@abhishek944/pi-tasks 0.7.0 → 0.8.2

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 CHANGED
@@ -7,7 +7,7 @@ It adds:
7
7
  - `WorkCreate`, `WorkList`, `WorkUpdate`, and `WorkDelete`
8
8
  - `TodoCreate`, `TodoList`, `TodoUpdate`, and `TodoDelete`
9
9
  - `/works`, a detailed floating dashboard modeled after `pi-loop-monitor`'s `/monitors`
10
- - a compact floating top-right panel with work and todo names
10
+ - a compact floating top-right panel with work and todo names and completion percentages
11
11
  - main-conversation guidance that keeps normal requested work current across every Pi skill
12
12
 
13
13
  Works and todos follow the active Pi session branch. Forking or navigating the session tree restores the state for that branch. `/ask` and `/btw` conversations do not update works, todos, loops, or monitors.
@@ -17,7 +17,7 @@ The coordination model is intentionally small: a work is the overall outcome, a
17
17
  ## Install
18
18
 
19
19
  ```bash
20
- pi install npm:@abhishek944/pi-tasks@0.7.0
20
+ pi install npm:@abhishek944/pi-tasks@0.8.1
21
21
  ```
22
22
 
23
23
  Restart Pi or run `/reload`.
@@ -29,12 +29,15 @@ The extension guides Pi to manage work automatically for normal requests that st
29
29
  ```text
30
30
  WorkCreate workName="Add task tracking" workInfo="Detailed goal, scope, constraints, and expected outcome" status="active"
31
31
  TodoCreate workId="W1" taskName="Implement state" taskInfo="Detailed task context and expected result" status="active"
32
+ TodoUpdate taskId="T1" completionPercent=40 taskInfo="The state changes are implemented; rendering and verification remain."
32
33
  TodoUpdate taskId="T1" status="completed" taskInfo="Implementation is complete; typecheck and build passed."
33
34
  WorkUpdate workId="W1" status="completed"
34
35
  ```
35
36
 
36
37
  Run `/works` to inspect full `workInfo` and `taskInfo` in an interactive overlay.
37
38
 
39
+ Pi reports approximate task progress through the existing `TodoCreate`/`TodoUpdate` tools using optional `completionPercent` (an integer from 0 to 100, or `null` for unknown). Work progress is the equal average of non-cancelled tasks, rounded down—not the fraction of finished tasks. For example, task values 100, 40, 0, 0 give work progress 35%. A missing estimate makes work progress unknown (`—`); blocked tasks retain their estimate. Completed tasks are 100%; reporting 100 without completed status is rejected. These percentages are estimates, not time predictions. The floating panel keeps percentages in a reserved right-hand column so long names cannot hide them. Existing keyboard controls are unchanged.
40
+
38
41
  The panel defaults to the floating top-right layout. 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 runs `cursor .` in the current session directory (the Cursor CLI must be on PATH). 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 open Cursor. Switch layouts with `/works-panel floating`, `/works-panel widget`, or `/works-panel off`.
39
42
 
40
43
  ## Optional auto-continuation
package/dist/markdown.js CHANGED
@@ -1,16 +1,17 @@
1
+ import { formatCompletion, taskCompletion, workCompletion } from "./progress.js";
1
2
  import { safeMultiline, safeSingleLine } from "./text.js";
