boardui 0.5.10 → 0.5.12

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.
Files changed (3) hide show
  1. package/README.md +7 -1
  2. package/dist/index.js +155 -83
  3. package/package.json +4 -4
package/README.md CHANGED
@@ -53,6 +53,10 @@ transitively (utils, icons, other components), writes the source files into
53
53
  your project, and installs any missing npm packages. Run without arguments for
54
54
  an interactive picker.
55
55
 
56
+ Names are forgiving: shadcn/ui's names resolve to the BoardUI item
57
+ (`boardui add dialog sheet` installs `modal` and `drawer`), as do plurals and
58
+ docs-page slugs. An unknown name fails with the closest real ones.
59
+
56
60
  | Option | Description |
57
61
  | --- | --- |
58
62
  | `-a, --all` | Add every component in the registry |
@@ -228,7 +232,9 @@ After a successful `boardui init`, the CLI sends one anonymous event containing
228
232
  the CLI version, detected package manager, and whether `--pro` was used. After a
229
233
  successful `boardui add`, it sends the CLI version, package manager, and the
230
234
  component names explicitly requested by the user. Automatically resolved
231
- dependencies are not included. A random installation ID is stored in the
235
+ dependencies are not included. Each event also says whether a person ran the
236
+ command (`source: "cli"`) or an agent ran it through `boardui mcp`
237
+ (`source: "mcp"`). A random installation ID is stored in the
232
238
  operating system's user config directory so repeat runs can be counted without
233
239
  collecting identity.
234
240
 
package/dist/index.js CHANGED
@@ -678,6 +678,103 @@ async function installMissingDependencies(project, wanted) {
678
678
  }
679
679
  }
680
680
 
681
+ // ../lib/agent/item-names.ts
682
+ function normalizeName(raw) {
683
+ return raw.trim().toLowerCase().replace(/\.tsx?$/, "").replace(/[\s_]+/g, "-").replace(/^@?boardui\//, "");
684
+ }
685
+ function editDistance(a, b) {
686
+ const rows = a.length + 1;
687
+ const cols = b.length + 1;
688
+ const d = Array.from({ length: rows }, (_, i) => {
689
+ const row = new Array(cols).fill(0);
690
+ row[0] = i;
691
+ return row;
692
+ });
693
+ for (let j = 0; j < cols; j++) d[0][j] = j;
694
+ for (let i = 1; i < rows; i++) {
695
+ for (let j = 1; j < cols; j++) {
696
+ d[i][j] = Math.min(
697
+ d[i - 1][j] + 1,
698
+ d[i][j - 1] + 1,
699
+ d[i - 1][j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1)
700
+ );
701
+ }
702
+ }
703
+ return d[rows - 1][cols - 1];
704
+ }
705
+ var UNRELEASED = {
706
+ "agent-orb": '"agent-orb" is not available yet. It is still in progress and not open to public use.',
707
+ orb: "The BoardUI orb component is not available yet. It is still in progress and not open to public use."
708
+ };
709
+ var CURATED_SUGGESTIONS = {
710
+ form: ["input", "select", "checkbox"],
711
+ card: ["stat-cards", "checkbox-card", "auth-card"],
712
+ chart: ["area-chart-card", "line-chart-card", "bar-list-card"],
713
+ alert: ["notification", "toast", "announcement"]
714
+ };
715
+ function docsSlug(url) {
716
+ if (!url) return void 0;
717
+ try {
718
+ return new URL(url).pathname.split("/").filter(Boolean).pop();
719
+ } catch {
720
+ return void 0;
721
+ }
722
+ }
723
+ function buildNameUniverse(free, pro) {
724
+ const freeItems = free?.items ?? [];
725
+ const proItems = pro?.items ?? [];
726
+ const all = /* @__PURE__ */ new Set([...freeItems.map((item) => item.name), ...proItems.map((item) => item.name)]);
727
+ const aliases = /* @__PURE__ */ new Map();
728
+ const add2 = (alias, name) => {
729
+ if (alias && alias !== name && !all.has(alias) && !aliases.has(alias)) aliases.set(alias, name);
730
+ };
731
+ for (const item of freeItems) for (const alias of item.meta?.aliases ?? []) add2(alias, item.name);
732
+ for (const item of proItems) for (const alias of item.aliases ?? []) add2(alias, item.name);
733
+ for (const item of proItems.filter((i) => i.kind === "template")) add2(docsSlug(item.docsUrl), item.name);
734
+ for (const item of proItems) add2(docsSlug(item.docsUrl), item.name);
735
+ for (const item of freeItems) add2(docsSlug(item.meta?.docsUrl), item.name);
736
+ return { all, aliases };
737
+ }
738
+ function lookup(name, universe) {
739
+ return universe.all.has(name) ? name : universe.aliases.get(name);
740
+ }
741
+ function aliasNote(raw, name) {
742
+ return normalizeName(raw) === name ? "" : `"${raw}" is BoardUI's "${name}"; use that name from here on.`;
743
+ }
744
+ function resolveName(raw, universe, listHint = "Call list_components for the exact names.") {
745
+ const n = normalizeName(raw);
746
+ const direct = lookup(n, universe);
747
+ if (direct) return { name: direct };
748
+ const unreleased = UNRELEASED[n];
749
+ if (unreleased) return { error: unreleased };
750
+ const variants = [
751
+ `${n}s`,
752
+ ...n.endsWith("s") ? [n.slice(0, -1)] : [],
753
+ ...n.endsWith("-chart") ? [`${n}-card`] : []
754
+ ];
755
+ for (const variant of variants) {
756
+ const name = lookup(variant, universe);
757
+ if (name) return { name };
758
+ }
759
+ const suggestions = new Set(
760
+ (CURATED_SUGGESTIONS[n] ?? []).filter((name) => universe.all.has(name))
761
+ );
762
+ const scored = [];
763
+ for (const name of universe.all) {
764
+ if (name.includes(n) || n.includes(name)) scored.push({ name, score: 0 });
765
+ else {
766
+ const dist = editDistance(n, name);
767
+ if (dist <= 2) scored.push({ name, score: dist });
768
+ }
769
+ }
770
+ scored.sort((a, b) => a.score - b.score || a.name.localeCompare(b.name));
771
+ for (const entry of scored) suggestions.add(entry.name);
772
+ const hint = suggestions.size ? ` Closest matches: ${[...suggestions].slice(0, 4).join(", ")}.` : "";
773
+ return {
774
+ error: `Unknown component "${raw}".${hint} ${listHint}`
775
+ };
776
+ }
777
+
681
778
  // src/lib/telemetry.ts
682
779
  import { randomUUID } from "crypto";
683
780
  import { existsSync as existsSync5, mkdirSync as mkdirSync3, readFileSync as readFileSync6, writeFileSync as writeFileSync3 } from "fs";
@@ -819,6 +916,29 @@ async function pickComponents() {
819
916
  });
