From 19fd9343f6838b58d4e2fa8a5d6d0b0c2f0323ec Mon Sep 17 00:00:00 2001 From: Tom Boucher Date: Sun, 5 Jul 2026 20:56:12 -0400 Subject: [PATCH] feat(#2002): self-healing runtime build for plugin-marketplace installs (#2036) The compiled gsd-core/bin/lib/*.cjs modules are gitignored build artifacts (ADR-457) shipped prebuilt in the npm tarball. A Claude Code plugin-marketplace / git-clone install materializes the repo tree directly and never runs `npm run build:lib`, so those ~148 files are absent and every CLI command dies at load with `Cannot find module './lib/cli-exit.cjs'`. gsd-tools.cjs now calls ensureRuntimeBuild() before its ./lib requires: a new committed bin helper that compiles the tree once on demand (lock-guarded, incremental-cache-cleared, portable `node ` invocation) when the sentinel cli-exit.cjs is missing, and surfaces an actionable error when TypeScript is unavailable. The already-built npm path is a single fs.existsSync no-op. ADR-457 (gitignored, build-at-publish) is preserved; no release-pipeline change. Verified against a simulated marketplace checkout (148 build outputs removed): the CLI self-heals and the result is byte-identical to `npm run build:lib`. Closes #2002 Co-authored-by: Claude Opus 4.8 --- .../2002-cli-self-healing-runtime-build.md | 6 + docs/how-to/install-on-your-runtime.md | 2 + gsd-core/bin/ensure-runtime-build.cjs | 246 +++++++++++++ gsd-core/bin/gsd-tools.cjs | 18 + tests/ensure-runtime-build.test.cjs | 340 ++++++++++++++++++ .../golden-install-parity/antigravity.json | 3 +- .../golden-install-parity/augment.json | 3 +- .../golden-install-parity/claude.json | 3 +- .../fixtures/golden-install-parity/cline.json | 3 +- .../golden-install-parity/codebuddy.json | 3 +- .../fixtures/golden-install-parity/codex.json | 3 +- .../golden-install-parity/copilot.json | 3 +- .../golden-install-parity/cursor.json | 3 +- .../golden-install-parity/hermes.json | 3 +- .../fixtures/golden-install-parity/kilo.json | 3 +- .../fixtures/golden-install-parity/kimi.json | 3 +- .../golden-install-parity/opencode.json | 3 +- .../fixtures/golden-install-parity/qwen.json | 3 +- .../fixtures/golden-install-parity/trae.json | 3 +- .../golden-install-parity/windsurf.json | 3 +- 20 files changed, 642 insertions(+), 15 deletions(-) create mode 100644 .changeset/2002-cli-self-healing-runtime-build.md create mode 100644 gsd-core/bin/ensure-runtime-build.cjs create mode 100644 tests/ensure-runtime-build.test.cjs diff --git a/.changeset/2002-cli-self-healing-runtime-build.md b/.changeset/2002-cli-self-healing-runtime-build.md new file mode 100644 index 000000000..3e2f35507 --- /dev/null +++ b/.changeset/2002-cli-self-healing-runtime-build.md @@ -0,0 +1,6 @@ +--- +type: Changed +pr: 2036 +--- + +**The GSD CLI now self-heals a missing runtime build.** The compiled `gsd-core/bin/lib/*.cjs` modules are gitignored build artifacts (ADR-457) that ship prebuilt in the npm tarball but are absent on a Claude Code plugin-marketplace / git-clone install, which never runs `npm run build:lib`. Previously every command died at load with `Cannot find module './lib/cli-exit.cjs'`. The `gsd-tools` entrypoint now detects the missing output and compiles it once, on demand (lock-guarded so parallel invocations don't race), then proceeds — a single no-op check on the already-built npm path. When TypeScript is genuinely unavailable it prints an actionable `npm install && npm run build:lib` message instead of crashing. diff --git a/docs/how-to/install-on-your-runtime.md b/docs/how-to/install-on-your-runtime.md index d24c1203f..051b94828 100644 --- a/docs/how-to/install-on-your-runtime.md +++ b/docs/how-to/install-on-your-runtime.md @@ -102,6 +102,8 @@ The `gsd-tools` binary (installed as part of the `@opengsd/gsd-core` npm package Node.js (`node`) must also be available on your `PATH`. The plugin's always-on guard hooks (wired in `hooks/hooks.json`) are invoked as `node "${CLAUDE_PLUGIN_ROOT}/hooks/