@abhishek944/pi-tasks 0.9.0 → 0.11.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/README.md +17 -9
- package/dist/agents/herdr.d.ts +4 -0
- package/dist/agents/herdr.js +23 -0
- package/dist/agents/links.d.ts +7 -0
- package/dist/agents/links.js +30 -0
- package/dist/agents/tools.d.ts +3 -0
- package/dist/agents/tools.js +140 -0
- package/dist/auto-continue.js +11 -14
- package/dist/index.d.ts +1 -1
- package/dist/index.js +30 -6
- package/dist/markdown.js +1 -1
- package/dist/open-repository.d.ts +2 -0
- package/dist/open-repository.js +22 -0
- package/dist/ownership.d.ts +1 -0
- package/dist/ownership.js +9 -0
- package/dist/progress.js +1 -1
- package/dist/state.d.ts +3 -4
- package/dist/state.js +10 -9
- package/dist/tools.js +14 -15
- package/dist/tracking.js +17 -6
- package/dist/types.d.ts +2 -4
- package/dist/ui/panel.d.ts +14 -4
- package/dist/ui/panel.js +110 -46
- package/dist/ui/works-dashboard.d.ts +3 -0
- package/dist/ui/works-dashboard.js +89 -18
- package/docs/REFERENCE.md +41 -13
- package/docs/USAGE_GUIDE.md +107 -14
- package/package.json +1 -1
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { copyToClipboard } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
import { matchesKey, truncateToWidth, visibleWidth, wrapTextWithAnsi, } from "@earendil-works/pi-tui";
|
|
3
|
+
import { delegateLink, focusPane } from "../agents/links.js";
|
|
3
4
|
import { formatWorksMarkdown } from "../markdown.js";
|
|
4
5
|
import { openRepository } from "../open-repository.js";
|
|
5
6
|
import { formatCompletion, taskCompletion, workCompletion } from "../progress.js";
|
|
6
7
|
import { safeMultiline, safeSingleLine } from "../text.js";
|
|
7
|
-
import { border, frame, gitBorder, progressName, rule, todoIcon
|
|
8
|
+
import { border, delegateHitRegion, frame, gitBorder, ownerBadge, progressName, recordId, rule, todoIcon } from "./panel.js";
|
|
8
9
|
const CHROME_LINES = 8;
|
|
9
10
|
export class WorksDashboard {
|
|
10
11
|
tui;
|
|
@@ -25,6 +26,8 @@ export class WorksDashboard {
|
|
|
25
26
|
messageColor = "warning";
|
|
26
27
|
copying = false;
|
|
27
28
|
opening = false;
|
|
29
|
+
openingDelegate = false;
|
|
30
|
+
delegateHits = [];
|
|
28
31
|
minimized = false;
|
|
29
32
|
unsubscribeGit;
|
|
30
33
|
openHitRegion;
|
|
@@ -49,6 +52,7 @@ export class WorksDashboard {
|
|
|
49
52
|
this.refreshTimer.unref?.();
|
|
50
53
|
}
|
|
51
54
|
render(width) {
|
|
55
|
+
this.delegateHits = [];
|
|
52
56
|
const dialogWidth = Math.max(1, width);
|
|
53
57
|
const innerWidth = Math.max(1, dialogWidth - 2);
|
|
54
58
|
const works = this.state.listWorks();
|
|
@@ -65,18 +69,25 @@ export class WorksDashboard {
|
|
|
65
69
|
this.syncSelection(items);
|
|
66
70
|
const terminalRows = this.tui.terminal.rows || process.stdout.rows || 30;
|
|
67
71
|
const dialogHeight = Math.max(8, Math.min(36, Math.floor(terminalRows * 0.82)));
|
|
68
|
-
const
|
|
72
|
+
const activeTodos = todos.filter((todo) => todo.status === "active").length;
|
|
69
73
|
const completedTodos = todos.filter((todo) => todo.status === "completed").length;
|
|
70
|
-
const summary = `${
|
|
74
|
+
const summary = `${works.length} works · ${activeTodos} todos active · ${completedTodos}/${todos.length} completed · session scoped`;
|
|
71
75
|
const bodyHeight = Math.max(0, dialogHeight - CHROME_LINES);
|
|
72
76
|
const detailBudget = this.detailsVisible ? Math.max(0, Math.floor(bodyHeight / 2)) : 0;
|
|
73
77
|
const details = this.renderDetails(items, innerWidth, detailBudget);
|
|
74
78
|
const listHeight = Math.max(0, bodyHeight - details.length);
|
|
75
79
|
if (listHeight > 0)
|
|
76
80
|
this.keepSelectionVisible(items, listHeight);
|
|
77
|
-
const rows = items.slice(this.scrollOffset, this.scrollOffset + listHeight).map((item) => this.renderRow(item, innerWidth));
|
|
81
|
+
const rows = items.slice(this.scrollOffset, this.scrollOffset + listHeight).map((item, index) => this.renderRow(item, innerWidth, 4 + index));
|
|
78
82
|
while (rows.length < listHeight)
|
|
79
83
|
rows.push("");
|
|
84
|
+
const selected = items.find((item) => item.key === this.selectedKey);
|
|
85
|
+
if (selected?.kind === "todo" && details[1] !== undefined) {
|
|
86
|
+
const start = visibleWidth(`${recordId(selected.todo.taskId, this.theme)} `);
|
|
87
|
+
const hit = delegateHitRegion(delegateLink(selected.todo.taskInfo), start, details[1], 5 + listHeight);
|
|
88
|
+
if (hit)
|
|
89
|
+
this.delegateHits.push(hit);
|
|
90
|
+
}
|
|
80
91
|
return [
|
|
81
92
|
gitBorder(innerWidth, this.theme, this.git.getSnapshot()),
|
|
82
93
|
frame(header, innerWidth, this.theme),
|
|
@@ -113,6 +124,18 @@ export class WorksDashboard {
|
|
|
113
124
|
}
|
|
114
125
|
if (this.minimized)
|
|
115
126
|
return;
|
|
127
|
+
if (matchesKey(data, "d")) {
|
|
128
|
+
const selected = items.find((item) => item.key === this.selectedKey);
|
|
129
|
+
const link = selected?.kind === "todo" ? delegateLink(selected.todo.taskInfo) : undefined;
|
|
130
|
+
if (link)
|
|
131
|
+
void this.openLinkedDelegate(link);
|
|
132
|
+
else {
|
|
133
|
+
this.message = "Select a delegated task with a Herdr pane link. Navigation requires Herdr.";
|
|
134
|
+
this.messageColor = "warning";
|
|
135
|
+
this.tui.requestRender();
|
|
136
|
+
}
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
116
139
|
this.messageColor = "warning";
|
|
117
140
|
if (this.keybindings.matches(data, "tui.select.up")) {
|
|
118
141
|
this.select(items, index - 1);
|
|
@@ -136,7 +159,24 @@ export class WorksDashboard {
|
|
|
136
159
|
this.tui.requestRender();
|
|
137
160
|
}
|
|
138
161
|
handleMouse(event) {
|
|
139
|
-
if (this.disposed
|
|
162
|
+
if (this.disposed)
|
|
163
|
+
return undefined;
|
|
164
|
+
if (event.type === "press" && event.button === "left") {
|
|
165
|
+
const delegateHit = this.delegateHits.some((region) => event.y === region.y && this.isHit(event.x, region));
|
|
166
|
+
const headerHit = event.y === 1 && [this.copyHitRegion, this.openHitRegion, this.toggleHitRegion].some((region) => this.isHit(event.x, region));
|
|
167
|
+
// Own the gesture so Pi does not turn repeated control clicks into text selection.
|
|
168
|
+
if (delegateHit || headerHit)
|
|
169
|
+
return { handled: true };
|
|
170
|
+
}
|
|
171
|
+
// Legacy mouse releases omit the button; Pi still normalizes the gesture as a click.
|
|
172
|
+
if (event.type !== "click" || (event.button !== "left" && event.button !== "none"))
|
|
173
|
+
return undefined;
|
|
174
|
+
const hit = this.delegateHits.find((region) => event.y === region.y && this.isHit(event.x, region));
|
|
175
|
+
if (hit) {
|
|
176
|
+
void this.openLinkedDelegate(hit.link);
|
|
177
|
+
return { handled: true, focus: true, render: true };
|
|
178
|
+
}
|
|
179
|
+
if (event.y !== 1)
|
|
140
180
|
return undefined;
|
|
141
181
|
if (this.isHit(event.x, this.toggleHitRegion)) {
|
|
142
182
|
this.toggleMinimized();
|
|
@@ -189,18 +229,23 @@ export class WorksDashboard {
|
|
|
189
229
|
this.scrollOffset = index - height + 1;
|
|
190
230
|
this.scrollOffset = Math.max(0, Math.min(this.scrollOffset, Math.max(0, items.length - height)));
|
|
191
231
|
}
|
|
192
|
-
renderRow(item, width) {
|
|
232
|
+
renderRow(item, width, y) {
|
|
193
233
|
const selected = item.key === this.selectedKey;
|
|
194
234
|
const prefix = selected ? this.theme.fg("accent", "▶ ") : " ";
|
|
195
235
|
if (item.kind === "work") {
|
|
196
236
|
const done = item.work.tasks.filter((todo) => todo.status === "completed").length;
|
|
197
|
-
const metadata = this.theme.fg("dim", `${
|
|
198
|
-
const nameWidth = width - visibleWidth(prefix) -
|
|
199
|
-
return truncateToWidth(`${prefix}${
|
|
237
|
+
const metadata = this.theme.fg("dim", `${done}/${item.work.tasks.length} completed`);
|
|
238
|
+
const nameWidth = width - visibleWidth(prefix) - 1 - visibleWidth(metadata);
|
|
239
|
+
return truncateToWidth(`${prefix}${this.theme.bold(progressName(item.work.workName, workCompletion(item.work), nameWidth, `${recordId(item.work.workId, this.theme)} `))} ${metadata}`, width, "");
|
|
200
240
|
}
|
|
201
|
-
const metadata = this.theme.fg("dim",
|
|
241
|
+
const metadata = this.theme.fg("dim", item.todo.status);
|
|
202
242
|
const nameWidth = width - visibleWidth(prefix) - 5 - visibleWidth(metadata);
|
|
203
|
-
|
|
243
|
+
const line = truncateToWidth(`${prefix} ${todoIcon(item.todo.status, this.theme)} ${progressName(item.todo.taskName, taskCompletion(item.todo), nameWidth, `${recordId(item.todo.taskId, this.theme)} ${ownerBadge(item.todo.taskInfo, this.theme, Boolean(delegateLink(item.todo.taskInfo)))} `)} ${metadata}`, width, "");
|
|
244
|
+
const start = visibleWidth(`${prefix} ${todoIcon(item.todo.status, this.theme)} ${recordId(item.todo.taskId, this.theme)} `);
|
|
245
|
+
const hit = delegateHitRegion(delegateLink(item.todo.taskInfo), start, line, y);
|
|
246
|
+
if (hit)
|
|
247
|
+
this.delegateHits.push(hit);
|
|
248
|
+
return line;
|
|
204
249
|
}
|
|
205
250
|
renderDetails(items, width, budget) {
|
|
206
251
|
if (!this.detailsVisible || budget === 0)
|
|
@@ -210,21 +255,22 @@ export class WorksDashboard {
|
|
|
210
255
|
return [this.theme.fg("muted", "No works or todos in this session.")].slice(0, budget);
|
|
211
256
|
let heading;
|
|
212
257
|
if (item.kind === "work") {
|
|
213
|
-
const lead = `${item.work.workId}
|
|
214
|
-
|
|
215
|
-
heading = `${lead}${progressName(item.work.workName, workCompletion(item.work), width - visibleWidth(lead + tail))}${tail}`;
|
|
258
|
+
const lead = `${recordId(item.work.workId, this.theme)} `;
|
|
259
|
+
heading = `${lead}${progressName(item.work.workName, workCompletion(item.work), width - visibleWidth(lead))}`;
|
|
216
260
|
}
|
|
217
261
|
else {
|
|
218
262
|
const taskName = safeSingleLine(item.todo.taskName);
|
|
263
|
+
const taskLead = `${recordId(item.todo.taskId, this.theme)} ${ownerBadge(item.todo.taskInfo, this.theme, Boolean(delegateLink(item.todo.taskInfo)))} `;
|
|
219
264
|
const workName = safeSingleLine(item.work.workName);
|
|
220
265
|
const taskProgress = formatCompletion(taskCompletion(item.todo));
|
|
221
266
|
const workProgress = formatCompletion(workCompletion(item.work));
|
|
222
|
-
const
|
|
267
|
+
const workId = recordId(item.todo.workId, this.theme);
|
|
268
|
+
const fixed = `${taskLead} · ${taskProgress} · ${item.todo.status} · ${workId} · ${workProgress}`;
|
|
223
269
|
const available = Math.max(0, width - visibleWidth(fixed));
|
|
224
270
|
const taskWidth = Math.min(visibleWidth(taskName), available - Math.min(visibleWidth(workName), Math.floor(available / 2)));
|
|
225
271
|
const shownTask = truncateToWidth(taskName, taskWidth, "…");
|
|
226
272
|
const shownWork = truncateToWidth(workName, available - taskWidth, "…");
|
|
227
|
-
heading = `${
|
|
273
|
+
heading = `${taskLead}${shownTask} · ${taskProgress} · ${item.todo.status} · ${workId} ${shownWork} · ${workProgress}`;
|
|
228
274
|
}
|
|
229
275
|
const info = item.kind === "work" ? item.work.workInfo : item.todo.taskInfo;
|
|
230
276
|
const infoLines = safeMultiline(info).flatMap((line) => wrapTextWithAnsi(this.theme.fg("dim", line || " "), width));
|
|
@@ -248,7 +294,7 @@ export class WorksDashboard {
|
|
|
248
294
|
const copyAction = this.copying
|
|
249
295
|
? this.theme.fg("dim", "[Copying…]")
|
|
250
296
|
: this.theme.fg("accent", this.theme.bold("[C Copy]"));
|
|
251
|
-
const openAction = this.theme.fg(this.opening ? "dim" : "accent", this.theme.bold("[O Open]"));
|
|
297
|
+
const openAction = this.theme.fg(this.opening ? "dim" : "accent", this.theme.underline(this.theme.bold("[O Open]")));
|
|
252
298
|
const toggleLabel = this.minimized ? "[M Maximize]" : "[M Minimize]";
|
|
253
299
|
const toggleAction = this.theme.fg("accent", this.theme.bold(toggleLabel));
|
|
254
300
|
const actionsWidth = visibleWidth(copyAction) + 1 + visibleWidth(openAction) + 1 + visibleWidth(toggleAction);
|
|
@@ -274,6 +320,31 @@ export class WorksDashboard {
|
|
|
274
320
|
isHit(x, region) {
|
|
275
321
|
return region !== undefined && x >= region.start && x < region.end;
|
|
276
322
|
}
|
|
323
|
+
async openLinkedDelegate(link) {
|
|
324
|
+
if (this.openingDelegate)
|
|
325
|
+
return;
|
|
326
|
+
this.openingDelegate = true;
|
|
327
|
+
this.message = "Opening delegated agent in Herdr…";
|
|
328
|
+
this.messageColor = "warning";
|
|
329
|
+
this.tui.requestRender();
|
|
330
|
+
try {
|
|
331
|
+
await focusPane(link.paneId, this.cwd);
|
|
332
|
+
this.message = "Opened delegated agent in Herdr.";
|
|
333
|
+
this.messageColor = "success";
|
|
334
|
+
}
|
|
335
|
+
catch (error) {
|
|
336
|
+
const reason = error instanceof Error ? safeSingleLine(error.message) : "Unknown error.";
|
|
337
|
+
this.message = `Could not open delegate. ${reason}`;
|
|
338
|
+
this.messageColor = "error";
|
|
339
|
+
if (!this.disposed)
|
|
340
|
+
this.notify(this.message, "error");
|
|
341
|
+
}
|
|
342
|
+
finally {
|
|
343
|
+
this.openingDelegate = false;
|
|
344
|
+
if (!this.disposed)
|
|
345
|
+
this.tui.requestRender();
|
|
346
|
+
}
|
|
347
|
+
}
|
|
277
348
|
async openInCursor() {
|
|
278
349
|
if (this.opening)
|
|
279
350
|
return;
|
|
@@ -325,7 +396,7 @@ export class WorksDashboard {
|
|
|
325
396
|
}
|
|
326
397
|
}
|
|
327
398
|
renderFooter(width) {
|
|
328
|
-
const text = "C copy all · O open Cursor · M minimize · configured ↑/↓ select · PgUp/PgDn scroll details · confirm toggles · cancel closes";
|
|
399
|
+
const text = "C copy all · O open Cursor · D open delegate · M minimize · configured ↑/↓ select · PgUp/PgDn scroll details · confirm toggles · cancel closes";
|
|
329
400
|
return truncateToWidth(this.theme.fg("muted", text), width, "");
|
|
330
401
|
}
|
|
331
402
|
}
|
package/docs/REFERENCE.md
CHANGED
|
@@ -18,15 +18,15 @@ Limits:
|
|
|
18
18
|
|
|
19
19
|
## Data
|
|
20
20
|
|
|
21
|
-
A work contains `workId`, `workName`, `workInfo`, `
|
|
21
|
+
A work contains `workId`, `workName`, `workInfo`, `createdAt`, and `updatedAt`. It is a collection with no stored or derived lifecycle status. Work tools do not accept status, and WorkList has no status filter. The public WorkStatus type is removed; consumers should use TodoStatus for task lifecycle.
|
|
22
22
|
|
|
23
|
-
A todo contains `taskId`, `workId`, `taskName`, `taskInfo`, `status`, optional `completionPercent`, `createdAt`, and `updatedAt`. Todo status
|
|
23
|
+
A todo contains `taskId`, `workId`, `taskName`, `taskInfo`, `status`, optional `completionPercent`, `createdAt`, and `updatedAt`. Todo status is `active`, `blocked`, `completed`, or `cancelled`; new todos default to `active`.
|
|
24
24
|
|
|
25
25
|
The public list shape assembles each work with `tasks: Todo[]`; tasks are stored separately to avoid duplicate state. Work progress is derived, not independently stored or editable.
|
|
26
26
|
|
|
27
|
-
`Blocked` includes waiting for another agent’s output, review, an external response, user input, permission, or a genuine obstacle. Mark dependent tasks blocked immediately, with the dependency and resume condition in their information field.
|
|
27
|
+
`Blocked` includes waiting for another agent’s output, review, an external response, user input, permission, or a genuine obstacle. Mark dependent tasks blocked immediately, with the dependency and resume condition in their information field. Tasks actually executing in a delegated agent can remain active. Resume affected tasks as active when the dependency resolves and work resumes. Works do not have status; cancelling a collection means explicitly cancelling its remaining tasks. These are agent instructions, not automatic dependency detection or a wake mechanism.
|
|
28
28
|
|
|
29
|
-
Replay normalizes legacy `planned` and `pending` statuses to `active` in both creation and update events
|
|
29
|
+
Replay accepts version-1 Work events with or without status, ignores retired Work statuses and status-only patches, and preserves IDs, details, timestamps and tasks without rewriting history. Work updates containing name/context changes still apply. Task replay normalizes legacy `planned` and `pending` statuses to `active` in both creation and update events; task tools accept only the four current statuses. Older clients that require Work status cannot read new status-free Work creation events correctly: upgrade readers before sharing new history, and retain session files before rollback.
|
|
30
30
|
|
|
31
31
|
### Completion progress
|
|
32
32
|
|
|
@@ -35,28 +35,40 @@ Replay normalizes legacy `planned` and `pending` statuses to `active` in both cr
|
|
|
35
35
|
- Completed tasks normalize to 100%; explicit partial progress with completed status is rejected. Explicit 100 requires completed status. Completion remains an agent assertion after verification, not an independent extension proof.
|
|
36
36
|
- Moving a partial task to blocked retains its progress. Reopening a completed task without a new estimate becomes unknown rather than retaining 100%.
|
|
37
37
|
- A work is the equal arithmetic mean of all non-cancelled task percentages, rounded down for display. For example, 100, 40, 0, 0 yields 35%.
|
|
38
|
-
- Any unknown eligible task makes the work unknown (`—`); unknown is not silently 0. With no eligible tasks
|
|
39
|
-
-
|
|
38
|
+
- Any unknown eligible task makes the work unknown (`—`); unknown is not silently 0. With no eligible tasks (empty Work or only cancelled tasks), work is unknown.
|
|
39
|
+
- Work progress reaches 100 only when all eligible tasks are completed; there is no parent status override. Progress never changes task statuses or auto-continuation eligibility.
|
|
40
40
|
- Optional progress fields are additive to version-1 branch events. Legacy completed tasks show 100%; other legacy tasks remain unknown until reported. Invalid optional progress is sanitized on replay without discarding the task.
|
|
41
41
|
- Dashboard, compact panel, list output and copied Markdown share these calculations. The compact panel reserves a narrow right-hand percentage column with a divider; names truncate independently. `/works` retains inline `· N%` labels and unchanged navigation. Percentages do not predict remaining time; no subtasks, weights or separate navigation sidebar are added.
|
|
42
42
|
|
|
43
43
|
## Tracking behavior
|
|
44
44
|
|
|
45
|
-
When all tracking tools are active, the extension adds hidden per-turn guidance for every normal request that starts or continues work. Pi finds or creates
|
|
45
|
+
When all tracking tools are active, the extension adds hidden per-turn guidance for every normal request that starts or continues work. Pi finds or creates the Work collection, synchronizes todos, marks the current todo active before the attempt, and updates task statuses afterward. Work context changes only when shared scope or decisions change. Tracking is not skipped merely because the request looks small.
|
|
46
|
+
|
|
47
|
+
The guidance also requires every delegated subagent, at every depth, to create or resume its own session-local Work and Todos before assigned work, maintain a real `workId` and an active `taskId`, and return its IDs with results. Parent assignment IDs are recorded as context, not used to mutate another session's records. Worker prompts must carry this requirement, including stopping delegated execution if tracking tools or IDs are unavailable. This is instruction-only, not a tool-call gate or automatic tracking repair.
|
|
46
48
|
|
|
47
49
|
The guidance is not added when the tracking tools have been removed from the active tool set. Pi Ask removes them during `/ask`. Pi BTW executes its side conversation outside the main conversation. The guidance also explicitly forbids changing works, todos, loops, or monitors during either mode.
|
|
48
50
|
|
|
51
|
+
### Shared workflow contract
|
|
52
|
+
|
|
53
|
+
The guidance directs every tracked Work, including worker-local Works, through the globally installed `implement` skill. Reuse an active skill rather than recursively invoking it. Specialized skill permissions remain authoritative; planning, research, and review do not gain implementation authority. Missing `implement`, tracking tools, valid session identity, or real IDs blocks execution. Reading instructions, obtaining identity, and establishing records are startup steps, not assigned execution. Plain conversation and side-thread exceptions remain unchanged.
|
|
54
|
+
|
|
55
|
+
The agent obtains its full session identity from `PI_SESSION_ID` in its own shell-tool command, not from a parent prompt or Herdr pane/name. Require `[A-Za-z0-9][A-Za-z0-9_-]*` and actual Work/Task IDs. Hosts without session-environment support must report the identity blocker rather than guess. Root artifacts use repository-relative `var/<sessionId>/<workId>/<taskId>/`; delegated artifacts append `<childSessionId>/<childWorkId>/<childTaskId>/` beneath the exact canonical parent task directory, recursively. Resolved destinations, including symlinks, must remain inside repository `var/`. Paths and parent IDs go in existing `taskInfo` and handoff context; each worker returns its own IDs and canonical path. Do not migrate legacy artifacts implicitly or overwrite files after branch navigation solely because numeric IDs match. `implement` owns the detailed path/ownership contract, including incompatible specialized helper handling.
|
|
56
|
+
|
|
57
|
+
Each task starts its existing `taskInfo` with `owner: self` or `owner: delegate` plus a reason, preserving that declaration in later updates. Delegation requires a bounded outcome, isolated ownership, ready inputs and verified prerequisites, useful parallelism or expertise that exceeds coordination costs, owning-skill permission, and available tracking/monitoring. Small or tightly coupled changes stay with one owner by default. Reassess on scope changes and apply the rule at every permitted delegation depth; parents retain integration and verification responsibility. Herdr retains lifecycle and monitor ownership. Worker root panes use only the parent's delegated Task ID as their name (`T34`, without brackets or descriptions), updated when a different parent Todo is assigned. This label is distinct from worker-local IDs and may repeat across parent sessions; returned resource IDs remain authoritative for lifecycle commands. No file-count, agent-count, or depth threshold is imposed.
|
|
58
|
+
|
|
59
|
+
This is model guidance only. No new schema fields, path-creation code, tool-call gate, cross-session mutation, session-ID API dependency, or automatic skill installer is added. Guidance still depends on all tracking tools being active as described above.
|
|
60
|
+
|
|
49
61
|
## Auto-continuation
|
|
50
62
|
|
|
51
63
|
Auto-continuation is optional and requires Pi 1.2.0 or newer. Configure `pi-tasks.autoContinue` in Pi's `settings.json`; the extension reads `pi.getSettings()` so trusted project settings override global settings. `enabled` defaults to `false`; `maxContinuations` is optional. Omission means no continuation limit; if supplied, it must be a positive safe integer. Explicit `null` is invalid. Invalid configuration disables the flow and reports a warning. Hosts without the new settings API keep normal task tracking with no automatic continuation.
|
|
52
64
|
|
|
53
|
-
A fresh accepted main interactive/RPC run arms a new continuation epoch. Input is provisional until the run starts, so handled/rejected prompts cannot arm it. Extension/custom starts do not arm or reset it. Steering/follow-up messages queued inside an already-running activity do not themselves reset the cap. Session start/reload, tree navigation, and shutdown disarm it until fresh user input.
|
|
65
|
+
A fresh accepted main interactive/RPC run arms a new continuation epoch. Input is provisional until the run starts, so handled/rejected prompts cannot arm it. Extension/custom starts do not arm or reset it. Steering/follow-up messages queued inside an already-running activity do not themselves reset the cap. Session start/reload, tree navigation, and shutdown disarm it until fresh user input. Explicitly aborted activity also suspends it; failed activity does not. `agent_settled.aborted` covers aborts that skip the actionable boundary. Tracking tools must be active; side conversations must not start continuation.
|
|
54
66
|
|
|
55
|
-
The synchronous `agent_before_settle` handler runs after native retries, compaction, and queued work. It
|
|
67
|
+
The synchronous `agent_before_settle` handler runs after native retries, compaction, and queued work. It accepts completed or error outcomes and requires a non-aborted signal, no pending messages in either the boundary preview or runtime queue, and no continuation already requested by an earlier handler. Pi is still busy at this actionable boundary, so it does not require `ctx.isIdle()`. Instead it appends one custom-message draft and requests one native continuation; Pi owns committing it and honoring cancellation. No detached prompt, timer, background worker, or polling loop is created.
|
|
56
68
|
|
|
57
|
-
|
|
69
|
+
Any active task across all Works on the current branch requires continuation. Legacy planned/pending task statuses replay as active. Empty Works and completed, blocked, or cancelled tasks do not trigger continuation. Work metadata has no scheduling role. The prompt includes a bounded preview of IDs, names and statuses, and directs the agent to list tools for full details. No records means no continuation. The extension never mutates statuses, verifies work independently, or treats a blocker label as proof of an actual dependency.
|
|
58
70
|
|
|
59
|
-
When `maxContinuations` is supplied, at most that many extra continuations are requested per fresh accepted main user run. The next unfinished boundary warns once and suspends continuation; a fresh user prompt resets the cap. With no limit supplied, continuation can consume tokens indefinitely while unfinished records remain, until interrupted,
|
|
71
|
+
When `maxContinuations` is supplied, at most that many extra continuations are requested per fresh accepted main user run. The next unfinished boundary warns once and suspends continuation; a fresh user prompt resets the cap. With no limit supplied, continuation can consume tokens indefinitely while unfinished records remain, until explicitly interrupted, disabled or otherwise suspended, including during repeated provider failures. This is not a cost cap or a cap on native tool/retry requests, and another extension may independently request work. Settings changes take effect when Pi reloads effective settings, normally through `/reload`.
|
|
60
72
|
|
|
61
73
|
## Repository status and Cursor
|
|
62
74
|
|
|
@@ -66,8 +78,24 @@ The implementation is informed by [pi-powerline-footer's cache behavior](https:/
|
|
|
66
78
|
|
|
67
79
|
Open appears between Copy and Minimize/Maximize. It executes `cursor` with the separate argument `.` in the active session working directory, without a shell. The executable must be on PATH; errors are shown instead of silently failing. `/works-panel open` supplies a command path, and `/works` uses `o`. Open is also available outside Git repositories.
|
|
68
80
|
|
|
81
|
+
### Ownership display
|
|
82
|
+
|
|
83
|
+
`taskOwner(taskInfo)` interprets explicit line-start `owner: self` or `owner: delegate` declarations case-insensitively. A trailing sentence/reason is allowed, but incidental prose and longer enum-like tokens such as `self-managed` do not count. Missing/invalid decisions or conflicting valid declarations return `unassigned`; repeated identical declarations remain unambiguous. Compact floating/widget panel rows, dashboard rows, and todo detail headings share this interpretation and show `[taskId] [self/delegate] Task name` (or `[unassigned]`). The existing `taskInfo` is the sole source; no persistence fields, tool parameters, migrations, or task-name edits are introduced. Progress reservations, status/count logic, and full details remain unchanged.
|
|
84
|
+
|
|
85
|
+
### Delegate navigation
|
|
86
|
+
|
|
87
|
+
Agent tools are thin, bounded, shell-free Herdr CLI wrappers using actual paneId values. No separate agent handle, private registry, process/session validation, startup receipt, recovery/reconnection or acquisition framework is implemented. Panes are assumed not to be repurposed. Structured CLI errors are reported even with exit code zero, and partial creation failures report the handles already obtained without automatic retry/cleanup.
|
|
88
|
+
|
|
89
|
+
AgentCreate creates a dedicated unfocused tab, starts Pi with the supplied model flags and calls the existing MonitorCreate through ctx.executeTool with onSignal and optional onDone unchanged. It returns paneId/tabId/monitorId, assignmentSent:false and the prepared assignment. The AI must confirm MonitorList shows subscription ready before explicit AgentSend. Follow-up sends do not replace the monitor. AgentClose calls MonitorStop with the supplied monitorId, then closes the supplied pane; callers must use only resources they created. AgentList returns the CLI inventory, including unrelated agents. No subprocess runs during rendering.
|
|
90
|
+
|
|
91
|
+
AgentCreate stores herdr-pane and herdr-monitor lines in existing taskInfo; task tools persist and restore these details. TodoUpdate preserves existing link lines for delegate-to-delegate detail edits unless explicit replacement metadata is supplied, so ordinary progress/status descriptions do not silently disable navigation. Changing ownership, explicit `herdr-pane: none`, or AgentClose can unlink. delegateLink interprets an unambiguous valid pane ID for owner:delegate inside Herdr. AgentClose removes matching delegate links. No task schema change or automatic task completion is introduced. The onSignal/onDone callbacks remain entirely owned by pi-loop-monitor; onDone means its process ended, not that worker work is complete.
|
|
92
|
+
|
|
93
|
+
Delegate navigation and AgentFocus first focus the pane, then explicitly activate the tab returned by Herdr; pane-focus success alone does not guarantee that the visible client switched tabs.
|
|
94
|
+
|
|
95
|
+
Linked `[delegate]` badges and Cursor Open controls are underlined. Fullscreen mouse regions use ANSI-aware visible columns and only include complete visible badges after clipping and scrolling. Floating/widget rows, dashboard rows and todo detail headings support clicks; hidden/minimized/offscreen badges have no regions. In `/works`, `d` opens the selected task's delegate, and `/works-panel delegate T<number>` provides a command path in regular mode. Outside Herdr or without a pane link, ownership stays informational and is not underlined. Unavailable CLI, stale/closed targets and other navigation failures produce visible errors.
|
|
96
|
+
|
|
69
97
|
## Interfaces
|
|
70
98
|
|
|
71
|
-
The compact panel defaults to a non-capturing floating overlay anchored at the top-right. It
|
|
99
|
+
The compact panel defaults to a non-capturing floating overlay anchored at the top-right. Its header hides the session ID and places an underlined Open session action immediately after Copy, including minimized/widget layouts. The action uses the Pi session-context identity to locate the matching direct/nested artifact directory under repository var and opens it via the existing shell-free Cursor launcher. If absent, the standard var/sessionId directory is created on activation; ambiguous matches or unsafe identity fail visibly. No lookup or process launch occurs during rendering. /works-panel open-session supplies a keyboard-command path. Existing repository Open remains separate. On narrow headers, Minimize/Maximize shorten to [-]/[+] to preserve every action and its hit region; overflow hints use remaining space. It prefixes work and todo names with bracketed IDs (`[W1] Name`, `[T1] [self] Name`), alongside status icons, completion counts, and a visible row range when content exceeds the terminal-aware viewport. It hides on terminals narrower than 90 columns or shorter than 18 rows. In fullscreen TUI mode, its title-bar Copy action exports every work and nested todo as Markdown, while Minimize collapses the panel to a restorable title bar that keeps Copy, Open, and Maximize available. `/works-panel minimize` and `/works-panel maximize` provide a keyboard-command path and preserve the collapsed state when switching between floating and widget layouts. Overflow starts at the newest rows and follows newly added tail rows until the user scrolls upward. Mouse-wheel events over the expanded floating panel scroll it directly without taking keyboard focus; regular terminal mode shows the newest rows and uses `/works` for complete browsing and copying. Because Pi treats any persistent overlay as active, the floating mode can block display-mode changes. `/works-panel widget` switches to a right-aligned widget above the editor, renders all rows, and retains the title actions, while `/works-panel off` hides it.
|
|
72
100
|
|
|
73
|
-
`/works` opens a top-centered detailed overlay. Its top-right Copy action uses `c` to copy every work and nested todo to the system clipboard as Markdown. Its Open action uses `o` to open the current directory in Cursor. Its Minimize action uses `m` to collapse the overlay to a framed top bar containing live total work and todo counts, Copy, Open, and a Maximize action; activating Maximize restores the full dashboard. In fullscreen TUI mode, Copy, Open, and Minimize/Maximize also respond to left clicks. Configured selection keys choose records, configured Page Up and Page Down keys scroll long details, the configured confirmation key toggles details, and the configured cancel key closes it.
|
|
101
|
+
`/works` opens a top-centered detailed overlay. List rows and detail headings use the same bracketed ID and ownership prefixes; list metadata no longer repeats the ID after the name. The dashboard title remains unchanged. Stored names remain unchanged. Its top-right Copy action uses `c` to copy every work and nested todo to the system clipboard as Markdown. Its Open action uses `o` to open the current directory in Cursor. Its Minimize action uses `m` to collapse the overlay to a framed top bar containing live total work and todo counts, Copy, Open, and a Maximize action; activating Maximize restores the full dashboard. In fullscreen TUI mode, Copy, Open, and Minimize/Maximize also respond to left clicks. Configured selection keys choose records, configured Page Up and Page Down keys scroll long details, the configured confirmation key toggles details, and the configured cancel key closes it.
|
package/docs/USAGE_GUIDE.md
CHANGED
|
@@ -5,24 +5,59 @@
|
|
|
5
5
|
For every normal request that starts or continues work, Pi should:
|
|
6
6
|
|
|
7
7
|
1. Find existing work and todos.
|
|
8
|
-
2. Create
|
|
8
|
+
2. Create the relevant Work collection, or refresh its shared context when needed.
|
|
9
9
|
3. Create or update detailed todos for the requested scope.
|
|
10
10
|
4. Mark the current todo active before starting it.
|
|
11
11
|
5. During longer tasks, report interim progress after roughly 5–10 meaningful working steps or a milestone, when an estimate is possible.
|
|
12
12
|
6. Mark the todo blocked immediately if its next step must wait on a dependency; otherwise update it after the attempt as active, completed, or cancelled.
|
|
13
|
-
7.
|
|
13
|
+
7. Keep status on tasks only; update Work context when scope or shared decisions change.
|
|
14
14
|
|
|
15
15
|
The extension applies this guidance across all loaded skills and does not skip work merely because it looks small. It does not update tracking during `/ask`, `/btw`, or BTW side threads.
|
|
16
16
|
|
|
17
17
|
Write `workInfo` and `taskInfo` in normal prose with full sentences and spaces between words. Conversational brevity modes do not apply to stored records; do not concatenate words to shorten them. This is model-facing guidance, not automatic repair of existing text.
|
|
18
18
|
|
|
19
|
+
## Shared workflow and artifacts
|
|
20
|
+
|
|
21
|
+
Every tracked Work, including each worker's local Work, uses the globally installed `implement` skill for coordination. Read it once before execution, or reuse it if active. Specialized skills retain their scope: research and review remain read-only, and planning does not authorize implementation. Plain conversation, `/ask`, and `/btw` remain outside this workflow. Pi-tasks owns records and progress; `implement` owns coordination, artifact paths, and integration; `herdr` owns delegated-agent lifecycle and monitors. This instruction does not install those skills or add runtime enforcement. If `implement`, tracking tools, or required IDs are unavailable, report the blocker rather than executing without them.
|
|
22
|
+
|
|
23
|
+
Read the full current session ID through the agent's own shell tool:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
printf '%s\n' "$PI_SESSION_ID"
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Startup includes reading instructions, obtaining identity, and creating/resuming tracking. Before execution, require a nonempty session ID matching `[A-Za-z0-9][A-Za-z0-9_-]*`, a real tool-returned Work ID, and an active Task ID. Do not invent IDs, use a Herdr pane/name as identity, or substitute the parent's session ID. Hosts/custom shell tools that do not expose session identity must report that blocker.
|
|
30
|
+
|
|
31
|
+
Root task artifacts use repository-relative `var/<sessionId>/<workId>/<taskId>/`, never the system `/var/`. A delegated worker appends its own `<childSessionId>/<childWorkId>/<childTaskId>/` below the exact `parentTaskDir` from its assignment, recursively. For example:
|
|
32
|
+
|
|
33
|
+
```text
|
|
34
|
+
var/<rootSessionId>/W1/T2/
|
|
35
|
+
plan.md
|
|
36
|
+
<childSessionId>/W1/T1/
|
|
37
|
+
report.md
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Record the canonical artifact directory and parent session/Work/Task IDs in `taskInfo`, pass them unchanged in handoffs, and return them with results. Keep resolved destinations inside the repository's `var/`, including symlinks. Create folders only for useful artifacts; feature names remain descriptions rather than path keys. Each task owns its files and links to shared coordinating-task plans rather than copying them. Reuse recorded paths only after verifying current ownership, especially after session-branch navigation; matching numeric IDs alone do not authorize overwriting artifacts. Preserve existing artifacts unless an explicit migration is approved. Follow `implement` for detailed path handling and report incompatible legacy helper paths rather than inventing unsupported arguments or silently falling back to feature-named directories.
|
|
41
|
+
|
|
42
|
+
### Choose self or delegate
|
|
43
|
+
|
|
44
|
+
Before each task, start `taskInfo` with `owner: self` or `owner: delegate` and a short reason. Preserve this declaration when updating the details. Delegate only when scope and acceptance criteria are clear, ownership can be isolated, required inputs and verified prerequisites are ready, and useful parallelism or expertise outweighs startup, context transfer, monitoring, and integration costs. The owning skill must permit delegation and required tracking and monitoring must be available. Small straightforward changes, tightly coupled edits, shared-interface design, and expensive-to-explain work normally stay with one owner. Risk alone is not a reason for parallel coding; independent review may still help. Do not use arbitrary file-count, agent-count, or depth thresholds. Reassess if scope changes; each allowed delegating child applies the same rule, and parents retain responsibility for monitoring, integration, verification, and cleanup.
|
|
45
|
+
|
|
46
|
+
Name each Herdr subagent root pane exactly with the parent's delegated Todo ID, for example `T34`, without brackets, descriptions, Work IDs, or other prefixes. The worker creates its own session-local tracking after startup; those IDs do not replace this pane label. Rename an owned worker pane if a follow-up assigns a different parent Todo. Names may repeat across parent sessions, so use returned resource IDs for lifecycle commands, never pane names.
|
|
47
|
+
|
|
48
|
+
These are instructions using existing details fields, not a new schema, shared cross-session task tree, automatic directory creator, or enforcement hook.
|
|
49
|
+
|
|
50
|
+
## Delegated agents
|
|
51
|
+
|
|
52
|
+
Every subagent must create or resume its own session-local Work and Todos before starting its assignment, at every delegation depth. It must have a real `workId` and an active `taskId` for the current step, keep its records current, and return the IDs with results, checks, and blockers. Include this requirement, the `implement`/specialized skill handoff, parent session/Work/Task IDs, and the canonical parent task directory in every worker prompt. Require the worker to return its own session/Work/Task IDs and canonical nested artifact directory. Record parent assignment IDs as context, not as shared records: each Pi session has its own IDs. If tracking tools or IDs are unavailable, the worker must report the blocker and not begin assigned work; a parent-owned Todo or Markdown checklist is not a substitute. Never invent IDs or claim tracking existed before it did. This is model-facing guidance, not a runtime enforcement hook; `/ask` and `/btw` remain outside tracking.
|
|
53
|
+
|
|
19
54
|
## Statuses and dependencies
|
|
20
55
|
|
|
21
|
-
Works
|
|
56
|
+
Works are collections with no status. Tasks use only `active`, `blocked`, `completed`, and `cancelled`. New tasks default to `active`; saved legacy task statuses `planned` and `pending` restore as active but are no longer accepted by tools. Old Work statuses are ignored during replay; no saved history is rewritten.
|
|
22
57
|
|
|
23
|
-
Use `blocked` immediately when a task cannot proceed until another agent produces output, a review finishes, an external response arrives, the user responds, permission is granted, or another obstacle is resolved. Record which dependency it awaits and what will unblock it in `taskInfo`; retain its current completion estimate.
|
|
58
|
+
Use `blocked` immediately when a task cannot proceed until another agent produces output, a review finishes, an external response arrives, the user responds, permission is granted, or another obstacle is resolved. Record which dependency it awaits and what will unblock it in `taskInfo`; retain its current completion estimate. Tasks actually executing in another agent may remain active, but downstream tasks waiting for that output are blocked.
|
|
24
59
|
|
|
25
|
-
|
|
60
|
+
When the dependency resolves and work resumes, mark the affected tasks active. Do not assign status to the parent Work. To cancel the whole collection, cancel its remaining tasks explicitly. Neither blocked status nor changing it schedules a wake automatically; use the appropriate monitor or event when an automatic notification is needed.
|
|
26
61
|
|
|
27
62
|
## Continue unfinished work automatically
|
|
28
63
|
|
|
@@ -38,25 +73,24 @@ This is off by default and requires Pi 1.2.0+. Add the following to global `~/.p
|
|
|
38
73
|
}
|
|
39
74
|
```
|
|
40
75
|
|
|
41
|
-
Send a normal prompt to start.
|
|
76
|
+
Send a normal prompt to start. After success or failure, if any task across all Works on the current session branch is active, the agent receives a message to continue and verify it. Legacy planned/pending task statuses restore as active. Empty Works and blocked, completed, or cancelled tasks do not cause another continuation. Record genuine blockers and resume conditions in taskInfo before handing off.
|
|
42
77
|
|
|
43
|
-
Press Escape/abort to stop. The extension will not restart from a monitor wake or another extension's message; send a new main prompt when you want it to resume. Failed runs
|
|
78
|
+
Press Escape/abort to stop. The extension will not restart from a monitor wake or another extension's message; send a new main prompt when you want it to resume. Failed runs do not disarm continuation: after native retries, unfinished records request another run. Repeated provider failures can therefore keep consuming tokens with no configured limit. Reloading or navigating session branches does not silently resume unfinished work.
|
|
44
79
|
|
|
45
80
|
Omitting `maxContinuations` means no continuation limit: it can keep consuming tokens while unfinished records remain. Manual abort and all other stopping conditions still apply. To cap it, add a positive integer such as `"maxContinuations": 10`. After the configured number of extra continuations, the extension warns and hands control back without changing records. A fresh accepted main user run resets the limit; a rejected prompt or steering/follow-up input queued inside a running activity does not. Set `enabled` to `false` and reload to disable the feature. It checks recorded states, not whether every user requirement was captured or genuinely verified.
|
|
46
81
|
|
|
47
82
|
## Work tools
|
|
48
83
|
|
|
49
84
|
```text
|
|
50
|
-
WorkCreate workName="Improve authentication" workInfo="Detailed context..."
|
|
85
|
+
WorkCreate workName="Improve authentication" workInfo="Detailed context..."
|
|
51
86
|
WorkList
|
|
52
87
|
WorkList limit=10
|
|
53
|
-
WorkList status="active" limit=5
|
|
54
88
|
WorkList workId="W1"
|
|
55
|
-
WorkUpdate workId="W1"
|
|
89
|
+
WorkUpdate workId="W1" workInfo="Updated shared scope and decisions..."
|
|
56
90
|
WorkDelete workId="W1"
|
|
57
91
|
```
|
|
58
92
|
|
|
59
|
-
`WorkList` returns all matching works when `limit` is omitted. A positive integer `limit` selects the newest matching works after filters, displayed oldest-to-newest; every selected work still includes all of its todos. The result shows how many works were returned and how many matched in total. `WorkDelete` also removes associated todos.
|
|
93
|
+
Work tools do not accept `status`; `WorkList` filters by Work ID only. `WorkList` returns all matching works when `limit` is omitted. A positive integer `limit` selects the newest matching works after filters, displayed oldest-to-newest; every selected work still includes all of its todos. The result shows how many works were returned and how many matched in total. `WorkDelete` also removes associated todos.
|
|
60
94
|
|
|
61
95
|
## Todo tools
|
|
62
96
|
|
|
@@ -77,22 +111,81 @@ TodoDelete taskId="T1"
|
|
|
77
111
|
|
|
78
112
|
During longer tasks, Pi should include a `completionPercent` estimate in `TodoUpdate` after roughly 5–10 meaningful working steps or a milestone, rather than waiting until completion or only updating status. Explain the evidence and remaining work in `taskInfo`. Estimates remain optional: use `null` when unknown, and leave a percentage unchanged if there is no new evidence. This is model-facing guidance, not an enforced schedule or an automatic percentage increase. These are approximate AI-reported values, not a fixed percentage for each status and not a time prediction. Use an integer 0–100 or `null` for unknown. Completed status means verified completion and displays 100%; 100 without completed status is rejected. Partial progress requires reopening a completed task; reopening without a fresh estimate makes it unknown. Blocking retains the current estimate.
|
|
79
113
|
|
|
80
|
-
Work progress averages all non-cancelled tasks equally and rounds down. Tasks at 100%, 40%, 0%, 0% produce 35% work completion, not 25% based on finished-task counts. If any eligible task lacks an estimate, the work displays `—`. No eligible tasks
|
|
114
|
+
Work progress averages all non-cancelled tasks equally and rounds down. Tasks at 100%, 40%, 0%, 0% produce 35% work completion, not 25% based on finished-task counts. If any eligible task lacks an estimate, the work displays `—`. No eligible tasks (an empty Work or only cancelled tasks) also means unknown. Work progress has no separate status or override. Existing sessions retain their records; legacy completed tasks display 100%, while other missing estimates remain unknown.
|
|
81
115
|
|
|
82
116
|
## TUI
|
|
83
117
|
|
|
84
|
-
|
|
118
|
+
Both the compact panel (floating or widget) and `/works` prefix work names with their IDs, such as `[W1] Locate subagent restrictions`. Task rows and dashboard detail headings also include ownership: `[T1] [self] Inspect the implement skill` or `[T2] [delegate] Implement storage`. These are display labels only; stored names and IDs are unchanged. Work IDs use the theme's accent color, task IDs use its type-highlight color, `[self]` uses success, `[delegate]` uses warning, and `[unassigned]` stays muted. Exact hues follow the selected theme; labels remain readable without relying on color.
|
|
119
|
+
|
|
120
|
+
Ownership is read case-insensitively from explicit line-start `owner: self` or `owner: delegate` declarations in `taskInfo`, optionally followed by a reason or sentence. Incidental prose does not assign ownership. Missing, invalid, or conflicting declarations show `[unassigned]`; repeated declarations with the same valid value are unambiguous. No old records are rewritten and no new tool parameter is required. For example:
|
|
121
|
+
|
|
122
|
+
```text
|
|
123
|
+
owner: self. This is a small, tightly coupled change.
|
|
124
|
+
The task covers the panel label and its documentation.
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Delegate pane links
|
|
128
|
+
|
|
129
|
+
`[delegate]` describes the ownership decision; it does not launch an agent. AgentCreate automatically adds `herdr-pane: <paneId>` and `herdr-monitor: <monitorId>` lines to the parent task's existing details. TodoUpdate keeps those lines when both old and new ownership stay delegate and the new details do not supply replacement link metadata. Explicit metadata takes precedence; changing ownership or AgentClose can clear the link. Set `herdr-pane: none` to explicitly unlink without changing ownership. No new task schema or private agent registry is added. AgentClose clears matching links without changing ownership or completion.
|
|
130
|
+
|
|
131
|
+
## Agent tools
|
|
132
|
+
|
|
133
|
+
These are simple Herdr CLI wrappers in pi-tasks, with no pi-herdr-agents dependency. AgentCreate also calls the existing MonitorCreate tool; AgentClose calls MonitorStop. Those two need modern Pi nested calls and the updated pi-loop-monitor result metadata. Base Work/Todo tracking and ordinary CLI wrappers do not depend on a private monitoring runtime.
|
|
134
|
+
|
|
135
|
+
| Tool | Purpose |
|
|
136
|
+
| --- | --- |
|
|
137
|
+
| `AgentCreate` | Create an unfocused tab, start Pi and register monitoring; return paneId/tabId/monitorId plus a prepared assignment. No prompt is sent. |
|
|
138
|
+
| `AgentList` | `herdr agent list` (includes unrelated agents). |
|
|
139
|
+
| `AgentStatus` | `herdr agent get <paneId>`. |
|
|
140
|
+
| `AgentOutput` | `herdr pane read`; 50 trailing lines by default, up to 200. |
|
|
141
|
+
| `AgentSend` | `herdr agent prompt <paneId> <message>` without waiting. |
|
|
142
|
+
| `AgentInterrupt` | `herdr agent send-keys <paneId> esc`. |
|
|
143
|
+
| `AgentClose` | MonitorStop for the supplied monitorId, then `herdr pane close <paneId>`. |
|
|
144
|
+
| `AgentFocus` | `herdr agent focus <paneId>`; also used by delegate links. |
|
|
145
|
+
|
|
146
|
+
For an existing active Work/Todo whose `taskInfo` starts with `owner: delegate`, call:
|
|
147
|
+
|
|
148
|
+
```typescript
|
|
149
|
+
AgentCreate({
|
|
150
|
+
workId: "W1",
|
|
151
|
+
taskId: "T2",
|
|
152
|
+
taskDir: "var/<full-current-sessionId>/W1/T2",
|
|
153
|
+
assignment: "Review the approved change. Do not edit files or run tests.",
|
|
154
|
+
provider: "<chosen-provider>",
|
|
155
|
+
model: "<chosen-model-id>",
|
|
156
|
+
thinking: "high",
|
|
157
|
+
onSignal: "Inspect worker output. Help with blockers; review the actual changes before completing the task.",
|
|
158
|
+
onDone: "The monitor stopped. Inspect its status and recover monitoring if still needed."
|
|
159
|
+
})
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Replace placeholders using the existing implement path convention and model-routing-policy. The wrapper passes taskDir to the prepared worker assignment; it does not create folders or verify the running model. It adds parent context and worker-local tracking instructions without granting extra permissions.
|
|
163
|
+
|
|
164
|
+
AgentCreate returns `assignmentSent: false`. Confirm MonitorList shows `Herdr signal subscription ready for <paneId>`, then call `AgentSend({ paneId, message: assignment })` using the returned assignment. Do not add a second monitor. Follow-up messages use that same paneId and existing subscription.
|
|
165
|
+
|
|
166
|
+
`onSignal` is a wake instruction for worker state changes, including blocked, idle and done. The monitor keeps watching. `onDone` is a wake instruction if the monitor process terminates, not a worker-completion callback; when omitted, pi-loop-monitor supplies its recovery instruction. Neither returns the worker's complete answer automatically. The parent uses `AgentOutput` and inspects actual files before marking tasks complete. Do not add a duplicate monitor or close a worker merely because it reports done.
|
|
167
|
+
|
|
168
|
+
Use actual paneId values, not pane names or a separate agent handle. These wrappers assume an agent pane is not repurposed. There are no process/session checks, startup receipts, registry, automatic reconnection, retry or rollback framework. Ordinary CLI errors are returned with any handles already obtained so the caller can inspect and decide what to do. Close only resources you created; a done signal does not automatically close anything or complete a task. If monitoring stops, use the existing monitor tools to inspect/reconnect explicitly.
|
|
169
|
+
|
|
170
|
+
Inside Herdr (`HERDR_ENV=1`), a linked `[delegate]` is underlined. In fullscreen mode, click that badge in compact/widget rows, dashboard rows, or task detail headings to focus its agent pane. Only fully visible badges are clickable. In `/works`, select the task and press `d`; `/works-panel delegate T<number>` provides a command path, including regular terminal mode. `[Open]` / `[O Open]` are also underlined and still open Cursor. Unlinked badges are not underlined, because they are not navigation actions.
|
|
171
|
+
|
|
172
|
+
Navigation directly focuses the linked paneId through Herdr. Closed panes, missing Herdr CLI and command errors are reported. No subprocess runs during rendering. Agent tools coordinate Herdr resources; pi-loop-monitor remains the sole monitoring runtime. Outside Herdr, badges remain informational.
|
|
173
|
+
|
|
174
|
+
The compact panel no longer displays the session ID. Its underlined `[Open session]` action sits immediately after Copy in floating, widget and minimized layouts. It opens this agent's existing artifact directory under repository `var/` in Cursor, including a nested delegated session folder. If no folder exists, it creates `var/<full-sessionId>/`; multiple matching folders report an ambiguity rather than guessing. Session identity comes from Pi's context, not a pane name. Folder resolution and Cursor launch happen only on activation, never during rendering. `/works-panel open-session` is the keyboard-command alternative. The existing Open action still opens the repository. Narrow compact headers use `[-]`/`[+]` for Minimize/Maximize so all actions fit. The `/works` dashboard retains its existing title and controls.
|
|
175
|
+
|
|
176
|
+
The panel defaults to a floating top-right layout and does not take keyboard focus. A slim, separated right-hand column keeps work and task percentages aligned and visible even when names are long; the left side retains names, task status icons and Work task-counts. Work rows have no status icons. It hides on small terminals. The top border centers repository-wide Git status: `git main · S2 U3 ?1` means two staged files, three unstaged files, and one untracked file; a file with both staged and unstaged edits counts in both. A clean repository shows `git main · clean`. Long branches shorten before counts. Detached HEAD shows `@` plus the short commit. Git remains visible while minimized and adds no content row.
|
|
85
177
|
|
|
86
178
|
The asynchronous Git cache refreshes every second while a view is attached; file-changing tool results expire it sooner without blanking the last snapshot. Initial reads show `git loading…`; outside Git the border is plain, and initial failures show `git unavailable`. Later refresh failures retain the last snapshot until a successful read. Polling is read-only and stops when both the panel and dashboard are closed/off.
|
|
87
179
|
|
|
88
180
|
In fullscreen TUI mode, click Copy in its title bar to copy every work and todo as Markdown, Open to run `cursor .` in the current session directory, or Minimize to collapse the panel to a small title bar. Copy and Open remain available while minimized, and Maximize restores the rows. Cursor's command-line launcher must be on PATH; launch failures produce visible error feedback. When more rows exist than fit, the floating panel starts at the newest rows; move the mouse over it and use the wheel to scroll older or newer rows without taking focus from the editor. In regular terminal mode, open `/works` to browse and copy the complete list.
|
|
89
181
|
|
|
90
|
-
Use `/works-panel minimize`, `/works-panel maximize`, or `/works-panel open` when mouse input is unavailable. Use `/works-panel widget` for a right-aligned layout above the editor that renders every row and retains the clickable title actions, `/works-panel floating` to return to the floating layout, or `/works-panel off` to hide it.
|
|
182
|
+
Use `/works-panel minimize`, `/works-panel maximize`, `/works-panel open`, or `/works-panel open-session` when mouse input is unavailable. Use `/works-panel widget` for a right-aligned layout above the editor that renders every row and retains the clickable title actions, `/works-panel floating` to return to the floating layout, or `/works-panel off` to hide it.
|
|
91
183
|
|
|
92
184
|
Run `/works` for full details. Its top border mirrors repository-wide Git status, and its top bar includes Copy, Open, and Minimize actions. In fullscreen TUI mode, click Minimize to collapse the dashboard to a top bar showing the current work and todo totals; click Maximize to restore it. The actions also have keyboard shortcuts that work in regular terminal mode.
|
|
93
185
|
|
|
94
186
|
- `c`: copy all works and todos as Markdown
|
|
95
187
|
- `o`: open the current repository/session directory in Cursor
|
|
188
|
+
- `d`: open the selected task's linked delegated agent
|
|
96
189
|
- `m`: minimize or maximize the dashboard
|
|
97
190
|
- Fullscreen left click: activate Copy, Open, Minimize, or Maximize
|
|
98
191
|
- Configured Up/Down keys: select
|