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

Method cmdAddContextContinue

cli/agent_command_blocks.go:567–605  ·  view source on GitHub ↗

cmdAddContextContinue feeds a block's output plus extra context back to the LLM. Returns true when the action consumed the plan and the caller must exit.

(ctx context.Context, renderer *agent.UIRenderer, blocks []CommandBlock, outputs []*CommandOutput, answer string)

Source from the content-addressed store, hash-verified

565// cmdAddContextContinue feeds a block's output plus extra context back to the
566// LLM. Returns true when the action consumed the plan and the caller must exit.
567func (a *AgentMode) cmdAddContextContinue(ctx context.Context, renderer *agent.UIRenderer, blocks []CommandBlock, outputs []*CommandOutput, answer string) bool {
568 cmdNumStr := strings.TrimPrefix(answer, "ac")
569 cmdNum, err := strconv.Atoi(cmdNumStr)
570 if err != nil || cmdNum < 1 || cmdNum > len(blocks) {
571 fmt.Println(i18n.T("agent.error.invalid_command_number_context"))
572 _ = a.getInput(renderer.Colorize(i18n.T("agent.status.press_enter"), agent.ColorGray))
573 return false
574 }
575 if outputs[cmdNum-1] == nil {
576 fmt.Println(i18n.T("agent.status.command_not_executed"))
577 _ = a.getInput(renderer.Colorize(i18n.T("agent.status.press_enter"), agent.ColorGray))
578 return false
579 }
580
581 fmt.Println(i18n.T("agent.output_header"))
582 fmt.Println("---------------------------------------")
583 fmt.Print(outputs[cmdNum-1].Output)
584 fmt.Println("---------------------------------------")
585
586 userContext := a.getMultilineInput(i18n.T("agent.prompt.additional_context"))
587
588 // Monta o prompt para a IA
589 toolContext := a.getToolContextString()
590 prompt := i18n.T("agent.llm_prompt.continuation_with_context",
591 strings.Join(blocks[cmdNum-1].Commands, "\n"),
592 outputs[cmdNum-1].Output,
593 outputs[cmdNum-1].ErrorMsg,
594 userContext,
595 ) + toolContext
596
597 a.cli.history = append(a.cli.history, models.Message{Role: "user", Content: prompt})
598
599 // Chama o loop de processamento unificado
600 a.continueWithNewAIResponse(ctx)
601
602 // Ao retornar do loop, o agente pode ter terminado ou apresentado um novo plano.
603 // Em ambos os casos, saímos do loop do plano de ação atual.
604 return true
605}
606
607// cmdContinue feeds a block and its output back to the LLM for continuation.
608// Returns true when the action consumed the plan and the caller must exit.

Callers 1

handleCommandBlocksMethod · 0.95

Calls 6

getInputMethod · 0.95
getMultilineInputMethod · 0.95
getToolContextStringMethod · 0.95
TFunction · 0.92
ColorizeMethod · 0.80

Tested by

no test coverage detected