@zinn-dev/cli 0.17.0 → 0.18.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 CHANGED
@@ -127,6 +127,27 @@ Note that a deletion happens _without_ confirmation.
127
127
 
128
128
  Use `task relation create --help` to discover types.
129
129
 
130
+ ## Task comments
131
+
132
+ Add and list comments on a task:
133
+
134
+ ```sh
135
+ zinn task comment create MDR-1 --text "Ready for review"
136
+ zinn task comment list MDR-1
137
+ ```
138
+
139
+ Comments receive keys per task like `MDR-1#1`.
140
+ `task view` includes the task's comments.
141
+
142
+ Edit or delete a comment using its key:
143
+
144
+ ```sh
145
+ zinn task comment edit MDR-1#1 --text "Approved"
146
+ zinn task comment delete MDR-1#1
147
+ ```
148
+
149
+ Deletion asks for confirmation. Comments can be added to archived tasks. Comment mutations are recorded in the activity log without changing the task's modification timestamp.
150
+
130
151
  ## Edit tasks
131
152
 
132
153
  Edit a task's title, description, priority, or labels:
@@ -217,7 +238,7 @@ Use `none` to clear priority. Omitting `--priority` on edits preserves it. Task
217
238
 
218
239
  ## Activity
219
240
 
220
- Zinn keeps an activity log of changes made to a task like creating, editing, moving, reordering, archiving, unarchiving and deleting it, its labels and its relations. Each log also says _who_ made the change.
241
+ Zinn keeps an activity log of changes made to a task like creating, editing, moving, reordering, archiving, unarchiving and deleting it, its labels, its relations, and its comments. Each log also says _who_ made the change.
221
242
  Note that this data is not yet surfaced by any command yet.
222
243
 
223
244
  When a coding agent performs a mutation with `zinn`, the change is recorded under that agent's name.
package/index.ts CHANGED
@@ -32,6 +32,10 @@ Commands:
32
32
  task relation create
33
33
  task relation list
34
34
  task relation delete
35
+ task comment create
36
+ task comment list
37
+ task comment edit
38
+ task comment delete
35
39
  task label add
36
40
  task label remove
37
41
  label create
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zinn-dev/cli",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "description": "A kanban workflow in the terminal.",
5
5
  "license": "MIT",
6
6
  "bugs": {
@@ -42,6 +42,6 @@
42
42
  "access": "public"
43
43
  },
44
44
  "dependencies": {
45
- "@zinn-dev/core": "0.12.0"
45
+ "@zinn-dev/core": "0.13.0"
46
46
  }
47
47
  }
@@ -0,0 +1,121 @@
1
+ import type { CommentWithKey } from "@zinn-dev/core";
2
+ import type { RouteDef } from "../types";
3
+
4
+ import { parseArgs } from "node:util";
5
+ import { comment } from "@zinn-dev/core";
6
+
7
+ import {
8
+ confirmAction,
9
+ output,
10
+ quit,
11
+ validatePositionalCount,
12
+ validateUniqueOptions,
13
+ } from "../lib";
14
+ import { currentActor } from "../actor";
15
+
16
+ type PresentedComment = Pick<CommentWithKey, "key" | "text" | "created_at" | "updated_at">;
17
+
18
+ function presentComment(commentMatch: CommentWithKey): PresentedComment {
19
+ return {
20
+ key: commentMatch.key,
21
+ text: commentMatch.text,
22
+ created_at: commentMatch.created_at,
23
+ updated_at: commentMatch.updated_at,
24
+ };
25
+ }
26
+
27
+ export function presentComments(taskKey: string) {
28
+ return comment.getAll(taskKey).map(presentComment);
29
+ }
30
+
31
+ export function formatComment(commentMatch: PresentedComment) {
32
+ const continuationIndent = " ".repeat(`${commentMatch.key} | `.length);
33
+ const text = commentMatch.text.split(/\r?\n/).join(`\n${continuationIndent}`);
34
+ return `${commentMatch.key} | ${text}`;
35
+ }
36
+
37
+ export function formatComments(comments: Array<PresentedComment>) {
38
+ return comments.map(formatComment).join("\n");
39
+ }
40
+
41
+ function parseTextArgs(args: Array<string>, entityName: "task" | "comment") {
42
+ const { values, positionals, tokens } = parseArgs({
43
+ args,
44
+ options: { text: { type: "string" } },
45
+ allowPositionals: true,
46
+ strict: true,
47
+ tokens: true,
48
+ });
49
+
50
+ validatePositionalCount(positionals, 1, `Exactly one ${entityName} key is required`);
51
+ validateUniqueOptions(tokens);
52
+
53
+ if (values.text === undefined) {
54
+ quit("Comment text must be specified with --text");
55
+ }
56
+
57
+ return { key: positionals[0]!, text: values.text };
58
+ }
59
+
60
+ export const commentRouter = {
61
+ create: {
62
+ run: (args) => {
63
+ const props = parseTextArgs(args, "task");
64
+ const created = comment.create({ taskKey: props.key, text: props.text }, currentActor());
65
+ output(presentComment(created), formatComment);
66
+ },
67
+ help: `Usage: zinn task comment create <task-key> --text <text>
68
+
69
+ Add a comment to a task. Comment text cannot be blank.
70
+ Archived tasks can be commented on.
71
+
72
+ Example: zinn task comment create MDR-1 --text "Ready for review"`,
73
+ },
74
+ list: {
75
+ run: (args) => {
76
+ const { positionals } = parseArgs({ args, allowPositionals: true, strict: true });
77
+ validatePositionalCount(positionals, 1, "Exactly one task key is required");
78
+ output(presentComments(positionals[0]!), formatComments);
79
+ },
80
+ help: `Usage: zinn task comment list <task-key>
81
+
82
+ List a task's comments by oldest first.
83
+
84
+ Example: zinn task comment list MDR-1`,
85
+ },
86
+ edit: {
87
+ run: (args) => {
88
+ const props = parseTextArgs(args, "comment");
89
+ const edited = comment.edit({ commentKey: props.key, text: props.text }, currentActor());
90
+ output(presentComment(edited), formatComment);
91
+ },
92
+ help: `Usage: zinn task comment edit <comment-key> --text <text>
93
+
94
+ Replace a comment's text. Comment text cannot be blank.
95
+
96
+ Example: zinn task comment edit MDR-1#2 --text "Approved"`,
97
+ },
98
+ delete: {
99
+ run: (args) => {
100
+ const { positionals } = parseArgs({ args, allowPositionals: true, strict: true });
101
+ validatePositionalCount(positionals, 1, "Exactly one comment key is required");
102
+
103
+ const commentMatch = comment.getByKey(positionals[0]!);
104
+ const canDelete = confirmAction(`Are you sure you want to delete ${commentMatch.key}?`);
105
+ const presented = presentComment(commentMatch);
106
+
107
+ if (!canDelete) {
108
+ output(presented, (entry) => `Deletion cancelled for ${entry.key}`);
109
+ return;
110
+ }
111
+
112
+ comment.delete({ commentKey: commentMatch.key }, currentActor());
113
+ output(presented, (entry) => `Deleted ${entry.key}`);
114
+ },
115
+ help: `Usage: zinn task comment delete <comment-key>
116
+
117
+ Permanently delete a comment after confirmation.
118
+
119
+ Example: zinn task comment delete MDR-1#2`,
120
+ },
121
+ } satisfies RouteDef;
@@ -1,4 +1,4 @@
1
- import type { RelationCreateInput } from "@zinn-dev/core";
1
+ import type { RelationCreateInput, TaskWithKey } from "@zinn-dev/core";
2
2
  import type { RouteDef } from "../types";
