@zinn-dev/cli 0.43.0 → 0.44.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/README.md +1 -1
  2. package/index.js +3 -3
  3. package/package.json +7 -4
  4. package/skills/zinn/SKILL.md +1 -1
  5. package/src/actor.d.ts +8 -0
  6. package/src/actor.js +5 -1
  7. package/src/capabilities-schema.d.ts +1 -1
  8. package/src/column-hint.js +3 -4
  9. package/src/errors.d.ts +12 -3
  10. package/src/errors.js +19 -2
  11. package/src/failure-log.d.ts +6 -0
  12. package/src/failure-log.js +167 -0
  13. package/src/input.d.ts +11 -0
  14. package/src/input.js +25 -1
  15. package/src/lib.d.ts +7 -5
  16. package/src/lib.js +52 -33
  17. package/src/list-limit.d.ts +2 -2
  18. package/src/list-limit.js +2 -2
  19. package/src/overview.d.ts +10 -0
  20. package/src/overview.js +41 -0
  21. package/src/presentation/activity-presentation.d.ts +2 -0
  22. package/src/presentation/activity-presentation.js +96 -35
  23. package/src/presentation/column-presentation.d.ts +17 -2
  24. package/src/presentation/column-presentation.js +45 -6
  25. package/src/presentation/info-presentation.js +36 -6
  26. package/src/presentation/relation-presentation.d.ts +6 -2
  27. package/src/presentation/relation-presentation.js +36 -26
  28. package/src/presentation/task-blame-presentation.d.ts +11 -0
  29. package/src/presentation/task-blame-presentation.js +56 -0
  30. package/src/presentation/task-presentation.d.ts +6 -1
  31. package/src/presentation/task-presentation.js +21 -9
  32. package/src/result-schemas.d.ts +480 -15
  33. package/src/result-schemas.js +54 -1
  34. package/src/routes/activity-router.d.ts +9 -1
  35. package/src/routes/activity-router.js +15 -2
  36. package/src/routes/info-router.js +3 -2
  37. package/src/routes/migrate-router.js +2 -2
  38. package/src/routes/project-router.d.ts +1 -1
  39. package/src/routes/project-router.js +3 -12
  40. package/src/routes/restore-router.js +9 -3
  41. package/src/routes/router.js +24 -11
  42. package/src/routes/routes.d.ts +51 -8
  43. package/src/routes/task-router.d.ts +41 -6
  44. package/src/routes/task-router.js +81 -24
  45. package/src/routes/whoami-router.js +1 -1
  46. package/src/run-facts.d.ts +14 -0
  47. package/src/run-facts.js +14 -0
  48. package/src/store-folder.d.ts +5 -0
  49. package/src/store-folder.js +16 -0
  50. package/src/telemetry.d.ts +31 -0
  51. package/src/telemetry.js +329 -0
  52. package/src/text-input.js +1 -5
  53. package/src/types.d.ts +1 -1
@@ -1,6 +1,6 @@
1
1
  import { jsonResult, taskDetailResults, taskChangeResults } from "../results.js";
2
2
  import { parseArgs } from "node:util";
3
- import { task, project, parseTaskKey, taskCreateSchema, taskEditSchema, taskDeleteManySchema, taskPrioritySchema, taskSortSchema, } from "@zinn-dev/core";
3
+ import { activity, task, project, parseTaskKey, taskCreateSchema, taskEditSchema, taskDeleteManySchema, taskPrioritySchema, taskSortSchema, } from "@zinn-dev/core";
4
4
  import { listLimitOption, listLimitDescription, parseListLimit } from "../list-limit.js";
5
5
  import { formatListContinuation } from "../list-continuation.js";
6
6
  import { parseTimestampInput } from "../timestamp-input.js";
@@ -16,7 +16,9 @@ import { commentRouter } from "./comment-router.js";
16
16
  import { formatRelationList, presentRelations } from "../presentation/relation-presentation.js";
17
17
  import { formatCommentList, presentComments } from "../presentation/comment-presentation.js";
18
18
  import { formatSection } from "../presentation/section.js";
19
- import { formatActivityList, presentActivities } from "../presentation/activity-presentation.js";
19
+ import { abbreviateActivityIds, formatActivityList, presentActivities, } from "../presentation/activity-presentation.js";
20
+ import { formatTaskBlame } from "../presentation/task-blame-presentation.js";
21
+ import { columnPlacement, createColumnBoard } from "../presentation/column-presentation.js";
20
22
  import { formatTaskList, formatTaskTimestamps, presentTask, } from "../presentation/task-presentation.js";
