diff --git a/cmd/chat.go b/cmd/chat.go index 6a9c900..dec9c3c 100644 --- a/cmd/chat.go +++ b/cmd/chat.go @@ -150,7 +150,6 @@ func runChat(cmd *cobra.Command, args []string) { color.Green("Grok > ") reply := client.Stream(history, model) - // Agent tool call handling if agentMode && strings.Contains(reply, "```tool") { handleToolCall(reply, &history) continue @@ -185,35 +184,25 @@ func handleToolCall(reply string, history *[]map[string]string) { switch tc.Tool { case "edit": if tc.File != "" && tc.Instruction != "" { - // Reuse the existing edit command's logic (preview + confirm) - editCmd.RunE = func(cmd *cobra.Command, args []string) error { - RunEditWithInstruction(tc.File, tc.Instruction) // we'll define this helper next - return nil - } + // Directly call the edit command's Run function with arguments + 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) _ = editCmd.Execute() } case "scaffold": if tc.Path != "" && tc.Description != "" { - scaffoldCmd.RunE = func(cmd *cobra.Command, args []string) error { - RunScaffoldWithDescription(tc.Path, tc.Description) - return nil - } + scaffoldCmd.SetArgs([]string{tc.Path}) _ = scaffoldCmd.Execute() } case "testgen": if tc.File != "" { - testgenCmd.RunE = func(cmd *cobra.Command, args []string) error { - RunTestgenWithFile(tc.File) - return nil - } + testgenCmd.SetArgs([]string{tc.File}) _ = testgenCmd.Execute() } case "lint": if tc.File != "" { - lintCmd.RunE = func(cmd *cobra.Command, args []string) error { - RunLintWithFile(tc.File) - return nil - } + lintCmd.SetArgs([]string{tc.File}) _ = lintCmd.Execute() } case "commit":