@zinn-dev/cli 0.45.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.
- package/README.md +1 -1
- package/package.json +3 -3
- package/skills/zinn/SKILL.md +2 -2
- package/src/actor.d.ts +1 -1
- package/src/actor.js +4 -1
- package/src/capabilities-schema.d.ts +78 -0
- package/src/capabilities-schema.js +44 -0
- package/src/capabilities.d.ts +2 -0
- package/src/capabilities.js +2 -0
- package/src/column-hint.js +2 -9
- package/src/errors.d.ts +5 -0
- package/src/errors.js +19 -5
- package/src/input.d.ts +30 -0
- package/src/input.js +18 -0
- package/src/lib.d.ts +75 -6
- package/src/lib.js +121 -33
- package/src/presentation/activity-presentation.d.ts +2 -1
- package/src/presentation/activity-presentation.js +23 -6
- package/src/presentation/color.d.ts +12 -0
- package/src/presentation/color.js +12 -0
- package/src/presentation/doctor-presentation.d.ts +7 -1
- package/src/presentation/doctor-presentation.js +6 -2
- package/src/presentation/project-presentation.d.ts +4 -1
- package/src/presentation/project-presentation.js +18 -0
- package/src/presentation/relation-presentation.js +8 -20
- package/src/presentation/section.d.ts +7 -4
- package/src/presentation/section.js +21 -7
- package/src/presentation/skill-status-presentation.d.ts +9 -0
- package/src/presentation/skill-status-presentation.js +43 -0
- package/src/presentation/task-blame-presentation.d.ts +3 -1
- package/src/presentation/task-blame-presentation.js +7 -5
- package/src/presentation/task-presentation.d.ts +28 -5
- package/src/presentation/task-presentation.js +120 -42
- package/src/result-schemas.d.ts +230 -14
- package/src/result-schemas.js +52 -0
- package/src/routes/activity-router.d.ts +5 -3
- package/src/routes/activity-router.js +44 -33
- package/src/routes/backup-router.d.ts +1 -0
- package/src/routes/backup-router.js +6 -12
- package/src/routes/capabilities-router.d.ts +1 -0
- package/src/routes/capabilities-router.js +3 -10
- package/src/routes/comment-router.d.ts +7 -6
- package/src/routes/comment-router.js +18 -66
- package/src/routes/doctor-router.d.ts +1 -0
- package/src/routes/doctor-router.js +35 -62
- package/src/routes/info-router.d.ts +1 -0
- package/src/routes/info-router.js +3 -10
- package/src/routes/label-router.d.ts +5 -0
- package/src/routes/label-router.js +11 -48
- package/src/routes/migrate-router.d.ts +1 -0
- package/src/routes/migrate-router.js +7 -16
- package/src/routes/project-router.d.ts +10 -0
- package/src/routes/project-router.js +42 -121
- package/src/routes/reindex-router.d.ts +1 -0
- package/src/routes/reindex-router.js +3 -10
- package/src/routes/relation-router.d.ts +13 -4
- package/src/routes/relation-router.js +15 -23
- package/src/routes/restore-router.d.ts +1 -0
- package/src/routes/restore-router.js +5 -15
- package/src/routes/router.js +33 -12
- package/src/routes/routes.d.ts +142 -32
- package/src/routes/skill-router.d.ts +53 -2
- package/src/routes/skill-router.js +103 -35
- package/src/routes/task-router.d.ts +61 -28
- package/src/routes/task-router.js +224 -263
- package/src/routes/whoami-router.d.ts +1 -0
- package/src/routes/whoami-router.js +3 -10
- package/src/skill-copies.d.ts +34 -0
- package/src/skill-copies.js +109 -0
- package/src/telemetry.d.ts +2 -2
- package/src/telemetry.js +11 -7
- package/src/types.d.ts +9 -1
- package/src/types.js +6 -0
- package/src/views.d.ts +117 -0
- package/src/views.js +54 -0
|
@@ -4,6 +4,7 @@ export declare const activityRouter: {
|
|
|
4
4
|
effects: {
|
|
5
5
|
domain: "read";
|
|
6
6
|
storage: "normal-open";
|
|
7
|
+
external: never[];
|
|
7
8
|
};
|
|
8
9
|
confirmation: {
|
|
9
10
|
kind: "none";
|
|
@@ -87,7 +88,7 @@ export declare const activityRouter: {
|
|
|
87
88
|
readonly value: {
|
|
88
89
|
readonly kind: "activity-action";
|
|
89
90
|
readonly name: "action";
|
|
90
|
-
readonly choices: ("create" | "
|
|
91
|
+
readonly choices: ("create" | "claim" | "delete" | "archive" | "edit" | "move" | "order" | "unarchive" | "relation_create" | "relation_delete" | "comment_create" | "comment_edit" | "comment_delete" | "claim_take" | "claim_heartbeat" | "claim_release")[];
|
|
91
92
|
};
|
|
92
93
|
};
|
|
93
94
|
readonly changed: {
|
|
@@ -96,8 +97,8 @@ export declare const activityRouter: {
|
|
|
96
97
|
readonly value: {
|
|
97
98
|
readonly kind: "activity-change";
|
|
98
99
|
readonly name: "field[=value]";
|
|
99
|
-
readonly pattern:
|
|
100
|
-
readonly description: `Fields: ${string}. Omit the value to match any change.
|
|
100
|
+
readonly pattern: string;
|
|
101
|
+
readonly description: `Fields: ${string}. Omit the value to match any change. ${string} priority=none matches an unassigned priority.`;
|
|
101
102
|
};
|
|
102
103
|
};
|
|
103
104
|
readonly follow: {
|
|
@@ -149,6 +150,7 @@ export declare const activityRouter: {
|
|
|
149
150
|
effects: {
|
|
150
151
|
domain: "read";
|
|
151
152
|
storage: "normal-open";
|
|
153
|
+
external: never[];
|
|
152
154
|
};
|
|
153
155
|
confirmation: {
|
|
154
156
|
kind: "none";
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import { listLimitOption, listLimitDescription, parseListLimit } from "../list-limit.js";
|
|
2
2
|
import { jsonResult } from "../results.js";
|
|
3
|
-
import {
|
|
4
|
-
import { activity, activityActionSchema, activityChangedFieldSchema, activityChangedSchema, CoreError, } from "@zinn-dev/core";
|
|
3
|
+
import { activity, activityActionSchema, activityChangedFieldSchema, activityChangedFieldsWithOptionalValue, activityChangedFieldsWithoutValue, activityChangedSchema, activityIdSchema, activityListSchema, CoreError, InputValidationError, readSnapshot, } from "@zinn-dev/core";
|
|
5
4
|
import { generateCommandUsage, getOptionInputs, violatesConstraint } from "../input.js";
|
|
6
5
|
import { CliError } from "../errors.js";
|
|
7
6
|
import { parseTimestampInput } from "../timestamp-input.js";
|
|
8
7
|
import { formatListContinuation } from "../list-continuation.js";
|
|
9
|
-
import { diagnostic, output, outputStream, quit,
|
|
8
|
+
import { diagnostic, getOutputMode, output, outputStream, quit, parseCommandArgs } from "../lib.js";
|
|
10
9
|
import { followUntilStopped } from "../follow.js";
|
|
11
10
|
import { formatActivityList, presentActivities } from "../presentation/activity-presentation.js";
|
|
11
|
+
import { readTerminalProps } from "../presentation/color.js";
|
|
12
12
|
const changedFieldList = activityChangedFieldSchema.options.join(", ");
|
|
13
|
+
const changedFieldListFormatter = new Intl.ListFormat("en-GB");
|
|
14
|
+
const changedFieldsWithoutValue = changedFieldListFormatter.format(activityChangedFieldsWithoutValue);
|
|
15
|
+
const changedFieldsWithValue = changedFieldListFormatter.format(activityChangedFieldsWithOptionalValue.map((field) => field === "labels" ? "added labels" : field));
|
|
16
|
+
const changedValueHelp = `Values apply to ${changedFieldsWithValue}, ignoring case.`;
|
|
13
17
|
const activityInputs = {
|
|
14
18
|
list: {
|
|
15
19
|
options: {
|
|
@@ -69,8 +73,8 @@ const activityInputs = {
|
|
|
69
73
|
value: {
|
|
70
74
|
kind: "activity-change",
|
|
71
75
|
name: "field[=value]",
|
|
72
|
-
pattern: `^((
|
|
73
|
-
description: `Fields: ${changedFieldList}. Omit the value to match any change.
|
|
76
|
+
pattern: String.raw `^(?:(?:${activityChangedFieldsWithOptionalValue.join("|")})(?:=[\s\S]+)?|${activityChangedFieldsWithoutValue.join("|")})$`,
|
|
77
|
+
description: `Fields: ${changedFieldList}. Omit the value to match any change. ${changedValueHelp} priority=none matches an unassigned priority.`,
|
|
74
78
|
},
|
|
75
79
|
},
|
|
76
80
|
follow: { type: "boolean" },
|
|
@@ -110,7 +114,7 @@ const activityInputs = {
|
|
|
110
114
|
export const activityRouter = {
|
|
111
115
|
list: {
|
|
112
116
|
summary: "List recorded activity across the database, newest first.",
|
|
113
|
-
effects: { domain: "read", storage: "normal-open" },
|
|
117
|
+
effects: { domain: "read", storage: "normal-open", external: [] },
|
|
114
118
|
confirmation: { kind: "none" },
|
|
115
119
|
input: activityInputs.list,
|
|
116
120
|
results: [
|
|
@@ -118,15 +122,7 @@ export const activityRouter = {
|
|
|
118
122
|
jsonResult("Activity", { kind: "booleanOption", name: "follow", value: true }, "json-lines"),
|
|
119
123
|
],
|
|
120
124
|
run: (args) => {
|
|
121
|
-
const { values,
|
|
122
|
-
args,
|
|
123
|
-
options: activityInputs.list.options,
|
|
124
|
-
allowPositionals: true,
|
|
125
|
-
strict: true,
|
|
126
|
-
tokens: true,
|
|
127
|
-
});
|
|
128
|
-
validateUniqueOptions(tokens, activityInputs.list.options);
|
|
129
|
-
validatePositionals(positionals, activityInputs.list.forms[0]);
|
|
125
|
+
const { values, tokens } = parseCommandArgs(args, activityInputs.list);
|
|
130
126
|
const [selectorConstraint, deletedHistoryConstraint, ...followConstraints] = activityInputs.list.constraints;
|
|
131
127
|
const optionInputs = getOptionInputs(values);
|
|
132
128
|
if (violatesConstraint(selectorConstraint, optionInputs)) {
|
|
@@ -172,22 +168,31 @@ export const activityRouter = {
|
|
|
172
168
|
since: parseTimestampInput(values.since, "--since"),
|
|
173
169
|
until: parseTimestampInput(values.until, "--until"),
|
|
174
170
|
};
|
|
175
|
-
const
|
|
171
|
+
const presentEvents = (events) => getOutputMode() === "json"
|
|
172
|
+
? { events: activity.attachTaskKeys(events), presented: [] }
|
|
173
|
+
: { events, presented: presentActivities(events, selection) };
|
|
176
174
|
if (values.follow === true) {
|
|
177
175
|
const follower = readSelectedActivity(values, () => activity.follow(filters));
|
|
178
176
|
return followUntilStopped(async (signal) => {
|
|
179
|
-
const polled = readSelectedActivity(values, () =>
|
|
177
|
+
const polled = readSelectedActivity(values, () => readSnapshot(() => {
|
|
178
|
+
const polled = follower.poll();
|
|
179
|
+
return "stopped" in polled ? polled : presentEvents(polled.events);
|
|
180
|
+
}));
|
|
180
181
|
if ("stopped" in polled) {
|
|
181
182
|
const reason = polled.stopped === "file_replaced"
|
|
182
183
|
? `The database file at ${polled.databasePath} was replaced or removed`
|
|
183
184
|
: `The database schema at ${polled.databasePath} changed`;
|
|
184
185
|
throw new CliError(`${reason}, so following stopped. Run the command again to follow new activity.`, "conflict", { entity: "database", databasePath: polled.databasePath });
|
|
185
186
|
}
|
|
186
|
-
await outputStream(polled.events,
|
|
187
|
+
await outputStream(polled.events, () => formatActivityList(polled.presented), signal);
|
|
187
188
|
});
|
|
188
189
|
}
|
|
189
|
-
const
|
|
190
|
-
|
|
190
|
+
const input = { ...filters, limit, startingAfter: values["starting-after"] };
|
|
191
|
+
const page = readSelectedActivity(values, () => readWithActivityPresentation(activityListSchema, input, () => {
|
|
192
|
+
const page = activity.getAll(input);
|
|
193
|
+
return { ...page, ...presentEvents(page.events) };
|
|
194
|
+
}));
|
|
195
|
+
output(page.events, () => formatActivityList(page.presented));
|
|
191
196
|
if (page.nextCursor !== undefined) {
|
|
192
197
|
diagnostic(`More activity. Continue with: ${formatListContinuation(["activity", "list"], [], tokens, "starting-after", page.nextCursor)}`);
|
|
193
198
|
}
|
|
@@ -214,9 +219,9 @@ Returns all matching events unless --limit is supplied.
|
|
|
214
219
|
--action <action> Match a recorded action. Repeat to match any listed action.
|
|
215
220
|
--changed <field>[=<value>] Match a task field change, with an optional value.
|
|
216
221
|
Fields: ${changedFieldList}.
|
|
217
|
-
|
|
222
|
+
${changedValueHelp}
|
|
218
223
|
Without a value, labels match additions and removals.
|
|
219
|
-
|
|
224
|
+
Use ${changedFieldsWithoutValue} without a value.
|
|
220
225
|
Use priority=none for an unassigned priority.
|
|
221
226
|
--follow Print new activity as it is committed, until stopped.
|
|
222
227
|
--limit <n> ${listLimitDescription}
|
|
@@ -262,22 +267,20 @@ Examples:
|
|
|
262
267
|
},
|
|
263
268
|
view: {
|
|
264
269
|
summary: "Show one recorded event with full activity/entity IDs, actor and complete changes.",
|
|
265
|
-
effects: { domain: "read", storage: "normal-open" },
|
|
270
|
+
effects: { domain: "read", storage: "normal-open", external: [] },
|
|
266
271
|
confirmation: { kind: "none" },
|
|
267
272
|
input: activityInputs.view,
|
|
268
273
|
results: [jsonResult("Activity")],
|
|
269
274
|
run: (args) => {
|
|
270
|
-
const { positionals } =
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
+
const { positionals } = parseCommandArgs(args, activityInputs.view);
|
|
276
|
+
const id = positionals[0];
|
|
277
|
+
const { viewed, presented } = readWithActivityPresentation(activityIdSchema, id, () => {
|
|
278
|
+
const event = activity.getById(id);
|
|
279
|
+
return getOutputMode() === "json"
|
|
280
|
+
? { viewed: activity.attachTaskKeys([event])[0], presented: [] }
|
|
281
|
+
: { viewed: event, presented: presentActivities([event], { showsFullIds: true }) };
|
|
275
282
|
});
|
|
276
|
-
|
|
277
|
-
const viewed = activity.getById(positionals[0]);
|
|
278
|
-
output(viewed, (event) => formatActivityList(presentActivities([event], { showsFullIds: true }), {
|
|
279
|
-
showsDetails: true,
|
|
280
|
-
}));
|
|
283
|
+
output(viewed, () => formatActivityList(presented, { showsDetails: true, ...readTerminalProps() }));
|
|
281
284
|
},
|
|
282
285
|
help: `${generateCommandUsage("activity view", activityInputs.view)}
|
|
283
286
|
|
|
@@ -290,6 +293,14 @@ With --json, return one full activity record.
|
|
|
290
293
|
Example: zinn activity view 019abcdf-1234-7`,
|
|
291
294
|
},
|
|
292
295
|
};
|
|
296
|
+
/** Validate input before opening the snapshot shared by activity reads and their lookups. */
|
|
297
|
+
function readWithActivityPresentation(schema, input, read) {
|
|
298
|
+
const validation = schema.safeParse(input);
|
|
299
|
+
if (!validation.success) {
|
|
300
|
+
throw new InputValidationError(validation.error.issues);
|
|
301
|
+
}
|
|
302
|
+
return readSnapshot(read);
|
|
303
|
+
}
|
|
293
304
|
/** Reads the selected activity, reporting core's refusals with the flag that caused them */
|
|
294
305
|
function readSelectedActivity(values, read) {
|
|
295
306
|
try {
|
|
@@ -1,30 +1,24 @@
|
|
|
1
1
|
import { jsonResult } from "../results.js";
|
|
2
|
-
import { parseArgs } from "node:util";
|
|
3
2
|
import { backup } from "@zinn-dev/core";
|
|
4
3
|
import { generateCommandUsage, noInput } from "../input.js";
|
|
5
|
-
import { output,
|
|
4
|
+
import { output, parseCommandArgs } from "../lib.js";
|
|
6
5
|
import packageJson from "../../package.json" with { type: "json" };
|
|
7
6
|
export const backupCommand = {
|
|
8
|
-
summary: "Save a copy of the database to ~/.zinn/backups/, or to backups/ in ZINN_DIR when it is set.",
|
|
9
|
-
effects: { domain: "none", storage: "backup" },
|
|
7
|
+
summary: "Save a verified copy of the database to ~/.zinn/backups/, or to backups/ in ZINN_DIR when it is set.",
|
|
8
|
+
effects: { domain: "none", storage: "backup", external: [] },
|
|
10
9
|
confirmation: { kind: "none" },
|
|
11
10
|
input: noInput,
|
|
12
11
|
results: [jsonResult("Backup")],
|
|
13
12
|
run: (args) => {
|
|
14
|
-
|
|
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
|
const created = backup.create({ client: "cli", version: packageJson.version });
|
|
22
15
|
output(created, (b) => `Saved a backup to ${b.path}`);
|
|
23
16
|
},
|
|
24
17
|
help: `${generateCommandUsage("backup", noInput)}
|
|
25
18
|
|
|
26
|
-
Save a copy of the database to ~/.zinn/backups/, or to backups/ in ZINN_DIR when it is set.
|
|
19
|
+
Save a verified copy of the database to ~/.zinn/backups/, or to backups/ in ZINN_DIR when it is set.
|
|
27
20
|
|
|
28
21
|
The copy includes recent writes and is safe to take while Zinn is in use.
|
|
22
|
+
Zinn checks the copy's SQLite integrity and foreign keys. If a check fails, the command reports the path of the copy retained for recovery.
|
|
29
23
|
Fails when there is no database yet. Existing backups are never overwritten.`,
|
|
30
24
|
};
|
|
@@ -1,22 +1,15 @@
|
|
|
1
|
-
import { parseArgs } from "node:util";
|
|
2
1
|
import { generateCommandUsage, noInput } from "../input.js";
|
|
3
|
-
import { getOutputMode, output,
|
|
2
|
+
import { getOutputMode, output, parseCommandArgs } from "../lib.js";
|
|
4
3
|
import { formatCapabilities } from "../presentation/capabilities-presentation.js";
|
|
5
4
|
import { jsonResult } from "../results.js";
|
|
6
5
|
export const capabilitiesCommand = {
|
|
7
6
|
summary: "Describe the installed CLI commands, inputs, results and errors.",
|
|
8
|
-
effects: { domain: "none", storage: "none" },
|
|
7
|
+
effects: { domain: "none", storage: "none", external: [] },
|
|
9
8
|
confirmation: { kind: "none" },
|
|
10
9
|
input: noInput,
|
|
11
10
|
results: [jsonResult("Capabilities")],
|
|
12
11
|
run: async (args) => {
|
|
13
|
-
|
|
14
|
-
options: noInput.options,
|
|
15
|
-
args,
|
|
16
|
-
strict: true,
|
|
17
|
-
allowPositionals: true,
|
|
18
|
-
});
|
|
19
|
-
validatePositionals(positionals, noInput.forms[0]);
|
|
12
|
+
parseCommandArgs(args, noInput);
|
|
20
13
|
const { generateCapabilities, getCapabilitySummary } = await import("../capabilities.js");
|
|
21
14
|
if (getOutputMode() === "json") {
|
|
22
15
|
output(generateCapabilities(), () => formatCapabilities(getCapabilitySummary()));
|
|
@@ -4,6 +4,7 @@ export declare const commentRouter: {
|
|
|
4
4
|
effects: {
|
|
5
5
|
domain: "create";
|
|
6
6
|
storage: "normal-open";
|
|
7
|
+
external: never[];
|
|
7
8
|
};
|
|
8
9
|
confirmation: {
|
|
9
10
|
kind: "none";
|
|
@@ -16,6 +17,7 @@ export declare const commentRouter: {
|
|
|
16
17
|
readonly kind: "text";
|
|
17
18
|
readonly name: "text";
|
|
18
19
|
};
|
|
20
|
+
readonly aliases: readonly ["body"];
|
|
19
21
|
};
|
|
20
22
|
readonly "text-file": {
|
|
21
23
|
readonly type: "string";
|
|
@@ -46,9 +48,6 @@ export declare const commentRouter: {
|
|
|
46
48
|
}];
|
|
47
49
|
};
|
|
48
50
|
results: import("../results.js").CommandResult[];
|
|
49
|
-
guessedFlags: {
|
|
50
|
-
"--body": (args: string[]) => string[];
|
|
51
|
-
};
|
|
52
51
|
run: (args: string[]) => Promise<void>;
|
|
53
52
|
help: string;
|
|
54
53
|
};
|
|
@@ -57,6 +56,7 @@ export declare const commentRouter: {
|
|
|
57
56
|
effects: {
|
|
58
57
|
domain: "read";
|
|
59
58
|
storage: "normal-open";
|
|
59
|
+
external: never[];
|
|
60
60
|
};
|
|
61
61
|
confirmation: {
|
|
62
62
|
kind: "none";
|
|
@@ -85,6 +85,7 @@ export declare const commentRouter: {
|
|
|
85
85
|
effects: {
|
|
86
86
|
domain: "read";
|
|
87
87
|
storage: "normal-open";
|
|
88
|
+
external: never[];
|
|
88
89
|
};
|
|
89
90
|
confirmation: {
|
|
90
91
|
kind: "none";
|
|
@@ -113,6 +114,7 @@ export declare const commentRouter: {
|
|
|
113
114
|
effects: {
|
|
114
115
|
domain: "update";
|
|
115
116
|
storage: "normal-open";
|
|
117
|
+
external: never[];
|
|
116
118
|
};
|
|
117
119
|
confirmation: {
|
|
118
120
|
kind: "none";
|
|
@@ -153,6 +155,7 @@ export declare const commentRouter: {
|
|
|
153
155
|
readonly kind: "text";
|
|
154
156
|
readonly name: "text";
|
|
155
157
|
};
|
|
158
|
+
readonly aliases: readonly ["body"];
|
|
156
159
|
};
|
|
157
160
|
readonly "text-file": {
|
|
158
161
|
readonly type: "string";
|
|
@@ -202,9 +205,6 @@ export declare const commentRouter: {
|
|
|
202
205
|
readonly notes: readonly [string, string];
|
|
203
206
|
};
|
|
204
207
|
results: import("../results.js").CommandResult[];
|
|
205
|
-
guessedFlags: {
|
|
206
|
-
"--body": (args: string[]) => string[];
|
|
207
|
-
};
|
|
208
208
|
run: (args: string[]) => Promise<void>;
|
|
209
209
|
help: string;
|
|
210
210
|
};
|
|
@@ -213,6 +213,7 @@ export declare const commentRouter: {
|
|
|
213
213
|
effects: {
|
|
214
214
|
domain: "delete";
|
|
215
215
|
storage: "normal-open";
|
|
216
|
+
external: never[];
|
|
216
217
|
};
|
|
217
218
|
confirmation: {
|
|
218
219
|
kind: "prompt";
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { jsonResult } from "../results.js";
|
|
2
|
-
import { parseArgs } from "node:util";
|
|
3
2
|
import { comment } from "@zinn-dev/core";
|
|
4
3
|
import { generateCommandUsage, getOptionInputs, taskKeyPositional, violatesConstraint, } from "../input.js";
|
|
5
|
-
import { confirmationDescription, confirmAction, dashValueHelp, output, outputChanges, quit,
|
|
4
|
+
import { confirmationDescription, confirmAction, dashValueHelp, output, outputChanges, quit, parseCommandArgs, } from "../lib.js";
|
|
6
5
|
import { resolveTextEdit, textEditHelp, textEditOptions, textEditConstraints, } from "../text-edit.js";
|
|
7
6
|
import { expectedValueFlags } from "../expected-values.js";
|
|
8
7
|
import { checkSingleStdinReader, resolveTextInput, textFileHelp, textFileOption, textSourceConstraint, } from "../text-input.js";
|
|
@@ -21,29 +20,13 @@ function requireCommentText(values) {
|
|
|
21
20
|
}
|
|
22
21
|
}
|
|
23
22
|
async function parseTextArgs(args) {
|
|
24
|
-
const { values, positionals
|
|
25
|
-
args,
|
|
26
|
-
options: commentInputs.create.options,
|
|
27
|
-
allowPositionals: true,
|
|
28
|
-
strict: true,
|
|
29
|
-
tokens: true,
|
|
30
|
-
});
|
|
31
|
-
validateUniqueOptions(tokens, commentInputs.create.options);
|
|
32
|
-
validatePositionals(positionals, commentInputs.create.forms[0]);
|
|
23
|
+
const { values, positionals } = parseCommandArgs(args, commentInputs.create);
|
|
33
24
|
requireCommentText(values);
|
|
34
25
|
const text = await resolveTextInput(values.text, values["text-file"], "--text");
|
|
35
26
|
return { key: positionals[0], text: text };
|
|
36
27
|
}
|
|
37
28
|
async function parseCommentEditArgs(args) {
|
|
38
|
-
const { values, positionals
|
|
39
|
-
args,
|
|
40
|
-
options: commentInputs.edit.options,
|
|
41
|
-
allowPositionals: true,
|
|
42
|
-
strict: true,
|
|
43
|
-
tokens: true,
|
|
44
|
-
});
|
|
45
|
-
validateUniqueOptions(tokens, commentInputs.edit.options);
|
|
46
|
-
validatePositionals(positionals, commentInputs.edit.forms[0]);
|
|
29
|
+
const { values, positionals } = parseCommandArgs(args, commentInputs.edit);
|
|
47
30
|
commentExpectations.parseValues(values);
|
|
48
31
|
checkSingleStdinReader(values, ["--text", ...commentExpectations.textFlags]);
|
|
49
32
|
const text = await resolveTextEdit(values, "--text");
|
|
@@ -52,10 +35,15 @@ async function parseCommentEditArgs(args) {
|
|
|
52
35
|
const expected = await commentExpectations.resolveText(values);
|
|
53
36
|
return { key: positionals[0], text: text, expected };
|
|
54
37
|
}
|
|
38
|
+
const commentTextOption = {
|
|
39
|
+
type: "string",
|
|
40
|
+
value: { kind: "text", name: "text" },
|
|
41
|
+
aliases: ["body"],
|
|
42
|
+
};
|
|
55
43
|
const commentInputs = {
|
|
56
44
|
create: {
|
|
57
45
|
options: {
|
|
58
|
-
text:
|
|
46
|
+
text: commentTextOption,
|
|
59
47
|
"text-file": textFileOption,
|
|
60
48
|
},
|
|
61
49
|
forms: [
|
|
@@ -88,7 +76,7 @@ const commentInputs = {
|
|
|
88
76
|
},
|
|
89
77
|
edit: {
|
|
90
78
|
options: {
|
|
91
|
-
text:
|
|
79
|
+
text: commentTextOption,
|
|
92
80
|
"text-file": textFileOption,
|
|
93
81
|
...textEditOptions,
|
|
94
82
|
...commentExpectations.options,
|
|
@@ -121,18 +109,10 @@ const commentInputs = {
|
|
|
121
109
|
export const commentRouter = {
|
|
122
110
|
create: {
|
|
123
111
|
summary: "Add a comment to a task. Comment text cannot be blank.",
|
|
124
|
-
effects: { domain: "create", storage: "normal-open" },
|
|
112
|
+
effects: { domain: "create", storage: "normal-open", external: [] },
|
|
125
113
|
confirmation: { kind: "none" },
|
|
126
114
|
input: commentInputs.create,
|
|
127
115
|
results: [jsonResult("Comment")],
|
|
128
|
-
guessedFlags: {
|
|
129
|
-
"--body": (args) => [
|
|
130
|
-
"task",
|
|
131
|
-
"comment",
|
|
132
|
-
"create",
|
|
133
|
-
...renameFlag(args, commentInputs.create.options, "body", "text"),
|
|
134
|
-
],
|
|
135
|
-
},
|
|
136
116
|
run: async (args) => {
|
|
137
117
|
const props = await parseTextArgs(args);
|
|
138
118
|
const created = comment.create({ taskKey: props.key, text: props.text }, currentActor());
|
|
@@ -151,18 +131,12 @@ Example: zinn task comment create MDR-1 --text 'Ready for review'`,
|
|
|
151
131
|
},
|
|
152
132
|
list: {
|
|
153
133
|
summary: "List a task's comments by oldest first.",
|
|
154
|
-
effects: { domain: "read", storage: "normal-open" },
|
|
134
|
+
effects: { domain: "read", storage: "normal-open", external: [] },
|
|
155
135
|
confirmation: { kind: "none" },
|
|
156
136
|
input: commentInputs.list,
|
|
157
137
|
results: [jsonResult("CommentList")],
|
|
158
138
|
run: (args) => {
|
|
159
|
-
const { positionals } =
|
|
160
|
-
options: commentInputs.list.options,
|
|
161
|
-
args,
|
|
162
|
-
allowPositionals: true,
|
|
163
|
-
strict: true,
|
|
164
|
-
});
|
|
165
|
-
validatePositionals(positionals, commentInputs.list.forms[0]);
|
|
139
|
+
const { positionals } = parseCommandArgs(args, commentInputs.list);
|
|
166
140
|
output(presentComments(positionals[0]), formatCommentList);
|
|
167
141
|
},
|
|
168
142
|
help: `${generateCommandUsage("task comment list", commentInputs.list)}
|
|
@@ -173,18 +147,12 @@ Example: zinn task comment list MDR-1`,
|
|
|
173
147
|
},
|
|
174
148
|
view: {
|
|
175
149
|
summary: "Show a comment's current text in full, keeping its line breaks.",
|
|
176
|
-
effects: { domain: "read", storage: "normal-open" },
|
|
150
|
+
effects: { domain: "read", storage: "normal-open", external: [] },
|
|
177
151
|
confirmation: { kind: "none" },
|
|
178
152
|
input: commentInputs.view,
|
|
179
153
|
results: [jsonResult("Comment")],
|
|
180
154
|
run: (args) => {
|
|
181
|
-
const { positionals } =
|
|
182
|
-
options: commentInputs.view.options,
|
|
183
|
-
args,
|
|
184
|
-
allowPositionals: true,
|
|
185
|
-
strict: true,
|
|
186
|
-
});
|
|
187
|
-
validatePositionals(positionals, commentInputs.view.forms[0]);
|
|
155
|
+
const { positionals } = parseCommandArgs(args, commentInputs.view);
|
|
188
156
|
output(presentComment(comment.getByKey(positionals[0])), (entry) => formatCommentList([entry], { showsCreatedAt: false }));
|
|
189
157
|
},
|
|
190
158
|
help: `${generateCommandUsage("task comment view", commentInputs.view)}
|
|
@@ -197,18 +165,10 @@ Example: zinn task comment view 'MDR-1#1'`,
|
|
|
197
165
|
},
|
|
198
166
|
edit: {
|
|
199
167
|
summary: "Replace a comment's text. Comment text cannot be blank.",
|
|
200
|
-
effects: { domain: "update", storage: "normal-open" },
|
|
168
|
+
effects: { domain: "update", storage: "normal-open", external: [] },
|
|
201
169
|
confirmation: { kind: "none" },
|
|
202
170
|
input: commentInputs.edit,
|
|
203
171
|
results: [jsonResult("CommentChange")],
|
|
204
|
-
guessedFlags: {
|
|
205
|
-
"--body": (args) => [
|
|
206
|
-
"task",
|
|
207
|
-
"comment",
|
|
208
|
-
"edit",
|
|
209
|
-
...renameFlag(args, commentInputs.edit.options, "body", "text"),
|
|
210
|
-
],
|
|
211
|
-
},
|
|
212
172
|
run: async (args) => {
|
|
213
173
|
const props = await parseCommentEditArgs(args);
|
|
214
174
|
const edited = comment.edit({ commentKey: props.key, text: props.text, expected: props.expected }, currentActor());
|
|
@@ -234,20 +194,12 @@ Examples:
|
|
|
234
194
|
},
|
|
235
195
|
delete: {
|
|
236
196
|
summary: "Permanently delete a comment after confirmation.",
|
|
237
|
-
effects: { domain: "delete", storage: "normal-open" },
|
|
197
|
+
effects: { domain: "delete", storage: "normal-open", external: [] },
|
|
238
198
|
confirmation: { kind: "prompt", description: confirmationDescription },
|
|
239
199
|
input: commentInputs.delete,
|
|
240
200
|
results: [jsonResult("Comment")],
|
|
241
201
|
run: async (args) => {
|
|
242
|
-
const { values, positionals
|
|
243
|
-
args,
|
|
244
|
-
options: commentInputs.delete.options,
|
|
245
|
-
allowPositionals: true,
|
|
246
|
-
strict: true,
|
|
247
|
-
tokens: true,
|
|
248
|
-
});
|
|
249
|
-
validateUniqueOptions(tokens, commentInputs.delete.options);
|
|
250
|
-
validatePositionals(positionals, commentInputs.delete.forms[0]);
|
|
202
|
+
const { values, positionals } = parseCommandArgs(args, commentInputs.delete);
|
|
251
203
|
const commentMatch = comment.getByKey(positionals[0]);
|
|
252
204
|
const canDelete = await confirmAction(`Are you sure you want to delete ${commentMatch.key}?`, values.yes === true);
|
|
253
205
|
const presented = presentComment(commentMatch);
|