@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
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { columnNameCell } from "./column-presentation.js";
|
|
1
|
+
import { relation } from "@zinn-dev/core";
|
|
2
|
+
import { columnNameCell, columnPlacement, createColumnBoard } from "./column-presentation.js";
|
|
3
3
|
import { formatCellSeparator, formatRows } from "./row-layout.js";
|
|
4
4
|
export function presentRelationChange(entry, source, target) {
|
|
5
5
|
return {
|
|
@@ -11,7 +11,7 @@ export function presentRelationChange(entry, source, target) {
|
|
|
11
11
|
target_task_id: target.id,
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
|
-
export function presentRelations(taskMatch) {
|
|
14
|
+
export function presentRelations(taskMatch, board = createColumnBoard()) {
|
|
15
15
|
return relation.getAll(taskMatch.key, { include: { tasks: true } }).map((entry) => {
|
|
16
16
|
const isSource = entry.source_task_id === taskMatch.id;
|
|
17
17
|
const other = isSource ? entry.target : entry.source;
|
|
@@ -22,6 +22,9 @@ export function presentRelations(taskMatch) {
|
|
|
22
22
|
if (entry.relation_type !== "related") {
|
|
23
23
|
direction = isSource ? "outgoing" : "incoming";
|
|
24
24
|
}
|
|
25
|
+
const projectColumns = board(other.project_id);
|
|
26
|
+
const columnMatch = projectColumns.find((boardColumn) => boardColumn.id === other.column_id);
|
|
27
|
+
const placement = columnPlacement(projectColumns, other.column_id);
|
|
25
28
|
return {
|
|
26
29
|
id: entry.id,
|
|
27
30
|
type: entry.relation_type,
|
|
@@ -30,42 +33,50 @@ export function presentRelations(taskMatch) {
|
|
|
30
33
|
id: other.id,
|
|
31
34
|
key: other.key,
|
|
32
35
|
project_id: other.project_id,
|
|
33
|
-
column:
|
|
36
|
+
column: columnMatch.name,
|
|
34
37
|
column_id: other.column_id,
|
|
38
|
+
is_first: placement.is_first,
|
|
39
|
+
is_last: placement.is_last,
|
|
40
|
+
column_category: columnMatch.category ?? null,
|
|
35
41
|
title: other.title,
|
|
36
42
|
status: other.archived_at == null ? "Active" : "Archived",
|
|
37
43
|
},
|
|
38
44
|
};
|
|
39
45
|
});
|
|
40
46
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
break;
|
|
61
|
-
}
|
|
47
|
+
function formatRelationLabel(entry) {
|
|
48
|
+
const isOutgoing = entry.direction === "outgoing";
|
|
49
|
+
let label = entry.type;
|
|
50
|
+
switch (entry.type) {
|
|
51
|
+
case "related": {
|
|
52
|
+
label = "Related to";
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
case "dependency": {
|
|
56
|
+
label = isOutgoing ? "Depends on" : "Depended on by";
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
case "subtask": {
|
|
60
|
+
label = isOutgoing ? "Parent" : "Subtask";
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
case "duplicate": {
|
|
64
|
+
label = isOutgoing ? "Duplicate of" : "Duplicated by";
|
|
65
|
+
break;
|
|
62
66
|
}
|
|
67
|
+
}
|
|
68
|
+
return label;
|
|
69
|
+
}
|
|
70
|
+
export function formatRelationList(relations, options = {}) {
|
|
71
|
+
return formatRows(relations.map((entry) => {
|
|
72
|
+
const label = formatRelationLabel(entry);
|
|
63
73
|
const archived = entry.task.status === "Archived" ? `${formatCellSeparator()}Archived` : "";
|
|
64
74
|
return [
|
|
65
75
|
{ text: label },
|
|
66
76
|
{ text: entry.task.key },
|
|
67
|
-
columnNameCell(entry.task.column),
|
|
77
|
+
columnNameCell(entry.task.column, entry.task.column_category),
|
|
68
78
|
{ text: `${entry.task.title}${archived}` },
|
|
79
|
+
...(options.trailingCell === undefined ? [] : [options.trailingCell(entry)]),
|
|
69
80
|
];
|
|
70
81
|
}));
|
|
71
82
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { PresentedRelation, PresentedTaskBlame } from "../result-schemas.js";
|
|
2
|
+
export declare function formatTaskBlame(blame: PresentedTaskBlame, options: {
|
|
3
|
+
relations: Array<PresentedRelation>;
|
|
4
|
+
columnCategory: string | null;
|
|
5
|
+
isArchived: boolean;
|
|
6
|
+
/** Short forms of activity IDs, which `activity view` accepts as well as full IDs. */
|
|
7
|
+
activityIdPrefixes: Map<string, string>;
|
|
8
|
+
}): string;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { formatActor } from "./activity-presentation.js";
|
|
2
|
+
import { columnNameCell } from "./column-presentation.js";
|
|
3
|
+
import { formatRelationList } from "./relation-presentation.js";
|
|
4
|
+
import { formatCell, formatCellSeparator, formatRows } from "./row-layout.js";
|
|
5
|
+
import { formatSection } from "./section.js";
|
|
6
|
+
import { formatLabelNames, taskPriorityCell } from "./task-presentation.js";
|
|
7
|
+
import { formatLocalTime } from "./time.js";
|
|
8
|
+
export function formatTaskBlame(blame, options) {
|
|
9
|
+
const events = new Map();
|
|
10
|
+
function reference(attribution) {
|
|
11
|
+
if (attribution === null) {
|
|
12
|
+
return "unrecorded";
|
|
13
|
+
}
|
|
14
|
+
events.set(attribution.id, attribution);
|
|
15
|
+
return options.activityIdPrefixes.get(attribution.id) ?? attribution.id;
|
|
16
|
+
}
|
|
17
|
+
function field(name, value, attribution) {
|
|
18
|
+
return `${name}: ${value} [${reference(attribution)}]`;
|
|
19
|
+
}
|
|
20
|
+
const { fields } = blame;
|
|
21
|
+
const labelNames = fields.labels.value.map((label) => label.name);
|
|
22
|
+
const content = [
|
|
23
|
+
`${blame.task.key} (${blame.task.id})${options.isArchived ? `${formatCellSeparator()}Archived` : ""}`,
|
|
24
|
+
formatSection("Fields", [
|
|
25
|
+
field("Title", fields.title.value, fields.title.attribution),
|
|
26
|
+
field("Column", formatCell(columnNameCell(fields.column.value.name, options.columnCategory)), fields.column.attribution),
|
|
27
|
+
field("Priority", formatCell(taskPriorityCell(fields.priority.value, true)), fields.priority.attribution),
|
|
28
|
+
field("Due", fields.due_at.value === null
|
|
29
|
+
? "none"
|
|
30
|
+
: formatLocalTime(fields.due_at.value, { includesSeconds: true }), fields.due_at.attribution),
|
|
31
|
+
field("Labels", labelNames.length === 0 ? "none" : formatLabelNames(labelNames), fields.labels.attribution),
|
|
32
|
+
field("Parent", fields.parent.value?.key ?? "none", fields.parent.attribution),
|
|
33
|
+
].join("\n")),
|
|
34
|
+
];
|
|
35
|
+
if (options.relations.length > 0) {
|
|
36
|
+
const relationAttributions = new Map(blame.relations.map((entry) => [entry.id, entry.attribution]));
|
|
37
|
+
content.push(formatSection("Relations", formatRelationList(options.relations, {
|
|
38
|
+
trailingCell: (entry) => ({
|
|
39
|
+
text: `[${reference(relationAttributions.get(entry.id) ?? null)}]`,
|
|
40
|
+
}),
|
|
41
|
+
})));
|
|
42
|
+
}
|
|
43
|
+
if (blame.description.length > 0) {
|
|
44
|
+
content.push(formatSection("Description", formatRows(blame.description.map((line) => [
|
|
45
|
+
{ text: String(line.line) },
|
|
46
|
+
{ text: `[${reference(line.attribution)}]` },
|
|
47
|
+
{ text: line.text },
|
|
48
|
+
]))));
|
|
49
|
+
}
|
|
50
|
+
if (events.size > 0) {
|
|
51
|
+
content.push(formatSection("Attribution", [...events.values()]
|
|
52
|
+
.map((event) => `${event.id}\n${formatLocalTime(event.created_at, { includesSeconds: true })}\n${formatActor(event)}`)
|
|
53
|
+
.join("\n\n")));
|
|
54
|
+
}
|
|
55
|
+
return content.join("\n\n");
|
|
56
|
+
}
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import type { TaskWithKey } from "@zinn-dev/core";
|
|
2
|
+
import type { RowCell } from "./row-layout.js";
|
|
2
3
|
import type { PresentedTask, PresentedTaskDetail } from "../result-schemas.js";
|
|
3
|
-
|
|
4
|
+
import type { ColumnBoard } from "./column-presentation.js";
|
|
5
|
+
export declare function taskPriorityCell(priority: PresentedTask["priority"], showsFullPriority: boolean): RowCell;
|
|
6
|
+
/** A task's label names on their own, colored as in a task row. */
|
|
7
|
+
export declare function formatLabelNames(labelNames: Array<string>): string;
|
|
8
|
+
export declare function presentTask(taskMatch: TaskWithKey, board?: ColumnBoard): PresentedTask;
|
|
4
9
|
export declare function formatTaskList(presentedTasks: Array<PresentedTask>, options?: {
|
|
5
10
|
showsStatus?: boolean;
|
|
6
11
|
showsFullPriority?: boolean;
|
|
7
12
|
prefix?: string;
|
|
13
|
+
/** Shows an expired claim too, and when each claim's lease ends */
|
|
14
|
+
showsClaimDetail?: boolean;
|
|
8
15
|
}): string;
|
|
9
16
|
export declare function formatTaskTimestamps(task: Pick<PresentedTaskDetail, "created_at" | "updated_at">): string;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { columnNameCell } from "./column-presentation.js";
|
|
1
|
+
import { label, task } from "@zinn-dev/core";
|
|
2
|
+
import { columnNameCell, columnPlacement, createColumnBoard } from "./column-presentation.js";
|
|
3
3
|
import { labelNameCell } from "./label-presentation.js";
|
|
4
4
|
import { formatCell, formatCellSeparator, formatRows } from "./row-layout.js";
|
|
5
5
|
import { formatLocalTime } from "./time.js";
|
|
6
|
+
import { formatActorLabel } from "./activity-presentation.js";
|
|
6
7
|
const EMPTY_CELL_MARKER = "-";
|
|
7
8
|
const LABEL_NAME_SEPARATOR = ", ";
|
|
8
|
-
function taskPriorityCell(priority, showsFullPriority) {
|
|
9
|
+
export function taskPriorityCell(priority, showsFullPriority) {
|
|
9
10
|
if (priority == null) {
|
|
10
11
|
return { text: EMPTY_CELL_MARKER, style: "dim" };
|
|
11
12
|
}
|
|
@@ -19,15 +20,30 @@ function taskPriorityCell(priority, showsFullPriority) {
|
|
|
19
20
|
function getLabelColorsByName() {
|
|
20
21
|
return new Map(label.getAll().map((labelMatch) => [labelMatch.name, labelMatch.color]));
|
|
21
22
|
}
|
|
22
|
-
|
|
23
|
+
function formatTaskLabelNames(labelNames, labelColorsByName) {
|
|
24
|
+
return labelNames
|
|
25
|
+
.map((labelName) => formatCell(labelNameCell(labelName, labelColorsByName.get(labelName))))
|
|
26
|
+
.join(LABEL_NAME_SEPARATOR);
|
|
27
|
+
}
|
|
28
|
+
/** A task's label names on their own, colored as in a task row. */
|
|
29
|
+
export function formatLabelNames(labelNames) {
|
|
30
|
+
return formatTaskLabelNames(labelNames, getLabelColorsByName());
|
|
31
|
+
}
|
|
32
|
+
export function presentTask(taskMatch, board = createColumnBoard()) {
|
|
23
33
|
const labels = task.label.getAll(taskMatch.key);
|
|
34
|
+
const projectColumns = board(taskMatch.project_id);
|
|
35
|
+
const columnMatch = projectColumns.find((boardColumn) => boardColumn.id === taskMatch.column_id);
|
|
36
|
+
const placement = columnPlacement(projectColumns, taskMatch.column_id);
|
|
24
37
|
return {
|
|
25
38
|
id: taskMatch.id,
|
|
26
39
|
key: taskMatch.key,
|
|
27
40
|
project_id: taskMatch.project_id,
|
|
28
41
|
status: taskMatch.archived_at == null ? "Active" : "Archived",
|
|
29
|
-
column:
|
|
42
|
+
column: columnMatch.name,
|
|
30
43
|
column_id: taskMatch.column_id,
|
|
44
|
+
is_first: placement.is_first,
|
|
45
|
+
is_last: placement.is_last,
|
|
46
|
+
column_category: columnMatch.category ?? null,
|
|
31
47
|
title: taskMatch.title,
|
|
32
48
|
description: taskMatch.description,
|
|
33
49
|
priority: taskMatch.priority,
|
|
@@ -36,8 +52,37 @@ export function presentTask(taskMatch) {
|
|
|
36
52
|
label_ids: labels.map((label) => label.id),
|
|
37
53
|
created_at: taskMatch.created_at,
|
|
38
54
|
updated_at: taskMatch.updated_at,
|
|
55
|
+
claim: presentClaim(taskMatch.claim),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function presentClaim(claim) {
|
|
59
|
+
if (claim == null) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
state: claim.state,
|
|
64
|
+
actor_kind: claim.actor_kind,
|
|
65
|
+
actor_name: claim.actor_name,
|
|
66
|
+
actor_session_id: claim.actor_session_id,
|
|
67
|
+
actor_thread_id: claim.actor_thread_id,
|
|
68
|
+
claimed_at: claim.claimed_at,
|
|
69
|
+
renewed_at: claim.renewed_at,
|
|
70
|
+
worked_at: claim.worked_at,
|
|
71
|
+
lease_ms: claim.lease_ms,
|
|
72
|
+
expires_at: claim.expires_at,
|
|
39
73
|
};
|
|
40
74
|
}
|
|
75
|
+
/** Who holds the claim, and when its lease ends or ended when `showsExpiry` is set */
|
|
76
|
+
function formatClaim(claim, showsExpiry) {
|
|
77
|
+
const holder = formatActorLabel(claim);
|
|
78
|
+
if (!showsExpiry) {
|
|
79
|
+
return `Claimed by ${holder}`;
|
|
80
|
+
}
|
|
81
|
+
const expiresAt = formatLocalTime(claim.expires_at, { includesSeconds: true });
|
|
82
|
+
return claim.state === "live"
|
|
83
|
+
? `Claimed by ${holder} until ${expiresAt}`
|
|
84
|
+
: `Claim by ${holder} expired at ${expiresAt}`;
|
|
85
|
+
}
|
|
41
86
|
export function formatTaskList(presentedTasks, options = {}) {
|
|
42
87
|
const labelColorsByName = getLabelColorsByName();
|
|
43
88
|
return formatRows(presentedTasks.map((presentedTask) => {
|
|
@@ -46,19 +91,23 @@ export function formatTaskList(presentedTasks, options = {}) {
|
|
|
46
91
|
: [];
|
|
47
92
|
const hasLabels = presentedTask.labels.length > 0;
|
|
48
93
|
// The last cell is never padded, so the color codes in its separator and label names do not affect column widths.
|
|
49
|
-
const labelNames = presentedTask.labels
|
|
50
|
-
.map((labelName) => formatCell(labelNameCell(labelName, labelColorsByName.get(labelName))))
|
|
51
|
-
.join(LABEL_NAME_SEPARATOR);
|
|
94
|
+
const labelNames = formatTaskLabelNames(presentedTask.labels, labelColorsByName);
|
|
52
95
|
const labels = hasLabels ? `${formatCellSeparator()}${labelNames}` : "";
|
|
53
96
|
const deadline = presentedTask.due_at == null
|
|
54
97
|
? ""
|
|
55
98
|
: `${formatCellSeparator()}Due ${formatLocalTime(presentedTask.due_at, { includesSeconds: true })}`;
|
|
99
|
+
const showsClaimDetail = options.showsClaimDetail ?? false;
|
|
100
|
+
const claim = presentedTask.claim;
|
|
101
|
+
const showsClaim = claim != null && (claim.state === "live" || showsClaimDetail);
|
|
102
|
+
const claimText = showsClaim
|
|
103
|
+
? `${formatCellSeparator()}${formatClaim(claim, showsClaimDetail)}`
|
|
104
|
+
: "";
|
|
56
105
|
return [
|
|
57
106
|
{ text: `${options.prefix ?? ""}${presentedTask.key}` },
|
|
58
107
|
...statusCells,
|
|
59
|
-
columnNameCell(presentedTask.column),
|
|
108
|
+
columnNameCell(presentedTask.column, presentedTask.column_category),
|
|
60
109
|
taskPriorityCell(presentedTask.priority, options.showsFullPriority ?? false),
|
|
61
|
-
{ text: `${presentedTask.title}${deadline}${labels}` },
|
|
110
|
+
{ text: `${presentedTask.title}${deadline}${claimText}${labels}` },
|
|
62
111
|
];
|
|
63
112
|
}));
|
|
64
113
|
}
|