@astryxdesign/cli 0.7.17-canary.gcfcba64 → 0.7.17-canary.ge6fbe93

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 (265) hide show
  1. package/README.md +1 -1
  2. package/api/build/_adapter.d.mts +12 -0
  3. package/api/build/_adapter.mjs +4 -0
  4. package/api/build/build.doc.mjs +2 -2
  5. package/api/build/build.type.d.mts +2 -2
  6. package/api/build/build.type.mjs +3 -3
  7. package/api/build/kit/kind.d.mts +2 -1
  8. package/api/build/kit/kind.mjs +116 -9
  9. package/api/build/kit/kit.mjs +6 -4
  10. package/api/build/kit/rank.d.mts +4 -2
  11. package/api/build/kit/rank.mjs +69 -14
  12. package/api/build/kit/start.d.mts +5 -4
  13. package/api/build/kit/start.mjs +14 -9
  14. package/api/build/kit/weights.d.mts +23 -0
  15. package/api/build/kit/weights.mjs +130 -49
  16. package/api/build/kit/words.d.mts +5 -0
  17. package/api/build/kit/words.mjs +9 -1
  18. package/api/component/__fixtures__/resolutions/modules.txt +1 -1
  19. package/api/component/list/list.mjs +2 -1
  20. package/api/discover/_adapter.mjs +34 -1
  21. package/api/discover/discover.type.d.mts +4 -1
  22. package/api/discover/discover.type.mjs +4 -1
  23. package/api/discover/search/search.mjs +3 -2
  24. package/api/docs/_adapter.d.mts +21 -0
  25. package/api/docs/_adapter.mjs +104 -26
  26. package/api/doctor/_adapter.d.mts +8 -0
  27. package/api/doctor/_adapter.mjs +42 -4
  28. package/api/doctor/built-checks.mjs +2 -1
  29. package/api/doctor/doctor.doc.mjs +1 -1
  30. package/api/doctor/doctor.mjs +2 -2
  31. package/api/doctor/theme-checks.mjs +28 -1
  32. package/api/icon/_records.mjs +2 -1
  33. package/api/integration/authoring-checks.mjs +6 -6
  34. package/api/integration/pack-check.mjs +16 -1
  35. package/api/integration/validate-integration.d.mts +12 -2
  36. package/api/integration/validate-integration.mjs +75 -5
  37. package/api/integration/validate-integration.type.d.mts +9 -0
  38. package/api/integration/validate-integration.type.mjs +1 -1
  39. package/api/integration/validateIntegration.doc.mjs +1 -1
  40. package/api/render/_adapter.mjs +90 -17
  41. package/api/render/render.doc.mjs +1 -1
  42. package/api/render/render.type.d.mts +24 -2
  43. package/api/render/render.type.mjs +13 -2
  44. package/api/search/_adapter.d.mts +9 -0
  45. package/api/search/_adapter.mjs +85 -0
  46. package/api/search/_gather-components.d.mts +3 -2
  47. package/api/search/_gather-components.mjs +12 -3
  48. package/api/search/_lexical.d.mts +5 -0
  49. package/api/search/_lexical.mjs +8 -2
  50. package/api/search/_result.d.mts +6 -4
  51. package/api/search/_result.mjs +4 -4
  52. package/api/search/search-index.mjs +7 -1
  53. package/api/template/cdn/cdn.mjs +37 -8
  54. package/api/template/copy/copy.d.mts +6 -3
  55. package/api/template/copy/copy.mjs +42 -8
  56. package/api/template/template.doc.mjs +3 -3
  57. package/api/template/template.mjs +8 -1
  58. package/api/template/template.type.d.mts +1 -0
  59. package/api/template/template.type.mjs +1 -0
  60. package/api/theme/_adapter.d.mts +2 -1
  61. package/api/theme/_adapter.mjs +108 -13
  62. package/api/theme/build/build.d.mts +97 -3
  63. package/api/theme/build/build.mjs +395 -146
  64. package/api/theme/build/core-interception.d.mts +10 -0
  65. package/api/theme/build/core-interception.mjs +10 -0
  66. package/api/theme/build/font-warning.d.mts +66 -5
  67. package/api/theme/build/font-warning.mjs +294 -56
  68. package/api/theme/build/icon-imports.mjs +51 -9
  69. package/api/theme/remove/remove.d.mts +2 -1
  70. package/api/theme/remove/remove.mjs +3 -2
  71. package/api/theme/theme.type.d.mts +6 -0
  72. package/api/theme/theme.type.mjs +5 -1
  73. package/api/theme/themeRemove.doc.mjs +8 -5
  74. package/api/theme-edit/_adapter.d.mts +71 -8
  75. package/api/theme-edit/_adapter.mjs +517 -192
  76. package/api/theme-edit/_catalog.d.mts +20 -2
  77. package/api/theme-edit/_catalog.mjs +50 -10
  78. package/api/theme-edit/_check.d.mts +68 -2
  79. package/api/theme-edit/_check.mjs +1741 -382
  80. package/api/theme-edit/_color.d.mts +9 -0
  81. package/api/theme-edit/_color.mjs +20 -1
  82. package/api/theme-edit/_compiler.d.mts +1 -0
  83. package/api/theme-edit/_compiler.mjs +124 -15
  84. package/api/theme-edit/_context.d.mts +51 -4
  85. package/api/theme-edit/_context.mjs +337 -69
  86. package/api/theme-edit/_css.d.mts +21 -0
  87. package/api/theme-edit/_css.mjs +66 -13
  88. package/api/theme-edit/_edit.d.mts +38 -10
  89. package/api/theme-edit/_edit.mjs +2788 -530
  90. package/api/theme-edit/_how-commands.d.mts +15 -1
  91. package/api/theme-edit/_how-commands.mjs +260 -34
  92. package/api/theme-edit/_how-question.d.mts +19 -7
  93. package/api/theme-edit/_how-question.mjs +3760 -628
  94. package/api/theme-edit/_how.d.mts +2 -1
  95. package/api/theme-edit/_how.mjs +134 -38
  96. package/api/theme-edit/_importers.d.mts +38 -0
  97. package/api/theme-edit/_importers.mjs +188 -0
  98. package/api/theme-edit/_name-rule.d.mts +11 -0
  99. package/api/theme-edit/_name-rule.mjs +12 -0
  100. package/api/theme-edit/_normal.d.mts +165 -13
  101. package/api/theme-edit/_normal.mjs +945 -65
  102. package/api/theme-edit/_palette.d.mts +20 -0
  103. package/api/theme-edit/_palette.mjs +39 -1
  104. package/api/theme-edit/_part-words.d.mts +31 -0
  105. package/api/theme-edit/_part-words.mjs +126 -0
  106. package/api/theme-edit/_parts.d.mts +31 -3
  107. package/api/theme-edit/_parts.mjs +216 -32
  108. package/api/theme-edit/_preview-app.d.mts +0 -12
  109. package/api/theme-edit/_preview-app.mjs +759 -423
  110. package/api/theme-edit/_preview.d.mts +80 -19
  111. package/api/theme-edit/_preview.mjs +421 -213
  112. package/api/theme-edit/_project.d.mts +61 -1
  113. package/api/theme-edit/_project.mjs +177 -6
  114. package/api/theme-edit/_settings.d.mts +404 -75
  115. package/api/theme-edit/_settings.mjs +2433 -656
  116. package/api/theme-edit/_tables.d.mts +29 -3
  117. package/api/theme-edit/_tables.mjs +186 -48
  118. package/api/theme-edit/_vet.d.mts +31 -0
  119. package/api/theme-edit/_vet.mjs +114 -8
  120. package/api/theme-edit/theme-edit.type.d.mts +7 -1
  121. package/api/theme-edit/theme-edit.type.mjs +2 -2
  122. package/api/theme-edit/themeEditHow.doc.mjs +1 -1
  123. package/api/theme-edit/themeEditNew.doc.d.mts +0 -1
  124. package/api/theme-edit/themeEditNew.doc.mjs +7 -4
  125. package/api/theme-edit/themeEditPreviewApp.doc.mjs +1 -1
  126. package/api/theme-edit/themeEditPreviewRemove.doc.mjs +2 -2
  127. package/api/upgrade/run/run.mjs +4 -3
  128. package/assets/codemods/integration-discovery.mjs +2 -1
  129. package/assets/component-list.generated.json +1 -1
  130. package/assets/docs/theme.doc.dense.mjs +76 -7
  131. package/assets/docs/theme.doc.mjs +59 -2
  132. package/assets/docs/theme.doc.zh.mjs +51 -1
  133. package/assets/docs/tree/checks.doc.mjs +1 -1
  134. package/assets/docs/tree/document-the-theme.doc.mjs +1 -1
  135. package/assets/docs/tree/font-setup.doc.mjs +1 -1
  136. package/assets/docs/tree/fonts-and-assets.doc.mjs +1 -1
  137. package/assets/docs/tree/render-pages.doc.mjs +4 -4
  138. package/assets/docs/tree/share-a-page.doc.mjs +157 -0
  139. package/assets/docs/use-a-theme.doc.mjs +1 -1
  140. package/assets/docs.generated.json +2 -2
  141. package/assets/search-catalog.generated.json +2 -0
  142. package/assets/self-audit.generated.json +1 -1
  143. package/assets/templates/blocks/components/ChatComposerInput/useSpeechRecognitionHookUsage.doc.mjs +14 -0
  144. package/assets/templates/blocks/components/ChatComposerInput/useSpeechRecognitionHookUsage.tsx +43 -0
  145. package/assets/templates/blocks/components/Hooks/useContainerRevealHookUsage.tsx +2 -2
  146. package/assets/templates/components.generated.json +1 -1
  147. package/assets/templates/pages/ai-chat-landing/template.doc.mjs +3 -0
  148. package/assets/theme.template.ts +9 -2
  149. package/authoring/doctypes/_schema.d.mts +6 -6
  150. package/authoring/doctypes/component/categories.d.mts +37 -0
  151. package/authoring/doctypes/component/categories.mjs +54 -0
  152. package/clients/cli/build-id.generated.json +1 -1
  153. package/clients/cli/commands/component.mjs +2 -1
  154. package/clients/cli/commands/docs.mjs +41 -5
  155. package/clients/cli/commands/doctor.mjs +10 -0
  156. package/clients/cli/commands/experimental/render.mjs +10 -0
  157. package/clients/cli/commands/experimental/theme.mjs +662 -105
  158. package/clients/cli/commands/experimental-theme-compile.doc.mjs +2 -2
  159. package/clients/cli/commands/experimental-theme-editor-how.doc.mjs +87 -1
  160. package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +10 -3
  161. package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +2 -2
  162. package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +2 -2
  163. package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +2 -2
  164. package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +2 -2
  165. package/clients/cli/commands/experimental-theme-preview-remove.doc.mjs +2 -2
  166. package/clients/cli/commands/experimental-theme-preview.doc.mjs +2 -1
  167. package/clients/cli/commands/experimental-theme-remove.doc.mjs +4 -4
  168. package/clients/cli/commands/experimental-theme.doc.mjs +5 -1
  169. package/clients/cli/commands/template.doc.mjs +1 -1
  170. package/clients/cli/commands/template.mjs +11 -0
  171. package/clients/cli/commands/theme-remove.doc.mjs +13 -5
  172. package/clients/cli/commands/theme.mjs +767 -557
  173. package/clients/cli/lib/cli-error.mjs +2 -1
  174. package/clients/cli/lib/json-shim.mjs +135 -24
  175. package/clients/cli/lib/manifest.mjs +3 -2
  176. package/clients/cli/manifest.generated.json +1 -1
  177. package/foundation/agent-docs/agent-docs.mjs +1 -1
  178. package/foundation/config/theme-state.d.mts +19 -2
  179. package/foundation/config/theme-state.mjs +93 -1
  180. package/foundation/discovery/component-discovery.mjs +5 -4
  181. package/foundation/discovery/copied-passages.mjs +2 -1
  182. package/foundation/discovery/core-component-docs.d.mts +29 -0
  183. package/foundation/discovery/core-component-docs.mjs +83 -0
  184. package/foundation/discovery/doc-types.mjs +4 -3
  185. package/foundation/discovery/docs-discovery.d.mts +8 -9
  186. package/foundation/discovery/docs-discovery.mjs +14 -47
  187. package/foundation/discovery/hook-discovery.mjs +2 -1
  188. package/foundation/discovery/icon-definition-discovery.mjs +2 -1
  189. package/foundation/discovery/icon-set-checks.mjs +2 -1
  190. package/foundation/discovery/icon-set-discovery.mjs +2 -1
  191. package/foundation/discovery/integration-doc-files.mjs +2 -1
  192. package/foundation/discovery/module-exports.d.mts +14 -1
  193. package/foundation/discovery/module-exports.mjs +62 -14
  194. package/foundation/discovery/prop-drift.mjs +9 -9
  195. package/foundation/discovery/stored-search-catalog.d.mts +115 -0
  196. package/foundation/discovery/stored-search-catalog.mjs +297 -0
  197. package/foundation/discovery/template-adapter.d.mts +6 -1
  198. package/foundation/discovery/template-adapter.mjs +6 -2
  199. package/foundation/discovery/template-icons.mjs +2 -1
  200. package/foundation/discovery/theme-discovery.mjs +31 -4
  201. package/foundation/discovery/theming-targets.d.mts +6 -5
  202. package/foundation/discovery/theming-targets.mjs +31 -47
  203. package/foundation/doc-compiler/inputs.mjs +3 -2
  204. package/foundation/env/semver.mjs +3 -1
  205. package/foundation/fonts/font-stylesheet.d.mts +38 -0
  206. package/foundation/fonts/font-stylesheet.mjs +146 -0
  207. package/foundation/fs/exact-codec.d.mts +12 -2
  208. package/foundation/fs/exact-codec.mjs +23 -6
  209. package/foundation/fs/file-protection.mjs +4 -3
  210. package/foundation/fs/gather-cache.d.mts +37 -0
  211. package/foundation/fs/gather-cache.mjs +357 -41
  212. package/foundation/fs/glob.d.mts +16 -0
  213. package/foundation/fs/glob.mjs +105 -0
  214. package/foundation/fs/module-loader.d.mts +6 -0
  215. package/foundation/fs/module-loader.mjs +2 -1
  216. package/foundation/fs/path-safety.d.mts +11 -2
  217. package/foundation/fs/path-safety.mjs +108 -18
  218. package/foundation/fs/paths.d.mts +18 -0
  219. package/foundation/fs/paths.mjs +15 -2
  220. package/foundation/fs/read-record.d.mts +9 -0
  221. package/foundation/fs/read-record.mjs +19 -11
  222. package/foundation/fs/stop-cleanup.d.mts +12 -0
  223. package/foundation/fs/stop-cleanup.mjs +66 -0
  224. package/foundation/integrations/contribution-inventory.mjs +4 -3
  225. package/foundation/integrations/pack-state.d.mts +73 -0
  226. package/foundation/integrations/pack-state.mjs +284 -0
  227. package/foundation/integrations/public-imports.mjs +2 -1
  228. package/foundation/integrations/shipped-imports.d.mts +122 -0
  229. package/foundation/integrations/shipped-imports.mjs +497 -0
  230. package/foundation/integrations/validate-contributions.d.mts +0 -17
  231. package/foundation/integrations/validate-contributions.mjs +6 -260
  232. package/foundation/render/assets.mjs +40 -6
  233. package/foundation/render/charts.d.mts +78 -27
  234. package/foundation/render/charts.mjs +266 -90
  235. package/foundation/render/embedded-files.mjs +17 -4
  236. package/foundation/render/embedded-imports.d.mts +56 -3
  237. package/foundation/render/embedded-imports.mjs +108 -20
  238. package/foundation/render/file-header.d.mts +2 -2
  239. package/foundation/render/file-header.mjs +1 -1
  240. package/foundation/render/markup-edits.d.mts +1 -1
  241. package/foundation/render/markup-edits.mjs +1 -1
  242. package/foundation/render/offline.d.mts +32 -0
  243. package/foundation/render/offline.mjs +56 -0
  244. package/foundation/render/page-worker.mjs +121 -8
  245. package/foundation/render/picture-chrome.d.mts +4 -0
  246. package/foundation/render/picture-chrome.mjs +192 -0
  247. package/foundation/render/picture-playwright.d.mts +4 -0
  248. package/foundation/render/picture-playwright.mjs +46 -0
  249. package/foundation/render/rebuild.mjs +2 -1
  250. package/foundation/render/render-page.d.mts +33 -2
  251. package/foundation/render/render-page.mjs +442 -103
  252. package/foundation/render/source-block.d.mts +6 -2
  253. package/foundation/render/source-block.mjs +31 -9
  254. package/foundation/render/ts-paths.d.mts +21 -5
  255. package/foundation/render/ts-paths.mjs +56 -15
  256. package/foundation/response/response-types.doc.mjs +2 -2
  257. package/foundation/text/compare-text.d.mts +14 -0
  258. package/foundation/text/compare-text.mjs +68 -0
  259. package/foundation/text/css-escape.d.mts +18 -0
  260. package/foundation/text/css-escape.mjs +35 -0
  261. package/foundation/text/string-utils.mjs +2 -1
  262. package/foundation/text/suggest-order.mjs +2 -1
  263. package/foundation/xle/browser.d.mts +2 -2
  264. package/foundation/xle/expand.mjs +2 -1
  265. package/package.json +6 -6
