@wrongstack/tools 0.313.0 → 0.313.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/dist/audit.js +10 -4055
- package/dist/bash.js +9 -2308
- package/dist/batch-tool-use.js +2 -187
- package/dist/browser/index.js +25 -1339
- package/dist/builtin.js +69 -33949
- package/dist/chunk-2CTB3UK5.js +197 -0
- package/dist/chunk-2ME7ZWDD.js +1272 -0
- package/dist/chunk-2TFQDEPU.js +113 -0
- package/dist/chunk-2ZCJNKFE.js +315 -0
- package/dist/chunk-3PVYQFRQ.js +472 -0
- package/dist/chunk-3QMQBO5Z.js +89 -0
- package/dist/chunk-42AKKX7O.js +385 -0
- package/dist/chunk-42SKEETB.js +113 -0
- package/dist/chunk-4BHUSMNL.js +104 -0
- package/dist/chunk-4I4LWFOO.js +431 -0
- package/dist/chunk-553IQUMO.js +478 -0
- package/dist/chunk-55KF77OK.js +1944 -0
- package/dist/chunk-6HLZK37X.js +359 -0
- package/dist/chunk-6RNIFLG4.js +305 -0
- package/dist/chunk-A6BRWIXN.js +317 -0
- package/dist/chunk-AHHDWNXC.js +200 -0
- package/dist/chunk-B2CIOKWP.js +899 -0
- package/dist/chunk-BTSFTGIL.js +7 -0
- package/dist/chunk-D33S4RQG.js +222 -0
- package/dist/chunk-DIJKHSUO.js +134 -0
- package/dist/chunk-DPL47QGS.js +3515 -0
- package/dist/chunk-EMRGN4KM.js +170 -0
- package/dist/chunk-FGOABE4Z.js +955 -0
- package/dist/chunk-FW65TP4G.js +520 -0
- package/dist/chunk-GOIZNNOA.js +221 -0
- package/dist/chunk-H5MJUAA6.js +295 -0
- package/dist/chunk-H5OHH6F4.js +223 -0
- package/dist/chunk-HC5RM4WY.js +199 -0
- package/dist/chunk-HEQFMLZ7.js +190 -0
- package/dist/chunk-HFXSNKCV.js +196 -0
- package/dist/chunk-HXSBQ2SE.js +1723 -0
- package/dist/chunk-ILESNGNM.js +163 -0
- package/dist/chunk-INF5CGAO.js +137 -0
- package/dist/chunk-IWDFZ6XR.js +337 -0
- package/dist/chunk-IXMNTNW5.js +238 -0
- package/dist/chunk-J4SRJKBW.js +428 -0
- package/dist/chunk-J5SKD6LN.js +235 -0
- package/dist/chunk-JRJJX3L5.js +424 -0
- package/dist/chunk-KXNDHMUB.js +366 -0
- package/dist/chunk-LIJQMYYX.js +59 -0
- package/dist/chunk-MAN26PZ5.js +260 -0
- package/dist/chunk-MKRQMLZA.js +474 -0
- package/dist/chunk-NBDZMMG2.js +169 -0
- package/dist/chunk-NHA6BEIH.js +101 -0
- package/dist/chunk-OA6YJIWL.js +4412 -0
- package/dist/chunk-OZC255IC.js +2830 -0
- package/dist/chunk-PUR6WU2B.js +154 -0
- package/dist/chunk-Q5JPPCZC.js +12 -0
- package/dist/chunk-QBV725YG.js +128 -0
- package/dist/chunk-QHVW4AAM.js +892 -0
- package/dist/chunk-QNJ7AQ4B.js +1000 -0
- package/dist/chunk-RGISBZBD.js +231 -0
- package/dist/chunk-RJZQWEMS.js +84 -0
- package/dist/chunk-RP2ZA47V.js +15 -0
- package/dist/chunk-RXISBFR5.js +315 -0
- package/dist/chunk-S5CCLZL3.js +99 -0
- package/dist/chunk-TVTCSBJF.js +122 -0
- package/dist/chunk-U4D5S3VQ.js +21 -0
- package/dist/chunk-U4VAATKP.js +193 -0
- package/dist/chunk-UKU2ZX4C.js +203 -0
- package/dist/chunk-UNSKG6DC.js +159 -0
- package/dist/chunk-URFKEIHM.js +1091 -0
- package/dist/chunk-UTV7YAW7.js +178 -0
- package/dist/chunk-V43EQ6VR.js +68 -0
- package/dist/chunk-VB3MJGCV.js +610 -0
- package/dist/chunk-WHIIIREL.js +223 -0
- package/dist/chunk-XMIFYKUT.js +1371 -0
- package/dist/chunk-YF2RSV34.js +54 -0
- package/dist/chunk-Z6DAKQ3U.js +1 -0
- package/dist/chunk-ZIGAZFWE.js +522 -0
- package/dist/circuit-breaker.js +3 -191
- package/dist/codebase-index/index.js +84 -13688
- package/dist/codebase-index/parser-worker-script.js +8 -3995
- package/dist/codebase-index/project-server.js +60 -8548
- package/dist/codebase-index/worker.js +20 -8416
- package/dist/design.js +2 -299
- package/dist/diff.js +4 -256
- package/dist/document.js +4 -222
- package/dist/e2e.js +5 -476
- package/dist/edit.js +14 -10200
- package/dist/exec.js +16 -3131
- package/dist/fetch.js +8 -398
- package/dist/format.js +10 -3750
- package/dist/generic-parser-VUXDIAOZ.js +13 -0
- package/dist/git.js +4 -380
- package/dist/glob.js +6 -280
- package/dist/go-parser-6CA77WZ4.js +469 -0
- package/dist/grep.js +7 -604
- package/dist/index.js +318 -35387
- package/dist/install.js +10 -4091
- package/dist/json-parser-7YMDJSBJ.js +213 -0
- package/dist/json.js +4 -665
- package/dist/kanban.js +3 -2096
- package/dist/languages/index.js +23 -4664
- package/dist/legacy-bridge-7UKZT46G.js +18 -0
- package/dist/lint.js +10 -3706
- package/dist/logs.js +4 -287
- package/dist/memory.js +6 -215
- package/dist/mode.js +3 -99
- package/dist/outdated.js +4 -5170
- package/dist/pack.js +65 -33897
- package/dist/parser-dispatch-VPOFDO2U.js +14 -0
- package/dist/patch.js +13 -9935
- package/dist/plan.js +5 -3286
- package/dist/process-registry.js +8 -651
- package/dist/ps-slash.js +12 -1439
- package/dist/py-parser-GPM5VYRG.js +16 -0
- package/dist/read.js +13 -9816
- package/dist/replace.js +15 -10014
- package/dist/rs-parser-WVQ4KYCX.js +81 -0
- package/dist/scaffold.js +4 -253
- package/dist/search.js +5 -585
- package/dist/session-kanban.js +30 -972
- package/dist/skill.js +2 -215
- package/dist/task.js +5 -3410
- package/dist/test.js +10 -3773
- package/dist/todo.js +4 -2891
- package/dist/tool-help.js +3 -123
- package/dist/tool-search.js +3 -79
- package/dist/tool-tier.js +68 -33984
- package/dist/tool-use.js +2 -93
- package/dist/tree-sitter-parser-YCILHGZD.js +17 -0
- package/dist/tree.js +4 -288
- package/dist/ts-parser-YH4ZMWMH.js +232 -0
- package/dist/typecheck.js +10 -3753
- package/dist/win32.js +6 -60
- package/dist/write.js +14 -9882
- package/dist/yaml-parser-GFAOKV53.js +157 -0
- package/package.json +5 -5
package/dist/task.js
CHANGED
|
@@ -1,3414 +1,9 @@
|
|
|
1
|
-
// src/task.ts
|
|
2
|
-
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
3
|
-
import { addPlanItem, formatPlan, mutatePlan as mutatePlan2, mutateTasks as mutateTasks2 } from "@wrongstack/core/storage";
|
|
4
|
-
import { computeTaskItemProgress, formatTaskList } from "@wrongstack/core/utils";
|
|
5
|
-
|
|
6
|
-
// src/session-kanban.ts
|
|
7
|
-
import { loadPlan, loadTasks } from "@wrongstack/core/storage";
|
|
8
|
-
import { deserializeTaskGraph } from "@wrongstack/core/tasking";
|
|
9
1
|
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
getKanbanOrchestrationSnapshot,
|
|
16
|
-
listBoards,
|
|
17
|
-
pruneSessionBoards,
|
|
18
|
-
removeBoard,
|
|
19
|
-
syncBoardFromTaskGraph,
|
|
20
|
-
touchKanbanPresence,
|
|
21
|
-
updateBoard
|
|
22
|
-
} from "@wrongstack/kanban";
|
|
23
|
-
|
|
24
|
-
// src/session-kanban-graph.ts
|
|
25
|
-
function todoListToSerializedGraph(todos, sessionId) {
|
|
26
|
-
const graphId = `todo:${sessionId}`;
|
|
27
|
-
const nodes = todos.map((todo, index) => ({
|
|
28
|
-
id: todo.id,
|
|
29
|
-
title: todo.content,
|
|
30
|
-
description: todo.activeForm ?? "",
|
|
31
|
-
type: "chore",
|
|
32
|
-
priority: "medium",
|
|
33
|
-
status: todo.status,
|
|
34
|
-
specRequirementId: `${graphId}:${todo.id}`,
|
|
35
|
-
createdAt: index,
|
|
36
|
-
updatedAt: index
|
|
37
|
-
}));
|
|
38
|
-
return {
|
|
39
|
-
id: graphId,
|
|
40
|
-
specId: graphId,
|
|
41
|
-
requiredRequirementIds: nodes.map((node) => node.specRequirementId),
|
|
42
|
-
title: "Session todos",
|
|
43
|
-
nodes,
|
|
44
|
-
edges: [],
|
|
45
|
-
rootNodes: nodes.map((node) => node.id),
|
|
46
|
-
createdAt: 0,
|
|
47
|
-
updatedAt: 0
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
function taskFileToSerializedGraph(tasks, sessionId) {
|
|
51
|
-
const graphId = `session:${sessionId}`;
|
|
52
|
-
const ids = new Set(tasks.map((task) => task.id));
|
|
53
|
-
const nodes = tasks.map((task, index) => ({
|
|
54
|
-
id: task.id,
|
|
55
|
-
title: task.title,
|
|
56
|
-
description: task.description ?? "",
|
|
57
|
-
type: task.type,
|
|
58
|
-
priority: task.priority,
|
|
59
|
-
status: task.status,
|
|
60
|
-
specRequirementId: `${graphId}:${task.id}`,
|
|
61
|
-
...task.assignee ? { assignee: task.assignee } : {},
|
|
62
|
-
...task.estimateHours !== void 0 ? { estimateHours: task.estimateHours } : {},
|
|
63
|
-
createdAt: index,
|
|
64
|
-
updatedAt: index
|
|
65
|
-
}));
|
|
66
|
-
const edges = tasks.flatMap(
|
|
67
|
-
(task) => (task.dependsOn ?? []).filter((dependency) => ids.has(dependency)).map((dependency) => ({
|
|
68
|
-
id: `${dependency}->${task.id}`,
|
|
69
|
-
from: dependency,
|
|
70
|
-
to: task.id,
|
|
71
|
-
type: "depends_on"
|
|
72
|
-
}))
|
|
73
|
-
);
|
|
74
|
-
const hasIncoming = new Set(edges.map((edge) => edge.to));
|
|
75
|
-
const rootNodes = nodes.filter((node) => !hasIncoming.has(node.id)).map((node) => node.id);
|
|
76
|
-
return {
|
|
77
|
-
// Keep the historical graph id so existing mirrored task cards are reused.
|
|
78
|
-
id: graphId,
|
|
79
|
-
specId: graphId,
|
|
80
|
-
requiredRequirementIds: nodes.map((node) => node.specRequirementId),
|
|
81
|
-
title: "Session tasks",
|
|
82
|
-
nodes,
|
|
83
|
-
edges,
|
|
84
|
-
rootNodes: rootNodes.length ? rootNodes : nodes[0] ? [nodes[0].id] : [],
|
|
85
|
-
createdAt: 0,
|
|
86
|
-
updatedAt: 0
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// src/session-kanban-sync.ts
|
|
91
|
-
import { getSharedProjectMailbox } from "@wrongstack/core/coordination";
|
|
92
|
-
import { mutatePlan, mutateTasks } from "@wrongstack/core/storage";
|
|
93
|
-
import { formatTodosForModel, resolveWstackPaths } from "@wrongstack/core/utils";
|
|
94
|
-
import {
|
|
95
|
-
getDependencyReadinessIssues
|
|
96
|
-
} from "@wrongstack/kanban";
|
|
97
|
-
function sourceStatus(task) {
|
|
98
|
-
if (task.status === "completed") return "completed";
|
|
99
|
-
if (task.status === "in_progress") return "in_progress";
|
|
100
|
-
if (task.status === "review") return "review";
|
|
101
|
-
if (task.status === "blocked") return "blocked";
|
|
102
|
-
if (task.status === "failed") return "failed";
|
|
103
|
-
return "pending";
|
|
104
|
-
}
|
|
105
|
-
function todoStatus(task) {
|
|
106
|
-
const status = sourceStatus(task);
|
|
107
|
-
if (status === "completed") return "completed";
|
|
108
|
-
if (status === "review" && task.assignment?.status === "completed") return "completed";
|
|
109
|
-
if (status === "in_progress" || status === "review") return "in_progress";
|
|
110
|
-
return "pending";
|
|
111
|
-
}
|
|
112
|
-
function sessionTodoFromTask(task, board) {
|
|
113
|
-
const blockedBy = board ? blockingTitles(board, task) : [];
|
|
114
|
-
return {
|
|
115
|
-
id: task.origin?.taskId ?? task.id,
|
|
116
|
-
content: task.title,
|
|
117
|
-
status: todoStatus(task),
|
|
118
|
-
...task.description ? { activeForm: task.description } : {},
|
|
119
|
-
...blockedBy.length ? { blockedBy } : {}
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
function managedTodoFromTask(task, board) {
|
|
123
|
-
return {
|
|
124
|
-
...sessionTodoFromTask(task, board),
|
|
125
|
-
kanbanBoardId: board.id,
|
|
126
|
-
kanbanTaskId: task.id
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
function blockingTitles(board, task) {
|
|
130
|
-
return getDependencyReadinessIssues(board, task).map((issue) => {
|
|
131
|
-
const dependency = board.tasks.find((candidate) => candidate.id === issue.dependencyId);
|
|
132
|
-
if (!dependency) return `${issue.dependencyId} (missing)`;
|
|
133
|
-
return dependency.title;
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
var PRIORITY_ORDER = {
|
|
137
|
-
critical: 0,
|
|
138
|
-
high: 1,
|
|
139
|
-
medium: 2,
|
|
140
|
-
low: 3
|
|
141
|
-
};
|
|
142
|
-
function orderTasksForTodos(board, tasks) {
|
|
143
|
-
const columnOrder = new Map(board.columns.map((column) => [column.id, column.order]));
|
|
144
|
-
const baseline = [...tasks].sort(
|
|
145
|
-
(left, right) => (columnOrder.get(left.columnId) ?? 0) - (columnOrder.get(right.columnId) ?? 0) || (PRIORITY_ORDER[left.priority] ?? 2) - (PRIORITY_ORDER[right.priority] ?? 2) || left.order - right.order || left.createdAt.localeCompare(right.createdAt) || left.id.localeCompare(right.id)
|
|
146
|
-
);
|
|
147
|
-
const included = new Set(baseline.map((task) => task.id));
|
|
148
|
-
const remaining = new Map(baseline.map((task) => [task.id, task]));
|
|
149
|
-
const emitted = [];
|
|
150
|
-
const done = /* @__PURE__ */ new Set();
|
|
151
|
-
while (remaining.size > 0) {
|
|
152
|
-
const ready = baseline.filter(
|
|
153
|
-
(task) => remaining.has(task.id) && (task.dependsOn ?? []).every(
|
|
154
|
-
(dependencyId) => !included.has(dependencyId) || done.has(dependencyId)
|
|
155
|
-
)
|
|
156
|
-
);
|
|
157
|
-
if (ready.length === 0) break;
|
|
158
|
-
for (const task of ready) {
|
|
159
|
-
remaining.delete(task.id);
|
|
160
|
-
done.add(task.id);
|
|
161
|
-
emitted.push(task);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
for (const task of baseline) if (remaining.has(task.id)) emitted.push(task);
|
|
165
|
-
return emitted;
|
|
166
|
-
}
|
|
167
|
-
function sameTodos(left, right) {
|
|
168
|
-
return left.length === right.length && left.every((todo, index) => {
|
|
169
|
-
const candidate = right[index];
|
|
170
|
-
return candidate?.id === todo.id && candidate.content === todo.content && candidate.status === todo.status && candidate.activeForm === todo.activeForm && candidate.promotedFromPlan === todo.promotedFromPlan && candidate.promotedFromTask === todo.promotedFromTask && candidate.kanbanBoardId === todo.kanbanBoardId && candidate.kanbanTaskId === todo.kanbanTaskId && (candidate.blockedBy ?? []).join("\0") === (todo.blockedBy ?? []).join("\0");
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
function broadcastTodoUpdate(context, todos) {
|
|
174
|
-
const sessionId = context.session?.id ?? "";
|
|
175
|
-
if (!context.agentId || !sessionId) return;
|
|
176
|
-
const statusCounts = { pending: 0, inProgress: 0, completed: 0 };
|
|
177
|
-
for (const todo of todos) {
|
|
178
|
-
if (todo.status === "completed") statusCounts.completed++;
|
|
179
|
-
else if (todo.status === "in_progress") statusCounts.inProgress++;
|
|
180
|
-
else statusCounts.pending++;
|
|
181
|
-
}
|
|
182
|
-
const projectDir = resolveWstackPaths({ projectRoot: context.projectRoot }).projectDir;
|
|
183
|
-
const mailbox = getSharedProjectMailbox(projectDir);
|
|
184
|
-
void mailbox.send({
|
|
185
|
-
from: context.agentId,
|
|
186
|
-
to: `@session:${sessionId}`,
|
|
187
|
-
type: "status",
|
|
188
|
-
subject: `Kanban todo list updated (${todos.length} item${todos.length === 1 ? "" : "s"})`,
|
|
189
|
-
body: `Shared Kanban board synced this session's todo list: ${todos.length} item${todos.length === 1 ? "" : "s"} \u2014 ${statusCounts.completed} completed, ${statusCounts.inProgress} in progress, ${statusCounts.pending} pending.`,
|
|
190
|
-
priority: "normal",
|
|
191
|
-
senderSessionId: sessionId
|
|
192
|
-
}).catch(() => {
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
function notifyTodoUpdate(context, todos) {
|
|
196
|
-
const summary = formatTodosForModel(todos);
|
|
197
|
-
const text = `[KANBAN TODO UPDATE]
|
|
198
|
-
Another Kanban agent reassessed the shared board. The canonical todo list is now:
|
|
199
|
-
${summary}
|
|
200
|
-
Reassess your current plan before continuing; do not rely on the initial todo snapshot. Preserve each row's <kanban board/task> binding verbatim on your next \`todo\` call \u2014 a row that loses it stops advancing its card.`;
|
|
201
|
-
const state = context.state;
|
|
202
|
-
if (typeof state.appendBlockToLastUserMessage === "function") {
|
|
203
|
-
if (state.appendBlockToLastUserMessage({ type: "text", text })) return;
|
|
204
|
-
}
|
|
205
|
-
if (typeof state.appendMessage === "function") {
|
|
206
|
-
state.appendMessage({ role: "user", content: [{ type: "text", text }] });
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
function applyManagedKanbanBoardToTodos(context, board, suppressedTodoMirrors2, options = {}) {
|
|
210
|
-
const metaKanban = context.meta["kanban"];
|
|
211
|
-
const metaBoardId = metaKanban && typeof metaKanban === "object" ? metaKanban["boardId"] : void 0;
|
|
212
|
-
const activeBoardId2 = context.currentKanbanBoardId ?? (typeof metaBoardId === "string" ? metaBoardId : void 0);
|
|
213
|
-
if (!activeBoardId2 || board.id !== activeBoardId2 || board.lifecycle?.mode !== "managed") {
|
|
214
|
-
return [...context.todos];
|
|
215
|
-
}
|
|
216
|
-
const ownerSessionId = options.sessionOwnerFromTags?.(board.tags);
|
|
217
|
-
if (ownerSessionId && ownerSessionId !== (context.session?.id ?? "")) {
|
|
218
|
-
return [...context.todos];
|
|
219
|
-
}
|
|
220
|
-
const projectedTodos = orderTasksForTodos(
|
|
221
|
-
board,
|
|
222
|
-
board.tasks.filter(
|
|
223
|
-
(task) => task.status !== "archived" && task.mergedIntoTaskId === void 0 && (!task.childTaskIds || task.childTaskIds.length === 0)
|
|
224
|
-
)
|
|
225
|
-
).map((task) => managedTodoFromTask(task, board));
|
|
226
|
-
if (sameTodos(context.todos, projectedTodos)) return [...context.todos];
|
|
227
|
-
suppressedTodoMirrors2.add(context);
|
|
228
|
-
try {
|
|
229
|
-
context.state.replaceTodos(projectedTodos);
|
|
230
|
-
} finally {
|
|
231
|
-
suppressedTodoMirrors2.delete(context);
|
|
232
|
-
}
|
|
233
|
-
notifyTodoUpdate(context, context.todos);
|
|
234
|
-
broadcastTodoUpdate(context, context.todos);
|
|
235
|
-
return [...context.todos];
|
|
236
|
-
}
|
|
237
|
-
async function applySessionKanbanTaskToSource(context, task, suppressedTodoMirrors2, options = {}) {
|
|
238
|
-
const originId = task.origin?.taskId;
|
|
239
|
-
const graphId = task.origin?.graphId ?? "";
|
|
240
|
-
const isTodoOrigin = task.origin?.system === "session-todo" || graphId.startsWith("todo:");
|
|
241
|
-
const targetTodo = context.todos?.find(
|
|
242
|
-
(todo) => originId !== void 0 && todo.id === originId || todo.kanbanTaskId === task.id || todo.id === task.id && !todo.promotedFromPlan && !todo.promotedFromTask
|
|
243
|
-
);
|
|
244
|
-
if (isTodoOrigin || targetTodo) {
|
|
245
|
-
const matchedId = targetTodo?.id ?? originId;
|
|
246
|
-
if (matchedId) {
|
|
247
|
-
const mappedStatus = todoStatus(task);
|
|
248
|
-
const next = options.remove ? context.todos.filter((todo) => todo.id !== matchedId) : context.todos.map(
|
|
249
|
-
(todo) => todo.id === matchedId ? {
|
|
250
|
-
...todo,
|
|
251
|
-
content: task.title,
|
|
252
|
-
status: mappedStatus,
|
|
253
|
-
kanbanTaskId: task.id
|
|
254
|
-
} : todo
|
|
255
|
-
);
|
|
256
|
-
suppressedTodoMirrors2.add(context);
|
|
257
|
-
try {
|
|
258
|
-
context.state.replaceTodos(next);
|
|
259
|
-
} finally {
|
|
260
|
-
suppressedTodoMirrors2.delete(context);
|
|
261
|
-
}
|
|
262
|
-
return { source: "todo", todos: [...context.todos] };
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
if (!originId) return { source: null };
|
|
266
|
-
const id = context.session?.id ?? "";
|
|
267
|
-
if (task.origin?.system === "session-plan" || graphId.startsWith("plan:")) {
|
|
268
|
-
const planPath = context.meta["plan.path"];
|
|
269
|
-
if (typeof planPath !== "string" || !planPath) {
|
|
270
|
-
throw new Error(
|
|
271
|
-
"Cannot reflect this Kanban edit back to its plan source: the session has no plan.path configured. The board mutation already succeeded; the plan file is now out of sync."
|
|
272
|
-
);
|
|
273
|
-
}
|
|
274
|
-
const plan = await mutatePlan(planPath, id, (file) => ({
|
|
275
|
-
...file,
|
|
276
|
-
updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
277
|
-
items: options.remove ? file.items.filter((item) => item.id !== originId) : file.items.map(
|
|
278
|
-
(item) => item.id === originId ? {
|
|
279
|
-
...item,
|
|
280
|
-
title: task.title,
|
|
281
|
-
details: task.description,
|
|
282
|
-
status: task.status === "completed" ? "done" : task.status === "in_progress" || task.status === "review" ? "in_progress" : "open",
|
|
283
|
-
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
284
|
-
} : item
|
|
285
|
-
)
|
|
286
|
-
}));
|
|
287
|
-
return { source: "plan", plan };
|
|
288
|
-
}
|
|
289
|
-
if (task.origin?.system === "session-task" || task.origin?.system === "session" || graphId.startsWith("session:")) {
|
|
290
|
-
const taskPath = context.meta["task.path"];
|
|
291
|
-
if (typeof taskPath !== "string" || !taskPath) {
|
|
292
|
-
throw new Error(
|
|
293
|
-
"Cannot reflect this Kanban edit back to its task source: the session has no task.path configured. The board mutation already succeeded; the task file is now out of sync."
|
|
294
|
-
);
|
|
295
|
-
}
|
|
296
|
-
const tasks = await mutateTasks(taskPath, id, (file) => ({
|
|
297
|
-
...file,
|
|
298
|
-
tasks: options.remove ? file.tasks.filter((item) => item.id !== originId) : file.tasks.map(
|
|
299
|
-
(item) => item.id === originId ? {
|
|
300
|
-
...item,
|
|
301
|
-
title: task.title,
|
|
302
|
-
description: task.description,
|
|
303
|
-
status: sourceStatus(task),
|
|
304
|
-
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
305
|
-
} : item
|
|
306
|
-
)
|
|
307
|
-
}));
|
|
308
|
-
return { source: "task", tasks };
|
|
309
|
-
}
|
|
310
|
-
return { source: null };
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
// src/session-kanban.ts
|
|
314
|
-
var SESSION_BOARD_TAG = "session-work";
|
|
315
|
-
var MIRROR_DISABLED_ENV = "WRONGSTACK_KANBAN_TASK_MIRROR";
|
|
316
|
-
var SESSION_KANBAN_COLUMNS = DEFAULT_COLUMNS.map((column) => ({
|
|
317
|
-
...column
|
|
318
|
-
}));
|
|
319
|
-
var boardQueue = /* @__PURE__ */ new Map();
|
|
320
|
-
var boardEnsures = /* @__PURE__ */ new Map();
|
|
321
|
-
var pendingMirrors = /* @__PURE__ */ new Map();
|
|
322
|
-
var activeMirrors = /* @__PURE__ */ new Set();
|
|
323
|
-
var mirrorFailures = /* @__PURE__ */ new Map();
|
|
324
|
-
var suppressedTodoMirrors = /* @__PURE__ */ new WeakSet();
|
|
325
|
-
function boardKey(projectRoot, sessionId) {
|
|
326
|
-
return `${projectRoot}\0${sessionId}`;
|
|
327
|
-
}
|
|
328
|
-
function mirrorKey(projectRoot, sessionId, sourceSystem) {
|
|
329
|
-
return `${boardKey(projectRoot, sessionId)}\0${sourceSystem}`;
|
|
330
|
-
}
|
|
331
|
-
function completedReconciliationGraph(latest, candidates) {
|
|
332
|
-
const latestNodeIds = new Set(latest.nodes.map((node) => node.id));
|
|
333
|
-
const carriedNodeIds = /* @__PURE__ */ new Set();
|
|
334
|
-
const completedNodes = candidates.flatMap(
|
|
335
|
-
(candidate) => candidate.nodes.filter((node) => {
|
|
336
|
-
if (node.status !== "completed" || latestNodeIds.has(node.id) || carriedNodeIds.has(node.id)) {
|
|
337
|
-
return false;
|
|
338
|
-
}
|
|
339
|
-
carriedNodeIds.add(node.id);
|
|
340
|
-
return true;
|
|
341
|
-
})
|
|
342
|
-
);
|
|
343
|
-
if (completedNodes.length === 0) return void 0;
|
|
344
|
-
const carriedRequirements = completedNodes.flatMap(
|
|
345
|
-
(node) => node.specRequirementId ? [node.specRequirementId] : []
|
|
346
|
-
);
|
|
347
|
-
return {
|
|
348
|
-
...latest,
|
|
349
|
-
nodes: [...latest.nodes, ...completedNodes],
|
|
350
|
-
rootNodes: [.../* @__PURE__ */ new Set([...latest.rootNodes, ...completedNodes.map((node) => node.id)])],
|
|
351
|
-
...latest.requiredRequirementIds ? {
|
|
352
|
-
requiredRequirementIds: [
|
|
353
|
-
.../* @__PURE__ */ new Set([...latest.requiredRequirementIds, ...carriedRequirements])
|
|
354
|
-
]
|
|
355
|
-
} : {}
|
|
356
|
-
};
|
|
357
|
-
}
|
|
358
|
-
function sessionTag(sessionId) {
|
|
359
|
-
return `session:${sessionId}`;
|
|
360
|
-
}
|
|
361
|
-
function sessionBoardTitle(sessionId) {
|
|
362
|
-
const leaf = sessionId.split(/[\\/]/).filter(Boolean).pop() ?? sessionId;
|
|
363
|
-
return `Session ${leaf.slice(0, 12)}`;
|
|
364
|
-
}
|
|
365
|
-
function sessionBoardTags(sessionId) {
|
|
366
|
-
return ["session", SESSION_BOARD_TAG, sessionTag(sessionId)];
|
|
367
|
-
}
|
|
368
|
-
function sessionIdFromTags(tags) {
|
|
369
|
-
const tag = tags?.find((candidate) => candidate.startsWith("session:"));
|
|
370
|
-
return tag?.slice("session:".length) || null;
|
|
371
|
-
}
|
|
372
|
-
function sameColumns(columns) {
|
|
373
|
-
return columns.length === SESSION_KANBAN_COLUMNS.length && columns.every((column, index) => column.id === SESSION_KANBAN_COLUMNS[index]?.id);
|
|
374
|
-
}
|
|
375
|
-
async function ensureSessionKanbanBoard(projectRoot, sessionId) {
|
|
376
|
-
if (!projectRoot || !sessionId || process.env[MIRROR_DISABLED_ENV] === "0") return null;
|
|
377
|
-
const key = boardKey(projectRoot, sessionId);
|
|
378
|
-
const inFlight = boardEnsures.get(key);
|
|
379
|
-
if (inFlight) return inFlight;
|
|
380
|
-
const promise = (async () => {
|
|
381
|
-
const summary = (await listBoards(projectRoot)).find(
|
|
382
|
-
(board2) => board2.tags?.includes(sessionTag(sessionId))
|
|
383
|
-
);
|
|
384
|
-
let board = summary ? await getBoard(projectRoot, summary.id) : null;
|
|
385
|
-
if (!board) {
|
|
386
|
-
return createBoard(projectRoot, {
|
|
387
|
-
title: sessionBoardTitle(sessionId),
|
|
388
|
-
description: "Live session work: todos, tasks, and plan items.",
|
|
389
|
-
tags: sessionBoardTags(sessionId),
|
|
390
|
-
columns: SESSION_KANBAN_COLUMNS,
|
|
391
|
-
generatedBy: `session-kanban:${sessionId}`,
|
|
392
|
-
kind: "session_mirror",
|
|
393
|
-
retention: { mode: "archive_after_ttl", ttlMs: 7 * 24 * 60 * 60 * 1e3 }
|
|
394
|
-
});
|
|
395
|
-
}
|
|
396
|
-
if (!sameColumns(board.columns) || !board.tags?.includes(SESSION_BOARD_TAG)) {
|
|
397
|
-
board = await updateBoard(projectRoot, board.id, {
|
|
398
|
-
title: sessionBoardTitle(sessionId),
|
|
399
|
-
description: "Live session work: todos, tasks, and plan items.",
|
|
400
|
-
tags: [.../* @__PURE__ */ new Set([...board.tags ?? [], ...sessionBoardTags(sessionId)])],
|
|
401
|
-
columns: SESSION_KANBAN_COLUMNS
|
|
402
|
-
}) ?? board;
|
|
403
|
-
}
|
|
404
|
-
return board;
|
|
405
|
-
})();
|
|
406
|
-
boardEnsures.set(key, promise);
|
|
407
|
-
try {
|
|
408
|
-
return await promise;
|
|
409
|
-
} finally {
|
|
410
|
-
boardEnsures.delete(key);
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
function enqueueBoardWork(projectRoot, sessionId, work) {
|
|
414
|
-
const key = boardKey(projectRoot, sessionId);
|
|
415
|
-
const previous = boardQueue.get(key) ?? Promise.resolve();
|
|
416
|
-
const result = previous.catch(() => void 0).then(work);
|
|
417
|
-
const tail = result.then(
|
|
418
|
-
() => void 0,
|
|
419
|
-
() => void 0
|
|
420
|
-
);
|
|
421
|
-
boardQueue.set(key, tail);
|
|
422
|
-
void tail.then(() => {
|
|
423
|
-
if (boardQueue.get(key) === tail) boardQueue.delete(key);
|
|
424
|
-
});
|
|
425
|
-
return result;
|
|
426
|
-
}
|
|
427
|
-
async function projectGraph(projectRoot, sessionId, graph, sourceSystem) {
|
|
428
|
-
if (!projectRoot || !sessionId || process.env[MIRROR_DISABLED_ENV] === "0") return null;
|
|
429
|
-
return enqueueBoardWork(projectRoot, sessionId, async () => {
|
|
430
|
-
const board = await ensureSessionKanbanBoard(projectRoot, sessionId);
|
|
431
|
-
if (!board) return null;
|
|
432
|
-
const result = await syncBoardFromTaskGraph(
|
|
433
|
-
projectRoot,
|
|
434
|
-
board.id,
|
|
435
|
-
deserializeTaskGraph(graph),
|
|
436
|
-
{
|
|
437
|
-
sourceSystem,
|
|
438
|
-
tags: [.../* @__PURE__ */ new Set([...board.tags ?? [], ...sessionBoardTags(sessionId)])],
|
|
439
|
-
archiveMissingTasks: true,
|
|
440
|
-
includeCompletedTasks: true,
|
|
441
|
-
allowRequirementScopeShrink: true
|
|
442
|
-
}
|
|
443
|
-
);
|
|
444
|
-
if (!result) return null;
|
|
445
|
-
const compacted = await compactSessionMirrorBoard(projectRoot, board.id);
|
|
446
|
-
if (compacted?.removedTaskIds.length) {
|
|
447
|
-
return await getBoard(projectRoot, board.id) ?? result.board;
|
|
448
|
-
}
|
|
449
|
-
return result.board;
|
|
450
|
-
});
|
|
451
|
-
}
|
|
452
|
-
function queueLatestMirror(projectRoot, sessionId, graph, sourceSystem) {
|
|
453
|
-
if (!projectRoot || !sessionId || process.env[MIRROR_DISABLED_ENV] === "0") return;
|
|
454
|
-
const key = mirrorKey(projectRoot, sessionId, sourceSystem);
|
|
455
|
-
const previous = pendingMirrors.get(key);
|
|
456
|
-
const reconciliationGraph = previous ? completedReconciliationGraph(
|
|
457
|
-
graph,
|
|
458
|
-
[previous.reconciliationGraph, previous.graph].filter(
|
|
459
|
-
(candidate) => candidate !== void 0
|
|
460
|
-
)
|
|
461
|
-
) : void 0;
|
|
462
|
-
pendingMirrors.set(key, {
|
|
463
|
-
projectRoot,
|
|
464
|
-
sessionId,
|
|
465
|
-
graph,
|
|
466
|
-
...reconciliationGraph ? { reconciliationGraph } : {},
|
|
467
|
-
sourceSystem
|
|
468
|
-
});
|
|
469
|
-
if (activeMirrors.has(key)) return;
|
|
470
|
-
activeMirrors.add(key);
|
|
471
|
-
void (async () => {
|
|
472
|
-
try {
|
|
473
|
-
for (; ; ) {
|
|
474
|
-
const pending = pendingMirrors.get(key);
|
|
475
|
-
if (!pending) break;
|
|
476
|
-
pendingMirrors.delete(key);
|
|
477
|
-
try {
|
|
478
|
-
if (pending.reconciliationGraph) {
|
|
479
|
-
await projectGraph(
|
|
480
|
-
pending.projectRoot,
|
|
481
|
-
pending.sessionId,
|
|
482
|
-
pending.reconciliationGraph,
|
|
483
|
-
pending.sourceSystem
|
|
484
|
-
);
|
|
485
|
-
}
|
|
486
|
-
await projectGraph(
|
|
487
|
-
pending.projectRoot,
|
|
488
|
-
pending.sessionId,
|
|
489
|
-
pending.graph,
|
|
490
|
-
pending.sourceSystem
|
|
491
|
-
);
|
|
492
|
-
mirrorFailures.delete(boardKey(pending.projectRoot, pending.sessionId));
|
|
493
|
-
} catch (error) {
|
|
494
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
495
|
-
mirrorFailures.set(boardKey(pending.projectRoot, pending.sessionId), {
|
|
496
|
-
message,
|
|
497
|
-
sourceSystem: pending.sourceSystem
|
|
498
|
-
});
|
|
499
|
-
console.warn(
|
|
500
|
-
JSON.stringify({
|
|
501
|
-
level: "warn",
|
|
502
|
-
event: "session-kanban.mirror-failed",
|
|
503
|
-
sessionId: pending.sessionId,
|
|
504
|
-
sourceSystem: pending.sourceSystem,
|
|
505
|
-
message,
|
|
506
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
507
|
-
})
|
|
508
|
-
);
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
} finally {
|
|
512
|
-
activeMirrors.delete(key);
|
|
513
|
-
const pending = pendingMirrors.get(key);
|
|
514
|
-
if (pending) {
|
|
515
|
-
pendingMirrors.delete(key);
|
|
516
|
-
queueLatestMirror(
|
|
517
|
-
pending.projectRoot,
|
|
518
|
-
pending.sessionId,
|
|
519
|
-
pending.graph,
|
|
520
|
-
pending.sourceSystem
|
|
521
|
-
);
|
|
522
|
-
}
|
|
523
|
-
}
|
|
524
|
-
})();
|
|
525
|
-
}
|
|
526
|
-
function takeSessionMirrorFailure(projectRoot, sessionId) {
|
|
527
|
-
if (!projectRoot || !sessionId) return void 0;
|
|
528
|
-
const key = boardKey(projectRoot, sessionId);
|
|
529
|
-
const failure = mirrorFailures.get(key);
|
|
530
|
-
if (!failure) return void 0;
|
|
531
|
-
mirrorFailures.delete(key);
|
|
532
|
-
return `Kanban mirror (${failure.sourceSystem}) failed and the board may be stale: ${failure.message}`;
|
|
533
|
-
}
|
|
534
|
-
function mirrorSessionTodosToKanban(projectRoot, todos, sessionId) {
|
|
535
|
-
queueLatestMirror(
|
|
536
|
-
projectRoot,
|
|
537
|
-
sessionId,
|
|
538
|
-
todoListToSerializedGraph(todos, sessionId),
|
|
539
|
-
"session-todo"
|
|
540
|
-
);
|
|
541
|
-
}
|
|
542
|
-
function mirrorSessionTasksToKanban(projectRoot, tasks, sessionId) {
|
|
543
|
-
queueLatestMirror(
|
|
544
|
-
projectRoot,
|
|
545
|
-
sessionId,
|
|
546
|
-
taskFileToSerializedGraph(tasks, sessionId),
|
|
547
|
-
"session-task"
|
|
548
|
-
);
|
|
549
|
-
}
|
|
550
|
-
function applyManagedKanbanBoardToTodos2(context, board) {
|
|
551
|
-
return applyManagedKanbanBoardToTodos(context, board, suppressedTodoMirrors, {
|
|
552
|
-
sessionOwnerFromTags: sessionIdFromTags
|
|
553
|
-
});
|
|
554
|
-
}
|
|
555
|
-
function applySessionKanbanTaskToSource2(context, task, options = {}) {
|
|
556
|
-
return applySessionKanbanTaskToSource(context, task, suppressedTodoMirrors, options);
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
// src/todo.ts
|
|
560
|
-
import {
|
|
561
|
-
loadPlan as loadPlan2,
|
|
562
|
-
loadTasks as loadTasks3,
|
|
563
|
-
savePlan,
|
|
564
|
-
saveTasks,
|
|
565
|
-
setPlanItemStatus
|
|
566
|
-
} from "@wrongstack/core/storage";
|
|
567
|
-
import { addTask as addTask3, getBoard as getBoard5 } from "@wrongstack/kanban";
|
|
568
|
-
|
|
569
|
-
// src/kanban.ts
|
|
570
|
-
import { stripLifecycleIssues as stripLifecycleIssues2 } from "@wrongstack/kanban";
|
|
571
|
-
|
|
572
|
-
// src/kanban-board-actions.ts
|
|
573
|
-
import { loadTasks as loadTasks2 } from "@wrongstack/core/storage";
|
|
574
|
-
import { deserializeTaskGraph as deserializeTaskGraph2, serializeTaskGraph } from "@wrongstack/core/tasking";
|
|
575
|
-
import {
|
|
576
|
-
addTask,
|
|
577
|
-
adoptManagedLifecycle,
|
|
578
|
-
createBoard as createBoard2,
|
|
579
|
-
createBoardFromTaskGraph,
|
|
580
|
-
createBoardFromText,
|
|
581
|
-
duplicateBoard,
|
|
582
|
-
exportBoardAsMarkdown,
|
|
583
|
-
exportBoardToTaskGraph,
|
|
584
|
-
getBoard as getBoard3,
|
|
585
|
-
getKanbanOrchestrationSnapshot as getKanbanOrchestrationSnapshot2,
|
|
586
|
-
getKanbanQueueHealth,
|
|
587
|
-
listBoards as listBoards2,
|
|
588
|
-
listKanbanEvents,
|
|
589
|
-
listReadyTasks,
|
|
590
|
-
parseLinesIntoTasks,
|
|
591
|
-
removeBoard as removeBoard2,
|
|
592
|
-
searchKanban,
|
|
593
|
-
syncBoardFromTaskGraph as syncBoardFromTaskGraph2,
|
|
594
|
-
updateBoard as updateBoard2
|
|
595
|
-
} from "@wrongstack/kanban";
|
|
596
|
-
|
|
597
|
-
// src/kanban-board-inputs.ts
|
|
598
|
-
function agentSettableGate(enforcement) {
|
|
599
|
-
if (enforcement === void 0 || enforcement === "off") return {};
|
|
600
|
-
return { completionGate: { enforcement } };
|
|
601
|
-
}
|
|
602
|
-
function boardCreateInput(input, title) {
|
|
603
|
-
return {
|
|
604
|
-
title,
|
|
605
|
-
...input.description !== void 0 ? { description: input.description } : {},
|
|
606
|
-
...input.tags !== void 0 ? { tags: input.tags } : {},
|
|
607
|
-
...input.generatedBy !== void 0 ? { generatedBy: input.generatedBy } : {},
|
|
608
|
-
...input.atomicityMode !== void 0 ? {
|
|
609
|
-
atomicity: {
|
|
610
|
-
mode: input.atomicityMode,
|
|
611
|
-
decomposition: input.atomicityDecomposition ?? "propose"
|
|
612
|
-
}
|
|
613
|
-
} : {},
|
|
614
|
-
...agentSettableGate(input.gateEnforcement)
|
|
615
|
-
};
|
|
616
|
-
}
|
|
617
|
-
function boardUpdatePatch(input) {
|
|
618
|
-
return {
|
|
619
|
-
...input.title !== void 0 ? { title: input.title } : {},
|
|
620
|
-
...input.description !== void 0 ? { description: input.description } : {},
|
|
621
|
-
...input.tags !== void 0 ? { tags: input.tags } : {},
|
|
622
|
-
...input.atomicityMode !== void 0 ? {
|
|
623
|
-
atomicity: {
|
|
624
|
-
mode: input.atomicityMode,
|
|
625
|
-
decomposition: input.atomicityDecomposition ?? "propose"
|
|
626
|
-
}
|
|
627
|
-
} : {},
|
|
628
|
-
...agentSettableGate(input.gateEnforcement)
|
|
629
|
-
};
|
|
630
|
-
}
|
|
631
|
-
function duplicateBoardOptions(input) {
|
|
632
|
-
return {
|
|
633
|
-
...input.title !== void 0 ? { title: input.title } : {},
|
|
634
|
-
...input.generatedBy !== void 0 ? { generatedBy: input.generatedBy } : {},
|
|
635
|
-
...input.includeTasks !== void 0 ? { includeTasks: input.includeTasks } : {},
|
|
636
|
-
...input.includeCompletedTasks !== void 0 ? { includeCompletedTasks: input.includeCompletedTasks } : {},
|
|
637
|
-
...input.preserveAssignment !== void 0 ? { preserveAssignment: input.preserveAssignment } : {}
|
|
638
|
-
};
|
|
639
|
-
}
|
|
640
|
-
|
|
641
|
-
// src/kanban-split-task-handler.ts
|
|
642
|
-
import { getBoard as getBoard2, splitTask } from "@wrongstack/kanban";
|
|
643
|
-
|
|
644
|
-
// src/kanban-tool-results.ts
|
|
645
|
-
function atomicityNudge(task) {
|
|
646
|
-
if (task.atomicityAssessment?.verdict !== "needs_decomposition") return "";
|
|
647
|
-
const reasons = task.atomicityAssessment.criteria.filter((entry) => entry.score < 1).map((entry) => entry.reason).join(" | ");
|
|
648
|
-
return ` Atomicity: needs_decomposition (score ${task.atomicityAssessment.score}) \u2014 call propose_decomposition with 2+ subtasks before dispatch. Reasons: ${reasons}`;
|
|
649
|
-
}
|
|
650
|
-
function readEnvGateEnforcement() {
|
|
651
|
-
const raw = process.env["WRONGSTACK_KANBAN_GATE"]?.trim().toLowerCase();
|
|
652
|
-
return raw === "strict" || raw === "soft" || raw === "off" ? raw : void 0;
|
|
653
|
-
}
|
|
654
|
-
function fail(message) {
|
|
655
|
-
return { ok: false, message };
|
|
656
|
-
}
|
|
657
|
-
function okBoard(board, message = "Board loaded.") {
|
|
658
|
-
return { ok: true, message, board };
|
|
659
|
-
}
|
|
660
|
-
function okTask(board, task, message) {
|
|
661
|
-
return { ok: true, message, board, task };
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
// src/kanban-split-task-handler.ts
|
|
665
|
-
async function handleSplitTask(projectRoot, input, extraSplitOptions) {
|
|
666
|
-
const boardId = input.boardId;
|
|
667
|
-
const taskId = input.taskId;
|
|
668
|
-
const childTitles = input.childTitles;
|
|
669
|
-
if (!boardId || !taskId || !childTitles?.length) {
|
|
670
|
-
return fail("split requires boardId, taskId, and at least one childTitles.");
|
|
671
|
-
}
|
|
672
|
-
const {
|
|
673
|
-
targetColumnId,
|
|
674
|
-
inheritAssignment,
|
|
675
|
-
inheritLabels,
|
|
676
|
-
inheritSuccessCriteria,
|
|
677
|
-
inheritGoalMetrics,
|
|
678
|
-
inheritDependencies,
|
|
679
|
-
chainChildren,
|
|
680
|
-
rewireDependents
|
|
681
|
-
} = input;
|
|
682
|
-
const result = await splitTask(projectRoot, boardId, taskId, {
|
|
683
|
-
titles: childTitles,
|
|
684
|
-
...extraSplitOptions,
|
|
685
|
-
...targetColumnId !== void 0 ? { columnId: targetColumnId } : {},
|
|
686
|
-
...inheritAssignment !== void 0 ? { inheritAssignment } : {},
|
|
687
|
-
...inheritLabels !== void 0 ? { inheritLabels } : {},
|
|
688
|
-
...inheritSuccessCriteria !== void 0 ? { inheritSuccessCriteria } : {},
|
|
689
|
-
...inheritGoalMetrics !== void 0 ? { inheritGoalMetrics } : {},
|
|
690
|
-
...inheritDependencies !== void 0 ? { inheritDependencies } : {},
|
|
691
|
-
...chainChildren !== void 0 ? { chainChildren } : {},
|
|
692
|
-
...rewireDependents !== void 0 ? { rewireDependents } : {}
|
|
693
|
-
});
|
|
694
|
-
if (!result) return fail("Task not found.");
|
|
695
|
-
const freshParent = result.board.tasks?.find((t) => t.id === taskId);
|
|
696
|
-
if (!freshParent) {
|
|
697
|
-
return fail(
|
|
698
|
-
`Split succeeded but parent ${taskId} not found in returned board. Children: [${result.children.map((c) => c.id).join(", ")}].`
|
|
699
|
-
);
|
|
700
|
-
}
|
|
701
|
-
return {
|
|
702
|
-
ok: true,
|
|
703
|
-
message: `${result.children.length} child task(s) created.`,
|
|
704
|
-
board: result.board,
|
|
705
|
-
task: freshParent,
|
|
706
|
-
children: result.children
|
|
707
|
-
};
|
|
708
|
-
}
|
|
709
|
-
async function requireBoard(projectRoot, boardId) {
|
|
710
|
-
return boardId ? getBoard2(projectRoot, boardId) : null;
|
|
711
|
-
}
|
|
712
|
-
|
|
713
|
-
// src/kanban-board-actions.ts
|
|
714
|
-
async function handleKanbanBoardAction(projectRoot, input, ctx) {
|
|
715
|
-
switch (input.action) {
|
|
716
|
-
case "list_boards": {
|
|
717
|
-
const boards = await listBoards2(projectRoot);
|
|
718
|
-
return { ok: true, message: `${boards.length} board(s).`, boards };
|
|
719
|
-
}
|
|
720
|
-
case "get_board": {
|
|
721
|
-
const board = await requireBoard(projectRoot, input.boardId);
|
|
722
|
-
return board ? okBoard(board) : fail("Board not found.");
|
|
723
|
-
}
|
|
724
|
-
case "create_board": {
|
|
725
|
-
if (!input.title) return fail("create_board requires title.");
|
|
726
|
-
const existing = (await listBoards2(projectRoot)).filter(
|
|
727
|
-
(candidate) => (candidate.kind ?? "project") === "project"
|
|
728
|
-
);
|
|
729
|
-
const board = await createBoard2(projectRoot, boardCreateInput(input, input.title));
|
|
730
|
-
const note = existing.length ? ` ${existing.length} other project board(s) already exist: ${existing.slice(0, 3).map((candidate) => `"${candidate.title}" (${candidate.taskCount} task(s))`).join(
|
|
731
|
-
", "
|
|
732
|
-
)}${existing.length > 3 ? ", \u2026" : ""}. If this work belongs to one of them, add_task there instead and delete this board.` : "";
|
|
733
|
-
return { ok: true, message: `Board created: ${board.title}.${note}`, board };
|
|
734
|
-
}
|
|
735
|
-
case "update_board": {
|
|
736
|
-
if (!input.boardId) return fail("update_board requires boardId.");
|
|
737
|
-
const board = await updateBoard2(projectRoot, input.boardId, boardUpdatePatch(input));
|
|
738
|
-
return board ? okBoard(board, "Board updated.") : fail("Board not found.");
|
|
739
|
-
}
|
|
740
|
-
case "adopt_managed_lifecycle": {
|
|
741
|
-
if (!input.boardId || !input.author || !input.transitionComment) {
|
|
742
|
-
return fail(
|
|
743
|
-
"adopt_managed_lifecycle requires boardId, author, transitionComment, and five ordered columns."
|
|
744
|
-
);
|
|
745
|
-
}
|
|
746
|
-
if (input.columns?.length !== 5) {
|
|
747
|
-
return fail(
|
|
748
|
-
"adopt_managed_lifecycle columns must be ordered as backlog, todo, running, review, done."
|
|
749
|
-
);
|
|
750
|
-
}
|
|
751
|
-
const [backlog, todo, running, review, done] = input.columns;
|
|
752
|
-
if (!backlog || !todo || !running || !review || !done) {
|
|
753
|
-
return fail("adopt_managed_lifecycle columns must contain five nonblank ids.");
|
|
754
|
-
}
|
|
755
|
-
const board = await adoptManagedLifecycle(projectRoot, input.boardId, {
|
|
756
|
-
columns: { backlog, todo, running, review, done },
|
|
757
|
-
actor: input.author,
|
|
758
|
-
comment: input.transitionComment
|
|
759
|
-
});
|
|
760
|
-
return board ? okBoard(board, "Managed lifecycle adopted without moving existing cards.") : fail("Board not found.");
|
|
761
|
-
}
|
|
762
|
-
case "release_managed_lifecycle": {
|
|
763
|
-
if (!input.boardId) return fail("release_managed_lifecycle requires boardId.");
|
|
764
|
-
const board = await updateBoard2(projectRoot, input.boardId, { lifecycle: null });
|
|
765
|
-
return board ? okBoard(
|
|
766
|
-
board,
|
|
767
|
-
"Managed lifecycle released; the board now tracks work without strict gates."
|
|
768
|
-
) : fail("Board not found.");
|
|
769
|
-
}
|
|
770
|
-
case "duplicate_board": {
|
|
771
|
-
if (!input.boardId) return fail("duplicate_board requires boardId.");
|
|
772
|
-
const board = await duplicateBoard(projectRoot, input.boardId, duplicateBoardOptions(input));
|
|
773
|
-
return board ? okBoard(board, "Board duplicated.") : fail("Board not found.");
|
|
774
|
-
}
|
|
775
|
-
case "delete_board": {
|
|
776
|
-
if (!input.boardId) return fail("delete_board requires boardId.");
|
|
777
|
-
const removed = await removeBoard2(projectRoot, input.boardId);
|
|
778
|
-
return { ok: removed, message: removed ? "Board deleted." : "Board not found." };
|
|
779
|
-
}
|
|
780
|
-
case "generate_board": {
|
|
781
|
-
if (!input.description) return fail("generate_board requires description.");
|
|
782
|
-
const boardInput = createBoardFromText({
|
|
783
|
-
description: input.description,
|
|
784
|
-
...input.title !== void 0 ? { title: input.title } : {},
|
|
785
|
-
...input.context !== void 0 ? { context: input.context } : {}
|
|
786
|
-
});
|
|
787
|
-
const board = await createBoard2(projectRoot, boardInput);
|
|
788
|
-
for (const tInput of parseLinesIntoTasks(
|
|
789
|
-
input.description,
|
|
790
|
-
board.columns[0]?.id ?? "backlog"
|
|
791
|
-
)) {
|
|
792
|
-
await addTask(projectRoot, board.id, tInput);
|
|
793
|
-
}
|
|
794
|
-
return okBoard(await getBoard3(projectRoot, board.id) ?? board, "Board generated.");
|
|
795
|
-
}
|
|
796
|
-
case "export_markdown": {
|
|
797
|
-
const board = await requireBoard(projectRoot, input.boardId);
|
|
798
|
-
if (!board) return fail("Board not found.");
|
|
799
|
-
return {
|
|
800
|
-
ok: true,
|
|
801
|
-
message: "Board exported.",
|
|
802
|
-
board,
|
|
803
|
-
markdown: exportBoardAsMarkdown(board)
|
|
804
|
-
};
|
|
805
|
-
}
|
|
806
|
-
case "export_task_graph": {
|
|
807
|
-
if (!input.boardId) return fail("export_task_graph requires boardId.");
|
|
808
|
-
const exported = await exportBoardToTaskGraph(projectRoot, input.boardId, {
|
|
809
|
-
...input.graphId !== void 0 ? { graphId: input.graphId } : {},
|
|
810
|
-
...input.specId !== void 0 ? { specId: input.specId } : {},
|
|
811
|
-
...input.title !== void 0 ? { title: input.title } : {},
|
|
812
|
-
...input.preserveOriginTaskIds !== void 0 ? { preserveOriginTaskIds: input.preserveOriginTaskIds } : {},
|
|
813
|
-
...input.includeArchived !== void 0 ? { includeArchived: input.includeArchived } : {}
|
|
814
|
-
});
|
|
815
|
-
if (!exported) return fail("Board not found.");
|
|
816
|
-
return {
|
|
817
|
-
ok: true,
|
|
818
|
-
message: `Task graph exported with ${exported.graph.nodes.size} node(s).`,
|
|
819
|
-
board: exported.board,
|
|
820
|
-
taskGraph: serializeTaskGraph(exported.graph)
|
|
821
|
-
};
|
|
822
|
-
}
|
|
823
|
-
case "sync_task_graph": {
|
|
824
|
-
if (!input.boardId || !input.taskGraph) {
|
|
825
|
-
return fail("sync_task_graph requires boardId and taskGraph.");
|
|
826
|
-
}
|
|
827
|
-
const graph = deserializeTaskGraph2(input.taskGraph);
|
|
828
|
-
const result = await syncBoardFromTaskGraph2(projectRoot, input.boardId, graph, {
|
|
829
|
-
...input.title !== void 0 ? { title: input.title } : {},
|
|
830
|
-
...input.description !== void 0 ? { description: input.description } : {},
|
|
831
|
-
...input.tags !== void 0 ? { tags: input.tags } : {},
|
|
832
|
-
...input.generatedBy !== void 0 ? { generatedBy: input.generatedBy } : {},
|
|
833
|
-
...input.sourceSystem !== void 0 ? { sourceSystem: input.sourceSystem } : {},
|
|
834
|
-
...input.phaseId !== void 0 ? { phaseId: input.phaseId } : {},
|
|
835
|
-
...input.includeCompletedTasks !== void 0 ? { includeCompletedTasks: input.includeCompletedTasks } : {},
|
|
836
|
-
...input.archiveMissingTasks !== void 0 ? { archiveMissingTasks: input.archiveMissingTasks } : {},
|
|
837
|
-
...input.preserveManualDependencies !== void 0 ? { preserveManualDependencies: input.preserveManualDependencies } : {}
|
|
838
|
-
});
|
|
839
|
-
return result ? {
|
|
840
|
-
ok: true,
|
|
841
|
-
message: `Task graph synced: ${result.createdTaskIds.length} created, ${result.updatedTaskIds.length} updated, ${result.archivedTaskIds.length} archived.`,
|
|
842
|
-
board: result.board
|
|
843
|
-
} : fail("Board not found.");
|
|
844
|
-
}
|
|
845
|
-
case "create_from_graph": {
|
|
846
|
-
if (!input.taskGraph) return fail("create_from_graph requires taskGraph.");
|
|
847
|
-
const graph = deserializeTaskGraph2(input.taskGraph);
|
|
848
|
-
const { board } = await createBoardFromTaskGraph(projectRoot, graph, {
|
|
849
|
-
...input.title !== void 0 ? { title: input.title } : {},
|
|
850
|
-
...input.description !== void 0 ? { description: input.description } : {},
|
|
851
|
-
...input.tags !== void 0 ? { tags: input.tags } : {},
|
|
852
|
-
...input.generatedBy !== void 0 ? { generatedBy: input.generatedBy } : {},
|
|
853
|
-
...input.sourceSystem !== void 0 ? { sourceSystem: input.sourceSystem } : {},
|
|
854
|
-
...input.phaseId !== void 0 ? { phaseId: input.phaseId } : {},
|
|
855
|
-
...input.includeCompletedTasks !== void 0 ? { includeCompletedTasks: input.includeCompletedTasks } : {}
|
|
856
|
-
});
|
|
857
|
-
return {
|
|
858
|
-
ok: true,
|
|
859
|
-
message: `Created board "${board.title}" from task graph with ${board.tasks.length} tasks.`,
|
|
860
|
-
board
|
|
861
|
-
};
|
|
862
|
-
}
|
|
863
|
-
case "import_session_tasks": {
|
|
864
|
-
const taskPath = ctx.meta?.["task.path"];
|
|
865
|
-
if (!taskPath) return fail("No session task file for this session.");
|
|
866
|
-
const file = await loadTasks2(taskPath);
|
|
867
|
-
if (!file || file.tasks.length === 0) return fail("No session tasks to import.");
|
|
868
|
-
const sessionId = ctx.session?.id ?? file.sessionId ?? "session";
|
|
869
|
-
const graph = deserializeTaskGraph2(taskFileToSerializedGraph(file.tasks, sessionId));
|
|
870
|
-
const tags = ["session", `session:${sessionId}`];
|
|
871
|
-
const existing = (await listBoards2(projectRoot)).find(
|
|
872
|
-
(b) => b.tags?.includes(`session:${sessionId}`)
|
|
873
|
-
);
|
|
874
|
-
if (existing) {
|
|
875
|
-
const result = await syncBoardFromTaskGraph2(projectRoot, existing.id, graph, {
|
|
876
|
-
sourceSystem: "session",
|
|
877
|
-
tags,
|
|
878
|
-
archiveMissingTasks: true,
|
|
879
|
-
includeCompletedTasks: true
|
|
880
|
-
});
|
|
881
|
-
return result ? {
|
|
882
|
-
ok: true,
|
|
883
|
-
message: `Synced ${file.tasks.length} session tasks into board "${result.board.title}".`,
|
|
884
|
-
board: result.board
|
|
885
|
-
} : fail("Session board vanished mid-sync.");
|
|
886
|
-
}
|
|
887
|
-
const { board } = await createBoardFromTaskGraph(projectRoot, graph, {
|
|
888
|
-
title: `Session tasks (${sessionId.slice(0, 8)})`,
|
|
889
|
-
sourceSystem: "session",
|
|
890
|
-
tags
|
|
891
|
-
});
|
|
892
|
-
return {
|
|
893
|
-
ok: true,
|
|
894
|
-
message: `Imported ${file.tasks.length} session tasks into new board "${board.title}".`,
|
|
895
|
-
board
|
|
896
|
-
};
|
|
897
|
-
}
|
|
898
|
-
case "search_tasks": {
|
|
899
|
-
const tasks = await searchKanban(projectRoot, {
|
|
900
|
-
query: input.query,
|
|
901
|
-
boardId: input.boardId,
|
|
902
|
-
assignedAgent: input.agentId,
|
|
903
|
-
status: input.status,
|
|
904
|
-
priority: input.priority,
|
|
905
|
-
label: input.labels?.[0],
|
|
906
|
-
chainId: input.chainId
|
|
907
|
-
});
|
|
908
|
-
return { ok: true, message: `${tasks.length} task(s) matched.`, tasks };
|
|
909
|
-
}
|
|
910
|
-
case "ready_tasks": {
|
|
911
|
-
const tasks = await listReadyTasks(projectRoot, {
|
|
912
|
-
query: input.query,
|
|
913
|
-
boardId: input.boardId,
|
|
914
|
-
assignedAgent: input.agentId,
|
|
915
|
-
priority: input.priority,
|
|
916
|
-
label: input.labels?.[0],
|
|
917
|
-
chainId: input.chainId,
|
|
918
|
-
limit: input.limit
|
|
919
|
-
});
|
|
920
|
-
return { ok: true, message: `${tasks.length} ready task(s).`, tasks };
|
|
921
|
-
}
|
|
922
|
-
case "snapshot": {
|
|
923
|
-
const snapshot = await getKanbanOrchestrationSnapshot2(projectRoot, {
|
|
924
|
-
query: input.query,
|
|
925
|
-
boardId: input.boardId,
|
|
926
|
-
assignedAgent: input.agentId,
|
|
927
|
-
status: input.status,
|
|
928
|
-
priority: input.priority,
|
|
929
|
-
label: input.labels?.[0],
|
|
930
|
-
chainId: input.chainId
|
|
931
|
-
});
|
|
932
|
-
return {
|
|
933
|
-
ok: true,
|
|
934
|
-
message: `${snapshot.ready.length} ready, ${snapshot.running.length} running, ${snapshot.blocked.length} blocked.`,
|
|
935
|
-
snapshot
|
|
936
|
-
};
|
|
937
|
-
}
|
|
938
|
-
case "events": {
|
|
939
|
-
if (!input.boardId) return fail("events requires boardId.");
|
|
940
|
-
const eventList = await listKanbanEvents(projectRoot, input.boardId);
|
|
941
|
-
return {
|
|
942
|
-
ok: true,
|
|
943
|
-
message: `${eventList.length} event(s).`,
|
|
944
|
-
events: eventList
|
|
945
|
-
};
|
|
946
|
-
}
|
|
947
|
-
case "queue_health": {
|
|
948
|
-
const health = await getKanbanQueueHealth(projectRoot, {
|
|
949
|
-
...input.boardId !== void 0 ? { boardId: input.boardId } : {}
|
|
950
|
-
});
|
|
951
|
-
return {
|
|
952
|
-
ok: true,
|
|
953
|
-
message: `Counts: startable=${health.counts.startable}, running=${health.counts.running}, stale=${health.staleAssignments.count}.`,
|
|
954
|
-
queueHealth: health
|
|
955
|
-
};
|
|
956
|
-
}
|
|
957
|
-
default:
|
|
958
|
-
return void 0;
|
|
959
|
-
}
|
|
960
|
-
}
|
|
961
|
-
|
|
962
|
-
// src/kanban-contract-actions.ts
|
|
963
|
-
import {
|
|
964
|
-
addContractEdge,
|
|
965
|
-
configureContractGraph,
|
|
966
|
-
evaluateTaskContractGraph,
|
|
967
|
-
getContractGraph,
|
|
968
|
-
removeContractEdge,
|
|
969
|
-
removeContractNode,
|
|
970
|
-
upsertContractNode
|
|
971
|
-
} from "@wrongstack/kanban";
|
|
972
|
-
async function handleKanbanContractAction(projectRoot, input, actor) {
|
|
973
|
-
switch (input.action) {
|
|
974
|
-
case "get_contract_graph": {
|
|
975
|
-
if (!input.boardId) return fail("get_contract_graph requires boardId.");
|
|
976
|
-
const found = await getContractGraph(projectRoot, input.boardId);
|
|
977
|
-
if (!found) return fail("Board not found.");
|
|
978
|
-
const evaluated = input.taskId ? await evaluateTaskContractGraph(projectRoot, input.boardId, input.taskId) : null;
|
|
979
|
-
if (input.taskId && !evaluated) return fail("Task not found on this board.");
|
|
980
|
-
return {
|
|
981
|
-
ok: true,
|
|
982
|
-
message: found.graph ? `Contract map: ${found.graph.nodes.length} node(s), ${found.graph.edges.length} edge(s), enforcement ${found.graph.enforcement}.` : "No contract map on this board yet. Call configure_contract_graph to start one.",
|
|
983
|
-
board: found.board,
|
|
984
|
-
contractGraph: found.graph,
|
|
985
|
-
...evaluated ? { contractEvaluation: evaluated.evaluation } : {}
|
|
986
|
-
};
|
|
987
|
-
}
|
|
988
|
-
case "configure_contract_graph": {
|
|
989
|
-
if (!input.boardId) return fail("configure_contract_graph requires boardId.");
|
|
990
|
-
const enforcement = input.contractEnforcement ?? "advisory";
|
|
991
|
-
const board = await configureContractGraph(projectRoot, input.boardId, enforcement);
|
|
992
|
-
return board ? okBoard(board, `Contract map enforcement set to ${enforcement}.`) : fail("Board not found.");
|
|
993
|
-
}
|
|
994
|
-
case "upsert_contract_node": {
|
|
995
|
-
if (!input.boardId || !input.taskId) {
|
|
996
|
-
return fail("upsert_contract_node requires boardId and taskId.");
|
|
997
|
-
}
|
|
998
|
-
if (!input.contractNodeKind || !input.contractNodeTitle) {
|
|
999
|
-
return fail("upsert_contract_node requires contractNodeKind and contractNodeTitle.");
|
|
1000
|
-
}
|
|
1001
|
-
const waiver = input.contractNodeState === "waived" ? {
|
|
1002
|
-
actor: actor ?? "agent",
|
|
1003
|
-
reason: input.contractWaiverReason ?? "",
|
|
1004
|
-
at: (/* @__PURE__ */ new Date()).toISOString()
|
|
1005
|
-
} : void 0;
|
|
1006
|
-
if (waiver && !waiver.reason.trim()) {
|
|
1007
|
-
return fail("A waived contract node requires contractWaiverReason.");
|
|
1008
|
-
}
|
|
1009
|
-
const result = await upsertContractNode(projectRoot, input.boardId, {
|
|
1010
|
-
taskId: input.taskId,
|
|
1011
|
-
kind: input.contractNodeKind,
|
|
1012
|
-
title: input.contractNodeTitle,
|
|
1013
|
-
...input.contractNodeId !== void 0 ? { id: input.contractNodeId } : {},
|
|
1014
|
-
...input.contractNodeDescription !== void 0 ? { description: input.contractNodeDescription } : {},
|
|
1015
|
-
...input.contractNodeState !== void 0 ? { state: input.contractNodeState } : {},
|
|
1016
|
-
...input.contractNodeEnforcement !== void 0 ? { enforcement: input.contractNodeEnforcement } : {},
|
|
1017
|
-
...input.contractCheckId !== void 0 ? { checkId: input.contractCheckId } : {},
|
|
1018
|
-
...input.contractMetricId !== void 0 ? { metricId: input.contractMetricId } : {},
|
|
1019
|
-
...waiver ? { waiver } : {},
|
|
1020
|
-
...actor !== void 0 ? { createdBy: actor } : {}
|
|
1021
|
-
});
|
|
1022
|
-
if (!result) return fail("Board or task not found.");
|
|
1023
|
-
return {
|
|
1024
|
-
ok: true,
|
|
1025
|
-
message: `Contract node ${result.node.kind} "${result.node.title}" saved (${result.node.id}).`,
|
|
1026
|
-
board: result.board,
|
|
1027
|
-
contractGraph: result.board.contractGraph ?? null
|
|
1028
|
-
};
|
|
1029
|
-
}
|
|
1030
|
-
case "remove_contract_node": {
|
|
1031
|
-
if (!input.boardId || !input.contractNodeId) {
|
|
1032
|
-
return fail("remove_contract_node requires boardId and contractNodeId.");
|
|
1033
|
-
}
|
|
1034
|
-
const board = await removeContractNode(projectRoot, input.boardId, input.contractNodeId);
|
|
1035
|
-
return board ? okBoard(board, "Contract node removed, along with every edge that touched it.") : fail("Contract node not found.");
|
|
1036
|
-
}
|
|
1037
|
-
case "add_contract_edge": {
|
|
1038
|
-
if (!input.boardId || !input.contractEdgeFrom || !input.contractEdgeTo) {
|
|
1039
|
-
return fail("add_contract_edge requires boardId, contractEdgeFrom, and contractEdgeTo.");
|
|
1040
|
-
}
|
|
1041
|
-
if (!input.contractEdgeType) return fail("add_contract_edge requires contractEdgeType.");
|
|
1042
|
-
const result = await addContractEdge(projectRoot, input.boardId, {
|
|
1043
|
-
from: input.contractEdgeFrom,
|
|
1044
|
-
to: input.contractEdgeTo,
|
|
1045
|
-
type: input.contractEdgeType,
|
|
1046
|
-
...input.contractEdgeId !== void 0 ? { id: input.contractEdgeId } : {},
|
|
1047
|
-
...input.contractNodeEnforcement !== void 0 ? { enforcement: input.contractNodeEnforcement } : {},
|
|
1048
|
-
...input.contractEdgeRationale !== void 0 ? { rationale: input.contractEdgeRationale } : {},
|
|
1049
|
-
...actor !== void 0 ? { createdBy: actor } : {}
|
|
1050
|
-
});
|
|
1051
|
-
if (!result) return fail("Board not found.");
|
|
1052
|
-
return {
|
|
1053
|
-
ok: true,
|
|
1054
|
-
message: `Contract edge ${result.edge.type}: ${result.edge.from} \u2192 ${result.edge.to}.`,
|
|
1055
|
-
board: result.board,
|
|
1056
|
-
contractGraph: result.board.contractGraph ?? null
|
|
1057
|
-
};
|
|
1058
|
-
}
|
|
1059
|
-
case "remove_contract_edge": {
|
|
1060
|
-
if (!input.boardId || !input.contractEdgeId) {
|
|
1061
|
-
return fail("remove_contract_edge requires boardId and contractEdgeId.");
|
|
1062
|
-
}
|
|
1063
|
-
const board = await removeContractEdge(projectRoot, input.boardId, input.contractEdgeId);
|
|
1064
|
-
return board ? okBoard(board, "Contract edge removed.") : fail("Contract edge not found.");
|
|
1065
|
-
}
|
|
1066
|
-
default:
|
|
1067
|
-
return void 0;
|
|
1068
|
-
}
|
|
1069
|
-
}
|
|
1070
|
-
|
|
1071
|
-
// src/kanban-decomposition-actions.ts
|
|
1072
|
-
import {
|
|
1073
|
-
assessTaskAtomicity,
|
|
1074
|
-
proposeTaskDecomposition,
|
|
1075
|
-
updateTask,
|
|
1076
|
-
verifyTaskCompletion
|
|
1077
|
-
} from "@wrongstack/kanban";
|
|
1078
|
-
|
|
1079
|
-
// src/kanban-evidence-bridge.ts
|
|
1080
|
-
import { recordCompletedWorkEvidence } from "@wrongstack/core/utils";
|
|
1081
|
-
function kanbanEvidenceKey(boardId, taskId) {
|
|
1082
|
-
return `kanban:${boardId}:${taskId}`;
|
|
1083
|
-
}
|
|
1084
|
-
function kanbanEvidencePointer(boardId, taskId) {
|
|
1085
|
-
return `kanban://${boardId}/${taskId}#verificationReport`;
|
|
1086
|
-
}
|
|
1087
|
-
function recordKanbanVerificationEvidence(ctx, report) {
|
|
1088
|
-
try {
|
|
1089
|
-
const passed = report.checks.filter((check) => check.status === "passed").length;
|
|
1090
|
-
const completedAt = Date.parse(report.completedAt);
|
|
1091
|
-
recordCompletedWorkEvidence(ctx, {
|
|
1092
|
-
key: kanbanEvidenceKey(report.boardId, report.taskId),
|
|
1093
|
-
source: "verification",
|
|
1094
|
-
summary: `${report.taskTitle} \u2014 verification ${report.verdict} (${passed}/${report.checks.length} checks)`,
|
|
1095
|
-
...Number.isFinite(completedAt) ? { completedAt } : {},
|
|
1096
|
-
evidence: kanbanEvidencePointer(report.boardId, report.taskId)
|
|
1097
|
-
});
|
|
1098
|
-
} catch {
|
|
1099
|
-
}
|
|
1100
|
-
}
|
|
1101
|
-
|
|
1102
|
-
// src/kanban-decomposition-actions.ts
|
|
1103
|
-
async function handleKanbanDecompositionAction(projectRoot, input, ctx) {
|
|
1104
|
-
switch (input.action) {
|
|
1105
|
-
case "assess_atomicity": {
|
|
1106
|
-
if (!input.boardId || !input.taskId) {
|
|
1107
|
-
return fail("assess_atomicity requires boardId and taskId.");
|
|
1108
|
-
}
|
|
1109
|
-
const result = await assessTaskAtomicity(projectRoot, input.boardId, input.taskId, {
|
|
1110
|
-
assessedBy: "agent",
|
|
1111
|
-
...ctx.agentId !== void 0 ? { eventContext: { actor: ctx.agentId } } : {}
|
|
1112
|
-
});
|
|
1113
|
-
if (!result) return fail("Task not found.");
|
|
1114
|
-
const failing = result.assessment.criteria.filter((entry) => entry.score < 1).map((entry) => entry.reason);
|
|
1115
|
-
const guidance = result.assessment.verdict === "needs_decomposition" ? ` This task should be split before dispatch \u2014 call propose_decomposition with 2+ subtasks (each with one verifiable success criterion). Reasons: ${failing.join(" | ")}` : result.assessment.verdict === "composite" ? " Container task: work happens in its children; it is verified via subtask aggregation." : "";
|
|
1116
|
-
return okTask(
|
|
1117
|
-
result.board,
|
|
1118
|
-
result.task,
|
|
1119
|
-
`Atomicity verdict: ${result.assessment.verdict} (score ${result.assessment.score}).${guidance}`
|
|
1120
|
-
);
|
|
1121
|
-
}
|
|
1122
|
-
case "propose_decomposition": {
|
|
1123
|
-
if (!input.boardId || !input.taskId || !input.subtasks?.length) {
|
|
1124
|
-
return fail("propose_decomposition requires boardId, taskId, and subtasks (2+).");
|
|
1125
|
-
}
|
|
1126
|
-
if (input.subtasks.length < 2) {
|
|
1127
|
-
return fail("propose_decomposition requires at least two subtasks.");
|
|
1128
|
-
}
|
|
1129
|
-
const invalid = input.subtasks.find(
|
|
1130
|
-
(subtask) => typeof subtask?.title !== "string" || !subtask.title.trim()
|
|
1131
|
-
);
|
|
1132
|
-
if (invalid) return fail("Every proposed subtask needs a non-blank title.");
|
|
1133
|
-
const result = await proposeTaskDecomposition(
|
|
1134
|
-
projectRoot,
|
|
1135
|
-
input.boardId,
|
|
1136
|
-
input.taskId,
|
|
1137
|
-
{
|
|
1138
|
-
subtasks: input.subtasks,
|
|
1139
|
-
...input.note !== void 0 ? { rationale: input.note } : {},
|
|
1140
|
-
...ctx.agentId !== void 0 ? { proposedBy: ctx.agentId } : {}
|
|
1141
|
-
},
|
|
1142
|
-
ctx.agentId !== void 0 ? { actor: ctx.agentId } : {}
|
|
1143
|
-
);
|
|
1144
|
-
if (!result) return fail("Task not found.");
|
|
1145
|
-
const message = result.proposal.status === "applied" ? `Decomposition applied: ${result.proposal.appliedChildTaskIds?.length ?? 0} child tasks created (parent marked atomic).` : 'Decomposition proposal recorded \u2014 awaiting approval (board policy is "propose"). It can be approved from the WebUI or via update_task.';
|
|
1146
|
-
return okTask(result.board, result.task, message);
|
|
1147
|
-
}
|
|
1148
|
-
case "verify_completion": {
|
|
1149
|
-
if (!input.boardId || !input.taskId) {
|
|
1150
|
-
return fail("verify_completion requires boardId and taskId.");
|
|
1151
|
-
}
|
|
1152
|
-
const verResult = await verifyTaskCompletion(projectRoot, input.boardId, input.taskId);
|
|
1153
|
-
const persistedBoard = await updateTask(projectRoot, input.boardId, input.taskId, {
|
|
1154
|
-
verificationReport: verResult.report,
|
|
1155
|
-
successCriteria: verResult.task.successCriteria
|
|
1156
|
-
});
|
|
1157
|
-
if (!persistedBoard) {
|
|
1158
|
-
return {
|
|
1159
|
-
ok: false,
|
|
1160
|
-
verdict: verResult.report.verdict,
|
|
1161
|
-
message: `Verification succeeded but persist failed: ${verResult.report.markdownSummary}. Board may be stale \u2014 re-run verify_completion.`,
|
|
1162
|
-
board: verResult.board
|
|
1163
|
-
};
|
|
1164
|
-
}
|
|
1165
|
-
recordKanbanVerificationEvidence(ctx, verResult.report);
|
|
1166
|
-
const freshTask = persistedBoard.tasks?.find((t) => t.id === input.taskId);
|
|
1167
|
-
const deterministicVerdicts = ["passed", "failed", "needs_human", "incomplete"];
|
|
1168
|
-
return {
|
|
1169
|
-
ok: deterministicVerdicts.includes(
|
|
1170
|
-
verResult.report.verdict
|
|
1171
|
-
),
|
|
1172
|
-
verdict: verResult.report.verdict,
|
|
1173
|
-
message: verResult.report.markdownSummary,
|
|
1174
|
-
board: persistedBoard,
|
|
1175
|
-
task: freshTask ?? verResult.task
|
|
1176
|
-
};
|
|
1177
|
-
}
|
|
1178
|
-
default:
|
|
1179
|
-
return void 0;
|
|
1180
|
-
}
|
|
1181
|
-
}
|
|
1182
|
-
|
|
1183
|
-
// src/kanban-detail-actions.ts
|
|
1184
|
-
import {
|
|
1185
|
-
addCheckToTask,
|
|
1186
|
-
addDependency,
|
|
1187
|
-
addGoalMetricToTask,
|
|
1188
|
-
addLinkToTask,
|
|
1189
|
-
addNoteToTask,
|
|
1190
|
-
getKanbanWorkbench,
|
|
1191
|
-
removeCheckFromTask,
|
|
1192
|
-
updateCheckOnTask,
|
|
1193
|
-
updateGoalMetricOnTask
|
|
1194
|
-
} from "@wrongstack/kanban";
|
|
1195
|
-
async function handleKanbanDetailAction(projectRoot, input) {
|
|
1196
|
-
switch (input.action) {
|
|
1197
|
-
case "workbench": {
|
|
1198
|
-
const workbench = await getKanbanWorkbench(projectRoot, {
|
|
1199
|
-
...input.limit !== void 0 ? { limitPerLane: input.limit, alertLimit: input.limit } : {}
|
|
1200
|
-
});
|
|
1201
|
-
return {
|
|
1202
|
-
ok: true,
|
|
1203
|
-
message: `${workbench.totals.now} now, ${workbench.totals.next} next, ${workbench.totals.blocked} blocked, ${workbench.totals.review} review; ${workbench.alertTotal} alert(s).`,
|
|
1204
|
-
workbench
|
|
1205
|
-
};
|
|
1206
|
-
}
|
|
1207
|
-
case "add_dependency": {
|
|
1208
|
-
if (!input.boardId || !input.taskId || !input.dependencyTaskId) {
|
|
1209
|
-
return fail("add_dependency requires boardId, taskId, and dependencyTaskId.");
|
|
1210
|
-
}
|
|
1211
|
-
const board = await addDependency(
|
|
1212
|
-
projectRoot,
|
|
1213
|
-
input.boardId,
|
|
1214
|
-
input.taskId,
|
|
1215
|
-
input.dependencyTaskId
|
|
1216
|
-
);
|
|
1217
|
-
return board ? okBoard(board, "Dependency added.") : fail("Task not found.");
|
|
1218
|
-
}
|
|
1219
|
-
case "add_goal_metric": {
|
|
1220
|
-
if (!input.boardId || !input.taskId || !input.metricName) {
|
|
1221
|
-
return fail("add_goal_metric requires boardId, taskId, and metricName.");
|
|
1222
|
-
}
|
|
1223
|
-
const board = await addGoalMetricToTask(projectRoot, input.boardId, input.taskId, {
|
|
1224
|
-
name: input.metricName,
|
|
1225
|
-
...input.metricStatus !== void 0 ? { status: input.metricStatus } : {},
|
|
1226
|
-
...input.metricTarget !== void 0 ? { target: input.metricTarget } : {},
|
|
1227
|
-
...input.metricCurrent !== void 0 ? { current: input.metricCurrent } : {},
|
|
1228
|
-
...input.metricDirection !== void 0 ? { direction: input.metricDirection } : {},
|
|
1229
|
-
...input.metricUnit !== void 0 ? { unit: input.metricUnit } : {},
|
|
1230
|
-
...input.metricNotes !== void 0 ? { notes: input.metricNotes } : {}
|
|
1231
|
-
});
|
|
1232
|
-
return board ? okBoard(board, "Goal metric added.") : fail("Task not found.");
|
|
1233
|
-
}
|
|
1234
|
-
case "update_goal_metric": {
|
|
1235
|
-
if (!input.boardId || !input.taskId || !input.metricId) {
|
|
1236
|
-
return fail("update_goal_metric requires boardId, taskId, and metricId.");
|
|
1237
|
-
}
|
|
1238
|
-
const board = await updateGoalMetricOnTask(
|
|
1239
|
-
projectRoot,
|
|
1240
|
-
input.boardId,
|
|
1241
|
-
input.taskId,
|
|
1242
|
-
input.metricId,
|
|
1243
|
-
{
|
|
1244
|
-
...input.metricName !== void 0 ? { name: input.metricName } : {},
|
|
1245
|
-
...input.metricStatus !== void 0 ? { status: input.metricStatus } : {},
|
|
1246
|
-
...input.metricTarget !== void 0 ? { target: input.metricTarget } : {},
|
|
1247
|
-
...input.metricCurrent !== void 0 ? { current: input.metricCurrent } : {},
|
|
1248
|
-
...input.metricDirection !== void 0 ? { direction: input.metricDirection } : {},
|
|
1249
|
-
...input.metricUnit !== void 0 ? { unit: input.metricUnit } : {},
|
|
1250
|
-
...input.metricNotes !== void 0 ? { notes: input.metricNotes } : {}
|
|
1251
|
-
}
|
|
1252
|
-
);
|
|
1253
|
-
return board ? okBoard(board, "Goal metric updated.") : fail("Metric not found.");
|
|
1254
|
-
}
|
|
1255
|
-
case "add_check": {
|
|
1256
|
-
if (!input.boardId || !input.taskId || !input.checkDescription) {
|
|
1257
|
-
return fail("add_check requires boardId, taskId, and checkDescription.");
|
|
1258
|
-
}
|
|
1259
|
-
const board = await addCheckToTask(projectRoot, input.boardId, input.taskId, {
|
|
1260
|
-
description: input.checkDescription,
|
|
1261
|
-
type: input.checkType ?? "manual",
|
|
1262
|
-
status: input.checkStatus,
|
|
1263
|
-
...input.checkNotes !== void 0 ? { notes: input.checkNotes } : {}
|
|
1264
|
-
});
|
|
1265
|
-
return board ? okBoard(board, "Check added.") : fail("Task not found.");
|
|
1266
|
-
}
|
|
1267
|
-
case "update_check": {
|
|
1268
|
-
if (!input.boardId || !input.taskId || !input.checkId) {
|
|
1269
|
-
return fail("update_check requires boardId, taskId, and checkId.");
|
|
1270
|
-
}
|
|
1271
|
-
const board = await updateCheckOnTask(
|
|
1272
|
-
projectRoot,
|
|
1273
|
-
input.boardId,
|
|
1274
|
-
input.taskId,
|
|
1275
|
-
input.checkId,
|
|
1276
|
-
{
|
|
1277
|
-
...input.checkDescription !== void 0 ? { description: input.checkDescription } : {},
|
|
1278
|
-
...input.checkStatus !== void 0 ? { status: input.checkStatus } : {},
|
|
1279
|
-
// Promoting an existing manual criterion to an executable one is the
|
|
1280
|
-
// common repair: the card was written before anyone knew the command.
|
|
1281
|
-
...input.checkType !== void 0 ? { type: input.checkType } : {},
|
|
1282
|
-
...input.checkNotes !== void 0 ? { notes: input.checkNotes } : {}
|
|
1283
|
-
}
|
|
1284
|
-
);
|
|
1285
|
-
return board ? okBoard(board, "Check updated.") : fail("Check not found.");
|
|
1286
|
-
}
|
|
1287
|
-
case "remove_check": {
|
|
1288
|
-
if (!input.boardId || !input.taskId || !input.checkId) {
|
|
1289
|
-
return fail("remove_check requires boardId, taskId, and checkId.");
|
|
1290
|
-
}
|
|
1291
|
-
const board = await removeCheckFromTask(
|
|
1292
|
-
projectRoot,
|
|
1293
|
-
input.boardId,
|
|
1294
|
-
input.taskId,
|
|
1295
|
-
input.checkId
|
|
1296
|
-
);
|
|
1297
|
-
return board ? okBoard(board, "Acceptance criterion removed.") : fail("Check not found on this task.");
|
|
1298
|
-
}
|
|
1299
|
-
case "add_note": {
|
|
1300
|
-
if (!input.boardId || !input.taskId || !input.note)
|
|
1301
|
-
return fail("add_note requires boardId, taskId, and note.");
|
|
1302
|
-
const board = await addNoteToTask(projectRoot, input.boardId, input.taskId, {
|
|
1303
|
-
author: input.author ?? "agent",
|
|
1304
|
-
content: input.note
|
|
1305
|
-
});
|
|
1306
|
-
return board ? okBoard(board, "Note added.") : fail("Task not found.");
|
|
1307
|
-
}
|
|
1308
|
-
case "add_link": {
|
|
1309
|
-
if (!input.boardId || !input.taskId || !input.url)
|
|
1310
|
-
return fail("add_link requires boardId, taskId, and url.");
|
|
1311
|
-
const board = await addLinkToTask(projectRoot, input.boardId, input.taskId, {
|
|
1312
|
-
url: input.url,
|
|
1313
|
-
type: input.linkType ?? "url",
|
|
1314
|
-
...input.linkTitle !== void 0 ? { title: input.linkTitle } : {}
|
|
1315
|
-
});
|
|
1316
|
-
return board ? okBoard(board, "Link added.") : fail("Task not found.");
|
|
1317
|
-
}
|
|
1318
|
-
case "split_atomic": {
|
|
1319
|
-
if (!input.boardId || !input.taskId || !input.childTitles?.length) {
|
|
1320
|
-
return fail("split_atomic requires boardId, taskId, and childTitles (at least one).");
|
|
1321
|
-
}
|
|
1322
|
-
return handleSplitTask(projectRoot, input, { atomic: true });
|
|
1323
|
-
}
|
|
1324
|
-
default:
|
|
1325
|
-
return void 0;
|
|
1326
|
-
}
|
|
1327
|
-
}
|
|
1328
|
-
|
|
1329
|
-
// src/kanban-lifecycle-actions.ts
|
|
1330
|
-
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
1331
|
-
import {
|
|
1332
|
-
addTask as addTask2,
|
|
1333
|
-
assignTask,
|
|
1334
|
-
claimReadyTask,
|
|
1335
|
-
copyTaskToBoard,
|
|
1336
|
-
evaluateContractGraphReadiness,
|
|
1337
|
-
finalizeTaskCompletion,
|
|
1338
|
-
getBoard as getBoard4,
|
|
1339
|
-
getTask,
|
|
1340
|
-
getTaskChain,
|
|
1341
|
-
heartbeatTaskAssignment,
|
|
1342
|
-
mergeTasks,
|
|
1343
|
-
moveTask,
|
|
1344
|
-
recoverStaleTaskAssignments,
|
|
1345
|
-
releaseTaskClaim,
|
|
1346
|
-
removeTask,
|
|
1347
|
-
repairManagedTaskProjection,
|
|
1348
|
-
resolveAutoAccept,
|
|
1349
|
-
setTaskChain,
|
|
1350
|
-
stripLifecycleIssues,
|
|
1351
|
-
transferTaskToBoard,
|
|
1352
|
-
transitionTask,
|
|
1353
|
-
updateTask as updateTask2,
|
|
1354
|
-
updateTaskAssignment,
|
|
1355
|
-
verifyTaskCompletion as verifyTaskCompletion2
|
|
1356
|
-
} from "@wrongstack/kanban";
|
|
1357
|
-
|
|
1358
|
-
// src/kanban-task-inputs.ts
|
|
1359
|
-
import { randomUUID } from "node:crypto";
|
|
1360
|
-
import { clampSubagentCapabilities } from "@wrongstack/core/security";
|
|
1361
|
-
function taskInput(input) {
|
|
1362
|
-
const assignment = hasAssignmentInput(input) ? assignmentForTaskCreate(input) : void 0;
|
|
1363
|
-
return {
|
|
1364
|
-
title: input.title ?? "",
|
|
1365
|
-
columnId: input.columnId,
|
|
1366
|
-
description: input.description,
|
|
1367
|
-
dueDate: input.dueDate,
|
|
1368
|
-
priority: input.priority,
|
|
1369
|
-
...input.taskType !== void 0 ? { type: input.taskType } : {},
|
|
1370
|
-
status: input.status,
|
|
1371
|
-
labels: input.labels,
|
|
1372
|
-
...assignment?.agentId ?? assignment?.role ?? assignment?.name ? { assignedAgent: assignment.agentId ?? assignment.role ?? assignment.name } : {},
|
|
1373
|
-
...input.assignee ?? assignment?.name ?? assignment?.agentId ? { assignee: input.assignee ?? assignment?.name ?? assignment?.agentId } : {},
|
|
1374
|
-
...mergedDependsOn(input) ? { dependsOn: mergedDependsOn(input) } : {},
|
|
1375
|
-
...input.estimatedHours !== void 0 ? { estimatedHours: input.estimatedHours } : {},
|
|
1376
|
-
...input.actualHours !== void 0 ? { actualHours: input.actualHours } : {},
|
|
1377
|
-
...assignment ? { assignment } : {},
|
|
1378
|
-
...input.order !== void 0 ? { order: input.order } : {},
|
|
1379
|
-
...input.retryPolicy !== void 0 ? { retryPolicy: input.retryPolicy } : {},
|
|
1380
|
-
...input.costCeilingUsd !== void 0 ? { costCeilingUsd: input.costCeilingUsd } : {},
|
|
1381
|
-
// The system prompt has always told the model it may "set atomic: true"
|
|
1382
|
-
// when creating a composite parent. It could not: the field reached
|
|
1383
|
-
// neither the create input nor the patch, so the instruction described a
|
|
1384
|
-
// capability that did not exist and the attempt was silently dropped.
|
|
1385
|
-
...input.atomic !== void 0 ? { atomic: input.atomic } : {},
|
|
1386
|
-
...input.childTitles !== void 0 ? { childTaskIds: input.childTitles } : {},
|
|
1387
|
-
...input.checkDescription !== void 0 ? {
|
|
1388
|
-
successCriteria: [
|
|
1389
|
-
{
|
|
1390
|
-
id: randomUUID(),
|
|
1391
|
-
description: input.checkDescription,
|
|
1392
|
-
// `manual` only as the fallback. Hard-coding it here meant every
|
|
1393
|
-
// agent-authored criterion was unverifiable by construction: the
|
|
1394
|
-
// deterministic plugins never matched, the registry passed the
|
|
1395
|
-
// hand-set status straight through, and "verified" collapsed into
|
|
1396
|
-
// "the author ticked its own box".
|
|
1397
|
-
type: input.checkType ?? "manual",
|
|
1398
|
-
status: input.checkStatus ?? "pending",
|
|
1399
|
-
...input.checkNotes !== void 0 ? { notes: input.checkNotes } : {}
|
|
1400
|
-
}
|
|
1401
|
-
]
|
|
1402
|
-
} : {},
|
|
1403
|
-
...input.metricName !== void 0 ? {
|
|
1404
|
-
goalMetrics: [
|
|
1405
|
-
{
|
|
1406
|
-
id: randomUUID(),
|
|
1407
|
-
name: input.metricName,
|
|
1408
|
-
status: input.metricStatus ?? "pending",
|
|
1409
|
-
...input.metricTarget !== void 0 ? { target: input.metricTarget } : {},
|
|
1410
|
-
...input.metricCurrent !== void 0 ? { current: input.metricCurrent } : {},
|
|
1411
|
-
...input.metricDirection !== void 0 ? { direction: input.metricDirection } : {},
|
|
1412
|
-
...input.metricUnit !== void 0 ? { unit: input.metricUnit } : {},
|
|
1413
|
-
...input.metricNotes !== void 0 ? { notes: input.metricNotes } : {}
|
|
1414
|
-
}
|
|
1415
|
-
]
|
|
1416
|
-
} : {},
|
|
1417
|
-
...input.url !== void 0 ? {
|
|
1418
|
-
links: [
|
|
1419
|
-
{
|
|
1420
|
-
url: input.url,
|
|
1421
|
-
type: input.linkType ?? "url",
|
|
1422
|
-
...input.linkTitle !== void 0 ? { title: input.linkTitle } : {}
|
|
1423
|
-
}
|
|
1424
|
-
]
|
|
1425
|
-
} : {},
|
|
1426
|
-
...input.note !== void 0 ? {
|
|
1427
|
-
notes: [
|
|
1428
|
-
{
|
|
1429
|
-
id: randomUUID(),
|
|
1430
|
-
author: input.author ?? "agent",
|
|
1431
|
-
content: input.note,
|
|
1432
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1433
|
-
}
|
|
1434
|
-
]
|
|
1435
|
-
} : {},
|
|
1436
|
-
...[input.graphId, input.specId, input.specRequirementId].some((value) => value !== void 0) ? {
|
|
1437
|
-
origin: {
|
|
1438
|
-
system: input.sourceSystem ?? "kanban-tool",
|
|
1439
|
-
...input.graphId !== void 0 ? { graphId: input.graphId } : {},
|
|
1440
|
-
...input.specId !== void 0 ? { specId: input.specId } : {},
|
|
1441
|
-
...input.specRequirementId !== void 0 ? { specRequirementId: input.specRequirementId } : {},
|
|
1442
|
-
...input.phaseId !== void 0 ? { phaseId: input.phaseId } : {}
|
|
1443
|
-
}
|
|
1444
|
-
} : {}
|
|
1445
|
-
};
|
|
1446
|
-
}
|
|
1447
|
-
function mergedDependsOn(input) {
|
|
1448
|
-
if (input.dependsOn === void 0 && input.dependencyTaskId === void 0) return void 0;
|
|
1449
|
-
return [
|
|
1450
|
-
...input.dependsOn ?? [],
|
|
1451
|
-
...input.dependencyTaskId !== void 0 ? [input.dependencyTaskId] : []
|
|
1452
|
-
].filter((id, i, arr) => id && arr.indexOf(id) === i);
|
|
1453
|
-
}
|
|
1454
|
-
function taskPatch(input) {
|
|
1455
|
-
return {
|
|
1456
|
-
title: input.title,
|
|
1457
|
-
description: input.description,
|
|
1458
|
-
dueDate: input.dueDate,
|
|
1459
|
-
columnId: input.columnId,
|
|
1460
|
-
order: input.order,
|
|
1461
|
-
priority: input.priority,
|
|
1462
|
-
...input.taskType !== void 0 ? { type: input.taskType } : {},
|
|
1463
|
-
status: input.status,
|
|
1464
|
-
labels: input.labels,
|
|
1465
|
-
assignedAgent: input.agentId,
|
|
1466
|
-
...mergedDependsOn(input) !== void 0 ? { dependsOn: mergedDependsOn(input) } : {},
|
|
1467
|
-
// `atomic` and `childTaskIds` are the composite-parent contract, and the
|
|
1468
|
-
// managed gate reads both: an `atomic` parent may not move forward without
|
|
1469
|
-
// children, and may not reach Done until every child is completed. The
|
|
1470
|
-
// manager has always accepted both on a patch; only this surface withheld
|
|
1471
|
-
// them, so `split_atomic` was a one-way door — delete the children and the
|
|
1472
|
-
// parent was stranded with no way to declare itself a leaf again.
|
|
1473
|
-
...input.atomic !== void 0 ? { atomic: input.atomic } : {},
|
|
1474
|
-
...input.childTaskIds !== void 0 ? { childTaskIds: input.childTaskIds } : {},
|
|
1475
|
-
...input.estimatedHours !== void 0 ? { estimatedHours: input.estimatedHours } : {},
|
|
1476
|
-
...input.actualHours !== void 0 ? { actualHours: input.actualHours } : {}
|
|
1477
|
-
};
|
|
1478
|
-
}
|
|
1479
|
-
function clampRequestedCapabilities(requested) {
|
|
1480
|
-
if (requested === void 0) return void 0;
|
|
1481
|
-
return clampSubagentCapabilities(requested).granted;
|
|
1482
|
-
}
|
|
1483
|
-
function assignmentInput(input) {
|
|
1484
|
-
return {
|
|
1485
|
-
agentId: input.agentId,
|
|
1486
|
-
name: input.name,
|
|
1487
|
-
role: input.role,
|
|
1488
|
-
provider: input.provider,
|
|
1489
|
-
model: input.model,
|
|
1490
|
-
fallbackProfile: input.fallbackProfile,
|
|
1491
|
-
fallbackModels: input.fallbackModels,
|
|
1492
|
-
tools: input.tools,
|
|
1493
|
-
allowedCapabilities: clampRequestedCapabilities(input.allowedCapabilities),
|
|
1494
|
-
assignee: input.assignee,
|
|
1495
|
-
leaseId: input.leaseId,
|
|
1496
|
-
claimedAt: input.claimedAt,
|
|
1497
|
-
heartbeatAt: input.heartbeatAt,
|
|
1498
|
-
leaseExpiresAt: input.leaseExpiresAt,
|
|
1499
|
-
attempt: input.attempt,
|
|
1500
|
-
maxAttempts: input.maxAttempts,
|
|
1501
|
-
costCeilingUsd: input.costCeilingUsd,
|
|
1502
|
-
retryPolicy: input.retryPolicy,
|
|
1503
|
-
lastFailureKind: input.lastFailureKind
|
|
1504
|
-
};
|
|
1505
|
-
}
|
|
1506
|
-
function hasAssignmentInput(input) {
|
|
1507
|
-
return input.agentId !== void 0 || input.name !== void 0 || input.role !== void 0 || input.provider !== void 0 || input.model !== void 0 || input.fallbackProfile !== void 0 || input.fallbackModels !== void 0 || input.tools !== void 0 || input.allowedCapabilities !== void 0 || input.assignee !== void 0 || input.leaseId !== void 0 || input.claimedAt !== void 0 || input.heartbeatAt !== void 0 || input.leaseExpiresAt !== void 0 || input.attempt !== void 0 || input.maxAttempts !== void 0 || input.costCeilingUsd !== void 0 || input.retryPolicy !== void 0 || input.lastFailureKind !== void 0 || input.assignmentStatus !== void 0;
|
|
1508
|
-
}
|
|
1509
|
-
function assignmentForTaskCreate(input) {
|
|
1510
|
-
return {
|
|
1511
|
-
status: input.assignmentStatus ?? "assigned",
|
|
1512
|
-
...input.agentId !== void 0 ? { agentId: input.agentId } : {},
|
|
1513
|
-
...input.name !== void 0 ? { name: input.name } : {},
|
|
1514
|
-
...input.role !== void 0 ? { role: input.role } : {},
|
|
1515
|
-
...input.provider !== void 0 ? { provider: input.provider } : {},
|
|
1516
|
-
...input.model !== void 0 ? { model: input.model } : {},
|
|
1517
|
-
...input.fallbackProfile !== void 0 ? { fallbackProfile: input.fallbackProfile } : {},
|
|
1518
|
-
...input.fallbackModels !== void 0 ? { fallbackModels: input.fallbackModels } : {},
|
|
1519
|
-
...input.tools !== void 0 ? { tools: input.tools } : {},
|
|
1520
|
-
...input.allowedCapabilities !== void 0 ? { allowedCapabilities: clampRequestedCapabilities(input.allowedCapabilities) } : {},
|
|
1521
|
-
...input.leaseId !== void 0 ? { leaseId: input.leaseId } : {},
|
|
1522
|
-
...input.claimedAt !== void 0 ? { claimedAt: input.claimedAt } : {},
|
|
1523
|
-
...input.heartbeatAt !== void 0 ? { heartbeatAt: input.heartbeatAt } : {},
|
|
1524
|
-
...input.leaseExpiresAt !== void 0 ? { leaseExpiresAt: input.leaseExpiresAt } : {},
|
|
1525
|
-
...input.attempt !== void 0 ? { attempt: input.attempt } : {},
|
|
1526
|
-
...input.maxAttempts !== void 0 ? { maxAttempts: input.maxAttempts } : {},
|
|
1527
|
-
...input.costCeilingUsd !== void 0 ? { costCeilingUsd: input.costCeilingUsd } : {},
|
|
1528
|
-
...input.retryPolicy !== void 0 ? { retryPolicy: input.retryPolicy } : {},
|
|
1529
|
-
...input.lastFailureKind !== void 0 ? { lastFailureKind: input.lastFailureKind } : {}
|
|
1530
|
-
};
|
|
1531
|
-
}
|
|
1532
|
-
|
|
1533
|
-
// src/kanban-lifecycle-actions.ts
|
|
1534
|
-
async function syncContextTask(ctx, task, options = {}) {
|
|
1535
|
-
if (!ctx?.state || !task) return;
|
|
1536
|
-
try {
|
|
1537
|
-
await applySessionKanbanTaskToSource2(ctx, task, options);
|
|
1538
|
-
} catch {
|
|
1539
|
-
}
|
|
1540
|
-
}
|
|
1541
|
-
async function handleKanbanLifecycleAction(projectRoot, input, ctx) {
|
|
1542
|
-
switch (input.action) {
|
|
1543
|
-
case "add_task": {
|
|
1544
|
-
if (!input.boardId || !input.title) return fail("add_task requires boardId and title.");
|
|
1545
|
-
const result = await addTask2(projectRoot, input.boardId, taskInput(input));
|
|
1546
|
-
if (!result) return fail("Board not found.");
|
|
1547
|
-
await syncContextTask(ctx, result.task);
|
|
1548
|
-
return okTask(result.board, result.task, `Task added.${atomicityNudge(result.task)}`);
|
|
1549
|
-
}
|
|
1550
|
-
case "split_task": {
|
|
1551
|
-
if (!input.boardId || !input.taskId || !input.childTitles?.length) {
|
|
1552
|
-
return fail("split_task requires boardId, taskId, and childTitles.");
|
|
1553
|
-
}
|
|
1554
|
-
return handleSplitTask(projectRoot, input, {});
|
|
1555
|
-
}
|
|
1556
|
-
case "merge_tasks": {
|
|
1557
|
-
if (!input.boardId || !input.taskIds?.length || !input.title) {
|
|
1558
|
-
return fail("merge_tasks requires boardId, taskIds, and title.");
|
|
1559
|
-
}
|
|
1560
|
-
const result = await mergeTasks(projectRoot, input.boardId, {
|
|
1561
|
-
taskIds: input.taskIds,
|
|
1562
|
-
title: input.title,
|
|
1563
|
-
...input.description !== void 0 ? { description: input.description } : {},
|
|
1564
|
-
...input.targetColumnId !== void 0 ? { targetColumnId: input.targetColumnId } : {},
|
|
1565
|
-
...input.preserveAssignment !== void 0 ? { preserveAssignment: input.preserveAssignment } : {},
|
|
1566
|
-
...input.closeSourceTasks !== void 0 ? { closeSourceTasks: input.closeSourceTasks } : {}
|
|
1567
|
-
});
|
|
1568
|
-
return result ? okTask(result.board, result.task, "Tasks merged.") : fail("Board or task not found.");
|
|
1569
|
-
}
|
|
1570
|
-
case "copy_task": {
|
|
1571
|
-
if (!input.boardId || !input.taskId || !input.targetBoardId) {
|
|
1572
|
-
return fail("copy_task requires boardId, taskId, and targetBoardId.");
|
|
1573
|
-
}
|
|
1574
|
-
const result = await copyTaskToBoard(
|
|
1575
|
-
projectRoot,
|
|
1576
|
-
input.boardId,
|
|
1577
|
-
input.taskId,
|
|
1578
|
-
input.targetBoardId,
|
|
1579
|
-
{
|
|
1580
|
-
...input.targetColumnId !== void 0 ? { targetColumnId: input.targetColumnId } : {},
|
|
1581
|
-
...input.order !== void 0 ? { targetOrder: input.order } : {},
|
|
1582
|
-
...input.preserveAssignment !== void 0 ? { preserveAssignment: input.preserveAssignment } : {},
|
|
1583
|
-
...input.preserveDependencies !== void 0 ? { preserveDependencies: input.preserveDependencies } : {}
|
|
1584
|
-
}
|
|
1585
|
-
);
|
|
1586
|
-
return result ? okTask(result.targetBoard, result.task, "Task copied to target board.") : fail("Board or task not found.");
|
|
1587
|
-
}
|
|
1588
|
-
case "transfer_task": {
|
|
1589
|
-
if (!input.boardId || !input.taskId || !input.targetBoardId) {
|
|
1590
|
-
return fail("transfer_task requires boardId, taskId, and targetBoardId.");
|
|
1591
|
-
}
|
|
1592
|
-
const result = await transferTaskToBoard(
|
|
1593
|
-
projectRoot,
|
|
1594
|
-
input.boardId,
|
|
1595
|
-
input.taskId,
|
|
1596
|
-
input.targetBoardId,
|
|
1597
|
-
{
|
|
1598
|
-
...input.targetColumnId !== void 0 ? { targetColumnId: input.targetColumnId } : {},
|
|
1599
|
-
...input.order !== void 0 ? { targetOrder: input.order } : {},
|
|
1600
|
-
...input.preserveAssignment !== void 0 ? { preserveAssignment: input.preserveAssignment } : {},
|
|
1601
|
-
...input.preserveDependencies !== void 0 ? { preserveDependencies: input.preserveDependencies } : {}
|
|
1602
|
-
}
|
|
1603
|
-
);
|
|
1604
|
-
return result ? okTask(result.targetBoard, result.task, "Task transferred to target board.") : fail("Board or task not found.");
|
|
1605
|
-
}
|
|
1606
|
-
case "get_task": {
|
|
1607
|
-
if (!input.boardId || !input.taskId) return fail("get_task requires boardId and taskId.");
|
|
1608
|
-
const task = await getTask(projectRoot, input.boardId, input.taskId);
|
|
1609
|
-
return task ? { ok: true, message: "Task loaded.", task } : fail("Task not found.");
|
|
1610
|
-
}
|
|
1611
|
-
case "start_task": {
|
|
1612
|
-
if (!input.boardId || !input.taskId || !input.author || !input.transitionComment) {
|
|
1613
|
-
return fail("start_task requires boardId, taskId, author, and transitionComment.");
|
|
1614
|
-
}
|
|
1615
|
-
let board = await getBoard4(projectRoot, input.boardId);
|
|
1616
|
-
let task = board?.tasks.find((candidate) => candidate.id === input.taskId);
|
|
1617
|
-
if (!board || !task) return fail("Board or task not found.");
|
|
1618
|
-
const readiness = evaluateContractGraphReadiness(board, task.id);
|
|
1619
|
-
if (!readiness.ready) {
|
|
1620
|
-
return fail(
|
|
1621
|
-
`Task is not implementation-ready: ${readiness.issues.map((issue) => issue.message).join(" | ")}`
|
|
1622
|
-
);
|
|
1623
|
-
}
|
|
1624
|
-
if (board.lifecycle?.mode !== "managed") {
|
|
1625
|
-
const now = /* @__PURE__ */ new Date();
|
|
1626
|
-
const assigned = await updateTaskAssignment(projectRoot, board.id, task.id, {
|
|
1627
|
-
status: "running",
|
|
1628
|
-
agentId: input.agentId ?? input.author,
|
|
1629
|
-
leaseId: input.leaseId ?? randomUUID2(),
|
|
1630
|
-
claimedAt: input.claimedAt ?? now.toISOString(),
|
|
1631
|
-
heartbeatAt: input.heartbeatAt ?? now.toISOString(),
|
|
1632
|
-
leaseExpiresAt: input.leaseExpiresAt ?? new Date(now.getTime() + 15 * 6e4).toISOString(),
|
|
1633
|
-
attempt: input.attempt ?? 1,
|
|
1634
|
-
maxAttempts: input.maxAttempts ?? 3
|
|
1635
|
-
});
|
|
1636
|
-
if (!assigned) return fail("Task assignment could not be started.");
|
|
1637
|
-
const started = await updateTask2(projectRoot, board.id, task.id, {
|
|
1638
|
-
status: "in_progress"
|
|
1639
|
-
});
|
|
1640
|
-
const current = started ?? assigned;
|
|
1641
|
-
const claimed = task;
|
|
1642
|
-
const currentTask = current.tasks.find((candidate) => candidate.id === claimed.id) ?? claimed;
|
|
1643
|
-
ctx.setCurrentKanbanTask?.(currentTask.id, current.id);
|
|
1644
|
-
return okTask(
|
|
1645
|
-
current,
|
|
1646
|
-
currentTask,
|
|
1647
|
-
"Task is active and bound to this run for attribution. This board is not in managed lifecycle mode, so runtime Kanban governance was not bound to it."
|
|
1648
|
-
);
|
|
1649
|
-
}
|
|
1650
|
-
let stage = task.lifecycle?.currentStage;
|
|
1651
|
-
if (stage === "backlog") {
|
|
1652
|
-
const moved = await transitionTask(projectRoot, board.id, task.id, {
|
|
1653
|
-
to: "todo",
|
|
1654
|
-
actor: input.author,
|
|
1655
|
-
comment: input.transitionComment
|
|
1656
|
-
});
|
|
1657
|
-
if (!moved) return fail("Task could not enter Todo.");
|
|
1658
|
-
board = moved.board;
|
|
1659
|
-
task = moved.task;
|
|
1660
|
-
stage = task.lifecycle?.currentStage;
|
|
1661
|
-
}
|
|
1662
|
-
if (stage === "todo" || stage === "review") {
|
|
1663
|
-
const now = /* @__PURE__ */ new Date();
|
|
1664
|
-
const leaseId = input.leaseId ?? randomUUID2();
|
|
1665
|
-
const assigned = await updateTaskAssignment(projectRoot, board.id, task.id, {
|
|
1666
|
-
status: "running",
|
|
1667
|
-
agentId: input.agentId ?? input.author,
|
|
1668
|
-
leaseId,
|
|
1669
|
-
claimedAt: input.claimedAt ?? now.toISOString(),
|
|
1670
|
-
heartbeatAt: input.heartbeatAt ?? now.toISOString(),
|
|
1671
|
-
leaseExpiresAt: input.leaseExpiresAt ?? new Date(now.getTime() + 15 * 6e4).toISOString(),
|
|
1672
|
-
attempt: input.attempt ?? 1,
|
|
1673
|
-
maxAttempts: input.maxAttempts ?? 3
|
|
1674
|
-
});
|
|
1675
|
-
if (!assigned) return fail("Task assignment could not be started.");
|
|
1676
|
-
const moved = await transitionTask(projectRoot, board.id, task.id, {
|
|
1677
|
-
to: "running",
|
|
1678
|
-
actor: input.author,
|
|
1679
|
-
comment: input.transitionComment
|
|
1680
|
-
});
|
|
1681
|
-
if (!moved) return fail("Task could not enter Running.");
|
|
1682
|
-
board = moved.board;
|
|
1683
|
-
task = moved.task;
|
|
1684
|
-
stage = task.lifecycle?.currentStage;
|
|
1685
|
-
}
|
|
1686
|
-
if (stage !== "running" || task.assignment?.status !== "running") {
|
|
1687
|
-
return fail(
|
|
1688
|
-
`start_task only accepts Backlog, Todo, Review repair, or live Running cards (current: ${stage ?? "unknown"}).`
|
|
1689
|
-
);
|
|
1690
|
-
}
|
|
1691
|
-
ctx.setCurrentKanbanTask(task.id, board.id);
|
|
1692
|
-
await syncContextTask(ctx, task);
|
|
1693
|
-
return okTask(
|
|
1694
|
-
board,
|
|
1695
|
-
task,
|
|
1696
|
-
"Task is active; runtime Kanban governance is now bound to this run."
|
|
1697
|
-
);
|
|
1698
|
-
}
|
|
1699
|
-
case "update_task": {
|
|
1700
|
-
if (!input.boardId || !input.taskId) return fail("update_task requires boardId and taskId.");
|
|
1701
|
-
const board = await updateTask2(projectRoot, input.boardId, input.taskId, taskPatch(input));
|
|
1702
|
-
if (board) {
|
|
1703
|
-
await syncContextTask(ctx, board.tasks.find((t) => t.id === input.taskId));
|
|
1704
|
-
}
|
|
1705
|
-
return board ? okBoard(board, "Task updated.") : fail("Task not found.");
|
|
1706
|
-
}
|
|
1707
|
-
case "transition_task": {
|
|
1708
|
-
if (!input.boardId || !input.taskId || !input.lifecycleStage || !input.author || !input.transitionComment) {
|
|
1709
|
-
return fail(
|
|
1710
|
-
"transition_task requires boardId, taskId, lifecycleStage, author, and transitionComment."
|
|
1711
|
-
);
|
|
1712
|
-
}
|
|
1713
|
-
if (input.lifecycleStage === "done") {
|
|
1714
|
-
const boardBefore = await getBoard4(projectRoot, input.boardId);
|
|
1715
|
-
const taskBefore = boardBefore ? await getTask(projectRoot, input.boardId, input.taskId) : null;
|
|
1716
|
-
if (boardBefore && taskBefore && !taskBefore.verificationReport && (taskBefore.atomic || Boolean(taskBefore.successCriteria?.length))) {
|
|
1717
|
-
const preGate = await verifyTaskCompletion2(projectRoot, input.boardId, taskBefore.id, {
|
|
1718
|
-
persist: false
|
|
1719
|
-
});
|
|
1720
|
-
await updateTask2(projectRoot, input.boardId, taskBefore.id, {
|
|
1721
|
-
verificationReport: preGate.report,
|
|
1722
|
-
successCriteria: preGate.task.successCriteria
|
|
1723
|
-
});
|
|
1724
|
-
}
|
|
1725
|
-
}
|
|
1726
|
-
const result = await transitionTask(projectRoot, input.boardId, input.taskId, {
|
|
1727
|
-
to: input.lifecycleStage,
|
|
1728
|
-
actor: input.author,
|
|
1729
|
-
comment: input.transitionComment,
|
|
1730
|
-
...input.transitionAction !== void 0 ? { action: input.transitionAction } : {},
|
|
1731
|
-
...input.tickChecks !== void 0 ? { tickChecks: input.tickChecks } : {},
|
|
1732
|
-
...input.attachmentUrl !== void 0 ? {
|
|
1733
|
-
attachment: {
|
|
1734
|
-
url: input.attachmentUrl,
|
|
1735
|
-
type: input.attachmentType ?? "url",
|
|
1736
|
-
...input.attachmentTitle !== void 0 ? { title: input.attachmentTitle } : {}
|
|
1737
|
-
}
|
|
1738
|
-
} : {},
|
|
1739
|
-
patch: taskPatch(input)
|
|
1740
|
-
});
|
|
1741
|
-
if (result && input.lifecycleStage === "done" && result.task.verificationReport) {
|
|
1742
|
-
recordKanbanVerificationEvidence(ctx, result.task.verificationReport);
|
|
1743
|
-
}
|
|
1744
|
-
if (result?.task) {
|
|
1745
|
-
await syncContextTask(ctx, result.task);
|
|
1746
|
-
}
|
|
1747
|
-
return result ? okTask(result.board, result.task, `Task advanced to ${result.transition.to}.`) : fail("Board or task not found.");
|
|
1748
|
-
}
|
|
1749
|
-
case "repair_managed_projection": {
|
|
1750
|
-
if (!input.boardId || !input.taskId || !input.author || !input.transitionComment) {
|
|
1751
|
-
return fail(
|
|
1752
|
-
"repair_managed_projection requires boardId, taskId, author, and transitionComment."
|
|
1753
|
-
);
|
|
1754
|
-
}
|
|
1755
|
-
const result = await repairManagedTaskProjection(projectRoot, input.boardId, input.taskId, {
|
|
1756
|
-
actor: input.author,
|
|
1757
|
-
comment: input.transitionComment
|
|
1758
|
-
});
|
|
1759
|
-
if (result?.task) {
|
|
1760
|
-
await syncContextTask(ctx, result.task);
|
|
1761
|
-
}
|
|
1762
|
-
return result ? okTask(
|
|
1763
|
-
result.board,
|
|
1764
|
-
result.task,
|
|
1765
|
-
"Managed card projection repaired from lifecycle history."
|
|
1766
|
-
) : fail("Board or task not found.");
|
|
1767
|
-
}
|
|
1768
|
-
case "move_task": {
|
|
1769
|
-
if (!input.boardId || !input.taskId || !input.targetColumnId) {
|
|
1770
|
-
return fail("move_task requires boardId, taskId, and targetColumnId.");
|
|
1771
|
-
}
|
|
1772
|
-
const board = await moveTask(
|
|
1773
|
-
projectRoot,
|
|
1774
|
-
input.boardId,
|
|
1775
|
-
input.taskId,
|
|
1776
|
-
input.targetColumnId,
|
|
1777
|
-
input.order
|
|
1778
|
-
);
|
|
1779
|
-
if (board) {
|
|
1780
|
-
await syncContextTask(ctx, board.tasks.find((t) => t.id === input.taskId));
|
|
1781
|
-
}
|
|
1782
|
-
return board ? okBoard(board, "Task moved.") : fail("Move failed.");
|
|
1783
|
-
}
|
|
1784
|
-
case "delete_task": {
|
|
1785
|
-
if (!input.boardId || !input.taskId) return fail("delete_task requires boardId and taskId.");
|
|
1786
|
-
const boardBefore = await getBoard4(projectRoot, input.boardId);
|
|
1787
|
-
const taskToDelete = boardBefore?.tasks.find((t) => t.id === input.taskId);
|
|
1788
|
-
const board = await removeTask(projectRoot, input.boardId, input.taskId);
|
|
1789
|
-
if (board && ctx.currentKanbanTaskId === input.taskId) {
|
|
1790
|
-
ctx.setCurrentKanbanTask?.(void 0, ctx.currentKanbanBoardId);
|
|
1791
|
-
}
|
|
1792
|
-
if (board && taskToDelete) {
|
|
1793
|
-
await syncContextTask(ctx, taskToDelete, { remove: true });
|
|
1794
|
-
}
|
|
1795
|
-
return board ? okBoard(board, "Task deleted.") : fail("Task not found.");
|
|
1796
|
-
}
|
|
1797
|
-
case "set_chain": {
|
|
1798
|
-
if (!input.boardId || !input.taskIds?.length) {
|
|
1799
|
-
return fail("set_chain requires boardId and taskIds.");
|
|
1800
|
-
}
|
|
1801
|
-
const result = await setTaskChain(projectRoot, input.boardId, {
|
|
1802
|
-
taskIds: input.taskIds,
|
|
1803
|
-
...input.chainId !== void 0 ? { chainId: input.chainId } : {},
|
|
1804
|
-
...input.enforceDependencies !== void 0 ? { enforceDependencies: input.enforceDependencies } : {}
|
|
1805
|
-
});
|
|
1806
|
-
return result ? {
|
|
1807
|
-
ok: true,
|
|
1808
|
-
message: `Chain set: ${result.chainId}`,
|
|
1809
|
-
board: result.board,
|
|
1810
|
-
chain: result.tasks
|
|
1811
|
-
} : fail("Board or task not found.");
|
|
1812
|
-
}
|
|
1813
|
-
case "get_chain": {
|
|
1814
|
-
if (!input.boardId || !(input.taskId || input.chainId)) {
|
|
1815
|
-
return fail("get_chain requires boardId and taskId or chainId.");
|
|
1816
|
-
}
|
|
1817
|
-
const result = await getTaskChain(
|
|
1818
|
-
projectRoot,
|
|
1819
|
-
input.boardId,
|
|
1820
|
-
input.taskId ?? input.chainId ?? ""
|
|
1821
|
-
);
|
|
1822
|
-
return result ? {
|
|
1823
|
-
ok: true,
|
|
1824
|
-
message: `Chain loaded: ${result.chainId}`,
|
|
1825
|
-
board: result.board,
|
|
1826
|
-
chain: result.tasks
|
|
1827
|
-
} : fail("Chain not found.");
|
|
1828
|
-
}
|
|
1829
|
-
case "claim_task": {
|
|
1830
|
-
const result = await claimReadyTask(projectRoot, {
|
|
1831
|
-
...input.boardId !== void 0 ? { boardId: input.boardId } : {},
|
|
1832
|
-
...input.taskId !== void 0 ? { taskId: input.taskId } : {},
|
|
1833
|
-
...assignmentInput(input),
|
|
1834
|
-
status: input.assignmentStatus ?? "queued"
|
|
1835
|
-
});
|
|
1836
|
-
return result ? okTask(result.board, result.task, "Task claimed.") : fail("No ready kanban task matched the claim.");
|
|
1837
|
-
}
|
|
1838
|
-
case "release_task": {
|
|
1839
|
-
if (!input.boardId || !input.taskId) {
|
|
1840
|
-
return fail("release_task requires boardId and taskId.");
|
|
1841
|
-
}
|
|
1842
|
-
const board = await releaseTaskClaim(projectRoot, input.boardId, input.taskId, {
|
|
1843
|
-
...input.releaseStatus !== void 0 ? { status: input.releaseStatus } : {},
|
|
1844
|
-
...input.releaseReason !== void 0 ? { reason: input.releaseReason } : {},
|
|
1845
|
-
...input.clearAssignee !== void 0 ? { clearAssignee: input.clearAssignee } : {}
|
|
1846
|
-
});
|
|
1847
|
-
return board ? okBoard(board, "Task claim released.") : fail("Task not found.");
|
|
1848
|
-
}
|
|
1849
|
-
case "assign_task": {
|
|
1850
|
-
if (!input.boardId || !input.taskId) return fail("assign_task requires boardId and taskId.");
|
|
1851
|
-
const board = await assignTask(
|
|
1852
|
-
projectRoot,
|
|
1853
|
-
input.boardId,
|
|
1854
|
-
input.taskId,
|
|
1855
|
-
assignmentInput(input)
|
|
1856
|
-
);
|
|
1857
|
-
return board ? okBoard(board, "Task assigned.") : fail("Task not found.");
|
|
1858
|
-
}
|
|
1859
|
-
case "mark_assignment": {
|
|
1860
|
-
if (!input.boardId || !input.taskId)
|
|
1861
|
-
return fail("mark_assignment requires boardId and taskId.");
|
|
1862
|
-
const assignmentStatus = input.assignmentStatus ?? (input.status === "completed" ? "completed" : input.error ? "failed" : void 0);
|
|
1863
|
-
const board = await updateTaskAssignment(
|
|
1864
|
-
projectRoot,
|
|
1865
|
-
input.boardId,
|
|
1866
|
-
input.taskId,
|
|
1867
|
-
{
|
|
1868
|
-
...assignmentStatus !== void 0 ? { status: assignmentStatus } : {},
|
|
1869
|
-
...input.subagentId !== void 0 ? { subagentId: input.subagentId } : {},
|
|
1870
|
-
...input.runTaskId !== void 0 ? { runTaskId: input.runTaskId } : {},
|
|
1871
|
-
...input.lastResult !== void 0 ? { lastResult: input.lastResult } : {},
|
|
1872
|
-
...input.error !== void 0 ? { error: input.error } : {},
|
|
1873
|
-
...input.agentId !== void 0 ? { agentId: input.agentId } : {},
|
|
1874
|
-
...input.leaseId !== void 0 ? { leaseId: input.leaseId } : {},
|
|
1875
|
-
...input.claimedAt !== void 0 ? { claimedAt: input.claimedAt } : {},
|
|
1876
|
-
...input.heartbeatAt !== void 0 ? { heartbeatAt: input.heartbeatAt } : {},
|
|
1877
|
-
...input.leaseExpiresAt !== void 0 ? { leaseExpiresAt: input.leaseExpiresAt } : {},
|
|
1878
|
-
...input.attempt !== void 0 ? { attempt: input.attempt } : {},
|
|
1879
|
-
...input.maxAttempts !== void 0 ? { maxAttempts: input.maxAttempts } : {}
|
|
1880
|
-
},
|
|
1881
|
-
input.expectedLeaseId !== void 0 ? { expectedLeaseId: input.expectedLeaseId } : {}
|
|
1882
|
-
);
|
|
1883
|
-
if (!board) return fail("Task not found.");
|
|
1884
|
-
if (assignmentStatus === "completed" && board.lifecycle?.mode !== "managed") {
|
|
1885
|
-
const envGate = readEnvGateEnforcement();
|
|
1886
|
-
const finalized = await finalizeTaskCompletion(projectRoot, board.id, input.taskId, {
|
|
1887
|
-
...board.completionGate === void 0 && envGate !== void 0 ? { enforcement: envGate } : {},
|
|
1888
|
-
...ctx.agentId !== void 0 ? { eventContext: { actor: ctx.agentId } } : {}
|
|
1889
|
-
});
|
|
1890
|
-
if (finalized) {
|
|
1891
|
-
if (finalized.gate.report) {
|
|
1892
|
-
recordKanbanVerificationEvidence(ctx, finalized.gate.report);
|
|
1893
|
-
}
|
|
1894
|
-
const gateSummary = {
|
|
1895
|
-
enforcement: finalized.gate.enforcement,
|
|
1896
|
-
allowed: finalized.gate.allowed,
|
|
1897
|
-
verdict: finalized.gate.verdict,
|
|
1898
|
-
issues: finalized.gate.issues.map((issue) => issue.message)
|
|
1899
|
-
};
|
|
1900
|
-
const gateMessage = finalized.gate.allowed ? `Completion gate ${finalized.gate.verdict === "skipped" ? "passed" : "passed"}; task completed.` : finalized.gate.enforcement === "strict" ? `Completion gate BLOCKED (verdict: ${finalized.gate.verdict}); task parked in review. Issues: ${gateSummary.issues.join(" | ")}` : `Completion gate failed softly (verdict: ${finalized.gate.verdict}); task completed with warnings. Issues: ${gateSummary.issues.join(" | ")}`;
|
|
1901
|
-
await syncContextTask(ctx, finalized.task);
|
|
1902
|
-
return {
|
|
1903
|
-
...okTask(finalized.board, finalized.task, `Assignment updated. ${gateMessage}`),
|
|
1904
|
-
gate: gateSummary
|
|
1905
|
-
};
|
|
1906
|
-
}
|
|
1907
|
-
} else if (board.lifecycle?.mode === "managed") {
|
|
1908
|
-
const managedTask = board.tasks.find((candidate) => candidate.id === input.taskId);
|
|
1909
|
-
const stage = managedTask?.lifecycle?.currentStage;
|
|
1910
|
-
const actor = ctx.agentId ?? "kanban-agent";
|
|
1911
|
-
let transitionResult = null;
|
|
1912
|
-
const lifecycleWarnings = [];
|
|
1913
|
-
if (assignmentStatus === "running" && stage === "todo") {
|
|
1914
|
-
try {
|
|
1915
|
-
transitionResult = await transitionTask(projectRoot, board.id, input.taskId, {
|
|
1916
|
-
to: "running",
|
|
1917
|
-
actor,
|
|
1918
|
-
comment: "Work started."
|
|
1919
|
-
});
|
|
1920
|
-
} catch (err) {
|
|
1921
|
-
lifecycleWarnings.push(
|
|
1922
|
-
`Lifecycle transition to Running deferred: ${stripLifecycleIssues(err instanceof Error ? err.message : String(err))}`
|
|
1923
|
-
);
|
|
1924
|
-
}
|
|
1925
|
-
}
|
|
1926
|
-
if (assignmentStatus === "completed" && stage === "running") {
|
|
1927
|
-
const comment = typeof input.lastResult === "string" && input.lastResult.trim().length > 0 ? input.lastResult.trim().slice(0, 1e3) : "Work completed.";
|
|
1928
|
-
try {
|
|
1929
|
-
transitionResult = await transitionTask(projectRoot, board.id, input.taskId, {
|
|
1930
|
-
to: "review",
|
|
1931
|
-
actor,
|
|
1932
|
-
comment,
|
|
1933
|
-
attachment: {
|
|
1934
|
-
url: `kanban://task/${input.taskId}/result`,
|
|
1935
|
-
title: "Worker completion result",
|
|
1936
|
-
type: "file"
|
|
1937
|
-
},
|
|
1938
|
-
patch: {
|
|
1939
|
-
...input.agentId !== void 0 ? { assignedAgent: input.agentId } : {}
|
|
1940
|
-
}
|
|
1941
|
-
});
|
|
1942
|
-
} catch (err) {
|
|
1943
|
-
lifecycleWarnings.push(
|
|
1944
|
-
`Lifecycle transition to Review failed: ${stripLifecycleIssues(err instanceof Error ? err.message : String(err))}`
|
|
1945
|
-
);
|
|
1946
|
-
}
|
|
1947
|
-
if (transitionResult) {
|
|
1948
|
-
const hasCriteria = (transitionResult.task.successCriteria?.length ?? 0) > 0 || transitionResult.task.atomic === true;
|
|
1949
|
-
if (hasCriteria) {
|
|
1950
|
-
try {
|
|
1951
|
-
const verResult = await verifyTaskCompletion2(projectRoot, board.id, input.taskId);
|
|
1952
|
-
if (verResult.report) {
|
|
1953
|
-
recordKanbanVerificationEvidence(ctx, verResult.report);
|
|
1954
|
-
}
|
|
1955
|
-
await updateTask2(projectRoot, board.id, input.taskId, {
|
|
1956
|
-
verificationReport: verResult.report,
|
|
1957
|
-
successCriteria: verResult.task.successCriteria
|
|
1958
|
-
});
|
|
1959
|
-
const verdict = verResult.report.verdict;
|
|
1960
|
-
if (verdict === "passed" && !resolveAutoAccept(board)) {
|
|
1961
|
-
lifecycleWarnings.push(
|
|
1962
|
-
"Verification passed, but this board does not auto-accept. The card is in Review awaiting an explicit transition_task to done."
|
|
1963
|
-
);
|
|
1964
|
-
} else if (verdict === "passed") {
|
|
1965
|
-
try {
|
|
1966
|
-
const doneResult = await transitionTask(projectRoot, board.id, input.taskId, {
|
|
1967
|
-
to: "done",
|
|
1968
|
-
actor,
|
|
1969
|
-
action: "Automated acceptance after verification",
|
|
1970
|
-
comment: "Auto-accepted: verification passed.",
|
|
1971
|
-
attachment: {
|
|
1972
|
-
url: `kanban://task/${input.taskId}/verification`,
|
|
1973
|
-
title: "Auto-verification result",
|
|
1974
|
-
type: "file"
|
|
1975
|
-
}
|
|
1976
|
-
});
|
|
1977
|
-
transitionResult = doneResult;
|
|
1978
|
-
} catch (acceptErr) {
|
|
1979
|
-
lifecycleWarnings.push(
|
|
1980
|
-
`Auto-accept to Done deferred: ${acceptErr instanceof Error ? acceptErr.message : String(acceptErr)}`
|
|
1981
|
-
);
|
|
1982
|
-
}
|
|
1983
|
-
} else {
|
|
1984
|
-
lifecycleWarnings.push(
|
|
1985
|
-
`Verification verdict: ${verdict} \u2014 card left in Review for manual acceptance.`
|
|
1986
|
-
);
|
|
1987
|
-
}
|
|
1988
|
-
} catch (verifyErr) {
|
|
1989
|
-
lifecycleWarnings.push(
|
|
1990
|
-
`Auto-verification error: ${verifyErr instanceof Error ? verifyErr.message : String(verifyErr)}`
|
|
1991
|
-
);
|
|
1992
|
-
}
|
|
1993
|
-
} else {
|
|
1994
|
-
lifecycleWarnings.push(
|
|
1995
|
-
"No automatic success criteria \u2014 card left in Review for manual verification."
|
|
1996
|
-
);
|
|
1997
|
-
}
|
|
1998
|
-
}
|
|
1999
|
-
}
|
|
2000
|
-
const responseBoard = transitionResult?.board ?? board;
|
|
2001
|
-
const responseTask = transitionResult?.task ?? managedTask;
|
|
2002
|
-
const msgParts = ["Assignment updated."];
|
|
2003
|
-
if (transitionResult) {
|
|
2004
|
-
msgParts.push(`Card advanced to ${transitionResult.transition.to}.`);
|
|
2005
|
-
}
|
|
2006
|
-
for (const w of lifecycleWarnings) msgParts.push(`Warning: ${w}`);
|
|
2007
|
-
await syncContextTask(ctx, responseTask);
|
|
2008
|
-
return okTask(responseBoard, responseTask, msgParts.join(" "));
|
|
2009
|
-
}
|
|
2010
|
-
return okBoard(board, "Assignment updated.");
|
|
2011
|
-
}
|
|
2012
|
-
case "heartbeat_assignment": {
|
|
2013
|
-
if (!input.boardId || !input.taskId) {
|
|
2014
|
-
return fail("heartbeat_assignment requires boardId and taskId.");
|
|
2015
|
-
}
|
|
2016
|
-
const board = await heartbeatTaskAssignment(projectRoot, input.boardId, input.taskId, {
|
|
2017
|
-
...input.heartbeatAt !== void 0 ? { heartbeatAt: input.heartbeatAt } : {},
|
|
2018
|
-
...input.leaseExpiresAt !== void 0 ? { leaseExpiresAt: input.leaseExpiresAt } : {},
|
|
2019
|
-
...input.expectedLeaseId !== void 0 ? { expectedLeaseId: input.expectedLeaseId } : {}
|
|
2020
|
-
});
|
|
2021
|
-
return board ? okBoard(board, "Assignment heartbeat updated.") : fail("Task assignment not found.");
|
|
2022
|
-
}
|
|
2023
|
-
case "recover_stale": {
|
|
2024
|
-
if (!input.boardId) return fail("recover_stale requires boardId.");
|
|
2025
|
-
const policyFields = [
|
|
2026
|
-
input.recoveryPolicyFailOnCostCeiling !== void 0,
|
|
2027
|
-
input.recoveryPolicyReleaseOnFailureKinds !== void 0,
|
|
2028
|
-
input.recoveryPolicyReleaseOnHeartbeatDue !== void 0,
|
|
2029
|
-
input.recoveryPolicyRetryPolicyOverride !== void 0
|
|
2030
|
-
].some(Boolean);
|
|
2031
|
-
const result = await recoverStaleTaskAssignments(projectRoot, input.boardId, {
|
|
2032
|
-
...input.recoveryMode !== void 0 ? { mode: input.recoveryMode } : {},
|
|
2033
|
-
...input.recoveryNow !== void 0 ? { now: input.recoveryNow } : {},
|
|
2034
|
-
...input.releaseReason !== void 0 ? { reason: input.releaseReason } : {},
|
|
2035
|
-
...input.clearAssignee !== void 0 ? { clearAssignee: input.clearAssignee } : {},
|
|
2036
|
-
...policyFields ? {
|
|
2037
|
-
policy: {
|
|
2038
|
-
...input.recoveryPolicyFailOnCostCeiling !== void 0 ? { failWhenCostCeilingSet: input.recoveryPolicyFailOnCostCeiling } : {},
|
|
2039
|
-
...input.recoveryPolicyReleaseOnFailureKinds !== void 0 ? {
|
|
2040
|
-
releaseOnFailureKinds: input.recoveryPolicyReleaseOnFailureKinds
|
|
2041
|
-
} : {},
|
|
2042
|
-
...input.recoveryPolicyReleaseOnHeartbeatDue !== void 0 ? {
|
|
2043
|
-
releaseOnHeartbeatDue: input.recoveryPolicyReleaseOnHeartbeatDue
|
|
2044
|
-
} : {},
|
|
2045
|
-
...input.recoveryPolicyRetryPolicyOverride !== void 0 ? {
|
|
2046
|
-
retryPolicyOverride: input.recoveryPolicyRetryPolicyOverride
|
|
2047
|
-
} : {}
|
|
2048
|
-
}
|
|
2049
|
-
} : {}
|
|
2050
|
-
});
|
|
2051
|
-
return result ? {
|
|
2052
|
-
ok: true,
|
|
2053
|
-
message: `Recovered ${result.tasks.length} stale assignment(s).`,
|
|
2054
|
-
board: result.board,
|
|
2055
|
-
recoveredTasks: result.tasks
|
|
2056
|
-
} : { ok: true, message: "No stale assignment matched.", recoveredTasks: [] };
|
|
2057
|
-
}
|
|
2058
|
-
default:
|
|
2059
|
-
return void 0;
|
|
2060
|
-
}
|
|
2061
|
-
}
|
|
2062
|
-
|
|
2063
|
-
// src/kanban-presence.ts
|
|
2064
|
-
import { touchKanbanPresence as touchKanbanPresence2 } from "@wrongstack/kanban";
|
|
2065
|
-
function createKanbanPresenceWrapper(projectRoot, input, ctx) {
|
|
2066
|
-
return async (result) => {
|
|
2067
|
-
const boardId = result.board?.id ?? input.boardId;
|
|
2068
|
-
if (!result.ok || !boardId || !ctx.session?.id || !ctx.agentId) return result;
|
|
2069
|
-
try {
|
|
2070
|
-
const board = await touchKanbanPresence2(projectRoot, boardId, {
|
|
2071
|
-
sessionId: ctx.session.id,
|
|
2072
|
-
agentId: ctx.agentId,
|
|
2073
|
-
agentName: ctx.agentName,
|
|
2074
|
-
taskId: input.taskId ?? result.task?.id,
|
|
2075
|
-
runTaskId: input.runTaskId
|
|
2076
|
-
});
|
|
2077
|
-
return board ? { ...result, board } : result;
|
|
2078
|
-
} catch {
|
|
2079
|
-
return result;
|
|
2080
|
-
}
|
|
2081
|
-
};
|
|
2082
|
-
}
|
|
2083
|
-
|
|
2084
|
-
// src/kanban-serializer.ts
|
|
2085
|
-
var KANBAN_BOARD_TRANSCRIPT_BYTE_CAP = 16384;
|
|
2086
|
-
var KANBAN_FULL_BOARD_ACTIONS = /* @__PURE__ */ new Set([
|
|
2087
|
-
"get_board",
|
|
2088
|
-
"export_markdown",
|
|
2089
|
-
"export_task_graph"
|
|
2090
|
-
]);
|
|
2091
|
-
function serializeKanbanOutput(output, input) {
|
|
2092
|
-
const action = input && typeof input === "object" ? input.action : void 0;
|
|
2093
|
-
const board = output.board;
|
|
2094
|
-
if (board) {
|
|
2095
|
-
const keepFull = typeof action === "string" && KANBAN_FULL_BOARD_ACTIONS.has(action);
|
|
2096
|
-
let boardBytes = 0;
|
|
2097
|
-
if (!keepFull) {
|
|
2098
|
-
try {
|
|
2099
|
-
boardBytes = Buffer.byteLength(JSON.stringify(board), "utf8");
|
|
2100
|
-
} catch {
|
|
2101
|
-
boardBytes = 0;
|
|
2102
|
-
}
|
|
2103
|
-
}
|
|
2104
|
-
if (!keepFull && boardBytes > KANBAN_BOARD_TRANSCRIPT_BYTE_CAP) {
|
|
2105
|
-
const columns = {};
|
|
2106
|
-
for (const column of board.columns) {
|
|
2107
|
-
columns[column.title || column.id] = board.tasks.filter(
|
|
2108
|
-
(task) => task.columnId === column.id
|
|
2109
|
-
).length;
|
|
2110
|
-
}
|
|
2111
|
-
const compact = {
|
|
2112
|
-
...output,
|
|
2113
|
-
board: {
|
|
2114
|
-
id: board.id,
|
|
2115
|
-
title: board.title,
|
|
2116
|
-
columns,
|
|
2117
|
-
totalTasks: board.tasks.length,
|
|
2118
|
-
note: `Full board (${boardBytes} bytes) omitted from the transcript; use get_board to load it.`
|
|
2119
|
-
}
|
|
2120
|
-
};
|
|
2121
|
-
return JSON.stringify(compact, null, 2);
|
|
2122
|
-
}
|
|
2123
|
-
}
|
|
2124
|
-
return JSON.stringify(output, null, 2);
|
|
2125
|
-
}
|
|
2126
|
-
|
|
2127
|
-
// src/kanban-tool-schema.ts
|
|
2128
|
-
var KANBAN_TOOL_DESCRIPTION = "Durable project task boards: create and move cards, record checks, notes, links and assignments. The board is a record of the work, not a permit for it \u2014 nothing here gates other tools. Managed boards additionally enforce ordered Backlog \u2192 Todo \u2192 Running \u2192 Review \u2192 Done transitions; release_managed_lifecycle turns that off.";
|
|
2129
|
-
var KANBAN_TOOL_USAGE_HINT = 'Track substantial or multi-step work so it survives the session; a trivial edit or a question needs no card. Work stays on ONE board: call list_boards first and add_task to the board this project already uses. create_board is for a genuinely separate line of work, not for each new piece of it \u2014 a second board splits the same effort in two, and a board holding a single card is the usual sign. Common flow: list_boards or search_tasks to orient, add_task to record work, start_task when you begin, update_check with checkStatus "passed" to tick acceptance criteria (read their ids from get_task), then transition_task. On a managed board a refused transition names the field it wants \u2014 supply it and retry. When the acceptance criterion is something a machine can run, say so: set checkType ("command", "test", "file_exists", "file_matches", "git_diff", "metric") and put the command, pattern or path in checkNotes, then verify_completion executes it and the result is real evidence. Leave checkType off (or "manual") only for criteria that genuinely need a human eye \u2014 a manual check records your assertion, it does not test anything. Goal metrics pass when current >= target by default; when lower is better (error rate, cost ceiling, latency, open-bug count), pass metricDirection "at_most" with add_goal_metric / update_goal_metric so verification compares current <= target instead.';
|
|
2130
|
-
var KANBAN_INPUT_SCHEMA = {
|
|
2131
|
-
type: "object",
|
|
2132
|
-
properties: {
|
|
2133
|
-
action: {
|
|
2134
|
-
type: "string",
|
|
2135
|
-
enum: [
|
|
2136
|
-
"list_boards",
|
|
2137
|
-
"get_board",
|
|
2138
|
-
"create_board",
|
|
2139
|
-
"duplicate_board",
|
|
2140
|
-
"update_board",
|
|
2141
|
-
"adopt_managed_lifecycle",
|
|
2142
|
-
"release_managed_lifecycle",
|
|
2143
|
-
"delete_board",
|
|
2144
|
-
"generate_board",
|
|
2145
|
-
"export_markdown",
|
|
2146
|
-
"export_task_graph",
|
|
2147
|
-
"sync_task_graph",
|
|
2148
|
-
"create_from_graph",
|
|
2149
|
-
"import_session_tasks",
|
|
2150
|
-
"search_tasks",
|
|
2151
|
-
"ready_tasks",
|
|
2152
|
-
"snapshot",
|
|
2153
|
-
"workbench",
|
|
2154
|
-
"add_task",
|
|
2155
|
-
"split_task",
|
|
2156
|
-
"merge_tasks",
|
|
2157
|
-
"copy_task",
|
|
2158
|
-
"transfer_task",
|
|
2159
|
-
"get_task",
|
|
2160
|
-
"start_task",
|
|
2161
|
-
"update_task",
|
|
2162
|
-
"transition_task",
|
|
2163
|
-
"repair_managed_projection",
|
|
2164
|
-
"move_task",
|
|
2165
|
-
"delete_task",
|
|
2166
|
-
"set_chain",
|
|
2167
|
-
"get_chain",
|
|
2168
|
-
"claim_task",
|
|
2169
|
-
"release_task",
|
|
2170
|
-
"assign_task",
|
|
2171
|
-
"mark_assignment",
|
|
2172
|
-
"heartbeat_assignment",
|
|
2173
|
-
"recover_stale",
|
|
2174
|
-
"events",
|
|
2175
|
-
"queue_health",
|
|
2176
|
-
"add_dependency",
|
|
2177
|
-
"add_goal_metric",
|
|
2178
|
-
"update_goal_metric",
|
|
2179
|
-
"add_check",
|
|
2180
|
-
"update_check",
|
|
2181
|
-
"remove_check",
|
|
2182
|
-
"add_note",
|
|
2183
|
-
"add_link",
|
|
2184
|
-
"verify_completion",
|
|
2185
|
-
"split_atomic",
|
|
2186
|
-
"assess_atomicity",
|
|
2187
|
-
"propose_decomposition",
|
|
2188
|
-
"get_contract_graph",
|
|
2189
|
-
"configure_contract_graph",
|
|
2190
|
-
"upsert_contract_node",
|
|
2191
|
-
"remove_contract_node",
|
|
2192
|
-
"add_contract_edge",
|
|
2193
|
-
"remove_contract_edge"
|
|
2194
|
-
]
|
|
2195
|
-
},
|
|
2196
|
-
boardId: { type: "string" },
|
|
2197
|
-
taskId: { type: "string" },
|
|
2198
|
-
taskIds: { type: "array", items: { type: "string" } },
|
|
2199
|
-
chainId: { type: "string" },
|
|
2200
|
-
fromNodeId: { type: "string" },
|
|
2201
|
-
toNodeId: { type: "string" },
|
|
2202
|
-
baseline: { oneOf: [{ type: "string" }, { type: "number" }] },
|
|
2203
|
-
threshold: { oneOf: [{ type: "string" }, { type: "number" }] },
|
|
2204
|
-
columnId: { type: "string" },
|
|
2205
|
-
targetBoardId: { type: "string" },
|
|
2206
|
-
targetColumnId: { type: "string" },
|
|
2207
|
-
title: { type: "string" },
|
|
2208
|
-
description: { type: "string" },
|
|
2209
|
-
dueDate: { type: "string" },
|
|
2210
|
-
tags: { type: "array", items: { type: "string" } },
|
|
2211
|
-
labels: { type: "array", items: { type: "string" } },
|
|
2212
|
-
priority: { type: "string", enum: ["critical", "high", "medium", "low"] },
|
|
2213
|
-
taskType: {
|
|
2214
|
-
type: "string",
|
|
2215
|
-
enum: ["feature", "bugfix", "refactor", "docs", "test", "chore"]
|
|
2216
|
-
},
|
|
2217
|
-
status: {
|
|
2218
|
-
type: "string",
|
|
2219
|
-
enum: [
|
|
2220
|
-
"pending",
|
|
2221
|
-
"ready",
|
|
2222
|
-
"in_progress",
|
|
2223
|
-
"blocked",
|
|
2224
|
-
"review",
|
|
2225
|
-
"completed",
|
|
2226
|
-
"failed",
|
|
2227
|
-
"archived"
|
|
2228
|
-
]
|
|
2229
|
-
},
|
|
2230
|
-
order: { type: "number" },
|
|
2231
|
-
query: { type: "string" },
|
|
2232
|
-
limit: { type: "number" },
|
|
2233
|
-
agentId: { type: "string" },
|
|
2234
|
-
name: { type: "string" },
|
|
2235
|
-
role: { type: "string" },
|
|
2236
|
-
provider: { type: "string" },
|
|
2237
|
-
model: { type: "string" },
|
|
2238
|
-
fallbackProfile: { type: "string" },
|
|
2239
|
-
fallbackModels: { type: "array", items: { type: "string" } },
|
|
2240
|
-
tools: { type: "array", items: { type: "string" } },
|
|
2241
|
-
allowedCapabilities: { type: "array", items: { type: "string" } },
|
|
2242
|
-
leaseId: { type: "string" },
|
|
2243
|
-
claimedAt: { type: "string" },
|
|
2244
|
-
heartbeatAt: { type: "string" },
|
|
2245
|
-
leaseExpiresAt: { type: "string" },
|
|
2246
|
-
attempt: { type: "number" },
|
|
2247
|
-
maxAttempts: { type: "number" },
|
|
2248
|
-
subagentId: { type: "string" },
|
|
2249
|
-
runTaskId: { type: "string" },
|
|
2250
|
-
lastResult: { type: "string" },
|
|
2251
|
-
error: { type: "string" },
|
|
2252
|
-
expectedLeaseId: { type: "string" },
|
|
2253
|
-
assignmentStatus: {
|
|
2254
|
-
type: "string",
|
|
2255
|
-
enum: ["assigned", "queued", "running", "completed", "failed", "cancelled"]
|
|
2256
|
-
},
|
|
2257
|
-
lifecycleStage: {
|
|
2258
|
-
type: "string",
|
|
2259
|
-
enum: ["backlog", "todo", "running", "review", "done"]
|
|
2260
|
-
},
|
|
2261
|
-
transitionAction: { type: "string" },
|
|
2262
|
-
transitionComment: { type: "string" },
|
|
2263
|
-
tickChecks: {
|
|
2264
|
-
type: "array",
|
|
2265
|
-
items: {
|
|
2266
|
-
type: "object",
|
|
2267
|
-
properties: {
|
|
2268
|
-
checkId: { type: "string" },
|
|
2269
|
-
checkStatus: { type: "string", enum: ["passed", "failed", "skipped"] }
|
|
2270
|
-
},
|
|
2271
|
-
required: ["checkId", "checkStatus"]
|
|
2272
|
-
},
|
|
2273
|
-
description: "`transition_task` (to=done only): flip one or more manual criteria to `passed` before the gate fires. Read ids from kanban get_task. Non-manual criteria are refused."
|
|
2274
|
-
},
|
|
2275
|
-
attachmentUrl: { type: "string" },
|
|
2276
|
-
attachmentTitle: { type: "string" },
|
|
2277
|
-
attachmentType: {
|
|
2278
|
-
type: "string",
|
|
2279
|
-
enum: ["issue", "pr", "doc", "commit", "design", "file", "url", "other"]
|
|
2280
|
-
},
|
|
2281
|
-
releaseStatus: { type: "string", enum: ["pending", "ready", "blocked"] },
|
|
2282
|
-
releaseReason: { type: "string" },
|
|
2283
|
-
clearAssignee: { type: "boolean" },
|
|
2284
|
-
recoveryMode: { type: "string", enum: ["auto", "release", "retry", "fail"] },
|
|
2285
|
-
recoveryNow: { type: "string" },
|
|
2286
|
-
recoveryPolicyFailOnCostCeiling: { type: "boolean" },
|
|
2287
|
-
recoveryPolicyReleaseOnFailureKinds: { type: "array", items: { type: "string" } },
|
|
2288
|
-
recoveryPolicyReleaseOnHeartbeatDue: { type: "boolean" },
|
|
2289
|
-
recoveryPolicyRetryPolicyOverride: {
|
|
2290
|
-
type: "string",
|
|
2291
|
-
enum: ["off", "incremental", "exponential"]
|
|
2292
|
-
},
|
|
2293
|
-
assignee: { type: "string" },
|
|
2294
|
-
costCeilingUsd: { type: "number" },
|
|
2295
|
-
retryPolicy: { type: "string", enum: ["off", "incremental", "exponential"] },
|
|
2296
|
-
lastFailureKind: { type: "string" },
|
|
2297
|
-
dependsOn: {
|
|
2298
|
-
type: "array",
|
|
2299
|
-
items: { type: "string" },
|
|
2300
|
-
description: "Task ids this card waits on. On update_task an explicit empty array clears them \u2014 use it when a dependency was recorded in error rather than completing work nobody wants."
|
|
2301
|
-
},
|
|
2302
|
-
atomic: {
|
|
2303
|
-
type: "boolean",
|
|
2304
|
-
description: "Composite parent (true) or executable leaf (false). Set false to make a stranded parent a leaf again after its children were dropped."
|
|
2305
|
-
},
|
|
2306
|
-
childTaskIds: {
|
|
2307
|
-
type: "array",
|
|
2308
|
-
items: { type: "string" },
|
|
2309
|
-
description: "Children of a composite parent. On update_task an explicit empty array detaches them all."
|
|
2310
|
-
},
|
|
2311
|
-
estimatedHours: { type: "number" },
|
|
2312
|
-
actualHours: { type: "number" },
|
|
2313
|
-
taskGraph: { type: "object" },
|
|
2314
|
-
graphId: { type: "string" },
|
|
2315
|
-
specId: { type: "string" },
|
|
2316
|
-
specRequirementId: { type: "string" },
|
|
2317
|
-
sourceSystem: { type: "string" },
|
|
2318
|
-
phaseId: { type: "string" },
|
|
2319
|
-
preserveOriginTaskIds: { type: "boolean" },
|
|
2320
|
-
includeArchived: { type: "boolean" },
|
|
2321
|
-
archiveMissingTasks: { type: "boolean" },
|
|
2322
|
-
preserveManualDependencies: { type: "boolean" },
|
|
2323
|
-
dependencyTaskId: { type: "string" },
|
|
2324
|
-
enforceDependencies: { type: "boolean" },
|
|
2325
|
-
childTitles: { type: "array", items: { type: "string" } },
|
|
2326
|
-
inheritAssignment: { type: "boolean" },
|
|
2327
|
-
inheritLabels: { type: "boolean" },
|
|
2328
|
-
inheritSuccessCriteria: { type: "boolean" },
|
|
2329
|
-
inheritGoalMetrics: { type: "boolean" },
|
|
2330
|
-
inheritDependencies: { type: "boolean" },
|
|
2331
|
-
chainChildren: { type: "boolean" },
|
|
2332
|
-
rewireDependents: { type: "boolean" },
|
|
2333
|
-
closeSourceTasks: { type: "boolean" },
|
|
2334
|
-
metricId: { type: "string" },
|
|
2335
|
-
metricName: { type: "string" },
|
|
2336
|
-
metricTarget: { oneOf: [{ type: "string" }, { type: "number" }] },
|
|
2337
|
-
metricCurrent: { oneOf: [{ type: "string" }, { type: "number" }] },
|
|
2338
|
-
metricDirection: { type: "string", enum: ["at_least", "at_most"] },
|
|
2339
|
-
metricUnit: { type: "string" },
|
|
2340
|
-
metricStatus: { type: "string", enum: ["pending", "met", "missed", "waived"] },
|
|
2341
|
-
metricNotes: { type: "string" },
|
|
2342
|
-
checkId: { type: "string" },
|
|
2343
|
-
checkDescription: { type: "string" },
|
|
2344
|
-
checkStatus: { type: "string", enum: ["pending", "passed", "failed", "skipped"] },
|
|
2345
|
-
checkType: {
|
|
2346
|
-
type: "string",
|
|
2347
|
-
// Only types a verifier can actually execute. `manual` is the default and
|
|
2348
|
-
// means a human or agent asserts the status by hand. The rest are run by
|
|
2349
|
-
// `verify_completion` against the default deterministic registry. Types
|
|
2350
|
-
// with no plugin in that registry (`auto`, `review`, `agent`, `council`)
|
|
2351
|
-
// are deliberately omitted: offering them would produce criteria that
|
|
2352
|
-
// silently report `skipped — no verifier plugin registered`.
|
|
2353
|
-
enum: ["manual", "command", "test", "file_exists", "file_matches", "git_diff", "metric"],
|
|
2354
|
-
description: 'How this acceptance criterion is verified. Default "manual" (status set by hand). Any other value makes verify_completion execute it, so the criterion becomes real evidence rather than a self-assertion. Pair with checkNotes.'
|
|
2355
|
-
},
|
|
2356
|
-
checkNotes: {
|
|
2357
|
-
type: "string",
|
|
2358
|
-
description: 'The executable body for a non-manual checkType, read in preference to checkDescription. command/test: the shell command or test pattern. file_exists: the path. file_matches: JSON {"file","pattern","flags"}. git_diff: JSON {"expectedFiles","minChanges","maxChanges"}.'
|
|
2359
|
-
},
|
|
2360
|
-
// ── Contract map ───────────────────────────────────────────────────
|
|
2361
|
-
// The card contract: what this work targets, what it must not break, what
|
|
2362
|
-
// it risks, and what verifies it. Advisory by default — the readiness gate
|
|
2363
|
-
// deliberately does not require map structure, so a map is an operator
|
|
2364
|
-
// review aid, not work the model must complete before implementing.
|
|
2365
|
-
contractEnforcement: {
|
|
2366
|
-
type: "string",
|
|
2367
|
-
enum: ["off", "advisory", "strict"],
|
|
2368
|
-
description: "Board-level contract map enforcement. Default when first configured: advisory."
|
|
2369
|
-
},
|
|
2370
|
-
contractNodeId: { type: "string" },
|
|
2371
|
-
contractNodeKind: {
|
|
2372
|
-
type: "string",
|
|
2373
|
-
enum: ["objective", "guardrail", "risk", "component", "artifact", "verification"],
|
|
2374
|
-
description: "objective = what this card is for; guardrail = what must keep working; risk = what could go wrong; component/artifact = what it touches; verification = what settles it."
|
|
2375
|
-
},
|
|
2376
|
-
contractNodeTitle: { type: "string" },
|
|
2377
|
-
contractNodeDescription: { type: "string" },
|
|
2378
|
-
contractNodeState: {
|
|
2379
|
-
type: "string",
|
|
2380
|
-
enum: ["unknown", "active", "satisfied", "violated", "waived", "resolved"]
|
|
2381
|
-
},
|
|
2382
|
-
contractNodeEnforcement: {
|
|
2383
|
-
type: "string",
|
|
2384
|
-
enum: ["blocking", "advisory", "informational"]
|
|
2385
|
-
},
|
|
2386
|
-
/** Bind a node to an acceptance criterion or goal metric already on the task. */
|
|
2387
|
-
contractCheckId: { type: "string" },
|
|
2388
|
-
contractMetricId: { type: "string" },
|
|
2389
|
-
contractWaiverReason: {
|
|
2390
|
-
type: "string",
|
|
2391
|
-
description: 'Required, with an actor, when contractNodeState is "waived".'
|
|
2392
|
-
},
|
|
2393
|
-
contractEdgeId: { type: "string" },
|
|
2394
|
-
contractEdgeFrom: {
|
|
2395
|
-
type: "string",
|
|
2396
|
-
description: 'A contract node id, or a task id (bare or "task:<id>") for the card endpoint.'
|
|
2397
|
-
},
|
|
2398
|
-
contractEdgeTo: { type: "string" },
|
|
2399
|
-
contractEdgeType: {
|
|
2400
|
-
type: "string",
|
|
2401
|
-
enum: [
|
|
2402
|
-
"targets",
|
|
2403
|
-
"affects",
|
|
2404
|
-
"must_preserve",
|
|
2405
|
-
"exposes",
|
|
2406
|
-
"verified_by",
|
|
2407
|
-
"conflicts_with",
|
|
2408
|
-
"derived_from",
|
|
2409
|
-
"relates_to"
|
|
2410
|
-
]
|
|
2411
|
-
},
|
|
2412
|
-
contractEdgeRationale: { type: "string" },
|
|
2413
|
-
note: { type: "string" },
|
|
2414
|
-
author: { type: "string" },
|
|
2415
|
-
url: { type: "string" },
|
|
2416
|
-
linkTitle: { type: "string" },
|
|
2417
|
-
linkType: {
|
|
2418
|
-
type: "string",
|
|
2419
|
-
enum: ["issue", "pr", "doc", "commit", "design", "file", "url", "other"]
|
|
2420
|
-
},
|
|
2421
|
-
context: { type: "string" },
|
|
2422
|
-
columns: { type: "array", items: { type: "string" } },
|
|
2423
|
-
generatedBy: { type: "string" },
|
|
2424
|
-
includeTasks: { type: "boolean" },
|
|
2425
|
-
includeCompletedTasks: { type: "boolean" },
|
|
2426
|
-
preserveAssignment: { type: "boolean" },
|
|
2427
|
-
preserveDependencies: { type: "boolean" },
|
|
2428
|
-
moveTasksToColumnId: { type: "string" },
|
|
2429
|
-
atomicityMode: { type: "string", enum: ["off", "assess", "enforce"] },
|
|
2430
|
-
atomicityDecomposition: { type: "string", enum: ["auto", "propose"] },
|
|
2431
|
-
gateEnforcement: {
|
|
2432
|
-
type: "string",
|
|
2433
|
-
// WS-023: `'off'` is deliberately absent. The agent whose work this gate
|
|
2434
|
-
// checks must not be able to switch it off; it may only tighten. Turning
|
|
2435
|
-
// a gate off stays a human decision, made through board config.
|
|
2436
|
-
enum: ["strict", "soft"]
|
|
2437
|
-
},
|
|
2438
|
-
subtasks: {
|
|
2439
|
-
type: "array",
|
|
2440
|
-
minItems: 2,
|
|
2441
|
-
items: {
|
|
2442
|
-
type: "object",
|
|
2443
|
-
properties: {
|
|
2444
|
-
title: { type: "string" },
|
|
2445
|
-
description: { type: "string" },
|
|
2446
|
-
successCriteria: { type: "array", items: { type: "string" } },
|
|
2447
|
-
dependsOnIndex: { type: "array", items: { type: "number" } }
|
|
2448
|
-
},
|
|
2449
|
-
required: ["title"]
|
|
2450
|
-
}
|
|
2451
|
-
}
|
|
2452
|
-
},
|
|
2453
|
-
required: ["action"]
|
|
2454
|
-
};
|
|
2455
|
-
|
|
2456
|
-
// src/kanban.ts
|
|
2457
|
-
var kanbanTool = {
|
|
2458
|
-
name: "kanban",
|
|
2459
|
-
category: "Project",
|
|
2460
|
-
description: KANBAN_TOOL_DESCRIPTION,
|
|
2461
|
-
usageHint: KANBAN_TOOL_USAGE_HINT,
|
|
2462
|
-
permission: "confirm",
|
|
2463
|
-
subjectKey: "action",
|
|
2464
|
-
mutating: true,
|
|
2465
|
-
capabilities: ["fs.write"],
|
|
2466
|
-
icon: "task",
|
|
2467
|
-
timeoutMs: 3e4,
|
|
2468
|
-
inputSchema: KANBAN_INPUT_SCHEMA,
|
|
2469
|
-
async execute(input, ctx) {
|
|
2470
|
-
const projectRoot = ctx.projectRoot;
|
|
2471
|
-
if (!projectRoot) return fail("No project root is available.");
|
|
2472
|
-
const withPresence = createKanbanPresenceWrapper(projectRoot, input, ctx);
|
|
2473
|
-
try {
|
|
2474
|
-
const result = await (async () => {
|
|
2475
|
-
const decompositionResult = await handleKanbanDecompositionAction(projectRoot, input, ctx);
|
|
2476
|
-
if (decompositionResult !== void 0) return decompositionResult;
|
|
2477
|
-
const boardResult = await handleKanbanBoardAction(projectRoot, input, ctx);
|
|
2478
|
-
if (boardResult !== void 0) return boardResult;
|
|
2479
|
-
const lifecycleResult = await handleKanbanLifecycleAction(projectRoot, input, ctx);
|
|
2480
|
-
if (lifecycleResult !== void 0) return lifecycleResult;
|
|
2481
|
-
const contractResult = await handleKanbanContractAction(
|
|
2482
|
-
projectRoot,
|
|
2483
|
-
input,
|
|
2484
|
-
input.author ?? input.agentId
|
|
2485
|
-
);
|
|
2486
|
-
if (contractResult !== void 0) return contractResult;
|
|
2487
|
-
const detailResult = await handleKanbanDetailAction(projectRoot, input);
|
|
2488
|
-
if (detailResult !== void 0) return detailResult;
|
|
2489
|
-
return fail(`Unknown kanban action: ${input.action}`);
|
|
2490
|
-
})();
|
|
2491
|
-
return withPresence(result);
|
|
2492
|
-
} catch (err) {
|
|
2493
|
-
return fail(stripLifecycleIssues2(err instanceof Error ? err.message : String(err)));
|
|
2494
|
-
}
|
|
2495
|
-
},
|
|
2496
|
-
serialize(output, input) {
|
|
2497
|
-
return serializeKanbanOutput(output, input);
|
|
2498
|
-
}
|
|
2499
|
-
};
|
|
2500
|
-
|
|
2501
|
-
// src/todo.ts
|
|
2502
|
-
function normalizedTitle(value) {
|
|
2503
|
-
return value.trim().toLocaleLowerCase().replace(/\s+/g, " ");
|
|
2504
|
-
}
|
|
2505
|
-
function activeBoardId(items, ctx) {
|
|
2506
|
-
const metaKanban = ctx.meta?.["kanban"];
|
|
2507
|
-
const metaBoardId = metaKanban && typeof metaKanban === "object" ? metaKanban["boardId"] : void 0;
|
|
2508
|
-
return ctx.currentKanbanBoardId ?? (typeof metaBoardId === "string" ? metaBoardId : void 0) ?? items.find((item) => item.kanbanBoardId)?.kanbanBoardId ?? "";
|
|
2509
|
-
}
|
|
2510
|
-
function bindTodosToBoard(items, previous, board) {
|
|
2511
|
-
const previousById = new Map(previous.map((item) => [item.id, item]));
|
|
2512
|
-
const available = board.tasks.filter(
|
|
2513
|
-
(task) => task.status !== "archived" && task.mergedIntoTaskId === void 0 && (!task.childTaskIds || task.childTaskIds.length === 0)
|
|
2514
|
-
).sort(
|
|
2515
|
-
(left, right) => left.createdAt.localeCompare(right.createdAt) || left.order - right.order
|
|
2516
|
-
);
|
|
2517
|
-
const used = /* @__PURE__ */ new Set();
|
|
2518
|
-
return items.map((item) => {
|
|
2519
|
-
const previousItem = previousById.get(item.id);
|
|
2520
|
-
const requestedTaskId = item.kanbanBoardId === board.id ? item.kanbanTaskId : previousItem?.kanbanBoardId === board.id ? previousItem.kanbanTaskId : void 0;
|
|
2521
|
-
const title = normalizedTitle(item.content);
|
|
2522
|
-
const candidates = [
|
|
2523
|
-
requestedTaskId ? board.tasks.find((task2) => task2.id === requestedTaskId) : void 0,
|
|
2524
|
-
board.tasks.find((task2) => task2.id === item.id),
|
|
2525
|
-
board.tasks.find((task2) => task2.origin?.taskId === item.id),
|
|
2526
|
-
available.find((task2) => !used.has(task2.id) && normalizedTitle(task2.title) === title)
|
|
2527
|
-
];
|
|
2528
|
-
const task = candidates.find((candidate) => candidate && !used.has(candidate.id));
|
|
2529
|
-
if (!task) {
|
|
2530
|
-
const { blockedBy: _discarded, ...rest } = item;
|
|
2531
|
-
return { ...rest };
|
|
2532
|
-
}
|
|
2533
|
-
used.add(task.id);
|
|
2534
|
-
const blockedBy = blockingTitles(board, task);
|
|
2535
|
-
return {
|
|
2536
|
-
...item,
|
|
2537
|
-
kanbanBoardId: board.id,
|
|
2538
|
-
kanbanTaskId: task.id,
|
|
2539
|
-
...blockedBy.length ? { blockedBy } : { blockedBy: void 0 }
|
|
2540
|
-
};
|
|
2541
|
-
});
|
|
2542
|
-
}
|
|
2543
|
-
function demoteBlockedInProgress(items, warnings) {
|
|
2544
|
-
return items.map((item) => {
|
|
2545
|
-
if (item.status !== "in_progress" || !item.blockedBy?.length) return item;
|
|
2546
|
-
warnings.push(
|
|
2547
|
-
`"${item.content}" cannot start yet \u2014 it waits on: ${item.blockedBy.join("; ")}. Kept as pending; complete the blocking work first.`
|
|
2548
|
-
);
|
|
2549
|
-
return { ...item, status: "pending" };
|
|
2550
|
-
});
|
|
2551
|
-
}
|
|
2552
|
-
async function createMissingManagedCards(items, board, ctx, warnings) {
|
|
2553
|
-
const created = /* @__PURE__ */ new Map();
|
|
2554
|
-
for (const item of items) {
|
|
2555
|
-
if (item.kanbanBoardId === board.id && item.kanbanTaskId) continue;
|
|
2556
|
-
try {
|
|
2557
|
-
const result = await addTask3(ctx.projectRoot, board.id, {
|
|
2558
|
-
title: item.content,
|
|
2559
|
-
description: item.activeForm?.trim() || `Added from the session todo list: ${item.content}`
|
|
2560
|
-
});
|
|
2561
|
-
if (!result) {
|
|
2562
|
-
warnings.push(`Could not open a Kanban card for "${item.content}": board not found.`);
|
|
2563
|
-
continue;
|
|
2564
|
-
}
|
|
2565
|
-
created.set(item.id, result.task.id);
|
|
2566
|
-
} catch (error) {
|
|
2567
|
-
warnings.push(
|
|
2568
|
-
`Could not open a Kanban card for "${item.content}": ${error instanceof Error ? error.message : String(error)}`
|
|
2569
|
-
);
|
|
2570
|
-
}
|
|
2571
|
-
}
|
|
2572
|
-
return created;
|
|
2573
|
-
}
|
|
2574
|
-
async function synchronizeManagedKanban(items, board, ctx, signal) {
|
|
2575
|
-
let synced = 0;
|
|
2576
|
-
const warnings = [];
|
|
2577
|
-
const actor = ctx.agentId?.trim() || ctx.agentName?.trim() || "kanban-agent";
|
|
2578
|
-
const execute = async (input) => {
|
|
2579
|
-
const result = await kanbanTool.execute(input, ctx, { signal });
|
|
2580
|
-
if (!result.ok) warnings.push(result.message);
|
|
2581
|
-
else {
|
|
2582
|
-
synced++;
|
|
2583
|
-
if (result.message.includes("Warning:")) warnings.push(result.message);
|
|
2584
|
-
}
|
|
2585
|
-
return result;
|
|
2586
|
-
};
|
|
2587
|
-
for (const item of items) {
|
|
2588
|
-
if (item.status !== "pending" || item.kanbanBoardId !== board.id || !item.kanbanTaskId) {
|
|
2589
|
-
continue;
|
|
2590
|
-
}
|
|
2591
|
-
const task = board.tasks.find((candidate) => candidate.id === item.kanbanTaskId);
|
|
2592
|
-
if (task?.lifecycle?.currentStage !== "running") continue;
|
|
2593
|
-
const released = await execute({
|
|
2594
|
-
action: "mark_assignment",
|
|
2595
|
-
boardId: board.id,
|
|
2596
|
-
taskId: task.id,
|
|
2597
|
-
assignmentStatus: "assigned",
|
|
2598
|
-
agentId: actor,
|
|
2599
|
-
lastResult: `Todo returned to queue: ${item.content}`
|
|
2600
|
-
});
|
|
2601
|
-
if (!released.ok) continue;
|
|
2602
|
-
await execute({
|
|
2603
|
-
action: "transition_task",
|
|
2604
|
-
boardId: board.id,
|
|
2605
|
-
taskId: task.id,
|
|
2606
|
-
lifecycleStage: "todo",
|
|
2607
|
-
author: actor,
|
|
2608
|
-
transitionComment: `Todo returned to queue: ${item.content}`
|
|
2609
|
-
});
|
|
2610
|
-
}
|
|
2611
|
-
for (const item of items) {
|
|
2612
|
-
if (item.status === "completed" || item.kanbanBoardId !== board.id || !item.kanbanTaskId) {
|
|
2613
|
-
continue;
|
|
2614
|
-
}
|
|
2615
|
-
const task = board.tasks.find((candidate) => candidate.id === item.kanbanTaskId);
|
|
2616
|
-
if (task?.status !== "completed") continue;
|
|
2617
|
-
warnings.push(
|
|
2618
|
-
`"${item.content}" is already Done on the Kanban board and a completed card cannot be reopened; the row stays completed. Create a follow-up card for any remaining work.`
|
|
2619
|
-
);
|
|
2620
|
-
}
|
|
2621
|
-
for (const item of items) {
|
|
2622
|
-
if (item.status !== "completed" || item.kanbanBoardId !== board.id || !item.kanbanTaskId) {
|
|
2623
|
-
continue;
|
|
2624
|
-
}
|
|
2625
|
-
const task = board.tasks.find((candidate) => candidate.id === item.kanbanTaskId);
|
|
2626
|
-
if (!task || task.status === "completed") continue;
|
|
2627
|
-
const stage = task.lifecycle?.currentStage;
|
|
2628
|
-
if (stage === "backlog" || stage === "todo") {
|
|
2629
|
-
const started = await execute({
|
|
2630
|
-
action: "start_task",
|
|
2631
|
-
boardId: board.id,
|
|
2632
|
-
taskId: task.id,
|
|
2633
|
-
author: actor,
|
|
2634
|
-
agentId: actor,
|
|
2635
|
-
transitionComment: `Auto-started for completion: ${item.content}`
|
|
2636
|
-
});
|
|
2637
|
-
if (!started.ok) {
|
|
2638
|
-
continue;
|
|
2639
|
-
}
|
|
2640
|
-
}
|
|
2641
|
-
await execute({
|
|
2642
|
-
action: "mark_assignment",
|
|
2643
|
-
boardId: board.id,
|
|
2644
|
-
taskId: task.id,
|
|
2645
|
-
assignmentStatus: "completed",
|
|
2646
|
-
agentId: actor,
|
|
2647
|
-
lastResult: `Todo completed: ${item.content}`
|
|
2648
|
-
});
|
|
2649
|
-
}
|
|
2650
|
-
const attemptedParents = /* @__PURE__ */ new Set();
|
|
2651
|
-
let afterCompletions = await getBoard5(ctx.projectRoot, board.id);
|
|
2652
|
-
while (afterCompletions) {
|
|
2653
|
-
const parent = afterCompletions.tasks.find(
|
|
2654
|
-
(task) => task.atomic === true && task.status !== "completed" && Boolean(task.childTaskIds?.length) && !attemptedParents.has(task.id) && task.childTaskIds?.every(
|
|
2655
|
-
(childId) => afterCompletions?.tasks.find((candidate) => candidate.id === childId)?.status === "completed"
|
|
2656
|
-
)
|
|
2657
|
-
);
|
|
2658
|
-
if (!parent) break;
|
|
2659
|
-
attemptedParents.add(parent.id);
|
|
2660
|
-
const started = await execute({
|
|
2661
|
-
action: "start_task",
|
|
2662
|
-
boardId: board.id,
|
|
2663
|
-
taskId: parent.id,
|
|
2664
|
-
author: actor,
|
|
2665
|
-
agentId: actor,
|
|
2666
|
-
transitionComment: "All child tasks completed; validating composite parent."
|
|
2667
|
-
});
|
|
2668
|
-
if (started.ok) {
|
|
2669
|
-
await execute({
|
|
2670
|
-
action: "mark_assignment",
|
|
2671
|
-
boardId: board.id,
|
|
2672
|
-
taskId: parent.id,
|
|
2673
|
-
assignmentStatus: "completed",
|
|
2674
|
-
agentId: actor,
|
|
2675
|
-
lastResult: "All child tasks completed; composite result ready for verification."
|
|
2676
|
-
});
|
|
2677
|
-
}
|
|
2678
|
-
afterCompletions = await getBoard5(ctx.projectRoot, board.id);
|
|
2679
|
-
}
|
|
2680
|
-
const completionPending = items.some(
|
|
2681
|
-
(item) => item.status === "completed" && item.kanbanBoardId === board.id && Boolean(item.kanbanTaskId) && afterCompletions?.tasks.find((task) => task.id === item.kanbanTaskId)?.status !== "completed"
|
|
2682
|
-
);
|
|
2683
|
-
const active = items.find(
|
|
2684
|
-
(item) => item.status === "in_progress" && item.kanbanBoardId === board.id && Boolean(item.kanbanTaskId)
|
|
2685
|
-
);
|
|
2686
|
-
const activeStage = active?.kanbanTaskId ? afterCompletions?.tasks.find((task) => task.id === active.kanbanTaskId)?.lifecycle?.currentStage : void 0;
|
|
2687
|
-
if (active?.kanbanTaskId) {
|
|
2688
|
-
if (activeStage === "review" || activeStage === "done") {
|
|
2689
|
-
warnings.push(
|
|
2690
|
-
`"${active.content}" is in ${activeStage === "review" ? "Review" : "Done"} awaiting acceptance; not re-activating it from the todo list. ` + (activeStage === "review" ? "Call kanban start_task explicitly to reopen it as a repair." : "Done is terminal; reopen only by creating a follow-up card.")
|
|
2691
|
-
);
|
|
2692
|
-
} else {
|
|
2693
|
-
await execute({
|
|
2694
|
-
action: "start_task",
|
|
2695
|
-
boardId: board.id,
|
|
2696
|
-
taskId: active.kanbanTaskId,
|
|
2697
|
-
author: actor,
|
|
2698
|
-
agentId: actor,
|
|
2699
|
-
transitionComment: `Todo activated: ${active.content}`
|
|
2700
|
-
});
|
|
2701
|
-
}
|
|
2702
|
-
}
|
|
2703
|
-
if (active?.kanbanTaskId && activeStage === "review") {
|
|
2704
|
-
} else if (active?.kanbanTaskId && completionPending) {
|
|
2705
|
-
warnings.push(
|
|
2706
|
-
"A completed todo is still awaiting acceptance; the next independent Kanban task was started."
|
|
2707
|
-
);
|
|
2708
|
-
} else if (!active && ctx.currentKanbanBoardId === board.id) {
|
|
2709
|
-
ctx.setCurrentKanbanTask(void 0, board.id);
|
|
2710
|
-
}
|
|
2711
|
-
return { synced, warnings };
|
|
2712
|
-
}
|
|
2713
|
-
var todoTool = {
|
|
2714
|
-
name: "todo",
|
|
2715
|
-
category: "Session",
|
|
2716
|
-
description: "Manage the compact active-work list. With a managed Kanban binding, every row resolves to a real card and status changes advance that card; without Kanban it remains session-only state. Each call replaces ordering and supplied fields, but unfinished omitted rows are retained until completed.",
|
|
2717
|
-
usageHint: "BEST PRACTICE for complex tasks:\n- At the beginning of a non-trivial task, create a clear todo list with specific, actionable items.\n- Only **one** item should be `in_progress` at any time.\n- Update the list frequently as work progresses (mark items done, add new ones, change status).\n- **Re-order items** to reflect current priorities. Omission is not cancellation: unfinished rows are retained until completed.\n- When all items are completed the board auto-clears \u2014 you do NOT need to send an empty list.\n- The system and user can see this list, so keep it honest and up-to-date.\nThis tool is extremely valuable for maintaining focus and giving the user visibility into your plan.",
|
|
2718
|
-
permission: "confirm",
|
|
2719
|
-
mutating: true,
|
|
2720
|
-
timeoutMs: 3e4,
|
|
2721
|
-
capabilities: ["session.todo", "fs.write"],
|
|
2722
|
-
subjectKey: "todos",
|
|
2723
|
-
icon: "todo",
|
|
2724
|
-
inputSchema: {
|
|
2725
|
-
type: "object",
|
|
2726
|
-
properties: {
|
|
2727
|
-
todos: {
|
|
2728
|
-
type: "array",
|
|
2729
|
-
items: {
|
|
2730
|
-
type: "object",
|
|
2731
|
-
properties: {
|
|
2732
|
-
id: {
|
|
2733
|
-
type: "string",
|
|
2734
|
-
description: 'Unique identifier for the todo item (e.g. "1", "auth-flow").'
|
|
2735
|
-
},
|
|
2736
|
-
content: {
|
|
2737
|
-
type: "string",
|
|
2738
|
-
description: "Clear, actionable description of the task."
|
|
2739
|
-
},
|
|
2740
|
-
status: {
|
|
2741
|
-
type: "string",
|
|
2742
|
-
enum: ["pending", "in_progress", "completed"],
|
|
2743
|
-
description: 'Current status. Only one item should be "in_progress" at a time.'
|
|
2744
|
-
},
|
|
2745
|
-
activeForm: {
|
|
2746
|
-
type: "string",
|
|
2747
|
-
description: 'Optional present-tense form shown while the task is active (e.g. "Fixing auth bug").'
|
|
2748
|
-
},
|
|
2749
|
-
kanbanBoardId: {
|
|
2750
|
-
type: "string",
|
|
2751
|
-
description: "Kanban board that owns this UI row when Kanban is active."
|
|
2752
|
-
},
|
|
2753
|
-
kanbanTaskId: {
|
|
2754
|
-
type: "string",
|
|
2755
|
-
description: "Real Kanban task represented by this UI row."
|
|
2756
|
-
}
|
|
2757
|
-
},
|
|
2758
|
-
required: ["id", "content", "status"]
|
|
2759
|
-
},
|
|
2760
|
-
description: "The desired todo list. Supplied rows are replaced/reordered; unfinished omitted rows are retained."
|
|
2761
|
-
}
|
|
2762
|
-
},
|
|
2763
|
-
required: ["todos"]
|
|
2764
|
-
},
|
|
2765
|
-
async execute(input, ctx, call) {
|
|
2766
|
-
if (!Array.isArray(input?.todos)) {
|
|
2767
|
-
throw new Error("todo: todos must be an array");
|
|
2768
|
-
}
|
|
2769
|
-
const items = input.todos.filter((t) => Boolean(t?.id && t.content));
|
|
2770
|
-
const todoIdentity = (item) => item.kanbanBoardId && item.kanbanTaskId ? `kanban:${item.kanbanBoardId}:${item.kanbanTaskId}` : item.promotedFromTask ? `task:${item.promotedFromTask}` : item.promotedFromPlan ? `plan:${item.promotedFromPlan}` : `todo:${item.id}`;
|
|
2771
|
-
const requestedIdentities = new Set(items.map(todoIdentity));
|
|
2772
|
-
for (const previous of ctx.todos ?? []) {
|
|
2773
|
-
const identity = todoIdentity(previous);
|
|
2774
|
-
if (previous.status === "completed" || requestedIdentities.has(identity)) {
|
|
2775
|
-
continue;
|
|
2776
|
-
}
|
|
2777
|
-
items.push({ ...previous });
|
|
2778
|
-
requestedIdentities.add(identity);
|
|
2779
|
-
}
|
|
2780
|
-
const inProgress = items.filter((t) => t.status === "in_progress");
|
|
2781
|
-
if (inProgress.length > 1) {
|
|
2782
|
-
let seenInProgress = false;
|
|
2783
|
-
for (const item of items) {
|
|
2784
|
-
if (item.status === "in_progress") {
|
|
2785
|
-
if (seenInProgress) item.status = "pending";
|
|
2786
|
-
seenInProgress = true;
|
|
2787
|
-
}
|
|
2788
|
-
}
|
|
2789
|
-
}
|
|
2790
|
-
const boardId = activeBoardId(items, ctx);
|
|
2791
|
-
let board = boardId ? await getBoard5(ctx.projectRoot, boardId) : null;
|
|
2792
|
-
const managed = board?.lifecycle?.mode === "managed";
|
|
2793
|
-
let boundItems = managed && board ? bindTodosToBoard(items, ctx.todos ?? [], board) : items;
|
|
2794
|
-
const creationWarnings = [];
|
|
2795
|
-
if (managed && board) {
|
|
2796
|
-
const managedBoardId = board.id;
|
|
2797
|
-
const created = await createMissingManagedCards(boundItems, board, ctx, creationWarnings);
|
|
2798
|
-
if (created.size > 0) {
|
|
2799
|
-
boundItems = boundItems.map((item) => {
|
|
2800
|
-
const taskId = created.get(item.id);
|
|
2801
|
-
return taskId ? { ...item, kanbanBoardId: managedBoardId, kanbanTaskId: taskId } : item;
|
|
2802
|
-
});
|
|
2803
|
-
board = await getBoard5(ctx.projectRoot, managedBoardId) ?? board;
|
|
2804
|
-
boundItems = bindTodosToBoard(boundItems, ctx.todos ?? [], board);
|
|
2805
|
-
}
|
|
2806
|
-
boundItems = demoteBlockedInProgress(boundItems, creationWarnings);
|
|
2807
|
-
}
|
|
2808
|
-
ctx.state.replaceTodos(boundItems);
|
|
2809
|
-
const kanbanSync = managed && board ? await synchronizeManagedKanban(boundItems, board, ctx, call.signal) : { synced: 0, warnings: [] };
|
|
2810
|
-
kanbanSync.warnings.unshift(...creationWarnings);
|
|
2811
|
-
if (managed && board) {
|
|
2812
|
-
const unresolved = boundItems.filter(
|
|
2813
|
-
(item) => item.kanbanBoardId !== board.id || !item.kanbanTaskId
|
|
2814
|
-
);
|
|
2815
|
-
if (unresolved.length > 0) {
|
|
2816
|
-
kanbanSync.warnings.push(
|
|
2817
|
-
`${unresolved.length} Todo row(s) could not be bound to a Kanban task and were not applied. Preserve kanbanBoardId/kanbanTaskId when updating the projection.`
|
|
2818
|
-
);
|
|
2819
|
-
}
|
|
2820
|
-
}
|
|
2821
|
-
const mirrorFailure = takeSessionMirrorFailure(ctx.projectRoot, ctx.session?.id ?? "");
|
|
2822
|
-
if (mirrorFailure) kanbanSync.warnings.push(mirrorFailure);
|
|
2823
|
-
let projectedBoard = board;
|
|
2824
|
-
if (managed && board) {
|
|
2825
|
-
const refreshed = await getBoard5(ctx.projectRoot, board.id);
|
|
2826
|
-
if (refreshed) {
|
|
2827
|
-
projectedBoard = refreshed;
|
|
2828
|
-
applyManagedKanbanBoardToTodos2(ctx, refreshed);
|
|
2829
|
-
}
|
|
2830
|
-
}
|
|
2831
|
-
if (!managed) {
|
|
2832
|
-
mirrorSessionTodosToKanban(ctx.projectRoot, items, ctx.session?.id ?? "session");
|
|
2833
|
-
}
|
|
2834
|
-
const completedPlanIds = /* @__PURE__ */ new Set();
|
|
2835
|
-
const completedTaskIds = /* @__PURE__ */ new Set();
|
|
2836
|
-
const pendingPlanIds = /* @__PURE__ */ new Set();
|
|
2837
|
-
const pendingTaskIds = /* @__PURE__ */ new Set();
|
|
2838
|
-
for (const item of items) {
|
|
2839
|
-
if (item.promotedFromPlan) {
|
|
2840
|
-
(item.status === "completed" ? completedPlanIds : pendingPlanIds).add(
|
|
2841
|
-
item.promotedFromPlan
|
|
2842
|
-
);
|
|
2843
|
-
}
|
|
2844
|
-
if (item.promotedFromTask) {
|
|
2845
|
-
(item.status === "completed" ? completedTaskIds : pendingTaskIds).add(
|
|
2846
|
-
item.promotedFromTask
|
|
2847
|
-
);
|
|
2848
|
-
}
|
|
2849
|
-
}
|
|
2850
|
-
for (const planId of completedPlanIds) {
|
|
2851
|
-
if (pendingPlanIds.has(planId)) continue;
|
|
2852
|
-
const meta = ctx.meta;
|
|
2853
|
-
const planPath = meta["plan.path.resolved"] ?? meta["plan.path"];
|
|
2854
|
-
if (typeof planPath !== "string" || !planPath) continue;
|
|
2855
|
-
try {
|
|
2856
|
-
const plan = await loadPlan2(planPath);
|
|
2857
|
-
if (plan) {
|
|
2858
|
-
const updated = setPlanItemStatus(plan, planId, "done");
|
|
2859
|
-
await savePlan(planPath, updated);
|
|
2860
|
-
}
|
|
2861
|
-
} catch {
|
|
2862
|
-
}
|
|
2863
|
-
}
|
|
2864
|
-
for (const taskId of completedTaskIds) {
|
|
2865
|
-
if (pendingTaskIds.has(taskId)) continue;
|
|
2866
|
-
const meta = ctx.meta;
|
|
2867
|
-
const taskPath = meta["task.path.resolved"] ?? meta["task.path"];
|
|
2868
|
-
if (typeof taskPath !== "string" || !taskPath) continue;
|
|
2869
|
-
try {
|
|
2870
|
-
const file = await loadTasks3(taskPath);
|
|
2871
|
-
if (file) {
|
|
2872
|
-
const task = file.tasks.find((t) => t.id === taskId);
|
|
2873
|
-
if (task && task.status !== "completed") {
|
|
2874
|
-
task.status = "completed";
|
|
2875
|
-
task.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
2876
|
-
await saveTasks(taskPath, file);
|
|
2877
|
-
}
|
|
2878
|
-
}
|
|
2879
|
-
} catch {
|
|
2880
|
-
}
|
|
2881
|
-
}
|
|
2882
|
-
return {
|
|
2883
|
-
count: items.length,
|
|
2884
|
-
in_progress: (ctx.todos ?? boundItems).filter((t) => t.status === "in_progress").length,
|
|
2885
|
-
...kanbanSync.synced > 0 ? { kanban_synced: kanbanSync.synced } : {},
|
|
2886
|
-
...kanbanSync.warnings.length > 0 ? { kanban_warnings: kanbanSync.warnings } : {},
|
|
2887
|
-
...projectedBoard?.lifecycle?.mode === "managed" ? {
|
|
2888
|
-
kanban_bindings: boundItems.flatMap((item) => {
|
|
2889
|
-
if (item.kanbanBoardId !== projectedBoard.id || !item.kanbanTaskId) return [];
|
|
2890
|
-
const task = projectedBoard.tasks.find(
|
|
2891
|
-
(candidate) => candidate.id === item.kanbanTaskId
|
|
2892
|
-
);
|
|
2893
|
-
return task ? [
|
|
2894
|
-
{
|
|
2895
|
-
todoId: item.id,
|
|
2896
|
-
boardId: projectedBoard.id,
|
|
2897
|
-
taskId: task.id,
|
|
2898
|
-
taskStatus: task.status
|
|
2899
|
-
}
|
|
2900
|
-
] : [];
|
|
2901
|
-
})
|
|
2902
|
-
} : {}
|
|
2903
|
-
};
|
|
2904
|
-
}
|
|
2905
|
-
};
|
|
2906
|
-
|
|
2907
|
-
// src/task.ts
|
|
2908
|
-
function findTaskIndex(tasks, query) {
|
|
2909
|
-
const asNum = Number.parseInt(query, 10);
|
|
2910
|
-
if (!Number.isNaN(asNum)) {
|
|
2911
|
-
const idx = asNum - 1;
|
|
2912
|
-
if (tasks[idx]) return idx;
|
|
2913
|
-
}
|
|
2914
|
-
const byId = tasks.findIndex((t) => t.id === query);
|
|
2915
|
-
if (byId >= 0) return byId;
|
|
2916
|
-
const lower = query.toLowerCase();
|
|
2917
|
-
return tasks.findIndex((t) => t.title.toLowerCase().includes(lower));
|
|
2918
|
-
}
|
|
2919
|
-
var taskTool = {
|
|
2920
|
-
name: "task",
|
|
2921
|
-
category: "Session",
|
|
2922
|
-
description: 'Manage session-persistent structured work items with dependencies, types, and priorities. Unlike `todo` (flat, tactical), `task` supports typed work (feature/bugfix/refactor/etc.), dependencies between items, priority ranking, and agent assignment. Tasks are written to disk and survive session resumes. By default they are isolated to this session; use `scope: "project"` to store tasks in a shared project-level file visible to all sessions.',
|
|
2923
|
-
usageHint: 'USE FOR STRUCTURED WORK:\n- `action: "replace"` \u2014 replace task details/order without omitting unfinished persisted tasks\n- `action: "add"` \u2014 append a single task\n- `action: "status"` \u2014 update a task\'s status (e.g. pending\u2192in_progress, in_progress\u2192completed)\n- `action: "show"` \u2014 view current tasks without changing them\n- `action: "promote"` \u2014 convert a task into actionable todo items via `target` (id|index|substring)\n- `action: "planify"` \u2014 promote a task to a plan item (strategic level) via `target` (id|index|substring)\n\nTask fields:\n- `dependsOn`: list of task IDs this one waits for\n- `type`: "feature" | "bugfix" | "refactor" | "docs" | "test" | "chore"\n- `priority`: "critical" | "high" | "medium" | "low"\n- `assignee`: agent/subagent name (e.g. "bug-hunter", "refactor-planner")\n- `estimateHours`: rough time estimate\n- `scope`: "session" (default, isolated) or "project" (shared across sessions)',
|
|
2924
|
-
permission: "confirm",
|
|
2925
|
-
mutating: true,
|
|
2926
|
-
subjectKey: "action",
|
|
2927
|
-
capabilities: ["fs.write"],
|
|
2928
|
-
icon: "task",
|
|
2929
|
-
timeoutMs: 5e3,
|
|
2930
|
-
inputSchema: {
|
|
2931
|
-
type: "object",
|
|
2932
|
-
properties: {
|
|
2933
|
-
action: {
|
|
2934
|
-
type: "string",
|
|
2935
|
-
enum: ["replace", "add", "status", "show", "promote", "planify"],
|
|
2936
|
-
description: "replace = set full list, add = append, status = update task status, show = view only, promote = convert task to todos, planify = convert task to plan item."
|
|
2937
|
-
},
|
|
2938
|
-
tasks: {
|
|
2939
|
-
type: "array",
|
|
2940
|
-
items: {
|
|
2941
|
-
type: "object",
|
|
2942
|
-
properties: {
|
|
2943
|
-
id: { type: "string", description: 'Unique id (e.g. "t1", "auth-flow").' },
|
|
2944
|
-
title: { type: "string", description: "Short title." },
|
|
2945
|
-
description: { type: "string", description: "Optional details." },
|
|
2946
|
-
type: {
|
|
2947
|
-
type: "string",
|
|
2948
|
-
enum: ["feature", "bugfix", "refactor", "docs", "test", "chore"]
|
|
2949
|
-
},
|
|
2950
|
-
priority: { type: "string", enum: ["critical", "high", "medium", "low"] },
|
|
2951
|
-
status: {
|
|
2952
|
-
type: "string",
|
|
2953
|
-
enum: ["pending", "in_progress", "blocked", "failed", "review", "completed"]
|
|
2954
|
-
},
|
|
2955
|
-
dependsOn: {
|
|
2956
|
-
type: "array",
|
|
2957
|
-
items: { type: "string" },
|
|
2958
|
-
description: "IDs of tasks this one depends on."
|
|
2959
|
-
},
|
|
2960
|
-
assignee: { type: "string", description: "Agent/subagent assigned." },
|
|
2961
|
-
estimateHours: { type: "number", description: "Estimated hours." },
|
|
2962
|
-
tags: { type: "array", items: { type: "string" }, description: "Optional tags." },
|
|
2963
|
-
createdAt: { type: "string" },
|
|
2964
|
-
updatedAt: { type: "string" }
|
|
2965
|
-
},
|
|
2966
|
-
required: ["id", "title", "type", "priority", "status"]
|
|
2967
|
-
},
|
|
2968
|
-
description: "Complete desired task list. Existing unfinished tasks may not be omitted; complete them first."
|
|
2969
|
-
},
|
|
2970
|
-
task: {
|
|
2971
|
-
type: "object",
|
|
2972
|
-
properties: {
|
|
2973
|
-
title: { type: "string" },
|
|
2974
|
-
description: { type: "string" },
|
|
2975
|
-
type: {
|
|
2976
|
-
type: "string",
|
|
2977
|
-
enum: ["feature", "bugfix", "refactor", "docs", "test", "chore"]
|
|
2978
|
-
},
|
|
2979
|
-
priority: { type: "string", enum: ["critical", "high", "medium", "low"] },
|
|
2980
|
-
status: {
|
|
2981
|
-
type: "string",
|
|
2982
|
-
enum: ["pending", "in_progress", "blocked", "failed", "review", "completed"]
|
|
2983
|
-
},
|
|
2984
|
-
dependsOn: { type: "array", items: { type: "string" } },
|
|
2985
|
-
assignee: { type: "string" },
|
|
2986
|
-
estimateHours: { type: "number" },
|
|
2987
|
-
tags: { type: "array", items: { type: "string" } }
|
|
2988
|
-
},
|
|
2989
|
-
required: ["title", "type", "priority"],
|
|
2990
|
-
description: "Single task to append (id/createdAt/updatedAt auto-generated)."
|
|
2991
|
-
},
|
|
2992
|
-
id: {
|
|
2993
|
-
type: "string",
|
|
2994
|
-
description: "Task id for action=status or target for action=promote."
|
|
2995
|
-
},
|
|
2996
|
-
status: {
|
|
2997
|
-
type: "string",
|
|
2998
|
-
enum: ["pending", "in_progress", "blocked", "failed", "review", "completed"],
|
|
2999
|
-
description: "New status for action=status."
|
|
3000
|
-
},
|
|
3001
|
-
target: {
|
|
3002
|
-
type: "string",
|
|
3003
|
-
description: "Target task identifier (id, 1-based index, or title substring) for action=promote."
|
|
3004
|
-
},
|
|
3005
|
-
subtasks: {
|
|
3006
|
-
type: "array",
|
|
3007
|
-
items: { type: "string" },
|
|
3008
|
-
description: "Optional subtask titles for action=promote. Each becomes a pending todo."
|
|
3009
|
-
},
|
|
3010
|
-
scope: {
|
|
3011
|
-
type: "string",
|
|
3012
|
-
enum: ["session", "project"],
|
|
3013
|
-
description: 'Storage scope: "session" (default, isolated to this session) or "project" (shared across all sessions for this project).'
|
|
3014
|
-
}
|
|
3015
|
-
},
|
|
3016
|
-
required: ["action"]
|
|
3017
|
-
},
|
|
3018
|
-
async execute(input, ctx) {
|
|
3019
|
-
const sessionTaskPath = ctx.meta["task.path"];
|
|
3020
|
-
let taskPath;
|
|
3021
|
-
if (input.scope === "project") {
|
|
3022
|
-
if (typeof sessionTaskPath === "string") {
|
|
3023
|
-
const lastSep = Math.max(
|
|
3024
|
-
sessionTaskPath.lastIndexOf("/"),
|
|
3025
|
-
sessionTaskPath.lastIndexOf("\\")
|
|
3026
|
-
);
|
|
3027
|
-
taskPath = lastSep >= 0 ? sessionTaskPath.slice(0, lastSep + 1) + "backlog.tasks.json" : "backlog.tasks.json";
|
|
3028
|
-
}
|
|
3029
|
-
} else {
|
|
3030
|
-
taskPath = sessionTaskPath;
|
|
3031
|
-
}
|
|
3032
|
-
if (typeof taskPath !== "string" || !taskPath) {
|
|
3033
|
-
return {
|
|
3034
|
-
ok: false,
|
|
3035
|
-
message: "Task storage path not configured.",
|
|
3036
|
-
count: 0,
|
|
3037
|
-
completed: 0,
|
|
3038
|
-
inProgress: 0
|
|
3039
|
-
};
|
|
3040
|
-
}
|
|
3041
|
-
const sessionId = ctx.session?.id ?? "unknown";
|
|
3042
|
-
let early = null;
|
|
3043
|
-
const promoteMeta = { count: 0, title: "" };
|
|
3044
|
-
const planifyMeta = { title: "", details: "" };
|
|
3045
|
-
let didPlanify = false;
|
|
3046
|
-
let todosToReplace = null;
|
|
3047
|
-
let file;
|
|
3048
|
-
try {
|
|
3049
|
-
file = await mutateTasks2(taskPath, sessionId, async (f) => {
|
|
3050
|
-
switch (input.action) {
|
|
3051
|
-
case "show":
|
|
3052
|
-
break;
|
|
3053
|
-
case "replace": {
|
|
3054
|
-
if (!Array.isArray(input.tasks)) {
|
|
3055
|
-
early = {
|
|
3056
|
-
ok: false,
|
|
3057
|
-
message: "action=replace requires `tasks` array.",
|
|
3058
|
-
count: 0,
|
|
3059
|
-
completed: 0,
|
|
3060
|
-
inProgress: 0
|
|
3061
|
-
};
|
|
3062
|
-
return f;
|
|
3063
|
-
}
|
|
3064
|
-
const newIds = new Set(input.tasks.map((t) => t.id));
|
|
3065
|
-
if (newIds.size !== input.tasks.length) {
|
|
3066
|
-
const seen = /* @__PURE__ */ new Set();
|
|
3067
|
-
const dupes = [
|
|
3068
|
-
...new Set(
|
|
3069
|
-
input.tasks.map((t) => t.id).filter((id) => {
|
|
3070
|
-
if (seen.has(id)) return true;
|
|
3071
|
-
seen.add(id);
|
|
3072
|
-
return false;
|
|
3073
|
-
})
|
|
3074
|
-
)
|
|
3075
|
-
];
|
|
3076
|
-
early = {
|
|
3077
|
-
ok: false,
|
|
3078
|
-
message: `action=replace has duplicate task IDs: ${dupes.join(", ")}. Each task id must be unique.`,
|
|
3079
|
-
count: 0,
|
|
3080
|
-
completed: 0,
|
|
3081
|
-
inProgress: 0
|
|
3082
|
-
};
|
|
3083
|
-
return f;
|
|
3084
|
-
}
|
|
3085
|
-
const omittedUnfinished = f.tasks.filter(
|
|
3086
|
-
(task) => task.status !== "completed" && !newIds.has(task.id)
|
|
3087
|
-
);
|
|
3088
|
-
if (omittedUnfinished.length > 0) {
|
|
3089
|
-
early = {
|
|
3090
|
-
ok: false,
|
|
3091
|
-
message: `action=replace cannot omit unfinished tasks: ${omittedUnfinished.map((task) => task.id).join(", ")}. Complete them first.`,
|
|
3092
|
-
count: f.tasks.length,
|
|
3093
|
-
...computeTaskItemProgress(f.tasks)
|
|
3094
|
-
};
|
|
3095
|
-
return f;
|
|
3096
|
-
}
|
|
3097
|
-
for (const t of input.tasks) {
|
|
3098
|
-
if (t.dependsOn && t.dependsOn.length > 0) {
|
|
3099
|
-
const missing = t.dependsOn.filter((d) => !newIds.has(d));
|
|
3100
|
-
if (missing.length > 0) {
|
|
3101
|
-
early = {
|
|
3102
|
-
ok: false,
|
|
3103
|
-
message: `dependsOn validation failed: task "${t.id}" references unknown IDs: ${missing.join(", ")}`,
|
|
3104
|
-
count: 0,
|
|
3105
|
-
completed: 0,
|
|
3106
|
-
inProgress: 0
|
|
3107
|
-
};
|
|
3108
|
-
return f;
|
|
3109
|
-
}
|
|
3110
|
-
}
|
|
3111
|
-
if (t.status === "in_progress" || t.status === "completed") {
|
|
3112
|
-
const unmet = (t.dependsOn ?? []).filter(
|
|
3113
|
-
(dependencyId) => input.tasks?.find((candidate) => candidate.id === dependencyId)?.status !== "completed"
|
|
3114
|
-
);
|
|
3115
|
-
if (unmet.length > 0) {
|
|
3116
|
-
early = {
|
|
3117
|
-
ok: false,
|
|
3118
|
-
message: `dependency status validation failed: task "${t.id}" cannot be ${t.status} before completion of ${unmet.join(", ")}.`,
|
|
3119
|
-
count: f.tasks.length,
|
|
3120
|
-
...computeTaskItemProgress(f.tasks)
|
|
3121
|
-
};
|
|
3122
|
-
return f;
|
|
3123
|
-
}
|
|
3124
|
-
}
|
|
3125
|
-
}
|
|
3126
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
3127
|
-
f.tasks = input.tasks.map((t) => ({
|
|
3128
|
-
...t,
|
|
3129
|
-
createdAt: t.createdAt || now,
|
|
3130
|
-
updatedAt: now
|
|
3131
|
-
}));
|
|
3132
|
-
break;
|
|
3133
|
-
}
|
|
3134
|
-
case "add": {
|
|
3135
|
-
const t = input.task;
|
|
3136
|
-
if (!t?.title) {
|
|
3137
|
-
early = {
|
|
3138
|
-
ok: false,
|
|
3139
|
-
message: "action=add requires `task` with at least `title`.",
|
|
3140
|
-
count: 0,
|
|
3141
|
-
completed: 0,
|
|
3142
|
-
inProgress: 0
|
|
3143
|
-
};
|
|
3144
|
-
return f;
|
|
3145
|
-
}
|
|
3146
|
-
if (t.dependsOn && t.dependsOn.length > 0) {
|
|
3147
|
-
const existingIds = new Set(f.tasks.map((e) => e.id));
|
|
3148
|
-
const missing = t.dependsOn.filter((d) => !existingIds.has(d));
|
|
3149
|
-
if (missing.length > 0) {
|
|
3150
|
-
early = {
|
|
3151
|
-
ok: false,
|
|
3152
|
-
message: `dependsOn validation failed: unknown task IDs: ${missing.join(", ")}`,
|
|
3153
|
-
count: 0,
|
|
3154
|
-
completed: 0,
|
|
3155
|
-
inProgress: 0
|
|
3156
|
-
};
|
|
3157
|
-
return f;
|
|
3158
|
-
}
|
|
3159
|
-
}
|
|
3160
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
3161
|
-
const newTask = {
|
|
3162
|
-
id: `task_${Date.now()}_${randomUUID3().slice(0, 8)}`,
|
|
3163
|
-
title: t.title,
|
|
3164
|
-
description: t.description,
|
|
3165
|
-
type: t.type || "feature",
|
|
3166
|
-
priority: t.priority || "medium",
|
|
3167
|
-
status: t.status || "pending",
|
|
3168
|
-
dependsOn: t.dependsOn,
|
|
3169
|
-
assignee: t.assignee,
|
|
3170
|
-
estimateHours: t.estimateHours,
|
|
3171
|
-
tags: t.tags,
|
|
3172
|
-
createdAt: now,
|
|
3173
|
-
updatedAt: now
|
|
3174
|
-
};
|
|
3175
|
-
f.tasks.push(newTask);
|
|
3176
|
-
break;
|
|
3177
|
-
}
|
|
3178
|
-
case "status": {
|
|
3179
|
-
if (!input.id || !input.status) {
|
|
3180
|
-
early = {
|
|
3181
|
-
ok: false,
|
|
3182
|
-
message: "action=status requires `id` and `status`.",
|
|
3183
|
-
count: 0,
|
|
3184
|
-
completed: 0,
|
|
3185
|
-
inProgress: 0
|
|
3186
|
-
};
|
|
3187
|
-
return f;
|
|
3188
|
-
}
|
|
3189
|
-
const task = f.tasks.find((t) => t.id === input.id);
|
|
3190
|
-
if (!task) {
|
|
3191
|
-
early = {
|
|
3192
|
-
ok: false,
|
|
3193
|
-
message: `Task "${input.id}" not found.`,
|
|
3194
|
-
count: 0,
|
|
3195
|
-
completed: 0,
|
|
3196
|
-
inProgress: 0
|
|
3197
|
-
};
|
|
3198
|
-
return f;
|
|
3199
|
-
}
|
|
3200
|
-
if (input.status === "in_progress" || input.status === "completed") {
|
|
3201
|
-
const unmet = (task.dependsOn ?? []).filter(
|
|
3202
|
-
(dependencyId) => f.tasks.find((candidate) => candidate.id === dependencyId)?.status !== "completed"
|
|
3203
|
-
);
|
|
3204
|
-
if (unmet.length > 0) {
|
|
3205
|
-
early = {
|
|
3206
|
-
ok: false,
|
|
3207
|
-
message: `Task "${task.id}" cannot be ${input.status} before dependencies complete: ${unmet.join(", ")}.`,
|
|
3208
|
-
count: f.tasks.length,
|
|
3209
|
-
...computeTaskItemProgress(f.tasks)
|
|
3210
|
-
};
|
|
3211
|
-
return f;
|
|
3212
|
-
}
|
|
3213
|
-
}
|
|
3214
|
-
task.status = input.status;
|
|
3215
|
-
task.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
3216
|
-
break;
|
|
3217
|
-
}
|
|
3218
|
-
case "promote": {
|
|
3219
|
-
const target = input.target?.trim();
|
|
3220
|
-
if (!target) {
|
|
3221
|
-
early = {
|
|
3222
|
-
ok: false,
|
|
3223
|
-
message: "action=promote requires `target` (task id, index, or title substring).",
|
|
3224
|
-
count: 0,
|
|
3225
|
-
completed: 0,
|
|
3226
|
-
inProgress: 0
|
|
3227
|
-
};
|
|
3228
|
-
return f;
|
|
3229
|
-
}
|
|
3230
|
-
const idx = findTaskIndex(f.tasks, target);
|
|
3231
|
-
if (idx === -1) {
|
|
3232
|
-
early = {
|
|
3233
|
-
ok: false,
|
|
3234
|
-
message: `No task matched "${target}".`,
|
|
3235
|
-
count: 0,
|
|
3236
|
-
completed: 0,
|
|
3237
|
-
inProgress: 0
|
|
3238
|
-
};
|
|
3239
|
-
return f;
|
|
3240
|
-
}
|
|
3241
|
-
const match = f.tasks[idx];
|
|
3242
|
-
if (!match) {
|
|
3243
|
-
early = {
|
|
3244
|
-
ok: false,
|
|
3245
|
-
message: `No task matched "${target}".`,
|
|
3246
|
-
count: 0,
|
|
3247
|
-
completed: 0,
|
|
3248
|
-
inProgress: 0
|
|
3249
|
-
};
|
|
3250
|
-
return f;
|
|
3251
|
-
}
|
|
3252
|
-
if (match.status !== "completed" && match.status !== "failed") {
|
|
3253
|
-
match.status = "in_progress";
|
|
3254
|
-
match.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
3255
|
-
}
|
|
3256
|
-
const todos = [];
|
|
3257
|
-
const ts = Date.now();
|
|
3258
|
-
todos.push({
|
|
3259
|
-
id: `todo_${ts}_task`,
|
|
3260
|
-
content: match.title,
|
|
3261
|
-
status: "in_progress",
|
|
3262
|
-
activeForm: match.title,
|
|
3263
|
-
promotedFromTask: match.id
|
|
3264
|
-
});
|
|
3265
|
-
if (match.description) {
|
|
3266
|
-
todos.push({
|
|
3267
|
-
id: `todo_${ts}_${randomUUID3().slice(0, 6)}`,
|
|
3268
|
-
content: match.description.slice(0, 200),
|
|
3269
|
-
status: "pending",
|
|
3270
|
-
promotedFromTask: match.id
|
|
3271
|
-
});
|
|
3272
|
-
}
|
|
3273
|
-
if (input.subtasks && input.subtasks.length > 0) {
|
|
3274
|
-
for (const st of input.subtasks) {
|
|
3275
|
-
todos.push({
|
|
3276
|
-
id: `todo_${ts}_${randomUUID3().slice(0, 6)}`,
|
|
3277
|
-
content: st,
|
|
3278
|
-
status: "pending",
|
|
3279
|
-
promotedFromTask: match.id
|
|
3280
|
-
});
|
|
3281
|
-
}
|
|
3282
|
-
}
|
|
3283
|
-
todosToReplace = todos;
|
|
3284
|
-
promoteMeta.count = todos.length;
|
|
3285
|
-
promoteMeta.title = match.title;
|
|
3286
|
-
break;
|
|
3287
|
-
}
|
|
3288
|
-
case "planify": {
|
|
3289
|
-
const target = input.target?.trim();
|
|
3290
|
-
if (!target) {
|
|
3291
|
-
early = {
|
|
3292
|
-
ok: false,
|
|
3293
|
-
message: "action=planify requires `target` (task id, index, or title substring).",
|
|
3294
|
-
count: 0,
|
|
3295
|
-
completed: 0,
|
|
3296
|
-
inProgress: 0
|
|
3297
|
-
};
|
|
3298
|
-
return f;
|
|
3299
|
-
}
|
|
3300
|
-
const idx = findTaskIndex(f.tasks, target);
|
|
3301
|
-
if (idx === -1) {
|
|
3302
|
-
early = {
|
|
3303
|
-
ok: false,
|
|
3304
|
-
message: `No task matched "${target}".`,
|
|
3305
|
-
count: 0,
|
|
3306
|
-
completed: 0,
|
|
3307
|
-
inProgress: 0
|
|
3308
|
-
};
|
|
3309
|
-
return f;
|
|
3310
|
-
}
|
|
3311
|
-
const match = f.tasks[idx];
|
|
3312
|
-
if (!match) {
|
|
3313
|
-
early = {
|
|
3314
|
-
ok: false,
|
|
3315
|
-
message: `No task matched "${target}".`,
|
|
3316
|
-
count: 0,
|
|
3317
|
-
completed: 0,
|
|
3318
|
-
inProgress: 0
|
|
3319
|
-
};
|
|
3320
|
-
return f;
|
|
3321
|
-
}
|
|
3322
|
-
planifyMeta.title = match.title;
|
|
3323
|
-
planifyMeta.details = match.description ?? "";
|
|
3324
|
-
didPlanify = true;
|
|
3325
|
-
break;
|
|
3326
|
-
}
|
|
3327
|
-
default:
|
|
3328
|
-
early = {
|
|
3329
|
-
ok: false,
|
|
3330
|
-
message: `Unknown action "${input.action}". Use replace | add | status | show | promote | planify.`,
|
|
3331
|
-
count: 0,
|
|
3332
|
-
completed: 0,
|
|
3333
|
-
inProgress: 0
|
|
3334
|
-
};
|
|
3335
|
-
return f;
|
|
3336
|
-
}
|
|
3337
|
-
return f;
|
|
3338
|
-
});
|
|
3339
|
-
} catch (err) {
|
|
3340
|
-
return {
|
|
3341
|
-
ok: false,
|
|
3342
|
-
message: `Task change not saved \u2014 ${err instanceof Error ? err.message : String(err)}`,
|
|
3343
|
-
count: 0,
|
|
3344
|
-
completed: 0,
|
|
3345
|
-
inProgress: 0
|
|
3346
|
-
};
|
|
3347
|
-
}
|
|
3348
|
-
ctx.meta["task.path.resolved"] = taskPath;
|
|
3349
|
-
if (todosToReplace) {
|
|
3350
|
-
await todoTool.execute({ todos: todosToReplace }, ctx, {
|
|
3351
|
-
signal: AbortSignal.timeout(3e4)
|
|
3352
|
-
});
|
|
3353
|
-
}
|
|
3354
|
-
mirrorSessionTasksToKanban(ctx.projectRoot, file.tasks, sessionId);
|
|
3355
|
-
if (early) return early;
|
|
3356
|
-
if (didPlanify) {
|
|
3357
|
-
const { title, details } = planifyMeta;
|
|
3358
|
-
const planPathRaw = ctx.meta["plan.path"];
|
|
3359
|
-
const prog = computeTaskItemProgress(file.tasks);
|
|
3360
|
-
if (typeof planPathRaw === "string" && planPathRaw) {
|
|
3361
|
-
let planPath = planPathRaw;
|
|
3362
|
-
if (input.scope === "project") {
|
|
3363
|
-
const lastSep = Math.max(planPath.lastIndexOf("/"), planPath.lastIndexOf("\\"));
|
|
3364
|
-
planPath = lastSep >= 0 ? planPath.slice(0, lastSep + 1) + "backlog.plan.json" : "backlog.plan.json";
|
|
3365
|
-
}
|
|
3366
|
-
let formatted = "";
|
|
3367
|
-
try {
|
|
3368
|
-
await mutatePlan2(planPath, sessionId, (pf) => {
|
|
3369
|
-
const { plan: updated } = addPlanItem(pf, title, details || void 0);
|
|
3370
|
-
formatted = formatPlan(updated);
|
|
3371
|
-
return updated;
|
|
3372
|
-
});
|
|
3373
|
-
ctx.meta["plan.path.resolved"] = planPath;
|
|
3374
|
-
} catch (err) {
|
|
3375
|
-
return {
|
|
3376
|
-
ok: false,
|
|
3377
|
-
message: `planify: plan not saved \u2014 ${err instanceof Error ? err.message : String(err)}`,
|
|
3378
|
-
count: file.tasks.length,
|
|
3379
|
-
completed: prog.completed,
|
|
3380
|
-
inProgress: prog.inProgress
|
|
3381
|
-
};
|
|
3382
|
-
}
|
|
3383
|
-
return {
|
|
3384
|
-
ok: true,
|
|
3385
|
-
message: `planify ok \u2014 added "${title}" to plan.
|
|
3386
|
-
${formatted}`,
|
|
3387
|
-
count: file.tasks.length,
|
|
3388
|
-
completed: prog.completed,
|
|
3389
|
-
inProgress: prog.inProgress
|
|
3390
|
-
};
|
|
3391
|
-
}
|
|
3392
|
-
return {
|
|
3393
|
-
ok: false,
|
|
3394
|
-
message: "Plan storage path not configured \u2014 cannot planify.",
|
|
3395
|
-
count: file.tasks.length,
|
|
3396
|
-
completed: prog.completed,
|
|
3397
|
-
inProgress: prog.inProgress
|
|
3398
|
-
};
|
|
3399
|
-
}
|
|
3400
|
-
const p = computeTaskItemProgress(file.tasks);
|
|
3401
|
-
const summary = promoteMeta.count > 0 ? `promote ok \u2014 ${promoteMeta.count} todo(s) created from "${promoteMeta.title}".
|
|
3402
|
-
${formatTaskList(file.tasks)}` : file.tasks.length > 0 ? formatTaskList(file.tasks) : "No tasks.";
|
|
3403
|
-
return {
|
|
3404
|
-
ok: true,
|
|
3405
|
-
message: summary,
|
|
3406
|
-
count: file.tasks.length,
|
|
3407
|
-
completed: p.completed,
|
|
3408
|
-
inProgress: p.inProgress
|
|
3409
|
-
};
|
|
3410
|
-
}
|
|
3411
|
-
};
|
|
2
|
+
taskTool
|
|
3
|
+
} from "./chunk-FW65TP4G.js";
|
|
4
|
+
import "./chunk-J4SRJKBW.js";
|
|
5
|
+
import "./chunk-55KF77OK.js";
|
|
6
|
+
import "./chunk-QNJ7AQ4B.js";
|
|
3412
7
|
export {
|
|
3413
8
|
taskTool
|
|
3414
9
|
};
|