* fix(#1521): resolve own runtime + worktrees-off for all non-Claude installs Generalizes the Codex-only #1515/#1519 fix to every non-Claude runtime, and wires it into the real install path (where it was previously dead-on-arrival). Root causes: 1. The runtime-default stamping lived only in `_applyRuntimeRewrites`, but the installer emits `gsd-core/workflows/*.md` via `copyWithPathReplacement`, which never calls it — so a real `--codex`/`--cursor`/etc. install emitted `--default claude` and worktrees-on. RUNTIME mis-resolved to claude and the workflow ran executors unisolated against the main checkout. (#1515/#1519 were also dead-on-arrival in real installs; this repairs them.) 2. Only `case 'codex'` was stamped; every other non-Claude runtime kept the Claude default. Fix: - New `_stampNonClaudeRuntimeDefaults(content, runtime)` (single shared helper) stamps `--default <runtime>` + `use_worktrees=false` for every `runtime != claude`; called from both `_applyRuntimeRewrites` and, crucially, `copyWithPathReplacement` in bin/install.js (the real workflow emit path). - Generalize the fail-closed worktree guard `= codex` -> `!= claude` in execute-phase/quick/diagnose-issues (worktree isolation is Claude-Code-only). - Flip manager/autonomous inline-vs-background gating to `codex -> background, everything-else -> inline` (research: only Codex can background-nest the pipeline's subagents; all others run inline, which they support). Worktree-capability determination is research-backed (official docs for all 14 non-Claude runtimes: none honor GSD's isolation="worktree" mechanism, only Codex background-nests). New end-to-end real-install test asserts the EMITTED workflow is stamped — the regression guard that would have caught the dead-on-arrival bug. Closes #1521 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013vX5eUtWa2wsZEyeMf5i3r * chore(#1521): backfill changeset PR number (#1537) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013vX5eUtWa2wsZEyeMf5i3r --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -28,7 +28,8 @@ function parseWorkflowSteps(content) {
|
||||
name: match[1],
|
||||
// After #3797 architectural fix, callsites use gsd_run
|
||||
readsRuntimeConfig: body.includes('RUNTIME=$(gsd_run query config-get runtime --default claude'),
|
||||
codexWorktreeGuard: body.includes('Codex execute-phase worktree isolation is unsupported'),
|
||||
// #1521: guard generalized from Codex-specific to all non-Claude runtimes
|
||||
codexWorktreeGuard: body.includes('git worktree isolation') && body.includes('unsupported on runtime'),
|
||||
worktreeDispatchGuidance: body.includes('isolation="worktree"'),
|
||||
};
|
||||
});
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
* dispatched Plan/Execute via Agent(run_in_background=true). On Claude Code a
|
||||
* backgrounded agent has no Agent/Task tool, so it cannot spawn the nested
|
||||
* subagents (worktree executors, plan-checker, verifier). The workflows must
|
||||
* now resolve the runtime and run inline on Claude Code.
|
||||
* now resolve the runtime and run inline everywhere except Codex, which is the
|
||||
* only supported runtime where a backgrounded agent can still nest subagents.
|
||||
*/
|
||||
|
||||
const { describe, test } = require('node:test');
|
||||
@@ -24,23 +25,47 @@ describe('bug-853 — manager/autonomous gate background dispatch by runtime', (
|
||||
assert.ok(matches.length >= 2, 'manager.md must resolve runtime for both plan and execute dispatch');
|
||||
});
|
||||
|
||||
test('manager.md documents why Claude Code cannot background-dispatch', () => {
|
||||
assert.match(MANAGER, /backgrounded agent has no `Agent`\/`Task` tool/);
|
||||
test('manager.md documents why most runtimes cannot background-dispatch', () => {
|
||||
// Accept both old singular form (backgrounded agent has no) and new plural form (backgrounded agents have no)
|
||||
assert.match(MANAGER, /backgrounded agents? ha(?:s|ve) no `Agent`\/`Task` tool/);
|
||||
});
|
||||
|
||||
test('manager.md runs plan/execute inline on Claude Code', () => {
|
||||
assert.match(MANAGER, /If `RUNTIME` is `claude`[\s\S]{0,400}?Skill\(skill="gsd-plan-phase"/);
|
||||
assert.match(MANAGER, /If `RUNTIME` is `claude`[\s\S]{0,400}?Skill\(skill="gsd-execute-phase"/);
|
||||
test('manager.md gates background dispatch on codex and runs plan/execute inline otherwise', () => {
|
||||
// Codex takes the background path
|
||||
assert.match(MANAGER, /If `RUNTIME` is `codex`[\s\S]{0,400}?run_in_background=true/);
|
||||
// Inline is the default/else branch for plan — anchored on the explicit non-Codex label
|
||||
assert.match(
|
||||
MANAGER,
|
||||
/Otherwise \(Claude Code or any other non-Codex runtime\)[\s\S]{0,400}?Skill\(skill="gsd-plan-phase"/,
|
||||
);
|
||||
// Inline is the default/else branch for execute — anchored on the explicit non-Codex label
|
||||
assert.match(
|
||||
MANAGER,
|
||||
/Otherwise \(Claude Code or any other non-Codex runtime\)[\s\S]{0,400}?Skill\(skill="gsd-execute-phase"/,
|
||||
);
|
||||
});
|
||||
|
||||
test('autonomous.md gates interactive background dispatch by runtime', () => {
|
||||
const autoRuntimeMatches = AUTONOMOUS.match(/config-get runtime/g) || [];
|
||||
assert.ok(autoRuntimeMatches.length >= 2, 'autonomous.md must resolve runtime in both 3b (plan) and 3c (execute) interactive branches');
|
||||
assert.match(AUTONOMOUS, /backgrounded agent has no `Agent`\/`Task` tool/);
|
||||
// Accept both old singular form (backgrounded agent has no) and new plural form (backgrounded agents have no)
|
||||
assert.match(AUTONOMOUS, /backgrounded agents? ha(?:s|ve) no `Agent`\/`Task` tool/);
|
||||
});
|
||||
|
||||
test('autonomous.md runs plan/execute inline on Claude Code in interactive mode', () => {
|
||||
assert.match(AUTONOMOUS, /On Claude Code \(`RUNTIME` is `claude`\)[\s\S]{0,400}?Skill\(skill="gsd-plan-phase"/);
|
||||
assert.match(AUTONOMOUS, /On Claude Code \(`RUNTIME` is `claude`\)[\s\S]{0,400}?Skill\(skill="gsd-execute-phase"/);
|
||||
test('autonomous.md gates interactive background dispatch on codex; runs plan/execute inline otherwise', () => {
|
||||
// Codex block: run_in_background=true appears within the codex branch and gsd-plan-phase is nearby
|
||||
assert.match(AUTONOMOUS, /If `RUNTIME` is `codex`[\s\S]{0,1200}?run_in_background=true[\s\S]{0,600}?gsd-plan-phase/);
|
||||
// Codex block: run_in_background=true appears within the codex branch and gsd-execute-phase is nearby
|
||||
assert.match(AUTONOMOUS, /If `RUNTIME` is `codex`[\s\S]{0,3000}?run_in_background=true[\s\S]{0,200}?gsd-execute-phase/);
|
||||
// Inline is the otherwise/else branch for plan — anchored on the explicit non-Codex label
|
||||
assert.match(
|
||||
AUTONOMOUS,
|
||||
/Otherwise \(Claude Code or any other non-Codex runtime\)[\s\S]{0,400}?Skill\(skill="gsd-plan-phase"/,
|
||||
);
|
||||
// Inline is the otherwise/else branch for execute — anchored on the explicit non-Codex label
|
||||
assert.match(
|
||||
AUTONOMOUS,
|
||||
/Otherwise \(Claude Code or any other non-Codex runtime\)[\s\S]{0,400}?Skill\(skill="gsd-execute-phase"/,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -66,17 +66,19 @@ test('codex emit defaults workflow.use_worktrees to false', () => {
|
||||
);
|
||||
});
|
||||
|
||||
test('non-codex runtime (cursor) does NOT rewrite the runtime default — stamping is codex-scoped', () => {
|
||||
test('claude runtime does NOT rewrite the runtime default — stamping is non-claude-scoped (#1521 inversion)', () => {
|
||||
// #1521 generalizes stamping to ALL non-Claude runtimes. The negative case
|
||||
// (no stamping) is now the 'claude' runtime, not other non-Claude runtimes.
|
||||
const line =
|
||||
'RUNTIME=$(gsd_run query config-get runtime --default claude --raw 2>/dev/null || echo "claude")\n';
|
||||
const out = conversion._applyRuntimeRewrites(line, 'cursor', '/home/u/.cursor/', true, undefined);
|
||||
const out = conversion._applyRuntimeRewrites(line, 'claude', '$HOME/.claude/', true, undefined);
|
||||
assert.ok(
|
||||
out.includes('--default claude --raw'),
|
||||
`Expected cursor output to preserve '--default claude --raw'; got:\n${out}`,
|
||||
`Expected claude output to preserve '--default claude --raw'; got:\n${out}`,
|
||||
);
|
||||
assert.ok(
|
||||
!out.includes('--default codex'),
|
||||
`Expected cursor output NOT to contain '--default codex'; got:\n${out}`,
|
||||
`Expected claude output NOT to contain '--default codex'; got:\n${out}`,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -107,14 +109,17 @@ test('regression: every edited workflow gets codex-stamped (source↔engine pari
|
||||
// Property tests (RULESET.TESTS.property-based-testing)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
test('property: runtime stamping applies iff runtime is codex (#1515)', () => {
|
||||
const RUNTIMES = ['claude','codex','cursor','cline','windsurf','augment','trae','qwen','hermes','gemini','opencode','kilo','copilot','antigravity','codebuddy'];
|
||||
test('property: runtime stamping applies for ALL non-claude runtimes; only claude leaves --default claude unchanged (#1521)', () => {
|
||||
// #1521: generalised from codex-only to all non-claude runtimes.
|
||||
// Use the canonical list from the conversion module to avoid hand-rolled array drift.
|
||||
const { NON_CLAUDE_RUNTIMES } = conversion;
|
||||
const RUNTIMES = ['claude', ...NON_CLAUDE_RUNTIMES];
|
||||
const line = 'RUNTIME=$(gsd_run query config-get runtime --default claude --raw 2>/dev/null || echo "claude")\n';
|
||||
fc.assert(fc.property(fc.constantFrom(...RUNTIMES), (rt) => {
|
||||
const out = conversion._applyRuntimeRewrites(line, rt, `$HOME/.${rt}/`, true, undefined);
|
||||
return rt === 'codex'
|
||||
? out.includes('--default codex --raw') && !out.includes('--default claude')
|
||||
: out.includes('--default claude --raw') && !out.includes('--default codex');
|
||||
return rt === 'claude'
|
||||
? out.includes('--default claude --raw') && !out.includes('--default codex')
|
||||
: out.includes(`--default ${rt} --raw`) && !out.includes('--default claude');
|
||||
}));
|
||||
});
|
||||
|
||||
|
||||
228
tests/fix-1521-non-claude-runtime-default-resolution.test.cjs
Normal file
228
tests/fix-1521-non-claude-runtime-default-resolution.test.cjs
Normal file
@@ -0,0 +1,228 @@
|
||||
'use strict';
|
||||
/**
|
||||
* Regression tests for #1521: every non-Claude runtime stamps its own runtime
|
||||
* identity + workflow.use_worktrees=false into emitted workflows.
|
||||
*
|
||||
* GSD's worktree isolation relies on Claude Code's isolation="worktree" spawn
|
||||
* parameter, which no other runtime honors. #1519 (Codex-only fix) is
|
||||
* generalized here to ALL non-Claude runtimes.
|
||||
*
|
||||
* All tests assert on the SUT's RETURN VALUE (engine output), not raw file reads,
|
||||
* except the parity integration test which carries the allow-test-rule exemption.
|
||||
*/
|
||||
|
||||
const { test } = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
const fc = require('fast-check');
|
||||
const conversion = require('../gsd-core/bin/lib/runtime-artifact-conversion.cjs');
|
||||
|
||||
// #1521: use the canonical list from the conversion module rather than a hand-rolled
|
||||
// local array that can drift from the real runtime set.
|
||||
const { NON_CLAUDE_RUNTIMES: NON_CLAUDE } = conversion;
|
||||
const WORKFLOWS = [
|
||||
'execute-phase.md', 'autonomous.md', 'manager.md', 'diagnose-issues.md', 'quick.md',
|
||||
];
|
||||
|
||||
const CLAUDE_RUNTIME_LINE = 'config-get runtime --default claude --raw 2>/dev/null || echo "claude"';
|
||||
const TRUE_WT_LINE = 'config-get workflow.use_worktrees --raw 2>/dev/null || echo "true"';
|
||||
const FALSE_WT_LINE = 'config-get workflow.use_worktrees --default false --raw 2>/dev/null || echo "false"';
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Parity across ALL non-Claude runtimes × all 5 workflows
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
test('parity: every non-Claude runtime stamps its own runtime default and use_worktrees=false on all workflows (#1521)', () => {
|
||||
// allow-test-rule: emitted workflow runtime-resolution shell block is the runtime contract surface (#1521)
|
||||
for (const rt of NON_CLAUDE) {
|
||||
for (const wf of WORKFLOWS) {
|
||||
const src = fs.readFileSync(
|
||||
path.join(__dirname, '..', 'gsd-core', 'workflows', wf),
|
||||
'utf8',
|
||||
);
|
||||
const out = conversion._applyRuntimeRewrites(src, rt, `$HOME/.${rt}/`, true, undefined);
|
||||
|
||||
// No un-stamped claude runtime line may survive
|
||||
assert.ok(
|
||||
!out.includes(CLAUDE_RUNTIME_LINE),
|
||||
`${rt}/${wf}: residual un-stamped claude runtime read — _stampNonClaudeRuntimeDefaults not applied`,
|
||||
);
|
||||
|
||||
// No un-stamped use_worktrees=true line may survive
|
||||
assert.ok(
|
||||
!out.includes(TRUE_WT_LINE),
|
||||
`${rt}/${wf}: residual un-stamped use_worktrees=true read — _stampNonClaudeRuntimeDefaults not applied`,
|
||||
);
|
||||
|
||||
// If the source had a runtime read, the output must have --default <rt>
|
||||
if (src.includes(CLAUDE_RUNTIME_LINE)) {
|
||||
assert.ok(
|
||||
out.includes(`config-get runtime --default ${rt} --raw 2>/dev/null || echo "${rt}"`),
|
||||
`${rt}/${wf}: runtime line not stamped to --default ${rt}`,
|
||||
);
|
||||
}
|
||||
|
||||
// If the source had a use_worktrees read, the output must have --default false
|
||||
if (src.includes(TRUE_WT_LINE)) {
|
||||
assert.ok(
|
||||
out.includes(FALSE_WT_LINE),
|
||||
`${rt}/${wf}: use_worktrees line not defaulted to false`,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Claude unchanged — no stamping for the native runtime
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
test('claude runtime leaves runtime default and use_worktrees=true unchanged (#1521)', () => {
|
||||
const src = fs.readFileSync(
|
||||
path.join(__dirname, '..', 'gsd-core', 'workflows', 'execute-phase.md'),
|
||||
'utf8',
|
||||
);
|
||||
const out = conversion._applyRuntimeRewrites(src, 'claude', '$HOME/.claude/', true, undefined);
|
||||
|
||||
// Claude emit must preserve the original --default claude line
|
||||
if (src.includes(CLAUDE_RUNTIME_LINE)) {
|
||||
assert.ok(
|
||||
out.includes(CLAUDE_RUNTIME_LINE),
|
||||
`claude/execute-phase.md: expected original claude runtime line to survive; got mutated`,
|
||||
);
|
||||
}
|
||||
|
||||
// Claude emit must NOT gain --default false for use_worktrees
|
||||
assert.ok(
|
||||
!out.includes(FALSE_WT_LINE),
|
||||
`claude/execute-phase.md: use_worktrees line must NOT be stamped false for claude runtime`,
|
||||
);
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// fc property — identity: each runtime stamps itself, claude stays unchanged
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
test('property: _stampNonClaudeRuntimeDefaults stamps each non-claude runtime and leaves claude unchanged (#1521)', () => {
|
||||
const line =
|
||||
'RUNTIME=$(gsd_run query config-get runtime --default claude --raw 2>/dev/null || echo "claude")\n';
|
||||
fc.assert(
|
||||
fc.property(fc.constantFrom(...NON_CLAUDE, 'claude'), (rt) => {
|
||||
const out = conversion._applyRuntimeRewrites(line, rt, `$HOME/.${rt}/`, true, undefined);
|
||||
if (rt === 'claude') {
|
||||
return out.includes('--default claude') && !/--default (?!claude)/.test(out);
|
||||
}
|
||||
return out.includes(`--default ${rt}`) && !out.includes('--default claude');
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// fc property — idempotence: stamping twice equals once
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
test('property: _stampNonClaudeRuntimeDefaults is idempotent (#1521)', () => {
|
||||
fc.assert(
|
||||
fc.property(
|
||||
fc.constantFrom(...NON_CLAUDE),
|
||||
fc.constantFrom('runtime', 'use_worktrees'),
|
||||
(rt, which) => {
|
||||
const line =
|
||||
which === 'runtime'
|
||||
? 'RUNTIME=$(gsd_run query config-get runtime --default claude --raw 2>/dev/null || echo "claude")\n'
|
||||
: 'USE_WORKTREES=$(gsd_run query config-get workflow.use_worktrees --raw 2>/dev/null || echo "true")\n';
|
||||
const once = conversion._applyRuntimeRewrites(line, rt, `$HOME/.${rt}/`, true, undefined);
|
||||
const twice = conversion._applyRuntimeRewrites(once, rt, `$HOME/.${rt}/`, true, undefined);
|
||||
return once === twice;
|
||||
},
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Guard generalization: execute-phase.md uses != "claude" not = "codex"
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Guard generalization: execute-phase.md, quick.md, and diagnose-issues.md
|
||||
// all use != "claude" (not = "codex") for the worktree guard (#1521)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
test('execute-phase.md, quick.md, and diagnose-issues.md guards are generalized to != "claude" (not Codex-specific) (#1521)', () => {
|
||||
// allow-test-rule: emitted workflow runtime-resolution shell block is the runtime contract surface (#1521)
|
||||
const GUARD_WORKFLOWS = ['execute-phase.md', 'quick.md', 'diagnose-issues.md'];
|
||||
for (const wf of GUARD_WORKFLOWS) {
|
||||
const src = fs.readFileSync(
|
||||
path.join(__dirname, '..', 'gsd-core', 'workflows', wf),
|
||||
'utf8',
|
||||
);
|
||||
assert.ok(
|
||||
src.includes('[ "$RUNTIME" != "claude" ] && [ "$USE_WORKTREES" != "false" ]'),
|
||||
`${wf}: expected generalized guard [ "$RUNTIME" != "claude" ] && [ "$USE_WORKTREES" != "false" ]`,
|
||||
);
|
||||
assert.ok(
|
||||
!src.includes('[ "$RUNTIME" = "codex" ] && [ "$USE_WORKTREES" != "false" ]'),
|
||||
`${wf}: found Codex-specific guard — should have been generalized to != "claude"`,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Orchestration gating: manager.md + autonomous.md now gate on codex for
|
||||
// background dispatch, not on "not claude". (#1521 Stage 2)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
test('manager.md and autonomous.md gate run_in_background on codex specifically (#1521)', () => {
|
||||
// allow-test-rule: orchestration dispatch gating in manager/autonomous .md is the runtime contract surface (#1521)
|
||||
const manager = fs.readFileSync(
|
||||
path.join(__dirname, '..', 'gsd-core', 'workflows', 'manager.md'),
|
||||
'utf8',
|
||||
);
|
||||
const autonomous = fs.readFileSync(
|
||||
path.join(__dirname, '..', 'gsd-core', 'workflows', 'autonomous.md'),
|
||||
'utf8',
|
||||
);
|
||||
|
||||
// Both files must gate run_in_background on codex (not on a generic "not claude" condition)
|
||||
assert.ok(
|
||||
/`RUNTIME` is `codex`[\s\S]{0,500}?run_in_background=true/.test(manager),
|
||||
'manager.md: expected run_in_background dispatch gated on RUNTIME=codex specifically',
|
||||
);
|
||||
assert.ok(
|
||||
/`RUNTIME` is `codex`[\s\S]{0,700}?run_in_background=true/.test(autonomous),
|
||||
'autonomous.md: expected run_in_background dispatch gated on RUNTIME=codex specifically',
|
||||
);
|
||||
|
||||
// Inline is the default/else branch (not just claude)
|
||||
assert.ok(
|
||||
/Otherwise[\s\S]{0,200}?Claude Code or any other non-Codex runtime/.test(manager),
|
||||
'manager.md: expected "Otherwise (Claude Code or any other non-Codex runtime)" inline branch',
|
||||
);
|
||||
assert.ok(
|
||||
/Otherwise[\s\S]{0,200}?Claude Code or any other non-Codex runtime/.test(autonomous),
|
||||
'autonomous.md: expected "Otherwise (Claude Code or any other non-Codex runtime)" inline branch',
|
||||
);
|
||||
});
|
||||
|
||||
test('manager.md and autonomous.md no longer contain old "not claude" background-dispatch gating (#1521)', () => {
|
||||
// allow-test-rule: orchestration dispatch gating in manager/autonomous .md is the runtime contract surface (#1521)
|
||||
const manager = fs.readFileSync(
|
||||
path.join(__dirname, '..', 'gsd-core', 'workflows', 'manager.md'),
|
||||
'utf8',
|
||||
);
|
||||
const autonomous = fs.readFileSync(
|
||||
path.join(__dirname, '..', 'gsd-core', 'workflows', 'autonomous.md'),
|
||||
'utf8',
|
||||
);
|
||||
|
||||
// The old phrasing that unconditionally sent every non-claude runtime to background must be gone
|
||||
assert.ok(
|
||||
!manager.includes('If `RUNTIME` is not `claude` (e.g. Codex)'),
|
||||
'manager.md: old "If `RUNTIME` is not `claude` (e.g. Codex)" gating must be replaced',
|
||||
);
|
||||
assert.ok(
|
||||
!autonomous.includes('On other runtimes:'),
|
||||
'autonomous.md: old "On other runtimes:" branch label must be replaced',
|
||||
);
|
||||
});
|
||||
95
tests/fix-1521-real-install-stamping.test.cjs
Normal file
95
tests/fix-1521-real-install-stamping.test.cjs
Normal file
@@ -0,0 +1,95 @@
|
||||
'use strict';
|
||||
/**
|
||||
* E2E regression tests for #1521: real install path (copyWithPathReplacement)
|
||||
* MUST stamp non-Claude runtime defaults into emitted gsd-core/workflows/*.md.
|
||||
*
|
||||
* The earlier unit tests in fix-1521-non-claude-runtime-default-resolution.test.cjs
|
||||
* only verify the engine (_applyRuntimeRewrites). This test verifies the wiring:
|
||||
* that a REAL `node bin/install.js --codex/--cursor --global` actually emits
|
||||
* execute-phase.md with --default codex / --default cursor (not --default claude).
|
||||
*
|
||||
* Root cause: copyWithPathReplacement is the emit path for gsd-core/workflows/*.md;
|
||||
* it did its own inline path rewrites but never called _stampNonClaudeRuntimeDefaults,
|
||||
* so the stamping was dead-on-arrival in real installs.
|
||||
*
|
||||
* This test must be RED before the fix is applied (Step 1) and GREEN after (Step 2).
|
||||
*/
|
||||
|
||||
const { test } = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const fs = require('node:fs');
|
||||
const os = require('node:os');
|
||||
const path = require('node:path');
|
||||
const { spawnSync } = require('node:child_process');
|
||||
const { cleanup } = require('./helpers.cjs');
|
||||
|
||||
const INSTALL = path.join(__dirname, '..', 'bin', 'install.js');
|
||||
|
||||
/**
|
||||
* Run a real install into a temp config dir and return the emitted
|
||||
* execute-phase.md content.
|
||||
* @param {string} runtime e.g. 'codex', 'cursor', 'claude'
|
||||
* @returns {string}
|
||||
*/
|
||||
function installAndRead(runtime) {
|
||||
const dir = fs.mkdtempSync(path.join(os.tmpdir(), `gsd-inst-${runtime}-`));
|
||||
const res = spawnSync(
|
||||
process.execPath,
|
||||
[INSTALL, `--${runtime}`, '--global', '--config-dir', dir],
|
||||
{ encoding: 'utf8', timeout: 120000 },
|
||||
);
|
||||
assert.strictEqual(res.status, 0, `install --${runtime} failed: ${res.stderr || res.stdout}`);
|
||||
const wf = path.join(dir, 'gsd-core', 'workflows', 'execute-phase.md');
|
||||
assert.ok(fs.existsSync(wf), `emitted workflow missing for ${runtime}: ${wf}`);
|
||||
const content = fs.readFileSync(wf, 'utf8');
|
||||
cleanup(dir);
|
||||
return content;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// RED tests: these MUST FAIL before the copyWithPathReplacement wiring is added
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
test('real install: codex-emitted execute-phase.md resolves runtime=codex and defaults worktrees off (#1521)', () => {
|
||||
const c = installAndRead('codex');
|
||||
assert.ok(
|
||||
c.includes('config-get runtime --default codex --raw'),
|
||||
'codex runtime default not stamped in real install',
|
||||
);
|
||||
assert.ok(
|
||||
c.includes('config-get workflow.use_worktrees --default false --raw'),
|
||||
'codex use_worktrees not defaulted false in real install',
|
||||
);
|
||||
assert.ok(
|
||||
!c.includes('config-get runtime --default claude --raw'),
|
||||
'residual claude default in codex install',
|
||||
);
|
||||
});
|
||||
|
||||
test('real install: cursor-emitted execute-phase.md resolves runtime=cursor (#1521)', () => {
|
||||
const c = installAndRead('cursor');
|
||||
assert.ok(
|
||||
c.includes('config-get runtime --default cursor --raw'),
|
||||
'cursor runtime default not stamped in real install',
|
||||
);
|
||||
assert.ok(
|
||||
!c.includes('config-get runtime --default claude --raw'),
|
||||
'residual claude default in cursor install',
|
||||
);
|
||||
});
|
||||
|
||||
test('real install: claude-emitted execute-phase.md keeps claude default + worktrees on (#1521)', () => {
|
||||
const c = installAndRead('claude');
|
||||
assert.ok(
|
||||
c.includes('config-get runtime --default claude --raw'),
|
||||
'claude default changed in claude install',
|
||||
);
|
||||
assert.ok(
|
||||
c.includes('config-get workflow.use_worktrees --raw 2>/dev/null || echo "true"'),
|
||||
'claude worktrees default changed (should still be true)',
|
||||
);
|
||||
assert.ok(
|
||||
!c.includes('config-get workflow.use_worktrees --default false --raw'),
|
||||
'claude install must NOT have use_worktrees=false stamped',
|
||||
);
|
||||
});
|
||||
@@ -8,14 +8,14 @@
|
||||
"audit-fix.md": 10988,
|
||||
"audit-milestone.md": 17637,
|
||||
"audit-uat.md": 7425,
|
||||
"autonomous.md": 42275,
|
||||
"autonomous.md": 42778,
|
||||
"check-todos.md": 9431,
|
||||
"cleanup.md": 9897,
|
||||
"code-review-fix.md": 23890,
|
||||
"code-review.md": 31602,
|
||||
"complete-milestone.md": 29987,
|
||||
"debug.md": 13505,
|
||||
"diagnose-issues.md": 12762,
|
||||
"diagnose-issues.md": 12820,
|
||||
"discovery-phase.md": 8651,
|
||||
"discuss-phase-assumptions.md": 26984,
|
||||
"discuss-phase-power.md": 11273,
|
||||
@@ -24,7 +24,7 @@
|
||||
"docs-update.md": 55662,
|
||||
"edit-phase.md": 12883,
|
||||
"eval-review.md": 9923,
|
||||
"execute-phase.md": 92926,
|
||||
"execute-phase.md": 93024,
|
||||
"execute-plan.md": 31365,
|
||||
"explore.md": 10497,
|
||||
"extract-learnings.md": 12849,
|
||||
@@ -39,7 +39,7 @@
|
||||
"insert-phase.md": 8943,
|
||||
"list-phase-assumptions.md": 4305,
|
||||
"list-workspaces.md": 5655,
|
||||
"manager.md": 25949,
|
||||
"manager.md": 26265,
|
||||
"map-codebase.md": 20789,
|
||||
"milestone-summary.md": 11774,
|
||||
"mvp-phase.md": 13582,
|
||||
@@ -57,7 +57,7 @@
|
||||
"pr-branch.md": 9561,
|
||||
"profile-user.md": 20650,
|
||||
"progress.md": 29387,
|
||||
"quick.md": 48772,
|
||||
"quick.md": 48830,
|
||||
"reapply-patches.md": 20393,
|
||||
"remove-phase.md": 8469,
|
||||
"remove-workspace.md": 7507,
|
||||
|
||||
Reference in New Issue
Block a user