basalt-ui 2.28.0 → 2.29.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 (229) hide show
  1. package/CHANGELOG.md +461 -401
  2. package/MIGRATING.md +202 -12
  3. package/agent/skills/basalt-app/SKILL.md +3 -3
  4. package/agent/skills/basalt-charts/SKILL.md +1 -1
  5. package/agent/skills/basalt-design/SKILL.md +11 -5
  6. package/agent/skills/basalt-design/references/catalogue.md +3 -1
  7. package/agent/skills/basalt-design/references/recipes.md +1 -1
  8. package/agent/skills/basalt-design/references/states.md +1 -1
  9. package/configs/oxlint-plugin.js +2 -1
  10. package/configs/oxlint.json +1 -0
  11. package/dist/charts/ChartCard.d.ts +9 -5
  12. package/dist/charts/ChartCard.d.ts.map +1 -1
  13. package/dist/charts/ChartCard.js +68 -12
  14. package/dist/charts/Sparkline.d.ts +5 -0
  15. package/dist/charts/Sparkline.d.ts.map +1 -1
  16. package/dist/charts/Sparkline.js +53 -5
  17. package/dist/charts/chart-box.module.css +9 -2
  18. package/dist/charts/chart-card.module.css +16 -13
  19. package/dist/charts/chart-card.module.css.d.ts +2 -0
  20. package/dist/charts/compile.d.ts +1 -1
  21. package/dist/charts/compile.d.ts.map +1 -1
  22. package/dist/charts/compile.js +18 -9
  23. package/dist/charts/ref-label.d.ts +6 -0
  24. package/dist/charts/ref-label.d.ts.map +1 -1
  25. package/dist/charts/ref-label.js +19 -5
  26. package/dist/charts/sparkline.module.css +44 -0
  27. package/dist/charts/sparkline.module.css.d.ts +3 -0
  28. package/dist/charts/state.d.ts +1 -1
  29. package/dist/charts/state.d.ts.map +1 -1
  30. package/dist/charts/state.js +3 -3
  31. package/dist/cli/doctor-upgrade.d.ts +11 -0
  32. package/dist/cli/doctor-upgrade.d.ts.map +1 -1
  33. package/dist/cli/doctor-upgrade.js +54 -0
  34. package/dist/cli/doctor.d.ts.map +1 -1
  35. package/dist/cli/doctor.js +32 -0
  36. package/dist/cli/help.d.ts.map +1 -1
  37. package/dist/cli/help.js +8 -3
  38. package/dist/cli/index.d.ts +13 -13
  39. package/dist/cli/index.d.ts.map +1 -1
  40. package/dist/cli/index.js +36 -2
  41. package/dist/cli/init.d.ts +6 -0
  42. package/dist/cli/init.d.ts.map +1 -1
  43. package/dist/cli/init.js +118 -27
  44. package/dist/cli/router-wiring.d.ts +3 -0
  45. package/dist/cli/router-wiring.d.ts.map +1 -1
  46. package/dist/cli/router-wiring.js +2 -0
  47. package/dist/cli/shot/capture.d.ts +28 -1
  48. package/dist/cli/shot/capture.d.ts.map +1 -1
  49. package/dist/cli/shot/capture.js +77 -7
  50. package/dist/cli/shot/detect.d.ts +4 -1
  51. package/dist/cli/shot/detect.d.ts.map +1 -1
  52. package/dist/cli/shot/detect.js +38 -16
  53. package/dist/cli/shot/index.d.ts.map +1 -1
  54. package/dist/cli/shot/index.js +9 -2
  55. package/dist/cli/shot/measure.d.ts.map +1 -1
  56. package/dist/cli/shot/measure.js +11 -2
  57. package/dist/cli/shot/types.d.ts +4 -1
  58. package/dist/cli/shot/types.d.ts.map +1 -1
  59. package/dist/cli/sync.d.ts.map +1 -1
  60. package/dist/cli/sync.js +10 -2
  61. package/dist/common/could-not-load.d.ts +13 -0
  62. package/dist/common/could-not-load.d.ts.map +1 -0
  63. package/dist/common/could-not-load.js +14 -0
  64. package/dist/common/index.d.ts +1 -0
  65. package/dist/common/index.d.ts.map +1 -1
  66. package/dist/common/index.js +3 -0
  67. package/dist/common/props.d.ts +20 -0
  68. package/dist/common/props.d.ts.map +1 -1
  69. package/dist/common/props.js +13 -1
  70. package/dist/common/retry-button.module.css +7 -3
  71. package/dist/dashboard/bar-list.d.ts +4 -4
  72. package/dist/dashboard/bar-list.d.ts.map +1 -1
  73. package/dist/dashboard/bar-list.js +10 -7
  74. package/dist/dashboard/bar-list.module.css +21 -3
  75. package/dist/dashboard/board.d.ts +2 -2
  76. package/dist/dashboard/board.d.ts.map +1 -1
  77. package/dist/dashboard/board.js +31 -12
  78. package/dist/dashboard/board.module.css +19 -0
  79. package/dist/dashboard/board.module.css.d.ts +2 -0
  80. package/dist/dashboard/empty-state.d.ts +3 -3
  81. package/dist/dashboard/empty-state.d.ts.map +1 -1
  82. package/dist/dashboard/empty-state.js +4 -2
  83. package/dist/dashboard/event-list-model.d.ts +3 -0
  84. package/dist/dashboard/event-list-model.d.ts.map +1 -1
  85. package/dist/dashboard/event-list-model.js +5 -1
  86. package/dist/dashboard/event-list-rows.d.ts.map +1 -1
  87. package/dist/dashboard/event-list-rows.js +2 -6
  88. package/dist/dashboard/event-list-scroll.d.ts +32 -4
  89. package/dist/dashboard/event-list-scroll.d.ts.map +1 -1
  90. package/dist/dashboard/event-list-scroll.js +117 -4
  91. package/dist/dashboard/event-list-skeleton.d.ts.map +1 -1
  92. package/dist/dashboard/event-list-skeleton.js +2 -4
  93. package/dist/dashboard/event-list.d.ts +4 -4
  94. package/dist/dashboard/event-list.d.ts.map +1 -1
  95. package/dist/dashboard/event-list.js +53 -23
  96. package/dist/dashboard/event-list.module.css +90 -37
  97. package/dist/dashboard/event-list.module.css.d.ts +1 -0
  98. package/dist/dashboard/meter-model.d.ts +6 -3
  99. package/dist/dashboard/meter-model.d.ts.map +1 -1
  100. package/dist/dashboard/meter-model.js +9 -4
  101. package/dist/dashboard/meter-parts.d.ts +3 -0
  102. package/dist/dashboard/meter-parts.d.ts.map +1 -1
  103. package/dist/dashboard/meter-parts.js +32 -4
  104. package/dist/dashboard/meter.d.ts +3 -3
  105. package/dist/dashboard/meter.d.ts.map +1 -1
  106. package/dist/dashboard/meter.js +10 -2
  107. package/dist/dashboard/meter.module.css +18 -11
  108. package/dist/dashboard/meter.module.css.d.ts +0 -1
  109. package/dist/dashboard/page-summary.d.ts +3 -3
  110. package/dist/dashboard/page-summary.d.ts.map +1 -1
  111. package/dist/dashboard/page-summary.js +7 -2
  112. package/dist/dashboard/page-summary.module.css +5 -2
  113. package/dist/dashboard/query-state.d.ts +9 -8
  114. package/dist/dashboard/query-state.d.ts.map +1 -1
  115. package/dist/dashboard/query-state.js +28 -10
  116. package/dist/dashboard/section.d.ts +11 -3
  117. package/dist/dashboard/section.d.ts.map +1 -1
  118. package/dist/dashboard/section.js +34 -7
  119. package/dist/dashboard/settings-section.d.ts +4 -4
  120. package/dist/dashboard/settings-section.d.ts.map +1 -1
  121. package/dist/dashboard/settings-section.js +11 -7
  122. package/dist/dashboard/settings-section.module.css +6 -0
  123. package/dist/dashboard/settings-section.module.css.d.ts +1 -0
  124. package/dist/dashboard/stat-card.d.ts +3 -3
  125. package/dist/dashboard/stat-card.d.ts.map +1 -1
  126. package/dist/dashboard/stat-card.js +24 -8
  127. package/dist/dashboard/stat-card.module.css +11 -0
  128. package/dist/dashboard/stat-group.d.ts +2 -2
  129. package/dist/dashboard/stat-group.d.ts.map +1 -1
  130. package/dist/dashboard/stat-group.js +10 -3
  131. package/dist/dashboard/stat-strip.d.ts +5 -4
  132. package/dist/dashboard/stat-strip.d.ts.map +1 -1
  133. package/dist/dashboard/stat-strip.js +41 -31
  134. package/dist/dashboard/stat-strip.module.css +4 -5
  135. package/dist/dashboard/visual-slot.d.ts +4 -0
  136. package/dist/dashboard/visual-slot.d.ts.map +1 -1
  137. package/dist/dashboard/visual-slot.js +2 -0
  138. package/dist/dashboard/widget-header.d.ts +6 -6
  139. package/dist/dashboard/widget-header.d.ts.map +1 -1
  140. package/dist/dashboard/widget-header.js +4 -2
  141. package/dist/dashboard/widget-header.module.css +6 -25
  142. package/dist/format/shared.d.ts.map +1 -1
  143. package/dist/format/shared.js +24 -1
  144. package/dist/guard/index.d.ts +1 -1
  145. package/dist/guard/index.d.ts.map +1 -1
  146. package/dist/guard/index.js +2 -1
  147. package/dist/styles.css +23 -0
  148. package/dist/table/cell-kinds.d.ts +10 -7
  149. package/dist/table/cell-kinds.d.ts.map +1 -1
  150. package/dist/table/cell-kinds.js +18 -7
  151. package/dist/table/data-table-fold.d.ts +13 -5
  152. package/dist/table/data-table-fold.d.ts.map +1 -1
  153. package/dist/table/data-table-fold.js +48 -16
  154. package/dist/table/data-table.d.ts +2 -2
  155. package/dist/table/data-table.d.ts.map +1 -1
  156. package/dist/table/data-table.js +16 -9
  157. package/dist/table/data-table.module.css +74 -2
  158. package/dist/table/data-table.module.css.d.ts +4 -0
  159. package/dist/theme/controls.module.css +23 -2
  160. package/llms.txt +263 -2
  161. package/package.json +1 -1
  162. package/src/charts/ChartCard.tsx +98 -16
  163. package/src/charts/Sparkline.tsx +84 -5
  164. package/src/charts/chart-box.module.css +9 -2
  165. package/src/charts/chart-card.module.css +16 -13
  166. package/src/charts/chart-card.module.css.d.ts +2 -0
  167. package/src/charts/compile.ts +37 -15
  168. package/src/charts/ref-label.ts +36 -9
  169. package/src/charts/sparkline.module.css +44 -0
  170. package/src/charts/sparkline.module.css.d.ts +3 -0
  171. package/src/charts/state.tsx +4 -3
  172. package/src/cli/doctor-upgrade.ts +75 -0
  173. package/src/cli/doctor.ts +36 -0
  174. package/src/cli/help.ts +16 -6
  175. package/src/cli/index.ts +73 -67
  176. package/src/cli/init.ts +157 -36
  177. package/src/cli/router-wiring.ts +2 -2
  178. package/src/cli/shot/capture.ts +109 -10
  179. package/src/cli/shot/detect.ts +46 -22
  180. package/src/cli/shot/index.ts +8 -2
  181. package/src/cli/shot/measure.ts +11 -2
  182. package/src/cli/shot/types.ts +4 -1
  183. package/src/cli/sync.ts +12 -2
  184. package/src/common/could-not-load.ts +22 -0
  185. package/src/common/index.ts +1 -0
  186. package/src/common/props.ts +30 -0
  187. package/src/common/retry-button.module.css +7 -3
  188. package/src/dashboard/bar-list.module.css +21 -3
  189. package/src/dashboard/bar-list.tsx +46 -41
  190. package/src/dashboard/board.module.css +19 -0
  191. package/src/dashboard/board.module.css.d.ts +2 -0
  192. package/src/dashboard/board.tsx +69 -48
  193. package/src/dashboard/empty-state.tsx +5 -2
  194. package/src/dashboard/event-list-model.ts +13 -1
  195. package/src/dashboard/event-list-rows.tsx +3 -6
  196. package/src/dashboard/event-list-scroll.ts +154 -8
  197. package/src/dashboard/event-list-skeleton.tsx +5 -1
  198. package/src/dashboard/event-list.module.css +90 -37
  199. package/src/dashboard/event-list.module.css.d.ts +1 -0
  200. package/src/dashboard/event-list.tsx +92 -65
  201. package/src/dashboard/meter-model.ts +16 -7
  202. package/src/dashboard/meter-parts.tsx +45 -13
  203. package/src/dashboard/meter.module.css +18 -11
  204. package/src/dashboard/meter.module.css.d.ts +0 -1
  205. package/src/dashboard/meter.tsx +36 -18
  206. package/src/dashboard/page-summary.module.css +5 -2
  207. package/src/dashboard/page-summary.tsx +13 -6
  208. package/src/dashboard/query-state.tsx +54 -29
  209. package/src/dashboard/section.tsx +83 -41
  210. package/src/dashboard/settings-section.module.css +6 -0
  211. package/src/dashboard/settings-section.module.css.d.ts +1 -0
  212. package/src/dashboard/settings-section.tsx +11 -6
  213. package/src/dashboard/stat-card.module.css +11 -0
  214. package/src/dashboard/stat-card.tsx +31 -8
  215. package/src/dashboard/stat-group.tsx +22 -14
  216. package/src/dashboard/stat-strip.module.css +4 -5
  217. package/src/dashboard/stat-strip.tsx +29 -20
  218. package/src/dashboard/visual-slot.ts +5 -0
  219. package/src/dashboard/widget-header.module.css +6 -25
  220. package/src/dashboard/widget-header.tsx +8 -5
  221. package/src/format/shared.ts +30 -1
  222. package/src/guard/index.ts +5 -1
  223. package/src/styles.css +23 -0
  224. package/src/table/cell-kinds.tsx +42 -13
  225. package/src/table/data-table-fold.tsx +65 -12
  226. package/src/table/data-table.module.css +74 -2
  227. package/src/table/data-table.module.css.d.ts +4 -0
  228. package/src/table/data-table.tsx +34 -13
  229. package/src/theme/controls.module.css +23 -2
