@dypt/cli 0.1.14 → 0.1.16
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 +20 -0
- package/dist/index.js +467 -172
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import { Argument, Command, Option } from "commander";
|
|
|
9
9
|
// package.json
|
|
10
10
|
var package_default = {
|
|
11
11
|
name: "@dypt/cli",
|
|
12
|
-
version: "0.1.
|
|
12
|
+
version: "0.1.16",
|
|
13
13
|
description: "Command-line interface for dypt task management",
|
|
14
14
|
license: "SEE LICENSE IN LICENSE",
|
|
15
15
|
homepage: "https://dypt.app",
|
|
@@ -240,10 +240,7 @@ async function clearCliToken(baseUrl = getBaseUrl(), filePath = getScopedTokenFi
|
|
|
240
240
|
}
|
|
241
241
|
|
|
242
242
|
// src/lib/trpc.ts
|
|
243
|
-
import {
|
|
244
|
-
createTRPCProxyClient,
|
|
245
|
-
httpBatchLink
|
|
246
|
-
} from "@trpc/client";
|
|
243
|
+
import { createTRPCProxyClient, httpBatchLink } from "@trpc/client";
|
|
247
244
|
import superjson from "superjson";
|
|
248
245
|
function resolveBaseUrl(baseUrl) {
|
|
249
246
|
return (baseUrl ?? getBaseUrl()).replace(/\/$/, "");
|
|
@@ -257,10 +254,7 @@ async function resolveAccessToken(baseUrl, getAccessToken) {
|
|
|
257
254
|
}
|
|
258
255
|
async function createCliTrpcClient(options = {}) {
|
|
259
256
|
const baseUrl = resolveBaseUrl(options.baseUrl);
|
|
260
|
-
const accessToken = await resolveAccessToken(
|
|
261
|
-
baseUrl,
|
|
262
|
-
options.getAccessToken
|
|
263
|
-
);
|
|
257
|
+
const accessToken = await resolveAccessToken(baseUrl, options.getAccessToken);
|
|
264
258
|
return createTRPCProxyClient({
|
|
265
259
|
links: [
|
|
266
260
|
httpBatchLink({
|
|
@@ -289,7 +283,11 @@ async function postJson(path4, body, options = {}) {
|
|
|
289
283
|
};
|
|
290
284
|
}
|
|
291
285
|
async function startDeviceAuth(label, options = {}) {
|
|
292
|
-
const response = await postJson(
|
|
286
|
+
const response = await postJson(
|
|
287
|
+
"/api/cli/auth/device-code",
|
|
288
|
+
{ label },
|
|
289
|
+
options
|
|
290
|
+
);
|
|
293
291
|
if (response.status >= 400) {
|
|
294
292
|
throw new Error(response.json.error ?? "CLI_DEVICE_AUTH_START_FAILED");
|
|
295
293
|
}
|
|
@@ -345,7 +343,15 @@ async function createCliApi(options = {}) {
|
|
|
345
343
|
listReminders: (input) => cliClient.cli.v1.reminders.list.query(input),
|
|
346
344
|
addReminders: (input) => cliClient.cli.v1.reminders.add.mutate(input),
|
|
347
345
|
setReminders: (input) => cliClient.cli.v1.reminders.set.mutate(input),
|
|
348
|
-
removeReminder: (input) => cliClient.cli.v1.reminders.remove.mutate(input)
|
|
346
|
+
removeReminder: (input) => cliClient.cli.v1.reminders.remove.mutate(input),
|
|
347
|
+
listTags: (input) => cliClient.cli.v1.tags.list.query(input),
|
|
348
|
+
getTag: (input) => cliClient.cli.v1.tags.get.query(input),
|
|
349
|
+
createTag: (input) => cliClient.cli.v1.tags.create.mutate(input),
|
|
350
|
+
updateTag: (input) => cliClient.cli.v1.tags.update.mutate(input),
|
|
351
|
+
deleteTag: (input) => cliClient.cli.v1.tags.delete.mutate(input),
|
|
352
|
+
mergeTag: (input) => cliClient.cli.v1.tags.merge.mutate(input),
|
|
353
|
+
getTaskTags: (input) => cliClient.cli.v1.tags.forTask.query(input),
|
|
354
|
+
assignTaskTags: (input) => cliClient.cli.v1.tags.assign.mutate(input)
|
|
349
355
|
};
|
|
350
356
|
}
|
|
351
357
|
|
|
@@ -1045,7 +1051,8 @@ async function runTaskCreate(input, deps) {
|
|
|
1045
1051
|
deadline: input.deadline,
|
|
1046
1052
|
expectedTimeTaken: input.expectedTimeTaken,
|
|
1047
1053
|
note: input.note,
|
|
1048
|
-
timeBeforeDeadline: input.timeBeforeDeadline
|
|
1054
|
+
...input.timeBeforeDeadline !== void 0 ? { timeBeforeDeadline: input.timeBeforeDeadline } : {},
|
|
1055
|
+
...input.tagPublicIds?.length ? { tagPublicIds: input.tagPublicIds } : {}
|
|
1049
1056
|
});
|
|
1050
1057
|
if (input.json) {
|
|
1051
1058
|
deps.printJson(result);
|
|
@@ -1129,7 +1136,9 @@ async function runTaskList(input, deps) {
|
|
|
1129
1136
|
actualTimeTo: input.actualTimeTo,
|
|
1130
1137
|
showPath: input.showPath,
|
|
1131
1138
|
limit: input.limit ?? "50",
|
|
1132
|
-
cursor: input.cursor
|
|
1139
|
+
cursor: input.cursor,
|
|
1140
|
+
tag: input.tag,
|
|
1141
|
+
tagMode: input.tagMode
|
|
1133
1142
|
});
|
|
1134
1143
|
if (input.json) {
|
|
1135
1144
|
deps.printJson(result);
|
|
@@ -1484,6 +1493,51 @@ async function runTaskCleanupPreview(input, deps) {
|
|
|
1484
1493
|
deps.printTable(result);
|
|
1485
1494
|
}
|
|
1486
1495
|
|
|
1496
|
+
// src/commands/tag/tag.ts
|
|
1497
|
+
function print(result, json, deps) {
|
|
1498
|
+
if (json) deps.printJson(result);
|
|
1499
|
+
else deps.printTable(result);
|
|
1500
|
+
}
|
|
1501
|
+
async function runTagList(input, deps) {
|
|
1502
|
+
const result = await deps.listTags({
|
|
1503
|
+
query: input.query,
|
|
1504
|
+
includeArchived: input.includeArchived
|
|
1505
|
+
});
|
|
1506
|
+
print(result, input.json, deps);
|
|
1507
|
+
}
|
|
1508
|
+
async function runTagCreate(input, deps) {
|
|
1509
|
+
const result = await deps.createTag({
|
|
1510
|
+
name: input.name,
|
|
1511
|
+
colour: input.colour,
|
|
1512
|
+
description: input.description
|
|
1513
|
+
});
|
|
1514
|
+
print(result, input.json, deps);
|
|
1515
|
+
}
|
|
1516
|
+
async function runTagGet(input, deps) {
|
|
1517
|
+
print(await deps.getTag({ ref: input.ref }), input.json, deps);
|
|
1518
|
+
}
|
|
1519
|
+
async function runTagUpdate(input, deps) {
|
|
1520
|
+
const { json, ...mutation } = input;
|
|
1521
|
+
print(await deps.updateTag(mutation), json, deps);
|
|
1522
|
+
}
|
|
1523
|
+
async function runTagDelete(input, deps) {
|
|
1524
|
+
print(
|
|
1525
|
+
await deps.deleteTag({ tagPublicId: input.tagPublicId }),
|
|
1526
|
+
input.json,
|
|
1527
|
+
deps
|
|
1528
|
+
);
|
|
1529
|
+
}
|
|
1530
|
+
async function runTagMerge(input, deps) {
|
|
1531
|
+
print(
|
|
1532
|
+
await deps.mergeTag({
|
|
1533
|
+
sourceTagPublicId: input.sourceTagPublicId,
|
|
1534
|
+
destinationTagPublicId: input.destinationTagPublicId
|
|
1535
|
+
}),
|
|
1536
|
+
input.json,
|
|
1537
|
+
deps
|
|
1538
|
+
);
|
|
1539
|
+
}
|
|
1540
|
+
|
|
1487
1541
|
// src/lib/banner.ts
|
|
1488
1542
|
var BANNER_LINES = [
|
|
1489
1543
|
" _ _ ",
|
|
@@ -1573,6 +1627,9 @@ function isTaskLike(value) {
|
|
|
1573
1627
|
function isNoteLike(value) {
|
|
1574
1628
|
return isRecord(value) && typeof value.id === "number" && typeof value.taskId === "number" && typeof value.content === "string";
|
|
1575
1629
|
}
|
|
1630
|
+
function isTagLike(value) {
|
|
1631
|
+
return isRecord(value) && typeof value.publicId === "string" && value.publicId.startsWith("tag_") && typeof value.name === "string" && typeof value.colour === "string" && (value.description === void 0 || value.description === null || typeof value.description === "string");
|
|
1632
|
+
}
|
|
1576
1633
|
function isDependencyLike(value) {
|
|
1577
1634
|
return isRecord(value) && typeof value.id === "number" && typeof value.title === "string";
|
|
1578
1635
|
}
|
|
@@ -2187,6 +2244,21 @@ function renderNotes(notes, color) {
|
|
|
2187
2244
|
${renderMarkdownNote(note.content, color)}`;
|
|
2188
2245
|
}).join("\n\n");
|
|
2189
2246
|
}
|
|
2247
|
+
function renderTagDetail(tag, color) {
|
|
2248
|
+
return [
|
|
2249
|
+
`${colorize(tag.publicId, "cyan", color)} ${emphasize(tag.name, "bold", color)}`,
|
|
2250
|
+
`Colour: ${tag.colour}`,
|
|
2251
|
+
`Description: ${tag.description ?? "-"}`,
|
|
2252
|
+
`Status: ${tag.archivedAt ? "archived" : "active"}`,
|
|
2253
|
+
`System identity: ${tag.systemKey ?? "-"}`,
|
|
2254
|
+
...tag.usageCount === void 0 ? [] : [`Usage: ${tag.usageCount} tasks`]
|
|
2255
|
+
].join("\n");
|
|
2256
|
+
}
|
|
2257
|
+
function renderTags(tags, color) {
|
|
2258
|
+
return tags.map(
|
|
2259
|
+
(tag) => `${colorize(tag.publicId, "cyan", color)} ${tag.name} \xB7 ${tag.colour}${tag.archivedAt ? " \xB7 archived" : ""}${tag.description ? " \xB7 description" : ""}`
|
|
2260
|
+
).join("\n");
|
|
2261
|
+
}
|
|
2190
2262
|
function renderDeleteMany(result, color) {
|
|
2191
2263
|
const lines = [
|
|
2192
2264
|
`${colorize("Deleted", "green", color)} ${result.tasksDeleted} task${result.tasksDeleted === 1 ? "" : "s"}.`,
|
|
@@ -2451,6 +2523,9 @@ function formatHumanOutput(value, options = {}) {
|
|
|
2451
2523
|
return renderUpdateMany(value, color);
|
|
2452
2524
|
}
|
|
2453
2525
|
if (Array.isArray(value)) {
|
|
2526
|
+
if (value.every(isTagLike)) {
|
|
2527
|
+
return renderTags(value, color);
|
|
2528
|
+
}
|
|
2454
2529
|
if (value.every(isTaskLike)) {
|
|
2455
2530
|
return renderTaskList({ items: value }, color);
|
|
2456
2531
|
}
|
|
@@ -2467,6 +2542,9 @@ function formatHumanOutput(value, options = {}) {
|
|
|
2467
2542
|
if (isNoteLike(value)) {
|
|
2468
2543
|
return renderNotes([value], color);
|
|
2469
2544
|
}
|
|
2545
|
+
if (isTagLike(value)) {
|
|
2546
|
+
return renderTagDetail(value, color);
|
|
2547
|
+
}
|
|
2470
2548
|
return JSON.stringify(value, null, 2);
|
|
2471
2549
|
}
|
|
2472
2550
|
function printJson(value) {
|
|
@@ -2490,14 +2568,38 @@ async function confirmAction(message, deps = {}) {
|
|
|
2490
2568
|
|
|
2491
2569
|
// src/index.ts
|
|
2492
2570
|
var cliVersion = package_default.version;
|
|
2493
|
-
var taskStatusChoices = [
|
|
2494
|
-
"not started",
|
|
2495
|
-
"in progress",
|
|
2496
|
-
"completed"
|
|
2497
|
-
];
|
|
2571
|
+
var taskStatusChoices = ["not started", "in progress", "completed"];
|
|
2498
2572
|
var taskPriorityChoices = ["low", "mid", "medium", "high"];
|
|
2499
2573
|
var agentTargetChoices = ["codex", "claude"];
|
|
2500
2574
|
var agentSourceChoices = ["github-release", "github-main", "local"];
|
|
2575
|
+
var tagColourChoices = [
|
|
2576
|
+
"gray",
|
|
2577
|
+
"red",
|
|
2578
|
+
"orange",
|
|
2579
|
+
"amber",
|
|
2580
|
+
"green",
|
|
2581
|
+
"teal",
|
|
2582
|
+
"blue",
|
|
2583
|
+
"indigo",
|
|
2584
|
+
"violet",
|
|
2585
|
+
"pink"
|
|
2586
|
+
];
|
|
2587
|
+
var MAX_TAG_DESCRIPTION_LENGTH = 500;
|
|
2588
|
+
function normalizeTagDescriptionOption(value) {
|
|
2589
|
+
if (value === void 0) return void 0;
|
|
2590
|
+
const normalized = value.trim();
|
|
2591
|
+
if (!normalized) {
|
|
2592
|
+
throw new Error(
|
|
2593
|
+
"Description cannot be empty. Omit --description or use --clear-description when updating."
|
|
2594
|
+
);
|
|
2595
|
+
}
|
|
2596
|
+
if (normalized.length > MAX_TAG_DESCRIPTION_LENGTH) {
|
|
2597
|
+
throw new Error(
|
|
2598
|
+
`Description must be ${MAX_TAG_DESCRIPTION_LENGTH} characters or fewer.`
|
|
2599
|
+
);
|
|
2600
|
+
}
|
|
2601
|
+
return normalized;
|
|
2602
|
+
}
|
|
2501
2603
|
function normalizePriority(priority) {
|
|
2502
2604
|
if (!priority) return void 0;
|
|
2503
2605
|
if (priority === "medium") return "mid";
|
|
@@ -2534,7 +2636,9 @@ function parseIntegerOption(value, label, minimum = 0, maximum) {
|
|
|
2534
2636
|
throw new Error(`${label} must be an integer >= ${minimum}`);
|
|
2535
2637
|
}
|
|
2536
2638
|
if (maximum !== void 0 && parsed > maximum) {
|
|
2537
|
-
throw new Error(
|
|
2639
|
+
throw new Error(
|
|
2640
|
+
`${label} must be an integer between ${minimum} and ${maximum}`
|
|
2641
|
+
);
|
|
2538
2642
|
}
|
|
2539
2643
|
return parsed;
|
|
2540
2644
|
}
|
|
@@ -2600,8 +2704,10 @@ function resolveTaskRefFromSearchMatches(ref, matches) {
|
|
|
2600
2704
|
const path4 = task.pathTitles?.join(" > ") ?? [task.parentTitle, task.title].filter(Boolean).join(" > ") ?? task.title;
|
|
2601
2705
|
return `- #${task.id} ${path4}`;
|
|
2602
2706
|
}).join("\n");
|
|
2603
|
-
throw new Error(
|
|
2604
|
-
${
|
|
2707
|
+
throw new Error(
|
|
2708
|
+
`Task reference is ambiguous: ${ref}
|
|
2709
|
+
${formattedMatches}`
|
|
2710
|
+
);
|
|
2605
2711
|
}
|
|
2606
2712
|
}
|
|
2607
2713
|
const normalizedRef = ref.trim().toLocaleLowerCase();
|
|
@@ -2766,6 +2872,158 @@ function buildCli() {
|
|
|
2766
2872
|
);
|
|
2767
2873
|
}
|
|
2768
2874
|
);
|
|
2875
|
+
const tag = addGroupHelpAction(
|
|
2876
|
+
program.command("tag").description("Tag commands")
|
|
2877
|
+
);
|
|
2878
|
+
tag.command("list").option("--query <text>", "filter tags by name").option("--archived", "include archived tags").option("--json", "print JSON output").action(
|
|
2879
|
+
async (options) => runTagList(
|
|
2880
|
+
{
|
|
2881
|
+
query: options.query,
|
|
2882
|
+
includeArchived: Boolean(options.archived),
|
|
2883
|
+
json: Boolean(options.json)
|
|
2884
|
+
},
|
|
2885
|
+
{
|
|
2886
|
+
listTags: (input) => withCliApi((api) => api.listTags(input)),
|
|
2887
|
+
printJson,
|
|
2888
|
+
printTable
|
|
2889
|
+
}
|
|
2890
|
+
)
|
|
2891
|
+
);
|
|
2892
|
+
tag.command("create").argument("<name>").addOption(
|
|
2893
|
+
new Option("--colour <colour>", "tag colour").choices([...tagColourChoices]).default("gray")
|
|
2894
|
+
).option(
|
|
2895
|
+
"--description <text>",
|
|
2896
|
+
`optional plain-text description (max ${MAX_TAG_DESCRIPTION_LENGTH} characters)`
|
|
2897
|
+
).option("--json", "print JSON output").action(
|
|
2898
|
+
async (name, options) => runTagCreate(
|
|
2899
|
+
{
|
|
2900
|
+
name,
|
|
2901
|
+
colour: options.colour,
|
|
2902
|
+
description: normalizeTagDescriptionOption(options.description),
|
|
2903
|
+
json: Boolean(options.json)
|
|
2904
|
+
},
|
|
2905
|
+
{
|
|
2906
|
+
createTag: (input) => withCliApi((api) => api.createTag(input)),
|
|
2907
|
+
printJson,
|
|
2908
|
+
printTable
|
|
2909
|
+
}
|
|
2910
|
+
)
|
|
2911
|
+
);
|
|
2912
|
+
tag.command("get").description("Inspect a complete tag definition").argument("<id-or-name>").option("--json", "print JSON output").action(
|
|
2913
|
+
(ref, options) => runTagGet(
|
|
2914
|
+
{ ref, json: Boolean(options.json) },
|
|
2915
|
+
{
|
|
2916
|
+
getTag: (input) => withCliApi((api) => api.getTag(input)),
|
|
2917
|
+
printJson,
|
|
2918
|
+
printTable
|
|
2919
|
+
}
|
|
2920
|
+
)
|
|
2921
|
+
);
|
|
2922
|
+
tag.command("update").argument("<tag-id>").option("--name <name>", "new tag name").addOption(
|
|
2923
|
+
new Option("--colour <colour>", "new tag colour").choices([
|
|
2924
|
+
...tagColourChoices
|
|
2925
|
+
])
|
|
2926
|
+
).option(
|
|
2927
|
+
"--description <text>",
|
|
2928
|
+
`new plain-text description (max ${MAX_TAG_DESCRIPTION_LENGTH} characters)`
|
|
2929
|
+
).option("--clear-description", "remove the tag description").option("--archive", "archive the tag").option("--restore", "restore the tag").option("--json", "print JSON output").action(
|
|
2930
|
+
async (tagPublicId, options) => {
|
|
2931
|
+
if (options.archive && options.restore)
|
|
2932
|
+
throw new Error("Choose either --archive or --restore.");
|
|
2933
|
+
if (options.description !== void 0 && options.clearDescription)
|
|
2934
|
+
throw new Error(
|
|
2935
|
+
"Choose either --description or --clear-description."
|
|
2936
|
+
);
|
|
2937
|
+
await runTagUpdate(
|
|
2938
|
+
{
|
|
2939
|
+
tagPublicId,
|
|
2940
|
+
name: options.name,
|
|
2941
|
+
colour: options.colour,
|
|
2942
|
+
description: options.clearDescription ? null : normalizeTagDescriptionOption(options.description),
|
|
2943
|
+
archived: options.archive ? true : options.restore ? false : void 0,
|
|
2944
|
+
json: Boolean(options.json)
|
|
2945
|
+
},
|
|
2946
|
+
{
|
|
2947
|
+
updateTag: (input) => withCliApi((api) => api.updateTag(input)),
|
|
2948
|
+
printJson,
|
|
2949
|
+
printTable
|
|
2950
|
+
}
|
|
2951
|
+
);
|
|
2952
|
+
}
|
|
2953
|
+
);
|
|
2954
|
+
tag.command("assign").argument("<task-refs...>").option(
|
|
2955
|
+
"--tag <name>",
|
|
2956
|
+
"existing tag name; repeat to assign multiple",
|
|
2957
|
+
(value, values = []) => [...values, value]
|
|
2958
|
+
).option("--clear", "remove all tags from the task").option("--json", "print JSON output").action(
|
|
2959
|
+
async (taskRefs, options) => {
|
|
2960
|
+
if (!options.clear && !options.tag?.length)
|
|
2961
|
+
throw new Error("Provide at least one --tag or use --clear.");
|
|
2962
|
+
await withCliApi(async (api) => {
|
|
2963
|
+
const taskIds = await Promise.all(
|
|
2964
|
+
taskRefs.map((taskRef) => resolveTaskId(api, taskRef))
|
|
2965
|
+
);
|
|
2966
|
+
const catalogue = await api.listTags({});
|
|
2967
|
+
const requested = (options.tag ?? []).map(
|
|
2968
|
+
(name) => name.trim().replace(/\s+/g, " ").toLowerCase()
|
|
2969
|
+
);
|
|
2970
|
+
const matched = requested.map(
|
|
2971
|
+
(name) => catalogue.find((tag2) => tag2.name === name)
|
|
2972
|
+
);
|
|
2973
|
+
if (matched.some((item) => !item))
|
|
2974
|
+
throw new Error(
|
|
2975
|
+
"Every --tag must name an existing tag. Use `dypt tag create` first."
|
|
2976
|
+
);
|
|
2977
|
+
const tagPublicIds = options.clear ? [] : matched.map((item) => item.publicId);
|
|
2978
|
+
const results = await Promise.all(
|
|
2979
|
+
taskIds.map(
|
|
2980
|
+
(taskId) => api.assignTaskTags({ taskId, tagPublicIds })
|
|
2981
|
+
)
|
|
2982
|
+
);
|
|
2983
|
+
const output = results.length === 1 ? results[0] : results;
|
|
2984
|
+
if (options.json) printJson(output);
|
|
2985
|
+
else printTable(output);
|
|
2986
|
+
});
|
|
2987
|
+
}
|
|
2988
|
+
);
|
|
2989
|
+
tag.command("merge").description("Merge a source tag into an active destination tag").argument("<source-tag-id>").argument("<destination-tag-id>").option("--yes", "confirm assignment transfer and source deletion").option("--json", "print JSON output").action(
|
|
2990
|
+
async (sourceTagPublicId, destinationTagPublicId, options) => {
|
|
2991
|
+
if (!options.yes) {
|
|
2992
|
+
throw new Error(
|
|
2993
|
+
"Merging transfers every assignment and permanently deletes the source tag. Re-run with --yes."
|
|
2994
|
+
);
|
|
2995
|
+
}
|
|
2996
|
+
await runTagMerge(
|
|
2997
|
+
{
|
|
2998
|
+
sourceTagPublicId,
|
|
2999
|
+
destinationTagPublicId,
|
|
3000
|
+
json: Boolean(options.json)
|
|
3001
|
+
},
|
|
3002
|
+
{
|
|
3003
|
+
mergeTag: (input) => withCliApi((api) => api.mergeTag(input)),
|
|
3004
|
+
printJson,
|
|
3005
|
+
printTable
|
|
3006
|
+
}
|
|
3007
|
+
);
|
|
3008
|
+
}
|
|
3009
|
+
);
|
|
3010
|
+
tag.command("delete").argument("<tag-id>").option("--yes", "confirm permanent deletion").option("--json", "print JSON output").action(
|
|
3011
|
+
async (tagPublicId, options) => {
|
|
3012
|
+
if (!options.yes) {
|
|
3013
|
+
throw new Error(
|
|
3014
|
+
"Permanent tag deletion removes every assignment. Re-run with --yes."
|
|
3015
|
+
);
|
|
3016
|
+
}
|
|
3017
|
+
await runTagDelete(
|
|
3018
|
+
{ tagPublicId, json: Boolean(options.json) },
|
|
3019
|
+
{
|
|
3020
|
+
deleteTag: (input) => withCliApi((api) => api.deleteTag(input)),
|
|
3021
|
+
printJson,
|
|
3022
|
+
printTable
|
|
3023
|
+
}
|
|
3024
|
+
);
|
|
3025
|
+
}
|
|
3026
|
+
);
|
|
2769
3027
|
const task = addGroupHelpAction(
|
|
2770
3028
|
program.command("task").description("Task commands")
|
|
2771
3029
|
);
|
|
@@ -2819,7 +3077,13 @@ function buildCli() {
|
|
|
2819
3077
|
"--priority <priority>",
|
|
2820
3078
|
`task priority (${taskPriorityChoices.join("|")})`
|
|
2821
3079
|
).choices([...taskPriorityChoices])
|
|
2822
|
-
).option("--leaves", "only show leaf tasks").option("--blocked <mode>", "show, hide, or only blocked tasks").option("--blocking <mode>", "show, hide, or only blocking tasks").option("--title-contains <text>", "filter titles by substring").option("--deadline-from <iso>", "inclusive deadline start").option("--deadline-to <iso>", "inclusive deadline end").option("--created-from <iso>", "inclusive created-at start").option("--created-to <iso>", "inclusive created-at end").option("--expected-time-from <minutes>", "minimum expected time").option("--expected-time-to <minutes>", "maximum expected time").option("--actual-time-from <minutes>", "minimum actual time").option("--actual-time-to <minutes>", "maximum actual time").option("--parent <ref>", "only include direct children of the given task").option("--scope <ref>", "only include descendants of the given task").option("--show-path", "show task path context in list output").option(
|
|
3080
|
+
).option("--leaves", "only show leaf tasks").option("--blocked <mode>", "show, hide, or only blocked tasks").option("--blocking <mode>", "show, hide, or only blocking tasks").option("--title-contains <text>", "filter titles by substring").option("--deadline-from <iso>", "inclusive deadline start").option("--deadline-to <iso>", "inclusive deadline end").option("--created-from <iso>", "inclusive created-at start").option("--created-to <iso>", "inclusive created-at end").option("--expected-time-from <minutes>", "minimum expected time").option("--expected-time-to <minutes>", "maximum expected time").option("--actual-time-from <minutes>", "minimum actual time").option("--actual-time-to <minutes>", "maximum actual time").option("--parent <ref>", "only include direct children of the given task").option("--scope <ref>", "only include descendants of the given task").option("--show-path", "show task path context in list output").option(
|
|
3081
|
+
"--tag <name>",
|
|
3082
|
+
"filter by tag; repeat for multiple tags",
|
|
3083
|
+
(value, values = []) => [...values, value]
|
|
3084
|
+
).addOption(
|
|
3085
|
+
new Option("--tag-mode <mode>", "match any or all selected tags").choices(["any", "all"]).default("any")
|
|
3086
|
+
).option("--limit <n>", "page size (1-100, default: 50)").option("--cursor <id>", "cursor task id for pagination").option("--json", "print JSON output").addHelpText(
|
|
2823
3087
|
"after",
|
|
2824
3088
|
[
|
|
2825
3089
|
"",
|
|
@@ -2830,82 +3094,88 @@ function buildCli() {
|
|
|
2830
3094
|
" pnpm cli task list --show-path --title-contains dypt",
|
|
2831
3095
|
" pnpm cli task list --cursor 119"
|
|
2832
3096
|
].join("\n")
|
|
2833
|
-
).action(
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
input.
|
|
2879
|
-
"
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
3097
|
+
).action(
|
|
3098
|
+
async (options) => {
|
|
3099
|
+
assertExclusiveHierarchyOptions(options.parent, options.scope);
|
|
3100
|
+
await runTaskList(
|
|
3101
|
+
{
|
|
3102
|
+
archived: options.archived,
|
|
3103
|
+
status: options.status,
|
|
3104
|
+
priority: options.priority,
|
|
3105
|
+
leaves: Boolean(options.leaves),
|
|
3106
|
+
blocked: options.blocked,
|
|
3107
|
+
blocking: options.blocking,
|
|
3108
|
+
titleContains: options.titleContains,
|
|
3109
|
+
deadlineFrom: options.deadlineFrom,
|
|
3110
|
+
deadlineTo: options.deadlineTo,
|
|
3111
|
+
createdFrom: options.createdFrom,
|
|
3112
|
+
createdTo: options.createdTo,
|
|
3113
|
+
expectedTimeFrom: options.expectedTimeFrom,
|
|
3114
|
+
expectedTimeTo: options.expectedTimeTo,
|
|
3115
|
+
actualTimeFrom: options.actualTimeFrom,
|
|
3116
|
+
actualTimeTo: options.actualTimeTo,
|
|
3117
|
+
parent: options.parent,
|
|
3118
|
+
scope: options.scope,
|
|
3119
|
+
showPath: Boolean(options.showPath),
|
|
3120
|
+
limit: options.limit,
|
|
3121
|
+
cursor: options.cursor,
|
|
3122
|
+
tag: options.tag,
|
|
3123
|
+
tagMode: options.tagMode,
|
|
3124
|
+
json: Boolean(options.json)
|
|
3125
|
+
},
|
|
3126
|
+
{
|
|
3127
|
+
listTasks: (input) => withCliApi(async (api) => {
|
|
3128
|
+
const parentTaskId = input.parent ? await resolveTaskId(api, input.parent) : void 0;
|
|
3129
|
+
const scopeTaskId = input.scope ? await resolveTaskId(api, input.scope) : void 0;
|
|
3130
|
+
return api.listTasks({
|
|
3131
|
+
archived: normalizeArchivedMode(input.archived),
|
|
3132
|
+
parentTaskId,
|
|
3133
|
+
scopeTaskId,
|
|
3134
|
+
status: normalizeStatus(input.status),
|
|
3135
|
+
priority: normalizePriority(input.priority),
|
|
3136
|
+
leaves: input.leaves,
|
|
3137
|
+
blocked: normalizeFilterMode(input.blocked),
|
|
3138
|
+
blocking: normalizeFilterMode(input.blocking),
|
|
3139
|
+
titleContains: input.titleContains,
|
|
3140
|
+
deadlineFrom: parseDateOption(input.deadlineFrom, "start"),
|
|
3141
|
+
deadlineTo: parseDateOption(input.deadlineTo, "end"),
|
|
3142
|
+
createdFrom: parseDateOption(input.createdFrom, "start"),
|
|
3143
|
+
createdTo: parseDateOption(input.createdTo, "end"),
|
|
3144
|
+
expectedTimeFrom: parseIntegerOption(
|
|
3145
|
+
input.expectedTimeFrom,
|
|
3146
|
+
"expected-time-from",
|
|
3147
|
+
0
|
|
3148
|
+
),
|
|
3149
|
+
expectedTimeTo: parseIntegerOption(
|
|
3150
|
+
input.expectedTimeTo,
|
|
3151
|
+
"expected-time-to",
|
|
3152
|
+
0
|
|
3153
|
+
),
|
|
3154
|
+
actualTimeFrom: parseIntegerOption(
|
|
3155
|
+
input.actualTimeFrom,
|
|
3156
|
+
"actual-time-from",
|
|
3157
|
+
0
|
|
3158
|
+
),
|
|
3159
|
+
actualTimeTo: parseIntegerOption(
|
|
3160
|
+
input.actualTimeTo,
|
|
3161
|
+
"actual-time-to",
|
|
3162
|
+
0
|
|
3163
|
+
),
|
|
3164
|
+
showPath: input.showPath,
|
|
3165
|
+
tagNames: input.tag,
|
|
3166
|
+
tagMode: input.tagMode === "all" ? "all" : "any",
|
|
3167
|
+
limit: parseIntegerOption(input.limit, "limit", 1, 100),
|
|
3168
|
+
cursor: input.cursor ? {
|
|
3169
|
+
id: parseIntegerOption(input.cursor, "cursor", 1)
|
|
3170
|
+
} : void 0
|
|
3171
|
+
});
|
|
3172
|
+
}),
|
|
3173
|
+
printJson,
|
|
3174
|
+
printTable
|
|
3175
|
+
}
|
|
3176
|
+
);
|
|
3177
|
+
}
|
|
3178
|
+
);
|
|
2909
3179
|
task.command("search").argument("<query>").option("--parent <ref>", "only search direct children of the given task").option("--scope <ref>", "only search descendants of the given task").option("--limit <n>", "page size (1-100, default: 20)").option("--cursor-score <score>", "pagination cursor score").option("--cursor-id <id>", "pagination cursor task id").option("--json", "print JSON output").addHelpText(
|
|
2910
3180
|
"after",
|
|
2911
3181
|
[
|
|
@@ -2917,50 +3187,52 @@ function buildCli() {
|
|
|
2917
3187
|
" pnpm cli task search dypt --limit 8",
|
|
2918
3188
|
" pnpm cli task search dypt --cursor-score 1 --cursor-id 45877 --limit 8"
|
|
2919
3189
|
].join("\n")
|
|
2920
|
-
).action(
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
3190
|
+
).action(
|
|
3191
|
+
async (query, options) => {
|
|
3192
|
+
assertExclusiveHierarchyOptions(options.parent, options.scope);
|
|
3193
|
+
if (options.cursorScore && !options.cursorId || options.cursorId && !options.cursorScore) {
|
|
3194
|
+
throw new Error(
|
|
3195
|
+
"Both --cursor-score and --cursor-id are required together"
|
|
3196
|
+
);
|
|
3197
|
+
}
|
|
3198
|
+
await runTaskSearch(
|
|
3199
|
+
{
|
|
3200
|
+
query,
|
|
3201
|
+
parent: options.parent,
|
|
3202
|
+
scope: options.scope,
|
|
3203
|
+
limit: options.limit,
|
|
3204
|
+
cursorScore: options.cursorScore,
|
|
3205
|
+
cursorId: options.cursorId,
|
|
3206
|
+
json: Boolean(options.json)
|
|
3207
|
+
},
|
|
3208
|
+
{
|
|
3209
|
+
searchTasks: (input) => withCliApi(async (api) => {
|
|
3210
|
+
const parentTaskId = input.parent ? await resolveTaskId(api, input.parent) : void 0;
|
|
3211
|
+
const scopeTaskId = input.scope ? await resolveTaskId(api, input.scope) : void 0;
|
|
3212
|
+
return api.searchTasks({
|
|
3213
|
+
query: input.query,
|
|
3214
|
+
parentTaskId,
|
|
3215
|
+
scopeTaskId,
|
|
3216
|
+
limit: parseIntegerOption(input.limit, "limit", 1, 100),
|
|
3217
|
+
cursor: input.cursorScore || input.cursorId ? {
|
|
3218
|
+
score: parseNumberOption(
|
|
3219
|
+
input.cursorScore,
|
|
3220
|
+
"cursor-score"
|
|
3221
|
+
),
|
|
3222
|
+
id: parseIntegerOption(
|
|
3223
|
+
input.cursorId,
|
|
3224
|
+
"cursor-id",
|
|
3225
|
+
1
|
|
3226
|
+
)
|
|
3227
|
+
} : void 0
|
|
3228
|
+
});
|
|
3229
|
+
}),
|
|
3230
|
+
printJson,
|
|
3231
|
+
printTable
|
|
3232
|
+
}
|
|
2925
3233
|
);
|
|
2926
3234
|
}
|
|
2927
|
-
|
|
2928
|
-
{
|
|
2929
|
-
query,
|
|
2930
|
-
parent: options.parent,
|
|
2931
|
-
scope: options.scope,
|
|
2932
|
-
limit: options.limit,
|
|
2933
|
-
cursorScore: options.cursorScore,
|
|
2934
|
-
cursorId: options.cursorId,
|
|
2935
|
-
json: Boolean(options.json)
|
|
2936
|
-
},
|
|
2937
|
-
{
|
|
2938
|
-
searchTasks: (input) => withCliApi(async (api) => {
|
|
2939
|
-
const parentTaskId = input.parent ? await resolveTaskId(api, input.parent) : void 0;
|
|
2940
|
-
const scopeTaskId = input.scope ? await resolveTaskId(api, input.scope) : void 0;
|
|
2941
|
-
return api.searchTasks({
|
|
2942
|
-
query: input.query,
|
|
2943
|
-
parentTaskId,
|
|
2944
|
-
scopeTaskId,
|
|
2945
|
-
limit: parseIntegerOption(input.limit, "limit", 1, 100),
|
|
2946
|
-
cursor: input.cursorScore || input.cursorId ? {
|
|
2947
|
-
score: parseNumberOption(
|
|
2948
|
-
input.cursorScore,
|
|
2949
|
-
"cursor-score"
|
|
2950
|
-
),
|
|
2951
|
-
id: parseIntegerOption(
|
|
2952
|
-
input.cursorId,
|
|
2953
|
-
"cursor-id",
|
|
2954
|
-
1
|
|
2955
|
-
)
|
|
2956
|
-
} : void 0
|
|
2957
|
-
});
|
|
2958
|
-
}),
|
|
2959
|
-
printJson,
|
|
2960
|
-
printTable
|
|
2961
|
-
}
|
|
2962
|
-
);
|
|
2963
|
-
});
|
|
3235
|
+
);
|
|
2964
3236
|
task.command("tree").description(
|
|
2965
3237
|
"Show a task subtree; omit ref for root tasks (defaults to depth 2)"
|
|
2966
3238
|
).argument("[ref]", "task id or title; omit for root tasks").option("--json", "print JSON output").option("--depth <depth>", "limit subtree depth").option("--full", "show the full subtree without a default depth limit").action(
|
|
@@ -3112,9 +3384,7 @@ function buildCli() {
|
|
|
3112
3384
|
);
|
|
3113
3385
|
});
|
|
3114
3386
|
};
|
|
3115
|
-
addGroupHelpAction(
|
|
3116
|
-
task.command("note").description("Task note commands")
|
|
3117
|
-
);
|
|
3387
|
+
addGroupHelpAction(task.command("note").description("Task note commands"));
|
|
3118
3388
|
const taskNote = task.commands.find((command) => command.name() === "note");
|
|
3119
3389
|
if (taskNote) {
|
|
3120
3390
|
addTaskNoteCommands(taskNote);
|
|
@@ -3125,6 +3395,10 @@ function buildCli() {
|
|
|
3125
3395
|
`task priority (${taskPriorityChoices.join("|")})`
|
|
3126
3396
|
).choices([...taskPriorityChoices])
|
|
3127
3397
|
).option("--deadline <deadline>", "ISO deadline").option("--expected-time <minutes>", "expected minutes").option("--note <markdown>", "initial task note in Markdown").option(
|
|
3398
|
+
"--tag <name>",
|
|
3399
|
+
"existing tag name; repeat to assign multiple",
|
|
3400
|
+
(value, values = []) => [...values, value]
|
|
3401
|
+
).option(
|
|
3128
3402
|
"--reminder <timing>",
|
|
3129
3403
|
`create-time reminder (${reminderTimingTokens.join("|")}); repeat for up to 3 reminders`,
|
|
3130
3404
|
(timing, timings) => [
|
|
@@ -3150,15 +3424,29 @@ function buildCli() {
|
|
|
3150
3424
|
json: Boolean(options.json)
|
|
3151
3425
|
},
|
|
3152
3426
|
{
|
|
3153
|
-
createTask: (input) => withCliApi(
|
|
3154
|
-
|
|
3427
|
+
createTask: (input) => withCliApi(async (api) => {
|
|
3428
|
+
const requested = (options.tag ?? []).map(
|
|
3429
|
+
(name) => name.trim().replace(/\s+/g, " ").toLowerCase()
|
|
3430
|
+
);
|
|
3431
|
+
const catalogue = requested.length ? await api.listTags({}) : [];
|
|
3432
|
+
const matched = requested.map(
|
|
3433
|
+
(name) => catalogue.find((tag2) => tag2.name === name)
|
|
3434
|
+
);
|
|
3435
|
+
if (matched.some((item) => !item))
|
|
3436
|
+
throw new Error(
|
|
3437
|
+
"Every --tag must name an existing tag. Use `dypt tag create` first."
|
|
3438
|
+
);
|
|
3439
|
+
return api.createTask({
|
|
3155
3440
|
...input,
|
|
3441
|
+
...matched.length ? {
|
|
3442
|
+
tagPublicIds: matched.map((item) => item.publicId)
|
|
3443
|
+
} : {},
|
|
3156
3444
|
parentId: await resolveParentId(
|
|
3157
3445
|
options.parent,
|
|
3158
3446
|
(ref) => resolveTaskId(api, ref)
|
|
3159
3447
|
)
|
|
3160
|
-
})
|
|
3161
|
-
),
|
|
3448
|
+
});
|
|
3449
|
+
}),
|
|
3162
3450
|
printJson,
|
|
3163
3451
|
printTable
|
|
3164
3452
|
}
|
|
@@ -3185,30 +3473,32 @@ function buildCli() {
|
|
|
3185
3473
|
}
|
|
3186
3474
|
);
|
|
3187
3475
|
});
|
|
3188
|
-
task.command("delete-many").argument("<refs...>").option("--yes", "skip confirmation").option("--json", "print JSON output").action(
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
confirm: (message) => confirmAction(message, {
|
|
3476
|
+
task.command("delete-many").argument("<refs...>").option("--yes", "skip confirmation").option("--json", "print JSON output").action(
|
|
3477
|
+
async (refs, options) => {
|
|
3478
|
+
await runTaskDeleteMany(
|
|
3479
|
+
{
|
|
3480
|
+
refs,
|
|
3481
|
+
yes: Boolean(options.yes),
|
|
3482
|
+
json: Boolean(options.json)
|
|
3483
|
+
},
|
|
3484
|
+
{
|
|
3198
3485
|
isTty: Boolean(process.stdout.isTTY),
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3486
|
+
confirm: (message) => confirmAction(message, {
|
|
3487
|
+
isTty: Boolean(process.stdout.isTTY),
|
|
3488
|
+
readLine: promptLine
|
|
3489
|
+
}),
|
|
3490
|
+
deleteTasks: (taskRefs) => withCliApi(async (api) => {
|
|
3491
|
+
const taskIds = await Promise.all(
|
|
3492
|
+
taskRefs.map((ref) => resolveTaskId(api, ref))
|
|
3493
|
+
);
|
|
3494
|
+
return api.deleteTasks({ taskIds });
|
|
3495
|
+
}),
|
|
3496
|
+
printJson,
|
|
3497
|
+
printTable
|
|
3498
|
+
}
|
|
3499
|
+
);
|
|
3500
|
+
}
|
|
3501
|
+
);
|
|
3212
3502
|
task.command("update").argument("<ref>").option("--title <title>", "new title").addOption(
|
|
3213
3503
|
new Option(
|
|
3214
3504
|
"--status <status>",
|
|
@@ -3392,7 +3682,10 @@ function buildCli() {
|
|
|
3392
3682
|
);
|
|
3393
3683
|
}
|
|
3394
3684
|
);
|
|
3395
|
-
task.command("reorder").argument("<refs...>").option(
|
|
3685
|
+
task.command("reorder").argument("<refs...>").option(
|
|
3686
|
+
"--parent <ref>",
|
|
3687
|
+
'validate task order under the given parent or "root"'
|
|
3688
|
+
).option("--preview", "preview the reorder without mutating").option("--json", "print JSON output").action(
|
|
3396
3689
|
async (refs, options) => {
|
|
3397
3690
|
await runTaskReorder(
|
|
3398
3691
|
{
|
|
@@ -3441,7 +3734,9 @@ function buildCli() {
|
|
|
3441
3734
|
].join("\n")
|
|
3442
3735
|
)
|
|
3443
3736
|
);
|
|
3444
|
-
cleanup.command("relocate-and-collapse").description(
|
|
3737
|
+
cleanup.command("relocate-and-collapse").description(
|
|
3738
|
+
"Move surviving direct children out of a wrapper and collapse it if emptied"
|
|
3739
|
+
).requiredOption("--wrapper <ref>", "wrapper task to clean up").requiredOption("--tasks <refs...>", "surviving direct child tasks to move").requiredOption("--to <ref>", 'destination parent task or "root"').option("--preview", "preview the workflow without mutating (default)").option("--yes", "apply the workflow immediately").option("--json", "print JSON output").addHelpText(
|
|
3445
3740
|
"after",
|
|
3446
3741
|
[
|
|
3447
3742
|
"",
|