820
917
  return names ?? [];
821
918
  }
919
+ async function resolveRequestedNames(names) {
920
+ let universe;
921
+ try {
922
+ const [free, pro] = await Promise.all([fetchRegistryIndex(), fetchProIndex().catch(() => null)]);
923
+ universe = buildNameUniverse(free, pro);
924
+ } catch {
925
+ return { names, notes: [], errors: [] };
926
+ }
927
+ const resolved = [];
928
+ const notes = [];
929
+ const errors = [];
930
+ for (const raw of names) {
931
+ const result = resolveName(raw, universe, "Run `boardui list` for the exact names.");
932
+ if (result.error !== void 0) {
933
+ errors.push(result.error);
934
+ continue;
935
+ }
936
+ resolved.push(result.name);
937
+ const note = aliasNote(raw, result.name);
938
+ if (note) notes.push(note);
939
+ }
940
+ return { names: [...new Set(resolved)], notes, errors };
941
+ }
822
942
  async function add(components, options) {
823
943
  const project = readProject(process.cwd());
824
944
  checkDirectoryOverride(project.config, options.path ?? options.dir);
@@ -844,8 +964,18 @@ async function add(components, options) {
844
964
  console.log("Nothing to add.");
845
965
  return;
846
966
  }
847
- const requestedComponents = [...new Set(names)];
848
967
  const spinner = ora("Resolving components...").start();
968
+ if (!options.all) {
969
+ const requested = await resolveRequestedNames(names);
970
+ if (requested.errors.length > 0) {
971
+ spinner.fail(requested.errors.join("\n"));
972
+ process.exitCode = 1;
973
+ return;
974
+ }
975
+ for (const note of requested.notes) spinner.info(note).start("Resolving components...");
976
+ names = requested.names;
977
+ }
978
+ const requestedComponents = [...new Set(names)];
849
979
  let items;
850
980
  try {
851
981
  items = await resolveItems(names);
@@ -1183,13 +1313,6 @@ import { instrument } from "@posthog/mcp";
1183
1313
  import { PostHog } from "posthog-node";
1184
1314
  import { z } from "zod";
1185
1315
 
1186
- // src/lib/mcp-analytics.ts
1187
- var HANDSHAKE_EVENTS = /* @__PURE__ */ new Set(["$mcp_initialize", "$mcp_tools_list"]);
1188
- function dropHandshakeEvents(capture) {
1189
- if (HANDSHAKE_EVENTS.has(capture.event) && capture.properties.$mcp_is_error !== true) return null;
1190
- return capture;
1191
- }
1192
-
1193
1316
  // ../lib/agent/rtl.ts
1194
1317
  var RTL_SETUP_GUIDE = [
1195
1318
  "## RTL Support",
@@ -1256,77 +1379,15 @@ function proIndex() {
1256
1379
  });
1257
1380
  return proIndexPromise;
1258
1381
  }
1259
- function normalizeName(raw) {
1260
- return raw.trim().toLowerCase().replace(/\.tsx?$/, "").replace(/[\s_]+/g, "-").replace(/^@?boardui\//, "");
1261
- }
1262
- function editDistance(a, b) {
1263
- const rows = a.length + 1;
1264
- const cols = b.length + 1;
1265
- const d = Array.from({ length: rows }, (_, i) => {
1266
- const row = new Array(cols).fill(0);
1267
- row[0] = i;
1268
- return row;
1269
- });
1270
- for (let j = 0; j < cols; j++) d[0][j] = j;
1271
- for (let i = 1; i < rows; i++) {
1272
- for (let j = 1; j < cols; j++) {
1273
- d[i][j] = Math.min(
1274
- d[i - 1][j] + 1,
1275
- d[i][j - 1] + 1,
1276
- d[i - 1][j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1)
1277
- );
1278
- }
1279
- }
1280
- return d[rows - 1][cols - 1];
1281
- }
1282
- var UNRELEASED = {
1283
- "agent-orb": '"agent-orb" is not available yet. It is still in progress and not open to public use.',
1284
- orb: "The BoardUI orb component is not available yet. It is still in progress and not open to public use."
1285
- };
1286
- var CURATED_SUGGESTIONS = {
1287
- "text-area": ["textarea"],
1288
- form: ["input", "select", "checkbox"],
1289
- modal: ["settings-modal", "auth-card"],
1290
- dialog: ["settings-modal"],
1291
- card: ["stat-cards", "area-chart-card", "auth-card"],
1292
- toast: ["notification"],
1293
- chart: ["area-chart-card", "line-chart-card", "bar-list-card"]
1294
- };
1295
1382
  async function nameUniverse() {
1296
1383
  const [free, pro] = await Promise.all([freeIndex(), proIndex()]);
1297
- const all = /* @__PURE__ */ new Set([
1298
- ...free.items.map((item) => item.name),
1299
- ...pro.items.map((item) => item.name)
1300
- ]);
1301
- const aliases = /* @__PURE__ */ new Map();
1302
- for (const item of pro.items) {
1303
- const slug = item.docsUrl?.split("/").pop();
1304
- if (slug && slug !== item.name && !all.has(slug)) aliases.set(slug, item.name);
1305
- }
1306
- return { all, aliases };
1384
+ return buildNameUniverse(free, pro);
1307
1385
  }
1308
- function resolveName(raw, universe) {
1309
- const n = normalizeName(raw);
1310
- if (universe.all.has(n)) return { name: n };
1311
- const alias = universe.aliases.get(n);
1312
- if (alias) return { name: alias };
1313
- const unreleased = UNRELEASED[n];
1314
- if (unreleased) return { error: unreleased };
1315
- const suggestions = new Set(CURATED_SUGGESTIONS[n] ?? []);
1316
- const scored = [];
1317
- for (const name of universe.all) {
1318
- if (name.includes(n) || n.includes(name)) scored.push({ name, score: 0 });
1319
- else {
1320
- const dist = editDistance(n, name);
1321
- if (dist <= 2) scored.push({ name, score: dist });
1322
- }
1323
- }
1324
- scored.sort((a, b) => a.score - b.score || a.name.localeCompare(b.name));
1325
- for (const entry of scored) suggestions.add(entry.name);
1326
- const hint = suggestions.size ? ` Closest matches: ${[...suggestions].slice(0, 4).join(", ")}.` : "";
1327
- return {
1328
- error: `Unknown component "${raw}".${hint} Call list_components for the exact names.`
1329
- };
1386
+ function withAliasNote(raw, name, body) {
1387
+ const note = aliasNote(raw, name);
1388
+ return note ? `${note}
1389
+
1390
+ ${body}` : body;
1330
1391
  }
1331
1392
  function text(value) {
1332
1393
  return { content: [{ type: "text", text: value }] };
@@ -1469,7 +1530,16 @@ async function mcp() {
1469
1530
  posthog.on("error", () => console.error("[mcp-analytics] PostHog delivery failed."));
1470
1531
  instrument(server, posthog, {
1471
1532
  eventProperties: () => ({ $mcp_transport: "stdio" }),
1472
- beforeSend: dropHandshakeEvents,
1533
+ // Every agent launch opens with initialize + tools/list. Those two events
1534
+ // were about 98% of our MCP events and used up the PostHog quota in
1535
+ // November 2026, and nothing here reads them.
1536
+ sendInitializeEvent: false,
1537
+ sendToolsListEvent: false,
1538
+ // @posthog/mcp 1.x turns these on by default. They add llm_model and
1539
+ // conversation_id arguments to every tool and a handle block to every
1540
+ // result, which would change the tool contract agents see.
1541
+ captureModel: false,
1542
+ enableConversationId: false,
1473
1543
  logger: (message) => {
1474
1544
  if (/warning|failed/i.test(message)) console.error(`[mcp-analytics] ${message}`);
1475
1545
  }
@@ -1573,10 +1643,10 @@ Public usage example (source requires the license):
1573
1643
  \`\`\`tsx
1574
1644
  ${projectExample(proItem.example, project)}
1575
1645
  \`\`\`` : "";
1576
- return text(proPitch([proItem]) + example);
1646
+ return text(withAliasNote(rawName, name, proPitch([proItem]) + example));
1577
1647
  }
1578
1648
  const item = await fetchRegistryItem(name);
1579
- return text(formatItemDetail(projectItem(item, project), proItem ? "pro" : "free"));
1649
+ return text(withAliasNote(rawName, name, formatItemDetail(projectItem(item, project), proItem ? "pro" : "free")));
1580
1650
  })
1581
1651
  );
1582
1652
  server.registerTool(
@@ -1609,7 +1679,7 @@ ${projectExample(proItem.example, project)}
1609
1679
  } else {
1610
1680
  lines2.push("", "No public example \u2014 see the docs page for a live preview.");
1611
1681
  }
1612
- return text(lines2.join("\n"));
1682
+ return text(withAliasNote(rawName, name, lines2.join("\n")));
1613
1683
  }
1614
1684
  const item = projectItem(await fetchRegistryItem(name), project);
1615
1685
  const lines = [
@@ -1627,7 +1697,7 @@ ${projectExample(proItem.example, project)}
1627
1697
  if (!item.meta?.example && !item.meta?.snippets?.length) {
1628
1698
  lines.push("", "No docs examples for this item \u2014 call get_component for the source.");
1629
1699
  }
1630
- return text(lines.join("\n"));
1700
+ return text(withAliasNote(rawName, name, lines.join("\n")));
1631
1701
  })
1632
1702
  );
