Skip to content

fix(#1265): ship a slim plugin/ folder instead of the whole dev repo - #1275

Merged
admarble merged 18 commits into
mainfrom
feature/1265-fix-plugin-ship-a-slim-plugin-folder-the-repo-root
Oct 2, 2026
Merged

admarble merged 18 commits into
mainfrom
feature/1265-fix-plugin-ship-a-slim-plugin-folder-the-repo-root

Conversation

@admarble

@admarble admarble commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • .claude-plugin/marketplace.json's source was "./", so every plugin install/update ran npm ci over this repo's full package.json/lockfile and wrote a ~700 MB node_modules that nothing in the plugin reads. source now points at ./plugin, a generated folder with no package.json holding only what loads at runtime.
  • plugin/hooks/, plugin/skills/, and plugin/memory/constitution.md are generated from templates/ by scripts/sync-hooks.sh and scripts/check-skill-sync.ts --fix, each gated by a byte-identity test in the suite.
  • Install id (sequant@sequant) is unchanged, so existing installs upgrade in place — verified locally against this repo's real v2.18.0 tag.
  • Release/pin tooling (release.sh, generate-mcp-launch-inline.mjs, plugin-version-sync.ts, prepare-marketplace.ts) now covers plugin/ and root .mcp.json independently.
  • Three QA rounds fixed: the upgrade-job's git worktree add reuse bug and its auth-dependent skill check, plugin/README.md's disclosure accuracy (constitution description, local prettier, opt-in smart tests, post-merge worktree cleanup, file-locking), and a check-skill-sync.ts denominator regression this issue itself introduced (caught by a full-suite run).

Pre-PR AC Verification

AC Status Evidence
AC-1 ✅ Implemented plugin/ has no package.json; real claude plugin install verified 1.0M total, no node_modules; CI gate in plugin-install-test.yml; mutation-verified (696 MB node_modules reproduced when package.json+lockfile added, then restored)
AC-2 ✅ Implemented 58 files, no oversized non-image files, no symlinks/junk; CI gate; mutation-verified
AC-3 ✅ Implemented plugin/hooks/, plugin/skills/, plugin/memory/constitution.md all generated from templates/; three byte-identity gate tests, each mutation-verified, plus a new plugin/hooks/hooks.json byte-identity test
AC-4 ✅ Implemented plugin/README.md (700+ words) + plugin/LICENSE; disclosure now covers MCP launch, git/gh, local prettier (default-on), opt-in smart tests, opt-in webhook, post-merge worktree cleanup, file-locking, and exactly what the constitution file is (the generic template /sequant:setup copies into target projects, not unique content)
AC-5 ✅ Implemented (locally) Upgrade-job's git worktree add reuse bug reproduced and fixed against this repo's real v2.18.0 tag; skill-presence check now reads the installed cache directly (no model call, no auth dependency) instead of claude --print, which needs API auth CI doesn't carry
AC-6 ✅ Implemented release.sh, generate-mcp-launch-inline.mjs, plugin-version-sync.ts, check-skill-sync.ts, lint-skill-calls.ts, .gitignore, package.json files all cover plugin/; root .mcp.json is now stamped independently at release too
AC-7 ✅ Implemented claude plugin validate --strict passes on both ./plugin and ., verified locally with the real CLI; CI gate added
AC-8 🔄 Deferred (by design) Human-required: owner runs the claude.ai directory portal validator after merge
AC-9 ✅ Implemented templates/memory/constitution.md carries the producer-parity row; check-constitution-dod.test.ts passes

Mutation records

AC-1 and AC-2 were verified against a real local install (not just the simulated find logic): mutating plugin/ and running claude plugin marketplace add + claude plugin install reproduced a 696 MB node_modules and a 307 KB oversized file respectively; both were restored to clean state and re-verified.

Test plan

  • npm run build
  • npm run lint
  • npm run typecheck:scripts
  • npm run lint:skill-sync && npm run lint:skill-calls && npm run lint:constitution-dod
  • Full suite, 3 shards (360 test files): all green
  • claude plugin validate --strict ./plugin && claude plugin validate --strict . (real CLI)
  • Real local claude plugin marketplace add + claude plugin install — confirmed no node_modules, ~1 MB total install
  • CI run of plugin-install-test.yml (AC-1/2/5/7 gates) — pending this PR

Closes #1265

🤖 Generated with Claude Code

Hand fixes after QA round 3 (21402b6, be77501)

QA round 3's AC-5 gap was real: v2.18.0 and HEAD share a version, so plugin update was a no-op and the checks inspected the old install. The upgrade job now takes the real-user path:

  • It installs from sequant-io/sequant#v2.18.0. Then it reads the install path from installed_plugins.json and asserts that the baseline has package.json and node_modules (about 720 MB), so the job can tell the two layouts apart.
  • It repoints the marketplace at the PR ref, stamps a test version into the cloned plugin/ manifest and marketplace entry (as a release bump would), and runs claude plugin update.
  • It asserts that the new install path differs from the old one and has no package.json, lockfile or node_modules (1.0 MB, 58 files), and that skills, hooks.json, .mcp.json and the MCP connection are present.

Run locally under bash -e from the repo checkout: it passes. The mutant fails.

Mutation-verified: AC-5 — copied package.json and package-lock.json into the cloned marketplace's plugin/ before the update; .github/workflows/plugin-install-test.yml > upgrade-test > Install 2.18.0 (repo-root plugin), then upgrade in place failed with "upgraded install still has package.json"; restored.

About QA's other gaps:

Directory portal finding → AC-10 (337378d)

The developer portal already tracks this repo (the 08-30 submission was migrated). It scanned main at v2.18.0 · ac69645 and returned one Blocking finding: "MCP server config couldn't be fully checked … This command has more than 1,024 parts". So the inline node -e launcher would have blocked the listing even from plugin/.

Mutation-verified: AC-10 — restored the inline node -e args in plugin/.mcp.json; scripts/plugin-mcp-pin.test.ts > #1265: shipped plugin .mcp.json runs the launcher file the plugin ships > is node ${CLAUDE_PLUGIN_ROOT}/mcp-launch.mjs sequant@<version> failed (with 2 sibling cases); restored. Appending a line to plugin/mcp-launch.mjs fails the byte-identical case.

After merge (owner): the listing's plugin path is fixed at "repository root", and the portal can't change it ("To use a different repository or path, make a new submission"). Withdraw the current submission and submit sequant-io/sequant with path plugin.

…tution.md

AC-9: templates/memory/constitution.md now matches memory/constitution.md so plugin/memory/constitution.md (generated from templates/) carries the #1250 row.
Entire-Checkpoint: 760dff312b9f
AC-1/AC-3: plugin/hooks, plugin/skills, plugin/memory are generated from templates/ by sync-hooks.sh and check-skill-sync.ts --fix. plugin/.mcp.json, plugin/.claude-plugin/plugin.json, plugin/LICENSE are copies of the root files. marketplace.json now points source at ./plugin. Root hooks/, skills/, .claude-plugin/plugin.json, .mcp.json are untouched and retired in a follow-up PR.

Entire-Checkpoint: ab10dfe73287
AC-1/AC-3: plugin/hooks, plugin/skills, plugin/memory are generated from templates/ by sync-hooks.sh and check-skill-sync.ts --fix. plugin/.mcp.json, plugin/.claude-plugin/plugin.json, plugin/LICENSE are copies of the root files. marketplace.json now points source at ./plugin. .gitignore's bare .mcp.json pattern is anchored to the repo root so it no longer swallows plugin/.mcp.json. Root hooks/, skills/, .claude-plugin/plugin.json, .mcp.json are untouched and retired in a follow-up PR.

Entire-Checkpoint: 5bd59a2ee643
…/ layout

AC-6: scripts/plugin-mcp-pin.test.ts's #1084 block resolved the shipped .mcp.json from a hardcoded root path; it now shares the marketplace-source-resolved shippedMcpJsonPath() helper with the #988 block, so it checks plugin/.mcp.json. release.sh now also version-stamps plugin/.claude-plugin/plugin.json. prepare-marketplace.ts's shippedMcpJsonPath() already resolved dynamically from marketplace.json source, so npm run prepare:marketplace already stamps plugin/.mcp.json correctly; only its stale comment needed updating. lint-skill-calls.ts now scans plugin/skills/ too.
Entire-Checkpoint: 8e6e0d2baf09
…nstall, and in-place upgrade

AC-1: new step installs into an isolated CLAUDE_CONFIG_DIR + CLAUDE_CODE_PLUGIN_CACHE_DIR and asserts no node_modules lands under the plugin cache.
AC-2: new step counts plugin/ files (<=512), checks for non-image files over 256 KiB, symlinks, and .DS_Store/Thumbs.db.
AC-5: new upgrade-test job installs sequant@sequant from the v2.18.0 tag's marketplace clone, advances that clone to this checkout, runs marketplace update + plugin update, and asserts the install id and skill discovery survive.
AC-7: claude plugin validate --strict now runs on both ./plugin and the marketplace root.
Workflow trigger paths gain plugin/**.

Entire-Checkpoint: 2d468235727e
AC-3: extends src/lib/relay/__tests__/hook-sync.test.ts with a drift check between templates/hooks/ and plugin/hooks/, mirroring the existing .claude/hooks/ check.

Mutation-verified: appending a line to plugin/hooks/post-tool.sh failed exactly the new "every file in templates/hooks/ exists byte-identically in plugin/hooks/" test; restored, suite green.
Entire-Checkpoint: 49038e18168e
…ard-fails on load regressions

AC-5: the second  reused CLONE_DIR after a bare rm -rf, which git refuses (exit 128, 'missing but already registered worktree') — reproduced locally. Switched to git worktree remove --force, which deregisters cleanly, confirmed by reproducing the failure and the fix against this repo's own v2.18.0 tag. The skill-discovery check now exits 1 instead of warning, and a new check asserts claude mcp list reports plugin:sequant:sequant as Connected after the upgrade.
Entire-Checkpoint: 4b18c71fe8cb
AC-6: generate-mcp-launch-inline.mjs --write now also rewrites plugin/.mcp.json, so a future mcp-launch.mjs change can no longer leave the shipped plugin/ copy stale. Mutation-verified: corrupting plugin/.mcp.json's inline launcher source failed scripts/plugin-mcp-pin.test.ts's byte-identical check; restored.

checkVersionSync() now also reads plugin/.claude-plugin/plugin.json (when present) and fails sync with a named error on mismatch, mirroring the existing marketplace.json check. Existing mock-based tests updated since plugin/.claude-plugin/plugin.json also matches their generic "plugin.json" substring checks; two new tests cover the field directly.

Entire-Checkpoint: e4ef40c435f4
AC-6: .claude-plugin/ was already in package.json's files list, so an npm-installed copy carries marketplace.json with source: ./plugin — without plugin/ itself, that path wouldn't resolve from the npm tarball. Added plugin (1.0M unpacked, no node_modules) to files for consistency. Verified with npm pack --dry-run.
Entire-Checkpoint: 7eb2be8d128c
AC-4: the README claimed hooks always write logs to ~/.sequant/logs/, but pre-tool.sh and post-tool.sh actually prefer ${CLAUDE_PLUGIN_DATA}/logs/ first (Claude Code's plugin data dir), falling back to ~/.sequant/logs/ and then a temp dir — verified by reading the actual _LOG_DIR resolution in both scripts. Also separated what capture-tokens.sh (a hook) writes directly (.sequant/.token-usage-<session-id>.json) from the broader .sequant/ state the sequant CLI/MCP server maintains, which the hooks themselves don't write.
Entire-Checkpoint: dbaec16780bd
…, not a hardcoded 3

Full-suite run caught this: adding plugin/skills as a 4th mirror earlier in this issue made check-skill-sync.ts print '4/3 match' for every synced file (lineCounts.length grew to 4 but the denominator was hardcoded), which failed two integration tests (#552, #921) asserting the literal string 'synced <file> — 3/3 match'. Fixed the denominator to MIRROR_DIRS.length + 1, and updated both tests' regex and messages to 4/4, matching reference_shape_checks_live_in_workflows_too.md's lesson: a shape change needs every test naming the literal re-run, not just the ones the new code path touches.

Entire-Checkpoint: f85d7a57cab9
…te test; README discloses prettier and opt-in smart tests

AC-3: scripts/sync-hooks.sh now also regenerates plugin/memory/constitution.md from templates/memory/constitution.md, and scripts/check-constitution-plugin-sync.test.ts gates byte-identity. Mutation-verified: appending a line to plugin/memory/constitution.md (the exact QA repro) failed the new test; restored, green.

AC-4: plugin/README.md was missing two disclosures the QA review found reading post-tool.sh directly — it runs the edited file's own local prettier --write by default (not opt-in, never npx), and it runs npm test asynchronously only when CLAUDE_HOOKS_SMART_TESTS=true is set. Also clarified that memory/constitution.md is this sequant-io/sequant repo's own constitution, copied from templates/memory/constitution.md, not a generic target-project template.
Entire-Checkpoint: 64e93158aee7
…-pin coverage (QA round 3)

AC-5: the upgrade-test job's skill check called `claude --print "list available skills"`, a model call that needs API auth CI has no reason to carry - reproduced as "Not logged in - Please run /login", silently missed by the old grep, then hard-failed. Replaced with a direct check of the installed plugin cache's SKILL.md files: no model call, no auth dependency, and it verifies the actual upgrade artifact.

AC-4: plugin/README.md's constitution description claimed it was "not a generic template", but skills/setup/SKILL.md's "Copy Constitution Template" step reads it via CLAUDE_PLUGIN_ROOT/memory/constitution.md and copies it into a target project's .claude/memory/constitution.md, substituting the PROJECT_NAME placeholder - it IS the generic template (root memory/constitution.md has never filled in its own placeholder either). Also corrected the "nothing outside those paths is modified" completeness claim: post-tool.sh runs git worktree remove --force plus git branch -D after a successful gh pr merge (can remove a directory outside the current project), and pre-tool.sh writes per-file lock files under TMPDIR during parallel edits - neither was previously disclosed.

CHANGELOG: fixed the "root .mcp.json retired in a follow-up PR" line to match the issue's actual Decision (root .mcp.json stays, since it is also this repo's own project MCP config).

AC-6 (suggestion): added a plugin/hooks/hooks.json byte-identity test (mutation-verified) - nothing previously checked that copy. prepare-marketplace.ts now also stamps root .mcp.json's version pin independently of shippedMcpJsonPath(), which resolves to plugin/.mcp.json since #1265 and no longer stamps root .mcp.json as a side effect; added test coverage for both the pin and the stamping code's presence.

Entire-Checkpoint: ee1e8f760059
…sion bump

The AC-5 job added the marketplace from a local directory, which loads the plugin in place with no cache copy or npm install, and v2.18.0 and HEAD shared a version, so plugin update was a no-op. It now installs from sequant-io/sequant#v2.18.0 (asserting the 2.18.0 cache has package.json and node_modules), repoints the marketplace at the PR ref, stamps a test version and updates, then asserts the new cache dir has no package.json, lockfile or node_modules.

Entire-Checkpoint: 7e892ee18e5d
…son and prints diagnostics

Entire-Checkpoint: 36c015ebdea5
… not an inline node -e

The directory refuses the plugin while its MCP command has more than 1,024 parts. The inline form existed only because root .mcp.json doubled as this repo's project config, where CLAUDE_PLUGIN_ROOT is undefined (#1084); plugin/.mcp.json is plugin-only, so it now runs node ${CLAUDE_PLUGIN_ROOT}/mcp-launch.mjs sequant@<version>. Root .mcp.json and templates/mcp.json stay inline. The generator syncs plugin/mcp-launch.mjs from scripts/ and checks the entry shape.

Entire-Checkpoint: 75d7e87d3d27
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.

fix(plugin): ship a slim ./plugin folder — the repo-root plugin pulls ~700 MB of dev dependencies into every install and fails directory review limits

1 participant