@zinn-dev/cli 0.46.0 → 0.47.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 (53) hide show
  1. package/package.json +2 -2
  2. package/skills/zinn/SKILL.md +1 -1
  3. package/src/capabilities-schema.d.ts +74 -0
  4. package/src/capabilities-schema.js +44 -0
  5. package/src/capabilities.d.ts +2 -0
  6. package/src/capabilities.js +2 -0
  7. package/src/column-hint.js +2 -9
  8. package/src/errors.d.ts +1 -0
  9. package/src/errors.js +1 -0
  10. package/src/input.d.ts +30 -0
  11. package/src/input.js +18 -0
  12. package/src/lib.d.ts +73 -5
  13. package/src/lib.js +69 -13
  14. package/src/presentation/activity-presentation.d.ts +2 -1
  15. package/src/presentation/activity-presentation.js +21 -6
  16. package/src/presentation/color.d.ts +12 -0
  17. package/src/presentation/color.js +12 -0
  18. package/src/presentation/project-presentation.d.ts +4 -1
  19. package/src/presentation/project-presentation.js +18 -0
  20. package/src/presentation/relation-presentation.js +8 -20
  21. package/src/presentation/section.d.ts +7 -4
  22. package/src/presentation/section.js +21 -7
  23. package/src/presentation/task-blame-presentation.d.ts +2 -1
  24. package/src/presentation/task-blame-presentation.js +4 -4
  25. package/src/presentation/task-presentation.d.ts +12 -1
  26. package/src/presentation/task-presentation.js +60 -9
  27. package/src/result-schemas.d.ts +93 -14
  28. package/src/result-schemas.js +1 -0
  29. package/src/routes/activity-router.d.ts +1 -1
  30. package/src/routes/activity-router.js +15 -31
  31. package/src/routes/backup-router.js +2 -9
  32. package/src/routes/capabilities-router.js +2 -9
  33. package/src/routes/comment-router.d.ts +2 -6
  34. package/src/routes/comment-router.js +13 -61
  35. package/src/routes/doctor-router.js +2 -9
  36. package/src/routes/info-router.js +2 -9
  37. package/src/routes/label-router.js +6 -43
  38. package/src/routes/migrate-router.js +2 -9
  39. package/src/routes/project-router.js +14 -100
  40. package/src/routes/reindex-router.js +2 -9
  41. package/src/routes/relation-router.d.ts +10 -4
  42. package/src/routes/relation-router.js +7 -18
  43. package/src/routes/restore-router.js +2 -11
  44. package/src/routes/router.js +32 -11
  45. package/src/routes/routes.d.ts +29 -30
  46. package/src/routes/skill-router.js +3 -18
  47. package/src/routes/task-router.d.ts +28 -28
  48. package/src/routes/task-router.js +62 -195
  49. package/src/routes/whoami-router.js +2 -9
  50. package/src/telemetry.js +3 -4
  51. package/src/types.d.ts +5 -1
  52. package/src/views.d.ts +117 -0
  53. package/src/views.js +54 -0
@@ -6,8 +6,8 @@ import { formatListContinuation } from "../list-continuation.js";
6
6
  import { parseTimestampInput } from "../timestamp-input.js";
7
7
  import { durationPattern, formatDurationInput, parseDurationInput } from "../duration-input.js";
8
8
  import { CliError } from "../errors.js";
9
- import { generateCommandUsage, taskKeyPositional, archiveConstraint, getOptionInputs, violatesConstraint, } from "../input.js";
10
- import { confirmationDescription, confirmAction, dashValueHelp, diagnostic, getOutputMode, output, outputChanges, quit, validatePositionals, validateTaskKey, validateOrderForms, requireStringOption, renameFlag, validateUniqueOptions, } from "../lib.js";
9
+ import { generateCommandUsage, taskKeyPositional, archiveConstraint, getOptionInputs, parseArgsOptions, violatesConstraint, } from "../input.js";
10
+ import { confirmationDescription, confirmAction, dashValueHelp, diagnostic, getOutputMode, output, outputChanges, quit, parseCommandArgs, validateTaskKey, validateOrderForms, requireStringOption, } from "../lib.js";
11
11
  import { resolveTextEdit, textEditHelp, textEditOptions, textEditConstraints, } from "../text-edit.js";
12
12
  import { expectedValueFlags } from "../expected-values.js";
13
13
  import { checkFieldsBeforeText, checkSingleStdinReader, resolveTextInput, textFileHelp, textFileOption, textSourceConstraint, } from "../text-input.js";
