pi-todo-ledger 0.6.0 → 0.7.1
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 +5 -1
- package/README.md +9 -5
- package/docs/configuration.md +27 -8
- package/docs/overlay.md +98 -16
- package/package.json +1 -1
- package/src/config.ts +32 -1
- package/src/index.ts +4 -4
- package/src/ledger/herdr-owner.ts +13 -5
- package/src/ledger/herdr-runs.ts +44 -0
- package/src/locales/de.json +4 -1
- package/src/locales/en.json +5 -1
- package/src/locales/es.json +4 -1
- package/src/locales/fr.json +4 -1
- package/src/locales/pt-BR.json +4 -1
- package/src/locales/pt.json +4 -1
- package/src/locales/ru.json +4 -1
- package/src/locales/uk.json +4 -1
- package/src/locales/zh-TW.json +36 -0
- package/src/locales/zh.json +5 -1
- package/src/state/i18n-bridge.ts +52 -4
- package/src/todo-overlay.ts +464 -64
- package/src/view/format.ts +2 -1
- package/src/view/live-runs.ts +120 -0
- package/src/view/task-labels.ts +2 -1
package/CONTRACT.md
CHANGED
|
@@ -167,7 +167,11 @@ A match issues a normal guarded `update`: `owner` becomes the full `details.name
|
|
|
167
167
|
|
|
168
168
|
`name` is verbatim; `id` is the child **run id** (`details.id`), not the parent's session id or a path-derived id.
|
|
169
169
|
`pane` is the acknowledged `details.worktree.paneId` and is absent for ordinary launches.
|
|
170
|
-
|
|
170
|
+
The top-level fields always describe the latest assignment. An old pane id does not carry forward. For example, after a reviewer joins a worker on the same task, `owner` and `metadata.herdr.id` identify the reviewer.
|
|
171
|
+
|
|
172
|
+
New writers also store `metadata.herdr.runs`: up to six `{ name, id, pane?, session?, agent? }` records, unique by run id, newest last. `session` is the launch acknowledgement's `sessionFile`. Once the list exceeds six, `metadata.herdr.older` counts the discarded records. An earlier v1 record without `runs` counts as one binding. A reader that finds a repeated run id (in imported or hand-edited metadata) keeps that id's last record in its last position, then applies the cap of six, so the next write is unique again. The snapshot version remains 1.
|
|
173
|
+
|
|
174
|
+
A successful `subagent_resume` appends its new run id when its acknowledged `sessionPath` matches a retained session path on exactly one non-deleted task in the calling session. An unknown or ambiguous path binds nothing.
|
|
171
175
|
Other metadata stays intact; a refusal leaves the launch successful but adds the reason to its response.
|
|
172
176
|
Manual `owner` updates (including `self`) are still allowed; the optional `herdr` record describes the last bound launch, not proof of a live pane or of the current owner's identity.
|
|
173
177
|
|
package/README.md
CHANGED
|
@@ -49,7 +49,7 @@ Use `metadata.herdr.id` to resolve or message the worker by its run key.
|
|
|
49
49
|
Use a name with `/boss send` only if it matches the name Straw Boss shows; a launch named `API worker` may appear there as `api-worker`.
|
|
50
50
|
You can still set `owner` by hand.
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
`/todos` and the panel's full view indent each open task under its first unfinished blocker; the panel's default focus view lists tasks flat and names every unfinished blocker after the subject. Both show the owner as `@owner`.
|
|
53
53
|
To mark a task as waiting for someone, set `metadata.waitsOn` to their name; to defer it until a particular time, set `metadata.until` to an ISO timestamp, e.g. `2027-01-15T09:00:00+08:00`.
|
|
54
54
|
An open task shows `⏸` with the name or the future deadline in local time.
|
|
55
55
|
These keys are display conventions: they neither schedule a wake-up nor change the task's `status` or the `todo/v1` contract.
|
|
@@ -110,18 +110,22 @@ Without one, the extension reads `rpiv-todo/config.json` from the same directori
|
|
|
110
110
|
```json
|
|
111
111
|
{
|
|
112
112
|
"maxWidgetLines": 8,
|
|
113
|
-
"collapseKey": "alt+t"
|
|
113
|
+
"collapseKey": "alt+t",
|
|
114
|
+
"view": "full"
|
|
114
115
|
}
|
|
115
116
|
```
|
|
116
117
|
|
|
117
118
|
| Setting | What it does | Default |
|
|
118
119
|
| --- | --- | --- |
|
|
119
|
-
| `
|
|
120
|
-
| `
|
|
120
|
+
| `view` | The panel's starting state. `"focus"` lists the tasks in progress and the next open ones, and folds the rest into one summary row. `"full"` shows the whole dependency tree. | `"focus"` |
|
|
121
|
+
| `maxWidgetLines` | Content rows the panel may use, heading included. Minimum `3`. Pi's tool-output expansion mode lifts the limit. | `12` |
|
|
122
|
+
| `collapseKey` | Key that cycles the panel focus → full → collapsed → focus, starting from `view`, in pi keybinding form (`alt+o`, `ctrl+shift+t`). A dim hint such as `+5 pending · ctrl+shift+t full` names the next state. `"off"` registers no shortcut and shows no hint. Needs `/reload` to rebind. | `"ctrl+shift+t"` |
|
|
121
123
|
| `guidance` | Replaces the built-in instructions the extension gives the model about the todo list (`promptSnippet`, `promptGuidelines`). Needs `/reload`. | built-ins |
|
|
122
124
|
|
|
123
125
|
More detail: [Configuration](docs/configuration.md), [`todo` tool reference](docs/tool-schema.md), [Panel and `/todos`](docs/overlay.md).
|
|
124
|
-
The panel's text
|
|
126
|
+
The panel's text follows the locale chosen in [`@juicesharp/rpiv-i18n`](https://www.npmjs.com/package/@juicesharp/rpiv-i18n) when it is installed.
|
|
127
|
+
Traditional Chinese needs `--locale zh-TW` or a `zh_TW` system locale, because the `/languages` picker offers only Simplified `zh`.
|
|
128
|
+
Without rpiv-i18n the panel is Traditional Chinese under a `zh_TW` or `zh_Hant` system locale and English otherwise; see [Localization](docs/overlay.md#localization).
|
|
125
129
|
|
|
126
130
|
## License
|
|
127
131
|
|
package/docs/configuration.md
CHANGED
|
@@ -31,6 +31,7 @@ The extension never writes this file — you create and edit it yourself.
|
|
|
31
31
|
{
|
|
32
32
|
"maxWidgetLines": 8,
|
|
33
33
|
"collapseKey": "alt+t",
|
|
34
|
+
"view": "full",
|
|
34
35
|
"guidance": {
|
|
35
36
|
"promptSnippet": "Use the `todo` tool to track multi-step work before starting it.",
|
|
36
37
|
"promptGuidelines": [
|
|
@@ -41,10 +42,26 @@ The extension never writes this file — you create and edit it yourself.
|
|
|
41
42
|
}
|
|
42
43
|
```
|
|
43
44
|
|
|
45
|
+
## `view`
|
|
46
|
+
|
|
47
|
+
**Default `"focus"`.** How the overlay lays out the list.
|
|
48
|
+
|
|
49
|
+
- `"focus"` shows the tasks in progress with their worker runs, the next two
|
|
50
|
+
open tasks (three when nothing is in progress), and one summary row for the
|
|
51
|
+
rest, such as `+1 in progress, 5 pending, 2 completed`.
|
|
52
|
+
- `"full"` shows the whole dependency tree, as releases up to 0.6.0 did.
|
|
53
|
+
- Any other value, or none, means `"focus"`.
|
|
54
|
+
- Read fresh on every render, like `maxWidgetLines`, so no `/reload`.
|
|
55
|
+
- It sets the starting state only. The `collapseKey` shortcut then cycles
|
|
56
|
+
focus → full → collapsed from there, and the chosen state holds for the rest
|
|
57
|
+
of the session.
|
|
58
|
+
|
|
59
|
+
[overlay.md](./overlay.md#focus-view) describes both layouts.
|
|
60
|
+
|
|
44
61
|
## `maxWidgetLines`
|
|
45
62
|
|
|
46
63
|
**Default `12`.** The content-row budget for the overlay — the heading row and,
|
|
47
|
-
on overflow, the
|
|
64
|
+
on overflow, the summary row both count against it. Only the trailing
|
|
48
65
|
blank spacer sits outside the budget, so `12` renders up to 13 terminal rows.
|
|
49
66
|
|
|
50
67
|
- Floor of `3`. A number below `3` falls back to the default.
|
|
@@ -52,13 +69,16 @@ blank spacer sits outside the budget, so `12` renders up to 13 terminal rows.
|
|
|
52
69
|
- No ceiling.
|
|
53
70
|
- Read fresh on every render, so a change takes effect on the next repaint —
|
|
54
71
|
no `/reload`.
|
|
55
|
-
- Pi's tool-output expansion mode (`ctrl+o` by default) temporarily
|
|
56
|
-
this budget
|
|
72
|
+
- Pi's tool-output expansion mode (`ctrl+o` by default) temporarily lifts
|
|
73
|
+
this budget; collapsing restores it. In the full view that shows every task.
|
|
74
|
+
The focus view keeps its selection and only stops cutting rows for space.
|
|
57
75
|
|
|
58
76
|
## `collapseKey`
|
|
59
77
|
|
|
60
|
-
**Default `"ctrl+shift+t"`.** The shortcut that
|
|
61
|
-
|
|
78
|
+
**Default `"ctrl+shift+t"`.** The shortcut that cycles the overlay through
|
|
79
|
+
the focus view, the full view, and the collapsed state, in that order, starting
|
|
80
|
+
from `view`. Each state shows a dim hint with this key and the next state; see
|
|
81
|
+
[overlay.md](./overlay.md#switching-views).
|
|
62
82
|
|
|
63
83
|
The value is trimmed and lowercased, then matched against Pi's keybinding
|
|
64
84
|
grammar: zero or more distinct modifiers joined by `+`, then a base key.
|
|
@@ -75,11 +95,10 @@ Examples: `alt+o`, `ctrl+shift+t`, `super+alt+f5`.
|
|
|
75
95
|
default. The grammar is checked strictly on purpose: Pi takes the last `+`-part
|
|
76
96
|
as the base key and ignores unknown parts, so a typo like `ctr+]` would
|
|
77
97
|
otherwise capture every bare `]` keypress globally.
|
|
78
|
-
- `"off"` disables the feature
|
|
98
|
+
- `"off"` disables the feature: no shortcut is registered and no hint is shown.
|
|
79
99
|
- The binding is resolved **once at extension load**. After editing this value,
|
|
80
100
|
run `/reload` to rebind; until you do, the old key stays active even though the
|
|
81
|
-
|
|
82
|
-
new one.
|
|
101
|
+
panel's hint text (which is resolved per render) already shows the new one.
|
|
83
102
|
|
|
84
103
|
## Guidance
|
|
85
104
|
|
package/docs/overlay.md
CHANGED
|
@@ -21,15 +21,45 @@ and taking the last saved snapshot, which replaces the whole list
|
|
|
21
21
|
(last-write-wins). See [tool-schema.md](./tool-schema.md#persistence) for where
|
|
22
22
|
snapshots are saved.
|
|
23
23
|
|
|
24
|
+
## Focus view
|
|
25
|
+
|
|
26
|
+
The panel opens in the focus view. It shows what is being worked on and what comes next, and folds the rest into one row:
|
|
27
|
+
|
|
28
|
+
```text
|
|
29
|
+
● Todos (0/8)
|
|
30
|
+
├─ ◐ #8 執行等待
|
|
31
|
+
│ └ fixture-test · astra · 執行中 6s
|
|
32
|
+
├─ ○ #1 檢查畫面
|
|
33
|
+
├─ ○ #2 確認版面
|
|
34
|
+
└─ +5 待處理 · ctrl+shift+t 完整
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Rows come in this order, until the row budget runs out:
|
|
38
|
+
|
|
39
|
+
1. the heading;
|
|
40
|
+
2. every task in progress, each followed by its run rows;
|
|
41
|
+
3. the next two open tasks in display order, or the next three when nothing is in progress;
|
|
42
|
+
4. completed tasks from the current turn, only if rows are left after the run rows;
|
|
43
|
+
5. one summary row counting the hidden tasks in progress, pending, and completed, in that order, such as `+1 in progress, 5 pending, 2 completed` (`+1 進行中、5 待處理、2 已完成` in zh-TW). Zero counts are left out, and with nothing hidden there is no summary row.
|
|
44
|
+
|
|
45
|
+
The summary row ends with a dim hint that names the panel key and the state it switches to next; see [Switching views](#switching-views).
|
|
46
|
+
|
|
47
|
+
`maxWidgetLines` is a hard cap here too: tasks in progress that do not fit are counted in the summary, and run rows that do not fit fold into `· N runs`.
|
|
48
|
+
Rows are flat, so the `⛓` tail lists every unfinished blocker of a task; `⏸`, owners, and the other marks are the same as in the full view.
|
|
49
|
+
Pi's tool-output expansion mode lifts the row cap but keeps this selection. Press the panel key for the tree below, set `"view": "full"` (see [configuration.md](./configuration.md#view)) to start there, or use `/todos` to see everything once.
|
|
50
|
+
|
|
24
51
|
## Anatomy of a row
|
|
25
52
|
|
|
53
|
+
The full view (`"view": "full"`) draws the whole dependency tree:
|
|
54
|
+
|
|
26
55
|
```text
|
|
27
56
|
● Todos (0/5) · fan-out/fan-in
|
|
28
57
|
├─ ◐ #1 Scope @Ari
|
|
29
58
|
├─ ○ #3 API
|
|
30
59
|
├─ ○ #4 Check API
|
|
31
60
|
├─ ○ #5 UI
|
|
32
|
-
|
|
61
|
+
├─ ⏸ #2 Approve waits Pat
|
|
62
|
+
└─ ctrl+shift+t collapse
|
|
33
63
|
```
|
|
34
64
|
|
|
35
65
|
- **Heading** — `● Todos (done/total)` in the accent color while any task is
|
|
@@ -38,7 +68,7 @@ snapshots are saved.
|
|
|
38
68
|
- **Glyphs** — `○` pending, `◐` in_progress, `✓` completed, `✗` deleted.
|
|
39
69
|
Completed and deleted subjects render dim and struck through.
|
|
40
70
|
- **activeForm** — appended dim in parentheses, only while the task is
|
|
41
|
-
`in_progress
|
|
71
|
+
`in_progress` and only when it differs from the subject (ignoring leading and trailing spaces).
|
|
42
72
|
- **Waiting** — `⏸` replaces the open-task glyph when `metadata.waitsOn` names a party or `metadata.until` is an ISO time in the future. The row shows the party, the local deadline, or both. An elapsed deadline no longer marks a task as waiting.
|
|
43
73
|
- **Owner** — `@owner` follows the subject in muted text.
|
|
44
74
|
- **Dependencies** — open rows nest under the first unfinished `blockedBy` id; siblings are visited in id order. Other unfinished blockers appear in the `⛓ #1,#2` tail. If another prerequisite interrupts a branch, `↳ #N` names the parent the row returns to.
|
|
@@ -49,10 +79,31 @@ snapshots are saved.
|
|
|
49
79
|
|
|
50
80
|
Rows longer than the terminal width are truncated with `…`.
|
|
51
81
|
|
|
82
|
+
## Worker runs under a task
|
|
83
|
+
|
|
84
|
+
When pi-herdr-agents is loaded, each task lists its live bound runs (`metadata.herdr.runs`) under its row: name, short model, state, and time in that state.
|
|
85
|
+
A run that is not working keeps its one row and gains a mark before its name:
|
|
86
|
+
|
|
87
|
+
- `◇ … · idle 3m` (zh-TW `閒置`), dim: its turn ended, or a persistent specialist sits between tasks (Maestro lifecycle `waiting`).
|
|
88
|
+
- `? … · waiting 42s` (zh-TW `等待回覆`), in the warning color: the pane shows a dialog, approval, or question (Maestro lifecycle `blocked`).
|
|
89
|
+
|
|
90
|
+
Starting and working runs carry no mark; other lifecycle kinds show their state word only.
|
|
91
|
+
A pending cancel replaces the state with `cancelling` or `cancel unconfirmed` and drops the mark.
|
|
92
|
+
Run rows count against the row budget; a task whose runs do not fit shows `· N runs` instead.
|
|
93
|
+
|
|
94
|
+
The panel asks the Subagents widget to hide a run only once it knows the run's row reached the screen:
|
|
95
|
+
|
|
96
|
+
- In Pi's inline renderer every widget line is written, so a row drawn on two frames in a row counts.
|
|
97
|
+
- Pi's fullscreen layout can clip the panel after it is drawn. Each run row there ends in an invisible marker unique to the panel and run: an escape sequence shaped like OSC 8 with an `id` parameter and no URI. Pi counts it as zero width, and terminals drop it (Ghostty and Herdr discard it as an invalid OSC 8), so it neither shows nor opens a link. Right after Pi paints a frame, the panel looks in `getScreenLines()` for a line that starts with the exact row it drew, marker included. A row the layout cut off is absent, and a row under a popup, a search highlight, or a selection no longer matches, so in both cases its run stays in the Subagents widget. A changed claim triggers one more frame, so the Subagents widget catches up one frame later.
|
|
98
|
+
- A renderer that offers neither gives no evidence, and the Subagents widget keeps every run.
|
|
99
|
+
|
|
100
|
+
Collapsing the panel, or the run leaving the panel, returns the run to the Subagents widget.
|
|
101
|
+
|
|
52
102
|
## Overflow
|
|
53
103
|
|
|
54
104
|
The content-row budget is `maxWidgetLines` (default `12`), and the heading counts
|
|
55
|
-
against it.
|
|
105
|
+
against it. The focus view applies it as described [above](#focus-view). In the
|
|
106
|
+
full view, when there are more tasks than fit:
|
|
56
107
|
|
|
57
108
|
1. one row is reserved for the summary line;
|
|
58
109
|
2. completed tasks are dropped first, newest first — the oldest completed rows
|
|
@@ -61,8 +112,8 @@ against it. When there are more tasks than fit:
|
|
|
61
112
|
truncated;
|
|
62
113
|
4. the last row becomes `+N more (X completed, Y pending)`.
|
|
63
114
|
|
|
64
|
-
|
|
65
|
-
widget
|
|
115
|
+
In the full view, Pi's tool-output expansion shortcut (`ctrl+o` by default)
|
|
116
|
+
expands the widget to show every task. Collapsing Pi's tool output reapplies the configured
|
|
66
117
|
row budget. Unfinished work is therefore the last thing to disappear in the
|
|
67
118
|
compact view. See [configuration.md](./configuration.md#maxwidgetlines) for the
|
|
68
119
|
budget's floor and reload semantics.
|
|
@@ -74,16 +125,37 @@ completed. At the start of the next agent turn, every completed row that has
|
|
|
74
125
|
already been displayed is hidden from later renders. Reloading or compacting the
|
|
75
126
|
session resets that tracking, so a fresh session shows the full list again.
|
|
76
127
|
|
|
77
|
-
##
|
|
128
|
+
## Switching views
|
|
129
|
+
|
|
130
|
+
`ctrl+shift+t` steps the panel through three states, always in this order:
|
|
78
131
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
the
|
|
132
|
+
1. focus view;
|
|
133
|
+
2. full view;
|
|
134
|
+
3. collapsed: the heading and one dim hint row, `└─ ctrl+shift+t focus`.
|
|
135
|
+
|
|
136
|
+
The panel starts in the state `view` names, `"focus"` unless you set `"full"`,
|
|
137
|
+
and the next press continues the cycle from there: from `"full"` it goes to
|
|
138
|
+
collapsed, then focus, then full again. The chosen state holds until the next
|
|
139
|
+
press or the end of the session.
|
|
140
|
+
|
|
141
|
+
Each state shows a dim hint naming the key and the next state: `ctrl+shift+t
|
|
142
|
+
full`, `ctrl+shift+t collapse`, `ctrl+shift+t focus` (`完整`, `收合`, `焦點` in
|
|
143
|
+
zh-TW). In the focus and full views the hint ends the summary row after a ` · `.
|
|
144
|
+
It is the first thing cut when the row is too narrow. With nothing to summarize,
|
|
145
|
+
the hint takes its own closing `└─` row, and only when the row budget has a row
|
|
146
|
+
to spare, so it never pushes a task out. The hint always shows the configured
|
|
147
|
+
key.
|
|
148
|
+
|
|
149
|
+
Collapsing hides the run rows, so the panel releases its claim on them; the
|
|
150
|
+
Subagents widget can show them again. In the focus and full views the panel
|
|
151
|
+
claims the run rows it actually paints, as described under
|
|
152
|
+
[Worker runs under a task](#worker-runs-under-a-task).
|
|
82
153
|
|
|
83
154
|
Rebind or disable the shortcut with the `collapseKey` option; see
|
|
84
|
-
[configuration.md](./configuration.md#collapsekey).
|
|
85
|
-
`"off"` while the panel is collapsed, the
|
|
86
|
-
label rather than advertising an
|
|
155
|
+
[configuration.md](./configuration.md#collapsekey). With `"off"` no hint is
|
|
156
|
+
shown. If the shortcut is set to `"off"` while the panel is collapsed, the
|
|
157
|
+
collapsed row becomes a static `collapsed` label rather than advertising an
|
|
158
|
+
unbindable key.
|
|
87
159
|
|
|
88
160
|
## `/todos`
|
|
89
161
|
|
|
@@ -107,18 +179,28 @@ tasks. Tombstoned tasks are never listed.
|
|
|
107
179
|
|
|
108
180
|
## Localization
|
|
109
181
|
|
|
110
|
-
The overlay heading,
|
|
182
|
+
The overlay heading, both summary rows, the key hint, the `/todos`
|
|
111
183
|
section headers, and the status words all localize through
|
|
112
184
|
[`@juicesharp/rpiv-i18n`](https://www.npmjs.com/package/@juicesharp/rpiv-i18n)
|
|
113
185
|
when that package is installed. Bundled locales: `de`, `en`, `es`, `fr`, `pt`,
|
|
114
|
-
`pt-BR`, `ru`, `uk`, `zh
|
|
186
|
+
`pt-BR`, `ru`, `uk`, `zh` (Simplified), and `zh-TW` (Traditional).
|
|
187
|
+
|
|
188
|
+
The `/languages` picker has no Traditional Chinese entry; its `中文 (zh)` is
|
|
189
|
+
Simplified. An explicit choice always wins, and the system locale is only the
|
|
190
|
+
default. To get Traditional Chinese, use one of:
|
|
191
|
+
|
|
192
|
+
- `pi --locale zh-TW`;
|
|
193
|
+
- `{ "locale": "zh-TW" }` in rpiv-i18n's `locale.json` (see its README for the path);
|
|
194
|
+
- **System default** in `/languages`, with `LC_ALL`, `LC_MESSAGES`, or `LANG` set to
|
|
195
|
+
a `zh_TW` or `zh_Hant` locale such as `zh_TW.UTF-8`.
|
|
115
196
|
|
|
116
197
|
LLM-facing output — the tool response envelope, reducer error messages, and the
|
|
117
198
|
schema descriptions — stays English by design.
|
|
118
199
|
|
|
119
200
|
The SDK is a soft optional peer, loaded through a dynamic import at module init.
|
|
120
|
-
When it is absent,
|
|
121
|
-
|
|
201
|
+
When it is absent, the panel is Traditional Chinese under a `zh_TW` or `zh_Hant`
|
|
202
|
+
system locale and English otherwise, and the extension stays online: no warning,
|
|
203
|
+
no crash. Install it at any time with
|
|
122
204
|
`pi install npm:@juicesharp/rpiv-i18n` and restart the session. To add or
|
|
123
205
|
override a translation, drop a `locales/<code>.json` file mirroring `en.json` —
|
|
124
206
|
see the `@juicesharp/rpiv-i18n` README's "Contributing translations" section.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-todo-ledger",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"description": "A todo list for pi agents with a public bookkeeping contract: snapshot entries, change events, and namespace validators. Fork of @juicesharp/rpiv-todo",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
package/src/config.ts
CHANGED
|
@@ -39,6 +39,24 @@ export function configCandidates(): string[] {
|
|
|
39
39
|
return [CONFIG_NAME, LEGACY_CONFIG_NAME].flatMap((name) => dirs.map((dir) => join(dir, name, "config.json")));
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
/**
|
|
43
|
+
* The locale rpiv-i18n's `/languages` picker saved, read the way rpiv-config reads it:
|
|
44
|
+
* the `$XDG_CONFIG_HOME` file wins when it exists, else `~/.config/rpiv-i18n/locale.json`.
|
|
45
|
+
*/
|
|
46
|
+
export function savedLocale(): string | undefined {
|
|
47
|
+
for (const dir of configDirs()) {
|
|
48
|
+
const path = join(dir, "rpiv-i18n", "locale.json");
|
|
49
|
+
if (!existsSync(path)) continue;
|
|
50
|
+
try {
|
|
51
|
+
const locale = (JSON.parse(readFileSync(path, "utf-8")) as { locale?: unknown } | null)?.locale;
|
|
52
|
+
return typeof locale === "string" && locale ? locale : undefined;
|
|
53
|
+
} catch {
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
|
|
42
60
|
/** Parse a JSON config file; `{}` for malformed JSON or a non-object value (with a warning). */
|
|
43
61
|
function readJsonObject(path: string): Record<string, unknown> {
|
|
44
62
|
try {
|
|
@@ -78,12 +96,25 @@ interface TodoConfig {
|
|
|
78
96
|
guidance?: GuidanceFields;
|
|
79
97
|
maxWidgetLines?: number;
|
|
80
98
|
/**
|
|
81
|
-
* Key spec for the overlay
|
|
99
|
+
* Key spec for the overlay cycle shortcut (focus → full → collapsed), in the same format as
|
|
82
100
|
* pi-coding-agent keybinding ids (`modifier+key`, e.g. `ctrl+shift+t`, `alt+o`).
|
|
83
101
|
* Defaults to `"ctrl+shift+t"`. Pass `"off"` to disable the collapse shortcut
|
|
84
102
|
* entirely. Validation happens in `resolveCollapseKey`, not at load.
|
|
85
103
|
*/
|
|
86
104
|
collapseKey?: string;
|
|
105
|
+
/** Panel layout: `"focus"` (default) or `"full"`. Validated in `getView`. */
|
|
106
|
+
view?: unknown;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** Panel layout: the compact focus view, or the whole dependency tree. */
|
|
110
|
+
export type OverlayView = "focus" | "full";
|
|
111
|
+
|
|
112
|
+
/** Default panel layout when `view` is missing or not one of the two names. */
|
|
113
|
+
export const DEFAULT_VIEW: OverlayView = "focus";
|
|
114
|
+
|
|
115
|
+
/** Panel layout, read fresh on every render like getMaxWidgetLines(); anything but `"full"` is focus. */
|
|
116
|
+
export function getView(): OverlayView {
|
|
117
|
+
return loadConfig().view === "full" ? "full" : DEFAULT_VIEW;
|
|
87
118
|
}
|
|
88
119
|
|
|
89
120
|
/** Default content-row budget when the config is missing/invalid — the prior
|
package/src/index.ts
CHANGED
|
@@ -169,7 +169,7 @@ export default function (
|
|
|
169
169
|
const { TodoOverlay } = await loadTodoOverlay();
|
|
170
170
|
if (generation !== lifecycleGeneration || !uiCtx) return;
|
|
171
171
|
|
|
172
|
-
todoOverlay ??= new TodoOverlay();
|
|
172
|
+
todoOverlay ??= new TodoOverlay(p => pi.events.emit('pi-herdr-agents:run-rows:v1', p));
|
|
173
173
|
todoOverlay.setUICtx(uiCtx);
|
|
174
174
|
if (resetCompletedDisplayState) todoOverlay.resetCompletedDisplayState();
|
|
175
175
|
todoOverlay.update();
|
|
@@ -200,7 +200,7 @@ export default function (
|
|
|
200
200
|
pi.events.emit(CHANGED_EVENT, toChangedEvent(id, getState(id)));
|
|
201
201
|
};
|
|
202
202
|
|
|
203
|
-
//
|
|
203
|
+
// Cycle hotkey for the todo overlay (focus → full → collapsed). The key is resolved once at
|
|
204
204
|
// factory scope from config (register-once contract: a config change needs
|
|
205
205
|
// `/reload` to re-bind, same as lane-switcher's env hotkey) and the binding is
|
|
206
206
|
// skipped entirely when collapseKey is "off". The handler closes over the
|
|
@@ -211,10 +211,10 @@ export default function (
|
|
|
211
211
|
const collapseKey = resolveCollapseKey();
|
|
212
212
|
if (collapseKey !== COLLAPSE_KEY_OFF) {
|
|
213
213
|
pi.registerShortcut(collapseKey as KeyId, {
|
|
214
|
-
description: "
|
|
214
|
+
description: "Cycle the todo overlay: focus, full, collapsed",
|
|
215
215
|
handler: (ctx) => {
|
|
216
216
|
if (!ctx.hasUI || !todoOverlay?.isRegistered()) return;
|
|
217
|
-
todoOverlay.
|
|
217
|
+
todoOverlay.cycleView();
|
|
218
218
|
},
|
|
219
219
|
});
|
|
220
220
|
}
|
|
@@ -6,6 +6,8 @@ import { sanitizeTerminalText } from "../tool/sanitize.ts";
|
|
|
6
6
|
import type { FinishCall } from "./finish-call.ts";
|
|
7
7
|
import { runningGuard } from "./guards.ts";
|
|
8
8
|
|
|
9
|
+
import { bindRun, history } from "./herdr-runs.ts";
|
|
10
|
+
|
|
9
11
|
const uid = /^t_[a-z2-7]{10}$/;
|
|
10
12
|
const local = /^([a-f0-9]{8})#([1-9]\d*)$/i;
|
|
11
13
|
const record = (x: unknown): x is Record<string, unknown> => typeof x === "object" && x !== null && !Array.isArray(x);
|
|
@@ -35,7 +37,8 @@ export function registerHerdrOwner(pi: ExtensionAPI, finish: FinishCall) {
|
|
|
35
37
|
// A blocked call need not produce a result. Drop any leftover captures at the turn boundary.
|
|
36
38
|
pi.on("agent_end", (_event, ctx) => { pending.delete(sid(ctx)); });
|
|
37
39
|
pi.on("tool_result", async (event, ctx) => {
|
|
38
|
-
|
|
40
|
+
const resume = event.toolName === "subagent_resume";
|
|
41
|
+
if (!resume && event.toolName !== "subagent") return;
|
|
39
42
|
const session = sid(ctx);
|
|
40
43
|
const calls = pending.get(session);
|
|
41
44
|
const capture = calls?.get(event.toolCallId);
|
|
@@ -44,11 +47,13 @@ export function registerHerdrOwner(pi: ExtensionAPI, finish: FinishCall) {
|
|
|
44
47
|
const d = event.details;
|
|
45
48
|
if (event.isError || !record(d) || d.status !== "started" || !nonblank(d.name) || !nonblank(d.id)) return;
|
|
46
49
|
const item = d.item;
|
|
47
|
-
|
|
50
|
+
const path = resume ? event.input.sessionPath : d.sessionFile;
|
|
51
|
+
if (resume ? (!nonblank(path) || path !== d.sessionPath) : (typeof item !== "string" || item !== event.input.item)) return;
|
|
48
52
|
const pinned = capture?.item === item ? capture : undefined;
|
|
49
|
-
if (!pinned && !uid.test(item)) return;
|
|
53
|
+
if (!resume && !pinned && !(typeof item === 'string' && uid.test(item))) return;
|
|
50
54
|
const pane = record(d.worktree) ? d.worktree.paneId : undefined;
|
|
51
|
-
const
|
|
55
|
+
const agent = d.agent ?? event.input.agent;
|
|
56
|
+
const run = { name: d.name, id: d.id, ...(nonblank(path) ? {session:path} : {}), ...(nonblank(agent) ? {agent} : {}), ...(nonblank(pane) ? { pane } : {}) };
|
|
52
57
|
const warn = (why: string) => ({
|
|
53
58
|
content: [...event.content, { type: "text" as const, text: `Todo owner binding: ${sanitizeTerminalText(why)}` }],
|
|
54
59
|
structuredContent: event.structuredContent,
|
|
@@ -58,10 +63,13 @@ export function registerHerdrOwner(pi: ExtensionAPI, finish: FinishCall) {
|
|
|
58
63
|
return await withSessionLock(session, async () => {
|
|
59
64
|
const before = getState(session);
|
|
60
65
|
if (pinned && !pinned.uid && listGeneration(session) !== pinned.generation) return;
|
|
61
|
-
const
|
|
66
|
+
const matches = resume ? before.tasks.filter(t => t.status !== 'deleted' && history(t.metadata?.herdr).runs.some(r => r.session === path)) : [];
|
|
67
|
+
if (resume && matches.length !== 1) return;
|
|
68
|
+
const task = resume ? matches[0] : pinned && !pinned.uid
|
|
62
69
|
? before.tasks.find(t => t.id === pinned.id && !t.uid)
|
|
63
70
|
: before.tasks.find(t => t.uid === (pinned?.uid ?? item));
|
|
64
71
|
if (!task || task.status === "deleted") return;
|
|
72
|
+
const herdr = bindRun(task.metadata?.herdr, run);
|
|
65
73
|
const params = { action: "update", id: task.id, owner: herdr.name, metadata: { herdr } };
|
|
66
74
|
const result = await finish(session, ctx.cwd, "update", params, before, applyTaskMutation(before, "update", params));
|
|
67
75
|
if (result.details.error) return warn(result.details.error);
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export interface BoundRun {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
pane?: string;
|
|
5
|
+
session?: string;
|
|
6
|
+
agent?: string;
|
|
7
|
+
}
|
|
8
|
+
export function history(value: unknown): { runs: BoundRun[]; older: number } {
|
|
9
|
+
if (!value || typeof value !== "object") return { runs: [], older: 0 };
|
|
10
|
+
const h = value as Record<string, unknown>;
|
|
11
|
+
const valid = (Array.isArray(h.runs) ? h.runs : [h]).filter(
|
|
12
|
+
(r): r is BoundRun =>
|
|
13
|
+
r && typeof r.id === "string" && typeof r.name === "string",
|
|
14
|
+
);
|
|
15
|
+
// Imported or hand-edited metadata may repeat an id: keep its last record, in its last position.
|
|
16
|
+
const seen = new Set<string>();
|
|
17
|
+
const unique: BoundRun[] = [];
|
|
18
|
+
for (let i = valid.length - 1; i >= 0; i--) {
|
|
19
|
+
if (seen.has(valid[i].id)) continue;
|
|
20
|
+
seen.add(valid[i].id);
|
|
21
|
+
unique.push(valid[i]);
|
|
22
|
+
}
|
|
23
|
+
unique.reverse();
|
|
24
|
+
const stored =
|
|
25
|
+
typeof h.older === "number" && Number.isSafeInteger(h.older) && h.older > 0
|
|
26
|
+
? h.older
|
|
27
|
+
: 0;
|
|
28
|
+
return {
|
|
29
|
+
runs: unique.slice(-6),
|
|
30
|
+
older: stored + Math.max(0, unique.length - 6),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export function bindRun(previous: unknown, newest: BoundRun) {
|
|
34
|
+
const { runs, older } = history(previous);
|
|
35
|
+
const next = [...runs.filter((r) => r.id !== newest.id), newest];
|
|
36
|
+
const dropped = older + Math.max(0, next.length - 6);
|
|
37
|
+
return {
|
|
38
|
+
name: newest.name,
|
|
39
|
+
id: newest.id,
|
|
40
|
+
...(newest.pane ? { pane: newest.pane } : {}),
|
|
41
|
+
runs: next.slice(-6),
|
|
42
|
+
...(dropped ? { older: dropped } : {}),
|
|
43
|
+
};
|
|
44
|
+
}
|
package/src/locales/de.json
CHANGED
|
@@ -8,7 +8,10 @@
|
|
|
8
8
|
|
|
9
9
|
"overlay.heading": "Todos",
|
|
10
10
|
"overlay.more": "weitere",
|
|
11
|
-
"overlay.
|
|
11
|
+
"overlay.keyHint": "{key} {next}",
|
|
12
|
+
"overlay.next.focus": "Fokus",
|
|
13
|
+
"overlay.next.full": "voll",
|
|
14
|
+
"overlay.next.collapsed": "einklappen",
|
|
12
15
|
"overlay.collapsed": "eingeklappt",
|
|
13
16
|
|
|
14
17
|
"command.no_todos": "Noch keine Todos. Bitte den Agenten, welche hinzuzufügen!",
|
package/src/locales/en.json
CHANGED
|
@@ -6,8 +6,12 @@
|
|
|
6
6
|
|
|
7
7
|
"overlay.heading": "Todos",
|
|
8
8
|
"overlay.more": "more",
|
|
9
|
-
"overlay.
|
|
9
|
+
"overlay.keyHint": "{key} {next}",
|
|
10
|
+
"overlay.next.focus": "focus",
|
|
11
|
+
"overlay.next.full": "full",
|
|
12
|
+
"overlay.next.collapsed": "collapse",
|
|
10
13
|
"overlay.collapsed": "collapsed",
|
|
14
|
+
"overlay.separator": ", ",
|
|
11
15
|
|
|
12
16
|
"command.no_todos": "No todos yet. Ask the agent to add some!",
|
|
13
17
|
"command.requires_interactive": "/todos requires interactive mode",
|
package/src/locales/es.json
CHANGED
|
@@ -8,7 +8,10 @@
|
|
|
8
8
|
|
|
9
9
|
"overlay.heading": "Tareas",
|
|
10
10
|
"overlay.more": "más",
|
|
11
|
-
"overlay.
|
|
11
|
+
"overlay.keyHint": "{key} {next}",
|
|
12
|
+
"overlay.next.focus": "enfoque",
|
|
13
|
+
"overlay.next.full": "completo",
|
|
14
|
+
"overlay.next.collapsed": "contraer",
|
|
12
15
|
"overlay.collapsed": "contraído",
|
|
13
16
|
|
|
14
17
|
"command.no_todos": "Sin tareas aún. ¡Pídele al agente que añada algunas!",
|
package/src/locales/fr.json
CHANGED
|
@@ -8,7 +8,10 @@
|
|
|
8
8
|
|
|
9
9
|
"overlay.heading": "Tâches",
|
|
10
10
|
"overlay.more": "autres",
|
|
11
|
-
"overlay.
|
|
11
|
+
"overlay.keyHint": "{key} {next}",
|
|
12
|
+
"overlay.next.focus": "focus",
|
|
13
|
+
"overlay.next.full": "complet",
|
|
14
|
+
"overlay.next.collapsed": "réduire",
|
|
12
15
|
"overlay.collapsed": "réduit",
|
|
13
16
|
|
|
14
17
|
"command.no_todos": "Pas encore de tâches. Demandez à l'agent d'en ajouter !",
|
package/src/locales/pt-BR.json
CHANGED
|
@@ -8,7 +8,10 @@
|
|
|
8
8
|
|
|
9
9
|
"overlay.heading": "Tarefas",
|
|
10
10
|
"overlay.more": "mais",
|
|
11
|
-
"overlay.
|
|
11
|
+
"overlay.keyHint": "{key} {next}",
|
|
12
|
+
"overlay.next.focus": "foco",
|
|
13
|
+
"overlay.next.full": "completo",
|
|
14
|
+
"overlay.next.collapsed": "recolher",
|
|
12
15
|
"overlay.collapsed": "recolhido",
|
|
13
16
|
|
|
14
17
|
"command.no_todos": "Nenhuma tarefa ainda. Peça ao agente para adicionar algumas!",
|
package/src/locales/pt.json
CHANGED
|
@@ -8,7 +8,10 @@
|
|
|
8
8
|
|
|
9
9
|
"overlay.heading": "Tarefas",
|
|
10
10
|
"overlay.more": "mais",
|
|
11
|
-
"overlay.
|
|
11
|
+
"overlay.keyHint": "{key} {next}",
|
|
12
|
+
"overlay.next.focus": "foco",
|
|
13
|
+
"overlay.next.full": "completo",
|
|
14
|
+
"overlay.next.collapsed": "recolher",
|
|
12
15
|
"overlay.collapsed": "recolhido",
|
|
13
16
|
|
|
14
17
|
"command.no_todos": "Sem tarefas ainda. Peça ao agente para adicionar algumas!",
|
package/src/locales/ru.json
CHANGED
|
@@ -8,7 +8,10 @@
|
|
|
8
8
|
|
|
9
9
|
"overlay.heading": "Задачи",
|
|
10
10
|
"overlay.more": "ещё",
|
|
11
|
-
"overlay.
|
|
11
|
+
"overlay.keyHint": "{key} {next}",
|
|
12
|
+
"overlay.next.focus": "фокус",
|
|
13
|
+
"overlay.next.full": "полностью",
|
|
14
|
+
"overlay.next.collapsed": "свернуть",
|
|
12
15
|
"overlay.collapsed": "свёрнуто",
|
|
13
16
|
|
|
14
17
|
"command.no_todos": "Задач пока нет. Попросите агента добавить!",
|
package/src/locales/uk.json
CHANGED
|
@@ -8,7 +8,10 @@
|
|
|
8
8
|
|
|
9
9
|
"overlay.heading": "Завдання",
|
|
10
10
|
"overlay.more": "ще",
|
|
11
|
-
"overlay.
|
|
11
|
+
"overlay.keyHint": "{key} {next}",
|
|
12
|
+
"overlay.next.focus": "фокус",
|
|
13
|
+
"overlay.next.full": "повністю",
|
|
14
|
+
"overlay.next.collapsed": "згорнути",
|
|
12
15
|
"overlay.collapsed": "згорнуто",
|
|
13
16
|
|
|
14
17
|
"command.no_todos": "Завдань поки немає. Попросіть агента додати!",
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"status.pending": "待處理",
|
|
3
|
+
"status.in_progress": "進行中",
|
|
4
|
+
"status.completed": "已完成",
|
|
5
|
+
"status.deleted": "已刪除",
|
|
6
|
+
"overlay.heading": "Todos",
|
|
7
|
+
"overlay.more": "項未顯示",
|
|
8
|
+
"overlay.keyHint": "{key} {next}",
|
|
9
|
+
"overlay.next.focus": "焦點",
|
|
10
|
+
"overlay.next.full": "完整",
|
|
11
|
+
"overlay.next.collapsed": "收合",
|
|
12
|
+
"overlay.collapsed": "已收合",
|
|
13
|
+
"overlay.separator": "、",
|
|
14
|
+
"command.no_todos": "目前沒有待辦事項。",
|
|
15
|
+
"command.requires_interactive": "/todos 需要互動模式",
|
|
16
|
+
"command.section.pending": "── 待處理 ──",
|
|
17
|
+
"command.section.in_progress": "── 進行中 ──",
|
|
18
|
+
"command.section.completed": "── 已完成 ──",
|
|
19
|
+
"wait.party": "等",
|
|
20
|
+
"wait.until": "等到",
|
|
21
|
+
"run.count": "個工作階段",
|
|
22
|
+
"run.cancel.requested": "取消中",
|
|
23
|
+
"run.cancel.unconfirmed": "取消未確認",
|
|
24
|
+
"run.tool.thread_wait": "等 thread",
|
|
25
|
+
"run.active.reviewer": "審查中",
|
|
26
|
+
"run.kind.active": "執行中",
|
|
27
|
+
"run.kind.running": "執行中",
|
|
28
|
+
"run.kind.starting": "啟動中",
|
|
29
|
+
"run.state.idle": "閒置",
|
|
30
|
+
"run.state.waiting": "等待回覆",
|
|
31
|
+
"run.kind.interrupted": "已中斷",
|
|
32
|
+
"run.kind.stalled": "停滯",
|
|
33
|
+
"run.kind.finalizing": "收尾中",
|
|
34
|
+
"run.kind.completed": "已完成",
|
|
35
|
+
"run.kind.failed": "失敗"
|
|
36
|
+
}
|