basalt-ui 1.0.0 → 1.0.2
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/AGENTS.md +12 -12
- package/CHANGELOG.md +19 -0
- package/README.md +31 -44
- package/agent/rules/basalt-charts.md +1 -1
- package/agent/rules/basalt-mantine.md +3 -3
- package/agent/rules/basalt-router.md +1 -1
- package/agent/rules/basalt-state.md +2 -2
- package/agent/rules/basalt-tokens.md +3 -3
- package/agent/skills/basalt-app/SKILL.md +137 -0
- package/agent/skills/basalt-charts/SKILL.md +179 -0
- package/agent/skills/basalt-design/SKILL.md +249 -0
- package/agent/templates/CLAUDE-block.md.tpl +8 -5
- package/agent/templates/__root.tpl +1 -1
- package/agent/templates/query-client.ts.tpl +1 -1
- package/configs/check.yml +8 -8
- package/configs/lefthook.yml +9 -5
- package/configs/oxlint-plugin.js +119 -7
- package/configs/oxlint-plugin.test.ts +73 -3
- package/configs/oxlint.json +2 -71
- package/dist/cli/index.d.ts +71 -28
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +134 -121
- package/dist/surfaces.d.ts +41 -17
- package/dist/surfaces.d.ts.map +1 -1
- package/dist/surfaces.js +37 -38
- package/dist/tokens/index.d.ts +1 -0
- package/dist/tokens/index.d.ts.map +1 -1
- package/dist/tokens/index.js +3 -0
- package/llms.txt +2 -2
- package/package.json +2 -2
- package/src/cli/check-theme.test.ts +12 -2
- package/src/cli/help.test.ts +93 -0
- package/src/cli/index.ts +332 -184
- package/src/cli/placement-engine.test.ts +194 -0
- package/src/cli/tarball-parity.test.ts +44 -0
- package/src/cli/template-format.test.ts +64 -0
- package/src/cli/template-ledger.test.ts +219 -0
- package/src/surfaces.ts +78 -43
- package/src/tokens/index.ts +6 -0
- /package/bin/{basalt.mjs → basalt-ui.mjs} +0 -0
package/dist/cli/index.js
CHANGED
|
@@ -12,10 +12,17 @@ import { dirname, isAbsolute, relative, resolve } from "node:path";
|
|
|
12
12
|
import { fileURLToPath } from "node:url";
|
|
13
13
|
import { checkSource, DEFAULT_GUARD_CONFIG, GUARD_RULES } from "../guard/index.js";
|
|
14
14
|
import { evaluateGuardHook } from "../guard/guard-hook.js";
|
|
15
|
-
import {
|
|
16
|
-
|
|
15
|
+
import {
|
|
16
|
+
hasImportBoundaryRuleRegistered,
|
|
17
|
+
MANTINE_FREE_VIA_IMPORT_BOUNDARY,
|
|
18
|
+
RULE_NAMES,
|
|
19
|
+
SKILL_NAMES,
|
|
20
|
+
SURFACES
|
|
21
|
+
} from "../surfaces.js";
|
|
22
|
+
const DEFAULT_ROOTS = ["src"];
|
|
23
|
+
const DEFAULT_SERIES_MODULE_PATH = "src/lib/series.ts";
|
|
17
24
|
function defaultExempt(cfg) {
|
|
18
|
-
return [cfg.seriesModulePath ??
|
|
25
|
+
return [cfg.seriesModulePath ?? DEFAULT_SERIES_MODULE_PATH];
|
|
19
26
|
}
|
|
20
27
|
const SKIP = /\.gen\.ts$|\.test\.[tj]sx?$|\.d\.ts$/;
|
|
21
28
|
const SERIES_MODULE_HINT_RE = /(series|palette)\.tsx?$/i;
|
|
@@ -102,11 +109,11 @@ function checkTheme(cwd = process.cwd()) {
|
|
|
102
109
|
if (scannedCount === 0) {
|
|
103
110
|
if (cfg.roots === void 0) {
|
|
104
111
|
console.error(
|
|
105
|
-
`\u2716 basalt check-theme: 0 files scanned \u2014 no "basalt.roots" configured in package.json, and the built-in default roots (${DEFAULT_ROOTS.join(", ")}) matched zero files. Set "basalt": { "roots": [...] } in package.json to point at your source directories.`
|
|
112
|
+
`\u2716 basalt-ui check-theme: 0 files scanned \u2014 no "basalt.roots" configured in package.json, and the built-in default roots (${DEFAULT_ROOTS.join(", ")}) matched zero files. Set "basalt": { "roots": [...] } in package.json to point at your source directories.`
|
|
106
113
|
);
|
|
107
114
|
} else {
|
|
108
115
|
console.error(
|
|
109
|
-
`\u2716 basalt check-theme: 0 files scanned \u2014 the configured "basalt.roots" (${roots.join(", ")}) matched zero files. Check the paths in "basalt.roots" in package.json.`
|
|
116
|
+
`\u2716 basalt-ui check-theme: 0 files scanned \u2014 the configured "basalt.roots" (${roots.join(", ")}) matched zero files. Check the paths in "basalt.roots" in package.json.`
|
|
110
117
|
);
|
|
111
118
|
}
|
|
112
119
|
return 1;
|
|
@@ -179,9 +186,7 @@ function buildTemplateVars(pkgRoot, cwd, cfg) {
|
|
|
179
186
|
APP_NAME: readPackageName(cwd),
|
|
180
187
|
BASALT_VERSION: readFrameworkVersion(pkgRoot),
|
|
181
188
|
ACCENT_HUE: cfg.accentHue ?? "blue",
|
|
182
|
-
SERIES_MODULE_PATH: cfg.seriesModulePath ??
|
|
183
|
-
MARKETPLACE_OWNER: cfg.marketplace?.owner ?? "jkrumm",
|
|
184
|
-
MARKETPLACE_REPO: cfg.marketplace?.repo ?? "basalt-ui"
|
|
189
|
+
SERIES_MODULE_PATH: cfg.seriesModulePath ?? DEFAULT_SERIES_MODULE_PATH
|
|
185
190
|
};
|
|
186
191
|
}
|
|
187
192
|
function fillTemplate(tpl, vars) {
|
|
@@ -193,6 +198,12 @@ function fillTemplate(tpl, vars) {
|
|
|
193
198
|
function findBlockRegion(host) {
|
|
194
199
|
const start = host.indexOf(BLOCK_BEGIN_PREFIX);
|
|
195
200
|
if (start === -1) return null;
|
|
201
|
+
const duplicate = host.indexOf(BLOCK_BEGIN_PREFIX, start + BLOCK_BEGIN_PREFIX.length);
|
|
202
|
+
if (duplicate !== -1) {
|
|
203
|
+
throw new Error(
|
|
204
|
+
`duplicate \`${BLOCK_BEGIN_PREFIX}\` markers found in the host file \u2014 remove the stale basalt block by hand, then re-run.`
|
|
205
|
+
);
|
|
206
|
+
}
|
|
196
207
|
const endMarker = host.indexOf(BLOCK_END, start);
|
|
197
208
|
if (endMarker === -1) return null;
|
|
198
209
|
return { start, end: endMarker + BLOCK_END.length };
|
|
@@ -228,16 +239,23 @@ function resolvePeerFlags(cwd, flags) {
|
|
|
228
239
|
function managedFiles(peers) {
|
|
229
240
|
const rules = RULE_NAMES.map((name) => ({
|
|
230
241
|
dest: `.claude/rules/basalt-${name}.md`,
|
|
231
|
-
|
|
242
|
+
mode: "managed",
|
|
232
243
|
source: `agent/rules/basalt-${name}.md`,
|
|
233
244
|
render: (ctx) => readSource(ctx.pkgRoot, `agent/rules/basalt-${name}.md`)
|
|
234
245
|
}));
|
|
246
|
+
const skills = SKILL_NAMES.map((name) => ({
|
|
247
|
+
dest: `.claude/skills/${name}/SKILL.md`,
|
|
248
|
+
mode: "managed",
|
|
249
|
+
source: `agent/skills/${name}/SKILL.md`,
|
|
250
|
+
render: (ctx) => readSource(ctx.pkgRoot, `agent/skills/${name}/SKILL.md`)
|
|
251
|
+
}));
|
|
235
252
|
const claudeBlock = {
|
|
236
253
|
dest: "CLAUDE.md",
|
|
237
|
-
|
|
254
|
+
mode: "managed",
|
|
255
|
+
markers: true,
|
|
238
256
|
source: "agent/templates/CLAUDE-block.md.tpl",
|
|
239
|
-
//
|
|
240
|
-
//
|
|
257
|
+
// With markers, render() returns the fully-rendered region INCLUDING its begin/end markers.
|
|
258
|
+
// The writer splices it into the consumer's host CLAUDE.md at apply time.
|
|
241
259
|
render: (ctx) => {
|
|
242
260
|
const tpl = readSource(ctx.pkgRoot, "agent/templates/CLAUDE-block.md.tpl");
|
|
243
261
|
if (tpl === null) return null;
|
|
@@ -246,7 +264,7 @@ function managedFiles(peers) {
|
|
|
246
264
|
};
|
|
247
265
|
const design = {
|
|
248
266
|
dest: "DESIGN.md",
|
|
249
|
-
|
|
267
|
+
mode: "seed",
|
|
250
268
|
source: "agent/templates/DESIGN.md.tpl",
|
|
251
269
|
render: (ctx) => {
|
|
252
270
|
const tpl = readSource(ctx.pkgRoot, "agent/templates/DESIGN.md.tpl");
|
|
@@ -256,31 +274,31 @@ function managedFiles(peers) {
|
|
|
256
274
|
};
|
|
257
275
|
const oxfmt = {
|
|
258
276
|
dest: ".oxfmtrc.json",
|
|
259
|
-
|
|
277
|
+
mode: "seed",
|
|
260
278
|
source: "configs/oxfmt.json",
|
|
261
279
|
render: (ctx) => readSource(ctx.pkgRoot, "configs/oxfmt.json")
|
|
262
280
|
};
|
|
263
281
|
const lefthook = {
|
|
264
282
|
dest: "lefthook.yml",
|
|
265
|
-
|
|
283
|
+
mode: "seed",
|
|
266
284
|
source: "configs/lefthook.yml",
|
|
267
|
-
render: (
|
|
285
|
+
render: () => "# Seeded by basalt-ui init \u2014 you own this file; sync never touches it again.\n# The extends target supplies oxlint + oxfmt + check-theme pre-commit jobs and\n# auto-updates with the basalt-ui package. Add your own commands alongside.\nextends:\n - node_modules/basalt-ui/configs/lefthook.yml\n"
|
|
268
286
|
};
|
|
269
287
|
const ci = {
|
|
270
288
|
dest: ".github/workflows/check.yml",
|
|
271
|
-
|
|
289
|
+
mode: "seed",
|
|
272
290
|
source: "configs/check.yml",
|
|
273
291
|
render: (ctx) => readSource(ctx.pkgRoot, "configs/check.yml")
|
|
274
292
|
};
|
|
275
293
|
const oxlintrc = {
|
|
276
294
|
dest: ".oxlintrc.json",
|
|
277
|
-
|
|
295
|
+
mode: "seed",
|
|
278
296
|
source: "configs/oxlint.json",
|
|
279
297
|
render: () => '{\n "extends": ["./node_modules/basalt-ui/configs/oxlint.json"]\n}\n'
|
|
280
298
|
};
|
|
281
299
|
const queryClient = {
|
|
282
300
|
dest: "src/query-client.ts",
|
|
283
|
-
|
|
301
|
+
mode: "seed",
|
|
284
302
|
source: "agent/templates/query-client.ts.tpl",
|
|
285
303
|
render: (ctx) => {
|
|
286
304
|
const tpl = readSource(ctx.pkgRoot, "agent/templates/query-client.ts.tpl");
|
|
@@ -290,7 +308,7 @@ function managedFiles(peers) {
|
|
|
290
308
|
};
|
|
291
309
|
const rootRoute = {
|
|
292
310
|
dest: "src/routes/__root.tsx",
|
|
293
|
-
|
|
311
|
+
mode: "seed",
|
|
294
312
|
source: "agent/templates/__root.tpl",
|
|
295
313
|
render: (ctx) => {
|
|
296
314
|
const tpl = readSource(ctx.pkgRoot, "agent/templates/__root.tpl");
|
|
@@ -301,14 +319,16 @@ function managedFiles(peers) {
|
|
|
301
319
|
const scaffolds = [];
|
|
302
320
|
if (peers.hasQuery) scaffolds.push(queryClient);
|
|
303
321
|
if (peers.hasRouter && peers.hasQuery) scaffolds.push(rootRoute);
|
|
304
|
-
return [...rules, claudeBlock, design, oxfmt, lefthook, ci, oxlintrc, ...scaffolds];
|
|
322
|
+
return [...rules, ...skills, claudeBlock, design, oxfmt, lefthook, ci, oxlintrc, ...scaffolds];
|
|
305
323
|
}
|
|
306
324
|
function readManifest(cwd) {
|
|
307
325
|
const raw = readIfExists(resolve(cwd, MANIFEST_PATH));
|
|
308
326
|
if (raw === null) return { version: 1, files: {} };
|
|
309
327
|
try {
|
|
310
328
|
const parsed = JSON.parse(raw);
|
|
311
|
-
|
|
329
|
+
const manifest = { version: 1, files: parsed.files ?? {} };
|
|
330
|
+
if (typeof parsed.basaltVersion === "string") manifest.basaltVersion = parsed.basaltVersion;
|
|
331
|
+
return manifest;
|
|
312
332
|
} catch {
|
|
313
333
|
return { version: 1, files: {} };
|
|
314
334
|
}
|
|
@@ -340,26 +360,33 @@ function unitState(file, cwd, ctx) {
|
|
|
340
360
|
const desired = file.render(ctx);
|
|
341
361
|
const destAbs = resolve(cwd, file.dest);
|
|
342
362
|
const onDisk = readIfExists(destAbs);
|
|
343
|
-
if (file.
|
|
363
|
+
if (file.markers) {
|
|
344
364
|
return { current: extractBlockRegion(onDisk), desired };
|
|
345
365
|
}
|
|
346
366
|
return { current: onDisk, desired };
|
|
347
367
|
}
|
|
368
|
+
function normalizeForLedger(text) {
|
|
369
|
+
return text.replace(/(<!-- basalt:begin)\s+\S+(\s*-->)/, "$1$2").split("\n").map((line) => line.replace(/[ \t]+$/, "")).join("\n").replace(/\n{2,}/g, "\n").trim();
|
|
370
|
+
}
|
|
348
371
|
function writeUnit(file, cwd, desired) {
|
|
349
372
|
const destAbs = resolve(cwd, file.dest);
|
|
350
|
-
if (file.
|
|
373
|
+
if (file.markers) {
|
|
351
374
|
const host = readIfExists(destAbs) ?? "";
|
|
352
375
|
writeFileEnsuringDir(destAbs, applyBlock(host, desired));
|
|
353
|
-
|
|
376
|
+
} else {
|
|
377
|
+
writeFileEnsuringDir(destAbs, desired);
|
|
354
378
|
}
|
|
355
|
-
|
|
356
|
-
return sha256(desired);
|
|
379
|
+
return sha256(normalizeForLedger(desired));
|
|
357
380
|
}
|
|
358
381
|
function classify(state, manifestHash) {
|
|
359
382
|
if (state.current === null) return "missing";
|
|
360
383
|
if (state.desired !== null && state.current === state.desired) return "current";
|
|
361
384
|
const currentHash = sha256(state.current);
|
|
362
385
|
if (currentHash === manifestHash) return "unchanged";
|
|
386
|
+
if (sha256(normalizeForLedger(state.current)) === manifestHash) return "unchanged";
|
|
387
|
+
if (state.desired !== null && normalizeForLedger(state.current) === normalizeForLedger(state.desired)) {
|
|
388
|
+
return "unchanged";
|
|
389
|
+
}
|
|
363
390
|
return "drifted";
|
|
364
391
|
}
|
|
365
392
|
function diffSummary(file, state) {
|
|
@@ -389,8 +416,8 @@ function init(cwd = process.cwd(), scaffoldFlags = {}) {
|
|
|
389
416
|
continue;
|
|
390
417
|
}
|
|
391
418
|
const destExists = existsSync(resolve(cwd, file.dest));
|
|
392
|
-
if (
|
|
393
|
-
manifest.files[file.dest] = sha256(state.desired);
|
|
419
|
+
if (!file.markers && destExists) {
|
|
420
|
+
manifest.files[file.dest] = sha256(normalizeForLedger(state.desired));
|
|
394
421
|
skipped++;
|
|
395
422
|
continue;
|
|
396
423
|
}
|
|
@@ -398,31 +425,25 @@ function init(cwd = process.cwd(), scaffoldFlags = {}) {
|
|
|
398
425
|
manifest.files[file.dest] = hash;
|
|
399
426
|
written++;
|
|
400
427
|
}
|
|
428
|
+
manifest.basaltVersion = ctx.vars.BASALT_VERSION;
|
|
401
429
|
writeFileEnsuringDir(resolve(cwd, MANIFEST_PATH), `${JSON.stringify(manifest, null, 2)}
|
|
402
430
|
`);
|
|
403
|
-
console.log(`basalt init: ${written} written, ${skipped} kept, manifest at ${MANIFEST_PATH}`);
|
|
431
|
+
console.log(`basalt-ui init: ${written} written, ${skipped} kept, manifest at ${MANIFEST_PATH}`);
|
|
404
432
|
if (missingSources.length > 0) {
|
|
405
433
|
console.log(
|
|
406
|
-
`basalt init: ${missingSources.length} shipped asset(s) not present, skipped: ${missingSources.join(", ")}`
|
|
434
|
+
`basalt-ui init: ${missingSources.length} shipped asset(s) not present, skipped: ${missingSources.join(", ")}`
|
|
407
435
|
);
|
|
408
436
|
}
|
|
409
437
|
if (!peers.hasQuery) {
|
|
410
438
|
console.log(
|
|
411
|
-
"basalt init: skipped src/query-client.ts (no @tanstack/react-query dependency detected) \u2014 install it, or re-run with --with-query, to scaffold it."
|
|
439
|
+
"basalt-ui init: skipped src/query-client.ts (no @tanstack/react-query dependency detected) \u2014 install it, or re-run with --with-query, to scaffold it."
|
|
412
440
|
);
|
|
413
441
|
}
|
|
414
442
|
if (!peers.hasRouter || !peers.hasQuery) {
|
|
415
443
|
console.log(
|
|
416
|
-
"basalt init: skipped src/routes/__root.tsx (needs both @tanstack/react-router and @tanstack/react-query) \u2014 install both, or re-run with --with-router --with-query, to scaffold it."
|
|
444
|
+
"basalt-ui init: skipped src/routes/__root.tsx (needs both @tanstack/react-router and @tanstack/react-query) \u2014 install both, or re-run with --with-router --with-query, to scaffold it."
|
|
417
445
|
);
|
|
418
446
|
}
|
|
419
|
-
const mp = `${ctx.vars.MARKETPLACE_OWNER}/${ctx.vars.MARKETPLACE_REPO}`;
|
|
420
|
-
console.log(
|
|
421
|
-
`
|
|
422
|
-
Skills: install the basalt plugin once (user scope \u2192 all projects, then auto-updates):
|
|
423
|
-
claude plugin marketplace add ${mp}
|
|
424
|
-
claude plugin install basalt@${ctx.vars.MARKETPLACE_REPO} (enable auto-update when prompted)`
|
|
425
|
-
);
|
|
426
447
|
console.log(
|
|
427
448
|
`
|
|
428
449
|
Theme guard hook: add to .claude/settings.json \u2192 hooks.PreToolUse to catch violations before they land:
|
|
@@ -430,13 +451,13 @@ Theme guard hook: add to .claude/settings.json \u2192 hooks.PreToolUse to catch
|
|
|
430
451
|
"PreToolUse": [
|
|
431
452
|
{
|
|
432
453
|
"matcher": "Write|Edit|MultiEdit",
|
|
433
|
-
"hooks": [{ "type": "command", "command": "bunx basalt guard-hook" }]
|
|
454
|
+
"hooks": [{ "type": "command", "command": "bunx basalt-ui guard-hook" }]
|
|
434
455
|
}
|
|
435
456
|
]
|
|
436
457
|
}`
|
|
437
458
|
);
|
|
438
459
|
console.log(
|
|
439
|
-
"\nFirst run: run `basalt check-theme` next, then tune the per-rule `basalt.*` config keys in package.json for anything that fires \u2014 do not mass-`theme-allow` findings."
|
|
460
|
+
"\nFirst run: run `basalt-ui check-theme` next, then tune the per-rule `basalt.*` config keys in package.json for anything that fires \u2014 do not mass-`theme-allow` findings."
|
|
440
461
|
);
|
|
441
462
|
return 0;
|
|
442
463
|
}
|
|
@@ -458,7 +479,7 @@ function sync(opts = {}, cwd = process.cwd()) {
|
|
|
458
479
|
missingSources.push(file.source);
|
|
459
480
|
continue;
|
|
460
481
|
}
|
|
461
|
-
if (file.
|
|
482
|
+
if (file.mode === "seed") {
|
|
462
483
|
if (state.current === null && !opts.check) {
|
|
463
484
|
manifest.files[file.dest] = writeUnit(file, cwd, state.desired);
|
|
464
485
|
recreated++;
|
|
@@ -467,7 +488,7 @@ function sync(opts = {}, cwd = process.cwd()) {
|
|
|
467
488
|
}
|
|
468
489
|
const kind = classify(state, manifest.files[file.dest]);
|
|
469
490
|
if (kind === "current") {
|
|
470
|
-
manifest.files[file.dest] = sha256(state.desired);
|
|
491
|
+
manifest.files[file.dest] = sha256(normalizeForLedger(state.desired));
|
|
471
492
|
continue;
|
|
472
493
|
}
|
|
473
494
|
if (kind === "drifted" && !opts.force) {
|
|
@@ -484,20 +505,21 @@ function sync(opts = {}, cwd = process.cwd()) {
|
|
|
484
505
|
}
|
|
485
506
|
if (opts.check) {
|
|
486
507
|
if (driftLines.length > 0) {
|
|
487
|
-
console.error("basalt sync --check: locally-drifted managed files:");
|
|
508
|
+
console.error("basalt-ui sync --check: locally-drifted managed files:");
|
|
488
509
|
for (const l of driftLines) console.error(l);
|
|
489
510
|
}
|
|
490
511
|
if (staleForCheck > 0) {
|
|
491
|
-
console.error(`basalt sync --check: ${staleForCheck} managed file(s) out of date.`);
|
|
512
|
+
console.error(`basalt-ui sync --check: ${staleForCheck} managed file(s) out of date.`);
|
|
492
513
|
return 1;
|
|
493
514
|
}
|
|
494
|
-
console.log("\u2713 basalt sync --check: all managed files current.");
|
|
515
|
+
console.log("\u2713 basalt-ui sync --check: all managed files current.");
|
|
495
516
|
return 0;
|
|
496
517
|
}
|
|
518
|
+
manifest.basaltVersion = ctx.vars.BASALT_VERSION;
|
|
497
519
|
writeFileEnsuringDir(resolve(cwd, MANIFEST_PATH), `${JSON.stringify(manifest, null, 2)}
|
|
498
520
|
`);
|
|
499
521
|
console.log(
|
|
500
|
-
`basalt sync: ${updated} updated, ${recreated} recreated, ${skippedDrift} skipped (drift).`
|
|
522
|
+
`basalt-ui sync: ${updated} updated, ${recreated} recreated, ${skippedDrift} skipped (drift).`
|
|
501
523
|
);
|
|
502
524
|
if (driftLines.length > 0) {
|
|
503
525
|
console.log("Locally-edited files were skipped (run with --force to overwrite):");
|
|
@@ -505,12 +527,12 @@ function sync(opts = {}, cwd = process.cwd()) {
|
|
|
505
527
|
}
|
|
506
528
|
if (missingSources.length > 0) {
|
|
507
529
|
console.log(
|
|
508
|
-
`basalt sync: ${missingSources.length} shipped asset(s) not present, skipped: ${missingSources.join(", ")}`
|
|
530
|
+
`basalt-ui sync: ${missingSources.length} shipped asset(s) not present, skipped: ${missingSources.join(", ")}`
|
|
509
531
|
);
|
|
510
532
|
}
|
|
511
533
|
return 0;
|
|
512
534
|
}
|
|
513
|
-
function checkCoverage(
|
|
535
|
+
function checkCoverage() {
|
|
514
536
|
const pkgRoot = packageRoot();
|
|
515
537
|
const failures = [];
|
|
516
538
|
const allSpecs = Object.entries(SURFACES);
|
|
@@ -536,26 +558,12 @@ function checkCoverage(cwd = process.cwd()) {
|
|
|
536
558
|
);
|
|
537
559
|
}
|
|
538
560
|
}
|
|
539
|
-
const
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
let pluginSkillNames = /* @__PURE__ */ new Set();
|
|
546
|
-
try {
|
|
547
|
-
const pluginJson = JSON.parse(readFileSync(pluginJsonPath, "utf8"));
|
|
548
|
-
pluginSkillNames = new Set((pluginJson.skills ?? []).map((s) => s.split("/").pop() ?? s));
|
|
549
|
-
} catch {
|
|
550
|
-
failures.push(`Cannot read plugin.json at ${pluginJsonPath}`);
|
|
551
|
-
}
|
|
552
|
-
const doctrineSkillUnion = new Set(doctrineSpecs.flatMap((s) => [...s.skill]));
|
|
553
|
-
for (const skill of doctrineSkillUnion) {
|
|
554
|
-
if (!pluginSkillNames.has(skill)) {
|
|
555
|
-
failures.push(
|
|
556
|
-
`SURFACES doctrine skill '${skill}' is not listed in plugins/basalt/.claude-plugin/plugin.json skills`
|
|
557
|
-
);
|
|
558
|
-
}
|
|
561
|
+
for (const skill of SKILL_NAMES) {
|
|
562
|
+
const skillPath = resolve(pkgRoot, `agent/skills/${skill}/SKILL.md`);
|
|
563
|
+
if (!existsSync(skillPath)) {
|
|
564
|
+
failures.push(
|
|
565
|
+
`Missing skill file: agent/skills/${skill}/SKILL.md (derived from SURFACES doctrine skills)`
|
|
566
|
+
);
|
|
559
567
|
}
|
|
560
568
|
}
|
|
561
569
|
let pkgExports = /* @__PURE__ */ new Set();
|
|
@@ -590,8 +598,25 @@ function checkCoverage(cwd = process.cwd()) {
|
|
|
590
598
|
}
|
|
591
599
|
}
|
|
592
600
|
const REQUIRED_MANTINE_BANS = ["@mantine/core", "@mantine/hooks", "@mantine/*"];
|
|
601
|
+
let shippedRules;
|
|
602
|
+
try {
|
|
603
|
+
const shippedConfig = JSON.parse(
|
|
604
|
+
readFileSync(resolve(pkgRoot, "configs/oxlint.json"), "utf8")
|
|
605
|
+
);
|
|
606
|
+
shippedRules = shippedConfig.rules;
|
|
607
|
+
} catch {
|
|
608
|
+
failures.push(`Cannot read configs/oxlint.json at ${pkgRoot} to verify basalt/import-boundary`);
|
|
609
|
+
}
|
|
610
|
+
const importBoundaryRegistered = hasImportBoundaryRuleRegistered(shippedRules);
|
|
593
611
|
for (const [key, spec] of allSpecs) {
|
|
594
612
|
if (spec.layer !== "headless") continue;
|
|
613
|
+
if (MANTINE_FREE_VIA_IMPORT_BOUNDARY.has(key)) {
|
|
614
|
+
if (importBoundaryRegistered) continue;
|
|
615
|
+
failures.push(
|
|
616
|
+
`SURFACES['${key}'] relies on the basalt/import-boundary plugin rule for Mantine-free coverage, but that rule is not registered as 'error' in configs/oxlint.json`
|
|
617
|
+
);
|
|
618
|
+
continue;
|
|
619
|
+
}
|
|
595
620
|
for (const required of REQUIRED_MANTINE_BANS) {
|
|
596
621
|
const hasBan = spec.forbiddenImports.some((fi) => fi.spec === required);
|
|
597
622
|
if (!hasBan) {
|
|
@@ -637,7 +662,7 @@ function checkCoverage(cwd = process.cwd()) {
|
|
|
637
662
|
function doctor(cwd = process.cwd()) {
|
|
638
663
|
const result = { hardFailures: 0, warnings: 0 };
|
|
639
664
|
const lines = [`
|
|
640
|
-
basalt doctor \u2014 ${cwd}
|
|
665
|
+
basalt-ui doctor \u2014 ${cwd}
|
|
641
666
|
`];
|
|
642
667
|
function pass(msg) {
|
|
643
668
|
lines.push(` \u2713 ${msg}`);
|
|
@@ -651,61 +676,44 @@ basalt doctor \u2014 ${cwd}
|
|
|
651
676
|
result.hardFailures++;
|
|
652
677
|
}
|
|
653
678
|
const manifestAbs = resolve(cwd, MANIFEST_PATH);
|
|
654
|
-
|
|
679
|
+
const manifestExists = existsSync(manifestAbs);
|
|
680
|
+
if (manifestExists) {
|
|
655
681
|
pass(`${MANIFEST_PATH} exists`);
|
|
656
682
|
} else {
|
|
657
|
-
fail(`${MANIFEST_PATH} missing \u2014 run \`basalt init\` to scaffold the consumer repo`);
|
|
658
|
-
}
|
|
659
|
-
const claudeMdAbs = resolve(cwd, "CLAUDE.md");
|
|
660
|
-
const claudeMdContent = readIfExists(claudeMdAbs);
|
|
661
|
-
if (claudeMdContent !== null && claudeMdContent.includes(BLOCK_BEGIN_PREFIX)) {
|
|
662
|
-
pass("CLAUDE.md contains the basalt managed block");
|
|
663
|
-
} else if (claudeMdContent === null) {
|
|
664
|
-
warn("CLAUDE.md not found \u2014 run `basalt init` to scaffold the basalt block");
|
|
665
|
-
} else {
|
|
666
|
-
warn(
|
|
667
|
-
`CLAUDE.md does not contain the basalt managed block (expected marker: ${BLOCK_BEGIN_PREFIX}) \u2014 run \`basalt sync\``
|
|
668
|
-
);
|
|
669
|
-
}
|
|
670
|
-
const missingRules = [];
|
|
671
|
-
for (const name of RULE_NAMES) {
|
|
672
|
-
const ruleAbs = resolve(cwd, `.claude/rules/basalt-${name}.md`);
|
|
673
|
-
if (!existsSync(ruleAbs)) missingRules.push(`basalt-${name}.md`);
|
|
683
|
+
fail(`${MANIFEST_PATH} missing \u2014 run \`basalt-ui init\` to scaffold the consumer repo`);
|
|
674
684
|
}
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
685
|
+
const consumerPkgRaw = readIfExists(resolve(cwd, "node_modules", "basalt-ui", "package.json"));
|
|
686
|
+
let installedVersion = null;
|
|
687
|
+
if (consumerPkgRaw !== null) {
|
|
688
|
+
try {
|
|
689
|
+
const consumerPkg = JSON.parse(consumerPkgRaw);
|
|
690
|
+
installedVersion = consumerPkg.version ?? null;
|
|
691
|
+
} catch {
|
|
692
|
+
warn("could not parse node_modules/basalt-ui/package.json \u2014 version checks skipped");
|
|
693
|
+
}
|
|
681
694
|
}
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
if (settingsContent !== null && settingsContent.includes("basalt")) {
|
|
686
|
-
pass("basalt plugin appears installed in ~/.claude/settings.json");
|
|
687
|
-
} else {
|
|
695
|
+
if (manifestExists && installedVersion !== null) {
|
|
696
|
+
const manifestVersion = readManifest(cwd).basaltVersion;
|
|
697
|
+
if (manifestVersion === void 0) {
|
|
688
698
|
warn(
|
|
689
|
-
|
|
699
|
+
`${MANIFEST_PATH} records no basaltVersion (written by an older basalt-ui) \u2014 run \`basalt-ui sync\` to refresh the doctrine and stamp the manifest.`
|
|
690
700
|
);
|
|
701
|
+
} else if (manifestVersion !== installedVersion) {
|
|
702
|
+
warn(
|
|
703
|
+
`installed basalt-ui (${installedVersion}) differs from the version that last synced (${manifestVersion}) \u2014 the placed doctrine is stale; run \`basalt-ui sync\`.`
|
|
704
|
+
);
|
|
705
|
+
} else {
|
|
706
|
+
pass(`installed basalt-ui (${installedVersion}) matches the manifest's basaltVersion`);
|
|
691
707
|
}
|
|
692
|
-
} catch {
|
|
693
|
-
warn("could not read ~/.claude/settings.json \u2014 plugin install status unknown");
|
|
694
708
|
}
|
|
695
709
|
const cliVersion = readFrameworkVersion(packageRoot());
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
);
|
|
704
|
-
} else {
|
|
705
|
-
pass(`CLI version (${cliVersion}) matches the installed basalt-ui in node_modules`);
|
|
706
|
-
}
|
|
707
|
-
} catch {
|
|
708
|
-
warn("could not parse node_modules/basalt-ui/package.json \u2014 CLI version check skipped");
|
|
710
|
+
if (installedVersion !== null) {
|
|
711
|
+
if (installedVersion !== cliVersion) {
|
|
712
|
+
warn(
|
|
713
|
+
`running CLI version (${cliVersion}) differs from the installed basalt-ui version in node_modules (${installedVersion}) \u2014 likely a stale \`bunx basalt-ui\` fetch from npm; add basalt-ui as a root devDependency so the bin hoists from your workspace.`
|
|
714
|
+
);
|
|
715
|
+
} else {
|
|
716
|
+
pass(`CLI version (${cliVersion}) matches the installed basalt-ui in node_modules`);
|
|
709
717
|
}
|
|
710
718
|
}
|
|
711
719
|
lines.push("");
|
|
@@ -865,8 +873,13 @@ async function guardHook(cwd = process.cwd()) {
|
|
|
865
873
|
}
|
|
866
874
|
return 0;
|
|
867
875
|
}
|
|
876
|
+
const USAGE = "Usage: basalt-ui <init [--with-router] [--with-query] | sync [--force] [--check] | check-theme | check-coverage | info [--json] | doctor | guard-hook | help>\n\nEvery subcommand accepts --help / -h to print this message and exit without running.";
|
|
868
877
|
function run(argv, cwd = process.cwd()) {
|
|
869
878
|
const [cmd, ...flags] = argv;
|
|
879
|
+
if (cmd === "help" || cmd === "--help" || cmd === "-h" || flags.includes("--help") || flags.includes("-h")) {
|
|
880
|
+
console.log(USAGE);
|
|
881
|
+
return 0;
|
|
882
|
+
}
|
|
870
883
|
switch (cmd) {
|
|
871
884
|
case "init":
|
|
872
885
|
return init(cwd, {
|
|
@@ -878,7 +891,7 @@ function run(argv, cwd = process.cwd()) {
|
|
|
878
891
|
case "check-theme":
|
|
879
892
|
return checkTheme(cwd);
|
|
880
893
|
case "check-coverage":
|
|
881
|
-
return checkCoverage(
|
|
894
|
+
return checkCoverage();
|
|
882
895
|
case "info":
|
|
883
896
|
return info(flags);
|
|
884
897
|
case "doctor":
|
|
@@ -886,15 +899,14 @@ function run(argv, cwd = process.cwd()) {
|
|
|
886
899
|
case "guard-hook":
|
|
887
900
|
return guardHook(cwd);
|
|
888
901
|
default:
|
|
889
|
-
console.error(
|
|
890
|
-
"Usage: basalt <init [--with-router] [--with-query] | sync [--force] [--check] | check-theme | check-coverage | info [--json] | doctor | guard-hook>"
|
|
891
|
-
);
|
|
902
|
+
console.error(USAGE);
|
|
892
903
|
return 1;
|
|
893
904
|
}
|
|
894
905
|
}
|
|
895
906
|
export {
|
|
896
907
|
MANIFEST_PATH,
|
|
897
908
|
RULE_NAMES,
|
|
909
|
+
SKILL_NAMES,
|
|
898
910
|
checkCoverage,
|
|
899
911
|
checkTheme,
|
|
900
912
|
doctor,
|
|
@@ -902,6 +914,7 @@ export {
|
|
|
902
914
|
info,
|
|
903
915
|
init,
|
|
904
916
|
managedFiles,
|
|
917
|
+
normalizeForLedger,
|
|
905
918
|
run,
|
|
906
919
|
sync
|
|
907
920
|
};
|
package/dist/surfaces.d.ts
CHANGED
|
@@ -13,7 +13,8 @@ import type { GuardKind } from './guard/types.js';
|
|
|
13
13
|
* // const bad: RuleName = 'overlays' // tsc error — not in the union
|
|
14
14
|
*/
|
|
15
15
|
export type RuleName = 'tokens' | 'charts' | 'mantine' | 'router' | 'query' | 'state' | 'forms' | 'notifications' | 'commands' | 'data' | 'agent' | 'content';
|
|
16
|
-
/** The 3
|
|
16
|
+
/** The 3 shipped skill names (agent/skills/basalt-{name}/SKILL.md, placed into a consumer's
|
|
17
|
+
* .claude/skills/ by `basalt-ui init`/`sync` — the same managed path the rules take).
|
|
17
18
|
*
|
|
18
19
|
* @example
|
|
19
20
|
* const s: SkillName = 'basalt-app'
|
|
@@ -59,13 +60,6 @@ type BaseSurface = {
|
|
|
59
60
|
readonly layer: Layer;
|
|
60
61
|
readonly forbiddenImports: readonly ForbiddenImport[];
|
|
61
62
|
readonly ruleOverrides?: readonly RuleOverride[];
|
|
62
|
-
/**
|
|
63
|
-
* REPLACE-not-inherit-and-add. When true, this surface's forbiddenImports are the COMPLETE ban
|
|
64
|
-
* set for its glob — the generator MUST NOT inherit-and-add the parent (src/**) bans. Charts sets
|
|
65
|
-
* this so the @visx/* ban from src/** does NOT leak into the charts override (which would re-ban
|
|
66
|
-
* visx). The projection emits the full list.
|
|
67
|
-
*/
|
|
68
|
-
readonly replaceBans?: true;
|
|
69
63
|
/**
|
|
70
64
|
* Human-readable description of this surface — single source for llms.txt and info output.
|
|
71
65
|
* Optional on tooling surfaces (they have no llms.txt row).
|
|
@@ -149,8 +143,7 @@ export declare const SURFACES: {
|
|
|
149
143
|
readonly shipped: readonly ["**/charts/**"];
|
|
150
144
|
readonly repo: readonly ["packages/basalt-ui/src/charts/**"];
|
|
151
145
|
};
|
|
152
|
-
readonly
|
|
153
|
-
readonly forbiddenImports: readonly [ForbiddenImport, ForbiddenImport, ForbiddenImport, ForbiddenImport];
|
|
146
|
+
readonly forbiddenImports: readonly [];
|
|
154
147
|
readonly ruleOverrides: readonly [{
|
|
155
148
|
readonly rule: "no-underscore-dangle";
|
|
156
149
|
readonly level: "off";
|
|
@@ -168,7 +161,7 @@ export declare const SURFACES: {
|
|
|
168
161
|
readonly shipped: readonly ["**/tokens/**"];
|
|
169
162
|
readonly repo: readonly ["packages/basalt-ui/src/tokens/**"];
|
|
170
163
|
};
|
|
171
|
-
readonly forbiddenImports: readonly [
|
|
164
|
+
readonly forbiddenImports: readonly [];
|
|
172
165
|
};
|
|
173
166
|
readonly './theme-lab': {
|
|
174
167
|
readonly kind: "tooling";
|
|
@@ -190,7 +183,7 @@ export declare const SURFACES: {
|
|
|
190
183
|
readonly shipped: readonly [];
|
|
191
184
|
readonly repo: readonly ["packages/basalt-ui/src/guard/**"];
|
|
192
185
|
};
|
|
193
|
-
readonly forbiddenImports: readonly [ForbiddenImport, ForbiddenImport, ForbiddenImport
|
|
186
|
+
readonly forbiddenImports: readonly [ForbiddenImport, ForbiddenImport, ForbiddenImport];
|
|
194
187
|
};
|
|
195
188
|
readonly './query': {
|
|
196
189
|
readonly kind: "doctrine";
|
|
@@ -204,7 +197,7 @@ export declare const SURFACES: {
|
|
|
204
197
|
readonly shipped: readonly [];
|
|
205
198
|
readonly repo: readonly ["packages/basalt-ui/src/query/**"];
|
|
206
199
|
};
|
|
207
|
-
readonly forbiddenImports: readonly [ForbiddenImport, ForbiddenImport, ForbiddenImport
|
|
200
|
+
readonly forbiddenImports: readonly [ForbiddenImport, ForbiddenImport, ForbiddenImport];
|
|
208
201
|
};
|
|
209
202
|
readonly './router-tanstack': {
|
|
210
203
|
readonly kind: "doctrine";
|
|
@@ -218,7 +211,7 @@ export declare const SURFACES: {
|
|
|
218
211
|
readonly shipped: readonly [];
|
|
219
212
|
readonly repo: readonly ["packages/basalt-ui/src/router-tanstack/**"];
|
|
220
213
|
};
|
|
221
|
-
readonly forbiddenImports: readonly [ForbiddenImport, ForbiddenImport, ForbiddenImport
|
|
214
|
+
readonly forbiddenImports: readonly [ForbiddenImport, ForbiddenImport, ForbiddenImport];
|
|
222
215
|
};
|
|
223
216
|
readonly './forms': {
|
|
224
217
|
readonly kind: "doctrine";
|
|
@@ -292,7 +285,7 @@ export declare const SURFACES: {
|
|
|
292
285
|
readonly shipped: readonly [];
|
|
293
286
|
readonly repo: readonly ["packages/basalt-ui/src/agent/**"];
|
|
294
287
|
};
|
|
295
|
-
readonly forbiddenImports: readonly [ForbiddenImport, ForbiddenImport, ForbiddenImport
|
|
288
|
+
readonly forbiddenImports: readonly [ForbiddenImport, ForbiddenImport, ForbiddenImport];
|
|
296
289
|
};
|
|
297
290
|
readonly './content': {
|
|
298
291
|
readonly kind: "doctrine";
|
|
@@ -316,7 +309,7 @@ export declare const SURFACES: {
|
|
|
316
309
|
readonly shipped: readonly [];
|
|
317
310
|
readonly repo: readonly ["packages/basalt-ui/src/state.ts"];
|
|
318
311
|
};
|
|
319
|
-
readonly forbiddenImports: readonly [ForbiddenImport, ForbiddenImport, ForbiddenImport
|
|
312
|
+
readonly forbiddenImports: readonly [ForbiddenImport, ForbiddenImport, ForbiddenImport];
|
|
320
313
|
};
|
|
321
314
|
readonly './connectivity': {
|
|
322
315
|
readonly kind: "doctrine";
|
|
@@ -361,7 +354,7 @@ export declare const SURFACES: {
|
|
|
361
354
|
readonly level: "off";
|
|
362
355
|
readonly target: "repo";
|
|
363
356
|
}];
|
|
364
|
-
readonly forbiddenImports: readonly [ForbiddenImport, ForbiddenImport
|
|
357
|
+
readonly forbiddenImports: readonly [ForbiddenImport, ForbiddenImport];
|
|
365
358
|
};
|
|
366
359
|
};
|
|
367
360
|
/**
|
|
@@ -372,5 +365,36 @@ export declare const SURFACES: {
|
|
|
372
365
|
* RULE_NAMES.includes('tokens') // true
|
|
373
366
|
*/
|
|
374
367
|
export declare const RULE_NAMES: readonly RuleName[];
|
|
368
|
+
/**
|
|
369
|
+
* Derived, deduped set of doctrine skill names. Same projection shape as RULE_NAMES — the CLI's
|
|
370
|
+
* managed-file manifest and check-coverage both consume it, so a skill referenced by any doctrine
|
|
371
|
+
* surface is guaranteed a `agent/skills/{name}/SKILL.md` placement path.
|
|
372
|
+
*
|
|
373
|
+
* @example
|
|
374
|
+
* SKILL_NAMES.includes('basalt-design') // true
|
|
375
|
+
*/
|
|
376
|
+
export declare const SKILL_NAMES: readonly SkillName[];
|
|
377
|
+
/**
|
|
378
|
+
* Headless SURFACES keys whose Mantine-free guarantee is enforced by the `basalt/import-boundary`
|
|
379
|
+
* oxlint plugin rule (`configs/oxlint-plugin.js`) instead of a `forbiddenImports` no-restricted-
|
|
380
|
+
* imports ban — the rule fires on `charts`/`tokens` path segments only, so ONLY these two surfaces
|
|
381
|
+
* qualify (every other headless surface still carries its Mantine ban in `forbiddenImports`).
|
|
382
|
+
*
|
|
383
|
+
* Membership alone does NOT satisfy the coverage check — `checkCoverage()`'s assertion 7 (and its
|
|
384
|
+
* test mirror) also require `hasImportBoundaryRuleRegistered` to hold, so a future removal of the
|
|
385
|
+
* plugin rule's registration still fails loudly instead of silently passing.
|
|
386
|
+
*/
|
|
387
|
+
export declare const MANTINE_FREE_VIA_IMPORT_BOUNDARY: ReadonlySet<string>;
|
|
388
|
+
/**
|
|
389
|
+
* True when a parsed oxlint config's `rules` object registers `basalt/import-boundary` as `'error'`
|
|
390
|
+
* — the live signal (not just a hardcoded assumption) that `MANTINE_FREE_VIA_IMPORT_BOUNDARY`
|
|
391
|
+
* surfaces are actually enforced. Pure — callers read + JSON.parse the config file themselves
|
|
392
|
+
* (surfaces.ts stays dependency-free, no fs access here).
|
|
393
|
+
*
|
|
394
|
+
* @example
|
|
395
|
+
* hasImportBoundaryRuleRegistered({ 'basalt/import-boundary': 'error' }) // true
|
|
396
|
+
* hasImportBoundaryRuleRegistered({}) // false
|
|
397
|
+
*/
|
|
398
|
+
export declare function hasImportBoundaryRuleRegistered(rules: Record<string, unknown> | undefined): boolean;
|
|
375
399
|
export {};
|
|
376
400
|
//# sourceMappingURL=surfaces.d.ts.map
|