Skip to content

Commit 3e9a234

Browse files
authored
site: getting-started now shows the generators are yours to own (#2)
* site: getting-started now shows the generators are yours to own The scaffold tree and the metaobjects.config.ts example both described an older, smaller `meta init` scaffold, and between them they silently contradicted the codegen doctrine (FR-040): generated code is a starting point adopters copy and own, not something the package hands down. Scaffold tree: add `codegen/generators/` with its four owned copies (entity, queries, routes, barrel) and the `src/db.ts` throwing stub, plus a short paragraph making the ownership point explicit — `meta gen` runs the local copies, not the package's. Config example: show the real local import lines, which is the only thing that tells a reader those four functions come from editable files in their own repo, and keep enough of the scaffolded comment to carry that. Adds the extStyle/dbImport/apiPrefix/docs keys the scaffold actually writes, and drops the commented-out `formFile()` line — it is not part of the scaffolded set. `meta eject` gets one mention in its place, since that is the real way to take ownership of a generator init skips. Also seeds AGENTS.md: llms.txt/llms-full.txt are generated and must not be hand-edited here, these blocks mirror the CLI's init and drift silently, and the hand-written gs-code spans need a render check. The video transcript already stated the doctrine correctly and is unchanged. * docs(agents): state the llms.txt situation accurately The note I added claimed deploy.yml already copies llms.txt/llms-full.txt in from the monorepo's docs/llms/. It does not — deploy.yml generates www/reference/ and nothing else. The copy is planned, not landed. Say so plainly: they are still committed files today, but treat them as read-only here, because hand-edits will be silently overwritten once the copy lands. Also records www/reference/ as the one thing that IS generated at deploy time today. An agent-memory file that asserts things about its own repo that aren't true is worse than no note at all.
1 parent ba16a4b commit 3e9a234

3 files changed

Lines changed: 74 additions & 9 deletions

File tree

AGENTS.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Project agent memory
2+
3+
This file is the project's committed home for project-intrinsic agent knowledge: build, test, release, architecture, and sharp-edge notes that should travel with the code.
4+
5+
## Generated files — do not hand-edit
6+
7+
- `www/reference/` is generated at deploy time (`.github/workflows/deploy.yml` clones the
8+
public reference implementation and runs `meta docs`). Anything committed there is
9+
replaced on every deploy.
10+
- `www/llms.txt` and `www/llms-full.txt` are **becoming** generated output, copied in from
11+
the MetaObjects monorepo's `docs/llms/`. As of this writing `deploy.yml` does not copy them
12+
yet — they are still committed files — but treat them as read-only here: once the copy
13+
lands, hand-edits made in this repo are silently overwritten. Fix them upstream instead.
14+
15+
## Content that mirrors the CLI
16+
17+
Several code blocks on `www/getting-started.html` reproduce what `meta init` actually writes
18+
— the scaffold tree, and the `metaobjects.config.ts` example. Nothing checks that they still
19+
match, so they drift silently when the CLI's scaffold changes. The authoritative source is
20+
the monorepo's `server/typescript/packages/cli/src/commands/init.ts` (the
21+
`SCAFFOLDED_GENERATOR_NAMES`, `OWNED_GENERATORS_DIR`, `buildMetaobjectsConfigBody`, and
22+
`DB_STUB_*` constants). Read it before changing those blocks; don't work from memory.
23+
24+
The page also carries a doctrinal claim worth keeping intact: the generators under
25+
`codegen/generators/` are copied into the adopter's repo for them to **own and edit**, and
26+
`meta gen` runs those local copies rather than the packaged ones. `www/video/getting-started.vtt`
27+
states the same thing — if a page edit contradicts it, the page is the thing that is wrong.
28+
29+
## Editing the `pre.gs-code` blocks
30+
31+
`www/getting-started.html` hand-writes its syntax highlighting with `<span class="c">`
32+
(comment), `s` (string), `k` (keyword), `n` (the `NEW` marker). An unclosed span or a
33+
misaligned comment column does not show up in a diff review — render the page and look at
34+
the block before calling an edit done. In the scaffold tree, the `#` comments all sit at
35+
visible column 33.

CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
AGENTS.md

