@astryxdesign/cli 0.6.3-canary.98a2e4e → 0.6.3-canary.9dbb6c1

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 (466) hide show
  1. package/README.md +106 -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 +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 +28 -30
  22. package/api/docs/_adapter.mjs +73 -135
  23. package/api/docs/compiled-topics.test.mjs +78 -0
  24. package/api/docs/detail/detail.d.mts +0 -15
  25. package/api/docs/detail/detail.mjs +14 -78
  26. package/api/docs/detail/section/section.mjs +22 -18
  27. package/api/docs/detail/section/section.test.mjs +4 -3
  28. package/api/docs/docs.doc.mjs +1 -0
  29. package/api/docs/docs.type.d.mts +4 -4
  30. package/api/docs/docs.type.mjs +10 -10
  31. package/api/docs/index/index.mjs +6 -5
  32. package/api/docs/list/list.mjs +3 -7
  33. package/api/doctor/doctor.d.mts +25 -3
  34. package/api/doctor/doctor.doc.mjs +1 -0
  35. package/api/doctor/doctor.mjs +186 -18
  36. package/api/doctor/doctor.test.mjs +326 -1
  37. package/api/gap-report/gap-report.doc.mjs +8 -4
  38. package/api/hook/_adapter.mjs +19 -5
  39. package/api/hook/hook.doc.mjs +1 -0
  40. package/api/hook/hook.type.d.mts +3 -3
  41. package/api/hook/hook.type.mjs +11 -11
  42. package/api/hook/list/list.d.mts +1 -1
  43. package/api/hook/list/list.mjs +69 -17
  44. package/api/init/init.doc.mjs +5 -0
  45. package/api/init/init.test.mjs +41 -1
  46. package/api/init/remove/remove.mjs +1 -1
  47. package/api/init/run/run.mjs +20 -10
  48. package/api/integration/add-contribution.component-names.test.mjs +120 -0
  49. package/api/integration/add-contribution.mjs +23 -10
  50. package/api/integration/add-contribution.test.mjs +121 -7
  51. package/api/integration/add-theme.mjs +34 -64
  52. package/api/integration/add-theme.test.mjs +105 -21
  53. package/api/integration/authoring-checks.test.mjs +8 -4
  54. package/api/integration/integration-block-exports.test.mjs +10 -6
  55. package/api/integration/integrationAdd.doc.mjs +8 -4
  56. package/api/integration/integrationAddAgentDoc.doc.mjs +1 -0
  57. package/api/integration/integrationAddCodemod.doc.mjs +1 -0
  58. package/api/integration/integrationAddComponent.doc.mjs +2 -1
  59. package/api/integration/integrationAddDoc.doc.mjs +1 -0
  60. package/api/integration/integrationAddTemplate.doc.mjs +1 -0
  61. package/api/integration/integrationAddTheme.doc.mjs +6 -5
  62. package/api/integration/integrationComponentConflicts.doc.mjs +1 -0
  63. package/api/integration/integrationDocConflicts.doc.mjs +1 -0
  64. package/api/integration/integrationPackCheck.doc.mjs +1 -0
  65. package/api/integration/integrationTemplateConflicts.doc.mjs +1 -0
  66. package/api/integration/pack-check.mjs +49 -7
  67. package/api/integration/pack-check.test.mjs +266 -47
  68. package/api/integration/summarizeIssues.doc.mjs +1 -0
  69. package/api/integration/validate-integration-fixes.test.mjs +1389 -0
  70. package/api/integration/validate-integration.mjs +52 -102
  71. package/api/integration/validate-integration.test.mjs +176 -23
  72. package/api/integration/validate-unread-theme-folders.test.mjs +110 -0
  73. package/api/integration/validateIntegration.doc.mjs +2 -1
  74. package/api/json/assertResponse.doc.mjs +1 -0
  75. package/api/json/envelope-types.test.mjs +76 -0
  76. package/api/json/isError.doc.mjs +1 -0
  77. package/api/json/parseResponse.doc.mjs +3 -2
  78. package/api/layout/expand/expand.mjs +7 -5
  79. package/api/layout/expand/expand.path-safety.test.mjs +53 -0
  80. package/api/layout/grammar/grammar.mjs +2 -1
  81. package/api/layout/layoutCheck.doc.mjs +1 -0
  82. package/api/layout/layoutExpand.doc.mjs +2 -1
  83. package/api/layout/layoutGrammar.doc.mjs +1 -0
  84. package/api/search/search-return-type.test.mjs +54 -0
  85. package/api/search/search.d.mts +2 -9
  86. package/api/search/search.doc.mjs +6 -1
  87. package/api/search/search.mjs +31 -14
  88. package/api/search/search.test.mjs +34 -0
  89. package/api/search/search.type.d.mts +1 -1
  90. package/api/search/search.type.mjs +1 -1
  91. package/api/swizzle/copy/copy.mjs +28 -11
  92. package/api/swizzle/swizzle.doc.mjs +2 -1
  93. package/api/swizzle/swizzle.type.d.mts +2 -2
  94. package/api/swizzle/swizzle.type.mjs +2 -2
  95. package/api/template/copy/copy.mjs +17 -23
  96. package/api/template/copy/copy.test.mjs +17 -0
  97. package/api/template/template-suffix.test.mjs +41 -21
  98. package/api/template/template.doc.mjs +3 -1
  99. package/api/template/template.type.d.mts +5 -5
  100. package/api/template/template.type.mjs +12 -12
  101. package/api/theme/_adapter.d.mts +2 -3
  102. package/api/theme/_adapter.mjs +4 -5
  103. package/api/theme/add/add.binary.test.mjs +84 -0
  104. package/api/theme/add/add.mjs +20 -3
  105. package/api/theme/add/add.staging.test.mjs +66 -0
  106. package/api/theme/add/add.test.mjs +14 -1
  107. package/api/theme/build/build.mjs +133 -42
  108. package/api/theme/build/build.public-component-vars.test.mjs +1 -1
  109. package/api/theme/build/build.receipt-doc.test.mjs +111 -0
  110. package/api/theme/build/build.test.mjs +127 -0
  111. package/api/theme/build/font-warning.mjs +3 -3
  112. package/api/theme/build/font-warning.test.mjs +5 -2
  113. package/api/theme/generateTonalPalette.doc.mjs +1 -0
  114. package/api/theme/integration-themes.test.mjs +39 -28
  115. package/api/theme/list/list.test.mjs +19 -20
  116. package/api/theme/listThemes.doc.mjs +6 -5
  117. package/api/theme/palette/generate/generate.mjs +8 -3
  118. package/api/theme/palette/generate/generate.test.mjs +96 -0
  119. package/api/theme/palette/generate/generator.d.mts +10 -13
  120. package/api/theme/palette/generate/generator.mjs +15 -4
  121. package/api/theme/palette/generate/generator.test.mjs +10 -0
  122. package/api/theme/template/template.mjs +11 -2
  123. package/api/theme/template/template.test.mjs +15 -0
  124. package/api/theme/theme.type.d.mts +170 -11
  125. package/api/theme/theme.type.mjs +94 -27
  126. package/api/theme/themeAdd.doc.mjs +4 -3
  127. package/api/theme/themeBuild.doc.mjs +8 -4
  128. package/api/theme/themeList.doc.mjs +6 -3
  129. package/api/theme/themeListAvailable.doc.mjs +5 -3
  130. package/api/theme/themePaletteGenerate.doc.mjs +1 -0
  131. package/api/theme/themeTargets.doc.mjs +1 -0
  132. package/api/theme/themeTemplate.doc.mjs +5 -1
  133. package/api/upgrade/_adapter.d.mts +12 -3
  134. package/api/upgrade/_adapter.mjs +108 -70
  135. package/api/upgrade/list/list.mjs +2 -1
  136. package/api/upgrade/list/list.test.mjs +73 -0
  137. package/api/upgrade/provider-agreement.test.mjs +152 -0
  138. package/api/upgrade/run/run.mjs +1 -0
  139. package/api/upgrade/status/status.mjs +2 -2
  140. package/api/upgrade/upgrade.doc.mjs +3 -1
  141. package/api/upgrade/upgrade.type.d.mts +8 -4
  142. package/api/upgrade/upgrade.type.mjs +11 -10
  143. package/assets/codemods/integration-discovery.mjs +48 -4
  144. package/assets/codemods/integration-discovery.test.mjs +73 -0
  145. package/assets/codemods/runner.mjs +115 -5
  146. package/assets/codemods/term-log.mjs +32 -8
  147. package/assets/codemods/term-log.test.mjs +19 -1
  148. package/assets/codemods/transform-prop.mjs +109 -0
  149. package/assets/codemods/transform-prop.test.mjs +95 -0
  150. package/assets/codemods/transforms/next/__tests__/migrate-theme-catalog-to-descriptors.test.mjs +216 -0
  151. package/assets/codemods/transforms/next/index.mjs +11 -1
  152. package/assets/codemods/transforms/next/migrate-theme-catalog-to-descriptors.mjs +141 -0
  153. package/assets/codemods/transforms/v0.0.14/__tests__/rename-status-variants.test.mjs +86 -165
  154. package/assets/codemods/transforms/v0.0.14/rename-status-variants.mjs +72 -210
  155. package/assets/codemods/transforms/v0.1.8/__tests__/rename-avatar-size-scale.test.mjs +83 -115
  156. package/assets/codemods/transforms/v0.1.8/rename-avatar-size-scale.mjs +57 -186
  157. package/assets/codemods/transforms/v0.3.0/__tests__/unwrap-authoring-factories.test.mjs +27 -5
  158. package/assets/codemods/transforms/v0.3.0/unwrap-authoring-factories.mjs +20 -5
  159. package/assets/codemods/transforms/v0.6.0/__tests__/next-codemods.test.mjs +47 -0
  160. package/assets/codemods/transforms/v0.6.0/rename-resizable-pixel-bounds.mjs +57 -10
  161. package/assets/docs/cli-integrations.doc.mjs +26 -30
  162. package/assets/docs/cli.doc.mjs +15 -0
  163. package/assets/docs/styling-libraries.doc.mjs +1 -1
  164. package/assets/docs/theme.doc.mjs +1 -1
  165. package/assets/docs/working-with-ai.doc.mjs +1 -1
  166. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaInlineRail.doc.mjs +14 -0
  167. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaInlineRail.tsx +61 -0
  168. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaOverscrollChaining.doc.mjs +14 -0
  169. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaOverscrollChaining.tsx +126 -0
  170. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaShowcase.doc.mjs +15 -0
  171. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaShowcase.tsx +86 -0
  172. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaStickyGroupHeaders.doc.mjs +14 -0
  173. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaStickyGroupHeaders.tsx +99 -0
  174. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaStickyPassthrough.doc.mjs +14 -0
  175. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaStickyPassthrough.tsx +122 -0
  176. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaTwoAxisBoard.doc.mjs +14 -0
  177. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaTwoAxisBoard.tsx +95 -0
  178. package/assets/templates/pages/table-tree/page.tsx +1704 -0
  179. package/assets/templates/pages/table-tree/template.doc.mjs +12 -0
  180. package/assets/templates/themes/butter/butterTheme.doc.mjs +11 -0
  181. package/assets/templates/themes/chocolate/chocolateTheme.doc.mjs +11 -0
  182. package/assets/templates/themes/gothic/gothicTheme.doc.mjs +11 -0
  183. package/assets/templates/themes/matcha/matchaTheme.doc.mjs +11 -0
  184. package/assets/templates/themes/neutral/neutralTheme.doc.mjs +11 -0
  185. package/assets/templates/themes/stone/stoneTheme.doc.mjs +11 -0
  186. package/assets/templates/themes/y2k/y2kTheme.doc.mjs +11 -0
  187. package/authoring/_shared/contract.ts +22 -0
  188. package/authoring/codemod/codemod.doc.mjs +7 -2
  189. package/authoring/codemod/parse.d.mts +8 -8
  190. package/authoring/codemod/parse.mjs +8 -6
  191. package/authoring/config/config.doc.mjs +2 -2
  192. package/authoring/config/debug-composition.test.mjs +92 -0
  193. package/authoring/config/parse.d.mts +13 -13
  194. package/authoring/config/parse.mjs +8 -8
  195. package/authoring/config/type.ts +18 -6
  196. package/authoring/debug/debug.doc.d.mts +11 -0
  197. package/authoring/debug/debug.doc.mjs +182 -0
  198. package/authoring/debug/parse.d.mts +4 -4
  199. package/authoring/debug/parse.mjs +3 -3
  200. package/authoring/doctypes/_schema.d.mts +121 -11
  201. package/authoring/doctypes/_schema.mjs +144 -13
  202. package/authoring/doctypes/base/graph-fields.doc.mjs +11 -4
  203. package/authoring/doctypes/base/type.ts +8 -4
  204. package/authoring/doctypes/command/command.doc.mjs +4 -3
  205. package/authoring/doctypes/command/parse.d.mts +2 -2
  206. package/authoring/doctypes/command/parse.mjs +1 -1
  207. package/authoring/doctypes/command/type.ts +3 -3
  208. package/authoring/doctypes/component/component.doc.mjs +5 -2
  209. package/authoring/doctypes/component/parse.d.mts +2 -2
  210. package/authoring/doctypes/component/parse.mjs +1 -1
  211. package/authoring/doctypes/component/type.ts +3 -3
  212. package/authoring/doctypes/doctypes-new.test.mjs +48 -6
  213. package/authoring/doctypes/enum/enum.doc.mjs +1 -1
  214. package/authoring/doctypes/enum/parse.d.mts +2 -2
  215. package/authoring/doctypes/enum/parse.mjs +1 -1
  216. package/authoring/doctypes/enum/type.ts +2 -2
  217. package/authoring/doctypes/function/function.doc.mjs +5 -1
  218. package/authoring/doctypes/function/parse.d.mts +2 -2
  219. package/authoring/doctypes/function/parse.mjs +1 -1
  220. package/authoring/doctypes/function/type.ts +2 -2
  221. package/authoring/doctypes/hook/hook.doc.mjs +4 -0
  222. package/authoring/doctypes/hook/parse.d.mts +2 -2
  223. package/authoring/doctypes/hook/parse.mjs +1 -1
  224. package/authoring/doctypes/hook/type.ts +3 -3
  225. package/authoring/doctypes/legacy.d.mts +6 -6
  226. package/authoring/doctypes/legacy.mjs +3 -3
  227. package/authoring/doctypes/load-contract.test.mjs +208 -0
  228. package/authoring/doctypes/namespace/namespace.doc.mjs +7 -3
  229. package/authoring/doctypes/namespace/parse.d.mts +2 -2
  230. package/authoring/doctypes/namespace/parse.mjs +1 -1
  231. package/authoring/doctypes/namespace/type.ts +2 -2
  232. package/authoring/doctypes/parse.d.mts +22 -20
  233. package/authoring/doctypes/parse.mjs +16 -12
  234. package/authoring/doctypes/reference/parse.d.mts +2 -2
  235. package/authoring/doctypes/reference/parse.mjs +1 -1
  236. package/authoring/doctypes/reference/reference.doc.mjs +7 -3
  237. package/authoring/doctypes/reference/type.ts +3 -3
  238. package/authoring/doctypes/schema/parse.d.mts +2 -2
  239. package/authoring/doctypes/schema/parse.mjs +1 -1
  240. package/authoring/doctypes/schema/schema.doc.mjs +1 -1
  241. package/authoring/doctypes/schema/type.ts +3 -4
  242. package/authoring/doctypes/template/parse.d.mts +92 -1
  243. package/authoring/doctypes/template/parse.mjs +33 -1
  244. package/authoring/doctypes/template/template.doc.mjs +7 -3
  245. package/authoring/doctypes/template/type.ts +4 -1
  246. package/authoring/doctypes/theme/parse.d.mts +35 -0
  247. package/authoring/doctypes/theme/parse.mjs +76 -0
  248. package/authoring/doctypes/theme/theme.doc.d.mts +9 -0
  249. package/authoring/doctypes/theme/theme.doc.mjs +79 -0
  250. package/authoring/doctypes/theme/type.ts +42 -0
  251. package/authoring/doctypes/types.ts +12 -11
  252. package/authoring/gap-report/gap-report.doc.d.mts +12 -0
  253. package/authoring/gap-report/gap-report.doc.mjs +183 -0
  254. package/authoring/gap-report/parse.d.mts +9 -9
  255. package/authoring/gap-report/parse.mjs +6 -6
  256. package/authoring/gap-report/type.ts +1 -1
  257. package/authoring/identity/identity.doc.mjs +3 -2
  258. package/authoring/identity/type.ts +10 -10
  259. package/authoring/index.d.mts +1 -0
  260. package/authoring/index.d.ts +21 -19
  261. package/authoring/index.mjs +2 -1
  262. package/authoring/integration/integration.doc.mjs +2 -2
  263. package/authoring/integration/parse.d.mts +2 -2
  264. package/authoring/integration/parse.mjs +1 -1
  265. package/authoring/integration/schema.d.mts +4 -4
  266. package/authoring/integration/schema.mjs +3 -3
  267. package/authoring/integration/type.ts +4 -10
  268. package/clients/cli/__tests__/cliManifest.test.ts +27 -29
  269. package/clients/cli/command-load-failure.test.mjs +83 -0
  270. package/clients/cli/commands/blog.doc.mjs +1 -1
  271. package/clients/cli/commands/blog.mjs +23 -8
  272. package/clients/cli/commands/blog.test.mjs +42 -1
  273. package/clients/cli/commands/build-theme.ascii-output.test.mjs +161 -0
  274. package/clients/cli/commands/build-theme.flag-docs.test.mjs +110 -0
  275. package/clients/cli/commands/build-theme.mjs +5 -5
  276. package/clients/cli/commands/build-theme.path-safety.test.mjs +86 -1
  277. package/clients/cli/commands/build-theme.variants.test.mjs +76 -0
  278. package/clients/cli/commands/build.doc.mjs +5 -2
  279. package/clients/cli/commands/build.exit-codes-doc.test.mjs +50 -0
  280. package/clients/cli/commands/build.mjs +32 -47
  281. package/clients/cli/commands/build.playbook.test.mjs +75 -0
  282. package/clients/cli/commands/build.text-fields.test.mjs +40 -0
  283. package/clients/cli/commands/component/index.mjs +2 -7
  284. package/clients/cli/commands/component-package.test.mjs +46 -0
  285. package/clients/cli/commands/component-resolution.test.mjs +21 -0
  286. package/clients/cli/commands/component.doc.mjs +1 -1
  287. package/clients/cli/commands/component.test.mjs +19 -0
  288. package/clients/cli/commands/detail-levels.test.mjs +2 -2
  289. package/clients/cli/commands/discover.broken-integration.test.mjs +48 -0
  290. package/clients/cli/commands/discover.components-flag.test.mjs +97 -0
  291. package/clients/cli/commands/discover.doc.mjs +5 -3
  292. package/clients/cli/commands/discover.mjs +3 -3
  293. package/clients/cli/commands/discover.text-projection.test.mjs +103 -0
  294. package/clients/cli/commands/docs.doc.mjs +1 -1
  295. package/clients/cli/commands/doctor-integration-components.doc.mjs +1 -1
  296. package/clients/cli/commands/doctor-integration-docs.doc.mjs +1 -1
  297. package/clients/cli/commands/doctor-integration-templates.doc.mjs +1 -1
  298. package/clients/cli/commands/doctor-integration-validate.doc.mjs +1 -1
  299. package/clients/cli/commands/doctor-integration.doc.mjs +1 -1
  300. package/clients/cli/commands/doctor-integration.package-json.test.mjs +53 -0
  301. package/clients/cli/commands/doctor-integration.test.mjs +15 -7
  302. package/clients/cli/commands/doctor.doc.mjs +1 -1
  303. package/clients/cli/commands/doctor.mjs +6 -16
  304. package/clients/cli/commands/doctor.test.mjs +42 -0
  305. package/clients/cli/commands/gap-report.doc.mjs +17 -6
  306. package/clients/cli/commands/gap-report.test.mjs +72 -0
  307. package/clients/cli/commands/hook/index.mjs +7 -17
  308. package/clients/cli/commands/hook.doc.mjs +1 -1
  309. package/clients/cli/commands/hook.text-projection.test.mjs +45 -0
  310. package/clients/cli/commands/init.doc.mjs +20 -9
  311. package/clients/cli/commands/init.flag-help.test.mjs +153 -0
  312. package/clients/cli/commands/integration-add.controls.test.mjs +132 -0
  313. package/clients/cli/commands/integration-add.doc.mjs +22 -6
  314. package/clients/cli/commands/integration-authoring.test.mjs +13 -9
  315. package/clients/cli/commands/integration-pack.doc.mjs +1 -1
  316. package/clients/cli/commands/integration-real-world.test.mjs +3 -9
  317. package/clients/cli/commands/integration.doc.mjs +1 -1
  318. package/clients/cli/commands/interactive-guard.test.mjs +101 -24
  319. package/clients/cli/commands/json-contract.test.mjs +33 -0
  320. package/clients/cli/commands/layout-check.doc.mjs +15 -4
  321. package/clients/cli/commands/layout-expand.doc.mjs +22 -5
  322. package/clients/cli/commands/layout-grammar.doc.mjs +1 -1
  323. package/clients/cli/commands/layout.doc.mjs +3 -3
  324. package/clients/cli/commands/layout.mjs +21 -9
  325. package/clients/cli/commands/layout.path-help.test.mjs +33 -0
  326. package/clients/cli/commands/layout.stdin-cap.test.mjs +47 -0
  327. package/clients/cli/commands/layout.text-fields.test.mjs +39 -0
  328. package/clients/cli/commands/manifest.doc.mjs +1 -1
  329. package/clients/cli/commands/no-prompt-wording.test.mjs +94 -0
  330. package/clients/cli/commands/search.doc.mjs +7 -4
  331. package/clients/cli/commands/search.mjs +17 -7
  332. package/clients/cli/commands/search.test.mjs +75 -0
  333. package/clients/cli/commands/swizzle.doc.mjs +3 -2
  334. package/clients/cli/commands/swizzle.path-safety.test.mjs +42 -0
  335. package/clients/cli/commands/template.doc.mjs +29 -7
  336. package/clients/cli/commands/template.flag-help.test.mjs +117 -0
  337. package/clients/cli/commands/template.path-help.test.mjs +40 -0
  338. package/clients/cli/commands/theme-add.doc.mjs +4 -3
  339. package/clients/cli/commands/theme-build.doc.mjs +8 -7
  340. package/clients/cli/commands/theme-list.doc.mjs +2 -2
  341. package/clients/cli/commands/theme-palette-generate.doc.mjs +3 -3
  342. package/clients/cli/commands/theme-palette-generate.test.mjs +19 -0
  343. package/clients/cli/commands/theme-palette.doc.mjs +1 -1
  344. package/clients/cli/commands/theme-targets.doc.mjs +1 -1
  345. package/clients/cli/commands/theme-template.behavior.test.mjs +12 -0
  346. package/clients/cli/commands/theme-template.doc.mjs +2 -2
  347. package/clients/cli/commands/theme.doc.mjs +1 -1
  348. package/clients/cli/commands/upgrade.ascii-output.test.mjs +87 -0
  349. package/clients/cli/commands/upgrade.doc.mjs +18 -7
  350. package/clients/cli/commands/upgrade.flag-help.test.mjs +188 -0
  351. package/clients/cli/commands/upgrade.hook-output.test.mjs +88 -0
  352. package/clients/cli/index.mjs +13 -30
  353. package/clients/cli/latest-version-env.test.mjs +50 -0
  354. package/clients/cli/lib/cli-error.test.mjs +7 -0
  355. package/clients/cli/lib/component-format.mjs +9 -9
  356. package/clients/cli/lib/component-format.test.mjs +1 -1
  357. package/clients/cli/lib/define-command.mjs +32 -6
  358. package/clients/cli/lib/doc-text-ascii.test.mjs +82 -0
  359. package/clients/cli/lib/exit-codes.test.mjs +97 -0
  360. package/clients/cli/lib/hook-format.mjs +19 -10
  361. package/clients/cli/lib/json-shim.mjs +38 -2
  362. package/clients/cli/lib/json-shim.test.mjs +83 -0
  363. package/clients/cli/lib/manifest.d.ts +2 -0
  364. package/clients/cli/lib/manifest.mjs +22 -0
  365. package/clients/cli/lib/manifest.test.mjs +17 -0
  366. package/foundation/agent-docs/agent-docs.d.mts +4 -0
  367. package/foundation/agent-docs/agent-docs.mjs +69 -3
  368. package/foundation/agent-docs/agent-docs.path-safety.test.mjs +266 -4
  369. package/foundation/config/integration-debug.test.mjs +28 -3
  370. package/foundation/config/project-themes.test.mjs +11 -19
  371. package/foundation/config/project.d.mts +8 -0
  372. package/foundation/config/project.mjs +173 -30
  373. package/foundation/config/project.test.mjs +129 -16
  374. package/foundation/discovery/authoring-self-docs.d.mts +6 -0
  375. package/foundation/discovery/authoring-self-docs.mjs +17 -7
  376. package/foundation/discovery/authoring-self-docs.test.mjs +71 -12
  377. package/foundation/discovery/authoring-surface.d.mts +74 -0
  378. package/foundation/discovery/authoring-surface.mjs +525 -0
  379. package/foundation/discovery/authoring-surface.test.mjs +392 -0
  380. package/foundation/discovery/cli-self-docs.d.mts +113 -0
  381. package/foundation/discovery/cli-self-docs.mjs +514 -0
  382. package/foundation/discovery/cli-self-docs.test.mjs +437 -0
  383. package/foundation/discovery/component-loader.d.mts +35 -38
  384. package/foundation/discovery/component-loader.mjs +53 -222
  385. package/foundation/discovery/docs-discovery.d.mts +7 -2
  386. package/foundation/discovery/docs-discovery.mjs +24 -14
  387. package/foundation/discovery/docs-discovery.test.mjs +55 -16
  388. package/foundation/discovery/template-adapter.d.mts +21 -5
  389. package/foundation/discovery/template-adapter.fixture-refs.test.mjs +248 -0
  390. package/foundation/discovery/template-adapter.integration-isolation.test.mjs +94 -0
  391. package/foundation/discovery/template-adapter.mjs +319 -65
  392. package/foundation/discovery/template-adapter.test.mjs +15 -0
  393. package/foundation/discovery/theme-discovery.d.mts +67 -7
  394. package/foundation/discovery/theme-discovery.mjs +916 -186
  395. package/foundation/discovery/theme-discovery.test.mjs +613 -219
  396. package/foundation/discovery/theming-targets.test.mjs +4 -0
  397. package/foundation/doc-compiler/bundle.d.mts +47 -0
  398. package/foundation/doc-compiler/bundle.mjs +218 -0
  399. package/foundation/doc-compiler/bundle.test.mjs +255 -0
  400. package/foundation/doc-compiler/compile.d.mts +362 -0
  401. package/foundation/doc-compiler/compile.mjs +511 -0
  402. package/foundation/doc-compiler/diagnostics.d.mts +126 -0
  403. package/foundation/doc-compiler/diagnostics.mjs +277 -0
  404. package/foundation/doc-compiler/doc-compiler.test.mjs +714 -0
  405. package/foundation/doc-compiler/doc-loads.test.mjs +1642 -0
  406. package/foundation/doc-compiler/import.d.mts +24 -0
  407. package/foundation/doc-compiler/import.mjs +59 -0
  408. package/foundation/doc-compiler/inputs.d.mts +102 -0
  409. package/foundation/doc-compiler/inputs.mjs +286 -0
  410. package/foundation/doc-compiler/inputs.test.mjs +299 -0
  411. package/foundation/doc-compiler/ir.d.mts +22 -0
  412. package/foundation/doc-compiler/ir.mjs +464 -0
  413. package/foundation/doc-compiler/lenses.d.mts +33 -0
  414. package/foundation/doc-compiler/lenses.mjs +127 -0
  415. package/foundation/doc-compiler/lower-doc.test.mjs +492 -0
  416. package/foundation/doc-compiler/overlays.d.mts +37 -0
  417. package/foundation/doc-compiler/overlays.mjs +206 -0
  418. package/foundation/doc-compiler/parse-readable.d.mts +9 -0
  419. package/foundation/doc-compiler/parse-readable.mjs +29 -0
  420. package/foundation/doc-compiler/read.d.mts +126 -0
  421. package/foundation/doc-compiler/read.mjs +320 -0
  422. package/foundation/doc-compiler/read.test.mjs +313 -0
  423. package/foundation/doc-compiler/source.d.mts +33 -0
  424. package/foundation/doc-compiler/source.mjs +128 -0
  425. package/foundation/fs/module-loader.d.mts +1 -0
  426. package/foundation/fs/module-loader.mjs +50 -1
  427. package/foundation/fs/module-loader.stdout.test.mjs +332 -0
  428. package/foundation/fs/path-safety.d.mts +3 -2
  429. package/foundation/fs/path-safety.mjs +49 -19
  430. package/foundation/fs/path-safety.test.mjs +50 -0
  431. package/foundation/fs/publish-file-hardlink-unavailable.test.mjs +129 -94
  432. package/foundation/integrations/autolink.d.mts +58 -1
  433. package/foundation/integrations/autolink.mjs +143 -52
  434. package/foundation/integrations/contribution-fixes.d.mts +145 -0
  435. package/foundation/integrations/contribution-fixes.mjs +1284 -0
  436. package/foundation/integrations/contribution-inventory.d.mts +1 -1
  437. package/foundation/integrations/contribution-inventory.mjs +17 -20
  438. package/foundation/integrations/contribution-inventory.test.mjs +67 -27
  439. package/foundation/integrations/integrations.d.mts +3 -0
  440. package/foundation/integrations/integrations.mjs +11 -97
  441. package/foundation/integrations/provider-ledger.test.mjs +275 -0
  442. package/foundation/integrations/provider-resolution.d.mts +152 -0
  443. package/foundation/integrations/provider-resolution.mjs +576 -0
  444. package/foundation/integrations/provider-resolution.test.mjs +369 -0
  445. package/foundation/integrations/theme-descriptor.d.mts +8 -0
  446. package/foundation/integrations/theme-descriptor.mjs +44 -0
  447. package/foundation/integrations/validate-contributions.mjs +104 -10
  448. package/foundation/response/base.d.ts +8 -4
  449. package/foundation/response/error-codes.doc.mjs +3 -4
  450. package/foundation/response/error-codes.mjs +2 -2
  451. package/foundation/response/error-codes.test.mjs +83 -0
  452. package/foundation/response/json-contract.test.mjs +11 -0
  453. package/foundation/response/json.d.mts +4 -2
  454. package/foundation/response/json.mjs +8 -10
  455. package/foundation/response/response-types.doc.mjs +11 -11
  456. package/foundation/response/response-types.doc.test.mjs +158 -0
  457. package/foundation/response/response.doc.mjs +1 -1
  458. package/foundation/text/string-utils.mjs +22 -10
  459. package/foundation/xle/expand.d.mts +2 -0
  460. package/foundation/xle/expand.mjs +3 -2
  461. package/foundation/xle/expand.test.mjs +54 -0
  462. package/package.json +9 -11
  463. package/assets/templates/themes/manifest.json +0 -95
  464. package/clients/cli/lib/update-check.mjs +0 -83
  465. package/clients/cli/lib/update-check.test.mjs +0 -137
  466. package/clients/cli/update-hint-commands.test.mjs +0 -54
