@zinn-dev/cli 0.41.0 → 0.43.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/README.md +11 -689
  2. package/index.js +2 -2
  3. package/package.json +4 -4
  4. package/skills/zinn/SKILL.md +1 -1
  5. package/src/capabilities-schema.d.ts +25 -26
  6. package/src/capabilities-schema.js +17 -82
  7. package/src/capabilities.d.ts +11 -3
  8. package/src/capabilities.js +12 -4
  9. package/src/column-hint.d.ts +3 -0
  10. package/src/column-hint.js +225 -0
  11. package/src/database.js +1 -4
  12. package/src/errors.d.ts +31 -3
  13. package/src/errors.js +77 -20
  14. package/src/input.d.ts +154 -43
  15. package/src/input.js +86 -13
  16. package/src/lib.d.ts +43 -6
  17. package/src/lib.js +134 -38
  18. package/src/list-continuation.d.ts +11 -0
  19. package/src/list-continuation.js +18 -0
  20. package/src/list-limit.d.ts +11 -0
  21. package/src/list-limit.js +17 -0
  22. package/src/presentation/activity-presentation.d.ts +9 -1
  23. package/src/presentation/activity-presentation.js +124 -28
  24. package/src/presentation/capabilities-presentation.d.ts +2 -0
  25. package/src/presentation/capabilities-presentation.js +3 -0
  26. package/src/presentation/column-presentation.d.ts +6 -0
  27. package/src/presentation/column-presentation.js +10 -0
  28. package/src/presentation/comment-presentation.d.ts +15 -0
  29. package/src/presentation/comment-presentation.js +29 -0
  30. package/src/presentation/description-presentation.d.ts +4 -0
  31. package/src/presentation/description-presentation.js +28 -5
  32. package/src/presentation/label-presentation.d.ts +8 -0
  33. package/src/presentation/label-presentation.js +28 -0
  34. package/src/presentation/project-presentation.d.ts +11 -0
  35. package/src/presentation/project-presentation.js +27 -0
  36. package/src/presentation/relation-presentation.d.ts +12 -0
  37. package/src/presentation/relation-presentation.js +87 -0
  38. package/src/presentation/row-layout.d.ts +1 -1
  39. package/src/presentation/row-layout.js +6 -5
  40. package/src/presentation/task-presentation.d.ts +3 -3
  41. package/src/presentation/task-presentation.js +29 -19
  42. package/src/presentation/text-width.d.ts +2 -0
  43. package/src/presentation/text-width.js +43 -0
  44. package/src/presentation/time.d.ts +3 -1
  45. package/src/presentation/time.js +5 -2
  46. package/src/project.d.ts +14 -5
  47. package/src/project.js +18 -6
  48. package/src/result-schemas.d.ts +279 -26
  49. package/src/result-schemas.js +72 -4
  50. package/src/results.d.ts +34 -17
  51. package/src/results.js +19 -0
  52. package/src/routes/activity-router.d.ts +79 -2
  53. package/src/routes/activity-router.js +209 -38
  54. package/src/routes/aliases.d.ts +2 -0
  55. package/src/routes/aliases.js +11 -0
  56. package/src/routes/capabilities-router.js +9 -3
  57. package/src/routes/comment-router.d.ts +41 -18
  58. package/src/routes/comment-router.js +65 -48
  59. package/src/routes/label-router.d.ts +57 -7
  60. package/src/routes/label-router.js +84 -39
  61. package/src/routes/project-router.d.ts +74 -12
  62. package/src/routes/project-router.js +131 -66
  63. package/src/routes/relation-router.d.ts +13 -9
  64. package/src/routes/relation-router.js +116 -116
  65. package/src/routes/restore-router.js +3 -6
  66. package/src/routes/router.d.ts +1 -1
  67. package/src/routes/router.js +88 -32
  68. package/src/routes/routes.d.ts +420 -50
  69. package/src/routes/routes.js +4 -0
  70. package/src/routes/task-router.d.ts +189 -30
  71. package/src/routes/task-router.js +254 -158
  72. package/src/routes/whoami-router.d.ts +21 -0
  73. package/src/routes/whoami-router.js +31 -0
  74. package/src/text-edit.d.ts +13 -9
  75. package/src/text-edit.js +23 -18
  76. package/src/text-input.d.ts +47 -0
  77. package/src/text-input.js +187 -0
  78. package/src/timestamp-input.d.ts +3 -0
  79. package/src/timestamp-input.js +31 -0
  80. package/src/types.d.ts +32 -9
  81. package/src/types.js +9 -1