package/README.md CHANGED
@@ -507,7 +507,7 @@ Every response has a `type` discriminant. The full set is below (generated from
507
507
  | `template.list` | The effective discovered TemplateListEntry[] for pages and blocks. A winning replacement entry includes optional `replaces`, naming the Core id omitted from the default list. |
508
508
  | `template.show` | The resolved template's source, exactly as a copy writes it, plus its description, kind, the component names it composes, and demoMediaReplaced (how many Astryx demo media references were replaced with placeholders for you to swap for your own media), and demoContentReplaced (how many Astryx docs-only demo content elements were replaced with a Text placeholder for your own content). |
509
509
  | `template.skeleton` | A layout skeleton (structural tags with spatial annotations) plus the template's description and the components it composes. The envelope's package names the npm package that owns the template. |
510
- | `template.copy` | A scaffold receipt: template id, output directory, written file name, file count, demoMediaReplaced (how many Astryx demo media references were replaced with placeholders), demoContentReplaced (how many Astryx docs-only demo content elements were replaced with a Text placeholder), notes (setup notes naming what the template needs that the project lacks — missing packages, missing StyleX compiler; empty when satisfied), missingPackages (external package names the template imports that are not in the project), and installCommand (a ready-to-run install command with the detected package manager and workspace version ranges; null when nothing is missing, or when several lockfiles leave the package manager undetermined). The envelope's package names the npm package that owns the template. |
510
+ | `template.copy` | A scaffold receipt: template id, output directory, written file name, file count, givenPath (optional; the absolute path as given, present only when it was inside the project), demoMediaReplaced (how many Astryx demo media references were replaced with placeholders), demoContentReplaced (how many Astryx docs-only demo content elements were replaced with a Text placeholder), notes (setup notes naming what the template needs that the project lacks — missing packages, missing StyleX compiler; empty when satisfied), missingPackages (external package names the template imports that are not in the project), and installCommand (a ready-to-run install command with the detected package manager and workspace version ranges; null when nothing is missing, or when several lockfiles leave the package manager undetermined). The envelope's package names the npm package that owns the template. |
511
511
  | `template.cdn` | A write receipt for the no-build-step CDN starter page: the path (relative to cwd), the Astryx version every CDN URL was pinned to, whether it was written, and the reason it was not. `exists` when a file was already there, which is a success. |
512
512
  | `hook.list` | The hook catalog grouped by category: `detail` (the level: names \| compact \| full) and `components`, the grouped map of hook names, brief entries, or a full HookDoc per entry. The envelope's package is @astryxdesign/core, the only package that ships hooks. |
513
513
  | `hook.detail` | One hook's full authored HookDoc. The envelope's package is @astryxdesign/core. |
@@ -13,12 +13,15 @@
13
13
  * @property {string[]} keywords The ideas the page serves, as its own descriptor names them; empty when it declares none.
14
14
  * @property {string} filePath Absolute path to the template source file on disk.
15
15
  * @property {string[]} components The components its page composes, read from its source on first use; empty when the source cannot be read.
16
+ * @property {boolean} hidden The template's own `isHiddenFromOverview`: kept off the gallery, so never taken as the app shell.
16
17
  */
17
18
  /**
18
19
  * A component the project can use, as the ranker reads it.
19
20
  * @typedef {object} ComponentWords
20
21
  * @property {string} name The component's name, e.g. `DateRangeInput`.
21
22
  * @property {string[]} keywords The keywords its own doc declares.
23
+ * @property {string} [category] The category its own doc files it under,
24
+ * e.g. `Table & List`.
22
25
  */
23
26
  /**
24
27
  * Every ready page template the project can scaffold, in discovery order. This
@@ -163,6 +166,10 @@ export type PageTemplate = {
163
166
  * The components its page composes, read from its source on first use; empty when the source cannot be read.
164
167
  */
165
168
  components: string[];
169
+ /**
170
+ * The template's own `isHiddenFromOverview`: kept off the gallery, so never taken as the app shell.
171
+ */
172
+ hidden: boolean;
166
173
  };
