Spaces:
Running
Running
File size: 4,351 Bytes
22b729d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 | // OFFLINE FALLBACK ONLY. The build flow downloads the engine's real bundle zip (/bundles/{id}
// /download) and shows the engine's file manifest; this reconstructs an equivalent bundle locally
// only when the API is unreachable, so the demo still produces a downloadable zip without a backend.
import type { BlueprintCandidate } from "@/types/blueprint";
import type { BundleFile } from "@/types/bundle";
import { AI_CODERS } from "./constants";
import { createCoderPrompt, bundleUrl } from "./coder-prompts";
export function createBundleFiles(
idea: string,
candidate: BlueprintCandidate,
bundleId: string,
): BundleFile[] {
const files: BundleFile[] = [];
files.push({
name: "README.md",
content: `# Matrix Bundle β ${candidate.name}
> A controlled build contract, not a vague prompt.
Idea: ${idea}
Blueprint: ${candidate.tier}
Bundle: ${bundleId}
Bundle URL: ${bundleUrl(bundleId)}
Stack: ${candidate.stack.join(", ")}
## How to build
1. Read MATRIX_BLUEPRINT.yaml.
2. Follow MATRIX_TASKS.md, one task at a time.
3. Stay inside MATRIX_ALLOWED_CHANGES.md.
4. Pass MATRIX_ACCEPTANCE_CRITERIA.md.
5. Run MATRIX_VALIDATION.md before finishing.
Send this bundle to an AI coder using one of the prompts in coder-prompts/.
`,
});
files.push({
name: "MATRIX_BLUEPRINT.yaml",
content: `apiVersion: matrix.builder/v1
kind: Blueprint
metadata:
name: ${candidate.name}
tier: ${candidate.tier.toLowerCase()}
bundle: ${bundleId}
idea: >
${idea}
stack:
${candidate.stack.map((item) => ` - ${item}`).join("\n")}
architecture:
frontend: ${candidate.stack.includes("React") ? "react" : "none"}
backend: fastapi
database: ${candidate.stack.includes("Postgres") ? "postgres" : "sqlite"}
deploy: ${candidate.stack.includes("K8s") ? "kubernetes" : "docker"}
`,
});
files.push({
name: "MATRIX_STANDARDS.lock",
content: `# Locked standards β do not edit
${candidate.standards.map((standard) => `- ${standard}`).join("\n")}
`,
});
files.push({
name: "MATRIX_TASKS.md",
content: `# Tasks β implement one at a time
## Task 01 β Project scaffold
Create the folder structure and entrypoints defined in MATRIX_BLUEPRINT.yaml.
## Task 02 β Core domain
Implement the core logic for: ${idea}.
## Task 03 β API surface
Expose the documented endpoints and OpenAPI contract.
## Task 04 β Tests and validation
Add tests and pass MATRIX_VALIDATION.md.
`,
});
files.push({
name: "MATRIX_ALLOWED_CHANGES.md",
content: `# Allowed changes
- Files under src/, app/, tests/, frontend/, backend/, worker/
- New routes that match MATRIX_BLUEPRINT.yaml
- Tests that prove the selected task works
# Forbidden
- Editing MATRIX_* control files
- New top-level dependencies not approved by MATRIX_STANDARDS.lock
- Changing the architecture
- Adding external SaaS, auth, background workers, or new databases without approval
`,
});
files.push({
name: "MATRIX_ACCEPTANCE_CRITERIA.md",
content: `# Acceptance criteria
- Current task implemented and tested
- Lints clean against MATRIX_STANDARDS.lock
- API matches the documented contract
- No secrets committed
- No forbidden files changed
`,
});
files.push({
name: "MATRIX_VALIDATION.md",
content: `# Validation
Run:
\`\`\`bash
make validate
\`\`\`
The build is approved only when validation passes with no architecture, dependency, or file-policy drift.
`,
});
files.push({
name: "docs/architecture.md",
content: `# Architecture
This project is generated from a Matrix Builder controlled blueprint.
- Idea: ${idea}
- Blueprint: ${candidate.name}
- Quality: ${candidate.tier}
- Engine: agent-generator
- Standard source: matrix-definitions
`,
});
files.push({
name: "docs/security.md",
content: `# Security
The AI coder must respect MATRIX_STANDARDS.lock and MATRIX_ALLOWED_CHANGES.md.
Forbidden changes include secrets, architecture drift, unapproved dependencies, and edits to MATRIX control files.
`,
});
files.push({
name: "docs/standards-report.md",
content: `# Standards report
${candidate.standards.map((standard) => `- ${standard}`).join("\n")}
`,
});
AI_CODERS.forEach((coder) => {
files.push({
name: `coder-prompts/${coder.id}.md`,
content: createCoderPrompt(coder.id, idea, candidate, bundleId),
});
});
return files;
}
|