@thecorporation/cli 26.3.46 → 26.3.48

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
@@ -9,174 +9,6 @@ var __export = (target, all) => {
9
9
  __defProp(target, name, { get: all[name], enumerable: true });
10
10
  };
11
11
 
12
- // src/animation.ts
13
- function renderFrame(frame) {
14
- const cols = [];
15
- for (let i = 0; i < BUILDINGS.length; i++) {
16
- const building = BUILDINGS[i];
17
- const h = building.length;
18
- const visible = Math.max(0, Math.min(h, frame - i));
19
- const width = building[0]?.length ?? 6;
20
- const blank = " ".repeat(width);
21
- const col = Array(MAX_HEIGHT - visible).fill(blank);
22
- col.push(...building.slice(h - visible));
23
- cols.push(col);
24
- }
25
- const lines = [];
26
- for (let row = 0; row < MAX_HEIGHT; row++) {
27
- lines.push(cols.map((col) => col[row]).join(""));
28
- }
29
- return lines.join("\n");
30
- }
31
- async function withAnimation(fn) {
32
- if (!process.stdout.isTTY) {
33
- return fn();
34
- }
35
- let frame = 0;
36
- let animDone = false;
37
- const spinChars = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
38
- let spinIdx = 0;
39
- let lastLineCount = 0;
40
- const clearPrev = () => {
41
- if (lastLineCount > 0) {
42
- process.stdout.write(`\x1B[${lastLineCount}A\x1B[0J`);
43
- }
44
- };
45
- const drawFrame = () => {
46
- clearPrev();
47
- if (!animDone) {
48
- const art = renderFrame(frame);
49
- const output = `${GOLD}${art}${RESET}
50
- `;
51
- process.stdout.write(output);
52
- lastLineCount = MAX_HEIGHT + 1;
53
- frame++;
54
- if (frame >= TOTAL_FRAMES) {
55
- animDone = true;
56
- }
57
- } else {
58
- const line = `${GOLD}${spinChars[spinIdx % spinChars.length]} Loading...${RESET}
59
- `;
60
- process.stdout.write(line);
61
- lastLineCount = 1;
62
- spinIdx++;
63
- }
64
- };
65
- drawFrame();
66
- const timer = setInterval(drawFrame, 100);
67
- try {
68
- const result = await fn();
69
- return result;
70
- } finally {
71
- clearInterval(timer);
72
- clearPrev();
73
- }
74
- }
75
- var BUILDINGS, MAX_HEIGHT, TOTAL_FRAMES, GOLD, RESET;
76
- var init_animation = __esm({
77
- "src/animation.ts"() {
78
- "use strict";
79
- BUILDINGS = [
80
- [
81
- " \u250C\u2510 ",
82
- " \u2502\u2502 ",
83
- " \u2502\u2502 ",
84
- " \u250C\u2524\u251C\u2510 ",
85
- " \u2502\u2502\u2502\u2502\u2502",
86
- " \u2502\u2502\u2502\u2502\u2502"
87
- ],
88
- [
89
- " \u2554\u2550\u2550\u2557 ",
90
- " \u2551\u25AA\u25AA\u2551 ",
91
- " \u2551\u25AA\u25AA\u2551 ",
92
- " \u2551\u25AA\u25AA\u2551 ",
93
- " \u2551\u25AA\u25AA\u2551 ",
94
- " \u2551\u25AA\u25AA\u2551 ",
95
- " \u2551\u25AA\u25AA\u2551 ",
96
- " \u2551\u25AA\u25AA\u2551 "
97
- ],
98
- [
99
- " /\\ ",
100
- " / \\ ",
101
- " \u2502\u25AA\u25AA\u2502 ",
102
- " \u2502\u25AA\u25AA\u2502 ",
103
- " \u2502\u25AA\u25AA\u2502 "
104
- ],
105
- [
106
- " \u250C\u2500\u2500\u2510 ",
107
- " \u2502\u224B\u224B\u2502 ",
108
- " \u2502\u25AA\u25AA\u2502 ",
109
- " \u2502\u25AA\u25AA\u2502 ",
110
- " \u2502\u25AA\u25AA\u2502 ",
111
- " \u2502\u25AA\u25AA\u2502 ",
112
- " \u2502\u25AA\u25AA\u2502 ",
113
- " \u2502\u25AA\u25AA\u2502 ",
114
- " \u2502\u25AA\u25AA\u2502 "
115
- ],
116
- [
117
- " \u257B ",
118
- " \u2503 ",
119
- " \u250C\u2524\u2510 ",
120
- " \u2502\u25AA\u2502 ",
121
- " \u2502\u25AA\u2502 ",
122
- " \u2502\u25AA\u2502 ",
123
- " \u2502\u25AA\u2502 ",
124
- " \u2502\u25AA\u2502 ",
125
- " \u2502\u25AA\u2502 ",
126
- " \u2502\u25AA\u2502 ",
127
- " \u2502\u25AA\u2502 "
128
- ],
129
- [
130
- " \u250C\u2510 ",
131
- " \u251C\u2524 ",
132
- " \u2502\u25AA\u2502 ",
133
- " \u2502\u25AA\u2502 ",
134
- " \u2502\u25AA\u2502 ",
135
- " \u2502\u25AA\u2502 "
136
- ],
137
- [
138
- " \u2554\u2550\u2550\u2550\u2557",
139
- " \u2551\u25AA \u25AA\u2551",
140
- " \u2551\u25AA \u25AA\u2551",
141
- " \u2551\u25AA \u25AA\u2551",
142
- " \u2551\u25AA \u25AA\u2551",
143
- " \u2551\u25AA \u25AA\u2551",
144
- " \u2551\u25AA \u25AA\u2551",
145
- " \u2551\u25AA \u25AA\u2551",
146
- " \u2551\u25AA \u25AA\u2551",
147
- " \u2551\u25AA \u25AA\u2551"
148
- ],
149
- [
150
- " \u252C\u2500\u252C ",
151
- " \u2502~\u2502 ",
152
- " \u2502\u25AA\u2502 ",
153
- " \u2502\u25AA\u2502 ",
154
- " \u2502\u25AA\u2502 ",
155
- " \u2502\u25AA\u2502 ",
156
- " \u2502\u25AA\u2502 "
157
- ]
158
- ];
159
- MAX_HEIGHT = Math.max(...BUILDINGS.map((b) => b.length));
160
- TOTAL_FRAMES = MAX_HEIGHT + 4;
161
- GOLD = "\x1B[38;2;212;160;23m";
162
- RESET = "\x1B[0m";
163
- }
164
- });
165
-
166
- // src/spinner.ts
167
- async function withSpinner(_label, fn, json) {
168
- if (json) {
169
- return fn();
170
- }
171
- return withAnimation(fn);
172
- }
173
- var init_spinner = __esm({
174
- "src/spinner.ts"() {
175
- "use strict";
176
- init_animation();
177
- }
178
- });
179
-
180
12
  // src/config.ts
