@abhishek944/pi-tasks 0.15.0 → 0.16.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.
Files changed (48) hide show
  1. package/README.md +59 -12
  2. package/dist/agents/delegation.d.ts +4 -0
  3. package/dist/agents/delegation.js +59 -0
  4. package/dist/agents/herdr.d.ts +10 -3
  5. package/dist/agents/herdr.js +39 -12
  6. package/dist/agents/links.d.ts +3 -3
  7. package/dist/agents/links.js +42 -19
  8. package/dist/auto-continue.js +160 -27
  9. package/dist/command.d.ts +2 -2
  10. package/dist/command.js +7 -3
  11. package/dist/delegated-time.d.ts +11 -0
  12. package/dist/delegated-time.js +51 -2
  13. package/dist/dependency.d.ts +7 -0
  14. package/dist/dependency.js +13 -0
  15. package/dist/durable.d.ts +38 -0
  16. package/dist/durable.js +515 -0
  17. package/dist/herdr-header.d.ts +3 -0
  18. package/dist/herdr-header.js +100 -0
  19. package/dist/herdr-panel.d.ts +7 -0
  20. package/dist/herdr-panel.js +182 -0
  21. package/dist/index.js +96 -56
  22. package/dist/markdown.js +3 -1
  23. package/dist/panel-settings.d.ts +11 -0
  24. package/dist/panel-settings.js +30 -0
  25. package/dist/snapshot.d.ts +23 -0
  26. package/dist/snapshot.js +123 -0
  27. package/dist/state.d.ts +21 -18
  28. package/dist/state.js +357 -286
  29. package/dist/thoughts.d.ts +11 -0
  30. package/dist/thoughts.js +14 -0
  31. package/dist/timing.js +2 -1
  32. package/dist/tools.js +48 -29
  33. package/dist/tracking.js +18 -11
  34. package/dist/types.d.ts +9 -2
  35. package/dist/ui/panel.js +17 -10
  36. package/dist/ui/task-view.d.ts +7 -0
  37. package/dist/ui/task-view.js +10 -0
  38. package/dist/ui/works-dashboard.js +22 -15
  39. package/docs/REFERENCE.md +56 -28
  40. package/docs/USAGE_GUIDE.md +112 -50
  41. package/herdr/pi-tasks/README.md +45 -0
  42. package/herdr/pi-tasks/header.js +192 -0
  43. package/herdr/pi-tasks/main.js +413 -0
  44. package/herdr/pi-tasks/mod.json +3 -0
  45. package/herdr/pi-tasks/spinner.svg +1 -0
  46. package/package.json +26 -1
  47. package/dist/agents/tools.d.ts +0 -3
  48. package/dist/agents/tools.js +0 -143
@@ -0,0 +1,11 @@
1
+ import type { Todo } from "./types.js";
2
+ /**
3
+ * The only task text shown in the panel and copied details. Stored ownership,
4
+ * links, artifact paths, and other taskInfo metadata are never visible.
5
+ *
6
+ * A blocked task's structured reason is the authoritative current dependency,
7
+ * so it wins over an older progress thought. Status changes clear an unsupplied
8
+ * thought in TaskState, which keeps resumed and completed tasks from showing a
9
+ * stale waiting message.
10
+ */
11
+ export declare function finalThoughtsFor(todo: Pick<Todo, "finalThoughts" | "status" | "blockedReason">): string | undefined;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The only task text shown in the panel and copied details. Stored ownership,
3
+ * links, artifact paths, and other taskInfo metadata are never visible.
4
+ *
5
+ * A blocked task's structured reason is the authoritative current dependency,
6
+ * so it wins over an older progress thought. Status changes clear an unsupplied
7
+ * thought in TaskState, which keeps resumed and completed tasks from showing a
8
+ * stale waiting message.
9
+ */
10
+ export function finalThoughtsFor(todo) {
11
+ if (todo.status === "blocked")
12
+ return todo.blockedReason?.trim() || todo.finalThoughts?.trim() || undefined;
13
+ return todo.finalThoughts?.trim() || undefined;
14
+ }
package/dist/timing.js CHANGED
@@ -41,7 +41,8 @@ export function registerTaskTiming(pi, state) {
41
41
  pi.on("session_before_fork", reset);
42
42
  pi.on("session_before_tree", reset);
43
43
  pi.on("session_shutdown", reset);
44
- // restore() discards runtime state; these only reset the lifecycle gate.
44
+ // Session resume clears running markers. Tree navigation only pauses timing;
45
+ // it never restores or rolls back session-owned task records.
45
46
  pi.on("session_start", reset);
46
47
  pi.on("session_tree", reset);
47
48
  }
package/dist/tools.js CHANGED
@@ -1,36 +1,43 @@
1
1
  import { StringEnum } from "@earendil-works/pi-ai";
2
2
  import { DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, formatSize, truncateHead } from "@earendil-works/pi-coding-agent";
3
3
  import { Type } from "typebox";
4
- import { preservePaneLink } from "./agents/links.js";
4
+ import { delegateLink, preservePaneLink } from "./agents/links.js";
5
+ import { DEPENDENCY_GUIDANCE, dependentOnLabel, TASK_DEPENDENCIES } from "./dependency.js";
5
6
  import { formatCompletion, taskCompletion, workCompletion } from "./progress.js";
7
+ import { finalThoughtsFor } from "./thoughts.js";
6
8
  import { formatTime, taskTime, workTime } from "./time.js";
7
9
  import { renderTaskCall, renderTaskResult, taskResult } from "./tool-result.js";
8
10
  import { areTrackingToolsActive } from "./tracking.js";
9
11
  const StatusSchema = StringEnum(["active", "blocked", "completed", "cancelled"]);
10
- const STATUS_GUIDANCE = "New tasks default to active. Use blocked immediately when the next step must wait for agent output, review, an external response, user input, permission, or another obstacle. Supply blockedReason when creating a blocked task or moving a task to blocked: explain the obstacle and what will allow work to resume. Unrelated blocked edits preserve the reason; leaving blocked clears it. Retain progress. Return blocked tasks to active when the dependency resolves and work resumes. Works are collections and have no status.";
12
+ const STATUS_GUIDANCE = "New tasks default to active. Use blocked only when the next step must wait for a user decision (a response, approval, or permission) or for another agent's output or review. Supply both blockedReason and dependentOn when creating a blocked task or moving a task to blocked; dependentOn accepts only \"user-decision\" or \"another-agent\". Unrelated blocked edits preserve both; leaving blocked clears both. Retain progress. Return blocked tasks to active when the dependency resolves and work resumes. Do not mark blocked for external services, tool failures, or other obstacles that fit neither category; keep the task active, preserve safety, and report the unavailable dependency truthfully. Works are collections and have no status.";
11
13
  const CompletionSchema = Type.Union([Type.Integer({ minimum: 0, maximum: 100 }), Type.Null()], {
12
- description: "AI-reported approximate task completion, not elapsed time or a status-to-percentage mapping. Use null for unknown; reserve 100 for verified completed status. Work progress is the equal average of non-cancelled tasks.",
14
+ description: "AI-reported approximate task completion, not elapsed time or a status-to-percentage mapping. Use null for unknown; reserve 100 for verified completed status. Work progress is the equal average of non-cancelled tasks. Keep visible evidence in finalThoughts only for a significant change; never narrate progress in taskInfo.",
13
15
  });
