refactor(chat): remove temporary overrides for edit and scaffold tools

Simplify tool call handling by eliminating global overrides for instructions and descriptions, directly executing commands with provided arguments.
This commit is contained in:
Gregory Gauthier 2026-03-04 12:24:23 +00:00
parent 79c28da120
commit bec85a69e0

View File

@ -183,21 +183,14 @@ func handleToolCall(reply string, history *[]map[string]string) {
switch tc.Tool {
case "edit":
if tc.File != "" && tc.Instruction != "" {
// Pass the instruction directly to the edit command
if tc.File != "" {
editCmd.SetArgs([]string{tc.File})
// 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 != "" {
if tc.Path != "" {
scaffoldCmd.SetArgs([]string{tc.Path})
scaffoldDescriptionOverride = tc.Description
_ = scaffoldCmd.Execute()
scaffoldDescriptionOverride = ""
}
case "testgen":
if tc.File != "" {
@ -219,9 +212,3 @@ 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
)