@astryxdesign/cli 0.7.17-canary.geeb3d7c → 0.7.17-canary.gf8e350a

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 (177) hide show
  1. package/api/build/_adapter.d.mts +5 -0
  2. package/api/build/_adapter.mjs +2 -0
  3. package/api/build/kit/rank.d.mts +4 -2
  4. package/api/build/kit/rank.mjs +60 -11
  5. package/api/build/kit/start.mjs +2 -1
  6. package/api/build/kit/weights.d.mts +23 -0
  7. package/api/build/kit/weights.mjs +130 -49
  8. package/api/build/kit/words.d.mts +5 -0
  9. package/api/build/kit/words.mjs +9 -1
  10. package/api/component/__fixtures__/resolutions/modules.txt +1 -1
  11. package/api/discover/_adapter.mjs +34 -1
  12. package/api/discover/discover.type.d.mts +4 -1
  13. package/api/discover/discover.type.mjs +4 -1
  14. package/api/docs/_adapter.d.mts +21 -0
  15. package/api/docs/_adapter.mjs +98 -23
  16. package/api/doctor/_adapter.d.mts +8 -0
  17. package/api/doctor/_adapter.mjs +36 -0
  18. package/api/doctor/doctor.doc.mjs +1 -1
  19. package/api/doctor/doctor.mjs +2 -2
  20. package/api/doctor/theme-checks.mjs +28 -1
  21. package/api/integration/pack-check.mjs +16 -1
  22. package/api/integration/validate-integration.d.mts +12 -2
  23. package/api/integration/validate-integration.mjs +48 -3
  24. package/api/integration/validate-integration.type.d.mts +9 -0
  25. package/api/integration/validate-integration.type.mjs +1 -1
  26. package/api/integration/validateIntegration.doc.mjs +1 -1
  27. package/api/render/render.type.d.mts +1 -1
  28. package/api/render/render.type.mjs +1 -1
  29. package/api/search/_adapter.d.mts +9 -0
  30. package/api/search/_adapter.mjs +85 -0
  31. package/api/theme/_adapter.d.mts +2 -1
  32. package/api/theme/_adapter.mjs +106 -12
  33. package/api/theme/build/build.d.mts +72 -1
  34. package/api/theme/build/build.mjs +286 -107
  35. package/api/theme/build/core-interception.d.mts +10 -0
  36. package/api/theme/build/core-interception.mjs +10 -0
  37. package/api/theme/build/font-warning.d.mts +40 -9
  38. package/api/theme/build/font-warning.mjs +134 -18
  39. package/api/theme/build/icon-imports.mjs +51 -9
  40. package/api/theme/remove/remove.d.mts +2 -1
  41. package/api/theme/remove/remove.mjs +3 -2
  42. package/api/theme/theme.type.d.mts +6 -0
  43. package/api/theme/theme.type.mjs +5 -1
  44. package/api/theme/themeRemove.doc.mjs +8 -5
  45. package/api/theme-edit/_adapter.d.mts +64 -8
  46. package/api/theme-edit/_adapter.mjs +391 -95
  47. package/api/theme-edit/_catalog.d.mts +20 -2
  48. package/api/theme-edit/_catalog.mjs +50 -10
  49. package/api/theme-edit/_check.d.mts +47 -2
  50. package/api/theme-edit/_check.mjs +1248 -341
  51. package/api/theme-edit/_color.d.mts +8 -0
  52. package/api/theme-edit/_color.mjs +12 -1
  53. package/api/theme-edit/_compiler.d.mts +1 -0
  54. package/api/theme-edit/_compiler.mjs +124 -15
  55. package/api/theme-edit/_context.d.mts +30 -4
  56. package/api/theme-edit/_context.mjs +240 -68
  57. package/api/theme-edit/_css.d.mts +21 -0
  58. package/api/theme-edit/_css.mjs +66 -13
  59. package/api/theme-edit/_edit.d.mts +38 -10
  60. package/api/theme-edit/_edit.mjs +2240 -499
  61. package/api/theme-edit/_how-commands.d.mts +15 -1
  62. package/api/theme-edit/_how-commands.mjs +202 -27
  63. package/api/theme-edit/_how-question.d.mts +6 -7
  64. package/api/theme-edit/_how-question.mjs +2323 -522
  65. package/api/theme-edit/_how.d.mts +2 -1
  66. package/api/theme-edit/_how.mjs +103 -33
  67. package/api/theme-edit/_importers.d.mts +38 -0
  68. package/api/theme-edit/_importers.mjs +188 -0
  69. package/api/theme-edit/_name-rule.d.mts +11 -0
  70. package/api/theme-edit/_name-rule.mjs +12 -0
  71. package/api/theme-edit/_normal.d.mts +118 -32
  72. package/api/theme-edit/_normal.mjs +724 -224
  73. package/api/theme-edit/_palette.d.mts +20 -0
  74. package/api/theme-edit/_palette.mjs +39 -1
  75. package/api/theme-edit/_part-words.d.mts +31 -0
  76. package/api/theme-edit/_part-words.mjs +126 -0
  77. package/api/theme-edit/_parts.d.mts +21 -3
  78. package/api/theme-edit/_parts.mjs +167 -32
  79. package/api/theme-edit/_preview-app.d.mts +0 -12
  80. package/api/theme-edit/_preview-app.mjs +566 -399
  81. package/api/theme-edit/_preview.d.mts +76 -23
  82. package/api/theme-edit/_preview.mjs +378 -256
  83. package/api/theme-edit/_project.d.mts +61 -1
  84. package/api/theme-edit/_project.mjs +177 -6
  85. package/api/theme-edit/_settings.d.mts +358 -111
  86. package/api/theme-edit/_settings.mjs +1923 -855
  87. package/api/theme-edit/_tables.d.mts +27 -3
  88. package/api/theme-edit/_tables.mjs +191 -11
  89. package/api/theme-edit/_vet.d.mts +14 -1
  90. package/api/theme-edit/_vet.mjs +86 -12
  91. package/api/theme-edit/theme-edit.type.d.mts +6 -1
  92. package/api/theme-edit/theme-edit.type.mjs +2 -2
  93. package/api/theme-edit/themeEditNew.doc.d.mts +0 -1
  94. package/api/theme-edit/themeEditNew.doc.mjs +7 -4
  95. package/api/theme-edit/themeEditPreviewApp.doc.mjs +1 -1
  96. package/assets/component-list.generated.json +1 -1
  97. package/assets/docs/theme.doc.dense.mjs +1 -1
  98. package/assets/docs/theme.doc.mjs +1 -1
  99. package/assets/docs/tree/checks.doc.mjs +1 -1
  100. package/assets/docs/tree/font-setup.doc.mjs +1 -1
  101. package/assets/docs/tree/fonts-and-assets.doc.mjs +1 -1
  102. package/assets/docs/tree/render-pages.doc.mjs +2 -2
  103. package/assets/docs/tree/share-a-page.doc.mjs +157 -0
  104. package/assets/docs/use-a-theme.doc.mjs +1 -1
  105. package/assets/docs.generated.json +2 -2
  106. package/assets/search-catalog.generated.json +2 -0
  107. package/assets/self-audit.generated.json +1 -1
  108. package/assets/templates/blocks/components/ChatComposerInput/useSpeechRecognitionHookUsage.doc.mjs +14 -0
  109. package/assets/templates/blocks/components/ChatComposerInput/useSpeechRecognitionHookUsage.tsx +43 -0
  110. package/assets/templates/components.generated.json +1 -1
  111. package/assets/templates/pages/ai-chat-landing/template.doc.mjs +3 -0
  112. package/assets/theme.template.ts +3 -2
  113. package/authoring/doctypes/_schema.d.mts +6 -6
  114. package/clients/cli/build-id.generated.json +1 -1
  115. package/clients/cli/commands/doctor.mjs +10 -0
  116. package/clients/cli/commands/experimental/theme.mjs +520 -146
  117. package/clients/cli/commands/experimental-theme-compile.doc.mjs +2 -2
  118. package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +9 -2
  119. package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +2 -2
  120. package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +1 -1
  121. package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +2 -2
  122. package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +1 -1
  123. package/clients/cli/commands/experimental-theme-preview.doc.mjs +2 -1
  124. package/clients/cli/commands/experimental-theme-remove.doc.mjs +4 -4
  125. package/clients/cli/commands/experimental-theme.doc.mjs +5 -1
  126. package/clients/cli/commands/theme-remove.doc.mjs +13 -5
  127. package/clients/cli/commands/theme.mjs +676 -556
  128. package/clients/cli/lib/json-shim.mjs +58 -4
  129. package/clients/cli/manifest.generated.json +1 -1
  130. package/foundation/agent-docs/agent-docs.mjs +1 -1
  131. package/foundation/config/theme-state.d.mts +19 -2
  132. package/foundation/config/theme-state.mjs +93 -1
  133. package/foundation/discovery/core-component-docs.d.mts +29 -0
  134. package/foundation/discovery/core-component-docs.mjs +83 -0
  135. package/foundation/discovery/module-exports.d.mts +14 -1
  136. package/foundation/discovery/module-exports.mjs +62 -14
  137. package/foundation/discovery/stored-search-catalog.d.mts +115 -0
  138. package/foundation/discovery/stored-search-catalog.mjs +297 -0
  139. package/foundation/discovery/template-adapter.d.mts +6 -1
  140. package/foundation/discovery/template-adapter.mjs +3 -0
  141. package/foundation/discovery/theme-discovery.mjs +28 -2
  142. package/foundation/discovery/theming-targets.d.mts +6 -5
  143. package/foundation/discovery/theming-targets.mjs +28 -45
  144. package/foundation/fonts/font-stylesheet.d.mts +7 -0
  145. package/foundation/fonts/font-stylesheet.mjs +34 -3
  146. package/foundation/fs/exact-codec.d.mts +12 -2
  147. package/foundation/fs/exact-codec.mjs +23 -6
  148. package/foundation/fs/gather-cache.d.mts +37 -0
  149. package/foundation/fs/gather-cache.mjs +354 -37
  150. package/foundation/fs/module-loader.d.mts +6 -0
  151. package/foundation/fs/module-loader.mjs +2 -1
  152. package/foundation/fs/read-record.d.mts +9 -0
  153. package/foundation/fs/read-record.mjs +19 -11
  154. package/foundation/fs/stop-cleanup.d.mts +12 -0
  155. package/foundation/fs/stop-cleanup.mjs +66 -0
  156. package/foundation/integrations/pack-state.d.mts +73 -0
  157. package/foundation/integrations/pack-state.mjs +284 -0
  158. package/foundation/integrations/shipped-imports.d.mts +122 -0
  159. package/foundation/integrations/shipped-imports.mjs +497 -0
  160. package/foundation/integrations/validate-contributions.d.mts +0 -17
  161. package/foundation/integrations/validate-contributions.mjs +6 -260
  162. package/foundation/render/charts.d.mts +78 -27
  163. package/foundation/render/charts.mjs +266 -90
  164. package/foundation/render/embedded-imports.d.mts +31 -0
  165. package/foundation/render/embedded-imports.mjs +66 -14
  166. package/foundation/render/page-worker.mjs +83 -8
  167. package/foundation/render/picture-chrome.d.mts +4 -0
  168. package/foundation/render/picture-chrome.mjs +185 -0
  169. package/foundation/render/picture-playwright.d.mts +4 -0
  170. package/{api/theme-edit/_playwright-picture.mjs → foundation/render/picture-playwright.mjs} +2 -2
  171. package/foundation/render/render-page.d.mts +2 -2
  172. package/foundation/render/render-page.mjs +365 -83
  173. package/foundation/text/css-escape.d.mts +18 -0
  174. package/foundation/text/css-escape.mjs +35 -0
  175. package/foundation/xle/browser.d.mts +2 -2
  176. package/package.json +6 -6
  177. package/api/theme-edit/_playwright-picture.d.mts +0 -4
