@zinn-dev/cli 0.14.0 → 0.16.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
@@ -148,6 +148,7 @@ zinn task move MDR-1 "In Progress"
148
148
  ```
149
149
 
150
150
  A moved task appears at the bottom of its destination column. Moving it to its current column does nothing. Archived tasks must be unarchived before they can be moved.
151
+ Moving prints only the task's key and new column, such as `MDR-1 | In Progress`, while `--json` prints the full task details.
151
152
 
152
153
  Change a task's position within its current column:
153
154
 
@@ -209,4 +210,13 @@ zinn task edit MDR-1 --priority urgent
209
210
  zinn task edit MDR-1 --priority none
210
211
  ```
211
212
 
212
- Use `none` to clear priority. Omitting `--priority` on edits preserves it. Assigned priorities appear in task list and view output; board ordering remains unchanged.
213
+ Use `none` to clear priority. Omitting `--priority` on edits preserves it. Task lists show priority in a compact column after the board column: `-` for unassigned and `L`, `M`, `H`, or `U` for low, medium, high, or urgent. Task views show the full priority value. Priority does not affect board ordering.
214
+
215
+ ## Activity
216
+
217
+ 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.
218
+ Note that this data is not yet surfaced by any command yet.
219
+
220
+ When a coding agent performs a mutation with `zinn`, the change is recorded under that agent's name.
221
+
222
+ Zinn recognizes Claude Code, Codex, OpenCode, Gemini CLI, Cline, Cursor, Copilot's coding agent, Crush, Amp, and any tool that sets `AI_AGENT`. If you are using a tool that Zinn does not recognize, you can set `AI_AGENT` in that tool's environment settings, for example `AI_AGENT=hermes`. Otherwise, Zinn uses your git `user.name` and `user.email`, and if that's also not set, it falls to your system username.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zinn-dev/cli",
3
- "version": "0.14.0",
3
+ "version": "0.16.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.11.0"
45
+ "@zinn-dev/core": "0.12.0"
46
46
  }
47
47
  }
