@dypt/cli 0.1.9 → 0.1.11
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 +5 -0
- package/dist/index.js +83 -42
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -41,8 +41,13 @@ Create a new task:
|
|
|
41
41
|
```bash
|
|
42
42
|
dypt task create "Follow up with customers"
|
|
43
43
|
dypt task create "Write release notes" --parent Work
|
|
44
|
+
dypt task create "Prepare launch" --note "## Context\n\nCoordinate the release."
|
|
44
45
|
```
|
|
45
46
|
|
|
47
|
+
Use `--note <markdown>` to create the task and its initial note atomically. If
|
|
48
|
+
the note cannot be stored, the task is not created. The command returns the
|
|
49
|
+
same task output in text and `--json` modes whether or not `--note` is used.
|
|
50
|
+
|
|
46
51
|
### Inspect a task
|
|
47
52
|
|
|
48
53
|
View a task and its details:
|
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.11",
|
|
13
13
|
description: "Command-line interface for dypt task management",
|
|
14
14
|
license: "SEE LICENSE IN LICENSE",
|
|
15
15
|
homepage: "https://dypt.app",
|
|
@@ -43,7 +43,7 @@ var package_default = {
|
|
|
43
43
|
},
|
|
44
44
|
dependencies: {
|
|
45
45
|
"@trpc/client": "^11.17.0",
|
|
46
|
-
commander: "^
|
|
46
|
+
commander: "^15.0.0",
|
|
47
47
|
"string-width": "^8.2.1",
|
|
48
48
|
superjson: "^2.2.6"
|
|
49
49
|
},
|
|
@@ -67,7 +67,7 @@ function getScopedTokenFilePath(baseUrl) {
|
|
|
67
67
|
return path.join(getConfigDir(), "tokens", `${scope}.json`);
|
|
68
68
|
}
|
|
69
69
|
function getBaseUrl() {
|
|
70
|
-
return (process.env.DYPT_BASE_URL ?? process.env.NEXT_PUBLIC_URL ?? "https://dypt.app").replace(
|
|
70
|
+
return (process.env.DYPT_BASE_URL ?? process.env.NEXT_PUBLIC_URL ?? "https://dypt.app").replace(/\/+$/, "");
|
|
71
71
|
}
|
|
72
72
|
function getDefaultDeviceLabel() {
|
|
73
73
|
const hostname = os.hostname().trim();
|
|
@@ -893,10 +893,11 @@ async function runNoteSet(input, deps) {
|
|
|
893
893
|
async function runTaskCreate(input, deps) {
|
|
894
894
|
const result = await deps.createTask({
|
|
895
895
|
title: input.title,
|
|
896
|
-
parentId: input.parentId
|
|
896
|
+
parentId: input.parentId ?? null,
|
|
897
897
|
priority: input.priority,
|
|
898
898
|
deadline: input.deadline,
|
|
899
|
-
expectedTimeTaken: input.expectedTimeTaken
|
|
899
|
+
expectedTimeTaken: input.expectedTimeTaken,
|
|
900
|
+
note: input.note
|
|
900
901
|
});
|
|
901
902
|
if (input.json) {
|
|
902
903
|
deps.printJson(result);
|
|
@@ -1099,9 +1100,26 @@ async function runTaskTree(input, deps) {
|
|
|
1099
1100
|
deps.printTable(result);
|
|
1100
1101
|
}
|
|
1101
1102
|
|
|
1103
|
+
// src/commands/task/updateFields.ts
|
|
1104
|
+
function hasSharedTaskMutationFields(input) {
|
|
1105
|
+
return input.status !== void 0 || input.priority !== void 0 || input.deadline !== void 0 || input.expectedTimeTaken !== void 0 || input.actualTimeTaken !== void 0 || input.archivedAt !== void 0 || input.parentRef !== void 0;
|
|
1106
|
+
}
|
|
1107
|
+
function pickSharedTaskMutationFields(input) {
|
|
1108
|
+
return {
|
|
1109
|
+
status: input.status,
|
|
1110
|
+
priority: input.priority,
|
|
1111
|
+
deadline: input.deadline,
|
|
1112
|
+
expectedTimeTaken: input.expectedTimeTaken,
|
|
1113
|
+
actualTimeTaken: input.actualTimeTaken,
|
|
1114
|
+
archivedAt: input.archivedAt,
|
|
1115
|
+
parentRef: input.parentRef
|
|
1116
|
+
};
|
|
1117
|
+
}
|
|
1118
|
+
|
|
1102
1119
|
// src/commands/task/update.ts
|
|
1103
1120
|
async function runTaskUpdate(input, deps) {
|
|
1104
|
-
const
|
|
1121
|
+
const sharedArgs = pickSharedTaskMutationFields(input);
|
|
1122
|
+
const hasMutations = input.title !== void 0 || hasSharedTaskMutationFields(sharedArgs) || input.position !== void 0;
|
|
1105
1123
|
if (!hasMutations) {
|
|
1106
1124
|
throw new Error(
|
|
1107
1125
|
"No changes specified. Use --title, --status, --priority, --deadline, --expected-time, --actual-time, --archive, --unarchive, --parent, or --position."
|
|
@@ -1113,24 +1131,12 @@ async function runTaskUpdate(input, deps) {
|
|
|
1113
1131
|
const args = {
|
|
1114
1132
|
ref: input.ref,
|
|
1115
1133
|
title: input.title,
|
|
1116
|
-
|
|
1117
|
-
priority: input.priority,
|
|
1118
|
-
deadline: input.deadline,
|
|
1119
|
-
expectedTimeTaken: input.expectedTimeTaken,
|
|
1120
|
-
actualTimeTaken: input.actualTimeTaken,
|
|
1121
|
-
archivedAt: input.archivedAt,
|
|
1122
|
-
parentRef: input.parentRef,
|
|
1134
|
+
...sharedArgs,
|
|
1123
1135
|
position: input.position
|
|
1124
1136
|
};
|
|
1125
1137
|
const result = input.preview ? await deps.previewTask({
|
|
1126
1138
|
ref: args.ref,
|
|
1127
|
-
|
|
1128
|
-
priority: args.priority,
|
|
1129
|
-
deadline: args.deadline,
|
|
1130
|
-
expectedTimeTaken: args.expectedTimeTaken,
|
|
1131
|
-
actualTimeTaken: args.actualTimeTaken,
|
|
1132
|
-
archivedAt: args.archivedAt,
|
|
1133
|
-
parentRef: args.parentRef,
|
|
1139
|
+
...sharedArgs,
|
|
1134
1140
|
position: args.position
|
|
1135
1141
|
}) : await deps.updateTask(args);
|
|
1136
1142
|
if (input.json) {
|
|
@@ -1142,7 +1148,8 @@ async function runTaskUpdate(input, deps) {
|
|
|
1142
1148
|
|
|
1143
1149
|
// src/commands/task/updateMany.ts
|
|
1144
1150
|
async function runTaskUpdateMany(input, deps) {
|
|
1145
|
-
const
|
|
1151
|
+
const sharedArgs = pickSharedTaskMutationFields(input);
|
|
1152
|
+
const hasMutations = hasSharedTaskMutationFields(sharedArgs);
|
|
1146
1153
|
if (!hasMutations) {
|
|
1147
1154
|
throw new Error(
|
|
1148
1155
|
"No changes specified. Use --status, --priority, --deadline, --expected-time, --actual-time, --archive, --unarchive, or --parent."
|
|
@@ -1150,13 +1157,7 @@ async function runTaskUpdateMany(input, deps) {
|
|
|
1150
1157
|
}
|
|
1151
1158
|
const args = {
|
|
1152
1159
|
refs: input.refs,
|
|
1153
|
-
|
|
1154
|
-
priority: input.priority,
|
|
1155
|
-
deadline: input.deadline,
|
|
1156
|
-
expectedTimeTaken: input.expectedTimeTaken,
|
|
1157
|
-
actualTimeTaken: input.actualTimeTaken,
|
|
1158
|
-
archivedAt: input.archivedAt,
|
|
1159
|
-
parentRef: input.parentRef
|
|
1160
|
+
...sharedArgs
|
|
1160
1161
|
};
|
|
1161
1162
|
const result = input.preview ? await deps.previewManyTasks(args) : await deps.updateManyTasks(args);
|
|
1162
1163
|
if (input.json) {
|
|
@@ -2372,9 +2373,10 @@ function parseNumberOption(value, label) {
|
|
|
2372
2373
|
}
|
|
2373
2374
|
function parseDateOption(value, boundary) {
|
|
2374
2375
|
if (!value) return void 0;
|
|
2375
|
-
const
|
|
2376
|
+
const isDateOnly = /^\d{4}-\d{2}-\d{2}$/.test(value);
|
|
2377
|
+
const normalized = isDateOnly ? `${value}${boundary === "start" ? "T00:00:00.000Z" : "T23:59:59.999Z"}` : value;
|
|
2376
2378
|
const parsed = new Date(normalized);
|
|
2377
|
-
if (Number.isNaN(parsed.getTime())) {
|
|
2379
|
+
if (Number.isNaN(parsed.getTime()) || isDateOnly && parsed.toISOString().slice(0, 10) !== value) {
|
|
2378
2380
|
throw new Error(`Invalid date: ${value}`);
|
|
2379
2381
|
}
|
|
2380
2382
|
return parsed;
|
|
@@ -2433,6 +2435,11 @@ function assertExclusiveHierarchyOptions(parent, scope) {
|
|
|
2433
2435
|
throw new Error("Use either --parent or --scope, not both");
|
|
2434
2436
|
}
|
|
2435
2437
|
}
|
|
2438
|
+
function assertExclusiveArchiveOptions(archive, unarchive) {
|
|
2439
|
+
if (archive && unarchive) {
|
|
2440
|
+
throw new Error("Use either --archive or --unarchive, not both");
|
|
2441
|
+
}
|
|
2442
|
+
}
|
|
2436
2443
|
async function withCliApi(callback) {
|
|
2437
2444
|
const api = await createCliApi();
|
|
2438
2445
|
return callback(api);
|
|
@@ -2897,27 +2904,35 @@ function buildCli() {
|
|
|
2897
2904
|
if (taskNote) {
|
|
2898
2905
|
addTaskNoteCommands(taskNote);
|
|
2899
2906
|
}
|
|
2900
|
-
task.command("create").argument("<title>").option("--parent <
|
|
2907
|
+
task.command("create").argument("<title>").option("--parent <ref>", 'parent task id, title, or "root"').addOption(
|
|
2901
2908
|
new Option(
|
|
2902
2909
|
"--priority <priority>",
|
|
2903
2910
|
`task priority (${taskPriorityChoices.join("|")})`
|
|
2904
2911
|
).choices([...taskPriorityChoices])
|
|
2905
|
-
).option("--deadline <deadline>", "ISO deadline").option("--expected-time <minutes>", "expected minutes").option("--json", "print JSON output").action(
|
|
2912
|
+
).option("--deadline <deadline>", "ISO deadline").option("--expected-time <minutes>", "expected minutes").option("--note <markdown>", "initial task note in Markdown").option("--json", "print JSON output").action(
|
|
2906
2913
|
async (title, options) => {
|
|
2907
2914
|
await runTaskCreate(
|
|
2908
2915
|
{
|
|
2909
2916
|
title,
|
|
2910
|
-
parentId: options.parent,
|
|
2911
2917
|
priority: normalizePriority(options.priority),
|
|
2912
2918
|
deadline: options.deadline ? parseDateOption(options.deadline, "start") : void 0,
|
|
2913
2919
|
expectedTimeTaken: parseIntegerOption(
|
|
2914
2920
|
options.expectedTime,
|
|
2915
2921
|
"expected-time"
|
|
2916
2922
|
),
|
|
2923
|
+
note: options.note,
|
|
2917
2924
|
json: Boolean(options.json)
|
|
2918
2925
|
},
|
|
2919
2926
|
{
|
|
2920
|
-
createTask: (input) => withCliApi(
|
|
2927
|
+
createTask: (input) => withCliApi(
|
|
2928
|
+
async (api) => api.createTask({
|
|
2929
|
+
...input,
|
|
2930
|
+
parentId: await resolveParentId(
|
|
2931
|
+
options.parent,
|
|
2932
|
+
(ref) => resolveTaskId(api, ref)
|
|
2933
|
+
)
|
|
2934
|
+
})
|
|
2935
|
+
),
|
|
2921
2936
|
printJson,
|
|
2922
2937
|
printTable
|
|
2923
2938
|
}
|
|
@@ -2980,6 +2995,7 @@ function buildCli() {
|
|
|
2980
2995
|
).choices([...taskPriorityChoices])
|
|
2981
2996
|
).option("--deadline <deadline>", "ISO deadline").option("--expected-time <minutes>", "expected minutes").option("--actual-time <minutes>", "actual minutes").option("--archive", "archive the task").option("--unarchive", "unarchive the task").option("--parent <ref>", 'move task under the given parent or "root"').option("--position <position>", "0-based sibling position").option("--preview", "preview the update without mutating").option("--json", "print JSON output").action(
|
|
2982
2997
|
async (ref, options) => {
|
|
2998
|
+
assertExclusiveArchiveOptions(options.archive, options.unarchive);
|
|
2983
2999
|
await runTaskUpdate(
|
|
2984
3000
|
{
|
|
2985
3001
|
ref,
|
|
@@ -3003,8 +3019,14 @@ function buildCli() {
|
|
|
3003
3019
|
status: normalizeStatus(input.status),
|
|
3004
3020
|
priority: normalizePriority(input.priority),
|
|
3005
3021
|
deadline: input.deadline ? new Date(String(input.deadline)) : void 0,
|
|
3006
|
-
expectedTimeTaken:
|
|
3007
|
-
|
|
3022
|
+
expectedTimeTaken: parseIntegerOption(
|
|
3023
|
+
input.expectedTimeTaken,
|
|
3024
|
+
"expected-time"
|
|
3025
|
+
),
|
|
3026
|
+
actualTimeTaken: parseIntegerOption(
|
|
3027
|
+
input.actualTimeTaken,
|
|
3028
|
+
"actual-time"
|
|
3029
|
+
),
|
|
3008
3030
|
archivedAt: input.archivedAt,
|
|
3009
3031
|
parentId: await resolveParentId(
|
|
3010
3032
|
input.parentRef,
|
|
@@ -3019,8 +3041,14 @@ function buildCli() {
|
|
|
3019
3041
|
status: normalizeStatus(input.status),
|
|
3020
3042
|
priority: normalizePriority(input.priority),
|
|
3021
3043
|
deadline: input.deadline ? new Date(String(input.deadline)) : void 0,
|
|
3022
|
-
expectedTimeTaken:
|
|
3023
|
-
|
|
3044
|
+
expectedTimeTaken: parseIntegerOption(
|
|
3045
|
+
input.expectedTimeTaken,
|
|
3046
|
+
"expected-time"
|
|
3047
|
+
),
|
|
3048
|
+
actualTimeTaken: parseIntegerOption(
|
|
3049
|
+
input.actualTimeTaken,
|
|
3050
|
+
"actual-time"
|
|
3051
|
+
),
|
|
3024
3052
|
archivedAt: input.archivedAt,
|
|
3025
3053
|
parentId: await resolveParentId(
|
|
3026
3054
|
input.parentRef,
|
|
@@ -3069,6 +3097,7 @@ function buildCli() {
|
|
|
3069
3097
|
).choices([...taskPriorityChoices])
|
|
3070
3098
|
).option("--deadline <deadline>", "ISO deadline").option("--expected-time <minutes>", "expected minutes").option("--actual-time <minutes>", "actual minutes").option("--archive", "archive the tasks").option("--unarchive", "unarchive the tasks").option("--parent <ref>", 'move tasks under the given parent or "root"').option("--preview", "preview the bulk update without mutating").option("--json", "print JSON output").action(
|
|
3071
3099
|
async (refs, options) => {
|
|
3100
|
+
assertExclusiveArchiveOptions(options.archive, options.unarchive);
|
|
3072
3101
|
await runTaskUpdateMany(
|
|
3073
3102
|
{
|
|
3074
3103
|
refs,
|
|
@@ -3092,8 +3121,14 @@ function buildCli() {
|
|
|
3092
3121
|
status: normalizeStatus(input.status),
|
|
3093
3122
|
priority: normalizePriority(input.priority),
|
|
3094
3123
|
deadline: input.deadline ? new Date(String(input.deadline)) : void 0,
|
|
3095
|
-
expectedTimeTaken:
|
|
3096
|
-
|
|
3124
|
+
expectedTimeTaken: parseIntegerOption(
|
|
3125
|
+
input.expectedTimeTaken,
|
|
3126
|
+
"expected-time"
|
|
3127
|
+
),
|
|
3128
|
+
actualTimeTaken: parseIntegerOption(
|
|
3129
|
+
input.actualTimeTaken,
|
|
3130
|
+
"actual-time"
|
|
3131
|
+
),
|
|
3097
3132
|
archivedAt: input.archivedAt,
|
|
3098
3133
|
parentId: await resolveParentId(
|
|
3099
3134
|
input.parentRef,
|
|
@@ -3110,8 +3145,14 @@ function buildCli() {
|
|
|
3110
3145
|
status: normalizeStatus(input.status),
|
|
3111
3146
|
priority: normalizePriority(input.priority),
|
|
3112
3147
|
deadline: input.deadline ? new Date(String(input.deadline)) : void 0,
|
|
3113
|
-
expectedTimeTaken:
|
|
3114
|
-
|
|
3148
|
+
expectedTimeTaken: parseIntegerOption(
|
|
3149
|
+
input.expectedTimeTaken,
|
|
3150
|
+
"expected-time"
|
|
3151
|
+
),
|
|
3152
|
+
actualTimeTaken: parseIntegerOption(
|
|
3153
|
+
input.actualTimeTaken,
|
|
3154
|
+
"actual-time"
|
|
3155
|
+
),
|
|
3115
3156
|
archivedAt: input.archivedAt,
|
|
3116
3157
|
parentId: await resolveParentId(
|
|
3117
3158
|
input.parentRef,
|