@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
@@ -1,6 +1,7 @@
1
1
  import { parseArgs } from "node:util";
2
2
  import { generateCommandUsage, noInput } from "../input.js";
3
- import { output, validatePositionals } from "../lib.js";
3
+ import { getOutputMode, output, validatePositionals } from "../lib.js";
4
+ import { formatCapabilities } from "../presentation/capabilities-presentation.js";
4
5
  import { jsonResult } from "../results.js";
5
6
  export const capabilitiesCommand = {
6
7
  summary: "Describe the installed CLI commands, inputs, results and errors.",
@@ -16,8 +17,13 @@ export const capabilitiesCommand = {
16
17
  allowPositionals: true,
17
18
  });
18
19
  validatePositionals(positionals, noInput.forms[0]);
19
- const { generateCapabilities } = await import("../capabilities.js");
20
- output(generateCapabilities(), (manifest) => `${manifest.cli.name} ${manifest.cli.version} (Experimental): ${manifest.commands.length} commands, manifest format ${manifest.manifestVersion}.\nRun zinn capabilities --json for the full contract.`);
20
+ const { generateCapabilities, getCapabilitySummary } = await import("../capabilities.js");
21
+ if (getOutputMode() === "json") {
22
+ output(generateCapabilities(), () => formatCapabilities(getCapabilitySummary()));
23
+ }
24
+ else {
25
+ output(getCapabilitySummary(), formatCapabilities);
26
+ }
21
27
  },
