@abhishek944/pi-tasks 0.4.0 → 0.7.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/dist/tools.js CHANGED
@@ -5,16 +5,18 @@ import { renderTaskCall, renderTaskResult, taskResult } from "./tool-result.js";
5
5
  const WorkStatusSchema = StringEnum(["planned", "active", "blocked", "completed", "cancelled"]);
6
6
  const TodoStatusSchema = StringEnum(["pending", "active", "blocked", "completed", "cancelled"]);
7
7
  const NameSchema = Type.String({ minLength: 1, maxLength: 240 });
8
- const InfoSchema = Type.String({ minLength: 1, maxLength: 10_000 });
8
+ const DETAILS_GUIDANCE = "Write workInfo and taskInfo in normal prose with full sentences and spaces between words. Conversational brevity modes must not compress stored records or concatenate words.";
9
+ const InfoSchema = Type.String({ minLength: 1, maxLength: 10_000, description: DETAILS_GUIDANCE });
9
10
  export function registerTaskTools(pi, state) {
10
11
  pi.registerTool({
11
12
  name: "WorkCreate",
12
13
  label: "WorkCreate",
13
- description: "Create a session-scoped work item. Use detailed workInfo that preserves the goal, context, scope, constraints, decisions, and expected outcome.",
14
+ description: `Create a session-scoped work item. Use detailed workInfo that preserves the goal, context, scope, constraints, decisions, and expected outcome. ${DETAILS_GUIDANCE}`,
14
15
  promptSnippet: "Create a session-scoped work item before starting substantial actionable work",
15
16
  promptGuidelines: [
16
17
  "Use WorkCreate for normal requests that start new work in the main conversation; never use it during /ask or /btw.",
17
18
  "Before creating work, use WorkList to avoid duplicating an existing work item.",
19
+ DETAILS_GUIDANCE,
18
20
  ],
19
21
  parameters: Type.Object({
20
22
  workName: NameSchema,
@@ -31,14 +33,17 @@ export function registerTaskTools(pi, state) {
31
33
  pi.registerTool({
32
34
  name: "WorkList",
33
35
  label: "WorkList",
34
- description: "List session-scoped works and their associated todos. Results include detailed workInfo and taskInfo and are truncated at 50KB or 2000 lines.",
36
+ description: "List session-scoped works and their associated todos. Optional limit returns the newest N matching works after filtering, in chronological order; omitted returns all. Results include detailed workInfo and taskInfo and are truncated at 50KB or 2000 lines.",
35
37
  parameters: Type.Object({
36
38
  workId: Type.Optional(Type.String()),
37
39
  status: Type.Optional(WorkStatusSchema),
40
+ limit: Type.Optional(Type.Integer({ minimum: 1, description: "Return only the newest N matching works; omit for all." })),
38
41
  }, { additionalProperties: false }),
39
42
  execute(_id, params) {
40
- const works = state.listWorks({ workId: params.workId, status: params.status });
41
- return Promise.resolve(taskResult(bounded(formatWorks(works)), "work-list", { count: works.length }, `${works.length} work${works.length === 1 ? "" : "s"} found`));
43
+ const matches = state.listWorks({ workId: params.workId, status: params.status });
44
+ const works = params.limit === undefined ? matches : matches.slice(-params.limit);
45
+ const summary = `Showing ${works.length} of ${matches.length} matching works`;
46
+ return Promise.resolve(taskResult(bounded(`${summary}\n\n${formatWorks(works)}`), "work-list", { count: works.length, total: matches.length }, summary));
42
47
  },
43
48
  renderCall: renderTaskCall("WorkList"),
44
49
  renderResult: renderTaskResult,
@@ -46,9 +51,9 @@ export function registerTaskTools(pi, state) {
46
51
  pi.registerTool({
47
52
  name: "WorkUpdate",
48
53
  label: "WorkUpdate",
49
- description: "Update a work's name, detailed information, or status. Use before implementation to mark relevant work active and after progress to keep its detailed context current.",
54
+ description: `Update a work's name, detailed information, or status. Use before implementation to mark relevant work active and after progress to keep its detailed context current. ${DETAILS_GUIDANCE}`,
50
55
  promptSnippet: "Update work status and detailed context as actionable work progresses",
51
- promptGuidelines: ["Use WorkUpdate and TodoUpdate before and after actionable main-conversation work; never update tracking during /ask or /btw."],
56
+ promptGuidelines: ["Use WorkUpdate and TodoUpdate before and after actionable main-conversation work; never update tracking during /ask or /btw.", DETAILS_GUIDANCE],
52
57
  parameters: Type.Object({
53
58
  workId: Type.String(),
54
59
  workName: Type.Optional(NameSchema),
@@ -81,11 +86,12 @@ export function registerTaskTools(pi, state) {
81
86
  pi.registerTool({
82
87
  name: "TodoCreate",
83
88
  label: "TodoCreate",
84
- description: "Create a todo under an existing work. taskInfo must contain enough detailed context, scope, constraints, expected outcome, and verification guidance to execute the task without guessing.",
89
+ description: `Create a todo under an existing work. taskInfo must contain enough detailed context, scope, constraints, expected outcome, and verification guidance to execute the task without guessing. ${DETAILS_GUIDANCE}`,
85
90
  promptSnippet: "Create detailed todos under the current work before implementation",
86
91
  promptGuidelines: [
87
92
  "Use TodoCreate only under an existing work and only for actionable main-conversation work; never use it during /ask or /btw.",
88
93
  "Keep taskInfo detailed, current, and self-contained.",
94
+ DETAILS_GUIDANCE,
89
95
  ],
90
96
  parameters: Type.Object({
91
97
  workId: Type.String(),
@@ -103,15 +109,18 @@ export function registerTaskTools(pi, state) {
103
109
  pi.registerTool({
104
110
  name: "TodoList",
105
111
  label: "TodoList",
106
- description: "List todos by task, work, or status. Results include detailed taskInfo and are truncated at 50KB or 2000 lines.",
112
+ description: "List todos by task, work, or status. Optional limit returns the newest N matching todos after filtering, in chronological order; omitted returns all. Results include detailed taskInfo and are truncated at 50KB or 2000 lines.",
107
113
  parameters: Type.Object({
108
114
  taskId: Type.Optional(Type.String()),
109
115
  workId: Type.Optional(Type.String()),
110
116
  status: Type.Optional(TodoStatusSchema),
117
+ limit: Type.Optional(Type.Integer({ minimum: 1, description: "Return only the newest N matching todos; omit for all." })),
111
118
  }, { additionalProperties: false }),
112
119
  execute(_id, params) {
113
- const todos = state.listTodos({ taskId: params.taskId, workId: params.workId, status: params.status });
114
- return Promise.resolve(taskResult(bounded(formatTodos(todos)), "todo-list", { count: todos.length }, `${todos.length} todo${todos.length === 1 ? "" : "s"} found`));
120
+ const matches = state.listTodos({ taskId: params.taskId, workId: params.workId, status: params.status });
121
+ const todos = params.limit === undefined ? matches : matches.slice(-params.limit);
122
+ const summary = `Showing ${todos.length} of ${matches.length} matching todos`;
123
+ return Promise.resolve(taskResult(bounded(`${summary}\n\n${formatTodos(todos)}`), "todo-list", { count: todos.length, total: matches.length }, summary));
115
124
  },
116
125
  renderCall: renderTaskCall("TodoList"),
117
126
  renderResult: renderTaskResult,
@@ -119,9 +128,9 @@ export function registerTaskTools(pi, state) {
119
128
  pi.registerTool({
120
129
  name: "TodoUpdate",
121
130
  label: "TodoUpdate",
122
- description: "Update a todo's name, detailed information, or status. Mark a todo active immediately before starting it and completed or blocked after the attempt.",
131
+ description: `Update a todo's name, detailed information, or status. Mark a todo active immediately before starting it and completed or blocked after the attempt. ${DETAILS_GUIDANCE}`,
123
132
  promptSnippet: "Keep todo status and detailed context synchronized with active work",
124
- promptGuidelines: ["Use TodoUpdate immediately before and after working on a todo in the main conversation; never update tracking during /ask or /btw."],
133
+ promptGuidelines: ["Use TodoUpdate immediately before and after working on a todo in the main conversation; never update tracking during /ask or /btw.", DETAILS_GUIDANCE],
125
134
  parameters: Type.Object({
126
135
  taskId: Type.String(),
127
136
  taskName: Type.Optional(NameSchema),
@@ -1,2 +1,3 @@
1
1
  import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
2
+ export declare function areTrackingToolsActive(pi: ExtensionAPI): boolean;
2
3
  export declare function registerTrackingGuidance(pi: ExtensionAPI): void;
package/dist/tracking.js CHANGED
@@ -3,6 +3,7 @@ const TRACKING_GUIDANCE = `[SESSION COORDINATION]
3
3
  Work is the overall outcome being pursued. A todo is a concrete step that belongs to a work. A monitor runs one long-lived background command. A loop schedules a future, recurring, event-driven, or idle continuation.
4
4
 
5
5
  For every normal user request that starts or continues work, keep the session's work and todo records synchronized. Do not skip tracking because the work looks small.
6
+ Write workInfo and taskInfo in normal prose with full sentences and spaces between words. Conversational brevity modes must not compress stored records or concatenate words.
6
7
 
7
8
  Before implementation, investigation, or any other requested work:
8
9
  1. Use WorkList and TodoList to find the relevant existing records and avoid duplicates.
@@ -17,10 +18,13 @@ During and after the attempt:
17
18
  - Mark the todo completed, blocked, or cancelled as appropriate and update taskInfo with important current context.
18
19
  - Keep the work active while required todos remain, blocked when progress cannot continue, and completed only when its required todos are complete.
19
20
  - Never create or update works, todos, loops, or monitors during /ask, /btw, or any BTW side thread.`;
21
+ export function areTrackingToolsActive(pi) {
22
+ const active = new Set(pi.getActiveTools());
23
+ return REQUIRED_TRACKING_TOOLS.every((name) => active.has(name));
24
+ }
20
25
  export function registerTrackingGuidance(pi) {
21
26
  pi.on("before_agent_start", (event) => {
22
- const active = new Set(pi.getActiveTools());
23
- if (!REQUIRED_TRACKING_TOOLS.every((name) => active.has(name)))
27
+ if (!areTrackingToolsActive(pi))
24
28
  return;
25
29
  return { systemPrompt: `${event.systemPrompt}\n\n${TRACKING_GUIDANCE}` };
26
30
  });
@@ -1,17 +1,20 @@
1
1
  import { type ExtensionUIContext, type Theme } from "@earendil-works/pi-coding-agent";
2
+ import type { GitSnapshot, GitStatusCache } from "../git-status.js";
2
3
  import type { TaskState } from "../state.js";
3
4
  import type { TodoStatus, WorkStatus } from "../types.js";
4
5
  export type TasksPanelMode = "floating" | "widget" | "off";
5
6
  export declare class TasksPanelHost {
6
7
  private readonly state;
8
+ private readonly git;
7
9
  private tui;
8
10
  private panel;
9
11
  private handle;
10
12
  private ui;
11
13
  private mode;
12
14
  private minimized;
13
- constructor(state: TaskState);
14
- attach(ui: ExtensionUIContext): void;
15
+ private cwd;
16
+ constructor(state: TaskState, git: GitStatusCache);
17
+ attach(ui: ExtensionUIContext, cwd: string): void;
15
18
  setMode(mode: TasksPanelMode): void;
16
19
  getMode(): TasksPanelMode;
17
20
  setMinimized(minimized: boolean): void;
@@ -24,4 +27,5 @@ export declare function workIcon(status: WorkStatus, theme: Theme): string;
24
27
  export declare function todoIcon(status: TodoStatus, theme: Theme): string;
25
28
  export declare function frame(content: string, innerWidth: number, theme: Theme): string;
26
29
  export declare function rule(innerWidth: number, theme: Theme): string;
30
+ export declare function gitBorder(innerWidth: number, theme: Theme, snapshot: GitSnapshot): string;
27
31
  export declare function border(innerWidth: number, edge: "top" | "bottom", theme: Theme): string;
package/dist/ui/panel.js CHANGED
@@ -1,21 +1,27 @@
1
+ import { stripVTControlCharacters } from "node:util";
1
2
  import { copyToClipboard } from "@earendil-works/pi-coding-agent";
2
3
  import { truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
3
4
  import { formatWorksMarkdown } from "../markdown.js";
5
+ import { openRepository } from "../open-repository.js";
4
6
  import { safeSingleLine } from "../text.js";
5
7
  const EMPTY_COMPONENT = { render: () => [], invalidate: () => { } };
6
8
  export class TasksPanelHost {
7
9
  state;
10
+ git;
8
11
  tui;
9
12
  panel;
10
13
  handle;
11
14
  ui;
12
15
  mode = "floating";
13
16
  minimized = false;
14
- constructor(state) {
17
+ cwd = "";
18
+ constructor(state, git) {
15
19
  this.state = state;
20
+ this.git = git;
16
21
  }
17
- attach(ui) {
22
+ attach(ui, cwd) {
18
23
  this.hideCurrent();
24
+ this.cwd = cwd;
19
25
  this.ui = ui;
20
26
  this.applyMode();
21
27
  }
@@ -53,7 +59,7 @@ export class TasksPanelHost {
53
59
  this.tui = tui;
54
60
  this.panel = new TasksPanel(tui, this.state, theme, "widget", this.minimized, (minimized) => {
55
61
  this.minimized = minimized;
56
- }, (message, type) => ui.notify(message, type));
62
+ }, (message, type) => ui.notify(message, type), this.cwd, this.git);
57
63
  return this.panel;
58
64
  });
59
65
  return;
@@ -62,7 +68,7 @@ export class TasksPanelHost {
62
68
  this.tui = tui;
63
69
  this.panel = new TasksPanel(tui, this.state, theme, "floating", this.minimized, (minimized) => {
64
70
  this.minimized = minimized;
65
- }, (message, type) => ui.notify(message, type));
71
+ }, (message, type) => ui.notify(message, type), this.cwd, this.git);
66
72
  this.handle = tui.showOverlay(this.panel, {
67
73
  anchor: "top-right",
68
74
  width: "42%",
@@ -70,12 +76,17 @@ export class TasksPanelHost {
70
76
  maxHeight: "48%",
71
77
  margin: { top: 1, right: 1 },
72
78
  nonCapturing: true,
73
- visible: (terminalWidth, terminalHeight) => terminalWidth >= 90 && terminalHeight >= 18,
79
+ visible: (terminalWidth, terminalHeight) => {
80
+ const visible = terminalWidth >= 90 && terminalHeight >= 18;
81
+ this.panel?.setVisible(visible);
82
+ return visible;
83
+ },
74
84
  });
75
85
  return EMPTY_COMPONENT;
76
86
  });
77
87
  }
78
88
  hideCurrent() {
89
+ this.panel?.dispose();
79
90
  this.handle?.hide();
80
91
  this.handle = undefined;
81
92
  this.ui?.setWidget("pi-tasks-panel", undefined);
@@ -92,14 +103,20 @@ class TasksPanel {
92
103
  minimized;
93
104
  onMinimizedChange;
94
105
  notify;
106
+ cwd;
107
+ git;
95
108
  scrollOffset = 0;
96
109
  pageSize = 1;
97
110
  contentLength = 0;
98
111
  followTail = true;
99
112
  copying = false;
113
+ opening = false;
114
+ disposed = false;
115
+ unsubscribeGit;
100
116
  copyHitRegion;
117
+ openHitRegion;
101
118
  toggleHitRegion;
102
- constructor(tui, state, theme, placement, minimized, onMinimizedChange, notify) {
119
+ constructor(tui, state, theme, placement, minimized, onMinimizedChange, notify, cwd, git) {
103
120
  this.tui = tui;
104
121
  this.state = state;
105
122
  this.theme = theme;
@@ -107,8 +124,12 @@ class TasksPanel {
107
124
  this.minimized = minimized;
108
125
  this.onMinimizedChange = onMinimizedChange;
109
126
  this.notify = notify;
127
+ this.cwd = cwd;
128
+ this.git = git;
110
129
  }
111
130
  render(width) {
131
+ if (this.placement === "widget")
132
+ this.setVisible(width >= 38);
112
133
  if (width < 38)
113
134
  return [];
114
135
  const works = this.state.listWorks();
@@ -118,7 +139,7 @@ class TasksPanel {
118
139
  if (this.minimized) {
119
140
  const header = this.renderHeader("Works", innerWidth, leftPad.length);
120
141
  return [
121
- border(innerWidth, "top", this.theme),
142
+ gitBorder(innerWidth, this.theme, this.git.getSnapshot()),
122
143
  frame(header, innerWidth, this.theme),
123
144
  border(innerWidth, "bottom", this.theme),
124
145
  ].map((line) => `${leftPad}${line}`);
@@ -156,7 +177,7 @@ class TasksPanel {
156
177
  }
157
178
  const header = this.renderHeader(title, innerWidth, leftPad.length);
158
179
  const lines = [
159
- border(innerWidth, "top", this.theme),
180
+ gitBorder(innerWidth, this.theme, this.git.getSnapshot()),
160
181
  frame(header, innerWidth, this.theme),
161
182
  rule(innerWidth, this.theme),
162
183
  ...shown.map((line) => frame(line, innerWidth, this.theme)),
@@ -165,6 +186,8 @@ class TasksPanel {
165
186
  return lines.map((line) => `${leftPad}${line}`);
166
187
  }
167
188
  handleMouse(event) {
189
+ if (this.disposed)
190
+ return undefined;
168
191
  if (event.type === "click" && event.button === "left" && event.y === 1) {
169
192
  if (this.isHit(event.x, this.toggleHitRegion)) {
170
193
  this.setMinimized(!this.minimized);
@@ -174,6 +197,10 @@ class TasksPanel {
174
197
  void this.copyAllAsMarkdown();
175
198
  return { handled: true, render: true };
176
199
  }
200
+ if (this.isHit(event.x, this.openHitRegion)) {
201
+ void this.openInCursor();
202
+ return { handled: true, render: true };
203
+ }
177
204
  }
178
205
  if (this.minimized || this.placement !== "floating" || event.type !== "wheel" || !event.wheelDelta)
179
206
  return undefined;
@@ -181,6 +208,23 @@ class TasksPanel {
181
208
  return { handled: true, render: changed };
182
209
  }
183
210
  invalidate() { }
211
+ dispose() {
212
+ if (this.disposed)
213
+ return;
214
+ this.setVisible(false);
215
+ this.disposed = true;
216
+ }
217
+ setVisible(visible) {
218
+ if (this.disposed)
219
+ return;
220
+ if (visible) {
221
+ this.unsubscribeGit ??= this.git.subscribe(() => this.tui.requestRender());
222
+ }
223
+ else {
224
+ this.unsubscribeGit?.();
225
+ this.unsubscribeGit = undefined;
226
+ }
227
+ }
184
228
  setMinimized(minimized) {
185
229
  if (this.minimized === minimized)
186
230
  return;
@@ -193,21 +237,45 @@ class TasksPanel {
193
237
  const copyAction = this.copying
194
238
  ? this.theme.fg("dim", "[Copying…]")
195
239
  : this.theme.fg("accent", this.theme.bold("[Copy]"));
240
+ const openAction = this.theme.fg(this.opening ? "dim" : "accent", this.theme.bold("[Open]"));
196
241
  const toggleLabel = this.minimized ? "[Maximize]" : "[Minimize]";
197
242
  const toggleAction = this.theme.fg("accent", this.theme.bold(toggleLabel));
198
- const actionsWidth = visibleWidth(copyAction) + 1 + visibleWidth(toggleAction);
243
+ const actionsWidth = visibleWidth(copyAction) + 1 + visibleWidth(openAction) + 1 + visibleWidth(toggleAction);
199
244
  const titleWidth = Math.max(0, width - actionsWidth - 1);
200
245
  const shownTitle = truncateToWidth(title, titleWidth, "");
201
246
  const gap = " ".repeat(Math.max(1, width - visibleWidth(shownTitle) - actionsWidth));
202
247
  const copyStart = leftPadWidth + 1 + visibleWidth(shownTitle) + gap.length;
203
248
  this.copyHitRegion = { start: copyStart, end: copyStart + visibleWidth(copyAction) };
204
- const toggleStart = this.copyHitRegion.end + 1;
249
+ const openStart = this.copyHitRegion.end + 1;
250
+ this.openHitRegion = { start: openStart, end: openStart + visibleWidth(openAction) };
251
+ const toggleStart = this.openHitRegion.end + 1;
205
252
  this.toggleHitRegion = { start: toggleStart, end: toggleStart + visibleWidth(toggleAction) };
206
- return `${shownTitle}${gap}${copyAction} ${toggleAction}`;
253
+ return `${shownTitle}${gap}${copyAction} ${openAction} ${toggleAction}`;
207
254
  }
208
255
  isHit(x, region) {
209
256
  return region !== undefined && x >= region.start && x < region.end;
210
257
  }
258
+ async openInCursor() {
259
+ if (this.opening)
260
+ return;
261
+ this.opening = true;
262
+ this.tui.requestRender();
263
+ try {
264
+ await openRepository(this.cwd);
265
+ if (!this.disposed)
266
+ this.notify("Opened repository in Cursor.", "info");
267
+ }
268
+ catch (error) {
269
+ const reason = error instanceof Error ? ` ${safeSingleLine(error.message)}` : "";
270
+ if (!this.disposed)
271
+ this.notify(`Could not open Cursor. Check that cursor is installed on PATH.${reason}`, "error");
272
+ }
273
+ finally {
274
+ this.opening = false;
275
+ if (!this.disposed)
276
+ this.tui.requestRender();
277
+ }
278
+ }
211
279
  async copyAllAsMarkdown() {
212
280
  if (this.copying)
213
281
  return;
@@ -283,6 +351,29 @@ export function frame(content, innerWidth, theme) {
283
351
  export function rule(innerWidth, theme) {
284
352
  return theme.fg("border", `├${"─".repeat(innerWidth)}┤`);
285
353
  }
354
+ export function gitBorder(innerWidth, theme, snapshot) {
355
+ if (snapshot.kind === "not-repository" || innerWidth < 6)
356
+ return border(innerWidth, "top", theme);
357
+ let label;
358
+ if (snapshot.kind === "ready") {
359
+ const clean = snapshot.staged === 0 && snapshot.unstaged === 0 && snapshot.untracked === 0;
360
+ let suffix = clean ? " · clean" : ` · S${snapshot.staged} U${snapshot.unstaged} ?${snapshot.untracked}`;
361
+ if (!clean && visibleWidth(suffix) > innerWidth - 13) {
362
+ const compact = new Intl.NumberFormat("en", { notation: "compact", maximumFractionDigits: 0 });
363
+ suffix = ` · S${compact.format(snapshot.staged)} U${compact.format(snapshot.unstaged)} ?${compact.format(snapshot.untracked)}`;
364
+ }
365
+ const branchWidth = Math.max(0, innerWidth - visibleWidth(`git ${suffix}`) - 4);
366
+ label = `git ${truncateToWidth(safeSingleLine(snapshot.branch), branchWidth, "…")}${suffix}`;
367
+ }
368
+ else {
369
+ label = snapshot.kind === "loading" ? "git loading…" : "git unavailable";
370
+ }
371
+ // Truncation may insert ANSI resets; color the complete plain label afterward.
372
+ label = stripVTControlCharacters(truncateToWidth(label, innerWidth - 4, "…"));
373
+ const slack = innerWidth - visibleWidth(label) - 2;
374
+ const left = Math.floor(slack / 2);
375
+ return theme.fg("border", `┌${"─".repeat(left)} ${label} ${"─".repeat(slack - left)}┐`);
376
+ }
286
377
  export function border(innerWidth, edge, theme) {
287
378
  return theme.fg("border", `${edge === "top" ? "┌" : "└"}${"─".repeat(innerWidth)}${edge === "top" ? "┐" : "┘"}`);
288
379
  }
@@ -1,5 +1,6 @@
1
1
  import { type KeybindingsManager, type Theme } from "@earendil-works/pi-coding-agent";
2
2
  import { type Component, type Focusable, type TUI, type TuiMouseEvent, type TuiMouseEventResult } from "@earendil-works/pi-tui";
3
+ import type { GitStatusCache } from "../git-status.js";
3
4
  import type { TaskState } from "../state.js";
4
5
  export declare class WorksDashboard implements Component, Focusable {
5
6
  private readonly tui;
@@ -7,6 +8,9 @@ export declare class WorksDashboard implements Component, Focusable {
7
8
  private readonly keybindings;
8
9
  private readonly state;
9
10
  private readonly close;
11
+ private readonly cwd;
12
+ private readonly git;
13
+ private readonly notify;
10
14
  focused: boolean;
11
15
  private selectedKey;
12
16
  private scrollOffset;
@@ -16,12 +20,15 @@ export declare class WorksDashboard implements Component, Focusable {
16
20
  private message;
17
21
  private messageColor;
18
22
  private copying;
23
+ private opening;
19
24
  private minimized;
25
+ private readonly unsubscribeGit;
26
+ private openHitRegion;
20
27
  private copyHitRegion;
21
28
  private toggleHitRegion;
22
29
  private disposed;
23
30
  private readonly refreshTimer;
24
- constructor(tui: TUI, theme: Theme, keybindings: KeybindingsManager, state: TaskState, close: () => void);
31
+ constructor(tui: TUI, theme: Theme, keybindings: KeybindingsManager, state: TaskState, close: () => void, cwd: string, git: GitStatusCache, notify: (message: string, type: "error") => void);
25
32
  render(width: number): string[];
26
33
  handleInput(data: string): void;
27
34
  handleMouse(event: TuiMouseEvent): TuiMouseEventResult | undefined;
@@ -36,6 +43,7 @@ export declare class WorksDashboard implements Component, Focusable {
36
43
  private renderHeader;
37
44
  private toggleMinimized;
38
45
  private isHit;
46
+ private openInCursor;
39
47
  private copyAllAsMarkdown;
40
48
  private renderFooter;
41
49
  }
@@ -1,8 +1,9 @@
1
1
  import { copyToClipboard } from "@earendil-works/pi-coding-agent";
2
2
  import { matchesKey, truncateToWidth, visibleWidth, wrapTextWithAnsi, } from "@earendil-works/pi-tui";
3
3
  import { formatWorksMarkdown } from "../markdown.js";
4
+ import { openRepository } from "../open-repository.js";
4
5
  import { safeMultiline, safeSingleLine } from "../text.js";
5
- import { border, frame, rule, todoIcon, workIcon } from "./panel.js";
6
+ import { border, frame, gitBorder, rule, todoIcon, workIcon } from "./panel.js";
6
7
  const CHROME_LINES = 8;
7
8
  export class WorksDashboard {
8
9
  tui;
@@ -10,6 +11,9 @@ export class WorksDashboard {
10
11
  keybindings;
11
12
  state;
12
13
  close;
14
+ cwd;
15
+ git;
16
+ notify;
13
17
  focused = false;
14
18
  selectedKey;
15
19
  scrollOffset = 0;
@@ -19,17 +23,24 @@ export class WorksDashboard {
19
23
  message = "Ready. Select an item; Escape closes.";
20
24
  messageColor = "warning";
21
25
  copying = false;
26
+ opening = false;
22
27
  minimized = false;
28
+ unsubscribeGit;
29
+ openHitRegion;
23
30
  copyHitRegion;
24
31
  toggleHitRegion;
25
32
  disposed = false;
26
33
  refreshTimer;
27
- constructor(tui, theme, keybindings, state, close) {
34
+ constructor(tui, theme, keybindings, state, close, cwd, git, notify) {
28
35
  this.tui = tui;
29
36
  this.theme = theme;
30
37
  this.keybindings = keybindings;
31
38
  this.state = state;
32
39
  this.close = close;
40
+ this.cwd = cwd;
41
+ this.git = git;
42
+ this.notify = notify;
43
+ this.unsubscribeGit = git.subscribe(() => tui.requestRender());
33
44
  this.refreshTimer = setInterval(() => {
34
45
  if (!this.disposed)
35
46
  this.tui.requestRender();
@@ -44,7 +55,7 @@ export class WorksDashboard {
44
55
  const header = this.renderHeader(innerWidth, works.length, todos.length);
45
56
  if (this.minimized) {
46
57
  return [
47
- border(innerWidth, "top", this.theme),
58
+ gitBorder(innerWidth, this.theme, this.git.getSnapshot()),
48
59
  frame(header, innerWidth, this.theme),
49
60
  border(innerWidth, "bottom", this.theme),
50
61
  ];
@@ -66,7 +77,7 @@ export class WorksDashboard {
66
77
  while (rows.length < listHeight)
67
78
  rows.push("");
68
79
  return [
69
- border(innerWidth, "top", this.theme),
80
+ gitBorder(innerWidth, this.theme, this.git.getSnapshot()),
70
81
  frame(header, innerWidth, this.theme),
71
82
  frame(this.theme.fg("dim", summary), innerWidth, this.theme),
72
83
  rule(innerWidth, this.theme),
@@ -91,6 +102,10 @@ export class WorksDashboard {
91
102
  void this.copyAllAsMarkdown();
92
103
  return;
93
104
  }
105
+ if (matchesKey(data, "o")) {
106
+ void this.openInCursor();
107
+ return;
108
+ }
94
109
  if (matchesKey(data, "m")) {
95
110
  this.toggleMinimized();
96
111
  return;
@@ -130,6 +145,10 @@ export class WorksDashboard {
130
145
  void this.copyAllAsMarkdown();
131
146
  return { handled: true, focus: true, render: true };
132
147
  }
148
+ if (this.isHit(event.x, this.openHitRegion)) {
149
+ void this.openInCursor();
150
+ return { handled: true, focus: true, render: true };
151
+ }
133
152
  return undefined;
134
153
  }
135
154
  invalidate() { }
@@ -137,6 +156,7 @@ export class WorksDashboard {
137
156
  if (this.disposed)
138
157
  return;
139
158
  this.disposed = true;
159
+ this.unsubscribeGit();
140
160
  clearInterval(this.refreshTimer);
141
161
  }
142
162
  items(works = this.state.listWorks()) {
@@ -208,17 +228,20 @@ export class WorksDashboard {
208
228
  const copyAction = this.copying
209
229
  ? this.theme.fg("dim", "[Copying…]")
210
230
  : this.theme.fg("accent", this.theme.bold("[C Copy]"));
231
+ const openAction = this.theme.fg(this.opening ? "dim" : "accent", this.theme.bold("[O Open]"));
211
232
  const toggleLabel = this.minimized ? "[M Maximize]" : "[M Minimize]";
212
233
  const toggleAction = this.theme.fg("accent", this.theme.bold(toggleLabel));
213
- const actionsWidth = visibleWidth(copyAction) + 1 + visibleWidth(toggleAction);
234
+ const actionsWidth = visibleWidth(copyAction) + 1 + visibleWidth(openAction) + 1 + visibleWidth(toggleAction);
214
235
  const titleWidth = Math.max(0, width - actionsWidth - 1);
215
236
  const shownTitle = truncateToWidth(title, titleWidth, "");
216
237
  const gap = " ".repeat(Math.max(1, width - visibleWidth(shownTitle) - actionsWidth));
217
238
  const copyStart = 1 + visibleWidth(shownTitle) + gap.length;
218
239
  this.copyHitRegion = { start: copyStart, end: copyStart + visibleWidth(copyAction) };
219
- const toggleStart = this.copyHitRegion.end + 1;
240
+ const openStart = this.copyHitRegion.end + 1;
241
+ this.openHitRegion = { start: openStart, end: openStart + visibleWidth(openAction) };
242
+ const toggleStart = this.openHitRegion.end + 1;
220
243
  this.toggleHitRegion = { start: toggleStart, end: toggleStart + visibleWidth(toggleAction) };
221
- return `${shownTitle}${gap}${copyAction} ${toggleAction}`;
244
+ return `${shownTitle}${gap}${copyAction} ${openAction} ${toggleAction}`;
222
245
  }
223
246
  toggleMinimized() {
224
247
  this.minimized = !this.minimized;
@@ -231,6 +254,31 @@ export class WorksDashboard {
231
254
  isHit(x, region) {
232
255
  return region !== undefined && x >= region.start && x < region.end;
233
256
  }
257
+ async openInCursor() {
258
+ if (this.opening)
259
+ return;
260
+ this.opening = true;
261
+ this.message = "Opening repository in Cursor…";
262
+ this.messageColor = "warning";
263
+ this.tui.requestRender();
264
+ try {
265
+ await openRepository(this.cwd);
266
+ this.message = "Opened repository in Cursor.";
267
+ this.messageColor = "success";
268
+ }
269
+ catch (error) {
270
+ const reason = error instanceof Error ? ` ${safeSingleLine(error.message)}` : "";
271
+ this.message = `Could not open Cursor. Check cursor is on PATH.${reason}`;
272
+ this.messageColor = "error";
273
+ if (!this.disposed)
274
+ this.notify(this.message, "error");
275
+ }
276
+ finally {
277
+ this.opening = false;
278
+ if (!this.disposed)
279
+ this.tui.requestRender();
280
+ }
281
+ }
234
282
  async copyAllAsMarkdown() {
235
283
  if (this.copying)
236
284
  return;
@@ -257,7 +305,7 @@ export class WorksDashboard {
257
305
  }
258
306
  }
259
307
  renderFooter(width) {
260
- const text = "C copy all · M minimize · configured ↑/↓ select · PgUp/PgDn scroll details · confirm toggles · cancel closes";
308
+ const text = "C copy all · O open Cursor · M minimize · configured ↑/↓ select · PgUp/PgDn scroll details · confirm toggles · cancel closes";
261
309
  return truncateToWidth(this.theme.fg("muted", text), width, "");
262
310
  }
263
311
  }
package/docs/REFERENCE.md CHANGED
@@ -14,6 +14,8 @@ Limits:
14
14
  - 10,000 characters per information field
15
15
  - list tool text is truncated at 50KB or 2,000 lines
16
16
 
17
+ `WorkList` and `TodoList` accept an optional positive integer `limit`. Without it, they return all matching records (subject to the output truncation above). With it, filters are applied first, then the newest `limit` matching works or todos are returned in oldest-to-newest order within that selection. A `WorkList` limit applies to works, not their nested todos: all todos belonging to each selected work are included. Both tools report the number returned and the total number matching the filters; those counts describe records selected before any text truncation.
18
+
17
19
  ## Data
18
20
 
19
21
  A work contains `workId`, `workName`, `workInfo`, `status`, `createdAt`, and `updatedAt`. Work status is `planned`, `active`, `blocked`, `completed`, or `cancelled`.
@@ -28,8 +30,28 @@ When all tracking tools are active, the extension adds hidden per-turn guidance
28
30
 
29
31
  The guidance is not added when the tracking tools have been removed from the active tool set. Pi Ask removes them during `/ask`. Pi BTW executes its side conversation outside the main conversation. The guidance also explicitly forbids changing works, todos, loops, or monitors during either mode.
30
32
 
33
+ ## Auto-continuation
34
+
35
+ Auto-continuation is optional and requires Pi 1.2.0 or newer. Configure `pi-tasks.autoContinue` in Pi's `settings.json`; the extension reads `pi.getSettings()` so trusted project settings override global settings. `enabled` defaults to `false`; `maxContinuations` is optional. Omission means no continuation limit; if supplied, it must be a positive safe integer. Explicit `null` is invalid. Invalid configuration disables the flow and reports a warning. Hosts without the new settings API keep normal task tracking with no automatic continuation.
36
+
37
+ A fresh accepted main interactive/RPC run arms a new continuation epoch. Input is provisional until the run starts, so handled/rejected prompts cannot arm it. Extension/custom starts do not arm or reset it. Steering/follow-up messages queued inside an already-running activity do not themselves reset the cap. Session start/reload, tree navigation, and shutdown disarm it until fresh user input. Aborted or failed activity also suspends it. `agent_settled.aborted` covers aborts that skip the actionable boundary. Tracking tools must be active; side conversations must not start continuation.
38
+
39
+ The synchronous `agent_before_settle` handler runs after native retries, compaction, and queued work. It requires a completed outcome, a non-aborted signal, no pending messages in either the boundary preview or runtime queue, and no continuation already requested by an earlier handler. Pi is still busy at this actionable boundary, so it does not require `ctx.isIdle()`. Instead it appends one custom-message draft and requests one native continuation; Pi owns committing it and honoring cancellation. No detached prompt, timer, background worker, or polling loop is created.
40
+
41
+ Planned/active works and pending/active todos on the current branch are unfinished. Completed, blocked, and cancelled records are settled. A settled parent does not hide an unfinished child. The prompt includes a bounded preview of IDs, names and statuses, and directs the agent to list tools for full details. No records means no continuation. The extension never mutates statuses, verifies work independently, or treats a blocker label as proof of an actual dependency.
42
+
43
+ When `maxContinuations` is supplied, at most that many extra continuations are requested per fresh accepted main user run. The next unfinished boundary warns once and suspends continuation; a fresh user prompt resets the cap. With no limit supplied, continuation can consume tokens indefinitely while unfinished records remain, until interrupted, failed, disabled or otherwise suspended. 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`.
44
+
45
+ ## Repository status and Cursor
46
+
47
+ 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.
48
+
49
+ 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.
50
+
51
+ 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.
52
+
31
53
  ## Interfaces
32
54
 
33
- The compact panel defaults to a non-capturing floating overlay anchored at the top-right. It shows work and todo names, 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 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.
55
+ The compact panel defaults to a non-capturing floating overlay anchored at the top-right. It shows work and todo names, 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.
34
56
 
35
- `/works` opens a top-centered detailed overlay. Its top-right Copy action uses `c` to copy every work and nested todo to the system clipboard as Markdown. Its Minimize action uses `m` to collapse the overlay to a framed top bar containing live total work and todo counts, Copy, and a Maximize action; activating Maximize restores the full dashboard. In fullscreen TUI mode, Copy and Minimize/Maximize also respond to left clicks. Configured selection keys choose records, configured Page Up and Page Down keys scroll long details, the configured confirmation key toggles details, and the configured cancel key closes it.
57
+ `/works` opens a top-centered detailed overlay. Its top-right Copy action uses `c` to copy every work and nested todo to the system clipboard as Markdown. Its Open action uses `o` to open the current directory in Cursor. Its Minimize action uses `m` to collapse the overlay to a framed top bar containing live total work and todo counts, Copy, Open, and a Maximize action; activating Maximize restores the full dashboard. In fullscreen TUI mode, Copy, Open, and Minimize/Maximize also respond to left clicks. Configured selection keys choose records, configured Page Up and Page Down keys scroll long details, the configured confirmation key toggles details, and the configured cancel key closes it.