181
13
  import {
182
14
  chmodSync,
@@ -717,7 +549,7 @@ var init_config = __esm({
717
549
 
718
550
  // src/references.ts
719
551
  import {
720
- shortId as shortId2,
552
+ shortId,
721
553
  slugify,
722
554
  describeReferenceRecord,
723
555
  getReferenceId,
@@ -727,7 +559,7 @@ import {
727
559
  } from "@thecorporation/corp-tools";
728
560
  import {
729
561
  ReferenceTracker,
730
- shortId as shortId3,
562
+ shortId as shortId2,
731
563
  normalize,
732
564
  validateReferenceInput,
733
565
  describeReferenceRecord as describeReferenceRecord2,
@@ -1010,7 +842,7 @@ var init_references = __esm({
1010
842
  );
1011
843
  }
1012
844
  ambiguousMessage(kind, ref, matches) {
1013
- const previews = matches.slice(0, 5).map((match) => `${match.label} [${shortId3(match.id)}]`).join(", ");
845
+ const previews = matches.slice(0, 5).map((match) => `${match.label} [${shortId2(match.id)}]`).join(", ");
1014
846
  return `Ambiguous ${kindLabel(kind)} reference "${ref}". Matches: ${previews}. Try: corp find ${kind} ${JSON.stringify(ref)}`;
1015
847
  }
1016
848
  async listRecords(kind, scope) {
@@ -1391,13 +1223,13 @@ function formatReferenceCell(kind, record) {
1391
1223
  const id = getReferenceId(kind, record);
1392
1224
  if (!id) return "";
1393
1225
  const alias = getReferenceAlias(kind, record);
1394
- return alias ? `${alias} [${shortId2(id)}]` : shortId2(id);
1226
+ return alias ? `${alias} [${shortId(id)}]` : shortId(id);
1395
1227
  }
1396
1228
  function printReferenceSummary(kind, record, opts = {}) {
1397
1229
  const id = getReferenceId(kind, record);
1398
1230
  if (!id) return;
1399
1231
  const alias = getReferenceAlias(kind, record);
1400
- const token = alias ? `${alias} [${shortId2(id)}]` : shortId2(id);
1232
+ const token = alias ? `${alias} [${shortId(id)}]` : shortId(id);
1401
1233
  console.log(` ${chalk.bold(opts.label ?? "Ref:")} ${token}`);
1402
1234
  console.log(` ${chalk.bold("ID:")} ${id}`);
1403
1235
  if (opts.showReuseHint) {
@@ -1485,17 +1317,17 @@ function printFinanceSummaryPanel(data) {
1485
1317
  console.log(chalk.green("\u2500".repeat(54)));
1486
1318
  console.log(chalk.green.bold(" Finance Summary"));
1487
1319
  console.log(chalk.green("\u2500".repeat(54)));
1488
- console.log(` ${chalk.bold("Entity:")} ${s2(data.entity_id) || "N/A"}`);
1489
- console.log(` ${chalk.bold("Invoices:")} ${s2(invoices.count)} total, ${s2(invoices.open_count)} open, ${money2(invoices.total_amount_cents)}`);
1320
+ console.log(` ${chalk.bold("Entity:")} ${s(data.entity_id) || "N/A"}`);
1321
+ console.log(` ${chalk.bold("Invoices:")} ${s(invoices.count)} total, ${s(invoices.open_count)} open, ${money(invoices.total_amount_cents)}`);
1490
1322
  if (invoices.latest_due_date) {
1491
1323
  console.log(` ${chalk.bold("Invoice Horizon:")} next due ${date(invoices.latest_due_date)}`);
1492
1324
  }
1493
- console.log(` ${chalk.bold("Bank Accounts:")} ${s2(bankAccounts.active_count)}/${s2(bankAccounts.count)} active`);
1494
- console.log(` ${chalk.bold("Payments:")} ${s2(payments.count)} total, ${s2(payments.pending_count)} pending, ${money2(payments.total_amount_cents)}`);
1495
- console.log(` ${chalk.bold("Payroll Runs:")} ${s2(payrollRuns.count)} total${payrollRuns.latest_period_end ? `, latest ${date(payrollRuns.latest_period_end)}` : ""}`);
1496
- console.log(` ${chalk.bold("Distributions:")} ${s2(distributions.count)} total, ${money2(distributions.total_amount_cents)}`);
1497
- console.log(` ${chalk.bold("Reconciliations:")} ${s2(reconciliations.balanced_count)}/${s2(reconciliations.count)} balanced`);
1498
- console.log(` ${chalk.bold("Contractors:")} ${s2(classifications.count)} classifications, ${s2(classifications.high_risk_count)} high risk`);
1325
+ console.log(` ${chalk.bold("Bank Accounts:")} ${s(bankAccounts.active_count)}/${s(bankAccounts.count)} active`);
1326
+ console.log(` ${chalk.bold("Payments:")} ${s(payments.count)} total, ${s(payments.pending_count)} pending, ${money(payments.total_amount_cents)}`);
1327
+ console.log(` ${chalk.bold("Payroll Runs:")} ${s(payrollRuns.count)} total${payrollRuns.latest_period_end ? `, latest ${date(payrollRuns.latest_period_end)}` : ""}`);
1328
+ console.log(` ${chalk.bold("Distributions:")} ${s(distributions.count)} total, ${money(distributions.total_amount_cents)}`);
1329
+ console.log(` ${chalk.bold("Reconciliations:")} ${s(reconciliations.balanced_count)}/${s(reconciliations.count)} balanced`);
1330
+ console.log(` ${chalk.bold("Contractors:")} ${s(classifications.count)} classifications, ${s(classifications.high_risk_count)} high risk`);
1499
1331
  console.log(chalk.green("\u2500".repeat(54)));
1500
1332
  }
1501
1333
  function printNextSteps(data) {
@@ -1550,12 +1382,12 @@ function makeTable(title, columns) {
1550
1382
  ${chalk.bold(title)}`);
1551
1383
  return new Table({ head: columns.map((c) => chalk.dim(c)) });
1552
1384
  }
1553
- function s2(val, maxLen) {
1385
+ function s(val, maxLen) {
1554
1386
  const str = val == null ? "" : String(val);
1555
1387
  if (maxLen && str.length > maxLen) return str.slice(0, maxLen);
1556
1388
  return str;
1557
1389
  }
1558
- function money2(val, cents = true) {
1390
+ function money(val, cents = true) {
1559
1391
  if (typeof val === "number") {
1560
1392
  const dollars = cents ? val / 100 : val;
1561
1393
  return `$${dollars.toLocaleString(void 0, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
@@ -1563,7 +1395,7 @@ function money2(val, cents = true) {
1563
1395
  return String(val ?? "");
1564
1396
  }
1565
1397
  function date(val) {
1566
- const str = s2(val);
1398
+ const str = s(val);
1567
1399
  if (!str) return "";
1568
1400
  const parsed = new Date(str);
1569
1401
  return Number.isNaN(parsed.getTime()) ? str : parsed.toISOString().slice(0, 10);
@@ -1571,23 +1403,23 @@ function date(val) {
1571
1403
  function actorLabel(record, field) {
1572
1404
  const actor = record[`${field}_actor`];
1573
1405
  if (actor && typeof actor === "object" && !Array.isArray(actor)) {
1574
- const label = s2(actor.label);
1575
- const actorType = s2(actor.actor_type);
1406
+ const label = s(actor.label);
1407
+ const actorType = s(actor.actor_type);
1576
1408
  if (label) {
1577
1409
  return actorType ? `${label} (${actorType})` : label;
1578
1410
  }
1579
1411
  }
1580
- return s2(record[field]);
1412
+ return s(record[field]);
1581
1413
  }
1582
1414
  function printEntitiesTable(entities) {
1583
1415
  const table = makeTable("Entities", ["Ref", "Name", "Type", "Jurisdiction", "Status"]);
1584
1416
  for (const e of entities) {
1585
1417
  table.push([
1586
1418
  formatReferenceCell("entity", e),
1587
- s2(e.legal_name ?? e.name),
1588
- s2(e.entity_type),
1589
- s2(e.jurisdiction),
1590
- s2(e.formation_status ?? e.status)
1419
+ s(e.legal_name ?? e.name),
1420
+ s(e.entity_type),
1421
+ s(e.jurisdiction),
1422
+ s(e.formation_status ?? e.status)
1591
1423
  ]);
1592
1424
  }
1593
1425
  console.log(table.toString());
@@ -1595,9 +1427,9 @@ function printEntitiesTable(entities) {
1595
1427
  function printObligationsTable(obligations) {
1596
1428
  const table = makeTable("Obligations", ["ID", "Type", "Urgency", "Due", "Status"]);
1597
1429
  for (const o of obligations) {
1598
- const urg = s2(o.urgency) || "upcoming";
1430
+ const urg = s(o.urgency) || "upcoming";
1599
1431
  const colorFn = URGENCY_COLORS[urg] ?? ((x) => x);
1600
- table.push([s2(o.obligation_id, 12), s2(o.obligation_type), colorFn(urg), s2(o.due_at), s2(o.status)]);
1432
+ table.push([s(o.obligation_id, 12), s(o.obligation_type), colorFn(urg), s(o.due_at), s(o.status)]);
1601
1433
  }
1602
1434
  console.log(table.toString());
1603
1435
  }
@@ -1606,27 +1438,27 @@ function printContactsTable(contacts) {
1606
1438
  for (const c of contacts) {
1607
1439
  table.push([
1608
1440
  formatReferenceCell("contact", c),
1609
- s2(c.name),
1610
- s2(c.email),
1611
- s2(c.category),
1612
- s2(c.entity_name ?? c.entity_id)
1441
+ s(c.name),
1442
+ s(c.email),
1443
+ s(c.category),
1444
+ s(c.entity_name ?? c.entity_id)
1613
1445
  ]);
1614
1446
  }
1615
1447
  console.log(table.toString());
1616
1448
  }
1617
1449
  function printCapTable(data) {
1618
- const accessLevel = s2(data.access_level) || "admin";
1450
+ const accessLevel = s(data.access_level) || "admin";
1619
1451
  const instruments = data.instruments ?? [];
1620
1452
  if (instruments.length > 0) {
1621
1453
  const table = makeTable("Cap Table \u2014 Instruments", ["Ref", "Symbol", "Kind", "Authorized", "Issued", "Diluted"]);
1622
1454
  for (const instrument of instruments) {
1623
1455
  table.push([
1624
1456
  formatReferenceCell("instrument", instrument),
1625
- s2(instrument.symbol),
1626
- s2(instrument.kind),
1627
- s2(instrument.authorized_units ?? "unlimited"),
1628
- s2(instrument.issued_units),
1629
- s2(instrument.diluted_units)
1457
+ s(instrument.symbol),
1458
+ s(instrument.kind),
1459
+ s(instrument.authorized_units ?? "unlimited"),
1460
+ s(instrument.issued_units),
1461
+ s(instrument.diluted_units)
1630
1462
  ]);
1631
1463
  }
1632
1464
  console.log(table.toString());
@@ -1640,10 +1472,10 @@ function printCapTable(data) {
1640
1472
  for (const holder of holders) {
1641
1473
  const dilutedBps = typeof holder.fully_diluted_bps === "number" ? `${(holder.fully_diluted_bps / 100).toFixed(2)}%` : "";
1642
1474
  table.push([
1643
- s2(holder.name),
1644
- s2(holder.outstanding_units),
1645
- s2(holder.as_converted_units),
1646
- s2(holder.fully_diluted_units),
1475
+ s(holder.name),
1476
+ s(holder.outstanding_units),
1477
+ s(holder.as_converted_units),
1478
+ s(holder.fully_diluted_units),
1647
1479
  dilutedBps
1648
1480
  ]);
1649
1481
  }
@@ -1657,9 +1489,9 @@ function printCapTable(data) {
1657
1489
  for (const sc of shareClasses) {
1658
1490
  const row = [
1659
1491
  formatReferenceCell("share_class", sc),
1660
- s2(sc.class_code ?? sc.name),
1661
- s2(sc.authorized),
1662
- s2(sc.outstanding)
1492
+ s(sc.class_code ?? sc.name),
1493
+ s(sc.authorized),
1494
+ s(sc.outstanding)
1663
1495
  ];
1664
1496
  if (accessLevel !== "summary") {
1665
1497
  const holders2 = sc.holders ?? [];
@@ -1673,7 +1505,7 @@ function printCapTable(data) {
1673
1505
  if (ownership.length > 0 && accessLevel !== "summary") {
1674
1506
  const table = makeTable("Ownership Breakdown", ["Holder", "Shares", "Percentage", "Class"]);
1675
1507
  for (const o of ownership) {
1676
- table.push([s2(o.holder_name ?? o.name), s2(o.shares), `${o.percentage ?? ""}%`, s2(o.share_class)]);
1508
+ table.push([s(o.holder_name ?? o.name), s(o.shares), `${o.percentage ?? ""}%`, s(o.share_class)]);
1677
1509
  }
1678
1510
  console.log(table.toString());
1679
1511
  }
@@ -1681,7 +1513,7 @@ function printCapTable(data) {
1681
1513
  if (pools.length > 0) {
1682
1514
  const table = makeTable("Option Pools", ["Name", "Authorized", "Granted", "Available"]);
1683
1515
  for (const p of pools) {
1684
- table.push([s2(p.name), s2(p.authorized), s2(p.granted), s2(p.available)]);
1516
+ table.push([s(p.name), s(p.authorized), s(p.granted), s(p.available)]);
1685
1517
  }
1686
1518
  console.log(table.toString());
1687
1519
  }
@@ -1692,7 +1524,7 @@ ${chalk.bold("Fully Diluted Shares:")} ${typeof fd === "number" ? fd.toLocaleStr
1692
1524
  }
1693
1525
  if (data.total_units != null) {
1694
1526
  console.log(`
1695
- ${chalk.bold("Cap Table Basis:")} ${s2(data.basis) || "outstanding"}`);
1527
+ ${chalk.bold("Cap Table Basis:")} ${s(data.basis) || "outstanding"}`);
1696
1528
  console.log(`${chalk.bold("Total Units:")} ${typeof data.total_units === "number" ? data.total_units.toLocaleString() : data.total_units}`);
1697
1529
  }
1698
1530
  }
@@ -1701,11 +1533,11 @@ function printSafesTable(safes) {
1701
1533
  for (const s_ of safes) {
1702
1534
  table.push([
1703
1535
  formatReferenceCell("safe_note", s_),
1704
- s2(s_.investor_name ?? s_.investor),
1705
- money2(s_.principal_amount_cents ?? s_.investment_amount ?? s_.amount),
1706
- money2(s_.valuation_cap_cents ?? s_.valuation_cap ?? s_.cap),
1707
- s2(s_.discount_rate ?? s_.discount),
1708
- s2(s_.issued_at ?? s_.date ?? s_.created_at)
1536
+ s(s_.investor_name ?? s_.investor),
1537
+ money(s_.principal_amount_cents ?? s_.investment_amount ?? s_.amount),
1538
+ money(s_.valuation_cap_cents ?? s_.valuation_cap ?? s_.cap),
1539
+ s(s_.discount_rate ?? s_.discount),
1540
+ s(s_.issued_at ?? s_.date ?? s_.created_at)
1709
1541
  ]);
1710
1542
  }
1711
1543
  console.log(table.toString());
@@ -1715,11 +1547,11 @@ function printTransfersTable(transfers) {
1715
1547
  for (const t of transfers) {
1716
1548
  table.push([
1717
1549
  formatReferenceCell("share_transfer", t),
1718
- s2(t.from_holder ?? t.from),
1719
- s2(t.to_holder ?? t.to),
1720
- s2(t.shares ?? t.share_count),
1721
- s2(t.transfer_type),
1722
- s2(t.status)
1550
+ s(t.from_holder ?? t.from),
1551
+ s(t.to_holder ?? t.to),
1552
+ s(t.shares ?? t.share_count),
1553
+ s(t.transfer_type),
1554
+ s(t.status)
1723
1555
  ]);
1724
1556
  }
1725
1557
  console.log(table.toString());
@@ -1729,11 +1561,11 @@ function printInstrumentsTable(instruments) {
1729
1561
  for (const instrument of instruments) {
1730
1562
  table.push([
1731
1563
  formatReferenceCell("instrument", instrument),
1732
- s2(instrument.symbol),
1733
- s2(instrument.kind),
1734
- s2(instrument.authorized_units ?? "unlimited"),
1735
- s2(instrument.issued_units),
1736
- s2(instrument.status)
1564
+ s(instrument.symbol),
1565
+ s(instrument.kind),
1566
+ s(instrument.authorized_units ?? "unlimited"),
1567
+ s(instrument.issued_units),
1568
+ s(instrument.status)
1737
1569
  ]);
1738
1570
  }
1739
1571
  console.log(table.toString());
@@ -1743,9 +1575,9 @@ function printShareClassesTable(shareClasses) {
1743
1575
  for (const shareClass of shareClasses) {
1744
1576
  table.push([
1745
1577
  formatReferenceCell("share_class", shareClass),
1746
- s2(shareClass.class_code ?? shareClass.name ?? shareClass.share_class),
1747
- s2(shareClass.authorized),
1748
- s2(shareClass.outstanding)
1578
+ s(shareClass.class_code ?? shareClass.name ?? shareClass.share_class),
1579
+ s(shareClass.authorized),
1580
+ s(shareClass.outstanding)
1749
1581
  ]);
1750
1582
  }
1751
1583
  console.log(table.toString());
@@ -1755,9 +1587,9 @@ function printRoundsTable(rounds) {
1755
1587
  for (const round of rounds) {
1756
1588
  table.push([
1757
1589
  formatReferenceCell("round", round),
1758
- s2(round.name),
1759
- s2(round.status),
1760
- s2(round.issuer_legal_entity_id),
1590
+ s(round.name),
1591
+ s(round.status),
1592
+ s(round.issuer_legal_entity_id),
1761
1593
  date(round.created_at)
1762
1594
  ]);
1763
1595
  }
@@ -1768,10 +1600,10 @@ function printInvoicesTable(invoices) {
1768
1600
  for (const invoice of invoices) {
1769
1601
  table.push([
1770
1602
  formatReferenceCell("invoice", invoice),
1771
- s2(invoice.customer_name),
1772
- money2(invoice.amount_cents),
1603
+ s(invoice.customer_name),
1604
+ money(invoice.amount_cents),
1773
1605
  date(invoice.due_date),
1774
- s2(invoice.status)
1606
+ s(invoice.status)
1775
1607
  ]);
1776
1608
  }
1777
1609
  console.log(table.toString());
@@ -1781,9 +1613,9 @@ function printBankAccountsTable(accounts) {
1781
1613
  for (const account of accounts) {
1782
1614
  table.push([
1783
1615
  formatReferenceCell("bank_account", account),
1784
- s2(account.bank_name),
1785
- s2(account.account_type),
1786
- s2(account.status),
1616
+ s(account.bank_name),
1617
+ s(account.account_type),
1618
+ s(account.status),
1787
1619
  date(account.created_at)
1788
1620
  ]);
1789
1621
  }
@@ -1794,10 +1626,10 @@ function printPaymentsTable(payments) {
1794
1626
  for (const payment of payments) {
1795
1627
  table.push([
1796
1628
  formatReferenceCell("payment", payment),
1797
- s2(payment.recipient),
1798
- money2(payment.amount_cents),
1799
- s2(payment.payment_method),
1800
- s2(payment.status)
1629
+ s(payment.recipient),
1630
+ money(payment.amount_cents),
1631
+ s(payment.payment_method),
1632
+ s(payment.status)
1801
1633
  ]);
1802
1634
  }
1803
1635
  console.log(table.toString());
@@ -1809,7 +1641,7 @@ function printPayrollRunsTable(runs) {
1809
1641
  formatReferenceCell("payroll_run", run),
1810
1642
  date(run.pay_period_start),
1811
1643
  date(run.pay_period_end),
1812
- s2(run.status),
1644
+ s(run.status),
1813
1645
  date(run.created_at)
1814
1646
  ]);
1815
1647
  }
@@ -1820,10 +1652,10 @@ function printDistributionsTable(distributions) {
1820
1652
  for (const distribution of distributions) {
1821
1653
  table.push([
1822
1654
  formatReferenceCell("distribution", distribution),
1823
- s2(distribution.distribution_type),
1824
- money2(distribution.total_amount_cents),
1825
- s2(distribution.status),
1826
- s2(distribution.description)
1655
+ s(distribution.distribution_type),
1656
+ money(distribution.total_amount_cents),
1657
+ s(distribution.status),
1658
+ s(distribution.description)
1827
1659
  ]);
1828
1660
  }
1829
1661
  console.log(table.toString());
@@ -1834,9 +1666,9 @@ function printReconciliationsTable(reconciliations) {
1834
1666
  table.push([
1835
1667
  formatReferenceCell("reconciliation", reconciliation),
1836
1668
  date(reconciliation.as_of_date),
1837
- money2(reconciliation.total_debits_cents),
1838
- money2(reconciliation.total_credits_cents),
1839
- s2(reconciliation.status)
1669
+ money(reconciliation.total_debits_cents),
1670
+ money(reconciliation.total_credits_cents),
1671
+ s(reconciliation.status)
1840
1672
  ]);
1841
1673
  }
1842
1674
  console.log(table.toString());
@@ -1847,9 +1679,9 @@ function printValuationsTable(valuations) {
1847
1679
  table.push([
1848
1680
  formatReferenceCell("valuation", v),
1849
1681
  date(v.effective_date ?? v.valuation_date ?? v.date),
1850
- s2(v.valuation_type ?? v.type),
1851
- money2(v.enterprise_value_cents ?? v.enterprise_value ?? v.valuation),
1852
- money2(v.fmv_per_share_cents ?? v.price_per_share ?? v.pps ?? v.fmv_per_share)
1682
+ s(v.valuation_type ?? v.type),
1683
+ money(v.enterprise_value_cents ?? v.enterprise_value ?? v.valuation),
1684
+ money(v.fmv_per_share_cents ?? v.price_per_share ?? v.pps ?? v.fmv_per_share)
1853
1685
  ]);
1854
1686
  }
1855
1687
  console.log(table.toString());
@@ -1859,10 +1691,10 @@ function printTaxFilingsTable(filings) {
1859
1691
  for (const filing of filings) {
1860
1692
  table.push([
1861
1693
  formatReferenceCell("tax_filing", filing),
1862
- s2(filing.document_type),
1863
- s2(filing.tax_year),
1864
- s2(filing.status),
1865
- s2(filing.document_id, 12)
1694
+ s(filing.document_type),
1695
+ s(filing.tax_year),
1696
+ s(filing.status),
1697
+ s(filing.document_id, 12)
1866
1698
  ]);
1867
1699
  }
1868
1700
  console.log(table.toString());
@@ -1872,10 +1704,10 @@ function printDeadlinesTable(deadlines) {
1872
1704
  for (const deadline of deadlines) {
1873
1705
  table.push([
1874
1706
  formatReferenceCell("deadline", deadline),
1875
- s2(deadline.deadline_type),
1707
+ s(deadline.deadline_type),
1876
1708
  date(deadline.due_date),
1877
- s2(deadline.status),
1878
- s2(deadline.description)
1709
+ s(deadline.status),
1710
+ s(deadline.description)
1879
1711
  ]);
1880
1712
  }
1881
1713
  console.log(table.toString());
@@ -1885,10 +1717,10 @@ function printClassificationsTable(classifications) {
1885
1717
  for (const classification of classifications) {
1886
1718
  table.push([
1887
1719
  formatReferenceCell("classification", classification),
1888
- s2(classification.contractor_name),
1889
- s2(classification.state),
1890
- s2(classification.risk_level),
1891
- s2(classification.classification)
1720
+ s(classification.contractor_name),
1721
+ s(classification.state),
1722
+ s(classification.risk_level),
1723
+ s(classification.classification)
1892
1724
  ]);
1893
1725
  }
1894
1726
  console.log(table.toString());
@@ -1898,10 +1730,10 @@ function printGovernanceTable(bodies) {
1898
1730
  for (const b of bodies) {
1899
1731
  table.push([
1900
1732
  formatReferenceCell("body", b),
1901
- s2(b.name),
1902
- s2(b.body_type ?? b.type),
1903
- s2(b.seat_count ?? b.seats),
1904
- s2(b.meeting_count ?? b.meetings)
1733
+ s(b.name),
1734
+ s(b.body_type ?? b.type),
1735
+ s(b.seat_count ?? b.seats),
1736
+ s(b.meeting_count ?? b.meetings)
1905
1737
  ]);
1906
1738
  }
1907
1739
  console.log(table.toString());
@@ -1911,9 +1743,9 @@ function printSeatsTable(seats) {
1911
1743
  for (const st of seats) {
1912
1744
  table.push([
1913
1745
  formatReferenceCell("seat", st),
1914
- s2(st.holder_name ?? st.holder ?? st.holder_id),
1915
- s2(st.role),
1916
- s2(st.status)
1746
+ s(st.holder_name ?? st.holder ?? st.holder_id),
1747
+ s(st.role),
1748
+ s(st.status)
1917
1749
  ]);
1918
1750
  }
1919
1751
  console.log(table.toString());
@@ -1923,10 +1755,10 @@ function printMeetingsTable(meetings) {
1923
1755
  for (const m of meetings) {
1924
1756
  table.push([
1925
1757
  formatReferenceCell("meeting", m),
1926
- s2(m.title ?? m.name),
1927
- s2(m.scheduled_date ?? m.meeting_date ?? m.date),
1928
- s2(m.status),
1929
- s2(m.resolution_count ?? m.resolutions)
1758
+ s(m.title ?? m.name),
1759
+ s(m.scheduled_date ?? m.meeting_date ?? m.date),
1760
+ s(m.status),
1761
+ s(m.resolution_count ?? m.resolutions)
1930
1762
  ]);
1931
1763
  }
1932
1764
  console.log(table.toString());
@@ -1936,11 +1768,11 @@ function printResolutionsTable(resolutions) {
1936
1768
  for (const r of resolutions) {
1937
1769
  table.push([
1938
1770
  formatReferenceCell("resolution", r),
1939
- s2(r.title),
1940
- s2(r.resolution_type ?? r.type),
1941
- s2(r.status),
1942
- s2(r.votes_for),
1943
- s2(r.votes_against)
1771
+ s(r.title),
1772
+ s(r.resolution_type ?? r.type),
1773
+ s(r.status),
1774
+ s(r.votes_for),
1775
+ s(r.votes_against)
1944
1776
  ]);
1945
1777
  }
1946
1778
  console.log(table.toString());
@@ -1950,9 +1782,9 @@ function printAgendaItemsTable(items) {
1950
1782
  for (const item of items) {
1951
1783
  table.push([
1952
1784
  formatReferenceCell("agenda_item", item),
1953
- s2(item.title),
1954
- s2(item.status),
1955
- s2(item.item_type ?? item.type)
1785
+ s(item.title),
1786
+ s(item.status),
1787
+ s(item.item_type ?? item.type)
1956
1788
  ]);
1957
1789
  }
1958
1790
  console.log(table.toString());
@@ -1961,13 +1793,13 @@ function printDocumentsTable(docs) {
1961
1793
  const table = makeTable("Documents", ["Ref", "Title", "Type", "Date", "Status", "Signatures"]);
1962
1794
  for (const d of docs) {
1963
1795
  const sigs = d.signatures;
1964
- const sigStr = Array.isArray(sigs) ? `${sigs.length} signed` : s2(sigs);
1796
+ const sigStr = Array.isArray(sigs) ? `${sigs.length} signed` : s(sigs);
1965
1797
  table.push([
1966
1798
  formatReferenceCell("document", d),
1967
- s2(d.title ?? d.name),
1968
- s2(d.document_type ?? d.type),
1969
- s2(d.date ?? d.created_at),
1970
- s2(d.status),
1799
+ s(d.title ?? d.name),
1800
+ s(d.document_type ?? d.type),
1801
+ s(d.date ?? d.created_at),
1802
+ s(d.status),
1971
1803
  sigStr
1972
1804
  ]);
1973
1805
  }
@@ -1976,14 +1808,14 @@ function printDocumentsTable(docs) {
1976
1808
  function printWorkItemsTable(items) {
1977
1809
  const table = makeTable("Work Items", ["Ref", "Title", "Category", "Status", "Deadline", "Claimed By"]);
1978
1810
  for (const w of items) {
1979
- const status = s2(w.effective_status ?? w.status);
1811
+ const status = s(w.effective_status ?? w.status);
1980
1812
  const colored = status === "completed" ? chalk.green(status) : status === "claimed" ? chalk.yellow(status) : status === "cancelled" ? chalk.dim(status) : status;
1981
1813
  table.push([
1982
1814
  formatReferenceCell("work_item", w),
1983
- s2(w.title),
1984
- s2(w.category),
1815
+ s(w.title),
1816
+ s(w.category),
1985
1817
  colored,
1986
- w.asap ? chalk.red.bold("ASAP") : s2(w.deadline ?? ""),
1818
+ w.asap ? chalk.red.bold("ASAP") : s(w.deadline ?? ""),
1987
1819
  actorLabel(w, "claimed_by")
1988
1820
  ]);
1989
1821
  }
@@ -1992,9 +1824,9 @@ function printWorkItemsTable(items) {
1992
1824
  function printAgentsTable(agents) {
1993
1825
  const table = makeTable("Agents", ["Ref", "Name", "Status", "Model"]);
1994
1826
  for (const a of agents) {
1995
- const status = s2(a.status);
1827
+ const status = s(a.status);
1996
1828
  const colored = status === "active" ? chalk.green(status) : status === "paused" ? chalk.yellow(status) : status;
1997
- table.push([formatReferenceCell("agent", a), s2(a.name), colored, s2(a.model)]);
1829
+ table.push([formatReferenceCell("agent", a), s(a.name), colored, s(a.model)]);
1998
1830
  }
1999
1831
  console.log(table.toString());
2000
1832
  }
@@ -2002,10 +1834,10 @@ function printServiceCatalogTable(items) {
2002
1834
  const table = makeTable("Service Catalog", ["Slug", "Name", "Price", "Type"]);
2003
1835
  for (const item of items) {
2004
1836
  table.push([
2005
- s2(item.slug),
2006
- s2(item.name),
2007
- money2(item.amount_cents),
2008
- s2(item.price_type)
1837
+ s(item.slug),
1838
+ s(item.name),
1839
+ money(item.amount_cents),
1840
+ s(item.price_type)
2009
1841
  ]);
2010
1842
  }
2011
1843
  console.log(table.toString());
@@ -2013,12 +1845,12 @@ function printServiceCatalogTable(items) {
2013
1845
  function printServiceRequestsTable(requests) {
2014
1846
  const table = makeTable("Service Requests", ["Ref", "Service", "Amount", "Status", "Created"]);
2015
1847
  for (const r of requests) {
2016
- const status = s2(r.status);
1848
+ const status = s(r.status);
2017
1849
  const colored = status === "fulfilled" ? chalk.green(status) : status === "paid" ? chalk.cyan(status) : status === "checkout" ? chalk.yellow(status) : status === "failed" ? chalk.dim(status) : status;
2018
1850
  table.push([
2019
1851
  formatReferenceCell("service_request", r),
2020
- s2(r.service_slug),
2021
- money2(r.amount_cents),
1852
+ s(r.service_slug),
1853
+ money(r.amount_cents),
2022
1854
  colored,
2023
1855
  date(r.created_at)
2024
1856
  ]);
@@ -2026,10 +1858,10 @@ function printServiceRequestsTable(requests) {
2026
1858
  console.log(table.toString());
2027
1859
  }
2028
1860
  function printBillingPanel(status, plans) {
2029
- const plan = s2(status.plan ?? status.tier) || "free";
2030
- const subStatus = s2(status.status) || "active";
2031
- const periodEnd = s2(status.current_period_end);
2032
- const explanation = s2(status.status_explanation);
1861
+ const plan = s(status.plan ?? status.tier) || "free";
1862
+ const subStatus = s(status.status) || "active";
1863
+ const periodEnd = s(status.current_period_end);
1864
+ const explanation = s(status.status_explanation);
2033
1865
  console.log(chalk.green("\u2500".repeat(50)));
2034
1866
  console.log(chalk.green.bold(" Billing Status"));
2035
1867
  console.log(chalk.green("\u2500".repeat(50)));
@@ -2044,13 +1876,13 @@ function printBillingPanel(status, plans) {
2044
1876
  const table = makeTable("Available Plans", ["Plan", "Price", "Features"]);
2045
1877
  for (const p of plans) {
2046
1878
  const amount = p.price_cents ?? p.amount ?? 0;
2047
- const interval = s2(p.interval);
1879
+ const interval = s(p.interval);
2048
1880
  let priceStr = "Free";
2049
1881
  if (amount > 0) {
2050
1882
  priceStr = interval ? `$${Math.round(amount / 100)}/${interval}` : `$${Math.round(amount / 100)}`;
2051
1883
  }
2052
- const name = s2(p.name ?? p.plan_id ?? p.tier);
2053
- const features = Array.isArray(p.features) ? p.features.join(", ") : s2(p.description);
1884
+ const name = s(p.name ?? p.plan_id ?? p.tier);
1885
+ const features = Array.isArray(p.features) ? p.features.join(", ") : s(p.description);
2054
1886
  table.push([name, priceStr, features]);
2055
1887
  }
2056
1888
  console.log(table.toString());
@@ -2089,6 +1921,174 @@ var init_output = __esm({
2089
1921
  }
2090
1922
  });
2091
1923
 
1924
+ // src/animation.ts
1925
+ function renderFrame(frame) {
1926
+ const cols = [];
1927
+ for (let i = 0; i < BUILDINGS.length; i++) {
1928
+ const building = BUILDINGS[i];
1929
+ const h = building.length;
1930
+ const visible = Math.max(0, Math.min(h, frame - i));
1931
+ const width = building[0]?.length ?? 6;
1932
+ const blank = " ".repeat(width);
1933
+ const col = Array(MAX_HEIGHT - visible).fill(blank);
1934
+ col.push(...building.slice(h - visible));
1935
+ cols.push(col);
1936
+ }
1937
+ const lines = [];
1938
+ for (let row = 0; row < MAX_HEIGHT; row++) {
1939
+ lines.push(cols.map((col) => col[row]).join(""));
1940
+ }
1941
+ return lines.join("\n");
1942
+ }
1943
+ async function withAnimation(fn) {
1944
+ if (!process.stdout.isTTY) {
1945
+ return fn();
1946
+ }
1947
+ let frame = 0;
1948
+ let animDone = false;
1949
+ const spinChars = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
1950
+ let spinIdx = 0;
1951
+ let lastLineCount = 0;
1952
+ const clearPrev = () => {
1953
+ if (lastLineCount > 0) {
1954
+ process.stdout.write(`\x1B[${lastLineCount}A\x1B[0J`);
1955
+ }
1956
+ };
1957
+ const drawFrame = () => {
1958
+ clearPrev();
1959
+ if (!animDone) {
1960
+ const art = renderFrame(frame);
1961
+ const output = `${GOLD}${art}${RESET}
1962
+ `;
1963
+ process.stdout.write(output);
1964
+ lastLineCount = MAX_HEIGHT + 1;
1965
+ frame++;
1966
+ if (frame >= TOTAL_FRAMES) {
1967
+ animDone = true;
1968
+ }
1969
+ } else {
1970
+ const line = `${GOLD}${spinChars[spinIdx % spinChars.length]} Loading...${RESET}
1971
+ `;
1972
+ process.stdout.write(line);
1973
+ lastLineCount = 1;
1974
+ spinIdx++;
1975
+ }
1976
+ };
1977
+ drawFrame();
1978
+ const timer = setInterval(drawFrame, 100);
1979
+ try {
1980
+ const result = await fn();
1981
+ return result;
1982
+ } finally {
1983
+ clearInterval(timer);
1984
+ clearPrev();
1985
+ }
1986
+ }
1987
+ var BUILDINGS, MAX_HEIGHT, TOTAL_FRAMES, GOLD, RESET;
1988
+ var init_animation = __esm({
1989
+ "src/animation.ts"() {
1990
+ "use strict";
1991
+ BUILDINGS = [
1992
+ [
1993
+ " \u250C\u2510 ",
1994
+ " \u2502\u2502 ",
1995
+ " \u2502\u2502 ",
1996
+ " \u250C\u2524\u251C\u2510 ",
1997
+ " \u2502\u2502\u2502\u2502\u2502",
1998
+ " \u2502\u2502\u2502\u2502\u2502"
1999
+ ],
2000
+ [
2001
+ " \u2554\u2550\u2550\u2557 ",
2002
+ " \u2551\u25AA\u25AA\u2551 ",
2003
+ " \u2551\u25AA\u25AA\u2551 ",
2004
+ " \u2551\u25AA\u25AA\u2551 ",
2005
+ " \u2551\u25AA\u25AA\u2551 ",
2006
+ " \u2551\u25AA\u25AA\u2551 ",
2007
+ " \u2551\u25AA\u25AA\u2551 ",
2008
+ " \u2551\u25AA\u25AA\u2551 "
2009
+ ],
2010
+ [
2011
+ " /\\ ",
2012
+ " / \\ ",
2013
+ " \u2502\u25AA\u25AA\u2502 ",
2014
+ " \u2502\u25AA\u25AA\u2502 ",
2015
+ " \u2502\u25AA\u25AA\u2502 "
2016
+ ],
2017
+ [
2018
+ " \u250C\u2500\u2500\u2510 ",
2019
+ " \u2502\u224B\u224B\u2502 ",
2020
+ " \u2502\u25AA\u25AA\u2502 ",
2021
+ " \u2502\u25AA\u25AA\u2502 ",
2022
+ " \u2502\u25AA\u25AA\u2502 ",
2023
+ " \u2502\u25AA\u25AA\u2502 ",
2024
+ " \u2502\u25AA\u25AA\u2502 ",
2025
+ " \u2502\u25AA\u25AA\u2502 ",
2026
+ " \u2502\u25AA\u25AA\u2502 "
2027
+ ],
2028
+ [
2029
+ " \u257B ",
2030
+ " \u2503 ",
2031
+ " \u250C\u2524\u2510 ",
2032
+ " \u2502\u25AA\u2502 ",
2033
+ " \u2502\u25AA\u2502 ",
2034
+ " \u2502\u25AA\u2502 ",
2035
+ " \u2502\u25AA\u2502 ",
2036
+ " \u2502\u25AA\u2502 ",
2037
+ " \u2502\u25AA\u2502 ",
2038
+ " \u2502\u25AA\u2502 ",
2039
+ " \u2502\u25AA\u2502 "
2040
+ ],
2041
+ [
2042
+ " \u250C\u2510 ",
2043
+ " \u251C\u2524 ",
2044
+ " \u2502\u25AA\u2502 ",
2045
+ " \u2502\u25AA\u2502 ",
2046
+ " \u2502\u25AA\u2502 ",
2047
+ " \u2502\u25AA\u2502 "
2048
+ ],
2049
+ [
2050
+ " \u2554\u2550\u2550\u2550\u2557",
2051
+ " \u2551\u25AA \u25AA\u2551",
2052
+ " \u2551\u25AA \u25AA\u2551",
2053
+ " \u2551\u25AA \u25AA\u2551",
2054
+ " \u2551\u25AA \u25AA\u2551",
2055
+ " \u2551\u25AA \u25AA\u2551",
2056
+ " \u2551\u25AA \u25AA\u2551",
2057
+ " \u2551\u25AA \u25AA\u2551",
2058
+ " \u2551\u25AA \u25AA\u2551",
2059
+ " \u2551\u25AA \u25AA\u2551"
2060
+ ],
2061
+ [
2062
+ " \u252C\u2500\u252C ",
2063
+ " \u2502~\u2502 ",
2064
+ " \u2502\u25AA\u2502 ",
2065
+ " \u2502\u25AA\u2502 ",
2066
+ " \u2502\u25AA\u2502 ",
2067
+ " \u2502\u25AA\u2502 ",
2068
+ " \u2502\u25AA\u2502 "
2069
+ ]
2070
+ ];
2071
+ MAX_HEIGHT = Math.max(...BUILDINGS.map((b) => b.length));
2072
+ TOTAL_FRAMES = MAX_HEIGHT + 4;
2073
+ GOLD = "\x1B[38;2;212;160;23m";
2074
+ RESET = "\x1B[0m";
2075
+ }
2076
+ });
2077
+
2078
+ // src/spinner.ts
2079
+ async function withSpinner(_label, fn, json) {
2080
+ if (json) {
2081
+ return fn();
2082
+ }
2083
+ return withAnimation(fn);
2084
+ }
2085
+ var init_spinner = __esm({
2086
+ "src/spinner.ts"() {
2087
+ "use strict";
2088
+ init_animation();
2089
+ }
2090
+ });
2091
+
2092
2092
  // src/api-client.ts
2093
2093
  import { CorpAPIClient, SessionExpiredError, provisionWorkspace } from "@thecorporation/corp-tools";
2094
2094
  var init_api_client = __esm({
@@ -2182,8 +2182,7 @@ var init_workspace = __esm({
2182
2182
  printStatusPanel(data);
2183
2183
  }
2184
2184
  } catch (err) {
2185
- ctx.writer.error(`Failed to fetch status: ${err}`);
2186
- process.exit(1);
2185
+ throw new Error(`Failed to fetch status: ${err}`);
2187
2186
  }
2188
2187
  },
2189
2188
  examples: ["corp status"]
@@ -2255,8 +2254,7 @@ var init_workspace = __esm({
2255
2254
  }
2256
2255
  console.log(chalk3.blue("\u2500".repeat(50)));
2257
2256
  } catch (err) {
2258
- ctx.writer.error(`Failed to fetch context: ${err}`);
2259
- process.exit(1);
2257
+ throw new Error(`Failed to fetch context: ${err}`);
2260
2258
  }
2261
2259
  },
2262
2260
  examples: ["corp context", "corp context --json"]
@@ -2278,8 +2276,7 @@ var init_workspace = __esm({
2278
2276
  const alias = getReferenceAlias("entity", { entity_id: entityId }) ?? entityId;
2279
2277
  ctx.writer.success(`Active entity set to ${alias} (${entityId})`);
2280
2278
  } catch (err) {
2281
- ctx.writer.error(`Failed to resolve entity: ${err}`);
2282
- process.exit(1);
2279
+ throw new Error(`Failed to resolve entity: ${err}`);
2283
2280
  }
2284
2281
  },
2285
2282
  examples: ["corp use", "corp use --json"]
@@ -2301,8 +2298,7 @@ var init_workspace = __esm({
2301
2298
  handler: async (ctx) => {
2302
2299
  const opts = ctx.opts;
2303
2300
  if (opts.entityId && opts.workspace) {
2304
- ctx.writer.error("--entity-id and --workspace are mutually exclusive");
2305
- process.exit(1);
2301
+ throw new Error("--entity-id and --workspace are mutually exclusive");
2306
2302
  }
2307
2303
  const localItems = localChecks();
2308
2304
  const hasCriticalLocal = localItems.some((i) => i.urgency === "critical");
@@ -2372,8 +2368,7 @@ var init_workspace = __esm({
2372
2368
  console.log(" corp form finalize @last");
2373
2369
  }
2374
2370
  } else {
2375
- ctx.writer.error(`Failed to fetch next steps: ${err}`);
2376
- process.exit(1);
2371
+ throw new Error(`Failed to fetch next steps: ${err}`);
2377
2372
  }
2378
2373
  }
2379
2374
  }
@@ -2441,8 +2436,7 @@ var init_workspace = __esm({
2441
2436
  }
2442
2437
  }
2443
2438
  } catch (err) {
2444
- ctx.writer.error(`Failed: ${err}`);
2445
- process.exit(1);
2439
+ throw new Error(`Failed: ${err}`);
2446
2440
  }
2447
2441
  },
2448
2442
  examples: ["corp digest"]
@@ -2465,8 +2459,7 @@ var init_workspace = __esm({
2465
2459
  printBillingPanel(enrichedStatus, plans);
2466
2460
  }
2467
2461
  } catch (err) {
2468
- ctx.writer.error(`Failed to fetch billing info: ${err}`);
2469
- process.exit(1);
2462
+ throw new Error(`Failed to fetch billing info: ${err}`);
2470
2463
  }
2471
2464
  },
2472
2465
  examples: ["corp billing"]
@@ -2481,14 +2474,12 @@ var init_workspace = __esm({
2481
2474
  const result = await ctx.client.createBillingPortal();
2482
2475
  const url = result.portal_url;
2483
2476
  if (!url) {
2484
- ctx.writer.error("No portal URL returned. Ensure you have an active subscription.");
2485
- process.exit(1);
2477
+ throw new Error("No portal URL returned. Ensure you have an active subscription.");
2486
2478
  }
2487
2479
  ctx.writer.success("Stripe Customer Portal URL:");
2488
2480
  ctx.writer.writeln(url);
2489
2481
  } catch (err) {
2490
- ctx.writer.error(`Failed to create portal session: ${err}`);
2491
- process.exit(1);
2482
+ throw new Error(`Failed to create portal session: ${err}`);
2492
2483
  }
2493
2484
  },
2494
2485
  examples: ["corp billing portal"]
@@ -2512,14 +2503,12 @@ var init_workspace = __esm({
2512
2503
  const result = await ctx.client.createBillingCheckout(opts.plan);
2513
2504
  const url = result.checkout_url;
2514
2505
  if (!url) {
2515
- ctx.writer.error("No checkout URL returned.");
2516
- process.exit(1);
2506
+ throw new Error("No checkout URL returned.");
2517
2507
  }
2518
2508
  ctx.writer.success(`Stripe Checkout URL for ${opts.plan}:`);
2519
2509
  ctx.writer.writeln(url);
2520
2510
  } catch (err) {
2521
- ctx.writer.error(`Failed to create checkout session: ${err}`);
2522
- process.exit(1);
2511
+ throw new Error(`Failed to create checkout session: ${err}`);
2523
2512
  }
2524
2513
  },
2525
2514
  examples: ["corp billing upgrade"]
@@ -2560,8 +2549,7 @@ async function entitiesHandler(ctx) {
2560
2549
  printEntitiesTable(entities);
2561
2550
  }
2562
2551
  } catch (err) {
2563
- printError(`Failed to fetch entities: ${err}`);
2564
- process.exit(1);
2552
+ throw new Error(`Failed to fetch entities: ${err}`);
2565
2553
  }
2566
2554
  }
2567
2555
  async function entitiesShowHandler(ctx) {
@@ -2573,8 +2561,7 @@ async function entitiesShowHandler(ctx) {
2573
2561
  const entities = await ctx.client.listEntities();
2574
2562
  const entity = entities.find((e) => e.entity_id === resolvedEntityId);
2575
2563
  if (!entity) {
2576
- printError(`Entity not found: ${entityRef}`);
2577
- process.exit(1);
2564
+ throw new Error(`Entity not found: ${entityRef}`);
2578
2565
  }
2579
2566
  await ctx.resolver.stabilizeRecord("entity", entity);
2580
2567
  if (quiet) {
@@ -2598,8 +2585,7 @@ async function entitiesShowHandler(ctx) {
2598
2585
  console.log(chalk4.blue("\u2500".repeat(40)));
2599
2586
  }
2600
2587
  } catch (err) {
2601
- printError(`Failed to fetch entities: ${err}`);
2602
- process.exit(1);
2588
+ throw new Error(`Failed to fetch entities: ${err}`);
2603
2589
  }
2604
2590
  }
2605
2591
  async function entitiesConvertHandler(ctx) {
@@ -2612,8 +2598,7 @@ async function entitiesConvertHandler(ctx) {
2612
2598
  printSuccess(`Entity conversion initiated: ${result.conversion_id ?? "OK"}`);
2613
2599
  printJson(result);
2614
2600
  } catch (err) {
2615
- printError(`Failed to convert entity: ${err}`);
2616
- process.exit(1);
2601
+ throw new Error(`Failed to convert entity: ${err}`);
2617
2602
  }
2618
2603
  }
2619
2604
  async function entitiesDissolveHandler(ctx) {
@@ -2638,11 +2623,10 @@ async function entitiesDissolveHandler(ctx) {
2638
2623
  } catch (err) {
2639
2624
  const msg = String(err);
2640
2625
  if (msg.includes("InvalidTransition") || msg.includes("422")) {
2641
- printError(`Cannot dissolve entity: only entities with 'active' status can be dissolved. Check the entity's current status with: corp entities show ${entityRef}`);
2626
+ throw new Error(`Cannot dissolve entity: only entities with 'active' status can be dissolved. Check the entity's current status with: corp entities show ${entityRef}`);
2642
2627
  } else {
2643
- printError(`Failed to dissolve entity: ${err}`);
2628
+ throw new Error(`Failed to dissolve entity: ${err}`);
2644
2629
  }
2645
- process.exit(1);
2646
2630
  }
2647
2631
  }
2648
2632
  async function contactsHandler(ctx) {
@@ -2655,8 +2639,7 @@ async function contactsHandler(ctx) {
2655
2639
  else if (contacts.length === 0) console.log("No contacts found.");
2656
2640
  else printContactsTable(contacts);
2657
2641
  } catch (err) {
2658
- printError(`Failed to fetch contacts: ${err}`);
2659
- process.exit(1);
2642
+ throw new Error(`Failed to fetch contacts: ${err}`);
2660
2643
  }
2661
2644
  }
2662
2645
  async function contactsShowHandler(ctx) {
@@ -2691,8 +2674,7 @@ async function contactsShowHandler(ctx) {
2691
2674
  console.log(chalk4.cyan("\u2500".repeat(40)));
2692
2675
  }
2693
2676
  } catch (err) {
2694
- printError(`Failed to fetch contact: ${err}`);
2695
- process.exit(1);
2677
+ throw new Error(`Failed to fetch contact: ${err}`);
2696
2678
  }
2697
2679
  }
2698
2680
  async function contactsAddHandler(ctx) {
@@ -2719,8 +2701,7 @@ async function contactsAddHandler(ctx) {
2719
2701
  { jsonOnly: jsonOutput, referenceKind: "contact", showReuseHint: true }
2720
2702
  );
2721
2703
  } catch (err) {
2722
- printError(`Failed to create contact: ${err}`);
2723
- process.exit(1);
2704
+ throw new Error(`Failed to create contact: ${err}`);
2724
2705
  }
2725
2706
  }
2726
2707
  async function contactsEditHandler(ctx) {
@@ -2767,8 +2748,7 @@ async function contactsEditHandler(ctx) {
2767
2748
  ctx.resolver.remember("contact", resolvedContactId, eid);
2768
2749
  printWriteResult(result, "Contact updated.", jsonOutput);
2769
2750
  } catch (err) {
2770
- printError(`Failed to update contact: ${err}`);
2771
- process.exit(1);
2751
+ throw new Error(`Failed to update contact: ${err}`);
2772
2752
  }
2773
2753
  }
2774
2754
  var entityCommands;
@@ -2812,7 +2792,7 @@ var init_entities = __esm({
2812
2792
  options: [
2813
2793
  { flags: "--reason <reason>", description: "Dissolution reason", required: true },
2814
2794
  { flags: "--effective-date <date>", description: "Effective date (ISO 8601)" },
2815
- { flags: "--yes, -y", description: "Skip confirmation prompt" }
2795
+ { flags: "--yes -y", description: "Skip confirmation prompt" }
2816
2796
  ],
2817
2797
  handler: entitiesDissolveHandler,
2818
2798
  examples: ["corp entities dissolve <entity-ref> --reason 'reason'", "corp entities dissolve --json"]
@@ -2899,7 +2879,7 @@ var init_entities = __esm({
2899
2879
  { flags: "--sms-enabled <sms-enabled>", description: "Sms Enabled" },
2900
2880
  { flags: "--webhook-enabled <webhook-enabled>", description: "Webhook Enabled" }
2901
2881
  ],
2902
- examples: ["corp contacts notification-prefs <contact-id>", "corp contacts notification-prefs --json"],
2882
+ examples: ["corp contacts update-notification-prefs <contact-id>", "corp contacts update-notification-prefs --json"],
2903
2883
  successTemplate: "Notification Prefs updated"
2904
2884
  }
2905
2885
  ];
@@ -3953,28 +3933,23 @@ async function resolveEntityRefForFormCommand2(resolver, entityRef, dryRun) {
3953
3933
  async function formCreateHandler(ctx) {
3954
3934
  const opts = ctx.opts;
3955
3935
  if (opts.shares || opts.authorizedShares) {
3956
- ctx.writer.error(
3936
+ throw new Error(
3957
3937
  "--shares / --authorized-shares is not accepted on form create.\n Set authorized shares during finalize:\n corp form finalize @last:entity --authorized-shares 10000000"
3958
3938
  );
3959
- process.exit(1);
3960
3939
  }
3961
3940
  const resolvedType = opts.type;
3962
3941
  const resolvedName = opts.name;
3963
3942
  if (!resolvedType) {
3964
- ctx.writer.error("required option '--type <type>' not specified");
3965
- process.exit(1);
3943
+ throw new Error("required option '--type <type>' not specified");
3966
3944
  }
3967
3945
  if (!SUPPORTED_ENTITY_TYPES2.includes(resolvedType)) {
3968
- ctx.writer.error(`unsupported entity type '${resolvedType}'. Supported types: ${SUPPORTED_ENTITY_TYPES2.join(", ")}`);
3969
- process.exit(1);
3946
+ throw new Error(`unsupported entity type '${resolvedType}'. Supported types: ${SUPPORTED_ENTITY_TYPES2.join(", ")}`);
3970
3947
  }
3971
3948
  if (!resolvedName) {
3972
- ctx.writer.error("required option '--name <name>' not specified");
3973
- process.exit(1);
3949
+ throw new Error("required option '--name <name>' not specified");
3974
3950
  }
3975
3951
  if (!resolvedName.trim()) {
3976
- ctx.writer.error("--name cannot be empty or whitespace");
3977
- process.exit(1);
3952
+ throw new Error("--name cannot be empty or whitespace");
3978
3953
  }
3979
3954
  const cfg = requireConfig("api_url", "api_key", "workspace_id");
3980
3955
  try {
@@ -4026,8 +4001,7 @@ async function formCreateHandler(ctx) {
4026
4001
  console.log(chalk6.yellow(`
4027
4002
  Next: corp form add-founder @last:entity --name "..." --email "..." --role member --pct 50`));
4028
4003
  } catch (err) {
4029
- printError(`Failed to create pending entity: ${err}`);
4030
- process.exit(1);
4004
+ throw new Error(`Failed to create pending entity: ${err}`);
4031
4005
  }
4032
4006
  }
4033
4007
  async function formAddFounderHandler(ctx) {
@@ -4037,13 +4011,11 @@ async function formAddFounderHandler(ctx) {
4037
4011
  const resolvedEntityId = await resolveEntityRefForFormCommand2(ctx.resolver, entityRef, ctx.dryRun);
4038
4012
  const rawPct = opts.ownershipPct ?? opts.pct;
4039
4013
  if (!rawPct) {
4040
- ctx.writer.error("required option '--ownership-pct <percent>' not specified");
4041
- process.exit(1);
4014
+ throw new Error("required option '--ownership-pct <percent>' not specified");
4042
4015
  }
4043
4016
  const pctValue = parseFloat(rawPct);
4044
4017
  if (isNaN(pctValue) || pctValue <= 0 || pctValue > 100) {
4045
- ctx.writer.error(`--ownership-pct must be between 0 and 100 (e.g. 60 for 60%), got: ${rawPct}`);
4046
- process.exit(1);
4018
+ throw new Error(`--ownership-pct must be between 0 and 100 (e.g. 60 for 60%), got: ${rawPct}`);
4047
4019
  }
4048
4020
  const payload = {
4049
4021
  name: opts.name,
@@ -4073,8 +4045,7 @@ async function formAddFounderHandler(ctx) {
4073
4045
  console.log(chalk6.yellow(`
4074
4046
  Next: add more founders or run: corp form finalize @last:entity`));
4075
4047
  } catch (err) {
4076
- printError(`Failed to add founder: ${err}`);
4077
- process.exit(1);
4048
+ throw new Error(`Failed to add founder: ${err}`);
4078
4049
  }
4079
4050
  }
4080
4051
  async function formFinalizeHandler(ctx) {
@@ -4165,7 +4136,7 @@ async function formFinalizeHandler(ctx) {
4165
4136
  hints.push('--incorporator-name "Incorporator Name"');
4166
4137
  }
4167
4138
  if (hints.length > 0) {
4168
- printError(
4139
+ throw new Error(
4169
4140
  `Finalization failed: ${msg}
4170
4141
 
4171
4142
  To fix, re-run finalize with the missing fields:
@@ -4175,9 +4146,8 @@ async function formFinalizeHandler(ctx) {
4175
4146
  corp form finalize @last ${hints.filter((h) => h.startsWith("--")).join(" ")}`
4176
4147
  );
4177
4148
  } else {
4178
- printError(`Failed to finalize formation: ${err}`);
4149
+ throw new Error(`Failed to finalize formation: ${err}`);
4179
4150
  }
4180
- process.exit(1);
4181
4151
  }
4182
4152
  }
4183
4153
  async function formActivateHandler(ctx) {
@@ -4228,8 +4198,7 @@ async function formActivateHandler(ctx) {
4228
4198
  console.log(chalk6.yellow(" corp next See all recommended actions"));
4229
4199
  }
4230
4200
  } catch (err) {
4231
- printError(`Failed to activate formation: ${err}`);
4232
- process.exit(1);
4201
+ throw new Error(`Failed to activate formation: ${err}`);
4233
4202
  }
4234
4203
  }
4235
4204
  var SUPPORTED_ENTITY_TYPES2, formationCommands;
@@ -4346,7 +4315,11 @@ var init_formation = __esm({
4346
4315
  { flags: "--incorporator-address <address>", description: "Incorporator mailing address (overrides founder)" }
4347
4316
  ],
4348
4317
  handler: formFinalizeHandler,
4349
- examples: ["corp form finalize"]
4318
+ examples: [
4319
+ "corp form finalize @last:entity",
4320
+ "corp form finalize @last:entity --authorized-shares 10000000 --par-value 0.0001",
4321
+ 'corp form finalize @last:entity --company-address "123 Main St,Wilmington,DE,19801" --incorporator-name "Alice Smith"'
4322
+ ]
4350
4323
  },
4351
4324
  {
4352
4325
  name: "form activate",
@@ -4361,7 +4334,11 @@ var init_formation = __esm({
4361
4334
  { flags: "--ein <ein>", description: "EIN to confirm (defaults to a deterministic simulated EIN)" }
4362
4335
  ],
4363
4336
  handler: formActivateHandler,
4364
- examples: ["corp form activate"]
4337
+ examples: [
4338
+ "corp form activate @last:entity",
4339
+ "corp form activate @last:entity --ein 84-1234567",
4340
+ "corp form activate @last:entity --filing-id DE-2026-0042 --receipt-reference RECEIPT-001"
4341
+ ]
4365
4342
  },
4366
4343
  // ── Auto-generated from OpenAPI ──────────────────────────────
4367
4344
  {
@@ -4462,7 +4439,7 @@ var init_formation = __esm({
4462
4439
  },
4463
4440
  {
4464
4441
  name: "formations pending",
4465
- description: "List entities with pending formations",
4442
+ description: "Create a pending formation",
4466
4443
  route: { method: "POST", path: "/v1/formations/pending" },
4467
4444
  options: [
4468
4445
  { flags: "--company-address <company-address>", description: "Company mailing address" },
@@ -4478,7 +4455,7 @@ var init_formation = __esm({
4478
4455
  { flags: "--transfer-restrictions <transfer-restrictions>", description: "Transfer Restrictions" }
4479
4456
  ],
4480
4457
  examples: ["corp formations pending --entity-type c_corp --legal-name 'legal-name'", "corp formations pending --json"],
4481
- successTemplate: "Pending created"
4458
+ successTemplate: "Pending formation created"
4482
4459
  },
4483
4460
  {
4484
4461
  name: "formations with-cap-table",
@@ -4723,8 +4700,7 @@ var init_cap_table = __esm({
4723
4700
  return;
4724
4701
  }
4725
4702
  if (data.access_level === "none") {
4726
- ctx.writer.error("You do not have access to this entity's cap table.");
4727
- process.exit(1);
4703
+ throw new Error("You do not have access to this entity's cap table.");
4728
4704
  }
4729
4705
  printCapTable(data);
4730
4706
  try {
@@ -4944,10 +4920,10 @@ var init_cap_table = __esm({
4944
4920
  "No 409A valuation found for this entity. Create one with:\n corp cap-table create-valuation --type four_oh_nine_a --date YYYY-MM-DD --methodology <method>"
4945
4921
  );
4946
4922
  }
4923
+ return;
4947
4924
  } else {
4948
- ctx.writer.error(`Failed to fetch 409A valuation: ${err}`);
4925
+ throw new Error(`Failed to fetch 409A valuation: ${err}`);
4949
4926
  }
4950
- process.exit(1);
4951
4927
  }
4952
4928
  },
4953
4929
  examples: ["corp cap-table 409a", "corp cap-table 409a --json"]
@@ -5520,7 +5496,7 @@ var init_cap_table = __esm({
5520
5496
  if (resolutionId) body.resolution_id = resolutionId;
5521
5497
  const result = await ctx.client.issueRound(roundId, body);
5522
5498
  ctx.resolver.remember("round", roundId, eid);
5523
- const roundMatch = (await ctx.resolver.find("round", shortId2(roundId), { entityId: eid })).find((match) => match.id === roundId);
5499
+ const roundMatch = (await ctx.resolver.find("round", shortId(roundId), { entityId: eid })).find((match) => match.id === roundId);
5524
5500
  if (ctx.opts.json) {
5525
5501
  ctx.writer.json(result);
5526
5502
  return;
@@ -5623,7 +5599,7 @@ var init_cap_table = __esm({
5623
5599
  ctx.writer.success(`Valuation submitted for approval: ${result.valuation_id ?? valuationId ?? "OK"}`);
5624
5600
  printReferenceSummary("valuation", result, { showReuseHint: true });
5625
5601
  if (result.meeting_id) {
5626
- const meetingMatch = (await ctx.resolver.find("meeting", shortId2(String(result.meeting_id)), { entityId: eid })).find((match) => match.id === String(result.meeting_id));
5602
+ const meetingMatch = (await ctx.resolver.find("meeting", shortId(String(result.meeting_id)), { entityId: eid })).find((match) => match.id === String(result.meeting_id));
5627
5603
  if (meetingMatch) {
5628
5604
  printReferenceSummary("meeting", meetingMatch.raw, { label: "Meeting Ref:" });
5629
5605
  } else {
@@ -5631,7 +5607,7 @@ var init_cap_table = __esm({
5631
5607
  }
5632
5608
  }
5633
5609
  if (result.agenda_item_id) {
5634
- const agendaMatch = (await ctx.resolver.find("agenda_item", shortId2(String(result.agenda_item_id)), {
5610
+ const agendaMatch = (await ctx.resolver.find("agenda_item", shortId(String(result.agenda_item_id)), {
5635
5611
  entityId: eid,
5636
5612
  meetingId: result.meeting_id ? String(result.meeting_id) : void 0
5637
5613
  })).find((match) => match.id === String(result.agenda_item_id));
@@ -5644,11 +5620,10 @@ var init_cap_table = __esm({
5644
5620
  } catch (err) {
5645
5621
  const msg = String(err);
5646
5622
  if (msg.includes("404") || msg.includes("Not found") || msg.includes("not found")) {
5647
- ctx.writer.error(`Valuation not found. List valuations with: corp cap-table valuations`);
5623
+ throw new Error(`Valuation not found. List valuations with: corp cap-table valuations`);
5648
5624
  } else {
5649
- ctx.writer.error(`Failed to submit valuation: ${err}`);
5625
+ throw new Error(`Failed to submit valuation: ${err}`);
5650
5626
  }
5651
- process.exit(1);
5652
5627
  }
5653
5628
  },
5654
5629
  examples: ["corp cap-table submit-valuation <valuation-ref>"]
@@ -5689,11 +5664,10 @@ var init_cap_table = __esm({
5689
5664
  } catch (err) {
5690
5665
  const msg = String(err);
5691
5666
  if (msg.includes("400")) {
5692
- ctx.writer.error(`Bad request \u2014 a --resolution-id from a board vote may be required. Submit for approval first: corp cap-table submit-valuation <valuation-ref>`);
5667
+ throw new Error(`Bad request \u2014 a --resolution-id from a board vote may be required. Submit for approval first: corp cap-table submit-valuation <valuation-ref>`);
5693
5668
  } else {
5694
- ctx.writer.error(`Failed to approve valuation: ${err}`);
5669
+ throw new Error(`Failed to approve valuation: ${err}`);
5695
5670
  }
5696
- process.exit(1);
5697
5671
  }
5698
5672
  },
5699
5673
  examples: ["corp cap-table approve-valuation <valuation-ref>", "corp cap-table approve-valuation --json"]
@@ -6537,13 +6511,11 @@ var init_finance = __esm({
6537
6511
  handler: async (ctx) => {
6538
6512
  const eid = await ctx.resolver.resolveEntity(ctx.opts.entityId);
6539
6513
  if (ctx.opts.amountCents != null && ctx.opts.amountDollars != null) {
6540
- printError("--amount-cents and --amount-dollars are mutually exclusive. Use one or the other.");
6541
- process.exit(1);
6514
+ throw new Error("--amount-cents and --amount-dollars are mutually exclusive. Use one or the other.");
6542
6515
  }
6543
6516
  const amountCents = ctx.opts.amountCents ?? (ctx.opts.amountDollars != null ? ctx.opts.amountDollars * 100 : void 0);
6544
6517
  if (amountCents == null) {
6545
- printError("required: --amount-cents <n> or --amount-dollars <n>");
6546
- process.exit(1);
6518
+ throw new Error("required: --amount-cents <n> or --amount-dollars <n>");
6547
6519
  }
6548
6520
  const result = await ctx.client.createInvoice({
6549
6521
  entity_id: eid,
@@ -6605,13 +6577,11 @@ var init_finance = __esm({
6605
6577
  handler: async (ctx) => {
6606
6578
  const eid = await ctx.resolver.resolveEntity(ctx.opts.entityId);
6607
6579
  if (ctx.opts.amountCents != null && ctx.opts.amountDollars != null) {
6608
- printError("--amount-cents and --amount-dollars are mutually exclusive. Use one or the other.");
6609
- process.exit(1);
6580
+ throw new Error("--amount-cents and --amount-dollars are mutually exclusive. Use one or the other.");
6610
6581
  }
6611
6582
  const amountCents = ctx.opts.amountCents ?? (ctx.opts.amountDollars != null ? ctx.opts.amountDollars * 100 : void 0);
6612
6583
  if (amountCents == null) {
6613
- printError("required: --amount-cents <n> or --amount-dollars <n>");
6614
- process.exit(1);
6584
+ throw new Error("required: --amount-cents <n> or --amount-dollars <n>");
6615
6585
  }
6616
6586
  const method = ctx.opts.method;
6617
6587
  const result = await ctx.client.submitPayment({
@@ -6923,7 +6893,17 @@ var init_finance = __esm({
6923
6893
  ctx.writer.json(result);
6924
6894
  return;
6925
6895
  }
6926
- printJson(result);
6896
+ if (result && typeof result === "object" && !Array.isArray(result)) {
6897
+ const rec = result;
6898
+ const lines = Object.entries(rec).map(([key, val]) => {
6899
+ const label = key.replace(/_/g, " ").replace(/\b\w/g, (ch) => ch.toUpperCase());
6900
+ const formatted = typeof val === "object" ? JSON.stringify(val) : String(val ?? "");
6901
+ return `${label}: ${formatted}`;
6902
+ });
6903
+ ctx.writer.panel("Financial Statements", "green", lines);
6904
+ } else {
6905
+ ctx.writer.json(result);
6906
+ }
6927
6907
  },
6928
6908
  examples: ["corp finance statements", "corp finance statements --json"]
6929
6909
  }
@@ -7427,7 +7407,7 @@ var init_governance = __esm({
7427
7407
  }
7428
7408
  }
7429
7409
  },
7430
- examples: ["corp governance vote <meeting-ref> <item-ref> --voter for --vote for"]
7410
+ examples: ["corp governance vote <meeting-ref> <item-ref> --voter <contact-ref> --vote for"]
7431
7411
  },
7432
7412
  // --- governance notice <meeting-ref> ---
7433
7413
  {
@@ -7513,7 +7493,7 @@ var init_governance = __esm({
7513
7493
  dryRun: true,
7514
7494
  args: [{ name: "meeting-ref", required: true, description: "Meeting reference" }],
7515
7495
  options: [
7516
- { flags: "--yes, -y", description: "Skip confirmation prompt" }
7496
+ { flags: "--yes -y", description: "Skip confirmation prompt" }
7517
7497
  ],
7518
7498
  handler: async (ctx) => {
7519
7499
  const meetingRef = ctx.positional[0];
@@ -7886,7 +7866,7 @@ var init_governance = __esm({
7886
7866
  },
7887
7867
  {
7888
7868
  name: "governance-bodies create",
7889
- description: "List all governance bodies",
7869
+ description: "Create a governance body",
7890
7870
  route: { method: "POST", path: "/v1/governance-bodies" },
7891
7871
  options: [
7892
7872
  { flags: "--body-type <body-type>", description: "The type of governance body.", required: true, choices: ["board_of_directors", "llc_member_vote"] },
@@ -7895,7 +7875,7 @@ var init_governance = __esm({
7895
7875
  { flags: "--voting-method <voting-method>", description: "How votes are counted.", required: true, choices: ["per_capita", "per_unit"] }
7896
7876
  ],
7897
7877
  examples: ["corp governance-bodies --body-type board_of_directors --name majority --quorum-rule majority --voting-method per_capita"],
7898
- successTemplate: "Governance Bodies created"
7878
+ successTemplate: "Governance body created"
7899
7879
  },
7900
7880
  {
7901
7881
  name: "governance-seats scan-expired",
@@ -7903,7 +7883,7 @@ var init_governance = __esm({
7903
7883
  route: { method: "POST", path: "/v1/governance-seats/scan-expired" },
7904
7884
  entity: true,
7905
7885
  examples: ["corp governance-seats scan-expired"],
7906
- successTemplate: "Scan Expired created"
7886
+ successTemplate: "Expired seats scanned"
7907
7887
  },
7908
7888
  {
7909
7889
  name: "governance-seats resign",
@@ -7912,7 +7892,7 @@ var init_governance = __esm({
7912
7892
  entity: true,
7913
7893
  args: [{ name: "seat-id", required: true, description: "Governance seat ID" }],
7914
7894
  examples: ["corp governance-seats resign <seat-id>"],
7915
- successTemplate: "Resign created"
7895
+ successTemplate: "Seat resigned"
7916
7896
  },
7917
7897
  {
7918
7898
  name: "governance audit-checkpoints",
@@ -8003,7 +7983,7 @@ var init_governance = __esm({
8003
7983
  { flags: "--metadata <metadata>", description: "Additional metadata (JSON)" }
8004
7984
  ],
8005
7985
  examples: ["corp governance evaluate --intent-type 'intent-type'", "corp governance evaluate --json"],
8006
- successTemplate: "Evaluate created"
7986
+ successTemplate: "Governance evaluated"
8007
7987
  },
8008
7988
  {
8009
7989
  name: "governance report-incident",
@@ -8155,12 +8135,10 @@ var init_documents = __esm({
8155
8135
  try {
8156
8136
  resolvedDocumentId = await ctx.resolver.resolveDocument(eid, docRef);
8157
8137
  } catch {
8158
- printError(
8138
+ throw new Error(
8159
8139
  `Could not resolve '${docRef}' as a document. If you just generated a contract, use the document_id from the generate output, not @last (which may reference the contract_id).
8160
8140
  List documents with: corp documents`
8161
8141
  );
8162
- process.exit(1);
8163
- return;
8164
8142
  }
8165
8143
  const result = await ctx.client.getSigningLink(resolvedDocumentId, eid);
8166
8144
  const shareUrl = formatSigningLink(resolvedDocumentId, result);
@@ -8307,7 +8285,7 @@ var init_documents = __esm({
8307
8285
  } catch (err) {
8308
8286
  const msg = String(err);
8309
8287
  if (template === "employment_offer" && (msg.includes("base_salary") || msg.includes("required"))) {
8310
- printError(
8288
+ throw new Error(
8311
8289
  `Failed to generate employment_offer: ${msg}
8312
8290
  Hint: employment_offer requires base_salary. Use:
8313
8291
  --base-salary 150000
@@ -8316,16 +8294,15 @@ var init_documents = __esm({
8316
8294
  bonus_terms, equity_terms, benefits_summary, governing_law`
8317
8295
  );
8318
8296
  } else if (template === "safe_agreement" && (msg.includes("purchase_amount") || msg.includes("investment_amount") || msg.includes("valuation_cap") || msg.includes("investor_notice") || msg.includes("required"))) {
8319
- printError(
8297
+ throw new Error(
8320
8298
  `Failed to generate safe_agreement: ${msg}
8321
8299
  Hint: safe_agreement requires purchase_amount, valuation_cap, and investor_notice_address. Use:
8322
8300
  --param purchase_amount=50000000 --param valuation_cap=10000000
8323
8301
  --param investor_notice_address="123 Main St, City, ST 12345"`
8324
8302
  );
8325
8303
  } else {
8326
- printError(`Failed to generate contract: ${err}`);
8304
+ throw new Error(`Failed to generate contract: ${err}`);
8327
8305
  }
8328
- process.exit(1);
8329
8306
  }
8330
8307
  },
8331
8308
  produces: { kind: "document" },
@@ -8345,8 +8322,7 @@ var init_documents = __esm({
8345
8322
  handler: async (ctx) => {
8346
8323
  const documentId = ctx.opts.definitionId ?? ctx.opts.documentId;
8347
8324
  if (!documentId || documentId.trim().length === 0) {
8348
- printError("preview-pdf requires --definition-id (or deprecated alias --document-id)");
8349
- process.exit(1);
8325
+ throw new Error("preview-pdf requires --definition-id (or deprecated alias --document-id)");
8350
8326
  }
8351
8327
  const eid = await ctx.resolver.resolveEntity(ctx.opts.entityId);
8352
8328
  await ctx.client.validatePreviewPdf(eid, documentId);
@@ -8426,7 +8402,7 @@ var init_compliance = __esm({
8426
8402
  // --- tax filings ---
8427
8403
  {
8428
8404
  name: "tax filings",
8429
- description: "Create a tax filing record",
8405
+ description: "List tax filing records",
8430
8406
  route: { method: "GET", path: "/v1/entities/{eid}/tax-filings" },
8431
8407
  entity: true,
8432
8408
  display: {
@@ -8487,7 +8463,10 @@ var init_compliance = __esm({
8487
8463
  },
8488
8464
  produces: { kind: "tax_filing" },
8489
8465
  successTemplate: "Tax filing created",
8490
- examples: ["corp tax file --year 'year'"]
8466
+ examples: [
8467
+ "corp tax file --type 1120 --year 2025",
8468
+ "corp tax file --type 83b --year 2025 --filer-contact-id @last:contact"
8469
+ ]
8491
8470
  },
8492
8471
  // --- tax deadlines ---
8493
8472
  {
@@ -8551,15 +8530,21 @@ var init_compliance = __esm({
8551
8530
  },
8552
8531
  produces: { kind: "deadline" },
8553
8532
  successTemplate: "Deadline tracked",
8554
- examples: ["corp tax deadline --type 'type' --due-date 'date' --description 'desc'", "corp tax deadline --json"]
8533
+ examples: [
8534
+ 'corp tax deadline --type annual_report --due-date 2026-03-31 --description "Delaware annual report due"',
8535
+ 'corp tax deadline --type annual_report --due-date 2026-03-31 --description "Delaware annual report" --recurrence annual'
8536
+ ]
8555
8537
  },
8556
8538
  // ── Auto-generated from OpenAPI ──────────────────────────────
8557
8539
  {
8558
8540
  name: "compliance escalations-scan",
8559
8541
  description: "Scan for compliance issues and create escalations",
8560
8542
  route: { method: "POST", path: "/v1/compliance/escalations/scan" },
8561
- examples: ["corp compliance escalations-scan"],
8562
- successTemplate: "Escalations Scan created"
8543
+ examples: [
8544
+ "corp compliance escalations-scan",
8545
+ "corp compliance escalations-scan --json"
8546
+ ],
8547
+ successTemplate: "Escalation scan complete"
8563
8548
  },
8564
8549
  {
8565
8550
  name: "compliance escalations-resolve-with-evidence",
@@ -8574,7 +8559,10 @@ var init_compliance = __esm({
8574
8559
  { flags: "--resolve-incident", description: "Resolve Incident" },
8575
8560
  { flags: "--resolve-obligation", description: "Resolve Obligation" }
8576
8561
  ],
8577
- examples: ["corp compliance escalations-resolve-with-evidence <escalation-id>", "corp compliance escalations-resolve-with-evidence --json"],
8562
+ examples: [
8563
+ "corp compliance escalations-resolve-with-evidence esc_01hx9k3n2p4q7r8s9t0uvwxyz --evidence-type filing --filing-reference DE-2026-0042",
8564
+ 'corp compliance escalations-resolve-with-evidence esc_01hx9k3n2p4q7r8s9t0uvwxyz --resolve-incident --notes "Filed on time"'
8565
+ ],
8578
8566
  successTemplate: "Escalations Resolve With Evidence created"
8579
8567
  },
8580
8568
  {
@@ -8591,7 +8579,10 @@ var init_compliance = __esm({
8591
8579
  { flags: "--provides-tools <provides-tools>", description: "Provides Tools" },
8592
8580
  { flags: "--state <state>", description: "State" }
8593
8581
  ],
8594
- examples: ["corp contractors classify --contractor-name 'contractor-name'", "corp contractors classify --json"],
8582
+ examples: [
8583
+ 'corp contractors classify --contractor-name "Jane Doe" --state CA --hours-per-week 20',
8584
+ 'corp contractors classify --contractor-name "Acme Services LLC" --duration-months 6 --exclusive-client false'
8585
+ ],
8595
8586
  successTemplate: "Classify created"
8596
8587
  },
8597
8588
  {
@@ -8605,7 +8596,10 @@ var init_compliance = __esm({
8605
8596
  { flags: "--recurrence <recurrence>", description: "Recurrence pattern for a deadline.", choices: ["one_time", "monthly", "quarterly", "annual"] },
8606
8597
  { flags: "--severity <severity>", description: "Risk severity of missing a deadline.", choices: ["low", "medium", "high", "critical"] }
8607
8598
  ],
8608
- examples: ["corp deadlines --deadline-type 'deadline-type' --description 'description' --due-date one_time", "corp deadlines --json"],
8599
+ examples: [
8600
+ 'corp deadlines --deadline-type annual_report --description "Delaware annual report" --due-date 2026-03-31 --recurrence annual',
8601
+ 'corp deadlines --deadline-type tax_filing --description "Q1 estimated taxes" --due-date 2026-04-15 --severity high'
8602
+ ],
8609
8603
  successTemplate: "Deadlines created"
8610
8604
  },
8611
8605
  {
@@ -8625,7 +8619,10 @@ var init_compliance = __esm({
8625
8619
  { flags: "--document-type <document-type>", description: "Type of document required", required: true },
8626
8620
  { flags: "--tax-year <tax-year>", description: "Tax Year", required: true, type: "int" }
8627
8621
  ],
8628
- examples: ["corp tax filings --document-type 'document-type' --tax-year 'tax-year'"],
8622
+ examples: [
8623
+ "corp tax create-filing --document-type 1120 --tax-year 2025",
8624
+ "corp tax create-filing --document-type 1065 --tax-year 2025 --json"
8625
+ ],
8629
8626
  successTemplate: "Filings created"
8630
8627
  }
8631
8628
  ];
@@ -8729,7 +8726,10 @@ var init_agents = __esm({
8729
8726
  }
8730
8727
  console.log(chalk9.magenta("\u2500".repeat(40)));
8731
8728
  },
8732
- examples: ["corp agents show"]
8729
+ examples: [
8730
+ "corp agents show @last:agent",
8731
+ "corp agents show agt_01hx9k3n2p4q7r8s9t0uvwxyz"
8732
+ ]
8733
8733
  },
8734
8734
  // --- agents create ---
8735
8735
  {
@@ -8759,19 +8759,21 @@ var init_agents = __esm({
8759
8759
  } catch (err) {
8760
8760
  const msg = String(err);
8761
8761
  if (msg.includes("409") || msg.includes("conflict") || msg.includes("already exists")) {
8762
- printError(
8762
+ throw new Error(
8763
8763
  `Agent name '${ctx.opts.name}' is already in use (deleted agents still reserve their name).
8764
8764
  Choose a different name, e.g.: corp agents create --name '...-v2' --prompt '...'`
8765
8765
  );
8766
8766
  } else {
8767
- printError(`Failed to create agent: ${err}`);
8767
+ throw new Error(`Failed to create agent: ${err}`);
8768
8768
  }
8769
- process.exit(1);
8770
8769
  }
8771
8770
  },
8772
8771
  produces: { kind: "agent" },
8773
8772
  successTemplate: "Agent created: {name}",
8774
- examples: ["corp agents create --name 'name' --prompt 'prompt'", "corp agents create --json"]
8773
+ examples: [
8774
+ 'corp agents create --name "bookkeeper" --prompt "You manage accounts payable for the company"',
8775
+ 'corp agents create --name "compliance-monitor" --prompt "You monitor regulatory deadlines" --model gpt-4o'
8776
+ ]
8775
8777
  },
8776
8778
  // --- agents pause <agent-ref> ---
8777
8779
  {
@@ -8785,7 +8787,10 @@ var init_agents = __esm({
8785
8787
  const result = await ctx.client.updateAgent(resolvedAgentId, { status: "paused" });
8786
8788
  ctx.writer.writeResult(result, `Agent ${resolvedAgentId} paused.`, { jsonOnly: ctx.opts.json });
8787
8789
  },
8788
- examples: ["corp agents pause <agent-ref>"]
8790
+ examples: [
8791
+ "corp agents pause @last:agent",
8792
+ "corp agents pause agt_01hx9k3n2p4q7r8s9t0uvwxyz"
8793
+ ]
8789
8794
  },
8790
8795
  // --- agents resume <agent-ref> ---
8791
8796
  {
@@ -8802,18 +8807,20 @@ var init_agents = __esm({
8802
8807
  } catch (err) {
8803
8808
  const msg = String(err);
8804
8809
  if (msg.includes("409") || msg.includes("disabled") || msg.includes("deleted")) {
8805
- printError(
8810
+ throw new Error(
8806
8811
  `Cannot resume agent ${agentRef}: the agent may be disabled or deleted.
8807
8812
  Disabled/deleted agents cannot be resumed. Create a new agent instead:
8808
8813
  corp agents create --name '...' --prompt '...'`
8809
8814
  );
8810
8815
  } else {
8811
- printError(`Failed to resume agent: ${err}`);
8816
+ throw new Error(`Failed to resume agent: ${err}`);
8812
8817
  }
8813
- process.exit(1);
8814
8818
  }
8815
8819
  },
8816
- examples: ["corp agents resume <agent-ref>"]
8820
+ examples: [
8821
+ "corp agents resume @last:agent",
8822
+ "corp agents resume agt_01hx9k3n2p4q7r8s9t0uvwxyz"
8823
+ ]
8817
8824
  },
8818
8825
  // --- agents delete <agent-ref> ---
8819
8826
  {
@@ -8822,7 +8829,7 @@ var init_agents = __esm({
8822
8829
  route: { method: "DELETE", path: "/v1/agents/{pos}" },
8823
8830
  args: [{ name: "agent-ref", required: true, description: "Agent reference" }],
8824
8831
  options: [
8825
- { flags: "--yes, -y", description: "Skip confirmation prompt" }
8832
+ { flags: "--yes -y", description: "Skip confirmation prompt" }
8826
8833
  ],
8827
8834
  handler: async (ctx) => {
8828
8835
  const agentRef = ctx.positional[0];
@@ -8840,7 +8847,10 @@ var init_agents = __esm({
8840
8847
  const result = await ctx.client.deleteAgent(resolvedAgentId);
8841
8848
  ctx.writer.writeResult(result, `Agent ${resolvedAgentId} deleted.`, { jsonOnly: ctx.opts.json });
8842
8849
  },
8843
- examples: ["corp agents delete <agent-ref>", "corp agents delete --json"]
8850
+ examples: [
8851
+ "corp agents delete @last:agent",
8852
+ "corp agents delete agt_01hx9k3n2p4q7r8s9t0uvwxyz --yes"
8853
+ ]
8844
8854
  },
8845
8855
  // --- agents message <agent-ref> ---
8846
8856
  {
@@ -8862,17 +8872,19 @@ var init_agents = __esm({
8862
8872
  } catch (err) {
8863
8873
  const msg = String(err);
8864
8874
  if (msg.includes("409")) {
8865
- printError(
8875
+ throw new Error(
8866
8876
  `Cannot message agent: the agent must be active or paused (not disabled/deleted).
8867
8877
  Check agent status: corp agents show ` + agentRef + "\n Resume a paused agent: corp agents resume " + agentRef
8868
8878
  );
8869
8879
  } else {
8870
- printError(`Failed to send message: ${err}`);
8880
+ throw new Error(`Failed to send message: ${err}`);
8871
8881
  }
8872
- process.exit(1);
8873
8882
  }
8874
8883
  },
8875
- examples: ["corp agents message <agent-ref>", "corp agents message --json"]
8884
+ examples: [
8885
+ `corp agents message @last:agent --body "Process this month's invoices"`,
8886
+ "corp agents message agt_01hx9k3n2p4q7r8s9t0uvwxyz --body-file ./task.txt"
8887
+ ]
8876
8888
  },
8877
8889
  // --- agents skill <agent-ref> ---
8878
8890
  {
@@ -8901,7 +8913,10 @@ var init_agents = __esm({
8901
8913
  });
8902
8914
  ctx.writer.writeResult(result, `Skill '${ctx.opts.name}' added to agent ${resolvedAgentId}.`, { jsonOnly: ctx.opts.json });
8903
8915
  },
8904
- examples: ["corp agents skill <agent-ref> --name 'name' --description 'desc'", "corp agents skill --json"]
8916
+ examples: [
8917
+ 'corp agents skill @last:agent --name invoice-processing --description "Process AP invoices from email"',
8918
+ 'corp agents skill agt_01hx9k3n2p4q7r8s9t0uvwxyz --name bookkeeping --description "Reconcile ledger entries" --instructions-file ./skills/bookkeeping.txt'
8919
+ ]
8905
8920
  },
8906
8921
  // --- agents execution <agent-ref> <execution-id> ---
8907
8922
  {
@@ -8932,7 +8947,10 @@ var init_agents = __esm({
8932
8947
  if (result.completed_at) console.log(` ${chalk9.bold("Completed:")} ${result.completed_at}`);
8933
8948
  console.log(chalk9.magenta("\u2500".repeat(40)));
8934
8949
  },
8935
- examples: ["corp agents execution"]
8950
+ examples: [
8951
+ "corp agents execution @last:agent exc_01hx9k3n2p4q7r8s9t0uvwxyz",
8952
+ "corp agents execution agt_01hx9k3n2p4q7r8s9t0uvwxyz exc_01hx9k3n2p4q7r8s9t0uvwxyz"
8953
+ ]
8936
8954
  },
8937
8955
  // --- agents execution-result <agent-ref> <execution-id> ---
8938
8956
  {
@@ -8956,7 +8974,10 @@ var init_agents = __esm({
8956
8974
  ctx.writer.success(`Result for execution ${executionId}:`);
8957
8975
  printJson(result);
8958
8976
  },
8959
- examples: ["corp agents execution-result"]
8977
+ examples: [
8978
+ "corp agents execution-result @last:agent exc_01hx9k3n2p4q7r8s9t0uvwxyz",
8979
+ "corp agents execution-result @last:agent exc_01hx9k3n2p4q7r8s9t0uvwxyz --json"
8980
+ ]
8960
8981
  },
8961
8982
  // --- agents kill <agent-ref> <execution-id> ---
8962
8983
  {
@@ -8984,7 +9005,10 @@ var init_agents = __esm({
8984
9005
  const result = await ctx.client.killAgentExecution(resolvedAgentId, executionId);
8985
9006
  ctx.writer.writeResult(result, `Execution ${executionId} killed.`, { jsonOnly: ctx.opts.json });
8986
9007
  },
8987
- examples: ["corp agents kill <agent-ref> <execution-id>", "corp agents kill --json"]
9008
+ examples: [
9009
+ "corp agents kill @last:agent exc_01hx9k3n2p4q7r8s9t0uvwxyz",
9010
+ "corp agents kill @last:agent exc_01hx9k3n2p4q7r8s9t0uvwxyz --yes"
9011
+ ]
8988
9012
  },
8989
9013
  // ── Auto-generated from OpenAPI ──────────────────────────────
8990
9014
  {
@@ -8993,7 +9017,10 @@ var init_agents = __esm({
8993
9017
  route: { method: "GET", path: "/v1/agents/{pos}/executions/{pos2}/logs" },
8994
9018
  args: [{ name: "agent-id", required: true, description: "Agent ID", posKind: "agent" }, { name: "execution-id", required: true, description: "Agent execution ID" }],
8995
9019
  display: { title: "Execution Logs", cols: ["@timestamp>Time", "level>Level", "message>Message"] },
8996
- examples: ["corp agents executions-logs"]
9020
+ examples: [
9021
+ "corp agents executions-logs @last:agent exc_01hx9k3n2p4q7r8s9t0uvwxyz",
9022
+ "corp agents executions-logs agt_01hx9k3n2p4q7r8s9t0uvwxyz exc_01hx9k3n2p4q7r8s9t0uvwxyz --json"
9023
+ ]
8997
9024
  },
8998
9025
  // ── Auto-generated from OpenAPI ──────────────────────────────
8999
9026
  {
@@ -9002,7 +9029,10 @@ var init_agents = __esm({
9002
9029
  route: { method: "GET", path: "/v1/agents/{pos}/messages/{pos2}" },
9003
9030
  args: [{ name: "agent-id", required: true, description: "Agent ID", posKind: "agent" }, { name: "message-id", required: true, description: "Message Id" }],
9004
9031
  display: { title: "Agent Message" },
9005
- examples: ["corp agents messages"]
9032
+ examples: [
9033
+ "corp agents messages @last:agent msg_01hx9k3n2p4q7r8s9t0uvwxyz",
9034
+ "corp agents messages @last:agent msg_01hx9k3n2p4q7r8s9t0uvwxyz --json"
9035
+ ]
9006
9036
  }
9007
9037
  ];
9008
9038
  }
@@ -9129,8 +9159,7 @@ var init_work_items = __esm({
9129
9159
  const eid = await ctx.resolver.resolveEntity(ctx.opts.entityId);
9130
9160
  const category = ctx.opts.category;
9131
9161
  if (!category) {
9132
- printError("required option '--category <category>' not specified");
9133
- process.exit(1);
9162
+ throw new Error("required option '--category <category>' not specified");
9134
9163
  }
9135
9164
  const data = { title: ctx.opts.title, category };
9136
9165
  if (ctx.opts.description) data.description = ctx.opts.description;
@@ -9168,8 +9197,7 @@ var init_work_items = __esm({
9168
9197
  const resolvedWorkItemId = await ctx.resolver.resolveWorkItem(eid, itemRef);
9169
9198
  const claimedBy = ctx.opts.by ?? ctx.opts.claimer;
9170
9199
  if (!claimedBy) {
9171
- printError("required option '--by <name>' not specified");
9172
- process.exit(1);
9200
+ throw new Error("required option '--by <name>' not specified");
9173
9201
  }
9174
9202
  const data = {
9175
9203
  claimed_by_actor: await ctx.resolver.resolveWorkItemActor(eid, claimedBy)
@@ -9199,8 +9227,7 @@ var init_work_items = __esm({
9199
9227
  const resolvedWorkItemId = await ctx.resolver.resolveWorkItem(eid, itemRef);
9200
9228
  const completedBy = ctx.opts.by ?? ctx.opts.completedBy;
9201
9229
  if (!completedBy) {
9202
- printError("required option '--by <name>' not specified");
9203
- process.exit(1);
9230
+ throw new Error("required option '--by <name>' not specified");
9204
9231
  }
9205
9232
  const data = {
9206
9233
  completed_by_actor: await ctx.resolver.resolveWorkItemActor(eid, completedBy)
@@ -9236,7 +9263,7 @@ var init_work_items = __esm({
9236
9263
  entity: true,
9237
9264
  args: [{ name: "item-ref", required: true, description: "Work item reference" }],
9238
9265
  options: [
9239
- { flags: "--yes, -y", description: "Skip confirmation prompt" }
9266
+ { flags: "--yes -y", description: "Skip confirmation prompt" }
9240
9267
  ],
9241
9268
  handler: async (ctx) => {
9242
9269
  const itemRef = ctx.positional[0];
@@ -9289,25 +9316,6 @@ var init_services = __esm({
9289
9316
  },
9290
9317
  examples: ["corp services", "corp services --json"]
9291
9318
  },
9292
- // --- services catalog ---
9293
- {
9294
- name: "services catalog",
9295
- description: "List the service catalog",
9296
- route: { method: "GET", path: "/v1/services/catalog" },
9297
- display: {
9298
- title: "Service Catalog",
9299
- cols: ["name>Name", "slug>Slug", "$price_cents>Price", "#service_id|id>ID"]
9300
- },
9301
- handler: async (ctx) => {
9302
- const items = await ctx.client.listServiceCatalog();
9303
- if (ctx.opts.json) {
9304
- ctx.writer.json(items);
9305
- return;
9306
- }
9307
- printServiceCatalogTable(items);
9308
- },
9309
- examples: ["corp services catalog"]
9310
- },
9311
9319
  // --- services list ---
9312
9320
  {
9313
9321
  name: "services list",
@@ -9470,7 +9478,7 @@ var init_services = __esm({
9470
9478
  },
9471
9479
  {
9472
9480
  name: "services requests",
9473
- description: "Submit a new service request",
9481
+ description: "View a service request by ID",
9474
9482
  route: { method: "GET", path: "/v1/services/requests/{pos}" },
9475
9483
  entity: true,
9476
9484
  args: [{ name: "request-id", required: true, description: "Document request ID", posKind: "service_request" }],
@@ -9483,7 +9491,7 @@ var init_services = __esm({
9483
9491
  route: { method: "POST", path: "/v1/services/requests/{pos}/cancel" },
9484
9492
  args: [{ name: "request-id", required: true, description: "Document request ID", posKind: "service_request" }],
9485
9493
  examples: ["corp services requests-cancel <request-id>"],
9486
- successTemplate: "Requests Cancel created"
9494
+ successTemplate: "Request cancelled"
9487
9495
  },
9488
9496
  {
9489
9497
  name: "services requests-checkout",
@@ -9491,7 +9499,7 @@ var init_services = __esm({
9491
9499
  route: { method: "POST", path: "/v1/services/requests/{pos}/checkout" },
9492
9500
  args: [{ name: "request-id", required: true, description: "Document request ID", posKind: "service_request" }],
9493
9501
  examples: ["corp services requests-checkout <request-id>"],
9494
- successTemplate: "Requests Checkout created"
9502
+ successTemplate: "Checkout started"
9495
9503
  },
9496
9504
  {
9497
9505
  name: "services requests-fulfill",
@@ -9822,7 +9830,7 @@ async function serveCommand(opts) {
9822
9830
  process.exit(1);
9823
9831
  }
9824
9832
  const port = parseInt(opts.port, 10);
9825
- if (isNaN(port) || port > 65535) {
9833
+ if (isNaN(port) || port < 1 || port > 65535) {
9826
9834
  console.error(`Error: Invalid port "${opts.port}"`);
9827
9835
  process.exit(1);
9828
9836
  }
@@ -10096,7 +10104,7 @@ async function demoCommand(opts) {
10096
10104
  entity_id: entityId,
10097
10105
  template_type: "nda",
10098
10106
  counterparty_name: "Example Counterparty",
10099
- effective_date: "2026-03-12",
10107
+ effective_date: (/* @__PURE__ */ new Date()).toISOString().slice(0, 10),
10100
10108
  parameters: {}
10101
10109
  });
10102
10110
  await resolver.stabilizeRecord("document", contract, entityId);
@@ -10615,6 +10623,66 @@ var init_feedback = __esm({
10615
10623
  }
10616
10624
  });
10617
10625
 
10626
+ // src/resource-kinds.ts
10627
+ var KINDS, ENTITY_SCOPED_KINDS;
10628
+ var init_resource_kinds = __esm({
10629
+ "src/resource-kinds.ts"() {
10630
+ "use strict";
10631
+ KINDS = /* @__PURE__ */ new Set([
10632
+ "entity",
10633
+ "contact",
10634
+ "share_transfer",
10635
+ "invoice",
10636
+ "bank_account",
10637
+ "payment",
10638
+ "payroll_run",
10639
+ "distribution",
10640
+ "reconciliation",
10641
+ "tax_filing",
10642
+ "deadline",
10643
+ "classification",
10644
+ "body",
10645
+ "meeting",
10646
+ "seat",
10647
+ "agenda_item",
10648
+ "resolution",
10649
+ "document",
10650
+ "work_item",
10651
+ "agent",
10652
+ "valuation",
10653
+ "safe_note",
10654
+ "instrument",
10655
+ "share_class",
10656
+ "round"
10657
+ ]);
10658
+ ENTITY_SCOPED_KINDS = /* @__PURE__ */ new Set([
10659
+ "contact",
10660
+ "share_transfer",
10661
+ "invoice",
10662
+ "bank_account",
10663
+ "payment",
10664
+ "payroll_run",
10665
+ "distribution",
10666
+ "reconciliation",
10667
+ "tax_filing",
10668
+ "deadline",
10669
+ "classification",
10670
+ "body",
10671
+ "meeting",
10672
+ "seat",
10673
+ "agenda_item",
10674
+ "resolution",
10675
+ "document",
10676
+ "work_item",
10677
+ "valuation",
10678
+ "safe_note",
10679
+ "instrument",
10680
+ "share_class",
10681
+ "round"
10682
+ ]);
10683
+ }
10684
+ });
10685
+
10618
10686
  // src/commands/resolve.ts
10619
10687
  var resolve_exports = {};
10620
10688
  __export(resolve_exports, {
@@ -10721,7 +10789,7 @@ async function resolveCommand(kind, ref, opts) {
10721
10789
  kind: normalizedKind,
10722
10790
  input: ref,
10723
10791
  resolved_id: resolvedId,
10724
- short_id: shortId2(resolvedId),
10792
+ short_id: shortId(resolvedId),
10725
10793
  ...entityId ? { entity_id: entityId } : {},
10726
10794
  ...bodyId ? { body_id: bodyId } : {},
10727
10795
  ...meetingId ? { meeting_id: meetingId } : {}
@@ -10743,7 +10811,6 @@ function requiredMeeting(meetingId, kind) {
10743
10811
  }
10744
10812
  return meetingId;
10745
10813
  }
10746
- var KINDS, ENTITY_SCOPED_KINDS;
10747
10814
  var init_resolve = __esm({
10748
10815
  "src/commands/resolve.ts"() {
10749
10816
  "use strict";
@@ -10751,58 +10818,7 @@ var init_resolve = __esm({
10751
10818
  init_api_client();
10752
10819
  init_output();
10753
10820
  init_references();
10754
- KINDS = /* @__PURE__ */ new Set([
10755
- "entity",
10756
- "contact",
10757
- "share_transfer",
10758
- "invoice",
10759
- "bank_account",
10760
- "payment",
10761
- "payroll_run",
10762
- "distribution",
10763
- "reconciliation",
10764
- "tax_filing",
10765
- "deadline",
10766
- "classification",
10767
- "body",
10768
- "meeting",
10769
- "seat",
10770
- "agenda_item",
10771
- "resolution",
10772
- "document",
10773
- "work_item",
10774
- "agent",
10775
- "valuation",
10776
- "safe_note",
10777
- "instrument",
10778
- "share_class",
10779
- "round"
10780
- ]);
10781
- ENTITY_SCOPED_KINDS = /* @__PURE__ */ new Set([
10782
- "contact",
10783
- "share_transfer",
10784
- "invoice",
10785
- "bank_account",
10786
- "payment",
10787
- "payroll_run",
10788
- "distribution",
10789
- "reconciliation",
10790
- "tax_filing",
10791
- "deadline",
10792
- "classification",
10793
- "body",
10794
- "meeting",
10795
- "seat",
10796
- "agenda_item",
10797
- "resolution",
10798
- "document",
10799
- "work_item",
10800
- "valuation",
10801
- "safe_note",
10802
- "instrument",
10803
- "share_class",
10804
- "round"
10805
- ]);
10821
+ init_resource_kinds();
10806
10822
  }
10807
10823
  });
10808
10824
 
@@ -10815,7 +10831,7 @@ import chalk14 from "chalk";
10815
10831
  import Table5 from "cli-table3";
10816
10832
  async function findCommand(kind, query, opts) {
10817
10833
  const normalizedKind = kind.trim().toLowerCase();
10818
- if (!KINDS2.has(normalizedKind)) {
10834
+ if (!KINDS.has(normalizedKind)) {
10819
10835
  printError(`Unsupported find kind: ${kind}`);
10820
10836
  process.exit(1);
10821
10837
  }
@@ -10823,7 +10839,7 @@ async function findCommand(kind, query, opts) {
10823
10839
  const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
10824
10840
  const resolver = new ReferenceResolver(client, cfg);
10825
10841
  try {
10826
- const entityId = ENTITY_SCOPED_KINDS2.has(normalizedKind) || opts.entityId || opts.bodyId || opts.meetingId ? await resolver.resolveEntity(opts.entityId) : void 0;
10842
+ const entityId = ENTITY_SCOPED_KINDS.has(normalizedKind) || opts.entityId || opts.bodyId || opts.meetingId ? await resolver.resolveEntity(opts.entityId) : void 0;
10827
10843
  const bodyId = entityId && opts.bodyId ? await resolver.resolveBody(entityId, opts.bodyId) : void 0;
10828
10844
  const meetingId = entityId && opts.meetingId ? await resolver.resolveMeeting(entityId, opts.meetingId, bodyId) : void 0;
10829
10845
  const matches = await resolver.find(normalizedKind, query, { entityId, bodyId, meetingId });
@@ -10870,7 +10886,6 @@ async function findCommand(kind, query, opts) {
10870
10886
  process.exit(1);
10871
10887
  }
10872
10888
  }
10873
- var KINDS2, ENTITY_SCOPED_KINDS2;
10874
10889
  var init_find = __esm({
10875
10890
  "src/commands/find.ts"() {
10876
10891
  "use strict";
@@ -10878,58 +10893,7 @@ var init_find = __esm({
10878
10893
  init_api_client();
10879
10894
  init_output();
10880
10895
  init_references();
10881
- KINDS2 = /* @__PURE__ */ new Set([
10882
- "entity",
10883
- "contact",
10884
- "share_transfer",
10885
- "invoice",
10886
- "bank_account",
10887
- "payment",
10888
- "payroll_run",
10889
- "distribution",
10890
- "reconciliation",
10891
- "tax_filing",
10892
- "deadline",
10893
- "classification",
10894
- "body",
10895
- "meeting",
10896
- "seat",
10897
- "agenda_item",
10898
- "resolution",
10899
- "document",
10900
- "work_item",
10901
- "agent",
10902
- "valuation",
10903
- "safe_note",
10904
- "instrument",
10905
- "share_class",
10906
- "round"
10907
- ]);
10908
- ENTITY_SCOPED_KINDS2 = /* @__PURE__ */ new Set([
10909
- "contact",
10910
- "share_transfer",
10911
- "invoice",
10912
- "bank_account",
10913
- "payment",
10914
- "payroll_run",
10915
- "distribution",
10916
- "reconciliation",
10917
- "tax_filing",
10918
- "deadline",
10919
- "classification",
10920
- "body",
10921
- "meeting",
10922
- "seat",
10923
- "agenda_item",
10924
- "resolution",
10925
- "document",
10926
- "work_item",
10927
- "valuation",
10928
- "safe_note",
10929
- "instrument",
10930
- "share_class",
10931
- "round"
10932
- ]);
10896
+ init_resource_kinds();
10933
10897
  }
10934
10898
  });
10935
10899
 
@@ -11273,7 +11237,7 @@ var init_admin = __esm({
11273
11237
  process.stderr.write(
11274
11238
  'Approvals are managed through governance meetings and execution intents.\nUse these commands to manage approvals:\n\n Board approval via meeting vote:\n corp governance convene --body <body> --type board_meeting --title "Approve X"\n corp governance vote <meeting> <item> --voter <contact> --vote for\n\n Written consent (no meeting needed):\n corp governance written-consent --body <body> --title "Approve X" --description "..."\n\n View pending items:\n corp governance meetings <body> # see scheduled meetings\n corp governance agenda-items <meeting> # see items awaiting votes\n corp cap-table valuations # see pending valuations\n'
11275
11239
  );
11276
- process.exit(1);
11240
+ process.exit(0);
11277
11241
  },
11278
11242
  examples: ["corp approvals"]
11279
11243
  },
@@ -11401,7 +11365,7 @@ var init_admin = __esm({
11401
11365
  { flags: "--ttl-seconds <ttl-seconds>", description: "Token TTL in seconds (60-86400)", type: "int" }
11402
11366
  ],
11403
11367
  examples: ["corp auth token-exchange --api-key 'api-key'", "corp auth token-exchange --json"],
11404
- successTemplate: "Token Exchange created"
11368
+ successTemplate: "Token exchanged"
11405
11369
  },
11406
11370
  {
11407
11371
  name: "ssh-keys",
@@ -11453,7 +11417,7 @@ var init_admin = __esm({
11453
11417
  { flags: "--kind <kind>", description: "Resource kind", required: true, choices: ["entity", "contact", "share_transfer", "invoice", "bank_account", "payment", "payroll_run", "distribution", "reconciliation", "tax_filing", "deadline", "classification", "body", "meeting", "seat", "agenda_item", "resolution", "document", "work_item", "agent", "valuation", "safe_note", "instrument", "share_class", "round"] }
11454
11418
  ],
11455
11419
  examples: ["corp references sync --items 'items' --kind 'kind'"],
11456
- successTemplate: "Sync created"
11420
+ successTemplate: "References synced"
11457
11421
  },
11458
11422
  // ── Auto-generated from OpenAPI ──────────────────────────────
11459
11423
  {
@@ -11576,7 +11540,10 @@ var init_execution = __esm({
11576
11540
  { flags: "--max-amount-cents <max-amount-cents>", description: "Maximum authorized amount in cents" },
11577
11541
  { flags: "--scope <scope>", description: "Authorization scope", required: true }
11578
11542
  ],
11579
- examples: ["corp execution approval-artifacts --approver-identity 'approver-identity' --channel 'channel' --intent-type 'intent-type' --scope 'scope'", "corp execution approval-artifacts --json"],
11543
+ examples: [
11544
+ 'corp execution approval-artifacts --approver-identity "alice@acme.com" --channel board_vote --intent-type equity_grant --scope entity',
11545
+ 'corp execution approval-artifacts --approver-identity "alice@acme.com" --channel written_consent --intent-type equity_grant --scope entity --approved-at 2026-03-01T00:00:00Z'
11546
+ ],
11580
11547
  successTemplate: "Approval Artifacts created"
11581
11548
  },
11582
11549
  {
@@ -11590,7 +11557,10 @@ var init_execution = __esm({
11590
11557
  { flags: "--intent-type <intent-type>", description: "Type of intent", required: true },
11591
11558
  { flags: "--metadata <metadata>", description: "Additional metadata (JSON)" }
11592
11559
  ],
11593
- examples: ["corp execution intents --description 'description' --intent-type 'intent-type'", "corp execution intents --json"],
11560
+ examples: [
11561
+ 'corp execution intents --description "Issue 10,000 options to Alice" --intent-type equity_grant --authority-tier tier_2',
11562
+ 'corp execution intents --description "Wire $50,000 to vendor" --intent-type payment --authority-tier tier_1'
11563
+ ],
11594
11564
  successTemplate: "Intents created"
11595
11565
  },
11596
11566
  {
@@ -11606,7 +11576,10 @@ var init_execution = __esm({
11606
11576
  { flags: "--intent-id <intent-id>", description: "Execution intent ID" },
11607
11577
  { flags: "--obligation-type <obligation-type>", description: "Type of obligation", required: true }
11608
11578
  ],
11609
- examples: ["corp execution obligations --assignee-type internal --description 'description' --obligation-type 'obligation-type'", "corp execution obligations --json"],
11579
+ examples: [
11580
+ 'corp execution obligations --assignee-type human --description "Sign equity grant agreement" --obligation-type signature',
11581
+ 'corp execution obligations --assignee-type internal --description "File 83(b) election" --obligation-type document --due-date 2026-04-15'
11582
+ ],
11610
11583
  successTemplate: "Obligations created"
11611
11584
  },
11612
11585
  {
@@ -11616,7 +11589,10 @@ var init_execution = __esm({
11616
11589
  entity: true,
11617
11590
  args: [{ name: "packet-id", required: true, description: "Document packet ID" }],
11618
11591
  display: { title: "Execution Packets", cols: ["finalized_at>Finalized At", "items>Items", "manifest_hash>Manifest Hash", "required_signers>Required Signers", "@created_at>Created At", "#entity_id>ID"] },
11619
- examples: ["corp execution packets", "corp execution packets --json"]
11592
+ examples: [
11593
+ "corp execution packets pkt_01hx9k3n2p4q7r8s9t0uvwxyz",
11594
+ "corp execution packets pkt_01hx9k3n2p4q7r8s9t0uvwxyz --json"
11595
+ ]
11620
11596
  },
11621
11597
  {
11622
11598
  name: "intents authorize",
@@ -11625,7 +11601,7 @@ var init_execution = __esm({
11625
11601
  entity: true,
11626
11602
  args: [{ name: "intent-id", required: true, description: "Execution intent ID" }],
11627
11603
  examples: ["corp intents authorize <intent-id>"],
11628
- successTemplate: "Authorize created"
11604
+ successTemplate: "Intent authorized"
11629
11605
  },
11630
11606
  {
11631
11607
  name: "intents bind-approval-artifact",
@@ -11635,7 +11611,9 @@ var init_execution = __esm({
11635
11611
  options: [
11636
11612
  { flags: "--approval-artifact-id <approval-artifact-id>", description: "Approval artifact ID to bind", required: true }
11637
11613
  ],
11638
- examples: ["corp intents bind-approval-artifact <intent-id> --approval-artifact-id 'approval-artifact-id'"],
11614
+ examples: [
11615
+ "corp intents bind-approval-artifact @last:intent --approval-artifact-id art_01hx9k3n2p4q7r8s9t0uvwxyz"
11616
+ ],
11639
11617
  successTemplate: "Bind Approval Artifact created"
11640
11618
  },
11641
11619
  {
@@ -11646,7 +11624,9 @@ var init_execution = __esm({
11646
11624
  options: [
11647
11625
  { flags: "--request-id <request-id>", description: "Document request ID", required: true }
11648
11626
  ],
11649
- examples: ["corp intents bind-document-request <intent-id> --request-id 'request-id'"],
11627
+ examples: [
11628
+ "corp intents bind-document-request @last:intent --request-id req_01hx9k3n2p4q7r8s9t0uvwxyz"
11629
+ ],
11650
11630
  successTemplate: "Bind Document Request created"
11651
11631
  },
11652
11632
  {
@@ -11656,7 +11636,7 @@ var init_execution = __esm({
11656
11636
  entity: true,
11657
11637
  args: [{ name: "intent-id", required: true, description: "Execution intent ID" }],
11658
11638
  examples: ["corp intents cancel <intent-id>"],
11659
- successTemplate: "Cancel created"
11639
+ successTemplate: "Intent cancelled"
11660
11640
  },
11661
11641
  {
11662
11642
  name: "intents evaluate",
@@ -11665,7 +11645,7 @@ var init_execution = __esm({
11665
11645
  entity: true,
11666
11646
  args: [{ name: "intent-id", required: true, description: "Execution intent ID" }],
11667
11647
  examples: ["corp intents evaluate <intent-id>"],
11668
- successTemplate: "Evaluate created"
11648
+ successTemplate: "Intent evaluated"
11669
11649
  },
11670
11650
  {
11671
11651
  name: "intents execute",
@@ -11674,7 +11654,7 @@ var init_execution = __esm({
11674
11654
  entity: true,
11675
11655
  args: [{ name: "intent-id", required: true, description: "Execution intent ID" }],
11676
11656
  examples: ["corp intents execute <intent-id>"],
11677
- successTemplate: "Execute created"
11657
+ successTemplate: "Intent executed"
11678
11658
  },
11679
11659
  {
11680
11660
  name: "intents receipts",
@@ -11683,7 +11663,10 @@ var init_execution = __esm({
11683
11663
  entity: true,
11684
11664
  args: [{ name: "intent-id", required: true, description: "Execution intent ID" }],
11685
11665
  display: { title: "Intents Receipts", cols: ["executed_at>Executed At", "idempotency_key>Idempotency Key", "request_hash>Request Hash", "response_hash>Response Hash", "@created_at>Created At", "#intent_id>ID"] },
11686
- examples: ["corp intents receipts", "corp intents receipts --json"]
11666
+ examples: [
11667
+ "corp intents receipts int_01hx9k3n2p4q7r8s9t0uvwxyz",
11668
+ "corp intents receipts @last:intent --json"
11669
+ ]
11687
11670
  },
11688
11671
  {
11689
11672
  name: "obligations assign",
@@ -11694,21 +11677,26 @@ var init_execution = __esm({
11694
11677
  options: [
11695
11678
  { flags: "--assignee-id <assignee-id>", description: "ID of the party to assign to", required: true }
11696
11679
  ],
11697
- examples: ["corp obligations assign <obligation-id> --assignee-id 'assignee-id'"],
11680
+ examples: [
11681
+ "corp obligations assign obl_01hx9k3n2p4q7r8s9t0uvwxyz --assignee-id usr_01hx9k3n2p4q7r8s9t0uvwxyz"
11682
+ ],
11698
11683
  successTemplate: "Assign created"
11699
11684
  },
11700
11685
  {
11701
11686
  name: "obligations document-requests",
11702
- description: "List or create document requests for an obligation",
11687
+ description: "List document requests for an obligation",
11703
11688
  route: { method: "GET", path: "/v1/obligations/{pos}/document-requests" },
11704
11689
  entity: true,
11705
11690
  args: [{ name: "obligation-id", required: true, description: "Obligation ID" }],
11706
11691
  display: { title: "Obligations Document Requests", cols: ["description>Description", "document_type>Document Type", "fulfilled_at>Fulfilled At", "not_applicable_at>Not Applicable At", "@created_at>Created At", "#entity_id>ID"] },
11707
- examples: ["corp obligations document-requests", "corp obligations document-requests --json"]
11692
+ examples: [
11693
+ "corp obligations document-requests obl_01hx9k3n2p4q7r8s9t0uvwxyz",
11694
+ "corp obligations document-requests obl_01hx9k3n2p4q7r8s9t0uvwxyz --json"
11695
+ ]
11708
11696
  },
11709
11697
  {
11710
11698
  name: "obligations create-document-request",
11711
- description: "List or create document requests for an obligation",
11699
+ description: "Create a document request for an obligation",
11712
11700
  route: { method: "POST", path: "/v1/obligations/{pos}/document-requests" },
11713
11701
  entity: true,
11714
11702
  args: [{ name: "obligation-id", required: true, description: "Obligation ID" }],
@@ -11716,7 +11704,9 @@ var init_execution = __esm({
11716
11704
  { flags: "--description <description>", description: "Description text", required: true },
11717
11705
  { flags: "--document-type <document-type>", description: "Type of document required", required: true }
11718
11706
  ],
11719
- examples: ["corp obligations document-requests <obligation-id> --description 'description' --document-type 'document-type'"],
11707
+ examples: [
11708
+ 'corp obligations create-document-request obl_01hx9k3n2p4q7r8s9t0uvwxyz --description "Signed equity grant agreement" --document-type equity_grant'
11709
+ ],
11720
11710
  successTemplate: "Document Requests created"
11721
11711
  },
11722
11712
  {
@@ -11726,7 +11716,7 @@ var init_execution = __esm({
11726
11716
  entity: true,
11727
11717
  args: [{ name: "obligation-id", required: true, description: "Obligation ID" }],
11728
11718
  examples: ["corp obligations expire <obligation-id>"],
11729
- successTemplate: "Expire created"
11719
+ successTemplate: "Obligation expired"
11730
11720
  },
11731
11721
  {
11732
11722
  name: "obligations fulfill",
@@ -11735,7 +11725,7 @@ var init_execution = __esm({
11735
11725
  entity: true,
11736
11726
  args: [{ name: "obligation-id", required: true, description: "Obligation ID" }],
11737
11727
  examples: ["corp obligations fulfill <obligation-id>"],
11738
- successTemplate: "Fulfill created"
11728
+ successTemplate: "Obligation fulfilled"
11739
11729
  },
11740
11730
  {
11741
11731
  name: "obligations waive",
@@ -11744,7 +11734,7 @@ var init_execution = __esm({
11744
11734
  entity: true,
11745
11735
  args: [{ name: "obligation-id", required: true, description: "Obligation ID" }],
11746
11736
  examples: ["corp obligations waive <obligation-id>"],
11747
- successTemplate: "Waive created"
11737
+ successTemplate: "Obligation waived"
11748
11738
  },
11749
11739
  {
11750
11740
  name: "receipts",
@@ -11753,7 +11743,10 @@ var init_execution = __esm({
11753
11743
  entity: true,
11754
11744
  args: [{ name: "receipt-id", required: true, description: "Execution receipt ID" }],
11755
11745
  display: { title: "Receipts", cols: ["executed_at>Executed At", "idempotency_key>Idempotency Key", "request_hash>Request Hash", "response_hash>Response Hash", "@created_at>Created At", "#intent_id>ID"] },
11756
- examples: ["corp receipts", "corp receipts --json"]
11746
+ examples: [
11747
+ "corp receipts rcp_01hx9k3n2p4q7r8s9t0uvwxyz",
11748
+ "corp receipts rcp_01hx9k3n2p4q7r8s9t0uvwxyz --json"
11749
+ ]
11757
11750
  },
11758
11751
  // ── Human obligations ───────────────────────────────────────────────
11759
11752
  {
@@ -11864,7 +11857,7 @@ var init_treasury = __esm({
11864
11857
  entity: true,
11865
11858
  args: [{ name: "bank-account-id", required: true, description: "Bank account ID", posKind: "bank_account" }],
11866
11859
  examples: ["corp bank-accounts close <bank-account-id>"],
11867
- successTemplate: "Close created"
11860
+ successTemplate: "Account closed"
11868
11861
  },
11869
11862
  {
11870
11863
  name: "distributions",
@@ -11926,7 +11919,7 @@ var init_treasury = __esm({
11926
11919
  },
11927
11920
  {
11928
11921
  name: "invoices",
11929
- description: "Create a new invoice",
11922
+ description: "View an invoice by ID",
11930
11923
  route: { method: "GET", path: "/v1/invoices/{pos}" },
11931
11924
  entity: true,
11932
11925
  args: [{ name: "invoice-id", required: true, description: "Invoice ID", posKind: "invoice" }],
@@ -11940,7 +11933,7 @@ var init_treasury = __esm({
11940
11933
  entity: true,
11941
11934
  args: [{ name: "invoice-id", required: true, description: "Invoice ID", posKind: "invoice" }],
11942
11935
  examples: ["corp invoices mark-paid <invoice-id>"],
11943
- successTemplate: "Mark Paid created"
11936
+ successTemplate: "Invoice marked as paid"
11944
11937
  },
11945
11938
  {
11946
11939
  name: "invoices pay-instructions",
@@ -11958,7 +11951,7 @@ var init_treasury = __esm({
11958
11951
  entity: true,
11959
11952
  args: [{ name: "invoice-id", required: true, description: "Invoice ID", posKind: "invoice" }],
11960
11953
  examples: ["corp invoices send <invoice-id>"],
11961
- successTemplate: "Send created"
11954
+ successTemplate: "Invoice sent"
11962
11955
  },
11963
11956
  {
11964
11957
  name: "invoices status",
@@ -11976,7 +11969,7 @@ var init_treasury = __esm({
11976
11969
  entity: true,
11977
11970
  args: [{ name: "entry-id", required: true, description: "Journal entry ID" }],
11978
11971
  examples: ["corp journal-entries post <entry-id>"],
11979
- successTemplate: "Post created"
11972
+ successTemplate: "Journal entry posted"
11980
11973
  },
11981
11974
  {
11982
11975
  name: "journal-entries void",
@@ -11985,7 +11978,7 @@ var init_treasury = __esm({
11985
11978
  entity: true,
11986
11979
  args: [{ name: "entry-id", required: true, description: "Journal entry ID" }],
11987
11980
  examples: ["corp journal-entries void <entry-id>"],
11988
- successTemplate: "Void created"
11981
+ successTemplate: "Journal entry voided"
11989
11982
  },
11990
11983
  {
11991
11984
  name: "ledger reconcile",
@@ -12026,7 +12019,7 @@ var init_treasury = __esm({
12026
12019
  { flags: "--recipient <recipient>", description: "Recipient", required: true }
12027
12020
  ],
12028
12021
  examples: ["corp payments execute --amount-cents 'amount-cents' --description bank_transfer --recipient 'recipient'", "corp payments execute --json"],
12029
- successTemplate: "Execute created"
12022
+ successTemplate: "Payment executed"
12030
12023
  },
12031
12024
  {
12032
12025
  name: "payroll runs",
@@ -12038,7 +12031,7 @@ var init_treasury = __esm({
12038
12031
  { flags: "--pay-period-start <pay-period-start>", description: "Pay Period Start", required: true }
12039
12032
  ],
12040
12033
  examples: ["corp payroll runs --pay-period-end 'pay-period-end' --pay-period-start 'pay-period-start'"],
12041
- successTemplate: "Runs created"
12034
+ successTemplate: "Payroll run created"
12042
12035
  },
12043
12036
  {
12044
12037
  name: "spending-limits",
@@ -12143,7 +12136,7 @@ var init_treasury = __esm({
12143
12136
  route: { method: "POST", path: "/v1/treasury/seed-chart-of-accounts" },
12144
12137
  entity: true,
12145
12138
  options: [
12146
- { flags: "--template <template>", description: "Template string with {{secret}} placeholders" }
12139
+ { flags: "--template <template>", description: "Chart of accounts template name to seed from" }
12147
12140
  ],
12148
12141
  examples: ["corp treasury seed-chart-of-accounts", "corp treasury seed-chart-of-accounts --json"],
12149
12142
  successTemplate: "Seed Chart Of Accounts created"
@@ -12224,6 +12217,275 @@ var init_branches = __esm({
12224
12217
  }
12225
12218
  });
12226
12219
 
12220
+ // src/registry/completions.ts
12221
+ function buildTree(commands) {
12222
+ const topLevelMap = /* @__PURE__ */ new Map();
12223
+ const topLevel = [];
12224
+ for (const cmd of commands) {
12225
+ if (cmd.hidden) continue;
12226
+ const parts = cmd.name.split(" ");
12227
+ const opts = ["--json"];
12228
+ if (cmd.entity) opts.push("--entity-id");
12229
+ if (cmd.dryRun) opts.push("--dry-run");
12230
+ for (const o of cmd.options ?? []) {
12231
+ if (o.hidden) continue;
12232
+ const longFlag = o.flags.split(/\s+/).find((f) => f.startsWith("--"));
12233
+ if (longFlag) {
12234
+ opts.push(longFlag.replace(/<[^>]*>|\[[^\]]*\]/, "").trim());
12235
+ }
12236
+ }
12237
+ const node = {
12238
+ name: parts[parts.length - 1],
12239
+ description: cmd.description,
12240
+ options: opts,
12241
+ subcmds: []
12242
+ };
12243
+ if (parts.length === 1) {
12244
+ topLevelMap.set(parts[0], node);
12245
+ topLevel.push(node);
12246
+ } else {
12247
+ const parentName = parts[0];
12248
+ let parent = topLevelMap.get(parentName);
12249
+ if (!parent) {
12250
+ parent = { name: parentName, description: "", options: [], subcmds: [] };
12251
+ topLevelMap.set(parentName, parent);
12252
+ topLevel.push(parent);
12253
+ }
12254
+ parent.subcmds.push(node);
12255
+ }
12256
+ }
12257
+ return topLevel;
12258
+ }
12259
+ function generateBash(commands) {
12260
+ const tree = buildTree(commands);
12261
+ const lines = [
12262
+ "# corp bash completion",
12263
+ "# Source this file or add to ~/.bash_completion.d/",
12264
+ "# source <(corp completions --shell bash)",
12265
+ "",
12266
+ "_corp_completions() {",
12267
+ " local cur prev words cword",
12268
+ " _init_completion 2>/dev/null || {",
12269
+ " COMPREPLY=()",
12270
+ ' cur="${COMP_WORDS[COMP_CWORD]}"',
12271
+ ' prev="${COMP_WORDS[COMP_CWORD-1]}"',
12272
+ ' words=("${COMP_WORDS[@]}")',
12273
+ " cword=$COMP_CWORD",
12274
+ " }",
12275
+ "",
12276
+ ' local subcommand=""',
12277
+ ' local subsubcommand=""',
12278
+ ' if [[ ${#words[@]} -ge 2 ]]; then subcommand="${words[1]}"; fi',
12279
+ ' if [[ ${#words[@]} -ge 3 ]]; then subsubcommand="${words[2]}"; fi',
12280
+ ""
12281
+ ];
12282
+ const topNames = tree.map((n) => n.name).join(" ");
12283
+ lines.push(` local top_commands="${topNames}"`);
12284
+ lines.push("");
12285
+ lines.push(' case "$subcommand" in');
12286
+ for (const parent of tree) {
12287
+ if (parent.subcmds.length > 0) {
12288
+ const subNames = parent.subcmds.map((s3) => s3.name).join(" ");
12289
+ lines.push(` ${parent.name})`);
12290
+ lines.push(` local ${parent.name}_subcmds="${subNames}"`);
12291
+ lines.push(` case "$subsubcommand" in`);
12292
+ for (const child of parent.subcmds) {
12293
+ const childFlags = child.options.join(" ");
12294
+ lines.push(` ${child.name})`);
12295
+ lines.push(` COMPREPLY=( $(compgen -W "${childFlags}" -- "$cur") )`);
12296
+ lines.push(" return 0 ;;");
12297
+ }
12298
+ const parentFlags = parent.options.join(" ");
12299
+ lines.push(" *)");
12300
+ if (parent.options.length > 0) {
12301
+ lines.push(` COMPREPLY=( $(compgen -W "${parent.subcmds.map((s3) => s3.name).join(" ")} ${parentFlags}" -- "$cur") )`);
12302
+ } else {
12303
+ lines.push(` COMPREPLY=( $(compgen -W "$${parent.name}_subcmds" -- "$cur") )`);
12304
+ }
12305
+ lines.push(" return 0 ;;");
12306
+ lines.push(" esac ;;");
12307
+ } else {
12308
+ const flags = parent.options.join(" ");
12309
+ lines.push(` ${parent.name})`);
12310
+ lines.push(` COMPREPLY=( $(compgen -W "${flags}" -- "$cur") )`);
12311
+ lines.push(" return 0 ;;");
12312
+ }
12313
+ }
12314
+ lines.push(" *)");
12315
+ lines.push(' COMPREPLY=( $(compgen -W "$top_commands" -- "$cur") )');
12316
+ lines.push(" return 0 ;;");
12317
+ lines.push(" esac");
12318
+ lines.push("}");
12319
+ lines.push("");
12320
+ lines.push("complete -F _corp_completions corp");
12321
+ lines.push("complete -F _corp_completions npx corp");
12322
+ return lines.join("\n");
12323
+ }
12324
+ function escapeZshDesc(s3) {
12325
+ return s3.replace(/'/g, "'\\''").replace(/:/g, "\\:");
12326
+ }
12327
+ function generateZsh(commands) {
12328
+ const tree = buildTree(commands);
12329
+ const lines = [
12330
+ "#compdef corp",
12331
+ "# corp zsh completion",
12332
+ "# Add to your fpath and run: compdef _corp corp",
12333
+ '# eval "$(corp completions --shell zsh)"',
12334
+ "",
12335
+ "_corp() {",
12336
+ " local state",
12337
+ " local -a top_commands",
12338
+ ""
12339
+ ];
12340
+ lines.push(" top_commands=(");
12341
+ for (const node of tree) {
12342
+ lines.push(` '${node.name}:${escapeZshDesc(node.description)}'`);
12343
+ }
12344
+ lines.push(" )");
12345
+ lines.push("");
12346
+ lines.push(" _arguments -C \\");
12347
+ lines.push(" '(-h --help)'{-h,--help}'[Show help]' \\");
12348
+ lines.push(" '(-V --version)'{-V,--version}'[Show version]' \\");
12349
+ lines.push(" '(-q --quiet)'{-q,--quiet}'[Quiet output]' \\");
12350
+ lines.push(" '1: :->cmd' \\");
12351
+ lines.push(" '*: :->args'");
12352
+ lines.push("");
12353
+ lines.push(" case $state in");
12354
+ lines.push(" cmd)");
12355
+ lines.push(" _describe 'command' top_commands ;;");
12356
+ lines.push(" args)");
12357
+ lines.push(" case $words[2] in");
12358
+ for (const parent of tree) {
12359
+ lines.push(` ${parent.name})`);
12360
+ if (parent.subcmds.length > 0) {
12361
+ lines.push(" local -a subcmds");
12362
+ lines.push(" subcmds=(");
12363
+ for (const child of parent.subcmds) {
12364
+ lines.push(` '${child.name}:${escapeZshDesc(child.description)}'`);
12365
+ }
12366
+ lines.push(" )");
12367
+ lines.push(" if (( CURRENT == 3 )); then");
12368
+ lines.push(" _describe 'subcommand' subcmds");
12369
+ lines.push(" else");
12370
+ lines.push(" case $words[3] in");
12371
+ for (const child of parent.subcmds) {
12372
+ const argSpec = child.options.map((f) => `'${f}[option]'`).join(" \\\n ");
12373
+ lines.push(` ${child.name})`);
12374
+ lines.push(` _arguments ${argSpec} ;;`);
12375
+ }
12376
+ lines.push(" esac");
12377
+ lines.push(" fi ;;");
12378
+ } else {
12379
+ const argSpec = parent.options.map((f) => `'${f}[option]'`).join(" \\\n ");
12380
+ if (argSpec) {
12381
+ lines.push(` _arguments ${argSpec} ;;`);
12382
+ } else {
12383
+ lines.push(" ;; # no options");
12384
+ }
12385
+ }
12386
+ }
12387
+ lines.push(" esac ;;");
12388
+ lines.push(" esac");
12389
+ lines.push("}");
12390
+ lines.push("");
12391
+ lines.push("_corp");
12392
+ return lines.join("\n");
12393
+ }
12394
+ function generateFish(commands) {
12395
+ const tree = buildTree(commands);
12396
+ const lines = [
12397
+ "# corp fish completion",
12398
+ "# Save to ~/.config/fish/completions/corp.fish",
12399
+ "# corp completions --shell fish > ~/.config/fish/completions/corp.fish",
12400
+ ""
12401
+ ];
12402
+ lines.push("complete -c corp -f");
12403
+ lines.push("");
12404
+ for (const node of tree) {
12405
+ const desc = node.description.replace(/'/g, "\\'");
12406
+ lines.push(`complete -c corp -n '__fish_use_subcommand' -a '${node.name}' -d '${desc}'`);
12407
+ }
12408
+ lines.push("");
12409
+ for (const parent of tree) {
12410
+ const parentName = parent.name;
12411
+ if (parent.subcmds.length > 0) {
12412
+ for (const child of parent.subcmds) {
12413
+ const desc = child.description.replace(/'/g, "\\'");
12414
+ lines.push(
12415
+ `complete -c corp -n "__fish_seen_subcommand_from ${parentName}; and not __fish_seen_subcommand_from ${parent.subcmds.map((s3) => s3.name).join(" ")}" -a '${child.name}' -d '${desc}'`
12416
+ );
12417
+ }
12418
+ lines.push("");
12419
+ for (const child of parent.subcmds) {
12420
+ for (const flag of child.options) {
12421
+ const long = flag.replace(/^--/, "");
12422
+ lines.push(
12423
+ `complete -c corp -n "__fish_seen_subcommand_from ${parentName}; and __fish_seen_subcommand_from ${child.name}" -l '${long}'`
12424
+ );
12425
+ }
12426
+ if (child.options.length > 0) lines.push("");
12427
+ }
12428
+ } else {
12429
+ for (const flag of parent.options) {
12430
+ const long = flag.replace(/^--/, "");
12431
+ lines.push(
12432
+ `complete -c corp -n "__fish_seen_subcommand_from ${parentName}" -l '${long}'`
12433
+ );
12434
+ }
12435
+ if (parent.options.length > 0) lines.push("");
12436
+ }
12437
+ }
12438
+ return lines.join("\n");
12439
+ }
12440
+ function makeCompletionsCommand(allCommands) {
12441
+ return {
12442
+ name: "completions",
12443
+ description: "Generate shell completion scripts",
12444
+ local: true,
12445
+ options: [
12446
+ {
12447
+ flags: "--shell <shell>",
12448
+ description: "Shell type (bash, zsh, fish)",
12449
+ choices: ["bash", "zsh", "fish"],
12450
+ required: true
12451
+ }
12452
+ ],
12453
+ examples: [
12454
+ "corp completions --shell bash",
12455
+ "corp completions --shell zsh",
12456
+ "corp completions --shell fish",
12457
+ "source <(corp completions --shell bash)",
12458
+ 'eval "$(corp completions --shell zsh)"',
12459
+ "corp completions --shell fish > ~/.config/fish/completions/corp.fish"
12460
+ ],
12461
+ handler: async (ctx) => {
12462
+ const shell = ctx.opts.shell;
12463
+ const cmds = allCommands.filter((c) => c.name !== "completions");
12464
+ let script;
12465
+ switch (shell) {
12466
+ case "bash":
12467
+ script = generateBash(cmds);
12468
+ break;
12469
+ case "zsh":
12470
+ script = generateZsh(cmds);
12471
+ break;
12472
+ case "fish":
12473
+ script = generateFish(cmds);
12474
+ break;
12475
+ default:
12476
+ ctx.writer.error(`Unknown shell: ${shell}. Choose bash, zsh, or fish.`);
12477
+ process.exit(1);
12478
+ }
12479
+ process.stdout.write(script + "\n");
12480
+ }
12481
+ };
12482
+ }
12483
+ var init_completions = __esm({
12484
+ "src/registry/completions.ts"() {
12485
+ "use strict";
12486
+ }
12487
+ });
12488
+
12227
12489
  // src/registry/index.ts
12228
12490
  var registry_exports = {};
12229
12491
  __export(registry_exports, {
@@ -12355,7 +12617,7 @@ function generateSchema(commands, programName, version) {
12355
12617
  commands: topLevel
12356
12618
  };
12357
12619
  }
12358
- var registry;
12620
+ var baseRegistry, registry;
12359
12621
  var init_registry = __esm({
12360
12622
  "src/registry/index.ts"() {
12361
12623
  "use strict";
@@ -12375,7 +12637,8 @@ var init_registry = __esm({
12375
12637
  init_secret_proxies();
12376
12638
  init_treasury();
12377
12639
  init_branches();
12378
- registry = [
12640
+ init_completions();
12641
+ baseRegistry = [
12379
12642
  ...workspaceCommands,
12380
12643
  ...entityCommands,
12381
12644
  ...formationCommands,
@@ -12393,6 +12656,10 @@ var init_registry = __esm({
12393
12656
  ...treasuryCommands,
12394
12657
  ...branchCommands
12395
12658
  ];
12659
+ registry = [
12660
+ ...baseRegistry,
12661
+ makeCompletionsCommand(baseRegistry)
12662
+ ];
12396
12663
  }
12397
12664
  });
12398
12665
 
@@ -12403,28 +12670,9 @@ import { createRequire } from "module";
12403
12670
  import { Command, Option } from "commander";
12404
12671
 
12405
12672
  // src/generic-executor.ts
12673
+ init_references();
12674
+ init_output();
12406
12675
  init_spinner();
12407
- function s(val, maxLen) {
12408
- const str = val == null ? "" : String(val);
12409
- if (maxLen && str.length > maxLen) return str.slice(0, maxLen);
12410
- return str;
12411
- }
12412
- function money(val) {
12413
- if (typeof val === "number") {
12414
- const dollars = val / 100;
12415
- return `$${dollars.toLocaleString(void 0, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
12416
- }
12417
- return s(val);
12418
- }
12419
- function fmtDate(val) {
12420
- const str = s(val);
12421
- if (!str) return "";
12422
- const parsed = new Date(str);
12423
- return Number.isNaN(parsed.getTime()) ? str : parsed.toISOString().slice(0, 10);
12424
- }
12425
- function shortId(val) {
12426
- return val.length > 8 ? val.slice(0, 8) + "\u2026" : val;
12427
- }
12428
12676
  function parseCol(spec) {
12429
12677
  let fmt = null;
12430
12678
  let rest = spec;
@@ -12450,7 +12698,7 @@ function getField(obj, keys) {
12450
12698
  function fmtField(val, fmt) {
12451
12699
  if (val == null) return "";
12452
12700
  if (fmt === "money") return money(val);
12453
- if (fmt === "date") return fmtDate(val);
12701
+ if (fmt === "date") return date(val);
12454
12702
  if (fmt === "id") return shortId(String(val));
12455
12703
  return String(val);
12456
12704
  }
@@ -12505,7 +12753,7 @@ function displayPanel(data, title, ctx) {
12505
12753
  const label = k.replace(/_/g, " ").replace(/\b\w/g, (ch) => ch.toUpperCase());
12506
12754
  let formatted;
12507
12755
  if (k.endsWith("_cents") && typeof v === "number") formatted = money(v);
12508
- else if ((k.includes("date") || k.endsWith("_at")) && v) formatted = fmtDate(v);
12756
+ else if ((k.includes("date") || k.endsWith("_at")) && v) formatted = date(v);
12509
12757
  else if (k.endsWith("_id")) formatted = shortId(String(v));
12510
12758
  else formatted = String(v);
12511
12759
  return `${label}: ${formatted}`;
@@ -12737,7 +12985,9 @@ init_api_client();
12737
12985
  init_references();
12738
12986
  function buildCLI(commands, version) {
12739
12987
  const program2 = new Command();
12740
- program2.name("corp").description("corp \u2014 Corporate governance from the terminal").version(version).enablePositionalOptions();
12988
+ program2.name("corp").description(
12989
+ 'The Corporation CLI \u2014 form entities, manage cap tables, govern, and operate.\n\nQuick start:\n corp form --type llc --name "My LLC" --member "Alice,a@co.com,member,100"\n corp cap-table\n corp next\n\nDocs: https://docs.thecorporation.ai'
12990
+ ).version(version).enablePositionalOptions();
12741
12991
  program2.option("-q, --quiet", "Only output the resource ID (for scripting)");
12742
12992
  program2.action(() => {
12743
12993
  program2.outputHelp();
@@ -12758,6 +13008,61 @@ function buildCLI(commands, version) {
12758
13008
  children.get(parent).push(def);
12759
13009
  }
12760
13010
  }
13011
+ const commandGroupOrder = {
13012
+ // Core workflow — formation & entity management
13013
+ form: 0,
13014
+ entities: 1,
13015
+ contacts: 2,
13016
+ // Cap table
13017
+ "cap-table": 10,
13018
+ "safe-notes": 11,
13019
+ "share-transfers": 12,
13020
+ valuations: 13,
13021
+ // Governance
13022
+ governance: 20,
13023
+ // Finance
13024
+ finance: 30,
13025
+ // Compliance & tax
13026
+ tax: 40,
13027
+ deadlines: 41,
13028
+ // Status / context / actions
13029
+ status: 50,
13030
+ context: 51,
13031
+ use: 52,
13032
+ next: 53,
13033
+ obligations: 54,
13034
+ "human-obligations": 55,
13035
+ digest: 56,
13036
+ // Services & work items
13037
+ services: 60,
13038
+ "work-items": 61,
13039
+ contracts: 62,
13040
+ // Agents
13041
+ agents: 70,
13042
+ // Admin / config / setup (last)
13043
+ billing: 80,
13044
+ "api-keys": 81,
13045
+ link: 82,
13046
+ claim: 83,
13047
+ feedback: 84,
13048
+ resolve: 85,
13049
+ find: 86,
13050
+ approvals: 87,
13051
+ receipts: 88,
13052
+ config: 90,
13053
+ setup: 91,
13054
+ schema: 92,
13055
+ serve: 93,
13056
+ demo: 94,
13057
+ chat: 95,
13058
+ completions: 96
13059
+ };
13060
+ topLevel.sort((a, b) => {
13061
+ const ga = commandGroupOrder[a.name] ?? 75;
13062
+ const gb = commandGroupOrder[b.name] ?? 75;
13063
+ if (ga !== gb) return ga - gb;
13064
+ return a.name.localeCompare(b.name);
13065
+ });
12761
13066
  const parentCmds = /* @__PURE__ */ new Map();
12762
13067
  for (const def of topLevel) {
12763
13068
  const cmd = wireCommand(program2, def);