tui

package
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 13, 2026 License: MIT Imports: 65 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewEnhancedTextArea

func NewEnhancedTextArea() textarea.Model

Enhanced textarea with better styling

func NewEnhancedTextInput

func NewEnhancedTextInput() textinput.Model

Enhanced input with placeholder and better visual feedback

func NewEnhancedThinkingSpinner

func NewEnhancedThinkingSpinner(_ string) spinner.Model

func NewEnhancedViewport

func NewEnhancedViewport(width, height int) viewport.Model

func NewSmoothViewport

func NewSmoothViewport(width, height int) viewport.Model

func RegisterToolRenderer added in v0.1.7

func RegisterToolRenderer(name string, r ToolRenderer)

RegisterToolRenderer registers a ToolRenderer for the given tool name.

func RenderAnimatedStatus

func RenderAnimatedStatus(status string, _ int) string

func RenderBadge

func RenderBadge(text, badgeType string) string

func RenderCharacterCount

func RenderCharacterCount(current, max int) string

Render character count

func RenderCompletedThinkingText

func RenderCompletedThinkingText() string

func RenderConnectionStatus

func RenderConnectionStatus(connected bool, details string) string

func RenderCurrentTime

func RenderCurrentTime() string

func RenderCustomScrollbar

func RenderCustomScrollbar(viewportHeight, contentHeight, scrollTop int) string

func RenderEnhancedCodeBlock

func RenderEnhancedCodeBlock(content string) string

func RenderEnhancedHeader

func RenderEnhancedHeader(text string) string

func RenderEnhancedInput

func RenderEnhancedInput(input textinput.Model, focused bool) string

Render enhanced input with focus state

func RenderEnhancedStatusBar

func RenderEnhancedStatusBar(sections []string) string

func RenderEnhancedTextArea

func RenderEnhancedTextArea(textarea textarea.Model, focused bool) string

Render enhanced textarea with focus state

func RenderEnhancedThinkingText

func RenderEnhancedThinkingText(sp spinner.Model) string

func RenderInputSuggestions

func RenderInputSuggestions(suggestions []string, selectedIndex int) string

Render input suggestions

func RenderKeyHint

func RenderKeyHint(key, description string) string

func RenderKeyHints

func RenderKeyHints(hints []string) string

func RenderMessageSeparator

func RenderMessageSeparator() string

func RenderModeIndicator

func RenderModeIndicator(mode string) string

Render input mode indicator

func RenderProgressBar

func RenderProgressBar(current, total int, label string) string

func RenderScrollHint

func RenderScrollHint(direction string) string

func RenderScrollPosition

func RenderScrollPosition(current, total int) string

func RenderSectionDivider

func RenderSectionDivider() string

func RenderShadowContainer

func RenderShadowContainer(content string) string

func RenderStatus

func RenderStatus(status string, statusType string) string

func RenderStatusIndicator

func RenderStatusIndicator(status string) string

func RenderTimelineLine

func RenderTimelineLine() string

func RenderTimelineNode

func RenderTimelineNode(completed bool) string

func RenderTokenUsage

func RenderTokenUsage(current, max int, _ string) string

func Run

func Run(opts Options) error

Types

type Annotation

type Annotation struct {
	Type    string
	Label   string
	Content string
}

Annotation represents a structured annotation with type, label, and content

type ApprovalDecision added in v0.1.6

type ApprovalDecision struct {
	Disposition ApprovalDisposition
}

func NormalizeApprovalDecision added in v0.1.6

func NormalizeApprovalDecision(d ApprovalDecision) ApprovalDecision

func (ApprovalDecision) Approved added in v0.1.6

func (d ApprovalDecision) Approved() bool

type ApprovalDisposition added in v0.1.6

type ApprovalDisposition string
const (
	ApprovalApproveOnce            ApprovalDisposition = "approve_once"
	ApprovalApproveSameToolSession ApprovalDisposition = "approve_same_tool_session"
	ApprovalApproveAllSession      ApprovalDisposition = "approve_all_session"
	ApprovalDeny                   ApprovalDisposition = "deny"
)

type ApprovalHandler

type ApprovalHandler func(ApprovalRequest) (ApprovalDecision, error)

