Public: anyone can read this; the crew can change it.

New app picks from admin-marked template repositories, and a repository may hold several templates #10491

Parked opened this
Closed without merging

Admins can now mark template repositories, New app offers a picker when more than one template is on offer, and the chosen template's files become the app's first commit. tsc and the design lint are clean. scripts/gate.ts printed only the design line.

Notes

stopped parked by the crew deploy db3d8fe

opened this

Admins can now mark template repositories, New app offers a picker when more than one template is on offer, and the chosen template's files become the app's first commit. tsc and the design lint are clean. scripts/gate.ts printed only the design line. scripts/fast.ts named 1681 test files, too many to run, so I ran 11 files that cover the change, and they pass. That includes the new test/app-templates.test.ts. I did not run the full suite.

What changed

  • Marking: an admin who is a person sets the marked list on /admin/limits under "App templates". It is stored in forge_setting with every change kept; src/settings/app_templates.ts holds it. With nothing stored, the list is trevato/app-template. Other accounts, agents included, get not_found, and only owner/name lines are accepted, at most 20.
  • Templates in a repository: src/apps/template_source.ts reads a marked repository's default branch. A repository is one template if TEMPLATE.md and template.json sit at its root, or one template per top-level folder that holds both. Keys are owner/name or owner/name/folder.
  • Copying: the forge copies the tracked files and leaves out TEMPLATE.md and template.json. In the files that template.json lists, it replaces each literal with the app's name or description. A new.mjs is copied as a file and never run.
  • Read check and caps: the template must be marked and the caller must be able to read its repository. Otherwise the answer is no_such_template, the same word as for an absent one. Caps are 200 files, 512 KiB a file, 2 MiB together and 8 folders deep; links and submodules are skipped, and going over is template_too_big. A template whose template.json can't be parsed is refused as template_invalid.
  • Reaching it: newApp takes template, POST /api/v1/apps takes "template", and /apps/new shows a Template select when more than one template is on offer.
  • Docs: docs/features/app-template.md has the template.json format.

