boardui 0.4.1 → 0.5.0

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 (2) hide show
  1. package/dist/index.js +197 -11
  2. package/package.json +3 -1
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  // src/index.ts
4
4
  import { Command } from "commander";
5
- import pc5 from "picocolors";
5
+ import pc6 from "picocolors";
6
6
 
7
7
  // src/commands/add.ts
8
8
  import path5 from "path";
@@ -139,7 +139,7 @@ import { existsSync as existsSync2, mkdirSync, readFileSync as readFileSync2, rm
139
139
  import { homedir, hostname } from "os";
140
140
  import path2 from "path";
141
141
  var LICENSE_API = "https://api.lemonsqueezy.com/v1/licenses";
142
- var PRO_PRODUCT_IDS = /* @__PURE__ */ new Set([1220683]);
142
+ var PRO_PRODUCT_IDS = /* @__PURE__ */ new Set([1220683, 1268490]);
143
143
  function configRoot() {
144
144
  if (process.env.XDG_CONFIG_HOME) return process.env.XDG_CONFIG_HOME;
145
145
  if (process.platform === "win32" && process.env.APPDATA) return process.env.APPDATA;
@@ -216,7 +216,25 @@ async function activateLicense(licenseKey) {
216
216
  seatsUsed: data.license_key?.activation_usage ?? 1,
217
217
  seatLimit: data.license_key?.activation_limit ?? 0,
218
218
  productName: data.meta?.product_name ?? "BoardUI Pro",
219
- warning: data.meta && !PRO_PRODUCT_IDS.has(data.meta.product_id) ? `This key belongs to "${data.meta.product_name}", not BoardUI Pro \u2014 pro installs will be refused.` : void 0
219
+ warning: data.meta && !PRO_PRODUCT_IDS.has(data.meta.product_id) ? `This key belongs to "${data.meta.product_name}", which this CLI version does not recognize as BoardUI Pro. The server has the final say \u2014 if pro installs are refused, update the CLI (npx boardui@latest) or contact hi@boardui.com.` : void 0
220
+ };
221
+ }
222
+ async function validateStoredLicense() {
223
+ const license = getLicense();
224
+ if (!license) return null;
225
+ const fields = { license_key: license.licenseKey };
226
+ if (license.instanceId) fields.instance_id = license.instanceId;
227
+ const data = await licenseApi("validate", fields);
228
+ if (!data.valid) {
229
+ return { valid: false, error: data.error ?? "This license key is not valid." };
230
+ }
231
+ return {
232
+ valid: true,
233
+ status: data.license_key?.status,
234
+ seatsUsed: data.license_key?.activation_usage,
235
+ seatLimit: data.license_key?.activation_limit,
236
+ productName: data.meta?.product_name,
237
+ unknownProduct: data.meta ? !PRO_PRODUCT_IDS.has(data.meta.product_id) : void 0
220
238
  };
221
239
  }
222
240
  async function deactivateLicense() {
@@ -347,6 +365,13 @@ var DEV_DEPS = ["tailwindcss", "@tailwindcss/postcss"];
347
365
  var PRO_DEPS = ["recharts", "motion", "prism-react-renderer", "@internationalized/date"];
348
366
  var INIT_ITEMS = ["globals", "cx", "use-dismiss-on-outside-press", "rules"];
349
367
  var RULES_ITEM_NAME = "rules";
368
+ var SKILL_ITEM_NAME = "skill";
369
+ function skillTargetDir(options, cwd, home) {
370
+ if (options.path) return path3.resolve(cwd, options.path);
371
+ if (options.client) return path3.join(home, ".agents", "skills", "boardui");
372
+ if (options.global) return path3.join(home, ".claude", "skills", "boardui");
373
+ return path3.join(cwd, ".claude", "skills", "boardui");
374
+ }
350
375
  var RULES_START_MARKER = "<!-- boardui:rules:start -->";
351
376
  var RULES_END_MARKER = "<!-- boardui:rules:end -->";
352
377
  function stripFrontmatter(markdown) {
@@ -535,6 +560,13 @@ async function trackInitSuccess({
535
560
  }) {
536
561
  await sendTelemetryEvent({ event: "init", packageManager, pro, source });
537
562
  }
563
+ async function trackSkillInstall({
564
+ scope,
565
+ client,
566
+ source = "cli"
567
+ }) {
568
+ await sendTelemetryEvent({ event: "skill", scope, client, source });
569
+ }
538
570
  async function trackAddSuccess({
539
571
  packageManager,
540
572
  components,
@@ -888,6 +920,8 @@ import { existsSync as existsSync6, readFileSync as readFileSync6 } from "fs";
888
920
  import path7 from "path";
889
921
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
890
922
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
923
+ import { instrument } from "@posthog/mcp";
924
+ import { PostHog } from "posthog-node";
891
925
  import { z } from "zod";
892
926
  var PRICING_URL = "https://www.boardui.com/pricing";
893
927
  var INSTRUCTIONS = `BoardUI is a React + Tailwind CSS v4 design system (Next.js first) with free components and paid Pro components/templates. This server installs component source directly into the user's project \u2014 no terminal needed.
@@ -899,9 +933,12 @@ Typical flow:
899
933
 
900
934
  Component names are exact \u2014 when unsure, call list_components instead of guessing.
901
935
 
902
- Design rules (always apply when writing UI in a BoardUI project): style with BoardUI's semantic Tailwind tokens, never raw palette classes or hex \u2014 text via text-text-primary/-secondary/-tertiary, surfaces via bg-background-*-default/-hover, borders via border-border-* and border-separator-border, icons via text-foreground-icon-*. Type uses composite utilities (text-title-2-medium, text-headline-medium, text-body-medium, ...) that set size/weight/line-height together \u2014 never rebuild them from text-sm font-medium. Dark mode flips tokens automatically via the .dark class; never hardcode dark: colors. Merge classes with cx() from @/utils/cx; icons from @remixicon/react as component references. init_boardui installs these rules as always-on files (AGENTS.md + .cursor/rules/boardui.mdc) so they survive beyond this session; install_rules adds them to an already initialized project.
936
+ Design rules (always apply when writing UI in a BoardUI project): style with BoardUI's semantic Tailwind tokens, never raw palette classes or hex \u2014 text via text-text-primary/-secondary/-tertiary, surfaces via bg-background-*-default/-hover, borders via border-border-* and border-separator-border, icons via text-foreground-icon-*. Type uses composite utilities (text-title-2-medium, text-headline-medium, text-body-medium, ...) that set size/weight/line-height together \u2014 never rebuild them from text-sm font-medium. Dark mode flips tokens automatically via the .dark class; never hardcode dark: colors. Merge classes with cx() from @/utils/cx; icons from @remixicon/react as component references. init_boardui installs these rules as always-on files (AGENTS.md + .cursor/rules/boardui.mdc) so they survive beyond this session; install_rules adds them to an already initialized project. For deeper always-loaded knowledge (full catalog, theming, page patterns), install_skill writes the BoardUI agent skill into .claude/skills/boardui.
903
937
 
904
938
  Pro: items marked PRO require a one-time BoardUI Pro license (${PRICING_URL}, lifetime updates). If the user wants a pro item and no license is active, relay the pricing link \u2014 and if they already purchased, ask them for the license key from their Lemon Squeezy receipt, then call activate_license with it. After that, pro installs work like free ones.`;
939
+ var posthog = new PostHog("phc_Cp49ooHFujriAf92MgJgj2spJZ2kyBrJC2uUN8wDRqSV", {
940
+ host: "https://eu.i.posthog.com"
941
+ });
905
942
  var freeIndexPromise = null;
906
943
  var proIndexPromise = null;
907
944
  function freeIndex() {
@@ -1027,6 +1064,7 @@ async function mcp() {
1027
1064
  { name: "boardui", version: CLI_VERSION },
1028
1065
  { instructions: INSTRUCTIONS }
1029
1066
  );
1067
+ instrument(server, posthog);
1030
1068
  server.registerTool(
1031
1069
  "get_started",
1032
1070
  {
@@ -1043,7 +1081,7 @@ ${INSTRUCTIONS}
1043
1081
 
1044
1082
  Pro license on this machine: ${licensed ? "ACTIVE (pro installs unlocked)" : `none yet \u2014 pro items show a purchase link (${PRICING_URL})`}.
1045
1083
 
1046
- Tools: list_components, get_component, get_usage_examples, install_components, init_boardui, install_rules, get_theme, activate_license, license_status, deactivate_license.`
1084
+ Tools: list_components, get_component, get_usage_examples, install_components, init_boardui, install_rules, install_skill, get_theme, activate_license, license_status, deactivate_license.`
1047
1085
  );
1048
1086
  })
1049
1087
  );
@@ -1218,7 +1256,23 @@ ${proItem.example}
1218
1256
  if (installable.length === 0) {
1219
1257
  return text(proPitch(lockedPro));
1220
1258
  }
1221
- const items = await resolveItems(installable);
1259
+ const proNamesSet = new Set(pro.items.map((item) => item.name));
1260
+ let items;
1261
+ let proFailure = null;
1262
+ try {
1263
+ items = await resolveItems(installable);
1264
+ } catch (error) {
1265
+ const freeSubset = installable.filter((name) => !proNamesSet.has(name));
1266
+ const proSubset = installable.filter((name) => proNamesSet.has(name));
1267
+ if (proSubset.length === 0) throw error;
1268
+ proFailure = { names: proSubset, message: error.message };
1269
+ if (freeSubset.length === 0) {
1270
+ return errorText(
1271
+ `Pro item${proSubset.length === 1 ? "" : "s"} (${proSubset.join(", ")}) could not be fetched: ${proFailure.message}`
1272
+ );
1273
+ }
1274
+ items = await resolveItems(freeSubset);
1275
+ }
1222
1276
  const targetRoot = sourceRoot(project);
1223
1277
  const report = writeFiles(collectWrites(items, targetRoot, project.cwd), overwrite);
1224
1278
  const assets = await downloadAssets(items, targetRoot, overwrite);
@@ -1263,6 +1317,13 @@ ${proItem.example}
1263
1317
  NOT installed (pro, no license): ${lockedPro.map((item) => item.name).join(", ")}.
1264
1318
 
1265
1319
  ${proPitch(lockedPro)}`;
1320
+ }
1321
+ if (proFailure) {
1322
+ result += `
1323
+
1324
+ ---
1325
+
1326
+ NOT installed \u2014 pro fetch failed for ${proFailure.names.join(", ")}: ${proFailure.message}`;
1266
1327
  }
1267
1328
  return text(result);
1268
1329
  }
@@ -1362,6 +1423,41 @@ ${proPitch(lockedPro)}`;
1362
1423
  }
1363
1424
  )
1364
1425
  );
1426
+ server.registerTool(
1427
+ "install_skill",
1428
+ {
1429
+ title: "Install the BoardUI agent skill",
1430
+ description: "Writes the BoardUI agent skill into the project's .claude/skills/boardui: SKILL.md with the workflow and design rules, plus reference files carrying the full component catalog, theming guide, page patterns, and the micro-animation language. Agents that support skills then load BoardUI knowledge automatically every session, without MCP calls. Re-run with overwrite to update to the latest content.",
1431
+ inputSchema: {
1432
+ overwrite: z.boolean().optional().describe("Overwrite an existing install (default false: existing files are kept). This is how the skill updates."),
1433
+ projectDir: z.string().optional().describe("Absolute path of the project root; defaults to the server's working directory.")
1434
+ },
1435
+ annotations: { destructiveHint: false }
1436
+ },
1437
+ safe(
1438
+ async ({ overwrite = false, projectDir }) => {
1439
+ const project = loadProject(projectDir);
1440
+ const items = await resolveItems([SKILL_ITEM_NAME]);
1441
+ const targetDir = path7.join(project.cwd, ".claude", "skills", "boardui");
1442
+ const report = writeFiles(collectWrites(items, targetDir), overwrite);
1443
+ const lines = [
1444
+ ...report.created.map((relPath) => ` created .claude/skills/boardui/${relPath}`),
1445
+ ...report.overwritten.map((relPath) => ` updated .claude/skills/boardui/${relPath}`),
1446
+ ...report.skipped.map(
1447
+ (relPath) => ` skipped ${relPath} (exists \u2014 pass overwrite to update)`
1448
+ )
1449
+ ];
1450
+ if (report.created.length + report.overwritten.length > 0) {
1451
+ await trackSkillInstall({ scope: "project", source: "mcp" });
1452
+ lines.push(
1453
+ "",
1454
+ "Skill-capable agents discover it automatically in new sessions (Claude Code loads .claude/skills without configuration)."
1455
+ );
1456
+ }
1457
+ return text(lines.join("\n"));
1458
+ }
1459
+ )
1460
+ );
1365
1461
  server.registerTool(
1366
1462
  "get_theme",
1367
1463
  {
@@ -1391,10 +1487,13 @@ ${proPitch(lockedPro)}`;
1391
1487
  },
1392
1488
  safe(async ({ licenseKey }) => {
1393
1489
  const result = await activateLicense(licenseKey.trim());
1394
- const lines = [
1490
+ const lines = result.warning ? [
1491
+ `License key activated and stored (product: ${result.productName}).`,
1492
+ `Warning: ${result.warning}`,
1493
+ ...result.seatLimit > 0 ? [`Seats in use: ${result.seatsUsed}/${result.seatLimit}.`] : []
1494
+ ] : [
1395
1495
  `License activated for ${result.productName}. Pro installs are unlocked on this machine.`,
1396
1496
  ...result.seatLimit > 0 ? [`Seats in use: ${result.seatsUsed}/${result.seatLimit}.`] : [],
1397
- ...result.warning ? [`Warning: ${result.warning}`] : [],
1398
1497
  "",
1399
1498
  'Try it: install_components with a pro item, e.g. ["agent-progress"].'
1400
1499
  ];
@@ -1405,7 +1504,7 @@ ${proPitch(lockedPro)}`;
1405
1504
  "license_status",
1406
1505
  {
1407
1506
  title: "Check Pro license status",
1408
- description: "Whether a BoardUI Pro license is active on this machine (key is shown masked).",
1507
+ description: "Validates the stored BoardUI Pro license against Lemon Squeezy (product, status, seats) \u2014 not just whether a key file exists. Key is shown masked.",
1409
1508
  annotations: { readOnlyHint: true }
1410
1509
  },
1411
1510
  safe(async () => {
@@ -1415,8 +1514,27 @@ ${proPitch(lockedPro)}`;
1415
1514
  `No Pro license on this machine. Pro items need a one-time purchase: ${PRICING_URL} \u2014 if the user already purchased, ask for their license key and call activate_license.`
1416
1515
  );
1417
1516
  }
1517
+ let validation;
1518
+ try {
1519
+ validation = await validateStoredLicense();
1520
+ } catch {
1521
+ return text(
1522
+ `A license key is stored (${maskKey(license.licenseKey)}) but the license server could not be reached to validate it. Pro installs validate server-side on every download, so try one to find out.`
1523
+ );
1524
+ }
1525
+ if (!validation || !validation.valid) {
1526
+ return text(
1527
+ `A license key is stored (${maskKey(license.licenseKey)}) but Lemon Squeezy rejects it: ${validation?.error ?? "not valid"}. Ask the user to re-check the key from their receipt, or contact hi@boardui.com.`
1528
+ );
1529
+ }
1530
+ const seats = validation.seatLimit && validation.seatLimit > 0 ? ` Seats: ${validation.seatsUsed}/${validation.seatLimit}.` : "";
1531
+ if (validation.unknownProduct) {
1532
+ return text(
1533
+ `License key ${maskKey(license.licenseKey)} is valid and ${validation.status} for "${validation.productName}", which this CLI version does not recognize as BoardUI Pro.${seats} The server has the final say \u2014 try a pro install; if it is refused, update the CLI or contact hi@boardui.com.`
1534
+ );
1535
+ }
1418
1536
  return text(
1419
- `Pro license active: ${maskKey(license.licenseKey)} (${license.instanceName || "stored locally"}). Pro components and templates install like free ones.`
1537
+ `Pro license valid and ${validation.status}: ${maskKey(license.licenseKey)} ("${validation.productName}").${seats} Pro components and templates install like free ones.`
1420
1538
  );
1421
1539
  })
1422
1540
  );
@@ -1433,10 +1551,75 @@ ${proPitch(lockedPro)}`;
1433
1551
  return text("Seat released and license removed from this machine.");
1434
1552
  })
1435
1553
  );
1554
+ process.on("SIGTERM", async () => {
1555
+ await posthog.shutdown();
1556
+ process.exit(0);
1557
+ });
1436
1558
  await server.connect(new StdioServerTransport());
1437
1559
  console.error(`boardui mcp v${CLI_VERSION} ready (stdio)`);
1438
1560
  }
1439
1561
 
1562
+ // src/commands/skill.ts
1563
+ import { existsSync as existsSync7, readFileSync as readFileSync7 } from "fs";
1564
+ import { homedir as homedir3 } from "os";
1565
+ import path8 from "path";
1566
+ import ora3 from "ora";
1567
+ import pc5 from "picocolors";
1568
+ var KNOWN_CLIENTS = ["codex", "gemini"];
1569
+ function installedVersion(targetDir) {
1570
+ try {
1571
+ const skillPath = path8.join(targetDir, "SKILL.md");
1572
+ if (!existsSync7(skillPath)) return null;
1573
+ const match = readFileSync7(skillPath, "utf8").match(/^\s*version:\s*(\S+)\s*$/m);
1574
+ return match?.[1] ?? null;
1575
+ } catch {
1576
+ return null;
1577
+ }
1578
+ }
1579
+ async function skill(options) {
1580
+ if (options.client && !KNOWN_CLIENTS.includes(options.client)) {
1581
+ console.log(
1582
+ pc5.yellow(
1583
+ `warning: unknown client "${options.client}" \u2014 installing to ~/.agents/skills/boardui, the shared convention Codex and Gemini read.`
1584
+ )
1585
+ );
1586
+ }
1587
+ const targetDir = skillTargetDir(options, process.cwd(), homedir3());
1588
+ const before = installedVersion(targetDir);
1589
+ const spinner = ora3("Fetching the BoardUI agent skill...").start();
1590
+ let items;
1591
+ try {
1592
+ items = await resolveItems([SKILL_ITEM_NAME]);
1593
+ } catch (error) {
1594
+ spinner.fail(error.message);
1595
+ process.exitCode = 1;
1596
+ return;
1597
+ }
1598
+ const fetched = items.flatMap((item) => item.files).find((file) => file.target === "SKILL.md")?.content.match(/^\s*version:\s*(\S+)\s*$/m)?.[1];
1599
+ spinner.succeed(
1600
+ before && fetched && before !== fetched ? `Skill fetched (installed ${before} -> ${fetched}).` : `Skill fetched${fetched ? ` (version ${fetched})` : ""}.`
1601
+ );
1602
+ const report = writeFiles(collectWrites(items, targetDir), Boolean(options.force));
1603
+ const shortDir = targetDir.startsWith(homedir3()) ? `~${targetDir.slice(homedir3().length)}` : path8.relative(process.cwd(), targetDir) || ".";
1604
+ for (const relPath of report.created) console.log(` ${pc5.green("created")} ${shortDir}/${relPath}`);
1605
+ for (const relPath of report.overwritten) console.log(` ${pc5.green("updated")} ${shortDir}/${relPath}`);
1606
+ for (const relPath of report.skipped) {
1607
+ console.log(` ${pc5.dim("skipped (exists \u2014 pass --force to update)")} ${relPath}`);
1608
+ }
1609
+ const telemetry = trackSkillInstall({
1610
+ scope: options.path ? "path" : options.client ? "agents" : options.global ? "global" : "project",
1611
+ client: options.client && KNOWN_CLIENTS.includes(options.client) ? options.client : void 0
1612
+ });
1613
+ if (report.created.length + report.overwritten.length > 0) {
1614
+ console.log(
1615
+ `
1616
+ ${pc5.bold("Done.")} Agents that support skills discover it automatically in new sessions.
1617
+ ${pc5.dim("Update any time: npx boardui@latest skill --force")}`
1618
+ );
1619
+ }
1620
+ await telemetry;
1621
+ }
1622
+
1440
1623
  // src/index.ts
1441
1624
  var program = new Command();
1442
1625
  program.name("boardui").description("Add BoardUI components to your project.").version(CLI_VERSION, "-v, --version");
@@ -1452,6 +1635,9 @@ program.command("list").description("List all available components.").action(asy
1452
1635
  program.command("mcp").description("Start the BoardUI MCP server (stdio) so AI agents can browse and install components.").action(async () => {
1453
1636
  await mcp();
1454
1637
  });
1638
+ program.command("skill").description("Install the BoardUI agent skill (SKILL.md + references) so agents like Claude Code and Codex know the design system.").option("-g, --global", "install to ~/.claude/skills/boardui instead of the project's .claude/skills").option("-c, --client <client>", "install to ~/.agents/skills/boardui for clients that read it (codex, gemini)").option("-p, --path <dir>", "custom directory to install the skill into").option("-f, --force", "overwrite an existing install (how you update)").action(async (options) => {
1639
+ await skill(options);
1640
+ });
1455
1641
  program.command("login").description("Activate a BoardUI Pro license key on this machine.").argument("[key]", "license key from your Lemon Squeezy receipt").action(async (key) => {
1456
1642
  await login(key);
1457
1643
  });
@@ -1459,7 +1645,7 @@ program.command("logout").description("Release this machine's Pro seat and remov
1459
1645
  await logout();
1460
1646
  });
1461
1647
  program.parseAsync().catch((error) => {
1462
- console.error(pc5.red(`
1648
+ console.error(pc6.red(`
1463
1649
  ${error.message}`));
1464
1650
  process.exit(1);
1465
1651
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "boardui",
3
- "version": "0.4.1",
3
+ "version": "0.5.0",
4
4
  "description": "Add BoardUI components to your project.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -34,9 +34,11 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "@modelcontextprotocol/sdk": "^1.30.0",
37
+ "@posthog/mcp": "^0.12.0",
37
38
  "commander": "^12.1.0",
38
39
  "ora": "^8.1.1",
39
40
  "picocolors": "^1.1.1",
41
+ "posthog-node": "^5.51.4",
40
42
  "prompts": "^2.4.2",
41
43
  "zod": "^4.5.1"
42
44
  },