type ApprovalRequest

type ApprovalRequest struct {
	ToolName string
	Command  string
	Reason   string
}

type Event

type Event struct {
	Type          EventType
	SessionID     string
	UserInput     string
	Content       string
	ToolName      string
	ToolCallID    string
	ToolArguments string
	ToolResult    string
	Error         string
	Plan          planpkg.State
	Usage         llm.Usage
	AgentID       string // non-empty when emitted by a subagent
	InvocationID  string // non-empty when emitted by a subagent, globally unique per invocation

	// EventThinkingProgress fields — reasoning progress without exposing content.
	ReasoningCharCount int
	ReasoningActive    bool
}

type EventType

type EventType string
const (
	EventRunStarted        EventType = "run_started"
	EventAssistantDelta    EventType = "assistant_delta"
	EventAssistantMessage  EventType = "assistant_message"
	EventToolCallStarted   EventType = "tool_call_started"
	EventToolCallCompleted EventType = "tool_call_completed"
	EventPlanUpdated       EventType = "plan_updated"
	EventUsageUpdated      EventType = "usage_updated"
	EventRunFinished       EventType = "run_finished"
	EventThinkingProgress  EventType = "thinking_progress"
	EventStatusUpdated     EventType = "status_updated"
)

type FileType added in v1.0.1

type FileType int
const (
	FileTypeImage FileType = iota
	FileTypeText
	FileTypePDF
	FileTypeBinary
	FileTypeUnknown
)

type MCPService

type MCPService interface {
	List(ctx context.Context) ([]mcpctl.ServerStatus, error)
	Show(ctx context.Context, serverID string) (mcpctl.ServerDetail, error)
	Add(ctx context.Context, req mcpctl.AddRequest) (mcpctl.ServerStatus, error)
	Remove(ctx context.Context, serverID string) error
	Enable(ctx context.Context, serverID string, enabled bool) (mcpctl.ServerStatus, error)
	Test(ctx context.Context, serverID string) (mcpctl.ServerStatus, error)
	Reload(ctx context.Context) error
}

type MarkdownRenderResult

type MarkdownRenderResult struct {
	Display string
	Copy    string
	Lines   []markdownRenderLine
}

type MarkdownStyleConfig

type MarkdownStyleConfig struct {
	// 基础颜色
	TextColor    lipgloss.Color
	AccentColor  lipgloss.Color
	MutedColor   lipgloss.Color
	SuccessColor lipgloss.Color
	WarningColor lipgloss.Color
	ErrorColor   lipgloss.Color

	// 代码块颜色
	CodeBgColor     lipgloss.Color
	CodeBorderColor lipgloss.Color

	// 高亮颜色
	HighlightColors map[string]lipgloss.Color
}

MarkdownStyleConfig - 简约的样式配置

func (*MarkdownStyleConfig) Code

Code 返回代码块样式

func (*MarkdownStyleConfig) Emphasis

func (s *MarkdownStyleConfig) Emphasis() lipgloss.Style

Emphasis 返回强调样式

func (*MarkdownStyleConfig) Heading

func (s *MarkdownStyleConfig) Heading(level int) lipgloss.Style

Heading 返回标题样式

func (*MarkdownStyleConfig) Highlight

func (s *MarkdownStyleConfig) Highlight(color string) lipgloss.Style

Highlight 返回高亮样式

func (*MarkdownStyleConfig) InlineCode

func (s *MarkdownStyleConfig) InlineCode() lipgloss.Style

InlineCode 返回内联代码样式

Link 返回链接样式

func (*MarkdownStyleConfig) Strikethrough

func (s *MarkdownStyleConfig) Strikethrough() lipgloss.Style

Strikethrough 返回删除线样式

func (*MarkdownStyleConfig) Strong

func (s *MarkdownStyleConfig) Strong() lipgloss.Style

Strong 返回粗体样式

func (*MarkdownStyleConfig) Text

Text 返回普通文本样式

type Observer

type Observer func(Event)

type Options