@@ -3,31 +3,11 @@ import { parseArgs } from "node:util";
3
3
  import { label, labelColorSchema, labelCreateSchema, labelDeleteSchema, labelEditSchema, } from "@zinn-dev/core";
4
4
  import { CliError } from "../errors.js";
5
5
  import { generateCommandUsage, noInput } from "../input.js";
6
- import { confirmationDescription, confirmAction, dashValueHelp, output, validatePositionals, validateUniqueOptions, } from "../lib.js";
6
+ import { confirmationDescription, confirmAction, dashValueHelp, output, outputChanges, validatePositionals, 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
9
  import { currentActor } from "../actor.js";
9
- import { isColorEnabled } from "../presentation/color.js";
10
- import { formatRows } from "../presentation/row-layout.js";
11
- function presentLabel(labelMatch) {
12
- return { name: labelMatch.name, color: labelMatch.color, description: labelMatch.description };
13
- }
14
- function formatLabel(presented) {
15
- return formatLabelList([presented]);
16
- }
17
- function formatLabelList(presentedLabels) {
18
- return formatRows(presentedLabels.map((presented) => {
19
- const descriptionCells = presented.description == null ? [] : [{ text: presented.description }];
20
- /**
21
- * The colored name shows the color, and if the environment
22
- * does not support color, it is explicitly printed instead
23
- */
24
- if (isColorEnabled()) {
25
- const style = labelColorSchema.options.find((color) => color === presented.color);
26
- return [{ text: presented.name, style }, ...descriptionCells];
27
- }
28
- return [{ text: presented.name }, { text: presented.color }, ...descriptionCells];
29
- }));
30
- }
10
+ import { formatLabelList, presentLabel } from "../presentation/label-presentation.js";
31
11
  const colorOption = {
32
12
  type: "string",
33
13
  value: {
@@ -40,18 +20,30 @@ const labelInputs = {
40
20
  create: {
41
21
  options: {
42
22
  description: { type: "string", value: { kind: "text", name: "text" } },
23
+ "description-file": textFileOption,
43
24
  color: colorOption,
44
25
  },
45
26
  forms: [
46
27
  { id: "default", positionals: [{ name: "name", min: 1, max: 1, value: { kind: "name" } }] },
47
28
  ],
48
- constraints: [],
29
+ constraints: [textSourceConstraint("--description")],
49
30
  },
50
31
  list: noInput,
32
+ view: {
33
+ options: {},
34
+ forms: [
35
+ {
36
+ id: "default",
37
+ positionals: [{ name: "name", min: 1, max: 1, value: { kind: "label-name" } }],
38
+ },
39
+ ],
40
+ constraints: [],
41
+ },
51
42
  edit: {
52
43
  options: {
53
44
  name: { type: "string", value: { kind: "text", name: "text" } },
54
45
  description: { type: "string", value: { kind: "text", name: "text" } },
46
+ "description-file": textFileOption,
55
47
  ...textEditOptions,
56
48
  color: colorOption,
57
49
  },
@@ -59,12 +51,16 @@ const labelInputs = {
59
51
  { id: "default", positionals: [{ name: "name", min: 1, max: 1, value: { kind: "name" } }] },
60
52
  ],
61
53
  constraints: [
54
+ textSourceConstraint("--description"),
62
55
  ...textEditConstraints("--description"),
63
56
  {
64
57
  kind: "atLeastOne",
58
+ // A description can also come from --description-file
65
59
  members: Object.keys(labelEditSchema.shape)
66
60
  .filter((name) => name !== "labelName")
67
- .map((name) => `option:${name}`),
61
+ .flatMap((name) => name === "description"
62
+ ? textSourceConstraint("--description").members
63
+ : [`option:${name}`]),
68
64
  },
69
65
  ],
70
66
  notes: [textEditHelp("--description")],
@@ -84,7 +80,7 @@ export const labelRouter = {
84
80
  confirmation: { kind: "none" },
85
81
  input: labelInputs.create,
86
82
  results: [jsonResult("Label")],
87
- run: (args) => {
83
+ run: async (args) => {
88
84
  const { values, positionals, tokens } = parseArgs({
89
85
  args,
90
86
  options: labelInputs.create.options,
@@ -94,15 +90,23 @@ export const labelRouter = {
94
90
  });
95
91
  validateUniqueOptions(tokens, labelInputs.create.options);
96
92
  validatePositionals(positionals, labelInputs.create.forms[0]);
97
- const input = labelCreateSchema.parse({ name: positionals[0], ...values });
93
+ checkFieldsBeforeText(labelCreateSchema, { name: positionals[0], color: values.color });
94
+ const description = await resolveTextInput(values.description, values["description-file"], "--description");
95
+ const input = labelCreateSchema.parse({
96
+ name: positionals[0],
97
+ description,
98
+ color: values.color,
99
+ });
98
100
  const created = label.create(input, currentActor());
99
- output(presentLabel(created), formatLabel);
101
+ output(presentLabel(created), (entry) => formatLabelList([entry], { showsDescriptionPreview: true }));
100
102
  },
101
103
  help: `${generateCommandUsage("label create", labelInputs.create)}
102
104
 
103
105
  Create a global label. Names preserve casing, but uniqueness is case-insensitive.
104
106
  Names are trimmed and cannot be blank or contain line breaks or control characters.
105
107
  Description is optional.
108
+ ${textFileHelp("--description")}
109
+ The printed result is a preview. 'label view' and --json show the full text.
106
110
 
107
111
  Color defaults to white.
108
112
  Valid colors: ${labelInputs.create.options.color.value.choices.join(", ")}.
@@ -125,19 +129,53 @@ Example: zinn label create bug --description 'Unexpected behavior' --color red`,
125
129
  allowPositionals: true,
126
130
  });
127
131
  validatePositionals(positionals, labelInputs.list.forms[0]);
128
- output(label.getAll().map(presentLabel), formatLabelList);
132
+ output(label.getAll().map(presentLabel), (entries) => formatLabelList(entries, { showsDescriptionPreview: true }));
129
133
  },
130
134
  help: `${generateCommandUsage("label list", labelInputs.list)}
131
135
 
132
- List all global label definitions.`,
136
+ List all global label definitions.
137
+ Descriptions are previews.
138
+ Use label view <name> for the full description. --json keeps the full text.`,
139
+ },
140
+ view: {
141
+ summary: "Show a global label with its full description.",
142
+ effects: { domain: "read", storage: "normal-open" },
143
+ confirmation: { kind: "none" },
144
+ input: labelInputs.view,
145
+ results: [jsonResult("Label")],
146
+ run: (args) => {
147
+ const { positionals } = parseArgs({
148
+ args,
149
+ options: labelInputs.view.options,
150
+ strict: true,
151
+ allowPositionals: true,
152
+ });
153
+ validatePositionals(positionals, labelInputs.view.forms[0]);
154
+ const props = labelDeleteSchema.parse({ name: positionals[0] });
155
+ const labelMatch = label.getByName(props.name);
156
+ if (labelMatch == null) {
157
+ throw new CliError(`A label with name "${props.name}" does not exist`, "not_found", {
158
+ entity: "label",
159
+ key: props.name,
160
+ source: "explicit",
161
+ });
162
+ }
163
+ output(presentLabel(labelMatch), (entry) => formatLabelList([entry]));
164
+ },
165
+ help: `${generateCommandUsage("label view", labelInputs.view)}
166
+
167
+ Show a global label with its full description, preserving line breaks and whitespace.
168
+ Label names are matched case-insensitively.
169
+
170
+ Example: zinn label view bug`,
133
171
  },
134
172
  edit: {
135
173
  summary: "Change specified fields.",
136
174
  effects: { domain: "update", storage: "normal-open" },
137
175
  confirmation: { kind: "none" },
138
176
  input: labelInputs.edit,
139
- results: [jsonResult("Label")],
140
- run: (args) => {
177
+ results: [jsonResult("LabelChange")],
178
+ run: async (args) => {
141
179
  const { values, positionals, tokens } = parseArgs({
142
180
  args,
143
181
  options: labelInputs.edit.options,
@@ -147,26 +185,33 @@ List all global label definitions.`,
147
185
  });
148
186
  validateUniqueOptions(tokens, labelInputs.edit.options);
149
187
  validatePositionals(positionals, labelInputs.edit.forms[0]);
188
+ checkFieldsBeforeText(labelEditSchema, {
189
+ labelName: positionals[0],
190
+ name: values.name,
191
+ color: values.color,
192
+ });
193
+ const description = await resolveTextEdit(values, "--description");
150
194
  const input = labelEditSchema.parse({
151
195
  labelName: positionals[0],
152
196
  name: values.name,
153
- description: resolveTextEdit(values.description, values, "--description"),
197
+ description,
154
198
  color: values.color,
155
199
  });
156
200
  const edited = label.edit(input, currentActor());
157
- output(presentLabel(edited), formatLabel);
201
+ outputChanges([edited], (change) => presentLabel(change.label), (entries) => formatLabelList(entries, { showsDescriptionPreview: true }), (entry) => `Label "${entry.name}" was unchanged`);
158
202
  },
159
203
  help: `${generateCommandUsage("label edit", labelInputs.edit)}
160
204
 
161
205
  Change specified fields.
206
+ With --json, changed is false when all supplied values already match.
162
207
  Provide at least one edit flag. Use --description '' to clear the description.
208
+ ${textFileHelp("--description")}
209
+ Description echoes use a preview; label view and --json keep the full text.
163
210
  Valid colors: ${labelInputs.edit.options.color.value.choices.join(", ")}.
164
211
 
165
212
  ${textEditHelp("--description")}
166
213
 
167
- Names are matched and kept unique case-insensitively while preserving their casing.
168
- Names are trimmed. Changing only the casing is allowed.
169
- Editing does not affect task attachments or task timestamps.
214
+ Label names match without case sensitivity.
170
215
 
171
216
  ${dashValueHelp("--description")}
172
217
 
@@ -201,11 +246,11 @@ Examples:
201
246
  }
202
247
  const canDelete = await confirmAction(`Are you sure you want to delete label "${labelMatch.name}" and remove it from all tasks?`, values.yes === true);
203
248
  if (!canDelete) {
204
- output(presentLabel(labelMatch), (l) => `Deletion cancelled for label "${l.name}"`);
249
+ output(presentLabel(labelMatch), (entry) => `Deletion cancelled for ${formatLabelList([entry], { showsDescriptionPreview: true })}`);
205
250
  return;
206
251
  }
207
252
  const deleted = label.delete(props, currentActor());
208
- output(presentLabel(deleted), (l) => `Deleted label "${l.name}"`);
253
+ output(presentLabel(deleted), (entry) => `Deleted ${formatLabelList([entry], { showsDescriptionPreview: true })}`);
209
254
  },
210
255
  help: `${generateCommandUsage("label delete", labelInputs.delete)}
211
256
 
@@ -24,6 +24,14 @@ export declare const projectRouter: {
24
24
  readonly name: "text";
25
25
  };
26
26
  };
27
+ readonly "description-file": {
28
+ readonly type: "string";
29
+ readonly value: {
30
+ readonly kind: "path";
31
+ readonly name: "path";
32
+ readonly description: "A UTF-8 file, or \"-\" for stdin. Trailing line breaks are dropped; empty or blank input is an error.";
33
+ };
34
+ };
27
35
  };
