@juicesharp/rpiv-todo 1.1.4 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -11,17 +11,17 @@
11
11
  [![npm version](https://img.shields.io/npm/v/@juicesharp/rpiv-todo.svg)](https://www.npmjs.com/package/@juicesharp/rpiv-todo)
12
12
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
13
13
 
14
- Give the model a todo list it can keep across long sessions. `rpiv-todo` adds the `todo` tool, the `/todos` slash command, and a live overlay above the editor to [Pi Agent](https://github.com/badlogic/pi-mono) — tasks survive `/reload` and conversation compaction, so the model picks up where it left off.
14
+ Give the model a todo list it can keep across long sessions. `rpiv-todo` adds the `todo` tool, the `/todos` slash command, and a live overlay above the editor to [Pi Agent](https://github.com/badlogic/pi-mono) - tasks survive `/reload` and conversation compaction, so the model picks up where it left off.
15
15
 
16
16
  ![Todo overlay widget above the Pi editor](https://raw.githubusercontent.com/juicesharp/rpiv-mono/main/packages/rpiv-todo/docs/overlay.jpg)
17
17
 
18
18
  ## Features
19
19
 
20
- - **Live overlay above the editor** — see the model's plan at all times; auto-hides when empty.
21
- - **Survives `/reload` and compaction** — tasks replay from the conversation branch, not disk.
22
- - **Status states** — pending, in_progress, completed, plus a deleted tombstone for audit.
23
- - **Dependency tracking** — `blockedBy` with cycle detection, so the model can sequence work.
24
- - **Smart truncation** — 12-line collapse threshold; completed tasks drop first, pending tasks stay visible last.
20
+ - **Live overlay above the editor** - see the model's plan at all times; completed items stay visible until the next agent response starts, then fall away; auto-hides when empty.
21
+ - **Survives `/reload` and compaction** - tasks replay from the conversation branch, not disk.
22
+ - **Status states** - pending, in_progress, completed, plus a deleted tombstone for audit.
23
+ - **Dependency tracking** - `blockedBy` with cycle detection, so the model can sequence work.
24
+ - **Smart truncation** - 12-line collapse threshold; completed tasks drop first, pending tasks stay visible last.
25
25
 
26
26
  ## Install
27
27
 
@@ -33,36 +33,95 @@ Then restart your Pi session.
33
33
 
34
34
  ### Optional: localization
35
35
 
36
- `rpiv-todo` works standalone — install only this package and you get the full English UI. Install `@juicesharp/rpiv-i18n` alongside it to flip the overlay heading, `/todos` section headers, and status words to your active locale:
36
+ `rpiv-todo` works standalone - install only this package and you get the full English UI. Install `@juicesharp/rpiv-i18n` alongside it to flip the overlay heading, `/todos` section headers, and status words to your active locale:
37
37
 
38
38
  ```bash
39
39
  pi install npm:@juicesharp/rpiv-i18n
40
40
  ```
41
41
 
42
- With the SDK present, locale resolves from `--locale <code>` → `~/.config/rpiv-i18n/locale.json` → `LANG` / `LC_ALL` → English. The `/languages` interactive picker and `pi --locale <code>` startup flag are also enabled. Without the SDK, the extension stays online and renders English at every call site — no warning, no crash. Users who installed via `pi install npm:@juicesharp/rpiv-pi` + `/rpiv-setup` get the SDK automatically.
42
+ With the SDK present, locale resolves from `--locale <code>` → `~/.config/rpiv-i18n/locale.json` → `LANG` / `LC_ALL` → English. The `/languages` interactive picker and `pi --locale <code>` startup flag are also enabled. Without the SDK, the extension stays online and renders English at every call site - no warning, no crash. Users who installed via `pi install npm:@juicesharp/rpiv-pi` + `/rpiv-setup` get the SDK automatically.
43
43
 
44
44
  ## Tool
45
45
 
46
- - **`todo`** — create / update / list / get / delete / clear tasks. 4-state
46
+ - **`todo`** - create / update / list / get / delete / clear tasks. 4-state
47
47
  machine (pending → in_progress → completed, plus deleted tombstone).
48
48
  Supports `blockedBy` dependency tracking with cycle detection. Tasks persist
49
- via branch replay — survive session compact and `/reload`.
49
+ via branch replay - survive session compact and `/reload`.
50
+
51
+ ### Schema
52
+
53
+ ```ts
54
+ todo({
55
+ action: "create" | "update" | "list" | "get" | "delete" | "clear",
56
+
57
+ // create-only
58
+ subject?: string, // required for create
59
+ blockedBy?: number[], // initial dependency ids
60
+
61
+ // create + update
62
+ description?: string,
63
+ activeForm?: string, // present-continuous label shown while in_progress
64
+ owner?: string,
65
+ metadata?: Record<string, unknown>, // pass null per key to delete that key on update
66
+
67
+ // update-only
68
+ addBlockedBy?: number[], // additive merge into blockedBy
69
+ removeBlockedBy?: number[], // additive removal from blockedBy
70
+
71
+ // update / get / delete
72
+ id?: number, // task id
73
+
74
+ // update (target) or list (filter)
75
+ status?: "pending" | "in_progress" | "completed" | "deleted",
76
+
77
+ // list-only
78
+ includeDeleted?: boolean, // default false - hides tombstones
79
+ })
80
+ ```
81
+
82
+ Valid status transitions: `pending ⇄ in_progress`, either → `completed`, any → `deleted` (terminal). `delete` keeps the task as a tombstone so historic `blockedBy` references still resolve.
83
+
84
+ Returns:
85
+
86
+ ```ts
87
+ {
88
+ content: [{ type: "text", text: string }], // human-readable summary of the op
89
+ details: { // full snapshot - replay reads this back
90
+ action: TaskAction,
91
+ params: Record<string, unknown>,
92
+ tasks: Array<{
93
+ id: number,
94
+ subject: string,
95
+ description?: string,
96
+ activeForm?: string,
97
+ status: "pending" | "in_progress" | "completed" | "deleted",
98
+ blockedBy?: number[],
99
+ owner?: string,
100
+ metadata?: Record<string, unknown>,
101
+ }>,
102
+ nextId: number,
103
+ error?: string, // present only on validation/transition failures
104
+ }
105
+ }
106
+ ```
50
107
 
51
108
  ## Commands
52
109
 
53
- - **`/todos`** — print the current todo list grouped by status.
110
+ - **`/todos`** - print the current todo list grouped by status.
54
111
 
55
112
  ## Overlay
56
113
 
57
- The aboveEditor widget auto-renders whenever any non-deleted tasks exist.
58
- 12-line collapse threshold; completed tasks drop first on overflow, pending
59
- tasks truncate last. Auto-hides when the list is empty.
114
+ The aboveEditor widget auto-renders whenever any overlay-visible tasks exist.
115
+ Completed tasks stay visible after completion until the next agent response
116
+ starts, then disappear from later overlay renders. 12-line collapse
117
+ threshold; completed tasks still drop first on overflow, pending tasks
118
+ truncate last. Auto-hides when the list is empty.
60
119
 
61
120
  ## Localization
62
121
 
63
122
  `rpiv-todo` localizes its TUI chrome (overlay heading, `/todos` section headers, status words) through `@juicesharp/rpiv-i18n` when the SDK is installed. Bundled locales: `de`, `en`, `es`, `fr`, `pt`, `pt-BR`, `ru`, `uk`. LLM-facing output (tool response envelope, reducer errors, schema descriptions) stays English by design.
64
123
 
65
- The SDK is a soft optional peer — `rpiv-todo` loads it via dynamic import at module init. If the SDK isn't installed, every render call site returns its inline English fallback and the extension stays online with English UI; no warning, no crash. See the Install section for adding the SDK after the fact. To contribute or override translations, see the `@juicesharp/rpiv-i18n` README "Contributing translations" section.
124
+ The SDK is a soft optional peer - `rpiv-todo` loads it via dynamic import at module init. If the SDK isn't installed, every render call site returns its inline English fallback and the extension stays online with English UI; no warning, no crash. See the Install section for adding the SDK after the fact. To contribute or override translations, see the `@juicesharp/rpiv-i18n` README "Contributing translations" section.
66
125
 
67
126
  ## License
68
127
 
package/index.ts CHANGED
@@ -81,17 +81,20 @@ export default function (pi: ExtensionAPI) {
81
81
  if (ctx.hasUI) {
82
82
  todoOverlay ??= new TodoOverlay();
83
83
  todoOverlay.setUICtx(ctx.ui);
84
+ todoOverlay.resetCompletedDisplayState();
84
85
  todoOverlay.update();
85
86
  }
86
87
  });
87
88
 
88
89
  pi.on("session_compact", async (_event, ctx) => {
89
90
  replaceState(replayFromBranch(ctx));
91
+ todoOverlay?.resetCompletedDisplayState();
90
92
  todoOverlay?.update();
91
93
  });
92
94
 
93
95
  pi.on("session_tree", async (_event, ctx) => {
94
96
  replaceState(replayFromBranch(ctx));
97
+ todoOverlay?.resetCompletedDisplayState();
95
98
  todoOverlay?.update();
96
99
  });
97
100
 
@@ -106,4 +109,8 @@ export default function (pi: ExtensionAPI) {
106
109
  if (event.toolName !== TOOL_NAME || event.isError) return;
107
110
  todoOverlay?.update();
108
111
  });
112
+
113
+ pi.on("agent_start", async () => {
114
+ todoOverlay?.hideCompletedTasksFromPreviousTurn();
115
+ });
109
116
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@juicesharp/rpiv-todo",
3
- "version": "1.1.4",
4
- "description": "Pi extension: gives the model a todo list with a live overlay that survives /reload and compaction",
3
+ "version": "1.2.0",
4
+ "description": "Pi extension. A todo list for the model, rendered as a live overlay that survives /reload and conversation compaction.",
5
5
  "keywords": [
6
6
  "pi-package",
7
7
  "pi-extension",
package/todo-overlay.ts CHANGED
@@ -5,21 +5,15 @@
5
5
  * registration in widgetContainerAbove, register-once + requestRender()
6
6
  * refresh, 12-line collapse-not-scroll, auto-hide when empty.
7
7
  *
8
- * Reads live state via `getTodos()` at render time — NEVER `replayFromBranch`
8
+ * Reads live state via `getState()` at render time — NEVER `replayFromBranch`
9
9
  * from `tool_execution_end` (branch is stale; `message_end` runs after).
10
10
  */
11
11
 
12
12
  import type { ExtensionUIContext, Theme } from "@mariozechner/pi-coding-agent";
13
13
  import { type TUI, truncateToWidth } from "@mariozechner/pi-tui";
14
14
  import { formatStatusLabel, t } from "./state/i18n-bridge.js";
15
- import {
16
- selectHasActive,
17
- selectOverlayLayout,
18
- selectShowTaskIds,
19
- selectTodoCounts,
20
- selectVisibleTasks,
21
- } from "./state/selectors.js";
22
- import { getTodos } from "./state/store.js";
15
+ import { selectHasActive, selectOverlayLayout, selectShowTaskIds, selectTodoCounts } from "./state/selectors.js";
16
+ import { getState } from "./state/store.js";
23
17
  import { formatOverlayTaskLine } from "./view/format.js";
24
18
 
25
19
  const WIDGET_KEY = "rpiv-todos";
@@ -33,6 +27,9 @@ export class TodoOverlay {
33
27
  private uiCtx: ExtensionUIContext | undefined;
34
28
  private widgetRegistered = false;
35
29
  private tui: TUI | undefined;
30
+ private completedTaskIdsPendingHide = new Set<number>();
31
+ private hiddenCompletedTaskIds = new Set<number>();
32
+ private lastNextId: number | undefined;
36
33
 
37
34
  setUICtx(ctx: ExtensionUIContext): void {
38
35
  // Identity-compare so repeat session_start handlers are idempotent;
@@ -46,8 +43,8 @@ export class TodoOverlay {
46
43
 
47
44
  update(): void {
48
45
  if (!this.uiCtx) return;
49
- const snapshot = { tasks: [...getTodos()], nextId: 0 };
50
- const visible = selectVisibleTasks(snapshot);
46
+ const snapshot = this.getSnapshot();
47
+ const visible = this.selectOverlayTasks(snapshot);
51
48
 
52
49
  if (visible.length === 0) {
53
50
  if (this.widgetRegistered) {
@@ -79,15 +76,57 @@ export class TodoOverlay {
79
76
  }
80
77
  }
81
78
 
79
+ resetCompletedDisplayState(): void {
80
+ this.completedTaskIdsPendingHide.clear();
81
+ this.hiddenCompletedTaskIds.clear();
82
+ this.lastNextId = undefined;
83
+ }
84
+
85
+ hideCompletedTasksFromPreviousTurn(): void {
86
+ if (this.completedTaskIdsPendingHide.size === 0) return;
87
+ for (const taskId of this.completedTaskIdsPendingHide) {
88
+ this.hiddenCompletedTaskIds.add(taskId);
89
+ }
90
+ this.completedTaskIdsPendingHide.clear();
91
+ this.tui?.requestRender();
92
+ }
93
+
94
+ private getSnapshot() {
95
+ const state = getState();
96
+ if (this.lastNextId !== undefined && state.nextId < this.lastNextId) {
97
+ this.resetCompletedDisplayState();
98
+ }
99
+ this.lastNextId = state.nextId;
100
+ const completedTaskIds = new Set(
101
+ state.tasks.filter((task) => task.status === "completed").map((task) => task.id),
102
+ );
103
+ for (const taskId of this.completedTaskIdsPendingHide) {
104
+ if (!completedTaskIds.has(taskId)) this.completedTaskIdsPendingHide.delete(taskId);
105
+ }
106
+ for (const taskId of this.hiddenCompletedTaskIds) {
107
+ if (!completedTaskIds.has(taskId)) this.hiddenCompletedTaskIds.delete(taskId);
108
+ }
109
+ return { tasks: [...state.tasks], nextId: state.nextId };
110
+ }
111
+
112
+ private selectOverlayTasks(snapshot: ReturnType<TodoOverlay["getSnapshot"]>) {
113
+ return snapshot.tasks.filter((task) => task.status !== "deleted" && !this.shouldHideCompletedTask(task));
114
+ }
115
+
116
+ private shouldHideCompletedTask(task: ReturnType<TodoOverlay["getSnapshot"]>["tasks"][number]): boolean {
117
+ return task.status === "completed" && this.hiddenCompletedTaskIds.has(task.id);
118
+ }
119
+
82
120
  private renderWidget(theme: Theme, width: number): string[] {
83
- const snapshot = { tasks: [...getTodos()], nextId: 0 };
84
- const all = selectVisibleTasks(snapshot);
85
- if (all.length === 0) return [];
121
+ const snapshot = this.getSnapshot();
122
+ const overlayTasks = this.selectOverlayTasks(snapshot);
123
+ if (overlayTasks.length === 0) return [];
86
124
 
125
+ const overlayState = { tasks: overlayTasks, nextId: snapshot.nextId };
87
126
  const truncate = (line: string): string => truncateToWidth(line, width, "…");
88
- const counts = selectTodoCounts(snapshot);
89
- const hasActive = selectHasActive(snapshot);
90
- const showIds = selectShowTaskIds(snapshot);
127
+ const counts = selectTodoCounts(overlayState);
128
+ const hasActive = selectHasActive(overlayState);
129
+ const showIds = selectShowTaskIds(overlayState);
91
130
 
92
131
  const headingColor = hasActive ? "accent" : "dim";
93
132
  const headingIcon = hasActive ? "●" : "○";
@@ -95,11 +134,23 @@ export class TodoOverlay {
95
134
  const heading = truncate(`${theme.fg(headingColor, headingIcon)} ${theme.fg(headingColor, headingText)}`);
96
135
 
97
136
  const lines: string[] = [heading];
98
- const layout = selectOverlayLayout(snapshot, MAX_WIDGET_LINES - 1);
137
+ const layout = selectOverlayLayout(overlayState, MAX_WIDGET_LINES - 1);
99
138
  for (const task of layout.visible) {
100
139
  lines.push(truncate(`${theme.fg("dim", "├─")} ${formatOverlayTaskLine(task, theme, showIds)}`));
101
140
  }
102
141
 
142
+ const newlyDisplayedCompletedTaskIds = overlayTasks
143
+ .filter(
144
+ (task) =>
145
+ task.status === "completed" &&
146
+ !this.completedTaskIdsPendingHide.has(task.id) &&
147
+ !this.hiddenCompletedTaskIds.has(task.id),
148
+ )
149
+ .map((task) => task.id);
150
+ for (const taskId of newlyDisplayedCompletedTaskIds) {
151
+ this.completedTaskIdsPendingHide.add(taskId);
152
+ }
153
+
103
154
  if (layout.hiddenCompleted === 0 && layout.truncatedTail === 0) {
104
155
  const last = lines.length - 1;
105
156
  lines[last] = lines[last].replace("├─", "└─");
@@ -122,5 +173,6 @@ export class TodoOverlay {
122
173
  this.widgetRegistered = false;
123
174
  this.tui = undefined;
124
175
  this.uiCtx = undefined;
176
+ this.resetCompletedDisplayState();
125
177
  }
126
178
  }
package/todo.ts CHANGED
@@ -67,7 +67,7 @@ export function registerTodoTool(pi: ExtensionAPI): void {
67
67
  label: TOOL_LABEL,
68
68
  description:
69
69
  "Manage a task list for tracking multi-step progress. Actions: create (new task), update (change status/fields/dependencies), list (all tasks, optionally filtered by status), get (single task details), delete (tombstone), clear (reset all). Status: pending → in_progress → completed, plus deleted tombstone. Use this to plan and track multi-step work like research, design, and implementation.",
70
- promptSnippet: "Manage a Claude-Code-style task list to track multi-step progress",
70
+ promptSnippet: "Manage a task list to track multi-step progress",
71
71
  promptGuidelines: [
72
72
  "Use `todo` for complex work with 3+ steps, when the user gives you a list of tasks, or immediately after receiving new instructions to capture requirements. Skip it for single trivial tasks and purely conversational requests.",
73
73
  "When starting any task, mark it in_progress BEFORE beginning work. Mark it completed IMMEDIATELY when done — never batch completions. Exactly one task should be in_progress at a time.",