@zinn-dev/cli 0.15.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 +9 -0
- package/package.json +2 -2
- package/src/actor.test.ts +41 -0
- package/src/actor.ts +78 -0
- package/src/routes/label-router.ts +2 -1
- package/src/routes/relation-router.ts +3 -2
- package/src/routes/task-router.ts +30 -23
package/README.md
CHANGED
|
@@ -211,3 +211,12 @@ zinn task edit MDR-1 --priority none
|
|
|
211
211
|
```
|
|
212
212
|
|
|
213
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.
|
|
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.
|
|
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
|
|
|
@@ -84,7 +85,7 @@ List all global label definitions.`,
|
|
|
84
85
|
return;
|
|
85
86
|
}
|
|
86
87
|
|
|
87
|
-
const deleted = label.delete(props);
|
|
88
|
+
const deleted = label.delete(props, currentActor());
|
|
88
89
|
output(presentLabel(deleted), (l) => `Deleted label "${l.name}"`);
|
|
89
90
|
},
|
|
90
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);
|
|
@@ -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) {
|
|
@@ -138,14 +139,17 @@ export const taskRouter = {
|
|
|
138
139
|
);
|
|
139
140
|
}
|
|
140
141
|
|
|
141
|
-
const editedTask = task.edit(
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
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
|
+
);
|
|
149
153
|
|
|
150
154
|
output(presentTask(editedTask), formatTask);
|
|
151
155
|
},
|
|
@@ -197,13 +201,16 @@ Example: zinn task edit MDR-1 --title "Meet the quarterly refinement quota"`,
|
|
|
197
201
|
if (projectMatch == null) {
|
|
198
202
|
quit(`Project with key "${project.standardizeKey(projectKey)}" does not exist`);
|
|
199
203
|
}
|
|
200
|
-
const createdTask = task.create(
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
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
|
+
);
|
|
207
214
|
output(presentTask(createdTask), formatTask);
|
|
208
215
|
},
|
|
209
216
|
help: `Usage: zinn task create <project-key> --title <text> [--description <text>] [--priority <low|medium|high|urgent|none>] [--label <name>]
|
|
@@ -310,7 +317,7 @@ Example: zinn task view MDR-1`,
|
|
|
310
317
|
quit("Target column must be specified");
|
|
311
318
|
}
|
|
312
319
|
|
|
313
|
-
const movedTask = task.move({ taskKey, targetColumn });
|
|
320
|
+
const movedTask = task.move({ taskKey, targetColumn }, currentActor());
|
|
314
321
|
output(presentTask(movedTask), formatTaskMove);
|
|
315
322
|
},
|
|
316
323
|
help: `Usage: zinn task move <task-key> <target-column>
|
|
@@ -349,7 +356,7 @@ Example: zinn task move MDR-1 "In Progress"`,
|
|
|
349
356
|
quit("Only one target task can be specified");
|
|
350
357
|
}
|
|
351
358
|
|
|
352
|
-
const orderedTask = task.order({ taskKey, direction, targetTaskKey });
|
|
359
|
+
const orderedTask = task.order({ taskKey, direction, targetTaskKey }, currentActor());
|
|
353
360
|
output(presentTask(orderedTask), formatTask);
|
|
354
361
|
return;
|
|
355
362
|
}
|
|
@@ -361,7 +368,7 @@ Example: zinn task move MDR-1 "In Progress"`,
|
|
|
361
368
|
quit(`Order direction "${direction}" does not accept a target task`);
|
|
362
369
|
}
|
|
363
370
|
|
|
364
|
-
const orderedTask = task.order({ taskKey, direction });
|
|
371
|
+
const orderedTask = task.order({ taskKey, direction }, currentActor());
|
|
365
372
|
output(presentTask(orderedTask), formatTask);
|
|
366
373
|
return;
|
|
367
374
|
}
|
|
@@ -392,7 +399,7 @@ Example: zinn task order MDR-2 before MDR-1`,
|
|
|
392
399
|
const presented = presentTask(taskMatch);
|
|
393
400
|
|
|
394
401
|
if (canDelete) {
|
|
395
|
-
task.delete(taskKey);
|
|
402
|
+
task.delete(taskKey, currentActor());
|
|
396
403
|
output(presented, (t) => `Deleted ${formatTask(t)}`);
|
|
397
404
|
} else {
|
|
398
405
|
output(presented, (t) => `Deletion cancelled for ${formatTask(t)}`);
|
|
@@ -415,7 +422,7 @@ Example: zinn task delete MDR-1`,
|
|
|
415
422
|
quit("Task key must be specified");
|
|
416
423
|
}
|
|
417
424
|
|
|
418
|
-
const archivedTask = task.archive(taskKey);
|
|
425
|
+
const archivedTask = task.archive(taskKey, currentActor());
|
|
419
426
|
output(presentTask(archivedTask), formatTaskWithStatus);
|
|
420
427
|
},
|
|
421
428
|
help: `Usage: zinn task archive <task-key>
|
|
@@ -432,7 +439,7 @@ Example: zinn task archive MDR-1`,
|
|
|
432
439
|
quit("Task key must be specified");
|
|
433
440
|
}
|
|
434
441
|
|
|
435
|
-
const unarchivedTask = task.unarchive(taskKey);
|
|
442
|
+
const unarchivedTask = task.unarchive(taskKey, currentActor());
|
|
436
443
|
output(presentTask(unarchivedTask), formatTaskWithStatus);
|
|
437
444
|
},
|
|
438
445
|
help: `Usage: zinn task unarchive <task-key>
|
|
@@ -446,7 +453,7 @@ Example: zinn task unarchive MDR-1`,
|
|
|
446
453
|
add: {
|
|
447
454
|
run: (args) => {
|
|
448
455
|
const props = parseTaskLabelArgs(args);
|
|
449
|
-
output(presentTask(task.label.add(props)), formatTask);
|
|
456
|
+
output(presentTask(task.label.add(props, currentActor())), formatTask);
|
|
450
457
|
},
|
|
451
458
|
help: `Usage: zinn task label add <task-key> <label-name> [label-name ...]
|
|
452
459
|
|
|
@@ -455,7 +462,7 @@ Add existing labels to a task. Already attached labels are unchanged.`,
|
|
|
455
462
|
remove: {
|
|
456
463
|
run: (args) => {
|
|
457
464
|
const props = parseTaskLabelArgs(args);
|
|
458
|
-
output(presentTask(task.label.remove(props)), formatTask);
|
|
465
|
+
output(presentTask(task.label.remove(props, currentActor())), formatTask);
|
|
459
466
|
},
|
|
460
467
|
help: `Usage: zinn task label remove <task-key> <label-name> [label-name ...]
|
|
461
468
|
|