Skip to content

feat(recipes): recipes add --project merges a recipe into an existing site - #1023

Merged
jimhoyd merged 4 commits into
mainfrom
claude/recipes-add-into-1014
Sep 30, 2026
Merged

jimhoyd merged 4 commits into
mainfrom
claude/recipes-add-into-1014

Conversation

@jimhoyd

@jimhoyd jimhoyd commented Sep 30, 2026

Copy link
Copy Markdown
Collaborator

Fixes #1014

What changed

urlcode recipes add <name> --project <dir> merges a bundled recipe into an existing project (a site's app/), instead of the files being copied by hand. --out still creates a new standalone project; exactly one of the two is required. The flag is --project, as every other command names the project; --into already means something else (artifacts stage).

The merge (packages/core/src/recipe-merge.ts, SDK mergeRecipe):

  • Routes declared in the recipe's urlcode.yaml are added to the project's urlcode.yaml. Includes (routes/auth.yaml) are written and appended to includes. An identical existing include file (the one extensions add auth wrote) is not a clash and is not written.
  • Extension config: each entry of a mapping under extensions.<name>.config (collections.bookings, the staff membership collection) is a unit. It is added if missing, left alone if identical, and a clash if it differs. Other top-level mappings (site.spa) merge the same way.
  • Other files (functions, pages, static files) are copied unless identical. README.md is not copied (recipes show prints it).
  • Fixtures are appended to tests/requests.json, one per line as the recipes write them. Fixtures have no id, so an identical fixture is skipped, and the same request with different expectations is a clash.
  • Seed: accounts are merged by id, and membership lists as a union.
  • tests/audit.json: expectRoutes moves by the routes the merge added, measured from the project as loaded after the write.
  • Refusals:
    • Any clash (route, config entry, include or other file, seed id, fixture) refuses everything, with code recipe-clash. Every clash is named, and nothing is written.
    • A recipe whose extensions the project does not declare is refused with code recipe-needs-extension, naming urlcode extensions add auth store.
  • Output: it prints JSON of what it changed (routes, includes, extensions, settings, files, fixtures, seed, expectRoutes, written), the recipe's inputs as notes, and the validate/test/audit commands to run next. --dry-run writes nothing.
  • Atomic: dependencies are written first and urlcode.yaml last, then the project is loaded again. Any failure restores every changed file and removes every created file and directory. Paths through a symlink are refused.
  • YAML formatting: urlcode.yaml is edited in place with the helpers extensions add uses. New entries are spliced after the existing ones, with the recipe's own comments, and every other line stays byte-identical; checkedYamlEdit refuses rather than reformats. yamlInsertEntry gained an optional pre-rendered block, so an empty routes: {} / collections: {} opens into block YAML instead of one long flow line. extensions add behaves exactly as before (it passes no block).

plan-feature: the new commands field is the next step when a recipe applies: urlcode extensions add for missing extensions, then urlcode recipes add <recipe> --project <dir>. Before a site exists, it is urlcode init <directory> --with ... and the merge into <directory>/app. next stays canonical MCP tool names.

Docs:

  • docs/RECIPES.md has a new section, "Adding a recipe to an existing project".
  • TOOLING.md (plan-feature commands, and a pointer from MCP add_recipe), AI-AUTHORING.md, llms.txt and the regenerated llms-full.txt.
  • The starter AGENTS.md, via agents-guide.ts, and skills/urlcode/SKILL.md.
  • The five auth recipe READMEs now say recipes add ... --project app instead of "copy these files and set expectRoutes".

Evidence

  • test/recipe-merge.test.ts:
    • Two recipes (json-endpoint, redirect) merged into a starter app/ validate, test and audit ready. The audit count moves 0 → 2 → 4.
    • Re-adding a recipe writes nothing.
    • static-page + contact-form is refused, naming route / and file app/public/index.html, with every file byte-identical.
    • Collection, route, include, seed-id and fixture clashes are each named.
    • A missing extension is refused, naming the command.
    • --out/--project are exclusive.
    • Project comments are kept.
    • A failed write (read-only tests/) restores everything and removes the created functions/.
  • packages/store/test/recipes.test.ts:
    • store-booking, store-credits and store-approval are each merged into an init + extensions add auth store site with the real auth and store extensions. Each passes validate --local, test (twice) and audit ready with --local-review, with the count from tests/audit.json.
    • store-booking + protected-download in one site pass. A changed bookings collection refuses a re-add, naming it, with nothing written.
  • test/addons.integration.ts runs the same three merges through real urlcode init and urlcode extensions add auth store (npm-packed core and add-ons): validate, test and audit ready. Passed locally.
  • plan-feature test for commands, with and without a project.
  • npm run verify: pass (local, macOS, Node 26.10), before the final merge of main; the recipe-merge, feature-plan, CLI and store recipe tests and npm run check rerun green after it
  • npm run test:package: pass (39 packaged example commands, starter and cookbook checks)
  • Package budgets: core measures 1075082/4241215/546, inside the current limits, so the table is unchanged.

Limitations

  • Two auth recipes whose fixtures together sign in more than ten times merge cleanly but fail urlcode test with 429. The auth extension keeps Better Auth's sign-in rate limit (10/min) on in hermetic runs. store-booking + store-credits is one such pair. Filed as [Bug]: a site whose fixtures sign in more than ten times fails urlcode test with 429 (Better Auth rate limit in hermetic runs) #1019 and documented in RECIPES.md; the two-recipe test uses store-booking + protected-download.
  • MCP has no merge tool: add_recipe still creates a new directory, and TOOLING.md points to the CLI.
  • An extension declared in an include file (not urlcode.yaml) is refused when the merge would need to edit it. So is a urlcode.yaml layout the in-place edit cannot handle.
  • A new include that declares its own extensions is only caught by the post-write load, which rolls back; it is not reported as a named clash. No bundled recipe does this.

🤖 Generated with Claude Code

@jimhoyd
jimhoyd enabled auto-merge (squash) September 30, 2026 00:47
@jimhoyd
jimhoyd merged commit 0017bcc into main Sep 30, 2026
26 checks passed
@jimhoyd
jimhoyd deleted the claude/recipes-add-into-1014 branch September 30, 2026 00:58
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.

recipes add --into: merge a recipe into an existing site instead of copying files by hand

1 participant