Summary
Integrate Prisma generator into the official Forge compile pipeline.
Motivation
The Prisma generator exists but cannot be accessed through the official CLI. A generator that is not integrated into the compile workflow is incomplete and untested in production.
Current state:
forge compile
# Output: generated/openapi.json, generated/nest/, etc.
# Missing: Prisma schema
Target state:
forge compile
# Output: generated/openapi.json, generated/nest/, generated/prisma/schema.prisma
Technical Design
CLI Integration Points
The compiler pipeline must:
- Instantiate PrismaGenerator
- Pass DatabaseSchema IR to generator
- Write generated schema.prisma to output folder
- Report success/failure
Generated Structure
project/
├── src/
├── generated/
│ ├── openapi.json
│ ├── nest/
│ │ ├── controllers/
│ │ ├── dto/
│ │ └── services/
│ └── prisma/ ← NEW
│ └── schema.prisma
└── forge.config.json
Configuration
forge.config.json:
{
"contracts": "./contracts/**/*.forge",
"output": "./generated",
"generators": {
"typescript": true,
"jsonSchema": true,
"zod": true,
"nestjs": true,
"openapi": true,
"prisma": true
}
}
Acceptance Criteria
Example Usage
Command
$ forge compile
✓ Parsing contracts
✓ Building semantic model
✓ Generating TypeScript
✓ Generating JSON Schema
✓ Generating Zod validators
✓ Generating NestJS
✓ Generating OpenAPI spec
✓ Generating Prisma schema
✓ All generators completed in 240ms
Output
generated/
├── index.ts
├── openapi.json
├── nest/
│ ├── controllers/
│ ├── dto/
│ └── services/
└── prisma/
└── schema.prisma
Files to Create/Modify
New Files:
tests/prisma-cli.test.mjs (NEW)
Modified Files:
packages/cli/src/commands/compile.ts (MODIFY - invoke Prisma generator)
packages/compiler/src/index.ts (MODIFY - if wrapper needed)
tests/cli.test.mjs (MODIFY - add Prisma output verification)
Test Strategy
Create integration test suite tests/prisma-cli.test.mjs:
CLI Tests
Validation Tests
Error Handling
Non-Goals
Out of scope (future phases):
prisma migrate integration
prisma db push integration
prisma studio launching
- Automatic database provisioning
- Provider selection UI
Future Extensions
Phase 2 (v0.3):
- Provider configuration (postgres/mysql/sqlite selection)
- Migration generation from schema diffs
Phase 3 (v0.4):
- Prisma client code generation
- Database seeding scripts
- Relationship handling
Implementation Notes
- Generator pipeline order: execute after Semantic Model but before output summary
- Output path: respect
config.output setting
- File permissions: schema.prisma should be readable/writable
- Error reporting: include line numbers from source contracts
Success Criteria
✅ Prisma fully integrated into official compile workflow
✅ No special commands needed (just forge compile)
✅ Schema generation transparent and automatic
✅ Unblocks database layer in generated applications
Summary
Integrate Prisma generator into the official Forge compile pipeline.
Motivation
The Prisma generator exists but cannot be accessed through the official CLI. A generator that is not integrated into the compile workflow is incomplete and untested in production.
Current state:
Target state:
forge compile # Output: generated/openapi.json, generated/nest/, generated/prisma/schema.prismaTechnical Design
CLI Integration Points
The compiler pipeline must:
Generated Structure
Configuration
forge.config.json:
{ "contracts": "./contracts/**/*.forge", "output": "./generated", "generators": { "typescript": true, "jsonSchema": true, "zod": true, "nestjs": true, "openapi": true, "prisma": true } }Acceptance Criteria
forge compilecommand invokes Prisma generationgenerated/prisma/Example Usage
Command
$ forge compile ✓ Parsing contracts ✓ Building semantic model ✓ Generating TypeScript ✓ Generating JSON Schema ✓ Generating Zod validators ✓ Generating NestJS ✓ Generating OpenAPI spec ✓ Generating Prisma schema ✓ All generators completed in 240msOutput
Files to Create/Modify
New Files:
tests/prisma-cli.test.mjs(NEW)Modified Files:
packages/cli/src/commands/compile.ts(MODIFY - invoke Prisma generator)packages/compiler/src/index.ts(MODIFY - if wrapper needed)tests/cli.test.mjs(MODIFY - add Prisma output verification)Test Strategy
Create integration test suite
tests/prisma-cli.test.mjs:CLI Tests
forge compilesucceeds with Prisma generatorgenerated/prisma/schema.prismaValidation Tests
Error Handling
Non-Goals
Out of scope (future phases):
prisma migrateintegrationprisma db pushintegrationprisma studiolaunchingFuture Extensions
Phase 2 (v0.3):
Phase 3 (v0.4):
Implementation Notes
config.outputsettingSuccess Criteria
✅ Prisma fully integrated into official compile workflow
✅ No special commands needed (just
forge compile)✅ Schema generation transparent and automatic
✅ Unblocks database layer in generated applications