boardui 0.3.0 → 0.4.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.
- package/README.md +19 -1
- package/dist/index.js +742 -122
- package/package.json +6 -3
package/README.md
CHANGED
|
@@ -12,6 +12,9 @@ npx boardui@latest add button select date-picker
|
|
|
12
12
|
# browse what's available
|
|
13
13
|
npx boardui@latest list
|
|
14
14
|
|
|
15
|
+
# start the MCP server so AI agents can do all of the above in chat
|
|
16
|
+
npx boardui@latest mcp
|
|
17
|
+
|
|
15
18
|
# activate BoardUI Pro, then install a Pro component or template
|
|
16
19
|
npx boardui@latest login YOUR_LICENSE_KEY
|
|
17
20
|
npx boardui@latest add calendar template-ai-chat
|
|
@@ -24,7 +27,10 @@ npx boardui@latest add calendar template-ai-chat
|
|
|
24
27
|
Prepares an existing Next.js project: installs runtime dependencies
|
|
25
28
|
(`react-aria-components`, `tailwind-merge`, `@remixicon/react`, Tailwind v4),
|
|
26
29
|
writes `styles/theme.css`, `styles/typography.css`, `styles/globals.css`,
|
|
27
|
-
`utils/cx.ts`, and prints wiring instructions.
|
|
30
|
+
`utils/cx.ts`, and prints wiring instructions. Also installs BoardUI's
|
|
31
|
+
always-on design rules for AI agents (semantic tokens, type scale,
|
|
32
|
+
conventions) as a fenced section in `AGENTS.md` plus a Cursor rule at
|
|
33
|
+
`.cursor/rules/boardui.mdc` — MCP context is on-demand, these are not.
|
|
28
34
|
|
|
29
35
|
| Option | Description |
|
|
30
36
|
| --- | --- |
|
|
@@ -52,6 +58,18 @@ an interactive picker.
|
|
|
52
58
|
|
|
53
59
|
Prints all available components grouped by type.
|
|
54
60
|
|
|
61
|
+
### `mcp`
|
|
62
|
+
|
|
63
|
+
Starts the BoardUI MCP server over stdio for AI agents (Claude Code, Cursor,
|
|
64
|
+
VS Code, Codex, and any MCP client). Tools cover listing components (free and
|
|
65
|
+
Pro), reading source and docs usage examples, installing components/templates
|
|
66
|
+
by writing files directly, one-time project init, theme tokens, and Pro
|
|
67
|
+
license activation/status/deactivation. Setup guide with per-client config:
|
|
68
|
+
https://www.boardui.com/mcp
|
|
69
|
+
|
|
70
|
+
Successful MCP-driven installs send the same anonymous telemetry as the CLI,
|
|
71
|
+
tagged with `source: "mcp"`.
|
|
72
|
+
|
|
55
73
|
### `login [key]`
|
|
56
74
|
|
|
57
75
|
Activates a BoardUI Pro license for this machine and stores the license and
|
package/dist/index.js
CHANGED
|
@@ -5,12 +5,15 @@ import { Command } from "commander";
|
|
|
5
5
|
import pc5 from "picocolors";
|
|
6
6
|
|
|
7
7
|
// src/commands/add.ts
|
|
8
|
-
import
|
|
9
|
-
import path4 from "path";
|
|
8
|
+
import path5 from "path";
|
|
10
9
|
import ora from "ora";
|
|
11
10
|
import pc from "picocolors";
|
|
12
11
|
import prompts from "prompts";
|
|
13
12
|
|
|
13
|
+
// src/lib/installer.ts
|
|
14
|
+
import { existsSync as existsSync3, mkdirSync as mkdirSync2, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "fs";
|
|
15
|
+
import path3 from "path";
|
|
16
|
+
|
|
14
17
|
// src/lib/install.ts
|
|
15
18
|
import { spawn } from "child_process";
|
|
16
19
|
|
|
@@ -136,7 +139,7 @@ import { existsSync as existsSync2, mkdirSync, readFileSync as readFileSync2, rm
|
|
|
136
139
|
import { homedir, hostname } from "os";
|
|
137
140
|
import path2 from "path";
|
|
138
141
|
var LICENSE_API = "https://api.lemonsqueezy.com/v1/licenses";
|
|
139
|
-
var PRO_PRODUCT_IDS = /* @__PURE__ */ new Set([1220683
|
|
142
|
+
var PRO_PRODUCT_IDS = /* @__PURE__ */ new Set([1220683]);
|
|
140
143
|
function configRoot() {
|
|
141
144
|
if (process.env.XDG_CONFIG_HOME) return process.env.XDG_CONFIG_HOME;
|
|
142
145
|
if (process.platform === "win32" && process.env.APPDATA) return process.env.APPDATA;
|
|
@@ -245,6 +248,9 @@ function proRegistryBaseUrl() {
|
|
|
245
248
|
function assetsBaseUrl() {
|
|
246
249
|
return (process.env.BOARDUI_ASSETS_URL ?? "https://www.boardui.com").replace(/\/$/, "");
|
|
247
250
|
}
|
|
251
|
+
async function fetchProIndex() {
|
|
252
|
+
return fetchJson(`${registryBaseUrl()}/registry-pro.json`);
|
|
253
|
+
}
|
|
248
254
|
async function fetchJson(url) {
|
|
249
255
|
let response;
|
|
250
256
|
try {
|
|
@@ -335,16 +341,130 @@ async function resolveItems(names) {
|
|
|
335
341
|
return ordered;
|
|
336
342
|
}
|
|
337
343
|
|
|
344
|
+
// src/lib/installer.ts
|
|
345
|
+
var RUNTIME_DEPS = ["react-aria-components", "tailwind-merge", "@remixicon/react"];
|
|
346
|
+
var DEV_DEPS = ["tailwindcss", "@tailwindcss/postcss"];
|
|
347
|
+
var PRO_DEPS = ["recharts", "motion", "prism-react-renderer", "@internationalized/date"];
|
|
348
|
+
var INIT_ITEMS = ["globals", "cx", "use-dismiss-on-outside-press", "rules"];
|
|
349
|
+
var RULES_ITEM_NAME = "rules";
|
|
350
|
+
var RULES_START_MARKER = "<!-- boardui:rules:start -->";
|
|
351
|
+
var RULES_END_MARKER = "<!-- boardui:rules:end -->";
|
|
352
|
+
function stripFrontmatter(markdown) {
|
|
353
|
+
const match = markdown.match(/^---\n[\s\S]*?\n---\n/);
|
|
354
|
+
return match ? markdown.slice(match[0].length) : markdown;
|
|
355
|
+
}
|
|
356
|
+
function syncAgentsRules(projectCwd, rulesMarkdown) {
|
|
357
|
+
const block = `${RULES_START_MARKER}
|
|
358
|
+
${stripFrontmatter(rulesMarkdown).trim()}
|
|
359
|
+
${RULES_END_MARKER}`;
|
|
360
|
+
const agentsPath = path3.join(projectCwd, "AGENTS.md");
|
|
361
|
+
if (!existsSync3(agentsPath)) {
|
|
362
|
+
writeFileSync2(agentsPath, `${block}
|
|
363
|
+
`);
|
|
364
|
+
return "created";
|
|
365
|
+
}
|
|
366
|
+
const current = readFileSync3(agentsPath, "utf8");
|
|
367
|
+
const start = current.indexOf(RULES_START_MARKER);
|
|
368
|
+
const end = current.indexOf(RULES_END_MARKER);
|
|
369
|
+
if (start !== -1 && end > start) {
|
|
370
|
+
const next = current.slice(0, start) + block + current.slice(end + RULES_END_MARKER.length);
|
|
371
|
+
writeFileSync2(agentsPath, next);
|
|
372
|
+
return "updated";
|
|
373
|
+
}
|
|
374
|
+
writeFileSync2(agentsPath, `${current.trimEnd()}
|
|
375
|
+
|
|
376
|
+
${block}
|
|
377
|
+
`);
|
|
378
|
+
return "appended";
|
|
379
|
+
}
|
|
380
|
+
function collectWrites(items, targetRoot, rootAnchor = targetRoot) {
|
|
381
|
+
const writesByPath = /* @__PURE__ */ new Map();
|
|
382
|
+
for (const item of items) {
|
|
383
|
+
for (const file of item.files) {
|
|
384
|
+
const relPath = file.target ?? file.path;
|
|
385
|
+
const absPath = path3.join(relPath.startsWith(".") ? rootAnchor : targetRoot, relPath);
|
|
386
|
+
const pending = writesByPath.get(absPath);
|
|
387
|
+
if (pending) {
|
|
388
|
+
if (pending.content !== file.content) {
|
|
389
|
+
throw new Error(`Registry items resolve to conflicting content for ${relPath}.`);
|
|
390
|
+
}
|
|
391
|
+
continue;
|
|
392
|
+
}
|
|
393
|
+
writesByPath.set(absPath, {
|
|
394
|
+
absPath,
|
|
395
|
+
relPath,
|
|
396
|
+
content: file.content,
|
|
397
|
+
exists: existsSync3(absPath)
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
return [...writesByPath.values()];
|
|
402
|
+
}
|
|
403
|
+
function writeFiles(writes, overwrite) {
|
|
404
|
+
const report = { created: [], overwritten: [], skipped: [] };
|
|
405
|
+
for (const write of writes) {
|
|
406
|
+
if (write.exists && !overwrite) {
|
|
407
|
+
report.skipped.push(write.relPath);
|
|
408
|
+
continue;
|
|
409
|
+
}
|
|
410
|
+
mkdirSync2(path3.dirname(write.absPath), { recursive: true });
|
|
411
|
+
writeFileSync2(write.absPath, write.content);
|
|
412
|
+
(write.exists ? report.overwritten : report.created).push(write.relPath);
|
|
413
|
+
}
|
|
414
|
+
return report;
|
|
415
|
+
}
|
|
416
|
+
async function downloadAssets(items, targetRoot, overwrite) {
|
|
417
|
+
const report = { fetched: [], skipped: [], failed: [] };
|
|
418
|
+
for (const asset of items.flatMap((item) => item.assets ?? [])) {
|
|
419
|
+
const absPath = path3.join(targetRoot, asset.target);
|
|
420
|
+
if (existsSync3(absPath) && !overwrite) {
|
|
421
|
+
report.skipped.push(asset.target);
|
|
422
|
+
continue;
|
|
423
|
+
}
|
|
424
|
+
try {
|
|
425
|
+
const response = await fetch(`${assetsBaseUrl()}${asset.url}`);
|
|
426
|
+
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
|
427
|
+
mkdirSync2(path3.dirname(absPath), { recursive: true });
|
|
428
|
+
writeFileSync2(absPath, Buffer.from(await response.arrayBuffer()));
|
|
429
|
+
report.fetched.push(asset.target);
|
|
430
|
+
} catch {
|
|
431
|
+
report.failed.push(asset.target);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
return report;
|
|
435
|
+
}
|
|
436
|
+
function missingDependencies(items, project) {
|
|
437
|
+
const wanted = /* @__PURE__ */ new Map();
|
|
438
|
+
for (const item of items) {
|
|
439
|
+
for (const spec of item.dependencies ?? []) {
|
|
440
|
+
const at = spec.lastIndexOf("@");
|
|
441
|
+
const pkg = at > 0 ? spec.slice(0, at) : spec;
|
|
442
|
+
if (!project.installedDependencies.has(pkg)) wanted.set(pkg, spec);
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
return wanted;
|
|
446
|
+
}
|
|
447
|
+
async function installMissingDependencies(project, wanted) {
|
|
448
|
+
const packages = [...wanted.values()];
|
|
449
|
+
if (packages.length === 0) return { installed: [] };
|
|
450
|
+
try {
|
|
451
|
+
await installPackages(project.packageManager, packages, project.cwd);
|
|
452
|
+
return { installed: packages };
|
|
453
|
+
} catch (error) {
|
|
454
|
+
return { installed: [], error: error.message };
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
|
|
338
458
|
// src/lib/telemetry.ts
|
|
339
459
|
import { randomUUID } from "crypto";
|
|
340
|
-
import { existsSync as
|
|
460
|
+
import { existsSync as existsSync4, mkdirSync as mkdirSync3, readFileSync as readFileSync5, writeFileSync as writeFileSync3 } from "fs";
|
|
341
461
|
import { homedir as homedir2 } from "os";
|
|
342
|
-
import
|
|
462
|
+
import path4 from "path";
|
|
343
463
|
|
|
344
464
|
// src/version.ts
|
|
345
|
-
import { readFileSync as
|
|
465
|
+
import { readFileSync as readFileSync4 } from "fs";
|
|
346
466
|
var packageJson = JSON.parse(
|
|
347
|
-
|
|
467
|
+
readFileSync4(new URL("../package.json", import.meta.url), "utf8")
|
|
348
468
|
);
|
|
349
469
|
var CLI_VERSION = packageJson.version;
|
|
350
470
|
|
|
@@ -360,23 +480,23 @@ function isTelemetryEnabled() {
|
|
|
360
480
|
function configRoot2() {
|
|
361
481
|
if (process.env.XDG_CONFIG_HOME) return process.env.XDG_CONFIG_HOME;
|
|
362
482
|
if (process.platform === "win32" && process.env.APPDATA) return process.env.APPDATA;
|
|
363
|
-
return
|
|
483
|
+
return path4.join(homedir2(), ".config");
|
|
364
484
|
}
|
|
365
485
|
function anonymousIdFile() {
|
|
366
|
-
return
|
|
486
|
+
return path4.join(configRoot2(), "boardui", "telemetry.json");
|
|
367
487
|
}
|
|
368
488
|
function getAnonymousId() {
|
|
369
489
|
const file = anonymousIdFile();
|
|
370
490
|
try {
|
|
371
|
-
if (
|
|
372
|
-
const stored = JSON.parse(
|
|
491
|
+
if (existsSync4(file)) {
|
|
492
|
+
const stored = JSON.parse(readFileSync5(file, "utf8"));
|
|
373
493
|
if (typeof stored.anonymousId === "string" && UUID_V4_RE.test(stored.anonymousId)) {
|
|
374
494
|
return stored.anonymousId;
|
|
375
495
|
}
|
|
376
496
|
}
|
|
377
497
|
const anonymousId = randomUUID();
|
|
378
|
-
|
|
379
|
-
|
|
498
|
+
mkdirSync3(path4.dirname(file), { recursive: true, mode: 448 });
|
|
499
|
+
writeFileSync3(file, `${JSON.stringify({ anonymousId }, null, 2)}
|
|
380
500
|
`, {
|
|
381
501
|
encoding: "utf8",
|
|
382
502
|
mode: 384
|
|
@@ -410,20 +530,23 @@ async function sendTelemetryEvent(event) {
|
|
|
410
530
|
}
|
|
411
531
|
async function trackInitSuccess({
|
|
412
532
|
packageManager,
|
|
413
|
-
pro
|
|
533
|
+
pro,
|
|
534
|
+
source = "cli"
|
|
414
535
|
}) {
|
|
415
|
-
await sendTelemetryEvent({ event: "init", packageManager, pro });
|
|
536
|
+
await sendTelemetryEvent({ event: "init", packageManager, pro, source });
|
|
416
537
|
}
|
|
417
538
|
async function trackAddSuccess({
|
|
418
539
|
packageManager,
|
|
419
|
-
components
|
|
540
|
+
components,
|
|
541
|
+
source = "cli"
|
|
420
542
|
}) {
|
|
421
543
|
const uniqueComponents = [...new Set(components)];
|
|
422
544
|
if (uniqueComponents.length === 0) return;
|
|
423
545
|
await sendTelemetryEvent({
|
|
424
546
|
event: "add",
|
|
425
547
|
packageManager,
|
|
426
|
-
components: uniqueComponents
|
|
548
|
+
components: uniqueComponents,
|
|
549
|
+
source
|
|
427
550
|
});
|
|
428
551
|
}
|
|
429
552
|
|
|
@@ -492,109 +615,52 @@ async function add(components, options) {
|
|
|
492
615
|
spinner.succeed(
|
|
493
616
|
`Resolved ${items.length} item${items.length === 1 ? "" : "s"}: ${items.map((i) => i.name).join(", ")}`
|
|
494
617
|
);
|
|
495
|
-
const targetRoot = options.path ?
|
|
496
|
-
const
|
|
497
|
-
for (const item of items) {
|
|
498
|
-
for (const file of item.files) {
|
|
499
|
-
const relPath = file.target ?? file.path;
|
|
500
|
-
const absPath = path4.join(targetRoot, relPath);
|
|
501
|
-
const pending = writesByPath.get(absPath);
|
|
502
|
-
if (pending) {
|
|
503
|
-
if (pending.content !== file.content) {
|
|
504
|
-
throw new Error(
|
|
505
|
-
`Registry items resolve to conflicting content for ${relPath}.`
|
|
506
|
-
);
|
|
507
|
-
}
|
|
508
|
-
continue;
|
|
509
|
-
}
|
|
510
|
-
writesByPath.set(absPath, {
|
|
511
|
-
absPath,
|
|
512
|
-
relPath,
|
|
513
|
-
content: file.content,
|
|
514
|
-
exists: existsSync4(absPath)
|
|
515
|
-
});
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
const writes = [...writesByPath.values()];
|
|
618
|
+
const targetRoot = options.path ? path5.resolve(process.cwd(), options.path) : options.dir ? path5.resolve(process.cwd(), options.dir) : sourceRoot(project);
|
|
619
|
+
const writes = collectWrites(items, targetRoot, project.cwd);
|
|
519
620
|
const conflicts = writes.filter((w) => w.exists);
|
|
520
|
-
let
|
|
521
|
-
if (conflicts.length > 0 && !options.
|
|
522
|
-
|
|
523
|
-
skipExisting = true;
|
|
524
|
-
} else {
|
|
525
|
-
console.log(pc.yellow(`
|
|
621
|
+
let overwrite = Boolean(options.overwrite);
|
|
622
|
+
if (conflicts.length > 0 && !overwrite && !options.yes) {
|
|
623
|
+
console.log(pc.yellow(`
|
|
526
624
|
The following files already exist:`));
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
}
|
|
542
|
-
skipExisting = action === "skip";
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
let written = 0;
|
|
546
|
-
let skipped = 0;
|
|
547
|
-
for (const write of writes) {
|
|
548
|
-
if (write.exists && skipExisting) {
|
|
549
|
-
skipped++;
|
|
550
|
-
continue;
|
|
625
|
+
for (const c of conflicts) console.log(` ${c.relPath}`);
|
|
626
|
+
const { action } = await prompts({
|
|
627
|
+
type: "select",
|
|
628
|
+
name: "action",
|
|
629
|
+
message: "How should existing files be handled?",
|
|
630
|
+
choices: [
|
|
631
|
+
{ title: "Skip existing files", value: "skip" },
|
|
632
|
+
{ title: "Overwrite existing files", value: "overwrite" },
|
|
633
|
+
{ title: "Cancel", value: "cancel" }
|
|
634
|
+
]
|
|
635
|
+
});
|
|
636
|
+
if (!action || action === "cancel") {
|
|
637
|
+
console.log("Cancelled.");
|
|
638
|
+
return;
|
|
551
639
|
}
|
|
552
|
-
|
|
553
|
-
writeFileSync3(write.absPath, write.content);
|
|
554
|
-
written++;
|
|
555
|
-
console.log(` ${pc.green(write.exists ? "overwrote" : "created")} ${write.relPath}`);
|
|
640
|
+
overwrite = action === "overwrite";
|
|
556
641
|
}
|
|
642
|
+
const report = writeFiles(writes, overwrite);
|
|
643
|
+
for (const relPath of report.created) console.log(` ${pc.green("created")} ${relPath}`);
|
|
644
|
+
for (const relPath of report.overwritten) console.log(` ${pc.green("overwrote")} ${relPath}`);
|
|
645
|
+
const skipped = report.skipped.length;
|
|
557
646
|
if (skipped > 0) console.log(pc.dim(` skipped ${skipped} existing file${skipped === 1 ? "" : "s"}`));
|
|
558
|
-
const
|
|
559
|
-
if (
|
|
560
|
-
const assetSpinner = ora(
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
const
|
|
564
|
-
|
|
565
|
-
const absPath = path4.join(targetRoot, asset.target);
|
|
566
|
-
if (existsSync4(absPath) && !options.overwrite) {
|
|
567
|
-
assetSkipped++;
|
|
568
|
-
continue;
|
|
569
|
-
}
|
|
570
|
-
try {
|
|
571
|
-
const response = await fetch(`${assetsBaseUrl()}${asset.url}`);
|
|
572
|
-
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
|
573
|
-
mkdirSync3(path4.dirname(absPath), { recursive: true });
|
|
574
|
-
writeFileSync3(absPath, Buffer.from(await response.arrayBuffer()));
|
|
575
|
-
fetched++;
|
|
576
|
-
} catch {
|
|
577
|
-
failures.push(asset.target);
|
|
578
|
-
}
|
|
579
|
-
}
|
|
580
|
-
if (failures.length > 0) {
|
|
647
|
+
const assetCount = items.flatMap((item) => item.assets ?? []).length;
|
|
648
|
+
if (assetCount > 0) {
|
|
649
|
+
const assetSpinner = ora(
|
|
650
|
+
`Downloading ${assetCount} template asset${assetCount === 1 ? "" : "s"}...`
|
|
651
|
+
).start();
|
|
652
|
+
const assets = await downloadAssets(items, targetRoot, Boolean(options.overwrite));
|
|
653
|
+
if (assets.failed.length > 0) {
|
|
581
654
|
assetSpinner.warn(
|
|
582
|
-
`Downloaded ${fetched} asset${fetched === 1 ? "" : "s"}; failed: ${
|
|
655
|
+
`Downloaded ${assets.fetched.length} asset${assets.fetched.length === 1 ? "" : "s"}; failed: ${assets.failed.join(", ")} \u2014 re-run with --overwrite to retry.`
|
|
583
656
|
);
|
|
584
657
|
} else {
|
|
585
658
|
assetSpinner.succeed(
|
|
586
|
-
`Downloaded ${fetched} asset${fetched === 1 ? "" : "s"}${
|
|
659
|
+
`Downloaded ${assets.fetched.length} asset${assets.fetched.length === 1 ? "" : "s"}${assets.skipped.length > 0 ? ` (${assets.skipped.length} already present)` : ""}.`
|
|
587
660
|
);
|
|
588
661
|
}
|
|
589
662
|
}
|
|
590
|
-
const wanted =
|
|
591
|
-
for (const item of items) {
|
|
592
|
-
for (const spec of item.dependencies ?? []) {
|
|
593
|
-
const at = spec.lastIndexOf("@");
|
|
594
|
-
const pkg = at > 0 ? spec.slice(0, at) : spec;
|
|
595
|
-
if (!project.installedDependencies.has(pkg)) wanted.set(pkg, spec);
|
|
596
|
-
}
|
|
597
|
-
}
|
|
663
|
+
const wanted = missingDependencies(items, project);
|
|
598
664
|
if (wanted.size > 0) {
|
|
599
665
|
const packages = [...wanted.values()];
|
|
600
666
|
let install = true;
|
|
@@ -609,12 +675,12 @@ The following files already exist:`));
|
|
|
609
675
|
}
|
|
610
676
|
if (install) {
|
|
611
677
|
const depSpinner = ora(`Installing dependencies with ${project.packageManager}...`).start();
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
depSpinner.
|
|
615
|
-
} catch (error) {
|
|
616
|
-
depSpinner.fail(`Failed to install dependencies: ${error.message}`);
|
|
678
|
+
const deps = await installMissingDependencies(project, wanted);
|
|
679
|
+
if (deps.error) {
|
|
680
|
+
depSpinner.fail(`Failed to install dependencies: ${deps.error}`);
|
|
617
681
|
console.log(pc.dim(`Install manually: ${project.packageManager} add ${packages.join(" ")}`));
|
|
682
|
+
} else {
|
|
683
|
+
depSpinner.succeed("Dependencies installed.");
|
|
618
684
|
}
|
|
619
685
|
} else {
|
|
620
686
|
console.log(pc.dim(`Skipped. Install manually: ${project.packageManager} add ${packages.join(" ")}`));
|
|
@@ -628,6 +694,7 @@ ${pc.bold("Note:")} import the BoardUI styles in your root layout or global css:
|
|
|
628
694
|
${pc.cyan(`@import "../styles/globals.css";`)} ${pc.dim("(adjust the relative path)")}`
|
|
629
695
|
);
|
|
630
696
|
}
|
|
697
|
+
const written = report.created.length + report.overwritten.length;
|
|
631
698
|
console.log(pc.green(`
|
|
632
699
|
Done. ${written} file${written === 1 ? "" : "s"} written.`));
|
|
633
700
|
if (written > 0) {
|
|
@@ -640,14 +707,10 @@ Done. ${written} file${written === 1 ? "" : "s"} written.`));
|
|
|
640
707
|
|
|
641
708
|
// src/commands/init.ts
|
|
642
709
|
import { existsSync as existsSync5, mkdirSync as mkdirSync4, writeFileSync as writeFileSync4 } from "fs";
|
|
643
|
-
import
|
|
710
|
+
import path6 from "path";
|
|
644
711
|
import ora2 from "ora";
|
|
645
712
|
import pc2 from "picocolors";
|
|
646
713
|
import prompts2 from "prompts";
|
|
647
|
-
var RUNTIME_DEPS = ["react-aria-components", "tailwind-merge", "@remixicon/react"];
|
|
648
|
-
var DEV_DEPS = ["tailwindcss", "@tailwindcss/postcss"];
|
|
649
|
-
var PRO_DEPS = ["recharts", "motion", "prism-react-renderer", "@internationalized/date"];
|
|
650
|
-
var INIT_ITEMS = ["globals", "cx", "use-dismiss-on-outside-press"];
|
|
651
714
|
async function init(options) {
|
|
652
715
|
const project = readProject(process.cwd());
|
|
653
716
|
console.log(pc2.bold("\nBoardUI init\n"));
|
|
@@ -670,7 +733,7 @@ async function init(options) {
|
|
|
670
733
|
const { confirmed } = await prompts2({
|
|
671
734
|
type: "confirm",
|
|
672
735
|
name: "confirmed",
|
|
673
|
-
message: `Set up BoardUI in ${
|
|
736
|
+
message: `Set up BoardUI in ${path6.basename(project.cwd)}? (installs Tailwind v4 + runtime deps, writes styles/ and utils/)`,
|
|
674
737
|
initial: true
|
|
675
738
|
});
|
|
676
739
|
if (!confirmed) {
|
|
@@ -706,20 +769,27 @@ async function init(options) {
|
|
|
706
769
|
return;
|
|
707
770
|
}
|
|
708
771
|
spinner.succeed("Foundations fetched.");
|
|
709
|
-
const targetRoot = options.dir ?
|
|
772
|
+
const targetRoot = options.dir ? path6.resolve(process.cwd(), options.dir) : sourceRoot(project);
|
|
710
773
|
for (const item of items) {
|
|
711
774
|
for (const file of item.files) {
|
|
712
775
|
const relPath = file.target ?? file.path;
|
|
713
|
-
const absPath =
|
|
776
|
+
const absPath = path6.join(relPath.startsWith(".") ? project.cwd : targetRoot, relPath);
|
|
714
777
|
if (existsSync5(absPath) && !options.overwrite) {
|
|
715
778
|
console.log(` ${pc2.dim("skipped (exists)")} ${relPath}`);
|
|
716
779
|
continue;
|
|
717
780
|
}
|
|
718
|
-
mkdirSync4(
|
|
781
|
+
mkdirSync4(path6.dirname(absPath), { recursive: true });
|
|
719
782
|
writeFileSync4(absPath, file.content);
|
|
720
783
|
console.log(` ${pc2.green("created")} ${relPath}`);
|
|
721
784
|
}
|
|
722
785
|
}
|
|
786
|
+
const rulesItem = items.find((item) => item.name === RULES_ITEM_NAME);
|
|
787
|
+
if (rulesItem?.files[0]?.content) {
|
|
788
|
+
const outcome = syncAgentsRules(project.cwd, rulesItem.files[0].content);
|
|
789
|
+
console.log(
|
|
790
|
+
` ${pc2.green(outcome === "created" ? "created" : outcome)} AGENTS.md ${pc2.dim("(always-on BoardUI rules for AI agents)")}`
|
|
791
|
+
);
|
|
792
|
+
}
|
|
723
793
|
const globalsPath = project.usesSrcDir ? "src/styles/globals.css" : "styles/globals.css";
|
|
724
794
|
const telemetry = dependenciesReady ? trackInitSuccess({
|
|
725
795
|
packageManager: project.packageManager,
|
|
@@ -813,6 +883,553 @@ async function logout() {
|
|
|
813
883
|
console.log(pc4.green("\u2713 Seat released and license removed from this machine."));
|
|
814
884
|
}
|
|
815
885
|
|
|
886
|
+
// src/commands/mcp.ts
|
|
887
|
+
import { existsSync as existsSync6, readFileSync as readFileSync6 } from "fs";
|
|
888
|
+
import path7 from "path";
|
|
889
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
890
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
891
|
+
import { z } from "zod";
|
|
892
|
+
var PRICING_URL = "https://www.boardui.com/pricing";
|
|
893
|
+
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.
|
|
894
|
+
|
|
895
|
+
Typical flow:
|
|
896
|
+
1. In a project without BoardUI, call init_boardui once (installs Tailwind v4 + runtime deps, writes styles/ and utils/).
|
|
897
|
+
2. Discover with list_components; read source/props with get_component; get working code with get_usage_examples.
|
|
898
|
+
3. Install with install_components \u2014 it writes the files and installs npm deps.
|
|
899
|
+
|
|
900
|
+
Component names are exact \u2014 when unsure, call list_components instead of guessing.
|
|
901
|
+
|
|
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.
|
|
903
|
+
|
|
904
|
+
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.`;
|
|
905
|
+
var freeIndexPromise = null;
|
|
906
|
+
var proIndexPromise = null;
|
|
907
|
+
function freeIndex() {
|
|
908
|
+
freeIndexPromise ??= fetchRegistryIndex().catch((error) => {
|
|
909
|
+
freeIndexPromise = null;
|
|
910
|
+
throw error;
|
|
911
|
+
});
|
|
912
|
+
return freeIndexPromise;
|
|
913
|
+
}
|
|
914
|
+
function proIndex() {
|
|
915
|
+
proIndexPromise ??= fetchProIndex().catch((error) => {
|
|
916
|
+
proIndexPromise = null;
|
|
917
|
+
throw error;
|
|
918
|
+
});
|
|
919
|
+
return proIndexPromise;
|
|
920
|
+
}
|
|
921
|
+
function text(value) {
|
|
922
|
+
return { content: [{ type: "text", text: value }] };
|
|
923
|
+
}
|
|
924
|
+
function errorText(value) {
|
|
925
|
+
return { content: [{ type: "text", text: value }], isError: true };
|
|
926
|
+
}
|
|
927
|
+
function safe(handler) {
|
|
928
|
+
return async (args) => {
|
|
929
|
+
try {
|
|
930
|
+
return await handler(args);
|
|
931
|
+
} catch (error) {
|
|
932
|
+
return errorText(error.message);
|
|
933
|
+
}
|
|
934
|
+
};
|
|
935
|
+
}
|
|
936
|
+
function maskKey(key) {
|
|
937
|
+
return key.length > 8 ? `${key.slice(0, 4)}\u2026${key.slice(-4)}` : "\u2026";
|
|
938
|
+
}
|
|
939
|
+
function loadProject(projectDir) {
|
|
940
|
+
const cwd = projectDir ? path7.resolve(projectDir) : process.cwd();
|
|
941
|
+
try {
|
|
942
|
+
return readProject(cwd);
|
|
943
|
+
} catch {
|
|
944
|
+
throw new Error(
|
|
945
|
+
`No package.json found in ${cwd}. Pass projectDir with the absolute path of the user's project root (the directory containing package.json).`
|
|
946
|
+
);
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
function applyAgentRules(project, items) {
|
|
950
|
+
const rules = items.find((item) => item.name === RULES_ITEM_NAME);
|
|
951
|
+
const content = rules?.files[0]?.content;
|
|
952
|
+
if (!content) return [];
|
|
953
|
+
const outcome = syncAgentsRules(project.cwd, content);
|
|
954
|
+
const verb = outcome === "created" ? "written to a new AGENTS.md" : outcome === "updated" ? "refreshed in AGENTS.md" : "appended to AGENTS.md";
|
|
955
|
+
const lines = [
|
|
956
|
+
`Always-on design rules ${verb} (tokens, type scale, conventions \u2014 loaded by agents every session, unlike on-demand MCP calls).`
|
|
957
|
+
];
|
|
958
|
+
const claudeMd = path7.join(project.cwd, "CLAUDE.md");
|
|
959
|
+
try {
|
|
960
|
+
if (existsSync6(claudeMd) && !readFileSync6(claudeMd, "utf8").includes("AGENTS.md")) {
|
|
961
|
+
lines.push(
|
|
962
|
+
'This project has a CLAUDE.md that does not reference AGENTS.md \u2014 add a "@AGENTS.md" line to it so Claude Code loads the BoardUI rules too.'
|
|
963
|
+
);
|
|
964
|
+
}
|
|
965
|
+
} catch {
|
|
966
|
+
}
|
|
967
|
+
return lines;
|
|
968
|
+
}
|
|
969
|
+
function aliasWarning(project) {
|
|
970
|
+
return project.hasAtAlias ? "" : `
|
|
971
|
+
|
|
972
|
+
Warning: no "@/*" path alias found in tsconfig.json \u2014 BoardUI components import via "@/". Add to tsconfig.json: "compilerOptions": { "paths": { "@/*": ["./*"] } }`;
|
|
973
|
+
}
|
|
974
|
+
function proPitch(items) {
|
|
975
|
+
const listing = items.map((item) => `- ${item.name} (${item.kind}): ${item.title} \u2014 ${item.description}`).join("\n");
|
|
976
|
+
return `The following are BoardUI Pro items, and no Pro license is active on this machine yet:
|
|
977
|
+
|
|
978
|
+
${listing}
|
|
979
|
+
|
|
980
|
+
BoardUI Pro is a one-time purchase with lifetime updates that unlocks every pro component and template: ${PRICING_URL}
|
|
981
|
+
|
|
982
|
+
If the user already purchased Pro, ask them for the license key from their Lemon Squeezy receipt (it was also emailed to them), then call activate_license with it \u2014 after that, install these items again and it will work.`;
|
|
983
|
+
}
|
|
984
|
+
function formatDependencyOutcome(project, wanted, installDependencies, outcome) {
|
|
985
|
+
if (wanted.size === 0) return "All npm dependencies were already installed.";
|
|
986
|
+
const specs = [...wanted.values()].join(" ");
|
|
987
|
+
if (!installDependencies) {
|
|
988
|
+
return `npm dependencies still needed (installDependencies was false): ${project.packageManager} add ${specs}`;
|
|
989
|
+
}
|
|
990
|
+
if (outcome?.error) {
|
|
991
|
+
return `Dependency install failed (${outcome.error}). Run manually: ${project.packageManager} add ${specs}`;
|
|
992
|
+
}
|
|
993
|
+
return `Installed npm dependencies with ${project.packageManager}: ${[...wanted.keys()].join(", ")}.`;
|
|
994
|
+
}
|
|
995
|
+
function formatItemDetail(item, tier) {
|
|
996
|
+
const lines = [
|
|
997
|
+
`# ${item.title} (${item.name})${tier === "pro" ? " \u2014 PRO" : ""}`,
|
|
998
|
+
"",
|
|
999
|
+
item.description,
|
|
1000
|
+
"",
|
|
1001
|
+
...item.meta?.docsUrl ? [`Docs: ${item.meta.docsUrl}`] : [],
|
|
1002
|
+
...item.dependencies.length ? [`npm dependencies: ${item.dependencies.join(", ")}`] : [],
|
|
1003
|
+
...item.registryDependencies.length ? [`BoardUI dependencies (installed automatically): ${item.registryDependencies.join(", ")}`] : []
|
|
1004
|
+
];
|
|
1005
|
+
if (item.meta?.example) {
|
|
1006
|
+
lines.push("", "## Usage example", "", "```tsx", item.meta.example, "```");
|
|
1007
|
+
}
|
|
1008
|
+
lines.push("", "## Source files");
|
|
1009
|
+
for (const file of item.files) {
|
|
1010
|
+
const lang = file.target.endsWith(".css") ? "css" : "tsx";
|
|
1011
|
+
lines.push("", `### ${file.target}`, "", `\`\`\`${lang}`, file.content, "```");
|
|
1012
|
+
}
|
|
1013
|
+
if (item.assets?.length) {
|
|
1014
|
+
lines.push(
|
|
1015
|
+
"",
|
|
1016
|
+
`Plus ${item.assets.length} image asset(s) downloaded from boardui.com on install.`
|
|
1017
|
+
);
|
|
1018
|
+
}
|
|
1019
|
+
lines.push(
|
|
1020
|
+
"",
|
|
1021
|
+
`Install with the install_components tool (also writes the ${item.registryDependencies.length ? "BoardUI dependencies listed above" : "required foundations"} and npm deps).`
|
|
1022
|
+
);
|
|
1023
|
+
return lines.join("\n");
|
|
1024
|
+
}
|
|
1025
|
+
async function mcp() {
|
|
1026
|
+
const server = new McpServer(
|
|
1027
|
+
{ name: "boardui", version: CLI_VERSION },
|
|
1028
|
+
{ instructions: INSTRUCTIONS }
|
|
1029
|
+
);
|
|
1030
|
+
server.registerTool(
|
|
1031
|
+
"get_started",
|
|
1032
|
+
{
|
|
1033
|
+
title: "Get started with BoardUI",
|
|
1034
|
+
description: "Overview of BoardUI and how to use this server: setup, discovering components, installing them, and how BoardUI Pro licensing works. Call this first in a fresh conversation about BoardUI.",
|
|
1035
|
+
annotations: { readOnlyHint: true }
|
|
1036
|
+
},
|
|
1037
|
+
safe(async () => {
|
|
1038
|
+
const licensed = getLicense() !== null;
|
|
1039
|
+
return text(
|
|
1040
|
+
`Welcome to BoardUI \u2014 a React + Tailwind CSS v4 design system with agent-first tooling.
|
|
1041
|
+
|
|
1042
|
+
${INSTRUCTIONS}
|
|
1043
|
+
|
|
1044
|
+
Pro license on this machine: ${licensed ? "ACTIVE (pro installs unlocked)" : `none yet \u2014 pro items show a purchase link (${PRICING_URL})`}.
|
|
1045
|
+
|
|
1046
|
+
Tools: list_components, get_component, get_usage_examples, install_components, init_boardui, install_rules, get_theme, activate_license, license_status, deactivate_license.`
|
|
1047
|
+
);
|
|
1048
|
+
})
|
|
1049
|
+
);
|
|
1050
|
+
server.registerTool(
|
|
1051
|
+
"list_components",
|
|
1052
|
+
{
|
|
1053
|
+
title: "List BoardUI components",
|
|
1054
|
+
description: "Lists every installable BoardUI item with exact names: free foundations/base/application components, plus Pro components and full-page templates. Call before installing anything whose exact name you don't know.",
|
|
1055
|
+
inputSchema: {
|
|
1056
|
+
tier: z.enum(["free", "pro", "all"]).optional().describe("Filter to free items, pro items, or everything (default all).")
|
|
1057
|
+
},
|
|
1058
|
+
annotations: { readOnlyHint: true }
|
|
1059
|
+
},
|
|
1060
|
+
safe(async ({ tier }) => {
|
|
1061
|
+
const filter = tier ?? "all";
|
|
1062
|
+
const sections = [];
|
|
1063
|
+
if (filter !== "pro") {
|
|
1064
|
+
const index = await freeIndex();
|
|
1065
|
+
const groups = [
|
|
1066
|
+
["base", "Base components (free)"],
|
|
1067
|
+
["application", "Application blocks (free)"],
|
|
1068
|
+
["foundations", "Foundations (free)"]
|
|
1069
|
+
];
|
|
1070
|
+
for (const [type, label] of groups) {
|
|
1071
|
+
const items = index.items.filter((item) => item.boarduiType === type);
|
|
1072
|
+
if (items.length === 0) continue;
|
|
1073
|
+
sections.push(
|
|
1074
|
+
`## ${label}
|
|
1075
|
+
${items.map((item) => `- ${item.name}: ${item.description}`).join("\n")}`
|
|
1076
|
+
);
|
|
1077
|
+
}
|
|
1078
|
+
}
|
|
1079
|
+
if (filter !== "free") {
|
|
1080
|
+
const index = await proIndex();
|
|
1081
|
+
const components = index.items.filter((item) => item.kind === "component");
|
|
1082
|
+
const templates = index.items.filter((item) => item.kind === "template");
|
|
1083
|
+
const licensed = getLicense() !== null;
|
|
1084
|
+
const proNote = licensed ? "Pro license active \u2014 these install like free items." : `Requires BoardUI Pro (one-time purchase, lifetime updates): ${PRICING_URL} \u2014 already purchased? Ask the user for their license key and call activate_license.`;
|
|
1085
|
+
sections.push(
|
|
1086
|
+
`## Pro components
|
|
1087
|
+
${proNote}
|
|
1088
|
+
${components.map((item) => `- ${item.name}: ${item.description}`).join("\n")}`
|
|
1089
|
+
);
|
|
1090
|
+
sections.push(
|
|
1091
|
+
`## Pro templates (full pages)
|
|
1092
|
+
${templates.map((item) => `- ${item.name}: ${item.description}`).join("\n")}`
|
|
1093
|
+
);
|
|
1094
|
+
}
|
|
1095
|
+
sections.push(
|
|
1096
|
+
"Next: get_component for source + props, get_usage_examples for working snippets, install_components to add to the project."
|
|
1097
|
+
);
|
|
1098
|
+
return text(sections.join("\n\n"));
|
|
1099
|
+
})
|
|
1100
|
+
);
|
|
1101
|
+
server.registerTool(
|
|
1102
|
+
"get_component",
|
|
1103
|
+
{
|
|
1104
|
+
title: "Get component source",
|
|
1105
|
+
description: "Full detail for one BoardUI item: description, docs URL, npm/BoardUI dependencies, usage example, and complete source files. For unlicensed pro items it returns the purchase/activation instructions instead of source.",
|
|
1106
|
+
inputSchema: {
|
|
1107
|
+
name: z.string().describe('Exact item name from list_components, e.g. "button".')
|
|
1108
|
+
},
|
|
1109
|
+
annotations: { readOnlyHint: true }
|
|
1110
|
+
},
|
|
1111
|
+
safe(async ({ name }) => {
|
|
1112
|
+
const [free, pro] = await Promise.all([freeIndex(), proIndex()]);
|
|
1113
|
+
const proItem = pro.items.find((item2) => item2.name === name);
|
|
1114
|
+
if (proItem && !getLicense()) {
|
|
1115
|
+
const example = proItem.example ? `
|
|
1116
|
+
|
|
1117
|
+
Public usage example (source requires the license):
|
|
1118
|
+
\`\`\`tsx
|
|
1119
|
+
${proItem.example}
|
|
1120
|
+
\`\`\`` : "";
|
|
1121
|
+
return text(proPitch([proItem]) + example);
|
|
1122
|
+
}
|
|
1123
|
+
if (!proItem && !free.items.some((item2) => item2.name === name)) {
|
|
1124
|
+
return errorText(
|
|
1125
|
+
`Unknown component "${name}". Call list_components for the exact names.`
|
|
1126
|
+
);
|
|
1127
|
+
}
|
|
1128
|
+
const item = await fetchRegistryItem(name);
|
|
1129
|
+
return text(formatItemDetail(item, proItem ? "pro" : "free"));
|
|
1130
|
+
})
|
|
1131
|
+
);
|
|
1132
|
+
server.registerTool(
|
|
1133
|
+
"get_usage_examples",
|
|
1134
|
+
{
|
|
1135
|
+
title: "Get usage examples",
|
|
1136
|
+
description: "Working usage snippets for a BoardUI item, straight from its docs page: the main example plus per-section snippets (variants, sizes, ...). Available for pro items too, without a license.",
|
|
1137
|
+
inputSchema: {
|
|
1138
|
+
name: z.string().describe("Exact item name from list_components.")
|
|
1139
|
+
},
|
|
1140
|
+
annotations: { readOnlyHint: true }
|
|
1141
|
+
},
|
|
1142
|
+
safe(async ({ name }) => {
|
|
1143
|
+
const [free, pro] = await Promise.all([freeIndex(), proIndex()]);
|
|
1144
|
+
const proItem = pro.items.find((item2) => item2.name === name);
|
|
1145
|
+
if (proItem) {
|
|
1146
|
+
const lines2 = [
|
|
1147
|
+
`# ${proItem.title} (${proItem.name}) \u2014 PRO`,
|
|
1148
|
+
"",
|
|
1149
|
+
proItem.description,
|
|
1150
|
+
...proItem.docsUrl ? ["", `Docs: ${proItem.docsUrl}`] : []
|
|
1151
|
+
];
|
|
1152
|
+
if (proItem.example) {
|
|
1153
|
+
lines2.push("", "```tsx", proItem.example, "```");
|
|
1154
|
+
} else {
|
|
1155
|
+
lines2.push("", "No public example \u2014 see the docs page for a live preview.");
|
|
1156
|
+
}
|
|
1157
|
+
return text(lines2.join("\n"));
|
|
1158
|
+
}
|
|
1159
|
+
if (!free.items.some((item2) => item2.name === name)) {
|
|
1160
|
+
return errorText(
|
|
1161
|
+
`Unknown component "${name}". Call list_components for the exact names.`
|
|
1162
|
+
);
|
|
1163
|
+
}
|
|
1164
|
+
const item = await fetchRegistryItem(name);
|
|
1165
|
+
const lines = [
|
|
1166
|
+
`# ${item.title} (${item.name})`,
|
|
1167
|
+
"",
|
|
1168
|
+
item.description,
|
|
1169
|
+
...item.meta?.docsUrl ? ["", `Docs: ${item.meta.docsUrl}`] : []
|
|
1170
|
+
];
|
|
1171
|
+
if (item.meta?.example) {
|
|
1172
|
+
lines.push("", "## Example", "", "```tsx", item.meta.example, "```");
|
|
1173
|
+
}
|
|
1174
|
+
for (const snippet of item.meta?.snippets ?? []) {
|
|
1175
|
+
lines.push("", `## ${snippet.label}`, "", "```tsx", snippet.code, "```");
|
|
1176
|
+
}
|
|
1177
|
+
if (!item.meta?.example && !item.meta?.snippets?.length) {
|
|
1178
|
+
lines.push("", "No docs examples for this item \u2014 call get_component for the source.");
|
|
1179
|
+
}
|
|
1180
|
+
return text(lines.join("\n"));
|
|
1181
|
+
})
|
|
1182
|
+
);
|
|
1183
|
+
server.registerTool(
|
|
1184
|
+
"install_components",
|
|
1185
|
+
{
|
|
1186
|
+
title: "Install BoardUI components",
|
|
1187
|
+
description: "Installs BoardUI components/templates into the user's project: writes the source files (plus BoardUI dependencies), downloads template assets, and installs missing npm packages (dependency installation can take a minute). Existing files are skipped unless overwrite is set. Unlicensed pro items are skipped with purchase/activation instructions; free items still install.",
|
|
1188
|
+
inputSchema: {
|
|
1189
|
+
names: z.array(z.string()).min(1).describe('Exact item names from list_components, e.g. ["button", "select"].'),
|
|
1190
|
+
overwrite: z.boolean().optional().describe("Overwrite files that already exist (default false: skip them)."),
|
|
1191
|
+
installDependencies: z.boolean().optional().describe("Install missing npm dependencies with the project's package manager (default true)."),
|
|
1192
|
+
projectDir: z.string().optional().describe("Absolute path of the project root; defaults to the server's working directory.")
|
|
1193
|
+
},
|
|
1194
|
+
annotations: { destructiveHint: false }
|
|
1195
|
+
},
|
|
1196
|
+
safe(
|
|
1197
|
+
async ({
|
|
1198
|
+
names,
|
|
1199
|
+
overwrite = false,
|
|
1200
|
+
installDependencies = true,
|
|
1201
|
+
projectDir
|
|
1202
|
+
}) => {
|
|
1203
|
+
const project = loadProject(projectDir);
|
|
1204
|
+
const [free, pro] = await Promise.all([freeIndex(), proIndex()]);
|
|
1205
|
+
const requested = [...new Set(names)];
|
|
1206
|
+
const unknown = requested.filter(
|
|
1207
|
+
(name) => !free.items.some((item) => item.name === name) && !pro.items.some((item) => item.name === name)
|
|
1208
|
+
);
|
|
1209
|
+
if (unknown.length > 0) {
|
|
1210
|
+
return errorText(
|
|
1211
|
+
`Unknown component${unknown.length === 1 ? "" : "s"}: ${unknown.join(", ")}. Call list_components for the exact names.`
|
|
1212
|
+
);
|
|
1213
|
+
}
|
|
1214
|
+
const licensed = getLicense() !== null;
|
|
1215
|
+
const lockedPro = licensed ? [] : pro.items.filter((item) => requested.includes(item.name));
|
|
1216
|
+
const lockedNames = new Set(lockedPro.map((item) => item.name));
|
|
1217
|
+
const installable = requested.filter((name) => !lockedNames.has(name));
|
|
1218
|
+
if (installable.length === 0) {
|
|
1219
|
+
return text(proPitch(lockedPro));
|
|
1220
|
+
}
|
|
1221
|
+
const items = await resolveItems(installable);
|
|
1222
|
+
const targetRoot = sourceRoot(project);
|
|
1223
|
+
const report = writeFiles(collectWrites(items, targetRoot, project.cwd), overwrite);
|
|
1224
|
+
const assets = await downloadAssets(items, targetRoot, overwrite);
|
|
1225
|
+
const wanted = missingDependencies(items, project);
|
|
1226
|
+
const deps = installDependencies ? await installMissingDependencies(project, wanted) : null;
|
|
1227
|
+
const written = report.created.length + report.overwritten.length;
|
|
1228
|
+
if (written > 0) {
|
|
1229
|
+
await trackAddSuccess({
|
|
1230
|
+
packageManager: project.packageManager,
|
|
1231
|
+
components: installable,
|
|
1232
|
+
source: "mcp"
|
|
1233
|
+
});
|
|
1234
|
+
}
|
|
1235
|
+
const lines = [
|
|
1236
|
+
`Installed ${items.map((item) => item.name).join(", ")} into ${targetRoot}.`,
|
|
1237
|
+
"",
|
|
1238
|
+
...report.created.map((relPath) => ` created ${relPath}`),
|
|
1239
|
+
...report.overwritten.map((relPath) => ` overwrote ${relPath}`),
|
|
1240
|
+
...report.skipped.map(
|
|
1241
|
+
(relPath) => ` skipped ${relPath} (exists \u2014 pass overwrite to replace)`
|
|
1242
|
+
)
|
|
1243
|
+
];
|
|
1244
|
+
if (assets.fetched.length + assets.skipped.length + assets.failed.length > 0) {
|
|
1245
|
+
lines.push(
|
|
1246
|
+
"",
|
|
1247
|
+
`Template assets: ${assets.fetched.length} downloaded${assets.skipped.length ? `, ${assets.skipped.length} already present` : ""}${assets.failed.length ? `, FAILED: ${assets.failed.join(", ")} (retry with overwrite)` : ""}.`
|
|
1248
|
+
);
|
|
1249
|
+
}
|
|
1250
|
+
lines.push("", formatDependencyOutcome(project, wanted, installDependencies, deps));
|
|
1251
|
+
if (items.some((item) => item.name === "globals")) {
|
|
1252
|
+
lines.push(
|
|
1253
|
+
"",
|
|
1254
|
+
'The globals stylesheet was installed \u2014 make sure the root layout imports it: import "@/styles/globals.css"; (replaces the default create-next-app globals.css import).'
|
|
1255
|
+
);
|
|
1256
|
+
}
|
|
1257
|
+
let result = lines.join("\n") + aliasWarning(project);
|
|
1258
|
+
if (lockedPro.length > 0) {
|
|
1259
|
+
result += `
|
|
1260
|
+
|
|
1261
|
+
---
|
|
1262
|
+
|
|
1263
|
+
NOT installed (pro, no license): ${lockedPro.map((item) => item.name).join(", ")}.
|
|
1264
|
+
|
|
1265
|
+
${proPitch(lockedPro)}`;
|
|
1266
|
+
}
|
|
1267
|
+
return text(result);
|
|
1268
|
+
}
|
|
1269
|
+
)
|
|
1270
|
+
);
|
|
1271
|
+
server.registerTool(
|
|
1272
|
+
"init_boardui",
|
|
1273
|
+
{
|
|
1274
|
+
title: "Set up BoardUI in a project",
|
|
1275
|
+
description: "One-time BoardUI setup for an existing (ideally Next.js + TypeScript) project: installs Tailwind v4 and the runtime npm deps, writes the theme/typography/global styles and core utils, and returns the wiring steps. Run before the first install_components in a fresh project. Dependency installation can take a minute.",
|
|
1276
|
+
inputSchema: {
|
|
1277
|
+
pro: z.boolean().optional().describe("Also install the deps BoardUI Pro components use \u2014 recharts, motion, ... (default false)."),
|
|
1278
|
+
overwrite: z.boolean().optional().describe("Overwrite existing style/util files (default false: skip them)."),
|
|
1279
|
+
projectDir: z.string().optional().describe("Absolute path of the project root; defaults to the server's working directory.")
|
|
1280
|
+
},
|
|
1281
|
+
annotations: { destructiveHint: false }
|
|
1282
|
+
},
|
|
1283
|
+
safe(
|
|
1284
|
+
async ({
|
|
1285
|
+
pro = false,
|
|
1286
|
+
overwrite = false,
|
|
1287
|
+
projectDir
|
|
1288
|
+
}) => {
|
|
1289
|
+
const project = loadProject(projectDir);
|
|
1290
|
+
const runtimeDeps = pro ? [...RUNTIME_DEPS, ...PRO_DEPS] : RUNTIME_DEPS;
|
|
1291
|
+
const missing = new Map(
|
|
1292
|
+
[...runtimeDeps, ...DEV_DEPS].filter((pkg) => !project.installedDependencies.has(pkg)).map((pkg) => [pkg, pkg])
|
|
1293
|
+
);
|
|
1294
|
+
const deps = await installMissingDependencies(project, missing);
|
|
1295
|
+
const items = await resolveItems(INIT_ITEMS);
|
|
1296
|
+
const targetRoot = sourceRoot(project);
|
|
1297
|
+
const report = writeFiles(collectWrites(items, targetRoot, project.cwd), overwrite);
|
|
1298
|
+
const rulesLines = applyAgentRules(project, items);
|
|
1299
|
+
if (!deps.error) {
|
|
1300
|
+
await trackInitSuccess({
|
|
1301
|
+
packageManager: project.packageManager,
|
|
1302
|
+
pro,
|
|
1303
|
+
source: "mcp"
|
|
1304
|
+
});
|
|
1305
|
+
}
|
|
1306
|
+
const lines = [
|
|
1307
|
+
`BoardUI initialized in ${project.cwd}.`,
|
|
1308
|
+
...project.isNextJs ? [] : [
|
|
1309
|
+
"",
|
|
1310
|
+
"Warning: no `next` dependency found \u2014 BoardUI is tested with Next.js + Tailwind v4; continuing anyway."
|
|
1311
|
+
],
|
|
1312
|
+
"",
|
|
1313
|
+
formatDependencyOutcome(project, missing, true, deps),
|
|
1314
|
+
"",
|
|
1315
|
+
...report.created.map((relPath) => ` created ${relPath}`),
|
|
1316
|
+
...report.overwritten.map((relPath) => ` overwrote ${relPath}`),
|
|
1317
|
+
...report.skipped.map((relPath) => ` skipped ${relPath} (already exists)`),
|
|
1318
|
+
...rulesLines.length ? ["", ...rulesLines] : [],
|
|
1319
|
+
"",
|
|
1320
|
+
"Finish the wiring:",
|
|
1321
|
+
'1. Import the BoardUI stylesheet in the root layout (app/layout.tsx): import "@/styles/globals.css"; \u2014 replacing the default create-next-app "./globals.css" import.',
|
|
1322
|
+
'2. Make sure PostCSS uses Tailwind v4 (postcss.config.mjs): export default { plugins: { "@tailwindcss/postcss": {} } };',
|
|
1323
|
+
'3. Install components with install_components, e.g. ["button", "select", "date-picker"].'
|
|
1324
|
+
];
|
|
1325
|
+
return text(lines.join("\n") + aliasWarning(project));
|
|
1326
|
+
}
|
|
1327
|
+
)
|
|
1328
|
+
);
|
|
1329
|
+
server.registerTool(
|
|
1330
|
+
"install_rules",
|
|
1331
|
+
{
|
|
1332
|
+
title: "Install always-on design rules",
|
|
1333
|
+
description: "Writes BoardUI's always-on design rules into the project: a fenced section in AGENTS.md plus .cursor/rules/boardui.mdc, so agents apply the tokens/type-scale conventions every session without needing an MCP call. init_boardui already does this \u2014 call this on projects initialized before rules existed, or to pull the latest rules.",
|
|
1334
|
+
inputSchema: {
|
|
1335
|
+
overwrite: z.boolean().optional().describe("Overwrite an existing .cursor/rules/boardui.mdc (default false: keep it). The AGENTS.md section is always refreshed in place."),
|
|
1336
|
+
projectDir: z.string().optional().describe("Absolute path of the project root; defaults to the server's working directory.")
|
|
1337
|
+
},
|
|
1338
|
+
annotations: { destructiveHint: false }
|
|
1339
|
+
},
|
|
1340
|
+
safe(
|
|
1341
|
+
async ({ overwrite = false, projectDir }) => {
|
|
1342
|
+
const project = loadProject(projectDir);
|
|
1343
|
+
const items = await resolveItems([RULES_ITEM_NAME]);
|
|
1344
|
+
const report = writeFiles(
|
|
1345
|
+
collectWrites(items, sourceRoot(project), project.cwd),
|
|
1346
|
+
overwrite
|
|
1347
|
+
);
|
|
1348
|
+
const lines = [
|
|
1349
|
+
...report.created.map((relPath) => ` created ${relPath}`),
|
|
1350
|
+
...report.overwritten.map((relPath) => ` overwrote ${relPath}`),
|
|
1351
|
+
...report.skipped.map((relPath) => ` skipped ${relPath} (exists \u2014 pass overwrite to replace)`),
|
|
1352
|
+
...applyAgentRules(project, items)
|
|
1353
|
+
];
|
|
1354
|
+
return text(lines.join("\n"));
|
|
1355
|
+
}
|
|
1356
|
+
)
|
|
1357
|
+
);
|
|
1358
|
+
server.registerTool(
|
|
1359
|
+
"get_theme",
|
|
1360
|
+
{
|
|
1361
|
+
title: "Get theme tokens",
|
|
1362
|
+
description: "The BoardUI theme foundations: color primitives + semantic tokens (theme.css), the type scale (typography.css), and the Tailwind entry stylesheet (globals.css). Use when restyling components or mapping BoardUI tokens onto a brand.",
|
|
1363
|
+
annotations: { readOnlyHint: true }
|
|
1364
|
+
},
|
|
1365
|
+
safe(async () => {
|
|
1366
|
+
const items = await resolveItems(["globals"]);
|
|
1367
|
+
const lines = [];
|
|
1368
|
+
for (const item of items) {
|
|
1369
|
+
for (const file of item.files) {
|
|
1370
|
+
lines.push(`## ${file.target}`, "", "```css", file.content, "```", "");
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
return text(lines.join("\n"));
|
|
1374
|
+
})
|
|
1375
|
+
);
|
|
1376
|
+
server.registerTool(
|
|
1377
|
+
"activate_license",
|
|
1378
|
+
{
|
|
1379
|
+
title: "Activate a BoardUI Pro license",
|
|
1380
|
+
description: "Activates a BoardUI Pro license key on this machine (uses one of the license's seats) and stores it for future installs \u2014 pro components/templates then install like free ones. Ask the user for the key from their Lemon Squeezy receipt; never invent one.",
|
|
1381
|
+
inputSchema: {
|
|
1382
|
+
licenseKey: z.string().describe("The BoardUI Pro license key from the user's Lemon Squeezy receipt.")
|
|
1383
|
+
}
|
|
1384
|
+
},
|
|
1385
|
+
safe(async ({ licenseKey }) => {
|
|
1386
|
+
const result = await activateLicense(licenseKey.trim());
|
|
1387
|
+
const lines = [
|
|
1388
|
+
`License activated for ${result.productName}. Pro installs are unlocked on this machine.`,
|
|
1389
|
+
...result.seatLimit > 0 ? [`Seats in use: ${result.seatsUsed}/${result.seatLimit}.`] : [],
|
|
1390
|
+
...result.warning ? [`Warning: ${result.warning}`] : [],
|
|
1391
|
+
"",
|
|
1392
|
+
'Try it: install_components with a pro item, e.g. ["agent-progress"].'
|
|
1393
|
+
];
|
|
1394
|
+
return text(lines.join("\n"));
|
|
1395
|
+
})
|
|
1396
|
+
);
|
|
1397
|
+
server.registerTool(
|
|
1398
|
+
"license_status",
|
|
1399
|
+
{
|
|
1400
|
+
title: "Check Pro license status",
|
|
1401
|
+
description: "Whether a BoardUI Pro license is active on this machine (key is shown masked).",
|
|
1402
|
+
annotations: { readOnlyHint: true }
|
|
1403
|
+
},
|
|
1404
|
+
safe(async () => {
|
|
1405
|
+
const license = getLicense();
|
|
1406
|
+
if (!license) {
|
|
1407
|
+
return text(
|
|
1408
|
+
`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.`
|
|
1409
|
+
);
|
|
1410
|
+
}
|
|
1411
|
+
return text(
|
|
1412
|
+
`Pro license active: ${maskKey(license.licenseKey)} (${license.instanceName || "stored locally"}). Pro components and templates install like free ones.`
|
|
1413
|
+
);
|
|
1414
|
+
})
|
|
1415
|
+
);
|
|
1416
|
+
server.registerTool(
|
|
1417
|
+
"deactivate_license",
|
|
1418
|
+
{
|
|
1419
|
+
title: "Deactivate the Pro license",
|
|
1420
|
+
description: "Releases this machine's BoardUI Pro seat and removes the stored key. Only call when the user explicitly asks to log out / move the seat to another machine."
|
|
1421
|
+
},
|
|
1422
|
+
safe(async () => {
|
|
1423
|
+
const license = getLicense();
|
|
1424
|
+
if (!license) return text("No license is stored on this machine.");
|
|
1425
|
+
await deactivateLicense();
|
|
1426
|
+
return text("Seat released and license removed from this machine.");
|
|
1427
|
+
})
|
|
1428
|
+
);
|
|
1429
|
+
await server.connect(new StdioServerTransport());
|
|
1430
|
+
console.error(`boardui mcp v${CLI_VERSION} ready (stdio)`);
|
|
1431
|
+
}
|
|
1432
|
+
|
|
816
1433
|
// src/index.ts
|
|
817
1434
|
var program = new Command();
|
|
818
1435
|
program.name("boardui").description("Add BoardUI components to your project.").version(CLI_VERSION, "-v, --version");
|
|
@@ -825,6 +1442,9 @@ program.command("add").description("Add components to your project.").argument("
|
|
|
825
1442
|
program.command("list").description("List all available components.").action(async () => {
|
|
826
1443
|
await list();
|
|
827
1444
|
});
|
|
1445
|
+
program.command("mcp").description("Start the BoardUI MCP server (stdio) so AI agents can browse and install components.").action(async () => {
|
|
1446
|
+
await mcp();
|
|
1447
|
+
});
|
|
828
1448
|
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) => {
|
|
829
1449
|
await login(key);
|
|
830
1450
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "boardui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Add BoardUI components to your project.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -20,7 +20,8 @@
|
|
|
20
20
|
"components",
|
|
21
21
|
"react",
|
|
22
22
|
"tailwindcss",
|
|
23
|
-
"cli"
|
|
23
|
+
"cli",
|
|
24
|
+
"mcp"
|
|
24
25
|
],
|
|
25
26
|
"homepage": "https://www.boardui.com/docs/cli",
|
|
26
27
|
"repository": {
|
|
@@ -32,10 +33,12 @@
|
|
|
32
33
|
"node": ">=18"
|
|
33
34
|
},
|
|
34
35
|
"dependencies": {
|
|
36
|
+
"@modelcontextprotocol/sdk": "^1.30.0",
|
|
35
37
|
"commander": "^12.1.0",
|
|
36
38
|
"ora": "^8.1.1",
|
|
37
39
|
"picocolors": "^1.1.1",
|
|
38
|
-
"prompts": "^2.4.2"
|
|
40
|
+
"prompts": "^2.4.2",
|
|
41
|
+
"zod": "^4.5.1"
|
|
39
42
|
},
|
|
40
43
|
"devDependencies": {
|
|
41
44
|
"@types/node": "^20",
|