@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 +21 -0
- package/README.md +133 -0
- package/assets/task-ui.png +0 -0
- package/core.ts +586 -0
- package/index.ts +726 -0
- package/package.json +41 -0
- package/skill/SKILL.md +157 -0
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mblarsen/pi-task-ui",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Backend-neutral task sidebar and agent tools for Pi.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"pi-package",
|
|
9
|
+
"pi-extension"
|
|
10
|
+
],
|
|
11
|
+
"files": [
|
|
12
|
+
"index.ts",
|
|
13
|
+
"core.ts",
|
|
14
|
+
"README.md",
|
|
15
|
+
"assets",
|
|
16
|
+
"skill"
|
|
17
|
+
],
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/mblarsen/pi-extensions.git",
|
|
21
|
+
"directory": "packages/task-ui"
|
|
22
|
+
},
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public"
|
|
25
|
+
},
|
|
26
|
+
"pi": {
|
|
27
|
+
"extensions": [
|
|
28
|
+
"./index.ts"
|
|
29
|
+
],
|
|
30
|
+
"skills": [
|
|
31
|
+
"./skill/SKILL.md"
|
|
32
|
+
]
|
|
33
|
+
},
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"@earendil-works/pi-ai": "*",
|
|
36
|
+
"@earendil-works/pi-coding-agent": "*",
|
|
37
|
+
"@earendil-works/pi-tui": "*",
|
|
38
|
+
"typebox": "*"
|
|
39
|
+
},
|
|
40
|
+
"author": "Michael Bøcker-Larsen"
|
|
41
|
+
}
|
package/skill/SKILL.md
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: task-ui
|
|
3
|
+
description: Keeps the task-ui sidebar synchronized while coordinating multi-step work or external task backends. Use when the user asks to track tasks, when work has several meaningful steps, when backend tasks should be mirrored with task_ui_* presentation tools, or when a new session resumes work managed by a task backend.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Task UI
|
|
7
|
+
|
|
8
|
+
Use the `task_ui_*` tools to maintain a truthful UI projection of work. These tools never plan, execute, coordinate, cancel, or inspect backend work themselves.
|
|
9
|
+
|
|
10
|
+
## When to track
|
|
11
|
+
|
|
12
|
+
Track work when:
|
|
13
|
+
|
|
14
|
+
- the user asks for task tracking
|
|
15
|
+
- the request has multiple meaningful steps whose state helps the user
|
|
16
|
+
- work is delegated to workers or an external task backend
|
|
17
|
+
- several tasks may run concurrently
|
|
18
|
+
|
|
19
|
+
Do not create a task list for a trivial single action.
|
|
20
|
+
|
|
21
|
+
## Start a task set
|
|
22
|
+
|
|
23
|
+
Prefer `task_ui_batch_create` when the initial set is known. Use `task_ui_create` for work discovered later.
|
|
24
|
+
|
|
25
|
+
Give each task:
|
|
26
|
+
|
|
27
|
+
- a concise outcome-oriented `subject`
|
|
28
|
+
- the backend task ID as `id` when mirroring a backend
|
|
29
|
+
- an optional short `label` when a meaningful category or workflow applies, such as `research` or `grilling`; do not add brackets
|
|
30
|
+
- `parent_id` when the task is a subtask
|
|
31
|
+
- `blocked_by` IDs for real dependencies
|
|
32
|
+
- `pending` status until work begins
|
|
33
|
+
|
|
34
|
+
Labels render right-aligned. The same label receives the same theme-derived color everywhere; omit the label rather than inventing a meaningless category.
|
|
35
|
+
|
|
36
|
+
Do not invent dependencies, progress, token counts, or backend IDs.
|
|
37
|
+
|
|
38
|
+
## Parent tasks and subtasks
|
|
39
|
+
|
|
40
|
+
Set `parent_id` to nest a task beneath an existing parent. Batch creation may include parents and their descendants together.
|
|
41
|
+
|
|
42
|
+
Parents remain independently executable tasks:
|
|
43
|
+
|
|
44
|
+
- a parent and its subtasks may execute concurrently
|
|
45
|
+
- parent status and progress are never derived from its children
|
|
46
|
+
- completing, failing, or stopping a parent does not change its children
|
|
47
|
+
- `blocked_by` expresses execution dependencies; `parent_id` expresses hierarchy only
|
|
48
|
+
|
|
49
|
+
Use `task_ui_update` with `parent_id: null` to detach a subtask and make it a root task. Pass an empty `label` to clear an existing label. Do not create parent cycles.
|
|
50
|
+
|
|
51
|
+
## Mirror execution
|
|
52
|
+
|
|
53
|
+
Before actively executing a task, call `task_ui_update` with:
|
|
54
|
+
|
|
55
|
+
```json
|
|
56
|
+
{
|
|
57
|
+
"task_id": "backend-or-ui-id",
|
|
58
|
+
"label": "verification",
|
|
59
|
+
"status": "in_progress",
|
|
60
|
+
"executing": true,
|
|
61
|
+
"active_form": "Running regression tests…"
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Use present-progress wording for `active_form`. Several tasks may be `in_progress` or `executing` concurrently.
|
|
66
|
+
|
|
67
|
+
Update `input_tokens`, `output_tokens`, and `started_at` only when reliable telemetry is available. Never estimate or fabricate telemetry.
|
|
68
|
+
|
|
69
|
+
If work remains in progress but is not currently executing, set `executing` to `false` and keep `status` as `in_progress`.
|
|
70
|
+
|
|
71
|
+
### Delegated and sub-agent work
|
|
72
|
+
|
|
73
|
+
When a sub-agent or backend worker starts actively working on a task, immediately mirror that execution with `task_ui_update`:
|
|
74
|
+
|
|
75
|
+
```json
|
|
76
|
+
{
|
|
77
|
+
"task_id": "worker-task-id",
|
|
78
|
+
"status": "in_progress",
|
|
79
|
+
"executing": true,
|
|
80
|
+
"active_form": "Implementing task hierarchy…"
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
This changes the static `◼` in-progress icon to the animated `✳`/`✽` spinner. Multiple delegated tasks may show spinners concurrently.
|
|
85
|
+
|
|
86
|
+
When the worker stops running but the task remains unfinished, set `executing: false` and leave it `in_progress`. When it completes, fails, requires input, or is canceled, clear `executing` while mirroring the confirmed backend state.
|
|
87
|
+
|
|
88
|
+
Spawning a sub-agent does not automatically update task-ui. The coordinating agent must call the backend tool and the matching `task_ui_update` separately.
|
|
89
|
+
|
|
90
|
+
## Finish or interrupt work
|
|
91
|
+
|
|
92
|
+
After successful completion, call `task_ui_update` with `status: "completed"`, `executing: false`, and `progress: 100`.
|
|
93
|
+
|
|
94
|
+
After failure, set `status: "failed"` and `executing: false`. Add concise diagnostic output with `task_ui_output` when useful.
|
|
95
|
+
|
|
96
|
+
To stop real backend work:
|
|
97
|
+
|
|
98
|
+
1. Cancel or stop it through the actual backend.
|
|
99
|
+
2. Confirm the backend action succeeded or report uncertainty.
|
|
100
|
+
3. Call `task_ui_stop` to move the projection into stopped history.
|
|
101
|
+
|
|
102
|
+
`task_ui_stop` alone never stops backend work.
|
|
103
|
+
|
|
104
|
+
Use `task_ui_remove` when one obsolete item should disappear from the projection. Its children become root tasks. Use `task_ui_clear` only when the user explicitly wants the entire projected list cleared. Neither tool changes or cancels backend work; perform any matching backend action separately.
|
|
105
|
+
|
|
106
|
+
## Read and resynchronize
|
|
107
|
+
|
|
108
|
+
Call `task_ui_get` without `task_id` to retrieve:
|
|
109
|
+
|
|
110
|
+
- every active task
|
|
111
|
+
- the next unblocked pending task
|
|
112
|
+
- the focused task
|
|
113
|
+
|
|
114
|
+
Call it with `task_id` for full details about one task. Use `task_ui_list` for full or status-filtered projection reads.
|
|
115
|
+
|
|
116
|
+
Use `task_ui_output` only for concise, user-relevant projected output. Do not stream large logs into the sidebar.
|
|
117
|
+
|
|
118
|
+
### New-session resynchronization
|
|
119
|
+
|
|
120
|
+
When a new Pi session resumes work managed by `ctx_task` or another persistent task backend:
|
|
121
|
+
|
|
122
|
+
1. Call `task_ui_list` to inspect the current projection; resumed Pi sessions may already contain UI state.
|
|
123
|
+
2. Query the backend with its `list` operation.
|
|
124
|
+
3. Treat backend IDs and states as authoritative.
|
|
125
|
+
4. Create missing projected tasks with `task_ui_create` or `task_ui_batch_create`.
|
|
126
|
+
5. Update existing projected tasks whose confirmed backend state changed.
|
|
127
|
+
6. Mirror only relevant active, pending, input-required, or recent terminal tasks; do not import an entire backend archive.
|
|
128
|
+
|
|
129
|
+
Never blindly batch-create backend tasks before reading task-ui, because duplicate IDs are rejected. Do not reset a restored projection merely because a new conversation turn began.
|
|
130
|
+
|
|
131
|
+
If no persistent backend is being used, do not invent one or attempt synchronization. A fresh UI-only session may correctly begin with no tasks.
|
|
132
|
+
|
|
133
|
+
## Backend coordination
|
|
134
|
+
|
|
135
|
+
When using `ctx_task` or another backend, perform each backend operation separately and then mirror the confirmed result with `task_ui_*`.
|
|
136
|
+
|
|
137
|
+
Keep backend state authoritative. If backend and projection disagree, read the backend first and update task-ui to match it.
|
|
138
|
+
|
|
139
|
+
### `ctx_task` synchronization
|
|
140
|
+
|
|
141
|
+
Mirror each confirmed backend mutation:
|
|
142
|
+
|
|
143
|
+
| Confirmed `ctx_task` action or state | Follow-up presentation call |
|
|
144
|
+
|---|---|
|
|
145
|
+
| `create` succeeds | `task_ui_create` using the returned task ID |
|
|
146
|
+
| state becomes `working` | `task_ui_update` with `status: "in_progress"`; set `executing` truthfully |
|
|
147
|
+
| state becomes `input-required` | `task_ui_update` with `status: "in_progress"` and `executing: false`; optionally append a concise input-needed note |
|
|
148
|
+
| state becomes `completed` | `task_ui_update` with `status: "completed"`, `executing: false`, and `progress: 100` |
|
|
149
|
+
| state becomes `failed` | `task_ui_update` with `status: "failed"` and `executing: false` |
|
|
150
|
+
| `cancel` succeeds or state becomes `canceled` | `task_ui_stop` with the confirmed reason |
|
|
151
|
+
| a user-relevant `message` arrives | optionally append a concise summary with `task_ui_output` |
|
|
152
|
+
|
|
153
|
+
Use `ctx_task get` or `ctx_task list` as authoritative reads. They do not require a presentation mutation unless they reveal that the projection is stale.
|
|
154
|
+
|
|
155
|
+
Do not copy large logs, private worker messages, or every backend message into `task_ui_output`.
|
|
156
|
+
|
|
157
|
+
If the backend mutation succeeds but its task-ui mirror fails, do not undo or repeat the backend mutation. Retry or repair only the presentation call.
|