2
3
  export function formatWorksMarkdown(works) {
3
4
  const lines = ["# Works and Todos", ""];
4
5
  if (works.length === 0)
5
6
  return `${lines.join("\n")}\n_No works or todos in this session._\n`;
6
7
  for (const work of works) {
7
- lines.push(`## ${work.workId} — ${escapeMarkdownInline(safeSingleLine(work.workName))}`, "", `**Status:** ${work.status}`, "", "### Details", "", markdownBody(work.workInfo), "", "### Todos", "");
8
+ lines.push(`## ${work.workId} — ${escapeMarkdownInline(safeSingleLine(work.workName))}`, "", `**Status:** ${work.status}`, `**Completion:** ${formatCompletion(workCompletion(work))}`, "", "### Details", "", markdownBody(work.workInfo), "", "### Todos", "");
8
9
  if (work.tasks.length === 0) {
9
10
  lines.push("_No todos._", "");
10
11
  continue;
11
12
  }
12
13
  for (const todo of work.tasks) {
13
- lines.push(`#### ${todo.taskId} — ${escapeMarkdownInline(safeSingleLine(todo.taskName))}`, "", `**Status:** ${todo.status}`, "", markdownBody(todo.taskInfo), "");
14
+ lines.push(`#### ${todo.taskId} — ${escapeMarkdownInline(safeSingleLine(todo.taskName))}`, "", `**Status:** ${todo.status}`, `**Completion:** ${formatCompletion(taskCompletion(todo))}`, "", markdownBody(todo.taskInfo), "");
14
15
  }
15
16
  }
16
17
  return `${lines.join("\n").trimEnd()}\n`;
@@ -0,0 +1,4 @@
1
+ import type { Todo, WorkWithTodos } from "./types.js";
2
+ export declare function taskCompletion(todo: Todo): number | null;
3
+ export declare function workCompletion(work: WorkWithTodos): number | null;
4
+ export declare function formatCompletion(value: number | null): string;
@@ -0,0 +1,22 @@
1
+ export function taskCompletion(todo) {
2
+ if (todo.status === "completed")
3
+ return 100;
4
+ const value = todo.completionPercent;
5
+ return typeof value === "number" && Number.isInteger(value) && value >= 0 && value < 100 ? value : null;
6
+ }
7
+ export function workCompletion(work) {
8
+ const tasks = work.tasks.filter((todo) => todo.status !== "cancelled");
9
+ if (tasks.length === 0)
10
+ return work.status === "completed" ? 100 : null;
11
+ let total = 0;
12
+ for (const todo of tasks) {
13
+ const value = taskCompletion(todo);
14
+ if (value === null)
15
+ return null;
16
+ total += value;
17
+ }
18
+ return Math.floor(total / tasks.length);
19
+ }
20
+ export function formatCompletion(value) {
21
+ return value === null ? "—" : `${value}%`;
22
+ }
package/dist/state.d.ts CHANGED
@@ -26,8 +26,8 @@ export declare class TaskState {
26
26
  createWork(workName: string, workInfo: string, status?: WorkStatus): Work;
27
27
  updateWork(workId: string, patch: Partial<Pick<Work, "workName" | "workInfo" | "status">>): Work;
28
28
  deleteWork(workId: string): boolean;
29
- createTodo(workId: string, taskName: string, taskInfo: string, status?: TodoStatus): Todo;
30
- updateTodo(taskId: string, patch: Partial<Pick<Todo, "taskName" | "taskInfo" | "status">>): Todo;
29
+ createTodo(workId: string, taskName: string, taskInfo: string, status?: TodoStatus, completionPercent?: number | null): Todo;
30
+ updateTodo(taskId: string, patch: Partial<Pick<Todo, "taskName" | "taskInfo" | "status" | "completionPercent">>): Todo;
31
31
  deleteTodo(taskId: string): boolean;
32
32
  private record;
33
33
  private apply;
package/dist/state.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { taskCompletion } from "./progress.js";
1
2
  import { safeSingleLine } from "./text.js";
2
3
  export const TASK_ENTRY_TYPE = "pi-tasks-state";
3
4
  export const MAX_WORKS = 100;
@@ -88,11 +89,12 @@ export class TaskState {
88
89
  this.record({ version: 1, type: "work-deleted", at: Date.now(), workId });
89
90
  return true;
90
91
  }
91
- createTodo(workId, taskName, taskInfo, status = "pending") {
92
+ createTodo(workId, taskName, taskInfo, status = "pending", completionPercent) {
92
93
  if (!this.works.has(workId))
93
94
  throw new Error(`Work ${workId} not found.`);
94
95
  if (this.todos.size >= MAX_TODOS)
95
96
  throw new Error(`Maximum of ${MAX_TODOS} todos reached.`);
97
+ validateCompletion(status, completionPercent);
96
98
  const now = Date.now();
97
99
  const todo = {
98
100
  taskId: `T${this.nextTaskId}`,
@@ -100,6 +102,7 @@ export class TaskState {
100
102
  taskName: requiredName(taskName, "taskName"),
101
103
  taskInfo: requiredText(taskInfo, "taskInfo"),
102
104
  status,
105
+ completionPercent: status === "completed" ? 100 : completionPercent ?? null,
103
106
  createdAt: now,
104
107
  updatedAt: now,
105
108
  };
@@ -107,12 +110,15 @@ export class TaskState {
107
110
  return { ...todo };
108
111
  }
109
112
  updateTodo(taskId, patch) {
110
- if (!this.todos.has(taskId))
113
+ const current = this.todos.get(taskId);
114
+ if (!current)
111
115
  throw new Error(`Todo ${taskId} not found.`);
116
+ validateCompletion(patch.status ?? current.status, patch.completionPercent);
112
117
  const normalized = compactPatch({
113
118
  taskName: patch.taskName === undefined ? undefined : requiredName(patch.taskName, "taskName"),
114
119
  taskInfo: patch.taskInfo === undefined ? undefined : requiredText(patch.taskInfo, "taskInfo"),
115
120
  status: patch.status,
121
+ completionPercent: patch.completionPercent,
116
122
  });
117
123
  if (Object.keys(normalized).length === 0)
118
124
  throw new Error("TodoUpdate requires at least one changed field.");
@@ -162,19 +168,26 @@ export class TaskState {
162
168
  if (typeof event.todo.workId !== "string" || typeof event.todo.taskName !== "string" || typeof event.todo.taskInfo !== "string" || !isTodoStatus(event.todo.status))
163
169
  throw new Error("Malformed todo entry.");
164
170
  if (this.works.has(event.todo.workId))
165
- this.todos.set(event.todo.taskId, { ...event.todo, taskName: safeSingleLine(event.todo.taskName) });
171
+ this.todos.set(event.todo.taskId, {
172
+ ...event.todo,
173
+ taskName: safeSingleLine(event.todo.taskName),
174
+ completionPercent: taskCompletion(event.todo),
175
+ });
166
176
  this.nextTaskId = Math.max(this.nextTaskId, numericId(event.todo.taskId) + 1);
167
177
  break;
168
178
  case "todo-updated": {
169
179
  const todo = this.todos.get(event.taskId);
170
- if (todo)
171
- this.todos.set(event.taskId, {
180
+ if (todo) {
181
+ const updated = {
172
182
  ...todo,
173
183
  ...(typeof event.patch.taskName === "string" ? { taskName: safeSingleLine(event.patch.taskName) } : {}),
174
184
  ...(typeof event.patch.taskInfo === "string" ? { taskInfo: event.patch.taskInfo } : {}),
175
185
  ...(isTodoStatus(event.patch.status) ? { status: event.patch.status } : {}),
186
+ ...(event.patch.completionPercent !== undefined ? { completionPercent: event.patch.completionPercent } : {}),
176
187
  updatedAt: event.at,
177
- });
188
+ };
189
+ this.todos.set(event.taskId, { ...updated, completionPercent: taskCompletion(updated) });
190
+ }
178
191
  break;
179
192
  }
180
193
  case "todo-deleted":
@@ -183,6 +196,16 @@ export class TaskState {
183
196
  }
184
197
  }
185
198
  }
199
+ function validateCompletion(status, value) {
200
+ if (value === undefined || value === null)
201
+ return;
202
+ if (!Number.isInteger(value) || value < 0 || value > 100)
203
+ throw new Error("completionPercent must be an integer from 0 to 100, or null for unknown.");
204
+ if (value === 100 && status !== "completed")
205
+ throw new Error("100% requires verified completion. Set status to completed after verification.");
206
+ if (status === "completed" && value !== 100)
207
+ throw new Error("Completed tasks have 100% progress. Reopen the task before reporting partial progress.");
208
+ }
186
209
  function requiredText(value, field) {
187
210
  const text = value.trim();
188
211
  if (!text)
package/dist/tools.js CHANGED
@@ -1,9 +1,13 @@
1
1
  import { StringEnum } from "@earendil-works/pi-ai";
2
2
  import { DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, formatSize, truncateHead } from "@earendil-works/pi-coding-agent";
3
3
  import { Type } from "typebox";
4
+ import { formatCompletion, taskCompletion, workCompletion } from "./progress.js";
4
5
  import { renderTaskCall, renderTaskResult, taskResult } from "./tool-result.js";
5
6
  const WorkStatusSchema = StringEnum(["planned", "active", "blocked", "completed", "cancelled"]);
6
7
  const TodoStatusSchema = StringEnum(["pending", "active", "blocked", "completed", "cancelled"]);
8
+ const CompletionSchema = Type.Union([Type.Integer({ minimum: 0, maximum: 100 }), Type.Null()], {
9
+ description: "AI-reported approximate task completion, not elapsed time or a status-to-percentage mapping. Use null for unknown; reserve 100 for verified completed status. Work progress is the equal average of non-cancelled tasks.",
10
+ });
7
11
  const NameSchema = Type.String({ minLength: 1, maxLength: 240 });
8
12
  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
13
  const InfoSchema = Type.String({ minLength: 1, maxLength: 10_000, description: DETAILS_GUIDANCE });
@@ -86,11 +90,11 @@ export function registerTaskTools(pi, state) {
86
90
  pi.registerTool({
87
91
  name: "TodoCreate",
88
92
  label: "TodoCreate",
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}`,
93
+ description: `Create a todo under an existing work, optionally reporting approximate completionPercent (0 for known unstarted work, null for unknown). taskInfo must contain enough detailed context, scope, constraints, expected outcome, and verification guidance to execute the task without guessing. ${DETAILS_GUIDANCE}`,
90
94
  promptSnippet: "Create detailed todos under the current work before implementation",
91
95
  promptGuidelines: [
92
96
  "Use TodoCreate only under an existing work and only for actionable main-conversation work; never use it during /ask or /btw.",
93
- "Keep taskInfo detailed, current, and self-contained.",
97
+ "Keep taskInfo detailed, current, and self-contained. Report completionPercent from actual progress; do not infer partial completion just from status.",
94
98
  DETAILS_GUIDANCE,
95
99
  ],
96
100
  parameters: Type.Object({
@@ -98,10 +102,11 @@ export function registerTaskTools(pi, state) {
98
102
  taskName: NameSchema,
99
103
  taskInfo: InfoSchema,
100
104
  status: Type.Optional(TodoStatusSchema),
105
+ completionPercent: Type.Optional(CompletionSchema),
101
106
  }, { additionalProperties: false }),
102
107
  execute(_id, params) {
103
- const todo = state.createTodo(params.workId, params.taskName, params.taskInfo, params.status);
104
- return Promise.resolve(taskResult(`Created todo ${todo.taskId} under ${todo.workId}: ${todo.taskName} [${todo.status}]`, "todo-create", { taskId: todo.taskId, workId: todo.workId }));
108
+ const todo = state.createTodo(params.workId, params.taskName, params.taskInfo, params.status, params.completionPercent);
109
+ return Promise.resolve(taskResult(`Created todo ${todo.taskId} under ${todo.workId}: ${todo.taskName} · ${formatCompletion(taskCompletion(todo))} [${todo.status}]`, "todo-create", { taskId: todo.taskId, workId: todo.workId, completionPercent: taskCompletion(todo) }));
105
110
  },
106
111
  renderCall: renderTaskCall("TodoCreate"),
107
112
  renderResult: renderTaskResult,
@@ -128,18 +133,19 @@ export function registerTaskTools(pi, state) {
128
133
  pi.registerTool({
129
134
  name: "TodoUpdate",
130
135
  label: "TodoUpdate",
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}`,
136
+ description: `Update a todo's name, detailed information, status, or completionPercent. Report approximate progress after meaningful work and explain evidence in taskInfo; blocking retains progress. Reserve completed/100 for verified completion. ${DETAILS_GUIDANCE}`,
132
137
  promptSnippet: "Keep todo status and detailed context synchronized with active work",
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],
138
+ promptGuidelines: ["Use TodoUpdate immediately before and after working on a todo in the main conversation; never update tracking during /ask or /btw.", "Update completionPercent after meaningful progress with evidence in taskInfo. Use null to clear an obsolete estimate; only verified completed tasks may reach 100. Work completion is calculated automatically from tasks.", DETAILS_GUIDANCE],
134
139
  parameters: Type.Object({
135
140
  taskId: Type.String(),
136
141
  taskName: Type.Optional(NameSchema),
137
142
  taskInfo: Type.Optional(InfoSchema),
138
143
  status: Type.Optional(TodoStatusSchema),
144
+ completionPercent: Type.Optional(CompletionSchema),
139
145
  }, { additionalProperties: false, minProperties: 2 }),
140
146
  execute(_id, params) {
141
- const todo = state.updateTodo(params.taskId, { taskName: params.taskName, taskInfo: params.taskInfo, status: params.status });
142
- return Promise.resolve(taskResult(`Updated todo ${todo.taskId}: ${todo.taskName} [${todo.status}]`, "todo-update", { taskId: todo.taskId, workId: todo.workId }));
147
+ const todo = state.updateTodo(params.taskId, { taskName: params.taskName, taskInfo: params.taskInfo, status: params.status, completionPercent: params.completionPercent });
148
+ return Promise.resolve(taskResult(`Updated todo ${todo.taskId}: ${todo.taskName} · ${formatCompletion(taskCompletion(todo))} [${todo.status}]`, "todo-update", { taskId: todo.taskId, workId: todo.workId, completionPercent: taskCompletion(todo) }));
143
149
  },
144
150
  renderCall: renderTaskCall("TodoUpdate"),
145
151
  renderResult: renderTaskResult,
@@ -164,7 +170,7 @@ function formatWorks(works) {
164
170
  if (works.length === 0)
165
171
  return "No works found in this session.";
166
172
  return works.map((work) => [
167
- `${work.workId} [${work.status}] ${work.workName}`,
173
+ `${work.workId} [${work.status}] ${work.workName} · ${formatCompletion(workCompletion(work))}`,
168
174
  `Work info:\n${work.workInfo}`,
169
175
  work.tasks.length ? `Todos:\n${formatTodos(work.tasks)}` : "Todos: none",
170
176
  ].join("\n")).join("\n\n---\n\n");
@@ -172,7 +178,7 @@ function formatWorks(works) {
172
178
  function formatTodos(todos) {
173
179
  if (todos.length === 0)
174
180
  return "No todos found.";
175
- return todos.map((todo) => `${todo.taskId} [${todo.status}] ${todo.taskName}\nWork: ${todo.workId}\nTask info:\n${todo.taskInfo}`).join("\n\n");
181
+ return todos.map((todo) => `${todo.taskId} [${todo.status}] ${todo.taskName} · ${formatCompletion(taskCompletion(todo))}\nWork: ${todo.workId}\nTask info:\n${todo.taskInfo}`).join("\n\n");
176
182
  }
177
183
  function bounded(text) {
178
184
  const result = truncateHead(text, { maxBytes: DEFAULT_MAX_BYTES, maxLines: DEFAULT_MAX_LINES });
package/dist/tracking.js CHANGED
@@ -10,12 +10,15 @@ Before implementation, investigation, or any other requested work:
10
10
  2. If no suitable work exists, create one with WorkCreate. Otherwise use WorkUpdate to refresh its detailed workInfo and mark it active.
11
11
  3. Create or update the work's todos so they match the requested scope. Keep taskInfo detailed and self-contained.
12
12
  4. Mark the todo being attempted active with TodoUpdate before doing that work.
13
+ 5. Report completionPercent on TodoCreate/TodoUpdate as an approximate integer from 0 to 100 based on actual work and verification, not elapsed time or a fixed mapping from status. Explicitly use 0 for genuinely unstarted tasks; use null when unknown. Never invent progress to make a work look further along.
13
14
 
14
15
  During and after the attempt:
15
16
  - When available, use MonitorCreate only when a command should continue in the background; inspect it with MonitorList and do not poll it with shell sleep loops.
16
17
  - When available, use LoopCreate only when work needs a future or repeated wake. Do not create a loop for ordinary synchronous work.
17
18
  - A loop or monitor does not replace work and todo status. Update the related todo when its result is known.
18
- - Mark the todo completed, blocked, or cancelled as appropriate and update taskInfo with important current context.
19
+ - After meaningful progress, update the task completionPercent and explain the evidence and remaining work in taskInfo. Keep estimates current, including after scope changes. Work completion is derived as the equal average of non-cancelled task percentages; any unknown child makes it unknown. Do not set an independent work percentage.
20
+ - Mark the todo completed, blocked, or cancelled as appropriate and update taskInfo with important current context. Only use completed/100 after verification. Blocking retains the last percentage; it does not erase completed effort. Reopening a completed task needs a fresh estimate (otherwise it becomes unknown).
21
+ - Percentages are approximate completion, not ETA or proof. Never mark a parent complete to conceal unfinished tasks, and never change statuses merely because a percentage looks complete.
19
22
  - Keep the work active while required todos remain, blocked when progress cannot continue, and completed only when its required todos are complete.
20
23
  - Never create or update works, todos, loops, or monitors during /ask, /btw, or any BTW side thread.`;
21
24
  export function areTrackingToolsActive(pi) {
package/dist/types.d.ts CHANGED
@@ -14,6 +14,7 @@ export interface Todo {
14
14
  taskName: string;
15
15
  taskInfo: string;
16
16
  status: TodoStatus;
17
+ completionPercent?: number | null;
17
18
  createdAt: number;
18
19
  updatedAt: number;
19
20
  }
@@ -46,7 +47,7 @@ export type TaskEvent = {
46
47
  type: "todo-updated";
47
48
  at: number;
48
49
  taskId: string;
49
- patch: Partial<Pick<Todo, "taskName" | "taskInfo" | "status">>;
50
+ patch: Partial<Pick<Todo, "taskName" | "taskInfo" | "status" | "completionPercent">>;
50
51
  } | {
51
52
  version: 1;
52
53
  type: "todo-deleted";
@@ -23,6 +23,7 @@ export declare class TasksPanelHost {
23
23
  private applyMode;
24
24
  private hideCurrent;
25
25
  }
26
+ export declare function progressName(name: string, completion: number | null, width: number): string;
26
27
  export declare function workIcon(status: WorkStatus, theme: Theme): string;
27
28
  export declare function todoIcon(status: TodoStatus, theme: Theme): string;
28
29
  export declare function frame(content: string, innerWidth: number, theme: Theme): string;
package/dist/ui/panel.js CHANGED
@@ -3,8 +3,11 @@ import { copyToClipboard } from "@earendil-works/pi-coding-agent";
3
3
  import { truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
4
4
  import { formatWorksMarkdown } from "../markdown.js";
5
5
  import { openRepository } from "../open-repository.js";
6
+ import { formatCompletion, taskCompletion, workCompletion } from "../progress.js";
6
7
  import { safeSingleLine } from "../text.js";
7
8
  const EMPTY_COMPONENT = { render: () => [], invalidate: () => { } };
9
+ const PROGRESS_VALUE_WIDTH = 4;
10
+ const PROGRESS_COLUMN_WIDTH = PROGRESS_VALUE_WIDTH + 3;
8
11
  export class TasksPanelHost {
9
12
  state;
10
13
  git;
@@ -144,14 +147,18 @@ class TasksPanel {
144
147
  border(innerWidth, "bottom", this.theme),
145
148
  ].map((line) => `${leftPad}${line}`);
146
149
  }
150
+ const contentWidth = innerWidth - PROGRESS_COLUMN_WIDTH;
147
151
  const content = [];
148
152
  if (works.length === 0)
149
- content.push(this.theme.fg("muted", "No works yet."));
153
+ content.push(progressColumn(this.theme.fg("muted", "No works yet."), null, innerWidth, this.theme));
150
154
  for (const work of works) {
151
155
  const completed = work.tasks.filter((todo) => todo.status === "completed").length;
152
- content.push(workSummaryLine(work.status, work.workName, `${completed}/${work.tasks.length}`, innerWidth, this.theme));
153
- for (const todo of work.tasks)
154
- content.push(` ${todoIcon(todo.status, this.theme)} ${this.theme.fg(todo.status === "completed" ? "muted" : "text", todo.taskName)}`);
156
+ const summary = workSummaryLine(work.status, work.workName, `${completed}/${work.tasks.length}`, contentWidth, this.theme);
157
+ content.push(progressColumn(summary, workCompletion(work), innerWidth, this.theme));
158
+ for (const todo of work.tasks) {
159
+ const label = ` ${todoIcon(todo.status, this.theme)} ${this.theme.fg(todo.status === "completed" ? "muted" : "text", safeSingleLine(todo.taskName))}`;
160
+ content.push(progressColumn(label, taskCompletion(todo), innerWidth, this.theme));
161
+ }
155
162
  }
156
163
  this.contentLength = content.length;
157
164
  const terminalRows = this.tui.terminal.rows || process.stdout.rows || 30;
@@ -172,16 +179,16 @@ class TasksPanel {
172
179
  let title = "Works";
173
180
  if (this.placement === "floating" && hasOverflow) {
174
181
  title += this.tui.mode === "fullscreen"
175
- ? ` · ${range} · wheel to scroll`
182
+ ? ` · ${range}`
176
183
  : ` · ${range} · latest · /works for all`;
177
184
  }
178
185
  const header = this.renderHeader(title, innerWidth, leftPad.length);
179
186
  const lines = [
180
187
  gitBorder(innerWidth, this.theme, this.git.getSnapshot()),
181
188
  frame(header, innerWidth, this.theme),
182
- rule(innerWidth, this.theme),
189
+ this.theme.fg("border", `├${"─".repeat(contentWidth + 1)}┬${"─".repeat(PROGRESS_VALUE_WIDTH + 1)}┤`),
183
190
  ...shown.map((line) => frame(line, innerWidth, this.theme)),
184
- border(innerWidth, "bottom", this.theme),
191
+ this.theme.fg("border", `└${"─".repeat(contentWidth + 1)}┴${"─".repeat(PROGRESS_VALUE_WIDTH + 1)}┘`),
185
192
  ];
186
193
  return lines.map((line) => `${leftPad}${line}`);
187
194
  }
@@ -314,10 +321,21 @@ class TasksPanel {
314
321
  return Math.max(0, this.contentLength - this.pageSize);
315
322
  }
316
323
  }
324
+ export function progressName(name, completion, width) {
325
+ const suffix = ` · ${formatCompletion(completion)}`;
326
+ return `${truncateToWidth(safeSingleLine(name), Math.max(0, width - visibleWidth(suffix)), "…")}${suffix}`;
327
+ }
328
+ function progressColumn(content, completion, width, theme) {
329
+ const contentWidth = width - PROGRESS_COLUMN_WIDTH;
330
+ const left = truncateToWidth(content, contentWidth, "…");
331
+ const padding = " ".repeat(Math.max(0, contentWidth - visibleWidth(left)));
332
+ const value = theme.fg(completion === null ? "muted" : "accent", formatCompletion(completion).padStart(PROGRESS_VALUE_WIDTH));
333
+ return `${left}${padding}${theme.fg("border", " │ ")}${value}`;
334
+ }
317
335
  function workSummaryLine(status, name, count, width, theme) {
318
- const left = `${workIcon(status, theme)} ${theme.fg("text", name)}`;
319
336
  const right = theme.fg("dim", count);
320
337
  const leftWidth = Math.max(0, width - visibleWidth(right) - 1);
338
+ const left = `${workIcon(status, theme)} ${theme.fg("text", safeSingleLine(name))}`;
321
339
  const shownLeft = truncateToWidth(left, leftWidth, "…");
322
340
  const gap = " ".repeat(Math.max(1, width - visibleWidth(shownLeft) - visibleWidth(right)));
323
341
  return `${shownLeft}${gap}${right}`;
@@ -2,8 +2,9 @@ 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
4
  import { openRepository } from "../open-repository.js";
5
+ import { formatCompletion, taskCompletion, workCompletion } from "../progress.js";
5
6
  import { safeMultiline, safeSingleLine } from "../text.js";
6
- import { border, frame, gitBorder, rule, todoIcon, workIcon } from "./panel.js";
7
+ import { border, frame, gitBorder, progressName, rule, todoIcon, workIcon } from "./panel.js";
7
8
  const CHROME_LINES = 8;
8
9
  export class WorksDashboard {
9
10
  tui;
@@ -164,7 +165,7 @@ export class WorksDashboard {
164
165
  for (const work of works) {
165
166
  items.push({ key: `work:${work.workId}`, kind: "work", work });
166
167
  for (const todo of work.tasks)
167
- items.push({ key: `todo:${todo.taskId}`, kind: "todo", todo, workName: work.workName });
168
+ items.push({ key: `todo:${todo.taskId}`, kind: "todo", todo, work });
168
169
  }
169
170
  return items;
170
171
  }
@@ -193,9 +194,13 @@ export class WorksDashboard {
193
194
  const prefix = selected ? this.theme.fg("accent", "▶ ") : " ";
194
195
  if (item.kind === "work") {
195
196
  const done = item.work.tasks.filter((todo) => todo.status === "completed").length;
196
- return truncateToWidth(`${prefix}${workIcon(item.work.status, this.theme)} ${this.theme.bold(safeSingleLine(item.work.workName))} ${this.theme.fg("dim", `${item.work.workId} · ${item.work.status} · ${done}/${item.work.tasks.length}`)}`, width, "");
197
+ const metadata = this.theme.fg("dim", `${item.work.workId} · ${item.work.status} · ${done}/${item.work.tasks.length}`);
198
+ const nameWidth = width - visibleWidth(prefix) - 3 - visibleWidth(metadata);
199
+ return truncateToWidth(`${prefix}${workIcon(item.work.status, this.theme)} ${this.theme.bold(progressName(item.work.workName, workCompletion(item.work), nameWidth))} ${metadata}`, width, "");
197
200
  }
198
- return truncateToWidth(`${prefix} ${todoIcon(item.todo.status, this.theme)} ${safeSingleLine(item.todo.taskName)} ${this.theme.fg("dim", `${item.todo.taskId} · ${item.todo.status}`)}`, width, "");
201
+ const metadata = this.theme.fg("dim", `${item.todo.taskId} · ${item.todo.status}`);
202
+ const nameWidth = width - visibleWidth(prefix) - 5 - visibleWidth(metadata);
203
+ return truncateToWidth(`${prefix} ${todoIcon(item.todo.status, this.theme)} ${progressName(item.todo.taskName, taskCompletion(item.todo), nameWidth)} ${metadata}`, width, "");
199
204
  }
200
205
  renderDetails(items, width, budget) {
201
206
  if (!this.detailsVisible || budget === 0)
@@ -203,9 +208,24 @@ export class WorksDashboard {
203
208
  const item = items.find((candidate) => candidate.key === this.selectedKey);
204
209
  if (!item)
205
210
  return [this.theme.fg("muted", "No works or todos in this session.")].slice(0, budget);
206
- const heading = item.kind === "work"
207
- ? `${item.work.workId} · ${safeSingleLine(item.work.workName)} · ${item.work.status}`
208
- : `${item.todo.taskId} · ${safeSingleLine(item.todo.taskName)} · ${item.todo.status} · ${item.todo.workId} ${safeSingleLine(item.workName)}`;
211
+ let heading;
212
+ if (item.kind === "work") {
213
+ const lead = `${item.work.workId} · `;
214
+ const tail = ` · ${item.work.status}`;
215
+ heading = `${lead}${progressName(item.work.workName, workCompletion(item.work), width - visibleWidth(lead + tail))}${tail}`;
216
+ }
217
+ else {
218
+ const taskName = safeSingleLine(item.todo.taskName);
219
+ const workName = safeSingleLine(item.work.workName);
220
+ const taskProgress = formatCompletion(taskCompletion(item.todo));
221
+ const workProgress = formatCompletion(workCompletion(item.work));
222
+ const fixed = `${item.todo.taskId} · · ${taskProgress} · ${item.todo.status} · ${item.todo.workId} · ${workProgress}`;
223
+ const available = Math.max(0, width - visibleWidth(fixed));
224
+ const taskWidth = Math.min(visibleWidth(taskName), available - Math.min(visibleWidth(workName), Math.floor(available / 2)));
225
+ const shownTask = truncateToWidth(taskName, taskWidth, "…");
226
+ const shownWork = truncateToWidth(workName, available - taskWidth, "…");
227
+ heading = `${item.todo.taskId} · ${shownTask} · ${taskProgress} · ${item.todo.status} · ${item.todo.workId} ${shownWork} · ${workProgress}`;
228
+ }
209
229
  const info = item.kind === "work" ? item.work.workInfo : item.todo.taskInfo;
210
230
  const infoLines = safeMultiline(info).flatMap((line) => wrapTextWithAnsi(this.theme.fg("dim", line || " "), width));
211
231
  const contentBudget = Math.max(0, budget - 3);
package/docs/REFERENCE.md CHANGED
@@ -20,9 +20,21 @@ Limits:
20
20
 
21
21
  A work contains `workId`, `workName`, `workInfo`, `status`, `createdAt`, and `updatedAt`. Work status is `planned`, `active`, `blocked`, `completed`, or `cancelled`.
22
22
 
23
- A todo contains `taskId`, `workId`, `taskName`, `taskInfo`, `status`, `createdAt`, and `updatedAt`. Todo status is `pending`, `active`, `blocked`, `completed`, or `cancelled`.
23
+ A todo contains `taskId`, `workId`, `taskName`, `taskInfo`, `status`, optional `completionPercent`, `createdAt`, and `updatedAt`. Todo status is `pending`, `active`, `blocked`, `completed`, or `cancelled`.
24
24
 
25
- The public list shape assembles each work with `tasks: Todo[]`; tasks are stored separately to avoid duplicate state.
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
+
27
+ ### Completion progress
28
+
29
+ `TodoCreate` and `TodoUpdate` accept optional `completionPercent`: an integer from 0 through 100, or `null` to clear an obsolete estimate. Omission preserves an existing estimate on updates. The AI reports approximate progress based on completed effort and verification, explaining the evidence and remaining scope in `taskInfo`; status alone never implies an arbitrary partial percentage. No new tool or extra model call is added.
30
+
31
+ - Completed tasks normalize to 100%; explicit partial progress with completed status is rejected. Explicit 100 requires completed status. Completion remains an agent assertion after verification, not an independent extension proof.
32
+ - Moving a partial task to blocked retains its progress. Reopening a completed task without a new estimate becomes unknown rather than retaining 100%.
33
+ - A work is the equal arithmetic mean of all non-cancelled task percentages, rounded down for display. For example, 100, 40, 0, 0 yields 35%.
34
+ - Any unknown eligible task makes the work unknown (`—`); unknown is not silently 0. With no eligible tasks, work is unknown unless its own status is completed, then 100%.
35
+ - A completed parent never overrides unfinished child progress. Work progress reaches 100 only when all eligible tasks are completed. Progress never changes statuses or auto-continuation eligibility.
36
+ - Optional progress fields are additive to version-1 branch events. Legacy completed tasks show 100%; other legacy tasks remain unknown until reported. Invalid optional progress is sanitized on replay without discarding the task.
37
+ - Dashboard, compact panel, list output and copied Markdown share these calculations. The compact panel reserves a narrow right-hand percentage column with a divider; names truncate independently. `/works` retains inline `· N%` labels and unchanged navigation. Percentages do not predict remaining time; no subtasks, weights or separate navigation sidebar are added.
26
38
 
27
39
  ## Tracking behavior
28
40
 
@@ -52,19 +52,27 @@ WorkDelete workId="W1"
52
52
  ## Todo tools
53
53
 
54
54
  ```text
55
- TodoCreate workId="W1" taskName="Inspect token flow" taskInfo="Detailed context..."
55
+ TodoCreate workId="W1" taskName="Inspect token flow" taskInfo="Detailed context..." completionPercent=0
56
56
  TodoList workId="W1"
57
57
  TodoList status="active"
58
58
  TodoList workId="W1" limit=10
59
- TodoUpdate taskId="T1" status="completed" taskInfo="Detailed outcome..."
59
+ TodoUpdate taskId="T1" status="active" completionPercent=40 taskInfo="Inspection is complete; implementation and verification remain."
60
+ TodoUpdate taskId="T1" status="completed" taskInfo="Detailed verified outcome..."
61
+ TodoUpdate taskId="T2" completionPercent=null taskInfo="The scope changed; the previous estimate is no longer reliable."
60
62
  TodoDelete taskId="T1"
61
63
  ```
62
64
 
63
65
  `TodoList` returns all matching todos when `limit` is omitted. A positive integer `limit` selects the newest matching todos after filters, displayed oldest-to-newest. The result shows how many todos were returned and how many matched in total. Both list tools can still truncate very long text output at 50KB or 2,000 lines.
64
66
 
67
+ ### Completion percentages
68
+
69
+ Pi updates each task’s `completionPercent` after meaningful progress. These are approximate AI-reported values, not a fixed percentage for each status and not a time prediction. Use an integer 0–100 or `null` for unknown. Completed status means verified completion and displays 100%; 100 without completed status is rejected. Partial progress requires reopening a completed task; reopening without a fresh estimate makes it unknown. Blocking retains the current estimate.
70
+
71
+ Work progress averages all non-cancelled tasks equally and rounds down. Tasks at 100%, 40%, 0%, 0% produce 35% work completion, not 25% based on finished-task counts. If any eligible task lacks an estimate, the work displays `—`. No eligible tasks also means unknown unless the work itself is verified complete. A completed parent never hides unfinished task progress. Existing sessions retain their records; legacy completed tasks display 100%, while other missing estimates remain unknown.
72
+
65
73
  ## TUI
66
74
 
67
- The panel defaults to a floating top-right layout and does not take keyboard focus. 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.
75
+ The panel defaults to a floating top-right layout and does not take keyboard focus. A slim, separated right-hand column keeps work and task percentages aligned and visible even when names are long; the left side retains names, status icons and work task-counts. 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.
68
76
 
69
77
  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.
70
78
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abhishek944/pi-tasks",
3
- "version": "0.7.0",
3
+ "version": "0.8.2",
4
4
  "description": "Session-scoped work and todo tracking for Pi.",
5
5
  "license": "MIT",
6
6
  "type": "module",