@zinn-dev/cli 0.44.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 (56) hide show
  1. package/package.json +2 -2
  2. package/skills/zinn/SKILL.md +7 -9
  3. package/src/capabilities-schema.d.ts +5 -1
  4. package/src/column-hint.js +1 -3
  5. package/src/database.d.ts +1 -2
  6. package/src/database.js +1 -6
  7. package/src/duration-input.d.ts +7 -0
  8. package/src/duration-input.js +31 -0
  9. package/src/errors.d.ts +22 -0
  10. package/src/errors.js +30 -5
  11. package/src/expected-values.d.ts +48 -0
  12. package/src/expected-values.js +60 -0
  13. package/src/follow.d.ts +9 -0
  14. package/src/follow.js +58 -0
  15. package/src/input.d.ts +0 -8
  16. package/src/input.js +36 -16
  17. package/src/lib.d.ts +5 -2
  18. package/src/lib.js +18 -8
  19. package/src/list-continuation.js +1 -4
  20. package/src/presentation/activity-presentation.d.ts +2 -0
  21. package/src/presentation/activity-presentation.js +58 -3
  22. package/src/presentation/column-presentation.d.ts +9 -4
  23. package/src/presentation/column-presentation.js +29 -12
  24. package/src/presentation/doctor-presentation.d.ts +4 -0
  25. package/src/presentation/doctor-presentation.js +24 -0
  26. package/src/presentation/relation-presentation.js +2 -1
  27. package/src/presentation/task-blame-presentation.d.ts +1 -4
  28. package/src/presentation/task-blame-presentation.js +1 -1
  29. package/src/presentation/task-presentation.d.ts +2 -0
  30. package/src/presentation/task-presentation.js +39 -2
  31. package/src/result-schemas.d.ts +353 -58
  32. package/src/result-schemas.js +46 -2
  33. package/src/results.d.ts +6 -2
  34. package/src/results.js +9 -3
  35. package/src/routes/activity-router.d.ts +12 -3
  36. package/src/routes/activity-router.js +93 -59
  37. package/src/routes/aliases.js +1 -0
  38. package/src/routes/comment-router.d.ts +24 -6
  39. package/src/routes/comment-router.js +15 -5
  40. package/src/routes/doctor-router.d.ts +39 -0
  41. package/src/routes/doctor-router.js +103 -0
  42. package/src/routes/label-router.d.ts +39 -6
  43. package/src/routes/label-router.js +22 -5
  44. package/src/routes/project-router.d.ts +60 -11
  45. package/src/routes/project-router.js +100 -33
  46. package/src/routes/restore-router.js +2 -2
  47. package/src/routes/router.js +3 -7
  48. package/src/routes/routes.d.ts +404 -33
  49. package/src/routes/routes.js +4 -0
  50. package/src/routes/skill-router.d.ts +25 -0
  51. package/src/routes/skill-router.js +96 -0
  52. package/src/routes/task-router.d.ts +231 -13
  53. package/src/routes/task-router.js +247 -19
  54. package/src/text-edit.d.ts +2 -2
  55. package/src/text-input.d.ts +19 -1
  56. package/src/text-input.js +26 -5
@@ -1,11 +1,12 @@
1
1
  import { jsonResult } from "../results.js";
2
2
  import { parseArgs } from "node:util";
3
- import { column, project, columnOrderSchema, columnDeleteSchema, projectCreateSchema, projectEditSchema, } from "@zinn-dev/core";
3
+ import { column, project, columnCategorySchema, columnOrderSchema, columnDeleteSchema, projectCreateSchema, projectEditSchema, } from "@zinn-dev/core";
4
4
  import { CliError } from "../errors.js";
5
5
  import { generateCommandUsage, getOptionInputs, noInput, violatesConstraint } from "../input.js";
6
6
  import { confirmationDescription, canPrompt, confirmAction, dashValueHelp, diagnostic, output, outputChanges, quit, validatePositionals, validateOrderForms, requireStringOption, validateUniqueOptions, } from "../lib.js";
7
7
  import { resolveTextEdit, textEditHelp, textEditOptions, textEditConstraints, } from "../text-edit.js";
8
- import { checkFieldsBeforeText, resolveTextInput, textFileHelp, textFileOption, textSourceConstraint, } from "../text-input.js";
8
+ import { expectedValueFlags } from "../expected-values.js";
9
+ import { checkFieldsBeforeText, checkSingleStdinReader, resolveTextInput, textFileHelp, textFileOption, textSourceConstraint, } from "../text-input.js";
9
10
  import { formatColumnList, presentColumn, presentColumnTaskCounts, } from "../presentation/column-presentation.js";
