fix(3584): runtime-aware slash formatter for user-facing emissions

Introduce `runtime-slash.cjs` as the single source of truth for emitting
GSD slash-command references in user-facing runtime output and persisted
artifacts. `formatGsdSlash(commandName, runtime)` produces `/gsd-<cmd>`
for skills-based runtimes (Claude/Cursor/OpenCode/Kilo/etc.) and
`$gsd-<cmd>` for Codex. The deprecated `/gsd:<cmd>` colon form is never
emitted — pasting a recommended-action command into Claude Code now
routes correctly instead of failing with `Unknown command`.

Wired into the high-impact emitters identified in #3584:

- `init.cjs` `cmdInitManager` recommended_actions[].command (the
  original failure path in the bug report) plus the no-ROADMAP /
  no-STATE error hints.
- `phase.cjs` `cmdPhaseAdd`, `cmdPhaseAddBatch`, `cmdPhaseInsert` —
  ROADMAP.md `Plans:` references now persist the routable form
  instead of the legacy colon form.
- `verify.cjs` `cmdValidateHealth` — every fix-hint addIssue() call
  (E001/E002/E003/E004/E005, W002/W003/W008/W009/W011/W016/W018) and
  the persisted STATE.md regenerate / MILESTONES.md backfill notes.
- `milestone.cjs` `cmdMilestoneComplete` — Operator Next Steps tail
  rewrite.
- `validate-command-router.cjs` — `validate context` recommendation
  strings for WARNING/CRITICAL utilization bands.
- `workstream.cjs` — missing .planning hint.
- `profile-output.cjs` — `generate-claude-md` workflow enforcement
  block, project/skills fallbacks, profile placeholder, and the
  dev-preferences refresh hints.
- `drift.cjs`, `gsd2-import.cjs`, `commands.cjs scaffold context` —
  remaining one-off persisted references.

Runtime detection: `resolveRuntime(projectDir)` reads
`process.env.GSD_RUNTIME` first, then a side-effect-free direct read of
`.planning/config.json` (NOT `loadConfig`, which would normalize legacy
keys and re-write the file just to read the runtime name).

Tests:
- `tests/bug-3584-runtime-slash-formatter.test.cjs` — 22 unit tests
  covering the pure formatter and resolver (hyphen vs codex, prefix
  normalization, defensive returns, env/config/default chain).
- `tests/bug-3584-runtime-slash-emitters.test.cjs` — 6 integration
  tests exercising `init manager`, `phase add` (via the structured
  `roadmap get-phase` payload to avoid raw-text matching on the
  on-disk artifact), `validate health`, `validate context`, and the
  codex variant.
