boardui 0.5.5 → 0.5.7
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 +98 -0
- package/dist/index.js +293 -115
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -67,6 +67,12 @@ by writing files directly, one-time project init, theme tokens, and Pro
|
|
|
67
67
|
license activation/status/deactivation. Setup guide with per-client config:
|
|
68
68
|
https://www.boardui.com/mcp
|
|
69
69
|
|
|
70
|
+
The server's startup instructions, `get_started`, `get_theme`, and
|
|
71
|
+
`init_boardui` include RTL setup for Arabic and Hebrew: install the free
|
|
72
|
+
`direction` foundation, wrap the app with `DirectionProvider`, and set matching
|
|
73
|
+
HTML language/direction. The guidance covers free and Pro source, logical
|
|
74
|
+
styles, mixed content, fonts, and existing installations.
|
|
75
|
+
|
|
70
76
|
Successful MCP-driven installs send the same anonymous telemetry as the CLI,
|
|
71
77
|
tagged with `source: "mcp"`.
|
|
72
78
|
|
|
@@ -87,6 +93,98 @@ npx boardui@latest login 12CA1606-...
|
|
|
87
93
|
Releases this machine's Lemon Squeezy activation and removes the locally stored
|
|
88
94
|
license.
|
|
89
95
|
|
|
96
|
+
## Custom paths and monorepos
|
|
97
|
+
|
|
98
|
+
Add an optional `boardui.json` next to the **destination package's**
|
|
99
|
+
`package.json`. Without this file, the existing root/`src` layout and `@/`
|
|
100
|
+
imports are unchanged. CLI `init`/`add` and MCP installations read the same
|
|
101
|
+
configuration; free and Pro components both support it.
|
|
102
|
+
|
|
103
|
+
For a shared package named `@workspace/ui` at `packages/ui`, use:
|
|
104
|
+
|
|
105
|
+
```json
|
|
106
|
+
{
|
|
107
|
+
"paths": {
|
|
108
|
+
"components": "src/components",
|
|
109
|
+
"utils": "src/utils",
|
|
110
|
+
"hooks": "src/hooks",
|
|
111
|
+
"styles": "src/styles",
|
|
112
|
+
"lib": "src/lib"
|
|
113
|
+
},
|
|
114
|
+
"aliases": {
|
|
115
|
+
"components": "@workspace/ui/components",
|
|
116
|
+
"utils": "@workspace/ui/utils",
|
|
117
|
+
"hooks": "@workspace/ui/hooks",
|
|
118
|
+
"styles": "@workspace/ui/styles",
|
|
119
|
+
"lib": "@workspace/ui/lib"
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Run the commands from that package:
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
cd packages/ui
|
|
128
|
+
npx boardui@latest init
|
|
129
|
+
npx boardui@latest add button
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
The button lands in `src/components/base/buttons/button.tsx`. Its
|
|
133
|
+
`@/utils/cx` import becomes `@workspace/ui/utils/cx`, and its utility lands
|
|
134
|
+
in `src/utils/cx.ts`. Relative imports are adjusted when their destination
|
|
135
|
+
moves. Existing files still skip by default; `--overwrite` replaces them.
|
|
136
|
+
|
|
137
|
+
- Supported groups are `components`, `utils`, `hooks`, `styles`, and `lib`.
|
|
138
|
+
Configure both a path and an alias for each group you change. Omitted
|
|
139
|
+
groups keep the normal source-root path and `@/<group>` alias.
|
|
140
|
+
- Paths are relative to the directory containing `boardui.json` and must
|
|
141
|
+
remain inside that package. Aliases are import prefixes, without `*`.
|
|
142
|
+
They must already resolve through your TypeScript/bundler configuration
|
|
143
|
+
or package exports; BoardUI does not create those mappings for you.
|
|
144
|
+
- Dependencies install into the package where you run the CLI. Configured
|
|
145
|
+
projects also look up parent directories for workspace lockfiles to
|
|
146
|
+
select npm, pnpm, Yarn, or Bun. Run from `packages/ui`, not the monorepo
|
|
147
|
+
root with a path pointing into it.
|
|
148
|
+
- `--path`/`--dir` keep working for unconfigured projects. Combining them
|
|
149
|
+
with configured mappings reports an error before installation; put the
|
|
150
|
+
destination in `boardui.json` instead.
|
|
151
|
+
- `app/` routes stay under the normal source root; `public/` assets and
|
|
152
|
+
`.cursor/` rules stay at the package root. Install full-page templates
|
|
153
|
+
into the consuming app. This feature does not split a template's files
|
|
154
|
+
or dependencies across multiple workspace packages.
|
|
155
|
+
- Changing this config does not relocate previously installed files.
|
|
156
|
+
Use it before the first install, or migrate existing files/imports to
|
|
157
|
+
match the new layout before adding more components.
|
|
158
|
+
|
|
159
|
+
For the shared-package example, the package must expose its source. A
|
|
160
|
+
typical `packages/ui/package.json` exports section is:
|
|
161
|
+
|
|
162
|
+
```json
|
|
163
|
+
{
|
|
164
|
+
"name": "@workspace/ui",
|
|
165
|
+
"exports": {
|
|
166
|
+
"./components/*": "./src/components/*.tsx",
|
|
167
|
+
"./utils/*": "./src/utils/*.ts",
|
|
168
|
+
"./hooks/*": "./src/hooks/*.ts",
|
|
169
|
+
"./styles/*": "./src/styles/*",
|
|
170
|
+
"./lib/*": "./src/lib/*.ts"
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Adapt extensions or explicit exports to your package's files and build
|
|
176
|
+
process. Each app must depend on the workspace package, import
|
|
177
|
+
`@workspace/ui/styles/globals.css`, and include the shared component source
|
|
178
|
+
in Tailwind's source detection. If needed, use Tailwind v4's `@source`
|
|
179
|
+
directive in the app stylesheet, with a path relative to that stylesheet.
|
|
180
|
+
The app's bundler must also compile the package's TypeScript/TSX source.
|
|
181
|
+
|
|
182
|
+
For MCP, pass the absolute `packages/ui` directory as `projectDir` to
|
|
183
|
+
`init_boardui`, `install_components`, and `install_rules`. Also pass it to
|
|
184
|
+
`get_component` and `get_usage_examples` to receive matching imports and
|
|
185
|
+
paths. Without `projectDir`, those read tools return the original registry
|
|
186
|
+
source/examples. Installed agent rules use the configured aliases too.
|
|
187
|
+
|
|
90
188
|
## Environment
|
|
91
189
|
|
|
92
190
|
| Variable | Description |
|
package/dist/index.js
CHANGED
|
@@ -5,27 +5,148 @@ import { Command } from "commander";
|
|
|
5
5
|
import pc6 from "picocolors";
|
|
6
6
|
|
|
7
7
|
// src/commands/add.ts
|
|
8
|
-
import
|
|
8
|
+
import path7 from "path";
|
|
9
9
|
import ora from "ora";
|
|
10
10
|
import pc from "picocolors";
|
|
11
11
|
import prompts from "prompts";
|
|
12
12
|
|
|
13
|
+
// src/lib/config.ts
|
|
14
|
+
import { existsSync, readFileSync } from "fs";
|
|
15
|
+
import path from "path";
|
|
16
|
+
var SOURCE_GROUPS = ["components", "utils", "hooks", "styles", "lib"];
|
|
17
|
+
function object(value, label) {
|
|
18
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
19
|
+
throw new Error(`boardui.json: ${label} must be an object.`);
|
|
20
|
+
}
|
|
21
|
+
return value;
|
|
22
|
+
}
|
|
23
|
+
function readConfig(cwd) {
|
|
24
|
+
const configPath = path.join(cwd, "boardui.json");
|
|
25
|
+
if (!existsSync(configPath)) return void 0;
|
|
26
|
+
let raw;
|
|
27
|
+
try {
|
|
28
|
+
raw = JSON.parse(readFileSync(configPath, "utf8"));
|
|
29
|
+
} catch {
|
|
30
|
+
throw new Error("boardui.json: could not read valid JSON.");
|
|
31
|
+
}
|
|
32
|
+
const config = object(raw, "config");
|
|
33
|
+
for (const key of Object.keys(config)) {
|
|
34
|
+
if (!["$schema", "paths", "aliases"].includes(key)) {
|
|
35
|
+
throw new Error(`boardui.json: unknown option "${key}". Use paths and aliases.`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const paths = object(config.paths === void 0 ? {} : config.paths, "paths");
|
|
39
|
+
const aliases = object(config.aliases === void 0 ? {} : config.aliases, "aliases");
|
|
40
|
+
const result = { paths: {}, aliases: {} };
|
|
41
|
+
for (const key of /* @__PURE__ */ new Set([...Object.keys(paths), ...Object.keys(aliases)])) {
|
|
42
|
+
if (!SOURCE_GROUPS.includes(key)) {
|
|
43
|
+
throw new Error(`boardui.json: unknown source group "${key}". Use ${SOURCE_GROUPS.join(", ")}.`);
|
|
44
|
+
}
|
|
45
|
+
const group = key;
|
|
46
|
+
const destination = paths[group];
|
|
47
|
+
const alias = aliases[group];
|
|
48
|
+
if (typeof destination !== "string" || !destination.trim() || typeof alias !== "string" || !alias.trim()) {
|
|
49
|
+
throw new Error(`boardui.json: configure both paths.${group} and aliases.${group} as non-empty strings.`);
|
|
50
|
+
}
|
|
51
|
+
const relative = path.relative(cwd, path.resolve(cwd, destination));
|
|
52
|
+
if (path.isAbsolute(destination) || path.win32.isAbsolute(destination) || destination.includes("\\") || /[\x00-\x1f*'"`${}]/.test(destination) || relative === ".." || relative.startsWith(`..${path.sep}`)) {
|
|
53
|
+
throw new Error(`boardui.json: paths.${group} must stay inside this package. Run BoardUI from the destination package instead.`);
|
|
54
|
+
}
|
|
55
|
+
const prefix = alias.replace(/\/+$/, "");
|
|
56
|
+
if (!prefix || /^[./]/.test(prefix) || /[^a-zA-Z0-9@#~_./-]/.test(prefix) || prefix.split("/").some((part) => !part || part === "." || part === "..")) {
|
|
57
|
+
throw new Error(`boardui.json: aliases.${group} must be an import prefix without wildcards (for example "@workspace/ui/${group}").`);
|
|
58
|
+
}
|
|
59
|
+
result.paths[group] = destination;
|
|
60
|
+
result.aliases[group] = prefix;
|
|
61
|
+
}
|
|
62
|
+
return result;
|
|
63
|
+
}
|
|
64
|
+
function sourceGroup(relPath) {
|
|
65
|
+
return SOURCE_GROUPS.find((group) => relPath === group || relPath.startsWith(`${group}/`));
|
|
66
|
+
}
|
|
67
|
+
function mappedPath(relPath, targetRoot, cwd, config) {
|
|
68
|
+
const group = sourceGroup(relPath);
|
|
69
|
+
const destination = group && config?.paths[group];
|
|
70
|
+
return destination ? path.resolve(cwd, destination, relPath.slice(group.length + 1)) : path.join(targetRoot, relPath);
|
|
71
|
+
}
|
|
72
|
+
function mappedImport(specifier, config) {
|
|
73
|
+
if (!specifier.startsWith("@/")) return specifier;
|
|
74
|
+
const group = sourceGroup(specifier.slice(2));
|
|
75
|
+
const alias = group && config?.aliases[group];
|
|
76
|
+
return alias ? alias + specifier.slice(group.length + 2) : specifier;
|
|
77
|
+
}
|
|
78
|
+
function checkDirectoryOverride(config, directory) {
|
|
79
|
+
if (directory && config && Object.keys(config.paths).length) {
|
|
80
|
+
throw new Error("Use paths in boardui.json instead of --path/--dir when custom aliases are configured.");
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
function needsAtAlias(config) {
|
|
84
|
+
return SOURCE_GROUPS.some((group) => (config?.aliases[group] ?? `@/${group}`).startsWith("@/"));
|
|
85
|
+
}
|
|
86
|
+
function mappedDocumentation(content, config) {
|
|
87
|
+
if (!config || !Object.keys(config.aliases).length) return content;
|
|
88
|
+
return content.replace(/@\/(?:components|utils|hooks|styles|lib)(?=\/|[\s`'"),.;:\]]|$)/g, (prefix) => mappedImport(prefix, config)).replace(/the `@\/` alias/g, "the aliases configured in `boardui.json`");
|
|
89
|
+
}
|
|
90
|
+
|
|
13
91
|
// src/lib/installer.ts
|
|
14
|
-
import { existsSync as
|
|
15
|
-
import
|
|
92
|
+
import { existsSync as existsSync4, mkdirSync as mkdirSync2, readFileSync as readFileSync4, writeFileSync as writeFileSync2 } from "fs";
|
|
93
|
+
import path5 from "path";
|
|
94
|
+
|
|
95
|
+
// src/lib/imports.ts
|
|
96
|
+
import path2 from "path";
|
|
97
|
+
import ts from "typescript";
|
|
98
|
+
function rewriteImports(content, relPath, targetRoot, cwd, config) {
|
|
99
|
+
if (!config || !Object.keys(config.paths).length || !/\.[cm]?[jt]sx?$/.test(relPath)) return content;
|
|
100
|
+
const source = ts.createSourceFile(relPath, content, ts.ScriptTarget.Latest, true);
|
|
101
|
+
const edits = [];
|
|
102
|
+
const filePath = mappedPath(relPath, targetRoot, cwd, config);
|
|
103
|
+
function rewrite(node) {
|
|
104
|
+
if (!node || !ts.isStringLiteralLike(node)) return;
|
|
105
|
+
const specifier = node.text;
|
|
106
|
+
let replacement = mappedImport(specifier, config);
|
|
107
|
+
if (specifier.startsWith("./") || specifier.startsWith("../")) {
|
|
108
|
+
const referenced = path2.posix.normalize(path2.posix.join(path2.posix.dirname(relPath), specifier));
|
|
109
|
+
const target = mappedPath(referenced, targetRoot, cwd, config);
|
|
110
|
+
let relative = path2.relative(path2.dirname(filePath), target).split(path2.sep).join("/");
|
|
111
|
+
if (!relative.startsWith(".")) relative = `./${relative}`;
|
|
112
|
+
if (path2.resolve(path2.dirname(filePath), specifier) !== target) replacement = relative;
|
|
113
|
+
}
|
|
114
|
+
if (replacement !== specifier) {
|
|
115
|
+
edits.push({ start: node.getStart(source) + 1, end: node.getEnd() - 1, value: replacement });
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
function visit(node) {
|
|
119
|
+
if (ts.isImportDeclaration(node) || ts.isExportDeclaration(node)) rewrite(node.moduleSpecifier);
|
|
120
|
+
else if (ts.isExternalModuleReference(node)) rewrite(node.expression);
|
|
121
|
+
else if (ts.isImportTypeNode(node) && ts.isLiteralTypeNode(node.argument)) rewrite(node.argument.literal);
|
|
122
|
+
else if (ts.isCallExpression(node) && (node.expression.kind === ts.SyntaxKind.ImportKeyword || ts.isIdentifier(node.expression) && node.expression.text === "require")) {
|
|
123
|
+
rewrite(node.arguments[0]);
|
|
124
|
+
}
|
|
125
|
+
ts.forEachChild(node, visit);
|
|
126
|
+
}
|
|
127
|
+
visit(source);
|
|
128
|
+
for (const edit of edits.sort((a, b) => b.start - a.start)) {
|
|
129
|
+
content = content.slice(0, edit.start) + edit.value + content.slice(edit.end);
|
|
130
|
+
}
|
|
131
|
+
return content;
|
|
132
|
+
}
|
|
16
133
|
|
|
17
134
|
// src/lib/install.ts
|
|
18
135
|
import { spawn } from "child_process";
|
|
19
136
|
|
|
20
137
|
// src/lib/project.ts
|
|
21
|
-
import { existsSync, readFileSync } from "fs";
|
|
22
|
-
import
|
|
23
|
-
function detectPackageManager(cwd) {
|
|
24
|
-
if (
|
|
25
|
-
if (
|
|
26
|
-
if (
|
|
138
|
+
import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
|
|
139
|
+
import path3 from "path";
|
|
140
|
+
function detectPackageManager(cwd, searchParents = false) {
|
|
141
|
+
if (existsSync2(path3.join(cwd, "pnpm-lock.yaml"))) return "pnpm";
|
|
142
|
+
if (existsSync2(path3.join(cwd, "yarn.lock"))) return "yarn";
|
|
143
|
+
if (existsSync2(path3.join(cwd, "bun.lock")) || existsSync2(path3.join(cwd, "bun.lockb"))) {
|
|
27
144
|
return "bun";
|
|
28
145
|
}
|
|
146
|
+
if (existsSync2(path3.join(cwd, "package-lock.json"))) return "npm";
|
|
147
|
+
if (searchParents && path3.dirname(cwd) !== cwd) {
|
|
148
|
+
return detectPackageManager(path3.dirname(cwd), true);
|
|
149
|
+
}
|
|
29
150
|
return "npm";
|
|
30
151
|
}
|
|
31
152
|
function installCommand(pm, packages) {
|
|
@@ -79,13 +200,15 @@ function parseJsonc(raw) {
|
|
|
79
200
|
return JSON.parse(out.replace(/,\s*([}\]])/g, "$1"));
|
|
80
201
|
}
|
|
81
202
|
function readProject(cwd) {
|
|
82
|
-
|
|
83
|
-
|
|
203
|
+
cwd = path3.resolve(cwd);
|
|
204
|
+
const pkgPath = path3.join(cwd, "package.json");
|
|
205
|
+
if (!existsSync2(pkgPath)) {
|
|
84
206
|
throw new Error(
|
|
85
207
|
"No package.json found in the current directory. Run this command from your project root."
|
|
86
208
|
);
|
|
87
209
|
}
|
|
88
|
-
const pkg = JSON.parse(
|
|
210
|
+
const pkg = JSON.parse(readFileSync2(pkgPath, "utf8"));
|
|
211
|
+
const config = readConfig(cwd);
|
|
89
212
|
const dependencyVersions = {
|
|
90
213
|
...pkg.devDependencies ?? {},
|
|
91
214
|
...pkg.dependencies ?? {}
|
|
@@ -97,11 +220,11 @@ function readProject(cwd) {
|
|
|
97
220
|
let hasAtAlias = false;
|
|
98
221
|
let aliasBase = ".";
|
|
99
222
|
for (const configName of ["tsconfig.json", "jsconfig.json"]) {
|
|
100
|
-
const configPath =
|
|
101
|
-
if (!
|
|
223
|
+
const configPath = path3.join(cwd, configName);
|
|
224
|
+
if (!existsSync2(configPath)) continue;
|
|
102
225
|
try {
|
|
103
|
-
const
|
|
104
|
-
const atPaths =
|
|
226
|
+
const config2 = parseJsonc(readFileSync2(configPath, "utf8"));
|
|
227
|
+
const atPaths = config2.compilerOptions?.paths?.["@/*"];
|
|
105
228
|
if (atPaths && atPaths.length > 0) {
|
|
106
229
|
hasAtAlias = true;
|
|
107
230
|
aliasBase = atPaths[0].replace(/\/?\*$/, "") || ".";
|
|
@@ -110,10 +233,11 @@ function readProject(cwd) {
|
|
|
110
233
|
}
|
|
111
234
|
break;
|
|
112
235
|
}
|
|
113
|
-
const usesSrcDir =
|
|
236
|
+
const usesSrcDir = existsSync2(path3.join(cwd, "src")) && (aliasBase.includes("src") || existsSync2(path3.join(cwd, "src", "app")) || existsSync2(path3.join(cwd, "src", "pages")));
|
|
114
237
|
return {
|
|
115
238
|
cwd,
|
|
116
|
-
|
|
239
|
+
config,
|
|
240
|
+
packageManager: detectPackageManager(cwd, Boolean(config)),
|
|
117
241
|
isNextJs: installedDependencies.has("next"),
|
|
118
242
|
hasAtAlias,
|
|
119
243
|
usesSrcDir,
|
|
@@ -122,7 +246,7 @@ function readProject(cwd) {
|
|
|
122
246
|
};
|
|
123
247
|
}
|
|
124
248
|
function sourceRoot(project) {
|
|
125
|
-
return project.usesSrcDir ?
|
|
249
|
+
return project.usesSrcDir ? path3.join(project.cwd, "src") : project.cwd;
|
|
126
250
|
}
|
|
127
251
|
|
|
128
252
|
// src/lib/install.ts
|
|
@@ -140,18 +264,18 @@ async function installPackages(pm, packages, cwd) {
|
|
|
140
264
|
}
|
|
141
265
|
|
|
142
266
|
// src/lib/license.ts
|
|
143
|
-
import { existsSync as
|
|
267
|
+
import { existsSync as existsSync3, mkdirSync, readFileSync as readFileSync3, rmSync, writeFileSync } from "fs";
|
|
144
268
|
import { homedir, hostname } from "os";
|
|
145
|
-
import
|
|
269
|
+
import path4 from "path";
|
|
146
270
|
var LICENSE_API = process.env.BOARDUI_LICENSE_API ?? "https://www.boardui.com/api/licenses";
|
|
147
271
|
var PRO_PRODUCT_IDS = /* @__PURE__ */ new Set([1220683, 1268490]);
|
|
148
272
|
function configRoot() {
|
|
149
273
|
if (process.env.XDG_CONFIG_HOME) return process.env.XDG_CONFIG_HOME;
|
|
150
274
|
if (process.platform === "win32" && process.env.APPDATA) return process.env.APPDATA;
|
|
151
|
-
return
|
|
275
|
+
return path4.join(homedir(), ".config");
|
|
152
276
|
}
|
|
153
277
|
function licenseFile() {
|
|
154
|
-
return
|
|
278
|
+
return path4.join(configRoot(), "boardui", "license.json");
|
|
155
279
|
}
|
|
156
280
|
function getLicense() {
|
|
157
281
|
const envKey = process.env.BOARDUI_LICENSE_KEY;
|
|
@@ -164,8 +288,8 @@ function getLicense() {
|
|
|
164
288
|
}
|
|
165
289
|
try {
|
|
166
290
|
const file = licenseFile();
|
|
167
|
-
if (!
|
|
168
|
-
const stored = JSON.parse(
|
|
291
|
+
if (!existsSync3(file)) return null;
|
|
292
|
+
const stored = JSON.parse(readFileSync3(file, "utf8"));
|
|
169
293
|
if (typeof stored.licenseKey !== "string" || stored.licenseKey.length === 0) return null;
|
|
170
294
|
return {
|
|
171
295
|
licenseKey: stored.licenseKey,
|
|
@@ -204,7 +328,7 @@ async function activateLicense(licenseKey) {
|
|
|
204
328
|
throw new Error(data.error ?? "Could not activate this license key.");
|
|
205
329
|
}
|
|
206
330
|
const file = licenseFile();
|
|
207
|
-
mkdirSync(
|
|
331
|
+
mkdirSync(path4.dirname(file), { recursive: true });
|
|
208
332
|
writeFileSync(
|
|
209
333
|
file,
|
|
210
334
|
JSON.stringify(
|
|
@@ -385,10 +509,10 @@ var INIT_ITEMS = ["globals", "cx", "use-dismiss-on-outside-press", "rules"];
|
|
|
385
509
|
var RULES_ITEM_NAME = "rules";
|
|
386
510
|
var SKILL_ITEM_NAME = "skill";
|
|
387
511
|
function skillTargetDir(options, cwd, home) {
|
|
388
|
-
if (options.path) return
|
|
389
|
-
if (options.client) return
|
|
390
|
-
if (options.global) return
|
|
391
|
-
return
|
|
512
|
+
if (options.path) return path5.resolve(cwd, options.path);
|
|
513
|
+
if (options.client) return path5.join(home, ".agents", "skills", "boardui");
|
|
514
|
+
if (options.global) return path5.join(home, ".claude", "skills", "boardui");
|
|
515
|
+
return path5.join(cwd, ".claude", "skills", "boardui");
|
|
392
516
|
}
|
|
393
517
|
var RULES_START_MARKER = "<!-- boardui:rules:start -->";
|
|
394
518
|
var RULES_END_MARKER = "<!-- boardui:rules:end -->";
|
|
@@ -400,13 +524,13 @@ function syncAgentsRules(projectCwd, rulesMarkdown) {
|
|
|
400
524
|
const block = `${RULES_START_MARKER}
|
|
401
525
|
${stripFrontmatter(rulesMarkdown).trim()}
|
|
402
526
|
${RULES_END_MARKER}`;
|
|
403
|
-
const agentsPath =
|
|
404
|
-
if (!
|
|
527
|
+
const agentsPath = path5.join(projectCwd, "AGENTS.md");
|
|
528
|
+
if (!existsSync4(agentsPath)) {
|
|
405
529
|
writeFileSync2(agentsPath, `${block}
|
|
406
530
|
`);
|
|
407
531
|
return "created";
|
|
408
532
|
}
|
|
409
|
-
const current =
|
|
533
|
+
const current = readFileSync4(agentsPath, "utf8");
|
|
410
534
|
const start = current.indexOf(RULES_START_MARKER);
|
|
411
535
|
const end = current.indexOf(RULES_END_MARKER);
|
|
412
536
|
if (start !== -1 && end > start) {
|
|
@@ -423,15 +547,17 @@ ${block}
|
|
|
423
547
|
function isRootAnchored(relPath) {
|
|
424
548
|
return relPath.startsWith(".") || relPath.startsWith("public/");
|
|
425
549
|
}
|
|
426
|
-
function collectWrites(items, targetRoot, rootAnchor = targetRoot) {
|
|
550
|
+
function collectWrites(items, targetRoot, rootAnchor = targetRoot, config) {
|
|
427
551
|
const writesByPath = /* @__PURE__ */ new Map();
|
|
428
552
|
for (const item of items) {
|
|
429
553
|
for (const file of item.files) {
|
|
430
|
-
const
|
|
431
|
-
const absPath =
|
|
554
|
+
const originalPath = file.target ?? file.path;
|
|
555
|
+
const absPath = isRootAnchored(originalPath) ? path5.join(rootAnchor, originalPath) : mappedPath(originalPath, targetRoot, rootAnchor, config);
|
|
556
|
+
const relPath = config ? path5.relative(rootAnchor, absPath) : originalPath;
|
|
557
|
+
const content = /\.(md|mdc)$/.test(originalPath) ? mappedDocumentation(file.content, config) : rewriteImports(file.content, originalPath, targetRoot, rootAnchor, config);
|
|
432
558
|
const pending = writesByPath.get(absPath);
|
|
433
559
|
if (pending) {
|
|
434
|
-
if (pending.content !==
|
|
560
|
+
if (pending.content !== content) {
|
|
435
561
|
throw new Error(`Registry items resolve to conflicting content for ${relPath}.`);
|
|
436
562
|
}
|
|
437
563
|
continue;
|
|
@@ -439,8 +565,8 @@ function collectWrites(items, targetRoot, rootAnchor = targetRoot) {
|
|
|
439
565
|
writesByPath.set(absPath, {
|
|
440
566
|
absPath,
|
|
441
567
|
relPath,
|
|
442
|
-
content
|
|
443
|
-
exists:
|
|
568
|
+
content,
|
|
569
|
+
exists: existsSync4(absPath)
|
|
444
570
|
});
|
|
445
571
|
}
|
|
446
572
|
}
|
|
@@ -453,7 +579,7 @@ function writeFiles(writes, overwrite) {
|
|
|
453
579
|
report.skipped.push(write.relPath);
|
|
454
580
|
continue;
|
|
455
581
|
}
|
|
456
|
-
mkdirSync2(
|
|
582
|
+
mkdirSync2(path5.dirname(write.absPath), { recursive: true });
|
|
457
583
|
writeFileSync2(write.absPath, write.content);
|
|
458
584
|
(write.exists ? report.overwritten : report.created).push(write.relPath);
|
|
459
585
|
}
|
|
@@ -462,15 +588,15 @@ function writeFiles(writes, overwrite) {
|
|
|
462
588
|
async function downloadAssets(items, targetRoot, overwrite, rootAnchor = targetRoot) {
|
|
463
589
|
const report = { fetched: [], skipped: [], failed: [] };
|
|
464
590
|
for (const asset of items.flatMap((item) => item.assets ?? [])) {
|
|
465
|
-
const absPath =
|
|
466
|
-
if (
|
|
591
|
+
const absPath = path5.join(isRootAnchored(asset.target) ? rootAnchor : targetRoot, asset.target);
|
|
592
|
+
if (existsSync4(absPath) && !overwrite) {
|
|
467
593
|
report.skipped.push(asset.target);
|
|
468
594
|
continue;
|
|
469
595
|
}
|
|
470
596
|
try {
|
|
471
597
|
const response = await fetch(`${assetsBaseUrl()}${asset.url}`);
|
|
472
598
|
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
|
473
|
-
mkdirSync2(
|
|
599
|
+
mkdirSync2(path5.dirname(absPath), { recursive: true });
|
|
474
600
|
writeFileSync2(absPath, Buffer.from(await response.arrayBuffer()));
|
|
475
601
|
report.fetched.push(asset.target);
|
|
476
602
|
} catch {
|
|
@@ -515,14 +641,14 @@ async function installMissingDependencies(project, wanted) {
|
|
|
515
641
|
|
|
516
642
|
// src/lib/telemetry.ts
|
|
517
643
|
import { randomUUID } from "crypto";
|
|
518
|
-
import { existsSync as
|
|
644
|
+
import { existsSync as existsSync5, mkdirSync as mkdirSync3, readFileSync as readFileSync6, writeFileSync as writeFileSync3 } from "fs";
|
|
519
645
|
import { homedir as homedir2 } from "os";
|
|
520
|
-
import
|
|
646
|
+
import path6 from "path";
|
|
521
647
|
|
|
522
648
|
// src/version.ts
|
|
523
|
-
import { readFileSync as
|
|
649
|
+
import { readFileSync as readFileSync5 } from "fs";
|
|
524
650
|
var packageJson = JSON.parse(
|
|
525
|
-
|
|
651
|
+
readFileSync5(new URL("../package.json", import.meta.url), "utf8")
|
|
526
652
|
);
|
|
527
653
|
var CLI_VERSION = packageJson.version;
|
|
528
654
|
|
|
@@ -538,22 +664,22 @@ function isTelemetryEnabled() {
|
|
|
538
664
|
function configRoot2() {
|
|
539
665
|
if (process.env.XDG_CONFIG_HOME) return process.env.XDG_CONFIG_HOME;
|
|
540
666
|
if (process.platform === "win32" && process.env.APPDATA) return process.env.APPDATA;
|
|
541
|
-
return
|
|
667
|
+
return path6.join(homedir2(), ".config");
|
|
542
668
|
}
|
|
543
669
|
function anonymousIdFile() {
|
|
544
|
-
return
|
|
670
|
+
return path6.join(configRoot2(), "boardui", "telemetry.json");
|
|
545
671
|
}
|
|
546
672
|
function getAnonymousId() {
|
|
547
673
|
const file = anonymousIdFile();
|
|
548
674
|
try {
|
|
549
|
-
if (
|
|
550
|
-
const stored = JSON.parse(
|
|
675
|
+
if (existsSync5(file)) {
|
|
676
|
+
const stored = JSON.parse(readFileSync6(file, "utf8"));
|
|
551
677
|
if (typeof stored.anonymousId === "string" && UUID_V4_RE.test(stored.anonymousId)) {
|
|
552
678
|
return stored.anonymousId;
|
|
553
679
|
}
|
|
554
680
|
}
|
|
555
681
|
const anonymousId = randomUUID();
|
|
556
|
-
mkdirSync3(
|
|
682
|
+
mkdirSync3(path6.dirname(file), { recursive: true, mode: 448 });
|
|
557
683
|
writeFileSync3(file, `${JSON.stringify({ anonymousId }, null, 2)}
|
|
558
684
|
`, {
|
|
559
685
|
encoding: "utf8",
|
|
@@ -648,7 +774,8 @@ async function pickComponents() {
|
|
|
648
774
|
}
|
|
649
775
|
async function add(components, options) {
|
|
650
776
|
const project = readProject(process.cwd());
|
|
651
|
-
|
|
777
|
+
checkDirectoryOverride(project.config, options.path ?? options.dir);
|
|
778
|
+
if (!project.hasAtAlias && needsAtAlias(project.config)) {
|
|
652
779
|
console.log(
|
|
653
780
|
pc.yellow(
|
|
654
781
|
`warning: no "@/*" path alias found in tsconfig.json \u2014 BoardUI components import via "@/". Add:
|
|
@@ -680,8 +807,8 @@ async function add(components, options) {
|
|
|
680
807
|
spinner.succeed(
|
|
681
808
|
`Resolved ${items.length} item${items.length === 1 ? "" : "s"}: ${items.map((i) => i.name).join(", ")}`
|
|
682
809
|
);
|
|
683
|
-
const targetRoot = options.path ?
|
|
684
|
-
const writes = collectWrites(items, targetRoot, project.cwd);
|
|
810
|
+
const targetRoot = options.path ? path7.resolve(process.cwd(), options.path) : options.dir ? path7.resolve(process.cwd(), options.dir) : sourceRoot(project);
|
|
811
|
+
const writes = collectWrites(items, targetRoot, project.cwd, project.config);
|
|
685
812
|
const conflicts = writes.filter((w) => w.exists);
|
|
686
813
|
let overwrite = Boolean(options.overwrite);
|
|
687
814
|
if (conflicts.length > 0 && !overwrite && !options.yes) {
|
|
@@ -774,7 +901,7 @@ ${pc.bold("Note:")} Tailwind was installed. Make sure a ${pc.cyan("postcss.confi
|
|
|
774
901
|
console.log(
|
|
775
902
|
`
|
|
776
903
|
${pc.bold("Note:")} import the BoardUI styles in your root layout or global css:
|
|
777
|
-
${pc.cyan(
|
|
904
|
+
${pc.cyan(`import "${mappedImport("@/styles/globals.css", project.config)}";`)}`
|
|
778
905
|
);
|
|
779
906
|
}
|
|
780
907
|
const written = report.created.length + report.overwritten.length;
|
|
@@ -789,13 +916,13 @@ Done. ${written} file${written === 1 ? "" : "s"} written.`));
|
|
|
789
916
|
}
|
|
790
917
|
|
|
791
918
|
// src/commands/init.ts
|
|
792
|
-
import
|
|
793
|
-
import path6 from "path";
|
|
919
|
+
import path8 from "path";
|
|
794
920
|
import ora2 from "ora";
|
|
795
921
|
import pc2 from "picocolors";
|
|
796
922
|
import prompts2 from "prompts";
|
|
797
923
|
async function init(options) {
|
|
798
924
|
const project = readProject(process.cwd());
|
|
925
|
+
checkDirectoryOverride(project.config, options.dir);
|
|
799
926
|
console.log(pc2.bold("\nBoardUI init\n"));
|
|
800
927
|
if (!project.isNextJs) {
|
|
801
928
|
console.log(
|
|
@@ -804,7 +931,7 @@ async function init(options) {
|
|
|
804
931
|
)
|
|
805
932
|
);
|
|
806
933
|
}
|
|
807
|
-
if (!project.hasAtAlias) {
|
|
934
|
+
if (!project.hasAtAlias && needsAtAlias(project.config)) {
|
|
808
935
|
console.log(
|
|
809
936
|
pc2.yellow(
|
|
810
937
|
`warning: no "@/*" path alias found in tsconfig.json \u2014 BoardUI components import via "@/". Add:
|
|
@@ -816,7 +943,7 @@ async function init(options) {
|
|
|
816
943
|
const { confirmed } = await prompts2({
|
|
817
944
|
type: "confirm",
|
|
818
945
|
name: "confirmed",
|
|
819
|
-
message: `Set up BoardUI in ${
|
|
946
|
+
message: `Set up BoardUI in ${path8.basename(project.cwd)}? (installs Tailwind v4 + runtime deps, writes styles/ and utils/)`,
|
|
820
947
|
initial: true
|
|
821
948
|
});
|
|
822
949
|
if (!confirmed) {
|
|
@@ -852,28 +979,18 @@ async function init(options) {
|
|
|
852
979
|
return;
|
|
853
980
|
}
|
|
854
981
|
spinner.succeed("Foundations fetched.");
|
|
855
|
-
const targetRoot = options.dir ?
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
if (existsSync5(absPath) && !options.overwrite) {
|
|
861
|
-
console.log(` ${pc2.dim("skipped (exists)")} ${relPath}`);
|
|
862
|
-
continue;
|
|
863
|
-
}
|
|
864
|
-
mkdirSync4(path6.dirname(absPath), { recursive: true });
|
|
865
|
-
writeFileSync4(absPath, file.content);
|
|
866
|
-
console.log(` ${pc2.green("created")} ${relPath}`);
|
|
867
|
-
}
|
|
868
|
-
}
|
|
982
|
+
const targetRoot = options.dir ? path8.resolve(process.cwd(), options.dir) : sourceRoot(project);
|
|
983
|
+
const report = writeFiles(collectWrites(items, targetRoot, project.cwd, project.config), Boolean(options.overwrite));
|
|
984
|
+
for (const relPath of report.created) console.log(` ${pc2.green("created")} ${relPath}`);
|
|
985
|
+
for (const relPath of report.overwritten) console.log(` ${pc2.green("overwrote")} ${relPath}`);
|
|
986
|
+
for (const relPath of report.skipped) console.log(` ${pc2.dim("skipped (exists)")} ${relPath}`);
|
|
869
987
|
const rulesItem = items.find((item) => item.name === RULES_ITEM_NAME);
|
|
870
988
|
if (rulesItem?.files[0]?.content) {
|
|
871
|
-
const outcome = syncAgentsRules(project.cwd, rulesItem.files[0].content);
|
|
989
|
+
const outcome = syncAgentsRules(project.cwd, mappedDocumentation(rulesItem.files[0].content, project.config));
|
|
872
990
|
console.log(
|
|
873
991
|
` ${pc2.green(outcome === "created" ? "created" : outcome)} AGENTS.md ${pc2.dim("(always-on BoardUI rules for AI agents)")}`
|
|
874
992
|
);
|
|
875
993
|
}
|
|
876
|
-
const globalsPath = project.usesSrcDir ? "src/styles/globals.css" : "styles/globals.css";
|
|
877
994
|
const telemetry = dependenciesReady ? trackInitSuccess({
|
|
878
995
|
packageManager: project.packageManager,
|
|
879
996
|
pro: Boolean(options.pro)
|
|
@@ -883,10 +1000,10 @@ ${pc2.bold("Almost done \u2014 wire up the styles:")}
|
|
|
883
1000
|
|
|
884
1001
|
1. Import the BoardUI stylesheet in your root layout (app/layout.tsx):
|
|
885
1002
|
|
|
886
|
-
${pc2.cyan(`import "@/styles/globals.css";`)}
|
|
1003
|
+
${pc2.cyan(`import "${mappedImport("@/styles/globals.css", project.config)}";`)}
|
|
887
1004
|
|
|
888
|
-
${pc2.dim(`(replaces the default create-next-app "./globals.css" import
|
|
889
|
-
${pc2.dim(
|
|
1005
|
+
${pc2.dim(`(replaces the default create-next-app "./globals.css" import;`)}
|
|
1006
|
+
${pc2.dim(`in a shared UI package, import the exported stylesheet in each consuming app)`)}
|
|
890
1007
|
|
|
891
1008
|
2. Make sure PostCSS uses Tailwind v4 (postcss.config.mjs):
|
|
892
1009
|
|
|
@@ -967,13 +1084,45 @@ async function logout() {
|
|
|
967
1084
|
}
|
|
968
1085
|
|
|
969
1086
|
// src/commands/mcp.ts
|
|
970
|
-
import { existsSync as existsSync6, readFileSync as
|
|
971
|
-
import
|
|
1087
|
+
import { existsSync as existsSync6, readFileSync as readFileSync7 } from "fs";
|
|
1088
|
+
import path9 from "path";
|
|
972
1089
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
973
1090
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
974
1091
|
import { instrument } from "@posthog/mcp";
|
|
975
1092
|
import { PostHog } from "posthog-node";
|
|
976
1093
|
import { z } from "zod";
|
|
1094
|
+
|
|
1095
|
+
// ../lib/agent/rtl.ts
|
|
1096
|
+
var RTL_SETUP_GUIDE = [
|
|
1097
|
+
"## RTL Support",
|
|
1098
|
+
"",
|
|
1099
|
+
"BoardUI supports Arabic, Hebrew, and other right-to-left languages across free components, Pro blocks, and templates. The same source handles RTL and LTR; there is no RTL CLI flag or separate component version.",
|
|
1100
|
+
"",
|
|
1101
|
+
"1. Read get_component and get_usage_examples for the free `direction` item. Install it with install_components (stdio), or write its source and dependencies yourself (read-only HTTP). CLI equivalent: `npx boardui@latest add direction`.",
|
|
1102
|
+
"2. Wrap the app with DirectionProvider using an explicit BCP 47 locale: `ar` for Arabic, `he` for Hebrew, `en-US` for English. Set matching `lang` and `dir` on `<html>` for a full-app RTL layout. CSS dir alone does not configure React Aria keyboard navigation, calendars, or portalled menus.",
|
|
1103
|
+
"",
|
|
1104
|
+
"```tsx",
|
|
1105
|
+
'import { DirectionProvider } from "@/components/foundations/direction/direction";',
|
|
1106
|
+
"",
|
|
1107
|
+
"export default function RootLayout({ children }: { children: React.ReactNode }) {",
|
|
1108
|
+
" return (",
|
|
1109
|
+
' <html lang="ar" dir="rtl">',
|
|
1110
|
+
" <body>",
|
|
1111
|
+
' <DirectionProvider locale="ar">{children}</DirectionProvider>',
|
|
1112
|
+
" </body>",
|
|
1113
|
+
" </html>",
|
|
1114
|
+
" );",
|
|
1115
|
+
"}",
|
|
1116
|
+
"```",
|
|
1117
|
+
"",
|
|
1118
|
+
"3. Use logical styles such as ps/pe, ms/me, start/end, and text-start/text-end. Mirror navigation arrows and drawer motion; preserve physical coordinates for charts, canvas, and decorative art. Custom portals should carry `dir={useDirection()}` on their root. Nest DirectionProvider for mixed-language regions.",
|
|
1119
|
+
"4. Keep email addresses, URLs, OTP digits, and code LTR; isolate mixed text with bdi or dir=auto. Choose fonts with Arabic or Hebrew coverage and avoid extra letter spacing for Arabic. Translate application labels and accessible names in the application's translation layer; use Intl for dates, numbers, and currencies. Optional `template-copy` supplies TemplateCopyProvider for translating template display copy. Chinese (`zh-CN`) remains LTR.",
|
|
1120
|
+
"5. For older installations, refresh the provider, component source, shared dependencies, and global styles. Preserve customizations before using overwrite. Pro updates use the licensed CLI or updated source downloads.",
|
|
1121
|
+
"",
|
|
1122
|
+
"Setup and live Arabic/Hebrew examples: https://www.boardui.com/rtl"
|
|
1123
|
+
].join("\n");
|
|
1124
|
+
|
|
1125
|
+
// src/commands/mcp.ts
|
|
977
1126
|
var PRICING_URL = "https://www.boardui.com/pricing";
|
|
978
1127
|
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.
|
|
979
1128
|
|
|
@@ -984,12 +1133,16 @@ Typical flow:
|
|
|
984
1133
|
|
|
985
1134
|
Component names are exact \u2014 when unsure, call list_components instead of guessing.
|
|
986
1135
|
|
|
987
|
-
|
|
1136
|
+
${RTL_SETUP_GUIDE}
|
|
1137
|
+
|
|
1138
|
+
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 (or the utils alias configured in boardui.json); 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.
|
|
1139
|
+
|
|
1140
|
+
Monorepos/custom aliases: put boardui.json next to the destination package's package.json, and pass that package as projectDir. Installs read its paths/aliases and keep npm dependencies in that package. Pass projectDir to get_component and get_usage_examples too for matching source and examples. Package exports and each consuming app's stylesheet/Tailwind setup must already be wired by the project.
|
|
988
1141
|
|
|
989
1142
|
Agent skill: BoardUI also ships an agent skill (SKILL.md open standard) carrying deeper always-loaded knowledge \u2014 the full component catalog, theming, page patterns, and the motion language. get_skill answers questions about it (returns SKILL.md and the file list); install_skill writes it into the project's .claude/skills/boardui. For other destinations, relay the CLI: npx boardui@latest skill (project), --global (~/.claude/skills), --client codex (~/.agents/skills, read by Codex and Gemini), --path <dir> (anywhere), --force (update). Docs: https://www.boardui.com/skill
|
|
990
1143
|
|
|
991
1144
|
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 purchase email, then call activate_license with it. After that, pro installs work like free ones.`;
|
|
992
|
-
var posthog = new PostHog("
|
|
1145
|
+
var posthog = new PostHog("", {
|
|
993
1146
|
host: "https://eu.i.posthog.com"
|
|
994
1147
|
});
|
|
995
1148
|
var freeIndexPromise = null;
|
|
@@ -1036,8 +1189,7 @@ var UNRELEASED = {
|
|
|
1036
1189
|
orb: "The BoardUI orb component is not available yet. It is still in progress and not open to public use."
|
|
1037
1190
|
};
|
|
1038
1191
|
var CURATED_SUGGESTIONS = {
|
|
1039
|
-
|
|
1040
|
-
"text-area": ["input"],
|
|
1192
|
+
"text-area": ["textarea"],
|
|
1041
1193
|
form: ["input", "select", "checkbox"],
|
|
1042
1194
|
modal: ["settings-modal", "auth-card"],
|
|
1043
1195
|
dialog: ["settings-modal"],
|
|
@@ -1100,27 +1252,26 @@ function maskKey(key) {
|
|
|
1100
1252
|
return key.length > 8 ? `${key.slice(0, 4)}\u2026${key.slice(-4)}` : "\u2026";
|
|
1101
1253
|
}
|
|
1102
1254
|
function loadProject(projectDir) {
|
|
1103
|
-
const cwd = projectDir ?
|
|
1104
|
-
|
|
1105
|
-
return readProject(cwd);
|
|
1106
|
-
} catch {
|
|
1255
|
+
const cwd = projectDir ? path9.resolve(projectDir) : process.cwd();
|
|
1256
|
+
if (!existsSync6(path9.join(cwd, "package.json"))) {
|
|
1107
1257
|
throw new Error(
|
|
1108
1258
|
`No package.json found in ${cwd}. Pass projectDir with the absolute path of the user's project root (the directory containing package.json). If the directory is a fresh or empty one, scaffold an app there first (e.g. \`npx create-next-app@latest .\`), then call init_boardui again.`
|
|
1109
1259
|
);
|
|
1110
1260
|
}
|
|
1261
|
+
return readProject(cwd);
|
|
1111
1262
|
}
|
|
1112
1263
|
function applyAgentRules(project, items) {
|
|
1113
1264
|
const rules = items.find((item) => item.name === RULES_ITEM_NAME);
|
|
1114
1265
|
const content = rules?.files[0]?.content;
|
|
1115
1266
|
if (!content) return [];
|
|
1116
|
-
const outcome = syncAgentsRules(project.cwd, content);
|
|
1267
|
+
const outcome = syncAgentsRules(project.cwd, mappedDocumentation(content, project.config));
|
|
1117
1268
|
const verb = outcome === "created" ? "written to a new AGENTS.md" : outcome === "updated" ? "refreshed in AGENTS.md" : "appended to AGENTS.md";
|
|
1118
1269
|
const lines = [
|
|
1119
1270
|
`Always-on design rules ${verb} (tokens, type scale, conventions \u2014 loaded by agents every session, unlike on-demand MCP calls).`
|
|
1120
1271
|
];
|
|
1121
|
-
const claudeMd =
|
|
1272
|
+
const claudeMd = path9.join(project.cwd, "CLAUDE.md");
|
|
1122
1273
|
try {
|
|
1123
|
-
if (existsSync6(claudeMd) && !
|
|
1274
|
+
if (existsSync6(claudeMd) && !readFileSync7(claudeMd, "utf8").includes("AGENTS.md")) {
|
|
1124
1275
|
lines.push(
|
|
1125
1276
|
'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.'
|
|
1126
1277
|
);
|
|
@@ -1130,7 +1281,7 @@ function applyAgentRules(project, items) {
|
|
|
1130
1281
|
return lines;
|
|
1131
1282
|
}
|
|
1132
1283
|
function aliasWarning(project) {
|
|
1133
|
-
return project.hasAtAlias ? "" : `
|
|
1284
|
+
return project.hasAtAlias || !needsAtAlias(project.config) ? "" : `
|
|
1134
1285
|
|
|
1135
1286
|
Warning: no "@/*" path alias found in tsconfig.json \u2014 BoardUI components import via "@/". Add to tsconfig.json: "compilerOptions": { "paths": { "@/*": ["./*"] } }`;
|
|
1136
1287
|
}
|
|
@@ -1185,6 +1336,27 @@ function formatItemDetail(item, tier) {
|
|
|
1185
1336
|
);
|
|
1186
1337
|
return lines.join("\n");
|
|
1187
1338
|
}
|
|
1339
|
+
function projectExample(code, project) {
|
|
1340
|
+
return project ? rewriteImports(code, "example.tsx", sourceRoot(project), project.cwd, project.config) : code;
|
|
1341
|
+
}
|
|
1342
|
+
function projectItem(item, project) {
|
|
1343
|
+
if (!project?.config) return item;
|
|
1344
|
+
const writes = collectWrites([item], sourceRoot(project), project.cwd, project.config);
|
|
1345
|
+
return {
|
|
1346
|
+
...item,
|
|
1347
|
+
files: writes.map((write) => ({
|
|
1348
|
+
path: write.relPath,
|
|
1349
|
+
target: write.relPath,
|
|
1350
|
+
content: write.content,
|
|
1351
|
+
type: "registry:file"
|
|
1352
|
+
})),
|
|
1353
|
+
meta: item.meta && {
|
|
1354
|
+
...item.meta,
|
|
1355
|
+
example: item.meta.example && projectExample(item.meta.example, project),
|
|
1356
|
+
snippets: item.meta.snippets?.map((snippet) => ({ ...snippet, code: projectExample(snippet.code, project) }))
|
|
1357
|
+
}
|
|
1358
|
+
};
|
|
1359
|
+
}
|
|
1188
1360
|
async function mcp() {
|
|
1189
1361
|
const server = new McpServer(
|
|
1190
1362
|
{ name: "boardui", version: CLI_VERSION },
|
|
@@ -1268,11 +1440,13 @@ ${templates.map((item) => `- ${item.name}: ${item.description}`).join("\n")}`
|
|
|
1268
1440
|
title: "Get component source",
|
|
1269
1441
|
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.",
|
|
1270
1442
|
inputSchema: {
|
|
1271
|
-
name: z.string().describe('Exact item name from list_components, e.g. "button".')
|
|
1443
|
+
name: z.string().describe('Exact item name from list_components, e.g. "button".'),
|
|
1444
|
+
projectDir: z.string().optional().describe("Destination package root; pass to adapt source paths and examples using its boardui.json.")
|
|
1272
1445
|
},
|
|
1273
1446
|
annotations: { readOnlyHint: true }
|
|
1274
1447
|
},
|
|
1275
|
-
safe(async ({ name: rawName }) => {
|
|
1448
|
+
safe(async ({ name: rawName, projectDir }) => {
|
|
1449
|
+
const project = projectDir ? loadProject(projectDir) : void 0;
|
|
1276
1450
|
const resolved = resolveName(rawName, await nameUniverse());
|
|
1277
1451
|
if (resolved.error !== void 0) return errorText(resolved.error);
|
|
1278
1452
|
const name = resolved.name;
|
|
@@ -1283,12 +1457,12 @@ ${templates.map((item) => `- ${item.name}: ${item.description}`).join("\n")}`
|
|
|
1283
1457
|
|
|
1284
1458
|
Public usage example (source requires the license):
|
|
1285
1459
|
\`\`\`tsx
|
|
1286
|
-
${proItem.example}
|
|
1460
|
+
${projectExample(proItem.example, project)}
|
|
1287
1461
|
\`\`\`` : "";
|
|
1288
1462
|
return text(proPitch([proItem]) + example);
|
|
1289
1463
|
}
|
|
1290
1464
|
const item = await fetchRegistryItem(name);
|
|
1291
|
-
return text(formatItemDetail(item, proItem ? "pro" : "free"));
|
|
1465
|
+
return text(formatItemDetail(projectItem(item, project), proItem ? "pro" : "free"));
|
|
1292
1466
|
})
|
|
1293
1467
|
);
|
|
1294
1468
|
server.registerTool(
|
|
@@ -1297,11 +1471,13 @@ ${proItem.example}
|
|
|
1297
1471
|
title: "Get usage examples",
|
|
1298
1472
|
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.",
|
|
1299
1473
|
inputSchema: {
|
|
1300
|
-
name: z.string().describe("Exact item name from list_components.")
|
|
1474
|
+
name: z.string().describe("Exact item name from list_components."),
|
|
1475
|
+
projectDir: z.string().optional().describe("Destination package root; pass to adapt examples using its boardui.json.")
|
|
1301
1476
|
},
|
|
1302
1477
|
annotations: { readOnlyHint: true }
|
|
1303
1478
|
},
|
|
1304
|
-
safe(async ({ name: rawName }) => {
|
|
1479
|
+
safe(async ({ name: rawName, projectDir }) => {
|
|
1480
|
+
const project = projectDir ? loadProject(projectDir) : void 0;
|
|
1305
1481
|
const resolved = resolveName(rawName, await nameUniverse());
|
|
1306
1482
|
if (resolved.error !== void 0) return errorText(resolved.error);
|
|
1307
1483
|
const name = resolved.name;
|
|
@@ -1315,13 +1491,13 @@ ${proItem.example}
|
|
|
1315
1491
|
...proItem.docsUrl ? ["", `Docs: ${proItem.docsUrl}`] : []
|
|
1316
1492
|
];
|
|
1317
1493
|
if (proItem.example) {
|
|
1318
|
-
lines2.push("", "```tsx", proItem.example, "```");
|
|
1494
|
+
lines2.push("", "```tsx", projectExample(proItem.example, project), "```");
|
|
1319
1495
|
} else {
|
|
1320
1496
|
lines2.push("", "No public example \u2014 see the docs page for a live preview.");
|
|
1321
1497
|
}
|
|
1322
1498
|
return text(lines2.join("\n"));
|
|
1323
1499
|
}
|
|
1324
|
-
const item = await fetchRegistryItem(name);
|
|
1500
|
+
const item = projectItem(await fetchRegistryItem(name), project);
|
|
1325
1501
|
const lines = [
|
|
1326
1502
|
`# ${item.title} (${item.name})`,
|
|
1327
1503
|
"",
|
|
@@ -1394,7 +1570,7 @@ ${proItem.example}
|
|
|
1394
1570
|
items = await resolveItems(freeSubset);
|
|
1395
1571
|
}
|
|
1396
1572
|
const targetRoot = sourceRoot(project);
|
|
1397
|
-
const report = writeFiles(collectWrites(items, targetRoot, project.cwd), overwrite);
|
|
1573
|
+
const report = writeFiles(collectWrites(items, targetRoot, project.cwd, project.config), overwrite);
|
|
1398
1574
|
const assets = await downloadAssets(items, targetRoot, overwrite, project.cwd);
|
|
1399
1575
|
const wanted = missingDependencies(items, project);
|
|
1400
1576
|
const deps = installDependencies ? await installMissingDependencies(project, wanted) : null;
|
|
@@ -1425,7 +1601,7 @@ ${proItem.example}
|
|
|
1425
1601
|
if (items.some((item) => item.name === "globals")) {
|
|
1426
1602
|
lines.push(
|
|
1427
1603
|
"",
|
|
1428
|
-
|
|
1604
|
+
`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).`
|
|
1429
1605
|
);
|
|
1430
1606
|
}
|
|
1431
1607
|
let result = lines.join("\n") + aliasWarning(project);
|
|
@@ -1475,7 +1651,7 @@ NOT installed \u2014 pro fetch failed for ${proFailure.names.join(", ")}: ${proF
|
|
|
1475
1651
|
const deps = await installMissingDependencies(project, missing);
|
|
1476
1652
|
const items = await resolveItems(INIT_ITEMS);
|
|
1477
1653
|
const targetRoot = sourceRoot(project);
|
|
1478
|
-
const report = writeFiles(collectWrites(items, targetRoot, project.cwd), overwrite);
|
|
1654
|
+
const report = writeFiles(collectWrites(items, targetRoot, project.cwd, project.config), overwrite);
|
|
1479
1655
|
const rulesLines = applyAgentRules(project, items);
|
|
1480
1656
|
if (!deps.error) {
|
|
1481
1657
|
await trackInitSuccess({
|
|
@@ -1485,7 +1661,7 @@ NOT installed \u2014 pro fetch failed for ${proFailure.names.join(", ")}: ${proF
|
|
|
1485
1661
|
});
|
|
1486
1662
|
}
|
|
1487
1663
|
const staleStylesheet = ["app/globals.css", "src/app/globals.css"].find(
|
|
1488
|
-
(rel) => existsSync6(
|
|
1664
|
+
(rel) => existsSync6(path9.join(project.cwd, rel))
|
|
1489
1665
|
);
|
|
1490
1666
|
const lines = [
|
|
1491
1667
|
`BoardUI initialized in ${project.cwd}.`,
|
|
@@ -1502,9 +1678,11 @@ NOT installed \u2014 pro fetch failed for ${proFailure.names.join(", ")}: ${proF
|
|
|
1502
1678
|
...rulesLines.length ? ["", ...rulesLines] : [],
|
|
1503
1679
|
"",
|
|
1504
1680
|
"Finish the wiring:",
|
|
1505
|
-
|
|
1681
|
+
`1. Import the BoardUI stylesheet in the consuming app's root layout: import "${mappedImport("@/styles/globals.css", project.config)}"; \u2014 replacing the default create-next-app "./globals.css" import.`,
|
|
1506
1682
|
'2. Make sure PostCSS uses Tailwind v4 (postcss.config.mjs): export default { plugins: { "@tailwindcss/postcss": {} } };',
|
|
1507
1683
|
'3. Install components with install_components, e.g. ["button", "select", "date-picker"].',
|
|
1684
|
+
"",
|
|
1685
|
+
mappedDocumentation(RTL_SETUP_GUIDE, project.config),
|
|
1508
1686
|
...staleStylesheet ? [
|
|
1509
1687
|
"",
|
|
1510
1688
|
`Note: ${staleStylesheet} is create-next-app's stylesheet, superseded by styles/globals.css \u2014 once step 1's import is swapped, that file is safe to delete.`
|
|
@@ -1530,7 +1708,7 @@ NOT installed \u2014 pro fetch failed for ${proFailure.names.join(", ")}: ${proF
|
|
|
1530
1708
|
const project = loadProject(projectDir);
|
|
1531
1709
|
const items = await resolveItems([RULES_ITEM_NAME]);
|
|
1532
1710
|
const report = writeFiles(
|
|
1533
|
-
collectWrites(items, sourceRoot(project), project.cwd),
|
|
1711
|
+
collectWrites(items, sourceRoot(project), project.cwd, project.config),
|
|
1534
1712
|
overwrite
|
|
1535
1713
|
);
|
|
1536
1714
|
const lines = [
|
|
@@ -1589,7 +1767,7 @@ ${skillMd}`
|
|
|
1589
1767
|
async ({ overwrite = false, projectDir }) => {
|
|
1590
1768
|
const project = loadProject(projectDir);
|
|
1591
1769
|
const items = await resolveItems([SKILL_ITEM_NAME]);
|
|
1592
|
-
const targetDir =
|
|
1770
|
+
const targetDir = path9.join(project.cwd, ".claude", "skills", "boardui");
|
|
1593
1771
|
const report = writeFiles(collectWrites(items, targetDir), overwrite);
|
|
1594
1772
|
const lines = [
|
|
1595
1773
|
...report.created.map((relPath) => ` created .claude/skills/boardui/${relPath}`),
|
|
@@ -1613,12 +1791,12 @@ ${skillMd}`
|
|
|
1613
1791
|
"get_theme",
|
|
1614
1792
|
{
|
|
1615
1793
|
title: "Get theme tokens",
|
|
1616
|
-
description: "The BoardUI theme foundations: color primitives + semantic tokens (theme.css), the type scale (typography.css),
|
|
1794
|
+
description: "The BoardUI theme foundations: color primitives + semantic tokens (theme.css), the type scale (typography.css), the Tailwind entry stylesheet (globals.css), and RTL setup for Arabic and Hebrew. Use when restyling components, mapping BoardUI tokens onto a brand, or enabling RTL.",
|
|
1617
1795
|
annotations: { readOnlyHint: true }
|
|
1618
1796
|
},
|
|
1619
1797
|
safe(async () => {
|
|
1620
1798
|
const items = await resolveItems(["globals"]);
|
|
1621
|
-
const lines = [];
|
|
1799
|
+
const lines = [RTL_SETUP_GUIDE, ""];
|
|
1622
1800
|
for (const item of items) {
|
|
1623
1801
|
for (const file of item.files) {
|
|
1624
1802
|
lines.push(`## ${file.target}`, "", "```css", file.content, "```", "");
|
|
@@ -1711,17 +1889,17 @@ ${skillMd}`
|
|
|
1711
1889
|
}
|
|
1712
1890
|
|
|
1713
1891
|
// src/commands/skill.ts
|
|
1714
|
-
import { existsSync as existsSync7, readFileSync as
|
|
1892
|
+
import { existsSync as existsSync7, readFileSync as readFileSync8 } from "fs";
|
|
1715
1893
|
import { homedir as homedir3 } from "os";
|
|
1716
|
-
import
|
|
1894
|
+
import path10 from "path";
|
|
1717
1895
|
import ora3 from "ora";
|
|
1718
1896
|
import pc5 from "picocolors";
|
|
1719
1897
|
var KNOWN_CLIENTS = ["codex", "gemini"];
|
|
1720
1898
|
function installedVersion(targetDir) {
|
|
1721
1899
|
try {
|
|
1722
|
-
const skillPath =
|
|
1900
|
+
const skillPath = path10.join(targetDir, "SKILL.md");
|
|
1723
1901
|
if (!existsSync7(skillPath)) return null;
|
|
1724
|
-
const match =
|
|
1902
|
+
const match = readFileSync8(skillPath, "utf8").match(/^\s*version:\s*(\S+)\s*$/m);
|
|
1725
1903
|
return match?.[1] ?? null;
|
|
1726
1904
|
} catch {
|
|
1727
1905
|
return null;
|
|
@@ -1751,7 +1929,7 @@ async function skill(options) {
|
|
|
1751
1929
|
before && fetched && before !== fetched ? `Skill fetched (installed ${before} -> ${fetched}).` : `Skill fetched${fetched ? ` (version ${fetched})` : ""}.`
|
|
1752
1930
|
);
|
|
1753
1931
|
const report = writeFiles(collectWrites(items, targetDir), Boolean(options.force));
|
|
1754
|
-
const shortDir = targetDir.startsWith(homedir3()) ? `~${targetDir.slice(homedir3().length)}` :
|
|
1932
|
+
const shortDir = targetDir.startsWith(homedir3()) ? `~${targetDir.slice(homedir3().length)}` : path10.relative(process.cwd(), targetDir) || ".";
|
|
1755
1933
|
for (const relPath of report.created) console.log(` ${pc5.green("created")} ${shortDir}/${relPath}`);
|
|
1756
1934
|
for (const relPath of report.overwritten) console.log(` ${pc5.green("updated")} ${shortDir}/${relPath}`);
|
|
1757
1935
|
for (const relPath of report.skipped) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "boardui",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.7",
|
|
4
4
|
"description": "Add BoardUI components to your project.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -40,12 +40,12 @@
|
|
|
40
40
|
"picocolors": "^1.1.1",
|
|
41
41
|
"posthog-node": "^5.51.4",
|
|
42
42
|
"prompts": "^2.4.2",
|
|
43
|
-
"zod": "^4.5.1"
|
|
43
|
+
"zod": "^4.5.1",
|
|
44
|
+
"typescript": "^5"
|
|
44
45
|
},
|
|
45
46
|
"devDependencies": {
|
|
46
47
|
"@types/node": "^20",
|
|
47
48
|
"@types/prompts": "^2.4.9",
|
|
48
|
-
"tsup": "^8.3.5"
|
|
49
|
-
"typescript": "^5"
|
|
49
|
+
"tsup": "^8.3.5"
|
|
50
50
|
}
|
|
51
51
|
}
|