@wrongstack/tools 0.309.1 → 0.310.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.
Files changed (57) hide show
  1. package/dist/_regex.d.ts +6 -34
  2. package/dist/bash.js +3 -3
  3. package/dist/builtin.js +3011 -1677
  4. package/dist/codebase-index/binary-frame.d.ts +57 -8
  5. package/dist/codebase-index/codebase-incoming-calls-tool.d.ts +6 -0
  6. package/dist/codebase-index/codebase-outgoing-calls-tool.d.ts +6 -0
  7. package/dist/codebase-index/codebase-search-tool.d.ts +15 -5
  8. package/dist/codebase-index/index-service.d.ts +3 -19
  9. package/dist/codebase-index/index.js +2735 -1415
  10. package/dist/codebase-index/indexer.d.ts +3 -0
  11. package/dist/codebase-index/parser-batch.d.ts +53 -0
  12. package/dist/codebase-index/parser-dispatch.d.ts +32 -0
  13. package/dist/codebase-index/parser-output.d.ts +14 -0
  14. package/dist/codebase-index/parser-worker-pool.d.ts +57 -4
  15. package/dist/codebase-index/parser-worker-script.d.ts +5 -2
  16. package/dist/codebase-index/parser-worker-script.js +4042 -0
  17. package/dist/codebase-index/project-server-cache.d.ts +16 -0
  18. package/dist/codebase-index/project-server-client.d.ts +2 -2
  19. package/dist/codebase-index/project-server-query-cache.d.ts +88 -0
  20. package/dist/codebase-index/project-server.js +2846 -1308
  21. package/dist/codebase-index/py-parser.d.ts +5 -0
  22. package/dist/codebase-index/schema.d.ts +14 -1
  23. package/dist/codebase-index/sqlite-runtime.d.ts +2 -2
  24. package/dist/codebase-index/tree-sitter/queries.d.ts +30 -3
  25. package/dist/codebase-index/tree-sitter/visitor.d.ts +2 -1
  26. package/dist/codebase-index/vector-search.d.ts +12 -0
  27. package/dist/codebase-index/wal-maintenance.d.ts +58 -0
  28. package/dist/codebase-index/worker-protocol/contracts.d.ts +44 -0
  29. package/dist/codebase-index/worker-protocol.d.ts +17 -1
  30. package/dist/codebase-index/worker.js +2300 -1020
  31. package/dist/codebase-index/writer-admin.d.ts +11 -0
  32. package/dist/codebase-index/writer-helpers.d.ts +31 -1
  33. package/dist/codebase-index/writer-mutations.d.ts +0 -6
  34. package/dist/codebase-index/writer-schema.d.ts +2 -2
  35. package/dist/codebase-index/writer.d.ts +15 -0
  36. package/dist/edit.js +2511 -1203
  37. package/dist/exec.js +5 -3
  38. package/dist/grep.js +5 -124
  39. package/dist/index.js +3007 -1736
  40. package/dist/json.js +5 -124
  41. package/dist/kanban.js +130 -0
  42. package/dist/logs.js +5 -121
  43. package/dist/pack.js +3011 -1677
  44. package/dist/patch.js +2524 -1216
  45. package/dist/plan.js +106 -0
  46. package/dist/read.js +2506 -1198
  47. package/dist/replace.js +2487 -1295
  48. package/dist/search.js +6 -2
  49. package/dist/session-kanban.js +24 -16
  50. package/dist/task.js +106 -0
  51. package/dist/todo.js +106 -0
  52. package/dist/tool-tier.d.ts +11 -0
  53. package/dist/tool-tier.js +3019 -1677
  54. package/dist/tree.js +14 -3
  55. package/dist/win32.js +3 -3
  56. package/dist/write.js +2513 -1205
  57. package/package.json +5 -4
package/dist/plan.js CHANGED
@@ -274,6 +274,81 @@ function applyManagedKanbanBoardToTodos(context, board, suppressedTodoMirrors2,
274
274
  broadcastTodoUpdate(context, context.todos);
275
275
  return [...context.todos];
276
276
  }
