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

@@ -21,7 +21,7 @@ const path = require('path');
const { spawnSync } = require('child_process');
const ROOT = path.resolve(__dirname, '..');
const identity = require(path.join(ROOT, 'gsd-core', 'bin', 'lib', 'package-identity.cjs'));
const identity = require(path.join(ROOT, 'msd-core', 'bin', 'lib', 'package-identity.cjs'));
const pkg = require(path.join(ROOT, 'package.json'));
const { MANAGED_HOOKS } = require(path.join(ROOT, 'hooks', 'managed-hooks-registry.cjs'));
const { cleanup, TEST_ENV_BASE } = require('./helpers.cjs');
@@ -47,7 +47,7 @@ describe('A: .claude-plugin/plugin.json', () => {
assert.ok(typeof manifest === 'object' && manifest !== null, 'manifest must be a JSON object');
});
test('name equals identity.binName ("gsd-core")', (t) => {
test('name equals identity.binName ("msd-core")', (t) => {
if (!manifest) { t.skip('manifest could not be parsed'); return; }
assert.equal(manifest.name, identity.binName, `name should be "${identity.binName}"`);
});
@@ -89,9 +89,9 @@ describe('A: .claude-plugin/plugin.json', () => {
);
});
test('commands field is "./commands/gsd/" and that dir exists with at least one .md file', (t) => {
test('commands field is "./commands/msd/" and that dir exists with at least one .md file', (t) => {
if (!manifest) { t.skip('manifest could not be parsed'); return; }
assert.equal(manifest.commands, './commands/gsd/', 'commands must be "./commands/gsd/"');
assert.equal(manifest.commands, './commands/msd/', 'commands must be "./commands/msd/"');
const resolvedDir = path.resolve(path.dirname(PLUGIN_JSON_PATH), '..', manifest.commands);
assert.ok(fs.existsSync(resolvedDir), `resolved commands dir must exist: ${resolvedDir}`);
const mdFiles = fs.readdirSync(resolvedDir).filter(f => f.endsWith('.md'));
@@ -189,14 +189,14 @@ describe('B: hooks/hooks.json', () => {
test('all eight always-on hooks are wired', (t) => {
if (!hooksConfig) { t.skip('hooks.json could not be parsed'); return; }
const REQUIRED_HOOKS = [
'gsd-check-update.js',
'gsd-prompt-guard.js',
'gsd-read-guard.js',
'gsd-worktree-path-guard.js',
'gsd-write-guard.js',
'gsd-secret-read-guard.js',
'gsd-context-monitor.js',
'gsd-read-injection-scanner.js',
'msd-check-update.js',
'msd-prompt-guard.js',
'msd-read-guard.js',
'msd-worktree-path-guard.js',
'msd-write-guard.js',
'msd-secret-read-guard.js',
'msd-context-monitor.js',
'msd-read-injection-scanner.js',
];
// Collect all basenames wired in hooks.json
const wiredBasenames = new Set();
@@ -216,20 +216,20 @@ describe('B: hooks/hooks.json', () => {
}
});
test('gsd-context-monitor.js entry has timeout === 10', (t) => {
test('msd-context-monitor.js entry has timeout === 10', (t) => {
if (!hooksConfig) { t.skip('hooks.json could not be parsed'); return; }
let found = false;
for (const eventEntries of Object.values(hooksConfig.hooks)) {
for (const entry of eventEntries) {
for (const hook of entry.hooks) {
if (hook.command && hook.command.includes('gsd-context-monitor.js')) {
if (hook.command && hook.command.includes('msd-context-monitor.js')) {
found = true;
assert.equal(hook.timeout, 10, 'gsd-context-monitor.js must have timeout === 10');
assert.equal(hook.timeout, 10, 'msd-context-monitor.js must have timeout === 10');
}
}
}
}
assert.ok(found, 'gsd-context-monitor.js entry was not found in hooks.json');
assert.ok(found, 'msd-context-monitor.js entry was not found in hooks.json');
});
});
@@ -387,14 +387,14 @@ describe('C: plugin.json schema validation', () => {
// 1. Inheriting the developer's ambient CLAUDE_CONFIG_DIR makes even a bare
// `--version` probe write into their live config dir. That alone kept
// `CLAUDE_CONFIG_DIR=<dir> npm run test:unit; find <dir> -type f` from
// returning empty after every GSD-side leak was closed.
// 2. BLANKING it (TEST_ENV_BASE's '' convention) is not enough here. GSD's
// returning empty after every MSD-side leak was closed.
// 2. BLANKING it (TEST_ENV_BASE's '' convention) is not enough here. MSD's
// own resolvers treat '' as falsy and fall back to the home dir, but this
// binary is not ours and gives no such guarantee -- blanking it produced a
// stray backups/ directory in the REPO ROOT.
//
// So point it at a real throwaway dir rather than at nothing.
const claudeCliHome = fs.mkdtempSync(path.join(os.tmpdir(), 'gsd-2665-claude-cli-'));
const claudeCliHome = fs.mkdtempSync(path.join(os.tmpdir(), 'msd-2665-claude-cli-'));
const claudeCliEnv = () => ({
...process.env,
...TEST_ENV_BASE,
@@ -438,18 +438,18 @@ describe('C: plugin.json schema validation', () => {
/**
* One entry that must survive the copy into each component tree, so C3 catches
* a partial copy rather than only a wholly empty one. `commands/gsd` and
* a partial copy rather than only a wholly empty one. `commands/msd` and
* `skills/` are what `.claude-plugin/plugin.json` declares; `hooks/hooks.json`
* is the manifest the runtime loads and the one entry hooks/ cannot be useful
* without.
*/
const EXPECTED_ENTRY = {
commands: 'gsd',
commands: 'msd',
hooks: 'hooks.json',
skills: 'gsd-add-tests',
skills: 'msd-add-tests',
// #3751: agents/ is undeclared in plugin.json (CLI-convention pickup), so
// the expected entry is a shipped agent file, not a manifest-declared path.
agents: 'gsd-executor.md',
agents: 'msd-executor.md',
};
/**
@@ -475,7 +475,7 @@ describe('C: plugin.json schema validation', () => {
}
function buildValidationPluginRoot() {
const pluginRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'gsd-plugin-validate-'));
const pluginRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'msd-plugin-validate-'));
// Construction is self-cleaning: the callers' try/finally only begins once
// this returns, so a throw partway through would otherwise strand a
// half-built root on disk. Before this helper existed the same steps ran
@@ -561,8 +561,8 @@ describe('C: plugin.json schema validation', () => {
const entries = fs.readdirSync(agentsDir);
assert.ok(entries.length > 0, 'agents/ is EMPTY in the C2 validation fixture');
assert.ok(
entries.some((e) => /^gsd-.*\.md$/.test(e)),
'agents/ must carry the shipped gsd-*.md files, not a stub'
entries.some((e) => /^msd-.*\.md$/.test(e)),
'agents/ must carry the shipped msd-*.md files, not a stub'
);
} finally {
cleanup(pluginRoot);
@@ -728,10 +728,10 @@ describe('D: always-on hook contract drift guard', () => {
return map;
}
test('SessionStart: one no-matcher group with gsd-ensure-canonical-path.js then gsd-check-update.js', () => {
// #997: gsd-ensure-canonical-path.js is wired alongside gsd-check-update.js
test('SessionStart: one no-matcher group with msd-ensure-canonical-path.js then msd-check-update.js', () => {
// #997: msd-ensure-canonical-path.js is wired alongside msd-check-update.js
// in the single SessionStart no-matcher group. It must run FIRST so the
// canonical ~/.claude/gsd-core path (and its @-include targets) exist before
// canonical ~/.claude/msd-core path (and its @-include targets) exist before
// any other SessionStart logic that may read the bundled tree.
const map = buildHookMap();
const groups = map['SessionStart'];
@@ -743,21 +743,21 @@ describe('D: always-on hook contract drift guard', () => {
`SessionStart no-matcher group must contain exactly two hooks; got: ${JSON.stringify(noMatcherHooks)}`
);
assert.equal(
noMatcherHooks[0].script, 'gsd-ensure-canonical-path.js',
'gsd-ensure-canonical-path.js must be the FIRST SessionStart hook (#997)'
noMatcherHooks[0].script, 'msd-ensure-canonical-path.js',
'msd-ensure-canonical-path.js must be the FIRST SessionStart hook (#997)'
);
assert.equal(
noMatcherHooks[0].timeout, 5,
'gsd-ensure-canonical-path.js must have a small timeout (5s) — symlink setup is fast'
'msd-ensure-canonical-path.js must have a small timeout (5s) — symlink setup is fast'
);
assert.equal(
noMatcherHooks[1].script, 'gsd-check-update.js',
'gsd-check-update.js must remain a SessionStart hook'
noMatcherHooks[1].script, 'msd-check-update.js',
'msd-check-update.js must remain a SessionStart hook'
);
assert.equal(noMatcherHooks[1].timeout, undefined, 'gsd-check-update.js must NOT have a timeout field');
assert.equal(noMatcherHooks[1].timeout, undefined, 'msd-check-update.js must NOT have a timeout field');
});
test('PreToolUse Write|Edit group: gsd-prompt-guard.js (timeout 5) + gsd-read-guard.js (timeout 5)', () => {
test('PreToolUse Write|Edit group: msd-prompt-guard.js (timeout 5) + msd-read-guard.js (timeout 5)', () => {
const map = buildHookMap();
const groups = map['PreToolUse'];
assert.ok(groups, 'PreToolUse must be present in hooks.json');
@@ -766,13 +766,13 @@ describe('D: always-on hook contract drift guard', () => {
Array.isArray(hooks) && hooks.length === 2,
`PreToolUse Write|Edit must have exactly 2 hooks; got: ${JSON.stringify(hooks)}`
);
assert.equal(hooks[0].script, 'gsd-prompt-guard.js', 'first hook must be gsd-prompt-guard.js');
assert.equal(hooks[0].timeout, 5, 'gsd-prompt-guard.js must have timeout 5');
assert.equal(hooks[1].script, 'gsd-read-guard.js', 'second hook must be gsd-read-guard.js');
assert.equal(hooks[1].timeout, 5, 'gsd-read-guard.js must have timeout 5');
assert.equal(hooks[0].script, 'msd-prompt-guard.js', 'first hook must be msd-prompt-guard.js');
assert.equal(hooks[0].timeout, 5, 'msd-prompt-guard.js must have timeout 5');
assert.equal(hooks[1].script, 'msd-read-guard.js', 'second hook must be msd-read-guard.js');
assert.equal(hooks[1].timeout, 5, 'msd-read-guard.js must have timeout 5');
});
test('PreToolUse Write|Edit|MultiEdit group: gsd-worktree-path-guard.js (timeout 5)', () => {
test('PreToolUse Write|Edit|MultiEdit group: msd-worktree-path-guard.js (timeout 5)', () => {
const map = buildHookMap();
const groups = map['PreToolUse'];
assert.ok(groups, 'PreToolUse must be present in hooks.json');
@@ -781,11 +781,11 @@ describe('D: always-on hook contract drift guard', () => {
Array.isArray(hooks) && hooks.length === 1,
`PreToolUse Write|Edit|MultiEdit must have exactly 1 hook; got: ${JSON.stringify(hooks)}`
);
assert.equal(hooks[0].script, 'gsd-worktree-path-guard.js', 'hook must be gsd-worktree-path-guard.js');
assert.equal(hooks[0].timeout, 5, 'gsd-worktree-path-guard.js must have timeout 5');
assert.equal(hooks[0].script, 'msd-worktree-path-guard.js', 'hook must be msd-worktree-path-guard.js');
assert.equal(hooks[0].timeout, 5, 'msd-worktree-path-guard.js must have timeout 5');
});
test('PreToolUse Write group: gsd-write-guard.js (timeout 5)', () => {
test('PreToolUse Write group: msd-write-guard.js (timeout 5)', () => {
const map = buildHookMap();
const groups = map['PreToolUse'];
assert.ok(groups, 'PreToolUse must be present in hooks.json');
@@ -797,11 +797,11 @@ describe('D: always-on hook contract drift guard', () => {
Array.isArray(hooks) && hooks.length === 1,
`PreToolUse Write must have exactly 1 hook; got: ${JSON.stringify(hooks)}`
);
assert.equal(hooks[0].script, 'gsd-write-guard.js', 'hook must be gsd-write-guard.js');
assert.equal(hooks[0].timeout, 5, 'gsd-write-guard.js must have timeout 5');
assert.equal(hooks[0].script, 'msd-write-guard.js', 'hook must be msd-write-guard.js');
assert.equal(hooks[0].timeout, 5, 'msd-write-guard.js must have timeout 5');
});
test('PreToolUse Read|Grep|Bash group: gsd-secret-read-guard.js (timeout 5)', () => {
test('PreToolUse Read|Grep|Bash group: msd-secret-read-guard.js (timeout 5)', () => {
const map = buildHookMap();
const groups = map['PreToolUse'];
assert.ok(groups, 'PreToolUse must be present in hooks.json');
@@ -812,11 +812,11 @@ describe('D: always-on hook contract drift guard', () => {
Array.isArray(hooks) && hooks.length === 1,
`PreToolUse Read|Grep|Bash must have exactly 1 hook; got: ${JSON.stringify(hooks)}`
);
assert.equal(hooks[0].script, 'gsd-secret-read-guard.js', 'hook must be gsd-secret-read-guard.js');
assert.equal(hooks[0].timeout, 5, 'gsd-secret-read-guard.js must have timeout 5');
assert.equal(hooks[0].script, 'msd-secret-read-guard.js', 'hook must be msd-secret-read-guard.js');
assert.equal(hooks[0].timeout, 5, 'msd-secret-read-guard.js must have timeout 5');
});
test('PostToolUse Bash|Edit|Write|MultiEdit|Agent|Task group: gsd-context-monitor.js (timeout 10)', () => {
test('PostToolUse Bash|Edit|Write|MultiEdit|Agent|Task group: msd-context-monitor.js (timeout 10)', () => {
const map = buildHookMap();
const groups = map['PostToolUse'];
assert.ok(groups, 'PostToolUse must be present in hooks.json');
@@ -825,11 +825,11 @@ describe('D: always-on hook contract drift guard', () => {
Array.isArray(hooks) && hooks.length === 1,
`PostToolUse Bash|Edit|Write|MultiEdit|Agent|Task must have exactly 1 hook; got: ${JSON.stringify(hooks)}`
);
assert.equal(hooks[0].script, 'gsd-context-monitor.js', 'hook must be gsd-context-monitor.js');
assert.equal(hooks[0].timeout, 10, 'gsd-context-monitor.js must have timeout 10');
assert.equal(hooks[0].script, 'msd-context-monitor.js', 'hook must be msd-context-monitor.js');
assert.equal(hooks[0].timeout, 10, 'msd-context-monitor.js must have timeout 10');
});
test('PostToolUse Read|WebFetch|WebSearch group: gsd-read-injection-scanner.js (timeout 5)', () => {
test('PostToolUse Read|WebFetch|WebSearch group: msd-read-injection-scanner.js (timeout 5)', () => {
const map = buildHookMap();
const groups = map['PostToolUse'];
assert.ok(groups, 'PostToolUse must be present in hooks.json');
@@ -840,8 +840,8 @@ describe('D: always-on hook contract drift guard', () => {
Array.isArray(hooks) && hooks.length === 1,
`PostToolUse Read|WebFetch|WebSearch must have exactly 1 hook; got: ${JSON.stringify(hooks)}`
);
assert.equal(hooks[0].script, 'gsd-read-injection-scanner.js', 'hook must be gsd-read-injection-scanner.js');
assert.equal(hooks[0].timeout, 5, 'gsd-read-injection-scanner.js must have timeout 5');
assert.equal(hooks[0].script, 'msd-read-injection-scanner.js', 'hook must be msd-read-injection-scanner.js');
assert.equal(hooks[0].timeout, 5, 'msd-read-injection-scanner.js must have timeout 5');
});
});
@@ -849,14 +849,14 @@ describe('D: always-on hook contract drift guard', () => {
describe('E: config-gated (opt-in) hooks must not appear in hooks.json', () => {
const CONFIG_GATED_HOOKS = [
'gsd-workflow-guard.js',
'gsd-validate-commit.sh',
'gsd-graphify-update.sh',
'gsd-session-state.sh',
'gsd-phase-boundary.sh',
'gsd-update-banner.js',
'gsd-statusline.js',
'gsd-check-update-worker.js',
'msd-workflow-guard.js',
'msd-validate-commit.sh',
'msd-graphify-update.sh',
'msd-session-state.sh',
'msd-phase-boundary.sh',
'msd-update-banner.js',
'msd-statusline.js',
'msd-check-update-worker.js',
];
test('none of the config-gated hook basenames appear in hooks.json command strings', () => {
@@ -874,12 +874,12 @@ describe('E: config-gated (opt-in) hooks must not appear in hooks.json', () => {
// ─── Section F: #997 canonical-path hook registration ────────────────────────
//
// gsd-ensure-canonical-path.js must be shipped + wired so plugin installs get a
// real ~/.claude/gsd-core directory (with the immutable bundled subdirs
// symlinked) — otherwise every `@~/.claude/gsd-core/...` include in agents /
// msd-ensure-canonical-path.js must be shipped + wired so plugin installs get a
// real ~/.claude/msd-core directory (with the immutable bundled subdirs
// symlinked) — otherwise every `@~/.claude/msd-core/...` include in agents /
// commands / templates resolves to nothing and agents fail (#997).
describe('F: #997 gsd-ensure-canonical-path.js is shipped and wired', () => {
const HOOK_BASENAME = 'gsd-ensure-canonical-path.js';
describe('F: #997 msd-ensure-canonical-path.js is shipped and wired', () => {
const HOOK_BASENAME = 'msd-ensure-canonical-path.js';
test('hook source file exists in hooks/', () => {
assert.ok(
@@ -933,7 +933,7 @@ describe('F: #997 gsd-ensure-canonical-path.js is shipped and wired', () => {
// filesystem state, not source text.
describe('G: #997 ensureCanonicalPath() behavioural regression', () => {
const { ensureCanonicalPath, dirLinkType, MANAGED_SUBDIRS } =
require(path.join(ROOT, 'hooks', 'gsd-ensure-canonical-path.js'));
require(path.join(ROOT, 'hooks', 'msd-ensure-canonical-path.js'));
test('win32 uses a junction; other platforms use a dir symlink', () => {
// Junction correctness is an explicit requirement but real junctions can
@@ -947,18 +947,18 @@ describe('G: #997 ensureCanonicalPath() behavioural regression', () => {
let tmp;
beforeEach(() => {
tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'gsd-997-'));
tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'msd-997-'));
});
afterEach(() => {
// eslint-disable-next-line local/no-raw-rmsync-in-tests -- per-test temp cleanup, swallows ENOENT
try { fs.rmSync(tmp, { recursive: true, force: true }); } catch { /* ignore */ }
});
// Build a fake plugin layout: <tmp>/plugin/gsd-core/<subdir>/marker.md and a
// Build a fake plugin layout: <tmp>/plugin/msd-core/<subdir>/marker.md and a
// separate fake home <tmp>/home with an (initially absent) .claude dir.
function makePluginLayout(subdirs = MANAGED_SUBDIRS) {
const pluginRoot = path.join(tmp, 'plugin');
const bundled = path.join(pluginRoot, 'gsd-core');
const bundled = path.join(pluginRoot, 'msd-core');
for (const sub of subdirs) {
fs.mkdirSync(path.join(bundled, sub), { recursive: true });
fs.writeFileSync(path.join(bundled, sub, 'marker.md'), `bundled ${sub}`);
@@ -968,12 +968,12 @@ describe('G: #997 ensureCanonicalPath() behavioural regression', () => {
return { pluginRoot, homeDir, bundled };
}
test('plugin layout: creates ~/.claude/gsd-core with all subdirs symlinked to the bundle', () => {
test('plugin layout: creates ~/.claude/msd-core with all subdirs symlinked to the bundle', () => {
const { pluginRoot, homeDir, bundled } = makePluginLayout();
const result = ensureCanonicalPath({ pluginRoot, homeDir, platform: 'linux', env: {} });
assert.equal(result.status, 'ensured', `expected ensured; got ${JSON.stringify(result)}`);
const canonical = path.join(homeDir, '.claude', 'gsd-core');
const canonical = path.join(homeDir, '.claude', 'msd-core');
assert.ok(fs.existsSync(canonical), 'canonical dir must exist');
for (const sub of MANAGED_SUBDIRS) {
@@ -1009,7 +1009,7 @@ describe('G: #997 ensureCanonicalPath() behavioural regression', () => {
const { pluginRoot, homeDir } = makePluginLayout();
// Simulate a classic bin/install.js layout: canonical dir is a REAL dir with
// REAL subdirs (not symlinks).
const canonical = path.join(homeDir, '.claude', 'gsd-core');
const canonical = path.join(homeDir, '.claude', 'msd-core');
for (const sub of MANAGED_SUBDIRS) {
fs.mkdirSync(path.join(canonical, sub), { recursive: true });
fs.writeFileSync(path.join(canonical, sub, 'real.md'), `classic ${sub}`);
@@ -1028,12 +1028,12 @@ describe('G: #997 ensureCanonicalPath() behavioural regression', () => {
const result = ensureCanonicalPath({ pluginRoot: undefined, homeDir, platform: 'linux', env: {} });
assert.equal(result.status, 'noop');
assert.equal(result.reason, 'no-plugin-bundle');
assert.ok(!fs.existsSync(path.join(homeDir, '.claude', 'gsd-core')), 'must not create canonical dir');
assert.ok(!fs.existsSync(path.join(homeDir, '.claude', 'msd-core')), 'must not create canonical dir');
});
test('boundary: bundled gsd-core dir missing under plugin root → no-op', () => {
test('boundary: bundled msd-core dir missing under plugin root → no-op', () => {
const pluginRoot = path.join(tmp, 'plugin-empty');
fs.mkdirSync(pluginRoot, { recursive: true }); // no gsd-core/ inside
fs.mkdirSync(pluginRoot, { recursive: true }); // no msd-core/ inside
const homeDir = path.join(tmp, 'home');
fs.mkdirSync(path.join(homeDir, '.claude'), { recursive: true });
const result = ensureCanonicalPath({ pluginRoot, homeDir, platform: 'linux', env: {} });
@@ -1043,7 +1043,7 @@ describe('G: #997 ensureCanonicalPath() behavioural regression', () => {
test('preserve: a real user file at a managed link target is never clobbered', () => {
const { pluginRoot, homeDir } = makePluginLayout();
const canonical = path.join(homeDir, '.claude', 'gsd-core');
const canonical = path.join(homeDir, '.claude', 'msd-core');
fs.mkdirSync(canonical, { recursive: true });
// User (or partial state) put a REAL directory at 'references' with content.
fs.mkdirSync(path.join(canonical, 'references'), { recursive: true });
@@ -1064,7 +1064,7 @@ describe('G: #997 ensureCanonicalPath() behavioural regression', () => {
test('preserve user-generated top-level file (USER-PROFILE.md) while linking subdirs', () => {
const { pluginRoot, homeDir } = makePluginLayout();
const canonical = path.join(homeDir, '.claude', 'gsd-core');
const canonical = path.join(homeDir, '.claude', 'msd-core');
fs.mkdirSync(canonical, { recursive: true });
// A user-generated file at the TOP of the canonical dir (not a managed
// subdir) — must never be removed. No managed subdir is real yet, so the
@@ -1085,11 +1085,11 @@ describe('G: #997 ensureCanonicalPath() behavioural regression', () => {
test('self-heal: a stale symlink (pointing at a removed prior plugin version) is pruned and recreated', () => {
const { pluginRoot, homeDir } = makePluginLayout();
const canonical = path.join(homeDir, '.claude', 'gsd-core');
const canonical = path.join(homeDir, '.claude', 'msd-core');
fs.mkdirSync(canonical, { recursive: true });
// Simulate a stale link left by a previous plugin version that has since
// been removed (claude plugin update rotated the version dir).
const stalePrior = path.join(tmp, 'plugin-OLD', 'gsd-core', 'references');
const stalePrior = path.join(tmp, 'plugin-OLD', 'msd-core', 'references');
fs.mkdirSync(stalePrior, { recursive: true });
const linkPath = path.join(canonical, 'references');
fs.symlinkSync(stalePrior, linkPath, 'dir');
@@ -1103,43 +1103,43 @@ describe('G: #997 ensureCanonicalPath() behavioural regression', () => {
// Now resolves to the CURRENT bundle.
assert.equal(
fs.realpathSync(linkPath),
fs.realpathSync(path.join(pluginRoot, 'gsd-core', 'references')),
fs.realpathSync(path.join(pluginRoot, 'msd-core', 'references')),
'references must now point at the current bundled tree'
);
});
test('self-heal: a managed symlink pointing at the wrong (but existing) target is repointed', () => {
const { pluginRoot, homeDir } = makePluginLayout();
const canonical = path.join(homeDir, '.claude', 'gsd-core');
const canonical = path.join(homeDir, '.claude', 'msd-core');
fs.mkdirSync(canonical, { recursive: true });
// A link to some OTHER real directory (e.g. a different plugin version still
// on disk). It is a valid link but points at the wrong place.
const otherDir = path.join(tmp, 'plugin-OTHER', 'gsd-core', 'workflows');
const otherDir = path.join(tmp, 'plugin-OTHER', 'msd-core', 'workflows');
fs.mkdirSync(otherDir, { recursive: true });
fs.symlinkSync(otherDir, path.join(canonical, 'workflows'), 'dir');
const result = ensureCanonicalPath({ pluginRoot, homeDir, platform: 'linux', env: {} });
assert.equal(result.status, 'ensured');
assert.equal(
fs.realpathSync(path.join(canonical, 'workflows')),
fs.realpathSync(path.join(pluginRoot, 'gsd-core', 'workflows')),
fs.realpathSync(path.join(pluginRoot, 'msd-core', 'workflows')),
'workflows must be repointed to the current bundle'
);
});
test('security: bundled gsd-core that symlinks OUTSIDE the plugin root is rejected', () => {
test('security: bundled msd-core that symlinks OUTSIDE the plugin root is rejected', () => {
const pluginRoot = path.join(tmp, 'plugin-evil');
fs.mkdirSync(pluginRoot, { recursive: true });
// Attacker places a symlink at <pluginRoot>/gsd-core pointing outside root.
// Attacker places a symlink at <pluginRoot>/msd-core pointing outside root.
const outside = path.join(tmp, 'OUTSIDE');
fs.mkdirSync(path.join(outside, 'references'), { recursive: true });
fs.symlinkSync(outside, path.join(pluginRoot, 'gsd-core'), 'dir');
fs.symlinkSync(outside, path.join(pluginRoot, 'msd-core'), 'dir');
const homeDir = path.join(tmp, 'home');
fs.mkdirSync(path.join(homeDir, '.claude'), { recursive: true });
const result = ensureCanonicalPath({ pluginRoot, homeDir, platform: 'linux', env: {} });
assert.equal(result.status, 'noop', 'a bundled tree resolving outside the plugin root must be rejected');
assert.equal(result.reason, 'no-plugin-bundle');
assert.ok(
!fs.existsSync(path.join(homeDir, '.claude', 'gsd-core', 'references')),
!fs.existsSync(path.join(homeDir, '.claude', 'msd-core', 'references')),
'must NOT link the canonical path at content outside the plugin root'
);
});
@@ -1153,18 +1153,18 @@ describe('G: #997 ensureCanonicalPath() behavioural regression', () => {
env: { CLAUDE_CONFIG_DIR: customCfg },
});
assert.equal(result.status, 'ensured');
assert.equal(result.canonicalDir, path.join(customCfg, 'gsd-core'));
assert.ok(fs.lstatSync(path.join(customCfg, 'gsd-core', 'references')).isSymbolicLink());
assert.equal(result.canonicalDir, path.join(customCfg, 'msd-core'));
assert.ok(fs.lstatSync(path.join(customCfg, 'msd-core', 'references')).isSymbolicLink());
});
test('canonical path is itself a symlink → no-op (never writes links through a user-pointed symlink)', () => {
// A user pointed ~/.claude/gsd-core at some other directory via a symlink.
// A user pointed ~/.claude/msd-core at some other directory via a symlink.
// The hook must NOT create managed links through it into a dir it does not
// own — it bails as a no-op.
const { pluginRoot, homeDir } = makePluginLayout();
const userTarget = path.join(tmp, 'user-gsd');
const userTarget = path.join(tmp, 'user-msd');
fs.mkdirSync(userTarget, { recursive: true });
const canonical = path.join(homeDir, '.claude', 'gsd-core');
const canonical = path.join(homeDir, '.claude', 'msd-core');
fs.symlinkSync(userTarget, canonical, 'dir');
const result = ensureCanonicalPath({ pluginRoot, homeDir, platform: 'linux', env: {} });
@@ -1207,7 +1207,7 @@ describe('G: #997 ensureCanonicalPath() behavioural regression', () => {
assert.ok(result.linked.includes('workflows'), 'legit subdir still linked');
assert.ok(result.skipped.includes('references'), 'escaping subdir must be skipped');
assert.ok(
!fs.existsSync(path.join(homeDir, '.claude', 'gsd-core', 'references')),
!fs.existsSync(path.join(homeDir, '.claude', 'msd-core', 'references')),
'canonical path must NOT expose the escaping subdir'
);
});
@@ -1229,8 +1229,8 @@ describe('G: #997 ensureCanonicalPath() behavioural regression', () => {
//
// ADR-766 originally projected commands + hooks but NOT skills. Phase B-provide
// (#1596) adds a build-generated `skills/` dir + a `skills` manifest field so
// plugin-installed GSD exposes `gsd-core:<skill>` the native Claude Code way.
// The skills are generated from `commands/gsd/*.md` by
// plugin-installed MSD exposes `msd-core:<skill>` the native Claude Code way.
// The skills are generated from `commands/msd/*.md` by
// `scripts/gen-plugin-skills.cjs` using `convertClaudeCommandToClaudeSkill`.
describe('H: skills surface projection (#1596)', () => {
const SKILLS_DIR = path.resolve(ROOT, 'skills');
@@ -1243,11 +1243,11 @@ describe('H: skills surface projection (#1596)', () => {
);
});
test('skills/ dir exists with at least one gsd-*/SKILL.md', () => {
test('skills/ dir exists with at least one msd-*/SKILL.md', () => {
assert.ok(fs.existsSync(SKILLS_DIR), `skills/ dir must exist (run: npm run gen:plugin-skills -- --write): ${SKILLS_DIR}`);
const entries = fs.readdirSync(SKILLS_DIR, { withFileTypes: true });
const skillDirs = entries.filter(e => e.isDirectory() && e.name.startsWith('gsd-'));
assert.ok(skillDirs.length > 0, 'skills/ must contain at least one gsd-*/ directory');
const skillDirs = entries.filter(e => e.isDirectory() && e.name.startsWith('msd-'));
assert.ok(skillDirs.length > 0, 'skills/ must contain at least one msd-*/ directory');
// Each must have a SKILL.md
for (const dir of skillDirs) {
const skillMd = path.join(SKILLS_DIR, dir.name, 'SKILL.md');
@@ -1258,7 +1258,7 @@ describe('H: skills surface projection (#1596)', () => {
test('every generated SKILL.md has name: and description: frontmatter', () => {
assert.ok(fs.existsSync(SKILLS_DIR), 'skills/ must exist');
const skillDirs = fs.readdirSync(SKILLS_DIR, { withFileTypes: true })
.filter(e => e.isDirectory() && e.name.startsWith('gsd-'));
.filter(e => e.isDirectory() && e.name.startsWith('msd-'));
assert.ok(skillDirs.length > 0, 'must have at least one skill dir');
for (const dir of skillDirs) {
const raw = fs.readFileSync(path.join(SKILLS_DIR, dir.name, 'SKILL.md'), 'utf-8');
@@ -1272,13 +1272,13 @@ describe('H: skills surface projection (#1596)', () => {
});
test('parity: one skill dir per command file (DEFECT.GENERATIVE-FIX)', () => {
const commandsDir = path.resolve(ROOT, 'commands', 'gsd');
const commandsDir = path.resolve(ROOT, 'commands', 'msd');
const commandFiles = fs.readdirSync(commandsDir).filter(f => f.endsWith('.md'));
const skillDirs = fs.readdirSync(SKILLS_DIR, { withFileTypes: true })
.filter(e => e.isDirectory() && e.name.startsWith('gsd-'));
.filter(e => e.isDirectory() && e.name.startsWith('msd-'));
assert.equal(
skillDirs.length, commandFiles.length,
`skills/gsd-*/ count (${skillDirs.length}) must equal commands/gsd/*.md count (${commandFiles.length}). ` +
`skills/msd-*/ count (${skillDirs.length}) must equal commands/msd/*.md count (${commandFiles.length}). ` +
`Run: npm run gen:plugin-skills -- --write`
);
});