14
16
  const BlockedReasonSchema = Type.Union([Type.String({ minLength: 1, maxLength: 10_000 }), Type.Null()], {
15
- description: "Required when creating a blocked task or entering blocked status. Explain what is blocking progress and what allows work to resume. Omission preserves the current reason while blocked; leaving blocked clears it automatically.",
17
+ description: "Required with dependentOn when creating a blocked task or entering blocked status. Explain the current dependency and what will unblock it. This is the visible Final thoughts for a blocked task, so do not duplicate it in finalThoughts. Omission preserves the current reason while blocked; leaving blocked clears it automatically.",
16
18
  });
19
+ const DependencySchema = StringEnum(TASK_DEPENDENCIES, { description: DEPENDENCY_GUIDANCE });
17
20
  const NameSchema = Type.String({ minLength: 1, maxLength: 240 });
18
- const DETAILS_GUIDANCE = "Write workInfo and taskInfo in normal prose with full sentences and spaces between words. Conversational brevity modes must not compress stored records or concatenate words.";
19
- const InfoSchema = Type.String({ minLength: 1, maxLength: 10_000, description: DETAILS_GUIDANCE });
21
+ const WORK_INFO_GUIDANCE = "Write workInfo in normal prose with full sentences and spaces between words. Conversational brevity modes must not compress stored records or concatenate words.";
22
+ const TASK_INFO_GUIDANCE = "taskInfo is hidden coordination metadata for resumption: keep the owner declaration, canonical artifact paths, parent IDs, and necessary execution constraints. Do not restate the goal, narrate progress, or put visible updates there.";
23
+ const FINAL_THOUGHTS_GUIDANCE = "The only user-visible task text. Write one concise update, not a goal, history, list, or section. For a completed task, state the short actual result, the verification performed, and any remaining limits; do not omit it by habit. For an active task, update only when something significant changed; otherwise leave it unchanged with no filler. For a blocked task, blockedReason is the authoritative visible dependency; do not duplicate it. Never put owner declarations, terminal or monitor links, artifact paths, or parent IDs here.";
24
+ const WorkInfoSchema = Type.String({ minLength: 1, maxLength: 10_000, description: WORK_INFO_GUIDANCE });
25
+ const TaskInfoSchema = Type.String({ minLength: 1, maxLength: 10_000, description: TASK_INFO_GUIDANCE });
26
+ const FinalThoughtsSchema = Type.String({ description: FINAL_THOUGHTS_GUIDANCE });
20
27
  export function registerTaskTools(pi, state) {
21
28
  pi.registerTool({
22
29
  name: "WorkCreate",
23
30
  label: "WorkCreate",
24
- description: `Create a session-scoped work item. Use detailed workInfo that preserves the goal, context, scope, constraints, decisions, and expected outcome. Works are collections of tasks and have no status. ${DETAILS_GUIDANCE}`,
31
+ description: `Create a session-scoped work item. Use detailed workInfo that preserves the goal, context, scope, constraints, decisions, and expected outcome. Works are collections of tasks and have no status. ${WORK_INFO_GUIDANCE}`,
25
32
  promptSnippet: "Create a session-scoped work item before starting substantial actionable work",
26
33
  promptGuidelines: [
27
34
  "Use WorkCreate for normal requests that start new work in the main conversation; never use it during /ask or /btw.",
28
35
  "Before creating work, use WorkList to avoid duplicating an existing work item.",
29
- DETAILS_GUIDANCE,
36
+ WORK_INFO_GUIDANCE,
30
37
  ],
31
38
  parameters: Type.Object({
32
39
  workName: NameSchema,
33
- workInfo: InfoSchema,
40
+ workInfo: WorkInfoSchema,
34
41
  }, { additionalProperties: false }),
35
42
  execute(_id, params) {
36
43
  const work = state.createWork(params.workName, params.workInfo);
@@ -42,7 +49,7 @@ export function registerTaskTools(pi, state) {
42
49
  pi.registerTool({
43
50
  name: "WorkList",
44
51
  label: "WorkList",
45
- description: "List session-scoped works and their associated todos. Optional limit returns the newest N matching works after filtering, in chronological order; omitted returns all. Results include detailed workInfo and taskInfo and are truncated at 50KB or 2000 lines.",
52
+ description: "List session-scoped works and their associated todos. Optional limit returns the newest N matching works after filtering, in chronological order; omitted returns all. Results include detailed workInfo, hidden taskInfo coordination metadata, and task final thoughts, and are truncated at 50KB or 2000 lines.",
46
53
  parameters: Type.Object({
47
54
  workId: Type.Optional(Type.String()),
48
55
  limit: Type.Optional(Type.Integer({ minimum: 1, description: "Return only the newest N matching works; omit for all." })),
@@ -59,13 +66,13 @@ export function registerTaskTools(pi, state) {
59
66
  pi.registerTool({
60
67
  name: "WorkUpdate",
61
68
  label: "WorkUpdate",
62
- description: `Update a work's name or detailed information as its scope or shared context changes. Works are collections of tasks and have no status. ${DETAILS_GUIDANCE}`,
69
+ description: `Update a work's name or detailed information as its scope or shared context changes. Works are collections of tasks and have no status. ${WORK_INFO_GUIDANCE}`,
63
70
  promptSnippet: "Update work context as its scope or shared decisions change",
64
- promptGuidelines: ["Use WorkUpdate when shared scope or context changes; keep execution status on tasks with TodoUpdate. Never update tracking during /ask or /btw.", DETAILS_GUIDANCE],
71
+ promptGuidelines: ["Use WorkUpdate when shared scope or context changes; keep execution status on tasks with TodoUpdate. It is not the record for a new user request: create that request's Todo first. Never update tracking during /ask or /btw.", WORK_INFO_GUIDANCE],
65
72
  parameters: Type.Object({
66
73
  workId: Type.String(),
67
74
  workName: Type.Optional(NameSchema),
68
- workInfo: Type.Optional(InfoSchema),
75
+ workInfo: Type.Optional(WorkInfoSchema),
69
76
  }, { additionalProperties: false, minProperties: 2 }),
70
77
  execute(_id, params) {
71
78
  const work = state.updateWork(params.workId, { workName: params.workName, workInfo: params.workInfo });
@@ -77,7 +84,7 @@ export function registerTaskTools(pi, state) {
77
84
  pi.registerTool({
78
85
  name: "WorkDelete",
79
86
  label: "WorkDelete",
80
- description: "Delete a work and every associated todo from the current session branch. Use only for explicit cancellation or mistaken entries.",
87
+ description: "Delete a work and every associated todo from the current Pi session. Use only for explicit cancellation or mistaken entries.",
81
88
  parameters: Type.Object({ workId: Type.String() }, { additionalProperties: false }),
82
89
  execute(_id, params) {
83
90
  const work = state.getWork(params.workId);
@@ -93,23 +100,27 @@ export function registerTaskTools(pi, state) {
93
100
  pi.registerTool({
94
101
  name: "TodoCreate",
95
102
  label: "TodoCreate",
96
- description: `Create a todo under an existing work, optionally reporting approximate completionPercent (0 for known unstarted work, null for unknown). For longer tasks, use TodoUpdate for interim estimates after roughly 5–10 meaningful working steps or a milestone; do not wait until completion. taskInfo must contain enough detailed context, scope, constraints, expected outcome, and verification guidance to execute the task without guessing. ${STATUS_GUIDANCE} ${DETAILS_GUIDANCE}`,
97
- promptSnippet: "Create detailed todos under the current work before implementation",
103
+ description: `Create a todo under an existing work, optionally reporting approximate completionPercent (0 for known unstarted work, null for unknown). For longer tasks, use TodoUpdate for interim estimates after roughly 5–10 meaningful working steps or a milestone; do not wait until completion. taskInfo must contain the required hidden coordination metadata and is never shown; finalThoughts is the only user-visible task text. ${STATUS_GUIDANCE} ${TASK_INFO_GUIDANCE} ${FINAL_THOUGHTS_GUIDANCE}`,
104
+ promptSnippet: "Create a todo for each distinct new actionable request before work",
98
105
  promptGuidelines: [
99
106
  "Use TodoCreate only under an existing work and only for actionable main-conversation work; never use it during /ask or /btw.",
100
- "Keep taskInfo detailed, current, and self-contained. completionPercent is optional; estimate from actual progress, use null when unknown, and do not infer partial completion just from status. For longer tasks, report interim estimates through TodoUpdate after roughly 5–10 meaningful working steps or a milestone.",
101
- DETAILS_GUIDANCE,
107
+ "Create a Todo for each distinct new actionable user request, including one added to an existing Work; reuse an existing Todo only when it owns the same outcome. Do not create one for each sentence, clarification, check, or tool call.",
108
+ "Keep taskInfo to hidden coordination metadata and finalThoughts to the visible update. completionPercent is optional; estimate from actual progress, use null when unknown, and do not infer partial completion just from status. For longer tasks, report interim estimates through TodoUpdate after roughly 5–10 meaningful working steps or a milestone.",
109
+ TASK_INFO_GUIDANCE,
110
+ FINAL_THOUGHTS_GUIDANCE,
102
111
  ],
103
112
  parameters: Type.Object({
104
113
  workId: Type.String(),
105
114
  taskName: NameSchema,
106
- taskInfo: InfoSchema,
115
+ taskInfo: TaskInfoSchema,
116
+ finalThoughts: Type.Optional(FinalThoughtsSchema),
107
117
  blockedReason: Type.Optional(BlockedReasonSchema),
118
+ dependentOn: Type.Optional(DependencySchema),
108
119
  status: Type.Optional(StatusSchema),
109
120
  completionPercent: Type.Optional(CompletionSchema),
110
121
  }, { additionalProperties: false }),
111
122
  execute(_id, params) {
112
- const todo = state.createTodo(params.workId, params.taskName, params.taskInfo, params.status, params.completionPercent, params.blockedReason);
123
+ const todo = state.createTodo({ workId: params.workId, taskName: params.taskName, taskInfo: params.taskInfo, finalThoughts: params.finalThoughts, status: params.status, completionPercent: params.completionPercent, blockedReason: params.blockedReason, dependentOn: params.dependentOn });
113
124
  return Promise.resolve(taskResult(`Created todo ${todo.taskId} under ${todo.workId}: ${todo.taskName} · ${formatCompletion(taskCompletion(todo))} [${todo.status}]`, "todo-create", { taskId: todo.taskId, workId: todo.workId, completionPercent: taskCompletion(todo) }));
114
125
  },
115
126
  renderCall: renderTaskCall("TodoCreate"),
@@ -118,7 +129,7 @@ export function registerTaskTools(pi, state) {
118
129
  pi.registerTool({
119
130
  name: "TodoList",
120
131
  label: "TodoList",
121
- description: "List todos by task, work, or status. Optional limit returns the newest N matching todos after filtering, in chronological order; omitted returns all. Results include detailed taskInfo and are truncated at 50KB or 2000 lines.",
132
+ description: "List todos by task, work, or status. Optional limit returns the newest N matching todos after filtering, in chronological order; omitted returns all. Results include hidden taskInfo coordination metadata and visible final thoughts, and are truncated at 50KB or 2000 lines.",
122
133
  parameters: Type.Object({
123
134
  taskId: Type.Optional(Type.String()),
124
135
  workId: Type.Optional(Type.String()),
@@ -137,14 +148,16 @@ export function registerTaskTools(pi, state) {
137
148
  pi.registerTool({
138
149
  name: "TodoUpdate",
139
150
  label: "TodoUpdate",
140
- description: `Update a todo's name, detailed information, status, completionPercent, or working selection. Set working=true immediately before working on an active owner: self task; it pauses any previously selected task. Set working=false to pause without changing status. Timing is calculated automatically, never estimated. Re-select with working=true on each fresh run. Delegated agents time their own local tasks; never select a parent delegate task. For longer tasks, include an optional completionPercent estimate after roughly 5–10 meaningful working steps or a milestone, not just at completion or in status-only updates. Explain evidence and remaining work in taskInfo; use null when unknown and never increase a percentage without evidence. Blocking retains progress. Reserve completed/100 for verified completion. ${STATUS_GUIDANCE} ${DETAILS_GUIDANCE}`,
141
- promptSnippet: "Keep todo status and detailed context synchronized with active work",
142
- promptGuidelines: ["Use TodoUpdate with working=true immediately before working on an active owner: self task, including when resuming on a fresh run. Use working=false when pausing without a status change. Only one local task is timed; runtime idle and user waits pause automatically. Never update tracking during /ask or /btw.", "During longer tasks, include an evidence-based completionPercent estimate after roughly 5–10 meaningful working steps or a milestone; do not wait until completion or only update status. Estimates remain optional: use null when unknown, and leave a percentage unchanged if there is no new evidence. Explain evidence and remaining work in taskInfo; only verified completed tasks may reach 100. Work completion is calculated automatically from tasks.", DETAILS_GUIDANCE],
151
+ description: `Update a todo's name, hidden coordination metadata, visible final thoughts, status, completionPercent, or working selection. Set working=true immediately before working on an active owner: self task; it pauses any previously selected task. Set working=false to pause without changing status. Timing is calculated automatically, never estimated. Re-select with working=true on each fresh run. Delegated agents time their own local tasks; never select a parent delegate task. For longer tasks, include an optional completionPercent estimate after roughly 5–10 meaningful working steps or a milestone, not just at completion or in status-only updates. Use finalThoughts for significant visible evidence; use null when unknown and never increase a percentage without evidence. A status change clears an unsupplied thought, so state the new dependency through blockedReason or the completed verified result. Blocking retains progress. Reserve completed/100 for verified completion. ${STATUS_GUIDANCE} ${TASK_INFO_GUIDANCE} ${FINAL_THOUGHTS_GUIDANCE} Completing a delegate task with a still-linked Core worker returns a cleanup advisory only; it never sends commands or changes worker state.`,
152
+ promptSnippet: "Keep todo status and visible final thoughts synchronized with active work",
153
+ promptGuidelines: ["Use TodoUpdate with working=true immediately before working on an active owner: self task, including when resuming on a fresh run. Use working=false when pausing without a status change. Only one local task is timed; runtime idle and user waits pause automatically. Never update tracking during /ask or /btw.", "A completion cleanup advisory is informational only. Decide whether a real follow-up dependency remains; never treat it as permission to send /close, interrupt, or close a worker.", "Do not rename or broaden an existing Todo to absorb a distinct new user request; create a new Todo for it.", "During longer tasks, include an evidence-based completionPercent estimate after roughly 5–10 meaningful working steps or a milestone; do not wait until completion or only update status. Estimates remain optional: use null when unknown, and leave a percentage unchanged if there is no new evidence. Explain evidence in finalThoughts only when it is significant; only verified completed tasks may reach 100. Work completion is calculated automatically from tasks.", TASK_INFO_GUIDANCE, FINAL_THOUGHTS_GUIDANCE],
143
154
  parameters: Type.Object({
144
155
  taskId: Type.String(),
145
156
  taskName: Type.Optional(NameSchema),
146
- taskInfo: Type.Optional(InfoSchema),
157
+ taskInfo: Type.Optional(TaskInfoSchema),
158
+ finalThoughts: Type.Optional(FinalThoughtsSchema),
147
159
  blockedReason: Type.Optional(BlockedReasonSchema),
160
+ dependentOn: Type.Optional(DependencySchema),
148
161
  status: Type.Optional(StatusSchema),
149
162
  completionPercent: Type.Optional(CompletionSchema),
150
163
  working: Type.Optional(Type.Boolean({ description: "Select this active owner: self task for automatic timing, or pause it. Selection switches away from the previously timed task. No timestamps or duration estimates are accepted." })),
@@ -152,9 +165,12 @@ export function registerTaskTools(pi, state) {
152
165
  execute(_id, params) {
153
166
  if (params.working !== undefined && !areTrackingToolsActive(pi))
154
167
  throw new Error("Task timing is available only in tracked main-conversation work, not /ask or /btw.");
155
- const taskInfo = params.taskInfo === undefined ? undefined : preservePaneLink(state.getTodo(params.taskId)?.taskInfo ?? "", params.taskInfo);
156
- const todo = state.updateTodo(params.taskId, { taskName: params.taskName, taskInfo, status: params.status, blockedReason: params.blockedReason, completionPercent: params.completionPercent, working: params.working });
157
- return Promise.resolve(taskResult(`Updated todo ${todo.taskId}: ${todo.taskName} · ${formatCompletion(taskCompletion(todo))} · ${formatTime(taskTime(todo))}${todo.workingSince === undefined ? "" : " running"} [${todo.status}]`, "todo-update", { taskId: todo.taskId, workId: todo.workId, completionPercent: taskCompletion(todo), elapsedMs: taskTime(todo), working: todo.workingSince !== undefined }));
168
+ const previous = state.getTodo(params.taskId);
169
+ const taskInfo = params.taskInfo === undefined ? undefined : preservePaneLink(previous?.taskInfo ?? "", params.taskInfo);
170
+ const todo = state.updateTodo(params.taskId, { taskName: params.taskName, taskInfo, finalThoughts: params.finalThoughts, status: params.status, blockedReason: params.blockedReason, dependentOn: params.dependentOn, completionPercent: params.completionPercent, working: params.working });
171
+ const completedTransition = previous?.status !== "completed" && todo.status === "completed";
172
+ const cleanupTerminalId = completedTransition ? delegateLink(todo.taskInfo)?.terminalId : undefined;
173
+ return Promise.resolve(taskResult(`Updated todo ${todo.taskId}: ${todo.taskName} · ${formatCompletion(taskCompletion(todo))} · ${formatTime(taskTime(todo))}${todo.workingSince === undefined ? "" : " running"} [${todo.status}]`, "todo-update", { taskId: todo.taskId, workId: todo.workId, status: todo.status, completionPercent: taskCompletion(todo), elapsedMs: taskTime(todo), working: todo.workingSince !== undefined, completedTransition, ...(cleanupTerminalId === undefined ? {} : { cleanupTerminalId }) }));
158
174
  },
159
175
  renderCall: renderTaskCall("TodoUpdate"),
160
176
  renderResult: renderTaskResult,
@@ -187,7 +203,10 @@ function formatWorks(works) {
187
203
  function formatTodos(todos) {
188
204
  if (todos.length === 0)
189
205
  return "No todos found.";
190
- return todos.map((todo) => `${todo.taskId} [${todo.status}] ${todo.taskName} · ${formatCompletion(taskCompletion(todo))} · Time: ${formatTime(taskTime(todo))}${todo.workingSince === undefined ? "" : " (running)"}\nWork: ${todo.workId}${todo.status === "blocked" ? `\nBlocked reason: ${todo.blockedReason ?? "No reason recorded."}` : ""}\nTask info:\n${todo.taskInfo}`).join("\n\n");
206
+ return todos.map((todo) => {
207
+ const dependency = dependentOnLabel(todo.dependentOn);
208
+ return `${todo.taskId} [${todo.status}] ${todo.taskName} · ${formatCompletion(taskCompletion(todo))} · Time: ${formatTime(taskTime(todo))}${todo.workingSince === undefined ? "" : " (running)"}\nWork: ${todo.workId}\nFinal thoughts:\n${finalThoughtsFor(todo) ?? "None recorded."}\n${dependency === undefined ? "" : `Dependent on: ${dependency}\n`}Task info (hidden coordination metadata):\n${todo.taskInfo}`;
209
+ }).join("\n\n");
191
210
  }
192
211
  function bounded(text) {
193
212
  const result = truncateHead(text, { maxBytes: DEFAULT_MAX_BYTES, maxLines: DEFAULT_MAX_LINES });
package/dist/tracking.js CHANGED
@@ -2,8 +2,11 @@ const REQUIRED_TRACKING_TOOLS = ["WorkCreate", "WorkList", "WorkUpdate", "TodoCr
2
2
  const TRACKING_GUIDANCE = `[SESSION COORDINATION]
3
3
  Work is a collection of tasks with shared context and no status of its own. A todo is a concrete step that belongs to a work and owns its execution status. A monitor runs one long-lived background command. A loop schedules a future, recurring, event-driven, or idle continuation.
4
4
 
5
- For every normal user request that starts or continues work, keep the session's work and todo records synchronized. Do not skip tracking because the work looks small.
6
- Write workInfo and taskInfo in normal prose with full sentences and spaces between words. Conversational brevity modes must not compress stored records or concatenate words.
5
+ Tasks belong only to the Pi session ID. Conversation branch navigation never rolls back task records; a new session ID starts a separate store.
6
+ For every normal user request that starts or continues work, keep the session's work and todo records synchronized. Treat each distinct new actionable request as its own outcome: before starting or delegating it, create its own Todo under the relevant Work, or a new Work when the outcome is separate, even when the request extends an existing Work. Do not record a new request only by broadening workInfo, renaming an existing Todo, or blocking a previous Todo. Reuse an active Todo only when it genuinely owns the same outcome; do not create a Todo for each sentence, clarification, check, or tool call. Do not skip tracking because the work looks small. Plain conversation and clarification need no Todo, and /ask and /btw remain outside tracking.
7
+ Write workInfo in normal prose with full sentences and spaces between words. Conversational brevity modes must not compress stored records or concatenate words. taskInfo is hidden coordination metadata; finalThoughts is the only user-visible task text.
8
+
9
+ Each task's finalThoughts is the only text shown in the task panel and copied details. Write one concise update, never a goal restatement, ownership rationale, history, list, or section. For a blocked task, blockedReason is the authoritative visible dependency and what will unblock it; do not duplicate it in finalThoughts. A blocked task also requires dependentOn="user-decision" for a user response, decision, or permission, or dependentOn="another-agent" for another agent's output or review; task details show it beside Final thoughts. For a completed task, state the short actual result, the verification performed, and any remaining limits; do not omit it by habit. For an active task, update only when something significant changed; otherwise leave the thought unchanged rather than adding filler. Keep owner declarations, terminal/monitor links, artifact paths, and parent IDs in taskInfo, never in finalThoughts.
7
10
 
8
11
  Every delegated subagent, at every delegation depth, must use these tools to create or resume its own session-local Work and Todos before assigned work. Do not begin assigned work without a real workId and an active taskId for the current step. Keep these records current and return the IDs with results, checks, and blockers. Parent assignment IDs are context, not shared records: IDs are session-scoped. Record the parent assignment in the worker's details; do not mutate the parent's session records. Include this requirement in every subagent prompt. If tracking tools or IDs are unavailable, report the blocker and do not begin delegated work; a parent-owned Todo or Markdown checklist is not a substitute. Do not invent IDs or backdate tracking. This is an instruction, not a runtime enforcement hook, and does not change the /ask or /btw exceptions.
9
12
 
@@ -12,25 +15,26 @@ Shared workflow contract:
12
15
  - Before execution, read the full current sessionId through the agent's own shell tool using printf '%s\\n' "$PI_SESSION_ID". Require a nonempty safe component matching [A-Za-z0-9][A-Za-z0-9_-]* and real tool-returned Work/Task IDs. Missing tools, identity, or IDs block execution; never substitute the parent's identity or invent IDs. Reading instructions, obtaining identity, and establishing tracking are startup steps.
13
16
  - Root task artifacts use repository-relative var/<sessionId>/<workId>/<taskId>/, not system /var/. A delegated worker appends its own <childSessionId>/<childWorkId>/<childTaskId>/ beneath the exact parentTaskDir supplied in its assignment, recursively. Keep resolved paths inside the repository's var/, including through symlinks. Record canonical paths and parent IDs in taskInfo, pass them unchanged in handoffs, and return them with results. Validate ownership before reuse after resume or branch navigation; do not overwrite artifacts just because numeric IDs match. Create artifacts only when useful; feature names are descriptions, not path keys. Do not migrate existing artifacts implicitly. Follow implement for the detailed contract and report incompatible helper paths rather than inventing arguments.
14
17
  - For every task, start taskInfo with owner: self or owner: delegate followed by a short reason before execution. Preserve this explicit declaration when updating taskInfo; the panel reads this line to show the ownership badge, with unassigned for missing or conflicting decisions. Delegate only when scope/acceptance criteria are clear, ownership can be isolated, inputs and prerequisites are ready, and useful parallelism or expertise outweighs startup and integration costs. Respect skill-specific delegation restrictions and required tracking/monitor tools. Keep small, tightly coupled, shared-interface, or expensive-to-explain work with one owner. Delegating agents retain responsibility for monitoring, integration, verification, and cleanup; children apply the same rule when allowed to delegate. No arbitrary worker, file-count, or depth thresholds.
15
- - Herdr subagent root panes are named exactly with the parent's delegated Task ID, such as T34, with no brackets, descriptions, Work IDs, or other prefixes. This is a display label, not the child's session or local Task ID. Use returned resource IDs for lifecycle operations because pane names can repeat across sessions; rename an owned worker pane when assigning it a different parent Todo.
16
- - Prefer pi-tasks AgentCreate/List/Status/Output/Send/Interrupt/Close/Focus CLI wrappers for supported Herdr operations; use CLI only for unavailable capabilities. AgentCreate takes an existing owner: delegate task, canonical taskDir, explicit model flags and onSignal/optional onDone instructions, creates the pane and monitor, automatically links the delegate badge, and marks the parent task blocked while awaiting the worker. It does not send work: confirm MonitorList shows subscription ready, then AgentSend the returned assignment to the actual paneId. Follow-ups keep that same monitor/callbacks. onSignal handles worker state changes; onDone means the monitor process ended, not the task finished. Do not add duplicate monitors, infer completion from signals or close workers before follow-ups finish. Use AgentClose only with paneId/monitorId values for resources you created. Wrappers assume panes are not repurposed and add no registry, process checks or automatic recovery.
17
- - Pi-tasks owns task records/progress and task-owned agent tool orchestration; implement owns coordination and artifact paths; Herdr owns panes/processes and pi-loop-monitor owns supervision. The shared skill/path guidance is instruction-only, not automatic cross-session shared records; Agent tools simply wrap the CLI and existing monitor tools. Plain conversation, /ask, and /btw remain outside this workflow.
18
+ - Workers are Core-only by default and need no Herdr app, space, tab or adoption label. When the user or the active harness explicitly requires a visible worker, that Core subagent has its own Herdr app tab named exactly with the parent's delegated Task ID, such as T34, with no brackets, descriptions, Work IDs or prefixes; request it with pi-herdr AgentCreate present:true and use the actual returned terminalId/tabId values because task labels repeat across parent sessions. This is a tab display label, not a terminal address or the child's session/Task identity. Rename the owned tab if assigning a different parent Todo. Never substitute a hidden worker when presentation was explicitly required, and do not split a shared tab.
19
+ - Prefer pi-herdr AgentCreate/Resume/List/Status/Output/Send/Interrupt/Close/Focus for Core operations; use hc only for unavailable process capabilities and herdr-app only for requested presentation and focus. Never use the retired herdr TUI CLI or require HERDR_ENV. AgentCreate verifies the real HC_TERMINAL_ID parent, starts interactive Pi with explicit model flags (Core-only, or in its own task-named visible app tab when presentation is requested), checks Pi readiness, registers a readiness-verified MonitorCreate with hcTerminalId, links the delegate badge and blocks the parent task. It sends no work: confirm MonitorList shows Core subscription ready, then AgentSend the returned assignment to terminalId. Follow-ups retain that monitor/callbacks. onSignal handles worker changes; onDone means the subscription process ended, not task completion. Do not add duplicate monitors, infer completion from signals or close workers before follow-ups finish. A post-launch AgentCreate failure returns structured partial handles; call AgentResume for that same terminal once it is idle, and never relaunch a replacement. AgentResume validates ownership and reuses or replaces exactly one Core subscription before relinking timing. Use AgentClose with terminalId and the monitorId when present; a partial worker with no monitor needs only terminalId. No registry or automatic recovery is added.
20
+ - Pi-tasks owns task records/progress, timing, and delegation metadata; pi-herdr owns the Agent tools and lifecycle orchestration; implement owns coordination and artifact paths; Core owns terminals/processes, Herdr app owns requested presentation and focus, and pi-loop-monitor owns supervision. The shared skill/path guidance is instruction-only, not automatic cross-session shared records; Agent tools simply wrap the CLI and existing monitor tools. Plain conversation, /ask, and /btw remain outside this workflow.
18
21
 
19
22
  Before implementation, investigation, or any other requested work:
20
23
  1. Use WorkList and TodoList to find the relevant existing records and avoid duplicates.
21
24
  2. If no suitable work exists, create one with WorkCreate. Otherwise use WorkUpdate when its scope or shared context needs refreshing.
22
- 3. Create or update the work's todos so they match the requested scope. Works have no status. New todos default to active; task statuses are active, blocked, completed, and cancelled. Keep taskInfo detailed and self-contained.
25
+ 3. Create a Todo for each distinct new actionable request, or update an existing Todo that already owns the same outcome; adding a request to an existing Work never makes it part of an existing Todo. Works have no status. New todos default to active; task statuses are active, blocked, completed, and cancelled. Keep taskInfo to hidden coordination metadata and set concise finalThoughts for visible updates.
23
26
  4. Mark the todo being attempted active with TodoUpdate before doing that work. For an owner: self task, include working=true to select it for automatic time measurement on every fresh run. Only one local task can be timed; selecting another pauses the previous one. Use working=false when pausing without changing status. Idle, blocking user prompts, and terminal statuses pause automatically. Delegated agents time their own local tasks; a parent delegate record is not a running local task. AgentCreate provides a timing reportPath: workers pause or complete assignment tasks and call TaskTimeExport with that path and all assignment-local taskIds before returning. The parent calls TaskTimeImport for its delegated task after worker output is available, before closing the agent. Follow-ups re-export the cumulative assignment task set and re-import. Import nested delegate time before exporting to your own caller. These tools read measured values; never hand-write timing reports or estimate or submit durations.
24
27
  5. completionPercent on TodoCreate/TodoUpdate is optional. When estimating, use an approximate integer from 0 to 100 based on actual work and verification, not elapsed time or a fixed mapping from status. Use 0 for genuinely unstarted tasks and null when unknown. Never invent progress to make a work look further along.
25
28
 
26
29
  During and after the attempt:
27
30
  - When available, use MonitorCreate only when a command should continue in the background; inspect it with MonitorList and do not poll it with shell sleep loops.
28
31
  - When available, use LoopCreate only when work needs a future or repeated wake. Do not create a loop for ordinary synchronous work.
29
- - A loop or monitor does not replace task status. Mark a task blocked immediately when its next step must wait for another agent’s output, review, an external response, user input, permission, or another obstacle. Supply blockedReason when creating a blocked task or entering blocked status, explaining the dependency and what will unblock it; preserve its progress. Unrelated edits preserve the current reason; leaving blocked clears it automatically. Parent delegated tasks stay blocked while awaiting worker output; the worker's own local tasks may be active. AgentCreate marks the parent task blocked automatically after successful creation. For manual delegation, mark the parent task blocked explicitly. When the dependency resolves and work resumes, mark the affected tasks active and update their context.
30
- - During longer tasks, include an evidence-based completionPercent estimate in TodoUpdate after roughly 5–10 meaningful working steps or a milestone. Do not wait until completion or only update status when an estimate is possible. 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. Keep estimates current, including after scope changes. Work completion is derived as the equal average of non-cancelled task percentages; any unknown child makes it unknown. Do not set an independent work percentage.
31
- - Mark the todo completed, blocked, or cancelled as appropriate and update taskInfo with important current context. Only use completed/100 after verification. Blocking retains the last percentage; it does not erase completed effort. Reopening a completed task needs a fresh estimate (otherwise it becomes unknown).
32
+ - Waiting has an owner and a wake. A real delegated agent keeps its parent task blocked with dependentOn="another-agent" and one continuous Core monitor (hcTerminalId); a state change is a cue to inspect fresh output, and done or idle is not completion proof. A long command keeps its task active with owner: self and uses a monitor onDone wake; it is not blocked merely because a process is running. An external service, failed tool, or missing access keeps the task active and is reported with its concrete dependency, never mislabelled as a user decision or agent output. Do not poll on a timer, add one-shot waits, retry unchanged work, or write repeat updates that only restate waiting. A stopped or unchanged loop iteration is normal: for a dynamic loop, update it once; fixed cron/event loops persist normally and need no update. Continue only with remaining work and finish cleanly when the stop condition is met.
33
+ - A loop or monitor does not replace task status. Mark a task blocked only when its next step waits for a user decision or another agent's output or review. Supply both blockedReason and dependentOn when creating a blocked task or entering blocked status; dependentOn must be exactly "user-decision" or "another-agent". Explain the current dependency and what will unblock it; preserve progress. blockedReason is the visible Final thoughts for a blocked task, so do not duplicate it in finalThoughts. Unrelated blocked edits preserve both fields; leaving blocked clears both. Do not mark a task blocked for external services, tool failures, or other obstacles that fit neither category: continue safe work and report the unavailable dependency truthfully instead of misclassifying it. Parent delegated tasks stay blocked while awaiting worker output; the worker's own local tasks may be active. AgentCreate marks the parent task blocked automatically with dependentOn="another-agent". For manual delegation, mark the parent task blocked explicitly. When the dependency resolves and work resumes, mark the affected tasks active and state the new significant update if there is one; a status change clears an unsupplied stale thought.
34
+ - During longer tasks, include an evidence-based completionPercent estimate in TodoUpdate after roughly 5–10 meaningful working steps or a milestone. Do not wait until completion or only update status when an estimate is possible. When a change is significant, explain the visible evidence and remaining work in finalThoughts; never narrate progress in taskInfo and do not add filler on every estimate. Estimates remain optional: use null when unknown, and leave a percentage unchanged if there is no new evidence. Keep estimates current, including after scope changes. Work completion is derived as the equal average of non-cancelled task percentages; any unknown child makes it unknown. Do not set an independent work percentage.
35
+ - Mark the todo completed, blocked, or cancelled as appropriate. Only use completed/100 after verification. On completion, set finalThoughts to the short actual result, checks performed, and remaining limits. Blocking retains the last percentage; it does not erase completed effort. Reopening a completed task needs a fresh estimate (otherwise it becomes unknown). Update taskInfo only when coordination metadata changes.
32
36
  - Percentages are approximate completion, not ETA or proof. Never change task statuses merely because a percentage looks complete.
33
- - Work is only a collection: never assign it active, blocked, completed, or cancelled status. Track every executable step as a todo; empty works do not trigger continuation. Automatic continuation checks active todos across all works on the current session branch; blocked, completed, and cancelled tasks do not trigger it. Update workInfo only when shared scope, context, or decisions change.
37
+ - Work is only a collection: never assign it active, blocked, completed, or cancelled status. Track every executable step as a todo; empty works do not trigger continuation. Automatic continuation checks active todos across all works in the current Pi session; blocked, completed, and cancelled tasks do not trigger it. Update workInfo only when shared scope, context, or decisions change.
34
38
  - Never create or update works, todos, loops, or monitors during /ask, /btw, or any BTW side thread.`;
35
39
  export function areTrackingToolsActive(pi) {
36
40
  const active = new Set(pi.getActiveTools());
@@ -40,6 +44,9 @@ export function registerTrackingGuidance(pi) {
40
44
  pi.on("before_agent_start", (event) => {
41
45
  if (!areTrackingToolsActive(pi))
42
46
  return;
43
- return { systemPrompt: `${event.systemPrompt}\n\n${TRACKING_GUIDANCE}` };
47
+ const options = event.systemPromptOptions;
48
+ options.appendSystemPrompt = options.appendSystemPrompt
49
+ ? `${options.appendSystemPrompt}\n\n${TRACKING_GUIDANCE}`
50
+ : TRACKING_GUIDANCE;
44
51
  });
45
52
  }
package/dist/types.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import type { TaskDependency } from "./dependency.js";
2
+ export type { TaskDependency } from "./dependency.js";
1
3
  export type TodoStatus = "active" | "blocked" | "completed" | "cancelled";
2
4
  export interface Work {
3
5
  workId: string;
@@ -16,15 +18,20 @@ export interface Todo {
16
18
  taskId: string;
17
19
  workId: string;
18
20
  taskName: string;
21
+ /** Hidden coordination metadata: owner declaration, artifact paths, parent IDs, identifiers. Never shown as task text. */
19
22
  taskInfo: string;
23
+ /** The only visible task text. Concise status update, not a goal or narrative. */
24
+ finalThoughts?: string;
20
25
  status: TodoStatus;
21
26
  /** Current obstacle and resume condition; cleared when leaving blocked. */
22
27
  blockedReason?: string | null;
28
+ /** The only two valid blocked dependencies; absent on nonblocked and legacy tasks. */
29
+ dependentOn?: TaskDependency;
23
30
  completionPercent?: number | null;
24
31
  /** Accumulated measured time; missing/null means historical time is unknown. */
25
32
  elapsedMs?: number | null;
26
33
  delegatedTimes?: DelegatedTime[];
27
- /** Current interval start, exposed only in live snapshots, never restored. */
34
+ /** Current interval start in the shared snapshot; cleared on process resume. */
28
35
  workingSince?: number;
29
36
  createdAt: number;
30
37
  updatedAt: number;
@@ -58,7 +65,7 @@ export type TaskEvent = {
58
65
  type: "todo-updated";
59
66
  at: number;
60
67
  taskId: string;
61
- patch: Partial<Pick<Todo, "taskName" | "taskInfo" | "status" | "blockedReason" | "completionPercent">>;
68
+ patch: Partial<Pick<Todo, "taskName" | "taskInfo" | "finalThoughts" | "status" | "blockedReason" | "dependentOn" | "completionPercent">>;
62
69
  } | {
63
70
  version: 1;
64
71
  type: "todo-time";
package/dist/ui/panel.js CHANGED
@@ -1,13 +1,14 @@
1
1
  import { stripVTControlCharacters } from "node:util";
2
2
  import { copyToClipboard } from "@earendil-works/pi-coding-agent";
3
3
  import { sliceByColumn, truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
4
- import { delegateLink, focusPane } from "../agents/links.js";
4
+ import { delegateLink, focusTerminal } from "../agents/links.js";
5
5
  import { formatWorksMarkdown } from "../markdown.js";
6
6
  import { openRepository, openSession } from "../open-repository.js";
7
7
  import { taskOwner } from "../ownership.js";
8
8
  import { formatCompletion, taskCompletion, workCompletion } from "../progress.js";
9
9
  import { safeSingleLine } from "../text.js";
10
10
  import { formatTime, taskTime, workTime } from "../time.js";
11
+ import { readTaskView } from "./task-view.js";
11
12
  const EMPTY_COMPONENT = { render: () => [], invalidate: () => { } };
12
13
  const PROGRESS_VALUE_WIDTH = 4;
13
14
  const TIME_VALUE_WIDTH = 8;
@@ -23,7 +24,7 @@ export class TasksPanelHost {
23
24
  panel;
24
25
  handle;
25
26
  ui;
26
- mode = "floating";
27
+ mode = "off";
27
28
  minimized = false;
28
29
  cwd = "";
29
30
  sessionId = "Session unavailable";
@@ -155,12 +156,17 @@ class TasksPanel {
155
156
  this.setVisible(width >= 48);
156
157
  if (width < 48)
157
158
  return [];
158
- const works = this.state.listWorks();
159
+ const { works, error } = readTaskView(this.state);
160
+ const todos = works.flatMap((work) => work.tasks);
159
161
  const boxWidth = this.placement === "floating" ? width : Math.min(54, Math.max(48, Math.floor(width * 0.44)));
160
162
  const innerWidth = boxWidth - 2;
161
163
  const leftPad = this.placement === "widget" ? " ".repeat(Math.max(0, width - boxWidth)) : "";
164
+ if (error) {
165
+ this.copyHitRegion = this.sessionHitRegion = this.openHitRegion = this.toggleHitRegion = undefined;
166
+ return [border(innerWidth, "top", this.theme), frame(this.theme.fg("error", "Tasks unavailable"), innerWidth, this.theme), frame(truncateToWidth(error, innerWidth, "…"), innerWidth, this.theme), border(innerWidth, "bottom", this.theme)].map((line) => `${leftPad}${line}`);
167
+ }
162
168
  if (this.minimized) {
163
- const header = this.renderHeader(innerWidth, leftPad.length);
169
+ const header = this.renderHeader(innerWidth, leftPad.length, todos);
164
170
  return [
165
171
  gitBorder(innerWidth, this.theme, this.git.getSnapshot()),
166
172
  frame(header, innerWidth, this.theme),
@@ -211,7 +217,7 @@ class TasksPanel {
211
217
  const suffix = this.placement === "floating" && hasOverflow
212
218
  ? this.tui.mode === "fullscreen" ? ` · ${range}` : ` · ${range} · latest · /works for all`
213
219
  : "";
214
- const header = this.renderHeader(innerWidth, leftPad.length, suffix);
220
+ const header = this.renderHeader(innerWidth, leftPad.length, todos, suffix);
215
221
  const lines = [
216
222
  gitBorder(innerWidth, this.theme, this.git.getSnapshot()),
217
223
  frame(header, innerWidth, this.theme),
@@ -277,7 +283,8 @@ class TasksPanel {
277
283
  if (visible) {
278
284
  this.unsubscribeGit ??= this.git.subscribe(() => this.tui.requestRender());
279
285
  this.refreshTimer ??= setInterval(() => {
280
- if (!this.minimized && this.state.listTodos().some((todo) => todo.workingSince !== undefined))
286
+ const view = readTaskView(this.state);
287
+ if (view.error || (!this.minimized && view.works.some((work) => work.tasks.some((todo) => todo.workingSince !== undefined))))
281
288
  this.tui.requestRender();
282
289
  }, 1_000);
283
290
  this.refreshTimer.unref?.();
@@ -296,9 +303,9 @@ class TasksPanel {
296
303
  this.onMinimizedChange(minimized);
297
304
  this.tui.requestRender();
298
305
  }
299
- renderHeader(width, leftPadWidth, suffix = "") {
306
+ renderHeader(width, leftPadWidth, todos, suffix = "") {
300
307
  const counts = { active: 0, blocked: 0, completed: 0, cancelled: 0 };
301
- for (const todo of this.state.listTodos())
308
+ for (const todo of todos)
302
309
  counts[todo.status]++;
303
310
  const statuses = ["blocked", "active", "completed", "cancelled"];
304
311
  const summary = statuses.filter((status) => counts[status] > 0)
@@ -334,7 +341,7 @@ class TasksPanel {
334
341
  return;
335
342
  this.openingDelegate = true;
336
343
  try {
337
- await focusPane(link.paneId, this.cwd);
344
+ await focusTerminal(link.terminalId, this.cwd);
338
345
  }
339
346
  catch (error) {
340
347
  const reason = error instanceof Error ? safeSingleLine(error.message) : "Unknown error.";
@@ -375,8 +382,8 @@ class TasksPanel {
375
382
  return;
376
383
  this.copying = true;
377
384
  this.tui.requestRender();
378
- const works = this.state.listWorks();
379
385
  try {
386
+ const works = this.state.listWorks();
380
387
  await copyToClipboard(formatWorksMarkdown(works));
381
388
  const todoCount = works.reduce((total, work) => total + work.tasks.length, 0);
382
389
  this.notify(`Copied ${works.length} work${works.length === 1 ? "" : "s"} and ${todoCount} todo${todoCount === 1 ? "" : "s"} as Markdown.`, "info");
@@ -0,0 +1,7 @@
1
+ import type { TaskState } from "../state.js";
2
+ import type { WorkWithTodos } from "../types.js";
3
+ /** Disk failures belong in the view, never in the terminal render/timer exception path. */
4
+ export declare function readTaskView(state: TaskState): {
5
+ works: WorkWithTodos[];
6
+ error?: string;
7
+ };
@@ -0,0 +1,10 @@
1
+ import { safeSingleLine } from "../text.js";
2
+ /** Disk failures belong in the view, never in the terminal render/timer exception path. */
3
+ export function readTaskView(state) {
4
+ try {
5
+ return { works: state.listWorks() };
6
+ }
7
+ catch (error) {
8
+ return { works: [], error: safeSingleLine(error instanceof Error ? error.message : "Task storage is unavailable.") };
9
+ }
10
+ }
@@ -1,12 +1,15 @@
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
+ import { delegateLink, focusTerminal } from "../agents/links.js";
4
+ import { dependentOnLabel } from "../dependency.js";
4
5
  import { formatWorksMarkdown } from "../markdown.js";
5
6
  import { openRepository } from "../open-repository.js";
6
7
  import { formatCompletion, taskCompletion, workCompletion } from "../progress.js";
7
8
  import { safeMultiline, safeSingleLine } from "../text.js";
9
+ import { finalThoughtsFor } from "../thoughts.js";
8
10
  import { formatTime, taskTime, workTime } from "../time.js";
9
11
  import { border, delegateHitRegion, frame, gitBorder, metricsColumn, metricsHeader, ownerBadge, recordId, rule, todoIcon } from "./panel.js";
12
+ import { readTaskView } from "./task-view.js";
10
13
  const CHROME_LINES = 9;
11
14
  export class WorksDashboard {
12
15
  tui;
@@ -65,7 +68,9 @@ export class WorksDashboard {
65
68
  this.toggleHitRegion = undefined;
66
69
  const dialogWidth = Math.max(1, width);
67
70
  const innerWidth = Math.max(1, dialogWidth - 2);
68
- const works = this.state.listWorks();
71
+ const { works, error } = readTaskView(this.state);
72
+ if (error)
73
+ return [border(innerWidth, "top", this.theme), frame(this.theme.fg("error", "Tasks unavailable · Escape closes"), innerWidth, this.theme), frame(truncateToWidth(error, innerWidth, "…"), innerWidth, this.theme), border(innerWidth, "bottom", this.theme)];
69
74
  const todos = works.flatMap((work) => work.tasks);
70
75
  const items = this.items(works);
71
76
  this.syncSelection(items);
@@ -157,7 +162,7 @@ export class WorksDashboard {
157
162
  if (link)
158
163
  void this.openLinkedDelegate(link);
159
164
  else {
160
- this.message = "Select a delegated task with a Herdr pane link. Navigation requires Herdr.";
165
+ this.message = "Select a delegated task with a Core terminal link. Navigation requires the Herdr app.";
161
166
  this.messageColor = "warning";
162
167
  this.tui.requestRender();
163
168
  }
@@ -240,7 +245,7 @@ export class WorksDashboard {
240
245
  this.unsubscribeGit();
241
246
  clearInterval(this.refreshTimer);
242
247
  }
243
- items(works = this.state.listWorks()) {
248
+ items(works = readTaskView(this.state).works) {
244
249
  const items = [];
245
250
  for (const work of works) {
246
251
  items.push({ key: `work:${work.workId}`, kind: "work", work });
@@ -331,19 +336,21 @@ export class WorksDashboard {
331
336
  lines.push(...wrap(this.theme.fg("muted", `${recordId(item.work.workId, this.theme)} ${safeSingleLine(item.work.workName)}`)), "");
332
337
  const status = `${todoIcon(task.status, this.theme)} ${task.status}`;
333
338
  lines.push(...wrap(`${status} · ${formatCompletion(taskCompletion(task))} complete · Time: ${formatTime(taskTime(task))}`), "");
334
- if (task.status === "blocked") {
335
- const reasonWidth = Math.max(1, contentWidth - 2);
336
- for (const line of safeMultiline(`Reason: ${task.blockedReason ?? "No reason recorded."}`)) {
337
- lines.push(...wrapTextWithAnsi(line || " ", reasonWidth).map((part) => this.theme.fg("warning", `│ ${part}`)));
338
- }
339
- lines.push("");
340
- }
341
339
  }
342
340
  else {
343
341
  lines.push(...wrap(`${formatCompletion(workCompletion(item.work))} complete · Time (task effort): ${formatTime(workTime(item.work))}`), "");
344
342
  }
345
- lines.push(this.theme.fg("accent", this.theme.bold(task ? "Task details" : "Work details")));
346
- lines.push(...safeMultiline(task?.taskInfo ?? item.work.workInfo).flatMap(wrap));
343
+ if (task) {
344
+ const dependency = dependentOnLabel(task.dependentOn);
345
+ lines.push(this.theme.fg("accent", this.theme.bold(dependency === undefined ? "Final thoughts" : `Final thoughts · Dependent on: ${dependency}`)));
346
+ const thoughts = finalThoughtsFor(task) ?? "No final thoughts recorded.";
347
+ const color = task.status === "blocked" ? "warning" : "muted";
348
+ lines.push(...safeMultiline(thoughts).flatMap(wrap).map((line) => this.theme.fg(color, line)));
349
+ }
350
+ else {
351
+ lines.push(this.theme.fg("accent", this.theme.bold("Work details")));
352
+ lines.push(...safeMultiline(item.work.workInfo).flatMap(wrap));
353
+ }
347
354
  this.detailPageSize = budget;
348
355
  this.detailOffset = Math.max(0, Math.min(this.detailOffset, Math.max(0, lines.length - budget)));
349
356
  const shown = lines.slice(this.detailOffset, this.detailOffset + budget);
@@ -403,7 +410,7 @@ export class WorksDashboard {
403
410
  this.messageColor = "warning";
404
411
  this.tui.requestRender();
405
412
  try {
406
- await focusPane(link.paneId, this.cwd);
413
+ await focusTerminal(link.terminalId, this.cwd);
407
414
  this.message = "Opened delegated agent in Herdr.";
408
415
  this.messageColor = "success";
409
416
  }
@@ -452,8 +459,8 @@ export class WorksDashboard {
452
459
  this.message = "Copying all works and todos as Markdown…";
453
460
  this.messageColor = "warning";
454
461
  this.tui.requestRender();
455
- const works = this.state.listWorks();
456
462
  try {
463
+ const works = this.state.listWorks();
457
464
  await copyToClipboard(formatWorksMarkdown(works));
458
465
  const todoCount = works.reduce((total, work) => total + work.tasks.length, 0);
459
466
  this.message = `Copied ${works.length} work${works.length === 1 ? "" : "s"} and ${todoCount} todo${todoCount === 1 ? "" : "s"} as Markdown.`;