@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
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { column, label, task } from "@zinn-dev/core";
|
|
2
|
-
import { styleOutputText } from "./color.js";
|
|
3
2
|
import { columnNameCell } from "./column-presentation.js";
|
|
4
|
-
import {
|
|
3
|
+
import { labelNameCell } from "./label-presentation.js";
|
|
4
|
+
import { formatCell, formatCellSeparator, formatRows } from "./row-layout.js";
|
|
5
|
+
import { formatLocalTime } from "./time.js";
|
|
5
6
|
const EMPTY_CELL_MARKER = "-";
|
|
6
7
|
const LABEL_NAME_SEPARATOR = ", ";
|
|
7
8
|
function taskPriorityCell(priority, showsFullPriority) {
|
|
@@ -12,31 +13,31 @@ function taskPriorityCell(priority, showsFullPriority) {
|
|
|
12
13
|
return { text: showsFullPriority ? `${priorityInitial}${priority.slice(1)}` : priorityInitial };
|
|
13
14
|
}
|
|
14
15
|
/**
|
|
15
|
-
* `PresentedTask` carries label names
|
|
16
|
+
* `PresentedTask` carries label names and IDs, without colors.
|
|
16
17
|
* Text output looks the colors up from the label definitions instead.
|
|
17
18
|
*/
|
|
18
19
|
function getLabelColorsByName() {
|
|
19
20
|
return new Map(label.getAll().map((labelMatch) => [labelMatch.name, labelMatch.color]));
|
|
20
21
|
}
|
|
21
|
-
function formatLabelNames(labelNames, labelColorsByName) {
|
|
22
|
-
return labelNames
|
|
23
|
-
.map((labelName) => styleOutputText(labelColorsByName.get(labelName), labelName))
|
|
24
|
-
.join(LABEL_NAME_SEPARATOR);
|
|
25
|
-
}
|
|
26
22
|
export function presentTask(taskMatch) {
|
|
23
|
+
const labels = task.label.getAll(taskMatch.key);
|
|
27
24
|
return {
|
|
25
|
+
id: taskMatch.id,
|
|
28
26
|
key: taskMatch.key,
|
|
27
|
+
project_id: taskMatch.project_id,
|
|
29
28
|
status: taskMatch.archived_at == null ? "Active" : "Archived",
|
|
30
29
|
column: column.getById(taskMatch.column_id).name,
|
|
30
|
+
column_id: taskMatch.column_id,
|
|
31
31
|
title: taskMatch.title,
|
|
32
32
|
description: taskMatch.description,
|
|
33
33
|
priority: taskMatch.priority,
|
|
34
|
-
|
|
34
|
+
due_at: taskMatch.due_at ?? null,
|
|
35
|
+
labels: labels.map((label) => label.name),
|
|
36
|
+
label_ids: labels.map((label) => label.id),
|
|
37
|
+
created_at: taskMatch.created_at,
|
|
38
|
+
updated_at: taskMatch.updated_at,
|
|
35
39
|
};
|
|
36
40
|
}
|
|
37
|
-
export function formatTaskRow(presented) {
|
|
38
|
-
return formatTaskList([presented]);
|
|
39
|
-
}
|
|
40
41
|
export function formatTaskList(presentedTasks, options = {}) {
|
|
41
42
|
const labelColorsByName = getLabelColorsByName();
|
|
42
43
|
return formatRows(presentedTasks.map((presentedTask) => {
|
|
@@ -45,18 +46,27 @@ export function formatTaskList(presentedTasks, options = {}) {
|
|
|
45
46
|
: [];
|
|
46
47
|
const hasLabels = presentedTask.labels.length > 0;
|
|
47
48
|
// The last cell is never padded, so the color codes in its separator and label names do not affect column widths.
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
const labelNames = presentedTask.labels
|
|
50
|
+
.map((labelName) => formatCell(labelNameCell(labelName, labelColorsByName.get(labelName))))
|
|
51
|
+
.join(LABEL_NAME_SEPARATOR);
|
|
52
|
+
const labels = hasLabels ? `${formatCellSeparator()}${labelNames}` : "";
|
|
53
|
+
const deadline = presentedTask.due_at == null
|
|
54
|
+
? ""
|
|
55
|
+
: `${formatCellSeparator()}Due ${formatLocalTime(presentedTask.due_at, { includesSeconds: true })}`;
|
|
51
56
|
return [
|
|
52
|
-
{ text: presentedTask.key },
|
|
57
|
+
{ text: `${options.prefix ?? ""}${presentedTask.key}` },
|
|
53
58
|
...statusCells,
|
|
54
59
|
columnNameCell(presentedTask.column),
|
|
55
60
|
taskPriorityCell(presentedTask.priority, options.showsFullPriority ?? false),
|
|
56
|
-
{ text: `${presentedTask.title}${labels}` },
|
|
61
|
+
{ text: `${presentedTask.title}${deadline}${labels}` },
|
|
57
62
|
];
|
|
58
63
|
}));
|
|
59
64
|
}
|
|
60
|
-
export function
|
|
61
|
-
return
|
|
65
|
+
export function formatTaskTimestamps(task) {
|
|
66
|
+
return formatRows([
|
|
67
|
+
[
|
|
68
|
+
{ text: `Task created at: ${formatLocalTime(task.created_at)}`, style: "dim" },
|
|
69
|
+
{ text: `Task updated at: ${formatLocalTime(task.updated_at)}`, style: "dim" },
|
|
70
|
+
],
|
|
71
|
+
]);
|
|
62
72
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const PRINTABLE_ASCII = /^[\x20-\x7e]*$/;
|
|
2
|
+
const ZERO_WIDTH_CODE_POINT = /^[\p{Mark}\p{Default_Ignorable_Code_Point}\p{Cc}]$/u;
|
|
3
|
+
// The constructor permits Unicode-set matching with the ES2023 declaration target.
|
|
4
|
+
const RGI_EMOJI = new RegExp("^\\p{RGI_Emoji}$", "v");
|
|
5
|
+
const segmenter = new Intl.Segmenter(undefined, { granularity: "grapheme" });
|
|
6
|
+
export function graphemes(text) {
|
|
7
|
+
return segmenter.segment(text);
|
|
8
|
+
}
|
|
9
|
+
function isWideEastAsian(codePoint) {
|
|
10
|
+
// Unicode EastAsianWidth.txt lists the Hangul, CJK, kana, Yi and fullwidth blocks below.
|
|
11
|
+
// https://www.unicode.org/Public/18.0.0/ucd/EastAsianWidth.txt
|
|
12
|
+
return ((codePoint >= 0x1100 && codePoint <= 0x115f) ||
|
|
13
|
+
codePoint === 0x2329 ||
|
|
14
|
+
codePoint === 0x232a ||
|
|
15
|
+
(codePoint >= 0x2e80 && codePoint <= 0xa4cf) ||
|
|
16
|
+
(codePoint >= 0xac00 && codePoint <= 0xd7a3) ||
|
|
17
|
+
(codePoint >= 0xf900 && codePoint <= 0xfaff) ||
|
|
18
|
+
(codePoint >= 0xfe10 && codePoint <= 0xfe19) ||
|
|
19
|
+
(codePoint >= 0xfe30 && codePoint <= 0xfe6f) ||
|
|
20
|
+
(codePoint >= 0xff01 && codePoint <= 0xff60) ||
|
|
21
|
+
(codePoint >= 0xffe0 && codePoint <= 0xffe6) ||
|
|
22
|
+
(codePoint >= 0x1aff0 && codePoint <= 0x1afff) ||
|
|
23
|
+
(codePoint >= 0x1b000 && codePoint <= 0x1b2ff) ||
|
|
24
|
+
(codePoint >= 0x20000 && codePoint <= 0x3fffd));
|
|
25
|
+
}
|
|
26
|
+
export function displayWidth(text) {
|
|
27
|
+
if (PRINTABLE_ASCII.test(text)) {
|
|
28
|
+
return text.length;
|
|
29
|
+
}
|
|
30
|
+
let width = 0;
|
|
31
|
+
for (const { segment } of graphemes(text)) {
|
|
32
|
+
if ([...segment].every((point) => ZERO_WIDTH_CODE_POINT.test(point))) {
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
if (RGI_EMOJI.test(segment) || isWideEastAsian(segment.codePointAt(0))) {
|
|
36
|
+
width += 2;
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
width += 1;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return width;
|
|
43
|
+
}
|
package/src/presentation/time.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const MINUTES_PER_HOUR = 60;
|
|
2
|
-
export function formatLocalTime(timestamp) {
|
|
2
|
+
export function formatLocalTime(timestamp, options = {}) {
|
|
3
3
|
const date = new Date(timestamp);
|
|
4
4
|
const offsetMinutes = -date.getTimezoneOffset();
|
|
5
5
|
const offsetSign = offsetMinutes >= 0 ? "+" : "-";
|
|
@@ -7,7 +7,10 @@ export function formatLocalTime(timestamp) {
|
|
|
7
7
|
const offsetHours = Math.floor(absoluteOffsetMinutes / MINUTES_PER_HOUR);
|
|
8
8
|
const remainingOffsetMinutes = absoluteOffsetMinutes % MINUTES_PER_HOUR;
|
|
9
9
|
const pad = (value) => String(value).padStart(2, "0");
|
|
10
|
+
const milliseconds = date.getMilliseconds();
|
|
11
|
+
const fraction = milliseconds === 0 ? "" : `.${String(milliseconds).padStart(3, "0")}`;
|
|
12
|
+
const seconds = options.includesSeconds ? `:${pad(date.getSeconds())}${fraction}` : "";
|
|
10
13
|
return (`${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ` +
|
|
11
|
-
`${pad(date.getHours())}:${pad(date.getMinutes())} ` +
|
|
14
|
+
`${pad(date.getHours())}:${pad(date.getMinutes())}${seconds} ` +
|
|
12
15
|
`${offsetSign}${pad(offsetHours)}:${pad(remainingOffsetMinutes)}`);
|
|
13
16
|
}
|
package/src/project.d.ts
CHANGED
|
@@ -2,11 +2,20 @@ export declare const projectScopeConstraint: {
|
|
|
2
2
|
readonly kind: "exclusive";
|
|
3
3
|
readonly members: readonly ["positional:project-key", "option:all-projects"];
|
|
4
4
|
};
|
|
5
|
-
export declare const requiredProjectDescription = "
|
|
6
|
-
export declare const projectScopeDescription = "An omitted project key
|
|
7
|
-
|
|
8
|
-
export declare function resolveProjectKey(typedKey: string | undefined, { required, allProjects, useDefault, }?: {
|
|
5
|
+
export declare const requiredProjectDescription = "Omit the project key to use defaultProject from settings; otherwise a project key is required.";
|
|
6
|
+
export declare const projectScopeDescription = "An omitted project key uses defaultProject, or all projects if unset. --all-projects overrides the default and cannot be combined with a project key.";
|
|
7
|
+
type ProjectKeyOptions = {
|
|
9
8
|
required?: boolean;
|
|
10
9
|
allProjects?: boolean;
|
|
11
10
|
useDefault?: boolean;
|
|
12
|
-
}
|
|
11
|
+
};
|
|
12
|
+
type ProjectKeyChoice = {
|
|
13
|
+
key: string;
|
|
14
|
+
settingsPath?: string;
|
|
15
|
+
};
|
|
16
|
+
/** Chooses the explicit project or the configured default, retaining unscoped list/search behavior. */
|
|
17
|
+
export declare function resolveProjectKey(typedKey: string | undefined, options?: ProjectKeyOptions): string | undefined;
|
|
18
|
+
export declare function chooseProjectKey(typedKey: string | undefined, { required, allProjects, useDefault }?: ProjectKeyOptions): ProjectKeyChoice | undefined;
|
|
19
|
+
/** Fails when the key came from defaultProject and that project does not exist. */
|
|
20
|
+
export declare function checkDefaultProject({ key, settingsPath }: ProjectKeyChoice): void;
|
|
21
|
+
export {};
|
package/src/project.js
CHANGED
|
@@ -7,10 +7,17 @@ export const projectScopeConstraint = {
|
|
|
7
7
|
kind: "exclusive",
|
|
8
8
|
members: ["positional:project-key", "option:all-projects"],
|
|
9
9
|
};
|
|
10
|
-
export const requiredProjectDescription = "
|
|
11
|
-
export const projectScopeDescription = "An omitted project key
|
|
10
|
+
export const requiredProjectDescription = "Omit the project key to use defaultProject from settings; otherwise a project key is required.";
|
|
11
|
+
export const projectScopeDescription = "An omitted project key uses defaultProject, or all projects if unset. --all-projects overrides the default and cannot be combined with a project key.";
|
|
12
12
|
/** Chooses the explicit project or the configured default, retaining unscoped list/search behavior. */
|
|
13
|
-
export function resolveProjectKey(typedKey,
|
|
13
|
+
export function resolveProjectKey(typedKey, options = {}) {
|
|
14
|
+
const choice = chooseProjectKey(typedKey, options);
|
|
15
|
+
if (choice !== undefined) {
|
|
16
|
+
checkDefaultProject(choice);
|
|
17
|
+
}
|
|
18
|
+
return choice?.key;
|
|
19
|
+
}
|
|
20
|
+
export function chooseProjectKey(typedKey, { required = false, allProjects = false, useDefault = true } = {}) {
|
|
14
21
|
if (allProjects) {
|
|
15
22
|
if (violatesConstraint(projectScopeConstraint, {
|
|
16
23
|
"positional:project-key": typedKey,
|
|
@@ -23,7 +30,7 @@ export function resolveProjectKey(typedKey, { required = false, allProjects = fa
|
|
|
23
30
|
return undefined;
|
|
24
31
|
}
|
|
25
32
|
if (typedKey !== undefined) {
|
|
26
|
-
return typedKey;
|
|
33
|
+
return { key: typedKey };
|
|
27
34
|
}
|
|
28
35
|
if (!useDefault) {
|
|
29
36
|
return undefined;
|
|
@@ -36,9 +43,14 @@ export function resolveProjectKey(typedKey, { required = false, allProjects = fa
|
|
|
36
43
|
}
|
|
37
44
|
return undefined;
|
|
38
45
|
}
|
|
39
|
-
|
|
46
|
+
return defaultProject;
|
|
47
|
+
}
|
|
48
|
+
/** Fails when the key came from defaultProject and that project does not exist. */
|
|
49
|
+
export function checkDefaultProject({ key, settingsPath }) {
|
|
50
|
+
if (settingsPath === undefined) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
40
53
|
if (project.getByKey(key) == null) {
|
|
41
54
|
throw new CliError(`Default project "${key}" from settings file ${settingsPath} does not exist`, "not_found", { entity: "project", key, source: "defaultProject", settingsPath });
|
|
42
55
|
}
|
|
43
|
-
return key;
|
|
44
56
|
}
|