Skip to content

fix(examples): packaged examples' tests.commands run from a consumer copy (#789) - #794

Merged
jimhoyd merged 1 commit into
mainfrom
claude/github-issue-789-f2eccf
Sep 26, 2026
Merged

jimhoyd merged 1 commit into
mainfrom
claude/github-issue-789-f2eccf

Conversation

@jimhoyd

@jimhoyd jimhoyd commented Sep 26, 2026

Copy link
Copy Markdown
Collaborator

Fixes #789.

Problem

Every packaged example's tests.commands named paths in the URLCode source checkout (node packages/core/src/cli.ts … --project examples/<id>, or --project examples/<id>). listExamples / searchExamples / getExample return those commands verbatim, so a consumer or agent running them got an error.

Change

  • urlcode examples add <id> --out <dir> [--dry-run] (SDK addExample, root export), mirroring recipes add. It copies every authoring-safe file of a runnable example, excluding catalog metadata (example.yaml, the cookbook's route-index.json). It lists the files an authoring copy refuses under omitted: .env.example, .gitattributes and .gitignore for assets, and .gitignore and package.json for cloudflare and vercel. A non-runnable example is refused.
  • Every example's commands are rewritten for the added directory (--project .), using the same convention recipes already use: a /operator/ path is an operator-owned location outside the project, and <...> marks operator input. The schema description and docs/RECIPES.md document this. The example READMEs are updated to match, since they travel with the copy.
  • npm run check refuses a recipe or example command that doesn't start with urlcode/node/npm/npx, or that names a source-checkout path (packages/, examples/, $PWD, …).
  • Packaged-integration test (scripts/package-smoke.ts): for each example with fixtures, it copies the example from the installed archive with examples add and runs every listed command verbatim. urlcode is the installed CLI and /operator/ is a scratch directory. Locally that is 39 commands, including data-dir's permissions/policy flow and prerender's node prerender.mjs.
  • getExample (MCP get_example) now returns add (the examples add command) for a runnable example. A non-runnable example returns all its files: monitoring and tunnel previously returned nothing.

Defects the new test surfaced

Nothing had ever run the listed audits of cloudflare and conditions, and both reported ready: false (uncovered HEAD methods).

  • cloudflare: added a /u/42 HEAD fixture.
  • conditions: added HEAD fixtures for /beta and /host. /limited HEAD is deliberately unmatched (its only case matches GET) and the fixtures assert its 404, so it gets a coveredElsewhere waiver with that reason. audit lists the waiver.

Evidence

  • npm run verify passed before the rebase onto v0.6.3: 946 core tests plus the workspace suites.
  • After the rebase: typecheck, lint, check (including docs checks), the recipes/conditions/cloudflare/exports/mcp suites (59/59) and npm run test:package all pass. The package smoke reports "39 packaged example commands ran from consumer copies".

Limitations

  • Examples without fixtures (compliance, egress, extensions, provider-conformance) aren't executed by the smoke test. Their commands are consumer-form, and they need operator input: a rules module, a host file or a deployment origin.
  • The cloudflare and vercel package.json files aren't copied (authoring copies refuse package.json), and they still declare @jimhoyd/urlcode: ^0.3.0. They aren't needed for validate/test/audit.

🤖 Generated with Claude Code

…umer copy (#789)

Every example's tests.commands named paths in the URLCode source checkout
(`node packages/core/src/cli.ts … --project examples/<id>`), so a consumer or
agent running them as returned by listExamples/getExample got an error.

- Add `urlcode examples add <id> --out <dir>` (SDK `addExample`), mirroring
  `recipes add`: copies every authoring-safe file of a runnable example and
  lists refused ones (dotfiles, package.json) under `omitted`.
- Rewrite every example's commands for the added directory (`--project .`);
  `/operator/` marks operator-owned paths, `<...>` operator input.
- `npm run check` refuses catalog commands that don't start with urlcode/node
  or name a source-checkout path.
- The package smoke test copies each example with fixtures from the packed
  archive and runs its commands verbatim (39 commands).
- getExample returns the `add` command for runnable examples and every file
  of a non-runnable one.
- Running the listed audits for the first time showed cloudflare and
  conditions were not ready: add their missing HEAD fixtures and a reasoned
  coverage waiver for /limited HEAD, which is deliberately unmatched.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@jimhoyd
jimhoyd enabled auto-merge (squash) September 26, 2026 16:54
@jimhoyd
jimhoyd merged commit f6ec567 into main Sep 26, 2026
30 checks passed
@jimhoyd
jimhoyd deleted the claude/github-issue-789-f2eccf branch September 26, 2026 16:55
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.

[Bug]: packaged examples' tests.commands only run inside the URLCode source checkout

1 participant