@dypt/cli 0.1.0 → 0.1.2

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/dist/index.js CHANGED
@@ -6,6 +6,52 @@ import { fileURLToPath, pathToFileURL } from "url";
6
6
  import { createInterface } from "readline/promises";
7
7
  import { Command, Option } from "commander";
8
8
 
9
+ // package.json
10
+ var package_default = {
11
+ name: "@dypt/cli",
12
+ version: "0.1.2",
13
+ description: "Command-line interface for dypt task management",
14
+ license: "SEE LICENSE IN LICENSE",
15
+ homepage: "https://dypt.app",
16
+ bugs: {
17
+ url: "https://dypt.app/help"
18
+ },
19
+ keywords: [
20
+ "dypt",
21
+ "cli",
22
+ "tasks",
23
+ "task-management"
24
+ ],
25
+ type: "module",
26
+ bin: {
27
+ dypt: "dist/index.js"
28
+ },
29
+ publishConfig: {
30
+ access: "public"
31
+ },
32
+ files: [
33
+ "dist"
34
+ ],
35
+ engines: {
36
+ node: "^22.20.0 || ^24.14.0"
37
+ },
38
+ scripts: {
39
+ build: "tsup",
40
+ prepack: "pnpm build",
41
+ test: "vitest run --config vitest.config.ts",
42
+ typecheck: "tsc --noEmit"
43
+ },
44
+ dependencies: {
45
+ "@trpc/client": "^11.11.0",
46
+ commander: "^13.1.0",
47
+ "string-width": "^7.2.0",
48
+ superjson: "^2.2.6"
49
+ },
50
+ devDependencies: {
51
+ tsup: "^8.5.1"
52
+ }
53
+ };
54
+
9
55
  // src/commands/auth/login.ts
10
56
  import { spawn } from "child_process";
11
57
 
@@ -346,8 +392,28 @@ async function runStatus(input, deps) {
346
392
  }
347
393
 
348
394
  // src/commands/dep/add.ts
