@juicesharp/rpiv-todo 0.1.2 → 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 +7 -5
- package/todo-overlay.ts +10 -35
- package/todo.ts +39 -130
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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juicesharp/rpiv-todo",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "Pi extension: Claude-Code-parity todo tool + persistent overlay widget",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|
|
@@ -13,11 +13,12 @@
|
|
|
13
13
|
"author": "juicesharp",
|
|
14
14
|
"repository": {
|
|
15
15
|
"type": "git",
|
|
16
|
-
"url": "git+https://github.com/juicesharp/rpiv-
|
|
16
|
+
"url": "git+https://github.com/juicesharp/rpiv-mono.git",
|
|
17
|
+
"directory": "packages/rpiv-todo"
|
|
17
18
|
},
|
|
18
|
-
"homepage": "https://github.com/juicesharp/rpiv-todo#readme",
|
|
19
|
+
"homepage": "https://github.com/juicesharp/rpiv-mono/tree/main/packages/rpiv-todo#readme",
|
|
19
20
|
"bugs": {
|
|
20
|
-
"url": "https://github.com/juicesharp/rpiv-
|
|
21
|
+
"url": "https://github.com/juicesharp/rpiv-mono/issues"
|
|
21
22
|
},
|
|
22
23
|
"publishConfig": {
|
|
23
24
|
"access": "public"
|
|
@@ -26,7 +27,8 @@
|
|
|
26
27
|
"index.ts",
|
|
27
28
|
"todo.ts",
|
|
28
29
|
"todo-overlay.ts",
|
|
29
|
-
"README.md"
|
|
30
|
+
"README.md",
|
|
31
|
+
"LICENSE"
|
|
30
32
|
],
|
|
31
33
|
"pi": {
|
|
32
34
|
"extensions": [
|
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,8 +10,8 @@
|
|
|
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
|
|
|
@@ -84,11 +84,7 @@ export function isTransitionValid(from: TaskStatus, to: TaskStatus): boolean {
|
|
|
84
84
|
return VALID_TRANSITIONS[from].has(to);
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
export function detectCycle(
|
|
88
|
-
taskList: readonly Task[],
|
|
89
|
-
taskId: number,
|
|
90
|
-
newBlockedBy: readonly number[],
|
|
91
|
-
): boolean {
|
|
87
|
+
export function detectCycle(taskList: readonly Task[], taskId: number, newBlockedBy: readonly number[]): boolean {
|
|
92
88
|
const edges = new Map<number, number[]>();
|
|
93
89
|
for (const t of taskList) {
|
|
94
90
|
if (t.id === taskId) {
|
|
@@ -180,34 +176,20 @@ function errorResult(
|
|
|
180
176
|
};
|
|
181
177
|
}
|
|
182
178
|
|
|
183
|
-
export function applyTaskMutation(
|
|
184
|
-
state: ReducerState,
|
|
185
|
-
action: TaskAction,
|
|
186
|
-
params: TaskMutationParams,
|
|
187
|
-
): ReducerResult {
|
|
179
|
+
export function applyTaskMutation(state: ReducerState, action: TaskAction, params: TaskMutationParams): ReducerResult {
|
|
188
180
|
switch (action) {
|
|
189
181
|
case "create": {
|
|
190
182
|
if (!params.subject || !params.subject.trim()) {
|
|
191
183
|
return errorResult(state, action, params, "subject required for create");
|
|
192
184
|
}
|
|
193
|
-
if (params.blockedBy
|
|
185
|
+
if (params.blockedBy?.length) {
|
|
194
186
|
for (const dep of params.blockedBy) {
|
|
195
187
|
const depTask = state.tasks.find((t) => t.id === dep);
|
|
196
188
|
if (!depTask) {
|
|
197
|
-
return errorResult(
|
|
198
|
-
state,
|
|
199
|
-
action,
|
|
200
|
-
params,
|
|
201
|
-
`blockedBy: #${dep} not found`,
|
|
202
|
-
);
|
|
189
|
+
return errorResult(state, action, params, `blockedBy: #${dep} not found`);
|
|
203
190
|
}
|
|
204
191
|
if (depTask.status === "deleted") {
|
|
205
|
-
return errorResult(
|
|
206
|
-
state,
|
|
207
|
-
action,
|
|
208
|
-
params,
|
|
209
|
-
`blockedBy: #${dep} is deleted`,
|
|
210
|
-
);
|
|
192
|
+
return errorResult(state, action, params, `blockedBy: #${dep} is deleted`);
|
|
211
193
|
}
|
|
212
194
|
}
|
|
213
195
|
}
|
|
@@ -218,7 +200,7 @@ export function applyTaskMutation(
|
|
|
218
200
|
};
|
|
219
201
|
if (params.description) newTask.description = params.description;
|
|
220
202
|
if (params.activeForm) newTask.activeForm = params.activeForm;
|
|
221
|
-
if (params.blockedBy
|
|
203
|
+
if (params.blockedBy?.length) {
|
|
222
204
|
newTask.blockedBy = [...params.blockedBy];
|
|
223
205
|
}
|
|
224
206
|
if (params.owner) newTask.owner = params.owner;
|
|
@@ -263,68 +245,38 @@ export function applyTaskMutation(
|
|
|
263
245
|
(params.addBlockedBy && params.addBlockedBy.length > 0) ||
|
|
264
246
|
(params.removeBlockedBy && params.removeBlockedBy.length > 0);
|
|
265
247
|
if (!hasMutation) {
|
|
266
|
-
return errorResult(
|
|
267
|
-
state,
|
|
268
|
-
action,
|
|
269
|
-
params,
|
|
270
|
-
"update requires at least one mutable field",
|
|
271
|
-
);
|
|
248
|
+
return errorResult(state, action, params, "update requires at least one mutable field");
|
|
272
249
|
}
|
|
273
250
|
|
|
274
251
|
let newStatus = current.status;
|
|
275
252
|
if (params.status !== undefined) {
|
|
276
253
|
if (!isTransitionValid(current.status, params.status)) {
|
|
277
|
-
return errorResult(
|
|
278
|
-
state,
|
|
279
|
-
action,
|
|
280
|
-
params,
|
|
281
|
-
`illegal transition ${current.status} → ${params.status}`,
|
|
282
|
-
);
|
|
254
|
+
return errorResult(state, action, params, `illegal transition ${current.status} → ${params.status}`);
|
|
283
255
|
}
|
|
284
256
|
newStatus = params.status;
|
|
285
257
|
}
|
|
286
258
|
|
|
287
259
|
let newBlockedBy = current.blockedBy ? [...current.blockedBy] : [];
|
|
288
|
-
if (params.removeBlockedBy
|
|
260
|
+
if (params.removeBlockedBy?.length) {
|
|
289
261
|
const toRemove = new Set(params.removeBlockedBy);
|
|
290
262
|
newBlockedBy = newBlockedBy.filter((dep) => !toRemove.has(dep));
|
|
291
263
|
}
|
|
292
|
-
if (params.addBlockedBy
|
|
264
|
+
if (params.addBlockedBy?.length) {
|
|
293
265
|
for (const dep of params.addBlockedBy) {
|
|
294
266
|
if (dep === current.id) {
|
|
295
|
-
return errorResult(
|
|
296
|
-
state,
|
|
297
|
-
action,
|
|
298
|
-
params,
|
|
299
|
-
`cannot block #${current.id} on itself`,
|
|
300
|
-
);
|
|
267
|
+
return errorResult(state, action, params, `cannot block #${current.id} on itself`);
|
|
301
268
|
}
|
|
302
269
|
const depTask = state.tasks.find((t) => t.id === dep);
|
|
303
270
|
if (!depTask) {
|
|
304
|
-
return errorResult(
|
|
305
|
-
state,
|
|
306
|
-
action,
|
|
307
|
-
params,
|
|
308
|
-
`addBlockedBy: #${dep} not found`,
|
|
309
|
-
);
|
|
271
|
+
return errorResult(state, action, params, `addBlockedBy: #${dep} not found`);
|
|
310
272
|
}
|
|
311
273
|
if (depTask.status === "deleted") {
|
|
312
|
-
return errorResult(
|
|
313
|
-
state,
|
|
314
|
-
action,
|
|
315
|
-
params,
|
|
316
|
-
`addBlockedBy: #${dep} is deleted`,
|
|
317
|
-
);
|
|
274
|
+
return errorResult(state, action, params, `addBlockedBy: #${dep} is deleted`);
|
|
318
275
|
}
|
|
319
276
|
if (!newBlockedBy.includes(dep)) newBlockedBy.push(dep);
|
|
320
277
|
}
|
|
321
278
|
if (detectCycle(state.tasks, current.id, newBlockedBy)) {
|
|
322
|
-
return errorResult(
|
|
323
|
-
state,
|
|
324
|
-
action,
|
|
325
|
-
params,
|
|
326
|
-
"addBlockedBy would create a cycle in the blockedBy graph",
|
|
327
|
-
);
|
|
279
|
+
return errorResult(state, action, params, "addBlockedBy would create a cycle in the blockedBy graph");
|
|
328
280
|
}
|
|
329
281
|
}
|
|
330
282
|
|
|
@@ -356,10 +308,7 @@ export function applyTaskMutation(
|
|
|
356
308
|
|
|
357
309
|
const newTasks = [...state.tasks];
|
|
358
310
|
newTasks[idx] = updated;
|
|
359
|
-
const transition =
|
|
360
|
-
current.status !== newStatus
|
|
361
|
-
? ` (${current.status} → ${newStatus})`
|
|
362
|
-
: "";
|
|
311
|
+
const transition = current.status !== newStatus ? ` (${current.status} → ${newStatus})` : "";
|
|
363
312
|
return {
|
|
364
313
|
state: { tasks: newTasks, nextId: state.nextId },
|
|
365
314
|
details: {
|
|
@@ -368,9 +317,7 @@ export function applyTaskMutation(
|
|
|
368
317
|
tasks: newTasks,
|
|
369
318
|
nextId: state.nextId,
|
|
370
319
|
},
|
|
371
|
-
content: [
|
|
372
|
-
{ type: "text", text: `Updated #${updated.id}${transition}` },
|
|
373
|
-
],
|
|
320
|
+
content: [{ type: "text", text: `Updated #${updated.id}${transition}` }],
|
|
374
321
|
};
|
|
375
322
|
}
|
|
376
323
|
|
|
@@ -389,13 +336,8 @@ export function applyTaskMutation(
|
|
|
389
336
|
? "No tasks"
|
|
390
337
|
: view
|
|
391
338
|
.map((t) => {
|
|
392
|
-
const block = t.blockedBy?.length
|
|
393
|
-
|
|
394
|
-
: "";
|
|
395
|
-
const form =
|
|
396
|
-
t.status === "in_progress" && t.activeForm
|
|
397
|
-
? ` (${t.activeForm})`
|
|
398
|
-
: "";
|
|
339
|
+
const block = t.blockedBy?.length ? ` ⛓ ${t.blockedBy.map((id) => `#${id}`).join(",")}` : "";
|
|
340
|
+
const form = t.status === "in_progress" && t.activeForm ? ` (${t.activeForm})` : "";
|
|
399
341
|
return `[${t.status}] #${t.id} ${t.subject}${form}${block}`;
|
|
400
342
|
})
|
|
401
343
|
.join("\n");
|
|
@@ -424,9 +366,7 @@ export function applyTaskMutation(
|
|
|
424
366
|
if (task.description) lines.push(` description: ${task.description}`);
|
|
425
367
|
if (task.activeForm) lines.push(` activeForm: ${task.activeForm}`);
|
|
426
368
|
if (task.blockedBy?.length) {
|
|
427
|
-
lines.push(
|
|
428
|
-
` blockedBy: ${task.blockedBy.map((id) => `#${id}`).join(", ")}`,
|
|
429
|
-
);
|
|
369
|
+
lines.push(` blockedBy: ${task.blockedBy.map((id) => `#${id}`).join(", ")}`);
|
|
430
370
|
}
|
|
431
371
|
if (blocks.length) {
|
|
432
372
|
lines.push(` blocks: ${blocks.map((id) => `#${id}`).join(", ")}`);
|
|
@@ -454,12 +394,7 @@ export function applyTaskMutation(
|
|
|
454
394
|
}
|
|
455
395
|
const current = state.tasks[idx];
|
|
456
396
|
if (current.status === "deleted") {
|
|
457
|
-
return errorResult(
|
|
458
|
-
state,
|
|
459
|
-
action,
|
|
460
|
-
params,
|
|
461
|
-
`#${current.id} is already deleted`,
|
|
462
|
-
);
|
|
397
|
+
return errorResult(state, action, params, `#${current.id} is already deleted`);
|
|
463
398
|
}
|
|
464
399
|
const updated: Task = { ...current, status: "deleted" };
|
|
465
400
|
const newTasks = [...state.tasks];
|
|
@@ -472,9 +407,7 @@ export function applyTaskMutation(
|
|
|
472
407
|
tasks: newTasks,
|
|
473
408
|
nextId: state.nextId,
|
|
474
409
|
},
|
|
475
|
-
content: [
|
|
476
|
-
{ type: "text", text: `Deleted #${updated.id}: ${updated.subject}` },
|
|
477
|
-
],
|
|
410
|
+
content: [{ type: "text", text: `Deleted #${updated.id}: ${updated.subject}` }],
|
|
478
411
|
};
|
|
479
412
|
}
|
|
480
413
|
|
|
@@ -524,9 +457,12 @@ export function reconstructTodoState(ctx: any): void {
|
|
|
524
457
|
|
|
525
458
|
function formatStatus(status: TaskStatus): string {
|
|
526
459
|
switch (status) {
|
|
527
|
-
case "in_progress":
|
|
528
|
-
|
|
529
|
-
|
|
460
|
+
case "in_progress":
|
|
461
|
+
return "in progress";
|
|
462
|
+
case "deleted":
|
|
463
|
+
return "deleted";
|
|
464
|
+
default:
|
|
465
|
+
return status;
|
|
530
466
|
}
|
|
531
467
|
}
|
|
532
468
|
|
|
@@ -566,16 +502,11 @@ function taskSubject(id: number): string | undefined {
|
|
|
566
502
|
|
|
567
503
|
const TodoParams = Type.Object({
|
|
568
504
|
action: StringEnum(["create", "update", "list", "get", "delete", "clear"] as const),
|
|
569
|
-
subject: Type.Optional(
|
|
570
|
-
|
|
571
|
-
),
|
|
572
|
-
description: Type.Optional(
|
|
573
|
-
Type.String({ description: "Long-form task description" }),
|
|
574
|
-
),
|
|
505
|
+
subject: Type.Optional(Type.String({ description: "Task subject line (required for create)" })),
|
|
506
|
+
description: Type.Optional(Type.String({ description: "Long-form task description" })),
|
|
575
507
|
activeForm: Type.Optional(
|
|
576
508
|
Type.String({
|
|
577
|
-
description:
|
|
578
|
-
"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')",
|
|
579
510
|
}),
|
|
580
511
|
),
|
|
581
512
|
status: Type.Optional(
|
|
@@ -598,13 +529,10 @@ const TodoParams = Type.Object({
|
|
|
598
529
|
description: "Task ids to remove from blockedBy (update only, additive merge)",
|
|
599
530
|
}),
|
|
600
531
|
),
|
|
601
|
-
owner: Type.Optional(
|
|
602
|
-
Type.String({ description: "Agent/owner assigned to this task" }),
|
|
603
|
-
),
|
|
532
|
+
owner: Type.Optional(Type.String({ description: "Agent/owner assigned to this task" })),
|
|
604
533
|
metadata: Type.Optional(
|
|
605
534
|
Type.Record(Type.String(), Type.Unknown(), {
|
|
606
|
-
description:
|
|
607
|
-
"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",
|
|
608
536
|
}),
|
|
609
537
|
),
|
|
610
538
|
id: Type.Optional(
|
|
@@ -614,8 +542,7 @@ const TodoParams = Type.Object({
|
|
|
614
542
|
),
|
|
615
543
|
includeDeleted: Type.Optional(
|
|
616
544
|
Type.Boolean({
|
|
617
|
-
description:
|
|
618
|
-
"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.",
|
|
619
546
|
}),
|
|
620
547
|
),
|
|
621
548
|
});
|
|
@@ -639,11 +566,7 @@ export function registerTodoTool(pi: ExtensionAPI): void {
|
|
|
639
566
|
parameters: TodoParams,
|
|
640
567
|
|
|
641
568
|
async execute(_toolCallId, params, _signal, _onUpdate, _ctx) {
|
|
642
|
-
const result = applyTaskMutation(
|
|
643
|
-
{ tasks, nextId },
|
|
644
|
-
params.action,
|
|
645
|
-
params as TaskMutationParams,
|
|
646
|
-
);
|
|
569
|
+
const result = applyTaskMutation({ tasks, nextId }, params.action, params as TaskMutationParams);
|
|
647
570
|
tasks = result.state.tasks;
|
|
648
571
|
nextId = result.state.nextId;
|
|
649
572
|
return {
|
|
@@ -673,9 +596,6 @@ export function registerTodoTool(pi: ExtensionAPI): void {
|
|
|
673
596
|
},
|
|
674
597
|
|
|
675
598
|
renderResult(result, _opts, theme, _context) {
|
|
676
|
-
if (result.isError) {
|
|
677
|
-
return new Text(theme.fg("error", "✗"), 0, 0);
|
|
678
|
-
}
|
|
679
599
|
const details = result.details as TaskDetails | undefined;
|
|
680
600
|
// Only create/update/delete advertise a status; list/get/clear render a
|
|
681
601
|
// plain ✓. This prevents list from rendering the last task's status as
|
|
@@ -689,9 +609,7 @@ export function registerTodoTool(pi: ExtensionAPI): void {
|
|
|
689
609
|
status = details.tasks[details.tasks.length - 1]?.status;
|
|
690
610
|
break;
|
|
691
611
|
case "update":
|
|
692
|
-
status =
|
|
693
|
-
params.status ??
|
|
694
|
-
details.tasks.find((t) => t.id === params.id)?.status;
|
|
612
|
+
status = params.status ?? details.tasks.find((t) => t.id === params.id)?.status;
|
|
695
613
|
break;
|
|
696
614
|
case "delete":
|
|
697
615
|
status = details.tasks.find((t) => t.id === params.id)?.status;
|
|
@@ -703,11 +621,7 @@ export function registerTodoTool(pi: ExtensionAPI): void {
|
|
|
703
621
|
}
|
|
704
622
|
}
|
|
705
623
|
if (status) {
|
|
706
|
-
return new Text(
|
|
707
|
-
theme.fg(STATUS_COLOR[status], `${STATUS_GLYPH[status]} ${formatStatus(status)}`),
|
|
708
|
-
0,
|
|
709
|
-
0,
|
|
710
|
-
);
|
|
624
|
+
return new Text(theme.fg(STATUS_COLOR[status], `${STATUS_GLYPH[status]} ${formatStatus(status)}`), 0, 0);
|
|
711
625
|
}
|
|
712
626
|
return new Text(theme.fg("success", "✓"), 0, 0);
|
|
713
627
|
},
|
|
@@ -750,13 +664,8 @@ export function registerTodosCommand(pi: ExtensionAPI): void {
|
|
|
750
664
|
const lines: string[] = [header.join(" · ")];
|
|
751
665
|
|
|
752
666
|
const renderTask = (t: Task, glyph: string): string => {
|
|
753
|
-
const form =
|
|
754
|
-
|
|
755
|
-
? ` (${t.activeForm})`
|
|
756
|
-
: "";
|
|
757
|
-
const block = t.blockedBy?.length
|
|
758
|
-
? ` ⛓ ${t.blockedBy.map((id) => `#${id}`).join(",")}`
|
|
759
|
-
: "";
|
|
667
|
+
const form = t.status === "in_progress" && t.activeForm ? ` (${t.activeForm})` : "";
|
|
668
|
+
const block = t.blockedBy?.length ? ` ⛓ ${t.blockedBy.map((id) => `#${id}`).join(",")}` : "";
|
|
760
669
|
return ` ${glyph} #${t.id} ${t.subject}${form}${block}`;
|
|
761
670
|
};
|
|
762
671
|
|