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 <noreply@anthropic.com>

* fix: backfill changeset pr: 1499

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Tom Boucher
2026-06-20 15:03:19 -04:00
committed by GitHub
parent f5276b36b3
commit d7da068dd7
3 changed files with 38 additions and 1 deletions

View File

@@ -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)
<!-- docs-exempt: internal release-tooling fix; no user-facing command or API change -->

View File

@@ -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",

View File

@@ -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),
);
});
});