@juicesharp/rpiv-todo 2.13.10 → 2.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/configuration.md +1 -1
- package/docs/tool-schema.md +34 -10
- package/package.json +3 -2
- package/state/state-reducer.ts +83 -21
- package/todo.ts +5 -1
- package/tool/normalize-params.ts +43 -0
- package/tool/response-envelope.ts +8 -4
- package/tool/types.ts +45 -1
- package/view/format.ts +2 -0
package/docs/configuration.md
CHANGED
|
@@ -87,7 +87,7 @@ Examples: `alt+o`, `ctrl+shift+t`, `super+alt+f5`.
|
|
|
87
87
|
|
|
88
88
|
`guidance.promptSnippet` (string) and `guidance.promptGuidelines` (array of
|
|
89
89
|
strings) replace the prompt copy the `todo` tool advertises to the model. Both
|
|
90
|
-
are absent by default, in which case the built-in snippet and the
|
|
90
|
+
are absent by default, in which case the built-in snippet and the nine built-in
|
|
91
91
|
guideline bullets are used.
|
|
92
92
|
|
|
93
93
|
- `promptSnippet` must be a non-empty string; an empty string or a wrong type
|
package/docs/tool-schema.md
CHANGED
|
@@ -8,7 +8,7 @@ for the `todo` tool registered by
|
|
|
8
8
|
|
|
9
9
|
| Action | Required params | What it does |
|
|
10
10
|
| --- | --- | --- |
|
|
11
|
-
| `create` | `subject` | Adds
|
|
11
|
+
| `create` | `subject` or `tasks[]` (one-of) | Adds one task, or several independent tasks, in `pending`. |
|
|
12
12
|
| `update` | `id` + at least one mutable field | Changes status, fields, or dependencies. |
|
|
13
13
|
| `list` | — | Returns all tasks, optionally filtered by `status`. |
|
|
14
14
|
| `get` | `id` | Returns one task with its `blockedBy` and reverse `blocks` edges. |
|
|
@@ -21,9 +21,17 @@ for the `todo` tool registered by
|
|
|
21
21
|
todo({
|
|
22
22
|
action: "create" | "update" | "list" | "get" | "delete" | "clear",
|
|
23
23
|
|
|
24
|
-
// create-only
|
|
25
|
-
subject?: string, // required for create
|
|
26
|
-
blockedBy?: number[], // initial dependency ids
|
|
24
|
+
// create-only (one-of: subject or tasks[])
|
|
25
|
+
subject?: string, // required for single create
|
|
26
|
+
blockedBy?: number[], // initial dependency ids (single create)
|
|
27
|
+
tasks?: Array<{ // batch create; independent items only
|
|
28
|
+
subject: string,
|
|
29
|
+
description?: string,
|
|
30
|
+
activeForm?: string,
|
|
31
|
+
blockedBy?: number[], // existing ids only; no sibling refs
|
|
32
|
+
owner?: string,
|
|
33
|
+
metadata?: Record<string, unknown>,
|
|
34
|
+
}>,
|
|
27
35
|
|
|
28
36
|
// create + update
|
|
29
37
|
description?: string, // long-form detail
|
|
@@ -46,6 +54,15 @@ todo({
|
|
|
46
54
|
})
|
|
47
55
|
```
|
|
48
56
|
|
|
57
|
+
`create` takes either `subject` (one task) or `tasks[]` (several independent
|
|
58
|
+
tasks). Passing both is rejected, even with a blank `subject`. Each item carries
|
|
59
|
+
its own `description`, `activeForm`, `blockedBy`, `owner` and `metadata`; the same
|
|
60
|
+
fields at the top level of a batch are rejected rather than dropped. The batch is validated first and committed
|
|
61
|
+
together: one bad item fails the whole call and leaves the list unchanged.
|
|
62
|
+
Items in `tasks[]` cannot `blockedBy` each other; those ids do not exist until
|
|
63
|
+
the call commits. Create the prerequisite first, then the dependent with
|
|
64
|
+
`blockedBy`. `blockedBy` on a batch item may name a task that already exists.
|
|
65
|
+
|
|
49
66
|
`update` merges `metadata` key by key into the existing record; passing `null`
|
|
50
67
|
for a key removes it, and emptying the record drops the field entirely.
|
|
51
68
|
`addBlockedBy` and `removeBlockedBy` are additive — do not resend the whole
|
|
@@ -123,6 +140,7 @@ fall back to the last `todo` tool result's `details`. Either way, tasks survive
|
|
|
123
140
|
| Situation | `content[0].text` |
|
|
124
141
|
| --- | --- |
|
|
125
142
|
| Created | `Created #3: Write the parser (pending)` |
|
|
143
|
+
| Created a batch | one `Created #N: … (pending)` line per task, joined by newlines |
|
|
126
144
|
| Updated with a status change | `Updated #3 (pending → in_progress)` |
|
|
127
145
|
| Updated without a status change | `Updated #3` |
|
|
128
146
|
| Update that changed nothing | `No change: #3 already matches the requested values (status: in_progress)` |
|
|
@@ -139,9 +157,14 @@ that it was a no-op instead of a fresh `Updated #N`.
|
|
|
139
157
|
|
|
140
158
|
| Message | Cause |
|
|
141
159
|
| --- | --- |
|
|
142
|
-
| `subject required for create` | `create` without a non-blank `subject`. |
|
|
160
|
+
| `subject required for create` | `create` without a non-blank `subject` and without `tasks[]`. |
|
|
161
|
+
| `create requires subject or tasks[], not both` | `create` with both `subject` and `tasks[]`. |
|
|
162
|
+
| `tasks[] must be non-empty` | `create` with `tasks: []`. |
|
|
163
|
+
| `create with tasks[] takes <fields> on each item, not at the top level` | `create` with `tasks[]` and a top-level `description`, `activeForm`, `blockedBy`, `owner`, or `metadata`. |
|
|
164
|
+
| `tasks[N]: subject required for create` | A batch item with a blank or missing subject. |
|
|
143
165
|
| `blockedBy: #N not found` | `create` naming an unknown dependency. |
|
|
144
166
|
| `blockedBy: #N is deleted` | `create` naming a tombstoned dependency. |
|
|
167
|
+
| `blockedBy: #N is another item in this batch; create the prerequisite first, then the dependent with blockedBy` | A `tasks[]` item naming a sibling that this call would assign. |
|
|
145
168
|
| `id required for update` / `get` / `delete` | `id` omitted. |
|
|
146
169
|
| `#N not found` | No task with that id. |
|
|
147
170
|
| `update requires at least one mutable field: subject, description, activeForm, status, owner, metadata, addBlockedBy, or removeBlockedBy` | `update` with only an `id`. |
|
|
@@ -156,9 +179,10 @@ carries the bare message. Task state is unchanged.
|
|
|
156
179
|
|
|
157
180
|
## Prompt guidance
|
|
158
181
|
|
|
159
|
-
The tool ships a `promptSnippet` and
|
|
160
|
-
model when to open a list, to
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
task's status. Both are
|
|
182
|
+
The tool ships a `promptSnippet` and nine `promptGuidelines` bullets telling the
|
|
183
|
+
model when to open a list, to create independent tasks in one `tasks[]` call,
|
|
184
|
+
to keep exactly one task `in_progress`, to mark work completed immediately
|
|
185
|
+
rather than in batches, never to complete a task with failing tests, and the
|
|
186
|
+
literal `update {id, status}` call shape for changing a task's status. Both are
|
|
187
|
+
overridable — see
|
|
164
188
|
[configuration.md](./configuration.md#guidance).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juicesharp/rpiv-todo",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.14.0",
|
|
4
4
|
"description": "Pi extension. A todo list for the model, rendered as a live overlay that survives /reload and conversation compaction.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
"state/state.ts",
|
|
47
47
|
"state/store.ts",
|
|
48
48
|
"state/task-graph.ts",
|
|
49
|
+
"tool/normalize-params.ts",
|
|
49
50
|
"tool/response-envelope.ts",
|
|
50
51
|
"tool/sanitize.ts",
|
|
51
52
|
"tool/types.ts",
|
|
@@ -70,6 +71,6 @@
|
|
|
70
71
|
}
|
|
71
72
|
},
|
|
72
73
|
"dependencies": {
|
|
73
|
-
"@juicesharp/rpiv-config": "^2.
|
|
74
|
+
"@juicesharp/rpiv-config": "^2.14.0"
|
|
74
75
|
}
|
|
75
76
|
}
|
package/state/state-reducer.ts
CHANGED
|
@@ -13,7 +13,7 @@ import { detectCycle } from "./task-graph.ts";
|
|
|
13
13
|
* `op.kind === "error"` without a side-channel boolean.
|
|
14
14
|
*/
|
|
15
15
|
export type Op =
|
|
16
|
-
| { kind: "create";
|
|
16
|
+
| { kind: "create"; taskIds: number[] }
|
|
17
17
|
| { kind: "update"; id: number; fromStatus: TaskStatus; toStatus: TaskStatus; changed: boolean }
|
|
18
18
|
| { kind: "delete"; id: number; subject: string }
|
|
19
19
|
| { kind: "list"; statusFilter?: TaskStatus; includeDeleted: boolean }
|
|
@@ -51,6 +51,45 @@ function errorResult(state: TaskState, message: string): ApplyResult {
|
|
|
51
51
|
return { state, op: { kind: "error", message } };
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
/** Per-task create fields: on a batch they belong to each `tasks[]` item. */
|
|
55
|
+
const BATCH_ITEM_FIELDS = ["description", "activeForm", "blockedBy", "owner", "metadata"] as const;
|
|
56
|
+
|
|
57
|
+
function asCreateItem(value: unknown): TaskMutationParams | undefined {
|
|
58
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return undefined;
|
|
59
|
+
return value as TaskMutationParams;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function buildCreatedTask(id: number, spec: TaskMutationParams, subject: string): Task {
|
|
63
|
+
const newTask: Task = {
|
|
64
|
+
id,
|
|
65
|
+
subject,
|
|
66
|
+
status: "pending",
|
|
67
|
+
};
|
|
68
|
+
if (spec.description) newTask.description = spec.description;
|
|
69
|
+
if (spec.activeForm) newTask.activeForm = spec.activeForm;
|
|
70
|
+
if (spec.blockedBy?.length) newTask.blockedBy = [...spec.blockedBy];
|
|
71
|
+
if (spec.owner) newTask.owner = spec.owner;
|
|
72
|
+
if (spec.metadata) newTask.metadata = { ...spec.metadata };
|
|
73
|
+
return newTask;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function validateCreateBlockedBy(
|
|
77
|
+
state: TaskState,
|
|
78
|
+
blockedBy: number[] | undefined,
|
|
79
|
+
siblingIds: ReadonlySet<number>,
|
|
80
|
+
): string | undefined {
|
|
81
|
+
if (!blockedBy?.length) return undefined;
|
|
82
|
+
for (const dep of blockedBy) {
|
|
83
|
+
if (siblingIds.has(dep)) {
|
|
84
|
+
return `blockedBy: #${dep} is another item in this batch; create the prerequisite first, then the dependent with blockedBy`;
|
|
85
|
+
}
|
|
86
|
+
const depTask = state.tasks.find((t) => t.id === dep);
|
|
87
|
+
if (!depTask) return `blockedBy: #${dep} not found`;
|
|
88
|
+
if (depTask.status === "deleted") return `blockedBy: #${dep} is deleted`;
|
|
89
|
+
}
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
|
|
54
93
|
function sameNumberList(a: number[] | undefined, b: number[] | undefined): boolean {
|
|
55
94
|
const x = a ?? [];
|
|
56
95
|
const y = b ?? [];
|
|
@@ -97,31 +136,54 @@ function taskChanged(before: Task, after: Task): boolean {
|
|
|
97
136
|
export function applyTaskMutation(state: TaskState, action: TaskAction, params: TaskMutationParams): ApplyResult {
|
|
98
137
|
switch (action) {
|
|
99
138
|
case "create": {
|
|
100
|
-
|
|
101
|
-
|
|
139
|
+
const batch = params.tasks;
|
|
140
|
+
|
|
141
|
+
if (Array.isArray(batch) && params.subject !== undefined) {
|
|
142
|
+
return errorResult(state, "create requires subject or tasks[], not both");
|
|
102
143
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
144
|
+
|
|
145
|
+
if (Array.isArray(batch)) {
|
|
146
|
+
// Each item carries its own fields; a top-level one would apply to no item.
|
|
147
|
+
const topLevel = BATCH_ITEM_FIELDS.filter((field) => params[field] !== undefined);
|
|
148
|
+
if (topLevel.length) {
|
|
149
|
+
return errorResult(
|
|
150
|
+
state,
|
|
151
|
+
`create with tasks[] takes ${topLevel.join(", ")} on each item, not at the top level`,
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
if (batch.length === 0) {
|
|
155
|
+
return errorResult(state, "tasks[] must be non-empty");
|
|
156
|
+
}
|
|
157
|
+
const items: Array<{ spec: TaskMutationParams; subject: string }> = [];
|
|
158
|
+
for (let i = 0; i < batch.length; i++) {
|
|
159
|
+
const spec = asCreateItem(batch[i]);
|
|
160
|
+
const subject = spec?.subject;
|
|
161
|
+
if (!spec || !subject?.trim()) {
|
|
162
|
+
return errorResult(state, `tasks[${i}]: subject required for create`);
|
|
163
|
+
}
|
|
164
|
+
items.push({ spec, subject });
|
|
108
165
|
}
|
|
166
|
+
const siblingIds = new Set(items.map((_, i) => state.nextId + i));
|
|
167
|
+
for (const item of items) {
|
|
168
|
+
const blockedError = validateCreateBlockedBy(state, item.spec.blockedBy, siblingIds);
|
|
169
|
+
if (blockedError) return errorResult(state, blockedError);
|
|
170
|
+
}
|
|
171
|
+
const created = items.map((item, i) => buildCreatedTask(state.nextId + i, item.spec, item.subject));
|
|
172
|
+
return {
|
|
173
|
+
state: { tasks: [...state.tasks, ...created], nextId: state.nextId + created.length },
|
|
174
|
+
op: { kind: "create", taskIds: created.map((t) => t.id) },
|
|
175
|
+
};
|
|
109
176
|
}
|
|
110
|
-
const newTask: Task = {
|
|
111
|
-
id: state.nextId,
|
|
112
|
-
subject: params.subject,
|
|
113
|
-
status: "pending",
|
|
114
|
-
};
|
|
115
|
-
if (params.description) newTask.description = params.description;
|
|
116
|
-
if (params.activeForm) newTask.activeForm = params.activeForm;
|
|
117
|
-
if (params.blockedBy?.length) newTask.blockedBy = [...params.blockedBy];
|
|
118
|
-
if (params.owner) newTask.owner = params.owner;
|
|
119
|
-
if (params.metadata) newTask.metadata = { ...params.metadata };
|
|
120
177
|
|
|
121
|
-
|
|
178
|
+
if (!params.subject?.trim()) {
|
|
179
|
+
return errorResult(state, "subject required for create");
|
|
180
|
+
}
|
|
181
|
+
const blockedError = validateCreateBlockedBy(state, params.blockedBy, new Set());
|
|
182
|
+
if (blockedError) return errorResult(state, blockedError);
|
|
183
|
+
const newTask = buildCreatedTask(state.nextId, params, params.subject);
|
|
122
184
|
return {
|
|
123
|
-
state: { tasks:
|
|
124
|
-
op: { kind: "create",
|
|
185
|
+
state: { tasks: [...state.tasks, newTask], nextId: state.nextId + 1 },
|
|
186
|
+
op: { kind: "create", taskIds: [newTask.id] },
|
|
125
187
|
};
|
|
126
188
|
}
|
|
127
189
|
|
package/todo.ts
CHANGED
|
@@ -18,6 +18,7 @@ import { formatStatusLabel, t } from "./state/i18n-bridge.ts";
|
|
|
18
18
|
import { selectTasksByStatus, selectTodoCounts, selectVisibleTasks } from "./state/selectors.ts";
|
|
19
19
|
import { applyTaskMutation, changesState } from "./state/state-reducer.ts";
|
|
20
20
|
import { commitState, getRenderState, getState, sid } from "./state/store.ts";
|
|
21
|
+
import { prepareTodoArguments } from "./tool/normalize-params.ts";
|
|
21
22
|
import { buildToolResult } from "./tool/response-envelope.ts";
|
|
22
23
|
import {
|
|
23
24
|
COMMAND_NAME,
|
|
@@ -61,6 +62,7 @@ export const DEFAULT_PROMPT_GUIDELINES: string[] = [
|
|
|
61
62
|
"Task status is a 4-state machine: pending → in_progress → completed, plus deleted as a tombstone. Pass activeForm (present-continuous label, e.g. 'researching existing tool') when marking in_progress.",
|
|
62
63
|
'To change a task\'s status, call update with the task id and the target status, e.g. {"action":"update","id":3,"status":"completed"} or {"action":"update","id":3,"status":"in_progress","activeForm":"writing tests"}. status is the field that changes the task; an update without a mutable field (status or another) is rejected.',
|
|
63
64
|
"Use blockedBy to express dependencies (A is blocked by B). On create, pass blockedBy as the initial set. On update, use addBlockedBy / removeBlockedBy (additive merge — do not resend the full array). Cycles are rejected.",
|
|
65
|
+
"To create several independent tasks at once, pass create with tasks: [{subject}, ...]. Do not also pass subject. tasks[] cannot blockedBy each other (ids do not exist until the call commits); create the prerequisite first, then the dependent with blockedBy. Dependency chains stay single-create.",
|
|
64
66
|
"list hides tombstoned (deleted) tasks by default; pass includeDeleted:true to see them. Pass status to filter by a single status.",
|
|
65
67
|
"Subject must be short and imperative (e.g. 'Research existing tool'); description is for long-form detail. activeForm is a present-continuous label shown while in_progress.",
|
|
66
68
|
];
|
|
@@ -71,10 +73,12 @@ export function registerTodoTool(pi: ExtensionAPI): void {
|
|
|
71
73
|
name: TOOL_NAME,
|
|
72
74
|
label: TOOL_LABEL,
|
|
73
75
|
description:
|
|
74
|
-
"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.",
|
|
76
|
+
"Manage a task list for tracking multi-step progress. Actions: create (new task, or several independent tasks at once via tasks[]), 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.",
|
|
75
77
|
promptSnippet: guidance.promptSnippet ?? DEFAULT_PROMPT_SNIPPET,
|
|
76
78
|
promptGuidelines: guidance.promptGuidelines ?? DEFAULT_PROMPT_GUIDELINES,
|
|
77
79
|
parameters: TodoParamsSchema,
|
|
80
|
+
// Undo a double-encoded tasks[] before Pi validates it (#244 shape).
|
|
81
|
+
prepareArguments: prepareTodoArguments,
|
|
78
82
|
|
|
79
83
|
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
|
|
80
84
|
const result = applyTaskMutation(getState(sid(ctx)), params.action, params as TaskMutationParams);
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { TodoParams } from "./types.ts";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Pi's `prepareArguments` hook: undo a double-encoded `tasks[]` before schema
|
|
5
|
+
* validation. Some tool-call parsers (vLLM/LiteLLM-served GLM/Qwen-class models)
|
|
6
|
+
* emit nested structures as JSON strings — `tasks` itself, or its items — the same
|
|
7
|
+
* shape rpiv-ask-user-question decodes for `questions` (#244). Only a string at an
|
|
8
|
+
* array/object position is decoded, and only when it parses to the expected shape;
|
|
9
|
+
* anything else is passed through untouched so validation still reports the real
|
|
10
|
+
* problem. Well-formed arguments are returned as-is.
|
|
11
|
+
*/
|
|
12
|
+
export function prepareTodoArguments(args: unknown): TodoParams {
|
|
13
|
+
if (!isRecord(args) || args.tasks === undefined) return args as TodoParams;
|
|
14
|
+
const tasks = decodeArray(args.tasks);
|
|
15
|
+
if (!Array.isArray(tasks)) return args as TodoParams;
|
|
16
|
+
const decoded = tasks.map(decodeObject);
|
|
17
|
+
if (tasks === args.tasks && decoded.every((item, i) => item === tasks[i])) return args as TodoParams;
|
|
18
|
+
return { ...args, tasks: decoded } as unknown as TodoParams;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
22
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** A JSON string holding an array → that array; anything else unchanged. */
|
|
26
|
+
function decodeArray(value: unknown): unknown {
|
|
27
|
+
const parsed = typeof value === "string" ? parseJson(value) : value;
|
|
28
|
+
return Array.isArray(parsed) ? parsed : value;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** A JSON string holding an object → that object; anything else unchanged. */
|
|
32
|
+
function decodeObject(value: unknown): unknown {
|
|
33
|
+
const parsed = typeof value === "string" ? parseJson(value) : value;
|
|
34
|
+
return isRecord(parsed) ? parsed : value;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function parseJson(text: string): unknown {
|
|
38
|
+
try {
|
|
39
|
+
return JSON.parse(text);
|
|
40
|
+
} catch {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -44,10 +44,14 @@ function formatGetLines(task: Task, state: TaskState): string {
|
|
|
44
44
|
export function formatContent(op: Op, state: TaskState): string {
|
|
45
45
|
switch (op.kind) {
|
|
46
46
|
case "create": {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
// Defensive — each `op.taskIds` entry resolves on the success path.
|
|
48
|
+
return op.taskIds
|
|
49
|
+
.map((id) => {
|
|
50
|
+
const created = state.tasks.find((x) => x.id === id);
|
|
51
|
+
if (!created) return `Created #${id}`;
|
|
52
|
+
return `Created #${created.id}: ${sanitizeTerminalText(created.subject)} (pending)`;
|
|
53
|
+
})
|
|
54
|
+
.join("\n");
|
|
51
55
|
}
|
|
52
56
|
case "update": {
|
|
53
57
|
if (!op.changed) {
|
package/tool/types.ts
CHANGED
|
@@ -66,6 +66,16 @@ export interface TaskDetails {
|
|
|
66
66
|
* signature (`[key: string]: unknown`) lets the runtime pass through TypeBox
|
|
67
67
|
* `Static<typeof TodoParamsSchema>` without `as` casts.
|
|
68
68
|
*/
|
|
69
|
+
/** One item in a batch `create` `tasks[]` payload. Same create-shaped fields as a single create, minus nested `tasks`. */
|
|
70
|
+
export interface CreateTaskInput {
|
|
71
|
+
subject: string;
|
|
72
|
+
description?: string;
|
|
73
|
+
activeForm?: string;
|
|
74
|
+
blockedBy?: number[];
|
|
75
|
+
owner?: string;
|
|
76
|
+
metadata?: Record<string, unknown>;
|
|
77
|
+
}
|
|
78
|
+
|
|
69
79
|
export interface TaskMutationParams {
|
|
70
80
|
[key: string]: unknown;
|
|
71
81
|
subject?: string;
|
|
@@ -79,6 +89,8 @@ export interface TaskMutationParams {
|
|
|
79
89
|
metadata?: Record<string, unknown>;
|
|
80
90
|
id?: number;
|
|
81
91
|
includeDeleted?: boolean;
|
|
92
|
+
/** Batch create items. One-of with `subject` on `create`. */
|
|
93
|
+
tasks?: CreateTaskInput[];
|
|
82
94
|
}
|
|
83
95
|
|
|
84
96
|
// ---------------------------------------------------------------------------
|
|
@@ -86,9 +98,35 @@ export interface TaskMutationParams {
|
|
|
86
98
|
// copy. Field order and wording are pinned by registration tests.
|
|
87
99
|
// ---------------------------------------------------------------------------
|
|
88
100
|
|
|
101
|
+
const CreateTaskInputSchema = Type.Object({
|
|
102
|
+
subject: Type.String({ description: "Task subject line" }),
|
|
103
|
+
description: Type.Optional(Type.String({ description: "Long-form task description" })),
|
|
104
|
+
activeForm: Type.Optional(
|
|
105
|
+
Type.String({
|
|
106
|
+
description: "Present-continuous spinner label shown while status is in_progress (e.g. 'writing tests')",
|
|
107
|
+
}),
|
|
108
|
+
),
|
|
109
|
+
blockedBy: Type.Optional(
|
|
110
|
+
Type.Array(Type.Number(), {
|
|
111
|
+
description:
|
|
112
|
+
"Existing task ids this item waits on. Cannot name another item in this same batch; create the prerequisite first, then the dependent with blockedBy.",
|
|
113
|
+
}),
|
|
114
|
+
),
|
|
115
|
+
owner: Type.Optional(Type.String({ description: "Agent/owner assigned to this task" })),
|
|
116
|
+
metadata: Type.Optional(
|
|
117
|
+
Type.Record(Type.String(), Type.Unknown(), {
|
|
118
|
+
description: "Arbitrary metadata",
|
|
119
|
+
}),
|
|
120
|
+
),
|
|
121
|
+
});
|
|
122
|
+
|
|
89
123
|
export const TodoParamsSchema = Type.Object({
|
|
90
124
|
action: StringEnum(["create", "update", "list", "get", "delete", "clear"] as const),
|
|
91
|
-
subject: Type.Optional(
|
|
125
|
+
subject: Type.Optional(
|
|
126
|
+
Type.String({
|
|
127
|
+
description: "Task subject line (required for create unless tasks[] is set)",
|
|
128
|
+
}),
|
|
129
|
+
),
|
|
92
130
|
description: Type.Optional(Type.String({ description: "Long-form task description" })),
|
|
93
131
|
activeForm: Type.Optional(
|
|
94
132
|
Type.String({
|
|
@@ -132,6 +170,12 @@ export const TodoParamsSchema = Type.Object({
|
|
|
132
170
|
description: "If true, list action returns deleted (tombstoned) tasks as well. Default: false.",
|
|
133
171
|
}),
|
|
134
172
|
),
|
|
173
|
+
tasks: Type.Optional(
|
|
174
|
+
Type.Array(CreateTaskInputSchema, {
|
|
175
|
+
description:
|
|
176
|
+
"Batch create: independent tasks in one call, one-of with subject. The whole list is validated then committed together. Items cannot blockedBy each other; create the prerequisite first, then the dependent with blockedBy.",
|
|
177
|
+
}),
|
|
178
|
+
),
|
|
135
179
|
});
|
|
136
180
|
|
|
137
181
|
export type TodoParams = Static<typeof TodoParamsSchema>;
|
package/view/format.ts
CHANGED
|
@@ -118,6 +118,8 @@ export function renderTodoCall(
|
|
|
118
118
|
|
|
119
119
|
if (args.action === "create" && args.subject) {
|
|
120
120
|
text += ` ${theme.fg("dim", sanitizeTerminalText(args.subject))}`;
|
|
121
|
+
} else if (args.action === "create" && Array.isArray(args.tasks)) {
|
|
122
|
+
text += ` ${theme.fg("dim", `${args.tasks.length} tasks`)}`;
|
|
121
123
|
} else if (
|
|
122
124
|
(args.action === "update" || args.action === "get" || args.action === "delete") &&
|
|
123
125
|
args.id !== undefined
|