@zinn-dev/cli 0.41.0 → 0.43.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 (81) hide show
  1. package/README.md +11 -689
  2. package/index.js +2 -2
  3. package/package.json +4 -4
  4. package/skills/zinn/SKILL.md +1 -1
  5. package/src/capabilities-schema.d.ts +25 -26
  6. package/src/capabilities-schema.js +17 -82
  7. package/src/capabilities.d.ts +11 -3
  8. package/src/capabilities.js +12 -4
  9. package/src/column-hint.d.ts +3 -0
  10. package/src/column-hint.js +225 -0
  11. package/src/database.js +1 -4
  12. package/src/errors.d.ts +31 -3
  13. package/src/errors.js +77 -20
  14. package/src/input.d.ts +154 -43
  15. package/src/input.js +86 -13
  16. package/src/lib.d.ts +43 -6
  17. package/src/lib.js +134 -38
  18. package/src/list-continuation.d.ts +11 -0
  19. package/src/list-continuation.js +18 -0
  20. package/src/list-limit.d.ts +11 -0
  21. package/src/list-limit.js +17 -0
  22. package/src/presentation/activity-presentation.d.ts +9 -1
  23. package/src/presentation/activity-presentation.js +124 -28
  24. package/src/presentation/capabilities-presentation.d.ts +2 -0
  25. package/src/presentation/capabilities-presentation.js +3 -0
  26. package/src/presentation/column-presentation.d.ts +6 -0
  27. package/src/presentation/column-presentation.js +10 -0
  28. package/src/presentation/comment-presentation.d.ts +15 -0
  29. package/src/presentation/comment-presentation.js +29 -0
  30. package/src/presentation/description-presentation.d.ts +4 -0
  31. package/src/presentation/description-presentation.js +28 -5
  32. package/src/presentation/label-presentation.d.ts +8 -0
  33. package/src/presentation/label-presentation.js +28 -0
  34. package/src/presentation/project-presentation.d.ts +11 -0
  35. package/src/presentation/project-presentation.js +27 -0
  36. package/src/presentation/relation-presentation.d.ts +12 -0
  37. package/src/presentation/relation-presentation.js +87 -0
  38. package/src/presentation/row-layout.d.ts +1 -1
  39. package/src/presentation/row-layout.js +6 -5
  40. package/src/presentation/task-presentation.d.ts +3 -3
  41. package/src/presentation/task-presentation.js +29 -19
  42. package/src/presentation/text-width.d.ts +2 -0
  43. package/src/presentation/text-width.js +43 -0
  44. package/src/presentation/time.d.ts +3 -1
  45. package/src/presentation/time.js +5 -2
  46. package/src/project.d.ts +14 -5
  47. package/src/project.js +18 -6
  48. package/src/result-schemas.d.ts +279 -26
  49. package/src/result-schemas.js +72 -4
  50. package/src/results.d.ts +34 -17
  51. package/src/results.js +19 -0
  52. package/src/routes/activity-router.d.ts +79 -2
  53. package/src/routes/activity-router.js +209 -38
  54. package/src/routes/aliases.d.ts +2 -0
  55. package/src/routes/aliases.js +11 -0
  56. package/src/routes/capabilities-router.js +9 -3
  57. package/src/routes/comment-router.d.ts +41 -18
  58. package/src/routes/comment-router.js +65 -48
  59. package/src/routes/label-router.d.ts +57 -7
  60. package/src/routes/label-router.js +84 -39
  61. package/src/routes/project-router.d.ts +74 -12
  62. package/src/routes/project-router.js +131 -66
  63. package/src/routes/relation-router.d.ts +13 -9
  64. package/src/routes/relation-router.js +116 -116
  65. package/src/routes/restore-router.js +3 -6
  66. package/src/routes/router.d.ts +1 -1
  67. package/src/routes/router.js +88 -32
  68. package/src/routes/routes.d.ts +420 -50
  69. package/src/routes/routes.js +4 -0
  70. package/src/routes/task-router.d.ts +189 -30
  71. package/src/routes/task-router.js +254 -158
  72. package/src/routes/whoami-router.d.ts +21 -0
  73. package/src/routes/whoami-router.js +31 -0
  74. package/src/text-edit.d.ts +13 -9
  75. package/src/text-edit.js +23 -18
  76. package/src/text-input.d.ts +47 -0
  77. package/src/text-input.js +187 -0
  78. package/src/timestamp-input.d.ts +3 -0
  79. package/src/timestamp-input.js +31 -0
  80. package/src/types.d.ts +32 -9
  81. package/src/types.js +9 -1
@@ -1,17 +1,23 @@
1
1
  import { jsonResult, taskDetailResults, taskChangeResults } from "../results.js";
2
2
  import { parseArgs } from "node:util";
3
- import { task, project, positiveIntegerPattern, searchLimitMessage, parseTaskKey, taskPrioritySchema, } from "@zinn-dev/core";
3
+ import { task, project, parseTaskKey, taskCreateSchema, taskEditSchema, taskDeleteManySchema, taskPrioritySchema, taskSortSchema, } from "@zinn-dev/core";
4
+ import { listLimitOption, listLimitDescription, parseListLimit } from "../list-limit.js";
5
+ import { formatListContinuation } from "../list-continuation.js";
6
+ import { parseTimestampInput } from "../timestamp-input.js";
4
7
  import { CliError } from "../errors.js";
5
8
  import { generateCommandUsage, taskKeyPositional, archiveConstraint, getOptionInputs, violatesConstraint, } from "../input.js";
