@zinn-dev/cli 0.44.0 → 0.45.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/package.json +2 -2
- package/skills/zinn/SKILL.md +7 -9
- package/src/capabilities-schema.d.ts +5 -1
- package/src/column-hint.js +1 -3
- package/src/database.d.ts +1 -2
- package/src/database.js +1 -6
- package/src/duration-input.d.ts +7 -0
- package/src/duration-input.js +31 -0
- package/src/errors.d.ts +22 -0
- package/src/errors.js +30 -5
- package/src/expected-values.d.ts +48 -0
- package/src/expected-values.js +60 -0
- package/src/follow.d.ts +9 -0
- package/src/follow.js +58 -0
- package/src/input.d.ts +0 -8
- package/src/input.js +36 -16
- package/src/lib.d.ts +5 -2
- package/src/lib.js +18 -8
- package/src/list-continuation.js +1 -4
- package/src/presentation/activity-presentation.d.ts +2 -0
- package/src/presentation/activity-presentation.js +58 -3
- package/src/presentation/column-presentation.d.ts +9 -4
- package/src/presentation/column-presentation.js +29 -12
- package/src/presentation/doctor-presentation.d.ts +4 -0
- package/src/presentation/doctor-presentation.js +24 -0
- package/src/presentation/relation-presentation.js +2 -1
- package/src/presentation/task-blame-presentation.d.ts +1 -4
- package/src/presentation/task-blame-presentation.js +1 -1
- package/src/presentation/task-presentation.d.ts +2 -0
- package/src/presentation/task-presentation.js +39 -2
- package/src/result-schemas.d.ts +353 -58
- package/src/result-schemas.js +46 -2
- package/src/results.d.ts +6 -2
- package/src/results.js +9 -3
- package/src/routes/activity-router.d.ts +12 -3
- package/src/routes/activity-router.js +93 -59
- package/src/routes/aliases.js +1 -0
- package/src/routes/comment-router.d.ts +24 -6
- package/src/routes/comment-router.js +15 -5
- package/src/routes/doctor-router.d.ts +39 -0
- package/src/routes/doctor-router.js +103 -0
- package/src/routes/label-router.d.ts +39 -6
- package/src/routes/label-router.js +22 -5
- package/src/routes/project-router.d.ts +60 -11
- package/src/routes/project-router.js +100 -33
- package/src/routes/restore-router.js +2 -2
- package/src/routes/router.js +3 -7
- package/src/routes/routes.d.ts +404 -33
- package/src/routes/routes.js +4 -0
- package/src/routes/skill-router.d.ts +25 -0
- package/src/routes/skill-router.js +96 -0
- package/src/routes/task-router.d.ts +231 -13
- package/src/routes/task-router.js +247 -19
- package/src/text-edit.d.ts +2 -2
- package/src/text-input.d.ts +19 -1
- package/src/text-input.js +26 -5
package/src/result-schemas.js
CHANGED
|
@@ -1,11 +1,31 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { activityActionSchema, activityEntityTypeSchema, actorKindSchema, infoDatabaseStateSchema, labelColorSchema, relationTypeSchema, settingsFileSourceSchema, settingsFileStateSchema, settingsSchema, storageSourceSchema, taskPrioritySchema, telemetryModeSchema, telemetrySourceSchema, } from "@zinn-dev/core";
|
|
2
|
+
import { activityActionSchema, activityEntityTypeSchema, actorKindSchema, columnCategorySchema, doctorCheckIdSchema, doctorStatusSchema, infoDatabaseStateSchema, labelColorSchema, relationTypeSchema, settingsFileSourceSchema, settingsFileStateSchema, settingsSchema, storageSourceSchema, taskPrioritySchema, telemetryModeSchema, telemetrySourceSchema, CLAIM_WORK_LIMIT_MS, } from "@zinn-dev/core";
|
|
3
3
|
import { errorDocumentSchema } from "./errors.js";
|
|
4
|
+
import { formatDurationInput } from "./duration-input.js";
|
|
4
5
|
import { capabilitiesSchema, jsonValueSchema } from "./capabilities-schema.js";
|
|
5
6
|
const nullableText = z.string().nullable();
|
|
6
7
|
const count = z.number().int().nonnegative();
|
|
7
8
|
const timestamp = z.number().int().describe("Milliseconds since the Unix epoch.");
|
|
8
9
|
const taskStatus = z.enum(["Active", "Archived"]);
|
|
10
|
+
// A newer Zinn may store a category this version does not know.
|
|
11
|
+
const columnCategory = z.string().nullable();
|
|
12
|
+
const columnCategoryValues = `Known categories: ${columnCategorySchema.options.join(", ")}. Other stored values may occur.`;
|
|
13
|
+
export const taskClaimSchema = z.strictObject({
|
|
14
|
+
state: z
|
|
15
|
+
.enum(["live", "expired"])
|
|
16
|
+
.describe("live until expires_at, expired after it. An expired claim stays until it is replaced or released."),
|
|
17
|
+
actor_kind: z
|
|
18
|
+
.string()
|
|
19
|
+
.describe(`Known actor kinds: ${actorKindSchema.options.join(", ")}. Other stored values may occur.`),
|
|
20
|
+
actor_name: nullableText,
|
|
21
|
+
actor_session_id: nullableText,
|
|
22
|
+
actor_thread_id: nullableText,
|
|
23
|
+
claimed_at: timestamp,
|
|
24
|
+
renewed_at: timestamp.describe("When the holder last renewed the claim."),
|
|
25
|
+
worked_at: timestamp.describe("When the holder last recorded work on the task."),
|
|
26
|
+
lease_ms: z.number().int().positive().describe("Lease length in milliseconds."),
|
|
27
|
+
expires_at: timestamp.describe(`The end of the lease after renewed_at, or ${formatDurationInput(CLAIM_WORK_LIMIT_MS)} after worked_at, whichever comes first.`),
|
|
28
|
+
});
|
|
9
29
|
export const taskSchema = z.strictObject({
|
|
10
30
|
id: z.string().describe("Stored task ID."),
|
|
11
31
|
key: z.string().describe("Readable project key and task number."),
|
|
@@ -15,6 +35,7 @@ export const taskSchema = z.strictObject({
|
|
|
15
35
|
column_id: z.string().describe("Current column ID."),
|
|
16
36
|
is_first: z.boolean().describe("Whether the task's column is the first column of its board."),
|
|
17
37
|
is_last: z.boolean().describe("Whether the task's column is the last column of its board."),
|
|
38
|
+
column_category: columnCategory.describe(`The task's column category, or null on an older database opened read-only. ${columnCategoryValues}`),
|
|
18
39
|
title: z.string(),
|
|
19
40
|
description: nullableText,
|
|
20
41
|
priority: z
|
|
@@ -28,6 +49,9 @@ export const taskSchema = z.strictObject({
|
|
|
28
49
|
label_ids: z.array(z.string()).describe("Attached label IDs, in the same order as labels."),
|
|
29
50
|
created_at: timestamp,
|
|
30
51
|
updated_at: timestamp,
|
|
52
|
+
claim: taskClaimSchema
|
|
53
|
+
.nullable()
|
|
54
|
+
.describe("The task's claim, or null when it has none or the database predates claims."),
|
|
31
55
|
});
|
|
32
56
|
export const relationSchema = z.strictObject({
|
|
33
57
|
id: z.string().describe("Stored relation ID."),
|
|
@@ -46,6 +70,7 @@ export const relationSchema = z.strictObject({
|
|
|
46
70
|
column_id: true,
|
|
47
71
|
is_first: true,
|
|
48
72
|
is_last: true,
|
|
73
|
+
column_category: true,
|
|
49
74
|
title: true,
|
|
50
75
|
status: true,
|
|
51
76
|
}),
|
|
@@ -143,15 +168,17 @@ export const columnSchema = z.strictObject({
|
|
|
143
168
|
name: z.string(),
|
|
144
169
|
is_first: z.boolean().describe("Whether this column is the first column of its board."),
|
|
145
170
|
is_last: z.boolean().describe("Whether this column is the last column of its board."),
|
|
171
|
+
category: columnCategory.describe(`What the column's tasks are to Zinn, or null on an older database opened read-only. ${columnCategoryValues}`),
|
|
146
172
|
});
|
|
147
173
|
export const columnChangeSchema = columnSchema.extend({
|
|
148
|
-
changed: z.boolean().describe("Whether the column's name or position changed."),
|
|
174
|
+
changed: z.boolean().describe("Whether the column's name, category or position changed."),
|
|
149
175
|
});
|
|
150
176
|
export const columnTaskCountSchema = z.strictObject({
|
|
151
177
|
id: columnSchema.shape.id,
|
|
152
178
|
name: z.string(),
|
|
153
179
|
is_first: columnSchema.shape.is_first,
|
|
154
180
|
is_last: columnSchema.shape.is_last,
|
|
181
|
+
category: columnSchema.shape.category,
|
|
155
182
|
taskCount: count,
|
|
156
183
|
});
|
|
157
184
|
export const projectViewSchema = projectSchema.extend({
|
|
@@ -253,7 +280,21 @@ export const infoSchema = z.strictObject({
|
|
|
253
280
|
runtime: z.strictObject({ name: z.enum(["Node", "Bun"]), version: z.string() }),
|
|
254
281
|
}),
|
|
255
282
|
});
|
|
283
|
+
export const doctorSchema = z.strictObject({
|
|
284
|
+
ok: z.boolean().describe("Whether every listed check is ok."),
|
|
285
|
+
checks: z
|
|
286
|
+
.array(z.strictObject({
|
|
287
|
+
id: z.enum([...doctorCheckIdSchema.options, "agent_skill"]),
|
|
288
|
+
status: doctorStatusSchema,
|
|
289
|
+
message: z.string(),
|
|
290
|
+
remedy: nullableText.describe("What to do about a warning or problem, null when the check is ok."),
|
|
291
|
+
}))
|
|
292
|
+
.describe("Checks that could not run because an earlier one failed are left out."),
|
|
293
|
+
});
|
|
256
294
|
export const backupSchema = z.strictObject({ path: z.string() });
|
|
295
|
+
export const skillInstallSchema = z.strictObject({
|
|
296
|
+
source: z.string().describe("The skill folder inside the CLI package that was installed."),
|
|
297
|
+
});
|
|
257
298
|
export const restoreSchema = z.strictObject({
|
|
258
299
|
databasePath: z.string(),
|
|
259
300
|
previousVersion: count.describe("Destination schema version before restore; zero when the destination had no schema version. backupPath says whether it was replaced."),
|
|
@@ -271,6 +312,7 @@ export const reindexSchema = z.strictObject({ databasePath: z.string(), taskCoun
|
|
|
271
312
|
export const resultSchemas = {
|
|
272
313
|
Task: taskSchema,
|
|
273
314
|
TaskList: z.array(taskSchema),
|
|
315
|
+
NextTask: taskSchema.nullable(),
|
|
274
316
|
TaskDetail: taskDetailSchema,
|
|
275
317
|
TaskBlame: taskBlameSchema,
|
|
276
318
|
TaskDetailHistory: taskDetailHistorySchema,
|
|
@@ -297,10 +339,12 @@ export const resultSchemas = {
|
|
|
297
339
|
ActivityList: z.array(activitySchema),
|
|
298
340
|
Actor: actorSchema,
|
|
299
341
|
Info: infoSchema,
|
|
342
|
+
Doctor: doctorSchema,
|
|
300
343
|
Backup: backupSchema,
|
|
301
344
|
Restore: restoreSchema,
|
|
302
345
|
Migrate: migrateSchema,
|
|
303
346
|
Reindex: reindexSchema,
|
|
347
|
+
SkillInstall: skillInstallSchema,
|
|
304
348
|
ErrorEnvelope: errorDocumentSchema,
|
|
305
349
|
Capabilities: capabilitiesSchema,
|
|
306
350
|
JsonValue: jsonValueSchema,
|
package/src/results.d.ts
CHANGED
|
@@ -27,14 +27,18 @@ export declare const commandResultSchema: z.ZodObject<{
|
|
|
27
27
|
max: z.ZodNullable<z.ZodNumber>;
|
|
28
28
|
}, z.core.$strict>], "kind">;
|
|
29
29
|
schemaRef: z.ZodString;
|
|
30
|
-
mode: z.
|
|
30
|
+
mode: z.ZodEnum<{
|
|
31
|
+
json: "json";
|
|
32
|
+
"json-lines": "json-lines";
|
|
33
|
+
}>;
|
|
31
34
|
stream: z.ZodLiteral<"stdout">;
|
|
32
35
|
exitCode: z.ZodLiteral<0>;
|
|
36
|
+
findingsExitCode: z.ZodOptional<z.ZodLiteral<1>>;
|
|
33
37
|
}, z.core.$strict>;
|
|
34
38
|
export type ResultSelector = z.infer<typeof resultSelectorSchema>;
|
|
35
39
|
export type CommandResult = z.infer<typeof commandResultSchema> & {
|
|
36
40
|
schemaRef: `#/schemas/definitions/${ResultSchemaName}`;
|
|
37
41
|
};
|
|
38
|
-
export declare function jsonResult(schema: ResultSchemaName, selector?: ResultSelector): CommandResult;
|
|
42
|
+
export declare function jsonResult(schema: ResultSchemaName, selector?: ResultSelector, mode?: CommandResult["mode"]): CommandResult;
|
|
39
43
|
export declare const taskDetailResults: CommandResult[];
|
|
40
44
|
export declare const taskChangeResults: CommandResult[];
|
package/src/results.js
CHANGED
|
@@ -13,15 +13,21 @@ export const resultReferenceSchema = z.string().regex(/^#\/schemas\/definitions\
|
|
|
13
13
|
export const commandResultSchema = z.strictObject({
|
|
14
14
|
selector: resultSelectorSchema,
|
|
15
15
|
schemaRef: resultReferenceSchema,
|
|
16
|
-
|
|
16
|
+
/**
|
|
17
|
+
* json is one document,
|
|
18
|
+
* json-lines is one document per line written as each becomes available
|
|
19
|
+
*/
|
|
20
|
+
mode: z.enum(["json", "json-lines"]),
|
|
17
21
|
stream: z.literal("stdout"),
|
|
18
22
|
exitCode: z.literal(0),
|
|
23
|
+
/** The same document arrives on stdout with this exit code when it reports findings */
|
|
24
|
+
findingsExitCode: z.literal(1).optional(),
|
|
19
25
|
});
|
|
20
|
-
export function jsonResult(schema, selector = { kind: "always" }) {
|
|
26
|
+
export function jsonResult(schema, selector = { kind: "always" }, mode = "json") {
|
|
21
27
|
return {
|
|
22
28
|
selector,
|
|
23
29
|
schemaRef: `#/schemas/definitions/${schema}`,
|
|
24
|
-
mode
|
|
30
|
+
mode,
|
|
25
31
|
stream: "stdout",
|
|
26
32
|
exitCode: 0,
|
|
27
33
|
};
|
|
@@ -87,7 +87,7 @@ export declare const activityRouter: {
|
|
|
87
87
|
readonly value: {
|
|
88
88
|
readonly kind: "activity-action";
|
|
89
89
|
readonly name: "action";
|
|
90
|
-
readonly choices: ("create" | "delete" | "archive" | "edit" | "move" | "order" | "unarchive" | "relation_create" | "relation_delete" | "comment_create" | "comment_edit" | "comment_delete")[];
|
|
90
|
+
readonly choices: ("create" | "delete" | "claim" | "archive" | "edit" | "move" | "order" | "unarchive" | "relation_create" | "relation_delete" | "comment_create" | "comment_edit" | "comment_delete" | "claim_take" | "claim_heartbeat" | "claim_release")[];
|
|
91
91
|
};
|
|
92
92
|
};
|
|
93
93
|
readonly changed: {
|
|
@@ -100,6 +100,9 @@ export declare const activityRouter: {
|
|
|
100
100
|
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.`;
|
|
101
101
|
};
|
|
102
102
|
};
|
|
103
|
+
readonly follow: {
|
|
104
|
+
readonly type: "boolean";
|
|
105
|
+
};
|
|
103
106
|
readonly limit: {
|
|
104
107
|
readonly type: "string";
|
|
105
108
|
readonly value: {
|
|
@@ -128,11 +131,17 @@ export declare const activityRouter: {
|
|
|
128
131
|
readonly kind: "requiresAny";
|
|
129
132
|
readonly input: "option:show-deleted";
|
|
130
133
|
readonly members: readonly ["option:project", "option:task"];
|
|
134
|
+
}, {
|
|
135
|
+
readonly kind: "exclusive";
|
|
136
|
+
readonly members: readonly ["option:follow", "option:limit"];
|
|
137
|
+
}, {
|
|
138
|
+
readonly kind: "exclusive";
|
|
139
|
+
readonly members: readonly ["option:follow", "option:starting-after"];
|
|
131
140
|
}];
|
|
132
|
-
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."];
|
|
141
|
+
readonly notes: readonly ["With --follow, the command prints activity committed after it starts, oldest first, and runs until stopped.", "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."];
|
|
133
142
|
};
|
|
134
143
|
results: import("../results.js").CommandResult[];
|
|
135
|
-
run: (args: string[]) => void;
|
|
144
|
+
run: (args: string[]) => Promise<void> | undefined;
|
|
136
145
|
help: string;
|
|
137
146
|
};
|
|
138
147
|
view: {
|
|
@@ -6,7 +6,8 @@ import { generateCommandUsage, getOptionInputs, violatesConstraint } from "../in
|
|
|
6
6
|
import { CliError } from "../errors.js";
|
|
7
7
|
import { parseTimestampInput } from "../timestamp-input.js";
|
|
8
8
|
import { formatListContinuation } from "../list-continuation.js";
|
|
9
|
-
import { diagnostic, output, quit, validatePositionals, validateUniqueOptions } from "../lib.js";
|
|
9
|
+
import { diagnostic, output, outputStream, quit, validatePositionals, validateUniqueOptions, } from "../lib.js";
|
|
10
|
+
import { followUntilStopped } from "../follow.js";
|
|
10
11
|
import { formatActivityList, presentActivities } from "../presentation/activity-presentation.js";
|
|
11
12
|
const changedFieldList = activityChangedFieldSchema.options.join(", ");
|
|
12
13
|
const activityInputs = {
|
|
@@ -72,6 +73,7 @@ const activityInputs = {
|
|
|
72
73
|
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.`,
|
|
73
74
|
},
|
|
74
75
|
},
|
|
76
|
+
follow: { type: "boolean" },
|
|
75
77
|
limit: listLimitOption,
|
|
76
78
|
"starting-after": { type: "string", value: { kind: "activity-id", name: "id" } },
|
|
77
79
|
},
|
|
@@ -86,8 +88,11 @@ const activityInputs = {
|
|
|
86
88
|
input: "option:show-deleted",
|
|
87
89
|
members: ["option:project", "option:task"],
|
|
88
90
|
},
|
|
91
|
+
{ kind: "exclusive", members: ["option:follow", "option:limit"] },
|
|
92
|
+
{ kind: "exclusive", members: ["option:follow", "option:starting-after"] },
|
|
89
93
|
],
|
|
90
94
|
notes: [
|
|
95
|
+
"With --follow, the command prints activity committed after it starts, oldest first, and runs until stopped.",
|
|
91
96
|
"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.",
|
|
92
97
|
],
|
|
93
98
|
},
|
|
@@ -108,7 +113,10 @@ export const activityRouter = {
|
|
|
108
113
|
effects: { domain: "read", storage: "normal-open" },
|
|
109
114
|
confirmation: { kind: "none" },
|
|
110
115
|
input: activityInputs.list,
|
|
111
|
-
results: [
|
|
116
|
+
results: [
|
|
117
|
+
jsonResult("ActivityList", { kind: "booleanOption", name: "follow", value: false }),
|
|
118
|
+
jsonResult("Activity", { kind: "booleanOption", name: "follow", value: true }, "json-lines"),
|
|
119
|
+
],
|
|
112
120
|
run: (args) => {
|
|
113
121
|
const { values, positionals, tokens } = parseArgs({
|
|
114
122
|
args,
|
|
@@ -119,7 +127,7 @@ export const activityRouter = {
|
|
|
119
127
|
});
|
|
120
128
|
validateUniqueOptions(tokens, activityInputs.list.options);
|
|
121
129
|
validatePositionals(positionals, activityInputs.list.forms[0]);
|
|
122
|
-
const [selectorConstraint, deletedHistoryConstraint] = activityInputs.list.constraints;
|
|
130
|
+
const [selectorConstraint, deletedHistoryConstraint, ...followConstraints] = activityInputs.list.constraints;
|
|
123
131
|
const optionInputs = getOptionInputs(values);
|
|
124
132
|
if (violatesConstraint(selectorConstraint, optionInputs)) {
|
|
125
133
|
const conflictingSelector = selectorConstraint.members.filter((member) => optionInputs[member] !== undefined)[1];
|
|
@@ -132,67 +140,54 @@ export const activityRouter = {
|
|
|
132
140
|
argument: "--show-deleted",
|
|
133
141
|
});
|
|
134
142
|
}
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
projectKey: values.project,
|
|
140
|
-
projectId: values["project-id"],
|
|
141
|
-
taskKey: values.task,
|
|
142
|
-
taskId: values["task-id"],
|
|
143
|
-
showDeleted: values["show-deleted"],
|
|
144
|
-
sessionId: values.session,
|
|
145
|
-
threadId: values.thread,
|
|
146
|
-
client: values.client,
|
|
147
|
-
actions: values.action?.map((action) => {
|
|
148
|
-
const parsed = activityActionSchema.safeParse(action);
|
|
149
|
-
if (!parsed.success) {
|
|
150
|
-
quit(`Unknown action "${action}". Use ${activityActionSchema.options.join(", ")}`, undefined, {
|
|
151
|
-
argument: "--action",
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
return parsed.data;
|
|
155
|
-
}),
|
|
156
|
-
changed: values.changed?.map(parseChangedFilter),
|
|
157
|
-
since: parseTimestampInput(values.since, "--since"),
|
|
158
|
-
until: parseTimestampInput(values.until, "--until"),
|
|
159
|
-
limit,
|
|
160
|
-
startingAfter: values["starting-after"],
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
catch (error) {
|
|
164
|
-
const isInvalidUpperBound = error instanceof CoreError &&
|
|
165
|
-
error.kind === "input" &&
|
|
166
|
-
error.facts.field?.[0] === "until";
|
|
167
|
-
if (isInvalidUpperBound) {
|
|
168
|
-
throw new CliError(error.message, "invalid_input", {
|
|
169
|
-
argument: "--until",
|
|
170
|
-
field: error.facts.field,
|
|
171
|
-
});
|
|
143
|
+
for (const constraint of followConstraints) {
|
|
144
|
+
if (violatesConstraint(constraint, optionInputs)) {
|
|
145
|
+
const argument = constraint.members[1].replace("option:", "--");
|
|
146
|
+
quit(`${argument} cannot be used with --follow`, undefined, { argument });
|
|
172
147
|
}
|
|
173
|
-
const isMissingCurrentSelection = (values.task !== undefined || values.project !== undefined) &&
|
|
174
|
-
values["show-deleted"] !== true &&
|
|
175
|
-
error instanceof CoreError &&
|
|
176
|
-
error.kind === "missing" &&
|
|
177
|
-
error.facts.entity === (values.project !== undefined ? "project" : "task");
|
|
178
|
-
if (isMissingCurrentSelection) {
|
|
179
|
-
const selector = error.facts.entity === "project" ? "--project" : "--task";
|
|
180
|
-
throw new CliError(error.message, "not_found", {
|
|
181
|
-
entity: error.facts.entity,
|
|
182
|
-
key: error.facts.key,
|
|
183
|
-
source: "explicit",
|
|
184
|
-
argument: selector,
|
|
185
|
-
}, `Use ${selector} ${values.project ?? values.task} --show-deleted to include deleted history.`);
|
|
186
|
-
}
|
|
187
|
-
throw error;
|
|
188
148
|
}
|
|
189
|
-
|
|
149
|
+
const limit = parseListLimit(values.limit);
|
|
150
|
+
const selection = {
|
|
190
151
|
projectKey: values.project,
|
|
191
152
|
projectId: values["project-id"],
|
|
192
|
-
showDeleted: values["show-deleted"],
|
|
193
153
|
taskKey: values.task,
|
|
194
154
|
taskId: values["task-id"],
|
|
195
|
-
|
|
155
|
+
showDeleted: values["show-deleted"],
|
|
156
|
+
};
|
|
157
|
+
const filters = {
|
|
158
|
+
...selection,
|
|
159
|
+
sessionId: values.session,
|
|
160
|
+
threadId: values.thread,
|
|
161
|
+
client: values.client,
|
|
162
|
+
actions: values.action?.map((action) => {
|
|
163
|
+
const parsed = activityActionSchema.safeParse(action);
|
|
164
|
+
if (!parsed.success) {
|
|
165
|
+
quit(`Unknown action "${action}". Use ${activityActionSchema.options.join(", ")}`, undefined, {
|
|
166
|
+
argument: "--action",
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
return parsed.data;
|
|
170
|
+
}),
|
|
171
|
+
changed: values.changed?.map(parseChangedFilter),
|
|
172
|
+
since: parseTimestampInput(values.since, "--since"),
|
|
173
|
+
until: parseTimestampInput(values.until, "--until"),
|
|
174
|
+
};
|
|
175
|
+
const formatEvents = (events) => formatActivityList(presentActivities(events, selection));
|
|
176
|
+
if (values.follow === true) {
|
|
177
|
+
const follower = readSelectedActivity(values, () => activity.follow(filters));
|
|
178
|
+
return followUntilStopped(async (signal) => {
|
|
179
|
+
const polled = readSelectedActivity(values, () => follower.poll());
|
|
180
|
+
if ("stopped" in polled) {
|
|
181
|
+
const reason = polled.stopped === "file_replaced"
|
|
182
|
+
? `The database file at ${polled.databasePath} was replaced or removed`
|
|
183
|
+
: `The database schema at ${polled.databasePath} changed`;
|
|
184
|
+
throw new CliError(`${reason}, so following stopped. Run the command again to follow new activity.`, "conflict", { entity: "database", databasePath: polled.databasePath });
|
|
185
|
+
}
|
|
186
|
+
await outputStream(polled.events, formatEvents, signal);
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
const page = readSelectedActivity(values, () => activity.getAll({ ...filters, limit, startingAfter: values["starting-after"] }));
|
|
190
|
+
output(page.events, formatEvents);
|
|
196
191
|
if (page.nextCursor !== undefined) {
|
|
197
192
|
diagnostic(`More activity. Continue with: ${formatListContinuation(["activity", "list"], [], tokens, "starting-after", page.nextCursor)}`);
|
|
198
193
|
}
|
|
@@ -223,6 +218,7 @@ Returns all matching events unless --limit is supplied.
|
|
|
223
218
|
Without a value, labels match additions and removals.
|
|
224
219
|
Title and description match any change, without a value.
|
|
225
220
|
Use priority=none for an unassigned priority.
|
|
221
|
+
--follow Print new activity as it is committed, until stopped.
|
|
226
222
|
--limit <n> ${listLimitDescription}
|
|
227
223
|
--starting-after <id> Continue with older events after this activity ID.
|
|
228
224
|
|
|
@@ -241,8 +237,15 @@ Times accept integer epoch milliseconds or YYYY-MM-DDTHH:mm:ss with Z or a
|
|
|
241
237
|
numeric offset such as +01:00. Optional fractional seconds have 1 to 3 digits.
|
|
242
238
|
Both bounds are inclusive. --until must be at or after --since.
|
|
243
239
|
|
|
240
|
+
--follow prints only activity committed after it starts, oldest first, and the
|
|
241
|
+
filters apply to it. It ends on Ctrl-C, once its output is closed, and with an
|
|
242
|
+
error when the database schema changes, including a restore, migration or
|
|
243
|
+
reindex, or when its file is replaced or removed.
|
|
244
|
+
--follow cannot be used with --limit or --starting-after.
|
|
245
|
+
|
|
244
246
|
Use activity view <activity-id> for complete recorded changes.
|
|
245
247
|
With --json, return an array of full activity records.
|
|
248
|
+
With --follow --json, print each full activity record as one JSON object per line.
|
|
246
249
|
|
|
247
250
|
Examples:
|
|
248
251
|
zinn activity list --limit 10
|
|
@@ -254,7 +257,8 @@ Examples:
|
|
|
254
257
|
zinn activity list --changed column=Review
|
|
255
258
|
zinn activity list --changed priority=high --changed labels=bug
|
|
256
259
|
zinn activity list --task APP-2
|
|
257
|
-
zinn activity list --task APP-2 --show-deleted
|
|
260
|
+
zinn activity list --task APP-2 --show-deleted
|
|
261
|
+
zinn activity list --follow --changed column=Review`,
|
|
258
262
|
},
|
|
259
263
|
view: {
|
|
260
264
|
summary: "Show one recorded event with full activity/entity IDs, actor and complete changes.",
|
|
@@ -286,6 +290,36 @@ With --json, return one full activity record.
|
|
|
286
290
|
Example: zinn activity view 019abcdf-1234-7`,
|
|
287
291
|
},
|
|
288
292
|
};
|
|
293
|
+
/** Reads the selected activity, reporting core's refusals with the flag that caused them */
|
|
294
|
+
function readSelectedActivity(values, read) {
|
|
295
|
+
try {
|
|
296
|
+
return read();
|
|
297
|
+
}
|
|
298
|
+
catch (error) {
|
|
299
|
+
const isInvalidUpperBound = error instanceof CoreError && error.kind === "input" && error.facts.field?.[0] === "until";
|
|
300
|
+
if (isInvalidUpperBound) {
|
|
301
|
+
throw new CliError(error.message, "invalid_input", {
|
|
302
|
+
argument: "--until",
|
|
303
|
+
field: error.facts.field,
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
const isMissingCurrentSelection = (values.task !== undefined || values.project !== undefined) &&
|
|
307
|
+
values["show-deleted"] !== true &&
|
|
308
|
+
error instanceof CoreError &&
|
|
309
|
+
error.kind === "missing" &&
|
|
310
|
+
error.facts.entity === (values.project !== undefined ? "project" : "task");
|
|
311
|
+
if (isMissingCurrentSelection) {
|
|
312
|
+
const selector = error.facts.entity === "project" ? "--project" : "--task";
|
|
313
|
+
throw new CliError(error.message, "not_found", {
|
|
314
|
+
entity: error.facts.entity,
|
|
315
|
+
key: error.facts.key,
|
|
316
|
+
source: "explicit",
|
|
317
|
+
argument: selector,
|
|
318
|
+
}, `Use ${selector} ${values.project ?? values.task} --show-deleted to include deleted history.`);
|
|
319
|
+
}
|
|
320
|
+
throw error;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
289
323
|
function parseChangedFilter(input) {
|
|
290
324
|
const separator = input.indexOf("=");
|
|
291
325
|
const field = separator === -1 ? input : input.slice(0, separator);
|
package/src/routes/aliases.js
CHANGED
|
@@ -39,7 +39,7 @@ export declare const commentRouter: {
|
|
|
39
39
|
}];
|
|
40
40
|
readonly constraints: readonly [{
|
|
41
41
|
readonly kind: "exclusive";
|
|
42
|
-
readonly members: readonly ["option:description" | "option:text", "option:description-file" | "option:text-file"];
|
|
42
|
+
readonly members: readonly ["option:description" | "option:text" | "option:expect-description" | "option:expect-text", "option:description-file" | "option:text-file" | "option:expect-description-file" | "option:expect-text-file"];
|
|
43
43
|
}, {
|
|
44
44
|
readonly kind: "atLeastOne";
|
|
45
45
|
readonly members: readonly ["option:text", "option:text-file"];
|
|
@@ -119,6 +119,21 @@ export declare const commentRouter: {
|
|
|
119
119
|
};
|
|
120
120
|
input: {
|
|
121
121
|
readonly options: {
|
|
122
|
+
readonly "expect-text": {
|
|
123
|
+
readonly type: "string";
|
|
124
|
+
readonly value: {
|
|
125
|
+
readonly kind: "text";
|
|
126
|
+
readonly name: "text";
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
readonly "expect-text-file": {
|
|
130
|
+
readonly type: "string";
|
|
131
|
+
readonly value: {
|
|
132
|
+
readonly kind: "path";
|
|
133
|
+
readonly name: "path";
|
|
134
|
+
readonly description: "A UTF-8 file, or \"-\" for stdin. Trailing line breaks are dropped; empty or blank input is an error.";
|
|
135
|
+
};
|
|
136
|
+
};
|
|
122
137
|
readonly append: {
|
|
123
138
|
readonly type: "boolean";
|
|
124
139
|
};
|
|
@@ -161,18 +176,18 @@ export declare const commentRouter: {
|
|
|
161
176
|
}];
|
|
162
177
|
readonly constraints: readonly [{
|
|
163
178
|
readonly kind: "exclusive";
|
|
164
|
-
readonly members: readonly ["option:description" | "option:text", "option:description-file" | "option:text-file"];
|
|
179
|
+
readonly members: readonly ["option:description" | "option:text" | "option:expect-description" | "option:expect-text", "option:description-file" | "option:text-file" | "option:expect-description-file" | "option:expect-text-file"];
|
|
165
180
|
}, {
|
|
166
181
|
readonly kind: "exclusive";
|
|
167
182
|
readonly members: readonly ["option:append", "option:replacing"];
|
|
168
183
|
}, {
|
|
169
184
|
readonly kind: "requiresAny";
|
|
170
185
|
readonly input: "option:append";
|
|
171
|
-
readonly members: readonly ["option:description" | "option:text", "option:description-file" | "option:text-file"];
|
|
186
|
+
readonly members: readonly ["option:description" | "option:text" | "option:expect-description" | "option:expect-text", "option:description-file" | "option:text-file" | "option:expect-description-file" | "option:expect-text-file"];
|
|
172
187
|
}, {
|
|
173
188
|
readonly kind: "requiresAny";
|
|
174
189
|
readonly input: "option:replacing";
|
|
175
|
-
readonly members: readonly ["option:description" | "option:text", "option:description-file" | "option:text-file"];
|
|
190
|
+
readonly members: readonly ["option:description" | "option:text" | "option:expect-description" | "option:expect-text", "option:description-file" | "option:text-file" | "option:expect-description-file" | "option:expect-text-file"];
|
|
176
191
|
}, {
|
|
177
192
|
readonly kind: "requires";
|
|
178
193
|
readonly input: "option:all";
|
|
@@ -180,8 +195,11 @@ export declare const commentRouter: {
|
|
|
180
195
|
}, {
|
|
181
196
|
readonly kind: "atLeastOne";
|
|
182
197
|
readonly members: readonly ["option:text", "option:text-file"];
|
|
183
|
-
}
|
|
184
|
-
|
|
198
|
+
}, ...{
|
|
199
|
+
readonly kind: "exclusive";
|
|
200
|
+
readonly members: readonly ["option:description" | "option:text" | "option:expect-description" | "option:expect-text", "option:description-file" | "option:text-file" | "option:expect-description-file" | "option:expect-text-file"];
|
|
201
|
+
}[]];
|
|
202
|
+
readonly notes: readonly [string, string];
|
|
185
203
|
};
|
|
186
204
|
results: import("../results.js").CommandResult[];
|
|
187
205
|
guessedFlags: {
|
|
@@ -4,13 +4,15 @@ import { comment } from "@zinn-dev/core";
|
|
|
4
4
|
import { generateCommandUsage, getOptionInputs, taskKeyPositional, violatesConstraint, } from "../input.js";
|
|
5
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 {
|
|
7
|
+
import { expectedValueFlags } from "../expected-values.js";
|
|
8
|
+
import { checkSingleStdinReader, resolveTextInput, textFileHelp, textFileOption, textSourceConstraint, } from "../text-input.js";
|
|
8
9
|
import { currentActor } from "../actor.js";
|
|
9
10
|
import { formatCommentList, presentComment, presentComments, } from "../presentation/comment-presentation.js";
|
|
10
11
|
const commentTextConstraint = {
|
|
11
12
|
kind: "atLeastOne",
|
|
12
13
|
members: ["option:text", "option:text-file"],
|
|
13
14
|
};
|
|
15
|
+
const commentExpectations = expectedValueFlags({ text: { field: "text", text: true } });
|
|
14
16
|
function requireCommentText(values) {
|
|
15
17
|
if (violatesConstraint(commentTextConstraint, getOptionInputs(values))) {
|
|
16
18
|
quit("Comment text must be specified with --text or --text-file", undefined, {
|
|
@@ -42,10 +44,13 @@ async function parseCommentEditArgs(args) {
|
|
|
42
44
|
});
|
|
43
45
|
validateUniqueOptions(tokens, commentInputs.edit.options);
|
|
44
46
|
validatePositionals(positionals, commentInputs.edit.forms[0]);
|
|
47
|
+
commentExpectations.parseValues(values);
|
|
48
|
+
checkSingleStdinReader(values, ["--text", ...commentExpectations.textFlags]);
|
|
45
49
|
const text = await resolveTextEdit(values, "--text");
|
|
46
50
|
// Without a text source nothing was read, so this usage error still comes before any input
|
|
47
51
|
requireCommentText(values);
|
|
48
|
-
|
|
52
|
+
const expected = await commentExpectations.resolveText(values);
|
|
53
|
+
return { key: positionals[0], text: text, expected };
|
|
49
54
|
}
|
|
50
55
|
const commentInputs = {
|
|
51
56
|
create: {
|
|
@@ -86,6 +91,7 @@ const commentInputs = {
|
|
|
86
91
|
text: { type: "string", value: { kind: "text", name: "text" } },
|
|
87
92
|
"text-file": textFileOption,
|
|
88
93
|
...textEditOptions,
|
|
94
|
+
...commentExpectations.options,
|
|
89
95
|
},
|
|
90
96
|
forms: [
|
|
91
97
|
{
|
|
@@ -97,8 +103,9 @@ const commentInputs = {
|
|
|
97
103
|
textSourceConstraint("--text"),
|
|
98
104
|
...textEditConstraints("--text"),
|
|
99
105
|
commentTextConstraint,
|
|
106
|
+
...commentExpectations.constraints,
|
|
100
107
|
],
|
|
101
|
-
notes: [textEditHelp("--text")],
|
|
108
|
+
notes: [textEditHelp("--text"), commentExpectations.help],
|
|
102
109
|
},
|
|
103
110
|
delete: {
|
|
104
111
|
options: { yes: { type: "boolean" } },
|
|
@@ -204,7 +211,7 @@ Example: zinn task comment view 'MDR-1#1'`,
|
|
|
204
211
|
},
|
|
205
212
|
run: async (args) => {
|
|
206
213
|
const props = await parseCommentEditArgs(args);
|
|
207
|
-
const edited = comment.edit({ commentKey: props.key, text: props.text }, currentActor());
|
|
214
|
+
const edited = comment.edit({ commentKey: props.key, text: props.text, expected: props.expected }, currentActor());
|
|
208
215
|
outputChanges([edited], (change) => presentComment(change.comment), (entries) => formatCommentList(entries, { showsCreatedAt: false, showsTextPreview: true }), (entry) => `Comment ${entry.key} was unchanged`);
|
|
209
216
|
},
|
|
210
217
|
help: `${generateCommandUsage("task comment edit", commentInputs.edit)}
|
|
@@ -216,11 +223,14 @@ The printed result is a preview. 'task comment view' shows the full text. --json
|
|
|
216
223
|
|
|
217
224
|
${textEditHelp("--text")}
|
|
218
225
|
|
|
226
|
+
${commentExpectations.help}
|
|
227
|
+
|
|
219
228
|
${dashValueHelp("--text")}
|
|
220
229
|
|
|
221
230
|
Examples:
|
|
222
231
|
zinn task comment edit 'MDR-1#2' --text Approved
|
|
223
|
-
zinn task comment edit 'MDR-1#2' --text 'Also approved.' --append
|
|
232
|
+
zinn task comment edit 'MDR-1#2' --text 'Also approved.' --append
|
|
233
|
+
zinn task comment edit 'MDR-1#2' --text Approved --expect-text 'Looks good'`,
|
|
224
234
|
},
|
|
225
235
|
delete: {
|
|
226
236
|
summary: "Permanently delete a comment after confirmation.",
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export declare const doctorCommand: {
|
|
2
|
+
summary: string;
|
|
3
|
+
effects: {
|
|
4
|
+
domain: "none";
|
|
5
|
+
storage: "inspect";
|
|
6
|
+
};
|
|
7
|
+
confirmation: {
|
|
8
|
+
kind: "none";
|
|
9
|
+
};
|
|
10
|
+
input: {
|
|
11
|
+
readonly options: {};
|
|
12
|
+
readonly forms: readonly [{
|
|
13
|
+
readonly id: "default";
|
|
14
|
+
readonly positionals: readonly [];
|
|
15
|
+
}];
|
|
16
|
+
readonly constraints: readonly [];
|
|
17
|
+
};
|
|
18
|
+
results: {
|
|
19
|
+
findingsExitCode: 1;
|
|
20
|
+
selector: {
|
|
21
|
+
kind: "always";
|
|
22
|
+
} | {
|
|
23
|
+
kind: "booleanOption";
|
|
24
|
+
name: string;
|
|
25
|
+
value: boolean;
|
|
26
|
+
} | {
|
|
27
|
+
kind: "positionalCount";
|
|
28
|
+
name: string;
|
|
29
|
+
min: number;
|
|
30
|
+
max: number | null;
|
|
31
|
+
};
|
|
32
|
+
schemaRef: `#/schemas/definitions/${import("../result-schemas.js").ResultSchemaName}`;
|
|
33
|
+
mode: "json" | "json-lines";
|
|
34
|
+
stream: "stdout";
|
|
35
|
+
exitCode: 0;
|
|
36
|
+
}[];
|
|
37
|
+
run: (args: string[]) => void;
|
|
38
|
+
help: string;
|
|
39
|
+
};
|