refactor: hard-fork GSD -> MSD (Make Software Done)

Mechanical rename produced by scripts/msd-rename.cjs: gsd/Gsd/GSD -> msd/Msd/MSD
across contents and paths, upstream package/repo coordinates -> @golem15/msd-core
and golem15com/msd-core. Deep links into upstream history, sibling upstream
packages, the GSD-2 import feature, CHANGELOG.md and .changeset/ are kept as-is.

Hand edits on top: MSD block-letter banner and logos, LICENSE copyright line,
package/plugin identity, regenerated lockfile, install-tree fixtures, derived
registries and benchmark baseline; migration checksum baseline re-locked
(MSD keeps its own install state, so no install had applied the old sums);
sort-order and regex-escaped expectations in tests adjusted.
This commit is contained in:
Jakub Zych
2026-10-06 01:47:40 +02:00
parent fe069b2a56
commit a9a7a328e6
2763 changed files with 78465 additions and 78434 deletions

View File

@@ -6,12 +6,12 @@ const assert = require('node:assert/strict');
const {
assertInstallerMigrationsUnblocked,
summarizeInstallerMigrationResult,
} = require('../gsd-core/bin/lib/installer-migration-report.cjs');
} = require('../msd-core/bin/lib/installer-migration-report.cjs');
test('summarizes every installer migration report category', () => {
const blockedAction = {
type: 'prompt-user',
relPath: 'hooks/gsd-retired-hook.js',
relPath: 'hooks/msd-retired-hook.js',
reason: 'needs a user choice',
};
const result = {
@@ -72,7 +72,7 @@ test('summarizes every installer migration report category', () => {
},
{
label: 'blocked',
relPath: 'hooks/gsd-retired-hook.js',
relPath: 'hooks/msd-retired-hook.js',
reason: 'needs a user choice',
},
]
@@ -82,7 +82,7 @@ test('summarizes every installer migration report category', () => {
test('collapses first-time baseline report rows without hiding destructive actions', () => {
const blockedAction = {
type: 'prompt-user',
relPath: 'hooks/gsd-ambiguous.js',
relPath: 'hooks/msd-ambiguous.js',
reason: 'needs a user choice',
};
const result = {
@@ -138,7 +138,7 @@ test('collapses first-time baseline report rows without hiding destructive actio
},
{
label: 'blocked',
relPath: 'hooks/gsd-ambiguous.js',
relPath: 'hooks/msd-ambiguous.js',
reason: 'needs a user choice',
},
]
@@ -155,7 +155,7 @@ test('throws when installer migrations require user choice', () => {
assertInstallerMigrationsUnblocked({
blocked: [
{
relPath: 'hooks/gsd-retired-hook.js',
relPath: 'hooks/msd-retired-hook.js',
reason: 'needs a user choice',
choices: ['keep', 'remove'],
},
@@ -167,10 +167,10 @@ test('throws when installer migrations require user choice', () => {
}
assert.ok(captured instanceof Error);
assert.match(captured.message, /installer migration blocked pending user choice/);
assert.match(captured.message, /hooks\/gsd-retired-hook\.js/);
assert.match(captured.message, /GSD_INSTALLER_MIGRATION_RESOLVE/);
assert.match(captured.message, /hooks\/msd-retired-hook\.js/);
assert.match(captured.message, /MSD_INSTALLER_MIGRATION_RESOLVE/);
assert.ok(captured.blockedByReason, 'error exposes grouped-by-reason data');
assert.equal(captured.resolutionEnvVar, 'GSD_INSTALLER_MIGRATION_RESOLVE');
assert.equal(captured.resolutionEnvVar, 'MSD_INSTALLER_MIGRATION_RESOLVE');
});
@@ -183,12 +183,12 @@ test('throws when installer migrations require user choice', () => {
/**
* Regression test for #3541: first-time-baseline installer migration
* `prompt-user` actions threw hard with no resolution path, making
* `/gsd-update` unrecoverable when leftover `gsd-*` files were classified
* as `stale-gsd-looking`.
* `/msd-update` unrecoverable when leftover `msd-*` files were classified
* as `stale-msd-looking`.
*
* Fix shape (per triage brief):
* A. Classify-and-default for safe categories - stale SDK build
* artifacts default to "remove"; user-facing skills/gsd-asterisk/SKILL.md
* artifacts default to "remove"; user-facing skills/msd-asterisk/SKILL.md
* defaults to "keep". Each resolution is logged.
* B. Improved error message when an unresolved prompt-user action
* remains: lists choices, suggests the resolution path, groups
@@ -201,7 +201,7 @@ test('throws when installer migrations require user choice', () => {
'use strict';
process.env.GSD_TEST_MODE = '1';
process.env.MSD_TEST_MODE = '1';
const { describe, test, beforeEach, afterEach } = require('node:test');
const assert = require('node:assert/strict');
@@ -210,11 +210,11 @@ const path = require('node:path');
const {
runInstallerMigrations,
} = require('../gsd-core/bin/lib/installer-migrations.cjs');
} = require('../msd-core/bin/lib/installer-migrations.cjs');
const {
assertInstallerMigrationsUnblocked,
resolveInstallerMigrationPromptsForNonTty,
} = require('../gsd-core/bin/lib/installer-migration-report.cjs');
} = require('../msd-core/bin/lib/installer-migration-report.cjs');
const { createTempDir, cleanup } = require('./helpers.cjs');
function writeFile(root, relPath, content) {
@@ -225,7 +225,7 @@ function writeFile(root, relPath, content) {
function writeManifest(root, files) {
fs.writeFileSync(
path.join(root, 'gsd-file-manifest.json'),
path.join(root, 'msd-file-manifest.json'),
JSON.stringify({
version: '1.41.2',
timestamp: '2026-05-10T00:00:00.000Z',
@@ -240,7 +240,7 @@ describe('#3541: installer migration prompt-user non-TTY resolution', { concurre
let configDir;
beforeEach(() => {
configDir = createTempDir('gsd-3541-');
configDir = createTempDir('msd-3541-');
});
afterEach(() => {
@@ -249,15 +249,15 @@ describe('#3541: installer migration prompt-user non-TTY resolution', { concurre
test('Test A: non-TTY default resolution removes stale SDK artifacts and keeps user skills', () => {
// Stale SDK build artifact: replicates the 1.41.2 → 1.42.2 upgrade where
// 24 stale `gsd-core/sdk/{dist,src}/gsd-*` files leaked into the
// 24 stale `msd-core/sdk/{dist,src}/msd-*` files leaked into the
// baseline because the new manifest no longer classifies them as managed.
writeFile(configDir, 'gsd-core/sdk/dist/gsd-old-bundle.js', 'stale sdk bundle\n');
// User-facing skill: replicates `skills/gsd-roadmap/SKILL.md` from the
writeFile(configDir, 'msd-core/sdk/dist/msd-old-bundle.js', 'stale sdk bundle\n');
// User-facing skill: replicates `skills/msd-roadmap/SKILL.md` from the
// same incident — user-owned content that must be preserved.
writeFile(configDir, 'skills/gsd-roadmap/SKILL.md', '# Roadmap skill\nuser content\n');
writeFile(configDir, 'skills/msd-roadmap/SKILL.md', '# Roadmap skill\nuser content\n');
// Plant an empty manifest so both files classify as `stale-gsd-looking`
// (they look like GSD artifacts but are not manifest-managed).
// Plant an empty manifest so both files classify as `stale-msd-looking`
// (they look like MSD artifacts but are not manifest-managed).
writeManifest(configDir, {});
const result = runInstallerMigrations({
@@ -272,7 +272,7 @@ describe('#3541: installer migration prompt-user non-TTY resolution', { concurre
const blockedPaths = (result.blocked || []).map((a) => a.relPath).sort();
assert.deepEqual(
blockedPaths,
['gsd-core/sdk/dist/gsd-old-bundle.js', 'skills/gsd-roadmap/SKILL.md'],
['msd-core/sdk/dist/msd-old-bundle.js', 'skills/msd-roadmap/SKILL.md'],
'precondition: both stale-looking files should be flagged for explicit user choice'
);
@@ -288,8 +288,8 @@ describe('#3541: installer migration prompt-user non-TTY resolution', { concurre
);
const byPath = new Map(resolved.resolutions.map((r) => [r.relPath, r]));
const sdkResolution = byPath.get('gsd-core/sdk/dist/gsd-old-bundle.js');
const skillResolution = byPath.get('skills/gsd-roadmap/SKILL.md');
const sdkResolution = byPath.get('msd-core/sdk/dist/msd-old-bundle.js');
const skillResolution = byPath.get('skills/msd-roadmap/SKILL.md');
assert.ok(sdkResolution, 'SDK artifact resolution logged');
assert.equal(sdkResolution.choice, 'remove', 'stale SDK build artifact defaults to remove');
@@ -318,18 +318,18 @@ describe('#3541: installer migration prompt-user non-TTY resolution', { concurre
const blocked = [
{
type: 'prompt-user',
relPath: 'gsd-core/sdk/dist/gsd-a.js',
reason: 'GSD-looking file is not proven manifest-managed and needs explicit user choice',
classification: 'stale-gsd-looking',
prompt: 'Choose whether to remove this stale-looking GSD artifact or keep it as user-owned.',
relPath: 'msd-core/sdk/dist/msd-a.js',
reason: 'MSD-looking file is not proven manifest-managed and needs explicit user choice',
classification: 'stale-msd-looking',
prompt: 'Choose whether to remove this stale-looking MSD artifact or keep it as user-owned.',
choices: ['keep', 'remove'],
},
{
type: 'prompt-user',
relPath: 'gsd-core/sdk/dist/gsd-b.js',
reason: 'GSD-looking file is not proven manifest-managed and needs explicit user choice',
classification: 'stale-gsd-looking',
prompt: 'Choose whether to remove this stale-looking GSD artifact or keep it as user-owned.',
relPath: 'msd-core/sdk/dist/msd-b.js',
reason: 'MSD-looking file is not proven manifest-managed and needs explicit user choice',
classification: 'stale-msd-looking',
prompt: 'Choose whether to remove this stale-looking MSD artifact or keep it as user-owned.',
choices: ['keep', 'remove'],
},
];
@@ -354,7 +354,7 @@ describe('#3541: installer migration prompt-user non-TTY resolution', { concurre
// surface — the message must point users at it.
assert.match(
message,
/GSD_INSTALLER_MIGRATION_RESOLVE/,
/MSD_INSTALLER_MIGRATION_RESOLVE/,
'error message suggests the non-interactive resolution env var'
);
@@ -381,7 +381,7 @@ describe('#3541: installer migration prompt-user non-TTY resolution', { concurre
blocked: [
{
type: 'prompt-user',
relPath: 'skills/gsd-custom/SKILL.toml',
relPath: 'skills/msd-custom/SKILL.toml',
reason: 'custom skill metadata requires user decision',
choices: ['keep', 'remove'],
},
@@ -391,7 +391,7 @@ describe('#3541: installer migration prompt-user non-TTY resolution', { concurre
blocked: [
{
type: 'prompt-user',
relPath: 'skills/gsd-custom/SKILL.toml',
relPath: 'skills/msd-custom/SKILL.toml',
reason: 'custom skill metadata requires user decision',
choices: ['keep', 'remove'],
},
@@ -401,12 +401,12 @@ describe('#3541: installer migration prompt-user non-TTY resolution', { concurre
const resolved = resolveInstallerMigrationPromptsForNonTty(result, {
isTty: false,
env: { GSD_INSTALLER_MIGRATION_RESOLVE: 'keep' },
env: { MSD_INSTALLER_MIGRATION_RESOLVE: 'keep' },
});
assert.equal(resolved.resolutions.length, 1, 'env override resolves prompt-user action');
assert.equal(resolved.resolutions[0].choice, 'keep');
assert.equal(resolved.resolutions[0].source, 'GSD_INSTALLER_MIGRATION_RESOLVE');
assert.equal(resolved.resolutions[0].source, 'MSD_INSTALLER_MIGRATION_RESOLVE');
assert.equal(resolved.resolutions[0].category, 'operator-override');
assert.equal((resolved.result.blocked || []).length, 0);
assert.equal((resolved.result.plan.blocked || []).length, 0);
@@ -425,17 +425,17 @@ describe('#3541: installer migration prompt-user non-TTY resolution', { concurre
const { describe: __foldDescribe } = require('node:test');
__foldDescribe("folded:bug-3610-installer-migration-bundled-hooks-classification (consolidation epic #1969 B5 #1974)", () => {
/**
* Regression test for #3610: fresh `npx @opengsd/gsd-core@latest --codex`
* hard-aborts when the target ~/.codex/hooks/ contains the bundled GSD
* hook files (`gsd-check-update-worker.js`, `gsd-prompt-guard.js`, …)
* Regression test for #3610: fresh `npx @golem15/msd-core@latest --codex`
* hard-aborts when the target ~/.codex/hooks/ contains the bundled MSD
* hook files (`msd-check-update-worker.js`, `msd-prompt-guard.js`, …)
* left over from a previous version. The installer-migration report
* classifies them as "GSD-looking file is not proven manifest-managed
* classifies them as "MSD-looking file is not proven manifest-managed
* and needs explicit user choice" and `assertInstallerMigrationsUnblocked`
* throws.
*
* The files in question are NOT user-owned — they are the GSD bundled
* hooks shipped under `hooks/gsd-*` in the npm package. The fix adds a
* `bundled-gsd-hook` classification to `classifyPromptUserAction` so the
* The files in question are NOT user-owned — they are the MSD bundled
* hooks shipped under `hooks/msd-*` in the npm package. The fix adds a
* `bundled-msd-hook` classification to `classifyPromptUserAction` so the
* resolver removes them (the installer then writes the fresh bundled
* versions in their place).
*
@@ -447,7 +447,7 @@ describe('#3541: installer migration prompt-user non-TTY resolution', { concurre
'use strict';
process.env.GSD_TEST_MODE = '1';
process.env.MSD_TEST_MODE = '1';
const { describe, test, beforeEach, afterEach } = require('node:test');
const assert = require('node:assert/strict');
@@ -456,12 +456,12 @@ const path = require('node:path');
const {
runInstallerMigrations,
} = require('../gsd-core/bin/lib/installer-migrations.cjs');
} = require('../msd-core/bin/lib/installer-migrations.cjs');
const {
assertInstallerMigrationsUnblocked,
resolveInstallerMigrationPromptsForNonTty,
classifyPromptUserAction,
} = require('../gsd-core/bin/lib/installer-migration-report.cjs');
} = require('../msd-core/bin/lib/installer-migration-report.cjs');
const { createTempDir, cleanup } = require('./helpers.cjs');
function writeFile(root, relPath, content) {
@@ -472,7 +472,7 @@ function writeFile(root, relPath, content) {
function writeManifest(root, files) {
fs.writeFileSync(
path.join(root, 'gsd-file-manifest.json'),
path.join(root, 'msd-file-manifest.json'),
JSON.stringify(
{
version: '1.41.2',
@@ -488,30 +488,30 @@ function writeManifest(root, files) {
}
// Reporter's exact list of blocked files from the v1.42.2 → v1.42.0 upgrade
// abort. Each is a real `hooks/gsd-*` file shipped under hooks/ in the npm
// abort. Each is a real `hooks/msd-*` file shipped under hooks/ in the npm
// package (verified by `ls hooks/`).
const BUNDLED_HOOK_RELPATHS = [
'hooks/gsd-check-update-worker.js',
'hooks/gsd-check-update.js',
'hooks/gsd-context-monitor.js',
'hooks/gsd-phase-boundary.sh',
'hooks/gsd-prompt-guard.js',
'hooks/gsd-read-guard.js',
'hooks/gsd-read-injection-scanner.js',
'hooks/gsd-session-state.sh',
'hooks/gsd-statusline.js',
'hooks/gsd-update-banner.js',
'hooks/gsd-validate-commit.sh',
'hooks/gsd-workflow-guard.js',
'hooks/msd-check-update-worker.js',
'hooks/msd-check-update.js',
'hooks/msd-context-monitor.js',
'hooks/msd-phase-boundary.sh',
'hooks/msd-prompt-guard.js',
'hooks/msd-read-guard.js',
'hooks/msd-read-injection-scanner.js',
'hooks/msd-session-state.sh',
'hooks/msd-statusline.js',
'hooks/msd-update-banner.js',
'hooks/msd-validate-commit.sh',
'hooks/msd-workflow-guard.js',
];
describe('bug #3610: classifyPromptUserAction recognizes bundled GSD hooks', () => {
test('classifies hooks/gsd-*.js as bundled-gsd-hook → remove', () => {
describe('bug #3610: classifyPromptUserAction recognizes bundled MSD hooks', () => {
test('classifies hooks/msd-*.js as bundled-msd-hook → remove', () => {
const result = classifyPromptUserAction({
relPath: 'hooks/gsd-prompt-guard.js',
relPath: 'hooks/msd-prompt-guard.js',
});
assert.ok(result, 'classifier returned null for a bundled GSD hook (.js)');
assert.strictEqual(result.category, 'bundled-gsd-hook');
assert.ok(result, 'classifier returned null for a bundled MSD hook (.js)');
assert.strictEqual(result.category, 'bundled-msd-hook');
assert.strictEqual(
result.choice,
'remove',
@@ -519,16 +519,16 @@ describe('bug #3610: classifyPromptUserAction recognizes bundled GSD hooks', ()
);
});
test('classifies hooks/gsd-*.sh as bundled-gsd-hook → remove', () => {
test('classifies hooks/msd-*.sh as bundled-msd-hook → remove', () => {
const result = classifyPromptUserAction({
relPath: 'hooks/gsd-validate-commit.sh',
relPath: 'hooks/msd-validate-commit.sh',
});
assert.ok(result);
assert.strictEqual(result.category, 'bundled-gsd-hook');
assert.strictEqual(result.category, 'bundled-msd-hook');
assert.strictEqual(result.choice, 'remove');
});
test('does NOT classify non-gsd hooks (preserves user-owned hook files)', () => {
test('does NOT classify non-msd hooks (preserves user-owned hook files)', () => {
// A user's custom hook that happens to live under hooks/ must NOT be
// auto-classified as bundled — the existing block-then-choose flow
// continues to apply, preserving the user's control over their files.
@@ -538,16 +538,16 @@ describe('bug #3610: classifyPromptUserAction recognizes bundled GSD hooks', ()
assert.strictEqual(
result,
null,
'non-gsd-prefixed hook must NOT auto-classify (would clobber user files)',
'non-msd-prefixed hook must NOT auto-classify (would clobber user files)',
);
});
test('does NOT classify deeper paths under hooks/gsd-* (e.g. hooks/lib/) as bundled-gsd-hook', () => {
// The bundled GSD distribution has hooks/lib/ (helper modules). Those
test('does NOT classify deeper paths under hooks/msd-* (e.g. hooks/lib/) as bundled-msd-hook', () => {
// The bundled MSD distribution has hooks/lib/ (helper modules). Those
// are managed differently — verify the classifier limits itself to
// top-level hooks/gsd-<name>.<ext> files, not nested directories.
// top-level hooks/msd-<name>.<ext> files, not nested directories.
const result = classifyPromptUserAction({
relPath: 'hooks/gsd-helpers/index.js',
relPath: 'hooks/msd-helpers/index.js',
});
assert.strictEqual(result, null);
});
@@ -557,7 +557,7 @@ describe('bug #3610: fresh upgrade with leftover bundled hooks does not throw',
let configDir;
beforeEach(() => {
configDir = createTempDir('gsd-3610-');
configDir = createTempDir('msd-3610-');
});
afterEach(() => {
@@ -565,7 +565,7 @@ describe('bug #3610: fresh upgrade with leftover bundled hooks does not throw',
});
test('end-to-end: 12 leftover bundled hooks + empty manifest → resolver clears all blockers', () => {
// Recreate the reporter's environment: 12 bundled `gsd-*` hook files
// Recreate the reporter's environment: 12 bundled `msd-*` hook files
// present at target, but the manifest has not yet seeded their baseline
// entries (first-time-baseline scan).
for (const rel of BUNDLED_HOOK_RELPATHS) {
@@ -585,7 +585,7 @@ describe('bug #3610: fresh upgrade with leftover bundled hooks does not throw',
assert.deepStrictEqual(
blockedPaths,
[...BUNDLED_HOOK_RELPATHS].sort(),
'precondition: every leftover hooks/gsd-* should be a prompt-user blocker',
'precondition: every leftover hooks/msd-* should be a prompt-user blocker',
);
// Resolve through the safe-default classifier (passing isTty=false to
@@ -600,7 +600,7 @@ describe('bug #3610: fresh upgrade with leftover bundled hooks does not throw',
);
for (const entry of resolved.resolutions) {
assert.strictEqual(entry.category, 'bundled-gsd-hook');
assert.strictEqual(entry.category, 'bundled-msd-hook');
assert.strictEqual(entry.choice, 'remove');
assert.strictEqual(entry.resolvedActionType, 'backup-and-remove');
}
@@ -630,18 +630,18 @@ describe('bug #3610: fresh upgrade with leftover bundled hooks does not throw',
// the contract.
/**
* Bug #3628: `bundled-gsd-hook` classifier (added in #3610) uses a shape
* regex (`/^hooks\/gsd-[^/]+\.(?:js|sh|cjs|mjs)$/`) that matches ANY file
* named `hooks/gsd-<name>.{js,sh,cjs,mjs}`, not only the 13 hook files
* Bug #3628: `bundled-msd-hook` classifier (added in #3610) uses a shape
* regex (`/^hooks\/msd-[^/]+\.(?:js|sh|cjs|mjs)$/`) that matches ANY file
* named `hooks/msd-<name>.{js,sh,cjs,mjs}`, not only the 13 hook files
* actually shipped in the npm distribution. The permissive shape regex
* silently auto-classifies — and on first-time-baseline scan auto-removes:
*
* - User-authored custom hooks (e.g. `hooks/gsd-personal-experiment.js`)
* - Retired bundled hooks from prior GSD versions
* - User-authored custom hooks (e.g. `hooks/msd-personal-experiment.js`)
* - Retired bundled hooks from prior MSD versions
*
* Fix: the classifier must whitelist the explicit set of shipped hook
* filenames sourced from a single point of truth (`BUNDLED_GSD_HOOK_FILES`
* exported from the classifier module). Any `hooks/gsd-<name>` file NOT in
* filenames sourced from a single point of truth (`BUNDLED_MSD_HOOK_FILES`
* exported from the classifier module). Any `hooks/msd-<name>` file NOT in
* that set must fall through to the existing block-or-prompt flow so the
* user retains control.
*/
@@ -653,25 +653,25 @@ const assert = require('node:assert/strict');
const {
classifyPromptUserAction,
BUNDLED_GSD_HOOK_FILES,
} = require('../gsd-core/bin/lib/installer-migration-report.cjs');
BUNDLED_MSD_HOOK_FILES,
} = require('../msd-core/bin/lib/installer-migration-report.cjs');
const path = require('node:path');
const fs = require('node:fs');
describe('bug #3628: BUNDLED_GSD_HOOK_FILES is an explicit whitelist', () => {
describe('bug #3628: BUNDLED_MSD_HOOK_FILES is an explicit whitelist', () => {
test('exports a Set of shipped hook filenames', () => {
assert.ok(
BUNDLED_GSD_HOOK_FILES instanceof Set,
'BUNDLED_GSD_HOOK_FILES must be exported as a Set so callers can probe membership',
BUNDLED_MSD_HOOK_FILES instanceof Set,
'BUNDLED_MSD_HOOK_FILES must be exported as a Set so callers can probe membership',
);
assert.ok(
BUNDLED_GSD_HOOK_FILES.size > 0,
'BUNDLED_GSD_HOOK_FILES must enumerate at least one shipped hook',
BUNDLED_MSD_HOOK_FILES.size > 0,
'BUNDLED_MSD_HOOK_FILES must enumerate at least one shipped hook',
);
});
test('every entry is a hooks/-prefixed posix path', () => {
for (const relPath of BUNDLED_GSD_HOOK_FILES) {
for (const relPath of BUNDLED_MSD_HOOK_FILES) {
assert.ok(
relPath.startsWith('hooks/'),
`entry ${JSON.stringify(relPath)} must be prefixed with "hooks/"`,
@@ -681,19 +681,19 @@ describe('bug #3628: BUNDLED_GSD_HOOK_FILES is an explicit whitelist', () => {
`entry ${JSON.stringify(relPath)} must use POSIX slashes`,
);
assert.ok(
relPath.includes('gsd-'),
`entry ${JSON.stringify(relPath)} must contain the "gsd-" prefix`,
relPath.includes('msd-'),
`entry ${JSON.stringify(relPath)} must contain the "msd-" prefix`,
);
}
});
test('every BUNDLED_GSD_HOOK_FILES entry corresponds to a real file in hooks/', () => {
test('every BUNDLED_MSD_HOOK_FILES entry corresponds to a real file in hooks/', () => {
// Sourcing the whitelist from a frozen constant is only durable if the
// constant stays aligned with the on-disk distribution. This guard
// fails the day someone removes a hook file but forgets to update the
// whitelist (or vice-versa).
const hooksDir = path.join(__dirname, '..', 'hooks');
for (const relPath of BUNDLED_GSD_HOOK_FILES) {
for (const relPath of BUNDLED_MSD_HOOK_FILES) {
const fullPath = path.join(hooksDir, relPath.slice('hooks/'.length));
assert.ok(
fs.existsSync(fullPath),
@@ -702,40 +702,40 @@ describe('bug #3628: BUNDLED_GSD_HOOK_FILES is an explicit whitelist', () => {
}
});
test('every gsd-*.{js,sh,cjs,mjs} file in hooks/ is in BUNDLED_GSD_HOOK_FILES (no shipping drift)', () => {
test('every msd-*.{js,sh,cjs,mjs} file in hooks/ is in BUNDLED_MSD_HOOK_FILES (no shipping drift)', () => {
const hooksDir = path.join(__dirname, '..', 'hooks');
const onDisk = fs
.readdirSync(hooksDir, { withFileTypes: true })
.filter((e) => e.isFile() && /^gsd-[^/]+\.(?:js|sh|cjs|mjs)$/.test(e.name))
.filter((e) => e.isFile() && /^msd-[^/]+\.(?:js|sh|cjs|mjs)$/.test(e.name))
.map((e) => `hooks/${e.name}`);
for (const relPath of onDisk) {
assert.ok(
BUNDLED_GSD_HOOK_FILES.has(relPath),
`${relPath} ships in hooks/ but is missing from BUNDLED_GSD_HOOK_FILES — whitelist drifted`,
BUNDLED_MSD_HOOK_FILES.has(relPath),
`${relPath} ships in hooks/ but is missing from BUNDLED_MSD_HOOK_FILES — whitelist drifted`,
);
}
});
});
describe('bug #3628: classifyPromptUserAction whitelists shipped bundled hooks', () => {
test('classifies every entry in BUNDLED_GSD_HOOK_FILES as bundled-gsd-hook → remove', () => {
for (const relPath of BUNDLED_GSD_HOOK_FILES) {
test('classifies every entry in BUNDLED_MSD_HOOK_FILES as bundled-msd-hook → remove', () => {
for (const relPath of BUNDLED_MSD_HOOK_FILES) {
const result = classifyPromptUserAction({ relPath });
assert.deepStrictEqual(
result,
{ category: 'bundled-gsd-hook', choice: 'remove' },
`${relPath} should classify as bundled-gsd-hook`,
{ category: 'bundled-msd-hook', choice: 'remove' },
`${relPath} should classify as bundled-msd-hook`,
);
}
});
const USER_OWNED_OR_RETIRED = [
'hooks/gsd-personal-experiment.js',
'hooks/gsd-my-custom-guard.sh',
'hooks/gsd-team-policy.cjs',
'hooks/gsd-retired-hook.js',
'hooks/gsd-old-statusline.js',
'hooks/gsd-experimental.mjs',
'hooks/msd-personal-experiment.js',
'hooks/msd-my-custom-guard.sh',
'hooks/msd-team-policy.cjs',
'hooks/msd-retired-hook.js',
'hooks/msd-old-statusline.js',
'hooks/msd-experimental.mjs',
];
for (const relPath of USER_OWNED_OR_RETIRED) {
@@ -748,14 +748,14 @@ describe('bug #3628: classifyPromptUserAction whitelists shipped bundled hooks',
});
}
test('still does NOT classify nested gsd-* directories (existing #3610 boundary preserved)', () => {
test('still does NOT classify nested msd-* directories (existing #3610 boundary preserved)', () => {
assert.strictEqual(
classifyPromptUserAction({ relPath: 'hooks/gsd-helpers/index.js' }),
classifyPromptUserAction({ relPath: 'hooks/msd-helpers/index.js' }),
null,
);
});
test('still does NOT classify non-gsd hooks (existing boundary preserved)', () => {
test('still does NOT classify non-msd hooks (existing boundary preserved)', () => {
assert.strictEqual(
classifyPromptUserAction({ relPath: 'hooks/my-custom-hook.js' }),
null,
@@ -781,7 +781,7 @@ const path = require('node:path');
const migration = require(path.join(
__dirname,
'..',
'gsd-core',
'msd-core',
'bin',
'lib',
'installer-migrations',
@@ -793,8 +793,8 @@ describe('bug #3442: codex legacy hooks.json migration consumes shared managed-h
const configDir = '/Users/me/.codex';
const hooksJson = {
hooks: [
{ command: '"/usr/local/bin/node" "/Users/me/.codex/hooks/gsd-check-update.js"' },
{ command: '"/usr/local/bin/node" "/Users/me/.codex/hooks/gsd-update-check.js"' },
{ command: '"/usr/local/bin/node" "/Users/me/.codex/hooks/msd-check-update.js"' },
{ command: '"/usr/local/bin/node" "/Users/me/.codex/hooks/msd-update-check.js"' },
{ command: '"/usr/local/bin/node" "/Users/me/.codex/hooks/custom-hook.js"' },
],
};
@@ -818,7 +818,7 @@ describe('bug #3442: codex legacy hooks.json migration consumes shared managed-h
const configDir = '/Users/me/.codex';
const hooksJson = {
hooks: [
{ command: '"/usr/local/bin/node" "/tmp/other/hooks/gsd-check-update.js"' },
{ command: '"/usr/local/bin/node" "/tmp/other/hooks/msd-check-update.js"' },
],
};