@juicesharp/rpiv-todo 0.1.1 → 0.6.1
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/LICENSE +21 -0
- package/README.md +1 -1
- package/index.ts +37 -37
- package/package.json +21 -6
- package/todo-overlay.ts +10 -35
- package/todo.ts +55 -135
- package/docs/overlay.jpg +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 juicesharp
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ Pi extension that registers the `todo` tool, `/todos` slash command, and a
|
|
|
4
4
|
persistent TodoOverlay widget above the editor. Replaces Claude Code's
|
|
5
5
|
TaskCreate/TaskUpdate tool family.
|
|
6
6
|
|
|
7
|
-

|
|
8
8
|
|
|
9
9
|
## Installation
|
|
10
10
|
|
package/index.ts
CHANGED
|
@@ -11,44 +11,44 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
14
|
-
import {
|
|
14
|
+
import { reconstructTodoState, registerTodosCommand, registerTodoTool, TOOL_NAME } from "./todo.js";
|
|
15
15
|
import { TodoOverlay } from "./todo-overlay.js";
|
|
16
16
|
|
|
17
17
|
export default function (pi: ExtensionAPI) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
18
|
+
// Todo overlay widget — constructed lazily at the first session_start with UI.
|
|
19
|
+
let todoOverlay: TodoOverlay | undefined;
|
|
20
|
+
|
|
21
|
+
registerTodoTool(pi);
|
|
22
|
+
registerTodosCommand(pi);
|
|
23
|
+
|
|
24
|
+
pi.on("session_start", async (_event, ctx) => {
|
|
25
|
+
reconstructTodoState(ctx);
|
|
26
|
+
if (ctx.hasUI) {
|
|
27
|
+
todoOverlay ??= new TodoOverlay();
|
|
28
|
+
todoOverlay.setUICtx(ctx.ui);
|
|
29
|
+
todoOverlay.update();
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
pi.on("session_compact", async (_event, ctx) => {
|
|
34
|
+
reconstructTodoState(ctx);
|
|
35
|
+
todoOverlay?.update();
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
pi.on("session_tree", async (_event, ctx) => {
|
|
39
|
+
reconstructTodoState(ctx);
|
|
40
|
+
todoOverlay?.update();
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
pi.on("session_shutdown", async () => {
|
|
44
|
+
todoOverlay?.dispose();
|
|
45
|
+
todoOverlay = undefined;
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// Reads getTodos() at render time; do NOT call reconstructTodoState here
|
|
49
|
+
// (branch is stale — message_end runs after tool_execution_end).
|
|
50
|
+
pi.on("tool_execution_end", async (event) => {
|
|
51
|
+
if (event.toolName !== TOOL_NAME || event.isError) return;
|
|
52
|
+
todoOverlay?.update();
|
|
53
|
+
});
|
|
54
54
|
}
|
package/package.json
CHANGED
|
@@ -1,24 +1,39 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juicesharp/rpiv-todo",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "Pi extension: Claude-Code-parity todo tool + persistent overlay widget",
|
|
5
|
-
"keywords": [
|
|
5
|
+
"keywords": [
|
|
6
|
+
"pi-package",
|
|
7
|
+
"pi-extension",
|
|
8
|
+
"rpiv",
|
|
9
|
+
"todo"
|
|
10
|
+
],
|
|
6
11
|
"type": "module",
|
|
7
12
|
"license": "MIT",
|
|
8
13
|
"author": "juicesharp",
|
|
9
14
|
"repository": {
|
|
10
15
|
"type": "git",
|
|
11
|
-
"url": "git+https://github.com/juicesharp/rpiv-
|
|
16
|
+
"url": "git+https://github.com/juicesharp/rpiv-mono.git",
|
|
17
|
+
"directory": "packages/rpiv-todo"
|
|
12
18
|
},
|
|
13
|
-
"homepage": "https://github.com/juicesharp/rpiv-todo#readme",
|
|
19
|
+
"homepage": "https://github.com/juicesharp/rpiv-mono/tree/main/packages/rpiv-todo#readme",
|
|
14
20
|
"bugs": {
|
|
15
|
-
"url": "https://github.com/juicesharp/rpiv-
|
|
21
|
+
"url": "https://github.com/juicesharp/rpiv-mono/issues"
|
|
16
22
|
},
|
|
17
23
|
"publishConfig": {
|
|
18
24
|
"access": "public"
|
|
19
25
|
},
|
|
26
|
+
"files": [
|
|
27
|
+
"index.ts",
|
|
28
|
+
"todo.ts",
|
|
29
|
+
"todo-overlay.ts",
|
|
30
|
+
"README.md",
|
|
31
|
+
"LICENSE"
|
|
32
|
+
],
|
|
20
33
|
"pi": {
|
|
21
|
-
"extensions": [
|
|
34
|
+
"extensions": [
|
|
35
|
+
"./index.ts"
|
|
36
|
+
]
|
|
22
37
|
},
|
|
23
38
|
"peerDependencies": {
|
|
24
39
|
"@mariozechner/pi-ai": "*",
|
package/todo-overlay.ts
CHANGED
|
@@ -11,11 +11,8 @@
|
|
|
11
11
|
* branch is stale at that point (message_end runs after the extension event).
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
import type {
|
|
15
|
-
|
|
16
|
-
Theme,
|
|
17
|
-
} from "@mariozechner/pi-coding-agent";
|
|
18
|
-
import { truncateToWidth, type TUI } from "@mariozechner/pi-tui";
|
|
14
|
+
import type { ExtensionUIContext, Theme } from "@mariozechner/pi-coding-agent";
|
|
15
|
+
import { type TUI, truncateToWidth } from "@mariozechner/pi-tui";
|
|
19
16
|
import { getTodos, type Task, type TaskStatus } from "./todo.js";
|
|
20
17
|
|
|
21
18
|
// ---- Constants ----
|
|
@@ -118,9 +115,7 @@ export class TodoOverlay {
|
|
|
118
115
|
|
|
119
116
|
const completedCount = all.filter((t) => t.status === "completed").length;
|
|
120
117
|
const totalVisible = all.length;
|
|
121
|
-
const hasActive = all.some(
|
|
122
|
-
(t) => t.status === "in_progress" || t.status === "pending",
|
|
123
|
-
);
|
|
118
|
+
const hasActive = all.some((t) => t.status === "in_progress" || t.status === "pending");
|
|
124
119
|
// Show per-row ids only when at least one task has a blockedBy
|
|
125
120
|
// reference — otherwise the `⛓ #N` suffix on a dep row couldn't be
|
|
126
121
|
// resolved against any visible task.
|
|
@@ -129,11 +124,7 @@ export class TodoOverlay {
|
|
|
129
124
|
const headingColor = hasActive ? "accent" : "dim";
|
|
130
125
|
const headingIcon = hasActive ? "●" : "○";
|
|
131
126
|
const headingText = `Todos (${completedCount}/${totalVisible})`;
|
|
132
|
-
const heading = truncate(
|
|
133
|
-
theme.fg(headingColor, headingIcon) +
|
|
134
|
-
" " +
|
|
135
|
-
theme.fg(headingColor, headingText),
|
|
136
|
-
);
|
|
127
|
+
const heading = truncate(`${theme.fg(headingColor, headingIcon)} ${theme.fg(headingColor, headingText)}`);
|
|
137
128
|
|
|
138
129
|
const lines: string[] = [heading];
|
|
139
130
|
const maxBody = MAX_WIDGET_LINES - 1; // heading takes 1 row
|
|
@@ -141,11 +132,7 @@ export class TodoOverlay {
|
|
|
141
132
|
// Happy path: everything fits in natural order.
|
|
142
133
|
if (all.length <= maxBody) {
|
|
143
134
|
for (const t of all) {
|
|
144
|
-
lines.push(
|
|
145
|
-
truncate(
|
|
146
|
-
theme.fg("dim", "├─") + " " + this.formatTaskLine(t, theme, showIds),
|
|
147
|
-
),
|
|
148
|
-
);
|
|
135
|
+
lines.push(truncate(`${theme.fg("dim", "├─")} ${this.formatTaskLine(t, theme, showIds)}`));
|
|
149
136
|
}
|
|
150
137
|
const last = lines.length - 1;
|
|
151
138
|
lines[last] = lines[last].replace("├─", "└─");
|
|
@@ -177,16 +164,10 @@ export class TodoOverlay {
|
|
|
177
164
|
}
|
|
178
165
|
|
|
179
166
|
for (const t of visible) {
|
|
180
|
-
lines.push(
|
|
181
|
-
truncate(
|
|
182
|
-
theme.fg("dim", "├─") + " " + this.formatTaskLine(t, theme, showIds),
|
|
183
|
-
),
|
|
184
|
-
);
|
|
167
|
+
lines.push(truncate(`${theme.fg("dim", "├─")} ${this.formatTaskLine(t, theme, showIds)}`));
|
|
185
168
|
}
|
|
186
169
|
|
|
187
|
-
const shownCompleted = visible.filter(
|
|
188
|
-
(t) => t.status === "completed",
|
|
189
|
-
).length;
|
|
170
|
+
const shownCompleted = visible.filter((t) => t.status === "completed").length;
|
|
190
171
|
const hiddenCompleted = completedCount - shownCompleted;
|
|
191
172
|
const totalHidden = hiddenCompleted + truncatedTailCount;
|
|
192
173
|
const overflowParts: string[] = [];
|
|
@@ -209,8 +190,7 @@ export class TodoOverlay {
|
|
|
209
190
|
|
|
210
191
|
private formatTaskLine(t: Task, theme: Theme, showId: boolean): string {
|
|
211
192
|
const glyph = statusGlyph(t.status, theme);
|
|
212
|
-
const subjectColor =
|
|
213
|
-
t.status === "completed" || t.status === "deleted" ? "dim" : "text";
|
|
193
|
+
const subjectColor = t.status === "completed" || t.status === "deleted" ? "dim" : "text";
|
|
214
194
|
let subject = theme.fg(subjectColor, t.subject);
|
|
215
195
|
if (t.status === "completed" || t.status === "deleted") {
|
|
216
196
|
subject = theme.strikethrough(subject);
|
|
@@ -221,15 +201,10 @@ export class TodoOverlay {
|
|
|
221
201
|
}
|
|
222
202
|
line += ` ${subject}`;
|
|
223
203
|
if (t.status === "in_progress" && t.activeForm) {
|
|
224
|
-
line +=
|
|
204
|
+
line += ` ${theme.fg("dim", `(${t.activeForm})`)}`;
|
|
225
205
|
}
|
|
226
206
|
if (t.blockedBy && t.blockedBy.length > 0) {
|
|
227
|
-
line +=
|
|
228
|
-
" " +
|
|
229
|
-
theme.fg(
|
|
230
|
-
"dim",
|
|
231
|
-
`⛓ ${t.blockedBy.map((id) => `#${id}`).join(",")}`,
|
|
232
|
-
);
|
|
207
|
+
line += ` ${theme.fg("dim", `⛓ ${t.blockedBy.map((id) => `#${id}`).join(",")}`)}`;
|
|
233
208
|
}
|
|
234
209
|
return line;
|
|
235
210
|
}
|
package/todo.ts
CHANGED
|
@@ -10,11 +10,22 @@
|
|
|
10
10
|
* templates/pi-permissions.jsonc:26.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
14
13
|
import { StringEnum } from "@mariozechner/pi-ai";
|
|
14
|
+
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
15
15
|
import { Text } from "@mariozechner/pi-tui";
|
|
16
16
|
import { Type } from "@sinclair/typebox";
|
|
17
17
|
|
|
18
|
+
// ---------------------------------------------------------------------------
|
|
19
|
+
// Constants — tool/command identity and static user-facing strings
|
|
20
|
+
// ---------------------------------------------------------------------------
|
|
21
|
+
|
|
22
|
+
export const TOOL_NAME = "todo";
|
|
23
|
+
const TOOL_LABEL = "Todo";
|
|
24
|
+
const COMMAND_NAME = "todos";
|
|
25
|
+
|
|
26
|
+
const ERR_REQUIRES_INTERACTIVE = "/todos requires interactive mode";
|
|
27
|
+
const MSG_NO_TODOS = "No todos yet. Ask the agent to add some!";
|
|
28
|
+
|
|
18
29
|
// ---------------------------------------------------------------------------
|
|
19
30
|
// Types
|
|
20
31
|
// ---------------------------------------------------------------------------
|
|
@@ -73,11 +84,7 @@ export function isTransitionValid(from: TaskStatus, to: TaskStatus): boolean {
|
|
|
73
84
|
return VALID_TRANSITIONS[from].has(to);
|
|
74
85
|
}
|
|
75
86
|
|
|
76
|
-
export function detectCycle(
|
|
77
|
-
taskList: readonly Task[],
|
|
78
|
-
taskId: number,
|
|
79
|
-
newBlockedBy: readonly number[],
|
|
80
|
-
): boolean {
|
|
87
|
+
export function detectCycle(taskList: readonly Task[], taskId: number, newBlockedBy: readonly number[]): boolean {
|
|
81
88
|
const edges = new Map<number, number[]>();
|
|
82
89
|
for (const t of taskList) {
|
|
83
90
|
if (t.id === taskId) {
|
|
@@ -169,34 +176,20 @@ function errorResult(
|
|
|
169
176
|
};
|
|
170
177
|
}
|
|
171
178
|
|
|
172
|
-
export function applyTaskMutation(
|
|
173
|
-
state: ReducerState,
|
|
174
|
-
action: TaskAction,
|
|
175
|
-
params: TaskMutationParams,
|
|
176
|
-
): ReducerResult {
|
|
179
|
+
export function applyTaskMutation(state: ReducerState, action: TaskAction, params: TaskMutationParams): ReducerResult {
|
|
177
180
|
switch (action) {
|
|
178
181
|
case "create": {
|
|
179
182
|
if (!params.subject || !params.subject.trim()) {
|
|
180
183
|
return errorResult(state, action, params, "subject required for create");
|
|
181
184
|
}
|
|
182
|
-
if (params.blockedBy
|
|
185
|
+
if (params.blockedBy?.length) {
|
|
183
186
|
for (const dep of params.blockedBy) {
|
|
184
187
|
const depTask = state.tasks.find((t) => t.id === dep);
|
|
185
188
|
if (!depTask) {
|
|
186
|
-
return errorResult(
|
|
187
|
-
state,
|
|
188
|
-
action,
|
|
189
|
-
params,
|
|
190
|
-
`blockedBy: #${dep} not found`,
|
|
191
|
-
);
|
|
189
|
+
return errorResult(state, action, params, `blockedBy: #${dep} not found`);
|
|
192
190
|
}
|
|
193
191
|
if (depTask.status === "deleted") {
|
|
194
|
-
return errorResult(
|
|
195
|
-
state,
|
|
196
|
-
action,
|
|
197
|
-
params,
|
|
198
|
-
`blockedBy: #${dep} is deleted`,
|
|
199
|
-
);
|
|
192
|
+
return errorResult(state, action, params, `blockedBy: #${dep} is deleted`);
|
|
200
193
|
}
|
|
201
194
|
}
|
|
202
195
|
}
|
|
@@ -207,7 +200,7 @@ export function applyTaskMutation(
|
|
|
207
200
|
};
|
|
208
201
|
if (params.description) newTask.description = params.description;
|
|
209
202
|
if (params.activeForm) newTask.activeForm = params.activeForm;
|
|
210
|
-
if (params.blockedBy
|
|
203
|
+
if (params.blockedBy?.length) {
|
|
211
204
|
newTask.blockedBy = [...params.blockedBy];
|
|
212
205
|
}
|
|
213
206
|
if (params.owner) newTask.owner = params.owner;
|
|
@@ -252,68 +245,38 @@ export function applyTaskMutation(
|
|
|
252
245
|
(params.addBlockedBy && params.addBlockedBy.length > 0) ||
|
|
253
246
|
(params.removeBlockedBy && params.removeBlockedBy.length > 0);
|
|
254
247
|
if (!hasMutation) {
|
|
255
|
-
return errorResult(
|
|
256
|
-
state,
|
|
257
|
-
action,
|
|
258
|
-
params,
|
|
259
|
-
"update requires at least one mutable field",
|
|
260
|
-
);
|
|
248
|
+
return errorResult(state, action, params, "update requires at least one mutable field");
|
|
261
249
|
}
|
|
262
250
|
|
|
263
251
|
let newStatus = current.status;
|
|
264
252
|
if (params.status !== undefined) {
|
|
265
253
|
if (!isTransitionValid(current.status, params.status)) {
|
|
266
|
-
return errorResult(
|
|
267
|
-
state,
|
|
268
|
-
action,
|
|
269
|
-
params,
|
|
270
|
-
`illegal transition ${current.status} → ${params.status}`,
|
|
271
|
-
);
|
|
254
|
+
return errorResult(state, action, params, `illegal transition ${current.status} → ${params.status}`);
|
|
272
255
|
}
|
|
273
256
|
newStatus = params.status;
|
|
274
257
|
}
|
|
275
258
|
|
|
276
259
|
let newBlockedBy = current.blockedBy ? [...current.blockedBy] : [];
|
|
277
|
-
if (params.removeBlockedBy
|
|
260
|
+
if (params.removeBlockedBy?.length) {
|
|
278
261
|
const toRemove = new Set(params.removeBlockedBy);
|
|
279
262
|
newBlockedBy = newBlockedBy.filter((dep) => !toRemove.has(dep));
|
|
280
263
|
}
|
|
281
|
-
if (params.addBlockedBy
|
|
264
|
+
if (params.addBlockedBy?.length) {
|
|
282
265
|
for (const dep of params.addBlockedBy) {
|
|
283
266
|
if (dep === current.id) {
|
|
284
|
-
return errorResult(
|
|
285
|
-
state,
|
|
286
|
-
action,
|
|
287
|
-
params,
|
|
288
|
-
`cannot block #${current.id} on itself`,
|
|
289
|
-
);
|
|
267
|
+
return errorResult(state, action, params, `cannot block #${current.id} on itself`);
|
|
290
268
|
}
|
|
291
269
|
const depTask = state.tasks.find((t) => t.id === dep);
|
|
292
270
|
if (!depTask) {
|
|
293
|
-
return errorResult(
|
|
294
|
-
state,
|
|
295
|
-
action,
|
|
296
|
-
params,
|
|
297
|
-
`addBlockedBy: #${dep} not found`,
|
|
298
|
-
);
|
|
271
|
+
return errorResult(state, action, params, `addBlockedBy: #${dep} not found`);
|
|
299
272
|
}
|
|
300
273
|
if (depTask.status === "deleted") {
|
|
301
|
-
return errorResult(
|
|
302
|
-
state,
|
|
303
|
-
action,
|
|
304
|
-
params,
|
|
305
|
-
`addBlockedBy: #${dep} is deleted`,
|
|
306
|
-
);
|
|
274
|
+
return errorResult(state, action, params, `addBlockedBy: #${dep} is deleted`);
|
|
307
275
|
}
|
|
308
276
|
if (!newBlockedBy.includes(dep)) newBlockedBy.push(dep);
|
|
309
277
|
}
|
|
310
278
|
if (detectCycle(state.tasks, current.id, newBlockedBy)) {
|
|
311
|
-
return errorResult(
|
|
312
|
-
state,
|
|
313
|
-
action,
|
|
314
|
-
params,
|
|
315
|
-
"addBlockedBy would create a cycle in the blockedBy graph",
|
|
316
|
-
);
|
|
279
|
+
return errorResult(state, action, params, "addBlockedBy would create a cycle in the blockedBy graph");
|
|
317
280
|
}
|
|
318
281
|
}
|
|
319
282
|
|
|
@@ -345,10 +308,7 @@ export function applyTaskMutation(
|
|
|
345
308
|
|
|
346
309
|
const newTasks = [...state.tasks];
|
|
347
310
|
newTasks[idx] = updated;
|
|
348
|
-
const transition =
|
|
349
|
-
current.status !== newStatus
|
|
350
|
-
? ` (${current.status} → ${newStatus})`
|
|
351
|
-
: "";
|
|
311
|
+
const transition = current.status !== newStatus ? ` (${current.status} → ${newStatus})` : "";
|
|
352
312
|
return {
|
|
353
313
|
state: { tasks: newTasks, nextId: state.nextId },
|
|
354
314
|
details: {
|
|
@@ -357,9 +317,7 @@ export function applyTaskMutation(
|
|
|
357
317
|
tasks: newTasks,
|
|
358
318
|
nextId: state.nextId,
|
|
359
319
|
},
|
|
360
|
-
content: [
|
|
361
|
-
{ type: "text", text: `Updated #${updated.id}${transition}` },
|
|
362
|
-
],
|
|
320
|
+
content: [{ type: "text", text: `Updated #${updated.id}${transition}` }],
|
|
363
321
|
};
|
|
364
322
|
}
|
|
365
323
|
|
|
@@ -378,13 +336,8 @@ export function applyTaskMutation(
|
|
|
378
336
|
? "No tasks"
|
|
379
337
|
: view
|
|
380
338
|
.map((t) => {
|
|
381
|
-
const block = t.blockedBy?.length
|
|
382
|
-
|
|
383
|
-
: "";
|
|
384
|
-
const form =
|
|
385
|
-
t.status === "in_progress" && t.activeForm
|
|
386
|
-
? ` (${t.activeForm})`
|
|
387
|
-
: "";
|
|
339
|
+
const block = t.blockedBy?.length ? ` ⛓ ${t.blockedBy.map((id) => `#${id}`).join(",")}` : "";
|
|
340
|
+
const form = t.status === "in_progress" && t.activeForm ? ` (${t.activeForm})` : "";
|
|
388
341
|
return `[${t.status}] #${t.id} ${t.subject}${form}${block}`;
|
|
389
342
|
})
|
|
390
343
|
.join("\n");
|
|
@@ -413,9 +366,7 @@ export function applyTaskMutation(
|
|
|
413
366
|
if (task.description) lines.push(` description: ${task.description}`);
|
|
414
367
|
if (task.activeForm) lines.push(` activeForm: ${task.activeForm}`);
|
|
415
368
|
if (task.blockedBy?.length) {
|
|
416
|
-
lines.push(
|
|
417
|
-
` blockedBy: ${task.blockedBy.map((id) => `#${id}`).join(", ")}`,
|
|
418
|
-
);
|
|
369
|
+
lines.push(` blockedBy: ${task.blockedBy.map((id) => `#${id}`).join(", ")}`);
|
|
419
370
|
}
|
|
420
371
|
if (blocks.length) {
|
|
421
372
|
lines.push(` blocks: ${blocks.map((id) => `#${id}`).join(", ")}`);
|
|
@@ -443,12 +394,7 @@ export function applyTaskMutation(
|
|
|
443
394
|
}
|
|
444
395
|
const current = state.tasks[idx];
|
|
445
396
|
if (current.status === "deleted") {
|
|
446
|
-
return errorResult(
|
|
447
|
-
state,
|
|
448
|
-
action,
|
|
449
|
-
params,
|
|
450
|
-
`#${current.id} is already deleted`,
|
|
451
|
-
);
|
|
397
|
+
return errorResult(state, action, params, `#${current.id} is already deleted`);
|
|
452
398
|
}
|
|
453
399
|
const updated: Task = { ...current, status: "deleted" };
|
|
454
400
|
const newTasks = [...state.tasks];
|
|
@@ -461,9 +407,7 @@ export function applyTaskMutation(
|
|
|
461
407
|
tasks: newTasks,
|
|
462
408
|
nextId: state.nextId,
|
|
463
409
|
},
|
|
464
|
-
content: [
|
|
465
|
-
{ type: "text", text: `Deleted #${updated.id}: ${updated.subject}` },
|
|
466
|
-
],
|
|
410
|
+
content: [{ type: "text", text: `Deleted #${updated.id}: ${updated.subject}` }],
|
|
467
411
|
};
|
|
468
412
|
}
|
|
469
413
|
|
|
@@ -513,9 +457,12 @@ export function reconstructTodoState(ctx: any): void {
|
|
|
513
457
|
|
|
514
458
|
function formatStatus(status: TaskStatus): string {
|
|
515
459
|
switch (status) {
|
|
516
|
-
case "in_progress":
|
|
517
|
-
|
|
518
|
-
|
|
460
|
+
case "in_progress":
|
|
461
|
+
return "in progress";
|
|
462
|
+
case "deleted":
|
|
463
|
+
return "deleted";
|
|
464
|
+
default:
|
|
465
|
+
return status;
|
|
519
466
|
}
|
|
520
467
|
}
|
|
521
468
|
|
|
@@ -555,16 +502,11 @@ function taskSubject(id: number): string | undefined {
|
|
|
555
502
|
|
|
556
503
|
const TodoParams = Type.Object({
|
|
557
504
|
action: StringEnum(["create", "update", "list", "get", "delete", "clear"] as const),
|
|
558
|
-
subject: Type.Optional(
|
|
559
|
-
|
|
560
|
-
),
|
|
561
|
-
description: Type.Optional(
|
|
562
|
-
Type.String({ description: "Long-form task description" }),
|
|
563
|
-
),
|
|
505
|
+
subject: Type.Optional(Type.String({ description: "Task subject line (required for create)" })),
|
|
506
|
+
description: Type.Optional(Type.String({ description: "Long-form task description" })),
|
|
564
507
|
activeForm: Type.Optional(
|
|
565
508
|
Type.String({
|
|
566
|
-
description:
|
|
567
|
-
"Present-continuous spinner label shown while status is in_progress (e.g. 'writing tests')",
|
|
509
|
+
description: "Present-continuous spinner label shown while status is in_progress (e.g. 'writing tests')",
|
|
568
510
|
}),
|
|
569
511
|
),
|
|
570
512
|
status: Type.Optional(
|
|
@@ -587,13 +529,10 @@ const TodoParams = Type.Object({
|
|
|
587
529
|
description: "Task ids to remove from blockedBy (update only, additive merge)",
|
|
588
530
|
}),
|
|
589
531
|
),
|
|
590
|
-
owner: Type.Optional(
|
|
591
|
-
Type.String({ description: "Agent/owner assigned to this task" }),
|
|
592
|
-
),
|
|
532
|
+
owner: Type.Optional(Type.String({ description: "Agent/owner assigned to this task" })),
|
|
593
533
|
metadata: Type.Optional(
|
|
594
534
|
Type.Record(Type.String(), Type.Unknown(), {
|
|
595
|
-
description:
|
|
596
|
-
"Arbitrary metadata; pass null value for a key to delete that key on update",
|
|
535
|
+
description: "Arbitrary metadata; pass null value for a key to delete that key on update",
|
|
597
536
|
}),
|
|
598
537
|
),
|
|
599
538
|
id: Type.Optional(
|
|
@@ -603,16 +542,15 @@ const TodoParams = Type.Object({
|
|
|
603
542
|
),
|
|
604
543
|
includeDeleted: Type.Optional(
|
|
605
544
|
Type.Boolean({
|
|
606
|
-
description:
|
|
607
|
-
"If true, list action returns deleted (tombstoned) tasks as well. Default: false.",
|
|
545
|
+
description: "If true, list action returns deleted (tombstoned) tasks as well. Default: false.",
|
|
608
546
|
}),
|
|
609
547
|
),
|
|
610
548
|
});
|
|
611
549
|
|
|
612
550
|
export function registerTodoTool(pi: ExtensionAPI): void {
|
|
613
551
|
pi.registerTool({
|
|
614
|
-
name:
|
|
615
|
-
label:
|
|
552
|
+
name: TOOL_NAME,
|
|
553
|
+
label: TOOL_LABEL,
|
|
616
554
|
description:
|
|
617
555
|
"Manage a task list for tracking multi-step progress. Actions: create (new task), update (change status/fields/dependencies), list (all tasks, optionally filtered by status), get (single task details), delete (tombstone), clear (reset all). Status: pending → in_progress → completed, plus deleted tombstone. Use this to plan and track multi-step work like research, design, and implementation.",
|
|
618
556
|
promptSnippet: "Manage a Claude-Code-style task list to track multi-step progress",
|
|
@@ -628,11 +566,7 @@ export function registerTodoTool(pi: ExtensionAPI): void {
|
|
|
628
566
|
parameters: TodoParams,
|
|
629
567
|
|
|
630
568
|
async execute(_toolCallId, params, _signal, _onUpdate, _ctx) {
|
|
631
|
-
const result = applyTaskMutation(
|
|
632
|
-
{ tasks, nextId },
|
|
633
|
-
params.action,
|
|
634
|
-
params as TaskMutationParams,
|
|
635
|
-
);
|
|
569
|
+
const result = applyTaskMutation({ tasks, nextId }, params.action, params as TaskMutationParams);
|
|
636
570
|
tasks = result.state.tasks;
|
|
637
571
|
nextId = result.state.nextId;
|
|
638
572
|
return {
|
|
@@ -662,9 +596,6 @@ export function registerTodoTool(pi: ExtensionAPI): void {
|
|
|
662
596
|
},
|
|
663
597
|
|
|
664
598
|
renderResult(result, _opts, theme, _context) {
|
|
665
|
-
if (result.isError) {
|
|
666
|
-
return new Text(theme.fg("error", "✗"), 0, 0);
|
|
667
|
-
}
|
|
668
599
|
const details = result.details as TaskDetails | undefined;
|
|
669
600
|
// Only create/update/delete advertise a status; list/get/clear render a
|
|
670
601
|
// plain ✓. This prevents list from rendering the last task's status as
|
|
@@ -678,9 +609,7 @@ export function registerTodoTool(pi: ExtensionAPI): void {
|
|
|
678
609
|
status = details.tasks[details.tasks.length - 1]?.status;
|
|
679
610
|
break;
|
|
680
611
|
case "update":
|
|
681
|
-
status =
|
|
682
|
-
params.status ??
|
|
683
|
-
details.tasks.find((t) => t.id === params.id)?.status;
|
|
612
|
+
status = params.status ?? details.tasks.find((t) => t.id === params.id)?.status;
|
|
684
613
|
break;
|
|
685
614
|
case "delete":
|
|
686
615
|
status = details.tasks.find((t) => t.id === params.id)?.status;
|
|
@@ -692,11 +621,7 @@ export function registerTodoTool(pi: ExtensionAPI): void {
|
|
|
692
621
|
}
|
|
693
622
|
}
|
|
694
623
|
if (status) {
|
|
695
|
-
return new Text(
|
|
696
|
-
theme.fg(STATUS_COLOR[status], `${STATUS_GLYPH[status]} ${formatStatus(status)}`),
|
|
697
|
-
0,
|
|
698
|
-
0,
|
|
699
|
-
);
|
|
624
|
+
return new Text(theme.fg(STATUS_COLOR[status], `${STATUS_GLYPH[status]} ${formatStatus(status)}`), 0, 0);
|
|
700
625
|
}
|
|
701
626
|
return new Text(theme.fg("success", "✓"), 0, 0);
|
|
702
627
|
},
|
|
@@ -708,16 +633,16 @@ export function registerTodoTool(pi: ExtensionAPI): void {
|
|
|
708
633
|
// ---------------------------------------------------------------------------
|
|
709
634
|
|
|
710
635
|
export function registerTodosCommand(pi: ExtensionAPI): void {
|
|
711
|
-
pi.registerCommand(
|
|
636
|
+
pi.registerCommand(COMMAND_NAME, {
|
|
712
637
|
description: "Show all todos on the current branch, grouped by status",
|
|
713
638
|
handler: async (_args, ctx) => {
|
|
714
639
|
if (!ctx.hasUI) {
|
|
715
|
-
ctx.ui.notify(
|
|
640
|
+
ctx.ui.notify(ERR_REQUIRES_INTERACTIVE, "error");
|
|
716
641
|
return;
|
|
717
642
|
}
|
|
718
643
|
const visible = tasks.filter((t) => t.status !== "deleted");
|
|
719
644
|
if (visible.length === 0) {
|
|
720
|
-
ctx.ui.notify(
|
|
645
|
+
ctx.ui.notify(MSG_NO_TODOS, "info");
|
|
721
646
|
return;
|
|
722
647
|
}
|
|
723
648
|
|
|
@@ -739,13 +664,8 @@ export function registerTodosCommand(pi: ExtensionAPI): void {
|
|
|
739
664
|
const lines: string[] = [header.join(" · ")];
|
|
740
665
|
|
|
741
666
|
const renderTask = (t: Task, glyph: string): string => {
|
|
742
|
-
const form =
|
|
743
|
-
|
|
744
|
-
? ` (${t.activeForm})`
|
|
745
|
-
: "";
|
|
746
|
-
const block = t.blockedBy?.length
|
|
747
|
-
? ` ⛓ ${t.blockedBy.map((id) => `#${id}`).join(",")}`
|
|
748
|
-
: "";
|
|
667
|
+
const form = t.status === "in_progress" && t.activeForm ? ` (${t.activeForm})` : "";
|
|
668
|
+
const block = t.blockedBy?.length ? ` ⛓ ${t.blockedBy.map((id) => `#${id}`).join(",")}` : "";
|
|
749
669
|
return ` ${glyph} #${t.id} ${t.subject}${form}${block}`;
|
|
750
670
|
};
|
|
751
671
|
|
package/docs/overlay.jpg
DELETED
|
Binary file
|