@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/overview.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export const overview = [
|
|
2
|
+
{
|
|
3
|
+
summary: "Set deadlines and sort or filter by them",
|
|
4
|
+
uses: [
|
|
5
|
+
{ command: "task create", flags: ["--due"] },
|
|
6
|
+
{ command: "task edit", flags: ["--due"] },
|
|
7
|
+
{ command: "task list", flags: ["--sort due", "--due-since", "--due-until"] },
|
|
8
|
+
],
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
summary: "Change several tasks in one command",
|
|
12
|
+
uses: [{ command: "task move" }, { command: "task archive" }, { command: "task delete" }],
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
summary: "Read text from a file or stdin",
|
|
16
|
+
uses: [
|
|
17
|
+
{ command: "task create", flags: ["--description-file"] },
|
|
18
|
+
{ command: "task comment create", flags: ["--text-file"] },
|
|
19
|
+
],
|
|
20
|
+
},
|
|
21
|
+
{ summary: "Search titles, descriptions and comments", uses: [{ command: "task search" }] },
|
|
22
|
+
{
|
|
23
|
+
summary: "Continue a long list",
|
|
24
|
+
uses: [
|
|
25
|
+
{ command: "task list", flags: ["--limit", "--starting-after"] },
|
|
26
|
+
{ command: "activity list", flags: ["--limit", "--starting-after"] },
|
|
27
|
+
],
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
summary: "See the agent and session behind each change",
|
|
31
|
+
uses: [{ command: "activity list" }, { command: "activity view" }],
|
|
32
|
+
},
|
|
33
|
+
];
|
|
34
|
+
export function formatOverview() {
|
|
35
|
+
return overview
|
|
36
|
+
.map(({ summary, uses }) => {
|
|
37
|
+
const named = uses.map(({ command, flags = [] }) => [command, ...flags].join(" "));
|
|
38
|
+
return ` ${summary}: ${named.join(", ")}`;
|
|
39
|
+
})
|
|
40
|
+
.join("\n");
|
|
41
|
+
}
|
|
@@ -22,9 +22,13 @@ export declare function presentActivities(events: Array<Activity>, options?: {
|
|
|
22
22
|
taskKey?: string;
|
|
23
23
|
taskId?: string;
|
|
24
24
|
showsFullIds?: boolean;
|
|
25
|
+
/** Only deletions among the events mark a reused key, as in one current task's history */
|
|
26
|
+
keysFromEventsOnly?: boolean;
|
|
25
27
|
}): Array<PresentedActivity>;
|
|
26
28
|
export declare function presentActor(actor: Actor): PresentedActor;
|
|
27
29
|
export declare function formatActor(actor: PresentedActor): string;
|
|
30
|
+
/** An actor's name and kind, as activity rows show who acted */
|
|
31
|
+
export declare function formatActorLabel(actor: Pick<PresentedActor, "actor_name" | "actor_kind">): string;
|
|
28
32
|
export declare function formatActivityList(entries: Array<PresentedActivity>, options?: {
|
|
29
33
|
showsDetails?: boolean;
|
|
30
34
|
}): string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { activity, activityTaskKeySchema, column, label, minimumActivityIdLength, project, task, timestampSchema, } from "@zinn-dev/core";
|
|
1
|
+
import { activity, activityTaskIdSchema, activityTaskKeySchema, column, label, minimumActivityIdLength, project, task, timestampSchema, } from "@zinn-dev/core";
|
|
2
2
|
import { formatDescriptionPreview } from "./description-presentation.js";
|
|
3
3
|
import { formatRows } from "./row-layout.js";
|
|
4
4
|
import { formatSection } from "./section.js";
|
|
@@ -24,7 +24,24 @@ const RECORDED_FIELDS = new Set([
|
|
|
24
24
|
"target",
|
|
25
25
|
"comment",
|
|
26
26
|
"text",
|
|
27
|
+
"lease_ms",
|
|
28
|
+
"replaced",
|
|
29
|
+
"previous_expires_at",
|
|
30
|
+
"claimed_at",
|
|
31
|
+
"expires_at",
|
|
32
|
+
"cause",
|
|
27
33
|
]);
|
|
34
|
+
const CLAIM_ACTIONS = new Set(["claim", "claim_take", "claim_heartbeat", "claim_release"]);
|
|
35
|
+
// A released claim records its holder as actor fields, which summaries show as one holder.
|
|
36
|
+
const CLAIM_HOLDER_FIELDS = new Set([
|
|
37
|
+
"actor_kind",
|
|
38
|
+
"actor_name",
|
|
39
|
+
"actor_session_id",
|
|
40
|
+
"actor_thread_id",
|
|
41
|
+
]);
|
|
42
|
+
const RECORDED_TIME_FIELDS = new Set(["due_at", "previous_expires_at", "claimed_at", "expires_at"]);
|
|
43
|
+
// Summaries leave out a released claim's own times, which activity view shows.
|
|
44
|
+
const CLAIM_SPAN_FIELDS = new Set(["claimed_at", "expires_at"]);
|
|
28
45
|
const ENTITY_PREVIEW_LENGTH = 24;
|
|
29
46
|
const UNKNOWN_ACTOR_NAME = "unknown";
|
|
30
47
|
const ACTOR_DETAIL_FIELDS = [
|
|
@@ -36,6 +53,7 @@ const ACTOR_DETAIL_FIELDS = [
|
|
|
36
53
|
{ key: "actor_agent", label: "Agent" },
|
|
37
54
|
{ key: "actor_model", label: "Model" },
|
|
38
55
|
{ key: "actor_effort", label: "Effort" },
|
|
56
|
+
{ key: "actor_client", label: "Client" },
|
|
39
57
|
];
|
|
40
58
|
const ACTION_LABELS = {
|
|
41
59
|
create: "created",
|
|
@@ -50,6 +68,10 @@ const ACTION_LABELS = {
|
|
|
50
68
|
comment_create: "added comment",
|
|
51
69
|
comment_edit: "edited comment",
|
|
52
70
|
comment_delete: "deleted comment",
|
|
71
|
+
claim: "claimed",
|
|
72
|
+
claim_take: "took over claim",
|
|
73
|
+
claim_heartbeat: "renewed claim",
|
|
74
|
+
claim_release: "released claim",
|
|
53
75
|
};
|
|
54
76
|
function isRecord(value) {
|
|
55
77
|
return value != null && typeof value === "object" && !Array.isArray(value);
|
|
@@ -87,21 +109,23 @@ export function abbreviateActivityIds(ids) {
|
|
|
87
109
|
}
|
|
88
110
|
return prefixes;
|
|
89
111
|
}
|
|
90
|
-
function getTaskNavigation(
|
|
112
|
+
function getTaskNavigation(pageEvents, { navigationEvents, taskKey, taskId, }) {
|
|
91
113
|
if (taskId !== undefined) {
|
|
92
114
|
return activity.getTaskIdentities({ taskId });
|
|
93
115
|
}
|
|
94
116
|
if (taskKey !== undefined) {
|
|
95
117
|
return activity.getTaskIdentities({ taskKey, showDeleted: true });
|
|
96
118
|
}
|
|
97
|
-
|
|
119
|
+
// A project selection counts only keys its own deletions recorded. Other pages check every key.
|
|
120
|
+
const selectionKeys = navigationEvents === undefined ? undefined : new Set();
|
|
121
|
+
const deletionEvents = navigationEvents ?? pageEvents;
|
|
98
122
|
function addKey(key) {
|
|
99
123
|
const parsed = activityTaskKeySchema.safeParse(key);
|
|
100
124
|
if (parsed.success) {
|
|
101
|
-
|
|
125
|
+
selectionKeys?.add(parsed.data);
|
|
102
126
|
}
|
|
103
127
|
}
|
|
104
|
-
for (const event of
|
|
128
|
+
for (const event of navigationEvents ?? []) {
|
|
105
129
|
if (event.action !== "delete") {
|
|
106
130
|
continue;
|
|
107
131
|
}
|
|
@@ -116,48 +140,98 @@ function getTaskNavigation(events, taskKey, taskId) {
|
|
|
116
140
|
}
|
|
117
141
|
}
|
|
118
142
|
}
|
|
119
|
-
const
|
|
120
|
-
const needsTaskIdentities =
|
|
121
|
-
if (needsTaskIdentities) {
|
|
122
|
-
|
|
123
|
-
identities.set(item.id, {
|
|
124
|
-
id: item.id,
|
|
125
|
-
key: item.key,
|
|
126
|
-
title: item.title,
|
|
127
|
-
status: item.archived_at == null ? "active" : "archived",
|
|
128
|
-
});
|
|
129
|
-
}
|
|
143
|
+
const isHistoricalKey = (key) => selectionKeys?.has(key) ?? true;
|
|
144
|
+
const needsTaskIdentities = (selectionKeys?.size ?? 0) > 0 || pageEvents.some((event) => event.entity_type === "task");
|
|
145
|
+
if (!needsTaskIdentities) {
|
|
146
|
+
return [];
|
|
130
147
|
}
|
|
131
|
-
|
|
148
|
+
/** A deleted task's recorded identity, when it is complete and holds a historical key. */
|
|
149
|
+
function toSnapshot(id, key, title) {
|
|
132
150
|
const parsedKey = activityTaskKeySchema.safeParse(key);
|
|
133
151
|
const isMatchingSnapshot = typeof id === "string" &&
|
|
134
152
|
typeof key === "string" &&
|
|
135
153
|
typeof title === "string" &&
|
|
136
154
|
parsedKey.success &&
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
identities.set(id, { id, key, title, status: "deleted" });
|
|
140
|
-
}
|
|
155
|
+
isHistoricalKey(parsedKey.data);
|
|
156
|
+
return isMatchingSnapshot ? [{ id, key, title, status: "deleted" }] : [];
|
|
141
157
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
158
|
+
const snapshots = deletionEvents.flatMap((event) => {
|
|
159
|
+
if (event.action !== "delete") {
|
|
160
|
+
return [];
|
|
161
|
+
}
|
|
162
|
+
if (event.entity_type === "task") {
|
|
163
|
+
return toSnapshot(event.entity_id, event.changes?.key, event.changes?.title);
|
|
164
|
+
}
|
|
165
|
+
if (event.entity_type === "project" && Array.isArray(event.changes?.tasks)) {
|
|
166
|
+
return event.changes.tasks
|
|
167
|
+
.filter(isRecord)
|
|
168
|
+
.flatMap((snapshot) => toSnapshot(snapshot.id, snapshot.key, snapshot.title));
|
|
169
|
+
}
|
|
170
|
+
return [];
|
|
171
|
+
});
|
|
172
|
+
// Current tasks the page names, removes or shares a deleted key with.
|
|
173
|
+
const referencedIds = new Set(snapshots.map((snapshot) => snapshot.id));
|
|
174
|
+
const pageTaskIds = new Set();
|
|
175
|
+
for (const event of pageEvents) {
|
|
176
|
+
if (event.entity_type === "task") {
|
|
177
|
+
referencedIds.add(event.entity_id);
|
|
178
|
+
pageTaskIds.add(event.entity_id);
|
|
179
|
+
}
|
|
180
|
+
else if (event.entity_type === "project" &&
|
|
181
|
+
event.action === "delete" &&
|
|
182
|
+
Array.isArray(event.changes?.tasks)) {
|
|
183
|
+
for (const snapshot of event.changes.tasks.filter(isRecord)) {
|
|
184
|
+
referencedIds.add(snapshot.id);
|
|
149
185
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
// Current identities come first, recorded deletions fill the gaps
|
|
189
|
+
const identities = new Map();
|
|
190
|
+
function addIdentities(items) {
|
|
191
|
+
for (const item of items) {
|
|
192
|
+
if (!identities.has(item.id)) {
|
|
193
|
+
identities.set(item.id, item);
|
|
156
194
|
}
|
|
157
195
|
}
|
|
158
196
|
}
|
|
197
|
+
function addDeletedIdentities(items) {
|
|
198
|
+
addIdentities(items.flatMap((item) => item.status === "deleted" ? toSnapshot(item.id, item.key, item.title) : []));
|
|
199
|
+
}
|
|
200
|
+
addIdentities(activity.getCurrentTaskIdentities({ taskIds: parseTaskIds(referencedIds) }));
|
|
201
|
+
addIdentities(snapshots);
|
|
202
|
+
if (selectionKeys?.size === 0) {
|
|
203
|
+
return [...identities.values()];
|
|
204
|
+
}
|
|
205
|
+
// A page task deleted outside the deletion events above can still hold a historical key.
|
|
206
|
+
addDeletedIdentities(activity.getDeletedTaskIdentities({
|
|
207
|
+
taskIds: parseTaskIds(pageTaskIds).filter((id) => !identities.has(id)),
|
|
208
|
+
}));
|
|
209
|
+
// A historical key on the page needs every identity in the database that holds it
|
|
210
|
+
const pageKeys = new Set();
|
|
211
|
+
for (const id of pageTaskIds) {
|
|
212
|
+
const parsedKey = activityTaskKeySchema.safeParse(identities.get(id)?.key);
|
|
213
|
+
if (parsedKey.success && isHistoricalKey(parsedKey.data)) {
|
|
214
|
+
pageKeys.add(parsedKey.data);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
addIdentities(activity.getCurrentTaskIdentities({ taskKeys: [...pageKeys] }));
|
|
218
|
+
// Two identities already settle that a key is shared.
|
|
219
|
+
const identityCounts = new Map();
|
|
220
|
+
for (const identity of identities.values()) {
|
|
221
|
+
identityCounts.set(identity.key, (identityCounts.get(identity.key) ?? 0) + 1);
|
|
222
|
+
}
|
|
223
|
+
addDeletedIdentities(activity.getDeletedTaskIdentities({
|
|
224
|
+
taskKeys: [...pageKeys].filter((key) => (identityCounts.get(key) ?? 0) < 2),
|
|
225
|
+
}));
|
|
159
226
|
return [...identities.values()];
|
|
160
227
|
}
|
|
228
|
+
/** The valid task IDs among the given values */
|
|
229
|
+
function parseTaskIds(values) {
|
|
230
|
+
return [...values].flatMap((value) => {
|
|
231
|
+
const parsed = activityTaskIdSchema.safeParse(value);
|
|
232
|
+
return parsed.success ? [parsed.data] : [];
|
|
233
|
+
});
|
|
234
|
+
}
|
|
161
235
|
export function presentActivities(events, options = {}) {
|
|
162
236
|
if (events.length === 0) {
|
|
163
237
|
return [];
|
|
@@ -166,14 +240,20 @@ export function presentActivities(events, options = {}) {
|
|
|
166
240
|
? new Map()
|
|
167
241
|
: abbreviateActivityIds(activity.getIds());
|
|
168
242
|
const hasProjectSelector = options.projectKey !== undefined || options.projectId !== undefined;
|
|
243
|
+
// Recorded names and deleted task keys come only from create and delete snapshots
|
|
169
244
|
const navigationEvents = hasProjectSelector
|
|
170
245
|
? activity.getAll({
|
|
171
246
|
projectKey: options.projectKey,
|
|
172
247
|
projectId: options.projectId,
|
|
173
248
|
showDeleted: options.showDeleted,
|
|
249
|
+
actions: ["create", "delete"],
|
|
174
250
|
}).events
|
|
175
251
|
: events;
|
|
176
|
-
const tasks = getTaskNavigation(
|
|
252
|
+
const tasks = getTaskNavigation(events, {
|
|
253
|
+
navigationEvents: hasProjectSelector || options.keysFromEventsOnly ? navigationEvents : undefined,
|
|
254
|
+
taskKey: options.taskKey,
|
|
255
|
+
taskId: options.taskId,
|
|
256
|
+
});
|
|
177
257
|
const tasksById = new Map(tasks.map((identity) => [identity.id, identity]));
|
|
178
258
|
const taskIdsByKey = new Map();
|
|
179
259
|
for (const identity of tasks) {
|
|
@@ -308,6 +388,28 @@ function formatDeadline(value) {
|
|
|
308
388
|
? formatLocalTime(parsed.data, { includesSeconds: true })
|
|
309
389
|
: summarizeValue(value);
|
|
310
390
|
}
|
|
391
|
+
/**
|
|
392
|
+
* Summarizes a claim action's holder, replaced claim and times.
|
|
393
|
+
* Returns `null` to leave the field out, or `undefined` for the usual summary.
|
|
394
|
+
*/
|
|
395
|
+
function summarizeClaimChange(changes, field, value) {
|
|
396
|
+
if (CLAIM_HOLDER_FIELDS.has(field)) {
|
|
397
|
+
const holder = changes;
|
|
398
|
+
return field === "actor_kind" ? `holder: ${formatActorLabel(holder)}` : null;
|
|
399
|
+
}
|
|
400
|
+
if (CLAIM_SPAN_FIELDS.has(field)) {
|
|
401
|
+
return null;
|
|
402
|
+
}
|
|
403
|
+
if (field === "replaced") {
|
|
404
|
+
return isRecord(value)
|
|
405
|
+
? `replaced: ${formatActorLabel(value)}`
|
|
406
|
+
: null;
|
|
407
|
+
}
|
|
408
|
+
if (RECORDED_TIME_FIELDS.has(field)) {
|
|
409
|
+
return `${field}: ${formatDeadline(value)}`;
|
|
410
|
+
}
|
|
411
|
+
return undefined;
|
|
412
|
+
}
|
|
311
413
|
function formatRemovedTasks(entry) {
|
|
312
414
|
return entry.removedTasks.map((identity) => `removed ${identity.key} (${identity.id})`);
|
|
313
415
|
}
|
|
@@ -323,6 +425,12 @@ function formatChangeSummary(entry, options = {}) {
|
|
|
323
425
|
if (isSnapshot && value === null) {
|
|
324
426
|
return null;
|
|
325
427
|
}
|
|
428
|
+
if (CLAIM_ACTIONS.has(event.action)) {
|
|
429
|
+
const claimSummary = summarizeClaimChange(changes, field, value);
|
|
430
|
+
if (claimSummary !== undefined) {
|
|
431
|
+
return claimSummary;
|
|
432
|
+
}
|
|
433
|
+
}
|
|
326
434
|
const repeatsIdentity = options.omitsIdentity &&
|
|
327
435
|
isSnapshot &&
|
|
328
436
|
(field === "key" || field === "name") &&
|
|
@@ -430,12 +538,14 @@ function formatRecordedChanges(event) {
|
|
|
430
538
|
}
|
|
431
539
|
const sections = [];
|
|
432
540
|
const unknownFields = {};
|
|
541
|
+
const isClaimAction = CLAIM_ACTIONS.has(event.action);
|
|
433
542
|
for (const [field, value] of Object.entries(event.changes)) {
|
|
434
|
-
|
|
543
|
+
const isRecordedField = RECORDED_FIELDS.has(field) || (isClaimAction && CLAIM_HOLDER_FIELDS.has(field));
|
|
544
|
+
if (!isRecordedField) {
|
|
435
545
|
unknownFields[field] = value;
|
|
436
546
|
continue;
|
|
437
547
|
}
|
|
438
|
-
const formatValue = field
|
|
548
|
+
const formatValue = RECORDED_TIME_FIELDS.has(field) ? formatDeadline : formatRecordedValue;
|
|
439
549
|
const body = isRecordedChangePair(event, value)
|
|
440
550
|
? `${formatSection("From", formatValue(value[0]))}\n\n${formatSection("To", formatValue(value[1]))}`
|
|
441
551
|
: formatValue(value);
|
|
@@ -457,6 +567,7 @@ export function presentActor(actor) {
|
|
|
457
567
|
actor_agent: actor.agent ?? null,
|
|
458
568
|
actor_model: actor.model ?? null,
|
|
459
569
|
actor_effort: actor.effort ?? null,
|
|
570
|
+
actor_client: actor.client ?? null,
|
|
460
571
|
};
|
|
461
572
|
}
|
|
462
573
|
export function formatActor(actor) {
|
|
@@ -465,12 +576,17 @@ export function formatActor(actor) {
|
|
|
465
576
|
...ACTOR_DETAIL_FIELDS.map(({ key, label }) => `${label}: ${actor[key] ?? "null"}`),
|
|
466
577
|
].join("\n");
|
|
467
578
|
}
|
|
579
|
+
/** An actor's name and kind, as activity rows show who acted */
|
|
580
|
+
export function formatActorLabel(actor) {
|
|
581
|
+
return `${actor.actor_name ?? UNKNOWN_ACTOR_NAME} (${actor.actor_kind})`;
|
|
582
|
+
}
|
|
468
583
|
export function formatActivityList(entries, options = {}) {
|
|
469
584
|
const rows = entries.map((entry) => {
|
|
470
585
|
const metadata = [
|
|
471
586
|
{ text: entry.displayId },
|
|
472
587
|
{ text: formatLocalTime(entry.event.created_at), style: "dim" },
|
|
473
|
-
{ text:
|
|
588
|
+
{ text: formatActorLabel(entry.event) },
|
|
589
|
+
{ text: entry.event.actor_client ?? "null" },
|
|
474
590
|
];
|
|
475
591
|
if (!options.showsDetails) {
|
|
476
592
|
return [...metadata, { text: formatActivityContent(entry) }];
|
|
@@ -1,16 +1,36 @@
|
|
|
1
|
+
import type { ColumnCategory } from "@zinn-dev/core";
|
|
1
2
|
import type { RowCell } from "./row-layout.js";
|
|
2
|
-
import type { PresentedColumn } from "../result-schemas.js";
|
|
3
|
+
import type { PresentedColumn, PresentedColumnTaskCount } from "../result-schemas.js";
|
|
4
|
+
import { column } from "@zinn-dev/core";
|
|
3
5
|
type ColumnRow = {
|
|
4
6
|
name: string;
|
|
7
|
+
category?: string | null;
|
|
5
8
|
project?: string;
|
|
6
9
|
taskCount?: number;
|
|
7
10
|
};
|
|
11
|
+
/** A project's columns in board order. */
|
|
12
|
+
export type ProjectColumns = ReturnType<typeof column.getAllByProjectKey>;
|
|
13
|
+
/** Reads each project's columns once, so presenting many rows costs one read per project. */
|
|
14
|
+
export type ColumnBoard = (projectId: string) => ProjectColumns;
|
|
15
|
+
export declare function createColumnBoard(): ColumnBoard;
|
|
16
|
+
/** A column off its board, such as a deleted one, has no placement and no color. */
|
|
17
|
+
export declare function columnPlacement(projectColumns: ProjectColumns, columnId: string): {
|
|
18
|
+
is_first: boolean;
|
|
19
|
+
is_last: boolean;
|
|
20
|
+
};
|
|
8
21
|
export declare function presentColumn(columnMatch: {
|
|
9
22
|
id: string;
|
|
10
23
|
project_id: string;
|
|
11
24
|
name: string;
|
|
25
|
+
category?: ColumnCategory;
|
|
12
26
|
}): PresentedColumn;
|
|
13
|
-
|
|
27
|
+
/** Shapes one board's column rows in order.*/
|
|
28
|
+
export declare function presentColumnTaskCounts(taskCounts: ReturnType<typeof column.getTaskCountsByProjectKey>): Array<PresentedColumnTaskCount>;
|
|
29
|
+
/**
|
|
30
|
+
* Colors a column name by its category.
|
|
31
|
+
* Names without a category, as on an older database, stay uncolored
|
|
32
|
+
*/
|
|
33
|
+
export declare function columnNameCell(columnName: string, category?: string | null): RowCell;
|
|
14
34
|
/** The archived row is left out when there are no archived tasks. */
|
|
15
35
|
export declare function formatColumnList(presentedColumns: Array<ColumnRow>, options?: {
|
|
16
36
|
showsProject?: boolean;
|
|
@@ -1,25 +1,68 @@
|
|
|
1
|
-
import { project } from "@zinn-dev/core";
|
|
1
|
+
import { column, project } from "@zinn-dev/core";
|
|
2
2
|
import { formatRows } from "./row-layout.js";
|
|
3
3
|
/** Archived tasks are off the board, so they share one row below the columns instead of a column of their own. */
|
|
4
4
|
const ARCHIVED_ROW_LABEL = "Archived";
|
|
5
|
+
export function createColumnBoard() {
|
|
6
|
+
const projectColumnsByProjectId = new Map();
|
|
7
|
+
return (projectId) => {
|
|
8
|
+
const cachedColumns = projectColumnsByProjectId.get(projectId);
|
|
9
|
+
if (cachedColumns != null) {
|
|
10
|
+
return cachedColumns;
|
|
11
|
+
}
|
|
12
|
+
const boardColumns = column.getAllByProjectKey(project.getById(projectId).key);
|
|
13
|
+
projectColumnsByProjectId.set(projectId, boardColumns);
|
|
14
|
+
return boardColumns;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/** A column off its board, such as a deleted one, has no placement and no color. */
|
|
18
|
+
export function columnPlacement(projectColumns, columnId) {
|
|
19
|
+
const columnIndex = projectColumns.findIndex((boardColumn) => boardColumn.id === columnId);
|
|
20
|
+
const isOnBoard = columnIndex !== -1;
|
|
21
|
+
return {
|
|
22
|
+
is_first: isOnBoard && columnIndex === 0,
|
|
23
|
+
is_last: isOnBoard && columnIndex === projectColumns.length - 1,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
5
26
|
export function presentColumn(columnMatch) {
|
|
6
27
|
const columnProject = project.getById(columnMatch.project_id);
|
|
28
|
+
const placement = columnPlacement(column.getAllByProjectKey(columnProject.key), columnMatch.id);
|
|
7
29
|
return {
|
|
8
30
|
id: columnMatch.id,
|
|
9
31
|
project: columnProject.key,
|
|
10
32
|
project_id: columnMatch.project_id,
|
|
11
33
|
name: columnMatch.name,
|
|
34
|
+
is_first: placement.is_first,
|
|
35
|
+
is_last: placement.is_last,
|
|
36
|
+
category: columnMatch.category ?? null,
|
|
12
37
|
};
|
|
13
38
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
39
|
+
/** Shapes one board's column rows in order.*/
|
|
40
|
+
export function presentColumnTaskCounts(taskCounts) {
|
|
41
|
+
const lastColumnIndex = taskCounts.columns.length - 1;
|
|
42
|
+
return taskCounts.columns.map((columnCount, columnIndex) => ({
|
|
43
|
+
id: columnCount.column.id,
|
|
44
|
+
name: columnCount.column.name,
|
|
45
|
+
is_first: columnIndex === 0,
|
|
46
|
+
is_last: columnIndex === lastColumnIndex,
|
|
47
|
+
category: columnCount.column.category ?? null,
|
|
48
|
+
taskCount: columnCount.taskCount,
|
|
49
|
+
}));
|
|
50
|
+
}
|
|
51
|
+
/** The color of each category's column names */
|
|
52
|
+
const CATEGORY_STYLES = {
|
|
53
|
+
backlog: "gray",
|
|
54
|
+
in_progress: "blue",
|
|
55
|
+
review: "yellow",
|
|
56
|
+
done: "green",
|
|
57
|
+
cancelled: "gray",
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Colors a column name by its category.
|
|
61
|
+
* Names without a category, as on an older database, stay uncolored
|
|
62
|
+
*/
|
|
63
|
+
export function columnNameCell(columnName, category) {
|
|
64
|
+
const style = category == null ? undefined : CATEGORY_STYLES[category];
|
|
65
|
+
return style === undefined ? { text: columnName } : { text: columnName, style };
|
|
23
66
|
}
|
|
24
67
|
/** The archived row is left out when there are no archived tasks. */
|
|
25
68
|
export function formatColumnList(presentedColumns, options = {}) {
|
|
@@ -27,13 +70,26 @@ export function formatColumnList(presentedColumns, options = {}) {
|
|
|
27
70
|
const projectCells = options.showsProject && presentedColumn.project != null
|
|
28
71
|
? [{ text: presentedColumn.project }]
|
|
29
72
|
: [];
|
|
73
|
+
// The cell stays, empty, for a column without a category on an older database.
|
|
74
|
+
const categoryCells = presentedColumn.category === undefined ? [] : [{ text: presentedColumn.category ?? "" }];
|
|
30
75
|
const taskCountCells = options.showsTaskCounts && presentedColumn.taskCount != null
|
|
31
76
|
? [{ text: String(presentedColumn.taskCount) }]
|
|
32
77
|
: [];
|
|
33
|
-
return [
|
|
78
|
+
return [
|
|
79
|
+
...projectCells,
|
|
80
|
+
columnNameCell(presentedColumn.name, presentedColumn.category),
|
|
81
|
+
...categoryCells,
|
|
82
|
+
...taskCountCells,
|
|
83
|
+
];
|
|
34
84
|
});
|
|
35
85
|
if (options.archivedTaskCount != null && options.archivedTaskCount > 0) {
|
|
36
|
-
|
|
86
|
+
// An empty cell keeps the count under the task counts when rows show categories.
|
|
87
|
+
const hasCategoryCell = presentedColumns.some((presentedColumn) => presentedColumn.category !== undefined);
|
|
88
|
+
rows.push([
|
|
89
|
+
{ text: ARCHIVED_ROW_LABEL },
|
|
90
|
+
...(hasCategoryCell ? [{ text: "" }] : []),
|
|
91
|
+
{ text: String(options.archivedTaskCount) },
|
|
92
|
+
]);
|
|
37
93
|
}
|
|
38
94
|
return formatRows(rows);
|
|
39
95
|
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { DoctorCheck } from "@zinn-dev/core";
|
|
2
|
+
import type { PresentedDoctor } from "../result-schemas.js";
|
|
3
|
+
export declare function presentDoctor(checks: ReadonlyArray<DoctorCheck>, agentSkill: DoctorCheck<"agent_skill">): PresentedDoctor;
|
|
4
|
+
export declare function formatDoctor(report: PresentedDoctor): string;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { styleOutputText } from "./color.js";
|
|
2
|
+
const STATUS_STYLES = {
|
|
3
|
+
ok: "green",
|
|
4
|
+
warning: "yellow",
|
|
5
|
+
problem: "red",
|
|
6
|
+
};
|
|
7
|
+
const STATUS_WIDTH = Math.max(...Object.keys(STATUS_STYLES).map((status) => status.length));
|
|
8
|
+
const REMEDY_INDENT = " ".repeat(STATUS_WIDTH + 1);
|
|
9
|
+
export function presentDoctor(checks, agentSkill) {
|
|
10
|
+
const presented = [...checks, agentSkill];
|
|
11
|
+
return {
|
|
12
|
+
ok: presented.every((check) => check.status === "ok"),
|
|
13
|
+
checks: presented,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export function formatDoctor(report) {
|
|
17
|
+
return report.checks
|
|
18
|
+
.flatMap(({ status, message, remedy }) => {
|
|
19
|
+
const label = styleOutputText(STATUS_STYLES[status], status.padEnd(STATUS_WIDTH));
|
|
20
|
+
const line = `${label} ${message}`;
|
|
21
|
+
return remedy === null ? [line] : [line, `${REMEDY_INDENT}${remedy}`];
|
|
22
|
+
})
|
|
23
|
+
.join("\n");
|
|
24
|
+
}
|
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
import packageJson from "../../package.json" with { type: "json" };
|
|
2
|
+
import { currentRuntime } from "../run-facts.js";
|
|
2
3
|
export function presentInfo(report) {
|
|
3
|
-
const bunVersion = process.versions.bun;
|
|
4
4
|
return {
|
|
5
5
|
settingsFiles: report.settingsFiles,
|
|
6
6
|
storage: report.storage,
|
|
7
7
|
defaultProject: report.defaultProject,
|
|
8
|
+
telemetry: report.telemetry,
|
|
8
9
|
database: report.database,
|
|
9
10
|
versions: {
|
|
10
11
|
cli: packageJson.version,
|
|
11
12
|
core: report.coreVersion,
|
|
12
|
-
runtime:
|
|
13
|
-
name: bunVersion === undefined ? "Node" : "Bun",
|
|
14
|
-
version: bunVersion ?? process.versions.node,
|
|
15
|
-
},
|
|
13
|
+
runtime: currentRuntime(),
|
|
16
14
|
},
|
|
17
15
|
};
|
|
18
16
|
}
|
|
@@ -31,6 +29,18 @@ function folderState(storage) {
|
|
|
31
29
|
}
|
|
32
30
|
return storage.exists ? "found" : "missing";
|
|
33
31
|
}
|
|
32
|
+
function telemetrySource(telemetry) {
|
|
33
|
+
return telemetry.settingsPath ?? telemetry.source ?? "unavailable";
|
|
34
|
+
}
|
|
35
|
+
function telemetryFolderState(telemetry) {
|
|
36
|
+
if (telemetry.exists === null) {
|
|
37
|
+
return "unavailable";
|
|
38
|
+
}
|
|
39
|
+
if (!telemetry.exists) {
|
|
40
|
+
return telemetry.sizeBytes === null ? "not a directory" : "missing";
|
|
41
|
+
}
|
|
42
|
+
return telemetry.sizeBytes === null ? "cannot be read" : `${telemetry.sizeBytes} bytes`;
|
|
43
|
+
}
|
|
34
44
|
function databaseState(database) {
|
|
35
45
|
if (database.error !== null) {
|
|
36
46
|
return database.error;
|
|
@@ -38,7 +48,7 @@ function databaseState(database) {
|
|
|
38
48
|
return `${database.state}; schema ${database.version ?? "unavailable"}, latest ${database.latestVersion}`;
|
|
39
49
|
}
|
|
40
50
|
export function formatInfo(report) {
|
|
41
|
-
const { storage, database, defaultProject, versions } = report;
|
|
51
|
+
const { storage, database, defaultProject, telemetry, versions } = report;
|
|
42
52
|
const storeIsUnavailable = storage.directory === null;
|
|
43
53
|
//
|
|
44
54
|
/**
|
|
@@ -56,12 +66,23 @@ export function formatInfo(report) {
|
|
|
56
66
|
? (defaultProject.key ?? "not configured")
|
|
57
67
|
: `unavailable (${unavailableReason(defaultProject.error)})`;
|
|
58
68
|
const defaultProjectSuffix = defaultProject.settingsPath === null ? "" : ` (${defaultProject.settingsPath})`;
|
|
69
|
+
const telemetryReason = telemetry.error === null ? "" : ` (${unavailableReason(telemetry.error)})`;
|
|
70
|
+
const telemetryText = telemetry.mode === null
|
|
71
|
+
? `unavailable${telemetryReason}`
|
|
72
|
+
: `${telemetry.mode} (${telemetrySource(telemetry)})`;
|
|
73
|
+
const telemetryLimit = telemetry.maxMegabytes === null ? "" : `, limit ${telemetry.maxMegabytes} MB`;
|
|
74
|
+
const telemetryAge = telemetry.maxAgeDays === null ? "" : `, kept ${telemetry.maxAgeDays} days`;
|
|
75
|
+
const telemetryFolderText = telemetry.directory === null
|
|
76
|
+
? `unavailable${telemetryReason}`
|
|
77
|
+
: `${telemetry.directory} (${telemetryFolderState(telemetry)})`;
|
|
59
78
|
const lines = [
|
|
60
79
|
`Store: ${storeHeader}`,
|
|
61
80
|
`Store folder: ${storeIsUnavailable ? "unavailable" : folderState(storage)}`,
|
|
62
81
|
`Database: ${database.path ?? "unavailable"}`,
|
|
63
82
|
`Database state: ${storeIsUnavailable ? "unavailable" : databaseState(database)}`,
|
|
64
83
|
`Default project: ${defaultProjectText}${defaultProjectSuffix}`,
|
|
84
|
+
`Telemetry: ${telemetryText}${telemetryLimit}${telemetryAge}`,
|
|
85
|
+
`Telemetry folder: ${telemetryFolderText}`,
|
|
65
86
|
"",
|
|
66
87
|
"Settings:",
|
|
67
88
|
];
|
|
@@ -89,6 +110,15 @@ export function formatInfo(report) {
|
|
|
89
110
|
if (file.settings.defaultProject !== undefined) {
|
|
90
111
|
lines.push(` defaultProject: ${file.settings.defaultProject}`);
|
|
91
112
|
}
|
|
113
|
+
if (file.settings.telemetry?.mode !== undefined) {
|
|
114
|
+
lines.push(` telemetry.mode: ${file.settings.telemetry.mode}`);
|
|
115
|
+
}
|
|
116
|
+
if (file.settings.telemetry?.maxMegabytes !== undefined) {
|
|
117
|
+
lines.push(` telemetry.maxMegabytes: ${file.settings.telemetry.maxMegabytes}`);
|
|
118
|
+
}
|
|
119
|
+
if (file.settings.telemetry?.maxAgeDays !== undefined) {
|
|
120
|
+
lines.push(` telemetry.maxAgeDays: ${file.settings.telemetry.maxAgeDays}`);
|
|
121
|
+
}
|
|
92
122
|
}
|
|
93
123
|
}
|
|
94
124
|
lines.push("", `CLI: ${versions.cli}`, `Core: ${versions.core}`, `Runtime: ${versions.runtime.name} ${versions.runtime.version}`);
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import type { TaskWithKey } from "@zinn-dev/core";
|
|
2
2
|
import type { PresentedRelation, PresentedRelationChange } from "../result-schemas.js";
|
|
3
|
+
import type { ColumnBoard } from "./column-presentation.js";
|
|
4
|
+
import type { RowCell } from "./row-layout.js";
|
|
3
5
|
import { relation } from "@zinn-dev/core";
|
|
4
6
|
export declare function presentRelationChange(entry: ReturnType<typeof relation.create>, source: TaskWithKey, target: TaskWithKey): PresentedRelationChange;
|
|
5
|
-
export declare function presentRelations(taskMatch: TaskWithKey): Array<PresentedRelation>;
|
|
6
|
-
export declare function formatRelationList(relations: Array<PresentedRelation
|
|
7
|
+
export declare function presentRelations(taskMatch: TaskWithKey, board?: ColumnBoard): Array<PresentedRelation>;
|
|
8
|
+
export declare function formatRelationList(relations: Array<PresentedRelation>, options?: {
|
|
9
|
+
trailingCell?: (entry: PresentedRelation) => RowCell;
|
|
10
|
+
}): string;
|
|
7
11
|
export declare function formatRelationChange(change: Pick<PresentedRelationChange, "type" | "source" | "target">, options: {
|
|
8
12
|
action: "create" | "delete";
|
|
9
13
|
} | {
|