@@ -15,13 +15,13 @@ import { currentActor } from "../actor.js";
15
15
  import { checkDefaultProject, chooseProjectKey, projectScopeConstraint, requiredProjectDescription, projectScopeDescription, } from "../project.js";
16
16
  import { relationRouter } from "./relation-router.js";
17
17
  import { commentRouter } from "./comment-router.js";
18
- import { formatRelationList, presentRelations } from "../presentation/relation-presentation.js";
19
- import { formatCommentList, presentComments } from "../presentation/comment-presentation.js";
20
- import { formatSection } from "../presentation/section.js";
21
- import { abbreviateActivityIds, formatActivityList, presentActivities, } from "../presentation/activity-presentation.js";
18
+ import { presentRelations } from "../presentation/relation-presentation.js";
19
+ import { presentComments } from "../presentation/comment-presentation.js";
20
+ import { abbreviateActivityIds, presentActivities } from "../presentation/activity-presentation.js";
22
21
  import { formatTaskBlame } from "../presentation/task-blame-presentation.js";
22
+ import { readTerminalProps } from "../presentation/color.js";
23
23
  import { createColumnBoard } from "../presentation/column-presentation.js";
24
- import { formatTaskList, formatTaskTimestamps, getLabelColorsByName, presentTask, presentTaskSearchResults, presentTasks, } from "../presentation/task-presentation.js";
24
+ import { formatTaskDetail, formatTaskList, getLabelColorsByName, presentTask, presentTaskSearchResults, presentTasks, } from "../presentation/task-presentation.js";
25
25
  // A column is changed with task move, so a guessed --status or --column suggests it with the same task keys.
