@zinn-dev/cli 0.45.0 → 0.47.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +3 -3
- package/skills/zinn/SKILL.md +2 -2
- package/src/actor.d.ts +1 -1
- package/src/actor.js +4 -1
- package/src/capabilities-schema.d.ts +78 -0
- package/src/capabilities-schema.js +44 -0
- package/src/capabilities.d.ts +2 -0
- package/src/capabilities.js +2 -0
- package/src/column-hint.js +2 -9
- package/src/errors.d.ts +5 -0
- package/src/errors.js +19 -5
- package/src/input.d.ts +30 -0
- package/src/input.js +18 -0
- package/src/lib.d.ts +75 -6
- package/src/lib.js +121 -33
- package/src/presentation/activity-presentation.d.ts +2 -1
- package/src/presentation/activity-presentation.js +23 -6
- package/src/presentation/color.d.ts +12 -0
- package/src/presentation/color.js +12 -0
- package/src/presentation/doctor-presentation.d.ts +7 -1
- package/src/presentation/doctor-presentation.js +6 -2
- package/src/presentation/project-presentation.d.ts +4 -1
- package/src/presentation/project-presentation.js +18 -0
- package/src/presentation/relation-presentation.js +8 -20
- package/src/presentation/section.d.ts +7 -4
- package/src/presentation/section.js +21 -7
- package/src/presentation/skill-status-presentation.d.ts +9 -0
- package/src/presentation/skill-status-presentation.js +43 -0
- package/src/presentation/task-blame-presentation.d.ts +3 -1
- package/src/presentation/task-blame-presentation.js +7 -5
- package/src/presentation/task-presentation.d.ts +28 -5
- package/src/presentation/task-presentation.js +120 -42
- package/src/result-schemas.d.ts +230 -14
- package/src/result-schemas.js +52 -0
- package/src/routes/activity-router.d.ts +5 -3
- package/src/routes/activity-router.js +44 -33
- package/src/routes/backup-router.d.ts +1 -0
- package/src/routes/backup-router.js +6 -12
- package/src/routes/capabilities-router.d.ts +1 -0
- package/src/routes/capabilities-router.js +3 -10
- package/src/routes/comment-router.d.ts +7 -6
- package/src/routes/comment-router.js +18 -66
- package/src/routes/doctor-router.d.ts +1 -0
- package/src/routes/doctor-router.js +35 -62
- package/src/routes/info-router.d.ts +1 -0
- package/src/routes/info-router.js +3 -10
- package/src/routes/label-router.d.ts +5 -0
- package/src/routes/label-router.js +11 -48
- package/src/routes/migrate-router.d.ts +1 -0
- package/src/routes/migrate-router.js +7 -16
- package/src/routes/project-router.d.ts +10 -0
- package/src/routes/project-router.js +42 -121
- package/src/routes/reindex-router.d.ts +1 -0
- package/src/routes/reindex-router.js +3 -10
- package/src/routes/relation-router.d.ts +13 -4
- package/src/routes/relation-router.js +15 -23
- package/src/routes/restore-router.d.ts +1 -0
- package/src/routes/restore-router.js +5 -15
- package/src/routes/router.js +33 -12
- package/src/routes/routes.d.ts +142 -32
- package/src/routes/skill-router.d.ts +53 -2
- package/src/routes/skill-router.js +103 -35
- package/src/routes/task-router.d.ts +61 -28
- package/src/routes/task-router.js +224 -263
- package/src/routes/whoami-router.d.ts +1 -0
- package/src/routes/whoami-router.js +3 -10
- package/src/skill-copies.d.ts +34 -0
- package/src/skill-copies.js +109 -0
- package/src/telemetry.d.ts +2 -2
- package/src/telemetry.js +11 -7
- package/src/types.d.ts +9 -1
- package/src/types.js +6 -0
- package/src/views.d.ts +117 -0
- package/src/views.js +54 -0
|
@@ -1,16 +1,39 @@
|
|
|
1
|
-
import type { TaskWithKey } from "@zinn-dev/core";
|
|
1
|
+
import type { TaskSearchMatch, TaskWithKey } from "@zinn-dev/core";
|
|
2
2
|
import type { RowCell } from "./row-layout.js";
|
|
3
3
|
import type { PresentedTask, PresentedTaskDetail } from "../result-schemas.js";
|
|
4
4
|
import type { ColumnBoard } from "./column-presentation.js";
|
|
5
|
+
import type { PresentedActivity } from "./activity-presentation.js";
|
|
6
|
+
import type { TerminalProps } from "./color.js";
|
|
5
7
|
export declare function taskPriorityCell(priority: PresentedTask["priority"], showsFullPriority: boolean): RowCell;
|
|
6
|
-
/**
|
|
7
|
-
|
|
8
|
+
/**
|
|
9
|
+
* `PresentedTask` carries label names and IDs, without colors.
|
|
10
|
+
* Text output looks the colors up from the label definitions instead.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getLabelColorsByName(): Map<string, "red" | "green" | "yellow" | "blue" | "magenta" | "cyan" | "white" | "gray">;
|
|
13
|
+
export declare function formatLabelNames(labelNames: Array<string>, labelColorsByName: ReadonlyMap<string, string>): string;
|
|
14
|
+
/** Shapes many tasks with one label read for all of them */
|
|
15
|
+
export declare function presentTasks(taskMatches: ReadonlyArray<TaskWithKey>, board?: ColumnBoard): Array<PresentedTask>;
|
|
8
16
|
export declare function presentTask(taskMatch: TaskWithKey, board?: ColumnBoard): PresentedTask;
|
|
9
|
-
export declare function
|
|
17
|
+
export declare function presentTaskSearchResults(taskMatches: TaskWithKey[], matchesByTaskId: ReadonlyMap<string, TaskSearchMatch[]> | undefined): Array<PresentedTask & {
|
|
18
|
+
matches?: TaskSearchMatch[];
|
|
19
|
+
}>;
|
|
20
|
+
export declare function formatTaskList(presentedTasks: Array<PresentedTask & {
|
|
21
|
+
matches?: TaskSearchMatch[];
|
|
22
|
+
}>, options?: {
|
|
10
23
|
showsStatus?: boolean;
|
|
11
24
|
showsFullPriority?: boolean;
|
|
12
25
|
prefix?: string;
|
|
26
|
+
labelColorsByName?: ReadonlyMap<string, string>;
|
|
13
27
|
/** Shows an expired claim too, and when each claim's lease ends */
|
|
14
28
|
showsClaimDetail?: boolean;
|
|
29
|
+
resumedExpiredClaim?: boolean;
|
|
15
30
|
}): string;
|
|
16
|
-
|
|
31
|
+
/**
|
|
32
|
+
* The task row followed by its description, relation, comment
|
|
33
|
+
* and history sections, each shown when it has content.
|
|
34
|
+
* In a terminal, section headings sit in a rule that fills the line.
|
|
35
|
+
*/
|
|
36
|
+
export declare function formatTaskDetail(presentedTask: PresentedTaskDetail, options?: {
|
|
37
|
+
history?: Array<PresentedActivity>;
|
|
38
|
+
labelColorsByName?: ReadonlyMap<string, string>;
|
|
39
|
+
} & TerminalProps): string;
|
|
@@ -1,15 +1,26 @@
|
|
|
1
1
|
import { label, task } from "@zinn-dev/core";
|
|
2
|
+
import { views } from "../views.js";
|
|
2
3
|
import { columnNameCell, columnPlacement, createColumnBoard } from "./column-presentation.js";
|
|
3
4
|
import { labelNameCell } from "./label-presentation.js";
|
|
4
5
|
import { formatCell, formatCellSeparator, formatRows } from "./row-layout.js";
|
|
5
6
|
import { formatLocalTime } from "./time.js";
|
|
6
|
-
import { formatActorLabel } from "./activity-presentation.js";
|
|
7
|
+
import { formatActivityList, formatActorLabel } from "./activity-presentation.js";
|
|
8
|
+
import { formatCommentList } from "./comment-presentation.js";
|
|
9
|
+
import { formatRelationList } from "./relation-presentation.js";
|
|
10
|
+
import { formatSection } from "./section.js";
|
|
11
|
+
import { styleOutputText } from "./color.js";
|
|
7
12
|
const EMPTY_CELL_MARKER = "-";
|
|
8
13
|
const LABEL_NAME_SEPARATOR = ", ";
|
|
14
|
+
const priorityWords = views.words.priorities;
|
|
9
15
|
export function taskPriorityCell(priority, showsFullPriority) {
|
|
10
|
-
|
|
16
|
+
const hasNoPriority = priority == null || priority === "";
|
|
17
|
+
if (hasNoPriority) {
|
|
11
18
|
return { text: EMPTY_CELL_MARKER, style: "dim" };
|
|
12
19
|
}
|
|
20
|
+
if (Object.hasOwn(priorityWords, priority)) {
|
|
21
|
+
const { word, initial } = priorityWords[priority];
|
|
22
|
+
return { text: showsFullPriority ? word : initial };
|
|
23
|
+
}
|
|
13
24
|
const priorityInitial = priority[0].toUpperCase();
|
|
14
25
|
return { text: showsFullPriority ? `${priorityInitial}${priority.slice(1)}` : priorityInitial };
|
|
15
26
|
}
|
|
@@ -17,43 +28,53 @@ export function taskPriorityCell(priority, showsFullPriority) {
|
|
|
17
28
|
* `PresentedTask` carries label names and IDs, without colors.
|
|
18
29
|
* Text output looks the colors up from the label definitions instead.
|
|
19
30
|
*/
|
|
20
|
-
function getLabelColorsByName() {
|
|
31
|
+
export function getLabelColorsByName() {
|
|
21
32
|
return new Map(label.getAll().map((labelMatch) => [labelMatch.name, labelMatch.color]));
|
|
22
33
|
}
|
|
23
|
-
function
|
|
34
|
+
export function formatLabelNames(labelNames, labelColorsByName) {
|
|
24
35
|
return labelNames
|
|
25
36
|
.map((labelName) => formatCell(labelNameCell(labelName, labelColorsByName.get(labelName))))
|
|
26
37
|
.join(LABEL_NAME_SEPARATOR);
|
|
27
38
|
}
|
|
28
|
-
/**
|
|
29
|
-
export function
|
|
30
|
-
|
|
39
|
+
/** Shapes many tasks with one label read for all of them */
|
|
40
|
+
export function presentTasks(taskMatches, board = createColumnBoard()) {
|
|
41
|
+
const labelsByTaskId = task.label.getAllByTaskIds(taskMatches.map((taskMatch) => taskMatch.id));
|
|
42
|
+
return taskMatches.map((taskMatch) => {
|
|
43
|
+
const labels = labelsByTaskId.get(taskMatch.id);
|
|
44
|
+
const projectColumns = board(taskMatch.project_id);
|
|
45
|
+
const columnMatch = projectColumns.find((boardColumn) => boardColumn.id === taskMatch.column_id);
|
|
46
|
+
const placement = columnPlacement(projectColumns, taskMatch.column_id);
|
|
47
|
+
return {
|
|
48
|
+
id: taskMatch.id,
|
|
49
|
+
key: taskMatch.key,
|
|
50
|
+
project_id: taskMatch.project_id,
|
|
51
|
+
status: taskMatch.archived_at == null ? "Active" : "Archived",
|
|
52
|
+
column: columnMatch.name,
|
|
53
|
+
column_id: taskMatch.column_id,
|
|
54
|
+
is_first: placement.is_first,
|
|
55
|
+
is_last: placement.is_last,
|
|
56
|
+
column_category: columnMatch.category ?? null,
|
|
57
|
+
title: taskMatch.title,
|
|
58
|
+
description: taskMatch.description,
|
|
59
|
+
priority: taskMatch.priority,
|
|
60
|
+
due_at: taskMatch.due_at ?? null,
|
|
61
|
+
labels: labels.map((label) => label.name),
|
|
62
|
+
label_ids: labels.map((label) => label.id),
|
|
63
|
+
created_at: taskMatch.created_at,
|
|
64
|
+
updated_at: taskMatch.updated_at,
|
|
65
|
+
claim: presentClaim(taskMatch.claim),
|
|
66
|
+
};
|
|
67
|
+
});
|
|
31
68
|
}
|
|
32
|
-
export function presentTask(taskMatch, board
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
status: taskMatch.archived_at == null ? "Active" : "Archived",
|
|
42
|
-
column: columnMatch.name,
|
|
43
|
-
column_id: taskMatch.column_id,
|
|
44
|
-
is_first: placement.is_first,
|
|
45
|
-
is_last: placement.is_last,
|
|
46
|
-
column_category: columnMatch.category ?? null,
|
|
47
|
-
title: taskMatch.title,
|
|
48
|
-
description: taskMatch.description,
|
|
49
|
-
priority: taskMatch.priority,
|
|
50
|
-
due_at: taskMatch.due_at ?? null,
|
|
51
|
-
labels: labels.map((label) => label.name),
|
|
52
|
-
label_ids: labels.map((label) => label.id),
|
|
53
|
-
created_at: taskMatch.created_at,
|
|
54
|
-
updated_at: taskMatch.updated_at,
|
|
55
|
-
claim: presentClaim(taskMatch.claim),
|
|
56
|
-
};
|
|
69
|
+
export function presentTask(taskMatch, board) {
|
|
70
|
+
return presentTasks([taskMatch], board)[0];
|
|
71
|
+
}
|
|
72
|
+
export function presentTaskSearchResults(taskMatches, matchesByTaskId) {
|
|
73
|
+
const tasks = presentTasks(taskMatches);
|
|
74
|
+
if (matchesByTaskId === undefined) {
|
|
75
|
+
return tasks;
|
|
76
|
+
}
|
|
77
|
+
return tasks.map((task) => ({ ...task, matches: matchesByTaskId.get(task.id) }));
|
|
57
78
|
}
|
|
58
79
|
function presentClaim(claim) {
|
|
59
80
|
if (claim == null) {
|
|
@@ -73,25 +94,43 @@ function presentClaim(claim) {
|
|
|
73
94
|
};
|
|
74
95
|
}
|
|
75
96
|
/** Who holds the claim, and when its lease ends or ended when `showsExpiry` is set */
|
|
76
|
-
function formatClaim(claim, showsExpiry) {
|
|
97
|
+
function formatClaim(claim, showsExpiry, resumedExpiredClaim = false) {
|
|
77
98
|
const holder = formatActorLabel(claim);
|
|
78
99
|
if (!showsExpiry) {
|
|
79
100
|
return `Claimed by ${holder}`;
|
|
80
101
|
}
|
|
81
102
|
const expiresAt = formatLocalTime(claim.expires_at, { includesSeconds: true });
|
|
103
|
+
if (resumedExpiredClaim) {
|
|
104
|
+
return `Resumed expired claim by ${holder} until ${expiresAt}`;
|
|
105
|
+
}
|
|
82
106
|
return claim.state === "live"
|
|
83
107
|
? `Claimed by ${holder} until ${expiresAt}`
|
|
84
108
|
: `Claim by ${holder} expired at ${expiresAt}`;
|
|
85
109
|
}
|
|
110
|
+
const SEARCH_SOURCE_LABELS = { key: "Task key", title: "Title", description: "Description" };
|
|
111
|
+
function formatSearchExcerpt(match) {
|
|
112
|
+
const source = match.field === "comment" ? `Comment ${match.comment_key}` : SEARCH_SOURCE_LABELS[match.field];
|
|
113
|
+
// Render stored control characters without interpreting them as terminal commands
|
|
114
|
+
const points = Array.from(match.snippet.replace(/\p{Cc}/gu, "�"));
|
|
115
|
+
let snippet = "";
|
|
116
|
+
let offset = 0;
|
|
117
|
+
for (const [start, end] of match.highlights) {
|
|
118
|
+
snippet += points.slice(offset, start).join("");
|
|
119
|
+
snippet += styleOutputText(["bold", "yellow"], points.slice(start, end).join(""));
|
|
120
|
+
offset = end;
|
|
121
|
+
}
|
|
122
|
+
snippet += points.slice(offset).join("");
|
|
123
|
+
return `\n ${source}${formatCellSeparator()}${snippet}`;
|
|
124
|
+
}
|
|
86
125
|
export function formatTaskList(presentedTasks, options = {}) {
|
|
87
|
-
const labelColorsByName = getLabelColorsByName();
|
|
126
|
+
const labelColorsByName = options.labelColorsByName ?? getLabelColorsByName();
|
|
88
127
|
return formatRows(presentedTasks.map((presentedTask) => {
|
|
89
128
|
const statusCells = options.showsStatus
|
|
90
129
|
? [{ text: presentedTask.status }]
|
|
91
130
|
: [];
|
|
92
131
|
const hasLabels = presentedTask.labels.length > 0;
|
|
93
132
|
// The last cell is never padded, so the color codes in its separator and label names do not affect column widths.
|
|
94
|
-
const labelNames =
|
|
133
|
+
const labelNames = formatLabelNames(presentedTask.labels, labelColorsByName);
|
|
95
134
|
const labels = hasLabels ? `${formatCellSeparator()}${labelNames}` : "";
|
|
96
135
|
const deadline = presentedTask.due_at == null
|
|
97
136
|
? ""
|
|
@@ -100,22 +139,61 @@ export function formatTaskList(presentedTasks, options = {}) {
|
|
|
100
139
|
const claim = presentedTask.claim;
|
|
101
140
|
const showsClaim = claim != null && (claim.state === "live" || showsClaimDetail);
|
|
102
141
|
const claimText = showsClaim
|
|
103
|
-
? `${formatCellSeparator()}${formatClaim(claim, showsClaimDetail)}`
|
|
142
|
+
? `${formatCellSeparator()}${formatClaim(claim, showsClaimDetail, options.resumedExpiredClaim)}`
|
|
104
143
|
: "";
|
|
144
|
+
const excerpts = presentedTask.matches?.map(formatSearchExcerpt).join("") ?? "";
|
|
105
145
|
return [
|
|
106
146
|
{ text: `${options.prefix ?? ""}${presentedTask.key}` },
|
|
107
147
|
...statusCells,
|
|
108
148
|
columnNameCell(presentedTask.column, presentedTask.column_category),
|
|
109
149
|
taskPriorityCell(presentedTask.priority, options.showsFullPriority ?? false),
|
|
110
|
-
{ text: `${presentedTask.title}${deadline}${claimText}${labels}` },
|
|
150
|
+
{ text: `${presentedTask.title}${deadline}${claimText}${labels}${excerpts}` },
|
|
111
151
|
];
|
|
112
152
|
}));
|
|
113
153
|
}
|
|
114
|
-
|
|
154
|
+
function formatTaskTimestamps(task, items) {
|
|
155
|
+
const timestamps = { createdAt: task.created_at, updatedAt: task.updated_at };
|
|
115
156
|
return formatRows([
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
157
|
+
items.map(({ role, label }) => ({
|
|
158
|
+
text: `${label}: ${formatLocalTime(timestamps[role])}`,
|
|
159
|
+
style: "dim",
|
|
160
|
+
})),
|
|
120
161
|
]);
|
|
121
162
|
}
|
|
163
|
+
/**
|
|
164
|
+
* The task row followed by its description, relation, comment
|
|
165
|
+
* and history sections, each shown when it has content.
|
|
166
|
+
* In a terminal, section headings sit in a rule that fills the line.
|
|
167
|
+
*/
|
|
168
|
+
export function formatTaskDetail(presentedTask, options = {}) {
|
|
169
|
+
const sections = views.taskDetail.sections.flatMap((section) => {
|
|
170
|
+
let content;
|
|
171
|
+
switch (section.id) {
|
|
172
|
+
case "task":
|
|
173
|
+
return [
|
|
174
|
+
formatTaskList([presentedTask], {
|
|
175
|
+
showsStatus: presentedTask.status === "Archived",
|
|
176
|
+
showsFullPriority: true,
|
|
177
|
+
showsClaimDetail: true,
|
|
178
|
+
labelColorsByName: options.labelColorsByName,
|
|
179
|
+
}),
|
|
180
|
+
];
|
|
181
|
+
case "description":
|
|
182
|
+
content = presentedTask.description;
|
|
183
|
+
break;
|
|
184
|
+
case "relations":
|
|
185
|
+
content = formatRelationList(presentedTask.relations) || null;
|
|
186
|
+
break;
|
|
187
|
+
case "comments":
|
|
188
|
+
content = formatCommentList(presentedTask.comments) || null;
|
|
189
|
+
break;
|
|
190
|
+
case "history":
|
|
191
|
+
content = formatActivityList(options.history ?? []) || null;
|
|
192
|
+
break;
|
|
193
|
+
case "times":
|
|
194
|
+
return [formatTaskTimestamps(presentedTask, section.items)];
|
|
195
|
+
}
|
|
196
|
+
return content == null ? [] : [formatSection(section.heading, content, options)];
|
|
197
|
+
});
|
|
198
|
+
return sections.join("\n\n");
|
|
199
|
+
}
|