@zinn-dev/cli 0.43.0 → 0.45.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 (78) hide show
  1. package/README.md +1 -1
  2. package/index.js +3 -3
  3. package/package.json +7 -4
  4. package/skills/zinn/SKILL.md +7 -9
  5. package/src/actor.d.ts +8 -0
  6. package/src/actor.js +5 -1
  7. package/src/capabilities-schema.d.ts +6 -2
  8. package/src/column-hint.js +2 -5
  9. package/src/database.d.ts +1 -2
  10. package/src/database.js +1 -6
  11. package/src/duration-input.d.ts +7 -0
  12. package/src/duration-input.js +31 -0
  13. package/src/errors.d.ts +34 -3
  14. package/src/errors.js +49 -7
  15. package/src/expected-values.d.ts +48 -0
  16. package/src/expected-values.js +60 -0
  17. package/src/failure-log.d.ts +6 -0
  18. package/src/failure-log.js +167 -0
  19. package/src/follow.d.ts +9 -0
  20. package/src/follow.js +58 -0
  21. package/src/input.d.ts +10 -7
  22. package/src/input.js +57 -13
  23. package/src/lib.d.ts +12 -7
  24. package/src/lib.js +70 -41
  25. package/src/list-continuation.js +1 -4
  26. package/src/list-limit.d.ts +2 -2
  27. package/src/list-limit.js +2 -2
  28. package/src/overview.d.ts +10 -0
  29. package/src/overview.js +41 -0
  30. package/src/presentation/activity-presentation.d.ts +4 -0
  31. package/src/presentation/activity-presentation.js +154 -38
  32. package/src/presentation/column-presentation.d.ts +22 -2
  33. package/src/presentation/column-presentation.js +68 -12
  34. package/src/presentation/doctor-presentation.d.ts +4 -0
  35. package/src/presentation/doctor-presentation.js +24 -0
  36. package/src/presentation/info-presentation.js +36 -6
  37. package/src/presentation/relation-presentation.d.ts +6 -2
  38. package/src/presentation/relation-presentation.js +37 -26
  39. package/src/presentation/task-blame-presentation.d.ts +8 -0
  40. package/src/presentation/task-blame-presentation.js +56 -0
  41. package/src/presentation/task-presentation.d.ts +8 -1
  42. package/src/presentation/task-presentation.js +59 -10
  43. package/src/result-schemas.d.ts +780 -20
  44. package/src/result-schemas.js +99 -2
  45. package/src/results.d.ts +6 -2
  46. package/src/results.js +9 -3
  47. package/src/routes/activity-router.d.ts +21 -4
  48. package/src/routes/activity-router.js +107 -60
  49. package/src/routes/aliases.js +1 -0
  50. package/src/routes/comment-router.d.ts +24 -6
  51. package/src/routes/comment-router.js +15 -5
  52. package/src/routes/doctor-router.d.ts +39 -0
  53. package/src/routes/doctor-router.js +103 -0
  54. package/src/routes/info-router.js +3 -2
  55. package/src/routes/label-router.d.ts +39 -6
  56. package/src/routes/label-router.js +22 -5
  57. package/src/routes/migrate-router.js +2 -2
  58. package/src/routes/project-router.d.ts +61 -12
  59. package/src/routes/project-router.js +103 -45
  60. package/src/routes/restore-router.js +11 -5
  61. package/src/routes/router.js +25 -16
  62. package/src/routes/routes.d.ts +455 -41
  63. package/src/routes/routes.js +4 -0
  64. package/src/routes/skill-router.d.ts +25 -0
  65. package/src/routes/skill-router.js +96 -0
  66. package/src/routes/task-router.d.ts +272 -19
  67. package/src/routes/task-router.js +325 -40
  68. package/src/routes/whoami-router.js +1 -1
  69. package/src/run-facts.d.ts +14 -0
  70. package/src/run-facts.js +14 -0
  71. package/src/store-folder.d.ts +5 -0
  72. package/src/store-folder.js +16 -0
  73. package/src/telemetry.d.ts +31 -0
  74. package/src/telemetry.js +329 -0
  75. package/src/text-edit.d.ts +2 -2
  76. package/src/text-input.d.ts +19 -1
  77. package/src/text-input.js +27 -10
  78. package/src/types.d.ts +1 -1
@@ -1,14 +1,16 @@
1
1
  import { jsonResult, taskDetailResults, taskChangeResults } from "../results.js";
2
2
  import { parseArgs } from "node:util";
3
- import { task, project, parseTaskKey, taskCreateSchema, taskEditSchema, taskDeleteManySchema, taskPrioritySchema, taskSortSchema, } from "@zinn-dev/core";
3
+ import { activity, task, project, parseTaskKey, taskCreateSchema, taskEditSchema, taskDeleteManySchema, taskPrioritySchema, taskSortSchema, taskStateFilterSchema, CLAIM_WORK_LIMIT_MS, MIN_CLAIM_LEASE_MS, } from "@zinn-dev/core";
4
4
  import { listLimitOption, listLimitDescription, parseListLimit } from "../list-limit.js";
5
5
  import { formatListContinuation } from "../list-continuation.js";
6
6
  import { parseTimestampInput } from "../timestamp-input.js";
7
+ import { durationPattern, formatDurationInput, parseDurationInput } from "../duration-input.js";
7
8
  import { CliError } from "../errors.js";
8
9
  import { generateCommandUsage, taskKeyPositional, archiveConstraint, getOptionInputs, violatesConstraint, } from "../input.js";
