@alpacachen/dsh-kanban 1.7.0 → 1.9.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/index.js CHANGED
@@ -7,14 +7,15 @@
7
7
  * Responsibilities:
8
8
  * - Workspace isolation: boards are keyed by workspaceId, one board per workspace.
9
9
  * - Persistence: ctx.fs writes <workspace.path>/.dsh-kanban.json.
10
- * - Agent tools: ctx.tools.register exposes 15 kanban_* tools.
10
+ * - Agent tools: ctx.tools.register exposes 16 kanban_* tools.
11
11
  * - Browser API: ctx.get('connection') registers the authenticated /api/kanban route.
12
12
  *
13
13
  * Per-workspace data model (disk files include schemaVersion):
14
- * schemaVersion: 3
14
+ * schemaVersion: 5
15
+ * completedColumnId: string | null
15
16
  * columns: [{ id, title }]
16
17
  * labels: [{ name, color }] // name is the unique key and binds the color
17
- * cards: [{ id, columnId, title, note, label, priority, createdAt, createdBy,
18
+ * cards: [{ id, columnId, title, note, label, priority, dueDate, completedAt, createdAt, createdBy,
18
19
  * comments: [{ id, content, source, createdAt }] }]
19
20
  * activities: [{ id, ts, cardId, type, source, field?, from?, to?, meta? }] // append-only log
20
21
  *
@@ -45,7 +46,7 @@ export const inject = ['tools']
45
46
  // Back up old files before following the migration chain on first access.
46
47
  // ---------------------------------------------------------------------------
47
48
 
48
- export const SCHEMA_VERSION = 3
49
+ export const SCHEMA_VERSION = 5
49
50
  export const LEGACY_VERSION = 0
50
51
 
51
52
  // Append-only activity log persisted with the board; drop oldest events above the limit.
@@ -64,6 +65,15 @@ const isObj = (v) => typeof v === 'object' && v !== null && !Array.isArray(v)
64
65
  const strField = (v, fb) => (typeof v === 'string' && v ? v : fb)
65
66
  const normColor = (v) => (typeof v === 'string' && /^#[0-9a-fA-F]{6}$/.test(v) ? v.toLowerCase() : '#94a3b8')
66
67
 
68
+ // Calendar dates stay date-only; parsing them as timestamps can shift the day by timezone.
69
+ const isDueDate = (value) => {
70
+ if (typeof value !== 'string' || !/^\d{4}-\d{2}-\d{2}$/.test(value)) return false
71
+ const [year, month, day] = value.split('-').map(Number)
72
+ if (year < 1 || month < 1 || month > 12 || day < 1) return false
73
+ const leapYear = year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0)
74
+ return day <= [31, leapYear ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month - 1]
75
+ }
76
+
67
77
  // Canonical v1 entity shapes: fill missing defaults without changing valid data.
68
78
  const normColumn = (c) =>
69
79
  isObj(c) ? { id: strField(c.id, ''), title: strField(c.title, 'Untitled') } : null
@@ -128,6 +138,19 @@ export const MIGRATIONS = {
128
138
  activities: pick(src.activities),
129
139
  }
130
140
  },
141
+ 3: (data) => ({
142
+ ...data,
143
+ schemaVersion: 4,
144
+ // Existing boards choose completion explicitly; titles and positions are customizable.
145
+ completedColumnId: null,
146
+ cards: Array.isArray(data.cards) ? data.cards.map((card) => isObj(card) ? { ...card, dueDate: null } : card) : data.cards,
147
+ }),
148
+ 4: (data) => ({
149
+ ...data,
150
+ schemaVersion: 5,
151
+ // Truncated, title-based activity history cannot reliably recover completion times.
152
+ cards: Array.isArray(data.cards) ? data.cards.map((card) => isObj(card) ? { ...card, completedAt: null } : card) : data.cards,
153
+ }),
131
154
  }
132
155
 
