@dypt/cli 0.1.10 → 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 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.10",
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: "^14.0.3",
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();
@@ -896,7 +896,8 @@ async function runTaskCreate(input, deps) {
896
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 hasMutations = input.title !== void 0 || 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 || input.position !== void 0;
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
- status: input.status,
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
- status: args.status,
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 hasMutations = 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;
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
- status: input.status,
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 normalized = /^\d{4}-\d{2}-\d{2}$/.test(value) ? `${value}${boundary === "start" ? "T00:00:00.000Z" : "T23:59:59.999Z"}` : value;
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);
@@ -2902,7 +2909,7 @@ function buildCli() {
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
  {
@@ -2913,6 +2920,7 @@ function buildCli() {
2913
2920
  options.expectedTime,
2914
2921
  "expected-time"
2915
2922
  ),
2923
+ note: options.note,
2916
2924
  json: Boolean(options.json)
2917
2925
  },
2918
2926
  {
@@ -2987,6 +2995,7 @@ function buildCli() {
2987
2995
  ).choices([...taskPriorityChoices])
2988
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(
2989
2997
  async (ref, options) => {
2998
+ assertExclusiveArchiveOptions(options.archive, options.unarchive);
2990
2999
  await runTaskUpdate(
2991
3000
  {
2992
3001
  ref,
@@ -3010,8 +3019,14 @@ function buildCli() {
3010
3019
  status: normalizeStatus(input.status),
3011
3020
  priority: normalizePriority(input.priority),
3012
3021
  deadline: input.deadline ? new Date(String(input.deadline)) : void 0,
3013
- expectedTimeTaken: input.expectedTimeTaken ? Number(input.expectedTimeTaken) : void 0,
3014
- actualTimeTaken: input.actualTimeTaken ? Number(input.actualTimeTaken) : void 0,
3022
+ expectedTimeTaken: parseIntegerOption(
3023
+ input.expectedTimeTaken,
3024
+ "expected-time"
3025
+ ),
3026
+ actualTimeTaken: parseIntegerOption(
3027
+ input.actualTimeTaken,
3028
+ "actual-time"
3029
+ ),
3015
3030
  archivedAt: input.archivedAt,
3016
3031
  parentId: await resolveParentId(
3017
3032
  input.parentRef,
@@ -3026,8 +3041,14 @@ function buildCli() {
3026
3041
  status: normalizeStatus(input.status),
3027
3042
  priority: normalizePriority(input.priority),
3028
3043
  deadline: input.deadline ? new Date(String(input.deadline)) : void 0,
3029
- expectedTimeTaken: input.expectedTimeTaken ? Number(input.expectedTimeTaken) : void 0,
3030
- actualTimeTaken: input.actualTimeTaken ? Number(input.actualTimeTaken) : void 0,
3044
+ expectedTimeTaken: parseIntegerOption(
3045
+ input.expectedTimeTaken,
3046
+ "expected-time"
3047
+ ),
3048
+ actualTimeTaken: parseIntegerOption(
3049
+ input.actualTimeTaken,
3050
+ "actual-time"
3051
+ ),
3031
3052
  archivedAt: input.archivedAt,
3032
3053
  parentId: await resolveParentId(
3033
3054
  input.parentRef,
@@ -3076,6 +3097,7 @@ function buildCli() {
3076
3097
  ).choices([...taskPriorityChoices])
3077
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(
3078
3099
  async (refs, options) => {
3100
+ assertExclusiveArchiveOptions(options.archive, options.unarchive);
3079
3101
  await runTaskUpdateMany(
3080
3102
  {
3081
3103
  refs,
@@ -3099,8 +3121,14 @@ function buildCli() {
3099
3121
  status: normalizeStatus(input.status),
3100
3122
  priority: normalizePriority(input.priority),
3101
3123
  deadline: input.deadline ? new Date(String(input.deadline)) : void 0,
3102
- expectedTimeTaken: input.expectedTimeTaken ? Number(input.expectedTimeTaken) : void 0,
3103
- actualTimeTaken: input.actualTimeTaken ? Number(input.actualTimeTaken) : void 0,
3124
+ expectedTimeTaken: parseIntegerOption(
3125
+ input.expectedTimeTaken,
3126
+ "expected-time"
3127
+ ),
3128
+ actualTimeTaken: parseIntegerOption(
3129
+ input.actualTimeTaken,
3130
+ "actual-time"
3131
+ ),
3104
3132
  archivedAt: input.archivedAt,
3105
3133
  parentId: await resolveParentId(
3106
3134
  input.parentRef,
@@ -3117,8 +3145,14 @@ function buildCli() {
3117
3145
  status: normalizeStatus(input.status),
3118
3146
  priority: normalizePriority(input.priority),
3119
3147
  deadline: input.deadline ? new Date(String(input.deadline)) : void 0,
3120
- expectedTimeTaken: input.expectedTimeTaken ? Number(input.expectedTimeTaken) : void 0,
3121
- actualTimeTaken: input.actualTimeTaken ? Number(input.actualTimeTaken) : void 0,
3148
+ expectedTimeTaken: parseIntegerOption(
3149
+ input.expectedTimeTaken,
3150
+ "expected-time"
3151
+ ),
3152
+ actualTimeTaken: parseIntegerOption(
3153
+ input.actualTimeTaken,
3154
+ "actual-time"
3155
+ ),
3122
3156
  archivedAt: input.archivedAt,
3123
3157
  parentId: await resolveParentId(
3124
3158
  input.parentRef,