@zinn-dev/cli 0.39.0 → 0.41.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 +171 -40
- package/index.d.ts +2 -0
- package/index.js +34 -0
- package/package.json +27 -18
- package/skills/zinn/SKILL.md +63 -0
- package/src/actor.d.ts +7 -0
- package/src/actor.js +129 -0
- package/src/capabilities-schema.d.ts +163 -0
- package/src/capabilities-schema.js +124 -0
- package/src/capabilities.d.ts +21 -0
- package/src/capabilities.js +22 -0
- package/src/database.d.ts +6 -0
- package/src/database.js +27 -0
- package/src/errors.d.ts +158 -0
- package/src/errors.js +224 -0
- package/src/input.d.ts +116 -0
- package/src/input.js +119 -0
- package/src/lib.d.ts +66 -0
- package/src/lib.js +333 -0
- package/src/presentation/activity-presentation.d.ts +23 -0
- package/src/presentation/activity-presentation.js +403 -0
- package/src/presentation/color.d.ts +9 -0
- package/src/presentation/color.js +21 -0
- package/src/presentation/column-presentation.d.ts +14 -0
- package/src/presentation/column-presentation.js +29 -0
- package/src/presentation/description-presentation.d.ts +3 -0
- package/src/presentation/description-presentation.js +11 -0
- package/src/presentation/info-presentation.d.ts +4 -0
- package/src/presentation/info-presentation.js +96 -0
- package/src/presentation/row-layout.d.ts +22 -0
- package/src/presentation/row-layout.js +58 -0
- package/src/presentation/section.d.ts +4 -0
- package/src/presentation/section.js +9 -0
- package/src/presentation/task-presentation.d.ts +9 -0
- package/src/presentation/task-presentation.js +62 -0
- package/src/presentation/time.d.ts +1 -0
- package/src/presentation/time.js +13 -0
- package/src/project.d.ts +12 -0
- package/src/project.js +44 -0
- package/src/release-identity.d.ts +2 -0
- package/src/release-identity.js +1 -0
- package/src/result-schemas.d.ts +987 -0
- package/src/result-schemas.js +220 -0
- package/src/results.d.ts +23 -0
- package/src/results.js +17 -0
- package/src/routes/activity-router.d.ts +81 -0
- package/src/routes/activity-router.js +119 -0
- package/src/routes/backup-router.d.ts +21 -0
- package/src/routes/backup-router.js +30 -0
- package/src/routes/capabilities-router.d.ts +21 -0
- package/src/routes/capabilities-router.js +28 -0
- package/src/routes/comment-router.d.ts +203 -0
- package/src/routes/comment-router.js +241 -0
- package/src/routes/info-router.d.ts +21 -0
- package/src/routes/info-router.js +29 -0
- package/src/routes/label-router.d.ts +183 -0
- package/src/routes/label-router.js +218 -0
- package/src/routes/migrate-router.d.ts +21 -0
- package/src/routes/migrate-router.js +49 -0
- package/src/routes/project-router.d.ts +389 -0
- package/src/routes/project-router.js +514 -0
- package/src/routes/reindex-router.d.ts +21 -0
- package/src/routes/reindex-router.js +33 -0
- package/src/routes/relation-router.d.ts +124 -0
- package/src/routes/relation-router.js +223 -0
- package/src/routes/restore-router.d.ts +33 -0
- package/src/routes/restore-router.js +88 -0
- package/src/routes/router.d.ts +6 -0
- package/src/routes/router.js +204 -0
- package/src/routes/routes.d.ts +1735 -0
- package/src/routes/routes.js +23 -0
- package/src/routes/task-router.d.ts +945 -0
- package/src/routes/task-router.js +789 -0
- package/src/text-edit.d.ts +43 -0
- package/src/text-edit.js +57 -0
- package/src/types.d.ts +24 -0
- package/src/types.js +1 -0
- package/index.ts +0 -26
- package/release-stamp.json +0 -1
- package/src/actor.test.ts +0 -41
- package/src/actor.ts +0 -78
- package/src/database.test.ts +0 -70
- package/src/database.ts +0 -41
- package/src/lib.test.ts +0 -86
- package/src/lib.ts +0 -159
- package/src/presentation/activity-presentation.test.ts +0 -112
- package/src/presentation/activity-presentation.ts +0 -490
- package/src/presentation/color.ts +0 -29
- package/src/presentation/column-presentation.ts +0 -48
- package/src/presentation/description-presentation.ts +0 -18
- package/src/presentation/row-layout.ts +0 -77
- package/src/presentation/section.ts +0 -16
- package/src/presentation/task-presentation.ts +0 -92
- package/src/presentation/time.ts +0 -17
- package/src/project.test.ts +0 -479
- package/src/project.ts +0 -53
- package/src/routes/activity-router.ts +0 -81
- package/src/routes/backup-router.ts +0 -24
- package/src/routes/comment-router.ts +0 -171
- package/src/routes/label-router.ts +0 -168
- package/src/routes/migrate-router.test.ts +0 -31
- package/src/routes/migrate-router.ts +0 -48
- package/src/routes/project-router.ts +0 -415
- package/src/routes/reindex-router.ts +0 -27
- package/src/routes/relation-router.ts +0 -194
- package/src/routes/restore-router.test.ts +0 -44
- package/src/routes/restore-router.ts +0 -90
- package/src/routes/router.test.ts +0 -136
- package/src/routes/router.ts +0 -248
- package/src/routes/routes.ts +0 -20
- package/src/routes/task-router.ts +0 -649
- package/src/text-edit.ts +0 -68
- package/src/types.ts +0 -6
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { styleOutputText } from "./color.js";
|
|
2
|
+
/** A bold heading above its body, optionally preceded by a dim horizontal rule. */
|
|
3
|
+
export function formatSection(heading, body, options = {}) {
|
|
4
|
+
const section = `${styleOutputText("bold", `${heading}:`)}\n${body}`;
|
|
5
|
+
if (options.separatorWidth === undefined) {
|
|
6
|
+
return section;
|
|
7
|
+
}
|
|
8
|
+
return `${styleOutputText("dim", "-".repeat(options.separatorWidth))}\n${section}`;
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { TaskWithKey } from "@zinn-dev/core";
|
|
2
|
+
import type { PresentedTask } from "../result-schemas.js";
|
|
3
|
+
export declare function presentTask(taskMatch: TaskWithKey): PresentedTask;
|
|
4
|
+
export declare function formatTaskRow(presented: PresentedTask): string;
|
|
5
|
+
export declare function formatTaskList(presentedTasks: Array<PresentedTask>, options?: {
|
|
6
|
+
showsStatus?: boolean;
|
|
7
|
+
showsFullPriority?: boolean;
|
|
8
|
+
}): string;
|
|
9
|
+
export declare function formatTaskListWithStatus(presentedTasks: Array<PresentedTask>): string;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { column, label, task } from "@zinn-dev/core";
|
|
2
|
+
import { styleOutputText } from "./color.js";
|
|
3
|
+
import { columnNameCell } from "./column-presentation.js";
|
|
4
|
+
import { formatCellSeparator, formatRows } from "./row-layout.js";
|
|
5
|
+
const EMPTY_CELL_MARKER = "-";
|
|
6
|
+
const LABEL_NAME_SEPARATOR = ", ";
|
|
7
|
+
function taskPriorityCell(priority, showsFullPriority) {
|
|
8
|
+
if (priority == null) {
|
|
9
|
+
return { text: EMPTY_CELL_MARKER, style: "dim" };
|
|
10
|
+
}
|
|
11
|
+
const priorityInitial = priority[0].toUpperCase();
|
|
12
|
+
return { text: showsFullPriority ? `${priorityInitial}${priority.slice(1)}` : priorityInitial };
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* `PresentedTask` carries label names only, so JSON stays a list of names.
|
|
16
|
+
* Text output looks the colors up from the label definitions instead.
|
|
17
|
+
*/
|
|
18
|
+
function getLabelColorsByName() {
|
|
19
|
+
return new Map(label.getAll().map((labelMatch) => [labelMatch.name, labelMatch.color]));
|
|
20
|
+
}
|
|
21
|
+
function formatLabelNames(labelNames, labelColorsByName) {
|
|
22
|
+
return labelNames
|
|
23
|
+
.map((labelName) => styleOutputText(labelColorsByName.get(labelName), labelName))
|
|
24
|
+
.join(LABEL_NAME_SEPARATOR);
|
|
25
|
+
}
|
|
26
|
+
export function presentTask(taskMatch) {
|
|
27
|
+
return {
|
|
28
|
+
key: taskMatch.key,
|
|
29
|
+
status: taskMatch.archived_at == null ? "Active" : "Archived",
|
|
30
|
+
column: column.getById(taskMatch.column_id).name,
|
|
31
|
+
title: taskMatch.title,
|
|
32
|
+
description: taskMatch.description,
|
|
33
|
+
priority: taskMatch.priority,
|
|
34
|
+
labels: task.label.getAll(taskMatch.key).map((label) => label.name),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export function formatTaskRow(presented) {
|
|
38
|
+
return formatTaskList([presented]);
|
|
39
|
+
}
|
|
40
|
+
export function formatTaskList(presentedTasks, options = {}) {
|
|
41
|
+
const labelColorsByName = getLabelColorsByName();
|
|
42
|
+
return formatRows(presentedTasks.map((presentedTask) => {
|
|
43
|
+
const statusCells = options.showsStatus
|
|
44
|
+
? [{ text: presentedTask.status }]
|
|
45
|
+
: [];
|
|
46
|
+
const hasLabels = presentedTask.labels.length > 0;
|
|
47
|
+
// The last cell is never padded, so the color codes in its separator and label names do not affect column widths.
|
|
48
|
+
const labels = hasLabels
|
|
49
|
+
? `${formatCellSeparator()}${formatLabelNames(presentedTask.labels, labelColorsByName)}`
|
|
50
|
+
: "";
|
|
51
|
+
return [
|
|
52
|
+
{ text: presentedTask.key },
|
|
53
|
+
...statusCells,
|
|
54
|
+
columnNameCell(presentedTask.column),
|
|
55
|
+
taskPriorityCell(presentedTask.priority, options.showsFullPriority ?? false),
|
|
56
|
+
{ text: `${presentedTask.title}${labels}` },
|
|
57
|
+
];
|
|
58
|
+
}));
|
|
59
|
+
}
|
|
60
|
+
export function formatTaskListWithStatus(presentedTasks) {
|
|
61
|
+
return formatTaskList(presentedTasks, { showsStatus: true });
|
|
62
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function formatLocalTime(timestamp: number): string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const MINUTES_PER_HOUR = 60;
|
|
2
|
+
export function formatLocalTime(timestamp) {
|
|
3
|
+
const date = new Date(timestamp);
|
|
4
|
+
const offsetMinutes = -date.getTimezoneOffset();
|
|
5
|
+
const offsetSign = offsetMinutes >= 0 ? "+" : "-";
|
|
6
|
+
const absoluteOffsetMinutes = Math.abs(offsetMinutes);
|
|
7
|
+
const offsetHours = Math.floor(absoluteOffsetMinutes / MINUTES_PER_HOUR);
|
|
8
|
+
const remainingOffsetMinutes = absoluteOffsetMinutes % MINUTES_PER_HOUR;
|
|
9
|
+
const pad = (value) => String(value).padStart(2, "0");
|
|
10
|
+
return (`${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ` +
|
|
11
|
+
`${pad(date.getHours())}:${pad(date.getMinutes())} ` +
|
|
12
|
+
`${offsetSign}${pad(offsetHours)}:${pad(remainingOffsetMinutes)}`);
|
|
13
|
+
}
|
package/src/project.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const projectScopeConstraint: {
|
|
2
|
+
readonly kind: "exclusive";
|
|
3
|
+
readonly members: readonly ["positional:project-key", "option:all-projects"];
|
|
4
|
+
};
|
|
5
|
+
export declare const requiredProjectDescription = "An omitted project key uses defaultProject from settings. Without a configured default, a project key is required. A missing configured project is an error.";
|
|
6
|
+
export declare const projectScopeDescription = "An omitted project key defaults to all projects unless defaultProject is configured. --all-projects overrides the defaultProject and excludes a typed project. A missing configured project is an error.";
|
|
7
|
+
/** Chooses the explicit project or the configured default, retaining unscoped list/search behavior. */
|
|
8
|
+
export declare function resolveProjectKey(typedKey: string | undefined, { required, allProjects, useDefault, }?: {
|
|
9
|
+
required?: boolean;
|
|
10
|
+
allProjects?: boolean;
|
|
11
|
+
useDefault?: boolean;
|
|
12
|
+
}): string | undefined;
|
package/src/project.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { homedir } from "node:os";
|
|
2
|
+
import { chooseDefaultProject, project, resolveSettings } from "@zinn-dev/core";
|
|
3
|
+
import { UsageError } from "./lib.js";
|
|
4
|
+
import { CliError } from "./errors.js";
|
|
5
|
+
import { violatesConstraint } from "./input.js";
|
|
6
|
+
export const projectScopeConstraint = {
|
|
7
|
+
kind: "exclusive",
|
|
8
|
+
members: ["positional:project-key", "option:all-projects"],
|
|
9
|
+
};
|
|
10
|
+
export const requiredProjectDescription = "An omitted project key uses defaultProject from settings. Without a configured default, a project key is required. A missing configured project is an error.";
|
|
11
|
+
export const projectScopeDescription = "An omitted project key defaults to all projects unless defaultProject is configured. --all-projects overrides the defaultProject and excludes a typed project. A missing configured project is an error.";
|
|
12
|
+
/** Chooses the explicit project or the configured default, retaining unscoped list/search behavior. */
|
|
13
|
+
export function resolveProjectKey(typedKey, { required = false, allProjects = false, useDefault = true, } = {}) {
|
|
14
|
+
if (allProjects) {
|
|
15
|
+
if (violatesConstraint(projectScopeConstraint, {
|
|
16
|
+
"positional:project-key": typedKey,
|
|
17
|
+
"option:all-projects": allProjects,
|
|
18
|
+
})) {
|
|
19
|
+
throw new UsageError("--all-projects cannot be combined with a project key", {
|
|
20
|
+
argument: "--all-projects",
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
if (typedKey !== undefined) {
|
|
26
|
+
return typedKey;
|
|
27
|
+
}
|
|
28
|
+
if (!useDefault) {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
const settings = resolveSettings({ cwd: process.cwd(), env: process.env, home: homedir() });
|
|
32
|
+
const defaultProject = chooseDefaultProject(settings);
|
|
33
|
+
if (defaultProject === null) {
|
|
34
|
+
if (required) {
|
|
35
|
+
throw new UsageError("Missing argument <project-key>. Supply a key or configure defaultProject", { argument: "project-key" });
|
|
36
|
+
}
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
const { key, settingsPath } = defaultProject;
|
|
40
|
+
if (project.getByKey(key) == null) {
|
|
41
|
+
throw new CliError(`Default project "${key}" from settings file ${settingsPath} does not exist`, "not_found", { entity: "project", key, source: "defaultProject", settingsPath });
|
|
42
|
+
}
|
|
43
|
+
return key;
|
|
44
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const RELEASE_MODE = "published";
|