21
23
  // A column is changed with task move, so a guessed --status or --column suggests it with the same task keys.
22
24
  function suggestTaskMove(args, options = {}) {
@@ -124,9 +126,9 @@ const taskInputs = {
124
126
  "starting-after": {
125
127
  type: "string",
126
128
  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",
129
+ kind: "task-cursor",
130
+ name: "cursor",
131
+ description: "Cursor from the continuation command that task list prints on stderr when more tasks remain",
130
132
  },
131
133
  },
132
134
  },
@@ -139,7 +141,7 @@ const taskInputs = {
139
141
  constraints: [archiveConstraint, projectScopeConstraint],
140
142
  notes: [
141
143
  projectScopeDescription,
142
- "A --starting-after task must match every selection filter. Cursor resolution uses current task identities before list filtering.",
144
+ "A --starting-after cursor works only with the --sort it was made for. Filters may change between pages.",
143
145
  ],
144
146
  },
145
147
  search: {
@@ -150,6 +152,7 @@ const taskInputs = {
150
152
  "all-projects": { type: "boolean" },
151
153
  limit: listLimitOption,
152
154
  label: { type: "string", multiple: true, value: { kind: "label-name", name: "name" } },
155
+ column: { type: "string", value: { kind: "column-name", name: "name" } },
153
156
  },
154
157
  forms: [
155
158
  {
@@ -176,6 +179,11 @@ const taskInputs = {
176
179
  ],
177
180
  constraints: [],
178
181
  },
182
+ blame: {
183
+ options: {},
184
+ forms: [{ id: "default", positionals: [taskKeyPositional] }],
185
+ constraints: [],
186
+ },
179
187
  edit: {
180
188
  options: {
181
189
  title: { type: "string", value: { kind: "text", name: "text" } },
@@ -403,11 +411,12 @@ Examples:
403
411
  columnName: values.column,
404
412
  startingAfter: values["starting-after"],
405
413
  });
406
- output(page.tasks.map(presentTask), (presentedTasks) => formatTaskList(presentedTasks, { showsStatus: values.all }));
407
- if (page.hasMore) {
414
+ const board = createColumnBoard();
415
+ output(page.tasks.map((taskMatch) => presentTask(taskMatch, board)), (presentedTasks) => formatTaskList(presentedTasks, { showsStatus: values.all }));
416
+ if (page.nextCursor !== undefined) {
408
417
  const selectionTokens = tokens.filter((token) => token.kind !== "option" || token.name !== "all-projects");
409
418
  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)}`);
419
+ diagnostic(`More tasks. Continue with: ${formatListContinuation(["task", "list"], projectScope, selectionTokens, "starting-after", page.nextCursor)}`);
411
420
  }
412
421
  },
413
422
  help: `${generateCommandUsage("task list", taskInputs.list)}
@@ -423,10 +432,9 @@ Equal activity times keep board order. Without --sort, board order is preserved.
423
432
  --sort due lists earliest deadlines first, with undated tasks last. Equal deadlines keep board order. Task positions stay unchanged.
424
433
  ${deadlineFilterHelp}
425
434
  --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
435
  When additional matches remain after --limit, stderr gives a shell-quoted command to continue, including with --json.
436
+ --starting-after <cursor>: Continue after the position a cursor records. Copy the cursor from that command.
437
+ A cursor works only with the --sort it was made for. Changes to other tasks between commands can still cause repeats or skips.
430
438
 
431
439
  Use 'task view' to see a task's full details, including its description.
432
440
 
@@ -466,8 +474,10 @@ Example: zinn task list MDR --label cli`,
466
474
  archive,
467
475
  limit,
468
476
  labelNames: values.label,
477
+ columnName: values.column,
469
478
  });
470
- output(result.tasks.map(presentTask), (presentedTasks) => formatTaskList(presentedTasks, { showsStatus: values.all }));
479
+ const board = createColumnBoard();
480
+ output(result.tasks.map((taskMatch) => presentTask(taskMatch, board)), (presentedTasks) => formatTaskList(presentedTasks, { showsStatus: values.all }));
471
481
  if (result.hiddenArchivedCount > 0) {
472
482
  const count = result.hiddenArchivedCount;
473
483
  const noun = count === 1 ? "match" : "matches";
@@ -486,6 +496,7 @@ A task-key query overrides the configured default project; a typed project key s
486
496
  By default, only active tasks are searched. Use --archived to search archived tasks or --all to search both.
487
497
  --limit <n>: ${listLimitDescription}
488
498
  Repeat --label to require every specified label, ignoring case.
499
+ --column matches an exact column name. Column and label matching ignore case.
489
500
  ${deadlineFilterHelp}
490
501
 
491
502
  Example: zinn task search 'refinement quota' MDR --limit 5`,
@@ -507,9 +518,10 @@ Example: zinn task search 'refinement quota' MDR --limit 5`,
507
518
  validateUniqueOptions(tokens, taskInputs.view.options);
508
519
  validatePositionals(positionals, taskInputs.view.forms[0]);
509
520
  const taskMatch = task.getByKey(positionals[0]);
521
+ const board = createColumnBoard();
510
522
  const detail = {
511
- ...presentTask(taskMatch),
512
- relations: presentRelations(taskMatch),
523
+ ...presentTask(taskMatch, board),
524
+ relations: presentRelations(taskMatch, board),
513
525
  comments: presentComments(taskMatch.key),
514
526
  };
515
527
  const viewedTask = values.history === true
@@ -543,7 +555,7 @@ Example: zinn task search 'refinement quota' MDR --limit 5`,
543
555
  sections.push(formatSection("Comments", comments, sectionOptions));
544
556
  }
545
557
  if ("activity" in t) {
546
- const history = formatActivityList(presentActivities(t.activity));
558
+ const history = formatActivityList(presentActivities(t.activity, { keysFromEventsOnly: true }));
547
559
  if (history.length > 0) {
548
560
  sections.push(formatSection("History", history, sectionOptions));
549
561
  }
@@ -566,6 +578,43 @@ Without --history, JSON omits activity.
566
578
  Examples:
567
579
  zinn task view MDR-1
568
580
  zinn task view MDR-1 --history`,
581
+ },
582
+ blame: {
583
+ summary: "Show the recorded authors of a task's current fields and description lines.",
584
+ effects: { domain: "read", storage: "normal-open" },
585
+ confirmation: { kind: "none" },
586
+ input: taskInputs.blame,
587
+ results: [jsonResult("TaskBlame")],
588
+ run: (args) => {
589
+ const { positionals } = parseArgs({
590
+ args,
591
+ options: taskInputs.blame.options,
592
+ allowPositionals: true,
593
+ strict: true,
594
+ });
595
+ validatePositionals(positionals, taskInputs.blame.forms[0]);
596
+ output(task.blame(positionals[0]), (blame) => {
597
+ const taskMatch = task.getByKey(blame.task.key);
598
+ const board = createColumnBoard();
599
+ return formatTaskBlame(blame, {
600
+ relations: presentRelations(taskMatch, board),
601
+ columnPlacement: columnPlacement(board(taskMatch.project_id), taskMatch.column_id),
602
+ isArchived: taskMatch.archived_at != null,
603
+ activityIdPrefixes: abbreviateActivityIds(activity.getIds()),
604
+ });
605
+ });
606
+ },
607
+ help: `${generateCommandUsage("task blame", taskInputs.blame)}
608
+
609
+ Show the recorded authors of a task's current fields, label membership, parent, relations and description lines.
610
+ Active and archived tasks are readable. A reused key selects its current task only.
611
+ Unchanged description lines keep their attribution through exact-line comparisons, including whitespace.
612
+ A terminal newline does not add a line or change its attribution. Missing history is unrecorded.
613
+ Recorded identities are kept as stored. Use activity view <activity-id> to inspect a recorded event.
614
+ With --json, fields contain value and nullable attribution, relations contain their attribution,
615
+ and description contains numbered text lines with nullable attribution.
616
+
617
+ Example: zinn task blame MDR-1`,
569
618
  },
570
619
  edit: {
571
620
  summary: "Edit a task's title, description, priority, deadline, or label attachments.",
@@ -599,7 +648,8 @@ Examples:
599
648
  quit("Provide at least one edit flag: --title, --description, --description-file, --priority, --due, --add-label, or --remove-label", undefined, { field: [] });
600
649
  }
601
650
  const editedTask = task.edit({ ...fields, description }, currentActor());
602
- outputChanges([editedTask], (change) => presentTask(change.task), formatTaskList, (entry) => `${entry.key} was unchanged`);
651
+ const board = createColumnBoard();
652
+ outputChanges([editedTask], (change) => presentTask(change.task, board), formatTaskList, (entry) => `${entry.key} was unchanged`);
603
653
  },
604
654
  help: `${generateCommandUsage("task edit", taskInputs.edit)}
605
655
 
@@ -649,7 +699,8 @@ Examples:
649
699
  const taskKeys = positionals.slice(0, -1);
650
700
  const targetColumn = positionals.at(-1);
651
701
  const moves = task.moveMany({ taskKeys, targetColumn }, currentActor());
652
- outputChanges(moves, (change) => presentTask(change.task), formatTaskList, (movedTask) => `${movedTask.key} was already in the ${movedTask.column} column`);
702
+ const board = createColumnBoard();
703
+ outputChanges(moves, (change) => presentTask(change.task, board), formatTaskList, (movedTask) => `${movedTask.key} was already in the ${movedTask.column} column`);
653
704
  },
654
705
  help: `${generateCommandUsage("task move", taskInputs.move)}
655
706
 
@@ -690,7 +741,8 @@ Example: zinn task move MDR-1 MDR-2 'In Progress'`,
690
741
  else {
691
742
  orders = task.orderMany({ taskKeys, direction: form.direction }, currentActor());
692
743
  }
693
- outputChanges(orders, (change) => presentTask(change.task), formatTaskList, (entry) => `${entry.key} was already in that position`);
744
+ const board = createColumnBoard();
745
+ outputChanges(orders, (change) => presentTask(change.task, board), formatTaskList, (entry) => `${entry.key} was already in that position`);
694
746
  },