395
+ function formatDependencyAddError(error) {
396
+ const message = error instanceof Error ? error.message : String(error);
397
+ switch (message) {
398
+ case "CLI_DEPENDENCY_ANCESTOR_CONFLICT":
399
+ return "Cannot add a dependency between a task and its parent or child task.";
400
+ case "CLI_DEPENDENCY_SELF_REFERENCE":
401
+ return "A task cannot depend on itself.";
402
+ case "CLI_DEPENDENCY_CYCLE":
403
+ return "Cannot add that dependency because it would create a cycle.";
404
+ case "CLI_DEPENDENCY_ARCHIVED_TASK":
405
+ return "Cannot add a dependency involving an archived task.";
406
+ default:
407
+ return message;
408
+ }
409
+ }
349
410
  async function runDependencyAdd(input, deps) {
350
- const result = await deps.addDependency(input.taskRef, input.blockedByRef);
411
+ let result;
412
+ try {
413
+ result = await deps.addDependency(input.taskRef, input.blockedByRef);
414
+ } catch (error) {
415
+ throw new Error(formatDependencyAddError(error));
416
+ }
351
417
  if (input.json) {
352
418
  deps.printJson(result);
353
419
  return;
@@ -409,7 +475,10 @@ async function runNoteSet(input, deps) {
409
475
  async function runTaskCreate(input, deps) {
410
476
  const result = await deps.createTask({
411
477
  title: input.title,
412
- parentId: input.parentId ? Number(input.parentId) : null
478
+ parentId: input.parentId ? Number(input.parentId) : null,
479
+ priority: input.priority,
480
+ deadline: input.deadline,
481
+ expectedTimeTaken: input.expectedTimeTaken
413
482
  });
414
483
  if (input.json) {
415
484
  deps.printJson(result);
@@ -1397,12 +1466,18 @@ function renderTaskSummary(value, color) {
1397
1466
  }
1398
1467
  function renderPlanningMetadataGaps(value, color) {
1399
1468
  const lines = [
1400
- `${colorize(`#${value.task.id}`, "cyan", color)} ${value.task.title} planning metadata gaps`
1469
+ `${colorize(`#${value.task.id}`, "cyan", color)} ${emphasize(
1470
+ `${value.task.title} planning metadata gaps`,
1471
+ "bold",
1472
+ color
1473
+ )}`
1401
1474
  ];
1402
1475
  if (value.items.length === 0) {
1476
+ lines.push("");
1403
1477
  lines.push(dim("No planning metadata gaps found.", color));
1404
1478
  return lines.join("\n");
1405
1479
  }
1480
+ lines.push("");
1406
1481
  lines.push(
1407
1482
  ...value.items.map(
1408
1483
  (item) => `${colorize(`#${item.id}`, "cyan", color)} ${item.title}
@@ -1413,12 +1488,18 @@ function renderPlanningMetadataGaps(value, color) {
1413
1488
  }
1414
1489
  function renderNextActions(value, color) {
1415
1490
  const lines = [
1416
- `${colorize(`#${value.task.id}`, "cyan", color)} ${value.task.title} likely next actions`
1491
+ `${colorize(`#${value.task.id}`, "cyan", color)} ${emphasize(
1492
+ `${value.task.title} likely next actions`,
1493
+ "bold",
1494
+ color
1495
+ )}`
1417
1496
  ];
1418
1497
  if (value.items.length === 0) {
1498
+ lines.push("");
1419
1499
  lines.push(dim("No next-action candidates found.", color));
1420
1500
  return lines.join("\n");
1421
1501
  }
1502
+ lines.push("");
1422
1503
  lines.push(
1423
1504
  ...value.items.map(
1424
1505
  (item) => `${colorize(`#${item.id}`, "cyan", color)} ${item.title}
@@ -1429,12 +1510,18 @@ function renderNextActions(value, color) {
1429
1510
  }
1430
1511
  function renderBranchFocusSignals(value, color) {
1431
1512
  const lines = [
1432
- `${colorize(`#${value.task.id}`, "cyan", color)} ${value.task.title} branch focus signals`
1513
+ `${colorize(`#${value.task.id}`, "cyan", color)} ${emphasize(
1514
+ `${value.task.title} branch focus signals`,
1515
+ "bold",
1516
+ color
1517
+ )}`
1433
1518
  ];
1434
1519
  if (value.items.length === 0) {
1520
+ lines.push("");
1435
1521
  lines.push(dim("No focus branches found.", color));
1436
1522
  return lines.join("\n");
1437
1523
  }
1524
+ lines.push("");
1438
1525
  lines.push(
1439
1526
  ...value.items.map(
1440
1527
  (item) => `${colorize(`#${item.id}`, "cyan", color)} ${item.title}
@@ -1702,6 +1789,7 @@ async function confirmAction(message, deps = {}) {
1702
1789
  }
1703
1790
 
1704
1791
  // src/index.ts
1792
+ var cliVersion = package_default.version;
1705
1793
  var taskStatusChoices = [
1706
1794
  "not started",
1707
1795
  "in progress",
@@ -1827,7 +1915,7 @@ async function promptLine(prompt) {
1827
1915
  }
1828
1916
  function buildCli() {
1829
1917
  const program = new Command();
1830
- program.name("dypt");
1918
+ program.name("dypt").version(cliVersion, "-V, --version");
1831
1919
  const addGroupHelpAction = (command) => {
1832
1920
  command.action(() => {
1833
1921
  command.outputHelp();
@@ -2213,12 +2301,23 @@ function buildCli() {
2213
2301
  if (taskNote) {
2214
2302
  addTaskNoteCommands(taskNote);
2215
2303
  }
2216
- task.command("create").argument("<title>").option("--parent <taskId>", "parent task id").option("--json", "print JSON output").action(
2304
+ task.command("create").argument("<title>").option("--parent <taskId>", "parent task id").addOption(
2305
+ new Option(
2306
+ "--priority <priority>",
2307
+ `task priority (${taskPriorityChoices.join("|")})`
2308
+ ).choices([...taskPriorityChoices])
2309
+ ).option("--deadline <deadline>", "ISO deadline").option("--expected-time <minutes>", "expected minutes").option("--json", "print JSON output").action(
2217
2310
  async (title, options) => {
2218
2311
  await runTaskCreate(
2219
2312
  {
2220
2313
  title,
2221
2314
  parentId: options.parent,
2315
+ priority: normalizePriority(options.priority),
2316
+ deadline: options.deadline ? parseDateOption(options.deadline, "start") : void 0,
2317
+ expectedTimeTaken: parseIntegerOption(
2318
+ options.expectedTime,
2319
+ "expected-time"
2320
+ ),
2222
2321
  json: Boolean(options.json)
2223
2322
  },
2224
2323
  {
@@ -2401,15 +2500,21 @@ function buildCli() {
2401
2500
  }
2402
2501
  );
2403
2502
  const cleanup = addGroupHelpAction(
2404
- task.command("cleanup").description("Cleanup plan commands")
2503
+ task.command("cleanup").description(
2504
+ [
2505
+ "Cleanup plan commands",
2506
+ "",
2507
+ "Use named cleanup workflows for task refs. Use preview/apply only with explicit cleanup plan JSON."
2508
+ ].join("\n")
2509
+ )
2405
2510
  );
2406
2511
  cleanup.command("relocate-and-collapse").description("Move surviving direct children out of a wrapper and collapse it if emptied").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(
2407
2512
  "after",
2408
2513
  [
2409
2514
  "",
2410
2515
  "Examples:",
2411
- ' pnpm cli task cleanup relocate-and-collapse --wrapper "Old wrapper" --tasks 42 43 --to "Canonical branch"',
2412
- " pnpm cli task cleanup relocate-and-collapse --wrapper 100 --tasks 101 --to root --yes --json"
2516
+ ' dypt task cleanup relocate-and-collapse --wrapper "Old wrapper" --tasks 42 43 --to "Canonical branch"',
2517
+ " dypt task cleanup relocate-and-collapse --wrapper 100 --tasks 101 --to root --yes --json"
2413
2518
  ].join("\n")
2414
2519
  ).action(
2415
2520
  async (options) => {
@@ -2440,13 +2545,13 @@ function buildCli() {
2440
2545
  );
2441
2546
  }
2442
2547
  );
2443
- cleanup.command("preview").option("--plan <json>", "inline cleanup plan JSON").option("--plan-file <path>", "path to a cleanup plan JSON file").option("--json", "print JSON output").addHelpText(
2548
+ cleanup.command("preview").description("Preview an explicit cleanup plan JSON").option("--plan <json>", "inline cleanup plan JSON").option("--plan-file <path>", "path to a cleanup plan JSON file").option("--json", "print JSON output").addHelpText(
2444
2549
  "after",
2445
2550
  [
2446
2551
  "",
2447
2552
  "Examples:",
2448
- ` pnpm cli task cleanup preview --plan '{"operations":[{"type":"archive","taskIds":[42]}]}'`,
2449
- " pnpm cli task cleanup preview --plan-file /tmp/cleanup-plan.json --json"
2553
+ ` dypt task cleanup preview --plan '{"operations":[{"type":"archive","taskIds":[42]}]}'`,
2554
+ " dypt task cleanup preview --plan-file /tmp/cleanup-plan.json --json"
2450
2555
  ].join("\n")
2451
2556
  ).action(
2452
2557
  async (options) => {
@@ -2464,13 +2569,13 @@ function buildCli() {
2464
2569
  );
2465
2570
  }
2466
2571
  );
2467
- cleanup.command("apply").option("--plan <json>", "inline cleanup plan JSON").option("--plan-file <path>", "path to a cleanup plan JSON file").option("--yes", "skip confirmation").option("--json", "print JSON output").addHelpText(
2572
+ cleanup.command("apply").description("Apply an explicit cleanup plan JSON").option("--plan <json>", "inline cleanup plan JSON").option("--plan-file <path>", "path to a cleanup plan JSON file").option("--yes", "skip confirmation").option("--json", "print JSON output").addHelpText(
2468
2573
  "after",
2469
2574
  [
2470
2575
  "",
2471
2576
  "Examples:",
2472
- ` pnpm cli task cleanup apply --plan '{"operations":[{"type":"archive","taskIds":[42]}]}' --yes`,
2473
- " pnpm cli task cleanup apply --plan-file /tmp/cleanup-plan.json --json --yes"
2577
+ ` dypt task cleanup apply --plan '{"operations":[{"type":"archive","taskIds":[42]}]}' --yes`,
2578
+ " dypt task cleanup apply --plan-file /tmp/cleanup-plan.json --json --yes"
2474
2579
  ].join("\n")
2475
2580
  ).action(
2476
2581
  async (options) => {
@@ -2560,6 +2665,10 @@ function buildCli() {
2560
2665
  program.command("note").description("Note commands")
2561
2666
  );
2562
2667
  addTaskNoteCommands(note);
2668
+ program.command("version").description("Print the installed CLI version").action(() => {
2669
+ process.stdout.write(`${cliVersion}
2670
+ `);
2671
+ });
2563
2672
  return program;
2564
2673
  }
2565
2674
  function isTopLevelHelpRequest(argv) {
@@ -2573,6 +2682,10 @@ function isTopLevelHelpRequest(argv) {
2573
2682
  }
2574
2683
  return false;
2575
2684
  }
2685
+ function isTopLevelVersionRequest(argv) {
2686
+ const args = argv.slice(2);
2687
+ return args.length === 1 && (args[0] === "--version" || args[0] === "-V");
2688
+ }
2576
2689
  async function runCli(argv) {
2577
2690
  const cli = buildCli();
2578
2691
  if (isTopLevelHelpRequest(argv)) {
@@ -2580,6 +2693,11 @@ async function runCli(argv) {
2580
2693
  cli.outputHelp();
2581
2694
  return 0;
2582
2695
  }
2696
+ if (isTopLevelVersionRequest(argv)) {
2697
+ process.stdout.write(`${cliVersion}
2698
+ `);
2699
+ return 0;
2700
+ }
2583
2701
  await cli.parseAsync(argv);
2584
2702
  return 0;
2585
2703
  }