@zinn-dev/cli 0.41.0 → 0.43.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -689
- package/index.js +2 -2
- package/package.json +4 -4
- package/skills/zinn/SKILL.md +1 -1
- package/src/capabilities-schema.d.ts +25 -26
- package/src/capabilities-schema.js +17 -82
- package/src/capabilities.d.ts +11 -3
- package/src/capabilities.js +12 -4
- package/src/column-hint.d.ts +3 -0
- package/src/column-hint.js +225 -0
- package/src/database.js +1 -4
- package/src/errors.d.ts +31 -3
- package/src/errors.js +77 -20
- package/src/input.d.ts +154 -43
- package/src/input.js +86 -13
- package/src/lib.d.ts +43 -6
- package/src/lib.js +134 -38
- package/src/list-continuation.d.ts +11 -0
- package/src/list-continuation.js +18 -0
- package/src/list-limit.d.ts +11 -0
- package/src/list-limit.js +17 -0
- package/src/presentation/activity-presentation.d.ts +9 -1
- package/src/presentation/activity-presentation.js +124 -28
- package/src/presentation/capabilities-presentation.d.ts +2 -0
- package/src/presentation/capabilities-presentation.js +3 -0
- package/src/presentation/column-presentation.d.ts +6 -0
- package/src/presentation/column-presentation.js +10 -0
- package/src/presentation/comment-presentation.d.ts +15 -0
- package/src/presentation/comment-presentation.js +29 -0
- package/src/presentation/description-presentation.d.ts +4 -0
- package/src/presentation/description-presentation.js +28 -5
- package/src/presentation/label-presentation.d.ts +8 -0
- package/src/presentation/label-presentation.js +28 -0
- package/src/presentation/project-presentation.d.ts +11 -0
- package/src/presentation/project-presentation.js +27 -0
- package/src/presentation/relation-presentation.d.ts +12 -0
- package/src/presentation/relation-presentation.js +87 -0
- package/src/presentation/row-layout.d.ts +1 -1
- package/src/presentation/row-layout.js +6 -5
- package/src/presentation/task-presentation.d.ts +3 -3
- package/src/presentation/task-presentation.js +29 -19
- package/src/presentation/text-width.d.ts +2 -0
- package/src/presentation/text-width.js +43 -0
- package/src/presentation/time.d.ts +3 -1
- package/src/presentation/time.js +5 -2
- package/src/project.d.ts +14 -5
- package/src/project.js +18 -6
- package/src/result-schemas.d.ts +279 -26
- package/src/result-schemas.js +72 -4
- package/src/results.d.ts +34 -17
- package/src/results.js +19 -0
- package/src/routes/activity-router.d.ts +79 -2
- package/src/routes/activity-router.js +209 -38
- package/src/routes/aliases.d.ts +2 -0
- package/src/routes/aliases.js +11 -0
- package/src/routes/capabilities-router.js +9 -3
- package/src/routes/comment-router.d.ts +41 -18
- package/src/routes/comment-router.js +65 -48
- package/src/routes/label-router.d.ts +57 -7
- package/src/routes/label-router.js +84 -39
- package/src/routes/project-router.d.ts +74 -12
- package/src/routes/project-router.js +131 -66
- package/src/routes/relation-router.d.ts +13 -9
- package/src/routes/relation-router.js +116 -116
- package/src/routes/restore-router.js +3 -6
- package/src/routes/router.d.ts +1 -1
- package/src/routes/router.js +88 -32
- package/src/routes/routes.d.ts +420 -50
- package/src/routes/routes.js +4 -0
- package/src/routes/task-router.d.ts +189 -30
- package/src/routes/task-router.js +254 -158
- package/src/routes/whoami-router.d.ts +21 -0
- package/src/routes/whoami-router.js +31 -0
- package/src/text-edit.d.ts +13 -9
- package/src/text-edit.js +23 -18
- package/src/text-input.d.ts +47 -0
- package/src/text-input.js +187 -0
- package/src/timestamp-input.d.ts +3 -0
- package/src/timestamp-input.js +31 -0
- package/src/types.d.ts +32 -9
- package/src/types.js +9 -1
package/src/result-schemas.js
CHANGED
|
@@ -7,18 +7,28 @@ const count = z.number().int().nonnegative();
|
|
|
7
7
|
const timestamp = z.number().int().describe("Milliseconds since the Unix epoch.");
|
|
8
8
|
const taskStatus = z.enum(["Active", "Archived"]);
|
|
9
9
|
export const taskSchema = z.strictObject({
|
|
10
|
+
id: z.string().describe("Stored task ID."),
|
|
10
11
|
key: z.string().describe("Readable project key and task number."),
|
|
12
|
+
project_id: z.string().describe("Owning project ID."),
|
|
11
13
|
status: taskStatus,
|
|
12
14
|
column: z.string().describe("Current column name."),
|
|
15
|
+
column_id: z.string().describe("Current column ID."),
|
|
13
16
|
title: z.string(),
|
|
14
17
|
description: nullableText,
|
|
15
18
|
priority: z
|
|
16
19
|
.string()
|
|
17
20
|
.nullable()
|
|
18
21
|
.describe(`Known priorities: ${taskPrioritySchema.options.join(", ")}. Other stored values may occur.`),
|
|
22
|
+
due_at: timestamp
|
|
23
|
+
.nullable()
|
|
24
|
+
.describe("Exact deadline in epoch milliseconds, or null when unset."),
|
|
19
25
|
labels: z.array(z.string()).describe("Attached label names."),
|
|
26
|
+
label_ids: z.array(z.string()).describe("Attached label IDs, in the same order as labels."),
|
|
27
|
+
created_at: timestamp,
|
|
28
|
+
updated_at: timestamp,
|
|
20
29
|
});
|
|
21
30
|
export const relationSchema = z.strictObject({
|
|
31
|
+
id: z.string().describe("Stored relation ID."),
|
|
22
32
|
type: z
|
|
23
33
|
.string()
|
|
24
34
|
.describe(`Known relation types: ${relationTypeSchema.options.join(", ")}. Other stored values may occur.`),
|
|
@@ -26,15 +36,28 @@ export const relationSchema = z.strictObject({
|
|
|
26
36
|
.enum(["outgoing", "incoming"])
|
|
27
37
|
.nullable()
|
|
28
38
|
.describe("Direction relative to the viewed task; null for a symmetric relation."),
|
|
29
|
-
task: taskSchema.pick({
|
|
39
|
+
task: taskSchema.pick({
|
|
40
|
+
id: true,
|
|
41
|
+
key: true,
|
|
42
|
+
project_id: true,
|
|
43
|
+
column: true,
|
|
44
|
+
column_id: true,
|
|
45
|
+
title: true,
|
|
46
|
+
status: true,
|
|
47
|
+
}),
|
|
30
48
|
});
|
|
31
49
|
export const relationChangeSchema = z.strictObject({
|
|
50
|
+
id: z.string().describe("Stored ID of the created or deleted relation."),
|
|
32
51
|
type: relationSchema.shape.type,
|
|
33
52
|
source: z.string().describe("Source task key, in the supplied direction."),
|
|
53
|
+
source_task_id: z.string().describe("Task ID matching source, in the supplied direction."),
|
|
34
54
|
target: z.string().describe("Target task key, in the supplied direction."),
|
|
55
|
+
target_task_id: z.string().describe("Task ID matching target, in the supplied direction."),
|
|
35
56
|
});
|
|
36
57
|
export const commentSchema = z.strictObject({
|
|
58
|
+
id: z.string().describe("Stored comment ID."),
|
|
37
59
|
key: z.string().describe("Readable task key and comment number."),
|
|
60
|
+
task_id: z.string().describe("Owning task ID."),
|
|
38
61
|
text: z.string(),
|
|
39
62
|
created_at: timestamp,
|
|
40
63
|
updated_at: timestamp,
|
|
@@ -65,6 +88,17 @@ export const activitySchema = z.strictObject({
|
|
|
65
88
|
.nullable()
|
|
66
89
|
.describe("Raw recorded JSON object, including unknown fields; null when no payload was recorded."),
|
|
67
90
|
});
|
|
91
|
+
export const actorSchema = activitySchema.pick({
|
|
92
|
+
actor_name: true,
|
|
93
|
+
actor_email: true,
|
|
94
|
+
actor_kind: true,
|
|
95
|
+
actor_source: true,
|
|
96
|
+
actor_session_id: true,
|
|
97
|
+
actor_thread_id: true,
|
|
98
|
+
actor_agent: true,
|
|
99
|
+
actor_model: true,
|
|
100
|
+
actor_effort: true,
|
|
101
|
+
});
|
|
68
102
|
export const taskDetailSchema = taskSchema.extend({
|
|
69
103
|
relations: z.array(relationSchema),
|
|
70
104
|
comments: z.array(commentSchema),
|
|
@@ -78,23 +112,52 @@ export const taskChangeSchema = taskSchema.extend({
|
|
|
78
112
|
changed: z.boolean().describe("Whether this key occurrence changed the task's state."),
|
|
79
113
|
});
|
|
80
114
|
export const projectSchema = z.strictObject({
|
|
115
|
+
id: z.string().describe("Stored project ID."),
|
|
81
116
|
key: z.string(),
|
|
82
117
|
name: z.string(),
|
|
83
118
|
description: nullableText,
|
|
84
119
|
});
|
|
85
|
-
export const
|
|
86
|
-
|
|
120
|
+
export const projectChangeSchema = projectSchema.extend({
|
|
121
|
+
changed: z.boolean().describe("Whether the project's fields changed."),
|
|
122
|
+
});
|
|
123
|
+
export const projectListEntrySchema = projectSchema.extend({
|
|
124
|
+
taskCounts: z.strictObject({
|
|
125
|
+
active: count.describe("Unarchived tasks in any column."),
|
|
126
|
+
archived: count.describe("Archived tasks."),
|
|
127
|
+
}),
|
|
128
|
+
});
|
|
129
|
+
export const columnSchema = z.strictObject({
|
|
130
|
+
id: z.string().describe("Stored column ID."),
|
|
131
|
+
project: z.string(),
|
|
132
|
+
project_id: z.string().describe("Owning project ID."),
|
|
133
|
+
name: z.string(),
|
|
134
|
+
});
|
|
135
|
+
export const columnChangeSchema = columnSchema.extend({
|
|
136
|
+
changed: z.boolean().describe("Whether the column's name or position changed."),
|
|
137
|
+
});
|
|
138
|
+
export const columnTaskCountSchema = z.strictObject({
|
|
139
|
+
id: columnSchema.shape.id,
|
|
140
|
+
name: z.string(),
|
|
141
|
+
taskCount: count,
|
|
142
|
+
});
|
|
87
143
|
export const projectViewSchema = projectSchema.extend({
|
|
88
144
|
columns: z.array(columnTaskCountSchema),
|
|
89
145
|
archivedTaskCount: count,
|
|
90
146
|
});
|
|
91
147
|
export const labelSchema = z.strictObject({
|
|
148
|
+
id: z.string().describe("Stored label ID."),
|
|
92
149
|
name: z.string(),
|
|
93
150
|
color: z
|
|
94
151
|
.string()
|
|
95
152
|
.describe(`Known label colors: ${labelColorSchema.options.join(", ")}. Other stored values may occur.`),
|
|
96
153
|
description: nullableText,
|
|
97
154
|
});
|
|
155
|
+
export const labelChangeSchema = labelSchema.extend({
|
|
156
|
+
changed: z.boolean().describe("Whether the label's fields changed."),
|
|
157
|
+
});
|
|
158
|
+
export const commentChangeSchema = commentSchema.extend({
|
|
159
|
+
changed: z.boolean().describe("Whether the comment's text changed."),
|
|
160
|
+
});
|
|
98
161
|
const settingsFileBase = z.strictObject({
|
|
99
162
|
path: z.string(),
|
|
100
163
|
source: settingsFileSourceSchema,
|
|
@@ -164,17 +227,22 @@ export const resultSchemas = {
|
|
|
164
227
|
RelationList: z.array(relationSchema),
|
|
165
228
|
RelationChange: relationChangeSchema,
|
|
166
229
|
Comment: commentSchema,
|
|
230
|
+
CommentChange: commentChangeSchema,
|
|
167
231
|
CommentList: z.array(commentSchema),
|
|
168
232
|
Project: projectSchema,
|
|
169
|
-
|
|
233
|
+
ProjectChange: projectChangeSchema,
|
|
234
|
+
ProjectList: z.array(projectListEntrySchema),
|
|
170
235
|
ProjectView: projectViewSchema,
|
|
171
236
|
Column: columnSchema,
|
|
237
|
+
ColumnChange: columnChangeSchema,
|
|
172
238
|
ColumnTaskCount: columnTaskCountSchema,
|
|
173
239
|
ColumnList: z.array(columnTaskCountSchema),
|
|
174
240
|
Label: labelSchema,
|
|
241
|
+
LabelChange: labelChangeSchema,
|
|
175
242
|
LabelList: z.array(labelSchema),
|
|
176
243
|
Activity: activitySchema,
|
|
177
244
|
ActivityList: z.array(activitySchema),
|
|
245
|
+
Actor: actorSchema,
|
|
178
246
|
Info: infoSchema,
|
|
179
247
|
Backup: backupSchema,
|
|
180
248
|
Restore: restoreSchema,
|
package/src/results.d.ts
CHANGED
|
@@ -1,22 +1,39 @@
|
|
|
1
1
|
import type { ResultSchemaName } from "./result-schemas.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
export declare const resultSelectorSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
4
|
+
kind: z.ZodLiteral<"always">;
|
|
5
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
6
|
+
kind: z.ZodLiteral<"booleanOption">;
|
|
7
|
+
name: z.ZodString;
|
|
8
|
+
value: z.ZodBoolean;
|
|
9
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
10
|
+
kind: z.ZodLiteral<"positionalCount">;
|
|
11
|
+
name: z.ZodString;
|
|
12
|
+
min: z.ZodNumber;
|
|
13
|
+
max: z.ZodNullable<z.ZodNumber>;
|
|
14
|
+
}, z.core.$strict>], "kind">;
|
|
15
|
+
export declare const resultReferenceSchema: z.ZodString;
|
|
16
|
+
export declare const commandResultSchema: z.ZodObject<{
|
|
17
|
+
selector: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
18
|
+
kind: z.ZodLiteral<"always">;
|
|
19
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
20
|
+
kind: z.ZodLiteral<"booleanOption">;
|
|
21
|
+
name: z.ZodString;
|
|
22
|
+
value: z.ZodBoolean;
|
|
23
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
24
|
+
kind: z.ZodLiteral<"positionalCount">;
|
|
25
|
+
name: z.ZodString;
|
|
26
|
+
min: z.ZodNumber;
|
|
27
|
+
max: z.ZodNullable<z.ZodNumber>;
|
|
28
|
+
}, z.core.$strict>], "kind">;
|
|
29
|
+
schemaRef: z.ZodString;
|
|
30
|
+
mode: z.ZodLiteral<"json">;
|
|
31
|
+
stream: z.ZodLiteral<"stdout">;
|
|
32
|
+
exitCode: z.ZodLiteral<0>;
|
|
33
|
+
}, z.core.$strict>;
|
|
34
|
+
export type ResultSelector = z.infer<typeof resultSelectorSchema>;
|
|
35
|
+
export type CommandResult = z.infer<typeof commandResultSchema> & {
|
|
16
36
|
schemaRef: `#/schemas/definitions/${ResultSchemaName}`;
|
|
17
|
-
mode: "json";
|
|
18
|
-
stream: "stdout";
|
|
19
|
-
exitCode: 0;
|
|
20
37
|
};
|
|
21
38
|
export declare function jsonResult(schema: ResultSchemaName, selector?: ResultSelector): CommandResult;
|
|
22
39
|
export declare const taskDetailResults: CommandResult[];
|
package/src/results.js
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const resultSelectorSchema = z.discriminatedUnion("kind", [
|
|
3
|
+
z.strictObject({ kind: z.literal("always") }),
|
|
4
|
+
z.strictObject({ kind: z.literal("booleanOption"), name: z.string(), value: z.boolean() }),
|
|
5
|
+
z.strictObject({
|
|
6
|
+
kind: z.literal("positionalCount"),
|
|
7
|
+
name: z.string(),
|
|
8
|
+
min: z.number().int().nonnegative(),
|
|
9
|
+
max: z.number().int().nonnegative().nullable(),
|
|
10
|
+
}),
|
|
11
|
+
]);
|
|
12
|
+
export const resultReferenceSchema = z.string().regex(/^#\/schemas\/definitions\/[^/]+$/);
|
|
13
|
+
export const commandResultSchema = z.strictObject({
|
|
14
|
+
selector: resultSelectorSchema,
|
|
15
|
+
schemaRef: resultReferenceSchema,
|
|
16
|
+
mode: z.literal("json"),
|
|
17
|
+
stream: z.literal("stdout"),
|
|
18
|
+
exitCode: z.literal(0),
|
|
19
|
+
});
|
|
1
20
|
export function jsonResult(schema, selector = { kind: "always" }) {
|
|
2
21
|
return {
|
|
3
22
|
selector,
|
|
@@ -10,6 +10,21 @@ export declare const activityRouter: {
|
|
|
10
10
|
};
|
|
11
11
|
input: {
|
|
12
12
|
readonly options: {
|
|
13
|
+
readonly project: {
|
|
14
|
+
readonly type: "string";
|
|
15
|
+
readonly value: {
|
|
16
|
+
readonly kind: "project-key";
|
|
17
|
+
readonly name: "project-key";
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
readonly "project-id": {
|
|
21
|
+
readonly type: "string";
|
|
22
|
+
readonly value: {
|
|
23
|
+
readonly kind: "project-id";
|
|
24
|
+
readonly name: "project-id";
|
|
25
|
+
readonly description: "Full project UUID; canonical or compact, case-insensitive";
|
|
26
|
+
};
|
|
27
|
+
};
|
|
13
28
|
readonly task: {
|
|
14
29
|
readonly type: "string";
|
|
15
30
|
readonly value: {
|
|
@@ -17,6 +32,17 @@ export declare const activityRouter: {
|
|
|
17
32
|
readonly name: "task-key";
|
|
18
33
|
};
|
|
19
34
|
};
|
|
35
|
+
readonly "task-id": {
|
|
36
|
+
readonly type: "string";
|
|
37
|
+
readonly value: {
|
|
38
|
+
readonly kind: "task-id";
|
|
39
|
+
readonly name: "task-id";
|
|
40
|
+
readonly description: "Full task UUID; canonical or compact, case-insensitive";
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
readonly "show-deleted": {
|
|
44
|
+
readonly type: "boolean";
|
|
45
|
+
};
|
|
20
46
|
readonly session: {
|
|
21
47
|
readonly type: "string";
|
|
22
48
|
readonly value: {
|
|
@@ -31,12 +57,55 @@ export declare const activityRouter: {
|
|
|
31
57
|
readonly name: "id";
|
|
32
58
|
};
|
|
33
59
|
};
|
|
60
|
+
readonly since: {
|
|
61
|
+
readonly type: "string";
|
|
62
|
+
readonly value: {
|
|
63
|
+
readonly kind: "timestamp";
|
|
64
|
+
readonly name: "time";
|
|
65
|
+
readonly description: "Inclusive lower bound. Integer epoch milliseconds or YYYY-MM-DDTHH:mm:ss with Z or a numeric offset. Optional fractional seconds have 1 to 3 digits.";
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
readonly until: {
|
|
69
|
+
readonly type: "string";
|
|
70
|
+
readonly value: {
|
|
71
|
+
readonly kind: "timestamp";
|
|
72
|
+
readonly name: "time";
|
|
73
|
+
readonly description: "Inclusive upper bound in the same formats as --since. Must be at or after --since.";
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
readonly action: {
|
|
77
|
+
readonly type: "string";
|
|
78
|
+
readonly multiple: true;
|
|
79
|
+
readonly value: {
|
|
80
|
+
readonly kind: "activity-action";
|
|
81
|
+
readonly name: "action";
|
|
82
|
+
readonly choices: ("create" | "delete" | "archive" | "edit" | "move" | "order" | "unarchive" | "relation_create" | "relation_delete" | "comment_create" | "comment_edit" | "comment_delete")[];
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
readonly changed: {
|
|
86
|
+
readonly type: "string";
|
|
87
|
+
readonly multiple: true;
|
|
88
|
+
readonly value: {
|
|
89
|
+
readonly kind: "activity-change";
|
|
90
|
+
readonly name: "field[=value]";
|
|
91
|
+
readonly pattern: `^((${string})|(${string})=.+)$`;
|
|
92
|
+
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
|
+
};
|
|
94
|
+
};
|
|
34
95
|
readonly limit: {
|
|
35
96
|
readonly type: "string";
|
|
36
97
|
readonly value: {
|
|
37
98
|
readonly kind: "positive-integer";
|
|
38
99
|
readonly name: "n";
|
|
39
|
-
readonly pattern:
|
|
100
|
+
readonly pattern: string;
|
|
101
|
+
};
|
|
102
|
+
readonly description: "Return at most n results after all filters. Use an integer from 1 through 11871.";
|
|
103
|
+
};
|
|
104
|
+
readonly "starting-after": {
|
|
105
|
+
readonly type: "string";
|
|
106
|
+
readonly value: {
|
|
107
|
+
readonly kind: "activity-id";
|
|
108
|
+
readonly name: "id";
|
|
40
109
|
};
|
|
41
110
|
};
|
|
42
111
|
};
|
|
@@ -44,7 +113,15 @@ export declare const activityRouter: {
|
|
|
44
113
|
readonly id: "default";
|
|
45
114
|
readonly positionals: readonly [];
|
|
46
115
|
}];
|
|
47
|
-
readonly constraints: readonly [
|
|
116
|
+
readonly constraints: readonly [{
|
|
117
|
+
readonly kind: "exclusive";
|
|
118
|
+
readonly members: readonly ["option:project", "option:project-id", "option:task", "option:task-id"];
|
|
119
|
+
}, {
|
|
120
|
+
readonly kind: "requiresAny";
|
|
121
|
+
readonly input: "option:show-deleted";
|
|
122
|
+
readonly members: readonly ["option:project", "option:task"];
|
|
123
|
+
}];
|
|
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."];
|
|
48
125
|
};
|
|
49
126
|
results: import("../results.js").CommandResult[];
|
|
50
127
|
run: (args: string[]) => void;
|
|
@@ -1,22 +1,87 @@
|
|
|
1
|
+
import { listLimitOption, listLimitDescription, parseListLimit } from "../list-limit.js";
|
|
1
2
|
import { jsonResult } from "../results.js";
|
|
2
3
|
import { parseArgs } from "node:util";
|
|
3
|
-
import { activity,
|
|
4
|
-
import { generateCommandUsage } from "../input.js";
|
|
5
|
-
import {
|
|
4
|
+
import { activity, activityActionSchema, activityChangedFieldSchema, activityChangedSchema, CoreError, } from "@zinn-dev/core";
|
|
5
|
+
import { generateCommandUsage, getOptionInputs, violatesConstraint } from "../input.js";
|
|
6
|
+
import { CliError } from "../errors.js";
|
|
7
|
+
import { parseTimestampInput } from "../timestamp-input.js";
|
|
8
|
+
import { formatListContinuation } from "../list-continuation.js";
|
|
9
|
+
import { diagnostic, output, quit, validatePositionals, validateUniqueOptions } from "../lib.js";
|
|
6
10
|
import { formatActivityList, presentActivities } from "../presentation/activity-presentation.js";
|
|
11
|
+
const changedFieldList = activityChangedFieldSchema.options.join(", ");
|
|
7
12
|
const activityInputs = {
|
|
8
13
|
list: {
|
|
9
14
|
options: {
|
|
15
|
+
project: { type: "string", value: { kind: "project-key", name: "project-key" } },
|
|
16
|
+
"project-id": {
|
|
17
|
+
type: "string",
|
|
18
|
+
value: {
|
|
19
|
+
kind: "project-id",
|
|
20
|
+
name: "project-id",
|
|
21
|
+
description: "Full project UUID; canonical or compact, case-insensitive",
|
|
22
|
+
},
|
|
23
|
+
},
|
|
10
24
|
task: { type: "string", value: { kind: "task-key", name: "task-key" } },
|
|
25
|
+
"task-id": {
|
|
26
|
+
type: "string",
|
|
27
|
+
value: {
|
|
28
|
+
kind: "task-id",
|
|
29
|
+
name: "task-id",
|
|
30
|
+
description: "Full task UUID; canonical or compact, case-insensitive",
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
"show-deleted": { type: "boolean" },
|
|
11
34
|
session: { type: "string", value: { kind: "text", name: "id" } },
|
|
12
35
|
thread: { type: "string", value: { kind: "text", name: "id" } },
|
|
13
|
-
|
|
36
|
+
since: {
|
|
14
37
|
type: "string",
|
|
15
|
-
value: {
|
|
38
|
+
value: {
|
|
39
|
+
kind: "timestamp",
|
|
40
|
+
name: "time",
|
|
41
|
+
description: "Inclusive lower bound. Integer epoch milliseconds or YYYY-MM-DDTHH:mm:ss with Z or a numeric offset. Optional fractional seconds have 1 to 3 digits.",
|
|
42
|
+
},
|
|
16
43
|
},
|
|
44
|
+
until: {
|
|
45
|
+
type: "string",
|
|
46
|
+
value: {
|
|
47
|
+
kind: "timestamp",
|
|
48
|
+
name: "time",
|
|
49
|
+
description: "Inclusive upper bound in the same formats as --since. Must be at or after --since.",
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
action: {
|
|
53
|
+
type: "string",
|
|
54
|
+
multiple: true,
|
|
55
|
+
value: { kind: "activity-action", name: "action", choices: activityActionSchema.options },
|
|
56
|
+
},
|
|
57
|
+
changed: {
|
|
58
|
+
type: "string",
|
|
59
|
+
multiple: true,
|
|
60
|
+
value: {
|
|
61
|
+
kind: "activity-change",
|
|
62
|
+
name: "field[=value]",
|
|
63
|
+
pattern: `^((${activityChangedFieldSchema.options.join("|")})|(${activityChangedFieldSchema.exclude(["title", "description"]).options.join("|")})=.+)$`,
|
|
64
|
+
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
|
+
},
|
|
66
|
+
},
|
|
67
|
+
limit: listLimitOption,
|
|
68
|
+
"starting-after": { type: "string", value: { kind: "activity-id", name: "id" } },
|
|
17
69
|
},
|
|
18
70
|
forms: [{ id: "default", positionals: [] }],
|
|
19
|
-
constraints: [
|
|
71
|
+
constraints: [
|
|
72
|
+
{
|
|
73
|
+
kind: "exclusive",
|
|
74
|
+
members: ["option:project", "option:project-id", "option:task", "option:task-id"],
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
kind: "requiresAny",
|
|
78
|
+
input: "option:show-deleted",
|
|
79
|
+
members: ["option:project", "option:task"],
|
|
80
|
+
},
|
|
81
|
+
],
|
|
82
|
+
notes: [
|
|
83
|
+
"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
|
+
],
|
|
20
85
|
},
|
|
21
86
|
view: {
|
|
22
87
|
options: {},
|
|
@@ -46,42 +111,137 @@ export const activityRouter = {
|
|
|
46
111
|
});
|
|
47
112
|
validateUniqueOptions(tokens, activityInputs.list.options);
|
|
48
113
|
validatePositionals(positionals, activityInputs.list.forms[0]);
|
|
49
|
-
|
|
50
|
-
const
|
|
51
|
-
if (
|
|
52
|
-
|
|
114
|
+
const [selectorConstraint, deletedHistoryConstraint] = activityInputs.list.constraints;
|
|
115
|
+
const optionInputs = getOptionInputs(values);
|
|
116
|
+
if (violatesConstraint(selectorConstraint, optionInputs)) {
|
|
117
|
+
const conflictingSelector = selectorConstraint.members.filter((member) => optionInputs[member] !== undefined)[1];
|
|
118
|
+
quit("Use one of --project, --project-id, --task or --task-id", undefined, {
|
|
119
|
+
argument: conflictingSelector.replace("option:", "--"),
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
if (violatesConstraint(deletedHistoryConstraint, optionInputs)) {
|
|
123
|
+
quit("--show-deleted requires --project or --task", undefined, {
|
|
124
|
+
argument: "--show-deleted",
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
const limit = parseListLimit(values.limit);
|
|
128
|
+
let page;
|
|
129
|
+
try {
|
|
130
|
+
page = activity.getAll({
|
|
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
|
+
});
|
|
163
|
+
}
|
|
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;
|
|
53
179
|
}
|
|
54
|
-
|
|
180
|
+
output(page.events, (items) => formatActivityList(presentActivities(items, {
|
|
181
|
+
projectKey: values.project,
|
|
182
|
+
projectId: values["project-id"],
|
|
183
|
+
showDeleted: values["show-deleted"],
|
|
55
184
|
taskKey: values.task,
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
185
|
+
taskId: values["task-id"],
|
|
186
|
+
})));
|
|
187
|
+
if (page.hasMore) {
|
|
188
|
+
diagnostic(`More activity. Continue with: ${formatListContinuation(["activity", "list"], [], tokens, "starting-after", page.events.at(-1).id)}`);
|
|
189
|
+
}
|
|
61
190
|
},
|
|
62
191
|
help: `${generateCommandUsage("activity list", activityInputs.list)}
|
|
63
192
|
|
|
64
193
|
List recorded activity across the database, newest first.
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
194
|
+
Returns all matching events unless --limit is supplied.
|
|
195
|
+
|
|
196
|
+
--task <key> Select an existing active or archived task.
|
|
197
|
+
--project <key> Select an existing project's activity, including deleted tasks.
|
|
198
|
+
--project-id <uuid> Select one project identity, including deleted projects.
|
|
199
|
+
Requires a full UUID.
|
|
200
|
+
--show-deleted Also include deleted identities sharing the selected key.
|
|
201
|
+
--task-id <uuid> Select one task identity, including deleted tasks.
|
|
202
|
+
Requires a full UUID.
|
|
203
|
+
--session <id> Match an exact session ID, including case.
|
|
204
|
+
--thread <id> Match an exact thread ID, including case.
|
|
205
|
+
--since <time> Include events at or after this time.
|
|
206
|
+
--until <time> Include events at or before this time.
|
|
207
|
+
--action <action> Match a recorded action. Repeat to match any listed action.
|
|
208
|
+
--changed <field>[=<value>] Match a task field change, with an optional value.
|
|
209
|
+
Fields: ${changedFieldList}.
|
|
210
|
+
Values apply to column, priority and added labels, ignoring case.
|
|
211
|
+
Without a value, labels match additions and removals.
|
|
212
|
+
Title and description match any change, without a value.
|
|
213
|
+
Use priority=none for an unassigned priority.
|
|
214
|
+
--limit <n> ${listLimitDescription}
|
|
215
|
+
--starting-after <id> Continue with older events after this activity ID.
|
|
216
|
+
|
|
217
|
+
Continuation accepts the same IDs as activity view. The cursor event need not
|
|
218
|
+
match the filters. Omit --limit to return every remaining match.
|
|
219
|
+
When more matches exist, stderr gives the command to continue, including with --json.
|
|
220
|
+
|
|
221
|
+
Use one of --project, --project-id, --task or --task-id.
|
|
222
|
+
--show-deleted requires --project or --task.
|
|
223
|
+
Repeated --action flags match any listed action.
|
|
224
|
+
Repeated --changed filters for one field match any of them.
|
|
225
|
+
Different fields must match the same event. All other filters must also match.
|
|
226
|
+
Initial task values also match. Column and label names match as recorded.
|
|
227
|
+
|
|
228
|
+
Times accept integer epoch milliseconds or YYYY-MM-DDTHH:mm:ss with Z or a
|
|
229
|
+
numeric offset such as +01:00. Optional fractional seconds have 1 to 3 digits.
|
|
230
|
+
Both bounds are inclusive. --until must be at or after --since.
|
|
72
231
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
Use activity view for full recorded changes; full IDs are durable, short prefixes may become ambiguous.
|
|
76
|
-
With --json, output is an array of full activity records, with parsed changes or null.
|
|
77
|
-
Group JSON records by entity_type and entity_id to distinguish tasks sharing a readable key.
|
|
78
|
-
id identifies the activity event.
|
|
79
|
-
A project deletion event's entity_id is the project ID and removed task IDs are in changes.tasks.
|
|
232
|
+
Use activity view <activity-id> for complete recorded changes.
|
|
233
|
+
With --json, return an array of full activity records.
|
|
80
234
|
|
|
81
235
|
Examples:
|
|
82
236
|
zinn activity list --limit 10
|
|
83
|
-
zinn activity list --
|
|
84
|
-
zinn activity list --
|
|
237
|
+
zinn activity list --project APP
|
|
238
|
+
zinn activity list --since 2026-10-25T00:00:00Z --until 2026-10-25T12:00:00Z
|
|
239
|
+
zinn activity list --action comment_create --action comment_edit
|
|
240
|
+
zinn activity list --action edit --changed description
|
|
241
|
+
zinn activity list --changed column=Review
|
|
242
|
+
zinn activity list --changed priority=high --changed labels=bug
|
|
243
|
+
zinn activity list --task APP-2
|
|
244
|
+
zinn activity list --task APP-2 --show-deleted`,
|
|
85
245
|
},
|
|
86
246
|
view: {
|
|
87
247
|
summary: "Show one recorded event with full activity/entity IDs, actor and complete changes.",
|
|
@@ -105,15 +265,26 @@ Examples:
|
|
|
105
265
|
help: `${generateCommandUsage("activity view", activityInputs.view)}
|
|
106
266
|
|
|
107
267
|
Show one recorded event with full activity/entity IDs, actor and complete changes.
|
|
108
|
-
|
|
109
|
-
Text times are local dates/times with a UTC offset.
|
|
268
|
+
Recorded text and line breaks are preserved.
|
|
110
269
|
|
|
111
270
|
Accept a full UUID or unique left prefix with at least eight hexadecimal digits.
|
|
112
|
-
|
|
113
|
-
An ambiguous prefix lists candidate IDs and requires more characters.
|
|
114
|
-
With --json, output is one full activity record, with parsed changes or null.
|
|
115
|
-
id identifies this event itself, while entity_type and entity_id identify its affected entity.
|
|
271
|
+
With --json, return one full activity record.
|
|
116
272
|
|
|
117
273
|
Example: zinn activity view 019abcdf-1234-7`,
|
|
118
274
|
},
|
|
119
275
|
};
|
|
276
|
+
function parseChangedFilter(input) {
|
|
277
|
+
const separator = input.indexOf("=");
|
|
278
|
+
const field = separator === -1 ? input : input.slice(0, separator);
|
|
279
|
+
const value = input.slice(separator + 1);
|
|
280
|
+
const filter = activityChangedSchema.safeParse(separator === -1
|
|
281
|
+
? { field }
|
|
282
|
+
: {
|
|
283
|
+
field,
|
|
284
|
+
value: field === "priority" && value.toLowerCase() === "none" ? null : value,
|
|
285
|
+
});
|
|
286
|
+
if (!filter.success) {
|
|
287
|
+
quit(filter.error.issues[0].message, undefined, { argument: "--changed" });
|
|
288
|
+
}
|
|
289
|
+
return filter.data;
|
|
290
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const commandAliases = {
|
|
2
|
+
view: ["show"],
|
|
3
|
+
list: ["ls"],
|
|
4
|
+
delete: ["rm"],
|
|
5
|
+
create: ["new"],
|
|
6
|
+
};
|
|
7
|
+
export function getCommandAliases(command) {
|
|
8
|
+
const words = command.split(" ");
|
|
9
|
+
const name = words.pop();
|
|
10
|
+
return (commandAliases[name] ?? []).map((alias) => [...words, alias]);
|
|
11
|
+
}
|