tui

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2026 License: MIT Imports: 33 Imported by: 0

Documentation

Overview

Package tui implements the interactive terminal UI using Bubble Tea v2.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateCommitMsgFunc

func GenerateCommitMsgFunc(llm llmmodel.LLM) func(ctx context.Context, diffs string) (string, error)

GenerateCommitMsgFunc creates a function that generates commit messages using the given LLM.

func Run

func Run(ctx context.Context, cfg Config) error

Run starts the interactive TUI.

Types

type AgentSubEvent

type AgentSubEvent struct {
	AgentID string
	Kind    string // "tool_call", "tool_result", "text_delta", etc.
	Content string
}

AgentSubEvent carries a subagent event from the agent tool to the TUI.

type CompactStatsProvider added in v0.0.4

type CompactStatsProvider interface {
	FormatStats() string
}

CompactStatsProvider provides compaction statistics for TUI display.

type CompleteResult

type CompleteResult struct {
	Candidates []CompletionCandidate
	Selected   int
	Type       CompletionType
}

CompleteResult holds all completion results.

func Complete

func Complete(input string, skills []extension.Skill, workDir string) *CompleteResult

Complete returns completion candidates for the given input. It analyzes the input and returns all matching options for commands, skills, and specs.

func (*CompleteResult) ApplySelection

func (r *CompleteResult) ApplySelection(index int) string

ApplySelection returns the text of the candidate at the given index.

func (*CompleteResult) CycleSelection

func (r *CompleteResult) CycleSelection(dir int)

CycleSelection moves the selection index in the given direction. dir should be 1 for next, -1 for previous.

func (*CompleteResult) SelectedCandidate

func (r *CompleteResult) SelectedCandidate() *CompletionCandidate

SelectedCandidate returns the currently selected candidate.

type CompletionCandidate

type CompletionCandidate struct {
	Text        string
	Description string
	Type        CompletionType
}

CompletionCandidate represents a single completion option.

type CompletionType

type CompletionType int

CompletionType identifies what kind of completion to perform.

const (
	CompletionTypeNone CompletionType = iota
	CompletionTypeCommand
	CompletionTypeSkill
	CompletionTypeSpec
)

type Config

type Config struct {
	Agent          *agent.Agent
	LLM            llmmodel.LLM // The active LLM, used by /ping.
	SessionID      string
	ModelName      string
	ProviderName   string
	ActiveRole     string
	Roles          map[string]config.RoleConfig
	SessionService *pisession.FileService
	WorkDir        string
	Orchestrator   *subagent.Orchestrator
	// GenerateCommitMsg is called by /commit to generate a conventional commit message from diffs.
	// If nil, /commit is disabled.
	GenerateCommitMsg func(ctx context.Context, diffs string) (string, error)
	// Logger is the session logger. If nil, logging is disabled.
	Logger *logger.Logger
	// Screen receives screen content updates for the screen tool.
	// If nil, the screen tool won't have access to TUI content.
	Screen *Screen
	// Skills is loaded from skill directories for command completion.
	Skills []extension.Skill
	// SkillDirs are the directories to re-scan for skills on each completion.
	SkillDirs []string
	// RestartCh receives a signal when the agent calls the restart tool.
	RestartCh chan struct{}
	// AgentEventCh receives subagent events from the agent tool for live display.
	AgentEventCh <-chan AgentSubEvent
	// TokenTracker tracks daily token usage and enforces limits. May be nil.
	TokenTracker TokenTracker
	// CompactMetrics tracks output compaction statistics. May be nil.
	CompactMetrics CompactStatsProvider
}

Config holds configuration for the TUI.

type Gate

type Gate struct {
	Name    string
	Command string
}

Gate represents a validation command parsed from the ## Gates section of PROMPT.md.

type GateResult

type GateResult struct {
	Name    string
	Command string
	Passed  bool
	Output  string
}

GateResult holds the result of running a single gate command.

type Screen

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

Screen provides thread-safe access to the current TUI screen content. It implements tools.ScreenProvider so the LLM can read what the user sees.

func (*Screen) ScreenContent

func (s *Screen) ScreenContent() string

ScreenContent returns the current screen content.

type TokenTracker added in v0.0.4

type TokenTracker interface {
	Limit() int64
	Remaining() int64     // -1 if unlimited
	PercentUsed() float64 // 0-100+
	TotalUsed() int64     // total tokens consumed today
}

TokenTracker provides read access to daily token usage for the status bar.

Jump to

Keyboard shortcuts

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