@astryxdesign/cli 0.6.5 → 0.6.6-canary.13d926e

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 (434) hide show
  1. package/CHANGELOG.md +87 -0
  2. package/README.md +58 -55
  3. package/api/build/_adapter.d.mts +55 -2
  4. package/api/build/_adapter.mjs +100 -10
  5. package/api/build/build.doc.mjs +2 -2
  6. package/api/build/build.test.mjs +111 -2
  7. package/api/build/build.type.d.mts +8 -0
  8. package/api/build/build.type.mjs +2 -0
  9. package/api/build/kit/kit.mjs +99 -22
  10. package/api/build/kit/rank.d.mts +32 -8
  11. package/api/build/kit/rank.mjs +291 -97
  12. package/api/build/kit/rank.test.mjs +231 -48
  13. package/api/build/kit/weights.d.mts +82 -0
  14. package/api/build/kit/weights.json +1 -0
  15. package/api/build/kit/weights.mjs +305 -0
  16. package/api/build/kit/weights.test.mjs +190 -0
  17. package/api/component/_adapter.d.mts +19 -0
  18. package/api/component/_adapter.mjs +33 -0
  19. package/api/component/component-replacement.test.mjs +603 -0
  20. package/api/component/component.mjs +49 -15
  21. package/api/component/component.test.mjs +32 -0
  22. package/api/component/component.type.d.mts +33 -3
  23. package/api/component/component.type.mjs +10 -3
  24. package/api/component/detail/blocks/blocks.d.mts +2 -1
  25. package/api/component/detail/blocks/blocks.mjs +5 -2
  26. package/api/component/detail/detail.mjs +5 -1
  27. package/api/component/detail/props/props.d.mts +2 -1
  28. package/api/component/detail/props/props.mjs +3 -2
  29. package/api/component/detail/showcase/showcase.d.mts +3 -1
  30. package/api/component/detail/showcase/showcase.mjs +3 -1
  31. package/api/component/detail/source/source.d.mts +3 -2
  32. package/api/component/detail/source/source.mjs +7 -3
  33. package/api/component/list/list.mjs +128 -10
  34. package/api/docs/_adapter.d.mts +11 -0
  35. package/api/docs/_adapter.mjs +25 -0
  36. package/api/docs/detail/detail.mjs +19 -3
  37. package/api/docs/detail/section/section.mjs +7 -1
  38. package/api/docs/docOverlays.test.mjs +10 -6
  39. package/api/docs/docs.d.mts +6 -0
  40. package/api/docs/docs.depth.test.mjs +134 -0
  41. package/api/docs/docs.doc.mjs +31 -2
  42. package/api/docs/docs.mjs +46 -1
  43. package/api/docs/docs.test.mjs +279 -0
  44. package/api/docs/docs.type.d.mts +81 -4
  45. package/api/docs/docs.type.mjs +41 -4
  46. package/api/docs/index/index.mjs +11 -2
  47. package/api/docs/index/index.test.mjs +7 -2
  48. package/api/docs/integration-tree.test.mjs +572 -0
  49. package/api/docs/integrationDocs.test.mjs +337 -0
  50. package/api/docs/node/node.d.mts +28 -3
  51. package/api/docs/node/node.mjs +149 -23
  52. package/api/doctor/_adapter.d.mts +43 -0
  53. package/api/doctor/_adapter.mjs +142 -0
  54. package/api/doctor/doctor.d.mts +0 -10
  55. package/api/doctor/doctor.doc.mjs +1 -3
  56. package/api/doctor/doctor.mjs +6 -123
  57. package/api/doctor/theme-checks.d.mts +12 -0
  58. package/api/doctor/theme-checks.mjs +1117 -0
  59. package/api/doctor/theme-checks.test.mjs +526 -0
  60. package/api/error.d.mts +22 -0
  61. package/api/error.mjs +42 -0
  62. package/api/gap-report/gap-report.d.mts +3 -1
  63. package/api/gap-report/gap-report.mjs +27 -3
  64. package/api/gap-report/gap-report.test.mjs +106 -0
  65. package/api/hook/_adapter.d.mts +1 -0
  66. package/api/hook/_adapter.mjs +3 -0
  67. package/api/hook/detail/detail.mjs +2 -2
  68. package/api/hook/detail/params/params.mjs +2 -2
  69. package/api/hook/hook.type.d.mts +12 -0
  70. package/api/hook/hook.type.mjs +3 -0
  71. package/api/hook/list/list.d.mts +1 -1
  72. package/api/hook/list/list.mjs +8 -8
  73. package/api/index.d.mts +1 -1
  74. package/api/index.mjs +4 -0
  75. package/api/init/run/run.d.mts +3 -5
  76. package/api/init/run/run.mjs +10 -11
  77. package/api/integration/__fixtures__/released-0.6.5-ocean.d.mts +14 -0
  78. package/api/integration/__fixtures__/released-0.6.5-ocean.mjs +15 -0
  79. package/api/integration/add-contribution.d.mts +2 -1
  80. package/api/integration/add-contribution.mjs +7 -3
  81. package/api/integration/add-contribution.test.mjs +3 -3
  82. package/api/integration/add-helpers.d.mts +26 -5
  83. package/api/integration/add-helpers.mjs +50 -5
  84. package/api/integration/add-theme.mjs +354 -28
  85. package/api/integration/add-theme.test.mjs +380 -16
  86. package/api/integration/authoring-checks.mjs +31 -8
  87. package/api/integration/authoring-checks.type.d.mts +8 -0
  88. package/api/integration/authoring-checks.type.mjs +7 -3
  89. package/api/integration/integration-authoring.type.d.mts +4 -1
  90. package/api/integration/integration-authoring.type.mjs +6 -1
  91. package/api/integration/integrationAdd.doc.mjs +6 -0
  92. package/api/integration/integrationAddTheme.doc.mjs +10 -0
  93. package/api/integration/integrationComponentConflicts.doc.mjs +6 -3
  94. package/api/integration/integrationDocConflicts.doc.mjs +1 -1
  95. package/api/integration/integrationTemplateConflicts.doc.mjs +1 -1
  96. package/api/integration/pack-check.component-replaces.test.mjs +126 -0
  97. package/api/integration/pack-check.d.mts +10 -0
  98. package/api/integration/pack-check.lifecycle-output.test.mjs +21 -2
  99. package/api/integration/pack-check.mjs +495 -4
  100. package/api/integration/pack-check.test.mjs +619 -10
  101. package/api/integration/validate-integration.d.mts +4 -2
  102. package/api/integration/validate-integration.mjs +7 -2
  103. package/api/integration/validate-integration.test.mjs +55 -0
  104. package/api/integration/validate-integration.type.d.mts +5 -0
  105. package/api/integration/validate-integration.type.mjs +5 -1
  106. package/api/integration/validateIntegration.doc.mjs +1 -1
  107. package/api/layout/expand/expand.mjs +12 -7
  108. package/api/layout/expand/expand.receipt.test.mjs +74 -0
  109. package/api/layout/layout.type.d.mts +1 -0
  110. package/api/layout/layout.type.mjs +1 -0
  111. package/api/layout/layoutExpand.doc.mjs +1 -1
  112. package/api/search/search.d.mts +39 -8
  113. package/api/search/search.doc.mjs +4 -4
  114. package/api/search/search.mjs +248 -66
  115. package/api/search/search.test.mjs +829 -0
  116. package/api/search/search.type.d.mts +6 -6
  117. package/api/search/search.type.mjs +5 -5
  118. package/api/swizzle/_adapter.d.mts +10 -0
  119. package/api/swizzle/_adapter.mjs +23 -0
  120. package/api/swizzle/copy/copy.d.mts +5 -6
  121. package/api/swizzle/copy/copy.mjs +95 -13
  122. package/api/swizzle/list/list.mjs +2 -2
  123. package/api/swizzle/swizzle.doc.mjs +4 -0
  124. package/api/swizzle/swizzle.test.mjs +55 -5
  125. package/api/swizzle/swizzle.type.d.mts +8 -0
  126. package/api/swizzle/swizzle.type.mjs +2 -0
  127. package/api/template/copy/copy.mjs +15 -8
  128. package/api/template/copy/copy.receipt.test.mjs +77 -0
  129. package/api/template/show/show.mjs +17 -4
  130. package/api/template/show/show.test.mjs +76 -0
  131. package/api/template/skeleton/skeleton.mjs +2 -1
  132. package/api/template/template-integration.test.mjs +14 -0
  133. package/api/template/template.d.mts +1 -1
  134. package/api/template/template.doc.mjs +6 -2
  135. package/api/template/template.mjs +2 -0
  136. package/api/template/template.type.d.mts +14 -0
  137. package/api/template/template.type.mjs +5 -0
  138. package/api/theme/_adapter.d.mts +106 -6
  139. package/api/theme/_adapter.mjs +687 -18
  140. package/api/theme/add/add.binary.test.mjs +76 -3
  141. package/api/theme/add/add.d.mts +5 -9
  142. package/api/theme/add/add.mjs +87 -64
  143. package/api/theme/add/add.rollback.test.mjs +9 -9
  144. package/api/theme/add/add.staging.test.mjs +9 -9
  145. package/api/theme/add/add.test.mjs +461 -55
  146. package/api/theme/add/add.types.test.mjs +151 -0
  147. package/api/theme/build/build.d.mts +50 -2
  148. package/api/theme/build/build.family.test.mjs +13 -4
  149. package/api/theme/build/build.icon-lineage.test.mjs +117 -0
  150. package/api/theme/build/build.icon-preservation.test.mjs +639 -0
  151. package/api/theme/build/build.mjs +463 -155
  152. package/api/theme/build/build.project-core.test.mjs +165 -0
  153. package/api/theme/build/build.test.mjs +220 -1
  154. package/api/theme/build/icon-imports.d.mts +47 -0
  155. package/api/theme/build/icon-imports.mjs +691 -0
  156. package/api/theme/eject/eject.binary.test.mjs +90 -0
  157. package/api/theme/eject/eject.d.mts +17 -0
  158. package/api/theme/eject/eject.mjs +65 -0
  159. package/api/theme/eject/eject.rollback.test.mjs +158 -0
  160. package/api/theme/eject/eject.staging.test.mjs +83 -0
  161. package/api/theme/eject/eject.test.mjs +160 -0
  162. package/api/theme/integration-themes.test.mjs +30 -6
  163. package/api/theme/list/list.d.mts +10 -0
  164. package/api/theme/list/list.mjs +75 -7
  165. package/api/theme/list/list.test.mjs +155 -4
  166. package/api/theme/remove/remove.d.mts +12 -0
  167. package/api/theme/remove/remove.mjs +15 -0
  168. package/api/theme/remove/remove.test.mjs +94 -0
  169. package/api/theme/template/template.mjs +3 -4
  170. package/api/theme/theme.d.mts +5 -2
  171. package/api/theme/theme.mjs +13 -8
  172. package/api/theme/theme.type.d.mts +106 -2
  173. package/api/theme/theme.type.mjs +54 -5
  174. package/api/theme/themeAdd.doc.d.mts +1 -3
  175. package/api/theme/themeAdd.doc.mjs +35 -22
  176. package/api/theme/themeBuild.doc.d.mts +4 -1
  177. package/api/theme/themeBuild.doc.mjs +15 -4
  178. package/api/theme/themeEject.doc.d.mts +8 -0
  179. package/api/theme/themeEject.doc.mjs +89 -0
  180. package/api/theme/themeListAvailable.doc.mjs +4 -4
  181. package/api/theme/themeListCopySources.doc.d.mts +8 -0
  182. package/api/theme/themeListCopySources.doc.mjs +60 -0
  183. package/api/theme/themeRemove.doc.d.mts +6 -0
  184. package/api/theme/themeRemove.doc.mjs +50 -0
  185. package/api/theme/themeTemplate.doc.mjs +4 -3
  186. package/api/theme/themeUse.doc.d.mts +6 -0
  187. package/api/theme/themeUse.doc.mjs +47 -0
  188. package/api/theme/use/use.d.mts +12 -0
  189. package/api/theme/use/use.mjs +15 -0
  190. package/api/theme/use/use.test.mjs +98 -0
  191. package/api/upgrade/_adapter.d.mts +1 -0
  192. package/api/upgrade/_adapter.mjs +3 -0
  193. package/api/upgrade/list/list.mjs +9 -3
  194. package/api/upgrade/run/run.mjs +20 -3
  195. package/api/upgrade/run/run.test.mjs +45 -1
  196. package/api/upgrade/upgrade.doc.mjs +1 -1
  197. package/api/upgrade/upgrade.type.d.mts +5 -0
  198. package/api/upgrade/upgrade.type.mjs +2 -0
  199. package/assets/codemods/integration-discovery.mjs +1 -1
  200. package/assets/codemods/integration-discovery.test.mjs +64 -0
  201. package/assets/codemods/transforms/next/__tests__/migrate-copied-themes-to-descriptors.test.mjs +129 -0
  202. package/assets/codemods/transforms/next/index.mjs +14 -1
  203. package/assets/codemods/transforms/next/migrate-copied-themes-to-descriptors.mjs +54 -0
  204. package/assets/docs/author-a-theme.doc.mjs +161 -0
  205. package/assets/docs/getting-started.doc.mjs +59 -15
  206. package/assets/docs/icons.doc.mjs +1 -0
  207. package/assets/docs/principles.doc.dense.mjs +2 -2
  208. package/assets/docs/principles.doc.mjs +2 -2
  209. package/assets/docs/principles.doc.zh.mjs +2 -2
  210. package/assets/docs/styling-libraries.doc.mjs +1 -1
  211. package/assets/docs/styling-overview.doc.mjs +211 -0
  212. package/assets/docs/styling.doc.mjs +2 -2
  213. package/assets/docs/theme.doc.dense.mjs +10 -198
  214. package/assets/docs/theme.doc.mjs +13 -770
  215. package/assets/docs/theme.doc.zh.mjs +31 -12
  216. package/assets/docs/tokens.doc.mjs +4 -4
  217. package/assets/docs/tree/add-a-theme.doc.mjs +6 -2
  218. package/assets/docs/tree/add-a-topic.doc.mjs +1 -1
  219. package/assets/docs/tree/check-your-docs.doc.mjs +2 -2
  220. package/assets/docs/tree/checks.doc.mjs +6 -5
  221. package/assets/docs/tree/debug-and-gap-reports.doc.mjs +1 -1
  222. package/assets/docs/tree/define-the-theme.doc.mjs +2 -2
  223. package/assets/docs/tree/document-the-theme.doc.mjs +4 -4
  224. package/assets/docs/tree/fonts-and-assets.doc.mjs +25 -20
  225. package/assets/docs/tree/headers-and-footers.doc.mjs +68 -0
  226. package/assets/docs/tree/layout-spacing.doc.mjs +168 -0
  227. package/assets/docs/tree/layout.doc.mjs +32 -0
  228. package/assets/docs/tree/replace-a-core-component.doc.mjs +21 -4
  229. package/assets/docs/tree/responsive.doc.mjs +102 -0
  230. package/assets/docs/tree/scaffold.doc.mjs +145 -0
  231. package/assets/docs/tree/sections-and-placement.doc.mjs +1 -1
  232. package/assets/docs/tree/side-panels.doc.mjs +82 -0
  233. package/assets/docs/tree/structure.doc.mjs +144 -0
  234. package/assets/docs/tree/template-doc-overview.doc.mjs +13 -1
  235. package/assets/docs/tree/themes.doc.mjs +2 -2
  236. package/assets/docs/tree/troubleshooting.doc.mjs +13 -5
  237. package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +22 -5
  238. package/assets/docs/tree/versioning.doc.mjs +11 -7
  239. package/assets/docs/use-a-theme.doc.mjs +209 -0
  240. package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupShowcase.doc.mjs +15 -0
  241. package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupShowcase.tsx +38 -0
  242. package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupWithSelectable.doc.mjs +20 -0
  243. package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupWithSelectable.tsx +48 -0
  244. package/assets/templates/pages/ai-chat/template.doc.mjs +16 -1
  245. package/assets/templates/pages/ai-chat-landing/template.doc.mjs +9 -1
  246. package/assets/templates/pages/blank/template.doc.mjs +3 -1
  247. package/assets/templates/pages/canvas-editor/template.doc.mjs +9 -1
  248. package/assets/templates/pages/centered-hero/template.doc.mjs +3 -1
  249. package/assets/templates/pages/checkout-wizard/template.doc.mjs +1 -0
  250. package/assets/templates/pages/classic-gallery/template.doc.mjs +3 -1
  251. package/assets/templates/pages/contact-form/template.doc.mjs +16 -1
  252. package/assets/templates/pages/dashboard/template.doc.mjs +15 -1
  253. package/assets/templates/pages/dashboard-alert-rail/template.doc.mjs +23 -1
  254. package/assets/templates/pages/dashboard-cohort-funnel/template.doc.mjs +10 -1
  255. package/assets/templates/pages/dashboard-comparison/template.doc.mjs +9 -1
  256. package/assets/templates/pages/dashboard-composition/template.doc.mjs +10 -1
  257. package/assets/templates/pages/dashboard-progress/template.doc.mjs +17 -1
  258. package/assets/templates/pages/dashboard-scorecard/template.doc.mjs +2 -1
  259. package/assets/templates/pages/detail-page/template.doc.mjs +8 -0
  260. package/assets/templates/pages/documentation/template.doc.mjs +10 -1
  261. package/assets/templates/pages/documentation-design/template.doc.mjs +10 -1
  262. package/assets/templates/pages/documentation-technical/template.doc.mjs +10 -1
  263. package/assets/templates/pages/editor/template.doc.mjs +9 -1
  264. package/assets/templates/pages/file-explorer/template.doc.mjs +3 -1
  265. package/assets/templates/pages/form-two-column/template.doc.mjs +17 -1
  266. package/assets/templates/pages/form-wizard/template.doc.mjs +14 -1
  267. package/assets/templates/pages/form-wizard-dialog/template.doc.mjs +1 -0
  268. package/assets/templates/pages/gallery-hero/template.doc.mjs +10 -1
  269. package/assets/templates/pages/ide/template.doc.mjs +9 -1
  270. package/assets/templates/pages/incident-console/template.doc.mjs +10 -1
  271. package/assets/templates/pages/kanban-board/template.doc.mjs +11 -1
  272. package/assets/templates/pages/library/template.doc.mjs +15 -1
  273. package/assets/templates/pages/login/template.doc.mjs +10 -1
  274. package/assets/templates/pages/login-card/template.doc.mjs +11 -1
  275. package/assets/templates/pages/login-split/template.doc.mjs +10 -1
  276. package/assets/templates/pages/login-sso/template.doc.mjs +10 -1
  277. package/assets/templates/pages/messaging-shell/template.doc.mjs +11 -1
  278. package/assets/templates/pages/mixed-gallery/template.doc.mjs +10 -1
  279. package/assets/templates/pages/payment-form/template.doc.mjs +3 -1
  280. package/assets/templates/pages/product-detail/template.doc.mjs +9 -1
  281. package/assets/templates/pages/product-gallery/template.doc.mjs +10 -1
  282. package/assets/templates/pages/settings/template.doc.mjs +3 -1
  283. package/assets/templates/pages/settings-dialog/template.doc.mjs +9 -1
  284. package/assets/templates/pages/settings-sidebar/template.doc.mjs +9 -1
  285. package/assets/templates/pages/shell-nav/template.doc.mjs +10 -1
  286. package/assets/templates/pages/shell-side-nav/template.doc.mjs +14 -1
  287. package/assets/templates/pages/shell-top-nav/template.doc.mjs +11 -1
  288. package/assets/templates/pages/side-gallery/template.doc.mjs +3 -1
  289. package/assets/templates/pages/table/template.doc.mjs +11 -1
  290. package/assets/templates/pages/table-collapsible/page.tsx +1474 -0
  291. package/assets/templates/pages/table-collapsible/template.doc.mjs +12 -0
  292. package/assets/templates/pages/table-comparison/page.tsx +1449 -0
  293. package/assets/templates/pages/table-comparison/template.doc.mjs +12 -0
  294. package/assets/templates/pages/table-filter/template.doc.mjs +21 -1
  295. package/assets/templates/pages/table-grouped/template.doc.mjs +15 -1
  296. package/assets/templates/pages/table-inbox/template.doc.mjs +18 -6
  297. package/assets/templates/pages/table-page/template.doc.mjs +20 -1
  298. package/assets/templates/pages/table-tree/template.doc.mjs +14 -1
  299. package/assets/templates/pages/theme-showcase/template.doc.mjs +10 -1
  300. package/assets/templates/pages/work-item-detail/template.doc.mjs +10 -0
  301. package/assets/templates/themes/butter/icons.tsx +2 -0
  302. package/assets/templates/themes/chocolate/icons.tsx +2 -0
  303. package/assets/templates/themes/gothic/icons.tsx +2 -0
  304. package/assets/templates/themes/matcha/icons.tsx +2 -0
  305. package/assets/templates/themes/neutral/icons.tsx +2 -0
  306. package/assets/templates/themes/stone/icons.tsx +2 -0
  307. package/assets/templates/themes/y2k/icons.tsx +2 -0
  308. package/authoring/doctypes/command/command.doc.mjs +5 -0
  309. package/authoring/doctypes/command/type.ts +2 -0
  310. package/authoring/doctypes/component/component.doc.mjs +1 -1
  311. package/authoring/doctypes/component/type.ts +8 -4
  312. package/authoring/doctypes/template/parse.d.mts +2 -0
  313. package/authoring/doctypes/template/parse.mjs +1 -0
  314. package/authoring/doctypes/template/parse.test.mjs +21 -0
  315. package/authoring/doctypes/template/template.doc.mjs +6 -0
  316. package/authoring/doctypes/template/type.ts +10 -0
  317. package/authoring/integration/integration.doc.mjs +1 -1
  318. package/clients/cli/commands/build-theme.mjs +279 -30
  319. package/clients/cli/commands/build.mjs +7 -6
  320. package/clients/cli/commands/build.text-fields.test.mjs +1 -1
  321. package/clients/cli/commands/component/index.mjs +88 -12
  322. package/clients/cli/commands/component-replacement.text.test.mjs +271 -0
  323. package/clients/cli/commands/component.doc.mjs +9 -2
  324. package/clients/cli/commands/discover.mjs +29 -1
  325. package/clients/cli/commands/discover.no-source.test.mjs +75 -0
  326. package/clients/cli/commands/docs.depth.test.mjs +219 -0
  327. package/clients/cli/commands/docs.doc.mjs +15 -2
  328. package/clients/cli/commands/docs.mjs +273 -16
  329. package/clients/cli/commands/docs.test.mjs +382 -0
  330. package/clients/cli/commands/doctor-integration-components.doc.mjs +15 -4
  331. package/clients/cli/commands/doctor.doc.mjs +1 -1
  332. package/clients/cli/commands/doctor.mjs +4 -4
  333. package/clients/cli/commands/doctor.test.mjs +9 -51
  334. package/clients/cli/commands/gap-report.doc.mjs +2 -2
  335. package/clients/cli/commands/gap-report.mjs +12 -0
  336. package/clients/cli/commands/gap-report.test.mjs +63 -0
  337. package/clients/cli/commands/hook/index.mjs +7 -2
  338. package/clients/cli/commands/import-hint-correctness.test.mjs +5 -5
  339. package/clients/cli/commands/init.next-steps.test.mjs +18 -23
  340. package/clients/cli/commands/integration-add.doc.mjs +10 -0
  341. package/clients/cli/commands/integration-authoring.test.mjs +12 -2
  342. package/clients/cli/commands/integration-real-world.test.mjs +61 -12
  343. package/clients/cli/commands/integration.mjs +3 -1
  344. package/clients/cli/commands/layout-check.doc.mjs +1 -0
  345. package/clients/cli/commands/layout-expand.doc.mjs +4 -1
  346. package/clients/cli/commands/layout-grammar.doc.mjs +1 -0
  347. package/clients/cli/commands/layout.doc.mjs +1 -0
  348. package/clients/cli/commands/layout.expand-receipt.test.mjs +94 -0
  349. package/clients/cli/commands/layout.mjs +61 -4
  350. package/clients/cli/commands/no-prompt-wording.test.mjs +4 -4
  351. package/clients/cli/commands/search.doc.mjs +5 -4
  352. package/clients/cli/commands/search.mjs +30 -6
  353. package/clients/cli/commands/search.test.mjs +63 -17
  354. package/clients/cli/commands/swizzle.doc.mjs +12 -3
  355. package/clients/cli/commands/swizzle.mjs +2 -1
  356. package/clients/cli/commands/template.copy-receipt.test.mjs +60 -0
  357. package/clients/cli/commands/template.mjs +70 -6
  358. package/clients/cli/commands/template.show-media.test.mjs +62 -0
  359. package/clients/cli/commands/text-json-parity.test.mjs +40 -0
  360. package/clients/cli/commands/theme-add-lifecycle.test.mjs +132 -0
  361. package/clients/cli/commands/theme-add.doc.mjs +19 -19
  362. package/clients/cli/commands/theme-eject.doc.mjs +47 -0
  363. package/clients/cli/commands/theme-list.behavior.test.mjs +44 -0
  364. package/clients/cli/commands/theme-list.doc.mjs +2 -2
  365. package/clients/cli/commands/theme-palette-generate.doc.mjs +1 -2
  366. package/clients/cli/commands/theme-remove.doc.mjs +22 -0
  367. package/clients/cli/commands/theme-template.doc.mjs +4 -3
  368. package/clients/cli/commands/theme-use.doc.mjs +22 -0
  369. package/clients/cli/commands/theme.doc.mjs +21 -16
  370. package/clients/cli/commands/upgrade.ascii-output.test.mjs +14 -0
  371. package/clients/cli/commands/upgrade.mjs +1 -1
  372. package/clients/cli/commands/write-failure.test.mjs +175 -0
  373. package/clients/cli/index.mjs +4 -1
  374. package/clients/cli/lib/component-format.mjs +19 -2
  375. package/clients/cli/lib/manifest.mjs +44 -165
  376. package/clients/cli/lib/manifest.test.mjs +98 -7
  377. package/clients/cli/lib/resolve-theme.mjs +80 -78
  378. package/clients/cli/lib/resolve-theme.test.mjs +523 -27
  379. package/foundation/agent-docs/agent-docs.mjs +31 -28
  380. package/foundation/agent-docs/agent-docs.test.mjs +1163 -0
  381. package/foundation/agent-docs/app-theme-workflow.test.mjs +13 -0
  382. package/foundation/config/project.d.mts +20 -5
  383. package/foundation/config/project.mjs +43 -6
  384. package/foundation/config/theme-private-vars.d.mts +12 -0
  385. package/foundation/config/theme-private-vars.mjs +107 -0
  386. package/foundation/config/theme-private-vars.test.mjs +55 -0
  387. package/foundation/config/theme-state.d.mts +145 -0
  388. package/foundation/config/theme-state.mjs +417 -0
  389. package/foundation/config/theme-state.test.mjs +182 -0
  390. package/foundation/discovery/component-discovery.d.mts +5 -2
  391. package/foundation/discovery/component-discovery.mjs +12 -6
  392. package/foundation/discovery/component-replacement.d.mts +91 -0
  393. package/foundation/discovery/component-replacement.mjs +417 -0
  394. package/foundation/discovery/component-replacement.test.mjs +480 -0
  395. package/foundation/discovery/docs-output-budget.d.mts +6 -2
  396. package/foundation/discovery/docs-output-budget.mjs +2 -1
  397. package/foundation/discovery/docs-section-key.d.mts +4 -2
  398. package/foundation/discovery/docs-section-key.mjs +1 -1
  399. package/foundation/discovery/module-exports.d.mts +10 -0
  400. package/foundation/discovery/module-exports.mjs +146 -0
  401. package/foundation/discovery/package-exports.d.mts +29 -0
  402. package/foundation/discovery/package-exports.mjs +200 -0
  403. package/foundation/discovery/template-adapter.d.mts +14 -0
  404. package/foundation/discovery/template-adapter.fixture-refs.test.mjs +37 -1
  405. package/foundation/discovery/template-adapter.mjs +21 -1
  406. package/foundation/discovery/theme-discovery.d.mts +78 -5
  407. package/foundation/discovery/theme-discovery.mjs +143 -18
  408. package/foundation/discovery/theme-discovery.test.mjs +9 -3
  409. package/foundation/discovery/theme-imports.d.mts +15 -0
  410. package/foundation/discovery/theme-imports.mjs +217 -0
  411. package/foundation/discovery/theme-imports.test.mjs +173 -0
  412. package/foundation/doc-compiler/doc-loads.test.mjs +18 -8
  413. package/foundation/doc-compiler/inputs.mjs +2 -1
  414. package/foundation/doc-compiler/inputs.test.mjs +0 -1
  415. package/foundation/doc-compiler/lenses.d.mts +4 -2
  416. package/foundation/doc-compiler/lenses.mjs +1 -1
  417. package/foundation/doc-compiler/tree.test.mjs +649 -0
  418. package/foundation/fs/module-loader.d.mts +9 -0
  419. package/foundation/fs/module-loader.mjs +71 -2
  420. package/foundation/integrations/cli-requirement.d.mts +79 -13
  421. package/foundation/integrations/cli-requirement.mjs +115 -22
  422. package/foundation/integrations/cli-requirement.test.mjs +205 -8
  423. package/foundation/integrations/contribution-inventory.mjs +3 -3
  424. package/foundation/response/base.d.ts +9 -3
  425. package/foundation/response/json.d.mts +7 -4
  426. package/foundation/response/json.mjs +10 -6
  427. package/foundation/response/response-types.doc.d.mts +5 -5
  428. package/foundation/response/response-types.doc.mjs +50 -35
  429. package/foundation/response/response.doc.mjs +18 -4
  430. package/foundation/text/copyright-header.mjs +1 -1
  431. package/foundation/text/copyright-header.test.mjs +1 -1
  432. package/package.json +9 -9
  433. package/assets/docs/layout.doc.dense.mjs +0 -388
  434. package/assets/docs/layout.doc.mjs +0 -550
@@ -0,0 +1,1117 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file Positive-evidence checks for the app theme record.
5
+ *
6
+ * Each AST-050 check has its own stable result. Missing app-theme state is
7
+ * informational. A check passes only after its specific evidence is read.
8
+ */
9
+
10
+ import * as path from 'node:path';
11
+ import {parse} from '@babel/parser';
12
+ import postcss from 'postcss';
13
+ import {
14
+ collectUnloadedFonts,
15
+ discoverDoctorThemes,
16
+ discoverDoctorUnmigratedCopies,
17
+ findDoctorCoreDir,
18
+ findDoctorInstalledPackage,
19
+ isLocalThemeOwner,
20
+ listProjectSourceFiles,
21
+ planThemeAppWrite,
22
+ readPackageJson,
23
+ readTextFile,
24
+ readTextFileIfExists,
25
+ readThemeState,
26
+ resolveDoctorThemeImports,
27
+ resolveRecordedTheme,
28
+ resolveThemeModule,
29
+ SOURCE_EXTENSIONS,
30
+ themeBuild,
31
+ themeRecordOwner,
32
+ validateThemePrivateInputs,
33
+ } from './_adapter.mjs';
34
+ import {getCliInvocation} from '../../foundation/env/package-manager.mjs';
35
+ import {satisfiesRange} from '../../foundation/env/semver.mjs';
36
+ import {logger} from '../logger.mjs';
37
+
38
+ /** @typedef {import('./doctor.mjs').DoctorCheck} DoctorCheck */
39
+ /** @typedef {import('../../foundation/discovery/theme-discovery.mjs').DiscoveredTheme} DiscoveredTheme */
40
+ /** @typedef {import('../../foundation/config/theme-state.mjs').ResolvedAppTheme} ResolvedAppTheme */
41
+
42
+ const CHECKS = [
43
+ ['theme-owners', 'Theme owners and built imports'],
44
+ ['theme-module', 'Generated theme module'],
45
+ ['theme-module-import', 'App imports the theme module'],
46
+ ['theme-stylesheet-imports', 'Built theme stylesheet imports'],
47
+ ['theme-local-builds', 'Local theme build freshness'],
48
+ ['theme-private-variables', 'Private theme variables'],
49
+ ['theme-core-peers', 'Theme Core peer compatibility'],
50
+ ['theme-default', 'Default added theme'],
51
+ ['theme-fonts', 'Theme font loading'],
52
+ ['theme-global-rules', 'Cross-theme global CSS rules'],
53
+ ];
54
+
55
+ /**
56
+ * @param {string} message
57
+ * @param {Error|null} [moduleError]
58
+ * @returns {DoctorCheck[]}
59
+ */
60
+ function unavailableChecks(message, moduleError = null) {
61
+ return CHECKS.map(([id, label]) => ({
62
+ id,
63
+ label,
64
+ status: moduleError && id === 'theme-module' ? 'fail' : 'info',
65
+ message:
66
+ moduleError && id === 'theme-module' ? moduleError.message : message,
67
+ ...(moduleError && id === 'theme-module'
68
+ ? {
69
+ fix: 'Keep one CLI-generated astryx-themes.ts or astryx-themes.js file, then run `astryx theme add <slug> --import`.',
70
+ }
71
+ : {}),
72
+ }));
73
+ }
74
+
75
+ /** @param {string} value */
76
+ function projectPath(value) {
77
+ return value.split(path.sep).join('/');
78
+ }
79
+
80
+ /** @param {string} root @param {string} file */
81
+ function relative(root, file) {
82
+ return projectPath(path.relative(root, file));
83
+ }
84
+
85
+ /**
86
+ * The concrete command that revalidates one recorded theme after its source or
87
+ * package is corrected.
88
+ * @param {string} projectDir
89
+ * @param {string} run
90
+ * @param {DiscoveredTheme[]} available
91
+ * @param {string} slug
92
+ * @param {string} owner
93
+ */
94
+ function refreshThemeCommand(projectDir, run, available, slug, owner) {
95
+ const theme = available.find(
96
+ candidate =>
97
+ candidate.slug === slug && themeRecordOwner(candidate) === owner,
98
+ );
99
+ if (!isLocalThemeOwner(owner)) {
100
+ const selector = theme?.package ?? owner;
101
+ return `npm install ${owner}@latest; ${run} theme add ${slug} --import --package ${selector}`;
102
+ }
103
+ const source = theme
104
+ ? relative(projectDir, path.join(theme.sourceDir, theme.entry))
105
+ : projectPath(path.join(owner, slug, `${slug}Theme.ts`));
106
+ return `${run} theme build ${source}; ${run} theme add ${slug} --import`;
107
+ }
108
+
109
+ /** @param {string} source */
110
+ function parseModule(source) {
111
+ return parse(source, {
112
+ sourceType: 'unambiguous',
113
+ plugins: ['typescript', 'jsx', 'decorators-legacy', 'importAttributes'],
114
+ });
115
+ }
116
+
117
+ /** @param {unknown} value @param {(node: any) => void} visit */
118
+ function walkAst(value, visit) {
119
+ if (value == null || typeof value !== 'object') return;
120
+ if (Array.isArray(value)) {
121
+ for (const item of value) walkAst(item, visit);
122
+ return;
123
+ }
124
+ const node = /** @type {Record<string, unknown>} */ (value);
125
+ if (typeof node.type === 'string') visit(node);
126
+ for (const [key, child] of Object.entries(node)) {
127
+ if (['loc', 'start', 'end', 'extra'].includes(key)) continue;
128
+ walkAst(child, visit);
129
+ }
130
+ }
131
+
132
+ /** @param {string} source */
133
+ function moduleSpecifiers(source) {
134
+ const values = new Set();
135
+ walkAst(parseModule(source), node => {
136
+ if (
137
+ [
138
+ 'ImportDeclaration',
139
+ 'ExportNamedDeclaration',
140
+ 'ExportAllDeclaration',
141
+ ].includes(node.type) &&
142
+ typeof node.source?.value === 'string'
143
+ ) {
144
+ values.add(node.source.value);
145
+ }
146
+ if (
147
+ node.type === 'ImportExpression' &&
148
+ typeof node.source?.value === 'string'
149
+ ) {
150
+ values.add(node.source.value);
151
+ }
152
+ if (
153
+ node.type === 'CallExpression' &&
154
+ (node.callee?.type === 'Import' || node.callee?.name === 'require') &&
155
+ typeof node.arguments?.[0]?.value === 'string'
156
+ ) {
157
+ values.add(node.arguments[0].value);
158
+ }
159
+ });
160
+ return values;
161
+ }
162
+
163
+ /** @param {string} specifier @param {string} fromFile @param {string} target */
164
+ function specifierTargets(specifier, fromFile, target) {
165
+ if (!specifier.startsWith('.')) return false;
166
+ const base = path.resolve(path.dirname(fromFile), specifier);
167
+ const candidates = [
168
+ base,
169
+ ...[...SOURCE_EXTENSIONS].map(extension => `${base}${extension}`),
170
+ ...[...SOURCE_EXTENSIONS].map(extension =>
171
+ path.join(base, `index${extension}`),
172
+ ),
173
+ ];
174
+ return candidates.some(
175
+ candidate => path.resolve(candidate) === path.resolve(target),
176
+ );
177
+ }
178
+
179
+ /** @param {string} root @param {string} generatedModule */
180
+ function sourceImportEvidence(root, generatedModule) {
181
+ let parseFailures = 0;
182
+ for (const file of listProjectSourceFiles(root, generatedModule)) {
183
+ try {
184
+ const source = readTextFile(file);
185
+ if (
186
+ [...moduleSpecifiers(source)].some(specifier =>
187
+ specifierTargets(specifier, file, generatedModule),
188
+ )
189
+ ) {
190
+ return {found: true, parseFailures};
191
+ }
192
+ } catch {
193
+ parseFailures += 1;
194
+ }
195
+ }
196
+ return {found: false, parseFailures};
197
+ }
198
+
199
+ /**
200
+ * Find a source file that imports one added built module without its paired CSS.
201
+ * @param {string} root
202
+ * @param {string} generatedModule
203
+ * @param {ResolvedAppTheme[]} themes
204
+ */
205
+ function themeImportPairEvidence(root, generatedModule, themes) {
206
+ const files = [
207
+ generatedModule,
208
+ ...listProjectSourceFiles(root, generatedModule),
209
+ ];
210
+ const unpaired = [];
211
+ const unproven = [];
212
+ for (const file of files) {
213
+ let source;
214
+ try {
215
+ source = readTextFile(file);
216
+ } catch {
217
+ continue;
218
+ }
219
+ const candidates = themes.filter(theme =>
220
+ source.includes(
221
+ theme.source === 'local'
222
+ ? path.basename(theme.moduleFile)
223
+ : theme.module,
224
+ ),
225
+ );
226
+ if (candidates.length === 0) continue;
227
+ let specifiers;
228
+ try {
229
+ specifiers = moduleSpecifiers(source);
230
+ } catch {
231
+ unproven.push(relative(root, file));
232
+ continue;
233
+ }
234
+ for (const theme of candidates) {
235
+ const importsModule = [...specifiers].some(specifier =>
236
+ theme.source === 'local'
237
+ ? specifierTargets(specifier, file, theme.moduleFile)
238
+ : specifier === theme.module,
239
+ );
240
+ if (!importsModule) continue;
241
+ const importsStylesheet = [...specifiers].some(specifier =>
242
+ theme.source === 'local'
243
+ ? specifierTargets(specifier, file, theme.stylesheetFile)
244
+ : specifier === theme.stylesheet,
245
+ );
246
+ if (!importsStylesheet) {
247
+ unpaired.push({
248
+ slug: theme.slug,
249
+ file: relative(root, file),
250
+ stylesheet: theme.stylesheet || relative(root, theme.stylesheetFile),
251
+ });
252
+ }
253
+ }
254
+ }
255
+ return {unpaired, unproven};
256
+ }
257
+
258
+ /** @param {string} value */
259
+ function normalizeFontName(value) {
260
+ return value
261
+ .trim()
262
+ .replace(/^(['"])(.*)\1$/u, '$2')
263
+ .replace(/\s+/gu, ' ');
264
+ }
265
+
266
+ /** @param {string[]} files */
267
+ function namedThemeFonts(files) {
268
+ const names = new Map();
269
+ for (const file of files) {
270
+ const source = readTextFileIfExists(file);
271
+ if (source == null) continue;
272
+ try {
273
+ walkAst(parseModule(source), node => {
274
+ if (node.type !== 'ObjectProperty' && node.type !== 'Property') return;
275
+ const key = node.key?.name ?? node.key?.value;
276
+ const value = node.value?.value;
277
+ if (typeof key !== 'string' || typeof value !== 'string') return;
278
+ /** @type {string[]} */
279
+ let found = [];
280
+ if (key.startsWith('--font-family-')) {
281
+ found = collectUnloadedFonts({tokens: {[key]: value}});
282
+ } else if (key === 'family') {
283
+ found = collectUnloadedFonts({typography: {body: {family: value}}});
284
+ } else if (key === 'fontFamily') {
285
+ found = collectUnloadedFonts({
286
+ components: {probe: {base: {fontFamily: value}}},
287
+ });
288
+ }
289
+ for (const name of found) {
290
+ const normalized = name.toLowerCase();
291
+ if (!names.has(normalized)) names.set(normalized, name);
292
+ }
293
+ });
294
+ } catch {
295
+ // The source-to-built checks report parse or build problems separately.
296
+ }
297
+ }
298
+ return new Set(names.values());
299
+ }
300
+
301
+ /** @param {string} css */
302
+ function fontStylesheetEvidence(css) {
303
+ const loaded = new Set();
304
+ let external = false;
305
+ const root = postcss.parse(css);
306
+ root.walkAtRules(atRule => {
307
+ if (atRule.name.toLowerCase() === 'import') external = true;
308
+ if (atRule.name.toLowerCase() !== 'font-face') return;
309
+ atRule.walkDecls(/^font-family$/iu, declaration => {
310
+ loaded.add(normalizeFontName(declaration.value).toLowerCase());
311
+ });
312
+ });
313
+ return {loaded, external};
314
+ }
315
+
316
+ /** @param {import('postcss').Rule} rule @param {string} slug */
317
+ function scopedToTheme(rule, slug) {
318
+ const needles = [
319
+ `[data-astryx-theme="${slug}"]`,
320
+ `[data-astryx-theme='${slug}']`,
321
+ ];
322
+ if (needles.some(needle => rule.selector.includes(needle))) return true;
323
+ /** @type {import('postcss').Node|undefined} */
324
+ let parent = rule.parent;
325
+ while (parent) {
326
+ if (parent.type === 'atrule') {
327
+ const atRule = /** @type {import('postcss').AtRule} */ (parent);
328
+ const params = atRule.params;
329
+ if (needles.some(needle => String(params).includes(needle))) return true;
330
+ }
331
+ parent = parent.parent;
332
+ }
333
+ return false;
334
+ }
335
+
336
+ /** @param {string} css @param {string} slug */
337
+ function globalRules(css, slug) {
338
+ const rules = new Map();
339
+ const root = postcss.parse(css);
340
+ root.walkRules(rule => {
341
+ if (scopedToTheme(rule, slug)) return;
342
+ /** @type {import('postcss').Node|undefined} */
343
+ let parent = rule.parent;
344
+ while (parent) {
345
+ if (
346
+ parent.type === 'atrule' &&
347
+ /keyframes$/iu.test(
348
+ /** @type {import('postcss').AtRule} */ (parent).name,
349
+ )
350
+ )
351
+ return;
352
+ parent = parent.parent;
353
+ }
354
+ /** @type {string[]} */
355
+ const declarations = [];
356
+ rule.walkDecls(declaration => {
357
+ declarations.push(
358
+ `${declaration.prop.trim()}:${declaration.value.trim()}${declaration.important ? '!important' : ''}`,
359
+ );
360
+ });
361
+ rules.set(rule.selector.trim(), declarations.sort().join(';'));
362
+ });
363
+ return rules;
364
+ }
365
+
366
+ /**
367
+ * Report source copies made by the released `theme add` before it copied
368
+ * descriptors. This is a migration notice, not one of the ten setup checks.
369
+ * @param {string} projectDir
370
+ * @returns {DoctorCheck|null}
371
+ */
372
+ function unmigratedCopyCheck(projectDir) {
373
+ const copies = discoverDoctorUnmigratedCopies(projectDir);
374
+ if (copies.length === 0) return null;
375
+ const shown = copies
376
+ .map(copy => relative(projectDir, copy.sourceDir))
377
+ .join(', ');
378
+ const command = `${getCliInvocation(projectDir)} upgrade --from 0.6.4 --path . --apply`;
379
+ return {
380
+ id: 'theme-unmigrated-copies',
381
+ label: 'Earlier copied themes',
382
+ status: 'warn',
383
+ message: `${copies.length} source theme copy or copies are not managed themes yet: ${shown}.`,
384
+ fix: `Write their missing descriptors with \`${command}\`.`,
385
+ };
386
+ }
387
+
388
+ /**
389
+ * Run all ten app-theme checks.
390
+ * @param {string} cwd
391
+ * @returns {Promise<DoctorCheck[]>}
392
+ */
393
+ export async function checkAppThemes(cwd) {
394
+ let state;
395
+ try {
396
+ state = readThemeState(cwd);
397
+ } catch (error) {
398
+ const err = error instanceof Error ? error : new Error(String(error));
399
+ if (/No package\.json found/u.test(err.message)) {
400
+ return unavailableChecks('No app theme record found.');
401
+ }
402
+ return unavailableChecks(
403
+ 'Skipped because the generated theme module could not be read.',
404
+ err,
405
+ );
406
+ }
407
+
408
+ if (!state.configured) {
409
+ try {
410
+ resolveThemeModule(state.projectDir, {forWrite: true});
411
+ } catch (error) {
412
+ return unavailableChecks(
413
+ 'Skipped because the generated theme module is unavailable.',
414
+ error instanceof Error ? error : new Error(String(error)),
415
+ );
416
+ }
417
+ const run = getCliInvocation(state.projectDir);
418
+ /** @type {DoctorCheck[]} */
419
+ const report = [
420
+ {
421
+ id: 'theme-management',
422
+ label: 'CLI-managed app themes',
423
+ status: 'info',
424
+ message: state.legacyTheme
425
+ ? `The CLI manages no themes. The released package.json astryx.theme value ${JSON.stringify(state.legacyTheme)} remains active.`
426
+ : 'The CLI manages no themes because this project has no generated theme module.',
427
+ fix: `Start managing app themes with \`${run} theme add <slug> --import\`.`,
428
+ },
429
+ ];
430
+ const migration = unmigratedCopyCheck(state.projectDir);
431
+ if (migration) report.push(migration);
432
+ return report;
433
+ }
434
+
435
+ const run = getCliInvocation(state.projectDir);
436
+ const ownerEntries = Object.entries(state.themes);
437
+ /** @type {DiscoveredTheme[]} */
438
+ let available = [];
439
+ let discoveryError = null;
440
+ try {
441
+ available = await discoverDoctorThemes(state.projectDir);
442
+ } catch (error) {
443
+ discoveryError = error instanceof Error ? error : new Error(String(error));
444
+ }
445
+
446
+ /** @type {ResolvedAppTheme[]} */
447
+ const resolved = [];
448
+ /** @type {Array<{slug: string, owner: string, message: string}>} */
449
+ const resolutionProblems = [];
450
+ const ownerCounts = new Map();
451
+ for (const theme of available) {
452
+ const owner = themeRecordOwner(theme);
453
+ ownerCounts.set(owner, (ownerCounts.get(owner) ?? 0) + 1);
454
+ }
455
+ if (!discoveryError) {
456
+ for (const [slug, owner] of ownerEntries) {
457
+ const theme = available.find(
458
+ candidate =>
459
+ candidate.slug === slug && themeRecordOwner(candidate) === owner,
460
+ );
461
+ if (!theme) {
462
+ resolutionProblems.push({
463
+ slug,
464
+ owner,
465
+ message: `Theme "${slug}" from ${owner} is unavailable.`,
466
+ });
467
+ continue;
468
+ }
469
+ /** @type {ResolvedAppTheme} */
470
+ let resolvedTheme;
471
+ try {
472
+ resolvedTheme = resolveDoctorThemeImports(theme, {
473
+ cwd: state.projectDir,
474
+ ownerThemeCount: ownerCounts.get(owner) ?? 1,
475
+ });
476
+ } catch (error) {
477
+ resolutionProblems.push({
478
+ slug,
479
+ owner,
480
+ message: error instanceof Error ? error.message : String(error),
481
+ });
482
+ continue;
483
+ }
484
+ try {
485
+ const loaded = await resolveRecordedTheme(state.projectDir, slug);
486
+ if (!loaded.module) {
487
+ resolutionProblems.push({
488
+ slug,
489
+ owner,
490
+ message: `Theme "${slug}" from ${owner} could not load its built module: ${loaded.problem ?? `${loaded.specifier} does not resolve`}.`,
491
+ });
492
+ continue;
493
+ }
494
+ } catch (error) {
495
+ const detail =
496
+ error instanceof Error
497
+ ? error.message.split('\n', 1)[0]?.trim() || error.name
498
+ : String(error);
499
+ resolutionProblems.push({
500
+ slug,
501
+ owner,
502
+ message: `Theme "${slug}" from ${owner} could not load its built module: ${detail}.`,
503
+ });
504
+ continue;
505
+ }
506
+ resolved.push(resolvedTheme);
507
+ }
508
+ }
509
+
510
+ const incompleteResolution =
511
+ discoveryError != null ||
512
+ resolutionProblems.length > 0 ||
513
+ resolved.length !== ownerEntries.length;
514
+
515
+ /** @type {ReturnType<typeof planThemeAppWrite>|null} */
516
+ let prepared = null;
517
+ if (
518
+ !discoveryError &&
519
+ resolutionProblems.length === 0 &&
520
+ resolved.length === ownerEntries.length &&
521
+ state.defaultSlug != null &&
522
+ Object.hasOwn(state.themes, state.defaultSlug)
523
+ ) {
524
+ try {
525
+ prepared = planThemeAppWrite(
526
+ state,
527
+ state.themes,
528
+ state.defaultSlug,
529
+ resolved,
530
+ );
531
+ } catch {
532
+ prepared = null;
533
+ }
534
+ }
535
+
536
+ /** @type {DoctorCheck[]} */
537
+ const checks = [];
538
+
539
+ if (ownerEntries.length === 0) {
540
+ checks.push({
541
+ id: 'theme-owners',
542
+ label: 'Theme owners and built imports',
543
+ status: 'fail',
544
+ message: 'The generated record has no added themes.',
545
+ fix: `${run} theme add <slug> --import`,
546
+ });
547
+ } else if (discoveryError) {
548
+ checks.push({
549
+ id: 'theme-owners',
550
+ label: 'Theme owners and built imports',
551
+ status: 'fail',
552
+ message: discoveryError.message,
553
+ fix: `${run} theme add <slug> --import`,
554
+ });
555
+ } else if (resolutionProblems.length > 0) {
556
+ checks.push({
557
+ id: 'theme-owners',
558
+ label: 'Theme owners and built imports',
559
+ status: 'fail',
560
+ message: resolutionProblems.map(problem => problem.message).join(' '),
561
+ fix: resolutionProblems
562
+ .map(problem =>
563
+ refreshThemeCommand(
564
+ state.projectDir,
565
+ run,
566
+ available,
567
+ problem.slug,
568
+ problem.owner,
569
+ ),
570
+ )
571
+ .join(' '),
572
+ });
573
+ } else {
574
+ checks.push({
575
+ id: 'theme-owners',
576
+ label: 'Theme owners and built imports',
577
+ status: 'pass',
578
+ message: `${resolved.length} added theme${resolved.length === 1 ? '' : 's'} resolve to built modules and stylesheets, and every built module loads.`,
579
+ });
580
+ }
581
+
582
+ const currentModule = state.module.expectedOriginal?.toString('utf-8') ?? '';
583
+ if (!prepared) {
584
+ checks.push({
585
+ id: 'theme-module',
586
+ label: 'Generated theme module',
587
+ status: 'info',
588
+ message:
589
+ 'Could not regenerate the module until its owners, imports, and default are valid.',
590
+ });
591
+ } else if (currentModule !== prepared.moduleContents) {
592
+ checks.push({
593
+ id: 'theme-module',
594
+ label: 'Generated theme module',
595
+ status: 'fail',
596
+ message: `${state.module.path} differs from the exact module generated from its own record.`,
597
+ fix: `${run} theme use ${state.defaultSlug}`,
598
+ });
599
+ } else {
600
+ checks.push({
601
+ id: 'theme-module',
602
+ label: 'Generated theme module',
603
+ status: 'pass',
604
+ message: `${state.module.path} has the generated marker and exactly matches its record.`,
605
+ });
606
+ }
607
+
608
+ const importEvidence = sourceImportEvidence(
609
+ state.projectDir,
610
+ state.module.file,
611
+ );
612
+ if (importEvidence.found) {
613
+ checks.push({
614
+ id: 'theme-module-import',
615
+ label: 'App imports the theme module',
616
+ status: 'pass',
617
+ message: `Project source imports ${state.module.path}.`,
618
+ });
619
+ } else {
620
+ checks.push({
621
+ id: 'theme-module-import',
622
+ label: 'App imports the theme module',
623
+ status: 'warn',
624
+ message: `Could not prove that project source imports ${state.module.path}${importEvidence.parseFailures ? `; ${importEvidence.parseFailures} source file(s) could not be parsed` : ''}.`,
625
+ fix: `Import {themes, defaultThemeSlug} from the generated module and render <Theme theme={themes[defaultThemeSlug]}>.`,
626
+ });
627
+ }
628
+
629
+ if (discoveryError || resolutionProblems.length > 0) {
630
+ checks.push({
631
+ id: 'theme-stylesheet-imports',
632
+ label: 'Built theme stylesheet imports',
633
+ status: 'info',
634
+ message:
635
+ 'Could not prove module and stylesheet pairs until every built import resolves.',
636
+ });
637
+ } else {
638
+ const pairEvidence = themeImportPairEvidence(
639
+ state.projectDir,
640
+ state.module.file,
641
+ prepared?.entries ?? resolved,
642
+ );
643
+ if (pairEvidence.unpaired.length > 0) {
644
+ checks.push({
645
+ id: 'theme-stylesheet-imports',
646
+ label: 'Built theme stylesheet imports',
647
+ status: 'fail',
648
+ message: pairEvidence.unpaired
649
+ .map(
650
+ problem =>
651
+ `${problem.file} imports ${problem.slug} without ${problem.stylesheet}`,
652
+ )
653
+ .join('; '),
654
+ fix: `Import the named stylesheet beside each built module, then run ${run} theme use ${state.defaultSlug}.`,
655
+ });
656
+ } else if (pairEvidence.unproven.length > 0) {
657
+ checks.push({
658
+ id: 'theme-stylesheet-imports',
659
+ label: 'Built theme stylesheet imports',
660
+ status: 'info',
661
+ message: `Could not parse theme imports in ${pairEvidence.unproven.join(', ')}.`,
662
+ });
663
+ } else {
664
+ checks.push({
665
+ id: 'theme-stylesheet-imports',
666
+ label: 'Built theme stylesheet imports',
667
+ status: 'pass',
668
+ message:
669
+ 'Every added built module import is paired with its stylesheet import.',
670
+ });
671
+ }
672
+ }
673
+
674
+ const localThemes = resolved.filter(theme => theme.source === 'local');
675
+ if (incompleteResolution) {
676
+ checks.push({
677
+ id: 'theme-local-builds',
678
+ label: 'Local theme build freshness',
679
+ status: 'info',
680
+ message:
681
+ 'Could not check local build freshness until every local output resolves.',
682
+ });
683
+ } else if (localThemes.length === 0) {
684
+ checks.push({
685
+ id: 'theme-local-builds',
686
+ label: 'Local theme build freshness',
687
+ status: 'pass',
688
+ message: 'No added local themes need a freshness check.',
689
+ });
690
+ } else {
691
+ const stale = [];
692
+ const previousSilent = logger.silent;
693
+ logger.setSilent(true);
694
+ try {
695
+ for (const theme of localThemes) {
696
+ const availableTheme = available.find(
697
+ candidate =>
698
+ candidate.slug === theme.slug &&
699
+ themeRecordOwner(candidate) === theme.owner,
700
+ );
701
+ if (!availableTheme) continue;
702
+ try {
703
+ const receipt = await themeBuild(
704
+ path.join(availableTheme.sourceDir, availableTheme.entry),
705
+ {check: true},
706
+ {cwd: state.projectDir},
707
+ );
708
+ if (
709
+ receipt == null ||
710
+ receipt.type !== 'theme.build.check' ||
711
+ !receipt.data.upToDate
712
+ ) {
713
+ stale.push(theme.slug);
714
+ }
715
+ } catch {
716
+ stale.push(theme.slug);
717
+ }
718
+ }
719
+ } finally {
720
+ logger.setSilent(previousSilent);
721
+ }
722
+ checks.push(
723
+ stale.length > 0
724
+ ? {
725
+ id: 'theme-local-builds',
726
+ label: 'Local theme build freshness',
727
+ status: 'fail',
728
+ message: `Local theme outputs are missing or stale: ${stale.join(', ')}.`,
729
+ fix: stale
730
+ .map(slug =>
731
+ refreshThemeCommand(
732
+ state.projectDir,
733
+ run,
734
+ available,
735
+ slug,
736
+ state.themes[slug],
737
+ ),
738
+ )
739
+ .join(' '),
740
+ }
741
+ : {
742
+ id: 'theme-local-builds',
743
+ label: 'Local theme build freshness',
744
+ status: 'pass',
745
+ message: 'Every added local theme output matches its source.',
746
+ },
747
+ );
748
+ }
749
+
750
+ const privateProblems = [];
751
+ for (const theme of resolved) {
752
+ const availableTheme = available.find(
753
+ candidate =>
754
+ candidate.slug === theme.slug &&
755
+ themeRecordOwner(candidate) === theme.owner,
756
+ );
757
+ if (!availableTheme) continue;
758
+ try {
759
+ const errors = await validateThemePrivateInputs(
760
+ path.join(availableTheme.sourceDir, availableTheme.entry),
761
+ {cwd: state.projectDir},
762
+ );
763
+ if (errors.length > 0) {
764
+ privateProblems.push({theme, message: errors.join('; ')});
765
+ }
766
+ } catch (error) {
767
+ privateProblems.push({
768
+ theme,
769
+ message: `input could not be inspected: ${error instanceof Error ? error.message : String(error)}`,
770
+ });
771
+ }
772
+ }
773
+ checks.push(
774
+ incompleteResolution
775
+ ? {
776
+ id: 'theme-private-variables',
777
+ label: 'Private theme variables',
778
+ status: 'info',
779
+ message:
780
+ 'Could not inspect every theme input until built imports resolve.',
781
+ }
782
+ : privateProblems.length > 0
783
+ ? {
784
+ id: 'theme-private-variables',
785
+ label: 'Private theme variables',
786
+ status: 'fail',
787
+ message: `Added theme inputs set private --_* variables directly (${privateProblems
788
+ .map(problem => `${problem.theme.slug}: ${problem.message}`)
789
+ .join('; ')}).`,
790
+ fix: `Remove the direct private input keys, then ${privateProblems
791
+ .map(problem =>
792
+ refreshThemeCommand(
793
+ state.projectDir,
794
+ run,
795
+ available,
796
+ problem.theme.slug,
797
+ problem.theme.owner,
798
+ ),
799
+ )
800
+ .join(' ')}`,
801
+ }
802
+ : {
803
+ id: 'theme-private-variables',
804
+ label: 'Private theme variables',
805
+ status: 'pass',
806
+ message:
807
+ 'No added theme input sets a private --_* variable directly.',
808
+ },
809
+ );
810
+
811
+ const coreDir = findDoctorCoreDir(state.projectDir);
812
+ const coreVersion = coreDir
813
+ ? readPackageVersion(path.join(coreDir, 'package.json'))
814
+ : null;
815
+ const peerProblems = [];
816
+ for (const [slug, owner] of ownerEntries) {
817
+ if (isLocalThemeOwner(owner)) continue;
818
+ const packageDir = findDoctorInstalledPackage(state.projectDir, owner);
819
+ const pkg = packageDir
820
+ ? readPackageJson(path.join(packageDir, 'package.json'))
821
+ : null;
822
+ const range = pkg?.peerDependencies?.['@astryxdesign/core'];
823
+ if (
824
+ !coreVersion ||
825
+ typeof range !== 'string' ||
826
+ !satisfiesRange(coreVersion, range)
827
+ ) {
828
+ peerProblems.push({
829
+ slug,
830
+ owner,
831
+ range: typeof range === 'string' ? range : null,
832
+ message: `${slug}: ${owner} requires ${typeof range === 'string' ? range : 'an undeclared Core range'}, installed ${coreVersion ?? 'none'}`,
833
+ });
834
+ }
835
+ }
836
+ checks.push(
837
+ incompleteResolution
838
+ ? {
839
+ id: 'theme-core-peers',
840
+ label: 'Theme Core peer compatibility',
841
+ status: 'info',
842
+ message:
843
+ 'Could not prove Core peer compatibility until every added theme resolves.',
844
+ }
845
+ : peerProblems.length > 0
846
+ ? {
847
+ id: 'theme-core-peers',
848
+ label: 'Theme Core peer compatibility',
849
+ status: 'fail',
850
+ message: peerProblems.map(problem => problem.message).join('; '),
851
+ fix: peerProblems
852
+ .map(problem =>
853
+ problem.range
854
+ ? `npm install '@astryxdesign/core@${problem.range}'; ${run} doctor`
855
+ : refreshThemeCommand(
856
+ state.projectDir,
857
+ run,
858
+ available,
859
+ problem.slug,
860
+ problem.owner,
861
+ ),
862
+ )
863
+ .join(' '),
864
+ }
865
+ : {
866
+ id: 'theme-core-peers',
867
+ label: 'Theme Core peer compatibility',
868
+ status: 'pass',
869
+ message:
870
+ 'Every added package theme accepts the installed @astryxdesign/core version.',
871
+ },
872
+ );
873
+
874
+ const validDefault =
875
+ state.defaultSlug != null && Object.hasOwn(state.themes, state.defaultSlug);
876
+ checks.push(
877
+ validDefault
878
+ ? {
879
+ id: 'theme-default',
880
+ label: 'Default added theme',
881
+ status: 'pass',
882
+ message: `Default theme "${state.defaultSlug}" is added.`,
883
+ }
884
+ : {
885
+ id: 'theme-default',
886
+ label: 'Default added theme',
887
+ status: 'fail',
888
+ message: `Default theme "${state.defaultSlug ?? ''}" is not one of the added themes.`,
889
+ fix:
890
+ ownerEntries.length > 0
891
+ ? `${run} theme use ${ownerEntries[0][0]}`
892
+ : `${run} theme add <slug> --import`,
893
+ },
894
+ );
895
+
896
+ const fontFailures = [];
897
+ const externalFontWarnings = [];
898
+ const missingFontWarnings = [];
899
+ let generatedImports = null;
900
+ try {
901
+ generatedImports = moduleSpecifiers(currentModule);
902
+ } catch {
903
+ // The generated-module check owns the parse failure. This check stays
904
+ // evidence-driven and refuses to pass without readable imports.
905
+ }
906
+ for (const theme of resolved) {
907
+ const availableTheme = available.find(
908
+ candidate =>
909
+ candidate.slug === theme.slug &&
910
+ themeRecordOwner(candidate) === theme.owner,
911
+ );
912
+ const files = [theme.moduleFile];
913
+ if (availableTheme) {
914
+ files.push(path.join(availableTheme.sourceDir, availableTheme.entry));
915
+ }
916
+ const names = namedThemeFonts(files);
917
+ if (names.size === 0) continue;
918
+ const importedTheme =
919
+ prepared?.entries.find(entry => entry.slug === theme.slug) ?? theme;
920
+ if (!theme.fontStylesheetFile || !importedTheme.fontStylesheet) {
921
+ const problem = {
922
+ theme,
923
+ message: `${[...names].join(', ')} (font stylesheet is not imported)`,
924
+ };
925
+ missingFontWarnings.push(problem);
926
+ continue;
927
+ }
928
+ if (!generatedImports?.has(importedTheme.fontStylesheet)) {
929
+ fontFailures.push({
930
+ theme,
931
+ message: `${[...names].join(', ')} (font stylesheet is not imported)`,
932
+ });
933
+ continue;
934
+ }
935
+ try {
936
+ const evidence = fontStylesheetEvidence(
937
+ readTextFile(theme.fontStylesheetFile),
938
+ );
939
+ const missing = [...names].filter(
940
+ name => !evidence.loaded.has(name.toLowerCase()),
941
+ );
942
+ if (missing.length === 0) continue;
943
+ if (evidence.external) {
944
+ externalFontWarnings.push(`${theme.slug}: ${missing.join(', ')}`);
945
+ } else {
946
+ fontFailures.push({theme, message: missing.join(', ')});
947
+ }
948
+ } catch {
949
+ fontFailures.push({
950
+ theme,
951
+ message: 'font stylesheet could not be parsed',
952
+ });
953
+ }
954
+ }
955
+ const fontWarningMessages = [];
956
+ const fontWarningFixes = [];
957
+ if (missingFontWarnings.length > 0) {
958
+ fontWarningMessages.push(
959
+ `Added themes name font families but import no font stylesheet (${missingFontWarnings
960
+ .map(problem => `${problem.theme.slug}: ${problem.message}`)
961
+ .join('; ')}).`,
962
+ );
963
+ const localWarnings = missingFontWarnings.filter(
964
+ problem => problem.theme.source === 'local',
965
+ );
966
+ const packageWarnings = missingFontWarnings.filter(
967
+ problem => problem.theme.source !== 'local',
968
+ );
969
+ if (localWarnings.length > 0) {
970
+ fontWarningFixes.push(
971
+ `Add <slug>.fonts.css beside each built local theme output, then ${localWarnings
972
+ .map(problem => `${run} theme add ${problem.theme.slug} --import`)
973
+ .join('; ')}.`,
974
+ );
975
+ }
976
+ if (packageWarnings.length > 0) {
977
+ fontWarningFixes.push(
978
+ 'Load the named package fonts in app HTML, or install a package version that exports <slug>.fonts.css (or fonts.css for a single-theme package).',
979
+ );
980
+ }
981
+ }
982
+ if (externalFontWarnings.length > 0) {
983
+ fontWarningMessages.push(
984
+ `External font imports prevent proof for ${externalFontWarnings.join('; ')}.`,
985
+ );
986
+ fontWarningFixes.push(
987
+ 'Confirm the font service stylesheet loads each named family.',
988
+ );
989
+ }
990
+ checks.push(
991
+ incompleteResolution
992
+ ? {
993
+ id: 'theme-fonts',
994
+ label: 'Theme font loading',
995
+ status: 'info',
996
+ message:
997
+ 'Could not prove font loading until every added theme resolves.',
998
+ }
999
+ : fontFailures.length > 0
1000
+ ? {
1001
+ id: 'theme-fonts',
1002
+ label: 'Theme font loading',
1003
+ status: 'fail',
1004
+ message: `Named font families have no proven loader (${fontFailures
1005
+ .map(problem => `${problem.theme.slug}: ${problem.message}`)
1006
+ .join('; ')}).`,
1007
+ fix: `Add the missing font stylesheet export or local <slug>.fonts.css, then ${fontFailures
1008
+ .map(problem =>
1009
+ refreshThemeCommand(
1010
+ state.projectDir,
1011
+ run,
1012
+ available,
1013
+ problem.theme.slug,
1014
+ problem.theme.owner,
1015
+ ),
1016
+ )
1017
+ .join(' ')}`,
1018
+ }
1019
+ : fontWarningMessages.length > 0
1020
+ ? {
1021
+ id: 'theme-fonts',
1022
+ label: 'Theme font loading',
1023
+ status: 'warn',
1024
+ message: fontWarningMessages.join(' '),
1025
+ fix: fontWarningFixes.join(' '),
1026
+ }
1027
+ : {
1028
+ id: 'theme-fonts',
1029
+ label: 'Theme font loading',
1030
+ status: 'pass',
1031
+ message:
1032
+ 'Every named non-system font has a local @font-face loader.',
1033
+ },
1034
+ );
1035
+
1036
+ const globalBySelector = new Map();
1037
+ const globalProblems = [];
1038
+ for (const theme of resolved) {
1039
+ try {
1040
+ for (const [selector, declarations] of globalRules(
1041
+ readTextFile(theme.stylesheetFile),
1042
+ theme.slug,
1043
+ )) {
1044
+ const prior = globalBySelector.get(selector);
1045
+ if (prior && prior.declarations !== declarations) {
1046
+ globalProblems.push({
1047
+ message: `${selector}: ${prior.theme.slug}, ${theme.slug}`,
1048
+ themes: [prior.theme, theme],
1049
+ });
1050
+ } else if (!prior) {
1051
+ globalBySelector.set(selector, {theme, declarations});
1052
+ }
1053
+ }
1054
+ } catch {
1055
+ globalProblems.push({
1056
+ message: `${theme.slug}: stylesheet could not be parsed`,
1057
+ themes: [theme],
1058
+ });
1059
+ }
1060
+ }
1061
+ /** @type {Map<string, ResolvedAppTheme>} */
1062
+ const globalRepairThemes = new Map();
1063
+ for (const problem of globalProblems) {
1064
+ for (const theme of problem.themes) {
1065
+ globalRepairThemes.set(`${theme.owner}\u0000${theme.slug}`, theme);
1066
+ }
1067
+ }
1068
+ checks.push(
1069
+ incompleteResolution
1070
+ ? {
1071
+ id: 'theme-global-rules',
1072
+ label: 'Cross-theme global CSS rules',
1073
+ status: 'info',
1074
+ message:
1075
+ 'Could not compare global CSS until every added stylesheet resolves.',
1076
+ }
1077
+ : globalProblems.length > 0
1078
+ ? {
1079
+ id: 'theme-global-rules',
1080
+ label: 'Cross-theme global CSS rules',
1081
+ status: 'fail',
1082
+ message: `Added themes write different global rules for the same selector (${globalProblems
1083
+ .map(problem => problem.message)
1084
+ .join('; ')}).`,
1085
+ fix: `Scope each conflicting rule under its [data-astryx-theme] selector, then ${[
1086
+ ...globalRepairThemes.values(),
1087
+ ]
1088
+ .map(theme =>
1089
+ refreshThemeCommand(
1090
+ state.projectDir,
1091
+ run,
1092
+ available,
1093
+ theme.slug,
1094
+ theme.owner,
1095
+ ),
1096
+ )
1097
+ .join(' ')}`,
1098
+ }
1099
+ : {
1100
+ id: 'theme-global-rules',
1101
+ label: 'Cross-theme global CSS rules',
1102
+ status: 'pass',
1103
+ message:
1104
+ 'No added themes write different rules for the same selector outside their own scope.',
1105
+ },
1106
+ );
1107
+
1108
+ const migration = unmigratedCopyCheck(state.projectDir);
1109
+ if (migration) checks.push(migration);
1110
+ return checks;
1111
+ }
1112
+
1113
+ /** @param {string} file */
1114
+ function readPackageVersion(file) {
1115
+ const pkg = readPackageJson(file);
1116
+ return typeof pkg?.version === 'string' ? pkg.version : null;
1117
+ }