Documentation
¶
Index ¶
- Constants
- Variables
- func BlackCircle() string
- func ContextColor(percent float64) lipgloss.Color
- func SetTheme(mode ThemeMode)
- func SpinnerTickCmd() tea.Cmd
- type App
- func (a *App) Init() tea.Cmd
- func (a *App) IsReadOnly() bool
- func (a *App) RestoreTranscript(msgs []ChatMessage)
- func (a *App) Send(msg tea.Msg)
- func (a *App) SetModel(model string)
- func (a *App) SetProvider(provider string)
- func (a *App) SubmitCh() <-chan string
- func (a *App) Update(msg tea.Msg) (tea.Model, tea.Cmd)
- func (a *App) View() string
- type AppConfig
- type AppState
- type ChatMessage
- type ChatView
- func (c *ChatView) AddSystemMessage(text string)
- func (c *ChatView) Clear()
- func (c ChatView) HasMessages() bool
- func (c ChatView) Init() tea.Cmd
- func (c *ChatView) InvalidateCache()
- func (c ChatView) IsToolOutputExpanded() bool
- func (c *ChatView) LoadMessages(msgs []ChatMessage)
- func (c *ChatView) SetToolOutputExpanded(expanded bool)
- func (c ChatView) Update(msg tea.Msg) (ChatView, tea.Cmd)
- func (c ChatView) View() string
- func (c ChatView) ViewWithHint() string
- type CommandHint
- type ComposerConfig
- type DiffDialog
- type EventSender
- type InputBox
- func (i *InputBox) Blur()
- func (i *InputBox) Focus() tea.Cmd
- func (i InputBox) GetPastedContent(id int) string
- func (i *InputBox) HandlePaste(content string) (display string, stored string)
- func (i InputBox) Height() int
- func (i InputBox) Init() tea.Cmd
- func (i *InputBox) RecordMouseEvent()
- func (i *InputBox) Reset()
- func (i InputBox) SearchHistory(query string) []string
- func (i InputBox) Update(msg tea.Msg) (InputBox, tea.Cmd)
- func (i InputBox) Value() string
- func (i InputBox) View() string
- type LayerContent
- type Layout
- type MouseMode
- type MsgAgentDone
- type MsgAskUser
- type MsgClosePanel
- type MsgDiffPreview
- type MsgError
- type MsgOpenPanel
- type MsgPermissionRequest
- type MsgResponseDone
- type MsgResumeChosen
- type MsgResumeEntries
- type MsgSpinnerTick
- type MsgSubAgentDone
- type MsgSubAgentStart
- type MsgSubmit
- type MsgSystemNotice
- type MsgTextDelta
- type MsgThinking
- type MsgToolDone
- type MsgToolStart
- type MsgUsage
- type MsgWindowSize
- type Panel
- type PermissionDialog
- func (p PermissionDialog) Card(width int) string
- func (p *PermissionDialog) Hide()
- func (p PermissionDialog) Init() tea.Cmd
- func (p PermissionDialog) IsVisible() bool
- func (p *PermissionDialog) Show(toolName, input string, responseCh chan PermissionResponse)
- func (p PermissionDialog) Update(msg tea.Msg) (PermissionDialog, tea.Cmd)
- func (p PermissionDialog) View() string
- type PermissionResponse
- type ResumeEntry
- type ResumeMode
- type ResumeSelector
- type SpinnerState
- type SubAgentStatus
- type ThemeMode
Constants ¶
const ( LabelContinue = "可继续" LabelReadonly = "仅浏览" LabelBlocked = "不兼容" ReasonCompatible = "同运行环境,可继续" ReasonAuthMismatch = "认证方式不兼容,仅可浏览" ReasonProviderBlock = "跨 provider,不可恢复" ReasonEndpointBlock = "跨 endpoint,不可恢复" ReasonReadonlyNotice = "当前会话为只读浏览,运行环境不兼容,不能继续对话" )
统一文案常量(selector / Enter 提示 / 输入区 共用)
const ( SymThinking = "∴" SymResponse = "⎿" SymPause = "⏸" SymUserPrompt = "❯" )
CC 符号体系
Variables ¶
var ( // 品牌色 ColorBrand = lipgloss.Color("#D77757") // CC: rgb(215,119,87) ColorBrandDim = lipgloss.Color("#EB9F7F") // CC: rgb(235,159,127) 闪烁态 // 语义色 ColorSuccess = lipgloss.Color("#2CB74F") ColorError = lipgloss.Color("#CC3333") ColorWarning = lipgloss.Color("#DCA032") ColorPerm = lipgloss.Color("#B1B9F9") // CC: rgb(177,185,249) 权限蓝紫 // 文本色 ColorText = lipgloss.Color("#FFFFFF") ColorTextDim = lipgloss.Color("#A0A0A0") ColorSubtle = lipgloss.Color("#6E6E6E") // 边框色 ColorInputBorder = lipgloss.Color("#888888") // CC: rgb(136,136,136) // Diff 色 ColorDiffAdd = lipgloss.Color("#4ADE80") ColorDiffDel = lipgloss.Color("#FB7185") // 上下文进度条 ColorCtxLow = lipgloss.Color("#34D399") ColorCtxMid = lipgloss.Color("#F59E0B") ColorCtxHigh = lipgloss.Color("#F87171") )
颜色令牌(CC dark theme 精确 RGB)
var ( // ⎿ 前缀及 assistant 响应区文本 StyleMsgResponse = lipgloss.NewStyle(). Foreground(ColorTextDim) // 用户输入文本 StyleUserText = lipgloss.NewStyle(). Foreground(ColorText). Bold(true) // ∴ 思考中文本 StyleThinking = lipgloss.NewStyle(). Foreground(ColorTextDim). Italic(true) // 工具名称 StyleToolName = lipgloss.NewStyle(). Bold(true) // 工具输出内容 StyleToolOutput = lipgloss.NewStyle(). Foreground(ColorTextDim) // 错误文本 StyleError = lipgloss.NewStyle(). Foreground(ColorError) // Spinner 动画 StyleSpinner = lipgloss.NewStyle(). Foreground(ColorBrand) // 通用 dim 文本 StyleDim = lipgloss.NewStyle(). Foreground(ColorTextDim) // 输入框提示符 StyleInputPrompt = lipgloss.NewStyle(). Foreground(ColorTextDim) // 权限请求标题 StylePermTitle = lipgloss.NewStyle(). Foreground(ColorPerm). Bold(true) // Diff 样式 StyleDiffAdd = lipgloss.NewStyle(). Foreground(ColorDiffAdd) StyleDiffDel = lipgloss.NewStyle(). Foreground(ColorDiffDel) StyleDiffHeader = lipgloss.NewStyle(). Foreground(ColorPerm). Bold(true) StyleDiffCtx = lipgloss.NewStyle(). Foreground(ColorTextDim) StyleFooter = lipgloss.NewStyle(). Foreground(ColorTextDim) )
组件样式
Functions ¶
Types ¶
type App ¶
type App struct {
// 会话回调(由 main.go 注入)
OnClear func()
OnCompact func() string
OnModelSwitch func(string)
OnExport func() string
OnInterrupt func()
OnResume func() ([]ResumeEntry, error)
OnResumeLoad func(sessionID string) error
OnThemeSwitch func(string) string
OnLogin func() string
OnLogout func() string
OnSkillsList func() string
OnPluginsList func() string
OnHooksList func() string
// 会话信息
SessionID string
SessionTurns int
// contains filtered or unexported fields
}
App TUI 主 Model
func (*App) RestoreTranscript ¶
func (a *App) RestoreTranscript(msgs []ChatMessage)
RestoreTranscript 从结构化消息恢复前台 transcript(/resume 后调用)
func (*App) SetProvider ¶
SetProvider 切换运行时 provider 名称(/resume 恢复后调用)
type AppConfig ¶
type AppConfig struct {
Model string
Provider string
Tracker *cost.Tracker
MaxContext int
Version string
ToolCount int
PermMode string
WorkDir string
}
AppConfig TUI 初始化配置
type ChatMessage ¶
type ChatMessage struct {
ID string // 稳定标识(递增 ID)
Role string // 用户 / 助手 / 工具 / 思考 / 错误 / 系统
Content string
ToolName string // 工具消息时使用
ToolID string // 工具调用标识(用于精确匹配同名工具)
ToolInput string // 工具输入参数(原始 JSON)
IsError bool
Folded bool // 是否已折叠
}
ChatMessage 单条转录消息
type ChatView ¶
type ChatView struct {
// contains filtered or unexported fields
}
ChatView 转录区域组件
func (*ChatView) AddSystemMessage ¶
AddSystemMessage 添加系统消息
func (ChatView) HasMessages ¶
HasMessages 返回是否有用户发起的消息(非 system 消息)
func (*ChatView) InvalidateCache ¶
func (c *ChatView) InvalidateCache()
InvalidateCache 清空 Markdown 渲染缓存并重建(主题切换后调用)
func (ChatView) IsToolOutputExpanded ¶
IsToolOutputExpanded 返回工具输出展开状态
func (*ChatView) LoadMessages ¶
func (c *ChatView) LoadMessages(msgs []ChatMessage)
LoadMessages 从外部替换全部消息并刷新视图(用于 /resume 恢复 transcript)
func (*ChatView) SetToolOutputExpanded ¶
SetToolOutputExpanded 设置工具输出展开状态
type ComposerConfig ¶
type ComposerConfig struct {
Model string
PermMode string
MouseMode MouseMode
ReadOnly bool
ToolExpanded bool
Tracker *cost.Tracker
MaxContext int
WorkDir string
}
ComposerConfig 底部 Composer 渲染所需数据
type DiffDialog ¶
type DiffDialog struct {
// contains filtered or unexported fields
}
DiffDialog 差异预览弹层
func (DiffDialog) Init ¶
func (d DiffDialog) Init() tea.Cmd
func (*DiffDialog) Show ¶
func (d *DiffDialog) Show(path string, diffText string, responseCh chan bool)
Show 显示差异预览弹层
func (DiffDialog) Update ¶
func (d DiffDialog) Update(msg tea.Msg) (DiffDialog, tea.Cmd)
type InputBox ¶
type InputBox struct {
// contains filtered or unexported fields
}
InputBox 输入框组件
func (InputBox) GetPastedContent ¶
GetPastedContent 获取存储的粘贴内容
func (*InputBox) HandlePaste ¶
HandlePaste 处理粘贴内容:短文本原样返回,长文本存储并返回引用标记
func (*InputBox) RecordMouseEvent ¶
func (i *InputBox) RecordMouseEvent()
RecordMouseEvent 记录鼠标事件时间(由 app.go 调用)
func (InputBox) SearchHistory ¶
SearchHistory 按关键词过滤历史记录(倒序,最近的在前)
type LayerContent ¶
type LayerContent struct {
Main string
Bottom string
BottomFloat string
Overlay string
Modal string // 已含 lipgloss.Place 定位的完整帧
}
LayerContent 各层内容
type Layout ¶
type Layout struct {
// contains filtered or unexported fields
}
Layout 五层布局管理器 真 overlay 实现:主区不被 overlay/bottomFloat 挤压。
- Main — 主滚动区(transcript),占满剩余高度
- Bottom — 底部固定区(Composer)
- BottomFloat — 底部浮层(权限确认、spinner),覆盖在 Main 底部
- Overlay — 覆盖层(ResumeSelector 等),居中覆盖在 Main 上
- Modal — 模态层(diff/panel),居中覆盖全屏,保留背景感
func (*Layout) MainHeight ¶
MainHeight 返回主区域可用高度
type MsgAskUser ¶
MsgAskUser 询问工具请求用户输入
type MsgDiffPreview ¶
MsgDiffPreview 差异预览确认请求
type MsgPermissionRequest ¶
type MsgPermissionRequest struct {
ID string
ToolName string
Input string
Response chan PermissionResponse
}
MsgPermissionRequest 权限请求
type MsgResumeEntries ¶
type MsgResumeEntries struct {
Entries []ResumeEntry
}
MsgResumeEntries 打开会话恢复选择器(携带结构化数据)
type MsgSubAgentDone ¶
MsgSubAgentDone 子 agent 执行完成
type MsgSubAgentStart ¶
MsgSubAgentStart 子 agent 开始执行
type MsgToolDone ¶
MsgToolDone 工具执行完成
type MsgToolStart ¶
MsgToolStart 工具开始执行
type Panel ¶
type Panel struct {
// contains filtered or unexported fields
}
Panel 可滚动文本面板(用于 /help /config /permissions 等长输出)
type PermissionDialog ¶
type PermissionDialog struct {
// contains filtered or unexported fields
}
PermissionDialog 权限确认对话框
func (PermissionDialog) Card ¶
func (p PermissionDialog) Card(width int) string
Card 渲染权限确认卡片(圆角边框 + 按键高亮反馈)
func (PermissionDialog) Init ¶
func (p PermissionDialog) Init() tea.Cmd
func (*PermissionDialog) Show ¶
func (p *PermissionDialog) Show(toolName, input string, responseCh chan PermissionResponse)
Show 显示权限对话框
func (PermissionDialog) Update ¶
func (p PermissionDialog) Update(msg tea.Msg) (PermissionDialog, tea.Cmd)
func (PermissionDialog) View ¶
func (p PermissionDialog) View() string
type PermissionResponse ¶
type PermissionResponse int
PermissionResponse 权限响应
const ( PermAllow PermissionResponse = iota PermDeny PermAlways PermNever )
type ResumeEntry ¶
type ResumeEntry struct {
ID string
Model string
Provider string
BaseURL string
AuthSource string
Turns int
Cost string
Mode ResumeMode // 恢复能力
ModeReason string // 原因文案
}
ResumeEntry 历史会话条目(含兼容性元数据)
type ResumeMode ¶
type ResumeMode string
ResumeMode 恢复能力级别
const ( ResumeContinue ResumeMode = "continue" // 完全兼容,可继续对话 ResumeReadonly ResumeMode = "readonly" // 可浏览历史,不可续接 ResumeBlocked ResumeMode = "blocked" // 不兼容,不可恢复 )
type ResumeSelector ¶
type ResumeSelector struct {
// contains filtered or unexported fields
}
ResumeSelector 会话恢复选择器(真正可滚动)
func (ResumeSelector) SelectedEntry ¶
func (r ResumeSelector) SelectedEntry() *ResumeEntry
SelectedEntry 返回当前选中的条目
func (ResumeSelector) Update ¶
func (r ResumeSelector) Update(msg tea.Msg) (ResumeSelector, tea.Cmd)
Update 处理键盘和鼠标事件
type SpinnerState ¶
type SpinnerState struct {
// contains filtered or unexported fields
}
SpinnerState 保存 Spinner 的运行状态
func (*SpinnerState) AddSubAgent ¶
func (s *SpinnerState) AddSubAgent(id, description string)
AddSubAgent 注册一个正在运行的子 agent
func (*SpinnerState) ClearSubAgents ¶
func (s *SpinnerState) ClearSubAgents()
ClearSubAgents 清空所有子 agent 状态
func (*SpinnerState) CompleteSubAgent ¶
func (s *SpinnerState) CompleteSubAgent(id string)
CompleteSubAgent 标记指定子 agent 为已完成
func (*SpinnerState) View ¶
func (s *SpinnerState) View() string
View 渲染 Spinner 行,格式:` [glyph] [verb]… [elapsed]` glyph 使用品牌橙色,elapsed 使用 dim 色 如果有子 agent,在下方渲染树形列表
type SubAgentStatus ¶
SubAgentStatus 子 agent 状态