* refactor(#1170): remove hand-maintained INVENTORY count scalars The `(N shipped)` heading counts in docs/INVENTORY.md were absolute scalars that collided silently on merge: two branches each bumping the same integer to N+1 produced a clean git merge whose value the merged filesystem (N+2) contradicted, hard-failing inventory-counts.test.cjs on the CI merge commit across all platforms (DEFECT.INVENTORY-MERGE-UNDERCOUNT). - Strip the six `(N shipped)` heading counts + the two prose footnote counts; repoint the intro to INVENTORY-MANIFEST.json as the registry. - Drop the decorative `generated` date from the manifest + its strip-before-compare branch in gen-inventory-manifest.cjs (it conflicted on cross-day merges and is read by nothing). - Delete inventory-counts.test.cjs (scalar-vs-disk gate, the collision source); its drift protection is subsumed by the merge-safe set-membership test inventory-manifest-sync.test.cjs, which stays as the sole gate. - Add inventory-headings-countfree.test.cjs guard (fails if a count is re-added to a heading). - Fix already-broken count-bearing cross-doc anchors to stable count-free slugs in ARCHITECTURE.md + multi-agent-orchestration.md. - Retire the now-impossible DEFECT.INVENTORY-MERGE-UNDERCOUNT + obsolete RULESET.DOC-CONSISTENCY in CONTEXT.md; de-count DEFECT.INVENTORY-DRIFT; correct stale MANIFEST-CANONICAL-KEY (all six families canonical). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * chore(#1170): backfill changeset PR number (#1179) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
113 lines
3.5 KiB
JavaScript
113 lines
3.5 KiB
JavaScript
#!/usr/bin/env node
|
|
'use strict';
|
|
|
|
/**
|
|
* Generates docs/INVENTORY-MANIFEST.json — a structural skeleton of every
|
|
* shipped surface derived entirely from the filesystem. Commit this file;
|
|
* CI re-runs the script and diffs. A non-empty diff means a surface shipped
|
|
* without an INVENTORY.md row.
|
|
*
|
|
* Usage:
|
|
* node scripts/gen-inventory-manifest.cjs # print to stdout
|
|
* node scripts/gen-inventory-manifest.cjs --write # write docs/INVENTORY-MANIFEST.json
|
|
* node scripts/gen-inventory-manifest.cjs --check # exit 1 if committed manifest is stale
|
|
*/
|
|
|
|
const fs = require('node:fs');
|
|
const path = require('node:path');
|
|
|
|
const { ExitError, runMain } = require('./lib/cli-exit.cjs');
|
|
|
|
const ROOT = path.resolve(__dirname, '..');
|
|
const MANIFEST_PATH = path.join(ROOT, 'docs', 'INVENTORY-MANIFEST.json');
|
|
|
|
const FAMILIES = [
|
|
{
|
|
name: 'agents',
|
|
dir: path.join(ROOT, 'agents'),
|
|
filter: (f) => /^gsd-.*\.md$/.test(f),
|
|
toName: (f) => f.replace(/\.md$/, ''),
|
|
},
|
|
{
|
|
name: 'commands',
|
|
dir: path.join(ROOT, 'commands', 'gsd'),
|
|
filter: (f) => f.endsWith('.md'),
|
|
toName: (f) => '/gsd-' + f.replace(/\.md$/, ''),
|
|
},
|
|
{
|
|
name: 'workflows',
|
|
dir: path.join(ROOT, 'gsd-core', 'workflows'),
|
|
filter: (f) => f.endsWith('.md'),
|
|
toName: (f) => f,
|
|
},
|
|
{
|
|
name: 'references',
|
|
dir: path.join(ROOT, 'gsd-core', 'references'),
|
|
filter: (f) => f.endsWith('.md'),
|
|
toName: (f) => f,
|
|
},
|
|
{
|
|
name: 'cli_modules',
|
|
dir: path.join(ROOT, 'gsd-core', 'bin', 'lib'),
|
|
filter: (f) => f.endsWith('.cjs'),
|
|
toName: (f) => f,
|
|
},
|
|
{
|
|
name: 'hooks',
|
|
dir: path.join(ROOT, 'hooks'),
|
|
filter: (f) => /\.(js|sh)$/.test(f),
|
|
toName: (f) => f,
|
|
},
|
|
];
|
|
|
|
function buildManifest() {
|
|
const manifest = { families: {} };
|
|
for (const { name, dir, filter, toName } of FAMILIES) {
|
|
manifest.families[name] = fs
|
|
.readdirSync(dir)
|
|
.filter((f) => fs.statSync(path.join(dir, f)).isFile() && filter(f))
|
|
.map(toName)
|
|
.sort();
|
|
}
|
|
return manifest;
|
|
}
|
|
|
|
function main() {
|
|
const [, , flag] = process.argv;
|
|
|
|
if (flag === '--check') {
|
|
const committed = JSON.parse(fs.readFileSync(MANIFEST_PATH, 'utf8'));
|
|
const live = buildManifest();
|
|
const committedStr = JSON.stringify(committed, null, 2);
|
|
const liveStr = JSON.stringify(live, null, 2);
|
|
if (committedStr !== liveStr) {
|
|
process.stderr.write(
|
|
'docs/INVENTORY-MANIFEST.json is stale. Run:\n' +
|
|
' node scripts/gen-inventory-manifest.cjs --write\n' +
|
|
'then add a matching row in docs/INVENTORY.md for each new entry.\n\n',
|
|
);
|
|
// Show diff-friendly output
|
|
for (const family of Object.keys(live.families)) {
|
|
const liveSet = new Set(live.families[family]);
|
|
const committedSet = new Set((committed.families || {})[family] || []);
|
|
for (const name of liveSet) {
|
|
if (!committedSet.has(name)) process.stderr.write(' + ' + family + '/' + name + '\n');
|
|
}
|
|
for (const name of committedSet) {
|
|
if (!liveSet.has(name)) process.stderr.write(' - ' + family + '/' + name + '\n');
|
|
}
|
|
}
|
|
throw new ExitError(1);
|
|
}
|
|
process.stdout.write('docs/INVENTORY-MANIFEST.json is up to date.\n');
|
|
} else if (flag === '--write') {
|
|
const manifest = buildManifest();
|
|
fs.writeFileSync(MANIFEST_PATH, JSON.stringify(manifest, null, 2) + '\n');
|
|
process.stdout.write('Wrote ' + MANIFEST_PATH + '\n');
|
|
} else {
|
|
process.stdout.write(JSON.stringify(buildManifest(), null, 2) + '\n');
|
|
}
|
|
}
|
|
|
|
runMain(main);
|