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:
@@ -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');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user