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
* ChatCLI - Persona Command Handler * 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
- Variables
- func AgentMaxTurns() int
- 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) CancelOperation()
- func (cli *ChatCLI) GetContextCommands() []prompt.Suggest
- func (cli *ChatCLI) GetInternalCommands() []prompt.Suggest
- func (cli *ChatCLI) HandleOneShotOrFatal(ctx context.Context, opts *Options) bool
- func (cli *ChatCLI) IsExecuting() bool
- func (cli *ChatCLI) PrintWelcomeScreen()
- func (cli *ChatCLI) RunAgentOnce(ctx context.Context, input string, autoExecute bool) error
- func (cli *ChatCLI) RunCoderOnce(ctx context.Context, input string) error
- func (cli *ChatCLI) RunOnce(ctx context.Context, input string, disableAnimation bool, rawOutput bool) error
- func (cli *ChatCLI) SetWatching(active bool, statusFunc func() string)
- func (cli *ChatCLI) Start(ctx context.Context)
- func (cli *ChatCLI) StartWatcher(cfg k8s.WatchConfig) error
- func (cli *ChatCLI) StopWatcher()
- type CommandBlock
- type CommandContextInfo
- type CommandHandler
- type CommandOutput
- type CompactConfig
- type ContextHandler
- type ExecutionProfile
- type FileChunk
- type HistoryCompactor
- func (hc *HistoryCompactor) CharBudget(cfg CompactConfig) int
- func (hc *HistoryCompactor) Compact(ctx context.Context, history []models.Message, llmClient client.LLMClient, ...) ([]models.Message, error)
- func (hc *HistoryCompactor) GenerateModeSummary(ctx context.Context, history []models.Message, llmClient client.LLMClient, ...) string
- func (hc *HistoryCompactor) NeedsCompaction(history []models.Message, cfg CompactConfig) bool
- type HistoryManager
- type InteractionState
- type Logger
- type MessageTrimmer
- type Options
- type PersonaHandler
- func (h *PersonaHandler) AttachAgent(name string)
- func (h *PersonaHandler) DetachAgent(name string)
- func (h *PersonaHandler) GetManager() *persona.Manager
- func (h *PersonaHandler) HandleCommand(userInput string)
- func (h *PersonaHandler) ListAgents()
- func (h *PersonaHandler) ListSkills()
- func (h *PersonaHandler) LoadAgent(name string)
- func (h *PersonaHandler) ShowActive(full bool)
- func (h *PersonaHandler) ShowAgentStatus()
- func (h *PersonaHandler) ShowAttachedAgents()
- func (h *PersonaHandler) ShowHelp()
- func (h *PersonaHandler) UnloadAgent()
- func (h *PersonaHandler) UnloadAllAgents()
- type SessionData
- type SessionManager
- func (sm *SessionManager) DeleteSession(name string) error
- func (sm *SessionManager) ListSessions() ([]string, error)
- func (sm *SessionManager) LoadSession(name string) ([]models.Message, error)
- func (sm *SessionManager) LoadSessionV2(name string) (*SessionData, error)
- func (sm *SessionManager) SaveSession(name string, history []models.Message) error
- func (sm *SessionManager) SaveSessionV2(name string, sd *SessionData) error
- type SourceType
Constants ¶
const ( SourceTypeUserInput = agent.SourceTypeUserInput SourceTypeFile = agent.SourceTypeFile SourceTypeCommandOutput = agent.SourceTypeCommandOutput )
Constantes re-exportadas
const ( StateNormal InteractionState = iota StateSwitchingProvider StateProcessing StateAgentMode ProfileNormal ExecutionProfile = iota ProfileAgent ProfileCoder )
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
const AgentFormatInstructions = `` /* 1057-byte string literal not displayed */
AgentFormatInstructions contains format instructions for /agent mode (used when a persona is active - combined with persona + these instructions)
const CoderFormatInstructions = `` /* 1428-byte string literal not displayed */
CoderFormatInstructions contains ONLY the format instructions for /coder mode (used when a persona is active - combined with persona + these instructions)
const CoderSystemPrompt = `You are a senior software engineer operating in ChatCLI /coder mode.
## MANDATORY RESPONSE FORMAT
Every response MUST follow this exact structure:
1. Start with a <reasoning> block (2-6 lines) containing:
- Your analysis of what needs to be done
- A numbered task list (1., 2., 3.)
- Mark completed tasks with [✓]
- On error, create a NEW replanned task list
2. Then emit one or more <tool_call> tags using ONLY the @coder tool:
<tool_call name="@coder" args='{"cmd":"SUBCOMMAND","args":{...}}' />
## TOOL CALL SYNTAX
ALWAYS use JSON format for args. The JSON MUST be on a SINGLE LINE (no line breaks inside args).
### Reading files
<tool_call name="@coder" args='{"cmd":"read","args":{"file":"path/to/file.go"}}' />
<tool_call name="@coder" args='{"cmd":"read","args":{"file":"main.go","start":10,"end":50}}' />
### Writing files
For multiline content, encode as base64:
<tool_call name="@coder" args='{"cmd":"write","args":{"file":"path/to/file.go","content":"BASE64_ENCODED_CONTENT","encoding":"base64"}}' />
For simple single-line content:
<tool_call name="@coder" args='{"cmd":"write","args":{"file":"hello.txt","content":"Hello World"}}' />
### Patching files (search/replace)
For multiline search/replace, use base64 encoding:
<tool_call name="@coder" args='{"cmd":"patch","args":{"file":"main.go","search":"BASE64_OLD","replace":"BASE64_NEW","encoding":"base64"}}' />
For simple text patches:
<tool_call name="@coder" args='{"cmd":"patch","args":{"file":"main.go","search":"old text","replace":"new text"}}' />
### Patching with unified diff
<tool_call name="@coder" args='{"cmd":"patch","args":{"file":"main.go","diff":"BASE64_UNIFIED_DIFF","diff-encoding":"base64"}}' />
### Directory tree
<tool_call name="@coder" args='{"cmd":"tree","args":{"dir":".","max-depth":4}}' />
### Searching
<tool_call name="@coder" args='{"cmd":"search","args":{"term":"functionName","dir":"./src","glob":"*.go"}}' />
### Executing commands
<tool_call name="@coder" args='{"cmd":"exec","args":{"cmd":"go build ./...","dir":"."}}' />
### Git operations
<tool_call name="@coder" args='{"cmd":"git-status","args":{"dir":"."}}' />
<tool_call name="@coder" args='{"cmd":"git-diff","args":{"staged":true}}' />
<tool_call name="@coder" args='{"cmd":"git-log","args":{"limit":10}}' />
### Running tests
<tool_call name="@coder" args='{"cmd":"test","args":{"dir":"."}}' />
### Rollback/Clean
<tool_call name="@coder" args='{"cmd":"rollback","args":{"file":"main.go"}}' />
<tool_call name="@coder" args='{"cmd":"clean","args":{"dir":".","force":true}}' />
## CRITICAL RULES
1. Use the @coder tool via <tool_call> for direct operations. When multi-agent orchestration is available, you may also use <agent_call> to delegate complex subtasks to specialized agents.
2. NEVER use code blocks (` + "```" + `). ONLY use <tool_call> or <agent_call> tags.
3. Args MUST be a single line. NEVER break args across multiple lines.
4. For multiline file content in write/patch, ALWAYS use base64 encoding.
5. Use single quotes around the JSON args value: args='{"cmd":...}'
6. NEVER use backslash to escape quotes inside args. Use single quotes around JSON.
7. BATCH multiple tool calls in one response when possible to save turns.
- Example: tree + read in the same response to explore
- Example: write + exec to create and test
- Do NOT batch if the second call depends on the first call's result.
8. If a tool in the batch fails, execution stops there.
## AVAILABLE SUBCOMMANDS
tree, search, read, write, patch, exec, git-status, git-diff, git-log, git-changed, git-branch, test, rollback, clean.
## ALTERNATIVE CLI-STYLE SYNTAX (also supported)
<tool_call name="@coder" args="read --file main.go --start 1 --end 50" />
<tool_call name="@coder" args="exec --cmd 'go test ./...'" />
`
CoderSystemPrompt is the complete system prompt for /coder mode (used when NO persona is active). Written in English for maximum AI compliance across all model families.
Variables ¶
var CommandFlags = map[string]map[string][]prompt.Suggest{
"@file": {
"--mode": {
{Text: "full", Description: "Processa o conteúdo completo (padrão, trunca se necessário)"},
{Text: "summary", Description: "Gera resumo estrutural (árvore de arquivos, tamanhos, sem conteúdo)"},
{Text: "chunked", Description: "Divide grandes projetos em pedaços gerenciáveis (use /nextchunk para prosseguir)"},
{Text: "smart", Description: "Seleciona arquivos relevantes com base no seu prompt (IA decide)"},
},
},
"@command": {
"-i": {},
"--ai": {},
},
"/switch": {
"--model": {},
"--max-tokens": {},
"--realm": {},
"--agent-id": {},
},
"/session": {
"new": {},
"save": {},
"load": {},
"list": {},
"delete": {},
},
"/context": {
"create": {},
"attach": {},
"detach": {},
"list": {},
"delete": {},
"show": {},
"merge": {},
"attached": {},
"export": {},
"import": {},
"metrics": {},
"help": {},
},
"/connect": {
"--token": {},
"--provider": {},
"--model": {},
"--llm-key": {},
"--use-local-auth": {},
"--tls": {},
"--ca-cert": {},
"--client-id": {},
"--client-key": {},
"--realm": {},
"--agent-id": {},
"--ollama-url": {},
},
"/agent": {
"list": {},
"load": {},
"attach": {},
"detach": {},
"skills": {},
"show": {
{Text: "--full", Description: "Mostra detalhes completos do agente"},
},
"status": {},
"off": {},
"help": {},
},
}
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
func (*AgentMode) Run ¶
func (a *AgentMode) Run(ctx context.Context, query string, additionalContext string, systemPromptOverride string) error
Run inicia o modo agente com uma consulta do usuário, utilizando um loop de Raciocínio-Ação (ReAct). Agora aceita systemPromptOverride para definir personas específicas (ex: Coder).
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
UserMaxTokens int
// K8s watcher context injection
WatcherContextFunc func() string // returns K8s context to prepend to LLM prompts
// 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) CancelOperation ¶ added in v1.22.0
func (cli *ChatCLI) CancelOperation()
CancelOperation cancela a operação atual se houver uma
func (*ChatCLI) GetContextCommands ¶ added in v1.37.0
GetContextCommands retorna a lista de sugestões para comandos com @
func (*ChatCLI) GetInternalCommands ¶ added in v1.37.0
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) IsExecuting ¶ added in v1.22.0
IsExecuting retorna true se uma operação está em andamento
func (*ChatCLI) PrintWelcomeScreen ¶ added in v1.18.0
func (cli *ChatCLI) PrintWelcomeScreen()
PrintWelcomeScreen exibe a tela de boas-vindas completa e traduzida.
func (*ChatCLI) RunAgentOnce ¶ added in v1.19.0
RunAgentOnce executa o modo agente de forma não-interativa (one-shot)
func (*ChatCLI) RunCoderOnce ¶ added in v1.42.0
RunCoderOnce executa o modo coder de forma não-interativa (one-shot), mas mantendo o loop ReAct do AgentMode (com tool_calls/plugins).
func (*ChatCLI) SetWatching ¶ added in v1.55.0
SetWatching configures the K8s watcher state for the CLI.
func (*ChatCLI) StartWatcher ¶ added in v1.56.0
func (cli *ChatCLI) StartWatcher(cfg k8s.WatchConfig) error
StartWatcher creates and starts a K8s watcher in background from interactive mode.
func (*ChatCLI) StopWatcher ¶ added in v1.56.0
func (cli *ChatCLI) StopWatcher()
StopWatcher stops the running K8s watcher if any.
type CommandBlock ¶
type CommandBlock = agent.CommandBlock
Aliases de tipos para manter compatibilidade
type CommandContextInfo ¶
type CommandContextInfo = agent.CommandContextInfo
Aliases de tipos para manter compatibilidade
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
type CommandOutput ¶
type CommandOutput = agent.CommandOutput
Aliases de tipos para manter compatibilidade
type CompactConfig ¶ added in v1.65.2
type CompactConfig struct {
Provider string
Model string
BudgetRatio float64 // fraction of context window to use (default 0.75)
MinKeepRecent int // minimum recent messages to keep verbatim (default 10)
CharsPerToken int // character-to-token ratio estimate (default 4)
}
CompactConfig holds parameters for a compaction operation.
func DefaultCompactConfig ¶ added in v1.65.2
func DefaultCompactConfig(provider, model string) CompactConfig
DefaultCompactConfig returns sensible defaults for chat mode.
type ContextHandler ¶ added in v1.33.0
type ContextHandler struct {
// contains filtered or unexported fields
}
ContextHandler gerencia comandos relacionados a contextos
func NewContextHandler ¶ added in v1.33.0
func NewContextHandler(logger *zap.Logger) (*ContextHandler, error)
NewContextHandler cria um novo handler de contextos
func (*ContextHandler) GetManager ¶ added in v1.33.0
func (h *ContextHandler) GetManager() *ctxmgr.Manager
GetManager retorna o gerenciador de contextos
func (*ContextHandler) HandleContextCommand ¶ added in v1.33.0
func (h *ContextHandler) HandleContextCommand(sessionID, input string) error
HandleContextCommand processa comandos /context
type ExecutionProfile ¶ added in v1.43.0
type ExecutionProfile int
type HistoryCompactor ¶ added in v1.65.2
type HistoryCompactor struct {
// contains filtered or unexported fields
}
HistoryCompactor manages conversation history size through a 3-level pipeline:
Level 1: Near-lossless trimming (strip reasoning, compact XML, dedup) Level 2: Structured summarization (extract facts, not prose) Level 3: Emergency truncation (last resort)
func NewHistoryCompactor ¶ added in v1.65.2
func NewHistoryCompactor(logger *zap.Logger) *HistoryCompactor
NewHistoryCompactor creates a new HistoryCompactor with its embedded trimmer.
func (*HistoryCompactor) CharBudget ¶ added in v1.65.2
func (hc *HistoryCompactor) CharBudget(cfg CompactConfig) int
CharBudget returns the character budget based on the model's context window.
func (*HistoryCompactor) Compact ¶ added in v1.65.2
func (hc *HistoryCompactor) Compact( ctx context.Context, history []models.Message, llmClient client.LLMClient, cfg CompactConfig, ) ([]models.Message, error)
Compact runs the 3-level compaction pipeline. Each level is progressively more aggressive. Most of the time, Level 1 (trim) suffices.
func (*HistoryCompactor) GenerateModeSummary ¶ added in v1.65.2
func (hc *HistoryCompactor) GenerateModeSummary( ctx context.Context, history []models.Message, llmClient client.LLMClient, modeName string, ) string
GenerateModeSummary creates a structured summary of a mode session (agent/coder) to be stored as shared memory when transitioning back to chat mode.
func (*HistoryCompactor) NeedsCompaction ¶ added in v1.65.2
func (hc *HistoryCompactor) NeedsCompaction(history []models.Message, cfg CompactConfig) bool
NeedsCompaction returns true if the total character count exceeds the budget.
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) GetHistoryFilePath ¶ added in v1.47.4
func (hm *HistoryManager) GetHistoryFilePath() string
GetHistoryFilePath retorna o caminho atual do arquivo de histórico
func (*HistoryManager) LoadHistory ¶
func (hm *HistoryManager) LoadHistory() ([]string, error)
LoadHistory carrega o histórico do arquivo
type InteractionState ¶ added in v1.22.0
type InteractionState int
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 MessageTrimmer ¶ added in v1.65.2
type MessageTrimmer struct {
// contains filtered or unexported fields
}
MessageTrimmer performs near-lossless trimming of conversation messages to reduce token usage without losing semantic information.
func NewMessageTrimmer ¶ added in v1.65.2
func NewMessageTrimmer(logger *zap.Logger) *MessageTrimmer
NewMessageTrimmer creates a new MessageTrimmer.
func (*MessageTrimmer) TrimHistory ¶ added in v1.65.2
func (t *MessageTrimmer) TrimHistory(history []models.Message) []models.Message
TrimHistory performs near-lossless trimming on all messages in the history. It preserves system messages, user-authored messages, and summary messages intact.
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
Raw bool // --raw
PromptFlagUsed bool // indica se -p/--prompt foi passado explicitamente
AgentAutoExec bool // --agent-auto-exec
MaxTokens int // --max-tokens
Realm string // --realm
AgentID string // --agent-id
}
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 PersonaHandler ¶ added in v1.48.0
type PersonaHandler struct {
// contains filtered or unexported fields
}
PersonaHandler handles agent/persona commands
func NewPersonaHandler ¶ added in v1.48.0
func NewPersonaHandler(logger *zap.Logger) *PersonaHandler
NewPersonaHandler creates a new persona handler
func (*PersonaHandler) AttachAgent ¶ added in v1.49.0
func (h *PersonaHandler) AttachAgent(name string)
AttachAgent adds an agent to active pool
func (*PersonaHandler) DetachAgent ¶ added in v1.49.0
func (h *PersonaHandler) DetachAgent(name string)
DetachAgent removes an agent from active pool
func (*PersonaHandler) GetManager ¶ added in v1.48.0
func (h *PersonaHandler) GetManager() *persona.Manager
GetManager returns the underlying persona manager
func (*PersonaHandler) HandleCommand ¶ added in v1.48.0
func (h *PersonaHandler) HandleCommand(userInput string)
HandleCommand processes /persona commands (retrocompatibilidade) Redireciona para os comandos /agent equivalentes
func (*PersonaHandler) ListAgents ¶ added in v1.48.0
func (h *PersonaHandler) ListAgents()
ListAgents shows all available agents
func (*PersonaHandler) ListSkills ¶ added in v1.48.0
func (h *PersonaHandler) ListSkills()
ListSkills shows all available skills
func (*PersonaHandler) LoadAgent ¶ added in v1.48.0
func (h *PersonaHandler) LoadAgent(name string)
LoadAgent loads an agent by name
func (*PersonaHandler) ShowActive ¶ added in v1.48.0
func (h *PersonaHandler) ShowActive(full bool)
ShowActive shows details of the currently active agent
func (*PersonaHandler) ShowAgentStatus ¶ added in v1.48.0
func (h *PersonaHandler) ShowAgentStatus()
ShowAgentStatus shows current agent/persona status (chamado por /agent sem argumentos)
func (*PersonaHandler) ShowAttachedAgents ¶ added in v1.49.0
func (h *PersonaHandler) ShowAttachedAgents()
ShowAttachedAgents shows only the list of attached agents without prompt details
func (*PersonaHandler) ShowHelp ¶ added in v1.48.0
func (h *PersonaHandler) ShowHelp()
ShowHelp shows usage information for /agent subcommands
func (*PersonaHandler) UnloadAgent ¶ added in v1.48.0
func (h *PersonaHandler) UnloadAgent()
UnloadAgent deactivates the current agent
func (*PersonaHandler) UnloadAllAgents ¶ added in v1.49.0
func (h *PersonaHandler) UnloadAllAgents()
UnloadAllAgents deactivates all agents
type SessionData ¶ added in v1.65.2
type SessionData = models.SessionData
SessionData is an alias for the shared models.SessionData type. Kept for local convenience within the cli package.
type SessionManager ¶ added in v1.23.0
type SessionManager struct {
// contains filtered or unexported fields
}
SessionManager gerencia o salvamento e carregamento de sessões de conversa.
func NewSessionManager ¶ added in v1.23.0
func NewSessionManager(logger *zap.Logger) (*SessionManager, error)
NewSessionManager cria uma nova instância do SessionManager.
func (*SessionManager) DeleteSession ¶ added in v1.23.0
func (sm *SessionManager) DeleteSession(name string) error
DeleteSession apaga um arquivo de sessão.
func (*SessionManager) ListSessions ¶ added in v1.23.0
func (sm *SessionManager) ListSessions() ([]string, error)
ListSessions lista todas as sessões salvas.
func (*SessionManager) LoadSession ¶ added in v1.23.0
func (sm *SessionManager) LoadSession(name string) ([]models.Message, error)
LoadSession carrega o histórico de uma conversa de um arquivo JSON. Mantém assinatura original para compatibilidade com remote client. Retorna apenas o chatHistory para uso legado.
func (*SessionManager) LoadSessionV2 ¶ added in v1.65.2
func (sm *SessionManager) LoadSessionV2(name string) (*SessionData, error)
LoadSessionV2 carrega uma sessão completa com suporte a formato v2 e legacy.
func (*SessionManager) SaveSession ¶ added in v1.23.0
func (sm *SessionManager) SaveSession(name string, history []models.Message) error
SaveSession salva o histórico da conversa em um arquivo JSON. Mantém assinatura original para compatibilidade com remote client.
func (*SessionManager) SaveSessionV2 ¶ added in v1.65.2
func (sm *SessionManager) SaveSessionV2(name string, sd *SessionData) error
SaveSessionV2 salva uma sessão completa com históricos escopados.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
* 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 |
|
Go Multi-Agent - Metrics Display
|
Go Multi-Agent - Metrics Display |
|
* ChatCLI - Paste Detection * cli/paste/detector.go * Copyright (c) 2024 Edilson Freitas * License: MIT
|
* ChatCLI - Paste Detection * cli/paste/detector.go * Copyright (c) 2024 Edilson Freitas * License: MIT |