1633
1703
  server.registerTool(
@@ -1653,12 +1723,14 @@ ${projectExample(proItem.example, project)}
1653
1723
  const project = loadProject(projectDir);
1654
1724
  const universe = await nameUniverse();
1655
1725
  const pro = await proIndex();
1656
- const resolutions = [...new Set(names)].map((raw) => resolveName(raw, universe));
1726
+ const rawNames = [...new Set(names)];
1727
+ const resolutions = rawNames.map((raw) => resolveName(raw, universe));
1657
1728
  const unknown = resolutions.flatMap((r) => r.error ? [r.error] : []);
1658
1729
  if (unknown.length > 0) {
1659
1730
  return errorText(unknown.join("\n"));
1660
1731
  }
1661
1732
  const requested = [...new Set(resolutions.flatMap((r) => r.name ? [r.name] : []))];
1733
+ const aliasNotes = rawNames.map((raw, i) => aliasNote(raw, resolutions[i].name ?? raw)).filter(Boolean);
1662
1734
  const licensed = getLicense() !== null;
1663
1735
  const lockedPro = licensed ? [] : pro.items.filter((item) => requested.includes(item.name));
1664
1736
  const lockedNames = new Set(lockedPro.map((item) => item.name));
@@ -1718,7 +1790,7 @@ ${projectExample(proItem.example, project)}
1718
1790
  `The globals stylesheet was installed \u2014 make sure the root layout imports it: import "${mappedImport("@/styles/globals.css", project.config)}"; (replaces the default create-next-app globals.css import).`
1719
1791
  );
1720
1792
  }
1721
- let result = lines.join("\n") + aliasWarning(project);
1793
+ let result = [...aliasNotes, ...lines].join("\n") + aliasWarning(project);
1722
1794
  if (lockedPro.length > 0) {
1723
1795
  result += `
1724
1796
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "boardui",
3
- "version": "0.5.10",
3
+ "version": "0.5.12",
4
4
  "description": "Add BoardUI components to your project.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -34,14 +34,14 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "@modelcontextprotocol/sdk": "^1.30.0",
37
- "@posthog/mcp": "^0.12.0",
37
+ "@posthog/mcp": "^1.8.2",
38
38
  "commander": "^12.1.0",
39
39
  "ora": "^8.1.1",
40
40
  "picocolors": "^1.1.1",
41
41
  "posthog-node": "^5.51.4",
42
42
  "prompts": "^2.4.2",
43
- "zod": "^4.5.1",
44
- "typescript": "^5"
43
+ "typescript": "^5",
44
+ "zod": "^4.5.1"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@types/node": "^20",