@@ -16,40 +16,37 @@
16
16
  */
17
17
  export function loadDocsCatalog(cwd?: string): Promise<DocsCatalog>;
18
18
  /**
19
- * @param {string} docPath
20
- * @param {{lang?: string|null}} [opts]
21
- * @returns {Promise<import('./docs.type.mjs').DocsDetailResponse['data']>}
19
+ * One topic, lowered for `lang`: overlaid, extensions merged, keys stamped.
20
+ * Memoized per catalog, so a read that references a topic twice loads it once.
21
+ * Every read of the catalog shares the memoized node, so it is frozen; the
22
+ * lenses hand readers copies.
23
+ * @param {DocsCatalog} catalog
24
+ * @param {import('../../foundation/discovery/docs-discovery.mjs').DocsTopicEntry} entry
25
+ * @param {string | null} [lang]
26
+ * @returns {Promise<import('../../foundation/doc-compiler/compile.mjs').CompiledReferenceNode>}
22
27
  */
23
- export function loadReferenceDocs(docPath: string, { lang }?: {
24
- lang?: string | null;
25
- }): Promise<import("./docs.type.mjs").DocsDetailResponse["data"]>;
28
+ export function lowerTopic(catalog: DocsCatalog, entry: import("../../foundation/discovery/docs-discovery.mjs").DocsTopicEntry, lang?: string | null): Promise<import("../../foundation/doc-compiler/compile.mjs").CompiledReferenceNode>;
26
29
  /**
27
- * Load one catalog entry: its own doc, plus any extension an integration
28
- * merged onto it, in configuration order.
29
- *
30
- * A localization overlay applies to each file before the extensions are
31
- * merged, so an extension written in the base language stays readable under
32
- * `--dense`/`--zh` (it replaces its own sections and leaves the rest
33
- * translated) rather than being dropped.
34
- *
35
- * @param {import('../../foundation/discovery/docs-discovery.mjs').DocsTopicEntry} entry
36
- * @param {{lang?: string|null}} [opts]
37
- * @returns {Promise<import('./docs.type.mjs').DocsDetailResponse['data']>}
30
+ * How a token reference finds its target: the topic it names in `catalog`,
31
+ * lowered for the same language.
32
+ * @param {DocsCatalog} catalog
33
+ * @param {string | null} lang
34
+ * @returns {(topic: string) => Promise<import('../../foundation/doc-compiler/compile.mjs').CompiledReferenceNode | null>}
38
35
  */
