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.
This commit is contained in:
Gregory Gauthier 2026-03-04 12:20:20 +00:00
parent 3e2b8ee7bf
commit 79c28da120

View File

@ -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
)