22
28
  help: `${generateCommandUsage("capabilities", noInput)}
23
29
 
@@ -1,12 +1,3 @@
1
- import type { PresentedComment } from "../result-schemas.js";
2
- export declare function presentComments(taskKey: string): {
3
- key: string;
4
- text: string;
5
- created_at: number;
6
- updated_at: number;
7
- }[];
8
- export declare function formatComment(commentMatch: PresentedComment): string;
9
- export declare function formatComments(comments: Array<PresentedComment>): string;
10
1
  export declare const commentRouter: {
11
2
  create: {
12
3
  summary: string;
@@ -21,12 +12,19 @@ export declare const commentRouter: {
21
12
  readonly options: {
22
13
  readonly text: {
23
14
  readonly type: "string";
24
- readonly required: true;
25
15
  readonly value: {
26
16
  readonly kind: "text";
27
17
  readonly name: "text";
28
18
  };
29
19
  };
20
+ readonly "text-file": {
21
+ readonly type: "string";
22
+ readonly value: {
23
+ readonly kind: "path";
24
+ readonly name: "path";
25
+ readonly description: "A UTF-8 file, or \"-\" for stdin. Trailing line breaks are dropped; empty or blank input is an error.";
26
+ };
27
+ };
30
28
  };
31
29
  readonly forms: readonly [{
32
30
  readonly id: "default";
@@ -39,10 +37,19 @@ export declare const commentRouter: {
39
37
  };
40
38
  }];
41
39
  }];
42
- readonly constraints: readonly [];
40
+ readonly constraints: readonly [{
41
+ readonly kind: "exclusive";
42
+ readonly members: readonly ["option:description" | "option:text", "option:description-file" | "option:text-file"];
43
+ }, {
44
+ readonly kind: "atLeastOne";
45
+ readonly members: readonly ["option:text", "option:text-file"];
46
+ }];
43
47
  };
44
48
  results: import("../results.js").CommandResult[];
45
- run: (args: string[]) => void;
49
+ guessedFlags: {
50
+ "--body": (args: string[]) => string[];
51
+ };
52
+ run: (args: string[]) => Promise<void>;
46
53
  help: string;
47
54
  };
48
55
  list: {
@@ -127,12 +134,19 @@ export declare const commentRouter: {
127
134
  };
128
135
  readonly text: {
129
136
  readonly type: "string";
130
- readonly required: true;
131
137
  readonly value: {
132
138
  readonly kind: "text";
133
139
  readonly name: "text";
134
140
  };
135
141
  };
142
+ readonly "text-file": {
143
+ readonly type: "string";
144
+ readonly value: {
145
+ readonly kind: "path";
146
+ readonly name: "path";
147
+ readonly description: "A UTF-8 file, or \"-\" for stdin. Trailing line breaks are dropped; empty or blank input is an error.";
148
+ };
149
+ };
136
150
  };
137
151
  readonly forms: readonly [{
138
152
  readonly id: "default";
@@ -146,25 +160,34 @@ export declare const commentRouter: {
146
160
  }];
147
161
  }];
148
162
  readonly constraints: readonly [{
163
+ readonly kind: "exclusive";
164
+ readonly members: readonly ["option:description" | "option:text", "option:description-file" | "option:text-file"];
165
+ }, {
149
166
  readonly kind: "exclusive";
150
167
  readonly members: readonly ["option:append", "option:replacing"];
151
168
  }, {
152
- readonly kind: "requires";
169
+ readonly kind: "requiresAny";
153
170
  readonly input: "option:append";
154
- readonly requires: `option:${string}`;
171
+ readonly members: readonly ["option:description" | "option:text", "option:description-file" | "option:text-file"];
155
172
  }, {
156
- readonly kind: "requires";
173
+ readonly kind: "requiresAny";
157
174
  readonly input: "option:replacing";
158
- readonly requires: `option:${string}`;
175
+ readonly members: readonly ["option:description" | "option:text", "option:description-file" | "option:text-file"];
159
176
  }, {
160
177
  readonly kind: "requires";
161
178
  readonly input: "option:all";
162
179
  readonly requires: "option:replacing";
180
+ }, {
181
+ readonly kind: "atLeastOne";
182
+ readonly members: readonly ["option:text", "option:text-file"];
163
183
  }];
164
184
  readonly notes: readonly [string];
165
185
  };
166
186
  results: import("../results.js").CommandResult[];
167
- run: (args: string[]) => void;
187
+ guessedFlags: {
188
+ "--body": (args: string[]) => string[];
189
+ };
190
+ run: (args: string[]) => Promise<void>;
168
191
  help: string;
169
192
  };
170
193
  delete: {
@@ -1,38 +1,24 @@
1
1
  import { jsonResult } from "../results.js";
2
2
  import { parseArgs } from "node:util";
3
3
  import { comment } from "@zinn-dev/core";
4
- import { generateCommandUsage, taskKeyPositional } from "../input.js";
5
- import { confirmationDescription, confirmAction, dashValueHelp, output, validatePositionals, requireStringOption, validateUniqueOptions, } from "../lib.js";
4
+ import { generateCommandUsage, getOptionInputs, taskKeyPositional, violatesConstraint, } from "../input.js";
5
+ import { confirmationDescription, confirmAction, dashValueHelp, output, outputChanges, quit, renameFlag, validatePositionals, validateUniqueOptions, } from "../lib.js";
6
6
  import { resolveTextEdit, textEditHelp, textEditOptions, textEditConstraints, } from "../text-edit.js";
7
+ import { resolveTextInput, textFileHelp, textFileOption, textSourceConstraint, } from "../text-input.js";
7
8
  import { currentActor } from "../actor.js";
8
- import { formatRows } from "../presentation/row-layout.js";
9
- import { formatLocalTime } from "../presentation/time.js";
10
- function presentComment(commentMatch) {
11
- return {
12
- key: commentMatch.key,
13
- text: commentMatch.text,
14
- created_at: commentMatch.created_at,
15
- updated_at: commentMatch.updated_at,
16
- };
17
- }
18
- export function presentComments(taskKey) {
19
- return comment.getAll(taskKey).map(presentComment);
20
- }
21
- function commentRow(commentMatch, options) {
22
- const createdAtCells = options.showsCreatedAt
23
- ? [{ text: formatLocalTime(commentMatch.created_at), style: "dim" }]
24
- : [];
25
- return [{ text: commentMatch.key }, ...createdAtCells, { text: commentMatch.text }];
26
- }
27
- export function formatComment(commentMatch) {
28
- return formatRows([commentRow(commentMatch, { showsCreatedAt: false })], {
29
- indentsContinuationLines: true,
30
- });
31
- }
32
- export function formatComments(comments) {
33
- return formatRows(comments.map((commentMatch) => commentRow(commentMatch, { showsCreatedAt: true })), { indentsContinuationLines: true });
9
+ import { formatCommentList, presentComment, presentComments, } from "../presentation/comment-presentation.js";
10
+ const commentTextConstraint = {
11
+ kind: "atLeastOne",
12
+ members: ["option:text", "option:text-file"],
13
+ };
14
+ function requireCommentText(values) {
15
+ if (violatesConstraint(commentTextConstraint, getOptionInputs(values))) {
16
+ quit("Comment text must be specified with --text or --text-file", undefined, {
17
+ argument: "--text",
18
+ });
19
+ }
34
20
  }
35
- function parseTextArgs(args) {
21
+ async function parseTextArgs(args) {
36
22
  const { values, positionals, tokens } = parseArgs({
37
23
  args,
38
24
  options: commentInputs.create.options,
@@ -42,10 +28,11 @@ function parseTextArgs(args) {
42
28
  });
43
29
  validateUniqueOptions(tokens, commentInputs.create.options);
44
30
  validatePositionals(positionals, commentInputs.create.forms[0]);
45
- const text = requireStringOption(commentInputs.create.options.text, values.text, "text", "Comment text must be specified with --text");
46
- return { key: positionals[0], text };
31
+ requireCommentText(values);
32
+ const text = await resolveTextInput(values.text, values["text-file"], "--text");
33
+ return { key: positionals[0], text: text };
47
34
  }
48
- function parseCommentEditArgs(args) {
35
+ async function parseCommentEditArgs(args) {
49
36
  const { values, positionals, tokens } = parseArgs({
50
37
  args,
51
38
  options: commentInputs.edit.options,
@@ -55,20 +42,24 @@ function parseCommentEditArgs(args) {
55
42
  });
56
43
  validateUniqueOptions(tokens, commentInputs.edit.options);
57
44
  validatePositionals(positionals, commentInputs.edit.forms[0]);
58
- const text = resolveTextEdit(values.text, values, "--text");
59
- requireStringOption(commentInputs.edit.options.text, values.text, "text", "Comment text must be specified with --text");
45
+ const text = await resolveTextEdit(values, "--text");
46
+ // Without a text source nothing was read, so this usage error still comes before any input
47
+ requireCommentText(values);
60
48
  return { key: positionals[0], text: text };
61
49
  }
62
50
  const commentInputs = {
63
51
  create: {
64
- options: { text: { type: "string", required: true, value: { kind: "text", name: "text" } } },
52
+ options: {
53
+ text: { type: "string", value: { kind: "text", name: "text" } },
54
+ "text-file": textFileOption,
55
+ },
65
56
  forms: [
66
57
  {
67
58
  id: "default",
68
59
  positionals: [taskKeyPositional],
69
60
  },
70
61
  ],
71
- constraints: [],
62
+ constraints: [textSourceConstraint("--text"), commentTextConstraint],
72
63
  },
73
64
  list: {
74
65
  options: {},
@@ -92,7 +83,8 @@ const commentInputs = {
92
83
  },
93
84
  edit: {
94
85
  options: {
95
- text: { type: "string", required: true, value: { kind: "text", name: "text" } },
86
+ text: { type: "string", value: { kind: "text", name: "text" } },
87
+ "text-file": textFileOption,
96
88
  ...textEditOptions,
97
89
  },
98
90
  forms: [
@@ -101,7 +93,11 @@ const commentInputs = {
101
93
  positionals: [{ name: "comment-key", min: 1, max: 1, value: { kind: "comment-key" } }],
102
94
  },
103
95
  ],
104
- constraints: [...textEditConstraints("--text")],
96
+ constraints: [
97
+ textSourceConstraint("--text"),
98
+ ...textEditConstraints("--text"),
99
+ commentTextConstraint,
100
+ ],
105
101
  notes: [textEditHelp("--text")],
106
102
  },
107
103
  delete: {
@@ -122,15 +118,25 @@ export const commentRouter = {
122
118
  confirmation: { kind: "none" },
123
119
  input: commentInputs.create,
124
120
  results: [jsonResult("Comment")],
125
- run: (args) => {
126
- const props = parseTextArgs(args);
121
+ guessedFlags: {
122
+ "--body": (args) => [
123
+ "task",
124
+ "comment",
125
+ "create",
126
+ ...renameFlag(args, commentInputs.create.options, "body", "text"),
127
+ ],
128
+ },
129
+ run: async (args) => {
130
+ const props = await parseTextArgs(args);
127
131
  const created = comment.create({ taskKey: props.key, text: props.text }, currentActor());
128
- output(presentComment(created), formatComment);
132
+ output(presentComment(created), (entry) => formatCommentList([entry], { showsCreatedAt: false, showsTextPreview: true }));
129
133
  },
130
134
  help: `${generateCommandUsage("task comment create", commentInputs.create)}
