@zinn-dev/cli 0.44.0 → 0.46.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 +1 -1
- package/package.json +3 -3
- package/skills/zinn/SKILL.md +7 -9
- package/src/actor.d.ts +1 -1
- package/src/actor.js +4 -1
- package/src/capabilities-schema.d.ts +9 -1
- package/src/column-hint.js +1 -3
- package/src/database.d.ts +1 -2
- package/src/database.js +1 -6
- package/src/duration-input.d.ts +7 -0
- package/src/duration-input.js +31 -0
- package/src/errors.d.ts +26 -0
- package/src/errors.js +46 -8
- package/src/expected-values.d.ts +48 -0
- package/src/expected-values.js +60 -0
- package/src/follow.d.ts +9 -0
- package/src/follow.js +58 -0
- package/src/input.d.ts +0 -8
- package/src/input.js +36 -16
- package/src/lib.d.ts +7 -3
- package/src/lib.js +70 -28
- package/src/list-continuation.js +1 -4
- package/src/presentation/activity-presentation.d.ts +2 -0
- package/src/presentation/activity-presentation.js +60 -3
- package/src/presentation/column-presentation.d.ts +9 -4
- package/src/presentation/column-presentation.js +29 -12
- package/src/presentation/doctor-presentation.d.ts +10 -0
- package/src/presentation/doctor-presentation.js +28 -0
- package/src/presentation/relation-presentation.js +2 -1
- package/src/presentation/skill-status-presentation.d.ts +9 -0
- package/src/presentation/skill-status-presentation.js +43 -0
- package/src/presentation/task-blame-presentation.d.ts +2 -4
- package/src/presentation/task-blame-presentation.js +4 -2
- package/src/presentation/task-presentation.d.ts +18 -4
- package/src/presentation/task-presentation.js +94 -30
- package/src/result-schemas.d.ts +490 -58
- package/src/result-schemas.js +97 -2
- package/src/results.d.ts +6 -2
- package/src/results.js +9 -3
- package/src/routes/activity-router.d.ts +16 -5
- package/src/routes/activity-router.js +131 -70
- package/src/routes/aliases.js +1 -0
- package/src/routes/backup-router.d.ts +1 -0
- package/src/routes/backup-router.js +4 -3
- package/src/routes/capabilities-router.d.ts +1 -0
- package/src/routes/capabilities-router.js +1 -1
- package/src/routes/comment-router.d.ts +29 -6
- package/src/routes/comment-router.js +20 -10
- package/src/routes/doctor-router.d.ts +40 -0
- package/src/routes/doctor-router.js +83 -0
- package/src/routes/info-router.d.ts +1 -0
- package/src/routes/info-router.js +1 -1
- package/src/routes/label-router.d.ts +44 -6
- package/src/routes/label-router.js +27 -10
- package/src/routes/migrate-router.d.ts +1 -0
- package/src/routes/migrate-router.js +5 -7
- package/src/routes/project-router.d.ts +70 -11
- package/src/routes/project-router.js +130 -56
- package/src/routes/reindex-router.d.ts +1 -0
- package/src/routes/reindex-router.js +1 -1
- package/src/routes/relation-router.d.ts +3 -0
- package/src/routes/relation-router.js +9 -6
- package/src/routes/restore-router.d.ts +1 -0
- package/src/routes/restore-router.js +5 -6
- package/src/routes/router.js +5 -9
- package/src/routes/routes.d.ts +517 -35
- package/src/routes/routes.js +4 -0
- package/src/routes/skill-router.d.ts +76 -0
- package/src/routes/skill-router.js +179 -0
- package/src/routes/task-router.d.ts +264 -13
- package/src/routes/task-router.js +415 -93
- package/src/routes/whoami-router.d.ts +1 -0
- package/src/routes/whoami-router.js +1 -1
- package/src/skill-copies.d.ts +34 -0
- package/src/skill-copies.js +109 -0
- package/src/telemetry.d.ts +2 -2
- package/src/telemetry.js +8 -3
- package/src/text-edit.d.ts +2 -2
- package/src/text-input.d.ts +19 -1
- package/src/text-input.js +26 -5
- package/src/types.d.ts +4 -0
- package/src/types.js +6 -0
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { jsonResult, taskDetailResults, taskChangeResults } from "../results.js";
|
|
2
2
|
import { parseArgs } from "node:util";
|
|
3
|
-
import { activity, task, project, parseTaskKey, taskCreateSchema, taskEditSchema, taskDeleteManySchema, taskPrioritySchema, taskSortSchema, } from "@zinn-dev/core";
|
|
3
|
+
import { activity, task, project, readSnapshot, parseTaskKey, taskCreateSchema, taskEditSchema, taskDeleteManySchema, taskPrioritySchema, taskSortSchema, taskStateFilterSchema, CLAIM_WORK_LIMIT_MS, MIN_CLAIM_LEASE_MS, CoreError, } from "@zinn-dev/core";
|
|
4
4
|
import { listLimitOption, listLimitDescription, parseListLimit } from "../list-limit.js";
|
|
5
5
|
import { formatListContinuation } from "../list-continuation.js";
|
|
6
6
|
import { parseTimestampInput } from "../timestamp-input.js";
|
|
7
|
+
import { durationPattern, formatDurationInput, parseDurationInput } from "../duration-input.js";
|
|
7
8
|
import { CliError } from "../errors.js";
|
|
8
9
|
import { generateCommandUsage, taskKeyPositional, archiveConstraint, getOptionInputs, violatesConstraint, } from "../input.js";
|
|
9
|
-
import { confirmationDescription, confirmAction, dashValueHelp, diagnostic, output, outputChanges, quit, validatePositionals, validateOrderForms, requireStringOption, renameFlag, validateUniqueOptions, } from "../lib.js";
|
|
10
|
+
import { confirmationDescription, confirmAction, dashValueHelp, diagnostic, getOutputMode, output, outputChanges, quit, validatePositionals, validateTaskKey, validateOrderForms, requireStringOption, renameFlag, validateUniqueOptions, } from "../lib.js";
|
|
10
11
|
import { resolveTextEdit, textEditHelp, textEditOptions, textEditConstraints, } from "../text-edit.js";
|
|
11
|
-
import {
|
|
12
|
+
import { expectedValueFlags } from "../expected-values.js";
|
|
13
|
+
import { checkFieldsBeforeText, checkSingleStdinReader, resolveTextInput, textFileHelp, textFileOption, textSourceConstraint, } from "../text-input.js";
|
|
12
14
|
import { currentActor } from "../actor.js";
|
|
13
|
-
import { checkDefaultProject, chooseProjectKey,
|
|
15
|
+
import { checkDefaultProject, chooseProjectKey, projectScopeConstraint, requiredProjectDescription, projectScopeDescription, } from "../project.js";
|
|
14
16
|
import { relationRouter } from "./relation-router.js";
|
|
15
17
|
import { commentRouter } from "./comment-router.js";
|
|
16
18
|
import { formatRelationList, presentRelations } from "../presentation/relation-presentation.js";
|
|
@@ -18,8 +20,8 @@ import { formatCommentList, presentComments } from "../presentation/comment-pres
|
|
|
18
20
|
import { formatSection } from "../presentation/section.js";
|
|
19
21
|
import { abbreviateActivityIds, formatActivityList, presentActivities, } from "../presentation/activity-presentation.js";
|
|
20
22
|
import { formatTaskBlame } from "../presentation/task-blame-presentation.js";
|
|
21
|
-
import {
|
|
22
|
-
import { formatTaskList, formatTaskTimestamps, presentTask, } from "../presentation/task-presentation.js";
|
|
23
|
+
import { createColumnBoard } from "../presentation/column-presentation.js";
|
|
24
|
+
import { formatTaskList, formatTaskTimestamps, getLabelColorsByName, presentTask, presentTaskSearchResults, presentTasks, } from "../presentation/task-presentation.js";
|
|
23
25
|
// A column is changed with task move, so a guessed --status or --column suggests it with the same task keys.
|
|
24
26
|
function suggestTaskMove(args, options = {}) {
|
|
25
27
|
const { values, positionals } = parseArgs({
|
|
@@ -32,6 +34,30 @@ function suggestTaskMove(args, options = {}) {
|
|
|
32
34
|
const columnWords = typeof guessedColumn === "string" ? [guessedColumn] : [];
|
|
33
35
|
return ["task", "move", ...positionals, ...columnWords];
|
|
34
36
|
}
|
|
37
|
+
// Project view lists the archived count beside the columns, so "Archived" reads like a move target.
|
|
38
|
+
const archiveTargetNames = ["archive", "archived"];
|
|
39
|
+
const searchMatchesConstraint = {
|
|
40
|
+
kind: "requires",
|
|
41
|
+
input: "option:with-matches",
|
|
42
|
+
requires: "option:json",
|
|
43
|
+
};
|
|
44
|
+
/** Moves tasks, and points a move to a missing Archived column at task archive. */
|
|
45
|
+
function moveOrPointToArchive(taskKeys, targetColumn, fromColumn) {
|
|
46
|
+
try {
|
|
47
|
+
return task.moveMany({ taskKeys, targetColumn, fromColumn }, currentActor());
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
const isMissingArchivedTarget = error instanceof CoreError &&
|
|
51
|
+
error.kind === "missing" &&
|
|
52
|
+
error.facts.entity === "column" &&
|
|
53
|
+
error.facts.key === targetColumn &&
|
|
54
|
+
archiveTargetNames.includes(targetColumn.toLowerCase());
|
|
55
|
+
if (!isMissingArchivedTarget) {
|
|
56
|
+
throw error;
|
|
57
|
+
}
|
|
58
|
+
throw new CliError(`${error.message}. Archive tasks with zinn task archive ${taskKeys.join(" ")}.`, "not_found", { entity: "column", key: targetColumn, source: "explicit" }, undefined, ["task", "archive"], error);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
35
61
|
const priorityOption = {
|
|
36
62
|
type: "string",
|
|
37
63
|
value: {
|
|
@@ -50,6 +76,29 @@ const dueOption = {
|
|
|
50
76
|
description: "Integer epoch milliseconds or YYYY-MM-DDTHH:mm:ss[.SSS] with Z or a numeric offset. Fractions have 1 to 3 digits. none clears the deadline, ignoring case. Omission leaves it unset on creation and unchanged on edit.",
|
|
51
77
|
},
|
|
52
78
|
};
|
|
79
|
+
const taskExpectations = expectedValueFlags({
|
|
80
|
+
title: { field: "title", option: { type: "string", value: { kind: "text", name: "text" } } },
|
|
81
|
+
description: { field: "description", text: true },
|
|
82
|
+
priority: {
|
|
83
|
+
field: "priority",
|
|
84
|
+
option: {
|
|
85
|
+
type: "string",
|
|
86
|
+
value: { ...priorityOption.value, description: "none expects no priority." },
|
|
87
|
+
},
|
|
88
|
+
parse: parsePriority,
|
|
89
|
+
},
|
|
90
|
+
due: {
|
|
91
|
+
field: "due_at",
|
|
92
|
+
option: {
|
|
93
|
+
type: "string",
|
|
94
|
+
value: {
|
|
95
|
+
...dueOption.value,
|
|
96
|
+
description: "Same formats as --due. none expects no deadline, ignoring case.",
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
parse: parseDue,
|
|
100
|
+
},
|
|
101
|
+
});
|
|
53
102
|
const deadlineFilterOptions = {
|
|
54
103
|
"due-since": {
|
|
55
104
|
type: "string",
|
|
@@ -118,6 +167,10 @@ const taskInputs = {
|
|
|
118
167
|
type: "string",
|
|
119
168
|
value: { kind: "enum", name: "key", choices: taskSortSchema.options },
|
|
120
169
|
},
|
|
170
|
+
state: {
|
|
171
|
+
type: "string",
|
|
172
|
+
value: { kind: "enum", name: "state", choices: taskStateFilterSchema.options },
|
|
173
|
+
},
|
|
121
174
|
archived: { type: "boolean" },
|
|
122
175
|
all: { type: "boolean" },
|
|
123
176
|
"all-projects": { type: "boolean" },
|
|
@@ -153,6 +206,7 @@ const taskInputs = {
|
|
|
153
206
|
limit: listLimitOption,
|
|
154
207
|
label: { type: "string", multiple: true, value: { kind: "label-name", name: "name" } },
|
|
155
208
|
column: { type: "string", value: { kind: "column-name", name: "name" } },
|
|
209
|
+
"with-matches": { type: "boolean", description: "Include match excerpts in JSON results" },
|
|
156
210
|
},
|
|
157
211
|
forms: [
|
|
158
212
|
{
|
|
@@ -163,12 +217,26 @@ const taskInputs = {
|
|
|
163
217
|
],
|
|
164
218
|
},
|
|
165
219
|
],
|
|
166
|
-
constraints: [archiveConstraint, projectScopeConstraint],
|
|
220
|
+
constraints: [archiveConstraint, projectScopeConstraint, searchMatchesConstraint],
|
|
167
221
|
notes: [
|
|
168
222
|
projectScopeDescription,
|
|
169
223
|
"A query that is a task key ignores defaultProject unless a project was typed. --all-projects still excludes a typed project.",
|
|
170
224
|
],
|
|
171
225
|
},
|
|
226
|
+
next: {
|
|
227
|
+
options: {
|
|
228
|
+
"all-projects": { type: "boolean" },
|
|
229
|
+
column: { type: "string", value: { kind: "column-name", name: "name" } },
|
|
230
|
+
},
|
|
231
|
+
forms: [
|
|
232
|
+
{
|
|
233
|
+
id: "default",
|
|
234
|
+
positionals: [{ name: "project-key", min: 0, max: 1, value: { kind: "project-key" } }],
|
|
235
|
+
},
|
|
236
|
+
],
|
|
237
|
+
constraints: [projectScopeConstraint],
|
|
238
|
+
notes: [projectScopeDescription],
|
|
239
|
+
},
|
|
172
240
|
view: {
|
|
173
241
|
options: { history: { type: "boolean" } },
|
|
174
242
|
forms: [
|
|
@@ -198,6 +266,7 @@ const taskInputs = {
|
|
|
198
266
|
multiple: true,
|
|
199
267
|
value: { kind: "label-name", name: "name" },
|
|
200
268
|
},
|
|
269
|
+
...taskExpectations.options,
|
|
201
270
|
},
|
|
202
271
|
forms: [
|
|
203
272
|
{
|
|
@@ -209,11 +278,14 @@ const taskInputs = {
|
|
|
209
278
|
textSourceConstraint("--description"),
|
|
210
279
|
...textEditConstraints("--description"),
|
|
211
280
|
taskEditConstraint,
|
|
281
|
+
...taskExpectations.constraints,
|
|
212
282
|
],
|
|
213
|
-
notes: [textEditHelp("--description")],
|
|
283
|
+
notes: [textEditHelp("--description"), taskExpectations.help],
|
|
214
284
|
},
|
|
215
285
|
move: {
|
|
216
|
-
options: {
|
|
286
|
+
options: {
|
|
287
|
+
from: { type: "string", value: { kind: "column-name", name: "column" } },
|
|
288
|
+
},
|
|
217
289
|
forms: [
|
|
218
290
|
{
|
|
219
291
|
id: "default",
|
|
@@ -273,6 +345,28 @@ const taskInputs = {
|
|
|
273
345
|
],
|
|
274
346
|
constraints: [],
|
|
275
347
|
},
|
|
348
|
+
claim: {
|
|
349
|
+
options: {
|
|
350
|
+
lease: {
|
|
351
|
+
type: "string",
|
|
352
|
+
required: true,
|
|
353
|
+
value: {
|
|
354
|
+
kind: "duration",
|
|
355
|
+
name: "duration",
|
|
356
|
+
pattern: durationPattern,
|
|
357
|
+
description: `Whole minutes or hours, such as 30m or 2h, from ${formatDurationInput(MIN_CLAIM_LEASE_MS)} through ${formatDurationInput(CLAIM_WORK_LIMIT_MS)}.`,
|
|
358
|
+
},
|
|
359
|
+
},
|
|
360
|
+
force: { type: "boolean" },
|
|
361
|
+
},
|
|
362
|
+
forms: [{ id: "default", positionals: [taskKeyPositional] }],
|
|
363
|
+
constraints: [],
|
|
364
|
+
},
|
|
365
|
+
heartbeat: {
|
|
366
|
+
options: {},
|
|
367
|
+
forms: [{ id: "default", positionals: [taskKeyPositional] }],
|
|
368
|
+
constraints: [],
|
|
369
|
+
},
|
|
276
370
|
delete: {
|
|
277
371
|
options: { yes: { type: "boolean" } },
|
|
278
372
|
forms: [
|
|
@@ -300,7 +394,7 @@ const taskInputs = {
|
|
|
300
394
|
export const taskRouter = {
|
|
301
395
|
create: {
|
|
302
396
|
summary: "Create a task at the bottom of a column. Without --column, it starts in the project's first column.",
|
|
303
|
-
effects: { domain: "create", storage: "normal-open" },
|
|
397
|
+
effects: { domain: "create", storage: "normal-open", external: [] },
|
|
304
398
|
confirmation: { kind: "none" },
|
|
305
399
|
input: taskInputs.create,
|
|
306
400
|
results: [jsonResult("Task")],
|
|
@@ -370,12 +464,12 @@ Unknown columns, labels or related tasks abort creation.
|
|
|
370
464
|
|
|
371
465
|
Examples:
|
|
372
466
|
zinn task create MDR --title 'Refine the numbers' --description 'Meet the quarterly quota' --label urgent
|
|
373
|
-
zinn task create MDR --title 'Review the numbers' --column
|
|
467
|
+
zinn task create MDR --title 'Review the numbers' --column Doing
|
|
374
468
|
zinn task create MDR --title 'Sort the files' --parent MDR-1 --depends-on MDR-2`,
|
|
375
469
|
},
|
|
376
470
|
list: {
|
|
377
471
|
summary: "List active tasks by default.",
|
|
378
|
-
effects: { domain: "read", storage: "normal-open" },
|
|
472
|
+
effects: { domain: "read", storage: "normal-open", external: [] },
|
|
379
473
|
confirmation: { kind: "none" },
|
|
380
474
|
input: taskInputs.list,
|
|
381
475
|
results: [jsonResult("TaskList")],
|
|
@@ -392,7 +486,10 @@ Examples:
|
|
|
392
486
|
if (violatesConstraint(archiveConstraint, getOptionInputs(values))) {
|
|
393
487
|
quit('Use either "--archived" or "--all", not both', undefined, { argument: "--archived" });
|
|
394
488
|
}
|
|
395
|
-
const
|
|
489
|
+
const projectChoice = chooseProjectKey(positionals[0], {
|
|
490
|
+
allProjects: values["all-projects"],
|
|
491
|
+
});
|
|
492
|
+
const projectKey = projectChoice?.key;
|
|
396
493
|
const archive = values.all ? "all" : values.archived ? "archived" : "active";
|
|
397
494
|
const limit = parseListLimit(values.limit);
|
|
398
495
|
const sort = taskSortSchema.optional().safeParse(values.sort);
|
|
@@ -401,28 +498,44 @@ Examples:
|
|
|
401
498
|
argument: "--sort",
|
|
402
499
|
});
|
|
403
500
|
}
|
|
404
|
-
const
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
501
|
+
const state = taskStateFilterSchema.optional().safeParse(values.state);
|
|
502
|
+
if (!state.success) {
|
|
503
|
+
quit(`Unknown state "${values.state}". Use ${taskStateFilterSchema.options.join(", ")}`, undefined, { argument: "--state" });
|
|
504
|
+
}
|
|
505
|
+
const deadlineFilters = parseDeadlineFilters(values);
|
|
506
|
+
const { presentedTasks, nextCursor, labelColorsByName } = readSnapshot(() => {
|
|
507
|
+
if (projectChoice !== undefined) {
|
|
508
|
+
checkDefaultProject(projectChoice);
|
|
509
|
+
}
|
|
510
|
+
const page = task.getPage({
|
|
511
|
+
...deadlineFilters,
|
|
512
|
+
limit,
|
|
513
|
+
sort: sort.data,
|
|
514
|
+
projectKey,
|
|
515
|
+
archive,
|
|
516
|
+
state: state.data,
|
|
517
|
+
labelNames: values.label,
|
|
518
|
+
columnName: values.column,
|
|
519
|
+
startingAfter: values["starting-after"],
|
|
520
|
+
});
|
|
521
|
+
return {
|
|
522
|
+
presentedTasks: presentTasks(page.tasks),
|
|
523
|
+
nextCursor: page.nextCursor,
|
|
524
|
+
labelColorsByName: getOutputMode() === "text" ? getLabelColorsByName() : undefined,
|
|
525
|
+
};
|
|
413
526
|
});
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
if (page.nextCursor !== undefined) {
|
|
527
|
+
output(presentedTasks, (entries) => formatTaskList(entries, { showsStatus: values.all, labelColorsByName }));
|
|
528
|
+
if (nextCursor !== undefined) {
|
|
417
529
|
const selectionTokens = tokens.filter((token) => token.kind !== "option" || token.name !== "all-projects");
|
|
418
530
|
const projectScope = projectKey === undefined ? ["--all-projects"] : [projectKey];
|
|
419
|
-
diagnostic(`More tasks. Continue with: ${formatListContinuation(["task", "list"], projectScope, selectionTokens, "starting-after",
|
|
531
|
+
diagnostic(`More tasks. Continue with: ${formatListContinuation(["task", "list"], projectScope, selectionTokens, "starting-after", nextCursor)}`);
|
|
420
532
|
}
|
|
421
533
|
},
|
|
422
534
|
help: `${generateCommandUsage("task list", taskInputs.list)}
|
|
423
535
|
|
|
424
536
|
List active tasks by default.
|
|
425
537
|
${projectScopeDescription}
|
|
538
|
+
--state open lists tasks outside done and cancelled columns, and --state closed lists tasks in them.
|
|
426
539
|
Use --archived to list archived tasks or --all to list both.
|
|
427
540
|
Repeat --label to require every specified label.
|
|
428
541
|
--column matches an exact column name. Column and label matching ignore case.
|
|
@@ -436,16 +549,19 @@ When additional matches remain after --limit, stderr gives a shell-quoted comman
|
|
|
436
549
|
--starting-after <cursor>: Continue after the position a cursor records. Copy the cursor from that command.
|
|
437
550
|
A cursor works only with the --sort it was made for. Changes to other tasks between commands can still cause repeats or skips.
|
|
438
551
|
|
|
439
|
-
Use 'task view' to see a task's full details, including its description.
|
|
552
|
+
Use 'task view' to see a task's full details, including its description and an expired claim.
|
|
440
553
|
|
|
441
554
|
Example: zinn task list MDR --label cli`,
|
|
442
555
|
},
|
|
443
556
|
search: {
|
|
444
|
-
summary: "Search task titles, descriptions, and comments
|
|
445
|
-
effects: { domain: "read", storage: "normal-open" },
|
|
557
|
+
summary: "Search task titles, descriptions, and comments with excerpts from matching sources.",
|
|
558
|
+
effects: { domain: "read", storage: "normal-open", external: [] },
|
|
446
559
|
confirmation: { kind: "none" },
|
|
447
560
|
input: taskInputs.search,
|
|
448
|
-
results: [
|
|
561
|
+
results: [
|
|
562
|
+
jsonResult("TaskList", { kind: "booleanOption", name: "with-matches", value: false }),
|
|
563
|
+
jsonResult("TaskSearchResults", { kind: "booleanOption", name: "with-matches", value: true }),
|
|
564
|
+
],
|
|
449
565
|
run: (args) => {
|
|
450
566
|
const { values, positionals, tokens } = parseArgs({
|
|
451
567
|
args,
|
|
@@ -460,36 +576,55 @@ Example: zinn task list MDR --label cli`,
|
|
|
460
576
|
if (violatesConstraint(archiveConstraint, getOptionInputs(values))) {
|
|
461
577
|
quit('Use either "--archived" or "--all", not both', undefined, { argument: "--archived" });
|
|
462
578
|
}
|
|
579
|
+
const isText = getOutputMode() === "text";
|
|
580
|
+
if (violatesConstraint(searchMatchesConstraint, {
|
|
581
|
+
...getOptionInputs(values),
|
|
582
|
+
"option:json": !isText,
|
|
583
|
+
})) {
|
|
584
|
+
quit("Add --json to use --with-matches.", undefined, { argument: "--with-matches" });
|
|
585
|
+
}
|
|
463
586
|
const archive = values.all ? "all" : values.archived ? "archived" : "active";
|
|
464
587
|
const isTaskKeyQuery = parseTaskKey(query.trim()) !== null;
|
|
465
|
-
const
|
|
588
|
+
const projectChoice = chooseProjectKey(positionals[1], {
|
|
466
589
|
allProjects: values["all-projects"],
|
|
467
590
|
useDefault: !isTaskKeyQuery,
|
|
468
591
|
});
|
|
469
592
|
const limit = parseListLimit(values.limit);
|
|
470
|
-
const
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
593
|
+
const deadlineFilters = parseDeadlineFilters(values);
|
|
594
|
+
const { presentedTasks, hiddenArchivedCount, labelColorsByName } = readSnapshot(() => {
|
|
595
|
+
if (projectChoice !== undefined) {
|
|
596
|
+
checkDefaultProject(projectChoice);
|
|
597
|
+
}
|
|
598
|
+
const result = task.search({
|
|
599
|
+
...deadlineFilters,
|
|
600
|
+
query,
|
|
601
|
+
projectKey: projectChoice?.key,
|
|
602
|
+
archive,
|
|
603
|
+
limit,
|
|
604
|
+
labelNames: values.label,
|
|
605
|
+
columnName: values.column,
|
|
606
|
+
includeMatches: isText || values["with-matches"] === true,
|
|
607
|
+
});
|
|
608
|
+
return {
|
|
609
|
+
presentedTasks: presentTaskSearchResults(result.tasks, result.matchesByTaskId),
|
|
610
|
+
hiddenArchivedCount: result.hiddenArchivedCount,
|
|
611
|
+
labelColorsByName: isText ? getLabelColorsByName() : undefined,
|
|
612
|
+
};
|
|
478
613
|
});
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
const count = result.hiddenArchivedCount;
|
|
614
|
+
output(presentedTasks, (entries) => formatTaskList(entries, { showsStatus: values.all, labelColorsByName }));
|
|
615
|
+
if (hiddenArchivedCount > 0) {
|
|
616
|
+
const count = hiddenArchivedCount;
|
|
483
617
|
const noun = count === 1 ? "match" : "matches";
|
|
484
618
|
diagnostic(`${count} archived ${noun} hidden, use --all to include them`);
|
|
485
619
|
}
|
|
486
620
|
},
|
|
487
621
|
help: `${generateCommandUsage("task search", taskInputs.search)}
|
|
488
622
|
|
|
489
|
-
Search task titles, descriptions, and comments.
|
|
623
|
+
Search task titles, descriptions, and comments. Comment excerpts include the comment key for 'task comment view'.
|
|
490
624
|
${projectScopeDescription}
|
|
491
625
|
Each word matches the start of a word, ignoring case and accents: e.g. "auth" finds "Authentication".
|
|
492
626
|
Every word must match. Quote a query with several words.
|
|
627
|
+
U+E000 is reserved for separating comments in the search index.
|
|
493
628
|
|
|
494
629
|
A task-key query overrides the configured default project; a typed project key still filters it.
|
|
495
630
|
|
|
@@ -499,11 +634,64 @@ Repeat --label to require every specified label, ignoring case.
|
|
|
499
634
|
--column matches an exact column name. Column and label matching ignore case.
|
|
500
635
|
${deadlineFilterHelp}
|
|
501
636
|
|
|
637
|
+
Use --json --with-matches to include excerpts and highlight ranges. --limit counts tasks.
|
|
638
|
+
|
|
502
639
|
Example: zinn task search 'refinement quota' MDR --limit 5`,
|
|
640
|
+
},
|
|
641
|
+
next: {
|
|
642
|
+
summary: "Show the next task that is ready to work on.",
|
|
643
|
+
effects: { domain: "read", storage: "normal-open", external: [] },
|
|
644
|
+
confirmation: { kind: "none" },
|
|
645
|
+
input: taskInputs.next,
|
|
646
|
+
results: [jsonResult("NextTask")],
|
|
647
|
+
run: (args) => {
|
|
648
|
+
const { values, positionals, tokens } = parseArgs({
|
|
649
|
+
args,
|
|
650
|
+
options: taskInputs.next.options,
|
|
651
|
+
allowPositionals: true,
|
|
652
|
+
strict: true,
|
|
653
|
+
tokens: true,
|
|
654
|
+
});
|
|
655
|
+
validateUniqueOptions(tokens, taskInputs.next.options);
|
|
656
|
+
validatePositionals(positionals, taskInputs.next.forms[0]);
|
|
657
|
+
const projectChoice = chooseProjectKey(positionals[0], {
|
|
658
|
+
allProjects: values["all-projects"],
|
|
659
|
+
});
|
|
660
|
+
const { presentedTask, labelColorsByName } = readSnapshot(() => {
|
|
661
|
+
if (projectChoice !== undefined) {
|
|
662
|
+
checkDefaultProject(projectChoice);
|
|
663
|
+
}
|
|
664
|
+
const nextTask = task.next({ projectKey: projectChoice?.key, columnName: values.column });
|
|
665
|
+
return {
|
|
666
|
+
presentedTask: nextTask === null ? null : presentTask(nextTask),
|
|
667
|
+
labelColorsByName: nextTask !== null && getOutputMode() === "text" ? getLabelColorsByName() : undefined,
|
|
668
|
+
};
|
|
669
|
+
});
|
|
670
|
+
output(presentedTask, (entry) => entry === null ? "No task is ready." : formatTaskList([entry], { labelColorsByName }));
|
|
671
|
+
},
|
|
672
|
+
help: `${generateCommandUsage("task next", taskInputs.next)}
|
|
673
|
+
|
|
674
|
+
Show the next task that is ready to work on.
|
|
675
|
+
A task is ready when it is active, in a todo or backlog column, has no live claim, and every task it depends on is archived or in a done or cancelled column.
|
|
676
|
+
Only dependency relations hold a task back. A task with a live claim is skipped, including your own.
|
|
677
|
+
Ready tasks in todo columns come before those in backlog columns, whatever their priority.
|
|
678
|
+
Within each, tasks are ordered by priority (urgent first, unset last), then the earliest deadline with undated tasks last, then the oldest task.
|
|
679
|
+
${projectScopeDescription}
|
|
680
|
+
--column takes ready tasks from one column instead, matching its exact name and ignoring case. Any column but a done or cancelled one can hold them.
|
|
681
|
+
When no task is ready, the command exits 0. With --json, it prints null.
|
|
682
|
+
To take the task, move it with task move --from, which fails if another caller moved it first. Then show that you are working on it with task claim.
|
|
683
|
+
task next <project> --column <working column> returns in-progress work with no live claim.
|
|
684
|
+
|
|
685
|
+
Use 'task view' to see the task's description, relations and comments.
|
|
686
|
+
|
|
687
|
+
Examples:
|
|
688
|
+
zinn task next MDR
|
|
689
|
+
zinn task next MDR --column Review
|
|
690
|
+
zinn task next MDR --column Doing`,
|
|
503
691
|
},
|
|
504
692
|
view: {
|
|
505
693
|
summary: "Show a task with its description, relations, comments, and creation and update times.",
|
|
506
|
-
effects: { domain: "read", storage: "normal-open" },
|
|
694
|
+
effects: { domain: "read", storage: "normal-open", external: [] },
|
|
507
695
|
confirmation: { kind: "none" },
|
|
508
696
|
input: taskInputs.view,
|
|
509
697
|
results: taskDetailResults,
|
|
@@ -517,21 +705,33 @@ Example: zinn task search 'refinement quota' MDR --limit 5`,
|
|
|
517
705
|
});
|
|
518
706
|
validateUniqueOptions(tokens, taskInputs.view.options);
|
|
519
707
|
validatePositionals(positionals, taskInputs.view.forms[0]);
|
|
520
|
-
const
|
|
521
|
-
|
|
522
|
-
const
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
708
|
+
const taskKey = positionals[0];
|
|
709
|
+
validateTaskKey(taskKey);
|
|
710
|
+
const { viewedTask, history, labelColorsByName } = readSnapshot(() => {
|
|
711
|
+
const taskMatch = task.getByKey(taskKey);
|
|
712
|
+
const board = createColumnBoard();
|
|
713
|
+
const detail = {
|
|
714
|
+
...presentTask(taskMatch, board),
|
|
715
|
+
relations: presentRelations(taskMatch, board),
|
|
716
|
+
comments: presentComments(taskMatch.key),
|
|
717
|
+
};
|
|
718
|
+
const viewedTask = values.history === true
|
|
719
|
+
? {
|
|
720
|
+
...detail,
|
|
721
|
+
activity: task
|
|
722
|
+
.activity(taskMatch.key)
|
|
723
|
+
.sort((left, right) => right.created_at - left.created_at || right.id.localeCompare(left.id)),
|
|
724
|
+
}
|
|
725
|
+
: detail;
|
|
726
|
+
const isText = getOutputMode() === "text";
|
|
727
|
+
return {
|
|
728
|
+
viewedTask,
|
|
729
|
+
history: isText && "activity" in viewedTask
|
|
730
|
+
? presentActivities(viewedTask.activity, { keysFromEventsOnly: true })
|
|
731
|
+
: [],
|
|
732
|
+
labelColorsByName: isText ? getLabelColorsByName() : undefined,
|
|
733
|
+
};
|
|
734
|
+
});
|
|
535
735
|
output(viewedTask, (t) => {
|
|
536
736
|
const MIN_SECTION_SEPARATOR_WIDTH = 60;
|
|
537
737
|
const terminalWidth = process.stdout.columns;
|
|
@@ -543,7 +743,12 @@ Example: zinn task search 'refinement quota' MDR --limit 5`,
|
|
|
543
743
|
const comments = formatCommentList(t.comments);
|
|
544
744
|
const isArchived = t.status === "Archived";
|
|
545
745
|
const sections = [
|
|
546
|
-
formatTaskList([t], {
|
|
746
|
+
formatTaskList([t], {
|
|
747
|
+
showsStatus: isArchived,
|
|
748
|
+
showsFullPriority: true,
|
|
749
|
+
showsClaimDetail: true,
|
|
750
|
+
labelColorsByName,
|
|
751
|
+
}),
|
|
547
752
|
];
|
|
548
753
|
if (t.description != null) {
|
|
549
754
|
sections.push(formatSection("Description", t.description, sectionOptions));
|
|
@@ -554,11 +759,9 @@ Example: zinn task search 'refinement quota' MDR --limit 5`,
|
|
|
554
759
|
if (comments.length > 0) {
|
|
555
760
|
sections.push(formatSection("Comments", comments, sectionOptions));
|
|
556
761
|
}
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
sections.push(formatSection("History", history, sectionOptions));
|
|
561
|
-
}
|
|
762
|
+
const formattedHistory = formatActivityList(history);
|
|
763
|
+
if (formattedHistory.length > 0) {
|
|
764
|
+
sections.push(formatSection("History", formattedHistory, sectionOptions));
|
|
562
765
|
}
|
|
563
766
|
sections.push(formatTaskTimestamps(t));
|
|
564
767
|
return sections.join("\n\n");
|
|
@@ -570,6 +773,7 @@ Show a task with its description, relations, comments, and creation and update t
|
|
|
570
773
|
A section is shown when the task has that content. The description prints in full, keeping its line breaks.
|
|
571
774
|
Task update time advances for edits, label attachment changes, moves, reorders, archiving and unarchiving.
|
|
572
775
|
With --json, created_at and updated_at are stored epoch milliseconds.
|
|
776
|
+
A claim shows with its holder and when its lease ends, also once it expired.
|
|
573
777
|
Use --history to include this task's recorded activity, newest first, including reorders and comment changes.
|
|
574
778
|
Use activity view <activity-id> for full recorded changes. Text times are local with a UTC offset.
|
|
575
779
|
With --history --json, the activity field contains full activity records, or [] when none are recorded.
|
|
@@ -581,7 +785,7 @@ Examples:
|
|
|
581
785
|
},
|
|
582
786
|
blame: {
|
|
583
787
|
summary: "Show the recorded authors of a task's current fields and description lines.",
|
|
584
|
-
effects: { domain: "read", storage: "normal-open" },
|
|
788
|
+
effects: { domain: "read", storage: "normal-open", external: [] },
|
|
585
789
|
confirmation: { kind: "none" },
|
|
586
790
|
input: taskInputs.blame,
|
|
587
791
|
results: [jsonResult("TaskBlame")],
|
|
@@ -593,16 +797,25 @@ Examples:
|
|
|
593
797
|
strict: true,
|
|
594
798
|
});
|
|
595
799
|
validatePositionals(positionals, taskInputs.blame.forms[0]);
|
|
596
|
-
|
|
800
|
+
const { blame, textOptions } = readSnapshot(() => {
|
|
801
|
+
const blame = task.blame(positionals[0]);
|
|
802
|
+
if (getOutputMode() === "json") {
|
|
803
|
+
return { blame };
|
|
804
|
+
}
|
|
597
805
|
const taskMatch = task.getByKey(blame.task.key);
|
|
598
806
|
const board = createColumnBoard();
|
|
599
|
-
return
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
807
|
+
return {
|
|
808
|
+
blame,
|
|
809
|
+
textOptions: {
|
|
810
|
+
relations: presentRelations(taskMatch, board),
|
|
811
|
+
columnCategory: board(taskMatch.project_id).find((boardColumn) => boardColumn.id === taskMatch.column_id)?.category ?? null,
|
|
812
|
+
isArchived: taskMatch.archived_at != null,
|
|
813
|
+
labelColorsByName: blame.fields.labels.value.length === 0 ? new Map() : getLabelColorsByName(),
|
|
814
|
+
activityIdPrefixes: abbreviateActivityIds(activity.getIds()),
|
|
815
|
+
},
|
|
816
|
+
};
|
|
605
817
|
});
|
|
818
|
+
output(blame, (entry) => formatTaskBlame(entry, textOptions));
|
|
606
819
|
},
|
|
607
820
|
help: `${generateCommandUsage("task blame", taskInputs.blame)}
|
|
608
821
|
|
|
@@ -618,7 +831,7 @@ Example: zinn task blame MDR-1`,
|
|
|
618
831
|
},
|
|
619
832
|
edit: {
|
|
620
833
|
summary: "Edit a task's title, description, priority, deadline, or label attachments.",
|
|
621
|
-
effects: { domain: "update", storage: "normal-open" },
|
|
834
|
+
effects: { domain: "update", storage: "normal-open", external: [] },
|
|
622
835
|
confirmation: { kind: "none" },
|
|
623
836
|
input: taskInputs.edit,
|
|
624
837
|
results: [jsonResult("TaskChange")],
|
|
@@ -641,13 +854,16 @@ Example: zinn task blame MDR-1`,
|
|
|
641
854
|
addLabelNames: values["add-label"],
|
|
642
855
|
removeLabelNames: values["remove-label"],
|
|
643
856
|
};
|
|
644
|
-
|
|
857
|
+
const expected = taskExpectations.parseValues(values);
|
|
858
|
+
checkFieldsBeforeText(taskEditSchema, { ...fields, expected });
|
|
859
|
+
checkSingleStdinReader(values, ["--description", ...taskExpectations.textFlags]);
|
|
645
860
|
const description = await resolveTextEdit(values, "--description");
|
|
646
861
|
// Without a text source nothing was read, so this usage error still comes before any input.
|
|
647
862
|
if (violatesConstraint(taskEditConstraint, getOptionInputs(values))) {
|
|
648
863
|
quit("Provide at least one edit flag: --title, --description, --description-file, --priority, --due, --add-label, or --remove-label", undefined, { field: [] });
|
|
649
864
|
}
|
|
650
|
-
const
|
|
865
|
+
const expectedText = await taskExpectations.resolveText(values);
|
|
866
|
+
const editedTask = task.edit({ ...fields, description, expected: { ...expected, ...expectedText } }, currentActor());
|
|
651
867
|
const board = createColumnBoard();
|
|
652
868
|
outputChanges([editedTask], (change) => presentTask(change.task, board), formatTaskList, (entry) => `${entry.key} was unchanged`);
|
|
653
869
|
},
|
|
@@ -662,6 +878,8 @@ ${textFileHelp("--description")}
|
|
|
662
878
|
|
|
663
879
|
${textEditHelp("--description")}
|
|
664
880
|
|
|
881
|
+
${taskExpectations.help}
|
|
882
|
+
|
|
665
883
|
Repeat --add-label or --remove-label for multiple existing labels, ignoring case.
|
|
666
884
|
The same label cannot be both added and removed.
|
|
667
885
|
Archived tasks can be edited.
|
|
@@ -671,7 +889,8 @@ ${dashValueHelp("--description")}
|
|
|
671
889
|
|
|
672
890
|
Examples:
|
|
673
891
|
zinn task edit MDR-1 --title 'Meet the quarterly refinement quota'
|
|
674
|
-
zinn task edit MDR-1 --description 'Bring waffles.' --append
|
|
892
|
+
zinn task edit MDR-1 --description 'Bring waffles.' --append
|
|
893
|
+
zinn task edit MDR-1 --title 'Refine the Cold Harbor file' --expect-title 'Refine the files'`,
|
|
675
894
|
guessedFlags: {
|
|
676
895
|
"--status": (args) => suggestTaskMove(args, taskInputs.edit.options),
|
|
677
896
|
"--column": (args) => suggestTaskMove(args, taskInputs.edit.options),
|
|
@@ -684,21 +903,23 @@ Examples:
|
|
|
684
903
|
},
|
|
685
904
|
move: {
|
|
686
905
|
summary: "Move tasks to another column in their projects.",
|
|
687
|
-
effects: { domain: "update", storage: "normal-open" },
|
|
906
|
+
effects: { domain: "update", storage: "normal-open", external: [] },
|
|
688
907
|
confirmation: { kind: "none" },
|
|
689
908
|
input: taskInputs.move,
|
|
690
909
|
results: taskChangeResults,
|
|
691
910
|
run: (args) => {
|
|
692
|
-
const { positionals } = parseArgs({
|
|
911
|
+
const { values, positionals, tokens } = parseArgs({
|
|
693
912
|
options: taskInputs.move.options,
|
|
694
913
|
args,
|
|
695
914
|
allowPositionals: true,
|
|
696
915
|
strict: true,
|
|
916
|
+
tokens: true,
|
|
697
917
|
});
|
|
918
|
+
validateUniqueOptions(tokens, taskInputs.move.options);
|
|
698
919
|
validatePositionals(positionals, taskInputs.move.forms[0]);
|
|
699
920
|
const taskKeys = positionals.slice(0, -1);
|
|
700
921
|
const targetColumn = positionals.at(-1);
|
|
701
|
-
const moves =
|
|
922
|
+
const moves = moveOrPointToArchive(taskKeys, targetColumn, values.from);
|
|
702
923
|
const board = createColumnBoard();
|
|
703
924
|
outputChanges(moves, (change) => presentTask(change.task, board), formatTaskList, (movedTask) => `${movedTask.key} was already in the ${movedTask.column} column`);
|
|
704
925
|
},
|
|
@@ -710,14 +931,17 @@ Each task's column is looked up in its own project.
|
|
|
710
931
|
|
|
711
932
|
Moving to the current column leaves the task unchanged.
|
|
712
933
|
Archived tasks must be unarchived before they can be moved.
|
|
934
|
+
With --from, the move fails with a conflict error unless every task is still in that column.
|
|
713
935
|
If any task cannot be moved, none change.
|
|
714
936
|
|
|
715
|
-
|
|
937
|
+
Examples:
|
|
938
|
+
zinn task move MDR-1 MDR-2 Doing
|
|
939
|
+
zinn task move MDR-1 Doing --from TODO`,
|
|
716
940
|
guessedFlags: { "--status": suggestTaskMove, "--column": suggestTaskMove },
|
|
717
941
|
},
|
|
718
942
|
order: {
|
|
719
943
|
summary: "Change task positions within their current column.",
|
|
720
|
-
effects: { domain: "update", storage: "normal-open" },
|
|
944
|
+
effects: { domain: "update", storage: "normal-open", external: [] },
|
|
721
945
|
confirmation: { kind: "none" },
|
|
722
946
|
input: taskInputs.order,
|
|
723
947
|
results: taskChangeResults,
|
|
@@ -758,7 +982,7 @@ Example: zinn task order MDR-2 before MDR-1`,
|
|
|
758
982
|
},
|
|
759
983
|
archive: {
|
|
760
984
|
summary: "Archive tasks so they no longer appear in active task lists.",
|
|
761
|
-
effects: { domain: "update", storage: "normal-open" },
|
|
985
|
+
effects: { domain: "update", storage: "normal-open", external: [] },
|
|
762
986
|
confirmation: { kind: "none" },
|
|
763
987
|
input: taskInputs.archive,
|
|
764
988
|
results: taskChangeResults,
|
|
@@ -781,7 +1005,7 @@ Example: zinn task archive MDR-1 MDR-2`,
|
|
|
781
1005
|
},
|
|
782
1006
|
unarchive: {
|
|
783
1007
|
summary: "Unarchive tasks at the bottom of their previous columns, in the order given.",
|
|
784
|
-
effects: { domain: "update", storage: "normal-open" },
|
|
1008
|
+
effects: { domain: "update", storage: "normal-open", external: [] },
|
|
785
1009
|
confirmation: { kind: "none" },
|
|
786
1010
|
input: taskInputs.archive,
|
|
787
1011
|
results: taskChangeResults,
|
|
@@ -801,10 +1025,93 @@ With --json, one task prints an object and several print an array.
|
|
|
801
1025
|
Each task's changed field is 'false' when it was already in the requested state.
|
|
802
1026
|
|
|
803
1027
|
Example: zinn task unarchive MDR-1 MDR-2`,
|
|
1028
|
+
},
|
|
1029
|
+
claim: {
|
|
1030
|
+
summary: "Claim a task for a lease, so other agents and people can see who works on it.",
|
|
1031
|
+
effects: { domain: "update", storage: "normal-open", external: [] },
|
|
1032
|
+
confirmation: { kind: "none" },
|
|
1033
|
+
input: taskInputs.claim,
|
|
1034
|
+
results: [jsonResult("TaskChange")],
|
|
1035
|
+
run: (args) => {
|
|
1036
|
+
const { values, positionals, tokens } = parseArgs({
|
|
1037
|
+
args,
|
|
1038
|
+
options: taskInputs.claim.options,
|
|
1039
|
+
allowPositionals: true,
|
|
1040
|
+
strict: true,
|
|
1041
|
+
tokens: true,
|
|
1042
|
+
});
|
|
1043
|
+
validateUniqueOptions(tokens, taskInputs.claim.options);
|
|
1044
|
+
validatePositionals(positionals, taskInputs.claim.forms[0]);
|
|
1045
|
+
const lease = requireStringOption(taskInputs.claim.options.lease, values.lease, "lease", "A claim needs a lease: use --lease, such as --lease 30m");
|
|
1046
|
+
const leaseMs = parseDurationInput(lease, "--lease");
|
|
1047
|
+
const isLeaseInRange = leaseMs >= MIN_CLAIM_LEASE_MS && leaseMs <= CLAIM_WORK_LIMIT_MS;
|
|
1048
|
+
if (!isLeaseInRange) {
|
|
1049
|
+
quit(`Use a lease from ${formatDurationInput(MIN_CLAIM_LEASE_MS)} through ${formatDurationInput(CLAIM_WORK_LIMIT_MS)}`, undefined, { argument: "--lease" });
|
|
1050
|
+
}
|
|
1051
|
+
const claimed = task.claim({
|
|
1052
|
+
taskKey: positionals[0],
|
|
1053
|
+
leaseMs,
|
|
1054
|
+
force: values.force,
|
|
1055
|
+
}, currentActor());
|
|
1056
|
+
outputClaimChange(claimed, (entry) => `${entry.key} was unchanged`);
|
|
1057
|
+
},
|
|
1058
|
+
help: `${generateCommandUsage("task claim", taskInputs.claim)}
|
|
1059
|
+
|
|
1060
|
+
Claim a task for a lease, so other agents and people can see who works on it.
|
|
1061
|
+
--lease takes whole minutes or hours, such as 30m or 2h, from ${formatDurationInput(MIN_CLAIM_LEASE_MS)} through ${formatDurationInput(CLAIM_WORK_LIMIT_MS)}.
|
|
1062
|
+
Any change the holder makes to the task, including a comment, renews the claim. So does task heartbeat.
|
|
1063
|
+
A claim expires when its lease runs out, or ${formatDurationInput(CLAIM_WORK_LIMIT_MS)} after the holder last changed the task.
|
|
1064
|
+
After that limit, only a change to the task renews it.
|
|
1065
|
+
Claiming a task you hold renews it with the new lease.
|
|
1066
|
+
An expired claim is replaced. A live claim by someone else is a conflict, unless --force takes it over.
|
|
1067
|
+
Agents are told apart by their session or thread, so an agent needs one its host sets, or ZINN_SESSION_ID.
|
|
1068
|
+
Archived tasks cannot be claimed. Archiving a task or moving it to a done or cancelled column releases its claim.
|
|
1069
|
+
|
|
1070
|
+
Examples:
|
|
1071
|
+
zinn task claim MDR-1 --lease 30m
|
|
1072
|
+
zinn task claim MDR-1 --lease 2h --force`,
|
|
1073
|
+
},
|
|
1074
|
+
heartbeat: {
|
|
1075
|
+
summary: "Renew your claim on a task with its current lease.",
|
|
1076
|
+
effects: { domain: "update", storage: "normal-open", external: [] },
|
|
1077
|
+
confirmation: { kind: "none" },
|
|
1078
|
+
input: taskInputs.heartbeat,
|
|
1079
|
+
results: [jsonResult("TaskChange")],
|
|
1080
|
+
run: (args) => {
|
|
1081
|
+
const taskKey = parseClaimedTaskKey(args);
|
|
1082
|
+
outputClaimChange(task.heartbeat(taskKey, currentActor()), (entry) => `${entry.key} was unchanged`);
|
|
1083
|
+
},
|
|
1084
|
+
help: `${generateCommandUsage("task heartbeat", taskInputs.heartbeat)}
|
|
1085
|
+
|
|
1086
|
+
Renew your claim on a task with its current lease.
|
|
1087
|
+
It fails when the task has no claim or someone else holds it.
|
|
1088
|
+
It also fails ${formatDurationInput(CLAIM_WORK_LIMIT_MS)} after you last changed the task. After that, only a change to the task renews the claim.
|
|
1089
|
+
Your own expired claim renews, unless someone claimed the task since.
|
|
1090
|
+
|
|
1091
|
+
Example: zinn task heartbeat MDR-1`,
|
|
1092
|
+
},
|
|
1093
|
+
release: {
|
|
1094
|
+
summary: "Release your claim on a task.",
|
|
1095
|
+
effects: { domain: "update", storage: "normal-open", external: [] },
|
|
1096
|
+
confirmation: { kind: "none" },
|
|
1097
|
+
input: taskInputs.heartbeat,
|
|
1098
|
+
results: [jsonResult("TaskChange")],
|
|
1099
|
+
run: (args) => {
|
|
1100
|
+
const taskKey = parseClaimedTaskKey(args);
|
|
1101
|
+
outputClaimChange(task.release(taskKey, currentActor()), (entry) => `${entry.key} had no claim`);
|
|
1102
|
+
},
|
|
1103
|
+
help: `${generateCommandUsage("task release", taskInputs.heartbeat)}
|
|
1104
|
+
|
|
1105
|
+
Release your claim on a task, even after it expires.
|
|
1106
|
+
Someone else's claim is a conflict, even after it expires. Use task claim to replace an expired claim held by someone else.
|
|
1107
|
+
Releasing a task without a claim does not do anything.
|
|
1108
|
+
With --json, changed is false when the task had no claim.
|
|
1109
|
+
|
|
1110
|
+
Example: zinn task release MDR-1`,
|
|
804
1111
|
},
|
|
805
1112
|
delete: {
|
|
806
1113
|
summary: "Permanently delete tasks after confirmation.",
|
|
807
|
-
effects: { domain: "delete", storage: "normal-open" },
|
|
1114
|
+
effects: { domain: "delete", storage: "normal-open", external: [] },
|
|
808
1115
|
confirmation: { kind: "prompt", description: confirmationDescription },
|
|
809
1116
|
input: taskInputs.delete,
|
|
810
1117
|
results: [
|
|
@@ -824,7 +1131,7 @@ Example: zinn task unarchive MDR-1 MDR-2`,
|
|
|
824
1131
|
const taskKeys = taskDeleteManySchema.parse(positionals);
|
|
825
1132
|
const taskMatches = taskKeys.map((taskKey) => task.getByKey(taskKey));
|
|
826
1133
|
const board = createColumnBoard();
|
|
827
|
-
const presented = taskMatches
|
|
1134
|
+
const presented = presentTasks(taskMatches, board);
|
|
828
1135
|
const canDelete = await confirmAction(`Are you sure you want to delete ${taskMatches.map((match) => match.key).join(", ")}?`, values.yes === true);
|
|
829
1136
|
if (canDelete) {
|
|
830
1137
|
task.deleteMany(taskKeys, currentActor());
|
|
@@ -848,7 +1155,7 @@ Example: zinn task delete MDR-1 MDR-2`,
|
|
|
848
1155
|
label: {
|
|
849
1156
|
add: {
|
|
850
1157
|
summary: "Add existing labels to a task. Label names are matched case-insensitively.",
|
|
851
|
-
effects: { domain: "update", storage: "normal-open" },
|
|
1158
|
+
effects: { domain: "update", storage: "normal-open", external: [] },
|
|
852
1159
|
confirmation: { kind: "none" },
|
|
853
1160
|
input: taskInputs.label_add,
|
|
854
1161
|
results: [jsonResult("TaskChange")],
|
|
@@ -865,7 +1172,7 @@ With --json, changed is false when all the labels were already attached.`,
|
|
|
865
1172
|
},
|
|
866
1173
|
remove: {
|
|
867
1174
|
summary: "Remove existing labels from a task. Label names are matched case-insensitively.",
|
|
868
|
-
effects: { domain: "update", storage: "normal-open" },
|
|
1175
|
+
effects: { domain: "update", storage: "normal-open", external: [] },
|
|
869
1176
|
confirmation: { kind: "none" },
|
|
870
1177
|
input: taskInputs.label_add,
|
|
871
1178
|
results: [jsonResult("TaskChange")],
|
|
@@ -892,6 +1199,21 @@ function parseTaskKeys(args) {
|
|
|
892
1199
|
validatePositionals(positionals, taskInputs.archive.forms[0]);
|
|
893
1200
|
return positionals;
|
|
894
1201
|
}
|
|
1202
|
+
function parseClaimedTaskKey(args) {
|
|
1203
|
+
const { positionals } = parseArgs({
|
|
1204
|
+
options: taskInputs.heartbeat.options,
|
|
1205
|
+
args,
|
|
1206
|
+
allowPositionals: true,
|
|
1207
|
+
strict: true,
|
|
1208
|
+
});
|
|
1209
|
+
validatePositionals(positionals, taskInputs.heartbeat.forms[0]);
|
|
1210
|
+
return positionals[0];
|
|
1211
|
+
}
|
|
1212
|
+
/** Prints a claim command's task with its claim and when the lease ends */
|
|
1213
|
+
function outputClaimChange(change, describeUnchanged) {
|
|
1214
|
+
const board = createColumnBoard();
|
|
1215
|
+
outputChanges([change], (claimChange) => presentTask(claimChange.task, board), (entries) => formatTaskList(entries, { showsClaimDetail: true }), describeUnchanged);
|
|
1216
|
+
}
|
|
895
1217
|
function parseTaskLabelArgs(args) {
|
|
896
1218
|
const { positionals } = parseArgs({
|
|
897
1219
|
options: taskInputs.label_add.options,
|
|
@@ -912,8 +1234,8 @@ function parseNewTaskRelations(flags) {
|
|
|
912
1234
|
];
|
|
913
1235
|
return targetsByType.flatMap(([relation_type, targetTaskKeys]) => targetTaskKeys.map((targetTaskKey) => ({ relation_type, targetTaskKey })));
|
|
914
1236
|
}
|
|
915
|
-
function parseDue(value) {
|
|
916
|
-
return value?.toLowerCase() === "none" ? null : parseTimestampInput(value,
|
|
1237
|
+
function parseDue(value, flag = "--due") {
|
|
1238
|
+
return value?.toLowerCase() === "none" ? null : parseTimestampInput(value, flag);
|
|
917
1239
|
}
|
|
918
1240
|
function parseDeadlineFilters(values) {
|
|
919
1241
|
const dueSince = parseTimestampInput(values["due-since"], "--due-since");
|
|
@@ -924,7 +1246,7 @@ function parseDeadlineFilters(values) {
|
|
|
924
1246
|
}
|
|
925
1247
|
return { dueSince, dueUntil };
|
|
926
1248
|
}
|
|
927
|
-
function parsePriority(value) {
|
|
1249
|
+
function parsePriority(value, flag = "--priority") {
|
|
928
1250
|
const normalizedPriority = value?.toLowerCase();
|
|
929
1251
|
if (normalizedPriority === undefined) {
|
|
930
1252
|
return undefined;
|
|
@@ -935,7 +1257,7 @@ function parsePriority(value) {
|
|
|
935
1257
|
const priority = taskPrioritySchema.safeParse(normalizedPriority);
|
|
936
1258
|
if (!priority.success) {
|
|
937
1259
|
quit("Priority must be low, medium, high, urgent, or none", undefined, {
|
|
938
|
-
argument:
|
|
1260
|
+
argument: flag,
|
|
939
1261
|
});
|
|
940
1262
|
}
|
|
941
1263
|
return priority.data;
|