Repository navigation
Description
Problem
The machine-readable tests.commands of the packaged examples only run inside URLCode's own source checkout. listExamples, searchExamples and getExample (@jimhoyd/urlcode/agent-context) return them verbatim to consumers, including agents and the hosted URLCode AI tools. A consumer who runs them as given gets an error.
Inspected the published @jimhoyd/[email protected] package from a consumer project (URLCode AI, Node 26). Core main at the time was 2383b121.
| Examples | Count | Listed command form | Problem outside the source checkout |
|---|---|---|---|
| assets, aws, cloudflare, compliance, conditions, cookbook, coverage-waiver, egress, extensions, lifecycle, not-found, prerender, provider-conformance, shared-blocks, vercel | 15 | node packages/core/src/cli.ts … --project examples/<id> |
Neither packages/core/src/cli.ts nor examples/<id> exists relative to the consumer |
| body-validation, data-dir | 2 | urlcode … --project examples/<id> |
examples/<id> does not exist relative to the consumer |
| monitoring, tunnel | 2 | no commands | — |
Source: each example's example.yaml, for example examples/assets/example.yaml:11-14:
tests:
fixtures: tests/requests.json
commands:
- node packages/core/src/cli.ts validate --local --project examples/assetsRecipes don't have this problem: urlcode recipes add <name> --out <dir> copies a recipe into the consumer's directory, and its commands use --project .. Scaffolding each of the 14 recipes and running its listed commands verbatim, 10 pass once /operator/ points at a real directory. The rest need operator input, such as a host file or a <reviewed revision> placeholder.
Reproduction
From any directory with @jimhoyd/[email protected] installed:
npx urlcode validate --local --project examples/body-validation
# {"event":"error","message":"Project directory not found: \"examples/body-validation\"; ...","code":"no-project"}The examples are shipped, though. Pointing the same commands at the packaged copy works:
npx urlcode validate --local --project node_modules/@jimhoyd/urlcode/examples/body-validation # valid, 3 routes
npx urlcode test --project node_modules/@jimhoyd/urlcode/examples/body-validation # 13/13The same holds for conditions (11/11 with its --origin) and not-found (5/5).
Related gaps a consumer hits on the same path:
urlcode examplesoffers onlylist|search. There is no equivalent ofrecipes addto copy an example into a working directory.getExamplereturns at most two files. It returnsREADME.mdonly forcompliance, and nothing formonitoringandtunnel, so its content is not a runnable project on its own.
Impact
An agent that follows the example's documented commands gets a failed command. That adds to exactly the discovery/repair overhead that jimhoyd-com/urlcode-ai#85 measures. The hosted authoring kit in jimhoyd-com/urlcode-ai#104 now works around this: when an example's commands reference the source checkout, it replaces them with urlcode validate --local --project . / urlcode test --project . and a note. That is a consumer-side patch over data core owns.
Possible directions (for the owner to choose)
- Keep the monorepo commands for core's own CI, but expose consumer-runnable commands separately. Either separate fields (e.g.
tests.commandsvs. a consumer form) or have the public APIs resolveexamples/<id>to the installed package path. - Add
urlcode examples add <id> --out <dir>, mirroringrecipes add, and write example commands relative to--project .. - At minimum, have
getExample/listExamplessay that the listed commands assume the source checkout.
Acceptance
- Every command returned for a packaged example by the public agent-context and catalog APIs runs from a consumer project with only the published package installed, or is explicitly marked as requiring the source checkout or operator input.
- A packaged-integration test executes those consumer commands for each example that has fixtures.
Activity
fix(examples): make packaged examples' tests.commands run from a cons…