28
36
  readonly forms: readonly [{
29
37
  readonly id: "default";
@@ -36,10 +44,13 @@ export declare const projectRouter: {
36
44
  };
37
45
  }];
38
46
  }];
39
- readonly constraints: readonly [];
47
+ readonly constraints: readonly [{
48
+ readonly kind: "exclusive";
49
+ readonly members: readonly ["option:description" | "option:text", "option:description-file" | "option:text-file"];
50
+ }];
40
51
  };
41
52
  results: import("../results.js").CommandResult[];
42
- run: (args: Array<string>) => void;
53
+ run: (args: Array<string>) => Promise<void>;
43
54
  help: string;
44
55
  };
45
56
  list: {
@@ -86,7 +97,7 @@ export declare const projectRouter: {
86
97
  }];
87
98
  }];
88
99
  readonly constraints: readonly [];
89
- readonly notes: readonly ["An omitted project key uses defaultProject from settings. Without a configured default, a project key is required. A missing configured project is an error."];
100
+ readonly notes: readonly ["Omit the project key to use defaultProject from settings; otherwise a project key is required."];
90
101
  };
91
102
  results: import("../results.js").CommandResult[];
92
103
  run: (args: Array<string>) => void;
@@ -130,6 +141,14 @@ export declare const projectRouter: {
130
141
  readonly name: "text";
131
142
  };
