Documentation
¶
Overview ¶
Package evo is Evident Output: a presentation library for CLI state, progress, evidence, changes, plans, messages, actions, and conclusions.
Application code owns execution. Evo owns presentation.
func main() {
out := evo.For("repo", evo.WriterOptions(os.Stdout, evo.Diagnostics(os.Stderr))...)
os.Exit(evo.Main(out, run))
}
func run(out *evo.Output) error {
t := out.Task("fetch")
output := t.Capture()
// run.Run(ctx, "git", args, output); t.Fail(..., output.DetailTail()) on error
return nil
}
Index ¶
- Constants
- Variables
- func EncodeJSON(s Snapshot, _ ...JSONOptions) ([]byte, error)
- func EncodeJSONL(events []Event, _ ...JSONLOptions) ([]byte, error)
- func IsCharDevice(w io.Writer) bool
- func Main(out *Output, run func(*Output) error) int
- func RenderPlain(s Snapshot, opts PlainOptions) ([]byte, error)
- type Action
- type CapabilityProfile
- type Capture
- func (c *Capture) Close() error
- func (c *Capture) DetailTail() ProblemOption
- func (c *Capture) Empty() bool
- func (c *Capture) Lines() []string
- func (c *Capture) Stderr() io.Writer
- func (c *Capture) Stdout() io.Writer
- func (c *Capture) Tail(n ...int) string
- func (c *Capture) TaskName() string
- func (c *Capture) Text() string
- func (c *Capture) Write(p []byte) (int, error)
- type CaptureOption
- type Changes
- func (c *Changes) Added(quantity int64, object string) *Changes
- func (c *Changes) Created(object string) *Changes
- func (c *Changes) Moved(source, destination string) *Changes
- func (c *Changes) Record(verb string, quantity int64, object string) *Changes
- func (c *Changes) Removed(quantity int64, object string) *Changes
- func (c *Changes) Reused(quantity int64, object string) *Changes
- func (c *Changes) Updated(quantity int64, object string) *Changes
- func (c *Changes) Wrote(object string) *Changes
- type ChangesSnapshot
- type ColorLevel
- type CommandSpec
- type Conclusion
- type ConclusionJSON
- type ConclusionState
- type Config
- type DebugPaneOption
- type DebugPresentation
- type EffectRecord
- type EntityState
- type Event
- type EventJSON
- type Evidence
- type Field
- type FixedClock
- type Item
- func (i *Item) Because(text string) *Item
- func (i *Item) Block(summary string, options ...ProblemOption) *Item
- func (i *Item) BlockedBy(problems ...Problem) *Item
- func (i *Item) Fail(summary string, options ...ProblemOption) *Item
- func (i *Item) FailedBy(problems ...Problem) *Item
- func (i *Item) Next(actions ...Action) *Item
- func (i *Item) NextCommand(executable string, args ...string) *Item
- func (i *Item) OK() *Item
- func (i *Item) Skip(reason string) *Item
- func (i *Item) Snapshot() ItemSnapshot
- func (i *Item) Start() *Item
- func (i *Item) Unknown(summary string, options ...ProblemOption) *Item
- func (i *Item) Warn(summary string, options ...ProblemOption) *Item
- func (i *Item) WarnedBy(problems ...Problem) *Item
- type ItemSnapshot
- type ItemSpec
- type JSONAction
- type JSONChanges
- type JSONCollection
- type JSONCommand
- type JSONDocument
- type JSONEffectRecord
- type JSONItem
- type JSONLOptions
- type JSONOptions
- type JSONOutputMeta
- type JSONPlan
- type JSONProblem
- type JSONProgress
- type JSONTask
- type LiveSurface
- type Location
- type LogLevel
- type NoopRedactor
- type Option
- func AlsoWrite(w io.Writer) Option
- func Clock(ts TimeSource) Option
- func DataProjection() Option
- func DebugHistory() Option
- func DebugLevel(level LogLevel) Option
- func DebugPane(opts ...DebugPaneOption) Option
- func Diagnostics(w io.Writer) Option
- func ExternalProjection() Option
- func MaxEntities(n int) Option
- func MaxEvents(n int) Option
- func MaxFrameRate(framesPerSecond int) Option
- func NoColor() Option
- func NonInteractive() Option
- func Plain() Option
- func Redact(r Redactor) Option
- func Strict() Option
- func Terminal(driver TerminalDriver) Option
- func To(w io.Writer) Option
- func VisibilityDelay(delay time.Duration) Option
- func Width(columns int) Option
- func WriterOptions(w io.Writer, extra ...Option) []Option
- type Output
- func (o *Output) AnyBlocked() bool
- func (o *Output) AnyFailed() bool
- func (o *Output) Cancel(reason string)
- func (o *Output) Capture(opts ...CaptureOption) *Capture
- func (o *Output) Changes(subject string) *Changes
- func (o *Output) Close() error
- func (o *Output) Conclusion() Conclusion
- func (o *Output) Debug(message string, fields ...Field)
- func (o *Output) DebugWriter() io.WriteCloser
- func (o *Output) Err() error
- func (o *Output) ErrorMessage(message string, _ ...Field)
- func (o *Output) Events() []Event
- func (o *Output) Explain(text string)
- func (o *Output) Fail(summary string, options ...ProblemOption)
- func (o *Output) FinalPlain() string
- func (o *Output) Finish() error
- func (o *Output) Info(message string, _ ...Field)
- func (o *Output) Item(name string) *Item
- func (o *Output) ItemWith(spec ItemSpec) (*Item, error)
- func (o *Output) Line(message string)
- func (o *Output) Linef(format string, args ...any)
- func (o *Output) Next(actions ...Action)
- func (o *Output) NextCommand(executable string, args ...string)
- func (o *Output) Plan(subject string) *Plan
- func (o *Output) SlogHandler(min slog.Leveler) slog.Handler
- func (o *Output) Snapshot() Snapshot
- func (o *Output) Snapshots() <-chan Snapshot
- func (o *Output) Suspend(fn func() error) error
- func (o *Output) Task(name string) *Task
- func (o *Output) Tasks(name string) *Tasks
- func (o *Output) WarnMessage(message string, _ ...Field)
- type PlainOptions
- type Plan
- func (p *Plan) Add(quantity int64, object string) *Plan
- func (p *Plan) Create(object string) *Plan
- func (p *Plan) Delete(quantity int64, object string) *Plan
- func (p *Plan) Move(source, destination string) *Plan
- func (p *Plan) Record(verb string, quantity int64, object string) *Plan
- func (p *Plan) Remove(quantity int64, object string) *Plan
- func (p *Plan) Retain(description string) *Plan
- func (p *Plan) Revoke(quantity int64, object string) *Plan
- func (p *Plan) Update(quantity int64, object string) *Plan
- func (p *Plan) Write(object string) *Plan
- type PlanSnapshot
- type Problem
- type ProblemOption
- func At(path string, line, column int) ProblemOption
- func Cause(err error) ProblemOption
- func Code(value string) ProblemOption
- func Count(value int64, unit ...string) ProblemOption
- func Detail(text string) ProblemOption
- func DetailTail(c *Capture) ProblemOption
- func Next(action Action) ProblemOption
- func NextCommand(executable string, args ...string) ProblemOption
- func On(subject string) ProblemOption
- type Progress
- type ProgressKind
- type ProjectionPolicy
- type Redactor
- type Snapshot
- type SystemClock
- type Task
- func (t *Task) Advance(delta int64) *Task
- func (t *Task) Bytes(completed, total int64) *Task
- func (t *Task) Cancel(reason string) *Task
- func (t *Task) Capture(opts ...CaptureOption) *Capture
- func (t *Task) Done() *Task
- func (t *Task) Donef(format string, args ...any) *Task
- func (t *Task) Fail(summary string, options ...ProblemOption) *Task
- func (t *Task) Next(actions ...Action) *Task
- func (t *Task) NextCommand(executable string, args ...string) *Task
- func (t *Task) Phase(text string) *Task
- func (t *Task) Progress(completed, total int64) *Task
- func (t *Task) Skip(reason string) *Task
- func (t *Task) Snapshot() TaskSnapshot
- func (t *Task) Warn(summary string, options ...ProblemOption) *Task
- type TaskSnapshot
- type Tasks
- type TasksSnapshot
- type TerminalDriver
- type TimeSource
Constants ¶
const ( ExitOK = 0 ExitBlocked = 1 ExitFailed = 2 ExitCancelled = 130 )
Default exit codes from architecture §26.
const Debug = LevelDebug
Debug is the debug log level (Appendix H).
const EventSchemaVersion = "1.0"
EventSchemaVersion is the durable event schema version (§25.2).
const JSONSchemaVersion = "1.0"
JSONSchemaVersion is the final JSON document schema version (§25.1).
Variables ¶
var ( ErrClosed = errors.New("evo: output is closed") ErrAlreadyResolved = errors.New("evo: entity is already resolved") ErrNoProblems = errors.New("evo: structured resolution requires problems") ErrUnresolvedItem = errors.New("evo: item has no final state") ErrUnresolvedTask = errors.New("evo: task has no final state") ErrInvalidProgress = errors.New("evo: invalid progress") ErrProgressRegression = errors.New("evo: progress moved backward") ErrDuplicateKey = errors.New("evo: duplicate entity key") ErrInvalidConfig = errors.New("evo: invalid configuration") ErrRenderer = errors.New("evo: renderer failure") ErrFinishing = errors.New("evo: output is finishing") ErrLimitExceeded = errors.New("evo: resource limit exceeded") )
Sentinel misuse and lifecycle errors recorded by the output aggregate.
Functions ¶
func EncodeJSON ¶
func EncodeJSON(s Snapshot, _ ...JSONOptions) ([]byte, error)
EncodeJSON encodes a snapshot as final JSON (§25.1 / §25.4).
func EncodeJSONL ¶
func EncodeJSONL(events []Event, _ ...JSONLOptions) ([]byte, error)
EncodeJSONL encodes durable events as JSON Lines (§25.2 / §25.4).
func IsCharDevice ¶
IsCharDevice reports whether w is an *os.File backed by a character device (typical interactive TTY). Pipes, files, and non-file writers return false.
Use when choosing Plain / NoColor defaults so agents capturing CLI output do not get ANSI noise.
func Main ¶
Main runs a CLI presentation lifecycle and returns the process exit code.
Typical entrypoint:
func main() {
out := evo.For("tool", evo.To(os.Stdout))
os.Exit(evo.Main(out, run))
}
func run(out *evo.Output) error {
out.Item("working tree").OK()
return nil
}
Lifecycle: run → Finish → Close (via defer).
Exit codes:
- nil out → ExitFailed (2)
- Finish error (presentation misuse / render) → ExitFailed (2)
- run error while conclusion is still OK → ExitFailed (2)
- otherwise Conclusion.ExitCode (OK=0, Blocked=1, Failed=2, Cancelled=130)
Application code still owns execution; Main only seals presentation and maps conclusion state to an exit code so every binary does not reimplement teardown.
func RenderPlain ¶
func RenderPlain(s Snapshot, opts PlainOptions) ([]byte, error)
RenderPlain projects a snapshot to plain text without terminal ownership.
Types ¶
type Action ¶
type Action struct {
Label string
Command *CommandSpec
URL string
File string
Explanation string
RequiresConfirmation bool
Destructive bool
}
Action is a recommended next step for the user.
type CapabilityProfile ¶
type CapabilityProfile struct {
Interactive bool
Color ColorLevel
Unicode bool
Width int
Height int
NoColor bool
}
CapabilityProfile holds terminal capability facts (§22).
func DetectCapabilities ¶
func DetectCapabilities(opts ...Option) CapabilityProfile
DetectCapabilities builds a profile from options and environment-like hints. It does not read the real environment in the core package without injection; callers pass NoColor/Width/NonInteractive options instead.
type Capture ¶ added in v0.1.1
type Capture struct {
// contains filtered or unexported fields
}
Capture is a process-output sink owned by a Task (preferred) or Output.
Recommended:
upgrade := out.Task("brew packages")
output := upgrade.Capture()
if err := run.Run(ctx, "brew", args, output); err != nil {
upgrade.Fail("brew upgrade failed", evo.Cause(err), output.DetailTail())
return nil
}
upgrade.Done()
Semantics:
- Always retains a bounded ring of sanitized lines (evidence exists even when debug presentation is disabled).
- Implements io.Writer; concurrency-safe.
- Never paints the live Items/Tasks region; never auto-surfaces on success.
- Mirrors to Diagnostics when configured; mirrors to Debug journal when DebugLevel allows (task-labeled).
- DetailTail is user-visible failure evidence; Cause is structured diagnostic.
Application code still owns process execution. Capture only owns presentation evidence.
func (*Capture) Close ¶ added in v0.1.1
Close flushes a trailing partial line. Idempotent for use with defer.
func (*Capture) DetailTail ¶ added in v0.1.2
func (c *Capture) DetailTail() ProblemOption
DetailTail returns a ProblemOption that attaches a user-visible presentation of the capture tail. Prefer stderr content when separate streams were used. Does not mutate the task; compose with Fail/Block/Warn:
upgrade.Fail("brew upgrade failed", evo.Cause(err), output.DetailTail())
func (*Capture) Lines ¶ added in v0.1.2
Lines returns a copy of retained combined lines (oldest first).
func (*Capture) Stderr ¶ added in v0.1.2
Stderr returns a writer that records lines as stderr (and into the combined ring).
func (*Capture) Stdout ¶ added in v0.1.2
Stdout returns a writer that records lines as stdout (and into the combined ring). Use when the runner supports separate streams:
cmd.Stdout = output.Stdout() cmd.Stderr = output.Stderr()
func (*Capture) Tail ¶ added in v0.1.1
Tail returns the last n retained combined lines joined by newlines. If n <= 0, returns the full retained ring (same as Text).
func (*Capture) TaskName ¶ added in v0.1.2
TaskName returns the owning task name when created via Task.Capture.
type CaptureOption ¶ added in v0.1.1
type CaptureOption interface {
// contains filtered or unexported methods
}
CaptureOption configures Capture.
func CaptureBytes ¶ added in v0.1.1
func CaptureBytes(n int) CaptureOption
CaptureBytes sets an approximate byte budget for retained lines (default 256KiB).
func CaptureLines ¶ added in v0.1.1
func CaptureLines(n int) CaptureOption
CaptureLines sets how many trailing lines are retained (default 200).
func CaptureQuiet ¶ added in v0.1.1
func CaptureQuiet() CaptureOption
CaptureQuiet disables Diagnostics and Debug mirrors (buffer/Tail only).
func KeepLastLines ¶ added in v0.1.2
func KeepLastLines(n int) CaptureOption
KeepLastLines sets how many trailing lines are retained (default 200). Alias of CaptureLines for the designer-facing name.
func MaxCaptureBytes ¶ added in v0.1.2
func MaxCaptureBytes(n int) CaptureOption
MaxCaptureBytes sets an approximate byte budget for retained lines (default 256KiB). Alias of CaptureBytes.
type Changes ¶
type Changes struct {
// contains filtered or unexported fields
}
Changes is a handle for durable effects that already occurred.
type ChangesSnapshot ¶
type ChangesSnapshot struct {
ID string
Subject string
Records []EffectRecord
}
ChangesSnapshot is an immutable changes section.
type ColorLevel ¶
type ColorLevel int
ColorLevel describes terminal color support.
const ( ColorNone ColorLevel = iota ColorBasic Color256 ColorTrue )
type CommandSpec ¶
CommandSpec is an executable plus argv (never a shell string).
type Conclusion ¶
type Conclusion struct {
State ConclusionState
Subject string
Changed bool
Partial bool
Cancelled bool
Explanation string
Items []ItemSnapshot
Tasks []TaskSnapshot
Collections []TasksSnapshot
Changes []ChangesSnapshot
Plans []PlanSnapshot
Actions []Action
ExitCode int
}
Conclusion is the multidimensional meaning of a finished command.
func (Conclusion) AnyBlocked ¶
func (c Conclusion) AnyBlocked() bool
AnyBlocked reports whether the finished conclusion is blocked, or any item snapshot is.
type ConclusionJSON ¶
type ConclusionJSON struct {
State ConclusionState `json:"state"`
Changed bool `json:"changed"`
Partial bool `json:"partial"`
Cancelled bool `json:"cancelled"`
ExitCode int `json:"exit_code"`
Explanation string `json:"explanation,omitempty"`
}
ConclusionJSON is JSON-friendly conclusion.
type ConclusionState ¶
type ConclusionState string
ConclusionState is the human headline for a finished output.
const ( StateReady ConclusionState = "ready" StateChanged ConclusionState = "changed" StateUnchanged ConclusionState = "unchanged" StateWarning ConclusionState = "warning" StateBlocked ConclusionState = "blocked" StateFailed ConclusionState = "failed" StateCancelled ConclusionState = "cancelled" StatePlanned ConclusionState = "planned" StatePartial ConclusionState = "partial" )
type Config ¶
type Config struct {
Subject string
Primary io.Writer
Diagnostic io.Writer
Projection ProjectionPolicy
Clock TimeSource
Redactor Redactor
Capabilities *CapabilityProfile
Strict bool
Plain bool
NoColor bool
Width int
}
Config is advanced construction for tests and embedding.
type DebugPaneOption ¶
type DebugPaneOption interface {
// contains filtered or unexported methods
}
DebugPaneOption configures DebugPane presentation.
func NewestFirst ¶
func NewestFirst() DebugPaneOption
NewestFirst orders the pane with the most recent record first (default).
func OldestFirst ¶
func OldestFirst() DebugPaneOption
OldestFirst orders the pane chronologically (oldest visible first).
func PaneHeight ¶
func PaneHeight(lines int) DebugPaneOption
PaneHeight sets how many debug records are visible in the pane (not including heading).
func PreserveDebugTail ¶
func PreserveDebugTail() DebugPaneOption
PreserveDebugTail always emits a bounded diagnostic tail under the final report. Without this, pane mode still preserves a tail on failed/blocked/cancelled conclusions.
type DebugPresentation ¶
type DebugPresentation int
DebugPresentation selects how structured debug records project to a TTY (§4.6 / §21.3).
const ( // DebugPresentationHistory appends durable scrollback above the live region (default). DebugPresentationHistory DebugPresentation = iota // DebugPresentationPane keeps a bounded rolling viewport inside the live region. DebugPresentationPane )
type EffectRecord ¶
EffectRecord is one semantic change or plan row.
type EntityState ¶
type EntityState string
EntityState is the lifecycle state of an item or task.
const ( Pending EntityState = "pending" Running EntityState = "running" OK EntityState = "ok" Done EntityState = "done" Warning EntityState = "warning" Blocked EntityState = "blocked" Failed EntityState = "failed" Unknown EntityState = "unknown" Skipped EntityState = "skipped" Cancelled EntityState = "cancelled" Empty EntityState = "empty" Incomplete EntityState = "incomplete" )
type Event ¶
type Event struct {
SchemaVersion string
Sequence uint64
Timestamp time.Time
Type string
OutputID string
EntityID string
Name string
State string
Completed *int64
Total *int64
Activation string
Payload map[string]any
}
Event is an immutable journal record.
type EventJSON ¶
type EventJSON struct {
SchemaVersion string `json:"schema_version"`
Sequence uint64 `json:"sequence"`
Type string `json:"type"`
OutputID string `json:"output_id,omitempty"`
EntityID string `json:"entity_id,omitempty"`
Name string `json:"name,omitempty"`
State string `json:"state,omitempty"`
Completed *int64 `json:"completed,omitempty"`
Total *int64 `json:"total,omitempty"`
Activation string `json:"activation,omitempty"`
Timestamp time.Time `json:"timestamp,omitempty"`
}
EventJSON is a JSON Lines event record (§25.2).
type Field ¶
Field is a structured diagnostic or log field.
type FixedClock ¶
FixedClock always returns the same instant.
type Item ¶
type Item struct {
// contains filtered or unexported fields
}
Item is a handle for one named final-report condition.
func (*Item) Block ¶
func (i *Item) Block(summary string, options ...ProblemOption) *Item
Block marks the item blocked with a simple problem.
func (*Item) Fail ¶
func (i *Item) Fail(summary string, options ...ProblemOption) *Item
Fail marks the item failed with a simple problem.
func (*Item) NextCommand ¶
NextCommand attaches a command action.
func (*Item) Snapshot ¶
func (i *Item) Snapshot() ItemSnapshot
Snapshot returns the item's current snapshot.
func (*Item) Start ¶
Start marks the item running so it becomes visible in the live region (indeterminate) while the application evaluates it. Optional: OK/Block/… may resolve pending items directly without Start (no transient frame when resolution is instant — §7.4 rule 5).
func (*Item) Unknown ¶
func (i *Item) Unknown(summary string, options ...ProblemOption) *Item
Unknown marks the item undetermined.
type ItemSnapshot ¶
type ItemSnapshot struct {
ID string
Name string
State EntityState
Problems []Problem
Because string
Actions []Action
Declaration int
}
ItemSnapshot is an immutable item view.
type ItemSpec ¶
type ItemSpec struct {
Key string
Name string
Description string
Order int
Hidden bool
ManualStart bool
}
ItemSpec is advanced item construction (§11.3).
type JSONAction ¶
type JSONAction struct {
Label string `json:"label,omitempty"`
Command *JSONCommand `json:"command,omitempty"`
URL string `json:"url,omitempty"`
}
JSONAction is a wire-format action.
type JSONChanges ¶
type JSONChanges struct {
ID string `json:"id"`
Subject string `json:"subject"`
Records []JSONEffectRecord `json:"records"`
}
JSONChanges is wire-format changes.
type JSONCollection ¶
type JSONCollection struct {
ID string `json:"id"`
Name string `json:"name"`
State EntityState `json:"state"`
Summary string `json:"summary,omitempty"`
Children []string `json:"children"`
}
JSONCollection is a wire-format task collection with child IDs (§25.1).
type JSONCommand ¶
type JSONCommand struct {
Executable string `json:"executable"`
Args []string `json:"args,omitempty"`
}
JSONCommand is argv for display.
type JSONDocument ¶
type JSONDocument struct {
SchemaVersion string `json:"schema_version"`
Output JSONOutputMeta `json:"output"`
Conclusion ConclusionJSON `json:"conclusion"`
Items []JSONItem `json:"items"`
TaskCollections []JSONCollection `json:"task_collections"`
Tasks []JSONTask `json:"tasks"`
Changes []JSONChanges `json:"changes"`
Plans []JSONPlan `json:"plans"`
Actions []JSONAction `json:"actions"`
}
JSONDocument is the final machine projection (§25.1).
type JSONEffectRecord ¶
type JSONEffectRecord struct {
Verb string `json:"verb"`
Quantity *int64 `json:"quantity,omitempty"`
Object string `json:"object"`
}
JSONEffectRecord is a change/plan row.
type JSONItem ¶
type JSONItem struct {
ID string `json:"id"`
Name string `json:"name"`
State EntityState `json:"state"`
Problems []JSONProblem `json:"problems"`
Because string `json:"because,omitempty"`
}
JSONItem is a wire-format item.
type JSONOutputMeta ¶
JSONOutputMeta identifies the output instance.
type JSONPlan ¶
type JSONPlan struct {
ID string `json:"id"`
Subject string `json:"subject"`
Records []JSONEffectRecord `json:"records"`
}
JSONPlan is wire-format plan.
type JSONProblem ¶
type JSONProblem struct {
Subject string `json:"subject,omitempty"`
Summary string `json:"summary,omitempty"`
Detail string `json:"detail,omitempty"`
Count int64 `json:"count,omitempty"`
Unit string `json:"unit,omitempty"`
Code string `json:"code,omitempty"`
}
JSONProblem is a wire-format problem (no raw Cause by default).
type JSONProgress ¶
type JSONProgress struct {
Kind ProgressKind `json:"kind"`
Completed int64 `json:"completed"`
Total int64 `json:"total"`
}
JSONProgress is wire-format progress.
type JSONTask ¶
type JSONTask struct {
ID string `json:"id"`
Name string `json:"name"`
State EntityState `json:"state"`
Phase string `json:"phase,omitempty"`
Summary string `json:"summary,omitempty"`
Progress *JSONProgress `json:"progress,omitempty"`
Problems []JSONProblem `json:"problems,omitempty"`
}
JSONTask is a wire-format task.
type LiveSurface ¶
type LiveSurface interface {
TerminalDriver
Columns() int
Rows() int
IsInteractive() bool
WriteLive(text string)
ClearLive()
WriteDurable(line string)
WriteFinal(text string)
}
LiveSurface is an interactive terminal sink for live-region rendering. testkit.Screen implements this; production drivers can as well.
type NoopRedactor ¶
type NoopRedactor struct{}
NoopRedactor leaves strings unchanged.
func (NoopRedactor) RedactString ¶
func (NoopRedactor) RedactString(s string) string
RedactString implements Redactor.
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option configures an Output.
func AlsoWrite ¶
AlsoWrite adds an additional human projection writer. On Finish, each writer receives the plain projection; failures on one do not skip the others (CON-009).
func DataProjection ¶
func DataProjection() Option
DataProjection selects data-command mode (UI/progress on diagnostic stream).
func DebugHistory ¶
func DebugHistory() Option
DebugHistory selects durable append-above-and-redraw presentation (v0.4 default).
func DebugLevel ¶
DebugLevel sets the minimum debug emission level.
func DebugPane ¶
func DebugPane(opts ...DebugPaneOption) Option
DebugPane selects a rolling TTY debug viewport at the bottom of the live region.
func Diagnostics ¶
Diagnostics sets the diagnostic writer for Debug history and Capture mirrors. When set and distinct from the primary writer (To), Debug lines are not also written to the human primary stream — use dual-stream for LaunchAgent / data-command layouts (human on stdout, diagnostics on stderr).
func ExternalProjection ¶
func ExternalProjection() Option
ExternalProjection selects snapshot-only host rendering.
func MaxEntities ¶
MaxEntities caps total items and tasks for one Output (0 uses default).
func MaxEvents ¶
MaxEvents caps durable journal events; when exceeded, oldest non-critical events are dropped so critical terminal events are retained (CON-008).
func MaxFrameRate ¶
MaxFrameRate caps interactive redraws per second.
func Plain ¶
func Plain() Option
Plain forces final-report projection (no live spinner region). Semantic color is still emitted unless NoColor is set.
func Terminal ¶
func Terminal(driver TerminalDriver) Option
Terminal injects a terminal driver (interactive projection; v0.2).
func VisibilityDelay ¶
VisibilityDelay sets the spinner visibility threshold.
func WriterOptions ¶
WriterOptions returns presentation options appropriate for human writer w.
On a TTY: color allowed (callers that honor NO_COLOR should pass NoColor themselves when the env is set). Off-TTY (*os.File that is not a char device): Plain + NoColor so piped/agent logs stay free of CSI. Non-file writers (buffers) are left unchanged so tests can still assert color rendering.
Always includes To(w). Pass Diagnostics(os.Stderr) in extra for dual-stream CLIs — Debug and Capture mirrors go to Diagnostics; Items/Tasks stay on w. Extra options are applied after defaults (they win on conflicts when options overwrite the same field).
out := evo.For("tool", evo.WriterOptions(os.Stdout, evo.Diagnostics(os.Stderr))...)
type Output ¶
type Output struct {
// contains filtered or unexported fields
}
Output is the aggregate root for one command's presentation lifecycle.
func NewWithConfig ¶
NewWithConfig builds an Output from advanced configuration.
func (*Output) AnyBlocked ¶
AnyBlocked reports whether any Item is currently in the Blocked state. Use before mutation: if out.AnyBlocked() { return nil } then Finish via Main.
func (*Output) Capture ¶ added in v0.1.1
func (o *Output) Capture(opts ...CaptureOption) *Capture
Capture returns an unscoped process sink (no owning task). Prefer Task.Capture so failure evidence is associated with the operation.
func (*Output) Conclusion ¶
func (o *Output) Conclusion() Conclusion
Conclusion returns the computed conclusion after Finish.
func (*Output) Debug ¶
Debug records a structured diagnostic (§4.6 / §21.3).
History mode (default): durable scrollback above the live region (or plain stream). Pane mode: record is journaled and shown in the rolling live pane; not durable scrollback unless a diagnostic tail is preserved at Finish.
When Diagnostics is configured and is a different writer than the primary stream, debug lines go to Diagnostics only (not the human Items/Tasks stream). Use Capture for child-process evidence instead of DebugWriter when you need Fail Detail.
func (*Output) DebugWriter ¶
func (o *Output) DebugWriter() io.WriteCloser
DebugWriter returns a line-oriented writer that emits Debug lines on newline. Partial UTF-8 sequences are buffered; control bytes are sanitized.
Prefer Capture for external process stdout/stderr: DebugWriter is filtered by DebugLevel (default LevelInfo drops all lines) and is the wrong dialect for child-command evidence used in Fail Detail. Use DebugWriter only when you intentionally want DEBUG-level journal lines (and set DebugLevel(Debug)).
func (*Output) ErrorMessage ¶
ErrorMessage emits an error durable line (not an item failure).
func (*Output) Fail ¶
func (o *Output) Fail(summary string, options ...ProblemOption)
Fail records an output-level failure.
func (*Output) FinalPlain ¶
FinalPlain returns the last rendered plain text after Finish.
func (*Output) Finish ¶
Finish validates, computes conclusion, emits final projections. Projection I/O runs outside the domain lock (§17.1).
func (*Output) Line ¶
Line emits a durable user-facing line immediately (not buffered until Finish).
func (*Output) NextCommand ¶
NextCommand attaches an output-level command action.
func (*Output) SlogHandler ¶
SlogHandler returns a slog.Handler that routes records through Output.Debug/Info lines.
func (*Output) Snapshots ¶
Snapshots returns a buffered channel of immutable snapshots. The channel is closed when the output is closed or finished. Callers should not block the library; buffer absorbs bursts.
func (*Output) Suspend ¶
Suspend temporarily pauses interactive presentation for host-owned output. In v0.3 plain/non-interactive mode this is a no-op around fn. With a live surface it clears the live region, runs fn, then resumes.
func (*Output) WarnMessage ¶
WarnMessage emits a warning durable line (not an item warning).
type PlainOptions ¶
PlainOptions configures pure plain projection (§25.4).
type Plan ¶
type Plan struct {
// contains filtered or unexported fields
}
Plan is a handle for effects that would occur but have not.
type PlanSnapshot ¶
type PlanSnapshot struct {
ID string
Subject string
Records []EffectRecord
}
PlanSnapshot is an immutable plan section.
type Problem ¶
type Problem struct {
Code string
Subject string
Summary string
Detail string
Severity string
Count int64
Unit string
Location *Location
Evidence []Evidence
Actions []Action
Fields []Field
Cause error
Sensitive bool
}
Problem is structured evidence explaining a negative item or task outcome.
type ProblemOption ¶
type ProblemOption interface {
// contains filtered or unexported methods
}
ProblemOption configures a problem constructed by Block/Warn/Fail helpers.
func Cause ¶
func Cause(err error) ProblemOption
Cause attaches a diagnostic error (not shown by default in human output).
func Count ¶
func Count(value int64, unit ...string) ProblemOption
Count sets a quantity and optional unit.
func Detail ¶
func Detail(text string) ProblemOption
Detail sets user-visible detail text (strings only).
func DetailTail ¶ added in v0.1.1
func DetailTail(c *Capture) ProblemOption
DetailTail is a free-function form of Capture.DetailTail for older call sites. Prefer output.DetailTail() on the capture value.
func NextCommand ¶
func NextCommand(executable string, args ...string) ProblemOption
NextCommand attaches a recommended command action.
type Progress ¶
type Progress struct {
Kind ProgressKind
Completed int64
Total int64
}
Progress is absolute measurement for a task.
type ProgressKind ¶
type ProgressKind string
ProgressKind classifies task measurement.
const ( Indeterminate ProgressKind = "indeterminate" Determinate ProgressKind = "determinate" BytesKind ProgressKind = "bytes" )
type ProjectionPolicy ¶
type ProjectionPolicy int
ProjectionPolicy selects how output is emitted.
const ( // ProjectionAuto chooses based on options/TTY hints. ProjectionAuto ProjectionPolicy = iota // ProjectionHuman is interactive or plain human output. ProjectionHuman // ProjectionData keeps machine data on the primary writer; UI on diagnostic. ProjectionData // ProjectionExternal disables inline rendering; snapshots only. ProjectionExternal )
type Redactor ¶
type Redactor interface {
// RedactString returns a display-safe form of s.
RedactString(s string) string
}
Redactor redacts sensitive values before journal and human rendering.
type Snapshot ¶
type Snapshot struct {
Version uint64
OutputID string
Subject string
Items []ItemSnapshot
Tasks []TaskSnapshot
Collections []TasksSnapshot
Changes []ChangesSnapshot
Plans []PlanSnapshot
Lines []string
Actions []Action
Conclusion *Conclusion
Timestamp time.Time
}
Snapshot is an immutable complete presentation state at a version.
type Task ¶
type Task struct {
// contains filtered or unexported fields
}
Task is a handle for one operation with phases or progress.
func (*Task) Capture ¶ added in v0.1.2
func (t *Task) Capture(opts ...CaptureOption) *Capture
Capture returns a process-output sink bound to this Task. The capture is associated with the task for debug labeling and failure detail.
func (*Task) Fail ¶
func (t *Task) Fail(summary string, options ...ProblemOption) *Task
Fail resolves the task as failed.
func (*Task) NextCommand ¶
NextCommand attaches a command action.
type TaskSnapshot ¶
type TaskSnapshot struct {
ID string
Name string
State EntityState
Phase string
Progress Progress
Summary string
Problems []Problem
Actions []Action
Collection string
Declaration int
}
TaskSnapshot is an immutable task view.
type Tasks ¶
type Tasks struct {
// contains filtered or unexported fields
}
Tasks is a handle for a collection of independent child tasks. State is always derived from children; no Done/Fail/Progress methods.
func (*Tasks) Snapshot ¶
func (g *Tasks) Snapshot() TasksSnapshot
Snapshot returns the collection snapshot with derived state.
type TasksSnapshot ¶
type TasksSnapshot struct {
ID string
Name string
State EntityState
Summary string
Tasks []TaskSnapshot
Declaration int
}
TasksSnapshot is an immutable collection view.
type TerminalDriver ¶
type TerminalDriver interface {
ID() string
}
TerminalDriver is the exclusive owner of terminal control sequences. Interactive implementation arrives in v0.2; the interface is defined early so options and tests compile.
type TimeSource ¶
TimeSource provides the current time for deterministic tests. Option constructor is Clock(TimeSource) to match the public API examples.
Source Files
¶
- action.go
- capability.go
- capture.go
- changes.go
- clock.go
- conclusion.go
- config.go
- debug.go
- debug_writer.go
- doc.go
- errors.go
- event.go
- field.go
- item.go
- itemspec.go
- jsonout.go
- live.go
- option.go
- output.go
- plain.go
- plan.go
- problem.go
- progressive.go
- projection.go
- redact.go
- run.go
- slog.go
- snapshot.go
- snapshots.go
- state.go
- suspend.go
- task.go
- tasks.go
- writer.go
Directories
¶
| Path | Synopsis |
|---|---|
|
agent
|
|
|
catalog
Package catalog is the task-oriented guidance catalog for agent assistance.
|
Package catalog is the task-oriented guidance catalog for agent assistance. |
|
harness
Package harness evaluates agent-assistance scenarios (§30.9, MCP-022/049).
|
Package harness evaluates agent-assistance scenarios (§30.9, MCP-022/049). |
|
preview
Package preview generates multi-profile plain previews from snapshots.
|
Package preview generates multi-profile plain previews from snapshots. |
|
review
Package review provides deterministic static review of Evident Output usage.
|
Package review provides deterministic static review of Evident Output usage. |
|
rules
Package rules is the stable review-rule registry (Appendix C namespaces).
|
Package rules is the stable review-rule registry (Appendix C namespaces). |
|
cmd
|
|
|
evident-output
command
Command evident-output provides review/preview/explain CLI parity with MCP tools.
|
Command evident-output provides review/preview/explain CLI parity with MCP tools. |
|
evident-output-mcp
command
Command evident-output-mcp is the stdio MCP server.
|
Command evident-output-mcp is the stdio MCP server. |
|
examples
|
|
|
data-command
command
Command data-command shows the data-command stream split.
|
Command data-command shows the data-command stream split. |
|
debug-history
command
Command debug-history demos v0.4 DebugHistory (default): durable scrollback above the live region using the compact bracketed grammar.
|
Command debug-history demos v0.4 DebugHistory (default): durable scrollback above the live region using the compact bracketed grammar. |
|
debug-pane
command
Command debug-pane demos v0.4 DebugPane: rolling slog-text viewport in the live region (newest first).
|
Command debug-pane demos v0.4 DebugPane: rolling slog-text viewport in the live region (newest first). |
|
doctor
command
Command doctor is an environment/health check CLI.
|
Command doctor is an environment/health check CLI. |
|
install-pipeline
command
Command install-pipeline simulates a multi-step install/bootstrap.
|
Command install-pipeline simulates a multi-step install/bootstrap. |
|
internal/demo
Package demo holds shared helpers for example CLIs.
|
Package demo holds shared helpers for example CLIs. |
|
live-progress
command
Command live-progress demos multi-task live progress (determinate bars + indeterminate spinner phases) with real wall-clock sleeps.
|
Command live-progress demos multi-task live progress (determinate bars + indeterminate spinner phases) with real wall-clock sleeps. |
|
migrate
command
Command migrate shows dry-run Plan vs applied Changes.
|
Command migrate shows dry-run Plan vs applied Changes. |
|
repo-status
command
Command repo-status is a realistic "is this repo safe to retire?" check.
|
Command repo-status is a realistic "is this repo safe to retire?" check. |
|
internal
|
|
|
sanitize
Package sanitize neutralizes untrusted text for terminal-safe display.
|
Package sanitize neutralizes untrusted text for terminal-safe display. |
|
width
Package width computes terminal cell widths for display text.
|
Package width computes terminal cell widths for display text. |
|
scripts
|
|
|
traceability-check
command
Command traceability-check verifies every expected §31 ID is present.
|
Command traceability-check verifies every expected §31 ID is present. |
|
Package terminal provides production terminal drivers for Evident Output.
|
Package terminal provides production terminal drivers for Evident Output. |
|
Package testkit provides deterministic clocks, screens, and assertions for evo tests.
|
Package testkit provides deterministic clocks, screens, and assertions for evo tests. |