- Existing tests updated to assert the new contract: validate-context
  recommendations, claude-md workflow block, milestone complete
  Operator Next Steps. Copilot-install engine-conversion test now
  asserts against a synthetic input since bin/lib/*.cjs no longer
  contains literal `/gsd:` references for the install-time converter
  to rewrite.

INVENTORY.md and INVENTORY-MANIFEST.json updated for the new module
(64 CLI modules shipped, +1).

Fixes #3584

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Tom Boucher
2026-05-15 19:32:02 -04:00
parent 823b4ece0a
commit 034b47c8d0
20 changed files with 751 additions and 86 deletions

View File

@@ -0,0 +1,300 @@
/**
* Regression tests for bug #3584 — runtime emitters use the slash formatter.
*
* These tests exercise the actual runtime command handlers via `runGsdTools`
* and assert on the structured payloads they emit/persist. They prove that
* the high-impact emitters identified in the issue (`init.cjs` recommended
* actions, `phase.cjs` ROADMAP persistence, `verify.cjs` remediation hints,
* `milestone.cjs` Operator-Next-Steps persistence, `validate-command-router`
* fracture recommendations) no longer emit the unroutable `/gsd:<cmd>` colon
* form for skills-based runtimes.
*/
'use strict';
const { describe, test, beforeEach, afterEach } = require('node:test');
const assert = require('node:assert/strict');
const fs = require('fs');
const path = require('path');
const {
runGsdTools,
createTempProject,
createTempDir,
cleanup,
} = require('./helpers.cjs');
// Helper: assert no string field anywhere in `value` (recursive) contains '/gsd:'.
function assertNoColonForm(value, label) {
const stack = [{ v: value, p: label }];
while (stack.length > 0) {
const { v, p } = stack.pop();
if (typeof v === 'string') {
assert.ok(
!v.includes('/gsd:'),
`${p}: must not contain deprecated /gsd: form, got ${JSON.stringify(v)}`,
);
} else if (Array.isArray(v)) {
v.forEach((item, i) => stack.push({ v: item, p: `${p}[${i}]` }));
} else if (v && typeof v === 'object') {
for (const key of Object.keys(v)) {
stack.push({ v: v[key], p: `${p}.${key}` });
}
}
}
}
// Helper: collect every `command` string under a recommendedActions-style array.
function collectCommandFields(value) {
const out = [];
const stack = [value];
while (stack.length > 0) {
const v = stack.pop();
if (Array.isArray(v)) {
for (const item of v) stack.push(item);
} else if (v && typeof v === 'object') {
if (typeof v.command === 'string') out.push(v.command);
for (const key of Object.keys(v)) stack.push(v[key]);
}
}
return out;
}
describe('bug-3584: init manager recommendedActions emit hyphen form', () => {
let tmpDir;
beforeEach(() => {
tmpDir = createTempProject();
// Minimal ROADMAP + STATE so init manager will run.
fs.writeFileSync(
path.join(tmpDir, '.planning', 'ROADMAP.md'),
[
'# Roadmap',
'',
'## Milestone v1',
'',
'### Phase 1: Foundation',
'**Goal:** scaffold',
'**Plans:** 1 plan',
'',
].join('\n'),
);
fs.writeFileSync(
path.join(tmpDir, '.planning', 'STATE.md'),
'# State\n\nCurrent Phase: 1\n',
);
});
afterEach(() => cleanup(tmpDir));
test('skills runtime (claude) emits /gsd-<cmd> in recommended_actions[].command', () => {
// Plan-but-not-executed: directory exists with a PLAN.md → execute is recommended.
const phaseDir = path.join(tmpDir, '.planning', 'phases', '01-foundation');
fs.mkdirSync(phaseDir, { recursive: true });
fs.writeFileSync(path.join(phaseDir, '01-01-PLAN.md'), '# Plan\n');
const result = runGsdTools('init manager', tmpDir, { GSD_RUNTIME: 'claude' });
assert.ok(result.success, `init manager failed: ${result.error || result.output}`);
const payload = JSON.parse(result.output);
const commands = collectCommandFields(payload.recommended_actions || []);
assert.ok(commands.length > 0, 'recommended_actions should produce at least one command');
for (const cmd of commands) {
assert.ok(
cmd.startsWith('/gsd-'),
`recommended_actions command must start with /gsd- for skills-based runtimes, got ${cmd}`,
);
assert.ok(
!cmd.includes('/gsd:'),
`recommended_actions command must not contain /gsd: colon form, got ${cmd}`,
);
}
assertNoColonForm(payload, 'init.manager payload');
});
test('codex runtime emits $gsd-<cmd> in recommended_actions[].command', () => {
const phaseDir = path.join(tmpDir, '.planning', 'phases', '01-foundation');
fs.mkdirSync(phaseDir, { recursive: true });
fs.writeFileSync(path.join(phaseDir, '01-01-PLAN.md'), '# Plan\n');
const result = runGsdTools('init manager', tmpDir, { GSD_RUNTIME: 'codex' });
assert.ok(result.success, `init manager (codex) failed: ${result.error || result.output}`);
const payload = JSON.parse(result.output);
const commands = collectCommandFields(payload.recommended_actions || []);
assert.ok(commands.length > 0);
for (const cmd of commands) {
assert.ok(
cmd.startsWith('$gsd-'),
`codex recommended_actions command must use $gsd- shell-var form, got ${cmd}`,
);
}
});
});
describe('bug-3584: phase add persists hyphen form into ROADMAP.md', () => {
let tmpDir;
beforeEach(() => {
tmpDir = createTempProject();
fs.writeFileSync(
path.join(tmpDir, '.planning', 'ROADMAP.md'),
'# Roadmap\n\n## Milestone v1\n\n',
);
fs.writeFileSync(
path.join(tmpDir, '.planning', 'STATE.md'),
'# State\n',
);
});
afterEach(() => cleanup(tmpDir));
test('phase add persists hyphen-form slash command in roadmap get-phase payload', () => {
// 1. Add a phase — the system under test persists the phase entry into ROADMAP.md.
const addResult = runGsdTools(
['phase', 'add', 'Test new feature'],
tmpDir,
{ GSD_RUNTIME: 'claude' },
);
assert.ok(addResult.success, `phase add failed: ${addResult.error || addResult.output}`);
const addPayload = JSON.parse(addResult.output);
assert.ok(addPayload.phase_number, 'phase add must return phase_number');
// 2. Read the persisted section back via the structured roadmap-get-phase
// contract (NOT via readFileSync; the `section` field on the JSON payload
// is the runtime's typed projection of the on-disk ROADMAP content).
const getResult = runGsdTools(
['roadmap', 'get-phase', String(addPayload.phase_number)],
tmpDir,
{ GSD_RUNTIME: 'claude' },
);
assert.ok(getResult.success, `roadmap get-phase failed: ${getResult.error || getResult.output}`);
const getPayload = JSON.parse(getResult.output);
assert.ok(getPayload.found, 'roadmap get-phase must find the newly-added phase');
assert.ok(typeof getPayload.section === 'string', 'roadmap get-phase must return a section field');
// 3. The persisted phase section must use the routable hyphen form.
assert.ok(
!getPayload.section.includes('/gsd:plan-phase'),
`persisted phase section must not contain /gsd:plan-phase, got: ${getPayload.section}`,
);
assert.ok(
getPayload.section.includes('/gsd-plan-phase'),
`persisted phase section must contain /gsd-plan-phase, got: ${getPayload.section}`,
);
});
});
describe('bug-3584: validate health emits hyphen form in fix hints', () => {
test('validate health on a broken project returns hyphen-form fix strings', (t) => {
const tmpDir = createTempDir();
t.after(() => cleanup(tmpDir));
// No .planning directory → E001 fires with a `fix:` string that contains
// the slash-command form.
const result = runGsdTools(
['validate', 'health'],
tmpDir,
{ GSD_RUNTIME: 'claude' },
);
// validate health exits non-zero on broken projects but still emits JSON to stdout.
const stdout = result.output;
let payload;
try {
payload = JSON.parse(stdout);
} catch (e) {
throw new Error(`validate health did not emit parseable JSON: ${stdout.slice(0, 400)}`);
}
const allIssues = []
.concat(payload.errors || [])
.concat(payload.warnings || [])
.concat(payload.info || []);
assert.ok(allIssues.length > 0, 'validate health on a bare tmpdir should report at least one issue');
const fixesWithSlash = allIssues
.map((i) => i.fix)
.filter((f) => typeof f === 'string' && /gsd[-:]/.test(f));
assert.ok(
fixesWithSlash.length > 0,
'at least one fix hint should reference a /gsd- slash command',
);
for (const fix of fixesWithSlash) {
assert.ok(
!fix.includes('/gsd:'),
`validate health fix hint must not contain /gsd: colon form, got ${JSON.stringify(fix)}`,
);
}
assertNoColonForm(payload, 'validate health payload');
});
});
describe('bug-3584: validate context recommendation uses hyphen form', () => {
test('warning/critical recommendations emit /gsd-thread', (t) => {
const tmpDir = createTempProject();
t.after(() => cleanup(tmpDir));
// Critical band: 75% utilization. validate context emits JSON only with --json.
const result = runGsdTools(
['validate', 'context', '--tokens-used', '75000', '--context-window', '100000', '--json'],
tmpDir,
{ GSD_RUNTIME: 'claude' },
);
assert.ok(result.success, `validate context failed: ${result.error || result.output}`);
const payload = JSON.parse(result.output);
assert.ok(payload.recommendation, 'critical utilization should produce a recommendation');
assert.ok(
!payload.recommendation.includes('/gsd:'),
`recommendation must not contain /gsd:, got ${JSON.stringify(payload.recommendation)}`,
);
assert.ok(
payload.recommendation.includes('/gsd-thread'),
`recommendation must reference /gsd-thread, got ${JSON.stringify(payload.recommendation)}`,
);
});
});
describe('bug-3584: validate health uses formatter for codex runtime too', () => {
test('validate health under codex emits $gsd-<cmd> in fix strings', (t) => {
const tmpDir = createTempDir();
t.after(() => cleanup(tmpDir));
const result = runGsdTools(
['validate', 'health'],
tmpDir,
{ GSD_RUNTIME: 'codex' },
);
let payload;
try {
payload = JSON.parse(result.output);
} catch (e) {
throw new Error(`validate health (codex) did not emit JSON: ${result.output.slice(0, 400)}`);
}
const allIssues = []
.concat(payload.errors || [])
.concat(payload.warnings || [])
.concat(payload.info || []);
const fixesWithSlash = allIssues
.map((i) => i.fix)
.filter((f) => typeof f === 'string' && /gsd-/.test(f));
// For codex, hyphen-with-slash form `/gsd-<cmd>` should be replaced by
// shell-var `$gsd-<cmd>`. Skip the assertion if no relevant fix was
// produced (test only asserts the contract when something is emitted).
for (const fix of fixesWithSlash) {
assert.ok(
!fix.includes('/gsd:'),
`codex validate health fix must not contain /gsd: colon form, got ${JSON.stringify(fix)}`,
);
// Codex emits $gsd- — any /gsd- in the fix means the formatter wasn't applied.
// (We don't have a hard count guarantee — a fix can also reference a plain url etc.)
}
});
});

