* test(#443): RED unified effort + fast_mode + resolve-execution All 68 tests failing as expected — no implementation yet. Covers: effort cascade (tier defaults, overrides, invalid fallthrough), fast_mode cascade (boolean-only, tier defaults), resolveEffortForTier escalation, renderEffortForRuntime clamping, resolve-execution CLI, config schema new keys, QA hostile-input matrix. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(#443): unified cross-provider effort + fast_mode knobs and resolve-execution query Adds config-driven effort control (universal ladder: minimal<low<medium<high<xhigh<max) and fast_mode propagation knobs, with per-runtime rendering that clamps the unique tail values (max=Anthropic-only clamps to xhigh on Codex; minimal=Codex-only clamps to low on Claude). Key changes: - config-schema.manifest.json: add effort.default, fast_mode.enabled as validKeys; add 4 dynamicKeyPatterns for effort.routing_tier_defaults, effort.agent_overrides, fast_mode.routing_tier_defaults, fast_mode.agent_overrides; fix stale _comment - config-defaults.manifest.json: add effort and fast_mode blocks with tier defaults - model-catalog.cjs: add EFFORT_RENDERING map, renderEffortForRuntime(), RUNTIMES_WITH_FAST_MODE - model-profiles.cjs: re-export new catalog exports - core.cjs: add resolveEffortInternal, resolveFastModeInternal, resolveEffortForTier, VALID_EFFORTS, EFFORT_SET, nextEffort; pass effort/fast_mode through loadConfig - commands.cjs: replace reasoning_effort in cmdResolveModel with unified effort; add cmdResolveExecution (superset command with effort_rendered, effort_param, effort_propagation, fast_mode, fast_mode_supported) - gsd-tools.cjs: add resolve-execution case with --effort/--fast-mode/--attempt flags - tests/feat-443: 69 tests covering cascade, rendering, escalation, CLI, schema, QA matrix - tests/commands.test.cjs: convert 3 reasoning_effort assertions to unified effort - docs/CONFIGURATION.md: document effort + fast_mode + resolve-execution sections - settings-advanced.md: list new effort/fast_mode keys in confirmation table Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * refactor(#443): remove dead catalog effort lane; unify codex effort through renderEffortForRuntime - Remove resolveReasoningEffortInternal (catalog-driven effort function) from core.cjs and its export; remove from commands.cjs destructure import - Convert tests/issue-2517-runtime-aware-profiles.test.cjs: all 11 effort assertions now use resolveEffortInternal + renderEffortForRuntime; Claude effort is first-class (output_config.effort); unknown runtimes assert param===null - Convert tests/feat-3023-model-phase-types.test.cjs: replace the entire resolveReasoningEffortInternal describe with unified effort assertions; effort derives from AGENT_DEFAULT_TIERS routing tier, not phase-type tier Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * docs(#443): ADR for unified cross-provider effort + fast-mode routing Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * test(#443): architecture-level QA invariants + test-strategy doc Add 48-test integration suite (feat-443-effort-fast-mode.integration.test.cjs) covering 8 architectural invariants: cross-provider validity (never emit a value the real API would 400 on), param/channel contract stability, resolve-execution JSON contract (all 8 keys + correct types), totality across the full 33-agent registry, fast-mode honesty (claude always fast_mode_supported=false), precedence first-valid-wins matrix for both effort and fast_mode cascades, dynamic-routing composition (effort escalation independent of model tier), and config-set round-trip for all new effort/* and fast_mode/* key namespaces. Append test-strategy section with invariant rationale and E2E gap documentation to docs/TESTING-SUITES.md. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * test(#443): add failing install-wiring tests for effort per-runtime injection (RED) TDD RED: 10 failing tests covering: - Claude .md gets effort: injected per tier (planner=xhigh, mapper=low, executor=high) - Gemini .md does NOT get effort: (already passing — Gemini-safe) - Codex .toml gets model_reasoning_effort via unified resolver - Config-driven: effort.agent_overrides drives both Claude .md and Codex .toml - Source purity: agents/*.md have no effort: key (already passing) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(#443): wire effort per-runtime at install (Claude .md frontmatter + Codex .toml unified) - Import AGENT_DEFAULT_TIERS and renderEffortForRuntime from model-catalog.cjs - Add readGsdEffectiveEffortConfig(targetDir): reads merged effort config from .planning/config.json (per-project wins) + ~/.gsd/defaults.json (global fallback), same probe pattern as readGsdRuntimeProfileResolver - Add resolveInstallTimeEffort(effortCfg, agentName): pure function matching resolveEffortInternal() precedence (agent_overrides > routing_tier_defaults > default > 'high') without loadConfig side-effects (no sub-repo detection, no migration writes) - Claude agent copy loop: inject `effort: <value>` into frontmatter ONLY for runtime === 'claude'; all other .md runtimes (Gemini, Qwen, Hermes, etc.) stay effort-free (Gemini-safe source contract preserved in agents/*.md) - generateCodexAgentToml: add effortCfg param; emit model_reasoning_effort from unified resolver (replaces old catalog entry.reasoning_effort); Codex clamps max → xhigh via renderEffortForRuntime('codex', ...) - installCodexConfig: pass readGsdEffectiveEffortConfig(targetDir) to generateCodexAgentToml so per-project config wins for Codex .toml too - Update failing tests to GREEN: 12/12 pass; all 17 install tests pass; 2847/2848 unit tests pass (1 pre-existing failure: policy-shell-pinning) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * refactor(#443): source install effort defaults from manifest (kill drift) + guard test Replace hardcoded _GSD_EFFORT_MANIFEST_TIER_DEFAULTS and the 'high' fallback in resolveInstallTimeEffort with values read from config-defaults.manifest.json at module init, using the same __dirname-relative path install.js already uses for all shared manifests. Add feat-443-effort-defaults-drift.test.cjs to assert equality between install.js's runtime constants and the manifest on every CI run. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(#443): reconcile Codex TOML tests with unified effort design The #443 unified effort resolver makes generateCodexAgentToml always emit model_reasoning_effort (driven by resolveInstallTimeEffort, not model_profile_overrides). The test 'generated TOML omits reasoning_effort when runtime has none' had an obsolete premise — model_profile_overrides.reasoning_effort:'' no longer suppresses unified effort. Convert it to assert the new invariant: Codex TOML always carries a valid model_reasoning_effort from the agent's routing tier (xhigh for gsd-planner, a heavy-tier agent), while model_profile_overrides model override is still respected. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(#443): make install.js effort resolution lazy (no load-time side effects breaking launcher-parity) Replace module-load-time IIFE + hard throw (config-defaults.manifest.json read) and top-level require of model-catalog.cjs with a lazy _getGsdEffortCatalog() getter that initialises on first call from resolveInstallTimeEffort / generateCodexAgentToml / Claude .md effort injection. Requiring install.js in unrelated test contexts (e.g. runtime-launcher-parity) no longer triggers manifest IO or throws, eliminating the load-time side effect that changed subprocess exit codes / stderr on the bench. Drift-guard exports (_GSD_EFFORT_MANIFEST_TIER_DEFAULTS / _GSD_EFFORT_MANIFEST_DEFAULT) preserved as lazy getter properties on module.exports so feat-443-effort-defaults-drift still validates them without forcing eager load. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(#443): isolate install-wiring test HOME to stop \$HOME/.claude pollution breaking launcher-parity runGlobalInstall() now redirects HOME to a per-call isolated tmpdir in addition to the existing runtime-specific env-var redirects (CLAUDE_CONFIG_DIR, GEMINI_CONFIG_DIR, CODEX_HOME). This ensures install.js code that uses os.homedir() directly — including the ~/.cache/gsd update-check deletion, ~/.gsd/defaults.json reads, and any HOME-relative npm subprocess writes — never touches the real \$HOME during the test. Without the HOME isolation the install test (which is new to this branch and is now picked up by Docker's raw \`tests/*.test.cjs\` glob) could write or delete files under the real \$HOME, causing runtime-launcher-parity test (D) to fail: (D) asserts a loud non-zero exit when \$RUNTIME_DIR/gsd-tools.cjs is absent and gsd-tools is not on PATH, but the launcher's \$HOME/.claude fallback arm succeeds if \$HOME/.claude/get-shit-done/bin/gsd-tools.cjs exists. Also sets GSD_SKIP_STALE_SDK_CHECK=1 to suppress the \`npm ls -g\` subprocess that the global installer spawns — irrelevant to effort-wiring assertions, slow, and potentially writes to ~/.npm cache. All 12 feat-443 install-wiring assertions preserved. Drift-guard 5/5. Unit suite 2848/2850 (pre-existing policy-shell-pinning.test.cjs failure on next). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * chore(#443): add changeset fragment for effort + fast-mode routing Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * fix(#443): set GSD_TEST_MODE before requiring install.js in drift-guard test to prevent HOME leak Without GSD_TEST_MODE=1, require('bin/install.js') runs the module's main install block (guarded by !GSD_TEST_MODE), performing a real global Claude install into $HOME/.claude/. On CI ubuntu where node is on standard PATH, the launcher's $HOME/.claude fallback arm then finds gsd-tools.cjs, causing runtime-launcher-parity test (D) to exit zero when it must exit non-zero. Root cause: feat-443-effort-defaults-drift.test.cjs (unit suite) runs alphabetically before runtime-launcher-parity.test.cjs in the same node --test invocation. Each runs in a separate worker process but shares the same HOME. The drift test's install leaks gsd-tools.cjs into that HOME, then the launcher test's bash subprocess finds it via the $HOME/.claude arm. Fix: add process.env.GSD_TEST_MODE = '1' at the top of the drift-guard test, before the require(installPath) call. This matches the pattern used by feat-443-effort-fast-mode.test.cjs and feat-443-effort-install-wiring .install.test.cjs. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(#443): deterministic resolve-execution arg parsing + validate install-time effort (Codex adversarial findings) Finding 1: resolve-execution --effort low gsd-planner misrouted 'low' as the agent. Replace find(non-dash) with a proper flag-consuming loop that collects a single positional; validate missing/extra positionals and malformed --attempt values. Finding 2: resolveInstallTimeEffort returned unvalidated effort strings (e.g. "ultra") verbatim. Each precedence layer now checks GSD_EFFORT_SET (imported once from core.cjs) before accepting a value, mirroring resolveEffortInternal exactly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(#443): newline-agnostic effort frontmatter injection (Windows CRLF) + CRLF-safe assertions Extracts injectEffortFrontmatter(content, effortValue) pure helper that detects EOL (LF vs CRLF) from the opening '---' line and inserts 'effort: <value>' before the closing '---' delimiter using the same EOL as the surrounding frontmatter. Regex now uses /^---\r?\n([\s\S]*?)^---\r?$/m instead of the LF-only /^(---\n[\s\S]*?)(---)(\n|$)/ that silently skipped CRLF files on Windows (git core.autocrlf=true checkout). Also adds 7 unit tests covering LF, CRLF, idempotency, no-frontmatter, and complex frontmatter cases. Exports injectEffortFrontmatter from module.exports. Fixes 6 CI failures in tests/feat-443-effort-install-wiring.install.test.cjs on windows-latest runners (lines 138, 145, 152, 261, 345, 356). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: CI Rebase Check <ci@gsd-redux> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
409 lines
17 KiB
JavaScript
409 lines
17 KiB
JavaScript
// allow-test-rule: integration-test-input
|
|
// Exercises install() + generateCodexAgentToml() as a black-box by inspecting
|
|
// produced output files in temp dirs. Source agent .md files are inputs whose
|
|
// installed transformation is asserted — not inspected for string presence.
|
|
|
|
/**
|
|
* #443 — Effort per-runtime wiring at install time.
|
|
*
|
|
* Verifies:
|
|
* 1. Claude global install injects `effort:` into agent .md frontmatter.
|
|
* 2. Gemini global install does NOT inject `effort:` (Gemini-safe .md).
|
|
* 3. Codex global install emits `model_reasoning_effort` in .toml via the
|
|
* unified resolver (not the old catalog-static path).
|
|
* 4. Config-driven proof: effort.agent_overrides wins over tier defaults
|
|
* for both Claude .md and Codex .toml.
|
|
* 5. Source agents/gsd-planner.md has NO effort: key (injection is
|
|
* install-only, source stays Gemini-safe).
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
process.env.GSD_TEST_MODE = '1';
|
|
|
|
const { describe, test, beforeEach, afterEach } = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
const fs = require('node:fs');
|
|
const path = require('node:path');
|
|
const os = require('node:os');
|
|
|
|
const { install } = require('../bin/install.js');
|
|
|
|
const REPO_ROOT = path.resolve(__dirname, '..');
|
|
const SOURCE_AGENTS_DIR = path.join(REPO_ROOT, 'agents');
|
|
|
|
// ─── helpers ─────────────────────────────────────────────────────────────────
|
|
|
|
function makeTmpDir(prefix) {
|
|
return fs.mkdtempSync(path.join(os.tmpdir(), prefix));
|
|
}
|
|
|
|
function readFrontmatter(mdPath) {
|
|
const content = fs.readFileSync(mdPath, 'utf8');
|
|
if (!content.startsWith('---')) return '';
|
|
const end = content.indexOf('---', 3);
|
|
if (end === -1) return '';
|
|
return content.substring(3, end);
|
|
}
|
|
|
|
/**
|
|
* Run a global install for the given runtime, redirecting its home dir to
|
|
* tmpHome. Returns the tmpHome for inspection.
|
|
*
|
|
* Env-var redirection:
|
|
* claude → CLAUDE_CONFIG_DIR
|
|
* gemini → GEMINI_CONFIG_DIR
|
|
* codex → CODEX_HOME
|
|
*
|
|
* HOME is also redirected to an isolated temp dir for the duration of the
|
|
* install call. This prevents any install.js code that uses os.homedir()
|
|
* directly (e.g. ~/.cache/gsd update-check deletion, ~/.gsd/defaults.json
|
|
* reads, stale-SDK npm subprocess writes to ~/.npm) from touching the real
|
|
* HOME and polluting the test environment for other concurrently-running
|
|
* test files (e.g. runtime-launcher-parity test (D) checks that
|
|
* $HOME/.claude/get-shit-done/bin/gsd-tools.cjs is absent).
|
|
*
|
|
* GSD_SKIP_STALE_SDK_CHECK=1 is set to suppress the `npm ls -g` subprocess
|
|
* that the installer spawns for global installs — that subprocess is slow,
|
|
* writes to ~/.npm cache, and is irrelevant to effort-wiring assertions.
|
|
*
|
|
* The working directory is set to REPO_ROOT so install() can find the source
|
|
* agents/. For config-driven tests, place tmpHome inside the project dir
|
|
* so that readGsdEffectiveEffortConfig(targetDir) can walk up from tmpHome
|
|
* and find .planning/config.json.
|
|
*/
|
|
function runGlobalInstall(runtime, tmpHome) {
|
|
const envVarMap = {
|
|
claude: 'CLAUDE_CONFIG_DIR',
|
|
gemini: 'GEMINI_CONFIG_DIR',
|
|
codex: 'CODEX_HOME',
|
|
};
|
|
const envVar = envVarMap[runtime];
|
|
if (!envVar) throw new Error(`Unsupported runtime in test: ${runtime}`);
|
|
|
|
// Isolate HOME to a fresh temp dir so install.js code that calls
|
|
// os.homedir() (cache deletion, defaults.json reads, npm subprocess)
|
|
// never touches the real $HOME/.claude / $HOME/.cache / $HOME/.gsd.
|
|
const isolatedHome = fs.mkdtempSync(path.join(os.tmpdir(), 'gsd-443-home-'));
|
|
|
|
const prev = process.env[envVar];
|
|
const prevCwd = process.cwd();
|
|
const prevHome = process.env.HOME;
|
|
const prevSkipStale = process.env.GSD_SKIP_STALE_SDK_CHECK;
|
|
|
|
process.env[envVar] = tmpHome;
|
|
process.env.HOME = isolatedHome;
|
|
process.env.GSD_SKIP_STALE_SDK_CHECK = '1';
|
|
process.chdir(REPO_ROOT);
|
|
|
|
try {
|
|
install(true, runtime);
|
|
} finally {
|
|
process.chdir(prevCwd);
|
|
if (prev === undefined) delete process.env[envVar];
|
|
else process.env[envVar] = prev;
|
|
if (prevHome === undefined) delete process.env.HOME;
|
|
else process.env.HOME = prevHome;
|
|
if (prevSkipStale === undefined) delete process.env.GSD_SKIP_STALE_SDK_CHECK;
|
|
else process.env.GSD_SKIP_STALE_SDK_CHECK = prevSkipStale;
|
|
// Clean up the isolated HOME dir
|
|
try { fs.rmSync(isolatedHome, { recursive: true, force: true }); } catch (_) { /* best-effort */ }
|
|
}
|
|
|
|
return tmpHome;
|
|
}
|
|
|
|
// ─── Tier default expectations ────────────────────────────────────────────────
|
|
// light → low, standard → high, heavy → xhigh (catalog defaults)
|
|
// gsd-planner: heavy → xhigh
|
|
// gsd-codebase-mapper: light → low
|
|
// gsd-executor: standard → high
|
|
|
|
// ─── describe 1: Claude install injects effort: ───────────────────────────────
|
|
|
|
describe('#443 Claude install: effort: injected into frontmatter', () => {
|
|
let tmpDir;
|
|
let claudeHome;
|
|
|
|
beforeEach(() => {
|
|
tmpDir = makeTmpDir('gsd-443-claude-');
|
|
claudeHome = path.join(tmpDir, 'claude-home');
|
|
fs.mkdirSync(claudeHome, { recursive: true });
|
|
});
|
|
|
|
afterEach(() => {
|
|
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
});
|
|
|
|
test('gsd-planner.md contains effort: xhigh (heavy tier default)', () => {
|
|
runGlobalInstall('claude', claudeHome);
|
|
const fm = readFrontmatter(path.join(claudeHome, 'agents', 'gsd-planner.md'));
|
|
assert.match(fm, /^effort:\s*xhigh$/m,
|
|
`gsd-planner frontmatter should have effort: xhigh\nActual:\n${fm}`);
|
|
});
|
|
|
|
test('gsd-codebase-mapper.md contains effort: low (light tier default)', () => {
|
|
runGlobalInstall('claude', claudeHome);
|
|
const fm = readFrontmatter(path.join(claudeHome, 'agents', 'gsd-codebase-mapper.md'));
|
|
assert.match(fm, /^effort:\s*low$/m,
|
|
`gsd-codebase-mapper frontmatter should have effort: low\nActual:\n${fm}`);
|
|
});
|
|
|
|
test('gsd-executor.md contains effort: high (standard tier default)', () => {
|
|
runGlobalInstall('claude', claudeHome);
|
|
const fm = readFrontmatter(path.join(claudeHome, 'agents', 'gsd-executor.md'));
|
|
assert.match(fm, /^effort:\s*high$/m,
|
|
`gsd-executor frontmatter should have effort: high\nActual:\n${fm}`);
|
|
});
|
|
});
|
|
|
|
// ─── describe 2: Gemini install does NOT inject effort: ──────────────────────
|
|
|
|
describe('#443 Gemini install: effort: absent (Gemini-safe)', () => {
|
|
let tmpDir;
|
|
let geminiHome;
|
|
|
|
beforeEach(() => {
|
|
tmpDir = makeTmpDir('gsd-443-gemini-');
|
|
geminiHome = path.join(tmpDir, 'gemini-home');
|
|
fs.mkdirSync(geminiHome, { recursive: true });
|
|
});
|
|
|
|
afterEach(() => {
|
|
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
});
|
|
|
|
test('gsd-planner.md does NOT contain effort: (Gemini install)', () => {
|
|
runGlobalInstall('gemini', geminiHome);
|
|
const fm = readFrontmatter(path.join(geminiHome, 'agents', 'gsd-planner.md'));
|
|
assert.doesNotMatch(fm, /^effort:/m,
|
|
`gsd-planner (Gemini) frontmatter must NOT have effort:\nActual:\n${fm}`);
|
|
});
|
|
|
|
test('gsd-executor.md does NOT contain effort: (Gemini install)', () => {
|
|
runGlobalInstall('gemini', geminiHome);
|
|
const fm = readFrontmatter(path.join(geminiHome, 'agents', 'gsd-executor.md'));
|
|
assert.doesNotMatch(fm, /^effort:/m,
|
|
`gsd-executor (Gemini) frontmatter must NOT have effort:\nActual:\n${fm}`);
|
|
});
|
|
});
|
|
|
|
// ─── describe 3: Codex install emits model_reasoning_effort in .toml ─────────
|
|
|
|
describe('#443 Codex install: model_reasoning_effort in .toml (unified resolver)', () => {
|
|
let tmpDir;
|
|
let codexHome;
|
|
|
|
beforeEach(() => {
|
|
tmpDir = makeTmpDir('gsd-443-codex-');
|
|
codexHome = path.join(tmpDir, 'codex-home');
|
|
fs.mkdirSync(codexHome, { recursive: true });
|
|
});
|
|
|
|
afterEach(() => {
|
|
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
});
|
|
|
|
test('gsd-planner.toml contains model_reasoning_effort = "xhigh" (heavy tier)', () => {
|
|
runGlobalInstall('codex', codexHome);
|
|
const tomlContent = fs.readFileSync(
|
|
path.join(codexHome, 'agents', 'gsd-planner.toml'), 'utf8'
|
|
);
|
|
assert.match(tomlContent, /^model_reasoning_effort\s*=\s*"xhigh"$/m,
|
|
`gsd-planner.toml should have model_reasoning_effort = "xhigh"\nActual:\n${tomlContent.slice(0, 500)}`);
|
|
});
|
|
});
|
|
|
|
// ─── describe 4: Config-driven proof ─────────────────────────────────────────
|
|
//
|
|
// The runtime home dir must be INSIDE (or a sibling of) the project root so
|
|
// that readGsdEffectiveEffortConfig(targetDir) can walk up from the runtime
|
|
// home and find .planning/config.json. We put .claude/ and .codex/ as siblings
|
|
// of .planning/ inside the project dir — this is the natural local-install shape.
|
|
|
|
describe('#443 Config-driven: effort.agent_overrides drives install-time effort', () => {
|
|
let tmpDir;
|
|
let claudeHome;
|
|
let codexHome;
|
|
|
|
beforeEach(() => {
|
|
// Layout: tmpDir/project/ <-- project root (cwd for install)
|
|
// .planning/config.json
|
|
// .claude/ <-- claudeHome (CLAUDE_CONFIG_DIR)
|
|
// .codex/ <-- codexHome (CODEX_HOME)
|
|
tmpDir = makeTmpDir('gsd-443-cfg-');
|
|
const projectDir = path.join(tmpDir, 'project');
|
|
claudeHome = path.join(projectDir, '.claude');
|
|
codexHome = path.join(projectDir, '.codex');
|
|
|
|
fs.mkdirSync(claudeHome, { recursive: true });
|
|
fs.mkdirSync(codexHome, { recursive: true });
|
|
fs.mkdirSync(path.join(projectDir, '.planning'), { recursive: true });
|
|
|
|
// Write a project config with effort.agent_overrides overriding gsd-planner to 'low'
|
|
const config = {
|
|
effort: {
|
|
agent_overrides: {
|
|
'gsd-planner': 'low',
|
|
},
|
|
},
|
|
};
|
|
fs.writeFileSync(
|
|
path.join(projectDir, '.planning', 'config.json'),
|
|
JSON.stringify(config, null, 2)
|
|
);
|
|
});
|
|
|
|
afterEach(() => {
|
|
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
});
|
|
|
|
test('Claude .md gets effort: low when agent_overrides.gsd-planner=low', () => {
|
|
// projectDir is the cwd for install — chdir handled inside runGlobalInstall.
|
|
// claudeHome is inside projectDir, so walking up from claudeHome finds .planning/config.json.
|
|
runGlobalInstall('claude', claudeHome);
|
|
const fm = readFrontmatter(path.join(claudeHome, 'agents', 'gsd-planner.md'));
|
|
assert.match(fm, /^effort:\s*low$/m,
|
|
`gsd-planner should have effort: low from config override\nActual:\n${fm}`);
|
|
});
|
|
|
|
test('Codex .toml gets model_reasoning_effort = "low" when agent_overrides.gsd-planner=low', () => {
|
|
runGlobalInstall('codex', codexHome);
|
|
const tomlContent = fs.readFileSync(
|
|
path.join(codexHome, 'agents', 'gsd-planner.toml'), 'utf8'
|
|
);
|
|
assert.match(tomlContent, /^model_reasoning_effort\s*=\s*"low"$/m,
|
|
`gsd-planner.toml should have model_reasoning_effort = "low" from config override\nActual:\n${tomlContent.slice(0, 500)}`);
|
|
});
|
|
|
|
test('Codex .toml clamps effort max → xhigh when agent_overrides.gsd-planner=max', () => {
|
|
const projectDir = path.dirname(codexHome);
|
|
// Overwrite config with max override
|
|
const config = {
|
|
effort: {
|
|
agent_overrides: {
|
|
'gsd-planner': 'max',
|
|
},
|
|
},
|
|
};
|
|
fs.writeFileSync(
|
|
path.join(projectDir, '.planning', 'config.json'),
|
|
JSON.stringify(config, null, 2)
|
|
);
|
|
|
|
runGlobalInstall('codex', codexHome);
|
|
const tomlContent = fs.readFileSync(
|
|
path.join(codexHome, 'agents', 'gsd-planner.toml'), 'utf8'
|
|
);
|
|
// Codex does not support 'max' → clamped to 'xhigh'
|
|
assert.match(tomlContent, /^model_reasoning_effort\s*=\s*"xhigh"$/m,
|
|
`gsd-planner.toml should clamp max → xhigh for Codex\nActual:\n${tomlContent.slice(0, 500)}`);
|
|
assert.doesNotMatch(tomlContent, /model_reasoning_effort\s*=\s*"max"/,
|
|
'Codex .toml must never contain model_reasoning_effort = "max"');
|
|
});
|
|
});
|
|
|
|
// ─── describe 5b: Invalid effort tokens fall through (Codex adversarial finding #2) ─
|
|
//
|
|
// These tests FAIL before the fix: resolveInstallTimeEffort returns the raw
|
|
// invalid string without validating it against VALID_EFFORTS.
|
|
|
|
describe('#443 resolveInstallTimeEffort: invalid tokens fall through to valid effort', () => {
|
|
let tmpDir;
|
|
let claudeHome;
|
|
let codexHome;
|
|
|
|
beforeEach(() => {
|
|
// Layout: tmpDir/project/ <-- project root
|
|
// .planning/config.json
|
|
// .claude/ <-- claudeHome
|
|
// .codex/ <-- codexHome
|
|
tmpDir = makeTmpDir('gsd-443-invalid-effort-');
|
|
const projectDir = path.join(tmpDir, 'project');
|
|
claudeHome = path.join(projectDir, '.claude');
|
|
codexHome = path.join(projectDir, '.codex');
|
|
|
|
fs.mkdirSync(claudeHome, { recursive: true });
|
|
fs.mkdirSync(codexHome, { recursive: true });
|
|
fs.mkdirSync(path.join(projectDir, '.planning'), { recursive: true });
|
|
});
|
|
|
|
afterEach(() => {
|
|
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
});
|
|
|
|
function writeProjectConfig(config) {
|
|
const projectDir = path.dirname(claudeHome);
|
|
fs.writeFileSync(
|
|
path.join(projectDir, '.planning', 'config.json'),
|
|
JSON.stringify(config, null, 2)
|
|
);
|
|
}
|
|
|
|
const VALID_EFFORTS = ['minimal', 'low', 'medium', 'high', 'xhigh', 'max'];
|
|
|
|
test('effort.default="ultra" (invalid) -> Claude .md effort: is a VALID value (falls through to high)', () => {
|
|
// BUG before fix: resolveInstallTimeEffort returns "ultra" verbatim
|
|
writeProjectConfig({ effort: { default: 'ultra' } });
|
|
runGlobalInstall('claude', claudeHome);
|
|
const fm = readFrontmatter(path.join(claudeHome, 'agents', 'gsd-planner.md'));
|
|
const match = fm.match(/^effort:\s*(\S+)$/m);
|
|
assert.ok(match, `effort: must be present in frontmatter\nActual:\n${fm}`);
|
|
assert.ok(VALID_EFFORTS.includes(match[1]),
|
|
`effort: must be a VALID effort string, got: "${match[1]}"\nActual frontmatter:\n${fm}`);
|
|
});
|
|
|
|
test('effort.agent_overrides.gsd-planner="bogus" (invalid) with valid default -> falls through to valid default', () => {
|
|
// BUG before fix: "bogus" is returned and written verbatim
|
|
writeProjectConfig({
|
|
effort: {
|
|
agent_overrides: { 'gsd-planner': 'bogus' },
|
|
default: 'medium',
|
|
},
|
|
});
|
|
runGlobalInstall('claude', claudeHome);
|
|
const fm = readFrontmatter(path.join(claudeHome, 'agents', 'gsd-planner.md'));
|
|
const match = fm.match(/^effort:\s*(\S+)$/m);
|
|
assert.ok(match, `effort: must be present in frontmatter\nActual:\n${fm}`);
|
|
assert.ok(VALID_EFFORTS.includes(match[1]),
|
|
`effort: must be a VALID effort string, got: "${match[1]}"\nActual frontmatter:\n${fm}`);
|
|
// Falls through invalid "bogus" -> valid tier default or "medium" default
|
|
// "medium" is valid, so it should appear (or tier default if medium is invalid, but medium is valid)
|
|
});
|
|
|
|
test('effort.default="ultra" (invalid) -> Codex .toml model_reasoning_effort is VALID', () => {
|
|
// BUG before fix: "ultra" written into .toml verbatim
|
|
writeProjectConfig({ effort: { default: 'ultra' } });
|
|
runGlobalInstall('codex', codexHome);
|
|
const tomlContent = fs.readFileSync(
|
|
path.join(codexHome, 'agents', 'gsd-planner.toml'), 'utf8'
|
|
);
|
|
const match = tomlContent.match(/^model_reasoning_effort\s*=\s*"([^"]+)"/m);
|
|
assert.ok(match, `model_reasoning_effort must be present in .toml\nActual:\n${tomlContent.slice(0, 500)}`);
|
|
assert.ok(VALID_EFFORTS.includes(match[1]),
|
|
`model_reasoning_effort must be VALID, got: "${match[1]}"\nActual:\n${tomlContent.slice(0, 500)}`);
|
|
});
|
|
});
|
|
|
|
// ─── describe 5: Source stays clean ──────────────────────────────────────────
|
|
|
|
describe('#443 Source purity: agents/gsd-planner.md has no effort: key', () => {
|
|
test('source agents/gsd-planner.md frontmatter does not contain effort:', () => {
|
|
const fm = readFrontmatter(path.join(SOURCE_AGENTS_DIR, 'gsd-planner.md'));
|
|
assert.doesNotMatch(fm, /^effort:/m,
|
|
`Source agents/gsd-planner.md must NOT contain effort: (injection is install-only)`);
|
|
});
|
|
|
|
test('source agents/gsd-executor.md frontmatter does not contain effort:', () => {
|
|
const fm = readFrontmatter(path.join(SOURCE_AGENTS_DIR, 'gsd-executor.md'));
|
|
assert.doesNotMatch(fm, /^effort:/m,
|
|
`Source agents/gsd-executor.md must NOT contain effort: (injection is install-only)`);
|
|
});
|
|
|
|
test('source agents/gsd-codebase-mapper.md frontmatter does not contain effort:', () => {
|
|
const fm = readFrontmatter(path.join(SOURCE_AGENTS_DIR, 'gsd-codebase-mapper.md'));
|
|
assert.doesNotMatch(fm, /^effort:/m,
|
|
`Source agents/gsd-codebase-mapper.md must NOT contain effort: (injection is install-only)`);
|
|
});
|
|
});
|