Skip to content

fix(cli): skills pre-flight is warn-only; serve is side-effect-free; shipped .mcp.json pinned (#988) - #989

Merged
admarble merged 2 commits into
mainfrom
feature/988-fix-cli-preaction-auto-sync-fires-on-serve-the
Sep 7, 2026
Merged

admarble merged 2 commits into
mainfrom
feature/988-fix-cli-preaction-auto-sync-fires-on-serve-the

Conversation

@admarble

@admarble admarble commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Closes #988.

What happened

Three downstream repos got unreviewed working-tree churn on 2026-09-06 — pre-tool.sh, .claude/skills/**, AGENTS.md, scripts/dev/*, .sequant-manifest.json — from npm exec sequant@latest serve, erasing an in-place hook customization in one of them. Chain, each link verified in source or on disk:

  1. marketplace.json declares source: "./", so the plugin ships the repo-root .mcp.json — npx -y sequant@latest serve. Reconsider sequant@latest pinning in generated MCP config (forces npx reinstall every release; surfaces as -32000) #793's pin only ever landed in a dist/ copy the GitHub marketplace never installs (plugin cache 2.12.0 and 2.13.0 both carry @latest).
  2. Claude Code starts the plugin's MCP server with cwd = the open project.
  3. bin/cli.ts preAction excluded only init/sync/update; on a version-marker mismatch it ran syncCommand({ quiet: true }) → copyTemplates({ force: true }), silently rewriting the managed trees.
  4. The write path protects one file (constitution.md); .claude/.local/ twins are honored by the classifier but not the copy.

Repeat trigger: every new session re-ran the sync until the marker bump was committed.

Changes

  • Pre-flight is warn-only (src/commands/version-preflight.ts, runVersionPreflight). Stale marker and content drift both print the existing warning naming sequant update / sequant sync; nothing is written from the hook. Exempt: init, sync, update, serve. The fix(sync): areSkillsOutdated/checkAndWarnSkillsOutdated pre-flight is version-only — misses content drift (sibling of #708) #713 rule ("never clobber in-place customizations") now covers version bumps.
  • serve is side-effect-free and reports install status its own way (stdout is the MCP channel): one stderr line — ! Skills install is stale (x → y). No files were modified. Run: sequant update — and a new sequant://install resource, always an object ({ installed: false } with no manifest; otherwise the startup status with filesModified: false as the report-only contract). sequant://config is unchanged: the settings file, verbatim. An earlier commit on this branch merged a skillsInstall field into config; reverted in 5d9e06e5 — server-computed status doesn't belong on a user-authored document (shape varied with JSON vs JSONC, re-serialized the file, shared a namespace with real settings). createServer(version, { install }) / registerResources(server, context) — additive, defaulted.
  • Shipped .mcp.json is pinned. prepare-marketplace resolves the file from marketplace.json source, stamps it to the release version, and validates it (the dist copy is still stamped for the official-marketplace path). Root .mcp.json pinned to 2.13.0 now; the /release skill (all three mirrors) force-adds the gitignored-but-tracked file into the release commit.
  • Docs: docs/internal/plugin-updates.md table row + a "Why version bumps stopped auto-syncing (fix(cli): preAction auto-sync fires on serve — the plugin's @latest MCP server silently rewrites .claude/hooks, skills, AGENTS.md in every project it starts in (#793 pin never ships via marketplace source "./") #988)" section; what-weve-built.md bullet; CHANGELOG Changed/Added/Fixed.

Verification

  • Full suite in the worktree: 5787 passed, 2 failed → both were exact resource-list assertions (server.test.ts:285, mcp-e2e.integration.test.ts:231) that now include sequant://install; updated, re-run green. npm run lint clean, tsc --noEmit clean.
  • New tests: version-preflight.test.ts (AC-1/AC-3), serve.integration.test.ts (AC-2/AC-3 — real dist/bin/cli.js serve subprocess, cwd = stale fixture project, tree snapshot before/after), install-resource.test.ts (AC-3 — install resource shape + config verbatim for JSON and JSONC), scripts/plugin-mcp-pin.test.ts (AC-4), version-preflight.docs.test.ts (AC-5).

Mutation-verified: AC-1 — reinstated await syncCommand({ quiet: true }) in the outdated branch of runVersionPreflight; version-preflight.test.ts › warns on a stale marker and writes nothing failed; restored.

Mutation-verified: AC-2 — inserted await syncCommand({ quiet: true }) at the top of serveCommand, rebuilt dist; serve.integration.test.ts › starts, warns on stderr naming update, and leaves every file byte-identical failed; restored and rebuilt.

Mutation-verified: AC-4 — set the root .mcp.json arg back to sequant@latest; plugin-mcp-pin.test.ts › resolves the shipped .mcp.json from marketplace.json source and finds the exact pin failed; restored.

Mutation-verified: AC-5 — changed the docs table Action cell back to **Auto-sync (copy)** and added await syncCommand({ quiet: true }) inside the preAction hook; both version-preflight.docs.test.ts gates (docs table… and bin/cli.ts preAction hook…) failed; restored.

Not in this PR

  • D3 from the issue (make copyTemplates honor .claude/.local/ twins on the write path) — separate decision; D1 alone closes the incident.
  • Downstream repos still need their marker bump committed and hook customizations moved to .claude/.local/hooks/ (documented path).

🤖 Generated with Claude Code

…cp.json (#988)

The commander preAction hook ran `syncCommand({ quiet: true })` on a
version-marker mismatch — a silent forced copy of .claude/skills, hooks,
agents, AGENTS.md, scripts/dev and the manifest. The plugin's MCP config is
the repo-root .mcp.json (marketplace.json source "./"), which shipped
`npx sequant@latest serve`; Claude Code starts that server with cwd = the
open project, so every post-release session rewrote tracked files in every
project whose marker lagged @latest, with no output. Three downstream repos
lost in-place hook customizations on 2026-09-06.

- preAction delegates to runVersionPreflight (src/commands/version-preflight.ts):
  warn-only for both stale marker and content drift, exempt for
  init/sync/update/serve. Nothing under the project is written from the hook.
- serve is exempt (stdout is the MCP channel); it reports install status on
  stderr ("... No files were modified. Run: sequant update"), merges a
  `skillsInstall` field into sequant://config when settings is plain JSON,
  and exposes sequant://install as the always-parseable channel.
- prepare-marketplace stamps and validates the .mcp.json that marketplace.json
  `source` resolves to — the file plugin users install — not only the dist
  copy #793 pinned; the release skill force-adds the gitignored-but-tracked
  file into the release commit. Root .mcp.json pinned to 2.13.0.
- Tests: warn-only unit test (fixture tree byte-identical), serve subprocess
  integration test (stale install → warning on stderr, tree unchanged), MCP
  resource tests, marketplace-resolved pin test, docs/cli contract gate.
- Docs: plugin-updates.md rewritten for warn-only + the #988 history;
  what-weve-built bullet; CHANGELOG Changed/Added/Fixed.

Claude-Session: https://claude.ai/code/session_017eTXiiVdL34aaiv3JwYcBJ
@admarble admarble added the bug Something isn't working label Sep 6, 2026
…he only install-status channel (#988)

Merging a server-computed `skillsInstall` field into the user's settings
document was the wrong shape: the field appeared only when the file parsed
as plain JSON, the file was re-serialized (formatting/key order rewritten),
and a status value shared a namespace with real settings. sequant://config
now returns the settings file byte-for-byte again, and sequant://install is
always an object — `{ installed: false }` with no manifest, otherwise the
startup status with `filesModified: false` as the report-only contract.

Claude-Session: https://claude.ai/code/session_017eTXiiVdL34aaiv3JwYcBJ
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

1 participant