@astryxdesign/cli 0.6.3-canary.ea2f048 → 0.6.3-canary.f04b501

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 (505) hide show
  1. package/README.md +106 -72
  2. package/api/blog/blog.doc.mjs +1 -0
  3. package/api/build/build.doc.mjs +4 -3
  4. package/api/build/build.test.mjs +14 -3
  5. package/api/build/build.type.d.mts +36 -2
  6. package/api/build/build.type.mjs +25 -4
  7. package/api/build/help/help.d.mts +8 -5
  8. package/api/build/help/help.mjs +56 -6
  9. package/api/component/component.doc.mjs +13 -3
  10. package/api/component/component.mjs +31 -2
  11. package/api/component/component.test.mjs +38 -0
  12. package/api/component/component.type.d.mts +22 -11
  13. package/api/component/component.type.mjs +32 -24
  14. package/api/component/detail/blocks/blocks.d.mts +2 -1
  15. package/api/component/detail/blocks/blocks.mjs +4 -3
  16. package/api/component/list/list.d.mts +0 -5
  17. package/api/component/list/list.mjs +37 -9
  18. package/api/discover/discover.doc.mjs +2 -1
  19. package/api/discover/discover.type.d.mts +4 -4
  20. package/api/discover/discover.type.mjs +10 -10
  21. package/api/docs/_adapter.d.mts +32 -24
  22. package/api/docs/_adapter.mjs +81 -87
  23. package/api/docs/compiled-topics.test.mjs +78 -0
  24. package/api/docs/detail/detail.mjs +14 -63
  25. package/api/docs/detail/section/section.d.mts +1 -1
  26. package/api/docs/detail/section/section.mjs +44 -20
  27. package/api/docs/detail/section/section.test.mjs +41 -0
  28. package/api/docs/docs.d.mts +7 -2
  29. package/api/docs/docs.doc.mjs +28 -10
  30. package/api/docs/docs.mjs +16 -9
  31. package/api/docs/docs.test.mjs +6 -0
  32. package/api/docs/docs.type.d.mts +40 -3
  33. package/api/docs/docs.type.mjs +36 -8
  34. package/api/docs/index/index.d.mts +18 -0
  35. package/api/docs/index/index.mjs +32 -0
  36. package/api/docs/index/index.test.mjs +62 -0
  37. package/api/docs/integrationDocs.test.mjs +106 -0
  38. package/api/docs/list/list.mjs +3 -7
  39. package/api/doctor/doctor.d.mts +70 -0
  40. package/api/doctor/doctor.doc.mjs +1 -0
  41. package/api/doctor/doctor.mjs +404 -0
  42. package/api/doctor/doctor.test.mjs +522 -1
  43. package/api/gap-report/gap-report.doc.mjs +8 -4
  44. package/api/hook/_adapter.mjs +19 -5
  45. package/api/hook/hook.doc.mjs +1 -0
  46. package/api/hook/hook.type.d.mts +3 -3
  47. package/api/hook/hook.type.mjs +11 -11
  48. package/api/hook/list/list.d.mts +2 -2
  49. package/api/hook/list/list.mjs +69 -17
  50. package/api/init/init.doc.mjs +5 -0
  51. package/api/init/init.test.mjs +41 -1
  52. package/api/init/remove/remove.mjs +1 -1
  53. package/api/init/run/run.mjs +20 -10
  54. package/api/integration/add-contribution.component-names.test.mjs +120 -0
  55. package/api/integration/add-contribution.mjs +23 -10
  56. package/api/integration/add-contribution.test.mjs +121 -7
  57. package/api/integration/add-theme.mjs +34 -64
  58. package/api/integration/add-theme.test.mjs +105 -21
  59. package/api/integration/authoring-checks.test.mjs +8 -4
  60. package/api/integration/integration-authoring.type.d.mts +1 -1
  61. package/api/integration/integration-block-exports.test.mjs +10 -6
  62. package/api/integration/integrationAdd.doc.mjs +8 -4
  63. package/api/integration/integrationAddAgentDoc.doc.mjs +1 -0
  64. package/api/integration/integrationAddCodemod.doc.mjs +1 -0
  65. package/api/integration/integrationAddComponent.doc.mjs +2 -1
  66. package/api/integration/integrationAddDoc.doc.mjs +1 -0
  67. package/api/integration/integrationAddTemplate.doc.mjs +1 -0
  68. package/api/integration/integrationAddTheme.doc.mjs +6 -5
  69. package/api/integration/integrationComponentConflicts.doc.mjs +1 -0
  70. package/api/integration/integrationDocConflicts.doc.mjs +1 -0
  71. package/api/integration/integrationPackCheck.doc.mjs +1 -0
  72. package/api/integration/integrationTemplateConflicts.doc.mjs +1 -0
  73. package/api/integration/pack-check.mjs +49 -7
  74. package/api/integration/pack-check.test.mjs +266 -47
  75. package/api/integration/summarizeIssues.doc.mjs +1 -0
  76. package/api/integration/validate-integration-fixes.test.mjs +1389 -0
  77. package/api/integration/validate-integration.mjs +52 -102
  78. package/api/integration/validate-integration.test.mjs +176 -23
  79. package/api/integration/validate-unread-theme-folders.test.mjs +110 -0
  80. package/api/integration/validateIntegration.doc.mjs +2 -1
  81. package/api/json/assertResponse.doc.mjs +1 -0
  82. package/api/json/envelope-types.test.mjs +76 -0
  83. package/api/json/isError.doc.mjs +1 -0
  84. package/api/json/parseResponse.doc.mjs +3 -2
  85. package/api/layout/expand/expand.mjs +7 -5
  86. package/api/layout/expand/expand.path-safety.test.mjs +53 -0
  87. package/api/layout/grammar/grammar.mjs +2 -1
  88. package/api/layout/layoutCheck.doc.mjs +1 -0
  89. package/api/layout/layoutExpand.doc.mjs +2 -1
  90. package/api/layout/layoutGrammar.doc.mjs +1 -0
  91. package/api/search/search-return-type.test.mjs +54 -0
  92. package/api/search/search.d.mts +3 -10
  93. package/api/search/search.doc.mjs +6 -1
  94. package/api/search/search.mjs +31 -14
  95. package/api/search/search.test.mjs +34 -0
  96. package/api/search/search.type.d.mts +2 -2
  97. package/api/search/search.type.mjs +1 -1
  98. package/api/swizzle/copy/copy.mjs +28 -11
  99. package/api/swizzle/swizzle.doc.mjs +2 -1
  100. package/api/swizzle/swizzle.type.d.mts +2 -2
  101. package/api/swizzle/swizzle.type.mjs +2 -2
  102. package/api/template/copy/copy.mjs +17 -23
  103. package/api/template/copy/copy.test.mjs +17 -0
  104. package/api/template/template-suffix.test.mjs +41 -21
  105. package/api/template/template.d.mts +1 -1
  106. package/api/template/template.doc.mjs +3 -1
  107. package/api/template/template.type.d.mts +6 -6
  108. package/api/template/template.type.mjs +12 -12
  109. package/api/theme/_adapter.d.mts +2 -3
  110. package/api/theme/_adapter.mjs +4 -5
  111. package/api/theme/add/add.binary.test.mjs +84 -0
  112. package/api/theme/add/add.mjs +20 -3
  113. package/api/theme/add/add.staging.test.mjs +66 -0
  114. package/api/theme/add/add.test.mjs +14 -1
  115. package/api/theme/build/build.mjs +133 -42
  116. package/api/theme/build/build.public-component-vars.test.mjs +1 -1
  117. package/api/theme/build/build.receipt-doc.test.mjs +111 -0
  118. package/api/theme/build/build.test.mjs +127 -0
  119. package/api/theme/build/font-warning.mjs +3 -3
  120. package/api/theme/build/font-warning.test.mjs +5 -2
  121. package/api/theme/generateTonalPalette.doc.mjs +1 -0
  122. package/api/theme/integration-themes.test.mjs +39 -28
  123. package/api/theme/list/list.test.mjs +19 -20
  124. package/api/theme/listThemes.doc.mjs +6 -5
  125. package/api/theme/palette/generate/generate.mjs +8 -3
  126. package/api/theme/palette/generate/generate.test.mjs +96 -0
  127. package/api/theme/palette/generate/generator.d.mts +10 -13
  128. package/api/theme/palette/generate/generator.mjs +15 -4
  129. package/api/theme/palette/generate/generator.test.mjs +10 -0
  130. package/api/theme/template/template.mjs +11 -2
  131. package/api/theme/template/template.test.mjs +15 -0
  132. package/api/theme/theme.type.d.mts +170 -11
  133. package/api/theme/theme.type.mjs +94 -27
  134. package/api/theme/themeAdd.doc.mjs +4 -3
  135. package/api/theme/themeBuild.doc.mjs +8 -4
  136. package/api/theme/themeList.doc.mjs +6 -3
  137. package/api/theme/themeListAvailable.doc.mjs +5 -3
  138. package/api/theme/themePaletteGenerate.doc.mjs +1 -0
  139. package/api/theme/themeTargets.doc.mjs +1 -0
  140. package/api/theme/themeTemplate.doc.mjs +5 -1
  141. package/api/upgrade/_adapter.d.mts +12 -3
  142. package/api/upgrade/_adapter.mjs +123 -19
  143. package/api/upgrade/list/list.mjs +2 -1
  144. package/api/upgrade/list/list.test.mjs +73 -0
  145. package/api/upgrade/project-context.test.mjs +272 -0
  146. package/api/upgrade/provider-agreement.test.mjs +152 -0
  147. package/api/upgrade/run/run.mjs +1 -0
  148. package/api/upgrade/status/status.mjs +2 -2
  149. package/api/upgrade/upgrade.doc.mjs +7 -4
  150. package/api/upgrade/upgrade.type.d.mts +9 -5
  151. package/api/upgrade/upgrade.type.mjs +12 -11
  152. package/assets/codemods/integration-discovery.mjs +48 -4
  153. package/assets/codemods/integration-discovery.test.mjs +73 -0
  154. package/assets/codemods/runner.mjs +115 -5
  155. package/assets/codemods/term-log.mjs +32 -8
  156. package/assets/codemods/term-log.test.mjs +19 -1
  157. package/assets/codemods/transform-prop.mjs +109 -0
  158. package/assets/codemods/transform-prop.test.mjs +95 -0
  159. package/assets/codemods/transforms/next/__tests__/migrate-theme-catalog-to-descriptors.test.mjs +216 -0
  160. package/assets/codemods/transforms/next/index.mjs +11 -1
  161. package/assets/codemods/transforms/next/migrate-theme-catalog-to-descriptors.mjs +141 -0
  162. package/assets/codemods/transforms/v0.0.14/__tests__/rename-status-variants.test.mjs +86 -165
  163. package/assets/codemods/transforms/v0.0.14/rename-status-variants.mjs +72 -210
  164. package/assets/codemods/transforms/v0.1.8/__tests__/rename-avatar-size-scale.test.mjs +83 -115
  165. package/assets/codemods/transforms/v0.1.8/rename-avatar-size-scale.mjs +57 -186
  166. package/assets/codemods/transforms/v0.3.0/__tests__/unwrap-authoring-factories.test.mjs +27 -5
  167. package/assets/codemods/transforms/v0.3.0/unwrap-authoring-factories.mjs +20 -5
  168. package/assets/codemods/transforms/v0.6.0/__tests__/next-codemods.test.mjs +47 -0
  169. package/assets/codemods/transforms/v0.6.0/rename-resizable-pixel-bounds.mjs +57 -10
  170. package/assets/docs/README.md +9 -0
  171. package/assets/docs/authoring.doc.mjs +14 -0
  172. package/assets/docs/cli-integrations.doc.mjs +78 -20
  173. package/assets/docs/cli.doc.mjs +15 -0
  174. package/assets/docs/styling-libraries.doc.mjs +1 -1
  175. package/assets/docs/theme.doc.mjs +1 -1
  176. package/assets/docs/working-with-ai.doc.mjs +1 -1
  177. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaInlineRail.doc.mjs +14 -0
  178. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaInlineRail.tsx +61 -0
  179. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaOverscrollChaining.doc.mjs +14 -0
  180. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaOverscrollChaining.tsx +126 -0
  181. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaShowcase.doc.mjs +15 -0
  182. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaShowcase.tsx +86 -0
  183. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaStickyGroupHeaders.doc.mjs +14 -0
  184. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaStickyGroupHeaders.tsx +99 -0
  185. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaStickyPassthrough.doc.mjs +14 -0
  186. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaStickyPassthrough.tsx +122 -0
  187. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaTwoAxisBoard.doc.mjs +14 -0
  188. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaTwoAxisBoard.tsx +95 -0
  189. package/assets/templates/pages/table-tree/page.tsx +1704 -0
  190. package/assets/templates/pages/table-tree/template.doc.mjs +12 -0
  191. package/assets/templates/themes/butter/butterTheme.doc.mjs +11 -0
  192. package/assets/templates/themes/chocolate/chocolateTheme.doc.mjs +11 -0
  193. package/assets/templates/themes/gothic/gothicTheme.doc.mjs +11 -0
  194. package/assets/templates/themes/matcha/matchaTheme.doc.mjs +11 -0
  195. package/assets/templates/themes/neutral/neutralTheme.doc.mjs +11 -0
  196. package/assets/templates/themes/stone/stoneTheme.doc.mjs +11 -0
  197. package/assets/templates/themes/y2k/y2kTheme.doc.mjs +11 -0
  198. package/authoring/_shared/contract.ts +22 -0
  199. package/authoring/codemod/codemod.doc.mjs +7 -2
  200. package/authoring/codemod/parse.d.mts +8 -8
  201. package/authoring/codemod/parse.mjs +8 -6
  202. package/authoring/config/config.doc.mjs +2 -2
  203. package/authoring/config/debug-composition.test.mjs +92 -0
  204. package/authoring/config/parse.d.mts +13 -13
  205. package/authoring/config/parse.mjs +8 -8
  206. package/authoring/config/type.ts +18 -6
  207. package/authoring/debug/debug.doc.d.mts +11 -0
  208. package/authoring/debug/debug.doc.mjs +182 -0
  209. package/authoring/debug/parse.d.mts +5 -5
  210. package/authoring/debug/parse.mjs +3 -3
  211. package/authoring/doctypes/_schema.d.mts +788 -23
  212. package/authoring/doctypes/_schema.mjs +492 -39
  213. package/authoring/doctypes/base/graph-fields.doc.d.mts +9 -0
  214. package/authoring/doctypes/base/graph-fields.doc.mjs +62 -0
  215. package/authoring/doctypes/base/type.ts +40 -0
  216. package/authoring/doctypes/command/command.doc.mjs +4 -3
  217. package/authoring/doctypes/command/parse.d.mts +2 -2
  218. package/authoring/doctypes/command/parse.mjs +1 -1
  219. package/authoring/doctypes/command/type.ts +4 -3
  220. package/authoring/doctypes/component/component.doc.mjs +6 -3
  221. package/authoring/doctypes/component/parse.d.mts +2 -2
  222. package/authoring/doctypes/component/parse.mjs +1 -1
  223. package/authoring/doctypes/component/type.ts +6 -5
  224. package/authoring/doctypes/doctypes-new.test.mjs +48 -6
  225. package/authoring/doctypes/enum/enum.doc.mjs +1 -1
  226. package/authoring/doctypes/enum/parse.d.mts +2 -2
  227. package/authoring/doctypes/enum/parse.mjs +1 -1
  228. package/authoring/doctypes/enum/type.ts +4 -2
  229. package/authoring/doctypes/function/function.doc.mjs +5 -1
  230. package/authoring/doctypes/function/parse.d.mts +2 -2
  231. package/authoring/doctypes/function/parse.mjs +1 -1
  232. package/authoring/doctypes/function/type.ts +7 -3
  233. package/authoring/doctypes/hook/hook.doc.mjs +4 -0
  234. package/authoring/doctypes/hook/parse.d.mts +2 -2
  235. package/authoring/doctypes/hook/parse.mjs +1 -1
  236. package/authoring/doctypes/hook/type.ts +5 -4
  237. package/authoring/doctypes/legacy.d.mts +8 -6
  238. package/authoring/doctypes/legacy.mjs +5 -4
  239. package/authoring/doctypes/load-contract.test.mjs +208 -0
  240. package/authoring/doctypes/namespace/namespace.doc.d.mts +9 -0
  241. package/authoring/doctypes/namespace/namespace.doc.mjs +132 -0
  242. package/authoring/doctypes/namespace/parse.d.mts +12 -0
  243. package/authoring/doctypes/namespace/parse.mjs +25 -0
  244. package/authoring/doctypes/namespace/parse.test.mjs +165 -0
  245. package/authoring/doctypes/namespace/type.ts +71 -0
  246. package/authoring/doctypes/parse.d.mts +22 -18
  247. package/authoring/doctypes/parse.mjs +22 -12
  248. package/authoring/doctypes/parse.test.mjs +77 -3
  249. package/authoring/doctypes/reference/parse.d.mts +2 -2
  250. package/authoring/doctypes/reference/parse.mjs +8 -5
  251. package/authoring/doctypes/reference/reference.doc.mjs +18 -5
  252. package/authoring/doctypes/reference/type.ts +53 -7
  253. package/authoring/doctypes/schema/parse.d.mts +2 -2
  254. package/authoring/doctypes/schema/parse.mjs +1 -1
  255. package/authoring/doctypes/schema/schema.doc.mjs +1 -1
  256. package/authoring/doctypes/schema/type.ts +4 -4
  257. package/authoring/doctypes/template/parse.d.mts +92 -1
  258. package/authoring/doctypes/template/parse.mjs +36 -2
  259. package/authoring/doctypes/template/parse.test.mjs +8 -2
  260. package/authoring/doctypes/template/template.doc.mjs +7 -3
  261. package/authoring/doctypes/template/type.ts +5 -2
  262. package/authoring/doctypes/theme/parse.d.mts +35 -0
  263. package/authoring/doctypes/theme/parse.mjs +76 -0
  264. package/authoring/doctypes/theme/theme.doc.d.mts +9 -0
  265. package/authoring/doctypes/theme/theme.doc.mjs +79 -0
  266. package/authoring/doctypes/theme/type.ts +42 -0
  267. package/authoring/doctypes/types.ts +12 -10
  268. package/authoring/gap-report/gap-report.doc.d.mts +12 -0
  269. package/authoring/gap-report/gap-report.doc.mjs +183 -0
  270. package/authoring/gap-report/parse.d.mts +10 -10
  271. package/authoring/gap-report/parse.mjs +6 -6
  272. package/authoring/gap-report/type.ts +1 -1
  273. package/authoring/identity/identity.doc.d.mts +9 -0
  274. package/authoring/identity/identity.doc.mjs +61 -0
  275. package/authoring/identity/type.ts +132 -0
  276. package/authoring/index.d.mts +2 -0
  277. package/authoring/index.d.ts +51 -17
  278. package/authoring/index.mjs +3 -1
  279. package/authoring/integration/integration.doc.mjs +15 -8
  280. package/authoring/integration/parse.d.mts +2 -2
  281. package/authoring/integration/parse.mjs +1 -1
  282. package/authoring/integration/parse.test.mjs +10 -1
  283. package/authoring/integration/schema.d.mts +6 -4
  284. package/authoring/integration/schema.mjs +9 -3
  285. package/authoring/integration/type.ts +18 -7
  286. package/authoring/shadcn/receipt.d.mts +6 -6
  287. package/clients/cli/__tests__/cliManifest.test.ts +27 -29
  288. package/clients/cli/command-load-failure.test.mjs +83 -0
  289. package/clients/cli/commands/blog.doc.mjs +1 -1
  290. package/clients/cli/commands/blog.mjs +23 -8
  291. package/clients/cli/commands/blog.test.mjs +42 -1
  292. package/clients/cli/commands/build-theme.ascii-output.test.mjs +161 -0
  293. package/clients/cli/commands/build-theme.flag-docs.test.mjs +110 -0
  294. package/clients/cli/commands/build-theme.mjs +5 -5
  295. package/clients/cli/commands/build-theme.path-safety.test.mjs +86 -1
  296. package/clients/cli/commands/build-theme.variants.test.mjs +76 -0
  297. package/clients/cli/commands/build.doc.mjs +5 -2
  298. package/clients/cli/commands/build.exit-codes-doc.test.mjs +50 -0
  299. package/clients/cli/commands/build.mjs +32 -47
  300. package/clients/cli/commands/build.playbook.test.mjs +75 -0
  301. package/clients/cli/commands/build.text-fields.test.mjs +40 -0
  302. package/clients/cli/commands/component/index.mjs +2 -7
  303. package/clients/cli/commands/component-package.test.mjs +46 -0
  304. package/clients/cli/commands/component-resolution.test.mjs +21 -0
  305. package/clients/cli/commands/component.doc.mjs +1 -1
  306. package/clients/cli/commands/component.test.mjs +19 -0
  307. package/clients/cli/commands/detail-levels.test.mjs +2 -2
  308. package/clients/cli/commands/discover.broken-integration.test.mjs +48 -0
  309. package/clients/cli/commands/discover.components-flag.test.mjs +97 -0
  310. package/clients/cli/commands/discover.doc.mjs +5 -3
  311. package/clients/cli/commands/discover.mjs +3 -3
  312. package/clients/cli/commands/discover.text-projection.test.mjs +103 -0
  313. package/clients/cli/commands/docs.doc.mjs +14 -4
  314. package/clients/cli/commands/docs.mjs +121 -21
  315. package/clients/cli/commands/docs.test.mjs +88 -0
  316. package/clients/cli/commands/doctor-integration-components.doc.mjs +1 -1
  317. package/clients/cli/commands/doctor-integration-docs.doc.mjs +1 -1
  318. package/clients/cli/commands/doctor-integration-templates.doc.mjs +1 -1
  319. package/clients/cli/commands/doctor-integration-validate.doc.mjs +1 -1
  320. package/clients/cli/commands/doctor-integration.doc.mjs +1 -1
  321. package/clients/cli/commands/doctor-integration.package-json.test.mjs +53 -0
  322. package/clients/cli/commands/doctor-integration.test.mjs +15 -7
  323. package/clients/cli/commands/doctor.doc.mjs +1 -1
  324. package/clients/cli/commands/doctor.mjs +6 -16
  325. package/clients/cli/commands/doctor.test.mjs +42 -0
  326. package/clients/cli/commands/gap-report.doc.mjs +17 -6
  327. package/clients/cli/commands/gap-report.test.mjs +72 -0
  328. package/clients/cli/commands/hook/index.mjs +7 -17
  329. package/clients/cli/commands/hook.doc.mjs +1 -1
  330. package/clients/cli/commands/hook.text-projection.test.mjs +45 -0
  331. package/clients/cli/commands/init.doc.mjs +20 -9
  332. package/clients/cli/commands/init.flag-help.test.mjs +153 -0
  333. package/clients/cli/commands/integration-add.controls.test.mjs +132 -0
  334. package/clients/cli/commands/integration-add.doc.mjs +22 -6
  335. package/clients/cli/commands/integration-authoring.test.mjs +13 -9
  336. package/clients/cli/commands/integration-pack.doc.mjs +1 -1
  337. package/clients/cli/commands/integration-real-world.test.mjs +3 -9
  338. package/clients/cli/commands/integration.doc.mjs +1 -1
  339. package/clients/cli/commands/interactive-guard.test.mjs +101 -24
  340. package/clients/cli/commands/json-contract.test.mjs +33 -0
  341. package/clients/cli/commands/layout-check.doc.mjs +15 -4
  342. package/clients/cli/commands/layout-expand.doc.mjs +22 -5
  343. package/clients/cli/commands/layout-grammar.doc.mjs +1 -1
  344. package/clients/cli/commands/layout.doc.mjs +3 -3
  345. package/clients/cli/commands/layout.mjs +21 -9
  346. package/clients/cli/commands/layout.path-help.test.mjs +33 -0
  347. package/clients/cli/commands/layout.stdin-cap.test.mjs +47 -0
  348. package/clients/cli/commands/layout.text-fields.test.mjs +39 -0
  349. package/clients/cli/commands/manifest.doc.mjs +1 -1
  350. package/clients/cli/commands/no-prompt-wording.test.mjs +94 -0
  351. package/clients/cli/commands/search.doc.mjs +7 -4
  352. package/clients/cli/commands/search.mjs +17 -7
  353. package/clients/cli/commands/search.test.mjs +75 -0
  354. package/clients/cli/commands/swizzle.doc.mjs +3 -2
  355. package/clients/cli/commands/swizzle.path-safety.test.mjs +42 -0
  356. package/clients/cli/commands/template.doc.mjs +29 -7
  357. package/clients/cli/commands/template.flag-help.test.mjs +117 -0
  358. package/clients/cli/commands/template.path-help.test.mjs +40 -0
  359. package/clients/cli/commands/theme-add.doc.mjs +4 -3
  360. package/clients/cli/commands/theme-build.doc.mjs +8 -7
  361. package/clients/cli/commands/theme-list.doc.mjs +2 -2
  362. package/clients/cli/commands/theme-palette-generate.doc.mjs +9 -5
  363. package/clients/cli/commands/theme-palette-generate.test.mjs +19 -0
  364. package/clients/cli/commands/theme-palette.doc.mjs +1 -1
  365. package/clients/cli/commands/theme-targets.doc.mjs +1 -1
  366. package/clients/cli/commands/theme-template.behavior.test.mjs +12 -0
  367. package/clients/cli/commands/theme-template.doc.mjs +2 -2
  368. package/clients/cli/commands/theme.doc.mjs +1 -1
  369. package/clients/cli/commands/upgrade.ascii-output.test.mjs +87 -0
  370. package/clients/cli/commands/upgrade.doc.mjs +20 -9
  371. package/clients/cli/commands/upgrade.flag-help.test.mjs +188 -0
  372. package/clients/cli/commands/upgrade.hook-output.test.mjs +88 -0
  373. package/clients/cli/formatters/index.mjs +162 -1
  374. package/clients/cli/formatters/index.test.mjs +91 -0
  375. package/clients/cli/index.mjs +13 -30
  376. package/clients/cli/latest-version-env.test.mjs +50 -0
  377. package/clients/cli/lib/cli-error.test.mjs +7 -0
  378. package/clients/cli/lib/component-format.mjs +9 -9
  379. package/clients/cli/lib/component-format.test.mjs +1 -1
  380. package/clients/cli/lib/define-command.mjs +32 -6
  381. package/clients/cli/lib/doc-text-ascii.test.mjs +82 -0
  382. package/clients/cli/lib/exit-codes.test.mjs +97 -0
  383. package/clients/cli/lib/hook-format.mjs +19 -10
  384. package/clients/cli/lib/json-shim.mjs +38 -2
  385. package/clients/cli/lib/json-shim.test.mjs +83 -0
  386. package/clients/cli/lib/manifest.d.ts +2 -0
  387. package/clients/cli/lib/manifest.mjs +29 -2
  388. package/clients/cli/lib/manifest.test.mjs +17 -0
  389. package/foundation/agent-docs/agent-docs.d.mts +4 -0
  390. package/foundation/agent-docs/agent-docs.mjs +69 -3
  391. package/foundation/agent-docs/agent-docs.path-safety.test.mjs +266 -4
  392. package/foundation/config/integration-debug.test.mjs +28 -3
  393. package/foundation/config/project-themes.test.mjs +11 -19
  394. package/foundation/config/project.d.mts +8 -0
  395. package/foundation/config/project.mjs +190 -32
  396. package/foundation/config/project.test.mjs +129 -16
  397. package/foundation/discovery/authoring-self-docs.d.mts +75 -0
  398. package/foundation/discovery/authoring-self-docs.mjs +224 -0
  399. package/foundation/discovery/authoring-self-docs.test.mjs +154 -0
  400. package/foundation/discovery/authoring-surface.d.mts +74 -0
  401. package/foundation/discovery/authoring-surface.mjs +525 -0
  402. package/foundation/discovery/authoring-surface.test.mjs +392 -0
  403. package/foundation/discovery/cli-self-docs.d.mts +113 -0
  404. package/foundation/discovery/cli-self-docs.mjs +514 -0
  405. package/foundation/discovery/cli-self-docs.test.mjs +437 -0
  406. package/foundation/discovery/component-discovery.d.mts +1 -1
  407. package/foundation/discovery/component-discovery.mjs +2 -1
  408. package/foundation/discovery/component-loader.d.mts +35 -38
  409. package/foundation/discovery/component-loader.mjs +53 -222
  410. package/foundation/discovery/docs-discovery.d.mts +12 -4
  411. package/foundation/discovery/docs-discovery.mjs +214 -98
  412. package/foundation/discovery/docs-discovery.test.mjs +284 -15
  413. package/foundation/discovery/docs-output-budget.d.mts +28 -0
  414. package/foundation/discovery/docs-output-budget.mjs +50 -0
  415. package/foundation/discovery/docs-section-key.d.mts +98 -0
  416. package/foundation/discovery/docs-section-key.mjs +221 -0
  417. package/foundation/discovery/docs-section-key.test.mjs +224 -0
  418. package/foundation/discovery/template-adapter.d.mts +21 -5
  419. package/foundation/discovery/template-adapter.fixture-refs.test.mjs +248 -0
  420. package/foundation/discovery/template-adapter.integration-isolation.test.mjs +94 -0
  421. package/foundation/discovery/template-adapter.mjs +321 -66
  422. package/foundation/discovery/template-adapter.test.mjs +15 -0
  423. package/foundation/discovery/theme-discovery.d.mts +67 -7
  424. package/foundation/discovery/theme-discovery.mjs +916 -186
  425. package/foundation/discovery/theme-discovery.test.mjs +613 -219
  426. package/foundation/discovery/theming-targets.test.mjs +4 -0
  427. package/foundation/doc-compiler/bundle.d.mts +47 -0
  428. package/foundation/doc-compiler/bundle.mjs +218 -0
  429. package/foundation/doc-compiler/bundle.test.mjs +255 -0
  430. package/foundation/doc-compiler/compile.d.mts +362 -0
  431. package/foundation/doc-compiler/compile.mjs +511 -0
  432. package/foundation/doc-compiler/diagnostics.d.mts +126 -0
  433. package/foundation/doc-compiler/diagnostics.mjs +277 -0
  434. package/foundation/doc-compiler/doc-compiler.test.mjs +714 -0
  435. package/foundation/doc-compiler/doc-loads.test.mjs +1642 -0
  436. package/foundation/doc-compiler/import.d.mts +24 -0
  437. package/foundation/doc-compiler/import.mjs +59 -0
  438. package/foundation/doc-compiler/inputs.d.mts +102 -0
  439. package/foundation/doc-compiler/inputs.mjs +286 -0
  440. package/foundation/doc-compiler/inputs.test.mjs +299 -0
  441. package/foundation/doc-compiler/ir.d.mts +22 -0
  442. package/foundation/doc-compiler/ir.mjs +464 -0
  443. package/foundation/doc-compiler/lenses.d.mts +33 -0
  444. package/foundation/doc-compiler/lenses.mjs +127 -0
  445. package/foundation/doc-compiler/lower-doc.test.mjs +492 -0
  446. package/foundation/doc-compiler/overlays.d.mts +37 -0
  447. package/foundation/doc-compiler/overlays.mjs +206 -0
  448. package/foundation/doc-compiler/parse-readable.d.mts +9 -0
  449. package/foundation/doc-compiler/parse-readable.mjs +29 -0
  450. package/foundation/doc-compiler/read.d.mts +126 -0
  451. package/foundation/doc-compiler/read.mjs +320 -0
  452. package/foundation/doc-compiler/read.test.mjs +313 -0
  453. package/foundation/doc-compiler/source.d.mts +33 -0
  454. package/foundation/doc-compiler/source.mjs +128 -0
  455. package/foundation/fs/module-loader.d.mts +1 -0
  456. package/foundation/fs/module-loader.mjs +50 -1
  457. package/foundation/fs/module-loader.stdout.test.mjs +332 -0
  458. package/foundation/fs/path-safety.d.mts +3 -2
  459. package/foundation/fs/path-safety.mjs +49 -19
  460. package/foundation/fs/path-safety.test.mjs +50 -0
  461. package/foundation/fs/publish-file-hardlink-unavailable.test.mjs +129 -94
  462. package/foundation/identity/provider-identity.d.mts +90 -0
  463. package/foundation/identity/provider-identity.mjs +320 -0
  464. package/foundation/identity/provider-identity.test.mjs +254 -0
  465. package/foundation/identity/providers.d.mts +7 -0
  466. package/foundation/identity/providers.mjs +16 -0
  467. package/foundation/integrations/autolink.d.mts +58 -1
  468. package/foundation/integrations/autolink.mjs +143 -45
  469. package/foundation/integrations/contribution-fixes.d.mts +145 -0
  470. package/foundation/integrations/contribution-fixes.mjs +1284 -0
  471. package/foundation/integrations/contribution-inventory.d.mts +1 -1
  472. package/foundation/integrations/contribution-inventory.mjs +17 -20
  473. package/foundation/integrations/contribution-inventory.test.mjs +67 -27
  474. package/foundation/integrations/integration-warnings.mjs +6 -0
  475. package/foundation/integrations/integrations.d.mts +49 -2
  476. package/foundation/integrations/integrations.mjs +81 -8
  477. package/foundation/integrations/integrations.test.mjs +384 -1
  478. package/foundation/integrations/provider-conflicts.test.mjs +125 -0
  479. package/foundation/integrations/provider-ledger.test.mjs +275 -0
  480. package/foundation/integrations/provider-resolution.d.mts +152 -0
  481. package/foundation/integrations/provider-resolution.mjs +576 -0
  482. package/foundation/integrations/provider-resolution.test.mjs +369 -0
  483. package/foundation/integrations/theme-descriptor.d.mts +8 -0
  484. package/foundation/integrations/theme-descriptor.mjs +44 -0
  485. package/foundation/integrations/validate-contributions.d.mts +2 -0
  486. package/foundation/integrations/validate-contributions.mjs +114 -10
  487. package/foundation/response/base.d.ts +8 -4
  488. package/foundation/response/error-codes.doc.mjs +3 -4
  489. package/foundation/response/error-codes.mjs +2 -2
  490. package/foundation/response/error-codes.test.mjs +83 -0
  491. package/foundation/response/json-contract.test.mjs +57 -17
  492. package/foundation/response/json.d.mts +4 -2
  493. package/foundation/response/json.mjs +8 -10
  494. package/foundation/response/response-types.doc.mjs +16 -11
  495. package/foundation/response/response-types.doc.test.mjs +158 -0
  496. package/foundation/response/response.doc.mjs +1 -1
  497. package/foundation/text/string-utils.mjs +22 -10
  498. package/foundation/xle/expand.d.mts +2 -0
  499. package/foundation/xle/expand.mjs +3 -2
  500. package/foundation/xle/expand.test.mjs +54 -0
  501. package/package.json +9 -11
  502. package/assets/templates/themes/manifest.json +0 -95
  503. package/clients/cli/lib/update-check.mjs +0 -83
  504. package/clients/cli/lib/update-check.test.mjs +0 -137
  505. package/clients/cli/update-hint-commands.test.mjs +0 -54
@@ -23,14 +23,16 @@
23
23
 
24
24
  import * as fs from 'node:fs';
25
25
  import * as path from 'node:path';
26
- import {createJiti} from 'jiti';
27
- import {loadModuleWithParser} from '../fs/module-loader.mjs';
28
- import {parseTemplate} from '../../authoring/doctypes/template/parse.mjs';
26
+ import {createRequire} from 'node:module';
27
+ import {readDocView} from '../doc-compiler/read.mjs';
29
28
  import {CLI_ROOT, discoverExternalPackages} from '../fs/paths.mjs';
29
+ import {CORE_PROVIDER_ID} from '../identity/providers.mjs';
30
30
  import {Project} from '../config/project.mjs';
31
31
 
32
+ const require = createRequire(import.meta.url);
33
+
32
34
  /** Identity used for core (built-in) templates in package-scoped listings. */
33
- const CORE_PACKAGE = '@astryxdesign/core';
35
+ const CORE_PACKAGE = CORE_PROVIDER_ID;
34
36
 
35
37
  /**
36
38
  * Identity for a template in package-scoped views. Core (built-in) templates
@@ -80,31 +82,28 @@ export function pkgOf(t) {
80
82
  */
81
83
 
82
84
  /**
83
- * Canonical basename suffixes for template-spec files, in precedence order.
84
- * A template spec is a scaffoldable TEMPLATE (a plain object stamped with a
85
- * `type` of `'page'` or `'block'`), so `.template.*` is the descriptive family
86
- * name.
85
+ * Released compatibility suffixes, in precedence order. Stable 0.6.0
86
+ * documented `.template.*`, so discovery keeps reading those files while all
87
+ * new authoring uses `.doc.mjs`.
87
88
  */
88
89
  const TEMPLATE_SUFFIXES = ['.template.ts', '.template.mjs', '.template.js'];
89
90
 
90
91
  /**
91
- * Legacy basename suffixes for template-spec files, in precedence order.
92
- * `.doc.*` was inherited from the component-doc convention before templates
93
- * had their own name; it is still accepted during the transition window.
92
+ * Descriptor suffixes for templates, in precedence order. New authoring always
93
+ * emits `.doc.mjs`; the TypeScript and JavaScript variants remain readable.
94
94
  */
95
95
  const DOC_SUFFIXES = ['.doc.ts', '.doc.mjs', '.doc.js'];
96
96
 
97
97
  /**
98
- * The union of canonical + legacy template-spec suffixes, canonical first so
99
- * `.template.*` wins over `.doc.*` when both stems exist. All template
100
- * discovery matches this union so a `Foo.template.ts` file is treated exactly
101
- * like a legacy `Foo.doc.mjs`.
98
+ * Every template-spec suffix, in the released precedence a core page directory
99
+ * uses to pick one file. Integration discovery never picks: every match is a
100
+ * template, so two specs for one stem list twice and read as ambiguous.
102
101
  */
103
102
  const ALL_TEMPLATE_SUFFIXES = [...TEMPLATE_SUFFIXES, ...DOC_SUFFIXES];
104
103
 
105
104
  /**
106
105
  * The template-spec suffix present on `file`, or null if none matches.
107
- * Recognizes both the canonical `.template.*` and legacy `.doc.*` families.
106
+ * Recognizes both the canonical `.doc.*` and released `.template.*` families.
108
107
  * @param {string} file
109
108
  * @returns {string | null}
110
109
  */
@@ -118,16 +117,6 @@ function matchedTemplateSuffix(file) {
118
117
  */
119
118
  const TEMPLATE_SUFFIX_RE = /\.(template|doc)\.(ts|mjs|js)$/;
120
119
 
121
- /** @type {ReturnType<typeof createJiti> | undefined} */
122
- let jitiInstance;
123
- /** Lazily-created jiti for loading `.ts` template specs (JSX-capable). */
124
- function getJiti() {
125
- if (!jitiInstance) {
126
- jitiInstance = createJiti(import.meta.url, {jsx: true});
127
- }
128
- return jitiInstance;
129
- }
130
-
131
120
  /**
132
121
  * Load an integration template doc module and validate it against the template
133
122
  * envelope at the load boundary. Default export only — `.ts` via jiti,
@@ -140,7 +129,13 @@ function getJiti() {
140
129
  * @param {string} [label]
141
130
  */
142
131
  async function loadIntegrationDoc(file, label) {
143
- return loadModuleWithParser(file, parseTemplate, {label});
132
+ return readDocView(file, {
133
+ root: 'templates',
134
+ exports: ['default'],
135
+ label: label ?? file,
136
+ strict: true,
137
+ value: 'parsed',
138
+ });
144
139
  }
145
140
 
146
141
  const TEMPLATES_DIR = path.join(CLI_ROOT, 'assets', 'templates');
@@ -184,17 +179,53 @@ const IMAGE_EXTENSIONS = new Set([
184
179
  ]);
185
180
 
186
181
  /**
187
- * Demo-asset sources to strip from scaffolded projects. Template demo imagery
182
+ * First path segment of every Astryx template fixture. Template demo imagery
188
183
  * is self-hosted under the docsite's `/template-assets/*` dir (committed there,
189
- * mirrored into the sandbox preview by scripts/sync-templates.js). Those paths
190
- * only resolve inside the Astryx docsite/sandbox, so on scaffold they're
191
- * replaced — a scaffolded project has no `/template-assets/` dir and would
192
- * otherwise 404. Genuine third-party URLs (e.g. brand logos from
193
- * paypalobjects.com) are intentionally left untouched.
194
- *
195
- * @type {RegExp}
184
+ * mirrored into the sandbox preview by scripts/sync-templates.js), so those
185
+ * paths only resolve inside the Astryx docsite/sandbox and are replaced on
186
+ * scaffold. Only a root-relative URL whose first segment this is counts: the
187
+ * same text inside a third-party URL or a product path is left untouched.
196
188
  */
197
- const DEMO_ASSET_PATTERN = /\/template-assets\/[\w.-]+\.(\w+)/g;
189
+ const FIXTURE_SEGMENT = 'template-assets';
190
+
191
+ /** Characters that end a URL token in template source, besides whitespace. */
192
+ const TOKEN_DELIMITERS = new Set([
193
+ "'",
194
+ '"',
195
+ '`',
196
+ '(',
197
+ ')',
198
+ '<',
199
+ '>',
200
+ '{',
201
+ '}',
202
+ '[',
203
+ ']',
204
+ '\\',
205
+ '|',
206
+ '^',
207
+ ]);
208
+
209
+ /** The closing delimiter each opening delimiter must pair with. */
210
+ const CLOSING_DELIMITERS = new Map([
211
+ ["'", "'"],
212
+ ['"', '"'],
213
+ ['`', '`'],
214
+ ['(', ')'],
215
+ ]);
216
+ const CLOSERS = new Set(CLOSING_DELIMITERS.values());
217
+
218
+ /** A URL with a scheme: absolute, so never a fixture reference. */
219
+ const ABSOLUTE_URL = /^[a-z][a-z\d+.-]*:/iu;
220
+
221
+ /** What may lead up to the fixture segment inside a relative product path. */
222
+ const RELATIVE_PATH_PREFIX = /^[\w.~%@/-]+$/u;
223
+
224
+ /** Punctuation that ends a sentence or list item after a path in text. */
225
+ const PROSE_PUNCTUATION = new Set(['.', ',', ';', ':', '!', '?']);
226
+
227
+ /** `from`, `import` or `require` right before a quoted module specifier. */
228
+ const MODULE_SPECIFIER_LEAD = /(?:^|[^\w$])(?:from|import|require)\s*\(?$/u;
198
229
 
199
230
  /**
200
231
  * Normalize path into Unix path (using forward slashes) for consistent comparison
@@ -208,36 +239,255 @@ function toPosixPath(p) {
208
239
  }
209
240
 
210
241
  /**
211
- * Replace demo asset references with a placeholder so scaffolded pages
212
- * render with zero setup. Images get a self-contained data URI; videos
213
- * (which have no equivalent inline placeholder — see VIDEO_EXTENSIONS) are
214
- * stripped to an empty src instead of being mis-replaced with image data.
215
- * Builders drop in their own media either way.
242
+ * Replace each Astryx template fixture reference with a placeholder so
243
+ * scaffolded pages render with zero setup. Images get a self-contained data
244
+ * URI; videos (which have no equivalent inline placeholder — see
245
+ * VIDEO_EXTENSIONS) are stripped to an empty src instead of being
246
+ * mis-replaced with image data. Builders drop in their own media either way.
247
+ *
248
+ * A reference is a URL token that resolves to a root-relative path under
249
+ * FIXTURE_SEGMENT. It is replaced whole, query and fragment included, and
250
+ * classified by the suffix of its last path segment. A reference that cannot
251
+ * be replaced safely throws with its path rather than being guessed at or
252
+ * left behind. Prose is left as written: in text (JSX text, a word inside a
253
+ * longer string) trailing punctuation is not part of a path and a path with
254
+ * no suffix, such as the bare directory, is a mention; inside a comment
255
+ * nothing throws.
216
256
  *
217
257
  * @param {string} source - Template source code.
218
258
  * @returns {string} Source with demo asset references replaced.
219
259
  */
220
260
  export function stripTemplateAssetRefs(source) {
221
- return source.replace(DEMO_ASSET_PATTERN, (match, extension) => {
222
- const ext = extension.toLowerCase();
223
- if (VIDEO_EXTENSIONS.has(ext)) {
224
- return '';
261
+ const needle = `/${FIXTURE_SEGMENT}`;
262
+ let output = '';
263
+ let copied = 0;
264
+ /** @type {Array<[number, number]> | undefined} */
265
+ let comments;
266
+ let at = source.indexOf(needle);
267
+ while (at !== -1) {
268
+ let start = at;
269
+ while (start > 0 && !isTokenDelimiter(source[start - 1])) start--;
270
+ let end = at + needle.length;
271
+ while (end < source.length && !isTokenDelimiter(source[end])) end++;
272
+ /** @type {{text: string, end: number} | null} */
273
+ let edit;
274
+ try {
275
+ edit = fixtureEdit(source, start, at, end);
276
+ } catch (err) {
277
+ comments ??= commentRanges(source);
278
+ if (!comments.some(([from, to]) => from <= at && at < to)) throw err;
279
+ edit = null;
225
280
  }
226
- if (IMAGE_EXTENSIONS.has(ext)) {
227
- return PLACEHOLDER_IMAGE;
281
+ if (edit) {
282
+ output += source.slice(copied, start) + edit.text;
283
+ copied = edit.end;
228
284
  }
229
- throw new Error(`Unrecognized template asset format ${ext} for ${match}`);
230
- });
285
+ at = source.indexOf(needle, end);
286
+ }
287
+ return output + source.slice(copied);
288
+ }
289
+
290
+ /** @param {string | undefined} char */
291
+ function isTokenDelimiter(char) {
292
+ return char === undefined || /\s/u.test(char) || TOKEN_DELIMITERS.has(char);
293
+ }
294
+
295
+ /**
296
+ * Whitespace, the source edge, or a tag bracket: what bounds a word of text.
297
+ * @param {string | undefined} char
298
+ */
299
+ function isTextDelimiter(char) {
300
+ return char === undefined || /\s/u.test(char) || char === '<' || char === '>';
301
+ }
302
+
303
+ /**
304
+ * The path segments of a root-relative URL under FIXTURE_SEGMENT, or null.
305
+ * @param {string} reference
306
+ * @returns {string[] | null}
307
+ */
308
+ function fixtureSegments(reference) {
309
+ if (!reference.startsWith('/') || reference.startsWith('//')) return null;
310
+ const segments = new URL(reference, 'http://template.invalid').pathname.split(
311
+ '/',
312
+ );
313
+ return segments[1] === FIXTURE_SEGMENT ? segments : null;
314
+ }
315
+
316
+ /**
317
+ * The replacement for the fixture reference in the URL token [start, end),
318
+ * which contains FIXTURE_SEGMENT's path at `at`; null when the token is not a
319
+ * fixture reference or is a prose mention.
320
+ * @param {string} source
321
+ * @param {number} start
322
+ * @param {number} at
323
+ * @param {number} end
324
+ * @returns {{text: string, end: number} | null}
325
+ */
326
+ function fixtureEdit(source, start, at, end) {
327
+ const token = source.slice(start, end);
328
+ if (ABSOLUTE_URL.test(token)) return null;
329
+ if (!token.startsWith('/')) {
330
+ if (!fixtureSegments(source.slice(at, end))) return null;
331
+ if (
332
+ source[start - 1] !== '\\' &&
333
+ RELATIVE_PATH_PREFIX.test(source.slice(start, at))
334
+ ) {
335
+ return null;
336
+ }
337
+ throw unsafeFixtureReference(
338
+ source,
339
+ at,
340
+ 'it is joined to text the copy cannot parse',
341
+ );
342
+ }
343
+
344
+ const before = source[start - 1];
345
+ const after = source[end];
346
+ if (after === '{' && token.endsWith('$')) {
347
+ if (!fixtureSegments(token.slice(0, -1))) return null;
348
+ throw unsafeFixtureReference(
349
+ source,
350
+ at,
351
+ 'it is built by a template-literal interpolation',
352
+ );
353
+ }
354
+ const quoted =
355
+ before !== undefined && CLOSING_DELIMITERS.get(before) === after;
356
+ const escapedQuoted =
357
+ (before === "'" || before === '"') &&
358
+ source[start - 2] === '\\' &&
359
+ after === '\\' &&
360
+ source[end + 1] === before;
361
+ const whole = quoted || escapedQuoted;
362
+ let referenceEnd = end;
363
+ if (!whole) {
364
+ while (
365
+ referenceEnd > at &&
366
+ PROSE_PUNCTUATION.has(source[referenceEnd - 1])
367
+ ) {
368
+ referenceEnd--;
369
+ }
370
+ }
371
+ const segments = fixtureSegments(source.slice(start, referenceEnd));
372
+ if (!segments) return null;
373
+
374
+ const inText =
375
+ (isTextDelimiter(before) || CLOSING_DELIMITERS.has(before)) &&
376
+ (isTextDelimiter(after) || CLOSERS.has(after)) &&
377
+ (isTextDelimiter(before) || isTextDelimiter(after));
378
+ if (!whole && !inText) {
379
+ throw unsafeFixtureReference(
380
+ source,
381
+ at,
382
+ 'it is not a whole quoted, url(), or text value',
383
+ );
384
+ }
385
+ if (quoted && before !== '(') {
386
+ const use = expressionUse(source, start - 1, end);
387
+ if (use) throw unsafeFixtureReference(source, at, use);
388
+ }
389
+
390
+ const ext = path.posix
391
+ .extname(segments[segments.length - 1])
392
+ .slice(1)
393
+ .toLowerCase();
394
+ if (VIDEO_EXTENSIONS.has(ext)) return {text: '', end: referenceEnd};
395
+ if (IMAGE_EXTENSIONS.has(ext)) {
396
+ return {text: PLACEHOLDER_IMAGE, end: referenceEnd};
397
+ }
398
+ if (whole || ext) {
399
+ throw new Error(
400
+ `Unrecognized template asset format ${ext || '(none)'} for ${displayReference(source, at)}`,
401
+ );
402
+ }
403
+ return null;
404
+ }
405
+
406
+ /**
407
+ * Why the string quoted at `open` and `close` cannot be replaced on its own,
408
+ * or null when it is a plain value.
409
+ * @param {string} source
410
+ * @param {number} open
411
+ * @param {number} close
412
+ * @returns {string | null}
413
+ */
414
+ function expressionUse(source, open, close) {
415
+ let prev = open - 1;
416
+ while (prev >= 0 && /\s/u.test(source[prev])) prev--;
417
+ let next = close + 1;
418
+ while (next < source.length && /\s/u.test(source[next])) next++;
419
+ if (
420
+ source[prev] === '+' ||
421
+ (source[prev] === '=' && source[prev - 1] === '+') ||
422
+ source[next] === '+'
423
+ ) {
424
+ return 'the string is concatenated with another value';
425
+ }
426
+ if (source[next] === '.' && /[A-Za-z_$]/u.test(source[next + 1] ?? '')) {
427
+ return 'a method is called on the string';
428
+ }
429
+ if (
430
+ MODULE_SPECIFIER_LEAD.test(source.slice(Math.max(0, prev - 16), prev + 1))
431
+ ) {
432
+ return 'it is imported as a module';
433
+ }
434
+ return null;
435
+ }
436
+
437
+ /**
438
+ * The [start, end) range of every comment in `source`, or none when it does
439
+ * not parse as TSX.
440
+ * @param {string} source
441
+ * @returns {Array<[number, number]>}
442
+ */
443
+ function commentRanges(source) {
444
+ try {
445
+ const {parse} = require('@babel/parser');
446
+ const {comments} = parse(source, {
447
+ sourceType: 'module',
448
+ plugins: ['jsx', 'typescript'],
449
+ });
450
+ return (comments ?? []).map(
451
+ comment =>
452
+ /** @type {[number, number]} */ ([
453
+ comment.start ?? 0,
454
+ comment.end ?? 0,
455
+ ]),
456
+ );
457
+ } catch {
458
+ return [];
459
+ }
460
+ }
461
+
462
+ /**
463
+ * The fixture path at `at`, up to the next whitespace, quote, or tag bracket.
464
+ * @param {string} source
465
+ * @param {number} at
466
+ */
467
+ function displayReference(source, at) {
468
+ let end = at;
469
+ while (end < source.length && !/[\s'"`<>]/u.test(source[end])) end++;
470
+ return source.slice(at, end);
471
+ }
472
+
473
+ /**
474
+ * @param {string} source
475
+ * @param {number} at
476
+ * @param {string} reason
477
+ */
478
+ function unsafeFixtureReference(source, at, reason) {
479
+ return new Error(
480
+ `Template asset reference ${displayReference(source, at)} cannot be replaced safely: ${reason}. Use the complete path as one static string.`,
481
+ );
231
482
  }
232
483
  /**
233
484
  * Load a template-spec module and return its metadata object. Supports both
234
485
  * families of suffix:
235
- * - Legacy `.doc.*` core/external specs export `export const doc = {...}`.
236
- * - Canonical `.template.*` specs export the stamped object (`type: 'page' |
237
- * 'block'`) as the default export.
238
- * Prefers the default export, falling back to the named `doc` export, so a
239
- * `Foo.template.ts` (default export) is read identically to a legacy
240
- * `Foo.doc.mjs` (`doc` export). `.ts` is loaded via jiti; `.mjs`/`.js` via a
486
+ * - Canonical `.doc.*` specs may export the stamped object (`type: 'page' |
487
+ * 'block'`) as the default export or use the historical named `doc` export.
488
+ * - Released `.template.*` compatibility specs use the same object shape.
489
+ * Prefers the default export, falling back to the named `doc` export. `.ts` is
490
+ * loaded via jiti; `.mjs`/`.js` via a
241
491
  * native dynamic import. Returns null if the file does not exist.
242
492
  *
243
493
  * @param {string} docPath absolute path to the spec file
@@ -245,10 +495,7 @@ export function stripTemplateAssetRefs(source) {
245
495
  */
246
496
  async function loadDocModule(docPath) {
247
497
  if (!fs.existsSync(docPath)) return null;
248
- const docModule = docPath.endsWith('.ts')
249
- ? await getJiti().import(docPath)
250
- : await import(`file://${docPath}`);
251
- return docModule.default ?? docModule.doc;
498
+ return readDocView(docPath, {root: 'templates', loader: 'template'});
252
499
  }
253
500
 
254
501
  /**
@@ -293,11 +540,11 @@ function findDocFiles(dir, pattern) {
293
540
 
294
541
  /**
295
542
  * Resolve the template-spec file for a core page directory: the first existing
296
- * `template.<suffix>` in canonical-then-legacy precedence, or null.
543
+ * metadata file in {@link ALL_TEMPLATE_SUFFIXES} precedence, or null.
297
544
  * @param {string} dirPath
298
545
  * @returns {string | null}
299
546
  */
300
- function findPageDocFile(dirPath) {
547
+ export function findPageDocFile(dirPath) {
301
548
  for (const suffix of ALL_TEMPLATE_SUFFIXES) {
302
549
  const candidate = path.join(dirPath, `template${suffix}`);
303
550
  if (fs.existsSync(candidate)) return candidate;
@@ -473,7 +720,7 @@ export async function discoverAllWithErrors(cwd = process.cwd()) {
473
720
  /**
474
721
  * Recursively collect integration template-spec files under `root`.
475
722
  * Returns absolute paths to files ending in one of ALL_TEMPLATE_SUFFIXES
476
- * (canonical `.template.*` or legacy `.doc.*`).
723
+ * (canonical `.doc.*` or released `.template.*` compatibility files).
477
724
  *
478
725
  * @param {string} root
479
726
  * @returns {string[]}
@@ -503,7 +750,7 @@ function findIntegrationDocFiles(root) {
503
750
  * Discover templates contributed by configured integrations.
504
751
  *
505
752
  * For each integration with a resolved `templates` root, every
506
- * `<id>.template.{ts,mjs,js}` (or legacy `<id>.doc.{ts,mjs,js}`) file is a
753
+ * canonical `<id>.doc.{mjs,ts,js}` (or released `<id>.template.{ts,mjs,js}`) file is a
507
754
  * template whose id is its path relative to the templates root with the
508
755
  * matched suffix stripped (kebab-case, may be nested). The doc's `type`
509
756
  * (page|block) decides scaffolding — there is no `/pages` vs `/blocks`
@@ -544,9 +791,17 @@ async function discoverIntegrationTemplates(cwd = process.cwd()) {
544
791
  }
545
792
 
546
793
  for (const integration of loadedIntegrations) {
547
- const result = await discoverIntegrationTemplatesForOne(integration);
548
- templates.push(...result.templates);
549
- errors.push(...result.errors);
794
+ // One integration's unreadable root must not cost core or the others theirs.
795
+ try {
796
+ const result = await discoverIntegrationTemplatesForOne(integration);
797
+ templates.push(...result.templates);
798
+ errors.push(...result.errors);
799
+ } catch (err) {
800
+ errors.push({
801
+ package: integration?.name ?? integration?.__spec ?? 'integration',
802
+ message: err instanceof Error ? err.message : String(err),
803
+ });
804
+ }
550
805
  }
551
806
 
552
807
  return {templates, errors};
@@ -18,6 +18,7 @@ import * as os from 'node:os';
18
18
  import * as path from 'node:path';
19
19
  import {
20
20
  extractComponents,
21
+ findPageDocFile,
21
22
  stripTemplateAssetRefs,
22
23
  } from './template-adapter.mjs';
23
24
 
@@ -164,3 +165,17 @@ describe('stripTemplateAssetRefs', () => {
164
165
  );
165
166
  });
166
167
  });
168
+
169
+ describe('findPageDocFile', () => {
170
+ it('keeps the released precedence when one page has two specs', () => {
171
+ const page = fs.mkdtempSync(path.join(dir, 'page-'));
172
+ fs.writeFileSync(path.join(page, 'template.doc.mjs'), 'export {};\n');
173
+ fs.writeFileSync(path.join(page, 'template.doc.ts'), 'export {};\n');
174
+ expect(findPageDocFile(page)).toBe(path.join(page, 'template.doc.ts'));
175
+
176
+ fs.writeFileSync(path.join(page, 'template.template.mjs'), 'export {};\n');
177
+ expect(findPageDocFile(page)).toBe(
178
+ path.join(page, 'template.template.mjs'),
179
+ );
180
+ });
181
+ });
@@ -2,15 +2,65 @@
2
2
  // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
3
 
4
4
  /**
5
- * Read and validate one theme catalog.
6
- * @param {string} themeRoot absolute catalog root
7
- * @param {string} owner package that owns the catalog
8
- * @param {{bundled?: boolean}} [options]
5
+ * How messages about a theme descriptor name it.
6
+ * @param {string} docPath
7
+ * @param {string} owner
8
+ */
9
+ export function themeDescriptorLabel(docPath: string, owner: string): string;
10
+ /**
11
+ * The static value a theme descriptor default-exports, read from its source
12
+ * without executing it. Throws when the file is not one static ThemeDoc
13
+ * object.
14
+ * @param {string} docPath
15
+ * @param {string} label
16
+ * @returns {Record<string, string | boolean>}
17
+ */
18
+ export function readThemeDescriptorValue(docPath: string, label: string): Record<string, string | boolean>;
19
+ /**
20
+ * Whether an entry at any depth of a themes root is outside every theme: a dot
21
+ * entry, or a name npm never publishes (npm-packlist's defaults).
22
+ * @param {string} name
23
+ */
24
+ export function isIgnoredThemeEntry(name: string): boolean;
25
+ /**
26
+ * Whether discovery reads a folder under a theme root as a theme. Dot-folders
27
+ * and folders with neither a descriptor nor a `<name>Theme` source are not.
28
+ * @param {string} folder absolute path
29
+ */
30
+ export function isThemeFolder(folder: string): boolean;
31
+ /**
32
+ * The files one theme folder ships: every regular file below it except
33
+ * {@link isIgnoredThemeEntry} entries. What pack-check requires and what
34
+ * `theme add` copies.
35
+ * @param {string} folder absolute path
36
+ * @returns {string[]} sorted POSIX paths relative to the folder
37
+ */
38
+ export function listThemeFiles(folder: string): string[];
39
+ /**
40
+ * Discover and validate one theme root.
41
+ * @param {string} themeRoot absolute root containing one directory per slug
42
+ * @param {string} owner package that owns the root
43
+ * @param {{bundled?: boolean}} [options] a bundled root is the CLI's own; its
44
+ * sources are checked by the CLI's tests rather than on every read
9
45
  * @returns {DiscoveredTheme[]}
10
46
  */
11
- export function discoverThemeCatalog(themeRoot: string, owner: string, { bundled }?: {
47
+ export function discoverThemeDirectory(themeRoot: string, owner: string, { bundled }?: {
12
48
  bundled?: boolean;
13
49
  }): DiscoveredTheme[];
50
+ /**
51
+ * Folders under a themes root that look like themes (see looksLikeTheme)
52
+ * but that discovery does not read as themes, and that no module elsewhere
53
+ * under the root imports, by a relative path or through the package's own
54
+ * name. Discovery skips them silently, as the released catalog skipped
55
+ * unlisted folders; doctor warns.
56
+ * @param {string} themeRoot
57
+ * @param {{packageDir?: string, packageName?: string}} [owner]
58
+ * @returns {string[]} absolute folder paths, sorted
59
+ */
60
+ export function unreadThemeFolders(themeRoot: string, { packageDir, packageName }?: {
61
+ packageDir?: string;
62
+ packageName?: string;
63
+ }): string[];
14
64
  /** @returns {DiscoveredTheme[]} */
15
65
  export function discoverBundledThemes(): DiscoveredTheme[];
16
66
  /**
@@ -20,8 +70,10 @@ export function discoverBundledThemes(): DiscoveredTheme[];
20
70
  export function discoverIntegrationThemes(integration: import("../integrations/integrations.mjs").LoadedIntegration): Promise<DiscoveredTheme[]>;
21
71
  export const BUNDLED_THEME_PACKAGE: "@astryxdesign/cli";
22
72
  export const THEMES_DIR: string;
23
- export const THEME_MANIFEST_BASENAME: "manifest.json";
24
- export const MANIFEST_PATH: string;
73
+ export const THEME_DOC_SUFFIX: ".doc.mjs";
74
+ export const THEME_MODULE_EXTENSIONS: string[];
75
+ /** A theme directory's name: lower-kebab, starting with a letter. */
76
+ export const THEME_SLUG_RE: RegExp;
25
77
  export type DiscoveredTheme = {
26
78
  slug: string;
27
79
  displayName: string;
@@ -29,6 +81,10 @@ export type DiscoveredTheme = {
29
81
  maintained: boolean;
30
82
  entry: string;
31
83
  exportName: string;
84
+ /**
85
+ * what `theme add` copies, relative to sourceDir,
86
+ * entry first
87
+ */
32
88
  files: string[];
33
89
  package: string;
34
90
  /**
@@ -36,4 +92,8 @@ export type DiscoveredTheme = {
36
92
  */
37
93
  sourceDir: string;
38
94
  bundled: boolean;
95
+ /**
96
+ * absolute descriptor path
97
+ */
98
+ docPath: string;
39
99
  };