695
747
  help: `${generateCommandUsage("task order", taskInputs.order)}
696
748
 
@@ -713,7 +765,8 @@ Example: zinn task order MDR-2 before MDR-1`,
713
765
  run: (args) => {
714
766
  const taskKeys = parseTaskKeys(args);
715
767
  const archives = task.archiveMany(taskKeys, currentActor());
716
- outputChanges(archives, (change) => presentTask(change.task), (entries) => formatTaskList(entries, { showsStatus: true }), (archivedTask) => `${archivedTask.key} was already archived`);
768
+ const board = createColumnBoard();
769
+ outputChanges(archives, (change) => presentTask(change.task, board), (entries) => formatTaskList(entries, { showsStatus: true }), (archivedTask) => `${archivedTask.key} was already archived`);
717
770
  },
718
771
  help: `${generateCommandUsage("task archive", taskInputs.archive)}
719
772
 
@@ -735,7 +788,8 @@ Example: zinn task archive MDR-1 MDR-2`,
735
788
  run: (args) => {
736
789
  const taskKeys = parseTaskKeys(args);
737
790
  const unarchives = task.unarchiveMany(taskKeys, currentActor());
738
- outputChanges(unarchives, (change) => presentTask(change.task), (entries) => formatTaskList(entries, { showsStatus: true }), (unarchivedTask) => `${unarchivedTask.key} was already active`);
791
+ const board = createColumnBoard();
792
+ outputChanges(unarchives, (change) => presentTask(change.task, board), (entries) => formatTaskList(entries, { showsStatus: true }), (unarchivedTask) => `${unarchivedTask.key} was already active`);
739
793
  },
