ui

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2026 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Expand

func Expand(template string, args []string) string

Expand substitutes placeholder patterns in template with the given args.

Supported patterns:

  • $1, $2, ... $N — positional args (1-based, out-of-range → "")
  • ${@:N} — all args from index N onward (1-based)
  • ${@:N:L} — L args starting at index N (1-based)
  • $@ / $ARGUMENTS — all args joined by space

Substitution is single-pass per pattern class (no recursive expansion).

func ParseArgs

func ParseArgs(s string) []string

ParseArgs splits a command argument string respecting double and single quotes. Empty quoted strings are skipped.

func ReadStdinPrompt

func ReadStdinPrompt() (string, error)

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

func RunPrint

func RunPrint(sess *agent.Session, args []string, jsonMode bool) error

RunPrint executes non-interactive print/json mode.

func RunPrintMode

func RunPrintMode(sess *agent.Session, 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.

Types

type App

type App struct {
	Session   *agent.Session
	Cwd       string
	GitBranch 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

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

	// 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

	// 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 BtwCommand added in v0.0.4

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

BtwCommand implements /btw — ephemeral side-chain Q&A that reads the full conversation context but never mutates history or invokes tools.

func NewBtwCommand added in v0.0.4

func NewBtwCommand(app *App) *BtwCommand

NewBtwCommand creates a /btw command bound to the given App.

func (*BtwCommand) Active added in v0.0.4

func (c *BtwCommand) Active() bool

func (*BtwCommand) Dismiss added in v0.0.4

func (c *BtwCommand) Dismiss()

func (*BtwCommand) HandleKey added in v0.0.4

func (c *BtwCommand) HandleKey(msg tea.KeyMsg) (bool, tea.Cmd)

func (*BtwCommand) IsModal added in v0.0.4

func (c *BtwCommand) IsModal() bool

func (*BtwCommand) Run added in v0.0.4

func (*BtwCommand) SetResult added in v0.0.4

func (c *BtwCommand) SetResult(msg tui.BtwResultMsg)

SetResult updates the overlay with the side question response.

func (*BtwCommand) Spec added in v0.0.4

func (c *BtwCommand) Spec() CommandSpec

func (*BtwCommand) View added in v0.0.4

func (c *BtwCommand) View(width int) string

type Command added in v0.0.2

type Command interface {
	Spec() CommandSpec
	Run(ctx *CommandContext, inv CommandInvocation) tea.Cmd
}

Command is the unified abstraction for all slash commands.

type CommandContext added in v0.0.2

type CommandContext struct {
	App *App
}

CommandContext provides runtime dependencies to commands.

type CommandInvocation added in v0.0.2

type CommandInvocation struct {
	Input   string
	Name    string
	RawArgs string
	Args    []string
}

CommandInvocation is the parsed slash-command input passed to command handlers.

type CommandKind added in v0.0.2

type CommandKind string
const (
	CommandKindBuiltin CommandKind = "builtin"
	CommandKindCustom  CommandKind = "custom"
	CommandKindSkill   CommandKind = "skill"
)

type CommandLoader added in v0.0.2

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

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

type CommandSpec added in v0.0.2

type CommandSpec struct {
	Name        string
	Aliases     []string
	Usage       string
	Description string
	Category    string
	NeedsIdle   bool
	Hidden      bool
	Kind        CommandKind
	Source      string
}

CommandSpec describes command metadata.

type ContextCommand added in v0.1.1

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

ContextCommand implements InteractiveCommand for /context. Opens a modal overlay with tabbed sections (usage / composition / suggestions).

func NewContextCommand added in v0.1.1

func NewContextCommand(app *App) *ContextCommand

func (*ContextCommand) Active added in v0.1.1

func (c *ContextCommand) Active() bool

func (*ContextCommand) Dismiss added in v0.1.1

func (c *ContextCommand) Dismiss()

func (*ContextCommand) HandleKey added in v0.1.1

func (c *ContextCommand) HandleKey(msg tea.KeyMsg) (bool, tea.Cmd)

func (*ContextCommand) IsModal added in v0.1.1

func (c *ContextCommand) IsModal() bool

func (*ContextCommand) Run added in v0.1.1

func (*ContextCommand) Spec added in v0.1.1

func (c *ContextCommand) Spec() CommandSpec

func (*ContextCommand) View added in v0.1.1

func (c *ContextCommand) View(width int) string

type DebugHarnessCommand added in v0.1.1

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

DebugHarnessCommand implements InteractiveCommand for /debug-harness. Opens a modal overlay with tabbed sections (turn / activity / metrics / context).

func NewDebugHarnessCommand added in v0.1.1

func NewDebugHarnessCommand(app *App) *DebugHarnessCommand

func (*DebugHarnessCommand) Active added in v0.1.1

func (c *DebugHarnessCommand) Active() bool

func (*DebugHarnessCommand) Dismiss added in v0.1.1

func (c *DebugHarnessCommand) Dismiss()

func (*DebugHarnessCommand) HandleKey added in v0.1.1

func (c *DebugHarnessCommand) HandleKey(msg tea.KeyMsg) (bool, tea.Cmd)

func (*DebugHarnessCommand) IsModal added in v0.1.1

func (c *DebugHarnessCommand) IsModal() bool

func (*DebugHarnessCommand) Run added in v0.1.1

func (*DebugHarnessCommand) Spec added in v0.1.1

func (c *DebugHarnessCommand) Spec() CommandSpec

func (*DebugHarnessCommand) View added in v0.1.1

func (c *DebugHarnessCommand) View(width int) string

type FileCommandAdapter added in v0.0.2

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

func (*FileCommandAdapter) Run added in v0.0.2

func (*FileCommandAdapter) Spec added in v0.0.2

func (c *FileCommandAdapter) Spec() CommandSpec

type HelpCommand added in v0.1.1

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

HelpCommand implements InteractiveCommand for /help. Opens a modal overlay with tabbed sections (general / built-in / custom / skills).

func NewHelpCommand added in v0.1.1

func NewHelpCommand(app *App) *HelpCommand

func (*HelpCommand) Active added in v0.1.1

func (c *HelpCommand) Active() bool

func (*HelpCommand) Dismiss added in v0.1.1

func (c *HelpCommand) Dismiss()

func (*HelpCommand) HandleKey added in v0.1.1

func (c *HelpCommand) HandleKey(msg tea.KeyMsg) (bool, tea.Cmd)

func (*HelpCommand) IsModal added in v0.1.1

func (c *HelpCommand) IsModal() bool

func (*HelpCommand) Run added in v0.1.1

func (*HelpCommand) Spec added in v0.1.1

func (c *HelpCommand) Spec() CommandSpec

func (*HelpCommand) View added in v0.1.1

func (c *HelpCommand) View(width int) string

type InteractiveCommand added in v0.0.2

type InteractiveCommand interface {
	Command
	Active() bool
	HandleKey(msg tea.KeyMsg) (handled bool, cmd tea.Cmd)
	View(width int) string
	Dismiss()
}

InteractiveCommand extends Command with modal keyboard interception and custom rendering. When Active() returns true the TUI routes all keyboard events through HandleKey and replaces the input area with View.

type ModalOverlay added in v0.0.4

type ModalOverlay interface {
	IsModal() bool
}

ModalOverlay is an optional interface for overlays that replace the input area.

type ModelCommand added in v0.0.2

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

ModelCommand implements InteractiveCommand for /model. Always opens an interactive selector overlay; any arguments are ignored. Selection is persisted to whichever settings file already owns the model setting (project if it defines provider/model, otherwise global), so that manual edits and /model stay in sync.

func NewModelCommand added in v0.0.2

func NewModelCommand(app *App) *ModelCommand

func (*ModelCommand) Active added in v0.0.2

func (c *ModelCommand) Active() bool

func (*ModelCommand) Dismiss added in v0.0.2

func (c *ModelCommand) Dismiss()

func (*ModelCommand) HandleKey added in v0.0.2

func (c *ModelCommand) HandleKey(msg tea.KeyMsg) (bool, tea.Cmd)

func (*ModelCommand) Run added in v0.0.2

func (*ModelCommand) Spec added in v0.0.2

func (c *ModelCommand) Spec() CommandSpec

func (*ModelCommand) View added in v0.0.2

func (c *ModelCommand) View(width int) string

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() []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 Command) CommandSpec

EffectiveSpec returns the command metadata with only active aliases included.

func (*Registry) Lookup added in v0.0.2

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

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

func (*Registry) Overlay added in v0.0.2

func (r *Registry) Overlay() InteractiveCommand

Overlay returns the currently active interactive command, or nil.

func (*Registry) Register added in v0.0.2

func (r *Registry) Register(cmd 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(commands []Command)

RegisterAll adds a batch of commands to the registry.

func (*Registry) SetOverlay added in v0.0.2

func (r *Registry) SetOverlay(ic InteractiveCommand)

SetOverlay sets the active interactive overlay.

type ResumeCommand added in v0.0.2

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

ResumeCommand implements InteractiveCommand for /resume. Opens an interactive overlay to select and switch sessions.

func NewResumeCommand added in v0.0.2

func NewResumeCommand(app *App) *ResumeCommand

func (*ResumeCommand) Active added in v0.0.2

func (c *ResumeCommand) Active() bool

func (*ResumeCommand) Dismiss added in v0.0.2

func (c *ResumeCommand) Dismiss()

func (*ResumeCommand) HandleKey added in v0.0.2

func (c *ResumeCommand) HandleKey(msg tea.KeyMsg) (bool, tea.Cmd)

func (*ResumeCommand) Run added in v0.0.2

func (*ResumeCommand) Spec added in v0.0.2

func (c *ResumeCommand) Spec() CommandSpec

func (*ResumeCommand) View added in v0.0.2

func (c *ResumeCommand) View(width int) string

type SettingsCommand added in v0.1.1

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

SettingsCommand implements InteractiveCommand for /settings. Opens a modal overlay with tabbed sections (general / runtime / providers).

func NewSettingsCommand added in v0.1.1

func NewSettingsCommand(app *App) *SettingsCommand

func (*SettingsCommand) Active added in v0.1.1

func (c *SettingsCommand) Active() bool

func (*SettingsCommand) Dismiss added in v0.1.1

func (c *SettingsCommand) Dismiss()

func (*SettingsCommand) HandleKey added in v0.1.1

func (c *SettingsCommand) HandleKey(msg tea.KeyMsg) (bool, tea.Cmd)

func (*SettingsCommand) IsModal added in v0.1.1

func (c *SettingsCommand) IsModal() bool

func (*SettingsCommand) Run added in v0.1.1

func (*SettingsCommand) Spec added in v0.1.1

func (c *SettingsCommand) Spec() CommandSpec

func (*SettingsCommand) View added in v0.1.1

func (c *SettingsCommand) View(width int) string

type SimpleCommand added in v0.0.2

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

SimpleCommand wraps a plain function as a Command.

func NewSimple added in v0.0.2

func NewSimple(spec CommandSpec, run func(*CommandContext, CommandInvocation) tea.Cmd) *SimpleCommand

NewSimple creates a SimpleCommand.

func (*SimpleCommand) Run added in v0.0.2

func (*SimpleCommand) Spec added in v0.0.2

func (c *SimpleCommand) Spec() CommandSpec

type SkillCommand added in v0.0.2

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

func (*SkillCommand) Run added in v0.0.2

func (*SkillCommand) Spec added in v0.0.2

func (c *SkillCommand) Spec() CommandSpec

type TasksCommand added in v0.0.3

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

TasksCommand implements InteractiveCommand for /tasks. Shows background bash commands and agent tasks in a grouped overlay.

func NewTasksCommand added in v0.0.3

func NewTasksCommand(app *App) *TasksCommand

func (*TasksCommand) Active added in v0.0.3

func (c *TasksCommand) Active() bool

func (*TasksCommand) Dismiss added in v0.0.3

func (c *TasksCommand) Dismiss()

func (*TasksCommand) HandleKey added in v0.0.3

func (c *TasksCommand) HandleKey(msg tea.KeyMsg) (bool, tea.Cmd)

func (*TasksCommand) Run added in v0.0.3

func (*TasksCommand) Spec added in v0.0.3

func (c *TasksCommand) Spec() CommandSpec

func (*TasksCommand) View added in v0.0.3

func (c *TasksCommand) View(width int) string

Directories

Path Synopsis
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

Jump to

Keyboard shortcuts

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