131
135
 
132
136
  Add a comment to a task. Comment text cannot be blank.
137
+ ${textFileHelp("--text")}
133
138
  Archived tasks can be commented on.
139
+ The printed result is a preview. 'task comment view' shows the full text. --json keeps the full text.
134
140
 
135
141
  ${dashValueHelp("--text")}
136
142
 
@@ -150,7 +156,7 @@ Example: zinn task comment create MDR-1 --text 'Ready for review'`,
150
156
  strict: true,
151
157
  });
152
158
  validatePositionals(positionals, commentInputs.list.forms[0]);
153
- output(presentComments(positionals[0]), formatComments);
159
+ output(presentComments(positionals[0]), formatCommentList);
154
160
  },
155
161
  help: `${generateCommandUsage("task comment list", commentInputs.list)}
156
162
 
@@ -172,13 +178,13 @@ Example: zinn task comment list MDR-1`,
172
178
  strict: true,
173
179
  });
174
180
  validatePositionals(positionals, commentInputs.view.forms[0]);
175
- output(presentComment(comment.getByKey(positionals[0])), formatComment);
181
+ output(presentComment(comment.getByKey(positionals[0])), (entry) => formatCommentList([entry], { showsCreatedAt: false }));
176
182
  },
177
183
  help: `${generateCommandUsage("task comment view", commentInputs.view)}