26
26
  function suggestTaskMove(args, options = {}) {
27
27
  const { values, positionals } = parseArgs({
@@ -32,7 +32,10 @@ function suggestTaskMove(args, options = {}) {
32
32
  });
33
33
  const guessedColumn = values.status ?? values.column;
34
34
  const columnWords = typeof guessedColumn === "string" ? [guessedColumn] : [];
35
- return ["task", "move", ...positionals, ...columnWords];
35
+ return {
36
+ args: ["task", "move", ...positionals, ...columnWords],
37
+ guidance: "Use task move with the destination column as a positional argument.",
38
+ };
36
39
  }
37
40
  // Project view lists the archived count beside the columns, so "Archived" reads like a move target.
38
41
  const archiveTargetNames = ["archive", "archived"];
@@ -41,6 +44,7 @@ const searchMatchesConstraint = {
41
44
  input: "option:with-matches",
42
45
  requires: "option:json",
43
46
  };
47
+ const columnFilterHelp = "--column matches an exact name in the selected projects, ignoring case. An unknown name reports the available columns.";
44
48
  /** Moves tasks, and points a move to a missing Archived column at task archive. */
45
49
  function moveOrPointToArchive(taskKeys, targetColumn, fromColumn) {
46
50
  try {
@@ -131,11 +135,16 @@ const taskEditConstraint = {
131
135
  "option:remove-label",
132
136
  ],
133
137
  };
138
+ const taskDescriptionOption = {
139
+ type: "string",
140
+ value: { kind: "text", name: "text" },
141
+ aliases: ["body"],
142
+ };
134
143
  const taskInputs = {
135
144
  create: {
136
145
  options: {
137
146
  title: { type: "string", required: true, value: { kind: "text", name: "text" } },
138
- description: { type: "string", value: { kind: "text", name: "text" } },
147
+ description: taskDescriptionOption,
139
148
  "description-file": textFileOption,
140
149
  priority: priorityOption,
141
150
  due: dueOption,
@@ -255,7 +264,7 @@ const taskInputs = {
255
264
  edit: {
256
265
  options: {
257
266
  title: { type: "string", value: { kind: "text", name: "text" } },
258
- description: { type: "string", value: { kind: "text", name: "text" } },
267
+ description: taskDescriptionOption,
259
268
  "description-file": textFileOption,
260
269
  ...textEditOptions,
261
270
  priority: priorityOption,
@@ -398,28 +407,8 @@ export const taskRouter = {
398
407
  confirmation: { kind: "none" },
399
408
  input: taskInputs.create,
400
409
  results: [jsonResult("Task")],
401
- guessedFlags: {
402
- "--status": (args) => [
403
- "task",
404
- "create",
405
- ...renameFlag(args, taskInputs.create.options, "status", "column"),
406
- ],
407
- "--body": (args) => [
408
- "task",
409
- "create",
410
- ...renameFlag(args, taskInputs.create.options, "body", "description"),
411
- ],
412
- },
413
410
  run: async (args) => {
414
- const { values, positionals, tokens } = parseArgs({
415
- args,
416
- options: taskInputs.create.options,
417
- allowPositionals: true,
418
- strict: true,
419
- tokens: true,
420
- });
421
- validateUniqueOptions(tokens, taskInputs.create.options);
422
- validatePositionals(positionals, taskInputs.create.forms[0]);
411
+ const { values, positionals } = parseCommandArgs(args, taskInputs.create);
423
412
  const projectChoice = chooseProjectKey(positionals[0], { required: true });
424
413
  const title = requireStringOption(taskInputs.create.options.title, values.title, "title", "A task needs at least a title: use --title");
425
414
  const priority = parsePriority(values.priority);
@@ -474,15 +463,7 @@ Examples:
474
463
  input: taskInputs.list,
475
464
  results: [jsonResult("TaskList")],
476
465
  run: (args) => {
477
- const { values, positionals, tokens } = parseArgs({
478
- args,
479
- options: taskInputs.list.options,
480
- allowPositionals: true,
481
- strict: true,
482
- tokens: true,
483
- });
484
- validateUniqueOptions(tokens, taskInputs.list.options);
485
- validatePositionals(positionals, taskInputs.list.forms[0]);
466
+ const { values, positionals, tokens } = parseCommandArgs(args, taskInputs.list);
486
467
  if (violatesConstraint(archiveConstraint, getOptionInputs(values))) {
487
468
  quit('Use either "--archived" or "--all", not both', undefined, { argument: "--archived" });
488
469
  }
@@ -537,8 +518,8 @@ List active tasks by default.
537
518
  ${projectScopeDescription}
538
519
  --state open lists tasks outside done and cancelled columns, and --state closed lists tasks in them.
539
520
  Use --archived to list archived tasks or --all to list both.
540
- Repeat --label to require every specified label.
541
- --column matches an exact column name. Column and label matching ignore case.
521
+ Repeat --label to require every specified label, ignoring case.
522
+ ${columnFilterHelp}
542
523
  All supplied filters must match.
543
524
  --sort activity lists the most recently active tasks first, including comments and relations.
544
525
  Equal activity times keep board order. Without --sort, board order is preserved.
@@ -563,15 +544,7 @@ Example: zinn task list MDR --label cli`,
563
544
  jsonResult("TaskSearchResults", { kind: "booleanOption", name: "with-matches", value: true }),
564
545
  ],
565
546
  run: (args) => {
566
- const { values, positionals, tokens } = parseArgs({
567
- args,
568
- options: taskInputs.search.options,
569
- allowPositionals: true,
570
- strict: true,
571
- tokens: true,
572
- });
573
- validateUniqueOptions(tokens, taskInputs.search.options);
574
- validatePositionals(positionals, taskInputs.search.forms[0]);
547
+ const { values, positionals } = parseCommandArgs(args, taskInputs.search);
575
548
  const query = positionals[0];
576
549
  if (violatesConstraint(archiveConstraint, getOptionInputs(values))) {
577
550
  quit('Use either "--archived" or "--all", not both', undefined, { argument: "--archived" });
@@ -631,7 +604,7 @@ A task-key query overrides the configured default project; a typed project key s
631
604
  By default, only active tasks are searched. Use --archived to search archived tasks or --all to search both.
632
605
  --limit <n>: ${listLimitDescription}
633
606
  Repeat --label to require every specified label, ignoring case.
634
- --column matches an exact column name. Column and label matching ignore case.
607
+ ${columnFilterHelp}
635
608
  ${deadlineFilterHelp}
636
609
 
637
610
  Use --json --with-matches to include excerpts and highlight ranges. --limit counts tasks.
@@ -645,15 +618,7 @@ Example: zinn task search 'refinement quota' MDR --limit 5`,
645
618
  input: taskInputs.next,
646
619
  results: [jsonResult("NextTask")],
647
620
  run: (args) => {
648
- const { values, positionals, tokens } = parseArgs({
649
- args,
650
- options: taskInputs.next.options,
651
- allowPositionals: true,
652
- strict: true,
653
- tokens: true,
654
- });
655
- validateUniqueOptions(tokens, taskInputs.next.options);
656
- validatePositionals(positionals, taskInputs.next.forms[0]);
621
+ const { values, positionals } = parseCommandArgs(args, taskInputs.next);
657
622
  const projectChoice = chooseProjectKey(positionals[0], {
658
623
  allProjects: values["all-projects"],
659
624
  });
@@ -677,7 +642,8 @@ Only dependency relations hold a task back. A task with a live claim is skipped,
677
642
  Ready tasks in todo columns come before those in backlog columns, whatever their priority.
678
643
  Within each, tasks are ordered by priority (urgent first, unset last), then the earliest deadline with undated tasks last, then the oldest task.
679
644
  ${projectScopeDescription}
680
- --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.
645
+ ${columnFilterHelp}
646
+ With --column, tasks in any matching column can qualify unless it is done or cancelled.
681
647
  When no task is ready, the command exits 0. With --json, it prints null.
682
648
  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.
683
649
  task next <project> --column <working column> returns in-progress work with no live claim.
@@ -696,15 +662,7 @@ Examples:
696
662
  input: taskInputs.view,
697
663
  results: taskDetailResults,
698
664
  run: (args) => {
699
- const { values, positionals, tokens } = parseArgs({
700
- args,
701
- options: taskInputs.view.options,
702
- allowPositionals: true,
703
- strict: true,
704
- tokens: true,
705
- });
706
- validateUniqueOptions(tokens, taskInputs.view.options);
707
- validatePositionals(positionals, taskInputs.view.forms[0]);
665
+ const { values, positionals } = parseCommandArgs(args, taskInputs.view);
708
666
  const taskKey = positionals[0];
709
667
  validateTaskKey(taskKey);
710
668
  const { viewedTask, history, labelColorsByName } = readSnapshot(() => {
@@ -715,57 +673,29 @@ Examples:
715
673
  relations: presentRelations(taskMatch, board),
716
674
  comments: presentComments(taskMatch.key),
717
675
  };
718
- const viewedTask = values.history === true
676
+ const events = values.history === true
677
+ ? task
678
+ .activity(taskMatch.key)
679
+ .sort((left, right) => right.created_at - left.created_at || right.id.localeCompare(left.id))
680
+ : [];
681
+ const isText = getOutputMode() === "text";
682
+ const viewedTask = values.history === true && !isText
719
683
  ? {
720
684
  ...detail,
721
- activity: task
722
- .activity(taskMatch.key)
723
- .sort((left, right) => right.created_at - left.created_at || right.id.localeCompare(left.id)),
685
+ activity: activity.attachTaskKeys(events),
724
686
  }
725
687
  : detail;
726
- const isText = getOutputMode() === "text";
727
688
  return {
728
689
  viewedTask,
729
- history: isText && "activity" in viewedTask
730
- ? presentActivities(viewedTask.activity, { keysFromEventsOnly: true })
731
- : [],
690
+ history: isText ? presentActivities(events, { keysFromEventsOnly: true }) : [],
732
691
  labelColorsByName: isText ? getLabelColorsByName() : undefined,
733
692
  };
734
693
  });
735
- output(viewedTask, (t) => {
736
- const MIN_SECTION_SEPARATOR_WIDTH = 60;
737
- const terminalWidth = process.stdout.columns;
738
- const hasTerminalWidth = process.stdout.isTTY === true && terminalWidth > 0;
739
- const sectionOptions = {
740
- separatorWidth: hasTerminalWidth ? terminalWidth : MIN_SECTION_SEPARATOR_WIDTH,
741
- };
742
- const relations = formatRelationList(t.relations);
743
- const comments = formatCommentList(t.comments);
744
- const isArchived = t.status === "Archived";
745
- const sections = [
746
- formatTaskList([t], {
747
- showsStatus: isArchived,
748
- showsFullPriority: true,
749
- showsClaimDetail: true,
750
- labelColorsByName,
751
- }),
752
- ];
753
- if (t.description != null) {
754
- sections.push(formatSection("Description", t.description, sectionOptions));
755
- }
756
- if (relations.length > 0) {
757
- sections.push(formatSection("Relations", relations, sectionOptions));
758
- }
759
- if (comments.length > 0) {
760
- sections.push(formatSection("Comments", comments, sectionOptions));
761
- }
762
- const formattedHistory = formatActivityList(history);
763
- if (formattedHistory.length > 0) {
764
- sections.push(formatSection("History", formattedHistory, sectionOptions));
765
- }
766
- sections.push(formatTaskTimestamps(t));
767
- return sections.join("\n\n");
768
- });
694
+ output(viewedTask, (t) => formatTaskDetail(t, {
695
+ history,
696
+ labelColorsByName,
697
+ ...readTerminalProps(),
698
+ }));
769
699
  },
770
700
  help: `${generateCommandUsage("task view", taskInputs.view)}
771
701
 
@@ -790,13 +720,7 @@ Examples:
790
720
  input: taskInputs.blame,
791
721
  results: [jsonResult("TaskBlame")],
792
722
  run: (args) => {
793
- const { positionals } = parseArgs({
794
- args,
795
- options: taskInputs.blame.options,
796
- allowPositionals: true,
797
- strict: true,
798
- });
799
- validatePositionals(positionals, taskInputs.blame.forms[0]);
723
+ const { positionals } = parseCommandArgs(args, taskInputs.blame);
800
724
  const { blame, textOptions } = readSnapshot(() => {
801
725
  const blame = task.blame(positionals[0]);
802
726
  if (getOutputMode() === "json") {
@@ -815,7 +739,7 @@ Examples:
815
739
  },
816
740
  };
817
741
  });
818
- output(blame, (entry) => formatTaskBlame(entry, textOptions));
742
+ output(blame, (entry) => formatTaskBlame(entry, { ...textOptions, ...readTerminalProps() }));
819
743
  },
820
744
  help: `${generateCommandUsage("task blame", taskInputs.blame)}
821
745
 
@@ -836,15 +760,7 @@ Example: zinn task blame MDR-1`,
836
760
  input: taskInputs.edit,
837
761
  results: [jsonResult("TaskChange")],
838
762
  run: async (args) => {
839
- const { values, positionals, tokens } = parseArgs({
840
- args,
841
- options: taskInputs.edit.options,
842
- allowPositionals: true,
843
- strict: true,
844
- tokens: true,
845
- });
846
- validateUniqueOptions(tokens, taskInputs.edit.options);
847
- validatePositionals(positionals, taskInputs.edit.forms[0]);
763
+ const { values, positionals } = parseCommandArgs(args, taskInputs.edit);
848
764
  const taskKey = positionals[0];
849
765
  const fields = {
850
766
  taskKey,
@@ -892,13 +808,8 @@ Examples:
892
808
  zinn task edit MDR-1 --description 'Bring waffles.' --append
893
809
  zinn task edit MDR-1 --title 'Refine the Cold Harbor file' --expect-title 'Refine the files'`,
894
810
  guessedFlags: {
895
- "--status": (args) => suggestTaskMove(args, taskInputs.edit.options),
896
- "--column": (args) => suggestTaskMove(args, taskInputs.edit.options),
897
- "--body": (args) => [
898
- "task",
899
- "edit",
900
- ...renameFlag(args, taskInputs.edit.options, "body", "description"),
901
- ],
811
+ "--status": (args) => suggestTaskMove(args, parseArgsOptions(taskInputs.edit.options)),
812
+ "--column": (args) => suggestTaskMove(args, parseArgsOptions(taskInputs.edit.options)),
902
813
  },
903
814
  },
904
815
  move: {
@@ -908,15 +819,7 @@ Examples:
908
819
  input: taskInputs.move,
909
820
  results: taskChangeResults,
910
821
  run: (args) => {
911
- const { values, positionals, tokens } = parseArgs({
912
- options: taskInputs.move.options,
913
- args,
914
- allowPositionals: true,
915
- strict: true,
916
- tokens: true,
917
- });
918
- validateUniqueOptions(tokens, taskInputs.move.options);
919
- validatePositionals(positionals, taskInputs.move.forms[0]);
822
+ const { values, positionals } = parseCommandArgs(args, taskInputs.move);
920
823
  const taskKeys = positionals.slice(0, -1);
921
824
  const targetColumn = positionals.at(-1);
922
825
  const moves = moveOrPointToArchive(taskKeys, targetColumn, values.from);
@@ -946,12 +849,7 @@ Examples:
946
849
  input: taskInputs.order,
947
850
  results: taskChangeResults,
948
851
  run: (args) => {
949
- const { positionals } = parseArgs({
950
- options: taskInputs.order.options,
951
- args,
952
- allowPositionals: true,
953
- strict: true,
954
- });
852
+ const { positionals } = parseCommandArgs(args, taskInputs.order);
955
853
  const form = validateOrderForms(positionals, taskInputs.order.forms);
956
854
  const taskKeys = positionals.slice(0, form.directionIndex);
957
855
  let orders;
@@ -1033,15 +931,7 @@ Example: zinn task unarchive MDR-1 MDR-2`,
1033
931
  input: taskInputs.claim,
1034
932
  results: [jsonResult("TaskChange")],
1035
933
  run: (args) => {
1036
- const { values, positionals, tokens } = parseArgs({
1037
- args,
1038
- options: taskInputs.claim.options,
1039
- allowPositionals: true,
1040
- strict: true,
1041
- tokens: true,
1042
- });
1043
- validateUniqueOptions(tokens, taskInputs.claim.options);
1044
- validatePositionals(positionals, taskInputs.claim.forms[0]);
934
+ const { values, positionals } = parseCommandArgs(args, taskInputs.claim);
1045
935
  const lease = requireStringOption(taskInputs.claim.options.lease, values.lease, "lease", "A claim needs a lease: use --lease, such as --lease 30m");
1046
936
  const leaseMs = parseDurationInput(lease, "--lease");
1047
937
  const isLeaseInRange = leaseMs >= MIN_CLAIM_LEASE_MS && leaseMs <= CLAIM_WORK_LIMIT_MS;
@@ -1062,8 +952,8 @@ Claim a task for a lease, so other agents and people can see who works on it.
1062
952
  Any change the holder makes to the task, including a comment, renews the claim. So does task heartbeat.
1063
953
  A claim expires when its lease runs out, or ${formatDurationInput(CLAIM_WORK_LIMIT_MS)} after the holder last changed the task.
1064
954
  After that limit, only a change to the task renews it.
1065
- Claiming a task you hold renews it with the new lease.
1066
- An expired claim is replaced. A live claim by someone else is a conflict, unless --force takes it over.
955
+ Claiming a task you hold renews your live claim or resumes your expired claim with the new lease.
956
+ Claiming someone else's expired claim replaces it. A live claim by someone else is a conflict, unless --force takes it over.
1067
957
  Agents are told apart by their session or thread, so an agent needs one its host sets, or ZINN_SESSION_ID.
1068
958
  Archived tasks cannot be claimed. Archiving a task or moving it to a done or cancelled column releases its claim.
1069
959
 
@@ -1086,7 +976,7 @@ Examples:
1086
976
  Renew your claim on a task with its current lease.
1087
977
  It fails when the task has no claim or someone else holds it.
1088
978
  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.
1089
- Your own expired claim renews, unless someone claimed the task since.
979
+ A heartbeat resumes your expired claim unless someone else has claimed the task since.
1090
980
 
1091
981
  Example: zinn task heartbeat MDR-1`,
1092
982
  },
@@ -1119,15 +1009,7 @@ Example: zinn task release MDR-1`,
1119
1009
  jsonResult("TaskList", { kind: "positionalCount", name: "task-key", min: 2, max: null }),
1120
1010
  ],
1121
1011
  run: async (args) => {
1122
- const { values, positionals, tokens } = parseArgs({
1123
- args,
1124
- options: taskInputs.delete.options,
1125
- allowPositionals: true,
1126
- strict: true,
1127
- tokens: true,
1128
- });
1129
- validateUniqueOptions(tokens, taskInputs.delete.options);
1130
- validatePositionals(positionals, taskInputs.delete.forms[0]);
1012
+ const { values, positionals } = parseCommandArgs(args, taskInputs.delete);
1131
1013
  const taskKeys = taskDeleteManySchema.parse(positionals);
1132
1014
  const taskMatches = taskKeys.map((taskKey) => task.getByKey(taskKey));
1133
1015
  const board = createColumnBoard();
@@ -1190,38 +1072,23 @@ With --json, changed is false when none of the labels were attached.`,
1190
1072
  },
1191
1073
  };
1192
1074
  function parseTaskKeys(args) {
1193
- const { positionals } = parseArgs({
1194
- options: taskInputs.archive.options,
1195
- args,
1196
- allowPositionals: true,
1197
- strict: true,
1198
- });
1199
- validatePositionals(positionals, taskInputs.archive.forms[0]);
1075
+ const { positionals } = parseCommandArgs(args, taskInputs.archive);
1200
1076
  return positionals;
1201
1077
  }
1202
1078
  function parseClaimedTaskKey(args) {
1203
- const { positionals } = parseArgs({
1204
- options: taskInputs.heartbeat.options,
1205
- args,
1206
- allowPositionals: true,
1207
- strict: true,
1208
- });
1209
- validatePositionals(positionals, taskInputs.heartbeat.forms[0]);
1079
+ const { positionals } = parseCommandArgs(args, taskInputs.heartbeat);
1210
1080
  return positionals[0];
1211
1081
  }
1212
1082
  /** Prints a claim command's task with its claim and when the lease ends */
1213
1083
  function outputClaimChange(change, describeUnchanged) {
1214
1084
  const board = createColumnBoard();
1215
- outputChanges([change], (claimChange) => presentTask(claimChange.task, board), (entries) => formatTaskList(entries, { showsClaimDetail: true }), describeUnchanged);
1085
+ outputChanges([change], (claimChange) => presentTask(claimChange.task, board), (entries) => formatTaskList(entries, {
1086
+ showsClaimDetail: true,
1087
+ resumedExpiredClaim: change.resumedExpiredClaim,
1088
+ }), describeUnchanged);
1216
1089
  }
1217
1090
  function parseTaskLabelArgs(args) {
1218
- const { positionals } = parseArgs({
1219
- options: taskInputs.label_add.options,
1220
- args,
1221
- strict: true,
1222
- allowPositionals: true,
1223
- });
1224
- validatePositionals(positionals, taskInputs.label_add.forms[0]);
1091
+ const { positionals } = parseCommandArgs(args, taskInputs.label_add);
1225
1092
  return { taskKey: positionals[0], labelNames: positionals.slice(1) };
1226
1093
  }
1227
1094
  // The new task is the source of each relation, so a flag names the type from its point of view.
@@ -1,7 +1,6 @@
1
- import { parseArgs } from "node:util";
2
1
  import { currentActor } from "../actor.js";
3
2
  import { generateCommandUsage, noInput } from "../input.js";
4
- import { output, validatePositionals } from "../lib.js";
3
+ import { output, parseCommandArgs } from "../lib.js";
5
4
  import { formatActor, presentActor } from "../presentation/activity-presentation.js";
6
5
  import { jsonResult } from "../results.js";
7
6
  export const whoamiCommand = {
@@ -11,13 +10,7 @@ export const whoamiCommand = {
11
10
  input: noInput,
12
11
  results: [jsonResult("Actor")],
13
12
  run: (args) => {
14
- const { positionals } = parseArgs({
15
- options: noInput.options,
16
- args,
17
- strict: true,
18
- allowPositionals: true,
19
- });
20
- validatePositionals(positionals, noInput.forms[0]);
13
+ parseCommandArgs(args, noInput);
21
14
  output(presentActor(currentActor()), formatActor);
22
15
  },
23
16
  help: `${generateCommandUsage("whoami", noInput)}
package/src/telemetry.js CHANGED
@@ -5,7 +5,7 @@ import { parseArgs } from "node:util";
5
5
  import { BYTES_PER_MEGABYTE, TELEMETRY_FOLDER_NAME, getConfiguredStorage, getProcessSettings, isMissingFileError, resolveTelemetry, } from "@zinn-dev/core";
6
6
  import packageJson from "../package.json" with { type: "json" };
7
7
  import { detectAgent, readExecutionIdentity } from "./actor.js";
8
- import { isHelpFlag, isRouterFlag, routerOptions, splitAtOptionSeparator } from "./input.js";
8
+ import { isHelpFlag, isRouterFlag, parseArgsOptions, routerOptions, splitAtOptionSeparator, } from "./input.js";
9
9
  import { currentRuntime, readRunClock } from "./run-facts.js";
10
10
  import { ensureFolderInStore } from "./store-folder.js";
11
11
  const RECORD_VERSION = 1;
@@ -148,8 +148,7 @@ function countPositionals() {
148
148
  if (matchedRun === null || matchedRun.help || didParseArgsThrow) {
149
149
  return undefined;
150
150
  }
151
- const options = matchedRun.match.input.options;
152
- const tokens = readTokens(matchedRun.commandArgs, options);
151
+ const tokens = readTokens(matchedRun.commandArgs, parseArgsOptions(matchedRun.match.input.options));
153
152
  return tokens.filter((token) => token.kind === "positional").length;
154
153
  }
155
154
  function describeFailure({ failure, logFileName }) {
@@ -167,7 +166,7 @@ function describeFailure({ failure, logFileName }) {
167
166
  }
168
167
  function createRecord(outcome, startedAt, elapsedMs) {
169
168
  const words = process.argv.slice(2);
170
- const known = matchedRun === null ? {} : matchedRun.match.input.options;
169
+ const known = matchedRun === null ? {} : parseArgsOptions(matchedRun.match.input.options);
171
170
  return {
172
171
  v: RECORD_VERSION,
173
172
  startedAt: startedAt.toISOString(),
package/src/types.d.ts CHANGED
@@ -32,6 +32,10 @@ export declare const commandConfirmationSchema: z.ZodObject<{
32
32
  }>;
33
33
  description: z.ZodOptional<z.ZodString>;
34
34
  }, z.core.$strict>;
35
+ export type FlagCorrection = {
36
+ args: Array<string>;
37
+ guidance: string;
38
+ };
35
39
  export type Command = {
36
40
  input: CommandInput;
37
41
  results: readonly CommandResult[];
@@ -40,7 +44,7 @@ export type Command = {
40
44
  confirmation: z.infer<typeof commandConfirmationSchema>;
41
45
  run: (args: Array<string>) => void | Promise<void>;
42
46
  help: string;
43
- guessedFlags?: Record<string, (args: Array<string>) => Array<string> | undefined>;
47
+ guessedFlags?: Record<string, (args: Array<string>) => FlagCorrection | undefined>;
44
48
  };
45
49
  export type ParsedRoute = {
46
50
  command: string;
package/src/views.d.ts ADDED
@@ -0,0 +1,117 @@
1
+ export declare const views: {
2
+ readonly version: "1.0";
3
+ readonly taskDetail: {
4
+ readonly sections: readonly [{
5
+ readonly id: "task";
6
+ readonly rank: 0;
7
+ readonly items: readonly [{
8
+ readonly role: "key";
9
+ readonly rank: 0;
10
+ }, {
11
+ readonly role: "status";
12
+ readonly rank: 0;
13
+ }, {
14
+ readonly role: "column";
15
+ readonly rank: 0;
16
+ }, {
17
+ readonly role: "priority";
18
+ readonly rank: 1;
19
+ }, {
20
+ readonly role: "title";
21
+ readonly rank: 0;
22
+ }, {
23
+ readonly role: "due";
24
+ readonly rank: 2;
25
+ }, {
26
+ readonly role: "claim";
27
+ readonly rank: 1;
28
+ }, {
29
+ readonly role: "labels";
30
+ readonly rank: 1;
31
+ }];
32
+ }, {
33
+ readonly id: "description";
34
+ readonly rank: 1;
35
+ readonly heading: "Description";
36
+ readonly short: "firstParagraph";
37
+ }, {
38
+ readonly id: "relations";
39
+ readonly rank: 1;
40
+ readonly heading: "Relations";
41
+ readonly short: "keys";
42
+ }, {
43
+ readonly id: "comments";
44
+ readonly rank: 2;
45
+ readonly heading: "Comments";
46
+ readonly short: "countAndLatest";
47
+ }, {
48
+ readonly id: "history";
49
+ readonly rank: 3;
50
+ readonly heading: "History";
51
+ readonly onRequest: true;
52
+ }, {
53
+ readonly id: "times";
54
+ readonly rank: 3;
55
+ readonly items: readonly [{
56
+ readonly role: "createdAt";
57
+ readonly rank: 3;
58
+ readonly label: "Task created at";
59
+ }, {
60
+ readonly role: "updatedAt";
61
+ readonly rank: 3;
62
+ readonly label: "Task updated at";
63
+ }];
64
+ }];
65
+ };
66
+ readonly words: {
67
+ readonly relations: {
68
+ readonly dependency: {
69
+ readonly outgoing: "Depends on";
70
+ readonly incoming: "Depended on by";
71
+ };
72
+ readonly subtask: {
73
+ readonly outgoing: "Parent";
74
+ readonly incoming: "Subtask";
75
+ };
76
+ readonly duplicate: {
77
+ readonly outgoing: "Duplicate of";
78
+ readonly incoming: "Duplicated by";
79
+ };
80
+ readonly related: "Related to";
81
+ };
82
+ readonly priorities: {
83
+ readonly urgent: {
84
+ readonly word: "Urgent";
85
+ readonly initial: "U";
86
+ };
87
+ readonly high: {
88
+ readonly word: "High";
89
+ readonly initial: "H";
90
+ };
91
+ readonly medium: {
92
+ readonly word: "Medium";
93
+ readonly initial: "M";
94
+ };
95
+ readonly low: {
96
+ readonly word: "Low";
97
+ readonly initial: "L";
98
+ };
99
+ };
100
+ };
101
+ readonly glyphs: {
102
+ readonly claimHolder: {
103
+ readonly thisSession: {
104
+ readonly glyph: "◆";
105
+ readonly words: "this session";
106
+ };
107
+ readonly otherHolder: {
108
+ readonly glyph: "◇";
109
+ readonly words: "another holder";
110
+ };
111
+ readonly unknownOwnership: {
112
+ readonly glyph: "?";
113
+ readonly words: "Claimed";
114
+ };
115
+ };
116
+ };
117
+ };