MCPcopy Create free account
hub / github.com/diillson/chatcli / runCoderQuery

Method runCoderQuery

cli/agent_mode.go:1068–1101  ·  view source on GitHub ↗

runCoderQuery is the shared body for the coder one-shot entries. It runs the AgentMode ReAct loop under the coder profile and system prompt; gatewayPersona toggles the messaging-gateway directive (see AgentMode.gatewayPersona).

(ctx context.Context, query string, gatewayPersona bool)

Source from the content-addressed store, hash-verified

1066// AgentMode ReAct loop under the coder profile and system prompt; gatewayPersona
1067// toggles the messaging-gateway directive (see AgentMode.gatewayPersona).
1068func (cli *ChatCLI) runCoderQuery(ctx context.Context, query string, gatewayPersona bool) error {
1069 cli.setExecutionProfile(ProfileCoder)
1070 defer cli.setExecutionProfile(ProfileNormal)
1071
1072 // Processar contextos especiais como @file, @git, etc.
1073 query, additionalContext, images := cli.processSpecialCommands(ctx, query)
1074 // Merge images staged from outside the @file flow (e.g. the gateway), then
1075 // gate against the active model (native vision vs describe-fallback).
1076 if len(cli.pendingInboundImages) > 0 {
1077 images = append(images, cli.pendingInboundImages...)
1078 cli.pendingInboundImages = nil
1079 }
1080 images, visionDesc := cli.gateImagesForModel(ctx, images)
1081 additionalContext += visionDesc
1082 fullQuery := query
1083 if additionalContext != "" {
1084 fullQuery = query + "\n\nContexto adicional:\n" + additionalContext
1085 }
1086
1087 // Assegurar que o modo agente está inicializado
1088 if cli.agentMode == nil {
1089 cli.agentMode = NewAgentMode(cli, cli.logger)
1090 }
1091
1092 cli.agentMode.pendingUserImages = images
1093 cli.agentMode.isCoderMode = true
1094 cli.agentMode.isOneShot = true
1095 cli.agentMode.gatewayPersona = gatewayPersona
1096 defer func() { cli.agentMode.gatewayPersona = false }()
1097
1098 // Executa o AgentMode no "perfil coder" (system prompt override):
1099 // timeline, tool_calls e execução automática de plugins.
1100 return cli.agentMode.Run(ctx, fullQuery, "", CoderSystemPrompt)
1101}
1102
1103// RunOnce executa modo agente one-shot
1104func (a *AgentMode) RunOnce(ctx context.Context, query string, autoExecute bool) error {

Callers 2

RunCoderOnceMethod · 0.95
RunGatewayCoderOnceMethod · 0.95

Calls 5

setExecutionProfileMethod · 0.95
gateImagesForModelMethod · 0.95
NewAgentModeFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected