@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
@@ -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,8 @@
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';
23
27
 
24
28
  /** The app shell, as one candidate. */
25
29
  export const SHELL = 'SHELL';
@@ -160,8 +164,34 @@ export function weightWords(idea) {
160
164
  * @property {WeightTable[]} tables
161
165
  * @property {number[]} blend three numbers per member (the tables, in order,
162
166
  * with the ranker second), then one for `SHELL`
167
+ * @property {{tables: WeightTable[], blend: number[]}} [pick] the pick
168
+ * model: its own tables and blend numbers, used only to choose which page
169
+ * starts once the call model (the top-level tables and blend) has called a
170
+ * page. Without it, one model does both.
163
171
  */
164
172
 
173
+ /**
174
+ * Whether the weights file carries a well-formed pick model. A malformed
175
+ * `pick` block is ignored, so one model then does both decisions.
176
+ * @param {WeightsFile} weights
177
+ * @returns {boolean}
178
+ */
179
+ const hasPickModel = weights =>
180
+ isWordModel(weights.pick, weights.candidates.length);
181
+
182
+ /**
183
+ * The pick model of a weights file: its `pick` tables and blend when present,
184
+ * else the file's own.
185
+ * @param {WeightsFile} weights
186
+ * @returns {WeightsFile}
187
+ */
188
+ const pickModel = weights => {
189
+ const pick = weights.pick;
190
+ return pick && hasPickModel(weights)
191
+ ? {...weights, tables: pick.tables, blend: pick.blend}
192
+ : weights;
193
+ };
194
+
165
195
  /**
166
196
  * A table's score for every candidate.
167
197
  * @param {WeightTable} table
@@ -233,32 +263,68 @@ function memberFeatures(v) {
233
263
  * @property {string} [displayName]
234
264
  * @property {string} [category]
235
265
  * @property {string[]} [keywords]
266
+ * @property {string} [description]
267
+ * @property {string[]} [components]
236
268
  */
237
269
 
238
270
  /**
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.
271
+ * The words of a descriptor text as this file reads an idea: stemmed, less
272
+ * search's stopwords. Search's stopwords are no evidence: "to" in a "to-do
273
+ * list" keyword must not answer the "to" of "rows to track orders".
274
+ * @param {string} text
275
+ * @returns {string[]}
276
+ */
277
+ const contentWords = text =>
278
+ weightWords(text)
279
+ .filter(w => !STOPWORDS.has(w))
280
+ .map(stem);
281
+
282
+ /**
283
+ * The words a template's descriptor gives an idea: every word of `texts`, and
284
+ * the words its keywords give the idea (`keywordWordsFor`): a phrase keyword
285
+ * counts all of its words when the idea names the whole phrase, and none of
286
+ * them otherwise.
287
+ * @param {string[]} texts
288
+ * @param {readonly string[]} keywords
289
+ * @param {string[]} order the idea's words, in order (`contentWords`)
290
+ * @returns {Set<string>}
291
+ */
292
+ const descriptorWordsFor = (texts, keywords, order) =>
293
+ new Set([
294
+ ...contentWords(texts.join(' ')),
295
+ ...keywordWordsFor(keywordUnits(keywords, contentWords), order),
296
+ ]);
297
+
298
+ /**
299
+ * How many of the idea's words a template's own descriptor names: its display
300
+ * name, its category, and its keywords.
241
301
  * @param {string} name
242
302
  * @param {DescribedTemplate[]} catalog
243
- * @param {Set<string>} words the idea's stemmed words, less search's stopwords
303
+ * @param {string[]} order the idea's words, in order (`contentWords`)
244
304
  */
245
- function ownWords(name, catalog, words) {
305
+ function ownWords(name, catalog, order) {
246
306
  const t = catalog.find(c => c.name === name);
247
307
  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),
308
+ const own = descriptorWordsFor(
309
+ [t.displayName ?? '', t.category ?? ''],
310
+ t.keywords ?? [],
311
+ order,
256
312
  );
257
313
  let n = 0;
258
- for (const w of words) if (own.has(w)) n++;
314
+ for (const w of new Set(order)) if (own.has(w)) n++;
259
315
  return n;
260
316
  }
261
317
 
318
+ /**
319
+ * A template's family: the part of its category before ` - `.
320
+ * @param {string} name
321
+ * @param {DescribedTemplate[]} catalog
322
+ */
323
+ const familyOf = (name, catalog) =>
324
+ String(catalog.find(c => c.name === name)?.category ?? '')
325
+ .split(' - ')[0]
326
+ .trim();
327
+
262
328
  /** How many fewer own words a template whose family the idea names first may
263
329
  * name than the listed template it competes with, and still start. */
264
330
  const FAMILY_SLACK = 2;
@@ -330,6 +396,139 @@ function blend(idea, ranked, pick, catalog, weights) {
330
396
  return {cands, scores, position};
331
397
  }
332
398
 
399
+ /**
400
+ * The most typical of the ready templates the ranker ties with `name` in its
401
+ * family (same score, same id length): the one whose descriptor's words are
402
+ * shared by the most of its family's templates, on average. `name` keeps its
403
+ * place on an equal value. Reads only the templates' descriptors.
404
+ * @param {string} name
405
+ * @param {import('./rank.mjs').RankedPage[]} ranked
406
+ * @param {string[]} cands
407
+ * @returns {string}
408
+ */
409
+ function typicalOfTie(name, ranked, cands) {
410
+ const self = ranked.find(r => r.name === name);
411
+ if (!self || self.family === SHELL_FAMILY || !self.family) return name;
412
+ const length = (/** @type {string} */ n) => n.split('-').length;
413
+ let chosen = self;
414
+ for (const r of ranked) {
415
+ if (
416
+ r.score === self.score &&
417
+ r.family === self.family &&
418
+ length(r.name) === length(self.name) &&
419
+ cands.includes(r.name) &&
420
+ r.typical > chosen.typical
421
+ )
422
+ chosen = r;
423
+ }
424
+ return chosen.name;
425
+ }
426
+
427
+ /**
428
+ * The words a template's whole descriptor gives an idea
429
+ * (`descriptorWordsFor`): its display name, category, keywords, description,
430
+ * and the names of the components its page composes.
431
+ * @param {DescribedTemplate} t
432
+ * @param {string[]} order the idea's words, in order (`contentWords`)
433
+ * @returns {Set<string>}
434
+ */
435
+ function descriptorWords(t, order) {
436
+ const components = (t.components ?? []).map(c =>
437
+ c.replace(/([a-z0-9])([A-Z])/g, '$1 $2'),
438
+ );
439
+ return descriptorWordsFor(
440
+ [t.displayName ?? '', t.category ?? '', t.description ?? '', ...components],
441
+ t.keywords ?? [],
442
+ order,
443
+ );
444
+ }
445
+
446
+ /**
447
+ * Settles an exact tie in the ranker by a fuller reading of each tied
448
+ * template's own descriptor. Words every tied template names cannot choose
449
+ * between them, so they are left out; each other word of the idea that a
450
+ * template's descriptor names adds its rarity within the family. The highest
451
+ * total starts. An equal total goes to the most typical of the family
452
+ * (`typicalOfTie`), then to `name`. Reads only the templates' descriptors.
453
+ * @param {string} name
454
+ * @param {string} idea
455
+ * @param {import('./rank.mjs').RankedPage[]} ranked
456
+ * @param {string[]} cands
457
+ * @param {DescribedTemplate[]} catalog
458
+ * @returns {string}
459
+ */
460
+ function fullerOfTie(name, idea, ranked, cands, catalog) {
461
+ const self = ranked.find(r => r.name === name);
462
+ if (!self || self.family === SHELL_FAMILY || !self.family) return name;
463
+ const length = (/** @type {string} */ n) => n.split('-').length;
464
+ const tied = ranked.filter(
465
+ r =>
466
+ r.score === self.score &&
467
+ r.family === self.family &&
468
+ length(r.name) === length(self.name) &&
469
+ cands.includes(r.name),
470
+ );
471
+ if (tied.length < 2) return name;
472
+ const family = catalog.filter(t => familyOf(t.name, catalog) === self.family);
473
+ const order = contentWords(idea);
474
+ const words = new Map(family.map(t => [t.name, descriptorWords(t, order)]));
475
+ const df = (/** @type {string} */ w) =>
476
+ family.filter(t => words.get(t.name)?.has(w)).length;
477
+ const said = new Set(order);
478
+ const own = tied.map(r => words.get(r.name) ?? new Set());
479
+ const n = family.length;
480
+ const score = tied.map((_, i) => {
481
+ let s = 0;
482
+ for (const w of said) {
483
+ if (!own[i].has(w) || own.every(o => o.has(w))) continue;
484
+ const d = df(w);
485
+ s += Math.log(1 + (n - d + 0.5) / (d + 0.5));
486
+ }
487
+ return s;
488
+ });
489
+ const top = Math.max(...score);
490
+ if (top === 0) return typicalOfTie(name, ranked, cands);
491
+ const leaders = tied.filter((_, i) => score[i] >= top - 1e-9);
492
+ if (leaders.length === 1) return leaders[0].name;
493
+ const lead = leaders.some(r => r.name === name) ? self : leaders[0];
494
+ return typicalOfTie(
495
+ lead.name,
496
+ ranked,
497
+ leaders.map(r => r.name),
498
+ );
499
+ }
500
+
501
+ /**
502
+ * The pick model's best ready, non-shell template that `ok` accepts, or null
503
+ * when it has none.
504
+ * @param {string} idea
505
+ * @param {import('./rank.mjs').RankedPage[]} ranked
506
+ * @param {import('./rank.mjs').RankedPage | null} pick
507
+ * @param {DescribedTemplate[]} catalog
508
+ * @param {WeightsFile} weights
509
+ * @param {(c: string) => boolean} [ok]
510
+ * @returns {string | null}
511
+ */
512
+ function bestPage(idea, ranked, pick, catalog, weights, ok = () => true) {
513
+ const {cands, scores} = blend(
514
+ idea,
515
+ ranked,
516
+ pick,
517
+ catalog,
518
+ pickModel(weights),
519
+ );
520
+ let at = -1;
521
+ for (let c = 0; c < cands.length; c++) {
522
+ if (
523
+ cands[c] !== SHELL &&
524
+ ok(cands[c]) &&
525
+ (at < 0 || scores[c] > scores[at])
526
+ )
527
+ at = c;
528
+ }
529
+ return at < 0 ? null : cands[at];
530
+ }
531
+
333
532
  /**
334
533
  * Every ready, non-shell template in the blend's own order, best first: the
335
534
  * order the page start is chosen from, so the alternatives build names beside
@@ -343,7 +542,13 @@ function blend(idea, ranked, pick, catalog, weights) {
343
542
  */
344
543
  export function blendOrder(idea, ranked, pick, catalog, weights) {
345
544
  if (!weights) return null;
346
- const {cands, scores} = blend(idea, ranked, pick, catalog, weights);
545
+ const {cands, scores} = blend(
546
+ idea,
547
+ ranked,
548
+ pick,
549
+ catalog,
550
+ pickModel(weights),
551
+ );
347
552
  return cands
348
553
  .map((c, i) => ({c, s: scores[i], i}))
349
554
  .filter(x => x.c !== SHELL)
@@ -388,31 +593,39 @@ export function weighStart(
388
593
  // The tables cannot judge a template they do not list (an integration's
389
594
  // template, or one added since they were fit), so its own descriptor
390
595
  // 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,
596
+ // display name, category and keywords as of the best listed template's (the
597
+ // pick model's choice, as for every other page), or names its family first
598
+ // and nearly as many; otherwise that listed template starts. Nothing learned about the template is involved,
394
599
  // so a new template competes on its own words.
395
600
  if (kept && !position.has(kept)) {
396
- const listed = best(c => c !== SHELL && position.has(c));
601
+ const listed = bestPage(idea, ranked, pick, catalog, weights, c =>
602
+ position.has(c),
603
+ );
397
604
  if (!listed) return kept;
398
605
  // The idea's own words, less search's stopwords: "basically" must not
399
606
  // 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;
607
+ const order = contentWords(idea);
608
+ const mine = ownWords(kept, catalog, order);
609
+ const theirs = ownWords(listed, catalog, order);
405
610
  // An idea that names the template's family before the listed one's
406
611
  // ("a dashboard with a data table") is that family's page, unless it
407
612
  // 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;
613
+ const stays =
614
+ mine >= theirs ||
615
+ (familyAt(kept, catalog, order) < familyAt(listed, catalog, order) &&
616
+ mine >= theirs - FAMILY_SLACK);
617
+ if (!stays) return listed;
618
+ // A tie in the ranker is no preference: every table that names "table"
619
+ // scores the same, and the alphabet must not choose the page. Among the
620
+ // family's templates the ranker ties with this unlisted one, the template
621
+ // whose own descriptor best matches the idea starts (`fullerOfTie`), then
622
+ // the one most typical of the family. Only the templates' descriptors
623
+ // decide this tie, never the tables.
624
+ return fullerOfTie(kept, idea, ranked, cands, catalog);
413
625
  }
414
626
  const top = best(() => true);
415
- if (top !== SHELL) return top;
627
+ if (top !== SHELL)
628
+ return bestPage(idea, ranked, pick, catalog, weights) ?? top;
416
629
  // An idea that asks for a new page keeps the ranker's template rather than
417
630
  // the shell.
418
631
  if (newPage && kept) return kept;
@@ -420,8 +633,9 @@ export function weighStart(
420
633
  }
421
634
 
422
635
  /**
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.
636
+ * The call model's scores: the app shell's, the best non-shell template's and
637
+ * the runner-up's, with the page to start from (the pick model's choice when
638
+ * the file has one, else the call model's best page). Null without weights.
425
639
  * @param {string} idea
426
640
  * @param {import('./rank.mjs').RankedPage[]} ranked
427
641
  * @param {import('./rank.mjs').RankedPage | null} pick
@@ -440,7 +654,9 @@ export function blendSummary(idea, ranked, pick, catalog, weights) {
440
654
  rest.sort((x, y) => y.score - x.score || x.i - y.i);
441
655
  return {
442
656
  shell,
443
- best: rest[0]?.name ?? null,
657
+ best: hasPickModel(weights)
658
+ ? bestPage(idea, ranked, pick, catalog, weights)
659
+ : (rest[0]?.name ?? null),
444
660
  bestScore: rest[0]?.score ?? 0,
445
661
  secondScore: rest[1]?.score ?? 0,
446
662
  };
@@ -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";
@@ -47,6 +47,14 @@ export const SHELL_FAMILY = 'Shell';
47
47
  export const CONTAINER_PHRASE =
48
48
  /\b(?:in|inside|within)\s+(?:a|an|the)\s+([a-z-]+)(?:\s+([a-z-]+))?/gi;
49
49
 
50
+ /**
51
+ * A place phrase: a preposition of place, then a determiner ("above the
52
+ * table", "into my dashboard"). CONTAINER_PHRASE is the narrower class of
53
+ * frames a page lives in ("in a modal"); this one names where a piece goes.
54
+ */
55
+ export const PLACE_PHRASE =
56
+ /\b(?:to|into|onto|in|inside|within|on|above|below|beside|under|next to)\s+(?:the|a|an|my|our|this|each|every|existing)\b/i;
57
+
50
58
  /**
51
59
  * Where a phrase ends, for finding the word that heads it: punctuation and
52
60
  * the words that join phrases.
@@ -130,6 +138,87 @@ export function containersOf(query) {
130
138
  return found;
131
139
  }
132
140
 
141
+ /**
142
+ * A template's keywords as the units a request can match, each read with the
143
+ * caller's own word reader. A one-word keyword is that word. A longer keyword
144
+ * is one phrase unit, its words joined by single spaces: a request matches it
145
+ * only when it names those words in that order (`phrasesIn`), and its words
146
+ * never count alone. So "table of contents" on a docs page adds no "table" to
147
+ * that page, and a table request still reads as a table.
148
+ * @param {readonly string[]} keywords
149
+ * @param {(text: string) => string[]} read the caller's word reader
150
+ * @returns {string[]}
151
+ */
152
+ export function keywordUnits(keywords, read) {
153
+ return keywords.map(keyword => read(keyword).join(' ')).filter(Boolean);
154
+ }
155
+
156
+ /**
157
+ * The phrase units (two or more words) a request names: the unit's words
158
+ * appear next to each other, in order, in the request's words as the same
159
+ * reader reads them.
160
+ * @param {readonly string[]} words the request's words, in order
161
+ * @param {Iterable<string>} units
162
+ * @returns {Set<string>}
163
+ */
164
+ export function phrasesIn(words, units) {
165
+ const text = ` ${words.join(' ')} `;
166
+ const found = new Set();
167
+ for (const unit of units) {
168
+ if (unit.includes(' ') && text.includes(` ${unit} `)) found.add(unit);
169
+ }
170
+ return found;
171
+ }
172
+
173
+ /**
174
+ * The words a template's keyword units give an idea: each one-word keyword,
175
+ * and every word of each phrase keyword the idea names (`phrasesIn`). A named
176
+ * phrase carries all of its words, as the same words listed one by one would;
177
+ * a phrase the idea does not name gives none of them.
178
+ * @param {readonly string[]} units the template's keyword units (`keywordUnits`)
179
+ * @param {readonly string[]} words the idea's words, in order, read the same way
180
+ * @returns {string[]}
181
+ */
182
+ export function keywordWordsFor(units, words) {
183
+ const named = phrasesIn(words, units);
184
+ return units.flatMap(unit =>
185
+ !unit.includes(' ') ? [unit] : named.has(unit) ? unit.split(' ') : [],
186
+ );
187
+ }
188
+
189
+ /**
190
+ * What each frame of an idea holds: for every container phrase ("settings in
191
+ * a modal", "in a settings modal"), the frame's terms with the words that
192
+ * name what sits in it: the head of the phrase right before the container
193
+ * phrase, and the container phrase's own other words. In "a toggle in a modal
194
+ * on the settings page" the modal holds the toggle, not the settings page.
195
+ * @param {string} query
196
+ * @returns {Map<string, Set<string>>} frame term -> terms it holds
197
+ */
198
+ export function framesOf(query) {
199
+ const text = String(query);
200
+ /** @type {Map<string, Set<string>>} */
201
+ const held = new Map();
202
+ for (const m of text.matchAll(CONTAINER_PHRASE)) {
203
+ const frames = terms(`${m[1]} ${m[2] ?? ''}`).filter(t =>
204
+ OVERLAY_FRAMES.has(t),
205
+ );
206
+ if (frames.length === 0) continue;
207
+ const before = text.slice(0, m.index).toLowerCase().split(PHRASE_END);
208
+ const lead = terms(before[before.length - 1] ?? '');
209
+ const holds = new Set([
210
+ ...lead.slice(-1),
211
+ ...terms(`${m[1]} ${m[2] ?? ''}`).filter(t => !OVERLAY_FRAMES.has(t)),
212
+ ]);
213
+ for (const f of frames) {
214
+ const set = held.get(f) ?? new Set();
215
+ for (const t of holds) set.add(t);
216
+ held.set(f, set);
217
+ }
218
+ }
219
+ return held;
220
+ }
221
+
133
222
  /** @param {string} text */
134
223
  export const normalized = text =>
135
224
  (
@@ -163,7 +252,7 @@ export const SYNONYMS_OF = (() => {
163
252
  /**
164
253
  * @typedef {import('../_adapter.mjs').PageTemplate} PageTemplate
165
254
  * @typedef {import('../_adapter.mjs').ComponentWords} ComponentWords
166
- * @typedef {{name: string, score: number, hits: number, familyNamed: boolean, headNamed: boolean, containerMatched: boolean, family: string, base: boolean, matched: Set<string>}} RankedPage
255
+ * @typedef {{name: string, score: number, hits: number, familyNamed: boolean, headNamed: boolean, containerMatched: boolean, family: string, base: boolean, matched: Set<string>, typical: number}} RankedPage
167
256
  * @typedef {'page' | 'part' | 'edit'} IdeaKind
168
257
  */
169
258
 
@@ -27,7 +27,6 @@ InputGroupInternalContext InputGroupInternalContext InputGroup/InputGroup.doc.mj
27
27
  InternationalizationContext InternationalizationContext i18n/InternationalizationProvider.doc.mjs i18n/InternationalizationContext.ts
28
28
  ItemDescriptionContext ItemDescriptionContext Item/Item.doc.mjs Item/ItemDescriptionContext.tsx
29
29
  ItemMarkerColumnsContext ItemMarkerColumnsContext Item/Item.doc.mjs Item/ItemMarkerColumnsContext.tsx
30
- ItemSwipeLayer ItemSwipeLayer Item/Item.doc.mjs Item/ItemSwipeLayer.tsx
31
30
  LayerContext LayerContext Layer/Layer.doc.mjs Layer/LayerContext.ts
32
31
  LayerDepthContext LayerDepthContext Layer/Layer.doc.mjs Layer/LayerDepthContext.tsx
33
32
  LayerProvider LayerProvider Layer/Layer.doc.mjs Layer/LayerProvider.tsx
@@ -111,7 +110,7 @@ dataTokens dataTokens theme/MediaTheme.doc.mjs theme/domainTokens/dataTokens.ts
111
110
  dayCellUtils dayCellUtils Calendar/Calendar.doc.mjs Calendar/dayCellUtils.ts
112
111
  declarationBoundary declarationBoundary theme/MediaTheme.doc.mjs theme/declarationBoundary.ts
113
112
  defaultIcons defaultIcons Icon/Icon.doc.mjs Icon/defaultIcons.tsx
114
- defineSyntaxTheme defineSyntaxTheme theme/MediaTheme.doc.mjs theme/syntax/defineSyntaxTheme.ts
113
+ defineSyntaxTheme defineSyntaxTheme theme/syntax/useSyntaxTheme.doc.mjs theme/syntax/defineSyntaxTheme.ts
115
114
  defineTheme defineTheme theme/MediaTheme.doc.mjs theme/defineTheme.ts
116
115
  derivedVarRegistry derivedVarRegistry theme/MediaTheme.doc.mjs theme/derivedVarRegistry.ts
117
116
  dockerfile dockerfile CodeBlock/CodeBlock.doc.mjs CodeBlock/languages/dockerfile.ts
@@ -191,7 +190,7 @@ popoverOperations popoverOperations Layer/Layer.doc.mjs Layer/popoverOperations.
191
190
  powerSearchSheetUtils powerSearchSheetUtils PowerSearch/PowerSearch.doc.mjs PowerSearch/powerSearchSheetUtils.ts
192
191
  powershell powershell CodeBlock/CodeBlock.doc.mjs CodeBlock/languages/powershell.ts
193
192
  preserveAnimations preserveAnimations Layer/Layer.doc.mjs Layer/preserveAnimations.ts
194
- presets presets theme/MediaTheme.doc.mjs theme/syntax/presets.ts
193
+ presets presets theme/syntax/useSyntaxTheme.doc.mjs theme/syntax/presets.ts
195
194
  pressGroupContext pressGroupContext hooks/useAnimatedLayout.doc.mjs hooks/pressGroupContext.ts
196
195
  protocol protocol Markdown/Markdown.doc.mjs Markdown/plugins/protocol.ts
197
196
  publicContext publicContext i18n/InternationalizationProvider.doc.mjs i18n/publicContext.ts
@@ -251,7 +250,7 @@ useCalendarConstraints useCalendarConstraints Calendar/useCalendarConstraints.do
251
250
  useCalendarDays useCalendarDays Calendar/useCalendarDays.doc.mjs Calendar/hooks/useCalendarDays.ts
252
251
  useCalendarNavigation useCalendarNavigation Calendar/useCalendarNavigation.doc.mjs Calendar/hooks/useCalendarNavigation.ts
253
252
  useChatComposerTokens useChatComposerTokens Chat/Chat.doc.mjs Chat/useChatComposerTokens.ts
254
- useChatDictation useChatDictation Chat/Chat.doc.mjs Chat/useChatDictation.ts
253
+ useChatDictation useChatDictation Chat/useChatDictation.doc.mjs Chat/useChatDictation.ts
255
254
  useChatNewMessages useChatNewMessages Chat/Chat.doc.mjs Chat/useChatNewMessages.ts
256
255
  useChatPasteAsToken useChatPasteAsToken Chat/Chat.doc.mjs Chat/useChatPasteAsToken.ts
257
256
  useChatStreamScroll useChatStreamScroll Chat/Chat.doc.mjs Chat/useChatStreamScroll.ts
@@ -295,7 +294,7 @@ useSettledOpen useSettledOpen hooks/useAnimatedLayout.doc.mjs hooks/useSettledOp
295
294
  useSheetGestures useSheetGestures BottomSheet/BottomSheet.doc.mjs BottomSheet/useSheetGestures.ts
296
295
  useSliderTouch useSliderTouch Slider/Slider.doc.mjs Slider/useSliderTouch.ts
297
296
  useSpeechRecognition useSpeechRecognition Chat/Chat.doc.mjs Chat/useSpeechRecognition.ts
298
- useSwipeAction useSwipeAction Item/Item.doc.mjs Item/useSwipeAction.ts
297
+ useSwipeAction useSwipeAction Swipe/createSwipe.doc.mjs Swipe/useSwipeAction.ts
299
298
  useSwitchTouch useSwitchTouch Switch/Switch.doc.mjs Switch/useSwitchTouch.ts
300
299
  useTableCellStyles useTableCellStyles Table/Table.doc.mjs Table/useTableCellStyles.ts
301
300
  useTableColumnSettingsState useTableColumnSettingsState Table/plugins/columnSettings/useTableColumnSettingsState.doc.mjs Table/plugins/columnSettings/useTableColumnSettingsState.tsx
@@ -15,7 +15,7 @@
15
15
  * @param {string|null} opts.lang
16
16
  * @returns {Promise<ComponentListResponse>}
17
17
  */
18
- export function componentList(coreDir: string, { cwd, category, detail, zh, dense, lang }: {
18
+ export function componentList(coreDir: string, opts: {
19
19
  cwd: string;
20
20
  category?: string | undefined;
21
21
  detail: "full" | "compact" | "brief";