@@ -0,0 +1,41 @@
1
+ import type { Actor } from "@zinn-dev/core";
2
+
3
+ import { expect, test } from "bun:test";
4
+
5
+ import { detectAgent } from "./actor";
6
+
7
+ const agent = (name: string): Actor => ({ name, email: null, kind: "agent" });
8
+
9
+ test("AI_AGENT is recorded as given, ahead of tool markers", () => {
10
+ expect(detectAgent({ AI_AGENT: "claude-code_2-1-280_agent", CLAUDECODE: "1" })).toEqual(
11
+ agent("claude-code_2-1-280_agent"),
12
+ );
13
+ expect(detectAgent({ AI_AGENT: "hermes" })).toEqual(agent("hermes"));
14
+ });
15
+
16
+ test("AGENT comes before CLAUDECODE, since Amp sets both", () => {
17
+ expect(detectAgent({ AGENT: "amp", CLAUDECODE: "1" })).toEqual(agent("amp"));
18
+ });
19
+
20
+ test("tool-specific markers map to fixed names", () => {
21
+ const cases: Array<[Record<string, string>, string]> = [
22
+ [{ CLAUDECODE: "1" }, "claude-code"],
23
+ [{ CODEX_THREAD_ID: "thread" }, "codex"],
24
+ [{ CODEX_SANDBOX: "seatbelt" }, "codex"],
25
+ [{ OPENCODE: "1" }, "opencode"],
26
+ [{ GEMINI_CLI: "1" }, "gemini-cli"],
27
+ [{ CLINE_ACTIVE: "true" }, "cline"],
28
+ [{ CURSOR_AGENT: "1" }, "cursor"],
29
+ [{ COPILOT_AGENT_SESSION_ID: "session" }, "copilot"],
30
+ [{ CRUSH: "1" }, "crush"],
31
+ ];
32
+
33
+ for (const [env, name] of cases) {
34
+ expect(detectAgent(env)).toEqual(agent(name));
35
+ }
36
+ });
37
+
38
+ test("empty or unrelated variables are not agents", () => {
39
+ expect(detectAgent({})).toBeNull();
40
+ expect(detectAgent({ AI_AGENT: " ", AGENT: "", HOME: "/home/someone" })).toBeNull();
41
+ });
package/src/actor.ts ADDED
@@ -0,0 +1,78 @@
1
+ import type { Actor } from "@zinn-dev/core";
2
+
3
+ import { execFileSync } from "node:child_process";
4
+ import { userInfo } from "node:os";
5
+
6
+ type Env = Record<string, string | undefined>;
7
+ type AgentMarker = { variables: Array<string>; name: string | null };
8
+
9
+ /**
10
+ * Environment variables that coding agents set in the shells they run.
11
+ * Undetected tools can set `AI_AGENT` through their own env configuration.
12
+ */
13
+ const AGENT_MARKERS: Array<AgentMarker> = [
14
+ { variables: ["AI_AGENT"], name: null },
15
+ { variables: ["AGENT"], name: null },
16
+ { variables: ["CLAUDECODE"], name: "claude-code" },
17
+ { variables: ["CODEX_THREAD_ID", "CODEX_SANDBOX"], name: "codex" },
18
+ { variables: ["OPENCODE"], name: "opencode" },
19
+ { variables: ["GEMINI_CLI"], name: "gemini-cli" },
20
+ { variables: ["CLINE_ACTIVE"], name: "cline" },
21
+ { variables: ["CURSOR_AGENT"], name: "cursor" },
22
+ { variables: ["COPILOT_AGENT_SESSION_ID"], name: "copilot" },
23
+ { variables: ["CRUSH"], name: "crush" },
24
+ ];
25
+
26
+ /** A marker without a fixed name records the variable's own value, e.g. `AI_AGENT=claude-code_2-1-280_agent`. */
27
+ export function detectAgent(env: Env): Actor | null {
28
+ for (const marker of AGENT_MARKERS) {
29
+ for (const variable of marker.variables) {
30
+ const value = env[variable]?.trim();
31
+ if (value == null || value.length === 0) {
32
+ continue;
33
+ }
34
+
35
+ return { name: marker.name ?? value, email: null, kind: "agent" };
36
+ }
37
+ }
38
+
39
+ return null;
40
+ }
41
+
42
+ function readGitConfig(key: string) {
43
+ try {
44
+ const value = execFileSync("git", ["config", key], {
45
+ encoding: "utf-8",
46
+ stdio: ["ignore", "pipe", "ignore"],
47
+ }).trim();
48
+
49
+ return value.length > 0 ? value : null;
50
+ } catch {
51
+ // git is missing or the key is unset
52
+ return null;
53
+ }
54
+ }
55
+
56
+ function resolveActor(): Actor {
57
+ const agent = detectAgent(process.env);
58
+ if (agent != null) {
59
+ return agent;
60
+ }
61
+
62
+ const gitName = readGitConfig("user.name");
63
+ if (gitName != null) {
64
+ return { name: gitName, email: readGitConfig("user.email"), kind: "human" };
65
+ }
66
+
67
+ return { name: userInfo().username, email: null, kind: "human" };
68
+ }
69
+
70
+ let actor: Actor | null = null;
71
+
72
+ export function currentActor(): Actor {
73
+ if (actor == null) {
74
+ actor = resolveActor();
75
+ }
76
+
77
+ return actor;
78
+ }
@@ -11,6 +11,7 @@ import {
11
11
  validatePositionalCount,
12
12
  validateUniqueOptions,
13
13
  } from "../lib";
14
+ import { currentActor } from "../actor";
14
15
 
15
16
  type PresentedLabel = Omit<Label, "id">;
16
17
 
