@wrongstack/tools 0.302.0 → 0.303.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/builtin.js +2799 -609
- package/dist/codebase-index/binary-frame.d.ts +43 -0
- package/dist/codebase-index/codebase-incoming-calls-tool.d.ts +1 -0
- package/dist/codebase-index/codebase-outgoing-calls-tool.d.ts +1 -0
- package/dist/codebase-index/content-hash.d.ts +66 -0
- package/dist/codebase-index/index.js +1569 -148
- package/dist/codebase-index/parser-worker-pool.d.ts +63 -0
- package/dist/codebase-index/parser-worker-script.d.ts +42 -0
- package/dist/codebase-index/project-server-protocol.d.ts +2 -0
- package/dist/codebase-index/project-server.js +1455 -99
- package/dist/codebase-index/schema.d.ts +7 -0
- package/dist/codebase-index/tree-sitter/queries.d.ts +48 -0
- package/dist/codebase-index/tree-sitter/util.d.ts +31 -0
- package/dist/codebase-index/tree-sitter/visitor.d.ts +47 -0
- package/dist/codebase-index/tree-sitter-parser.d.ts +58 -0
- package/dist/codebase-index/vector-search.d.ts +62 -0
- package/dist/codebase-index/worker-protocol.d.ts +2 -0
- package/dist/codebase-index/worker.js +1424 -68
- package/dist/codebase-index/writer-bulk-insert.d.ts +5 -0
- package/dist/codebase-index/writer-graph-reader.d.ts +39 -0
- package/dist/codebase-index/writer-schema.d.ts +9 -2
- package/dist/codebase-index/writer.d.ts +36 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2785 -634
- package/dist/kanban-task-inputs.d.ts +1 -0
- package/dist/kanban-tool-schema.d.ts +2 -2
- package/dist/kanban-tool-types.d.ts +18 -2
- package/dist/kanban.js +392 -126
- package/dist/pack.js +2799 -609
- package/dist/plan.d.ts +4 -1
- package/dist/plan.js +2380 -9
- package/dist/read.js +1531 -98
- package/dist/session-kanban.d.ts +8 -0
- package/dist/session-kanban.js +111 -17
- package/dist/task.d.ts +5 -4
- package/dist/task.js +2418 -43
- package/dist/todo.d.ts +10 -1
- package/dist/todo.js +2152 -20
- package/dist/tool-tier.js +2799 -609
- package/package.json +8 -4
package/dist/todo.js
CHANGED
|
@@ -1,5 +1,989 @@
|
|
|
1
1
|
// src/todo.ts
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
loadPlan as loadPlan2,
|
|
4
|
+
loadTasks as loadTasks3,
|
|
5
|
+
savePlan,
|
|
6
|
+
saveTasks,
|
|
7
|
+
setPlanItemStatus
|
|
8
|
+
} from "@wrongstack/core/storage";
|
|
9
|
+
import { getBoard as getBoard4 } from "@wrongstack/kanban";
|
|
10
|
+
|
|
11
|
+
// src/kanban.ts
|
|
12
|
+
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
13
|
+
import { loadTasks as loadTasks2 } from "@wrongstack/core/storage";
|
|
14
|
+
import { deserializeTaskGraph as deserializeTaskGraph2, serializeTaskGraph } from "@wrongstack/core/tasking";
|
|
15
|
+
import {
|
|
16
|
+
addColumn,
|
|
17
|
+
addTask,
|
|
18
|
+
adoptManagedLifecycle,
|
|
19
|
+
assignTask,
|
|
20
|
+
claimReadyTask,
|
|
21
|
+
copyTaskToBoard,
|
|
22
|
+
createBoard as createBoard2,
|
|
23
|
+
createBoardFromTaskGraph,
|
|
24
|
+
createBoardFromText,
|
|
25
|
+
duplicateBoard,
|
|
26
|
+
evaluateContractGraphReadiness,
|
|
27
|
+
exportBoardAsMarkdown,
|
|
28
|
+
exportBoardToTaskGraph,
|
|
29
|
+
finalizeTaskCompletion,
|
|
30
|
+
getBoard as getBoard3,
|
|
31
|
+
getKanbanOrchestrationSnapshot,
|
|
32
|
+
getKanbanQueueHealth,
|
|
33
|
+
getTask,
|
|
34
|
+
getTaskChain,
|
|
35
|
+
heartbeatTaskAssignment,
|
|
36
|
+
listBoards as listBoards2,
|
|
37
|
+
listKanbanEvents,
|
|
38
|
+
listReadyTasks,
|
|
39
|
+
mergeTasks,
|
|
40
|
+
moveTask,
|
|
41
|
+
parseLinesIntoTasks,
|
|
42
|
+
recoverStaleTaskAssignments,
|
|
43
|
+
releaseTaskClaim,
|
|
44
|
+
removeBoard as removeBoard2,
|
|
45
|
+
removeColumn,
|
|
46
|
+
removeTask,
|
|
47
|
+
repairManagedTaskProjection,
|
|
48
|
+
searchKanban,
|
|
49
|
+
setTaskChain,
|
|
50
|
+
syncBoardFromTaskGraph as syncBoardFromTaskGraph2,
|
|
51
|
+
transferTaskToBoard,
|
|
52
|
+
transitionTask,
|
|
53
|
+
updateBoard as updateBoard2,
|
|
54
|
+
updateColumn,
|
|
55
|
+
updateTask as updateTask2,
|
|
56
|
+
updateTaskAssignment,
|
|
57
|
+
verifyTaskCompletion as verifyTaskCompletion2
|
|
58
|
+
} from "@wrongstack/kanban";
|
|
59
|
+
|
|
60
|
+
// src/kanban-board-inputs.ts
|
|
61
|
+
function agentSettableGate(enforcement) {
|
|
62
|
+
if (enforcement === void 0 || enforcement === "off") return {};
|
|
63
|
+
return { completionGate: { enforcement } };
|
|
64
|
+
}
|
|
65
|
+
function boardCreateInput(input, title) {
|
|
66
|
+
return {
|
|
67
|
+
title,
|
|
68
|
+
...input.description !== void 0 ? { description: input.description } : {},
|
|
69
|
+
...input.tags !== void 0 ? { tags: input.tags } : {},
|
|
70
|
+
...input.generatedBy !== void 0 ? { generatedBy: input.generatedBy } : {},
|
|
71
|
+
...input.atomicityMode !== void 0 ? {
|
|
72
|
+
atomicity: {
|
|
73
|
+
mode: input.atomicityMode,
|
|
74
|
+
decomposition: input.atomicityDecomposition ?? "propose"
|
|
75
|
+
}
|
|
76
|
+
} : {},
|
|
77
|
+
...agentSettableGate(input.gateEnforcement)
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
function boardUpdatePatch(input) {
|
|
81
|
+
return {
|
|
82
|
+
...input.title !== void 0 ? { title: input.title } : {},
|
|
83
|
+
...input.description !== void 0 ? { description: input.description } : {},
|
|
84
|
+
...input.tags !== void 0 ? { tags: input.tags } : {},
|
|
85
|
+
...input.atomicityMode !== void 0 ? {
|
|
86
|
+
atomicity: {
|
|
87
|
+
mode: input.atomicityMode,
|
|
88
|
+
decomposition: input.atomicityDecomposition ?? "propose"
|
|
89
|
+
}
|
|
90
|
+
} : {},
|
|
91
|
+
...agentSettableGate(input.gateEnforcement)
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
function duplicateBoardOptions(input) {
|
|
95
|
+
return {
|
|
96
|
+
...input.title !== void 0 ? { title: input.title } : {},
|
|
97
|
+
...input.generatedBy !== void 0 ? { generatedBy: input.generatedBy } : {},
|
|
98
|
+
...input.includeTasks !== void 0 ? { includeTasks: input.includeTasks } : {},
|
|
99
|
+
...input.includeCompletedTasks !== void 0 ? { includeCompletedTasks: input.includeCompletedTasks } : {},
|
|
100
|
+
...input.preserveAssignment !== void 0 ? { preserveAssignment: input.preserveAssignment } : {}
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// src/kanban-decomposition-actions.ts
|
|
105
|
+
import {
|
|
106
|
+
assessTaskAtomicity,
|
|
107
|
+
proposeTaskDecomposition,
|
|
108
|
+
updateTask,
|
|
109
|
+
verifyTaskCompletion
|
|
110
|
+
} from "@wrongstack/kanban";
|
|
111
|
+
|
|
112
|
+
// src/kanban-evidence-bridge.ts
|
|
113
|
+
import { recordCompletedWorkEvidence } from "@wrongstack/core/utils";
|
|
114
|
+
function kanbanEvidenceKey(boardId, taskId) {
|
|
115
|
+
return `kanban:${boardId}:${taskId}`;
|
|
116
|
+
}
|
|
117
|
+
function kanbanEvidencePointer(boardId, taskId) {
|
|
118
|
+
return `kanban://${boardId}/${taskId}#verificationReport`;
|
|
119
|
+
}
|
|
120
|
+
function recordKanbanVerificationEvidence(ctx, report) {
|
|
121
|
+
try {
|
|
122
|
+
const passed = report.checks.filter((check) => check.status === "passed").length;
|
|
123
|
+
const completedAt = Date.parse(report.completedAt);
|
|
124
|
+
recordCompletedWorkEvidence(ctx, {
|
|
125
|
+
key: kanbanEvidenceKey(report.boardId, report.taskId),
|
|
126
|
+
source: "verification",
|
|
127
|
+
summary: `${report.taskTitle} \u2014 verification ${report.verdict} (${passed}/${report.checks.length} checks)`,
|
|
128
|
+
...Number.isFinite(completedAt) ? { completedAt } : {},
|
|
129
|
+
evidence: kanbanEvidencePointer(report.boardId, report.taskId)
|
|
130
|
+
});
|
|
131
|
+
} catch {
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// src/kanban-tool-results.ts
|
|
136
|
+
function atomicityNudge(task) {
|
|
137
|
+
if (task.atomicityAssessment?.verdict !== "needs_decomposition") return "";
|
|
138
|
+
const reasons = task.atomicityAssessment.criteria.filter((entry) => entry.score < 1).map((entry) => entry.reason).join(" | ");
|
|
139
|
+
return ` Atomicity: needs_decomposition (score ${task.atomicityAssessment.score}) \u2014 call propose_decomposition with 2+ subtasks before dispatch. Reasons: ${reasons}`;
|
|
140
|
+
}
|
|
141
|
+
function readEnvGateEnforcement() {
|
|
142
|
+
const raw = process.env["WRONGSTACK_KANBAN_GATE"]?.trim().toLowerCase();
|
|
143
|
+
return raw === "strict" || raw === "soft" || raw === "off" ? raw : void 0;
|
|
144
|
+
}
|
|
145
|
+
function fail(message) {
|
|
146
|
+
return { ok: false, message };
|
|
147
|
+
}
|
|
148
|
+
function okBoard(board, message = "Board loaded.") {
|
|
149
|
+
return { ok: true, message, board };
|
|
150
|
+
}
|
|
151
|
+
function okTask(board, task, message) {
|
|
152
|
+
return { ok: true, message, board, task };
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// src/kanban-decomposition-actions.ts
|
|
156
|
+
async function handleKanbanDecompositionAction(projectRoot, input, ctx) {
|
|
157
|
+
switch (input.action) {
|
|
158
|
+
case "assess_atomicity": {
|
|
159
|
+
if (!input.boardId || !input.taskId) {
|
|
160
|
+
return fail("assess_atomicity requires boardId and taskId.");
|
|
161
|
+
}
|
|
162
|
+
const result = await assessTaskAtomicity(projectRoot, input.boardId, input.taskId, {
|
|
163
|
+
assessedBy: "agent",
|
|
164
|
+
...ctx.agentId !== void 0 ? { eventContext: { actor: ctx.agentId } } : {}
|
|
165
|
+
});
|
|
166
|
+
if (!result) return fail("Task not found.");
|
|
167
|
+
const failing = result.assessment.criteria.filter((entry) => entry.score < 1).map((entry) => entry.reason);
|
|
168
|
+
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." : "";
|
|
169
|
+
return okTask(
|
|
170
|
+
result.board,
|
|
171
|
+
result.task,
|
|
172
|
+
`Atomicity verdict: ${result.assessment.verdict} (score ${result.assessment.score}).${guidance}`
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
case "propose_decomposition": {
|
|
176
|
+
if (!input.boardId || !input.taskId || !input.subtasks?.length) {
|
|
177
|
+
return fail("propose_decomposition requires boardId, taskId, and subtasks (2+).");
|
|
178
|
+
}
|
|
179
|
+
if (input.subtasks.length < 2) {
|
|
180
|
+
return fail("propose_decomposition requires at least two subtasks.");
|
|
181
|
+
}
|
|
182
|
+
const invalid = input.subtasks.find(
|
|
183
|
+
(subtask) => typeof subtask?.title !== "string" || !subtask.title.trim()
|
|
184
|
+
);
|
|
185
|
+
if (invalid) return fail("Every proposed subtask needs a non-blank title.");
|
|
186
|
+
const result = await proposeTaskDecomposition(
|
|
187
|
+
projectRoot,
|
|
188
|
+
input.boardId,
|
|
189
|
+
input.taskId,
|
|
190
|
+
{
|
|
191
|
+
subtasks: input.subtasks,
|
|
192
|
+
...input.note !== void 0 ? { rationale: input.note } : {},
|
|
193
|
+
...ctx.agentId !== void 0 ? { proposedBy: ctx.agentId } : {}
|
|
194
|
+
},
|
|
195
|
+
ctx.agentId !== void 0 ? { actor: ctx.agentId } : {}
|
|
196
|
+
);
|
|
197
|
+
if (!result) return fail("Task not found.");
|
|
198
|
+
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.';
|
|
199
|
+
return okTask(result.board, result.task, message);
|
|
200
|
+
}
|
|
201
|
+
case "verify_completion": {
|
|
202
|
+
if (!input.boardId || !input.taskId) {
|
|
203
|
+
return fail("verify_completion requires boardId and taskId.");
|
|
204
|
+
}
|
|
205
|
+
const verResult = await verifyTaskCompletion(projectRoot, input.boardId, input.taskId);
|
|
206
|
+
const persistedBoard = await updateTask(projectRoot, input.boardId, input.taskId, {
|
|
207
|
+
verificationReport: verResult.report,
|
|
208
|
+
successCriteria: verResult.task.successCriteria
|
|
209
|
+
});
|
|
210
|
+
if (!persistedBoard) {
|
|
211
|
+
return {
|
|
212
|
+
ok: false,
|
|
213
|
+
verdict: verResult.report.verdict,
|
|
214
|
+
message: `Verification succeeded but persist failed: ${verResult.report.markdownSummary}. Board may be stale \u2014 re-run verify_completion.`,
|
|
215
|
+
board: verResult.board
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
recordKanbanVerificationEvidence(ctx, verResult.report);
|
|
219
|
+
const freshTask = persistedBoard.tasks?.find((t) => t.id === input.taskId);
|
|
220
|
+
const deterministicVerdicts = ["passed", "failed", "needs_human", "incomplete"];
|
|
221
|
+
return {
|
|
222
|
+
ok: deterministicVerdicts.includes(
|
|
223
|
+
verResult.report.verdict
|
|
224
|
+
),
|
|
225
|
+
verdict: verResult.report.verdict,
|
|
226
|
+
message: verResult.report.markdownSummary,
|
|
227
|
+
board: persistedBoard,
|
|
228
|
+
task: freshTask ?? verResult.task
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
default:
|
|
232
|
+
return void 0;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// src/kanban-detail-actions.ts
|
|
237
|
+
import {
|
|
238
|
+
addCheckToTask,
|
|
239
|
+
addContractEdge,
|
|
240
|
+
addDependency,
|
|
241
|
+
addGoalMetricToTask,
|
|
242
|
+
addLinkToTask,
|
|
243
|
+
addNoteToTask,
|
|
244
|
+
configureContractGraph,
|
|
245
|
+
evaluateTaskContractGraph,
|
|
246
|
+
getContractGraph,
|
|
247
|
+
getKanbanWorkbench,
|
|
248
|
+
removeContractEdge,
|
|
249
|
+
removeContractNode,
|
|
250
|
+
updateCheckOnTask,
|
|
251
|
+
updateGoalMetricOnTask,
|
|
252
|
+
upsertContractNode
|
|
253
|
+
} from "@wrongstack/kanban";
|
|
254
|
+
|
|
255
|
+
// src/kanban-split-task-handler.ts
|
|
256
|
+
import { getBoard, splitTask } from "@wrongstack/kanban";
|
|
257
|
+
async function handleSplitTask(projectRoot, input, extraSplitOptions) {
|
|
258
|
+
const boardId = input.boardId;
|
|
259
|
+
const taskId = input.taskId;
|
|
260
|
+
const childTitles = input.childTitles;
|
|
261
|
+
if (!boardId || !taskId || !childTitles?.length) {
|
|
262
|
+
return fail("split requires boardId, taskId, and at least one childTitles.");
|
|
263
|
+
}
|
|
264
|
+
const {
|
|
265
|
+
targetColumnId,
|
|
266
|
+
inheritAssignment,
|
|
267
|
+
inheritLabels,
|
|
268
|
+
inheritSuccessCriteria,
|
|
269
|
+
inheritGoalMetrics,
|
|
270
|
+
inheritDependencies,
|
|
271
|
+
chainChildren,
|
|
272
|
+
rewireDependents
|
|
273
|
+
} = input;
|
|
274
|
+
const result = await splitTask(projectRoot, boardId, taskId, {
|
|
275
|
+
titles: childTitles,
|
|
276
|
+
...extraSplitOptions,
|
|
277
|
+
...targetColumnId !== void 0 ? { columnId: targetColumnId } : {},
|
|
278
|
+
...inheritAssignment !== void 0 ? { inheritAssignment } : {},
|
|
279
|
+
...inheritLabels !== void 0 ? { inheritLabels } : {},
|
|
280
|
+
...inheritSuccessCriteria !== void 0 ? { inheritSuccessCriteria } : {},
|
|
281
|
+
...inheritGoalMetrics !== void 0 ? { inheritGoalMetrics } : {},
|
|
282
|
+
...inheritDependencies !== void 0 ? { inheritDependencies } : {},
|
|
283
|
+
...chainChildren !== void 0 ? { chainChildren } : {},
|
|
284
|
+
...rewireDependents !== void 0 ? { rewireDependents } : {}
|
|
285
|
+
});
|
|
286
|
+
if (!result) return fail("Task not found.");
|
|
287
|
+
const freshParent = result.board.tasks?.find((t) => t.id === taskId);
|
|
288
|
+
if (!freshParent) {
|
|
289
|
+
return fail(
|
|
290
|
+
`Split succeeded but parent ${taskId} not found in returned board. Children: [${result.children.map((c) => c.id).join(", ")}].`
|
|
291
|
+
);
|
|
292
|
+
}
|
|
293
|
+
return {
|
|
294
|
+
ok: true,
|
|
295
|
+
message: `${result.children.length} child task(s) created.`,
|
|
296
|
+
board: result.board,
|
|
297
|
+
task: freshParent,
|
|
298
|
+
children: result.children
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
async function requireBoard(projectRoot, boardId) {
|
|
302
|
+
return boardId ? getBoard(projectRoot, boardId) : null;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// src/kanban-detail-actions.ts
|
|
306
|
+
async function handleKanbanDetailAction(projectRoot, input) {
|
|
307
|
+
switch (input.action) {
|
|
308
|
+
case "workbench": {
|
|
309
|
+
const workbench = await getKanbanWorkbench(projectRoot, {
|
|
310
|
+
...input.limit !== void 0 ? { limitPerLane: input.limit, alertLimit: input.limit } : {}
|
|
311
|
+
});
|
|
312
|
+
return {
|
|
313
|
+
ok: true,
|
|
314
|
+
message: `${workbench.totals.now} now, ${workbench.totals.next} next, ${workbench.totals.blocked} blocked, ${workbench.totals.review} review; ${workbench.alertTotal} alert(s).`,
|
|
315
|
+
workbench
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
case "get_contract_graph": {
|
|
319
|
+
if (!input.boardId) return fail("get_contract_graph requires boardId.");
|
|
320
|
+
const result = await getContractGraph(projectRoot, input.boardId);
|
|
321
|
+
return result ? {
|
|
322
|
+
ok: true,
|
|
323
|
+
message: result.graph ? `${result.graph.nodes.length} contract node(s), ${result.graph.edges.length} edge(s).` : "Contract graph is not configured.",
|
|
324
|
+
board: result.board,
|
|
325
|
+
...result.graph ? { contractGraph: result.graph } : {}
|
|
326
|
+
} : fail("Board not found.");
|
|
327
|
+
}
|
|
328
|
+
case "configure_contract_graph": {
|
|
329
|
+
if (!input.boardId || !input.contractGraphEnforcement) {
|
|
330
|
+
return fail("configure_contract_graph requires boardId and contractGraphEnforcement.");
|
|
331
|
+
}
|
|
332
|
+
const current = await getContractGraph(projectRoot, input.boardId);
|
|
333
|
+
if (!current) return fail("Board not found.");
|
|
334
|
+
if (input.contractGraphEnforcement === "strict" && current.graph?.enforcement !== "strict") {
|
|
335
|
+
return fail(
|
|
336
|
+
"Strict Contract Map enforcement is operator-owned. Autonomous agents may use advisory maps but may not turn them into an execution gate."
|
|
337
|
+
);
|
|
338
|
+
}
|
|
339
|
+
if (current.graph?.enforcement === "strict" && input.contractGraphEnforcement !== "strict") {
|
|
340
|
+
return fail("An autonomous agent may not loosen a strict contract graph.");
|
|
341
|
+
}
|
|
342
|
+
const board = await configureContractGraph(
|
|
343
|
+
projectRoot,
|
|
344
|
+
input.boardId,
|
|
345
|
+
input.contractGraphEnforcement
|
|
346
|
+
);
|
|
347
|
+
return board ? okBoard(board, "Contract graph configured.") : fail("Board not found.");
|
|
348
|
+
}
|
|
349
|
+
case "upsert_contract_node": {
|
|
350
|
+
if (!input.boardId || !input.taskId || !input.contractNodeKind || !input.title) {
|
|
351
|
+
return fail("upsert_contract_node requires boardId, taskId, contractNodeKind, and title.");
|
|
352
|
+
}
|
|
353
|
+
if (input.contractNodeState === "waived") {
|
|
354
|
+
return fail(
|
|
355
|
+
"The autonomous kanban tool may not waive contract nodes; a human-owned review surface must record that exception."
|
|
356
|
+
);
|
|
357
|
+
}
|
|
358
|
+
if (input.contractNodeId) {
|
|
359
|
+
const current = await getContractGraph(projectRoot, input.boardId);
|
|
360
|
+
const existing = current?.graph?.nodes.find((node) => node.id === input.contractNodeId);
|
|
361
|
+
if (current?.graph?.enforcement === "strict" && existing && (existing.kind !== input.contractNodeKind || input.contractEnforcement !== void 0 && input.contractEnforcement !== existing.enforcement)) {
|
|
362
|
+
return fail(
|
|
363
|
+
"The autonomous kanban tool may not change the kind or enforcement of an existing strict contract node."
|
|
364
|
+
);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
const result = await upsertContractNode(projectRoot, input.boardId, {
|
|
368
|
+
...input.contractNodeId ? { id: input.contractNodeId } : {},
|
|
369
|
+
taskId: input.taskId,
|
|
370
|
+
kind: input.contractNodeKind,
|
|
371
|
+
title: input.title,
|
|
372
|
+
...input.description !== void 0 ? { description: input.description } : {},
|
|
373
|
+
...input.contractEnforcement !== void 0 ? { enforcement: input.contractEnforcement } : {},
|
|
374
|
+
...input.contractNodeState !== void 0 ? { state: input.contractNodeState } : {},
|
|
375
|
+
...input.checkId !== void 0 ? { checkId: input.checkId } : {},
|
|
376
|
+
...input.metricId !== void 0 ? { metricId: input.metricId } : {},
|
|
377
|
+
...input.baseline !== void 0 ? { baseline: input.baseline } : {},
|
|
378
|
+
...input.threshold !== void 0 ? { threshold: input.threshold } : {},
|
|
379
|
+
...input.author !== void 0 ? { createdBy: input.author } : {}
|
|
380
|
+
});
|
|
381
|
+
return result ? {
|
|
382
|
+
...okBoard(result.board, "Contract node saved."),
|
|
383
|
+
contractGraph: result.board.contractGraph
|
|
384
|
+
} : fail("Task not found.");
|
|
385
|
+
}
|
|
386
|
+
case "link_contract_nodes": {
|
|
387
|
+
if (!input.boardId || !input.fromNodeId || !input.toNodeId || !input.contractEdgeType) {
|
|
388
|
+
return fail(
|
|
389
|
+
"link_contract_nodes requires boardId, fromNodeId, toNodeId, and contractEdgeType."
|
|
390
|
+
);
|
|
391
|
+
}
|
|
392
|
+
const result = await addContractEdge(projectRoot, input.boardId, {
|
|
393
|
+
from: input.fromNodeId,
|
|
394
|
+
to: input.toNodeId,
|
|
395
|
+
type: input.contractEdgeType,
|
|
396
|
+
...input.contractEdgeId ? { id: input.contractEdgeId } : {},
|
|
397
|
+
...input.contractEnforcement ? { enforcement: input.contractEnforcement } : {},
|
|
398
|
+
...input.contractRationale ? { rationale: input.contractRationale } : {},
|
|
399
|
+
...input.author ? { createdBy: input.author } : {}
|
|
400
|
+
});
|
|
401
|
+
return result ? {
|
|
402
|
+
...okBoard(result.board, "Contract edge added."),
|
|
403
|
+
contractGraph: result.board.contractGraph
|
|
404
|
+
} : fail("Board not found.");
|
|
405
|
+
}
|
|
406
|
+
case "remove_contract_node": {
|
|
407
|
+
if (!input.boardId || !input.contractNodeId) {
|
|
408
|
+
return fail("remove_contract_node requires boardId and contractNodeId.");
|
|
409
|
+
}
|
|
410
|
+
const current = await getContractGraph(projectRoot, input.boardId);
|
|
411
|
+
const node = current?.graph?.nodes.find((candidate) => candidate.id === input.contractNodeId);
|
|
412
|
+
if (current?.graph?.enforcement === "strict" && node?.enforcement === "blocking") {
|
|
413
|
+
return fail("The autonomous kanban tool may not remove a blocking strict contract node.");
|
|
414
|
+
}
|
|
415
|
+
const board = await removeContractNode(projectRoot, input.boardId, input.contractNodeId);
|
|
416
|
+
return board ? okBoard(board, "Contract node removed.") : fail("Contract node not found.");
|
|
417
|
+
}
|
|
418
|
+
case "remove_contract_edge": {
|
|
419
|
+
if (!input.boardId || !input.contractEdgeId) {
|
|
420
|
+
return fail("remove_contract_edge requires boardId and contractEdgeId.");
|
|
421
|
+
}
|
|
422
|
+
const current = await getContractGraph(projectRoot, input.boardId);
|
|
423
|
+
const edge = current?.graph?.edges.find((candidate) => candidate.id === input.contractEdgeId);
|
|
424
|
+
if (current?.graph?.enforcement === "strict" && edge?.enforcement === "blocking") {
|
|
425
|
+
return fail("The autonomous kanban tool may not remove a blocking strict contract edge.");
|
|
426
|
+
}
|
|
427
|
+
const board = await removeContractEdge(projectRoot, input.boardId, input.contractEdgeId);
|
|
428
|
+
return board ? okBoard(board, "Contract edge removed.") : fail("Contract edge not found.");
|
|
429
|
+
}
|
|
430
|
+
case "evaluate_contract_graph": {
|
|
431
|
+
if (!input.boardId || !input.taskId) {
|
|
432
|
+
return fail("evaluate_contract_graph requires boardId and taskId.");
|
|
433
|
+
}
|
|
434
|
+
const result = await evaluateTaskContractGraph(projectRoot, input.boardId, input.taskId);
|
|
435
|
+
return result ? {
|
|
436
|
+
ok: result.evaluation.allowed,
|
|
437
|
+
message: result.evaluation.allowed ? "Contract graph is closed." : `Contract graph has ${result.evaluation.issues.length} unresolved issue(s).`,
|
|
438
|
+
board: result.board,
|
|
439
|
+
contractGraph: result.board.contractGraph,
|
|
440
|
+
contractEvaluation: result.evaluation
|
|
441
|
+
} : fail("Task not found.");
|
|
442
|
+
}
|
|
443
|
+
case "add_dependency": {
|
|
444
|
+
if (!input.boardId || !input.taskId || !input.dependencyTaskId) {
|
|
445
|
+
return fail("add_dependency requires boardId, taskId, and dependencyTaskId.");
|
|
446
|
+
}
|
|
447
|
+
const board = await addDependency(
|
|
448
|
+
projectRoot,
|
|
449
|
+
input.boardId,
|
|
450
|
+
input.taskId,
|
|
451
|
+
input.dependencyTaskId
|
|
452
|
+
);
|
|
453
|
+
return board ? okBoard(board, "Dependency added.") : fail("Task not found.");
|
|
454
|
+
}
|
|
455
|
+
case "add_goal_metric": {
|
|
456
|
+
if (!input.boardId || !input.taskId || !input.metricName) {
|
|
457
|
+
return fail("add_goal_metric requires boardId, taskId, and metricName.");
|
|
458
|
+
}
|
|
459
|
+
const board = await addGoalMetricToTask(projectRoot, input.boardId, input.taskId, {
|
|
460
|
+
name: input.metricName,
|
|
461
|
+
...input.metricStatus !== void 0 ? { status: input.metricStatus } : {},
|
|
462
|
+
...input.metricTarget !== void 0 ? { target: input.metricTarget } : {},
|
|
463
|
+
...input.metricCurrent !== void 0 ? { current: input.metricCurrent } : {},
|
|
464
|
+
...input.metricUnit !== void 0 ? { unit: input.metricUnit } : {},
|
|
465
|
+
...input.metricNotes !== void 0 ? { notes: input.metricNotes } : {}
|
|
466
|
+
});
|
|
467
|
+
return board ? okBoard(board, "Goal metric added.") : fail("Task not found.");
|
|
468
|
+
}
|
|
469
|
+
case "update_goal_metric": {
|
|
470
|
+
if (!input.boardId || !input.taskId || !input.metricId) {
|
|
471
|
+
return fail("update_goal_metric requires boardId, taskId, and metricId.");
|
|
472
|
+
}
|
|
473
|
+
const board = await updateGoalMetricOnTask(
|
|
474
|
+
projectRoot,
|
|
475
|
+
input.boardId,
|
|
476
|
+
input.taskId,
|
|
477
|
+
input.metricId,
|
|
478
|
+
{
|
|
479
|
+
...input.metricName !== void 0 ? { name: input.metricName } : {},
|
|
480
|
+
...input.metricStatus !== void 0 ? { status: input.metricStatus } : {},
|
|
481
|
+
...input.metricTarget !== void 0 ? { target: input.metricTarget } : {},
|
|
482
|
+
...input.metricCurrent !== void 0 ? { current: input.metricCurrent } : {},
|
|
483
|
+
...input.metricUnit !== void 0 ? { unit: input.metricUnit } : {},
|
|
484
|
+
...input.metricNotes !== void 0 ? { notes: input.metricNotes } : {}
|
|
485
|
+
}
|
|
486
|
+
);
|
|
487
|
+
return board ? okBoard(board, "Goal metric updated.") : fail("Metric not found.");
|
|
488
|
+
}
|
|
489
|
+
case "add_check": {
|
|
490
|
+
if (!input.boardId || !input.taskId || !input.checkDescription) {
|
|
491
|
+
return fail("add_check requires boardId, taskId, and checkDescription.");
|
|
492
|
+
}
|
|
493
|
+
const board = await addCheckToTask(projectRoot, input.boardId, input.taskId, {
|
|
494
|
+
description: input.checkDescription,
|
|
495
|
+
type: "manual",
|
|
496
|
+
status: input.checkStatus
|
|
497
|
+
});
|
|
498
|
+
return board ? okBoard(board, "Check added.") : fail("Task not found.");
|
|
499
|
+
}
|
|
500
|
+
case "update_check": {
|
|
501
|
+
if (!input.boardId || !input.taskId || !input.checkId) {
|
|
502
|
+
return fail("update_check requires boardId, taskId, and checkId.");
|
|
503
|
+
}
|
|
504
|
+
const board = await updateCheckOnTask(
|
|
505
|
+
projectRoot,
|
|
506
|
+
input.boardId,
|
|
507
|
+
input.taskId,
|
|
508
|
+
input.checkId,
|
|
509
|
+
{
|
|
510
|
+
...input.checkDescription !== void 0 ? { description: input.checkDescription } : {},
|
|
511
|
+
...input.checkStatus !== void 0 ? { status: input.checkStatus } : {}
|
|
512
|
+
}
|
|
513
|
+
);
|
|
514
|
+
return board ? okBoard(board, "Check updated.") : fail("Check not found.");
|
|
515
|
+
}
|
|
516
|
+
case "add_note": {
|
|
517
|
+
if (!input.boardId || !input.taskId || !input.note)
|
|
518
|
+
return fail("add_note requires boardId, taskId, and note.");
|
|
519
|
+
const board = await addNoteToTask(projectRoot, input.boardId, input.taskId, {
|
|
520
|
+
author: input.author ?? "agent",
|
|
521
|
+
content: input.note
|
|
522
|
+
});
|
|
523
|
+
return board ? okBoard(board, "Note added.") : fail("Task not found.");
|
|
524
|
+
}
|
|
525
|
+
case "add_link": {
|
|
526
|
+
if (!input.boardId || !input.taskId || !input.url)
|
|
527
|
+
return fail("add_link requires boardId, taskId, and url.");
|
|
528
|
+
const board = await addLinkToTask(projectRoot, input.boardId, input.taskId, {
|
|
529
|
+
url: input.url,
|
|
530
|
+
type: input.linkType ?? "url",
|
|
531
|
+
...input.linkTitle !== void 0 ? { title: input.linkTitle } : {}
|
|
532
|
+
});
|
|
533
|
+
return board ? okBoard(board, "Link added.") : fail("Task not found.");
|
|
534
|
+
}
|
|
535
|
+
case "split_atomic": {
|
|
536
|
+
if (!input.boardId || !input.taskId || !input.childTitles?.length) {
|
|
537
|
+
return fail("split_atomic requires boardId, taskId, and childTitles (at least one).");
|
|
538
|
+
}
|
|
539
|
+
return handleSplitTask(projectRoot, input, { atomic: true });
|
|
540
|
+
}
|
|
541
|
+
default:
|
|
542
|
+
return void 0;
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
// src/kanban-presence.ts
|
|
547
|
+
import { touchKanbanPresence } from "@wrongstack/kanban";
|
|
548
|
+
function createKanbanPresenceWrapper(projectRoot, input, ctx) {
|
|
549
|
+
return async (result) => {
|
|
550
|
+
const boardId = result.board?.id ?? input.boardId;
|
|
551
|
+
if (!result.ok || !boardId || !ctx.session?.id || !ctx.agentId) return result;
|
|
552
|
+
try {
|
|
553
|
+
const board = await touchKanbanPresence(projectRoot, boardId, {
|
|
554
|
+
sessionId: ctx.session.id,
|
|
555
|
+
agentId: ctx.agentId,
|
|
556
|
+
agentName: ctx.agentName,
|
|
557
|
+
taskId: input.taskId ?? result.task?.id,
|
|
558
|
+
runTaskId: input.runTaskId
|
|
559
|
+
});
|
|
560
|
+
return board ? { ...result, board } : result;
|
|
561
|
+
} catch {
|
|
562
|
+
return result;
|
|
563
|
+
}
|
|
564
|
+
};
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
// src/kanban-task-inputs.ts
|
|
568
|
+
import { randomUUID } from "node:crypto";
|
|
569
|
+
import { clampSubagentCapabilities } from "@wrongstack/core/security";
|
|
570
|
+
function taskInput(input) {
|
|
571
|
+
const assignment = hasAssignmentInput(input) ? assignmentForTaskCreate(input) : void 0;
|
|
572
|
+
return {
|
|
573
|
+
title: input.title ?? "",
|
|
574
|
+
columnId: input.columnId,
|
|
575
|
+
description: input.description,
|
|
576
|
+
dueDate: input.dueDate,
|
|
577
|
+
priority: input.priority,
|
|
578
|
+
...input.taskType !== void 0 ? { type: input.taskType } : {},
|
|
579
|
+
status: input.status,
|
|
580
|
+
labels: input.labels,
|
|
581
|
+
...assignment?.agentId ?? assignment?.role ?? assignment?.name ? { assignedAgent: assignment.agentId ?? assignment.role ?? assignment.name } : {},
|
|
582
|
+
...input.assignee ?? assignment?.name ?? assignment?.agentId ? { assignee: input.assignee ?? assignment?.name ?? assignment?.agentId } : {},
|
|
583
|
+
...mergedDependsOn(input) ? { dependsOn: mergedDependsOn(input) } : {},
|
|
584
|
+
...input.estimatedHours !== void 0 ? { estimatedHours: input.estimatedHours } : {},
|
|
585
|
+
...input.actualHours !== void 0 ? { actualHours: input.actualHours } : {},
|
|
586
|
+
...assignment ? { assignment } : {},
|
|
587
|
+
...input.order !== void 0 ? { order: input.order } : {},
|
|
588
|
+
...input.retryPolicy !== void 0 ? { retryPolicy: input.retryPolicy } : {},
|
|
589
|
+
...input.costCeilingUsd !== void 0 ? { costCeilingUsd: input.costCeilingUsd } : {},
|
|
590
|
+
...input.childTitles !== void 0 ? { childTaskIds: input.childTitles } : {},
|
|
591
|
+
...input.checkDescription !== void 0 ? {
|
|
592
|
+
successCriteria: [
|
|
593
|
+
{
|
|
594
|
+
id: randomUUID(),
|
|
595
|
+
description: input.checkDescription,
|
|
596
|
+
type: "manual",
|
|
597
|
+
status: input.checkStatus ?? "pending"
|
|
598
|
+
}
|
|
599
|
+
]
|
|
600
|
+
} : {},
|
|
601
|
+
...input.metricName !== void 0 ? {
|
|
602
|
+
goalMetrics: [
|
|
603
|
+
{
|
|
604
|
+
id: randomUUID(),
|
|
605
|
+
name: input.metricName,
|
|
606
|
+
status: input.metricStatus ?? "pending",
|
|
607
|
+
...input.metricTarget !== void 0 ? { target: input.metricTarget } : {},
|
|
608
|
+
...input.metricCurrent !== void 0 ? { current: input.metricCurrent } : {},
|
|
609
|
+
...input.metricUnit !== void 0 ? { unit: input.metricUnit } : {},
|
|
610
|
+
...input.metricNotes !== void 0 ? { notes: input.metricNotes } : {}
|
|
611
|
+
}
|
|
612
|
+
]
|
|
613
|
+
} : {},
|
|
614
|
+
...input.url !== void 0 ? {
|
|
615
|
+
links: [
|
|
616
|
+
{
|
|
617
|
+
url: input.url,
|
|
618
|
+
type: input.linkType ?? "url",
|
|
619
|
+
...input.linkTitle !== void 0 ? { title: input.linkTitle } : {}
|
|
620
|
+
}
|
|
621
|
+
]
|
|
622
|
+
} : {},
|
|
623
|
+
...input.note !== void 0 ? {
|
|
624
|
+
notes: [
|
|
625
|
+
{
|
|
626
|
+
id: randomUUID(),
|
|
627
|
+
author: input.author ?? "agent",
|
|
628
|
+
content: input.note,
|
|
629
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
630
|
+
}
|
|
631
|
+
]
|
|
632
|
+
} : {},
|
|
633
|
+
...[input.graphId, input.specId, input.specRequirementId].some((value) => value !== void 0) ? {
|
|
634
|
+
origin: {
|
|
635
|
+
system: input.sourceSystem ?? "kanban-tool",
|
|
636
|
+
...input.graphId !== void 0 ? { graphId: input.graphId } : {},
|
|
637
|
+
...input.specId !== void 0 ? { specId: input.specId } : {},
|
|
638
|
+
...input.specRequirementId !== void 0 ? { specRequirementId: input.specRequirementId } : {},
|
|
639
|
+
...input.phaseId !== void 0 ? { phaseId: input.phaseId } : {}
|
|
640
|
+
}
|
|
641
|
+
} : {}
|
|
642
|
+
};
|
|
643
|
+
}
|
|
644
|
+
function mergedDependsOn(input) {
|
|
645
|
+
const ids = [
|
|
646
|
+
...input.dependsOn ?? [],
|
|
647
|
+
...input.dependencyTaskId !== void 0 ? [input.dependencyTaskId] : []
|
|
648
|
+
].filter((id, i, arr) => id && arr.indexOf(id) === i);
|
|
649
|
+
return ids.length > 0 ? ids : void 0;
|
|
650
|
+
}
|
|
651
|
+
function taskPatch(input) {
|
|
652
|
+
return {
|
|
653
|
+
title: input.title,
|
|
654
|
+
description: input.description,
|
|
655
|
+
dueDate: input.dueDate,
|
|
656
|
+
columnId: input.columnId,
|
|
657
|
+
order: input.order,
|
|
658
|
+
priority: input.priority,
|
|
659
|
+
...input.taskType !== void 0 ? { type: input.taskType } : {},
|
|
660
|
+
status: input.status,
|
|
661
|
+
labels: input.labels,
|
|
662
|
+
assignedAgent: input.agentId,
|
|
663
|
+
...mergedDependsOn(input) ? { dependsOn: mergedDependsOn(input) } : {},
|
|
664
|
+
...input.estimatedHours !== void 0 ? { estimatedHours: input.estimatedHours } : {},
|
|
665
|
+
...input.actualHours !== void 0 ? { actualHours: input.actualHours } : {}
|
|
666
|
+
};
|
|
667
|
+
}
|
|
668
|
+
function clampRequestedCapabilities(requested) {
|
|
669
|
+
if (requested === void 0) return void 0;
|
|
670
|
+
return clampSubagentCapabilities(requested).granted;
|
|
671
|
+
}
|
|
672
|
+
function assignmentInput(input) {
|
|
673
|
+
return {
|
|
674
|
+
agentId: input.agentId,
|
|
675
|
+
name: input.name,
|
|
676
|
+
role: input.role,
|
|
677
|
+
provider: input.provider,
|
|
678
|
+
model: input.model,
|
|
679
|
+
fallbackProfile: input.fallbackProfile,
|
|
680
|
+
fallbackModels: input.fallbackModels,
|
|
681
|
+
tools: input.tools,
|
|
682
|
+
allowedCapabilities: clampRequestedCapabilities(input.allowedCapabilities),
|
|
683
|
+
assignee: input.assignee,
|
|
684
|
+
leaseId: input.leaseId,
|
|
685
|
+
claimedAt: input.claimedAt,
|
|
686
|
+
heartbeatAt: input.heartbeatAt,
|
|
687
|
+
leaseExpiresAt: input.leaseExpiresAt,
|
|
688
|
+
attempt: input.attempt,
|
|
689
|
+
maxAttempts: input.maxAttempts,
|
|
690
|
+
costCeilingUsd: input.costCeilingUsd,
|
|
691
|
+
retryPolicy: input.retryPolicy,
|
|
692
|
+
lastFailureKind: input.lastFailureKind
|
|
693
|
+
};
|
|
694
|
+
}
|
|
695
|
+
function hasAssignmentInput(input) {
|
|
696
|
+
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;
|
|
697
|
+
}
|
|
698
|
+
function assignmentForTaskCreate(input) {
|
|
699
|
+
return {
|
|
700
|
+
status: input.assignmentStatus ?? "assigned",
|
|
701
|
+
...input.agentId !== void 0 ? { agentId: input.agentId } : {},
|
|
702
|
+
...input.name !== void 0 ? { name: input.name } : {},
|
|
703
|
+
...input.role !== void 0 ? { role: input.role } : {},
|
|
704
|
+
...input.provider !== void 0 ? { provider: input.provider } : {},
|
|
705
|
+
...input.model !== void 0 ? { model: input.model } : {},
|
|
706
|
+
...input.fallbackProfile !== void 0 ? { fallbackProfile: input.fallbackProfile } : {},
|
|
707
|
+
...input.fallbackModels !== void 0 ? { fallbackModels: input.fallbackModels } : {},
|
|
708
|
+
...input.tools !== void 0 ? { tools: input.tools } : {},
|
|
709
|
+
...input.allowedCapabilities !== void 0 ? { allowedCapabilities: clampRequestedCapabilities(input.allowedCapabilities) } : {},
|
|
710
|
+
...input.leaseId !== void 0 ? { leaseId: input.leaseId } : {},
|
|
711
|
+
...input.claimedAt !== void 0 ? { claimedAt: input.claimedAt } : {},
|
|
712
|
+
...input.heartbeatAt !== void 0 ? { heartbeatAt: input.heartbeatAt } : {},
|
|
713
|
+
...input.leaseExpiresAt !== void 0 ? { leaseExpiresAt: input.leaseExpiresAt } : {},
|
|
714
|
+
...input.attempt !== void 0 ? { attempt: input.attempt } : {},
|
|
715
|
+
...input.maxAttempts !== void 0 ? { maxAttempts: input.maxAttempts } : {},
|
|
716
|
+
...input.costCeilingUsd !== void 0 ? { costCeilingUsd: input.costCeilingUsd } : {},
|
|
717
|
+
...input.retryPolicy !== void 0 ? { retryPolicy: input.retryPolicy } : {},
|
|
718
|
+
...input.lastFailureKind !== void 0 ? { lastFailureKind: input.lastFailureKind } : {}
|
|
719
|
+
};
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
// src/kanban-tool-schema.ts
|
|
723
|
+
var KANBAN_TOOL_DESCRIPTION = "Manage and audit project-scoped multi-kanban boards through the shared IPC Kanban server and its SQLite store. Managed cards enforce fully specified details and adjacent Backlog \u2192 Todo \u2192 Running \u2192 Review \u2192 Done transitions with persistent comments and evidence. Contract Map actions are optional advisory metadata unless an operator explicitly enabled strict enforcement. Use verify_completion to validate executable success criteria before Done.";
|
|
724
|
+
var KANBAN_TOOL_USAGE_HINT = "Use this for durable project kanban state. Read workbench when orienting across boards; it returns bounded Now, Next, Blocked, Review lanes and operational alerts. Before coding mutation, create a fully detailed card on a managed board with executable acceptance criteria, then call start_task. The runtime blocks product mutations until start_task binds a ready Running card. Do not create, inspect, repair, or enable a Contract Map during ordinary work; every map mode stays off the execution and completion path. Worker completion enters Review; Done requires passed acceptance criteria and review evidence. Surface existing strict-map findings for operator review without stopping work to repair them.";
|
|
725
|
+
var KANBAN_INPUT_SCHEMA = {
|
|
726
|
+
type: "object",
|
|
727
|
+
properties: {
|
|
728
|
+
action: {
|
|
729
|
+
type: "string",
|
|
730
|
+
enum: [
|
|
731
|
+
"list_boards",
|
|
732
|
+
"get_board",
|
|
733
|
+
"create_board",
|
|
734
|
+
"duplicate_board",
|
|
735
|
+
"update_board",
|
|
736
|
+
"adopt_managed_lifecycle",
|
|
737
|
+
"delete_board",
|
|
738
|
+
"generate_board",
|
|
739
|
+
"export_markdown",
|
|
740
|
+
"export_task_graph",
|
|
741
|
+
"sync_task_graph",
|
|
742
|
+
"create_from_graph",
|
|
743
|
+
"import_session_tasks",
|
|
744
|
+
"search_tasks",
|
|
745
|
+
"ready_tasks",
|
|
746
|
+
"snapshot",
|
|
747
|
+
"workbench",
|
|
748
|
+
"add_column",
|
|
749
|
+
"update_column",
|
|
750
|
+
"delete_column",
|
|
751
|
+
"add_task",
|
|
752
|
+
"split_task",
|
|
753
|
+
"merge_tasks",
|
|
754
|
+
"copy_task",
|
|
755
|
+
"transfer_task",
|
|
756
|
+
"get_task",
|
|
757
|
+
"start_task",
|
|
758
|
+
"update_task",
|
|
759
|
+
"transition_task",
|
|
760
|
+
"repair_managed_projection",
|
|
761
|
+
"move_task",
|
|
762
|
+
"delete_task",
|
|
763
|
+
"set_chain",
|
|
764
|
+
"get_chain",
|
|
765
|
+
"get_contract_graph",
|
|
766
|
+
"configure_contract_graph",
|
|
767
|
+
"upsert_contract_node",
|
|
768
|
+
"link_contract_nodes",
|
|
769
|
+
"remove_contract_node",
|
|
770
|
+
"remove_contract_edge",
|
|
771
|
+
"evaluate_contract_graph",
|
|
772
|
+
"claim_task",
|
|
773
|
+
"release_task",
|
|
774
|
+
"assign_task",
|
|
775
|
+
"mark_assignment",
|
|
776
|
+
"heartbeat_assignment",
|
|
777
|
+
"recover_stale",
|
|
778
|
+
"events",
|
|
779
|
+
"queue_health",
|
|
780
|
+
"add_dependency",
|
|
781
|
+
"add_goal_metric",
|
|
782
|
+
"update_goal_metric",
|
|
783
|
+
"add_check",
|
|
784
|
+
"update_check",
|
|
785
|
+
"add_note",
|
|
786
|
+
"add_link",
|
|
787
|
+
"verify_completion",
|
|
788
|
+
"split_atomic",
|
|
789
|
+
"assess_atomicity",
|
|
790
|
+
"propose_decomposition"
|
|
791
|
+
]
|
|
792
|
+
},
|
|
793
|
+
boardId: { type: "string" },
|
|
794
|
+
taskId: { type: "string" },
|
|
795
|
+
taskIds: { type: "array", items: { type: "string" } },
|
|
796
|
+
chainId: { type: "string" },
|
|
797
|
+
contractNodeId: { type: "string" },
|
|
798
|
+
contractNodeKind: {
|
|
799
|
+
type: "string",
|
|
800
|
+
enum: ["objective", "guardrail", "risk", "component", "artifact", "verification"]
|
|
801
|
+
},
|
|
802
|
+
contractNodeState: {
|
|
803
|
+
type: "string",
|
|
804
|
+
enum: ["unknown", "active", "satisfied", "violated", "resolved"]
|
|
805
|
+
},
|
|
806
|
+
contractEnforcement: {
|
|
807
|
+
type: "string",
|
|
808
|
+
enum: ["blocking", "advisory", "informational"]
|
|
809
|
+
},
|
|
810
|
+
contractGraphEnforcement: { type: "string", enum: ["off", "advisory", "strict"] },
|
|
811
|
+
contractEdgeId: { type: "string" },
|
|
812
|
+
contractEdgeType: {
|
|
813
|
+
type: "string",
|
|
814
|
+
enum: [
|
|
815
|
+
"targets",
|
|
816
|
+
"affects",
|
|
817
|
+
"must_preserve",
|
|
818
|
+
"exposes",
|
|
819
|
+
"verified_by",
|
|
820
|
+
"conflicts_with",
|
|
821
|
+
"derived_from",
|
|
822
|
+
"relates_to"
|
|
823
|
+
]
|
|
824
|
+
},
|
|
825
|
+
fromNodeId: { type: "string" },
|
|
826
|
+
toNodeId: { type: "string" },
|
|
827
|
+
contractRationale: { type: "string" },
|
|
828
|
+
baseline: { oneOf: [{ type: "string" }, { type: "number" }] },
|
|
829
|
+
threshold: { oneOf: [{ type: "string" }, { type: "number" }] },
|
|
830
|
+
columnId: { type: "string" },
|
|
831
|
+
targetBoardId: { type: "string" },
|
|
832
|
+
targetColumnId: { type: "string" },
|
|
833
|
+
title: { type: "string" },
|
|
834
|
+
description: { type: "string" },
|
|
835
|
+
dueDate: { type: "string" },
|
|
836
|
+
tags: { type: "array", items: { type: "string" } },
|
|
837
|
+
labels: { type: "array", items: { type: "string" } },
|
|
838
|
+
priority: { type: "string", enum: ["critical", "high", "medium", "low"] },
|
|
839
|
+
taskType: {
|
|
840
|
+
type: "string",
|
|
841
|
+
enum: ["feature", "bugfix", "refactor", "docs", "test", "chore"]
|
|
842
|
+
},
|
|
843
|
+
status: {
|
|
844
|
+
type: "string",
|
|
845
|
+
enum: [
|
|
846
|
+
"pending",
|
|
847
|
+
"ready",
|
|
848
|
+
"in_progress",
|
|
849
|
+
"blocked",
|
|
850
|
+
"review",
|
|
851
|
+
"completed",
|
|
852
|
+
"failed",
|
|
853
|
+
"archived"
|
|
854
|
+
]
|
|
855
|
+
},
|
|
856
|
+
order: { type: "number" },
|
|
857
|
+
query: { type: "string" },
|
|
858
|
+
limit: { type: "number" },
|
|
859
|
+
agentId: { type: "string" },
|
|
860
|
+
name: { type: "string" },
|
|
861
|
+
role: { type: "string" },
|
|
862
|
+
provider: { type: "string" },
|
|
863
|
+
model: { type: "string" },
|
|
864
|
+
fallbackProfile: { type: "string" },
|
|
865
|
+
fallbackModels: { type: "array", items: { type: "string" } },
|
|
866
|
+
tools: { type: "array", items: { type: "string" } },
|
|
867
|
+
allowedCapabilities: { type: "array", items: { type: "string" } },
|
|
868
|
+
leaseId: { type: "string" },
|
|
869
|
+
claimedAt: { type: "string" },
|
|
870
|
+
heartbeatAt: { type: "string" },
|
|
871
|
+
leaseExpiresAt: { type: "string" },
|
|
872
|
+
attempt: { type: "number" },
|
|
873
|
+
maxAttempts: { type: "number" },
|
|
874
|
+
subagentId: { type: "string" },
|
|
875
|
+
runTaskId: { type: "string" },
|
|
876
|
+
lastResult: { type: "string" },
|
|
877
|
+
error: { type: "string" },
|
|
878
|
+
expectedLeaseId: { type: "string" },
|
|
879
|
+
assignmentStatus: {
|
|
880
|
+
type: "string",
|
|
881
|
+
enum: ["assigned", "queued", "running", "completed", "failed", "cancelled"]
|
|
882
|
+
},
|
|
883
|
+
lifecycleStage: {
|
|
884
|
+
type: "string",
|
|
885
|
+
enum: ["backlog", "todo", "running", "review", "done"]
|
|
886
|
+
},
|
|
887
|
+
transitionAction: { type: "string" },
|
|
888
|
+
transitionComment: { type: "string" },
|
|
889
|
+
attachmentUrl: { type: "string" },
|
|
890
|
+
attachmentTitle: { type: "string" },
|
|
891
|
+
attachmentType: {
|
|
892
|
+
type: "string",
|
|
893
|
+
enum: ["issue", "pr", "doc", "commit", "design", "file", "url", "other"]
|
|
894
|
+
},
|
|
895
|
+
releaseStatus: { type: "string", enum: ["pending", "ready", "blocked"] },
|
|
896
|
+
releaseReason: { type: "string" },
|
|
897
|
+
clearAssignee: { type: "boolean" },
|
|
898
|
+
recoveryMode: { type: "string", enum: ["auto", "release", "retry", "fail"] },
|
|
899
|
+
recoveryNow: { type: "string" },
|
|
900
|
+
recoveryPolicyFailOnCostCeiling: { type: "boolean" },
|
|
901
|
+
recoveryPolicyReleaseOnFailureKinds: { type: "array", items: { type: "string" } },
|
|
902
|
+
recoveryPolicyReleaseOnHeartbeatDue: { type: "boolean" },
|
|
903
|
+
recoveryPolicyRetryPolicyOverride: {
|
|
904
|
+
type: "string",
|
|
905
|
+
enum: ["off", "incremental", "exponential"]
|
|
906
|
+
},
|
|
907
|
+
assignee: { type: "string" },
|
|
908
|
+
costCeilingUsd: { type: "number" },
|
|
909
|
+
retryPolicy: { type: "string", enum: ["off", "incremental", "exponential"] },
|
|
910
|
+
lastFailureKind: { type: "string" },
|
|
911
|
+
dependsOn: { type: "array", items: { type: "string" } },
|
|
912
|
+
estimatedHours: { type: "number" },
|
|
913
|
+
actualHours: { type: "number" },
|
|
914
|
+
taskGraph: { type: "object" },
|
|
915
|
+
graphId: { type: "string" },
|
|
916
|
+
specId: { type: "string" },
|
|
917
|
+
specRequirementId: { type: "string" },
|
|
918
|
+
sourceSystem: { type: "string" },
|
|
919
|
+
phaseId: { type: "string" },
|
|
920
|
+
preserveOriginTaskIds: { type: "boolean" },
|
|
921
|
+
includeArchived: { type: "boolean" },
|
|
922
|
+
archiveMissingTasks: { type: "boolean" },
|
|
923
|
+
preserveManualDependencies: { type: "boolean" },
|
|
924
|
+
dependencyTaskId: { type: "string" },
|
|
925
|
+
enforceDependencies: { type: "boolean" },
|
|
926
|
+
childTitles: { type: "array", items: { type: "string" } },
|
|
927
|
+
inheritAssignment: { type: "boolean" },
|
|
928
|
+
inheritLabels: { type: "boolean" },
|
|
929
|
+
inheritSuccessCriteria: { type: "boolean" },
|
|
930
|
+
inheritGoalMetrics: { type: "boolean" },
|
|
931
|
+
inheritDependencies: { type: "boolean" },
|
|
932
|
+
chainChildren: { type: "boolean" },
|
|
933
|
+
rewireDependents: { type: "boolean" },
|
|
934
|
+
closeSourceTasks: { type: "boolean" },
|
|
935
|
+
metricId: { type: "string" },
|
|
936
|
+
metricName: { type: "string" },
|
|
937
|
+
metricTarget: { oneOf: [{ type: "string" }, { type: "number" }] },
|
|
938
|
+
metricCurrent: { oneOf: [{ type: "string" }, { type: "number" }] },
|
|
939
|
+
metricUnit: { type: "string" },
|
|
940
|
+
metricStatus: { type: "string", enum: ["pending", "met", "missed", "waived"] },
|
|
941
|
+
metricNotes: { type: "string" },
|
|
942
|
+
checkId: { type: "string" },
|
|
943
|
+
checkDescription: { type: "string" },
|
|
944
|
+
checkStatus: { type: "string", enum: ["pending", "passed", "failed", "skipped"] },
|
|
945
|
+
note: { type: "string" },
|
|
946
|
+
author: { type: "string" },
|
|
947
|
+
url: { type: "string" },
|
|
948
|
+
linkTitle: { type: "string" },
|
|
949
|
+
linkType: {
|
|
950
|
+
type: "string",
|
|
951
|
+
enum: ["issue", "pr", "doc", "commit", "design", "file", "url", "other"]
|
|
952
|
+
},
|
|
953
|
+
context: { type: "string" },
|
|
954
|
+
columns: { type: "array", items: { type: "string" } },
|
|
955
|
+
generatedBy: { type: "string" },
|
|
956
|
+
includeTasks: { type: "boolean" },
|
|
957
|
+
includeCompletedTasks: { type: "boolean" },
|
|
958
|
+
preserveAssignment: { type: "boolean" },
|
|
959
|
+
preserveDependencies: { type: "boolean" },
|
|
960
|
+
moveTasksToColumnId: { type: "string" },
|
|
961
|
+
atomicityMode: { type: "string", enum: ["off", "assess", "enforce"] },
|
|
962
|
+
atomicityDecomposition: { type: "string", enum: ["auto", "propose"] },
|
|
963
|
+
gateEnforcement: {
|
|
964
|
+
type: "string",
|
|
965
|
+
// WS-023: `'off'` is deliberately absent. The agent whose work this gate
|
|
966
|
+
// checks must not be able to switch it off; it may only tighten. Turning
|
|
967
|
+
// a gate off stays a human decision, made through board config.
|
|
968
|
+
enum: ["strict", "soft"]
|
|
969
|
+
},
|
|
970
|
+
subtasks: {
|
|
971
|
+
type: "array",
|
|
972
|
+
minItems: 2,
|
|
973
|
+
items: {
|
|
974
|
+
type: "object",
|
|
975
|
+
properties: {
|
|
976
|
+
title: { type: "string" },
|
|
977
|
+
description: { type: "string" },
|
|
978
|
+
successCriteria: { type: "array", items: { type: "string" } },
|
|
979
|
+
dependsOnIndex: { type: "array", items: { type: "number" } }
|
|
980
|
+
},
|
|
981
|
+
required: ["title"]
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
},
|
|
985
|
+
required: ["action"]
|
|
986
|
+
};
|
|
3
987
|
|
|
4
988
|
// src/session-kanban.ts
|
|
5
989
|
import { getSharedProjectMailbox } from "@wrongstack/core/coordination";
|
|
@@ -14,11 +998,11 @@ import { resolveWstackPaths } from "@wrongstack/core/utils";
|
|
|
14
998
|
import {
|
|
15
999
|
bridgeKanbanSupervisor,
|
|
16
1000
|
createBoard,
|
|
17
|
-
getBoard,
|
|
1001
|
+
getBoard as getBoard2,
|
|
18
1002
|
listBoards,
|
|
19
1003
|
removeBoard,
|
|
20
1004
|
syncBoardFromTaskGraph,
|
|
21
|
-
touchKanbanPresence,
|
|
1005
|
+
touchKanbanPresence as touchKanbanPresence2,
|
|
22
1006
|
updateBoard
|
|
23
1007
|
} from "@wrongstack/kanban";
|
|
24
1008
|
var SESSION_BOARD_TAG = "session-work";
|
|
@@ -33,6 +1017,7 @@ var boardQueue = /* @__PURE__ */ new Map();
|
|
|
33
1017
|
var boardEnsures = /* @__PURE__ */ new Map();
|
|
34
1018
|
var pendingMirrors = /* @__PURE__ */ new Map();
|
|
35
1019
|
var activeMirrors = /* @__PURE__ */ new Set();
|
|
1020
|
+
var suppressedTodoMirrors = /* @__PURE__ */ new WeakSet();
|
|
36
1021
|
function boardKey(projectRoot, sessionId) {
|
|
37
1022
|
return `${projectRoot}\0${sessionId}`;
|
|
38
1023
|
}
|
|
@@ -61,7 +1046,7 @@ async function ensureSessionKanbanBoard(projectRoot, sessionId) {
|
|
|
61
1046
|
const summary = (await listBoards(projectRoot)).find(
|
|
62
1047
|
(board2) => board2.tags?.includes(sessionTag(sessionId))
|
|
63
1048
|
);
|
|
64
|
-
let board = summary ? await
|
|
1049
|
+
let board = summary ? await getBoard2(projectRoot, summary.id) : null;
|
|
65
1050
|
if (!board) {
|
|
66
1051
|
return createBoard(projectRoot, {
|
|
67
1052
|
title: sessionBoardTitle(sessionId),
|
|
@@ -142,7 +1127,17 @@ function queueLatestMirror(projectRoot, sessionId, graph, sourceSystem) {
|
|
|
142
1127
|
pending.graph,
|
|
143
1128
|
pending.sourceSystem
|
|
144
1129
|
);
|
|
145
|
-
} catch {
|
|
1130
|
+
} catch (error) {
|
|
1131
|
+
console.warn(
|
|
1132
|
+
JSON.stringify({
|
|
1133
|
+
level: "warn",
|
|
1134
|
+
event: "session-kanban.mirror-failed",
|
|
1135
|
+
sessionId: pending.sessionId,
|
|
1136
|
+
sourceSystem: pending.sourceSystem,
|
|
1137
|
+
message: error instanceof Error ? error.message : String(error),
|
|
1138
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
1139
|
+
})
|
|
1140
|
+
);
|
|
146
1141
|
}
|
|
147
1142
|
}
|
|
148
1143
|
} finally {
|
|
@@ -161,6 +1156,7 @@ function queueLatestMirror(projectRoot, sessionId, graph, sourceSystem) {
|
|
|
161
1156
|
})();
|
|
162
1157
|
}
|
|
163
1158
|
function todoListToSerializedGraph(todos, sessionId) {
|
|
1159
|
+
const graphId = `todo:${sessionId}`;
|
|
164
1160
|
const nodes = todos.map((todo, index) => ({
|
|
165
1161
|
id: todo.id,
|
|
166
1162
|
title: todo.content,
|
|
@@ -168,12 +1164,14 @@ function todoListToSerializedGraph(todos, sessionId) {
|
|
|
168
1164
|
type: "chore",
|
|
169
1165
|
priority: "medium",
|
|
170
1166
|
status: todo.status,
|
|
1167
|
+
specRequirementId: `${graphId}:${todo.id}`,
|
|
171
1168
|
createdAt: index,
|
|
172
1169
|
updatedAt: index
|
|
173
1170
|
}));
|
|
174
1171
|
return {
|
|
175
|
-
id:
|
|
176
|
-
specId:
|
|
1172
|
+
id: graphId,
|
|
1173
|
+
specId: graphId,
|
|
1174
|
+
requiredRequirementIds: nodes.map((node) => node.specRequirementId),
|
|
177
1175
|
title: "Session todos",
|
|
178
1176
|
nodes,
|
|
179
1177
|
edges: [],
|
|
@@ -182,6 +1180,87 @@ function todoListToSerializedGraph(todos, sessionId) {
|
|
|
182
1180
|
updatedAt: 0
|
|
183
1181
|
};
|
|
184
1182
|
}
|
|
1183
|
+
function taskFileToSerializedGraph(tasks, sessionId) {
|
|
1184
|
+
const graphId = `session:${sessionId}`;
|
|
1185
|
+
const ids = new Set(tasks.map((task) => task.id));
|
|
1186
|
+
const nodes = tasks.map((task, index) => ({
|
|
1187
|
+
id: task.id,
|
|
1188
|
+
title: task.title,
|
|
1189
|
+
description: task.description ?? "",
|
|
1190
|
+
type: task.type,
|
|
1191
|
+
priority: task.priority,
|
|
1192
|
+
status: task.status,
|
|
1193
|
+
specRequirementId: `${graphId}:${task.id}`,
|
|
1194
|
+
...task.assignee ? { assignee: task.assignee } : {},
|
|
1195
|
+
...task.estimateHours !== void 0 ? { estimateHours: task.estimateHours } : {},
|
|
1196
|
+
createdAt: index,
|
|
1197
|
+
updatedAt: index
|
|
1198
|
+
}));
|
|
1199
|
+
const edges = tasks.flatMap(
|
|
1200
|
+
(task) => (task.dependsOn ?? []).filter((dependency) => ids.has(dependency)).map((dependency) => ({
|
|
1201
|
+
id: `${dependency}->${task.id}`,
|
|
1202
|
+
from: dependency,
|
|
1203
|
+
to: task.id,
|
|
1204
|
+
type: "depends_on"
|
|
1205
|
+
}))
|
|
1206
|
+
);
|
|
1207
|
+
const hasIncoming = new Set(edges.map((edge) => edge.to));
|
|
1208
|
+
const rootNodes = nodes.filter((node) => !hasIncoming.has(node.id)).map((node) => node.id);
|
|
1209
|
+
return {
|
|
1210
|
+
// Keep the historical graph id so existing mirrored task cards are reused.
|
|
1211
|
+
id: graphId,
|
|
1212
|
+
specId: graphId,
|
|
1213
|
+
requiredRequirementIds: nodes.map((node) => node.specRequirementId),
|
|
1214
|
+
title: "Session tasks",
|
|
1215
|
+
nodes,
|
|
1216
|
+
edges,
|
|
1217
|
+
rootNodes: rootNodes.length ? rootNodes : nodes[0] ? [nodes[0].id] : [],
|
|
1218
|
+
createdAt: 0,
|
|
1219
|
+
updatedAt: 0
|
|
1220
|
+
};
|
|
1221
|
+
}
|
|
1222
|
+
function broadcastTodoUpdate(context, todos) {
|
|
1223
|
+
const sessionId = context.session?.id ?? "";
|
|
1224
|
+
if (!context.agentId || !sessionId) return;
|
|
1225
|
+
const statusCounts = { pending: 0, inProgress: 0, completed: 0 };
|
|
1226
|
+
for (const todo of todos) {
|
|
1227
|
+
if (todo.status === "completed") statusCounts.completed++;
|
|
1228
|
+
else if (todo.status === "in_progress") statusCounts.inProgress++;
|
|
1229
|
+
else statusCounts.pending++;
|
|
1230
|
+
}
|
|
1231
|
+
const projectDir = resolveWstackPaths({ projectRoot: context.projectRoot }).projectDir;
|
|
1232
|
+
const mailbox = getSharedProjectMailbox(projectDir);
|
|
1233
|
+
void mailbox.send({
|
|
1234
|
+
from: context.agentId,
|
|
1235
|
+
to: "*",
|
|
1236
|
+
type: "status",
|
|
1237
|
+
subject: `Kanban todo list updated (${todos.length} item${todos.length === 1 ? "" : "s"})`,
|
|
1238
|
+
body: JSON.stringify({
|
|
1239
|
+
kind: "kanban.todos.updated",
|
|
1240
|
+
sessionId,
|
|
1241
|
+
revision: context.state.revision,
|
|
1242
|
+
todoCount: todos.length,
|
|
1243
|
+
statusCounts
|
|
1244
|
+
}),
|
|
1245
|
+
priority: "normal",
|
|
1246
|
+
senderSessionId: sessionId
|
|
1247
|
+
}).catch(() => {
|
|
1248
|
+
});
|
|
1249
|
+
}
|
|
1250
|
+
function notifyTodoUpdate(context, todos) {
|
|
1251
|
+
const summary = todos.length ? todos.map((todo) => `- [${todo.status}] ${todo.content} (${todo.id})`).join("\n") : "- No active todos remain.";
|
|
1252
|
+
const text = `[KANBAN TODO UPDATE]
|
|
1253
|
+
Another Kanban agent reassessed the shared board. The canonical todo list is now:
|
|
1254
|
+
${summary}
|
|
1255
|
+
Reassess your current plan before continuing; do not rely on the initial todo snapshot.`;
|
|
1256
|
+
const state = context.state;
|
|
1257
|
+
if (typeof state.appendBlockToLastUserMessage === "function") {
|
|
1258
|
+
if (state.appendBlockToLastUserMessage({ type: "text", text })) return;
|
|
1259
|
+
}
|
|
1260
|
+
if (typeof state.appendMessage === "function") {
|
|
1261
|
+
state.appendMessage({ role: "user", content: [{ type: "text", text }] });
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
185
1264
|
function mirrorSessionTodosToKanban(projectRoot, todos, sessionId) {
|
|
186
1265
|
queueLatestMirror(
|
|
187
1266
|
projectRoot,
|
|
@@ -190,18 +1269,1011 @@ function mirrorSessionTodosToKanban(projectRoot, todos, sessionId) {
|
|
|
190
1269
|
"session-todo"
|
|
191
1270
|
);
|
|
192
1271
|
}
|
|
1272
|
+
function sourceStatus(task) {
|
|
1273
|
+
if (task.status === "completed") return "completed";
|
|
1274
|
+
if (task.status === "in_progress") return "in_progress";
|
|
1275
|
+
if (task.status === "review") return "review";
|
|
1276
|
+
if (task.status === "blocked") return "blocked";
|
|
1277
|
+
if (task.status === "failed") return "failed";
|
|
1278
|
+
return "pending";
|
|
1279
|
+
}
|
|
1280
|
+
function todoStatus(task) {
|
|
1281
|
+
const status = sourceStatus(task);
|
|
1282
|
+
if (status === "completed") return "completed";
|
|
1283
|
+
if (status === "in_progress" || status === "review") return "in_progress";
|
|
1284
|
+
return "pending";
|
|
1285
|
+
}
|
|
1286
|
+
function sessionTodoFromTask(task, boardId) {
|
|
1287
|
+
return {
|
|
1288
|
+
id: task.origin?.taskId ?? task.id,
|
|
1289
|
+
content: task.title,
|
|
1290
|
+
status: todoStatus(task),
|
|
1291
|
+
kanbanBoardId: boardId,
|
|
1292
|
+
kanbanTaskId: task.id,
|
|
1293
|
+
...task.description ? { activeForm: task.description } : {}
|
|
1294
|
+
};
|
|
1295
|
+
}
|
|
1296
|
+
function managedTodoFromTask(task, boardId) {
|
|
1297
|
+
return {
|
|
1298
|
+
...sessionTodoFromTask(task, boardId),
|
|
1299
|
+
status: task.status === "completed" ? "completed" : task.status === "in_progress" ? "in_progress" : "pending"
|
|
1300
|
+
};
|
|
1301
|
+
}
|
|
1302
|
+
function sameTodos(left, right) {
|
|
1303
|
+
return left.length === right.length && left.every((todo, index) => {
|
|
1304
|
+
const candidate = right[index];
|
|
1305
|
+
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;
|
|
1306
|
+
});
|
|
1307
|
+
}
|
|
1308
|
+
function applyManagedKanbanBoardToTodos(context, board) {
|
|
1309
|
+
const metaKanban = context.meta["kanban"];
|
|
1310
|
+
const metaBoardId = metaKanban && typeof metaKanban === "object" ? metaKanban["boardId"] : void 0;
|
|
1311
|
+
const activeBoardId2 = context.currentKanbanBoardId ?? (typeof metaBoardId === "string" ? metaBoardId : void 0);
|
|
1312
|
+
if (!activeBoardId2 || board.id !== activeBoardId2 || board.lifecycle?.mode !== "managed") {
|
|
1313
|
+
return [...context.todos];
|
|
1314
|
+
}
|
|
1315
|
+
const projectedTodos = board.tasks.filter(
|
|
1316
|
+
(task) => task.status !== "archived" && task.mergedIntoTaskId === void 0 && (!task.childTaskIds || task.childTaskIds.length === 0)
|
|
1317
|
+
).sort(
|
|
1318
|
+
(left, right) => left.createdAt.localeCompare(right.createdAt) || left.order - right.order
|
|
1319
|
+
).map((task) => managedTodoFromTask(task, board.id));
|
|
1320
|
+
if (sameTodos(context.todos, projectedTodos)) return [...context.todos];
|
|
1321
|
+
suppressedTodoMirrors.add(context);
|
|
1322
|
+
try {
|
|
1323
|
+
context.state.replaceTodos(projectedTodos);
|
|
1324
|
+
} finally {
|
|
1325
|
+
suppressedTodoMirrors.delete(context);
|
|
1326
|
+
}
|
|
1327
|
+
notifyTodoUpdate(context, context.todos);
|
|
1328
|
+
broadcastTodoUpdate(context, context.todos);
|
|
1329
|
+
return [...context.todos];
|
|
1330
|
+
}
|
|
1331
|
+
|
|
1332
|
+
// src/kanban.ts
|
|
1333
|
+
var kanbanTool = {
|
|
1334
|
+
name: "kanban",
|
|
1335
|
+
category: "Project",
|
|
1336
|
+
description: KANBAN_TOOL_DESCRIPTION,
|
|
1337
|
+
usageHint: KANBAN_TOOL_USAGE_HINT,
|
|
1338
|
+
permission: "confirm",
|
|
1339
|
+
mutating: true,
|
|
1340
|
+
capabilities: ["fs.write"],
|
|
1341
|
+
icon: "task",
|
|
1342
|
+
timeoutMs: 3e4,
|
|
1343
|
+
inputSchema: KANBAN_INPUT_SCHEMA,
|
|
1344
|
+
async execute(input, ctx) {
|
|
1345
|
+
const projectRoot = ctx.projectRoot;
|
|
1346
|
+
if (!projectRoot) return fail("No project root is available.");
|
|
1347
|
+
const withPresence = createKanbanPresenceWrapper(projectRoot, input, ctx);
|
|
1348
|
+
try {
|
|
1349
|
+
const result = await (async () => {
|
|
1350
|
+
const decompositionResult = await handleKanbanDecompositionAction(projectRoot, input, ctx);
|
|
1351
|
+
if (decompositionResult !== void 0) return decompositionResult;
|
|
1352
|
+
switch (input.action) {
|
|
1353
|
+
case "list_boards": {
|
|
1354
|
+
const boards = await listBoards2(projectRoot);
|
|
1355
|
+
return { ok: true, message: `${boards.length} board(s).`, boards };
|
|
1356
|
+
}
|
|
1357
|
+
case "get_board": {
|
|
1358
|
+
const board = await requireBoard(projectRoot, input.boardId);
|
|
1359
|
+
return board ? okBoard(board) : fail("Board not found.");
|
|
1360
|
+
}
|
|
1361
|
+
case "create_board": {
|
|
1362
|
+
if (!input.title) return fail("create_board requires title.");
|
|
1363
|
+
const board = await createBoard2(projectRoot, boardCreateInput(input, input.title));
|
|
1364
|
+
return { ok: true, message: `Board created: ${board.title}`, board };
|
|
1365
|
+
}
|
|
1366
|
+
case "update_board": {
|
|
1367
|
+
if (!input.boardId) return fail("update_board requires boardId.");
|
|
1368
|
+
const board = await updateBoard2(projectRoot, input.boardId, boardUpdatePatch(input));
|
|
1369
|
+
return board ? okBoard(board, "Board updated.") : fail("Board not found.");
|
|
1370
|
+
}
|
|
1371
|
+
case "adopt_managed_lifecycle": {
|
|
1372
|
+
if (!input.boardId || !input.author || !input.transitionComment) {
|
|
1373
|
+
return fail(
|
|
1374
|
+
"adopt_managed_lifecycle requires boardId, author, transitionComment, and five ordered columns."
|
|
1375
|
+
);
|
|
1376
|
+
}
|
|
1377
|
+
if (input.columns?.length !== 5) {
|
|
1378
|
+
return fail(
|
|
1379
|
+
"adopt_managed_lifecycle columns must be ordered as backlog, todo, running, review, done."
|
|
1380
|
+
);
|
|
1381
|
+
}
|
|
1382
|
+
const [backlog, todo, running, review, done] = input.columns;
|
|
1383
|
+
if (!backlog || !todo || !running || !review || !done) {
|
|
1384
|
+
return fail("adopt_managed_lifecycle columns must contain five nonblank ids.");
|
|
1385
|
+
}
|
|
1386
|
+
const board = await adoptManagedLifecycle(projectRoot, input.boardId, {
|
|
1387
|
+
columns: { backlog, todo, running, review, done },
|
|
1388
|
+
actor: input.author,
|
|
1389
|
+
comment: input.transitionComment
|
|
1390
|
+
});
|
|
1391
|
+
return board ? okBoard(board, "Managed lifecycle adopted without moving existing cards.") : fail("Board not found.");
|
|
1392
|
+
}
|
|
1393
|
+
case "duplicate_board": {
|
|
1394
|
+
if (!input.boardId) return fail("duplicate_board requires boardId.");
|
|
1395
|
+
const board = await duplicateBoard(
|
|
1396
|
+
projectRoot,
|
|
1397
|
+
input.boardId,
|
|
1398
|
+
duplicateBoardOptions(input)
|
|
1399
|
+
);
|
|
1400
|
+
return board ? okBoard(board, "Board duplicated.") : fail("Board not found.");
|
|
1401
|
+
}
|
|
1402
|
+
case "delete_board": {
|
|
1403
|
+
if (!input.boardId) return fail("delete_board requires boardId.");
|
|
1404
|
+
const removed = await removeBoard2(projectRoot, input.boardId);
|
|
1405
|
+
return { ok: removed, message: removed ? "Board deleted." : "Board not found." };
|
|
1406
|
+
}
|
|
1407
|
+
case "generate_board": {
|
|
1408
|
+
if (!input.description) return fail("generate_board requires description.");
|
|
1409
|
+
const boardInput = createBoardFromText({
|
|
1410
|
+
description: input.description,
|
|
1411
|
+
...input.title !== void 0 ? { title: input.title } : {},
|
|
1412
|
+
...input.context !== void 0 ? { context: input.context } : {},
|
|
1413
|
+
...input.columns !== void 0 ? { columns: input.columns } : {}
|
|
1414
|
+
});
|
|
1415
|
+
const board = await createBoard2(projectRoot, boardInput);
|
|
1416
|
+
for (const taskInput2 of parseLinesIntoTasks(
|
|
1417
|
+
input.description,
|
|
1418
|
+
board.columns[0]?.id ?? "backlog"
|
|
1419
|
+
)) {
|
|
1420
|
+
await addTask(projectRoot, board.id, taskInput2);
|
|
1421
|
+
}
|
|
1422
|
+
return okBoard(await getBoard3(projectRoot, board.id) ?? board, "Board generated.");
|
|
1423
|
+
}
|
|
1424
|
+
case "export_markdown": {
|
|
1425
|
+
const board = await requireBoard(projectRoot, input.boardId);
|
|
1426
|
+
if (!board) return fail("Board not found.");
|
|
1427
|
+
return {
|
|
1428
|
+
ok: true,
|
|
1429
|
+
message: "Board exported.",
|
|
1430
|
+
board,
|
|
1431
|
+
markdown: exportBoardAsMarkdown(board)
|
|
1432
|
+
};
|
|
1433
|
+
}
|
|
1434
|
+
case "export_task_graph": {
|
|
1435
|
+
if (!input.boardId) return fail("export_task_graph requires boardId.");
|
|
1436
|
+
const exported = await exportBoardToTaskGraph(projectRoot, input.boardId, {
|
|
1437
|
+
...input.graphId !== void 0 ? { graphId: input.graphId } : {},
|
|
1438
|
+
...input.specId !== void 0 ? { specId: input.specId } : {},
|
|
1439
|
+
...input.title !== void 0 ? { title: input.title } : {},
|
|
1440
|
+
...input.preserveOriginTaskIds !== void 0 ? { preserveOriginTaskIds: input.preserveOriginTaskIds } : {},
|
|
1441
|
+
...input.includeArchived !== void 0 ? { includeArchived: input.includeArchived } : {}
|
|
1442
|
+
});
|
|
1443
|
+
if (!exported) return fail("Board not found.");
|
|
1444
|
+
return {
|
|
1445
|
+
ok: true,
|
|
1446
|
+
message: `Task graph exported with ${exported.graph.nodes.size} node(s).`,
|
|
1447
|
+
board: exported.board,
|
|
1448
|
+
taskGraph: serializeTaskGraph(exported.graph)
|
|
1449
|
+
};
|
|
1450
|
+
}
|
|
1451
|
+
case "sync_task_graph": {
|
|
1452
|
+
if (!input.boardId || !input.taskGraph) {
|
|
1453
|
+
return fail("sync_task_graph requires boardId and taskGraph.");
|
|
1454
|
+
}
|
|
1455
|
+
const graph = deserializeTaskGraph2(input.taskGraph);
|
|
1456
|
+
const result2 = await syncBoardFromTaskGraph2(projectRoot, input.boardId, graph, {
|
|
1457
|
+
...input.title !== void 0 ? { title: input.title } : {},
|
|
1458
|
+
...input.description !== void 0 ? { description: input.description } : {},
|
|
1459
|
+
...input.tags !== void 0 ? { tags: input.tags } : {},
|
|
1460
|
+
...input.generatedBy !== void 0 ? { generatedBy: input.generatedBy } : {},
|
|
1461
|
+
...input.sourceSystem !== void 0 ? { sourceSystem: input.sourceSystem } : {},
|
|
1462
|
+
...input.phaseId !== void 0 ? { phaseId: input.phaseId } : {},
|
|
1463
|
+
...input.includeCompletedTasks !== void 0 ? { includeCompletedTasks: input.includeCompletedTasks } : {},
|
|
1464
|
+
...input.archiveMissingTasks !== void 0 ? { archiveMissingTasks: input.archiveMissingTasks } : {},
|
|
1465
|
+
...input.preserveManualDependencies !== void 0 ? { preserveManualDependencies: input.preserveManualDependencies } : {}
|
|
1466
|
+
});
|
|
1467
|
+
return result2 ? {
|
|
1468
|
+
ok: true,
|
|
1469
|
+
message: `Task graph synced: ${result2.createdTaskIds.length} created, ${result2.updatedTaskIds.length} updated, ${result2.archivedTaskIds.length} archived.`,
|
|
1470
|
+
board: result2.board
|
|
1471
|
+
} : fail("Board not found.");
|
|
1472
|
+
}
|
|
1473
|
+
case "create_from_graph": {
|
|
1474
|
+
if (!input.taskGraph) return fail("create_from_graph requires taskGraph.");
|
|
1475
|
+
const graph = deserializeTaskGraph2(input.taskGraph);
|
|
1476
|
+
const { board } = await createBoardFromTaskGraph(projectRoot, graph, {
|
|
1477
|
+
...input.title !== void 0 ? { title: input.title } : {},
|
|
1478
|
+
...input.description !== void 0 ? { description: input.description } : {},
|
|
1479
|
+
...input.tags !== void 0 ? { tags: input.tags } : {},
|
|
1480
|
+
...input.generatedBy !== void 0 ? { generatedBy: input.generatedBy } : {},
|
|
1481
|
+
...input.sourceSystem !== void 0 ? { sourceSystem: input.sourceSystem } : {},
|
|
1482
|
+
...input.phaseId !== void 0 ? { phaseId: input.phaseId } : {},
|
|
1483
|
+
...input.includeCompletedTasks !== void 0 ? { includeCompletedTasks: input.includeCompletedTasks } : {}
|
|
1484
|
+
});
|
|
1485
|
+
return {
|
|
1486
|
+
ok: true,
|
|
1487
|
+
message: `Created board "${board.title}" from task graph with ${board.tasks.length} tasks.`,
|
|
1488
|
+
board
|
|
1489
|
+
};
|
|
1490
|
+
}
|
|
1491
|
+
case "import_session_tasks": {
|
|
1492
|
+
const taskPath = ctx.meta?.["task.path"];
|
|
1493
|
+
if (!taskPath) return fail("No session task file for this session.");
|
|
1494
|
+
const file = await loadTasks2(taskPath);
|
|
1495
|
+
if (!file || file.tasks.length === 0) return fail("No session tasks to import.");
|
|
1496
|
+
const sessionId = ctx.session?.id ?? file.sessionId ?? "session";
|
|
1497
|
+
const graph = deserializeTaskGraph2(taskFileToSerializedGraph(file.tasks, sessionId));
|
|
1498
|
+
const tags = ["session", `session:${sessionId}`];
|
|
1499
|
+
const existing = (await listBoards2(projectRoot)).find(
|
|
1500
|
+
(b) => b.tags?.includes(`session:${sessionId}`)
|
|
1501
|
+
);
|
|
1502
|
+
if (existing) {
|
|
1503
|
+
const result2 = await syncBoardFromTaskGraph2(projectRoot, existing.id, graph, {
|
|
1504
|
+
sourceSystem: "session",
|
|
1505
|
+
tags,
|
|
1506
|
+
archiveMissingTasks: true,
|
|
1507
|
+
includeCompletedTasks: true
|
|
1508
|
+
});
|
|
1509
|
+
return result2 ? {
|
|
1510
|
+
ok: true,
|
|
1511
|
+
message: `Synced ${file.tasks.length} session tasks into board "${result2.board.title}".`,
|
|
1512
|
+
board: result2.board
|
|
1513
|
+
} : fail("Session board vanished mid-sync.");
|
|
1514
|
+
}
|
|
1515
|
+
const { board } = await createBoardFromTaskGraph(projectRoot, graph, {
|
|
1516
|
+
title: `Session tasks (${sessionId.slice(0, 8)})`,
|
|
1517
|
+
sourceSystem: "session",
|
|
1518
|
+
tags
|
|
1519
|
+
});
|
|
1520
|
+
return {
|
|
1521
|
+
ok: true,
|
|
1522
|
+
message: `Imported ${file.tasks.length} session tasks into new board "${board.title}".`,
|
|
1523
|
+
board
|
|
1524
|
+
};
|
|
1525
|
+
}
|
|
1526
|
+
case "search_tasks": {
|
|
1527
|
+
const tasks = await searchKanban(projectRoot, {
|
|
1528
|
+
query: input.query,
|
|
1529
|
+
boardId: input.boardId,
|
|
1530
|
+
assignedAgent: input.agentId,
|
|
1531
|
+
status: input.status,
|
|
1532
|
+
priority: input.priority,
|
|
1533
|
+
label: input.labels?.[0],
|
|
1534
|
+
chainId: input.chainId
|
|
1535
|
+
});
|
|
1536
|
+
return { ok: true, message: `${tasks.length} task(s) matched.`, tasks };
|
|
1537
|
+
}
|
|
1538
|
+
case "ready_tasks": {
|
|
1539
|
+
const tasks = await listReadyTasks(projectRoot, {
|
|
1540
|
+
query: input.query,
|
|
1541
|
+
boardId: input.boardId,
|
|
1542
|
+
assignedAgent: input.agentId,
|
|
1543
|
+
priority: input.priority,
|
|
1544
|
+
label: input.labels?.[0],
|
|
1545
|
+
chainId: input.chainId,
|
|
1546
|
+
limit: input.limit
|
|
1547
|
+
});
|
|
1548
|
+
return { ok: true, message: `${tasks.length} ready task(s).`, tasks };
|
|
1549
|
+
}
|
|
1550
|
+
case "snapshot": {
|
|
1551
|
+
const snapshot = await getKanbanOrchestrationSnapshot(projectRoot, {
|
|
1552
|
+
query: input.query,
|
|
1553
|
+
boardId: input.boardId,
|
|
1554
|
+
assignedAgent: input.agentId,
|
|
1555
|
+
status: input.status,
|
|
1556
|
+
priority: input.priority,
|
|
1557
|
+
label: input.labels?.[0],
|
|
1558
|
+
chainId: input.chainId
|
|
1559
|
+
});
|
|
1560
|
+
return {
|
|
1561
|
+
ok: true,
|
|
1562
|
+
message: `${snapshot.ready.length} ready, ${snapshot.running.length} running, ${snapshot.blocked.length} blocked.`,
|
|
1563
|
+
snapshot
|
|
1564
|
+
};
|
|
1565
|
+
}
|
|
1566
|
+
case "add_column": {
|
|
1567
|
+
if (!input.boardId || !input.title)
|
|
1568
|
+
return fail("add_column requires boardId and title.");
|
|
1569
|
+
const result2 = await addColumn(projectRoot, input.boardId, {
|
|
1570
|
+
title: input.title,
|
|
1571
|
+
...input.description !== void 0 ? { description: input.description } : {}
|
|
1572
|
+
});
|
|
1573
|
+
return result2 ? okBoard(result2.board, "Column added.") : fail("Board not found.");
|
|
1574
|
+
}
|
|
1575
|
+
case "update_column": {
|
|
1576
|
+
if (!input.boardId || !input.columnId)
|
|
1577
|
+
return fail("update_column requires boardId and columnId.");
|
|
1578
|
+
const board = await updateColumn(projectRoot, input.boardId, input.columnId, {
|
|
1579
|
+
...input.title !== void 0 ? { title: input.title } : {},
|
|
1580
|
+
...input.description !== void 0 ? { description: input.description } : {},
|
|
1581
|
+
...input.order !== void 0 ? { order: input.order } : {}
|
|
1582
|
+
});
|
|
1583
|
+
return board ? okBoard(board, "Column updated.") : fail("Column not found.");
|
|
1584
|
+
}
|
|
1585
|
+
case "delete_column": {
|
|
1586
|
+
if (!input.boardId || !input.columnId)
|
|
1587
|
+
return fail("delete_column requires boardId and columnId.");
|
|
1588
|
+
const board = await removeColumn(projectRoot, input.boardId, input.columnId, {
|
|
1589
|
+
moveTasksToColumnId: input.moveTasksToColumnId
|
|
1590
|
+
});
|
|
1591
|
+
return board ? okBoard(board, "Column deleted.") : fail("Column not found.");
|
|
1592
|
+
}
|
|
1593
|
+
case "add_task": {
|
|
1594
|
+
if (!input.boardId || !input.title) return fail("add_task requires boardId and title.");
|
|
1595
|
+
const result2 = await addTask(projectRoot, input.boardId, taskInput(input));
|
|
1596
|
+
if (!result2) return fail("Board not found.");
|
|
1597
|
+
return okTask(result2.board, result2.task, `Task added.${atomicityNudge(result2.task)}`);
|
|
1598
|
+
}
|
|
1599
|
+
case "split_task": {
|
|
1600
|
+
if (!input.boardId || !input.taskId || !input.childTitles?.length) {
|
|
1601
|
+
return fail("split_task requires boardId, taskId, and childTitles.");
|
|
1602
|
+
}
|
|
1603
|
+
return handleSplitTask(projectRoot, input, {});
|
|
1604
|
+
}
|
|
1605
|
+
case "merge_tasks": {
|
|
1606
|
+
if (!input.boardId || !input.taskIds?.length || !input.title) {
|
|
1607
|
+
return fail("merge_tasks requires boardId, taskIds, and title.");
|
|
1608
|
+
}
|
|
1609
|
+
const result2 = await mergeTasks(projectRoot, input.boardId, {
|
|
1610
|
+
taskIds: input.taskIds,
|
|
1611
|
+
title: input.title,
|
|
1612
|
+
...input.description !== void 0 ? { description: input.description } : {},
|
|
1613
|
+
...input.targetColumnId !== void 0 ? { targetColumnId: input.targetColumnId } : {},
|
|
1614
|
+
...input.preserveAssignment !== void 0 ? { preserveAssignment: input.preserveAssignment } : {},
|
|
1615
|
+
...input.closeSourceTasks !== void 0 ? { closeSourceTasks: input.closeSourceTasks } : {}
|
|
1616
|
+
});
|
|
1617
|
+
return result2 ? okTask(result2.board, result2.task, "Tasks merged.") : fail("Board or task not found.");
|
|
1618
|
+
}
|
|
1619
|
+
case "copy_task": {
|
|
1620
|
+
if (!input.boardId || !input.taskId || !input.targetBoardId) {
|
|
1621
|
+
return fail("copy_task requires boardId, taskId, and targetBoardId.");
|
|
1622
|
+
}
|
|
1623
|
+
const result2 = await copyTaskToBoard(
|
|
1624
|
+
projectRoot,
|
|
1625
|
+
input.boardId,
|
|
1626
|
+
input.taskId,
|
|
1627
|
+
input.targetBoardId,
|
|
1628
|
+
{
|
|
1629
|
+
...input.targetColumnId !== void 0 ? { targetColumnId: input.targetColumnId } : {},
|
|
1630
|
+
...input.order !== void 0 ? { targetOrder: input.order } : {},
|
|
1631
|
+
...input.preserveAssignment !== void 0 ? { preserveAssignment: input.preserveAssignment } : {},
|
|
1632
|
+
...input.preserveDependencies !== void 0 ? { preserveDependencies: input.preserveDependencies } : {}
|
|
1633
|
+
}
|
|
1634
|
+
);
|
|
1635
|
+
return result2 ? okTask(result2.targetBoard, result2.task, "Task copied to target board.") : fail("Board or task not found.");
|
|
1636
|
+
}
|
|
1637
|
+
case "transfer_task": {
|
|
1638
|
+
if (!input.boardId || !input.taskId || !input.targetBoardId) {
|
|
1639
|
+
return fail("transfer_task requires boardId, taskId, and targetBoardId.");
|
|
1640
|
+
}
|
|
1641
|
+
const result2 = await transferTaskToBoard(
|
|
1642
|
+
projectRoot,
|
|
1643
|
+
input.boardId,
|
|
1644
|
+
input.taskId,
|
|
1645
|
+
input.targetBoardId,
|
|
1646
|
+
{
|
|
1647
|
+
...input.targetColumnId !== void 0 ? { targetColumnId: input.targetColumnId } : {},
|
|
1648
|
+
...input.order !== void 0 ? { targetOrder: input.order } : {},
|
|
1649
|
+
...input.preserveAssignment !== void 0 ? { preserveAssignment: input.preserveAssignment } : {},
|
|
1650
|
+
...input.preserveDependencies !== void 0 ? { preserveDependencies: input.preserveDependencies } : {}
|
|
1651
|
+
}
|
|
1652
|
+
);
|
|
1653
|
+
return result2 ? okTask(result2.targetBoard, result2.task, "Task transferred to target board.") : fail("Board or task not found.");
|
|
1654
|
+
}
|
|
1655
|
+
case "get_task": {
|
|
1656
|
+
if (!input.boardId || !input.taskId)
|
|
1657
|
+
return fail("get_task requires boardId and taskId.");
|
|
1658
|
+
const task = await getTask(projectRoot, input.boardId, input.taskId);
|
|
1659
|
+
return task ? { ok: true, message: "Task loaded.", task } : fail("Task not found.");
|
|
1660
|
+
}
|
|
1661
|
+
case "start_task": {
|
|
1662
|
+
if (!input.boardId || !input.taskId || !input.author || !input.transitionComment) {
|
|
1663
|
+
return fail("start_task requires boardId, taskId, author, and transitionComment.");
|
|
1664
|
+
}
|
|
1665
|
+
let board = await getBoard3(projectRoot, input.boardId);
|
|
1666
|
+
let task = board?.tasks.find((candidate) => candidate.id === input.taskId);
|
|
1667
|
+
if (!board || !task) return fail("Board or task not found.");
|
|
1668
|
+
const readiness = evaluateContractGraphReadiness(board, task.id);
|
|
1669
|
+
if (!readiness.ready) {
|
|
1670
|
+
return fail(
|
|
1671
|
+
`Task is not implementation-ready: ${readiness.issues.map((issue) => issue.message).join(" | ")}`
|
|
1672
|
+
);
|
|
1673
|
+
}
|
|
1674
|
+
let stage = task.lifecycle?.currentStage;
|
|
1675
|
+
if (stage === "backlog") {
|
|
1676
|
+
const moved = await transitionTask(projectRoot, board.id, task.id, {
|
|
1677
|
+
to: "todo",
|
|
1678
|
+
actor: input.author,
|
|
1679
|
+
comment: input.transitionComment
|
|
1680
|
+
});
|
|
1681
|
+
if (!moved) return fail("Task could not enter Todo.");
|
|
1682
|
+
board = moved.board;
|
|
1683
|
+
task = moved.task;
|
|
1684
|
+
stage = task.lifecycle?.currentStage;
|
|
1685
|
+
}
|
|
1686
|
+
if (stage === "todo" || stage === "review") {
|
|
1687
|
+
const now = /* @__PURE__ */ new Date();
|
|
1688
|
+
const leaseId = input.leaseId ?? randomUUID2();
|
|
1689
|
+
const assigned = await updateTaskAssignment(projectRoot, board.id, task.id, {
|
|
1690
|
+
status: "running",
|
|
1691
|
+
agentId: input.agentId ?? input.author,
|
|
1692
|
+
leaseId,
|
|
1693
|
+
claimedAt: input.claimedAt ?? now.toISOString(),
|
|
1694
|
+
heartbeatAt: input.heartbeatAt ?? now.toISOString(),
|
|
1695
|
+
leaseExpiresAt: input.leaseExpiresAt ?? new Date(now.getTime() + 15 * 6e4).toISOString(),
|
|
1696
|
+
attempt: input.attempt ?? 1,
|
|
1697
|
+
maxAttempts: input.maxAttempts ?? 3
|
|
1698
|
+
});
|
|
1699
|
+
if (!assigned) return fail("Task assignment could not be started.");
|
|
1700
|
+
const moved = await transitionTask(projectRoot, board.id, task.id, {
|
|
1701
|
+
to: "running",
|
|
1702
|
+
actor: input.author,
|
|
1703
|
+
comment: input.transitionComment
|
|
1704
|
+
});
|
|
1705
|
+
if (!moved) return fail("Task could not enter Running.");
|
|
1706
|
+
board = moved.board;
|
|
1707
|
+
task = moved.task;
|
|
1708
|
+
stage = task.lifecycle?.currentStage;
|
|
1709
|
+
}
|
|
1710
|
+
if (stage !== "running" || task.assignment?.status !== "running") {
|
|
1711
|
+
return fail(
|
|
1712
|
+
`start_task only accepts Backlog, Todo, Review repair, or live Running cards (current: ${stage ?? "unknown"}).`
|
|
1713
|
+
);
|
|
1714
|
+
}
|
|
1715
|
+
ctx.setCurrentKanbanTask(task.id, board.id);
|
|
1716
|
+
return okTask(
|
|
1717
|
+
board,
|
|
1718
|
+
task,
|
|
1719
|
+
"Task is active; runtime Kanban governance is now bound to this run."
|
|
1720
|
+
);
|
|
1721
|
+
}
|
|
1722
|
+
case "update_task": {
|
|
1723
|
+
if (!input.boardId || !input.taskId)
|
|
1724
|
+
return fail("update_task requires boardId and taskId.");
|
|
1725
|
+
const board = await updateTask2(
|
|
1726
|
+
projectRoot,
|
|
1727
|
+
input.boardId,
|
|
1728
|
+
input.taskId,
|
|
1729
|
+
taskPatch(input)
|
|
1730
|
+
);
|
|
1731
|
+
return board ? okBoard(board, "Task updated.") : fail("Task not found.");
|
|
1732
|
+
}
|
|
1733
|
+
case "transition_task": {
|
|
1734
|
+
if (!input.boardId || !input.taskId || !input.lifecycleStage || !input.author || !input.transitionComment) {
|
|
1735
|
+
return fail(
|
|
1736
|
+
"transition_task requires boardId, taskId, lifecycleStage, author, and transitionComment."
|
|
1737
|
+
);
|
|
1738
|
+
}
|
|
1739
|
+
if (input.lifecycleStage === "done") {
|
|
1740
|
+
const boardBefore = await getBoard3(projectRoot, input.boardId);
|
|
1741
|
+
const taskBefore = boardBefore ? await getTask(projectRoot, input.boardId, input.taskId) : null;
|
|
1742
|
+
if (boardBefore && taskBefore && !taskBefore.verificationReport && (taskBefore.atomic || Boolean(taskBefore.successCriteria?.length))) {
|
|
1743
|
+
const preGate = await verifyTaskCompletion2(
|
|
1744
|
+
projectRoot,
|
|
1745
|
+
input.boardId,
|
|
1746
|
+
taskBefore.id,
|
|
1747
|
+
{
|
|
1748
|
+
persist: false
|
|
1749
|
+
}
|
|
1750
|
+
);
|
|
1751
|
+
await updateTask2(projectRoot, input.boardId, taskBefore.id, {
|
|
1752
|
+
verificationReport: preGate.report,
|
|
1753
|
+
successCriteria: preGate.task.successCriteria
|
|
1754
|
+
});
|
|
1755
|
+
}
|
|
1756
|
+
}
|
|
1757
|
+
const result2 = await transitionTask(projectRoot, input.boardId, input.taskId, {
|
|
1758
|
+
to: input.lifecycleStage,
|
|
1759
|
+
actor: input.author,
|
|
1760
|
+
comment: input.transitionComment,
|
|
1761
|
+
...input.transitionAction !== void 0 ? { action: input.transitionAction } : {},
|
|
1762
|
+
...input.attachmentUrl !== void 0 ? {
|
|
1763
|
+
attachment: {
|
|
1764
|
+
url: input.attachmentUrl,
|
|
1765
|
+
type: input.attachmentType ?? "url",
|
|
1766
|
+
...input.attachmentTitle !== void 0 ? { title: input.attachmentTitle } : {}
|
|
1767
|
+
}
|
|
1768
|
+
} : {},
|
|
1769
|
+
patch: taskPatch(input)
|
|
1770
|
+
});
|
|
1771
|
+
if (result2 && input.lifecycleStage === "done" && result2.task.verificationReport) {
|
|
1772
|
+
recordKanbanVerificationEvidence(ctx, result2.task.verificationReport);
|
|
1773
|
+
}
|
|
1774
|
+
return result2 ? okTask(result2.board, result2.task, `Task advanced to ${result2.transition.to}.`) : fail("Board or task not found.");
|
|
1775
|
+
}
|
|
1776
|
+
case "repair_managed_projection": {
|
|
1777
|
+
if (!input.boardId || !input.taskId || !input.author || !input.transitionComment) {
|
|
1778
|
+
return fail(
|
|
1779
|
+
"repair_managed_projection requires boardId, taskId, author, and transitionComment."
|
|
1780
|
+
);
|
|
1781
|
+
}
|
|
1782
|
+
const result2 = await repairManagedTaskProjection(
|
|
1783
|
+
projectRoot,
|
|
1784
|
+
input.boardId,
|
|
1785
|
+
input.taskId,
|
|
1786
|
+
{
|
|
1787
|
+
actor: input.author,
|
|
1788
|
+
comment: input.transitionComment
|
|
1789
|
+
}
|
|
1790
|
+
);
|
|
1791
|
+
return result2 ? okTask(
|
|
1792
|
+
result2.board,
|
|
1793
|
+
result2.task,
|
|
1794
|
+
"Managed card projection repaired from lifecycle history."
|
|
1795
|
+
) : fail("Board or task not found.");
|
|
1796
|
+
}
|
|
1797
|
+
case "move_task": {
|
|
1798
|
+
if (!input.boardId || !input.taskId || !input.targetColumnId) {
|
|
1799
|
+
return fail("move_task requires boardId, taskId, and targetColumnId.");
|
|
1800
|
+
}
|
|
1801
|
+
const board = await moveTask(
|
|
1802
|
+
projectRoot,
|
|
1803
|
+
input.boardId,
|
|
1804
|
+
input.taskId,
|
|
1805
|
+
input.targetColumnId,
|
|
1806
|
+
input.order
|
|
1807
|
+
);
|
|
1808
|
+
return board ? okBoard(board, "Task moved.") : fail("Move failed.");
|
|
1809
|
+
}
|
|
1810
|
+
case "delete_task": {
|
|
1811
|
+
if (!input.boardId || !input.taskId)
|
|
1812
|
+
return fail("delete_task requires boardId and taskId.");
|
|
1813
|
+
const board = await removeTask(projectRoot, input.boardId, input.taskId);
|
|
1814
|
+
return board ? okBoard(board, "Task deleted.") : fail("Task not found.");
|
|
1815
|
+
}
|
|
1816
|
+
case "set_chain": {
|
|
1817
|
+
if (!input.boardId || !input.taskIds?.length) {
|
|
1818
|
+
return fail("set_chain requires boardId and taskIds.");
|
|
1819
|
+
}
|
|
1820
|
+
const result2 = await setTaskChain(projectRoot, input.boardId, {
|
|
1821
|
+
taskIds: input.taskIds,
|
|
1822
|
+
...input.chainId !== void 0 ? { chainId: input.chainId } : {},
|
|
1823
|
+
...input.enforceDependencies !== void 0 ? { enforceDependencies: input.enforceDependencies } : {}
|
|
1824
|
+
});
|
|
1825
|
+
return result2 ? {
|
|
1826
|
+
ok: true,
|
|
1827
|
+
message: `Chain set: ${result2.chainId}`,
|
|
1828
|
+
board: result2.board,
|
|
1829
|
+
chain: result2.tasks
|
|
1830
|
+
} : fail("Board or task not found.");
|
|
1831
|
+
}
|
|
1832
|
+
case "get_chain": {
|
|
1833
|
+
if (!input.boardId || !(input.taskId || input.chainId)) {
|
|
1834
|
+
return fail("get_chain requires boardId and taskId or chainId.");
|
|
1835
|
+
}
|
|
1836
|
+
const result2 = await getTaskChain(
|
|
1837
|
+
projectRoot,
|
|
1838
|
+
input.boardId,
|
|
1839
|
+
input.taskId ?? input.chainId ?? ""
|
|
1840
|
+
);
|
|
1841
|
+
return result2 ? {
|
|
1842
|
+
ok: true,
|
|
1843
|
+
message: `Chain loaded: ${result2.chainId}`,
|
|
1844
|
+
board: result2.board,
|
|
1845
|
+
chain: result2.tasks
|
|
1846
|
+
} : fail("Chain not found.");
|
|
1847
|
+
}
|
|
1848
|
+
case "claim_task": {
|
|
1849
|
+
const result2 = await claimReadyTask(projectRoot, {
|
|
1850
|
+
...input.boardId !== void 0 ? { boardId: input.boardId } : {},
|
|
1851
|
+
...input.taskId !== void 0 ? { taskId: input.taskId } : {},
|
|
1852
|
+
...assignmentInput(input),
|
|
1853
|
+
status: input.assignmentStatus ?? "queued"
|
|
1854
|
+
});
|
|
1855
|
+
return result2 ? okTask(result2.board, result2.task, "Task claimed.") : fail("No ready kanban task matched the claim.");
|
|
1856
|
+
}
|
|
1857
|
+
case "release_task": {
|
|
1858
|
+
if (!input.boardId || !input.taskId) {
|
|
1859
|
+
return fail("release_task requires boardId and taskId.");
|
|
1860
|
+
}
|
|
1861
|
+
const board = await releaseTaskClaim(projectRoot, input.boardId, input.taskId, {
|
|
1862
|
+
...input.releaseStatus !== void 0 ? { status: input.releaseStatus } : {},
|
|
1863
|
+
...input.releaseReason !== void 0 ? { reason: input.releaseReason } : {},
|
|
1864
|
+
...input.clearAssignee !== void 0 ? { clearAssignee: input.clearAssignee } : {}
|
|
1865
|
+
});
|
|
1866
|
+
return board ? okBoard(board, "Task claim released.") : fail("Task not found.");
|
|
1867
|
+
}
|
|
1868
|
+
case "assign_task": {
|
|
1869
|
+
if (!input.boardId || !input.taskId)
|
|
1870
|
+
return fail("assign_task requires boardId and taskId.");
|
|
1871
|
+
const board = await assignTask(
|
|
1872
|
+
projectRoot,
|
|
1873
|
+
input.boardId,
|
|
1874
|
+
input.taskId,
|
|
1875
|
+
assignmentInput(input)
|
|
1876
|
+
);
|
|
1877
|
+
return board ? okBoard(board, "Task assigned.") : fail("Task not found.");
|
|
1878
|
+
}
|
|
1879
|
+
case "mark_assignment": {
|
|
1880
|
+
if (!input.boardId || !input.taskId)
|
|
1881
|
+
return fail("mark_assignment requires boardId and taskId.");
|
|
1882
|
+
const assignmentStatus = input.assignmentStatus ?? (input.status === "completed" ? "completed" : input.error ? "failed" : void 0);
|
|
1883
|
+
const board = await updateTaskAssignment(
|
|
1884
|
+
projectRoot,
|
|
1885
|
+
input.boardId,
|
|
1886
|
+
input.taskId,
|
|
1887
|
+
{
|
|
1888
|
+
...assignmentStatus !== void 0 ? { status: assignmentStatus } : {},
|
|
1889
|
+
...input.subagentId !== void 0 ? { subagentId: input.subagentId } : {},
|
|
1890
|
+
...input.runTaskId !== void 0 ? { runTaskId: input.runTaskId } : {},
|
|
1891
|
+
...input.lastResult !== void 0 ? { lastResult: input.lastResult } : {},
|
|
1892
|
+
...input.error !== void 0 ? { error: input.error } : {},
|
|
1893
|
+
...input.agentId !== void 0 ? { agentId: input.agentId } : {},
|
|
1894
|
+
...input.leaseId !== void 0 ? { leaseId: input.leaseId } : {},
|
|
1895
|
+
...input.claimedAt !== void 0 ? { claimedAt: input.claimedAt } : {},
|
|
1896
|
+
...input.heartbeatAt !== void 0 ? { heartbeatAt: input.heartbeatAt } : {},
|
|
1897
|
+
...input.leaseExpiresAt !== void 0 ? { leaseExpiresAt: input.leaseExpiresAt } : {},
|
|
1898
|
+
...input.attempt !== void 0 ? { attempt: input.attempt } : {},
|
|
1899
|
+
...input.maxAttempts !== void 0 ? { maxAttempts: input.maxAttempts } : {}
|
|
1900
|
+
},
|
|
1901
|
+
// Ownership fence: when expectedLeaseId is supplied, the write is
|
|
1902
|
+
// applied only if the current assignment still holds this lease.
|
|
1903
|
+
// This prevents a recovered+reassigned stale worker's terminal
|
|
1904
|
+
// mark_assignment from overwriting the successor's state. The check
|
|
1905
|
+
// is atomic inside updateTaskAssignment's mutateBoard lock.
|
|
1906
|
+
input.expectedLeaseId !== void 0 ? { expectedLeaseId: input.expectedLeaseId } : {}
|
|
1907
|
+
);
|
|
1908
|
+
if (!board) return fail("Task not found.");
|
|
1909
|
+
if (assignmentStatus === "completed" && board.lifecycle?.mode !== "managed") {
|
|
1910
|
+
const envGate = readEnvGateEnforcement();
|
|
1911
|
+
const finalized = await finalizeTaskCompletion(projectRoot, board.id, input.taskId, {
|
|
1912
|
+
...board.completionGate === void 0 && envGate !== void 0 ? { enforcement: envGate } : {},
|
|
1913
|
+
...ctx.agentId !== void 0 ? { eventContext: { actor: ctx.agentId } } : {}
|
|
1914
|
+
});
|
|
1915
|
+
if (finalized) {
|
|
1916
|
+
if (finalized.gate.report) {
|
|
1917
|
+
recordKanbanVerificationEvidence(ctx, finalized.gate.report);
|
|
1918
|
+
}
|
|
1919
|
+
const gateSummary = {
|
|
1920
|
+
enforcement: finalized.gate.enforcement,
|
|
1921
|
+
allowed: finalized.gate.allowed,
|
|
1922
|
+
verdict: finalized.gate.verdict,
|
|
1923
|
+
issues: finalized.gate.issues.map((issue) => issue.message)
|
|
1924
|
+
};
|
|
1925
|
+
const gateMessage = finalized.gate.allowed ? `Completion gate ${finalized.gate.verdict === "skipped" ? "skipped" : "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(" | ")}`;
|
|
1926
|
+
return {
|
|
1927
|
+
...okTask(finalized.board, finalized.task, `Assignment updated. ${gateMessage}`),
|
|
1928
|
+
gate: gateSummary
|
|
1929
|
+
};
|
|
1930
|
+
}
|
|
1931
|
+
} else if (board.lifecycle?.mode === "managed") {
|
|
1932
|
+
const managedTask = board.tasks.find((candidate) => candidate.id === input.taskId);
|
|
1933
|
+
const stage = managedTask?.lifecycle?.currentStage;
|
|
1934
|
+
const actor = ctx.agentId ?? "kanban-agent";
|
|
1935
|
+
let transitionResult = null;
|
|
1936
|
+
const lifecycleWarnings = [];
|
|
1937
|
+
if (assignmentStatus === "running" && stage === "todo") {
|
|
1938
|
+
try {
|
|
1939
|
+
transitionResult = await transitionTask(projectRoot, board.id, input.taskId, {
|
|
1940
|
+
to: "running",
|
|
1941
|
+
actor,
|
|
1942
|
+
comment: "Work started."
|
|
1943
|
+
});
|
|
1944
|
+
} catch (err) {
|
|
1945
|
+
lifecycleWarnings.push(
|
|
1946
|
+
`Lifecycle transition to Running deferred: ${err instanceof Error ? err.message : String(err)}`
|
|
1947
|
+
);
|
|
1948
|
+
}
|
|
1949
|
+
}
|
|
1950
|
+
if (assignmentStatus === "completed" && stage === "running") {
|
|
1951
|
+
const comment = typeof input.lastResult === "string" && input.lastResult.trim().length > 0 ? input.lastResult.trim().slice(0, 1e3) : "Work completed.";
|
|
1952
|
+
try {
|
|
1953
|
+
transitionResult = await transitionTask(projectRoot, board.id, input.taskId, {
|
|
1954
|
+
to: "review",
|
|
1955
|
+
actor,
|
|
1956
|
+
comment,
|
|
1957
|
+
attachment: {
|
|
1958
|
+
url: `kanban://task/${input.taskId}/result`,
|
|
1959
|
+
title: "Worker completion result",
|
|
1960
|
+
type: "file"
|
|
1961
|
+
},
|
|
1962
|
+
patch: {
|
|
1963
|
+
// Only patch non-description fields so the
|
|
1964
|
+
// original card description is preserved.
|
|
1965
|
+
...input.agentId !== void 0 ? { assignedAgent: input.agentId } : {}
|
|
1966
|
+
}
|
|
1967
|
+
});
|
|
1968
|
+
} catch (err) {
|
|
1969
|
+
lifecycleWarnings.push(
|
|
1970
|
+
`Lifecycle transition to Review failed: ${err instanceof Error ? err.message : String(err)}`
|
|
1971
|
+
);
|
|
1972
|
+
}
|
|
1973
|
+
if (transitionResult) {
|
|
1974
|
+
const hasCriteria = (transitionResult.task.successCriteria?.length ?? 0) > 0 || transitionResult.task.atomic === true;
|
|
1975
|
+
if (hasCriteria) {
|
|
1976
|
+
try {
|
|
1977
|
+
const verResult = await verifyTaskCompletion2(
|
|
1978
|
+
projectRoot,
|
|
1979
|
+
board.id,
|
|
1980
|
+
input.taskId
|
|
1981
|
+
);
|
|
1982
|
+
if (verResult.report) {
|
|
1983
|
+
recordKanbanVerificationEvidence(ctx, verResult.report);
|
|
1984
|
+
}
|
|
1985
|
+
await updateTask2(projectRoot, board.id, input.taskId, {
|
|
1986
|
+
verificationReport: verResult.report,
|
|
1987
|
+
successCriteria: verResult.task.successCriteria
|
|
1988
|
+
});
|
|
1989
|
+
const verdict = verResult.report.verdict;
|
|
1990
|
+
if (verdict === "passed") {
|
|
1991
|
+
try {
|
|
1992
|
+
const doneResult = await transitionTask(
|
|
1993
|
+
projectRoot,
|
|
1994
|
+
board.id,
|
|
1995
|
+
input.taskId,
|
|
1996
|
+
{
|
|
1997
|
+
to: "done",
|
|
1998
|
+
actor,
|
|
1999
|
+
action: "Automated acceptance after verification",
|
|
2000
|
+
comment: "Auto-accepted: verification passed.",
|
|
2001
|
+
attachment: {
|
|
2002
|
+
url: `kanban://task/${input.taskId}/verification`,
|
|
2003
|
+
title: "Auto-verification result",
|
|
2004
|
+
type: "file"
|
|
2005
|
+
}
|
|
2006
|
+
}
|
|
2007
|
+
);
|
|
2008
|
+
transitionResult = doneResult;
|
|
2009
|
+
} catch (acceptErr) {
|
|
2010
|
+
lifecycleWarnings.push(
|
|
2011
|
+
`Auto-accept to Done deferred: ${acceptErr instanceof Error ? acceptErr.message : String(acceptErr)}`
|
|
2012
|
+
);
|
|
2013
|
+
}
|
|
2014
|
+
} else {
|
|
2015
|
+
lifecycleWarnings.push(
|
|
2016
|
+
`Verification verdict: ${verdict} \u2014 card left in Review for manual acceptance.`
|
|
2017
|
+
);
|
|
2018
|
+
}
|
|
2019
|
+
} catch (verifyErr) {
|
|
2020
|
+
lifecycleWarnings.push(
|
|
2021
|
+
`Auto-verification error: ${verifyErr instanceof Error ? verifyErr.message : String(verifyErr)}`
|
|
2022
|
+
);
|
|
2023
|
+
}
|
|
2024
|
+
} else {
|
|
2025
|
+
lifecycleWarnings.push(
|
|
2026
|
+
"No automatic success criteria \u2014 card left in Review for manual verification."
|
|
2027
|
+
);
|
|
2028
|
+
}
|
|
2029
|
+
}
|
|
2030
|
+
}
|
|
2031
|
+
const responseBoard = transitionResult?.board ?? board;
|
|
2032
|
+
const responseTask = transitionResult?.task ?? managedTask;
|
|
2033
|
+
const msgParts = ["Assignment updated."];
|
|
2034
|
+
if (transitionResult) {
|
|
2035
|
+
msgParts.push(`Card advanced to ${transitionResult.transition.to}.`);
|
|
2036
|
+
}
|
|
2037
|
+
for (const w of lifecycleWarnings) msgParts.push(`Warning: ${w}`);
|
|
2038
|
+
return okTask(responseBoard, responseTask, msgParts.join(" "));
|
|
2039
|
+
}
|
|
2040
|
+
return okBoard(board, "Assignment updated.");
|
|
2041
|
+
}
|
|
2042
|
+
case "heartbeat_assignment": {
|
|
2043
|
+
if (!input.boardId || !input.taskId) {
|
|
2044
|
+
return fail("heartbeat_assignment requires boardId and taskId.");
|
|
2045
|
+
}
|
|
2046
|
+
const board = await heartbeatTaskAssignment(projectRoot, input.boardId, input.taskId, {
|
|
2047
|
+
...input.heartbeatAt !== void 0 ? { heartbeatAt: input.heartbeatAt } : {},
|
|
2048
|
+
...input.leaseExpiresAt !== void 0 ? { leaseExpiresAt: input.leaseExpiresAt } : {},
|
|
2049
|
+
// Ownership fence: when expectedLeaseId is supplied, the renewal
|
|
2050
|
+
// is applied only if the current assignment still holds this lease.
|
|
2051
|
+
// This prevents a recovered+reassigned stale worker's heartbeat
|
|
2052
|
+
// from renewing the successor's lease. The check is atomic inside
|
|
2053
|
+
// heartbeatTaskAssignment's mutateBoard lock.
|
|
2054
|
+
...input.expectedLeaseId !== void 0 ? { expectedLeaseId: input.expectedLeaseId } : {}
|
|
2055
|
+
});
|
|
2056
|
+
return board ? okBoard(board, "Assignment heartbeat updated.") : fail("Task assignment not found.");
|
|
2057
|
+
}
|
|
2058
|
+
case "recover_stale": {
|
|
2059
|
+
if (!input.boardId) return fail("recover_stale requires boardId.");
|
|
2060
|
+
const policyFields = [
|
|
2061
|
+
input.recoveryPolicyFailOnCostCeiling !== void 0,
|
|
2062
|
+
input.recoveryPolicyReleaseOnFailureKinds !== void 0,
|
|
2063
|
+
input.recoveryPolicyReleaseOnHeartbeatDue !== void 0,
|
|
2064
|
+
input.recoveryPolicyRetryPolicyOverride !== void 0
|
|
2065
|
+
].some(Boolean);
|
|
2066
|
+
const result2 = await recoverStaleTaskAssignments(projectRoot, input.boardId, {
|
|
2067
|
+
...input.recoveryMode !== void 0 ? { mode: input.recoveryMode } : {},
|
|
2068
|
+
...input.recoveryNow !== void 0 ? { now: input.recoveryNow } : {},
|
|
2069
|
+
...input.releaseReason !== void 0 ? { reason: input.releaseReason } : {},
|
|
2070
|
+
...input.clearAssignee !== void 0 ? { clearAssignee: input.clearAssignee } : {},
|
|
2071
|
+
...policyFields ? {
|
|
2072
|
+
policy: {
|
|
2073
|
+
...input.recoveryPolicyFailOnCostCeiling !== void 0 ? { failWhenCostCeilingSet: input.recoveryPolicyFailOnCostCeiling } : {},
|
|
2074
|
+
...input.recoveryPolicyReleaseOnFailureKinds !== void 0 ? {
|
|
2075
|
+
releaseOnFailureKinds: input.recoveryPolicyReleaseOnFailureKinds
|
|
2076
|
+
} : {},
|
|
2077
|
+
...input.recoveryPolicyReleaseOnHeartbeatDue !== void 0 ? {
|
|
2078
|
+
releaseOnHeartbeatDue: input.recoveryPolicyReleaseOnHeartbeatDue
|
|
2079
|
+
} : {},
|
|
2080
|
+
...input.recoveryPolicyRetryPolicyOverride !== void 0 ? {
|
|
2081
|
+
retryPolicyOverride: input.recoveryPolicyRetryPolicyOverride
|
|
2082
|
+
} : {}
|
|
2083
|
+
}
|
|
2084
|
+
} : {}
|
|
2085
|
+
});
|
|
2086
|
+
return result2 ? {
|
|
2087
|
+
ok: true,
|
|
2088
|
+
message: `Recovered ${result2.tasks.length} stale assignment(s).`,
|
|
2089
|
+
board: result2.board,
|
|
2090
|
+
recoveredTasks: result2.tasks
|
|
2091
|
+
} : { ok: true, message: "No stale assignment matched.", recoveredTasks: [] };
|
|
2092
|
+
}
|
|
2093
|
+
case "events": {
|
|
2094
|
+
if (!input.boardId) return fail("events requires boardId.");
|
|
2095
|
+
const eventList = await listKanbanEvents(projectRoot, input.boardId);
|
|
2096
|
+
return {
|
|
2097
|
+
ok: true,
|
|
2098
|
+
message: `${eventList.length} event(s).`,
|
|
2099
|
+
events: eventList
|
|
2100
|
+
};
|
|
2101
|
+
}
|
|
2102
|
+
case "queue_health": {
|
|
2103
|
+
const health = await getKanbanQueueHealth(projectRoot, {
|
|
2104
|
+
...input.boardId !== void 0 ? { boardId: input.boardId } : {}
|
|
2105
|
+
});
|
|
2106
|
+
return {
|
|
2107
|
+
ok: true,
|
|
2108
|
+
message: `Counts: ready=${health.counts.ready}, running=${health.counts.running}, stale=${health.staleAssignments.count}.`,
|
|
2109
|
+
queueHealth: health
|
|
2110
|
+
};
|
|
2111
|
+
}
|
|
2112
|
+
default:
|
|
2113
|
+
{
|
|
2114
|
+
const detailResult = await handleKanbanDetailAction(projectRoot, input);
|
|
2115
|
+
if (detailResult !== void 0) return detailResult;
|
|
2116
|
+
}
|
|
2117
|
+
return fail(`Unknown kanban action: ${input.action}`);
|
|
2118
|
+
}
|
|
2119
|
+
})();
|
|
2120
|
+
return withPresence(result);
|
|
2121
|
+
} catch (err) {
|
|
2122
|
+
return fail(err instanceof Error ? err.message : String(err));
|
|
2123
|
+
}
|
|
2124
|
+
}
|
|
2125
|
+
};
|
|
193
2126
|
|
|
194
2127
|
// src/todo.ts
|
|
2128
|
+
function normalizedTitle(value) {
|
|
2129
|
+
return value.trim().toLocaleLowerCase().replace(/\s+/g, " ");
|
|
2130
|
+
}
|
|
2131
|
+
function activeBoardId(items, ctx) {
|
|
2132
|
+
const metaKanban = ctx.meta?.["kanban"];
|
|
2133
|
+
const metaBoardId = metaKanban && typeof metaKanban === "object" ? metaKanban["boardId"] : void 0;
|
|
2134
|
+
return ctx.currentKanbanBoardId ?? (typeof metaBoardId === "string" ? metaBoardId : void 0) ?? items.find((item) => item.kanbanBoardId)?.kanbanBoardId ?? "";
|
|
2135
|
+
}
|
|
2136
|
+
function bindTodosToBoard(items, previous, board) {
|
|
2137
|
+
const previousById = new Map(previous.map((item) => [item.id, item]));
|
|
2138
|
+
const available = board.tasks.filter(
|
|
2139
|
+
(task) => task.status !== "archived" && task.mergedIntoTaskId === void 0 && (!task.childTaskIds || task.childTaskIds.length === 0)
|
|
2140
|
+
).sort(
|
|
2141
|
+
(left, right) => left.createdAt.localeCompare(right.createdAt) || left.order - right.order
|
|
2142
|
+
);
|
|
2143
|
+
const used = /* @__PURE__ */ new Set();
|
|
2144
|
+
return items.map((item) => {
|
|
2145
|
+
const previousItem = previousById.get(item.id);
|
|
2146
|
+
const requestedTaskId = item.kanbanBoardId === board.id ? item.kanbanTaskId : previousItem?.kanbanBoardId === board.id ? previousItem.kanbanTaskId : void 0;
|
|
2147
|
+
const title = normalizedTitle(item.content);
|
|
2148
|
+
const candidates = [
|
|
2149
|
+
requestedTaskId ? board.tasks.find((task2) => task2.id === requestedTaskId) : void 0,
|
|
2150
|
+
board.tasks.find((task2) => task2.id === item.id),
|
|
2151
|
+
board.tasks.find((task2) => task2.origin?.taskId === item.id),
|
|
2152
|
+
available.find((task2) => !used.has(task2.id) && normalizedTitle(task2.title) === title)
|
|
2153
|
+
];
|
|
2154
|
+
const task = candidates.find((candidate) => candidate && !used.has(candidate.id));
|
|
2155
|
+
if (!task) return { ...item };
|
|
2156
|
+
used.add(task.id);
|
|
2157
|
+
return { ...item, kanbanBoardId: board.id, kanbanTaskId: task.id };
|
|
2158
|
+
});
|
|
2159
|
+
}
|
|
2160
|
+
async function synchronizeManagedKanban(items, board, ctx, signal) {
|
|
2161
|
+
let synced = 0;
|
|
2162
|
+
const warnings = [];
|
|
2163
|
+
const actor = ctx.agentId?.trim() || ctx.agentName?.trim() || "kanban-agent";
|
|
2164
|
+
const execute = async (input) => {
|
|
2165
|
+
const result = await kanbanTool.execute(input, ctx, { signal });
|
|
2166
|
+
if (!result.ok) warnings.push(result.message);
|
|
2167
|
+
else {
|
|
2168
|
+
synced++;
|
|
2169
|
+
if (result.message.includes("Warning:")) warnings.push(result.message);
|
|
2170
|
+
}
|
|
2171
|
+
return result;
|
|
2172
|
+
};
|
|
2173
|
+
for (const item of items) {
|
|
2174
|
+
if (item.status !== "pending" || item.kanbanBoardId !== board.id || !item.kanbanTaskId) {
|
|
2175
|
+
continue;
|
|
2176
|
+
}
|
|
2177
|
+
const task = board.tasks.find((candidate) => candidate.id === item.kanbanTaskId);
|
|
2178
|
+
if (task?.lifecycle?.currentStage !== "running") continue;
|
|
2179
|
+
const released = await execute({
|
|
2180
|
+
action: "mark_assignment",
|
|
2181
|
+
boardId: board.id,
|
|
2182
|
+
taskId: task.id,
|
|
2183
|
+
assignmentStatus: "assigned",
|
|
2184
|
+
agentId: actor,
|
|
2185
|
+
lastResult: `Todo returned to queue: ${item.content}`
|
|
2186
|
+
});
|
|
2187
|
+
if (!released.ok) continue;
|
|
2188
|
+
await execute({
|
|
2189
|
+
action: "transition_task",
|
|
2190
|
+
boardId: board.id,
|
|
2191
|
+
taskId: task.id,
|
|
2192
|
+
lifecycleStage: "todo",
|
|
2193
|
+
author: actor,
|
|
2194
|
+
transitionComment: `Todo returned to queue: ${item.content}`
|
|
2195
|
+
});
|
|
2196
|
+
}
|
|
2197
|
+
for (const item of items) {
|
|
2198
|
+
if (item.status !== "completed" || item.kanbanBoardId !== board.id || !item.kanbanTaskId) {
|
|
2199
|
+
continue;
|
|
2200
|
+
}
|
|
2201
|
+
const task = board.tasks.find((candidate) => candidate.id === item.kanbanTaskId);
|
|
2202
|
+
if (!task || task.status === "completed") continue;
|
|
2203
|
+
await execute({
|
|
2204
|
+
action: "mark_assignment",
|
|
2205
|
+
boardId: board.id,
|
|
2206
|
+
taskId: task.id,
|
|
2207
|
+
assignmentStatus: "completed",
|
|
2208
|
+
agentId: actor,
|
|
2209
|
+
lastResult: `Todo completed: ${item.content}`
|
|
2210
|
+
});
|
|
2211
|
+
}
|
|
2212
|
+
const attemptedParents = /* @__PURE__ */ new Set();
|
|
2213
|
+
let afterCompletions = await getBoard4(ctx.projectRoot, board.id);
|
|
2214
|
+
while (afterCompletions) {
|
|
2215
|
+
const parent = afterCompletions.tasks.find(
|
|
2216
|
+
(task) => task.atomic === true && task.status !== "completed" && Boolean(task.childTaskIds?.length) && !attemptedParents.has(task.id) && task.childTaskIds?.every(
|
|
2217
|
+
(childId) => afterCompletions?.tasks.find((candidate) => candidate.id === childId)?.status === "completed"
|
|
2218
|
+
)
|
|
2219
|
+
);
|
|
2220
|
+
if (!parent) break;
|
|
2221
|
+
attemptedParents.add(parent.id);
|
|
2222
|
+
const started = await execute({
|
|
2223
|
+
action: "start_task",
|
|
2224
|
+
boardId: board.id,
|
|
2225
|
+
taskId: parent.id,
|
|
2226
|
+
author: actor,
|
|
2227
|
+
agentId: actor,
|
|
2228
|
+
transitionComment: "All child tasks completed; validating composite parent."
|
|
2229
|
+
});
|
|
2230
|
+
if (started.ok) {
|
|
2231
|
+
await execute({
|
|
2232
|
+
action: "mark_assignment",
|
|
2233
|
+
boardId: board.id,
|
|
2234
|
+
taskId: parent.id,
|
|
2235
|
+
assignmentStatus: "completed",
|
|
2236
|
+
agentId: actor,
|
|
2237
|
+
lastResult: "All child tasks completed; composite result ready for verification."
|
|
2238
|
+
});
|
|
2239
|
+
}
|
|
2240
|
+
afterCompletions = await getBoard4(ctx.projectRoot, board.id);
|
|
2241
|
+
}
|
|
2242
|
+
const completionPending = items.some(
|
|
2243
|
+
(item) => item.status === "completed" && item.kanbanBoardId === board.id && Boolean(item.kanbanTaskId) && afterCompletions?.tasks.find((task) => task.id === item.kanbanTaskId)?.status !== "completed"
|
|
2244
|
+
);
|
|
2245
|
+
const active = items.find(
|
|
2246
|
+
(item) => item.status === "in_progress" && item.kanbanBoardId === board.id && Boolean(item.kanbanTaskId)
|
|
2247
|
+
);
|
|
2248
|
+
if (active?.kanbanTaskId) {
|
|
2249
|
+
await execute({
|
|
2250
|
+
action: "start_task",
|
|
2251
|
+
boardId: board.id,
|
|
2252
|
+
taskId: active.kanbanTaskId,
|
|
2253
|
+
author: actor,
|
|
2254
|
+
agentId: actor,
|
|
2255
|
+
transitionComment: `Todo activated: ${active.content}`
|
|
2256
|
+
});
|
|
2257
|
+
}
|
|
2258
|
+
if (active?.kanbanTaskId && completionPending) {
|
|
2259
|
+
warnings.push(
|
|
2260
|
+
"A completed todo is still awaiting acceptance; the next independent Kanban task was started."
|
|
2261
|
+
);
|
|
2262
|
+
} else if (!active && ctx.currentKanbanBoardId === board.id) {
|
|
2263
|
+
ctx.setCurrentKanbanTask(void 0, board.id);
|
|
2264
|
+
}
|
|
2265
|
+
return { synced, warnings };
|
|
2266
|
+
}
|
|
195
2267
|
var todoTool = {
|
|
196
2268
|
name: "todo",
|
|
197
2269
|
category: "Session",
|
|
198
|
-
description: "Manage the
|
|
199
|
-
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
|
|
200
|
-
permission: "
|
|
201
|
-
mutating:
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
2270
|
+
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.",
|
|
2271
|
+
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.",
|
|
2272
|
+
permission: "confirm",
|
|
2273
|
+
mutating: true,
|
|
2274
|
+
timeoutMs: 3e4,
|
|
2275
|
+
capabilities: ["session.todo", "fs.write"],
|
|
2276
|
+
subjectKey: "todos",
|
|
205
2277
|
icon: "todo",
|
|
206
2278
|
inputSchema: {
|
|
207
2279
|
type: "object",
|
|
@@ -227,20 +2299,38 @@ var todoTool = {
|
|
|
227
2299
|
activeForm: {
|
|
228
2300
|
type: "string",
|
|
229
2301
|
description: 'Optional present-tense form shown while the task is active (e.g. "Fixing auth bug").'
|
|
2302
|
+
},
|
|
2303
|
+
kanbanBoardId: {
|
|
2304
|
+
type: "string",
|
|
2305
|
+
description: "Kanban board that owns this UI row when Kanban is active."
|
|
2306
|
+
},
|
|
2307
|
+
kanbanTaskId: {
|
|
2308
|
+
type: "string",
|
|
2309
|
+
description: "Real Kanban task represented by this UI row."
|
|
230
2310
|
}
|
|
231
2311
|
},
|
|
232
2312
|
required: ["id", "content", "status"]
|
|
233
2313
|
},
|
|
234
|
-
description: "The
|
|
2314
|
+
description: "The desired todo list. Supplied rows are replaced/reordered; unfinished omitted rows are retained."
|
|
235
2315
|
}
|
|
236
2316
|
},
|
|
237
2317
|
required: ["todos"]
|
|
238
2318
|
},
|
|
239
|
-
async execute(input, ctx) {
|
|
2319
|
+
async execute(input, ctx, call) {
|
|
240
2320
|
if (!Array.isArray(input?.todos)) {
|
|
241
2321
|
throw new Error("todo: todos must be an array");
|
|
242
2322
|
}
|
|
243
2323
|
const items = input.todos.filter((t) => Boolean(t?.id && t.content));
|
|
2324
|
+
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}`;
|
|
2325
|
+
const requestedIdentities = new Set(items.map(todoIdentity));
|
|
2326
|
+
for (const previous of ctx.todos ?? []) {
|
|
2327
|
+
const identity = todoIdentity(previous);
|
|
2328
|
+
if (previous.status === "completed" || requestedIdentities.has(identity)) {
|
|
2329
|
+
continue;
|
|
2330
|
+
}
|
|
2331
|
+
items.push({ ...previous });
|
|
2332
|
+
requestedIdentities.add(identity);
|
|
2333
|
+
}
|
|
244
2334
|
const inProgress = items.filter((t) => t.status === "in_progress");
|
|
245
2335
|
if (inProgress.length > 1) {
|
|
246
2336
|
let seenInProgress = false;
|
|
@@ -251,8 +2341,32 @@ var todoTool = {
|
|
|
251
2341
|
}
|
|
252
2342
|
}
|
|
253
2343
|
}
|
|
254
|
-
|
|
255
|
-
|
|
2344
|
+
const boardId = activeBoardId(items, ctx);
|
|
2345
|
+
const board = boardId ? await getBoard4(ctx.projectRoot, boardId) : null;
|
|
2346
|
+
const boundItems = board?.lifecycle?.mode === "managed" ? bindTodosToBoard(items, ctx.todos ?? [], board) : items;
|
|
2347
|
+
ctx.state.replaceTodos(boundItems);
|
|
2348
|
+
const kanbanSync = board?.lifecycle?.mode === "managed" ? await synchronizeManagedKanban(boundItems, board, ctx, call.signal) : { synced: 0, warnings: [] };
|
|
2349
|
+
if (board?.lifecycle?.mode === "managed") {
|
|
2350
|
+
const unresolved = boundItems.filter(
|
|
2351
|
+
(item) => item.kanbanBoardId !== board.id || !item.kanbanTaskId
|
|
2352
|
+
);
|
|
2353
|
+
if (unresolved.length > 0) {
|
|
2354
|
+
kanbanSync.warnings.push(
|
|
2355
|
+
`${unresolved.length} Todo row(s) did not match a real Kanban task and were not applied. Preserve kanbanBoardId/kanbanTaskId when updating the projection.`
|
|
2356
|
+
);
|
|
2357
|
+
}
|
|
2358
|
+
}
|
|
2359
|
+
let projectedBoard = board;
|
|
2360
|
+
if (board?.lifecycle?.mode === "managed") {
|
|
2361
|
+
const refreshed = await getBoard4(ctx.projectRoot, board.id);
|
|
2362
|
+
if (refreshed) {
|
|
2363
|
+
projectedBoard = refreshed;
|
|
2364
|
+
applyManagedKanbanBoardToTodos(ctx, refreshed);
|
|
2365
|
+
}
|
|
2366
|
+
}
|
|
2367
|
+
if (board?.lifecycle?.mode !== "managed") {
|
|
2368
|
+
mirrorSessionTodosToKanban(ctx.projectRoot, items, ctx.session?.id ?? "session");
|
|
2369
|
+
}
|
|
256
2370
|
const completedPlanIds = /* @__PURE__ */ new Set();
|
|
257
2371
|
const completedTaskIds = /* @__PURE__ */ new Set();
|
|
258
2372
|
const pendingPlanIds = /* @__PURE__ */ new Set();
|
|
@@ -287,7 +2401,7 @@ var todoTool = {
|
|
|
287
2401
|
const taskPath = ctx.meta["task.path"];
|
|
288
2402
|
if (typeof taskPath !== "string" || !taskPath) continue;
|
|
289
2403
|
try {
|
|
290
|
-
const file = await
|
|
2404
|
+
const file = await loadTasks3(taskPath);
|
|
291
2405
|
if (file) {
|
|
292
2406
|
const task = file.tasks.find((t) => t.id === taskId);
|
|
293
2407
|
if (task && task.status !== "completed") {
|
|
@@ -301,7 +2415,25 @@ var todoTool = {
|
|
|
301
2415
|
}
|
|
302
2416
|
return {
|
|
303
2417
|
count: items.length,
|
|
304
|
-
in_progress:
|
|
2418
|
+
in_progress: (ctx.todos ?? boundItems).filter((t) => t.status === "in_progress").length,
|
|
2419
|
+
...kanbanSync.synced > 0 ? { kanban_synced: kanbanSync.synced } : {},
|
|
2420
|
+
...kanbanSync.warnings.length > 0 ? { kanban_warnings: kanbanSync.warnings } : {},
|
|
2421
|
+
...projectedBoard?.lifecycle?.mode === "managed" ? {
|
|
2422
|
+
kanban_bindings: boundItems.flatMap((item) => {
|
|
2423
|
+
if (item.kanbanBoardId !== projectedBoard.id || !item.kanbanTaskId) return [];
|
|
2424
|
+
const task = projectedBoard.tasks.find(
|
|
2425
|
+
(candidate) => candidate.id === item.kanbanTaskId
|
|
2426
|
+
);
|
|
2427
|
+
return task ? [
|
|
2428
|
+
{
|
|
2429
|
+
todoId: item.id,
|
|
2430
|
+
boardId: projectedBoard.id,
|
|
2431
|
+
taskId: task.id,
|
|
2432
|
+
taskStatus: task.status
|
|
2433
|
+
}
|
|
2434
|
+
] : [];
|
|
2435
|
+
})
|
|
2436
|
+
} : {}
|
|
305
2437
|
};
|
|
306
2438
|
}
|
|
307
2439
|
};
|