167
174
  /**
168
175
  * A component the project can use, as the ranker reads it.
@@ -176,6 +183,11 @@ export type ComponentWords = {
176
183
  * The keywords its own doc declares.
177
184
  */
178
185
  keywords: string[];
186
+ /**
187
+ * The category its own doc files it under,
188
+ * e.g. `Table & List`.
189
+ */
190
+ category?: string | undefined;
179
191
  };
180
192
  /**
181
193
  * A block the kit can name, as search names a block result.
@@ -50,6 +50,7 @@ export {withListingCache} from '../../foundation/fs/listing-cache.mjs';
50
50
  * @property {string[]} keywords The ideas the page serves, as its own descriptor names them; empty when it declares none.
51
51
  * @property {string} filePath Absolute path to the template source file on disk.
52
52
  * @property {string[]} components The components its page composes, read from its source on first use; empty when the source cannot be read.
53
+ * @property {boolean} hidden The template's own `isHiddenFromOverview`: kept off the gallery, so never taken as the app shell.
53
54
  */
54
55
 
55
56
  /**
@@ -57,6 +58,8 @@ export {withListingCache} from '../../foundation/fs/listing-cache.mjs';
57
58
  * @typedef {object} ComponentWords
58
59
  * @property {string} name The component's name, e.g. `DateRangeInput`.
59
60
  * @property {string[]} keywords The keywords its own doc declares.
61
+ * @property {string} [category] The category its own doc files it under,
62
+ * e.g. `Table & List`.
60
63
  */
61
64
 
62
65
  /**
@@ -111,6 +114,7 @@ export async function loadTemplates(cwd) {
111
114
  package: t.package ?? '@astryxdesign/core',
112
115
  category: t.category || '',
113
116
  keywords: t.keywords ?? [],
117
+ hidden: t.hidden === true,
114
118
  filePath: t.filePath,
115
119
  // The id `template()` resolves back to this entry: an active
116
120
  // replacement owns the Core id it names, so that id selects it.
@@ -19,7 +19,7 @@ export const doc = {
19
19
  'The "build a page" entry point. Called with no query it returns the ' +
20
20
  'how-to-build-a-page playbook as data: the workflow steps with their ' +
21
21
  'commands, the on-system rules, and related lookups. Called with a query it names the page template to ' +
22
- 'START from (always one: the page template a ranker built for long descriptions puts first; for a part ' +
22
+ "START from (always one: for a whole page, the template its page-pick model chooses from the page ranker's list and its own word tables, or the app shell when its word weights call the shell; for a part " +
23
23
  'of a page, the page it names; else the app shell, unless the idea reads as a whole page, which starts ' +
24
24
  'from the closest page template) and the next two templates, ' +
25
25
  'and the unified search grouped around it: the other close page templates, drop-in blocks, and ' +
@@ -65,7 +65,7 @@ export const doc = {
65
65
  {
66
66
  type: 'build.kit',
67
67
  description:
68
- "The page template to start from and the kit around it: the echoed query, hasResults/matchCount/directMatch fields, `start` (the template to scaffold, the `template <id> --type page <path>` command that selects it, whether the page ranker's pick is also search's direct match, the closest page, or the fallback app shell, the ranker's next two `alternatives`, and optional `notes` — setup notes naming what the template needs that the project lacks, such as missing packages or a missing StyleX compiler), search's closest page templates (≤3), drop-in block patterns (≤5), idea-specific components/hooks (≤6), and the always-on frame + foundation component-name arrays. Carries `hint` only when the kit came back thin — what to try instead, so a caller does not read a near-empty kit as \"the package has nothing\".",
68
+ 'The page template to start from and the kit around it: the echoed query, hasResults/matchCount/directMatch fields, `start` (the template to scaffold, the `template <id> --type page <path>` command that selects it, whether the start is also search\'s direct match, the closest page, or the fallback app shell, the next two `alternatives` in the order the start is chosen from, and optional `notes` — setup notes naming what the template needs that the project lacks, such as missing packages or a missing StyleX compiler), search\'s closest page templates (≤3), drop-in block patterns (≤5), idea-specific components/hooks (≤6), and the always-on frame + foundation component-name arrays. Carries `hint` only when the kit came back thin — what to try instead, so a caller does not read a near-empty kit as "the package has nothing".',
69
69
  },
70
70
  ],
71
71
  throws: [
@@ -69,7 +69,7 @@ export type BuildStart = {
69
69
  */
70
70
  command: string;
71
71
  /**
72
- * Why this template. The page ranker picks every start: it weighs each matched word by how rare it is among page templates, favors the family the idea's head names and the container it names ("in a modal"), and discounts words that only modify another. `direct` when its pick is also search's direct match (`directMatch`); `closest` when it is not; `fallback` when no template has the evidence to lead and the page starts from the app shell.
72
+ * Why this template. The page ranker orders the page templates: it weighs each matched word by how rare it is among page templates, favors the family the idea's head names and the container it names ("in a modal"), and discounts words that only modify another. For a part or an edit, the start is where the ranker's placement rules put it; for a whole page, checked-in word weights decide page or app shell and a page-pick model chooses the page from the ranker's list and its own word tables, so the start can differ from the ranker's first template. `direct` when the start is also search's direct match (`directMatch`); `closest` when it is not; `fallback` when the page starts from the app shell.
73
73
  */
74
74
  basis: "direct" | "closest" | "fallback";
75
75
  /**
@@ -77,7 +77,7 @@ export type BuildStart = {
77
77
  */
78
78
  reason: string;
79
79
  /**
80
- * The ranker's next closest page templates (≤2), for when the start's layout is wrong.
80
+ * The next closest page templates (≤2), for when the start's layout is wrong: for a whole page in the page-pick model's order, else in the ranker's.
81
81
  */
82
82
  alternatives: BuildAlternative[];
83
83
  /**
@@ -44,9 +44,9 @@
44
44
  * @property {string} description What the page is: its layout and the ideas it serves.
45
45
  * @property {string} package The npm package that owns this template.
46
46
  * @property {string} command The scaffold command that selects exactly this template, `astryx template <id> --type page <path>`: `<id>` is the Core id an integration replacement stands in for, else the template's own id, `<path>` is a placeholder for the file or folder to write the template to, and the `astryx` prefix is for the caller to replace with its own invocation.
47
- * @property {'direct' | 'closest' | 'fallback'} basis Why this template. The page ranker picks every start: it weighs each matched word by how rare it is among page templates, favors the family the idea's head names and the container it names ("in a modal"), and discounts words that only modify another. `direct` when its pick is also search's direct match (`directMatch`); `closest` when it is not; `fallback` when no template has the evidence to lead and the page starts from the app shell.
47
+ * @property {'direct' | 'closest' | 'fallback'} basis Why this template. The page ranker orders the page templates: it weighs each matched word by how rare it is among page templates, favors the family the idea's head names and the container it names ("in a modal"), and discounts words that only modify another. For a part or an edit, the start is where the ranker's placement rules put it; for a whole page, checked-in word weights decide page or app shell and a page-pick model chooses the page from the ranker's list and its own word tables, so the start can differ from the ranker's first template. `direct` when the start is also search's direct match (`directMatch`); `closest` when it is not; `fallback` when the page starts from the app shell.
48
48
  * @property {string} reason One sentence saying the same as `basis`, for a reader.
49
- * @property {BuildAlternative[]} alternatives The ranker's next closest page templates (≤2), for when the start's layout is wrong.
49
+ * @property {BuildAlternative[]} alternatives The next closest page templates (≤2), for when the start's layout is wrong: for a whole page in the page-pick model's order, else in the ranker's.
50
50
  * @property {string[]} [notes] Setup notes: what the template needs that the project lacks (missing packages, missing StyleX compiler). Present only when the start template imports packages the project does not have or needs a StyleX compiler the project has not configured.
51
51
  */
52
52
 
@@ -75,7 +75,7 @@
75
75
  * @property {boolean} data.hasResults False when search returned nothing. The kit still names a template in `start`.
76
76
  * @property {number} data.matchCount Total ranked search matches for the query — counted before the search `limit`, the kit's score floors, and its per-group caps, so it is never a cap read back.
77
77
  * @property {boolean} data.directMatch True when the top page template is a confident direct match.
