todos

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package todos is the agent's operational work tracker — a lightweight checklist the agent maintains itself so it doesn't lose its place when a request has several moving parts. It is NOT the deliberate, research-heavy `/plan` mode (that decides WHAT to do and asks the human to confirm); todos are just for NOT LOSING TRACK during execution.

The authoritative list lives in the Session's memory (the agent's scratchpad for this run). Each change is also snapshotted into the event log as a `todos_updated` event — purely for provenance/replay, never as the source of truth. Todos deliberately stay OUT of the human-authored objectives table: agent-inferred work must not masquerade as the user's durable goals. A todo only becomes durable project intent if the user explicitly promotes it to an objective.

Index

Constants

View Source
const (
	StatusPending = "pending"
	StatusActive  = "active"
	StatusDone    = "done"
	StatusBlocked = "blocked"
	StatusSkipped = "skipped" // intentionally not doing this item
)

Status values for a todo item. They map onto the checklist legend: ✓ done · ▸ active · ○ pending · ! blocked.

View Source
const EventKind = "todos_updated"

EventKind is the canonical event kind for a todo-list snapshot. (Mirrored as events.KindTodosUpdated; kept here too so this package needn't import events.)

Variables

This section is empty.

Functions

func ActiveIndex

func ActiveIndex(l List) int

ActiveIndex returns the index of the active item, or -1 if none.

func Marker

func Marker(status string) string

Marker returns the checklist glyph for a status.

Types

type Item

type Item struct {
	Title  string `json:"title"`
	Detail string `json:"detail,omitempty"`
	Status string `json:"status"`
	Owner  string `json:"owner,omitempty"`
}

Item is one unit of work the agent is tracking. Detail is per-item context (what the step actually entails) so the agent can pick the work back up later. Owner is who runs it — "main" today; "reader"/"background" once parallel fan-out (a later slice) can dispatch items to sub-agents.

type List

type List []Item

List is an ordered set of todo items. Slice 1 executes them serially: at most one item is StatusActive at a time. (Parallel fan-out is a later slice, built on the explore/jobs substrate — not here.)

func Advance

func Advance(l List) List

Advance marks the current active item done and promotes the next pending item to active. Used when the agent finishes the step it was on.

func Append

func Append(l List, extra List) List

Append pushes newly-discovered work onto the end of an existing list (the "push" path) without rewriting it — important for long-running sessions that accumulate many items. It keeps existing items untouched and promotes an active item if none remains.

func Current

func Current(ctx context.Context, st store.Store) (List, error)

Current reads the most recent todo-list snapshot from the event log. An empty list (no error) means no todos have been recorded yet.

func FromTitles

func FromTitles(titles []string) List

FromTitles builds a fresh list from plain titles (the `create` action), with the first item active and the rest pending.

func MarkBlockedAt

func MarkBlockedAt(l List, idx int) List

MarkBlockedAt marks the item at idx (1-based) blocked; idx<=0 targets active.

func MarkDoneAt

func MarkDoneAt(l List, idx int) List

MarkDoneAt marks the item at idx (1-based) done; idx<=0 targets the active item. It then ensures something is active if work remains.

func MarkSkippedAt

func MarkSkippedAt(l List, idx int) List

MarkSkippedAt marks the item at idx (1-based) skipped; idx<=0 targets active. Skipping is "intentionally not doing this", distinct from done.

func Normalize

func Normalize(l List) List

Normalize cleans a model-supplied list: it drops empty titles, defaults blank or unknown statuses to pending, collapses multiple actives down to the first, and — if nothing is active yet but work remains — promotes the first pending item to active so there is always a clear "current" step.

func StartAt

func StartAt(l List, idx int) List

StartAt makes the item at idx (1-based) the active one, demoting any current active item back to pending (a deliberate focus switch). idx<=0 starts the next pending item. Serial execution keeps exactly one item active.

func (List) AllSettled

func (l List) AllSettled() bool

AllSettled reports whether every item has reached a terminal state (done or deliberately skipped) — i.e. there's no work left pending/active/blocked.

func (List) Payload

func (l List) Payload() map[string]any

Payload returns the event payload for persisting l (used by the runtime's session-tagged emitter so todo changes are attributed like any other event).

func (List) Render

func (l List) Render(indent string) string

Render returns the multi-line checklist, each line prefixed with indent, e.g.

✓ 1. inspect current loader
▸ 2. add upsert path
○ 3. update tests

func (List) RenderWindow

func (l List) RenderWindow(indent string, max int) string

RenderWindow renders at most max item lines, centered on the active item, so a long list (a session can accumulate dozens) stays compact in the live TUI. Hidden items above/below are summarized as "…N above/below". The full list is always available via `todo show` / `memcode todos`.

func (List) Summary

func (l List) Summary() string

Summary is a plain-language progress line: "2/6 done" (skipped items count as resolved), with "· N blocked" appended when anything is stuck.

Jump to

Keyboard shortcuts

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