basalt-ui 2.21.0 → 2.23.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.
Files changed (254) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/MIGRATING.md +452 -12
  3. package/agent/agents/basalt-design-reviewer.md +1 -1
  4. package/agent/rules/basalt-tokens.md +1 -1
  5. package/agent/skills/basalt-design/SKILL.md +1 -1
  6. package/agent/skills/basalt-design/references/anti-defaults.md +1 -1
  7. package/agent/skills/basalt-design/references/catalogue.md +1 -0
  8. package/dist/charts/BandStrip.d.ts.map +1 -1
  9. package/dist/charts/BandStrip.js +73 -3
  10. package/dist/charts/Bars.d.ts.map +1 -1
  11. package/dist/charts/Bars.js +6 -0
  12. package/dist/charts/CartesianChart.d.ts +10 -0
  13. package/dist/charts/CartesianChart.d.ts.map +1 -1
  14. package/dist/charts/CartesianChart.js +8 -5
  15. package/dist/charts/ChartCard.d.ts +12 -3
  16. package/dist/charts/ChartCard.d.ts.map +1 -1
  17. package/dist/charts/ChartCard.js +39 -8
  18. package/dist/charts/DualPanel.d.ts.map +1 -1
  19. package/dist/charts/DualPanel.js +5 -8
  20. package/dist/charts/Heatmap.d.ts +12 -1
  21. package/dist/charts/Heatmap.d.ts.map +1 -1
  22. package/dist/charts/Heatmap.js +34 -5
  23. package/dist/charts/Lines.d.ts +3 -0
  24. package/dist/charts/Lines.d.ts.map +1 -1
  25. package/dist/charts/Lines.js +29 -6
  26. package/dist/charts/MirroredBars.d.ts.map +1 -1
  27. package/dist/charts/MirroredBars.js +4 -6
  28. package/dist/charts/Sparkline.d.ts +14 -2
  29. package/dist/charts/Sparkline.d.ts.map +1 -1
  30. package/dist/charts/Sparkline.js +101 -22
  31. package/dist/charts/StackedArea.d.ts +4 -1
  32. package/dist/charts/StackedArea.d.ts.map +1 -1
  33. package/dist/charts/StackedArea.js +9 -3
  34. package/dist/charts/band-fold.d.ts +38 -1
  35. package/dist/charts/band-fold.d.ts.map +1 -1
  36. package/dist/charts/band-fold.js +18 -1
  37. package/dist/charts/chart-box.module.css +19 -0
  38. package/dist/charts/chart-card.module.css +25 -0
  39. package/dist/charts/chart-dates.d.ts +12 -0
  40. package/dist/charts/chart-dates.d.ts.map +1 -0
  41. package/dist/charts/chart-dates.js +16 -0
  42. package/dist/charts/chart-legend.module.css +7 -0
  43. package/dist/charts/compile.d.ts +25 -6
  44. package/dist/charts/compile.d.ts.map +1 -1
  45. package/dist/charts/compile.js +152 -72
  46. package/dist/charts/date-tick-format.d.ts +5 -5
  47. package/dist/charts/date-tick-format.d.ts.map +1 -1
  48. package/dist/charts/date-tick-format.js +3 -7
  49. package/dist/charts/labels.d.ts +21 -6
  50. package/dist/charts/labels.d.ts.map +1 -1
  51. package/dist/charts/labels.js +52 -17
  52. package/dist/charts/legend.d.ts +2 -0
  53. package/dist/charts/legend.d.ts.map +1 -1
  54. package/dist/charts/legend.js +7 -21
  55. package/dist/charts/marks.js +1 -1
  56. package/dist/charts/panel.d.ts +0 -6
  57. package/dist/charts/panel.d.ts.map +1 -1
  58. package/dist/charts/panel.js +1 -10
  59. package/dist/charts/ref-label.d.ts +43 -0
  60. package/dist/charts/ref-label.d.ts.map +1 -0
  61. package/dist/charts/ref-label.js +75 -0
  62. package/dist/charts/scales.d.ts +4 -1
  63. package/dist/charts/scales.d.ts.map +1 -1
  64. package/dist/charts/scales.js +14 -3
  65. package/dist/charts/sparkline.module.css +13 -17
  66. package/dist/charts/sparkline.module.css.d.ts +1 -2
  67. package/dist/charts/state.d.ts +2 -0
  68. package/dist/charts/state.d.ts.map +1 -1
  69. package/dist/charts/state.js +5 -2
  70. package/dist/charts/types.d.ts +18 -8
  71. package/dist/charts/types.d.ts.map +1 -1
  72. package/dist/cli/doctor-upgrade.d.ts +1 -0
  73. package/dist/cli/doctor-upgrade.d.ts.map +1 -1
  74. package/dist/cli/doctor-upgrade.js +1 -0
  75. package/dist/cli/init.d.ts +2 -0
  76. package/dist/cli/init.d.ts.map +1 -1
  77. package/dist/cli/init.js +68 -4
  78. package/dist/cli/shot/capture.d.ts +21 -2
  79. package/dist/cli/shot/capture.d.ts.map +1 -1
  80. package/dist/cli/shot/capture.js +202 -36
  81. package/dist/cli/shot/detect.d.ts.map +1 -1
  82. package/dist/cli/shot/detect.js +17 -1
  83. package/dist/cli/shot/playwright.d.ts +13 -2
  84. package/dist/cli/shot/playwright.d.ts.map +1 -1
  85. package/dist/cli/shot/playwright.js +5 -1
  86. package/dist/cli/shot/types.d.ts +4 -0
  87. package/dist/cli/shot/types.d.ts.map +1 -1
  88. package/dist/cli/shot/types.js +2 -0
  89. package/dist/cli/tokens-css.d.ts +5 -7
  90. package/dist/cli/tokens-css.d.ts.map +1 -1
  91. package/dist/cli/tokens-css.js +11 -12
  92. package/dist/controls/controls.module.css +11 -1
  93. package/dist/controls/filter-pill.d.ts.map +1 -1
  94. package/dist/controls/filter-pill.js +1 -0
  95. package/dist/controls/sync-button.d.ts.map +1 -1
  96. package/dist/controls/sync-button.js +22 -3
  97. package/dist/controls/sync-button.module.css +34 -2
  98. package/dist/controls/sync-button.module.css.d.ts +1 -0
  99. package/dist/dashboard/bar-list.d.ts +6 -1
  100. package/dist/dashboard/bar-list.d.ts.map +1 -1
  101. package/dist/dashboard/bar-list.js +15 -8
  102. package/dist/dashboard/bar-list.module.css +83 -0
  103. package/dist/dashboard/bar-list.module.css.d.ts +1 -0
  104. package/dist/dashboard/delta-badge.d.ts.map +1 -1
  105. package/dist/dashboard/delta-badge.js +2 -2
  106. package/dist/dashboard/index.d.ts +1 -0
  107. package/dist/dashboard/index.d.ts.map +1 -1
  108. package/dist/dashboard/index.js +2 -0
  109. package/dist/dashboard/meter-model.d.ts +84 -5
  110. package/dist/dashboard/meter-model.d.ts.map +1 -1
  111. package/dist/dashboard/meter-model.js +100 -15
  112. package/dist/dashboard/meter-parts.d.ts +9 -1
  113. package/dist/dashboard/meter-parts.d.ts.map +1 -1
  114. package/dist/dashboard/meter-parts.js +276 -74
  115. package/dist/dashboard/meter.d.ts +54 -65
  116. package/dist/dashboard/meter.d.ts.map +1 -1
  117. package/dist/dashboard/meter.js +21 -4
  118. package/dist/dashboard/meter.module.css +76 -0
  119. package/dist/dashboard/meter.module.css.d.ts +6 -0
  120. package/dist/dashboard/page-summary.d.ts +20 -0
  121. package/dist/dashboard/page-summary.d.ts.map +1 -0
  122. package/dist/dashboard/page-summary.js +28 -0
  123. package/dist/dashboard/page-summary.module.css +89 -0
  124. package/dist/dashboard/page-summary.module.css.d.ts +15 -0
  125. package/dist/dashboard/query-state.d.ts.map +1 -1
  126. package/dist/dashboard/query-state.js +1 -1
  127. package/dist/dashboard/section.d.ts +25 -2
  128. package/dist/dashboard/section.d.ts.map +1 -1
  129. package/dist/dashboard/section.js +10 -5
  130. package/dist/dashboard/section.module.css +23 -0
  131. package/dist/dashboard/section.module.css.d.ts +1 -0
  132. package/dist/dashboard/stat-card-parts.d.ts.map +1 -1
  133. package/dist/dashboard/stat-card-parts.js +1 -1
  134. package/dist/dashboard/stat-card.d.ts +4 -2
  135. package/dist/dashboard/stat-card.d.ts.map +1 -1
  136. package/dist/dashboard/stat-card.js +7 -5
  137. package/dist/dashboard/stat-card.module.css +36 -0
  138. package/dist/dashboard/stat-group.module.css +7 -0
  139. package/dist/dashboard/stat-strip.d.ts +22 -6
  140. package/dist/dashboard/stat-strip.d.ts.map +1 -1
  141. package/dist/dashboard/stat-strip.js +104 -60
  142. package/dist/dashboard/stat-strip.module.css +122 -53
  143. package/dist/dashboard/stat-strip.module.css.d.ts +4 -0
  144. package/dist/dashboard/visual-slot.d.ts +7 -1
  145. package/dist/dashboard/visual-slot.d.ts.map +1 -1
  146. package/dist/dashboard/visual-slot.js +3 -1
  147. package/dist/guard/index.d.ts.map +1 -1
  148. package/dist/guard/index.js +0 -5
  149. package/dist/guard/vx-names.d.ts.map +1 -1
  150. package/dist/guard/vx-names.js +2 -0
  151. package/dist/index.d.ts +1 -1
  152. package/dist/index.d.ts.map +1 -1
  153. package/dist/index.js +3 -1
  154. package/dist/styles.css +43 -4
  155. package/dist/theme/chrome-vars.d.ts +20 -5
  156. package/dist/theme/chrome-vars.d.ts.map +1 -1
  157. package/dist/theme/chrome-vars.js +46 -3
  158. package/dist/theme/controls.module.css +37 -0
  159. package/dist/theme/controls.module.css.d.ts +2 -0
  160. package/dist/theme/index.d.ts.map +1 -1
  161. package/dist/theme/index.js +18 -27
  162. package/dist/theme/status-verdict.d.ts.map +1 -1
  163. package/dist/theme/status-verdict.js +9 -1
  164. package/dist/tokens/core.d.ts +2 -1
  165. package/dist/tokens/core.d.ts.map +1 -1
  166. package/dist/tokens/core.js +6 -1
  167. package/dist/tokens/derive.d.ts +3 -1
  168. package/dist/tokens/derive.d.ts.map +1 -1
  169. package/dist/tokens/derive.js +16 -1
  170. package/dist/tokens/palette.d.ts +11 -10
  171. package/dist/tokens/palette.d.ts.map +1 -1
  172. package/dist/tokens/palette.js +11 -10
  173. package/dist/tokens/status-text.d.ts.map +1 -1
  174. package/dist/tokens/status-text.js +3 -1
  175. package/llms.txt +42 -22
  176. package/package.json +1 -1
  177. package/src/charts/BandStrip.tsx +83 -3
  178. package/src/charts/Bars.tsx +7 -0
  179. package/src/charts/CartesianChart.tsx +18 -3
  180. package/src/charts/ChartCard.tsx +54 -13
  181. package/src/charts/DualPanel.tsx +3 -6
  182. package/src/charts/Heatmap.tsx +54 -5
  183. package/src/charts/Lines.tsx +56 -10
  184. package/src/charts/MirroredBars.tsx +3 -5
  185. package/src/charts/Sparkline.tsx +135 -25
  186. package/src/charts/StackedArea.tsx +14 -4
  187. package/src/charts/band-fold.ts +50 -1
  188. package/src/charts/chart-box.module.css +19 -0
  189. package/src/charts/chart-card.module.css +25 -0
  190. package/src/charts/chart-dates.ts +30 -0
  191. package/src/charts/chart-legend.module.css +7 -0
  192. package/src/charts/compile.ts +253 -87
  193. package/src/charts/date-tick-format.ts +10 -13
  194. package/src/charts/labels.ts +81 -26
  195. package/src/charts/legend.tsx +10 -20
  196. package/src/charts/marks.ts +1 -1
  197. package/src/charts/panel.tsx +1 -16
  198. package/src/charts/ref-label.ts +131 -0
  199. package/src/charts/scales.ts +22 -2
  200. package/src/charts/sparkline.module.css +13 -17
  201. package/src/charts/sparkline.module.css.d.ts +1 -2
  202. package/src/charts/state.tsx +9 -4
  203. package/src/charts/types.ts +18 -8
  204. package/src/cli/doctor-upgrade.ts +1 -1
  205. package/src/cli/init.ts +100 -3
  206. package/src/cli/shot/capture.ts +266 -35
  207. package/src/cli/shot/detect.ts +18 -1
  208. package/src/cli/shot/playwright.ts +20 -4
  209. package/src/cli/shot/types.ts +5 -0
  210. package/src/cli/tokens-css.ts +18 -20
  211. package/src/controls/controls.module.css +11 -1
  212. package/src/controls/filter-pill.tsx +2 -0
  213. package/src/controls/sync-button.module.css +34 -2
  214. package/src/controls/sync-button.module.css.d.ts +1 -0
  215. package/src/controls/sync-button.tsx +40 -4
  216. package/src/dashboard/bar-list.module.css +83 -0
  217. package/src/dashboard/bar-list.module.css.d.ts +1 -0
  218. package/src/dashboard/bar-list.tsx +107 -69
  219. package/src/dashboard/delta-badge.tsx +6 -2
  220. package/src/dashboard/index.ts +1 -0
  221. package/src/dashboard/meter-model.ts +207 -24
  222. package/src/dashboard/meter-parts.tsx +349 -67
  223. package/src/dashboard/meter.module.css +76 -0
  224. package/src/dashboard/meter.module.css.d.ts +6 -0
  225. package/src/dashboard/meter.tsx +72 -18
  226. package/src/dashboard/page-summary.module.css +89 -0
  227. package/src/dashboard/page-summary.module.css.d.ts +15 -0
  228. package/src/dashboard/page-summary.tsx +95 -0
  229. package/src/dashboard/query-state.tsx +1 -1
  230. package/src/dashboard/section.module.css +23 -0
  231. package/src/dashboard/section.module.css.d.ts +1 -0
  232. package/src/dashboard/section.tsx +59 -11
  233. package/src/dashboard/stat-card-parts.tsx +5 -1
  234. package/src/dashboard/stat-card.module.css +36 -0
  235. package/src/dashboard/stat-card.tsx +12 -6
  236. package/src/dashboard/stat-group.module.css +7 -0
  237. package/src/dashboard/stat-strip.module.css +122 -53
  238. package/src/dashboard/stat-strip.module.css.d.ts +4 -0
  239. package/src/dashboard/stat-strip.tsx +176 -91
  240. package/src/dashboard/visual-slot.ts +12 -3
  241. package/src/guard/index.ts +0 -5
  242. package/src/guard/vx-names.ts +2 -0
  243. package/src/index.ts +2 -0
  244. package/src/styles.css +43 -4
  245. package/src/theme/__snapshots__/plain-theme.test.ts.snap +200 -68
  246. package/src/theme/chrome-vars.ts +77 -8
  247. package/src/theme/controls.module.css +37 -0
  248. package/src/theme/controls.module.css.d.ts +2 -0
  249. package/src/theme/index.ts +22 -32
  250. package/src/theme/status-verdict.tsx +5 -1
  251. package/src/tokens/core.ts +4 -1
  252. package/src/tokens/derive.ts +32 -3
  253. package/src/tokens/palette.ts +11 -10
  254. package/src/tokens/status-text.ts +2 -0