10
11
  import { formatProjectList, presentProject } from "../presentation/project-presentation.js";
11
12
  import { formatSection } from "../presentation/section.js";
@@ -15,6 +16,34 @@ const projectEditConstraint = {
15
16
  kind: "atLeastOne",
16
17
  members: ["option:name", "option:description", "option:description-file"],
17
18
  };
19
+ const projectExpectations = expectedValueFlags({
20
+ name: { field: "name", option: { type: "string", value: { kind: "text", name: "text" } } },
21
+ description: { field: "description", text: true },
22
+ });
23
+ const columnCategoryOption = {
24
+ type: "string",
25
+ value: { kind: "enum", name: "category", choices: columnCategorySchema.options },
26
+ };
27
+ const columnCategoryValues = columnCategorySchema.options.join(", ");
28
+ const columnEditConstraint = {
29
+ kind: "atLeastOne",
30
+ members: ["option:name", "option:category"],
31
+ };
32
+ /** Asks before a category change that would change whether a column's tasks count as open or closed */
33
+ async function confirmCategoryChange(projectKey, columnName, category, isPreconfirmed) {
34
+ const columnMatch = column.getByName(projectKey, columnName);
35
+ const isSameCategory = columnMatch.category === category;
36
+ if (isPreconfirmed || isSameCategory) {
37
+ return true;
38
+ }
39
+ const { taskCount, archivedTaskCount } = column
40
+ .getTaskCountsByProjectKey(projectKey)
41
+ .columns.find((entry) => entry.column.id === columnMatch.id);
42
+ if (taskCount + archivedTaskCount === 0) {
43
+ return true;
44
+ }
45
+ return confirmAction(`Column "${columnMatch.name}" holds ${taskCount} active and ${archivedTaskCount} archived tasks. Change its category from ${columnMatch.category} to ${category}?`, false);
46
+ }
18
47
  const projectInputs = {
19
48
  create: {
20
49
  options: {
@@ -48,6 +77,7 @@ const projectInputs = {
48
77
  description: { type: "string", value: { kind: "text", name: "text" } },
49
78
  "description-file": textFileOption,
50
79
  ...textEditOptions,
80
+ ...projectExpectations.options,
51
81
  },
52
82
  forms: [
53
83
  {
@@ -59,8 +89,9 @@ const projectInputs = {
59
89
  textSourceConstraint("--description"),
60
90
  ...textEditConstraints("--description"),
61
91
  projectEditConstraint,
92
+ ...projectExpectations.constraints,
62
93
  ],
63
- notes: [requiredProjectDescription, textEditHelp("--description")],
94
+ notes: [requiredProjectDescription, textEditHelp("--description"), projectExpectations.help],
64
95
  },
65
96
  delete: {
66
97
  options: { yes: { type: "boolean" } },
@@ -74,7 +105,7 @@ const projectInputs = {
74
105
  notes: [requiredProjectDescription],
75
106
  },
76
107
  column_create: {
77
- options: {},
108
+ options: { category: { ...columnCategoryOption, required: true } },
78
109
  forms: [
79
110
  {
80
111
  id: "default",
@@ -98,7 +129,11 @@ const projectInputs = {
98
129
  notes: [requiredProjectDescription],
99
130
  },
100
131
  column_edit: {
101
- options: { name: { type: "string", required: true, value: { kind: "text", name: "text" } } },
132
+ options: {
133
+ name: { type: "string", value: { kind: "text", name: "text" } },
134
+ category: columnCategoryOption,
135
+ yes: { type: "boolean" },
136
+ },
102
137
  forms: [
103
138
  {
104
139
  id: "default",
@@ -108,7 +143,7 @@ const projectInputs = {
108
143
  ],
109
144
  },
110
145
  ],
111
- constraints: [],
146
+ constraints: [columnEditConstraint],
112
147
  },
113
148
  column_delete: {
114
149
  options: { yes: { type: "boolean" } },
@@ -292,10 +327,13 @@ Example: zinn project view MDR`,
292
327
  validateUniqueOptions(tokens, projectInputs.edit.options);
293
328
  validatePositionals(positionals, projectInputs.edit.forms[0]);
294
329
  const projectChoice = chooseProjectKey(positionals[0], { required: true });
330
+ const expected = projectExpectations.parseValues(values);
295
331
  checkFieldsBeforeText(projectEditSchema, {
296
332
  projectKey: projectChoice.key,
297
333
  name: values.name,
334
+ expected,
298
335
  });
336
+ checkSingleStdinReader(values, ["--description", ...projectExpectations.textFlags]);
299
337
  const description = await resolveTextEdit(values, "--description");
300
338
  // Without a text source nothing was read, so this usage error still comes before any input
301
339
  if (violatesConstraint(projectEditConstraint, getOptionInputs(values))) {
@@ -304,7 +342,13 @@ Example: zinn project view MDR`,
304
342
  });
305
343
  }
306
344
  checkDefaultProject(projectChoice);
307
- const editedProject = project.edit({ projectKey: projectChoice.key, name: values.name, description }, currentActor());
345
+ const expectedText = await projectExpectations.resolveText(values);
346
+ const editedProject = project.edit({
347
+ projectKey: projectChoice.key,
348
+ name: values.name,
349
+ description,
350
+ expected: { ...expected, ...expectedText },
351
+ }, currentActor());
308
352
  outputChanges([editedProject], (change) => presentProject(change.project), formatProjectList, (entry) => `Project ${entry.key} was unchanged`);
309
353
  },
310
354
  help: `${generateCommandUsage("project edit", projectInputs.edit)}
@@ -317,11 +361,14 @@ ${textFileHelp("--description")}
317
361
 
318
362
  ${textEditHelp("--description")}
319
363
 
364
+ ${projectExpectations.help}
365
+
320
366
  ${dashValueHelp("--description")}
321
367
 
322
368
  Examples:
323
369
  zinn project edit MDR --name 'Macrodata Refinement'
324
- zinn project edit MDR --description database --replacing board --all`,
370
+ zinn project edit MDR --description database --replacing board --all
371
+ zinn project edit MDR --name 'Macrodata Refinement' --expect-name 'Macrodata'`,
325
372
  },
326
373
  delete: {
327
374
  summary: "Permanently delete a project and all of its columns and tasks after confirmation.",
@@ -393,29 +440,34 @@ Example: zinn project delete MDR`,
393
440
  input: projectInputs.column_create,
394
441
  results: [jsonResult("Column")],
395
442
  run: (args) => {
396
- const { positionals } = parseArgs({
443
+ const { values, positionals, tokens } = parseArgs({
397
444
  options: projectInputs.column_create.options,
398
445
  args,
399
446
  allowPositionals: true,
400
447
  strict: true,
448
+ tokens: true,
401
449
  });
450
+ validateUniqueOptions(tokens, projectInputs.column_create.options);
402
451
  validatePositionals(positionals, projectInputs.column_create.forms[0]);
403
- const projectKey = positionals[0];
404
- const columnName = positionals[1];
405
- try {
406
- const createdColumn = column.create({ projectKey, name: columnName }, currentActor());
407
- output(presentColumn(createdColumn), (entry) => formatColumnList([entry], { showsProject: true }));
408
- }
409
- catch (err) {
410
- throw err;
411
- }
452
+ const category = requireStringOption(projectInputs.column_create.options.category, values.category, "category", `Provide the column's category with --category: ${columnCategoryValues}`);
453
+ const createdColumn = column.create({
454
+ projectKey: positionals[0],
455
+ name: positionals[1],
456
+ category: category,
457
+ }, currentActor());
458
+ output(presentColumn(createdColumn), (entry) => formatColumnList([entry], { showsProject: true }));
412
459
  },
413
460
  help: `${generateCommandUsage("project column create", projectInputs.column_create)}
414
461
 
415
462
  Add a column at the end of a project's board.
416
463
  Names are trimmed, cannot be blank or contain line breaks or control characters, and must be unique within the project regardless of casing.
417
464
 
418
- Example: zinn project column create MDR Boardlog`,
465
+ --category is required and says what the column's tasks are to Zinn, whatever the column is called.
466
+ Category values: ${columnCategoryValues}.
467
+ Tasks in done and cancelled columns are closed: task next skips them, and they no longer block tasks that depend on them.
468
+ task next hands out tasks in todo columns, then backlog columns.
469
+
470
+ Example: zinn project column create MDR Boardlog --category backlog`,
419
471
  },
420
472
  list: {
421
473
  summary: "List a project's columns in board order with their unarchived task counts.",
@@ -445,12 +497,15 @@ ${requiredProjectDescription}
445
497
  Example: zinn project column list MDR`,
446
498
  },
447
499
  edit: {
448
- summary: "Rename a column.",
500
+ summary: "Rename a column or change its category.",
449
501
  effects: { domain: "update", storage: "normal-open" },
450
- confirmation: { kind: "none" },
502
+ confirmation: {
503
+ kind: "prompt",
504
+ description: `Only asks when changing the category of a column that holds tasks. ${confirmationDescription}`,
505
+ },
451
506
  input: projectInputs.column_edit,
452
507
  results: [jsonResult("ColumnChange")],
453
- run: (args) => {
508
+ run: async (args) => {
454
509
  const { values, positionals, tokens } = parseArgs({
455
510
  args,
456
511
  options: projectInputs.column_edit.options,
@@ -460,19 +515,29 @@ Example: zinn project column list MDR`,
460
515
  });
461
516
  validateUniqueOptions(tokens, projectInputs.column_edit.options);
462
517
  validatePositionals(positionals, projectInputs.column_edit.forms[0]);
463
- const name = requireStringOption(projectInputs.column_edit.options.name, values.name, "name", "Provide an edit flag: --name");
464
- const editedColumn = column.edit({
465
- projectKey: positionals[0],
466
- columnName: positionals[1],
467
- name,
468
- }, currentActor());
518
+ if (violatesConstraint(columnEditConstraint, getOptionInputs(values))) {
519
+ quit("Provide an edit flag: --name or --category", undefined, { field: [] });
520
+ }
521
+ const projectKey = positionals[0];
522
+ const columnName = positionals[1];
523
+ const category = values.category;
524
+ if (category !== undefined) {
525
+ const isConfirmed = await confirmCategoryChange(projectKey, columnName, category, values.yes === true);
526
+ if (!isConfirmed) {
527
+ diagnostic("Column edit cancelled");
528
+ return;
529
+ }
530
+ }
531
+ const editedColumn = column.edit({ projectKey, columnName, name: values.name, category }, currentActor());
469
532
  outputChanges([editedColumn], (change) => presentColumn(change.column), (entries) => formatColumnList(entries, { showsProject: true }), (entry) => `Column "${entry.name}" was unchanged`);
470
533
  },
471
534
  help: `${generateCommandUsage("project column edit", projectInputs.column_edit)}
472
535
 
473
- Rename a column.
474
- The --name flag is required.
475
- With --json, changed is false when the name already matches.
536
+ Rename a column, change its category, or both.
537
+ Provide --name, --category or both.
538
+ Category values: ${columnCategoryValues}.
539
+ Changing the category of a column that holds tasks, active or archived, asks first: it changes which of them count as open or closed. Use --yes to change it without a prompt, including with --json or without a terminal.
540
+ With --json, changed is false when the name and category already match.
476
541
 
477
542
  Columns are matched by name, and matching is case-insensitive.
478
543
  Names are trimmed, and must remain unique within the same project.
@@ -480,7 +545,9 @@ Changing only the casing of a column's own name is allowed.
480
545
 
481
546
  ${dashValueHelp("--name")}
482
547
 
483
- Example: zinn project column edit MDR 'In Progress' --name Refining`,
548
+ Examples:
549
+ zinn project column edit MDR Doing --name Refining
550
+ zinn project column edit MDR Shipped --category done --yes`,
484
551
  },
485
552
  order: {
486
553
  summary: "Change a column's position on the project's board.",
@@ -522,7 +589,7 @@ Columns are matched by name, and matching is case-insensitive.
522
589
  Ordering to the current position, or before or after itself, leaves the column unchanged.
523
590
  With --json, changed is false when the column was already in that position.
524
591
 
525
- Example: zinn project column order MDR Review before 'In Progress'`,
592
+ Example: zinn project column order MDR Review before Doing`,
526
593
  },
527
594
  delete: {
528
595
  summary: "Delete an empty project column after confirmation.",
@@ -39,7 +39,7 @@ export const restoreCommand = {
39
39
  const isPreconfirmed = values.yes === true;
40
40
  // A backup that would be refused is refused before the prompt.
41
41
  if (!isPreconfirmed) {
42
- backup.check({ ...build, path });
42
+ backup.check({ ...build, path, storage });
43
43
  }
44
44
  const isConfirmed = await askConfirmation(`Replace the database at ${databasePath} with the backup ${path}? The current database is saved to ${backupDirectory} first.`, isPreconfirmed);
45
45
  if (!isConfirmed) {
@@ -84,7 +84,7 @@ Replace the database with the one in a backup file, such as one saved by \`zinn
84
84
  The current database is saved first, in the same place as \`zinn backup\`, and the restore is applied completely or not at all.
85
85
  A backup with an older schema version is restored at that version. Zinn then upgrades it like any older database: by itself, except for ~/.zinn run from a source checkout, which needs \`zinn migrate\`.
86
86
  Restoring onto a missing database creates it inside an existing Zinn folder.
87
- Fails, leaving the database as it is, when the backup has a newer schema version than this Zinn or none at all, is damaged, or is not a Zinn database.
87
+ Fails, leaving the database as it is, when the backup has a newer schema version than this Zinn or none at all, is damaged, is not a Zinn database, is the database itself, or changes after restore checked it.
88
88
  Use --yes to skip the confirmation prompt, for example in scripts or with --json.
89
89
 
90
90
  Example: zinn restore ~/.zinn/backups/2026-10-06T12-30-05Z-cli-0.40.0-1a2b3c4d.sqlite`,
@@ -1,16 +1,16 @@
1
1
  import { parseArgs } from "node:util";
2
- import { routerOptions, helpSpellings, versionSpellings, usageLabel, isAllowLegacyReadFlag, isHelpFlag, isRouterFlag, splitAtOptionSeparator, } from "../input.js";
2
+ import { routerOptions, helpSpellings, versionSpellings, usageLabel, isHelpFlag, isRouterFlag, splitAtOptionSeparator, } from "../input.js";
3
3
  import { getCommandAliases } from "./aliases.js";
4
4
  import { classifyFailure, CliError } from "../errors.js";
5
5
  import { quotedColumnHint } from "../column-hint.js";
6
6
  import { formatCell } from "../presentation/row-layout.js";
7
7
  import { formatOverview } from "../overview.js";
8
- import { boundParserMessage, dashValueHelp, diagnostic, failureMessage, finishRun, isDebugOutputEnabled, isParseArgsError, parseArgsFailure, prepareOutput, quit, renderFailure, setLegacyReadAllowed, UsageError, validateUniqueOptions, } from "../lib.js";
8
+ import { boundParserMessage, dashValueHelp, diagnostic, failureMessage, finishRun, isDebugOutputEnabled, isParseArgsError, parseArgsFailure, prepareOutput, quit, renderFailure, UsageError, validateUniqueOptions, } from "../lib.js";
9
9
  import { noteMatchedRun, noteParseArgsThrew, noteUnmatchedRun } from "../telemetry.js";
10
10
  function getIsRunnable(obj) {
11
11
  return Object.hasOwn(obj, "run");
12
12
  }
13
- // --json and --allow-legacy-read can each be given once, like a command's own flags.
13
+ // --json can be given once, like a command's own flags.
14
14
  function validateRouterFlags(routableArgs) {
15
15
  const { tokens } = parseArgs({
16
16
  args: routableArgs.filter(isRouterFlag),
@@ -77,7 +77,6 @@ Options:
77
77
  ${helpSpellings.join(", ")} Show help
78
78
  ${versionSpellings.join(", ")} Show version
79
79
  --json Print command output as JSON
80
- --allow-legacy-read Read a database without a schema version, best effort and read-only
81
80
 
82
81
  Commands:
83
82
  ${formatCommands(parsedRoutes, "")}
@@ -176,9 +175,6 @@ async function route(parsedRoutes, rawArgs, beforeRun) {
176
175
  // Anything after "--" belongs to the command, so "--json" there is search text, not a flag.
177
176
  const { optionWords: routableArgs, passthroughWords: passthroughArgs } = splitAtOptionSeparator(rawArgs);
178
177
  const filteredRoutableArgs = routableArgs.filter((arg) => !isRouterFlag(arg));
179
- if (routableArgs.some(isAllowLegacyReadFlag)) {
180
- setLegacyReadAllowed(true);
181
- }
182
178
  // A help flag asks for help with the command words before it, so nothing after it is read.
183
179
  const helpFlagIndex = filteredRoutableArgs.findIndex(isHelpFlag);
184
180
  const isHelpRequest = helpFlagIndex !== -1;