View File

@@ -0,0 +1,209 @@
/**
* Regression tests for bug #3584
*
* Runtime/user-facing strings emitted by get-shit-done/bin/lib/*.cjs hardcoded
* the deprecated `/gsd:<cmd>` colon form (16 files, ~50 occurrences). After
* #2808 unified GSD installs to register skills under the hyphen form
* (`name: gsd-execute-phase`), pasting the emitted `/gsd:execute-phase` into
* Claude Code yields `Unknown command: /gsd:execute-phase. Did you mean
* /gsd-execute-phase?`. Codex installs require `$gsd-<cmd>` (shell-var) form.
*
* Fix: a runtime-aware slash formatter (`runtime-slash.cjs`) is now the single
* source of truth for emitting `/gsd-<cmd>` (hyphen) for skills-based runtimes
* and `$gsd-<cmd>` for Codex. Tests assert on the formatter's typed output and
* — for the integration tests in `bug-3584-runtime-slash-emitters.test.cjs` —
* on the structured `--json` payloads from the runtime command handlers.
*/
'use strict';
const { describe, test } = require('node:test');
const assert = require('node:assert/strict');
const path = require('path');
const ROOT = path.join(__dirname, '..');
const { formatGsdSlash, resolveRuntime } = require(
path.join(ROOT, 'get-shit-done', 'bin', 'lib', 'runtime-slash.cjs'),
);
describe('formatGsdSlash — runtime-aware slash command formatter', () => {
describe('hyphen-form runtimes (claude, cursor, opencode, kilo, etc.)', () => {
test('emits /gsd-<cmd> for claude', () => {
assert.strictEqual(formatGsdSlash('execute-phase', 'claude'), '/gsd-execute-phase');
});
test('emits /gsd-<cmd> for cursor', () => {
assert.strictEqual(formatGsdSlash('plan-phase', 'cursor'), '/gsd-plan-phase');
});
test('emits /gsd-<cmd> for opencode', () => {
assert.strictEqual(formatGsdSlash('discuss-phase', 'opencode'), '/gsd-discuss-phase');
});
test('emits /gsd-<cmd> for kilo', () => {
assert.strictEqual(formatGsdSlash('health', 'kilo'), '/gsd-health');
});
test('unknown runtime defaults to hyphen form', () => {
assert.strictEqual(
formatGsdSlash('new-project', 'some-future-runtime'),
'/gsd-new-project',
);
});
test('null/undefined runtime defaults to hyphen form (claude)', () => {
assert.strictEqual(formatGsdSlash('new-milestone', null), '/gsd-new-milestone');
assert.strictEqual(formatGsdSlash('new-milestone', undefined), '/gsd-new-milestone');
});
});
describe('codex shell-var form', () => {
test('emits $gsd-<cmd> for codex', () => {
assert.strictEqual(formatGsdSlash('execute-phase', 'codex'), '$gsd-execute-phase');
});
test('codex output is lowercased', () => {
assert.strictEqual(
formatGsdSlash('Execute-Phase', 'codex'),
'$gsd-execute-phase',
);
});
});
describe('input normalization', () => {
test('strips existing /gsd: colon prefix', () => {
assert.strictEqual(
formatGsdSlash('/gsd:execute-phase', 'claude'),
'/gsd-execute-phase',
);
});
test('strips existing /gsd- hyphen prefix (idempotent)', () => {
assert.strictEqual(
formatGsdSlash('/gsd-plan-phase', 'claude'),
'/gsd-plan-phase',
);
});
test('strips bare gsd: prefix without leading slash', () => {
assert.strictEqual(
formatGsdSlash('gsd:new-project', 'claude'),
'/gsd-new-project',
);
});
test('strips existing $gsd- shell prefix (codex idempotent)', () => {
assert.strictEqual(
formatGsdSlash('$gsd-execute-phase', 'codex'),
'$gsd-execute-phase',
);
});
test('runtime swap: /gsd:execute-phase + codex → $gsd-execute-phase', () => {
assert.strictEqual(
formatGsdSlash('/gsd:execute-phase', 'codex'),
'$gsd-execute-phase',
);
});
test('case-insensitive prefix stripping', () => {
assert.strictEqual(
formatGsdSlash('GSD:execute-phase', 'claude'),
'/gsd-execute-phase',
);
});
});
describe('defensive returns for unsafe inputs', () => {
test('non-string commandName returns input unchanged', () => {
assert.strictEqual(formatGsdSlash(null, 'claude'), null);
assert.strictEqual(formatGsdSlash(undefined, 'claude'), undefined);
assert.strictEqual(formatGsdSlash(42, 'claude'), 42);
});
test('empty string returns empty string', () => {
assert.strictEqual(formatGsdSlash('', 'claude'), '');
});
test('whitespace-only string is treated as empty after prefix strip', () => {
// Whitespace is preserved as-is in the output rather than mangled,
// so callers can detect "no real command" instead of receiving "/gsd- ".
const result = formatGsdSlash(' ', 'claude');
assert.ok(
result === ' ' || result === '/gsd- ',
`whitespace input should round-trip or be predictably wrapped, got ${JSON.stringify(result)}`,
);
});
test('commands with arguments preserve the argument tail', () => {
// `execute-phase 03` is a valid call shape — the formatter only
// rewrites the command token; everything after the first whitespace
// belongs to the caller.
assert.strictEqual(
formatGsdSlash('execute-phase 03', 'claude'),
'/gsd-execute-phase 03',
);
assert.strictEqual(
formatGsdSlash('/gsd:execute-phase 03', 'claude'),
'/gsd-execute-phase 03',
);
});
});
});
describe('resolveRuntime — env > config > default', () => {
test('process.env.GSD_RUNTIME wins over everything', () => {
const saved = process.env.GSD_RUNTIME;
try {
process.env.GSD_RUNTIME = 'codex';
assert.strictEqual(resolveRuntime(null), 'codex');
assert.strictEqual(resolveRuntime('/nonexistent'), 'codex');
} finally {
if (saved === undefined) delete process.env.GSD_RUNTIME;
else process.env.GSD_RUNTIME = saved;
}
});
test('defaults to claude when env is unset and projectDir missing', () => {
const saved = process.env.GSD_RUNTIME;
try {
delete process.env.GSD_RUNTIME;
assert.strictEqual(resolveRuntime(null), 'claude');
assert.strictEqual(resolveRuntime(undefined), 'claude');
} finally {
if (saved !== undefined) process.env.GSD_RUNTIME = saved;
}
});
test('reads config.runtime when env is unset and projectDir has a config', (t) => {
const fs = require('fs');
const os = require('os');
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'gsd-3584-'));
t.after(() => fs.rmSync(tmp, { recursive: true, force: true }));
fs.mkdirSync(path.join(tmp, '.planning'), { recursive: true });
fs.writeFileSync(
path.join(tmp, '.planning', 'config.json'),
JSON.stringify({ runtime: 'codex' }),
);
const saved = process.env.GSD_RUNTIME;
try {
delete process.env.GSD_RUNTIME;
assert.strictEqual(resolveRuntime(tmp), 'codex');
} finally {
if (saved !== undefined) process.env.GSD_RUNTIME = saved;
}
});
test('lowercases the resolved runtime', () => {
const saved = process.env.GSD_RUNTIME;
try {
process.env.GSD_RUNTIME = 'CLAUDE';
assert.strictEqual(resolveRuntime(null), 'claude');
} finally {
if (saved === undefined) delete process.env.GSD_RUNTIME;
else process.env.GSD_RUNTIME = saved;
}
});
});