132
143
  };
144
+ readonly "description-file": {
145
+ readonly type: "string";
146
+ readonly value: {
147
+ readonly kind: "path";
148
+ readonly name: "path";
149
+ readonly description: "A UTF-8 file, or \"-\" for stdin. Trailing line breaks are dropped; empty or blank input is an error.";
150
+ };
151
+ };
133
152
  };
134
153
  readonly forms: readonly [{
135
154
  readonly id: "default";
@@ -143,28 +162,31 @@ export declare const projectRouter: {
143
162
  }];
144
163
  }];
145
164
  readonly constraints: readonly [{
165
+ readonly kind: "exclusive";
166
+ readonly members: readonly ["option:description" | "option:text", "option:description-file" | "option:text-file"];
167
+ }, {
146
168
  readonly kind: "exclusive";
147
169
  readonly members: readonly ["option:append", "option:replacing"];
148
170
  }, {
149
- readonly kind: "requires";
171
+ readonly kind: "requiresAny";
150
172
  readonly input: "option:append";
151
- readonly requires: `option:${string}`;
173
+ readonly members: readonly ["option:description" | "option:text", "option:description-file" | "option:text-file"];
152
174
  }, {
153
- readonly kind: "requires";
175
+ readonly kind: "requiresAny";
154
176
  readonly input: "option:replacing";
155
- readonly requires: `option:${string}`;
177
+ readonly members: readonly ["option:description" | "option:text", "option:description-file" | "option:text-file"];
156
178
  }, {
157
179
  readonly kind: "requires";
158
180
  readonly input: "option:all";
159
181
  readonly requires: "option:replacing";
160
182
  }, {
161
183
  readonly kind: "atLeastOne";
162
- readonly members: readonly ["option:name", "option:description"];
184
+ readonly members: readonly ["option:name", "option:description", "option:description-file"];
163
185
  }];
