@abhishek944/pi-tasks 0.14.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.
- package/README.md +59 -12
- package/dist/agents/delegation.d.ts +4 -0
- package/dist/agents/delegation.js +59 -0
- package/dist/agents/herdr.d.ts +10 -3
- package/dist/agents/herdr.js +39 -12
- package/dist/agents/links.d.ts +3 -3
- package/dist/agents/links.js +42 -19
- package/dist/auto-continue.js +160 -27
- package/dist/command.d.ts +2 -2
- package/dist/command.js +8 -4
- package/dist/delegated-time.d.ts +11 -0
- package/dist/delegated-time.js +51 -2
- package/dist/dependency.d.ts +7 -0
- package/dist/dependency.js +13 -0
- package/dist/durable.d.ts +38 -0
- package/dist/durable.js +515 -0
- package/dist/herdr-header.d.ts +3 -0
- package/dist/herdr-header.js +100 -0
- package/dist/herdr-panel.d.ts +7 -0
- package/dist/herdr-panel.js +182 -0
- package/dist/index.js +98 -56
- package/dist/markdown.js +3 -1
- package/dist/open-repository.d.ts +5 -3
- package/dist/open-repository.js +19 -5
- package/dist/panel-settings.d.ts +11 -0
- package/dist/panel-settings.js +30 -0
- package/dist/snapshot.d.ts +23 -0
- package/dist/snapshot.js +123 -0
- package/dist/state.d.ts +21 -18
- package/dist/state.js +357 -286
- package/dist/thoughts.d.ts +11 -0
- package/dist/thoughts.js +14 -0
- package/dist/timing.js +2 -1
- package/dist/tools.js +48 -29
- package/dist/tracking.js +18 -11
- package/dist/types.d.ts +9 -2
- package/dist/ui/panel.d.ts +2 -1
- package/dist/ui/panel.js +33 -21
- package/dist/ui/task-view.d.ts +7 -0
- package/dist/ui/task-view.js +10 -0
- package/dist/ui/works-dashboard.d.ts +3 -2
- package/dist/ui/works-dashboard.js +33 -24
- package/docs/REFERENCE.md +58 -30
- package/docs/USAGE_GUIDE.md +129 -51
- package/herdr/pi-tasks/README.md +45 -0
- package/herdr/pi-tasks/header.js +192 -0
- package/herdr/pi-tasks/main.js +413 -0
- package/herdr/pi-tasks/mod.json +3 -0
- package/herdr/pi-tasks/spinner.svg +1 -0
- package/package.json +26 -1
- package/dist/agents/tools.d.ts +0 -3
- 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;
|
package/dist/thoughts.js
ADDED
|
@@ -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
|
-
//
|
|
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
|
|
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
|
|
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
|
|
19
|
-
const
|
|
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. ${
|
|
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
|
-
|
|
36
|
+
WORK_INFO_GUIDANCE,
|
|
30
37
|
],
|
|
31
38
|
parameters: Type.Object({
|
|
32
39
|
workName: NameSchema,
|
|
33
|
-
workInfo:
|
|
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
|
|
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. ${
|
|
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.",
|
|
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(
|
|
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
|
|
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
|
|
97
|
-
promptSnippet: "Create
|
|
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
|
-
"
|
|
101
|
-
|
|
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:
|
|
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
|
|
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,
|
|
141
|
-
promptSnippet: "Keep todo status and
|
|
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
|
|
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(
|
|
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
|
|
156
|
-
const
|
|
157
|
-
|
|
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) =>
|
|
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
|
-
|
|
6
|
-
|
|
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
|
|
16
|
-
- Prefer pi-
|
|
17
|
-
- Pi-tasks owns task records/progress and
|
|
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
|
|
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
|
-
-
|
|
30
|
-
-
|
|
31
|
-
-
|
|
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
|
|
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
|
-
|
|
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
|
|
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.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export declare function metricsContentWidth(width: number): number;
|
|
|
8
8
|
export declare class TasksPanelHost {
|
|
9
9
|
private readonly state;
|
|
10
10
|
private readonly git;
|
|
11
|
+
private readonly getOpenCommand;
|
|
11
12
|
private tui;
|
|
12
13
|
private panel;
|
|
13
14
|
private handle;
|
|
@@ -16,7 +17,7 @@ export declare class TasksPanelHost {
|
|
|
16
17
|
private minimized;
|
|
17
18
|
private cwd;
|
|
18
19
|
private sessionId;
|
|
19
|
-
constructor(state: TaskState, git: GitStatusCache);
|
|
20
|
+
constructor(state: TaskState, git: GitStatusCache, getOpenCommand: () => string[]);
|
|
20
21
|
attach(ui: ExtensionUIContext, cwd: string, sessionId: string): void;
|
|
21
22
|
setMode(mode: TasksPanelMode): void;
|
|
22
23
|
getMode(): TasksPanelMode;
|
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,
|
|
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;
|
|
@@ -18,17 +19,19 @@ export function metricsContentWidth(width) {
|
|
|
18
19
|
export class TasksPanelHost {
|
|
19
20
|
state;
|
|
20
21
|
git;
|
|
22
|
+
getOpenCommand;
|
|
21
23
|
tui;
|
|
22
24
|
panel;
|
|
23
25
|
handle;
|
|
24
26
|
ui;
|
|
25
|
-
mode = "
|
|
27
|
+
mode = "off";
|
|
26
28
|
minimized = false;
|
|
27
29
|
cwd = "";
|
|
28
30
|
sessionId = "Session unavailable";
|
|
29
|
-
constructor(state, git) {
|
|
31
|
+
constructor(state, git, getOpenCommand) {
|
|
30
32
|
this.state = state;
|
|
31
33
|
this.git = git;
|
|
34
|
+
this.getOpenCommand = getOpenCommand;
|
|
32
35
|
}
|
|
33
36
|
attach(ui, cwd, sessionId) {
|
|
34
37
|
this.hideCurrent();
|
|
@@ -71,7 +74,7 @@ export class TasksPanelHost {
|
|
|
71
74
|
this.tui = tui;
|
|
72
75
|
this.panel = new TasksPanel(tui, this.state, theme, "widget", this.minimized, (minimized) => {
|
|
73
76
|
this.minimized = minimized;
|
|
74
|
-
}, (message, type) => ui.notify(message, type), this.cwd, this.git, this.sessionId);
|
|
77
|
+
}, (message, type) => ui.notify(message, type), this.cwd, this.git, this.sessionId, this.getOpenCommand);
|
|
75
78
|
return this.panel;
|
|
76
79
|
});
|
|
77
80
|
return;
|
|
@@ -80,7 +83,7 @@ export class TasksPanelHost {
|
|
|
80
83
|
this.tui = tui;
|
|
81
84
|
this.panel = new TasksPanel(tui, this.state, theme, "floating", this.minimized, (minimized) => {
|
|
82
85
|
this.minimized = minimized;
|
|
83
|
-
}, (message, type) => ui.notify(message, type), this.cwd, this.git, this.sessionId);
|
|
86
|
+
}, (message, type) => ui.notify(message, type), this.cwd, this.git, this.sessionId, this.getOpenCommand);
|
|
84
87
|
this.handle = tui.showOverlay(this.panel, {
|
|
85
88
|
anchor: "top-right",
|
|
86
89
|
width: "42%",
|
|
@@ -118,6 +121,7 @@ class TasksPanel {
|
|
|
118
121
|
cwd;
|
|
119
122
|
git;
|
|
120
123
|
sessionId;
|
|
124
|
+
getOpenCommand;
|
|
121
125
|
scrollOffset = 0;
|
|
122
126
|
pageSize = 1;
|
|
123
127
|
contentLength = 0;
|
|
@@ -133,7 +137,7 @@ class TasksPanel {
|
|
|
133
137
|
openHitRegion;
|
|
134
138
|
sessionHitRegion;
|
|
135
139
|
toggleHitRegion;
|
|
136
|
-
constructor(tui, state, theme, placement, minimized, onMinimizedChange, notify, cwd, git, sessionId) {
|
|
140
|
+
constructor(tui, state, theme, placement, minimized, onMinimizedChange, notify, cwd, git, sessionId, getOpenCommand) {
|
|
137
141
|
this.tui = tui;
|
|
138
142
|
this.state = state;
|
|
139
143
|
this.theme = theme;
|
|
@@ -144,6 +148,7 @@ class TasksPanel {
|
|
|
144
148
|
this.cwd = cwd;
|
|
145
149
|
this.git = git;
|
|
146
150
|
this.sessionId = sessionId;
|
|
151
|
+
this.getOpenCommand = getOpenCommand;
|
|
147
152
|
}
|
|
148
153
|
render(width) {
|
|
149
154
|
this.delegateHits = [];
|
|
@@ -151,12 +156,17 @@ class TasksPanel {
|
|
|
151
156
|
this.setVisible(width >= 48);
|
|
152
157
|
if (width < 48)
|
|
153
158
|
return [];
|
|
154
|
-
const works = this.state
|
|
159
|
+
const { works, error } = readTaskView(this.state);
|
|
160
|
+
const todos = works.flatMap((work) => work.tasks);
|
|
155
161
|
const boxWidth = this.placement === "floating" ? width : Math.min(54, Math.max(48, Math.floor(width * 0.44)));
|
|
156
162
|
const innerWidth = boxWidth - 2;
|
|
157
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
|
+
}
|
|
158
168
|
if (this.minimized) {
|
|
159
|
-
const header = this.renderHeader(innerWidth, leftPad.length);
|
|
169
|
+
const header = this.renderHeader(innerWidth, leftPad.length, todos);
|
|
160
170
|
return [
|
|
161
171
|
gitBorder(innerWidth, this.theme, this.git.getSnapshot()),
|
|
162
172
|
frame(header, innerWidth, this.theme),
|
|
@@ -207,7 +217,7 @@ class TasksPanel {
|
|
|
207
217
|
const suffix = this.placement === "floating" && hasOverflow
|
|
208
218
|
? this.tui.mode === "fullscreen" ? ` · ${range}` : ` · ${range} · latest · /works for all`
|
|
209
219
|
: "";
|
|
210
|
-
const header = this.renderHeader(innerWidth, leftPad.length, suffix);
|
|
220
|
+
const header = this.renderHeader(innerWidth, leftPad.length, todos, suffix);
|
|
211
221
|
const lines = [
|
|
212
222
|
gitBorder(innerWidth, this.theme, this.git.getSnapshot()),
|
|
213
223
|
frame(header, innerWidth, this.theme),
|
|
@@ -247,11 +257,11 @@ class TasksPanel {
|
|
|
247
257
|
return { handled: true, render: true };
|
|
248
258
|
}
|
|
249
259
|
if (this.isHit(event.x, this.sessionHitRegion)) {
|
|
250
|
-
void this.
|
|
260
|
+
void this.openDirectory(true);
|
|
251
261
|
return { handled: true, render: true };
|
|
252
262
|
}
|
|
253
263
|
if (this.isHit(event.x, this.openHitRegion)) {
|
|
254
|
-
void this.
|
|
264
|
+
void this.openDirectory();
|
|
255
265
|
return { handled: true, render: true };
|
|
256
266
|
}
|
|
257
267
|
}
|
|
@@ -273,7 +283,8 @@ class TasksPanel {
|
|
|
273
283
|
if (visible) {
|
|
274
284
|
this.unsubscribeGit ??= this.git.subscribe(() => this.tui.requestRender());
|
|
275
285
|
this.refreshTimer ??= setInterval(() => {
|
|
276
|
-
|
|
286
|
+
const view = readTaskView(this.state);
|
|
287
|
+
if (view.error || (!this.minimized && view.works.some((work) => work.tasks.some((todo) => todo.workingSince !== undefined))))
|
|
277
288
|
this.tui.requestRender();
|
|
278
289
|
}, 1_000);
|
|
279
290
|
this.refreshTimer.unref?.();
|
|
@@ -292,9 +303,9 @@ class TasksPanel {
|
|
|
292
303
|
this.onMinimizedChange(minimized);
|
|
293
304
|
this.tui.requestRender();
|
|
294
305
|
}
|
|
295
|
-
renderHeader(width, leftPadWidth, suffix = "") {
|
|
306
|
+
renderHeader(width, leftPadWidth, todos, suffix = "") {
|
|
296
307
|
const counts = { active: 0, blocked: 0, completed: 0, cancelled: 0 };
|
|
297
|
-
for (const todo of
|
|
308
|
+
for (const todo of todos)
|
|
298
309
|
counts[todo.status]++;
|
|
299
310
|
const statuses = ["blocked", "active", "completed", "cancelled"];
|
|
300
311
|
const summary = statuses.filter((status) => counts[status] > 0)
|
|
@@ -330,7 +341,7 @@ class TasksPanel {
|
|
|
330
341
|
return;
|
|
331
342
|
this.openingDelegate = true;
|
|
332
343
|
try {
|
|
333
|
-
await
|
|
344
|
+
await focusTerminal(link.terminalId, this.cwd);
|
|
334
345
|
}
|
|
335
346
|
catch (error) {
|
|
336
347
|
const reason = error instanceof Error ? safeSingleLine(error.message) : "Unknown error.";
|
|
@@ -341,23 +352,24 @@ class TasksPanel {
|
|
|
341
352
|
this.openingDelegate = false;
|
|
342
353
|
}
|
|
343
354
|
}
|
|
344
|
-
async
|
|
355
|
+
async openDirectory(session = false) {
|
|
345
356
|
if (this.opening)
|
|
346
357
|
return;
|
|
347
358
|
this.opening = true;
|
|
348
359
|
this.tui.requestRender();
|
|
349
360
|
try {
|
|
361
|
+
const command = this.getOpenCommand();
|
|
350
362
|
if (session)
|
|
351
|
-
await openSession(this.cwd, this.sessionId);
|
|
363
|
+
await openSession(this.cwd, this.sessionId, command);
|
|
352
364
|
else
|
|
353
|
-
await openRepository(this.cwd);
|
|
365
|
+
await openRepository(this.cwd, command);
|
|
354
366
|
if (!this.disposed)
|
|
355
|
-
this.notify(session ? "Opened session artifacts
|
|
367
|
+
this.notify(session ? "Opened session artifacts." : "Opened repository.", "info");
|
|
356
368
|
}
|
|
357
369
|
catch (error) {
|
|
358
370
|
const reason = error instanceof Error ? ` ${safeSingleLine(error.message)}` : "";
|
|
359
371
|
if (!this.disposed)
|
|
360
|
-
this.notify(
|
|
372
|
+
this.notify(`Could not open ${session ? "session artifacts" : "repository"}. Check pi-tasks.openCommand and that its executable is installed on PATH.${reason}`, "error");
|
|
361
373
|
}
|
|
362
374
|
finally {
|
|
363
375
|
this.opening = false;
|
|
@@ -370,8 +382,8 @@ class TasksPanel {
|
|
|
370
382
|
return;
|
|
371
383
|
this.copying = true;
|
|
372
384
|
this.tui.requestRender();
|
|
373
|
-
const works = this.state.listWorks();
|
|
374
385
|
try {
|
|
386
|
+
const works = this.state.listWorks();
|
|
375
387
|
await copyToClipboard(formatWorksMarkdown(works));
|
|
376
388
|
const todoCount = works.reduce((total, work) => total + work.tasks.length, 0);
|
|
377
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
|
+
}
|