ui

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2026 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatError added in v0.1.3

func FormatError(err error, fallbackPrefix string) string

FormatError renders err for user display. Recognizes common cross-cutting conditions (cancellation, agent loop limits, LLM provider errors) with short friendly messages; falls back to err.Error() for anything else.

fallbackPrefix is prepended when no friendly category matches and the fallback is err.Error(). Pass "" to skip.

func ReadStdinPrompt

func ReadStdinPrompt() (string, error)

ReadStdinPrompt reads all of stdin as a prompt (for pipe usage).

func RunOnboarding added in v0.3.0

func RunOnboarding() (tui.OnboardingResult, error)

RunOnboarding runs the first-run setup wizard. Called by main() before the runtime boots when no configuration exists (or with -setup).

func RunPrint

func RunPrint(rt *bootstrap.Runtime, args []string, jsonMode bool) error

RunPrint executes non-interactive print/json mode.

func RunPrintMode

func RunPrintMode(sess *agent.Session, taskRT *task.Runtime, prompt string, jsonMode bool) error

RunPrintMode runs the agent in non-interactive mode. stdout receives assistant text (pipe-friendly), stderr receives tool/status info. When jsonMode is true, all events are streamed as JSONL to stdout.

func RunTUI

func RunTUI(rt *bootstrap.Runtime, version string) error

RunTUI executes interactive TUI mode. The frontend-neutral session lifecycle (plan/goal managers, goal tool callbacks, MCP manager, cron store) is already assembled by bootstrap; this function only adds the TUI-specific bindings on top.

Types

type App

type App struct {
	Session   *agent.Session
	Cwd       string
	GitBranch string
	Version   string

	ApprovalEngine *approval.Engine

	// Commands are user-defined slash commands loaded from .md files.
	Commands []config.FileCommand

	// Skills are loaded skill definitions.
	Skills []skill.Spec
	// SkillCatalog provides shared skill invocation behavior across UI and tools.
	SkillCatalog  *skill.Catalog
	PluginCatalog *plugin.Catalog

	// MCPManager manages MCP server connections.
	MCPManager *mcpclient.Manager
	MCPServers map[string]mcpclient.ServerConfig

	// CronStore holds session-scoped cron jobs for /loop command.
	CronStore *cron.Store

	// Dreamer triggers background memory consolidation for /dream.
	// nil in modes without one (print); the command degrades gracefully.
	Dreamer *dream.Dreamer

	// TaskRuntime provides unified access to all background tasks (shells + agents).
	TaskRuntime *task.Runtime

	// TeamRegistry is the session-wide team registry. nil before any
	// team_create call; the chrome's team chip and any team-aware command
	// degrade to "no team" when nil or HasTeam() returns false.
	TeamRegistry *team.Registry

	// TeammateEvents is the per-session fan-out hub for teammate AgentLoop
	// events. The TUI's teammate-transcript modal subscribes here. May be
	// nil in headless / non-TUI flows; nil is a valid no-op publisher.
	TeammateEvents *cbteam.EventHub

	// PlanStore persists plans to ~/.codebot/plans/.
	PlanStore *storage.PlanStore

	// SessionStore is used to record plan slug into the session log.
	SessionStore *storage.Store

	// History provides input history for Up/Down navigation.
	History *storage.History

	PlanManager *plan.Manager
	GoalManager *goal.Manager

	// CommandLoaders allow alternative command sources to be injected at app construction time.
	CommandLoaders []CommandLoader
	// contains filtered or unexported fields
}

App is the TUI adapter. Business logic lives in agent.Session.

func (*App) Config

func (a *App) Config() tui.Config

Config returns a tui.Config with all hooks wired to this App.

type CommandLoader added in v0.0.2

type CommandLoader interface {
	Load(app *App) []commands.Command
}

CommandLoader discovers a family of commands and contributes them to the registry.

type ModalOverlay added in v0.0.4

type ModalOverlay interface {
	IsModal() bool
}

ModalOverlay is an optional interface used by overlays that want to opt out of the modal default. Overlays that intercept keyboard input (the typical case) replace the input area; non-modal overlays — autocomplete-style hint panels that coexist with the input — must implement this and return false.

type Registry added in v0.0.2

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

Registry manages command registration, lookup by name/alias, and the active interactive overlay.

func NewRegistry added in v0.0.2

func NewRegistry() *Registry

NewRegistry creates an empty Registry.

func (*Registry) All added in v0.0.2

func (r *Registry) All() []commands.Command

All returns all registered commands sorted by kind and then by name.

func (*Registry) ClearOverlay added in v0.0.2

func (r *Registry) ClearOverlay()

ClearOverlay dismisses and clears the active overlay.

func (*Registry) EffectiveSpec added in v0.0.2

func (r *Registry) EffectiveSpec(cmd commands.Command) commands.Spec

EffectiveSpec returns the command metadata with only active aliases included.

func (*Registry) Lookup added in v0.0.2

func (r *Registry) Lookup(name string) (commands.Command, bool)

Lookup finds a command by name or alias (case-insensitive).

func (*Registry) Overlay added in v0.0.2

func (r *Registry) Overlay() commands.InteractiveCommand

Overlay returns the currently active interactive command, or nil.

func (*Registry) Register added in v0.0.2

func (r *Registry) Register(cmd commands.Command)

Register adds or replaces a command and its aliases in the registry.

func (*Registry) RegisterAll added in v0.0.2

func (r *Registry) RegisterAll(cmds []commands.Command)

RegisterAll adds a batch of commands to the registry.

func (*Registry) Reset added in v0.1.3

func (r *Registry) Reset()

Reset clears all registered commands and aliases. The active overlay is preserved because rebuilds (e.g. on /reload) should not dismiss an open modal that the user is interacting with.

func (*Registry) SetOverlay added in v0.0.2

func (r *Registry) SetOverlay(ic commands.InteractiveCommand)

SetOverlay sets the active interactive overlay.

Directories

Path Synopsis
Package commands holds the slash-command implementations and the abstractions required to register them with the host UI.
Package commands holds the slash-command implementations and the abstractions required to register them with the host UI.
Package imageinput handles image input from clipboard paste and file drag-drop, converting raw data to agentcore ContentBlocks.
Package imageinput handles image input from clipboard paste and file drag-drop, converting raw data to agentcore ContentBlocks.
tui
syntax
Package syntax wraps chroma to emit ANSI-colored code that nests safely inside a lipgloss background-color span.
Package syntax wraps chroma to emit ANSI-colored code that nests safely inside a lipgloss background-color span.

Jump to

Keyboard shortcuts

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