6
- import { confirmationDescription, confirmAction, dashValueHelp, diagnostic, output, quit, validatePositionals, validateOrderForms, requireStringOption, validateUniqueOptions, } from "../lib.js";
9
+ import { confirmationDescription, confirmAction, dashValueHelp, diagnostic, output, outputChanges, quit, validatePositionals, validateOrderForms, requireStringOption, renameFlag, validateUniqueOptions, } from "../lib.js";
7
10
  import { resolveTextEdit, textEditHelp, textEditOptions, textEditConstraints, } from "../text-edit.js";
8
- import { formatRelations, presentRelations, relationRouter } from "./relation-router.js";
9
- import { commentRouter, formatComments, presentComments } from "./comment-router.js";
11
+ import { checkFieldsBeforeText, resolveTextInput, textFileHelp, textFileOption, textSourceConstraint, } from "../text-input.js";
10
12
  import { currentActor } from "../actor.js";
11
- import { resolveProjectKey, projectScopeConstraint, requiredProjectDescription, projectScopeDescription, } from "../project.js";
13
+ import { checkDefaultProject, chooseProjectKey, resolveProjectKey, projectScopeConstraint, requiredProjectDescription, projectScopeDescription, } from "../project.js";
14
+ import { relationRouter } from "./relation-router.js";
15
+ import { commentRouter } from "./comment-router.js";
16
+ import { formatRelationList, presentRelations } from "../presentation/relation-presentation.js";
17
+ import { formatCommentList, presentComments } from "../presentation/comment-presentation.js";
12
18
  import { formatSection } from "../presentation/section.js";
13
19
  import { formatActivityList, presentActivities } from "../presentation/activity-presentation.js";
14
- import { formatTaskList, formatTaskListWithStatus, formatTaskRow, presentTask, } from "../presentation/task-presentation.js";
20
+ import { formatTaskList, formatTaskTimestamps, presentTask, } from "../presentation/task-presentation.js";
15
21
  // A column is changed with task move, so a guessed --status or --column suggests it with the same task keys.
