@@ -62,10 +62,30 @@ pub const Loop = struct {
6262 self .log .sayFmt ("Hint: {s}" , .{hint });
6363 }
6464
65+ if (self .cfg .verbose ) {
66+ self .log .logVerbose ("Verbose mode enabled" );
67+ {
68+ var buf : [64 ]u8 = undefined ;
69+ const msg = std .fmt .bufPrint (& buf , "Backoff base: {d}s" , .{self .cfg .backoff_base }) catch "" ;
70+ self .log .logVerbose (msg );
71+ }
72+ {
73+ var buf : [64 ]u8 = undefined ;
74+ const msg = std .fmt .bufPrint (& buf , "Max retries: {d}" , .{self .cfg .max_retries }) catch "" ;
75+ self .log .logVerbose (msg );
76+ }
77+ {
78+ var buf : [64 ]u8 = undefined ;
79+ const msg = std .fmt .bufPrint (& buf , "Task pause: {d}s" , .{self .cfg .task_pause_seconds }) catch "" ;
80+ self .log .logVerbose (msg );
81+ }
82+ }
83+
6584 self .log .say ("Running continuously (Ctrl+C to stop, Ctrl+C twice to force)" );
6685 self .log .say ("" );
6786
6887 while (! shutdown_requested ) {
88+ self .log .logVerbose ("Starting new cycle" );
6989 self .log .say ("" );
7090 self .log .sayFmt ("[Cycle {d}]" , .{self .st .cycle });
7191 self .log .setCycle (self .st .cycle );
@@ -75,13 +95,19 @@ pub const Loop = struct {
7595
7696 // Planning phase
7797 if (! fsutil .fileExists (self .paths .current_plan ) or self .st .phase == .planning ) {
98+ self .log .logVerbose ("Phase: planning" );
7899 // Check for ideas first
79100 var idea_list = ideas .loadAllIdeas (self .paths .ideas_dir , self .allocator , self .cfg .max_file_size ) catch null ;
80101
81102 var result : ExecutionResult = .failure ;
82103
83104 if (idea_list ) | * list | {
84105 defer list .deinit ();
106+ {
107+ var buf : [64 ]u8 = undefined ;
108+ const msg = std .fmt .bufPrint (& buf , "Found {d} idea(s) in ideas queue" , .{list .ideas .len }) catch "" ;
109+ self .log .logVerbose (msg );
110+ }
85111
86112 if (list .ideas .len == 1 ) {
87113 // Single idea - use it directly
@@ -113,6 +139,7 @@ pub const Loop = struct {
113139 } else {
114140 // Multiple ideas - AI selects simplest one
115141 self .log .sayFmt ("[Cycle {d}] Found {d} idea(s) in queue" , .{ self .st .cycle , list .ideas .len });
142+ self .log .logVerbose ("Multiple ideas found, requesting AI selection" );
116143
117144 // Format ideas for AI selection
118145 const formatted = ideas .formatIdeasForSelection (list .ideas , self .allocator ) catch | err | {
@@ -238,6 +265,7 @@ pub const Loop = struct {
238265 if (shutdown_requested ) break ;
239266
240267 // Execution phase
268+ self .log .logVerbose ("Phase: execution" );
241269 self .log .logFmt ("[Cycle {d}] Executing tasks..." , .{self .st .cycle });
242270
243271 while (! shutdown_requested ) {
@@ -268,6 +296,12 @@ pub const Loop = struct {
268296 self .st .current_task_num += 1 ;
269297 self .st .task_index += 1 ;
270298
299+ {
300+ var buf : [64 ]u8 = undefined ;
301+ const msg = std .fmt .bufPrint (& buf , "Executing task {d}/{d}" , .{ self .st .current_task_num , self .st .total_tasks }) catch "" ;
302+ self .log .logVerbose (msg );
303+ }
304+
271305 const result = self .executor .runTask (
272306 task .description ,
273307 self .st .cycle ,
@@ -311,6 +345,7 @@ pub const Loop = struct {
311345 self .log .logError (" Plan file may not be updated correctly" );
312346 };
313347
348+ self .log .logVerbose ("Task marked complete, saving state" );
314349 try self .st .save (self .paths .state_file , self .allocator );
315350
316351 // Small pause between tasks
@@ -321,6 +356,7 @@ pub const Loop = struct {
321356 if (shutdown_requested ) break ;
322357
323358 // Evaluation phase
359+ self .log .logVerbose ("Phase: evaluation" );
324360 const eval_result = evaluator .evaluate (
325361 self .executor ,
326362 self .paths .current_plan ,
@@ -339,6 +375,7 @@ pub const Loop = struct {
339375
340376 if (eval_result == .complete ) {
341377 self .log .sayFmt ("[Cycle {d}] Complete, starting new cycle" , .{self .st .cycle });
378+ self .log .logVerbose ("Evaluation result: complete" );
342379
343380 // Archive plan
344381 plan .archive (
@@ -361,6 +398,7 @@ pub const Loop = struct {
361398 self .st .current_task_num = 0 ;
362399 self .st .total_tasks = 0 ;
363400 } else {
401+ self .log .logVerbose ("Evaluation result: needs_work" );
364402 // Check if there are actually pending tasks
365403 if (! evaluator .hasPendingTasks (self .paths .current_plan , self .allocator , self .cfg .max_file_size )) {
366404 self .log .sayFmt ("[Cycle {d}] NEEDS_WORK but no tasks, starting new cycle" , .{self .st .cycle });
@@ -385,6 +423,11 @@ pub const Loop = struct {
385423 }
386424
387425 try self .st .save (self .paths .state_file , self .allocator );
426+ {
427+ var buf : [64 ]u8 = undefined ;
428+ const msg = std .fmt .bufPrint (& buf , "Cycle {d} complete, state saved" , .{self .st .cycle - | 1 }) catch "" ;
429+ self .log .logVerbose (msg );
430+ }
388431 self .log .sayFmt ("[Cycle {d}] Complete" , .{self .st .cycle - | 1 });
389432 }
390433
@@ -401,6 +444,11 @@ pub const Loop = struct {
401444
402445 fn backoffSleep (self : * Loop ) void {
403446 const sleep_time = self .cfg .backoff_base * 2 ;
447+ if (self .cfg .verbose ) {
448+ var buf : [64 ]u8 = undefined ;
449+ const msg = std .fmt .bufPrint (& buf , "Backoff: sleeping for {d} seconds" , .{sleep_time }) catch "Backoff sleep" ;
450+ self .log .logVerbose (msg );
451+ }
404452 std .Thread .sleep (@as (u64 , sleep_time ) * std .time .ns_per_s );
405453 }
406454};
@@ -499,6 +547,9 @@ fn createTestPaths(allocator: Allocator) !fsutil.Paths {
499547 try std .fs .cwd ().makePath (cycle_log_dir );
500548 try std .fs .cwd ().makePath (history_dir );
501549
550+ const ideas_dir = try std .fs .path .join (allocator , &.{ temp_dir , "ideas" });
551+ try std .fs .cwd ().makePath (ideas_dir );
552+
502553 return fsutil.Paths {
503554 .opencoder_dir = opencoder_dir ,
504555 .state_file = state_file ,
@@ -507,6 +558,7 @@ fn createTestPaths(allocator: Allocator) !fsutil.Paths {
507558 .cycle_log_dir = cycle_log_dir ,
508559 .alerts_file = alerts_file ,
509560 .history_dir = history_dir ,
561+ .ideas_dir = ideas_dir ,
510562 .allocator = allocator ,
511563 };
512564}
0 commit comments