277
+ async function applySessionKanbanTaskToSource(context, task, suppressedTodoMirrors2, options = {}) {
278
+ const originId = task.origin?.taskId;
279
+ const graphId = task.origin?.graphId ?? "";
280
+ const isTodoOrigin = task.origin?.system === "session-todo" || graphId.startsWith("todo:");
281
+ const targetTodo = context.todos?.find(
282
+ (todo) => originId !== void 0 && todo.id === originId || todo.kanbanTaskId === task.id || todo.id === task.id && !todo.promotedFromPlan && !todo.promotedFromTask
283
+ );
284
+ if (isTodoOrigin || targetTodo) {
285
+ const matchedId = targetTodo?.id ?? originId;
286
+ if (matchedId) {
287
+ const mappedStatus = todoStatus(task);
288
+ const next = options.remove ? context.todos.filter((todo) => todo.id !== matchedId) : context.todos.map(
289
+ (todo) => todo.id === matchedId ? {
290
+ ...todo,
291
+ content: task.title,
292
+ status: mappedStatus,
293
+ kanbanTaskId: task.id
294
+ } : todo
295
+ );
296
+ suppressedTodoMirrors2.add(context);
297
+ try {
298
+ context.state.replaceTodos(next);
299
+ } finally {
300
+ suppressedTodoMirrors2.delete(context);
301
+ }
302
+ return { source: "todo", todos: [...context.todos] };
303
+ }
304
+ }
305
+ if (!originId) return { source: null };
306
+ const id = context.session?.id ?? "";
307
+ if (task.origin?.system === "session-plan" || graphId.startsWith("plan:")) {
308
+ const planPath = context.meta["plan.path"];
309
+ if (typeof planPath !== "string" || !planPath) {
310
+ throw new Error(
311
+ "Cannot reflect this Kanban edit back to its plan source: the session has no plan.path configured. The board mutation already succeeded; the plan file is now out of sync."
312
+ );
313
+ }
314
+ const plan = await mutatePlan(planPath, id, (file) => ({
315
+ ...file,
316
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
317
+ items: options.remove ? file.items.filter((item) => item.id !== originId) : file.items.map(
318
+ (item) => item.id === originId ? {
319
+ ...item,
320
+ title: task.title,
321
+ details: task.description,
322
+ status: task.status === "completed" ? "done" : task.status === "in_progress" || task.status === "review" ? "in_progress" : "open",
323
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
324
+ } : item
325
+ )
326
+ }));
327
+ return { source: "plan", plan };
328
+ }
329
+ if (task.origin?.system === "session-task" || task.origin?.system === "session" || graphId.startsWith("session:")) {
330
+ const taskPath = context.meta["task.path"];
331
+ if (typeof taskPath !== "string" || !taskPath) {
332
+ throw new Error(
333
+ "Cannot reflect this Kanban edit back to its task source: the session has no task.path configured. The board mutation already succeeded; the task file is now out of sync."
334
+ );
335
+ }
336
+ const tasks = await mutateTasks(taskPath, id, (file) => ({
337
+ ...file,
338
+ tasks: options.remove ? file.tasks.filter((item) => item.id !== originId) : file.tasks.map(
339
+ (item) => item.id === originId ? {
340
+ ...item,
341
+ title: task.title,
342
+ description: task.description,
343
+ status: sourceStatus(task),
344
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
345
+ } : item
346
+ )
347
+ }));
348
+ return { source: "task", tasks };
349
+ }
350
+ return { source: null };
351
+ }
277
352
 
278
353
  // src/session-kanban.ts
279
354
  var SESSION_BOARD_TAG = "session-work";
@@ -517,6 +592,9 @@ function applyManagedKanbanBoardToTodos2(context, board) {
517
592
  sessionOwnerFromTags: sessionIdFromTags
518
593
  });
519
594
  }
595
+ function applySessionKanbanTaskToSource2(context, task, options = {}) {
596
+ return applySessionKanbanTaskToSource(context, task, suppressedTodoMirrors, options);
597
+ }
520
598
 
521
599
  // src/todo.ts