16
22
  function suggestTaskMove(args, options = {}) {
17
23
  const { values, positionals } = parseArgs({
@@ -34,12 +40,42 @@ const priorityOption = {
34
40
  description: "Omission leaves priority unassigned on creation and unchanged on edit. none clears priority; JSON uses null.",
35
41
  },
36
42
  };
43
+ const dueOption = {
44
+ type: "string",
45
+ value: {
46
+ kind: "timestamp",
47
+ name: "timestamp",
48
+ 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
+ },
50
+ };
51
+ const deadlineFilterOptions = {
52
+ "due-since": {
53
+ type: "string",
54
+ value: {
55
+ kind: "timestamp",
56
+ name: "timestamp",
57
+ description: "Inclusive lower deadline bound. Integer epoch milliseconds or a timestamp with seconds and Z or a numeric offset. Fractions have 1 to 3 digits. Undated tasks do not match.",
58
+ },
59
+ },
60
+ "due-until": {
61
+ type: "string",
62
+ value: {
63
+ kind: "timestamp",
64
+ name: "timestamp",
65
+ description: "Inclusive upper deadline bound in the same formats as --due-since. Must be at or after --due-since. Undated tasks do not match.",
66
+ },
67
+ },
68
+ };
69
+ const deadlineHelp = "--due accepts integer epoch milliseconds or YYYY-MM-DDTHH:mm:ss[.SSS] with Z or a numeric offset such as +01:00. Fractional seconds have 1 to 3 digits. Use --due none to clear it. Omission leaves it unset on creation and unchanged on edit.";
70
+ const deadlineFilterHelp = "--due-since and --due-until select deadlines inclusively, using integer epoch milliseconds or timestamps with seconds and Z or a numeric offset. Fractional seconds have 1 to 3 digits. Either bound may appear alone. --due-until must be at or after --due-since. Undated tasks do not match. All filters apply before --limit.";
37
71
  const taskEditConstraint = {
38
72
  kind: "atLeastOne",
39
73
  members: [
40
74
  "option:title",
41
75
  "option:description",
76
+ "option:description-file",
42
77
  "option:priority",
78
+ "option:due",
43
79
  "option:add-label",
44
80
  "option:remove-label",
45
81
  ],
@@ -49,7 +85,9 @@ const taskInputs = {
49
85
  options: {
50
86
  title: { type: "string", required: true, value: { kind: "text", name: "text" } },
51
87
  description: { type: "string", value: { kind: "text", name: "text" } },
88
+ "description-file": textFileOption,
52
89
  priority: priorityOption,
90
+ due: dueOption,
53
91
  label: { type: "string", multiple: true, value: { kind: "label-name", name: "name" } },
54
92
  column: { type: "string", value: { kind: "column-name", name: "name" } },
55
93
  parent: { type: "string", value: { kind: "task-key", name: "task-key" } },
@@ -67,16 +105,30 @@ const taskInputs = {
67
105
  positionals: [{ name: "project-key", min: 0, max: 1, value: { kind: "project-key" } }],
68
106
  },
69
107
  ],
70
- constraints: [],
108
+ constraints: [textSourceConstraint("--description")],
71
109
  notes: [requiredProjectDescription],
72
110
  },
73
111
  list: {
74
112
  options: {
113
+ ...deadlineFilterOptions,
114
+ limit: listLimitOption,
115
+ sort: {
116
+ type: "string",
117
+ value: { kind: "enum", name: "key", choices: taskSortSchema.options },
118
+ },
75
119
  archived: { type: "boolean" },
76
120
  all: { type: "boolean" },
77
121
  "all-projects": { type: "boolean" },
78
122
  label: { type: "string", multiple: true, value: { kind: "label-name", name: "name" } },
79
123
  column: { type: "string", value: { kind: "column-name", name: "name" } },
124
+ "starting-after": {
125
+ type: "string",
126
+ 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",
130
+ },
131
+ },
80
132
  },
81
133
  forms: [
82
134
  {
@@ -85,17 +137,18 @@ const taskInputs = {
85
137
  },
86
138
  ],
87
139
  constraints: [archiveConstraint, projectScopeConstraint],
88
- notes: [projectScopeDescription],
140
+ notes: [
141
+ projectScopeDescription,
142
+ "A --starting-after task must match every selection filter. Cursor resolution uses current task identities before list filtering.",
143
+ ],
89
144
  },
90
145
  search: {
91
146
  options: {
147
+ ...deadlineFilterOptions,
92
148
  archived: { type: "boolean" },
93
149
  all: { type: "boolean" },
94
150
  "all-projects": { type: "boolean" },
95
- limit: {
96
- type: "string",
97
- value: { kind: "positive-integer", name: "n", pattern: `^${positiveIntegerPattern}$` },
98
- },
151
+ limit: listLimitOption,
99
152
  label: { type: "string", multiple: true, value: { kind: "label-name", name: "name" } },
100
153
  },
101
154
  forms: [
@@ -127,8 +180,10 @@ const taskInputs = {
127
180
  options: {
128
181
  title: { type: "string", value: { kind: "text", name: "text" } },
129
182
  description: { type: "string", value: { kind: "text", name: "text" } },
183
+ "description-file": textFileOption,
130
184
  ...textEditOptions,
131
185
  priority: priorityOption,
186
+ due: dueOption,
132
187
  "add-label": { type: "string", multiple: true, value: { kind: "label-name", name: "name" } },
133
188
  "remove-label": {
134
189
  type: "string",
@@ -142,7 +197,11 @@ const taskInputs = {
142
197
  positionals: [taskKeyPositional],
143
198
  },
144
199
  ],
145
- constraints: [...textEditConstraints("--description"), taskEditConstraint],
200
+ constraints: [
201
+ textSourceConstraint("--description"),
202
+ ...textEditConstraints("--description"),
203
+ taskEditConstraint,
204
+ ],
146
205
  notes: [textEditHelp("--description")],
147
206
  },
148
207
  move: {
@@ -164,19 +223,26 @@ const taskInputs = {
164
223
  {
165
224
  id: "absolute",
166
225
  positionals: [
167
- taskKeyPositional,
226
+ { ...taskKeyPositional, max: null },
168
227
  {
169
228
  name: "direction",
170
229
  min: 1,
171
230
  max: 1,
172
- value: { kind: "enum", choices: ["top", "up", "down", "bottom"] },
231
+ value: { kind: "enum", choices: ["top", "bottom"] },
173
232
  },
174
233
  ],
175
234
  },
176
235
  {
177
- id: "relative",
236
+ id: "step",
178
237
  positionals: [
179
238
  taskKeyPositional,
239
+ { name: "direction", min: 1, max: 1, value: { kind: "enum", choices: ["up", "down"] } },
240
+ ],
241
+ },
242
+ {
243
+ id: "relative",
244
+ positionals: [
245
+ { ...taskKeyPositional, max: null },
180
246
  {
181
247
  name: "direction",
182
248
  min: 1,
@@ -204,7 +270,7 @@ const taskInputs = {
204
270
  forms: [
205
271
  {
206
272
  id: "default",
207
- positionals: [taskKeyPositional],
273
+ positionals: [{ ...taskKeyPositional, max: null }],
208
274
  },
209
275
  ],
210
276
  constraints: [],
@@ -230,7 +296,19 @@ export const taskRouter = {
230
296
  confirmation: { kind: "none" },
231
297
  input: taskInputs.create,
232
298
  results: [jsonResult("Task")],
233
- run: (args) => {
299
+ guessedFlags: {
300
+ "--status": (args) => [
301
+ "task",
302
+ "create",
303
+ ...renameFlag(args, taskInputs.create.options, "status", "column"),
304
+ ],
305
+ "--body": (args) => [
306
+ "task",
307
+ "create",
308
+ ...renameFlag(args, taskInputs.create.options, "body", "description"),
309
+ ],
310
+ },
311
+ run: async (args) => {
234
312
  const { values, positionals, tokens } = parseArgs({
235
313
  args,
236
314
  options: taskInputs.create.options,
@@ -240,22 +318,27 @@ export const taskRouter = {
240
318
  });
241
319
  validateUniqueOptions(tokens, taskInputs.create.options);
242
320
  validatePositionals(positionals, taskInputs.create.forms[0]);
243
- const projectKey = resolveProjectKey(positionals[0], { required: true });
321
+ const projectChoice = chooseProjectKey(positionals[0], { required: true });
244
322
  const title = requireStringOption(taskInputs.create.options.title, values.title, "title", "A task needs at least a title: use --title");
245
- const projectMatch = project.getByKey(projectKey);
246
- if (projectMatch == null) {
247
- throw new CliError(`Project with key "${project.standardizeKey(projectKey)}" does not exist`, "not_found", { entity: "project", key: project.standardizeKey(projectKey), source: "explicit" });
248
- }
249
- const createdTask = task.create({
250
- project_id: projectMatch.id,
323
+ const priority = parsePriority(values.priority);
324
+ const fields = {
251
325
  title,
252
- description: values.description ?? null,
253
- priority: parsePriority(values.priority),
326
+ priority,
327
+ due_at: parseDue(values.due),
254
328
  labelNames: values.label,
255
329
  columnName: values.column,
256
330
  relations: parseNewTaskRelations(values),
257
- }, currentActor());
258
- output(presentTask(createdTask), formatTaskRow);
331
+ };
332
+ checkFieldsBeforeText(taskCreateSchema, fields);
333
+ const description = await resolveTextInput(values.description, values["description-file"], "--description");
334
+ checkDefaultProject(projectChoice);
335
+ const projectKey = projectChoice.key;
336
+ const projectMatch = project.getByKey(projectKey);
337
+ if (projectMatch == null) {
338
+ throw new CliError(`Project with key "${project.standardizeKey(projectKey)}" does not exist`, "not_found", { entity: "project", key: project.standardizeKey(projectKey), source: "explicit" });
339
+ }
340
+ const createdTask = task.create({ ...fields, project_id: projectMatch.id, description: description ?? null }, currentActor());
341
+ output(presentTask(createdTask), (entry) => formatTaskList([entry]));
259
342
  },
260
343
  help: `${generateCommandUsage("task create", taskInputs.create)}
261
344
 
@@ -263,19 +346,19 @@ Create a task at the bottom of a column. Without --column, it starts in the proj
263
346
 
264
347
  ${requiredProjectDescription}
265
348
 
266
- Column names are matched case-insensitively. An unknown column is an error and creates nothing.
267
- Priority defaults to none (unassigned). Priority values are case-insensitive.
268
- Priority values: ${priorityOption.value.choices.join(", ")}.
269
- Repeat --label to attach multiple existing labels. Unknown labels are errors.
270
- Label names are matched case-insensitively.
271
- Titles are trimmed and cannot be blank or contain line breaks or control characters.
349
+ Priority values: ${priorityOption.value.choices.join(", ")}; defaults to none.
350
+ ${deadlineHelp}
351
+ Repeat --label to attach multiple existing labels.
352
+ ${textFileHelp("--description")}
272
353
 
273
354
  ${dashValueHelp("--description")}
274
355
 
275
- Relations are set from the new task's perspective: it becomes a subtask of --parent, depends on --depends-on,
356
+ The new task is a subtask of --parent, depends on --depends-on,
276
357
  is a duplicate of --duplicate-of, and is related to --related.
277
358
  Repeat --depends-on and --related to name several tasks.
278
- A target task that does not exist causes an error, and task creation is aborted.
359
+ Each target may have one relation type. Identical repeated requests count once.
360
+ Different relation types for the same target abort creation.
361
+ Unknown columns, labels or related tasks abort creation.
279
362
 
280
363
  Examples:
281
364
  zinn task create MDR --title 'Refine the numbers' --description 'Meet the quarterly quota' --label urgent
@@ -303,25 +386,48 @@ Examples:
303
386
  }
304
387
  const projectKey = resolveProjectKey(positionals[0], { allProjects: values["all-projects"] });
305
388
  const archive = values.all ? "all" : values.archived ? "archived" : "active";
306
- const tasks = task.getAll({
389
+ const limit = parseListLimit(values.limit);
390
+ const sort = taskSortSchema.optional().safeParse(values.sort);
391
+ if (!sort.success) {
392
+ quit(`Unknown sort "${values.sort}". Use ${taskSortSchema.options.join(", ")}`, undefined, {
393
+ argument: "--sort",
394
+ });
395
+ }
396
+ const page = task.getPage({
397
+ ...parseDeadlineFilters(values),
398
+ limit,
399
+ sort: sort.data,
307
400
  projectKey,
308
401
  archive,
309
402
  labelNames: values.label,
310
403
  columnName: values.column,
404
+ startingAfter: values["starting-after"],
311
405
  });
312
- output(tasks.map(presentTask), (presentedTasks) => formatTaskList(presentedTasks, { showsStatus: values.all }));
406
+ output(page.tasks.map(presentTask), (presentedTasks) => formatTaskList(presentedTasks, { showsStatus: values.all }));
407
+ if (page.hasMore) {
408
+ const selectionTokens = tokens.filter((token) => token.kind !== "option" || token.name !== "all-projects");
409
+ 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)}`);
411
+ }
313
412
  },
314
413
  help: `${generateCommandUsage("task list", taskInputs.list)}
315
414
 
316
415
  List active tasks by default.
317
416
  ${projectScopeDescription}
318
417
  Use --archived to list archived tasks or --all to list both.
319
- Use --label to filter for tasks with a specific label, no case-sensitivity is applied for matching.
320
- Use --column to filter by an exact column name without case sensitivty.
321
- Column, label and archive filters can be combined together. No matches print nothing, or return [] for --json, and exit successfully.
418
+ Repeat --label to require every specified label.
419
+ --column matches an exact column name. Column and label matching ignore case.
420
+ All supplied filters must match.
421
+ --sort activity lists the most recently active tasks first, including comments and relations.
422
+ Equal activity times keep board order. Without --sort, board order is preserved.
423
+ --sort due lists earliest deadlines first, with undated tasks last. Equal deadlines keep board order. Task positions stay unchanged.
424
+ ${deadlineFilterHelp}
425
+ --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
+ When additional matches remain after --limit, stderr gives a shell-quoted command to continue, including with --json.
322
430
 
323
- Each row shows a task's key, column, priority marker, title, and labels. --all adds an Active or Archived status after the key.
324
- Priority markers: - unassigned, L low, M medium, H high, U urgent.
325
431
  Use 'task view' to see a task's full details, including its description.
326
432
 
327
433
  Example: zinn task list MDR --label cli`,
@@ -347,17 +453,14 @@ Example: zinn task list MDR --label cli`,
347
453
  quit('Use either "--archived" or "--all", not both', undefined, { argument: "--archived" });
348
454
  }
349
455
  const archive = values.all ? "all" : values.archived ? "archived" : "active";
350
- const limitPattern = new RegExp(taskInputs.search.options.limit.value.pattern);
351
- if (values.limit !== undefined && !limitPattern.test(values.limit)) {
352
- quit(searchLimitMessage, undefined, { argument: "--limit" });
353
- }
354
456
  const isTaskKeyQuery = parseTaskKey(query.trim()) !== null;
355
457
  const projectKey = resolveProjectKey(positionals[1], {
356
458
  allProjects: values["all-projects"],
357
459
  useDefault: !isTaskKeyQuery,
358
460
  });
359
- const limit = values.limit === undefined ? undefined : Number(values.limit);
461
+ const limit = parseListLimit(values.limit);
360
462
  const result = task.search({
463
+ ...parseDeadlineFilters(values),
361
464
  query,
362
465
  projectKey,
363
466
  archive,
@@ -378,21 +481,17 @@ ${projectScopeDescription}
378
481
  Each word matches the start of a word, ignoring case and accents: e.g. "auth" finds "Authentication".
379
482
  Every word must match. Quote a query with several words.
380
483
 
381
- A query that is exactly a task key, such as MDR-1, lists that task first.
382
- If given, a task key query overrides the configured default, and a typed project key still filters the search.
383
- Other results are ordered by relevance, with title matches weighted highest.
384
- Equally relevant tasks are ordered by project key, then task number.
484
+ A task-key query overrides the configured default project; a typed project key still filters it.
385
485
 
386
486
  By default, only active tasks are searched. Use --archived to search archived tasks or --all to search both.
387
- When archived matches are hidden, a note is printed to say how many.
388
- Use --limit to show at most <n> results.
389
- Use --label to filter for tasks with a specific label, no case-sensitivity is applied for matching.
390
- A search result's output matches that of 'task list'.
487
+ --limit <n>: ${listLimitDescription}
488
+ Repeat --label to require every specified label, ignoring case.
489
+ ${deadlineFilterHelp}
391
490
 
392
491
  Example: zinn task search 'refinement quota' MDR --limit 5`,
393
492
  },
394
493
  view: {
395
- summary: "Show a task with its description, relations, and comments.",
494
+ summary: "Show a task with its description, relations, comments, and creation and update times.",
396
495
  effects: { domain: "read", storage: "normal-open" },
397
496
  confirmation: { kind: "none" },
398
497
  input: taskInputs.view,
@@ -428,8 +527,8 @@ Example: zinn task search 'refinement quota' MDR --limit 5`,
428
527
  const sectionOptions = {
429
528
  separatorWidth: hasTerminalWidth ? terminalWidth : MIN_SECTION_SEPARATOR_WIDTH,
430
529
  };
431
- const relations = formatRelations(t.relations);
432
- const comments = formatComments(t.comments);
530
+ const relations = formatRelationList(t.relations);
531
+ const comments = formatCommentList(t.comments);
433
532
  const isArchived = t.status === "Archived";
434
533
  const sections = [
435
534
  formatTaskList([t], { showsStatus: isArchived, showsFullPriority: true }),
@@ -449,13 +548,16 @@ Example: zinn task search 'refinement quota' MDR --limit 5`,
449
548
  sections.push(formatSection("History", history, sectionOptions));
450
549
  }
451
550
  }
551
+ sections.push(formatTaskTimestamps(t));
452
552
  return sections.join("\n\n");
453
553
  });
454
554
  },
455
555
  help: `${generateCommandUsage("task view", taskInputs.view)}
456
556
 
457
- Show a task with its description, relations, and comments.
557
+ Show a task with its description, relations, comments, and creation and update times.
458
558
  A section is shown when the task has that content. The description prints in full, keeping its line breaks.
559
+ Task update time advances for edits, label attachment changes, moves, reorders, archiving and unarchiving.
560
+ With --json, created_at and updated_at are stored epoch milliseconds.
459
561
  Use --history to include this task's recorded activity, newest first, including reorders and comment changes.
460
562
  Use activity view <activity-id> for full recorded changes. Text times are local with a UTC offset.
461
563
  With --history --json, the activity field contains full activity records, or [] when none are recorded.
@@ -466,12 +568,12 @@ Examples:
466
568
  zinn task view MDR-1 --history`,
467
569
  },
468
570
  edit: {
469
- summary: "Edit a task's title, description, priority, or label attachments.",
571
+ summary: "Edit a task's title, description, priority, deadline, or label attachments.",
470
572
  effects: { domain: "update", storage: "normal-open" },
471
573
  confirmation: { kind: "none" },
472
574
  input: taskInputs.edit,
473
- results: [jsonResult("Task")],
474
- run: (args) => {
575
+ results: [jsonResult("TaskChange")],
576
+ run: async (args) => {
475
577
  const { values, positionals, tokens } = parseArgs({
476
578
  args,
477
579
  options: taskInputs.edit.options,
@@ -482,36 +584,38 @@ Examples:
482
584
  validateUniqueOptions(tokens, taskInputs.edit.options);
483
585
  validatePositionals(positionals, taskInputs.edit.forms[0]);
484
586
  const taskKey = positionals[0];
485
- const description = resolveTextEdit(values.description, values, "--description");
486
- if (violatesConstraint(taskEditConstraint, getOptionInputs({ ...values, description }))) {
487
- quit("Provide at least one edit flag: --title, --description, --priority, --add-label, or --remove-label", undefined, { field: [] });
488
- }
489
- const editedTask = task.edit({
587
+ const fields = {
490
588
  taskKey,
491
589
  title: values.title,
492
- description,
493
590
  priority: parsePriority(values.priority),
591
+ due_at: parseDue(values.due),
494
592
  addLabelNames: values["add-label"],
495
593
  removeLabelNames: values["remove-label"],
496
- }, currentActor());
497
- output(presentTask(editedTask), formatTaskRow);
594
+ };
595
+ checkFieldsBeforeText(taskEditSchema, fields);
596
+ const description = await resolveTextEdit(values, "--description");
597
+ // Without a text source nothing was read, so this usage error still comes before any input.
598
+ if (violatesConstraint(taskEditConstraint, getOptionInputs(values))) {
599
+ quit("Provide at least one edit flag: --title, --description, --description-file, --priority, --due, --add-label, or --remove-label", undefined, { field: [] });
600
+ }
601
+ const editedTask = task.edit({ ...fields, description }, currentActor());
602
+ outputChanges([editedTask], (change) => presentTask(change.task), formatTaskList, (entry) => `${entry.key} was unchanged`);
498
603
  },
499
604
  help: `${generateCommandUsage("task edit", taskInputs.edit)}
500
605
 
501
- Edit a task's title, description, priority, or label attachments.
502
- Use --priority none to clear priority. Priority values are case-insensitive.
606
+ Edit a task's title, description, priority, deadline, or label attachments.
607
+ ${deadlineHelp}
608
+ Use --priority none to clear priority.
503
609
  Priority values: ${priorityOption.value.choices.join(", ")}.
504
610
  Provide at least one edit flag. Use --description '' to clear the description.
611
+ ${textFileHelp("--description")}
505
612
 
506
613
  ${textEditHelp("--description")}
507
614
 
508
- Repeat --add-label or --remove-label for multiple existing labels.
509
- Label names are matched case-insensitively.
510
- Adding an attached label or removing an unattached label does not do anything.
511
- Archived tasks can be edited.
512
-
615
+ Repeat --add-label or --remove-label for multiple existing labels, ignoring case.
513
616
  The same label cannot be both added and removed.
514
- Titles are trimmed and cannot be blank or contain line breaks or control characters.
617
+ Archived tasks can be edited.
618
+ With --json, changed is false when all supplied values already match.
515
619
 
516
620
  ${dashValueHelp("--description")}
517
621
 
@@ -521,6 +625,11 @@ Examples:
521
625
  guessedFlags: {
522
626
  "--status": (args) => suggestTaskMove(args, taskInputs.edit.options),
523
627
  "--column": (args) => suggestTaskMove(args, taskInputs.edit.options),
628
+ "--body": (args) => [
629
+ "task",
630
+ "edit",
631
+ ...renameFlag(args, taskInputs.edit.options, "body", "description"),
632
+ ],
524
633
  },
525
634
  },
526
635
  move: {
@@ -540,31 +649,27 @@ Examples:
540
649
  const taskKeys = positionals.slice(0, -1);
541
650
  const targetColumn = positionals.at(-1);
542
651
  const moves = task.moveMany({ taskKeys, targetColumn }, currentActor());
543
- outputTaskChanges(moves, formatTaskList, (movedTask) => `${movedTask.key} was already in the ${movedTask.column} column`);
652
+ outputChanges(moves, (change) => presentTask(change.task), formatTaskList, (movedTask) => `${movedTask.key} was already in the ${movedTask.column} column`);
544
653
  },
545
654
  help: `${generateCommandUsage("task move", taskInputs.move)}
546
655
 
547
656
  Move tasks to another column in their projects.
548
- Moving a task to a different column lists it last in that column,
549
- matching placement at the bottom of a visual kanban column.
550
- Several tasks are moved in the order given, and each task's column is looked up in its own project.
657
+ Moved tasks go to the bottom of the destination column in the order given.
658
+ Each task's column is looked up in its own project.
551
659
 
552
- Giving a task's current column as the target will not do anything, and a note says so.
660
+ Moving to the current column leaves the task unchanged.
553
661
  Archived tasks must be unarchived before they can be moved.
554
- On bulk changes, if any task cannot be moved, the bulk operation is aborted.
555
-
556
- With --json, one task prints an object and several print an array.
557
- Each task's changed field is 'false' when it was already in the requested state.
662
+ If any task cannot be moved, none change.
558
663
 
559
664
  Example: zinn task move MDR-1 MDR-2 'In Progress'`,
560
665
  guessedFlags: { "--status": suggestTaskMove, "--column": suggestTaskMove },
561
666
  },
562
667
  order: {
563
- summary: "Change a task's position within its current column.",
668
+ summary: "Change task positions within their current column.",
564
669
  effects: { domain: "update", storage: "normal-open" },
565
670
  confirmation: { kind: "none" },
566
671
  input: taskInputs.order,
567
- results: [jsonResult("Task")],
672
+ results: taskChangeResults,
568
673
  run: (args) => {
569
674
  const { positionals } = parseArgs({
570
675
  options: taskInputs.order.options,
@@ -573,23 +678,29 @@ Example: zinn task move MDR-1 MDR-2 'In Progress'`,
573
678
  strict: true,
574
679
  });
575
680
  const form = validateOrderForms(positionals, taskInputs.order.forms);
576
- const taskKey = positionals[0];
681
+ const taskKeys = positionals.slice(0, form.directionIndex);
682
+ let orders;
577
683
  if (form.id === "relative") {
578
- const direction = positionals[1];
579
- const orderedTask = task.order({ taskKey, direction, targetTaskKey: positionals[2] }, currentActor());
580
- output(presentTask(orderedTask), formatTaskRow);
684
+ orders = task.orderMany({
685
+ taskKeys,
686
+ direction: form.direction,
687
+ targetTaskKey: positionals[form.directionIndex + 1],
688
+ }, currentActor());
581
689
  }
582
690
  else {
583
- const direction = positionals[1];
584
- const orderedTask = task.order({ taskKey, direction }, currentActor());
585
- output(presentTask(orderedTask), formatTaskRow);
691
+ orders = task.orderMany({ taskKeys, direction: form.direction }, currentActor());
586
692
  }
693
+ outputChanges(orders, (change) => presentTask(change.task), formatTaskList, (entry) => `${entry.key} was already in that position`);
587
694
  },
588
695
  help: `${generateCommandUsage("task order", taskInputs.order)}
589
696
 
590
- Change a task's position within its current column.
591
- Use top or bottom for either end, up or down for one position,
592
- or before or after to place it relative to another task.
697
+ Change task positions within their current column.
698
+ Order the first task as requested, then each next task after the one before it.
699
+ Use top or bottom for either end, or before or after for placement relative to another task.
700
+ Up and down take one task and move it one position.
701
+ Several tasks must be distinct active tasks in the same project and column. Their target cannot be among them.
702
+ Ordering to the current position, or before or after itself, leaves the task unchanged.
703
+ With --json, one task prints an object and several an array. Changed is false for an unchanged step.
593
704
 
594
705
  Example: zinn task order MDR-2 before MDR-1`,
595
706
  },
@@ -602,7 +713,7 @@ Example: zinn task order MDR-2 before MDR-1`,
602
713
  run: (args) => {
603
714
  const taskKeys = parseTaskKeys(args);
604
715
  const archives = task.archiveMany(taskKeys, currentActor());
605
- outputTaskChanges(archives, formatTaskListWithStatus, (archivedTask) => `${archivedTask.key} was already archived`);
716
+ outputChanges(archives, (change) => presentTask(change.task), (entries) => formatTaskList(entries, { showsStatus: true }), (archivedTask) => `${archivedTask.key} was already archived`);
606
717
  },
607
718
  help: `${generateCommandUsage("task archive", taskInputs.archive)}
608
719
 
@@ -624,7 +735,7 @@ Example: zinn task archive MDR-1 MDR-2`,
624
735
  run: (args) => {
625
736
  const taskKeys = parseTaskKeys(args);
626
737
  const unarchives = task.unarchiveMany(taskKeys, currentActor());
627
- outputTaskChanges(unarchives, formatTaskListWithStatus, (unarchivedTask) => `${unarchivedTask.key} was already active`);
738
+ outputChanges(unarchives, (change) => presentTask(change.task), (entries) => formatTaskList(entries, { showsStatus: true }), (unarchivedTask) => `${unarchivedTask.key} was already active`);
628
739
  },
629
740
  help: `${generateCommandUsage("task unarchive", taskInputs.archive)}
630
741
 
@@ -638,11 +749,14 @@ Each task's changed field is 'false' when it was already in the requested state.
638
749
  Example: zinn task unarchive MDR-1 MDR-2`,
639
750
  },
640
751
  delete: {
641
- summary: "Permanently delete a task after confirmation.",
752
+ summary: "Permanently delete tasks after confirmation.",
642
753
  effects: { domain: "delete", storage: "normal-open" },
643
754
  confirmation: { kind: "prompt", description: confirmationDescription },
644
755
  input: taskInputs.delete,
645
- results: [jsonResult("Task")],
756
+ results: [
757
+ jsonResult("Task", { kind: "positionalCount", name: "task-key", min: 1, max: 1 }),
758
+ jsonResult("TaskList", { kind: "positionalCount", name: "task-key", min: 2, max: null }),
759
+ ],
646
760
  run: async (args) => {
647
761
  const { values, positionals, tokens } = parseArgs({
648
762
  args,
@@ -653,29 +767,26 @@ Example: zinn task unarchive MDR-1 MDR-2`,
653
767
  });
654
768
  validateUniqueOptions(tokens, taskInputs.delete.options);
655
769
  validatePositionals(positionals, taskInputs.delete.forms[0]);
656
- const taskKey = positionals[0];
657
- try {
658
- const taskMatch = task.getByKey(taskKey);
659
- const canDelete = await confirmAction(`Are you sure you want to delete ${taskKey}?`, values.yes === true);
660
- const presented = presentTask(taskMatch);
661
- if (canDelete) {
662
- task.delete(taskKey, currentActor());
663
- output(presented, (t) => `Deleted ${formatTaskRow(t)}`);
664
- }
665
- else {
666
- output(presented, (t) => `Deletion cancelled for ${formatTaskRow(t)}`);
667
- }
668
- }
669
- catch (err) {
670
- throw err;
770
+ const taskKeys = taskDeleteManySchema.parse(positionals);
771
+ const taskMatches = taskKeys.map((taskKey) => task.getByKey(taskKey));
772
+ const presented = taskMatches.map(presentTask);
773
+ const canDelete = await confirmAction(`Are you sure you want to delete ${taskMatches.map((match) => match.key).join(", ")}?`, values.yes === true);
774
+ if (canDelete) {
775
+ task.deleteMany(taskKeys, currentActor());
671
776
  }
777
+ output(presented.length === 1 ? presented[0] : presented, (entries) => formatTaskList(Array.isArray(entries) ? entries : [entries], {
778
+ prefix: canDelete ? "Deleted " : "Deletion cancelled for ",
779
+ }));
672
780
  },
673
781
  help: `${generateCommandUsage("task delete", taskInputs.delete)}
674
782
 
675
- Permanently delete a task after confirmation.
783
+ Permanently delete one or more tasks, including archived tasks, after one confirmation.
784
+ Give task keys from any project, separated by space. If any of the tasks cannot be deleted, none are deleted.
785
+ Every key must exist and be distinct, ignoring case, before confirmation.
676
786
  Use --yes to skip the confirmation prompt, for example in scripts or with --json.
787
+ With --json, one task prints an object and several an array.
677
788
 
678
- Example: zinn task delete MDR-1`,
789
+ Example: zinn task delete MDR-1 MDR-2`,
679
790
  },
680
791
  relation: relationRouter,
681
792
  comment: commentRouter,
@@ -685,29 +796,32 @@ Example: zinn task delete MDR-1`,
685
796
  effects: { domain: "update", storage: "normal-open" },
686
797
  confirmation: { kind: "none" },
687
798
  input: taskInputs.label_add,
688
- results: [jsonResult("Task")],
799
+ results: [jsonResult("TaskChange")],
689
800
  run: (args) => {
690
801
  const props = parseTaskLabelArgs(args);
691
- output(presentTask(task.label.add(props, currentActor())), formatTaskRow);
802
+ outputChanges([task.label.add(props, currentActor())], (change) => presentTask(change.task), formatTaskList, (entry) => `${entry.key} already had those labels`);
692
803
  },
693
804
  help: `${generateCommandUsage("task label add", taskInputs.label_add)}
694
805
 
695
806
  Add existing labels to a task. Label names are matched case-insensitively.
696
- Already attached labels are unchanged.`,
807
+ Already attached labels are unchanged.
808
+ With --json, changed is false when all the labels were already attached.`,
697
809
  },
698
810
  remove: {
699
811
  summary: "Remove existing labels from a task. Label names are matched case-insensitively.",
700
812
  effects: { domain: "update", storage: "normal-open" },
701
813
  confirmation: { kind: "none" },
702
814
  input: taskInputs.label_add,
703
- results: [jsonResult("Task")],
815
+ results: [jsonResult("TaskChange")],
704
816
  run: (args) => {
705
817
  const props = parseTaskLabelArgs(args);
706
- output(presentTask(task.label.remove(props, currentActor())), formatTaskRow);
818
+ outputChanges([task.label.remove(props, currentActor())], (change) => presentTask(change.task), formatTaskList, (entry) => `${entry.key} had none of those labels`);
707
819
  },
708
820
  help: `${generateCommandUsage("task label remove", taskInputs.label_add)}
709
821
 
710
- Remove existing labels from a task. Label names are matched case-insensitively.`,
822
+ Remove existing labels from a task. Label names are matched case-insensitively.
823
+ Labels that are not attached are unchanged.
824
+ With --json, changed is false when none of the labels were attached.`,
711
825
  },
712
826
  },
713
827
  };
@@ -721,36 +835,6 @@ function parseTaskKeys(args) {
721
835
  validatePositionals(positionals, taskInputs.archive.forms[0]);
722
836
  return positionals;
723
837
  }
724
- /**
725
- * Prints the changed tasks as rows, or as JSON: an object for one task and an array for several.
726
- * JSON includes each task's `changed` flag, and each unchanged task also gets a note on stderr.
727
- */
728
- function outputTaskChanges(changes, formatTasks, describeUnchanged) {
729
- const presentedChanges = changes.map((change) => {
730
- const presentedTask = presentTask(change.task);
731
- return {
732
- key: presentedTask.key,
733
- status: presentedTask.status,
734
- column: presentedTask.column,
735
- title: presentedTask.title,
736
- description: presentedTask.description,
737
- priority: presentedTask.priority,
738
- labels: presentedTask.labels,
739
- changed: change.changed,
740
- };
741
- });
742
- if (presentedChanges.length === 1) {
743
- output(presentedChanges[0], (presentedChange) => formatTasks([presentedChange]));
744
- }
745
- else {
746
- output(presentedChanges, formatTasks);
747
- }
748
- for (const presentedChange of presentedChanges) {
749
- if (!presentedChange.changed) {
750
- diagnostic(describeUnchanged(presentedChange));
751
- }
752
- }
753
- }
754
838
  function parseTaskLabelArgs(args) {
755
839
  const { positionals } = parseArgs({
756
840
  options: taskInputs.label_add.options,
@@ -771,6 +855,18 @@ function parseNewTaskRelations(flags) {
771
855
  ];
772
856
  return targetsByType.flatMap(([relation_type, targetTaskKeys]) => targetTaskKeys.map((targetTaskKey) => ({ relation_type, targetTaskKey })));
773
857
  }
858
+ function parseDue(value) {
859
+ return value?.toLowerCase() === "none" ? null : parseTimestampInput(value, "--due");
860
+ }
861
+ function parseDeadlineFilters(values) {
862
+ const dueSince = parseTimestampInput(values["due-since"], "--due-since");
863
+ const dueUntil = parseTimestampInput(values["due-until"], "--due-until");
864
+ const hasReversedBounds = dueSince !== undefined && dueUntil !== undefined && dueSince > dueUntil;
865
+ if (hasReversedBounds) {
866
+ quit("--due-until must be at or after --due-since", undefined, { argument: "--due-until" });
867
+ }
868
+ return { dueSince, dueUntil };
869
+ }
774
870
  function parsePriority(value) {
775
871
  const normalizedPriority = value?.toLowerCase();
776
872
  if (normalizedPriority === undefined) {