Files
get-shit-done/tests/thinking-partner.test.cjs
Tom Boucher 41dc475c46 refactor(workflows): extract discuss-phase modes/templates/advisor for progressive disclosure (closes #2551) (#2607)
* refactor(workflows): extract discuss-phase modes/templates/advisor for progressive disclosure (closes #2551)

Splits 1,347-line workflows/discuss-phase.md into a 495-line dispatcher plus
per-mode files in workflows/discuss-phase/modes/ and templates in
workflows/discuss-phase/templates/. Mirrors the progressive-disclosure
pattern that #2361 enforced for agents.

- Per-mode files: power, all, auto, chain, text, batch, analyze, default, advisor
- Templates lazy-loaded at the step that produces the artifact (CONTEXT.md
  template at write_context, DISCUSSION-LOG.md template at git_commit,
  checkpoint.json schema when checkpointing)
- Advisor mode gated behind `[ -f $HOME/.claude/get-shit-done/USER-PROFILE.md ]`
  — inverse of #2174's --advisor flag (don't pay the cost when unused)
- scout_codebase phase-type→map selection table extracted to
  references/scout-codebase.md
- New tests/workflow-size-budget.test.cjs enforces tiered budgets across
  all workflows/*.md (XL=1700 / LARGE=1500 / DEFAULT=1000) plus the
  explicit <500 ceiling for discuss-phase.md per #2551
- Existing tests updated to read from the new file locations after the
  split (functional equivalence preserved — content moved, not removed)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix(#2607): align modes/auto.md check_existing with parent (Update it, not Skip)

CodeRabbit flagged drift between the parent step (which auto-selects "Update
it") and modes/auto.md (which documented "Skip"). The pre-refactor file had
both — line 182 said "Skip" in the overview, line 250 said "Update it" in the
actual step. The step is authoritative. Fix the new mode file to match.

Refs: PR #2607 review comment 3127783430

* test(#2607): harden discuss-phase regression tests after #2551 split

CodeRabbit identified four test smells where the split weakened coverage:

- workflow-size-budget: assertion was unreachable (entered if-block on match,
  then asserted occurrences === 0 — always failed). Now unconditional.
- bug-2549-2550-2552: bounded-read assertion checked concatenated source, so
  src.includes('3') was satisfied by unrelated content in scout-codebase.md
  (e.g., "3-5 most relevant files"). Now reads parent only with a stricter
  regex. Also asserts SCOUT_REF exists.
- chain-flag-plan-phase: filter(existsSync) silently skipped a missing
  modes/chain.md. Now fails loudly via explicit asserts.
- discuss-checkpoint: same silent-filter pattern across three sources. Now
  asserts each required path before reading.

Refs: PR #2607 review comments 3127783457, 3127783452, plus nitpicks for
chain-flag-plan-phase.test.cjs:21-24 and discuss-checkpoint.test.cjs:22-27

* docs(#2607): fix INVENTORY count, context.md placeholders, scout grep portability

- INVENTORY.md: subdirectory note said "50 top-level references" but the
  section header now says 51. Updated to 51.
- templates/context.md: footer hardcoded XX-name instead of declared
  placeholders [X]/[Name], which would leak sample text into generated
  CONTEXT.md files. Now uses the declared placeholders.
- references/scout-codebase.md: no-maps fallback used grep -rl with
  "\\|" alternation (GNU grep only — silent on BSD/macOS grep). Switched
  to grep -rlE with extended regex for portability.

Refs: PR #2607 review comments 3127783404, 3127783448, plus nitpick for
scout-codebase.md:32-40

* docs(#2607): label fenced examples + clarify overlay/advisor precedence

- analyze.md / text.md / default.md: add language tags (markdown/text) to
  fenced example blocks to silence markdownlint MD040 warnings flagged by
  CodeRabbit (one fence in analyze.md, two in text.md, five in default.md).
- discuss-phase.md: document overlay stacking rules in discuss_areas — fixed
  outer→inner order --analyze → --batch → --text, with a pointer to each
  overlay file for mode-specific precedence.
- advisor.md: add tie-breaker rules for NON_TECHNICAL_OWNER signals — explicit
  technical_background overrides inferred signals; otherwise OR-aggregate;
  contradictory explanation_depth values resolve by most-recent-wins.

Refs: PR #2607 review comments 3127783415, 3127783437, plus nitpicks for
default.md:24, discuss-phase.md:345-365, and advisor.md:51-56

* fix(#2607): extract codebase_drift_gate body to keep execute-phase under XL budget

PR #2605 added 80 lines to execute-phase.md (1622 -> 1702), pushing it over
the XL_BUDGET=1700 line cap enforced by tests/workflow-size-budget.test.cjs
(introduced by this PR). Per the test's own remediation hint and #2551's
progressive-disclosure pattern, extract the codebase_drift_gate step body to
get-shit-done/workflows/execute-phase/steps/codebase-drift-gate.md and leave
a brief pointer in the workflow. execute-phase.md is now 1633 lines.

Budget is NOT relaxed; the offending workflow is tightened.

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-22 21:57:24 -04:00

209 lines
8.2 KiB
JavaScript

const { describe, test } = require('node:test');
const assert = require('node:assert/strict');
const fs = require('fs');
const path = require('path');
const GSD_ROOT = path.join(__dirname, '..', 'get-shit-done');
describe('Thinking Partner Integration (#1726)', () => {
// Reference doc tests
describe('Reference document', () => {
const refPath = path.join(GSD_ROOT, 'references', 'thinking-partner.md');
test('thinking-partner.md exists', () => {
assert.ok(fs.existsSync(refPath), 'references/thinking-partner.md should exist');
});
test('documents all 3 integration points', () => {
const content = fs.readFileSync(refPath, 'utf-8');
assert.ok(content.includes('### 1. Discuss Phase'), 'should document Discuss Phase integration');
assert.ok(content.includes('### 2. Plan Phase'), 'should document Plan Phase integration');
assert.ok(content.includes('### 3. Explore'), 'should document Explore integration');
});
test('documents keyword tradeoff signals', () => {
const content = fs.readFileSync(refPath, 'utf-8');
assert.ok(content.includes('"or"'), 'should list "or" as keyword signal');
assert.ok(content.includes('"versus"'), 'should list "versus" as keyword signal');
assert.ok(content.includes('"tradeoff"'), 'should list "tradeoff" as keyword signal');
assert.ok(content.includes('"pros and cons"'), 'should list "pros and cons" as keyword signal');
assert.ok(content.includes('"torn between"'), 'should list "torn between" as keyword signal');
});
test('documents structural tradeoff signals', () => {
const content = fs.readFileSync(refPath, 'utf-8');
assert.ok(content.includes('2+ competing options'), 'should list competing options signal');
assert.ok(content.includes('which is better'), 'should list "which is better" signal');
assert.ok(content.includes('reverses a previous decision'), 'should list decision reversal signal');
});
test('documents when NOT to activate', () => {
const content = fs.readFileSync(refPath, 'utf-8');
assert.ok(content.includes('When NOT to activate'), 'should document non-activation cases');
assert.ok(content.includes('already made a clear choice'), 'should mention clear choices');
});
test('feature is opt-in with default false', () => {
const content = fs.readFileSync(refPath, 'utf-8');
assert.ok(content.includes('Default: `false`'), 'should document default as false');
assert.ok(content.includes('opt-in'), 'should describe feature as opt-in');
});
test('documents design principles', () => {
const content = fs.readFileSync(refPath, 'utf-8');
assert.ok(content.includes('Lightweight'), 'should list Lightweight principle');
assert.ok(content.includes('Opt-in'), 'should list Opt-in principle');
assert.ok(content.includes('Skippable'), 'should list Skippable principle');
assert.ok(content.includes('Brief'), 'should list Brief principle');
assert.ok(content.includes('Aligned'), 'should list Aligned principle');
});
test('explore integration deferred to #1729', () => {
const content = fs.readFileSync(refPath, 'utf-8');
assert.ok(content.includes('#1729'), 'should reference issue #1729 for explore integration');
});
});
// Config tests
describe('Config integration', () => {
test('features.thinking_partner is in VALID_CONFIG_KEYS', () => {
const configSrc = fs.readFileSync(
path.join(GSD_ROOT, 'bin', 'lib', 'config-schema.cjs'),
'utf-8'
);
assert.ok(
configSrc.includes("'features.thinking_partner'"),
'VALID_CONFIG_KEYS should contain features.thinking_partner'
);
});
test('features is in KNOWN_TOP_LEVEL section containers', () => {
const coreSrc = fs.readFileSync(
path.join(GSD_ROOT, 'bin', 'lib', 'core.cjs'),
'utf-8'
);
// The KNOWN_TOP_LEVEL set should include 'features' in section containers
assert.ok(
coreSrc.includes("'features'"),
'KNOWN_TOP_LEVEL should contain features as a section container'
);
});
});
// Workflow integration tests
// After #2551 progressive-disclosure refactor, the thinking-partner block
// moved into the per-mode files (default.md, advisor.md) since the prompt
// is mode-specific (only fires inside discuss_areas, after a user answer).
describe('Discuss-phase integration', () => {
function readDiscussFamily() {
const candidates = [
path.join(GSD_ROOT, 'workflows', 'discuss-phase.md'),
path.join(GSD_ROOT, 'workflows', 'discuss-phase', 'modes', 'default.md'),
path.join(GSD_ROOT, 'workflows', 'discuss-phase', 'modes', 'advisor.md'),
];
return candidates
.filter(p => fs.existsSync(p))
.map(p => fs.readFileSync(p, 'utf-8'))
.join('\n');
}
test('discuss-phase.md contains thinking partner conditional block', () => {
const content = readDiscussFamily();
assert.ok(
content.includes('Thinking partner (conditional)'),
'discuss-phase workflow family should contain thinking partner conditional block'
);
});
test('discuss-phase references features.thinking_partner config', () => {
const content = readDiscussFamily();
assert.ok(
content.includes('features.thinking_partner'),
'discuss-phase workflow family should reference the config key'
);
});
test('discuss-phase references thinking-partner.md for signal list', () => {
const content = readDiscussFamily();
assert.ok(
content.includes('references/thinking-partner.md'),
'discuss-phase workflow family should reference the signal list doc'
);
});
test('discuss-phase offers skip option', () => {
const content = readDiscussFamily();
assert.ok(
content.includes('No, decision made'),
'discuss-phase workflow family should offer a skip/decline option'
);
});
});
describe('Plan-phase integration', () => {
test('plan-phase.md contains thinking partner conditional block', () => {
const content = fs.readFileSync(
path.join(GSD_ROOT, 'workflows', 'plan-phase.md'),
'utf-8'
);
assert.ok(
content.includes('Thinking partner for architectural tradeoffs (conditional)'),
'plan-phase.md should contain thinking partner conditional block'
);
});
test('plan-phase references features.thinking_partner config', () => {
const content = fs.readFileSync(
path.join(GSD_ROOT, 'workflows', 'plan-phase.md'),
'utf-8'
);
assert.ok(
content.includes('features.thinking_partner'),
'plan-phase.md should reference the config key'
);
});
test('plan-phase scans for architectural tradeoff keywords', () => {
const content = fs.readFileSync(
path.join(GSD_ROOT, 'workflows', 'plan-phase.md'),
'utf-8'
);
assert.ok(
content.includes('"architecture"'),
'plan-phase.md should list architecture as a keyword'
);
assert.ok(
content.includes('"approach"'),
'plan-phase.md should list approach as a keyword'
);
assert.ok(
content.includes('"alternative"'),
'plan-phase.md should list alternative as a keyword'
);
});
test('plan-phase offers skip option', () => {
const content = fs.readFileSync(
path.join(GSD_ROOT, 'workflows', 'plan-phase.md'),
'utf-8'
);
assert.ok(
content.includes("No, I'll decide"),
'plan-phase.md should offer a skip/decline option'
);
});
test('plan-phase block is between step 11 and step 12', () => {
const content = fs.readFileSync(
path.join(GSD_ROOT, 'workflows', 'plan-phase.md'),
'utf-8'
);
const step11Idx = content.indexOf('## 11. Handle Checker Return');
const thinkingIdx = content.indexOf('Thinking partner for architectural tradeoffs');
const step12Idx = content.indexOf('## 12. Revision Loop');
assert.ok(step11Idx < thinkingIdx, 'thinking partner block should come after step 11');
assert.ok(thinkingIdx < step12Idx, 'thinking partner block should come before step 12');
});
});
});