740
794
  help: `${generateCommandUsage("task unarchive", taskInputs.archive)}
741
795
 
@@ -769,7 +823,8 @@ Example: zinn task unarchive MDR-1 MDR-2`,
769
823
  validatePositionals(positionals, taskInputs.delete.forms[0]);
770
824
  const taskKeys = taskDeleteManySchema.parse(positionals);
771
825
  const taskMatches = taskKeys.map((taskKey) => task.getByKey(taskKey));
772
- const presented = taskMatches.map(presentTask);
826
+ const board = createColumnBoard();
827
+ const presented = taskMatches.map((taskMatch) => presentTask(taskMatch, board));
773
828
  const canDelete = await confirmAction(`Are you sure you want to delete ${taskMatches.map((match) => match.key).join(", ")}?`, values.yes === true);
774
829
  if (canDelete) {
775
830
  task.deleteMany(taskKeys, currentActor());
@@ -799,7 +854,8 @@ Example: zinn task delete MDR-1 MDR-2`,
799
854
  results: [jsonResult("TaskChange")],
800
855
  run: (args) => {
801
856
  const props = parseTaskLabelArgs(args);
802
- outputChanges([task.label.add(props, currentActor())], (change) => presentTask(change.task), formatTaskList, (entry) => `${entry.key} already had those labels`);
857
+ const board = createColumnBoard();
858
+ outputChanges([task.label.add(props, currentActor())], (change) => presentTask(change.task, board), formatTaskList, (entry) => `${entry.key} already had those labels`);
803
859
  },
804
860
  help: `${generateCommandUsage("task label add", taskInputs.label_add)}
805
861
 
@@ -815,7 +871,8 @@ With --json, changed is false when all the labels were already attached.`,
815
871
  results: [jsonResult("TaskChange")],
816
872
  run: (args) => {
817
873
  const props = parseTaskLabelArgs(args);
818
- outputChanges([task.label.remove(props, currentActor())], (change) => presentTask(change.task), formatTaskList, (entry) => `${entry.key} had none of those labels`);
874
+ const board = createColumnBoard();
875
+ outputChanges([task.label.remove(props, currentActor())], (change) => presentTask(change.task, board), formatTaskList, (entry) => `${entry.key} had none of those labels`);
819
876
  },
820
877
  help: `${generateCommandUsage("task label remove", taskInputs.label_add)}
821
878
 
@@ -23,7 +23,7 @@ export const whoamiCommand = {
23
23
  help: `${generateCommandUsage("whoami", noInput)}
24
24
 
25
25
  Show the actor a change would record in the current environment and folder.
26
- Includes name, email, kind, source, session, thread, agent, model and effort.
26
+ Includes name, email, kind, source, session, thread, agent, model, effort and client.
27
27
  Git identity is read from the current folder.
28
28
 
29
29
  Works without reading settings or opening storage.
@@ -0,0 +1,14 @@
1
+ /** The runtime's name and version, reported the same way by `zinn info`, failure logs and telemetry */
2
+ export declare function currentRuntime(): {
3
+ name: "Node";
4
+ version: string;
5
+ } | {
6
+ name: "Bun";
7
+ version: string;
8
+ };
9
+ /** When this process started and how long it has run, in milliseconds */
10
+ export declare function readRunClock(): {
11
+ now: Date;
12
+ elapsedMs: number;
13
+ startedAt: Date;
14
+ };
@@ -0,0 +1,14 @@
1
+ const MS_PER_SECOND = 1000;
2
+ /** The runtime's name and version, reported the same way by `zinn info`, failure logs and telemetry */
3
+ export function currentRuntime() {
4
+ const { bun, node } = process.versions;
5
+ return bun === undefined
6
+ ? { name: "Node", version: node }
7
+ : { name: "Bun", version: bun };
8
+ }
9
+ /** When this process started and how long it has run, in milliseconds */
10
+ export function readRunClock() {
11
+ const elapsedMs = Math.round(process.uptime() * MS_PER_SECOND);
12
+ const now = new Date();
13
+ return { now, elapsedMs, startedAt: new Date(now.getTime() - elapsedMs) };
14
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Creates a folder if its store exists.
3
+ * ! It never creates the store, which **read** commands avoid
4
+ */
5
+ export declare function ensureFolderInStore(folder: string): void;
@@ -0,0 +1,16 @@
1
+ import { mkdirSync } from "node:fs";
2
+ /**
3
+ * Creates a folder if its store exists.
4
+ * ! It never creates the store, which **read** commands avoid
5
+ */
6
+ export function ensureFolderInStore(folder) {
7
+ try {
8
+ mkdirSync(folder);
9
+ }
10
+ catch (error) {
11
+ const alreadyExists = error.code === "EEXIST";
12
+ if (!alreadyExists) {
13
+ throw error;
14
+ }
15
+ }
16
+ }
@@ -0,0 +1,31 @@
1
+ import type { ClassifiedFailure } from "./errors.js";
2
+ import type { ParsedRoute } from "./types.js";
3
+ type RunOutcome = {
4
+ failure?: ClassifiedFailure;
5
+ logFileName?: string;
6
+ };
7
+ type UnmatchedRun = {
8
+ namespace: string;
9
+ unmatchedWord?: string;
10
+ help: boolean;
11
+ };
12
+ type MatchedRun = {
13
+ match: ParsedRoute;
14
+ typedRoute: string;
15
+ commandArgs: Array<string>;
16
+ help: boolean;
17
+ };
18
+ /** A successful run of a command that declares one of these only reads or reports, and leaves no record */
19
+ export declare const UNRECORDED_STORAGE_EFFECTS: ReadonlyArray<ParsedRoute["effects"]["storage"]>;
20
+ export declare function noteMatchedRun(run: MatchedRun): void;
21
+ /** An option-shaped word is left out of `unmatchedWord` because it can carry a value. `options` names it */
22
+ export declare function noteUnmatchedRun({ namespace, unmatchedWord, help }: UnmatchedRun): void;
23
+ export declare function noteParseArgsThrew(): void;
24
+ /**
25
+ * Appends this run's record to the current record file in the store's `telemetry` folder.
26
+ * A run that starts a new file first deletes old ones, so the newest records are the ones kept.
27
+ * It never throws, so recording cannot change a run's result.
28
+ * Returns one sentence saying what went wrong, or undefined when nothing did or no record was due.
29
+ */
30
+ export declare function writeRunRecord(outcome: RunOutcome): string | undefined;
31
+ export {};