@astryxdesign/cli 0.6.2 → 0.6.3-canary.039a67e

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 (540) hide show
  1. package/CHANGELOG.md +118 -1
  2. package/README.md +108 -72
  3. package/api/blog/blog.doc.mjs +1 -0
  4. package/api/build/build.doc.mjs +4 -3
  5. package/api/build/build.test.mjs +14 -3
  6. package/api/build/build.type.d.mts +36 -2
  7. package/api/build/build.type.mjs +25 -4
  8. package/api/build/help/help.d.mts +8 -5
  9. package/api/build/help/help.mjs +56 -6
  10. package/api/component/component.doc.mjs +13 -3
  11. package/api/component/component.mjs +31 -2
  12. package/api/component/component.test.mjs +38 -0
  13. package/api/component/component.type.d.mts +22 -11
  14. package/api/component/component.type.mjs +32 -24
  15. package/api/component/detail/blocks/blocks.d.mts +2 -1
  16. package/api/component/detail/blocks/blocks.mjs +4 -3
  17. package/api/component/list/list.d.mts +0 -5
  18. package/api/component/list/list.mjs +37 -9
  19. package/api/discover/discover.doc.mjs +2 -1
  20. package/api/discover/discover.type.d.mts +4 -4
  21. package/api/discover/discover.type.mjs +10 -10
  22. package/api/docs/_adapter.d.mts +32 -24
  23. package/api/docs/_adapter.mjs +81 -87
  24. package/api/docs/compiled-topics.test.mjs +78 -0
  25. package/api/docs/detail/detail.mjs +14 -63
  26. package/api/docs/detail/section/section.d.mts +1 -1
  27. package/api/docs/detail/section/section.mjs +37 -19
  28. package/api/docs/detail/section/section.test.mjs +50 -0
  29. package/api/docs/docs.d.mts +7 -2
  30. package/api/docs/docs.doc.mjs +28 -10
  31. package/api/docs/docs.mjs +16 -9
  32. package/api/docs/docs.test.mjs +6 -0
  33. package/api/docs/docs.type.d.mts +40 -3
  34. package/api/docs/docs.type.mjs +36 -8
  35. package/api/docs/index/index.d.mts +18 -0
  36. package/api/docs/index/index.mjs +32 -0
  37. package/api/docs/index/index.test.mjs +62 -0
  38. package/api/docs/integrationDocs.test.mjs +106 -0
  39. package/api/docs/list/list.mjs +3 -7
  40. package/api/doctor/doctor.d.mts +70 -0
  41. package/api/doctor/doctor.doc.mjs +1 -0
  42. package/api/doctor/doctor.mjs +404 -0
  43. package/api/doctor/doctor.test.mjs +522 -1
  44. package/api/gap-report/gap-report.doc.mjs +8 -4
  45. package/api/hook/_adapter.mjs +19 -5
  46. package/api/hook/hook.doc.mjs +1 -0
  47. package/api/hook/hook.type.d.mts +3 -3
  48. package/api/hook/hook.type.mjs +11 -11
  49. package/api/hook/list/list.d.mts +2 -2
  50. package/api/hook/list/list.mjs +69 -17
  51. package/api/init/init.doc.mjs +5 -0
  52. package/api/init/init.test.mjs +41 -1
  53. package/api/init/remove/remove.mjs +1 -1
  54. package/api/init/run/run.mjs +20 -10
  55. package/api/integration/add-contribution.component-names.test.mjs +120 -0
  56. package/api/integration/add-contribution.mjs +23 -10
  57. package/api/integration/add-contribution.test.mjs +121 -7
  58. package/api/integration/add-theme.mjs +34 -64
  59. package/api/integration/add-theme.test.mjs +105 -21
  60. package/api/integration/authoring-checks.test.mjs +8 -4
  61. package/api/integration/integration-authoring.type.d.mts +1 -1
  62. package/api/integration/integration-block-exports.test.mjs +10 -6
  63. package/api/integration/integrationAdd.doc.mjs +8 -4
  64. package/api/integration/integrationAddAgentDoc.doc.mjs +1 -0
  65. package/api/integration/integrationAddCodemod.doc.mjs +1 -0
  66. package/api/integration/integrationAddComponent.doc.mjs +2 -1
  67. package/api/integration/integrationAddDoc.doc.mjs +1 -0
  68. package/api/integration/integrationAddTemplate.doc.mjs +1 -0
  69. package/api/integration/integrationAddTheme.doc.mjs +6 -5
  70. package/api/integration/integrationComponentConflicts.doc.mjs +1 -0
  71. package/api/integration/integrationDocConflicts.doc.mjs +1 -0
  72. package/api/integration/integrationPackCheck.doc.mjs +1 -0
  73. package/api/integration/integrationTemplateConflicts.doc.mjs +1 -0
  74. package/api/integration/pack-check.mjs +49 -7
  75. package/api/integration/pack-check.test.mjs +266 -47
  76. package/api/integration/summarizeIssues.doc.mjs +1 -0
  77. package/api/integration/validate-integration-fixes.test.mjs +1389 -0
  78. package/api/integration/validate-integration.mjs +52 -102
  79. package/api/integration/validate-integration.test.mjs +176 -23
  80. package/api/integration/validate-unread-theme-folders.test.mjs +110 -0
  81. package/api/integration/validateIntegration.doc.mjs +2 -1
  82. package/api/json/assertResponse.doc.mjs +1 -0
  83. package/api/json/envelope-types.test.mjs +76 -0
  84. package/api/json/isError.doc.mjs +1 -0
  85. package/api/json/parseResponse.doc.mjs +3 -2
  86. package/api/layout/expand/expand.mjs +7 -5
  87. package/api/layout/expand/expand.path-safety.test.mjs +53 -0
  88. package/api/layout/grammar/grammar.mjs +2 -1
  89. package/api/layout/layoutCheck.doc.mjs +1 -0
  90. package/api/layout/layoutExpand.doc.mjs +2 -1
  91. package/api/layout/layoutGrammar.doc.mjs +1 -0
  92. package/api/search/search-return-type.test.mjs +54 -0
  93. package/api/search/search.d.mts +3 -10
  94. package/api/search/search.doc.mjs +6 -1
  95. package/api/search/search.mjs +31 -14
  96. package/api/search/search.test.mjs +34 -0
  97. package/api/search/search.type.d.mts +2 -2
  98. package/api/search/search.type.mjs +1 -1
  99. package/api/swizzle/copy/copy.mjs +28 -11
  100. package/api/swizzle/swizzle.doc.mjs +2 -1
  101. package/api/swizzle/swizzle.type.d.mts +2 -2
  102. package/api/swizzle/swizzle.type.mjs +2 -2
  103. package/api/template/copy/copy.mjs +17 -23
  104. package/api/template/copy/copy.test.mjs +17 -0
  105. package/api/template/template-suffix.test.mjs +41 -21
  106. package/api/template/template.d.mts +1 -1
  107. package/api/template/template.doc.mjs +3 -1
  108. package/api/template/template.type.d.mts +6 -6
  109. package/api/template/template.type.mjs +12 -12
  110. package/api/theme/_adapter.d.mts +2 -3
  111. package/api/theme/_adapter.mjs +4 -5
  112. package/api/theme/add/add.binary.test.mjs +84 -0
  113. package/api/theme/add/add.mjs +20 -3
  114. package/api/theme/add/add.staging.test.mjs +66 -0
  115. package/api/theme/add/add.test.mjs +14 -1
  116. package/api/theme/build/build.mjs +133 -42
  117. package/api/theme/build/build.public-component-vars.test.mjs +1 -1
  118. package/api/theme/build/build.receipt-doc.test.mjs +111 -0
  119. package/api/theme/build/build.test.mjs +127 -0
  120. package/api/theme/build/font-warning.mjs +3 -3
  121. package/api/theme/build/font-warning.test.mjs +5 -2
  122. package/api/theme/generateTonalPalette.doc.mjs +1 -0
  123. package/api/theme/integration-themes.test.mjs +39 -28
  124. package/api/theme/list/list.test.mjs +19 -20
  125. package/api/theme/listThemes.doc.mjs +6 -5
  126. package/api/theme/palette/generate/generate.mjs +8 -3
  127. package/api/theme/palette/generate/generate.test.mjs +96 -0
  128. package/api/theme/palette/generate/generator.d.mts +10 -13
  129. package/api/theme/palette/generate/generator.mjs +15 -4
  130. package/api/theme/palette/generate/generator.test.mjs +10 -0
  131. package/api/theme/template/template.mjs +11 -2
  132. package/api/theme/template/template.test.mjs +15 -0
  133. package/api/theme/theme.type.d.mts +170 -11
  134. package/api/theme/theme.type.mjs +94 -27
  135. package/api/theme/themeAdd.doc.mjs +4 -3
  136. package/api/theme/themeBuild.doc.mjs +8 -4
  137. package/api/theme/themeList.doc.mjs +6 -3
  138. package/api/theme/themeListAvailable.doc.mjs +5 -3
  139. package/api/theme/themePaletteGenerate.doc.mjs +1 -0
  140. package/api/theme/themeTargets.doc.mjs +1 -0
  141. package/api/theme/themeTemplate.doc.mjs +5 -1
  142. package/api/upgrade/_adapter.d.mts +32 -5
  143. package/api/upgrade/_adapter.mjs +139 -22
  144. package/api/upgrade/list/list.mjs +2 -1
  145. package/api/upgrade/list/list.test.mjs +73 -0
  146. package/api/upgrade/project-context.test.mjs +272 -0
  147. package/api/upgrade/provider-agreement.test.mjs +152 -0
  148. package/api/upgrade/run/run.mjs +356 -59
  149. package/api/upgrade/status/status.mjs +2 -2
  150. package/api/upgrade/upgrade.doc.mjs +12 -5
  151. package/api/upgrade/upgrade.type.d.mts +43 -5
  152. package/api/upgrade/upgrade.type.mjs +27 -11
  153. package/assets/codemods/__tests__/runner.test.mjs +330 -8
  154. package/assets/codemods/integration-discovery.mjs +48 -4
  155. package/assets/codemods/integration-discovery.test.mjs +73 -0
  156. package/assets/codemods/integration-runner.mjs +56 -4
  157. package/assets/codemods/integration-runner.protection.test.mjs +153 -0
  158. package/assets/codemods/run-codemod.mjs +177 -34
  159. package/assets/codemods/runner.mjs +350 -102
  160. package/assets/codemods/term-log.mjs +32 -8
  161. package/assets/codemods/term-log.test.mjs +19 -1
  162. package/assets/codemods/transform-prop.mjs +109 -0
  163. package/assets/codemods/transform-prop.test.mjs +95 -0
  164. package/assets/codemods/transforms/next/__tests__/migrate-native-picker-to-presentation.test.mjs +63 -0
  165. package/assets/codemods/transforms/next/__tests__/migrate-theme-catalog-to-descriptors.test.mjs +220 -0
  166. package/assets/codemods/transforms/next/index.mjs +19 -1
  167. package/assets/codemods/transforms/next/migrate-native-picker-to-presentation.mjs +148 -0
  168. package/assets/codemods/transforms/next/migrate-theme-catalog-to-descriptors.mjs +141 -0
  169. package/assets/codemods/transforms/v0.0.14/__tests__/rename-status-variants.test.mjs +86 -165
  170. package/assets/codemods/transforms/v0.0.14/rename-status-variants.mjs +72 -210
  171. package/assets/codemods/transforms/v0.1.8/__tests__/rename-avatar-size-scale.test.mjs +83 -115
  172. package/assets/codemods/transforms/v0.1.8/rename-avatar-size-scale.mjs +57 -186
  173. package/assets/codemods/transforms/v0.3.0/__tests__/unwrap-authoring-factories.test.mjs +27 -5
  174. package/assets/codemods/transforms/v0.3.0/unwrap-authoring-factories.mjs +20 -5
  175. package/assets/codemods/transforms/v0.6.0/__tests__/next-codemods.test.mjs +47 -0
  176. package/assets/codemods/transforms/v0.6.0/rename-resizable-pixel-bounds.mjs +57 -10
  177. package/assets/docs/README.md +9 -0
  178. package/assets/docs/authoring.doc.mjs +14 -0
  179. package/assets/docs/cli-integrations.doc.mjs +91 -20
  180. package/assets/docs/cli.doc.mjs +15 -0
  181. package/assets/docs/styling-libraries.doc.mjs +1 -1
  182. package/assets/docs/theme.doc.mjs +1 -1
  183. package/assets/docs/working-with-ai.doc.mjs +1 -1
  184. package/assets/templates/blocks/components/DateInput/DateInputDateRange.tsx +1 -1
  185. package/assets/templates/blocks/components/Item/ItemDocumentTabs.doc.mjs +14 -0
  186. package/assets/templates/blocks/components/Item/ItemDocumentTabs.tsx +100 -0
  187. package/assets/templates/blocks/components/Kbd/KbdModifierCombos.tsx +3 -1
  188. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaInlineRail.doc.mjs +14 -0
  189. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaInlineRail.tsx +61 -0
  190. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaOverscrollChaining.doc.mjs +14 -0
  191. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaOverscrollChaining.tsx +126 -0
  192. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaShowcase.doc.mjs +15 -0
  193. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaShowcase.tsx +86 -0
  194. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaStickyGroupHeaders.doc.mjs +14 -0
  195. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaStickyGroupHeaders.tsx +99 -0
  196. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaStickyPassthrough.doc.mjs +14 -0
  197. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaStickyPassthrough.tsx +122 -0
  198. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaTwoAxisBoard.doc.mjs +14 -0
  199. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaTwoAxisBoard.tsx +95 -0
  200. package/assets/templates/blocks/components/TimeInput/TimeInputConstrained.tsx +1 -0
  201. package/assets/templates/blocks/components/Timer/TimerFormats.doc.mjs +14 -0
  202. package/assets/templates/blocks/components/Timer/TimerFormats.tsx +34 -0
  203. package/assets/templates/blocks/components/Timer/TimerInline.doc.mjs +14 -0
  204. package/assets/templates/blocks/components/Timer/TimerInline.tsx +14 -0
  205. package/assets/templates/blocks/components/Timer/TimerShowcase.doc.mjs +13 -0
  206. package/assets/templates/blocks/components/Timer/TimerShowcase.tsx +47 -0
  207. package/assets/templates/blocks/components/Timer/TimerTypography.doc.mjs +14 -0
  208. package/assets/templates/blocks/components/Timer/TimerTypography.tsx +31 -0
  209. package/assets/templates/blocks/components/Toolbar/ToolbarTableFilter.doc.mjs +19 -3
  210. package/assets/templates/blocks/components/Toolbar/ToolbarTableFilter.tsx +383 -65
  211. package/assets/templates/pages/canvas-editor/page.tsx +2875 -0
  212. package/assets/templates/pages/canvas-editor/template.doc.mjs +12 -0
  213. package/assets/templates/pages/table-tree/page.tsx +1704 -0
  214. package/assets/templates/pages/table-tree/template.doc.mjs +12 -0
  215. package/assets/templates/themes/butter/butterTheme.doc.mjs +11 -0
  216. package/assets/templates/themes/chocolate/chocolateTheme.doc.mjs +11 -0
  217. package/assets/templates/themes/gothic/gothicTheme.doc.mjs +11 -0
  218. package/assets/templates/themes/matcha/matchaTheme.doc.mjs +11 -0
  219. package/assets/templates/themes/neutral/neutralTheme.doc.mjs +11 -0
  220. package/assets/templates/themes/stone/stoneTheme.doc.mjs +11 -0
  221. package/assets/templates/themes/y2k/y2kTheme.doc.mjs +11 -0
  222. package/authoring/_shared/contract.ts +22 -0
  223. package/authoring/codemod/codemod.doc.mjs +7 -2
  224. package/authoring/codemod/parse.d.mts +8 -8
  225. package/authoring/codemod/parse.mjs +8 -6
  226. package/authoring/codemod/type.ts +12 -0
  227. package/authoring/config/config.doc.mjs +2 -2
  228. package/authoring/config/debug-composition.test.mjs +92 -0
  229. package/authoring/config/parse.d.mts +13 -13
  230. package/authoring/config/parse.mjs +8 -8
  231. package/authoring/config/type.ts +18 -6
  232. package/authoring/debug/debug.doc.d.mts +11 -0
  233. package/authoring/debug/debug.doc.mjs +182 -0
  234. package/authoring/debug/parse.d.mts +5 -5
  235. package/authoring/debug/parse.mjs +3 -3
  236. package/authoring/doctypes/_schema.d.mts +718 -23
  237. package/authoring/doctypes/_schema.mjs +519 -39
  238. package/authoring/doctypes/base/graph-fields.doc.d.mts +9 -0
  239. package/authoring/doctypes/base/graph-fields.doc.mjs +62 -0
  240. package/authoring/doctypes/base/type.ts +40 -0
  241. package/authoring/doctypes/command/command.doc.mjs +4 -3
  242. package/authoring/doctypes/command/parse.d.mts +2 -2
  243. package/authoring/doctypes/command/parse.mjs +1 -1
  244. package/authoring/doctypes/command/type.ts +4 -3
  245. package/authoring/doctypes/component/component.doc.mjs +6 -3
  246. package/authoring/doctypes/component/parse.d.mts +2 -2
  247. package/authoring/doctypes/component/parse.mjs +1 -1
  248. package/authoring/doctypes/component/type.ts +6 -5
  249. package/authoring/doctypes/doctypes-new.test.mjs +48 -6
  250. package/authoring/doctypes/enum/enum.doc.mjs +1 -1
  251. package/authoring/doctypes/enum/parse.d.mts +2 -2
  252. package/authoring/doctypes/enum/parse.mjs +1 -1
  253. package/authoring/doctypes/enum/type.ts +4 -2
  254. package/authoring/doctypes/function/function.doc.mjs +5 -1
  255. package/authoring/doctypes/function/parse.d.mts +2 -2
  256. package/authoring/doctypes/function/parse.mjs +1 -1
  257. package/authoring/doctypes/function/type.ts +7 -3
  258. package/authoring/doctypes/hook/hook.doc.mjs +4 -0
  259. package/authoring/doctypes/hook/parse.d.mts +2 -2
  260. package/authoring/doctypes/hook/parse.mjs +1 -1
  261. package/authoring/doctypes/hook/type.ts +5 -4
  262. package/authoring/doctypes/legacy.d.mts +8 -6
  263. package/authoring/doctypes/legacy.mjs +5 -4
  264. package/authoring/doctypes/load-contract.test.mjs +208 -0
  265. package/authoring/doctypes/namespace/namespace.doc.d.mts +9 -0
  266. package/authoring/doctypes/namespace/namespace.doc.mjs +132 -0
  267. package/authoring/doctypes/namespace/parse.d.mts +12 -0
  268. package/authoring/doctypes/namespace/parse.mjs +25 -0
  269. package/authoring/doctypes/namespace/parse.test.mjs +163 -0
  270. package/authoring/doctypes/namespace/type.ts +74 -0
  271. package/authoring/doctypes/parse.d.mts +22 -18
  272. package/authoring/doctypes/parse.mjs +22 -11
  273. package/authoring/doctypes/parse.test.mjs +77 -3
  274. package/authoring/doctypes/reference/parse.d.mts +2 -2
  275. package/authoring/doctypes/reference/parse.mjs +8 -5
  276. package/authoring/doctypes/reference/reference.doc.mjs +20 -5
  277. package/authoring/doctypes/reference/type.ts +50 -5
  278. package/authoring/doctypes/schema/parse.d.mts +2 -2
  279. package/authoring/doctypes/schema/parse.mjs +1 -1
  280. package/authoring/doctypes/schema/schema.doc.mjs +1 -1
  281. package/authoring/doctypes/schema/type.ts +4 -4
  282. package/authoring/doctypes/template/parse.d.mts +92 -1
  283. package/authoring/doctypes/template/parse.mjs +36 -2
  284. package/authoring/doctypes/template/parse.test.mjs +8 -2
  285. package/authoring/doctypes/template/template.doc.mjs +7 -3
  286. package/authoring/doctypes/template/type.ts +6 -2
  287. package/authoring/doctypes/theme/parse.d.mts +35 -0
  288. package/authoring/doctypes/theme/parse.mjs +76 -0
  289. package/authoring/doctypes/theme/theme.doc.d.mts +9 -0
  290. package/authoring/doctypes/theme/theme.doc.mjs +79 -0
  291. package/authoring/doctypes/theme/type.ts +42 -0
  292. package/authoring/doctypes/types.ts +12 -10
  293. package/authoring/gap-report/gap-report.doc.d.mts +12 -0
  294. package/authoring/gap-report/gap-report.doc.mjs +183 -0
  295. package/authoring/gap-report/parse.d.mts +10 -10
  296. package/authoring/gap-report/parse.mjs +6 -6
  297. package/authoring/gap-report/type.ts +1 -1
  298. package/authoring/identity/identity.doc.d.mts +9 -0
  299. package/authoring/identity/identity.doc.mjs +61 -0
  300. package/authoring/identity/type.ts +132 -0
  301. package/authoring/index.d.mts +2 -0
  302. package/authoring/index.d.ts +52 -17
  303. package/authoring/index.mjs +3 -1
  304. package/authoring/integration/integration.doc.mjs +15 -8
  305. package/authoring/integration/parse.d.mts +2 -2
  306. package/authoring/integration/parse.mjs +1 -1
  307. package/authoring/integration/parse.test.mjs +10 -1
  308. package/authoring/integration/schema.d.mts +6 -4
  309. package/authoring/integration/schema.mjs +9 -3
  310. package/authoring/integration/type.ts +18 -7
  311. package/authoring/shadcn/receipt.d.mts +6 -6
  312. package/clients/cli/__tests__/cliManifest.test.ts +27 -29
  313. package/clients/cli/command-load-failure.test.mjs +83 -0
  314. package/clients/cli/commands/blog.doc.mjs +1 -1
  315. package/clients/cli/commands/blog.mjs +23 -8
  316. package/clients/cli/commands/blog.test.mjs +42 -1
  317. package/clients/cli/commands/build-theme.adaptations.test.mjs +100 -1
  318. package/clients/cli/commands/build-theme.ascii-output.test.mjs +161 -0
  319. package/clients/cli/commands/build-theme.flag-docs.test.mjs +110 -0
  320. package/clients/cli/commands/build-theme.mjs +15 -49
  321. package/clients/cli/commands/build-theme.path-safety.test.mjs +86 -1
  322. package/clients/cli/commands/build-theme.variants.test.mjs +76 -0
  323. package/clients/cli/commands/build.doc.mjs +5 -2
  324. package/clients/cli/commands/build.exit-codes-doc.test.mjs +50 -0
  325. package/clients/cli/commands/build.mjs +32 -47
  326. package/clients/cli/commands/build.playbook.test.mjs +75 -0
  327. package/clients/cli/commands/build.text-fields.test.mjs +40 -0
  328. package/clients/cli/commands/component/index.mjs +2 -7
  329. package/clients/cli/commands/component-package.test.mjs +46 -0
  330. package/clients/cli/commands/component-resolution.test.mjs +21 -0
  331. package/clients/cli/commands/component.doc.mjs +1 -1
  332. package/clients/cli/commands/component.test.mjs +19 -0
  333. package/clients/cli/commands/detail-levels.test.mjs +2 -2
  334. package/clients/cli/commands/discover.broken-integration.test.mjs +48 -0
  335. package/clients/cli/commands/discover.components-flag.test.mjs +97 -0
  336. package/clients/cli/commands/discover.doc.mjs +5 -3
  337. package/clients/cli/commands/discover.mjs +3 -3
  338. package/clients/cli/commands/discover.text-projection.test.mjs +103 -0
  339. package/clients/cli/commands/docs.doc.mjs +14 -4
  340. package/clients/cli/commands/docs.mjs +73 -16
  341. package/clients/cli/commands/docs.test.mjs +85 -0
  342. package/clients/cli/commands/doctor-integration-components.doc.mjs +1 -1
  343. package/clients/cli/commands/doctor-integration-docs.doc.mjs +1 -1
  344. package/clients/cli/commands/doctor-integration-templates.doc.mjs +1 -1
  345. package/clients/cli/commands/doctor-integration-validate.doc.mjs +1 -1
  346. package/clients/cli/commands/doctor-integration.doc.mjs +1 -1
  347. package/clients/cli/commands/doctor-integration.package-json.test.mjs +53 -0
  348. package/clients/cli/commands/doctor-integration.test.mjs +15 -7
  349. package/clients/cli/commands/doctor.doc.mjs +1 -1
  350. package/clients/cli/commands/doctor.mjs +6 -16
  351. package/clients/cli/commands/doctor.test.mjs +42 -0
  352. package/clients/cli/commands/gap-report.doc.mjs +17 -6
  353. package/clients/cli/commands/gap-report.test.mjs +72 -0
  354. package/clients/cli/commands/hook/index.mjs +7 -17
  355. package/clients/cli/commands/hook.doc.mjs +1 -1
  356. package/clients/cli/commands/hook.text-projection.test.mjs +45 -0
  357. package/clients/cli/commands/init.doc.mjs +20 -9
  358. package/clients/cli/commands/init.flag-help.test.mjs +153 -0
  359. package/clients/cli/commands/integration-add.controls.test.mjs +132 -0
  360. package/clients/cli/commands/integration-add.doc.mjs +22 -6
  361. package/clients/cli/commands/integration-authoring.test.mjs +13 -9
  362. package/clients/cli/commands/integration-pack.doc.mjs +1 -1
  363. package/clients/cli/commands/integration-real-world.test.mjs +3 -9
  364. package/clients/cli/commands/integration.doc.mjs +1 -1
  365. package/clients/cli/commands/interactive-guard.test.mjs +101 -24
  366. package/clients/cli/commands/json-contract.test.mjs +33 -0
  367. package/clients/cli/commands/layout-check.doc.mjs +15 -4
  368. package/clients/cli/commands/layout-expand.doc.mjs +22 -5
  369. package/clients/cli/commands/layout-grammar.doc.mjs +1 -1
  370. package/clients/cli/commands/layout.doc.mjs +3 -3
  371. package/clients/cli/commands/layout.mjs +21 -9
  372. package/clients/cli/commands/layout.path-help.test.mjs +33 -0
  373. package/clients/cli/commands/layout.stdin-cap.test.mjs +47 -0
  374. package/clients/cli/commands/layout.text-fields.test.mjs +39 -0
  375. package/clients/cli/commands/manifest.doc.mjs +1 -1
  376. package/clients/cli/commands/no-prompt-wording.test.mjs +94 -0
  377. package/clients/cli/commands/search.doc.mjs +7 -4
  378. package/clients/cli/commands/search.mjs +17 -7
  379. package/clients/cli/commands/search.test.mjs +75 -0
  380. package/clients/cli/commands/swizzle.doc.mjs +3 -2
  381. package/clients/cli/commands/swizzle.path-safety.test.mjs +42 -0
  382. package/clients/cli/commands/template.doc.mjs +29 -7
  383. package/clients/cli/commands/template.flag-help.test.mjs +117 -0
  384. package/clients/cli/commands/template.path-help.test.mjs +40 -0
  385. package/clients/cli/commands/text-json-parity.test.mjs +718 -0
  386. package/clients/cli/commands/theme-add.doc.mjs +4 -3
  387. package/clients/cli/commands/theme-build.doc.mjs +8 -7
  388. package/clients/cli/commands/theme-list.doc.mjs +2 -2
  389. package/clients/cli/commands/theme-palette-generate.doc.mjs +9 -5
  390. package/clients/cli/commands/theme-palette-generate.test.mjs +19 -0
  391. package/clients/cli/commands/theme-palette.doc.mjs +1 -1
  392. package/clients/cli/commands/theme-targets.behavior.test.mjs +4 -3
  393. package/clients/cli/commands/theme-targets.doc.mjs +1 -1
  394. package/clients/cli/commands/theme-template.behavior.test.mjs +12 -0
  395. package/clients/cli/commands/theme-template.doc.mjs +2 -2
  396. package/clients/cli/commands/theme.doc.mjs +1 -1
  397. package/clients/cli/commands/upgrade.ascii-output.test.mjs +87 -0
  398. package/clients/cli/commands/upgrade.doc.mjs +22 -10
  399. package/clients/cli/commands/upgrade.file-protection.test.mjs +228 -0
  400. package/clients/cli/commands/upgrade.flag-help.test.mjs +188 -0
  401. package/clients/cli/commands/upgrade.hook-output.test.mjs +88 -0
  402. package/clients/cli/commands/upgrade.mjs +29 -7
  403. package/clients/cli/formatters/index.mjs +164 -1
  404. package/clients/cli/formatters/index.test.mjs +97 -0
  405. package/clients/cli/index.mjs +13 -30
  406. package/clients/cli/latest-version-env.test.mjs +50 -0
  407. package/clients/cli/lib/cli-error.test.mjs +7 -0
  408. package/clients/cli/lib/component-format.mjs +9 -9
  409. package/clients/cli/lib/component-format.test.mjs +1 -1
  410. package/clients/cli/lib/define-command.mjs +32 -6
  411. package/clients/cli/lib/doc-text-ascii.test.mjs +82 -0
  412. package/clients/cli/lib/exit-codes.test.mjs +97 -0
  413. package/clients/cli/lib/hook-format.mjs +19 -10
  414. package/clients/cli/lib/json-shim.mjs +38 -2
  415. package/clients/cli/lib/json-shim.test.mjs +83 -0
  416. package/clients/cli/lib/manifest.d.ts +2 -0
  417. package/clients/cli/lib/manifest.mjs +29 -2
  418. package/clients/cli/lib/manifest.test.mjs +17 -0
  419. package/foundation/agent-docs/agent-docs.d.mts +4 -0
  420. package/foundation/agent-docs/agent-docs.mjs +69 -3
  421. package/foundation/agent-docs/agent-docs.path-safety.test.mjs +266 -4
  422. package/foundation/config/integration-debug.test.mjs +28 -3
  423. package/foundation/config/project-themes.test.mjs +11 -19
  424. package/foundation/config/project.d.mts +8 -0
  425. package/foundation/config/project.mjs +190 -32
  426. package/foundation/config/project.test.mjs +129 -16
  427. package/foundation/discovery/authoring-self-docs.d.mts +75 -0
  428. package/foundation/discovery/authoring-self-docs.mjs +224 -0
  429. package/foundation/discovery/authoring-self-docs.test.mjs +155 -0
  430. package/foundation/discovery/authoring-surface.d.mts +74 -0
  431. package/foundation/discovery/authoring-surface.mjs +525 -0
  432. package/foundation/discovery/authoring-surface.test.mjs +392 -0
  433. package/foundation/discovery/cli-self-docs.d.mts +113 -0
  434. package/foundation/discovery/cli-self-docs.mjs +514 -0
  435. package/foundation/discovery/cli-self-docs.test.mjs +437 -0
  436. package/foundation/discovery/component-discovery.d.mts +1 -1
  437. package/foundation/discovery/component-discovery.mjs +2 -1
  438. package/foundation/discovery/component-loader.d.mts +35 -38
  439. package/foundation/discovery/component-loader.mjs +53 -222
  440. package/foundation/discovery/docs-discovery.d.mts +12 -4
  441. package/foundation/discovery/docs-discovery.mjs +215 -98
  442. package/foundation/discovery/docs-discovery.test.mjs +281 -15
  443. package/foundation/discovery/docs-output-budget.d.mts +28 -0
  444. package/foundation/discovery/docs-output-budget.mjs +50 -0
  445. package/foundation/discovery/docs-section-key.d.mts +109 -0
  446. package/foundation/discovery/docs-section-key.mjs +308 -0
  447. package/foundation/discovery/docs-section-key.test.mjs +246 -0
  448. package/foundation/discovery/template-adapter.d.mts +21 -5
  449. package/foundation/discovery/template-adapter.fixture-refs.test.mjs +248 -0
  450. package/foundation/discovery/template-adapter.integration-isolation.test.mjs +94 -0
  451. package/foundation/discovery/template-adapter.mjs +321 -66
  452. package/foundation/discovery/template-adapter.test.mjs +15 -0
  453. package/foundation/discovery/theme-discovery.d.mts +67 -7
  454. package/foundation/discovery/theme-discovery.mjs +916 -186
  455. package/foundation/discovery/theme-discovery.test.mjs +613 -219
  456. package/foundation/discovery/theming-targets.test.mjs +4 -0
  457. package/foundation/doc-compiler/bundle.d.mts +47 -0
  458. package/foundation/doc-compiler/bundle.mjs +218 -0
  459. package/foundation/doc-compiler/bundle.test.mjs +255 -0
  460. package/foundation/doc-compiler/compile.d.mts +362 -0
  461. package/foundation/doc-compiler/compile.mjs +512 -0
  462. package/foundation/doc-compiler/diagnostics.d.mts +126 -0
  463. package/foundation/doc-compiler/diagnostics.mjs +277 -0
  464. package/foundation/doc-compiler/doc-compiler.test.mjs +714 -0
  465. package/foundation/doc-compiler/doc-loads.test.mjs +1642 -0
  466. package/foundation/doc-compiler/import.d.mts +24 -0
  467. package/foundation/doc-compiler/import.mjs +59 -0
  468. package/foundation/doc-compiler/inputs.d.mts +102 -0
  469. package/foundation/doc-compiler/inputs.mjs +286 -0
  470. package/foundation/doc-compiler/inputs.test.mjs +299 -0
  471. package/foundation/doc-compiler/ir.d.mts +22 -0
  472. package/foundation/doc-compiler/ir.mjs +464 -0
  473. package/foundation/doc-compiler/lenses.d.mts +33 -0
  474. package/foundation/doc-compiler/lenses.mjs +127 -0
  475. package/foundation/doc-compiler/lower-doc.test.mjs +492 -0
  476. package/foundation/doc-compiler/overlays.d.mts +37 -0
  477. package/foundation/doc-compiler/overlays.mjs +206 -0
  478. package/foundation/doc-compiler/parse-readable.d.mts +9 -0
  479. package/foundation/doc-compiler/parse-readable.mjs +29 -0
  480. package/foundation/doc-compiler/read.d.mts +126 -0
  481. package/foundation/doc-compiler/read.mjs +320 -0
  482. package/foundation/doc-compiler/read.test.mjs +313 -0
  483. package/foundation/doc-compiler/source.d.mts +33 -0
  484. package/foundation/doc-compiler/source.mjs +128 -0
  485. package/foundation/fs/file-protection.d.mts +33 -0
  486. package/foundation/fs/file-protection.mjs +825 -0
  487. package/foundation/fs/file-protection.test.mjs +250 -0
  488. package/foundation/fs/module-loader.d.mts +1 -0
  489. package/foundation/fs/module-loader.mjs +50 -1
  490. package/foundation/fs/module-loader.stdout.test.mjs +332 -0
  491. package/foundation/fs/path-safety.d.mts +3 -2
  492. package/foundation/fs/path-safety.mjs +49 -19
  493. package/foundation/fs/path-safety.test.mjs +50 -0
  494. package/foundation/fs/publish-file-hardlink-unavailable.test.mjs +129 -94
  495. package/foundation/identity/provider-identity.d.mts +90 -0
  496. package/foundation/identity/provider-identity.mjs +320 -0
  497. package/foundation/identity/provider-identity.test.mjs +254 -0
  498. package/foundation/identity/providers.d.mts +7 -0
  499. package/foundation/identity/providers.mjs +16 -0
  500. package/foundation/integrations/autolink.d.mts +58 -1
  501. package/foundation/integrations/autolink.mjs +143 -45
  502. package/foundation/integrations/contribution-fixes.d.mts +145 -0
  503. package/foundation/integrations/contribution-fixes.mjs +1284 -0
  504. package/foundation/integrations/contribution-inventory.d.mts +1 -1
  505. package/foundation/integrations/contribution-inventory.mjs +17 -20
  506. package/foundation/integrations/contribution-inventory.test.mjs +67 -27
  507. package/foundation/integrations/integration-warnings.mjs +6 -0
  508. package/foundation/integrations/integrations.d.mts +49 -2
  509. package/foundation/integrations/integrations.mjs +81 -8
  510. package/foundation/integrations/integrations.test.mjs +384 -1
  511. package/foundation/integrations/provider-conflicts.test.mjs +125 -0
  512. package/foundation/integrations/provider-ledger.test.mjs +275 -0
  513. package/foundation/integrations/provider-resolution.d.mts +152 -0
  514. package/foundation/integrations/provider-resolution.mjs +576 -0
  515. package/foundation/integrations/provider-resolution.test.mjs +369 -0
  516. package/foundation/integrations/theme-descriptor.d.mts +8 -0
  517. package/foundation/integrations/theme-descriptor.mjs +44 -0
  518. package/foundation/integrations/validate-contributions.d.mts +2 -0
  519. package/foundation/integrations/validate-contributions.mjs +114 -10
  520. package/foundation/response/base.d.ts +8 -4
  521. package/foundation/response/error-codes.d.mts +3 -1
  522. package/foundation/response/error-codes.d.ts +2 -0
  523. package/foundation/response/error-codes.doc.mjs +13 -4
  524. package/foundation/response/error-codes.mjs +8 -2
  525. package/foundation/response/error-codes.test.mjs +137 -10
  526. package/foundation/response/json-contract.test.mjs +57 -17
  527. package/foundation/response/json.d.mts +4 -2
  528. package/foundation/response/json.mjs +8 -10
  529. package/foundation/response/response-types.doc.mjs +16 -11
  530. package/foundation/response/response-types.doc.test.mjs +158 -0
  531. package/foundation/response/response.doc.mjs +1 -1
  532. package/foundation/text/string-utils.mjs +22 -10
  533. package/foundation/xle/expand.d.mts +2 -0
  534. package/foundation/xle/expand.mjs +3 -2
  535. package/foundation/xle/expand.test.mjs +54 -0
  536. package/package.json +10 -11
  537. package/assets/templates/themes/manifest.json +0 -95
  538. package/clients/cli/lib/update-check.mjs +0 -83
  539. package/clients/cli/lib/update-check.test.mjs +0 -137
  540. package/clients/cli/update-hint-commands.test.mjs +0 -54
@@ -31,7 +31,9 @@ function topic(fields) {
31
31
  name: 'deploying',
32
32
  title: 'Deploying',
33
33
  description: 'How to ship it.',
34
- sections: [{title: 'Overview', content: [{type: 'prose', text: 'Ship it.'}]}],
34
+ sections: [
35
+ {title: 'Overview', content: [{type: 'prose', text: 'Ship it.'}]},
36
+ ],
35
37
  ...fields,
36
38
  };
37
39
  }
@@ -97,7 +99,9 @@ describe('discoverIntegrationDocs', () => {
97
99
  }),
98
100
  );
99
101
  expect(errors).toEqual([]);
100
- expect(records.map(r => [r.name, r.package, r.replaces, r.extendsTopic])).toEqual([
102
+ expect(
103
+ records.map(r => [r.name, r.package, r.replaces, r.extendsTopic]),
104
+ ).toEqual([
101
105
  ['deploying', '@acme/widgets', undefined, undefined],
102
106
  ['getting-started', '@acme/widgets', 'getting-started', undefined],
103
107
  ['theme-extra', '@acme/widgets', undefined, 'theme'],
@@ -126,7 +130,9 @@ describe('discoverIntegrationDocs', () => {
126
130
 
127
131
  it('reports a doc that exports nothing, rather than skipping it silently', async () => {
128
132
  const {records, errors} = await discoverIntegrationDocs(
129
- integration('@acme/empty', {'deploying.doc.mjs': 'export const nope = 1;\n'}),
133
+ integration('@acme/empty', {
134
+ 'deploying.doc.mjs': 'export const nope = 1;\n',
135
+ }),
130
136
  );
131
137
  expect(records).toEqual([]);
132
138
  expect(errors).toHaveLength(1);
@@ -153,6 +159,49 @@ describe('discoverIntegrationDocs', () => {
153
159
  expect(records).toEqual([]);
154
160
  expect(errors[0].message).toContain('declares both');
155
161
  });
162
+
163
+ it('rejects graph blocks at the legacy topic-reader boundary', async () => {
164
+ const {records, errors} = await discoverIntegrationDocs(
165
+ integration('@acme/graph-block', {
166
+ 'deploying.doc.mjs': topic({
167
+ sections: [
168
+ {
169
+ id: 'steps',
170
+ title: 'Steps',
171
+ content: [
172
+ {
173
+ type: 'workflow',
174
+ steps: [{title: 'Install', description: 'Run install.'}],
175
+ },
176
+ ],
177
+ },
178
+ ],
179
+ }),
180
+ }),
181
+ );
182
+ expect(records).toEqual([]);
183
+ expect(errors[0].message).toContain('Invalid discriminator value');
184
+ });
185
+
186
+ it('names a namespace doc instead of listing topic fields it lacks', async () => {
187
+ const {records, errors} = await discoverIntegrationDocs(
188
+ integration('@acme/namespace', {
189
+ 'guides.doc.mjs': {
190
+ type: 'namespace',
191
+ name: 'guides',
192
+ title: 'Guides',
193
+ summary: 'Every guide.',
194
+ slots: {guides: {title: 'Guides', accepts: {kinds: ['generic']}}},
195
+ },
196
+ }),
197
+ );
198
+ expect(records).toEqual([]);
199
+ expect(errors).toHaveLength(1);
200
+ expect(errors[0].message).toContain(
201
+ '"guides" is a namespace doc. Only the docs graph reads namespace docs',
202
+ );
203
+ expect(errors[0].message).not.toContain('sections:');
204
+ });
156
205
  });
157
206
 
158
207
  describe('problemsInTopic', () => {
@@ -170,7 +219,11 @@ describe('problemsInTopic', () => {
170
219
  // A misspelled required field: the block renders nothing at all.
171
220
  expect(
172
221
  problemsInTopic(
173
- topic({sections: [{title: 'Overview', content: [{type: 'prose', txt: 'oops'}]}]}),
222
+ topic({
223
+ sections: [
224
+ {title: 'Overview', content: [{type: 'prose', txt: 'oops'}]},
225
+ ],
226
+ }),
174
227
  ),
175
228
  ).toEqual([
176
229
  'sections[0].content[0].text: required for a prose block',
@@ -180,7 +233,12 @@ describe('problemsInTopic', () => {
180
233
  expect(
181
234
  problemsInTopic(
182
235
  topic({
183
- sections: [{title: 'Overview', content: [{type: 'heading', level: 2, text: 'x'}]}],
236
+ sections: [
237
+ {
238
+ title: 'Overview',
239
+ content: [{type: 'heading', level: 2, text: 'x'}],
240
+ },
241
+ ],
184
242
  }),
185
243
  ),
186
244
  ).toContain('sections[0].content[0].level: 2 is not one of 3, 4, 5, 6');
@@ -196,11 +254,27 @@ describe('problemsInTopic', () => {
196
254
  ],
197
255
  }),
198
256
  ),
199
- ).toContain('sections[0].content[0].rows[0]: has 1 cells but the table has 2 headers');
257
+ ).toContain(
258
+ 'sections[0].content[0].rows[0]: has 1 cells but the table has 2 headers',
259
+ );
260
+ });
261
+
262
+ it('rejects graph metadata at the legacy topic-reader boundary', () => {
263
+ for (const fields of [
264
+ {placement: {parent: 'namespace:cli'}},
265
+ {aliases: ['setup']},
266
+ {audience: 'internal'},
267
+ ]) {
268
+ expect(problemsInTopic(topic(fields)).join('\n')).toContain(
269
+ 'requires the compiled graph reader',
270
+ );
271
+ }
200
272
  });
201
273
 
202
274
  it('rejects a name that is not URL-safe', () => {
203
- expect(problemsInTopic(topic({name: 'not a topic'})).join('\n')).toContain('URL-safe');
275
+ expect(problemsInTopic(topic({name: 'not a topic'})).join('\n')).toContain(
276
+ 'URL-safe',
277
+ );
204
278
  });
205
279
  });
206
280
 
@@ -228,11 +302,23 @@ describe('DocsCatalog', () => {
228
302
  expect(catalog.resolve('deploying').package).toBe('@acme/widgets');
229
303
  });
230
304
 
305
+ it('treats topic identities case-insensitively without losing display case', () => {
306
+ const catalog = DocsCatalog.fromBuiltins();
307
+ expect(catalog.add(record({name: 'Deploying'}))).toBeNull();
308
+ expect(catalog.resolve('deploying').name).toBe('Deploying');
309
+ expect(catalog.resolve('DEPLOYING').name).toBe('Deploying');
310
+
311
+ const issue = catalog.add(
312
+ record({name: 'deploying', package: '@acme/duplicate'}),
313
+ );
314
+ expect(issue).toMatchObject({code: 'invalid_doc', severity: 'error'});
315
+ });
316
+
231
317
  it('refuses to shadow an existing topic by name alone', () => {
232
318
  const catalog = DocsCatalog.fromBuiltins({tokens: '/cli/tokens.doc.mjs'});
233
319
  const issue = catalog.add(record({name: 'tokens'}));
234
320
  expect(issue).toMatchObject({code: 'invalid_doc', severity: 'error'});
235
- expect(issue.message).toContain("already provided by @astryxdesign/cli");
321
+ expect(issue.message).toContain('already provided by @astryxdesign/cli');
236
322
  expect(issue.message).toContain("replaces: 'tokens'");
237
323
  // The built-in topic is untouched.
238
324
  expect(catalog.resolve('tokens').package).toBe(BUILTIN_DOCS_PACKAGE);
@@ -244,7 +330,9 @@ describe('DocsCatalog', () => {
244
330
  tokens: '/cli/tokens.doc.mjs',
245
331
  });
246
332
  expect(
247
- catalog.add(record({name: 'getting-started', replaces: 'getting-started'})),
333
+ catalog.add(
334
+ record({name: 'getting-started', replaces: 'getting-started'}),
335
+ ),
248
336
  ).toBeNull();
249
337
  expect(catalog.names()).toEqual(['getting-started', 'tokens']);
250
338
  const entry = catalog.resolve('getting-started');
@@ -276,12 +364,16 @@ describe('DocsCatalog', () => {
276
364
 
277
365
  it('warns, and lets the later package win, when two replace one topic', () => {
278
366
  const catalog = DocsCatalog.fromBuiltins({tokens: '/cli/tokens.doc.mjs'});
279
- expect(catalog.add(record({name: 'tokens', replaces: 'tokens'}))).toBeNull();
367
+ expect(
368
+ catalog.add(record({name: 'tokens', replaces: 'tokens'})),
369
+ ).toBeNull();
280
370
  const issue = catalog.add(
281
371
  record({name: 'tokens', package: '@acme/later', replaces: 'tokens'}),
282
372
  );
283
373
  expect(issue).toMatchObject({code: 'duplicate_doc', severity: 'warning'});
284
- expect(issue.message).toContain('@acme/later is configured later, so it wins');
374
+ expect(issue.message).toContain(
375
+ '@acme/later is configured later, so it wins',
376
+ );
285
377
  expect(catalog.resolve('tokens').package).toBe('@acme/later');
286
378
  });
287
379
 
@@ -327,15 +419,189 @@ describe('mergeTopic', () => {
327
419
  {title: 'Internal', content: [{type: 'prose', text: 'the meta way'}]},
328
420
  ],
329
421
  });
330
- expect(merged.sections.map(s => s.title)).toEqual(['Install', 'Tokens', 'Internal']);
422
+ expect(merged.sections.map(s => s.title)).toEqual([
423
+ 'Install',
424
+ 'Tokens',
425
+ 'Internal',
426
+ ]);
331
427
  expect(merged.sections[0].content[0].text).toBe('yarn add');
332
428
  expect(merged.sections[1].content[0].text).toBe('use tokens');
333
429
  // The base is untouched.
334
430
  expect(base.sections[0].content[0].text).toBe('npm i');
335
431
  });
336
432
 
337
- it('takes the title and description only when the overlay states them', () => {
338
- expect(mergeTopic(base, {sections: []}).title).toBe('Theme');
339
- expect(mergeTopic(base, {title: 'Theming', sections: []}).title).toBe('Theming');
433
+ it('replaces a section by stable ID even when its title changes', () => {
434
+ const merged = mergeTopic(
435
+ {
436
+ ...base,
437
+ sections: [
438
+ {id: 'install', title: 'Install', content: []},
439
+ {id: 'tokens', title: 'Tokens', content: []},
440
+ ],
441
+ },
442
+ {
443
+ sections: [{id: 'install', title: 'Setup', content: []}],
444
+ },
445
+ );
446
+ expect(merged.sections.map(section => [section.id, section.title])).toEqual(
447
+ [
448
+ ['install', 'Setup'],
449
+ ['tokens', 'Tokens'],
450
+ ],
451
+ );
452
+ });
453
+
454
+ it('migrates a legacy section to a stable ID without duplicating it', () => {
455
+ const merged = mergeTopic(base, {
456
+ sections: [
457
+ {
458
+ id: 'install',
459
+ title: 'Install',
460
+ content: [{type: 'prose', text: 'yarn add'}],
461
+ },
462
+ ],
463
+ });
464
+ expect(
465
+ merged.sections.map(section => [section.id ?? null, section.title]),
466
+ ).toEqual([
467
+ ['install', 'Install'],
468
+ [null, 'Tokens'],
469
+ ]);
470
+ expect(merged.sections[0].content[0].text).toBe('yarn add');
471
+ });
472
+
473
+ it('lets a legacy extension replace a section that has since gained an ID', () => {
474
+ const merged = mergeTopic(
475
+ {
476
+ ...base,
477
+ sections: [
478
+ {id: 'setup-steps', title: 'Install', content: []},
479
+ {title: 'Tokens', content: []},
480
+ ],
481
+ },
482
+ {
483
+ sections: [
484
+ {title: 'Install', content: [{type: 'prose', text: 'yarn add'}]},
485
+ ],
486
+ },
487
+ );
488
+ expect(
489
+ merged.sections.map(section => [section.id ?? null, section.title]),
490
+ ).toEqual([
491
+ ['setup-steps', 'Install'],
492
+ [null, 'Tokens'],
493
+ ]);
494
+ expect(merged.sections[0].content[0].text).toBe('yarn add');
495
+ });
496
+
497
+ it('keeps two different authored IDs distinct under one title', () => {
498
+ const merged = mergeTopic(
499
+ {...base, sections: [{id: 'install', title: 'Install', content: []}]},
500
+ {sections: [{id: 'install-yarn', title: 'Install', content: []}]},
501
+ );
502
+ expect(merged.sections.map(section => section.id)).toEqual([
503
+ 'install',
504
+ 'install-yarn',
505
+ ]);
506
+ });
507
+
508
+ it('keeps the base title and description: an extension never renames a topic', () => {
509
+ const merged = mergeTopic(base, {
510
+ title: 'Acme theme notes',
511
+ description: 'Our additions.',
512
+ sections: [],
513
+ });
514
+ expect(merged.title).toBe('Theme');
515
+ expect(merged.description).toBe('Theming.');
516
+ });
517
+ });
518
+
519
+ describe('problemsInTopic section keys', () => {
520
+ /** @param {object[]} sections */
521
+ const doc = sections => ({
522
+ type: 'generic',
523
+ name: 'keys',
524
+ title: 'Keys',
525
+ description: 'Section keys.',
526
+ sections: sections.map(s => ({
527
+ content: [{type: 'prose', text: 'x'}],
528
+ ...s,
529
+ })),
530
+ });
531
+
532
+ it('keeps legacy title-only key conflicts readable', () => {
533
+ expect(
534
+ problemsInTopic(doc([{title: 'Quick Start'}, {title: 'Quick-start'}])),
535
+ ).toEqual([]);
536
+ });
537
+
538
+ it('rejects an unsafe id', () => {
539
+ expect(
540
+ problemsInTopic(doc([{id: 'Quick Start', title: 'Quick Start'}])),
541
+ ).toEqual([expect.stringContaining('is not a stable key')]);
542
+ });
543
+
544
+ it('keeps a legacy title that has no derived key readable', () => {
545
+ expect(problemsInTopic(doc([{title: '亮/暗模式'}]))).toEqual([]);
546
+ expect(
547
+ problemsInTopic(doc([{id: 'light-dark', title: '亮/暗模式'}])),
548
+ ).toEqual([]);
549
+ });
550
+ });
551
+
552
+ describe('mergeTopic by section key', () => {
553
+ const base = {
554
+ title: 'Theme',
555
+ sections: [
556
+ {title: 'Quick Start', content: [{type: 'prose', text: 'base'}]},
557
+ {title: 'Light/Dark Mode', content: [{type: 'prose', text: 'base'}]},
558
+ ],
559
+ };
560
+ const titles = doc =>
561
+ doc.sections.map(s => [s.id ?? null, s.title, s.content[0].text]);
562
+
563
+ it('replaces the section whose derived key an extension id names', () => {
564
+ const merged = mergeTopic(base, {
565
+ sections: [
566
+ {
567
+ id: 'quick-start',
568
+ title: 'Quick Start with Acme',
569
+ content: [{type: 'prose', text: 'acme'}],
570
+ },
571
+ ],
572
+ });
573
+ expect(titles(merged)).toEqual([
574
+ ['quick-start', 'Quick Start with Acme', 'acme'],
575
+ [null, 'Light/Dark Mode', 'base'],
576
+ ]);
577
+ });
578
+
579
+ it('keeps a legacy title variant as a separate section', () => {
580
+ const merged = mergeTopic(base, {
581
+ sections: [
582
+ {title: 'Light-Dark Mode', content: [{type: 'prose', text: 'acme'}]},
583
+ ],
584
+ });
585
+ expect(titles(merged)).toEqual([
586
+ [null, 'Quick Start', 'base'],
587
+ [null, 'Light/Dark Mode', 'base'],
588
+ [null, 'Light-Dark Mode', 'acme'],
589
+ ]);
590
+ });
591
+
592
+ it('prefers the key over a legacy title for an extension with an id', () => {
593
+ const merged = mergeTopic(base, {
594
+ sections: [
595
+ {
596
+ id: 'light-dark-mode',
597
+ title: 'Quick Start',
598
+ content: [{type: 'prose', text: 'acme'}],
599
+ },
600
+ ],
601
+ });
602
+ expect(titles(merged)).toEqual([
603
+ [null, 'Quick Start', 'base'],
604
+ ['light-dark-mode', 'Quick Start', 'acme'],
605
+ ]);
340
606
  });
341
607
  });
@@ -0,0 +1,28 @@
1
+ // @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
2
+ // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
+
4
+ /**
5
+ * A payload's size as `--json` prints it: the envelope data, two-space
6
+ * indented, in UTF-8 bytes.
7
+ * @param {unknown} payload
8
+ * @returns {number}
9
+ */
10
+ export function docPayloadBytes(payload: unknown): number;
11
+ /**
12
+ * @param {import('../../api/docs/docs.type.mjs').DocsIndex} index
13
+ * @returns {number}
14
+ */
15
+ export function docsIndexBytes(index: import("../../api/docs/docs.type.mjs").DocsIndex): number;
16
+ /**
17
+ * The sections a single read would return more than `budget` bytes for.
18
+ * @param {any[]} sections
19
+ * @param {number} [budget]
20
+ * @returns {{key: string, title: string, bytes: number}[]}
21
+ */
22
+ export function oversizedDocSections(sections: any[], budget?: number): {
23
+ key: string;
24
+ title: string;
25
+ bytes: number;
26
+ }[];
27
+ /** The most one index or one section read may return, in bytes. */
28
+ export const DOC_OUTPUT_BUDGET_BYTES: number;
@@ -0,0 +1,50 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file The most one progressive docs read may return.
5
+ *
6
+ * @input Docs payloads: one topic's section index, or one section.
7
+ * @output Their size in bytes as `--json` prints them, and the sections over
8
+ * the budget.
9
+ * @position Shared by Doctor's docs checks and the authoring self-doc audit, so
10
+ * both hold every read to the same limit.
11
+ */
12
+
13
+ import {sectionKey} from './docs-section-key.mjs';
14
+
15
+ /** The most one index or one section read may return, in bytes. */
16
+ export const DOC_OUTPUT_BUDGET_BYTES = 32 * 1024;
17
+
18
+ /**
19
+ * A payload's size as `--json` prints it: the envelope data, two-space
20
+ * indented, in UTF-8 bytes.
21
+ * @param {unknown} payload
22
+ * @returns {number}
23
+ */
24
+ export function docPayloadBytes(payload) {
25
+ return Buffer.byteLength(JSON.stringify(payload, null, 2), 'utf8');
26
+ }
27
+
28
+ /**
29
+ * @param {import('../../api/docs/docs.type.mjs').DocsIndex} index
30
+ * @returns {number}
31
+ */
32
+ export function docsIndexBytes(index) {
33
+ return docPayloadBytes({type: 'docs.index', data: index});
34
+ }
35
+
36
+ /**
37
+ * The sections a single read would return more than `budget` bytes for.
38
+ * @param {any[]} sections
39
+ * @param {number} [budget]
40
+ * @returns {{key: string, title: string, bytes: number}[]}
41
+ */
42
+ export function oversizedDocSections(sections, budget = DOC_OUTPUT_BUDGET_BYTES) {
43
+ return sections
44
+ .map(section => ({
45
+ key: sectionKey(section),
46
+ title: section.title,
47
+ bytes: docPayloadBytes({type: 'docs.detail.section', data: section}),
48
+ }))
49
+ .filter(entry => entry.bytes > budget);
50
+ }
@@ -0,0 +1,109 @@
1
+ // @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
2
+ // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
+
4
+ /**
5
+ * Record the authored title of a section whose visible title a translation
6
+ * overlay replaces.
7
+ * @template {object} T
8
+ * @param {T} section
9
+ * @param {string} title
10
+ * @returns {T}
11
+ */
12
+ export function withSourceTitle<T extends object>(section: T, title: string): T;
13
+ /**
14
+ * @param {any} section
15
+ * @returns {string}
16
+ */
17
+ export function sourceTitle(section: any): string;
18
+ /**
19
+ * The key a title derives: accents folded, `&` spelled out, and every other
20
+ * run of non-alphanumerics collapsed to one hyphen. Empty when the title has
21
+ * no Latin letters or digits to derive from.
22
+ * @param {unknown} title
23
+ * @returns {string}
24
+ */
25
+ export function sectionTitleKey(title: unknown): string;
26
+ /**
27
+ * The key a section is addressed by: its authored `id`, else the key its
28
+ * authored title derives.
29
+ * @param {any} section
30
+ * @returns {string}
31
+ */
32
+ export function sectionKey(section: any): string;
33
+ /**
34
+ * Fatal key problems: only an explicitly authored `id` can make a previously
35
+ * readable topic invalid. Derived-key collisions and titles with no Latin
36
+ * letters or digits are handled by {@link withSectionKeys} for 0.6.x
37
+ * compatibility.
38
+ * @param {any[]} sections
39
+ * @returns {string[]}
40
+ */
41
+ export function sectionKeyErrors(sections: any[]): string[];
42
+ /**
43
+ * Compatibility notices for section keys. These inputs loaded in 0.6.x, so
44
+ * readers keep accepting them and assign deterministic fallback keys.
45
+ * @param {any[]} sections
46
+ * @returns {string[]}
47
+ */
48
+ export function sectionKeyProblems(sections: any[]): string[];
49
+ /**
50
+ * Stamp every section with the key it is addressed by. Runs only after
51
+ * extensions merge: a derived key must never take part in merge matching.
52
+ * @template {{sections: any[]}} T
53
+ * @param {T} doc
54
+ * @returns {T}
55
+ */
56
+ export function withSectionKeys<T extends {
57
+ sections: any[];
58
+ }>(doc: T): T;
59
+ /**
60
+ * Find the section a reader asked for. The 0.6.x first-match title-substring
61
+ * lookup remains first in the authored-title view. In a localized view, an
62
+ * exact stable key resolves before translated title substrings because those
63
+ * translations cannot participate in language-stable key allocation. Generated
64
+ * keys avoid authored-title conflicts, and authored IDs that would shadow an
65
+ * authored legacy query are rejected.
66
+ * @param {any[]} sections
67
+ * @param {string} query
68
+ * @returns {{section: any | null, candidates: any[]}} `candidates` lists every
69
+ * legacy title match when the query is ambiguous
70
+ */
71
+ export function findDocSection(sections: any[], query: string): {
72
+ section: any | null;
73
+ candidates: any[];
74
+ };
75
+ /**
76
+ * One line that says what a section holds: its first prose or list text,
77
+ * whitespace collapsed, cut at a word boundary.
78
+ * @param {any} section
79
+ * @param {number} [max]
80
+ * @returns {string}
81
+ */
82
+ export function sectionSummary(section: any, max?: number): string;
83
+ /**
84
+ * The index a topic-only read returns: what the topic is, and one entry per
85
+ * section with the key to read it by.
86
+ * @param {{name: string, title: string, description: string, sections: any[]}} doc
87
+ * @returns {import('../../api/docs/docs.type.mjs').DocsIndex}
88
+ */
89
+ export function buildDocsIndexData(doc: {
90
+ name: string;
91
+ title: string;
92
+ description: string;
93
+ sections: any[];
94
+ }): import("../../api/docs/docs.type.mjs").DocsIndex;
95
+ /**
96
+ * @file Stable section keys, section lookup, and the topic index.
97
+ *
98
+ * @input Reference-doc sections, each with an optional authored `id`.
99
+ * @output The key a section is addressed by (its `id`, else a kebab-case key
100
+ * derived from its authored title), lookup by key or title, and the compact
101
+ * index a topic-only docs read returns.
102
+ * @position Shared by docs discovery (which rejects colliding keys before a
103
+ * reader sees them), the docs leaves (index, section, detail), and Doctor
104
+ * (output budgets). Imports nothing from discovery, so both can use it.
105
+ */
106
+ /** A stable key: lowercase letters and digits, joined by single hyphens. */
107
+ export const SECTION_KEY_RE: RegExp;
108
+ /** The longest summary an index entry carries, in characters. */
109
+ export const SECTION_SUMMARY_MAX: 240;