Files
oh-my-claudecode/scripts/test-max-attempts.ts
Yeachan-Heo bec423db11 fix: Address design flaws and add PRD/progress support for v2.6.0
Design Flaw Fixes:
- Add max-attempts counter (5) to todo-continuation to prevent infinite loops
- Add mutual exclusion between UltraQA and Ralph Loop (cannot run simultaneously)
- Standardize agent name prefixing in commands (use oh-my-claude-sisyphus: prefix)

New Features:
- Ralph Loop PRD support with prd.json for structured task tracking
- Progress memory system (progress.txt) for patterns and learnings
- /ralph-init command to initialize PRD structure

Code Quality:
- Fix VERSION constant mismatch (2.4.1 → 2.6.0)
- Standardize completion promise to TASK_COMPLETE
- Fix max iterations documentation (100 → 10)
- Remove references to non-existent /start-work command
- Add 77 new tests (318 total)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 07:29:54 +00:00

95 lines
3.3 KiB
TypeScript

#!/usr/bin/env tsx
/**
* Test script for max-attempts counter in todo-continuation
*
* Tests the resetTodoContinuationAttempts functionality to verify
* that the counter tracking mechanism works correctly.
*/
import { resetTodoContinuationAttempts, checkPersistentModes } from '../src/hooks/persistent-mode/index.js';
async function runTests() {
console.log('Testing max-attempts counter...\n');
let testsPassed = 0;
let testsFailed = 0;
// Test 1: Basic reset functionality
try {
console.log('Test 1: Basic reset (should not throw)');
resetTodoContinuationAttempts('test-session-1');
console.log('✓ PASS: resetTodoContinuationAttempts executed without error\n');
testsPassed++;
} catch (error) {
console.error('✗ FAIL: resetTodoContinuationAttempts threw error:', error);
testsFailed++;
}
// Test 2: Multiple resets on same session
try {
console.log('Test 2: Multiple resets on same session');
resetTodoContinuationAttempts('test-session-2');
resetTodoContinuationAttempts('test-session-2');
resetTodoContinuationAttempts('test-session-2');
console.log('✓ PASS: Multiple resets work correctly\n');
testsPassed++;
} catch (error) {
console.error('✗ FAIL: Multiple resets failed:', error);
testsFailed++;
}
// Test 3: Reset different sessions
try {
console.log('Test 3: Reset different sessions');
resetTodoContinuationAttempts('session-a');
resetTodoContinuationAttempts('session-b');
resetTodoContinuationAttempts('session-c');
console.log('✓ PASS: Can reset different sessions independently\n');
testsPassed++;
} catch (error) {
console.error('✗ FAIL: Different session resets failed:', error);
testsFailed++;
}
// Test 4: Indirect test via checkPersistentModes (no todos should not throw)
try {
console.log('Test 4: Indirect test via checkPersistentModes');
const result = await checkPersistentModes('test-session-indirect');
console.log(`✓ PASS: checkPersistentModes executed (shouldBlock=${result.shouldBlock}, mode=${result.mode})\n`);
testsPassed++;
} catch (error) {
console.error('✗ FAIL: checkPersistentModes threw error:', error);
testsFailed++;
}
// Test 5: Reset with empty string session ID
try {
console.log('Test 5: Reset with empty string session ID');
resetTodoContinuationAttempts('');
console.log('✓ PASS: Empty session ID handled correctly\n');
testsPassed++;
} catch (error) {
console.error('✗ FAIL: Empty session ID failed:', error);
testsFailed++;
}
// Summary
console.log('═══════════════════════════════════════');
console.log('SUMMARY');
console.log('═══════════════════════════════════════');
console.log(`Total tests: ${testsPassed + testsFailed}`);
console.log(`Passed: ${testsPassed}`);
console.log(`Failed: ${testsFailed}`);
console.log('═══════════════════════════════════════\n');
if (testsFailed === 0) {
console.log('✓ ALL TESTS PASSED');
process.exit(0);
} else {
console.log('✗ SOME TESTS FAILED');
process.exit(1);
}
}
runTests();