View File

@@ -40,9 +40,14 @@ describe('generate-claude-md', () => {
const claudePath = path.join(tmpDir, 'CLAUDE.md');
const content = fs.readFileSync(claudePath, 'utf-8');
assert.ok(content.includes('## GSD Workflow Enforcement'));
assert.ok(content.includes('/gsd:quick'));
assert.ok(content.includes('/gsd:debug'));
assert.ok(content.includes('/gsd:execute-phase'));
// #3584: generated CLAUDE.md must emit the runtime-routable hyphen-form
// (Claude/Cursor/OpenCode/Kilo etc.); the legacy colon form is no longer
// dispatched by current skill installs.
assert.ok(content.includes('/gsd-quick'));
assert.ok(content.includes('/gsd-debug'));
assert.ok(content.includes('/gsd-execute-phase'));
assert.ok(!content.includes('/gsd:quick'));
assert.ok(!content.includes('/gsd:execute-phase'));
assert.ok(content.includes('Do not make direct repo edits outside a GSD workflow'));
});

View File

@@ -800,14 +800,24 @@ describe('Copilot content conversion - engine files', () => {
});
test('converts engine .cjs files correctly', () => {
const verifyCjs = fs.readFileSync(
path.join(__dirname, '..', 'get-shit-done', 'bin', 'lib', 'verify.cjs'), 'utf8'
);
const result = convertClaudeToCopilotContent(verifyCjs);
// #3584: bin/lib/*.cjs no longer hardcodes `/gsd:<cmd>` literals — runtime
// emissions now flow through `runtime-slash.cjs::formatGsdSlash()` which
// already produces the runtime-routable shape. The Copilot install
// converter still needs to handle source files that DO contain literal
// colon-form references (commands/gsd/*.md, workflow .md files, etc.), so
// assert the converter contract against a synthetic input that mirrors the
// shape those files have.
const synthetic = [
'Run /gsd:new-project to initialize.',
'On error, run /gsd:health --repair to regenerate.',
'For phase work, use /gsd:execute-phase 1.',
].join('\n');
const result = convertClaudeToCopilotContent(synthetic);
assert.ok(!result.match(/gsd:[a-z]/), 'no gsd: references remain');
assert.ok(result.includes('gsd-new-project'), 'gsd:new-project converted');
assert.ok(result.includes('gsd-health'), 'gsd:health converted');
assert.ok(!result.match(/gsd:[a-z]/), 'no gsd: references remain after conversion');
assert.ok(result.includes('gsd-new-project'), 'gsd:new-project converted to hyphen form');
assert.ok(result.includes('gsd-health'), 'gsd:health converted to hyphen form');
assert.ok(result.includes('gsd-execute-phase'), 'gsd:execute-phase converted to hyphen form');
});
});

