@zinn-dev/cli 0.15.0 → 0.17.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 +12 -0
- package/index.ts +1 -0
- package/package.json +2 -2
- package/src/actor.test.ts +41 -0
- package/src/actor.ts +78 -0
- package/src/presentation/task-presentation.ts +118 -0
- package/src/routes/label-router.ts +2 -1
- package/src/routes/project-router.ts +38 -1
- package/src/routes/relation-router.ts +3 -2
- package/src/routes/task-router.ts +42 -139
package/README.md
CHANGED
|
@@ -28,9 +28,12 @@ You can list projects or inspect a project's columns with:
|
|
|
28
28
|
|
|
29
29
|
```sh
|
|
30
30
|
zinn project list
|
|
31
|
+
zinn project view MDR
|
|
31
32
|
zinn project column list MDR
|
|
32
33
|
```
|
|
33
34
|
|
|
35
|
+
`project view` prints the project and its unarchived tasks. It's the same list as you would get with `zinn task list <project-key>`.
|
|
36
|
+
|
|
34
37
|
Rename a project:
|
|
35
38
|
|
|
36
39
|
```sh
|
|
@@ -211,3 +214,12 @@ zinn task edit MDR-1 --priority none
|
|
|
211
214
|
```
|
|
212
215
|
|
|
213
216
|
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.
|
|
217
|
+
|
|
218
|
+
## Activity
|
|
219
|
+
|
|
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.
|
|
221
|
+
Note that this data is not yet surfaced by any command yet.
|
|
222
|
+
|
|
223
|
+
When a coding agent performs a mutation with `zinn`, the change is recorded under that agent's name.
|
|
224
|
+
|
|
225
|
+
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/index.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zinn-dev/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.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
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import type { TaskPriority, TaskWithKey } from "@zinn-dev/core";
|
|
2
|
+
|
|
3
|
+
import { styleText } from "node:util";
|
|
4
|
+
import { column, task } from "@zinn-dev/core";
|
|
5
|
+
|
|
6
|
+
import { TASK_DESCRIPTION_PREVIEW_LENGTH } from "../constant";
|
|
7
|
+
|
|
8
|
+
function formatTaskDescriptionPreview(description: string | null) {
|
|
9
|
+
if (description == null) {
|
|
10
|
+
return "";
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const normalizedDescription = description.replace(/\s+/g, " ").trim();
|
|
14
|
+
|
|
15
|
+
if (normalizedDescription.length <= TASK_DESCRIPTION_PREVIEW_LENGTH) {
|
|
16
|
+
return normalizedDescription;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return `${normalizedDescription.slice(0, TASK_DESCRIPTION_PREVIEW_LENGTH - 1).trimEnd()}…`;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type PresentedTask = {
|
|
23
|
+
key: string;
|
|
24
|
+
status: "Active" | "Archived";
|
|
25
|
+
column: string;
|
|
26
|
+
title: string;
|
|
27
|
+
description: string | null;
|
|
28
|
+
priority: TaskPriority | null;
|
|
29
|
+
labels: Array<string>;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
function formatTaskPriorityMarker(priority: TaskPriority | null) {
|
|
33
|
+
if (priority == null) {
|
|
34
|
+
return "-";
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return priority[0]!.toUpperCase();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function formatTaskColumn(columnName: string, width = columnName.length) {
|
|
41
|
+
const paddedColumnName = columnName.padEnd(width);
|
|
42
|
+
|
|
43
|
+
// TODO: Derive column colors from column roles once roles exist instead of relying on names.
|
|
44
|
+
if (columnName === "Backlog") {
|
|
45
|
+
return styleText("gray", paddedColumnName);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (columnName === "Done") {
|
|
49
|
+
return styleText("green", paddedColumnName);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return paddedColumnName;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function presentTask(taskMatch: TaskWithKey): PresentedTask {
|
|
56
|
+
return {
|
|
57
|
+
key: taskMatch.key,
|
|
58
|
+
status: taskMatch.archived_at == null ? "Active" : "Archived",
|
|
59
|
+
column: column.getById(taskMatch.column_id)!.name,
|
|
60
|
+
title: taskMatch.title,
|
|
61
|
+
description: taskMatch.description,
|
|
62
|
+
priority: taskMatch.priority,
|
|
63
|
+
labels: task.label.getAll(taskMatch.key).map((label) => label.name),
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function formatTask(presented: PresentedTask, options: { showsStatus?: boolean } = {}) {
|
|
68
|
+
const status = options.showsStatus ? ` | ${presented.status}` : "";
|
|
69
|
+
const column = formatTaskColumn(presented.column);
|
|
70
|
+
const description = presented.description == null ? "" : ` | ${presented.description}`;
|
|
71
|
+
|
|
72
|
+
const priority = presented.priority == null ? "" : ` | Priority: ${presented.priority}`;
|
|
73
|
+
const labelText =
|
|
74
|
+
presented.labels.length === 0 ? "" : ` | Labels: ${presented.labels.join(", ")}`;
|
|
75
|
+
|
|
76
|
+
return `${presented.key}${status} | ${column} | ${presented.title}${description}${priority}${labelText}`;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export function formatTaskWithStatus(presented: PresentedTask) {
|
|
80
|
+
return formatTask(presented, { showsStatus: true });
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function formatTaskMove(presented: PresentedTask) {
|
|
84
|
+
return `${presented.key} | ${formatTaskColumn(presented.column)}`;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function formatTaskList(
|
|
88
|
+
presentedTasks: Array<PresentedTask>,
|
|
89
|
+
options: { showsStatus?: boolean } = {},
|
|
90
|
+
) {
|
|
91
|
+
const longestKeyLength = presentedTasks.reduce(
|
|
92
|
+
(previousLength, currentTask) => Math.max(previousLength, currentTask.key.length),
|
|
93
|
+
0,
|
|
94
|
+
);
|
|
95
|
+
const longestColumnNameLength = presentedTasks.reduce(
|
|
96
|
+
(previousLength, currentTask) => Math.max(previousLength, currentTask.column.length),
|
|
97
|
+
0,
|
|
98
|
+
);
|
|
99
|
+
const longestStatusLength = presentedTasks.reduce(
|
|
100
|
+
(previousLength, currentTask) => Math.max(previousLength, currentTask.status.length),
|
|
101
|
+
0,
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
return presentedTasks
|
|
105
|
+
.map((presentedTask) => {
|
|
106
|
+
const status = options.showsStatus
|
|
107
|
+
? ` | ${presentedTask.status.padEnd(longestStatusLength)}`
|
|
108
|
+
: "";
|
|
109
|
+
const descriptionPreview = formatTaskDescriptionPreview(presentedTask.description);
|
|
110
|
+
const description =
|
|
111
|
+
presentedTask.description == null ? "" : ` | ${descriptionPreview}`;
|
|
112
|
+
const priority = formatTaskPriorityMarker(presentedTask.priority);
|
|
113
|
+
const column = formatTaskColumn(presentedTask.column, longestColumnNameLength);
|
|
114
|
+
|
|
115
|
+
return `${presentedTask.key.padEnd(longestKeyLength)}${status} | ${column} | ${priority} | ${presentedTask.title}${description}`;
|
|
116
|
+
})
|
|
117
|
+
.join("\n");
|
|
118
|
+
}
|
|
@@ -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>
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { RouteDef } from "../types";
|
|
2
|
+
import type { PresentedTask } from "../presentation/task-presentation";
|
|
2
3
|
|
|
3
4
|
import { parseArgs } from "node:util";
|
|
4
5
|
|
|
5
|
-
import { column, project } from "@zinn-dev/core";
|
|
6
|
+
import { column, project, task } from "@zinn-dev/core";
|
|
6
7
|
import {
|
|
7
8
|
confirmAction,
|
|
8
9
|
output,
|
|
@@ -10,8 +11,10 @@ import {
|
|
|
10
11
|
validatePositionalCount,
|
|
11
12
|
validateUniqueOptions,
|
|
12
13
|
} from "../lib";
|
|
14
|
+
import { formatTaskList, presentTask } from "../presentation/task-presentation";
|
|
13
15
|
|
|
14
16
|
type PresentedProject = { key: string; name: string };
|
|
17
|
+
type PresentedProjectView = PresentedProject & { tasks: Array<PresentedTask> };
|
|
15
18
|
|
|
16
19
|
function presentProject(projectMatch: PresentedProject): PresentedProject {
|
|
17
20
|
return { key: projectMatch.key, name: projectMatch.name };
|
|
@@ -116,6 +119,40 @@ Example: zinn project create MDR --name "Macrodata Refinement"`,
|
|
|
116
119
|
List projects and their keys.
|
|
117
120
|
|
|
118
121
|
Example: zinn project list`,
|
|
122
|
+
},
|
|
123
|
+
view: {
|
|
124
|
+
run: (args: Array<string>) => {
|
|
125
|
+
const projectKey = args[0];
|
|
126
|
+
|
|
127
|
+
if (projectKey == null) {
|
|
128
|
+
quit("Project key must be specified");
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
validatePositionalCount(args, 1, "Only one project key can be specified");
|
|
132
|
+
|
|
133
|
+
const projectMatch = project.getByKey(projectKey);
|
|
134
|
+
|
|
135
|
+
if (projectMatch == null) {
|
|
136
|
+
quit(`Project with key "${project.standardizeKey(projectKey)}" does not exist!`);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const presentedProject: PresentedProjectView = {
|
|
140
|
+
...presentProject(projectMatch),
|
|
141
|
+
tasks: task.getAll({ projectKey, archive: "active" }).map(presentTask),
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
output(presentedProject, (viewedProject) => {
|
|
145
|
+
const projectHeader = formatProject(viewedProject);
|
|
146
|
+
const taskList = formatTaskList(viewedProject.tasks);
|
|
147
|
+
|
|
148
|
+
return taskList.length === 0 ? projectHeader : `${projectHeader}\n\n${taskList}`;
|
|
149
|
+
});
|
|
150
|
+
},
|
|
151
|
+
help: `Usage: zinn project view <project-key>
|
|
152
|
+
|
|
153
|
+
Show a project and its active tasks in board order.
|
|
154
|
+
|
|
155
|
+
Example: zinn project view MDR`,
|
|
119
156
|
},
|
|
120
157
|
delete: {
|
|
121
158
|
run: (args: Array<string>) => {
|
|
@@ -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);
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import type { TaskPriority } from "@zinn-dev/core";
|
|
2
1
|
import type { RouteDef } from "../types";
|
|
3
2
|
|
|
4
|
-
import { parseArgs
|
|
5
|
-
import { task, project
|
|
3
|
+
import { parseArgs } from "node:util";
|
|
4
|
+
import { task, project } from "@zinn-dev/core";
|
|
6
5
|
|
|
7
6
|
import {
|
|
8
7
|
confirmAction,
|
|
@@ -12,91 +11,14 @@ import {
|
|
|
12
11
|
validateUniqueOptions,
|
|
13
12
|
} from "../lib";
|
|
14
13
|
import { formatRelations, presentRelations, relationRouter } from "./relation-router";
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
if (normalizedDescription.length <= TASK_DESCRIPTION_PREVIEW_LENGTH) {
|
|
25
|
-
return normalizedDescription;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return `${normalizedDescription.slice(0, TASK_DESCRIPTION_PREVIEW_LENGTH - 1).trimEnd()}…`;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
type PresentedTask = {
|
|
32
|
-
key: string;
|
|
33
|
-
status: "Active" | "Archived";
|
|
34
|
-
column: string;
|
|
35
|
-
title: string;
|
|
36
|
-
description: string | null;
|
|
37
|
-
priority: TaskPriority | null;
|
|
38
|
-
labels: Array<string>;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
function formatTaskPriorityMarker(priority: TaskPriority | null) {
|
|
42
|
-
if (priority == null) {
|
|
43
|
-
return "-";
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return priority[0]!.toUpperCase();
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function formatTaskColumn(columnName: string, width = columnName.length) {
|
|
50
|
-
const paddedColumnName = columnName.padEnd(width);
|
|
51
|
-
|
|
52
|
-
// TODO: Derive column colors from column roles once roles exist instead of relying on names.
|
|
53
|
-
if (columnName === "Backlog") {
|
|
54
|
-
return styleText("gray", paddedColumnName);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (columnName === "Done") {
|
|
58
|
-
return styleText("green", paddedColumnName);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return paddedColumnName;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function presentTask(taskMatch: ReturnType<typeof task.getByKey>): PresentedTask {
|
|
65
|
-
return {
|
|
66
|
-
key: taskMatch.key,
|
|
67
|
-
status: taskMatch.archived_at == null ? "Active" : "Archived",
|
|
68
|
-
column: column.getById(taskMatch.column_id)!.name,
|
|
69
|
-
title: taskMatch.title,
|
|
70
|
-
description: taskMatch.description,
|
|
71
|
-
priority: taskMatch.priority,
|
|
72
|
-
labels: task.label.getAll(taskMatch.key).map((label) => label.name),
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// TODO: a CLI row formatter that accepts text columns and joins them with " | " would be useful
|
|
77
|
-
// Reuse it across task list/view and other command output in a separate change.
|
|
78
|
-
function formatTask(
|
|
79
|
-
presented: PresentedTask,
|
|
80
|
-
options: { showsStatus?: boolean } = {},
|
|
81
|
-
) {
|
|
82
|
-
const status = options.showsStatus ? ` | ${presented.status}` : "";
|
|
83
|
-
const column = formatTaskColumn(presented.column);
|
|
84
|
-
const description = presented.description == null ? "" : ` | ${presented.description}`;
|
|
85
|
-
|
|
86
|
-
const priority = presented.priority == null ? "" : ` | Priority: ${presented.priority}`;
|
|
87
|
-
const labelText =
|
|
88
|
-
presented.labels.length === 0 ? "" : ` | Labels: ${presented.labels.join(", ")}`;
|
|
89
|
-
|
|
90
|
-
return `${presented.key}${status} | ${column} | ${presented.title}${description}${priority}${labelText}`;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
function formatTaskWithStatus(presented: PresentedTask) {
|
|
94
|
-
return formatTask(presented, { showsStatus: true });
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
function formatTaskMove(presented: PresentedTask) {
|
|
98
|
-
return `${presented.key} | ${formatTaskColumn(presented.column)}`;
|
|
99
|
-
}
|
|
14
|
+
import { currentActor } from "../actor";
|
|
15
|
+
import {
|
|
16
|
+
formatTask,
|
|
17
|
+
formatTaskList,
|
|
18
|
+
formatTaskMove,
|
|
19
|
+
formatTaskWithStatus,
|
|
20
|
+
presentTask,
|
|
21
|
+
} from "../presentation/task-presentation";
|
|
100
22
|
|
|
101
23
|
export const taskRouter = {
|
|
102
24
|
edit: {
|
|
@@ -138,14 +60,17 @@ export const taskRouter = {
|
|
|
138
60
|
);
|
|
139
61
|
}
|
|
140
62
|
|
|
141
|
-
const editedTask = task.edit(
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
63
|
+
const editedTask = task.edit(
|
|
64
|
+
{
|
|
65
|
+
taskKey,
|
|
66
|
+
title: values.title,
|
|
67
|
+
description: values.description,
|
|
68
|
+
priority: parsePriority(values.priority),
|
|
69
|
+
addLabelNames: values["add-label"],
|
|
70
|
+
removeLabelNames: values["remove-label"],
|
|
71
|
+
},
|
|
72
|
+
currentActor(),
|
|
73
|
+
);
|
|
149
74
|
|
|
150
75
|
output(presentTask(editedTask), formatTask);
|
|
151
76
|
},
|
|
@@ -197,13 +122,16 @@ Example: zinn task edit MDR-1 --title "Meet the quarterly refinement quota"`,
|
|
|
197
122
|
if (projectMatch == null) {
|
|
198
123
|
quit(`Project with key "${project.standardizeKey(projectKey)}" does not exist`);
|
|
199
124
|
}
|
|
200
|
-
const createdTask = task.create(
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
125
|
+
const createdTask = task.create(
|
|
126
|
+
{
|
|
127
|
+
project_id: projectMatch.id,
|
|
128
|
+
title: values.title,
|
|
129
|
+
description: values.description ?? null,
|
|
130
|
+
priority: parsePriority(values.priority),
|
|
131
|
+
labelNames: values.label,
|
|
132
|
+
},
|
|
133
|
+
currentActor(),
|
|
134
|
+
);
|
|
207
135
|
output(presentTask(createdTask), formatTask);
|
|
208
136
|
},
|
|
209
137
|
help: `Usage: zinn task create <project-key> --title <text> [--description <text>] [--priority <low|medium|high|urgent|none>] [--label <name>]
|
|
@@ -235,34 +163,9 @@ Example: zinn task create MDR --title "Refine the numbers" --description "Meet t
|
|
|
235
163
|
|
|
236
164
|
const tasks = task.getAll({ projectKey, archive });
|
|
237
165
|
|
|
238
|
-
output(tasks.map(presentTask), (presentedTasks) =>
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
0,
|
|
242
|
-
);
|
|
243
|
-
const longestColumnNameLength = presentedTasks.reduce(
|
|
244
|
-
(previousLength, currentTask) =>
|
|
245
|
-
Math.max(previousLength, currentTask.column.length),
|
|
246
|
-
0,
|
|
247
|
-
);
|
|
248
|
-
const longestStatusLength = presentedTasks.reduce(
|
|
249
|
-
(prev, current) => Math.max(prev, current.status.length),
|
|
250
|
-
0,
|
|
251
|
-
);
|
|
252
|
-
|
|
253
|
-
return presentedTasks
|
|
254
|
-
.map((t) => {
|
|
255
|
-
// TODO: console output formatting for standardizied output
|
|
256
|
-
const status = showsAll ? ` | ${t.status.padEnd(longestStatusLength)}` : "";
|
|
257
|
-
const descriptionPreview = formatTaskDescriptionPreview(t.description);
|
|
258
|
-
const description = t.description == null ? "" : ` | ${descriptionPreview}`;
|
|
259
|
-
const priority = formatTaskPriorityMarker(t.priority);
|
|
260
|
-
const column = formatTaskColumn(t.column, longestColumnNameLength);
|
|
261
|
-
|
|
262
|
-
return `${t.key.padEnd(longestKeyLength)}${status} | ${column} | ${priority} | ${t.title}${description}`;
|
|
263
|
-
})
|
|
264
|
-
.join("\n");
|
|
265
|
-
});
|
|
166
|
+
output(tasks.map(presentTask), (presentedTasks) =>
|
|
167
|
+
formatTaskList(presentedTasks, { showsStatus: showsAll }),
|
|
168
|
+
);
|
|
266
169
|
},
|
|
267
170
|
help: `Usage: zinn task list [project-key] [--archived | --all]
|
|
268
171
|
|
|
@@ -310,7 +213,7 @@ Example: zinn task view MDR-1`,
|
|
|
310
213
|
quit("Target column must be specified");
|
|
311
214
|
}
|
|
312
215
|
|
|
313
|
-
const movedTask = task.move({ taskKey, targetColumn });
|
|
216
|
+
const movedTask = task.move({ taskKey, targetColumn }, currentActor());
|
|
314
217
|
output(presentTask(movedTask), formatTaskMove);
|
|
315
218
|
},
|
|
316
219
|
help: `Usage: zinn task move <task-key> <target-column>
|
|
@@ -349,7 +252,7 @@ Example: zinn task move MDR-1 "In Progress"`,
|
|
|
349
252
|
quit("Only one target task can be specified");
|
|
350
253
|
}
|
|
351
254
|
|
|
352
|
-
const orderedTask = task.order({ taskKey, direction, targetTaskKey });
|
|
255
|
+
const orderedTask = task.order({ taskKey, direction, targetTaskKey }, currentActor());
|
|
353
256
|
output(presentTask(orderedTask), formatTask);
|
|
354
257
|
return;
|
|
355
258
|
}
|
|
@@ -361,7 +264,7 @@ Example: zinn task move MDR-1 "In Progress"`,
|
|
|
361
264
|
quit(`Order direction "${direction}" does not accept a target task`);
|
|
362
265
|
}
|
|
363
266
|
|
|
364
|
-
const orderedTask = task.order({ taskKey, direction });
|
|
267
|
+
const orderedTask = task.order({ taskKey, direction }, currentActor());
|
|
365
268
|
output(presentTask(orderedTask), formatTask);
|
|
366
269
|
return;
|
|
367
270
|
}
|
|
@@ -392,7 +295,7 @@ Example: zinn task order MDR-2 before MDR-1`,
|
|
|
392
295
|
const presented = presentTask(taskMatch);
|
|
393
296
|
|
|
394
297
|
if (canDelete) {
|
|
395
|
-
task.delete(taskKey);
|
|
298
|
+
task.delete(taskKey, currentActor());
|
|
396
299
|
output(presented, (t) => `Deleted ${formatTask(t)}`);
|
|
397
300
|
} else {
|
|
398
301
|
output(presented, (t) => `Deletion cancelled for ${formatTask(t)}`);
|
|
@@ -415,7 +318,7 @@ Example: zinn task delete MDR-1`,
|
|
|
415
318
|
quit("Task key must be specified");
|
|
416
319
|
}
|
|
417
320
|
|
|
418
|
-
const archivedTask = task.archive(taskKey);
|
|
321
|
+
const archivedTask = task.archive(taskKey, currentActor());
|
|
419
322
|
output(presentTask(archivedTask), formatTaskWithStatus);
|
|
420
323
|
},
|
|
421
324
|
help: `Usage: zinn task archive <task-key>
|
|
@@ -432,7 +335,7 @@ Example: zinn task archive MDR-1`,
|
|
|
432
335
|
quit("Task key must be specified");
|
|
433
336
|
}
|
|
434
337
|
|
|
435
|
-
const unarchivedTask = task.unarchive(taskKey);
|
|
338
|
+
const unarchivedTask = task.unarchive(taskKey, currentActor());
|
|
436
339
|
output(presentTask(unarchivedTask), formatTaskWithStatus);
|
|
437
340
|
},
|
|
438
341
|
help: `Usage: zinn task unarchive <task-key>
|
|
@@ -446,7 +349,7 @@ Example: zinn task unarchive MDR-1`,
|
|
|
446
349
|
add: {
|
|
447
350
|
run: (args) => {
|
|
448
351
|
const props = parseTaskLabelArgs(args);
|
|
449
|
-
output(presentTask(task.label.add(props)), formatTask);
|
|
352
|
+
output(presentTask(task.label.add(props, currentActor())), formatTask);
|
|
450
353
|
},
|
|
451
354
|
help: `Usage: zinn task label add <task-key> <label-name> [label-name ...]
|
|
452
355
|
|
|
@@ -455,7 +358,7 @@ Add existing labels to a task. Already attached labels are unchanged.`,
|
|
|
455
358
|
remove: {
|
|
456
359
|
run: (args) => {
|
|
457
360
|
const props = parseTaskLabelArgs(args);
|
|
458
|
-
output(presentTask(task.label.remove(props)), formatTask);
|
|
361
|
+
output(presentTask(task.label.remove(props, currentActor())), formatTask);
|
|
459
362
|
},
|
|
460
363
|
help: `Usage: zinn task label remove <task-key> <label-name> [label-name ...]
|
|
461
364
|
|