basalt-ui 3.0.0 → 3.1.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/AGENTS.md +1 -0
- package/CHANGELOG.md +72 -39
- package/MIGRATING.md +44 -2
- package/README.md +39 -12
- package/agent/rules/basalt-tokens.md +1 -1
- package/agent/rules/basalt-ui.md +3 -3
- package/agent/skills/basalt-app/references/live.md +4 -4
- package/agent/skills/basalt-app/references/migrate.md +2 -2
- package/agent/skills/basalt-app/references/setup.md +17 -8
- package/agent/skills/basalt-app/references/testing.md +8 -6
- package/agent/skills/basalt-design/SKILL.md +2 -1
- package/agent/skills/basalt-design/references/controls.md +1 -0
- package/agent/skills/basalt-design/references/parts.md +5 -1
- package/agent/templates/AGENTS-block.md.tpl +6 -23
- package/agent/templates/AGENTS-block.site.md.tpl +5 -18
- package/agent/templates/AGENTS-block.tokens.md.tpl +3 -7
- package/agent/templates/DESIGN.md.tpl +1 -1
- package/agent/templates/_app-error.i18n.tpl +8 -32
- package/agent/templates/_app-error.tpl +8 -32
- package/agent/templates/_app-pending.i18n.tpl +5 -3
- package/agent/templates/_app-pending.tpl +5 -4
- package/agent/templates/main.i18n.tpl +8 -3
- package/agent/templates/main.tpl +8 -3
- package/agent/templates/router.start.tpl +8 -3
- package/agent/templates/seed-messages.json +0 -30
- package/configs/oxlint-app.json +9 -1
- package/configs/oxlint-bridge.json +3 -1
- package/configs/oxlint-parts.json +9 -1
- package/configs/oxlint-site.json +3 -1
- package/dist/astro/shiki.d.ts +3 -2
- package/dist/astro/shiki.d.ts.map +1 -1
- package/dist/cards/bar-list.d.ts.map +1 -1
- package/dist/cards/bar-list.js +2 -1
- package/dist/cards/chain-view.d.ts +37 -8
- package/dist/cards/chain-view.d.ts.map +1 -1
- package/dist/cards/chain-view.js +105 -38
- package/dist/cards/contract.d.ts +8 -1
- package/dist/cards/contract.d.ts.map +1 -1
- package/dist/cards/data-panel.d.ts.map +1 -1
- package/dist/cards/data-panel.js +1 -0
- package/dist/cards/event-list.d.ts.map +1 -1
- package/dist/cards/event-list.js +3 -2
- package/dist/cards/index.d.ts +1 -1
- package/dist/cards/index.d.ts.map +1 -1
- package/dist/cards/row-list.d.ts.map +1 -1
- package/dist/cards/row-list.js +2 -1
- package/dist/cards/stat-card-parts.d.ts +3 -3
- package/dist/cards/stat-card-parts.d.ts.map +1 -1
- package/dist/cards/stat-card-parts.js +8 -2
- package/dist/cards/stat-card.d.ts.map +1 -1
- package/dist/cards/stat-card.js +34 -9
- package/dist/charts/core/compile.d.ts +2 -0
- package/dist/charts/core/compile.d.ts.map +1 -1
- package/dist/charts/core/compile.js +16 -8
- package/dist/charts/core/cursor.d.ts +2 -1
- package/dist/charts/core/cursor.d.ts.map +1 -1
- package/dist/charts/core/cursor.js +8 -1
- package/dist/charts/core/tooltip-said.d.ts +16 -0
- package/dist/charts/core/tooltip-said.d.ts.map +1 -0
- package/dist/charts/core/tooltip-said.js +39 -0
- package/dist/charts/focus.d.ts.map +1 -1
- package/dist/charts/focus.js +1 -1
- package/dist/charts/parts/chart-card.d.ts.map +1 -1
- package/dist/charts/parts/chart-card.js +1 -0
- package/dist/cli/agent-note.d.ts +3 -3
- package/dist/cli/agent-note.d.ts.map +1 -1
- package/dist/cli/agent-note.js +5 -5
- package/dist/cli/budget/index.d.ts +7 -0
- package/dist/cli/budget/index.d.ts.map +1 -1
- package/dist/cli/budget/index.js +11 -5
- package/dist/cli/config.d.ts +1 -1
- package/dist/cli/doctor/app.d.ts.map +1 -1
- package/dist/cli/doctor/app.js +53 -24
- package/dist/cli/doctor/eject.d.ts.map +1 -1
- package/dist/cli/doctor/eject.js +16 -9
- package/dist/cli/doctor/guards.d.ts.map +1 -1
- package/dist/cli/doctor/guards.js +11 -8
- package/dist/cli/doctor/hook.js +1 -1
- package/dist/cli/doctor/install.d.ts.map +1 -1
- package/dist/cli/doctor/install.js +46 -22
- package/dist/cli/doctor/translations.d.ts.map +1 -1
- package/dist/cli/doctor/translations.js +11 -4
- package/dist/cli/doctor/types.d.ts +2 -2
- package/dist/cli/doctor/types.d.ts.map +1 -1
- package/dist/cli/doctor/types.js +1 -1
- package/dist/cli/doctor/wiring.d.ts.map +1 -1
- package/dist/cli/doctor/wiring.js +26 -15
- package/dist/cli/eject/dropped-slots.d.ts +6 -0
- package/dist/cli/eject/dropped-slots.d.ts.map +1 -0
- package/dist/cli/eject/dropped-slots.js +9 -0
- package/dist/cli/eject/index.d.ts.map +1 -1
- package/dist/cli/eject/index.js +9 -8
- package/dist/cli/help.d.ts.map +1 -1
- package/dist/cli/help.js +7 -2
- package/dist/cli/index.d.ts +6 -5
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +38 -7
- package/dist/cli/init/index.d.ts +10 -0
- package/dist/cli/init/index.d.ts.map +1 -1
- package/dist/cli/init/index.js +61 -10
- package/dist/cli/init/locales.d.ts +7 -0
- package/dist/cli/init/locales.d.ts.map +1 -1
- package/dist/cli/init/locales.js +21 -6
- package/dist/cli/init/router-seeds.d.ts.map +1 -1
- package/dist/cli/init/router-seeds.js +16 -3
- package/dist/cli/init/steps.d.ts +36 -3
- package/dist/cli/init/steps.d.ts.map +1 -1
- package/dist/cli/init/steps.js +201 -34
- package/dist/cli/lint/baseline.d.ts +27 -0
- package/dist/cli/lint/baseline.d.ts.map +1 -0
- package/dist/cli/lint/baseline.js +96 -0
- package/dist/cli/lint/engine.d.ts +2 -0
- package/dist/cli/lint/engine.d.ts.map +1 -1
- package/dist/cli/lint/engine.js +18 -8
- package/dist/cli/lint/hook.d.ts.map +1 -1
- package/dist/cli/lint/hook.js +8 -3
- package/dist/cli/lint/index.d.ts +3 -0
- package/dist/cli/lint/index.d.ts.map +1 -1
- package/dist/cli/lint/index.js +67 -8
- package/dist/cli/manifest.d.ts +46 -3
- package/dist/cli/manifest.d.ts.map +1 -1
- package/dist/cli/manifest.js +71 -1
- package/dist/cli/migrate/census.d.ts +6 -0
- package/dist/cli/migrate/census.d.ts.map +1 -1
- package/dist/cli/migrate/census.js +22 -1
- package/dist/cli/migrate/index.d.ts +5 -0
- package/dist/cli/migrate/index.d.ts.map +1 -1
- package/dist/cli/migrate/index.js +36 -3
- package/dist/cli/migrate/lost-classes.d.ts +20 -0
- package/dist/cli/migrate/lost-classes.d.ts.map +1 -0
- package/dist/cli/migrate/lost-classes.js +145 -0
- package/dist/cli/migrate/rows.d.ts +10 -0
- package/dist/cli/migrate/rows.d.ts.map +1 -1
- package/dist/cli/migrate/rows.js +15 -0
- package/dist/cli/package-manager.d.ts.map +1 -1
- package/dist/cli/package-manager.js +2 -1
- package/dist/cli/peers.d.ts +2 -0
- package/dist/cli/peers.d.ts.map +1 -1
- package/dist/cli/peers.js +7 -0
- package/dist/cli/presets.d.ts.map +1 -1
- package/dist/cli/presets.js +27 -11
- package/dist/cli/resolver.d.ts +13 -4
- package/dist/cli/resolver.d.ts.map +1 -1
- package/dist/cli/resolver.js +39 -5
- package/dist/cli/router-wiring.d.ts +1 -0
- package/dist/cli/router-wiring.d.ts.map +1 -1
- package/dist/cli/router-wiring.js +1 -1
- package/dist/cli/sync/engine.d.ts +8 -1
- package/dist/cli/sync/engine.d.ts.map +1 -1
- package/dist/cli/sync/engine.js +25 -14
- package/dist/cli/sync/index.d.ts.map +1 -1
- package/dist/cli/sync/index.js +7 -4
- package/dist/cli/sync/render.d.ts.map +1 -1
- package/dist/cli/sync/render.js +21 -28
- package/dist/cli/tokens-css.d.ts +2 -0
- package/dist/cli/tokens-css.d.ts.map +1 -1
- package/dist/cli/tokens-css.js +28 -6
- package/dist/controls/contract.d.ts +2 -1
- package/dist/controls/contract.d.ts.map +1 -1
- package/dist/controls/control-home.d.ts +4 -1
- package/dist/controls/control-home.d.ts.map +1 -1
- package/dist/controls/control-home.js +5 -3
- package/dist/controls/local-control.d.ts +28 -1
- package/dist/controls/local-control.d.ts.map +1 -1
- package/dist/controls/local-control.js +14 -2
- package/dist/core/cn.d.ts.map +1 -1
- package/dist/core/cn.js +6 -5
- package/dist/core/frame-figure.d.ts +2 -0
- package/dist/core/frame-figure.d.ts.map +1 -1
- package/dist/core/frame-figure.js +5 -2
- package/dist/core/frame-head.d.ts +3 -1
- package/dist/core/frame-head.d.ts.map +1 -1
- package/dist/core/frame-head.js +28 -7
- package/dist/core/frame-regions.d.ts +1 -1
- package/dist/core/frame-regions.d.ts.map +1 -1
- package/dist/core/frame-regions.js +18 -8
- package/dist/core/info-hint.d.ts +5 -0
- package/dist/core/info-hint.d.ts.map +1 -1
- package/dist/core/info-hint.js +22 -1
- package/dist/core/mark-tone.d.ts +6 -2
- package/dist/core/mark-tone.d.ts.map +1 -1
- package/dist/core/mark-tone.js +1 -1
- package/dist/core/mark-types.d.ts +4 -2
- package/dist/core/mark-types.d.ts.map +1 -1
- package/dist/core/messages/chain.d.ts +2 -1
- package/dist/core/messages/chain.d.ts.map +1 -1
- package/dist/core/messages/chain.js +1 -0
- package/dist/core/messages/index.d.ts +2 -1
- package/dist/core/messages/index.d.ts.map +1 -1
- package/dist/core/messages/index.js +2 -0
- package/dist/core/messages/runs.d.ts +20 -0
- package/dist/core/messages/runs.d.ts.map +1 -0
- package/dist/core/messages/runs.js +18 -0
- package/dist/core/phase.d.ts +25 -2
- package/dist/core/phase.d.ts.map +1 -1
- package/dist/core/ports.d.ts +4 -1
- package/dist/core/ports.d.ts.map +1 -1
- package/dist/core/provider.d.ts +3 -1
- package/dist/core/provider.d.ts.map +1 -1
- package/dist/core/provider.js +5 -3
- package/dist/core/scheme.d.ts +2 -1
- package/dist/core/scheme.d.ts.map +1 -1
- package/dist/core/scheme.js +1 -0
- package/dist/core/spark/mini-bars.d.ts +6 -4
- package/dist/core/spark/mini-bars.d.ts.map +1 -1
- package/dist/core/spark/mini-bars.js +36 -11
- package/dist/core/spark/sparkline.d.ts +2 -2
- package/dist/core/spark/sparkline.d.ts.map +1 -1
- package/dist/core/spark/sparkline.js +21 -2
- package/dist/css/bridge.css +63 -0
- package/dist/css/generate.d.ts +2 -2
- package/dist/css/generate.d.ts.map +1 -1
- package/dist/css/generate.js +25 -0
- package/dist/data/live/live-query.d.ts +2 -2
- package/dist/data/live/live-query.d.ts.map +1 -1
- package/dist/data/live/live-query.js +2 -1
- package/dist/lint/preset.d.ts +12 -3
- package/dist/lint/preset.d.ts.map +1 -1
- package/dist/lint/preset.js +30 -10
- package/dist/lint/rules/class/table.d.ts.map +1 -1
- package/dist/lint/rules/class/table.js +3 -1
- package/dist/lint/rules/structure/control-home.js +1 -1
- package/dist/lint/rules/structure/import-boundary.d.ts.map +1 -1
- package/dist/lint/rules/structure/import-boundary.js +2 -0
- package/dist/lint/rules/structure/label-literal.d.ts.map +1 -1
- package/dist/lint/rules/structure/label-literal.js +1 -1
- package/dist/lint/shadcn.d.ts +562 -0
- package/dist/lint/shadcn.d.ts.map +1 -0
- package/dist/lint/shadcn.js +52 -0
- package/dist/lint/stylelint/render.d.ts +3 -1
- package/dist/lint/stylelint/render.d.ts.map +1 -1
- package/dist/lint/stylelint/render.js +23 -2
- package/dist/lint/stylelint/rules.d.ts +3 -2
- package/dist/lint/stylelint/rules.d.ts.map +1 -1
- package/dist/lint/stylelint/rules.js +11 -6
- package/dist/lint/weakened.d.ts +8 -0
- package/dist/lint/weakened.d.ts.map +1 -1
- package/dist/lint/weakened.js +44 -1
- package/dist/messages/de.d.ts.map +1 -1
- package/dist/messages/de.js +15 -0
- package/dist/messages/es.d.ts.map +1 -1
- package/dist/messages/es.js +15 -0
- package/dist/messages/fr.d.ts.map +1 -1
- package/dist/messages/fr.js +15 -0
- package/dist/messages/zh-hans.d.ts.map +1 -1
- package/dist/messages/zh-hans.js +15 -0
- package/dist/page/bar-title.d.ts +25 -0
- package/dist/page/bar-title.d.ts.map +1 -0
- package/dist/page/bar-title.js +10 -0
- package/dist/page/contract.d.ts +11 -1
- package/dist/page/contract.d.ts.map +1 -1
- package/dist/page/empty-state.d.ts +5 -2
- package/dist/page/empty-state.d.ts.map +1 -1
- package/dist/page/empty-state.js +14 -3
- package/dist/page/facts.d.ts +19 -2
- package/dist/page/facts.d.ts.map +1 -1
- package/dist/page/facts.js +26 -5
- package/dist/page/index.d.ts +8 -0
- package/dist/page/index.d.ts.map +1 -1
- package/dist/page/index.js +9 -0
- package/dist/page/page-bar.d.ts.map +1 -1
- package/dist/page/page-bar.js +2 -7
- package/dist/page/page-summary.d.ts +2 -1
- package/dist/page/page-summary.d.ts.map +1 -1
- package/dist/page/page-summary.js +1 -1
- package/dist/page/run-button.d.ts +26 -0
- package/dist/page/run-button.d.ts.map +1 -0
- package/dist/page/run-button.js +31 -0
- package/dist/page/run-list.d.ts +28 -0
- package/dist/page/run-list.d.ts.map +1 -0
- package/dist/page/run-list.js +88 -0
- package/dist/page/run-queue.d.ts +78 -0
- package/dist/page/run-queue.d.ts.map +1 -0
- package/dist/page/run-queue.js +93 -0
- package/dist/page/section.d.ts +6 -1
- package/dist/page/section.d.ts.map +1 -1
- package/dist/page/section.js +34 -16
- package/dist/shell/commands/command-palette.d.ts.map +1 -1
- package/dist/shell/commands/command-palette.js +5 -1
- package/dist/shell/parts/header.js +1 -1
- package/dist/surfaces.d.ts +15 -1
- package/dist/surfaces.d.ts.map +1 -1
- package/dist/surfaces.js +19 -2
- package/dist/testing/index.d.ts +1 -0
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +3 -0
- package/dist/testing/pseudo-locale.d.ts +41 -0
- package/dist/testing/pseudo-locale.d.ts.map +1 -0
- package/dist/testing/pseudo-locale.js +74 -0
- package/dist/testing/quality.d.ts +6 -0
- package/dist/testing/quality.d.ts.map +1 -1
- package/dist/testing/quality.js +139 -1
- package/dist/tokens/bridge-sheet.d.ts +21 -0
- package/dist/tokens/bridge-sheet.d.ts.map +1 -0
- package/dist/tokens/bridge-sheet.js +68 -0
- package/dist/tokens/emit.d.ts +6 -1
- package/dist/tokens/emit.d.ts.map +1 -1
- package/dist/tokens/emit.js +26 -1
- package/dist/ui/accordion.js +1 -1
- package/dist/ui/card.d.ts +32 -4
- package/dist/ui/card.d.ts.map +1 -1
- package/dist/ui/card.js +26 -3
- package/dist/ui/collapsible.d.ts +4 -2
- package/dist/ui/collapsible.d.ts.map +1 -1
- package/dist/ui/collapsible.js +1 -1
- package/dist/ui/combobox.js +1 -1
- package/dist/ui/meter.d.ts +34 -3
- package/dist/ui/meter.d.ts.map +1 -1
- package/dist/ui/meter.guard.d.ts +2 -0
- package/dist/ui/meter.guard.d.ts.map +1 -1
- package/dist/ui/meter.guard.js +20 -0
- package/dist/ui/meter.js +23 -7
- package/dist/ui/primitive.contract.d.ts.map +1 -1
- package/dist/ui/primitive.contract.js +7 -0
- package/dist/ui/remote-pad.d.ts +62 -0
- package/dist/ui/remote-pad.d.ts.map +1 -0
- package/dist/ui/remote-pad.guard.d.ts +21 -0
- package/dist/ui/remote-pad.guard.d.ts.map +1 -0
- package/dist/ui/remote-pad.guard.js +6 -0
- package/dist/ui/remote-pad.js +148 -0
- package/dist/ui/segmented.d.ts.map +1 -1
- package/dist/ui/segmented.js +4 -0
- package/dist/ui/skeleton.d.ts +9 -4
- package/dist/ui/skeleton.d.ts.map +1 -1
- package/dist/ui/skeleton.guard.d.ts +6 -2
- package/dist/ui/skeleton.guard.d.ts.map +1 -1
- package/dist/ui/skeleton.guard.js +4 -0
- package/dist/ui/skeleton.js +2 -1
- package/dist/ui/slots.d.ts +2 -1
- package/dist/ui/slots.d.ts.map +1 -1
- package/dist/ui/slots.js +2 -1
- package/dist/vite/allotment.d.ts +1 -1
- package/dist/vite/allotment.d.ts.map +1 -1
- package/dist/vite/allotment.js +15 -1
- package/dist/vite/doc.d.ts +1 -1
- package/dist/vite/doc.d.ts.map +1 -1
- package/dist/vite/doc.js +12 -2
- package/dist/vite/head.d.ts +4 -3
- package/dist/vite/head.d.ts.map +1 -1
- package/dist/vite/index.d.ts.map +1 -1
- package/dist/vite/index.js +4 -1
- package/dist/vite/shell-worker.d.ts +6 -0
- package/dist/vite/shell-worker.d.ts.map +1 -0
- package/dist/vite/shell-worker.js +92 -0
- package/docs/astro.md +19 -4
- package/docs/bar-list.md +3 -2
- package/docs/bar-title.md +33 -0
- package/docs/basalt-provider.md +2 -1
- package/docs/card.md +24 -4
- package/docs/chain-view.md +12 -7
- package/docs/chart-card.md +3 -2
- package/docs/collapsible.md +4 -2
- package/docs/control-home.md +4 -2
- package/docs/create-run-queue.md +40 -0
- package/docs/data-panel.md +3 -2
- package/docs/de.md +1 -1
- package/docs/empty-state.md +3 -1
- package/docs/es.md +1 -1
- package/docs/event-list.md +3 -2
- package/docs/fact.md +6 -1
- package/docs/facts.md +5 -1
- package/docs/fr.md +1 -1
- package/docs/live-query.md +1 -1
- package/docs/meter.md +17 -13
- package/docs/mini-bars.md +7 -5
- package/docs/pseudo-basalt-messages.md +30 -0
- package/docs/pseudo-messages.md +27 -0
- package/docs/quality.md +2 -1
- package/docs/recipes/localise-app.md +2 -2
- package/docs/remote-pad.md +40 -0
- package/docs/row-list.md +3 -2
- package/docs/run-button.md +45 -0
- package/docs/run-list.md +71 -0
- package/docs/section.md +7 -1
- package/docs/set-scheme.md +2 -2
- package/docs/skeleton.md +4 -3
- package/docs/slots.md +1 -1
- package/docs/sparkline.md +5 -2
- package/docs/stat-card.md +6 -4
- package/docs/testing.md +64 -0
- package/docs/use-local-control.md +8 -1
- package/docs/use-runs.md +32 -0
- package/docs/vite.md +12 -2
- package/docs/zh-hans.md +1 -1
- package/llms.txt +88 -21
- package/migrations/areas/shadcn.json +338 -0
- package/package.json +9 -2
- package/src/astro/shiki.ts +3 -1
- package/src/cards/bar-list.tsx +2 -1
- package/src/cards/chain-view.tsx +167 -55
- package/src/cards/contract.ts +8 -1
- package/src/cards/data-panel.tsx +1 -0
- package/src/cards/event-list.tsx +2 -1
- package/src/cards/index.ts +1 -0
- package/src/cards/row-list.tsx +2 -1
- package/src/cards/stat-card-parts.tsx +9 -7
- package/src/cards/stat-card.tsx +39 -12
- package/src/charts/core/compile.ts +31 -19
- package/src/charts/core/cursor.ts +11 -3
- package/src/charts/core/tooltip-said.ts +55 -0
- package/src/charts/focus.tsx +4 -1
- package/src/charts/parts/chart-card.tsx +1 -0
- package/src/cli/agent-note.ts +12 -5
- package/src/cli/budget/index.ts +22 -5
- package/src/cli/config.ts +1 -1
- package/src/cli/doctor/app.ts +75 -23
- package/src/cli/doctor/eject.ts +30 -10
- package/src/cli/doctor/guards.ts +11 -8
- package/src/cli/doctor/hook.ts +1 -1
- package/src/cli/doctor/install.ts +61 -24
- package/src/cli/doctor/translations.ts +13 -4
- package/src/cli/doctor/types.ts +2 -3
- package/src/cli/doctor/wiring.ts +30 -16
- package/src/cli/eject/dropped-slots.ts +11 -0
- package/src/cli/eject/index.ts +13 -9
- package/src/cli/help.ts +34 -10
- package/src/cli/index.ts +56 -14
- package/src/cli/init/index.ts +64 -5
- package/src/cli/init/locales.ts +41 -8
- package/src/cli/init/router-seeds.ts +17 -3
- package/src/cli/init/steps.ts +308 -41
- package/src/cli/lint/baseline.ts +141 -0
- package/src/cli/lint/engine.ts +33 -10
- package/src/cli/lint/hook.ts +11 -3
- package/src/cli/lint/index.ts +77 -12
- package/src/cli/manifest.ts +132 -4
- package/src/cli/migrate/census.ts +35 -1
- package/src/cli/migrate/index.ts +46 -3
- package/src/cli/migrate/lost-classes.ts +203 -0
- package/src/cli/migrate/rows.ts +21 -0
- package/src/cli/package-manager.ts +4 -1
- package/src/cli/peers.ts +11 -0
- package/src/cli/presets.ts +32 -11
- package/src/cli/resolver.ts +58 -10
- package/src/cli/router-wiring.ts +3 -1
- package/src/cli/sync/engine.ts +30 -14
- package/src/cli/sync/index.ts +7 -4
- package/src/cli/sync/render.ts +29 -37
- package/src/cli/tokens-css.ts +42 -5
- package/src/controls/contract.ts +2 -0
- package/src/controls/control-home.tsx +15 -4
- package/src/controls/local-control.ts +49 -3
- package/src/core/cn.ts +9 -5
- package/src/core/frame-figure.tsx +7 -1
- package/src/core/frame-head.tsx +32 -6
- package/src/core/frame-regions.tsx +18 -8
- package/src/core/info-hint.tsx +26 -0
- package/src/core/mark-tone.ts +10 -3
- package/src/core/mark-types.ts +4 -2
- package/src/core/messages/chain.ts +2 -1
- package/src/core/messages/index.ts +4 -0
- package/src/core/messages/runs.ts +40 -0
- package/src/core/phase.ts +22 -2
- package/src/core/ports.ts +13 -1
- package/src/core/provider.tsx +7 -3
- package/src/core/scheme.ts +6 -2
- package/src/core/spark/mini-bars.tsx +59 -15
- package/src/core/spark/sparkline.tsx +26 -4
- package/src/css/bridge.css +63 -0
- package/src/css/generate.ts +40 -3
- package/src/data/live/live-query.ts +4 -3
- package/src/lint/preset.ts +52 -13
- package/src/lint/rules/class/table.ts +3 -1
- package/src/lint/rules/structure/control-home.ts +1 -1
- package/src/lint/rules/structure/import-boundary.ts +2 -0
- package/src/lint/rules/structure/label-literal.ts +3 -1
- package/src/lint/shadcn.ts +91 -0
- package/src/lint/stylelint/render.ts +31 -1
- package/src/lint/stylelint/rules.ts +19 -7
- package/src/lint/weakened.ts +59 -1
- package/src/messages/de.ts +20 -0
- package/src/messages/es.ts +20 -0
- package/src/messages/fr.ts +20 -0
- package/src/messages/zh-hans.ts +20 -0
- package/src/page/bar-title.tsx +35 -0
- package/src/page/contract.ts +11 -1
- package/src/page/empty-state.tsx +18 -8
- package/src/page/facts.tsx +43 -5
- package/src/page/index.ts +8 -0
- package/src/page/page-bar.tsx +2 -9
- package/src/page/page-summary.tsx +4 -3
- package/src/page/run-button.tsx +52 -0
- package/src/page/run-list.tsx +151 -0
- package/src/page/run-queue.ts +185 -0
- package/src/page/section.tsx +30 -5
- package/src/shell/commands/command-palette.tsx +10 -1
- package/src/shell/parts/header.tsx +1 -1
- package/src/surfaces.ts +18 -1
- package/src/testing/index.ts +1 -0
- package/src/testing/pseudo-locale.ts +149 -0
- package/src/testing/quality.ts +188 -0
- package/src/tokens/bridge-sheet.ts +80 -0
- package/src/tokens/emit.ts +45 -6
- package/src/ui/accordion.tsx +1 -1
- package/src/ui/card.tsx +56 -6
- package/src/ui/collapsible.tsx +5 -3
- package/src/ui/combobox.tsx +1 -1
- package/src/ui/meter.guard.ts +23 -0
- package/src/ui/meter.tsx +76 -27
- package/src/ui/no-restyle.generated.json +8 -0
- package/src/ui/primitive.contract.ts +7 -0
- package/src/ui/remote-pad.guard.ts +24 -0
- package/src/ui/remote-pad.tsx +249 -0
- package/src/ui/segmented.tsx +6 -0
- package/src/ui/skeleton.guard.ts +7 -2
- package/src/ui/skeleton.tsx +10 -4
- package/src/ui/slots.ts +2 -1
- package/src/vite/allotment.ts +15 -1
- package/src/vite/doc.ts +12 -2
- package/src/vite/head.ts +4 -3
- package/src/vite/index.ts +4 -1
- package/src/vite/shell-worker.ts +115 -0
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The adoption baseline, `.basalt/baseline.json`: the findings an app already had when it took the
|
|
3
|
+
* guards on, counted per file and rule. `lint` passes a file's rule while it holds no more than its
|
|
4
|
+
* count and reports every finding of it above that (no line says which one is new). The count only
|
|
5
|
+
* goes down: `lint --baseline` writes the file once and refuses while it exists, `lint --stats`
|
|
6
|
+
* lowers it, and a full `lint` fails while it holds more than is left, so a fixed finding cannot
|
|
7
|
+
* make room for a new one.
|
|
8
|
+
*/
|
|
9
|
+
import { mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
|
|
10
|
+
import { dirname, resolve } from 'node:path'
|
|
11
|
+
|
|
12
|
+
import type { Finding } from './engine'
|
|
13
|
+
|
|
14
|
+
export const BASELINE_PATH = '.basalt/baseline.json'
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Never baselined: a dead or reasonless directive is fixed, not kept, and a file a scanner cannot
|
|
18
|
+
* parse hides whatever else it holds. oxlint reports both under one id; stylelint names a directive
|
|
19
|
+
* report `--report-*` and a syntax error `CssSyntaxError`.
|
|
20
|
+
*/
|
|
21
|
+
const isNever = (id: string): boolean =>
|
|
22
|
+
id === 'basalt/waiver-needs-reason' ||
|
|
23
|
+
id === 'oxlint/unused-directive' ||
|
|
24
|
+
id === 'stylelint/parse-error' ||
|
|
25
|
+
id === 'stylelint/CssSyntaxError' ||
|
|
26
|
+
id.startsWith('stylelint/--report-')
|
|
27
|
+
|
|
28
|
+
/** Install-relative file -> rule id -> findings tolerated. */
|
|
29
|
+
export type Baseline = Record<string, Record<string, number>>
|
|
30
|
+
|
|
31
|
+
const isCounts = (value: unknown): value is Record<string, number> =>
|
|
32
|
+
typeof value === 'object' &&
|
|
33
|
+
value !== null &&
|
|
34
|
+
!Array.isArray(value) &&
|
|
35
|
+
Object.values(value).every((n) => Number.isInteger(n) && (n as number) > 0)
|
|
36
|
+
|
|
37
|
+
export function parseBaseline(text: string): { baseline: Baseline } | { error: string } {
|
|
38
|
+
const bad = {
|
|
39
|
+
error: `${BASELINE_PATH} does not parse as { "<file>": { "<rule>": <count> } }: restore it from git`,
|
|
40
|
+
}
|
|
41
|
+
let parsed: unknown
|
|
42
|
+
try {
|
|
43
|
+
parsed = JSON.parse(text)
|
|
44
|
+
} catch {
|
|
45
|
+
return bad
|
|
46
|
+
}
|
|
47
|
+
if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) return bad
|
|
48
|
+
return Object.values(parsed).every(isCounts) ? { baseline: parsed as Baseline } : bad
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** The install's baseline, or null when it has none; a broken file throws, so no run reads past it. */
|
|
52
|
+
export function readBaseline(dir: string): Baseline | null {
|
|
53
|
+
let text: string
|
|
54
|
+
try {
|
|
55
|
+
text = readFileSync(resolve(dir, BASELINE_PATH), 'utf8')
|
|
56
|
+
} catch (error) {
|
|
57
|
+
if ((error as NodeJS.ErrnoException).code === 'ENOENT') return null
|
|
58
|
+
throw error
|
|
59
|
+
}
|
|
60
|
+
const read = parseBaseline(text)
|
|
61
|
+
if ('error' in read) throw new Error(read.error)
|
|
62
|
+
return read.baseline
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** The findings a baseline may hold, counted. */
|
|
66
|
+
export function countFindings(findings: readonly Finding[]): Baseline {
|
|
67
|
+
const counts: Baseline = {}
|
|
68
|
+
for (const { file, id } of findings) {
|
|
69
|
+
if (isNever(id)) continue
|
|
70
|
+
const rules = (counts[file] ??= {})
|
|
71
|
+
rules[id] = (rules[id] ?? 0) + 1
|
|
72
|
+
}
|
|
73
|
+
return counts
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export const baselineSize = (baseline: Baseline): number =>
|
|
77
|
+
Object.values(baseline)
|
|
78
|
+
.flatMap((rules) => Object.values(rules))
|
|
79
|
+
.reduce((sum, n) => sum + n, 0)
|
|
80
|
+
|
|
81
|
+
const sortedEntries = <T>(record: Record<string, T>): [string, T][] =>
|
|
82
|
+
Object.entries(record).toSorted(([a], [b]) => a.localeCompare(b))
|
|
83
|
+
|
|
84
|
+
/** Writes the canonical bytes, or removes the file when nothing is left; true when it changed. */
|
|
85
|
+
export function writeBaseline(dir: string, baseline: Baseline): boolean {
|
|
86
|
+
const path = resolve(dir, BASELINE_PATH)
|
|
87
|
+
const rows = sortedEntries(baseline).map(
|
|
88
|
+
([file, rules]) => [file, Object.fromEntries(sortedEntries(rules))] as const,
|
|
89
|
+
)
|
|
90
|
+
const next = rows.length === 0 ? null : `${JSON.stringify(Object.fromEntries(rows), null, 2)}\n`
|
|
91
|
+
let current: string | null = null
|
|
92
|
+
try {
|
|
93
|
+
current = readFileSync(path, 'utf8')
|
|
94
|
+
} catch {
|
|
95
|
+
// no file yet
|
|
96
|
+
}
|
|
97
|
+
if (current === next) return false
|
|
98
|
+
if (next === null) rmSync(path, { force: true })
|
|
99
|
+
else {
|
|
100
|
+
mkdirSync(dirname(path), { recursive: true })
|
|
101
|
+
writeFileSync(path, next, 'utf8')
|
|
102
|
+
}
|
|
103
|
+
return true
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** The findings to report: all of a file's rule once it holds more than its count, else none. */
|
|
107
|
+
export function applyBaseline(
|
|
108
|
+
findings: readonly Finding[],
|
|
109
|
+
baseline: Baseline | null,
|
|
110
|
+
): { reported: Finding[]; held: number } {
|
|
111
|
+
if (baseline === null) return { reported: [...findings], held: 0 }
|
|
112
|
+
const counts = countFindings(findings)
|
|
113
|
+
const reported = findings.flatMap((f) => {
|
|
114
|
+
const allowed = isNever(f.id) ? undefined : baseline[f.file]?.[f.id]
|
|
115
|
+
if (allowed === undefined) return [f]
|
|
116
|
+
const found = counts[f.file]?.[f.id] ?? 0
|
|
117
|
+
return found <= allowed
|
|
118
|
+
? []
|
|
119
|
+
: [{ ...f, message: `${f.message} (${found} in this file, ${allowed} baselined)` }]
|
|
120
|
+
})
|
|
121
|
+
return { reported, held: findings.length - reported.length }
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* The baseline a full scan's `findings` leave: each count lowered to what is there, none raised. A
|
|
126
|
+
* file a scanner could not read (or with a dead directive) keeps its counts until it is clean of that.
|
|
127
|
+
*/
|
|
128
|
+
export function lowerBaseline(baseline: Baseline, findings: readonly Finding[]): Baseline {
|
|
129
|
+
const counts = countFindings(findings)
|
|
130
|
+
const unread = new Set(findings.filter((f) => isNever(f.id)).map((f) => f.file))
|
|
131
|
+
return Object.fromEntries(
|
|
132
|
+
Object.entries(baseline).flatMap(([file, rules]) => {
|
|
133
|
+
if (unread.has(file)) return [[file, rules]]
|
|
134
|
+
const left = Object.entries(rules).flatMap(([id, n]) => {
|
|
135
|
+
const now = Math.min(n, counts[file]?.[id] ?? 0)
|
|
136
|
+
return now > 0 ? [[id, now] as const] : []
|
|
137
|
+
})
|
|
138
|
+
return left.length > 0 ? [[file, Object.fromEntries(left)]] : []
|
|
139
|
+
}),
|
|
140
|
+
)
|
|
141
|
+
}
|
package/src/cli/lint/engine.ts
CHANGED
|
@@ -19,7 +19,7 @@ import { filesUnder, rootsOf, SKIPPED_DIRS } from '../doctor/types'
|
|
|
19
19
|
import { findBin, STYLELINT_IGNORE_ARGS } from '../../lint/bin'
|
|
20
20
|
import { dropMisreadDirectives } from '../../lint/rules/structure/waiver-needs-reason'
|
|
21
21
|
import { valueListMessage } from '../../lint/stylelint/rules'
|
|
22
|
-
import { PRESET_FILE } from '../../lint/weakened'
|
|
22
|
+
import { ignoreMatcher, PRESET_FILE, presetLoadProblems } from '../../lint/weakened'
|
|
23
23
|
import { TEMPLATE_FILE, templateClassFindings } from './template-classes'
|
|
24
24
|
|
|
25
25
|
export { findBin }
|
|
@@ -254,14 +254,24 @@ export function runCheckTokens(project: Project, files: readonly string[]): Find
|
|
|
254
254
|
}))
|
|
255
255
|
}
|
|
256
256
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
257
|
+
type PresetFile = {
|
|
258
|
+
rules?: Record<string, unknown>
|
|
259
|
+
overrides?: { files?: string[]; rules?: Record<string, unknown> }[]
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* The basalt rule ids a generated preset (`.oxlintrc.basalt.json`) turns on for `file`
|
|
264
|
+
* (install-relative): its top-level rules, then each override that names the file, in order, the way
|
|
265
|
+
* oxlint lays them. A scoped preset holds the rules in its root overrides, so the top level alone is empty.
|
|
266
|
+
*/
|
|
267
|
+
function enabledIds(preset: PresetFile, file: string): Set<string> {
|
|
268
|
+
const levels = new Map<string, unknown>(Object.entries(preset.rules ?? {}))
|
|
269
|
+
for (const block of preset.overrides ?? []) {
|
|
270
|
+
if (!(block.files ?? []).some((glob) => ignoreMatcher(glob)(file))) continue
|
|
271
|
+
for (const [id, level] of Object.entries(block.rules ?? {})) levels.set(id, level)
|
|
272
|
+
}
|
|
263
273
|
return new Set(
|
|
264
|
-
|
|
274
|
+
[...levels]
|
|
265
275
|
.filter(
|
|
266
276
|
([id, level]) =>
|
|
267
277
|
id.startsWith('basalt/') && (Array.isArray(level) ? level[0] : level) !== 'off',
|
|
@@ -270,14 +280,27 @@ function enabledIds(root: string): Set<string> {
|
|
|
270
280
|
)
|
|
271
281
|
}
|
|
272
282
|
|
|
283
|
+
/** Why oxlint would run none of the preset's rules over `files`; empty when no file goes to oxlint. */
|
|
284
|
+
export function presetProblems(project: Project, files: readonly string[]): string[] {
|
|
285
|
+
return files.some((f) => JS_FILE.test(f) && profileOf(project, f) !== 'tokens')
|
|
286
|
+
? presetLoadProblems(project.root)
|
|
287
|
+
: []
|
|
288
|
+
}
|
|
289
|
+
|
|
273
290
|
/** The class rules over the `.astro`, `.mdx` and `.html` templates oxlint cannot parse. */
|
|
274
291
|
export function runTemplateClasses(project: Project, files: readonly string[]): Finding[] {
|
|
275
292
|
const templates = files.filter((f) => TEMPLATE_FILE.test(f) && profileOf(project, f) !== 'tokens')
|
|
276
293
|
if (templates.length === 0) return []
|
|
277
|
-
const
|
|
294
|
+
const path = resolve(project.root, PRESET_FILE)
|
|
295
|
+
const preset: PresetFile = existsSync(path)
|
|
296
|
+
? (JSON.parse(readFileSync(path, 'utf8')) as PresetFile)
|
|
297
|
+
: {}
|
|
278
298
|
return templates.flatMap((file) => {
|
|
279
299
|
const text = readFileSync(resolve(project.root, file), 'utf8')
|
|
280
|
-
return templateClassFindings(text,
|
|
300
|
+
return templateClassFindings(text, enabledIds(preset, file)).map((f) => ({
|
|
301
|
+
file: posix(file),
|
|
302
|
+
...f,
|
|
303
|
+
}))
|
|
281
304
|
})
|
|
282
305
|
}
|
|
283
306
|
|
package/src/cli/lint/hook.ts
CHANGED
|
@@ -20,6 +20,7 @@ import { OXLINT_PRESET_FILE, STYLELINT_PRESET_FILE } from '../presets'
|
|
|
20
20
|
import { parseJsonc } from '../source-text'
|
|
21
21
|
import { changedFiles, isScanned, scan } from './engine'
|
|
22
22
|
import type { Finding, Project } from './engine'
|
|
23
|
+
import { applyBaseline, BASELINE_PATH, readBaseline } from './baseline'
|
|
23
24
|
import { RECORD_COMMAND, RECORD_PATH } from './record'
|
|
24
25
|
import { HOOK_ADAPTERS, HOOK_TARGETS, MANAGED_DIRS, harnessesOf } from '../harness'
|
|
25
26
|
import { SHIM } from './settings'
|
|
@@ -161,12 +162,16 @@ function editedFiles(project: Project, input: HookInput): Edited[] {
|
|
|
161
162
|
return patchFiles(command).flatMap((p) => inside(p.path, p))
|
|
162
163
|
}
|
|
163
164
|
|
|
165
|
+
/** A scan's findings less the adoption baseline: an edit answers for what it adds. */
|
|
166
|
+
const unheld = (project: Project, files: readonly string[]): Finding[] =>
|
|
167
|
+
applyBaseline(scan(project, files), readBaseline(project.root)).reported
|
|
168
|
+
|
|
164
169
|
function postEdit(project: Project, input: HookInput): number {
|
|
165
170
|
const scanned = editedFiles(project, input)
|
|
166
171
|
.filter((e) => existsSync(e.abs) && isScanned(project, e.rel))
|
|
167
172
|
.map((e) => e.rel)
|
|
168
173
|
if (scanned.length === 0) return 0
|
|
169
|
-
const findings =
|
|
174
|
+
const findings = unheld(project, [...new Set(scanned)])
|
|
170
175
|
return report(hasStopEvent(project) ? findings.filter((f) => !HELD_TO_STOP.has(f.id)) : findings)
|
|
171
176
|
}
|
|
172
177
|
|
|
@@ -185,7 +190,7 @@ function stop(project: Project, input: HookInput): number {
|
|
|
185
190
|
if (input.stop_hook_active === true || typeof session !== 'string' || session === '') return 0
|
|
186
191
|
const counter = stopCounter(project, session)
|
|
187
192
|
if (existsSync(counter)) return 0
|
|
188
|
-
const findings =
|
|
193
|
+
const findings = unheld(project, changedFiles(project))
|
|
189
194
|
if (findings.length === 0) return 0
|
|
190
195
|
writeFileSync(counter, '1')
|
|
191
196
|
return report(findings)
|
|
@@ -249,7 +254,7 @@ function manifestDenial(current: string | null, next: string | null): string | n
|
|
|
249
254
|
if ('error' in was || !isTranslated(was.manifest) || isTranslated(read.manifest)) return null
|
|
250
255
|
return `this edit takes ${MANIFEST_PATH} from two or more \`locales\` to fewer, which switches the literal-text guards off; keep every language the app ships, and waive a single line with a reasoned directive.`
|
|
251
256
|
}
|
|
252
|
-
return `${MANIFEST_PATH} keys ${changed.join(', ')} are written by basalt-ui (\`init\`, \`sync\`, \`eject <name> --reason\`); edit only the consumer keys (profile, roots, locales, catalogs, bespoke, deepRender, authoredContent, viewports, classPrefixes, harnesses, hook, tokens, extra), then run \`basalt-ui sync\`.`
|
|
257
|
+
return `${MANIFEST_PATH} keys ${changed.join(', ')} are written by basalt-ui (\`init\`, \`sync\`, \`eject <name> --reason\`); edit only the consumer keys (profile, roots, locales, partialLocales, catalogs, wordModules, bespoke, deepRender, authoredContent, viewports, classPrefixes, harnesses, hook, tokens, extra), then run \`basalt-ui sync\`.`
|
|
253
258
|
}
|
|
254
259
|
/** Every directory a placement writes a `basalt-` file into, whatever the manifest lists today. */
|
|
255
260
|
const MANAGED_AGENT_FILE = new RegExp(
|
|
@@ -272,6 +277,9 @@ function denial(
|
|
|
272
277
|
if (rel === RECORD_PATH) {
|
|
273
278
|
return `${RECORD_PATH} is the count of this app's waivers and seams; ${RECORD_COMMAND} writes it, never edit it by hand.`
|
|
274
279
|
}
|
|
280
|
+
if (rel === BASELINE_PATH) {
|
|
281
|
+
return `${BASELINE_PATH} is the adoption baseline, which only goes down: fix the finding at its source; \`basalt-ui lint --stats\` lowers it.`
|
|
282
|
+
}
|
|
275
283
|
if (rel === MANIFEST_PATH) return manifestDenial(current, next)
|
|
276
284
|
if (rel === '.basalt' || rel.startsWith('.basalt/')) {
|
|
277
285
|
return ".basalt/** is basalt-ui's ledger and shim; `basalt-ui init`, `sync` and `eject <name> --reason` write it, never edit it by hand. The consumer keys of .basalt/manifest.json are the one exception."
|
package/src/cli/lint/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `lint [--file p | --changed | --stats] [--agent] [--hook <event>]`
|
|
2
|
+
* `lint [--file p | --changed | --stats | --baseline] [--agent] [--hook <event>]`
|
|
3
3
|
* (docs/v3/concepts/skills-agent-layer.md 4.1): oxlint, stylelint and `checkTokens` over the declared
|
|
4
|
-
* roots, then the eject ceiling of `.basalt/budget.json`; `--stats` also writes the record (`./record`). Plain output exits 1 on a finding; `--agent` is
|
|
4
|
+
* roots, less the adoption baseline (`./baseline`), then the eject ceiling of `.basalt/budget.json`; `--stats` also writes the record (`./record`) and lowers the baseline. Plain output exits 1 on a finding; `--agent` is
|
|
5
5
|
* terse and exits 2 so a hook blocks; `--hook` reads the event JSON on stdin, is called only by the
|
|
6
6
|
* managed shim and is exempt from the unknown-flag exit 1, because a hook that exits 1 reads as a pass.
|
|
7
7
|
*/
|
|
@@ -12,9 +12,19 @@ import { parseArgs } from 'node:util'
|
|
|
12
12
|
import { BUDGET_PATH, countedFigure, RAISE_COMMAND, readBudget } from '../budget'
|
|
13
13
|
import { noteRelocation, resolveProjectDir } from '../index'
|
|
14
14
|
import { installAllCommand } from '../package-manager'
|
|
15
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
applyBaseline,
|
|
17
|
+
BASELINE_PATH,
|
|
18
|
+
baselineSize,
|
|
19
|
+
countFindings,
|
|
20
|
+
lowerBaseline,
|
|
21
|
+
readBaseline,
|
|
22
|
+
writeBaseline,
|
|
23
|
+
} from './baseline'
|
|
24
|
+
import type { Baseline } from './baseline'
|
|
25
|
+
import { changedFiles, inRoots, loadProject, presetProblems, rootFiles, scan } from './engine'
|
|
16
26
|
import type { Finding, Project } from './engine'
|
|
17
|
-
import { capFindings, HOOK_EVENTS, runHookEvent } from './hook'
|
|
27
|
+
import { capFindings, findingLine, HOOK_EVENTS, runHookEvent } from './hook'
|
|
18
28
|
import type { HookEventName, HookInput } from './hook'
|
|
19
29
|
import { RECORD_PATH, writeRecord } from './record'
|
|
20
30
|
import { countEjects, countSource, formatStats, tally } from './stats'
|
|
@@ -25,6 +35,7 @@ export const LINT_OPTIONS = {
|
|
|
25
35
|
agent: { type: 'boolean' },
|
|
26
36
|
changed: { type: 'boolean' },
|
|
27
37
|
stats: { type: 'boolean' },
|
|
38
|
+
baseline: { type: 'boolean' },
|
|
28
39
|
hook: { type: 'string' },
|
|
29
40
|
} as const
|
|
30
41
|
|
|
@@ -93,6 +104,24 @@ function countAll(
|
|
|
93
104
|
return { stats, source }
|
|
94
105
|
}
|
|
95
106
|
|
|
107
|
+
/** `--baseline`: records what a full scan finds, once; what it cannot hold is still reported. */
|
|
108
|
+
function writeFirstBaseline(project: Project, findings: readonly Finding[]): number {
|
|
109
|
+
const counts = countFindings(findings)
|
|
110
|
+
const { reported } = applyBaseline(findings, counts)
|
|
111
|
+
if (reported.length > 0) {
|
|
112
|
+
console.log(reported.map(findingLine).join('\n'))
|
|
113
|
+
}
|
|
114
|
+
const size = baselineSize(counts)
|
|
115
|
+
if (size === 0) console.log(`nothing to baseline; ${BASELINE_PATH} not written`)
|
|
116
|
+
else {
|
|
117
|
+
writeBaseline(project.root, counts)
|
|
118
|
+
console.log(
|
|
119
|
+
`${BASELINE_PATH}: ${plural(size, 'finding')} in ${plural(Object.keys(counts).length, 'file')} baselined; commit it`,
|
|
120
|
+
)
|
|
121
|
+
}
|
|
122
|
+
return reported.length > 0 ? 1 : 0
|
|
123
|
+
}
|
|
124
|
+
|
|
96
125
|
export function lint(flags: readonly string[], invocationCwd: string): number {
|
|
97
126
|
if (isHookCall(flags)) return lintHook(flags, invocationCwd)
|
|
98
127
|
const fail = (why: string): number => (console.error(`✖ basalt-ui lint: ${why}`), 1)
|
|
@@ -104,11 +133,32 @@ export function lint(flags: readonly string[], invocationCwd: string): number {
|
|
|
104
133
|
}
|
|
105
134
|
if (files.length > 0 && values.changed === true)
|
|
106
135
|
return fail('--file and --changed are alternatives')
|
|
136
|
+
const wantsBaseline = values.baseline === true
|
|
137
|
+
if (
|
|
138
|
+
wantsBaseline &&
|
|
139
|
+
(files.length > 0 || values.changed === true || wantsStats || values.agent === true)
|
|
140
|
+
) {
|
|
141
|
+
return fail('--baseline counts the whole install; drop every other flag')
|
|
142
|
+
}
|
|
107
143
|
|
|
108
144
|
const resolved = resolveProjectDir(invocationCwd)
|
|
109
145
|
noteRelocation('lint', resolved)
|
|
110
146
|
const project = loadProject(resolved.dir)
|
|
111
147
|
if ('error' in project) return fail(project.error)
|
|
148
|
+
let baseline: Baseline | null
|
|
149
|
+
try {
|
|
150
|
+
baseline = readBaseline(project.root)
|
|
151
|
+
} catch (error) {
|
|
152
|
+
return fail((error as Error).message)
|
|
153
|
+
}
|
|
154
|
+
if (wantsBaseline) {
|
|
155
|
+
if (project.manifest === null) return fail('--baseline needs an install: run `basalt-ui init`')
|
|
156
|
+
if (baseline !== null) {
|
|
157
|
+
return fail(
|
|
158
|
+
`${BASELINE_PATH} exists and only goes down (\`basalt-ui lint --stats\`); fix new findings at their source`,
|
|
159
|
+
)
|
|
160
|
+
}
|
|
161
|
+
}
|
|
112
162
|
|
|
113
163
|
const partial = files.length > 0 || values.changed === true
|
|
114
164
|
let targets: string[]
|
|
@@ -134,18 +184,20 @@ export function lint(flags: readonly string[], invocationCwd: string): number {
|
|
|
134
184
|
)
|
|
135
185
|
}
|
|
136
186
|
|
|
137
|
-
|
|
187
|
+
// A config that does not load the preset runs none of its rules: that is no clean run.
|
|
188
|
+
const unloaded = project.manifest === null ? [] : presetProblems(project, targets)
|
|
189
|
+
if (unloaded.length > 0) return fail(unloaded.join('; '))
|
|
190
|
+
|
|
191
|
+
let scanned: Finding[]
|
|
138
192
|
try {
|
|
139
|
-
|
|
193
|
+
scanned = scan(project, targets)
|
|
140
194
|
} catch (error) {
|
|
141
195
|
return fail(`${(error as Error).message}`)
|
|
142
196
|
}
|
|
143
|
-
if (
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
: findings.map((f) => `${f.file}:${f.line} ${f.id}: ${f.message}`).join('\n'),
|
|
148
|
-
)
|
|
197
|
+
if (wantsBaseline) return writeFirstBaseline(project, scanned)
|
|
198
|
+
const { reported: findings, held } = applyBaseline(scanned, baseline)
|
|
199
|
+
if (findings.length > 0) say(agent ? capFindings(findings) : findings.map(findingLine).join('\n'))
|
|
200
|
+
if (held > 0 && !agent) say(`${plural(held, 'finding')} held by ${BASELINE_PATH}`)
|
|
149
201
|
|
|
150
202
|
const code = findings.length > 0 ? (agent ? 2 : 1) : 0
|
|
151
203
|
if (partial) return code
|
|
@@ -162,6 +214,10 @@ export function lint(flags: readonly string[], invocationCwd: string): number {
|
|
|
162
214
|
`${RECORD_PATH}: ${writeRecord(project.root, source) ? 'written; commit it' : 'unchanged'}`,
|
|
163
215
|
)
|
|
164
216
|
}
|
|
217
|
+
if (baseline !== null) {
|
|
218
|
+
const lowered = writeBaseline(project.root, lowerBaseline(baseline, scanned))
|
|
219
|
+
say(`${BASELINE_PATH}: ${lowered ? 'lowered; commit it' : 'unchanged'}`)
|
|
220
|
+
}
|
|
165
221
|
ejects = stats.counts.ejects
|
|
166
222
|
} else ejects = countEjects(project)
|
|
167
223
|
if (budget !== null && 'error' in budget) return fail(budget.error)
|
|
@@ -172,6 +228,15 @@ export function lint(flags: readonly string[], invocationCwd: string): number {
|
|
|
172
228
|
return 1
|
|
173
229
|
}
|
|
174
230
|
if (wantsStats) return 0
|
|
231
|
+
if (baseline !== null) {
|
|
232
|
+
const slack = baselineSize(baseline) - baselineSize(lowerBaseline(baseline, scanned))
|
|
233
|
+
if (slack > 0) {
|
|
234
|
+
say(
|
|
235
|
+
`${BASELINE_PATH} holds ${plural(slack, 'finding')} more than is left; run \`basalt-ui lint --stats\` and commit it`,
|
|
236
|
+
)
|
|
237
|
+
return agent ? 2 : 1
|
|
238
|
+
}
|
|
239
|
+
}
|
|
175
240
|
if (code === 0 && !agent)
|
|
176
241
|
say(`✓ basalt-ui lint: no findings in ${plural(targets.length, 'file')}.`)
|
|
177
242
|
return code
|
package/src/cli/manifest.ts
CHANGED
|
@@ -17,6 +17,20 @@ export const MANIFEST_PATH = '.basalt/manifest.json'
|
|
|
17
17
|
export const PROFILES = ['tokens', 'site', 'bridge', 'parts', 'app'] as const
|
|
18
18
|
export type Profile = (typeof PROFILES)[number]
|
|
19
19
|
|
|
20
|
+
/** Where the block and the design record live unless the manifest says otherwise. */
|
|
21
|
+
export const AGENTS_FILE = 'AGENTS.md'
|
|
22
|
+
export const DESIGN_FILE = 'DESIGN.md'
|
|
23
|
+
/** The block's sentence on a defect in basalt-ui when the manifest sets no `report`. */
|
|
24
|
+
export const DEFAULT_REPORT =
|
|
25
|
+
'send it with a minimal reproduction (file, command, output) to the tracker in `bugs.url` of `node_modules/basalt-ui/package.json`.'
|
|
26
|
+
|
|
27
|
+
/** The file the block is spliced into, relative to the install root. */
|
|
28
|
+
export const agentsPath = (manifest: Pick<Manifest, 'agents'>): string =>
|
|
29
|
+
manifest.agents ?? AGENTS_FILE
|
|
30
|
+
/** The design record, relative to the install root. */
|
|
31
|
+
export const designPath = (manifest: Pick<Manifest, 'design'>): string =>
|
|
32
|
+
manifest.design ?? DESIGN_FILE
|
|
33
|
+
|
|
20
34
|
/**
|
|
21
35
|
* Whether every root that takes code is a `site`: the declared roots above `tokens` (a token sheet beside a site does not
|
|
22
36
|
* make it an app), else the manifest's own profile. The one reading sync, doctor and shot share.
|
|
@@ -50,6 +64,12 @@ export type Manifest = {
|
|
|
50
64
|
* every language's catalogue is complete.
|
|
51
65
|
*/
|
|
52
66
|
locales?: string[]
|
|
67
|
+
/**
|
|
68
|
+
* Languages of `locales`, never the source one, whose catalogue is still being translated: the app
|
|
69
|
+
* ships them and its catalogue tool falls back to the source language, so `doctor` requires their
|
|
70
|
+
* catalogue files but not every message in them.
|
|
71
|
+
*/
|
|
72
|
+
partialLocales?: string[]
|
|
53
73
|
/**
|
|
54
74
|
* Where a language's message catalogues live, relative to the install root: paths with
|
|
55
75
|
* `{locale}`, where `*` stands for one directory or file name. Absent reads as
|
|
@@ -58,9 +78,16 @@ export type Manifest = {
|
|
|
58
78
|
catalogs?: string[]
|
|
59
79
|
/**
|
|
60
80
|
* Directories (relative to the install root) that draw their own surface, a game table or a
|
|
61
|
-
* seating plan: `primitive-bypass` lets positioned geometry and hand-drawn marks through there
|
|
81
|
+
* seating plan: `primitive-bypass` lets positioned geometry and hand-drawn marks through there,
|
|
82
|
+
* and stylelint lets status, chart and brand color paint a surface and a grid track be a length.
|
|
62
83
|
*/
|
|
63
84
|
bespoke?: string[]
|
|
85
|
+
/**
|
|
86
|
+
* A `site` root's words modules (globs relative to the install root, each naming `.ts` files): a
|
|
87
|
+
* site keeps a language's words in a module instead of a message catalogue, so the literal-text
|
|
88
|
+
* guards are off in them. Pages and parts stay checked.
|
|
89
|
+
*/
|
|
90
|
+
wordModules?: string[]
|
|
64
91
|
/** The agent harnesses the layer is placed for; absent reads as Claude Code alone, `[]` places none. */
|
|
65
92
|
harnesses?: Harness[]
|
|
66
93
|
/** `false` wires no edit hook in any harness; absent is true. */
|
|
@@ -68,6 +95,22 @@ export type Manifest = {
|
|
|
68
95
|
tokens: TokenOutput[]
|
|
69
96
|
/** The `--extra` file `tokens:css` reads. */
|
|
70
97
|
extra?: string
|
|
98
|
+
/**
|
|
99
|
+
* Where the managed block lives, relative to the install root: the AGENTS file of the app this
|
|
100
|
+
* install serves (`apps/console/AGENTS.md`), so the repo's root file stays about the repo.
|
|
101
|
+
* Absent reads as `AGENTS.md`.
|
|
102
|
+
*/
|
|
103
|
+
agents?: string
|
|
104
|
+
/**
|
|
105
|
+
* Where the design record lives, relative to the install root (`apps/console/DESIGN.md`): `doctor`
|
|
106
|
+
* reads it there, `init` seeds it there and the block names it. Absent reads as `DESIGN.md`.
|
|
107
|
+
*/
|
|
108
|
+
design?: string
|
|
109
|
+
/**
|
|
110
|
+
* The block's one sentence on a defect in basalt-ui (where to send it): a repo whose agents file
|
|
111
|
+
* issues through another channel names it here. Absent reads as `DEFAULT_REPORT`.
|
|
112
|
+
*/
|
|
113
|
+
report?: string
|
|
71
114
|
/** A sibling install's name prefix for its repo-root rules and skills (`basalt-v3-`, `basalt-v3-<dir>-`). */
|
|
72
115
|
sibling?: string
|
|
73
116
|
/** Fields this version does not know, kept so a newer manifest survives an older `sync`. */
|
|
@@ -88,8 +131,8 @@ export type ManifestRead = { manifest: Manifest; format: number } | { error: str
|
|
|
88
131
|
/**
|
|
89
132
|
* The keys the CLI writes: `init`, `sync` and `eject` own them, and the pre-edit guard refuses a
|
|
90
133
|
* hand edit that changes one. Every other key is the consumer's to edit: `profile`, `roots`,
|
|
91
|
-
* `locales`, `catalogs`, `bespoke`, `deepRender`, `authoredContent`, `viewports`, `classPrefixes`, `harnesses`, `hook`,
|
|
92
|
-
* `tokens`, `extra`.
|
|
134
|
+
* `locales`, `partialLocales`, `catalogs`, `wordModules`, `bespoke`, `deepRender`, `authoredContent`, `viewports`, `classPrefixes`, `harnesses`, `hook`,
|
|
135
|
+
* `agents`, `design`, `report`, `tokens`, `extra`.
|
|
93
136
|
*/
|
|
94
137
|
export const CLI_OWNED_KEYS = ['format', 'version', 'managed', 'ejected', 'sibling'] as const
|
|
95
138
|
|
|
@@ -104,10 +147,15 @@ const KNOWN = [
|
|
|
104
147
|
'tokens',
|
|
105
148
|
'extra',
|
|
106
149
|
'sibling',
|
|
150
|
+
'agents',
|
|
151
|
+
'design',
|
|
152
|
+
'report',
|
|
107
153
|
'harnesses',
|
|
108
154
|
'hook',
|
|
109
155
|
'locales',
|
|
156
|
+
'partialLocales',
|
|
110
157
|
'catalogs',
|
|
158
|
+
'wordModules',
|
|
111
159
|
...LISTS,
|
|
112
160
|
]
|
|
113
161
|
|
|
@@ -121,7 +169,7 @@ export const isLocaleTag = (tag: string): boolean => {
|
|
|
121
169
|
return false
|
|
122
170
|
}
|
|
123
171
|
}
|
|
124
|
-
const isCatalogPattern = (pattern: string): boolean =>
|
|
172
|
+
export const isCatalogPattern = (pattern: string): boolean =>
|
|
125
173
|
pattern.includes('{locale}') && !/^([/\\]|[a-zA-Z]:)/.test(pattern) && !/\n|\r/.test(pattern)
|
|
126
174
|
const isProfile = (v: unknown): v is Profile => PROFILES.includes(v as Profile)
|
|
127
175
|
const isStrings = (v: unknown): v is string[] =>
|
|
@@ -131,11 +179,42 @@ const isRelative = (root: string): boolean =>
|
|
|
131
179
|
!/^([/\\]|[a-zA-Z]:)/.test(root) &&
|
|
132
180
|
!/\n|\r/.test(root) &&
|
|
133
181
|
!root.split('/').includes('..')
|
|
182
|
+
/** A markdown file below the install root: relative, no glob, not a directory. */
|
|
183
|
+
export const isMarkdownFile = (path: string): boolean =>
|
|
184
|
+
isRelative(path) && !path.startsWith('./') && /\.md$/i.test(path) && !/[*?[\]{}]/.test(path)
|
|
134
185
|
/** The root (`.`, `./.`) would waive the whole project: a bespoke surface is one named directory, no glob. */
|
|
135
186
|
const isBespokeDir = (dir: string): boolean =>
|
|
136
187
|
isRelative(dir) &&
|
|
137
188
|
dir.split('/').some((segment) => segment !== '' && segment !== '.') &&
|
|
138
189
|
!/[*?[\]{}]/.test(dir)
|
|
190
|
+
/** A declared root as a clean relative path (`./src/` -> `src`, the root itself -> `.`). */
|
|
191
|
+
export const cleanRoot = (raw: string): string =>
|
|
192
|
+
raw.replace(/^(?:\.\/)+/, '').replace(/\/+$/, '') || '.'
|
|
193
|
+
|
|
194
|
+
const within = (path: string, root: string): boolean =>
|
|
195
|
+
root === '' || path === root || path.startsWith(`${root}/`)
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* A words module glob: `.ts` files only, so no markup is ever waived, below a root declared `site`
|
|
199
|
+
* with no other profile nested under the directory the glob starts in. An `app` root keeps its
|
|
200
|
+
* words in a message catalogue.
|
|
201
|
+
*/
|
|
202
|
+
function isWordModule(glob: string, profile: Profile, roots: Manifest['roots']): boolean {
|
|
203
|
+
if (!isRelative(glob) || /^(?:\.\/|!)/.test(glob) || !/\.[cm]?ts$/.test(glob)) return false
|
|
204
|
+
const segments = glob.split('/')
|
|
205
|
+
if (segments.some((segment) => segment === '' || segment === '.')) return false
|
|
206
|
+
const wild = segments.findIndex((segment) => /[*?[\]{}]/.test(segment))
|
|
207
|
+
const dir = segments.slice(0, wild === -1 ? -1 : wild).join('/')
|
|
208
|
+
// The paths the preset lints (`cleanRoot`), so the bound judges what is linted.
|
|
209
|
+
const declared = Object.entries(roots).map(
|
|
210
|
+
([root, of]) => [cleanRoot(root).replace(/^\.$/, ''), of] as const,
|
|
211
|
+
)
|
|
212
|
+
const owner = declared
|
|
213
|
+
.filter(([root]) => within(dir, root))
|
|
214
|
+
.toSorted(([a], [b]) => b.length - a.length)[0]
|
|
215
|
+
const own = declared.length === 0 ? profile : owner?.[1]
|
|
216
|
+
return own === 'site' && declared.every(([root, of]) => of === 'site' || !within(root, dir))
|
|
217
|
+
}
|
|
139
218
|
const isTokenOutput = (v: unknown): v is TokenOutput =>
|
|
140
219
|
isRecord(v) &&
|
|
141
220
|
typeof v['out'] === 'string' &&
|
|
@@ -172,10 +251,15 @@ export function parseManifest(text: string): ManifestRead {
|
|
|
172
251
|
tokens = [],
|
|
173
252
|
extra,
|
|
174
253
|
sibling,
|
|
254
|
+
agents,
|
|
255
|
+
design,
|
|
256
|
+
report,
|
|
175
257
|
harnesses,
|
|
176
258
|
hook,
|
|
177
259
|
locales,
|
|
260
|
+
partialLocales,
|
|
178
261
|
catalogs,
|
|
262
|
+
wordModules,
|
|
179
263
|
} = raw
|
|
180
264
|
if (!isProfile(profile)) {
|
|
181
265
|
const door = `run \`basalt-ui init --profile <${PROFILES.join('|')}>\``
|
|
@@ -208,6 +292,17 @@ export function parseManifest(text: string): ManifestRead {
|
|
|
208
292
|
) {
|
|
209
293
|
return bad('`sibling` must be a name prefix starting `basalt-v3-`')
|
|
210
294
|
}
|
|
295
|
+
for (const [key, value] of [
|
|
296
|
+
['agents', agents],
|
|
297
|
+
['design', design],
|
|
298
|
+
] as const) {
|
|
299
|
+
if (value !== undefined && !(typeof value === 'string' && isMarkdownFile(value))) {
|
|
300
|
+
return bad(`\`${key}\` must be a relative path to a .md file below the install root`)
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
if (report !== undefined && !(typeof report === 'string' && /^[^\n\r]+$/.test(report.trim()))) {
|
|
304
|
+
return bad('`report` must be one line of text')
|
|
305
|
+
}
|
|
211
306
|
if (harnesses !== undefined && !(Array.isArray(harnesses) && harnesses.every(isHarness))) {
|
|
212
307
|
return bad('`harnesses` must list claude-code, codex, opencode or pi')
|
|
213
308
|
}
|
|
@@ -218,11 +313,34 @@ export function parseManifest(text: string): ManifestRead {
|
|
|
218
313
|
) {
|
|
219
314
|
return bad('`locales` must list distinct language tags (en, de, zh-Hans), the source one first')
|
|
220
315
|
}
|
|
316
|
+
if (
|
|
317
|
+
partialLocales !== undefined &&
|
|
318
|
+
!(
|
|
319
|
+
isStrings(partialLocales) &&
|
|
320
|
+
new Set(partialLocales).size === partialLocales.length &&
|
|
321
|
+
partialLocales.every((tag) => ((locales ?? []) as string[]).indexOf(tag) > 0)
|
|
322
|
+
)
|
|
323
|
+
) {
|
|
324
|
+
return bad(
|
|
325
|
+
'`partialLocales` must list distinct languages of `locales`, never the source (first) one',
|
|
326
|
+
)
|
|
327
|
+
}
|
|
221
328
|
if (catalogs !== undefined && !(isStrings(catalogs) && catalogs.every(isCatalogPattern))) {
|
|
222
329
|
return bad(
|
|
223
330
|
'`catalogs` must list relative paths that name {locale}, like src/locales/{locale}.po',
|
|
224
331
|
)
|
|
225
332
|
}
|
|
333
|
+
if (
|
|
334
|
+
wordModules !== undefined &&
|
|
335
|
+
!(
|
|
336
|
+
isStrings(wordModules) &&
|
|
337
|
+
wordModules.every((glob) => isWordModule(glob, profile, roots as Manifest['roots']))
|
|
338
|
+
)
|
|
339
|
+
) {
|
|
340
|
+
return bad(
|
|
341
|
+
'`wordModules` must list `.ts` globs below a `site` root, like apps/site/src/strings.*.ts',
|
|
342
|
+
)
|
|
343
|
+
}
|
|
226
344
|
const lists = LISTS.map((key) => raw[key] ?? [])
|
|
227
345
|
if (!lists.every(isStrings)) return bad(`${LISTS.join(', ')} must be arrays of strings`)
|
|
228
346
|
if (!(lists[4] as string[]).every(isBespokeDir)) {
|
|
@@ -245,10 +363,15 @@ export function parseManifest(text: string): ManifestRead {
|
|
|
245
363
|
...(harnesses === undefined ? {} : { harnesses: [...new Set(harnesses as Harness[])] }),
|
|
246
364
|
...(hook === undefined ? {} : { hook }),
|
|
247
365
|
...(locales === undefined ? {} : { locales: locales as string[] }),
|
|
366
|
+
...(partialLocales === undefined ? {} : { partialLocales: partialLocales as string[] }),
|
|
248
367
|
...(catalogs === undefined ? {} : { catalogs: catalogs as string[] }),
|
|
368
|
+
...(wordModules === undefined ? {} : { wordModules: wordModules as string[] }),
|
|
249
369
|
tokens,
|
|
250
370
|
...(extra === undefined ? {} : { extra }),
|
|
251
371
|
...(typeof sibling === 'string' ? { sibling } : {}),
|
|
372
|
+
...(typeof agents === 'string' ? { agents } : {}),
|
|
373
|
+
...(typeof design === 'string' ? { design } : {}),
|
|
374
|
+
...(typeof report === 'string' ? { report: report.trim() } : {}),
|
|
252
375
|
rest: Object.fromEntries(Object.entries(raw).filter(([key]) => !KNOWN.includes(key))),
|
|
253
376
|
},
|
|
254
377
|
}
|
|
@@ -276,10 +399,15 @@ export function serializeManifest(m: Manifest): string {
|
|
|
276
399
|
...(m.harnesses === undefined ? {} : { harnesses: m.harnesses }),
|
|
277
400
|
...(m.hook === undefined ? {} : { hook: m.hook }),
|
|
278
401
|
...(m.locales === undefined ? {} : { locales: m.locales }),
|
|
402
|
+
...(m.partialLocales?.length ? { partialLocales: m.partialLocales } : {}),
|
|
279
403
|
...(m.catalogs === undefined ? {} : { catalogs: m.catalogs }),
|
|
404
|
+
...(m.wordModules?.length ? { wordModules: m.wordModules } : {}),
|
|
280
405
|
tokens,
|
|
281
406
|
...(extra === undefined ? {} : { extra }),
|
|
282
407
|
...(sibling === undefined ? {} : { sibling }),
|
|
408
|
+
...(m.agents === undefined ? {} : { agents: m.agents }),
|
|
409
|
+
...(m.design === undefined ? {} : { design: m.design }),
|
|
410
|
+
...(m.report === undefined ? {} : { report: m.report }),
|
|
283
411
|
...rest,
|
|
284
412
|
}
|
|
285
413
|
return `${JSON.stringify(body, null, 2)}\n`
|