164
- readonly notes: readonly ["An omitted project key uses defaultProject from settings. Without a configured default, a project key is required. A missing configured project is an error.", string];
186
+ readonly notes: readonly ["Omit the project key to use defaultProject from settings; otherwise a project key is required.", string];
165
187
  };
166
188
  results: import("../results.js").CommandResult[];
167
- run: (args: string[]) => void;
189
+ run: (args: string[]) => Promise<void>;
168
190
  help: string;
169
191
  };
170
192
  delete: {
@@ -195,7 +217,7 @@ export declare const projectRouter: {
195
217
  }];
196
218
  }];
197
219
  readonly constraints: readonly [];
198
- readonly notes: readonly ["An omitted project key uses defaultProject from settings. Without a configured default, a project key is required. A missing configured project is an error."];
220
+ readonly notes: readonly ["Omit the project key to use defaultProject from settings; otherwise a project key is required."];
199
221
  };
200
222
  results: import("../results.js").CommandResult[];
201
223
  run: (args: Array<string>) => Promise<void>;
@@ -260,7 +282,7 @@ export declare const projectRouter: {
260
282
  }];
261
283
  }];
262
284
  readonly constraints: readonly [];
263
- readonly notes: readonly ["An omitted project key uses defaultProject from settings. Without a configured default, a project key is required. A missing configured project is an error."];
285
+ readonly notes: readonly ["Omit the project key to use defaultProject from settings; otherwise a project key is required."];
264
286
  };
265
287
  results: import("../results.js").CommandResult[];
266
288
  run: (args: Array<string>) => void;
@@ -385,5 +407,45 @@ export declare const projectRouter: {
385
407
  run: (args: Array<string>) => void;
386
408
  help: string;
387
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
+ };
388
450
  };
389
451
  };