@capdiem/pi-todo

中文文档
0.3.2发布于 2026/09/01MITES Module零依赖构建来源已验证近 30 天下载 5666

A lightweight atomic todo tool for the Pi coding agent: one-call snapshot plans, three states, stale-write guard, plus a TUI widget and a pi-agent-desktop sidebar panel

原始使用文档
文档目录8 节
  1. Features
  2. Install
  3. Tool schema
  4. Semantics
  5. Rendering
  6. Desktop integration
  7. Persistence
  8. License

pi-todo

A lightweight, minimal, atomic todo tool for the Pi coding agent. The model writes the complete task plan in one call instead of issuing one create call per task.

It is deliberately small — only the essential plan-maintenance core, with no dependencies or settings menus, no collapse/expand, and exactly one lightweight reminder (a run-end reconcile nudge, see Features). The live plan renders as a read-only widget above Pi's input box, and when hosted by pi-agent-desktop it also appears in the desktop's left-nav sidebar todo panel with zero extra configuration (desktop-side support is upcoming — see Desktop integration).

Features

  • One-call creation of a complete plan (snapshot semantics)
  • Three statuses: pending, in_progress, completed
  • Stable task keys; omission-based deletion (no cancelled or archived state)
  • baseVersion stale-write guard against concurrent/out-of-order updates
  • At most one in_progress task at a time
  • Atomic validation — a failed write never mutates state
  • Completed todos are never auto-removed; the model prunes them (by omitting their keys) once their whole work content is complete
  • State persists in tool-result details and survives /reload and /tree
  • A read-only widget above Pi's input box using markdown-style glyphs ([ ] pending, [-] in_progress, [x] completed); no collapse/expand
  • Run-end reconcile reminder (invisible): when a turn settles (agent_settled) while tasks are still in_progress, the extension records a reminder and injects it into the system prompt of the next turn via before_agent_start. The model is reminded to mark them completed if the work is actually done — with no visible chat message, no extra agent run, and no toggle needed. It fires at most once per turn, is skipped while the plan has no in_progress tasks, and cannot loop (there is no steer message to loop on).
  • When hosted by pi-agent-desktop, the live plan also renders in the desktop's left-nav sidebar todo panel (the desktop-owned pi-agent-desktop:todo widget extension point) — no extra configuration needed

Install

This extension registers the todo tool. Remove any other extension that owns the same todo tool name before installing it, e.g.:

pi remove <the-other-todo-extension>
pi install npm:@capdiem/pi-todo

To try it without installing:

pi -e ./extensions/pi-todo/index.ts

Tool schema

The todo tool accepts the complete authoritative list of tasks to retain. Existing tasks may omit unchanged fields; a new key requires subject and status. Any current key omitted from tasks is permanently deleted:

todo({
  baseVersion?: number,
  tasks: Array<{
    key: string,
    subject?: string,
    status?: "pending" | "in_progress" | "completed",
  }>,
})

Example:

{
  "baseVersion": 0,
  "tasks": [
    { "key": "inspect", "subject": "Inspect the existing implementation", "status": "in_progress" },
    { "key": "implement", "subject": "Implement the optimized protocol", "status": "pending" },
    { "key": "verify", "subject": "Verify the implementation", "status": "pending" }
  ]
}

To hand work off, include every current key but only send changed fields:

{
  "baseVersion": 1,
  "tasks": [
    { "key": "inspect", "status": "completed" },
    { "key": "implement", "status": "in_progress" },
    { "key": "verify" }
  ]
}

Subjects are inherited from the previous snapshot; both status changes commit atomically.

To cancel or otherwise delete work, omit its key from the next complete plan. Deletion is permanent state removal — there is no cancelled status or archived record.

Semantics

  • key is the task identity while that task remains in the plan.
  • Existing keys inherit omitted fields from their previous state.
  • New keys require subject and status.
  • Every key present in tasks remains in the plan; omitted current keys are permanently deleted.
  • Completed tasks remain visible (struck through) until the model prunes them by omitting their keys once their whole work content is complete.
  • tasks: [] clears the plan.
  • baseVersion, when provided, rejects stale writes.
  • At most one task may be in_progress at a time.
  • Validation is all-or-nothing; failed writes do not mutate state.
  • A write that leaves the plan unchanged does not bump the version.

Each successful result includes the current version and complete plan.

Rendering

The task list is rendered in a read-only widget above Pi's input box. It always shows the full list (no collapse/expand): a progress header plus every task with a markdown-style status glyph. in_progress labels are bold, completed labels are struck through. The widget appears only while a plan exists.

Desktop integration

When hosted by pi-agent-desktop (in rpc mode), the live plan renders in the desktop's left-nav sidebar todo panel — a persistent checkbox list next to the chat that stays in view while you work.

The plan is pushed over the desktop-owned todo widget extension point (defined by pi-agent-desktop; see its lib/todo-state.ts and docs/todo-widget.md): a setWidget request with the desktop-reserved key "pi-agent-desktop:todo", one JSON TodoTask per line. The desktop routes it straight into its sidebar todo panel. It is fire-and-forget (not persisted); when the desktop opens a session, this extension's session_start restore re-emits the current plan, so the panel shows the latest snapshot. The TUI keeps its own component widget (see Rendering) and is unchanged.

Status: the desktop-side panel is upcoming. The todo-panel support currently lives on a feature branch in pi-agent-desktop and has not been merged into a release yet. @capdiem/pi-todo already conforms to the pi-agent-desktop:todo widget protocol, so once the panel ships you get the sidebar rendering with zero extra configuration.

Persistence

Writes are stored in tool-result details. On session_start and /tree navigation, the extension restores the latest valid state entry from the active branch. (For backwards compatibility it also recognizes legacy hidden custom-message snapshots emitted by older versions that auto-removed completed tasks.)

This minimal extension does not handle compaction checkpoints: if compaction drops every todo tool result from the branch, the plan resets to empty (the model's own context still contains the plan text). Add compaction handling from a full-featured todo extension if that matters to your workflow.

License

MIT

版本与发布记录

@capdiem/pi-todo 共发布 9 个版本,首次发布于 2026/08/27;过去 12 个月发布了 9 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.3.2latest2026/09/012 个月前
0.3.12026/09/012 个月前
0.3.02026/09/012 个月前
0.2.12026/08/282 个月前
0.2.02026/08/282 个月前
0.1.32026/08/272 个月前

关于 @capdiem/pi-todo 的常见问题

@capdiem/pi-todo 是什么?

A lightweight atomic todo tool for the Pi coding agent: one-call snapshot plans, three states, stale-write guard, plus a TUI widget and a pi-agent-desktop sidebar panel

如何安装 @capdiem/pi-todo?

在项目目录运行 npm install @capdiem/pi-todo,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@earendil-works/pi-ai(*)、@earendil-works/pi-coding-agent(*)、@earendil-works/pi-tui(*)、typebox(*)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@capdiem/pi-todo 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/capdiem__pi-todo 是否存在。

@capdiem/pi-todo 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@capdiem/pi-todo 可以商用吗?

@capdiem/pi-todo 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@capdiem/pi-todo 的下载量有多少?

根据 npm 官方下载统计,@capdiem/pi-todo 在 2026/10/09 – 2026/11/07 这 30 天内被下载 5,666 次,日均约 189 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@capdiem/pi-todo 还在维护吗?

最新版本 0.3.2 发布于 2026/09/01(2 个月前);至今共发布 9 个版本,其中过去 12 个月发布了 9 个;首次发布于 2026/08/27。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。