133
156
  /**
@@ -184,6 +207,10 @@ export function validateBoard(data) {
184
207
  }
185
208
  }
186
209
 
210
+ if (data.completedColumnId !== null && !columnIds.has(data.completedColumnId)) {
211
+ errors.push('completedColumnId must be null or reference an existing column')
212
+ }
213
+
187
214
  const labelNames = new Set()
188
215
  if (Array.isArray(data.labels)) {
189
216
  for (const l of data.labels) {
@@ -213,6 +240,9 @@ export function validateBoard(data) {
213
240
  }
214
241
  if (!columnIds.has(c.columnId)) errors.push('card references missing column: ' + c.id)
215
242
  if (c.label != null && !labelNames.has(c.label)) errors.push('card references missing label: ' + c.id)
243
+ if (c.dueDate !== null && !isDueDate(c.dueDate)) errors.push('card has invalid due date: ' + c.id)
244
+ if (c.completedAt !== null && (typeof c.completedAt !== 'string' || !Number.isFinite(Date.parse(c.completedAt)) || new Date(c.completedAt).toISOString() !== c.completedAt)) errors.push('card has invalid completion time: ' + c.id)
245
+ if (c.completedAt !== null && c.columnId !== data.completedColumnId) errors.push('incomplete card has a completion time: ' + c.id)
216
246
  if (c.priority != null && !['high', 'medium', 'low'].includes(c.priority)) errors.push('card has invalid priority: ' + c.id)
217
247
  for (const comment of c.comments) {
218
248
  if (!isObj(comment) || typeof comment.id !== 'string' || !comment.id || typeof comment.content !== 'string' || !comment.content.trim() || comment.content.length > 2000 || !['human', 'agent'].includes(comment.source) || typeof comment.createdAt !== 'string' || !comment.createdAt) {
@@ -430,6 +460,7 @@ export function apply(ctx) {
430
460
  const load = (async () => {
431
461
  const board = {
432
462
  schemaVersion: SCHEMA_VERSION,
463
+ completedColumnId: null,
433
464
  columns: [],
434
465
  labels: [],
435
466
  cards: [],
@@ -440,12 +471,15 @@ export function apply(ctx) {
440
471
  const fs = getFs()
441
472
  const target = await targetOf(workspace)
442
473
  let migrated = false
474
+ let loadedBoard = false
443
475
  if (fs && target) {
444
476
  try {
445
477
  const text = await fs.readText(target)
446
478
  const parsed = parseBoardText(text)
447
479
  for (const w of parsed.warnings) warn(board, w)
448
480
  if (parsed.ok) {
481
+ loadedBoard = true
482
+ board.completedColumnId = parsed.data.completedColumnId
449
483
  board.columns = parsed.data.columns
450
484
  board.labels = parsed.data.labels
451
485
  board.cards = parsed.data.cards
@@ -486,7 +520,11 @@ export function apply(ctx) {
486
520
  }
487
521
  for (const act of board.activities) bumpSeq(act.id)
488
522
  if (board.columns.length === 0) {
489
- for (const title of DEFAULT_COLUMNS) board.columns.push({ id: nextId('c'), title })
523
+ for (const title of DEFAULT_COLUMNS) {
524
+ const column = { id: nextId('c'), title }
525
+ board.columns.push(column)
526
+ if (!loadedBoard && title === 'Done') board.completedColumnId = column.id
527
+ }
490
528
  }
491
529
  if (board.labels.length === 0) board.labels = DEFAULT_LABELS.map((l) => ({ ...l }))
492
530
  boards.set(key, board)
@@ -518,6 +556,7 @@ export function apply(ctx) {
518
556
  target,
519
557
  JSON.stringify({
520
558
  schemaVersion: SCHEMA_VERSION,
559
+ completedColumnId: board.completedColumnId,
521
560
  columns: board.columns,
522
561
  labels: board.labels,
523
562
  cards: board.cards,
@@ -553,6 +592,7 @@ export function apply(ctx) {
553
592
  const findLabel = (b, name) => b.labels.find((l) => l.name === name)
554
593
 
555
594
  const cloneBoard = (b) => ({
595
+ completedColumnId: b.completedColumnId,
556
596
  columns: b.columns.map((c) => ({ id: c.id, title: c.title })),
557
597
  labels: b.labels.map((l) => ({ name: l.name, color: l.color })),
558
598
  cards: b.cards.map((c) => ({
@@ -562,6 +602,8 @@ export function apply(ctx) {
562
602
  note: c.note ?? '',
563
603
  label: c.label ?? null,
564
604
  priority: c.priority ?? null,
605
+ dueDate: c.dueDate,
606
+ completedAt: c.completedAt,
565
607
  createdAt: typeof c.createdAt === 'string' ? c.createdAt : null,
566
608
  createdBy: typeof c.createdBy === 'string' ? c.createdBy : null,
567
609
  comments: Array.isArray(c.comments)
@@ -576,6 +618,7 @@ export function apply(ctx) {
576
618
  activities: Array.isArray(b.activities) ? b.activities.map((a) => ({ ...a })) : [],
577
619
  })
578
620
  const summaryOfClone = (clone) => ({
621
+ completedColumnId: clone.completedColumnId,
579
622
  columns: clone.columns.map((c) => ({
580
623
  id: c.id,
581
624
  title: c.title,
@@ -588,6 +631,8 @@ export function apply(ctx) {
588
631
  title: c.title,
589
632
  label: c.label ?? null,
590
633
  priority: c.priority ?? null,
634
+ dueDate: c.dueDate,
635
+ completedAt: c.completedAt,
591
636
  commentCount: c.comments.length,
592
637
  })),
593
638
  })
@@ -624,10 +669,11 @@ export function apply(ctx) {
624
669
  case 'getCard': {
625
670
  const card = cloneBoard(board).cards.find((c) => c.id === str(a.id, ''))
626
671
  if (!card) return { warnings: takeWarnings(board), error: 'Card not found: ' + str(a.id, '') }
627
- return { card, warnings: takeWarnings(board) }
672
+ return { card, completedColumnId: board.completedColumnId, warnings: takeWarnings(board) }
628
673
  }
629
674
 
630
675
  case 'addCard': {
676
+ if (a.dueDate !== undefined && a.dueDate !== null && a.dueDate !== '' && !isDueDate(a.dueDate)) return result({ error: 'Due date must be a real calendar date in YYYY-MM-DD format' })
631
677
  const col = findColumn(board, str(a.columnId, '')) || board.columns[0]
632
678
  if (!col) return result({ error: 'No list available' })
633
679
  const label = typeof a.label === 'string' ? clampText(a.label, LABEL_LIMIT, 'Label', board) : undefined
@@ -639,10 +685,12 @@ export function apply(ctx) {
639
685
  note: clampText(a.note, NOTE_LIMIT, 'Note', board),
640
686
  label,
641
687
  priority: normPriority(a.priority),
688
+ dueDate: a.dueDate || null,
642
689
  createdAt: new Date().toISOString(),
643
690
  createdBy: actor,
644
691
  comments: [],
645
692
  }
693
+ card.completedAt = col.id === board.completedColumnId ? card.createdAt : null
646
694
  board.cards.push(card)
647
695
  record(board, {
648
696
  cardId: card.id,
@@ -653,6 +701,7 @@ export function apply(ctx) {
653
701
  column: col.title,
654
702
  label: card.label ?? null,
655
703
  priority: card.priority ?? null,
704
+ dueDate: card.dueDate,
656
705
  },
657
706
  })
658
707
  await save(workspace, session)
@@ -660,6 +709,7 @@ export function apply(ctx) {
660
709
  }
661
710
 
662
711
  case 'updateCard': {
712
+ if (a.dueDate !== undefined && a.dueDate !== null && a.dueDate !== '' && !isDueDate(a.dueDate)) return result({ error: 'Due date must be a real calendar date in YYYY-MM-DD format' })
663
713
  const card = findCard(board, str(a.id, ''))
664
714
  if (card) {
665
715
  const nextLabel = typeof a.label === 'string' ? clampText(a.label, LABEL_LIMIT, 'Label', board) : undefined
@@ -669,16 +719,19 @@ export function apply(ctx) {
669
719
  note: card.note,
670
720
  label: card.label ?? null,
671
721
  priority: card.priority ?? null,
722
+ dueDate: card.dueDate,
672
723
  }
673
724
  if (typeof a.title === 'string') card.title = clampText(a.title, TITLE_LIMIT, 'Title', board) || card.title
674
725
  if (typeof a.note === 'string') card.note = clampText(a.note, NOTE_LIMIT, 'Note', board)
675
726
  if (typeof a.label === 'string') card.label = nextLabel || undefined
676
727
  if (typeof a.priority === 'string') card.priority = normPriority(a.priority)
728
+ if (a.dueDate !== undefined) card.dueDate = a.dueDate || null
677
729
  const after = {
678
730
  title: card.title,
679
731
  note: card.note,
680
732
  label: card.label ?? null,
681
733
  priority: card.priority ?? null,
734
+ dueDate: card.dueDate,
682
735
  }
683
736
  if (after.title !== before.title) {
684
737
  record(board, { cardId: card.id, type: 'card_title_changed', source: actor, field: 'title', from: before.title, to: after.title })
@@ -689,6 +742,9 @@ export function apply(ctx) {
689
742
  if (after.label !== before.label) {
690
743
  record(board, { cardId: card.id, type: 'card_label_changed', source: actor, field: 'label', from: before.label, to: after.label })
691
744
  }
745
+ if (after.dueDate !== before.dueDate) {
746
+ record(board, { cardId: card.id, type: 'card_due_date_changed', source: actor, field: 'dueDate', from: before.dueDate, to: after.dueDate })
747
+ }
692
748
  if (after.priority !== before.priority) {
693
749
  record(board, { cardId: card.id, type: 'card_priority_changed', source: actor, field: 'priority', from: before.priority, to: after.priority })
694
750
  }
@@ -733,7 +789,9 @@ export function apply(ctx) {
733
789
  if (!card || !target) return result({ error: 'Card or list not found' })
734
790
  const fromCol = findColumn(board, card.columnId)
735
791
  const fromTitle = fromCol ? fromCol.title : String(card.columnId)
792
+ const changedColumn = card.columnId !== target.id
736
793
  board.cards = board.cards.filter((c) => c.id !== card.id)
794
+ if (changedColumn) card.completedAt = target.id === board.completedColumnId ? new Date().toISOString() : null
737
795
  card.columnId = target.id
738
796
  const inCol = board.cards.filter((c) => c.columnId === target.id)
739
797
  const toIndex = typeof a.toIndex === 'number' && Number.isFinite(a.toIndex)
@@ -742,7 +800,7 @@ export function apply(ctx) {
742
800
  const anchor = inCol[toIndex]
743
801
  if (anchor) board.cards.splice(board.cards.indexOf(anchor), 0, card)
744
802
  else board.cards.push(card)
745
- if (fromTitle !== target.title) {
803
+ if (changedColumn) {
746
804
  record(board, { cardId: card.id, type: 'card_moved', source: actor, field: 'columnId', from: fromTitle, to: target.title, meta: { title: card.title } })
747
805
  }
748
806
  await save(workspace, session)
@@ -770,6 +828,19 @@ export function apply(ctx) {
770
828
  return col ? result({ message: 'List renamed' }) : result({ error: 'List not found' })
771
829
  }
772
830
 
831
+ case 'setCompletedColumn': {
832
+ if (a.columnId !== null && (typeof a.columnId !== 'string' || !findColumn(board, a.columnId))) return result({ error: 'Completion column must be null or an existing list id' })
833
+ const previousId = board.completedColumnId
834
+ if (previousId !== a.columnId) {
835
+ board.completedColumnId = a.columnId
836
+ // Changing the definition of done does not establish when existing cards finished.
837
+ for (const card of board.cards) card.completedAt = null
838
+ record(board, { cardId: null, type: 'board_completed_column_changed', source: actor, field: 'completedColumnId', from: previousId, to: a.columnId, meta: { fromColumn: findColumn(board, previousId)?.title ?? null, toColumn: findColumn(board, a.columnId)?.title ?? null } })
839
+ await save(workspace, session)
840
+ }
841
+ return result({ message: a.columnId === null ? 'Completion column cleared' : 'Completion column updated' })
842
+ }
843
+
773
844
  case 'deleteColumn': {
774
845
  const id = str(a.id, '')
775
846
  if (board.columns.length <= 1) return result({ error: 'At least one list must remain' })
@@ -777,10 +848,15 @@ export function apply(ctx) {
777
848
  if (idx < 0) return result({ error: 'List not found' })
778
849
  const deleted = board.columns[idx]
779
850
  board.columns.splice(idx, 1)
851
+ if (board.completedColumnId === id) {
852
+ board.completedColumnId = null
853
+ record(board, { cardId: null, type: 'board_completed_column_changed', source: actor, field: 'completedColumnId', from: id, to: null, meta: { fromColumn: deleted.title, toColumn: null } })
854
+ }
780
855
  const fallback = board.columns[0].id
781
856
  for (const card of board.cards) {
782
857
  if (card.columnId === id) {
783
858
  card.columnId = fallback
859
+ card.completedAt = fallback === board.completedColumnId ? new Date().toISOString() : null
784
860
  record(board, { cardId: card.id, type: 'card_moved', source: actor, field: 'columnId', from: deleted.title, to: board.columns[0].title, meta: { title: card.title } })
785
861
  }
786
862
  }
@@ -903,7 +979,7 @@ export function apply(ctx) {
903
979
  const registry = getWorkspaceRegistry()
904
980
  return registry && typeof registry.get === 'function' ? registry.get(id) : undefined
905
981
  }
906
- const emptyBoardSummary = { columns: [], labels: [], cards: [] }
982
+ const emptyBoardSummary = { completedColumnId: null, columns: [], labels: [], cards: [] }
907
983
 
908
984
  const runTool = async (method, args, exec) => {
909
985
  const workspace = await workspaceOfExec(exec)
@@ -974,50 +1050,15 @@ export function apply(ctx) {
974
1050
  }
975
1051
  }
976
1052
 
977
- const routeState = { registered: false, timer: null, dispose: null, disposed: false, attempts: 0 }
978
- const registerRoute = () => {
979
- if (routeState.registered || routeState.disposed) return
980
- const connection = ctx.get('connection')
981
- if (connection === undefined) return
982
- try {
983
- const dispose = connection.fetch.register({
984
- path: '/api/kanban',
985
- methods: ['POST'],
986
- requestBody: 'streaming',
987
- fetch: httpHandler,
988
- })
989
- routeState.dispose = typeof dispose === 'function' ? dispose : null
990
- routeState.registered = true
991
- console.log('dsh-kanban: /api/kanban route registered')
992
- } catch (err) {
993
- console.log('dsh-kanban: Route registration failed: ' + ((err && err.message) || err))
994
- }
995
- }
996
- registerRoute()
997
- if (!routeState.registered) {
998
- const timer = ctx.get('timer')
999
- if (timer) {
1000
- routeState.timer = timer.interval(() => {
1001
- routeState.attempts++
1002
- registerRoute()
1003
- maybeStartupCheck()
1004
- if (routeState.registered || routeState.attempts >= 40) {
1005
- if (routeState.timer) routeState.timer()
1006
- routeState.timer = null
1007
- }
1008
- }, 500)
1009
- }
1010
- }
1053
+ // Connection may arrive after tools during desktop boot; follow its lifecycle.
1054
+ ctx.inject(['connection'], (routeCtx) => routeCtx.connection.fetch.register({
1055
+ path: '/api/kanban',
1056
+ methods: ['POST'],
1057
+ requestBody: 'streaming',
1058
+ fetch: httpHandler,
1059
+ }))
1011
1060
 
1012
1061
  // ---- Startup checks: read each workspace board and back up corrupt files ----
1013
- const startupState = { done: false }
1014
- const maybeStartupCheck = () => {
1015
- if (startupState.done) return
1016
- const registry = getWorkspaceRegistry()
1017
- if (!getFs() || !registry || typeof registry.list !== 'function') return
1018
- startupState.done = true
1019
- runStartupCheck()
1020
- }
1021
1062
  const runStartupCheck = async () => {
1022
1063
  const fs = getFs()
1023
1064
  const registry = getWorkspaceRegistry()
@@ -1079,7 +1120,7 @@ export function apply(ctx) {
1079
1120
  console.log('dsh-kanban: Startup check failed: ' + ((err && err.message) || err))
1080
1121
  }
1081
1122
  }
1082
- maybeStartupCheck()
1123
+ ctx.inject(['fs', 'workspaceRegistry'], () => { void runStartupCheck() })
1083
1124
 
1084
1125
  // ---- Tool registration ----
1085
1126
  const resultSchema = {
@@ -1102,8 +1143,9 @@ export function apply(ctx) {
1102
1143
  lines.push(String((value && value.message) || ''))
1103
1144
  if (b && Array.isArray(b.columns)) {
1104
1145
  lines.push('Board state:')
1146
+ lines.push('Completion column: ' + (b.completedColumnId || 'not set'))
1105
1147
  for (const col of b.columns) {
1106
- lines.push('· ' + col.title + ' (' + col.count + ')')
1148
+ lines.push('· [' + col.id + '] ' + col.title + ' (' + col.count + ')' + (col.id === b.completedColumnId ? ' [completed]' : ''))
1107
1149
  }
1108
1150
  if (Array.isArray(b.labels) && b.labels.length > 0) {
1109
1151
  lines.push('Labels: ' + b.labels.map((l) => l.name).join(' / '))
@@ -1115,6 +1157,8 @@ export function apply(ctx) {
1115
1157
  (card.priority ? '[' + card.priority + '] ' : '') +
1116
1158
  (card.label ? '[' + card.label + '] ' : '') +
1117
1159
  card.title +
1160
+ (card.dueDate ? ' (due ' + card.dueDate + ')' : '') +
1161
+ (card.columnId === b.completedColumnId ? ' [completed; completedAt: ' + (card.completedAt || 'unknown') + ']' : '') +
1118
1162
  (card.commentCount ? ' (' + card.commentCount + ' comments)' : ''),
1119
1163
  )
1120
1164
  }
@@ -1127,7 +1171,7 @@ export function apply(ctx) {
1127
1171
  const tools = [
1128
1172
  {
1129
1173
  name: 'kanban_get',
1130
- description: 'Read the current state of the current project (workspace) kanban board (all lists, labels and cards). Call it before planning to understand existing content and avoid duplicate cards.',
1174
+ description: 'Read the current state of the current project (workspace) kanban board (all lists, labels, cards with dueDate and completedAt, and completedColumnId). Due dates are local calendar dates, not UTC timestamps; a date becomes overdue the following day. Cards in completedColumnId are finished and excluded from due-today/overdue checks. completedAt is the latest completion UTC timestamp; null on a completed card means unknown. Resolve relative dates using the user local date and confirm the concrete YYYY-MM-DD date. Call it before planning to understand existing content and avoid duplicate cards.',
1131
1175
  parameters: { type: 'object', properties: {} },
1132
1176
  output: output(renderBoard),
1133
1177
  async execute(args, exec) {
@@ -1136,7 +1180,7 @@ export function apply(ctx) {
1136
1180
  },
1137
1181
  {
1138
1182
  name: 'kanban_get_card',
1139
- description: "Read one card's full details (title, raw Markdown description in note, label, priority and comments) by id from the current project (workspace) board. Use kanban_get first to discover card ids; its summary omits note. Read this tool before editing an existing description to preserve its content and Markdown formatting.",
1183
+ description: "Read one card's full details (title, raw Markdown description in note, label, priority, dueDate, completedAt and comments), plus the board completion column ID from the current project (workspace) board by card id. completedAt is a system-managed UTC timestamp, cleared on reopening; null on a completed card means unknown. Use kanban_get first to discover card ids; its summary omits note. Read this tool before editing an existing description to preserve its content and Markdown formatting.",
1140
1184
  parameters: {
1141
1185
  type: 'object',
1142
1186
  properties: {
@@ -1151,6 +1195,7 @@ export function apply(ctx) {
1151
1195
  ok: { type: 'boolean' },
1152
1196
  message: { type: 'string' },
1153
1197
  card: { type: 'object' },
1198
+ completedColumnId: { oneOf: [{ type: 'string' }, { type: 'null' }] },
1154
1199
  warnings: { type: 'array', items: { type: 'string' } },
1155
1200
  },
1156
1201
  required: ['ok', 'message'],
@@ -1167,6 +1212,9 @@ export function apply(ctx) {
1167
1212
  lines.push('[' + c.id + '] ' + c.title)
1168
1213
  if (c.priority) lines.push('Priority: ' + c.priority)
1169
1214
  if (c.label) lines.push('Label: ' + c.label)
1215
+ if (c.dueDate) lines.push('Due date: ' + c.dueDate + ' (local calendar date)')
1216
+ lines.push('Completed: ' + (c.columnId === value.completedColumnId ? 'yes' : 'no'))
1217
+ if (c.columnId === value.completedColumnId) lines.push('Completed at: ' + (c.completedAt || 'unknown'))
1170
1218
  if (c.note) lines.push('Note: ' + c.note)
1171
1219
  if (Array.isArray(c.comments) && c.comments.length > 0) {
1172
1220
  lines.push('Comments:')
@@ -1184,7 +1232,7 @@ export function apply(ctx) {
1184
1232
  const session = exec && exec.agent && exec.agent.session
1185
1233
  const r = await dispatch(workspace, 'getCard', args, 'agent', session)
1186
1234
  if (r.error) return { ok: false, message: r.error, warnings: Array.isArray(r.warnings) ? r.warnings : [] }
1187
- return { ok: true, message: 'Card ' + String(args.id || '') + ' details', card: r.card, warnings: Array.isArray(r.warnings) ? r.warnings : [] }
1235
+ return { ok: true, message: 'Card ' + String(args.id || '') + ' details', card: r.card, completedColumnId: r.completedColumnId, warnings: Array.isArray(r.warnings) ? r.warnings : [] }
1188
1236
  },
1189
1237
  },
1190
1238
  {
@@ -1214,6 +1262,7 @@ export function apply(ctx) {
1214
1262
  note: { type: 'string', description: `Task description as raw Markdown source, not HTML: background, acceptance criteria or breakdown details. Supports headings, lists, tables and fenced code blocks; preserve line breaks. Optional; max ${NOTE_LIMIT} chars including Markdown syntax and newlines. Longer input is truncated with a warning.` },
1215
1263
  label: { type: 'string', description: `Label name (optional; max ${LABEL_LIMIT} chars): e.g. New Feature, bug, Feedback` },
1216
1264
  priority: { type: 'string', enum: ['high', 'medium', 'low'], description: 'Priority (optional): high=P0 / medium=P1 / low=P2' },
1265
+ dueDate: { oneOf: [{ type: 'string' }, { type: 'null' }], description: 'Optional local calendar date in YYYY-MM-DD format, without time or timezone. Resolve relative dates such as Friday using the user local date and confirm the concrete date. Omit to keep unchanged (new cards default to no date); null or empty string clears it. Due today is not overdue until the next local day; completed-column cards are excluded.' },
1217
1266
  },
1218
1267
  required: ['title'],
1219
1268
  },
@@ -1224,7 +1273,7 @@ export function apply(ctx) {
1224
1273
  },
1225
1274
  {
1226
1275
  name: 'kanban_update_card',
1227
- description: "Update a card's title, Markdown description (note), label or priority on the board. Read kanban_get_card before editing an existing description; note replaces the whole description, not a patch.",
1276
+ description: "Update a card's title, Markdown description (note), label, priority or dueDate on the board. Read kanban_get_card before editing an existing description; note replaces the whole description, not a patch.",
1228
1277
  parameters: {
1229
1278
  type: 'object',
1230
1279
  properties: {
@@ -1233,6 +1282,7 @@ export function apply(ctx) {
1233
1282
  note: { type: 'string', description: `Complete replacement description as raw Markdown source, not HTML; preserve line breaks. Omit to keep the description unchanged; pass an empty string to clear it. Max ${NOTE_LIMIT} chars including Markdown syntax and newlines. Longer input is truncated with a warning.` },
1234
1283
  label: { type: 'string', description: `New label name (optional; max ${LABEL_LIMIT} chars); pass empty string to clear` },
1235
1284
  priority: { type: 'string', enum: ['high', 'medium', 'low', ''], description: 'New priority (optional): high=P0 / medium=P1 / low=P2; pass empty string to clear' },
1285
+ dueDate: { oneOf: [{ type: 'string' }, { type: 'null' }], description: 'Optional local calendar date in YYYY-MM-DD format, without time or timezone. Resolve relative dates such as Friday using the user local date and confirm the concrete date. Omit to keep unchanged (new cards default to no date); null or empty string clears it. Due today is not overdue until the next local day; completed-column cards are excluded.' },
1236
1286
  },
1237
1287
  required: ['id'],
1238
1288
  },
@@ -1300,6 +1350,19 @@ export function apply(ctx) {
1300
1350
  return runTool('renameColumn', args, exec)
1301
1351
  },
1302
1352
  },
1353
+ {
1354
+ name: 'kanban_set_completed_column',
1355
+ description: 'Choose the one list that means completed for this board by its stable column id, or clear the setting with null. Cards in this list are excluded from due-today and overdue checks. Existing boards require an explicit choice; never infer completion from a list name or position. New boards default to Done. Changing this setting clears completion timestamps; cards already in the new completion list have unknown completion times.',
1356
+ parameters: {
1357
+ type: 'object',
1358
+ properties: { columnId: { oneOf: [{ type: 'string' }, { type: 'null' }], description: 'Existing list id from kanban_get, or null to clear the completion column' } },
1359
+ required: ['columnId'],
1360
+ },
1361
+ output: output(renderBoard),
1362
+ async execute(args, exec) {
1363
+ return runTool('setCompletedColumn', args, exec)
1364
+ },
1365
+ },
1303
1366
  {
1304
1367
  name: 'kanban_delete_column',
1305
1368
  description: 'Delete a list from the board; its cards are moved into the first list. At least one list must remain.',
@@ -1423,11 +1486,6 @@ export function apply(ctx) {
1423
1486
  for (const tool of tools) ctx.tools.register(tool)
1424
1487
 
1425
1488
  return async () => {
1426
- routeState.disposed = true
1427
- if (routeState.timer) routeState.timer()
1428
- routeState.timer = null
1429
- if (routeState.dispose) await routeState.dispose()
1430
- routeState.dispose = null
1431
1489
  boards.clear()
1432
1490
  boardLoads.clear()
1433
1491
  workspaceQueues.clear()