11/**
2- * RetardMax Mode — Aggressive autonomous Claude Code loop
2+ * LoopMax Mode — Aggressive autonomous Claude Code loop
33 *
44 * Never-ending loop that spawns Claude Code agents until all tests pass.
55 * No planning, just execution. Uses git worktrees for isolation,
66 * commits often to preserve work, and respawns on failure.
77 *
8- * Usage: stackmemory ralph retardmax "make all tests pass"
8+ * Usage: stackmemory ralph loopmax "make all tests pass"
99 */
1010
1111import { spawn , execSync , type ChildProcess } from 'child_process' ;
@@ -16,7 +16,7 @@ import { logger } from '../../core/monitoring/logger.js';
1616
1717// ── Types ──
1818
19- export interface RetardMaxConfig {
19+ export interface LoopMaxConfig {
2020 /** Task description / goal */
2121 task : string ;
2222 /** Completion criteria — loop stops when this passes */
@@ -48,7 +48,7 @@ export interface LoopIteration {
4848 stuck : boolean ;
4949}
5050
51- interface RetardMaxState {
51+ interface LoopMaxState {
5252 task : string ;
5353 criteria : string ;
5454 startedAt : number ;
@@ -64,20 +64,20 @@ interface RetardMaxState {
6464
6565const STUCK_TIMEOUT_MS = 5 * 60 * 1000 ; // 5 min no output = stuck
6666const LOOP_COOLDOWN_MS = 3_000 ; // 3s between respawns
67- const TMP_DRAFT_DIR = join ( tmpdir ( ) , 'retardmax -drafts' ) ;
67+ const TMP_DRAFT_DIR = join ( tmpdir ( ) , 'loopmax -drafts' ) ;
6868
6969// ── Core ──
7070
71- export class RetardMaxRunner {
72- private config : Required < RetardMaxConfig > ;
73- private state : RetardMaxState ;
71+ export class LoopMaxRunner {
72+ private config : Required < LoopMaxConfig > ;
73+ private state : LoopMaxState ;
7474 private stateFile : string ;
7575 private logFile : string ;
7676 private activeProcess : ChildProcess | null = null ;
7777 private stopped = false ;
7878 private workDir : string ;
7979
80- constructor ( config : RetardMaxConfig ) {
80+ constructor ( config : LoopMaxConfig ) {
8181 this . config = {
8282 task : config . task ,
8383 criteria : config . criteria ,
@@ -117,7 +117,7 @@ export class RetardMaxRunner {
117117
118118 /** Main entry — runs forever until criteria met or stopped */
119119 async run ( ) : Promise < void > {
120- this . log ( `RetardMax starting: ${ this . config . task } ` ) ;
120+ this . log ( `LoopMax starting: ${ this . config . task } ` ) ;
121121 this . log ( `Criteria: ${ this . config . criteria } ` ) ;
122122 this . log ( `State: ${ this . stateFile } ` ) ;
123123 this . log ( `Log: ${ this . logFile } ` ) ;
@@ -178,7 +178,7 @@ export class RetardMaxRunner {
178178 if ( await this . checkCriteria ( ) ) {
179179 this . log ( 'ALL CRITERIA MET — loop complete!' ) ;
180180 this . state . status = 'completed' ;
181- this . commitAndSummarize ( 'RetardMax complete — all criteria met' ) ;
181+ this . commitAndSummarize ( 'LoopMax complete — all criteria met' ) ;
182182 break ;
183183 }
184184
@@ -231,7 +231,7 @@ export class RetardMaxRunner {
231231
232232 // Auto-commit after each loop
233233 iteration . commitsMade = this . autoCommit (
234- `retardmax : loop ${ this . state . loop } (exit=${ result . exitCode } )`
234+ `loopmax : loop ${ this . state . loop } (exit=${ result . exitCode } )`
235235 ) ;
236236 this . state . totalCommits += iteration . commitsMade ;
237237 } catch ( err ) {
@@ -242,7 +242,7 @@ export class RetardMaxRunner {
242242
243243 // Still try to commit whatever we have
244244 iteration . commitsMade = this . autoCommit (
245- `retardmax : loop ${ this . state . loop } crashed — saving progress`
245+ `loopmax : loop ${ this . state . loop } crashed — saving progress`
246246 ) ;
247247 this . state . totalCommits += iteration . commitsMade ;
248248 }
@@ -275,12 +275,12 @@ export class RetardMaxRunner {
275275 stdio : [ 'ignore' , 'pipe' , 'pipe' ] ,
276276 env : {
277277 ...process . env ,
278- RETARDMAX : '1' ,
279- RETARDMAX_LOOP : String ( this . state . loop ) ,
280- RETARDMAX_STATE : this . stateFile ,
281- RETARDMAX_TASK : this . config . task ,
282- RETARDMAX_CRITERIA : this . config . criteria ,
283- RETARDMAX_MODEL : this . config . model ,
278+ LOOPMAX : '1' ,
279+ LOOPMAX_LOOP : String ( this . state . loop ) ,
280+ LOOPMAX_STATE : this . stateFile ,
281+ LOOPMAX_TASK : this . config . task ,
282+ LOOPMAX_CRITERIA : this . config . criteria ,
283+ LOOPMAX_MODEL : this . config . model ,
284284 } ,
285285 } ) ;
286286
@@ -358,15 +358,15 @@ export class RetardMaxRunner {
358358 `` ,
359359 this . config . criteria ,
360360 `` ,
361- `# Mode: RetardMax ` ,
361+ `# Mode: LoopMax ` ,
362362 `` ,
363- `You are in RetardMax mode. Rules:` ,
363+ `You are in LoopMax mode. Rules:` ,
364364 `1. DO NOT PLAN. Just start coding immediately.` ,
365365 `2. Run tests often. Fix what breaks. Repeat.` ,
366366 `3. Commit to git frequently to preserve your work.` ,
367367 `4. If tests pass and lint is clean, you're done.` ,
368368 `5. If you get stuck, commit what you have and describe the blocker.` ,
369- `6. Save any drafts or experiments to /tmp/retardmax -drafts/` ,
369+ `6. Save any drafts or experiments to /tmp/loopmax -drafts/` ,
370370 `7. Be aggressive — try things, break things, fix things.` ,
371371 `8. Do NOT ask for permission. Do NOT explain your reasoning at length.` ,
372372 `9. Prefer action over analysis. Code over comments.` ,
@@ -490,8 +490,8 @@ export class RetardMaxRunner {
490490 timeout : 10_000 ,
491491 env : {
492492 ...process . env ,
493- GIT_AUTHOR_NAME : 'RetardMax ' ,
494- GIT_COMMITTER_NAME : 'RetardMax ' ,
493+ GIT_AUTHOR_NAME : 'LoopMax ' ,
494+ GIT_COMMITTER_NAME : 'LoopMax ' ,
495495 } ,
496496 } ) ;
497497
@@ -513,7 +513,7 @@ export class RetardMaxRunner {
513513 `summary-loop-${ this . state . loop } .md`
514514 ) ;
515515 const summary = [
516- `# RetardMax Checkpoint` ,
516+ `# LoopMax Checkpoint` ,
517517 `` ,
518518 `**Reason:** ${ reason } ` ,
519519 `**Loop:** ${ this . state . loop } ` ,
@@ -538,14 +538,14 @@ export class RetardMaxRunner {
538538 ] . join ( '\n' ) ;
539539
540540 writeFileSync ( summaryFile , summary ) ;
541- this . autoCommit ( `retardmax : checkpoint — ${ reason } ` ) ;
541+ this . autoCommit ( `loopmax : checkpoint — ${ reason } ` ) ;
542542 this . saveState ( ) ;
543543 }
544544
545545 /** Set up a git worktree for isolated work */
546546 private async setupWorktree ( ) : Promise < void > {
547- const branch = `retardmax /${ Date . now ( ) } ` ;
548- const worktreePath = join ( tmpdir ( ) , `retardmax -wt-${ Date . now ( ) } ` ) ;
547+ const branch = `loopmax /${ Date . now ( ) } ` ;
548+ const worktreePath = join ( tmpdir ( ) , `loopmax -wt-${ Date . now ( ) } ` ) ;
549549
550550 this . log ( `Creating worktree at ${ worktreePath } on branch ${ branch } ` ) ;
551551
@@ -629,7 +629,7 @@ export class RetardMaxRunner {
629629 const stuckLoops = this . state . iterations . filter ( ( i ) => i . stuck ) . length ;
630630
631631 console . log ( '\n' + '=' . repeat ( 60 ) ) ;
632- console . log ( 'RetardMax Summary' ) ;
632+ console . log ( 'LoopMax Summary' ) ;
633633 console . log ( '=' . repeat ( 60 ) ) ;
634634 console . log ( `Status: ${ this . state . status } ` ) ;
635635 console . log ( `Total loops: ${ this . state . loop } ` ) ;
@@ -648,11 +648,11 @@ export class RetardMaxRunner {
648648
649649 private log ( msg : string ) : void {
650650 const ts = new Date ( ) . toISOString ( ) . substring ( 11 , 19 ) ;
651- const line = `[${ ts } ] [retardmax ] ${ msg } ` ;
651+ const line = `[${ ts } ] [loopmax ] ${ msg } ` ;
652652 if ( this . config . verbose ) {
653653 console . log ( line ) ;
654654 }
655- logger . info ( msg , { component : 'retardmax ' , loop : this . state . loop } ) ;
655+ logger . info ( msg , { component : 'loopmax ' , loop : this . state . loop } ) ;
656656 }
657657}
658658
0 commit comments