statusline

package
v0.0.25 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package statusline defines the display-only, dependency-leaf protocol shared by mecatui composition and UI status-line renderers.

Index

Constants

View Source
const (
	// ProtocolVersion is the current Input wire-independent contract version.
	ProtocolVersion uint8 = 2
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Clock

type Clock struct {
	Now time.Time
}

Clock is the raw source-owned time fact. A submitted value is preserved until the source refreshes it; templates and future commands observe the same value.

type Command

type Command struct {
	Path string
	Args []string
	// PassthroughEnv names additional parent environment variables explicitly
	// allowed into the command's otherwise fixed environment.
	PassthroughEnv []string
	LaunchDir      string
	// RefreshInterval optionally refreshes an otherwise idle command. Values below
	// one second are disabled; input changes still use the command debounce.
	RefreshInterval time.Duration
}

Command is a validated local status command. Path is an absolute executable and Args are passed literally. LaunchDir remains private command-runner state and is never projected into Input.

func (Command) Valid

func (c Command) Valid() bool

Valid reports whether command specifies an absolute executable and literal args.

func (Command) ValidatePassthroughEnv added in v0.0.23

func (c Command) ValidatePassthroughEnv() error

ValidatePassthroughEnv reports whether PassthroughEnv has valid names that do not override values owned by the status-command environment.

type Context

type Context struct {
	Used    ContextAtom
	Window  ContextAtom
	Percent int
}

Context describes current context-window consumption. Percent is Used.Raw as an integer percentage of Window.Raw, or zero when the window is unknown. The visual bar is renderer-owned because its glyphs and semantic style depend on the active theme and available surface width.

type ContextAtom

type ContextAtom struct {
	Raw   int64
	Human string
}

ContextAtom carries an exact token count and its standard compact display notation. It is separate from UsageAtom to make the context-window contract explicit at call sites.

type Delegation

type Delegation struct {
	Total          DelegationStateCounts
	DirectSubagent DelegationStateCounts
	TeamMember     DelegationStateCounts
	ParallelBranch DelegationStateCounts
	Subagents      DelegationSummary
	Parallel       DelegationSummary
	Team           LiveTeam
}

Delegation groups the uniform state counts by flat leaf unit. Total is the component-wise sum of direct subagent, team member, and parallel branch.

func (Delegation) Valid

func (d Delegation) Valid() bool

Valid reports whether Total is exactly the sum of the leaf units.

type DelegationStateCounts

type DelegationStateCounts struct {
	Running          int
	AwaitingApproval int
	Completed        int
	Failed           int
	Cancelled        int
	Stopped          int
}

DelegationStateCounts classifies delegated leaf work into mutually exclusive terminal and live states.

type DelegationSummary

type DelegationSummary struct {
	Running  int
	Finished int
}

DelegationSummary is the display-oriented running/finished projection of one leaf family. Finished deliberately collapses the detailed terminal states; raw DelegationStateCounts remains available for command handlers.

type Document

type Document struct {
	Header Surface
	Footer Surface
}

Document is a parsed StatusML document. Header and Footer are independently optional through their Present fields.

func Render

func Render(markup string, palette Palette) Document

Render parses bounded StatusML, safely literalizing malformed or unknown markup, then resolves every semantic token via palette. It never returns raw terminal control bytes from either markup text or palette data.

type Input

type Input struct {
	Version    uint8
	Server     ServerTarget
	Session    Session
	Model      Model
	Usage      Usage
	Context    Context
	Workspace  Workspace
	Terminal   Terminal
	MainAgent  MainAgent
	Delegation Delegation
	Clock      Clock
}

Input is the canonical, raw snapshot supplied to status handlers. It is intentionally a small allowlist: it carries display-safe session facts, never prompts, transcript/tool content, credentials, authentication metadata, diagnostics, or raw command output.

Commands receive this exact data as JSON. Template rendering receives a private, StatusML-escaped projection so template interpolation cannot create markup or terminal controls. The raw input remains available to commands for ordinary data use such as querying Git from Workspace.Path.

Renderer policy—clipping, safety/activity lanes, and context-bar glyph/style selection—does not belong here. Header and footer available widths are facts computed after those renderer reservations.

type LinkPalette

type LinkPalette interface {
	StatusLinkColor() string
	StatusLinkUnderline() bool
}

LinkPalette is an optional theme extension for StatusML links. Render never emits OSC 8; consumers decide how to display the validated destination.

type LiveTeam

type LiveTeam struct {
	ID      string
	Working int
	Total   int
}

LiveTeam is present only while a team is active. Completed teams intentionally disappear from the footer, unlike parallel and direct-subagent summaries.

type MainAgent

type MainAgent struct {
	State    string
	Activity string
	Approval string
}

MainAgent carries the main agent's display-safe activity. State is one of "connecting", "idle", "thinking", "running_tool", "awaiting_approval", "completed", "failed", or "cancelled". Activity is a bounded display label. Approval is "none" or "awaiting" and reflects whether a human verdict is pending.

type Model

type Model struct {
	ProviderID    string
	ID            string
	DisplayName   string
	Route         string
	ContextWindow ContextAtom
}

Model carries the provider-independent model facts selected for the session. ProviderID and ID are opaque routing identifiers; DisplayName is the operator- facing label. ContextWindow is the resolved model context capacity, not current session consumption.

type Palette

type Palette interface {
	StatusColor(Token) string
}

Palette resolves a StatusML semantic token through the active theme. It returns descriptive style data, never terminal control sequences.

type PassthroughEnvError added in v0.0.23

type PassthroughEnvError struct {
	ReservedName string
}

PassthroughEnvError reports an invalid passthrough environment name. ReservedName is empty when the value does not match the supported environment-name grammar.

func (*PassthroughEnvError) Error added in v0.0.23

func (e *PassthroughEnvError) Error() string

type Result

type Result struct {
	Header Surface
	Footer Surface
}

Result holds independently selected semantic surfaces. It never contains terminal rendering or control sequences.

type ServerTarget

type ServerTarget struct {
	// DisplayTarget is the credential-free connection target shown in chrome.
	DisplayTarget  string
	ConnectionMode string
}

ServerTarget identifies the display target and connection mode, without any authentication or endpoint credential data. ConnectionMode is one of "embedded" (the local in-process server) or "connect" (an explicitly dialed server); an empty value means the mode is not yet known.

type Session

type Session struct {
	Title           string
	Handle          string
	Mode            string
	ReasoningEffort string
}

Session carries optional user-facing session facts. Title is empty when no custom or generated title exists. Handle is the fixed, terminal-safe escaped session prefix used by ordinary mecatui presentation. Mode is the active permission mode. ReasoningEffort is either empty (unset or unsupported) or one of "low", "medium", "high", "xhigh", or "max".

type Source

type Source interface {
	Submit(Input)
	Changed() <-chan struct{}
	Latest() Result
	Close(context.Context) error
}

Source produces the latest semantic status-line surfaces from raw display facts. It is UI-agnostic: Changed is a wake-up edge, never a queue.

func NewCommandSource

func NewCommandSource(command Command) Source

NewCommandSource creates a local command-backed source. It passes complete raw Input JSON on stdin and never exposes command failures or captured output to the generated status line.

func NewDefaultSource

func NewDefaultSource(refreshInterval time.Duration) Source

NewDefaultSource creates the shipped source. It owns all default variants, including initial and partial-surface degradation.

func NewTemplateSource

func NewTemplateSource(templates TemplateSet, interval time.Duration) Source

NewTemplateSource creates a template source whose missing surfaces and variants use the shipped defaults.

type Span

type Span struct {
	Text      string
	Token     Token
	Color     string
	Href      string
	Underline bool
}

Span is one terminal-safe text run resolved through a Palette. Href is a separately validated link destination and is never included in Text.

type Surface

type Surface struct {
	Present bool
	Spans   []Span
}

Surface is an optional header or footer. Present distinguishes an absent surface from a present empty one. The renderer determines alignment by surface: headers are left-aligned and footers are right-aligned.

type SurfaceTemplates

type SurfaceTemplates struct{ Full, Compact, Minimal string }

SurfaceTemplates contains the three independently selected variants for one surface. Empty variants fall back to the corresponding shipped variant.

type TemplateSet

type TemplateSet struct{ Header, Footer SurfaceTemplates }

TemplateSet provides independent header and footer variant sets.

type Terminal

type Terminal struct {
	Rows            int
	Cols            int
	HeaderAvailCols int
	FooterAvailCols int
}

Terminal provides measured dimensions and independently reserved columns for status surfaces. Cols is the full terminal width. HeaderAvailCols and FooterAvailCols are the widths remaining after the renderer reserves mandatory header safety/navigation and footer activity lanes, respectively.

type Token

type Token string

Token is a closed semantic style vocabulary for StatusML text.

const (
	TokenText      Token = "text"
	TokenMuted     Token = "muted"
	TokenPrimary   Token = "primary"
	TokenSecondary Token = "secondary"
	TokenAccent    Token = "accent"
	TokenSuccess   Token = "success"
	TokenWarning   Token = "warning"
	TokenError     Token = "error"
	TokenInfo      Token = "info"
)

Token values are the only semantic styles StatusML accepts.

type Usage

type Usage struct {
	Input            UsageAtom
	Output           UsageAtom
	CacheRead        UsageAtom
	CacheWrite       UsageAtom
	CacheReadPercent int
}

Usage is the cumulative session usage summary. CacheRead is input served from the prompt cache (a subset of Input); CacheWrite is input written to the prompt cache. CacheReadPercent is the integer percentage CacheRead.Raw/Input.Raw, or zero when the input count is zero.

type UsageAtom

type UsageAtom struct {
	Raw   int64
	Human string
}

UsageAtom carries an exact non-negative token count and the same count rendered with the standard compact display notation (for example, "1.1M"). Raw is for arithmetic or command handlers; Human is a display-ready atom.

type Workspace

type Workspace struct {
	Location string
	Path     string
	Basename string
}

Workspace is the active session workspace only. Location is "local", "remote", or "unknown". Path and Basename are populated only for a local workspace; remote and unknown workspaces must not be presented as usable local command paths.

Jump to

Keyboard shortcuts

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