Documentation
¶
Overview ¶
Package customization defines the display-only, dependency-leaf presentation customization protocol shared by mecatui composition and UI status-line renderers.
Index ¶
- Constants
- func ClearCommandCWD(source Source)
- func DefaultTitleTemplate() string
- func SetCommandCWD(source Source, cwd string)
- type Clock
- type Command
- type CommandDiagnostics
- type CommandDiagnosticsSource
- type Context
- type ContextAtom
- type Delegation
- type DelegationStateCounts
- type DelegationSummary
- type Document
- type Input
- type LinkPalette
- type LiveTeam
- type MainAgent
- type Model
- type Palette
- type PassthroughEnvError
- type Result
- type ServerTarget
- type Session
- type Source
- type Span
- type Surface
- type SurfaceTemplates
- type TemplateSet
- type Terminal
- type TitleRenderer
- type Token
- type Usage
- type UsageAtom
- type Workspace
Constants ¶
const ( CommandSurfaceDefault = "default" CommandSurfaceCustom = "custom" CommandSurfaceStale = "stale" CommandErrorNone = "none" CommandErrorUnsupported = "unsupported" CommandErrorTimeout = "timeout" CommandErrorOutputLimit = "output_limit" CommandErrorInvalidStatusML = "invalid_statusml" CommandErrorExit = "exit" CommandErrorFailed = "failed" )
CommandSurfaceDefault, CommandSurfaceCustom, and CommandSurfaceStale describe whether the latest command result uses a shipped, custom, or stale surface. CommandErrorNone, CommandErrorUnsupported, CommandErrorTimeout, CommandErrorOutputLimit, CommandErrorInvalidStatusML, CommandErrorExit, and CommandErrorFailed classify a command result without exposing failure details.
const ( // ProtocolVersion is the current Input wire-independent contract version. ProtocolVersion uint8 = 6 )
Variables ¶
This section is empty.
Functions ¶
func ClearCommandCWD ¶
func ClearCommandCWD(source Source)
ClearCommandCWD clears the direct command's local-session CWD so it falls back to the configured helper directory until a lookup supplies a new root.
func DefaultTitleTemplate ¶
func DefaultTitleTemplate() string
DefaultTitleTemplate returns the terminal-title template shipped with mecatui.
func SetCommandCWD ¶
SetCommandCWD updates the private process working directory for a direct command source. The directory is never part of Input or status rendering.
Types ¶
type Clock ¶
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
// contains filtered or unexported fields
}
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 ¶
Valid reports whether command specifies an absolute executable and literal args.
func (Command) ValidatePassthroughEnv ¶
ValidatePassthroughEnv reports whether PassthroughEnv has valid names that do not override values owned by the status-command environment.
type CommandDiagnostics ¶
CommandDiagnostics is the safe, coarse status of the latest completed command. Its fields are closed vocabularies: Header/Footer are default, custom, or stale; Error is none, unsupported, timeout, output_limit, invalid_statusml, exit, or failed.
type CommandDiagnosticsSource ¶
type CommandDiagnosticsSource interface {
CommandDiagnostics() CommandDiagnostics
}
CommandDiagnosticsSource is optionally implemented by command-backed sources. Template and default sources intentionally expose no command diagnostics.
type Context ¶
type Context struct {
Used ContextAtom
Window ContextAtom
Percent int
Known bool
Estimated bool
}
Context describes current context-window consumption. Known reports whether Used reflects a known occupancy; Estimated reports whether that occupancy is an estimate. Percent is Used.Raw as an integer percentage of Window.Raw, or zero when the window or occupancy 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 ¶
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 ¶
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
}
Document is a parsed StatusML document. Header and Footer are independently optional through their Present fields.
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 display-safe status data.
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 ¶
LinkPalette is an optional theme extension for StatusML links. The UI renderer uses the separately validated destination when emitting terminal output.
type LiveTeam ¶
LiveTeam is present only while a team is active. Completed teams intentionally disappear from the footer, unlike parallel and direct-subagent summaries.
type MainAgent ¶
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
ProviderLabel string
FriendlyName string
Route string
ContextWindow ContextAtom
}
Model carries the provider-independent model facts selected for the session. ProviderID and ID are opaque routing identifiers. ProviderLabel is the resolved provider/model identity for display (or the raw model ID when the provider is unknown); FriendlyName is the inventory name, falling back to ID. Route is an observed downstream route, not part of the model identity. ContextWindow is the resolved model context capacity, not current session consumption.
type Palette ¶
Palette resolves a StatusML semantic token through the active theme. It returns descriptive style data, never terminal control sequences.
type PassthroughEnvError ¶
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 ¶
func (e *PassthroughEnvError) Error() string
type Result ¶
type Result struct {
Header 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 ¶
Session carries optional user-facing session facts. Title is empty when no custom or generated title exists. Handle is the short displayed 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 ¶
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 ¶
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 ¶
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 ¶
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 Terminal ¶
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. Emoji reports whether the terminal is likely to render emoji presentation (for example ⚡️) at its expected width; it is a conservative, environment-based guess fixed for the process.
type TitleRenderer ¶
type TitleRenderer struct {
// contains filtered or unexported fields
}
TitleRenderer renders a plain-text title from the display-safe status input. It deliberately has no StatusML parsing or command-source integration.
func NewTitleRenderer ¶
func NewTitleRenderer(source string) (*TitleRenderer, error)
NewTitleRenderer validates and compiles a title template. The startup render catches template expressions which parse successfully but cannot execute against the status projection.
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" // TokenDanger renders as the filled, theme-independent alarm pill (the yolo // mode marker) rather than a foreground colour. TokenDanger Token = "danger" )
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 ¶
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 ¶
Workspace is the active session workspace's display-safe provenance. Location is "local", "remote", or "unknown". Name is provider-supplied display metadata, not a filesystem basename. Path is supplied to status templates through their StatusML-escaped projection and to a direct local status command after the privileged local-context RPC has returned an eligible local root. It is otherwise empty and is not part of universal client projections.