9
10
  import { confirmationDescription, confirmAction, dashValueHelp, diagnostic, output, outputChanges, quit, validatePositionals, validateOrderForms, requireStringOption, renameFlag, validateUniqueOptions, } from "../lib.js";
10
11
  import { resolveTextEdit, textEditHelp, textEditOptions, textEditConstraints, } from "../text-edit.js";
11
- import { checkFieldsBeforeText, resolveTextInput, textFileHelp, textFileOption, textSourceConstraint, } from "../text-input.js";
12
+ import { expectedValueFlags } from "../expected-values.js";
13
+ import { checkFieldsBeforeText, checkSingleStdinReader, resolveTextInput, textFileHelp, textFileOption, textSourceConstraint, } from "../text-input.js";
12
14
  import { currentActor } from "../actor.js";
13
15
  import { checkDefaultProject, chooseProjectKey, resolveProjectKey, projectScopeConstraint, requiredProjectDescription, projectScopeDescription, } from "../project.js";
14
16
  import { relationRouter } from "./relation-router.js";
@@ -16,7 +18,9 @@ import { commentRouter } from "./comment-router.js";
16
18
  import { formatRelationList, presentRelations } from "../presentation/relation-presentation.js";
17
19
  import { formatCommentList, presentComments } from "../presentation/comment-presentation.js";
18
20
  import { formatSection } from "../presentation/section.js";
19
- import { formatActivityList, presentActivities } from "../presentation/activity-presentation.js";
21
+ import { abbreviateActivityIds, formatActivityList, presentActivities, } from "../presentation/activity-presentation.js";
22
+ import { formatTaskBlame } from "../presentation/task-blame-presentation.js";
23
+ import { createColumnBoard } from "../presentation/column-presentation.js";
20
24
  import { formatTaskList, formatTaskTimestamps, presentTask, } from "../presentation/task-presentation.js";
21
25
  // A column is changed with task move, so a guessed --status or --column suggests it with the same task keys.
22
26
  function suggestTaskMove(args, options = {}) {
@@ -48,6 +52,29 @@ const dueOption = {
48
52
  description: "Integer epoch milliseconds or YYYY-MM-DDTHH:mm:ss[.SSS] with Z or a numeric offset. Fractions have 1 to 3 digits. none clears the deadline, ignoring case. Omission leaves it unset on creation and unchanged on edit.",
49
53
  },
50
54
  };
