@astryxdesign/cli 0.7.16 → 0.7.17-canary.g335a172

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 (339) hide show
  1. package/README.md +76 -86
  2. package/api/build/_adapter.d.mts +12 -0
  3. package/api/build/_adapter.mjs +51 -34
  4. package/api/build/blocks/blocks.d.mts +7 -5
  5. package/api/build/blocks/blocks.mjs +113 -26
  6. package/api/build/build.doc.mjs +4 -3
  7. package/api/build/build.type.d.mts +2 -2
  8. package/api/build/build.type.mjs +3 -3
  9. package/api/build/kit/kind.d.mts +2 -1
  10. package/api/build/kit/kind.mjs +199 -10
  11. package/api/build/kit/kit.mjs +6 -4
  12. package/api/build/kit/rank.mjs +69 -16
  13. package/api/build/kit/start.d.mts +5 -4
  14. package/api/build/kit/start.mjs +12 -8
  15. package/api/build/kit/weights.d.mts +16 -3
  16. package/api/build/kit/weights.json +1 -1
  17. package/api/build/kit/weights.mjs +251 -35
  18. package/api/build/kit/word-model.d.mts +23 -0
  19. package/api/build/kit/word-model.mjs +46 -0
  20. package/api/build/kit/words.d.mts +48 -0
  21. package/api/build/kit/words.mjs +90 -1
  22. package/api/component/__fixtures__/resolutions/modules.txt +4 -5
  23. package/api/component/list/list.d.mts +1 -1
  24. package/api/component/list/list.mjs +48 -6
  25. package/api/discover/_adapter.d.mts +1 -1
  26. package/api/discover/search/search.mjs +3 -2
  27. package/api/docs/_adapter.d.mts +26 -2
  28. package/api/docs/_adapter.mjs +219 -6
  29. package/api/docs/docs.d.mts +3 -0
  30. package/api/docs/docs.doc.mjs +7 -1
  31. package/api/docs/docs.mjs +12 -0
  32. package/api/docs/docs.type.d.mts +5 -0
  33. package/api/docs/docs.type.mjs +2 -0
  34. package/api/docs/node/node.mjs +1 -1
  35. package/api/doctor/_adapter.d.mts +27 -5
  36. package/api/doctor/_adapter.mjs +83 -10
  37. package/api/doctor/built-checks.mjs +40 -14
  38. package/api/doctor/doctor.d.mts +4 -3
  39. package/api/doctor/doctor.mjs +14 -7
  40. package/api/doctor/theme-checks.mjs +121 -17
  41. package/api/icon/_records.mjs +2 -1
  42. package/api/index.d.mts +2 -0
  43. package/api/index.mjs +2 -0
  44. package/api/integration/_adapter.d.mts +44 -0
  45. package/api/integration/_adapter.mjs +77 -1
  46. package/api/integration/authoring-checks.mjs +6 -6
  47. package/api/integration/example-scope.d.mts +14 -0
  48. package/api/integration/example-scope.mjs +44 -0
  49. package/api/integration/example-scope.type.d.mts +29 -0
  50. package/api/integration/example-scope.type.mjs +25 -0
  51. package/api/integration/integrationExampleScope.doc.d.mts +11 -0
  52. package/api/integration/integrationExampleScope.doc.mjs +59 -0
  53. package/api/integration/validate-integration.mjs +19 -1
  54. package/api/integration/validate-integration.type.d.mts +9 -0
  55. package/api/integration/validate-integration.type.mjs +1 -1
  56. package/api/integration/validateIntegration.doc.mjs +1 -1
  57. package/api/render/_adapter.mjs +591 -195
  58. package/api/render/render.doc.mjs +11 -3
  59. package/api/render/render.type.d.mts +52 -0
  60. package/api/render/render.type.mjs +31 -1
  61. package/api/search/ORDERING.md +1 -1
  62. package/api/search/_candidate-score.mjs +51 -32
  63. package/api/search/_fit-order.mjs +3 -3
  64. package/api/search/_gather-components.d.mts +3 -2
  65. package/api/search/_gather-components.mjs +12 -3
  66. package/api/search/_lexical.d.mts +5 -0
  67. package/api/search/_lexical.mjs +8 -2
  68. package/api/search/_result.d.mts +11 -9
  69. package/api/search/_result.mjs +4 -4
  70. package/api/search/_score.d.mts +6 -1
  71. package/api/search/_score.mjs +15 -3
  72. package/api/search/search-index.mjs +7 -1
  73. package/api/search/search.d.mts +1 -1
  74. package/api/theme/_adapter.mjs +12 -1
  75. package/api/theme/build/build.d.mts +60 -0
  76. package/api/theme/build/build.mjs +210 -54
  77. package/api/theme/build/font-warning.d.mts +8 -0
  78. package/api/theme/build/font-warning.mjs +19 -0
  79. package/api/theme/theme.type.d.mts +10 -0
  80. package/api/theme/theme.type.mjs +7 -1
  81. package/api/theme-edit/_adapter.d.mts +55 -0
  82. package/api/theme-edit/_adapter.mjs +673 -42
  83. package/api/theme-edit/_check.d.mts +28 -22
  84. package/api/theme-edit/_check.mjs +1858 -312
  85. package/api/theme-edit/_color.d.mts +10 -0
  86. package/api/theme-edit/_color.mjs +49 -1
  87. package/api/theme-edit/_compiler.mjs +9 -0
  88. package/api/theme-edit/_context.mjs +60 -3
  89. package/api/theme-edit/_css.mjs +21 -1
  90. package/api/theme-edit/_edit.d.mts +22 -0
  91. package/api/theme-edit/_edit.mjs +1533 -92
  92. package/api/theme-edit/_how-commands.d.mts +57 -0
  93. package/api/theme-edit/_how-commands.mjs +587 -1
  94. package/api/theme-edit/_how-question.d.mts +78 -0
  95. package/api/theme-edit/_how-question.mjs +4716 -235
  96. package/api/theme-edit/_how.mjs +134 -8
  97. package/api/theme-edit/_marks.d.mts +31 -5
  98. package/api/theme-edit/_marks.mjs +57 -5
  99. package/api/theme-edit/_normal.d.mts +219 -0
  100. package/api/theme-edit/_normal.mjs +1041 -0
  101. package/api/theme-edit/_palette.mjs +10 -4
  102. package/api/theme-edit/_parts.d.mts +8 -0
  103. package/api/theme-edit/_parts.mjs +103 -2
  104. package/api/theme-edit/_playwright-picture.d.mts +4 -0
  105. package/api/theme-edit/_playwright-picture.mjs +34 -0
  106. package/api/theme-edit/_preview-app.d.mts +7 -1
  107. package/api/theme-edit/_preview-app.mjs +394 -74
  108. package/api/theme-edit/_preview.d.mts +69 -8
  109. package/api/theme-edit/_preview.mjs +531 -108
  110. package/api/theme-edit/_settings.d.mts +243 -6
  111. package/api/theme-edit/_settings.mjs +2415 -147
  112. package/api/theme-edit/_tables.d.mts +6 -0
  113. package/api/theme-edit/_tables.mjs +44 -1
  114. package/api/theme-edit/_vet.d.mts +18 -0
  115. package/api/theme-edit/_vet.mjs +32 -0
  116. package/api/theme-edit/theme-edit.type.d.mts +10 -1
  117. package/api/theme-edit/theme-edit.type.mjs +4 -1
  118. package/api/theme-edit/themeEditHow.doc.mjs +1 -1
  119. package/api/theme-edit/themeEditNew.doc.mjs +1 -1
  120. package/api/theme-edit/themeEditPreviewApp.doc.mjs +3 -3
  121. package/api/theme-edit/themeEditPreviewRemove.doc.mjs +2 -2
  122. package/api/upgrade/run/run.mjs +4 -3
  123. package/assets/codemods/integration-discovery.mjs +2 -1
  124. package/assets/codemods/run-codemod.mjs +87 -7
  125. package/assets/codemods/transforms/next/index.mjs +11 -1
  126. package/assets/codemods/transforms/next/migrate-item-swipe-actions-to-swipe.mjs +394 -0
  127. package/assets/component-list.generated.json +1 -0
  128. package/assets/docs/author-a-theme.doc.mjs +1 -0
  129. package/assets/docs/theme.doc.dense.mjs +2 -2
  130. package/assets/docs/theme.doc.mjs +1 -1
  131. package/assets/docs/tree/check-your-docs.doc.mjs +1 -1
  132. package/assets/docs/tree/checks.doc.mjs +1 -1
  133. package/assets/docs/tree/cli-command.doc.mjs +2 -3
  134. package/assets/docs/tree/render-pages.doc.mjs +44 -3
  135. package/assets/docs/tree/single-component.doc.mjs +4 -0
  136. package/assets/docs/tree/template-doc-overview.doc.mjs +1 -1
  137. package/assets/docs/tree/test-in-an-app.doc.mjs +1 -1
  138. package/assets/docs/use-a-theme.doc.mjs +1 -1
  139. package/assets/docs.generated.json +2 -2
  140. package/assets/self-audit.generated.json +1 -1
  141. package/assets/templates/blocks/components/ChatComposerInput/useChatDictationHookUsage.doc.mjs +14 -0
  142. package/assets/templates/blocks/components/ChatComposerInput/useChatDictationHookUsage.tsx +38 -0
  143. package/assets/templates/blocks/components/Hooks/useContainerRevealHookUsage.tsx +2 -2
  144. package/assets/templates/blocks/components/SyntaxTheme/useSyntaxThemeHookUsage.doc.mjs +14 -0
  145. package/assets/templates/blocks/components/SyntaxTheme/useSyntaxThemeHookUsage.tsx +36 -0
  146. package/assets/templates/components.generated.json +1 -1
  147. package/assets/templates/pages/ai-chat/template.doc.mjs +5 -4
  148. package/assets/templates/pages/ai-chat-landing/template.doc.mjs +2 -1
  149. package/assets/templates/pages/blank/template.doc.mjs +1 -1
  150. package/assets/templates/pages/canvas-editor/template.doc.mjs +4 -2
  151. package/assets/templates/pages/centered-hero/template.doc.mjs +9 -1
  152. package/assets/templates/pages/classic-gallery/template.doc.mjs +1 -1
  153. package/assets/templates/pages/contact-form/template.doc.mjs +2 -1
  154. package/assets/templates/pages/dashboard/template.doc.mjs +3 -2
  155. package/assets/templates/pages/dashboard-alert-rail/template.doc.mjs +2 -1
  156. package/assets/templates/pages/dashboard-cohort-funnel/template.doc.mjs +2 -1
  157. package/assets/templates/pages/dashboard-composition/template.doc.mjs +2 -1
  158. package/assets/templates/pages/dashboard-progress/template.doc.mjs +6 -3
  159. package/assets/templates/pages/detail-page/template.doc.mjs +10 -3
  160. package/assets/templates/pages/documentation/template.doc.mjs +4 -1
  161. package/assets/templates/pages/documentation-design/template.doc.mjs +7 -1
  162. package/assets/templates/pages/documentation-technical/template.doc.mjs +7 -1
  163. package/assets/templates/pages/editor/template.doc.mjs +2 -8
  164. package/assets/templates/pages/file-explorer/template.doc.mjs +1 -1
  165. package/assets/templates/pages/form-two-column/template.doc.mjs +4 -3
  166. package/assets/templates/pages/form-wizard/template.doc.mjs +5 -3
  167. package/assets/templates/pages/gallery-hero/template.doc.mjs +4 -2
  168. package/assets/templates/pages/ide/page.tsx +24 -2
  169. package/assets/templates/pages/kanban-board/template.doc.mjs +1 -9
  170. package/assets/templates/pages/library/template.doc.mjs +4 -1
  171. package/assets/templates/pages/login/template.doc.mjs +2 -1
  172. package/assets/templates/pages/login-card/template.doc.mjs +2 -1
  173. package/assets/templates/pages/login-split/template.doc.mjs +2 -1
  174. package/assets/templates/pages/login-sso/template.doc.mjs +4 -2
  175. package/assets/templates/pages/mixed-gallery/template.doc.mjs +2 -1
  176. package/assets/templates/pages/product-detail/template.doc.mjs +4 -2
  177. package/assets/templates/pages/product-gallery/template.doc.mjs +2 -1
  178. package/assets/templates/pages/settings-dialog/template.doc.mjs +2 -1
  179. package/assets/templates/pages/settings-sidebar/template.doc.mjs +2 -1
  180. package/assets/templates/pages/shell-nav/template.doc.mjs +4 -2
  181. package/assets/templates/pages/shell-side-nav/template.doc.mjs +5 -3
  182. package/assets/templates/pages/shell-top-nav/template.doc.mjs +2 -1
  183. package/assets/templates/pages/side-gallery/template.doc.mjs +9 -1
  184. package/assets/templates/pages/table-filter/template.doc.mjs +9 -8
  185. package/assets/templates/pages/table-grouped/template.doc.mjs +4 -2
  186. package/assets/templates/pages/table-page/template.doc.mjs +5 -4
  187. package/assets/templates/pages/table-tree/template.doc.mjs +6 -3
  188. package/assets/templates/pages/theme-showcase/template.doc.mjs +2 -9
  189. package/assets/templates/pages/work-item-detail/template.doc.mjs +1 -0
  190. package/assets/theme.template.ts +6 -0
  191. package/authoring/debug/parse.d.mts +3 -3
  192. package/authoring/doctypes/_schema.d.mts +3 -3
  193. package/authoring/doctypes/command/command.doc.mjs +1 -1
  194. package/authoring/doctypes/component/categories.d.mts +37 -0
  195. package/authoring/doctypes/component/categories.mjs +54 -0
  196. package/authoring/doctypes/template/template.doc.mjs +1 -1
  197. package/authoring/doctypes/template/type.ts +9 -0
  198. package/authoring/example/example.doc.d.mts +12 -0
  199. package/authoring/example/example.doc.mjs +69 -0
  200. package/authoring/example/preview.d.mts +92 -0
  201. package/authoring/example/preview.mjs +994 -0
  202. package/authoring/example/type.ts +102 -0
  203. package/authoring/index.d.mts +1 -0
  204. package/authoring/index.d.ts +12 -0
  205. package/authoring/index.mjs +3 -1
  206. package/clients/cli/bin/astryx.mjs +6 -9
  207. package/clients/cli/build-id.generated.json +1 -1
  208. package/clients/cli/commands/component.doc.mjs +1 -1
  209. package/clients/cli/commands/component.mjs +22 -3
  210. package/clients/cli/commands/docs.doc.mjs +7 -1
  211. package/clients/cli/commands/docs.mjs +3 -1
  212. package/clients/cli/commands/doctor.mjs +32 -14
  213. package/clients/cli/commands/experimental/render.mjs +42 -1
  214. package/clients/cli/commands/experimental/theme.mjs +145 -16
  215. package/clients/cli/commands/experimental-render.doc.mjs +2 -2
  216. package/clients/cli/commands/experimental-theme-compile.doc.mjs +3 -3
  217. package/clients/cli/commands/experimental-theme-editor-how.doc.mjs +87 -1
  218. package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +2 -2
  219. package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +1 -1
  220. package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +1 -1
  221. package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +2 -2
  222. package/clients/cli/commands/experimental-theme-editor.doc.mjs +1 -1
  223. package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +1 -1
  224. package/clients/cli/commands/experimental-theme-preview-remove.doc.mjs +2 -2
  225. package/clients/cli/commands/search.doc.mjs +2 -1
  226. package/clients/cli/commands/search.mjs +6 -1
  227. package/clients/cli/commands/template.mjs +4 -2
  228. package/clients/cli/commands/theme-build.doc.mjs +5 -1
  229. package/clients/cli/commands/theme.doc.mjs +1 -1
  230. package/clients/cli/commands/theme.mjs +183 -6
  231. package/clients/cli/commands/upgrade.mjs +42 -7
  232. package/clients/cli/index.mjs +1 -1
  233. package/clients/cli/lib/cli-error.mjs +2 -1
  234. package/clients/cli/lib/component-format.mjs +205 -98
  235. package/clients/cli/lib/hook-format.mjs +9 -19
  236. package/clients/cli/lib/json-shim.mjs +77 -21
  237. package/clients/cli/lib/manifest.mjs +3 -2
  238. package/clients/cli/manifest.generated.json +1 -1
  239. package/foundation/agent-docs/agent-docs.mjs +1 -1
  240. package/foundation/config/theme-state.d.mts +13 -1
  241. package/foundation/config/theme-state.mjs +47 -7
  242. package/foundation/discovery/authoring-self-docs.mjs +1 -0
  243. package/foundation/discovery/component-discovery.d.mts +11 -0
  244. package/foundation/discovery/component-discovery.mjs +56 -8
  245. package/foundation/discovery/component-replacement.mjs +130 -1
  246. package/foundation/discovery/copied-passages.mjs +2 -1
  247. package/foundation/discovery/doc-types.mjs +4 -3
  248. package/foundation/discovery/entry-name-files.d.mts +43 -0
  249. package/foundation/discovery/entry-name-files.mjs +264 -0
  250. package/foundation/discovery/hook-discovery.d.mts +8 -2
  251. package/foundation/discovery/hook-discovery.mjs +22 -8
  252. package/foundation/discovery/icon-definition-discovery.mjs +2 -1
  253. package/foundation/discovery/icon-set-checks.mjs +2 -1
  254. package/foundation/discovery/icon-set-discovery.mjs +2 -1
  255. package/foundation/discovery/integration-doc-files.mjs +2 -1
  256. package/foundation/discovery/package-exports.d.mts +10 -0
  257. package/foundation/discovery/package-exports.mjs +56 -3
  258. package/foundation/discovery/prop-drift.mjs +9 -9
  259. package/foundation/discovery/runner-allowlist.d.mts +1 -0
  260. package/foundation/discovery/runner-allowlist.mjs +2 -0
  261. package/foundation/discovery/stored-component-list.d.mts +43 -0
  262. package/foundation/discovery/stored-component-list.mjs +90 -0
  263. package/foundation/discovery/stored-self-audit.d.mts +26 -10
  264. package/foundation/discovery/stored-self-audit.mjs +38 -18
  265. package/foundation/discovery/template-adapter.d.mts +52 -0
  266. package/foundation/discovery/template-adapter.mjs +176 -12
  267. package/foundation/discovery/template-icons.mjs +2 -1
  268. package/foundation/discovery/theme-discovery.mjs +3 -2
  269. package/foundation/discovery/theme-imports.d.mts +14 -0
  270. package/foundation/discovery/theme-imports.mjs +43 -1
  271. package/foundation/discovery/theming-targets.mjs +3 -2
  272. package/foundation/doc-compiler/import.mjs +7 -1
  273. package/foundation/doc-compiler/inputs.mjs +3 -2
  274. package/foundation/doc-compiler/parse-readable.mjs +4 -1
  275. package/foundation/doc-compiler/stored-docs.d.mts +22 -0
  276. package/foundation/doc-compiler/stored-docs.mjs +49 -0
  277. package/foundation/env/semver.mjs +3 -1
  278. package/foundation/fonts/font-stylesheet.d.mts +31 -0
  279. package/foundation/fonts/font-stylesheet.mjs +115 -0
  280. package/foundation/fs/cache-eviction.d.mts +21 -0
  281. package/foundation/fs/cache-eviction.mjs +73 -0
  282. package/foundation/fs/file-protection.mjs +4 -3
  283. package/foundation/fs/gather-cache.d.mts +25 -4
  284. package/foundation/fs/gather-cache.mjs +164 -55
  285. package/foundation/fs/jiti-cache.d.mts +19 -1
  286. package/foundation/fs/jiti-cache.mjs +130 -6
  287. package/foundation/fs/kept-tree.d.mts +60 -0
  288. package/foundation/fs/kept-tree.mjs +154 -0
  289. package/foundation/fs/listing-cache.d.mts +7 -0
  290. package/foundation/fs/listing-cache.mjs +10 -0
  291. package/foundation/fs/module-loader.d.mts +24 -2
  292. package/foundation/fs/module-loader.mjs +94 -21
  293. package/foundation/fs/paths.d.mts +18 -0
  294. package/foundation/fs/paths.mjs +15 -2
  295. package/foundation/identity/provider-identity.d.mts +6 -0
  296. package/foundation/identity/provider-identity.mjs +10 -1
  297. package/foundation/integrations/contribution-inventory.mjs +4 -3
  298. package/foundation/integrations/example-code.d.mts +63 -0
  299. package/foundation/integrations/example-code.mjs +416 -0
  300. package/foundation/integrations/public-imports.d.mts +9 -0
  301. package/foundation/integrations/public-imports.mjs +3 -2
  302. package/foundation/integrations/validate-contributions.mjs +17 -45
  303. package/foundation/render/embedded-files.d.mts +6 -0
  304. package/foundation/render/embedded-files.mjs +25 -5
  305. package/foundation/render/embedded-imports.d.mts +39 -7
  306. package/foundation/render/embedded-imports.mjs +66 -27
  307. package/foundation/render/file-header.d.mts +66 -0
  308. package/foundation/render/file-header.mjs +118 -0
  309. package/foundation/render/host-answer.d.mts +18 -0
  310. package/foundation/render/host-answer.mjs +46 -0
  311. package/foundation/render/host-exit.d.mts +1 -0
  312. package/foundation/render/host-exit.mjs +6 -1
  313. package/foundation/render/html-reader.d.mts +55 -2
  314. package/foundation/render/html-reader.mjs +145 -26
  315. package/foundation/render/markup-edits.d.mts +57 -0
  316. package/foundation/render/markup-edits.mjs +182 -0
  317. package/foundation/render/page-host.mjs +29 -12
  318. package/foundation/render/page-worker.mjs +121 -13
  319. package/foundation/render/rebuild.mjs +2 -1
  320. package/foundation/render/render-page.d.mts +35 -3
  321. package/foundation/render/render-page.mjs +316 -42
  322. package/foundation/render/source-block.d.mts +85 -6
  323. package/foundation/render/source-block.mjs +211 -20
  324. package/foundation/render/ts-paths.d.mts +69 -6
  325. package/foundation/render/ts-paths.mjs +326 -40
  326. package/foundation/response/error-codes.d.mts +3 -1
  327. package/foundation/response/error-codes.d.ts +1 -0
  328. package/foundation/response/error-codes.doc.mjs +12 -1
  329. package/foundation/response/error-codes.mjs +11 -1
  330. package/foundation/response/response-types.doc.mjs +2 -2
  331. package/foundation/text/compare-text.d.mts +14 -0
  332. package/foundation/text/compare-text.mjs +68 -0
  333. package/foundation/text/string-utils.d.mts +3 -2
  334. package/foundation/text/string-utils.mjs +18 -4
  335. package/foundation/text/suggest-order.d.mts +9 -0
  336. package/foundation/text/suggest-order.mjs +15 -1
  337. package/foundation/xle/expand.mjs +2 -1
  338. package/host/index.mjs +8 -6
  339. package/package.json +7 -6