78
- * @property {BuildStart | null} data.start The page template to start from: the ranker's pick, else the app shell. Null only when the kit is narrowed to components or hooks (`type`), or when the project has no page template to offer.
78
+ * @property {BuildStart | null} data.start The page template to start from (see `BuildStart.basis`), else the app shell. Null only when the kit is narrowed to components or hooks (`type`), or when the project has no page template to offer.
79
79
  * @property {import('../search/search.type.mjs').SearchResultEntry[]} data.pages Closest page templates by search (≤3). Each entry's `command` carries `--skeleton` when `directMatch` is false, so it previews the layout; `start.command` is the scaffold.
80
80
  * @property {import('../search/search.type.mjs').SearchResultEntry[]} data.blocks Drop-in block patterns covering parts of the idea (≤5), best first. A block search returned keeps search's score and reason; any other block carries the block picker's relative score (100 for its best candidate, never below 1) and reason, so the two kinds of score are not comparable.
81
81
  * @property {import('../search/search.type.mjs').SearchResultEntry[]} data.domain Idea-specific components/hooks (≤6), excluding frame/foundation.
@@ -4,7 +4,8 @@
4
4
  /**
5
5
  * What an idea asks for (spec:AST-048/FR3): a whole `page`; a `part` of one,
6
6
  * when its head noun names one of the system's components and it lists fewer
7
- * than PAGE_PIECES pieces; or an `edit` of a page the builder already has.
7
+ * than PAGE_PIECES pieces or only that component's contents; or an `edit` of a
8
+ * page the builder already has.
8
9
  *
9
10
  * @param {string} query
10
11
  * @param {PageTemplate[]} pages
@@ -8,7 +8,10 @@
8
8
  * not a page, and the system's own components say what a part is: an idea
9
9
  * whose head noun is a word of a component's name or keywords, Core's or an
10
10
  * integration's, asks for that part, unless the noun is a family word ("a data
11
- * table") or the idea lists a page's worth of pieces. Words search drops as
11
+ * table") or the idea lists a page's worth of pieces. A component named with
12
+ * its listed contents ("a side panel with an owner, a status, and a history")
13
+ * is still one part, unless the component holds records: its category declares
14
+ * a page family (a list, a table). Words search drops as
12
15
  * stopwords ("page", "screen", "app", "view") name no component, so "a calendar
13
16
  * page" asks for a page and "a calendar" for a part. A part starts from the
14
17
  * base template of the family the idea names ("an empty state for a settings
@@ -26,6 +29,7 @@
26
29
  * new dashboard").
27
30
  */
28
31
 
32
+ import {COMPONENT_CATEGORIES} from '../../../authoring/doctypes/component/categories.mjs';
29
33
  import {stem} from '../../search/search.mjs';
30
34
  import {
31
35
  HEAD_END,
@@ -46,7 +50,7 @@ import {
46
50
  /**
47
51
  * How many listed pieces make an idea a page: a part is one thing with a detail
48
52
  * or two ("a status pill with a tooltip"), while three pieces, two commas
49
- * apart, describe a page.
53
+ * apart, describe a page, unless they are one component's contents.
50
54
  */
51
55
  const PAGE_PIECES = 3;
52
56
 
@@ -71,7 +75,8 @@ const NEW = /\bnew\b/;
71
75
  /**
72
76
  * What an idea asks for (spec:AST-048/FR3): a whole `page`; a `part` of one,
73
77
  * when its head noun names one of the system's components and it lists fewer
74
- * than PAGE_PIECES pieces; or an `edit` of a page the builder already has.
78
+ * than PAGE_PIECES pieces or only that component's contents; or an `edit` of a
79
+ * page the builder already has.
75
80
  *
76
81
  * @param {string} query
77
82
  * @param {PageTemplate[]} pages
@@ -87,21 +92,123 @@ export function ideaKind(query, pages, components) {
87
92
  // calendar", "page" the noun of "a calendar page". An overlay frame names
88
93
  // where the thing lives, not the thing: "drafts" is the noun of "drafts in
89
94
  // a modal".
90
- const head = (text.split(HEAD_END)[0] ?? '').replace(CONTAINER_PHRASE, m =>
95
+ const rawHead = text.split(HEAD_END)[0] ?? '';
96
+ const head = rawHead.replace(CONTAINER_PHRASE, m =>
91
97
  containersOf(m).size > 0 ? ' ' : m,
92
98
  );
93
- const words = (head.toLowerCase().match(/[a-z0-9]+/g) ?? []).filter(
94
- w => w.length >= 2,
95
- );
96
- const noun = stem(words[words.length - 1] ?? '');
99
+ const noun = lastNoun(head);
97
100
  if (familyWords.has(noun)) return 'page';
101
+ const holdsRecords = (/** @type {string} */ word) =>
102
+ namedComponents(word, components).some(c => namesFamily(c, familyWords));
103
+ if (
104
+ describesOnePart(text, rawHead, noun, familyWords, components) &&
105
+ !holdsRecords(noun)
106
+ )
107
+ return 'part';
98
108
  const pieces = (text.match(/,/g) ?? []).length + 1;
99
109
  if (pieces >= PAGE_PIECES) return 'page';
100
- return components.some(c => componentTerms(c).includes(noun))
110
+ const namesPart = (/** @type {string} */ word) =>
111
+ components.some(c => componentTerms(c).includes(word));
112
+ if (!namesPart(noun)) return 'page';
113
+ // A component that holds records, followed by "of", is a page of those
114
+ // records ("a list of jobs"), unless what follows names a component ("a list
115
+ // of buttons") or a page family ("a list of settings toggles").
116
+ if (!holdsRecords(noun) || !endsOnOf(text)) return 'part';
117
+ const phrase = madeOf(text);
118
+ return terms(phrase).some(t => familyWords.has(t)) ||
119
+ namesPart(lastNoun(phrase))
101
120
  ? 'part'
102
121
  : 'page';
103
122
  }
104
123
 
