@@ -900,6 +900,76 @@ node ValidatorNode {
900900 # }
901901}
902902
903+ # User input node for task continuation
904+ node UserInputNode {
905+ has status: str = "waiting";
906+ has user_input: str = "";
907+ has should_continue: bool = True;
908+
909+ """Wait for user input and determine next action"""
910+ def get_user_input(coder: Any) -> Tuple[str, bool] {
911+ try {
912+ coder.io.tool_output("\n" + "="*50);
913+ coder.io.tool_output("Genius Agent - Task Completed!");
914+ coder.io.tool_output("What would you like me to do next?");
915+ coder.io.tool_output("Options:");
916+ coder.io.tool_output(" - Describe a new task");
917+ coder.io.tool_output(" - Type 'exit' or 'quit' to stop");
918+ coder.io.tool_output(" - Type 'status' to see current repository state");
919+ coder.io.tool_output("="*50);
920+
921+ user_input = input("\nNext task > ").strip();
922+
923+ if user_input.lower() in ['exit', 'quit', 'stop'] {
924+ return ("", False);
925+ } elif user_input.lower() == 'status' {
926+ return ("status", True);
927+ } elif user_input == '' {
928+ return ("empty", True); # Handle empty input separately
929+ } else {
930+ return (user_input, True);
931+ }
932+ } except (KeyboardInterrupt, EOFError) {
933+ coder.io.tool_output("\nExiting Genius Agent...");
934+ return ("", False);
935+ } except Exception as e {
936+ coder.io.tool_output(f"Error getting user input: {str(e)}");
937+ return ("", False);
938+ }
939+ }
940+
941+ """Show current repository status"""
942+ def show_status(coder: Any) {
943+ coder.io.tool_output("\nCurrent Repository Status:");
944+ coder.io.tool_output("-" * 30);
945+
946+ if coder.abs_fnames {
947+ coder.io.tool_output("Files in current session:");
948+ for fname in coder.abs_fnames {
949+ coder.io.tool_output(f" - {fname}");
950+ }
951+ } else {
952+ coder.io.tool_output("No files in current session");
953+ }
954+
955+ if coder.repo {
956+ try {
957+ dirty_files = coder.repo.get_dirty_files();
958+ if dirty_files {
959+ coder.io.tool_output("\nModified files:");
960+ for file in dirty_files {
961+ coder.io.tool_output(f" - {file}");
962+ }
963+ } else {
964+ coder.io.tool_output("\nNo uncommitted changes");
965+ }
966+ } except Exception as e {
967+ coder.io.tool_output(f"Could not get git status: {e}");
968+ }
969+ }
970+ }
971+ }
972+
903973# Terminal node for end of graph traversal
904974node EndNode {}
905975glob END = EndNode();
@@ -941,12 +1011,14 @@ walker GeniusAgent {
9411011 planning_node = PlanningNode(task=self.task, status="pending", planning_model=self.planning_model);
9421012 editor_node = EditorNode(file_path="", content="", changes=[], status="pending", editor_model=self.editor_model);
9431013 validator_node = ValidatorNode(file_path="", issues=[], status="pending", validation_model=self.editor_model);
1014+ user_input_node = UserInputNode(status="waiting");
9441015
945- # Connect the workflow
1016+ # Connect the workflow with user input loop
9461017 root ++> planning_node;
9471018 planning_node ++> editor_node;
9481019 editor_node ++> validator_node;
949- validator_node ++> END;
1020+ validator_node ++> user_input_node; # Go to user input instead of END
1021+ # Note: UserInputNode will handle navigation based on user choice
9501022
9511023 self.coder.io.tool_output(f"Genius Agent - Phase: Initialization | Action: Starting Genius Agent | Reasoning: Beginning autonomous development cycle for: {self.task}");
9521024
@@ -1196,9 +1268,67 @@ walker GeniusAgent {
11961268 }
11971269 }
11981270
1271+ # Generate report before moving to user input
1272+ self.generate_comprehensive_report();
1273+
11991274 visit [-->];
12001275 }
12011276
1277+ # Handle user input and decide next action
1278+ can handle_user_input with UserInputNode entry {
1279+ here.status = "waiting";
1280+
1281+ while True {
1282+ (user_input, should_continue) = here.get_user_input(self.coder);
1283+
1284+ if not should_continue {
1285+ self.coder.io.tool_output("Genius Agent - Phase: Shutdown | Action: User requested exit | Reasoning: Gracefully shutting down");
1286+ # End the walker execution
1287+ return;
1288+ }
1289+
1290+ if user_input == "status" {
1291+ here.show_status(self.coder);
1292+ continue;
1293+ }
1294+
1295+ if user_input == "empty" {
1296+ self.coder.io.tool_output("Please provide a task description or type 'exit' to quit.");
1297+ continue;
1298+ }
1299+
1300+ if user_input {
1301+ # Reset for new task
1302+ self.task = user_input;
1303+ self.task_explicitly_provided = True;
1304+ self.planning_complete = False;
1305+ self.last_error_context = None;
1306+ self.current_iteration = 0;
1307+
1308+ self.coder.io.tool_output(f"Genius Agent - Phase: New Task | Action: Starting new task | Reasoning: User provided new task: {user_input}");
1309+
1310+ # Create new nodes for the next cycle
1311+ planning_node = PlanningNode(task=self.task, status="pending", planning_model=self.planning_model);
1312+ editor_node = EditorNode(file_path="", content="", changes=[], status="pending", editor_model=self.editor_model);
1313+ validator_node = ValidatorNode(file_path="", issues=[], status="pending", validation_model=self.editor_model);
1314+ new_user_input_node = UserInputNode(status="waiting");
1315+
1316+ # Connect the new workflow
1317+ here ++> planning_node;
1318+ planning_node ++> editor_node;
1319+ editor_node ++> validator_node;
1320+ validator_node ++> new_user_input_node;
1321+
1322+ # Start the new cycle
1323+ visit [-->];
1324+ return;
1325+ } else {
1326+ here.show_status(self.coder);
1327+ self.coder.io.tool_output("Please provide a valid task or type 'exit' to quit.");
1328+ }
1329+ }
1330+ }
1331+
12021332 # Handle reaching the end
12031333 can finish with EndNode entry {
12041334 success = len(self.completed_tasks) > 0;
0 commit comments