diff --git a/tests/bug-2346-agent-read-loop-guards.test.cjs b/tests/bug-2346-agent-read-loop-guards.test.cjs index 6916baff8..303f5b66b 100644 --- a/tests/bug-2346-agent-read-loop-guards.test.cjs +++ b/tests/bug-2346-agent-read-loop-guards.test.cjs @@ -28,15 +28,13 @@ describe('bug #2346: agent read loop guards', () => { describe('gsd-ui-checker', () => { const agentPath = path.join(AGENTS_DIR, 'gsd-ui-checker.md'); - let content; + const content = fs.readFileSync(agentPath, 'utf-8'); test('agent file exists', () => { assert.ok(fs.existsSync(agentPath), 'agents/gsd-ui-checker.md must exist'); - content = fs.readFileSync(agentPath, 'utf-8'); }); test('has block', () => { - content = content || fs.readFileSync(agentPath, 'utf-8'); assert.ok( content.includes(''), 'gsd-ui-checker.md must have a block to prevent unbounded read loops (#2346)' @@ -44,7 +42,6 @@ describe('bug #2346: agent read loop guards', () => { }); test('critical_rules contains no-re-read constraint', () => { - content = content || fs.readFileSync(agentPath, 'utf-8'); const rulesStart = content.indexOf(''); const rulesEnd = content.indexOf('', rulesStart); assert.ok(rulesStart !== -1 && rulesEnd !== -1, ' block must be complete'); @@ -56,7 +53,6 @@ describe('bug #2346: agent read loop guards', () => { }); test('critical_rules appears before success_criteria', () => { - content = content || fs.readFileSync(agentPath, 'utf-8'); const rulesIdx = content.indexOf(''); const successIdx = content.indexOf(''); assert.ok(rulesIdx !== -1 && successIdx !== -1, 'both sections must exist'); @@ -69,15 +65,13 @@ describe('bug #2346: agent read loop guards', () => { describe('gsd-planner', () => { const agentPath = path.join(AGENTS_DIR, 'gsd-planner.md'); - let content; + const content = fs.readFileSync(agentPath, 'utf-8'); test('agent file exists', () => { assert.ok(fs.existsSync(agentPath), 'agents/gsd-planner.md must exist'); - content = fs.readFileSync(agentPath, 'utf-8'); }); test('has block', () => { - content = content || fs.readFileSync(agentPath, 'utf-8'); assert.ok( content.includes(''), 'gsd-planner.md must have a block to prevent unbounded read loops (#2346)' @@ -85,7 +79,6 @@ describe('bug #2346: agent read loop guards', () => { }); test('critical_rules contains no-re-read constraint', () => { - content = content || fs.readFileSync(agentPath, 'utf-8'); const rulesStart = content.indexOf(''); const rulesEnd = content.indexOf('', rulesStart); assert.ok(rulesStart !== -1 && rulesEnd !== -1, ' block must be complete'); @@ -97,7 +90,6 @@ describe('bug #2346: agent read loop guards', () => { }); test('critical_rules appears before success_criteria', () => { - content = content || fs.readFileSync(agentPath, 'utf-8'); const rulesIdx = content.indexOf(''); const successIdx = content.lastIndexOf(''); assert.ok(rulesIdx !== -1 && successIdx !== -1, 'both sections must exist'); diff --git a/tests/plan-bounce.test.cjs b/tests/plan-bounce.test.cjs index b87664519..3c8f464a2 100644 --- a/tests/plan-bounce.test.cjs +++ b/tests/plan-bounce.test.cjs @@ -86,10 +86,9 @@ describe('Plan Bounce: config template defaults', () => { // plan-phase.md is the installed AI workflow instruction — its text content IS what executes. // String presence tests guard against accidental deletion of bounce step clauses. describe('Plan Bounce: plan-phase.md step 12.5', () => { - let content; + const content = fs.readFileSync(PLAN_PHASE_PATH, 'utf-8'); test('plan-phase.md contains step 12.5', () => { - content = fs.readFileSync(PLAN_PHASE_PATH, 'utf-8'); assert.ok( content.includes('## 12.5'), 'plan-phase.md should contain step 12.5' @@ -97,7 +96,6 @@ describe('Plan Bounce: plan-phase.md step 12.5', () => { }); test('step 12.5 references plan bounce', () => { - content = content || fs.readFileSync(PLAN_PHASE_PATH, 'utf-8'); // The step title should mention bounce assert.ok( /## 12\.5.*[Bb]ounce/i.test(content), @@ -106,7 +104,6 @@ describe('Plan Bounce: plan-phase.md step 12.5', () => { }); test('plan-phase.md has --bounce flag handling', () => { - content = content || fs.readFileSync(PLAN_PHASE_PATH, 'utf-8'); assert.ok( content.includes('--bounce'), 'plan-phase.md should handle --bounce flag' @@ -114,7 +111,6 @@ describe('Plan Bounce: plan-phase.md step 12.5', () => { }); test('plan-phase.md has --skip-bounce flag handling', () => { - content = content || fs.readFileSync(PLAN_PHASE_PATH, 'utf-8'); assert.ok( content.includes('--skip-bounce'), 'plan-phase.md should handle --skip-bounce flag' @@ -122,7 +118,6 @@ describe('Plan Bounce: plan-phase.md step 12.5', () => { }); test('plan-phase.md has backup pattern (pre-bounce.md)', () => { - content = content || fs.readFileSync(PLAN_PHASE_PATH, 'utf-8'); assert.ok( content.includes('pre-bounce.md'), 'plan-phase.md should reference pre-bounce.md backup files' @@ -130,7 +125,6 @@ describe('Plan Bounce: plan-phase.md step 12.5', () => { }); test('plan-phase.md has frontmatter integrity validation for bounced plans', () => { - content = content || fs.readFileSync(PLAN_PHASE_PATH, 'utf-8'); // Should mention YAML frontmatter validation after bounce assert.ok( /frontmatter.*bounced|bounced.*frontmatter|YAML.*bounce|bounce.*YAML/i.test(content), @@ -139,7 +133,6 @@ describe('Plan Bounce: plan-phase.md step 12.5', () => { }); test('plan-phase.md re-runs checker on bounced plans', () => { - content = content || fs.readFileSync(PLAN_PHASE_PATH, 'utf-8'); // Should mention re-running plan checker after bounce assert.ok( /[Rr]e-run.*checker.*bounce|bounce.*checker.*re-run|checker.*bounced/i.test(content), @@ -148,7 +141,6 @@ describe('Plan Bounce: plan-phase.md step 12.5', () => { }); test('plan-phase.md references plan_bounce config keys', () => { - content = content || fs.readFileSync(PLAN_PHASE_PATH, 'utf-8'); assert.ok( content.includes('plan_bounce_script'), 'plan-phase.md should reference plan_bounce_script config' @@ -160,7 +152,6 @@ describe('Plan Bounce: plan-phase.md step 12.5', () => { }); test('plan-phase.md disables bounce when --gaps flag is present', () => { - content = content || fs.readFileSync(PLAN_PHASE_PATH, 'utf-8'); // Should mention that --gaps disables bounce assert.ok( /--gaps.*bounce|bounce.*--gaps/i.test(content), @@ -169,7 +160,6 @@ describe('Plan Bounce: plan-phase.md step 12.5', () => { }); test('plan-phase.md restores original on script failure', () => { - content = content || fs.readFileSync(PLAN_PHASE_PATH, 'utf-8'); // Should mention restoring from backup on failure assert.ok( /restore.*original|restore.*pre-bounce|original.*restore/i.test(content),