Files
get-shit-done/tests/discuss-phase-power.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

150 lines
5.9 KiB
JavaScript

/**
* GSD Tools Tests - discuss-phase power user mode
*
* Validates that the --power flag workflow documentation is present and
* correctly describes the bulk question generation/answering flow.
*
* Closes: #1513
*/
const { test, describe } = require('node:test');
const assert = require('node:assert/strict');
const fs = require('fs');
const path = require('path');
describe('discuss-phase power user mode (#1513)', () => {
const commandPath = path.join(__dirname, '..', 'commands', 'gsd', 'discuss-phase.md');
const workflowPath = path.join(__dirname, '..', 'get-shit-done', 'workflows', 'discuss-phase.md');
const powerWorkflowPath = path.join(__dirname, '..', 'get-shit-done', 'workflows', 'discuss-phase-power.md');
describe('command file (discuss-phase.md)', () => {
test('mentions --power flag in argument-hint or description', () => {
const content = fs.readFileSync(commandPath, 'utf8');
assert.ok(
content.includes('--power'),
'commands/gsd/discuss-phase.md should document the --power flag'
);
});
test('references the power workflow file', () => {
const content = fs.readFileSync(commandPath, 'utf8');
assert.ok(
content.includes('discuss-phase-power'),
'command file should reference discuss-phase-power workflow'
);
});
});
describe('main workflow file (discuss-phase.md)', () => {
test('has power_user_mode section or references discuss-phase-power.md', () => {
// After #2551, the power dispatch lives in discuss-phase/modes/power.md and
// the parent references it via the dispatch table.
const parentContent = fs.readFileSync(workflowPath, 'utf8');
const powerModePath = path.join(__dirname, '..', 'get-shit-done', 'workflows', 'discuss-phase', 'modes', 'power.md');
const powerMode = fs.existsSync(powerModePath) ? fs.readFileSync(powerModePath, 'utf8') : '';
const content = parentContent + '\n' + powerMode;
const hasPowerSection = content.includes('power_user_mode') || content.includes('power user mode') || content.includes('modes/power.md');
const hasReference = content.includes('discuss-phase-power');
assert.ok(
hasPowerSection || hasReference,
'discuss-phase.md (or modes/power.md after #2551) should have power_user_mode section or reference discuss-phase-power.md'
);
});
test('describes --power flag routing', () => {
const content = fs.readFileSync(workflowPath, 'utf8');
assert.ok(
content.includes('--power'),
'discuss-phase.md should describe --power flag handling'
);
});
});
describe('power workflow file (discuss-phase-power.md)', () => {
test('file exists', () => {
assert.ok(
fs.existsSync(powerWorkflowPath),
'get-shit-done/workflows/discuss-phase-power.md should exist'
);
});
test('describes the generate step', () => {
const content = fs.readFileSync(powerWorkflowPath, 'utf8');
assert.ok(
content.includes('generate') || content.includes('Generate'),
'power workflow should describe generating questions'
);
});
test('describes the wait/notify step', () => {
const content = fs.readFileSync(powerWorkflowPath, 'utf8');
const hasWait = content.includes('wait') || content.includes('Wait');
const hasNotify = content.includes('notify') || content.includes('Notify') || content.includes('notif');
assert.ok(
hasWait || hasNotify,
'power workflow should describe the wait/notify step after generating files'
);
});
test('describes the refresh step', () => {
const content = fs.readFileSync(powerWorkflowPath, 'utf8');
assert.ok(
content.includes('refresh') || content.includes('Refresh'),
'power workflow should describe the refresh step for processing answers'
);
});
test('describes the finalize step', () => {
const content = fs.readFileSync(powerWorkflowPath, 'utf8');
assert.ok(
content.includes('finalize') || content.includes('Finalize'),
'power workflow should describe the finalize step for generating CONTEXT.md'
);
});
test('QUESTIONS.json structure has required fields', () => {
const content = fs.readFileSync(powerWorkflowPath, 'utf8');
assert.ok(content.includes('QUESTIONS.json'), 'should mention QUESTIONS.json file');
assert.ok(content.includes('"phase"'), 'JSON structure should include phase field');
assert.ok(content.includes('"stats"'), 'JSON structure should include stats field');
assert.ok(content.includes('"sections"'), 'JSON structure should include sections field');
assert.ok(
content.includes('"id"') && content.includes('"title"'),
'JSON structure should include question id and title fields'
);
assert.ok(
content.includes('"options"'),
'JSON structure should include options array'
);
assert.ok(
content.includes('"answer"'),
'JSON structure should include answer field'
);
assert.ok(
content.includes('"status"'),
'JSON structure should include status field'
);
});
test('describes HTML generation step', () => {
const content = fs.readFileSync(powerWorkflowPath, 'utf8');
assert.ok(
content.includes('QUESTIONS.html') || content.includes('.html'),
'power workflow should describe generating the HTML companion file'
);
assert.ok(
content.includes('HTML') || content.includes('html'),
'power workflow should mention HTML output'
);
});
test('QUESTIONS.json file naming uses padded phase number', () => {
const content = fs.readFileSync(powerWorkflowPath, 'utf8');
assert.ok(
content.includes('padded_phase') || content.includes('{padded_phase}') || content.includes('QUESTIONS.json'),
'power workflow should describe file naming with padded phase number'
);
});
});
});