refactor: optimize ACP agent initialization and remove dead code

- Remove unreachable custom agent command validation from ACPExecutor.Execute()
- Add IsBuiltinAgent() utility function for cleaner agent name resolution
- Replace inline agent list iteration with IsBuiltinAgent() check in agent_chat.go
- Add explicit stdin pipe cleanup in RunAgentACP() defer block
- Simplify CLI output handling by removing redundant stream output fallback
This commit is contained in:
j3ssie
2026-03-07 14:13:19 +08:00
parent 9bdb3260b6
commit ecc77b9a30
3 changed files with 12 additions and 47 deletions
+1 -6
View File
@@ -75,17 +75,12 @@ func runAgent(cmd *cobra.Command, args []string) error {
StreamWriter: os.Stdout,
}
output, _, err := executor.RunAgentACP(ctx, message, agentName, cfg)
_, _, err = executor.RunAgentACP(ctx, message, agentName, cfg)
if err != nil {
printer.Error("Agent failed: %s", err)
return err
}
// If there was no stream writer, print output at the end
if cfg.StreamWriter == nil && output != "" {
fmt.Println(output)
}
return nil
}