@@ -6,6 +6,7 @@ import type { StoredChartSpec } from '@tanstack/charts/types/core'
6
6
  import type { BasaltProps } from '../common/props'
7
7
  import type { ContainerClass } from '../tokens/size-classes'
8
8
  import type { CurveName } from './curves'
9
+ import type { RefLabelPosition } from './ref-label'
9
10
 
10
11
  /** What `x` may return. The value type picks the x scale (§ 9.4): `Date` → time, `number` → linear,
11
12
  * `string` → point (lines) or band (bars). */
@@ -27,8 +28,10 @@ export type ChartSeries<T> = {
27
28
  mark?: 'line' | 'bar' | 'area' | undefined
28
29
  /** Default `'solid'`; `'dashed'` is `VX.dashArray` on the line, the legend and the tooltip. */
29
30
  dash?: 'solid' | 'dashed' | undefined
30
- /** Interpolation between points. Default `'monotone'`. A piecewise-constant quantity (a price
31
- * tier, a config value) is a step: a smoothed curve draws values that never existed. */
31
+ /** Interpolation between points. Default `'linear'`: discrete values (a daily total, a monthly
32
+ * rate) are joined by straight segments, never by a smoothed curve with crossings between points
33
+ * that never happened. `'monotone'` is an opt-in for a continuous measure; a piecewise-constant
34
+ * quantity (a price tier, a config value) is a step. */
32
35
  curve?: CurveName | undefined
33
36
  strokeWidth?: number | undefined
34
37
  /**
@@ -155,11 +158,17 @@ export type RefLine = {
155
158
  dashed?: boolean | undefined
156
159
  axis?: 'left' | 'right' | undefined
157
160
  /**
158
- * Names the line on the plot: a small muted caption at the plot's right end (left end for a
159
- * right-axis line, clear of its tick labels), above the line, below it near the plot's top. It
160
- * follows the legend toggle. The ink is `--vx-ink2`, never the line colour.
161
+ * Names the line on the plot: a small muted caption on one of four spots (the plot's end or
162
+ * start, above or below the line). It follows the legend toggle. The ink is `--vx-ink2`, never
163
+ * the line colour.
161
164
  */
162
165
  label?: string | undefined
166
+ /**
167
+ * Pins the caption's spot. Default: the first spot (the plot's right end above the line; the left
168
+ * end for a right-axis line) that stays inside the plot and that no data line runs through, so a
169
+ * line in the top or bottom quarter, or one a series ends on, moves its caption.
170
+ */
171
+ labelPosition?: RefLabelPosition | undefined
163
172
  /**
164
173
  * Names the line in the legend (its color, dashed as `dashed`; a toggle hides the line), so a
165
174
  * threshold needs no always-`null` series. `mark` is the swatch shape. Default `'line'`. The
@@ -190,8 +199,9 @@ export type ChartTooltipRow = {
190
199
  }
191
200
 
192
201
  export type ChartTooltipConfig<T, X extends ChartX = ChartX> = {
193
- /** The tooltip title. Default: the x value through `formatX`'s long form (a date reads
194
- * `Mon Sep 1 2026`). */
202
+ /** The tooltip title. Default: a Date x reads weekday, day, month and year in the page locale
203
+ * (`Tue 1 Sep 2026`; a non-day instant adds its time) whatever `formatX` shortens the ticks to;
204
+ * any other x goes through `formatX`. */
195
205
  formatHeader?: ((x: X, d: T) => string) | undefined
196
206
  /** Rows after the per-series rows (a total, a zone badge, a context line). `visible`/`hidden` are
197
207
  * the legend's split, so a row never names a series the plot no longer draws. */
@@ -311,7 +321,7 @@ export type CartesianChartProps<T, X extends ChartX = ChartX> = BasaltProps & {
311
321
  xDomain?: readonly [X, X] | undefined
312
322
  /**
313
323
  * Tick label for an x value. Default: compact numbers, strings verbatim, and dates by tick step
314
- * (`HH:MM` with the day on midnight, `DD.MM`, a month with the year on January; a label recurs
324
+ * (`HH:MM` with the day on midnight, the day (`4 Oct`, in the page locale), a month with the year on January; a label recurs
315
325
  * only behind a day or year label).
316
326
  */
317
327
  formatX?: ((x: X) => string) | undefined
@@ -370,7 +370,7 @@ export function seedTsconfigExtends(cwd: string): string | null {
370
370
  }
371
371
 
372
372
  const SEED_HINT = 'node_modules/basalt-ui/agent/templates/main.tpl'
373
- const ROUTER_PLUGIN_FIX =
373
+ export const ROUTER_PLUGIN_FIX =
374
374
  "Fix: `bun add -D @tanstack/router-plugin`, add `tanstackRouter({ target: 'react', autoCodeSplitting: true })` " +
375
375
  "from '@tanstack/router-plugin/vite' to `plugins` in vite.config.ts (before react()), then run vite once " +
376
376
  'to generate src/routeTree.gen.ts — or define the tree in code (`createRootRoute` + `createRoute`), drop the routeTree.gen import and pass the tree to createBasaltRouter.'
package/src/cli/init.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  * the managed-file manifest engine back from `./index`, this package's shared CLI helpers, and the
4
4
  * oxlint-preset plugin reader from `./sync` (also called there).
5
5
  */
6
- import { existsSync } from 'node:fs'
6
+ import { existsSync, readFileSync } from 'node:fs'
7
7
  import { resolve } from 'node:path'
8
8
 
9
9
  import { deriveSpacing } from '../tokens/core'
@@ -34,7 +34,8 @@ import {
34
34
  writeFileEnsuringDir,
35
35
  writeUnit,
36
36
  } from './index'
37
- import { seedTsconfigExtends } from './doctor-upgrade'
37
+ import { ROUTER_PLUGIN_FIX, seedTsconfigExtends } from './doctor-upgrade'
38
+ import { routerSeedDest } from './router-wiring'
38
39
  import { readOxlintPresetPlugins } from './sync'
39
40
 
40
41
  /**
@@ -57,6 +58,70 @@ const KEPT_FILE_COST: Record<string, string> = {
57
58
  'DESIGN.md': 'the design brief Claude reads is yours, not the seeded one.',
58
59
  }
59
60
 
61
+ /** One line at a time (string literals keep their inner spaces): trimmed, `;`, trailing `,` and `"` quotes undone. */
62
+ const normalise = (code: string): string =>
63
+ code
64
+ .split('\n')
65
+ .map((line) =>
66
+ line
67
+ .trim()
68
+ .replace(/[;,]$/, '')
69
+ .replace(/"([^"']*)"/g, "'$1'"),
70
+ )
71
+ .filter(Boolean)
72
+ .join('\n')
73
+
74
+ const viteTemplate = (css: boolean, app: string): string => `import { StrictMode } from 'react'
75
+ import { createRoot } from 'react-dom/client'
76
+ ${css ? "import './index.css'" : ''}
77
+ import App from '${app}'
78
+
79
+ createRoot(document.getElementById('root')!).render(
80
+ <StrictMode>
81
+ <App />
82
+ </StrictMode>,
83
+ )`
84
+
85
+ const STOCK_MAINS = [true, false].flatMap((css) =>
86
+ ['.tsx', ''].map((ext) => normalise(viteTemplate(css, './App' + ext))),
87
+ )
88
+
89
+ /** Whether `text` is create-vite's react-ts `main.tsx`, untouched (formatting aside): never an edited file. */
90
+ export const isStockViteMain = (text: string): boolean => STOCK_MAINS.includes(normalise(text))
91
+
92
+ const ALSO_REQUIRED_PEERS = ['motion']
93
+
94
+ /** The required peers of `.` (plus the ones `styles.css` imports) the app does not declare yet, with their ranges. */
95
+ function missingPeers(cwd: string, pkgRoot: string): Record<string, string> {
96
+ const shipped = JSON.parse(readFileSync(resolve(pkgRoot, 'package.json'), 'utf8')) as {
97
+ peerDependencies?: Record<string, string>
98
+ peerDependenciesMeta?: Record<string, { optional?: boolean }>
99
+ }
100
+ const app = JSON.parse(readFileSync(resolve(cwd, 'package.json'), 'utf8')) as Record<
101
+ string,
102
+ Record<string, string> | undefined
103
+ >
104
+ const declared = new Set(
105
+ ['dependencies', 'devDependencies', 'peerDependencies'].flatMap((k) =>
106
+ Object.keys(app[k] ?? {}),
107
+ ),
108
+ )
109
+ return Object.fromEntries(
110
+ Object.entries(shipped.peerDependencies ?? {}).filter(
111
+ ([name]) =>
112
+ !declared.has(name) &&
113
+ (shipped.peerDependenciesMeta?.[name]?.optional !== true ||
114
+ ALSO_REQUIRED_PEERS.includes(name)),
115
+ ),
116
+ )
117
+ }
118
+
119
+ const hasRouterPlugin = (cwd: string): boolean =>
120
+ ['vite.config.ts', 'vite.config.mts', 'vite.config.js', 'vite.config.mjs'].some((f) => {
121
+ const abs = resolve(cwd, f)
122
+ return existsSync(abs) && readFileSync(abs, 'utf8').includes('@tanstack/router-plugin')
123
+ })
124
+
60
125
  /** What happened to a kept `.oxlintrc.json`, by the merge result (null: `--no-merge-lint`). */
61
126
  function oxlintrcCost(merge: MergeLintResult | null): string {
62
127
  if (merge === 'added' || merge === 'already') {
@@ -149,6 +214,12 @@ export function init(cwd: string = process.cwd(), scaffoldFlags: ScaffoldFlags =
149
214
  )
150
215
  const files = managedFiles(placement, ctx.pkgRoot).filter((f) => !skippedSeeds.has(f.dest))
151
216
 
217
+ const mainDest = routerSeedDest(placement.appRel, 'main')
218
+ const mainPath = resolve(cwd, mainDest)
219
+ const stockMain =
220
+ !skippedSeeds.has(mainDest) &&
221
+ existsSync(mainPath) &&
222
+ isStockViteMain(readFileSync(mainPath, 'utf8'))
152
223
  const writtenFiles: string[] = []
153
224
  const keptFiles: string[] = []
154
225
  const missingSources: string[] = []
@@ -163,7 +234,7 @@ export function init(cwd: string = process.cwd(), scaffoldFlags: ScaffoldFlags =
163
234
  // Whole files (managed + seed) are skip-if-exists on init; a marker-spliced region always
164
235
  // inserts/updates itself inside its host file.
165
236
  const destExists = existsSync(resolve(cwd, file.dest))
166
- if (!file.markers && destExists) {
237
+ if (!file.markers && destExists && !(stockMain && file.dest === mainDest)) {
167
238
  // Already present — keep the consumer's copy untouched. Record the SHIPPED hash (normalized,
168
239
  // same ledger form `writeUnit` uses) so a later sync treats a pre-existing-but-different file
169
240
  // as locally drifted (skip unless --force), never silently clobbering a file the consumer
@@ -186,6 +257,28 @@ export function init(cwd: string = process.cwd(), scaffoldFlags: ScaffoldFlags =
186
257
  const mergeLint: MergeLintResult | null =
187
258
  scaffoldFlags.noMergeLint === true ? null : mergeOxlintExtends(cwd, ctx.vars.OXLINT_PRESET_PATH)
188
259
 
260
+ // The entry was seeded above or kept; either way the app still needs the peers it imports and the router plugin.
261
+ const keptUnwired =
262
+ keptFiles.includes(mainDest) && !/from ['"]basalt-ui['"/]/.test(readFileSync(mainPath, 'utf8'))
263
+ const advice: string[] = []
264
+ if (stockMain || keptUnwired) {
265
+ const missing = missingPeers(cwd, ctx.pkgRoot)
266
+ const count = Object.keys(missing).length
267
+ if (count > 0 && stockMain) {
268
+ patchPackageJson(cwd, (pkg) => {
269
+ pkg['dependencies'] = { ...(pkg['dependencies'] as Record<string, string>), ...missing }
270
+ return true
271
+ })
272
+ advice.push(
273
+ `added ${count} missing peers to package.json; run \`bun install\` (init does not).`,
274
+ )
275
+ } else if (count > 0) {
276
+ const specs = Object.entries(missing).map(([name, range]) => `${name}@${range}`)
277
+ advice.push(`missing peers: \`bun add ${specs.join(' ')}\`.`)
278
+ }
279
+ if (!hasRouterPlugin(cwd)) advice.push(ROUTER_PLUGIN_FIX.replace(/^Fix: /, 'router plugin: '))
280
+ }
281
+
189
282
  manifest.basaltVersion = ctx.vars.BASALT_VERSION
190
283
  manifest.spacingScale = { ...deriveSpacing(0).scale }
191
284
  writeFileEnsuringDir(resolve(cwd, MANIFEST_PATH), `${JSON.stringify(manifest, null, 2)}\n`)
@@ -194,6 +287,10 @@ export function init(cwd: string = process.cwd(), scaffoldFlags: ScaffoldFlags =
194
287
  `basalt-ui init: ${writtenFiles.length} written, ${keptFiles.length} kept, manifest at ${MANIFEST_PATH}`,
195
288
  )
196
289
  reportPrune(pruned)
290
+ if (stockMain) {
291
+ console.log(`basalt-ui init: seeded ${mainDest} (it was the unmodified Vite template).`)
292
+ }
293
+ for (const line of advice) console.log(`basalt-ui init: ${line}`)
197
294
  if (missingSources.length > 0) {
198
295
  console.log(
199
296
  `basalt-ui init: ${missingSources.length} shipped asset(s) not present, skipped: ${missingSources.join(', ')}`,