You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 135b8ea
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: .claude/rules/codegen-architecture.md
+8-1Lines changed: 8 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,7 +24,14 @@ interface Generator {
24
24
}
25
25
```
26
26
27
-
Helpers `perEntity()` and `oncePerRun()` cover the common "file per entity" / "one-shot" cases.
27
+
Helpers `perEntity()`, `perPackage()` and `perModel()` cover the per-object / per-package /
28
+
whole-model scopes (`oncePerRun()` is the deprecated alias of `perModel()`).
29
+
30
+
**Writing a generator of your own is the primary path** (ADR-0034 Amendment 4): `meta
31
+
generator new <name> [--scope entity|package|model]` writes a working one into
32
+
`codegen/generators/` and wires it into the config. Model reads an owned generator needs
33
+
are exported from the package root (`objectRefTarget`, `enumValues`, `servedPath`, the case
34
+
helpers); the guide and every port's shape are in `docs/recipes/write-your-own-generator.md`.
28
35
29
36
**Built-in factories**: `entityFile`, `queriesFile`, `routesFile`, `formFile`, `barrel`. Per ADR-0034 (scaffold-and-own) and its Amendment 2 (opt-in codegen), `meta init` scaffolds `codegen/generators/` EMPTY with `generators: []`; `meta gen --list --probe` is the catalog, and `meta eject <name>...` copies each chosen reference template into the consumer repo at `codegen/generators/*.ts` and prints the import and entry to wire. The owned copy is the ONLY import path for `entityFile`/`queriesFile`/`routesFile`/`barrel`: the deprecated `@metaobjectsdev/codegen-ts/generators` re-export of them was **removed at the 1.0 cut**.
Copy file name to clipboardExpand all lines: README.md
+13-8Lines changed: 13 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@ model. Your hand-written logic stays yours.
17
17
supposed to do — that your agent reads and writes. Two things happen to it:
18
18
19
19
-**Generate.** The boring parts are derived from it, in TypeScript, Java, Kotlin, C#
20
-
and Python — at build time by reference generators you copy into your repo and own,
20
+
and Python — at build time by generators you write or copy into your repo and own,
21
21
or at runtime from the live model. Nothing proprietary in the output.
22
22
-**Verify.** The build fails when generated code drifts from the model and when a
23
23
prompt's payload no longer matches what it's told — and it fails or warns when a
@@ -183,7 +183,7 @@ MetaObjects has two layers, and only the first is a promise
183
183
184
184
|| Core — guaranteed | Helpers — yours |
185
185
|---|---|---|
186
-
|**What**| The metamodel, loader, canonical format and registry; runtime metadata access (the `ObjectManager`, not the HTTP adapters that mount it); schema migrations (`meta migrate`); the drift gates (`meta verify`); prompt render and the reply parser | Every generator that writes application code into your repo: routes, controllers, ORM wiring, DTOs, forms, grids, hooks |
186
+
|**What**| The metamodel, loader, canonical format and registry; runtime metadata access (the `ObjectManager`, not the HTTP adapters that mount it); schema migrations (`meta migrate`); the drift gates (`meta verify`); prompt render and the reply parser | Every generator that writes code into your repo — the ones you write for the outputs you need, and the reference routes, controllers, ORM wiring, DTOs, forms, grids and hooks you copy|
187
187
|**Promise**| Conformance-gated, the same behaviour in every port that ships it, covered by the [compatibility policy](docs/compatibility-policy.md)| Reference starting points that compile and pass their reference fixtures. Copy one with `meta eject` and change it freely |
188
188
|**A defect is**| A MetaObjects bug, fixed in a release | A bug in the reference, fixed there; your copy is yours |
189
189
@@ -202,12 +202,17 @@ complete in all five ports; MCP exposure of declared prompts/tools is the one re
202
202
roadmap item. The fifth has been dogfooded on maintainer-owned projects only, and the
203
203
sixth ships two libraries at their own stability labels:
204
204
205
-
1.**Codegen***(reference generators you own, ejectable in every port)* — starting points that emit per-language
206
-
code (Drizzle/Zod + Fastify for TS, Spring REST + DTO + repository for Java,
207
-
`data class` + Exposed for Kotlin, EF Core record + ASP.NET routes for C#, Pydantic +
208
-
FastAPI for Python). Copy the ones you need, change them, and regenerate with
209
-
hand-edit-preserving three-way merge. The engine that runs them is core; their output
210
-
is yours.
205
+
1.**Codegen***(generators you write and own, in every port)* — on the core, you build
206
+
the generators your application needs: OpenAPI, JSON Schema, Zod, DTOs, a client,
207
+
docs — anything the model describes. A generator is a name plus a function from the
208
+
model to files, and `verify` gates it with nothing to register; `meta generator new
209
+
<name>` scaffolds a working one on TypeScript, and
210
+
[Write your own generator](docs/recipes/write-your-own-generator.md) has every port's
211
+
20-line shape plus JSON Schema and OpenAPI examples to copy. The reference generators
212
+
(Drizzle/Zod + Fastify for TS, Spring REST + DTO + repository for Java, `data class` +
213
+
Exposed for Kotlin, EF Core record + ASP.NET routes for C#, Pydantic + FastAPI for
214
+
Python) are starting points: eject the one that is close, change it, and regenerate.
215
+
The engine that runs generators is core; their output is yours.
211
216
2.**Runtime metadata** — load metadata at runtime, drive behavior dynamically
212
217
(CRUD, validation, relationships, dynamic admin UIs; typed tool payloads are
213
218
declared today, with MCP exposure on the roadmap).
0 commit comments