3
3
 
4
4
  import { parseArgs } from "node:util";
@@ -15,10 +15,8 @@ type PresentedRelation = {
15
15
  task: { key: string; title: string; status: "Active" | "Archived" };
16
16
  };
17
17
 
18
- export function presentRelations(taskKey: string): Array<PresentedRelation> {
19
- const taskMatch = task.getByKey(taskKey);
20
-
21
- return relation.getAll(taskKey, { include: { tasks: true } }).map((entry) => {
18
+ export function presentRelations(taskMatch: TaskWithKey): Array<PresentedRelation> {
19
+ return relation.getAll(taskMatch.key, { include: { tasks: true } }).map((entry) => {
22
20
  const isSource = entry.source_task_id === taskMatch.id;
23
21
  const other = isSource ? entry.target : entry.source;
24
22
  if (other == null) {
@@ -167,7 +165,7 @@ Example: zinn task relation create APP-1 APP-2 --type dependency`,
167
165
  run: (args) => {
168
166
  const { positionals } = parseArgs({ args, allowPositionals: true, strict: true });
169
167
  validatePositionalCount(positionals, 1, "Provide exactly one task key");
170
- output(presentRelations(positionals[0]!), formatRelations);
168
+ output(presentRelations(task.getByKey(positionals[0]!)), formatRelations);
171
169
  },
172
170
  help: `Usage: zinn task relation list <task-key>
173
171
 
@@ -11,6 +11,7 @@ import {
11
11
  validateUniqueOptions,
12
12
  } from "../lib";
13
13
  import { formatRelations, presentRelations, relationRouter } from "./relation-router";
14
+ import { commentRouter, formatComments, presentComments } from "./comment-router";
14
15
  import { currentActor } from "../actor";
15
16
  import {
16
17
  formatTask,
@@ -184,20 +185,32 @@ Example: zinn task list MDR --all`,
184
185
  }
185
186
 
186
187
  const taskMatch = task.getByKey(taskKey);
187
- const viewedTask = { ...presentTask(taskMatch), relations: presentRelations(taskKey) };
188
+ const viewedTask = {
189
+ ...presentTask(taskMatch),
190
+ relations: presentRelations(taskMatch),
191
+ comments: presentComments(taskMatch.key),
192
+ };
188
193
 
189
194
  output(viewedTask, (t) => {
190
195
  const relations = formatRelations(t.relations);
196
+ const comments = formatComments(t.comments);
191
197
  const formattedTask = formatTask(t);
198
+ const sections = [formattedTask];
192
199
 
193
- return relations.length > 0
194
- ? `${formattedTask}\n\nRelations:\n${relations}`
195
- : formattedTask;
200
+ if (relations.length > 0) {
201
+ sections.push(`Relations:\n${relations}`);
202
+ }
203
+
204
+ if (comments.length > 0) {
205
+ sections.push(`Comments:\n${comments}`);
206
+ }
207
+
208
+ return sections.join("\n\n");
196
209
  });
197
210
  },
198
211
  help: `Usage: zinn task view <task-key>
199
212
 
200
- Show a task with its current column, description, priority, labels, and relations.
213
+ Show a task with its current column, description, priority, labels, relations, and comments.
201
214
 
202
215
  Example: zinn task view MDR-1`,
203
216
  },
@@ -345,6 +358,7 @@ Unarchive a task at the bottom of its previous column.
345
358
  Example: zinn task unarchive MDR-1`,
346
359
  },
347
360
  relation: relationRouter,
361
+ comment: commentRouter,
348
362
  label: {
349
363
  add: {
350
364
  run: (args) => {