From d7da068dd7e6b7a0405d44339e5160e21cd11c30 Mon Sep 17 00:00:00 2001 From: Tom Boucher Date: Sat, 20 Jun 2026 15:03:19 -0400 Subject: [PATCH] fix(#1498): regenerate capability-registry.cjs in npm version lifecycle hook (#1499) * fix(#1498): regenerate capability-registry.cjs in npm version lifecycle hook The version npm lifecycle script now runs gen-capability-registry.cjs --write after sync-manifest-versions.cjs stamps all capability/*.json version fields. Without this, every npm version X.Y.Z call left capability-registry.cjs stale (capability JSONs got the new version string, but the registry still embedded the old ones), causing gen-capability-registry.cjs --check to fail in the RC test suite. - package.json version script: add gen-capability-registry --write + git add - tests/issue-844-manifest-version-sync.test.cjs: regression guard (describe F) Co-Authored-By: Claude Sonnet 4.6 * fix: backfill changeset pr: 1499 Co-Authored-By: Claude Sonnet 4.6 --------- Co-authored-by: Claude Sonnet 4.6 --- .changeset/patient-tunas-jump.md | 7 +++++ package.json | 2 +- .../issue-844-manifest-version-sync.test.cjs | 30 +++++++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 .changeset/patient-tunas-jump.md diff --git a/.changeset/patient-tunas-jump.md b/.changeset/patient-tunas-jump.md new file mode 100644 index 000000000..b20068e55 --- /dev/null +++ b/.changeset/patient-tunas-jump.md @@ -0,0 +1,7 @@ +--- +type: Fixed +pr: 1499 +--- +**`npm version` no longer leaves `capability-registry.cjs` stale** — the `version` npm lifecycle script now regenerates and stages the capability registry after stamping new version strings into all capability manifests, preventing the 1.6.0-rc regression where `gen-capability-registry.cjs --check` failed. (#1498) + + diff --git a/package.json b/package.json index 4c0ea18f2..59be7afb6 100644 --- a/package.json +++ b/package.json @@ -86,7 +86,7 @@ "gen:capability-registry": "node scripts/gen-capability-registry.cjs --write", "prepack": "npm run build:lib", "prepare": "npm run build:lib", - "version": "node scripts/sync-manifest-versions.cjs --stage", + "version": "node scripts/sync-manifest-versions.cjs --stage && node scripts/gen-capability-registry.cjs --write && git add gsd-core/bin/lib/capability-registry.cjs", "prepublishOnly": "npm run build:lib && npm run build:hooks", "pretest": "npm run build:lib && npm run lint:skill-deps", "pretest:coverage": "npm run build:lib && npm run lint:skill-deps", diff --git a/tests/issue-844-manifest-version-sync.test.cjs b/tests/issue-844-manifest-version-sync.test.cjs index 7bca6dd7d..0288dfa0f 100644 --- a/tests/issue-844-manifest-version-sync.test.cjs +++ b/tests/issue-844-manifest-version-sync.test.cjs @@ -341,3 +341,33 @@ describe('D: CLI --check exits 0 when manifests are in sync', () => { ); }); }); + +// ─── F: version script includes capability-registry regen (#1498) ───────────── +// +// Regression guard for #1498: the `npm version` lifecycle script must regenerate +// capability-registry.cjs after stamping capability manifests. Without this, +// `npm version X.Y.Z` leaves the committed registry stale (capability JSONs get +// new version strings but the registry still has the old ones), causing the +// `gen-capability-registry.cjs --check` test to fail in the RC workflow. +describe('F: npm version script includes gen-capability-registry --write (#1498)', () => { + + test('package.json "version" script regenerates capability-registry.cjs after syncing manifests', () => { + const pkg = JSON.parse(fs.readFileSync(path.join(ROOT, 'package.json'), 'utf8')); + const versionScript = pkg.scripts && pkg.scripts.version; + assert.ok( + typeof versionScript === 'string', + 'package.json must have a "version" script', + ); + assert.ok( + versionScript.includes('gen-capability-registry.cjs --write'), + 'package.json "version" script must include "gen-capability-registry.cjs --write" to keep the registry in sync after npm version bumps capability manifests. ' + + 'Got: ' + JSON.stringify(versionScript), + ); + assert.ok( + versionScript.includes('git add') && versionScript.includes('capability-registry.cjs'), + 'package.json "version" script must stage capability-registry.cjs with "git add" so it is included in the version-bump commit. ' + + 'Got: ' + JSON.stringify(versionScript), + ); + }); + +});