@juicesharp/rpiv-todo 2.14.2 → 2.16.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 +3 -3
- package/config.ts +4 -3
- package/docs/configuration.md +3 -1
- package/docs/overlay.md +13 -1
- package/index.ts +10 -1
- package/package.json +2 -2
- package/state/replay.ts +25 -4
- package/todo-overlay.ts +32 -3
- package/tool/types.ts +17 -3
package/README.md
CHANGED
|
@@ -40,8 +40,8 @@ input box, updating as work moves:
|
|
|
40
40
|

|
|
41
41
|
|
|
42
42
|
Press `ctrl+shift+t` to collapse the panel to its heading plus a one-line hint,
|
|
43
|
-
and again to expand it.
|
|
44
|
-
by status.
|
|
43
|
+
and again to expand it. Clicking the heading row toggles it too. Run `/todos` at
|
|
44
|
+
any time to print the full list grouped by status.
|
|
45
45
|
|
|
46
46
|
## What you get
|
|
47
47
|
|
|
@@ -81,7 +81,7 @@ Optional. Create `~/.config/rpiv-todo/config.json` (or
|
|
|
81
81
|
|
|
82
82
|
| Setting | What it does | Default |
|
|
83
83
|
| --- | --- | --- |
|
|
84
|
-
| `maxWidgetLines` | Content rows the overlay may use, heading included. Minimum `3`. Applies on the next repaint. Pi's tool-output expansion mode shows all tasks. | `12` |
|
|
84
|
+
| `maxWidgetLines` | Content rows the overlay may use, heading included. Minimum `3`. `0` turns the overlay off. Applies on the next repaint. Pi's tool-output expansion mode shows all tasks. | `12` |
|
|
85
85
|
| `collapseKey` | Key that collapses and expands the panel, in Pi keybinding form (`alt+o`, `ctrl+shift+t`). Set `"off"` to register no shortcut. Needs `/reload` to rebind. | `"ctrl+shift+t"` |
|
|
86
86
|
| `guidance` | Replaces the built-in instructions the extension gives the model about when and how to use the todo list. Needs `/reload`. | _(built-ins)_ |
|
|
87
87
|
|
package/config.ts
CHANGED
|
@@ -31,12 +31,13 @@ export function loadConfig(): TodoConfig {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
/** Content-row budget for the overlay, read fresh on every call (per-render —
|
|
34
|
-
* no `/reload`). Mirrors warp's getHeartbeatMs
|
|
35
|
-
*
|
|
36
|
-
*
|
|
34
|
+
* no `/reload`). Mirrors warp's getHeartbeatMs: `0` turns the overlay off; a
|
|
35
|
+
* non-number or any other value below the floor of 3 falls back to the default;
|
|
36
|
+
* no ceiling. */
|
|
37
37
|
export function getMaxWidgetLines(): number {
|
|
38
38
|
const config = loadConfig();
|
|
39
39
|
const lines = config.maxWidgetLines;
|
|
40
|
+
if (lines === 0) return 0; // off
|
|
40
41
|
if (typeof lines !== "number" || lines < 3) return DEFAULT_MAX_WIDGET_LINES;
|
|
41
42
|
return lines;
|
|
42
43
|
}
|
package/docs/configuration.md
CHANGED
|
@@ -49,7 +49,9 @@ extension only reads it.
|
|
|
49
49
|
on overflow, the `+N more` summary row both count against it. Only the trailing
|
|
50
50
|
blank spacer sits outside the budget, so `12` renders up to 13 terminal rows.
|
|
51
51
|
|
|
52
|
-
-
|
|
52
|
+
- `0` turns the overlay off. The `todo` tool and `/todos` keep working, and
|
|
53
|
+
Pi's tool-output expansion mode does not bring the panel back.
|
|
54
|
+
- Floor of `3`. Any other number below `3` falls back to the default.
|
|
53
55
|
- A non-number falls back to the default.
|
|
54
56
|
- No ceiling.
|
|
55
57
|
- Read fresh on every render, so a change takes effect on the next repaint —
|
package/docs/overlay.md
CHANGED
|
@@ -16,6 +16,10 @@ The widget is mounted above the Pi editor under the key `rpiv-todos`.
|
|
|
16
16
|
| Bound | Only the foreground session's overlay is refreshed. A detached or child session has its own task state and never rebinds or repaints the foreground panel. |
|
|
17
17
|
| Disposed | On the foreground session's shutdown. A child session shutting down leaves the overlay alone. |
|
|
18
18
|
|
|
19
|
+
Set [`maxWidgetLines`](./configuration.md#maxwidgetlines) to `0` to turn the
|
|
20
|
+
overlay off. It then draws nothing, while the `todo` tool and `/todos` keep
|
|
21
|
+
working.
|
|
22
|
+
|
|
19
23
|
Task state is partitioned by session id, so parallel sessions cannot read or
|
|
20
24
|
overwrite each other's lists. Nothing is written to disk: on session start,
|
|
21
25
|
compaction, and session-tree changes, the list is rebuilt by walking the branch
|
|
@@ -72,7 +76,9 @@ budget's floor and reload semantics.
|
|
|
72
76
|
|
|
73
77
|
A completed task stays on screen for the remainder of the turn in which it was
|
|
74
78
|
completed. At the start of the next agent turn, every completed row that has
|
|
75
|
-
already been displayed is hidden from later renders.
|
|
79
|
+
already been displayed is hidden from later renders. A child session starting
|
|
80
|
+
its own run (a subagent, for example) does not hide them, and once the last
|
|
81
|
+
row is hidden the panel is removed. Reloading or compacting the
|
|
76
82
|
session resets that tracking, so a fresh session shows the full list again.
|
|
77
83
|
|
|
78
84
|
## Collapsing
|
|
@@ -86,6 +92,12 @@ Rebind or disable the shortcut with the `collapseKey` option; see
|
|
|
86
92
|
`"off"` while the panel is collapsed, the hint becomes a static `collapsed`
|
|
87
93
|
label rather than advertising an unbindable key.
|
|
88
94
|
|
|
95
|
+
Clicking the heading row also toggles the panel, which covers terminals that
|
|
96
|
+
swallow the shortcut. Only an unmodified left click on that row counts: task
|
|
97
|
+
rows, modified clicks, drags and wheel events keep their existing meaning, and
|
|
98
|
+
the click still works when `collapseKey` is `"off"`. Mouse dispatch requires
|
|
99
|
+
Pi's fullscreen mode; a host without it simply never delivers the click.
|
|
100
|
+
|
|
89
101
|
## `/todos`
|
|
90
102
|
|
|
91
103
|
`/todos` prints the whole list grouped by status, independent of the overlay's
|
package/index.ts
CHANGED
|
@@ -284,7 +284,16 @@ export default function (pi: ExtensionAPI, importOverlay: TodoOverlayImporter =
|
|
|
284
284
|
const prewarmTimer = setTimeout(() => void loadTodoOverlay().catch(() => undefined), PREWARM_DELAY_MS);
|
|
285
285
|
prewarmTimer.unref?.();
|
|
286
286
|
|
|
287
|
-
pi.on("agent_start", async () => {
|
|
287
|
+
pi.on("agent_start", async (_event, ctx) => {
|
|
288
|
+
let id: string;
|
|
289
|
+
try {
|
|
290
|
+
id = sid(ctx);
|
|
291
|
+
} catch (e) {
|
|
292
|
+
if (!isStaleCtxError(e)) throw e;
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
// A child session's run must not hide rows the foreground has not moved past.
|
|
296
|
+
if (id !== getActiveRenderSession()) return;
|
|
288
297
|
todoOverlay?.hideCompletedTasksFromPreviousTurn();
|
|
289
298
|
});
|
|
290
299
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juicesharp/rpiv-todo",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.16.0",
|
|
4
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",
|
|
@@ -71,6 +71,6 @@
|
|
|
71
71
|
}
|
|
72
72
|
},
|
|
73
73
|
"dependencies": {
|
|
74
|
-
"@juicesharp/rpiv-config": "^2.
|
|
74
|
+
"@juicesharp/rpiv-config": "^2.16.0"
|
|
75
75
|
}
|
|
76
76
|
}
|
package/state/replay.ts
CHANGED
|
@@ -1,15 +1,36 @@
|
|
|
1
|
-
import type { TaskDetails } from "../tool/types.ts";
|
|
1
|
+
import type { Task, TaskDetails, TaskStatus } from "../tool/types.ts";
|
|
2
2
|
import { EMPTY_STATE, type TaskState } from "./state.ts";
|
|
3
3
|
|
|
4
|
+
const TASK_STATUSES: ReadonlySet<unknown> = new Set<TaskStatus>(["pending", "in_progress", "completed", "deleted"]);
|
|
5
|
+
|
|
6
|
+
const optional = (value: unknown, valid: (v: unknown) => boolean): boolean => value === undefined || valid(value);
|
|
7
|
+
const isString = (v: unknown): boolean => typeof v === "string";
|
|
8
|
+
|
|
9
|
+
function isTask(value: unknown): value is Task {
|
|
10
|
+
if (!value || typeof value !== "object") return false;
|
|
11
|
+
const t = value as Record<string, unknown>;
|
|
12
|
+
return (
|
|
13
|
+
Number.isSafeInteger(t.id) &&
|
|
14
|
+
typeof t.subject === "string" &&
|
|
15
|
+
TASK_STATUSES.has(t.status) &&
|
|
16
|
+
optional(t.description, isString) &&
|
|
17
|
+
optional(t.activeForm, isString) &&
|
|
18
|
+
optional(t.owner, isString) &&
|
|
19
|
+
optional(t.blockedBy, (v) => Array.isArray(v) && v.every((id) => Number.isSafeInteger(id))) &&
|
|
20
|
+
optional(t.metadata, (v) => typeof v === "object" && v !== null)
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
4
24
|
/**
|
|
5
25
|
* Discriminator for `details` envelopes that match the persisted `TaskDetails`
|
|
6
|
-
* shape. Defensive —
|
|
7
|
-
*
|
|
26
|
+
* shape, down to every task. Defensive — a snapshot from an older or corrupt
|
|
27
|
+
* session (e.g. a `tasks[]` another extension truncated with a marker string)
|
|
28
|
+
* is skipped whole, so replay keeps the last valid one.
|
|
8
29
|
*/
|
|
9
30
|
export function isTaskDetails(value: unknown): value is TaskDetails {
|
|
10
31
|
if (!value || typeof value !== "object") return false;
|
|
11
32
|
const v = value as Record<string, unknown>;
|
|
12
|
-
return Array.isArray(v.tasks) &&
|
|
33
|
+
return Array.isArray(v.tasks) && v.tasks.every(isTask) && Number.isSafeInteger(v.nextId);
|
|
13
34
|
}
|
|
14
35
|
|
|
15
36
|
/** Fresh `TaskState` from a persisted snapshot — copies each task so replay never aliases branch data. */
|
package/todo-overlay.ts
CHANGED
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
* registration in widgetContainerAbove, register-once + requestRender()
|
|
6
6
|
* refresh, configurable collapse-not-scroll (default 12 content rows via
|
|
7
7
|
* getMaxWidgetLines(); plus a trailing spacer row so the widget renders up
|
|
8
|
-
* to 13 lines), Pi tool-output expansion awareness, auto-hide when empty
|
|
8
|
+
* to 13 lines), Pi tool-output expansion awareness, auto-hide when empty, off when
|
|
9
|
+
* getMaxWidgetLines() is 0.
|
|
9
10
|
*
|
|
10
11
|
* Reads live state via `getRenderState()` (the ctx-less foreground slot) at render
|
|
11
12
|
* time — NEVER `replayFromBranch` from `tool_execution_end` (branch is stale;
|
|
@@ -13,6 +14,7 @@
|
|
|
13
14
|
*/
|
|
14
15
|
|
|
15
16
|
import type { ExtensionUIContext, Theme } from "@earendil-works/pi-coding-agent";
|
|
17
|
+
import type { TuiMouseEvent, TuiMouseEventResult } from "@earendil-works/pi-tui";
|
|
16
18
|
import { type TUI, truncateToWidth } from "@earendil-works/pi-tui";
|
|
17
19
|
import { COLLAPSE_KEY_OFF, getMaxWidgetLines, resolveCollapseKey } from "./config.ts";
|
|
18
20
|
import { formatStatusLabel, t } from "./state/i18n-bridge.ts";
|
|
@@ -22,6 +24,9 @@ import { formatOverlayTaskLine } from "./view/format.ts";
|
|
|
22
24
|
|
|
23
25
|
const WIDGET_KEY = "rpiv-todos";
|
|
24
26
|
|
|
27
|
+
/** Local row index of the heading inside the rendered widget. */
|
|
28
|
+
const HEADING_ROW = 0;
|
|
29
|
+
|
|
25
30
|
// English fallbacks for localized overlay chrome strings.
|
|
26
31
|
const OVERLAY_HEADING = "Todos";
|
|
27
32
|
const OVERLAY_MORE = "more";
|
|
@@ -72,6 +77,7 @@ export class TodoOverlay {
|
|
|
72
77
|
// No rendered strings are cached. Pi invalidates on theme changes;
|
|
73
78
|
// the next render reads uiCtx.theme.
|
|
74
79
|
},
|
|
80
|
+
handleMouse: (event: TuiMouseEvent) => this.handleHeadingClick(event),
|
|
75
81
|
};
|
|
76
82
|
},
|
|
77
83
|
{ placement: "aboveEditor" },
|
|
@@ -82,6 +88,22 @@ export class TodoOverlay {
|
|
|
82
88
|
}
|
|
83
89
|
}
|
|
84
90
|
|
|
91
|
+
/** Toggle the panel from a click on the heading row.
|
|
92
|
+
*
|
|
93
|
+
* Only an unmodified left click counts: task rows keep their own meaning (and
|
|
94
|
+
* there is no per-task action yet), while modified clicks, drags, wheels and
|
|
95
|
+
* press/release events stay available to the transcript's selection, scrolling
|
|
96
|
+
* and app-level bindings. The heading renders in both states, so the same row
|
|
97
|
+
* collapses and expands. Hosts without mouse dispatch never call this and keep
|
|
98
|
+
* the keyboard-only behavior. */
|
|
99
|
+
private handleHeadingClick(event: TuiMouseEvent): TuiMouseEventResult | undefined {
|
|
100
|
+
if (event.type !== "click" || event.button !== "left") return undefined;
|
|
101
|
+
if (event.shift || event.alt || event.ctrl) return undefined;
|
|
102
|
+
if (event.y !== HEADING_ROW) return undefined;
|
|
103
|
+
this.toggleCollapse();
|
|
104
|
+
return { handled: true };
|
|
105
|
+
}
|
|
106
|
+
|
|
85
107
|
resetCompletedDisplayState(): void {
|
|
86
108
|
this.completedTaskIdsPendingHide.clear();
|
|
87
109
|
this.hiddenCompletedTaskIds.clear();
|
|
@@ -94,7 +116,8 @@ export class TodoOverlay {
|
|
|
94
116
|
this.hiddenCompletedTaskIds.add(taskId);
|
|
95
117
|
}
|
|
96
118
|
this.completedTaskIdsPendingHide.clear();
|
|
97
|
-
|
|
119
|
+
// update(), not a bare repaint: hiding the last row must unregister the widget.
|
|
120
|
+
this.update();
|
|
98
121
|
}
|
|
99
122
|
|
|
100
123
|
toggleCollapse(): void {
|
|
@@ -136,6 +159,12 @@ export class TodoOverlay {
|
|
|
136
159
|
}
|
|
137
160
|
|
|
138
161
|
private renderWidget(theme: Theme, width: number): string[] {
|
|
162
|
+
// maxWidgetLines 0 turns the overlay off. Like the collapsed view below, return
|
|
163
|
+
// before the completed-display tracking: a task that is never shown must not be
|
|
164
|
+
// queued for hide.
|
|
165
|
+
const maxWidgetLines = getMaxWidgetLines();
|
|
166
|
+
if (maxWidgetLines === 0) return [];
|
|
167
|
+
|
|
139
168
|
const snapshot = this.getSnapshot();
|
|
140
169
|
const overlayTasks = this.selectOverlayTasks(snapshot);
|
|
141
170
|
if (overlayTasks.length === 0) return [];
|
|
@@ -175,7 +204,7 @@ export class TodoOverlay {
|
|
|
175
204
|
// Pi's global tool-output expansion mode is read on every render so its
|
|
176
205
|
// expand/collapse shortcut also expands this live widget. Optional chaining
|
|
177
206
|
// preserves compatibility with hosts predating getToolsExpanded().
|
|
178
|
-
const bodyBudget = this.uiCtx?.getToolsExpanded?.() === true ? overlayTasks.length :
|
|
207
|
+
const bodyBudget = this.uiCtx?.getToolsExpanded?.() === true ? overlayTasks.length : maxWidgetLines - 1;
|
|
179
208
|
const layout = selectOverlayLayout(overlayState, bodyBudget);
|
|
180
209
|
for (const task of layout.visible) {
|
|
181
210
|
lines.push(truncate(`${theme.fg("dim", "├─")} ${formatOverlayTaskLine(task, theme, showIds)}`));
|
package/tool/types.ts
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { type Static, type TUnsafe, Type } from "typebox";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A `{ type: "string", enum }` schema, the form Google's API and other providers accept where
|
|
5
|
+
* anyOf/const unions fail. Local rather than pi-ai's `StringEnum`, whose return type changed in
|
|
6
|
+
* Pi 1.5 to one typebox's `Static` reads as `unknown`; the JSON sent is the same on any Pi.
|
|
7
|
+
*/
|
|
8
|
+
function StringEnum<const T extends readonly string[]>(
|
|
9
|
+
values: T,
|
|
10
|
+
options?: { description?: string },
|
|
11
|
+
): TUnsafe<T[number]> {
|
|
12
|
+
return Type.Unsafe<T[number]>({ type: "string", enum: values, ...options });
|
|
13
|
+
}
|
|
3
14
|
|
|
4
15
|
// ---------------------------------------------------------------------------
|
|
5
16
|
// Tool / command identity — verbatim string boundaries.
|
|
@@ -121,7 +132,10 @@ const CreateTaskInputSchema = Type.Object({
|
|
|
121
132
|
});
|
|
122
133
|
|
|
123
134
|
export const TodoParamsSchema = Type.Object({
|
|
124
|
-
action: StringEnum(["create", "update", "list", "get", "delete", "clear"] as const
|
|
135
|
+
action: StringEnum(["create", "update", "list", "get", "delete", "clear"] as const, {
|
|
136
|
+
description:
|
|
137
|
+
"Required in every call — the operation to perform: create (one task by subject, or several with tasks[]), update (change an existing task by id), list, get (one task by id), delete (tombstone by id), clear (reset all).",
|
|
138
|
+
}),
|
|
125
139
|
subject: Type.Optional(
|
|
126
140
|
Type.String({
|
|
127
141
|
description: "Task subject line (required for create unless tasks[] is set)",
|