@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.
Files changed (113) hide show
  1. package/README.md +171 -40
  2. package/index.d.ts +2 -0
  3. package/index.js +34 -0
  4. package/package.json +27 -18
  5. package/skills/zinn/SKILL.md +63 -0
  6. package/src/actor.d.ts +7 -0
  7. package/src/actor.js +129 -0
  8. package/src/capabilities-schema.d.ts +163 -0
  9. package/src/capabilities-schema.js +124 -0
  10. package/src/capabilities.d.ts +21 -0
  11. package/src/capabilities.js +22 -0
  12. package/src/database.d.ts +6 -0
  13. package/src/database.js +27 -0
  14. package/src/errors.d.ts +158 -0
  15. package/src/errors.js +224 -0
  16. package/src/input.d.ts +116 -0
  17. package/src/input.js +119 -0
  18. package/src/lib.d.ts +66 -0
  19. package/src/lib.js +333 -0
  20. package/src/presentation/activity-presentation.d.ts +23 -0
  21. package/src/presentation/activity-presentation.js +403 -0
  22. package/src/presentation/color.d.ts +9 -0
  23. package/src/presentation/color.js +21 -0
  24. package/src/presentation/column-presentation.d.ts +14 -0
  25. package/src/presentation/column-presentation.js +29 -0
  26. package/src/presentation/description-presentation.d.ts +3 -0
  27. package/src/presentation/description-presentation.js +11 -0
  28. package/src/presentation/info-presentation.d.ts +4 -0
  29. package/src/presentation/info-presentation.js +96 -0
  30. package/src/presentation/row-layout.d.ts +22 -0
  31. package/src/presentation/row-layout.js +58 -0
  32. package/src/presentation/section.d.ts +4 -0
  33. package/src/presentation/section.js +9 -0
  34. package/src/presentation/task-presentation.d.ts +9 -0
  35. package/src/presentation/task-presentation.js +62 -0
  36. package/src/presentation/time.d.ts +1 -0
  37. package/src/presentation/time.js +13 -0
  38. package/src/project.d.ts +12 -0
  39. package/src/project.js +44 -0
  40. package/src/release-identity.d.ts +2 -0
  41. package/src/release-identity.js +1 -0
  42. package/src/result-schemas.d.ts +987 -0
  43. package/src/result-schemas.js +220 -0
  44. package/src/results.d.ts +23 -0
  45. package/src/results.js +17 -0
  46. package/src/routes/activity-router.d.ts +81 -0
  47. package/src/routes/activity-router.js +119 -0
  48. package/src/routes/backup-router.d.ts +21 -0
  49. package/src/routes/backup-router.js +30 -0
  50. package/src/routes/capabilities-router.d.ts +21 -0
  51. package/src/routes/capabilities-router.js +28 -0
  52. package/src/routes/comment-router.d.ts +203 -0
  53. package/src/routes/comment-router.js +241 -0
  54. package/src/routes/info-router.d.ts +21 -0
  55. package/src/routes/info-router.js +29 -0
  56. package/src/routes/label-router.d.ts +183 -0
  57. package/src/routes/label-router.js +218 -0
  58. package/src/routes/migrate-router.d.ts +21 -0
  59. package/src/routes/migrate-router.js +49 -0
  60. package/src/routes/project-router.d.ts +389 -0
  61. package/src/routes/project-router.js +514 -0
  62. package/src/routes/reindex-router.d.ts +21 -0
  63. package/src/routes/reindex-router.js +33 -0
  64. package/src/routes/relation-router.d.ts +124 -0
  65. package/src/routes/relation-router.js +223 -0
  66. package/src/routes/restore-router.d.ts +33 -0
  67. package/src/routes/restore-router.js +88 -0
  68. package/src/routes/router.d.ts +6 -0
  69. package/src/routes/router.js +204 -0
  70. package/src/routes/routes.d.ts +1735 -0
  71. package/src/routes/routes.js +23 -0
  72. package/src/routes/task-router.d.ts +945 -0
  73. package/src/routes/task-router.js +789 -0
  74. package/src/text-edit.d.ts +43 -0
  75. package/src/text-edit.js +57 -0
  76. package/src/types.d.ts +24 -0
  77. package/src/types.js +1 -0
  78. package/index.ts +0 -26
  79. package/release-stamp.json +0 -1
  80. package/src/actor.test.ts +0 -41
  81. package/src/actor.ts +0 -78
  82. package/src/database.test.ts +0 -70
  83. package/src/database.ts +0 -41
  84. package/src/lib.test.ts +0 -86
  85. package/src/lib.ts +0 -159
  86. package/src/presentation/activity-presentation.test.ts +0 -112
  87. package/src/presentation/activity-presentation.ts +0 -490
  88. package/src/presentation/color.ts +0 -29
  89. package/src/presentation/column-presentation.ts +0 -48
  90. package/src/presentation/description-presentation.ts +0 -18
  91. package/src/presentation/row-layout.ts +0 -77
  92. package/src/presentation/section.ts +0 -16
  93. package/src/presentation/task-presentation.ts +0 -92
  94. package/src/presentation/time.ts +0 -17
  95. package/src/project.test.ts +0 -479
  96. package/src/project.ts +0 -53
  97. package/src/routes/activity-router.ts +0 -81
  98. package/src/routes/backup-router.ts +0 -24
  99. package/src/routes/comment-router.ts +0 -171
  100. package/src/routes/label-router.ts +0 -168
  101. package/src/routes/migrate-router.test.ts +0 -31
  102. package/src/routes/migrate-router.ts +0 -48
  103. package/src/routes/project-router.ts +0 -415
  104. package/src/routes/reindex-router.ts +0 -27
  105. package/src/routes/relation-router.ts +0 -194
  106. package/src/routes/restore-router.test.ts +0 -44
  107. package/src/routes/restore-router.ts +0 -90
  108. package/src/routes/router.test.ts +0 -136
  109. package/src/routes/router.ts +0 -248
  110. package/src/routes/routes.ts +0 -20
  111. package/src/routes/task-router.ts +0 -649
  112. package/src/text-edit.ts +0 -68
  113. package/src/types.ts +0 -6
