Documentation
¶
Index ¶
- func DeleteSession(name string) error
- func ExpandGlob(pattern string) ([]string, error)
- func FormatFileSize(bytes int64) string
- func GetParentOptions(path string) []string
- func ListSessions() ([]string, error)
- func SaveApprovedDirs(dirs *ApprovedDirs) error
- func SaveCurrentSession(session *Session) error
- func SaveSession(session *Session, filename string) error
- type ApprovedDirs
- type ChatMessage
- type Command
- type CommandSource
- type CompletionsModel
- func (c *CompletionsModel) Hide()
- func (c *CompletionsModel) IsVisible() bool
- func (c *CompletionsModel) Selected() *Command
- func (c *CompletionsModel) SetItems(items []Command)
- func (c *CompletionsModel) SetQuery(query string)
- func (c *CompletionsModel) SetSize(width, height int)
- func (c *CompletionsModel) Show()
- func (c *CompletionsModel) Update(msg tea.Msg) (*CompletionsModel, tea.Cmd)
- func (c *CompletionsModel) View() string
- type DialogItem
- type DialogModel
- func (d *DialogModel) Close()
- func (d *DialogModel) Cursor() int
- func (d *DialogModel) GetDirApprovalPath() string
- func (d *DialogModel) IsOpen() bool
- func (d *DialogModel) ItemAt(idx int) *DialogItem
- func (d *DialogModel) Query() string
- func (d *DialogModel) Selected() *DialogItem
- func (d *DialogModel) SetCursor(pos int)
- func (d *DialogModel) SetQuery(query string)
- func (d *DialogModel) SetSize(width, height int)
- func (d *DialogModel) ShowDirApproval(filePath string, options []string)
- func (d *DialogModel) ShowMCPPicker(mcpManager *mcp.Manager)
- func (d *DialogModel) ShowModelPicker(currentModel string, providers []ProviderInfo)
- func (d *DialogModel) ShowSessionList(sessions []string, currentSession string)
- func (d *DialogModel) Type() DialogType
- func (d *DialogModel) Update(msg tea.Msg) (*DialogModel, tea.Cmd)
- func (d *DialogModel) View() string
- type DialogType
- type DirApprovalRequest
- type FileAttachment
- type FileCompletion
- type FileCompletionSource
- type KeyMap
- type MessageRole
- type Model
- type ProviderInfo
- type Session
- type Subcommand
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExpandGlob ¶
ExpandGlob expands a glob pattern to matching files
func FormatFileSize ¶
FormatFileSize returns a human-readable file size
func GetParentOptions ¶
GetParentOptions returns the directory and its parents for approval choices
func ListSessions ¶
ListSessions returns all saved session names
func SaveApprovedDirs ¶
func SaveApprovedDirs(dirs *ApprovedDirs) error
SaveApprovedDirs saves the approved directories to disk
func SaveCurrentSession ¶
SaveCurrentSession saves the current session for auto-restore
func SaveSession ¶
SaveSession saves a session to disk
Types ¶
type ApprovedDirs ¶
type ApprovedDirs struct {
ApprovedAt time.Time `json:"approved_at"`
Directories []string `json:"directories"`
}
ApprovedDirs stores the list of approved directories
func LoadApprovedDirs ¶
func LoadApprovedDirs() (*ApprovedDirs, error)
LoadApprovedDirs loads the approved directories from disk
func (*ApprovedDirs) AddDirectory ¶
func (d *ApprovedDirs) AddDirectory(dir string) error
AddDirectory adds a directory to the approved list
func (*ApprovedDirs) IsPathApproved ¶
func (d *ApprovedDirs) IsPathApproved(path string) bool
IsPathApproved checks if a path is within an approved directory
func (*ApprovedDirs) RemoveDirectory ¶
func (d *ApprovedDirs) RemoveDirectory(dir string) error
RemoveDirectory removes a directory from the approved list
type ChatMessage ¶
type ChatMessage struct {
Role MessageRole `json:"role"`
Content string `json:"content"`
Files []string `json:"files,omitempty"` // Attached files for user messages
Tokens int `json:"tokens,omitempty"` // Token count for assistant messages
DurationMs int64 `json:"duration_ms,omitempty"` // Response time for assistant messages
WebSearch bool `json:"web_search,omitempty"` // Whether web search was used
CreatedAt time.Time `json:"created_at"`
}
ChatMessage represents a single message in the conversation
func NewAssistantMessage ¶
func NewAssistantMessage(content string, tokens int, durationMs int64, webSearch bool) ChatMessage
NewAssistantMessage creates a new assistant message
func NewUserMessage ¶
func NewUserMessage(content string, files []string) ChatMessage
NewUserMessage creates a new user message
type Command ¶
type Command struct {
Name string
Aliases []string
Description string
Usage string
Subcommands []Subcommand // Optional subcommands
}
Command represents a slash command
func FilterCommands ¶
FilterCommands returns commands matching the query using fuzzy search If query contains a space (e.g., "mcp "), it returns subcommands for that command
type CommandSource ¶
type CommandSource []Command
CommandSource implements fuzzy.Source for command searching
func (CommandSource) Len ¶
func (c CommandSource) Len() int
func (CommandSource) String ¶
func (c CommandSource) String(i int) string
type CompletionsModel ¶
type CompletionsModel struct {
// contains filtered or unexported fields
}
CompletionsModel handles the command completions popup
func NewCompletionsModel ¶
func NewCompletionsModel(styles *ui.Styles) *CompletionsModel
NewCompletionsModel creates a new completions model
func (*CompletionsModel) IsVisible ¶
func (c *CompletionsModel) IsVisible() bool
IsVisible returns whether the popup is visible
func (*CompletionsModel) Selected ¶
func (c *CompletionsModel) Selected() *Command
Selected returns the currently selected command
func (*CompletionsModel) SetItems ¶
func (c *CompletionsModel) SetItems(items []Command)
SetItems sets custom completion items (for dynamic completions like server names)
func (*CompletionsModel) SetQuery ¶
func (c *CompletionsModel) SetQuery(query string)
SetQuery updates the filter query
func (*CompletionsModel) SetSize ¶
func (c *CompletionsModel) SetSize(width, height int)
SetSize updates the dimensions
func (*CompletionsModel) Show ¶
func (c *CompletionsModel) Show()
Show displays the completions popup
func (*CompletionsModel) Update ¶
func (c *CompletionsModel) Update(msg tea.Msg) (*CompletionsModel, tea.Cmd)
Update handles messages
func (*CompletionsModel) View ¶
func (c *CompletionsModel) View() string
View renders the completions popup
type DialogItem ¶
DialogItem represents an item in a dialog list
type DialogModel ¶
type DialogModel struct {
// contains filtered or unexported fields
}
DialogModel handles modal dialogs
func NewDialogModel ¶
func NewDialogModel(styles *ui.Styles) *DialogModel
NewDialogModel creates a new dialog model
func (*DialogModel) Cursor ¶
func (d *DialogModel) Cursor() int
Cursor returns the current cursor position
func (*DialogModel) GetDirApprovalPath ¶
func (d *DialogModel) GetDirApprovalPath() string
GetDirApprovalPath returns the path that triggered the approval request
func (*DialogModel) IsOpen ¶
func (d *DialogModel) IsOpen() bool
IsOpen returns whether a dialog is open
func (*DialogModel) ItemAt ¶
func (d *DialogModel) ItemAt(idx int) *DialogItem
ItemAt returns the item at the given index (0-based)
func (*DialogModel) Query ¶
func (d *DialogModel) Query() string
Query returns the current filter query
func (*DialogModel) Selected ¶
func (d *DialogModel) Selected() *DialogItem
Selected returns the currently highlighted item
func (*DialogModel) SetCursor ¶
func (d *DialogModel) SetCursor(pos int)
SetCursor sets the cursor position, clamping to valid range
func (*DialogModel) SetQuery ¶
func (d *DialogModel) SetQuery(query string)
SetQuery updates the filter query for model picker or MCP picker
func (*DialogModel) SetSize ¶
func (d *DialogModel) SetSize(width, height int)
SetSize updates the dimensions
func (*DialogModel) ShowDirApproval ¶
func (d *DialogModel) ShowDirApproval(filePath string, options []string)
ShowDirApproval opens the directory approval dialog
func (*DialogModel) ShowMCPPicker ¶
func (d *DialogModel) ShowMCPPicker(mcpManager *mcp.Manager)
ShowMCPPicker opens the MCP server picker dialog
func (*DialogModel) ShowModelPicker ¶
func (d *DialogModel) ShowModelPicker(currentModel string, providers []ProviderInfo)
ShowModelPicker opens the model picker dialog
func (*DialogModel) ShowSessionList ¶
func (d *DialogModel) ShowSessionList(sessions []string, currentSession string)
ShowSessionList opens the session list dialog
func (*DialogModel) Type ¶
func (d *DialogModel) Type() DialogType
Type returns the current dialog type
func (*DialogModel) Update ¶
func (d *DialogModel) Update(msg tea.Msg) (*DialogModel, tea.Cmd)
Update handles messages
type DialogType ¶
type DialogType int
DialogType represents the type of dialog
const ( DialogNone DialogType = iota DialogModelPicker DialogSessionList DialogDirApproval DialogMCPPicker )
type DirApprovalRequest ¶
type DirApprovalRequest struct {
Path string // The file path that triggered the request
Options []string // Directory options to approve
OnApprove func(dir string)
OnDeny func()
}
DirApprovalRequest represents a pending directory approval request
type FileAttachment ¶
FileAttachment represents an attached file
func AttachFile ¶
func AttachFile(path string) (*FileAttachment, error)
AttachFile reads a file and creates an attachment
type FileCompletion ¶
FileCompletion represents a file path completion item
func ListFiles ¶
func ListFiles(dir string, query string) []FileCompletion
ListFiles returns files in a directory for completion
type FileCompletionSource ¶
type FileCompletionSource []FileCompletion
FileCompletionSource implements fuzzy.Source for file completions
func (FileCompletionSource) Len ¶
func (f FileCompletionSource) Len() int
func (FileCompletionSource) String ¶
func (f FileCompletionSource) String(i int) string
type KeyMap ¶
type KeyMap struct {
// Global
Quit key.Binding
Help key.Binding
Commands key.Binding
// Editor
Send key.Binding
Newline key.Binding
NewlineAlt key.Binding
ClearLine key.Binding
DeleteWord key.Binding
Cancel key.Binding
HistoryUp key.Binding
HistoryDown key.Binding
Tab key.Binding
// History navigation
ScrollUp key.Binding
ScrollDown key.Binding
PageUp key.Binding
PageDown key.Binding
GoToTop key.Binding
GoToBottom key.Binding
Copy key.Binding
// Shortcuts
SwitchModel key.Binding
ToggleWeb key.Binding
AttachFile key.Binding
Clear key.Binding
NewSession key.Binding
MCPPicker key.Binding
}
KeyMap defines keybindings for the chat TUI
type MessageRole ¶
type MessageRole string
MessageRole represents who sent the message
const ( RoleUser MessageRole = "user" RoleAssistant MessageRole = "assistant" )
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model is the main chat TUI model
func New ¶
func New(cfg *config.Config, provider llm.Provider, engine *llm.Engine, modelName string, mcpManager *mcp.Manager, maxTurns int, forceExternalSearch bool, searchEnabled bool, localTools []string, showStats bool) *Model
New creates a new chat model
func (*Model) ExecuteCommand ¶
ExecuteCommand handles slash command execution
type ProviderInfo ¶
ProviderInfo holds provider and model information
func GetAvailableProviders ¶
func GetAvailableProviders(cfg *config.Config) []ProviderInfo
GetAvailableProviders returns providers with their models in consistent order If cfg is provided, custom configured providers are also included
type Session ¶
type Session struct {
Name string `json:"name"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Provider string `json:"provider"`
Model string `json:"model"`
Messages []ChatMessage `json:"messages"`
}
Session represents a saved chat session
func LoadCurrentSession ¶
LoadCurrentSession loads the current session if it exists
func LoadSession ¶
LoadSession loads a session from disk
func NewSession ¶
NewSession creates a new empty session
type Subcommand ¶
Subcommand represents a subcommand of a slash command