@juicesharp/rpiv-todo 1.1.3 → 1.1.5
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 +87 -12
- package/index.ts +64 -4
- package/locales/de.json +17 -0
- package/locales/en.json +15 -0
- package/locales/es.json +17 -0
- package/locales/fr.json +17 -0
- package/locales/pt-BR.json +17 -0
- package/locales/pt.json +17 -0
- package/locales/ru.json +17 -0
- package/locales/uk.json +17 -0
- package/package.json +10 -2
- package/state/i18n-bridge.ts +64 -0
- package/todo-overlay.ts +82 -24
- package/todo.ts +19 -12
- package/view/format.ts +6 -12
package/README.md
CHANGED
|
@@ -11,17 +11,17 @@
|
|
|
11
11
|
[](https://www.npmjs.com/package/@juicesharp/rpiv-todo)
|
|
12
12
|
[](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)
|
|
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
|

|
|
17
17
|
|
|
18
18
|
## Features
|
|
19
19
|
|
|
20
|
-
- **Live overlay above the editor**
|
|
21
|
-
- **Survives `/reload` and compaction**
|
|
22
|
-
- **Status states**
|
|
23
|
-
- **Dependency tracking**
|
|
24
|
-
- **Smart truncation**
|
|
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
|
|
|
@@ -31,22 +31,97 @@ pi install npm:@juicesharp/rpiv-todo
|
|
|
31
31
|
|
|
32
32
|
Then restart your Pi session.
|
|
33
33
|
|
|
34
|
+
### Optional: localization
|
|
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:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
pi install npm:@juicesharp/rpiv-i18n
|
|
40
|
+
```
|
|
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.
|
|
43
|
+
|
|
34
44
|
## Tool
|
|
35
45
|
|
|
36
|
-
- **`todo`**
|
|
46
|
+
- **`todo`** - create / update / list / get / delete / clear tasks. 4-state
|
|
37
47
|
machine (pending → in_progress → completed, plus deleted tombstone).
|
|
38
48
|
Supports `blockedBy` dependency tracking with cycle detection. Tasks persist
|
|
39
|
-
via branch replay
|
|
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
|
+
```
|
|
40
107
|
|
|
41
108
|
## Commands
|
|
42
109
|
|
|
43
|
-
- **`/todos`**
|
|
110
|
+
- **`/todos`** - print the current todo list grouped by status.
|
|
44
111
|
|
|
45
112
|
## Overlay
|
|
46
113
|
|
|
47
|
-
The aboveEditor widget auto-renders whenever any
|
|
48
|
-
|
|
49
|
-
|
|
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.
|
|
119
|
+
|
|
120
|
+
## Localization
|
|
121
|
+
|
|
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.
|
|
123
|
+
|
|
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.
|
|
50
125
|
|
|
51
126
|
## License
|
|
52
127
|
|
package/index.ts
CHANGED
|
@@ -1,21 +1,74 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* rpiv-todo — Pi extension
|
|
2
|
+
* rpiv-todo — Pi extension. Registers the `todo` tool, `/todos` slash
|
|
3
|
+
* command, and the persistent TodoOverlay widget.
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* TUI chrome strings localize at render time via the i18n bridge. Strings are
|
|
6
|
+
* registered with rpiv-i18n here, once, at module init — but only when the
|
|
7
|
+
* SDK is actually installed. If `@juicesharp/rpiv-i18n` is missing (standalone
|
|
8
|
+
* install of just this package), the dynamic-load shim no-ops and the bridge's
|
|
9
|
+
* `t(key, fallback)` returns the inline English literal at every call site.
|
|
10
|
+
* The extension stays online either way.
|
|
11
|
+
*
|
|
12
|
+
* Adding a locale: drop `locales/<code>.json` next to en.json (mirroring the
|
|
13
|
+
* key set), then add the load + entry to the `registerStrings` call below.
|
|
14
|
+
* See `@juicesharp/rpiv-i18n` README → "Contributing translations" for the
|
|
15
|
+
* full convention.
|
|
7
16
|
*
|
|
8
17
|
* Extracted from rpiv-pi@7525a5d. Tool name "todo" and widget key
|
|
9
18
|
* "rpiv-todos" preserved verbatim so existing session history replays
|
|
10
19
|
* correctly after upgrade.
|
|
11
20
|
*/
|
|
12
21
|
|
|
22
|
+
import { readFileSync } from "node:fs";
|
|
23
|
+
import { fileURLToPath } from "node:url";
|
|
13
24
|
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
25
|
+
import { I18N_NAMESPACE } from "./state/i18n-bridge.js";
|
|
14
26
|
import { replayFromBranch } from "./state/replay.js";
|
|
15
27
|
import { replaceState } from "./state/store.js";
|
|
16
28
|
import { registerTodosCommand, registerTodoTool, TOOL_NAME } from "./todo.js";
|
|
17
29
|
import { TodoOverlay } from "./todo-overlay.js";
|
|
18
30
|
|
|
31
|
+
type TranslationMap = Readonly<Record<string, string>>;
|
|
32
|
+
type I18nSDK = { registerStrings: (namespace: string, byLocale: Record<string, TranslationMap>) => void };
|
|
33
|
+
|
|
34
|
+
function loadLocale(code: string): TranslationMap {
|
|
35
|
+
// A missing or malformed locale file degrades gracefully: registerStrings
|
|
36
|
+
// records an empty map for the locale, so render-time `t(key, fallback)`
|
|
37
|
+
// returns the canonical English literal at the call site. Crashing here
|
|
38
|
+
// would take the entire todo extension offline at module init —
|
|
39
|
+
// publish-manifest miss would brick the extension.
|
|
40
|
+
try {
|
|
41
|
+
return JSON.parse(
|
|
42
|
+
readFileSync(fileURLToPath(new URL(`./locales/${code}.json`, import.meta.url)), "utf-8"),
|
|
43
|
+
) as TranslationMap;
|
|
44
|
+
} catch (err) {
|
|
45
|
+
console.warn(
|
|
46
|
+
`rpiv-todo: failed to load locales/${code}.json — falling back to English (${(err as Error).message})`,
|
|
47
|
+
);
|
|
48
|
+
return {};
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Dynamic import keeps `@juicesharp/rpiv-i18n` a soft optional peer: when the
|
|
53
|
+
// SDK is installed alongside this package the strings register and
|
|
54
|
+
// `/languages` flips them live; when it isn't, the import rejects here, we
|
|
55
|
+
// no-op, and the bridge's English-fallback shim keeps the extension online.
|
|
56
|
+
try {
|
|
57
|
+
const sdk = (await import("@juicesharp/rpiv-i18n")) as I18nSDK;
|
|
58
|
+
sdk.registerStrings(I18N_NAMESPACE, {
|
|
59
|
+
de: loadLocale("de"),
|
|
60
|
+
en: loadLocale("en"),
|
|
61
|
+
es: loadLocale("es"),
|
|
62
|
+
fr: loadLocale("fr"),
|
|
63
|
+
pt: loadLocale("pt"),
|
|
64
|
+
"pt-BR": loadLocale("pt-BR"),
|
|
65
|
+
ru: loadLocale("ru"),
|
|
66
|
+
uk: loadLocale("uk"),
|
|
67
|
+
});
|
|
68
|
+
} catch {
|
|
69
|
+
// SDK absent — extension still loads with English-only UI.
|
|
70
|
+
}
|
|
71
|
+
|
|
19
72
|
export default function (pi: ExtensionAPI) {
|
|
20
73
|
// Todo overlay widget — constructed lazily at the first session_start with UI.
|
|
21
74
|
let todoOverlay: TodoOverlay | undefined;
|
|
@@ -28,17 +81,20 @@ export default function (pi: ExtensionAPI) {
|
|
|
28
81
|
if (ctx.hasUI) {
|
|
29
82
|
todoOverlay ??= new TodoOverlay();
|
|
30
83
|
todoOverlay.setUICtx(ctx.ui);
|
|
84
|
+
todoOverlay.resetCompletedDisplayState();
|
|
31
85
|
todoOverlay.update();
|
|
32
86
|
}
|
|
33
87
|
});
|
|
34
88
|
|
|
35
89
|
pi.on("session_compact", async (_event, ctx) => {
|
|
36
90
|
replaceState(replayFromBranch(ctx));
|
|
91
|
+
todoOverlay?.resetCompletedDisplayState();
|
|
37
92
|
todoOverlay?.update();
|
|
38
93
|
});
|
|
39
94
|
|
|
40
95
|
pi.on("session_tree", async (_event, ctx) => {
|
|
41
96
|
replaceState(replayFromBranch(ctx));
|
|
97
|
+
todoOverlay?.resetCompletedDisplayState();
|
|
42
98
|
todoOverlay?.update();
|
|
43
99
|
});
|
|
44
100
|
|
|
@@ -53,4 +109,8 @@ export default function (pi: ExtensionAPI) {
|
|
|
53
109
|
if (event.toolName !== TOOL_NAME || event.isError) return;
|
|
54
110
|
todoOverlay?.update();
|
|
55
111
|
});
|
|
112
|
+
|
|
113
|
+
pi.on("agent_start", async () => {
|
|
114
|
+
todoOverlay?.hideCompletedTasksFromPreviousTurn();
|
|
115
|
+
});
|
|
56
116
|
}
|
package/locales/de.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_meta.notes": "Auto-translated draft. Native-speaker review welcome via PR. Unicode box-drawing characters (──) stay untranslated. Note: 'overlay.more' renders as '+5 weitere' which is grammatically loose for plural agreement — accepted for badge brevity.",
|
|
3
|
+
|
|
4
|
+
"status.pending": "ausstehend",
|
|
5
|
+
"status.in_progress": "in Bearbeitung",
|
|
6
|
+
"status.completed": "erledigt",
|
|
7
|
+
"status.deleted": "gelöscht",
|
|
8
|
+
|
|
9
|
+
"overlay.heading": "Todos",
|
|
10
|
+
"overlay.more": "weitere",
|
|
11
|
+
|
|
12
|
+
"command.no_todos": "Noch keine Todos. Bitte den Agenten, welche hinzuzufügen!",
|
|
13
|
+
"command.requires_interactive": "/todos erfordert den interaktiven Modus",
|
|
14
|
+
"command.section.pending": "── Ausstehend ──",
|
|
15
|
+
"command.section.in_progress": "── In Bearbeitung ──",
|
|
16
|
+
"command.section.completed": "── Erledigt ──"
|
|
17
|
+
}
|
package/locales/en.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"status.pending": "pending",
|
|
3
|
+
"status.in_progress": "in progress",
|
|
4
|
+
"status.completed": "completed",
|
|
5
|
+
"status.deleted": "deleted",
|
|
6
|
+
|
|
7
|
+
"overlay.heading": "Todos",
|
|
8
|
+
"overlay.more": "more",
|
|
9
|
+
|
|
10
|
+
"command.no_todos": "No todos yet. Ask the agent to add some!",
|
|
11
|
+
"command.requires_interactive": "/todos requires interactive mode",
|
|
12
|
+
"command.section.pending": "── Pending ──",
|
|
13
|
+
"command.section.in_progress": "── In Progress ──",
|
|
14
|
+
"command.section.completed": "── Completed ──"
|
|
15
|
+
}
|
package/locales/es.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_meta.notes": "Auto-translated draft. Native-speaker review welcome via PR. Unicode box-drawing characters (──) stay untranslated.",
|
|
3
|
+
|
|
4
|
+
"status.pending": "pendientes",
|
|
5
|
+
"status.in_progress": "en curso",
|
|
6
|
+
"status.completed": "completadas",
|
|
7
|
+
"status.deleted": "eliminada",
|
|
8
|
+
|
|
9
|
+
"overlay.heading": "Tareas",
|
|
10
|
+
"overlay.more": "más",
|
|
11
|
+
|
|
12
|
+
"command.no_todos": "Sin tareas aún. ¡Pídele al agente que añada algunas!",
|
|
13
|
+
"command.requires_interactive": "/todos requiere modo interactivo",
|
|
14
|
+
"command.section.pending": "── Pendientes ──",
|
|
15
|
+
"command.section.in_progress": "── En curso ──",
|
|
16
|
+
"command.section.completed": "── Completadas ──"
|
|
17
|
+
}
|
package/locales/fr.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_meta.notes": "Auto-translated draft. Native-speaker review welcome via PR. Unicode box-drawing characters (──) stay untranslated.",
|
|
3
|
+
|
|
4
|
+
"status.pending": "en attente",
|
|
5
|
+
"status.in_progress": "en cours",
|
|
6
|
+
"status.completed": "terminées",
|
|
7
|
+
"status.deleted": "supprimée",
|
|
8
|
+
|
|
9
|
+
"overlay.heading": "Tâches",
|
|
10
|
+
"overlay.more": "autres",
|
|
11
|
+
|
|
12
|
+
"command.no_todos": "Pas encore de tâches. Demandez à l'agent d'en ajouter !",
|
|
13
|
+
"command.requires_interactive": "/todos nécessite le mode interactif",
|
|
14
|
+
"command.section.pending": "── En attente ──",
|
|
15
|
+
"command.section.in_progress": "── En cours ──",
|
|
16
|
+
"command.section.completed": "── Terminées ──"
|
|
17
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_meta.notes": "Auto-translated draft. Native-speaker review welcome via PR. Unicode box-drawing characters (──) stay untranslated.",
|
|
3
|
+
|
|
4
|
+
"status.pending": "pendentes",
|
|
5
|
+
"status.in_progress": "em andamento",
|
|
6
|
+
"status.completed": "concluídas",
|
|
7
|
+
"status.deleted": "excluída",
|
|
8
|
+
|
|
9
|
+
"overlay.heading": "Tarefas",
|
|
10
|
+
"overlay.more": "mais",
|
|
11
|
+
|
|
12
|
+
"command.no_todos": "Nenhuma tarefa ainda. Peça ao agente para adicionar algumas!",
|
|
13
|
+
"command.requires_interactive": "/todos requer modo interativo",
|
|
14
|
+
"command.section.pending": "── Pendentes ──",
|
|
15
|
+
"command.section.in_progress": "── Em andamento ──",
|
|
16
|
+
"command.section.completed": "── Concluídas ──"
|
|
17
|
+
}
|
package/locales/pt.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_meta.notes": "Auto-translated draft. Native-speaker review welcome via PR. Unicode box-drawing characters (──) stay untranslated.",
|
|
3
|
+
|
|
4
|
+
"status.pending": "pendentes",
|
|
5
|
+
"status.in_progress": "em curso",
|
|
6
|
+
"status.completed": "concluídas",
|
|
7
|
+
"status.deleted": "eliminada",
|
|
8
|
+
|
|
9
|
+
"overlay.heading": "Tarefas",
|
|
10
|
+
"overlay.more": "mais",
|
|
11
|
+
|
|
12
|
+
"command.no_todos": "Sem tarefas ainda. Peça ao agente para adicionar algumas!",
|
|
13
|
+
"command.requires_interactive": "/todos requer modo interativo",
|
|
14
|
+
"command.section.pending": "── Pendentes ──",
|
|
15
|
+
"command.section.in_progress": "── Em curso ──",
|
|
16
|
+
"command.section.completed": "── Concluídas ──"
|
|
17
|
+
}
|
package/locales/ru.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_meta.notes": "Автоперевод. Приветствуется проверка носителем языка через PR. Символы юникода (──) не переводятся.",
|
|
3
|
+
|
|
4
|
+
"status.pending": "ожидание",
|
|
5
|
+
"status.in_progress": "в работе",
|
|
6
|
+
"status.completed": "выполнено",
|
|
7
|
+
"status.deleted": "удалена",
|
|
8
|
+
|
|
9
|
+
"overlay.heading": "Задачи",
|
|
10
|
+
"overlay.more": "ещё",
|
|
11
|
+
|
|
12
|
+
"command.no_todos": "Задач пока нет. Попросите агента добавить!",
|
|
13
|
+
"command.requires_interactive": "/todos требует интерактивного режима",
|
|
14
|
+
"command.section.pending": "── Ожидание ──",
|
|
15
|
+
"command.section.in_progress": "── В работе ──",
|
|
16
|
+
"command.section.completed": "── Выполнено ──"
|
|
17
|
+
}
|
package/locales/uk.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_meta.notes": "Автопереклад. Привітна перевірка носієм мови через PR. Символи юнікоду (──) не перекладаються.",
|
|
3
|
+
|
|
4
|
+
"status.pending": "очікування",
|
|
5
|
+
"status.in_progress": "у роботі",
|
|
6
|
+
"status.completed": "виконано",
|
|
7
|
+
"status.deleted": "видалено",
|
|
8
|
+
|
|
9
|
+
"overlay.heading": "Завдання",
|
|
10
|
+
"overlay.more": "ще",
|
|
11
|
+
|
|
12
|
+
"command.no_todos": "Завдань поки немає. Попросіть агента додати!",
|
|
13
|
+
"command.requires_interactive": "/todos потребує інтерактивного режиму",
|
|
14
|
+
"command.section.pending": "── Очікування ──",
|
|
15
|
+
"command.section.in_progress": "── У роботі ──",
|
|
16
|
+
"command.section.completed": "── Виконано ──"
|
|
17
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juicesharp/rpiv-todo",
|
|
3
|
-
"version": "1.1.
|
|
4
|
-
"description": "Pi extension
|
|
3
|
+
"version": "1.1.5",
|
|
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",
|
|
@@ -28,11 +28,13 @@
|
|
|
28
28
|
},
|
|
29
29
|
"files": [
|
|
30
30
|
"index.ts",
|
|
31
|
+
"locales/",
|
|
31
32
|
"todo.ts",
|
|
32
33
|
"todo-overlay.ts",
|
|
33
34
|
"LICENSE",
|
|
34
35
|
"README.md",
|
|
35
36
|
"state/invariants.ts",
|
|
37
|
+
"state/i18n-bridge.ts",
|
|
36
38
|
"state/replay.ts",
|
|
37
39
|
"state/selectors.ts",
|
|
38
40
|
"state/state-reducer.ts",
|
|
@@ -49,9 +51,15 @@
|
|
|
49
51
|
]
|
|
50
52
|
},
|
|
51
53
|
"peerDependencies": {
|
|
54
|
+
"@juicesharp/rpiv-i18n": "*",
|
|
52
55
|
"@mariozechner/pi-ai": "*",
|
|
53
56
|
"@mariozechner/pi-coding-agent": "*",
|
|
54
57
|
"@mariozechner/pi-tui": "*",
|
|
55
58
|
"typebox": "*"
|
|
59
|
+
},
|
|
60
|
+
"peerDependenciesMeta": {
|
|
61
|
+
"@juicesharp/rpiv-i18n": {
|
|
62
|
+
"optional": true
|
|
63
|
+
}
|
|
56
64
|
}
|
|
57
65
|
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* i18n bridge for rpiv-todo — single thin import surface so every call site
|
|
3
|
+
* routes through one module. Backed by `@juicesharp/rpiv-i18n`'s SDK when
|
|
4
|
+
* available; degrades to canonical-English fallbacks when not.
|
|
5
|
+
*
|
|
6
|
+
* - `t(key, fallback)` is `scope("@juicesharp/rpiv-todo")` if the SDK is
|
|
7
|
+
* installed (live `/languages` updates propagate). If the SDK is missing
|
|
8
|
+
* (standalone install without rpiv-i18n), `t` is an identity passthrough
|
|
9
|
+
* that returns the inline English fallback at every call site, so the
|
|
10
|
+
* extension stays online with English UI.
|
|
11
|
+
* - `formatStatusLabel(status)` resolves a TaskStatus to its locale-aware
|
|
12
|
+
* label via the canonical `status.*` namespace, with the English literal
|
|
13
|
+
* as fallback so nothing renders blank if the namespace isn't registered.
|
|
14
|
+
* This is the SINGLE point of localization for status words — overlay,
|
|
15
|
+
* /todos header, /todos render-call all route through here.
|
|
16
|
+
*
|
|
17
|
+
* Strings are registered ONCE at extension load (see ../index.ts). Call sites
|
|
18
|
+
* MUST use this module at render time — never bake the result into a top-level
|
|
19
|
+
* `const X = formatStatusLabel(...)`.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import type { TaskStatus } from "../tool/types.js";
|
|
23
|
+
|
|
24
|
+
export const I18N_NAMESPACE = "@juicesharp/rpiv-todo";
|
|
25
|
+
|
|
26
|
+
type ScopeFn = (key: string, fallback: string) => string;
|
|
27
|
+
type I18nSDK = { scope: (namespace: string) => ScopeFn };
|
|
28
|
+
|
|
29
|
+
// Prefer the live SDK if installed: closures it returns track the active
|
|
30
|
+
// locale, so /languages picker propagates to our render call sites. If the
|
|
31
|
+
// SDK isn't installed (standalone install of this extension without
|
|
32
|
+
// rpiv-i18n), the dynamic import fails, every t(key, fallback) returns the
|
|
33
|
+
// canonical English literal, and the extension stays online.
|
|
34
|
+
//
|
|
35
|
+
// Top-level await is required so a synchronous `t(...)` call from any
|
|
36
|
+
// downstream module sees the resolved scope; ESM module loading awaits this
|
|
37
|
+
// before evaluating any importer.
|
|
38
|
+
let scopeImpl: ScopeFn;
|
|
39
|
+
try {
|
|
40
|
+
const sdk = (await import("@juicesharp/rpiv-i18n")) as I18nSDK;
|
|
41
|
+
scopeImpl = sdk.scope(I18N_NAMESPACE);
|
|
42
|
+
} catch {
|
|
43
|
+
scopeImpl = (_key, fallback) => fallback;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const t: ScopeFn = scopeImpl;
|
|
47
|
+
|
|
48
|
+
const STATUS_LABEL_PENDING = "pending";
|
|
49
|
+
const STATUS_LABEL_IN_PROGRESS = "in progress";
|
|
50
|
+
const STATUS_LABEL_COMPLETED = "completed";
|
|
51
|
+
const STATUS_LABEL_DELETED = "deleted";
|
|
52
|
+
|
|
53
|
+
export function formatStatusLabel(status: TaskStatus): string {
|
|
54
|
+
switch (status) {
|
|
55
|
+
case "pending":
|
|
56
|
+
return t("status.pending", STATUS_LABEL_PENDING);
|
|
57
|
+
case "in_progress":
|
|
58
|
+
return t("status.in_progress", STATUS_LABEL_IN_PROGRESS);
|
|
59
|
+
case "completed":
|
|
60
|
+
return t("status.completed", STATUS_LABEL_COMPLETED);
|
|
61
|
+
case "deleted":
|
|
62
|
+
return t("status.deleted", STATUS_LABEL_DELETED);
|
|
63
|
+
}
|
|
64
|
+
}
|
package/todo-overlay.ts
CHANGED
|
@@ -5,29 +5,31 @@
|
|
|
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 `
|
|
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
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
selectShowTaskIds,
|
|
18
|
-
selectTodoCounts,
|
|
19
|
-
selectVisibleTasks,
|
|
20
|
-
} from "./state/selectors.js";
|
|
21
|
-
import { getTodos } from "./state/store.js";
|
|
14
|
+
import { formatStatusLabel, t } from "./state/i18n-bridge.js";
|
|
15
|
+
import { selectHasActive, selectOverlayLayout, selectShowTaskIds, selectTodoCounts } from "./state/selectors.js";
|
|
16
|
+
import { getState } from "./state/store.js";
|
|
22
17
|
import { formatOverlayTaskLine } from "./view/format.js";
|
|
23
18
|
|
|
24
19
|
const WIDGET_KEY = "rpiv-todos";
|
|
25
20
|
const MAX_WIDGET_LINES = 12;
|
|
26
21
|
|
|
22
|
+
// English fallbacks for localized overlay chrome strings.
|
|
23
|
+
const OVERLAY_HEADING = "Todos";
|
|
24
|
+
const OVERLAY_MORE = "more";
|
|
25
|
+
|
|
27
26
|
export class TodoOverlay {
|
|
28
27
|
private uiCtx: ExtensionUIContext | undefined;
|
|
29
28
|
private widgetRegistered = false;
|
|
30
29
|
private tui: TUI | undefined;
|
|
30
|
+
private completedTaskIdsPendingHide = new Set<number>();
|
|
31
|
+
private hiddenCompletedTaskIds = new Set<number>();
|
|
32
|
+
private lastNextId: number | undefined;
|
|
31
33
|
|
|
32
34
|
setUICtx(ctx: ExtensionUIContext): void {
|
|
33
35
|
// Identity-compare so repeat session_start handlers are idempotent;
|
|
@@ -41,8 +43,8 @@ export class TodoOverlay {
|
|
|
41
43
|
|
|
42
44
|
update(): void {
|
|
43
45
|
if (!this.uiCtx) return;
|
|
44
|
-
const snapshot =
|
|
45
|
-
const visible =
|
|
46
|
+
const snapshot = this.getSnapshot();
|
|
47
|
+
const visible = this.selectOverlayTasks(snapshot);
|
|
46
48
|
|
|
47
49
|
if (visible.length === 0) {
|
|
48
50
|
if (this.widgetRegistered) {
|
|
@@ -74,25 +76,79 @@ export class TodoOverlay {
|
|
|
74
76
|
}
|
|
75
77
|
}
|
|
76
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
|
+
|
|
77
120
|
private renderWidget(theme: Theme, width: number): string[] {
|
|
78
|
-
const snapshot =
|
|
79
|
-
const
|
|
80
|
-
if (
|
|
121
|
+
const snapshot = this.getSnapshot();
|
|
122
|
+
const overlayTasks = this.selectOverlayTasks(snapshot);
|
|
123
|
+
if (overlayTasks.length === 0) return [];
|
|
81
124
|
|
|
125
|
+
const overlayState = { tasks: overlayTasks, nextId: snapshot.nextId };
|
|
82
126
|
const truncate = (line: string): string => truncateToWidth(line, width, "…");
|
|
83
|
-
const counts = selectTodoCounts(
|
|
84
|
-
const hasActive = selectHasActive(
|
|
85
|
-
const showIds = selectShowTaskIds(
|
|
127
|
+
const counts = selectTodoCounts(overlayState);
|
|
128
|
+
const hasActive = selectHasActive(overlayState);
|
|
129
|
+
const showIds = selectShowTaskIds(overlayState);
|
|
86
130
|
|
|
87
131
|
const headingColor = hasActive ? "accent" : "dim";
|
|
88
132
|
const headingIcon = hasActive ? "●" : "○";
|
|
89
|
-
const headingText =
|
|
133
|
+
const headingText = `${t("overlay.heading", OVERLAY_HEADING)} (${counts.completed}/${counts.total})`;
|
|
90
134
|
const heading = truncate(`${theme.fg(headingColor, headingIcon)} ${theme.fg(headingColor, headingText)}`);
|
|
91
135
|
|
|
92
136
|
const lines: string[] = [heading];
|
|
93
|
-
const layout = selectOverlayLayout(
|
|
94
|
-
for (const
|
|
95
|
-
lines.push(truncate(`${theme.fg("dim", "├─")} ${formatOverlayTaskLine(
|
|
137
|
+
const layout = selectOverlayLayout(overlayState, MAX_WIDGET_LINES - 1);
|
|
138
|
+
for (const task of layout.visible) {
|
|
139
|
+
lines.push(truncate(`${theme.fg("dim", "├─")} ${formatOverlayTaskLine(task, theme, showIds)}`));
|
|
140
|
+
}
|
|
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);
|
|
96
152
|
}
|
|
97
153
|
|
|
98
154
|
if (layout.hiddenCompleted === 0 && layout.truncatedTail === 0) {
|
|
@@ -103,10 +159,11 @@ export class TodoOverlay {
|
|
|
103
159
|
|
|
104
160
|
const totalHidden = layout.hiddenCompleted + layout.truncatedTail;
|
|
105
161
|
const overflowParts: string[] = [];
|
|
106
|
-
if (layout.hiddenCompleted > 0) overflowParts.push(`${layout.hiddenCompleted} completed`);
|
|
107
|
-
if (layout.truncatedTail > 0) overflowParts.push(`${layout.truncatedTail} pending`);
|
|
162
|
+
if (layout.hiddenCompleted > 0) overflowParts.push(`${layout.hiddenCompleted} ${formatStatusLabel("completed")}`);
|
|
163
|
+
if (layout.truncatedTail > 0) overflowParts.push(`${layout.truncatedTail} ${formatStatusLabel("pending")}`);
|
|
164
|
+
const more = t("overlay.more", OVERLAY_MORE);
|
|
108
165
|
const summary =
|
|
109
|
-
overflowParts.length > 0 ? `+${totalHidden} more (${overflowParts.join(", ")})` : `+${totalHidden} more`;
|
|
166
|
+
overflowParts.length > 0 ? `+${totalHidden} ${more} (${overflowParts.join(", ")})` : `+${totalHidden} ${more}`;
|
|
110
167
|
lines.push(truncate(`${theme.fg("dim", "└─")} ${theme.fg("dim", summary)}`));
|
|
111
168
|
return lines;
|
|
112
169
|
}
|
|
@@ -116,5 +173,6 @@ export class TodoOverlay {
|
|
|
116
173
|
this.widgetRegistered = false;
|
|
117
174
|
this.tui = undefined;
|
|
118
175
|
this.uiCtx = undefined;
|
|
176
|
+
this.resetCompletedDisplayState();
|
|
119
177
|
}
|
|
120
178
|
}
|
package/todo.ts
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
16
|
+
import { formatStatusLabel, t } from "./state/i18n-bridge.js";
|
|
16
17
|
import { replayFromBranch } from "./state/replay.js";
|
|
17
18
|
import { selectTasksByStatus, selectTodoCounts, selectVisibleTasks } from "./state/selectors.js";
|
|
18
19
|
import { applyTaskMutation } from "./state/state-reducer.js";
|
|
@@ -27,7 +28,13 @@ import {
|
|
|
27
28
|
TOOL_NAME,
|
|
28
29
|
TodoParamsSchema,
|
|
29
30
|
} from "./tool/types.js";
|
|
30
|
-
import { formatCommandTaskLine,
|
|
31
|
+
import { formatCommandTaskLine, renderTodoCall, renderTodoResult } from "./view/format.js";
|
|
32
|
+
|
|
33
|
+
// English fallbacks for localized /todos section headers — the box-drawing
|
|
34
|
+
// decoration is part of the localized string so translators can adjust spacing.
|
|
35
|
+
const SECTION_PENDING = "── Pending ──";
|
|
36
|
+
const SECTION_IN_PROGRESS = "── In Progress ──";
|
|
37
|
+
const SECTION_COMPLETED = "── Completed ──";
|
|
31
38
|
|
|
32
39
|
// ---------------------------------------------------------------------------
|
|
33
40
|
// Public re-exports — pre-refactor consumers (overlay, tests, index.ts) keep
|
|
@@ -60,7 +67,7 @@ export function registerTodoTool(pi: ExtensionAPI): void {
|
|
|
60
67
|
label: TOOL_LABEL,
|
|
61
68
|
description:
|
|
62
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.",
|
|
63
|
-
promptSnippet: "Manage a
|
|
70
|
+
promptSnippet: "Manage a task list to track multi-step progress",
|
|
64
71
|
promptGuidelines: [
|
|
65
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.",
|
|
66
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.",
|
|
@@ -97,35 +104,35 @@ export function registerTodosCommand(pi: ExtensionAPI): void {
|
|
|
97
104
|
description: "Show all todos on the current branch, grouped by status",
|
|
98
105
|
handler: async (_args, ctx) => {
|
|
99
106
|
if (!ctx.hasUI) {
|
|
100
|
-
ctx.ui.notify(ERR_REQUIRES_INTERACTIVE, "error");
|
|
107
|
+
ctx.ui.notify(t("command.requires_interactive", ERR_REQUIRES_INTERACTIVE), "error");
|
|
101
108
|
return;
|
|
102
109
|
}
|
|
103
110
|
const state = getState();
|
|
104
111
|
const visible = selectVisibleTasks(state);
|
|
105
112
|
if (visible.length === 0) {
|
|
106
|
-
ctx.ui.notify(MSG_NO_TODOS, "info");
|
|
113
|
+
ctx.ui.notify(t("command.no_todos", MSG_NO_TODOS), "info");
|
|
107
114
|
return;
|
|
108
115
|
}
|
|
109
116
|
const groups = selectTasksByStatus(state);
|
|
110
117
|
const counts = selectTodoCounts(state);
|
|
111
118
|
|
|
112
119
|
const header: string[] = [];
|
|
113
|
-
if (counts.completed > 0) header.push(`${counts.completed}/${counts.total} completed`);
|
|
120
|
+
if (counts.completed > 0) header.push(`${counts.completed}/${counts.total} ${formatStatusLabel("completed")}`);
|
|
114
121
|
if (counts.inProgress > 0) header.push(`${counts.inProgress} ${formatStatusLabel("in_progress")}`);
|
|
115
|
-
if (counts.pending > 0) header.push(`${counts.pending} pending`);
|
|
122
|
+
if (counts.pending > 0) header.push(`${counts.pending} ${formatStatusLabel("pending")}`);
|
|
116
123
|
|
|
117
124
|
const lines: string[] = [header.join(" · ")];
|
|
118
125
|
if (groups.pending.length > 0) {
|
|
119
|
-
lines.push("
|
|
120
|
-
for (const
|
|
126
|
+
lines.push(t("command.section.pending", SECTION_PENDING));
|
|
127
|
+
for (const task of groups.pending) lines.push(formatCommandTaskLine(task, "○"));
|
|
121
128
|
}
|
|
122
129
|
if (groups.inProgress.length > 0) {
|
|
123
|
-
lines.push("
|
|
124
|
-
for (const
|
|
130
|
+
lines.push(t("command.section.in_progress", SECTION_IN_PROGRESS));
|
|
131
|
+
for (const task of groups.inProgress) lines.push(formatCommandTaskLine(task, "◐"));
|
|
125
132
|
}
|
|
126
133
|
if (groups.completed.length > 0) {
|
|
127
|
-
lines.push("
|
|
128
|
-
for (const
|
|
134
|
+
lines.push(t("command.section.completed", SECTION_COMPLETED));
|
|
135
|
+
for (const task of groups.completed) lines.push(formatCommandTaskLine(task, "✓"));
|
|
129
136
|
}
|
|
130
137
|
|
|
131
138
|
ctx.ui.notify(lines.join("\n"), "info");
|
package/view/format.ts
CHANGED
|
@@ -1,24 +1,18 @@
|
|
|
1
1
|
import type { Theme } from "@mariozechner/pi-coding-agent";
|
|
2
2
|
import { Text } from "@mariozechner/pi-tui";
|
|
3
|
+
import { formatStatusLabel } from "../state/i18n-bridge.js";
|
|
3
4
|
import { selectTaskSubjectById } from "../state/selectors.js";
|
|
4
5
|
import type { TaskState } from "../state/state.js";
|
|
5
6
|
import type { Task, TaskAction, TaskDetails, TaskMutationParams, TaskStatus } from "../tool/types.js";
|
|
6
7
|
|
|
8
|
+
// Re-export so legacy import paths (todo.ts, tests) continue to resolve;
|
|
9
|
+
// the canonical definition lives in the i18n bridge.
|
|
10
|
+
export { formatStatusLabel };
|
|
11
|
+
|
|
7
12
|
// ---------------------------------------------------------------------------
|
|
8
|
-
// Status presentation tables — the single source of truth for
|
|
13
|
+
// Status presentation tables — the single source of truth for glyph/color.
|
|
9
14
|
// ---------------------------------------------------------------------------
|
|
10
15
|
|
|
11
|
-
export function formatStatusLabel(status: TaskStatus): string {
|
|
12
|
-
switch (status) {
|
|
13
|
-
case "in_progress":
|
|
14
|
-
return "in progress";
|
|
15
|
-
case "deleted":
|
|
16
|
-
return "deleted";
|
|
17
|
-
default:
|
|
18
|
-
return status;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
16
|
export const STATUS_GLYPH: Record<TaskStatus, string> = {
|
|
23
17
|
pending: "○",
|
|
24
18
|
in_progress: "◐",
|