124
+ /**
125
+ * Whether an idea describes one part and its contents: its head names a
126
+ * component by name and ends on a word ("a side panel with a, b and c"), not
127
+ * on a comma or a colon that starts a list of peers, and no word of the idea
128
+ * names a page family. Such an idea is a part however many pieces it lists.
129
+ * @param {string} text
130
+ * @param {string} head the idea's head, before any frame is removed
131
+ * @param {string} noun
132
+ * @param {Map<string, string>} familyWords
133
+ * @param {ComponentWords[]} components
134
+ * @returns {boolean}
135
+ */
136
+ function describesOnePart(text, head, noun, familyWords, components) {
137
+ const end = text.slice(head.length).match(/^\s*([a-z]+)/i);
138
+ return (
139
+ end !== null &&
140
+ components.some(c => nameTerms(c).includes(noun)) &&
141
+ !terms(text).some(t => familyWords.has(t))
142
+ );
143
+ }
144
+
145
+ /**
146
+ * The components a word names: the one whose whole name is the word
147
+ * ("button" names Button), else every component whose name holds it.
148
+ * @param {string} word
149
+ * @param {ComponentWords[]} components
150
+ * @returns {ComponentWords[]}
151
+ */
152
+ function namedComponents(word, components) {
153
+ const whole = components.filter(c => {
154
+ const name = nameTerms(c);
155
+ return name.length === 1 && name[0] === word;
156
+ });
157
+ return whole.length > 0
158
+ ? whole
159
+ : components.filter(c => nameTerms(c).includes(word));
160
+ }
161
+
162
+ /**
163
+ * Whether a component's doc files it under a category that declares a page
164
+ * family the project has ("Table & List" declares the table family): such a
165
+ * component holds the records a page of that family shows.
166
+ * @param {ComponentWords} component
167
+ * @param {Map<string, string>} familyWords
168
+ * @returns {boolean}
169
+ */
170
+ function namesFamily(component, familyWords) {
171
+ const family = Object.hasOwn(COMPONENT_CATEGORIES, component.category ?? '')
172
+ ? COMPONENT_CATEGORIES[component.category ?? ''].pageFamily
173
+ : undefined;
174
+ return family !== undefined && [...familyWords.values()].includes(family);
175
+ }
176
+
177
+ /**
178
+ * The stem of a phrase's last word.
179
+ * @param {string} phrase
180
+ * @returns {string}
181
+ */
182
+ function lastNoun(phrase) {
183
+ const words = (phrase.toLowerCase().match(/[a-z0-9]+/g) ?? []).filter(
184
+ w => w.length >= 2,
185
+ );
186
+ return stem(words[words.length - 1] ?? '');
187
+ }
188
+
189
+ /**
190
+ * Whether an idea's head ends on "of" ("a list of jobs").
191
+ * @param {string} text
192
+ * @returns {boolean}
193
+ */
194
+ function endsOnOf(text) {
195
+ return text.match(HEAD_END)?.[0].toLowerCase() === 'of';
196
+ }
197
+
198
+ /**
199
+ * What a head that ends on "of" is made of: the phrase after "of", up to the
200
+ * next head end, without an overlay frame.
201
+ * @param {string} text
202
+ * @returns {string}
203
+ */
204
+ function madeOf(text) {
205
+ const end = text.match(HEAD_END);
206
+ const rest = text.slice((end?.index ?? 0) + (end?.[0].length ?? 0));
207
+ return (rest.split(HEAD_END)[0] ?? '').replace(CONTAINER_PHRASE, m =>
208
+ containersOf(m).size > 0 ? ' ' : m,
209
+ );
210
+ }
211
+
105
212
  /**
106
213
  * Whether an idea adds a piece to a page the builder already has: it opens
107
214
  * with "add", says where the piece goes with a place phrase that names
@@ -3,10 +3,12 @@
3
3
  /**
4
4
  * @file build.kit leaf — the page template to start from, and the kit around it.
5
5
  *
6
- * Every kit names a page template to START from: the page the page ranker
7
- * (rank.mjs) puts first when it has the evidence to lead, else the app shell.
8
- * The ranker is the only thing that picks the start, so one noisy signal —
9
- * search matching "site" to a gallery's "side" — cannot choose the page. A
6
+ * Every kit names a page template to START from, else the app shell. The page
7
+ * ranker (rank.mjs) orders the page templates; for a whole page the word
8
+ * weights (weights.mjs) decide page or shell and the page-pick model chooses
9
+ * the page from that list (start.mjs). Search's own matches never choose the
10
+ * start, so one noisy signal — search matching "site" to a gallery's "side" —
11
+ * cannot choose the page. A
10
12
  * template carries the page frame, the spacing, and the section rhythm; a page
11
13
  * composed from components carries none of that, so the kit never recommends
12
14
  * composing from scratch while a template exists. Next to the start it names
@@ -2,8 +2,10 @@
2
2
  // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
3
 
4
4
  /**
5
- * Rank page templates against an idea, best first. Ties go to the template
6
- * with the shorter id (the family's broader page), then by name.
5
+ * Rank page templates against an idea, best first. An exact tie goes to a
6
+ * family's base template ahead of a variant; templates still tied are ordered
7
+ * by how strongly each one's own descriptor answers the idea, then by how
8
+ * typical of its family it is, then by name (`settleTies`).
7
9
  *
8
10
  * @param {string} query
9
11
  * @param {PageTemplate[]} pages
@@ -23,7 +23,10 @@
23
23
  * "board" picks the kanban board for a game board. Here every matched term
24
24
  * counts, weighted by how rare it is among page templates (inverse document
25
25
  * frequency), so the page that answers more of the idea — and its rarer words —
26
- * wins. Structural signals sit on top:
26
+ * wins. Structural signals sit on top. They order the ranker's list; for a
27
+ * whole page, the page-pick model in weights.mjs reads that list beside its
28
+ * own word tables and picks the start, so the start can differ from the
29
+ * ranker's first template:
27
30
  *
28
31
  * - The head noun. The words before the first "with", ":" or "," name what
29
32
  * the page is ("audit dashboard: dense table with …"); a family word there
@@ -50,7 +53,7 @@
50
53
 
51
54
  import {
52
55
  HEAD_END,
53
- SHELL_FAMILY,
56
+ isAppShell,
54
57
  terms,
55
58
  modifiersOf,
56
59
  pairsOf,
@@ -62,6 +65,8 @@ import {
62
65
  keywordWordsFor,
63
66
  framesOf,
64
67
  } from './words.mjs';
68
+ import {namedOutright, tieReading} from './weights.mjs';
69
+ import {compareText} from '../../../foundation/text/compare-text.mjs';
65
70
 
66
71
  /**
67
72
  * @typedef {import('./words.mjs').PageTemplate} PageTemplate
@@ -131,8 +136,10 @@ const START_SCORE = 10;
131
136
  const START_TERMS = 2;
132
137
 
133
138
  /**
134
- * Rank page templates against an idea, best first. Ties go to the template
135
- * with the shorter id (the family's broader page), then by name.
139
+ * Rank page templates against an idea, best first. An exact tie goes to a
140
+ * family's base template ahead of a variant; templates still tied are ordered
141
+ * by how strongly each one's own descriptor answers the idea, then by how
142
+ * typical of its family it is, then by name (`settleTies`).
136
143
  *
137
144
  * @param {string} query
138
145
  * @param {PageTemplate[]} pages
@@ -283,20 +290,67 @@ export function rankPages(query, pages) {
283
290
  family,
284
291
  base,
285
292
  matched,
293
+ hidden: page.hidden === true,
286
294
  };
287
295
  })
288
- .sort(
289
- (a, b) =>
290
- b.score - a.score ||
291
- a.name.split('-').length - b.name.split('-').length ||
292
- a.name.localeCompare(b.name),
293
- );
294
- return baseFirst(ranked);
296
+ .sort((a, b) => b.score - a.score || Number(b.base) - Number(a.base));
297
+ return baseFirst(settleTies(ranked, query, pages));
298
+ }
299
+
300
+ /**
301
+ * Order each run of templates the ranker scores exactly the same (and that
302
+ * are all bases or all variants), whatever their families: first the one the
303
+ * idea names by its whole name (`namedOutright`), then by how strongly each
304
+ * one's own descriptor answers the idea (`tieReading`), then by how typical of
305
+ * its family it is, then by name. The catalog's order never decides, and
306
+ * neither does the host's locale.
307
+ * @param {RankedPage[]} ranked sorted by score, then base first
308
+ * @param {string} query
309
+ * @param {PageTemplate[]} pages
310
+ * @returns {RankedPage[]}
311
+ */
312
+ function settleTies(ranked, query, pages) {
313
+ const out = [];
314
+ for (let i = 0; i < ranked.length;) {
315
+ let j = i + 1;
316
+ while (
317
+ j < ranked.length &&
318
+ ranked[j].score === ranked[i].score &&
319
+ ranked[j].base === ranked[i].base
320
+ )
321
+ j++;
322
+ const run = ranked.slice(i, j);
323
+ if (run.length > 1) {
324
+ const reading = tieReading(
325
+ run.map(r => r.name),
326
+ query,
327
+ pages,
328
+ );
329
+ const named = namedOutright(
330
+ run.map(r => r.name),
331
+ query,
332
+ pages,
333
+ );
334
+ const at = new Map(run.map((r, k) => [r, reading[k]]));
335
+ const outright = new Map(run.map((r, k) => [r, named[k]]));
336
+ run.sort(
337
+ (a, b) =>
338
+ Number(outright.get(b)) - Number(outright.get(a)) ||
339
+ Number(at.get(b)) - Number(at.get(a)) ||
340
+ b.typical - a.typical ||
341
+ compareText(a.name, b.name),
342
+ );
343
+ } else run.sort((a, b) => compareText(a.name, b.name));
344
+ out.push(...run);
345
+ i = j;
346
+ }
347
+ return out;
295
348
  }