@@ -20,6 +21,11 @@ function presentLabel(labelMatch: Label): PresentedLabel {
20
21
 
21
22
  function formatLabel(presented: PresentedLabel) {
22
23
  const coloredName = styleText(presented.color, presented.name);
24
+
25
+ if (presented.description.length === 0) {
26
+ return coloredName;
27
+ }
28
+
23
29
  return `${coloredName} | ${presented.description}`;
24
30
  }
25
31
 
@@ -79,7 +85,7 @@ List all global label definitions.`,
79
85
  return;
80
86
  }
81
87
 
82
- const deleted = label.delete(props);
88
+ const deleted = label.delete(props, currentActor());
83
89
  output(presentLabel(deleted), (l) => `Deleted label "${l.name}"`);
84
90
  },
85
91
  help: `Usage: zinn label delete <name>
@@ -4,6 +4,7 @@ import type { RouteDef } from "../types";
4
4
  import { parseArgs } from "node:util";
5
5
  import { relation, relationCreateSchema, task } from "@zinn-dev/core";
6
6
  import { output, quit, validatePositionalCount, validateUniqueOptions } from "../lib";
7
+ import { currentActor } from "../actor";
7
8
 
8
9
  // TODO: maybe core should export it as a reusable if we need it in more places
9
10
  type RelationType = RelationCreateInput["relation_type"];
@@ -98,7 +99,7 @@ export const relationRouter = {
98
99
  delete: {
99
100
  run: (args) => {
100
101
  const props = parseRelationArgs(args);
101
- relation.delete(props);
102
+ relation.delete(props, currentActor());
102
103
 
103
104
  const source = task.getByKey(props.sourceTaskKey);
104
105
  const target = task.getByKey(props.targetTaskKey);
@@ -130,7 +131,7 @@ Example: zinn task relation delete APP-1 APP-2 --type dependency`,
130
131
  const props = parseRelationArgs(args);
131
132
  const { sourceTaskKey, targetTaskKey } = props;
132
133
 
133
- relation.create(props);
134
+ relation.create(props, currentActor());
134
135
 
135
136
  const source = task.getByKey(sourceTaskKey);
136
137
  const target = task.getByKey(targetTaskKey);
@@ -14,7 +14,8 @@ function getNamespaceHelp(parsedRoutes: Array<ParsedRoute>, namespace: string) {
14
14
  const prefix = `${namespace} `;
15
15
  const commands = parsedRoutes
16
16
  .map((route) => route.command)
17
- .filter((command) => command.startsWith(prefix));
17
+ .filter((command) => command.startsWith(prefix))
18
+ .map((command) => command.slice(prefix.length));
18
19
 
19
20
  if (commands.length === 0) {
20
21
  return null;
@@ -1,7 +1,7 @@
1
1
  import type { TaskPriority } from "@zinn-dev/core";
2
2
  import type { RouteDef } from "../types";
3
3
 
4
- import { parseArgs } from "node:util";
4
+ import { parseArgs, styleText } from "node:util";
5
5
  import { task, project, column } from "@zinn-dev/core";
6
6
 
7
7
  import {
@@ -13,6 +13,7 @@ import {
13
13
  } from "../lib";
14
14
  import { formatRelations, presentRelations, relationRouter } from "./relation-router";
15
15
  import { TASK_DESCRIPTION_PREVIEW_LENGTH } from "../constant";
16
+ import { currentActor } from "../actor";
16
17
 
17
18
  function formatTaskDescriptionPreview(description: string | null) {
18
19
  if (description == null) {
@@ -38,6 +39,29 @@ type PresentedTask = {
38
39
  labels: Array<string>;
39
40
  };
40
41
 
42
+ function formatTaskPriorityMarker(priority: TaskPriority | null) {
43
+ if (priority == null) {
44
+ return "-";
45
+ }
46
+
47
+ return priority[0]!.toUpperCase();
48
+ }
49
+
50
+ function formatTaskColumn(columnName: string, width = columnName.length) {
51
+ const paddedColumnName = columnName.padEnd(width);
52
+
53
+ // TODO: Derive column colors from column roles once roles exist instead of relying on names.
54
+ if (columnName === "Backlog") {
55
+ return styleText("gray", paddedColumnName);
56
+ }
57
+
58
+ if (columnName === "Done") {
59
+ return styleText("green", paddedColumnName);
60
+ }
61
+
62
+ return paddedColumnName;
63
+ }
64
+
41
65
  function presentTask(taskMatch: ReturnType<typeof task.getByKey>): PresentedTask {
42
66
  return {
43
67
  key: taskMatch.key,
@@ -52,21 +76,29 @@ function presentTask(taskMatch: ReturnType<typeof task.getByKey>): PresentedTask
52
76
 
53
77
  // TODO: a CLI row formatter that accepts text columns and joins them with " | " would be useful
54
78
  // Reuse it across task list/view and other command output in a separate change.
55
- function formatTask(presented: PresentedTask, options: { showsStatus?: boolean } = {}) {
79
+ function formatTask(
80
+ presented: PresentedTask,
81
+ options: { showsStatus?: boolean } = {},
82
+ ) {
56
83
  const status = options.showsStatus ? ` | ${presented.status}` : "";
84
+ const column = formatTaskColumn(presented.column);
57
85
  const description = presented.description == null ? "" : ` | ${presented.description}`;
58
86
 
59
87
  const priority = presented.priority == null ? "" : ` | Priority: ${presented.priority}`;
60
88
  const labelText =
61
89
  presented.labels.length === 0 ? "" : ` | Labels: ${presented.labels.join(", ")}`;
62
90
 
63
- return `${presented.key}${status} | ${presented.column} | ${presented.title}${description}${priority}${labelText}`;
91
+ return `${presented.key}${status} | ${column} | ${presented.title}${description}${priority}${labelText}`;
64
92
  }
65
93
 
66
94
  function formatTaskWithStatus(presented: PresentedTask) {
67
95
  return formatTask(presented, { showsStatus: true });
68
96
  }
69
97
 
98
+ function formatTaskMove(presented: PresentedTask) {
99
+ return `${presented.key} | ${formatTaskColumn(presented.column)}`;
100
+ }
101
+
70
102
  export const taskRouter = {
71
103
  edit: {
72
104
  run: (args) => {
@@ -107,14 +139,17 @@ export const taskRouter = {
107
139
  );
108
140
  }
109
141
 
110
- const editedTask = task.edit({
111
- taskKey,
112
- title: values.title,
113
- description: values.description,
114
- priority: parsePriority(values.priority),
115
- addLabelNames: values["add-label"],
116
- removeLabelNames: values["remove-label"],
117
- });
142
+ const editedTask = task.edit(
143
+ {
144
+ taskKey,
145
+ title: values.title,
146
+ description: values.description,
147
+ priority: parsePriority(values.priority),
148
+ addLabelNames: values["add-label"],
149
+ removeLabelNames: values["remove-label"],
150
+ },
151
+ currentActor(),
152
+ );
118
153
 
119
154
  output(presentTask(editedTask), formatTask);
120
155
  },
@@ -166,13 +201,16 @@ Example: zinn task edit MDR-1 --title "Meet the quarterly refinement quota"`,
166
201
  if (projectMatch == null) {
167
202
  quit(`Project with key "${project.standardizeKey(projectKey)}" does not exist`);
168
203
  }
169
- const createdTask = task.create({
170
- project_id: projectMatch.id,
171
- title: values.title,
172
- description: values.description ?? null,
173
- priority: parsePriority(values.priority),
174
- labelNames: values.label,
175
- });
204
+ const createdTask = task.create(
205
+ {
206
+ project_id: projectMatch.id,
207
+ title: values.title,
208
+ description: values.description ?? null,
209
+ priority: parsePriority(values.priority),
210
+ labelNames: values.label,
211
+ },
212
+ currentActor(),
213
+ );
176
214
  output(presentTask(createdTask), formatTask);
177
215
  },
178
216
  help: `Usage: zinn task create <project-key> --title <text> [--description <text>] [--priority <low|medium|high|urgent|none>] [--label <name>]
@@ -209,6 +247,11 @@ Example: zinn task create MDR --title "Refine the numbers" --description "Meet t
209
247
  (prev, current) => Math.max(prev, current.key.length),
210
248
  0,
211
249
  );
250
+ const longestColumnNameLength = presentedTasks.reduce(
251
+ (previousLength, currentTask) =>
252
+ Math.max(previousLength, currentTask.column.length),
253
+ 0,
254
+ );
212
255
  const longestStatusLength = presentedTasks.reduce(
213
256
  (prev, current) => Math.max(prev, current.status.length),
214
257
  0,
@@ -220,8 +263,10 @@ Example: zinn task create MDR --title "Refine the numbers" --description "Meet t
220
263
  const status = showsAll ? ` | ${t.status.padEnd(longestStatusLength)}` : "";
221
264
  const descriptionPreview = formatTaskDescriptionPreview(t.description);
222
265
  const description = t.description == null ? "" : ` | ${descriptionPreview}`;
223
- const priority = t.priority == null ? "" : ` | Priority: ${t.priority}`;
224
- return `${t.key.padEnd(longestKeyLength)}${status} | ${t.column} | ${t.title}${description}${priority}`;
266
+ const priority = formatTaskPriorityMarker(t.priority);
267
+ const column = formatTaskColumn(t.column, longestColumnNameLength);
268
+
269
+ return `${t.key.padEnd(longestKeyLength)}${status} | ${column} | ${priority} | ${t.title}${description}`;
225
270
  })
226
271
  .join("\n");
227
272
  });
@@ -230,6 +275,7 @@ Example: zinn task create MDR --title "Refine the numbers" --description "Meet t
230
275
 
231
276
  List active tasks by default.
232
277
  Use --archived to list archived tasks or --all to list both.
278
+ Priority markers: - unassigned, L low, M medium, H high, U urgent.
233
279
 
234
280
  Example: zinn task list MDR --all`,
235
281
  },
@@ -246,9 +292,11 @@ Example: zinn task list MDR --all`,
246
292
 
247
293
  output(viewedTask, (t) => {
248
294
  const relations = formatRelations(t.relations);
295
+ const formattedTask = formatTask(t);
296
+
249
297
  return relations.length > 0
250
- ? `${formatTask(t)}\n\nRelations:\n${relations}`
251
- : formatTask(t);
298
+ ? `${formattedTask}\n\nRelations:\n${relations}`
299
+ : formattedTask;
252
300
  });
253
301
  },
254
302
  help: `Usage: zinn task view <task-key>
@@ -269,8 +317,8 @@ Example: zinn task view MDR-1`,
269
317
  quit("Target column must be specified");
270
318
  }
271
319
 
272
- const movedTask = task.move({ taskKey, targetColumn });
273
- output(presentTask(movedTask), formatTask);
320
+ const movedTask = task.move({ taskKey, targetColumn }, currentActor());
321
+ output(presentTask(movedTask), formatTaskMove);
274
322
  },
275
323
  help: `Usage: zinn task move <task-key> <target-column>
276
324
 
@@ -278,6 +326,8 @@ Move a task to another column in its project.
278
326
  Moving a task to a different column lists it last in that column,
279
327
  matching placement at the bottom of a visual kanban column.
280
328
 
329
+ Prints the task's key and new column.
330
+
281
331
  Giving a task's current column as the target will not do anything.
282
332
  Archived tasks must be unarchived before they can be moved.
283
333
 
@@ -306,7 +356,7 @@ Example: zinn task move MDR-1 "In Progress"`,
306
356
  quit("Only one target task can be specified");
307
357
  }
308
358
 
309
- const orderedTask = task.order({ taskKey, direction, targetTaskKey });
359
+ const orderedTask = task.order({ taskKey, direction, targetTaskKey }, currentActor());
310
360
  output(presentTask(orderedTask), formatTask);
311
361
  return;
312
362
  }
@@ -318,7 +368,7 @@ Example: zinn task move MDR-1 "In Progress"`,
318
368
  quit(`Order direction "${direction}" does not accept a target task`);
319
369
  }
320
370
 
321
- const orderedTask = task.order({ taskKey, direction });
371
+ const orderedTask = task.order({ taskKey, direction }, currentActor());
322
372
  output(presentTask(orderedTask), formatTask);
323
373
  return;
324
374
  }