www/getting-started.html

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,18 @@ <h3>Set up the project and the agent context</h3>
7777
<p>Add the TypeScript CLI and scaffold the workspace. <code>meta init</code> also teaches your coding agent how to use MetaObjects:</p>
7878
<pre class="gs-code">npm i <span class="s">@metaobjectsdev/cli</span>
7979
npx meta init</pre>
80-
<p>That writes a small, legible tree — <strong>your models go in <code>metaobjects/</code></strong>:</p>
80+
<p>That writes a small, legible tree — <strong>your models go in <code>metaobjects/</code></strong>,
81+
and the code generators land in your repo too:</p>
8182
<pre class="gs-code"><span class="c">your-project/</span>
8283
├── metaobjects/ <span class="c"># ← your models live here (.yaml or .json)</span>
8384
│ └── meta.common.json <span class="c"># starter file (shared abstracts)</span>
85+
├── codegen/generators/ <span class="c"># ← the code generators — YOURS to edit</span>
86+
│ ├── entity.ts <span class="c"># Drizzle table + Zod schemas</span>
87+
│ ├── queries.ts <span class="c"># typed data-access</span>
88+
│ ├── routes.ts <span class="c"># REST endpoints (Fastify)</span>
89+
│ └── barrel.ts <span class="c"># the index.ts re-exports</span>
8490
├── metaobjects.config.ts <span class="c"># ← targets: dialect + what to generate</span>
91+
├── src/db.ts <span class="c"># throwing stub — swap in your DB connection</span>
8592
├── CLAUDE.md <span class="c"># wired to auto-load the context below</span>
8693
├── .metaobjects/ <span class="c"># tool state + agent docs (AGENTS.md, CLAUDE.md)</span>
8794
└── .claude/skills/ <span class="c"># six skills your agent now has:</span>
@@ -91,6 +98,10 @@ <h3>Set up the project and the agent context</h3>
9198
├── metaobjects-prompts/ <span class="c"># typed LLM prompts</span>
9299
├── metaobjects-verify/ <span class="c"># drift checks</span>
93100
└── metaobjects-audit/ <span class="c"># check adoption depth</span></pre>
101+
<p>Those four generators under <code>codegen/generators/</code> are the point: they're plain
102+
TypeScript, copied into your project, and <strong>yours to edit</strong>. <code>meta gen</code>
103+
runs those local copies — not the ones inside the package — so changing the shape of the
104+
generated code is an ordinary edit to a file you own.</p>
94105
</div>
95106
</div>
96107
</section>
@@ -138,19 +149,37 @@ <h2 class="section-label">3 · Pick your language</h2>
138149
</tbody>
139150
</table>
140151
<p class="gs-note">For TypeScript, <code>metaobjects.config.ts</code> chooses <em>what</em> you generate — the SQL
141-
<code>dialect</code> and which <code>generators</code> run:</p>
152+
<code>dialect</code> and which <code>generators</code> run. Note where those generators come from:
153+
<code>./codegen/generators/</code>, in your repo. Here's what <code>meta init</code> writes, with its
154+
longer comments trimmed:</p>
142155
<pre class="gs-code"><span class="c">// metaobjects.config.ts</span>
156+
import { defineConfig } from <span class="s">"@metaobjectsdev/cli"</span>;
157+
<span class="c">// meta init copied these reference templates into ./codegen/generators/ —</span>
158+
<span class="c">// they are YOURS to edit, and meta gen runs from these local copies, not</span>
159+
<span class="c">// from the package.</span>
160+
import { entityFile } from <span class="s">"./codegen/generators/entity.js"</span>;
161+
import { queriesFile } from <span class="s">"./codegen/generators/queries.js"</span>;
162+
import { routesFile } from <span class="s">"./codegen/generators/routes.js"</span>;
163+
import { barrel } from <span class="s">"./codegen/generators/barrel.js"</span>;
164+
143165
export default defineConfig({
144-
outDir: <span class="s">"src/generated"</span>,
145-
dialect: <span class="s">"sqlite"</span>, <span class="c">// sqlite | postgres | d1</span>
166+
outDir: <span class="s">"src/generated"</span>,
167+
extStyle: <span class="s">"js"</span>, <span class="c">// ".js" import suffixes — right for Node ESM + tsc</span>
168+
dialect: <span class="s">"sqlite"</span>, <span class="c">// sqlite | postgres | d1</span>
169+
dbImport: <span class="s">"../db"</span>, <span class="c">// the src/db.ts stub — swap in your real DB</span>
170+
apiPrefix: <span class="s">""</span>, <span class="c">// set to "/api" to mount the routes under /api</span>
146171
generators: [
147-
entityFile(), <span class="c">// Drizzle table + Zod schemas + typed constants</span>
148-
queriesFile(), <span class="c">// typed data-access (findById, list, create…)</span>
149-
routesFile(), <span class="c">// REST endpoints (Fastify)</span>
150-
<span class="c">// formFile(), // opt-in: React form components</span>
151-
barrel(),
172+
entityFile(), <span class="c">// Drizzle table + Zod schemas + typed constants</span>
173+
queriesFile(), <span class="c">// typed data-access (findById, list, create…)</span>
174+
routesFile(), <span class="c">// REST endpoints (Fastify)</span>
175+
barrel(), <span class="c">// src/generated/index.ts re-exports</span>
152176
],
177+
docs: { outDir: <span class="s">"./docs"</span>, surfaces: [<span class="s">"model"</span>, <span class="s">"api"</span>] },
153178
});</pre>
179+
<p class="gs-note">Those four are what <code>meta init</code> wires up. There are more — React forms,
180+
TanStack hooks and grids, Hono routes — and you take ownership of one the same way:
181+
<code>meta eject --list</code> shows what's available, and <code>meta eject form</code> copies it
182+
into <code>codegen/generators/</code> and prints the import line to wire up.</p>
154183
</section>
155184

156185
<section>

0 commit comments

Comments
 (0)