@@ -1,77 +0,0 @@
1
- import type { StyleFormat } from "./color";
2
-
3
- import { styleOutputText } from "./color";
4
-
5
- export type RowCell = { text: string; style?: StyleFormat };
6
-
7
- const CELL_SEPARATOR = " | ";
8
- const LINE_BREAK_PATTERN = /\r?\n/;
9
-
10
- export function formatCell(cell: RowCell, width = cell.text.length) {
11
- const paddedText = cell.text.padEnd(width);
12
-
13
- if (cell.style == null) {
14
- return paddedText;
15
- }
16
-
17
- return styleOutputText(cell.style, paddedText);
18
- }
19
-
20
- /**
21
- * Rows that join extra text onto their last cell, such as a task's labels, put one there too, which is why it is exported.
22
- */
23
- export function formatCellSeparator() {
24
- return styleOutputText("dim", CELL_SEPARATOR);
25
- }
26
-
27
- function indentContinuationLines(text: string, indentWidth: number) {
28
- return text.split(LINE_BREAK_PATTERN).join(`\n${" ".repeat(indentWidth)}`);
29
- }
30
-
31
- /**
32
- * Lines rows up by padding each cell's text to its column's **widest** text.
33
- * Widths use `String.length`, so emoji and CJK misalign.
34
- * A row's last cell holds free text such as a title and is left unpadded.
35
- *
36
- * With `indentsContinuationLines`, a last cell that spans several lines starts each later line
37
- * where the cell starts, below the padded cells before it. Without it, those lines are left as they are.
38
- * Only a last cell may span lines: the widths do not account for line breaks.
39
- */
40
- export function formatRows(
41
- rows: Array<Array<RowCell>>,
42
- options: { indentsContinuationLines?: boolean } = {},
43
- ) {
44
- const columnWidths: Array<number> = [];
45
-
46
- for (const row of rows) {
47
- row.forEach((cell, columnIndex) => {
48
- columnWidths[columnIndex] = Math.max(columnWidths[columnIndex] ?? 0, cell.text.length);
49
- });
50
- }
51
-
52
- return rows
53
- .map((row) => {
54
- const lastCellIndex = row.length - 1;
55
- const lastCellStartColumn = columnWidths
56
- .slice(0, lastCellIndex)
57
- .reduce((total, width) => total + width + CELL_SEPARATOR.length, 0);
58
-
59
- return row
60
- .map((cell, columnIndex) => {
61
- if (columnIndex !== lastCellIndex) {
62
- return formatCell(cell, columnWidths[columnIndex]!);
63
- }
64
-
65
- if (!options.indentsContinuationLines) {
66
- return formatCell(cell);
67
- }
68
-
69
- return formatCell({
70
- ...cell,
71
- text: indentContinuationLines(cell.text, lastCellStartColumn),
72
- });
73
- })
74
- .join(formatCellSeparator());
75
- })
76
- .join("\n");
77
- }
@@ -1,16 +0,0 @@
1
- import { styleOutputText } from "./color";
2
-
3
- /** A bold heading above its body, optionally preceded by a dim horizontal rule. */
4
- export function formatSection(
5
- heading: string,
6
- body: string,
7
- options: { separatorWidth?: number } = {},
8
- ) {
9
- const section = `${styleOutputText("bold", `${heading}:`)}\n${body}`;
10
-
11
- if (options.separatorWidth === undefined) {
12
- return section;
13
- }
14
-
15
- return `${styleOutputText("dim", "-".repeat(options.separatorWidth))}\n${section}`;
16
- }
@@ -1,92 +0,0 @@
1
- import type { LabelColor, TaskPriority, TaskWithKey } from "@zinn-dev/core";
2
- import type { RowCell } from "./row-layout";
3
-
4
- import { column, label, task } from "@zinn-dev/core";
5
-
6
- import { styleOutputText } from "./color";
7
- import { columnNameCell } from "./column-presentation";
8
- import { formatCellSeparator, formatRows } from "./row-layout";
9
-
10
- export type PresentedTask = {
11
- key: string;
12
- status: "Active" | "Archived";
13
- column: string;
14
- title: string;
15
- description: string | null;
16
- priority: TaskPriority | null;
17
- labels: Array<string>;
18
- };
19
-
20
- const EMPTY_CELL_MARKER = "-";
21
- const LABEL_NAME_SEPARATOR = ", ";
22
-
23
- function taskPriorityCell(priority: TaskPriority | null, showsFullPriority: boolean): RowCell {
24
- if (priority == null) {
25
- return { text: EMPTY_CELL_MARKER, style: "dim" };
26
- }
27
-
28
- const priorityInitial = priority[0]!.toUpperCase();
29
- return { text: showsFullPriority ? `${priorityInitial}${priority.slice(1)}` : priorityInitial };
30
- }
31
-
32
- /**
33
- * `PresentedTask` carries label names only, so JSON stays a list of names.
34
- * Text output looks the colors up from the label definitions instead.
35
- */
36
- function getLabelColorsByName() {
37
- return new Map(label.getAll().map((labelMatch) => [labelMatch.name, labelMatch.color]));
38
- }
39
-
40
- function formatLabelNames(labelNames: Array<string>, labelColorsByName: Map<string, LabelColor>) {
41
- return labelNames
42
- .map((labelName) => styleOutputText(labelColorsByName.get(labelName)!, labelName))
43
- .join(LABEL_NAME_SEPARATOR);
44
- }
45
-
46
- export function presentTask(taskMatch: TaskWithKey): PresentedTask {
47
- return {
48
- key: taskMatch.key,
49
- status: taskMatch.archived_at == null ? "Active" : "Archived",
50
- column: column.getById(taskMatch.column_id)!.name,
51
- title: taskMatch.title,
52
- description: taskMatch.description,
53
- priority: taskMatch.priority,
54
- labels: task.label.getAll(taskMatch.key).map((label) => label.name),
55
- };
56
- }
57
-
58
- export function formatTaskRow(presented: PresentedTask) {
59
- return formatTaskList([presented]);
60
- }
61
-
62
- export function formatTaskList(
63
- presentedTasks: Array<PresentedTask>,
64
- options: { showsStatus?: boolean; showsFullPriority?: boolean } = {},
65
- ) {
66
- const labelColorsByName = getLabelColorsByName();
67
-
68
- return formatRows(
69
- presentedTasks.map((presentedTask) => {
70
- const statusCells: Array<RowCell> = options.showsStatus
71
- ? [{ text: presentedTask.status }]
72
- : [];
73
- const hasLabels = presentedTask.labels.length > 0;
74
- // The last cell is never padded, so the color codes in its separator and label names do not affect column widths.
75
- const labels = hasLabels
76
- ? `${formatCellSeparator()}${formatLabelNames(presentedTask.labels, labelColorsByName)}`
77
- : "";
78
-
79
- return [
80
- { text: presentedTask.key },
81
- ...statusCells,
82
- columnNameCell(presentedTask.column),
83
- taskPriorityCell(presentedTask.priority, options.showsFullPriority ?? false),
84
- { text: `${presentedTask.title}${labels}` },
85
- ];
86
- }),
87
- );
88
- }
89
-
90
- export function formatTaskListWithStatus(presentedTasks: Array<PresentedTask>) {
91
- return formatTaskList(presentedTasks, { showsStatus: true });
92
- }
@@ -1,17 +0,0 @@
1
- const MINUTES_PER_HOUR = 60;
2
-
3
- export function formatLocalTime(timestamp: number) {
4
- const date = new Date(timestamp);
5
- const offsetMinutes = -date.getTimezoneOffset();
6
- const offsetSign = offsetMinutes >= 0 ? "+" : "-";
7
- const absoluteOffsetMinutes = Math.abs(offsetMinutes);
8
- const offsetHours = Math.floor(absoluteOffsetMinutes / MINUTES_PER_HOUR);
9
- const remainingOffsetMinutes = absoluteOffsetMinutes % MINUTES_PER_HOUR;
10
- const pad = (value: number) => String(value).padStart(2, "0");
11
-
12
- return (
13
- `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ` +
14
- `${pad(date.getHours())}:${pad(date.getMinutes())} ` +
15
- `${offsetSign}${pad(offsetHours)}:${pad(remainingOffsetMinutes)}`
16
- );
17
- }