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:
@@ -16,12 +16,12 @@ const {
|
||||
readInstallState,
|
||||
runInstallerMigrations,
|
||||
writeInstallState,
|
||||
} = require('../gsd-core/bin/lib/installer-migrations.cjs');
|
||||
const firstTimeBaselineMigration = require('../gsd-core/bin/lib/installer-migrations/000-first-time-baseline.cjs');
|
||||
const opencodeBaselineCommandsDirMigration = require('../gsd-core/bin/lib/installer-migrations/005-opencode-baseline-commands-dir.cjs');
|
||||
} = require('../msd-core/bin/lib/installer-migrations.cjs');
|
||||
const firstTimeBaselineMigration = require('../msd-core/bin/lib/installer-migrations/000-first-time-baseline.cjs');
|
||||
const opencodeBaselineCommandsDirMigration = require('../msd-core/bin/lib/installer-migrations/005-opencode-baseline-commands-dir.cjs');
|
||||
|
||||
function createTempInstall() {
|
||||
return fs.mkdtempSync(path.join(os.tmpdir(), 'gsd-installer-migrations-'));
|
||||
return fs.mkdtempSync(path.join(os.tmpdir(), 'msd-installer-migrations-'));
|
||||
}
|
||||
|
||||
function cleanup(dir) {
|
||||
@@ -41,7 +41,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.49.0',
|
||||
timestamp: '2026-05-10T00:00:00.000Z',
|
||||
@@ -77,7 +77,7 @@ function legacyCodexHook(configDir) {
|
||||
hooks: [
|
||||
{
|
||||
type: 'command',
|
||||
command: `node "${path.join(configDir, 'hooks', 'gsd-check-update.js')}"`,
|
||||
command: `node "${path.join(configDir, 'hooks', 'msd-check-update.js')}"`,
|
||||
},
|
||||
],
|
||||
};
|
||||
@@ -97,10 +97,10 @@ function userHook(command) {
|
||||
test('records a first-time baseline while preserving user-owned artifacts', () => {
|
||||
const configDir = createTempInstall();
|
||||
try {
|
||||
writeFile(configDir, 'gsd-core/workflows/plan.md', 'managed workflow\n');
|
||||
writeFile(configDir, 'gsd-core/USER-PROFILE.md', 'user profile\n');
|
||||
writeFile(configDir, 'msd-core/workflows/plan.md', 'managed workflow\n');
|
||||
writeFile(configDir, 'msd-core/USER-PROFILE.md', 'user profile\n');
|
||||
writeManifest(configDir, {
|
||||
'gsd-core/workflows/plan.md': sha256('managed workflow\n'),
|
||||
'msd-core/workflows/plan.md': sha256('managed workflow\n'),
|
||||
});
|
||||
|
||||
const result = runInstallerMigrations({
|
||||
@@ -113,8 +113,8 @@ test('records a first-time baseline while preserving user-owned artifacts', () =
|
||||
});
|
||||
|
||||
assert.deepEqual(result.appliedMigrationIds, ['2026-05-11-first-time-baseline-scan']);
|
||||
assert.equal(fs.readFileSync(path.join(configDir, 'gsd-core/workflows/plan.md'), 'utf8'), 'managed workflow\n');
|
||||
assert.equal(fs.readFileSync(path.join(configDir, 'gsd-core/USER-PROFILE.md'), 'utf8'), 'user profile\n');
|
||||
assert.equal(fs.readFileSync(path.join(configDir, 'msd-core/workflows/plan.md'), 'utf8'), 'managed workflow\n');
|
||||
assert.equal(fs.readFileSync(path.join(configDir, 'msd-core/USER-PROFILE.md'), 'utf8'), 'user profile\n');
|
||||
|
||||
assert.deepEqual(
|
||||
result.plan.actions.map((action) => ({
|
||||
@@ -125,12 +125,12 @@ test('records a first-time baseline while preserving user-owned artifacts', () =
|
||||
[
|
||||
{
|
||||
type: 'record-baseline',
|
||||
relPath: 'gsd-core/workflows/plan.md',
|
||||
relPath: 'msd-core/workflows/plan.md',
|
||||
classification: 'managed-pristine',
|
||||
},
|
||||
{
|
||||
type: 'baseline-preserve-user',
|
||||
relPath: 'gsd-core/USER-PROFILE.md',
|
||||
relPath: 'msd-core/USER-PROFILE.md',
|
||||
classification: 'user-owned',
|
||||
},
|
||||
]
|
||||
@@ -227,10 +227,10 @@ test('preserves user-owned skill files during baseline without hashing their con
|
||||
);
|
||||
});
|
||||
|
||||
test('blocks stale GSD-looking baseline artifacts for explicit user choice', () => {
|
||||
test('blocks stale MSD-looking baseline artifacts for explicit user choice', () => {
|
||||
const configDir = createTempInstall();
|
||||
try {
|
||||
writeFile(configDir, 'hooks/gsd-retired-hook.js', 'old gsd hook\n');
|
||||
writeFile(configDir, 'hooks/msd-retired-hook.js', 'old msd hook\n');
|
||||
writeManifest(configDir, {});
|
||||
|
||||
const result = runInstallerMigrations({
|
||||
@@ -245,7 +245,7 @@ test('blocks stale GSD-looking baseline artifacts for explicit user choice', ()
|
||||
assert.deepEqual(result.appliedMigrationIds, []);
|
||||
assert.equal(result.journalRelPath, null);
|
||||
assert.equal(fs.existsSync(path.join(configDir, INSTALL_STATE_NAME)), false);
|
||||
assert.equal(fs.readFileSync(path.join(configDir, 'hooks/gsd-retired-hook.js'), 'utf8'), 'old gsd hook\n');
|
||||
assert.equal(fs.readFileSync(path.join(configDir, 'hooks/msd-retired-hook.js'), 'utf8'), 'old msd hook\n');
|
||||
assert.deepEqual(
|
||||
result.blocked.map((action) => ({
|
||||
type: action.type,
|
||||
@@ -256,8 +256,8 @@ test('blocks stale GSD-looking baseline artifacts for explicit user choice', ()
|
||||
[
|
||||
{
|
||||
type: 'prompt-user',
|
||||
relPath: 'hooks/gsd-retired-hook.js',
|
||||
classification: 'stale-gsd-looking',
|
||||
relPath: 'hooks/msd-retired-hook.js',
|
||||
classification: 'stale-msd-looking',
|
||||
choices: ['keep', 'remove'],
|
||||
},
|
||||
]
|
||||
@@ -270,9 +270,9 @@ test('blocks stale GSD-looking baseline artifacts for explicit user choice', ()
|
||||
test('records known generated agent artifacts so profile cleanup can remove them', () => {
|
||||
const configDir = createTempInstall();
|
||||
try {
|
||||
writeFile(configDir, 'agents/gsd-executor.md', 'old generated agent\n');
|
||||
writeFile(configDir, 'agents/gsd-executor.toml', 'old generated agent config\n');
|
||||
writeFile(configDir, 'agents/gsd-local-experiment.md', 'user experiment\n');
|
||||
writeFile(configDir, 'agents/msd-executor.md', 'old generated agent\n');
|
||||
writeFile(configDir, 'agents/msd-executor.toml', 'old generated agent config\n');
|
||||
writeFile(configDir, 'agents/msd-local-experiment.md', 'user experiment\n');
|
||||
writeManifest(configDir, {});
|
||||
|
||||
const result = runInstallerMigrations({
|
||||
@@ -293,25 +293,25 @@ test('records known generated agent artifacts so profile cleanup can remove them
|
||||
[
|
||||
{
|
||||
type: 'record-baseline',
|
||||
relPath: 'agents/gsd-executor.md',
|
||||
relPath: 'agents/msd-executor.md',
|
||||
classification: 'unknown',
|
||||
},
|
||||
{
|
||||
type: 'record-baseline',
|
||||
relPath: 'agents/gsd-executor.toml',
|
||||
relPath: 'agents/msd-executor.toml',
|
||||
classification: 'unknown',
|
||||
},
|
||||
{
|
||||
type: 'prompt-user',
|
||||
relPath: 'agents/gsd-local-experiment.md',
|
||||
classification: 'stale-gsd-looking',
|
||||
relPath: 'agents/msd-local-experiment.md',
|
||||
classification: 'stale-msd-looking',
|
||||
},
|
||||
]
|
||||
);
|
||||
assert.deepEqual(result.blocked.map((action) => action.relPath), ['agents/gsd-local-experiment.md']);
|
||||
assert.equal(fs.readFileSync(path.join(configDir, 'agents/gsd-executor.md'), 'utf8'), 'old generated agent\n');
|
||||
assert.equal(fs.readFileSync(path.join(configDir, 'agents/gsd-executor.toml'), 'utf8'), 'old generated agent config\n');
|
||||
assert.equal(fs.readFileSync(path.join(configDir, 'agents/gsd-local-experiment.md'), 'utf8'), 'user experiment\n');
|
||||
assert.deepEqual(result.blocked.map((action) => action.relPath), ['agents/msd-local-experiment.md']);
|
||||
assert.equal(fs.readFileSync(path.join(configDir, 'agents/msd-executor.md'), 'utf8'), 'old generated agent\n');
|
||||
assert.equal(fs.readFileSync(path.join(configDir, 'agents/msd-executor.toml'), 'utf8'), 'old generated agent config\n');
|
||||
assert.equal(fs.readFileSync(path.join(configDir, 'agents/msd-local-experiment.md'), 'utf8'), 'user experiment\n');
|
||||
} finally {
|
||||
cleanup(configDir);
|
||||
}
|
||||
@@ -326,14 +326,14 @@ test('records known generated agent artifacts so profile cleanup can remove them
|
||||
// pin migration 005's widened scan of the plural `commands/` surface.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
test('baselines pre-existing OpenCode commands/ files: managed, unknown, and stale-GSD-looking', () => {
|
||||
test('baselines pre-existing OpenCode commands/ files: managed, unknown, and stale-MSD-looking', () => {
|
||||
const configDir = createTempInstall();
|
||||
try {
|
||||
writeFile(configDir, 'commands/gsd-plan-phase.md', 'managed command\n');
|
||||
writeFile(configDir, 'commands/msd-plan-phase.md', 'managed command\n');
|
||||
writeFile(configDir, 'commands/my-custom-command.md', 'user command\n');
|
||||
writeFile(configDir, 'commands/gsd-retired-command.md', 'stale gsd-looking file, not in manifest\n');
|
||||
writeFile(configDir, 'commands/msd-retired-command.md', 'stale msd-looking file, not in manifest\n');
|
||||
writeManifest(configDir, {
|
||||
'commands/gsd-plan-phase.md': sha256('managed command\n'),
|
||||
'commands/msd-plan-phase.md': sha256('managed command\n'),
|
||||
});
|
||||
|
||||
const result = runInstallerMigrations({
|
||||
@@ -354,7 +354,7 @@ test('baselines pre-existing OpenCode commands/ files: managed, unknown, and sta
|
||||
[
|
||||
{
|
||||
type: 'record-baseline',
|
||||
relPath: 'commands/gsd-plan-phase.md',
|
||||
relPath: 'commands/msd-plan-phase.md',
|
||||
classification: 'managed-pristine',
|
||||
},
|
||||
{
|
||||
@@ -364,20 +364,20 @@ test('baselines pre-existing OpenCode commands/ files: managed, unknown, and sta
|
||||
},
|
||||
{
|
||||
type: 'prompt-user',
|
||||
relPath: 'commands/gsd-retired-command.md',
|
||||
classification: 'stale-gsd-looking',
|
||||
relPath: 'commands/msd-retired-command.md',
|
||||
classification: 'stale-msd-looking',
|
||||
},
|
||||
]
|
||||
);
|
||||
// The stale-GSD-looking file blocks the plan (needs explicit user choice),
|
||||
// The stale-MSD-looking file blocks the plan (needs explicit user choice),
|
||||
// so nothing was applied and no install state was written yet.
|
||||
assert.deepEqual(result.appliedMigrationIds, []);
|
||||
assert.equal(fs.existsSync(path.join(configDir, INSTALL_STATE_NAME)), false);
|
||||
// Every file on disk is untouched — baseline-preserve-user/record-baseline/
|
||||
// prompt-user are all non-mutating classification actions.
|
||||
assert.equal(fs.readFileSync(path.join(configDir, 'commands/gsd-plan-phase.md'), 'utf8'), 'managed command\n');
|
||||
assert.equal(fs.readFileSync(path.join(configDir, 'commands/msd-plan-phase.md'), 'utf8'), 'managed command\n');
|
||||
assert.equal(fs.readFileSync(path.join(configDir, 'commands/my-custom-command.md'), 'utf8'), 'user command\n');
|
||||
assert.equal(fs.readFileSync(path.join(configDir, 'commands/gsd-retired-command.md'), 'utf8'), 'stale gsd-looking file, not in manifest\n');
|
||||
assert.equal(fs.readFileSync(path.join(configDir, 'commands/msd-retired-command.md'), 'utf8'), 'stale msd-looking file, not in manifest\n');
|
||||
} finally {
|
||||
cleanup(configDir);
|
||||
}
|
||||
@@ -386,10 +386,10 @@ test('baselines pre-existing OpenCode commands/ files: managed, unknown, and sta
|
||||
test('OpenCode commands/ baseline is idempotent — a second run does not re-plan already-applied files', () => {
|
||||
const configDir = createTempInstall();
|
||||
try {
|
||||
writeFile(configDir, 'commands/gsd-plan-phase.md', 'managed command\n');
|
||||
writeFile(configDir, 'commands/msd-plan-phase.md', 'managed command\n');
|
||||
writeFile(configDir, 'commands/my-custom-command.md', 'user command\n');
|
||||
writeManifest(configDir, {
|
||||
'commands/gsd-plan-phase.md': sha256('managed command\n'),
|
||||
'commands/msd-plan-phase.md': sha256('managed command\n'),
|
||||
});
|
||||
|
||||
const first = runInstallerMigrations({
|
||||
@@ -421,7 +421,7 @@ test('OpenCode commands/ baseline is idempotent — a second run does not re-pla
|
||||
'2026-07-17-opencode-baseline-commands-dir',
|
||||
]);
|
||||
// Files remain untouched across both runs.
|
||||
assert.equal(fs.readFileSync(path.join(configDir, 'commands/gsd-plan-phase.md'), 'utf8'), 'managed command\n');
|
||||
assert.equal(fs.readFileSync(path.join(configDir, 'commands/msd-plan-phase.md'), 'utf8'), 'managed command\n');
|
||||
assert.equal(fs.readFileSync(path.join(configDir, 'commands/my-custom-command.md'), 'utf8'), 'user command\n');
|
||||
} finally {
|
||||
cleanup(configDir);
|
||||
@@ -434,11 +434,11 @@ test('OpenCode commands/ baseline migration is scoped to opencode and never plan
|
||||
// Kilo's descriptor keeps the singular `command/` dir; a `commands/` (plural)
|
||||
// directory here would be unrelated to Kilo's install surface. This proves the
|
||||
// migration's `runtimes: ['opencode']` scoping keeps Kilo installs untouched.
|
||||
writeFile(configDir, 'commands/gsd-plan-phase.md', 'managed command\n');
|
||||
writeFile(configDir, 'command/gsd-plan-phase.md', 'kilo managed command\n');
|
||||
writeFile(configDir, 'commands/msd-plan-phase.md', 'managed command\n');
|
||||
writeFile(configDir, 'command/msd-plan-phase.md', 'kilo managed command\n');
|
||||
writeManifest(configDir, {
|
||||
'commands/gsd-plan-phase.md': sha256('managed command\n'),
|
||||
'command/gsd-plan-phase.md': sha256('kilo managed command\n'),
|
||||
'commands/msd-plan-phase.md': sha256('managed command\n'),
|
||||
'command/msd-plan-phase.md': sha256('kilo managed command\n'),
|
||||
});
|
||||
|
||||
const result = runInstallerMigrations({
|
||||
@@ -457,20 +457,20 @@ test('OpenCode commands/ baseline migration is scoped to opencode and never plan
|
||||
assert.deepEqual(result.plan.actions, []);
|
||||
assert.deepEqual(result.appliedMigrationIds, []);
|
||||
assert.equal(fs.existsSync(path.join(configDir, INSTALL_STATE_NAME)), false);
|
||||
assert.equal(fs.readFileSync(path.join(configDir, 'commands/gsd-plan-phase.md'), 'utf8'), 'managed command\n');
|
||||
assert.equal(fs.readFileSync(path.join(configDir, 'command/gsd-plan-phase.md'), 'utf8'), 'kilo managed command\n');
|
||||
assert.equal(fs.readFileSync(path.join(configDir, 'commands/msd-plan-phase.md'), 'utf8'), 'managed command\n');
|
||||
assert.equal(fs.readFileSync(path.join(configDir, 'command/msd-plan-phase.md'), 'utf8'), 'kilo managed command\n');
|
||||
} finally {
|
||||
cleanup(configDir);
|
||||
}
|
||||
});
|
||||
|
||||
test('regression (#2329 follow-up): pre-existing unmanifested commands/gsd-*.md is no longer silently destroyed', () => {
|
||||
test('regression (#2329 follow-up): pre-existing unmanifested commands/msd-*.md is no longer silently destroyed', () => {
|
||||
const configDir = createTempInstall();
|
||||
try {
|
||||
// Simulates a pre-existing, non-GSD file sitting under OpenCode's commands/
|
||||
// directory before GSD's first-ever migration-tracked run against this
|
||||
// Simulates a pre-existing, non-MSD file sitting under OpenCode's commands/
|
||||
// directory before MSD's first-ever migration-tracked run against this
|
||||
// configDir (no manifest, no install state yet).
|
||||
writeFile(configDir, 'commands/gsd-retired-plan.md', 'pre-existing file, not GSD-written\n');
|
||||
writeFile(configDir, 'commands/msd-retired-plan.md', 'pre-existing file, not MSD-written\n');
|
||||
|
||||
// Full default migration set (all shipped migrations, including 000 AND 005),
|
||||
// matching production: bin/install.js calls runInstallerMigrations with no
|
||||
@@ -490,15 +490,15 @@ test('regression (#2329 follow-up): pre-existing unmanifested commands/gsd-*.md
|
||||
// surface already had.
|
||||
assert.deepEqual(result.appliedMigrationIds, []);
|
||||
assert.ok(Array.isArray(result.blocked) && result.blocked.length > 0, 'expected a blocked prompt-user action');
|
||||
const blockedForFile = result.blocked.find((action) => action.relPath === 'commands/gsd-retired-plan.md');
|
||||
assert.ok(blockedForFile, 'expected commands/gsd-retired-plan.md to be blocked pending user choice');
|
||||
const blockedForFile = result.blocked.find((action) => action.relPath === 'commands/msd-retired-plan.md');
|
||||
assert.ok(blockedForFile, 'expected commands/msd-retired-plan.md to be blocked pending user choice');
|
||||
assert.equal(blockedForFile.type, 'prompt-user');
|
||||
assert.equal(blockedForFile.migrationId, '2026-07-17-opencode-baseline-commands-dir');
|
||||
// The file itself was never touched — migrations only classify, they do not
|
||||
// mutate disk.
|
||||
assert.equal(
|
||||
fs.readFileSync(path.join(configDir, 'commands/gsd-retired-plan.md'), 'utf8'),
|
||||
'pre-existing file, not GSD-written\n'
|
||||
fs.readFileSync(path.join(configDir, 'commands/msd-retired-plan.md'), 'utf8'),
|
||||
'pre-existing file, not MSD-written\n'
|
||||
);
|
||||
} finally {
|
||||
cleanup(configDir);
|
||||
@@ -721,7 +721,7 @@ test('classifies large files without loading the whole file through readFileSync
|
||||
cleanup(configDir);
|
||||
});
|
||||
|
||||
const relPath = 'skills/gsd-large/SKILL.md';
|
||||
const relPath = 'skills/msd-large/SKILL.md';
|
||||
const fullPath = path.join(configDir, relPath);
|
||||
fs.mkdirSync(path.dirname(fullPath), { recursive: true });
|
||||
fs.writeFileSync(fullPath, Buffer.alloc(1024 * 1024 + 1, 'a'));
|
||||
@@ -766,7 +766,7 @@ test('applies an unblocked plan with a journal and install-state update', () =>
|
||||
assert.deepEqual(result.appliedMigrationIds, ['2026-05-11-remove-old-hook']);
|
||||
assert.match(
|
||||
result.journalRelPath,
|
||||
/^gsd-migration-journal\/2026-05-11T00-00-01-000Z-[0-9a-f]+\.json$/
|
||||
/^msd-migration-journal\/2026-05-11T00-00-01-000Z-[0-9a-f]+\.json$/
|
||||
);
|
||||
|
||||
const journal = JSON.parse(fs.readFileSync(path.join(configDir, result.journalRelPath), 'utf8'));
|
||||
@@ -859,7 +859,7 @@ test('stores modified-file backups under the unique migration run journal', (t)
|
||||
const journal = JSON.parse(fs.readFileSync(path.join(configDir, result.journalRelPath), 'utf8'));
|
||||
const backupRelPath = journal.actions[0].backupRelPath;
|
||||
|
||||
assert.match(backupRelPath, /^gsd-migration-journal\/2026-05-11T00-00-10-000Z-[0-9a-f]+-backups\/hooks\/old-hook\.js$/);
|
||||
assert.match(backupRelPath, /^msd-migration-journal\/2026-05-11T00-00-10-000Z-[0-9a-f]+-backups\/hooks\/old-hook\.js$/);
|
||||
assert.equal(fs.readFileSync(path.join(configDir, backupRelPath), 'utf8'), 'user changed hook\n');
|
||||
});
|
||||
|
||||
@@ -891,7 +891,7 @@ test('successful migration rollback removes run-scoped backup directories', (t)
|
||||
assert.equal(fs.readFileSync(path.join(configDir, 'hooks/old-hook.js'), 'utf8'), 'user changed hook\n');
|
||||
assert.equal(fs.existsSync(path.join(configDir, result.journalRelPath)), false);
|
||||
assert.equal(
|
||||
fs.readdirSync(path.join(configDir, 'gsd-migration-journal')).some((name) => name.includes('backups')),
|
||||
fs.readdirSync(path.join(configDir, 'msd-migration-journal')).some((name) => name.includes('backups')),
|
||||
false
|
||||
);
|
||||
});
|
||||
@@ -899,7 +899,7 @@ test('successful migration rollback removes run-scoped backup directories', (t)
|
||||
test('refuses to run migrations while another installer owns the migration lock', (t) => {
|
||||
const configDir = createTempInstall();
|
||||
t.after(() => cleanup(configDir));
|
||||
fs.writeFileSync(path.join(configDir, 'gsd-install-migration.lock'), 'held by test\n', 'utf8');
|
||||
fs.writeFileSync(path.join(configDir, 'msd-install-migration.lock'), 'held by test\n', 'utf8');
|
||||
|
||||
assert.throws(
|
||||
() => runInstallerMigrations({
|
||||
@@ -923,7 +923,7 @@ test('reports lock release failures after migration work completes', (t) => {
|
||||
// NOT silently swallowed on Windows (#3670). Mock unlinkSync to simulate
|
||||
// a Windows NTFS EPERM condition when the lock file is removed.
|
||||
fs.unlinkSync = (targetPath) => {
|
||||
if (path.basename(String(targetPath)) === 'gsd-install-migration.lock') {
|
||||
if (path.basename(String(targetPath)) === 'msd-install-migration.lock') {
|
||||
throw new Error('simulated lock unlink failure');
|
||||
}
|
||||
return originalUnlinkSync.call(fs, targetPath);
|
||||
@@ -951,7 +951,7 @@ test('rollback handle restores files and install state after a successful apply'
|
||||
{
|
||||
id: 'already-applied',
|
||||
appliedAt: '2026-05-10T00:00:00.000Z',
|
||||
journal: 'gsd-migration-journal/prior.json',
|
||||
journal: 'msd-migration-journal/prior.json',
|
||||
},
|
||||
],
|
||||
});
|
||||
@@ -1041,8 +1041,8 @@ test('rolls back touched files and leaves state unchanged when apply fails', ()
|
||||
assert.equal(fs.readFileSync(path.join(configDir, 'hooks/old-hook.js'), 'utf8'), 'managed hook\n');
|
||||
assert.deepEqual(readInstallState(configDir).appliedMigrations, []);
|
||||
assert.equal(
|
||||
fs.existsSync(path.join(configDir, 'gsd-migration-journal')) &&
|
||||
fs.readdirSync(path.join(configDir, 'gsd-migration-journal')).some((name) =>
|
||||
fs.existsSync(path.join(configDir, 'msd-migration-journal')) &&
|
||||
fs.readdirSync(path.join(configDir, 'msd-migration-journal')).some((name) =>
|
||||
name.startsWith('2026-05-11T00-00-02-000Z')
|
||||
),
|
||||
false
|
||||
@@ -1097,8 +1097,8 @@ test('cleans rollback and backup artifacts when migration apply fails', (t) => {
|
||||
|
||||
assert.equal(fs.readFileSync(path.join(configDir, 'hooks/old-hook.js'), 'utf8'), 'user changed hook\n');
|
||||
assert.equal(
|
||||
fs.existsSync(path.join(configDir, 'gsd-migration-journal')) &&
|
||||
fs.readdirSync(path.join(configDir, 'gsd-migration-journal')).some((name) =>
|
||||
fs.existsSync(path.join(configDir, 'msd-migration-journal')) &&
|
||||
fs.readdirSync(path.join(configDir, 'msd-migration-journal')).some((name) =>
|
||||
name.startsWith('2026-05-11T00-00-12-000Z')
|
||||
),
|
||||
false
|
||||
@@ -1238,7 +1238,7 @@ test('skips migration records already present in install state', () => {
|
||||
{
|
||||
id: '2026-05-11-remove-old-hook',
|
||||
appliedAt: '2026-05-11T00:00:00.000Z',
|
||||
journal: 'gsd-migration-journal/prior.json',
|
||||
journal: 'msd-migration-journal/prior.json',
|
||||
},
|
||||
],
|
||||
});
|
||||
@@ -1305,7 +1305,7 @@ test('surfaces checksum drift for an already-applied migration without aborting'
|
||||
id: '2026-05-11-remove-old-hook',
|
||||
checksum: 'sha256:old-definition',
|
||||
appliedAt: '2026-05-11T00:00:00.000Z',
|
||||
journal: 'gsd-migration-journal/prior.json',
|
||||
journal: 'msd-migration-journal/prior.json',
|
||||
},
|
||||
],
|
||||
});
|
||||
@@ -1345,7 +1345,7 @@ test('ignores checksum drift for applied migrations outside the active runtime s
|
||||
id: '2026-05-11-codex-only',
|
||||
checksum: 'sha256:old-definition',
|
||||
appliedAt: '2026-05-11T00:00:00.000Z',
|
||||
journal: 'gsd-migration-journal/prior.json',
|
||||
journal: 'msd-migration-journal/prior.json',
|
||||
},
|
||||
],
|
||||
});
|
||||
@@ -1502,7 +1502,7 @@ test('backs up modified legacy orphan files before removing them', () => {
|
||||
const plan = planInstallerMigrations({
|
||||
configDir,
|
||||
migrations: discoverInstallerMigrations({
|
||||
migrationsDir: path.join(__dirname, '..', 'gsd-core', 'bin', 'lib', 'installer-migrations'),
|
||||
migrationsDir: path.join(__dirname, '..', 'msd-core', 'bin', 'lib', 'installer-migrations'),
|
||||
}),
|
||||
scope: 'global',
|
||||
now: () => '2026-05-11T00:00:05.000Z',
|
||||
@@ -1536,7 +1536,7 @@ test('runs a Codex legacy hooks.json cleanup migration without removing user hoo
|
||||
SessionStart: [
|
||||
legacyCodexHook(configDir),
|
||||
userHook('node "/Users/example/bin/user-hook.js"'),
|
||||
userHook('node "/Users/example/bin/gsd-check-update.js"'),
|
||||
userHook('node "/Users/example/bin/msd-check-update.js"'),
|
||||
],
|
||||
}, null, 2)
|
||||
);
|
||||
@@ -1554,7 +1554,7 @@ test('runs a Codex legacy hooks.json cleanup migration without removing user hoo
|
||||
|
||||
assert.deepEqual(commands, [
|
||||
'node "/Users/example/bin/user-hook.js"',
|
||||
'node "/Users/example/bin/gsd-check-update.js"',
|
||||
'node "/Users/example/bin/msd-check-update.js"',
|
||||
]);
|
||||
assert.ok(result.appliedMigrationIds.includes('2026-05-11-codex-legacy-hooks-json'));
|
||||
} finally {
|
||||
@@ -1616,7 +1616,7 @@ test('skips runtime-specific migration records for other runtimes', () => {
|
||||
});
|
||||
|
||||
const hooksJson = JSON.parse(fs.readFileSync(path.join(configDir, 'hooks.json'), 'utf8'));
|
||||
assert.equal(hooksJson.SessionStart[0].hooks[0].command, `node "${path.join(configDir, 'hooks', 'gsd-check-update.js')}"`);
|
||||
assert.equal(hooksJson.SessionStart[0].hooks[0].command, `node "${path.join(configDir, 'hooks', 'msd-check-update.js')}"`);
|
||||
assert.equal(result.appliedMigrationIds.includes('2026-05-11-codex-legacy-hooks-json'), false);
|
||||
} finally {
|
||||
cleanup(configDir);
|
||||
@@ -1646,18 +1646,21 @@ test('shipped installer-migration checksums are locked to a committed baseline (
|
||||
// extraordinary intentional body change (add a comment explaining why). Editing a
|
||||
// shipped migration body breaks the stored checksum for everyone who already applied
|
||||
// it (root cause of #670) — add a NEW fix-forward migration id instead.
|
||||
// MSD hard fork: the GSD -> MSD rename rewrote every migration body, so the whole
|
||||
// baseline was re-locked once here. Safe because MSD keeps its own install state
|
||||
// (msd-install-state.json) — no MSD install had applied these under the old sums.
|
||||
const EXPECTED_CHECKSUMS = {
|
||||
'2026-05-11-first-time-baseline-scan':
|
||||
'sha256:4ec58d35b30dbf39cc56e3972146086d8d31861ecd800cf0b37a7aa94fe74c2a',
|
||||
'sha256:d453813296b1c9d7b6e54e4002ddd38e56a051193daa629b4e2adbd5da15a21a',
|
||||
'2026-05-11-legacy-orphan-files':
|
||||
'sha256:e492698748a2436a12a55f0940f539b9bf651d8ffcac6f60cd856a6dabd6788c',
|
||||
'sha256:b099979afabf2b4c49410d12d901fb0b7ddb0088e9a560bab05aad7c2c0c26fa',
|
||||
'2026-05-11-codex-legacy-hooks-json':
|
||||
'sha256:5ce55294aa02f25758f604a569c899a6d2d060299189f5f447f68d8033157058',
|
||||
'2026-06-02-rename-get-shit-done-to-gsd-core':
|
||||
'sha256:3a9f1d97f64097fb313203d19c6d93a187a38df61dd299afa5eef73e16124e95',
|
||||
// Migration 004: prune stale gsd-pristine/get-shit-done/ snapshots (#934) // gsd-allow-legacy-name
|
||||
'2026-06-09-prune-stale-pristine-get-shit-done': // gsd-allow-legacy-name
|
||||
'sha256:6555dd044659276fbc204e81793cd92c5315d54e7316bcdd82d2c98d15a7e9e8',
|
||||
'sha256:42fd6770de2aee639463c5c4fbfc82b43cb775b0566f374fde51472e42da6a31',
|
||||
'2026-06-02-rename-get-shit-done-to-msd-core':
|
||||
'sha256:5d9996f14e41df2e3a97845a0e55946508603e6fdf282ebe86a919d0ac4012bb',
|
||||
// Migration 004: prune stale msd-pristine/get-shit-done/ snapshots (#934) // msd-allow-legacy-name
|
||||
'2026-06-09-prune-stale-pristine-get-shit-done': // msd-allow-legacy-name
|
||||
'sha256:60a154fba2fc2a37cc72fcb0fcc8936dd941b2b184db5911f43877181858c418',
|
||||
// Migration 005 (NEW, added here per this test's own sanctioned "adding a new
|
||||
// migration" case — not a shipped-body edit): baseline OpenCode's commands/
|
||||
// (plural) directory during the first-time scan. #2329 moved OpenCode command
|
||||
@@ -1665,35 +1668,35 @@ test('shipped installer-migration checksums are locked to a committed baseline (
|
||||
// is a shipped, immutable body that still only names command/, so this
|
||||
// fix-forward migration widens the scanned surface without touching 000.
|
||||
'2026-07-17-opencode-baseline-commands-dir':
|
||||
'sha256:0f6080b5f9b75fb5adbe9664a71152e23a5336813453b0a77e4df6fd483ad38e',
|
||||
'sha256:3310ef32615b0b214f39f660f19a734ba1fe7d7200fe0a10b0ffc86fca15b39a',
|
||||
// Migration 006 (NEW, added here per this test's own sanctioned "adding a new
|
||||
// migration" case — not a shipped-body edit): retire pi's stale
|
||||
// extensions/gsd.cjs. #2470 renamed the installed extension to
|
||||
// extensions/gsd.js because pi's isExtensionFile() auto-discovery accepts
|
||||
// extensions/msd.cjs. #2470 renamed the installed extension to
|
||||
// extensions/msd.js because pi's isExtensionFile() auto-discovery accepts
|
||||
// only .ts/.js and silently skips everything else; without this migration the
|
||||
// old path drops out of the manifest and uninstall can never remove it.
|
||||
'2026-07-20-pi-extension-cjs-to-js':
|
||||
'sha256:185fa926ae24d83cbdd95c31a9ad2cc8d123e176ad543669b3b0ed75e6ca6f4a',
|
||||
'sha256:7cba8de555a7d09f23c19ea2409dc83586f91fb02c38d079aee2dd8e9744471d',
|
||||
// Migration 007 (NEW, added here per this test's own sanctioned "adding a new
|
||||
// migration" case — not a shipped-body edit): retire the pre-#2544
|
||||
// {"type":"commonjs"} marker at the runtime config root. #2544 moved that
|
||||
// marker into the directories GSD fills, so without this an upgraded install
|
||||
// marker into the directories MSD fills, so without this an upgraded install
|
||||
// keeps both and the config root stays pinned to CommonJS. Ownership is proven
|
||||
// by exact content match rather than the manifest — the config-root marker was
|
||||
// never manifest-recorded — so the action declares its own classification.
|
||||
'2026-07-28-retire-config-root-commonjs-marker':
|
||||
'sha256:8f2140cbe8f2dd8f7dfd52a0f6957c5edfe966c52d7e6e4d74ec7366930e0e1d',
|
||||
'sha256:5d352b823594fe3e172fe575061edf2d0fab31158c79e2275184ee9d7116a6e4',
|
||||
// Migration 008: retire Cursor's duplicate commands/ surface (#2644).
|
||||
'2026-07-29-cursor-retire-commands-surface':
|
||||
'sha256:d0b2b812a3f752650f2518b48280f74a5937c80ec8412bac493382dfa3db083f',
|
||||
'sha256:8d340681ea3bbe77ed36bb36996953b3753950d8f2360a1c8222f96b618c71ec',
|
||||
// Migration 009 (NEW, added here per this test's own sanctioned "adding a new
|
||||
// migration" case — not a shipped-body edit): retire pi's reserved hooks/
|
||||
// directory now that the shared hook bundle installs at gsd-hooks/ instead
|
||||
// directory now that the shared hook bundle installs at msd-hooks/ instead
|
||||
// (#3023). pi warns on hooks/'s mere existence regardless of contents, so an
|
||||
// upgraded install must have both the legacy files AND the emptied directory
|
||||
// itself retired via the new remove-empty-dir action.
|
||||
'2026-08-07-pi-retire-reserved-hooks-dir':
|
||||
'sha256:34264415b00e15e5a1691eae3db9bd24dca11e5c04d78358420a7a8adf115f9e',
|
||||
'sha256:bb58ef391b3ee6fb61f9cacadd05f54ed57c8f7454553ec68ef4c18dc26b19f2',
|
||||
// Migration 010 (NEW, added here per this test's own sanctioned "adding a new
|
||||
// migration" case): retire Antigravity's configHome skills/agents surfaces
|
||||
// (#3738). Antigravity scans ~/.gemini/config for global discovery, so
|
||||
@@ -1701,10 +1704,10 @@ test('shipped installer-migration checksums are locked to a committed baseline (
|
||||
// kinds install under the .gemini/config home override and this migration
|
||||
// converges upgraded installs. Global scope only — local .agents is live.
|
||||
'2026-08-26-antigravity-retire-confighome-artifacts':
|
||||
'sha256:52764c43418accdc26c89482b1a46bf9ebcde1c1d9a80e302971a7b068a3be3c',
|
||||
'sha256:0011d160a7fe07230a9d89de8ce39215e004fff1077961dc687781cb9fe103ba',
|
||||
};
|
||||
|
||||
const { DEFAULT_MIGRATIONS_DIR, migrationChecksum: computeChecksum } = require('../gsd-core/bin/lib/installer-migrations.cjs');
|
||||
const { DEFAULT_MIGRATIONS_DIR, migrationChecksum: computeChecksum } = require('../msd-core/bin/lib/installer-migrations.cjs');
|
||||
const migrations = discoverInstallerMigrations({ migrationsDir: DEFAULT_MIGRATIONS_DIR });
|
||||
const discoveredIds = new Set(migrations.map((m) => m.id));
|
||||
|
||||
@@ -1830,11 +1833,11 @@ test('reconciles a drifted applied-migration checksum into install state on appl
|
||||
const {
|
||||
applyInstallerMigrationPlan,
|
||||
evaluateRemoveEmptyDir,
|
||||
} = require('../gsd-core/bin/lib/installer-migrations.cjs');
|
||||
} = require('../msd-core/bin/lib/installer-migrations.cjs');
|
||||
const { cleanup, createTempDir } = require('./helpers.cjs');
|
||||
|
||||
test('evaluateRemoveEmptyDir removes a genuinely empty directory', (t) => {
|
||||
const configDir = createTempDir('gsd-remove-empty-dir-');
|
||||
const configDir = createTempDir('msd-remove-empty-dir-');
|
||||
t.after(() => cleanup(configDir));
|
||||
const target = path.join(configDir, 'hooks');
|
||||
fs.mkdirSync(target);
|
||||
@@ -1844,7 +1847,7 @@ test('reconciles a drifted applied-migration checksum into install state on appl
|
||||
});
|
||||
|
||||
test('evaluateRemoveEmptyDir leaves a non-empty directory in place (planned-but-skipped, not an error)', (t) => {
|
||||
const configDir = createTempDir('gsd-remove-empty-dir-');
|
||||
const configDir = createTempDir('msd-remove-empty-dir-');
|
||||
t.after(() => cleanup(configDir));
|
||||
const target = path.join(configDir, 'hooks');
|
||||
fs.mkdirSync(target);
|
||||
@@ -1856,9 +1859,9 @@ test('reconciles a drifted applied-migration checksum into install state on appl
|
||||
});
|
||||
|
||||
test('evaluateRemoveEmptyDir refuses a symlinked directory (never follows it)', (t) => {
|
||||
const configDir = createTempDir('gsd-remove-empty-dir-');
|
||||
const configDir = createTempDir('msd-remove-empty-dir-');
|
||||
t.after(() => cleanup(configDir));
|
||||
const realElsewhere = createTempDir('gsd-remove-empty-dir-elsewhere-');
|
||||
const realElsewhere = createTempDir('msd-remove-empty-dir-elsewhere-');
|
||||
t.after(() => cleanup(realElsewhere));
|
||||
const linkPath = path.join(configDir, 'hooks');
|
||||
fs.symlinkSync(realElsewhere, linkPath, 'dir');
|
||||
@@ -1869,9 +1872,9 @@ test('reconciles a drifted applied-migration checksum into install state on appl
|
||||
});
|
||||
|
||||
test('evaluateRemoveEmptyDir refuses a target outside configDir', (t) => {
|
||||
const configDir = createTempDir('gsd-remove-empty-dir-');
|
||||
const configDir = createTempDir('msd-remove-empty-dir-');
|
||||
t.after(() => cleanup(configDir));
|
||||
const outside = createTempDir('gsd-remove-empty-dir-outside-');
|
||||
const outside = createTempDir('msd-remove-empty-dir-outside-');
|
||||
t.after(() => cleanup(outside));
|
||||
|
||||
assert.equal(evaluateRemoveEmptyDir(configDir, outside), 'left-in-place');
|
||||
@@ -1879,7 +1882,7 @@ test('reconciles a drifted applied-migration checksum into install state on appl
|
||||
});
|
||||
|
||||
test('evaluateRemoveEmptyDir refuses to remove configDir itself', (t) => {
|
||||
const configDir = createTempDir('gsd-remove-empty-dir-');
|
||||
const configDir = createTempDir('msd-remove-empty-dir-');
|
||||
t.after(() => cleanup(configDir));
|
||||
|
||||
assert.equal(evaluateRemoveEmptyDir(configDir, configDir), 'left-in-place');
|
||||
@@ -1887,7 +1890,7 @@ test('reconciles a drifted applied-migration checksum into install state on appl
|
||||
});
|
||||
|
||||
test('evaluateRemoveEmptyDir treats an already-absent directory as a clean no-op', (t) => {
|
||||
const configDir = createTempDir('gsd-remove-empty-dir-');
|
||||
const configDir = createTempDir('msd-remove-empty-dir-');
|
||||
t.after(() => cleanup(configDir));
|
||||
const target = path.join(configDir, 'hooks');
|
||||
assert.equal(fs.existsSync(target), false);
|
||||
@@ -1898,7 +1901,7 @@ test('reconciles a drifted applied-migration checksum into install state on appl
|
||||
});
|
||||
|
||||
test('evaluateRemoveEmptyDir degrades an EACCES from rmdirSync without throwing', (t) => {
|
||||
const configDir = createTempDir('gsd-remove-empty-dir-');
|
||||
const configDir = createTempDir('msd-remove-empty-dir-');
|
||||
const target = path.join(configDir, 'hooks');
|
||||
fs.mkdirSync(target);
|
||||
|
||||
@@ -1932,7 +1935,7 @@ test('reconciles a drifted applied-migration checksum into install state on appl
|
||||
});
|
||||
|
||||
test('applyInstallerMigrationPlan wires remove-empty-dir through to journal + disk removal', (t) => {
|
||||
const configDir = createTempDir('gsd-remove-empty-dir-apply-');
|
||||
const configDir = createTempDir('msd-remove-empty-dir-apply-');
|
||||
t.after(() => cleanup(configDir));
|
||||
const target = path.join(configDir, 'hooks');
|
||||
fs.mkdirSync(target);
|
||||
@@ -1963,7 +1966,7 @@ test('reconciles a drifted applied-migration checksum into install state on appl
|
||||
});
|
||||
|
||||
test('applyInstallerMigrationPlan leaves a non-empty remove-empty-dir target on disk and journals it', (t) => {
|
||||
const configDir = createTempDir('gsd-remove-empty-dir-apply-');
|
||||
const configDir = createTempDir('msd-remove-empty-dir-apply-');
|
||||
t.after(() => cleanup(configDir));
|
||||
const target = path.join(configDir, 'hooks');
|
||||
fs.mkdirSync(target);
|
||||
@@ -1999,35 +2002,35 @@ test('reconciles a drifted applied-migration checksum into install state on appl
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
{
|
||||
const cursorCommandsMigration = require('../gsd-core/bin/lib/installer-migrations/008-cursor-retire-commands-surface.cjs');
|
||||
const cursorCommandsMigration = require('../msd-core/bin/lib/installer-migrations/008-cursor-retire-commands-surface.cjs');
|
||||
|
||||
test('migration 008 plans only manifest-managed gsd-*.md command files', (t) => {
|
||||
test('migration 008 plans only manifest-managed msd-*.md command files', (t) => {
|
||||
const configDir = createTempInstall();
|
||||
t.after(() => cleanup(configDir));
|
||||
writeFile(configDir, 'commands/gsd-help.md', '# help\n');
|
||||
writeFile(configDir, 'commands/gsd-custom.md', '# custom\n');
|
||||
writeFile(configDir, 'commands/not-gsd.md', '# other\n');
|
||||
writeFile(configDir, 'commands/msd-help.md', '# help\n');
|
||||
writeFile(configDir, 'commands/msd-custom.md', '# custom\n');
|
||||
writeFile(configDir, 'commands/not-msd.md', '# other\n');
|
||||
|
||||
const actions = cursorCommandsMigration.plan({
|
||||
configDir,
|
||||
classifyArtifact(relPath) {
|
||||
if (relPath === 'commands/gsd-help.md') return { classification: 'managed-pristine' };
|
||||
if (relPath === 'commands/msd-help.md') return { classification: 'managed-pristine' };
|
||||
return { classification: 'unknown' };
|
||||
},
|
||||
});
|
||||
|
||||
assert.deepEqual(actions.map((action) => [action.type, action.relPath]), [
|
||||
['remove-managed', 'commands/gsd-help.md'],
|
||||
['remove-managed', 'commands/msd-help.md'],
|
||||
]);
|
||||
});
|
||||
|
||||
test('migration 008 backs up a modified managed command and preserves an unknown neighbor', (t) => {
|
||||
const configDir = createTempInstall();
|
||||
t.after(() => cleanup(configDir));
|
||||
writeFile(configDir, 'commands/gsd-help.md', '# locally modified help\n');
|
||||
writeFile(configDir, 'commands/gsd-custom.md', '# user command\n');
|
||||
writeFile(configDir, 'commands/msd-help.md', '# locally modified help\n');
|
||||
writeFile(configDir, 'commands/msd-custom.md', '# user command\n');
|
||||
writeManifest(configDir, {
|
||||
'commands/gsd-help.md': sha256('# original generated help\n'),
|
||||
'commands/msd-help.md': sha256('# original generated help\n'),
|
||||
});
|
||||
|
||||
const result = runInstallerMigrations({
|
||||
@@ -2036,8 +2039,8 @@ test('reconciles a drifted applied-migration checksum into install state on appl
|
||||
});
|
||||
|
||||
assert.equal(result.plan.actions[0].type, 'backup-and-remove');
|
||||
assert.ok(!fs.existsSync(path.join(configDir, 'commands', 'gsd-help.md')));
|
||||
assert.ok(fs.existsSync(path.join(configDir, 'commands', 'gsd-custom.md')),
|
||||
assert.ok(!fs.existsSync(path.join(configDir, 'commands', 'msd-help.md')));
|
||||
assert.ok(fs.existsSync(path.join(configDir, 'commands', 'msd-custom.md')),
|
||||
'unmanifested user command must be preserved');
|
||||
const journal = JSON.parse(fs.readFileSync(path.join(configDir, result.journalRelPath), 'utf8'));
|
||||
assert.equal(
|
||||
@@ -2050,13 +2053,13 @@ test('reconciles a drifted applied-migration checksum into install state on appl
|
||||
for (const scope of ['global', 'local']) {
|
||||
const configDir = createTempInstall();
|
||||
t.after(() => cleanup(configDir));
|
||||
writeFile(configDir, 'commands/gsd-help.md', '# help\n');
|
||||
writeManifest(configDir, { 'commands/gsd-help.md': sha256('# help\n') });
|
||||
writeFile(configDir, 'commands/msd-help.md', '# help\n');
|
||||
writeManifest(configDir, { 'commands/msd-help.md': sha256('# help\n') });
|
||||
const result = runInstallerMigrations({
|
||||
configDir, runtime: 'cursor', scope, migrations: [cursorCommandsMigration],
|
||||
now: () => `2026-07-29T00:00:0${scope === 'global' ? '0' : '1'}.000Z`,
|
||||
});
|
||||
assert.ok(!fs.existsSync(path.join(configDir, 'commands', 'gsd-help.md')),
|
||||
assert.ok(!fs.existsSync(path.join(configDir, 'commands', 'msd-help.md')),
|
||||
`${scope} Cursor install must retire the duplicate command`);
|
||||
assert.deepEqual(result.appliedMigrationIds, ['2026-07-29-cursor-retire-commands-surface']);
|
||||
}
|
||||
@@ -2073,7 +2076,7 @@ test('reconciles a drifted applied-migration checksum into install state on appl
|
||||
/**
|
||||
* Regression test for bug #3357.
|
||||
*
|
||||
* Older Codex installs carried legacy GSD SessionStart commands in hooks.json.
|
||||
* Older Codex installs carried legacy MSD SessionStart commands in hooks.json.
|
||||
* Current install keeps the managed SessionStart hook in hooks.json (single
|
||||
* representation per layer) and strips stale managed entries before writing
|
||||
* exactly one canonical managed command.
|
||||
@@ -2085,7 +2088,7 @@ test('reconciles a drifted applied-migration checksum into install state on appl
|
||||
|
||||
'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');
|
||||
@@ -2095,9 +2098,9 @@ const { runNode } = require('./helpers/process-seam.cjs');
|
||||
const { throwIfFailed } = require('./helpers/git-fixture.cjs');
|
||||
|
||||
const installModule = require('../bin/install.js');
|
||||
const { readInstallState } = require('../gsd-core/bin/lib/installer-migrations.cjs');
|
||||
const { readInstallState } = require('../msd-core/bin/lib/installer-migrations.cjs');
|
||||
const { install, parseTomlToObject } = installModule;
|
||||
const { reconcileCodexHooksJsonEvent } = require('../gsd-core/bin/lib/runtime-hooks-surface.cjs');
|
||||
const { reconcileCodexHooksJsonEvent } = require('../msd-core/bin/lib/runtime-hooks-surface.cjs');
|
||||
const { createTempDir, cleanup } = require('./helpers.cjs');
|
||||
const HOOKS_DIST = path.join(__dirname, '..', 'hooks', 'dist');
|
||||
const BUILD_HOOKS_SCRIPT = path.join(__dirname, '..', 'scripts', 'build-hooks.js');
|
||||
@@ -2130,11 +2133,11 @@ function withCodexHome(codexHome, fn) {
|
||||
}
|
||||
}
|
||||
|
||||
function legacyGsdHook(codexHome) {
|
||||
function legacyMsdHook(codexHome) {
|
||||
return {
|
||||
hooks: [{
|
||||
type: 'command',
|
||||
command: `node "${path.join(codexHome, 'hooks', 'gsd-check-update.js')}"`,
|
||||
command: `node "${path.join(codexHome, 'hooks', 'msd-check-update.js')}"`,
|
||||
}],
|
||||
};
|
||||
}
|
||||
@@ -2148,16 +2151,16 @@ function userHook() {
|
||||
};
|
||||
}
|
||||
|
||||
function tomlGsdHookCount(codexHome) {
|
||||
function tomlMsdHookCount(codexHome) {
|
||||
const parsed = parseTomlToObject(fs.readFileSync(path.join(codexHome, 'config.toml'), 'utf8'));
|
||||
const sessionStart = parsed.hooks?.SessionStart ?? [];
|
||||
return sessionStart
|
||||
.flatMap((entry) => Array.isArray(entry.hooks) ? entry.hooks : [])
|
||||
.filter((hook) => typeof hook.command === 'string' && hook.command.includes('gsd-check-update'))
|
||||
.filter((hook) => typeof hook.command === 'string' && hook.command.includes('msd-check-update'))
|
||||
.length;
|
||||
}
|
||||
|
||||
describe('#3357 — Codex install removes legacy GSD hooks.json entries', { concurrency: false }, () => {
|
||||
describe('#3357 — Codex install removes legacy MSD hooks.json entries', { concurrency: false }, () => {
|
||||
let tmpRoot;
|
||||
let codexHome;
|
||||
|
||||
@@ -2168,7 +2171,7 @@ describe('#3357 — Codex install removes legacy GSD hooks.json entries', { conc
|
||||
`node ${BUILD_HOOKS_SCRIPT}`,
|
||||
);
|
||||
}
|
||||
tmpRoot = createTempDir('gsd-3357-');
|
||||
tmpRoot = createTempDir('msd-3357-');
|
||||
codexHome = path.join(tmpRoot, '.codex');
|
||||
fs.mkdirSync(codexHome, { recursive: true });
|
||||
});
|
||||
@@ -2181,7 +2184,7 @@ describe('#3357 — Codex install removes legacy GSD hooks.json entries', { conc
|
||||
test('rewrites hooks.json to one managed SessionStart hook when file only had legacy managed entry', () => {
|
||||
fs.writeFileSync(
|
||||
path.join(codexHome, 'hooks.json'),
|
||||
JSON.stringify({ SessionStart: [legacyGsdHook(codexHome)] }, null, 2),
|
||||
JSON.stringify({ SessionStart: [legacyMsdHook(codexHome)] }, null, 2),
|
||||
);
|
||||
|
||||
withCodexHome(codexHome, () => install(true, 'codex'));
|
||||
@@ -2197,21 +2200,21 @@ describe('#3357 — Codex install removes legacy GSD hooks.json entries', { conc
|
||||
'hooks.json must NOT have a top-level SessionStart key (bug #1348)',
|
||||
);
|
||||
const commands = hooksJson.hooks.SessionStart.flatMap((entry) => entry.hooks).map((hook) => hook.command);
|
||||
const managed = commands.filter((cmd) => typeof cmd === 'string' && cmd.includes('gsd-check-update'));
|
||||
const managed = commands.filter((cmd) => typeof cmd === 'string' && cmd.includes('msd-check-update'));
|
||||
assert.equal(managed.length, 1);
|
||||
assert.equal(tomlGsdHookCount(codexHome), 0);
|
||||
assert.equal(tomlMsdHookCount(codexHome), 0);
|
||||
});
|
||||
|
||||
test('preserves user hooks.json entries while removing the legacy GSD hook', () => {
|
||||
test('preserves user hooks.json entries while removing the legacy MSD hook', () => {
|
||||
const userOwnedSameBasenameHook = {
|
||||
hooks: [{
|
||||
type: 'command',
|
||||
command: 'node "/Users/example/bin/gsd-check-update.js"',
|
||||
command: 'node "/Users/example/bin/msd-check-update.js"',
|
||||
}],
|
||||
};
|
||||
fs.writeFileSync(
|
||||
path.join(codexHome, 'hooks.json'),
|
||||
JSON.stringify({ SessionStart: [legacyGsdHook(codexHome), userHook(), userOwnedSameBasenameHook] }, null, 2),
|
||||
JSON.stringify({ SessionStart: [legacyMsdHook(codexHome), userHook(), userOwnedSameBasenameHook] }, null, 2),
|
||||
);
|
||||
|
||||
withCodexHome(codexHome, () => install(true, 'codex'));
|
||||
@@ -2227,15 +2230,15 @@ describe('#3357 — Codex install removes legacy GSD hooks.json entries', { conc
|
||||
'hooks.json must NOT have a top-level SessionStart key (bug #1348)',
|
||||
);
|
||||
const commands = hooksJson.hooks.SessionStart.flatMap((entry) => entry.hooks).map((hook) => hook.command);
|
||||
const managed = commands.filter((cmd) => typeof cmd === 'string' && cmd.includes('gsd-check-update'));
|
||||
const managed = commands.filter((cmd) => typeof cmd === 'string' && cmd.includes('msd-check-update'));
|
||||
assert.equal(commands.includes('node "/Users/example/bin/user-hook.js"'), true);
|
||||
assert.equal(commands.includes('node "/Users/example/bin/gsd-check-update.js"'), true);
|
||||
assert.equal(commands.includes('node "/Users/example/bin/msd-check-update.js"'), true);
|
||||
assert.equal(managed.length, 2);
|
||||
assert.equal(tomlGsdHookCount(codexHome), 0);
|
||||
assert.equal(tomlMsdHookCount(codexHome), 0);
|
||||
});
|
||||
|
||||
test('restores migrated hooks.json and install state when later Codex validation fails', () => {
|
||||
const before = JSON.stringify({ SessionStart: [legacyGsdHook(codexHome)] }, null, 2);
|
||||
const before = JSON.stringify({ SessionStart: [legacyMsdHook(codexHome)] }, null, 2);
|
||||
fs.writeFileSync(path.join(codexHome, 'hooks.json'), before);
|
||||
|
||||
installModule.__codexSchemaValidator = () => ({
|
||||
@@ -2264,7 +2267,7 @@ describe('#1348 — reconcileCodexHooksJsonEvent canonical nested shape', { conc
|
||||
let tmpDir;
|
||||
|
||||
beforeEach(() => {
|
||||
tmpDir = createTempDir('gsd-1348-');
|
||||
tmpDir = createTempDir('msd-1348-');
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
@@ -2274,7 +2277,7 @@ describe('#1348 — reconcileCodexHooksJsonEvent canonical nested shape', { conc
|
||||
// (a) Fresh/absent hooks.json: register → { "hooks": { "SessionStart": [...] } }
|
||||
test('(a) fresh/absent hooks.json writes nested { hooks: { SessionStart: [...] } } shape', () => {
|
||||
const hooksJsonPath = path.join(tmpDir, 'hooks.json');
|
||||
const FAKE_CMD = `"/usr/local/bin/node" "${path.join(tmpDir, 'hooks', 'gsd-check-update.js').replace(/\\/g, '/')}"`;
|
||||
const FAKE_CMD = `"/usr/local/bin/node" "${path.join(tmpDir, 'hooks', 'msd-check-update.js').replace(/\\/g, '/')}"`;
|
||||
assert.ok(!fs.existsSync(hooksJsonPath), 'precondition: hooks.json must not exist');
|
||||
|
||||
reconcileCodexHooksJsonEvent(tmpDir, 'SessionStart', { managedCommand: FAKE_CMD });
|
||||
@@ -2299,7 +2302,7 @@ describe('#1348 — reconcileCodexHooksJsonEvent canonical nested shape', { conc
|
||||
// (b) Legacy migration: seed top-level { "SessionStart": [<user>] }, register →
|
||||
// nested hooks.SessionStart contains BOTH migrated user entry AND managed entry
|
||||
test('(b) legacy top-level shape: user entries migrate into hooks.SessionStart alongside managed entry', () => {
|
||||
const FAKE_CMD = `"/usr/local/bin/node" "${path.join(tmpDir, 'hooks', 'gsd-check-update.js').replace(/\\/g, '/')}"`;
|
||||
const FAKE_CMD = `"/usr/local/bin/node" "${path.join(tmpDir, 'hooks', 'msd-check-update.js').replace(/\\/g, '/')}"`;
|
||||
const userEntry = { hooks: [{ type: 'command', command: 'node "/Users/alice/my-hook.js"' }] };
|
||||
fs.writeFileSync(
|
||||
path.join(tmpDir, 'hooks.json'),
|
||||
@@ -2330,13 +2333,13 @@ describe('#1348 — reconcileCodexHooksJsonEvent canonical nested shape', { conc
|
||||
);
|
||||
|
||||
// Managed entry is also present
|
||||
const managedCount = allCommands.filter((c) => typeof c === 'string' && c.includes('gsd-check-update')).length;
|
||||
const managedCount = allCommands.filter((c) => typeof c === 'string' && c.includes('msd-check-update')).length;
|
||||
assert.equal(managedCount, 1, 'Exactly one managed entry must be present under hooks.SessionStart');
|
||||
});
|
||||
|
||||
// (c-i) Dedup: re-registering the same managed command does not duplicate it
|
||||
test('(c-i) re-registering managed command produces exactly one managed entry', () => {
|
||||
const FAKE_CMD = `"/usr/local/bin/node" "${path.join(tmpDir, 'hooks', 'gsd-check-update.js').replace(/\\/g, '/')}"`;
|
||||
const FAKE_CMD = `"/usr/local/bin/node" "${path.join(tmpDir, 'hooks', 'msd-check-update.js').replace(/\\/g, '/')}"`;
|
||||
reconcileCodexHooksJsonEvent(tmpDir, 'SessionStart', { managedCommand: FAKE_CMD });
|
||||
reconcileCodexHooksJsonEvent(tmpDir, 'SessionStart', { managedCommand: FAKE_CMD });
|
||||
|
||||
@@ -2344,13 +2347,13 @@ describe('#1348 — reconcileCodexHooksJsonEvent canonical nested shape', { conc
|
||||
const allCommands = hooksJson.hooks.SessionStart
|
||||
.flatMap((e) => Array.isArray(e.hooks) ? e.hooks : [])
|
||||
.map((h) => h.command);
|
||||
const managedCount = allCommands.filter((c) => typeof c === 'string' && c.includes('gsd-check-update')).length;
|
||||
const managedCount = allCommands.filter((c) => typeof c === 'string' && c.includes('msd-check-update')).length;
|
||||
assert.equal(managedCount, 1, 'Re-register must yield exactly one managed entry');
|
||||
});
|
||||
|
||||
// (c-ii) Removal: user entries remain under hooks, managed entry is gone
|
||||
test('(c-ii) removing managed hook leaves user entry under hooks.SessionStart', () => {
|
||||
const FAKE_CMD = `"/usr/local/bin/node" "${path.join(tmpDir, 'hooks', 'gsd-check-update.js').replace(/\\/g, '/')}"`;
|
||||
const FAKE_CMD = `"/usr/local/bin/node" "${path.join(tmpDir, 'hooks', 'msd-check-update.js').replace(/\\/g, '/')}"`;
|
||||
const userEntry = { hooks: [{ type: 'command', command: 'node "/Users/alice/my-hook.js"' }] };
|
||||
// Seed already-nested file with both user + managed
|
||||
reconcileCodexHooksJsonEvent(tmpDir, 'SessionStart', { managedCommand: FAKE_CMD });
|
||||
@@ -2372,7 +2375,7 @@ describe('#1348 — reconcileCodexHooksJsonEvent canonical nested shape', { conc
|
||||
`User entry must remain after managed removal; commands: ${JSON.stringify(allCommands)}`,
|
||||
);
|
||||
// No managed entry
|
||||
const managedCount = allCommands.filter((c) => typeof c === 'string' && c.includes('gsd-check-update')).length;
|
||||
const managedCount = allCommands.filter((c) => typeof c === 'string' && c.includes('msd-check-update')).length;
|
||||
assert.equal(managedCount, 0, 'No managed entry must remain after removal');
|
||||
});
|
||||
|
||||
@@ -2392,7 +2395,7 @@ describe('#1348 — reconcileCodexHooksJsonEvent canonical nested shape', { conc
|
||||
// (d) Mixed nested + top-level shape: { "hooks": { "PreToolUse": [...] }, "SessionStart": [...] }
|
||||
// The stray top-level event array must be lifted into hooks and merged; no top-level key survives.
|
||||
test('(d) mixed nested + top-level shape: stray top-level event array is lifted and merged', () => {
|
||||
const FAKE_CMD = `"/usr/local/bin/node" "${path.join(tmpDir, 'hooks', 'gsd-check-update.js').replace(/\\/g, '/')}"`;
|
||||
const FAKE_CMD = `"/usr/local/bin/node" "${path.join(tmpDir, 'hooks', 'msd-check-update.js').replace(/\\/g, '/')}"`;
|
||||
const existingNestedEntry = { hooks: [{ type: 'command', command: 'node "/Users/alice/pre-tool.js"' }] };
|
||||
const userTopLevelEntry = { hooks: [{ type: 'command', command: 'node "/Users/alice/session-start.js"' }] };
|
||||
|
||||
@@ -2431,7 +2434,7 @@ describe('#1348 — reconcileCodexHooksJsonEvent canonical nested shape', { conc
|
||||
sessionCommands.includes('node "/Users/alice/session-start.js"'),
|
||||
`Migrated user entry must be present in hooks.SessionStart; commands: ${JSON.stringify(sessionCommands)}; full: ${JSON.stringify(hooksJson)}`,
|
||||
);
|
||||
const managedCount = sessionCommands.filter((c) => typeof c === 'string' && c.includes('gsd-check-update')).length;
|
||||
const managedCount = sessionCommands.filter((c) => typeof c === 'string' && c.includes('msd-check-update')).length;
|
||||
assert.equal(managedCount, 1, `Exactly one managed entry must be present in hooks.SessionStart; commands: ${JSON.stringify(sessionCommands)}`);
|
||||
|
||||
// hooks.PreToolUse is untouched
|
||||
@@ -2460,7 +2463,7 @@ describe('#1348 — reconcileCodexHooksJsonEvent canonical nested shape', { conc
|
||||
__foldDescribe("folded:bug-3670-cursor-local-install-migration-lock (consolidation epic #1969 B5 #1974)", () => {
|
||||
/**
|
||||
* Regression tests for issue #3670: --cursor --local install self-deadlocks
|
||||
* on gsd-install-migration.lock.
|
||||
* on msd-install-migration.lock.
|
||||
*
|
||||
* Root cause: On Windows, `fs.rmSync(lockPath, { force: true })` in the lock
|
||||
* release closure silently swallows EPERM errors that NTFS returns when a
|
||||
@@ -2516,7 +2519,7 @@ const path = require('node:path');
|
||||
const {
|
||||
INSTALL_MIGRATION_LOCK_NAME,
|
||||
runInstallerMigrations,
|
||||
} = require('../gsd-core/bin/lib/installer-migrations.cjs');
|
||||
} = require('../msd-core/bin/lib/installer-migrations.cjs');
|
||||
const { cleanup } = require('./helpers.cjs');
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -2524,7 +2527,7 @@ const { cleanup } = require('./helpers.cjs');
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function createTempDir() {
|
||||
return fs.mkdtempSync(path.join(os.tmpdir(), 'gsd-3670-'));
|
||||
return fs.mkdtempSync(path.join(os.tmpdir(), 'msd-3670-'));
|
||||
}
|
||||
|
||||
function lockPath(dir) {
|
||||
@@ -2791,7 +2794,7 @@ test('T5: unreclaimable same-PID lock throws bounded error (reclaim-unlink failu
|
||||
const { describe, test } = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
|
||||
const migration = require('../gsd-core/bin/lib/installer-migrations/001-legacy-orphan-files.cjs');
|
||||
const migration = require('../msd-core/bin/lib/installer-migrations/001-legacy-orphan-files.cjs');
|
||||
|
||||
describe('migration metadata', () => {
|
||||
test('exports a single migration object with required fields', () => {
|
||||
@@ -2841,7 +2844,7 @@ describe('migration.plan()', () => {
|
||||
const actions = migration.plan(makeClassifier('managed-pristine'));
|
||||
const relPaths = actions.map((a) => a.relPath).sort();
|
||||
assert.deepStrictEqual(relPaths, [
|
||||
'hooks/gsd-notify.sh',
|
||||
'hooks/msd-notify.sh',
|
||||
'hooks/statusline.js',
|
||||
]);
|
||||
});
|
||||
@@ -2869,14 +2872,14 @@ describe('migration.plan()', () => {
|
||||
//
|
||||
// `fs.copyFileSync` follows symlinks. Before this hardening, a managed path
|
||||
// replaced by a link would have had the LINK TARGET's bytes copied into the
|
||||
// journal's backup tree — e.g. a `gsd.cjs` symlinked at a private key would
|
||||
// land that key's contents under gsd-migration-journal/. Nothing GSD installs
|
||||
// journal's backup tree — e.g. a `msd.cjs` symlinked at a private key would
|
||||
// land that key's contents under msd-migration-journal/. Nothing MSD installs
|
||||
// is ever a symlink, so the faithful snapshot is the link itself.
|
||||
|
||||
{
|
||||
const { describe, test } = require('node:test');
|
||||
describe('symlinked managed path is snapshotted as a link, never dereferenced', () => {
|
||||
const piExtensionMigration = require('../gsd-core/bin/lib/installer-migrations/006-pi-extension-cjs-to-js.cjs');
|
||||
const piExtensionMigration = require('../msd-core/bin/lib/installer-migrations/006-pi-extension-cjs-to-js.cjs');
|
||||
const SECRET = 'TOP-SECRET-PRIVATE-KEY-MATERIAL\n';
|
||||
|
||||
test('backup-and-remove on a symlinked managed file copies the link, not the referent', (t) => {
|
||||
@@ -2886,7 +2889,7 @@ describe('migration.plan()', () => {
|
||||
const secretPath = path.join(secretDir, 'id_rsa');
|
||||
fs.writeFileSync(secretPath, SECRET, 'utf8');
|
||||
|
||||
const linkPath = path.join(configDir, 'extensions', 'gsd.cjs');
|
||||
const linkPath = path.join(configDir, 'extensions', 'msd.cjs');
|
||||
fs.mkdirSync(path.dirname(linkPath), { recursive: true });
|
||||
try {
|
||||
fs.symlinkSync(secretPath, linkPath);
|
||||
@@ -2897,7 +2900,7 @@ describe('migration.plan()', () => {
|
||||
|
||||
// Manifest records the path as managed with a hash that cannot match the
|
||||
// referent -> classification 'managed-modified' -> backup-and-remove.
|
||||
writeManifest(configDir, { 'extensions/gsd.cjs': sha256('the original extension\n') });
|
||||
writeManifest(configDir, { 'extensions/msd.cjs': sha256('the original extension\n') });
|
||||
|
||||
const result = runInstallerMigrations({
|
||||
configDir,
|
||||
@@ -2945,8 +2948,8 @@ describe('migration.plan()', () => {
|
||||
const configDir = createTempInstall();
|
||||
t.after(() => cleanup(configDir));
|
||||
|
||||
writeFile(configDir, 'extensions/gsd.cjs', 'locally patched extension\n');
|
||||
writeManifest(configDir, { 'extensions/gsd.cjs': sha256('the original extension\n') });
|
||||
writeFile(configDir, 'extensions/msd.cjs', 'locally patched extension\n');
|
||||
writeManifest(configDir, { 'extensions/msd.cjs': sha256('the original extension\n') });
|
||||
|
||||
const result = runInstallerMigrations({
|
||||
configDir,
|
||||
@@ -2970,7 +2973,7 @@ describe('migration.plan()', () => {
|
||||
'locally patched extension\n',
|
||||
'a real file must still be backed up by content so the user can recover it',
|
||||
);
|
||||
assert.ok(!fs.existsSync(path.join(configDir, 'extensions', 'gsd.cjs')));
|
||||
assert.ok(!fs.existsSync(path.join(configDir, 'extensions', 'msd.cjs')));
|
||||
});
|
||||
|
||||
// In-flight failure recovery: when a later step of the SAME apply() attempt
|
||||
@@ -2994,7 +2997,7 @@ describe('migration.plan()', () => {
|
||||
const secretPath = path.join(secretDir, 'id_rsa');
|
||||
fs.writeFileSync(secretPath, SECRET, 'utf8');
|
||||
|
||||
const linkPath = path.join(configDir, 'extensions', 'gsd.cjs');
|
||||
const linkPath = path.join(configDir, 'extensions', 'msd.cjs');
|
||||
fs.mkdirSync(path.dirname(linkPath), { recursive: true });
|
||||
try {
|
||||
fs.symlinkSync(secretPath, linkPath);
|
||||
@@ -3002,7 +3005,7 @@ describe('migration.plan()', () => {
|
||||
t.skip('symlink creation unsupported on this platform/privilege');
|
||||
return;
|
||||
}
|
||||
writeManifest(configDir, { 'extensions/gsd.cjs': sha256('the original extension\n') });
|
||||
writeManifest(configDir, { 'extensions/msd.cjs': sha256('the original extension\n') });
|
||||
|
||||
let fired = false;
|
||||
fs.rmSync = function patched(target, options) {
|
||||
@@ -3064,7 +3067,7 @@ describe('migration.plan()', () => {
|
||||
const targetPath = path.join(secretDir, 'id_rsa');
|
||||
fs.writeFileSync(targetPath, SECRET, 'utf8');
|
||||
|
||||
const linkPath = path.join(configDir, 'extensions', 'gsd.cjs');
|
||||
const linkPath = path.join(configDir, 'extensions', 'msd.cjs');
|
||||
fs.mkdirSync(path.dirname(linkPath), { recursive: true });
|
||||
try {
|
||||
fs.symlinkSync(targetPath, linkPath);
|
||||
@@ -3072,7 +3075,7 @@ describe('migration.plan()', () => {
|
||||
t.skip('symlink creation unsupported on this platform/privilege');
|
||||
return;
|
||||
}
|
||||
writeManifest(configDir, { 'extensions/gsd.cjs': sha256('the original extension\n') });
|
||||
writeManifest(configDir, { 'extensions/msd.cjs': sha256('the original extension\n') });
|
||||
|
||||
const result = runInstallerMigrations({
|
||||
configDir,
|
||||
|
||||
Reference in New Issue
Block a user