Skip to content

fix(core): context and plan-feature forward --origin; emitted commands quote and locate the project (#791, #790) - #797

Merged
jimhoyd merged 7 commits into
mainfrom
claude/issue-triage-709b4f
Sep 26, 2026
Merged

jimhoyd merged 7 commits into
mainfrom
claude/issue-triage-709b4f

Conversation

@jimhoyd

@jimhoyd jimhoyd commented Sep 26, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #791 and #790.

Scope change: #798 merged separately and fixed #777, #793 and #795 with its own design. This branch's earlier changes for those issues were dropped in a merge commit that takes main's version. The net diff against main is now only the context/MCP command fix.

#791: context, context --task, plan-feature and MCP dropped --origin

  • context.ts passes the origin to site expansion (applySite(loaded,{origin})) in both buildContext and buildTaskContext.
  • FeaturePlanOptions.origin is added, and CLI plan-feature and MCP plan_feature forward it.
  • With no origin, a sitemap project still fails with the existing error naming --origin; nothing is guessed.

#790: emitted commands mishandled paths and the working directory

  • Every emitted --project argument, including projectFlag overrides, goes through shellWord.
  • MCP get_context now emits the absolute project path. It used to emit --project ., which from the site root, where .mcp.json runs --project app --host-file host.mjs, put host.mjs inside the "project". The host-file safety check is unchanged.
  • The CLI repeats --project as the user typed it, now quoted.
  • docs/TOOLING.md documents all of this.

Evidence

  • New test/context-commands.test.ts, 5 tests; all fail on the old source. They cover:
    • origin through the SDK, the CLI and real serveMcp (get_context, the task variant, plan_feature), plus the error when it's missing;
    • emitted commands for paths containing spaces and an apostrophe, run through /bin/sh;
    • the issue-comment case: the MCP validate command run from the site root.
  • npm run verify exits 0 on this exact tree: 1006 core tests pass, and every workspace suite has 0 failures.

Limitations

  • Emitted commands still start with npx --no --package @jimhoyd/urlcode, so they need a directory inside the site. That is the documented client working directory.
  • The shell-execution tests are skipped on Windows.
  • A sitemap project with no origin still errors instead of returning partial context.

Closes #791
Closes #790

🤖 Generated with Claude Code

jimhoyd and others added 6 commits September 26, 2026 12:08
…s quote and locate the project (#791, #790)

#791: context, context --task and plan-feature compiled the project with
applySite(loaded,{}), discarding the operator's --origin, so a site.sitemap
project failed claiming the flag was missing. compile() now takes the origin;
FeaturePlanOptions gains `origin`; the CLI plan-feature and the MCP
get_context/plan_feature paths forward it. Without an origin the site
expansion error still names --origin; nothing is guessed.

#790: the project argument in emitted commands is shell-quoted with
shellWord (context and task context, including projectFlag overrides). MCP
get_context emitted `--project .`, which from the client's working directory
(the site root for `--project app --host-file host.mjs`) named the site
itself and put host.mjs inside the "project", failing the host-file check.
It now emits the project's absolute path, matching the absolute host file.

Tests: test/context-commands.test.ts covers sitemap+origin via SDK, CLI and
the real serveMcp path, spaces/apostrophe quoting executed through /bin/sh,
and the site-root MCP scenario executed from the site root.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…to core (#793, #795)

#793: the contact-form recipe said test and audit probes do not fire its
signal. They do: fixtures are ordinary requests, and only HEAD and the
/_urlcode health, readiness and metrics probes are exempt. The recipe README,
docs/EGRESS.md (new "Signals under test and audit" section) and the egress
example README now say so and recommend a controlled test receiver. A new
egress-runtime test runs the recipe's fixtures through runProjectTests and
auditProject with only the transport replaced and asserts one signal POST each.

#795: examples/cloudflare and examples/vercel depended on core ^0.3.0.
release-bump now rewrites the exact @jimhoyd/urlcode pin in every tracked
examples/*/package.json and --check fails when one drifts; both examples pin
the current version. VERSION-ALIGNMENT and RELEASE-OPERATIONS describe it,
and release-bump tests cover the bump and the drift.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
#777)

A dev reload of `init --with admin,form-records --example` was rejected with
"Store directory is already locked by this process": the replacement runtime
activated its extensions while the serving one still held the store lock.

Define the reload lifecycle (RIM-EXT-HANDOFF-001): the replacement snapshot is
built and fully checked with its extensions deferred; the server then holds
newly admitted requests, waits (bounded by closeTimeoutMs) for the serving
snapshot's in-flight requests, closes its extensions, activates the
replacement's and makes it current before the held requests resume. If the
replacement refuses, the serving snapshot's plan is activated again and keeps
serving; a failed restore answers 503 with readiness degraded until a later
reload succeeds. At most one activation of each registration is ever live, so
the store lock stays single-writer without being removed or force-unlocked.

prepareExtensions returns a reusable ExtensionPlan (fresh registry per
activate, idempotent close); activations receive `declarations`, the
snapshot's validated extension configs, and store's ui screen source now reads
its config from there instead of the project file on disk, so a restored
last-good snapshot keeps its screens. Core still imports no package.

Tests: test/extension-handoff.test.ts (ordering, restore, failed restore,
in-flight hold and drain timeout, deferred runtime) and
packages/form-records/test/reload.test.ts, which serves the site
`init --with admin,form-records --example` generates through its host.mjs with
the real packages, reloads the changed contact title, and checks a refused
reload keeps the last-good snapshot with exactly one store lock.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Resolves runtime.ts/server.ts/extensions.ts and the RIM table. One rule now
covers both features: an admitted stream holds its runtime's extensions, so a
handoff release waits for open streams as well as buffered requests, and a dev
reload of a project declaring extensions first ends open streams with the new
end reason `reload` (clients resume, e.g. MCP Last-Event-ID) rather than being
refused for as long as a client stays connected. A project declaring no
extensions has nothing to hand over and keeps #796's behavior: streams run on
the retired runtime. handle() keeps its request counted until a stream is
admitted, so no release or close runs between dispatch settling and tracking.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@jimhoyd
jimhoyd enabled auto-merge (squash) September 26, 2026 19:42
#798 fixed #777, #793 and #795 with its own design (an extension handoff()
hook with a reference-counted exclusive resource) and merged first. This
resolves the conflict by taking main for all of that, so this branch's own
reload-handoff, recipe-signal and example-pin changes are dropped. What remains
is the context/plan-feature/MCP fix for #791 and #790 on top of main.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@jimhoyd jimhoyd changed the title Extension handoff on dev reload, context origin/quoting, recipe signal docs and example pins (#777, #790, #791, #793, #795) fix(core): context and plan-feature forward --origin; emitted commands quote and locate the project (#791, #790) Sep 26, 2026
@jimhoyd
jimhoyd merged commit 361e2de into main Sep 26, 2026
27 checks passed
@jimhoyd
jimhoyd deleted the claude/issue-triage-709b4f branch September 26, 2026 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant