narrate

package
v0.78.2 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: Apache-2.0 Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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 Ordinal

func Ordinal(n int) string

Ordinal renders 2 → "2nd", 3 → "3rd", 11 → "11th".

func Phrase

func Phrase(tool string, payload json.RawMessage) string

Phrase renders one tool call as a present-participle phrase.

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"`
}

Activity is the current-activity summary for a session.

func Summarize

func Summarize(events []event.Event, opt Options) Activity

Summarize derives the activity for a session from its most recent events (oldest first). It looks at the last tool.pre for the phrase, the last event kind for the health badge, and the last TodoWrite for plan progress.

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
}

Options tune Summarize.

type Plan

type Plan struct {
	Done  int    `json:"done"`
	Total int    `json:"total"`
	Next  string `json:"next,omitempty"` // first in_progress or pending item
}

Plan is TodoWrite-derived progress.

Jump to

Keyboard shortcuts

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