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:
@@ -4,10 +4,10 @@
|
||||
// Per CONTRIBUTING.md exception matrix.
|
||||
|
||||
/**
|
||||
* GSD Tools Tests - frontmatter CLI integration
|
||||
* MSD Tools Tests - frontmatter CLI integration
|
||||
*
|
||||
* Integration tests for the 4 frontmatter subcommands (get, set, merge, validate)
|
||||
* exercised through gsd-tools.cjs via execSync.
|
||||
* exercised through msd-tools.cjs via execSync.
|
||||
*
|
||||
* Each test creates its own temp file, runs the CLI command, asserts output,
|
||||
* and cleans up in afterEach (per-test cleanup with individual temp files).
|
||||
@@ -21,13 +21,13 @@ const os = require('os');
|
||||
const { runNode } = require('./helpers/process-seam.cjs');
|
||||
const { toLegacyResult } = require('./helpers/git-fixture.cjs');
|
||||
const { PROBE_TIMEOUT_MS } = require('./helpers/timeouts.cjs');
|
||||
const { runGsdTools, parseFrontmatter } = require('./helpers.cjs');
|
||||
const { runMsdTools, parseFrontmatter } = require('./helpers.cjs');
|
||||
|
||||
// Track temp files for cleanup
|
||||
let tempFiles = [];
|
||||
|
||||
function writeTempFile(content) {
|
||||
const tmpFile = path.join(os.tmpdir(), `gsd-fm-test-${Date.now()}-${Math.random().toString(36).slice(2)}.md`);
|
||||
const tmpFile = path.join(os.tmpdir(), `msd-fm-test-${Date.now()}-${Math.random().toString(36).slice(2)}.md`);
|
||||
fs.writeFileSync(tmpFile, content, 'utf-8');
|
||||
tempFiles.push(tmpFile);
|
||||
return tmpFile;
|
||||
@@ -45,7 +45,7 @@ afterEach(() => {
|
||||
describe('frontmatter get', () => {
|
||||
test('returns all fields as JSON', () => {
|
||||
const file = writeTempFile('---\nphase: 01\nplan: 01\ntype: execute\n---\nbody text');
|
||||
const result = runGsdTools(['frontmatter', 'get', file]);
|
||||
const result = runMsdTools(['frontmatter', 'get', file]);
|
||||
assert.ok(result.success, `Command failed: ${result.error}`);
|
||||
const parsed = JSON.parse(result.output);
|
||||
assert.strictEqual(parsed.phase, '01');
|
||||
@@ -55,7 +55,7 @@ describe('frontmatter get', () => {
|
||||
|
||||
test('returns specific field with --field', () => {
|
||||
const file = writeTempFile('---\nphase: 01\nplan: 02\ntype: tdd\n---\nbody');
|
||||
const result = runGsdTools(['frontmatter', 'get', file, '--field', 'phase']);
|
||||
const result = runMsdTools(['frontmatter', 'get', file, '--field', 'phase']);
|
||||
assert.ok(result.success, `Command failed: ${result.error}`);
|
||||
const parsed = JSON.parse(result.output);
|
||||
assert.strictEqual(parsed.phase, '01');
|
||||
@@ -63,7 +63,7 @@ describe('frontmatter get', () => {
|
||||
|
||||
test('returns error for missing field', () => {
|
||||
const file = writeTempFile('---\nphase: 01\n---\n');
|
||||
const result = runGsdTools(['frontmatter', 'get', file, '--field', 'nonexistent']);
|
||||
const result = runMsdTools(['frontmatter', 'get', file, '--field', 'nonexistent']);
|
||||
// The command succeeds (exit 0) but returns an error object in JSON
|
||||
assert.ok(result.success, 'Command should exit 0');
|
||||
const parsed = JSON.parse(result.output);
|
||||
@@ -72,7 +72,7 @@ describe('frontmatter get', () => {
|
||||
});
|
||||
|
||||
test('returns error for missing file', () => {
|
||||
const result = runGsdTools('frontmatter get /nonexistent/path/file.md');
|
||||
const result = runMsdTools('frontmatter get /nonexistent/path/file.md');
|
||||
assert.ok(result.success, 'Command should exit 0 with error JSON');
|
||||
const parsed = JSON.parse(result.output);
|
||||
assert.ok(parsed.error, 'Should have error field');
|
||||
@@ -80,7 +80,7 @@ describe('frontmatter get', () => {
|
||||
|
||||
test('handles file with no frontmatter', () => {
|
||||
const file = writeTempFile('Plain text with no frontmatter delimiters.');
|
||||
const result = runGsdTools(['frontmatter', 'get', file]);
|
||||
const result = runMsdTools(['frontmatter', 'get', file]);
|
||||
assert.ok(result.success, `Command failed: ${result.error}`);
|
||||
const parsed = JSON.parse(result.output);
|
||||
assert.deepStrictEqual(parsed, {}, 'Should return empty object for no frontmatter');
|
||||
@@ -92,41 +92,41 @@ describe('frontmatter get', () => {
|
||||
describe('frontmatter set', () => {
|
||||
test('updates existing field', () => {
|
||||
const file = writeTempFile('---\nphase: 01\ntype: execute\n---\nbody');
|
||||
const result = runGsdTools(['frontmatter', 'set', file, '--field', 'phase', '--value', '02']);
|
||||
const result = runMsdTools(['frontmatter', 'set', file, '--field', 'phase', '--value', '02']);
|
||||
assert.ok(result.success, `Command failed: ${result.error}`);
|
||||
|
||||
// Read back and verify
|
||||
const content = fs.readFileSync(file, 'utf-8');
|
||||
const { extractFrontmatter } = require('../gsd-core/bin/lib/frontmatter.cjs');
|
||||
const { extractFrontmatter } = require('../msd-core/bin/lib/frontmatter.cjs');
|
||||
const fm = extractFrontmatter(content);
|
||||
assert.strictEqual(fm.phase, '02');
|
||||
});
|
||||
|
||||
test('adds new field', () => {
|
||||
const file = writeTempFile('---\nphase: 01\n---\nbody');
|
||||
const result = runGsdTools(['frontmatter', 'set', file, '--field', 'status', '--value', 'active']);
|
||||
const result = runMsdTools(['frontmatter', 'set', file, '--field', 'status', '--value', 'active']);
|
||||
assert.ok(result.success, `Command failed: ${result.error}`);
|
||||
|
||||
const content = fs.readFileSync(file, 'utf-8');
|
||||
const { extractFrontmatter } = require('../gsd-core/bin/lib/frontmatter.cjs');
|
||||
const { extractFrontmatter } = require('../msd-core/bin/lib/frontmatter.cjs');
|
||||
const fm = extractFrontmatter(content);
|
||||
assert.strictEqual(fm.status, 'active');
|
||||
});
|
||||
|
||||
test('handles JSON array value', () => {
|
||||
const file = writeTempFile('---\nphase: 01\n---\nbody');
|
||||
const result = runGsdTools(['frontmatter', 'set', file, '--field', 'tags', '--value', '["a","b"]']);
|
||||
const result = runMsdTools(['frontmatter', 'set', file, '--field', 'tags', '--value', '["a","b"]']);
|
||||
assert.ok(result.success, `Command failed: ${result.error}`);
|
||||
|
||||
const content = fs.readFileSync(file, 'utf-8');
|
||||
const { extractFrontmatter } = require('../gsd-core/bin/lib/frontmatter.cjs');
|
||||
const { extractFrontmatter } = require('../msd-core/bin/lib/frontmatter.cjs');
|
||||
const fm = extractFrontmatter(content);
|
||||
assert.ok(Array.isArray(fm.tags), 'tags should be an array');
|
||||
assert.deepStrictEqual(fm.tags, ['a', 'b']);
|
||||
});
|
||||
|
||||
test('returns error for missing file', () => {
|
||||
const result = runGsdTools('frontmatter set /nonexistent/file.md --field phase --value "01"');
|
||||
const result = runMsdTools('frontmatter set /nonexistent/file.md --field phase --value "01"');
|
||||
assert.ok(result.success, 'Command should exit 0 with error JSON');
|
||||
const parsed = JSON.parse(result.output);
|
||||
assert.ok(parsed.error, 'Should have error field');
|
||||
@@ -135,7 +135,7 @@ describe('frontmatter set', () => {
|
||||
test('preserves body content after set', () => {
|
||||
const bodyText = '\n\n# My Heading\n\nSome paragraph with special chars: $, %, &.';
|
||||
const file = writeTempFile('---\nphase: 01\n---' + bodyText);
|
||||
runGsdTools(['frontmatter', 'set', file, '--field', 'phase', '--value', '02']);
|
||||
runMsdTools(['frontmatter', 'set', file, '--field', 'phase', '--value', '02']);
|
||||
|
||||
const content = fs.readFileSync(file, 'utf-8');
|
||||
assert.ok(content.includes('# My Heading'), 'heading should be preserved');
|
||||
@@ -148,11 +148,11 @@ describe('frontmatter set', () => {
|
||||
describe('frontmatter merge', () => {
|
||||
test('merges multiple fields into frontmatter', () => {
|
||||
const file = writeTempFile('---\nphase: 01\n---\nbody');
|
||||
const result = runGsdTools(['frontmatter', 'merge', file, '--data', '{"plan":"02","type":"tdd"}']);
|
||||
const result = runMsdTools(['frontmatter', 'merge', file, '--data', '{"plan":"02","type":"tdd"}']);
|
||||
assert.ok(result.success, `Command failed: ${result.error}`);
|
||||
|
||||
const content = fs.readFileSync(file, 'utf-8');
|
||||
const { extractFrontmatter } = require('../gsd-core/bin/lib/frontmatter.cjs');
|
||||
const { extractFrontmatter } = require('../msd-core/bin/lib/frontmatter.cjs');
|
||||
const fm = extractFrontmatter(content);
|
||||
assert.strictEqual(fm.phase, '01', 'original field should be preserved');
|
||||
assert.strictEqual(fm.plan, '02', 'merged field should be present');
|
||||
@@ -161,18 +161,18 @@ describe('frontmatter merge', () => {
|
||||
|
||||
test('overwrites existing fields on conflict', () => {
|
||||
const file = writeTempFile('---\nphase: 01\ntype: execute\n---\nbody');
|
||||
const result = runGsdTools(['frontmatter', 'merge', file, '--data', '{"phase":"02"}']);
|
||||
const result = runMsdTools(['frontmatter', 'merge', file, '--data', '{"phase":"02"}']);
|
||||
assert.ok(result.success, `Command failed: ${result.error}`);
|
||||
|
||||
const content = fs.readFileSync(file, 'utf-8');
|
||||
const { extractFrontmatter } = require('../gsd-core/bin/lib/frontmatter.cjs');
|
||||
const { extractFrontmatter } = require('../msd-core/bin/lib/frontmatter.cjs');
|
||||
const fm = extractFrontmatter(content);
|
||||
assert.strictEqual(fm.phase, '02', 'conflicting field should be overwritten');
|
||||
assert.strictEqual(fm.type, 'execute', 'non-conflicting field should be preserved');
|
||||
});
|
||||
|
||||
test('returns error for missing file', () => {
|
||||
const result = runGsdTools(`frontmatter merge /nonexistent/file.md --data '{"phase":"01"}'`);
|
||||
const result = runMsdTools(`frontmatter merge /nonexistent/file.md --data '{"phase":"01"}'`);
|
||||
assert.ok(result.success, 'Command should exit 0 with error JSON');
|
||||
const parsed = JSON.parse(result.output);
|
||||
assert.ok(parsed.error, 'Should have error field');
|
||||
@@ -180,7 +180,7 @@ describe('frontmatter merge', () => {
|
||||
|
||||
test('returns error for invalid JSON data', () => {
|
||||
const file = writeTempFile('---\nphase: 01\n---\nbody');
|
||||
const result = runGsdTools(['frontmatter', 'merge', file, '--data', 'not json']);
|
||||
const result = runMsdTools(['frontmatter', 'merge', file, '--data', 'not json']);
|
||||
// cmdFrontmatterMerge calls error() which exits with code 1
|
||||
assert.ok(!result.success, 'Command should fail with non-zero exit code');
|
||||
assert.ok(result.error.includes('Invalid JSON'), 'Error should mention invalid JSON');
|
||||
@@ -205,7 +205,7 @@ must_haves:
|
||||
---
|
||||
body`;
|
||||
const file = writeTempFile(content);
|
||||
const result = runGsdTools(['frontmatter', 'validate', file, '--schema', 'plan']);
|
||||
const result = runMsdTools(['frontmatter', 'validate', file, '--schema', 'plan']);
|
||||
assert.ok(result.success, `Command failed: ${result.error}`);
|
||||
const parsed = JSON.parse(result.output);
|
||||
assert.strictEqual(parsed.valid, true, 'Should be valid');
|
||||
@@ -215,7 +215,7 @@ body`;
|
||||
|
||||
test('reports invalid with missing fields', () => {
|
||||
const file = writeTempFile('---\nphase: 01\n---\nbody');
|
||||
const result = runGsdTools(['frontmatter', 'validate', file, '--schema', 'plan']);
|
||||
const result = runMsdTools(['frontmatter', 'validate', file, '--schema', 'plan']);
|
||||
assert.ok(result.success, `Command failed: ${result.error}`);
|
||||
const parsed = JSON.parse(result.output);
|
||||
assert.strictEqual(parsed.valid, false, 'Should be invalid');
|
||||
@@ -239,7 +239,7 @@ completed: 2026-02-25
|
||||
---
|
||||
body`;
|
||||
const file = writeTempFile(content);
|
||||
const result = runGsdTools(['frontmatter', 'validate', file, '--schema', 'summary']);
|
||||
const result = runMsdTools(['frontmatter', 'validate', file, '--schema', 'summary']);
|
||||
assert.ok(result.success, `Command failed: ${result.error}`);
|
||||
const parsed = JSON.parse(result.output);
|
||||
assert.strictEqual(parsed.valid, true, 'Should be valid for summary schema');
|
||||
@@ -255,7 +255,7 @@ score: 5/5
|
||||
---
|
||||
body`;
|
||||
const file = writeTempFile(content);
|
||||
const result = runGsdTools(['frontmatter', 'validate', file, '--schema', 'verification']);
|
||||
const result = runMsdTools(['frontmatter', 'validate', file, '--schema', 'verification']);
|
||||
assert.ok(result.success, `Command failed: ${result.error}`);
|
||||
const parsed = JSON.parse(result.output);
|
||||
assert.strictEqual(parsed.valid, true, 'Should be valid for verification schema');
|
||||
@@ -264,7 +264,7 @@ body`;
|
||||
|
||||
test('returns error for unknown schema', () => {
|
||||
const file = writeTempFile('---\nphase: 01\n---\n');
|
||||
const result = runGsdTools(['frontmatter', 'validate', file, '--schema', 'unknown']);
|
||||
const result = runMsdTools(['frontmatter', 'validate', file, '--schema', 'unknown']);
|
||||
// cmdFrontmatterValidate calls error() which exits with code 1
|
||||
assert.ok(!result.success, 'Command should fail with non-zero exit code');
|
||||
assert.ok(result.error.includes('Unknown schema'), 'Error should mention unknown schema');
|
||||
@@ -275,12 +275,12 @@ body`;
|
||||
// `!schema` guard never fires and the command crashes with an uncaught TypeError
|
||||
// ("Cannot read properties of undefined (reading 'filter')") and a stack trace
|
||||
// instead of reporting "Unknown schema". Now that --schema is an agent-bound
|
||||
// variable ($SCHEMA in agents/gsd-planner.md's validate_plan step) rather than a
|
||||
// variable ($SCHEMA in agents/msd-planner.md's validate_plan step) rather than a
|
||||
// fixed literal, this is reachable from prompt state.
|
||||
for (const schemaName of ['__proto__', 'constructor', 'toString', 'hasOwnProperty', 'valueOf']) {
|
||||
test(`--schema ${schemaName} reports Unknown schema, not a crash`, () => {
|
||||
const file = writeTempFile('---\nphase: 01\n---\n');
|
||||
const result = runGsdTools(['frontmatter', 'validate', file, '--schema', schemaName]);
|
||||
const result = runMsdTools(['frontmatter', 'validate', file, '--schema', schemaName]);
|
||||
assert.ok(!result.success, `--schema ${schemaName} should fail with a non-zero exit code, not crash`);
|
||||
assert.ok(
|
||||
result.error.includes('Unknown schema'),
|
||||
@@ -294,7 +294,7 @@ body`;
|
||||
}
|
||||
|
||||
test('returns error for missing file', () => {
|
||||
const result = runGsdTools('frontmatter validate /nonexistent/file.md --schema plan');
|
||||
const result = runMsdTools('frontmatter validate /nonexistent/file.md --schema plan');
|
||||
assert.ok(result.success, 'Command should exit 0 with error JSON');
|
||||
const parsed = JSON.parse(result.output);
|
||||
assert.ok(parsed.error, 'Should have error field');
|
||||
@@ -329,7 +329,7 @@ body`;
|
||||
// Row 1 — failing-first regression test.
|
||||
test('rejects plan-gap-closure frontmatter missing gap_closure (#2847)', () => {
|
||||
const file = writeTempFile(PLAN_BODY_NO_GAP_CLOSURE);
|
||||
const result = runGsdTools(['frontmatter', 'validate', file, '--schema', 'plan-gap-closure']);
|
||||
const result = runMsdTools(['frontmatter', 'validate', file, '--schema', 'plan-gap-closure']);
|
||||
assert.ok(result.success, `Command failed: ${result.error}`);
|
||||
const parsed = JSON.parse(result.output);
|
||||
assert.strictEqual(parsed.valid, false, 'Should be invalid: gap_closure is missing');
|
||||
@@ -356,7 +356,7 @@ gap_closure: true
|
||||
---
|
||||
body`;
|
||||
const file = writeTempFile(content);
|
||||
const result = runGsdTools(['frontmatter', 'validate', file, '--schema', 'plan-gap-closure']);
|
||||
const result = runMsdTools(['frontmatter', 'validate', file, '--schema', 'plan-gap-closure']);
|
||||
assert.ok(result.success, `Command failed: ${result.error}`);
|
||||
const parsed = JSON.parse(result.output);
|
||||
assert.strictEqual(parsed.valid, true, 'Should be valid: gap_closure is present');
|
||||
@@ -369,7 +369,7 @@ body`;
|
||||
// Row 3 — empty/near-empty input boundary.
|
||||
test('reports all plan-gap-closure fields missing except phase for near-empty frontmatter', () => {
|
||||
const file = writeTempFile('---\nphase: 01\n---\nbody');
|
||||
const result = runGsdTools(['frontmatter', 'validate', file, '--schema', 'plan-gap-closure']);
|
||||
const result = runMsdTools(['frontmatter', 'validate', file, '--schema', 'plan-gap-closure']);
|
||||
assert.ok(result.success, `Command failed: ${result.error}`);
|
||||
const parsed = JSON.parse(result.output);
|
||||
assert.strictEqual(parsed.valid, false);
|
||||
@@ -381,7 +381,7 @@ body`;
|
||||
// Row 4 — negative space: standard-mode ('plan' schema) plans are unaffected by #2847's fix.
|
||||
test('plan schema (standard/reviews mode) still reports valid without gap_closure — unaffected by #2847 fix', () => {
|
||||
const file = writeTempFile(PLAN_BODY_NO_GAP_CLOSURE);
|
||||
const result = runGsdTools(['frontmatter', 'validate', file, '--schema', 'plan']);
|
||||
const result = runMsdTools(['frontmatter', 'validate', file, '--schema', 'plan']);
|
||||
assert.ok(result.success, `Command failed: ${result.error}`);
|
||||
const parsed = JSON.parse(result.output);
|
||||
assert.strictEqual(parsed.valid, true, 'plan schema must not require gap_closure (AC(3): standard mode unaffected)');
|
||||
@@ -408,7 +408,7 @@ body`;
|
||||
'body',
|
||||
].join('\r\n');
|
||||
const file = writeTempFile(content);
|
||||
const result = runGsdTools(['frontmatter', 'validate', file, '--schema', 'plan-gap-closure']);
|
||||
const result = runMsdTools(['frontmatter', 'validate', file, '--schema', 'plan-gap-closure']);
|
||||
assert.ok(result.success, `Command failed: ${result.error}`);
|
||||
const parsed = JSON.parse(result.output);
|
||||
assert.strictEqual(parsed.valid, true, 'CRLF frontmatter must parse identically to LF for plan-gap-closure');
|
||||
@@ -440,7 +440,7 @@ gap_closure: false
|
||||
---
|
||||
body`;
|
||||
const file = writeTempFile(content);
|
||||
const result = runGsdTools(['frontmatter', 'validate', file, '--schema', 'plan-gap-closure']);
|
||||
const result = runMsdTools(['frontmatter', 'validate', file, '--schema', 'plan-gap-closure']);
|
||||
assert.ok(result.success, `Command failed: ${result.error}`);
|
||||
const parsed = JSON.parse(result.output);
|
||||
assert.strictEqual(parsed.valid, false, 'gap_closure: false must NOT satisfy plan-gap-closure');
|
||||
@@ -460,11 +460,11 @@ body`;
|
||||
// implied by Rows 1/2/6 individually).
|
||||
test('invalidValue distinguishes "present but wrong value" from "absent" for the same missing-reporting field', () => {
|
||||
const absentResult = JSON.parse(
|
||||
runGsdTools(['frontmatter', 'validate', writeTempFile(PLAN_BODY_NO_GAP_CLOSURE), '--schema', 'plan-gap-closure']).output
|
||||
runMsdTools(['frontmatter', 'validate', writeTempFile(PLAN_BODY_NO_GAP_CLOSURE), '--schema', 'plan-gap-closure']).output
|
||||
);
|
||||
const wrongValueContent = PLAN_BODY_NO_GAP_CLOSURE.replace('---\nbody', 'gap_closure: TRUE\n---\nbody');
|
||||
const wrongValueResult = JSON.parse(
|
||||
runGsdTools(['frontmatter', 'validate', writeTempFile(wrongValueContent), '--schema', 'plan-gap-closure']).output
|
||||
runMsdTools(['frontmatter', 'validate', writeTempFile(wrongValueContent), '--schema', 'plan-gap-closure']).output
|
||||
);
|
||||
|
||||
// Both report gap_closure as missing (the field does not satisfy the schema either way)...
|
||||
@@ -485,7 +485,7 @@ body`;
|
||||
// object-list items ({path, provides} maps) to scalar strings and re-emits them as a
|
||||
// malformed inline array — destroying `provides:` whenever an UNRELATED field changed.
|
||||
// The fix preserves the original raw text for any structurally-unchanged top-level key.
|
||||
const { parseMustHavesBlock } = require('../gsd-core/bin/lib/frontmatter.cjs');
|
||||
const { parseMustHavesBlock } = require('../msd-core/bin/lib/frontmatter.cjs');
|
||||
|
||||
describe('frontmatter set/merge preserves must_haves object-lists (#1572)', () => {
|
||||
const ARTIFACTS_PLAN = [
|
||||
@@ -525,7 +525,7 @@ describe('frontmatter set/merge preserves must_haves object-lists (#1572)', () =
|
||||
|
||||
function runAndParse(plan, cmdArgsForFile) {
|
||||
const file = writeTempFile(plan);
|
||||
runGsdTools(cmdArgsForFile(file));
|
||||
runMsdTools(cmdArgsForFile(file));
|
||||
const after = fs.readFileSync(file, 'utf-8');
|
||||
return after;
|
||||
}
|
||||
@@ -568,8 +568,8 @@ describe('frontmatter set/merge preserves must_haves object-lists (#1572)', () =
|
||||
|
||||
test('round-trip is stable: setting wave twice still preserves artifacts (per-key preservation is idempotent)', () => {
|
||||
const file = writeTempFile(ARTIFACTS_PLAN);
|
||||
runGsdTools(['frontmatter', 'set', file, '--field', 'wave', '--value', '2']);
|
||||
runGsdTools(['frontmatter', 'set', file, '--field', 'wave', '--value', '3']);
|
||||
runMsdTools(['frontmatter', 'set', file, '--field', 'wave', '--value', '2']);
|
||||
runMsdTools(['frontmatter', 'set', file, '--field', 'wave', '--value', '3']);
|
||||
const after = fs.readFileSync(file, 'utf-8');
|
||||
assert.deepEqual(
|
||||
parseMustHavesBlock(after, 'artifacts'),
|
||||
@@ -586,7 +586,7 @@ describe('frontmatter set/merge preserves must_haves object-lists (#1572)', () =
|
||||
// lossy writer (it would emit "[object Object]"). Rather than silently destroy the
|
||||
// data, spliceFrontmatter throws — the command fails and the file is left unchanged.
|
||||
const file = writeTempFile(ARTIFACTS_PLAN);
|
||||
const result = runGsdTools([
|
||||
const result = runMsdTools([
|
||||
'frontmatter', 'set', file, '--field', 'must_haves',
|
||||
'--value', JSON.stringify({ artifacts: [{ path: 'src/new.ts', provides: 'new thing' }] }),
|
||||
]);
|
||||
@@ -622,7 +622,7 @@ describe('Bug #1660: frontmatter set of an object-list field fails closed instea
|
||||
const before = fs.readFileSync(file, 'utf-8');
|
||||
// New value {artifacts:["path: src/foo.ts"]} — its extractFrontmatter projection equals
|
||||
// the original's flattened projection, so the set would otherwise be a silent no-op.
|
||||
const result = runGsdTools(['frontmatter', 'set', file, '--field', 'must_haves', '--value', JSON.stringify({ artifacts: ['path: src/foo.ts'] })]);
|
||||
const result = runMsdTools(['frontmatter', 'set', file, '--field', 'must_haves', '--value', JSON.stringify({ artifacts: ['path: src/foo.ts'] })]);
|
||||
const parsed = JSON.parse(result.output);
|
||||
assert.ok(parsed.error, 'a no-op set of an object-list field must surface an error, not silent {updated:true}');
|
||||
const after = fs.readFileSync(file, 'utf-8');
|
||||
@@ -631,7 +631,7 @@ describe('Bug #1660: frontmatter set of an object-list field fails closed instea
|
||||
|
||||
test('an idempotent set of a scalar (wave, same value) still reports updated (no false positive)', () => {
|
||||
const file = writeTempFile('---\nphase: 1\nwave: 1\n---\n# body\n');
|
||||
const result = runGsdTools(['frontmatter', 'set', file, '--field', 'wave', '--value', '1']);
|
||||
const result = runMsdTools(['frontmatter', 'set', file, '--field', 'wave', '--value', '1']);
|
||||
const parsed = JSON.parse(result.output);
|
||||
assert.equal(parsed.updated, true, 'an idempotent SCALAR set must still report {updated:true} (not fail-closed)');
|
||||
assert.ok(!parsed.error, 'an idempotent scalar set must not produce an error');
|
||||
@@ -639,7 +639,7 @@ describe('Bug #1660: frontmatter set of an object-list field fails closed instea
|
||||
|
||||
test('an idempotent set of a scalar array (tags, same value) still reports updated (no false positive)', () => {
|
||||
const file = writeTempFile('---\nphase: 1\ntags: ["a","b"]\n---\n# body\n');
|
||||
const result = runGsdTools(['frontmatter', 'set', file, '--field', 'tags', '--value', '["a","b"]']);
|
||||
const result = runMsdTools(['frontmatter', 'set', file, '--field', 'tags', '--value', '["a","b"]']);
|
||||
const parsed = JSON.parse(result.output);
|
||||
assert.equal(parsed.updated, true, 'an idempotent scalar-ARRAY set must still report {updated:true} (arrays round-trip; not fail-closed)');
|
||||
assert.ok(!parsed.error, 'an idempotent scalar-array set must not produce an error');
|
||||
@@ -650,7 +650,7 @@ describe('Bug #1660: frontmatter set of an object-list field fails closed instea
|
||||
//
|
||||
// The thread workflow's CLOSE and RESUME branches previously invoked the
|
||||
// pre-1.6 positional shape (frontmatter.set <file> <field> <value>). Since 1.6
|
||||
// the dispatcher (gsd-tools.cjs) reads field/value from the named --field/
|
||||
// the dispatcher (msd-tools.cjs) reads field/value from the named --field/
|
||||
// --value flags via parseNamedArgs; the positional form leaves field/value
|
||||
// undefined, cmdFrontmatterSet errors `file, field, and value required`, and
|
||||
// the status/updated writes are silently skipped — so closing a thread never
|
||||
@@ -659,7 +659,7 @@ describe('#1778: thread workflow uses the 1.6 named-flag frontmatter.set form',
|
||||
test('behavioral: named-flag form writes the field; positional form errors and does not mutate', () => {
|
||||
// 1.6 named-flag form — must succeed and write status: resolved.
|
||||
const goodFile = writeTempFile('---\nstatus: open\nupdated: "2025-01-01"\n---\n\n# thread body\n');
|
||||
const good = runGsdTools(['frontmatter', 'set', goodFile, '--field', 'status', '--value', 'resolved']);
|
||||
const good = runMsdTools(['frontmatter', 'set', goodFile, '--field', 'status', '--value', 'resolved']);
|
||||
assert.ok(good.success, `named-flag form must succeed; stderr: ${good.error}`);
|
||||
assert.strictEqual(
|
||||
parseFrontmatter(fs.readFileSync(goodFile, 'utf-8')).status,
|
||||
@@ -677,7 +677,7 @@ describe('#1778: thread workflow uses the 1.6 named-flag frontmatter.set form',
|
||||
// rejection now happens earlier, at argv-parsing time, not deep inside
|
||||
// the command).
|
||||
const badFile = writeTempFile('---\nstatus: open\nupdated: "2025-01-01"\n---\n\n# thread body\n');
|
||||
const bad = runGsdTools(['frontmatter', 'set', badFile, 'status', 'resolved']);
|
||||
const bad = runMsdTools(['frontmatter', 'set', badFile, 'status', 'resolved']);
|
||||
assert.ok(!bad.success, 'positional form must fail (it is the bug being guarded against)');
|
||||
assert.ok(
|
||||
(bad.error + bad.output).includes('unexpected positional argument'),
|
||||
@@ -690,10 +690,10 @@ describe('#1778: thread workflow uses the 1.6 named-flag frontmatter.set form',
|
||||
);
|
||||
});
|
||||
|
||||
test('workflow parity: no gsd-core/workflows/*.md emits the positional frontmatter.set form', () => {
|
||||
const workflowsDir = path.join(__dirname, '..', 'gsd-core', 'workflows');
|
||||
test('workflow parity: no msd-core/workflows/*.md emits the positional frontmatter.set form', () => {
|
||||
const workflowsDir = path.join(__dirname, '..', 'msd-core', 'workflows');
|
||||
const files = fs.readdirSync(workflowsDir).filter((f) => f.endsWith('.md'));
|
||||
assert.ok(files.length > 0, 'expected at least one workflow under gsd-core/workflows/');
|
||||
assert.ok(files.length > 0, 'expected at least one workflow under msd-core/workflows/');
|
||||
|
||||
const offenders = [];
|
||||
for (const name of files) {
|
||||
@@ -701,7 +701,7 @@ describe('#1778: thread workflow uses the 1.6 named-flag frontmatter.set form',
|
||||
const lines = fs.readFileSync(full, 'utf-8').split(/\r?\n/);
|
||||
lines.forEach((line, i) => {
|
||||
// Match any frontmatter.set invocation (dot or space form, with or
|
||||
// without the `gsd_run query` prefix). The 1.6 contract requires
|
||||
// without the `msd_run query` prefix). The 1.6 contract requires
|
||||
// --field AND --value on every set call; a set line missing --field
|
||||
// is the pre-1.6 positional form (#1778).
|
||||
if (!/frontmatter[.\s]+set\b/.test(line)) return;
|
||||
@@ -714,12 +714,12 @@ describe('#1778: thread workflow uses the 1.6 named-flag frontmatter.set form',
|
||||
assert.deepStrictEqual(
|
||||
offenders,
|
||||
[],
|
||||
`These workflow frontmatter.set invocations are missing the 1.6 --field/--value named flags (the #1778 positional-form bug):\n ${offenders.join('\n ')}\n\nUse: gsd_run query frontmatter.set <file> --field <field> --value <value>`,
|
||||
`These workflow frontmatter.set invocations are missing the 1.6 --field/--value named flags (the #1778 positional-form bug):\n ${offenders.join('\n ')}\n\nUse: msd_run query frontmatter.set <file> --field <field> --value <value>`,
|
||||
);
|
||||
});
|
||||
|
||||
test('thread workflow CLOSE writes status: resolved and RESUME writes status: in_progress via named flags', () => {
|
||||
const src = fs.readFileSync(path.join(__dirname, '..', 'gsd-core', 'workflows', 'thread.md'), 'utf-8');
|
||||
const src = fs.readFileSync(path.join(__dirname, '..', 'msd-core', 'workflows', 'thread.md'), 'utf-8');
|
||||
|
||||
// CLOSE mode: status resolved + updated, both via named flags.
|
||||
assert.ok(
|
||||
@@ -742,11 +742,11 @@ describe('#1778: thread workflow uses the 1.6 named-flag frontmatter.set form',
|
||||
// ─── #1882: the user-reachable surface actually distinguishes the two cases ───
|
||||
|
||||
describe('frontmatter get — truncated vs absent frontmatter (#1882)', () => {
|
||||
const TOOLS = path.join(__dirname, '..', 'gsd-core', 'bin', 'gsd-tools.cjs');
|
||||
const TOOLS = path.join(__dirname, '..', 'msd-core', 'bin', 'msd-tools.cjs');
|
||||
|
||||
function runCapturingStderr(file) {
|
||||
const r = runNode([TOOLS, 'frontmatter', 'get', file, '--raw'], {
|
||||
env: { ...process.env, GSD_TEST_MODE: '1' },
|
||||
env: { ...process.env, MSD_TEST_MODE: '1' },
|
||||
timeoutMs: PROBE_TIMEOUT_MS,
|
||||
});
|
||||
const legacy = toLegacyResult(r);
|
||||
@@ -793,7 +793,7 @@ describe('#4806 frontmatter get — unparseable frontmatter', () => {
|
||||
// read. Reporting "Field not found" tells the caller the key is absent —
|
||||
// indistinguishable from a file that genuinely lacks it.
|
||||
const file = writeTempFile('---\nstatus: "passed\n---\n\n# Verification Report\n');
|
||||
const result = runGsdTools(['frontmatter', 'get', file, '--field', 'status']);
|
||||
const result = runMsdTools(['frontmatter', 'get', file, '--field', 'status']);
|
||||
// The verb answers exit-0 JSON with an `error` FIELD (its documented
|
||||
// error shape) — the assertion is on the error text, not the exit code.
|
||||
assert.strictEqual(result.success, true, `command failed: ${result.error}`);
|
||||
@@ -807,7 +807,7 @@ describe('#4806 frontmatter get — unparseable frontmatter', () => {
|
||||
|
||||
test('a well-formed file still returns the field', () => {
|
||||
const file = writeTempFile('---\nstatus: passed\n---\n\n# V\n');
|
||||
const result = runGsdTools(['frontmatter', 'get', file, '--field', 'status']);
|
||||
const result = runMsdTools(['frontmatter', 'get', file, '--field', 'status']);
|
||||
assert.ok(result.success, `command failed: ${result.error}`);
|
||||
const parsed = JSON.parse(result.output);
|
||||
assert.strictEqual(parsed.status, 'passed');
|
||||
|
||||
Reference in New Issue
Block a user