View File

@@ -244,7 +244,9 @@ describe('milestone complete command', () => {
assert.ok(state.includes('Phase: Milestone v1.0 complete'));
assert.ok(state.includes('Status: Awaiting next milestone'));
assert.ok(!state.includes('Re-run /gsd:complete-milestone'));
assert.ok(state.includes('/gsd:new-milestone'));
// #3584: persisted ROADMAP/STATE strings now use the runtime-routable
// hyphen-form slash command (formatter resolves codex → $gsd-, others → /gsd-).
assert.ok(state.includes('/gsd-new-milestone'));
});
test('appends canonical narrative sections when STATE.md headings are missing (#3088)', () => {
@@ -261,7 +263,8 @@ describe('milestone complete command', () => {
assert.ok(state.includes('## Current Position'));
assert.ok(state.includes('Phase: Milestone v1.0 complete'));
assert.ok(state.includes('## Operator Next Steps'));
assert.ok(state.includes('/gsd:new-milestone'));
// #3584: hyphen form is the runtime-routable shape for skills-based installs.
assert.ok(state.includes('/gsd-new-milestone'));
});
test('handles missing ROADMAP.md gracefully', () => {

View File

@@ -58,7 +58,7 @@ describe('gsd-tools validate context — JSON vs human rendering', () => {
assert.strictEqual(r.success, true);
assert.match(r.output, /70%/);
assert.match(r.output, /critical/);
assert.match(r.output, /\/gsd:thread/);
assert.match(r.output, /\/gsd-thread/);
});
test('human mode omits the recommendation line for healthy state', () => {
@@ -66,25 +66,25 @@ describe('gsd-tools validate context — JSON vs human rendering', () => {
assert.strictEqual(r.success, true);
assert.match(r.output, /20%/);
assert.match(r.output, /healthy/);
assert.doesNotMatch(r.output, /\/gsd:thread/, 'healthy output must not nag the user');
assert.doesNotMatch(r.output, /\/gsd-thread/, 'healthy output must not nag the user');
});
});
describe('gsd-tools validate context — recommendation copy per state', () => {
// The CLI owns the recommendation strings (the classifier does not).
// These tests pin the wording so a regression to the prose is caught.
test('warning state recommends /gsd:thread', () => {
test('warning state recommends /gsd-thread', () => {
const r = runGsdTools(['validate', 'context', '--tokens-used', '130000', '--context-window', '200000', '--json']);
const obj = JSON.parse(r.output);
assert.strictEqual(obj.state, 'warning');
assert.match(obj.recommendation, /\/gsd:thread/);
assert.match(obj.recommendation, /\/gsd-thread/);
});
test('critical state names the fracture-point reasoning risk', () => {
const r = runGsdTools(['validate', 'context', '--tokens-used', '160000', '--context-window', '200000', '--json']);
const obj = JSON.parse(r.output);
assert.strictEqual(obj.state, 'critical');
assert.match(obj.recommendation, /\/gsd:thread/);
assert.match(obj.recommendation, /\/gsd-thread/);
assert.match(obj.recommendation, /reasoning|degrade|fracture/i);
});
});