type Options struct {
	Runner       Runner
	Store        SessionStore
	MCPService   MCPService
	Session      *session.Session
	ImageStore   assets.ImageStore
	Notifier     notifypkg.Notifier
	Config       config.Config
	Workspace    string
	Version      string
	StartupGuide StartupGuide
	AgentSource  mention.AgentSource
}

type RunPromptInput

type RunPromptInput struct {
	UserMessage                     llm.Message
	Assets                          map[llm.AssetID]llm.ImageAsset
	DisplayText                     string
	PersistDisplayTextAsUserMessage bool
}

type Runner

type Runner interface {
	RunPromptWithInput(ctx context.Context, sess *session.Session, input RunPromptInput, mode string, out io.Writer) (string, error)
	SetObserver(observer Observer)
	SetApprovalHandler(handler ApprovalHandler)
	UpdateProvider(providerCfg config.ProviderConfig, client llm.Client)
	ListSkills() ([]skills.Skill, []skills.Diagnostic)
	GetActiveSkill(sess *session.Session) (skills.Skill, bool)
	ActivateSkill(sess *session.Session, name string, args map[string]string) (skills.Skill, error)
	ClearActiveSkill(sess *session.Session) error
	ClearSkill(name string) (skills.ClearResult, error)
	SubAgentManager() *subagentspkg.Manager
	ListModels(ctx context.Context) ([]provider.ModelInfo, []provider.Warning, error)
}

type SessionStore

type SessionStore interface {
	Save(session *session.Session) error
	Load(id string) (*session.Session, error)
	List(limit int) ([]session.Summary, []string, error)
	DeleteInWorkspace(workspace, id string) error
	CleanupZeroMessageSessions(workspace, activeSessionID string) (session.CleanupResult, error)
}

type SimpleCache

type SimpleCache struct {
	// contains filtered or unexported fields
}

SimpleCache - 简约的缓存机制

func NewSimpleCache

func NewSimpleCache() *SimpleCache

NewSimpleCache 创建新的简单缓存

func (*SimpleCache) Get

func (c *SimpleCache) Get(key string) (string, bool)

Get 从缓存获取值

func (*SimpleCache) Set

func (c *SimpleCache) Set(key, value string)

Set 设置缓存值

type SimpleMarkdownRenderer

type SimpleMarkdownRenderer struct {
	// contains filtered or unexported fields
}

SimpleMarkdownRenderer - 简约的Markdown渲染器

func NewSimpleMarkdownRenderer

func NewSimpleMarkdownRenderer(width int) *SimpleMarkdownRenderer

NewSimpleMarkdownRenderer 创建新的简约Markdown渲染器

func (*SimpleMarkdownRenderer) Render

func (r *SimpleMarkdownRenderer) Render(markdown string) string

Render 渲染Markdown文本

type StartupGuide

type StartupGuide struct {
	Active       bool
	Title        string
	Status       string
	Lines        []string
	ConfigPath   string
	CurrentField string
}

type SubAgentToolCall added in v0.1.8

type SubAgentToolCall struct {
	ToolName    string
	ToolCallID  string   // precise matching for EventToolCallCompleted
	CompactBody string   // short description, e.g. "search_text: config"
	Status      string   // "running" / "done" / "error"
	Summary     string   // summary after completion
	DetailLines []string // expanded detail lines (ctrl+o)
}

SubAgentToolCall tracks a single tool call made by a running subagent.

type ToolRenderResult added in v0.1.7

type ToolRenderResult struct {
	Summary     string
	DetailLines []string
	Status      string
	CompactLine string
}

ToolRenderResult is the normalized output used by the TUI pipeline.

type ToolRenderer added in v0.1.7

type ToolRenderer interface {
	// DisplayLabel returns the short tag shown in the tool header (e.g. "READ", "SHELL").
	DisplayLabel() string

	// Render parses payload once and returns all fields needed by the TUI.
	Render(payload string) ToolRenderResult
}

ToolRenderer describes how a tool's execution is displayed in the TUI. Each tool registers an implementation; the rendering pipeline calls Render once so payload parsing is not repeated for summary and compact fields.

func GetToolRenderer added in v0.1.7

func GetToolRenderer(name string) ToolRenderer

GetToolRenderer returns the registered renderer for the tool, or nil if none.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL