@juicesharp/rpiv-todo 1.1.3 → 1.1.4
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 +16 -0
- package/index.ts +57 -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 +9 -1
- package/state/i18n-bridge.ts +64 -0
- package/todo-overlay.ts +12 -6
- package/todo.ts +18 -11
- package/view/format.ts +6 -12
package/README.md
CHANGED
|
@@ -31,6 +31,16 @@ 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
46
|
- **`todo`** — create / update / list / get / delete / clear tasks. 4-state
|
|
@@ -48,6 +58,12 @@ The aboveEditor widget auto-renders whenever any non-deleted tasks exist.
|
|
|
48
58
|
12-line collapse threshold; completed tasks drop first on overflow, pending
|
|
49
59
|
tasks truncate last. Auto-hides when the list is empty.
|
|
50
60
|
|
|
61
|
+
## Localization
|
|
62
|
+
|
|
63
|
+
`rpiv-todo` localizes its TUI chrome (overlay heading, `/todos` section headers, status words) through `@juicesharp/rpiv-i18n` when the SDK is installed. Bundled locales: `de`, `en`, `es`, `fr`, `pt`, `pt-BR`, `ru`, `uk`. LLM-facing output (tool response envelope, reducer errors, schema descriptions) stays English by design.
|
|
64
|
+
|
|
65
|
+
The SDK is a soft optional peer — `rpiv-todo` loads it via dynamic import at module init. If the SDK isn't installed, every render call site returns its inline English fallback and the extension stays online with English UI; no warning, no crash. See the Install section for adding the SDK after the fact. To contribute or override translations, see the `@juicesharp/rpiv-i18n` README "Contributing translations" section.
|
|
66
|
+
|
|
51
67
|
## License
|
|
52
68
|
|
|
53
69
|
MIT
|
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;
|
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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juicesharp/rpiv-todo",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4",
|
|
4
4
|
"description": "Pi extension: gives the model a todo list with a live overlay that survives /reload and compaction",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|
|
@@ -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
|
@@ -11,6 +11,7 @@
|
|
|
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 { formatStatusLabel, t } from "./state/i18n-bridge.js";
|
|
14
15
|
import {
|
|
15
16
|
selectHasActive,
|
|
16
17
|
selectOverlayLayout,
|
|
@@ -24,6 +25,10 @@ import { formatOverlayTaskLine } from "./view/format.js";
|
|
|
24
25
|
const WIDGET_KEY = "rpiv-todos";
|
|
25
26
|
const MAX_WIDGET_LINES = 12;
|
|
26
27
|
|
|
28
|
+
// English fallbacks for localized overlay chrome strings.
|
|
29
|
+
const OVERLAY_HEADING = "Todos";
|
|
30
|
+
const OVERLAY_MORE = "more";
|
|
31
|
+
|
|
27
32
|
export class TodoOverlay {
|
|
28
33
|
private uiCtx: ExtensionUIContext | undefined;
|
|
29
34
|
private widgetRegistered = false;
|
|
@@ -86,13 +91,13 @@ export class TodoOverlay {
|
|
|
86
91
|
|
|
87
92
|
const headingColor = hasActive ? "accent" : "dim";
|
|
88
93
|
const headingIcon = hasActive ? "●" : "○";
|
|
89
|
-
const headingText =
|
|
94
|
+
const headingText = `${t("overlay.heading", OVERLAY_HEADING)} (${counts.completed}/${counts.total})`;
|
|
90
95
|
const heading = truncate(`${theme.fg(headingColor, headingIcon)} ${theme.fg(headingColor, headingText)}`);
|
|
91
96
|
|
|
92
97
|
const lines: string[] = [heading];
|
|
93
98
|
const layout = selectOverlayLayout(snapshot, MAX_WIDGET_LINES - 1);
|
|
94
|
-
for (const
|
|
95
|
-
lines.push(truncate(`${theme.fg("dim", "├─")} ${formatOverlayTaskLine(
|
|
99
|
+
for (const task of layout.visible) {
|
|
100
|
+
lines.push(truncate(`${theme.fg("dim", "├─")} ${formatOverlayTaskLine(task, theme, showIds)}`));
|
|
96
101
|
}
|
|
97
102
|
|
|
98
103
|
if (layout.hiddenCompleted === 0 && layout.truncatedTail === 0) {
|
|
@@ -103,10 +108,11 @@ export class TodoOverlay {
|
|
|
103
108
|
|
|
104
109
|
const totalHidden = layout.hiddenCompleted + layout.truncatedTail;
|
|
105
110
|
const overflowParts: string[] = [];
|
|
106
|
-
if (layout.hiddenCompleted > 0) overflowParts.push(`${layout.hiddenCompleted} completed`);
|
|
107
|
-
if (layout.truncatedTail > 0) overflowParts.push(`${layout.truncatedTail} pending`);
|
|
111
|
+
if (layout.hiddenCompleted > 0) overflowParts.push(`${layout.hiddenCompleted} ${formatStatusLabel("completed")}`);
|
|
112
|
+
if (layout.truncatedTail > 0) overflowParts.push(`${layout.truncatedTail} ${formatStatusLabel("pending")}`);
|
|
113
|
+
const more = t("overlay.more", OVERLAY_MORE);
|
|
108
114
|
const summary =
|
|
109
|
-
overflowParts.length > 0 ? `+${totalHidden} more (${overflowParts.join(", ")})` : `+${totalHidden} more`;
|
|
115
|
+
overflowParts.length > 0 ? `+${totalHidden} ${more} (${overflowParts.join(", ")})` : `+${totalHidden} ${more}`;
|
|
110
116
|
lines.push(truncate(`${theme.fg("dim", "└─")} ${theme.fg("dim", summary)}`));
|
|
111
117
|
return lines;
|
|
112
118
|
}
|
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
|
|
@@ -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: "◐",
|