@@ -349,7 +399,7 @@ Example: zinn task order MDR-2 before MDR-1`,
349
399
  const presented = presentTask(taskMatch);
350
400
 
351
401
  if (canDelete) {
352
- task.delete(taskKey);
402
+ task.delete(taskKey, currentActor());
353
403
  output(presented, (t) => `Deleted ${formatTask(t)}`);
354
404
  } else {
355
405
  output(presented, (t) => `Deletion cancelled for ${formatTask(t)}`);
@@ -372,7 +422,7 @@ Example: zinn task delete MDR-1`,
372
422
  quit("Task key must be specified");
373
423
  }
374
424
 
375
- const archivedTask = task.archive(taskKey);
425
+ const archivedTask = task.archive(taskKey, currentActor());
376
426
  output(presentTask(archivedTask), formatTaskWithStatus);
377
427
  },
378
428
  help: `Usage: zinn task archive <task-key>
@@ -389,7 +439,7 @@ Example: zinn task archive MDR-1`,
389
439
  quit("Task key must be specified");
390
440
  }
391
441
 
392
- const unarchivedTask = task.unarchive(taskKey);
442
+ const unarchivedTask = task.unarchive(taskKey, currentActor());
393
443
  output(presentTask(unarchivedTask), formatTaskWithStatus);
394
444
  },
395
445
  help: `Usage: zinn task unarchive <task-key>
@@ -403,7 +453,7 @@ Example: zinn task unarchive MDR-1`,
403
453
  add: {
404
454
  run: (args) => {
405
455
  const props = parseTaskLabelArgs(args);
406
- output(presentTask(task.label.add(props)), formatTask);
456
+ output(presentTask(task.label.add(props, currentActor())), formatTask);
407
457
  },
408
458
  help: `Usage: zinn task label add <task-key> <label-name> [label-name ...]
409
459
 
@@ -412,7 +462,7 @@ Add existing labels to a task. Already attached labels are unchanged.`,
412
462
  remove: {
413
463
  run: (args) => {
414
464
  const props = parseTaskLabelArgs(args);
415
- output(presentTask(task.label.remove(props)), formatTask);
465
+ output(presentTask(task.label.remove(props, currentActor())), formatTask);
416
466
  },
417
467
  help: `Usage: zinn task label remove <task-key> <label-name> [label-name ...]
418
468