Repository navigation
fix(examples): packaged examples' tests.commands run from a consumer copy (#789) - #794
Merged
Merged
Conversation
…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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #789.
Problem
Every packaged example's
tests.commandsnamed paths in the URLCode source checkout (node packages/core/src/cli.ts … --project examples/<id>, or--project examples/<id>).listExamples/searchExamples/getExamplereturn those commands verbatim, so a consumer or agent running them got an error.Change
urlcode examples add <id> --out <dir> [--dry-run](SDKaddExample, root export), mirroringrecipes add. It copies every authoring-safe file of a runnable example, excluding catalog metadata (example.yaml, the cookbook'sroute-index.json). It lists the files an authoring copy refuses underomitted:.env.example,.gitattributesand.gitignorefor assets, and.gitignoreandpackage.jsonfor cloudflare and vercel. A non-runnable example is refused.--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 anddocs/RECIPES.mddocument this. The example READMEs are updated to match, since they travel with the copy.npm run checkrefuses a recipe or example command that doesn't start withurlcode/node/npm/npx, or that names a source-checkout path (packages/,examples/,$PWD, …).scripts/package-smoke.ts): for each example with fixtures, it copies the example from the installed archive withexamples addand runs every listed command verbatim.urlcodeis the installed CLI and/operator/is a scratch directory. Locally that is 39 commands, including data-dir's permissions/policy flow and prerender'snode prerender.mjs.getExample(MCPget_example) now returnsadd(theexamples addcommand) for a runnable example. A non-runnable example returns all its files:monitoringandtunnelpreviously returned nothing.Defects the new test surfaced
Nothing had ever run the listed audits of
cloudflareandconditions, and both reportedready: false(uncovered HEAD methods)./u/42HEAD fixture./betaand/host./limitedHEAD is deliberately unmatched (its only case matches GET) and the fixtures assert its 404, so it gets acoveredElsewherewaiver with that reason.auditlists the waiver.Evidence
npm run verifypassed before the rebase onto v0.6.3: 946 core tests plus the workspace suites.typecheck,lint,check(including docs checks), the recipes/conditions/cloudflare/exports/mcp suites (59/59) andnpm run test:packageall pass. The package smoke reports "39 packaged example commands ran from consumer copies".Limitations
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.package.jsonfiles aren't copied (authoring copies refusepackage.json), and they still declare@jimhoyd/urlcode: ^0.3.0. They aren't needed for validate/test/audit.🤖 Generated with Claude Code