@wspc/cli 0.0.8 → 0.0.9

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/cli.js CHANGED
@@ -1206,9 +1206,9 @@ var ConfigStore = class {
1206
1206
  };
1207
1207
 
1208
1208
  // src/version.ts
1209
- var VERSION = "0.0.8";
1210
- var SPEC_SHA = "9735a255";
1211
- var SPEC_FETCHED_AT = "2026-06-08T08:32:23.241Z";
1209
+ var VERSION = "0.0.9";
1210
+ var SPEC_SHA = "15a30e63";
1211
+ var SPEC_FETCHED_AT = "2026-06-08T09:36:22.810Z";
1212
1212
  var API_BASE = "https://api.wspc.ai";
1213
1213
 
1214
1214
  // src/index.ts
@@ -1496,6 +1496,42 @@ function relativeTime(value, now = Date.now()) {
1496
1496
  }
1497
1497
  return future ? `in ${amount}${unit}` : `${amount}${unit} ago`;
1498
1498
  }
1499
+ function wrapToWidth(text, width) {
1500
+ const limit = width > 0 ? width : 80;
1501
+ const out = [];
1502
+ for (const line of text.split("\n")) {
1503
+ if (line.length === 0) {
1504
+ out.push("");
1505
+ continue;
1506
+ }
1507
+ let cur = "";
1508
+ for (let word of line.split(" ")) {
1509
+ while (visibleWidth(word) > limit) {
1510
+ let head = "";
1511
+ for (const ch of word) {
1512
+ if (head && visibleWidth(head + ch) > limit) break;
1513
+ head += ch;
1514
+ if (visibleWidth(head) >= limit) break;
1515
+ }
1516
+ if (cur) {
1517
+ out.push(cur);
1518
+ cur = "";
1519
+ }
1520
+ out.push(head);
1521
+ word = word.slice(head.length);
1522
+ }
1523
+ const sep = cur ? " " : "";
1524
+ if (cur && visibleWidth(cur + sep + word) > limit) {
1525
+ out.push(cur);
1526
+ cur = word;
1527
+ } else {
1528
+ cur = cur + sep + word;
1529
+ }
1530
+ }
1531
+ if (cur) out.push(cur);
1532
+ }
1533
+ return out;
1534
+ }
1499
1535
  function table(headers, rows) {
1500
1536
  if (rows.length === 0) {
1501
1537
  return "";
@@ -1557,6 +1593,10 @@ function shouldOutputJson() {
1557
1593
  }
1558
1594
  return false;
1559
1595
  }
1596
+ function termWidth() {
1597
+ const c = process.stdout.columns;
1598
+ return typeof c === "number" && c > 0 ? c : 80;
1599
+ }
1560
1600
  function renderGeneric(data, hints) {
1561
1601
  const shape = hints?.shape ?? detectShape(data);
1562
1602
  if (shape === "list") {
@@ -1638,18 +1678,45 @@ function renderObject(data, hints) {
1638
1678
  const arrayFields = hints?.fields ? [] : Object.keys(obj).filter(
1639
1679
  (k) => Array.isArray(obj[k]) && obj[k].length > 0
1640
1680
  );
1681
+ const formatted = fields.map((f) => [
1682
+ f,
1683
+ formatCell(obj[f], format[f], hints?.enumColorMap?.[f], { noTruncate: true })
1684
+ ]);
1641
1685
  const labelWidth = Math.max(
1642
- ...fields.map((f) => f.length),
1643
- ...arrayFields.map((f) => f.length)
1686
+ ...formatted.map(([f]) => f.length),
1687
+ ...arrayFields.map((f) => f.length),
1688
+ 0
1644
1689
  );
1645
- for (const f of fields) {
1646
- const value = formatCell(obj[f], format[f], hints?.enumColorMap?.[f]);
1690
+ const tw = termWidth();
1691
+ const avail = tw - (2 + labelWidth + 2);
1692
+ const inlineFinal = [];
1693
+ const blocks = [];
1694
+ for (const [f, value] of formatted) {
1695
+ if (value.includes("\n") || visibleWidth(value) > avail) {
1696
+ blocks.push([f, value]);
1697
+ } else {
1698
+ inlineFinal.push([f, value]);
1699
+ }
1700
+ }
1701
+ for (const [f, value] of inlineFinal) {
1647
1702
  process.stdout.write(` ${dim(f.padEnd(labelWidth))} ${value}
1648
1703
  `);
1649
1704
  }
1650
1705
  for (const f of arrayFields) {
1651
- renderArrayField(f, obj[f], labelWidth);
1652
- }
1706
+ const uncapped = f === "children" || f === "comments";
1707
+ const max = uncapped ? Number.POSITIVE_INFINITY : ARRAY_FIELD_MAX_ITEMS;
1708
+ renderArrayField(f, obj[f], labelWidth, max);
1709
+ }
1710
+ const hadAbove = inlineFinal.length > 0 || arrayFields.length > 0;
1711
+ blocks.forEach(([f, value], i) => {
1712
+ if (hadAbove || i > 0) process.stdout.write("\n");
1713
+ process.stdout.write(` ${dim(f)}
1714
+ `);
1715
+ for (const line of wrapToWidth(value, tw - 4)) {
1716
+ process.stdout.write(` ${line}
1717
+ `);
1718
+ }
1719
+ });
1653
1720
  if (hints?.secretField) {
1654
1721
  const value = obj[hints.secretField];
1655
1722
  if (value !== void 0) {
@@ -1663,12 +1730,12 @@ function renderObject(data, hints) {
1663
1730
  }
1664
1731
  }
1665
1732
  var ARRAY_FIELD_MAX_ITEMS = 10;
1666
- function renderArrayField(name, items, labelWidth) {
1733
+ function renderArrayField(name, items, labelWidth, max = ARRAY_FIELD_MAX_ITEMS) {
1667
1734
  const count = items.length;
1668
1735
  const header = `${count} ${count === 1 ? "item" : "items"}`;
1669
1736
  process.stdout.write(` ${dim(name.padEnd(labelWidth))} ${header}
1670
1737
  `);
1671
- const shown = items.slice(0, ARRAY_FIELD_MAX_ITEMS);
1738
+ const shown = items.slice(0, max);
1672
1739
  shown.forEach((item, i) => {
1673
1740
  process.stdout.write(` ${dim(`${i + 1}.`)} ${formatArrayItem(item)}
1674
1741
  `);
@@ -1681,10 +1748,31 @@ function renderArrayField(name, items, labelWidth) {
1681
1748
  function formatArrayItem(item) {
1682
1749
  if (item === null) return dim("null");
1683
1750
  if (typeof item !== "object") return String(item);
1751
+ const todo = formatTodoLike(item);
1752
+ if (todo !== null) return todo;
1753
+ const comment = formatCommentLike(item);
1754
+ if (comment !== null) return comment;
1684
1755
  const attendee = formatAttendeeLike(item);
1685
1756
  if (attendee !== null) return attendee;
1686
1757
  return JSON.stringify(item);
1687
1758
  }
1759
+ function formatTodoLike(item) {
1760
+ if (!item || typeof item !== "object" || Array.isArray(item)) return null;
1761
+ const rec = item;
1762
+ if (typeof rec.id !== "string" || typeof rec.title !== "string") return null;
1763
+ const id = idShort(rec.id);
1764
+ const status = typeof rec.status === "string" ? statusBadge(rec.status) : "";
1765
+ return status ? `${id} ${status} ${rec.title}` : `${id} ${rec.title}`;
1766
+ }
1767
+ function formatCommentLike(item) {
1768
+ if (!item || typeof item !== "object" || Array.isArray(item)) return null;
1769
+ const rec = item;
1770
+ if (typeof rec.id !== "string" || typeof rec.content !== "string") return null;
1771
+ const id = idShort(rec.id);
1772
+ const when = rec.created_at !== void 0 ? `${relativeTime(rec.created_at)} ` : "";
1773
+ const snippet = truncate(rec.content, 60);
1774
+ return `${id} ${when}${snippet}`;
1775
+ }
1688
1776
  function formatAttendeeLike(item) {
1689
1777
  if (!item || typeof item !== "object" || Array.isArray(item)) return null;
1690
1778
  const rec = item;
@@ -1711,7 +1799,7 @@ function renderScalar(data) {
1711
1799
  function isScalar(v) {
1712
1800
  return v === null || typeof v !== "object" && typeof v !== "function";
1713
1801
  }
1714
- function formatCell(value, fmt, colorMap) {
1802
+ function formatCell(value, fmt, colorMap, opts) {
1715
1803
  if (fmt !== "enum-badge" && (value === void 0 || value === null)) return dim("\u2014");
1716
1804
  switch (fmt) {
1717
1805
  case "id-short":
@@ -1721,7 +1809,7 @@ function formatCell(value, fmt, colorMap) {
1721
1809
  case "relative-time":
1722
1810
  return relativeTime(value);
1723
1811
  case "truncate":
1724
- return truncate(String(value), 50);
1812
+ return opts?.noTruncate ? String(value) : truncate(String(value), 50);
1725
1813
  case "bool-badge":
1726
1814
  return boolBadge(value);
1727
1815
  case "enum-badge": {
@@ -2630,7 +2718,7 @@ var todoCommentCreateCommand = new Command34("add").description("Add a comment t
2630
2718
  process.exitCode = 1;
2631
2719
  return;
2632
2720
  }
2633
- render({ kind: "todo_comment_create", display: { "shape": "object", "format": { "id": "id-short", "todo_id": "id-short", "user_id": "id-short", "content": "truncate", "created_at": "relative-time", "updated_at": "relative-time", "deleted_at": "relative-time" } } }, result.data);
2721
+ render({ kind: "todo_comment_create", display: { "shape": "object", "format": { "id": "id-short", "todo_id": "id-short", "user_id": "id-short", "created_at": "relative-time", "updated_at": "relative-time", "deleted_at": "relative-time" } } }, result.data);
2634
2722
  });
2635
2723
 
2636
2724
  // src/generated/cli/todo/comment/ls.ts
@@ -2748,7 +2836,7 @@ var todoCreateCommand = new Command39("add").description("Create a todo").argume
2748
2836
  process.exitCode = 1;
2749
2837
  return;
2750
2838
  }
2751
- render({ kind: "todo_create", display: { "shape": "object", "format": { "id": "id-short", "user_id": "id-short", "project_id": "id-short", "parent_id": "id-short", "type_id": "id-short", "title": "truncate", "description": "truncate", "status": "status-badge", "due_at": "relative-time", "created_at": "relative-time", "updated_at": "relative-time", "deleted_at": "relative-time" } } }, result.data);
2839
+ render({ kind: "todo_create", display: { "shape": "object", "format": { "id": "id-short", "user_id": "id-short", "project_id": "id-short", "parent_id": "id-short", "type_id": "id-short", "status": "status-badge", "due_at": "relative-time", "created_at": "relative-time", "updated_at": "relative-time", "deleted_at": "relative-time" } } }, result.data);
2752
2840
  });
2753
2841
 
2754
2842
  // src/generated/cli/todo/ls.ts
@@ -2824,7 +2912,7 @@ var todoCommentDeleteCommand = new Command42("rm").description("Soft-delete a co
2824
2912
  process.exitCode = 1;
2825
2913
  return;
2826
2914
  }
2827
- render({ kind: "todo_comment_delete", display: { "shape": "object", "format": { "id": "id-short", "todo_id": "id-short", "user_id": "id-short", "content": "truncate", "created_at": "relative-time", "updated_at": "relative-time", "deleted_at": "relative-time" } } }, result.data);
2915
+ render({ kind: "todo_comment_delete", display: { "shape": "object", "format": { "id": "id-short", "todo_id": "id-short", "user_id": "id-short", "created_at": "relative-time", "updated_at": "relative-time", "deleted_at": "relative-time" } } }, result.data);
2828
2916
  });
2829
2917
 
2830
2918
  // src/generated/cli/todo/comment/edit.ts
@@ -2848,7 +2936,7 @@ var todoCommentUpdateCommand = new Command43("edit").description("Edit a comment
2848
2936
  process.exitCode = 1;
2849
2937
  return;
2850
2938
  }
2851
- render({ kind: "todo_comment_update", display: { "shape": "object", "format": { "id": "id-short", "todo_id": "id-short", "user_id": "id-short", "content": "truncate", "created_at": "relative-time", "updated_at": "relative-time", "deleted_at": "relative-time" } } }, result.data);
2939
+ render({ kind: "todo_comment_update", display: { "shape": "object", "format": { "id": "id-short", "todo_id": "id-short", "user_id": "id-short", "created_at": "relative-time", "updated_at": "relative-time", "deleted_at": "relative-time" } } }, result.data);
2852
2940
  });
2853
2941
 
2854
2942
  // src/generated/cli/todo/rm.ts
@@ -2873,7 +2961,7 @@ var todoDeleteCommand = new Command44("rm").description("Soft-delete a todo").ar
2873
2961
  process.exitCode = 1;
2874
2962
  return;
2875
2963
  }
2876
- render({ kind: "todo_delete", display: { "shape": "object", "format": { "id": "id-short", "user_id": "id-short", "project_id": "id-short", "parent_id": "id-short", "type_id": "id-short", "title": "truncate", "description": "truncate", "status": "status-badge", "due_at": "relative-time", "created_at": "relative-time", "updated_at": "relative-time", "deleted_at": "relative-time" } } }, result.data);
2964
+ render({ kind: "todo_delete", display: { "shape": "object", "format": { "id": "id-short", "user_id": "id-short", "project_id": "id-short", "parent_id": "id-short", "type_id": "id-short", "status": "status-badge", "due_at": "relative-time", "created_at": "relative-time", "updated_at": "relative-time", "deleted_at": "relative-time" } } }, result.data);
2877
2965
  });
2878
2966
 
2879
2967
  // src/generated/cli/todo/show.ts
@@ -2887,7 +2975,8 @@ var todoGetCommand = new Command45("show").description("Get a todo by id").argum
2887
2975
  },
2888
2976
  query: {
2889
2977
  include_deleted: opts.includeDeleted,
2890
- include_orphan_fields: opts.includeOrphanFields
2978
+ include_orphan_fields: opts.includeOrphanFields,
2979
+ include: "children,comments"
2891
2980
  }
2892
2981
  });
2893
2982
  if (result.error || !result.response?.ok) {
@@ -2898,7 +2987,7 @@ var todoGetCommand = new Command45("show").description("Get a todo by id").argum
2898
2987
  process.exitCode = 1;
2899
2988
  return;
2900
2989
  }
2901
- render({ kind: "todo_get", display: { "shape": "object", "format": { "id": "id-short", "user_id": "id-short", "project_id": "id-short", "parent_id": "id-short", "type_id": "id-short", "title": "truncate", "description": "truncate", "status": "status-badge", "due_at": "relative-time", "created_at": "relative-time", "updated_at": "relative-time", "deleted_at": "relative-time" } } }, result.data);
2990
+ render({ kind: "todo_get", display: { "shape": "object", "format": { "id": "id-short", "user_id": "id-short", "project_id": "id-short", "parent_id": "id-short", "type_id": "id-short", "status": "status-badge", "due_at": "relative-time", "created_at": "relative-time", "updated_at": "relative-time", "deleted_at": "relative-time" } } }, result.data);
2902
2991
  });
2903
2992
 
2904
2993
  // src/generated/cli/todo/update.ts
@@ -2930,7 +3019,7 @@ var todoUpdateCommand = new Command46("update").description("Update a todo").arg
2930
3019
  process.exitCode = 1;
2931
3020
  return;
2932
3021
  }
2933
- render({ kind: "todo_update", display: { "shape": "object", "format": { "id": "id-short", "user_id": "id-short", "project_id": "id-short", "parent_id": "id-short", "type_id": "id-short", "title": "truncate", "description": "truncate", "status": "status-badge", "due_at": "relative-time", "created_at": "relative-time", "updated_at": "relative-time", "deleted_at": "relative-time" } } }, result.data);
3022
+ render({ kind: "todo_update", display: { "shape": "object", "format": { "id": "id-short", "user_id": "id-short", "project_id": "id-short", "parent_id": "id-short", "type_id": "id-short", "status": "status-badge", "due_at": "relative-time", "created_at": "relative-time", "updated_at": "relative-time", "deleted_at": "relative-time" } } }, result.data);
2934
3023
  });
2935
3024
 
2936
3025
  // src/generated/cli/index.ts