@@ -12,12 +12,15 @@
12
12
  * @property {string} category The template's own `Family - Variant` label; empty when it declares none.
13
13
  * @property {string[]} keywords The ideas the page serves, as its own descriptor names them; empty when it declares none.
14
14
  * @property {string} filePath Absolute path to the template source file on disk.
15
+ * @property {string[]} components The components its page composes, read from its source on first use; empty when the source cannot be read.
15
16
  */
16
17
  /**
17
18
  * A component the project can use, as the ranker reads it.
18
19
  * @typedef {object} ComponentWords
19
20
  * @property {string} name The component's name, e.g. `DateRangeInput`.
20
21
  * @property {string[]} keywords The keywords its own doc declares.
22
+ * @property {string} [category] The category its own doc files it under,
23
+ * e.g. `Table & List`.
21
24
  */
22
25
  /**
23
26
  * Every ready page template the project can scaffold, in discovery order. This
@@ -158,6 +161,10 @@ export type PageTemplate = {
158
161
  * Absolute path to the template source file on disk.
159
162
  */
160
163
  filePath: string;
164
+ /**
165
+ * The components its page composes, read from its source on first use; empty when the source cannot be read.
166
+ */
167
+ components: string[];
161
168
  };
162
169
  /**
163
170
  * A component the project can use, as the ranker reads it.
@@ -171,6 +178,11 @@ export type ComponentWords = {
171
178
  * The keywords its own doc declares.
172
179
  */
173
180
  keywords: string[];
181
+ /**
182
+ * The category its own doc files it under,
183
+ * e.g. `Table & List`.
184
+ */
185
+ category?: string | undefined;
174
186
  };
175
187
  /**
176
188
  * A block the kit can name, as search names a block result.
@@ -28,6 +28,8 @@ import {componentKeywords} from '../search/search.mjs';
28
28
  import {findCoreDir, requireCoreDir} from '../../foundation/fs/paths.mjs';
29
29
  import {persistedDerived} from '../../foundation/fs/gather-cache.mjs';
30
30
  import {analyzeTemplateNeeds} from '../../foundation/discovery/template-needs.mjs';
31
+ import {extractComponents} from '../../foundation/discovery/template-adapter.mjs';
32
+ import {isWordModel} from './kit/word-model.mjs';
31
33
 
32
34
  /**
33
35
  * Runs one build with a single directory listing per path: the kit resolves
@@ -47,6 +49,7 @@ export {withListingCache} from '../../foundation/fs/listing-cache.mjs';
47
49
  * @property {string} category The template's own `Family - Variant` label; empty when it declares none.
48
50
  * @property {string[]} keywords The ideas the page serves, as its own descriptor names them; empty when it declares none.
49
51
  * @property {string} filePath Absolute path to the template source file on disk.
52
+ * @property {string[]} components The components its page composes, read from its source on first use; empty when the source cannot be read.
50
53
  */
51
54
 
52
55
  /**
@@ -54,6 +57,8 @@ export {withListingCache} from '../../foundation/fs/listing-cache.mjs';
54
57
  * @typedef {object} ComponentWords
55
58
  * @property {string} name The component's name, e.g. `DateRangeInput`.
56
59
  * @property {string[]} keywords The keywords its own doc declares.
60
+ * @property {string} [category] The category its own doc files it under,
61
+ * e.g. `Table & List`.
57
62
  */
58
63
 
59
64
  /**
@@ -99,18 +104,23 @@ export async function loadTemplates(cwd) {
99
104
  }
100
105
  const pages = templates
101
106
  .filter(t => t.type === 'page' && t.isReady !== false)
102
- .map(t => ({
103
- name: t.dirName,
104
- displayName: t.displayName || t.name,
105
- description: t.description || '',
106
- package: t.package ?? '@astryxdesign/core',
107
- category: t.category || '',
108
- keywords: t.keywords ?? [],
109
- filePath: t.filePath,
110
- // The id `template()` resolves back to this entry: an active replacement
111
- // owns the Core id it names, so that id selects it, not its own.
112
- command: `astryx template ${t.replaces ?? t.dirName} --type page`,
113
- }));
107
+ .map(t =>
108
+ withComponents(
109
+ {
110
+ name: t.dirName,
111
+ displayName: t.displayName || t.name,
112
+ description: t.description || '',
113
+ package: t.package ?? '@astryxdesign/core',
114
+ category: t.category || '',
115
+ keywords: t.keywords ?? [],
116
+ filePath: t.filePath,
117
+ // The id `template()` resolves back to this entry: an active
118
+ // replacement owns the Core id it names, so that id selects it.
119
+ command: `astryx template ${t.replaces ?? t.dirName} --type page`,
120
+ },
121
+ t.filePath,
122
+ ),
123
+ );
114
124
  const blocks = templates
115
125
  .filter(t => t.type === 'block')
116
126
  .map(t => ({
@@ -261,28 +271,7 @@ export function loadBlockPicker() {
261
271
  */
262
272
  export function isWeightsFile(file) {
263
273
  const n = Array.isArray(file?.candidates) ? file.candidates.length : 0;
264
- return (
265
- n > 0 &&
266
- Array.isArray(file.tables) &&
267
- file.tables.length > 0 &&
268
- file.tables.every(
269
- (/** @type {any} */ t) =>
270
- Array.isArray(t?.words) &&
271
- Array.isArray(t.rows) &&
272
- t.rows.length === t.words.length &&
273
- t.rows.every(
274
- (/** @type {any} */ r) => typeof r === 'string' && r.length === n,
275
- ) &&
276
- Array.isArray(t.bias) &&
277
- t.bias.length === n &&
278
- t.bias.every((/** @type {any} */ b) => Number.isFinite(b)) &&
279
- Number.isFinite(t.clip) &&
280
- Number.isFinite(t.step),
281
- ) &&
282
- Array.isArray(file.blend) &&
283
- file.blend.length === 3 * (file.tables.length + 1) + 1 &&
284
- file.blend.every((/** @type {any} */ x) => Number.isFinite(x))
285
- );
274
+ return isWordModel(file, n);
286
275
  }
287
276
 
288
277
  /** The ranking coefficients the picker reads. */
@@ -362,3 +351,31 @@ export function templateSetupNotes(template, cwd) {
362
351
  export function requireBuildCoreDir(cwd) {
363
352
  return requireCoreDir(cwd);
364
353
  }
354
+
355
+ /**
356
+ * Adds a lazy, non-enumerable `components` getter to a page entry: the page's
357
+ * source is read and parsed only when a caller reads it, once, so loading the
358
+ * catalog stays cheap and the entry's own fields are unchanged.
359
+ * @template {object} T
360
+ * @param {T} entry
361
+ * @param {string | undefined} filePath
362
+ * @returns {T & {readonly components: string[]}}
363
+ */
364
+ function withComponents(entry, filePath) {
365
+ /** @type {string[] | undefined} */
366
+ let components;
367
+ return /** @type {T & {readonly components: string[]}} */ (
368
+ Object.defineProperty(entry, 'components', {
369
+ get() {
370
+ if (components === undefined) {
371
+ try {
372
+ components = filePath ? extractComponents(filePath) : [];
373
+ } catch {
374
+ components = [];
375
+ }
376
+ }
377
+ return components;
378
+ },
379
+ })
380
+ );
381
+ }
@@ -47,17 +47,19 @@ export function requestSideOf(request: string, weights: BlockPickerWeights): {
47
47
  /**
48
48
  * The picker's match of a request to a docs text: their projections' dot
49
49
  * product plus the lexical weight times their plain overlap (the cosine of
50
- * their word vectors). Build's ranking also reads the overlap alone.
51
- * @param {{vector: Map<number, number>, projected: Float64Array}} request
52
- * @param {{vector: Map<number, number>, projected: Float64Array}} doc
50
+ * their word vectors). The vectors are keyed by vocabulary index (search's
51
+ * fit) or by word (the block picker's overlap, which also counts single
52
+ * words outside the vocabulary).
53
+ * @param {{vector: Map<number | string, number>, projected: Float64Array}} request
54
+ * @param {{vector: Map<number | string, number>, projected: Float64Array}} doc
53
55
  * @param {BlockPickerWeights} weights
54
56
  * @returns {{match: number, overlap: number}}
55
57
  */
56
58
  export function matchOf(request: {
57
- vector: Map<number, number>;
59
+ vector: Map<number | string, number>;
58
60
  projected: Float64Array;
59
61
  }, doc: {
60
- vector: Map<number, number>;
62
+ vector: Map<number | string, number>;
61
63
  projected: Float64Array;
62
64
  }, weights: BlockPickerWeights): {
63
65
  match: number;
@@ -27,7 +27,11 @@
27
27
  * request's vector through the request matrix, against the docs' vector
28
28
  * through the doc matrix, plus the lexical weight times their plain overlap
29
29
  * (cosine), so a block the weights were never fitted with, such as a new one,
30
- * is scored from its docs the same way. The candidates are the best matches,
30
+ * is scored from its docs the same way. The plain overlap also counts single
31
+ * words outside the vocabulary the matrices were fitted with (such a word
32
+ * weighs as much as the vocabulary's rarest word), so a newer block's own
33
+ * words still tie it to a request that uses them. The
34
+ * candidates are the best matches,
31
35
  * build's own blocks, search's first results, and the best plain overlaps.
32
36
  * Each candidate's final score adds the ranking coefficients times: its match
33
37
  * relative to the best, its place among the matches, its lead over the
@@ -197,10 +201,42 @@ function vectorOf(terms, d) {
197
201
  return v;
198
202
  }
199
203
 
204
+ /**
205
+ * A text's sparse unit vector over its words, for the plain overlap:
206
+ * (1 + ln count) x idf. A single word outside the vocabulary weighs as much
207
+ * as the vocabulary's rarest word (no fitted text used it often enough to
208
+ * keep). It counts only when `known` has it: a request word no block's docs
209
+ * use cannot tie the request to any block. A word pair counts only when the
210
+ * vocabulary has it.
211
+ * @param {string[]} terms
212
+ * @param {{index: Map<string, number>, idf: Float64Array, rarest: number}} d
213
+ * @param {Set<string>} [known] the words outside the vocabulary that count; all when absent
214
+ * @returns {Map<string, number>}
215
+ */
216
+ function wordVectorOf(terms, d, known) {
217
+ /** @type {Map<string, number>} */
218
+ const counts = new Map();
219
+ for (const t of terms) counts.set(t, (counts.get(t) ?? 0) + 1);
220
+ /** @type {Map<string, number>} */
221
+ const v = new Map();
222
+ let sq = 0;
223
+ for (const [t, c] of counts) {
224
+ const i = d.index.get(t);
225
+ if (i === undefined && (t.includes('_') || (known && !known.has(t))))
226
+ continue;
227
+ const x = (1 + Math.log(c)) * (i === undefined ? d.rarest : d.idf[i]);
228
+ v.set(t, x);
229
+ sq += x * x;
230
+ }
231
+ const norm = Math.sqrt(sq) || 1;
232
+ for (const [t, x] of v) v.set(t, x / norm);
233
+ return v;
234
+ }
235
+
200
236
  /**
201
237
  * The vocabulary index and idf, read once per weights object, and each matrix
202
238
  * row decoded when a side first uses it.
203
- * @type {WeakMap<BlockPickerWeights, {index: Map<string, number>, idf: Float64Array, rows: Map<string, Int8Array>}>}
239
+ * @type {WeakMap<BlockPickerWeights, {index: Map<string, number>, idf: Float64Array, rarest: number, rows: Map<string, Int8Array>}>}
204
240
  */
205
241
  const vocabularies = new WeakMap();
206
242
 
@@ -208,9 +244,11 @@ const vocabularies = new WeakMap();
208
244
  function vocabularyOf(weights) {
209
245
  let v = vocabularies.get(weights);
210
246
  if (!v) {
247
+ const idf = Float64Array.from(weights.idf, x => x / 1024);
211
248
  v = {
212
249
  index: new Map(weights.vocab.map((w, i) => [w, i])),
213
- idf: Float64Array.from(weights.idf, x => x / 1024),
250
+ idf,
251
+ rarest: idf.reduce((a, x) => Math.max(a, x), 0),
214
252
  rows: new Map(),
215
253
  };
216
254
  vocabularies.set(weights, v);
@@ -292,9 +330,11 @@ export function requestSideOf(request, weights) {
292
330
  /**
293
331
  * The picker's match of a request to a docs text: their projections' dot
294
332
  * product plus the lexical weight times their plain overlap (the cosine of
295
- * their word vectors). Build's ranking also reads the overlap alone.
296
- * @param {{vector: Map<number, number>, projected: Float64Array}} request
297
- * @param {{vector: Map<number, number>, projected: Float64Array}} doc
333
+ * their word vectors). The vectors are keyed by vocabulary index (search's
334
+ * fit) or by word (the block picker's overlap, which also counts single
335
+ * words outside the vocabulary).
336
+ * @param {{vector: Map<number | string, number>, projected: Float64Array}} request
337
+ * @param {{vector: Map<number | string, number>, projected: Float64Array}} doc
298
338
  * @param {BlockPickerWeights} weights
299
339
  * @returns {{match: number, overlap: number}}
300
340
  */
@@ -325,7 +365,7 @@ function componentOf(block, componentNames) {
325
365
  /**
326
366
  * The catalog, read once per weights and catalog contents: each block's
327
367
  * component, docs vector and projection, and each component's name phrases.
328
- * @type {WeakMap<BlockPickerWeights, {key: string, blocks: Map<string, {component: string, vector: Map<number, number>, projected: Float64Array}>, phrases: Map<string, [string[], number][]>}>}
368
+ * @type {WeakMap<BlockPickerWeights, {key: string, blocks: Map<string, {component: string, vector: Map<number, number>, projected: Float64Array, words: Map<string, number>}>, phrases: Map<string, [string[], number][]>}>}
329
369
  */
330
370
  const catalogs = new WeakMap();
331
371
 
@@ -357,19 +397,41 @@ function readCatalog(catalog, components, weights, keep) {
357
397
  return read;
358
398
  }
359
399
 
400
+ /**
401
+ * Every word the catalog's block docs use, per read catalog.
402
+ * @type {WeakMap<object, Set<string>>}
403
+ */
404
+ const docWords = new WeakMap();
405
+
406
+ /**
407
+ * @param {{blocks: Map<string, {words: Map<string, number>}>}} cat
408
+ * @returns {Set<string>}
409
+ */
410
+ function docWordsOf(cat) {
411
+ let words = docWords.get(cat);
412
+ if (!words) {
413
+ words = new Set();
414
+ for (const b of cat.blocks.values())
415
+ for (const t of b.words.keys()) words.add(t);
416
+ docWords.set(cat, words);
417
+ }
418
+ return words;
419
+ }
420
+
360
421
  /**
361
422
  * readCatalog's value, worked out.
362
423
  * @param {string} key
363
424
  * @param {CatalogBlock[]} catalog
364
425
  * @param {CatalogComponent[]} components
365
426
  * @param {BlockPickerWeights} weights
366
- * @returns {{key: string, blocks: Map<string, {component: string, vector: Map<number, number>, projected: Float64Array}>, phrases: Map<string, [string[], number][]>}}
427
+ * @returns {{key: string, blocks: Map<string, {component: string, vector: Map<number, number>, projected: Float64Array, words: Map<string, number>}>, phrases: Map<string, [string[], number][]>}}
367
428
  */
368
429
  function computeCatalog(key, catalog, components, weights) {
369
430
  const names = components.map(c => c.name).sort((a, b) => b.length - a.length);
370
431
  const keywords = new Map(components.map(c => [c.name, c.keywords ?? []]));
371
- /** @type {Map<string, {component: string, vector: Map<number, number>, projected: Float64Array}>} */
432
+ /** @type {Map<string, {component: string, vector: Map<number, number>, projected: Float64Array, words: Map<string, number>}>} */
372
433
  const blocks = new Map();
434
+ const vocabulary = vocabularyOf(weights);
373
435
  for (const b of catalog) {
374
436
  if (blocks.has(b.name)) continue;
375
437
  const component = componentOf(b, names);
@@ -380,7 +442,11 @@ function computeCatalog(key, catalog, components, weights) {
380
442
  wordsOf(component).join(' '),
381
443
  (keywords.get(component) ?? []).join(' '),
382
444
  ].join(' ');
383
- blocks.set(b.name, {component, ...docSideOf(text, weights)});
445
+ blocks.set(b.name, {
446
+ component,
447
+ ...docSideOf(text, weights),
448
+ words: wordVectorOf(termsOf(text), vocabulary),
449
+ });
384
450
  }
385
451
  // A component is named by its own words, or by a keyword at most three
386
452
  // components share (weighted by how few share it).
@@ -412,7 +478,8 @@ function computeCatalog(key, catalog, components, weights) {
412
478
  const CATALOG_CODEC = {
413
479
  /**
414
480
  * What decode can get wrong in a read-back catalog: its key, each block's
415
- * component, and projections of one width with finite numbers.
481
+ * component and word vector, and projections of one width with finite
482
+ * numbers.
416
483
  * @param {any} read
417
484
  */
418
485
  valid: read => {
@@ -422,6 +489,7 @@ const CATALOG_CODEC = {
422
489
  return blocks.every(
423
490
  (/** @type {any} */ b) =>
424
491
  typeof b.component === 'string' &&
492
+ b.words instanceof Map &&
425
493
  b.projected.length > 0 &&
426
494
  b.projected.length === width &&
427
495
  [...b.projected].every(Number.isFinite),
@@ -435,6 +503,7 @@ const CATALOG_CODEC = {
435
503
  b.component,
436
504
  [...b.vector],
437
505
  [...b.projected],
506
+ [...b.words],
438
507
  ]),
439
508
  phrases: [...read.phrases],
440
509
  }),
@@ -447,11 +516,12 @@ const CATALOG_CODEC = {
447
516
  blocks: new Map(
448
517
  stored.blocks.map(
449
518
  (
450
- /** @type {[string, string, [number, number][], number[]]} */ [
519
+ /** @type {[string, string, [number, number][], number[], [string, number][]]} */ [
451
520
  name,
452
521
  component,
453
522
  vector,
454
523
  projected,
524
+ words,
455
525
  ],
456
526
  ) => [
457
527
  name,
@@ -459,6 +529,7 @@ const CATALOG_CODEC = {
459
529
  component,
460
530
  vector: new Map(vector),
461
531
  projected: Float64Array.from(projected),
532
+ words: new Map(words),
462
533
  },
463
534
  ],
464
535
  ),
@@ -540,10 +611,22 @@ export function pickBlocks(request, signals, weights, keep) {
540
611
  if (own.length === 0) return {names: [], entries};
541
612
  const cat = readCatalog(signals.catalog, signals.components, weights, keep);
542
613
  const side = requestSideOf(request, weights);
614
+ const words = wordVectorOf(
615
+ termsOf(request),
616
+ vocabularyOf(weights),
617
+ docWordsOf(cat),
618
+ );
543
619
  /** @type {Map<string, {match: number, overlap: number}>} */
544
620
  const scored = new Map();
545
621
  for (const [name, b] of cat.blocks)
546
- scored.set(name, matchOf(side, b, weights));
622
+ scored.set(
623
+ name,
624
+ matchOf(
625
+ {vector: words, projected: side.projected},
626
+ {vector: b.words, projected: b.projected},
627
+ weights,
628
+ ),
629
+ );
547
630
  const get = (/** @type {string} */ b) =>
548
631
  scored.get(b) ?? {match: -Infinity, overlap: 0};
549
632
  const ranked = [...scored.keys()].sort((a, b) => get(b).match - get(a).match);
@@ -593,8 +676,8 @@ export function pickBlocks(request, signals, weights, keep) {
593
676
  });
594
677
  final.sort((a, b) => b.score - a.score || a.pos - b.pos);
595
678
  const foreign = new Set(signals.foreign);
596
- const words = wordsOf(request);
597
- const keeps = own.map(b => foreign.has(b) || writesName(words, b));
679
+ const requestWords = wordsOf(request);
680
+ const keeps = own.map(b => foreign.has(b) || writesName(requestWords, b));
598
681
  const kept = new Set(own.filter((_, k) => keeps[k]));
599
682
  const order = [
600
683
  ...final.map(x => x.b).filter(b => !kept.has(b) && !foreign.has(b)),
@@ -626,7 +709,7 @@ export function pickBlocks(request, signals, weights, keep) {
626
709
  name,
627
710
  package: block.package ?? '',
628
711
  score: Math.max(1, Math.round(100 * Math.exp(x.score - max))),
629
- reason: reasonFor(request, side, cat.blocks.get(name), weights),
712
+ reason: reasonFor(request, side, words, cat.blocks.get(name), weights),
630
713
  description: block.description ?? '',
631
714
  displayName: block.displayName,
632
715
  kind: 'block',
@@ -640,10 +723,11 @@ export function pickBlocks(request, signals, weights, keep) {
640
723
  * Why a block fits: the request words that tie it to its docs most.
641
724
  * @param {string} request
642
725
  * @param {{vector: Map<number, number>, projected: Float64Array}} side the request's side
643
- * @param {{vector: Map<number, number>, projected: Float64Array} | undefined} block
726
+ * @param {Map<string, number>} words the request's word vector for the plain overlap
727
+ * @param {{projected: Float64Array, words: Map<string, number>} | undefined} block
644
728
  * @param {BlockPickerWeights} weights
645
729
  */
646
- function reasonFor(request, side, block, weights) {
730
+ function reasonFor(request, side, words, block, weights) {
647
731
  if (!block) return 'fits by meaning';
648
732
  const raw =
649
733
  String(request)
@@ -653,17 +737,20 @@ function reasonFor(request, side, block, weights) {
653
737
  const wordOf = new Map();
654
738
  for (const w of raw)
655
739
  if (!STOP.has(w) && !wordOf.has(stemOf(w))) wordOf.set(stemOf(w), w);
740
+ const {index} = vocabularyOf(weights);
656
741
  /** @type {[string, number][]} */
657
742
  const parts = [];
658
- for (const [i, x] of side.vector) {
659
- const term = weights.vocab[i];
743
+ for (const [term, x] of words) {
660
744
  if (term.includes('_')) continue;
661
- const row = rowOf(weights, 'request', i);
662
- let s = 0;
663
- for (let k = 0; k < weights.dims; k++) s += row[k] * block.projected[k];
664
- s =
665
- x * s * weights.requestScale +
666
- weights.lexical * x * (block.vector.get(i) ?? 0);
745
+ let s = weights.lexical * x * (block.words.get(term) ?? 0);
746
+ const i = index.get(term);
747
+ const v = i === undefined ? undefined : side.vector.get(i);
748
+ if (i !== undefined && v !== undefined) {
749
+ const row = rowOf(weights, 'request', i);
750
+ let dot = 0;
751
+ for (let k = 0; k < weights.dims; k++) dot += row[k] * block.projected[k];
752
+ s += v * dot * weights.requestScale;
753
+ }
667
754
  if (s > 0) parts.push([wordOf.get(term) ?? term, s]);
668
755
  }
669
756
  parts.sort((a, b) => b[1] - a[1]);
@@ -19,8 +19,9 @@ export const doc = {
19
19
  'The "build a page" entry point. Called with no query it returns the ' +
20
20
  'how-to-build-a-page playbook as data: the workflow steps with their ' +
21
21
  'commands, the on-system rules, and related lookups. Called with a query it names the page template to ' +
22
- 'START from (always one: the page template a ranker built for long descriptions puts first; for a part ' +
23
- 'of a page, the page it names; else the app shell) and the next two templates, ' +
22
+ "START from (always one: for a whole page, the template its page-pick model chooses from the page ranker's list and its own word tables, or the app shell when its word weights call the shell; for a part " +
23
+ 'of a page, the page it names; else the app shell, unless the idea reads as a whole page, which starts ' +
24
+ 'from the closest page template) and the next two templates, ' +
24
25
  'and the unified search grouped around it: the other close page templates, drop-in blocks, and ' +
25
26
  'idea-specific components/hooks, plus the always-on frame + foundation. A template carries the page ' +
26
27
  'frame and spacing, so the kit never recommends composing a page from components.',
@@ -64,7 +65,7 @@ export const doc = {
64
65
  {
65
66
  type: 'build.kit',
66
67
  description:
67
- "The page template to start from and the kit around it: the echoed query, hasResults/matchCount/directMatch fields, `start` (the template to scaffold, the `template <id> --type page <path>` command that selects it, whether the page ranker's pick is also search's direct match, the closest page, or the fallback app shell, the ranker's next two `alternatives`, and optional `notes` — setup notes naming what the template needs that the project lacks, such as missing packages or a missing StyleX compiler), search's closest page templates (≤3), drop-in block patterns (≤5), idea-specific components/hooks (≤6), and the always-on frame + foundation component-name arrays. Carries `hint` only when the kit came back thin — what to try instead, so a caller does not read a near-empty kit as \"the package has nothing\".",
68
+ 'The page template to start from and the kit around it: the echoed query, hasResults/matchCount/directMatch fields, `start` (the template to scaffold, the `template <id> --type page <path>` command that selects it, whether the start is also search\'s direct match, the closest page, or the fallback app shell, the next two `alternatives` in the order the start is chosen from, and optional `notes` — setup notes naming what the template needs that the project lacks, such as missing packages or a missing StyleX compiler), search\'s closest page templates (≤3), drop-in block patterns (≤5), idea-specific components/hooks (≤6), and the always-on frame + foundation component-name arrays. Carries `hint` only when the kit came back thin — what to try instead, so a caller does not read a near-empty kit as "the package has nothing".',
68
69
  },
69
70
  ],
70
71
  throws: [
@@ -69,7 +69,7 @@ export type BuildStart = {
69
69
  */
70
70
  command: string;
71
71
  /**
72
- * Why this template. The page ranker picks every start: it weighs each matched word by how rare it is among page templates, favors the family the idea's head names and the container it names ("in a modal"), and discounts words that only modify another. `direct` when its pick is also search's direct match (`directMatch`); `closest` when it is not; `fallback` when no template has the evidence to lead and the page starts from the app shell.
72
+ * Why this template. The page ranker orders the page templates: it weighs each matched word by how rare it is among page templates, favors the family the idea's head names and the container it names ("in a modal"), and discounts words that only modify another. For a part or an edit, the start is where the ranker's placement rules put it; for a whole page, checked-in word weights decide page or app shell and a page-pick model chooses the page from the ranker's list and its own word tables, so the start can differ from the ranker's first template. `direct` when the start is also search's direct match (`directMatch`); `closest` when it is not; `fallback` when the page starts from the app shell.
73
73
  */
74
74
  basis: "direct" | "closest" | "fallback";
75
75
  /**
@@ -77,7 +77,7 @@ export type BuildStart = {
77
77
  */
78
78
  reason: string;
79
79
  /**
80
- * The ranker's next closest page templates (≤2), for when the start's layout is wrong.
80
+ * The next closest page templates (≤2), for when the start's layout is wrong: for a whole page in the page-pick model's order, else in the ranker's.
81
81
  */
82
82
  alternatives: BuildAlternative[];
83
83
  /**
@@ -44,9 +44,9 @@
44
44
  * @property {string} description What the page is: its layout and the ideas it serves.
45
45
  * @property {string} package The npm package that owns this template.
46
46
  * @property {string} command The scaffold command that selects exactly this template, `astryx template <id> --type page <path>`: `<id>` is the Core id an integration replacement stands in for, else the template's own id, `<path>` is a placeholder for the file or folder to write the template to, and the `astryx` prefix is for the caller to replace with its own invocation.
47
- * @property {'direct' | 'closest' | 'fallback'} basis Why this template. The page ranker picks every start: it weighs each matched word by how rare it is among page templates, favors the family the idea's head names and the container it names ("in a modal"), and discounts words that only modify another. `direct` when its pick is also search's direct match (`directMatch`); `closest` when it is not; `fallback` when no template has the evidence to lead and the page starts from the app shell.
47
+ * @property {'direct' | 'closest' | 'fallback'} basis Why this template. The page ranker orders the page templates: it weighs each matched word by how rare it is among page templates, favors the family the idea's head names and the container it names ("in a modal"), and discounts words that only modify another. For a part or an edit, the start is where the ranker's placement rules put it; for a whole page, checked-in word weights decide page or app shell and a page-pick model chooses the page from the ranker's list and its own word tables, so the start can differ from the ranker's first template. `direct` when the start is also search's direct match (`directMatch`); `closest` when it is not; `fallback` when the page starts from the app shell.
48
48
  * @property {string} reason One sentence saying the same as `basis`, for a reader.
49
- * @property {BuildAlternative[]} alternatives The ranker's next closest page templates (≤2), for when the start's layout is wrong.
49
+ * @property {BuildAlternative[]} alternatives The next closest page templates (≤2), for when the start's layout is wrong: for a whole page in the page-pick model's order, else in the ranker's.
50
50
  * @property {string[]} [notes] Setup notes: what the template needs that the project lacks (missing packages, missing StyleX compiler). Present only when the start template imports packages the project does not have or needs a StyleX compiler the project has not configured.
51
51
  */
52
52
 
@@ -75,7 +75,7 @@
75
75
  * @property {boolean} data.hasResults False when search returned nothing. The kit still names a template in `start`.
76
76
  * @property {number} data.matchCount Total ranked search matches for the query — counted before the search `limit`, the kit's score floors, and its per-group caps, so it is never a cap read back.
77
77
  * @property {boolean} data.directMatch True when the top page template is a confident direct match.
78
- * @property {BuildStart | null} data.start The page template to start from: the ranker's pick, else the app shell. Null only when the kit is narrowed to components or hooks (`type`), or when the project has no page template to offer.
78
+ * @property {BuildStart | null} data.start The page template to start from (see `BuildStart.basis`), else the app shell. Null only when the kit is narrowed to components or hooks (`type`), or when the project has no page template to offer.
79
79
  * @property {import('../search/search.type.mjs').SearchResultEntry[]} data.pages Closest page templates by search (≤3). Each entry's `command` carries `--skeleton` when `directMatch` is false, so it previews the layout; `start.command` is the scaffold.
80
80
  * @property {import('../search/search.type.mjs').SearchResultEntry[]} data.blocks Drop-in block patterns covering parts of the idea (≤5), best first. A block search returned keeps search's score and reason; any other block carries the block picker's relative score (100 for its best candidate, never below 1) and reason, so the two kinds of score are not comparable.
81
81
  * @property {import('../search/search.type.mjs').SearchResultEntry[]} data.domain Idea-specific components/hooks (≤6), excluding frame/foundation.
@@ -4,7 +4,8 @@
4
4
  /**
5
5
  * What an idea asks for (spec:AST-048/FR3): a whole `page`; a `part` of one,
6
6
  * when its head noun names one of the system's components and it lists fewer
7
- * than PAGE_PIECES pieces; or an `edit` of a page the builder already has.
7
+ * than PAGE_PIECES pieces or only that component's contents; or an `edit` of a
8
+ * page the builder already has.
8
9
  *
9
10
  * @param {string} query
10
11
  * @param {PageTemplate[]} pages