Harden task state and terminal rendering

This commit is contained in:
jb
2026-08-26 15:13:19 -04:00
parent 6826854b66
commit ae0ca47236
10 changed files with 452 additions and 48 deletions
+6 -1
View File
@@ -11,6 +11,7 @@ Hierarchical, session-local task tracking for [Pi](https://pi.dev), with atomic
- Five focused tools: `set_tasks`, `update_task`, `rm_task`, `list_task`, and `get_task`
- Parent/child task trees with generated integer IDs and atomic append/replace modes
- Atomic batch mutations: every requested change succeeds or none of it is applied
- Bounded task input and widget output to keep sessions and terminals responsive
- Four states: `pending`, `in-progress`, `blocked`, and `done`
- Cumulative active-time tracking that pauses outside `in-progress` and survives session restore
- Session-branch persistence across reload, resume, fork, tree navigation, and context compaction
@@ -89,13 +90,15 @@ Example append call:
Task input keys are explicit so strict tool-schema bridges do not invent values for omitted properties. Use `description: null` when no detail is needed, `status: "pending"` for the default state, `parentId: null` for root tasks and nested children, and `children: []` for leaves. `prepareArguments` still expands legacy calls that omit these fields.
To keep model-generated input safe and bounded, a session may contain up to 200 tasks. One mutation may affect up to 50 explicitly supplied tasks, hierarchy depth is limited to eight levels, names to 200 Unicode characters, and descriptions to 4,000 Unicode characters. Names and descriptions reject terminal controls and bidirectional override characters; descriptions may still contain line feeds for normal multi-line detail.
IDs are not reused by append/remove operations; `replace` deliberately rebuilds IDs from `1`. Replace forbids non-null `parentId`, so new hierarchy must use nested `children`. Multiple tasks may be `in-progress`. A parent can be marked `done` only when all descendants are also `done`.
A task starts timing the first time it enters `in-progress`. Leaving that state records a stop and pauses the timer; entering it again resumes with a new active segment while preserving the cumulative duration. Repeated updates with the same status, as well as name, description, hierarchy, and position changes, do not reset timing. For started tasks, `get_task` includes the first `startedAt` timestamp, a `stoppedAt` timestamp while paused, and cumulative `durationMs`. Timestamps use ISO 8601.
## Pi Widget
The widget appears above Pi's editor while tasks exist. Run `/tasks` to hide or show it for the current Pi runtime.
The widget appears above Pi's editor while tasks exist. Run `/tasks` to hide or show it for the current Pi runtime. It shows at most 12 task rows plus a compact count of hidden tasks, so larger plans do not crowd the editor out of an 80×24 terminal.
```text
Tasks 2/6 · !1 ━━━━━────────
@@ -128,6 +131,8 @@ Metadata failures never block task operations. The extension does not change Her
## Development
Development tests use Node's built-in TypeScript type stripping and require Node.js 22.18 or newer. The extension itself retains its Node.js 20 runtime requirement because Pi loads TypeScript extensions through its own loader.
```bash
npm install
npm run typecheck