Part of #212.
Scope
Extract all code generation from stackbilt-web/src/lib/scaffold-core.ts into packages/scaffold-core/src/codegen/. This is the largest module — approximately 1,000 lines of pattern-specific file generation logic.
Files to create
| File |
Source |
Responsibility |
routes.ts |
buildRoutes(), routeContent() |
Route list derivation from traits; per-pattern route handler bodies |
files.ts |
baseFiles() |
Orchestrator — assembles full ScaffoldFile[] from all generators |
wrangler.ts |
generateWranglerBindings() |
wrangler.toml binding block generation |
index.ts |
— |
Re-exports generateFiles(classification, governance, profile, intention) → ScaffoldFile[] |
Dependencies
classify/ (ClassifyResult, QualityProfile, traits)
governance/ (GovernanceDocs — governance files are included in the output file set)
Tests
Per-pattern file set assertions:
workers-saas produces D1 migration, tenant middleware, typed contract
stripe-webhook produces HMAC verifier, KV idempotency guard
ai-chat produces streaming handler, system prompt, cost cap middleware
cron-worker produces scheduled handler, idempotency cursor
- All patterns produce
wrangler.toml, src/worker.ts, package.json
Migrate stackbilt-web/src/lib/__tests__/scaffold-materializer-parity.test.ts here.
Part of #212.
Scope
Extract all code generation from
stackbilt-web/src/lib/scaffold-core.tsintopackages/scaffold-core/src/codegen/. This is the largest module — approximately 1,000 lines of pattern-specific file generation logic.Files to create
routes.tsbuildRoutes(),routeContent()files.tsbaseFiles()wrangler.tsgenerateWranglerBindings()index.tsgenerateFiles(classification, governance, profile, intention) → ScaffoldFile[]Dependencies
classify/(ClassifyResult, QualityProfile, traits)governance/(GovernanceDocs — governance files are included in the output file set)Tests
Per-pattern file set assertions:
workers-saasproduces D1 migration, tenant middleware, typed contractstripe-webhookproduces HMAC verifier, KV idempotency guardai-chatproduces streaming handler, system prompt, cost cap middlewarecron-workerproduces scheduled handler, idempotency cursorwrangler.toml,src/worker.ts,package.jsonMigrate
stackbilt-web/src/lib/__tests__/scaffold-materializer-parity.test.tshere.