Documentation
¶
Overview ¶
Package narrate turns tool events into the human-readable phrases the Now screen shows ("editing main.go", "running go test — 2nd attempt") and derives a session's health badge and plan progress. Pure functions, unit-tested; the UI and any future TUI render what this package says. See .ai/04-ui.md.
Index ¶
Constants ¶
const ( HealthWorking = "working" HealthIdle = "idle" HealthWaiting = "waiting-on-you" HealthLooping = "looping" HealthError = "error" HealthEnded = "ended" )
Health badges (spec: working / idle / waiting-on-you / looping? / error).
Variables ¶
This section is empty.
Functions ¶
func BackgroundPhrase ¶ added in v0.94.0
BackgroundPhrase is what a session whose turn ended says while n of its subagents still work.
func MainTurnEnded ¶ added in v0.94.0
MainTurnEnded reports whether the main thread's newest event is a top-level Stop: the parent finished its turn, whatever its subagents still do. mainLast, when given, is that event; otherwise it is found in events (oldest first).
Types ¶
type Activity ¶
type Activity struct {
Phrase string `json:"phrase"`
Tool string `json:"tool,omitempty"`
At time.Time `json:"at"`
Health string `json:"health"`
Plan *Plan `json:"plan,omitempty"`
// Repeats counts consecutive identical (tool, sample) calls ending at the latest event.
Repeats int `json:"repeats,omitempty"`
// Background is how many subagents are still working after the main
// thread ended its turn. Claude Code resumes the parent by itself when
// they finish, so nothing is wanted from the user and Health is working.
// Zero otherwise.
Background int `json:"background,omitempty"`
}
Activity is the current-activity summary for a session.
type Options ¶
type Options struct {
Now time.Time
IdleAfter time.Duration // no events for this long ⇒ idle (default 5m)
Looping bool // an unexpired loop alert exists for the session
SessionEnded bool
// LiveSubagents is how many subagents are working in the session now
// (store.LiveSubagents). With the main thread's turn ended, they make the
// session "working in background", not waiting on anyone.
LiveSubagents int
// MainLast is the main thread's newest event, for a caller that had to
// look it up because events holds none (a parent whose subagents logged
// more than the window). Nil means "find it in events".
MainLast *event.Event
}
Options tune Summarize.