diff --git a/cmd/chat.go b/cmd/chat.go index dec9c3c..6c44b6c 100644 --- a/cmd/chat.go +++ b/cmd/chat.go @@ -184,16 +184,20 @@ func handleToolCall(reply string, history *[]map[string]string) { switch tc.Tool { case "edit": if tc.File != "" && tc.Instruction != "" { - // Directly call the edit command's Run function with arguments + // Pass the instruction directly to the edit command editCmd.SetArgs([]string{tc.File}) - // We temporarily override the instruction via a global or flag if needed. - // For now we just run the normal edit flow (it will ask for instruction interactively) + // We set a temporary global so the edit command can pick up the instruction + // (this is the simplest way without refactoring every command) + editInstructionOverride = tc.Instruction _ = editCmd.Execute() + editInstructionOverride = "" // reset } case "scaffold": if tc.Path != "" && tc.Description != "" { scaffoldCmd.SetArgs([]string{tc.Path}) + scaffoldDescriptionOverride = tc.Description _ = scaffoldCmd.Execute() + scaffoldDescriptionOverride = "" } case "testgen": if tc.File != "" { @@ -215,3 +219,9 @@ func handleToolCall(reply string, history *[]map[string]string) { *history = append(*history, map[string]string{"role": "assistant", "content": reply}) } + +// Temporary overrides so the existing command logic can pick up the instruction from the agent +var ( + editInstructionOverride string + scaffoldDescriptionOverride string +)