package/src/cli/doctor.ts CHANGED
@@ -41,8 +41,11 @@ import {
41
41
  appWiringCheck,
42
42
  shellDeclarationFindings,
43
43
  startWiringWarnings,
44
+ compareVersions,
44
45
  droppedSubpathsCheck,
45
46
  exactPeersCheck,
47
+ migratingSince,
48
+ staleEmittedSheets,
46
49
  oxlintFloorCheck,
47
50
  retiredLintRulesCheck,
48
51
  subpathPeersCheck,
@@ -101,6 +104,32 @@ function aiMajorsAt(dir: string): Partial<Record<AiMajorField, number>> {
101
104
  return out
102
105
  }
103
106
 
107
+ /** `doctor --from <version>`: the consumer-visible MIGRATING.md changes since `from`, up to the install. */
108
+ function doctorFrom(invocationCwd: string, from: string | undefined): number {
109
+ if (from === undefined || !/^\d+\.\d+\.\d+$/.test(from)) {
110
+ console.error('basalt-ui doctor --from <x.y.z>: the version you are upgrading from.')
111
+ return 1
112
+ }
113
+ const install = findBasaltInstall(resolveProjectDir(invocationCwd).dir)
114
+ const markdown = install.dir === null ? null : readIfExists(resolve(install.dir, 'MIGRATING.md'))
115
+ if (markdown === null) {
116
+ console.error('basalt-ui doctor --from: no installed basalt-ui. Fix: `bun add basalt-ui`.')
117
+ return 1
118
+ }
119
+ if (install.version !== null && compareVersions(from, install.version) > 0) {
120
+ console.error(`basalt-ui doctor --from ${from}: newer than the installed ${install.version}.`)
121
+ return 1
122
+ }
123
+ const lines = migratingSince(markdown, from, install.version)
124
+ const span = `after ${from} up to ${install.version ?? 'the install'}`
125
+ console.log(
126
+ lines.length === 0
127
+ ? `No consumer-visible changes recorded ${span}.`
128
+ : `Consumer-visible changes ${span} (full text: MIGRATING.md):\n${lines.join('\n')}`,
129
+ )
130
+ return 0
131
+ }
132
+
104
133
  /**
105
134
  * Check a consumer repo's basalt integration and print a pass/warn report. One directory, no
106
135
  * workspace walking (see {@link resolveProjectDir}). Checks, in print order:
@@ -129,6 +158,11 @@ export function doctor(
129
158
  designLoop: DesignLoopProbes = {},
130
159
  ): number {
131
160
  if (conflictingProfileFlags('doctor', flags)) return 1
161
+ const fromAt = flags.findIndex((f) => f === '--from' || f.startsWith('--from='))
162
+ if (fromAt !== -1) {
163
+ const flag = flags[fromAt] as string
164
+ return doctorFrom(invocationCwd, flag.startsWith('--from=') ? flag.slice(7) : flags[fromAt + 1])
165
+ }
132
166
  const project = resolveProjectDir(invocationCwd)
133
167
  // Inside the app package of a monorepo the manifest is above: read the install root instead.
134
168
  const aboveRoot = project.relocatedFrom === null ? installRootAbove(project.dir) : null
@@ -426,6 +460,8 @@ export function doctor(
426
460
  for (const line of shell.warnings) warn(line)
427
461
  }
428
462
 
463
+ for (const line of staleEmittedSheets(cwd, scannableFiles(cwd, cfg), install.version)) warn(line)
464
+
429
465
  // ── Design loop: advisory info lines (no warning count — they never change the verdict) ─────
430
466
  if (profile !== 'tokens-only') lines.push(...designLoopLines(cwd, resolveRoots(cfg), designLoop))
431
467
 
package/src/cli/help.ts CHANGED
@@ -18,6 +18,7 @@ export const COMMAND_OPTIONS: Record<
18
18
  > = {
19
19
  init: {
20
20
  'no-merge-lint': { type: 'boolean' },
21
+ 'no-install': { type: 'boolean' },
21
22
  },
22
23
  sync: {
23
24
  force: { type: 'boolean' },
@@ -31,7 +32,11 @@ export const COMMAND_OPTIONS: Record<
31
32
  'tokens-only': { type: 'boolean' },
32
33
  framework: { type: 'boolean' },
33
34
  },
34
- doctor: { 'tokens-only': { type: 'boolean' }, framework: { type: 'boolean' } },
35
+ doctor: {
36
+ 'tokens-only': { type: 'boolean' },
37
+ framework: { type: 'boolean' },
38
+ from: { type: 'string' },
39
+ },
35
40
  'guard-hook': {},
36
41
  'tokens:css': {
37
42
  out: { type: 'string' },
@@ -78,10 +83,10 @@ export function unknownFlag(cmd: string, flags: readonly string[]): string | nul
78
83
 
79
84
  /** The one usage string — printed by `basalt help` / `--help` / `-h` AND the unknown-command fallback. */
80
85
  export const USAGE =
81
- 'Usage: basalt-ui <--version | init [--no-merge-lint] |\n' +
86
+ 'Usage: basalt-ui <--version | init [--no-merge-lint] [--no-install] |\n' +
82
87
  ' sync [--force] [--check] [--verbose] [--tokens-only|--framework] |\n' +
83
88
  ' check-theme [--audit-allows] |\n' +
84
- ' doctor [--tokens-only|--framework] | guard-hook | tokens:css | fonts:css |\n' +
89
+ ' doctor [--tokens-only|--framework|--from <x.y.z>] | guard-hook | tokens:css | fonts:css |\n' +
85
90
  ' shot <route…> | shot detect | help>\n\n' +
86
91
  'check-theme [--tokens-only|--framework] [--audit-allows]\n' +
87
92
  ' --audit-allows reports instead of scanning: every `theme-allow` annotation and every\n' +
@@ -102,13 +107,15 @@ export const USAGE =
102
107
  ' Render routes in Chromium (Playwright from YOUR project: bun add -d playwright) and write\n' +
103
108
  ' board.html, metrics.json and png/* — every data-shot anchor × light/dark × desktop/mobile ×\n' +
104
109
  ' rest, hover, focus, tooltip, empty, loading, error. --dist serves a built SPA dir itself.\n' +
110
+ ' --out must resolve inside the project (the app dir in a monorepo, not the repo root); routes are\n' +
111
+ ' separate arguments (zsh does not word-split $ROUTES).\n' +
105
112
  ' Default --out .basalt/shots (emptied each run); .basalt/shots/last.json names the last out dir.\n' +
106
113
  ' A real, signed-in app: [--local-storage <key>=<@env:NAME|@file:path>]… seeds localStorage (app origin\n' +
107
114
  ' only) before any page script; [--api <prefix>=<origin>]… (with --dist) proxies GET/HEAD under that\n' +
108
115
  ' prefix to the origin (other methods get 405 unless --api-allow-writes); [--header <name>=@env:NAME]… is\n' +
109
116
  ' added to every proxied request, to EVERY --api origin (never on a navigation; https required);\n' +
110
117
  ' [--wait <ms|networkidle>] adds ms of settle AFTER networkidle (default none); [--auto-anchors] crops\n' +
111
- ' each Card, Paper and table over 120×60 px on a page with no data-shot. Values are never printed or\n' +
118
+ ' each Card, Paper and table over 120×60 px (else main, section, header, form) on a page with no data-shot. Values are never printed or\n' +
112
119
  ' written; a redirect, 401/403/404, 5xx or dead API fails every shot of that page. Shots of real data go to the\n' +
113
120
  ' reviewer subagent and so to its model provider: point --api at staging or synthetic data when the\n' +
114
121
  " app holds other people's data. Example:\n" +
@@ -127,10 +134,13 @@ export const USAGE =
127
134
  ' P2 noted, not failing: degraded: a lint warning, a contrast measured on an assumed white backdrop\n' +
128
135
  ' P3 noted, not failing: polish: an off-scale value within 1 px of a step\n' +
129
136
  ' score = 100 - (25 per P0 + 10 per P1 + 3 per P2 + 1 per P3), floored at 0. Each run appends\n' +
130
- ' {at, out, commit, counts, score} to .basalt/shots/history.json and prints the last 5 scores as a trend.\n' +
137
+ ' {at, out, commit, counts, score} to .basalt/shots/history.json and prints the last 5 scores of THAT --out dir as a trend\n' +
138
+ ' with the finding count beside each (the score floors at 0). No anchor measured: "nothing measured", no score.\n' +
139
+ ' detect takes --out <dir>, never a positional.\n' +
131
140
  ' A component can declare a rest anchor absent in a URL state with data-shot-absent="empty error": that\n' +
132
141
  ' cell is recorded `absent`, not `error`.\n\n' +
133
- 'doctor [--tokens-only|--framework]\n' +
142
+ 'doctor [--tokens-only|--framework] [--from <x.y.z>]\n' +
143
+ ' doctor --from <x.y.z> print the consumer-visible MIGRATING changes since that version\n' +
134
144
  ' Checks THIS project only: the manifest exists, the oxlint preset is wired, the pre-commit\n' +
135
145
  ' hook runs check-theme (via `lefthook dump`), and the ai package major is consistent within\n' +
136
146
  ' this package.json. Profile is DECLARED, same as check-theme — never inferred.\n\n' +
package/src/cli/index.ts CHANGED
@@ -176,15 +176,8 @@ export function readBasaltConfig(cwd: string): BasaltConfig {
176
176
  const SCANNABLE_EXT = /\.(?:tsx?|jsx|[cm][jt]s|astro|vue|css|html?|webmanifest)$/
177
177
 
178
178
  /**
179
- * Recursively collect scannable files under a root, skipping dependency/build dirs. Node+Bun-safe.
180
- * `checkSource` is already syntax-aware per extension (`guardSyntaxFor`); the walker was the only
181
- * gap, twice over — `.css` (CSS modules / `styles.css`) and now `.html`/`.webmanifest`.
182
- *
183
- * `.json` is deliberately NOT here even though the guard resolves it as markup: a consumer repo is
184
- * full of JSON that is configuration, fixtures and lockfiles, and blanket-scanning it produces
185
- * exactly the class of false positive already reported against a `data.json` test fixture. A JSON
186
- * that IS a design surface (a `manifest.json` rather than a `*.webmanifest`) is reachable by naming
187
- * it in `basalt.include`.
179
+ * Recursively collect scannable files under a root, skipping dependency/build dirs. `.json` is NOT
180
+ * scanned (config, fixtures, lockfiles: false positives); name a design-surface JSON in `basalt.include`.
188
181
  */
189
182
  function walkSourceFiles(dir: string, out: string[] = []): string[] {
190
183
  let entries: string[]
@@ -512,6 +505,9 @@ export function basaltBinCommand(install: BasaltInstall, cwd: string): string {
512
505
  return `${relativePosix(cwd, binDir).replace(/^\.\//, '')}/basalt-ui`
513
506
  }
514
507
 
508
+ /** Every basalt-written `oxlint .` carries it: config ignores don't stop oxlint loading a worktree's nested config (1.87). */
509
+ export const OXLINT_IGNORE_FLAG = "--ignore-pattern '.claude/worktrees/**'"
510
+
515
511
  /**
516
512
  * The consumer owns the CI gate when its Makefile has a `check:` target: `doctor` and `sync --check`
517
513
  * stay as steps of their own (drift is never skippable), then `make check` replaces the built-in
@@ -523,7 +519,7 @@ export function ciGateSteps(cwd: string): string {
523
519
  const steps = owned
524
520
  ? [...drift, '- run: make check']
525
521
  : [
526
- '- run: bunx oxlint .',
522
+ `- run: bunx oxlint ${OXLINT_IGNORE_FLAG} .`,
527
523
  drift[0],
528
524
  "- run: '{{BASALT_BIN}} check-theme'",
529
525
  drift[1],
@@ -676,11 +672,16 @@ export function importsAgentsMd(text: string): boolean {
676
672
  return text.split(/\r?\n/).some(isAgentsImportLine)
677
673
  }
678
674
 
675
+ /** Longest an install or first build `init` waits for. */
676
+ const RUN_TIMEOUT_MS = 5 * 60_000
677
+
679
678
  /** Scaffold options. `noMergeLint`: `--no-merge-lint` leaves an existing `.oxlintrc.json` untouched. */
680
679
  export type ScaffoldFlags = {
681
680
  noMergeLint?: boolean
682
681
  /** Shipped-source root; defaults to this package. Tests point it at a scratch package. */
683
682
  pkgRoot?: string
683
+ /** Runs a command in the app dir for `init` (install, first vite build); true on exit 0. Absent: `init` runs nothing and prints the command. */
684
+ run?: (argv: string[], cwd: string) => boolean
684
685
  }
685
686
 
686
687
  export { ROUTER_SEED_DESTS, START_PROVIDER_HINT, routerSeedDest, routerSeedDests }
@@ -1002,10 +1003,8 @@ export function managedFiles(
1002
1003
  }
1003
1004
  const scaffolds: ManagedFile[] = [navModule, rootRoute, mainEntry]
1004
1005
 
1005
- // lefthook.yml / .github/workflows/check.yml are repo-root-shaped: lefthook and GitHub Actions
1006
- // only ever read config at the repo root, so a package living in a subdirectory (a monorepo's
1007
- // `web/`) skips both rather than relocating them — the repo root very often already has its own
1008
- // lefthook/CI config, and writing over or beside it is worse than not writing at all.
1006
+ // lefthook and GitHub Actions only read config at the repo root: a package in a subdirectory skips
1007
+ // both (the root often has its own), and `sync` reports on the root's files instead.
1009
1008
  const rootTooling: ManagedFile[] = placement.isPackageRepoRoot ? [lefthook, ci] : []
1010
1009
 
1011
1010
  return [
@@ -1022,12 +1021,9 @@ export function managedFiles(
1022
1021
  }
1023
1022
 
1024
1023
  /**
1025
- * The PERMANENT placement skips as sentences — one text for `init` and `sync`, which carried two
1026
- * near-copies that had already drifted apart. Correct and unchanging, which is why `sync --check`
1027
- * hides them behind `--verbose`. `extends` alone is NOT the recipe for the hook, and saying only
1028
- * that shipped a broken one: lefthook merges the preset's commands but runs every one at the REPO
1029
- * ROOT, with no oxlint config, no local binary and no basalt config. `root:` moves the invocation
1030
- * cwd per command and merges (the preset does not define it) — see the preset's MONOREPO RECIPE.
1024
+ * The placement skips as sentences — one text for `init` and `sync`. `extends` alone is NOT the
1025
+ * recipe for the hook: lefthook runs every merged command at the REPO ROOT, where there is no oxlint
1026
+ * config, binary or basalt config. `root:` moves the cwd per command (the preset's MONOREPO RECIPE).
1031
1027
  */
1032
1028
  export function placementNotices(cwd: string, placement: PlacementFlags): string[] {
1033
1029
  const out: string[] = []
@@ -1052,6 +1048,29 @@ export function placementNotices(cwd: string, placement: PlacementFlags): string
1052
1048
  return out
1053
1049
  }
1054
1050
 
1051
+ /** The two repo-root templates vs the repo root's own files, read-only: 'in sync' | 'drifted' | 'absent'. */
1052
+ export function rootToolingStates(cwd: string, p: PlacementFlags, ctx: RenderContext): string[] {
1053
+ if (p.isPackageRepoRoot) return []
1054
+ const pkg = relativePosix(p.repoRoot, cwd).replace(/^\.\//, '')
1055
+ const preset = shippedAssetPath(findBasaltInstall(cwd), p.repoRoot, 'configs/lefthook.yml')
1056
+ const ci = fillTemplate(readSource(ctx.pkgRoot, 'configs/check.yml') ?? '', ctx.vars)
1057
+ const steps = ci
1058
+ .split('\n')
1059
+ .map((l) => l.trim())
1060
+ .filter((l) => l.startsWith('- run:'))
1061
+ const state = (file: string, ok: (text: string) => boolean): string => {
1062
+ const text = readIfExists(resolve(p.repoRoot, file))
1063
+ return text === null ? 'absent' : ok(text) ? 'in sync' : 'drifted'
1064
+ }
1065
+ return [
1066
+ state(
1067
+ 'lefthook.yml',
1068
+ (t) => t.includes(preset.replace(/^\.\//, '')) && t.split(`root: '${pkg}/'`).length > 3,
1069
+ ),
1070
+ state('.github/workflows/check.yml', (t) => steps.every((l) => t.includes(l))),
1071
+ ]
1072
+ }
1073
+
1055
1074
  export type Manifest = {
1056
1075
  version: 1
1057
1076
  /** The basalt-ui version that last wrote this manifest — `doctor`'s one reconciliation axis. */
@@ -1094,14 +1113,10 @@ export function readManifest(cwd: string): Manifest {
1094
1113
  }
1095
1114
 
1096
1115
  /**
1097
- * The managed NAMESPACES whose membership is derived, not fixed: `RULE_NAMES`, `SKILL_NAMES` and
1098
- * `AGENT_NAMES` decide which files `managedFiles()` places under them, so a rule, skill or agent that is RETIRED
1099
- * upstream leaves a file behind in every consumer that ever synced it — and Claude keeps loading it.
1100
- *
1101
- * Scoped to these patterns on purpose, and never applied to the manifest wholesale: several
1102
- * managed/seed entries are legitimately absent from `managedFiles()` for a run (`lefthook.yml` and
1103
- * `check.yml` when the package is not the repo root). Deleting a dest just because this run did not place it would
1104
- * remove a consumer's CI workflow on a monorepo.
1116
+ * The managed NAMESPACES whose membership is derived (`RULE_NAMES`, `SKILL_NAMES`, `AGENT_NAMES`): a
1117
+ * file RETIRED upstream stays behind in every consumer that synced it, and Claude keeps loading it.
1118
+ * Scoped to these patterns, never the whole manifest: `lefthook.yml` and `check.yml` are legitimately
1119
+ * absent from `managedFiles()` below the repo root, and deleting them would remove a consumer's CI.
1105
1120
  */
1106
1121
  const RETIREABLE_DEST_PATTERNS: readonly RegExp[] = [
1107
1122
  /^\.claude\/rules\/basalt-[a-z0-9-]+\.md$/,
@@ -1350,14 +1365,10 @@ export function patchPackageJson(
1350
1365
  }
1351
1366
 
1352
1367
  /**
1353
- * The source roots for THIS repo, inferred from its actual layout — the fix for the single most
1354
- * reported false-green: without `basalt.roots` a workspace repo scaffolds a `check-theme` that
1355
- * scans zero files and a CI `oxfmt 'src/**'` that matches nothing, while `doctor` reports green.
1356
- *
1357
- * A workspace repo resolves to the `src/` of every workspace package that depends on basalt or
1358
- * Mantine (a backend package's `src/` has nothing for a design guard to say); with no such package
1359
- * it falls back to every workspace `src/`, and a single-package repo to plain `src`. Empty when
1360
- * nothing plausible exists — `init` says so rather than writing a root that matches nothing.
1368
+ * The source roots for THIS repo, inferred from its layout (without `basalt.roots` a workspace repo
1369
+ * scaffolds a `check-theme` that scans zero files while `doctor` reports green). A workspace repo
1370
+ * resolves to the `src/` of every package depending on basalt or Mantine, else every workspace
1371
+ * `src/`; a single-package repo to `src`. Empty when nothing plausible exists.
1361
1372
  */
1362
1373
  function detectRoots(cwd: string): string[] {
1363
1374
  const workspacePackages = collectWorkspacePackages(cwd).packages.filter((pkg) => pkg.dir !== cwd)
@@ -1586,27 +1597,19 @@ export function mergeOxlintExtends(cwd: string, presetPath: string): MergeLintRe
1586
1597
  return 'added'
1587
1598
  }
1588
1599
 
1589
- // ──────────────────────────────────────────────────────────────────────────────
1590
- // workspace-glob primitives — shared by findBasaltInstall and reconcileRoots (`doctor` moved to
1591
- // its own file in C2 and no longer walks the workspace: ai-major-parity is scoped to one
1592
- // package.json, and project resolution is BASALT_CWD → cwd, nothing inferred).
1593
- // ──────────────────────────────────────────────────────────────────────────────
1600
+ // workspace-glob primitives — shared by findBasaltInstall and reconcileRoots
1594
1601
 
1595
1602
  /**
1596
- * Which shape of consumer a project-scoped command is looking at.
1597
- *
1598
- * `framework` — the Mantine app the scaffold is for. `tokens-only` — a consumer that took the
1599
- * `--vx-*` layer and nothing else (rollhook: no Mantine, no manifest, `tokens:css` output). Telling
1600
- * the second to "run `basalt-ui init`" is the wrong instruction: init scaffolds Mantine rules,
1601
- * skills and a DESIGN.md it will never read. DECLARED only (`--framework` / `--tokens-only`, or
1602
- * `"basalt": { "profile": "tokens-only" }`) — never inferred; see {@link declaredProfile}.
1603
+ * Which shape of consumer a command is looking at: `framework` (the Mantine app the scaffold is
1604
+ * for) or `tokens-only` (took the `--vx-*` layer and nothing else, so `init` is the wrong advice).
1605
+ * DECLARED only (`--framework` / `--tokens-only` / `basalt.profile`), never inferred; see
1606
+ * {@link declaredProfile}.
1603
1607
  */
1604
1608
  export type DoctorProfile = 'framework' | 'tokens-only'
1605
1609
 
1606
1610
  type WorkspacePackage = { readonly name: string; readonly dir: string }
1607
1611
 
1608
- /** {@link collectWorkspacePackages}'s return: the walked packages plus whether a `workspaces`
1609
- * field was present at all (distinguishes "nothing to compare" from "not a workspace root"). */
1612
+ /** {@link collectWorkspacePackages}'s return: the packages plus whether a `workspaces` field existed. */
1610
1613
  type WorkspaceWalk = {
1611
1614
  readonly packages: readonly WorkspacePackage[]
1612
1615
  readonly hasWorkspacesField: boolean
@@ -1666,14 +1669,9 @@ function expandPatternSegments(baseDir: string, segments: readonly string[]): st
1666
1669
  }
1667
1670
 
1668
1671
  /**
1669
- * Expands a root `package.json`'s `workspaces` patterns into concrete package directories.
1670
- * Supports literal segments, a single-wildcard segment, and a double-wildcard segment, both
1671
- * interior and trailing (e.g. `packages` followed by a double wildcard, or an interior single
1672
- * wildcard between two literal segments) — not just one trailing single-wildcard segment. A
1673
- * candidate directory that has no `package.json` of its own is skipped, not reported — an empty
1674
- * scaffold directory is not a workspace package. Also honours npm/bun/yarn `!`-prefixed exclusion
1675
- * entries (e.g. `["packages/*", "!packages/legacy"]`) — both the included and excluded patterns
1676
- * are expanded through the same machinery, then the excluded set is subtracted.
1672
+ * Expands a root `package.json`'s `workspaces` patterns into package directories: literal,
1673
+ * single-wildcard and double-wildcard segments (interior or trailing) and `!`-prefixed exclusions.
1674
+ * A directory without its own `package.json` is skipped.
1677
1675
  */
1678
1676
  function expandWorkspaceGlobs(cwd: string, patterns: readonly string[]): string[] {
1679
1677
  const expand = (pattern: string): string[] =>
@@ -1700,15 +1698,10 @@ function expandWorkspaceGlobs(cwd: string, patterns: readonly string[]): string[
1700
1698
  }
1701
1699
 
1702
1700
  /**
1703
- * Every workspace package declared by `cwd`'s root `package.json` (npm/bun/yarn `workspaces`
1704
- * field, array or `{ packages: [...] }` object form), named + directory-resolved — PLUS the root
1705
- * manifest itself, labelled `"{name} (root)"`. The root is walked because it commonly carries a
1706
- * hoisted `ai` dev dependency that can itself skew against a workspace package's own major — that
1707
- * is the producer/consumer shape the whole check exists to catch, and it is invisible if only the
1708
- * expanded workspace dirs are inspected. `hasWorkspacesField` is `false` (and `packages` empty)
1709
- * when `cwd` has no `package.json`, no `workspaces` field, or the field is a shape this doesn't
1710
- * recognize — a repo-wide walk is a bonus check, not something that should ever throw doctor over
1711
- * an unrecognized `workspaces` shape.
1701
+ * Every workspace package declared by `cwd`'s root `package.json` (array or `{ packages }` form),
1702
+ * PLUS the root manifest itself, labelled `"{name} (root)"` (it commonly carries a hoisted `ai`
1703
+ * dev dependency that can skew against a package's major). `hasWorkspacesField` is `false` when
1704
+ * there is no `package.json`, no `workspaces` field, or a shape this doesn't recognize; never throws.
1712
1705
  */
1713
1706
  function collectWorkspacePackages(cwd: string): WorkspaceWalk {
1714
1707
  const parsed = readPackageJson<{ workspaces?: unknown; name?: string }>(cwd)
@@ -1783,6 +1776,19 @@ export function run(argv: string[], cwd: string = process.cwd()): number | Promi
1783
1776
  case 'init':
1784
1777
  return init(cwd, {
1785
1778
  noMergeLint: flags.includes('--no-merge-lint'),
1779
+ // `--no-install` leaves `run` out: init writes the files and prints the commands (CI, offline).
1780
+ ...(flags.includes('--no-install')
1781
+ ? {}
1782
+ : {
1783
+ run: (argv: string[], dir: string) =>
1784
+ // A timeout kills the child and leaves `status` null, which reads as failure; `shell` resolves `bun.cmd`/`npx.cmd` on Windows.
1785
+ spawnSync(argv[0] ?? '', argv.slice(1), {
1786
+ cwd: dir,
1787
+ stdio: 'inherit',
1788
+ timeout: RUN_TIMEOUT_MS,
1789
+ shell: process.platform === 'win32',
1790
+ }).status === 0,
1791
+ }),
1786
1792
  })
1787
1793
  case 'sync':
1788
1794
  return sync(
package/src/cli/init.ts CHANGED
@@ -3,8 +3,8 @@
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, readFileSync } from 'node:fs'
7
- import { resolve } from 'node:path'
6
+ import { existsSync, readFileSync, writeFileSync } from 'node:fs'
7
+ import { dirname, resolve } from 'node:path'
8
8
 
9
9
  import { deriveSpacing } from '../tokens/core'
10
10
  import { shellConfigError } from './config'
@@ -19,6 +19,7 @@ import {
19
19
  managedFiles,
20
20
  mergeOxlintExtends,
21
21
  normalizeForLedger,
22
+ OXLINT_IGNORE_FLAG,
22
23
  patchPackageJson,
23
24
  placementNotices,
24
25
  pruneRetiredManagedFiles,
@@ -35,7 +36,14 @@ import {
35
36
  writeUnit,
36
37
  } from './index'
37
38
  import { ROUTER_PLUGIN_FIX, seedTsconfigExtends } from './doctor-upgrade'
38
- import { routerSeedDest } from './router-wiring'
39
+ import {
40
+ appEntry,
41
+ registersRouterPlugin,
42
+ routeTreeDirs,
43
+ routerSeedDest,
44
+ VITE_CONFIGS,
45
+ } from './router-wiring'
46
+ import { readPackageJson, tokenize } from './source-text'
39
47
  import { readOxlintPresetPlugins } from './sync'
40
48
 
41
49
  /**
@@ -91,36 +99,126 @@ export const isStockViteMain = (text: string): boolean => STOCK_MAINS.includes(n
91
99
 
92
100
  const ALSO_REQUIRED_PEERS = ['motion']
93
101
 
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> {
102
+ /** The required peers of `.` (plus the ones `styles.css` imports) with their ranges. */
103
+ function requiredPeers(pkgRoot: string): Record<string, string> {
96
104
  const shipped = JSON.parse(readFileSync(resolve(pkgRoot, 'package.json'), 'utf8')) as {
97
105
  peerDependencies?: Record<string, string>
98
106
  peerDependenciesMeta?: Record<string, { optional?: boolean }>
99
107
  }
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(
108
+ return Object.fromEntries(
109
+ Object.entries(shipped.peerDependencies ?? {}).filter(
110
+ ([name]) =>
111
+ shipped.peerDependenciesMeta?.[name]?.optional !== true ||
112
+ ALSO_REQUIRED_PEERS.includes(name),
113
+ ),
114
+ )
115
+ }
116
+
117
+ /** Every dependency name the app's package.json declares, in any dependency block. */
118
+ function declaredNames(cwd: string): Set<string> {
119
+ const app = (readPackageJson<Record<string, Record<string, string> | undefined>>(cwd) ??
120
+ {}) as Record<string, Record<string, string> | undefined>
121
+ return new Set(
105
122
  ['dependencies', 'devDependencies', 'peerDependencies'].flatMap((k) =>
106
123
  Object.keys(app[k] ?? {}),
107
124
  ),
108
125
  )
126
+ }
127
+
128
+ /** The required peers the app does not declare yet, with their ranges. */
129
+ function missingPeers(cwd: string, pkgRoot: string): Record<string, string> {
130
+ const declared = declaredNames(cwd)
109
131
  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
- ),
132
+ Object.entries(requiredPeers(pkgRoot)).filter(([name]) => !declared.has(name)),
116
133
  )
117
134
  }
118
135
 
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
- })
136
+ const ROUTER_PLUGIN_IMPORT = "import { tanstackRouter } from '@tanstack/router-plugin/vite'"
137
+
138
+ /**
139
+ * `@tanstack/router-plugin` is not released in lockstep with `@tanstack/react-router` (npm, 2026-10-23:
140
+ * plugin 1.168.48 latest against router 1.170.46), so no peer range fits; 1.168.40 is the version the
141
+ * playground runs and it exists on the registry.
142
+ */
143
+ export const ROUTER_PLUGIN_RANGE = '^1.168.40'
144
+
145
+ /** The vite config of the app at `dir`: its path and text; undefined when there is none. */
146
+ function viteConfigOf(dir: string): { file: string; text: string } | undefined {
147
+ const file = VITE_CONFIGS.map((f) => resolve(dir, f)).find((abs) => existsSync(abs))
148
+ return file === undefined ? undefined : { file, text: readFileSync(file, 'utf8') }
149
+ }
150
+
151
+ /** create-vite's config with the router plugin in front of `react()`; null for any other shape (not exactly one `plugins` array opening on `react(`). */
152
+ function withRouterPlugin(text: string): string | null {
153
+ if ((text.match(/\bplugins\s*:\s*\[/g) ?? []).length !== 1) return null
154
+ const wired = text.replace(
155
+ /(\bplugins\s*:\s*\[\s*)(react\()/,
156
+ "$1tanstackRouter({ target: 'react', autoCodeSplitting: true }), $2",
157
+ )
158
+ if (wired === text) return null
159
+ const imported =
160
+ /\bimport\s*(?:type\s*)?\{[^}]*\btanstackRouter\b[^}]*\}\s*from\s*['"]@tanstack\/router-plugin\/vite['"]/
161
+ return imported.test(tokenize(text).code) ? wired : `${ROUTER_PLUGIN_IMPORT}\n${wired}`
162
+ }
163
+
164
+ /** Whether `name` resolves from `dir`: a `node_modules/<name>` in it or any directory above. */
165
+ function isInstalled(dir: string, name: string): boolean {
166
+ for (let d = dir; ; d = dirname(d)) {
167
+ if (existsSync(resolve(d, 'node_modules', name, 'package.json'))) return true
168
+ if (dirname(d) === d) return false
169
+ }
170
+ }
171
+
172
+ /** The package manager the nearest lockfile (the app's directory or any above, like `isInstalled`) names, bun without one; its install and one-off-`vite` argv. */
173
+ function packageManager(dir: string): { install: string[]; vite: string[] } {
174
+ for (let d = dir; ; d = dirname(d)) {
175
+ const has = (f: string): boolean => existsSync(resolve(d, f))
176
+ if (has('pnpm-lock.yaml'))
177
+ return { install: ['pnpm', 'install'], vite: ['pnpm', 'exec', 'vite'] }
178
+ if (has('yarn.lock')) return { install: ['yarn', 'install'], vite: ['yarn', 'vite'] }
179
+ if (has('package-lock.json')) return { install: ['npm', 'install'], vite: ['npx', 'vite'] }
180
+ if (has('bun.lock') || has('bun.lockb') || dirname(d) === d)
181
+ return { install: ['bun', 'install'], vite: ['bunx', 'vite'] }
182
+ }
183
+ }
184
+
185
+ /**
186
+ * Decides what is left from the artifacts, not from this run: the plugin (or a basalt peer) declared
187
+ * in package.json but absent from node_modules, or the plugin registered with no `routeTree.gen.ts`
188
+ * on disk. Runs the install and the first `vite build` through `run` (the plugin writes the tree
189
+ * before the build can fail on anything else, so the file, not the exit code, is the answer) and
190
+ * says the one command for whatever stays pending, on every run until it is resolved.
191
+ */
192
+ function finishInstall(dir: string, pkgRoot: string, run: ScaffoldFlags['run']): string[] {
193
+ const plugin = registersRouterPlugin(viteConfigOf(dir)?.text ?? '')
194
+ const declared = declaredNames(dir)
195
+ const names = ['@tanstack/router-plugin', ...Object.keys(requiredPeers(pkgRoot))]
196
+ const needsInstall = names.some((n) => declared.has(n) && !isInstalled(dir, n))
197
+ const hasTree = () =>
198
+ !plugin ||
199
+ routeTreeDirs(appEntry(dir)).some((d) => existsSync(resolve(dir, d, 'routeTree.gen.ts')))
200
+ if (!needsInstall && hasTree()) return []
201
+ const pm = packageManager(dir)
202
+ const [install, build] = [pm.install.join(' '), [...pm.vite, 'build'].join(' ')]
203
+ const out: string[] = []
204
+ if (needsInstall) {
205
+ if (run?.(pm.install, dir) !== true) {
206
+ return [
207
+ `run \`${install}\` (init did not)${plugin ? `, then \`${build}\` once to generate routeTree.gen.ts` : ''}.`,
208
+ ]
209
+ }
210
+ out.push(`ran \`${install}\`.`)
211
+ }
212
+ if (!hasTree()) {
213
+ run?.([...pm.vite, 'build'], dir)
214
+ out.push(
215
+ hasTree()
216
+ ? `ran \`${build}\` (generated routeTree.gen.ts).`
217
+ : `run \`${build}\` once to generate routeTree.gen.ts (init did not).`,
218
+ )
219
+ }
220
+ return out
221
+ }
124
222
 
125
223
  /** What happened to a kept `.oxlintrc.json`, by the merge result (null: `--no-merge-lint`). */
126
224
  function oxlintrcCost(merge: MergeLintResult | null): string {
@@ -177,7 +275,7 @@ export function init(cwd: string = process.cwd(), scaffoldFlags: ScaffoldFlags =
177
275
  // `basalt-tokens.md` tells the consumer to wire `oxlint . && basalt-ui check-theme` into their
178
276
  // lint, and init's own closing message says to run check-theme next — but nothing ever added a
179
277
  // script, so the guard stayed manual for exactly as long as someone remembered it.
180
- const lintScript = `oxlint . && ${ctx.vars.BASALT_BIN} check-theme`
278
+ const lintScript = `oxlint ${OXLINT_IGNORE_FLAG} . && ${ctx.vars.BASALT_BIN} check-theme`
181
279
  const seededLintScript = patchPackageJson(cwd, (pkg) => {
182
280
  const scripts = (pkg['scripts'] ?? {}) as Record<string, unknown>
183
281
  if (scripts['lint:basalt'] !== undefined) return false
@@ -220,6 +318,36 @@ export function init(cwd: string = process.cwd(), scaffoldFlags: ScaffoldFlags =
220
318
  !skippedSeeds.has(mainDest) &&
221
319
  existsSync(mainPath) &&
222
320
  isStockViteMain(readFileSync(mainPath, 'utf8'))
321
+ const advice: string[] = []
322
+ const appDir = resolve(cwd, placement.appRel)
323
+ // Before main.tsx is seeded: a run killed in between leaves a stock main.tsx, so the next run
324
+ // finds the app unwired again and finishes (the artifact check in `finishInstall` covers the rest).
325
+ // package.json goes first, the vite config last: a declared-but-uninstalled plugin is found by that
326
+ // check, a wired config with nothing declared is never left behind.
327
+ if (stockMain) {
328
+ const missing = missingPeers(cwd, ctx.pkgRoot)
329
+ const count = Object.keys(missing).length
330
+ const vite = viteConfigOf(appDir)
331
+ const wired =
332
+ vite !== undefined && !registersRouterPlugin(vite.text) ? withRouterPlugin(vite.text) : null
333
+ patchPackageJson(cwd, (pkg) => {
334
+ pkg['dependencies'] = { ...(pkg['dependencies'] as Record<string, string>), ...missing }
335
+ if (wired !== null) {
336
+ pkg['devDependencies'] = {
337
+ '@tanstack/router-plugin': ROUTER_PLUGIN_RANGE,
338
+ ...(pkg['devDependencies'] as Record<string, string> | undefined),
339
+ }
340
+ }
341
+ return count > 0 || wired !== null
342
+ })
343
+ if (count > 0) advice.push(`added ${count} missing peers to package.json.`)
344
+ if (wired !== null && vite !== undefined) {
345
+ writeFileSync(vite.file, wired, 'utf8')
346
+ advice.push('wired the TanStack router plugin into vite.config (before react()).')
347
+ } else if (!registersRouterPlugin(vite?.text ?? '')) {
348
+ advice.push(ROUTER_PLUGIN_FIX.replace(/^Fix: /, 'router plugin: '))
349
+ }
350
+ }
223
351
  const writtenFiles: string[] = []
224
352
  const keptFiles: string[] = []
225
353
  const missingSources: string[] = []
@@ -257,27 +385,20 @@ export function init(cwd: string = process.cwd(), scaffoldFlags: ScaffoldFlags =
257
385
  const mergeLint: MergeLintResult | null =
258
386
  scaffoldFlags.noMergeLint === true ? null : mergeOxlintExtends(cwd, ctx.vars.OXLINT_PRESET_PATH)
259
387
 
260
- // The entry was seeded above or kept; either way the app still needs the peers it imports and the router plugin.
388
+ // The entry was kept (it is not the stock template): the app still needs the peers it imports and the router plugin.
261
389
  const keptUnwired =
262
390
  keptFiles.includes(mainDest) && !/from ['"]basalt-ui['"/]/.test(readFileSync(mainPath, 'utf8'))
263
- const advice: string[] = []
264
- if (stockMain || keptUnwired) {
391
+ if (keptUnwired) {
265
392
  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) {
393
+ if (Object.keys(missing).length > 0) {
276
394
  const specs = Object.entries(missing).map(([name, range]) => `${name}@${range}`)
277
395
  advice.push(`missing peers: \`bun add ${specs.join(' ')}\`.`)
278
396
  }
279
- if (!hasRouterPlugin(cwd)) advice.push(ROUTER_PLUGIN_FIX.replace(/^Fix: /, 'router plugin: '))
397
+ if (!registersRouterPlugin(viteConfigOf(appDir)?.text ?? '')) {
398
+ advice.push(ROUTER_PLUGIN_FIX.replace(/^Fix: /, 'router plugin: '))
399
+ }
280
400
  }
401
+ advice.push(...finishInstall(appDir, ctx.pkgRoot, scaffoldFlags.run))
281
402
 
282
403
  manifest.basaltVersion = ctx.vars.BASALT_VERSION
283
404
  manifest.spacingScale = { ...deriveSpacing(0).scale }