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:
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* GSD Tools Tests - --pick flag
|
||||
* MSD Tools Tests - --pick flag
|
||||
*
|
||||
* Regression tests for the --pick CLI flag that extracts a single field
|
||||
* from JSON output, replacing the need for jq as an external dependency.
|
||||
@@ -9,7 +9,7 @@ const { test, describe } = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
const { runGsdTools, createTempProject, cleanup } = require('./helpers.cjs');
|
||||
const { runMsdTools, createTempProject, cleanup } = require('./helpers.cjs');
|
||||
const { seedPhase } = require('./fixtures/index.cjs');
|
||||
const { runCli } = require('./helpers/cli-negative.cjs');
|
||||
|
||||
@@ -17,13 +17,13 @@ const { runCli } = require('./helpers/cli-negative.cjs');
|
||||
|
||||
describe('--pick flag', () => {
|
||||
test('extracts a top-level field from JSON output', () => {
|
||||
const result = runGsdTools('generate-slug "hello world" --pick slug');
|
||||
const result = runMsdTools('generate-slug "hello world" --pick slug');
|
||||
assert.strictEqual(result.success, true);
|
||||
assert.strictEqual(result.output, 'hello-world');
|
||||
});
|
||||
|
||||
test('extracts a top-level field using array args', () => {
|
||||
const result = runGsdTools(['generate-slug', 'hello world', '--pick', 'slug']);
|
||||
const result = runMsdTools(['generate-slug', 'hello world', '--pick', 'slug']);
|
||||
assert.strictEqual(result.success, true);
|
||||
assert.strictEqual(result.output, 'hello-world');
|
||||
});
|
||||
@@ -32,11 +32,11 @@ describe('--pick flag', () => {
|
||||
// answer"), never a demotion to the empty answer at exit 0. This inverts
|
||||
// the old pinned assertion below (kept as a comment for the historical
|
||||
// record — measured on this tree, 2026-08-26, exit 0 + empty stdout):
|
||||
// const result = runGsdTools('generate-slug "test" --pick nonexistent');
|
||||
// const result = runMsdTools('generate-slug "test" --pick nonexistent');
|
||||
// assert.strictEqual(result.success, true);
|
||||
// assert.strictEqual(result.output, '');
|
||||
test('absentFieldExitsNonZero_3365', () => {
|
||||
const result = runGsdTools('generate-slug "test" --pick nonexistent');
|
||||
const result = runMsdTools('generate-slug "test" --pick nonexistent');
|
||||
assert.strictEqual(result.success, false, 'an absent --pick field must exit non-zero');
|
||||
assert.strictEqual(result.output, '');
|
||||
assert.match(result.error, /nonexistent/, 'stderr must name the requested field');
|
||||
@@ -47,7 +47,7 @@ describe('--pick flag', () => {
|
||||
test('zeroCountPrintsZeroAtExitZero', () => {
|
||||
const tmpDir = createTempProject();
|
||||
try {
|
||||
const result = runGsdTools('query phases.list --type summaries --pick count', tmpDir);
|
||||
const result = runMsdTools('query phases.list --type summaries --pick count', tmpDir);
|
||||
assert.strictEqual(result.success, true);
|
||||
assert.strictEqual(result.output, '0');
|
||||
} finally {
|
||||
@@ -62,7 +62,7 @@ describe('--pick flag', () => {
|
||||
test('presentButNullIsEmptyAtExitZero', () => {
|
||||
const tmpDir = createTempProject();
|
||||
try {
|
||||
const result = runGsdTools('query phases.list --type plans --pick phase_dir', tmpDir);
|
||||
const result = runMsdTools('query phases.list --type plans --pick phase_dir', tmpDir);
|
||||
assert.strictEqual(result.success, true);
|
||||
assert.strictEqual(result.output, '');
|
||||
} finally {
|
||||
@@ -79,14 +79,14 @@ describe('--pick flag', () => {
|
||||
seedPhase(tmpDir, '02-beta');
|
||||
seedPhase(tmpDir, '03-gamma');
|
||||
|
||||
const atLenMinus1 = runGsdTools('query phases.list --pick directories[2]', tmpDir);
|
||||
const atLenMinus1 = runMsdTools('query phases.list --pick directories[2]', tmpDir);
|
||||
assert.strictEqual(atLenMinus1.success, true);
|
||||
assert.strictEqual(atLenMinus1.output, '03-gamma');
|
||||
|
||||
const atLen = runGsdTools('query phases.list --pick directories[3]', tmpDir);
|
||||
const atLen = runMsdTools('query phases.list --pick directories[3]', tmpDir);
|
||||
assert.strictEqual(atLen.success, false, 'index == length is out of range and must exit non-zero');
|
||||
|
||||
const atLenPlus1 = runGsdTools('query phases.list --pick directories[4]', tmpDir);
|
||||
const atLenPlus1 = runMsdTools('query phases.list --pick directories[4]', tmpDir);
|
||||
assert.strictEqual(atLenPlus1.success, false, 'index == length + 1 is out of range and must exit non-zero');
|
||||
} finally {
|
||||
cleanup(tmpDir);
|
||||
@@ -96,7 +96,7 @@ describe('--pick flag', () => {
|
||||
// P12 (test matrix): the measured B11 defect — a non-JSON command's
|
||||
// `--pick` must never dump the whole document as a coincidental "success".
|
||||
// TODAY (measured on this tree, 2026-08-26), against an empty temp project:
|
||||
// $ gsd-tools audit-open --pick nonexistent_field
|
||||
// $ msd-tools audit-open --pick nonexistent_field
|
||||
// ### Milestone Close: Open Artifact Audit
|
||||
//
|
||||
// All artifact types clear. Safe to proceed.
|
||||
@@ -106,7 +106,7 @@ describe('--pick flag', () => {
|
||||
test('nonJsonOutputDoesNotDumpWholeDocument', () => {
|
||||
const tmpDir = createTempProject();
|
||||
try {
|
||||
const result = runGsdTools('audit-open --pick nonexistent_field', tmpDir);
|
||||
const result = runMsdTools('audit-open --pick nonexistent_field', tmpDir);
|
||||
assert.strictEqual(result.success, false);
|
||||
assert.strictEqual(result.output, '');
|
||||
} finally {
|
||||
@@ -118,7 +118,7 @@ describe('--pick flag', () => {
|
||||
// coincidental "success" — measured today: exit 0, stdout `hello-world`,
|
||||
// via the same non-JSON dump `--raw` produces.
|
||||
test('rawPlusPickIsRejectedNotCoincidentallyRight', () => {
|
||||
const result = runGsdTools(['generate-slug', 'Hello World', '--raw', '--pick', 'slug']);
|
||||
const result = runMsdTools(['generate-slug', 'Hello World', '--raw', '--pick', 'slug']);
|
||||
assert.strictEqual(result.success, false);
|
||||
});
|
||||
|
||||
@@ -126,7 +126,7 @@ describe('--pick flag', () => {
|
||||
// stdout `hello-world` (the SLUG field's value, not the bogus field asked
|
||||
// for), via the same non-JSON dump.
|
||||
test('rawPlusPickBogusDoesNotEmitAnotherFieldsValue', () => {
|
||||
const result = runGsdTools(['generate-slug', 'Hello World', '--raw', '--pick', 'bogus']);
|
||||
const result = runMsdTools(['generate-slug', 'Hello World', '--raw', '--pick', 'bogus']);
|
||||
assert.strictEqual(result.success, false);
|
||||
assert.ok(
|
||||
!result.output.includes('hello-world'),
|
||||
@@ -135,26 +135,26 @@ describe('--pick flag', () => {
|
||||
});
|
||||
|
||||
test('errors when --pick has no value', () => {
|
||||
const result = runGsdTools('generate-slug "test" --pick');
|
||||
const result = runMsdTools('generate-slug "test" --pick');
|
||||
assert.strictEqual(result.success, false);
|
||||
assert.match(result.error, /Missing value for --pick/);
|
||||
});
|
||||
|
||||
test('errors when --pick value starts with --', () => {
|
||||
const result = runGsdTools(['generate-slug', 'test', '--pick', '--raw']);
|
||||
const result = runMsdTools(['generate-slug', 'test', '--pick', '--raw']);
|
||||
assert.strictEqual(result.success, false);
|
||||
assert.match(result.error, /Missing value for --pick/);
|
||||
});
|
||||
|
||||
test('does not collide with frontmatter --field flag', () => {
|
||||
// frontmatter subcommand uses --field internally; --pick should not interfere
|
||||
const result = runGsdTools('generate-slug "test-value" --pick slug');
|
||||
const result = runMsdTools('generate-slug "test-value" --pick slug');
|
||||
assert.strictEqual(result.success, true);
|
||||
assert.strictEqual(result.output, 'test-value');
|
||||
});
|
||||
|
||||
test('works with current-timestamp command', () => {
|
||||
const result = runGsdTools('current-timestamp --pick timestamp');
|
||||
const result = runMsdTools('current-timestamp --pick timestamp');
|
||||
assert.strictEqual(result.success, true);
|
||||
assert.ok(result.output.length > 0, 'timestamp should not be empty');
|
||||
assert.match(result.output, /^\d{4}-\d{2}-\d{2}T/);
|
||||
@@ -205,15 +205,15 @@ describe('--pick flag', () => {
|
||||
seedPhase(tmpDir, '02-beta');
|
||||
seedPhase(tmpDir, '03-gamma');
|
||||
|
||||
const last = runGsdTools('query phases.list --pick directories[-1]', tmpDir);
|
||||
const last = runMsdTools('query phases.list --pick directories[-1]', tmpDir);
|
||||
assert.strictEqual(last.success, true);
|
||||
assert.strictEqual(last.output, '03-gamma');
|
||||
|
||||
const first = runGsdTools('query phases.list --pick directories[-3]', tmpDir);
|
||||
const first = runMsdTools('query phases.list --pick directories[-3]', tmpDir);
|
||||
assert.strictEqual(first.success, true);
|
||||
assert.strictEqual(first.output, '01-alpha');
|
||||
|
||||
const outOfRange = runGsdTools('query phases.list --pick directories[-4]', tmpDir);
|
||||
const outOfRange = runMsdTools('query phases.list --pick directories[-4]', tmpDir);
|
||||
assert.strictEqual(outOfRange.success, false, 'index == -(N+1) is out of range and must exit non-zero');
|
||||
} finally {
|
||||
cleanup(tmpDir);
|
||||
@@ -227,7 +227,7 @@ describe('--pick flag', () => {
|
||||
test('nonObjectJsonRootExitsNonZero', () => {
|
||||
const tmpDir = createTempProject();
|
||||
try {
|
||||
const plain = runGsdTools('config-get nonexistent.key --default fallback', tmpDir);
|
||||
const plain = runMsdTools('config-get nonexistent.key --default fallback', tmpDir);
|
||||
assert.strictEqual(plain.success, true);
|
||||
assert.strictEqual(plain.output, '"fallback"');
|
||||
|
||||
@@ -267,7 +267,7 @@ describe('--pick flag', () => {
|
||||
made++;
|
||||
}
|
||||
|
||||
const plain = runGsdTools('query phases.list', tmpDir);
|
||||
const plain = runMsdTools('query phases.list', tmpDir);
|
||||
assert.strictEqual(plain.success, true);
|
||||
assert.ok(
|
||||
plain.output.length > 50000,
|
||||
@@ -276,7 +276,7 @@ describe('--pick flag', () => {
|
||||
|
||||
// Present field ("largeAtFilePayloadStillResolves"): resolves at exit
|
||||
// 0 through the @file: payload.
|
||||
const present = runGsdTools('query phases.list --pick count', tmpDir);
|
||||
const present = runMsdTools('query phases.list --pick count', tmpDir);
|
||||
assert.strictEqual(present.success, true);
|
||||
assert.strictEqual(present.output, String(PHASE_COUNT));
|
||||
|
||||
@@ -301,7 +301,7 @@ describe('--pick flag', () => {
|
||||
// Adversarial review finding (isolated review, verified live): `--pick`'s
|
||||
// field value reaches the "field not found" / "output was not JSON"
|
||||
// diagnostics verbatim. Repro on this tree BEFORE the fix:
|
||||
// $ node gsd-tools.cjs generate-slug x --pick $'a\nError: forged'
|
||||
// $ node msd-tools.cjs generate-slug x --pick $'a\nError: forged'
|
||||
// Error: --pick a
|
||||
// Error: forged: field not found; available top-level keys: slug
|
||||
// Spawns the real CLI (the vulnerability is about the literal bytes on
|
||||
@@ -339,7 +339,7 @@ describe('formatDiagnosticToken escapes untrusted --pick field values', () => {
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// formatKeyForDiagnosticList (gsd-tools.cjs) — untrusted frontmatter KEY
|
||||
// formatKeyForDiagnosticList (msd-tools.cjs) — untrusted frontmatter KEY
|
||||
// escaping, as distinct from the untrusted --pick TOKEN escaping above.
|
||||
//
|
||||
// `frontmatter get <file>` (no --field) reads an arbitrary user-authored
|
||||
@@ -347,13 +347,13 @@ describe('formatDiagnosticToken escapes untrusted --pick field values', () => {
|
||||
// top-level frontmatter keys straight into the "field not found; available
|
||||
// top-level keys: ..." diagnostic. A key is therefore untrusted input from a
|
||||
// user document in exactly the way a --pick argv token is untrusted input
|
||||
// from the shell — formatKeyForDiagnosticList (gsd-tools.cjs) exists to
|
||||
// from the shell — formatKeyForDiagnosticList (msd-tools.cjs) exists to
|
||||
// neutralize it the same way formatDiagnosticToken neutralizes the token.
|
||||
//
|
||||
// Reachable + verified live on this tree, e.g. for a frontmatter key
|
||||
// containing a real embedded newline:
|
||||
// $ printf '---\n"weird\\nkey": v\nplain: y\n---\n\nbody\n' > f.md
|
||||
// $ gsd-tools frontmatter get f.md --pick absent_field
|
||||
// $ msd-tools frontmatter get f.md --pick absent_field
|
||||
// Error: --pick "absent_field": field not found; available top-level keys: weird\nkey, plain
|
||||
// The `\n` in that stderr is the two-character ESCAPED sequence backslash-n,
|
||||
// not a real newline — the raw/untrimmed stderr assertions below pin that.
|
||||
|
||||
Reference in New Issue
Block a user