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

@@ -8,9 +8,9 @@ const crypto = require('crypto');
const fs = require('fs');
const os = require('os');
const path = require('path');
const { runGsdTools, cleanup } = require('./helpers.cjs');
const { runMsdTools, cleanup } = require('./helpers.cjs');
const { createFixture, seedWorkstream } = require('./fixtures/index.cjs');
const { migrateToWorkstreams, getOtherActiveWorkstreams } = require('../gsd-core/bin/lib/workstream.cjs');
const { migrateToWorkstreams, getOtherActiveWorkstreams } = require('../msd-core/bin/lib/workstream.cjs');
// ─── Helper ──────────────────────────────────────────────────────────────────
@@ -22,13 +22,13 @@ function createFailingTtyEnv(tmpDir) {
fs.mkdirSync(binDir, { recursive: true });
fs.writeFileSync(
path.join(binDir, 'tty'),
'#!/bin/sh\nif [ -n "$GSD_TTY_MARKER" ]; then printf "tty\\n" >> "$GSD_TTY_MARKER"; fi\nexit 99\n',
'#!/bin/sh\nif [ -n "$MSD_TTY_MARKER" ]; then printf "tty\\n" >> "$MSD_TTY_MARKER"; fi\nexit 99\n',
'utf-8'
);
fs.chmodSync(path.join(binDir, 'tty'), 0o755);
fs.writeFileSync(
path.join(binDir, 'tty.cmd'),
'@echo off\r\nif not "%GSD_TTY_MARKER%"=="" echo tty>>"%GSD_TTY_MARKER%"\r\nexit /b 99\r\n',
'@echo off\r\nif not "%MSD_TTY_MARKER%"=="" echo tty>>"%MSD_TTY_MARKER%"\r\nexit /b 99\r\n',
'utf-8'
);
@@ -36,7 +36,7 @@ function createFailingTtyEnv(tmpDir) {
markerFile,
env: {
PATH: `${binDir}${path.delimiter}${inheritedPath}`,
GSD_TTY_MARKER: markerFile,
MSD_TTY_MARKER: markerFile,
},
};
}
@@ -48,7 +48,7 @@ function getSessionPointerDir(tmpDir) {
.update(planningPath)
.digest('hex')
.slice(0, 16);
return path.join(os.tmpdir(), 'gsd-workstream-sessions', projectId);
return path.join(os.tmpdir(), 'msd-workstream-sessions', projectId);
}
function sanitizeSessionToken(value) {
@@ -78,8 +78,8 @@ describe('planningDir workstream awareness via env var', () => {
after(() => cleanup(tmpDir));
test('state json returns workstream-scoped state when GSD_WORKSTREAM is set', () => {
const result = runGsdTools(['state', 'json', '--raw'], tmpDir, { GSD_WORKSTREAM: 'alpha' });
test('state json returns workstream-scoped state when MSD_WORKSTREAM is set', () => {
const result = runMsdTools(['state', 'json', '--raw'], tmpDir, { MSD_WORKSTREAM: 'alpha' });
assert.ok(result.success, `state json failed: ${result.error}`);
const data = JSON.parse(result.output);
assert.ok(data.status || data.current_phase !== undefined, 'should return state data');
@@ -88,7 +88,7 @@ describe('planningDir workstream awareness via env var', () => {
test('state json reads from flat .planning when no workstream set', () => {
// Clear active-workstream so no auto-detection
try { fs.unlinkSync(path.join(tmpDir, '.planning', 'active-workstream')); } catch {}
const result = runGsdTools(['state', 'json', '--raw'], tmpDir, { GSD_WORKSTREAM: '' });
const result = runMsdTools(['state', 'json', '--raw'], tmpDir, { MSD_WORKSTREAM: '' });
// Should fail or return empty state since flat .planning/ has no STATE.md
assert.ok(!result.success || result.output.includes('not found') || result.output === '{}',
'should read from flat .planning/');
@@ -96,13 +96,13 @@ describe('planningDir workstream awareness via env var', () => {
fs.writeFileSync(path.join(tmpDir, '.planning', 'active-workstream'), 'alpha\n');
});
test('--ws flag overrides GSD_WORKSTREAM env var', () => {
test('--ws flag overrides MSD_WORKSTREAM env var', () => {
// Create a second workstream
const betaDir = path.join(tmpDir, '.planning', 'workstreams', 'beta');
fs.mkdirSync(path.join(betaDir, 'phases'), { recursive: true });
fs.writeFileSync(path.join(betaDir, 'STATE.md'), '# State\n**Status:** Beta active\n');
const result = runGsdTools(['state', 'json', '--raw', '--ws', 'beta'], tmpDir, { GSD_WORKSTREAM: 'alpha' });
const result = runMsdTools(['state', 'json', '--raw', '--ws', 'beta'], tmpDir, { MSD_WORKSTREAM: 'alpha' });
assert.ok(result.success, `state json --ws beta failed: ${result.error}`);
});
});
@@ -123,8 +123,8 @@ describe('session-scoped active workstream routing', () => {
after(() => cleanup(tmpDir));
test('stores active workstream per session instead of mutating shared pointer', () => {
const alphaSet = runGsdTools(['workstream', 'set', 'alpha', '--raw'], tmpDir, { GSD_SESSION_KEY: 'session-alpha' });
const betaSet = runGsdTools(['workstream', 'set', 'beta', '--raw'], tmpDir, { GSD_SESSION_KEY: 'session-beta' });
const alphaSet = runMsdTools(['workstream', 'set', 'alpha', '--raw'], tmpDir, { MSD_SESSION_KEY: 'session-alpha' });
const betaSet = runMsdTools(['workstream', 'set', 'beta', '--raw'], tmpDir, { MSD_SESSION_KEY: 'session-beta' });
assert.ok(alphaSet.success, `alpha set failed: ${alphaSet.error}`);
assert.ok(betaSet.success, `beta set failed: ${betaSet.error}`);
@@ -133,8 +133,8 @@ describe('session-scoped active workstream routing', () => {
});
test('different sessions resolve different active workstreams without --ws', () => {
const alpha = runGsdTools(['workstream', 'get', '--raw'], tmpDir, { GSD_SESSION_KEY: 'session-alpha' });
const beta = runGsdTools(['workstream', 'get', '--raw'], tmpDir, { GSD_SESSION_KEY: 'session-beta' });
const alpha = runMsdTools(['workstream', 'get', '--raw'], tmpDir, { MSD_SESSION_KEY: 'session-alpha' });
const beta = runMsdTools(['workstream', 'get', '--raw'], tmpDir, { MSD_SESSION_KEY: 'session-beta' });
assert.ok(alpha.success, `alpha get failed: ${alpha.error}`);
assert.ok(beta.success, `beta get failed: ${beta.error}`);
@@ -145,8 +145,8 @@ describe('session-scoped active workstream routing', () => {
test('session-scoped pointer ignores legacy shared active-workstream file', () => {
fs.writeFileSync(path.join(tmpDir, '.planning', 'active-workstream'), 'beta\n');
const alpha = runGsdTools(['workstream', 'get', '--raw'], tmpDir, { GSD_SESSION_KEY: 'session-alpha' });
const shared = runGsdTools(['workstream', 'get', '--raw'], tmpDir);
const alpha = runMsdTools(['workstream', 'get', '--raw'], tmpDir, { MSD_SESSION_KEY: 'session-alpha' });
const shared = runMsdTools(['workstream', 'get', '--raw'], tmpDir);
assert.ok(alpha.success, `session-scoped get failed: ${alpha.error}`);
assert.ok(shared.success, `legacy get failed: ${shared.error}`);
@@ -155,8 +155,8 @@ describe('session-scoped active workstream routing', () => {
});
test('state commands route to the session-scoped workstream automatically', () => {
const alpha = runGsdTools(['state', 'json', '--raw'], tmpDir, { GSD_SESSION_KEY: 'session-alpha' });
const beta = runGsdTools(['state', 'json', '--raw'], tmpDir, { GSD_SESSION_KEY: 'session-beta' });
const alpha = runMsdTools(['state', 'json', '--raw'], tmpDir, { MSD_SESSION_KEY: 'session-alpha' });
const beta = runMsdTools(['state', 'json', '--raw'], tmpDir, { MSD_SESSION_KEY: 'session-beta' });
assert.ok(alpha.success, `alpha state failed: ${alpha.error}`);
assert.ok(beta.success, `beta state failed: ${beta.error}`);
@@ -178,9 +178,9 @@ describe('session-scoped active workstream routing', () => {
// of whatever an earlier test in this block left on disk.
try { fs.unlinkSync(path.join(tmpDir, '.planning', 'active-workstream')); } catch {}
const clearAlpha = runGsdTools(['workstream', 'set', '--clear', '--raw'], tmpDir, { GSD_SESSION_KEY: 'session-alpha' });
const alpha = runGsdTools(['workstream', 'get'], tmpDir, { GSD_SESSION_KEY: 'session-alpha' });
const beta = runGsdTools(['workstream', 'get', '--raw'], tmpDir, { GSD_SESSION_KEY: 'session-beta' });
const clearAlpha = runMsdTools(['workstream', 'set', '--clear', '--raw'], tmpDir, { MSD_SESSION_KEY: 'session-alpha' });
const alpha = runMsdTools(['workstream', 'get'], tmpDir, { MSD_SESSION_KEY: 'session-alpha' });
const beta = runMsdTools(['workstream', 'get', '--raw'], tmpDir, { MSD_SESSION_KEY: 'session-beta' });
assert.ok(clearAlpha.success, `clear alpha failed: ${clearAlpha.error}`);
assert.ok(alpha.success, `alpha get after clear failed: ${alpha.error}`);
@@ -209,8 +209,8 @@ describe('session resolution hardening', () => {
test('headless runs skip tty probing and use the shared active-workstream fallback', () => {
const { markerFile, env } = createFailingTtyEnv(tmpDir);
const set = runGsdTools(['workstream', 'set', 'alpha', '--raw'], tmpDir, env);
const get = runGsdTools(['workstream', 'get', '--raw'], tmpDir, env);
const set = runMsdTools(['workstream', 'set', 'alpha', '--raw'], tmpDir, env);
const get = runMsdTools(['workstream', 'get', '--raw'], tmpDir, env);
assert.ok(set.success, `headless set failed: ${set.error}`);
assert.ok(get.success, `headless get failed: ${get.error}`);
@@ -224,12 +224,12 @@ describe('session resolution hardening', () => {
});
test('explicit runtime session ids outrank tty-derived identities', () => {
const set = runGsdTools(['workstream', 'set', 'alpha', '--raw'], tmpDir, {
GSD_SESSION_KEY: 'shared-session',
const set = runMsdTools(['workstream', 'set', 'alpha', '--raw'], tmpDir, {
MSD_SESSION_KEY: 'shared-session',
TTY: '/dev/pts/42',
});
const get = runGsdTools(['workstream', 'get', '--raw'], tmpDir, {
GSD_SESSION_KEY: 'shared-session',
const get = runMsdTools(['workstream', 'get', '--raw'], tmpDir, {
MSD_SESSION_KEY: 'shared-session',
TTY: '/dev/pts/99',
});
@@ -242,8 +242,8 @@ describe('session resolution hardening', () => {
test('TTY environment variables provide a session-scoped pointer without spawning tty', () => {
const { markerFile, env } = createFailingTtyEnv(tmpDir);
const ttyEnv = { ...env, TTY: '/dev/pts/42' };
const set = runGsdTools(['workstream', 'set', 'beta', '--raw'], tmpDir, ttyEnv);
const get = runGsdTools(['workstream', 'get', '--raw'], tmpDir, ttyEnv);
const set = runMsdTools(['workstream', 'set', 'beta', '--raw'], tmpDir, ttyEnv);
const get = runMsdTools(['workstream', 'get', '--raw'], tmpDir, ttyEnv);
assert.ok(set.success, `TTY set failed: ${set.error}`);
assert.ok(get.success, `TTY get failed: ${get.error}`);
@@ -264,7 +264,7 @@ describe('session inherits shared marker when pointer-less (#3579)', () => {
const {
getActiveWorkstream,
peekActiveWorkstream,
} = require('../gsd-core/bin/lib/active-workstream-store.cjs');
} = require('../msd-core/bin/lib/active-workstream-store.cjs');
beforeEach(() => {
tmpDir = createFixture();
@@ -281,7 +281,7 @@ describe('session inherits shared marker when pointer-less (#3579)', () => {
test('session key present, no session pointer, marker names an existing workstream -> inherits the marker', () => {
fs.writeFileSync(path.join(tmpDir, '.planning', 'active-workstream'), 'alpha\n');
const result = runGsdTools(['workstream', 'get', '--raw'], tmpDir, { GSD_SESSION_KEY: 'no-pointer-session' });
const result = runMsdTools(['workstream', 'get', '--raw'], tmpDir, { MSD_SESSION_KEY: 'no-pointer-session' });
assert.ok(result.success, `get failed: ${result.error}`);
assert.strictEqual(result.output, 'alpha');
@@ -291,11 +291,11 @@ describe('session inherits shared marker when pointer-less (#3579)', () => {
const markerPath = path.join(tmpDir, '.planning', 'active-workstream');
fs.writeFileSync(markerPath, 'alpha\n');
const sessionDir = getSessionPointerDir(tmpDir);
const savedSessionKey = process.env.GSD_SESSION_KEY;
process.env.GSD_SESSION_KEY = 'peek-no-pointer';
const savedSessionKey = process.env.MSD_SESSION_KEY;
process.env.MSD_SESSION_KEY = 'peek-no-pointer';
t.after(() => {
if (savedSessionKey !== undefined) process.env.GSD_SESSION_KEY = savedSessionKey;
else delete process.env.GSD_SESSION_KEY;
if (savedSessionKey !== undefined) process.env.MSD_SESSION_KEY = savedSessionKey;
else delete process.env.MSD_SESSION_KEY;
});
const resolved = peekActiveWorkstream(tmpDir);
@@ -307,9 +307,9 @@ describe('session inherits shared marker when pointer-less (#3579)', () => {
test('session pointer names beta while marker names alpha -> resolves beta, marker untouched (isolation)', () => {
const markerPath = path.join(tmpDir, '.planning', 'active-workstream');
fs.writeFileSync(markerPath, 'alpha\n');
runGsdTools(['workstream', 'set', 'beta', '--raw'], tmpDir, { GSD_SESSION_KEY: 'has-own-pointer' });
runMsdTools(['workstream', 'set', 'beta', '--raw'], tmpDir, { MSD_SESSION_KEY: 'has-own-pointer' });
const result = runGsdTools(['workstream', 'get', '--raw'], tmpDir, { GSD_SESSION_KEY: 'has-own-pointer' });
const result = runMsdTools(['workstream', 'get', '--raw'], tmpDir, { MSD_SESSION_KEY: 'has-own-pointer' });
assert.ok(result.success, `get failed: ${result.error}`);
assert.strictEqual(result.output, 'beta');
@@ -319,10 +319,10 @@ describe('session inherits shared marker when pointer-less (#3579)', () => {
test('workstream set --clear with a valid repo marker present -> session returns to inheriting the marker, not flat', () => {
const markerPath = path.join(tmpDir, '.planning', 'active-workstream');
fs.writeFileSync(markerPath, 'alpha\n');
runGsdTools(['workstream', 'set', 'beta', '--raw'], tmpDir, { GSD_SESSION_KEY: 'clear-then-inherit-session' });
runMsdTools(['workstream', 'set', 'beta', '--raw'], tmpDir, { MSD_SESSION_KEY: 'clear-then-inherit-session' });
const clear = runGsdTools(['workstream', 'set', '--clear', '--raw'], tmpDir, { GSD_SESSION_KEY: 'clear-then-inherit-session' });
const result = runGsdTools(['workstream', 'get', '--raw'], tmpDir, { GSD_SESSION_KEY: 'clear-then-inherit-session' });
const clear = runMsdTools(['workstream', 'set', '--clear', '--raw'], tmpDir, { MSD_SESSION_KEY: 'clear-then-inherit-session' });
const result = runMsdTools(['workstream', 'get', '--raw'], tmpDir, { MSD_SESSION_KEY: 'clear-then-inherit-session' });
assert.ok(clear.success, `clear failed: ${clear.error}`);
assert.ok(result.success, `get after clear failed: ${result.error}`);
@@ -336,7 +336,7 @@ describe('session inherits shared marker when pointer-less (#3579)', () => {
test('no session key, marker present -> resolves the marker (pre-existing path stays green)', () => {
fs.writeFileSync(path.join(tmpDir, '.planning', 'active-workstream'), 'alpha\n');
const result = runGsdTools(['workstream', 'get', '--raw'], tmpDir, {});
const result = runMsdTools(['workstream', 'get', '--raw'], tmpDir, {});
assert.ok(result.success, `get failed: ${result.error}`);
assert.strictEqual(result.output, 'alpha');
@@ -347,11 +347,11 @@ describe('session inherits shared marker when pointer-less (#3579)', () => {
const flatDir = createFixture();
t.after(() => cleanup(flatDir));
const savedSessionKey = process.env.GSD_SESSION_KEY;
process.env.GSD_SESSION_KEY = 'flat-no-workstreams-dir';
const savedSessionKey = process.env.MSD_SESSION_KEY;
process.env.MSD_SESSION_KEY = 'flat-no-workstreams-dir';
t.after(() => {
if (savedSessionKey !== undefined) process.env.GSD_SESSION_KEY = savedSessionKey;
else delete process.env.GSD_SESSION_KEY;
if (savedSessionKey !== undefined) process.env.MSD_SESSION_KEY = savedSessionKey;
else delete process.env.MSD_SESSION_KEY;
});
assert.strictEqual(getActiveWorkstream(flatDir), null);
@@ -362,7 +362,7 @@ describe('session inherits shared marker when pointer-less (#3579)', () => {
const markerPath = path.join(tmpDir, '.planning', 'active-workstream');
fs.writeFileSync(markerPath, 'ghost-workstream\n');
const result = runGsdTools(['workstream', 'get'], tmpDir, { GSD_SESSION_KEY: 'stale-marker-session' });
const result = runMsdTools(['workstream', 'get'], tmpDir, { MSD_SESSION_KEY: 'stale-marker-session' });
assert.ok(result.success, `get failed: ${result.error}`);
assert.strictEqual(JSON.parse(result.output).active, null);
@@ -374,12 +374,12 @@ describe('session inherits shared marker when pointer-less (#3579)', () => {
const markerPath = path.join(tmpDir, '.planning', 'active-workstream');
fs.writeFileSync(markerPath, 'beta\n');
runGsdTools(['workstream', 'set', 'alpha', '--raw'], tmpDir, { GSD_SESSION_KEY: 'whitespace-pointer-session' });
runMsdTools(['workstream', 'set', 'alpha', '--raw'], tmpDir, { MSD_SESSION_KEY: 'whitespace-pointer-session' });
const sessionDir = getSessionPointerDir(tmpDir);
const sessionFile = getSessionPointerFileName('GSD_SESSION_KEY', 'whitespace-pointer-session');
const sessionFile = getSessionPointerFileName('MSD_SESSION_KEY', 'whitespace-pointer-session');
fs.writeFileSync(path.join(sessionDir, sessionFile), ' \n');
const result = runGsdTools(['workstream', 'get', '--raw'], tmpDir, { GSD_SESSION_KEY: 'whitespace-pointer-session' });
const result = runMsdTools(['workstream', 'get', '--raw'], tmpDir, { MSD_SESSION_KEY: 'whitespace-pointer-session' });
assert.ok(result.success, `get failed: ${result.error}`);
assert.strictEqual(result.output, 'beta');
@@ -389,7 +389,7 @@ describe('session inherits shared marker when pointer-less (#3579)', () => {
const markerPath = path.join(tmpDir, '.planning', 'active-workstream');
fs.writeFileSync(markerPath, ' \n');
const result = runGsdTools(['workstream', 'get'], tmpDir, { GSD_SESSION_KEY: 'whitespace-marker-session' });
const result = runMsdTools(['workstream', 'get'], tmpDir, { MSD_SESSION_KEY: 'whitespace-marker-session' });
assert.ok(result.success, `get failed: ${result.error}`);
assert.strictEqual(JSON.parse(result.output).active, null);
@@ -399,7 +399,7 @@ describe('session inherits shared marker when pointer-less (#3579)', () => {
const markerPath = path.join(tmpDir, '.planning', 'active-workstream');
fs.writeFileSync(markerPath, '');
const result = runGsdTools(['workstream', 'get'], tmpDir, { GSD_SESSION_KEY: 'empty-marker-session' });
const result = runMsdTools(['workstream', 'get'], tmpDir, { MSD_SESSION_KEY: 'empty-marker-session' });
assert.ok(result.success, `get failed: ${result.error}`);
assert.strictEqual(JSON.parse(result.output).active, null);
@@ -408,11 +408,11 @@ describe('session inherits shared marker when pointer-less (#3579)', () => {
test('session pointer is stale (its workstream is deleted) while marker names a different, still-valid workstream -> resolves null, never falls through to inherit the marker', () => {
const markerPath = path.join(tmpDir, '.planning', 'active-workstream');
fs.writeFileSync(markerPath, 'beta\n');
runGsdTools(['workstream', 'set', 'alpha', '--raw'], tmpDir, { GSD_SESSION_KEY: 'stale-own-pointer-session' });
runMsdTools(['workstream', 'set', 'alpha', '--raw'], tmpDir, { MSD_SESSION_KEY: 'stale-own-pointer-session' });
// eslint-disable-next-line local/no-raw-rmsync-in-tests -- mid-test fault injection: simulates a deleted workstream to exercise stale-pointer self-cleanup
fs.rmSync(path.join(tmpDir, '.planning', 'workstreams', 'alpha'), { recursive: true, force: true });
const result = runGsdTools(['workstream', 'get'], tmpDir, { GSD_SESSION_KEY: 'stale-own-pointer-session' });
const result = runMsdTools(['workstream', 'get'], tmpDir, { MSD_SESSION_KEY: 'stale-own-pointer-session' });
assert.ok(result.success, `get failed: ${result.error}`);
assert.strictEqual(
@@ -428,7 +428,7 @@ describe('session inherits shared marker when pointer-less (#3579)', () => {
// not resolve" — asserted structurally (via --json-errors) per CONTRIBUTING,
// not by regexing the human-readable message.
test('init.progress fail-safe guard: no marker at all -> reason workstream_mode_none_active', () => {
const result = runGsdTools(['--json-errors', 'init', 'progress'], tmpDir);
const result = runMsdTools(['--json-errors', 'init', 'progress'], tmpDir);
assert.equal(result.success, false, 'must still refuse');
const payload = JSON.parse(result.error);
@@ -436,11 +436,11 @@ describe('session inherits shared marker when pointer-less (#3579)', () => {
});
test('init.progress fail-safe guard: marker present but names a missing workstream dir -> reason workstream_mode_marker_unresolved, distinct message', () => {
const noneResult = runGsdTools(['--json-errors', 'init', 'progress'], tmpDir);
const noneResult = runMsdTools(['--json-errors', 'init', 'progress'], tmpDir);
const nonePayload = JSON.parse(noneResult.error);
fs.writeFileSync(path.join(tmpDir, '.planning', 'active-workstream'), 'ghost-workstream\n');
const unresolvedResult = runGsdTools(['--json-errors', 'init', 'progress'], tmpDir);
const unresolvedResult = runMsdTools(['--json-errors', 'init', 'progress'], tmpDir);
assert.equal(unresolvedResult.success, false, 'must still refuse');
const unresolvedPayload = JSON.parse(unresolvedResult.error);
@@ -457,7 +457,7 @@ describe('session inherits shared marker when pointer-less (#3579)', () => {
test('init.progress fail-safe guard: marker present but names an invalid workstream name -> reason workstream_mode_marker_unresolved, invalid_name', () => {
fs.writeFileSync(path.join(tmpDir, '.planning', 'active-workstream'), 'bad/name\n');
const result = runGsdTools(['--json-errors', 'init', 'progress'], tmpDir);
const result = runMsdTools(['--json-errors', 'init', 'progress'], tmpDir);
assert.equal(result.success, false, 'must still refuse');
const payload = JSON.parse(result.error);
@@ -484,14 +484,14 @@ describe('pointer lifecycle hardening', () => {
test('clearing one session pointer leaves sibling session pointers intact', () => {
const sessionDir = getSessionPointerDir(tmpDir);
const alphaFile = getSessionPointerFileName('GSD_SESSION_KEY', 'session-alpha');
const betaFile = getSessionPointerFileName('GSD_SESSION_KEY', 'session-beta');
const alphaFile = getSessionPointerFileName('MSD_SESSION_KEY', 'session-alpha');
const betaFile = getSessionPointerFileName('MSD_SESSION_KEY', 'session-beta');
runGsdTools(['workstream', 'set', 'alpha', '--raw'], tmpDir, { GSD_SESSION_KEY: 'session-alpha' });
runGsdTools(['workstream', 'set', 'beta', '--raw'], tmpDir, { GSD_SESSION_KEY: 'session-beta' });
runMsdTools(['workstream', 'set', 'alpha', '--raw'], tmpDir, { MSD_SESSION_KEY: 'session-alpha' });
runMsdTools(['workstream', 'set', 'beta', '--raw'], tmpDir, { MSD_SESSION_KEY: 'session-beta' });
const clearAlpha = runGsdTools(['workstream', 'set', '--clear', '--raw'], tmpDir, { GSD_SESSION_KEY: 'session-alpha' });
const beta = runGsdTools(['workstream', 'get', '--raw'], tmpDir, { GSD_SESSION_KEY: 'session-beta' });
const clearAlpha = runMsdTools(['workstream', 'set', '--clear', '--raw'], tmpDir, { MSD_SESSION_KEY: 'session-alpha' });
const beta = runMsdTools(['workstream', 'get', '--raw'], tmpDir, { MSD_SESSION_KEY: 'session-beta' });
assert.ok(clearAlpha.success, `clear alpha failed: ${clearAlpha.error}`);
assert.ok(beta.success, `beta get failed: ${beta.error}`);
@@ -503,15 +503,15 @@ describe('pointer lifecycle hardening', () => {
test('stale pointers self-clean without deleting sibling session pointers', () => {
const sessionDir = getSessionPointerDir(tmpDir);
const betaFile = getSessionPointerFileName('GSD_SESSION_KEY', 'session-beta');
const betaFile = getSessionPointerFileName('MSD_SESSION_KEY', 'session-beta');
runGsdTools(['workstream', 'set', 'alpha', '--raw'], tmpDir, { GSD_SESSION_KEY: 'session-alpha' });
runGsdTools(['workstream', 'set', 'beta', '--raw'], tmpDir, { GSD_SESSION_KEY: 'session-beta' });
runMsdTools(['workstream', 'set', 'alpha', '--raw'], tmpDir, { MSD_SESSION_KEY: 'session-alpha' });
runMsdTools(['workstream', 'set', 'beta', '--raw'], tmpDir, { MSD_SESSION_KEY: 'session-beta' });
// eslint-disable-next-line local/no-raw-rmsync-in-tests -- mid-test fault injection: simulates a deleted workstream to exercise stale-pointer self-cleanup
fs.rmSync(path.join(tmpDir, '.planning', 'workstreams', 'alpha'), { recursive: true, force: true });
const alpha = runGsdTools(['workstream', 'get'], tmpDir, { GSD_SESSION_KEY: 'session-alpha' });
const beta = runGsdTools(['workstream', 'get', '--raw'], tmpDir, { GSD_SESSION_KEY: 'session-beta' });
const alpha = runMsdTools(['workstream', 'get'], tmpDir, { MSD_SESSION_KEY: 'session-alpha' });
const beta = runMsdTools(['workstream', 'get', '--raw'], tmpDir, { MSD_SESSION_KEY: 'session-beta' });
assert.ok(alpha.success, `stale alpha get failed: ${alpha.error}`);
assert.ok(beta.success, `beta get after stale cleanup failed: ${beta.error}`);
@@ -523,12 +523,12 @@ describe('pointer lifecycle hardening', () => {
test('clearing the last session pointer removes the empty session tmp directory', () => {
const sessionDir = getSessionPointerDir(tmpDir);
const set = runGsdTools(['workstream', 'set', 'alpha', '--raw'], tmpDir, { GSD_SESSION_KEY: 'session-alpha' });
const set = runMsdTools(['workstream', 'set', 'alpha', '--raw'], tmpDir, { MSD_SESSION_KEY: 'session-alpha' });
assert.ok(set.success, `set alpha failed: ${set.error}`);
assert.ok(fs.existsSync(sessionDir), 'session tmp directory should exist after storing a session-scoped pointer');
const clear = runGsdTools(['workstream', 'set', '--clear', '--raw'], tmpDir, { GSD_SESSION_KEY: 'session-alpha' });
const clear = runMsdTools(['workstream', 'set', '--clear', '--raw'], tmpDir, { MSD_SESSION_KEY: 'session-alpha' });
assert.ok(clear.success, `clear alpha failed: ${clear.error}`);
assert.ok(!fs.existsSync(sessionDir), 'last-pointer cleanup should remove the empty session tmp directory');
@@ -548,7 +548,7 @@ describe('workstream create', () => {
after(() => cleanup(tmpDir));
test('creates a new workstream in clean project', () => {
const result = runGsdTools(['workstream', 'create', 'feature-x', '--raw'], tmpDir);
const result = runMsdTools(['workstream', 'create', 'feature-x', '--raw'], tmpDir);
assert.ok(result.success, `create failed: ${result.error}`);
const data = JSON.parse(result.output);
assert.strictEqual(data.created, true);
@@ -563,7 +563,7 @@ describe('workstream create', () => {
});
test('rejects duplicate workstream', () => {
const result = runGsdTools(['workstream', 'create', 'feature-x', '--raw'], tmpDir);
const result = runMsdTools(['workstream', 'create', 'feature-x', '--raw'], tmpDir);
assert.ok(result.success); // returns success with error field
const data = JSON.parse(result.output);
assert.strictEqual(data.created, false);
@@ -571,7 +571,7 @@ describe('workstream create', () => {
});
test('creates second workstream', () => {
const result = runGsdTools(['workstream', 'create', 'feature-y', '--raw'], tmpDir);
const result = runMsdTools(['workstream', 'create', 'feature-y', '--raw'], tmpDir);
assert.ok(result.success);
const data = JSON.parse(result.output);
assert.strictEqual(data.created, true);
@@ -593,7 +593,7 @@ describe('workstream create with migration', () => {
after(() => cleanup(tmpDir));
test('migrates existing flat work to named workstream', () => {
const result = runGsdTools(['workstream', 'create', 'new-feature', '--migrate-name', 'existing-work', '--raw'], tmpDir);
const result = runMsdTools(['workstream', 'create', 'new-feature', '--migrate-name', 'existing-work', '--raw'], tmpDir);
assert.ok(result.success, `create with migration failed: ${result.error}`);
const data = JSON.parse(result.output);
assert.strictEqual(data.created, true);
@@ -613,7 +613,7 @@ describe('workstream create with migration', () => {
fs.writeFileSync(path.join(isolatedDir, '.planning', 'ROADMAP.md'), '## Roadmap v1.0: Existing\n### Phase 1: A\n');
fs.writeFileSync(path.join(isolatedDir, '.planning', 'STATE.md'), '# State\n**Status:** In progress\n');
const result = runGsdTools(
const result = runMsdTools(
['workstream', 'create', 'new-feature', '--migrate-name', 'Bad Name', '--raw'],
isolatedDir
);
@@ -674,7 +674,7 @@ describe('workstream list', () => {
after(() => cleanup(tmpDir));
test('lists all workstreams with active first, then lexical name', () => {
const result = runGsdTools(['workstream', 'list', '--raw'], tmpDir);
const result = runMsdTools(['workstream', 'list', '--raw'], tmpDir);
assert.ok(result.success, `list failed: ${result.error}`);
const data = JSON.parse(result.output);
assert.strictEqual(data.mode, 'workstream');
@@ -694,7 +694,7 @@ describe('workstream list', () => {
});
test('reports flat mode when no workstreams exist', () => {
const result = runGsdTools(['workstream', 'list', '--raw'], flatDir);
const result = runMsdTools(['workstream', 'list', '--raw'], flatDir);
assert.ok(result.success);
const data = JSON.parse(result.output);
assert.strictEqual(data.mode, 'flat');
@@ -717,7 +717,7 @@ describe('workstream status', () => {
after(() => cleanup(tmpDir));
test('returns detailed status for workstream', () => {
const result = runGsdTools(['workstream', 'status', 'alpha', '--raw'], tmpDir);
const result = runMsdTools(['workstream', 'status', 'alpha', '--raw'], tmpDir);
assert.ok(result.success, `status failed: ${result.error}`);
const data = JSON.parse(result.output);
assert.strictEqual(data.found, true);
@@ -728,7 +728,7 @@ describe('workstream status', () => {
});
test('returns not found for missing workstream', () => {
const result = runGsdTools(['workstream', 'status', 'nonexistent', '--raw'], tmpDir);
const result = runMsdTools(['workstream', 'status', 'nonexistent', '--raw'], tmpDir);
assert.ok(result.success);
const data = JSON.parse(result.output);
assert.strictEqual(data.found, false);
@@ -749,7 +749,7 @@ describe('workstream complete', () => {
after(() => cleanup(tmpDir));
test('archives workstream to milestones/', () => {
const result = runGsdTools(['workstream', 'complete', 'done-ws', '--raw'], tmpDir);
const result = runMsdTools(['workstream', 'complete', 'done-ws', '--raw'], tmpDir);
assert.ok(result.success, `complete failed: ${result.error}`);
const data = JSON.parse(result.output);
assert.strictEqual(data.completed, true);
@@ -778,28 +778,28 @@ describe('workstream set/get', () => {
after(() => cleanup(tmpDir));
test('sets active workstream', () => {
const result = runGsdTools(['workstream', 'set', 'ws-a', '--raw'], tmpDir);
const result = runMsdTools(['workstream', 'set', 'ws-a', '--raw'], tmpDir);
assert.ok(result.success);
assert.strictEqual(result.output, 'ws-a');
});
test('gets active workstream', () => {
const result = runGsdTools(['workstream', 'get', '--raw'], tmpDir);
const result = runMsdTools(['workstream', 'get', '--raw'], tmpDir);
assert.ok(result.success);
assert.strictEqual(result.output, 'ws-a');
});
test('errors when set called with no name (#1527)', () => {
const result = runGsdTools(['workstream', 'set', '--raw'], tmpDir);
const result = runMsdTools(['workstream', 'set', '--raw'], tmpDir);
assert.ok(!result.success, 'should fail when no name provided');
assert.ok(result.error.includes('name required'), 'error should mention name required');
});
test('--clear explicitly unsets active workstream', () => {
// First set one
runGsdTools(['workstream', 'set', 'ws-b', '--raw'], tmpDir);
runMsdTools(['workstream', 'set', 'ws-b', '--raw'], tmpDir);
// Then clear
const result = runGsdTools(['workstream', 'set', '--clear', '--raw'], tmpDir);
const result = runMsdTools(['workstream', 'set', '--clear', '--raw'], tmpDir);
assert.ok(result.success);
const data = JSON.parse(result.output);
assert.strictEqual(data.active, null);
@@ -831,7 +831,7 @@ describe('getOtherActiveWorkstreams', () => {
after(() => cleanup(tmpDir));
test('workstream list excludes completed workstreams from active count', () => {
const result = runGsdTools(['workstream', 'list', '--raw'], tmpDir);
const result = runMsdTools(['workstream', 'list', '--raw'], tmpDir);
assert.ok(result.success);
const data = JSON.parse(result.output);
assert.strictEqual(data.count, 3); // all listed
@@ -888,7 +888,7 @@ describe('workstream progress', () => {
after(() => cleanup(tmpDir));
test('returns progress summary in deterministic order', () => {
const result = runGsdTools(['workstream', 'progress', '--raw'], tmpDir);
const result = runMsdTools(['workstream', 'progress', '--raw'], tmpDir);
assert.ok(result.success, `progress failed: ${result.error}`);
const data = JSON.parse(result.output);
assert.strictEqual(data.mode, 'workstream');
@@ -915,7 +915,7 @@ describe('workstream progress', () => {
fs.writeFileSync(path.join(wsDir, 'STATE.md'), '# State\n**Status:** In progress\n');
fs.writeFileSync(path.join(wsDir, 'ROADMAP.md'), '# Roadmap\n### Phase 1: One\n');
const result = runGsdTools(['workstream', 'progress', '--raw'], isolatedDir);
const result = runMsdTools(['workstream', 'progress', '--raw'], isolatedDir);
assert.ok(result.success, `progress failed: ${result.error}`);
const data = JSON.parse(result.output);
assert.strictEqual(data.workstreams[0].progress_percent, 100);
@@ -927,7 +927,7 @@ describe('workstream progress', () => {
test('returns flat mode when no workstreams exist', () => {
const emptyDir = createFixture();
try {
const result = runGsdTools(['workstream', 'progress', '--raw'], emptyDir);
const result = runMsdTools(['workstream', 'progress', '--raw'], emptyDir);
assert.ok(result.success, `progress in flat mode failed: ${result.error}`);
const data = JSON.parse(result.output);
assert.strictEqual(data.mode, 'flat');
@@ -937,9 +937,9 @@ describe('workstream progress', () => {
});
});
// ─── Integration: gsd-tools --ws flag ────────────────────────────────────────
// ─── Integration: msd-tools --ws flag ────────────────────────────────────────
describe('gsd-tools --ws flag integration', () => {
describe('msd-tools --ws flag integration', () => {
let tmpDir;
before(() => {
@@ -957,13 +957,13 @@ describe('gsd-tools --ws flag integration', () => {
after(() => cleanup(tmpDir));
test('find-phase resolves to workstream-scoped phases via --ws', () => {
const result = runGsdTools(['find-phase', '1', '--raw', '--ws', 'test-ws'], tmpDir);
const result = runMsdTools(['find-phase', '1', '--raw', '--ws', 'test-ws'], tmpDir);
assert.ok(result.success, `find-phase failed: ${result.error}`);
assert.ok(result.output.includes('workstreams/test-ws'), `path should be workstream-scoped: ${result.output}`);
});
test('find-phase returns JSON with workstream path when not raw', () => {
const result = runGsdTools(['find-phase', '1', '--ws', 'test-ws'], tmpDir);
const result = runMsdTools(['find-phase', '1', '--ws', 'test-ws'], tmpDir);
assert.ok(result.success, `find-phase failed: ${result.error}`);
const data = JSON.parse(result.output);
assert.ok(data.found, 'phase should be found');
@@ -1000,18 +1000,18 @@ describe('path traversal rejection', () => {
describe('--ws flag rejects traversal attempts', () => {
for (const name of maliciousNames) {
test(`rejects --ws=${name}`, () => {
const result = runGsdTools(['workstream', 'list', '--raw', '--ws', name], tmpDir);
const result = runMsdTools(['workstream', 'list', '--raw', '--ws', name], tmpDir);
assert.ok(!result.success, `should reject --ws=${name}`);
assert.ok(result.error.includes('Invalid workstream name'), `error should mention invalid name for: ${name}`);
});
}
});
describe('GSD_WORKSTREAM env var rejects traversal attempts', () => {
describe('MSD_WORKSTREAM env var rejects traversal attempts', () => {
for (const name of maliciousNames) {
test(`rejects GSD_WORKSTREAM=${name}`, () => {
const result = runGsdTools(['workstream', 'list', '--raw'], tmpDir, { GSD_WORKSTREAM: name });
assert.ok(!result.success, `should reject GSD_WORKSTREAM=${name}`);
test(`rejects MSD_WORKSTREAM=${name}`, () => {
const result = runMsdTools(['workstream', 'list', '--raw'], tmpDir, { MSD_WORKSTREAM: name });
assert.ok(!result.success, `should reject MSD_WORKSTREAM=${name}`);
assert.ok(result.error.includes('Invalid workstream name'), `error should mention invalid name for: ${name}`);
});
}
@@ -1020,7 +1020,7 @@ describe('path traversal rejection', () => {
describe('cmdWorkstreamSet rejects traversal attempts', () => {
for (const name of maliciousNames) {
test(`rejects set ${name}`, () => {
const result = runGsdTools(['workstream', 'set', name, '--raw'], tmpDir);
const result = runMsdTools(['workstream', 'set', name, '--raw'], tmpDir);
// cmdWorkstreamSet validates the positional arg and returns invalid_name error
assert.ok(result.success, `command should exit cleanly for: ${name}`);
const data = JSON.parse(result.output);
@@ -1033,7 +1033,7 @@ describe('path traversal rejection', () => {
describe('cmdWorkstreamStatus rejects invalid names consistently', () => {
for (const name of maliciousNames) {
test(`rejects status ${name}`, () => {
const result = runGsdTools(['workstream', 'status', name, '--raw'], tmpDir);
const result = runMsdTools(['workstream', 'status', name, '--raw'], tmpDir);
assert.ok(!result.success, `status should reject invalid name: ${name}`);
assert.ok(result.error.includes('Invalid workstream name'), `error should mention invalid name for: ${name}`);
});
@@ -1043,7 +1043,7 @@ describe('path traversal rejection', () => {
describe('cmdWorkstreamComplete rejects invalid names consistently', () => {
for (const name of maliciousNames) {
test(`rejects complete ${name}`, () => {
const result = runGsdTools(['workstream', 'complete', name, '--raw'], tmpDir);
const result = runMsdTools(['workstream', 'complete', name, '--raw'], tmpDir);
assert.ok(!result.success, `complete should reject invalid name: ${name}`);
assert.ok(result.error.includes('Invalid workstream name'), `error should mention invalid name for: ${name}`);
});
@@ -1055,7 +1055,7 @@ describe('path traversal rejection', () => {
test(`rejects poisoned file containing ${name}`, () => {
// Write malicious name directly to the active-workstream file
fs.writeFileSync(path.join(tmpDir, '.planning', 'active-workstream'), name + '\n');
const result = runGsdTools(['workstream', 'get'], tmpDir, { GSD_WORKSTREAM: '' });
const result = runMsdTools(['workstream', 'get'], tmpDir, { MSD_WORKSTREAM: '' });
assert.ok(result.success, 'get should succeed');
const data = JSON.parse(result.output);
// getActiveWorkstream should return null for invalid names
@@ -1070,7 +1070,7 @@ describe('path traversal rejection', () => {
});
describe('setActiveWorkstream rejects invalid names directly', () => {
const { setActiveWorkstream } = require('../gsd-core/bin/lib/planning-workspace.cjs');
const { setActiveWorkstream } = require('../msd-core/bin/lib/planning-workspace.cjs');
for (const name of maliciousNames) {
test(`throws for ${name}`, () => {
assert.throws(
@@ -1119,7 +1119,7 @@ describe('#2562 — a refused shipped marker reaches every workstream command',
after(() => cleanup(tmpDir));
test('workstream progress projects the refusal beside the percentage', () => {
const result = runGsdTools(['workstream', 'progress', '--raw'], tmpDir);
const result = runMsdTools(['workstream', 'progress', '--raw'], tmpDir);
assert.ok(result.success, `progress failed: ${result.error}`);
const ws = JSON.parse(result.output).workstreams.find(w => w.name === 'dirty-archive');
assert.ok(ws, 'workstream missing from progress output');
@@ -1129,7 +1129,7 @@ describe('#2562 — a refused shipped marker reaches every workstream command',
});
test('workstream status projects the refusal', () => {
const result = runGsdTools(['workstream', 'status', 'dirty-archive', '--raw'], tmpDir);
const result = runMsdTools(['workstream', 'status', 'dirty-archive', '--raw'], tmpDir);
assert.ok(result.success, `status failed: ${result.error}`);
const data = JSON.parse(result.output);
assert.strictEqual(data.found, true);
@@ -1137,7 +1137,7 @@ describe('#2562 — a refused shipped marker reaches every workstream command',
});
test('workstream list projects the refusal', () => {
const result = runGsdTools(['workstream', 'list', '--raw'], tmpDir);
const result = runMsdTools(['workstream', 'list', '--raw'], tmpDir);
assert.ok(result.success, `list failed: ${result.error}`);
const ws = JSON.parse(result.output).workstreams.find(w => w.name === 'dirty-archive');
assert.ok(ws, 'workstream missing from list output');
@@ -1160,7 +1160,7 @@ describe('#2562 — a refused shipped marker reaches every workstream command',
fs.mkdirSync(path.join(wsDir, 'milestones'), { recursive: true });
fs.writeFileSync(path.join(wsDir, 'milestones', 'v2.0-ROADMAP.md'), '# v2.0 archived\n');
const result = runGsdTools(['workstream', 'progress', '--raw'], isolatedDir);
const result = runMsdTools(['workstream', 'progress', '--raw'], isolatedDir);
assert.ok(result.success, `progress failed: ${result.error}`);
const ws = JSON.parse(result.output).workstreams.find(w => w.name === 'clean-archive');
assert.ok(ws, 'workstream missing from progress output');