basalt-ui 2.14.0 → 2.15.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/CHANGELOG.md +40 -0
- package/MIGRATING.md +19 -13
- package/agent/agents/basalt-design-reviewer.md +83 -0
- package/agent/rules/basalt-batteries.md +1 -2
- package/agent/rules/basalt-charts.md +1 -1
- package/agent/rules/basalt-controls.md +3 -3
- package/agent/rules/basalt-mantine.md +1 -2
- package/agent/rules/basalt-state.md +1 -2
- package/agent/rules/basalt-tokens.md +1 -3
- package/agent/skills/basalt-design/SKILL.md +26 -8
- package/agent/templates/AGENTS-block.md.tpl +7 -0
- package/configs/oxlint-plugin.js +39 -2
- package/configs/oxlint-plugin.test.ts +48 -0
- package/dist/charts/legend.d.ts +4 -4
- package/dist/cli/board-freshness.d.ts +25 -0
- package/dist/cli/board-freshness.d.ts.map +1 -0
- package/dist/cli/board-freshness.js +88 -0
- package/dist/cli/doctor.d.ts +2 -1
- package/dist/cli/doctor.d.ts.map +1 -1
- package/dist/cli/doctor.js +3 -1
- package/dist/cli/help.d.ts.map +1 -1
- package/dist/cli/help.js +9 -3
- package/dist/cli/index.d.ts +15 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +57 -7
- package/dist/cli/init.d.ts.map +1 -1
- package/dist/cli/init.js +6 -1
- package/dist/cli/shot/board.d.ts +5 -0
- package/dist/cli/shot/board.d.ts.map +1 -0
- package/dist/cli/shot/board.js +96 -0
- package/dist/cli/shot/capture.d.ts +59 -0
- package/dist/cli/shot/capture.d.ts.map +1 -0
- package/dist/cli/shot/capture.js +473 -0
- package/dist/cli/shot/index.d.ts +45 -0
- package/dist/cli/shot/index.d.ts.map +1 -0
- package/dist/cli/shot/index.js +289 -0
- package/dist/cli/shot/measure.d.ts +28 -0
- package/dist/cli/shot/measure.d.ts.map +1 -0
- package/dist/cli/shot/measure.js +176 -0
- package/dist/cli/shot/playwright.d.ts +101 -0
- package/dist/cli/shot/playwright.d.ts.map +1 -0
- package/dist/cli/shot/playwright.js +60 -0
- package/dist/cli/shot/serve.d.ts +6 -0
- package/dist/cli/shot/serve.d.ts.map +1 -0
- package/dist/cli/shot/serve.js +33 -0
- package/dist/cli/shot/types.d.ts +97 -0
- package/dist/cli/shot/types.d.ts.map +1 -0
- package/dist/cli/shot/types.js +17 -0
- package/dist/cli/sync.d.ts.map +1 -1
- package/dist/cli/sync.js +2 -1
- package/dist/surfaces.d.ts +2 -0
- package/dist/surfaces.d.ts.map +1 -1
- package/dist/surfaces.js +2 -0
- package/llms.txt +2 -2
- package/package.json +1 -1
- package/src/charts/legend.tsx +4 -4
- package/src/cli/board-freshness.ts +132 -0
- package/src/cli/doctor.ts +10 -1
- package/src/cli/help.ts +14 -2
- package/src/cli/index.ts +80 -10
- package/src/cli/init.ts +8 -1
- package/src/cli/shot/board.ts +154 -0
- package/src/cli/shot/capture.ts +650 -0
- package/src/cli/shot/index.ts +362 -0
- package/src/cli/shot/measure.ts +225 -0
- package/src/cli/shot/playwright.ts +152 -0
- package/src/cli/shot/serve.ts +35 -0
- package/src/cli/shot/types.ts +91 -0
- package/src/cli/sync.ts +2 -1
- package/src/surfaces.ts +5 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { existsSync, statSync } from "node:fs";
|
|
2
|
+
import { join, normalize, resolve, sep } from "node:path";
|
|
3
|
+
import { ShotError } from "./playwright.js";
|
|
4
|
+
function serveDist(distDir) {
|
|
5
|
+
const root = resolve(distDir);
|
|
6
|
+
if (!existsSync(root) || !statSync(root).isDirectory()) {
|
|
7
|
+
throw new ShotError(`--dist ${distDir} is not a directory`);
|
|
8
|
+
}
|
|
9
|
+
const fileFor = (pathname) => {
|
|
10
|
+
const file = normalize(join(root, decodeURIComponent(pathname)));
|
|
11
|
+
if (file !== root && !file.startsWith(root + sep)) return null;
|
|
12
|
+
if (existsSync(file) && statSync(file).isFile()) return file;
|
|
13
|
+
if (/\.[a-z0-9]+$/i.test(pathname)) return null;
|
|
14
|
+
const index = join(root, "index.html");
|
|
15
|
+
return existsSync(index) ? index : null;
|
|
16
|
+
};
|
|
17
|
+
const server = Bun.serve({
|
|
18
|
+
port: 0,
|
|
19
|
+
hostname: "127.0.0.1",
|
|
20
|
+
fetch(req) {
|
|
21
|
+
try {
|
|
22
|
+
const file = fileFor(new URL(req.url).pathname);
|
|
23
|
+
return file ? new Response(Bun.file(file), { headers: { "cache-control": "no-store" } }) : new Response("not found", { status: 404 });
|
|
24
|
+
} catch {
|
|
25
|
+
return new Response("bad request", { status: 400 });
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
return { origin: `http://127.0.0.1:${server.port}`, stop: () => void server.stop(true) };
|
|
30
|
+
}
|
|
31
|
+
export {
|
|
32
|
+
serveDist
|
|
33
|
+
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
export declare const SCHEMES: readonly ["light", "dark"];
|
|
2
|
+
export declare const VIEWPORTS: readonly ["desktop", "mobile"];
|
|
3
|
+
export declare const STATES: readonly ["rest", "hover", "focus", "tooltip", "empty", "loading", "error"];
|
|
4
|
+
/** The states a page opts into with `data-shot-states`; reached through the `shot-state` URL param. */
|
|
5
|
+
export declare const URL_STATES: readonly ["empty", "loading", "error"];
|
|
6
|
+
/** The `name` of a route's full-page shot: not a valid `data-shot` value. */
|
|
7
|
+
export declare const PAGE_ANCHOR = "_page";
|
|
8
|
+
export type Scheme = (typeof SCHEMES)[number];
|
|
9
|
+
export type Viewport = (typeof VIEWPORTS)[number];
|
|
10
|
+
export type ShotState = (typeof STATES)[number];
|
|
11
|
+
export declare const VIEWPORT_SPECS: Record<Viewport, {
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
mobile: boolean;
|
|
15
|
+
}>;
|
|
16
|
+
export type Sides = {
|
|
17
|
+
top: number;
|
|
18
|
+
right: number;
|
|
19
|
+
bottom: number;
|
|
20
|
+
left: number;
|
|
21
|
+
};
|
|
22
|
+
export type ContrastFailure = {
|
|
23
|
+
text: string;
|
|
24
|
+
ratio: number;
|
|
25
|
+
fg: string;
|
|
26
|
+
bg: string;
|
|
27
|
+
fontSize: number;
|
|
28
|
+
};
|
|
29
|
+
/** What the in-page measurer returns for one anchor. */
|
|
30
|
+
export type Measurement = {
|
|
31
|
+
box: {
|
|
32
|
+
width: number;
|
|
33
|
+
height: number;
|
|
34
|
+
};
|
|
35
|
+
padding: Sides;
|
|
36
|
+
gap: {
|
|
37
|
+
row: number;
|
|
38
|
+
column: number;
|
|
39
|
+
};
|
|
40
|
+
radius: number;
|
|
41
|
+
borderWidth: number;
|
|
42
|
+
fontSizes: number[];
|
|
43
|
+
nested: {
|
|
44
|
+
path: string;
|
|
45
|
+
radius: number;
|
|
46
|
+
padding: Sides;
|
|
47
|
+
}[];
|
|
48
|
+
emptyRatio: number;
|
|
49
|
+
/** `min` is null when the anchor holds no text. */
|
|
50
|
+
contrast: {
|
|
51
|
+
min: number | null;
|
|
52
|
+
failures: ContrastFailure[];
|
|
53
|
+
/** Set when some text sat on no opaque ancestor background and white was assumed. */
|
|
54
|
+
backdrop?: 'assumed-white';
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
export type AnchorMetrics = Measurement & {
|
|
58
|
+
route: string;
|
|
59
|
+
name: string;
|
|
60
|
+
scheme: Scheme;
|
|
61
|
+
viewport: Viewport;
|
|
62
|
+
/** The anchor's contact sheet (`png/…__sheet.png`): every state × scheme × viewport on one image. Absent when it could not be written. */
|
|
63
|
+
sheet?: string;
|
|
64
|
+
};
|
|
65
|
+
export type ShotRecord = {
|
|
66
|
+
route: string;
|
|
67
|
+
name: string;
|
|
68
|
+
scheme: Scheme;
|
|
69
|
+
viewport: Viewport;
|
|
70
|
+
state: ShotState;
|
|
71
|
+
file: string | null;
|
|
72
|
+
status: 'ok' | 'not-declared' | 'skipped' | 'error';
|
|
73
|
+
note?: string;
|
|
74
|
+
};
|
|
75
|
+
/** The theme's resolved steps (px) for one scheme × viewport; a missing custom property is omitted. */
|
|
76
|
+
export type Scale = {
|
|
77
|
+
scheme: Scheme;
|
|
78
|
+
viewport: Viewport;
|
|
79
|
+
spacing: Record<string, number>;
|
|
80
|
+
radius: Record<string, number>;
|
|
81
|
+
fontSizes: Record<string, number>;
|
|
82
|
+
};
|
|
83
|
+
export type ShotMetrics = {
|
|
84
|
+
version: 1;
|
|
85
|
+
generatedAt: string;
|
|
86
|
+
base: string;
|
|
87
|
+
routes: string[];
|
|
88
|
+
viewports: Viewport[];
|
|
89
|
+
schemes: Scheme[];
|
|
90
|
+
states: ShotState[];
|
|
91
|
+
scale: Scale[];
|
|
92
|
+
/** Why `scale` is empty or partial; absent when it was read. */
|
|
93
|
+
scaleError?: string;
|
|
94
|
+
anchors: AnchorMetrics[];
|
|
95
|
+
shots: ShotRecord[];
|
|
96
|
+
};
|
|
97
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/cli/shot/types.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,4BAA6B,CAAA;AACjD,eAAO,MAAM,SAAS,gCAAiC,CAAA;AACvD,eAAO,MAAM,MAAM,6EAA8E,CAAA;AACjG,uGAAuG;AACvG,eAAO,MAAM,UAAU,wCAAyC,CAAA;AAEhE,6EAA6E;AAC7E,eAAO,MAAM,WAAW,UAAU,CAAA;AAElC,MAAM,MAAM,MAAM,GAAG,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,CAAC,CAAA;AAC7C,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,CAAC,CAAA;AACjD,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,MAAM,CAAC,CAAC,MAAM,CAAC,CAAA;AAE/C,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,QAAQ,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EA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"];
|
|
2
|
+
const VIEWPORTS = ["desktop", "mobile"];
|
|
3
|
+
const STATES = ["rest", "hover", "focus", "tooltip", "empty", "loading", "error"];
|
|
4
|
+
const URL_STATES = ["empty", "loading", "error"];
|
|
5
|
+
const PAGE_ANCHOR = "_page";
|
|
6
|
+
const VIEWPORT_SPECS = {
|
|
7
|
+
desktop: { width: 1440, height: 900, mobile: false },
|
|
8
|
+
mobile: { width: 390, height: 844, mobile: true }
|
|
9
|
+
};
|
|
10
|
+
export {
|
|
11
|
+
PAGE_ANCHOR,
|
|
12
|
+
SCHEMES,
|
|
13
|
+
STATES,
|
|
14
|
+
URL_STATES,
|
|
15
|
+
VIEWPORTS,
|
|
16
|
+
VIEWPORT_SPECS
|
|
17
|
+
};
|
package/dist/cli/sync.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../src/cli/sync.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../src/cli/sync.ts"],"names":[],"mappings":"AAgDA,gGAAgG;AAChG,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAGjE;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,mGAAmG;IACnG,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAC1B,CAAA;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAKrF;AAQD;;;;;;;;;GASG;AACH,wBAAgB,IAAI,CAAC,IAAI,GAAE,WAAgB,EAAE,aAAa,GAAE,MAAsB,GAAG,MAAM,CAiP1F"}
|
package/dist/cli/sync.js
CHANGED
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
readManifest,
|
|
25
25
|
readSource,
|
|
26
26
|
reconcileRoots,
|
|
27
|
+
ruleRootsFor,
|
|
27
28
|
relativePosix,
|
|
28
29
|
renderContext,
|
|
29
30
|
reportPrune,
|
|
@@ -92,7 +93,7 @@ function sync(opts = {}, invocationCwd = process.cwd()) {
|
|
|
92
93
|
return 1;
|
|
93
94
|
}
|
|
94
95
|
const rootsState = reconcileRoots(cwd, { write: opts.check !== true });
|
|
95
|
-
const ctx = renderContext(cwd);
|
|
96
|
+
const ctx = renderContext(cwd, ruleRootsFor(rootsState));
|
|
96
97
|
const manifest = readManifest(cwd);
|
|
97
98
|
const placement = resolvePlacement(cwd);
|
|
98
99
|
const { skip: seedSkip, skipped } = routerSeedPlan(cwd, placement.appRel);
|
package/dist/surfaces.d.ts
CHANGED
|
@@ -379,6 +379,8 @@ export declare const RULE_NAMES: readonly RuleName[];
|
|
|
379
379
|
* SKILL_NAMES.includes('basalt-design') // true
|
|
380
380
|
*/
|
|
381
381
|
export declare const SKILL_NAMES: readonly SkillName[];
|
|
382
|
+
/** The shipped subagents (`agent/agents/<name>.md`), installed at `.claude/agents/`. */
|
|
383
|
+
export declare const AGENT_NAMES: readonly ["basalt-design-reviewer"];
|
|
382
384
|
/**
|
|
383
385
|
* Headless SURFACES keys whose Mantine-free guarantee is enforced by the `basalt/token-layer-
|
|
384
386
|
* boundary` oxlint plugin rule (`configs/oxlint-plugin.js`) instead of a `forbiddenImports`
|
package/dist/surfaces.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"surfaces.d.ts","sourceRoot":"","sources":["../src/surfaces.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAI9C;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,OAAO,GAAG,UAAU,GAAG,WAAW,CA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AAO,MAAM,6BAA6B,EAAE,WAAW,CAAC,MAAM,CAAqC,CAAA;AAEnG;;;;;;;;;;;;GAYG;AACH,wBAAgB,+BAA+B,CAC7C,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GACzC,OAAO,CAET"}
|
package/dist/surfaces.js
CHANGED
|
@@ -420,11 +420,13 @@ const SKILL_NAMES = [
|
|
|
420
420
|
Object.values(SURFACES).filter((s) => s.kind === "doctrine").flatMap((s) => [...s.skill])
|
|
421
421
|
)
|
|
422
422
|
];
|
|
423
|
+
const AGENT_NAMES = ["basalt-design-reviewer"];
|
|
423
424
|
const TOKEN_LAYER_BOUNDARY_SURFACES = /* @__PURE__ */ new Set(["./charts", "./tokens"]);
|
|
424
425
|
function hasTokenLayerBoundaryRegistered(rules) {
|
|
425
426
|
return rules?.["basalt/token-layer-boundary"] === "error";
|
|
426
427
|
}
|
|
427
428
|
export {
|
|
429
|
+
AGENT_NAMES,
|
|
428
430
|
PLUGIN_RULE_ID_LIST,
|
|
429
431
|
RULE_NAMES,
|
|
430
432
|
SKILL_NAMES,
|
package/llms.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# basalt-ui v2.
|
|
1
|
+
# basalt-ui v2.15.0
|
|
2
2
|
# Opinionated framework for Mantine-based React apps — theme, app shell, TanStack Charts, toolchain presets
|
|
3
3
|
#
|
|
4
4
|
# Entry points: use the exact import specifier below; do not guess.
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
# A subpath's `Install:` line is its required peers; `OptionalPeers:` are import()-only, install on use.
|
|
14
14
|
|
|
15
15
|
Package: basalt-ui
|
|
16
|
-
Version: 2.
|
|
16
|
+
Version: 2.15.0
|
|
17
17
|
|
|
18
18
|
## basalt-ui
|
|
19
19
|
Import: import { ... } from 'basalt-ui'
|
package/package.json
CHANGED
package/src/charts/legend.tsx
CHANGED
|
@@ -109,10 +109,10 @@ const swatchFill = (s: SwatchStyle): string =>
|
|
|
109
109
|
s.colorNegative ? `linear-gradient(90deg, ${s.color} 50%, ${s.colorNegative} 50%)` : s.color
|
|
110
110
|
|
|
111
111
|
/**
|
|
112
|
-
* A line series' key: a stroke with its dash, compact below 480px
|
|
113
|
-
*
|
|
114
|
-
* dashed swatch has BUTT caps: a round cap grows each
|
|
115
|
-
* would close the gap.
|
|
112
|
+
* A line series' key: a stroke with its dash, compact below 480px of CHART width (a container
|
|
113
|
+
* query, not the viewport) and wide from 480px. Both are at least 14px with two or more clear
|
|
114
|
+
* dashes: a shorter key reads as two dots. A dashed swatch has BUTT caps: a round cap grows each
|
|
115
|
+
* dash by half the stroke width per end and would close the gap.
|
|
116
116
|
*/
|
|
117
117
|
export const LINE_SWATCH = {
|
|
118
118
|
compact: { width: 14, dash: '4 3' },
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
// Doctor's design-loop section: the stale-board notice and the optional-Playwright probe. A leaf:
|
|
2
|
+
// imports nothing from `./index`. Stat-walk only — never reads a file body, never throws.
|
|
3
|
+
import { readFileSync, readdirSync, statSync } from 'node:fs'
|
|
4
|
+
import type { Dirent } from 'node:fs'
|
|
5
|
+
import { createRequire } from 'node:module'
|
|
6
|
+
import { join, resolve } from 'node:path'
|
|
7
|
+
|
|
8
|
+
const LAST_SHOT = join('.basalt', 'shots', 'last.json')
|
|
9
|
+
const SKIPPED_DIRS = new Set(['node_modules', 'dist', '.git', '.basalt'])
|
|
10
|
+
const UI_FILE = /\.(tsx|css)$/
|
|
11
|
+
/** Directories plus UI files visited before the walk gives up; other files are free, so a big non-UI tree cannot pin the notice on. */
|
|
12
|
+
const WALK_CAP = 5000
|
|
13
|
+
|
|
14
|
+
export const BOARD_NOTICE =
|
|
15
|
+
'UI changed since the last board — run basalt-ui shot <routes> and the basalt-design-reviewer (/basalt-design)'
|
|
16
|
+
export const PLAYWRIGHT_INSTALL = 'bun add -d playwright && bunx playwright install chromium'
|
|
17
|
+
|
|
18
|
+
/** `newest`: latest UI mtime in ms, null when none. `truncated`: the cap hit, so `newest` may be stale. */
|
|
19
|
+
type Walk = { newest: number | null; truncated: boolean }
|
|
20
|
+
|
|
21
|
+
function mtimeOf(path: string): number | null {
|
|
22
|
+
try {
|
|
23
|
+
return statSync(path, { throwIfNoEntry: false })?.mtimeMs ?? null
|
|
24
|
+
} catch {
|
|
25
|
+
return null
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function walkUi(cwd: string, roots: string[], cap: number): Walk {
|
|
30
|
+
const walk: Walk = { newest: null, truncated: false }
|
|
31
|
+
const stack = roots.map((root) => resolve(cwd, root))
|
|
32
|
+
let visited = 0
|
|
33
|
+
for (let dir = stack.pop(); dir !== undefined; dir = stack.pop()) {
|
|
34
|
+
if (++visited > cap) return { ...walk, truncated: true }
|
|
35
|
+
let entries: Dirent[]
|
|
36
|
+
try {
|
|
37
|
+
entries = readdirSync(dir, { withFileTypes: true })
|
|
38
|
+
} catch (error) {
|
|
39
|
+
// Only a missing dir means "no UI here"; anything else leaves the scan unknown.
|
|
40
|
+
if ((error as NodeJS.ErrnoException).code !== 'ENOENT') walk.truncated = true
|
|
41
|
+
continue
|
|
42
|
+
}
|
|
43
|
+
for (const entry of entries) {
|
|
44
|
+
const path = join(dir, entry.name)
|
|
45
|
+
if (entry.isDirectory()) {
|
|
46
|
+
if (!SKIPPED_DIRS.has(entry.name)) stack.push(path)
|
|
47
|
+
continue
|
|
48
|
+
}
|
|
49
|
+
if (!UI_FILE.test(entry.name)) continue
|
|
50
|
+
if (++visited > cap) return { ...walk, truncated: true }
|
|
51
|
+
const mtime = mtimeOf(path)
|
|
52
|
+
if (mtime !== null && (walk.newest === null || mtime > walk.newest)) walk.newest = mtime
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return walk
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** The last board's time (ms), or null when `last.json` is absent, corrupt or has no parseable `at`. */
|
|
59
|
+
function lastBoardAt(cwd: string): number | null {
|
|
60
|
+
try {
|
|
61
|
+
const last: unknown = JSON.parse(readFileSync(resolve(cwd, LAST_SHOT), 'utf8'))
|
|
62
|
+
if (typeof last !== 'object' || last === null) return null
|
|
63
|
+
const at = (last as { at?: unknown }).at
|
|
64
|
+
if (typeof at !== 'string') return null
|
|
65
|
+
const ms = Date.parse(at)
|
|
66
|
+
return Number.isNaN(ms) ? null : ms
|
|
67
|
+
} catch {
|
|
68
|
+
return null
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* The notice line when a UI file is newer than the last board, no valid board exists, or the walk
|
|
74
|
+
* hit its cap (unknown is reported, never "fresh"); else null. The signal is mtime-based, so a
|
|
75
|
+
* checkout or rebase can fire it on unchanged UI — a documented trade-off for a stat-only check.
|
|
76
|
+
*/
|
|
77
|
+
export function staleBoardNotice(
|
|
78
|
+
cwd: string,
|
|
79
|
+
roots: string[],
|
|
80
|
+
walkCap: number = WALK_CAP,
|
|
81
|
+
): string | null {
|
|
82
|
+
const { newest, truncated } = walkUi(cwd, roots, walkCap)
|
|
83
|
+
if (truncated) return BOARD_NOTICE
|
|
84
|
+
if (newest === null) return null
|
|
85
|
+
const at = lastBoardAt(cwd)
|
|
86
|
+
return at === null || newest > at ? BOARD_NOTICE : null
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** Loads `<id>/package.json` from the consumer; throws when unresolvable. Injectable for tests. */
|
|
90
|
+
export type PackageLoader = (id: string) => { version?: string }
|
|
91
|
+
|
|
92
|
+
/** The consumer's Playwright version (`playwright`, then `playwright-core`), or null when absent. */
|
|
93
|
+
export function playwrightVersion(
|
|
94
|
+
cwd: string,
|
|
95
|
+
load: PackageLoader = createRequire(resolve(cwd, 'package.json')),
|
|
96
|
+
): string | null {
|
|
97
|
+
for (const name of ['playwright', 'playwright-core']) {
|
|
98
|
+
try {
|
|
99
|
+
return load(`${name}/package.json`).version ?? 'unknown'
|
|
100
|
+
} catch {
|
|
101
|
+
// try the next candidate
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return null
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** Test seams for {@link designLoopLines}. */
|
|
108
|
+
export type DesignLoopProbes = {
|
|
109
|
+
notice?: (cwd: string, roots: string[]) => string | null
|
|
110
|
+
playwright?: (cwd: string) => string | null
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Doctor's design-loop section: advisory info lines only. They never count as a warning, so they
|
|
115
|
+
* cannot change doctor's verdict or its "All checks passed" line.
|
|
116
|
+
*/
|
|
117
|
+
export function designLoopLines(
|
|
118
|
+
cwd: string,
|
|
119
|
+
roots: string[],
|
|
120
|
+
probes: DesignLoopProbes = {},
|
|
121
|
+
): string[] {
|
|
122
|
+
const lines: string[] = []
|
|
123
|
+
const notice = (probes.notice ?? staleBoardNotice)(cwd, roots)
|
|
124
|
+
if (notice !== null) lines.push(` → ${notice}`)
|
|
125
|
+
const playwright = (probes.playwright ?? playwrightVersion)(cwd)
|
|
126
|
+
lines.push(
|
|
127
|
+
playwright === null
|
|
128
|
+
? ` → playwright is not installed (optional, needed by basalt-ui shot): ${PLAYWRIGHT_INSTALL}`
|
|
129
|
+
: ` ✓ playwright resolves (${playwright === 'unknown' ? 'version unknown' : playwright}; optional: basalt-ui shot)`,
|
|
130
|
+
)
|
|
131
|
+
return lines
|
|
132
|
+
}
|
package/src/cli/doctor.ts
CHANGED
|
@@ -33,6 +33,8 @@ import {
|
|
|
33
33
|
scannableFiles,
|
|
34
34
|
shippedAssetPath,
|
|
35
35
|
} from './index'
|
|
36
|
+
import { designLoopLines } from './board-freshness'
|
|
37
|
+
import type { DesignLoopProbes } from './board-freshness'
|
|
36
38
|
import { parseJsonc } from './source-text'
|
|
37
39
|
import { resolveRoots } from './config'
|
|
38
40
|
import {
|
|
@@ -121,7 +123,11 @@ function aiMajorsAt(dir: string): Partial<Record<AiMajorField, number>> {
|
|
|
121
123
|
*
|
|
122
124
|
* Returns the exit code: 0 = all good, 1 = one or more hard failures or skipped checks.
|
|
123
125
|
*/
|
|
124
|
-
export function doctor(
|
|
126
|
+
export function doctor(
|
|
127
|
+
invocationCwd: string = process.cwd(),
|
|
128
|
+
flags: string[] = [],
|
|
129
|
+
designLoop: DesignLoopProbes = {},
|
|
130
|
+
): number {
|
|
125
131
|
if (conflictingProfileFlags('doctor', flags)) return 1
|
|
126
132
|
const project = resolveProjectDir(invocationCwd)
|
|
127
133
|
// Inside the app package of a monorepo the manifest is above: read the install root instead.
|
|
@@ -420,6 +426,9 @@ export function doctor(invocationCwd: string = process.cwd(), flags: string[] =
|
|
|
420
426
|
for (const line of shell.warnings) warn(line)
|
|
421
427
|
}
|
|
422
428
|
|
|
429
|
+
// ── Design loop: advisory info lines (no warning count — they never change the verdict) ─────
|
|
430
|
+
if (profile !== 'tokens-only') lines.push(...designLoopLines(cwd, resolveRoots(cfg), designLoop))
|
|
431
|
+
|
|
423
432
|
// ── Report ──────────────────────────────────────────────────────────────────
|
|
424
433
|
lines.push('')
|
|
425
434
|
if (result.hardFailures === 0 && result.warnings === 0 && result.skipped === 0) {
|
package/src/cli/help.ts
CHANGED
|
@@ -43,6 +43,12 @@ export const COMMAND_OPTIONS: Record<string, Record<string, { type: 'string' | '
|
|
|
43
43
|
only: { type: 'string' },
|
|
44
44
|
},
|
|
45
45
|
'fonts:css': { out: { type: 'string' }, check: { type: 'boolean' } },
|
|
46
|
+
shot: {
|
|
47
|
+
base: { type: 'string' },
|
|
48
|
+
dist: { type: 'string' },
|
|
49
|
+
out: { type: 'string' },
|
|
50
|
+
states: { type: 'string' },
|
|
51
|
+
},
|
|
46
52
|
}
|
|
47
53
|
|
|
48
54
|
/** The first flag `cmd` does not accept, or null. Unknown commands return null — the dispatcher's
|
|
@@ -51,7 +57,7 @@ export function unknownFlag(cmd: string, flags: readonly string[]): string | nul
|
|
|
51
57
|
const options = COMMAND_OPTIONS[cmd]
|
|
52
58
|
if (options === undefined) return null
|
|
53
59
|
try {
|
|
54
|
-
parseArgs({ args: [...flags], options, strict: true, allowPositionals:
|
|
60
|
+
parseArgs({ args: [...flags], options, strict: true, allowPositionals: cmd === 'shot' })
|
|
55
61
|
return null
|
|
56
62
|
} catch (err) {
|
|
57
63
|
const message = err instanceof Error ? err.message : String(err)
|
|
@@ -65,7 +71,8 @@ export const USAGE =
|
|
|
65
71
|
'Usage: basalt-ui <--version | init [--no-merge-lint] |\n' +
|
|
66
72
|
' sync [--force] [--check] [--verbose] [--tokens-only|--framework] |\n' +
|
|
67
73
|
' check-theme [--audit-allows] |\n' +
|
|
68
|
-
' doctor [--tokens-only|--framework] | guard-hook | tokens:css | fonts:css
|
|
74
|
+
' doctor [--tokens-only|--framework] | guard-hook | tokens:css | fonts:css |\n' +
|
|
75
|
+
' shot <route…> | help>\n\n' +
|
|
69
76
|
'check-theme [--tokens-only|--framework] [--audit-allows]\n' +
|
|
70
77
|
' --audit-allows reports instead of scanning: every `theme-allow` annotation and every\n' +
|
|
71
78
|
' `basalt.exemptRules` entry, with what each one still suppresses — proved by re-running the\n' +
|
|
@@ -81,6 +88,11 @@ export const USAGE =
|
|
|
81
88
|
'fonts:css [--out <path>] [--check]\n' +
|
|
82
89
|
' Emit the shipped --basalt-font-* stacks as plain CSS — the typeface half of the token layer,\n' +
|
|
83
90
|
' otherwise reachable only by importing styles.css.\n\n' +
|
|
91
|
+
'shot <route…> (--base <url> | --dist <dir>) [--out <dir>] [--states <list>]\n' +
|
|
92
|
+
' Render routes in Chromium (Playwright from YOUR project: bun add -d playwright) and write\n' +
|
|
93
|
+
' board.html, metrics.json and png/* — every data-shot anchor × light/dark × desktop/mobile ×\n' +
|
|
94
|
+
' rest, hover, focus, tooltip, empty, loading, error. --dist serves a built SPA dir itself.\n' +
|
|
95
|
+
' Default --out .basalt/shots (emptied each run); .basalt/shots/last.json names the last out dir.\n\n' +
|
|
84
96
|
'doctor [--tokens-only|--framework]\n' +
|
|
85
97
|
' Checks THIS project only: the manifest exists, the oxlint preset is wired, the pre-commit\n' +
|
|
86
98
|
' hook runs check-theme (via `lefthook dump`), and the ai package major is consistent within\n' +
|
package/src/cli/index.ts
CHANGED
|
@@ -22,12 +22,13 @@ import { fileURLToPath } from 'node:url'
|
|
|
22
22
|
|
|
23
23
|
import { DEFAULT_GUARD_CONFIG, guardWaiverHint } from '../guard'
|
|
24
24
|
import type { GuardConfig, GuardKind, GuardSeverity } from '../guard'
|
|
25
|
-
import { RULE_NAMES, SKILL_NAMES } from '../surfaces'
|
|
25
|
+
import { AGENT_NAMES, RULE_NAMES, SKILL_NAMES } from '../surfaces'
|
|
26
26
|
import { checkTheme } from './check-theme'
|
|
27
27
|
import { doctor } from './doctor'
|
|
28
28
|
import { guardHook } from './guard-hook'
|
|
29
29
|
import { COMMAND_OPTIONS, USAGE, unknownFlag } from './help'
|
|
30
30
|
import { init } from './init'
|
|
31
|
+
import { shot } from './shot'
|
|
31
32
|
import { sync } from './sync'
|
|
32
33
|
import type { BasaltInstall } from './basalt-install'
|
|
33
34
|
import {
|
|
@@ -454,6 +455,8 @@ type TemplateVars = {
|
|
|
454
455
|
SERIES_MODULE_PATH: string
|
|
455
456
|
/** The consumer's configured roots as space-separated quoted oxfmt globs, e.g. `'apps/web/src/**'`. */
|
|
456
457
|
ROOTS_GLOBS: string
|
|
458
|
+
/** The roots a rule's `paths:` renders from: `basalt.roots` (init/sync write the inferred ones first), else {@link LEGACY_RULE_ROOTS}. */
|
|
459
|
+
RULE_ROOTS: string[]
|
|
457
460
|
/** Path to the shipped oxlint preset from the consumer dir — RESOLVED, never assumed at the root. */
|
|
458
461
|
OXLINT_PRESET_PATH: string
|
|
459
462
|
/** Path to the shipped lefthook preset from the consumer dir — same resolution. */
|
|
@@ -538,6 +541,7 @@ function buildTemplateVars(pkgRoot: string, cwd: string, cfg: BasaltConfig): Tem
|
|
|
538
541
|
ACCENT_HUE: cfg.accentHue ?? 'blue',
|
|
539
542
|
SERIES_MODULE_PATH: resolveSeriesModulePath(cfg),
|
|
540
543
|
ROOTS_GLOBS: resolveRoots(cfg).map(toRootGlob).join(' '),
|
|
544
|
+
RULE_ROOTS: cfg.roots ?? [],
|
|
541
545
|
OXLINT_PRESET_PATH: shippedAssetPath(install, cwd, OXLINT_FILES.preset),
|
|
542
546
|
LEFTHOOK_PRESET_PATH: shippedAssetPath(install, cwd, 'configs/lefthook.yml'),
|
|
543
547
|
BASALT_BIN: basaltBinCommand(install, cwd),
|
|
@@ -545,12 +549,42 @@ function buildTemplateVars(pkgRoot: string, cwd: string, cfg: BasaltConfig): Tem
|
|
|
545
549
|
}
|
|
546
550
|
}
|
|
547
551
|
|
|
552
|
+
/** Rule roots when nothing is declared or inferable — what the shipped rules matched before roots. */
|
|
553
|
+
const LEGACY_RULE_ROOTS = ['src', 'apps/**/src', 'packages/**/src']
|
|
554
|
+
|
|
555
|
+
const FRONT_MATTER = /^---\n[\s\S]*?\n---\n/
|
|
556
|
+
const RULE_PATHS_BLOCK = /^paths:\n(?: {2}- .*\n)+/m
|
|
557
|
+
|
|
558
|
+
/**
|
|
559
|
+
* A rule's front-matter `paths:` block rendered from `roots`: one `'<root>/**'` item per root,
|
|
560
|
+
* normalised (no `./`, no trailing slash) and single-quoted for YAML. Only the leading `---…---`
|
|
561
|
+
* block is touched. Front matter without `paths:` is returned unchanged; a `paths:` that is not the
|
|
562
|
+
* expected list shape, or a root that would match everywhere (`''`, `/`, absolute), throws.
|
|
563
|
+
*/
|
|
564
|
+
export function renderRulePaths(text: string, roots: readonly string[]): string {
|
|
565
|
+
const front = FRONT_MATTER.exec(text)?.[0]
|
|
566
|
+
if (front === undefined || !/^paths:/m.test(front)) return text
|
|
567
|
+
if (!RULE_PATHS_BLOCK.test(front)) throw new Error('rule `paths:` is not a list of ` - …` items')
|
|
568
|
+
const items = (roots.length > 0 ? roots : LEGACY_RULE_ROOTS).map((raw) => {
|
|
569
|
+
const root = raw.replace(/^(?:\.\/)+/, '').replace(/\/+$/, '')
|
|
570
|
+
if (/[\n\r]/.test(root)) throw new Error(`basalt.roots entry has a line break: ${raw}`)
|
|
571
|
+
if (raw.startsWith('/') || root === '') {
|
|
572
|
+
throw new Error(`basalt.roots entry must be a relative directory, got ${JSON.stringify(raw)}`)
|
|
573
|
+
}
|
|
574
|
+
return ` - '${(root === '.' ? '**' : `${root}/**`).replace(/'/g, "''")}'`
|
|
575
|
+
})
|
|
576
|
+
return (
|
|
577
|
+
front.replace(RULE_PATHS_BLOCK, () => `paths:\n${items.join('\n')}\n`) +
|
|
578
|
+
text.slice(front.length)
|
|
579
|
+
)
|
|
580
|
+
}
|
|
581
|
+
|
|
548
582
|
/** Substitute every `{{KEY}}` placeholder from the variable map; unknown keys are left verbatim. */
|
|
549
583
|
function fillTemplate(tpl: string, vars: TemplateVars): string {
|
|
550
584
|
const fill = (text: string): string =>
|
|
551
585
|
text.replace(/\{\{(\w+)\}\}/g, (m, key: string) => {
|
|
552
|
-
const v = (vars as Record<string,
|
|
553
|
-
return v
|
|
586
|
+
const v = (vars as Record<string, unknown>)[key]
|
|
587
|
+
return typeof v === 'string' ? v : m
|
|
554
588
|
})
|
|
555
589
|
// The marker is a YAML comment so the template stays valid YAML; GATE_STEPS itself carries
|
|
556
590
|
// placeholders, so it expands before the generic pass.
|
|
@@ -792,7 +826,10 @@ export function managedFiles(placement: PlacementFlags = ROOT_PLACEMENT): Manage
|
|
|
792
826
|
dest: `.claude/rules/basalt-${name}.md`,
|
|
793
827
|
mode: 'managed' as const,
|
|
794
828
|
source: `agent/rules/basalt-${name}.md`,
|
|
795
|
-
render: (ctx: RenderContext) =>
|
|
829
|
+
render: (ctx: RenderContext) => {
|
|
830
|
+
const text = readSource(ctx.pkgRoot, `agent/rules/basalt-${name}.md`)
|
|
831
|
+
return text === null ? null : renderRulePaths(text, ctx.vars.RULE_ROOTS)
|
|
832
|
+
},
|
|
796
833
|
}))
|
|
797
834
|
|
|
798
835
|
// Skills take the same managed path the rules do — Claude Code cannot load skills from
|
|
@@ -805,6 +842,14 @@ export function managedFiles(placement: PlacementFlags = ROOT_PLACEMENT): Manage
|
|
|
805
842
|
render: (ctx: RenderContext) => readSource(ctx.pkgRoot, `agent/skills/${name}/SKILL.md`),
|
|
806
843
|
}))
|
|
807
844
|
|
|
845
|
+
// Subagents load only walking UP from the session cwd, so the consumer root is the right home.
|
|
846
|
+
const agents: ManagedFile[] = AGENT_NAMES.map((name) => ({
|
|
847
|
+
dest: `.claude/agents/${name}.md`,
|
|
848
|
+
mode: 'managed' as const,
|
|
849
|
+
source: `agent/agents/${name}.md`,
|
|
850
|
+
render: (ctx: RenderContext) => readSource(ctx.pkgRoot, `agent/agents/${name}.md`),
|
|
851
|
+
}))
|
|
852
|
+
|
|
808
853
|
// AGENTS.md, not CLAUDE.md: Claude Code loads a repo-root AGENTS.md directly, but ANY CLAUDE.md
|
|
809
854
|
// in or above the cwd suppresses it — so the block must not be the reason a CLAUDE.md exists.
|
|
810
855
|
const agentsBlock: ManagedFile = {
|
|
@@ -940,7 +985,17 @@ export function managedFiles(placement: PlacementFlags = ROOT_PLACEMENT): Manage
|
|
|
940
985
|
// lefthook/CI config, and writing over or beside it is worse than not writing at all.
|
|
941
986
|
const rootTooling: ManagedFile[] = placement.isPackageRepoRoot ? [lefthook, ci] : []
|
|
942
987
|
|
|
943
|
-
return [
|
|
988
|
+
return [
|
|
989
|
+
...rules,
|
|
990
|
+
...skills,
|
|
991
|
+
...agents,
|
|
992
|
+
agentsBlock,
|
|
993
|
+
design,
|
|
994
|
+
oxfmt,
|
|
995
|
+
...rootTooling,
|
|
996
|
+
oxlintrc,
|
|
997
|
+
...scaffolds,
|
|
998
|
+
]
|
|
944
999
|
}
|
|
945
1000
|
|
|
946
1001
|
/**
|
|
@@ -1016,11 +1071,11 @@ export function readManifest(cwd: string): Manifest {
|
|
|
1016
1071
|
}
|
|
1017
1072
|
|
|
1018
1073
|
/**
|
|
1019
|
-
* The
|
|
1020
|
-
* decide which files `managedFiles()` places under them, so a rule or
|
|
1074
|
+
* The managed NAMESPACES whose membership is derived, not fixed: `RULE_NAMES`, `SKILL_NAMES` and
|
|
1075
|
+
* `AGENT_NAMES` decide which files `managedFiles()` places under them, so a rule, skill or agent that is RETIRED
|
|
1021
1076
|
* upstream leaves a file behind in every consumer that ever synced it — and Claude keeps loading it.
|
|
1022
1077
|
*
|
|
1023
|
-
* Scoped to these
|
|
1078
|
+
* Scoped to these patterns on purpose, and never applied to the manifest wholesale: several
|
|
1024
1079
|
* managed/seed entries are legitimately absent from `managedFiles()` for a run (`lefthook.yml` and
|
|
1025
1080
|
* `check.yml` when the package is not the repo root). Deleting a dest just because this run did not place it would
|
|
1026
1081
|
* remove a consumer's CI workflow on a monorepo.
|
|
@@ -1028,6 +1083,7 @@ export function readManifest(cwd: string): Manifest {
|
|
|
1028
1083
|
const RETIREABLE_DEST_PATTERNS: readonly RegExp[] = [
|
|
1029
1084
|
/^\.claude\/rules\/basalt-[a-z0-9-]+\.md$/,
|
|
1030
1085
|
/^\.claude\/skills\/basalt-[a-z0-9-]+\/SKILL\.md$/,
|
|
1086
|
+
/^\.claude\/agents\/basalt-[a-z0-9-]+\.md$/,
|
|
1031
1087
|
]
|
|
1032
1088
|
|
|
1033
1089
|
/** A tracked dest inside a derived namespace that this basalt version no longer ships. */
|
|
@@ -1222,9 +1278,21 @@ export function diffSummary(file: ManagedFile, state: UnitState): string {
|
|
|
1222
1278
|
}
|
|
1223
1279
|
|
|
1224
1280
|
/** Build the render context for a run from the package root + consumer cwd/config. */
|
|
1225
|
-
export function renderContext(cwd: string): RenderContext {
|
|
1281
|
+
export function renderContext(cwd: string, ruleRoots?: readonly string[]): RenderContext {
|
|
1226
1282
|
const pkgRoot = packageRoot()
|
|
1227
|
-
|
|
1283
|
+
const vars = buildTemplateVars(pkgRoot, cwd, readBasaltConfig(cwd))
|
|
1284
|
+
return { pkgRoot, vars: ruleRoots === undefined ? vars : { ...vars, RULE_ROOTS: [...ruleRoots] } }
|
|
1285
|
+
}
|
|
1286
|
+
|
|
1287
|
+
/**
|
|
1288
|
+
* The rule roots a run renders with: what `reconcileRoots` wrote, or — on `--check`, which writes
|
|
1289
|
+
* nothing — what a real sync would have written, so check and write never disagree.
|
|
1290
|
+
*/
|
|
1291
|
+
export function ruleRootsFor(state: RootsState): readonly string[] | undefined {
|
|
1292
|
+
if (state.kind === 'wrote') return state.roots
|
|
1293
|
+
return state.kind === 'declared' && state.declared.length === 0 && state.unscanned.length > 0
|
|
1294
|
+
? state.unscanned
|
|
1295
|
+
: undefined
|
|
1228
1296
|
}
|
|
1229
1297
|
|
|
1230
1298
|
// ──────────────────────────────────────────────────────────────────────────────
|
|
@@ -1700,6 +1768,8 @@ export function run(argv: string[], cwd: string = process.cwd()): number | Promi
|
|
|
1700
1768
|
return tokensCss(flags, cwd)
|
|
1701
1769
|
case 'fonts:css':
|
|
1702
1770
|
return fontsCss(flags, cwd)
|
|
1771
|
+
case 'shot':
|
|
1772
|
+
return shot(flags, cwd)
|
|
1703
1773
|
default:
|
|
1704
1774
|
// Named, not just implied by a usage dump: a full-screen help block with no error line reads
|
|
1705
1775
|
// like the command ran and chose to print help. Reported by a consumer who passed
|