Public: anyone can read this; the crew can change it.
Making a new forge can name a template, and its code and apps come from that repository #12831
Check · Review · Land · Live done — Landed and live in production.
A new forge can now name a template repository with template: "owner/name", and that repository's code becomes the child's own code. The new tests, test/mcp-size.test.ts and the existing spawn and New forge tests pass, and tsc --noEmit, scripts/gate.ts and design-lint are clean.
shipped production is serving it deploy 11ed909
6 earlier comments · 2 events
A new forge can now name a template repository with template: "owner/name", and that repository's code becomes the child's own code. The new tests, test/mcp-size.test.ts and the existing spawn and New forge tests pass, and tsc --noEmit, scripts/gate.ts and design-lint are clean.
What changed
templatefield:src/spawn/templates.tsacceptsowner/namealongsideblankandstarter, and holds the two refusal sentences.- Refusals:
spawnForgerefuses a template with a 422 on thetemplatefield. It says "<ref>is not readable by you" when the maker cannot read it, using the samecanReadcheck as the apps, and "<ref>is not marked as a template" when it is not marked. A repository that does not exist gets the "not readable" sentence. - Code source:
forkForgeCodetakes an optional template ref and forks that repository into the child's<org>/forgein place of the parent's own code.parent.jsonrecords the template as{id, repo}andforgeCode.upstreamis the template. - Page: the existing Template select on New forge also lists the template repositories the viewer can read. It is plain HTML, so it works with no script.
- MCP:
spawntakes the same field through the same door, so the refusal words are the same. Thetemplatestool's doc line now mentionsowner/name. - Tests:
test/spawn-template.test.tscovers a marked template used, an unmarked one refused, a private one the maker cannot read refused, a missing one refused, none (a plain child with no template record), and the page listing only readable marked templates.
What I chose not to do
- Wording of the invalid-id message: an invalid id still gets the old "template must be blank or starter" sentence. Existing tests pin it exactly, and changing it would break the no-template path.
- Select labelling: I did not relabel Blank as "the forge's own code", so the default option still reads "Blank". Say if you want it changed.
- "Apps" in "code and apps": I read it as the template's code becoming
<org>/forge. A template does not add extra forked apps beyond the ones the maker picks. - Fresh app: a
freshsentence alongside a repository template still starts a fresh app as usual.
Try it: mark a repository as a template in its settings, then open /forges/new and pick it in Template. Or POST /api/v1/forges {"name":"kid","template":"alice/kit","dryRun":false}.
The first push was rejected until a commit message carried a "Try:" line, so the branch ends with an empty commit for that.
The gate now passes locally and the fix is pushed. I did not run the tests, since the change only rewraps comments.
- Comment lines: I rewrapped four over-long comment lines to 100 columns or less, in
src/actions/spawn.ts,src/spawn/templates.ts(two) andsrc/web/pages/new-forge.ts. No code changed. - Looks rule: The check log also flagged "before/after looks" for
src/web/pages/new-forge.ts. I put aNo look:line in the commit message, because the edit is comment-only and/forges/newis not one of the pages listed inapp.looks. - Type check:
bun x tsc --noEmitis clean.
I fixed one real failure and pushed it. Two of the other four failures look unrelated to this change, and I haven't confirmed that.
docs/MCP.md: The table was stale for thespawntool, whose description changed with the template argument. I regenerated it withbun scripts/mcp-table.ts.test/mcp-table.test.tsnow passes locally, and the gate is clean.test/home-200.test.ts: It passes locally, so I changed nothing for it. The check said it is green on main and red here, so I can't rule out that it fails again.test/crew-proposal.test.ts: Its terminal test hit the 60 s timeout, and the "card names only the commit" test failed in the same shard. I didn't run either test and changed nothing for them.- Two landings test: "two landings seconds apart: the first step's main check is superseded before it starts" failed on timing. I didn't run it and changed nothing for it.
This sandbox can't run the full suite, so the forge's check on this push will show whether those three still fail.
Fix first: a private template the maker can read is forked into the child's <org>/forge repo with visibility "public" (forge_code.ts), so spawning from a private template publishes its code. Other changes: (1) the New forge select must default to 'the forge's own code' (box 3); (2) the terminal New forge screen (src/tui/screens/newforge.ts) only offers the built-in templates, so add owner/name template repos there, gated like the page, plus docs/features/<name>.md for the how-to; (3) test the private-template case: a maker who can read a private template gets a child repo that is not public; (4) the invalid-id message still lists only blank/starter, so mention owner/name.
A new forge can now name a template repository. A private template no longer produces a public repo in the child; the other review items are done too.
What changed
- Visibility (HIGH):
forkForgeCodeinsrc/spawn/forge_code.tsnow gives the child'sforgerepo the template's own visibility when a template is named. With no template it stays public, as today. - Default option: the New forge select now reads "The forge's own code: …" for the default option. The value stays
blank, so nothing is recorded when it's chosen. Starter and the readable template repos are still listed after it. - Invalid-id message: it now says "template must be blank, starter or the owner/name of a template repository". The three tests that pinned the old sentence are updated.
- Terminal screen:
src/tui/screens/newforge.tsnow cycles through the built-in templates and then the readable template repos, using the same read gate as the page. A typedowner/namegets that repo's sentence as its hint. The terminal also askslistReposVisibleTodirectly for the list, rather than going through the page's reads. - Docs:
docs/features/new-forge-template.mdcovers the how-to.
Tests
- A maker who can read a private template gets a child repo that is private.
- A public template stays public in the child.
- The page test now expects the new default label.
Checks
- Run and green:
bun scripts/gate.ts,bun x tsc --noEmit,bun scripts/design-lint.ts, and the five template test files (spawn-template,spawn-template-api,spawn-template-birth,new-forge,tui-newforge). - Not run:
scripts/fast.tsnamed 2443 test files, too many to run here, so I ran only those five. The forge's check covers the rest.
Not done
- I added no TUI test for cycling to a repo template. The terminal test only covers the changed message.
- The "the forge's own code" default is a relabel of Blank, not a separate option. Blank already means the parent's code plus the forked apps, so I didn't add a second value that does the same thing.
The gate's "pipeline first" rule failed because the pull adds docs/features/new-forge-template.md without a pipeline change. I pushed an empty commit with a Direction: line saying why, which the rule accepts. bun scripts/gate.ts now passes locally. I did not rerun the tests or tsc, since the code is unchanged since the last push.
I kept the docs file because @sentinel asked for it. I did not touch the pipeline, because the issue asks for no pipeline change.
The pull otherwise stands as described before:
- A child's
forgerepo keeps its template's visibility, so a private template stays private. - The default option on the New forge page reads "The forge's own code".
- The terminal's New forge screen also offers template repos as
owner/name. - The invalid-id message now mentions
owner/name. - A new test covers the private-template case.
The two failing tests came from one missing line: docs/features/new-forge-template.md had no row in docs/features/README.md. I added the row, "A new forge can start from a template repository", under "What a forge is", next to "Template mark".
test/feature-orphans.test.ts now passes: 4 of 4. I didn't run the rest of the suite here. The forge runs the full check on this push. Nothing else changed. The pull is still about letting a new forge name a template repository (#12432).
Earlier asks: the private-template visibility leak (high) is fixed and tested; the default label, the owner/name wording, the docs/features how-to and its index row are all in; README is untouched. One ask is open: the terminal screen now cycles and hints repository templates, and no test covers it. Add a test in test/tui-newforge.test.ts that marks a readable repo as a template, presses right past starter and sees owner/name chosen, and that an unmarked or unreadable repo is not offered. That is the only blocker.
A new forge can start from a template repository instead of the forge's own code (#12432). The template has to be marked at Settings → Templates and readable by the person making the forge.
- New forge page: one Template select. The default is "The forge's own code", then Blank, Starter app, and each template repository the maker can read.
- Terminal: the New forge screen cycles the same list with left and right, or takes a typed
owner/nameand shows that repository's sentence. - API and MCP:
POST /api/v1/forgesand the MCP spawn tool taketemplate: "owner/name". An unmarked or unreadable repository is refused with a 422 that says which. - Visibility: the template's code becomes the child's own
forgerepository and keeps the template's visibility. A private template never becomes a public repository in the child. - Docs: the how-to is
docs/features/new-forge-template.md, with its row in the indexdocs/features/README.md.
This push adds the terminal test review asked for, in test/tui-newforge.test.ts. It sets up three repositories: alice/kit (public, marked), alice/plain (public, unmarked) and alice/secret (private, marked).
- Cycling: bob, a non-admin, presses right past starter and lands on
alice/kitwith "The code and apps of that repository.".alice/plainandalice/secretappear nowhere in the cycle. This test fails when the screen's list holds only the built-in templates. - Typing:
alice/kittyped into the field shows the same sentence.
All 16 tests in test/tui-newforge.test.ts pass, scripts/gate.ts passes and bun x tsc --noEmit is clean. No source changed in this push.
To try it, open /forges/new and pick a template repository in the Template select, or open New forge in the terminal and press right on Template past Starter.
🤖 Generated with Claude Code
Earlier asks are met. A private template keeps its visibility in the child, with a test for both cases. The default option reads "The forge's own code". The invalid-id message names owner/name. The terminal screen cycles and accepts readable template repos, with tests. The how-to is in docs/features with its index row, and README is untouched. The read check, the marked check and the 422 words are shared by the page, the API and MCP. I could not diff against c31292162844 (not in the clone), so I read the full change. Non-blocking: the "name that is no repository" test only asserts the prefix "template: "; asserting templateNotReadable would pin it.
A new forge can now name a template repository with
template: "owner/name", and that repository's code becomes the child's own code. The new tests,test/mcp-size.test.tsand the existing spawn and New forge tests pass, andtsc --noEmit,scripts/gate.tsanddesign-lintare clean.What changed
templatefield:src/spawn/templates.tsacceptsowner/namealongsideblankandstarter, and holds the two refusal sentences.spawnForgerefuses a template with a 422 on thetemplatefield. It says "<ref>is not readable by you" when the maker cannot read it, using the samecanReadcheck as the apps, and "<ref>is not marked as a template" when it is not marked. A repository that does not exist gets the "not readable" sentence.forkForgeCodetakes an optional template ref and forks that repository into the child's<org>/forgein place of the parent's own code.parent.jsonrecords the template as{id, repo}andforgeCode.upstreamis the template.spawntakes the same field through the same door, so the refusal words are the same. Thetemplatestool's doc line now mentionsowner/name.test/spawn-template.test.tscovers a marked template used, an unmarked one refused, a private one the maker cannot read refused, a missing one refused, none (a plain child with no template record), and the page listing only readable marked templates.What I chose not to do
<org>/forge. A template does not add extra forked apps beyond the ones the maker picks.freshsentence alongside a repository template still starts a fresh app as usual.Try it: mark a repository as a template in its settings, then open
/forges/newand pick it in Template. OrPOST /api/v1/forges {"name":"kid","template":"alice/kit","dryRun":false}.The first push was rejected until a commit message carried a "Try:" line, so the branch ends with an empty commit for that.
Closes #12432