← Catalog

pi-todo-ledger

A todo list for pi agents with a public bookkeeping contract: snapshot entries, change events, and namespace validators. Fork of @juicesharp/rpiv-todo

Extension

Install

Install with PiG

pig install npm:pi-todo-ledger

Install with Pi

pi install npm:pi-todo-ledger
Review before installing

Packages run code with your permissions and influence agent behavior. Catalog inclusion is not a security audit. Review the source before installing a third-party package.

Pi manifest JSON

The pi field of package.json.

{
  "extensions": [
    "./src/index.ts"
  ]
}

README

Written by the package's publisher, shown as published in version 0.4.0 (README.md). PiG does not review it.

pi-todo-ledger

A todo list for pi agents that other extensions can read and check without importing it. It is a fork of @juicesharp/rpiv-todo 2.15.0: the todo tool, the /todos command, and the live panel above the editor work as they do in rpiv-todo. On top of them it publishes a bookkeeping contract, CONTRACT.md:

  • Snapshot entry. Every change appends a todo/v1 entry with the whole list to the session branch. Its shape is fixed by schema/todo-v1.schema.json.
  • Change event. todo:changed on pi.events carries { v: 1, sessionId, tasks } after every change and when a session's list is restored.
  • Namespace validators. An extension that owns metadata.<ns> registers a validator with todo:namespace; the tool runs it before committing and returns its refusal as a tool error.
  • Change guards. An extension that must approve whole calls (including creates without metadata, batches, deletes, and clear) registers an async guard with todo:guard; the tool awaits it before committing.
  • Stable identity. Each new task gets a uid that survives replay and import. Imported tasks also name their source session when the snapshot records it.
  • Bookkeeping fields. Tasks gain points (effort, 0 to 10), anchor (the check that shows the task is done), and evidence (an append-only list of check runs, each { command, sha?, ref?, result, at }).
  • Work graph. A task can name the graph of the plan it belongs to: single-loop, fan-out/fan-in, or orchestrator-worker. list groups open tasks by it.

Replaces rpiv-todo

This package registers the tool name todo, as rpiv-todo does, so install one or the other. With both installed, the two todo tools clash.

Switching keeps your lists. On a session started under rpiv-todo, the extension restores the list from rpiv-todo's records (rpiv-todo-state entries, else todo tool results) and writes todo/v1 entries from the next change on. It reads rpiv-todo's config file too, until you create one of its own (see Configuration).

pi remove npm:@juicesharp/rpiv-todo
pi install npm:pi-todo-ledger

Then run /reload or restart pi.

Using it

Nothing changes for the agent: it calls todo with the same actions and parameters as before (create, update, list, get, delete, clear, with blockedBy, owner, activeForm, and metadata). The new fields are optional parameters of create (and of each tasks[] item) and update:

{ "action": "create", "subject": "Fix replay of old sessions", "points": 2, "anchor": "npm test -- replay" }
{ "action": "update", "id": 1, "evidence": [{ "command": "npm test -- replay", "sha": "f503b7f", "result": "pass" }] }

points and anchor are replaced by an update that sets them. evidence items are appended after the existing ones; at defaults to the time of the call. get shows all three fields.

graph names the work graph of the plan a task belongs to, one of single-loop, fan-out/fan-in, and orchestrator-worker; any other value is refused. One session often runs several plans, so each task carries its own. An update replaces it and graph: null clears it. When an open task names a graph, list shows open tasks under one <graph>: header per graph, then no graph:, then closed:. A metadata.graph holding one of the three names, as earlier sessions wrote it, is read as graph when the list is restored or imported.

{ "action": "create", "tasks": [{ "subject": "Port the parser", "graph": "fan-out/fan-in" }, { "subject": "Port the printer", "graph": "fan-out/fan-in" }] }

To pick up another session's list, for example after its pane died, call todo in the new session before creating any tasks and name the old session by its id, a unique prefix of it, or its .jsonl file:

{ "action": "import", "session": "01a2130c" }

The tool looks the id up in pi's session directories (PI_CODING_AGENT_SESSION_DIR when set, and sessions under the agent directory, PI_CODING_AGENT_DIR or ~/.pi/agent) and restores the newest todo/v1 snapshot on that session's current branch. An id that matches several sessions, or none, is refused.

A snapshot file works too: save the data from a todo/v1 entry as JSON and import it by path.

{ "action": "import", "path": "handover.json" }

A relative path starts in the new session's working directory. Import keeps the task ids, dependencies, evidence, tombstones, and next id; it never merges with or replaces an existing list.

Reading the list from another extension

Listen for the event, or read the newest snapshot on the branch:

pi.events.on("todo:changed", (data) => {
  const { sessionId, tasks } = data as { v: 1; sessionId: string; tasks: Array<{ id: number; status: string }> };
});

function currentTasks(ctx: ExtensionContext) {
  let tasks: unknown[] = [];
  for (const entry of ctx.sessionManager.getBranch()) {
    if (entry.type === "custom" && entry.customType === "todo/v1") tasks = (entry.data as { tasks: unknown[] }).tasks;
  }
  return tasks;
}

CONTRACT.md describes when each fires, how validators and guards register, and what a refusal looks like.

Configuration

Optional. Create ~/.config/pi-todo-ledger/config.json, or $XDG_CONFIG_HOME/pi-todo-ledger/config.json if you set that variable. Without one, the extension reads rpiv-todo/config.json from the same directories.

{
  "maxWidgetLines": 8,
  "collapseKey": "alt+t"
}
SettingWhat it doesDefault
maxWidgetLinesContent rows the panel may use, heading included. Minimum 3. Pi's tool-output expansion mode shows all tasks.12
collapseKeyKey that collapses and expands the panel, in pi keybinding form (alt+o, ctrl+shift+t). "off" registers no shortcut. Needs /reload to rebind."ctrl+shift+t"
guidanceReplaces the built-in instructions the extension gives the model about the todo list (promptSnippet, promptGuidelines). Needs /reload.built-ins

More detail: Configuration, todo tool reference, Panel and /todos. The panel's text is localized when @juicesharp/rpiv-i18n is installed, and English otherwise.

License

MIT. Copyright juicesharp (rpiv-todo) and wayne930242 (this fork); see LICENSE and NOTICE.