@@ -13,6 +13,7 @@
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.
@@ -165,6 +166,10 @@ export type PageTemplate = {
165
166
  * The components its page composes, read from its source on first use; empty when the source cannot be read.
166
167
  */
167
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;
168
173
  };
169
174
  /**
170
175
  * A component the project can use, as the ranker reads it.
@@ -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
  /**
@@ -113,6 +114,7 @@ export async function loadTemplates(cwd) {
113
114
  package: t.package ?? '@astryxdesign/core',
114
115
  category: t.category || '',
115
116
  keywords: t.keywords ?? [],
117
+ hidden: t.hidden === true,
116
118
  filePath: t.filePath,
117
119
  // The id `template()` resolves back to this entry: an active
118
120
  // replacement owns the Core id it names, so that id selects it.
@@ -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
@@ -53,7 +53,7 @@
53
53
 
54
54
  import {
55
55
  HEAD_END,
56
- SHELL_FAMILY,
56
+ isAppShell,
57
57
  terms,
58
58
  modifiersOf,
59
59
  pairsOf,
@@ -65,6 +65,7 @@ import {
65
65
  keywordWordsFor,
66
66
  framesOf,
67
67
  } from './words.mjs';
68
+ import {namedOutright, tieReading} from './weights.mjs';
68
69
  import {compareText} from '../../../foundation/text/compare-text.mjs';
69
70
 
70
71
  /**
@@ -135,8 +136,10 @@ const START_SCORE = 10;
135
136
  const START_TERMS = 2;
136
137
 
137
138
  /**
138
- * Rank page templates against an idea, best first. Ties go to the template
139
- * 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`).
140
143
  *
141
144
  * @param {string} query
142
145
  * @param {PageTemplate[]} pages
@@ -287,15 +290,61 @@ export function rankPages(query, pages) {
287
290
  family,
288
291
  base,
289
292
  matched,
293
+ hidden: page.hidden === true,
290
294
  };
291
295
  })
292
- .sort(
293
- (a, b) =>
294
- b.score - a.score ||
295
- a.name.split('-').length - b.name.split('-').length ||
296
- compareText(a.name, b.name),
297
- );
298
- 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;
299
348
  }
300
349
 
301
350
  /**
@@ -369,7 +418,7 @@ export function pickStart(ranked, kind = 'page') {
369
418
  // when one leads ("a frame with sidebar navigation"), else none, for the
370
419
  // kit's neutral fallback.
371
420
  const lead = pickStart(ranked);
372
- return lead?.family === SHELL_FAMILY ? lead : null;
421
+ return isAppShell(lead) ? lead : null;
373
422
  }
374
423
  const top = ranked[0];
375
424
  if (!top || top.score < START_SCORE) return null;
@@ -11,6 +11,7 @@ import {loadWeights} from '../_adapter.mjs';
11
11
  import {asksForNewPage} from './kind.mjs';
12
12
  import {pickAlternatives, pickStart} from './rank.mjs';
13
13
  import {hasEditPhrase, shellCallScore} from './shellcall.mjs';
14
+ import {isAppShell} from './words.mjs';
14
15
  import {blendOrder, blendSummary, weighStart} from './weights.mjs';
15
16
 
16
17
  /**
@@ -168,7 +169,7 @@ export function chooseStart(ranked, kind, pages, directMatch, catalog, idea) {
168
169
  weighed === undefined
169
170
  ? proposed
170
171
  : weighed === null
171
- ? proposed?.family === 'Shell' || (proposed && direct && !unready)
172
+ ? isAppShell(proposed) || (proposed && direct && !unready)
172
173
  ? proposed
173
174
  : null
174
175
  : (ranked.find(r => r.name === weighed) ?? proposed);
@@ -13,6 +13,29 @@ export function stem(word: string): string;
13
13
  * @returns {string[]}
14
14
  */
15
15
  export function weightWords(idea: string): string[];
16
+ /**
17
+ * Which of a set of tied templates the idea names by its whole name: its
18
+ * display name or its id, as consecutive words of the idea ("a form wizard
19
+ * page" names `form-wizard`, "Form Wizard"). A whole name is stronger evidence
20
+ * than any descriptor word, so it settles an exact tie first.
21
+ * @param {string[]} names the tied templates' ids
22
+ * @param {string} idea
23
+ * @param {DescribedTemplate[]} catalog
24
+ * @returns {boolean[]} one flag per name, in order
25
+ */
26
+ export function namedOutright(names: string[], idea: string, catalog: DescribedTemplate[]): boolean[];
27
+ /**
28
+ * How strongly each of a set of tied templates' own descriptors answers the
29
+ * idea. Words every tied template names cannot choose between them, so they
30
+ * are left out; each other word of the idea that a template's descriptor
31
+ * names adds its rarity among the templates of the tied templates' families.
32
+ * Reads only the templates' descriptors.
33
+ * @param {string[]} names the tied templates' ids
34
+ * @param {string} idea
35
+ * @param {DescribedTemplate[]} catalog
36
+ * @returns {number[]} one reading per name, in order
37
+ */
38
+ export function tieReading(names: string[], idea: string, catalog: DescribedTemplate[]): number[];
16
39
  /**
17
40
  * Every ready, non-shell template in the blend's own order, best first: the
18
41
  * order the page start is chosen from, so the alternatives build names beside
@@ -24,6 +24,7 @@
24
24
  import {STOPWORDS} from '../../search/search.mjs';
25
25
  import {keywordUnits, keywordWordsFor} from './words.mjs';
26
26
  import {isWordModel} from './word-model.mjs';
27
+ import {compareText} from '../../../foundation/text/compare-text.mjs';
27
28
 
28
29
  /** The app shell, as one candidate. */
