@astryxdesign/cli 0.7.17-canary.g5a3fd39 → 0.7.17-canary.g5cf5d69

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 (426) hide show
  1. package/README.md +64 -63
  2. package/api/build/_adapter.d.mts +51 -0
  3. package/api/build/_adapter.mjs +122 -6
  4. package/api/build/build.doc.mjs +1 -1
  5. package/api/build/build.mjs +23 -14
  6. package/api/build/build.type.d.mts +1 -1
  7. package/api/build/build.type.mjs +3 -3
  8. package/api/build/help/help.d.mts +15 -14
  9. package/api/build/help/help.mjs +62 -3
  10. package/api/build/kit/answer.mjs +2 -3
  11. package/api/build/kit/signals.d.mts +10 -0
  12. package/api/build/kit/signals.mjs +15 -2
  13. package/api/component/detail/blocks/blocks.mjs +2 -1
  14. package/api/discover/_adapter.d.mts +57 -6
  15. package/api/discover/_adapter.mjs +278 -49
  16. package/api/discover/_catalog-view.d.mts +7 -0
  17. package/api/discover/_catalog-view.mjs +10 -1
  18. package/api/discover/detail/detail.d.mts +3 -2
  19. package/api/discover/detail/detail.mjs +3 -2
  20. package/api/discover/detail/doc/doc.mjs +1 -1
  21. package/api/discover/discover.d.mts +24 -0
  22. package/api/discover/discover.doc.mjs +1 -1
  23. package/api/discover/discover.mjs +146 -25
  24. package/api/discover/discover.type.d.mts +6 -4
  25. package/api/discover/discover.type.mjs +6 -4
  26. package/api/discover/search/search.d.mts +22 -0
  27. package/api/discover/search/search.mjs +290 -70
  28. package/api/docs/_entry-names.mjs +4 -3
  29. package/api/doctor/_adapter.d.mts +43 -3
  30. package/api/doctor/_adapter.mjs +142 -18
  31. package/api/doctor/built-checks.d.mts +30 -3
  32. package/api/doctor/built-checks.mjs +132 -5
  33. package/api/doctor/doctor.d.mts +93 -6
  34. package/api/doctor/doctor.doc.mjs +2 -2
  35. package/api/doctor/doctor.mjs +524 -33
  36. package/api/doctor/doctor.type.d.mts +2 -1
  37. package/api/doctor/doctor.type.mjs +2 -1
  38. package/api/doctor/theme-checks.d.mts +19 -0
  39. package/api/doctor/theme-checks.mjs +74 -6
  40. package/api/hook/hook.type.d.mts +1 -1
  41. package/api/hook/hook.type.mjs +1 -1
  42. package/api/hook/list/list.mjs +11 -7
  43. package/api/icon/_adapter.d.mts +2 -1
  44. package/api/icon/_adapter.mjs +10 -15
  45. package/api/icon/_records.d.mts +3 -1
  46. package/api/icon/_records.mjs +30 -3
  47. package/api/icon/exportIconIndex.doc.mjs +1 -1
  48. package/api/icon/icon.doc.mjs +3 -3
  49. package/api/icon/icon.type.d.mts +32 -1
  50. package/api/icon/icon.type.mjs +19 -3
  51. package/api/icon/list/list.mjs +4 -1
  52. package/api/icon/rankIconIndex.doc.mjs +1 -1
  53. package/api/icon/search/icon-index.mjs +18 -8
  54. package/api/icon/search/search.d.mts +26 -3
  55. package/api/icon/search/search.mjs +155 -9
  56. package/api/init/_adapter.d.mts +14 -0
  57. package/api/init/_adapter.mjs +26 -4
  58. package/api/init/init.d.mts +1 -1
  59. package/api/init/init.doc.mjs +2 -2
  60. package/api/init/init.mjs +1 -1
  61. package/api/init/init.type.d.mts +29 -1
  62. package/api/init/init.type.mjs +14 -1
  63. package/api/init/run/run.d.mts +11 -1
  64. package/api/init/run/run.mjs +84 -5
  65. package/api/integration/_adapter.d.mts +5 -4
  66. package/api/integration/_adapter.mjs +7 -5
  67. package/api/integration/integrationCheck.doc.mjs +1 -1
  68. package/api/integration/pack-check.mjs +8 -9
  69. package/api/integration/validate-integration.d.mts +1 -1
  70. package/api/integration/validate-integration.mjs +26 -24
  71. package/api/integration/validate-integration.type.d.mts +5 -2
  72. package/api/integration/validate-integration.type.mjs +5 -2
  73. package/api/integration/validateIntegration.doc.mjs +1 -1
  74. package/api/render/_adapter.d.mts +4 -2
  75. package/api/render/_adapter.mjs +62 -21
  76. package/api/render/render.doc.mjs +8 -5
  77. package/api/render/render.mjs +1 -1
  78. package/api/render/render.type.d.mts +2 -0
  79. package/api/render/render.type.mjs +2 -0
  80. package/api/search/ORDERING.md +2 -2
  81. package/api/search/_candidate-score.d.mts +3 -0
  82. package/api/search/_candidate-score.mjs +36 -3
  83. package/api/search/_gather-docs.mjs +29 -2
  84. package/api/search/_gather-templates.mjs +2 -1
  85. package/api/search/_main-searcher.mjs +13 -0
  86. package/api/search/_named-keywords.d.mts +2 -1
  87. package/api/search/_named-keywords.mjs +48 -6
  88. package/api/search/_order.d.mts +36 -1
  89. package/api/search/_order.mjs +141 -3
  90. package/api/swizzle/list/list.mjs +8 -1
  91. package/api/swizzle/swizzle.type.d.mts +1 -1
  92. package/api/swizzle/swizzle.type.mjs +1 -1
  93. package/api/template/copy/copy.mjs +3 -4
  94. package/api/template/list/list.mjs +2 -1
  95. package/api/template/show/show.mjs +2 -1
  96. package/api/template/skeleton/skeleton.mjs +2 -1
  97. package/api/template/template.doc.mjs +1 -1
  98. package/api/template/template.mjs +19 -1
  99. package/api/template/template.type.d.mts +1 -0
  100. package/api/template/template.type.mjs +2 -1
  101. package/api/theme/_adapter.d.mts +1 -0
  102. package/api/theme/_adapter.mjs +3 -5
  103. package/api/theme/_app-provider.d.mts +42 -0
  104. package/api/theme/_app-provider.mjs +61 -27
  105. package/api/theme/build/build.d.mts +4 -10
  106. package/api/theme/build/build.mjs +165 -116
  107. package/api/theme/build/input-fields.d.mts +9 -0
  108. package/api/theme/build/input-fields.mjs +155 -16
  109. package/api/theme/build/radius-values.d.mts +18 -0
  110. package/api/theme/build/radius-values.mjs +76 -0
  111. package/api/theme/build/typography-values.mjs +7 -23
  112. package/api/theme/build/written-values.d.mts +18 -0
  113. package/api/theme/build/written-values.mjs +107 -31
  114. package/api/theme/eject/eject.mjs +6 -1
  115. package/api/theme/palette/generate/generator.mjs +24 -0
  116. package/api/theme/theme.type.d.mts +4 -2
  117. package/api/theme/theme.type.mjs +3 -2
  118. package/api/theme/themeBuild.doc.mjs +2 -2
  119. package/api/theme/themeEject.doc.mjs +1 -1
  120. package/api/theme-edit/_catalog.d.mts +40 -0
  121. package/api/theme-edit/_catalog.mjs +100 -22
  122. package/api/theme-edit/_check.mjs +213 -43
  123. package/api/theme-edit/_color.d.mts +14 -0
  124. package/api/theme-edit/_color.mjs +22 -0
  125. package/api/theme-edit/_compiler.mjs +52 -0
  126. package/api/theme-edit/_context.d.mts +20 -2
  127. package/api/theme-edit/_context.mjs +157 -29
  128. package/api/theme-edit/_edit.mjs +426 -58
  129. package/api/theme-edit/_how-question.d.mts +14 -0
  130. package/api/theme-edit/_how-question.mjs +1541 -127
  131. package/api/theme-edit/_how.mjs +43 -0
  132. package/api/theme-edit/_missed.mjs +107 -27
  133. package/api/theme-edit/_normal.d.mts +18 -4
  134. package/api/theme-edit/_normal.mjs +84 -3
  135. package/api/theme-edit/_palette.d.mts +9 -0
  136. package/api/theme-edit/_palette.mjs +158 -33
  137. package/api/theme-edit/_part-words.mjs +16 -3
  138. package/api/theme-edit/_parts.d.mts +8 -0
  139. package/api/theme-edit/_parts.mjs +120 -36
  140. package/api/theme-edit/_png.d.mts +24 -0
  141. package/api/theme-edit/_png.mjs +99 -0
  142. package/api/theme-edit/_preview-app.d.mts +16 -0
  143. package/api/theme-edit/_preview-app.mjs +52 -18
  144. package/api/theme-edit/_preview.d.mts +44 -26
  145. package/api/theme-edit/_preview.mjs +255 -67
  146. package/api/theme-edit/_project.d.mts +12 -1
  147. package/api/theme-edit/_project.mjs +16 -1
  148. package/api/theme-edit/_settings.d.mts +116 -0
  149. package/api/theme-edit/_settings.mjs +1197 -58
  150. package/api/theme-edit/_tables.d.mts +16 -0
  151. package/api/theme-edit/_tables.mjs +34 -4
  152. package/api/theme-edit/theme-edit.type.d.mts +15 -2
  153. package/api/theme-edit/theme-edit.type.mjs +8 -6
  154. package/api/upgrade/_adapter.d.mts +46 -7
  155. package/api/upgrade/_adapter.mjs +110 -15
  156. package/api/upgrade/registry/registry.d.mts +6 -3
  157. package/api/upgrade/registry/registry.mjs +21 -6
  158. package/api/upgrade/run/run.mjs +23 -11
  159. package/api/upgrade/upgrade.doc.mjs +4 -3
  160. package/assets/component-list.generated.json +1 -1
  161. package/assets/docs/tree/agent-guidance.doc.mjs +3 -2
  162. package/assets/docs/tree/checks.doc.mjs +2 -2
  163. package/assets/docs/tree/host-entry.doc.mjs +4 -0
  164. package/assets/docs/tree/icon-definitions.doc.mjs +3 -3
  165. package/assets/docs/tree/icon-sets.doc.mjs +6 -6
  166. package/assets/docs/tree/problems.doc.mjs +3 -3
  167. package/assets/docs/tree/render-pages.doc.mjs +17 -3
  168. package/assets/docs/tree/share-a-page.doc.mjs +5 -5
  169. package/assets/docs/tree/short-and-findable.doc.mjs +3 -3
  170. package/assets/docs/tree/troubleshooting.doc.mjs +8 -0
  171. package/assets/docs/tree/updates.doc.mjs +1 -1
  172. package/assets/docs/tree/versioning.doc.mjs +1 -1
  173. package/assets/docs/working-with-ai.doc.mjs +40 -5
  174. package/assets/docs-routes.generated.json +1 -1
  175. package/assets/docs.generated.json +2 -2
  176. package/assets/icons/installed-icon-set.doc.mjs +30 -0
  177. package/assets/search-catalog.generated.json +2 -2
  178. package/assets/self-audit.generated.json +1 -1
  179. package/assets/templates/blocks/components/Avatar/AvatarInteractive.tsx +6 -1
  180. package/assets/templates/blocks/components/CodeBlock/CodeBlockTerminal.tsx +1 -1
  181. package/assets/templates/blocks/components/LinkProvider/LinkProviderCustomLink.tsx +3 -1
  182. package/assets/templates/components.generated.json +1 -1
  183. package/assets/templates/pages/ai-chat/page.tsx +6 -2
  184. package/assets/templates/pages/ai-chat-landing/page.tsx +1 -1
  185. package/assets/templates/pages/blank/page.tsx +4 -2
  186. package/assets/templates/pages/canvas-editor/page.tsx +3 -1
  187. package/assets/templates/pages/centered-hero/page.tsx +1 -1
  188. package/assets/templates/pages/checkout-wizard/page.tsx +1 -1
  189. package/assets/templates/pages/classic-gallery/page.tsx +1 -1
  190. package/assets/templates/pages/contact-form/page.tsx +2 -2
  191. package/assets/templates/pages/course-detail/page.tsx +1 -1
  192. package/assets/templates/pages/dashboard/page.tsx +24 -8
  193. package/assets/templates/pages/dashboard-alert-rail/page.tsx +4 -2
  194. package/assets/templates/pages/dashboard-cohort-funnel/page.tsx +7 -3
  195. package/assets/templates/pages/dashboard-comparison/page.tsx +5 -2
  196. package/assets/templates/pages/dashboard-composition/page.tsx +10 -4
  197. package/assets/templates/pages/dashboard-progress/page.tsx +6 -3
  198. package/assets/templates/pages/dashboard-scorecard/page.tsx +17 -8
  199. package/assets/templates/pages/detail-page/page.tsx +22 -5
  200. package/assets/templates/pages/documentation/page.tsx +4 -2
  201. package/assets/templates/pages/documentation-design/page.tsx +5 -2
  202. package/assets/templates/pages/documentation-technical/page.tsx +4 -2
  203. package/assets/templates/pages/editor/page.tsx +28 -9
  204. package/assets/templates/pages/file-explorer/page.tsx +3 -1
  205. package/assets/templates/pages/form-two-column/page.tsx +1 -1
  206. package/assets/templates/pages/form-wizard/page.tsx +1 -1
  207. package/assets/templates/pages/form-wizard-dialog/page.tsx +3 -1
  208. package/assets/templates/pages/form-wizard-inline/page.tsx +1 -1
  209. package/assets/templates/pages/form-wizard-vertical/page.tsx +1 -1
  210. package/assets/templates/pages/gallery-hero/page.tsx +1 -1
  211. package/assets/templates/pages/ide/page.tsx +7 -2
  212. package/assets/templates/pages/kanban-board/page.tsx +10 -4
  213. package/assets/templates/pages/library/page.tsx +31 -61
  214. package/assets/templates/pages/login/page.tsx +4 -2
  215. package/assets/templates/pages/login-card/page.tsx +4 -2
  216. package/assets/templates/pages/login-split/page.tsx +3 -2
  217. package/assets/templates/pages/login-sso/page.tsx +4 -4
  218. package/assets/templates/pages/mixed-gallery/page.tsx +1 -1
  219. package/assets/templates/pages/payment-form/page.tsx +1 -1
  220. package/assets/templates/pages/product-detail/page.tsx +16 -4
  221. package/assets/templates/pages/product-gallery/page.tsx +1 -1
  222. package/assets/templates/pages/settings/page.tsx +10 -4
  223. package/assets/templates/pages/settings-dialog/page.tsx +5 -6
  224. package/assets/templates/pages/settings-sidebar/page.tsx +39 -13
  225. package/assets/templates/pages/side-gallery/page.tsx +1 -1
  226. package/assets/templates/pages/table/page.tsx +2 -2
  227. package/assets/templates/pages/table-filter/page.tsx +21 -6
  228. package/assets/templates/pages/table-grouped/page.tsx +23 -2
  229. package/assets/templates/pages/table-inbox/page.tsx +82 -32
  230. package/assets/templates/pages/theme-showcase/page.tsx +3 -2
  231. package/assets/templates/themes/butter/butterPaletteRefs.generated.ts +12 -12
  232. package/assets/templates/themes/butter/butterTheme.ts +197 -4
  233. package/assets/templates/themes/chocolate/chocolateTheme.ts +72 -8
  234. package/assets/templates/themes/gothic/gothicPaletteRefs.generated.ts +3 -3
  235. package/assets/templates/themes/gothic/gothicTheme.ts +114 -4
  236. package/assets/templates/themes/matcha/matchaPaletteRefs.generated.ts +8 -8
  237. package/assets/templates/themes/matcha/matchaTheme.ts +48 -12
  238. package/assets/templates/themes/neutral/neutralTheme.ts +29 -0
  239. package/assets/templates/themes/stone/stonePaletteRefs.generated.ts +2 -2
  240. package/assets/templates/themes/stone/stoneTheme.ts +69 -0
  241. package/assets/templates/themes/y2k/y2kPaletteRefs.generated.ts +9 -9
  242. package/assets/templates/themes/y2k/y2kTheme.ts +249 -14
  243. package/authoring/codemod/parse.d.mts +0 -36
  244. package/authoring/codemod/parse.mjs +62 -41
  245. package/authoring/config/config.doc.mjs +1 -1
  246. package/authoring/config/parse.d.mts +0 -47
  247. package/authoring/config/parse.mjs +128 -103
  248. package/authoring/config/type.ts +4 -3
  249. package/authoring/debug/parse.d.mts +2 -2
  250. package/authoring/discover/parse.d.mts +2 -2
  251. package/authoring/discover/parse.mjs +52 -38
  252. package/authoring/discover/type.ts +2 -1
  253. package/authoring/doctypes/_schema.d.mts +834 -950
  254. package/authoring/doctypes/_schema.mjs +863 -825
  255. package/authoring/doctypes/command/parse.mjs +2 -2
  256. package/authoring/doctypes/component/parse.mjs +2 -2
  257. package/authoring/doctypes/enum/parse.mjs +2 -2
  258. package/authoring/doctypes/hook/parse.mjs +2 -2
  259. package/authoring/doctypes/icon-definition/icon-definition.doc.mjs +1 -1
  260. package/authoring/doctypes/icon-definition/parse.d.mts +0 -24
  261. package/authoring/doctypes/icon-definition/parse.mjs +59 -43
  262. package/authoring/doctypes/icon-set/parse.d.mts +0 -75
  263. package/authoring/doctypes/icon-set/parse.mjs +239 -210
  264. package/authoring/doctypes/legacy.mjs +3 -3
  265. package/authoring/doctypes/namespace/parse.mjs +2 -2
  266. package/authoring/doctypes/reference/parse.mjs +2 -2
  267. package/authoring/doctypes/schema/parse.mjs +2 -2
  268. package/authoring/doctypes/template/parse.d.mts +0 -101
  269. package/authoring/doctypes/template/parse.mjs +131 -106
  270. package/authoring/doctypes/theme/parse.d.mts +0 -23
  271. package/authoring/doctypes/theme/parse.mjs +52 -36
  272. package/authoring/gap-report/parse.d.mts +1 -1
  273. package/authoring/integration/integration.doc.mjs +8 -0
  274. package/authoring/integration/schema.d.mts +14 -3
  275. package/authoring/integration/schema.mjs +20 -2
  276. package/authoring/integration/type.ts +14 -0
  277. package/clients/cli/build-id.generated.json +1 -1
  278. package/clients/cli/commands/build.mjs +27 -13
  279. package/clients/cli/commands/component.mjs +14 -3
  280. package/clients/cli/commands/discover.doc.mjs +2 -2
  281. package/clients/cli/commands/discover.mjs +20 -3
  282. package/clients/cli/commands/docs.doc.mjs +11 -9
  283. package/clients/cli/commands/docs.mjs +50 -21
  284. package/clients/cli/commands/experimental/icon.mjs +330 -227
  285. package/clients/cli/commands/experimental/render.mjs +16 -1
  286. package/clients/cli/commands/experimental/theme.mjs +42 -17
  287. package/clients/cli/commands/experimental-icon-add.doc.mjs +1 -1
  288. package/clients/cli/commands/experimental-icon-map.doc.mjs +4 -1
  289. package/clients/cli/commands/experimental-icon-new-definition.doc.mjs +4 -1
  290. package/clients/cli/commands/experimental-icon-new-set.doc.mjs +4 -1
  291. package/clients/cli/commands/experimental-icon-use.doc.mjs +1 -1
  292. package/clients/cli/commands/experimental-icon.doc.mjs +1 -1
  293. package/clients/cli/commands/experimental-render.doc.mjs +3 -3
  294. package/clients/cli/commands/experimental-theme-compile.doc.mjs +1 -1
  295. package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +1 -1
  296. package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +1 -1
  297. package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +1 -1
  298. package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +1 -1
  299. package/clients/cli/commands/init.doc.mjs +36 -24
  300. package/clients/cli/commands/integration-check.doc.mjs +1 -1
  301. package/clients/cli/commands/mcp.doc.mjs +53 -0
  302. package/clients/cli/commands/mcp.mjs +51 -0
  303. package/clients/cli/commands/search.mjs +46 -9
  304. package/clients/cli/commands/template.mjs +3 -2
  305. package/clients/cli/commands/theme-build.doc.mjs +1 -1
  306. package/clients/cli/commands/theme.mjs +12 -2
  307. package/clients/cli/commands/upgrade.doc.mjs +3 -2
  308. package/clients/cli/commands.generated.json +1 -1
  309. package/clients/cli/formatters/index.mjs +52 -6
  310. package/clients/cli/index.mjs +23 -17
  311. package/clients/cli/lib/base-gate.mjs +37 -5
  312. package/clients/cli/lib/define-command.mjs +82 -4
  313. package/clients/cli/lib/json-shim.mjs +61 -4
  314. package/clients/cli/lib/manifest.mjs +9 -1
  315. package/clients/cli/lib/mcp-server.mjs +286 -0
  316. package/clients/cli/lib/mcp-tools.mjs +405 -0
  317. package/clients/cli/lib/other-cli-words.mjs +99 -0
  318. package/clients/cli/lib/stray-option.mjs +27 -1
  319. package/clients/cli/lib/unknown-command.mjs +326 -11
  320. package/clients/cli/manifest.generated.json +1 -1
  321. package/clients/cli/run.mjs +1 -1
  322. package/foundation/agent-docs/agent-docs.d.mts +49 -1
  323. package/foundation/agent-docs/agent-docs.mjs +108 -7
  324. package/foundation/agent-docs/computer-agent-text.mjs +1 -1
  325. package/foundation/bases/core.d.mts +1 -1
  326. package/foundation/bases/core.mjs +3 -3
  327. package/foundation/bases/resolve.d.mts +4 -8
  328. package/foundation/bases/resolve.mjs +15 -21
  329. package/foundation/bases/state.d.mts +15 -9
  330. package/foundation/bases/state.mjs +33 -6
  331. package/foundation/config/project.d.mts +5 -4
  332. package/foundation/config/project.mjs +33 -17
  333. package/foundation/discovery/component-discovery.mjs +15 -28
  334. package/foundation/discovery/icon-imports.d.mts +66 -0
  335. package/foundation/discovery/icon-imports.mjs +225 -0
  336. package/foundation/discovery/icon-ranking.d.mts +12 -2
  337. package/foundation/discovery/icon-ranking.mjs +197 -10
  338. package/foundation/discovery/icon-set-checks.mjs +2 -1
  339. package/foundation/discovery/icon-set-discovery.d.mts +28 -0
  340. package/foundation/discovery/icon-set-discovery.mjs +42 -0
  341. package/foundation/discovery/icon-set-writer.d.mts +2 -11
  342. package/foundation/discovery/icon-set-writer.mjs +3 -29
  343. package/foundation/discovery/module-exports.d.mts +1 -1
  344. package/foundation/discovery/module-exports.mjs +136 -33
  345. package/foundation/discovery/name-roots.d.mts +5 -0
  346. package/foundation/discovery/name-roots.mjs +11 -0
  347. package/foundation/discovery/runner-allowlist.d.mts +1 -0
  348. package/foundation/discovery/runner-allowlist.mjs +2 -0
  349. package/foundation/discovery/runner-commands.mjs +1 -0
  350. package/foundation/discovery/template-adapter.d.mts +1 -1
  351. package/foundation/discovery/template-destination.d.mts +14 -6
  352. package/foundation/discovery/template-destination.mjs +42 -8
  353. package/foundation/discovery/template-icons.d.mts +45 -2
  354. package/foundation/discovery/template-icons.mjs +26 -54
  355. package/foundation/discovery/template-needs.d.mts +28 -2
  356. package/foundation/discovery/template-needs.mjs +92 -11
  357. package/foundation/discovery/theme-discovery.d.mts +8 -0
  358. package/foundation/discovery/theme-discovery.mjs +23 -6
  359. package/foundation/discovery/theme-imports.mjs +2 -4
  360. package/foundation/doc-compiler/parse-readable.mjs +4 -3
  361. package/foundation/doc-compiler/stored-docs.d.mts +13 -0
  362. package/foundation/doc-compiler/stored-docs.mjs +74 -3
  363. package/foundation/env/cli-command.d.mts +68 -10
  364. package/foundation/env/cli-command.mjs +116 -22
  365. package/foundation/env/project-scope.d.mts +9 -0
  366. package/foundation/env/project-scope.mjs +28 -2
  367. package/foundation/fs/gather-cache.d.mts +23 -0
  368. package/foundation/fs/gather-cache.mjs +94 -2
  369. package/foundation/fs/module-loader.d.mts +3 -1
  370. package/foundation/fs/module-loader.mjs +85 -5
  371. package/foundation/fs/read-record.mjs +9 -5
  372. package/foundation/identity/package-names.d.mts +18 -0
  373. package/foundation/identity/package-names.mjs +19 -0
  374. package/foundation/identity/providers.mjs +3 -2
  375. package/foundation/integrations/icon-features.d.mts +63 -0
  376. package/foundation/integrations/icon-features.mjs +54 -0
  377. package/foundation/integrations/integrations.d.mts +13 -1
  378. package/foundation/integrations/integrations.mjs +47 -6
  379. package/foundation/integrations/pack-state.d.mts +21 -0
  380. package/foundation/integrations/pack-state.mjs +42 -19
  381. package/foundation/integrations/validate-contributions.d.mts +11 -3
  382. package/foundation/integrations/validate-contributions.mjs +51 -13
  383. package/foundation/release/cache.d.mts +13 -1
  384. package/foundation/release/cache.mjs +94 -14
  385. package/foundation/release/notices.d.mts +15 -0
  386. package/foundation/release/notices.mjs +111 -7
  387. package/foundation/release/project.d.mts +3 -4
  388. package/foundation/release/project.mjs +5 -6
  389. package/foundation/render/client-bundle.d.mts +126 -0
  390. package/foundation/render/client-bundle.mjs +565 -0
  391. package/foundation/render/cut-short.d.mts +7 -1
  392. package/foundation/render/cut-short.mjs +46 -6
  393. package/foundation/render/embedded-imports.d.mts +4 -3
  394. package/foundation/render/embedded-imports.mjs +13 -8
  395. package/foundation/render/esbuild-dependency.d.mts +14 -0
  396. package/foundation/render/esbuild-dependency.mjs +41 -0
  397. package/foundation/render/file-header.mjs +5 -4
  398. package/foundation/render/page-worker.mjs +562 -86
  399. package/foundation/render/picture-chrome.mjs +54 -29
  400. package/foundation/render/picture-playwright.mjs +78 -42
  401. package/foundation/render/picture-window.d.mts +33 -0
  402. package/foundation/render/picture-window.mjs +78 -0
  403. package/foundation/render/render-page.d.mts +55 -4
  404. package/foundation/render/render-page.mjs +199 -28
  405. package/foundation/render/restore-folder.d.mts +13 -0
  406. package/foundation/render/restore-folder.mjs +30 -0
  407. package/foundation/render/served-packages.d.mts +2 -1
  408. package/foundation/render/served-packages.mjs +5 -3
  409. package/foundation/render/ts-paths.d.mts +11 -0
  410. package/foundation/render/ts-paths.mjs +27 -2
  411. package/foundation/render/value-uses.d.mts +43 -0
  412. package/foundation/render/value-uses.mjs +110 -0
  413. package/foundation/response/error-codes.d.mts +2 -1
  414. package/foundation/response/error-codes.doc.mjs +7 -1
  415. package/foundation/response/error-codes.mjs +10 -2
  416. package/foundation/response/response-types.doc.mjs +12 -12
  417. package/foundation/runtime/package-root.d.mts +8 -0
  418. package/foundation/runtime/package-root.mjs +20 -0
  419. package/foundation/suggest/other-command.d.mts +11 -0
  420. package/foundation/suggest/other-command.mjs +1 -1
  421. package/foundation/text/icon-id.d.mts +20 -0
  422. package/foundation/text/icon-id.mjs +40 -0
  423. package/foundation/text/icon-set-next.d.mts +25 -0
  424. package/foundation/text/icon-set-next.mjs +29 -0
  425. package/foundation/xle/browser.d.mts +2 -2
  426. package/package.json +7 -6
@@ -10,8 +10,11 @@
10
10
  import * as fs from 'node:fs';
11
11
  import * as os from 'node:os';
12
12
  import * as path from 'node:path';
13
+ import {freeRestoreFolder} from '../../foundation/render/restore-folder.mjs';
13
14
  import {randomUUID} from 'node:crypto';
14
15
  import {createRequire} from 'node:module';
16
+ import {installStepFor} from '../../foundation/discovery/template-needs.mjs';
17
+ import {installGuidanceFor} from '../../foundation/env/cli-command.mjs';
15
18
  import {AstryxError} from '../error.mjs';
16
19
  import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
17
20
  import {
@@ -49,7 +52,7 @@ import {climbsOut, findPackageRoot, isInside as liesInside, requireCoreDir} from
49
52
  import {runChoice} from '../../foundation/release/run-context.mjs';
50
53
  import {isAlive, pidSpace} from '../../foundation/release/cache.mjs';
51
54
  import {isServedPackage} from '../../foundation/render/served-packages.mjs';
52
- import {hostedRun, recordResolved} from '../../foundation/runtime/package-root.mjs';
55
+ import {hostedRun, recordResolved, servingRootPackages} from '../../foundation/runtime/package-root.mjs';
53
56
 
54
57
  export {PAGE_EXTENSIONS, embeddedPathProblem};
55
58
 
@@ -136,15 +139,16 @@ function resolvesCore(dir) {
136
139
  * @param {string} file absolute
137
140
  * @param {string} cwd
138
141
  * @param {string} what
142
+ * @param {string} [fix] what to do instead
139
143
  * @returns {string}
140
144
  */
141
- function confined(file, cwd, what) {
145
+ function confined(file, cwd, what, fix = 'Write inside the folder you run the command from.') {
142
146
  try {
143
147
  return assertWithin(file, cwd, {allowAbsolute: true, label: what});
144
148
  } catch (e) {
145
149
  if (e instanceof PathSafetyError) {
146
150
  throw new AstryxError(
147
- `${what} ${shown(cwd, file)} is outside the current folder; nothing was written. Write inside the folder you run the command from.`,
151
+ `${what} ${shown(cwd, file)} is outside the current folder; nothing was written. ${fix}`,
148
152
  [],
149
153
  ERROR_CODES.ERR_PATH_TRAVERSAL,
150
154
  );
@@ -404,14 +408,28 @@ function writeRestore(writes, folder, cwd, overwrite) {
404
408
  return true;
405
409
  }
406
410
 
407
- /** @param {unknown} e */
408
- function asAstryxError(e) {
411
+ /** @param {unknown} e @param {string} [cwd] the project the page belongs to */
412
+ function asAstryxError(e, cwd = process.cwd()) {
409
413
  if (e instanceof RenderError) {
410
414
  const code = /** @type {import('../../foundation/response/error-codes.mjs').ErrorCode} */ (e.code);
411
415
  /** @type {{name: string, reason: string}[]} */
412
416
  const suggestions = [];
413
417
  if (e.code === 'ERR_RENDER_MISSING_DEPENDENCY' && typeof e.detail?.package === 'string') {
414
- suggestions.push({name: `npm install ${e.detail.package}`, reason: 'install the package the page imports'});
418
+ // The integration's install guidance first, then the install command
419
+ // the render named in the project's package manager, else the
420
+ // project's install step for every package it found.
421
+ const packages = Array.isArray(e.detail.packages) ? e.detail.packages : [e.detail.package];
422
+ const guidance = installGuidanceFor(packages, cwd);
423
+ const needs = `install ${packages.join(', ')}, which this render needs`;
424
+ if (guidance) {
425
+ suggestions.push({name: guidance, reason: needs});
426
+ } else if (typeof e.detail.install === 'string') {
427
+ suggestions.push({name: e.detail.install, reason: needs});
428
+ } else {
429
+ const {line, note} = installStepFor(packages, cwd);
430
+ const what = packages.length === 1 ? 'install the package the page imports' : 'install the packages the page imports';
431
+ suggestions.push({name: line, reason: note ? `${what} (${note})` : what});
432
+ }
415
433
  }
416
434
  return new AstryxError(e.message, suggestions, code);
417
435
  }
@@ -422,6 +440,16 @@ function asAstryxError(e) {
422
440
  return e;
423
441
  }
424
442
 
443
+ /**
444
+ * The packages besides Astryx, React and StyleX that a page outside a project
445
+ * takes from the package set: the integrations the host approves, and the
446
+ * other packages its set declares, such as the icon library templates import.
447
+ * @returns {string[]}
448
+ */
449
+ function servedExtras() {
450
+ return [...(hostedRun()?.integrations ?? []), ...servingRootPackages()];
451
+ }
452
+
425
453
  /**
426
454
  * The package set the CLI runs from, for a page outside a project
427
455
  * (architecture:cli-surface INV30): the Core it carries, found by the rule of
@@ -438,7 +466,7 @@ function servedSet(input) {
438
466
  const dir = path.dirname(input);
439
467
  if (runChoice(dir).inProject) return null;
440
468
  try {
441
- return {dir: requireCoreDir(dir), integrations: hostedRun()?.integrations ?? []};
469
+ return {dir: requireCoreDir(dir), integrations: servedExtras()};
442
470
  } catch (e) {
443
471
  const err = /** @type {any} */ (e);
444
472
  return err?.code === ERROR_CODES.ERR_VERSIONS_UNAVAILABLE ? {unavailable: err} : null;
@@ -447,12 +475,17 @@ function servedSet(input) {
447
475
 
448
476
  /**
449
477
  * Render a page module to one HTML file and write it.
450
- * @param {{cwd: string, input: string, output: string, title?: string}} args absolute paths
478
+ * @param {{cwd: string, input: string, output: string, title?: string, absolute?: boolean}} args absolute paths;
479
+ * `absolute`: the caller named the output by an absolute path
451
480
  * @returns {Promise<import('./render.type.mjs').RenderPageResponse['data']>}
452
481
  */
453
- export async function renderToFile({cwd, input, output, title}) {
482
+ export async function renderToFile({cwd, input, output, title, absolute = false}) {
454
483
  readInput(input, cwd);
455
- confined(output, cwd, 'The output');
484
+ // An absolute --out is the caller's choice of place, also outside the
485
+ // current folder (cli-surface DEC-16). The file there is still never one a
486
+ // render did not write.
487
+ const elsewhere = absolute && !isInside(output, cwd);
488
+ if (!elsewhere) confined(output, cwd, 'The output', 'Write inside the folder you run the command from, or name an absolute path.');
456
489
  /** @type {import('../../foundation/render/render-page.mjs').RenderedPage} */
457
490
  let page;
458
491
  try {
@@ -461,14 +494,17 @@ export async function renderToFile({cwd, input, output, title}) {
461
494
  page = await renderPage(input, {title, version: cliVersion(), served: set && 'dir' in set ? set : null, output, cwd});
462
495
  } catch (e) {
463
496
  // A page that needs the Core the CLI could not obtain says why.
464
- const missing = /** @type {any} */ (e)?.code === 'ERR_RENDER_MISSING_DEPENDENCY' ? /** @type {any} */ (e).detail?.package : null;
465
- if (set && 'unavailable' in set && typeof missing === 'string' && isServedPackage(missing, hostedRun()?.integrations ?? [])) {
497
+ const detail = /** @type {any} */ (e)?.code === 'ERR_RENDER_MISSING_DEPENDENCY' ? /** @type {any} */ (e).detail : null;
498
+ /** @type {unknown[]} */
499
+ const missing = Array.isArray(detail?.packages) ? detail.packages : [detail?.package];
500
+ const served = servedExtras();
501
+ if (set && 'unavailable' in set && missing.some(name => typeof name === 'string' && isServedPackage(name, served))) {
466
502
  throw new AstryxError(set.unavailable.message, [], ERROR_CODES.ERR_VERSIONS_UNAVAILABLE);
467
503
  }
468
504
  throw e;
469
505
  }
470
506
  } catch (e) {
471
- throw asAstryxError(e);
507
+ throw asAstryxError(e, cwd);
472
508
  }
473
509
  for (const {name, dir} of page.fromSet) {
474
510
  let version = null;
@@ -479,7 +515,16 @@ export async function renderToFile({cwd, input, output, title}) {
479
515
  }
480
516
  recordResolved(name, version, dir, 'package-set');
481
517
  }
482
- refuseProtected([output], cwd);
518
+ if (!elsewhere) refuseProtected([output], cwd);
519
+ // Elsewhere, the file named is the file written: a link there would put the
520
+ // render wherever the link points.
521
+ if (elsewhere && fs.lstatSync(output, {throwIfNoEntry: false})?.isSymbolicLink()) {
522
+ throw new AstryxError(
523
+ `${shown(cwd, output)} is a symbolic link, so it is not replaced; nothing was written. Name the file itself.`,
524
+ [],
525
+ ERROR_CODES.ERR_PATH_TRAVERSAL,
526
+ );
527
+ }
483
528
  // An existing file is replaced only when a render wrote it.
484
529
  if (
485
530
  fs.existsSync(output) &&
@@ -517,6 +562,8 @@ export async function renderToFile({cwd, input, output, title}) {
517
562
  cssBytes: page.cssBytes,
518
563
  images: page.images,
519
564
  warnings: page.warnings,
565
+ scriptBytes: page.scriptBytes ?? 0,
566
+ scriptModules: page.scriptModules ?? 0,
520
567
  };
521
568
  }
522
569
 
@@ -629,13 +676,7 @@ function aliasedResult(unaliased, page, cwd) {
629
676
  * @param {string} input absolute
630
677
  */
631
678
  function restoreFolder(input) {
632
- const stem = path.basename(input).replace(/\.[^.]+$/, '');
633
- let folder = path.join(path.dirname(input), `${stem}-restored`);
634
- for (let n = 2; fs.existsSync(folder); n++) {
635
- removeStaleTemporaries(folder);
636
- folder = path.join(path.dirname(input), `${stem}-restored-${n}`);
637
- }
638
- return folder;
679
+ return freeRestoreFolder(path.dirname(input), path.basename(input), removeStaleTemporaries);
639
680
  }
640
681
 
641
682
  /**
@@ -16,13 +16,15 @@ export const doc = {
16
16
  summary:
17
17
  'Render a page to one self-contained HTML file, or turn a rendered file back into a page.',
18
18
  description:
19
- "Renders the page module's default export on the server with the project's own React and Astryx components (outside a project, with the Astryx, React and StyleX the CLI runs with), and writes ONE static HTML file that needs nothing beside it: the page's own StyleX styles are compiled, Core's stylesheets are cut to the rules the markup uses (layer order, custom properties and keyframes kept), local images become data: URIs, and the page's source is embedded so it can be given back exactly. The file runs no script and loads nothing from the network, so it works inside a sandboxed frame with a strict content security policy, and its colors follow the viewer's light or dark scheme. Warnings name anything that may differ from what the author meant, such as a component that did not render the text it was given. The file opens with a plain note for its next reader, a person or an agent: the CLI version and render format that made it, the page's path, the files it carries, the packages and versions it rendered with, and the exact commands that give the page back and render it again; the embedded source records the same facts and the markup as rendered. With `reverse` (the way back, or unrender), it writes the embedded source back byte for byte, and only the files a render embeds: the page and the local modules, stylesheets, JSON files and images it imports, into a new folder; it also reports the render format, the CLI version and packages that rendered the file, and whether someone changed the markup after the render, naming each run of text that changed and where the old text sits in the restored source (the restored files stay the page as rendered); a file with Astryx markup but no embedded source is rebuilt from its component class names and data attributes (text and layout only); any other file is refused. Experimental: it may change or be removed in a patch release.",
19
+ "Renders the page module's default export on the server with the project's own React and Astryx components (outside a project, with the Astryx, React and StyleX the CLI runs with, and, when a tool runs the CLI through its host entry, the packages the `package.json` beside that CLI lists in `dependencies` or `optionalDependencies`), and writes ONE HTML file that is the page as a live app and needs nothing beside it: the page's own StyleX styles are compiled, Core's stylesheets are cut to the rules the page can use (layer order, custom properties and keyframes kept), local images become data: URIs, the page's source is embedded so it can be given back exactly, and the page's own script follows it inline: the page's modules and the packages they use, bundled for the browser by esbuild (a dependency of the CLI that only this function loads). The file paints its markup first, then the script draws the live page over it, so state, effects and event handlers work: popovers, menus, dialogs, tabs and forms behave as in the app. It loads nothing from the network and the render adds no `eval`, so it works in a sandboxed frame that allows scripts under a policy that allows inline scripts, and its colors follow the viewer's light or dark scheme. A page whose script cannot be built for the browser (a module it loads needs Node, say) is refused. A page is refused with ERR_RENDER_COMPILE naming the file, the line, the module and the missing name, as a build refuses it, when it imports a name that one of its own modules, a StyleX variables module (`.stylex`) or an `@astryxdesign/*` package does not export, draws a member (`<Name.Member>`) such an export lacks, or imports any package subpath the package does not export (a named, default or side-effect import). A name another package does not export is refused only when the page's script is built: a page that draws or calls it as it renders fails with ERR_RENDER_FAILED first. Not checked: type imports, a name the page never uses as a value, a default import from a module that exists, a named import from one of the page's own CommonJS modules (a bundler reads those by interop), and a name the page imports through a TypeScript module that only re-exports it with a plain `export {…}` (such a page fails with ERR_RENDER_FAILED if it draws or calls the name as it renders). Warnings name anything that may differ from what the author meant, such as a component that did not render the text it was given. The file opens with a plain note for its next reader, a person or an agent: the CLI version and render format that made it, the page's path, the files it carries, the packages and versions it rendered with, and the exact commands that give the page back and render it again; the embedded source records the same facts and the markup as rendered. With `reverse` (the way back, or unrender), it writes the embedded source back byte for byte, and only the files a render embeds: the page and the local modules, stylesheets, JSON files and images it imports, into a new folder; it also reports the render format, the CLI version and packages that rendered the file, and whether someone changed the markup after the render, naming each run of text that changed and where the old text sits in the restored source (the restored files stay the page as rendered); a file with Astryx markup but no embedded source is rebuilt from its component class names and data attributes (text and layout only); any other file is refused. Experimental: it may change or be removed in a patch release.",
20
20
  importPath: '@astryxdesign/cli/api/experimental',
21
21
  signature:
22
22
  'render(file: string, options?: RenderOptions): Promise<RenderPageResponse | RenderReverseResponse>',
23
23
  keywords: [
24
24
  'render',
25
25
  'static',
26
+ 'interactive',
27
+ 'hydrate',
26
28
  'html',
27
29
  'export',
28
30
  'artifact',
@@ -44,7 +46,7 @@ export const doc = {
44
46
  name: 'options.out',
45
47
  type: 'string',
46
48
  description:
47
- "The file to write. Rendering: an .html file (default: the page's name with .html). Reversing: a page module (default: inside a new folder beside the HTML file, named after it, such as `report-restored/`).",
49
+ "The file to write. Rendering: an .html file (default: the page's name with .html); a relative path stays inside the current folder, and an absolute path may name any folder (a render never replaces a file it did not write). Reversing: a page module inside the current folder (default: inside a new folder beside the HTML file, named after it, such as `report-restored/`).",
48
50
  },
49
51
  {
50
52
  name: 'options.reverse',
@@ -75,7 +77,7 @@ export const doc = {
75
77
  {
76
78
  type: 'render.page',
77
79
  description:
78
- 'The page and the HTML file written, its size, the local modules embedded, the stylesheets inlined, the class and image counts, the CSS size, and any warnings.',
80
+ "The page and the HTML file written, its size, the local modules embedded, the stylesheets inlined, the class and image counts, the CSS size, the script's size and how many modules it holds, and any warnings.",
79
81
  },
80
82
  {
81
83
  type: 'render.reverse',
@@ -95,7 +97,8 @@ export const doc = {
95
97
  {code: 'ERR_WRITE_FAILED', when: 'a file cannot be written, such as when `out` names a folder; with `reverse`, every file is written or none is'},
96
98
  {code: 'ERR_RENDER_COMPILE', when: 'the page does not compile, or a stylesheet it imports is not valid CSS (the message names the file)'},
97
99
  {code: 'ERR_RENDER_NO_DEFAULT_EXPORT', when: 'the page has no default export'},
98
- {code: 'ERR_RENDER_MISSING_DEPENDENCY', when: 'the page imports a package that is not installed; the suggestion is its install line'},
100
+ {code: 'ERR_RENDER_MISSING_DEPENDENCY', when: "the page imports a package that is not installed (the suggestion is the install line), or the esbuild the CLI depends on is missing from its install"},
101
+ {code: 'ERR_RENDER_SCRIPT', when: "the page's script cannot be built for the browser: a module it loads needs Node (`fs`, `path`), or cannot be found or compiled for the browser; the message names the module"},
99
102
  {code: 'ERR_VERSIONS_UNAVAILABLE', when: 'outside a project, the page imports an Astryx package, React or StyleX, and the Core of the release that answers cannot be downloaded'},
100
103
  {code: 'ERR_RENDER_BROWSER_API', when: 'the page reads a browser-only API, such as window or document, while rendering'},
101
104
  {code: 'ERR_RENDER_ASSET_TOO_LARGE', when: 'a local file the page uses is over 8 MB'},
@@ -110,7 +113,7 @@ export const doc = {
110
113
  code: 'ERR_RENDER_NEWER_FORMAT',
111
114
  when: 'reversing a file in a newer render format than this CLI reads; the message and the suggestion name the CLI version that wrote it',
112
115
  },
113
- {code: 'ERR_PATH_TRAVERSAL', when: 'a file would be written outside the current folder (symlinks followed), or through a symbolic link: `out`, or with `reverse` the page or an embedded file; or, with `reverse`, a file other than the page would go into a folder that already exists'},
116
+ {code: 'ERR_PATH_TRAVERSAL', when: 'a file would be written outside the current folder (symlinks followed), or through a symbolic link: a relative `out`, or with `reverse` the page or an embedded file; an absolute `out` that is a symbolic link; or, with `reverse`, a file other than the page would go into a folder that already exists'},
114
117
  ],
115
118
  examples: [
116
119
  {label: 'Render a page', code: "const {data} = await render('src/app/page.tsx', {out: 'page.html'});"},
@@ -108,6 +108,6 @@ export async function render(file, options = {}) {
108
108
  const target = output ?? input.replace(/\.[^.]+$/, '.html');
109
109
  return {
110
110
  type: 'render.page',
111
- data: await renderToFile({cwd, input, output: target, title}),
111
+ data: await renderToFile({cwd, input, output: target, title, absolute: Boolean(options.out) && path.isAbsolute(/** @type {string} */ (options.out))}),
112
112
  };
113
113
  }
@@ -74,6 +74,8 @@ export type RenderPageResponse = {
74
74
  cssBytes: number;
75
75
  images: number;
76
76
  warnings: RenderWarning[];
77
+ scriptBytes: number;
78
+ scriptModules: number;
77
79
  };
78
80
  };
79
81
  /**
@@ -52,6 +52,8 @@
52
52
  * @property {number} data.cssBytes - Size of the inlined CSS.
53
53
  * @property {number} data.images - Local files inlined as data: URIs.
54
54
  * @property {RenderWarning[]} data.warnings - Empty when nothing looked wrong.
55
+ * @property {number} data.scriptBytes - Size of the page's script, which `bytes` includes.
56
+ * @property {number} data.scriptModules - How many modules the page's script holds (the page's own, its packages', React's).
55
57
  */
56
58
 
57
59
  /**
@@ -1,10 +1,10 @@
1
1
  # Search ordering data
2
2
 
3
- `astryx search` decides **what matches**, and each match's score and reason, with the lexical ranker (`_lexical.mjs` and the files it imports). The files in this folder only decide **the order of matches inside one score band**: they never add or drop a match, change a score, or move a match past one of another band or kind (doc or not). The bands are scores 195 and up, 188–194, 170–187, 160–169, 151–159, 100–150, 55–99, and under 55. A band can be wide (55–99 holds keyword matches beside one-word description hits), so inside a band a lower score can lead a higher one.
3
+ `astryx search` decides **what matches**, and each match's score and reason, with the lexical ranker (`_lexical.mjs` and the files it imports). The files in this folder only decide **the order of matches inside one score band**: they never add or drop a match, change a score, or move a match past one of another band or kind (doc or not). The bands are scores 195 and up, 188–194, 170–187, 160–169, 151–159, 100–150, 55–99, and under 55. A band can be wide (55–99 holds keyword matches beside one-word description hits), so inside a band a lower score can lead a higher one. In search's own reading of the catalog (`searchView` in `_named-keywords.mjs`), a doc that opens a level (a docs-tree namespace, holding the docs under its route as `_summarizes`) does not answer a query word through its text (its prose, or a code term or table cell its keywords gather) when a doc beneath it answers that word at least as strongly (`_candidate-score.mjs`); its name, title, description and declared keywords stay its own. `searchCore`, which build reads, keeps the gathered reading.
4
4
 
5
5
  ## Rule
6
6
 
7
- `spec:AST-083` owns search's result order; this file describes the data that implements it. Inside one score band, a searcher's static weights decide the order. Matches with the same score move together as one block, placed by the learned position of the block's first match: moving each one on its own breaks search's existing rules for tied matches. Inside a block, the lexical ranker's order holds, except below the first result: there a block of one domain puts a part of the first result first (its name words start with the first result's; at most two parts lead across an answer), then the match whose matched words are rarer in the catalog. Matches never cross bands or kinds. There is no model runtime: every number is a plain static value read at load time. A one-word PascalCase query that only doc text mentions is read as its words too (`identifierReading` in `_lexical.mjs`): the lexical ranker puts the entries that mention it, and those its words name outright, before the entries its words only match, and the learned order and fit pass then apply to that order as to any other.
7
+ `spec:AST-083` owns search's result order; this file describes the data that implements it. Inside one score band, a searcher's static weights decide the order. Matches with the same score move together as one block, placed by the learned position of the block's first match: moving each one on its own breaks search's existing rules for tied matches. Then a family's root leads a part of its own family in their run (same band and domain) when the root answers every query word the part answers and no query word is, in any plural or stem form, a word of the part's name that does not start a word of the root's name (`rootsFirst`, with families from each member's doc): `tabs` puts TabList before its Tab, while a query holding "item" keeps ListItem before List and one holding "statuses" keeps FieldStatus before Field. The root moves just ahead of the part; nothing else moves. Then the first result's tie can go to another match (`tieByOwnName`): among matches of the first result's domain that scored the same as it and matched the same query words (the terms their reasons list), a match whose name words hold more of the query's words than the first result's name moves first. A first result whose reason lists no terms keeps its place: one that matched the whole query (a name, keyword, or title hit) or whose title the query holds (`how do i generate a palette` keeps `author-a-theme` ahead of the tied `generate-a-palette` doc); a part of the first result (in its family, or its name words start with the first result's) never takes its place this way; and an entry the query names keeps it. Without this, a tie for first place goes to the first name alphabetically. Inside a block, the lexical ranker's order holds, except below the first result: there a block of one domain puts a part of the first result first (its name words start with the first result's; at most two parts lead across an answer), then the match whose matched words are rarer in the catalog. Matches never cross bands or kinds. There is no model runtime: every number is a plain static value read at load time. A one-word PascalCase query that only doc text mentions is read as its words too (`identifierReading` in `_lexical.mjs`): the lexical ranker puts the entries that mention it, and those its words name outright, before the entries its words only match, and the learned order and fit pass then apply to that order as to any other.
8
8
 
9
9
  After that order, one fit pass reads the first ten results (`_fit-order.mjs`). The first result stays. The others split into runs of one band and kind. Inside a run, each match gets a fit to the whole query from the block picker's `matchOf` (`../build/blocks/blocks.mjs` with `blocks.weights.json`, over the weights' vocabulary) over the match's own docs: its name words, display name or title, description, and keywords. A match whose fit is under 1.7 times the run's median fit moves, in order, after the others in its run, unless its name spells two or more of the query's words. Such a match never moves down; it can still move up when others move after it. A run whose median fit is zero or less keeps its order. A query that is an entry's whole name skips the pass, as it skips the learned order. The pass always reads ten places before the limit cuts the answer. At the default limit, and at any limit of 10 or more, the set of results stays the same. A smaller limit shows the top of the new order, so it can show a different result. Build's loader (`loadBlockPicker` in `../build/_adapter.mjs`) reads and checks the block-picker weights for both commands. When the file is missing, unreadable, or not the picker's shape, the loader returns null and the pass keeps the order. The pass reads the weights only when a run holds two or more matches, and it decodes only the matrix rows that the query's words and those matches' docs use, so a search does not pay for the whole catalog.
10
10
 
@@ -21,6 +21,8 @@
21
21
  * @param {string[]} [candidate.guidance] - Usage guidance (features, best practices) — scored a tier below description.
22
22
  * @param {string} [candidate._family] - The family whose doc lists the entry as a member.
23
23
  * @param {number} [candidate._familyIndex] - The entry's place among that family's members.
24
+ * @param {any[]} [candidate._summarizes] - The docs beneath a doc that
25
+ * opens a level, in search's view only (_named-keywords.mjs).
24
26
  * @param {{fuzzy?: boolean, joins?: boolean, part?: boolean, synonym?: boolean, mentions?: boolean}} [opts] - `mentions`: also say whether the hit is only a mention (see `inText`); only the reading of a one-identifier query asks, so other searches pay nothing for it. `fuzzy`: allow edit-distance (typo) matches. Default true; multi-word queries pass false. `joins`: read a spaced query joined into a name or keyword (default true); off when the query names an entry outright. `part`: the term is one word of a longer query, so a name's head word after single letters (Stack in VStack) does not count as a keyword hit for it. `synonym`: the term stands in for a word of the query, so it names no family.
25
27
  * @returns {{score: number, reason: string, alias?: 'partial' | 'keyword', inText?: true} | null}
26
28
  * `alias` marks a hit that read the query's words joined; `inText`, asked
@@ -40,6 +42,7 @@ export function scoreCandidate(term: string, candidate: {
40
42
  guidance?: string[] | undefined;
41
43
  _family?: string | undefined;
42
44
  _familyIndex?: number | undefined;
45
+ _summarizes?: any[] | undefined;
43
46
  }, { fuzzy, joins, part, synonym, mentions, }?: {
44
47
  fuzzy?: boolean;
45
48
  joins?: boolean;
@@ -236,6 +236,8 @@ function weakKeywordScore(t, kw) {
236
236
  * @param {string[]} [candidate.guidance] - Usage guidance (features, best practices) — scored a tier below description.
237
237
  * @param {string} [candidate._family] - The family whose doc lists the entry as a member.
238
238
  * @param {number} [candidate._familyIndex] - The entry's place among that family's members.
239
+ * @param {any[]} [candidate._summarizes] - The docs beneath a doc that
240
+ * opens a level, in search's view only (_named-keywords.mjs).
239
241
  * @param {{fuzzy?: boolean, joins?: boolean, part?: boolean, synonym?: boolean, mentions?: boolean}} [opts] - `mentions`: also say whether the hit is only a mention (see `inText`); only the reading of a one-identifier query asks, so other searches pay nothing for it. `fuzzy`: allow edit-distance (typo) matches. Default true; multi-word queries pass false. `joins`: read a spaced query joined into a name or keyword (default true); off when the query names an entry outright. `part`: the term is one word of a longer query, so a name's head word after single letters (Stack in VStack) does not count as a keyword hit for it. `synonym`: the term stands in for a word of the query, so it names no family.
240
242
  * @returns {{score: number, reason: string, alias?: 'partial' | 'keyword', inText?: true} | null}
241
243
  * `alias` marks a hit that read the query's words joined; `inText`, asked
@@ -271,14 +273,37 @@ export function scoreCandidate(
271
273
  let alias = false;
272
274
  /** Whether the best hit is a mention in text, not a name or keyword. */
273
275
  let inText = false;
276
+ // A doc that opens a level (search's view, _named-keywords.mjs) sums up the
277
+ // docs beneath it: a term its text mentions that one of them answers at
278
+ // least as strongly is that doc's evidence, not this page's.
279
+ const summarized = candidate._summarizes;
280
+ /** @param {number} score */
281
+ const answeredBelow = score =>
282
+ summarized != null &&
283
+ summarized.some(
284
+ doc =>
285
+ (scoreCandidate(term, doc, {fuzzy, joins, part, synonym})?.score ??
286
+ 0) >= score,
287
+ );
274
288
  /**
275
289
  * @param {number} score
276
290
  * @param {string} why
277
291
  * @param {'partial' | 'keyword' | false} [byAlias] - the hit reads the
278
292
  * query's words joined, into part of a name or into a keyword
279
293
  * @param {boolean} [mention] - the hit is the term mentioned in text
294
+ * @param {boolean} [text] - the hit is the page's text (its prose, or a
295
+ * keyword that text gathers) rather than its name, title, description or
296
+ * declared keywords; a page that sums up the docs beneath it does not
297
+ * take it when one of them answers the term as strongly
280
298
  */
281
- const consider = (score, why, byAlias = false, mention = false) => {
299
+ const consider = (
300
+ score,
301
+ why,
302
+ byAlias = false,
303
+ mention = false,
304
+ text = false,
305
+ ) => {
306
+ if (text && score > best && answeredBelow(score)) return;
282
307
  if (score > best) {
283
308
  best = score;
284
309
  reason = why;
@@ -378,6 +403,9 @@ export function scoreCandidate(
378
403
 
379
404
  // ── Keyword signals ─────────────────────────────────────────────
380
405
  const termJoined = joined(term);
406
+ /** Whether a keyword is one the page's text gathers (see `consider`). */
407
+ const byText = (/** @type {string} */ lower) =>
408
+ summarized != null && mentionKeyword(candidate, lower);
381
409
  for (const {kw, text: kwText, lower: kwLower} of p.keywords) {
382
410
  // A one-word keyword typed as separate words is the keyword: `number
383
411
  // field` is `numberfield`. Only a
@@ -390,6 +418,7 @@ export function scoreCandidate(
390
418
  `keyword "${kw}"`,
391
419
  false,
392
420
  mentions && mentionKeyword(candidate, kwLower),
421
+ byText(kwLower),
393
422
  );
394
423
  continue;
395
424
  }
@@ -399,6 +428,7 @@ export function scoreCandidate(
399
428
  `keyword "${kw}"`,
400
429
  'keyword',
401
430
  mentions && mentionKeyword(candidate, kwLower),
431
+ byText(kwLower),
402
432
  );
403
433
  continue;
404
434
  }
@@ -408,6 +438,7 @@ export function scoreCandidate(
408
438
  `keyword "${kw}"`,
409
439
  false,
410
440
  mentions && mentionKeyword(candidate, kwLower),
441
+ byText(kwLower),
411
442
  );
412
443
  continue;
413
444
  }
@@ -417,6 +448,7 @@ export function scoreCandidate(
417
448
  `keyword "${kw}"`,
418
449
  false,
419
450
  mentions && mentionKeyword(candidate, kwLower),
451
+ byText(kwLower),
420
452
  );
421
453
  if (fuzzy) {
422
454
  const dist = typoDistance(term, kwLower);
@@ -426,6 +458,7 @@ export function scoreCandidate(
426
458
  `keyword "${kw}" (distance ${dist})`,
427
459
  false,
428
460
  mentions && mentionKeyword(candidate, kwLower),
461
+ byText(kwLower),
429
462
  );
430
463
  }
431
464
  }
@@ -457,7 +490,7 @@ export function scoreCandidate(
457
490
  let matchedProse = false;
458
491
  for (let i = 0; i < prose.length; i++) {
459
492
  if (prose[i] && re.test(loweredAt(p.prose, prose, i))) {
460
- consider(50, `docs mention "${term}"`, false, true);
493
+ consider(50, `docs mention "${term}"`, false, true, true);
461
494
  matchedProse = true;
462
495
  break;
463
496
  }
@@ -468,7 +501,7 @@ export function scoreCandidate(
468
501
  if (!matchedProse) {
469
502
  for (let i = 0; i < guidance.length; i++) {
470
503
  if (guidance[i] && re.test(loweredAt(p.guidance, guidance, i))) {
471
- consider(45, `guidance mentions "${term}"`, false, true);
504
+ consider(45, `guidance mentions "${term}"`, false, true, true);
472
505
  break;
473
506
  }
474
507
  }
@@ -20,6 +20,7 @@ import {
20
20
  } from '../../foundation/discovery/docs-section-key.mjs';
21
21
  import {sectionProse, codeTerms, headings, plain} from './_doc-text.mjs';
22
22
  import {loadAuthoringSelfDocs} from '../../foundation/discovery/authoring-self-docs.mjs';
23
+ import {readDocAsData} from '../../foundation/discovery/docs-discovery.mjs';
23
24
 
24
25
  /** @typedef {import('./_lexical.mjs').Candidate} Candidate */
25
26
 
@@ -73,12 +74,16 @@ export async function gatherDocs(cwd) {
73
74
  }
74
75
  const read = lowered?.doc ?? null;
75
76
  if (isExperimentalDoc(read)) continue;
77
+ const hiddenHere = new Set([
78
+ ...hidden,
79
+ ...(await experimentalSectionKeys(entry.extensions)),
80
+ ]);
76
81
  const doc =
77
- read && hidden.size > 0 && Array.isArray(read.sections)
82
+ read && hiddenHere.size > 0 && Array.isArray(read.sections)
78
83
  ? {
79
84
  ...read,
80
85
  sections: read.sections.filter(
81
- (/** @type {any} */ section) => !hidden.has(section.id),
86
+ (/** @type {any} */ section) => !hiddenHere.has(section.id),
82
87
  ),
83
88
  }
84
89
  : read;
@@ -194,6 +199,28 @@ export async function gatherDocs(cwd) {
194
199
  return candidates;
195
200
  }
196
201
 
202
+ /**
203
+ * The keys of the sections that experimental extensions add to a topic: like
204
+ * an experimental topic, they are read on their own and never searched.
205
+ * @param {ReadonlyArray<{path: string}>} extensions
206
+ * @returns {Promise<string[]>}
207
+ */
208
+ async function experimentalSectionKeys(extensions) {
209
+ /** @type {string[]} */
210
+ const keys = [];
211
+ for (const extension of extensions) {
212
+ let doc;
213
+ try {
214
+ doc = /** @type {any} */ (await readDocAsData(extension.path));
215
+ } catch {
216
+ continue;
217
+ }
218
+ if (!isExperimentalDoc(doc) || !Array.isArray(doc.sections)) continue;
219
+ keys.push(...doc.sections.map(sectionKey));
220
+ }
221
+ return keys;
222
+ }
223
+
197
224
  /**
198
225
  * Is this doc an experimental surface's (spec:AST-017 FR21)?
199
226
  * @param {any} doc
@@ -5,6 +5,7 @@
5
5
  */
6
6
 
7
7
  import fs from 'node:fs';
8
+ import {renderTokens} from '../../foundation/doc-compiler/links.mjs';
8
9
  import {CORE_PACKAGE} from '../../foundation/discovery/component-discovery.mjs';
9
10
  import {discoverTemplates} from '../template/template.mjs';
10
11
  import {listAvailableThemes} from '../theme/_adapter.mjs';
@@ -123,7 +124,7 @@ export async function gatherTemplates(cwd) {
123
124
  return derive();
124
125
  },
125
126
  ...(weakKeywordBound ? {weakKeywordBound} : {}),
126
- description: t.description || '',
127
+ description: renderTokens(t.description || ''),
127
128
  // A template's own keywords name the many ideas it serves, so they score
128
129
  // as its prose does, not as a name: one of them matching one word of a
129
130
  // short idea is not a direct match.
@@ -70,6 +70,18 @@ function namesLoosely(candidate, loose) {
70
70
  });
71
71
  }
72
72
 
73
+ /**
74
+ * Each family member's `domain:name`, mapped to the family its doc lists it
75
+ * in (see rootsFirst in _order.mjs).
76
+ * @param {import('./_lexical.mjs').Candidate[]} all
77
+ * @returns {Map<string, string>}
78
+ */
79
+ function familiesOf(all) {
80
+ return new Map(
81
+ all.flatMap(c => (c._family ? [[`${c.domain}:${c.name}`, c._family]] : [])),
82
+ );
83
+ }
84
+
73
85
  /**
74
86
  * Ranks with one searcher's weights. Shared by the main searcher and every
75
87
  * topic searcher, which differ only in their weights.
@@ -105,6 +117,7 @@ export function rankWith(request, catalog, weights) {
105
117
  lexical,
106
118
  query,
107
119
  Math.max(limit, FIT_PLACES),
120
+ familiesOf(catalog.all),
108
121
  ),
109
122
  catalog.all,
110
123
  query,
@@ -14,7 +14,8 @@
14
14
  export function withoutOtherNames(all: import("./_lexical.mjs").Candidate[], named?: import("./_lexical.mjs").Candidate[]): import("./_lexical.mjs").Candidate[];
15
15
  /**
16
16
  * The gathered catalog as search reads it: its entries with
17
- * {@link withoutOtherNames} applied. Names come from the catalog and from
17
+ * {@link withoutOtherNames} applied, and each doc that opens a level read at
18
+ * its own grain ({@link withSummarized}). Names come from the catalog and from
18
19
  * `others`, further gathered catalogs (a search for one `type` passes the
19
20
  * other of components and hooks, so `type` never changes which keywords
20
21
  * count). A reused gather, with the same others, gets the same view back.
@@ -133,6 +133,45 @@ export function withoutOtherNames(all, named = all) {
133
133
  });
134
134
  }
135
135
 
136
+ /**
137
+ * The catalog's docs, each doc that opens a level (a docs-tree namespace such
138
+ * as `layout`) holding the docs beneath it (`_summarizes`: the pages under its
139
+ * route and their sections). Such a page sums up the docs below it: a word its
140
+ * text shares with one of them is that doc's evidence, which the reader opens
141
+ * at its own grain, so the page does not answer it through that text
142
+ * (`scoreCandidate`, _candidate-score.mjs). Its name, title, description and
143
+ * declared keywords stay its own. Entries with nothing beneath them are
144
+ * returned as they are.
145
+ * @param {import('./_lexical.mjs').Candidate[]} all
146
+ * @returns {import('./_lexical.mjs').Candidate[]}
147
+ */
148
+ function withSummarized(all) {
149
+ /** @type {Map<string, import('./_lexical.mjs').Candidate[]>} */
150
+ const below = new Map();
151
+ for (const c of all) {
152
+ const topic = c.domain === 'doc' ? /** @type {any} */ (c)._topic : null;
153
+ if (typeof topic !== 'string') continue;
154
+ for (let at = topic.indexOf('/'); at > 0; at = topic.indexOf('/', at + 1)) {
155
+ const route = topic.slice(0, at);
156
+ const list = below.get(route);
157
+ if (list) list.push(c);
158
+ else below.set(route, [c]);
159
+ }
160
+ }
161
+ if (below.size === 0) return all;
162
+ return all.map(c => {
163
+ const topic = c.domain === 'doc' ? /** @type {any} */ (c)._topic : null;
164
+ const docs = typeof topic === 'string' ? below.get(topic) : undefined;
165
+ if (!docs) return c;
166
+ const view = Object.create(
167
+ Object.getPrototypeOf(c),
168
+ Object.getOwnPropertyDescriptors(c),
169
+ );
170
+ Object.defineProperty(view, '_summarizes', {value: docs});
171
+ return view;
172
+ });
173
+ }
174
+
136
175
  /**
137
176
  * Each gathered catalog's search views, one per set of naming catalogs.
138
177
  * @type {WeakMap<object, {others: object[], view: object}[]>}
@@ -141,7 +180,8 @@ const views = new WeakMap();
141
180
 
142
181
  /**
143
182
  * The gathered catalog as search reads it: its entries with
144
- * {@link withoutOtherNames} applied. Names come from the catalog and from
183
+ * {@link withoutOtherNames} applied, and each doc that opens a level read at
184
+ * its own grain ({@link withSummarized}). Names come from the catalog and from
145
185
  * `others`, further gathered catalogs (a search for one `type` passes the
146
186
  * other of components and hooks, so `type` never changes which keywords
147
187
  * count). A reused gather, with the same others, gets the same view back.
@@ -158,11 +198,13 @@ export function searchView(catalog, others = []) {
158
198
  v.others.every((o, i) => o === others[i]),
159
199
  );
160
200
  if (hit) return /** @type {T} */ (hit.view);
161
- const all = withoutOtherNames(
162
- catalog.all,
163
- others.length === 0
164
- ? catalog.all
165
- : [catalog.all, ...others.map(o => o.all)].flat(),
201
+ const all = withSummarized(
202
+ withoutOtherNames(
203
+ catalog.all,
204
+ others.length === 0
205
+ ? catalog.all
206
+ : [catalog.all, ...others.map(o => o.all)].flat(),
207
+ ),
166
208
  );
167
209
  const swap = new Map(catalog.all.map((c, i) => [c, all[i]]));
168
210
  const view = {