@zinn-dev/cli 0.43.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/README.md +1 -1
- package/index.js +3 -3
- package/package.json +7 -4
- package/skills/zinn/SKILL.md +7 -9
- package/src/actor.d.ts +8 -0
- package/src/actor.js +5 -1
- package/src/capabilities-schema.d.ts +6 -2
- package/src/column-hint.js +2 -5
- 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 +34 -3
- package/src/errors.js +49 -7
- package/src/expected-values.d.ts +48 -0
- package/src/expected-values.js +60 -0
- package/src/failure-log.d.ts +6 -0
- package/src/failure-log.js +167 -0
- package/src/follow.d.ts +9 -0
- package/src/follow.js +58 -0
- package/src/input.d.ts +10 -7
- package/src/input.js +57 -13
- package/src/lib.d.ts +12 -7
- package/src/lib.js +70 -41
- package/src/list-continuation.js +1 -4
- package/src/list-limit.d.ts +2 -2
- package/src/list-limit.js +2 -2
- package/src/overview.d.ts +10 -0
- package/src/overview.js +41 -0
- package/src/presentation/activity-presentation.d.ts +4 -0
- package/src/presentation/activity-presentation.js +154 -38
- package/src/presentation/column-presentation.d.ts +22 -2
- package/src/presentation/column-presentation.js +68 -12
- package/src/presentation/doctor-presentation.d.ts +4 -0
- package/src/presentation/doctor-presentation.js +24 -0
- package/src/presentation/info-presentation.js +36 -6
- package/src/presentation/relation-presentation.d.ts +6 -2
- package/src/presentation/relation-presentation.js +37 -26
- package/src/presentation/task-blame-presentation.d.ts +8 -0
- package/src/presentation/task-blame-presentation.js +56 -0
- package/src/presentation/task-presentation.d.ts +8 -1
- package/src/presentation/task-presentation.js +59 -10
- package/src/result-schemas.d.ts +780 -20
- package/src/result-schemas.js +99 -2
- package/src/results.d.ts +6 -2
- package/src/results.js +9 -3
- package/src/routes/activity-router.d.ts +21 -4
- package/src/routes/activity-router.js +107 -60
- 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/info-router.js +3 -2
- package/src/routes/label-router.d.ts +39 -6
- package/src/routes/label-router.js +22 -5
- package/src/routes/migrate-router.js +2 -2
- package/src/routes/project-router.d.ts +61 -12
- package/src/routes/project-router.js +103 -45
- package/src/routes/restore-router.js +11 -5
- package/src/routes/router.js +25 -16
- package/src/routes/routes.d.ts +455 -41
- 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 +272 -19
- package/src/routes/task-router.js +325 -40
- package/src/routes/whoami-router.js +1 -1
- package/src/run-facts.d.ts +14 -0
- package/src/run-facts.js +14 -0
- package/src/store-folder.d.ts +5 -0
- package/src/store-folder.js +16 -0
- package/src/telemetry.d.ts +31 -0
- package/src/telemetry.js +329 -0
- package/src/text-edit.d.ts +2 -2
- package/src/text-input.d.ts +19 -1
- package/src/text-input.js +27 -10
- package/src/types.d.ts +1 -1
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, } 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."),
|
|
@@ -13,6 +33,9 @@ export const taskSchema = z.strictObject({
|
|
|
13
33
|
status: taskStatus,
|
|
14
34
|
column: z.string().describe("Current column name."),
|
|
15
35
|
column_id: z.string().describe("Current column ID."),
|
|
36
|
+
is_first: z.boolean().describe("Whether the task's column is the first column of its board."),
|
|
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}`),
|
|
16
39
|
title: z.string(),
|
|
17
40
|
description: nullableText,
|
|
18
41
|
priority: z
|
|
@@ -26,6 +49,9 @@ export const taskSchema = z.strictObject({
|
|
|
26
49
|
label_ids: z.array(z.string()).describe("Attached label IDs, in the same order as labels."),
|
|
27
50
|
created_at: timestamp,
|
|
28
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."),
|
|
29
55
|
});
|
|
30
56
|
export const relationSchema = z.strictObject({
|
|
31
57
|
id: z.string().describe("Stored relation ID."),
|
|
@@ -42,6 +68,9 @@ export const relationSchema = z.strictObject({
|
|
|
42
68
|
project_id: true,
|
|
43
69
|
column: true,
|
|
44
70
|
column_id: true,
|
|
71
|
+
is_first: true,
|
|
72
|
+
is_last: true,
|
|
73
|
+
column_category: true,
|
|
45
74
|
title: true,
|
|
46
75
|
status: true,
|
|
47
76
|
}),
|
|
@@ -76,6 +105,7 @@ export const activitySchema = z.strictObject({
|
|
|
76
105
|
actor_agent: nullableText,
|
|
77
106
|
actor_model: nullableText,
|
|
78
107
|
actor_effort: nullableText,
|
|
108
|
+
actor_client: nullableText,
|
|
79
109
|
entity_type: z
|
|
80
110
|
.string()
|
|
81
111
|
.describe(`Known entity types: ${activityEntityTypeSchema.options.join(", ")}. Other stored values may occur.`),
|
|
@@ -98,6 +128,11 @@ export const actorSchema = activitySchema.pick({
|
|
|
98
128
|
actor_agent: true,
|
|
99
129
|
actor_model: true,
|
|
100
130
|
actor_effort: true,
|
|
131
|
+
actor_client: true,
|
|
132
|
+
});
|
|
133
|
+
export const taskAttributionSchema = actorSchema.extend({
|
|
134
|
+
id: activitySchema.shape.id,
|
|
135
|
+
created_at: timestamp,
|
|
101
136
|
});
|
|
102
137
|
export const taskDetailSchema = taskSchema.extend({
|
|
103
138
|
relations: z.array(relationSchema),
|
|
@@ -131,13 +166,19 @@ export const columnSchema = z.strictObject({
|
|
|
131
166
|
project: z.string(),
|
|
132
167
|
project_id: z.string().describe("Owning project ID."),
|
|
133
168
|
name: z.string(),
|
|
169
|
+
is_first: z.boolean().describe("Whether this column is the first column of its board."),
|
|
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}`),
|
|
134
172
|
});
|
|
135
173
|
export const columnChangeSchema = columnSchema.extend({
|
|
136
|
-
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."),
|
|
137
175
|
});
|
|
138
176
|
export const columnTaskCountSchema = z.strictObject({
|
|
139
177
|
id: columnSchema.shape.id,
|
|
140
178
|
name: z.string(),
|
|
179
|
+
is_first: columnSchema.shape.is_first,
|
|
180
|
+
is_last: columnSchema.shape.is_last,
|
|
181
|
+
category: columnSchema.shape.category,
|
|
141
182
|
taskCount: count,
|
|
142
183
|
});
|
|
143
184
|
export const projectViewSchema = projectSchema.extend({
|
|
@@ -155,6 +196,33 @@ export const labelSchema = z.strictObject({
|
|
|
155
196
|
export const labelChangeSchema = labelSchema.extend({
|
|
156
197
|
changed: z.boolean().describe("Whether the label's fields changed."),
|
|
157
198
|
});
|
|
199
|
+
const blameTaskIdentity = taskSchema.pick({ id: true, key: true });
|
|
200
|
+
function blamedValue(value) {
|
|
201
|
+
return z.strictObject({ value, attribution: taskAttributionSchema.nullable() });
|
|
202
|
+
}
|
|
203
|
+
export const taskBlameSchema = z.strictObject({
|
|
204
|
+
task: blameTaskIdentity,
|
|
205
|
+
fields: z.strictObject({
|
|
206
|
+
title: blamedValue(z.string()),
|
|
207
|
+
column: blamedValue(columnSchema.pick({ id: true, name: true })),
|
|
208
|
+
priority: blamedValue(taskSchema.shape.priority),
|
|
209
|
+
due_at: blamedValue(taskSchema.shape.due_at),
|
|
210
|
+
labels: blamedValue(z.array(labelSchema.pick({ id: true, name: true }))),
|
|
211
|
+
parent: blamedValue(blameTaskIdentity.nullable()),
|
|
212
|
+
}),
|
|
213
|
+
relations: z.array(z.strictObject({
|
|
214
|
+
id: relationSchema.shape.id,
|
|
215
|
+
type: relationSchema.shape.type,
|
|
216
|
+
direction: relationSchema.shape.direction,
|
|
217
|
+
task: blameTaskIdentity,
|
|
218
|
+
attribution: taskAttributionSchema.nullable(),
|
|
219
|
+
})),
|
|
220
|
+
description: z.array(z.strictObject({
|
|
221
|
+
line: z.number().int().positive(),
|
|
222
|
+
text: z.string(),
|
|
223
|
+
attribution: taskAttributionSchema.nullable(),
|
|
224
|
+
})),
|
|
225
|
+
});
|
|
158
226
|
export const commentChangeSchema = commentSchema.extend({
|
|
159
227
|
changed: z.boolean().describe("Whether the comment's text changed."),
|
|
160
228
|
});
|
|
@@ -188,6 +256,17 @@ export const infoSchema = z.strictObject({
|
|
|
188
256
|
settingsPath: nullableText,
|
|
189
257
|
error: nullableText,
|
|
190
258
|
}),
|
|
259
|
+
telemetry: z.strictObject({
|
|
260
|
+
mode: telemetryModeSchema.nullable(),
|
|
261
|
+
source: telemetrySourceSchema.nullable(),
|
|
262
|
+
settingsPath: nullableText,
|
|
263
|
+
maxMegabytes: z.number().int().positive().nullable(),
|
|
264
|
+
maxAgeDays: z.number().int().positive().nullable(),
|
|
265
|
+
directory: nullableText,
|
|
266
|
+
exists: z.boolean().nullable(),
|
|
267
|
+
sizeBytes: count.nullable(),
|
|
268
|
+
error: nullableText,
|
|
269
|
+
}),
|
|
191
270
|
database: z.strictObject({
|
|
192
271
|
path: nullableText,
|
|
193
272
|
state: infoDatabaseStateSchema,
|
|
@@ -201,7 +280,21 @@ export const infoSchema = z.strictObject({
|
|
|
201
280
|
runtime: z.strictObject({ name: z.enum(["Node", "Bun"]), version: z.string() }),
|
|
202
281
|
}),
|
|
203
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
|
+
});
|
|
204
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
|
+
});
|
|
205
298
|
export const restoreSchema = z.strictObject({
|
|
206
299
|
databasePath: z.string(),
|
|
207
300
|
previousVersion: count.describe("Destination schema version before restore; zero when the destination had no schema version. backupPath says whether it was replaced."),
|
|
@@ -219,7 +312,9 @@ export const reindexSchema = z.strictObject({ databasePath: z.string(), taskCoun
|
|
|
219
312
|
export const resultSchemas = {
|
|
220
313
|
Task: taskSchema,
|
|
221
314
|
TaskList: z.array(taskSchema),
|
|
315
|
+
NextTask: taskSchema.nullable(),
|
|
222
316
|
TaskDetail: taskDetailSchema,
|
|
317
|
+
TaskBlame: taskBlameSchema,
|
|
223
318
|
TaskDetailHistory: taskDetailHistorySchema,
|
|
224
319
|
TaskChange: taskChangeSchema,
|
|
225
320
|
TaskChanges: z.array(taskChangeSchema).min(2),
|
|
@@ -244,10 +339,12 @@ export const resultSchemas = {
|
|
|
244
339
|
ActivityList: z.array(activitySchema),
|
|
245
340
|
Actor: actorSchema,
|
|
246
341
|
Info: infoSchema,
|
|
342
|
+
Doctor: doctorSchema,
|
|
247
343
|
Backup: backupSchema,
|
|
248
344
|
Restore: restoreSchema,
|
|
249
345
|
Migrate: migrateSchema,
|
|
250
346
|
Reindex: reindexSchema,
|
|
347
|
+
SkillInstall: skillInstallSchema,
|
|
251
348
|
ErrorEnvelope: errorDocumentSchema,
|
|
252
349
|
Capabilities: capabilitiesSchema,
|
|
253
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
|
};
|
|
@@ -57,6 +57,14 @@ export declare const activityRouter: {
|
|
|
57
57
|
readonly name: "id";
|
|
58
58
|
};
|
|
59
59
|
};
|
|
60
|
+
readonly client: {
|
|
61
|
+
readonly type: "string";
|
|
62
|
+
readonly value: {
|
|
63
|
+
readonly kind: "text";
|
|
64
|
+
readonly name: "name";
|
|
65
|
+
readonly description: "Match a client name or its colon-separated parts, including case.";
|
|
66
|
+
};
|
|
67
|
+
};
|
|
60
68
|
readonly since: {
|
|
61
69
|
readonly type: "string";
|
|
62
70
|
readonly value: {
|
|
@@ -79,7 +87,7 @@ export declare const activityRouter: {
|
|
|
79
87
|
readonly value: {
|
|
80
88
|
readonly kind: "activity-action";
|
|
81
89
|
readonly name: "action";
|
|
82
|
-
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")[];
|
|
83
91
|
};
|
|
84
92
|
};
|
|
85
93
|
readonly changed: {
|
|
@@ -92,6 +100,9 @@ export declare const activityRouter: {
|
|
|
92
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.`;
|
|
93
101
|
};
|
|
94
102
|
};
|
|
103
|
+
readonly follow: {
|
|
104
|
+
readonly type: "boolean";
|
|
105
|
+
};
|
|
95
106
|
readonly limit: {
|
|
96
107
|
readonly type: "string";
|
|
97
108
|
readonly value: {
|
|
@@ -99,7 +110,7 @@ export declare const activityRouter: {
|
|
|
99
110
|
readonly name: "n";
|
|
100
111
|
readonly pattern: string;
|
|
101
112
|
};
|
|
102
|
-
readonly description: "Return at most n results after all filters.
|
|
113
|
+
readonly description: "Return at most n results after all filters.";
|
|
103
114
|
};
|
|
104
115
|
readonly "starting-after": {
|
|
105
116
|
readonly type: "string";
|
|
@@ -120,11 +131,17 @@ export declare const activityRouter: {
|
|
|
120
131
|
readonly kind: "requiresAny";
|
|
121
132
|
readonly input: "option:show-deleted";
|
|
122
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"];
|
|
123
140
|
}];
|
|
124
|
-
readonly notes: readonly ["Repeated --action flags match any listed action. Repeated --changed filters for one field match any of them. Different fields must match the same event. All other filters must also match, before --limit applies."];
|
|
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."];
|
|
125
142
|
};
|
|
126
143
|
results: import("../results.js").CommandResult[];
|
|
127
|
-
run: (args: string[]) => void;
|
|
144
|
+
run: (args: string[]) => Promise<void> | undefined;
|
|
128
145
|
help: string;
|
|
129
146
|
};
|
|
130
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 = {
|
|
@@ -33,6 +34,14 @@ const activityInputs = {
|
|
|
33
34
|
"show-deleted": { type: "boolean" },
|
|
34
35
|
session: { type: "string", value: { kind: "text", name: "id" } },
|
|
35
36
|
thread: { type: "string", value: { kind: "text", name: "id" } },
|
|
37
|
+
client: {
|
|
38
|
+
type: "string",
|
|
39
|
+
value: {
|
|
40
|
+
kind: "text",
|
|
41
|
+
name: "name",
|
|
42
|
+
description: "Match a client name or its colon-separated parts, including case.",
|
|
43
|
+
},
|
|
44
|
+
},
|
|
36
45
|
since: {
|
|
37
46
|
type: "string",
|
|
38
47
|
value: {
|
|
@@ -64,6 +73,7 @@ const activityInputs = {
|
|
|
64
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.`,
|
|
65
74
|
},
|
|
66
75
|
},
|
|
76
|
+
follow: { type: "boolean" },
|
|
67
77
|
limit: listLimitOption,
|
|
68
78
|
"starting-after": { type: "string", value: { kind: "activity-id", name: "id" } },
|
|
69
79
|
},
|
|
@@ -78,8 +88,11 @@ const activityInputs = {
|
|
|
78
88
|
input: "option:show-deleted",
|
|
79
89
|
members: ["option:project", "option:task"],
|
|
80
90
|
},
|
|
91
|
+
{ kind: "exclusive", members: ["option:follow", "option:limit"] },
|
|
92
|
+
{ kind: "exclusive", members: ["option:follow", "option:starting-after"] },
|
|
81
93
|
],
|
|
82
94
|
notes: [
|
|
95
|
+
"With --follow, the command prints activity committed after it starts, oldest first, and runs until stopped.",
|
|
83
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.",
|
|
84
97
|
],
|
|
85
98
|
},
|
|
@@ -100,7 +113,10 @@ export const activityRouter = {
|
|
|
100
113
|
effects: { domain: "read", storage: "normal-open" },
|
|
101
114
|
confirmation: { kind: "none" },
|
|
102
115
|
input: activityInputs.list,
|
|
103
|
-
results: [
|
|
116
|
+
results: [
|
|
117
|
+
jsonResult("ActivityList", { kind: "booleanOption", name: "follow", value: false }),
|
|
118
|
+
jsonResult("Activity", { kind: "booleanOption", name: "follow", value: true }, "json-lines"),
|
|
119
|
+
],
|
|
104
120
|
run: (args) => {
|
|
105
121
|
const { values, positionals, tokens } = parseArgs({
|
|
106
122
|
args,
|
|
@@ -111,7 +127,7 @@ export const activityRouter = {
|
|
|
111
127
|
});
|
|
112
128
|
validateUniqueOptions(tokens, activityInputs.list.options);
|
|
113
129
|
validatePositionals(positionals, activityInputs.list.forms[0]);
|
|
114
|
-
const [selectorConstraint, deletedHistoryConstraint] = activityInputs.list.constraints;
|
|
130
|
+
const [selectorConstraint, deletedHistoryConstraint, ...followConstraints] = activityInputs.list.constraints;
|
|
115
131
|
const optionInputs = getOptionInputs(values);
|
|
116
132
|
if (violatesConstraint(selectorConstraint, optionInputs)) {
|
|
117
133
|
const conflictingSelector = selectorConstraint.members.filter((member) => optionInputs[member] !== undefined)[1];
|
|
@@ -124,68 +140,56 @@ export const activityRouter = {
|
|
|
124
140
|
argument: "--show-deleted",
|
|
125
141
|
});
|
|
126
142
|
}
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
projectKey: values.project,
|
|
132
|
-
projectId: values["project-id"],
|
|
133
|
-
taskKey: values.task,
|
|
134
|
-
taskId: values["task-id"],
|
|
135
|
-
showDeleted: values["show-deleted"],
|
|
136
|
-
sessionId: values.session,
|
|
137
|
-
threadId: values.thread,
|
|
138
|
-
actions: values.action?.map((action) => {
|
|
139
|
-
const parsed = activityActionSchema.safeParse(action);
|
|
140
|
-
if (!parsed.success) {
|
|
141
|
-
quit(`Unknown action "${action}". Use ${activityActionSchema.options.join(", ")}`, undefined, {
|
|
142
|
-
argument: "--action",
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
return parsed.data;
|
|
146
|
-
}),
|
|
147
|
-
changed: values.changed?.map(parseChangedFilter),
|
|
148
|
-
since: parseTimestampInput(values.since, "--since"),
|
|
149
|
-
until: parseTimestampInput(values.until, "--until"),
|
|
150
|
-
limit,
|
|
151
|
-
startingAfter: values["starting-after"],
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
catch (error) {
|
|
155
|
-
const isInvalidUpperBound = error instanceof CoreError &&
|
|
156
|
-
error.kind === "input" &&
|
|
157
|
-
error.facts.field?.[0] === "until";
|
|
158
|
-
if (isInvalidUpperBound) {
|
|
159
|
-
throw new CliError(error.message, "invalid_input", {
|
|
160
|
-
argument: "--until",
|
|
161
|
-
field: error.facts.field,
|
|
162
|
-
});
|
|
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 });
|
|
163
147
|
}
|
|
164
|
-
const isMissingCurrentSelection = (values.task !== undefined || values.project !== undefined) &&
|
|
165
|
-
values["show-deleted"] !== true &&
|
|
166
|
-
error instanceof CoreError &&
|
|
167
|
-
error.kind === "missing" &&
|
|
168
|
-
error.facts.entity === (values.project !== undefined ? "project" : "task");
|
|
169
|
-
if (isMissingCurrentSelection) {
|
|
170
|
-
const selector = error.facts.entity === "project" ? "--project" : "--task";
|
|
171
|
-
throw new CliError(error.message, "not_found", {
|
|
172
|
-
entity: error.facts.entity,
|
|
173
|
-
key: error.facts.key,
|
|
174
|
-
source: "explicit",
|
|
175
|
-
argument: selector,
|
|
176
|
-
}, `Use ${selector} ${values.project ?? values.task} --show-deleted to include deleted history.`);
|
|
177
|
-
}
|
|
178
|
-
throw error;
|
|
179
148
|
}
|
|
180
|
-
|
|
149
|
+
const limit = parseListLimit(values.limit);
|
|
150
|
+
const selection = {
|
|
181
151
|
projectKey: values.project,
|
|
182
152
|
projectId: values["project-id"],
|
|
183
|
-
showDeleted: values["show-deleted"],
|
|
184
153
|
taskKey: values.task,
|
|
185
154
|
taskId: values["task-id"],
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
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);
|
|
191
|
+
if (page.nextCursor !== undefined) {
|
|
192
|
+
diagnostic(`More activity. Continue with: ${formatListContinuation(["activity", "list"], [], tokens, "starting-after", page.nextCursor)}`);
|
|
189
193
|
}
|
|
190
194
|
},
|
|
191
195
|
help: `${generateCommandUsage("activity list", activityInputs.list)}
|
|
@@ -202,6 +206,9 @@ Returns all matching events unless --limit is supplied.
|
|
|
202
206
|
Requires a full UUID.
|
|
203
207
|
--session <id> Match an exact session ID, including case.
|
|
204
208
|
--thread <id> Match an exact thread ID, including case.
|
|
209
|
+
--client <name> Match a client name or its colon-separated parts, including case.
|
|
210
|
+
zinn-opencode matches zinn-opencode and zinn-opencode:panel.
|
|
211
|
+
Versions are ignored. Names are taken from whitespace-separated tokens.
|
|
205
212
|
--since <time> Include events at or after this time.
|
|
206
213
|
--until <time> Include events at or before this time.
|
|
207
214
|
--action <action> Match a recorded action. Repeat to match any listed action.
|
|
@@ -211,6 +218,7 @@ Returns all matching events unless --limit is supplied.
|
|
|
211
218
|
Without a value, labels match additions and removals.
|
|
212
219
|
Title and description match any change, without a value.
|
|
213
220
|
Use priority=none for an unassigned priority.
|
|
221
|
+
--follow Print new activity as it is committed, until stopped.
|
|
214
222
|
--limit <n> ${listLimitDescription}
|
|
215
223
|
--starting-after <id> Continue with older events after this activity ID.
|
|
216
224
|
|
|
@@ -229,19 +237,28 @@ Times accept integer epoch milliseconds or YYYY-MM-DDTHH:mm:ss with Z or a
|
|
|
229
237
|
numeric offset such as +01:00. Optional fractional seconds have 1 to 3 digits.
|
|
230
238
|
Both bounds are inclusive. --until must be at or after --since.
|
|
231
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
|
+
|
|
232
246
|
Use activity view <activity-id> for complete recorded changes.
|
|
233
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.
|
|
234
249
|
|
|
235
250
|
Examples:
|
|
236
251
|
zinn activity list --limit 10
|
|
237
252
|
zinn activity list --project APP
|
|
253
|
+
zinn activity list --client zinn-opencode:panel
|
|
238
254
|
zinn activity list --since 2026-10-25T00:00:00Z --until 2026-10-25T12:00:00Z
|
|
239
255
|
zinn activity list --action comment_create --action comment_edit
|
|
240
256
|
zinn activity list --action edit --changed description
|
|
241
257
|
zinn activity list --changed column=Review
|
|
242
258
|
zinn activity list --changed priority=high --changed labels=bug
|
|
243
259
|
zinn activity list --task APP-2
|
|
244
|
-
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`,
|
|
245
262
|
},
|
|
246
263
|
view: {
|
|
247
264
|
summary: "Show one recorded event with full activity/entity IDs, actor and complete changes.",
|
|
@@ -273,6 +290,36 @@ With --json, return one full activity record.
|
|
|
273
290
|
Example: zinn activity view 019abcdf-1234-7`,
|
|
274
291
|
},
|
|
275
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
|
+
}
|
|
276
323
|
function parseChangedFilter(input) {
|
|
277
324
|
const separator = input.indexOf("=");
|
|
278
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: {
|