55
+ const taskExpectations = expectedValueFlags({
56
+ title: { field: "title", option: { type: "string", value: { kind: "text", name: "text" } } },
57
+ description: { field: "description", text: true },
58
+ priority: {
59
+ field: "priority",
60
+ option: {
61
+ type: "string",
62
+ value: { ...priorityOption.value, description: "none expects no priority." },
63
+ },
64
+ parse: parsePriority,
65
+ },
66
+ due: {
67
+ field: "due_at",
68
+ option: {
69
+ type: "string",
70
+ value: {
71
+ ...dueOption.value,
72
+ description: "Same formats as --due. none expects no deadline, ignoring case.",
73
+ },
74
+ },
75
+ parse: parseDue,
76
+ },
77
+ });
51
78
  const deadlineFilterOptions = {
52
79
  "due-since": {
53
80
  type: "string",
@@ -116,6 +143,10 @@ const taskInputs = {
116
143
  type: "string",
117
144
  value: { kind: "enum", name: "key", choices: taskSortSchema.options },
118
145
  },
146
+ state: {
147
+ type: "string",
148
+ value: { kind: "enum", name: "state", choices: taskStateFilterSchema.options },
149
+ },
119
150
  archived: { type: "boolean" },
120
151
  all: { type: "boolean" },
121
152
  "all-projects": { type: "boolean" },
@@ -124,9 +155,9 @@ const taskInputs = {
124
155
  "starting-after": {
125
156
  type: "string",
126
157
  value: {
127
- kind: "task-id",
128
- name: "id",
129
- description: "Task UUID or globally unambiguous left prefix with at least 8 hexadecimal digits. Canonical or compact, case-insensitive",
158
+ kind: "task-cursor",
159
+ name: "cursor",
160
+ description: "Cursor from the continuation command that task list prints on stderr when more tasks remain",
130
161
  },
131
162
  },
132
163
  },
@@ -139,7 +170,7 @@ const taskInputs = {
139
170
  constraints: [archiveConstraint, projectScopeConstraint],
140
171
  notes: [
141
172
  projectScopeDescription,
142
- "A --starting-after task must match every selection filter. Cursor resolution uses current task identities before list filtering.",
173
+ "A --starting-after cursor works only with the --sort it was made for. Filters may change between pages.",
143
174
  ],
144
175
  },
145
176
  search: {
@@ -150,6 +181,7 @@ const taskInputs = {
150
181
  "all-projects": { type: "boolean" },
151
182
  limit: listLimitOption,
152
183
  label: { type: "string", multiple: true, value: { kind: "label-name", name: "name" } },
184
+ column: { type: "string", value: { kind: "column-name", name: "name" } },
153
185
  },
154
186
  forms: [
155
187
  {
@@ -166,6 +198,20 @@ const taskInputs = {
166
198
  "A query that is a task key ignores defaultProject unless a project was typed. --all-projects still excludes a typed project.",
167
199
  ],
168
200
  },
201
+ next: {
202
+ options: {
203
+ "all-projects": { type: "boolean" },
204
+ column: { type: "string", value: { kind: "column-name", name: "name" } },
205
+ },
206
+ forms: [
207
+ {
208
+ id: "default",
209
+ positionals: [{ name: "project-key", min: 0, max: 1, value: { kind: "project-key" } }],
210
+ },
211
+ ],
212
+ constraints: [projectScopeConstraint],
213
+ notes: [projectScopeDescription],
214
+ },
169
215
  view: {
170
216
  options: { history: { type: "boolean" } },
171
217
  forms: [
@@ -176,6 +222,11 @@ const taskInputs = {
176
222
  ],
177
223
  constraints: [],
178
224
  },
225
+ blame: {
226
+ options: {},
227
+ forms: [{ id: "default", positionals: [taskKeyPositional] }],
228
+ constraints: [],
229
+ },
179
230
  edit: {
180
231
  options: {
181
232
  title: { type: "string", value: { kind: "text", name: "text" } },
@@ -190,6 +241,7 @@ const taskInputs = {
190
241
  multiple: true,
191
242
  value: { kind: "label-name", name: "name" },
192
243
  },
244
+ ...taskExpectations.options,
193
245
  },
194
246
  forms: [
195
247
  {
@@ -201,11 +253,14 @@ const taskInputs = {
201
253
  textSourceConstraint("--description"),
202
254
  ...textEditConstraints("--description"),
203
255
  taskEditConstraint,
256
+ ...taskExpectations.constraints,
204
257
  ],
205
- notes: [textEditHelp("--description")],
258
+ notes: [textEditHelp("--description"), taskExpectations.help],
206
259
  },
207
260
  move: {
208
- options: {},
261
+ options: {
262
+ from: { type: "string", value: { kind: "column-name", name: "column" } },
263
+ },
209
264
  forms: [
210
265
  {
211
266
  id: "default",
@@ -265,6 +320,28 @@ const taskInputs = {
265
320
  ],
266
321
  constraints: [],
267
322
  },
323
+ claim: {
324
+ options: {
325
+ lease: {
326
+ type: "string",
327
+ required: true,
328
+ value: {
329
+ kind: "duration",
330
+ name: "duration",
331
+ pattern: durationPattern,
332
+ description: `Whole minutes or hours, such as 30m or 2h, from ${formatDurationInput(MIN_CLAIM_LEASE_MS)} through ${formatDurationInput(CLAIM_WORK_LIMIT_MS)}.`,
333
+ },
334
+ },
335
+ force: { type: "boolean" },
336
+ },
337
+ forms: [{ id: "default", positionals: [taskKeyPositional] }],
338
+ constraints: [],
339
+ },
340
+ heartbeat: {
341
+ options: {},
342
+ forms: [{ id: "default", positionals: [taskKeyPositional] }],
343
+ constraints: [],
344
+ },
268
345
  delete: {
269
346
  options: { yes: { type: "boolean" } },
270
347
  forms: [
@@ -362,7 +439,7 @@ Unknown columns, labels or related tasks abort creation.
362
439
 
363
440
  Examples:
364
441
  zinn task create MDR --title 'Refine the numbers' --description 'Meet the quarterly quota' --label urgent
365
- zinn task create MDR --title 'Review the numbers' --column 'In Progress'
442
+ zinn task create MDR --title 'Review the numbers' --column Doing
366
443
  zinn task create MDR --title 'Sort the files' --parent MDR-1 --depends-on MDR-2`,
367
444
  },
368
445
  list: {
@@ -393,27 +470,34 @@ Examples:
393
470
  argument: "--sort",
394
471
  });
395
472
  }
473
+ const state = taskStateFilterSchema.optional().safeParse(values.state);
474
+ if (!state.success) {
475
+ quit(`Unknown state "${values.state}". Use ${taskStateFilterSchema.options.join(", ")}`, undefined, { argument: "--state" });
476
+ }
396
477
  const page = task.getPage({
397
478
  ...parseDeadlineFilters(values),
398
479
  limit,
399
480
  sort: sort.data,
400
481
  projectKey,
401
482
  archive,
483
+ state: state.data,
402
484
  labelNames: values.label,
403
485
  columnName: values.column,
404
486
  startingAfter: values["starting-after"],
405
487
  });
406
- output(page.tasks.map(presentTask), (presentedTasks) => formatTaskList(presentedTasks, { showsStatus: values.all }));
407
- if (page.hasMore) {
488
+ const board = createColumnBoard();
489
+ output(page.tasks.map((taskMatch) => presentTask(taskMatch, board)), (presentedTasks) => formatTaskList(presentedTasks, { showsStatus: values.all }));
490
+ if (page.nextCursor !== undefined) {
408
491
  const selectionTokens = tokens.filter((token) => token.kind !== "option" || token.name !== "all-projects");
409
492
  const projectScope = projectKey === undefined ? ["--all-projects"] : [projectKey];
410
- diagnostic(`More tasks. Continue with: ${formatListContinuation(["task", "list"], projectScope, selectionTokens, "starting-after", page.tasks.at(-1).id)}`);
493
+ diagnostic(`More tasks. Continue with: ${formatListContinuation(["task", "list"], projectScope, selectionTokens, "starting-after", page.nextCursor)}`);
411
494
  }
412
495
  },
413
496
  help: `${generateCommandUsage("task list", taskInputs.list)}
414
497
 
415
498
  List active tasks by default.
416
499
  ${projectScopeDescription}
500
+ --state open lists tasks outside done and cancelled columns, and --state closed lists tasks in them.
417
501
  Use --archived to list archived tasks or --all to list both.
418
502
  Repeat --label to require every specified label.
419
503
  --column matches an exact column name. Column and label matching ignore case.
@@ -423,12 +507,11 @@ Equal activity times keep board order. Without --sort, board order is preserved.
423
507
  --sort due lists earliest deadlines first, with undated tasks last. Equal deadlines keep board order. Task positions stay unchanged.
424
508
  ${deadlineFilterHelp}
425
509
  --limit <n>: ${listLimitDescription}
426
- --starting-after <id>: Continue after a current matching task. Accepts a UUID, canonical or compact, case-insensitive.
427
- Use the task's id from --json output as the cursor.
428
- The task cursor must match all selection filters. Movement or edits can change current sort positions between commands.
429
510
  When additional matches remain after --limit, stderr gives a shell-quoted command to continue, including with --json.
511
+ --starting-after <cursor>: Continue after the position a cursor records. Copy the cursor from that command.
512
+ A cursor works only with the --sort it was made for. Changes to other tasks between commands can still cause repeats or skips.
430
513
 
431
- Use 'task view' to see a task's full details, including its description.
514
+ Use 'task view' to see a task's full details, including its description and an expired claim.
432
515
 
433
516
  Example: zinn task list MDR --label cli`,
434
517
  },
@@ -466,8 +549,10 @@ Example: zinn task list MDR --label cli`,
466
549
  archive,
467
550
  limit,
468
551
  labelNames: values.label,
552
+ columnName: values.column,
469
553
  });
470
- output(result.tasks.map(presentTask), (presentedTasks) => formatTaskList(presentedTasks, { showsStatus: values.all }));
554
+ const board = createColumnBoard();
555
+ output(result.tasks.map((taskMatch) => presentTask(taskMatch, board)), (presentedTasks) => formatTaskList(presentedTasks, { showsStatus: values.all }));
471
556
  if (result.hiddenArchivedCount > 0) {
472
557
  const count = result.hiddenArchivedCount;
473
558
  const noun = count === 1 ? "match" : "matches";
@@ -486,9 +571,51 @@ A task-key query overrides the configured default project; a typed project key s
486
571
  By default, only active tasks are searched. Use --archived to search archived tasks or --all to search both.
487
572
  --limit <n>: ${listLimitDescription}
488
573
  Repeat --label to require every specified label, ignoring case.
574
+ --column matches an exact column name. Column and label matching ignore case.
489
575
  ${deadlineFilterHelp}
490
576
 
491
577
  Example: zinn task search 'refinement quota' MDR --limit 5`,
578
+ },
579
+ next: {
580
+ summary: "Show the next task that is ready to work on.",
581
+ effects: { domain: "read", storage: "normal-open" },
582
+ confirmation: { kind: "none" },
583
+ input: taskInputs.next,
584
+ results: [jsonResult("NextTask")],
585
+ run: (args) => {
586
+ const { values, positionals, tokens } = parseArgs({
587
+ args,
588
+ options: taskInputs.next.options,
589
+ allowPositionals: true,
590
+ strict: true,
591
+ tokens: true,
592
+ });
593
+ validateUniqueOptions(tokens, taskInputs.next.options);
594
+ validatePositionals(positionals, taskInputs.next.forms[0]);
595
+ const projectKey = resolveProjectKey(positionals[0], { allProjects: values["all-projects"] });
596
+ const nextTask = task.next({ projectKey, columnName: values.column });
597
+ const board = createColumnBoard();
598
+ output(nextTask === null ? null : presentTask(nextTask, board), (presentedTask) => presentedTask === null ? "No task is ready." : formatTaskList([presentedTask]));
599
+ },
600
+ help: `${generateCommandUsage("task next", taskInputs.next)}
601
+
602
+ Show the next task that is ready to work on.
603
+ A task is ready when it is active, in a todo or backlog column, has no live claim, and every task it depends on is archived or in a done or cancelled column.
604
+ Only dependency relations hold a task back. A task with a live claim is skipped, including your own.
605
+ Ready tasks in todo columns come before those in backlog columns, whatever their priority.
606
+ Within each, tasks are ordered by priority (urgent first, unset last), then the earliest deadline with undated tasks last, then the oldest task.
607
+ ${projectScopeDescription}
608
+ --column takes ready tasks from one column instead, matching its exact name and ignoring case. Any column but a done or cancelled one can hold them.
609
+ When no task is ready, the command exits 0. With --json, it prints null.
610
+ To take the task, move it with task move --from, which fails if another caller moved it first. Then show that you are working on it with task claim.
611
+ task next <project> --column <working column> returns in-progress work with no live claim.
612
+
613
+ Use 'task view' to see the task's description, relations and comments.
614
+
615
+ Examples:
616
+ zinn task next MDR
617
+ zinn task next MDR --column Review
618
+ zinn task next MDR --column Doing`,
492
619
  },
493
620
  view: {
494
621
  summary: "Show a task with its description, relations, comments, and creation and update times.",
@@ -507,9 +634,10 @@ Example: zinn task search 'refinement quota' MDR --limit 5`,
507
634
  validateUniqueOptions(tokens, taskInputs.view.options);
508
635
  validatePositionals(positionals, taskInputs.view.forms[0]);
509
636
  const taskMatch = task.getByKey(positionals[0]);
637
+ const board = createColumnBoard();
510
638
  const detail = {
511
- ...presentTask(taskMatch),
512
- relations: presentRelations(taskMatch),
639
+ ...presentTask(taskMatch, board),
640
+ relations: presentRelations(taskMatch, board),
513
641
  comments: presentComments(taskMatch.key),
514
642
  };
515
643
  const viewedTask = values.history === true
@@ -531,7 +659,11 @@ Example: zinn task search 'refinement quota' MDR --limit 5`,
531
659
  const comments = formatCommentList(t.comments);
532
660
  const isArchived = t.status === "Archived";
533
661
  const sections = [
534
- formatTaskList([t], { showsStatus: isArchived, showsFullPriority: true }),
662
+ formatTaskList([t], {
663
+ showsStatus: isArchived,
664
+ showsFullPriority: true,
665
+ showsClaimDetail: true,
666
+ }),
535
667
  ];
536
668
  if (t.description != null) {
537
669
  sections.push(formatSection("Description", t.description, sectionOptions));
@@ -543,7 +675,7 @@ Example: zinn task search 'refinement quota' MDR --limit 5`,
543
675
  sections.push(formatSection("Comments", comments, sectionOptions));
544
676
  }
545
677
  if ("activity" in t) {
546
- const history = formatActivityList(presentActivities(t.activity));
678
+ const history = formatActivityList(presentActivities(t.activity, { keysFromEventsOnly: true }));
547
679
  if (history.length > 0) {
548
680
  sections.push(formatSection("History", history, sectionOptions));
549
681
  }
@@ -558,6 +690,7 @@ Show a task with its description, relations, comments, and creation and update t
558
690
  A section is shown when the task has that content. The description prints in full, keeping its line breaks.
559
691
  Task update time advances for edits, label attachment changes, moves, reorders, archiving and unarchiving.
560
692
  With --json, created_at and updated_at are stored epoch milliseconds.
693
+ A claim shows with its holder and when its lease ends, also once it expired.
561
694
  Use --history to include this task's recorded activity, newest first, including reorders and comment changes.
562
695
  Use activity view <activity-id> for full recorded changes. Text times are local with a UTC offset.
563
696
  With --history --json, the activity field contains full activity records, or [] when none are recorded.
@@ -566,6 +699,43 @@ Without --history, JSON omits activity.
566
699
  Examples:
567
700
  zinn task view MDR-1
568
701
  zinn task view MDR-1 --history`,
702
+ },
703
+ blame: {
704
+ summary: "Show the recorded authors of a task's current fields and description lines.",
705
+ effects: { domain: "read", storage: "normal-open" },
706
+ confirmation: { kind: "none" },
707
+ input: taskInputs.blame,
708
+ results: [jsonResult("TaskBlame")],
709
+ run: (args) => {
710
+ const { positionals } = parseArgs({
711
+ args,
712
+ options: taskInputs.blame.options,
713
+ allowPositionals: true,
714
+ strict: true,
715
+ });
716
+ validatePositionals(positionals, taskInputs.blame.forms[0]);
717
+ output(task.blame(positionals[0]), (blame) => {
718
+ const taskMatch = task.getByKey(blame.task.key);
719
+ const board = createColumnBoard();
720
+ return formatTaskBlame(blame, {
721
+ relations: presentRelations(taskMatch, board),
722
+ columnCategory: board(taskMatch.project_id).find((boardColumn) => boardColumn.id === taskMatch.column_id)?.category ?? null,
723
+ isArchived: taskMatch.archived_at != null,
724
+ activityIdPrefixes: abbreviateActivityIds(activity.getIds()),
725
+ });
726
+ });
727
+ },
728
+ help: `${generateCommandUsage("task blame", taskInputs.blame)}
729
+
730
+ Show the recorded authors of a task's current fields, label membership, parent, relations and description lines.
731
+ Active and archived tasks are readable. A reused key selects its current task only.
732
+ Unchanged description lines keep their attribution through exact-line comparisons, including whitespace.
733
+ A terminal newline does not add a line or change its attribution. Missing history is unrecorded.
734
+ Recorded identities are kept as stored. Use activity view <activity-id> to inspect a recorded event.
735
+ With --json, fields contain value and nullable attribution, relations contain their attribution,
736
+ and description contains numbered text lines with nullable attribution.
737
+
738
+ Example: zinn task blame MDR-1`,
569
739
  },
570
740
  edit: {
571
741
  summary: "Edit a task's title, description, priority, deadline, or label attachments.",
@@ -592,14 +762,18 @@ Examples:
592
762
  addLabelNames: values["add-label"],
593
763
  removeLabelNames: values["remove-label"],
594
764
  };
595
- checkFieldsBeforeText(taskEditSchema, fields);
765
+ const expected = taskExpectations.parseValues(values);
766
+ checkFieldsBeforeText(taskEditSchema, { ...fields, expected });
767
+ checkSingleStdinReader(values, ["--description", ...taskExpectations.textFlags]);
596
768
  const description = await resolveTextEdit(values, "--description");
597
769
  // Without a text source nothing was read, so this usage error still comes before any input.
598
770
  if (violatesConstraint(taskEditConstraint, getOptionInputs(values))) {
599
771
  quit("Provide at least one edit flag: --title, --description, --description-file, --priority, --due, --add-label, or --remove-label", undefined, { field: [] });
600
772
  }
601
- const editedTask = task.edit({ ...fields, description }, currentActor());
602
- outputChanges([editedTask], (change) => presentTask(change.task), formatTaskList, (entry) => `${entry.key} was unchanged`);
773
+ const expectedText = await taskExpectations.resolveText(values);
774
+ const editedTask = task.edit({ ...fields, description, expected: { ...expected, ...expectedText } }, currentActor());
775
+ const board = createColumnBoard();
776
+ outputChanges([editedTask], (change) => presentTask(change.task, board), formatTaskList, (entry) => `${entry.key} was unchanged`);
603
777
  },
604
778
  help: `${generateCommandUsage("task edit", taskInputs.edit)}
605
779
 
@@ -612,6 +786,8 @@ ${textFileHelp("--description")}
612
786
 
613
787
  ${textEditHelp("--description")}
614
788
 
789
+ ${taskExpectations.help}
790
+
615
791
  Repeat --add-label or --remove-label for multiple existing labels, ignoring case.
616
792
  The same label cannot be both added and removed.
617
793
  Archived tasks can be edited.
@@ -621,7 +797,8 @@ ${dashValueHelp("--description")}
621
797
 
622
798
  Examples:
623
799
  zinn task edit MDR-1 --title 'Meet the quarterly refinement quota'
624
- zinn task edit MDR-1 --description 'Bring waffles.' --append`,
800
+ zinn task edit MDR-1 --description 'Bring waffles.' --append
801
+ zinn task edit MDR-1 --title 'Refine the Cold Harbor file' --expect-title 'Refine the files'`,
625
802
  guessedFlags: {
626
803
  "--status": (args) => suggestTaskMove(args, taskInputs.edit.options),
627
804
  "--column": (args) => suggestTaskMove(args, taskInputs.edit.options),
@@ -639,17 +816,20 @@ Examples:
639
816
  input: taskInputs.move,
640
817
  results: taskChangeResults,
641
818
  run: (args) => {
642
- const { positionals } = parseArgs({
819
+ const { values, positionals, tokens } = parseArgs({
643
820
  options: taskInputs.move.options,
644
821
  args,
645
822
  allowPositionals: true,
646
823
  strict: true,
824
+ tokens: true,
647
825
  });
826
+ validateUniqueOptions(tokens, taskInputs.move.options);
648
827
  validatePositionals(positionals, taskInputs.move.forms[0]);
649
828
  const taskKeys = positionals.slice(0, -1);
650
829
  const targetColumn = positionals.at(-1);
651
- const moves = task.moveMany({ taskKeys, targetColumn }, currentActor());
652
- outputChanges(moves, (change) => presentTask(change.task), formatTaskList, (movedTask) => `${movedTask.key} was already in the ${movedTask.column} column`);
830
+ const moves = task.moveMany({ taskKeys, targetColumn, fromColumn: values.from }, currentActor());
831
+ const board = createColumnBoard();
832
+ outputChanges(moves, (change) => presentTask(change.task, board), formatTaskList, (movedTask) => `${movedTask.key} was already in the ${movedTask.column} column`);
653
833
  },
654
834
  help: `${generateCommandUsage("task move", taskInputs.move)}
655
835
 
@@ -659,9 +839,12 @@ Each task's column is looked up in its own project.
659
839
 
660
840
  Moving to the current column leaves the task unchanged.
661
841
  Archived tasks must be unarchived before they can be moved.
842
+ With --from, the move fails with a conflict error unless every task is still in that column.
662
843
  If any task cannot be moved, none change.
663
844
 
664
- Example: zinn task move MDR-1 MDR-2 'In Progress'`,
845
+ Examples:
846
+ zinn task move MDR-1 MDR-2 Doing
847
+ zinn task move MDR-1 Doing --from TODO`,
665
848
  guessedFlags: { "--status": suggestTaskMove, "--column": suggestTaskMove },
666
849
  },
667
850
  order: {
@@ -690,7 +873,8 @@ Example: zinn task move MDR-1 MDR-2 'In Progress'`,
690
873
  else {
691
874
  orders = task.orderMany({ taskKeys, direction: form.direction }, currentActor());
692
875
  }
693
- outputChanges(orders, (change) => presentTask(change.task), formatTaskList, (entry) => `${entry.key} was already in that position`);
876
+ const board = createColumnBoard();
877
+ outputChanges(orders, (change) => presentTask(change.task, board), formatTaskList, (entry) => `${entry.key} was already in that position`);
694
878
  },
695
879
  help: `${generateCommandUsage("task order", taskInputs.order)}
696
880
 
@@ -713,7 +897,8 @@ Example: zinn task order MDR-2 before MDR-1`,
713
897
  run: (args) => {
714
898
  const taskKeys = parseTaskKeys(args);
715
899
  const archives = task.archiveMany(taskKeys, currentActor());
716
- outputChanges(archives, (change) => presentTask(change.task), (entries) => formatTaskList(entries, { showsStatus: true }), (archivedTask) => `${archivedTask.key} was already archived`);
900
+ const board = createColumnBoard();
901
+ outputChanges(archives, (change) => presentTask(change.task, board), (entries) => formatTaskList(entries, { showsStatus: true }), (archivedTask) => `${archivedTask.key} was already archived`);
717
902
  },
718
903
  help: `${generateCommandUsage("task archive", taskInputs.archive)}
719
904
 
@@ -735,7 +920,8 @@ Example: zinn task archive MDR-1 MDR-2`,
735
920
  run: (args) => {
736
921
  const taskKeys = parseTaskKeys(args);
737
922
  const unarchives = task.unarchiveMany(taskKeys, currentActor());
738
- outputChanges(unarchives, (change) => presentTask(change.task), (entries) => formatTaskList(entries, { showsStatus: true }), (unarchivedTask) => `${unarchivedTask.key} was already active`);
923
+ const board = createColumnBoard();
924
+ outputChanges(unarchives, (change) => presentTask(change.task, board), (entries) => formatTaskList(entries, { showsStatus: true }), (unarchivedTask) => `${unarchivedTask.key} was already active`);
739
925
  },
740
926
  help: `${generateCommandUsage("task unarchive", taskInputs.archive)}
741
927
 
@@ -747,6 +933,87 @@ With --json, one task prints an object and several print an array.
747
933
  Each task's changed field is 'false' when it was already in the requested state.
748
934
 
749
935
  Example: zinn task unarchive MDR-1 MDR-2`,
936
+ },
937
+ claim: {
938
+ summary: "Claim a task for a lease, so other agents and people can see who works on it.",
939
+ effects: { domain: "update", storage: "normal-open" },
940
+ confirmation: { kind: "none" },
941
+ input: taskInputs.claim,
942
+ results: [jsonResult("TaskChange")],
943
+ run: (args) => {
944
+ const { values, positionals, tokens } = parseArgs({
945
+ args,
946
+ options: taskInputs.claim.options,
947
+ allowPositionals: true,
948
+ strict: true,
949
+ tokens: true,
950
+ });
951
+ validateUniqueOptions(tokens, taskInputs.claim.options);
952
+ validatePositionals(positionals, taskInputs.claim.forms[0]);
953
+ const lease = requireStringOption(taskInputs.claim.options.lease, values.lease, "lease", "A claim needs a lease: use --lease, such as --lease 30m");
954
+ const leaseMs = parseDurationInput(lease, "--lease");
955
+ const isLeaseInRange = leaseMs >= MIN_CLAIM_LEASE_MS && leaseMs <= CLAIM_WORK_LIMIT_MS;
956
+ if (!isLeaseInRange) {
957
+ quit(`Use a lease from ${formatDurationInput(MIN_CLAIM_LEASE_MS)} through ${formatDurationInput(CLAIM_WORK_LIMIT_MS)}`, undefined, { argument: "--lease" });
958
+ }
959
+ const claimed = task.claim({
960
+ taskKey: positionals[0],
961
+ leaseMs,
962
+ force: values.force,
963
+ }, currentActor());
964
+ outputClaimChange(claimed, (entry) => `${entry.key} was unchanged`);
965
+ },
966
+ help: `${generateCommandUsage("task claim", taskInputs.claim)}
967
+
968
+ Claim a task for a lease, so other agents and people can see who works on it.
969
+ --lease takes whole minutes or hours, such as 30m or 2h, from ${formatDurationInput(MIN_CLAIM_LEASE_MS)} through ${formatDurationInput(CLAIM_WORK_LIMIT_MS)}.
970
+ Any change the holder makes to the task, including a comment, renews the claim. So does task heartbeat.
971
+ A claim expires when its lease runs out, or ${formatDurationInput(CLAIM_WORK_LIMIT_MS)} after the holder last changed the task.
972
+ After that limit, only a change to the task renews it.
973
+ Claiming a task you hold renews it with the new lease.
974
+ An expired claim is replaced. A live claim by someone else is a conflict, unless --force takes it over.
975
+ Agents are told apart by their session or thread, so an agent needs one its host sets, or ZINN_SESSION_ID.
976
+ Archived tasks cannot be claimed. Archiving a task or moving it to a done or cancelled column releases its claim.
977
+
978
+ Examples:
979
+ zinn task claim MDR-1 --lease 30m
980
+ zinn task claim MDR-1 --lease 2h --force`,
981
+ },
982
+ heartbeat: {
983
+ summary: "Renew your claim on a task with its current lease.",
984
+ effects: { domain: "update", storage: "normal-open" },
985
+ confirmation: { kind: "none" },
986
+ input: taskInputs.heartbeat,
987
+ results: [jsonResult("TaskChange")],
988
+ run: (args) => {
989
+ const taskKey = parseClaimedTaskKey(args);
990
+ outputClaimChange(task.heartbeat(taskKey, currentActor()), (entry) => `${entry.key} was unchanged`);
991
+ },
992
+ help: `${generateCommandUsage("task heartbeat", taskInputs.heartbeat)}
993
+
994
+ Renew your claim on a task with its current lease.
995
+ It fails when the task has no claim or someone else holds it.
996
+ It also fails ${formatDurationInput(CLAIM_WORK_LIMIT_MS)} after you last changed the task. After that, only a change to the task renews the claim.
997
+
998
+ Example: zinn task heartbeat MDR-1`,
999
+ },
1000
+ release: {
1001
+ summary: "Release your claim on a task.",
1002
+ effects: { domain: "update", storage: "normal-open" },
1003
+ confirmation: { kind: "none" },
1004
+ input: taskInputs.heartbeat,
1005
+ results: [jsonResult("TaskChange")],
1006
+ run: (args) => {
1007
+ const taskKey = parseClaimedTaskKey(args);
1008
+ outputClaimChange(task.release(taskKey, currentActor()), (entry) => `${entry.key} had no claim`);
1009
+ },
1010
+ help: `${generateCommandUsage("task release", taskInputs.heartbeat)}
1011
+
1012
+ Release your claim on a task.
1013
+ Releasing a task without a claim does not do anything. Someone else's claim is a conflict.
1014
+ With --json, changed is false when the task had no claim.
1015
+
1016
+ Example: zinn task release MDR-1`,
750
1017
  },
751
1018
  delete: {
752
1019
  summary: "Permanently delete tasks after confirmation.",
@@ -769,7 +1036,8 @@ Example: zinn task unarchive MDR-1 MDR-2`,
769
1036
  validatePositionals(positionals, taskInputs.delete.forms[0]);
770
1037
  const taskKeys = taskDeleteManySchema.parse(positionals);
771
1038
  const taskMatches = taskKeys.map((taskKey) => task.getByKey(taskKey));
772
- const presented = taskMatches.map(presentTask);
1039
+ const board = createColumnBoard();
1040
+ const presented = taskMatches.map((taskMatch) => presentTask(taskMatch, board));
773
1041
  const canDelete = await confirmAction(`Are you sure you want to delete ${taskMatches.map((match) => match.key).join(", ")}?`, values.yes === true);
774
1042
  if (canDelete) {
775
1043
  task.deleteMany(taskKeys, currentActor());
@@ -799,7 +1067,8 @@ Example: zinn task delete MDR-1 MDR-2`,
799
1067
  results: [jsonResult("TaskChange")],
800
1068
  run: (args) => {
801
1069
  const props = parseTaskLabelArgs(args);
802
- outputChanges([task.label.add(props, currentActor())], (change) => presentTask(change.task), formatTaskList, (entry) => `${entry.key} already had those labels`);
1070
+ const board = createColumnBoard();
1071
+ outputChanges([task.label.add(props, currentActor())], (change) => presentTask(change.task, board), formatTaskList, (entry) => `${entry.key} already had those labels`);
803
1072
  },
804
1073
  help: `${generateCommandUsage("task label add", taskInputs.label_add)}
805
1074
 
@@ -815,7 +1084,8 @@ With --json, changed is false when all the labels were already attached.`,
815
1084
  results: [jsonResult("TaskChange")],
816
1085
  run: (args) => {
817
1086
  const props = parseTaskLabelArgs(args);
818
- outputChanges([task.label.remove(props, currentActor())], (change) => presentTask(change.task), formatTaskList, (entry) => `${entry.key} had none of those labels`);
1087
+ const board = createColumnBoard();
1088
+ outputChanges([task.label.remove(props, currentActor())], (change) => presentTask(change.task, board), formatTaskList, (entry) => `${entry.key} had none of those labels`);
819
1089
  },
820
1090
  help: `${generateCommandUsage("task label remove", taskInputs.label_add)}
821
1091
 
@@ -835,6 +1105,21 @@ function parseTaskKeys(args) {
835
1105
  validatePositionals(positionals, taskInputs.archive.forms[0]);
836
1106
  return positionals;
837
1107
  }
1108
+ function parseClaimedTaskKey(args) {
1109
+ const { positionals } = parseArgs({
1110
+ options: taskInputs.heartbeat.options,
1111
+ args,
1112
+ allowPositionals: true,
1113
+ strict: true,
1114
+ });
1115
+ validatePositionals(positionals, taskInputs.heartbeat.forms[0]);
1116
+ return positionals[0];
1117
+ }
1118
+ /** Prints a claim command's task with its claim and when the lease ends */
1119
+ function outputClaimChange(change, describeUnchanged) {
1120
+ const board = createColumnBoard();
1121
+ outputChanges([change], (claimChange) => presentTask(claimChange.task, board), (entries) => formatTaskList(entries, { showsClaimDetail: true }), describeUnchanged);
1122
+ }
838
1123
  function parseTaskLabelArgs(args) {
839
1124
  const { positionals } = parseArgs({
840
1125
  options: taskInputs.label_add.options,
@@ -855,8 +1140,8 @@ function parseNewTaskRelations(flags) {
855
1140
  ];
856
1141
  return targetsByType.flatMap(([relation_type, targetTaskKeys]) => targetTaskKeys.map((targetTaskKey) => ({ relation_type, targetTaskKey })));
857
1142
  }
858
- function parseDue(value) {
859
- return value?.toLowerCase() === "none" ? null : parseTimestampInput(value, "--due");
1143
+ function parseDue(value, flag = "--due") {
1144
+ return value?.toLowerCase() === "none" ? null : parseTimestampInput(value, flag);
860
1145
  }
861
1146
  function parseDeadlineFilters(values) {
862
1147
  const dueSince = parseTimestampInput(values["due-since"], "--due-since");
@@ -867,7 +1152,7 @@ function parseDeadlineFilters(values) {
867
1152
  }
868
1153
  return { dueSince, dueUntil };
869
1154
  }
870
- function parsePriority(value) {
1155
+ function parsePriority(value, flag = "--priority") {
871
1156
  const normalizedPriority = value?.toLowerCase();
872
1157
  if (normalizedPriority === undefined) {
873
1158
  return undefined;
@@ -878,7 +1163,7 @@ function parsePriority(value) {
878
1163
  const priority = taskPrioritySchema.safeParse(normalizedPriority);
879
1164
  if (!priority.success) {
880
1165
  quit("Priority must be low, medium, high, urgent, or none", undefined, {
881
- argument: "--priority",
1166
+ argument: flag,
882
1167
  });
883
1168
  }
884
1169
  return priority.data;