Documentation
¶
Overview ¶
Package tui provides the interactive terminal user interface for the Echoryn chat command.
It integrates reeflective/readline for line editing, charmbracelet glamour/lipgloss/termenv for rendering, and a pluggable slash-command framework. The design favours scroll-back friendly output (no alt-screen) and aims for a Claude Code-like user experience.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChatMessage ¶
ChatMessage is the message format exchanged with the Hivemind server.
type ChatStreamFunc ¶
type ChatStreamFunc func( ctx context.Context, messages []ChatMessage, cb StreamCallback, toolCb ToolCallCallback, ) (string, error)
ChatStreamFunc is the function signature of HivemindClient.ChatStream. It is used by ClientAdapter to avoid a direct import cycle between the chat package and the tui package.
type Client ¶
type Client interface {
// ChatStream sends messages and streams the response.
// cb is called for each text delta; toolCb for each tool invocation.
// Returns the full assistant reply.
ChatStream(ctx context.Context, messages []ChatMessage, cb StreamCallback, toolCb ToolCallCallback) (string, error)
// Model returns the model name.
Model() string
// BaseURL returns the server address.
BaseURL() string
// SessionKey returns the session identifier.
SessionKey() string
}
Client defines the interface the TUI needs from the chat backend. This decouples the TUI from the concrete HTTP client implementation, making it testable and extensible.
type ClientAdapter ¶
type ClientAdapter struct {
ChatStreamFn ChatStreamFunc
ModelName string
ServerURL string
Session string
}
ClientAdapter wraps the raw function pointers from the chat package's HivemindClient so that they satisfy the Client interface.
This thin adapter exists to break the import cycle:
chat → tui.Client (interface) chat → tui.ClientAdapter (creates from HivemindClient)
Without exposing HivemindClient's concrete type to the tui package.
func (*ClientAdapter) BaseURL ¶
func (a *ClientAdapter) BaseURL() string
BaseURL returns the server address.
func (*ClientAdapter) ChatStream ¶
func (a *ClientAdapter) ChatStream( ctx context.Context, messages []ChatMessage, cb StreamCallback, toolCb ToolCallCallback, ) (string, error)
ChatStream delegates to the wrapped function.
func (*ClientAdapter) Model ¶
func (a *ClientAdapter) Model() string
Model returns the configured model name.
func (*ClientAdapter) SessionKey ¶
func (a *ClientAdapter) SessionKey() string
SessionKey returns the session identifier.
type Config ¶
type Config struct {
// Prompt is the primary input prompt (default: "> ").
Prompt string
// MultilinePrompt is shown on continuation lines (default: "· ").
MultilinePrompt string
// History configures persistent command history.
History input.HistoryConfig
// RequestTimeout is the maximum duration for a single chat request.
RequestTimeout time.Duration
// TeamAPI provides the backend API for team operations (optional).
TeamAPI command.TeamAPI
}
Config holds all configurable options for the TUI.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a Config with production-ready defaults.
type Option ¶
type Option func(*Config)
Option is a functional option for configuring the TUI.
func WithHistoryFile ¶
WithHistoryFile sets the path for persistent history.
func WithRequestTimeout ¶
WithRequestTimeout sets the per-request timeout.
func WithTeamAPI ¶
WithTeamAPI sets the team API for the TUI, enabling team commands.
type StreamCallback ¶
type StreamCallback func(delta string)
StreamCallback is called for each text delta during streaming.
type TUI ¶
type TUI struct {
// contains filtered or unexported fields
}
TUI is the top-level interactive chat controller.
It owns the terminal, input reader, renderer, command registry, and the conversation message history. The [Run] method starts the main REPL loop and blocks until the user exits.
type ToolCallCallback ¶
type ToolCallCallback func(name string)
ToolCallCallback is called when a tool call is detected in the stream.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package bubbletea provides a BubbleTea-based TUI for Echoryn.
|
Package bubbletea provides a BubbleTea-based TUI for Echoryn. |
|
client
Package client provides client interfaces for the BubbleTea TUI.
|
Package client provides client interfaces for the BubbleTea TUI. |
|
components
Package markdown provides Markdown rendering for terminal output.
|
Package markdown provides Markdown rendering for terminal output. |
|
components/completion
Package completion provides auto-completion for commands and suggestions.
|
Package completion provides auto-completion for commands and suggestions. |
|
components/list
Package list provides virtualized list rendering for large datasets.
|
Package list provides virtualized list rendering for large datasets. |
|
components/markdown
Package markdown provides markdown rendering for terminal output.
|
Package markdown provides markdown rendering for terminal output. |
|
components/spinner
Package spinner provides a loading spinner component.
|
Package spinner provides a loading spinner component. |
|
components/textbuffer
Package textbuffer provides a multi-line text editor with cursor movement, history navigation, and auto-completion support.
|
Package textbuffer provides a multi-line text editor with cursor movement, history navigation, and auto-completion support. |
|
theme
Package theme provides semantic theming for the TUI.
|
Package theme provides semantic theming for the TUI. |
|
Package command provides slash command implementations for the TUI.
|
Package command provides slash command implementations for the TUI. |
|
Package input provides the user input subsystem for the TUI.
|
Package input provides the user input subsystem for the TUI. |
|
Package render provides output and rendering components for the TUI.
|
Package render provides output and rendering components for the TUI. |
|
Package terminal provides low-level terminal state management.
|
Package terminal provides low-level terminal state management. |