296
349
 
297
350
  /**
298
351
  * Put a named family's base template ahead of the variant that outranks it,
299
- * unless the variant matched START_TERMS terms the base did not, or the base
352
+ * unless the variant matched START_TERMS terms the base did not, the idea
353
+ * places the page in the variant's frame and not the base's, or the base
300
354
  * cannot start on its own: too little score, or too few matched terms. The
301
355
  * head names the exception: a family word in the idea's head is start
302
356
  * evidence on its own — the same evidence pickStart accepts in place of a
@@ -319,8 +373,9 @@ function baseFirst(ranked) {
319
373
  ) {
320
374
  return ranked;
321
375
  }
376
+ // The frame is what a template is, and pickStart takes it as evidence.
322
377
  const own = [...top.matched].filter(t => !base.matched.has(t)).length;
323
- return own >= START_TERMS
378
+ return own >= START_TERMS || (top.containerMatched && !base.containerMatched)
324
379
  ? ranked
325
380
  : [base, ...ranked.filter(r => r !== base)];
326
381
  }
@@ -363,7 +418,7 @@ export function pickStart(ranked, kind = 'page') {
363
418
  // when one leads ("a frame with sidebar navigation"), else none, for the
364
419
  // kit's neutral fallback.
365
420
  const lead = pickStart(ranked);
366
- return lead?.family === SHELL_FAMILY ? lead : null;
421
+ return isAppShell(lead) ? lead : null;
367
422
  }
368
423
  const top = ranked[0];
369
424
  if (!top || top.score < START_SCORE) return null;
@@ -2,12 +2,13 @@
2
2
  // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
3
 
4
4
  /**
5
- * The template to start from: the ready page the ranker puts first when it
6
- * has the evidence to lead, else the first fallback shell the project can
5
+ * The template to start from: for a whole page, the ready page the word
6
+ * weights and the page-pick model choose (weighStart); for a part or an edit,
7
+ * the ranker's placement; else the first fallback shell the project can
7
8
  * scaffold. Null only when the project has no page template to offer at all.
8
9
  *
9
- * `direct` means two independent signals agree: the ranker's pick is also
10
- * search's direct match. The ranker sees only ready templates, so a template
10
+ * `direct` means two independent signals agree: the start is also search's
11
+ * direct match. The ranker sees only ready templates, so a template
11
12
  * still marked not ready is never the start; when search matched one directly
12
13
  * the reason names it, so the reader knows why the kit starts elsewhere.
13
14
  *