178
184
 
179
185
  Show a comment's current text in full, keeping its line breaks.
180
186
  Comments on archived tasks can be viewed.
181
- With --json, return one object with key, text, created_at and updated_at.
187
+ With --json, return one object with id, key, task_id, text, created_at and updated_at.
182
188
 
183
189
  Example: zinn task comment view 'MDR-1#1'`,
184
190
  },
@@ -187,15 +193,26 @@ Example: zinn task comment view 'MDR-1#1'`,
187
193
  effects: { domain: "update", storage: "normal-open" },
188
194
  confirmation: { kind: "none" },
189
195
  input: commentInputs.edit,
190
- results: [jsonResult("Comment")],
191
- run: (args) => {
192
- const props = parseCommentEditArgs(args);
196
+ results: [jsonResult("CommentChange")],
197
+ guessedFlags: {
198
+ "--body": (args) => [
199
+ "task",
200
+ "comment",
201
+ "edit",
202
+ ...renameFlag(args, commentInputs.edit.options, "body", "text"),
203
+ ],
204
+ },
205
+ run: async (args) => {
206
+ const props = await parseCommentEditArgs(args);
193
207
  const edited = comment.edit({ commentKey: props.key, text: props.text }, currentActor());
194
- output(presentComment(edited), formatComment);
208
+ outputChanges([edited], (change) => presentComment(change.comment), (entries) => formatCommentList(entries, { showsCreatedAt: false, showsTextPreview: true }), (entry) => `Comment ${entry.key} was unchanged`);
195
209
  },
196
210
  help: `${generateCommandUsage("task comment edit", commentInputs.edit)}
197
211
 
198
212
  Replace a comment's text. Comment text cannot be blank.
213
+ With --json, changed is false when the text already matches.
214
+ ${textFileHelp("--text")}
215
+ The printed result is a preview. 'task comment view' shows the full text. --json keeps the full text.
199
216
 
200
217
  ${textEditHelp("--text")}
201
218
 
@@ -17,6 +17,14 @@ export declare const labelRouter: {
17
17
  readonly name: "text";
18
18
  };
19
19
  };
20
+ readonly "description-file": {
21
+ readonly type: "string";
22
+ readonly value: {
23
+ readonly kind: "path";
24
+ readonly name: "path";
25
+ readonly description: "A UTF-8 file, or \"-\" for stdin. Trailing line breaks are dropped; empty or blank input is an error.";
26
+ };
27
+ };
20
28
  readonly color: {
21
29
  readonly type: "string";
22
30
  readonly value: {
@@ -37,10 +45,13 @@ export declare const labelRouter: {
37
45
  };
38
46
  }];
39
47
  }];
40
- readonly constraints: readonly [];
48
+ readonly constraints: readonly [{
49
+ readonly kind: "exclusive";
50
+ readonly members: readonly ["option:description" | "option:text", "option:description-file" | "option:text-file"];
51
+ }];
41
52
  };
42
53
  results: import("../results.js").CommandResult[];
43
- run: (args: string[]) => void;
54
+ run: (args: string[]) => Promise<void>;
44
55
  help: string;
45
56
  };
46
57
  list: {
@@ -64,6 +75,34 @@ export declare const labelRouter: {
64
75
  run: (args: string[]) => void;
65
76
  help: string;
66
77
  };
78
+ view: {
79
+ summary: string;
80
+ effects: {
81
+ domain: "read";
82
+ storage: "normal-open";
83
+ };
84
+ confirmation: {
85
+ kind: "none";
86
+ };
87
+ input: {
88
+ readonly options: {};
89
+ readonly forms: readonly [{
90
+ readonly id: "default";
91
+ readonly positionals: readonly [{
92
+ readonly name: "name";
93
+ readonly min: 1;
94
+ readonly max: 1;
95
+ readonly value: {
96
+ readonly kind: "label-name";
97
+ };
98
+ }];
99
+ }];
100
+ readonly constraints: readonly [];
101
+ };
102
+ results: import("../results.js").CommandResult[];
103
+ run: (args: string[]) => void;
104
+ help: string;
105
+ };
67
106
  edit: {
68
107
  summary: string;
69
108
  effects: {
@@ -110,6 +149,14 @@ export declare const labelRouter: {
110
149
  readonly name: "text";
111
150
  };
112
151
  };
152
+ readonly "description-file": {
153
+ readonly type: "string";
154
+ readonly value: {
155
+ readonly kind: "path";
156
+ readonly name: "path";
157
+ readonly description: "A UTF-8 file, or \"-\" for stdin. Trailing line breaks are dropped; empty or blank input is an error.";
158
+ };
159
+ };
113
160
  };
114
161
  readonly forms: readonly [{
115
162
  readonly id: "default";
@@ -123,16 +170,19 @@ export declare const labelRouter: {
123
170
  }];
124
171
  }];
125
172
  readonly constraints: readonly [{
173
+ readonly kind: "exclusive";
174
+ readonly members: readonly ["option:description" | "option:text", "option:description-file" | "option:text-file"];
175
+ }, {
126
176
  readonly kind: "exclusive";
127
177
  readonly members: readonly ["option:append", "option:replacing"];
128
178
  }, {
129
- readonly kind: "requires";
179
+ readonly kind: "requiresAny";
130
180
  readonly input: "option:append";
131
- readonly requires: `option:${string}`;
181
+ readonly members: readonly ["option:description" | "option:text", "option:description-file" | "option:text-file"];
132
182
  }, {
133
- readonly kind: "requires";
183
+ readonly kind: "requiresAny";
134
184
  readonly input: "option:replacing";
135
- readonly requires: `option:${string}`;
185
+ readonly members: readonly ["option:description" | "option:text", "option:description-file" | "option:text-file"];
136
186
  }, {
137
187
  readonly kind: "requires";
138
188
  readonly input: "option:all";
@@ -144,7 +194,7 @@ export declare const labelRouter: {
144
194
  readonly notes: readonly [string];
145
195
  };
146
196
  results: import("../results.js").CommandResult[];
147
- run: (args: string[]) => void;
197
+ run: (args: string[]) => Promise<void>;
148
198
  help: string;
149
199
  };
150
200
  delete: {