522
600
  import {
@@ -1493,12 +1571,20 @@ function assignmentForTaskCreate(input) {
1493
1571
  }
1494
1572
 
1495
1573
  // src/kanban-lifecycle-actions.ts
1574
+ async function syncContextTask(ctx, task, options = {}) {
1575
+ if (!ctx?.state || !task) return;
1576
+ try {
1577
+ await applySessionKanbanTaskToSource2(ctx, task, options);
1578
+ } catch {
1579
+ }
1580
+ }
1496
1581
  async function handleKanbanLifecycleAction(projectRoot, input, ctx) {
1497
1582
  switch (input.action) {
1498
1583
  case "add_task": {
1499
1584
  if (!input.boardId || !input.title) return fail("add_task requires boardId and title.");
1500
1585
  const result = await addTask2(projectRoot, input.boardId, taskInput(input));
1501
1586
  if (!result) return fail("Board not found.");
1587
+ await syncContextTask(ctx, result.task);
1502
1588
  return okTask(result.board, result.task, `Task added.${atomicityNudge(result.task)}`);
1503
1589
  }
1504
1590
  case "split_task": {
@@ -1643,6 +1729,7 @@ async function handleKanbanLifecycleAction(projectRoot, input, ctx) {
1643
1729
  );
1644
1730
  }
1645
1731
  ctx.setCurrentKanbanTask(task.id, board.id);
1732
+ await syncContextTask(ctx, task);
1646
1733
  return okTask(
1647
1734
  board,
1648
1735
  task,
@@ -1652,6 +1739,9 @@ async function handleKanbanLifecycleAction(projectRoot, input, ctx) {
1652
1739
  case "update_task": {
1653
1740
  if (!input.boardId || !input.taskId) return fail("update_task requires boardId and taskId.");
1654
1741
  const board = await updateTask2(projectRoot, input.boardId, input.taskId, taskPatch(input));
1742
+ if (board) {
1743
+ await syncContextTask(ctx, board.tasks.find((t) => t.id === input.taskId));
1744
+ }
1655
1745
  return board ? okBoard(board, "Task updated.") : fail("Task not found.");
1656
1746
  }
1657
1747
  case "transition_task": {
@@ -1691,6 +1781,9 @@ async function handleKanbanLifecycleAction(projectRoot, input, ctx) {
1691
1781
  if (result && input.lifecycleStage === "done" && result.task.verificationReport) {
1692
1782
  recordKanbanVerificationEvidence(ctx, result.task.verificationReport);
1693
1783
  }
1784
+ if (result?.task) {
1785
+ await syncContextTask(ctx, result.task);
1786
+ }
1694
1787
  return result ? okTask(result.board, result.task, `Task advanced to ${result.transition.to}.`) : fail("Board or task not found.");
1695
1788
  }
1696
1789
  case "repair_managed_projection": {
@@ -1703,6 +1796,9 @@ async function handleKanbanLifecycleAction(projectRoot, input, ctx) {
1703
1796
  actor: input.author,
1704
1797
  comment: input.transitionComment
1705
1798
  });
1799
+ if (result?.task) {
1800
+ await syncContextTask(ctx, result.task);
1801
+ }
1706
1802
  return result ? okTask(
1707
1803
  result.board,
1708
1804
  result.task,
@@ -1720,14 +1816,22 @@ async function handleKanbanLifecycleAction(projectRoot, input, ctx) {
1720
1816
  input.targetColumnId,
1721
1817
  input.order
1722
1818
  );
1819
+ if (board) {
1820
+ await syncContextTask(ctx, board.tasks.find((t) => t.id === input.taskId));
1821
+ }
1723
1822
  return board ? okBoard(board, "Task moved.") : fail("Move failed.");
1724
1823
  }
1725
1824
  case "delete_task": {
1726
1825
  if (!input.boardId || !input.taskId) return fail("delete_task requires boardId and taskId.");
1826
+ const boardBefore = await getBoard4(projectRoot, input.boardId);
1827
+ const taskToDelete = boardBefore?.tasks.find((t) => t.id === input.taskId);
1727
1828
  const board = await removeTask(projectRoot, input.boardId, input.taskId);
1728
1829
  if (board && ctx.currentKanbanTaskId === input.taskId) {
1729
1830
  ctx.setCurrentKanbanTask?.(void 0, ctx.currentKanbanBoardId);
1730
1831
  }
1832
+ if (board && taskToDelete) {
1833
+ await syncContextTask(ctx, taskToDelete, { remove: true });
1834
+ }
1731
1835
  return board ? okBoard(board, "Task deleted.") : fail("Task not found.");
1732
1836
  }
1733
1837
  case "set_chain": {
@@ -1834,6 +1938,7 @@ async function handleKanbanLifecycleAction(projectRoot, input, ctx) {
1834
1938
  issues: finalized.gate.issues.map((issue) => issue.message)
1835
1939
  };
1836
1940
  const gateMessage = finalized.gate.allowed ? `Completion gate ${finalized.gate.verdict === "skipped" ? "passed" : "passed"}; task completed.` : finalized.gate.enforcement === "strict" ? `Completion gate BLOCKED (verdict: ${finalized.gate.verdict}); task parked in review. Issues: ${gateSummary.issues.join(" | ")}` : `Completion gate failed softly (verdict: ${finalized.gate.verdict}); task completed with warnings. Issues: ${gateSummary.issues.join(" | ")}`;
1941
+ await syncContextTask(ctx, finalized.task);
1837
1942
  return {
1838
1943
  ...okTask(finalized.board, finalized.task, `Assignment updated. ${gateMessage}`),
1839
1944
  gate: gateSummary
@@ -1939,6 +2044,7 @@ async function handleKanbanLifecycleAction(projectRoot, input, ctx) {
1939
2044
  msgParts.push(`Card advanced to ${transitionResult.transition.to}.`);
1940
2045
  }
1941
2046
  for (const w of lifecycleWarnings) msgParts.push(`Warning: ${w}`);
2047
+ await syncContextTask(ctx, responseTask);
1942
2048
  return okTask(responseBoard, responseTask, msgParts.join(" "));
1943
2049
  }
1944
2050
  return okBoard(board, "Assignment updated.");