Documentation
¶
Overview ¶
* ChatCLI - Command Line Interface for LLM interaction * Copyright (c) 2024 Edilson Freitas * License: MIT
* ChatCLI - Command Line Interface for LLM interaction * Copyright (c) 2024 Edilson Freitas * License: MIT
* ChatCLI - Command Line Interface for LLM interaction * Copyright (c) 2024 Edilson Freitas * License: MIT
* ChatCLI - Command Line Interface for LLM interaction * Copyright (c) 2024 Edilson Freitas * License: MIT
* ChatCLI - Command Line Interface for LLM interaction * Copyright (c) 2024 Edilson Freitas * License: MIT
* ChatCLI - Command Line Interface for LLM interaction * Copyright (c) 2024 Edilson Freitas * License: MIT
Index ¶
- Constants
- func HasStdin() bool
- func PreprocessArgs(args []string) []string
- type AgentMode
- type AnimationManager
- type ChatCLI
- func (cli *ChatCLI) ApplyOverrides(mgr manager.LLMManager, provider, model string) error
- func (cli *ChatCLI) HandleOneShotOrFatal(ctx context.Context, opts *Options) bool
- func (cli *ChatCLI) PrintWelcomeScreen()
- func (cli *ChatCLI) RunAgentOnce(ctx context.Context, input string, autoExecute bool) error
- func (cli *ChatCLI) RunOnce(ctx context.Context, input string, disableAnimation bool) error
- func (cli *ChatCLI) Start(ctx context.Context)
- type CommandBlock
- type CommandContextInfo
- type CommandExecutor
- type CommandHandler
- type CommandOutput
- type FileChunk
- type HistoryManager
- type Liner
- type Logger
- type MultilineInputManager
- type OSCommandExecutor
- type Options
- type SourceType
Constants ¶
const ( ColorReset = "\033[0m" ColorGreen = "\033[32m" ColorLime = "\033[92m" ColorCyan = "\033[36m" ColorGray = "\033[90m" ColorPurple = "\033[35m" ColorBold = "\033[1m" ColorYellow = "\033[33m" ColorRed = "\033[31m" )
ANSI Color Codes
Variables ¶
This section is empty.
Functions ¶
func HasStdin ¶ added in v1.16.1
func HasStdin() bool
Detecta se há dados no stdin (pipe/arquivo ao invés de TTY).
func PreprocessArgs ¶ added in v1.16.2
PreprocessArgs normaliza o caso de -p/--prompt sem valor, convertendo para -p= / --prompt= Ex.: echo "msg" | chatcli -p -> trata como prompt vazio + stdin (não quebra o flag parser)
Types ¶
type AgentMode ¶
type AgentMode struct {
// contains filtered or unexported fields
}
AgentMode representa a funcionalidade de agente autônomo no ChatCLI
func NewAgentMode ¶
NewAgentMode cria uma nova instância do modo agente
type AnimationManager ¶
type AnimationManager struct {
// contains filtered or unexported fields
}
func NewAnimationManager ¶
func NewAnimationManager() *AnimationManager
func (*AnimationManager) ShowThinkingAnimation ¶
func (am *AnimationManager) ShowThinkingAnimation(message string)
ShowThinkingAnimation inicia ou atualiza a animação "pensando"
func (*AnimationManager) StopThinkingAnimation ¶
func (am *AnimationManager) StopThinkingAnimation()
StopThinkingAnimation para a animação de forma segura
func (*AnimationManager) UpdateMessage ¶
func (am *AnimationManager) UpdateMessage(message string)
UpdateMessage atualiza a mensagem sem parar e reiniciar a animação
type ChatCLI ¶
type ChatCLI struct {
Client client.LLMClient
Provider string
Model string
// contains filtered or unexported fields
}
ChatCLI representa a interface de linha de comando do chat
func NewChatCLI ¶
NewChatCLI cria uma nova instância de ChatCLI
func (*ChatCLI) ApplyOverrides ¶ added in v1.16.0
func (cli *ChatCLI) ApplyOverrides(mgr manager.LLMManager, provider, model string) error
ApplyOverrides atualiza provider/model e reobtém o client correspondente
func (*ChatCLI) HandleOneShotOrFatal ¶ added in v1.16.3
HandleOneShotOrFatal executa o modo one-shot se solicitado (flag -p usada ou stdin presente). - Em caso de erro, imprime mensagem em Markdown (stderr) e faz logger.Fatal (sem fallback). - Retorna true se o one-shot foi tratado (com sucesso ou erro fatal). Retorna false se não foi acionado.
func (*ChatCLI) PrintWelcomeScreen ¶ added in v1.18.0
func (cli *ChatCLI) PrintWelcomeScreen()
PrintWelcomeScreen exibe a tela de boas-vindas completa.
func (*ChatCLI) RunAgentOnce ¶ added in v1.19.0
RunAgentOnce executa o modo agente de forma não-interativa (one-shot)
type CommandBlock ¶
type CommandBlock struct {
Description string
Commands []string
Language string
ContextInfo CommandContextInfo
}
CommandBlock representa um bloco de comandos executáveis
type CommandContextInfo ¶
type CommandContextInfo struct {
SourceType SourceType
FileExtension string
IsScript bool
ScriptType string // shell, python, etc.
}
CommandContextInfo contém metadados sobre a origem e natureza de um comando
type CommandExecutor ¶ added in v1.20.0
type CommandExecutor interface {
CommandContext(ctx context.Context, name string, arg ...string) *exec.Cmd
}
CommandExecutor define uma interface para executar comandos do sistema. Isso permite mockar a execução nos testes.
type CommandHandler ¶
type CommandHandler struct {
// contains filtered or unexported fields
}
func NewCommandHandler ¶
func NewCommandHandler(cli *ChatCLI) *CommandHandler
func (*CommandHandler) HandleCommand ¶
func (ch *CommandHandler) HandleCommand(userInput string) bool
HandleCommand processa comandos do sistema
type CommandOutput ¶
type CommandOutput struct {
CommandBlock CommandBlock
Output string
ErrorMsg string
}
type HistoryManager ¶
type HistoryManager struct {
// contains filtered or unexported fields
}
func NewHistoryManager ¶
func NewHistoryManager(logger *zap.Logger) *HistoryManager
func (*HistoryManager) AppendAndRotateHistory ¶ added in v1.19.1
func (hm *HistoryManager) AppendAndRotateHistory(newCommands []string) error
AppendAndRotateHistory salva o histórico no arquivo e faz backup se o tamanho exceder o limite
func (*HistoryManager) LoadHistory ¶
func (hm *HistoryManager) LoadHistory() ([]string, error)
LoadHistory carrega o histórico do arquivo
type Liner ¶
type Liner interface {
Prompt(string) (string, error)
Close() error
SetCtrlCAborts(bool)
AppendHistory(string)
SetCompleter(liner.Completer)
}
Adicione a interface Liner
type Logger ¶
type Logger interface {
Info(msg string, fields ...zap.Field)
Error(msg string, fields ...zap.Field)
Warn(msg string, fields ...zap.Field)
Sync() error
}
Logger interface para facilitar a testabilidade
type MultilineInputManager ¶ added in v1.20.1
type MultilineInputManager struct {
// contains filtered or unexported fields
}
MultilineInputManager gerencia entrada de múltiplas linhas
func NewMultilineInputManager ¶ added in v1.20.1
func NewMultilineInputManager() *MultilineInputManager
NewMultilineInputManager cria um novo gerenciador de entrada multilinha
func (*MultilineInputManager) ClearBuffer ¶ added in v1.20.1
func (m *MultilineInputManager) ClearBuffer()
ClearBuffer limpa o buffer interno
func (*MultilineInputManager) GetMultilineInput ¶ added in v1.20.1
func (m *MultilineInputManager) GetMultilineInput() (string, bool)
GetMultilineInput garante restauração do terminal e lida corretamente com /mcancel
func (*MultilineInputManager) IsMultilineMode ¶ added in v1.20.1
func (m *MultilineInputManager) IsMultilineMode() bool
IsMultilineMode retorna se está em modo multilinha
func (*MultilineInputManager) Reset ¶ added in v1.20.1
func (m *MultilineInputManager) Reset()
Reset reseta completamente o estado do gerenciador
func (*MultilineInputManager) StartMultilineMode ¶ added in v1.20.1
func (m *MultilineInputManager) StartMultilineMode()
StartMultilineMode com texto de cancelamento corrigido (/mcancel)
type OSCommandExecutor ¶ added in v1.20.0
type OSCommandExecutor struct{}
OSCommandExecutor é a implementação real que usa o pacote os/exec.
func (*OSCommandExecutor) CommandContext ¶ added in v1.20.0
type Options ¶ added in v1.16.0
type Options struct {
// Geral
Version bool // --version | -v
Help bool // --help | -h
// Modo one-shot
Prompt string // -p | --prompt
Provider string // --provider
Model string // --model
Timeout time.Duration // --timeout
NoAnim bool // --no-anim
PromptFlagUsed bool // indica se -p/--prompt foi passado explicitamente
AgentAutoExec bool // --agent-auto-exec
}
Options representa as flags suportadas pelo binário
func NewFlagSet ¶ added in v1.16.0
NewFlagSet cria um FlagSet isolado e as Options para parsing
type SourceType ¶
type SourceType int
const ( SourceTypeUserInput SourceType = iota SourceTypeFile SourceTypeCommandOutput )