@abhishek944/pi-tasks 0.13.0 → 0.15.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 +3 -2
- package/dist/agents/tools.js +9 -6
- package/dist/command.d.ts +1 -1
- package/dist/command.js +2 -2
- package/dist/delegated-time.d.ts +4 -0
- package/dist/delegated-time.js +164 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +11 -7
- package/dist/open-repository.d.ts +5 -3
- package/dist/open-repository.js +19 -5
- package/dist/state.d.ts +3 -1
- package/dist/state.js +30 -2
- package/dist/time.js +13 -4
- package/dist/tracking.js +1 -1
- package/dist/types.d.ts +13 -0
- package/dist/ui/panel.d.ts +2 -1
- package/dist/ui/panel.js +16 -11
- package/dist/ui/works-dashboard.d.ts +3 -2
- package/dist/ui/works-dashboard.js +11 -9
- package/docs/REFERENCE.md +15 -9
- package/docs/USAGE_GUIDE.md +46 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,6 +6,7 @@ It adds:
|
|
|
6
6
|
|
|
7
7
|
- `WorkCreate`, `WorkList`, `WorkUpdate`, and `WorkDelete`
|
|
8
8
|
- `TodoCreate`, `TodoList`, `TodoUpdate`, and `TodoDelete`
|
|
9
|
+
- `TaskTimeExport` and `TaskTimeImport` for measured delegated effort
|
|
9
10
|
- `/works`, a detailed floating dashboard modeled after `pi-loop-monitor`'s `/monitors`
|
|
10
11
|
- a compact floating top-right panel with work and todo names, completion percentages, and measured active time
|
|
11
12
|
- main-conversation guidance that keeps normal requested work current across every Pi skill and requires each delegated agent to establish its own Work and Todo IDs before assigned work
|
|
@@ -49,11 +50,11 @@ The panel and `/works` reserve **Done** and **Time** columns. Select the task yo
|
|
|
49
50
|
|
|
50
51
|
The extension uses `Date.now()` to add working intervals, including thinking and foreground tools. Idle time, native retry delays between agent loops, and blocking user prompts do not count. Completion, blocking, cancellation, ownership changes, abort, and shutdown stop the timer automatically. Saved totals survive reload and branch navigation; restored tasks are paused and offline time never counts. A running time has a `▶` marker. Totals are saved on interval boundaries, not every display tick. A forced process kill can lose the current unsaved interval. Blocking prompt exclusion needs a Pi host that emits `ui_prompt_start`/`ui_prompt_end`; older hosts still pause at agent-loop boundaries.
|
|
51
52
|
|
|
52
|
-
New tasks start at `0s`; historical tasks without timing show `—` until measured, with no attempt to reconstruct earlier time. Work time sums every task's measured effort, including cancelled tasks; any unknown task makes the total unknown. It is not wall-clock duration or an estimate of remaining time. Every delegated agent times its own local tasks; the parent
|
|
53
|
+
New tasks start at `0s`; historical tasks without timing show `—` until measured, with no attempt to reconstruct earlier time. Work time sums every task's measured effort, including cancelled tasks; any unknown task makes the total unknown. It is not wall-clock duration or an estimate of remaining time. Every delegated agent times its own local tasks. AgentCreate supplies a timing report path; the worker calls `TaskTimeExport` with its assignment task IDs after pausing or completing them. The parent then calls `TaskTimeImport` with its delegated task ID. The parent task and Work include that measured effort, without counting waiting or changing status. Until exported and imported, delegated effort shows `—`. Repeated imports replace the cumulative snapshot rather than adding it again. See [delegated timing](docs/USAGE_GUIDE.md#delegated-timing). Listings and copied Markdown include the same totals.
|
|
53
54
|
|
|
54
55
|
The panel and `/works` prefix work names with IDs and task names with IDs plus ownership, such as `[W1] Locate subagent restrictions` and `[T1] [self] Inspect the implement skill`. Task ownership comes from an explicit `owner: self` or `owner: delegate` declaration at the start of a line in `taskInfo`; preserve it on updates. Missing or conflicting decisions show `[unassigned]`, without rewriting stored names or old records. Inside Herdr, `AgentCreate` automatically links its task to an underlined, clickable `[delegate]` badge; Open actions are also underlined. See [delegate pane links](docs/USAGE_GUIDE.md#delegate-pane-links) for linking and keyboard access.
|
|
55
56
|
|
|
56
|
-
The panel defaults to the floating top-right layout. The compact header no longer displays the session ID. An underlined Open session action beside Copy opens this agent's artifact folder
|
|
57
|
+
The panel defaults to the floating top-right layout. The compact header no longer displays the session ID. An underlined Open session action beside Copy opens this agent's artifact folder using the configured command, including existing nested delegated paths; if none exists, it creates `var/<sessionId>/`. The existing Open still opens the repository. Use `/works-panel open-session` without mouse input. Narrow headers shorten Minimize/Maximize to `[-]`/`[+]`. The `/works` dashboard title stays unchanged. Its top border centers the current repository's Git branch and staged/unstaged/untracked file counts, refreshed asynchronously with a one-second cache. Clean repositories show `clean`. In fullscreen TUI mode, its title bar has clickable Copy, Open, and Minimize/Maximize actions, and you can scroll overflowing rows directly with the mouse wheel. Open defaults to `cursor .`; configure `pi-tasks.openCommand` to use another tool (see [configuration](docs/USAGE_GUIDE.md#configure-open-and-open-session)). Open `/works` to inspect every row or copy from the keyboard. Use `/works-panel minimize`, `/works-panel maximize`, or `/works-panel open` when mouse input is unavailable. In `/works`, press `o` to run the configured command. Switch layouts with `/works-panel floating`, `/works-panel widget`, or `/works-panel off`.
|
|
57
58
|
|
|
58
59
|
## Task-owned agents
|
|
59
60
|
|
package/dist/agents/tools.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Type } from "typebox";
|
|
2
|
+
import { createTimingReport } from "../delegated-time.js";
|
|
2
3
|
import { taskOwner } from "../ownership.js";
|
|
3
4
|
import { renderTaskCall, renderTaskResult, taskResult } from "../tool-result.js";
|
|
4
5
|
import { areTrackingToolsActive } from "../tracking.js";
|
|
@@ -34,11 +35,11 @@ export function registerAgentTools(pi, state) {
|
|
|
34
35
|
};
|
|
35
36
|
pi.registerTool({
|
|
36
37
|
name: "AgentCreate", label: "AgentCreate",
|
|
37
|
-
description: "Wrap Herdr tab creation, Pi startup and MonitorCreate. Returns actual paneId/tabId/monitorId and a prepared assignment; automatically links the task's delegate badge and marks the parent task blocked while awaiting the worker. Does NOT send work: confirm MonitorList shows subscription ready, then AgentSend the returned assignment. onSignal wakes the parent for worker state changes; optional onDone handles monitor termination, not task completion. No private agent registry, automatic recovery or process checks.",
|
|
38
|
+
description: "Wrap a timing descriptor, Herdr tab creation, Pi startup and MonitorCreate. Requires an existing canonical taskDir inside repository var/. Returns reportPath, actual paneId/tabId/monitorId and a prepared assignment with timing-export instructions; automatically links the task's delegate badge and marks the parent task blocked while awaiting the worker. Does NOT send work: confirm MonitorList shows subscription ready, then AgentSend the returned assignment. onSignal wakes the parent for worker state changes; optional onDone handles monitor termination, not task completion. No private agent registry, automatic recovery or process checks.",
|
|
38
39
|
promptGuidelines: ["Prefer these agent tools over CLI for supported operations; use Herdr CLI only for missing capabilities.", "Choose explicit provider/model/thinking/Fast through model-routing-policy. Create only authorized agents, never in /ask or /btw.", "After AgentCreate, confirm MonitorList shows the pane subscription ready before AgentSend. Do not add a duplicate monitor. Read actual output/files before completing tasks."],
|
|
39
40
|
parameters: Type.Object({
|
|
40
41
|
workId: Type.String({ pattern: "^W[1-9][0-9]*$" }), taskId: Type.String({ pattern: "^T[1-9][0-9]*$" }),
|
|
41
|
-
taskDir: Type.String({ minLength: 1, description: "Existing canonical parent task artifact directory from implement
|
|
42
|
+
taskDir: Type.String({ minLength: 1, description: "Existing canonical parent task artifact directory from implement, inside repository var/. A unique timing descriptor is written here and passed to the worker; no directory is created by this wrapper." }),
|
|
42
43
|
assignment: Type.String({ minLength: 1, maxLength: 32_000 }), provider: Type.String({ minLength: 1 }), model: Type.String({ minLength: 1 }),
|
|
43
44
|
thinking: Type.String({ minLength: 1, description: "Explicit thinking level supported by the chosen model." }),
|
|
44
45
|
fast: Type.Optional(Type.Boolean({ description: "Forward --fast only when requested and supported." })),
|
|
@@ -52,7 +53,8 @@ export function registerAgentTools(pi, state) {
|
|
|
52
53
|
const todo = state.getTodo(params.taskId);
|
|
53
54
|
if (!todo || todo.workId !== params.workId || taskOwner(todo.taskInfo) !== "delegate")
|
|
54
55
|
throw new Error("Use an existing task in this work with owner: delegate.");
|
|
55
|
-
const
|
|
56
|
+
const reportPath = await createTimingReport(ctx, params.taskDir, params.workId, params.taskId);
|
|
57
|
+
const handles = { reportPath };
|
|
56
58
|
try {
|
|
57
59
|
const current = object((await herdr(["pane", "current"], ctx.cwd, signal)).pane);
|
|
58
60
|
if (typeof current?.workspace_id !== "string")
|
|
@@ -69,17 +71,18 @@ export function registerAgentTools(pi, state) {
|
|
|
69
71
|
args.push("--fast");
|
|
70
72
|
await herdr(args, ctx.cwd, signal, 45_000);
|
|
71
73
|
const watched = await monitor(ctx, "MonitorCreate", { herdrPaneId: pane.pane_id, description: `Agent ${params.taskId} (${pane.pane_id})`, timeout: 0,
|
|
72
|
-
onSignal: params.onSignal, ...(params.onDone === undefined ? {} : { onDone: params.onDone }) }, signal);
|
|
74
|
+
onSignal: `${params.onSignal}\nWhen worker output is available, call TaskTimeImport for taskId ${params.taskId} to import measured effort from its timing report. Timing import does not verify or complete the task.`, ...(params.onDone === undefined ? {} : { onDone: params.onDone }) }, signal);
|
|
73
75
|
if (typeof watched.monitorId !== "string")
|
|
74
76
|
throw new Error("Update pi-loop-monitor: MonitorCreate must return details.monitorId.");
|
|
75
77
|
handles.monitorId = watched.monitorId;
|
|
76
78
|
const currentTodo = state.getTodo(params.taskId);
|
|
77
79
|
if (!currentTodo || currentTodo.workId !== params.workId)
|
|
78
80
|
throw new Error("The parent task is no longer available for linking.");
|
|
81
|
+
state.setDelegatedTime(params.taskId, { reportPath, elapsedMs: null });
|
|
79
82
|
state.updateTodo(params.taskId, { status: "blocked", blockedReason: "Waiting for the delegated agent. Resume when its output is available for inspection and verification.", taskInfo: withPaneLink(currentTodo.taskInfo, pane.pane_id, watched.monitorId) });
|
|
80
|
-
const assignment = `Parent session ${ctx.sessionManager.getSessionId()}, work ${params.workId}, task ${params.taskId}. Exact parentTaskDir: ${params.taskDir}. Read global implement and applicable skills. Obtain your own PI_SESSION_ID through your shell, establish your own Work and active Todo using WorkList/TodoList and create/update tools before executing, keep them current, and return your IDs, nested task artifact path, changed files, checks and blockers. Parent IDs are context, not shared records. This handoff grants no additional permissions.\n\n${params.assignment}`;
|
|
83
|
+
const assignment = `Parent session ${ctx.sessionManager.getSessionId()}, work ${params.workId}, task ${params.taskId}. Exact parentTaskDir: ${params.taskDir}. Read global implement and applicable skills. Obtain your own PI_SESSION_ID through your shell, establish your own Work and active Todo using WorkList/TodoList and create/update tools before executing, keep them current, and return your IDs, nested task artifact path, changed files, checks and blockers. Parent IDs are context, not shared records. This handoff grants no additional permissions. Timing reportPath: ${JSON.stringify(reportPath)}. Before returning results, pause or complete every assignment task, import any nested delegates with TaskTimeImport, then call TaskTimeExport with this exact reportPath and all assignment-local taskIds (including cancelled tasks, excluding unrelated work). Never calculate or type durations yourself. After follow-ups, export the cumulative set again to the same reportPath. If export is unavailable or fails, report that limitation; do not hand-write the timing file.\n\n${params.assignment}`;
|
|
81
84
|
return result("AgentCreate", { ...handles, taskDir: params.taskDir, assignment, assignmentSent: false,
|
|
82
|
-
next: "Confirm MonitorList shows subscription ready, then AgentSend this assignment to the returned paneId." });
|
|
85
|
+
next: "Confirm MonitorList shows subscription ready, then AgentSend this assignment to the returned paneId. After worker output is available, call TaskTimeImport for this task before closing its agent; verify completion separately." });
|
|
83
86
|
}
|
|
84
87
|
catch (error) {
|
|
85
88
|
throw new Error(`${error instanceof Error ? error.message : String(error)}. The command may have partially completed. Handles returned so far: ${JSON.stringify(handles)}. Inspect these resources; no automatic retry or cleanup was performed.`);
|
package/dist/command.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
import type { GitStatusCache } from "./git-status.js";
|
|
3
3
|
import type { TaskState } from "./state.js";
|
|
4
|
-
export declare function registerWorksCommand(pi: ExtensionAPI, state: TaskState, git: GitStatusCache): void;
|
|
4
|
+
export declare function registerWorksCommand(pi: ExtensionAPI, state: TaskState, git: GitStatusCache, getOpenCommand: () => string[]): void;
|
package/dist/command.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { runWorksOverlay } from "./ui/overlay.js";
|
|
2
2
|
import { WorksDashboard } from "./ui/works-dashboard.js";
|
|
3
|
-
export function registerWorksCommand(pi, state, git) {
|
|
3
|
+
export function registerWorksCommand(pi, state, git, getOpenCommand) {
|
|
4
4
|
let closeActiveDashboard;
|
|
5
5
|
pi.on("session_start", () => {
|
|
6
6
|
closeActiveDashboard?.();
|
|
@@ -28,7 +28,7 @@ export function registerWorksCommand(pi, state, git) {
|
|
|
28
28
|
};
|
|
29
29
|
commandClose = closeCurrent;
|
|
30
30
|
closeActiveDashboard = closeCurrent;
|
|
31
|
-
return new WorksDashboard(tui, theme, keybindings, state, closeCurrent, ctx.cwd, git, (message, type) => ctx.ui.notify(message, type));
|
|
31
|
+
return new WorksDashboard(tui, theme, keybindings, state, closeCurrent, ctx.cwd, git, (message, type) => ctx.ui.notify(message, type), getOpenCommand);
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
34
|
catch (error) {
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type ExtensionAPI, type ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import type { TaskState } from "./state.js";
|
|
3
|
+
export declare function createTimingReport(ctx: ExtensionContext, taskDir: string, workId: string, taskId: string): Promise<string>;
|
|
4
|
+
export declare function registerDelegatedTimeTools(pi: ExtensionAPI, state: TaskState): void;
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { readFile, realpath, rename, stat, unlink, writeFile } from "node:fs/promises";
|
|
3
|
+
import { basename, dirname, isAbsolute, relative, resolve, sep } from "node:path";
|
|
4
|
+
import { withFileMutationQueue } from "@earendil-works/pi-coding-agent";
|
|
5
|
+
import { Type } from "typebox";
|
|
6
|
+
import { formatTime, taskTime } from "./time.js";
|
|
7
|
+
import { renderTaskCall, renderTaskResult, taskResult } from "./tool-result.js";
|
|
8
|
+
import { areTrackingToolsActive } from "./tracking.js";
|
|
9
|
+
const SESSION_ID = /^[A-Za-z0-9][A-Za-z0-9_-]*$/;
|
|
10
|
+
const TASK_ID = /^T[1-9][0-9]*$/;
|
|
11
|
+
const WORK_ID = /^W[1-9][0-9]*$/;
|
|
12
|
+
const ElapsedSchema = Type.Union([Type.Integer({ minimum: 0 }), Type.Null()]);
|
|
13
|
+
const execution = { executionMode: "sequential", annotations: { readOnlyHint: false, destructiveHint: false, openWorldHint: false } };
|
|
14
|
+
function inside(root, path) {
|
|
15
|
+
const suffix = relative(root, path);
|
|
16
|
+
return !!suffix && suffix !== ".." && !suffix.startsWith(`..${sep}`) && !isAbsolute(suffix);
|
|
17
|
+
}
|
|
18
|
+
/** All reports are regular files within the repository's real var/ tree. */
|
|
19
|
+
async function reportDirectory(cwd, path) {
|
|
20
|
+
const root = resolve(await realpath(cwd), "var");
|
|
21
|
+
const directory = await realpath(path);
|
|
22
|
+
if (!inside(root, directory))
|
|
23
|
+
throw new Error("Timing reports must be below the repository's var/ directory.");
|
|
24
|
+
return directory;
|
|
25
|
+
}
|
|
26
|
+
async function reportFile(cwd, path) {
|
|
27
|
+
const requested = resolve(cwd, path);
|
|
28
|
+
const directory = await reportDirectory(cwd, dirname(requested));
|
|
29
|
+
const actual = await realpath(requested);
|
|
30
|
+
if (actual !== resolve(directory, basename(requested)) || !(await stat(actual)).isFile()) {
|
|
31
|
+
throw new Error("Timing reports must be regular files, not symlinks.");
|
|
32
|
+
}
|
|
33
|
+
return actual;
|
|
34
|
+
}
|
|
35
|
+
function object(value) {
|
|
36
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : undefined;
|
|
37
|
+
}
|
|
38
|
+
function validElapsed(value) {
|
|
39
|
+
return value === null || (typeof value === "number" && Number.isSafeInteger(value) && value >= 0);
|
|
40
|
+
}
|
|
41
|
+
async function readReport(path) {
|
|
42
|
+
if ((await stat(path)).size > 128_000)
|
|
43
|
+
throw new Error("Timing report exceeds 128 KB.");
|
|
44
|
+
const data = object(JSON.parse(await readFile(path, "utf8")));
|
|
45
|
+
if (data?.version !== 1 || typeof data.parentSessionId !== "string" || !SESSION_ID.test(data.parentSessionId)
|
|
46
|
+
|| typeof data.parentWorkId !== "string" || !WORK_ID.test(data.parentWorkId)
|
|
47
|
+
|| typeof data.parentTaskId !== "string" || !TASK_ID.test(data.parentTaskId)
|
|
48
|
+
|| !(data.workerSessionId === null || (typeof data.workerSessionId === "string" && SESSION_ID.test(data.workerSessionId)))
|
|
49
|
+
|| !Array.isArray(data.tasks) || data.tasks.length > 500)
|
|
50
|
+
throw new Error("Malformed timing report.");
|
|
51
|
+
const ids = new Set();
|
|
52
|
+
for (const raw of data.tasks) {
|
|
53
|
+
const task = object(raw);
|
|
54
|
+
if (!task || typeof task.taskId !== "string" || !TASK_ID.test(task.taskId) || ids.has(task.taskId) || !validElapsed(task.elapsedMs)) {
|
|
55
|
+
throw new Error("Malformed or duplicate timing report task.");
|
|
56
|
+
}
|
|
57
|
+
ids.add(task.taskId);
|
|
58
|
+
}
|
|
59
|
+
if ((data.workerSessionId === null) !== (data.tasks.length === 0))
|
|
60
|
+
throw new Error("Timing report has no worker measurement.");
|
|
61
|
+
return data;
|
|
62
|
+
}
|
|
63
|
+
export async function createTimingReport(ctx, taskDir, workId, taskId) {
|
|
64
|
+
const sessionId = ctx.sessionManager.getSessionId();
|
|
65
|
+
if (!SESSION_ID.test(sessionId))
|
|
66
|
+
throw new Error("Invalid parent session ID for timing handoff.");
|
|
67
|
+
const directory = await reportDirectory(ctx.cwd, resolve(ctx.cwd, taskDir));
|
|
68
|
+
const path = resolve(directory, `delegated-time-${randomUUID()}.json`);
|
|
69
|
+
const report = { version: 1, parentSessionId: sessionId, parentWorkId: workId, parentTaskId: taskId, workerSessionId: null, tasks: [] };
|
|
70
|
+
await withFileMutationQueue(path, () => writeFile(path, `${JSON.stringify(report, null, 2)}\n`, { flag: "wx", mode: 0o600 }));
|
|
71
|
+
return path;
|
|
72
|
+
}
|
|
73
|
+
function measuredTotal(report) {
|
|
74
|
+
if (!report.tasks.length || report.tasks.some((task) => task.elapsedMs === null))
|
|
75
|
+
return null;
|
|
76
|
+
const total = report.tasks.reduce((sum, task) => sum + (task.elapsedMs ?? 0), 0);
|
|
77
|
+
if (!Number.isSafeInteger(total))
|
|
78
|
+
throw new Error("Timing report total is too large.");
|
|
79
|
+
return total;
|
|
80
|
+
}
|
|
81
|
+
export function registerDelegatedTimeTools(pi, state) {
|
|
82
|
+
const requireMainWork = () => {
|
|
83
|
+
if (!areTrackingToolsActive(pi))
|
|
84
|
+
throw new Error("Timing handoffs are available only in tracked main-conversation work, not /ask or /btw.");
|
|
85
|
+
};
|
|
86
|
+
pi.registerTool({
|
|
87
|
+
name: "TaskTimeExport", label: "TaskTimeExport",
|
|
88
|
+
description: "Export measured effort for this worker's assignment to the exact reportPath supplied by AgentCreate. Pause or complete every included task first. Supply all assignment task IDs, including cancelled tasks and imported nested delegates; exclude unrelated tasks. Re-export the cumulative set after follow-ups. Durations come from pi-tasks, never from the model. Does not complete the parent task.",
|
|
89
|
+
parameters: Type.Object({
|
|
90
|
+
reportPath: Type.String({ minLength: 1 }),
|
|
91
|
+
taskIds: Type.Array(Type.String({ pattern: TASK_ID.source }), { minItems: 1, maxItems: 500, uniqueItems: true }),
|
|
92
|
+
}, { additionalProperties: false }),
|
|
93
|
+
...{ outputSchema: Type.Object({ reportPath: Type.String(), workerSessionId: Type.String(), elapsedMs: ElapsedSchema, taskIds: Type.Array(Type.String()) }) },
|
|
94
|
+
...execution,
|
|
95
|
+
async execute(_id, params, _signal, _update, ctx) {
|
|
96
|
+
requireMainWork();
|
|
97
|
+
const path = await reportFile(ctx.cwd, params.reportPath);
|
|
98
|
+
return withFileMutationQueue(path, async () => {
|
|
99
|
+
const previous = await readReport(path);
|
|
100
|
+
const workerSessionId = ctx.sessionManager.getSessionId();
|
|
101
|
+
if (!SESSION_ID.test(workerSessionId) || workerSessionId === previous.parentSessionId)
|
|
102
|
+
throw new Error("Timing export requires a distinct worker session.");
|
|
103
|
+
if (previous.workerSessionId !== null && previous.workerSessionId !== workerSessionId)
|
|
104
|
+
throw new Error("Timing report belongs to another worker session.");
|
|
105
|
+
const ids = new Set(params.taskIds);
|
|
106
|
+
if (ids.size !== params.taskIds.length || previous.tasks.some((task) => !ids.has(task.taskId)))
|
|
107
|
+
throw new Error("Re-export all previously reported tasks plus any new assignment tasks.");
|
|
108
|
+
const now = Date.now();
|
|
109
|
+
const tasks = params.taskIds.map((taskId) => {
|
|
110
|
+
const todo = state.getTodo(taskId);
|
|
111
|
+
if (!todo)
|
|
112
|
+
throw new Error(`Todo ${taskId} not found in this worker session.`);
|
|
113
|
+
if (todo.workingSince !== undefined)
|
|
114
|
+
throw new Error(`Pause or complete ${taskId} before exporting timing.`);
|
|
115
|
+
return { taskId, elapsedMs: taskTime(todo, now) };
|
|
116
|
+
});
|
|
117
|
+
const report = { ...previous, workerSessionId, tasks };
|
|
118
|
+
const elapsedMs = measuredTotal(report);
|
|
119
|
+
const temporary = `${path}.${randomUUID()}.tmp`;
|
|
120
|
+
try {
|
|
121
|
+
await writeFile(temporary, `${JSON.stringify(report, null, 2)}\n`, { flag: "wx", mode: 0o600 });
|
|
122
|
+
await rename(temporary, path);
|
|
123
|
+
}
|
|
124
|
+
finally {
|
|
125
|
+
await unlink(temporary).catch((error) => { if (error.code !== "ENOENT")
|
|
126
|
+
throw error; });
|
|
127
|
+
}
|
|
128
|
+
const data = { reportPath: path, workerSessionId, elapsedMs, taskIds: params.taskIds };
|
|
129
|
+
return { ...taskResult(`Exported ${tasks.length} task timings: ${formatTime(elapsedMs)}. Parent must call TaskTimeImport for ${report.parentTaskId}.`, "task-time-export", data), structuredContent: data };
|
|
130
|
+
});
|
|
131
|
+
},
|
|
132
|
+
renderCall: renderTaskCall("TaskTimeExport"), renderResult: renderTaskResult,
|
|
133
|
+
});
|
|
134
|
+
pi.registerTool({
|
|
135
|
+
name: "TaskTimeImport", label: "TaskTimeImport",
|
|
136
|
+
description: "Import this delegated task's registered worker timing files after worker output is available. Repeated imports replace cumulative snapshots, never double-count. Parent status and completion are unchanged. Missing worker measurements stay unknown. Import nested delegate time before exporting to your own caller.",
|
|
137
|
+
parameters: Type.Object({ taskId: Type.String({ pattern: TASK_ID.source }) }, { additionalProperties: false }),
|
|
138
|
+
...{ outputSchema: Type.Object({ taskId: Type.String(), elapsedMs: ElapsedSchema }) },
|
|
139
|
+
...execution,
|
|
140
|
+
async execute(_id, params, _signal, _update, ctx) {
|
|
141
|
+
requireMainWork();
|
|
142
|
+
const todo = state.getTodo(params.taskId);
|
|
143
|
+
if (!todo?.delegatedTimes?.length)
|
|
144
|
+
throw new Error("This task has no timing handoff registered by AgentCreate.");
|
|
145
|
+
const updates = [];
|
|
146
|
+
for (const source of todo.delegatedTimes) {
|
|
147
|
+
const path = await reportFile(ctx.cwd, source.reportPath);
|
|
148
|
+
const report = await readReport(path);
|
|
149
|
+
if (report.parentSessionId !== ctx.sessionManager.getSessionId() || report.parentWorkId !== todo.workId || report.parentTaskId !== todo.taskId) {
|
|
150
|
+
throw new Error("Timing report belongs to another parent assignment.");
|
|
151
|
+
}
|
|
152
|
+
if (source.workerSessionId && source.workerSessionId !== report.workerSessionId)
|
|
153
|
+
throw new Error("Timing report belongs to another worker session.");
|
|
154
|
+
updates.push({ reportPath: source.reportPath, workerSessionId: report.workerSessionId ?? undefined, elapsedMs: measuredTotal(report) });
|
|
155
|
+
}
|
|
156
|
+
for (const source of updates)
|
|
157
|
+
state.setDelegatedTime(todo.taskId, source);
|
|
158
|
+
const elapsedMs = taskTime(state.getTodo(todo.taskId));
|
|
159
|
+
const data = { taskId: todo.taskId, elapsedMs };
|
|
160
|
+
return { ...taskResult(`Imported timing for ${todo.taskId}: ${formatTime(elapsedMs)}. Status remains ${todo.status}.${updates.some((source) => !source.workerSessionId) ? " A worker has not exported its measurement yet." : ""}`, "task-time-import", data), structuredContent: data };
|
|
161
|
+
},
|
|
162
|
+
renderCall: renderTaskCall("TaskTimeImport"), renderResult: renderTaskResult,
|
|
163
|
+
});
|
|
164
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/** Session-scoped work and todo tracking for Pi. */
|
|
2
2
|
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
3
3
|
export default function tasksExtension(pi: ExtensionAPI): void;
|
|
4
|
-
export type { Todo, TodoStatus, Work, WorkWithTodos } from "./types.js";
|
|
4
|
+
export type { DelegatedTime, Todo, TodoStatus, Work, WorkWithTodos } from "./types.js";
|
package/dist/index.js
CHANGED
|
@@ -2,8 +2,9 @@ import { delegateLink, focusPane } from "./agents/links.js";
|
|
|
2
2
|
import { registerAgentTools } from "./agents/tools.js";
|
|
3
3
|
import { registerTaskAutoContinue } from "./auto-continue.js";
|
|
4
4
|
import { registerWorksCommand } from "./command.js";
|
|
5
|
+
import { registerDelegatedTimeTools } from "./delegated-time.js";
|
|
5
6
|
import { GitStatusCache } from "./git-status.js";
|
|
6
|
-
import { openRepository, openSession } from "./open-repository.js";
|
|
7
|
+
import { openRepository, openSession, readOpenCommand } from "./open-repository.js";
|
|
7
8
|
import { TaskState } from "./state.js";
|
|
8
9
|
import { safeSingleLine } from "./text.js";
|
|
9
10
|
import { registerTaskTiming } from "./timing.js";
|
|
@@ -14,13 +15,15 @@ export default function tasksExtension(pi) {
|
|
|
14
15
|
let panel;
|
|
15
16
|
const state = new TaskState(pi, () => panel?.update());
|
|
16
17
|
const git = new GitStatusCache();
|
|
17
|
-
|
|
18
|
+
const getOpenCommand = () => readOpenCommand(pi.getSettings?.());
|
|
19
|
+
panel = new TasksPanelHost(state, git, getOpenCommand);
|
|
18
20
|
registerTaskTools(pi, state);
|
|
21
|
+
registerDelegatedTimeTools(pi, state);
|
|
19
22
|
registerTaskTiming(pi, state);
|
|
20
23
|
registerAgentTools(pi, state);
|
|
21
24
|
registerTrackingGuidance(pi);
|
|
22
25
|
registerTaskAutoContinue(pi, state);
|
|
23
|
-
registerWorksCommand(pi, state, git);
|
|
26
|
+
registerWorksCommand(pi, state, git, getOpenCommand);
|
|
24
27
|
pi.registerCommand("works-panel", {
|
|
25
28
|
description: "Set the works panel display mode",
|
|
26
29
|
handler: async (args, ctx) => {
|
|
@@ -45,15 +48,16 @@ export default function tasksExtension(pi) {
|
|
|
45
48
|
}
|
|
46
49
|
if (requested === "open" || requested === "open-session") {
|
|
47
50
|
try {
|
|
51
|
+
const command = getOpenCommand();
|
|
48
52
|
if (requested === "open-session")
|
|
49
|
-
await openSession(ctx.cwd, ctx.sessionManager.getSessionId());
|
|
53
|
+
await openSession(ctx.cwd, ctx.sessionManager.getSessionId(), command);
|
|
50
54
|
else
|
|
51
|
-
await openRepository(ctx.cwd);
|
|
52
|
-
ctx.ui.notify(requested === "open-session" ? "Opened session artifacts
|
|
55
|
+
await openRepository(ctx.cwd, command);
|
|
56
|
+
ctx.ui.notify(requested === "open-session" ? "Opened session artifacts." : "Opened repository.", "info");
|
|
53
57
|
}
|
|
54
58
|
catch (error) {
|
|
55
59
|
const reason = error instanceof Error ? ` ${safeSingleLine(error.message)}` : "";
|
|
56
|
-
ctx.ui.notify(`Could not open
|
|
60
|
+
ctx.ui.notify(`Could not open directory. Check pi-tasks.openCommand and that its executable is installed on PATH.${reason}`, "error");
|
|
57
61
|
}
|
|
58
62
|
return;
|
|
59
63
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
export declare function
|
|
1
|
+
/** Read the executable and fixed arguments from Pi's merged settings. */
|
|
2
|
+
export declare function readOpenCommand(settings: unknown): string[];
|
|
3
|
+
/** Launch the configured command without a shell, appending the target directory. */
|
|
4
|
+
export declare function openRepository(cwd: string, command?: string[]): Promise<void>;
|
|
3
5
|
/** Open the existing direct or nested agent artifact root, creating a new root only if needed. */
|
|
4
|
-
export declare function openSession(cwd: string, sessionId: string): Promise<void>;
|
|
6
|
+
export declare function openSession(cwd: string, sessionId: string, command?: string[]): Promise<void>;
|
package/dist/open-repository.js
CHANGED
|
@@ -3,12 +3,26 @@ import { glob, mkdir, stat } from "node:fs/promises";
|
|
|
3
3
|
import { resolve } from "node:path";
|
|
4
4
|
import { promisify } from "node:util";
|
|
5
5
|
const execFileAsync = promisify(execFile);
|
|
6
|
-
/**
|
|
7
|
-
export
|
|
8
|
-
|
|
6
|
+
/** Read the executable and fixed arguments from Pi's merged settings. */
|
|
7
|
+
export function readOpenCommand(settings) {
|
|
8
|
+
const config = settings !== null && typeof settings === "object" ? settings["pi-tasks"] : undefined;
|
|
9
|
+
const command = config !== null && typeof config === "object" ? config.openCommand : undefined;
|
|
10
|
+
if (command === undefined)
|
|
11
|
+
return ["cursor"];
|
|
12
|
+
if (!Array.isArray(command) || command.length === 0 || command.some((part) => typeof part !== "string" || part.includes("\0")) || !command[0].trim()) {
|
|
13
|
+
throw new Error("pi-tasks.openCommand must be a nonempty array of strings starting with an executable, for example [\"code\", \"--new-window\"].");
|
|
14
|
+
}
|
|
15
|
+
return [...command];
|
|
16
|
+
}
|
|
17
|
+
/** Launch the configured command without a shell, appending the target directory. */
|
|
18
|
+
export async function openRepository(cwd, command = ["cursor"]) {
|
|
19
|
+
const [executable, ...args] = command;
|
|
20
|
+
if (!executable)
|
|
21
|
+
throw new Error("An open command executable is required.");
|
|
22
|
+
await execFileAsync(executable, [...args, "."], { cwd, timeout: 10_000, maxBuffer: 64 * 1024, windowsHide: true });
|
|
9
23
|
}
|
|
10
24
|
/** Open the existing direct or nested agent artifact root, creating a new root only if needed. */
|
|
11
|
-
export async function openSession(cwd, sessionId) {
|
|
25
|
+
export async function openSession(cwd, sessionId, command = ["cursor"]) {
|
|
12
26
|
if (!/^[A-Za-z0-9][A-Za-z0-9_-]*$/.test(sessionId))
|
|
13
27
|
throw new Error("A valid Pi session ID is required to open session artifacts.");
|
|
14
28
|
const repository = await execFileAsync("git", ["rev-parse", "--show-toplevel"], { cwd, timeout: 5_000, maxBuffer: 64 * 1024, windowsHide: true })
|
|
@@ -25,5 +39,5 @@ export async function openSession(cwd, sessionId) {
|
|
|
25
39
|
throw new Error("Multiple artifact folders match this session; open the intended folder explicitly.");
|
|
26
40
|
const directory = matches[0] ?? resolve(varRoot, sessionId);
|
|
27
41
|
await mkdir(directory, { recursive: true });
|
|
28
|
-
await openRepository(directory);
|
|
42
|
+
await openRepository(directory, command);
|
|
29
43
|
}
|
package/dist/state.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
import type { Todo, TodoStatus, Work, WorkWithTodos } from "./types.js";
|
|
2
|
+
import type { DelegatedTime, Todo, TodoStatus, Work, WorkWithTodos } from "./types.js";
|
|
3
3
|
export declare const TASK_ENTRY_TYPE = "pi-tasks-state";
|
|
4
4
|
export declare const MAX_WORKS = 100;
|
|
5
5
|
export declare const MAX_TODOS = 500;
|
|
@@ -38,6 +38,8 @@ export declare class TaskState {
|
|
|
38
38
|
updateTodo(taskId: string, patch: Partial<Pick<Todo, "taskName" | "taskInfo" | "status" | "blockedReason" | "completionPercent">> & {
|
|
39
39
|
working?: boolean;
|
|
40
40
|
}): Todo;
|
|
41
|
+
/** Replace a cumulative assignment snapshot, never add it again on retry. */
|
|
42
|
+
setDelegatedTime(taskId: string, source: DelegatedTime): void;
|
|
41
43
|
deleteTodo(taskId: string): boolean;
|
|
42
44
|
private record;
|
|
43
45
|
private apply;
|
package/dist/state.js
CHANGED
|
@@ -63,7 +63,7 @@ export class TaskState {
|
|
|
63
63
|
return todo ? this.snapshot(todo) : undefined;
|
|
64
64
|
}
|
|
65
65
|
snapshot(todo) {
|
|
66
|
-
return { ...todo, workingSince: todo.taskId === this.focusedTaskId ? this.workingSince : undefined };
|
|
66
|
+
return { ...todo, delegatedTimes: todo.delegatedTimes?.map((source) => ({ ...source })), workingSince: todo.taskId === this.focusedTaskId ? this.workingSince : undefined };
|
|
67
67
|
}
|
|
68
68
|
/** Gate the selected task on actual agent execution, not task status. */
|
|
69
69
|
setAgentRunning(running) {
|
|
@@ -200,6 +200,20 @@ export class TaskState {
|
|
|
200
200
|
this.setWorking(taskId, patch.working);
|
|
201
201
|
return this.getTodo(taskId);
|
|
202
202
|
}
|
|
203
|
+
/** Replace a cumulative assignment snapshot, never add it again on retry. */
|
|
204
|
+
setDelegatedTime(taskId, source) {
|
|
205
|
+
const todo = this.todos.get(taskId);
|
|
206
|
+
if (!todo || taskOwner(todo.taskInfo) !== "delegate")
|
|
207
|
+
throw new Error("Delegated timing requires an existing owner: delegate task.");
|
|
208
|
+
if (!validDelegatedTime(source))
|
|
209
|
+
throw new Error("Invalid delegated timing source.");
|
|
210
|
+
const previous = todo.delegatedTimes?.find((entry) => entry.reportPath === source.reportPath);
|
|
211
|
+
if (previous?.workerSessionId && previous.workerSessionId !== source.workerSessionId)
|
|
212
|
+
throw new Error("Timing report belongs to another worker session.");
|
|
213
|
+
if (previous?.elapsedMs === source.elapsedMs && previous?.workerSessionId === source.workerSessionId)
|
|
214
|
+
return;
|
|
215
|
+
this.record({ version: 1, type: "todo-delegated-time", at: Date.now(), taskId, source });
|
|
216
|
+
}
|
|
203
217
|
deleteTodo(taskId) {
|
|
204
218
|
if (!this.todos.has(taskId))
|
|
205
219
|
return false;
|
|
@@ -260,6 +274,7 @@ export class TaskState {
|
|
|
260
274
|
taskName: safeSingleLine(event.todo.taskName),
|
|
261
275
|
completionPercent: taskCompletion(event.todo),
|
|
262
276
|
elapsedMs: validElapsed(event.todo.elapsedMs) ? event.todo.elapsedMs : null,
|
|
277
|
+
delegatedTimes: undefined,
|
|
263
278
|
workingSince: undefined,
|
|
264
279
|
});
|
|
265
280
|
this.nextTaskId = Math.max(this.nextTaskId, numericId(event.todo.taskId) + 1);
|
|
@@ -293,6 +308,14 @@ export class TaskState {
|
|
|
293
308
|
this.todos.set(event.taskId, { ...todo, elapsedMs: event.elapsedMs });
|
|
294
309
|
break;
|
|
295
310
|
}
|
|
311
|
+
case "todo-delegated-time": {
|
|
312
|
+
const todo = this.todos.get(event.taskId);
|
|
313
|
+
if (todo && validDelegatedTime(event.source)) {
|
|
314
|
+
const sources = (todo.delegatedTimes ?? []).filter((source) => source.reportPath !== event.source.reportPath);
|
|
315
|
+
this.todos.set(event.taskId, { ...todo, delegatedTimes: [...sources, { ...event.source }] });
|
|
316
|
+
}
|
|
317
|
+
break;
|
|
318
|
+
}
|
|
296
319
|
case "todo-deleted":
|
|
297
320
|
this.todos.delete(event.taskId);
|
|
298
321
|
break;
|
|
@@ -317,6 +340,11 @@ function normalizeBlockedReason(status, supplied, current) {
|
|
|
317
340
|
throw new Error("blockedReason must not exceed 10000 characters.");
|
|
318
341
|
return reason;
|
|
319
342
|
}
|
|
343
|
+
function validDelegatedTime(value) {
|
|
344
|
+
return !!value && typeof value.reportPath === "string" && value.reportPath.length > 0
|
|
345
|
+
&& (value.elapsedMs === null || validElapsed(value.elapsedMs))
|
|
346
|
+
&& (value.workerSessionId === undefined || (typeof value.workerSessionId === "string" && /^[A-Za-z0-9][A-Za-z0-9_-]*$/.test(value.workerSessionId)));
|
|
347
|
+
}
|
|
320
348
|
function validElapsed(value) {
|
|
321
349
|
return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
|
|
322
350
|
}
|
|
@@ -368,7 +396,7 @@ function parseEvent(value) {
|
|
|
368
396
|
const candidate = value;
|
|
369
397
|
if (candidate.version !== 1 || typeof candidate.type !== "string")
|
|
370
398
|
return undefined;
|
|
371
|
-
if (!["work-created", "work-updated", "work-deleted", "todo-created", "todo-updated", "todo-deleted", "todo-time"].includes(candidate.type))
|
|
399
|
+
if (!["work-created", "work-updated", "work-deleted", "todo-created", "todo-updated", "todo-deleted", "todo-time", "todo-delegated-time"].includes(candidate.type))
|
|
372
400
|
return undefined;
|
|
373
401
|
return value;
|
|
374
402
|
}
|
package/dist/time.js
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import { taskOwner } from "./ownership.js";
|
|
2
2
|
/** Measured task effort, not time since task creation. */
|
|
3
3
|
export function taskTime(todo, now = Date.now()) {
|
|
4
|
-
//
|
|
5
|
-
|
|
6
|
-
if (taskOwner(todo.taskInfo) === "delegate" || todo.elapsedMs === undefined || todo.elapsedMs === null)
|
|
4
|
+
// A delegate without a report is unmeasured, not a zero-length assignment.
|
|
5
|
+
if (taskOwner(todo.taskInfo) === "delegate" && !todo.delegatedTimes?.length)
|
|
7
6
|
return null;
|
|
8
|
-
|
|
7
|
+
if (todo.elapsedMs === undefined || todo.elapsedMs === null)
|
|
8
|
+
return null;
|
|
9
|
+
let total = todo.elapsedMs + (todo.workingSince === undefined ? 0 : Math.max(0, now - todo.workingSince));
|
|
10
|
+
for (const source of todo.delegatedTimes ?? []) {
|
|
11
|
+
if (source.elapsedMs === null)
|
|
12
|
+
return null;
|
|
13
|
+
total += source.elapsedMs;
|
|
14
|
+
}
|
|
15
|
+
return Number.isSafeInteger(total) ? total : null;
|
|
9
16
|
}
|
|
10
17
|
/** Cancelled tasks still consumed effort. Unknown historical time stays unknown. */
|
|
11
18
|
export function workTime(work, now = Date.now()) {
|
|
@@ -15,6 +22,8 @@ export function workTime(work, now = Date.now()) {
|
|
|
15
22
|
if (elapsed === null)
|
|
16
23
|
return null;
|
|
17
24
|
total += elapsed;
|
|
25
|
+
if (!Number.isSafeInteger(total))
|
|
26
|
+
return null;
|
|
18
27
|
}
|
|
19
28
|
return work.tasks.length ? total : null;
|
|
20
29
|
}
|
package/dist/tracking.js
CHANGED
|
@@ -20,7 +20,7 @@ Before implementation, investigation, or any other requested work:
|
|
|
20
20
|
1. Use WorkList and TodoList to find the relevant existing records and avoid duplicates.
|
|
21
21
|
2. If no suitable work exists, create one with WorkCreate. Otherwise use WorkUpdate when its scope or shared context needs refreshing.
|
|
22
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.
|
|
23
|
-
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.
|
|
23
|
+
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
24
|
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
25
|
|
|
26
26
|
During and after the attempt:
|
package/dist/types.d.ts
CHANGED
|
@@ -6,6 +6,12 @@ export interface Work {
|
|
|
6
6
|
createdAt: number;
|
|
7
7
|
updatedAt: number;
|
|
8
8
|
}
|
|
9
|
+
/** One assignment's cumulative imported effort; absent measurement stays unknown. */
|
|
10
|
+
export interface DelegatedTime {
|
|
11
|
+
reportPath: string;
|
|
12
|
+
elapsedMs: number | null;
|
|
13
|
+
workerSessionId?: string;
|
|
14
|
+
}
|
|
9
15
|
export interface Todo {
|
|
10
16
|
taskId: string;
|
|
11
17
|
workId: string;
|
|
@@ -17,6 +23,7 @@ export interface Todo {
|
|
|
17
23
|
completionPercent?: number | null;
|
|
18
24
|
/** Accumulated measured time; missing/null means historical time is unknown. */
|
|
19
25
|
elapsedMs?: number | null;
|
|
26
|
+
delegatedTimes?: DelegatedTime[];
|
|
20
27
|
/** Current interval start, exposed only in live snapshots, never restored. */
|
|
21
28
|
workingSince?: number;
|
|
22
29
|
createdAt: number;
|
|
@@ -58,6 +65,12 @@ export type TaskEvent = {
|
|
|
58
65
|
at: number;
|
|
59
66
|
taskId: string;
|
|
60
67
|
elapsedMs: number;
|
|
68
|
+
} | {
|
|
69
|
+
version: 1;
|
|
70
|
+
type: "todo-delegated-time";
|
|
71
|
+
at: number;
|
|
72
|
+
taskId: string;
|
|
73
|
+
source: DelegatedTime;
|
|
61
74
|
} | {
|
|
62
75
|
version: 1;
|
|
63
76
|
type: "todo-deleted";
|
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
|
@@ -18,6 +18,7 @@ export function metricsContentWidth(width) {
|
|
|
18
18
|
export class TasksPanelHost {
|
|
19
19
|
state;
|
|
20
20
|
git;
|
|
21
|
+
getOpenCommand;
|
|
21
22
|
tui;
|
|
22
23
|
panel;
|
|
23
24
|
handle;
|
|
@@ -26,9 +27,10 @@ export class TasksPanelHost {
|
|
|
26
27
|
minimized = false;
|
|
27
28
|
cwd = "";
|
|
28
29
|
sessionId = "Session unavailable";
|
|
29
|
-
constructor(state, git) {
|
|
30
|
+
constructor(state, git, getOpenCommand) {
|
|
30
31
|
this.state = state;
|
|
31
32
|
this.git = git;
|
|
33
|
+
this.getOpenCommand = getOpenCommand;
|
|
32
34
|
}
|
|
33
35
|
attach(ui, cwd, sessionId) {
|
|
34
36
|
this.hideCurrent();
|
|
@@ -71,7 +73,7 @@ export class TasksPanelHost {
|
|
|
71
73
|
this.tui = tui;
|
|
72
74
|
this.panel = new TasksPanel(tui, this.state, theme, "widget", this.minimized, (minimized) => {
|
|
73
75
|
this.minimized = minimized;
|
|
74
|
-
}, (message, type) => ui.notify(message, type), this.cwd, this.git, this.sessionId);
|
|
76
|
+
}, (message, type) => ui.notify(message, type), this.cwd, this.git, this.sessionId, this.getOpenCommand);
|
|
75
77
|
return this.panel;
|
|
76
78
|
});
|
|
77
79
|
return;
|
|
@@ -80,7 +82,7 @@ export class TasksPanelHost {
|
|
|
80
82
|
this.tui = tui;
|
|
81
83
|
this.panel = new TasksPanel(tui, this.state, theme, "floating", this.minimized, (minimized) => {
|
|
82
84
|
this.minimized = minimized;
|
|
83
|
-
}, (message, type) => ui.notify(message, type), this.cwd, this.git, this.sessionId);
|
|
85
|
+
}, (message, type) => ui.notify(message, type), this.cwd, this.git, this.sessionId, this.getOpenCommand);
|
|
84
86
|
this.handle = tui.showOverlay(this.panel, {
|
|
85
87
|
anchor: "top-right",
|
|
86
88
|
width: "42%",
|
|
@@ -118,6 +120,7 @@ class TasksPanel {
|
|
|
118
120
|
cwd;
|
|
119
121
|
git;
|
|
120
122
|
sessionId;
|
|
123
|
+
getOpenCommand;
|
|
121
124
|
scrollOffset = 0;
|
|
122
125
|
pageSize = 1;
|
|
123
126
|
contentLength = 0;
|
|
@@ -133,7 +136,7 @@ class TasksPanel {
|
|
|
133
136
|
openHitRegion;
|
|
134
137
|
sessionHitRegion;
|
|
135
138
|
toggleHitRegion;
|
|
136
|
-
constructor(tui, state, theme, placement, minimized, onMinimizedChange, notify, cwd, git, sessionId) {
|
|
139
|
+
constructor(tui, state, theme, placement, minimized, onMinimizedChange, notify, cwd, git, sessionId, getOpenCommand) {
|
|
137
140
|
this.tui = tui;
|
|
138
141
|
this.state = state;
|
|
139
142
|
this.theme = theme;
|
|
@@ -144,6 +147,7 @@ class TasksPanel {
|
|
|
144
147
|
this.cwd = cwd;
|
|
145
148
|
this.git = git;
|
|
146
149
|
this.sessionId = sessionId;
|
|
150
|
+
this.getOpenCommand = getOpenCommand;
|
|
147
151
|
}
|
|
148
152
|
render(width) {
|
|
149
153
|
this.delegateHits = [];
|
|
@@ -247,11 +251,11 @@ class TasksPanel {
|
|
|
247
251
|
return { handled: true, render: true };
|
|
248
252
|
}
|
|
249
253
|
if (this.isHit(event.x, this.sessionHitRegion)) {
|
|
250
|
-
void this.
|
|
254
|
+
void this.openDirectory(true);
|
|
251
255
|
return { handled: true, render: true };
|
|
252
256
|
}
|
|
253
257
|
if (this.isHit(event.x, this.openHitRegion)) {
|
|
254
|
-
void this.
|
|
258
|
+
void this.openDirectory();
|
|
255
259
|
return { handled: true, render: true };
|
|
256
260
|
}
|
|
257
261
|
}
|
|
@@ -341,23 +345,24 @@ class TasksPanel {
|
|
|
341
345
|
this.openingDelegate = false;
|
|
342
346
|
}
|
|
343
347
|
}
|
|
344
|
-
async
|
|
348
|
+
async openDirectory(session = false) {
|
|
345
349
|
if (this.opening)
|
|
346
350
|
return;
|
|
347
351
|
this.opening = true;
|
|
348
352
|
this.tui.requestRender();
|
|
349
353
|
try {
|
|
354
|
+
const command = this.getOpenCommand();
|
|
350
355
|
if (session)
|
|
351
|
-
await openSession(this.cwd, this.sessionId);
|
|
356
|
+
await openSession(this.cwd, this.sessionId, command);
|
|
352
357
|
else
|
|
353
|
-
await openRepository(this.cwd);
|
|
358
|
+
await openRepository(this.cwd, command);
|
|
354
359
|
if (!this.disposed)
|
|
355
|
-
this.notify(session ? "Opened session artifacts
|
|
360
|
+
this.notify(session ? "Opened session artifacts." : "Opened repository.", "info");
|
|
356
361
|
}
|
|
357
362
|
catch (error) {
|
|
358
363
|
const reason = error instanceof Error ? ` ${safeSingleLine(error.message)}` : "";
|
|
359
364
|
if (!this.disposed)
|
|
360
|
-
this.notify(
|
|
365
|
+
this.notify(`Could not open ${session ? "session artifacts" : "repository"}. Check pi-tasks.openCommand and that its executable is installed on PATH.${reason}`, "error");
|
|
361
366
|
}
|
|
362
367
|
finally {
|
|
363
368
|
this.opening = false;
|
|
@@ -11,6 +11,7 @@ export declare class WorksDashboard implements Component, Focusable {
|
|
|
11
11
|
private readonly cwd;
|
|
12
12
|
private readonly git;
|
|
13
13
|
private readonly notify;
|
|
14
|
+
private readonly getOpenCommand;
|
|
14
15
|
focused: boolean;
|
|
15
16
|
private selectedKey;
|
|
16
17
|
private scrollOffset;
|
|
@@ -32,7 +33,7 @@ export declare class WorksDashboard implements Component, Focusable {
|
|
|
32
33
|
private toggleHitRegion;
|
|
33
34
|
private disposed;
|
|
34
35
|
private readonly refreshTimer;
|
|
35
|
-
constructor(tui: TUI, theme: Theme, keybindings: KeybindingsManager, state: TaskState, close: () => void, cwd: string, git: GitStatusCache, notify: (message: string, type: "error") => void);
|
|
36
|
+
constructor(tui: TUI, theme: Theme, keybindings: KeybindingsManager, state: TaskState, close: () => void, cwd: string, git: GitStatusCache, notify: (message: string, type: "error") => void, getOpenCommand: () => string[]);
|
|
36
37
|
render(width: number): string[];
|
|
37
38
|
handleInput(data: string): void;
|
|
38
39
|
handleMouse(event: TuiMouseEvent): TuiMouseEventResult | undefined;
|
|
@@ -50,7 +51,7 @@ export declare class WorksDashboard implements Component, Focusable {
|
|
|
50
51
|
private toggleMinimized;
|
|
51
52
|
private isHit;
|
|
52
53
|
private openLinkedDelegate;
|
|
53
|
-
private
|
|
54
|
+
private openDirectory;
|
|
54
55
|
private copyAllAsMarkdown;
|
|
55
56
|
private renderFooter;
|
|
56
57
|
}
|
|
@@ -17,6 +17,7 @@ export class WorksDashboard {
|
|
|
17
17
|
cwd;
|
|
18
18
|
git;
|
|
19
19
|
notify;
|
|
20
|
+
getOpenCommand;
|
|
20
21
|
focused = false;
|
|
21
22
|
selectedKey;
|
|
22
23
|
scrollOffset = 0;
|
|
@@ -38,7 +39,7 @@ export class WorksDashboard {
|
|
|
38
39
|
toggleHitRegion;
|
|
39
40
|
disposed = false;
|
|
40
41
|
refreshTimer;
|
|
41
|
-
constructor(tui, theme, keybindings, state, close, cwd, git, notify) {
|
|
42
|
+
constructor(tui, theme, keybindings, state, close, cwd, git, notify, getOpenCommand) {
|
|
42
43
|
this.tui = tui;
|
|
43
44
|
this.theme = theme;
|
|
44
45
|
this.keybindings = keybindings;
|
|
@@ -47,6 +48,7 @@ export class WorksDashboard {
|
|
|
47
48
|
this.cwd = cwd;
|
|
48
49
|
this.git = git;
|
|
49
50
|
this.notify = notify;
|
|
51
|
+
this.getOpenCommand = getOpenCommand;
|
|
50
52
|
this.unsubscribeGit = git.subscribe(() => tui.requestRender());
|
|
51
53
|
this.refreshTimer = setInterval(() => {
|
|
52
54
|
if (!this.disposed)
|
|
@@ -140,7 +142,7 @@ export class WorksDashboard {
|
|
|
140
142
|
return;
|
|
141
143
|
}
|
|
142
144
|
if (matchesKey(data, "o")) {
|
|
143
|
-
void this.
|
|
145
|
+
void this.openDirectory();
|
|
144
146
|
return;
|
|
145
147
|
}
|
|
146
148
|
if (matchesKey(data, "m")) {
|
|
@@ -225,7 +227,7 @@ export class WorksDashboard {
|
|
|
225
227
|
return { handled: true, focus: true, render: true };
|
|
226
228
|
}
|
|
227
229
|
if (this.isHit(event.x, this.openHitRegion)) {
|
|
228
|
-
void this.
|
|
230
|
+
void this.openDirectory();
|
|
229
231
|
return { handled: true, focus: true, render: true };
|
|
230
232
|
}
|
|
231
233
|
return undefined;
|
|
@@ -418,21 +420,21 @@ export class WorksDashboard {
|
|
|
418
420
|
this.tui.requestRender();
|
|
419
421
|
}
|
|
420
422
|
}
|
|
421
|
-
async
|
|
423
|
+
async openDirectory() {
|
|
422
424
|
if (this.opening)
|
|
423
425
|
return;
|
|
424
426
|
this.opening = true;
|
|
425
|
-
this.message = "Opening repository
|
|
427
|
+
this.message = "Opening repository…";
|
|
426
428
|
this.messageColor = "warning";
|
|
427
429
|
this.tui.requestRender();
|
|
428
430
|
try {
|
|
429
|
-
await openRepository(this.cwd);
|
|
430
|
-
this.message = "Opened repository
|
|
431
|
+
await openRepository(this.cwd, this.getOpenCommand());
|
|
432
|
+
this.message = "Opened repository.";
|
|
431
433
|
this.messageColor = "success";
|
|
432
434
|
}
|
|
433
435
|
catch (error) {
|
|
434
436
|
const reason = error instanceof Error ? ` ${safeSingleLine(error.message)}` : "";
|
|
435
|
-
this.message = `Could not open
|
|
437
|
+
this.message = `Could not open repository. Check pi-tasks.openCommand and that its executable is installed on PATH.${reason}`;
|
|
436
438
|
this.messageColor = "error";
|
|
437
439
|
if (!this.disposed)
|
|
438
440
|
this.notify(this.message, "error");
|
|
@@ -469,7 +471,7 @@ export class WorksDashboard {
|
|
|
469
471
|
}
|
|
470
472
|
}
|
|
471
473
|
renderFooter(width) {
|
|
472
|
-
const text = "↑/↓ select · Enter details · Esc close · C copy · O
|
|
474
|
+
const text = "↑/↓ select · Enter details · Esc close · C copy · O open · D delegate · M minimize";
|
|
473
475
|
return truncateToWidth(this.theme.fg("muted", text), width, "");
|
|
474
476
|
}
|
|
475
477
|
}
|
package/docs/REFERENCE.md
CHANGED
|
@@ -20,7 +20,7 @@ Limits:
|
|
|
20
20
|
|
|
21
21
|
A work contains `workId`, `workName`, `workInfo`, `createdAt`, and `updatedAt`. It is a collection with no stored or derived lifecycle status. Work tools do not accept status, and WorkList has no status filter. The public WorkStatus type is removed; consumers should use TodoStatus for task lifecycle.
|
|
22
22
|
|
|
23
|
-
A todo contains `taskId`, `workId`, `taskName`, `taskInfo`, `status`, optional `blockedReason`, optional `completionPercent`, optional `elapsedMs`, runtime-only optional `workingSince`, `createdAt`, and `updatedAt`. Todo status is `active`, `blocked`, `completed`, or `cancelled`; new todos default to `active`.
|
|
23
|
+
A todo contains `taskId`, `workId`, `taskName`, `taskInfo`, `status`, optional `blockedReason`, optional `completionPercent`, optional `elapsedMs`, optional `delegatedTimes`, runtime-only optional `workingSince`, `createdAt`, and `updatedAt`. Todo status is `active`, `blocked`, `completed`, or `cancelled`; new todos default to `active`.
|
|
24
24
|
|
|
25
25
|
The public list shape assembles each work with `tasks: Todo[]`; tasks are stored separately to avoid duplicate state. Work progress is derived, not independently stored or editable.
|
|
26
26
|
|
|
@@ -48,7 +48,13 @@ TaskState owns focus, an agent-running gate, and an in-memory interval timestamp
|
|
|
48
48
|
|
|
49
49
|
`registerTaskTiming` gates focus with agent start/end and nested blocking user-prompt events. Every new `before_agent_start` clears prior selection; native loop continuations can retain selection until final settlement. Abort signals close the interval immediately. Settlement, shutdown, and pre-navigation boundaries close and clear selection. Tool execution and model thinking within an agent loop count; idle and native retry waits between loops do not. Hosts without blocking-prompt events cannot exclude an in-loop extension dialog, but retain loop-boundary pauses. There is no per-second persistence, heartbeat, or crash-recovery registry: forced termination may lose the uncommitted interval.
|
|
50
50
|
|
|
51
|
-
`taskTime`, `workTime`, and `formatTime` supply shared display calculations. Work time sums all tasks, including cancelled tasks, because already-spent effort is real; an empty Work or any unknown task yields unknown. This differs deliberately from completion, which excludes cancelled tasks and averages rather than sums. Delegated workers measure their own session-local
|
|
51
|
+
`taskTime`, `workTime`, and `formatTime` supply shared display calculations. Work time sums all tasks, including cancelled tasks, because already-spent effort is real; an empty Work or any unknown task yields unknown. This differs deliberately from completion, which excludes cancelled tasks and averages rather than sums. Delegated workers measure their own session-local tasks. Parent delegate records remain unknown until their registered assignment snapshots have been exported and imported. Known task effort is the stored local interval total plus imported assignment totals; prompt-to-completion duration is never used as a substitute. Imported sources remain attached across ownership changes so already-consumed effort is not lost. Unknown local history or any unknown source keeps the aggregate unknown. Unsafe aggregate totals also display unknown. No cross-session task registry or live monitor timing bridge is added.
|
|
52
|
+
|
|
53
|
+
`TaskTimeExport({ reportPath, taskIds })` reads the descriptor created by AgentCreate and writes a paused cumulative snapshot for the explicitly selected worker tasks. The schema contains version 1, parent session/Work/Task IDs, worker session identity and an array of `{ taskId, elapsedMs }` values. The worker cannot supply durations. Export rejects running tasks, missing or duplicate IDs, another worker session, and dropping previously exported tasks. Cancelled tasks belong in the assignment set; unrelated tasks do not. Nested delegate imports must happen before export. Unknown values propagate rather than becoming zero.
|
|
54
|
+
|
|
55
|
+
`TaskTimeImport({ taskId })` reads only the paths already registered on that parent task, validates parent and worker identities, and persists the latest snapshot per source. Missing exports remain unknown; missing files and malformed reports produce errors. Validation finishes before state updates begin. A version-1 `todo-delegated-time` event stores `{ reportPath, elapsedMs, workerSessionId? }` per assignment. Re-import replaces the source instead of adding it again, so follow-up cumulative exports and repeated imports do not double-count. Additional AgentCreate assignments add separate sources. Neither export nor import changes status, completion or task descriptive timestamps. Totals remain available after report files or panes are removed, until another explicit import is attempted. Imported events follow the parent branch; files hold the latest worker snapshot and are not branch-versioned, so an explicit import after navigation intentionally reads the latest exported value. Forked parent sessions cannot import reports addressed to the original parent session.
|
|
56
|
+
|
|
57
|
+
Report files are bounded to 128 KB and 500 unique task IDs, contain no task prose, and must be regular files below the repository's canonical var/ tree. Exports use the host file-mutation queue and atomic replacement. Descriptor names are unique per assignment. Existing legacy/manual delegations without a registered report remain unknown. Both worker and parent need the new tools loaded; older readers ignore the new timing event. No migration of historical durations is attempted.
|
|
52
58
|
|
|
53
59
|
Compact floating/widget views refresh running durations once per second while visible and dispose the render timer on hide. `/works` reuses its existing refresh interval. Neither timer writes session entries. Both views reserve Done and Time columns with name clipping, a running marker, and explicit unknown duration. The compact box minimum is 48 columns so the task prefix does not consume the entire name area; widget views hide below that width. Lists, dashboard details, and copied Markdown show the same measured totals.
|
|
54
60
|
|
|
@@ -82,13 +88,13 @@ Any active task across all Works on the current branch requires continuation. Le
|
|
|
82
88
|
|
|
83
89
|
When `maxContinuations` is supplied, at most that many extra continuations are requested per fresh accepted main user run. The next unfinished boundary warns once and suspends continuation; a fresh user prompt resets the cap. With no limit supplied, continuation can consume tokens indefinitely while unfinished records remain, until explicitly interrupted, disabled or otherwise suspended, including during repeated provider failures. This is not a cost cap or a cap on native tool/retry requests, and another extension may independently request work. Settings changes take effect when Pi reloads effective settings, normally through `/reload`.
|
|
84
90
|
|
|
85
|
-
## Repository status and
|
|
91
|
+
## Repository status and opening directories
|
|
86
92
|
|
|
87
93
|
Both terminal views share a cwd-scoped asynchronous Git status cache, separate from persisted work/todo state. The top border centers `git <branch> · S<staged> U<unstaged> ?<untracked>`; zero counts collapse to `clean`, detached HEAD uses `@<shortcommit>`, and narrow frames shorten the branch first. The border label remains when minimized. Initial loading displays `git loading…`, non-repositories have a plain border, and initial read failures display `git unavailable`; refreshes and later failures retain the prior snapshot.
|
|
88
94
|
|
|
89
95
|
The implementation is informed by [pi-powerline-footer's cache behavior](https://github.com/nicobailon/pi-powerline-footer/blob/main/git-status.ts): a one-second cache, asynchronous stale-while-refresh reads, deduplicated requests, cwd/generation guards, read-only Git environment (`GIT_OPTIONAL_LOCKS=0`), and bounded child processes. This extension reads branch and file counts together rather than running a separate branch timer. Attached views share the poller; unsubscribing the last view or shutting down releases it. File-changing `write`, `edit`, and `bash` results expire cached data sooner.
|
|
90
96
|
|
|
91
|
-
Open appears between Copy and Minimize/Maximize. It executes `cursor` with the separate argument `.` in the active session working directory, without a shell. The executable must be on PATH; errors are shown instead of silently failing. `/works-panel open` supplies a command path, and `/works` uses `o`. Open is also available outside Git repositories.
|
|
97
|
+
Open appears between Copy and Minimize/Maximize. It executes the command from `pi-tasks.openCommand` (default `["cursor"]`) with the separate argument `.` appended in the active session working directory, without a shell. The executable must be on PATH or specified by absolute path; errors are shown instead of silently failing. `/works-panel open` supplies a command path, and `/works` uses `o`. Open is also available outside Git repositories.
|
|
92
98
|
|
|
93
99
|
### Ownership display
|
|
94
100
|
|
|
@@ -98,16 +104,16 @@ Open appears between Copy and Minimize/Maximize. It executes `cursor` with the s
|
|
|
98
104
|
|
|
99
105
|
Agent tools are thin, bounded, shell-free Herdr CLI wrappers using actual paneId values. No separate agent handle, private registry, process/session validation, startup receipt, recovery/reconnection or acquisition framework is implemented. Panes are assumed not to be repurposed. Structured CLI errors are reported even with exit code zero, and partial creation failures report the handles already obtained without automatic retry/cleanup.
|
|
100
106
|
|
|
101
|
-
AgentCreate creates a dedicated unfocused tab, starts Pi with the supplied model flags and calls the existing MonitorCreate through ctx.executeTool
|
|
107
|
+
AgentCreate creates a timing descriptor in the existing canonical taskDir, then creates a dedicated unfocused tab, starts Pi with the supplied model flags and calls the existing MonitorCreate through ctx.executeTool. It appends a TaskTimeImport reminder to onSignal; optional onDone remains unchanged. It returns paneId/tabId/monitorId/reportPath, assignmentSent:false and the prepared assignment with TaskTimeExport instructions. The AI must confirm MonitorList shows subscription ready before explicit AgentSend. Follow-up sends do not replace the monitor. AgentClose calls MonitorStop with the supplied monitorId, then closes the supplied pane; callers must use only resources they created. AgentList returns the CLI inventory, including unrelated agents. No subprocess runs during rendering.
|
|
102
108
|
|
|
103
|
-
AgentCreate marks the parent task blocked and stores herdr-pane and herdr-monitor lines in existing taskInfo after successful agent startup and monitor creation; task tools persist and restore these details. TodoUpdate preserves existing link lines for delegate-to-delegate detail edits unless explicit replacement metadata is supplied, so ordinary progress/status descriptions do not silently disable navigation. Changing ownership, explicit `herdr-pane: none`, or AgentClose can unlink. delegateLink interprets an unambiguous valid pane ID for owner:delegate inside Herdr. AgentClose removes matching delegate links.
|
|
109
|
+
AgentCreate marks the parent task blocked and stores herdr-pane and herdr-monitor lines in existing taskInfo after successful agent startup and monitor creation; task tools persist and restore these details. TodoUpdate preserves existing link lines for delegate-to-delegate detail edits unless explicit replacement metadata is supplied, so ordinary progress/status descriptions do not silently disable navigation. Changing ownership, explicit `herdr-pane: none`, or AgentClose can unlink. delegateLink interprets an unambiguous valid pane ID for owner:delegate inside Herdr. AgentClose removes matching delegate links. Pane links do not change task schema or complete tasks automatically; separate delegatedTimes fields hold timing snapshots. Execution of onSignal/onDone remains owned by pi-loop-monitor; onDone means its process ended, not that worker work is complete.
|
|
104
110
|
|
|
105
111
|
Delegate navigation and AgentFocus first focus the pane, then explicitly activate the tab returned by Herdr; pane-focus success alone does not guarantee that the visible client switched tabs.
|
|
106
112
|
|
|
107
|
-
Linked `[delegate]` badges and
|
|
113
|
+
Linked `[delegate]` badges and Open controls are underlined. Fullscreen mouse regions use ANSI-aware visible columns and only include complete visible badges after clipping and scrolling. Floating/widget rows, dashboard rows and todo detail headings support clicks; hidden/minimized/offscreen badges have no regions. In `/works`, `d` opens the selected task's delegate, and `/works-panel delegate T<number>` provides a command path in regular mode. Outside Herdr or without a pane link, ownership stays informational and is not underlined. Unavailable CLI, stale/closed targets and other navigation failures produce visible errors.
|
|
108
114
|
|
|
109
115
|
## Interfaces
|
|
110
116
|
|
|
111
|
-
The compact panel defaults to a non-capturing floating overlay anchored at the top-right. Its header hides the session ID and places an underlined Open session action immediately after Copy, including minimized/widget layouts. The action uses the Pi session-context identity to locate the matching direct/nested artifact directory under repository var and opens it via the
|
|
117
|
+
The compact panel defaults to a non-capturing floating overlay anchored at the top-right. Its header hides the session ID and places an underlined Open session action immediately after Copy, including minimized/widget layouts. The action uses the Pi session-context identity to locate the matching direct/nested artifact directory under repository var and opens it via the configured shell-free launcher. If absent, the standard var/sessionId directory is created on activation; ambiguous matches or unsafe identity fail visibly. No lookup or process launch occurs during rendering. /works-panel open-session supplies a keyboard-command path. Existing repository Open remains separate. On narrow headers, Minimize/Maximize shorten to [-]/[+] to preserve every action and its hit region; overflow hints use remaining space. It prefixes work and todo names with bracketed IDs (`[W1] Name`, `[T1] [self] Name`), alongside status icons, completion counts, and a visible row range when content exceeds the terminal-aware viewport. It hides on terminals narrower than 90 columns or shorter than 18 rows. In fullscreen TUI mode, its title-bar Copy action exports every work and nested todo as Markdown, while Minimize collapses the panel to a restorable title bar that keeps Copy, Open, and Maximize available. `/works-panel minimize` and `/works-panel maximize` provide a keyboard-command path and preserve the collapsed state when switching between floating and widget layouts. Overflow starts at the newest rows and follows newly added tail rows until the user scrolls upward. Mouse-wheel events over the expanded floating panel scroll it directly without taking keyboard focus; regular terminal mode shows the newest rows and uses `/works` for complete browsing and copying. Because Pi treats any persistent overlay as active, the floating mode can block display-mode changes. `/works-panel widget` switches to a right-aligned widget above the editor, renders all rows, and retains the title actions, while `/works-panel off` hides it.
|
|
112
118
|
|
|
113
|
-
`/works` opens a top-centered detailed overlay. List rows and detail headings use the same bracketed ID and ownership prefixes; list metadata no longer repeats the ID after the name. The dashboard title remains unchanged. Stored names remain unchanged. Its top-right Copy action uses `c` to copy every work and nested todo to the system clipboard as Markdown. Its Open action uses `o` to open the current directory
|
|
119
|
+
`/works` opens a top-centered detailed overlay. List rows and detail headings use the same bracketed ID and ownership prefixes; list metadata no longer repeats the ID after the name. The dashboard title remains unchanged. Stored names remain unchanged. Its top-right Copy action uses `c` to copy every work and nested todo to the system clipboard as Markdown. Its Open action uses `o` to open the current directory using the configured command. Its Minimize action uses `m` to collapse the overlay to a framed top bar containing live total work and todo counts, Copy, Open, and a Maximize action; activating Maximize restores the full dashboard. In fullscreen TUI mode, Copy, Open, and Minimize/Maximize also respond to left clicks. Configured selection keys choose records; confirmation or a row click opens a dedicated full detail view that replaces the list within the existing overlay. The view shows Back to works, ID/owner, name, parent work, status/progress/time, a prominent `Reason: ...` line when blocked, and full details. Arrow keys, Page Up/Page Down, and the mouse wheel scroll long details. The Back action or configured cancel key returns to the same list selection and scroll position; cancel from the list closes the dashboard. Delegate badges remain independent click targets and retain their agent-navigation behavior. Work rows also open full Work details. Missing/deleted selections return to the list.
|
package/docs/USAGE_GUIDE.md
CHANGED
|
@@ -79,6 +79,22 @@ Press Escape/abort to stop. The extension will not restart from a monitor wake o
|
|
|
79
79
|
|
|
80
80
|
Omitting `maxContinuations` means no continuation limit: it can keep consuming tokens while unfinished records remain. Manual abort and all other stopping conditions still apply. To cap it, add a positive integer such as `"maxContinuations": 10`. After the configured number of extra continuations, the extension warns and hands control back without changing records. A fresh accepted main user run resets the limit; a rejected prompt or steering/follow-up input queued inside a running activity does not. Set `enabled` to `false` and reload to disable the feature. It checks recorded states, not whether every user requirement was captured or genuinely verified.
|
|
81
81
|
|
|
82
|
+
## Configure Open and Open Session
|
|
83
|
+
|
|
84
|
+
Both actions share `pi-tasks.openCommand` in global `~/.pi/agent/settings.json` (or your custom agent directory) or a trusted project's `.pi/settings.json`. For example, to use VS Code:
|
|
85
|
+
|
|
86
|
+
```json
|
|
87
|
+
{
|
|
88
|
+
"pi-tasks": {
|
|
89
|
+
"openCommand": ["code", "--new-window"]
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Merge this field into your existing settings, then run `/reload`. The array contains an executable followed by optional fixed arguments; the target directory is appended as a separate `.` argument, with the process working directory set to the repository/session directory or session artifact folder. For example, the setting above runs `code --new-window .`. Use `["cursor"]` for Cursor, `["zed"]` for Zed, or `["open", "-a", "Visual Studio Code"]` on macOS. Executable paths and arguments containing spaces belong in individual array entries; no shell quoting, expansion, pipelines, or command substitution is performed.
|
|
95
|
+
|
|
96
|
+
Omitting the setting retains `["cursor"]`. Empty arrays, blank executables, non-string entries, and NUL characters are rejected visibly without launching anything. The executable must be installed on PATH or specified by absolute path. Configuration requires a Pi host with `pi.getSettings()` (Pi 1.2.0+); older hosts retain the Cursor default. Trusted project settings override global settings through Pi's settings API. The floating panel, widget, `/works` Open/`o`, and `/works-panel open|open-session` all use this setting. Open still targets the current session working directory; Open Session still locates or creates this agent's artifact folder.
|
|
97
|
+
|
|
82
98
|
## Work tools
|
|
83
99
|
|
|
84
100
|
```text
|
|
@@ -120,7 +136,30 @@ The first call selects T1; the second pauses T1 and selects T2; the third pauses
|
|
|
120
136
|
|
|
121
137
|
Time is saved total milliseconds plus `Date.now() - workingSince` while running. The extension saves each interval when paused, switched, or finished, not on every one-second display refresh. Thinking and foreground tool execution count. Idle periods, retry delays between agent loops, and blocking extension UI prompts pause timing. Blocking, completion, cancellation, changing away from self ownership, abort, and shutdown close the interval. Select again at the beginning of each new run. A restored session or branch always starts paused and excludes offline time. Abrupt process termination can lose the unsaved current interval; there is no background checkpoint writer. Blocking prompt exclusion requires a Pi host emitting `ui_prompt_start` and `ui_prompt_end`; older hosts retain loop-boundary timing.
|
|
122
138
|
|
|
123
|
-
The compact panel and `/works` show reserved Done and Time columns; `▶` beside a duration means it is running. New tasks show `0s`. Legacy tasks without timing show `—`; selecting one begins measurement from now, not from its creation date. Work time sums task effort, including cancelled tasks; any unknown duration makes its total unknown. This is not elapsed wall-clock time and does not predict completion. Each delegated agent times its own local
|
|
139
|
+
The compact panel and `/works` show reserved Done and Time columns; `▶` beside a duration means it is running. New tasks show `0s`. Legacy tasks without timing show `—`; selecting one begins measurement from now, not from its creation date. Work time sums task effort, including cancelled tasks; any unknown duration makes its total unknown. This is not elapsed wall-clock time and does not predict completion. Each delegated agent times its own local tasks. Parent delegate records show `—` until the worker exports measured time and the parent imports it. Imported effort contributes to both the parent task and its Work, even while the parent task remains blocked. List tools and copied Markdown include durations too.
|
|
140
|
+
|
|
141
|
+
### Delegated timing
|
|
142
|
+
|
|
143
|
+
AgentCreate creates a unique `delegated-time-<id>.json` descriptor below the existing canonical parent task directory and returns its `reportPath`. Its prepared worker assignment includes export instructions; its monitor callback includes import instructions. Herdr still runs the worker and pi-loop-monitor still reports state changes. The timing file, not the notification or chat response, carries the measured values. Both agents need this version of pi-tasks loaded.
|
|
144
|
+
|
|
145
|
+
Before returning, the worker pauses or completes its assignment tasks and exports their timing:
|
|
146
|
+
|
|
147
|
+
```text
|
|
148
|
+
TodoUpdate taskId="T1" working=false
|
|
149
|
+
TaskTimeExport reportPath="<exact path from AgentCreate>" taskIds=["T1", "T2"]
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Use worker-local IDs for every task in this assignment, including cancelled tasks. Exclude unrelated work. Durations are read by the extension; the model never supplies milliseconds. Import any nested delegates before exporting their containing task. Unknown nested or historical effort stays unknown. An export is a paused snapshot, not a live timer; work performed after export needs a new export.
|
|
153
|
+
|
|
154
|
+
After inspecting the worker output, the parent imports timing using its own task ID:
|
|
155
|
+
|
|
156
|
+
```text
|
|
157
|
+
TaskTimeImport taskId="T5"
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Import leaves status and completion unchanged. The parent can remain blocked and still display measured worker effort. Import before closing the worker, so export failures can be corrected. Repeated imports replace the previous cumulative value. After follow-ups, the worker re-exports all previously included task IDs plus any new assignment tasks to the same file, and the parent imports again. A new AgentCreate on the same parent task registers an additional assignment source; its effort is added once, and unreported sources make the total unknown.
|
|
161
|
+
|
|
162
|
+
Report files contain parent IDs, worker session identity and task timing values, not task text or transcripts. They must remain under repository `var/`. A report binds to its first exporting worker session. Missing files, identity mismatches and malformed data produce tool errors; missing worker exports remain unknown rather than zero. Legacy/manual delegations without an AgentCreate report remain unknown. Existing imported totals survive reload and pane closure; newer worker exports only affect the parent after another explicit import. Older extension versions cannot show these imported totals. No polling, background timing registry, or changes to Herdr/pi-loop-monitor are involved.
|
|
124
163
|
|
|
125
164
|
### Completion percentages
|
|
126
165
|
|
|
@@ -149,7 +188,7 @@ These are simple Herdr CLI wrappers in pi-tasks, with no pi-herdr-agents depende
|
|
|
149
188
|
|
|
150
189
|
| Tool | Purpose |
|
|
151
190
|
| --- | --- |
|
|
152
|
-
| `AgentCreate` | Create an unfocused tab, start Pi and register monitoring; return paneId/tabId/monitorId plus a prepared assignment. No prompt is sent. |
|
|
191
|
+
| `AgentCreate` | Create a timing descriptor, an unfocused tab, start Pi and register monitoring; return paneId/tabId/monitorId/reportPath plus a prepared assignment. No prompt is sent. |
|
|
153
192
|
| `AgentList` | `herdr agent list` (includes unrelated agents). |
|
|
154
193
|
| `AgentStatus` | `herdr agent get <paneId>`. |
|
|
155
194
|
| `AgentOutput` | `herdr pane read`; 50 trailing lines by default, up to 200. |
|
|
@@ -174,7 +213,7 @@ AgentCreate({
|
|
|
174
213
|
})
|
|
175
214
|
```
|
|
176
215
|
|
|
177
|
-
Replace placeholders using the existing implement path convention and model-routing-policy. The wrapper
|
|
216
|
+
Replace placeholders using the existing implement path convention and model-routing-policy. The wrapper requires taskDir to exist inside the repository's canonical var/ tree. It creates a timing descriptor there but does not create folders or verify the running model. It adds parent context, worker-local tracking and timing-export instructions without granting extra permissions.
|
|
178
217
|
|
|
179
218
|
AgentCreate returns `assignmentSent: false`. Confirm MonitorList shows `Herdr signal subscription ready for <paneId>`, then call `AgentSend({ paneId, message: assignment })` using the returned assignment. Do not add a second monitor. Follow-up messages use that same paneId and existing subscription.
|
|
180
219
|
|
|
@@ -182,24 +221,24 @@ AgentCreate returns `assignmentSent: false`. Confirm MonitorList shows `Herdr si
|
|
|
182
221
|
|
|
183
222
|
Use actual paneId values, not pane names or a separate agent handle. These wrappers assume an agent pane is not repurposed. There are no process/session checks, startup receipts, registry, automatic reconnection, retry or rollback framework. Ordinary CLI errors are returned with any handles already obtained so the caller can inspect and decide what to do. Close only resources you created; a done signal does not automatically close anything or complete a task. If monitoring stops, use the existing monitor tools to inspect/reconnect explicitly.
|
|
184
223
|
|
|
185
|
-
Inside Herdr (`HERDR_ENV=1`), a linked `[delegate]` is underlined. In fullscreen mode, click that badge in compact/widget rows, dashboard rows, or task detail headings to focus its agent pane. Only fully visible badges are clickable. In `/works`, select the task and press `d`; `/works-panel delegate T<number>` provides a command path, including regular terminal mode. `[Open]` / `[O Open]` are also underlined and
|
|
224
|
+
Inside Herdr (`HERDR_ENV=1`), a linked `[delegate]` is underlined. In fullscreen mode, click that badge in compact/widget rows, dashboard rows, or task detail headings to focus its agent pane. Only fully visible badges are clickable. In `/works`, select the task and press `d`; `/works-panel delegate T<number>` provides a command path, including regular terminal mode. `[Open]` / `[O Open]` are also underlined and use the configured open command. Unlinked badges are not underlined, because they are not navigation actions.
|
|
186
225
|
|
|
187
226
|
Navigation directly focuses the linked paneId through Herdr. Closed panes, missing Herdr CLI and command errors are reported. No subprocess runs during rendering. Agent tools coordinate Herdr resources; pi-loop-monitor remains the sole monitoring runtime. Outside Herdr, badges remain informational.
|
|
188
227
|
|
|
189
|
-
The compact panel no longer displays the session ID. Before Copy, its header shows nonzero task-state counts across all Works: `3!` blocked, `2▶` active, `5✓` completed, and `1×` cancelled, using the same icon colors as task rows. Counts update in floating, widget and minimized layouts; narrow headers shorten the toggle and truncate the summary when needed. Its underlined `[Open session]` action sits immediately after Copy in floating, widget and minimized layouts. It opens this agent's existing artifact directory under repository `var/`
|
|
228
|
+
The compact panel no longer displays the session ID. Before Copy, its header shows nonzero task-state counts across all Works: `3!` blocked, `2▶` active, `5✓` completed, and `1×` cancelled, using the same icon colors as task rows. Counts update in floating, widget and minimized layouts; narrow headers shorten the toggle and truncate the summary when needed. Its underlined `[Open session]` action sits immediately after Copy in floating, widget and minimized layouts. It opens this agent's existing artifact directory under repository `var/` using the configured command, including a nested delegated session folder. If no folder exists, it creates `var/<full-sessionId>/`; multiple matching folders report an ambiguity rather than guessing. Session identity comes from Pi's context, not a pane name. Folder resolution and command launch happen only on activation, never during rendering. `/works-panel open-session` is the keyboard-command alternative. The existing Open action still opens the repository. Narrow compact headers use `[-]`/`[+]` for Minimize/Maximize so all actions fit. The `/works` dashboard retains its existing title and controls.
|
|
190
229
|
|
|
191
230
|
The panel defaults to a floating top-right layout and does not take keyboard focus. Its minimum box width is 48 columns to leave room for names beside both metrics; the widget hides below 48 columns. Separated right-hand Done and Time columns keep work/task percentages and measured durations aligned and visible even when names are long; the left side retains names, task status icons and Work task-counts. Work rows have no status icons. It hides on small terminals. The top border centers repository-wide Git status: `git main · S2 U3 ?1` means two staged files, three unstaged files, and one untracked file; a file with both staged and unstaged edits counts in both. A clean repository shows `git main · clean`. Long branches shorten before counts. Detached HEAD shows `@` plus the short commit. Git remains visible while minimized and adds no content row.
|
|
192
231
|
|
|
193
232
|
The asynchronous Git cache refreshes every second while a view is attached; file-changing tool results expire it sooner without blanking the last snapshot. Initial reads show `git loading…`; outside Git the border is plain, and initial failures show `git unavailable`. Later refresh failures retain the last snapshot until a successful read. Polling is read-only and stops when both the panel and dashboard are closed/off.
|
|
194
233
|
|
|
195
|
-
In fullscreen TUI mode, click Copy in its title bar to copy every work and todo as Markdown, Open to run
|
|
234
|
+
In fullscreen TUI mode, click Copy in its title bar to copy every work and todo as Markdown, Open to run the configured command in the current session directory, or Minimize to collapse the panel to a small title bar. Copy and Open remain available while minimized, and Maximize restores the rows. The configured executable must be on PATH (or be an absolute path); launch failures produce visible error feedback. When more rows exist than fit, the floating panel starts at the newest rows; move the mouse over it and use the wheel to scroll older or newer rows without taking focus from the editor. In regular terminal mode, open `/works` to browse and copy the complete list.
|
|
196
235
|
|
|
197
236
|
Use `/works-panel minimize`, `/works-panel maximize`, `/works-panel open`, or `/works-panel open-session` when mouse input is unavailable. Use `/works-panel widget` for a right-aligned layout above the editor that renders every row and retains the clickable title actions, `/works-panel floating` to return to the floating layout, or `/works-panel off` to hide it.
|
|
198
237
|
|
|
199
238
|
Run `/works` for full details. Its top border mirrors repository-wide Git status, and its top bar includes Copy, Open, and Minimize actions. In fullscreen TUI mode, click Minimize to collapse the dashboard to a top bar showing the current work and todo totals; click Maximize to restore it. The actions also have keyboard shortcuts that work in regular terminal mode.
|
|
200
239
|
|
|
201
240
|
- `c`: copy all works and todos as Markdown
|
|
202
|
-
- `o`: open the current repository/session directory
|
|
241
|
+
- `o`: open the current repository/session directory using the configured command
|
|
203
242
|
- `d`: open the selected task's linked delegated agent
|
|
204
243
|
- `m`: minimize or maximize the dashboard
|
|
205
244
|
- Fullscreen left click: activate header actions, or click a task/work row to open its full details. Clicking a linked delegate badge still opens its agent.
|