Skip to content

docs: spec — templates create Cabinets, libraries extend them - #257

Open
oxedom wants to merge 2 commits into
mainfrom
docs/spec-templates-library-rework
Open

docs: spec — templates create Cabinets, libraries extend them#257
oxedom wants to merge 2 commits into
mainfrom
docs/spec-templates-library-rework

Conversation

@oxedom

@oxedom oxedom commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Design spec only. No code changes. Lowest priority of the three current specs.

The taxonomy

Two catalogs look alike but do different things:

  • TemplatePOST /api/registry/import scaffolds a new Cabinet. A bootstrap.
  • LibraryPOST /api/agents/library/[slug]/add copies one part into an existing Cabinet. An extend.

The boundary is the action, not the size of the thing. A single merged "Gallery" was considered and rejected: it hides the one distinction that matters at click time — does this create a Cabinet, or add to the one I'm in? See ADR-0003.

Today "template" means three different things in code and "getting started" means two.

Scope

  • Kill the template overload (resolveAgentTemplateDirresolveLibraryAgentDir, response keys, and the four duplicate LibraryTemplate declarations collapsed to one export). RegistryTemplate keeps its name — it's a genuine template.
  • Empty-state discovery: "+ Add from Agent Library" / "+ Add from Job Library" at the point of need.
  • A Templates sidebar rail entry next to Integrations.
  • Extend preview to the Home carousel.

What verification cut

Most of the draft. Checked line-by-line against the code:

  • Preview already exists. RegistryBrowser has rendered a full org chart from /api/registry/[slug] since before this spec — the route already returns agents[], jobs[], children[], and README. No manifest change needed. Only the Home carousel imports blind, so this work is a fraction of what was drafted.
  • Import is already transactional (github-fetch.ts:109-112, import/route.ts:82-86). The draft's "possible bug" was wrong.
  • /api/agents/library has three consumers, not two — the draft missed use-agent-picker.ts:27.

Cut from scope: the resources/getting-started rename

Production-breaking for too little value:

  • prepare-electron-package.mjs:252 hardcodes "getting-started", and its copyDirectory (:133-141) opens with if (!(await pathExists(fromPath))) return; — a missing source is a no-op, not an error. So the rename produces a green electron:make that ships a .seed with no guide content. No build error, no test failure.
  • Proof the drift is already live: :253 copies resources/example-cabinet-carousel-factory, which does not exist. It has been silently skipping for some time.

The bigger bug found underneath (follow-up, not fixed here)

seedGettingStartedDir is already a no-op in every packaged build. PROJECT_ROOT = process.cwd() (runtime-config.ts:5) is not derived from resourcesPath/__dirname, main.cjs spawns the standalone server with no cwd, and .next/standalone contains no resources/. Packaged installs seed one guide at the data root via .seed; dev seeds one per Cabinet. Dev and production have silently diverged, and any CI test of the seeder passes while proving nothing about production. Filed as its own issue — and it's the prerequisite that would make the rename cheap later.

A decision reversed

The draft said the tour-tail template path should "import into the empty Cabinet in place". That would let a failed download delete the user's Cabinet. targetPath is a parent path that 409s on an existing dir, and downloadRegistryTemplate rolls back with fs.rm(targetDir, { recursive: true, force: true }) — safe only because that path is always newly created. The spec now requires a distinct intoPath, server-side emptiness checks, temp-dir staging with merge-on-success, and a rollback that can only touch the temp dir.

Note

Depends on CONTEXT.md, which lands via #256 (the onboarding spec).

🤖 Generated with Claude Code

Splits the two catalogs on the action they perform: a Template creates a
new Cabinet, a Library adds parts to an existing one. Kills the three-way
"template" overload in code, adds empty-state discovery and a Templates
sidebar entry, and extends preview to the Home carousel.

Verification cut most of the draft. Registry preview already exists,
import is already transactional, and the getting-started rename is
production-breaking for too little value, so it is out of scope. The
draft's "import into the empty Cabinet" decision is reversed: it would
have let a failed download rm -rf the user's Cabinet.

Adds ADR-0003 recording why the two catalogs are not merged into one
Gallery.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@oxedom
oxedom requested a review from a team as a code owner July 16, 2026 11:31
The paragraph described how the directory rename would behave on user
disks, which contradicts the section immediately above it stating the
rename is out of scope.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant