@astryxdesign/cli 0.7.16 → 0.7.17-canary.g49a475f

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 (354) 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.d.mts +4 -2
  13. package/api/build/kit/rank.mjs +125 -24
  14. package/api/build/kit/start.d.mts +5 -4
  15. package/api/build/kit/start.mjs +12 -8
  16. package/api/build/kit/weights.d.mts +39 -3
  17. package/api/build/kit/weights.json +1 -1
  18. package/api/build/kit/weights.mjs +340 -43
  19. package/api/build/kit/word-model.d.mts +23 -0
  20. package/api/build/kit/word-model.mjs +46 -0
  21. package/api/build/kit/words.d.mts +48 -0
  22. package/api/build/kit/words.mjs +90 -1
  23. package/api/component/__fixtures__/resolutions/modules.txt +4 -5
  24. package/api/component/list/list.d.mts +1 -1
  25. package/api/component/list/list.mjs +48 -6
  26. package/api/discover/_adapter.d.mts +1 -1
  27. package/api/discover/search/search.mjs +3 -2
  28. package/api/docs/_adapter.d.mts +26 -2
  29. package/api/docs/_adapter.mjs +219 -6
  30. package/api/docs/docs.d.mts +3 -0
  31. package/api/docs/docs.doc.mjs +7 -1
  32. package/api/docs/docs.mjs +12 -0
  33. package/api/docs/docs.type.d.mts +5 -0
  34. package/api/docs/docs.type.mjs +2 -0
  35. package/api/docs/node/node.mjs +1 -1
  36. package/api/doctor/_adapter.d.mts +27 -5
  37. package/api/doctor/_adapter.mjs +83 -10
  38. package/api/doctor/built-checks.mjs +40 -14
  39. package/api/doctor/doctor.d.mts +4 -3
  40. package/api/doctor/doctor.mjs +14 -7
  41. package/api/doctor/theme-checks.mjs +121 -17
  42. package/api/icon/_records.mjs +2 -1
  43. package/api/index.d.mts +2 -0
  44. package/api/index.mjs +2 -0
  45. package/api/integration/_adapter.d.mts +44 -0
  46. package/api/integration/_adapter.mjs +77 -1
  47. package/api/integration/authoring-checks.mjs +6 -6
  48. package/api/integration/example-scope.d.mts +14 -0
  49. package/api/integration/example-scope.mjs +44 -0
  50. package/api/integration/example-scope.type.d.mts +29 -0
  51. package/api/integration/example-scope.type.mjs +25 -0
  52. package/api/integration/integrationExampleScope.doc.d.mts +11 -0
  53. package/api/integration/integrationExampleScope.doc.mjs +59 -0
  54. package/api/integration/validate-integration.mjs +19 -1
  55. package/api/integration/validate-integration.type.d.mts +9 -0
  56. package/api/integration/validate-integration.type.mjs +1 -1
  57. package/api/integration/validateIntegration.doc.mjs +1 -1
  58. package/api/render/_adapter.mjs +591 -195
  59. package/api/render/render.doc.mjs +11 -3
  60. package/api/render/render.type.d.mts +52 -0
  61. package/api/render/render.type.mjs +31 -1
  62. package/api/search/ORDERING.md +1 -1
  63. package/api/search/_adapter.d.mts +9 -0
  64. package/api/search/_adapter.mjs +85 -0
  65. package/api/search/_candidate-score.mjs +51 -32
  66. package/api/search/_fit-order.mjs +3 -3
  67. package/api/search/_gather-components.d.mts +3 -2
  68. package/api/search/_gather-components.mjs +12 -3
  69. package/api/search/_lexical.d.mts +5 -0
  70. package/api/search/_lexical.mjs +8 -2
  71. package/api/search/_result.d.mts +11 -9
  72. package/api/search/_result.mjs +4 -4
  73. package/api/search/_score.d.mts +6 -1
  74. package/api/search/_score.mjs +15 -3
  75. package/api/search/search-index.mjs +7 -1
  76. package/api/search/search.d.mts +1 -1
  77. package/api/theme/_adapter.mjs +12 -1
  78. package/api/theme/build/build.d.mts +75 -0
  79. package/api/theme/build/build.mjs +243 -58
  80. package/api/theme/build/font-warning.d.mts +7 -0
  81. package/api/theme/build/font-warning.mjs +17 -0
  82. package/api/theme/theme.type.d.mts +10 -0
  83. package/api/theme/theme.type.mjs +7 -1
  84. package/api/theme-edit/_adapter.d.mts +63 -2
  85. package/api/theme-edit/_adapter.mjs +771 -57
  86. package/api/theme-edit/_check.d.mts +40 -22
  87. package/api/theme-edit/_check.mjs +2029 -336
  88. package/api/theme-edit/_color.d.mts +10 -0
  89. package/api/theme-edit/_color.mjs +49 -1
  90. package/api/theme-edit/_compiler.mjs +9 -0
  91. package/api/theme-edit/_context.d.mts +3 -3
  92. package/api/theme-edit/_context.mjs +111 -48
  93. package/api/theme-edit/_css.d.mts +14 -0
  94. package/api/theme-edit/_css.mjs +46 -1
  95. package/api/theme-edit/_edit.d.mts +18 -4
  96. package/api/theme-edit/_edit.mjs +1685 -155
  97. package/api/theme-edit/_how-commands.d.mts +65 -0
  98. package/api/theme-edit/_how-commands.mjs +633 -1
  99. package/api/theme-edit/_how-question.d.mts +84 -0
  100. package/api/theme-edit/_how-question.mjs +5124 -281
  101. package/api/theme-edit/_how.mjs +140 -29
  102. package/api/theme-edit/_marks.d.mts +31 -5
  103. package/api/theme-edit/_marks.mjs +57 -5
  104. package/api/theme-edit/_name-rule.d.mts +11 -0
  105. package/api/theme-edit/_name-rule.mjs +12 -0
  106. package/api/theme-edit/_normal.d.mts +257 -0
  107. package/api/theme-edit/_normal.mjs +1252 -0
  108. package/api/theme-edit/_palette.mjs +10 -4
  109. package/api/theme-edit/_parts.d.mts +10 -1
  110. package/api/theme-edit/_parts.mjs +179 -3
  111. package/api/theme-edit/_preview-app.d.mts +7 -1
  112. package/api/theme-edit/_preview-app.mjs +515 -148
  113. package/api/theme-edit/_preview.d.mts +100 -14
  114. package/api/theme-edit/_preview.mjs +549 -137
  115. package/api/theme-edit/_settings.d.mts +347 -30
  116. package/api/theme-edit/_settings.mjs +2971 -327
  117. package/api/theme-edit/_tables.d.mts +6 -0
  118. package/api/theme-edit/_tables.mjs +44 -1
  119. package/api/theme-edit/_vet.d.mts +18 -0
  120. package/api/theme-edit/_vet.mjs +32 -0
  121. package/api/theme-edit/theme-edit.type.d.mts +10 -1
  122. package/api/theme-edit/theme-edit.type.mjs +4 -1
  123. package/api/theme-edit/themeEditHow.doc.mjs +1 -1
  124. package/api/theme-edit/themeEditNew.doc.d.mts +0 -1
  125. package/api/theme-edit/themeEditNew.doc.mjs +7 -4
  126. package/api/theme-edit/themeEditPreviewApp.doc.mjs +3 -3
  127. package/api/theme-edit/themeEditPreviewRemove.doc.mjs +2 -2
  128. package/api/upgrade/run/run.mjs +4 -3
  129. package/assets/codemods/integration-discovery.mjs +2 -1
  130. package/assets/codemods/run-codemod.mjs +87 -7
  131. package/assets/codemods/transforms/next/index.mjs +11 -1
  132. package/assets/codemods/transforms/next/migrate-item-swipe-actions-to-swipe.mjs +394 -0
  133. package/assets/component-list.generated.json +1 -0
  134. package/assets/docs/author-a-theme.doc.mjs +1 -0
  135. package/assets/docs/theme.doc.dense.mjs +2 -2
  136. package/assets/docs/theme.doc.mjs +1 -1
  137. package/assets/docs/tree/check-your-docs.doc.mjs +1 -1
  138. package/assets/docs/tree/checks.doc.mjs +1 -1
  139. package/assets/docs/tree/cli-command.doc.mjs +2 -3
  140. package/assets/docs/tree/render-pages.doc.mjs +44 -3
  141. package/assets/docs/tree/single-component.doc.mjs +4 -0
  142. package/assets/docs/tree/template-doc-overview.doc.mjs +1 -1
  143. package/assets/docs/tree/test-in-an-app.doc.mjs +1 -1
  144. package/assets/docs/use-a-theme.doc.mjs +1 -1
  145. package/assets/docs.generated.json +2 -2
  146. package/assets/search-catalog.generated.json +2 -0
  147. package/assets/self-audit.generated.json +1 -1
  148. package/assets/templates/blocks/components/ChatComposerInput/useChatDictationHookUsage.doc.mjs +14 -0
  149. package/assets/templates/blocks/components/ChatComposerInput/useChatDictationHookUsage.tsx +38 -0
  150. package/assets/templates/blocks/components/Hooks/useContainerRevealHookUsage.tsx +2 -2
  151. package/assets/templates/blocks/components/SyntaxTheme/useSyntaxThemeHookUsage.doc.mjs +14 -0
  152. package/assets/templates/blocks/components/SyntaxTheme/useSyntaxThemeHookUsage.tsx +36 -0
  153. package/assets/templates/components.generated.json +1 -1
  154. package/assets/templates/pages/ai-chat/template.doc.mjs +5 -4
  155. package/assets/templates/pages/ai-chat-landing/template.doc.mjs +2 -1
  156. package/assets/templates/pages/blank/template.doc.mjs +1 -1
  157. package/assets/templates/pages/canvas-editor/template.doc.mjs +4 -2
  158. package/assets/templates/pages/centered-hero/template.doc.mjs +9 -1
  159. package/assets/templates/pages/classic-gallery/template.doc.mjs +1 -1
  160. package/assets/templates/pages/contact-form/template.doc.mjs +2 -1
  161. package/assets/templates/pages/dashboard/template.doc.mjs +3 -2
  162. package/assets/templates/pages/dashboard-alert-rail/template.doc.mjs +2 -1
  163. package/assets/templates/pages/dashboard-cohort-funnel/template.doc.mjs +2 -1
  164. package/assets/templates/pages/dashboard-composition/template.doc.mjs +2 -1
  165. package/assets/templates/pages/dashboard-progress/template.doc.mjs +6 -3
  166. package/assets/templates/pages/detail-page/template.doc.mjs +10 -3
  167. package/assets/templates/pages/documentation/template.doc.mjs +4 -1
  168. package/assets/templates/pages/documentation-design/template.doc.mjs +7 -1
  169. package/assets/templates/pages/documentation-technical/template.doc.mjs +7 -1
  170. package/assets/templates/pages/editor/template.doc.mjs +2 -8
  171. package/assets/templates/pages/file-explorer/template.doc.mjs +1 -1
  172. package/assets/templates/pages/form-two-column/template.doc.mjs +4 -3
  173. package/assets/templates/pages/form-wizard/template.doc.mjs +5 -3
  174. package/assets/templates/pages/gallery-hero/template.doc.mjs +4 -2
  175. package/assets/templates/pages/ide/page.tsx +24 -2
  176. package/assets/templates/pages/kanban-board/template.doc.mjs +1 -9
  177. package/assets/templates/pages/library/template.doc.mjs +4 -1
  178. package/assets/templates/pages/login/template.doc.mjs +2 -1
  179. package/assets/templates/pages/login-card/template.doc.mjs +2 -1
  180. package/assets/templates/pages/login-split/template.doc.mjs +2 -1
  181. package/assets/templates/pages/login-sso/template.doc.mjs +4 -2
  182. package/assets/templates/pages/mixed-gallery/template.doc.mjs +2 -1
  183. package/assets/templates/pages/product-detail/template.doc.mjs +4 -2
  184. package/assets/templates/pages/product-gallery/template.doc.mjs +2 -1
  185. package/assets/templates/pages/settings-dialog/template.doc.mjs +2 -1
  186. package/assets/templates/pages/settings-sidebar/template.doc.mjs +2 -1
  187. package/assets/templates/pages/shell-nav/template.doc.mjs +4 -2
  188. package/assets/templates/pages/shell-side-nav/template.doc.mjs +5 -3
  189. package/assets/templates/pages/shell-top-nav/template.doc.mjs +2 -1
  190. package/assets/templates/pages/side-gallery/template.doc.mjs +9 -1
  191. package/assets/templates/pages/table-filter/template.doc.mjs +9 -8
  192. package/assets/templates/pages/table-grouped/template.doc.mjs +4 -2
  193. package/assets/templates/pages/table-page/template.doc.mjs +5 -4
  194. package/assets/templates/pages/table-tree/template.doc.mjs +6 -3
  195. package/assets/templates/pages/theme-showcase/template.doc.mjs +2 -9
  196. package/assets/templates/pages/work-item-detail/template.doc.mjs +1 -0
  197. package/assets/theme.template.ts +6 -0
  198. package/authoring/debug/parse.d.mts +3 -3
  199. package/authoring/doctypes/_schema.d.mts +3 -3
  200. package/authoring/doctypes/command/command.doc.mjs +1 -1
  201. package/authoring/doctypes/component/categories.d.mts +37 -0
  202. package/authoring/doctypes/component/categories.mjs +54 -0
  203. package/authoring/doctypes/template/template.doc.mjs +1 -1
  204. package/authoring/doctypes/template/type.ts +9 -0
  205. package/authoring/example/example.doc.d.mts +12 -0
  206. package/authoring/example/example.doc.mjs +69 -0
  207. package/authoring/example/preview.d.mts +92 -0
  208. package/authoring/example/preview.mjs +994 -0
  209. package/authoring/example/type.ts +102 -0
  210. package/authoring/index.d.mts +1 -0
  211. package/authoring/index.d.ts +12 -0
  212. package/authoring/index.mjs +3 -1
  213. package/clients/cli/bin/astryx.mjs +6 -9
  214. package/clients/cli/build-id.generated.json +1 -1
  215. package/clients/cli/commands/component.doc.mjs +1 -1
  216. package/clients/cli/commands/component.mjs +22 -3
  217. package/clients/cli/commands/docs.doc.mjs +7 -1
  218. package/clients/cli/commands/docs.mjs +3 -1
  219. package/clients/cli/commands/doctor.mjs +32 -14
  220. package/clients/cli/commands/experimental/render.mjs +42 -1
  221. package/clients/cli/commands/experimental/theme.mjs +163 -28
  222. package/clients/cli/commands/experimental-render.doc.mjs +2 -2
  223. package/clients/cli/commands/experimental-theme-compile.doc.mjs +3 -3
  224. package/clients/cli/commands/experimental-theme-editor-how.doc.mjs +87 -1
  225. package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +10 -3
  226. package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +1 -1
  227. package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +1 -1
  228. package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +2 -2
  229. package/clients/cli/commands/experimental-theme-editor.doc.mjs +1 -1
  230. package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +1 -1
  231. package/clients/cli/commands/experimental-theme-preview-remove.doc.mjs +2 -2
  232. package/clients/cli/commands/experimental-theme-preview.doc.mjs +2 -1
  233. package/clients/cli/commands/experimental-theme.doc.mjs +5 -1
  234. package/clients/cli/commands/search.doc.mjs +2 -1
  235. package/clients/cli/commands/search.mjs +6 -1
  236. package/clients/cli/commands/template.mjs +4 -2
  237. package/clients/cli/commands/theme-build.doc.mjs +5 -1
  238. package/clients/cli/commands/theme.doc.mjs +1 -1
  239. package/clients/cli/commands/theme.mjs +209 -8
  240. package/clients/cli/commands/upgrade.mjs +42 -7
  241. package/clients/cli/index.mjs +1 -1
  242. package/clients/cli/lib/cli-error.mjs +2 -1
  243. package/clients/cli/lib/component-format.mjs +205 -98
  244. package/clients/cli/lib/hook-format.mjs +9 -19
  245. package/clients/cli/lib/json-shim.mjs +77 -21
  246. package/clients/cli/lib/manifest.mjs +3 -2
  247. package/clients/cli/manifest.generated.json +1 -1
  248. package/foundation/agent-docs/agent-docs.mjs +1 -1
  249. package/foundation/config/theme-state.d.mts +13 -1
  250. package/foundation/config/theme-state.mjs +47 -7
  251. package/foundation/discovery/authoring-self-docs.mjs +1 -0
  252. package/foundation/discovery/component-discovery.d.mts +11 -0
  253. package/foundation/discovery/component-discovery.mjs +56 -8
  254. package/foundation/discovery/component-replacement.mjs +130 -1
  255. package/foundation/discovery/copied-passages.mjs +2 -1
  256. package/foundation/discovery/doc-types.mjs +4 -3
  257. package/foundation/discovery/entry-name-files.d.mts +43 -0
  258. package/foundation/discovery/entry-name-files.mjs +264 -0
  259. package/foundation/discovery/hook-discovery.d.mts +8 -2
  260. package/foundation/discovery/hook-discovery.mjs +22 -8
  261. package/foundation/discovery/icon-definition-discovery.mjs +2 -1
  262. package/foundation/discovery/icon-set-checks.mjs +2 -1
  263. package/foundation/discovery/icon-set-discovery.mjs +2 -1
  264. package/foundation/discovery/integration-doc-files.mjs +2 -1
  265. package/foundation/discovery/package-exports.d.mts +10 -0
  266. package/foundation/discovery/package-exports.mjs +56 -3
  267. package/foundation/discovery/prop-drift.mjs +9 -9
  268. package/foundation/discovery/runner-allowlist.d.mts +1 -0
  269. package/foundation/discovery/runner-allowlist.mjs +2 -0
  270. package/foundation/discovery/stored-component-list.d.mts +43 -0
  271. package/foundation/discovery/stored-component-list.mjs +90 -0
  272. package/foundation/discovery/stored-search-catalog.d.mts +115 -0
  273. package/foundation/discovery/stored-search-catalog.mjs +297 -0
  274. package/foundation/discovery/stored-self-audit.d.mts +26 -10
  275. package/foundation/discovery/stored-self-audit.mjs +38 -18
  276. package/foundation/discovery/template-adapter.d.mts +52 -0
  277. package/foundation/discovery/template-adapter.mjs +176 -12
  278. package/foundation/discovery/template-icons.mjs +2 -1
  279. package/foundation/discovery/theme-discovery.mjs +3 -2
  280. package/foundation/discovery/theme-imports.d.mts +14 -0
  281. package/foundation/discovery/theme-imports.mjs +43 -1
  282. package/foundation/discovery/theming-targets.mjs +3 -2
  283. package/foundation/doc-compiler/import.mjs +7 -1
  284. package/foundation/doc-compiler/inputs.mjs +3 -2
  285. package/foundation/doc-compiler/parse-readable.mjs +4 -1
  286. package/foundation/doc-compiler/stored-docs.d.mts +22 -0
  287. package/foundation/doc-compiler/stored-docs.mjs +49 -0
  288. package/foundation/env/semver.mjs +3 -1
  289. package/foundation/fonts/font-stylesheet.d.mts +31 -0
  290. package/foundation/fonts/font-stylesheet.mjs +115 -0
  291. package/foundation/fs/cache-eviction.d.mts +21 -0
  292. package/foundation/fs/cache-eviction.mjs +73 -0
  293. package/foundation/fs/file-protection.mjs +4 -3
  294. package/foundation/fs/gather-cache.d.mts +25 -4
  295. package/foundation/fs/gather-cache.mjs +164 -55
  296. package/foundation/fs/jiti-cache.d.mts +19 -1
  297. package/foundation/fs/jiti-cache.mjs +130 -6
  298. package/foundation/fs/kept-tree.d.mts +60 -0
  299. package/foundation/fs/kept-tree.mjs +154 -0
  300. package/foundation/fs/listing-cache.d.mts +7 -0
  301. package/foundation/fs/listing-cache.mjs +10 -0
  302. package/foundation/fs/module-loader.d.mts +24 -2
  303. package/foundation/fs/module-loader.mjs +94 -21
  304. package/foundation/fs/paths.d.mts +18 -0
  305. package/foundation/fs/paths.mjs +15 -2
  306. package/foundation/identity/provider-identity.d.mts +6 -0
  307. package/foundation/identity/provider-identity.mjs +10 -1
  308. package/foundation/integrations/contribution-inventory.mjs +4 -3
  309. package/foundation/integrations/example-code.d.mts +63 -0
  310. package/foundation/integrations/example-code.mjs +416 -0
  311. package/foundation/integrations/public-imports.d.mts +9 -0
  312. package/foundation/integrations/public-imports.mjs +3 -2
  313. package/foundation/integrations/validate-contributions.mjs +17 -45
  314. package/foundation/render/embedded-files.d.mts +6 -0
  315. package/foundation/render/embedded-files.mjs +25 -5
  316. package/foundation/render/embedded-imports.d.mts +39 -7
  317. package/foundation/render/embedded-imports.mjs +66 -27
  318. package/foundation/render/file-header.d.mts +66 -0
  319. package/foundation/render/file-header.mjs +118 -0
  320. package/foundation/render/host-answer.d.mts +18 -0
  321. package/foundation/render/host-answer.mjs +46 -0
  322. package/foundation/render/host-exit.d.mts +1 -0
  323. package/foundation/render/host-exit.mjs +6 -1
  324. package/foundation/render/html-reader.d.mts +55 -2
  325. package/foundation/render/html-reader.mjs +145 -26
  326. package/foundation/render/markup-edits.d.mts +57 -0
  327. package/foundation/render/markup-edits.mjs +182 -0
  328. package/foundation/render/page-host.mjs +29 -12
  329. package/foundation/render/page-worker.mjs +121 -13
  330. package/foundation/render/picture-chrome.d.mts +4 -0
  331. package/foundation/render/picture-chrome.mjs +185 -0
  332. package/foundation/render/picture-playwright.d.mts +4 -0
  333. package/foundation/render/picture-playwright.mjs +34 -0
  334. package/foundation/render/rebuild.mjs +2 -1
  335. package/foundation/render/render-page.d.mts +35 -3
  336. package/foundation/render/render-page.mjs +316 -42
  337. package/foundation/render/source-block.d.mts +85 -6
  338. package/foundation/render/source-block.mjs +211 -20
  339. package/foundation/render/ts-paths.d.mts +69 -6
  340. package/foundation/render/ts-paths.mjs +326 -40
  341. package/foundation/response/error-codes.d.mts +3 -1
  342. package/foundation/response/error-codes.d.ts +1 -0
  343. package/foundation/response/error-codes.doc.mjs +12 -1
  344. package/foundation/response/error-codes.mjs +11 -1
  345. package/foundation/response/response-types.doc.mjs +2 -2
  346. package/foundation/text/compare-text.d.mts +14 -0
  347. package/foundation/text/compare-text.mjs +68 -0
  348. package/foundation/text/string-utils.d.mts +3 -2
  349. package/foundation/text/string-utils.mjs +18 -4
  350. package/foundation/text/suggest-order.d.mts +9 -0
  351. package/foundation/text/suggest-order.mjs +15 -1
  352. package/foundation/xle/expand.mjs +2 -1
  353. package/host/index.mjs +8 -6
  354. package/package.json +7 -6
@@ -1,9 +1,11 @@
1
1
  // Copyright (c) Meta Platforms, Inc. and affiliates.
2
2
 
3
3
  /**
4
- * @file Word weights for `build`'s START (spec:AST-048): a checked-in table of
5
- * per-template word weights, blended with the page ranker's own scores, picks
6
- * the template an idea starts from.
4
+ * @file Word weights for `build`'s START (spec:AST-048): checked-in tables of
5
+ * per-template word weights, blended with the page ranker's own scores, pick
6
+ * the template an idea starts from. The call model (the file's top-level
7
+ * tables and blend) decides page or app shell; an optional pick model
8
+ * (`pick`) chooses which page once the call model calls a page.
7
9
  *
8
10
  * @input An idea, the ranker's output for it (`rankPages`, `pickStart`), the
9
11
  * project's ready page templates, and the weights (`weights.json` beside this
@@ -20,6 +22,9 @@
20
22
  */
21
23
 
22
24
  import {STOPWORDS} from '../../search/search.mjs';
25
+ import {keywordUnits, keywordWordsFor} from './words.mjs';
26
+ import {isWordModel} from './word-model.mjs';
27
+ import {compareText} from '../../../foundation/text/compare-text.mjs';
23
28
 
24
29
  /** The app shell, as one candidate. */
25
30
  export const SHELL = 'SHELL';
@@ -160,8 +165,34 @@ export function weightWords(idea) {
160
165
  * @property {WeightTable[]} tables
161
166
  * @property {number[]} blend three numbers per member (the tables, in order,
162
167
  * with the ranker second), then one for `SHELL`
168
+ * @property {{tables: WeightTable[], blend: number[]}} [pick] the pick
169
+ * model: its own tables and blend numbers, used only to choose which page
170
+ * starts once the call model (the top-level tables and blend) has called a
171
+ * page. Without it, one model does both.
163
172
  */
164
173
 
174
+ /**
175
+ * Whether the weights file carries a well-formed pick model. A malformed
176
+ * `pick` block is ignored, so one model then does both decisions.
177
+ * @param {WeightsFile} weights
178
+ * @returns {boolean}
179
+ */
180
+ const hasPickModel = weights =>
181
+ isWordModel(weights.pick, weights.candidates.length);
182
+
183
+ /**
184
+ * The pick model of a weights file: its `pick` tables and blend when present,
185
+ * else the file's own.
186
+ * @param {WeightsFile} weights
187
+ * @returns {WeightsFile}
188
+ */
189
+ const pickModel = weights => {
190
+ const pick = weights.pick;
191
+ return pick && hasPickModel(weights)
192
+ ? {...weights, tables: pick.tables, blend: pick.blend}
193
+ : weights;
194
+ };
195
+
165
196
  /**
166
197
  * A table's score for every candidate.
167
198
  * @param {WeightTable} table
@@ -217,9 +248,15 @@ function memberFeatures(v) {
217
248
  Math.max(1, finite.length),
218
249
  ) || 1;
219
250
  const val = v.map(x => (x === undefined ? -1e9 : x));
220
- const order = [...val.keys()].sort((a, b) => val[b] - val[a]);
221
- const rank = new Array(v.length);
222
- order.forEach((ci, r) => (rank[ci] = r));
251
+ // Equal values share the average of the ranks they span. That is the mean
252
+ // rank an arbitrary order gives them, which is what the blend numbers were
253
+ // fit on, and the candidates' order in the weights file never decides. Two
254
+ // or more candidates tied at a member's top share a rank above 0, so none
255
+ // of them gets the is-top feature.
256
+ const rank = val.map(
257
+ x =>
258
+ val.filter(y => y > x).length + (val.filter(y => y === x).length - 1) / 2,
259
+ );
223
260
  return v.map((x, i) => [
224
261
  x === undefined ? -4 : Math.max(-4, Math.min(4, (x - mean) / sd)),
225
262
  1 / (rank[i] + 1),
@@ -233,32 +270,68 @@ function memberFeatures(v) {
233
270
  * @property {string} [displayName]
234
271
  * @property {string} [category]
235
272
  * @property {string[]} [keywords]
273
+ * @property {string} [description]
274
+ * @property {string[]} [components]
275
+ */
276
+
277
+ /**
278
+ * The words of a descriptor text as this file reads an idea: stemmed, less
279
+ * search's stopwords. Search's stopwords are no evidence: "to" in a "to-do
280
+ * list" keyword must not answer the "to" of "rows to track orders".
281
+ * @param {string} text
282
+ * @returns {string[]}
283
+ */
284
+ const contentWords = text =>
285
+ weightWords(text)
286
+ .filter(w => !STOPWORDS.has(w))
287
+ .map(stem);
288
+
289
+ /**
290
+ * The words a template's descriptor gives an idea: every word of `texts`, and
291
+ * the words its keywords give the idea (`keywordWordsFor`): a phrase keyword
292
+ * counts all of its words when the idea names the whole phrase, and none of
293
+ * them otherwise.
294
+ * @param {string[]} texts
295
+ * @param {readonly string[]} keywords
296
+ * @param {string[]} order the idea's words, in order (`contentWords`)
297
+ * @returns {Set<string>}
236
298
  */
299
+ const descriptorWordsFor = (texts, keywords, order) =>
300
+ new Set([
301
+ ...contentWords(texts.join(' ')),
302
+ ...keywordWordsFor(keywordUnits(keywords, contentWords), order),
303
+ ]);
237
304
 
238
305
  /**
239
- * How many of the idea's stemmed words a template's own descriptor names: its
240
- * display name, its category, and its keywords, less search's stopwords.
306
+ * How many of the idea's words a template's own descriptor names: its display
307
+ * name, its category, and its keywords.
241
308
  * @param {string} name
242
309
  * @param {DescribedTemplate[]} catalog
243
- * @param {Set<string>} words the idea's stemmed words, less search's stopwords
310
+ * @param {string[]} order the idea's words, in order (`contentWords`)
244
311
  */
245
- function ownWords(name, catalog, words) {
312
+ function ownWords(name, catalog, order) {
246
313
  const t = catalog.find(c => c.name === name);
247
314
  if (!t) return 0;
248
- // Search's stopwords are no evidence: "to" in a "to-do list" keyword must
249
- // not answer the "to" of "rows to track orders".
250
- const own = new Set(
251
- weightWords(
252
- [t.displayName ?? '', t.category ?? '', ...(t.keywords ?? [])].join(' '),
253
- )
254
- .filter(w => !STOPWORDS.has(w))
255
- .map(stem),
315
+ const own = descriptorWordsFor(
316
+ [t.displayName ?? '', t.category ?? ''],
317
+ t.keywords ?? [],
318
+ order,
256
319
  );
257
320
  let n = 0;
258
- for (const w of words) if (own.has(w)) n++;
321
+ for (const w of new Set(order)) if (own.has(w)) n++;
259
322
  return n;
260
323
  }
261
324
 
325
+ /**
326
+ * A template's family: the part of its category before ` - `.
327
+ * @param {string} name
328
+ * @param {DescribedTemplate[]} catalog
329
+ */
330
+ const familyOf = (name, catalog) =>
331
+ String(catalog.find(c => c.name === name)?.category ?? '')
332
+ .split(' - ')[0]
333
+ .trim();
334
+
262
335
  /** How many fewer own words a template whose family the idea names first may
263
336
  * name than the listed template it competes with, and still start. */
264
337
  const FAMILY_SLACK = 2;
@@ -330,6 +403,224 @@ function blend(idea, ranked, pick, catalog, weights) {
330
403
  return {cands, scores, position};
331
404
  }
332
405
 
406
+ /**
407
+ * The most typical of the ready templates the ranker ties with `name` in its
408
+ * family (same score, and both the family's base or both variants): the one
409
+ * whose descriptor's words are shared by the most of its family's templates,
410
+ * on average. `name` keeps its
411
+ * place on an equal value. Reads only the templates' descriptors.
412
+ * @param {string} name
413
+ * @param {import('./rank.mjs').RankedPage[]} ranked
414
+ * @param {string[]} cands
415
+ * @returns {string}
416
+ */
417
+ function typicalOfTie(name, ranked, cands) {
418
+ const self = ranked.find(r => r.name === name);
419
+ if (!self || self.family === SHELL_FAMILY || !self.family) return name;
420
+ let chosen = self;
421
+ for (const r of ranked) {
422
+ if (
423
+ r.score === self.score &&
424
+ r.family === self.family &&
425
+ r.base === self.base &&
426
+ cands.includes(r.name) &&
427
+ r.typical > chosen.typical
428
+ )
429
+ chosen = r;
430
+ }
431
+ return chosen.name;
432
+ }
433
+
434
+ /**
435
+ * The words a template's whole descriptor gives an idea
436
+ * (`descriptorWordsFor`): its display name, category, keywords, description,
437
+ * and the names of the components its page composes.
438
+ * @param {DescribedTemplate} t
439
+ * @param {string[]} order the idea's words, in order (`contentWords`)
440
+ * @returns {Set<string>}
441
+ */
442
+ function descriptorWords(t, order) {
443
+ const components = (t.components ?? []).map(c =>
444
+ c.replace(/([a-z0-9])([A-Z])/g, '$1 $2'),
445
+ );
446
+ return descriptorWordsFor(
447
+ [t.displayName ?? '', t.category ?? '', t.description ?? '', ...components],
448
+ t.keywords ?? [],
449
+ order,
450
+ );
451
+ }
452
+
453
+ /**
454
+ * Which of a set of tied templates the idea names by its whole name: its
455
+ * display name or its id, as consecutive words of the idea ("a form wizard
456
+ * page" names `form-wizard`, "Form Wizard"). A whole name is stronger evidence
457
+ * than any descriptor word, so it settles an exact tie first.
458
+ * @param {string[]} names the tied templates' ids
459
+ * @param {string} idea
460
+ * @param {DescribedTemplate[]} catalog
461
+ * @returns {boolean[]} one flag per name, in order
462
+ */
463
+ export function namedOutright(names, idea, catalog) {
464
+ const said = weightWords(idea).map(stem);
465
+ const holds = (/** @type {string[]} */ phrase) =>
466
+ phrase.length > 0 &&
467
+ said.some((_, i) => phrase.every((w, k) => said[i + k] === w));
468
+ return names.map(name => {
469
+ const t = catalog.find(c => c.name === name);
470
+ return [t?.displayName ?? '', name.replace(/-/g, ' ')].some(text =>
471
+ holds(weightWords(text).map(stem)),
472
+ );
473
+ });
474
+ }
475
+
476
+ /**
477
+ * How strongly each of a set of tied templates' own descriptors answers the
478
+ * idea. Words every tied template names cannot choose between them, so they
479
+ * are left out; each other word of the idea that a template's descriptor
480
+ * names adds its rarity among the templates of the tied templates' families.
481
+ * Reads only the templates' descriptors.
482
+ * @param {string[]} names the tied templates' ids
483
+ * @param {string} idea
484
+ * @param {DescribedTemplate[]} catalog
485
+ * @returns {number[]} one reading per name, in order
486
+ */
487
+ export function tieReading(names, idea, catalog) {
488
+ const families = new Set(names.map(name => familyOf(name, catalog)));
489
+ const pool = catalog.filter(t => families.has(familyOf(t.name, catalog)));
490
+ const order = contentWords(idea);
491
+ const words = new Map(pool.map(t => [t.name, descriptorWords(t, order)]));
492
+ const df = (/** @type {string} */ w) =>
493
+ pool.filter(t => words.get(t.name)?.has(w)).length;
494
+ const said = new Set(order);
495
+ const own = names.map(name => words.get(name) ?? new Set());
496
+ const n = pool.length;
497
+ return names.map((_, i) => {
498
+ let s = 0;
499
+ for (const w of said) {
500
+ if (!own[i].has(w) || own.every(o => o.has(w))) continue;
501
+ const d = df(w);
502
+ s += Math.log(1 + (n - d + 0.5) / (d + 0.5));
503
+ }
504
+ return s;
505
+ });
506
+ }
507
+
508
+ /**
509
+ * Settles an exact tie in the ranker: a tied template the idea names by its
510
+ * whole name starts (`namedOutright`); otherwise a fuller reading of each tied
511
+ * template's own descriptor decides. Words every tied template names cannot choose
512
+ * between them, so they are left out; each other word of the idea that a
513
+ * template's descriptor names adds its rarity within the family. The highest
514
+ * total starts. An equal total goes to the most typical of the family
515
+ * (`typicalOfTie`), then to `name`. Reads only the templates' descriptors.
516
+ * @param {string} name
517
+ * @param {string} idea
518
+ * @param {import('./rank.mjs').RankedPage[]} ranked
519
+ * @param {string[]} cands
520
+ * @param {DescribedTemplate[]} catalog
521
+ * @returns {string}
522
+ */
523
+ function fullerOfTie(name, idea, ranked, cands, catalog) {
524
+ const self = ranked.find(r => r.name === name);
525
+ if (!self || self.family === SHELL_FAMILY || !self.family) return name;
526
+ const tied = ranked.filter(
527
+ r =>
528
+ r.score === self.score &&
529
+ r.family === self.family &&
530
+ r.base === self.base &&
531
+ cands.includes(r.name),
532
+ );
533
+ if (tied.length < 2) return name;
534
+ const named = namedOutright(
535
+ tied.map(r => r.name),
536
+ idea,
537
+ catalog,
538
+ );
539
+ if (named.filter(Boolean).length === 1) return tied[named.indexOf(true)].name;
540
+ const score = tieReading(
541
+ tied.map(r => r.name),
542
+ idea,
543
+ catalog,
544
+ );
545
+ const top = Math.max(...score);
546
+ if (top === 0) return typicalOfTie(name, ranked, cands);
547
+ const leaders = tied.filter((_, i) => score[i] >= top - 1e-9);
548
+ if (leaders.length === 1) return leaders[0].name;
549
+ const lead = leaders.some(r => r.name === name) ? self : leaders[0];
550
+ return typicalOfTie(
551
+ lead.name,
552
+ ranked,
553
+ leaders.map(r => r.name),
554
+ );
555
+ }
556
+
557
+ /**
558
+ * The pick model's best ready, non-shell template that `ok` accepts, or null
559
+ * when it has none.
560
+ * @param {string} idea
561
+ * @param {import('./rank.mjs').RankedPage[]} ranked
562
+ * @param {import('./rank.mjs').RankedPage | null} pick
563
+ * @param {DescribedTemplate[]} catalog
564
+ * @param {WeightsFile} weights
565
+ * @param {(c: string) => boolean} [ok]
566
+ * @returns {string | null}
567
+ */
568
+ function bestPage(idea, ranked, pick, catalog, weights, ok = () => true) {
569
+ return pickOrder(idea, ranked, pick, catalog, weights).find(ok) ?? null;
570
+ }
571
+
572
+ /**
573
+ * Every ready, non-shell template in the pick model's order, best first.
574
+ * Templates the pick model scores exactly the same are ordered like an exact
575
+ * tie in the ranker: a template the idea names by its whole name first
576
+ * (`namedOutright`), then by how strongly each one's own descriptor answers
577
+ * the idea (`tieReading`), then by how typical of its family it is, then by
578
+ * name.
579
+ * The weights file's candidate order never decides.
580
+ * @param {string} idea
581
+ * @param {import('./rank.mjs').RankedPage[]} ranked
582
+ * @param {import('./rank.mjs').RankedPage | null} pick
583
+ * @param {DescribedTemplate[]} catalog
584
+ * @param {WeightsFile} weights
585
+ * @returns {string[]}
586
+ */
587
+ function pickOrder(idea, ranked, pick, catalog, weights) {
588
+ const {cands, scores} = blend(
589
+ idea,
590
+ ranked,
591
+ pick,
592
+ catalog,
593
+ pickModel(weights),
594
+ );
595
+ const sorted = cands
596
+ .map((c, i) => ({c, s: scores[i]}))
597
+ .filter(x => x.c !== SHELL)
598
+ .sort((x, y) => y.s - x.s);
599
+ const typical = new Map(ranked.map(r => [r.name, r.typical]));
600
+ const out = [];
601
+ for (let i = 0; i < sorted.length;) {
602
+ let j = i + 1;
603
+ while (j < sorted.length && sorted[j].s === sorted[i].s) j++;
604
+ const run = sorted.slice(i, j).map(x => x.c);
605
+ if (run.length > 1) {
606
+ const reading = tieReading(run, idea, catalog);
607
+ const named = namedOutright(run, idea, catalog);
608
+ const at = new Map(run.map((c, k) => [c, reading[k]]));
609
+ const outright = new Map(run.map((c, k) => [c, named[k]]));
610
+ run.sort(
611
+ (a, b) =>
612
+ Number(outright.get(b)) - Number(outright.get(a)) ||
613
+ Number(at.get(b)) - Number(at.get(a)) ||
614
+ (typical.get(b) ?? 0) - (typical.get(a) ?? 0) ||
615
+ compareText(a, b),
616
+ );
617
+ }
618
+ out.push(...run);
619
+ i = j;
620
+ }
621
+ return out;
622
+ }
623
+
333
624
  /**
334
625
  * Every ready, non-shell template in the blend's own order, best first: the
335
626
  * order the page start is chosen from, so the alternatives build names beside
@@ -343,12 +634,7 @@ function blend(idea, ranked, pick, catalog, weights) {
343
634
  */
344
635
  export function blendOrder(idea, ranked, pick, catalog, weights) {
345
636
  if (!weights) return null;
346
- const {cands, scores} = blend(idea, ranked, pick, catalog, weights);
347
- return cands
348
- .map((c, i) => ({c, s: scores[i], i}))
349
- .filter(x => x.c !== SHELL)
350
- .sort((x, y) => y.s - x.s || x.i - y.i)
351
- .map(x => x.c);
637
+ return pickOrder(idea, ranked, pick, catalog, weights);
352
638
  }
353
639
 
354
640
  /**
@@ -388,31 +674,39 @@ export function weighStart(
388
674
  // The tables cannot judge a template they do not list (an integration's
389
675
  // template, or one added since they were fit), so its own descriptor
390
676
  // decides: the ranker's pick stands when the idea names as many words of its
391
- // display name, category and keywords as of the tables' first listed
392
- // template's, or names its family first and nearly as many; otherwise that
393
- // listed template starts. Nothing learned about the template is involved,
677
+ // display name, category and keywords as of the best listed template's (the
678
+ // pick model's choice, as for every other page), or names its family first
679
+ // and nearly as many; otherwise that listed template starts. Nothing learned about the template is involved,
394
680
  // so a new template competes on its own words.
395
681
  if (kept && !position.has(kept)) {
396
- const listed = best(c => c !== SHELL && position.has(c));
682
+ const listed = bestPage(idea, ranked, pick, catalog, weights, c =>
683
+ position.has(c),
684
+ );
397
685
  if (!listed) return kept;
398
686
  // The idea's own words, less search's stopwords: "basically" must not
399
687
  // answer the "Basic" of a category.
400
- const content = weightWords(idea).filter(w => !STOPWORDS.has(w));
401
- const said = new Set(content.map(stem));
402
- const mine = ownWords(kept, catalog, said);
403
- const theirs = ownWords(listed, catalog, said);
404
- if (mine >= theirs) return kept;
688
+ const order = contentWords(idea);
689
+ const mine = ownWords(kept, catalog, order);
690
+ const theirs = ownWords(listed, catalog, order);
405
691
  // An idea that names the template's family before the listed one's
406
692
  // ("a dashboard with a data table") is that family's page, unless it
407
693
  // names far more of the listed template's words.
408
- const order = content.map(stem);
409
- return familyAt(kept, catalog, order) < familyAt(listed, catalog, order) &&
410
- mine >= theirs - FAMILY_SLACK
411
- ? kept
412
- : listed;
694
+ const stays =
695
+ mine >= theirs ||
696
+ (familyAt(kept, catalog, order) < familyAt(listed, catalog, order) &&
697
+ mine >= theirs - FAMILY_SLACK);
698
+ if (!stays) return listed;
699
+ // A tie in the ranker is no preference: every table that names "table"
700
+ // scores the same, and the alphabet must not choose the page. Among the
701
+ // family's templates the ranker ties with this unlisted one, the template
702
+ // whose own descriptor best matches the idea starts (`fullerOfTie`), then
703
+ // the one most typical of the family. Only the templates' descriptors
704
+ // decide this tie, never the tables.
705
+ return fullerOfTie(kept, idea, ranked, cands, catalog);
413
706
  }
414
707
  const top = best(() => true);
415
- if (top !== SHELL) return top;
708
+ if (top !== SHELL)
709
+ return bestPage(idea, ranked, pick, catalog, weights) ?? top;
416
710
  // An idea that asks for a new page keeps the ranker's template rather than
417
711
  // the shell.
418
712
  if (newPage && kept) return kept;
@@ -420,8 +714,9 @@ export function weighStart(
420
714
  }
421
715
 
422
716
  /**
423
- * The blend's scores: the app shell's, and the best non-shell template with
424
- * its score and the runner-up's. Null without weights.
717
+ * The call model's scores: the app shell's, the best non-shell template's and
718
+ * the runner-up's, with the page to start from (the pick model's choice when
719
+ * the file has one, else the call model's best page). Null without weights.
425
720
  * @param {string} idea
426
721
  * @param {import('./rank.mjs').RankedPage[]} ranked
427
722
  * @param {import('./rank.mjs').RankedPage | null} pick
@@ -440,7 +735,9 @@ export function blendSummary(idea, ranked, pick, catalog, weights) {
440
735
  rest.sort((x, y) => y.score - x.score || x.i - y.i);
441
736
  return {
442
737
  shell,
443
- best: rest[0]?.name ?? null,
738
+ best: hasPickModel(weights)
739
+ ? bestPage(idea, ranked, pick, catalog, weights)
740
+ : (rest[0]?.name ?? null),
444
741
  bestScore: rest[0]?.score ?? 0,
445
742
  secondScore: rest[1]?.score ?? 0,
446
743
  };
@@ -0,0 +1,23 @@
1
+ // @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
2
+ // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
+
4
+ /**
5
+ * @file The shape check for `build`'s checked-in word models (spec:AST-048).
6
+ *
7
+ * @input A parsed word model (tables and blend numbers) and the candidate
8
+ * count of its weights file.
9
+ * @output `isWordModel(model, n)`: whether the kit can read it.
10
+ * @position Beside weights.mjs (api/build/kit/). The adapter checks the
11
+ * weights file's call model with it, and weights.mjs checks the optional
12
+ * pick model with it. It imports nothing, so both can use it.
13
+ */
14
+ /**
15
+ * Whether a word model has the shape the kit reads, over `n` candidates: every
16
+ * table row has a weight per candidate, every bias a number per candidate, and
17
+ * the blend has three numbers per member (the tables plus the ranker) and one
18
+ * for the shell. The weights file's call model and its `pick` model share it.
19
+ * @param {any} model
20
+ * @param {number} n the candidate count
21
+ * @returns {boolean}
22
+ */
23
+ export function isWordModel(model: any, n: number): boolean;
@@ -0,0 +1,46 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file The shape check for `build`'s checked-in word models (spec:AST-048).
5
+ *
6
+ * @input A parsed word model (tables and blend numbers) and the candidate
7
+ * count of its weights file.
8
+ * @output `isWordModel(model, n)`: whether the kit can read it.
9
+ * @position Beside weights.mjs (api/build/kit/). The adapter checks the
10
+ * weights file's call model with it, and weights.mjs checks the optional
11
+ * pick model with it. It imports nothing, so both can use it.
12
+ */
13
+
14
+ /**
15
+ * Whether a word model has the shape the kit reads, over `n` candidates: every
16
+ * table row has a weight per candidate, every bias a number per candidate, and
17
+ * the blend has three numbers per member (the tables plus the ranker) and one
18
+ * for the shell. The weights file's call model and its `pick` model share it.
19
+ * @param {any} model
20
+ * @param {number} n the candidate count
21
+ * @returns {boolean}
22
+ */
23
+ export function isWordModel(model, n) {
24
+ return (
25
+ n > 0 &&
26
+ Array.isArray(model?.tables) &&
27
+ model.tables.length > 0 &&
28
+ model.tables.every(
29
+ (/** @type {any} */ t) =>
30
+ Array.isArray(t?.words) &&
31
+ Array.isArray(t.rows) &&
32
+ t.rows.length === t.words.length &&
33
+ t.rows.every(
34
+ (/** @type {any} */ r) => typeof r === 'string' && r.length === n,
35
+ ) &&
36
+ Array.isArray(t.bias) &&
37
+ t.bias.length === n &&
38
+ t.bias.every((/** @type {any} */ b) => Number.isFinite(b)) &&
39
+ Number.isFinite(t.clip) &&
40
+ Number.isFinite(t.step),
41
+ ) &&
42
+ Array.isArray(model.blend) &&
43
+ model.blend.length === 3 * (model.tables.length + 1) + 1 &&
44
+ model.blend.every((/** @type {any} */ x) => Number.isFinite(x))
45
+ );
46
+ }
@@ -30,6 +30,47 @@ export function pairsOf(texts: string[]): Set<string>;
30
30
  * @returns {Set<string>}
31
31
  */
32
32
  export function containersOf(query: string): Set<string>;
33
+ /**
34
+ * A template's keywords as the units a request can match, each read with the
35
+ * caller's own word reader. A one-word keyword is that word. A longer keyword
36
+ * is one phrase unit, its words joined by single spaces: a request matches it
37
+ * only when it names those words in that order (`phrasesIn`), and its words
38
+ * never count alone. So "table of contents" on a docs page adds no "table" to
39
+ * that page, and a table request still reads as a table.
40
+ * @param {readonly string[]} keywords
41
+ * @param {(text: string) => string[]} read the caller's word reader
42
+ * @returns {string[]}
43
+ */
44
+ export function keywordUnits(keywords: readonly string[], read: (text: string) => string[]): string[];
45
+ /**
46
+ * The phrase units (two or more words) a request names: the unit's words
47
+ * appear next to each other, in order, in the request's words as the same
48
+ * reader reads them.
49
+ * @param {readonly string[]} words the request's words, in order
50
+ * @param {Iterable<string>} units
51
+ * @returns {Set<string>}
52
+ */
53
+ export function phrasesIn(words: readonly string[], units: Iterable<string>): Set<string>;
54
+ /**
55
+ * The words a template's keyword units give an idea: each one-word keyword,
56
+ * and every word of each phrase keyword the idea names (`phrasesIn`). A named
57
+ * phrase carries all of its words, as the same words listed one by one would;
58
+ * a phrase the idea does not name gives none of them.
59
+ * @param {readonly string[]} units the template's keyword units (`keywordUnits`)
60
+ * @param {readonly string[]} words the idea's words, in order, read the same way
61
+ * @returns {string[]}
62
+ */
63
+ export function keywordWordsFor(units: readonly string[], words: readonly string[]): string[];
64
+ /**
65
+ * What each frame of an idea holds: for every container phrase ("settings in
66
+ * a modal", "in a settings modal"), the frame's terms with the words that
67
+ * name what sits in it: the head of the phrase right before the container
68
+ * phrase, and the container phrase's own other words. In "a toggle in a modal
69
+ * on the settings page" the modal holds the toggle, not the settings page.
70
+ * @param {string} query
71
+ * @returns {Map<string, Set<string>>} frame term -> terms it holds
72
+ */
73
+ export function framesOf(query: string): Map<string, Set<string>>;
33
74
  /**
34
75
  * Family words, from the templates' own ids: a word in the ids of two or more
35
76
  * templates of one family, plus the family's name when a template carries it.
@@ -49,6 +90,12 @@ export const HEAD_END: RegExp;
49
90
  export const SHELL_FAMILY: "Shell";
50
91
  /** A container phrase: "in a modal", "inside the side panel". */
51
92
  export const CONTAINER_PHRASE: RegExp;
93
+ /**
94
+ * A place phrase: a preposition of place, then a determiner ("above the
95
+ * table", "into my dashboard"). CONTAINER_PHRASE is the narrower class of
96
+ * frames a page lives in ("in a modal"); this one names where a piece goes.
97
+ */
98
+ export const PLACE_PHRASE: RegExp;
52
99
  /**
53
100
  * Where a phrase ends, for finding the word that heads it: punctuation and
54
101
  * the words that join phrases.
@@ -69,5 +116,6 @@ export type RankedPage = {
69
116
  family: string;
70
117
  base: boolean;
71
118
  matched: Set<string>;
119
+ typical: number;
72
120
  };
73
121
  export type IdeaKind = "page" | "part" | "edit";