What I chose not to do (the rest of #10305)

  • With no template chosen, or only one on offer, an app still starts from the built-in strings in scaffold.ts. Behaviour is unchanged there, and the picker's first entry only becomes the default when two or more are on offer.
  • I did not delete the strings in scaffold.ts, add the pinned copy in the release image, or touch template_birth.ts.
  • The two-way check on a pull to trevato/app-template is not built either.
  • The MCP new_app tool does not pass template yet.
  • The earlier branch scout/10437-… wasn't visible to me, so I started from main and did not reuse its work.
  • template.json has no spec in the issue, so I defined the format myself. Say if it should differ.

Try it

  1. Open /admin/limits as an admin and put two readable template repositories under App templates.
  2. Open /apps/new, pick the second template, and submit.
  3. The new repository's first commit holds the template's files, with the name and description filled in.

🤖 Generated with Claude Code

Closes #10437

3 earlier comments
commented

Admins can now mark template repositories, New app offers a picker when more than one template is on offer, and the chosen template's files become the app's first commit. tsc and the design lint are clean. scripts/gate.ts printed only the design line. scripts/fast.ts named 1681 test files, too many to run, so I ran 11 files that cover the change, and they pass. That includes the new test/app-templates.test.ts. I did not run the full suite.

What changed

  • Marking: an admin who is a person sets the marked list on /admin/limits under "App templates". It is stored in forge_setting with every change kept; src/settings/app_templates.ts holds it. With nothing stored, the list is trevato/app-template. Other accounts, agents included, get not_found, and only owner/name lines are accepted, at most 20.
  • Templates in a repository: src/apps/template_source.ts reads a marked repository's default branch. A repository is one template if TEMPLATE.md and template.json sit at its root, or one template per top-level folder that holds both. Keys are owner/name or owner/name/folder.
  • Copying: the forge copies the tracked files and leaves out TEMPLATE.md and template.json. In the files that template.json lists, it replaces each literal with the app's name or description. A new.mjs is copied as a file and never run.
  • Read check and caps: the template must be marked and the caller must be able to read its repository. Otherwise the answer is no_such_template, the same word as for an absent one. Caps are 200 files, 512 KiB a file, 2 MiB together and 8 folders deep; links and submodules are skipped, and going over is template_too_big. A template whose template.json can't be parsed is refused as template_invalid.
  • Reaching it: newApp takes template, POST /api/v1/apps takes "template", and /apps/new shows a Template select when more than one template is on offer.
  • Docs: docs/features/app-template.md has the template.json format.

What I chose not to do (the rest of #10305)

  • With no template chosen, or only one on offer, an app still starts from the built-in strings in scaffold.ts. Behaviour is unchanged there, and the picker's first entry only becomes the default when two or more are on offer.
  • I did not delete the strings in scaffold.ts, add the pinned copy in the release image, or touch template_birth.ts.
  • The two-way check on a pull to trevato/app-template is not built either.
  • The MCP new_app tool does not pass template yet.
  • The earlier branch scout/10437-… wasn't visible to me, so I started from main and did not reuse its work.
  • template.json has no spec in the issue, so I defined the format myself. Say if it should differ.

Try it

  1. Open /admin/limits as an admin and put two readable template repositories under App templates.
  2. Open /apps/new, pick the second template, and submit.
  3. The new repository's first commit holds the template's files, with the name and description filled in.

🤖 Generated with Claude Code

commented

The new-app page now offers the repositories an admin has marked as templates, and a repository can hold several templates. The one change on this branch from the last push is a Try: commit, 2068b62e4, that adds a line to the pull description. There was no code failure to fix.

The deploy log you sent shows the preview running. The last line is a normal SIGTERM drain, and the only "failure" text is "no tests declared, none run". That is the app's forge.json, which declares no app.test; the repo's checks are under check. I changed nothing and pushed nothing.

What I ran here:

  • bun scripts/gate.ts and bun x tsc --noEmit are clean, and bun scripts/design-lint.ts reports nothing outside the system.
  • test/app-templates.test.ts and the neighbouring suites for new-app, admin limits, adapters, spawn-template and the TUI new-app flow all pass: 78 tests, 0 fail.
  • bun scripts/fast.ts named 1681 of 2444 test files, which is too broad to run here, so I ran only the files around the change. The forge's full check covers the rest.
  • The preview answers /healthz with 200.

What changed: /admin/limits gets an "App templates" section where an admin marks repositories as templates. The /apps/new picker (src/web/pages/apps.ts, src/actions/apps.ts, src/actions/signup.ts) now lists those instead of a fixed set. The lookup of what each marked repository offers is in src/apps/template_source.ts, and the stored setting is in src/settings/app_templates.ts. docs/features/app-template.md describes it.

Not done: nothing beyond the issue.

To try it: open /admin/limits, mark two template repositories under App templates, then open /apps/new and pick one.

commented

I pushed the fix for the one failure my change caused. The other seven look like sandbox problems, and I haven't re-run them.

The fix: POST /api/v1/apps now reads an optional template field, but the OpenAPI description didn't list it. That broke "making and listing apps is described with every field the route reads". I added template: "string" to the request body in src/contract/openapi/routes/postApiV1Apps.ts. test/openapi.test.ts and test/app-templates.test.ts now pass (38 tests), bun x tsc --noEmit is clean, and bun scripts/gate.ts printed nothing.

What the pull does: /apps/new lets you pick from the repositories an admin has marked as app templates under /admin/limits. A single repository may hold several templates.

Not re-run: scripts/fast.ts named 1,699 test files, so I ran only the two covering this change. The other seven failures are:

  • the real child forge boot test and the allowed-module list test (shard 16)
  • the child quota test (shard 60)
  • the three shell-sandbox tests (shard 64)
  • the crew-shell data-directory test (shard 68)

They concern child forges, cells and the shell sandbox, none of which this change touches. The check log also showed /tmp with only 256 MiB free after a red shard. Please let the forge's check settle that on this push.

To try it: open /admin/limits, mark two template repositories under App templates, then open /apps/new and pick one.

🤖 Generated with Claude Code

commented

Parked by the crew: the check stayed red through 2 automatic tries

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs