@zinn-dev/cli 0.42.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 (41) hide show
  1. package/package.json +3 -4
  2. package/skills/zinn/SKILL.md +1 -1
  3. package/src/capabilities-schema.d.ts +3 -3
  4. package/src/errors.d.ts +31 -3
  5. package/src/errors.js +75 -20
  6. package/src/lib.d.ts +14 -5
  7. package/src/lib.js +68 -33
  8. package/src/list-continuation.d.ts +11 -0
  9. package/src/list-continuation.js +18 -0
  10. package/src/list-limit.d.ts +11 -0
  11. package/src/list-limit.js +17 -0
  12. package/src/presentation/activity-presentation.js +18 -5
  13. package/src/presentation/description-presentation.d.ts +3 -16
  14. package/src/presentation/description-presentation.js +22 -21
  15. package/src/presentation/project-presentation.d.ts +6 -2
  16. package/src/presentation/project-presentation.js +9 -1
  17. package/src/presentation/relation-presentation.d.ts +6 -1
  18. package/src/presentation/relation-presentation.js +14 -0
  19. package/src/presentation/row-layout.d.ts +1 -1
  20. package/src/presentation/row-layout.js +6 -5
  21. package/src/presentation/task-presentation.js +7 -1
  22. package/src/presentation/text-width.d.ts +2 -0
  23. package/src/presentation/text-width.js +43 -0
  24. package/src/presentation/time.d.ts +3 -1
  25. package/src/presentation/time.js +5 -2
  26. package/src/result-schemas.d.ts +49 -3
  27. package/src/result-schemas.js +12 -3
  28. package/src/routes/activity-router.d.ts +45 -1
  29. package/src/routes/activity-router.js +113 -15
  30. package/src/routes/project-router.d.ts +40 -0
  31. package/src/routes/project-router.js +73 -12
  32. package/src/routes/relation-router.d.ts +7 -3
  33. package/src/routes/relation-router.js +73 -56
  34. package/src/routes/restore-router.js +2 -5
  35. package/src/routes/router.js +54 -27
  36. package/src/routes/routes.d.ts +169 -7
  37. package/src/routes/task-router.d.ts +84 -6
  38. package/src/routes/task-router.js +107 -19
  39. package/src/timestamp-input.d.ts +3 -0
  40. package/src/timestamp-input.js +31 -0
  41. package/src/types.d.ts +3 -3
@@ -57,12 +57,55 @@ export declare const activityRouter: {
57
57
  readonly name: "id";
58
58
  };
59
59
  };
60
+ readonly since: {
61
+ readonly type: "string";
62
+ readonly value: {
63
+ readonly kind: "timestamp";
64
+ readonly name: "time";
65
+ readonly description: "Inclusive lower bound. Integer epoch milliseconds or YYYY-MM-DDTHH:mm:ss with Z or a numeric offset. Optional fractional seconds have 1 to 3 digits.";
66
+ };
67
+ };
68
+ readonly until: {
69
+ readonly type: "string";
70
+ readonly value: {
71
+ readonly kind: "timestamp";
72
+ readonly name: "time";
73
+ readonly description: "Inclusive upper bound in the same formats as --since. Must be at or after --since.";
74
+ };
75
+ };
76
+ readonly action: {
77
+ readonly type: "string";
78
+ readonly multiple: true;
79
+ readonly value: {
80
+ readonly kind: "activity-action";
81
+ readonly name: "action";
82
+ readonly choices: ("create" | "delete" | "archive" | "edit" | "move" | "order" | "unarchive" | "relation_create" | "relation_delete" | "comment_create" | "comment_edit" | "comment_delete")[];
83
+ };
84
+ };
85
+ readonly changed: {
86
+ readonly type: "string";
87
+ readonly multiple: true;
88
+ readonly value: {
89
+ readonly kind: "activity-change";
90
+ readonly name: "field[=value]";
91
+ readonly pattern: `^((${string})|(${string})=.+)$`;
92
+ readonly description: `Fields: ${string}. Omit the value to match any change. Values apply to column, priority and added labels, ignoring case. priority=none matches an unassigned priority.`;
93
+ };
94
+ };
60
95
  readonly limit: {
61
96
  readonly type: "string";
62
97
  readonly value: {
63
98
  readonly kind: "positive-integer";
64
99
  readonly name: "n";
65
- readonly pattern: "^[1-9]\\d{0,14}\\d?$";
100
+ readonly pattern: string;
101
+ };
102
+ readonly description: "Return at most n results after all filters. Use an integer from 1 through 11871.";
103
+ };
104
+ readonly "starting-after": {
105
+ readonly type: "string";
106
+ readonly value: {
107
+ readonly kind: "activity-id";
108
+ readonly name: "id";
66
109
  };
67
110
  };
68
111
  };
@@ -78,6 +121,7 @@ export declare const activityRouter: {
78
121
  readonly input: "option:show-deleted";
79
122
  readonly members: readonly ["option:project", "option:task"];
80
123
  }];
124
+ readonly notes: readonly ["Repeated --action flags match any listed action. Repeated --changed filters for one field match any of them. Different fields must match the same event. All other filters must also match, before --limit applies."];
81
125
  };
82
126
  results: import("../results.js").CommandResult[];
83
127
  run: (args: string[]) => void;
@@ -1,10 +1,14 @@
1
+ import { listLimitOption, listLimitDescription, parseListLimit } from "../list-limit.js";
1
2
  import { jsonResult } from "../results.js";
2
3
  import { parseArgs } from "node:util";
3
- import { activity, activityLimitMessage, CoreError, positiveIntegerPattern } from "@zinn-dev/core";
4
+ import { activity, activityActionSchema, activityChangedFieldSchema, activityChangedSchema, CoreError, } from "@zinn-dev/core";
4
5
  import { generateCommandUsage, getOptionInputs, violatesConstraint } from "../input.js";
5
6
  import { CliError } from "../errors.js";
6
- import { output, quit, validatePositionals, validateUniqueOptions } from "../lib.js";
7
+ import { parseTimestampInput } from "../timestamp-input.js";
8
+ import { formatListContinuation } from "../list-continuation.js";
9
+ import { diagnostic, output, quit, validatePositionals, validateUniqueOptions } from "../lib.js";
7
10
  import { formatActivityList, presentActivities } from "../presentation/activity-presentation.js";
11
+ const changedFieldList = activityChangedFieldSchema.options.join(", ");
8
12
  const activityInputs = {
9
13
  list: {
10
14
  options: {
@@ -29,10 +33,39 @@ const activityInputs = {
29
33
  "show-deleted": { type: "boolean" },
30
34
  session: { type: "string", value: { kind: "text", name: "id" } },
31
35
  thread: { type: "string", value: { kind: "text", name: "id" } },
32
- limit: {
36
+ since: {
33
37
  type: "string",
34
- value: { kind: "positive-integer", name: "n", pattern: `^${positiveIntegerPattern}\\d?$` },
38
+ value: {
39
+ kind: "timestamp",
40
+ name: "time",
41
+ description: "Inclusive lower bound. Integer epoch milliseconds or YYYY-MM-DDTHH:mm:ss with Z or a numeric offset. Optional fractional seconds have 1 to 3 digits.",
42
+ },
43
+ },
44
+ until: {
45
+ type: "string",
46
+ value: {
47
+ kind: "timestamp",
48
+ name: "time",
49
+ description: "Inclusive upper bound in the same formats as --since. Must be at or after --since.",
50
+ },
51
+ },
52
+ action: {
53
+ type: "string",
54
+ multiple: true,
55
+ value: { kind: "activity-action", name: "action", choices: activityActionSchema.options },
56
+ },
57
+ changed: {
58
+ type: "string",
59
+ multiple: true,
60
+ value: {
61
+ kind: "activity-change",
62
+ name: "field[=value]",
63
+ pattern: `^((${activityChangedFieldSchema.options.join("|")})|(${activityChangedFieldSchema.exclude(["title", "description"]).options.join("|")})=.+)$`,
64
+ description: `Fields: ${changedFieldList}. Omit the value to match any change. Values apply to column, priority and added labels, ignoring case. priority=none matches an unassigned priority.`,
65
+ },
35
66
  },
67
+ limit: listLimitOption,
68
+ "starting-after": { type: "string", value: { kind: "activity-id", name: "id" } },
36
69
  },
37
70
  forms: [{ id: "default", positionals: [] }],
38
71
  constraints: [
@@ -46,6 +79,9 @@ const activityInputs = {
46
79
  members: ["option:project", "option:task"],
47
80
  },
48
81
  ],
82
+ notes: [
83
+ "Repeated --action flags match any listed action. Repeated --changed filters for one field match any of them. Different fields must match the same event. All other filters must also match, before --limit applies.",
84
+ ],
49
85
  },
50
86
  view: {
51
87
  options: {},
@@ -88,14 +124,10 @@ export const activityRouter = {
88
124
  argument: "--show-deleted",
89
125
  });
90
126
  }
91
- // Safe integers can have one more digit than readable task numbers.
92
- const limitPattern = new RegExp(activityInputs.list.options.limit.value.pattern);
93
- if (values.limit !== undefined && !limitPattern.test(values.limit)) {
94
- quit(activityLimitMessage, undefined, { argument: "--limit" });
95
- }
96
- let events;
127
+ const limit = parseListLimit(values.limit);
128
+ let page;
97
129
  try {
98
- events = activity.getAll({
130
+ page = activity.getAll({
99
131
  projectKey: values.project,
100
132
  projectId: values["project-id"],
101
133
  taskKey: values.task,
@@ -103,10 +135,32 @@ export const activityRouter = {
103
135
  showDeleted: values["show-deleted"],
104
136
  sessionId: values.session,
105
137
  threadId: values.thread,
106
- limit: values.limit === undefined ? undefined : Number(values.limit),
138
+ actions: values.action?.map((action) => {
139
+ const parsed = activityActionSchema.safeParse(action);
140
+ if (!parsed.success) {
141
+ quit(`Unknown action "${action}". Use ${activityActionSchema.options.join(", ")}`, undefined, {
142
+ argument: "--action",
143
+ });
144
+ }
145
+ return parsed.data;
146
+ }),
147
+ changed: values.changed?.map(parseChangedFilter),
148
+ since: parseTimestampInput(values.since, "--since"),
149
+ until: parseTimestampInput(values.until, "--until"),
150
+ limit,
151
+ startingAfter: values["starting-after"],
107
152
  });
108
153
  }
109
154
  catch (error) {
155
+ const isInvalidUpperBound = error instanceof CoreError &&
156
+ error.kind === "input" &&
157
+ error.facts.field?.[0] === "until";
158
+ if (isInvalidUpperBound) {
159
+ throw new CliError(error.message, "invalid_input", {
160
+ argument: "--until",
161
+ field: error.facts.field,
162
+ });
163
+ }
110
164
  const isMissingCurrentSelection = (values.task !== undefined || values.project !== undefined) &&
111
165
  values["show-deleted"] !== true &&
112
166
  error instanceof CoreError &&
@@ -123,13 +177,16 @@ export const activityRouter = {
123
177
  }
124
178
  throw error;
125
179
  }
126
- output(events, (items) => formatActivityList(presentActivities(items, {
180
+ output(page.events, (items) => formatActivityList(presentActivities(items, {
127
181
  projectKey: values.project,
128
182
  projectId: values["project-id"],
129
183
  showDeleted: values["show-deleted"],
130
184
  taskKey: values.task,
131
185
  taskId: values["task-id"],
132
186
  })));
187
+ if (page.hasMore) {
188
+ diagnostic(`More activity. Continue with: ${formatListContinuation(["activity", "list"], [], tokens, "starting-after", page.events.at(-1).id)}`);
189
+ }
133
190
  },
134
191
  help: `${generateCommandUsage("activity list", activityInputs.list)}
135
192
 
@@ -145,11 +202,32 @@ Returns all matching events unless --limit is supplied.
145
202
  Requires a full UUID.
146
203
  --session <id> Match an exact session ID, including case.
147
204
  --thread <id> Match an exact thread ID, including case.
148
- --limit <n> Return at most n matching events.
205
+ --since <time> Include events at or after this time.
206
+ --until <time> Include events at or before this time.
207
+ --action <action> Match a recorded action. Repeat to match any listed action.
208
+ --changed <field>[=<value>] Match a task field change, with an optional value.
209
+ Fields: ${changedFieldList}.
210
+ Values apply to column, priority and added labels, ignoring case.
211
+ Without a value, labels match additions and removals.
212
+ Title and description match any change, without a value.
213
+ Use priority=none for an unassigned priority.
214
+ --limit <n> ${listLimitDescription}
215
+ --starting-after <id> Continue with older events after this activity ID.
216
+
217
+ Continuation accepts the same IDs as activity view. The cursor event need not
218
+ match the filters. Omit --limit to return every remaining match.
219
+ When more matches exist, stderr gives the command to continue, including with --json.
149
220
 
150
221
  Use one of --project, --project-id, --task or --task-id.
151
222
  --show-deleted requires --project or --task.
152
- All supplied filters must match.
223
+ Repeated --action flags match any listed action.
224
+ Repeated --changed filters for one field match any of them.
225
+ Different fields must match the same event. All other filters must also match.
226
+ Initial task values also match. Column and label names match as recorded.
227
+
228
+ Times accept integer epoch milliseconds or YYYY-MM-DDTHH:mm:ss with Z or a
229
+ numeric offset such as +01:00. Optional fractional seconds have 1 to 3 digits.
230
+ Both bounds are inclusive. --until must be at or after --since.
153
231
 
154
232
  Use activity view <activity-id> for complete recorded changes.
155
233
  With --json, return an array of full activity records.
@@ -157,6 +235,11 @@ With --json, return an array of full activity records.
157
235
  Examples:
158
236
  zinn activity list --limit 10
159
237
  zinn activity list --project APP
238
+ zinn activity list --since 2026-10-25T00:00:00Z --until 2026-10-25T12:00:00Z
239
+ zinn activity list --action comment_create --action comment_edit
240
+ zinn activity list --action edit --changed description
241
+ zinn activity list --changed column=Review
242
+ zinn activity list --changed priority=high --changed labels=bug
160
243
  zinn activity list --task APP-2
161
244
  zinn activity list --task APP-2 --show-deleted`,
162
245
  },
@@ -190,3 +273,18 @@ With --json, return one full activity record.
190
273
  Example: zinn activity view 019abcdf-1234-7`,
191
274
  },
192
275
  };
276
+ function parseChangedFilter(input) {
277
+ const separator = input.indexOf("=");
278
+ const field = separator === -1 ? input : input.slice(0, separator);
279
+ const value = input.slice(separator + 1);
280
+ const filter = activityChangedSchema.safeParse(separator === -1
281
+ ? { field }
282
+ : {
283
+ field,
284
+ value: field === "priority" && value.toLowerCase() === "none" ? null : value,
285
+ });
286
+ if (!filter.success) {
287
+ quit(filter.error.issues[0].message, undefined, { argument: "--changed" });
288
+ }
289
+ return filter.data;
290
+ }
@@ -407,5 +407,45 @@ export declare const projectRouter: {
407
407
  run: (args: Array<string>) => void;
408
408
  help: string;
409
409
  };
410
+ delete: {
411
+ summary: string;
412
+ effects: {
413
+ domain: "delete";
414
+ storage: "normal-open";
415
+ };
416
+ confirmation: {
417
+ kind: "prompt";
418
+ description: string;
419
+ };
420
+ input: {
421
+ readonly options: {
422
+ readonly yes: {
423
+ readonly type: "boolean";
424
+ };
425
+ };
426
+ readonly forms: readonly [{
427
+ readonly id: "default";
428
+ readonly positionals: readonly [{
429
+ readonly name: "project-key";
430
+ readonly min: 1;
431
+ readonly max: 1;
432
+ readonly value: {
433
+ readonly kind: "project-key";
434
+ };
435
+ }, {
436
+ readonly name: "column-name";
437
+ readonly min: 1;
438
+ readonly max: 1;
439
+ readonly value: {
440
+ readonly kind: "column-name";
441
+ };
442
+ }];
443
+ }];
444
+ readonly constraints: readonly [];
445
+ };
446
+ results: import("../results.js").CommandResult[];
447
+ run: (args: string[]) => Promise<void>;
448
+ help: string;
449
+ };
410
450
  };
411
451
  };
@@ -1,6 +1,6 @@
1
1
  import { jsonResult } from "../results.js";
2
2
  import { parseArgs } from "node:util";
3
- import { column, project, columnOrderSchema, projectCreateSchema, projectEditSchema, } from "@zinn-dev/core";
3
+ import { column, project, 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";
@@ -110,6 +110,19 @@ const projectInputs = {
110
110
  ],
111
111
  constraints: [],
112
112
  },
113
+ column_delete: {
114
+ options: { yes: { type: "boolean" } },
115
+ forms: [
116
+ {
117
+ id: "default",
118
+ positionals: [
119
+ { name: "project-key", min: 1, max: 1, value: { kind: "project-key" } },
120
+ { name: "column-name", min: 1, max: 1, value: { kind: "column-name" } },
121
+ ],
122
+ },
123
+ ],
124
+ constraints: [],
125
+ },
113
126
  column_order: {
114
127
  options: {},
115
128
  forms: [
@@ -187,7 +200,7 @@ ${dashValueHelp("--description")}
187
200
  Example: zinn project create MDR --name 'Macrodata Refinement'`,
188
201
  },
189
202
  list: {
190
- summary: "List projects, their keys, and truncated description previews.",
203
+ summary: "List projects with active and archived task counts.",
191
204
  effects: { domain: "read", storage: "normal-open" },
192
205
  confirmation: { kind: "none" },
193
206
  input: projectInputs.list,
@@ -200,12 +213,16 @@ Example: zinn project create MDR --name 'Macrodata Refinement'`,
200
213
  strict: true,
201
214
  });
202
215
  validatePositionals(positionals, projectInputs.list.forms[0]);
203
- const projects = project.getAll();
204
- output(projects.map(presentProject), formatProjectList);
216
+ const projects = project
217
+ .getAllWithTaskCounts()
218
+ .map((entry) => ({ ...presentProject(entry), taskCounts: entry.taskCounts }));
219
+ output(projects, (entries) => formatProjectList(entries, { showsTaskCounts: true }));
205
220
  },
206
221
  help: `${generateCommandUsage("project list", projectInputs.list)}
207
222
 
208
- List projects, their keys, and truncated description previews.
223
+ List projects with active and archived task counts.
224
+ Active tasks are unarchived tasks in any column, including Done.
225
+ With --json, each project includes taskCounts: { active, archived }, including zeros.
209
226
 
210
227
  Example: zinn project list`,
211
228
  },
@@ -226,7 +243,7 @@ Example: zinn project list`,
226
243
  const projectKey = resolveProjectKey(positionals[0], { required: true });
227
244
  const projectMatch = project.getByKey(projectKey);
228
245
  if (projectMatch == null) {
229
- throw new CliError(`Project with key "${project.standardizeKey(projectKey)}" does not exist!`, "not_found", { entity: "project", key: project.standardizeKey(projectKey), source: "explicit" });
246
+ throw new CliError(`Project with key "${project.standardizeKey(projectKey)}" does not exist`, "not_found", { entity: "project", key: project.standardizeKey(projectKey), source: "explicit" });
230
247
  }
231
248
  const taskCounts = column.getTaskCountsByProjectKey(projectMatch.key);
232
249
  const presentedProject = {
@@ -244,11 +261,13 @@ Example: zinn project list`,
244
261
  if (viewedProject.description != null) {
245
262
  sections.push(formatSection("Description", viewedProject.description));
246
263
  }
247
- const columnTaskCounts = formatColumnList(viewedProject.columns, {
248
- showsTaskCounts: true,
249
- archivedTaskCount: viewedProject.archivedTaskCount,
250
- });
251
- sections.push(formatSection("Columns", columnTaskCounts));
264
+ if (viewedProject.columns.length > 0) {
265
+ const columnTaskCounts = formatColumnList(viewedProject.columns, {
266
+ showsTaskCounts: true,
267
+ archivedTaskCount: viewedProject.archivedTaskCount,
268
+ });
269
+ sections.push(formatSection("Columns", columnTaskCounts));
270
+ }
252
271
  return sections.join("\n\n");
253
272
  });
254
273
  },
@@ -332,7 +351,7 @@ Examples:
332
351
  try {
333
352
  const projectMatch = project.getByKey(projectKey);
334
353
  if (projectMatch == null) {
335
- throw new CliError(`Project with key "${projectKey}" does not exist!`, "not_found", {
354
+ throw new CliError(`Project with key "${projectKey}" does not exist`, "not_found", {
336
355
  entity: "project",
337
356
  key: projectKey,
338
357
  source: "explicit",
@@ -514,5 +533,47 @@ With --json, changed is false when the column was already in that position.
514
533
 
515
534
  Example: zinn project column order MDR Review before 'In Progress'`,
516
535
  },
536
+ delete: {
537
+ summary: "Delete an empty project column after confirmation.",
538
+ effects: { domain: "delete", storage: "normal-open" },
539
+ confirmation: { kind: "prompt", description: confirmationDescription },
540
+ input: projectInputs.column_delete,
541
+ results: [jsonResult("Column")],
542
+ run: async (args) => {
543
+ const { values, positionals, tokens } = parseArgs({
544
+ args,
545
+ options: projectInputs.column_delete.options,
546
+ allowPositionals: true,
547
+ strict: true,
548
+ tokens: true,
549
+ });
550
+ validateUniqueOptions(tokens, projectInputs.column_delete.options);
551
+ validatePositionals(positionals, projectInputs.column_delete.forms[0]);
552
+ const props = columnDeleteSchema.parse({
553
+ projectKey: positionals[0],
554
+ columnName: positionals[1],
555
+ });
556
+ const columnMatch = column.getByName(props.projectKey, props.columnName);
557
+ const presentedColumn = presentColumn(columnMatch);
558
+ const canDelete = await confirmAction(`Are you sure you want to delete column "${columnMatch.name}" from ${presentedColumn.project}?`, values.yes === true);
559
+ if (!canDelete) {
560
+ output(presentedColumn, (entry) => `Deletion cancelled for ${formatColumnList([entry], { showsProject: true })}`);
561
+ return;
562
+ }
563
+ const deletedColumn = column.delete(props, currentActor());
564
+ output(presentColumn(deletedColumn), (entry) => `Deleted ${formatColumnList([entry], { showsProject: true })}`);
565
+ },
566
+ help: `${generateCommandUsage("project column delete", projectInputs.column_delete)}
567
+
568
+ Delete an empty project column after confirmation.
569
+ Columns are matched by name, and matching is case-insensitive.
570
+ A column must hold no active or archived tasks. Use task move or task delete to clear it.
571
+ New tasks enter the project's first column unless --column selects another.
572
+ A project may have no columns. Add one with project column create before creating tasks.
573
+
574
+ Use --yes to skip the confirmation prompt, including with --json.
575
+
576
+ Example: zinn project column delete MDR Review`,
577
+ },
517
578
  },
518
579
  };
@@ -2,14 +2,18 @@ export declare const relationRouter: {
2
2
  create: {
3
3
  summary: string;
4
4
  effects: {
5
- domain: "create";
5
+ domain: "replace";
6
6
  storage: "normal-open";
7
7
  };
8
8
  confirmation: {
9
- kind: "none";
9
+ kind: "prompt";
10
+ description: string;
10
11
  };
11
12
  input: {
12
13
  readonly options: {
14
+ readonly yes: {
15
+ readonly type: "boolean";
16
+ };
13
17
  readonly type: {
14
18
  readonly type: "string";
15
19
  readonly required: true;
@@ -43,7 +47,7 @@ export declare const relationRouter: {
43
47
  guessedFlags: {
44
48
  [k: string]: (args: Array<string>) => string[] | undefined;
45
49
  };
46
- run: (args: string[]) => void;
50
+ run: (args: string[]) => Promise<void>;
47
51
  help: string;
48
52
  };
49
53
  list: {