pi-todo-ledger 0.0.0-stage → 0.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/CONTRACT.md ADDED
@@ -0,0 +1,213 @@
1
+ # Bookkeeping contract, version 1
2
+
3
+ Other pi extensions read and check the todo list through four things: a snapshot entry on the session branch, a change event, namespace validators, and change guards.
4
+ They depend on this document and on [`schema/todo-v1.schema.json`](schema/todo-v1.schema.json), never on this package's code, so they need no import from it and keep working when its internals change.
5
+
6
+ Every payload carries `v: 1`.
7
+ Within version 1, later releases may add optional properties; readers ignore properties they do not know.
8
+ Any other change to a name or shape below raises the version.
9
+
10
+ ## Task
11
+
12
+ A task in a snapshot or an event has these properties.
13
+ The schema's `$defs/task` is the exact definition.
14
+
15
+ | Property | Type | Meaning |
16
+ | --- | --- | --- |
17
+ | `id` | integer ≥ 1 | Unique within one list, that is one branch of one session. Ids are not stable identities: `clear` restarts them at 1, and two branches of a session (after `/tree`) can give the same id to different tasks. |
18
+ | `subject` | string | Short imperative line. |
19
+ | `status` | `pending`, `in_progress`, `completed`, `deleted` | `deleted` is a tombstone that stays in the list. |
20
+ | `description` | string, optional | Long-form detail. |
21
+ | `activeForm` | string, optional | Present-continuous label shown while in progress. |
22
+ | `blockedBy` | integer[], optional | Ids of tasks this task waits on. |
23
+ | `owner` | string, optional | Who works on the task. |
24
+ | `metadata` | object, optional | Free-form fields; each top-level key is a namespace (see [Namespaces](#3-namespaces)). |
25
+ | `points` | number from 0 to 10, optional | Effort estimate. |
26
+ | `anchor` | non-empty string, optional | The check that shows the task is done, such as a test command. |
27
+ | `evidence` | Evidence[], optional | Runs of checks, oldest first. |
28
+
29
+ An evidence entry is `{ command, sha?, result, at }`:
30
+
31
+ | Property | Type | Meaning |
32
+ | --- | --- | --- |
33
+ | `command` | non-empty string | The check that ran. |
34
+ | `sha` | string, optional | Revision the check ran on, such as a git commit SHA. |
35
+ | `result` | `pass` or `fail` | How the run ended. |
36
+ | `at` | string | ISO 8601 time of the run in UTC, as `Date.prototype.toISOString` writes it. The tool converts the caller's time to that form, fills in the call time when the caller leaves it out, and rejects a time more than five minutes after the call. |
37
+
38
+ `evidence` is append-only.
39
+ A `todo` `update` call adds its `evidence` items after the existing ones, and no call removes or rewrites an entry; only `clear`, which empties the whole list, drops them.
40
+ `points` and `anchor` are replaced by an update that sets them, and cannot be removed.
41
+
42
+ > [!IMPORTANT]
43
+ > Evidence is self-reported bookkeeping, not proof.
44
+ > When recording new evidence, the extension checks its shape and time; when importing or replaying a snapshot, it preserves the recorded time.
45
+ > It runs nothing and cannot tell whether the command ran or how it ended.
46
+ > Use it to find which checks were run and on which revision, so the next round can reuse a green run.
47
+ > A consumer that judges whether a check passed after the last change, such as a guard that blocks closing a task, keeps the session's real tool results (the command's own output on the branch) as the source of truth and treats evidence only as a pointer to them.
48
+
49
+ The agent sets these fields through the `todo` tool's `points`, `anchor`, and `evidence` parameters on `create` (also on each `tasks[]` item) and `update`.
50
+
51
+ ## 1. Snapshot entry `todo/v1`
52
+
53
+ After every call that changes the list, the extension appends a custom session entry:
54
+
55
+ ```json
56
+ { "type": "custom", "customType": "todo/v1", "data": { "v": 1, "tasks": [], "nextId": 1 } }
57
+ ```
58
+
59
+ `data` matches the schema's root: `v`, every task in id order including tombstones, and `nextId`, the id the next created task receives.
60
+ Each entry holds the whole list, so a reader needs only the newest one.
61
+
62
+ To read the current list, walk `ctx.sessionManager.getBranch()` and keep the newest entry whose `customType` is `todo/v1` and whose `data` matches the schema.
63
+ Read the branch, not every session entry: entries on abandoned branches describe another history.
64
+
65
+ Calls that change nothing write no entry: `list`, `get`, an `update` whose values equal the current ones, a call the tool rejects, and a call a namespace validator or guard refuses.
66
+
67
+ ### Import into an empty list
68
+
69
+ Since 0.2.0, `todo` accepts `{ "action": "import", "path": "handover.json" }` as an additive operation within v1.
70
+ The file contains the snapshot `data` itself, not the surrounding session entry.
71
+ Import requires an empty list (even a tombstone counts as a task), unique task ids, a task for every `blockedBy` id, and a `nextId` greater than every task id.
72
+ It preserves all task fields, including historical evidence timestamps, and commits one `todo/v1` entry with the supplied `nextId`.
73
+
74
+ ### Migration from rpiv-todo
75
+
76
+ When a branch has no `todo/v1` entry, the extension restores the list from rpiv-todo's records, newest first by kind:
77
+
78
+ 1. custom entries with `customType: "rpiv-todo-state"`, whose `data` holds `tasks` and `nextId`;
79
+ 2. otherwise, `toolResult` messages of the `todo` tool, whose `details` hold `tasks` and `nextId`.
80
+
81
+ Once a `todo/v1` entry exists it wins over both, even when an rpiv record appears later on the branch.
82
+ The extension writes no rpiv records.
83
+
84
+ ## 2. Event `todo:changed`
85
+
86
+ The extension emits on `pi.events`:
87
+
88
+ ```ts
89
+ pi.events.on("todo:changed", (data) => {
90
+ const { v, sessionId, tasks } = data as { v: 1; sessionId: string; tasks: Task[] };
91
+ });
92
+ ```
93
+
94
+ It fires:
95
+
96
+ - after every call that writes a `todo/v1` entry, with the list that entry holds;
97
+ - after the extension restores a session's list on `session_start`, `session_compact`, and `session_tree`, including when the list is empty.
98
+
99
+ `sessionId` is the session whose list changed; a child session has its own list and its own events.
100
+ `tasks` is the full list, tombstones included, as a copy: changing it does not change the list.
101
+ The payload matches `$defs/changedEvent` in the schema.
102
+
103
+ ## Reading the list
104
+
105
+ Each `todo:changed` payload and each `todo/v1` snapshot holds the session's whole current list.
106
+ A consumer replaces its copy of that session's list with it every time.
107
+ It never merges tasks by `sessionId` and `id`: after `clear` or a branch switch, the same id names a different task, and a merge would keep tasks that no longer exist or attach old fields to new tasks.
108
+
109
+ ## 3. Namespaces
110
+
111
+ An extension that owns `metadata.<ns>` registers a validator by emitting `todo:namespace`:
112
+
113
+ ```ts
114
+ const register = () =>
115
+ pi.events.emit("todo:namespace", {
116
+ v: 1,
117
+ ns: "train",
118
+ validate: (value, task, op) =>
119
+ op === "update" && task.status === "completed" && (value as { step?: string } | undefined)?.step !== "merged"
120
+ ? "complete the task only after the merge step"
121
+ : undefined,
122
+ });
123
+
124
+ register(); // the todo extension loaded first
125
+ pi.events.on("todo:ready", register); // the todo extension loads later
126
+ ```
127
+
128
+ The extension emits `todo:ready` with `{ v: 1 }` when it loads, because `pi.events` delivers an event only to listeners subscribed at that moment and extensions load in no fixed order.
129
+ Registering on both covers either order.
130
+ A later registration of the same `ns` replaces the earlier one.
131
+ The extension ignores, with a console warning, a payload whose `v` is not 1, whose `ns` is empty, or whose `validate` is not a function.
132
+
133
+ Before a call commits, the extension runs `validate(value, task, op)` for each task the call creates, changes, or deletes, once for every registered namespace that the task carries in `metadata` after the change or that the call sets or removes:
134
+
135
+ - `value` is `task.metadata[ns]` after the change, or `undefined` when the call removes it (`metadata: { ns: null }`);
136
+ - `task` is a copy of the task as it would be committed;
137
+ - `op` is `"create"`, `"update"`, or `"delete"`.
138
+
139
+ Returning a non-empty string refuses the change; returning `undefined` accepts it.
140
+ A validator that throws refuses with `validator threw: <message>`.
141
+ On the first refusal the whole call is refused: nothing commits, no entry is written, no event fires, and the tool returns an error result (`isError: true`) whose text is:
142
+
143
+ ```text
144
+ Error: metadata.<ns> refused #<id>: <reason>
145
+ ```
146
+
147
+ `clear`, `list`, and `get` run no validators.
148
+ Namespaces nobody registered pass unchecked.
149
+
150
+ ## 4. Change guards
151
+
152
+ A namespace validator judges one task's value.
153
+ An extension that must judge a call as a whole registers a guard instead: for example, one that refuses a task created without its namespace, compares a change with the list before it, or reads state outside the list.
154
+ It registers by emitting `todo:guard`, and registers again on `todo:ready` as in [Namespaces](#3-namespaces):
155
+
156
+ ```ts
157
+ const register = () =>
158
+ pi.events.emit("todo:guard", {
159
+ v: 1,
160
+ id: "train",
161
+ check: async (change) =>
162
+ change.op === "clear" && change.before.some((t) => t.status === "in_progress")
163
+ ? "steps are in progress; complete or void them first"
164
+ : undefined,
165
+ });
166
+ ```
167
+
168
+ A later registration of the same `id` replaces the earlier one; the extension ignores, with a console warning, a payload whose `v` is not 1, whose `id` is empty, or whose `check` is not a function.
169
+
170
+ The extension calls `check(change)` for every call that would change the list: `create` (a single task or a `tasks[]` batch, with or without metadata), `import`, `update`, `delete`, and `clear`.
171
+ On import, namespace validators see each relevant task as a `create`.
172
+ Guard registration accepts an optional `imports: true` field within v1.
173
+ If any registered guard has not opted in, the tool returns `Error: guard <id> refused: guard does not accept imports` without calling the guards or committing the list.
174
+ Otherwise each guard sees one `op: "create"` with `params.action: "import"`, the original `path`, an empty `before`, and the full imported list in `after`.
175
+ A guard that accepts imports must judge the tasks in `change.after`, not `change.params`: the arguments name the snapshot file but do not contain its tasks.
176
+ A valid `update` that changes nothing, such as setting `in_progress` on a task already in progress after `/reload`, reaches the guards too, flagged `noop: true`: it is how an agent restates a task's state, and a guard may track it.
177
+ `change` matches `$defs/change` in the schema and is a copy:
178
+
179
+ | Property | Meaning |
180
+ | --- | --- |
181
+ | `op` | `"create"`, `"update"`, `"delete"`, or `"clear"`. |
182
+ | `params` | The call's arguments as the tool received them. |
183
+ | `before` | The whole list before the call, tombstones included. |
184
+ | `after` | The whole list as the call would commit it. |
185
+ | `sessionId` | The session that made the call. It does not say which branch of the session is current; a guard that needs the branch keeps its own map from session id to the latest context it saw (for example from `session_start` and `session_tree`). |
186
+ | `cwd` | That session's working directory. |
187
+ | `noop` | `true` on an `update` that changes nothing, where `before` equals `after`; absent otherwise. |
188
+
189
+ Guards run after the namespace validators and before anything commits, one at a time in registration order, and the extension awaits each.
190
+ `check` returns, or resolves to, a non-empty string to refuse, or `undefined` to accept.
191
+ The first refusal refuses the whole call as in [Namespaces](#3-namespaces): nothing commits, no entry is written, no event fires, and the tool returns an error result (`isError: true`):
192
+
193
+ | Outcome | Tool result text |
194
+ | --- | --- |
195
+ | `check` returns or resolves to a reason | `Error: guard <id> refused: <reason>` |
196
+ | `check` throws or rejects | `Error: guard <id> refused: guard threw: <message>` |
197
+ | `check` takes longer than 10 seconds | `Error: guard <id> timed out after 10000 ms` |
198
+
199
+ The time limit stops waiting on an asynchronous guard at 10 seconds.
200
+ It cannot interrupt a synchronous guard, which holds the event loop until it returns; the extension measures how long it took and refuses the call with the same timeout error if it ran past the limit.
201
+
202
+ An accepted `noop` update writes no entry and emits no event; a refused one returns the refusal like any other call.
203
+ Reads (`list`, `get`) and calls the tool rejects run no guard.
204
+ One session's `todo` calls run one at a time, so a guard never sees a `before` that another call of the same session is about to change.
205
+ A guard reads the list from `change.before` and `change.after` and never calls the `todo` tool for the session it is judging: such a call is refused at once with `Error: todo called from inside guard <id>`, and changes nothing.
206
+ The same holds along a chain of guards: when session A's guard calls `todo` for session B, and B's guard calls `todo` for A, the call for A is refused the same way, naming A's guard.
207
+ Calling `todo` for a session whose guard is not running further up the chain is allowed.
208
+ A call aborted (through the tool's abort signal) while it waits for an earlier call or while its guards run commits nothing and returns `Error: call aborted; nothing changed`, a `noop` update included.
209
+
210
+ ## Coexistence
211
+
212
+ This package registers the tool name `todo`, as rpiv-todo does.
213
+ Install one of the two: with both installed, the tool names clash.
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 juicesharp
4
+ Copyright (c) 2026 wayne930242
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
package/NOTICE ADDED
@@ -0,0 +1,13 @@
1
+ pi-todo-ledger
2
+ Copyright (c) 2026 wayne930242
3
+
4
+ This package is a fork of @juicesharp/rpiv-todo 2.15.0
5
+ (https://github.com/juicesharp/rpiv-mono, packages/rpiv-todo),
6
+ Copyright (c) 2026 juicesharp, released under the MIT License.
7
+
8
+ The fork keeps rpiv-todo's `todo` tool, `/todos` command, and overlay, and adds
9
+ the bookkeeping contract described in CONTRACT.md: the `todo/v1` snapshot
10
+ entry, the `todo:changed` event, metadata namespace validators, and the
11
+ `points`, `anchor`, and `evidence` task fields. Configuration helpers formerly
12
+ imported from @juicesharp/rpiv-config 2.15.0 (MIT, same copyright holder) are
13
+ vendored in src/config.ts.
package/README.md CHANGED
@@ -1,3 +1,96 @@
1
- # Temporary Holding Version
1
+ # pi-todo-ledger
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A todo list for [pi](https://github.com/earendil-works/pi) agents that other extensions can read and check without importing it.
4
+ It is a fork of [`@juicesharp/rpiv-todo`](https://github.com/juicesharp/rpiv-mono/tree/main/packages/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.
5
+ On top of them it publishes a bookkeeping contract, [CONTRACT.md](CONTRACT.md):
6
+
7
+ - **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`](schema/todo-v1.schema.json).
8
+ - **Change event.** `todo:changed` on `pi.events` carries `{ v: 1, sessionId, tasks }` after every change and when a session's list is restored.
9
+ - **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.
10
+ - **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.
11
+ - **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?, result, at }`).
12
+
13
+ ## Replaces rpiv-todo
14
+
15
+ This package registers the tool name `todo`, as rpiv-todo does, so install one or the other.
16
+ With both installed, the two `todo` tools clash.
17
+
18
+ Switching keeps your lists.
19
+ 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.
20
+ It reads rpiv-todo's config file too, until you create one of its own (see [Configuration](#configuration)).
21
+
22
+ ```sh
23
+ pi remove npm:@juicesharp/rpiv-todo
24
+ pi install npm:pi-todo-ledger
25
+ ```
26
+
27
+ Then run `/reload` or restart pi.
28
+
29
+ ## Using it
30
+
31
+ 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`).
32
+ The new fields are optional parameters of `create` (and of each `tasks[]` item) and `update`:
33
+
34
+ ```text
35
+ { "action": "create", "subject": "Fix replay of old sessions", "points": 2, "anchor": "npm test -- replay" }
36
+ { "action": "update", "id": 1, "evidence": [{ "command": "npm test -- replay", "sha": "f503b7f", "result": "pass" }] }
37
+ ```
38
+
39
+ `points` and `anchor` are replaced by an update that sets them.
40
+ `evidence` items are appended after the existing ones; `at` defaults to the time of the call.
41
+ `get` shows all three fields.
42
+
43
+ To pick up another session's list, save the `data` from its latest `todo/v1` entry as JSON.
44
+ In the new session, call `todo` before creating any tasks:
45
+
46
+ ```json
47
+ { "action": "import", "path": "handover.json" }
48
+ ```
49
+
50
+ A relative path starts in the new session's working directory.
51
+ Import keeps the task ids, dependencies, evidence, tombstones, and next id; it never merges with or replaces an existing list.
52
+
53
+ ## Reading the list from another extension
54
+
55
+ Listen for the event, or read the newest snapshot on the branch:
56
+
57
+ ```ts
58
+ pi.events.on("todo:changed", (data) => {
59
+ const { sessionId, tasks } = data as { v: 1; sessionId: string; tasks: Array<{ id: number; status: string }> };
60
+ });
61
+
62
+ function currentTasks(ctx: ExtensionContext) {
63
+ let tasks: unknown[] = [];
64
+ for (const entry of ctx.sessionManager.getBranch()) {
65
+ if (entry.type === "custom" && entry.customType === "todo/v1") tasks = (entry.data as { tasks: unknown[] }).tasks;
66
+ }
67
+ return tasks;
68
+ }
69
+ ```
70
+
71
+ [CONTRACT.md](CONTRACT.md) describes when each fires, how validators and guards register, and what a refusal looks like.
72
+
73
+ ## Configuration
74
+
75
+ Optional. Create `~/.config/pi-todo-ledger/config.json`, or `$XDG_CONFIG_HOME/pi-todo-ledger/config.json` if you set that variable.
76
+ Without one, the extension reads `rpiv-todo/config.json` from the same directories.
77
+
78
+ ```json
79
+ {
80
+ "maxWidgetLines": 8,
81
+ "collapseKey": "alt+t"
82
+ }
83
+ ```
84
+
85
+ | Setting | What it does | Default |
86
+ | --- | --- | --- |
87
+ | `maxWidgetLines` | Content rows the panel may use, heading included. Minimum `3`. Pi's tool-output expansion mode shows all tasks. | `12` |
88
+ | `collapseKey` | Key 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"` |
89
+ | `guidance` | Replaces the built-in instructions the extension gives the model about the todo list (`promptSnippet`, `promptGuidelines`). Needs `/reload`. | built-ins |
90
+
91
+ More detail: [Configuration](docs/configuration.md), [`todo` tool reference](docs/tool-schema.md), [Panel and `/todos`](docs/overlay.md).
92
+ The panel's text is localized when [`@juicesharp/rpiv-i18n`](https://www.npmjs.com/package/@juicesharp/rpiv-i18n) is installed, and English otherwise.
93
+
94
+ ## License
95
+
96
+ MIT. Copyright juicesharp (rpiv-todo) and wayne930242 (this fork); see [LICENSE](LICENSE) and [NOTICE](NOTICE).
@@ -0,0 +1,108 @@
1
+ # Configuration reference
2
+
3
+ Every option pi-todo-ledger reads, where the file lives, and exactly what
4
+ happens when a value is wrong.
5
+
6
+ ## Where the file lives
7
+
8
+ The config file is optional. The extension reads the first of these files that
9
+ exists:
10
+
11
+ 1. `$XDG_CONFIG_HOME/pi-todo-ledger/config.json`, when `XDG_CONFIG_HOME` is set
12
+ to an absolute path. A bare `~` or a leading `~/` is expanded first; a `~user`
13
+ form is not expanded, so the variable is ignored.
14
+ 2. `~/.config/pi-todo-ledger/config.json`.
15
+ 3. `$XDG_CONFIG_HOME/rpiv-todo/config.json`, then `~/.config/rpiv-todo/config.json`:
16
+ rpiv-todo's file, so settings carry over from rpiv-todo until you create a
17
+ `pi-todo-ledger` one.
18
+
19
+ The first existing file wins even when it is malformed: you get a warning and
20
+ defaults, and the extension does **not** quietly read the next file instead.
21
+ No file means every default applies. Malformed JSON prints a
22
+ `pi-todo-ledger: invalid JSON at …` warning, and a JSON array or another
23
+ non-object value (`null`, a string, a number, a boolean) prints a
24
+ `… is not a JSON object` warning; both are treated as `{}`.
25
+
26
+ The extension never writes this file — you create and edit it yourself.
27
+
28
+ ## Example
29
+
30
+ ```json
31
+ {
32
+ "maxWidgetLines": 8,
33
+ "collapseKey": "alt+t",
34
+ "guidance": {
35
+ "promptSnippet": "Use the `todo` tool to track multi-step work before starting it.",
36
+ "promptGuidelines": [
37
+ "Create one task per discrete step.",
38
+ "Mark a task in_progress while working on it; completed when done."
39
+ ]
40
+ }
41
+ }
42
+ ```
43
+
44
+ ## `maxWidgetLines`
45
+
46
+ **Default `12`.** The content-row budget for the overlay — the heading row and,
47
+ on overflow, the `+N more` summary row both count against it. Only the trailing
48
+ blank spacer sits outside the budget, so `12` renders up to 13 terminal rows.
49
+
50
+ - Floor of `3`. A number below `3` falls back to the default.
51
+ - A non-number falls back to the default.
52
+ - No ceiling.
53
+ - Read fresh on every render, so a change takes effect on the next repaint —
54
+ no `/reload`.
55
+ - Pi's tool-output expansion mode (`ctrl+o` by default) temporarily overrides
56
+ this budget and shows every task; collapsing restores the configured budget.
57
+
58
+ ## `collapseKey`
59
+
60
+ **Default `"ctrl+shift+t"`.** The shortcut that collapses and expands the
61
+ overlay.
62
+
63
+ The value is trimmed and lowercased, then matched against Pi's keybinding
64
+ grammar: zero or more distinct modifiers joined by `+`, then a base key.
65
+
66
+ | Part | Accepted |
67
+ | --- | --- |
68
+ | Modifiers | `ctrl`, `shift`, `alt`, `super` — each at most once |
69
+ | Base key | one printable character (`a`, `7`, `]`, `/`, …) |
70
+ | Base key | a named key: `escape`, `esc`, `enter`, `return`, `tab`, `space`, `backspace`, `delete`, `insert`, `clear`, `home`, `end`, `pageup`, `pagedown`, `up`, `down`, `left`, `right`, `f1`–`f12` |
71
+
72
+ Examples: `alt+o`, `ctrl+shift+t`, `super+alt+f5`.
73
+
74
+ - A missing, empty, blank, non-string, or ungrammatical value falls back to the
75
+ default. The grammar is checked strictly on purpose: Pi takes the last `+`-part
76
+ as the base key and ignores unknown parts, so a typo like `ctr+]` would
77
+ otherwise capture every bare `]` keypress globally.
78
+ - `"off"` disables the feature — no shortcut is registered at all.
79
+ - The binding is resolved **once at extension load**. After editing this value,
80
+ run `/reload` to rebind; until you do, the old key stays active even though the
81
+ collapsed panel's hint text (which is resolved per render) already shows the
82
+ new one.
83
+
84
+ ## Guidance
85
+
86
+ `guidance.promptSnippet` (string) and `guidance.promptGuidelines` (array of
87
+ strings) replace the prompt copy the `todo` tool advertises to the model. Both
88
+ are absent by default, in which case the built-in snippet and the nine built-in
89
+ guideline bullets are used.
90
+
91
+ - `promptSnippet` must be a non-empty string; an empty string or a wrong type
92
+ falls back to the default.
93
+ - `promptGuidelines` must be a non-empty array of non-empty strings. A non-array,
94
+ or an array containing an empty string, falls back to the default — the array
95
+ is all-or-nothing, not merged item by item.
96
+ - Both are read at extension load, so `/reload` after editing them.
97
+
98
+ ## Environment variables
99
+
100
+ | Variable | Effect |
101
+ | --- | --- |
102
+ | `XDG_CONFIG_HOME` | Relocates the config directory, as described above. |
103
+ | `HOME` | Anchors `~/.config` when `XDG_CONFIG_HOME` does not apply. |
104
+
105
+ pi-todo-ledger reads no environment variables of its own. If you have
106
+ [`@juicesharp/rpiv-i18n`](https://www.npmjs.com/package/@juicesharp/rpiv-i18n)
107
+ installed, that package has its own locale configuration and its own env-var
108
+ chain — see its README.
@@ -0,0 +1,128 @@
1
+ # Overlay and `/todos` display
2
+
3
+ How pi-todo-ledger renders the task list — when the overlay appears, what each glyph means, how
4
+ overflow is trimmed, and which strings localize.
5
+
6
+ ## When the overlay exists
7
+
8
+ The widget is mounted above the Pi editor under the key `rpiv-todos`, the key rpiv-todo uses.
9
+
10
+ | Stage | Condition |
11
+ | --- | --- |
12
+ | Created | At the first session start that has a UI. A headless session never creates it. |
13
+ | Registered | Only while at least one overlay-visible task exists. The widget unregisters itself when the list empties, and re-registers when a task reappears. |
14
+ | 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. |
15
+ | Disposed | On the foreground session's shutdown. A child session shutting down leaves the overlay alone. |
16
+
17
+ Task state is partitioned by session id, so parallel sessions cannot read or
18
+ overwrite each other's lists. Nothing is written to disk: on session start,
19
+ compaction, and session-tree changes, the list is rebuilt by walking the branch
20
+ and taking the last saved snapshot, which replaces the whole list
21
+ (last-write-wins). See [tool-schema.md](./tool-schema.md#persistence) for where
22
+ snapshots are saved.
23
+
24
+ ## Anatomy of a row
25
+
26
+ ```
27
+ ● Todos (2/5)
28
+ ├─ ✓ Create DemoTodo domain entity
29
+ ├─ ✓ Create IDemoTodoRepository interface
30
+ ├─ ◐ Create DemoTodoRepository (creating the repository)
31
+ ├─ ○ Register DI bindings
32
+ └─ ○ Add integration tests
33
+ ```
34
+
35
+ - **Heading** — `● Todos (done/total)` in the accent color while any task is
36
+ `pending` or `in_progress`; `○ Todos (done/total)` dimmed once everything is
37
+ completed.
38
+ - **Glyphs** — `○` pending, `◐` in_progress, `✓` completed, `✗` deleted.
39
+ Completed and deleted subjects render dim and struck through.
40
+ - **activeForm** — appended dim in parentheses, only while the task is
41
+ `in_progress`.
42
+ - **Dependencies** — appended as `⛓ #1,#2` when the task has a `blockedBy` set.
43
+ - **`#id` prefix** — shown on every row only when at least one visible task
44
+ carries a `blockedBy`. Without a `⛓ #N` anywhere, the per-row ids have nothing
45
+ to point at, so they are omitted.
46
+ - **Prefixes** — `├─` on each row, `└─` on the last one. A blank spacer line is
47
+ always appended below the panel so it is not flush against the input box.
48
+
49
+ Rows longer than the terminal width are truncated with `…`.
50
+
51
+ ## Overflow
52
+
53
+ The content-row budget is `maxWidgetLines` (default `12`), and the heading counts
54
+ against it. When there are more tasks than fit:
55
+
56
+ 1. one row is reserved for the summary line;
57
+ 2. completed tasks are dropped first, newest first — the oldest completed rows
58
+ are the last completed rows to go;
59
+ 3. if the unfinished tasks alone still overflow, the tail of that list is
60
+ truncated;
61
+ 4. the last row becomes `+N more (X completed, Y pending)`.
62
+
63
+ Use Pi's tool-output expansion shortcut (`ctrl+o` by default) to expand the
64
+ widget and show every task. Collapsing Pi's tool output reapplies the configured
65
+ row budget. Unfinished work is therefore the last thing to disappear in the
66
+ compact view. See [configuration.md](./configuration.md#maxwidgetlines) for the
67
+ budget's floor and reload semantics.
68
+
69
+ ## Completed tasks fading out
70
+
71
+ A completed task stays on screen for the remainder of the turn in which it was
72
+ completed. At the start of the next agent turn, every completed row that has
73
+ already been displayed is hidden from later renders. Reloading or compacting the
74
+ session resets that tracking, so a fresh session shows the full list again.
75
+
76
+ ## Collapsing
77
+
78
+ Press `ctrl+shift+t` to collapse the panel to two lines — the heading plus a dim
79
+ `└─ ctrl+shift+t to expand` hint — and again to expand it. The hint always shows
80
+ the currently configured key.
81
+
82
+ Rebind or disable the shortcut with the `collapseKey` option; see
83
+ [configuration.md](./configuration.md#collapsekey). If the shortcut is set to
84
+ `"off"` while the panel is collapsed, the hint becomes a static `collapsed`
85
+ label rather than advertising an unbindable key.
86
+
87
+ ## `/todos`
88
+
89
+ `/todos` prints the whole list grouped by status, independent of the overlay's
90
+ row budget and auto-hiding:
91
+
92
+ ```
93
+ 2/7 completed · 1 in progress · 4 pending
94
+ ── Pending ──
95
+ ○ #4 Register DI bindings
96
+ ○ #5 Add integration tests ⛓ #4
97
+ ○ #6 Wire up the HTTP endpoint
98
+ ○ #7 Update the API docs
99
+ ── In Progress ──
100
+ ◐ #3 Create DemoTodoRepository (creating the repository)
101
+ ── Completed ──
102
+ ✓ #1 Create DemoTodo domain entity
103
+ ✓ #2 Create IDemoTodoRepository interface
104
+ ```
105
+
106
+ The header omits any count that is zero. Sections appear only when they have
107
+ tasks. Tombstoned tasks are never listed.
108
+
109
+ - With no tasks: `No todos yet. Ask the agent to add some!`
110
+ - In a non-interactive session: `/todos requires interactive mode`
111
+
112
+ ## Localization
113
+
114
+ The overlay heading, the `+N more` summary, the collapse hint, the `/todos`
115
+ section headers, and the status words all localize through
116
+ [`@juicesharp/rpiv-i18n`](https://www.npmjs.com/package/@juicesharp/rpiv-i18n)
117
+ when that package is installed. Bundled locales: `de`, `en`, `es`, `fr`, `pt`,
118
+ `pt-BR`, `ru`, `uk`, `zh`.
119
+
120
+ LLM-facing output — the tool response envelope, reducer error messages, and the
121
+ schema descriptions — stays English by design.
122
+
123
+ The SDK is a soft optional peer, loaded through a dynamic import at module init.
124
+ When it is absent, every call site returns its inline English literal and the
125
+ extension stays online: no warning, no crash. Install it at any time with
126
+ `pi install npm:@juicesharp/rpiv-i18n` and restart the session. To add or
127
+ override a translation, drop a `locales/<code>.json` file mirroring `en.json` —
128
+ see the `@juicesharp/rpiv-i18n` README's "Contributing translations" section.