From 79c28da12020a05ab61baa949537bb0847fad139 Mon Sep 17 00:00:00 2001 From: Gregory Gauthier Date: Wed, 4 Mar 2026 12:20:20 +0000 Subject: [PATCH] feat(chat): add overrides for direct instruction passing in tool calls Introduce temporary global variables `editInstructionOverride` and `scaffoldDescriptionOverride` to pass instructions from the AI agent directly to the edit and scaffold commands. This avoids interactive prompts and enables seamless tool integration without major refactoring. Resets overrides after execution. --- cmd/chat.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) 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 +)