@mblarsen/pi-task-ui 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Michael Bøcker-Larsen
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,133 @@
1
+ # task-ui
2
+
3
+ A backend-neutral task sidebar for Pi.
4
+
5
+ ![Task sidebar showing executing and completed work](assets/task-ui.png)
6
+
7
+ `task-ui` is deliberately presentation-only:
8
+
9
+ - no planning mode
10
+ - no task execution or worker spawning
11
+ - no automatic backend calls
12
+ - no process control
13
+ - no injected system prompts
14
+
15
+ The agent coordinates a real backend—such as `ctx_task`—and mirrors its state into the UI.
16
+
17
+ ## Install
18
+
19
+ ```bash
20
+ pi install npm:@mblarsen/pi-task-ui
21
+ ```
22
+
23
+ ## UI
24
+
25
+ The sidebar opens automatically as a non-capturing overlay on the right. Toggle it with `Alt+U` or:
26
+
27
+ ```text
28
+ /task-ui
29
+ ```
30
+
31
+ The bar hides responsively below 72 terminal columns. Its `Tasks` panel shows numbered work, nested subtasks, blockers, terminal history, optional right-aligned labels, and projected execution telemetry without a summary or progress bar. Subtasks use stable hierarchical labels such as `#2.1` and `#2.1.1` and render immediately beneath their parent in subtask order. Active and pending work share one stable list capped at the first seven items, so the earliest work retains priority; overflow is summarized as `… and N more`. `history` shows the latest three terminal transitions newest-first and does not reorder them after metadata or output edits. When only history remains, a muted `All done!` message appears above it.
32
+
33
+ | Icon | Meaning |
34
+ |---|---|
35
+ | `✔` | Completed; dimmed and struck through |
36
+ | `◼` | In progress but not currently executing |
37
+ | `◻` | Pending |
38
+ | `✳` / `✽` | Executing; animated with active-form text, elapsed time, and token counts |
39
+ | `✖` | Failed and retained in history |
40
+ | `■` | Stopped and retained in history |
41
+
42
+ `executing` is transient presentation metadata layered over `in_progress`, so several tasks may execute concurrently.
43
+
44
+ Tasks may carry one short `label`, such as `grilling` or `research`. Labels render in brackets at the right edge while the task title truncates first. Label colors are selected deterministically from the active theme: the same label is always the same color, while different labels spread across the available palette.
45
+
46
+ Parents are independently executable. Their status and progress are not derived from subtasks, and terminal parent transitions never modify child state. Hierarchy (`parent_id`) and execution dependencies (`blocked_by`) are separate concepts.
47
+
48
+ ## Presentation tools
49
+
50
+ | Tool | UI-only behavior |
51
+ |---|---|
52
+ | `task_ui_create` | Add or mirror one numbered root task or subtask, optionally with a label |
53
+ | `task_ui_batch_create` | Atomically add or mirror several tasks, including nested hierarchies |
54
+ | `task_ui_list` | List projected tasks, optionally filtered by status |
55
+ | `task_ui_get` | Read one task; without `task_id`, return active, next, and focused tasks |
56
+ | `task_ui_update` | Update the label, status, blockers, focus-driving state, progress, and execution telemetry |
57
+ | `task_ui_output` | Append, read, or clear projected output |
58
+ | `task_ui_remove` | Remove one projected task and detach its children as root tasks |
59
+ | `task_ui_clear` | Clear the entire projection |
60
+ | `task_ui_stop` | Move a task to stopped history, stop its spinner, and advance focus |
61
+
62
+ `task_ui_remove`, `task_ui_clear`, and `task_ui_stop` do not modify backend work. The agent must perform matching backend actions separately when needed.
63
+
64
+ The bundled `task-ui` Agent Skill teaches the agent when to create task sets, mirror backend transitions, maintain execution telemetry, and avoid fabricating state. Invoke it explicitly with `/skill:task-ui` or let Pi load it when the request matches its description.
65
+
66
+ ### Execution telemetry
67
+
68
+ Create and update operations accept:
69
+
70
+ - `label`: short category or workflow text rendered right-aligned; pass it without brackets
71
+ - `parent_id`: nests a task under an independently executable parent
72
+ - `executing`: enables the animated execution state
73
+ - `active_form`: present-progress text such as `Acquiring plutonium…`
74
+ - `started_at`: ISO timestamp used for elapsed time
75
+ - `input_tokens` and `output_tokens`: projected token counts
76
+ - `blocked_by`: task IDs displayed as numbered dependencies
77
+
78
+ ### Coordinating with `ctx_task`
79
+
80
+ A typical flow is:
81
+
82
+ 1. Call `ctx_task { action: "create", ... }`.
83
+ 2. Call `task_ui_create` with the returned backend task ID.
84
+ 3. Use `ctx_task` for backend state transitions or messages.
85
+ 4. Mirror those transitions with `task_ui_update` or `task_ui_output`.
86
+ 5. To stop real work, cancel it through the backend first, then call `task_ui_stop`.
87
+
88
+ No coupling to `ctx_task` is built into this extension.
89
+
90
+ ## Backend adapter events
91
+
92
+ Other Pi extensions can update the projection through `pi.events`:
93
+
94
+ ```ts
95
+ pi.events.emit("task-ui:snapshot", {
96
+ tasks: [
97
+ { id: "worker-1", subject: "Review API", label: "research", status: "running" },
98
+ {
99
+ id: "worker-2",
100
+ subject: "Run tests",
101
+ status: "running",
102
+ executing: true,
103
+ activeForm: "Running regression suite…",
104
+ startedAt: new Date().toISOString(),
105
+ inputTokens: 4100,
106
+ outputTokens: 1200,
107
+ parentId: "worker-1",
108
+ blockedBy: ["worker-1"],
109
+ },
110
+ ],
111
+ focusedTaskId: "worker-2",
112
+ });
113
+
114
+ pi.events.emit("task-ui:upsert", {
115
+ id: "worker-2",
116
+ label: "verification",
117
+ status: "completed",
118
+ executing: false,
119
+ progress: 100,
120
+ });
121
+
122
+ pi.events.emit("task-ui:output", {
123
+ taskId: "worker-2",
124
+ text: "Regression suite passed",
125
+ });
126
+
127
+ pi.events.emit("task-ui:focus", { taskId: "worker-2" });
128
+ pi.events.emit("task-ui:remove", { taskId: "worker-2" });
129
+ ```
130
+
131
+ Accepted external status aliases include `running`, `working`, `done`, `success`, `error`, `cancelled`, and `queued`.
132
+
133
+ Projection snapshots are stored as TUI-only session entries, so state follows Pi session branches without entering model context. A completely new Pi session begins with an empty projection; the bundled Agent Skill instructs the agent to read any persistent task backend and reconcile confirmed tasks by backend ID when resuming backend-managed work.
Binary file