39
- export function loadTopicDoc(entry: import("../../foundation/discovery/docs-discovery.mjs").DocsTopicEntry, { lang }?: {
40
- lang?: string | null;
41
- }): Promise<import("./docs.type.mjs").DocsDetailResponse["data"]>;
36
+ export function referenceTargets(catalog: DocsCatalog, lang: string | null): (topic: string) => Promise<import("../../foundation/doc-compiler/compile.mjs").CompiledReferenceNode | null>;
42
37
  /**
43
- * The overlay languages a topic ships for its own file or any extension.
38
+ * One topic, compiled for `lang`: lowered, then every token reference linked.
39
+ * @param {DocsCatalog} catalog
44
40
  * @param {import('../../foundation/discovery/docs-discovery.mjs').DocsTopicEntry} entry
45
- * @returns {string[]}
41
+ * @param {string | null} [lang]
42
+ * @returns {Promise<import('../../foundation/doc-compiler/compile.mjs').CompiledReferenceNode>}
46
43
  */
47
- export function overlayLanguages(entry: import("../../foundation/discovery/docs-discovery.mjs").DocsTopicEntry): string[];
44
+ export function compileTopic(catalog: DocsCatalog, entry: import("../../foundation/discovery/docs-discovery.mjs").DocsTopicEntry, lang?: string | null): Promise<import("../../foundation/doc-compiler/compile.mjs").CompiledReferenceNode>;
48
45
  /**
49
46
  * Resolve `topic` against the project's catalog (throwing `ERR_UNKNOWN_TOPIC`
50
- * when unmatched), and load it with any --dense/--zh overlay and any
51
- * integration extension applied. Shared by the detail and section leaves so
52
- * topic normalization and unknown-topic handling live in exactly one place.
47
+ * when unmatched) and lower it with any --dense/--zh overlay and any
48
+ * integration extension applied. Shared by the leaves so topic normalization
49
+ * and unknown-topic handling live in exactly one place.
53
50
  *
54
51
  * @param {string} topic
55
52
  * @param {object} [options]
@@ -59,7 +56,7 @@ export function overlayLanguages(entry: import("../../foundation/discovery/docs-
59
56
  * @param {string} [options.cwd]
60
57
  * @returns {Promise<{
61
58
  * catalog: DocsCatalog,
62
- * docsData: import('./docs.type.mjs').DocsDetailResponse['data'],
59
+ * node: import('../../foundation/doc-compiler/compile.mjs').CompiledReferenceNode,
63
60
  * lang: string | null,
64
61
  * }>}
65
62
  */
@@ -70,9 +67,10 @@ export function resolveTopicDocs(topic: string, options?: {
70
67
  cwd?: string | undefined;
71
68
  }): Promise<{
72
69
  catalog: DocsCatalog;
73
- docsData: import("./docs.type.mjs").DocsDetailResponse["data"];
70
+ node: import("../../foundation/doc-compiler/compile.mjs").CompiledReferenceNode;
74
71
  lang: string | null;
75
72
  }>;
76
- /** The localized overlays a docs read can apply. */
77
- export const OVERLAY_LANGUAGES: string[];
78
73
  import { DocsCatalog } from '../../foundation/discovery/docs-discovery.mjs';
74
+ import { OVERLAY_LANGUAGES } from '../../foundation/doc-compiler/read.mjs';
75
+ import { overlayLanguages } from '../../foundation/doc-compiler/read.mjs';
76
+ export { OVERLAY_LANGUAGES, overlayLanguages };
@@ -7,32 +7,32 @@
7
7
  * packages/cli/assets/docs/{topic}.doc.mjs plus every topic the configured
8
8
  * integrations contribute — and, when a --dense/--zh overlay is requested,
9
9
  * the sibling {topic}.doc.dense.mjs / {topic}.doc.zh.mjs.
10
- * @output Catalog access, overlay- and extension-merged reference-doc data,
11
- * and a combined resolve step ({catalog, docsData}) that the detail and
12
- * section leaves share.
13
- * @position Sits beside docs.mjs (api/docs/). Owns everything ≥2 leaves need so
14
- * no leaf re-implements resolution, overlay merging, or unknown-topic
15
- * handling. Discovery itself lives in foundation/discovery/docs-discovery,
16
- * which api/search and the agent-docs block read through the same catalog.
10
+ * @output Catalog access, the compiler input for a topic, and the compiled
11
+ * node for it: lowered (overlaid, extensions merged, keys stamped) or linked
12
+ * (token references resolved too), memoized per catalog.
13
+ * @position Sits beside docs.mjs (api/docs/). Hands topics to
14
+ * foundation/doc-compiler (which loads their files) and memoizes the nodes
15
+ * per catalog, so no leaf, doctor check or search loads, merges, or resolves
16
+ * docs on its own. Discovery itself lives in
17
+ * foundation/discovery/docs-discovery, which the catalog comes from.
17
18
  */
18
19
 
19
- import * as fs from 'node:fs';
20
- import * as path from 'node:path';
21
- import {pathToFileURL} from 'node:url';
22
20
  import {Project} from '../../foundation/config/project.mjs';
21
+ import {DocsCatalog} from '../../foundation/discovery/docs-discovery.mjs';
23
22
  import {
24
- DocsCatalog,
25
- mergeTopic,
26
- problemsInTopic,
27
- withSourceTitle,
28
- } from '../../foundation/discovery/docs-discovery.mjs';
23
+ linkReferenceTopic,
24
+ lowerReferenceTopic,
25
+ } from '../../foundation/doc-compiler/compile.mjs';
29
26
  import {
30
- sectionKeyProblems,
31
- withSectionKeys,
32
- } from '../../foundation/discovery/docs-section-key.mjs';
27
+ deepFreeze,
28
+ loadTopicInput,
29
+ OVERLAY_LANGUAGES,
30
+ overlayLanguages,
31
+ } from '../../foundation/doc-compiler/read.mjs';
33
32
  import {AstryxError} from '../error.mjs';
34
33
  import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
35
- import {parseDoc} from '../../authoring/doctypes/parse.mjs';
34
+
35
+ export {OVERLAY_LANGUAGES, overlayLanguages};
36
36
 
37
37
  /**
38
38
  * The project's topics: the built-in ones plus whatever the configured
@@ -57,140 +57,78 @@ export async function loadDocsCatalog(cwd = process.cwd()) {
57
57
  }
58
58
 
59
59
  /**
60
- * @param {string} docPath
61
- * @param {{lang?: string|null}} [opts]
62
- * @returns {Promise<import('./docs.type.mjs').DocsDetailResponse['data']>}
60
+ * The overlay a read applies: none for the authored language.
61
+ * @param {string | null | undefined} lang
62
+ * @returns {string | null}
63
63
  */
64
- export async function loadReferenceDocs(docPath, {lang} = {}) {
65
- const mod = await import(pathToFileURL(docPath).href);
66
- const parsed = parseDoc(mod.docs ?? mod.default, path.basename(docPath));
67
- if (!('sections' in parsed)) {
68
- throw new Error(`${path.basename(docPath)} is not a reference document.`);
69
- }
70
- const problems = problemsInTopic(parsed);
71
- if (problems.length > 0) {
72
- throw new Error(
73
- `${path.basename(docPath)} is invalid: ${problems.join('; ')}`,
74
- );
75
- }
76
- const docs = parsed;
77
- if (!lang || lang === 'en') return docs;
78
-
79
- const translationPath = overlayPath(docPath, lang);
80
- if (!fs.existsSync(translationPath)) return docs;
81
-
82
- const translationMod = await import(pathToFileURL(translationPath).href);
83
- const translation = translationMod.docsZh || translationMod.docsDense;
84
- if (!translation) return docs;
85
-
86
- // Overlays are keyed to a base section by title (`section`), not by array
87
- // position. Position-keying silently grafted each overlay title onto whatever
88
- // base section happened to share its index, so an overlay that omitted or
89
- // reordered a section corrupted every section after it — `docs tokens --dense`
90
- // printed the colour table under a "Spacing" heading (#2182). An overlay may
91
- // now cover any subset of sections, in any order; sections it does not name
92
- // keep their base content.
93
- /** @type {Map<string, any>} */
94
- const bySection = new Map();
95
- for (const ts of translation.sections ?? []) {
96
- if (ts?.section != null) bySection.set(ts.section, ts);
97
- }
98
-
99
- return {
100
- ...docs,
101
- description: translation.description || docs.description,
102
- sections: docs.sections.map(
103
- (
104
- /** @type {import('@astryxdesign/cli/authoring').ReferenceSection} */ section,
105
- ) => {
106
- const ts = bySection.get(section.title);
107
- if (!ts) return section;
108
- const localized = {
109
- ...section,
110
- title: ts.title || section.title,
111
- content: section.content.map(
112
- (
113
- /** @type {import('@astryxdesign/cli/authoring').ReferenceContentBlock} */ block,
114
- /** @type {number} */ bi,
115
- ) => {
116
- const tb = ts.content?.[bi];
117
- if (!tb) return block;
118
- if (tb.type === 'prose' && block.type === 'prose')
119
- return {...block, text: tb.text};
120
- if (tb.type === 'list' && block.type === 'list')
121
- return {...block, items: tb.items};
122
- return block;
123
- },
124
- ),
125
- };
126
- return withSourceTitle(localized, section.title);
127
- },
128
- ),
129
- };
64
+ function overlayLanguage(lang) {
65
+ return lang && lang !== 'en' ? lang : null;
130
66
  }
131
67
 
68
+ /** @type {WeakMap<DocsCatalog, Map<string, Promise<import('../../foundation/doc-compiler/compile.mjs').CompiledReferenceNode>>>} */
69
+ const loweredByCatalog = new WeakMap();
70
+
132
71
  /**
133
- * Load one catalog entry: its own doc, plus any extension an integration
134
- * merged onto it, in configuration order.
135
- *
136
- * A localization overlay applies to each file before the extensions are
137
- * merged, so an extension written in the base language stays readable under
138
- * `--dense`/`--zh` (it replaces its own sections and leaves the rest
139
- * translated) rather than being dropped.
140
- *
72
+ * One topic, lowered for `lang`: overlaid, extensions merged, keys stamped.
73
+ * Memoized per catalog, so a read that references a topic twice loads it once.
74
+ * Every read of the catalog shares the memoized node, so it is frozen; the
75
+ * lenses hand readers copies.
76
+ * @param {DocsCatalog} catalog
141
77
  * @param {import('../../foundation/discovery/docs-discovery.mjs').DocsTopicEntry} entry
142
- * @param {{lang?: string|null}} [opts]
143
- * @returns {Promise<import('./docs.type.mjs').DocsDetailResponse['data']>}
78
+ * @param {string | null} [lang]
79
+ * @returns {Promise<import('../../foundation/doc-compiler/compile.mjs').CompiledReferenceNode>}
144
80
  */
145
- export async function loadTopicDoc(entry, {lang} = {}) {
146
- let doc = await loadReferenceDocs(entry.path, {lang});
147
- for (const extension of entry.extensions) {
148
- doc = mergeTopic(doc, await loadReferenceDocs(extension.path, {lang}));
149
- // Merging matches on keys, so this holds unless merge itself regresses.
150
- const problems = sectionKeyProblems(doc.sections);
151
- if (problems.length > 0) {
152
- throw new Error(
153
- `${path.basename(extension.path)}, extending ${entry.name}, leaves two sections with one key: ${problems.join('; ')}`,
154
- );
155
- }
81
+ export function lowerTopic(catalog, entry, lang = null) {
82
+ const overlay = overlayLanguage(lang);
83
+ let cache = loweredByCatalog.get(catalog);
84
+ if (!cache) {
85
+ cache = new Map();
86
+ loweredByCatalog.set(catalog, cache);
156
87
  }
157
- // Derived keys are stamped only now, so they never take part in merging.
158
- return withSectionKeys(doc);
88
+ const key = `${entry.name.toLowerCase()}\u0000${overlay ?? ''}`;
89
+ let lowered = cache.get(key);
90
+ if (!lowered) {
91
+ lowered = loadTopicInput(entry, overlay).then(input =>
92
+ deepFreeze(lowerReferenceTopic(input)),
93
+ );
94
+ cache.set(key, lowered);
95
+ }
96
+ return lowered;
159
97
  }
160
98
 
161
- /** The localized overlays a docs read can apply. */
162
- export const OVERLAY_LANGUAGES = ['zh', 'dense'];
163
-
164
99
  /**
165
- * Where the `lang` overlay of a doc file lives: `{topic}.doc.{lang}.mjs`.
166
- * @param {string} docPath
167
- * @param {string} lang
168
- * @returns {string}
100
+ * How a token reference finds its target: the topic it names in `catalog`,
101
+ * lowered for the same language.
102
+ * @param {DocsCatalog} catalog
103
+ * @param {string | null} lang
104
+ * @returns {(topic: string) => Promise<import('../../foundation/doc-compiler/compile.mjs').CompiledReferenceNode | null>}
169
105
  */
170
- function overlayPath(docPath, lang) {
171
- return path.join(
172
- path.dirname(docPath),
173
- `${path.basename(docPath, '.doc.mjs')}.doc.${lang}.mjs`,
174
- );
106
+ export function referenceTargets(catalog, lang) {
107
+ return async topic => {
108
+ const target = catalog.resolve(topic);
109
+ return target ? lowerTopic(catalog, target, lang) : null;
110
+ };
175
111
  }
176
112
 
177
113
  /**
178
- * The overlay languages a topic ships for its own file or any extension.
114
+ * One topic, compiled for `lang`: lowered, then every token reference linked.
115
+ * @param {DocsCatalog} catalog
179
116
  * @param {import('../../foundation/discovery/docs-discovery.mjs').DocsTopicEntry} entry
180
- * @returns {string[]}
117
+ * @param {string | null} [lang]
118
+ * @returns {Promise<import('../../foundation/doc-compiler/compile.mjs').CompiledReferenceNode>}
181
119
  */
182
- export function overlayLanguages(entry) {
183
- const files = [entry.path, ...entry.extensions.map(ext => ext.path)];
184
- return OVERLAY_LANGUAGES.filter(lang =>
185
- files.some(file => fs.existsSync(overlayPath(file, lang))),
120
+ export async function compileTopic(catalog, entry, lang = null) {
121
+ return linkReferenceTopic(
122
+ await lowerTopic(catalog, entry, lang),
123
+ referenceTargets(catalog, lang),
186
124
  );
187
125
  }
188
126
 
189
127
  /**
190
128
  * Resolve `topic` against the project's catalog (throwing `ERR_UNKNOWN_TOPIC`
191
- * when unmatched), and load it with any --dense/--zh overlay and any
192
- * integration extension applied. Shared by the detail and section leaves so
193
- * topic normalization and unknown-topic handling live in exactly one place.
129
+ * when unmatched) and lower it with any --dense/--zh overlay and any
130
+ * integration extension applied. Shared by the leaves so topic normalization
131
+ * and unknown-topic handling live in exactly one place.
194
132
  *
195
133
  * @param {string} topic
196
134
  * @param {object} [options]
@@ -200,7 +138,7 @@ export function overlayLanguages(entry) {
200
138
  * @param {string} [options.cwd]
201
139
  * @returns {Promise<{
202
140
  * catalog: DocsCatalog,
203
- * docsData: import('./docs.type.mjs').DocsDetailResponse['data'],
141
+ * node: import('../../foundation/doc-compiler/compile.mjs').CompiledReferenceNode,
204
142
  * lang: string | null,
205
143
  * }>}
206
144
  */
@@ -221,6 +159,6 @@ export async function resolveTopicDocs(topic, options = {}) {
221
159
  );
222
160
  }
223
161
 
224
- const docsData = await loadTopicDoc(entry, {lang: effectiveLang});
225
- return {catalog, docsData, lang: effectiveLang};
162
+ const node = await lowerTopic(catalog, entry, effectiveLang);
163
+ return {catalog, node, lang: effectiveLang};
226
164
  }
@@ -0,0 +1,78 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file Every shipped topic compiles to a plain-JSON node that answers every
5
+ * docs read exactly as the live one does, and no read can change another read
6
+ * of the same catalog.
7
+ */
8
+
9
+ import {describe, expect, it} from 'vitest';
10
+ import {parseCompiledReferenceNode} from '../../foundation/doc-compiler/ir.mjs';
11
+ import {detailView, indexView} from '../../foundation/doc-compiler/lenses.mjs';
12
+ import {
13
+ compileTopic,
14
+ loadDocsCatalog,
15
+ lowerTopic,
16
+ overlayLanguages,
17
+ } from './_adapter.mjs';
18
+
19
+ const SLOW = 60_000;
20
+
21
+ describe('every shipped topic compiles to plain JSON', () => {
22
+ it(
23
+ 'survives a JSON round trip with identical responses in every language',
24
+ async () => {
25
+ const catalog = await loadDocsCatalog();
26
+ let compiled = 0;
27
+ for (const entry of catalog.entries()) {
28
+ for (const lang of [null, ...overlayLanguages(entry)]) {
29
+ const lowered = await lowerTopic(catalog, entry, lang);
30
+ expect(parseCompiledReferenceNode(lowered)).toBe(lowered);
31
+ const node = await compileTopic(catalog, entry, lang);
32
+ expect(parseCompiledReferenceNode(node)).toBe(node);
33
+ const copy = parseCompiledReferenceNode(
34
+ JSON.parse(JSON.stringify(node)),
35
+ );
36
+ expect(JSON.stringify(detailView(copy))).toBe(
37
+ JSON.stringify(detailView(node)),
38
+ );
39
+ expect(JSON.stringify(indexView(copy))).toBe(
40
+ JSON.stringify(indexView(node)),
41
+ );
42
+ compiled += 1;
43
+ }
44
+ }
45
+ expect(compiled).toBeGreaterThan(catalog.entries().length);
46
+ },
47
+ SLOW,
48
+ );
49
+ });
50
+
51
+ describe('reads that share a catalog', () => {
52
+ it(
53
+ 'never let one read change another',
54
+ async () => {
55
+ const catalog = await loadDocsCatalog();
56
+ const tokens = catalog.resolve('tokens');
57
+ const first = detailView(await compileTopic(catalog, tokens));
58
+ for (const section of first.sections) {
59
+ section.title = 'EDITED';
60
+ for (const block of section.content) {
61
+ if (typeof block.text === 'string') block.text = 'EDITED';
62
+ if (Array.isArray(block.rows)) block.rows.push(['EDITED']);
63
+ }
64
+ }
65
+ const again = detailView(await compileTopic(catalog, tokens));
66
+ const index = indexView(await lowerTopic(catalog, tokens));
67
+ const spacing = detailView(
68
+ await compileTopic(catalog, catalog.resolve('spacing')),
69
+ );
70
+ for (const read of [again, index, spacing]) {
71
+ expect(JSON.stringify(read)).not.toContain('EDITED');
72
+ }
73
+ const lowered = await lowerTopic(catalog, tokens);
74
+ expect(Object.isFrozen(lowered.doc.sections[0].content)).toBe(true);
75
+ },
76
+ SLOW,
77
+ );
78
+ });
@@ -1,21 +1,6 @@
1
1
  // @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
2
2
  // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
3
 
4
- /**
5
- * Resolve token-ref blocks by inlining the referenced section's table.
6
- * This allows section docs to reference token tables without duplicating data.
7
- *
8
- * The reference is resolved through the catalog, so a topic may point at one
9
- * an integration contributed (or replaced) rather than only at a built-in. It
10
- * names the section by key or authored title, so it resolves in every language.
11
- * @param {import('../docs.type.mjs').DocsDetailResponse['data']} docsData
12
- * @param {import('../../../foundation/discovery/docs-discovery.mjs').DocsCatalog} catalog
13
- * @param {{lang?: string | null}} [options]
14
- * @returns {Promise<import('../docs.type.mjs').DocsDetailResponse['data']>}
15
- */
16
- export function resolveTokenRefs(docsData: import("../docs.type.mjs").DocsDetailResponse["data"], catalog: import("../../../foundation/discovery/docs-discovery.mjs").DocsCatalog, { lang }?: {
17
- lang?: string | null;
18
- }): Promise<import("../docs.type.mjs").DocsDetailResponse["data"]>;
19
4
  /**
20
5
  * @param {string} topic
21
6
  * @param {object} [options]
@@ -3,84 +3,17 @@
3
3
  /**
4
4
  * @file docs.detail leaf — load one topic's full reference doc.
5
5
  *
6
- * @input A topic name plus optional {lang, zh, dense}. Resolves and loads the
7
- * topic via the shared adapter, then inlines any token-ref blocks.
6
+ * @input A topic name plus optional {lang, zh, dense, cwd}. Resolves the topic
7
+ * via the shared adapter and compiles it with its token references linked.
8
8
  * @output { type: 'docs.detail', data: ReferenceDoc } — the full doc with
9
- * token-refs resolved, matching `xds --json docs <topic>`.
10
- * @position Leaf under api/docs. Owns resolveTokenRefs (used only here); shares
11
- * discovery/loading/topic-resolution with the section leaf via _adapter.mjs.
9
+ * token-refs inlined, matching `astryx --json docs <topic>`.
10
+ * @position Leaf under api/docs. Reads the compiled node through the detail
11
+ * lens; resolution, overlays and extensions happen in the compiler.
12
12
  */
13
13
 
14
- import {loadTopicDoc, resolveTopicDocs} from '../_adapter.mjs';
15
- import {
16
- sectionKey,
17
- sourceTitle,
18
- withSourceTitle,
19
- } from '../../../foundation/discovery/docs-section-key.mjs';
20
-
21
- /**
22
- * Resolve token-ref blocks by inlining the referenced section's table.
23
- * This allows section docs to reference token tables without duplicating data.
24
- *
25
- * The reference is resolved through the catalog, so a topic may point at one
26
- * an integration contributed (or replaced) rather than only at a built-in. It
27
- * names the section by key or authored title, so it resolves in every language.
28
- * @param {import('../docs.type.mjs').DocsDetailResponse['data']} docsData
29
- * @param {import('../../../foundation/discovery/docs-discovery.mjs').DocsCatalog} catalog
30
- * @param {{lang?: string | null}} [options]
31
- * @returns {Promise<import('../docs.type.mjs').DocsDetailResponse['data']>}
32
- */
33
- export async function resolveTokenRefs(docsData, catalog, {lang = null} = {}) {
34
- const resolved = {...docsData, sections: [...docsData.sections]};
35
- for (let si = 0; si < resolved.sections.length; si++) {
36
- const section = resolved.sections[si];
37
- /** @type {import('@astryxdesign/cli/authoring').ReferenceContentBlock[]} */
38
- const newContent = [];
39
- for (const block of section.content) {
40
- if (block.type === 'token-ref') {
41
- const refEntry = catalog.resolve(block.topic);
42
- if (!refEntry) {
43
- newContent.push({type: 'prose', text: `[token-ref: unknown topic "${block.topic}"]`});
44
- continue;
45
- }
46
- const refDocs = await loadTopicDoc(refEntry, {lang});
47
- const wanted = block.section.toLowerCase();
48
- const refSection = refDocs.sections.find(
49
- (/** @type {import('@astryxdesign/cli/authoring').ReferenceSection} */ s) =>
50
- sectionKey(s) === block.section ||
51
- sourceTitle(s).toLowerCase() === wanted,
52
- );
53
- if (!refSection) {
54
- newContent.push({type: 'prose', text: `[token-ref: section "${block.section}" not found in "${block.topic}"]`});
55
- continue;
56
- }
57
- // Inline the referenced section's content blocks (tables, prose, etc.)
58
- // and carry over the previewType
59
- for (const refBlock of refSection.content) {
60
- newContent.push(refBlock);
61
- }
62
- // If the referenced section has a previewType, attach it to our section
63
- if (refSection.previewType && !section.previewType) {
64
- resolved.sections[si] = withSourceTitle(
65
- {...section, previewType: refSection.previewType, content: newContent},
66
- sourceTitle(section),
67
- );
68
- }
69
- } else {
70
- newContent.push(block);
71
- }
72
- }
73
- if (resolved.sections[si] === section) {
74
- resolved.sections[si] = withSourceTitle(
75
- {...section, content: newContent},
76
- sourceTitle(section),
77
- );
78
- } else {
79
- resolved.sections[si].content = newContent;
80
- }
81
- }
82
- return resolved;
83
- }
14
+ import {linkReferenceTopic} from '../../../foundation/doc-compiler/compile.mjs';
15
+ import {detailView} from '../../../foundation/doc-compiler/lenses.mjs';
16
+ import {referenceTargets, resolveTopicDocs} from '../_adapter.mjs';
84
17
 
85
18
  /**
86
19
  * @param {string} topic
@@ -92,7 +25,10 @@ export async function resolveTokenRefs(docsData, catalog, {lang = null} = {}) {
92
25
  * @returns {Promise<import('../docs.type.mjs').DocsDetailResponse>}
93
26
  */
94
27
  export async function detail(topic, options = {}) {
95
- const {catalog, docsData, lang} = await resolveTopicDocs(topic, options);
96
- const resolved = await resolveTokenRefs(docsData, catalog, {lang});
97
- return {type: 'docs.detail', data: resolved};
28
+ const {catalog, node, lang} = await resolveTopicDocs(topic, options);
29
+ const linked = await linkReferenceTopic(
30
+ node,
31
+ referenceTargets(catalog, lang),
32
+ );
33
+ return {type: 'docs.detail', data: detailView(linked)};
98
34
  }
@@ -4,14 +4,15 @@
4
4
  * @file docs.detail.section leaf — load a single section of a topic.
5
5
  *
6
6
  * @input A topic name, a section query, and optional {lang, zh, dense}. Resolves
7
- * and loads the topic via the shared adapter, then finds the section by its
8
- * stable key, then by exact title, then by a title that contains the query.
7
+ * the topic via the shared adapter, finds the section in its lowered compiled
8
+ * node by its stable key, then by exact title, then by a title that contains
9
+ * the query, and links only that section.
9
10
  * @output { type: 'docs.detail.section', data: ReferenceSection } with any
10
11
  * token-ref blocks inlined — matching `astryx --json docs <topic> <section>`.
11
12
  * Throws ERR_UNKNOWN_SECTION when nothing matches, or when the query matches
12
13
  * more than one section (the candidates come back as suggestions).
13
- * @position Leaf nested under api/docs/detail. Shares discovery/loading/
14
- * topic-resolution with the detail leaf via _adapter.mjs.
14
+ * @position Leaf nested under api/docs/detail. Shares topic resolution with the
15
+ * detail leaf via _adapter.mjs and reads through the compiler's lenses.
15
16
  */
16
17
 
17
18
  import {AstryxError} from '../../../error.mjs';
@@ -20,8 +21,12 @@ import {
20
21
  findDocSection,
21
22
  sectionKey,
22
23
  } from '../../../../foundation/discovery/docs-section-key.mjs';
23
- import {resolveTopicDocs} from '../../_adapter.mjs';
24
- import {resolveTokenRefs} from '../detail.mjs';
24
+ import {linkReferenceSection} from '../../../../foundation/doc-compiler/compile.mjs';
25
+ import {
26
+ readerSections,
27
+ sectionView,
28
+ } from '../../../../foundation/doc-compiler/lenses.mjs';
29
+ import {referenceTargets, resolveTopicDocs} from '../../_adapter.mjs';
25
30
 
26
31
  /**
27
32
  * @param {string} topic
@@ -44,31 +49,30 @@ export async function section(topic, sectionName, options = {}) {
44
49
  ERROR_CODES.ERR_UNKNOWN_SECTION,
45
50
  );
46
51
  }
47
- const {catalog, docsData, lang} = await resolveTopicDocs(topic, options);
48
52
 
49
- const {section: match, candidates} = findDocSection(
50
- docsData.sections,
51
- sectionName,
52
- );
53
+ const {catalog, node, lang} = await resolveTopicDocs(topic, options);
54
+ const sections = readerSections(node);
55
+ const {section: match, candidates} = findDocSection(sections, sectionName);
53
56
  if (!match) {
54
57
  const ambiguous = candidates.length > 1;
55
58
  throw new AstryxError(
56
59
  ambiguous
57
60
  ? `Section "${sectionName}" matches ${candidates.length} sections in "${topic}". Read one by its key.`
58
61
  : `Section "${sectionName}" not found in "${topic}"`,
59
- (ambiguous ? candidates : docsData.sections).map(s => ({
62
+ (ambiguous ? candidates : sections).map(s => ({
60
63
  name: sectionKey(s),
61
64
  reason: s.title,
62
65
  })),
63
66
  ERROR_CODES.ERR_UNKNOWN_SECTION,
64
67
  );
65
68
  }
69
+
66
70
  // A section read on its own inlines its token refs, as the whole topic does;
67
- // otherwise a section that is only a token-ref prints blank.
68
- const {sections} = await resolveTokenRefs(
69
- {...docsData, sections: [match]},
70
- catalog,
71
- {lang},
71
+ // otherwise a section that is only a token-ref prints blank. Only this
72
+ // section is linked, so a broken reference elsewhere cannot fail the read.
73
+ const linked = await linkReferenceSection(
74
+ match,
75
+ referenceTargets(catalog, lang),
72
76
  );
73
- return {type: 'docs.detail.section', data: sections[0]};
77
+ return {type: 'docs.detail.section', data: sectionView(node, linked)};
74
78
  }