29
30
  export const SHELL = 'SHELL';
@@ -247,9 +248,15 @@ function memberFeatures(v) {
247
248
  Math.max(1, finite.length),
248
249
  ) || 1;
249
250
  const val = v.map(x => (x === undefined ? -1e9 : x));
250
- const order = [...val.keys()].sort((a, b) => val[b] - val[a]);
251
- const rank = new Array(v.length);
252
- order.forEach((ci, r) => (rank[ci] = r));
251
+ // Equal values share the average of the ranks they span. That is the mean
252
+ // rank an arbitrary order gives them, which is what the blend numbers were
253
+ // fit on, and the candidates' order in the weights file never decides. Two
254
+ // or more candidates tied at a member's top share a rank above 0, so none
255
+ // of them gets the is-top feature.
256
+ const rank = val.map(
257
+ x =>
258
+ val.filter(y => y > x).length + (val.filter(y => y === x).length - 1) / 2,
259
+ );
253
260
  return v.map((x, i) => [
254
261
  x === undefined ? -4 : Math.max(-4, Math.min(4, (x - mean) / sd)),
255
262
  1 / (rank[i] + 1),
@@ -398,8 +405,9 @@ function blend(idea, ranked, pick, catalog, weights) {
398
405
 
399
406
  /**
400
407
  * 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
408
+ * family (same score, and both the family's base or both variants): the one
409
+ * whose descriptor's words are shared by the most of its family's templates,
410
+ * on average. `name` keeps its
403
411
  * place on an equal value. Reads only the templates' descriptors.
404
412
  * @param {string} name
405
413
  * @param {import('./rank.mjs').RankedPage[]} ranked
@@ -409,13 +417,12 @@ function blend(idea, ranked, pick, catalog, weights) {
409
417
  function typicalOfTie(name, ranked, cands) {
410
418
  const self = ranked.find(r => r.name === name);
411
419
  if (!self || self.family === SHELL_FAMILY || !self.family) return name;
412
- const length = (/** @type {string} */ n) => n.split('-').length;
413
420
  let chosen = self;
414
421
  for (const r of ranked) {
415
422
  if (
416
423
  r.score === self.score &&
417
424
  r.family === self.family &&
418
- length(r.name) === length(self.name) &&
425
+ r.base === self.base &&
419
426
  cands.includes(r.name) &&
420
427
  r.typical > chosen.typical
421
428
  )
@@ -444,8 +451,64 @@ function descriptorWords(t, order) {
444
451
  }
445
452
 
446
453
  /**
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
454
+ * Which of a set of tied templates the idea names by its whole name: its
455
+ * display name or its id, as consecutive words of the idea ("a form wizard
456
+ * page" names `form-wizard`, "Form Wizard"). A whole name is stronger evidence
457
+ * than any descriptor word, so it settles an exact tie first.
458
+ * @param {string[]} names the tied templates' ids
459
+ * @param {string} idea
460
+ * @param {DescribedTemplate[]} catalog
461
+ * @returns {boolean[]} one flag per name, in order
462
+ */
463
+ export function namedOutright(names, idea, catalog) {
464
+ const said = weightWords(idea).map(stem);
465
+ const holds = (/** @type {string[]} */ phrase) =>
466
+ phrase.length > 0 &&
467
+ said.some((_, i) => phrase.every((w, k) => said[i + k] === w));
468
+ return names.map(name => {
469
+ const t = catalog.find(c => c.name === name);
470
+ return [t?.displayName ?? '', name.replace(/-/g, ' ')].some(text =>
471
+ holds(weightWords(text).map(stem)),
472
+ );
473
+ });
474
+ }
475
+
476
+ /**
477
+ * How strongly each of a set of tied templates' own descriptors answers the
478
+ * idea. Words every tied template names cannot choose between them, so they
479
+ * are left out; each other word of the idea that a template's descriptor
480
+ * names adds its rarity among the templates of the tied templates' families.
481
+ * Reads only the templates' descriptors.
482
+ * @param {string[]} names the tied templates' ids
483
+ * @param {string} idea
484
+ * @param {DescribedTemplate[]} catalog
485
+ * @returns {number[]} one reading per name, in order
486
+ */
487
+ export function tieReading(names, idea, catalog) {
488
+ const families = new Set(names.map(name => familyOf(name, catalog)));
489
+ const pool = catalog.filter(t => families.has(familyOf(t.name, catalog)));
490
+ const order = contentWords(idea);
491
+ const words = new Map(pool.map(t => [t.name, descriptorWords(t, order)]));
492
+ const df = (/** @type {string} */ w) =>
493
+ pool.filter(t => words.get(t.name)?.has(w)).length;
494
+ const said = new Set(order);
495
+ const own = names.map(name => words.get(name) ?? new Set());
496
+ const n = pool.length;
497
+ return names.map((_, i) => {
498
+ let s = 0;
499
+ for (const w of said) {
500
+ if (!own[i].has(w) || own.every(o => o.has(w))) continue;
501
+ const d = df(w);
502
+ s += Math.log(1 + (n - d + 0.5) / (d + 0.5));
503
+ }
504
+ return s;
505
+ });
506
+ }
507
+
508
+ /**
509
+ * Settles an exact tie in the ranker: a tied template the idea names by its
510
+ * whole name starts (`namedOutright`); otherwise a fuller reading of each tied
511
+ * template's own descriptor decides. Words every tied template names cannot choose
449
512
  * between them, so they are left out; each other word of the idea that a
450
513
  * template's descriptor names adds its rarity within the family. The highest
451
514
  * total starts. An equal total goes to the most typical of the family
@@ -460,32 +523,25 @@ function descriptorWords(t, order) {
460
523
  function fullerOfTie(name, idea, ranked, cands, catalog) {
461
524
  const self = ranked.find(r => r.name === name);
462
525
  if (!self || self.family === SHELL_FAMILY || !self.family) return name;
463
- const length = (/** @type {string} */ n) => n.split('-').length;
464
526
  const tied = ranked.filter(
465
527
  r =>
466
528
  r.score === self.score &&
467
529
  r.family === self.family &&
468
- length(r.name) === length(self.name) &&
530
+ r.base === self.base &&
469
531
  cands.includes(r.name),
470
532
  );
471
533
  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
- });
534
+ const named = namedOutright(
535
+ tied.map(r => r.name),
536
+ idea,
537
+ catalog,
538
+ );
539
+ if (named.filter(Boolean).length === 1) return tied[named.indexOf(true)].name;
540
+ const score = tieReading(
541
+ tied.map(r => r.name),
542
+ idea,
543
+ catalog,
544
+ );
489
545
  const top = Math.max(...score);
490
546
  if (top === 0) return typicalOfTie(name, ranked, cands);
491
547
  const leaders = tied.filter((_, i) => score[i] >= top - 1e-9);
@@ -510,6 +566,25 @@ function fullerOfTie(name, idea, ranked, cands, catalog) {
510
566
  * @returns {string | null}
511
567
  */
512
568
  function bestPage(idea, ranked, pick, catalog, weights, ok = () => true) {
569
+ return pickOrder(idea, ranked, pick, catalog, weights).find(ok) ?? null;
570
+ }
571
+
572
+ /**
573
+ * Every ready, non-shell template in the pick model's order, best first.
574
+ * Templates the pick model scores exactly the same are ordered like an exact
575
+ * tie in the ranker: a template the idea names by its whole name first
576
+ * (`namedOutright`), then by how strongly each one's own descriptor answers
577
+ * the idea (`tieReading`), then by how typical of its family it is, then by
578
+ * name.
579
+ * The weights file's candidate order never decides.
580
+ * @param {string} idea
581
+ * @param {import('./rank.mjs').RankedPage[]} ranked
582
+ * @param {import('./rank.mjs').RankedPage | null} pick
583
+ * @param {DescribedTemplate[]} catalog
584
+ * @param {WeightsFile} weights
585
+ * @returns {string[]}
586
+ */
587
+ function pickOrder(idea, ranked, pick, catalog, weights) {
513
588
  const {cands, scores} = blend(
514
589
  idea,
515
590
  ranked,
@@ -517,16 +592,33 @@ function bestPage(idea, ranked, pick, catalog, weights, ok = () => true) {
517
592
  catalog,
518
593
  pickModel(weights),
519
594
  );
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;
595
+ const sorted = cands
596
+ .map((c, i) => ({c, s: scores[i]}))
597
+ .filter(x => x.c !== SHELL)
598
+ .sort((x, y) => y.s - x.s);
599
+ const typical = new Map(ranked.map(r => [r.name, r.typical]));
600
+ const out = [];
601
+ for (let i = 0; i < sorted.length;) {
602
+ let j = i + 1;
603
+ while (j < sorted.length && sorted[j].s === sorted[i].s) j++;
604
+ const run = sorted.slice(i, j).map(x => x.c);
605
+ if (run.length > 1) {
606
+ const reading = tieReading(run, idea, catalog);
607
+ const named = namedOutright(run, idea, catalog);
608
+ const at = new Map(run.map((c, k) => [c, reading[k]]));
609
+ const outright = new Map(run.map((c, k) => [c, named[k]]));
610
+ run.sort(
611
+ (a, b) =>
612
+ Number(outright.get(b)) - Number(outright.get(a)) ||
613
+ Number(at.get(b)) - Number(at.get(a)) ||
614
+ (typical.get(b) ?? 0) - (typical.get(a) ?? 0) ||
615
+ compareText(a, b),
616
+ );
617
+ }
618
+ out.push(...run);
619
+ i = j;
528
620
  }
529
- return at < 0 ? null : cands[at];
621
+ return out;
530
622
  }
531
623
 
532
624
  /**
@@ -542,18 +634,7 @@ function bestPage(idea, ranked, pick, catalog, weights, ok = () => true) {
542
634
  */
543
635
  export function blendOrder(idea, ranked, pick, catalog, weights) {
544
636
  if (!weights) return null;
545
- const {cands, scores} = blend(
546
- idea,
547
- ranked,
548
- pick,
549
- catalog,
550
- pickModel(weights),
551
- );
552
- return cands
553
- .map((c, i) => ({c, s: scores[i], i}))
554
- .filter(x => x.c !== SHELL)
555
- .sort((x, y) => y.s - x.s || x.i - y.i)
556
- .map(x => x.c);
637
+ return pickOrder(idea, ranked, pick, catalog, weights);
557
638
  }
558
639
 
559
640
  /**
@@ -88,6 +88,10 @@ export const HEAD_END: RegExp;
88
88
  * explicit `Shell -` category (architecture:template-authoring/INV7).
89
89
  */
90
90
  export const SHELL_FAMILY: "Shell";
91
+ export function isAppShell(page: {
92
+ family: string;
93
+ hidden?: boolean;
94
+ } | null | undefined): boolean;
91
95
  /** A container phrase: "in a modal", "inside the side panel". */
92
96
  export const CONTAINER_PHRASE: RegExp;
93
97
  /**
@@ -117,5 +121,6 @@ export type RankedPage = {
117
121
  base: boolean;
118
122
  matched: Set<string>;
119
123
  typical: number;
124
+ hidden: boolean;
120
125
  };
121
126
  export type IdeaKind = "page" | "part" | "edit";
@@ -43,6 +43,14 @@ const OVERLAY_FRAMES = new Set([
43
43
  */
44
44
  export const SHELL_FAMILY = 'Shell';
45
45
 
46
+ /**
47
+ * Whether a ranked template can be the app shell: a template of the Shell
48
+ * family that is not kept off the gallery. A hidden template is no starter.
49
+ * @param {{family: string, hidden?: boolean} | null | undefined} page
50
+ */
51
+ export const isAppShell = page =>
52
+ page?.family === SHELL_FAMILY && page.hidden !== true;
53
+
46
54
  /** A container phrase: "in a modal", "inside the side panel". */
47
55
  export const CONTAINER_PHRASE =
48
56
  /\b(?:in|inside|within)\s+(?:a|an|the)\s+([a-z-]+)(?:\s+([a-z-]+))?/gi;
@@ -252,7 +260,7 @@ export const SYNONYMS_OF = (() => {
252
260
  /**
253
261
  * @typedef {import('../_adapter.mjs').PageTemplate} PageTemplate
254
262
  * @typedef {import('../_adapter.mjs').ComponentWords} ComponentWords
255
- * @typedef {{name: string, score: number, hits: number, familyNamed: boolean, headNamed: boolean, containerMatched: boolean, family: string, base: boolean, matched: Set<string>, typical: number}} RankedPage
263
+ * @typedef {{name: string, score: number, hits: number, familyNamed: boolean, headNamed: boolean, containerMatched: boolean, family: string, base: boolean, matched: Set<string>, typical: number, hidden: boolean}} RankedPage
256
264
  * @typedef {'page' | 'part' | 'edit'} IdeaKind
257
265
  */
258
266
 
@@ -293,7 +293,7 @@ useSelectorPresentation useSelectorPresentation Selector/Selector.doc.mjs Select
293
293
  useSettledOpen useSettledOpen hooks/useAnimatedLayout.doc.mjs hooks/useSettledOpen.ts
294
294
  useSheetGestures useSheetGestures BottomSheet/BottomSheet.doc.mjs BottomSheet/useSheetGestures.ts
295
295
  useSliderTouch useSliderTouch Slider/Slider.doc.mjs Slider/useSliderTouch.ts
296
- useSpeechRecognition useSpeechRecognition Chat/Chat.doc.mjs Chat/useSpeechRecognition.ts
296
+ useSpeechRecognition useSpeechRecognition Chat/useSpeechRecognition.doc.mjs Chat/useSpeechRecognition.ts
297
297
  useSwipeAction useSwipeAction Swipe/createSwipe.doc.mjs Swipe/useSwipeAction.ts
298
298
  useSwitchTouch useSwitchTouch Switch/Switch.doc.mjs Switch/useSwitchTouch.ts
299
299
  useTableCellStyles useTableCellStyles Table/Table.doc.mjs Table/useTableCellStyles.ts
@@ -30,6 +30,7 @@ import {hostedRun} from '../../foundation/runtime/package-root.mjs';
30
30
  import {scanAllPackages, findComponentInPackages} from './_package-scanner.mjs';
31
31
  import {loadDocs} from '../../foundation/discovery/component-loader.mjs';
32
32
  import {collectIdentities} from '../../foundation/integrations/contribution-inventory.mjs';
33
+ import {packageDocNames, projectTree} from '../docs/_adapter.mjs';
33
34
  import {discoverIntegrationIconSets} from '../../foundation/discovery/icon-set-discovery.mjs';
34
35
  import {detectPackageManager} from '../../foundation/env/package-manager.mjs';
35
36
  import {isValidSemver, semverCompare} from '../../foundation/env/semver.mjs';
@@ -221,6 +222,7 @@ export async function discoverPackages() {
221
222
  export async function describeInstalled(project, scanned) {
222
223
  if (project == null) return scanned;
223
224
  const byName = new Map(scanned.map(pkg => [pkg.name, pkg]));
225
+ const docs = await projectDocs(project);
224
226
  /** @type {InstalledPackage[]} */
225
227
  const installed = [];
226
228
  for (const integration of project.loadedIntegrations) {
@@ -238,10 +240,12 @@ export async function describeInstalled(project, scanned) {
238
240
  // Components come from the scan above; loading every component doc again
239
241
  // here would only slow the list down.
240
242
  // Icon sets are read below, only with the opt-in.
243
+ // Docs are named from the project's docs catalog, below.
241
244
  const {identities} = await collectIdentities({
242
245
  ...integration,
243
246
  components: undefined,
244
247
  iconSets: undefined,
248
+ docs: undefined,
245
249
  });
246
250
  // Icon sets are listed the way every icon surface sees them: a set that
247
251
  // is invalid or whose module does not resolve answers nothing (FR9).
@@ -253,7 +257,11 @@ export async function describeInstalled(project, scanned) {
253
257
  installed.push({
254
258
  ...base,
255
259
  templates: identities.templates.map(t => t.id),
256
- docs: identities.docs,
260
+ // Each doc by the name `astryx docs` opens it by, not the name on its
261
+ // file: a doc that adds sections to `theme` opens as `theme`.
262
+ docs: docs
263
+ ? packageDocNames(docs.catalog, docs.tree, integration.name)
264
+ : [],
257
265
  themes: identities.themes.map(t => t.slug),
258
266
  codemods: identities.codemods.map(c => `${c.version}/${c.id}`),
259
267
  iconSets: sets.map(set => set.name),
@@ -280,6 +288,31 @@ export async function describeInstalled(project, scanned) {
280
288
  return installed;
281
289
  }
282
290
 
291
+ /**
292
+ * The project's docs catalog and tree, as a docs read builds them, so discover
293
+ * names each doc the way `astryx docs` opens it. Null when no integration
294
+ * ships docs, so there is nothing to name and nothing is built, or when they
295
+ * cannot be built: a docs read then answers from the CLI's own topics alone,
296
+ * so no integration doc opens.
297
+ * @param {Project} project
298
+ * @returns {Promise<{catalog: import('../../foundation/discovery/docs-discovery.mjs').DocsCatalog, tree: import('../../foundation/doc-compiler/tree.mjs').DocsTree} | null>}
299
+ */
300
+ async function projectDocs(project) {
301
+ if (
302
+ !project.loadedIntegrations.some(
303
+ integration => !integration.__loadError && integration.docs,
304
+ )
305
+ ) {
306
+ return null;
307
+ }
308
+ try {
309
+ const catalog = await project.docs();
310
+ return {catalog, tree: await projectTree(catalog)};
311
+ } catch {
312
+ return null;
313
+ }
314
+ }
315
+
283
316
  /**
284
317
  * Whether the project has any discover source: its own `discover` config field,
285
318
  * or an integration's `discover` named export (valid or not).
@@ -56,7 +56,10 @@ export type DiscoverListEntry = {
56
56
  */
57
57
  templates?: string[] | undefined;
58
58
  /**
59
- * Doc topic names, when it adds any.
59
+ * What `astryx docs` opens each doc it adds by,
60
+ * when it adds any: a topic's name, the name of a topic it adds sections
61
+ * to, or the route of a namespace doc or guide it places, or of a guide it
62
+ * replaces or extends.
60
63
  */
61
64
  docs?: string[] | undefined;
62
65
  /**
@@ -51,7 +51,10 @@
51
51
  * @property {string} [description]
52
52
  * @property {string} [displayName]
53
53
  * @property {string[]} [templates] Template ids, when it adds any.
54
- * @property {string[]} [docs] Doc topic names, when it adds any.
54
+ * @property {string[]} [docs] What `astryx docs` opens each doc it adds by,
55
+ * when it adds any: a topic's name, the name of a topic it adds sections
56
+ * to, or the route of a namespace doc or guide it places, or of a guide it
57
+ * replaces or extends.
55
58
  * @property {string[]} [themes] Theme slugs, when it adds any.
56
59
  * @property {string[]} [codemods] `<version>/<id>`, when it adds any.
57
60
  * @property {string[]} [agentDocs] Agent guidance, when a source lists any.
@@ -350,6 +350,25 @@ export function childIdentity(tree: DocsTree, child: TreeNode): import("./docs.t
350
350
  * @returns {boolean}
351
351
  */
352
352
  export function holdsOwnName(tree: DocsTree, catalog: DocsCatalog, entry: import("../../foundation/discovery/docs-discovery.mjs").DocsTopicEntry): boolean;
353
+ /**
354
+ * The names `astryx docs` opens a package's docs by, sorted: the one rule
355
+ * every surface that lists a package's docs names them by, so each name it
356
+ * prints opens (`astryx discover` lists an installed integration's docs this
357
+ * way). The docs are what the package's docs root ships, and each opens where
358
+ * it lands, not by the name on its file: a topic the package wrote or took
359
+ * over opens by its own name; a doc that adds sections to another topic opens
360
+ * with that topic, by its name; a namespace doc or guide the package places,
361
+ * and a guide it replaces or extends by its route, open by that route. A topic
362
+ * whose name opens another doc is left out, as the topic list leaves it out
363
+ * (spec:AST-046 FR11). Typed docs of the package's other contributions, such
364
+ * as an icon set's own icon definitions, are listed with those contributions,
365
+ * not here.
366
+ * @param {DocsCatalog} catalog
367
+ * @param {DocsTree} tree
368
+ * @param {string} owner the package
369
+ * @returns {string[]}
370
+ */
371
+ export function packageDocNames(catalog: DocsCatalog, tree: DocsTree, owner: string): string[];
353
372
  /**
354
373
  * The doc that took a flat topic's route in the docs tree, when it is not
355
374
  * that topic (spec:AST-046 FR11): the CLI keeps its routes, such as `cli`
@@ -504,6 +523,7 @@ export type LinkProblem = import("../../foundation/doc-compiler/links.mjs").Link
504
523
  export type LinkResolver = import("../../foundation/doc-compiler/links.mjs").LinkResolver;
505
524
  export type DocIncluder = import("../../foundation/doc-compiler/links.mjs").DocIncluder;
506
525
  export type DocsTopicEntry = import("../../foundation/discovery/docs-discovery.mjs").DocsTopicEntry;
526
+ export type TreeInputs = Awaited<ReturnType<typeof loadTreeInputs>>;
507
527
  import { DocsCatalog } from '../../foundation/discovery/docs-discovery.mjs';
508
528
  /**
509
529
  * The catalog one integration package's docs and links read, as doctor checks
@@ -521,4 +541,5 @@ declare function packageCatalog(integration: any, discovered: {
521
541
  import { AstryxError } from '../error.mjs';
522
542
  import { OVERLAY_LANGUAGES } from '../../foundation/doc-compiler/read.mjs';
523
543
  import { overlayLanguages } from '../../foundation/doc-compiler/read.mjs';
544
+ import { loadTreeInputs } from '../../foundation/doc-compiler/tree.mjs';
524
545
  export { OVERLAY_LANGUAGES, overlayLanguages };