@dypt/cli 0.1.15 → 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 CHANGED
@@ -129,6 +129,26 @@ dypt reminder list 123 --json
129
129
  dypt reminder add 123 1d --json
130
130
  ```
131
131
 
132
+ ### Manage tags
133
+
134
+ Create, inspect, and update reusable tags from the CLI:
135
+
136
+ ```bash
137
+ dypt tag create "deep work" --colour violet --description "Requires uninterrupted focus."
138
+ dypt tag get "deep work"
139
+ dypt tag get tag_abc123 --json
140
+ dypt tag update tag_abc123 --description "Use for focused work without meetings."
141
+ dypt tag update tag_abc123 --clear-description
142
+ ```
143
+
144
+ Descriptions are optional plain text, are trimmed when stored, and can contain
145
+ up to 500 characters. `tag list` keeps one tag per line and indicates when a
146
+ description exists; `tag get` prints the complete description. Add `--json` to
147
+ creation, inspection, or update commands for the complete structured tag.
148
+
149
+ When tags are merged, the destination tag keeps its name, colour, and
150
+ description. The source definition is discarded with the source tag.
151
+
132
152
  ## JSON output
133
153
 
134
154
  Most commands support `--json` for agent and automation use.
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.15",
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",
@@ -345,6 +345,7 @@ async function createCliApi(options = {}) {
345
345
  setReminders: (input) => cliClient.cli.v1.reminders.set.mutate(input),
346
346
  removeReminder: (input) => cliClient.cli.v1.reminders.remove.mutate(input),
347
347
  listTags: (input) => cliClient.cli.v1.tags.list.query(input),
348
+ getTag: (input) => cliClient.cli.v1.tags.get.query(input),
348
349
  createTag: (input) => cliClient.cli.v1.tags.create.mutate(input),
349
350
  updateTag: (input) => cliClient.cli.v1.tags.update.mutate(input),
350
351
  deleteTag: (input) => cliClient.cli.v1.tags.delete.mutate(input),
@@ -1507,10 +1508,14 @@ async function runTagList(input, deps) {
1507
1508
  async function runTagCreate(input, deps) {
1508
1509
  const result = await deps.createTag({
1509
1510
  name: input.name,
1510
- colour: input.colour
1511
+ colour: input.colour,
1512
+ description: input.description
1511
1513
  });
1512
1514
  print(result, input.json, deps);
1513
1515
  }
1516
+ async function runTagGet(input, deps) {
1517
+ print(await deps.getTag({ ref: input.ref }), input.json, deps);
1518
+ }
1514
1519
  async function runTagUpdate(input, deps) {
1515
1520
  const { json, ...mutation } = input;
1516
1521
  print(await deps.updateTag(mutation), json, deps);
@@ -1622,6 +1627,9 @@ function isTaskLike(value) {
1622
1627
  function isNoteLike(value) {
1623
1628
  return isRecord(value) && typeof value.id === "number" && typeof value.taskId === "number" && typeof value.content === "string";
1624
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
+ }
1625
1633
  function isDependencyLike(value) {
1626
1634
  return isRecord(value) && typeof value.id === "number" && typeof value.title === "string";
1627
1635
  }
@@ -2236,6 +2244,21 @@ function renderNotes(notes, color) {
2236
2244
  ${renderMarkdownNote(note.content, color)}`;
2237
2245
  }).join("\n\n");
2238
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
+ }
2239
2262
  function renderDeleteMany(result, color) {
2240
2263
  const lines = [
2241
2264
  `${colorize("Deleted", "green", color)} ${result.tasksDeleted} task${result.tasksDeleted === 1 ? "" : "s"}.`,
@@ -2500,6 +2523,9 @@ function formatHumanOutput(value, options = {}) {
2500
2523
  return renderUpdateMany(value, color);
2501
2524
  }
2502
2525
  if (Array.isArray(value)) {
2526
+ if (value.every(isTagLike)) {
2527
+ return renderTags(value, color);
2528
+ }
2503
2529
  if (value.every(isTaskLike)) {
2504
2530
  return renderTaskList({ items: value }, color);
2505
2531
  }
@@ -2516,6 +2542,9 @@ function formatHumanOutput(value, options = {}) {
2516
2542
  if (isNoteLike(value)) {
2517
2543
  return renderNotes([value], color);
2518
2544
  }
2545
+ if (isTagLike(value)) {
2546
+ return renderTagDetail(value, color);
2547
+ }
2519
2548
  return JSON.stringify(value, null, 2);
2520
2549
  }
2521
2550
  function printJson(value) {
@@ -2555,6 +2584,22 @@ var tagColourChoices = [
2555
2584
  "violet",
2556
2585
  "pink"
2557
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
+ }
2558
2603
  function normalizePriority(priority) {
2559
2604
  if (!priority) return void 0;
2560
2605
  if (priority === "medium") return "mid";
@@ -2846,9 +2891,17 @@ function buildCli() {
2846
2891
  );
2847
2892
  tag.command("create").argument("<name>").addOption(
2848
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)`
2849
2897
  ).option("--json", "print JSON output").action(
2850
2898
  async (name, options) => runTagCreate(
2851
- { name, colour: options.colour, json: Boolean(options.json) },
2899
+ {
2900
+ name,
2901
+ colour: options.colour,
2902
+ description: normalizeTagDescriptionOption(options.description),
2903
+ json: Boolean(options.json)
2904
+ },
2852
2905
  {
2853
2906
  createTag: (input) => withCliApi((api) => api.createTag(input)),
2854
2907
  printJson,
@@ -2856,19 +2909,37 @@ function buildCli() {
2856
2909
  }
2857
2910
  )
2858
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
+ );
2859
2922
  tag.command("update").argument("<tag-id>").option("--name <name>", "new tag name").addOption(
2860
2923
  new Option("--colour <colour>", "new tag colour").choices([
2861
2924
  ...tagColourChoices
2862
2925
  ])
2863
- ).option("--archive", "archive the tag").option("--restore", "restore the tag").option("--json", "print JSON output").action(
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(
2864
2930
  async (tagPublicId, options) => {
2865
2931
  if (options.archive && options.restore)
2866
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
+ );
2867
2937
  await runTagUpdate(
2868
2938
  {
2869
2939
  tagPublicId,
2870
2940
  name: options.name,
2871
2941
  colour: options.colour,
2942
+ description: options.clearDescription ? null : normalizeTagDescriptionOption(options.description),
2872
2943
  archived: options.archive ? true : options.restore ? false : void 0,
2873
2944
  json: Boolean(options.json)
2874
2945
  },