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

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

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.

Notes

shipped production is serving it deploy 11ed909

opened this

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

  • template field: src/spawn/templates.ts accepts owner/name alongside blank and starter, and holds the two refusal sentences.
  • Refusals: spawnForge refuses a template with a 422 on the template field. It says "<ref> is not readable by you" when the maker cannot read it, using the same canRead check 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: forkForgeCode takes an optional template ref and forks that repository into the child's <org>/forge in place of the parent's own code. parent.json records the template as {id, repo} and forgeCode.upstream is 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: spawn takes the same field through the same door, so the refusal words are the same. The templates tool's doc line now mentions owner/name.
  • Tests: test/spawn-template.test.ts covers 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 fresh sentence 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.

Closes #12432

6 earlier comments · 2 events
commented

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

  • template field: src/spawn/templates.ts accepts owner/name alongside blank and starter, and holds the two refusal sentences.
  • Refusals: spawnForge refuses a template with a 422 on the template field. It says "<ref> is not readable by you" when the maker cannot read it, using the same canRead check 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: forkForgeCode takes an optional template ref and forks that repository into the child's <org>/forge in place of the parent's own code. parent.json records the template as {id, repo} and forgeCode.upstream is 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: spawn takes the same field through the same door, so the refusal words are the same. The templates tool's doc line now mentions owner/name.
  • Tests: test/spawn-template.test.ts covers 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 fresh sentence 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.

commented

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) and src/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 a No look: line in the commit message, because the edit is comment-only and /forges/new is not one of the pages listed in app.looks.
  • Type check: bun x tsc --noEmit is clean.
commented

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 the spawn tool, whose description changed with the template argument. I regenerated it with bun scripts/mcp-table.ts. test/mcp-table.test.ts now 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.

Changes requested — before the latest push

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.

commented

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): forkForgeCode in src/spawn/forge_code.ts now gives the child's forge repo 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.ts now cycles through the built-in templates and then the readable template repos, using the same read gate as the page. A typed owner/name gets that repo's sentence as its hint. The terminal also asks listReposVisibleTo directly for the list, rather than going through the page's reads.
  • Docs: docs/features/new-forge-template.md covers 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.ts named 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.
commented

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 forge repo 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.
commented

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).

Changes requested — before the latest push

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.

commented

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/name and shows that repository's sentence.
  • API and MCP: POST /api/v1/forges and the MCP spawn tool take template: "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 forge repository 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 index docs/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/kit with "The code and apps of that repository.". alice/plain and alice/secret appear nowhere in the cycle. This test fails when the screen's list holds only the built-in templates.
  • Typing: alice/kit typed 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

Approved

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.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs