@astryxdesign/cli 0.6.3-canary.7482949 → 0.6.3-canary.7ada42e

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 (411) hide show
  1. package/README.md +108 -73
  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 +35 -1
  6. package/api/build/build.type.mjs +24 -3
  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 +16 -5
  13. package/api/component/component.type.mjs +13 -5
  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/docs/_adapter.d.mts +3 -8
  20. package/api/docs/_adapter.mjs +13 -105
  21. package/api/docs/docs.doc.mjs +1 -0
  22. package/api/docs/list/list.mjs +3 -7
  23. package/api/doctor/doctor.d.mts +25 -3
  24. package/api/doctor/doctor.doc.mjs +1 -0
  25. package/api/doctor/doctor.mjs +185 -13
  26. package/api/doctor/doctor.test.mjs +326 -1
  27. package/api/gap-report/gap-report.doc.mjs +8 -4
  28. package/api/hook/_adapter.mjs +19 -5
  29. package/api/hook/hook.doc.mjs +1 -0
  30. package/api/hook/list/list.d.mts +1 -1
  31. package/api/hook/list/list.mjs +69 -17
  32. package/api/init/init.doc.mjs +5 -0
  33. package/api/init/init.test.mjs +41 -1
  34. package/api/init/remove/remove.mjs +1 -1
  35. package/api/init/run/run.mjs +20 -10
  36. package/api/integration/add-contribution.component-names.test.mjs +120 -0
  37. package/api/integration/add-contribution.mjs +18 -7
  38. package/api/integration/add-contribution.test.mjs +117 -3
  39. package/api/integration/add-theme.mjs +34 -64
  40. package/api/integration/add-theme.test.mjs +105 -21
  41. package/api/integration/authoring-checks.test.mjs +8 -4
  42. package/api/integration/integration-block-exports.test.mjs +10 -6
  43. package/api/integration/integrationAdd.doc.mjs +8 -4
  44. package/api/integration/integrationAddAgentDoc.doc.mjs +1 -0
  45. package/api/integration/integrationAddCodemod.doc.mjs +1 -0
  46. package/api/integration/integrationAddComponent.doc.mjs +2 -1
  47. package/api/integration/integrationAddDoc.doc.mjs +1 -0
  48. package/api/integration/integrationAddTemplate.doc.mjs +1 -0
  49. package/api/integration/integrationAddTheme.doc.mjs +6 -5
  50. package/api/integration/integrationComponentConflicts.doc.mjs +1 -0
  51. package/api/integration/integrationDocConflicts.doc.mjs +1 -0
  52. package/api/integration/integrationPackCheck.doc.mjs +1 -0
  53. package/api/integration/integrationTemplateConflicts.doc.mjs +1 -0
  54. package/api/integration/pack-check.test.mjs +17 -47
  55. package/api/integration/summarizeIssues.doc.mjs +1 -0
  56. package/api/integration/validate-integration-fixes.test.mjs +1389 -0
  57. package/api/integration/validate-integration.mjs +52 -102
  58. package/api/integration/validate-integration.test.mjs +176 -23
  59. package/api/integration/validate-unread-theme-folders.test.mjs +110 -0
  60. package/api/integration/validateIntegration.doc.mjs +2 -1
  61. package/api/json/assertResponse.doc.mjs +1 -0
  62. package/api/json/envelope-types.test.mjs +76 -0
  63. package/api/json/isError.doc.mjs +1 -0
  64. package/api/json/parseResponse.doc.mjs +3 -2
  65. package/api/layout/expand/expand.mjs +7 -5
  66. package/api/layout/expand/expand.path-safety.test.mjs +53 -0
  67. package/api/layout/grammar/grammar.mjs +2 -1
  68. package/api/layout/layoutCheck.doc.mjs +1 -0
  69. package/api/layout/layoutExpand.doc.mjs +2 -1
  70. package/api/layout/layoutGrammar.doc.mjs +1 -0
  71. package/api/search/search-return-type.test.mjs +54 -0
  72. package/api/search/search.d.mts +2 -9
  73. package/api/search/search.doc.mjs +6 -1
  74. package/api/search/search.mjs +26 -9
  75. package/api/search/search.test.mjs +34 -0
  76. package/api/swizzle/copy/copy.mjs +28 -11
  77. package/api/swizzle/swizzle.doc.mjs +2 -1
  78. package/api/template/copy/copy.mjs +17 -23
  79. package/api/template/copy/copy.test.mjs +17 -0
  80. package/api/template/template-suffix.test.mjs +41 -21
  81. package/api/template/template.doc.mjs +3 -1
  82. package/api/theme/_adapter.d.mts +2 -3
  83. package/api/theme/_adapter.mjs +4 -5
  84. package/api/theme/add/add.binary.test.mjs +84 -0
  85. package/api/theme/add/add.mjs +20 -3
  86. package/api/theme/add/add.staging.test.mjs +66 -0
  87. package/api/theme/add/add.test.mjs +14 -1
  88. package/api/theme/build/build.mjs +114 -37
  89. package/api/theme/build/build.public-component-vars.test.mjs +1 -1
  90. package/api/theme/build/build.receipt-doc.test.mjs +111 -0
  91. package/api/theme/build/font-warning.mjs +3 -3
  92. package/api/theme/build/font-warning.test.mjs +5 -2
  93. package/api/theme/generateTonalPalette.doc.mjs +1 -0
  94. package/api/theme/integration-themes.test.mjs +39 -28
  95. package/api/theme/list/list.test.mjs +19 -20
  96. package/api/theme/listThemes.doc.mjs +6 -5
  97. package/api/theme/palette/generate/generate.mjs +7 -2
  98. package/api/theme/palette/generate/generate.test.mjs +96 -0
  99. package/api/theme/palette/generate/generator.mjs +8 -1
  100. package/api/theme/palette/generate/generator.test.mjs +10 -0
  101. package/api/theme/template/template.mjs +11 -2
  102. package/api/theme/template/template.test.mjs +15 -0
  103. package/api/theme/themeAdd.doc.mjs +4 -3
  104. package/api/theme/themeBuild.doc.mjs +8 -4
  105. package/api/theme/themeList.doc.mjs +6 -3
  106. package/api/theme/themeListAvailable.doc.mjs +5 -3
  107. package/api/theme/themePaletteGenerate.doc.mjs +1 -0
  108. package/api/theme/themeTargets.doc.mjs +1 -0
  109. package/api/theme/themeTemplate.doc.mjs +5 -1
  110. package/api/upgrade/_adapter.d.mts +32 -5
  111. package/api/upgrade/_adapter.mjs +124 -73
  112. package/api/upgrade/list/list.mjs +2 -1
  113. package/api/upgrade/list/list.test.mjs +73 -0
  114. package/api/upgrade/provider-agreement.test.mjs +152 -0
  115. package/api/upgrade/run/run.mjs +356 -59
  116. package/api/upgrade/status/status.mjs +2 -2
  117. package/api/upgrade/upgrade.doc.mjs +8 -2
  118. package/api/upgrade/upgrade.type.d.mts +38 -0
  119. package/api/upgrade/upgrade.type.mjs +16 -0
  120. package/assets/codemods/__tests__/runner.test.mjs +330 -8
  121. package/assets/codemods/integration-discovery.mjs +8 -2
  122. package/assets/codemods/integration-discovery.test.mjs +15 -0
  123. package/assets/codemods/integration-runner.mjs +56 -4
  124. package/assets/codemods/integration-runner.protection.test.mjs +153 -0
  125. package/assets/codemods/run-codemod.mjs +177 -34
  126. package/assets/codemods/runner.mjs +350 -102
  127. package/assets/codemods/term-log.mjs +32 -8
  128. package/assets/codemods/term-log.test.mjs +19 -1
  129. package/assets/codemods/transform-prop.mjs +109 -0
  130. package/assets/codemods/transform-prop.test.mjs +95 -0
  131. package/assets/codemods/transforms/next/__tests__/migrate-native-picker-to-presentation.test.mjs +63 -0
  132. package/assets/codemods/transforms/next/__tests__/migrate-theme-catalog-to-descriptors.test.mjs +220 -0
  133. package/assets/codemods/transforms/next/index.mjs +19 -1
  134. package/assets/codemods/transforms/next/migrate-native-picker-to-presentation.mjs +148 -0
  135. package/assets/codemods/transforms/next/migrate-theme-catalog-to-descriptors.mjs +141 -0
  136. package/assets/codemods/transforms/v0.0.14/__tests__/rename-status-variants.test.mjs +86 -165
  137. package/assets/codemods/transforms/v0.0.14/rename-status-variants.mjs +72 -210
  138. package/assets/codemods/transforms/v0.1.8/__tests__/rename-avatar-size-scale.test.mjs +83 -115
  139. package/assets/codemods/transforms/v0.1.8/rename-avatar-size-scale.mjs +57 -186
  140. package/assets/codemods/transforms/v0.6.0/__tests__/next-codemods.test.mjs +47 -0
  141. package/assets/codemods/transforms/v0.6.0/rename-resizable-pixel-bounds.mjs +57 -10
  142. package/assets/docs/cli-integrations.doc.mjs +30 -30
  143. package/assets/docs/cli.doc.mjs +15 -0
  144. package/assets/docs/theme.doc.mjs +1 -1
  145. package/assets/templates/blocks/components/DateInput/DateInputDateRange.tsx +1 -1
  146. package/assets/templates/blocks/components/Item/ItemDocumentTabs.doc.mjs +14 -0
  147. package/assets/templates/blocks/components/Item/ItemDocumentTabs.tsx +100 -0
  148. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaInlineRail.doc.mjs +14 -0
  149. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaInlineRail.tsx +61 -0
  150. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaOverscrollChaining.doc.mjs +14 -0
  151. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaOverscrollChaining.tsx +126 -0
  152. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaShowcase.doc.mjs +15 -0
  153. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaShowcase.tsx +86 -0
  154. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaStickyGroupHeaders.doc.mjs +14 -0
  155. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaStickyGroupHeaders.tsx +99 -0
  156. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaStickyPassthrough.doc.mjs +14 -0
  157. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaStickyPassthrough.tsx +122 -0
  158. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaTwoAxisBoard.doc.mjs +14 -0
  159. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaTwoAxisBoard.tsx +95 -0
  160. package/assets/templates/blocks/components/TimeInput/TimeInputConstrained.tsx +1 -0
  161. package/assets/templates/themes/butter/butterTheme.doc.mjs +11 -0
  162. package/assets/templates/themes/chocolate/chocolateTheme.doc.mjs +11 -0
  163. package/assets/templates/themes/gothic/gothicTheme.doc.mjs +11 -0
  164. package/assets/templates/themes/matcha/matchaTheme.doc.mjs +11 -0
  165. package/assets/templates/themes/neutral/neutralTheme.doc.mjs +11 -0
  166. package/assets/templates/themes/stone/stoneTheme.doc.mjs +11 -0
  167. package/assets/templates/themes/y2k/y2kTheme.doc.mjs +11 -0
  168. package/authoring/codemod/codemod.doc.mjs +1 -1
  169. package/authoring/codemod/type.ts +12 -0
  170. package/authoring/config/config.doc.mjs +2 -2
  171. package/authoring/config/debug-composition.test.mjs +92 -0
  172. package/authoring/config/type.ts +15 -3
  173. package/authoring/debug/debug.doc.d.mts +11 -0
  174. package/authoring/debug/debug.doc.mjs +182 -0
  175. package/authoring/doctypes/base/graph-fields.doc.mjs +1 -1
  176. package/authoring/doctypes/command/command.doc.mjs +1 -1
  177. package/authoring/doctypes/command/type.ts +1 -1
  178. package/authoring/doctypes/component/type.ts +2 -2
  179. package/authoring/doctypes/doctypes-new.test.mjs +48 -6
  180. package/authoring/doctypes/enum/enum.doc.mjs +1 -1
  181. package/authoring/doctypes/enum/type.ts +1 -1
  182. package/authoring/doctypes/function/function.doc.mjs +1 -1
  183. package/authoring/doctypes/function/type.ts +1 -1
  184. package/authoring/doctypes/hook/type.ts +2 -2
  185. package/authoring/doctypes/load-contract.test.mjs +2 -1
  186. package/authoring/doctypes/parse.d.mts +4 -2
  187. package/authoring/doctypes/parse.mjs +7 -3
  188. package/authoring/doctypes/reference/reference.doc.mjs +1 -1
  189. package/authoring/doctypes/reference/type.ts +2 -2
  190. package/authoring/doctypes/schema/schema.doc.mjs +1 -1
  191. package/authoring/doctypes/schema/type.ts +1 -2
  192. package/authoring/doctypes/template/template.doc.mjs +3 -3
  193. package/authoring/doctypes/theme/parse.d.mts +35 -0
  194. package/authoring/doctypes/theme/parse.mjs +76 -0
  195. package/authoring/doctypes/theme/theme.doc.d.mts +9 -0
  196. package/authoring/doctypes/theme/theme.doc.mjs +79 -0
  197. package/authoring/doctypes/theme/type.ts +42 -0
  198. package/authoring/doctypes/types.ts +2 -1
  199. package/authoring/gap-report/gap-report.doc.d.mts +12 -0
  200. package/authoring/gap-report/gap-report.doc.mjs +183 -0
  201. package/authoring/index.d.mts +1 -0
  202. package/authoring/index.d.ts +6 -4
  203. package/authoring/index.mjs +2 -1
  204. package/authoring/integration/integration.doc.mjs +2 -2
  205. package/authoring/integration/type.ts +3 -9
  206. package/clients/cli/__tests__/cliManifest.test.ts +27 -29
  207. package/clients/cli/command-load-failure.test.mjs +83 -0
  208. package/clients/cli/commands/blog.doc.mjs +1 -1
  209. package/clients/cli/commands/blog.mjs +23 -8
  210. package/clients/cli/commands/blog.test.mjs +42 -1
  211. package/clients/cli/commands/build-theme.ascii-output.test.mjs +161 -0
  212. package/clients/cli/commands/build-theme.flag-docs.test.mjs +110 -0
  213. package/clients/cli/commands/build-theme.mjs +15 -49
  214. package/clients/cli/commands/build-theme.path-safety.test.mjs +86 -1
  215. package/clients/cli/commands/build-theme.variants.test.mjs +76 -0
  216. package/clients/cli/commands/build.doc.mjs +5 -2
  217. package/clients/cli/commands/build.exit-codes-doc.test.mjs +50 -0
  218. package/clients/cli/commands/build.mjs +32 -47
  219. package/clients/cli/commands/build.playbook.test.mjs +75 -0
  220. package/clients/cli/commands/build.text-fields.test.mjs +40 -0
  221. package/clients/cli/commands/component/index.mjs +2 -7
  222. package/clients/cli/commands/component-package.test.mjs +46 -0
  223. package/clients/cli/commands/component-resolution.test.mjs +21 -0
  224. package/clients/cli/commands/component.doc.mjs +1 -1
  225. package/clients/cli/commands/component.test.mjs +19 -0
  226. package/clients/cli/commands/detail-levels.test.mjs +2 -2
  227. package/clients/cli/commands/discover.broken-integration.test.mjs +48 -0
  228. package/clients/cli/commands/discover.components-flag.test.mjs +97 -0
  229. package/clients/cli/commands/discover.doc.mjs +5 -3
  230. package/clients/cli/commands/discover.mjs +3 -3
  231. package/clients/cli/commands/discover.text-projection.test.mjs +103 -0
  232. package/clients/cli/commands/docs.doc.mjs +1 -1
  233. package/clients/cli/commands/docs.mjs +1 -1
  234. package/clients/cli/commands/doctor-integration-components.doc.mjs +1 -1
  235. package/clients/cli/commands/doctor-integration-docs.doc.mjs +1 -1
  236. package/clients/cli/commands/doctor-integration-templates.doc.mjs +1 -1
  237. package/clients/cli/commands/doctor-integration-validate.doc.mjs +1 -1
  238. package/clients/cli/commands/doctor-integration.doc.mjs +1 -1
  239. package/clients/cli/commands/doctor-integration.package-json.test.mjs +53 -0
  240. package/clients/cli/commands/doctor-integration.test.mjs +15 -7
  241. package/clients/cli/commands/doctor.doc.mjs +1 -1
  242. package/clients/cli/commands/doctor.mjs +6 -16
  243. package/clients/cli/commands/doctor.test.mjs +42 -0
  244. package/clients/cli/commands/gap-report.doc.mjs +17 -6
  245. package/clients/cli/commands/gap-report.test.mjs +72 -0
  246. package/clients/cli/commands/hook/index.mjs +7 -17
  247. package/clients/cli/commands/hook.doc.mjs +1 -1
  248. package/clients/cli/commands/hook.text-projection.test.mjs +45 -0
  249. package/clients/cli/commands/init.doc.mjs +20 -9
  250. package/clients/cli/commands/init.flag-help.test.mjs +153 -0
  251. package/clients/cli/commands/integration-add.controls.test.mjs +132 -0
  252. package/clients/cli/commands/integration-add.doc.mjs +22 -6
  253. package/clients/cli/commands/integration-pack.doc.mjs +1 -1
  254. package/clients/cli/commands/integration-real-world.test.mjs +3 -9
  255. package/clients/cli/commands/integration.doc.mjs +1 -1
  256. package/clients/cli/commands/interactive-guard.test.mjs +101 -24
  257. package/clients/cli/commands/json-contract.test.mjs +33 -0
  258. package/clients/cli/commands/layout-check.doc.mjs +15 -4
  259. package/clients/cli/commands/layout-expand.doc.mjs +22 -5
  260. package/clients/cli/commands/layout-grammar.doc.mjs +1 -1
  261. package/clients/cli/commands/layout.doc.mjs +3 -3
  262. package/clients/cli/commands/layout.mjs +21 -9
  263. package/clients/cli/commands/layout.path-help.test.mjs +33 -0
  264. package/clients/cli/commands/layout.stdin-cap.test.mjs +47 -0
  265. package/clients/cli/commands/layout.text-fields.test.mjs +39 -0
  266. package/clients/cli/commands/manifest.doc.mjs +1 -1
  267. package/clients/cli/commands/no-prompt-wording.test.mjs +94 -0
  268. package/clients/cli/commands/search.doc.mjs +7 -4
  269. package/clients/cli/commands/search.mjs +17 -7
  270. package/clients/cli/commands/search.test.mjs +75 -0
  271. package/clients/cli/commands/swizzle.doc.mjs +3 -2
  272. package/clients/cli/commands/swizzle.path-safety.test.mjs +42 -0
  273. package/clients/cli/commands/template.doc.mjs +29 -7
  274. package/clients/cli/commands/template.flag-help.test.mjs +117 -0
  275. package/clients/cli/commands/template.path-help.test.mjs +40 -0
  276. package/clients/cli/commands/text-json-parity.test.mjs +719 -0
  277. package/clients/cli/commands/theme-add.doc.mjs +4 -3
  278. package/clients/cli/commands/theme-build.doc.mjs +8 -7
  279. package/clients/cli/commands/theme-list.doc.mjs +2 -2
  280. package/clients/cli/commands/theme-palette-generate.doc.mjs +3 -3
  281. package/clients/cli/commands/theme-palette-generate.test.mjs +19 -0
  282. package/clients/cli/commands/theme-palette.doc.mjs +1 -1
  283. package/clients/cli/commands/theme-targets.behavior.test.mjs +4 -3
  284. package/clients/cli/commands/theme-targets.doc.mjs +1 -1
  285. package/clients/cli/commands/theme-template.behavior.test.mjs +12 -0
  286. package/clients/cli/commands/theme-template.doc.mjs +2 -2
  287. package/clients/cli/commands/theme.doc.mjs +1 -1
  288. package/clients/cli/commands/upgrade.ascii-output.test.mjs +87 -0
  289. package/clients/cli/commands/upgrade.doc.mjs +20 -8
  290. package/clients/cli/commands/upgrade.file-protection.test.mjs +228 -0
  291. package/clients/cli/commands/upgrade.flag-help.test.mjs +188 -0
  292. package/clients/cli/commands/upgrade.hook-output.test.mjs +88 -0
  293. package/clients/cli/commands/upgrade.mjs +29 -7
  294. package/clients/cli/formatters/index.mjs +2 -0
  295. package/clients/cli/formatters/index.test.mjs +6 -0
  296. package/clients/cli/index.mjs +13 -30
  297. package/clients/cli/latest-version-env.test.mjs +50 -0
  298. package/clients/cli/lib/cli-error.test.mjs +7 -0
  299. package/clients/cli/lib/component-format.mjs +9 -9
  300. package/clients/cli/lib/component-format.test.mjs +1 -1
  301. package/clients/cli/lib/define-command.mjs +32 -6
  302. package/clients/cli/lib/doc-text-ascii.test.mjs +82 -0
  303. package/clients/cli/lib/exit-codes.test.mjs +97 -0
  304. package/clients/cli/lib/hook-format.mjs +19 -10
  305. package/clients/cli/lib/json-shim.mjs +38 -2
  306. package/clients/cli/lib/json-shim.test.mjs +83 -0
  307. package/clients/cli/lib/manifest.d.ts +2 -0
  308. package/clients/cli/lib/manifest.mjs +22 -0
  309. package/clients/cli/lib/manifest.test.mjs +17 -0
  310. package/foundation/agent-docs/agent-docs.d.mts +4 -0
  311. package/foundation/agent-docs/agent-docs.mjs +69 -3
  312. package/foundation/agent-docs/agent-docs.path-safety.test.mjs +266 -4
  313. package/foundation/config/integration-debug.test.mjs +28 -3
  314. package/foundation/config/project-themes.test.mjs +11 -19
  315. package/foundation/config/project.d.mts +8 -0
  316. package/foundation/config/project.mjs +173 -30
  317. package/foundation/config/project.test.mjs +129 -16
  318. package/foundation/discovery/authoring-self-docs.d.mts +6 -0
  319. package/foundation/discovery/authoring-self-docs.mjs +17 -7
  320. package/foundation/discovery/authoring-surface.d.mts +74 -0
  321. package/foundation/discovery/authoring-surface.mjs +525 -0
  322. package/foundation/discovery/authoring-surface.test.mjs +392 -0
  323. package/foundation/discovery/cli-self-docs.d.mts +113 -0
  324. package/foundation/discovery/cli-self-docs.mjs +514 -0
  325. package/foundation/discovery/cli-self-docs.test.mjs +437 -0
  326. package/foundation/discovery/component-loader.d.mts +35 -38
  327. package/foundation/discovery/component-loader.mjs +53 -222
  328. package/foundation/discovery/docs-discovery.d.mts +3 -2
  329. package/foundation/discovery/docs-discovery.mjs +8 -12
  330. package/foundation/discovery/docs-discovery.test.mjs +8 -5
  331. package/foundation/discovery/template-adapter.d.mts +21 -5
  332. package/foundation/discovery/template-adapter.fixture-refs.test.mjs +248 -0
  333. package/foundation/discovery/template-adapter.integration-isolation.test.mjs +94 -0
  334. package/foundation/discovery/template-adapter.mjs +319 -65
  335. package/foundation/discovery/template-adapter.test.mjs +15 -0
  336. package/foundation/discovery/theme-discovery.d.mts +67 -7
  337. package/foundation/discovery/theme-discovery.mjs +916 -186
  338. package/foundation/discovery/theme-discovery.test.mjs +613 -219
  339. package/foundation/doc-compiler/bundle.d.mts +47 -0
  340. package/foundation/doc-compiler/bundle.mjs +218 -0
  341. package/foundation/doc-compiler/bundle.test.mjs +255 -0
  342. package/foundation/doc-compiler/compile.d.mts +200 -0
  343. package/foundation/doc-compiler/compile.mjs +254 -5
  344. package/foundation/doc-compiler/diagnostics.d.mts +126 -0
  345. package/foundation/doc-compiler/diagnostics.mjs +277 -0
  346. package/foundation/doc-compiler/doc-compiler.test.mjs +28 -1
  347. package/foundation/doc-compiler/doc-loads.test.mjs +1642 -0
  348. package/foundation/doc-compiler/import.d.mts +24 -0
  349. package/foundation/doc-compiler/import.mjs +59 -0
  350. package/foundation/doc-compiler/inputs.d.mts +102 -0
  351. package/foundation/doc-compiler/inputs.mjs +286 -0
  352. package/foundation/doc-compiler/inputs.test.mjs +299 -0
  353. package/foundation/doc-compiler/ir.d.mts +13 -0
  354. package/foundation/doc-compiler/ir.mjs +189 -12
  355. package/foundation/doc-compiler/lower-doc.test.mjs +492 -0
  356. package/foundation/doc-compiler/overlays.d.mts +37 -0
  357. package/foundation/doc-compiler/overlays.mjs +206 -0
  358. package/foundation/doc-compiler/parse-readable.d.mts +9 -0
  359. package/foundation/doc-compiler/parse-readable.mjs +29 -0
  360. package/foundation/doc-compiler/read.d.mts +126 -0
  361. package/foundation/doc-compiler/read.mjs +320 -0
  362. package/foundation/doc-compiler/read.test.mjs +313 -0
  363. package/foundation/doc-compiler/source.d.mts +33 -0
  364. package/foundation/doc-compiler/source.mjs +128 -0
  365. package/foundation/fs/file-protection.d.mts +33 -0
  366. package/foundation/fs/file-protection.mjs +825 -0
  367. package/foundation/fs/file-protection.test.mjs +250 -0
  368. package/foundation/fs/module-loader.d.mts +1 -0
  369. package/foundation/fs/module-loader.mjs +50 -1
  370. package/foundation/fs/module-loader.stdout.test.mjs +332 -0
  371. package/foundation/fs/path-safety.d.mts +3 -2
  372. package/foundation/fs/path-safety.mjs +49 -19
  373. package/foundation/fs/path-safety.test.mjs +50 -0
  374. package/foundation/fs/publish-file-hardlink-unavailable.test.mjs +129 -94
  375. package/foundation/integrations/autolink.d.mts +58 -1
  376. package/foundation/integrations/autolink.mjs +143 -52
  377. package/foundation/integrations/contribution-fixes.d.mts +145 -0
  378. package/foundation/integrations/contribution-fixes.mjs +1284 -0
  379. package/foundation/integrations/contribution-inventory.d.mts +1 -1
  380. package/foundation/integrations/contribution-inventory.mjs +17 -20
  381. package/foundation/integrations/contribution-inventory.test.mjs +67 -27
  382. package/foundation/integrations/integrations.d.mts +3 -0
  383. package/foundation/integrations/integrations.mjs +11 -97
  384. package/foundation/integrations/provider-ledger.test.mjs +275 -0
  385. package/foundation/integrations/provider-resolution.d.mts +152 -0
  386. package/foundation/integrations/provider-resolution.mjs +576 -0
  387. package/foundation/integrations/provider-resolution.test.mjs +369 -0
  388. package/foundation/integrations/theme-descriptor.d.mts +8 -0
  389. package/foundation/integrations/theme-descriptor.mjs +44 -0
  390. package/foundation/integrations/validate-contributions.mjs +104 -10
  391. package/foundation/response/base.d.ts +8 -4
  392. package/foundation/response/error-codes.d.mts +3 -1
  393. package/foundation/response/error-codes.d.ts +2 -0
  394. package/foundation/response/error-codes.doc.mjs +13 -4
  395. package/foundation/response/error-codes.mjs +8 -2
  396. package/foundation/response/error-codes.test.mjs +137 -10
  397. package/foundation/response/json-contract.test.mjs +11 -0
  398. package/foundation/response/json.d.mts +4 -2
  399. package/foundation/response/json.mjs +8 -10
  400. package/foundation/response/response-types.doc.mjs +11 -11
  401. package/foundation/response/response-types.doc.test.mjs +158 -0
  402. package/foundation/response/response.doc.mjs +1 -1
  403. package/foundation/text/string-utils.mjs +22 -10
  404. package/foundation/xle/expand.d.mts +2 -0
  405. package/foundation/xle/expand.mjs +3 -2
  406. package/foundation/xle/expand.test.mjs +54 -0
  407. package/package.json +10 -9
  408. package/assets/templates/themes/manifest.json +0 -95
  409. package/clients/cli/lib/update-check.mjs +0 -83
  410. package/clients/cli/lib/update-check.test.mjs +0 -137
  411. package/clients/cli/update-hint-commands.test.mjs +0 -54
@@ -23,13 +23,14 @@
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';
30
29
  import {CORE_PROVIDER_ID} from '../identity/providers.mjs';
31
30
  import {Project} from '../config/project.mjs';
32
31
 
32
+ const require = createRequire(import.meta.url);
33
+
33
34
  /** Identity used for core (built-in) templates in package-scoped listings. */
34
35
  const CORE_PACKAGE = CORE_PROVIDER_ID;
35
36
 
@@ -81,31 +82,28 @@ export function pkgOf(t) {
81
82
  */
82
83
 
83
84
  /**
84
- * Canonical basename suffixes for template-spec files, in precedence order.
85
- * A template spec is a scaffoldable TEMPLATE (a plain object stamped with a
86
- * `type` of `'page'` or `'block'`), so `.template.*` is the descriptive family
87
- * 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`.
88
88
  */
89
89
  const TEMPLATE_SUFFIXES = ['.template.ts', '.template.mjs', '.template.js'];
90
90
 
91
91
  /**
92
- * Legacy basename suffixes for template-spec files, in precedence order.
93
- * `.doc.*` was inherited from the component-doc convention before templates
94
- * 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.
95
94
  */
96
95
  const DOC_SUFFIXES = ['.doc.ts', '.doc.mjs', '.doc.js'];
97
96
 
98
97
  /**
99
- * The union of canonical + legacy template-spec suffixes, canonical first so
100
- * `.template.*` wins over `.doc.*` when both stems exist. All template
101
- * discovery matches this union so a `Foo.template.ts` file is treated exactly
102
- * 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.
103
101
  */
104
102
  const ALL_TEMPLATE_SUFFIXES = [...TEMPLATE_SUFFIXES, ...DOC_SUFFIXES];
105
103
 
106
104
  /**
107
105
  * The template-spec suffix present on `file`, or null if none matches.
108
- * Recognizes both the canonical `.template.*` and legacy `.doc.*` families.
106
+ * Recognizes both the canonical `.doc.*` and released `.template.*` families.
109
107
  * @param {string} file
110
108
  * @returns {string | null}
111
109
  */
@@ -119,16 +117,6 @@ function matchedTemplateSuffix(file) {
119
117
  */
120
118
  const TEMPLATE_SUFFIX_RE = /\.(template|doc)\.(ts|mjs|js)$/;
121
119
 
122
- /** @type {ReturnType<typeof createJiti> | undefined} */
123
- let jitiInstance;
124
- /** Lazily-created jiti for loading `.ts` template specs (JSX-capable). */
125
- function getJiti() {
126
- if (!jitiInstance) {
127
- jitiInstance = createJiti(import.meta.url, {jsx: true});
128
- }
129
- return jitiInstance;
130
- }
131
-
132
120
  /**
133
121
  * Load an integration template doc module and validate it against the template
134
122
  * envelope at the load boundary. Default export only — `.ts` via jiti,
@@ -141,7 +129,13 @@ function getJiti() {
141
129
  * @param {string} [label]
142
130
  */
143
131
  async function loadIntegrationDoc(file, label) {
144
- 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
+ });
145
139
  }
146
140
 
147
141
  const TEMPLATES_DIR = path.join(CLI_ROOT, 'assets', 'templates');
@@ -185,17 +179,53 @@ const IMAGE_EXTENSIONS = new Set([
185
179
  ]);
186
180
 
187
181
  /**
188
- * Demo-asset sources to strip from scaffolded projects. Template demo imagery
182
+ * First path segment of every Astryx template fixture. Template demo imagery
189
183
  * is self-hosted under the docsite's `/template-assets/*` dir (committed there,
190
- * mirrored into the sandbox preview by scripts/sync-templates.js). Those paths
191
- * only resolve inside the Astryx docsite/sandbox, so on scaffold they're
192
- * replaced — a scaffolded project has no `/template-assets/` dir and would
193
- * otherwise 404. Genuine third-party URLs (e.g. brand logos from
194
- * paypalobjects.com) are intentionally left untouched.
195
- *
196
- * @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.
197
188
  */
198
- 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;
199
229
 
200
230
  /**
201
231
  * Normalize path into Unix path (using forward slashes) for consistent comparison
@@ -209,36 +239,255 @@ function toPosixPath(p) {
209
239
  }
210
240
 
211
241
  /**
212
- * Replace demo asset references with a placeholder so scaffolded pages
213
- * render with zero setup. Images get a self-contained data URI; videos
214
- * (which have no equivalent inline placeholder — see VIDEO_EXTENSIONS) are
215
- * stripped to an empty src instead of being mis-replaced with image data.
216
- * 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.
217
256
  *
218
257
  * @param {string} source - Template source code.
219
258
  * @returns {string} Source with demo asset references replaced.
220
259
  */
221
260
  export function stripTemplateAssetRefs(source) {
222
- return source.replace(DEMO_ASSET_PATTERN, (match, extension) => {
223
- const ext = extension.toLowerCase();
224
- if (VIDEO_EXTENSIONS.has(ext)) {
225
- 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;
226
280
  }
227
- if (IMAGE_EXTENSIONS.has(ext)) {
228
- return PLACEHOLDER_IMAGE;
281
+ if (edit) {
282
+ output += source.slice(copied, start) + edit.text;
283
+ copied = edit.end;
229
284
  }
230
- throw new Error(`Unrecognized template asset format ${ext} for ${match}`);
231
- });
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
+ );
232
482
  }
233
483
  /**
234
484
  * Load a template-spec module and return its metadata object. Supports both
235
485
  * families of suffix:
236
- * - Legacy `.doc.*` core/external specs export `export const doc = {...}`.
237
- * - Canonical `.template.*` specs export the stamped object (`type: 'page' |
238
- * 'block'`) as the default export.
239
- * Prefers the default export, falling back to the named `doc` export, so a
240
- * `Foo.template.ts` (default export) is read identically to a legacy
241
- * `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
242
491
  * native dynamic import. Returns null if the file does not exist.
243
492
  *
244
493
  * @param {string} docPath absolute path to the spec file
@@ -246,10 +495,7 @@ export function stripTemplateAssetRefs(source) {
246
495
  */
247
496
  async function loadDocModule(docPath) {
248
497
  if (!fs.existsSync(docPath)) return null;
249
- const docModule = docPath.endsWith('.ts')
250
- ? await getJiti().import(docPath)
251
- : await import(`file://${docPath}`);
252
- return docModule.default ?? docModule.doc;
498
+ return readDocView(docPath, {root: 'templates', loader: 'template'});
253
499
  }
254
500
 
255
501
  /**
@@ -294,11 +540,11 @@ function findDocFiles(dir, pattern) {
294
540
 
295
541
  /**
296
542
  * Resolve the template-spec file for a core page directory: the first existing
297
- * `template.<suffix>` in canonical-then-legacy precedence, or null.
543
+ * metadata file in {@link ALL_TEMPLATE_SUFFIXES} precedence, or null.
298
544
  * @param {string} dirPath
299
545
  * @returns {string | null}
300
546
  */
301
- function findPageDocFile(dirPath) {
547
+ export function findPageDocFile(dirPath) {
302
548
  for (const suffix of ALL_TEMPLATE_SUFFIXES) {
303
549
  const candidate = path.join(dirPath, `template${suffix}`);
304
550
  if (fs.existsSync(candidate)) return candidate;
@@ -474,7 +720,7 @@ export async function discoverAllWithErrors(cwd = process.cwd()) {
474
720
  /**
475
721
  * Recursively collect integration template-spec files under `root`.
476
722
  * Returns absolute paths to files ending in one of ALL_TEMPLATE_SUFFIXES
477
- * (canonical `.template.*` or legacy `.doc.*`).
723
+ * (canonical `.doc.*` or released `.template.*` compatibility files).
478
724
  *
479
725
  * @param {string} root
480
726
  * @returns {string[]}
@@ -504,7 +750,7 @@ function findIntegrationDocFiles(root) {
504
750
  * Discover templates contributed by configured integrations.
505
751
  *
506
752
  * For each integration with a resolved `templates` root, every
507
- * `<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
508
754
  * template whose id is its path relative to the templates root with the
509
755
  * matched suffix stripped (kebab-case, may be nested). The doc's `type`
510
756
  * (page|block) decides scaffolding — there is no `/pages` vs `/blocks`
@@ -545,9 +791,17 @@ async function discoverIntegrationTemplates(cwd = process.cwd()) {
545
791
  }
546
792
 
547
793
  for (const integration of loadedIntegrations) {
548
- const result = await discoverIntegrationTemplatesForOne(integration);
549
- templates.push(...result.templates);
550
- 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
+ }
551
805
  }
552
806
 
553
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
  };