@astryxdesign/cli 0.7.16-canary.gbb5e9d4 → 0.7.16-canary.gcc14978

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 (172) hide show
  1. package/README.md +1 -1
  2. package/api/build/_adapter.d.mts +15 -0
  3. package/api/build/_adapter.mjs +71 -12
  4. package/api/build/blocks/blocks.d.mts +1 -0
  5. package/api/build/blocks/blocks.mjs +18 -1
  6. package/api/build/build.doc.mjs +2 -1
  7. package/api/build/kit/rank.mjs +14 -0
  8. package/api/build/kit/shell.weights.json +1 -0
  9. package/api/build/kit/shellcall.d.mts +26 -0
  10. package/api/build/kit/shellcall.mjs +87 -0
  11. package/api/build/kit/start.mjs +67 -4
  12. package/api/build/kit/weights.d.mts +17 -0
  13. package/api/build/kit/weights.mjs +163 -5
  14. package/api/build/kit/words.d.mts +1 -0
  15. package/api/build/kit/words.mjs +1 -1
  16. package/api/component/__fixtures__/resolutions/modules.txt +4 -4
  17. package/api/docs/_adapter.d.mts +26 -2
  18. package/api/docs/_adapter.mjs +217 -5
  19. package/api/docs/node/node.mjs +1 -1
  20. package/api/doctor/_adapter.d.mts +31 -2
  21. package/api/doctor/_adapter.mjs +82 -1
  22. package/api/doctor/built-checks.mjs +1 -1
  23. package/api/doctor/doctor.d.mts +26 -0
  24. package/api/doctor/doctor.doc.mjs +1 -1
  25. package/api/doctor/doctor.mjs +139 -8
  26. package/api/doctor/theme-checks.mjs +275 -26
  27. package/api/icon/_adapter.d.mts +7 -3
  28. package/api/icon/_adapter.mjs +12 -3
  29. package/api/icon/icon.type.d.mts +15 -0
  30. package/api/icon/icon.type.mjs +10 -3
  31. package/api/icon/iconUse.doc.mjs +19 -5
  32. package/api/icon/list/list.mjs +7 -1
  33. package/api/icon/use/use.d.mts +8 -5
  34. package/api/icon/use/use.mjs +95 -13
  35. package/api/init/run/run.mjs +1 -0
  36. package/api/integration/add-contribution.mjs +3 -3
  37. package/api/integration/pack-check.mjs +1 -1
  38. package/api/search/_adapter.mjs +12 -0
  39. package/api/search/_entries.d.mts +2 -1
  40. package/api/search/_entries.mjs +28 -1
  41. package/api/swizzle/_moduleGraph.mjs +1 -1
  42. package/api/template/template.type.d.mts +6 -2
  43. package/api/template/template.type.mjs +2 -1
  44. package/api/theme/_adapter.mjs +16 -2
  45. package/api/theme/_fork.mjs +1 -1
  46. package/api/theme/build/build.d.mts +88 -9
  47. package/api/theme/build/build.mjs +240 -75
  48. package/api/theme/generateTonalPalette.doc.mjs +2 -2
  49. package/api/theme/palette/generate/generator.mjs +141 -2
  50. package/api/theme/theme.type.d.mts +39 -0
  51. package/api/theme/theme.type.mjs +21 -0
  52. package/api/theme/themeBuild.doc.mjs +1 -1
  53. package/api/theme/themePaletteGenerate.doc.mjs +1 -1
  54. package/api/theme-edit/_adapter.d.mts +7 -2
  55. package/api/theme-edit/_adapter.mjs +163 -29
  56. package/api/theme-edit/_check.d.mts +10 -3
  57. package/api/theme-edit/_check.mjs +270 -74
  58. package/api/theme-edit/_context.d.mts +2 -1
  59. package/api/theme-edit/_context.mjs +19 -1
  60. package/api/theme-edit/_edit.d.mts +16 -0
  61. package/api/theme-edit/_edit.mjs +425 -65
  62. package/api/theme-edit/_how-question.d.mts +8 -0
  63. package/api/theme-edit/_how-question.mjs +518 -43
  64. package/api/theme-edit/_marks.d.mts +39 -0
  65. package/api/theme-edit/_marks.mjs +67 -0
  66. package/api/theme-edit/_normal.d.mts +80 -0
  67. package/api/theme-edit/_normal.mjs +359 -0
  68. package/api/theme-edit/_palette.d.mts +27 -0
  69. package/api/theme-edit/_palette.mjs +112 -8
  70. package/api/theme-edit/_preview-app.d.mts +46 -1
  71. package/api/theme-edit/_preview-app.mjs +367 -36
  72. package/api/theme-edit/_preview.d.mts +66 -0
  73. package/api/theme-edit/_preview.mjs +273 -6
  74. package/api/theme-edit/_project.d.mts +4 -0
  75. package/api/theme-edit/_project.mjs +27 -6
  76. package/api/theme-edit/_settings.d.mts +64 -2
  77. package/api/theme-edit/_settings.mjs +502 -125
  78. package/api/theme-edit/_tables.mjs +1 -1
  79. package/api/theme-edit/theme-edit.type.d.mts +39 -2
  80. package/api/theme-edit/theme-edit.type.mjs +13 -2
  81. package/api/theme-edit/themeEditPreviewApp.doc.mjs +1 -1
  82. package/assets/codemods/parse.mjs +2 -2
  83. package/assets/docs/author-a-theme.doc.mjs +1 -1
  84. package/assets/docs/theme.doc.dense.mjs +1 -1
  85. package/assets/docs/theme.doc.mjs +1 -1
  86. package/assets/docs/theme.doc.zh.mjs +4 -3
  87. package/assets/docs/tree/define-the-theme.doc.mjs +1 -1
  88. package/assets/docs/tree/icon-sets.doc.mjs +63 -8
  89. package/assets/docs.generated.json +2 -2
  90. package/assets/self-audit.generated.json +1 -1
  91. package/assets/templates/blocks/components/ChatComposerInput/useChatDictationHookUsage.doc.mjs +14 -0
  92. package/assets/templates/blocks/components/ChatComposerInput/useChatDictationHookUsage.tsx +38 -0
  93. package/assets/templates/blocks/components/Outline/useOutlineFromDOMHookUsage.doc.mjs +21 -0
  94. package/assets/templates/blocks/components/Outline/useOutlineFromDOMHookUsage.tsx +62 -0
  95. package/assets/templates/blocks/components/SyntaxTheme/useSyntaxThemeHookUsage.doc.mjs +14 -0
  96. package/assets/templates/blocks/components/SyntaxTheme/useSyntaxThemeHookUsage.tsx +36 -0
  97. package/assets/templates/components.generated.json +1 -1
  98. package/assets/templates/pages/ai-chat/page.tsx +20 -2
  99. package/assets/templates/pages/ide/page.tsx +24 -2
  100. package/assets/templates/themes/neutral/neutralPalettes.generated.receipt.json +2 -0
  101. package/authoring/config/config.doc.mjs +8 -0
  102. package/authoring/config/parse.d.mts +1 -0
  103. package/authoring/config/parse.mjs +12 -0
  104. package/authoring/config/type.ts +8 -0
  105. package/authoring/doctypes/icon-set/icon-set-data.doc.mjs +3 -3
  106. package/authoring/shadcn/source-variants.d.mts +1 -1
  107. package/authoring/shadcn/source-variants.mjs +32 -10
  108. package/clients/cli/build-id.generated.json +1 -1
  109. package/clients/cli/commands/experimental/icon.mjs +61 -6
  110. package/clients/cli/commands/experimental/theme.mjs +9 -2
  111. package/clients/cli/commands/experimental-icon-use.doc.mjs +12 -5
  112. package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +2 -2
  113. package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +1 -1
  114. package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +2 -2
  115. package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +1 -1
  116. package/clients/cli/commands/experimental-theme-editor.doc.mjs +1 -1
  117. package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +1 -1
  118. package/clients/cli/commands/theme.doc.mjs +7 -2
  119. package/clients/cli/commands/theme.mjs +88 -21
  120. package/clients/cli/commands.generated.json +1 -1
  121. package/clients/cli/index.mjs +25 -5
  122. package/clients/cli/manifest.generated.json +1 -1
  123. package/foundation/agent-docs/agent-docs.mjs +1 -1
  124. package/foundation/config/config-writer.d.mts +23 -0
  125. package/foundation/config/config-writer.mjs +152 -58
  126. package/foundation/config/project.mjs +53 -2
  127. package/foundation/discovery/component-discovery.d.mts +11 -0
  128. package/foundation/discovery/component-discovery.mjs +38 -24
  129. package/foundation/discovery/entry-name-files.d.mts +43 -0
  130. package/foundation/discovery/entry-name-files.mjs +264 -0
  131. package/foundation/discovery/hook-discovery.d.mts +8 -2
  132. package/foundation/discovery/hook-discovery.mjs +20 -7
  133. package/foundation/discovery/icon-set-checks.mjs +164 -48
  134. package/foundation/discovery/icon-set-discovery.d.mts +38 -5
  135. package/foundation/discovery/icon-set-discovery.mjs +50 -6
  136. package/foundation/discovery/icon-set-theme-maps.d.mts +59 -0
  137. package/foundation/discovery/icon-set-theme-maps.mjs +95 -0
  138. package/foundation/discovery/icon-set-writer.d.mts +2 -3
  139. package/foundation/discovery/icon-set-writer.mjs +58 -17
  140. package/foundation/discovery/module-exports.mjs +1 -15
  141. package/foundation/discovery/template-adapter.d.mts +52 -0
  142. package/foundation/discovery/template-adapter.mjs +185 -19
  143. package/foundation/discovery/template-icons.d.mts +27 -10
  144. package/foundation/discovery/template-icons.mjs +142 -26
  145. package/foundation/discovery/template-source-tree.mjs +3 -16
  146. package/foundation/discovery/theme-discovery.d.mts +25 -0
  147. package/foundation/discovery/theme-discovery.mjs +86 -48
  148. package/foundation/doc-compiler/import.mjs +7 -1
  149. package/foundation/doc-compiler/parse-readable.mjs +4 -1
  150. package/foundation/doc-compiler/stored-docs.d.mts +22 -0
  151. package/foundation/doc-compiler/stored-docs.mjs +49 -0
  152. package/foundation/fs/gather-cache.d.mts +26 -3
  153. package/foundation/fs/gather-cache.mjs +144 -15
  154. package/foundation/fs/kept-tree.d.mts +60 -0
  155. package/foundation/fs/kept-tree.mjs +154 -0
  156. package/foundation/integrations/autolink.d.mts +4 -2
  157. package/foundation/integrations/autolink.mjs +4 -2
  158. package/foundation/integrations/cli-requirement.d.mts +16 -5
  159. package/foundation/integrations/cli-requirement.mjs +27 -6
  160. package/foundation/integrations/contribution-fixes.mjs +1 -16
  161. package/foundation/integrations/may-have-integrations.mjs +5 -2
  162. package/foundation/integrations/missing-dependency.d.mts +9 -0
  163. package/foundation/integrations/missing-dependency.mjs +100 -0
  164. package/foundation/integrations/public-imports.mjs +1 -1
  165. package/foundation/render/embedded-imports.mjs +1 -1
  166. package/foundation/render/page-worker.mjs +4 -1
  167. package/foundation/runtime/lazy-dependencies.d.mts +14 -0
  168. package/foundation/runtime/lazy-dependencies.mjs +82 -0
  169. package/foundation/text/suggest-order.d.mts +9 -0
  170. package/foundation/text/suggest-order.mjs +13 -0
  171. package/foundation/xle/browser.d.mts +2 -2
  172. package/package.json +6 -6
package/README.md CHANGED
@@ -112,7 +112,7 @@ Each command declares what it does in a folder outside any project, and `astryx
112
112
  | `search` | Search components, hooks, docs, templates, and themes in one ranked list | `same` |
113
113
  | `swizzle` | Copy component source for customization | `refuse` |
114
114
  | `template` | List, show, or scaffold page and block templates | `same` |
115
- | `theme` | Add, switch, build, and author themes | by subcommand |
115
+ | `theme` | Add, switch, build, and author themes (to make or change one, use experimental theme editor) | by subcommand |
116
116
  | `upgrade` | Update your code after upgrading Astryx, and refresh ShadCN-copied components | `own` |
117
117
 
118
118
  <!-- END GENERATED: commands -->
@@ -12,6 +12,7 @@
12
12
  * @property {string} category The template's own `Family - Variant` label; empty when it declares none.
13
13
  * @property {string[]} keywords The ideas the page serves, as its own descriptor names them; empty when it declares none.
14
14
  * @property {string} filePath Absolute path to the template source file on disk.
15
+ * @property {string[]} components The components its page composes, read from its source on first use; empty when the source cannot be read.
15
16
  */
16
17
  /**
17
18
  * A component the project can use, as the ranker reads it.
@@ -69,6 +70,15 @@ export function loadComponents(cwd: string): Promise<ComponentWords[]>;
69
70
  * @returns {import('./kit/weights.mjs').WeightsFile | null}
70
71
  */
71
72
  export function loadWeights(): import("./kit/weights.mjs").WeightsFile | null;
73
+ /**
74
+ * The fixed word table of the shell-start check (kit/shell.weights.json), read
75
+ * once. Null when the file is missing or unreadable.
76
+ * @returns {{threshold: number, weights: Record<string, number>} | null}
77
+ */
78
+ export function loadShellWeights(): {
79
+ threshold: number;
80
+ weights: Record<string, number>;
81
+ } | null;
72
82
  /**
73
83
  * The classifier weights of build's root (tree.weights.json), read once.
74
84
  * @returns {import('../../foundation/route/route.mjs').ClassifierWeights}
@@ -77,6 +87,7 @@ export function loadTreeWeights(): import("../../foundation/route/route.mjs").Cl
77
87
  export function keptBlockCatalog<T>(key: unknown[], compute: () => T, codec: {
78
88
  encode: (value: T) => any;
79
89
  decode: (stored: any) => T;
90
+ valid?: (value: any) => boolean;
80
91
  }): T;
81
92
  /**
82
93
  * The block picker's weights (blocks/blocks.weights.json), read once; null
@@ -148,6 +159,10 @@ export type PageTemplate = {
148
159
  * Absolute path to the template source file on disk.
149
160
  */
150
161
  filePath: string;
162
+ /**
163
+ * The components its page composes, read from its source on first use; empty when the source cannot be read.
164
+ */
165
+ components: string[];
151
166
  };
152
167
  /**
153
168
  * A component the project can use, as the ranker reads it.
@@ -28,6 +28,7 @@ import {componentKeywords} from '../search/search.mjs';
28
28
  import {findCoreDir, requireCoreDir} from '../../foundation/fs/paths.mjs';
29
29
  import {persistedDerived} from '../../foundation/fs/gather-cache.mjs';
30
30
  import {analyzeTemplateNeeds} from '../../foundation/discovery/template-needs.mjs';
31
+ import {extractComponents} from '../../foundation/discovery/template-adapter.mjs';
31
32
 
32
33
  /**
33
34
  * Runs one build with a single directory listing per path: the kit resolves
@@ -47,6 +48,7 @@ export {withListingCache} from '../../foundation/fs/listing-cache.mjs';
47
48
  * @property {string} category The template's own `Family - Variant` label; empty when it declares none.
48
49
  * @property {string[]} keywords The ideas the page serves, as its own descriptor names them; empty when it declares none.
49
50
  * @property {string} filePath Absolute path to the template source file on disk.
51
+ * @property {string[]} components The components its page composes, read from its source on first use; empty when the source cannot be read.
50
52
  */
51
53
 
52
54
  /**
@@ -99,18 +101,23 @@ export async function loadTemplates(cwd) {
99
101
  }
100
102
  const pages = templates
101
103
  .filter(t => t.type === 'page' && t.isReady !== false)
102
- .map(t => ({
103
- name: t.dirName,
104
- displayName: t.displayName || t.name,
105
- description: t.description || '',
106
- package: t.package ?? '@astryxdesign/core',
107
- category: t.category || '',
108
- keywords: t.keywords ?? [],
109
- filePath: t.filePath,
110
- // The id `template()` resolves back to this entry: an active replacement
111
- // owns the Core id it names, so that id selects it, not its own.
112
- command: `astryx template ${t.replaces ?? t.dirName} --type page`,
113
- }));
104
+ .map(t =>
105
+ withComponents(
106
+ {
107
+ name: t.dirName,
108
+ displayName: t.displayName || t.name,
109
+ description: t.description || '',
110
+ package: t.package ?? '@astryxdesign/core',
111
+ category: t.category || '',
112
+ keywords: t.keywords ?? [],
113
+ filePath: t.filePath,
114
+ // The id `template()` resolves back to this entry: an active
115
+ // replacement owns the Core id it names, so that id selects it.
116
+ command: `astryx template ${t.replaces ?? t.dirName} --type page`,
117
+ },
118
+ t.filePath,
119
+ ),
120
+ );
114
121
  const blocks = templates
115
122
  .filter(t => t.type === 'block')
116
123
  .map(t => ({
@@ -164,6 +171,30 @@ export function loadWeights() {
164
171
  return weights ?? null;
165
172
  }
166
173
 
174
+ /** @type {{threshold: number, weights: Record<string, number>} | null | undefined} */
175
+ let shellWeights;
176
+
177
+ /**
178
+ * The fixed word table of the shell-start check (kit/shell.weights.json), read
179
+ * once. Null when the file is missing or unreadable.
180
+ * @returns {{threshold: number, weights: Record<string, number>} | null}
181
+ */
182
+ export function loadShellWeights() {
183
+ if (shellWeights === undefined) {
184
+ try {
185
+ shellWeights = JSON.parse(
186
+ fs.readFileSync(
187
+ new URL('./kit/shell.weights.json', import.meta.url),
188
+ 'utf8',
189
+ ),
190
+ );
191
+ } catch {
192
+ shellWeights = null;
193
+ }
194
+ }
195
+ return shellWeights ?? null;
196
+ }
197
+
167
198
  /** @type {import('../../foundation/route/route.mjs').ClassifierWeights | undefined} */
168
199
  let treeWeights;
169
200
 
@@ -338,3 +369,31 @@ export function templateSetupNotes(template, cwd) {
338
369
  export function requireBuildCoreDir(cwd) {
339
370
  return requireCoreDir(cwd);
340
371
  }
372
+
373
+ /**
374
+ * Adds a lazy, non-enumerable `components` getter to a page entry: the page's
375
+ * source is read and parsed only when a caller reads it, once, so loading the
376
+ * catalog stays cheap and the entry's own fields are unchanged.
377
+ * @template {object} T
378
+ * @param {T} entry
379
+ * @param {string | undefined} filePath
380
+ * @returns {T & {readonly components: string[]}}
381
+ */
382
+ function withComponents(entry, filePath) {
383
+ /** @type {string[] | undefined} */
384
+ let components;
385
+ return /** @type {T & {readonly components: string[]}} */ (
386
+ Object.defineProperty(entry, 'components', {
387
+ get() {
388
+ if (components === undefined) {
389
+ try {
390
+ components = filePath ? extractComponents(filePath) : [];
391
+ } catch {
392
+ components = [];
393
+ }
394
+ }
395
+ return components;
396
+ },
397
+ })
398
+ );
399
+ }
@@ -90,6 +90,7 @@ export function pickBlocks(request: string, signals: {
90
90
  export type KeepCatalog = <T>(key: unknown[], compute: () => T, codec: {
91
91
  encode: (value: T) => any;
92
92
  decode: (stored: any) => T;
93
+ valid?: (value: any) => boolean;
93
94
  }) => T;
94
95
  export type BlockPickerWeights = {
95
96
  /**
@@ -45,7 +45,7 @@ import {STOPWORDS} from '../../search/_query.mjs';
45
45
  /**
46
46
  * Keeps a value derived from the catalog between runs (build's adapter does
47
47
  * it beside the kept search catalog), or works it out.
48
- * @typedef {<T>(key: unknown[], compute: () => T, codec: {encode: (value: T) => any, decode: (stored: any) => T}) => T} KeepCatalog
48
+ * @typedef {<T>(key: unknown[], compute: () => T, codec: {encode: (value: T) => any, decode: (stored: any) => T, valid?: (value: any) => boolean}) => T} KeepCatalog
49
49
  */
50
50
 
51
51
  /**
@@ -410,6 +410,23 @@ function computeCatalog(key, catalog, components, weights) {
410
410
  * projection as its numbers.
411
411
  */
412
412
  const CATALOG_CODEC = {
413
+ /**
414
+ * What decode can get wrong in a read-back catalog: its key, each block's
415
+ * component, and projections of one width with finite numbers.
416
+ * @param {any} read
417
+ */
418
+ valid: read => {
419
+ if (read == null || typeof read.key !== 'string') return false;
420
+ const blocks = [...read.blocks.values()];
421
+ const width = blocks[0]?.projected.length;
422
+ return blocks.every(
423
+ (/** @type {any} */ b) =>
424
+ typeof b.component === 'string' &&
425
+ b.projected.length > 0 &&
426
+ b.projected.length === width &&
427
+ [...b.projected].every(Number.isFinite),
428
+ );
429
+ },
413
430
  /** @param {ReturnType<typeof computeCatalog>} read */
414
431
  encode: read => ({
415
432
  key: read.key,
@@ -20,7 +20,8 @@ export const doc = {
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
22
  'START from (always one: the page template a ranker built for long descriptions puts first; for a part ' +
23
- 'of a page, the page it names; else the app shell) and the next two templates, ' +
23
+ 'of a page, the page it names; else the app shell, unless the idea reads as a whole page, which starts ' +
24
+ 'from the closest page template) and the next two templates, ' +
24
25
  'and the unified search grouped around it: the other close page templates, drop-in blocks, and ' +
25
26
  'idea-specific components/hooks, plus the always-on frame + foundation. A template carries the page ' +
26
27
  'frame and spacing, so the kit never recommends composing a page from components.',
@@ -175,6 +175,16 @@ export function rankPages(query, pages) {
175
175
  return d ? Math.log(1 + (n - d + 0.5) / (d + 0.5)) : 0;
176
176
  };
177
177
 
178
+ // How many templates of each family carry each term, for how typical of its
179
+ // family a template's descriptor is.
180
+ /** @type {Map<string, Map<string, number>>} */
181
+ const familyDf = new Map();
182
+ for (const {family, bag} of docs) {
183
+ const counts = familyDf.get(family) ?? new Map();
184
+ familyDf.set(family, counts);
185
+ for (const t of bag.keys()) counts.set(t, (counts.get(t) ?? 0) + 1);
186
+ }
187
+
178
188
  const familyOfWord = familyWordsOf(pages);
179
189
  /** @param {string[]} ts */
180
190
  const familiesIn = ts =>
@@ -226,8 +236,12 @@ export function rankPages(query, pages) {
226
236
  else if (familyNamed) score += BODY_FAMILY;
227
237
  const base = normalized(page.name) === normalized(family);
228
238
  if (familyNamed && base) score += FAMILY_BASE;
239
+ const inFamily = familyDf.get(family);
240
+ let shared = 0;
241
+ for (const t of bag.keys()) shared += (inFamily?.get(t) ?? 1) - 1;
229
242
  return {
230
243
  name: page.name,
244
+ typical: bag.size ? shared / bag.size : 0,
231
245
  score,
232
246
  hits,
233
247
  familyNamed,
@@ -0,0 +1 @@
1
+ {"threshold":1.5,"weights":{"b:above_an":-0.5,"b:above_existing":-0.5,"b:action_and":-1.0,"b:action_with":-1.0,"b:actions_and":-1.0,"b:add_button":1.0,"b:all_and":-1.0,"b:an_add":0.5,"b:an_empty":-1.0,"b:an_existing":-1.5,"b:an_external":-1.0,"b:an_open":-1.0,"b:an_optional":-0.5,"b:analytics_dashboard":-0.5,"b:and_accessible":-1.5,"b:and_action":-1.0,"b:and_after":0.5,"b:and_before":-0.5,"b:and_cancel":-0.5,"b:and_collapsed":-1.0,"b:and_collapsible":0.5,"b:and_compact":1.5,"b:and_confirmation":-0.5,"b:and_current":-0.5,"b:and_dark":-1.0,"b:and_data":0.5,"b:and_date":-0.5,"b:and_dense":0.5,"b:and_detail":1.5,"b:and_empty":-0.5,"b:and_evidence":0.5,"b:and_explicit":1.0,"b:and_inline":1.0,"b:and_links":0.5,"b:and_live":1.0,"b:and_metadata":1.0,"b:and_next":1.0,"b:and_no":-1.0,"b:and_one":0.5,"b:and_open":0.5,"b:and_optional":1.0,"b:and_percentage":-0.5,"b:and_refresh":-1.0,"b:and_saved":-0.5,"b:and_selected":1.0,"b:and_separate":1.0,"b:and_show":1.5,"b:and_source":-0.5,"b:and_status":0.5,"b:and_table":-0.5,"b:and_three":-1.0,"b:and_time":-0.5,"b:and_two":1.0,"b:and_unavailable":-1.5,"b:app_name":-0.5,"b:app_shell":0.5,"b:app_with":0.5,"b:banner_for":-0.5,"b:banner_with":-0.5,"b:bar_and":-1.0,"b:bar_chart":-0.5,"b:bar_with":0.5,"b:bars_and":0.5,"b:before_after":1.0,"b:before_and":0.5,"b:below_the":-0.5,"b:beside_an":-0.5,"b:button_and":1.0,"b:button_in":-0.5,"b:button_opening":-0.5,"b:button_with":-0.5,"b:buttons_and":0.5,"b:calendar_with":1.5,"b:card_with":-1.5,"b:cards_and":1.5,"b:cell_with":-0.5,"b:chart_and":1.0,"b:chart_legend":-0.5,"b:chart_with":-1.5,"b:charts_with":-1.5,"b:columns_and":-0.5,"b:compact_chart":-0.5,"b:compact_inline":-0.5,"b:compact_model":-0.5,"b:compact_read":-0.5,"b:compact_status":-0.5,"b:compact_table":-1.0,"b:comparison_table":0.5,"b:comparison_with":1.0,"b:confirmation_dialog":-0.5,"b:controls_for":-0.5,"b:controls_with":-1.5,"b:copy_link":-1.0,"b:counts_and":1.0,"b:coverage_and":-0.5,"b:coverage_table":-0.5,"b:dashboard_with":0.5,"b:data_dashboard":-0.5,"b:data_source":0.5,"b:data_table":-0.5,"b:date_and":-0.5,"b:dense_data":1.0,"b:dense_read":0.5,"b:dense_table":-1.0,"b:description_and":0.5,"b:detail_dialog":1.0,"b:detail_page":-0.5,"b:detail_panel":0.5,"b:detail_with":1.0,"b:details_and":-0.5,"b:details_dialog":-0.5,"b:details_panel":0.5,"b:details_with":-0.5,"b:dialog_and":-0.5,"b:dialog_with":-2.5,"b:each_with":-1.5,"b:empty_and":0.5,"b:empty_state":-0.5,"b:empty_states":-0.5,"b:error_and":0.5,"b:error_banner":0.5,"b:error_states":-0.5,"b:evidence_and":1.0,"b:evidence_table":1.0,"b:existing_analytics":-0.5,"b:existing_app":3.0,"b:existing_dashboard":-0.5,"b:existing_dense":-2.0,"b:existing_metric":-0.5,"b:existing_metrics":-0.5,"b:existing_overview":-0.5,"b:existing_page":-1.0,"b:existing_review":-0.5,"b:existing_run":-0.5,"b:existing_sidebar":-0.5,"b:existing_test":-0.5,"b:external_link":-0.5,"b:external_links":-0.5,"b:fields_and":-0.5,"b:filter_for":-0.5,"b:filters_and":0.5,"b:filters_with":-0.5,"b:for_an":1.0,"b:for_the":1.0,"b:form_and":0.5,"b:form_dialog":-0.5,"b:form_to":0.5,"b:form_with":1.0,"b:full_width":0.5,"b:graph_with":-0.5,"b:grid_of":1.0,"b:grid_with":1.0,"b:header_and":-2.0,"b:header_with":-0.5,"b:heading_and":-0.5,"b:headings_and":-0.5,"b:health_dashboard":-0.5,"b:history_table":0.5,"b:history_with":0.5,"b:hover_card":-0.5,"b:in_an":-0.5,"b:inside_existing":-0.5,"b:inside_the":2.0,"b:inspector_with":-1.0,"b:keep_existing":-0.5,"b:keep_the":-2.0,"b:keyboard_accessible":-0.5,"b:label_and":-1.0,"b:labels_and":-0.5,"b:landing_page":-0.5,"b:last_updated":0.5,"b:left_and":1.0,"b:light_and":-0.5,"b:line_chart":1.5,"b:link_button":-0.5,"b:link_to":1.0,"b:links_and":-0.5,"b:links_in":-1.0,"b:links_to":1.5,"b:list_and":-1.0,"b:list_with":1.0,"b:loading_empty":1.0,"b:loading_error":0.5,"b:menu_with":-1.0,"b:metadata_and":0.5,"b:metadata_rows":-0.5,"b:metadata_with":-1.0,"b:metric_card":-0.5,"b:metric_cards":-1.0,"b:metrics_and":-1.0,"b:metrics_table":-1.0,"b:metrics_with":0.5,"b:modal_with":-0.5,"b:name_and":-0.5,"b:names_and":-0.5,"b:navigation_and":0.5,"b:navigation_with":-0.5,"b:next_action":0.5,"b:next_to":-0.5,"b:notice_with":-0.5,"b:of_an":-0.5,"b:of_the":0.5,"b:on_an":-0.5,"b:on_hover":-0.5,"b:on_mobile":-0.5,"b:on_the":0.5,"b:one_compact":-0.5,"b:one_primary":-0.5,"b:overview_and":-1.0,"b:overview_with":2.0,"b:page_and":-0.5,"b:page_for":1.0,"b:page_frame":-1.0,"b:page_header":-1.0,"b:page_with":1.0,"b:panel_with":-2.5,"b:per_row":0.5,"b:picker_with":-0.5,"b:popover_with":-1.0,"b:preserve_the":-0.5,"b:primary_action":0.5,"b:report_with":1.0,"b:results_table":-0.5,"b:results_with":-0.5,"b:retry_button":-0.5,"b:review_page":0.5,"b:review_queue":0.5,"b:review_table":-0.5,"b:review_with":0.5,"b:right_side":-0.5,"b:row_and":-0.5,"b:row_with":-0.5,"b:rows_and":0.5,"b:rows_in":-0.5,"b:rows_with":-0.5,"b:run_history":0.5,"b:save_and":-0.5,"b:search_and":-0.5,"b:search_with":1.5,"b:searchable_multi":-1.0,"b:section_with":-1.0,"b:sections_with":-1.5,"b:segmented_control":-0.5,"b:selector_for":-0.5,"b:selector_in":-0.5,"b:selector_to":-1.0,"b:selectors_and":-0.5,"b:series_chart":-1.0,"b:shell_and":1.5,"b:shell_with":-0.5,"b:side_navigation":-1.0,"b:sidebar_and":1.5,"b:sidebar_with":-1.5,"b:single_page":1.5,"b:source_and":0.5,"b:source_details":-0.5,"b:source_links":1.0,"b:state_for":-0.5,"b:status_in":-0.5,"b:status_rows":1.0,"b:summary_and":1.0,"b:summary_card":-0.5,"b:summary_table":-0.5,"b:summary_with":-1.0,"b:switch_and":0.5,"b:tab_with":0.5,"b:table_and":0.5,"b:table_cell":-0.5,"b:table_column":-1.0,"b:table_of":0.5,"b:table_row":-1.0,"b:table_rows":-0.5,"b:table_to":-0.5,"b:table_with":0.5,"b:tables_and":1.0,"b:tables_with":0.5,"b:tags_and":-0.5,"b:text_and":-0.5,"b:text_input":2.5,"b:that_opens":-0.5,"b:the_app":1.0,"b:the_current":-1.5,"b:the_existing":-1.0,"b:the_left":0.5,"b:the_page":-1.0,"b:the_right":0.5,"b:the_selected":0.5,"b:time_and":-1.0,"b:time_range":0.5,"b:time_series":0.5,"b:timeline_with":-0.5,"b:timestamp_and":-0.5,"b:title_and":-0.5,"b:to_show":-1.0,"b:to_the":-1.0,"b:toggle_to":-0.5,"b:tokens_and":-0.5,"b:tool_with":0.5,"b:toolbar_and":1.0,"b:toolbar_with":-1.0,"b:trend_and":0.5,"b:two_column":-0.5,"b:two_compact":-1.0,"b:unavailable_states":-1.0,"b:update_the":-0.5,"b:using_the":1.0,"b:warning_and":-0.5,"b:while_preserving":-0.5,"b:with_clickable":0.5,"b:with_colored":-0.5,"b:with_compact":-0.5,"b:with_copy":-1.0,"b:with_counts":-0.5,"b:with_current":0.5,"b:with_editable":0.5,"b:with_exact":-0.5,"b:with_expandable":-1.0,"b:with_explicit":-0.5,"b:with_filters":0.5,"b:with_four":-0.5,"b:with_grouped":0.5,"b:with_hover":1.0,"b:with_independent":-0.5,"b:with_inline":1.5,"b:with_one":0.5,"b:with_per":0.5,"b:with_progress":-1.0,"b:with_read":-0.5,"b:with_request":1.0,"b:with_search":-0.5,"b:with_separate":-0.5,"b:with_shared":0.5,"b:with_tabs":0.5,"b:with_the":-0.5,"b:with_title":-1.0,"b:without_changing":-0.5,"b:workflow_with":1.5,"b:workspace_with":1.5,"base":-0.5,"commas:0":-0.5,"commas:3":1.0,"commas:4":1.0,"h:3":-0.5,"k:edit":-1.0,"k:page":0.5,"k:part":-0.5,"len:0":-1.0,"len:1":-1.0,"len:2":-0.5,"len:4":0.5,"len:5":0.5,"len:6":1.5,"s:0":-0.5,"s:4":0.5,"s:5":0.5,"u:above":-0.5,"u:accepted":-0.5,"u:access":1.0,"u:accessible":-1.0,"u:account":0.5,"u:actions":-0.5,"u:add":-1.5,"u:admin":1.0,"u:after":-0.5,"u:agent":0.5,"u:ai":0.5,"u:alert":1.0,"u:all":-0.5,"u:analytics":0.5,"u:animated":0.5,"u:answer":0.5,"u:application":0.5,"u:apply":-0.5,"u:architecture":1.0,"u:area":-0.5,"u:areas":1.0,"u:artifact":-0.5,"u:artifacts":-0.5,"u:as":-0.5,"u:assistant":-0.5,"u:at":0.5,"u:attachment":-1.0,"u:badge":-1.0,"u:banner":-0.5,"u:bar":-0.5,"u:below":-1.0,"u:benchmark":1.0,"u:between":-0.5,"u:blocked":-0.5,"u:blocking":-0.5,"u:blocks":0.5,"u:board":1.5,"u:body":0.5,"u:bounded":-1.0,"u:brief":0.5,"u:browser":1.0,"u:bug":-1.0,"u:bulk":-0.5,"u:button":-0.5,"u:buttons":-0.5,"u:by":0.5,"u:calendar":1.0,"u:cancel":-0.5,"u:candidate":0.5,"u:candidates":-0.5,"u:capture":0.5,"u:card":-0.5,"u:catalog":0.5,"u:category":0.5,"u:cells":0.5,"u:center":0.5,"u:change":-0.5,"u:changes":-0.5,"u:changing":-0.5,"u:chart":-1.0,"u:charts":0.5,"u:check":0.5,"u:checkboxes":-1.0,"u:chips":-1.0,"u:choose":-1.0,"u:clear":-1.0,"u:close":-0.5,"u:closed":-1.5,"u:cohort":0.5,"u:collapse":-0.5,"u:collapsed":-1.5,"u:collapsible":-0.5,"u:color":-0.5,"u:colors":-0.5,"u:columns":0.5,"u:comment":-0.5,"u:comments":-1.5,"u:compact":-0.5,"u:compare":2.0,"u:completed":-1.0,"u:completion":-0.5,"u:component":1.0,"u:concise":-0.5,"u:config":1.0,"u:configuration":-0.5,"u:confirm":-1.0,"u:confirmed":-1.0,"u:console":1.0,"u:containing":0.5,"u:content":-1.0,"u:contextual":-1.0,"u:conversation":-0.5,"u:copy":-0.5,"u:count":-0.5,"u:counts":-1.0,"u:create":0.5,"u:custom":-0.5,"u:daily":0.5,"u:dark":0.5,"u:dashboard":0.5,"u:data":-0.5,"u:dataset":0.5,"u:day":-0.5,"u:days":-0.5,"u:decision":0.5,"u:decisions":1.5,"u:default":-2.0,"u:definition":-0.5,"u:definitions":0.5,"u:delete":-0.5,"u:delta":-1.5,"u:demand":-0.5,"u:dense":0.5,"u:dependency":-1.0,"u:description":-0.5,"u:descriptions":-1.0,"u:destination":-1.5,"u:detailed":-0.5,"u:details":0.5,"u:diagnostic":0.5,"u:diagnostics":0.5,"u:dialog":-1.0,"u:directory":2.5,"u:disabled":-0.5,"u:disclosure":-0.5,"u:display":-0.5,"u:distinct":-0.5,"u:document":1.5,"u:documentation":0.5,"u:dot":-0.5,"u:dots":0.5,"u:drafts":-0.5,"u:drawer":-1.0,"u:drill":0.5,"u:drop":-0.5,"u:dropdown":-0.5,"u:duration":-0.5,"u:each":1.0,"u:editable":1.0,"u:editor":-0.5,"u:edits":-1.0,"u:embedded":-1.0,"u:end":-0.5,"u:entity":0.5,"u:error":-0.5,"u:event":0.5,"u:events":0.5,"u:evidence":-0.5,"u:existing":-2.5,"u:expand":-1.0,"u:expandable":-0.5,"u:expanded":-1.5,"u:experiment":-0.5,"u:explain":-1.0,"u:explaining":-0.5,"u:explicit":-1.0,"u:failed":-0.5,"u:failure":-0.5,"u:fallback":-1.0,"u:feature":1.0,"u:feed":0.5,"u:feedback":-0.5,"u:fields":-0.5,"u:file":0.5,"u:filterable":1.5,"u:filtered":-1.0,"u:filters":0.5,"u:findings":0.5,"u:first":0.5,"u:flow":-0.5,"u:follow":0.5,"u:footer":-1.5,"u:for":-1.0,"u:form":1.0,"u:four":1.0,"u:from":-0.5,"u:gallery":0.5,"u:gap":-0.5,"u:gate":1.0,"u:generate":0.5,"u:generated":-0.5,"u:global":0.5,"u:graph":0.5,"u:grid":1.0,"u:group":0.5,"u:grouped":0.5,"u:guide":2.0,"u:header":-0.5,"u:headers":-0.5,"u:heading":-0.5,"u:headings":0.5,"u:headline":0.5,"u:health":0.5,"u:hierarchy":-0.5,"u:highlight":-0.5,"u:highlighted":0.5,"u:home":0.5,"u:horizontal":0.5,"u:host":-0.5,"u:hours":0.5,"u:hover":-1.0,"u:icon":-1.5,"u:icons":-0.5,"u:id":-0.5,"u:in":-1.0,"u:inbox":1.0,"u:independently":0.5,"u:indicator":-0.5,"u:info":-1.0,"u:information":-0.5,"u:informational":-1.0,"u:inline":-1.5,"u:inside":-1.0,"u:inspector":1.5,"u:intake":1.5,"u:interactive":1.0,"u:into":-1.0,"u:inventory":1.5,"u:item":-0.5,"u:items":-1.5,"u:its":0.5,"u:job":0.5,"u:jobs":-0.5,"u:json":0.5,"u:keep":-1.0,"u:keeping":-0.5,"u:label":-1.0,"u:labeled":-0.5,"u:labeling":1.0,"u:labels":-1.0,"u:landing":1.0,"u:legend":-0.5,"u:level":-1.0,"u:library":0.5,"u:lifecycle":0.5,"u:light":-0.5,"u:line":-0.5,"u:lines":-0.5,"u:linked":-1.0,"u:links":-0.5,"u:list":1.0,"u:listing":1.0,"u:lists":0.5,"u:load":-0.5,"u:loading":-1.0,"u:log":2.0,"u:long":-0.5,"u:lookup":1.0,"u:manager":0.5,"u:match":-1.0,"u:matching":1.0,"u:matrix":1.5,"u:measured":0.5,"u:measurement":0.5,"u:message":-0.5,"u:messages":-1.5,"u:metadata":-0.5,"u:metric":0.5,"u:minimal":-0.5,"u:mobile":1.0,"u:modal":-1.0,"u:mode":-0.5,"u:model":-0.5,"u:monitoring":-0.5,"u:more":0.5,"u:multi":0.5,"u:multiple":-0.5,"u:my":1.0,"u:name":-0.5,"u:names":-0.5,"u:nav":-0.5,"u:navigation":-0.5,"u:neutral":-1.0,"u:new":-0.5,"u:node":-0.5,"u:not":-1.0,"u:note":1.0,"u:numbered":-0.5,"u:numbers":-1.5,"u:observed":-1.0,"u:of":0.5,"u:on":-1.0,"u:only":0.5,"u:open":-0.5,"u:opening":-0.5,"u:opens":-0.5,"u:operations":0.5,"u:option":0.5,"u:optional":-1.0,"u:options":-1.5,"u:outcome":-1.0,"u:output":-0.5,"u:over":-1.0,"u:overlay":-1.0,"u:owner":0.5,"u:page":1.0,"u:pages":0.5,"u:paginated":0.5,"u:pagination":-0.5,"u:pane":1.0,"u:panel":-0.5,"u:panels":1.0,"u:percentage":-0.5,"u:performance":0.5,"u:person":-0.5,"u:pill":-1.5,"u:pills":-0.5,"u:pinned":0.5,"u:pipeline":-1.0,"u:placeholder":-2.0,"u:plus":0.5,"u:popover":-0.5,"u:post":0.5,"u:presentation":1.5,"u:preserve":-1.5,"u:preserving":-2.5,"u:preview":0.5,"u:previews":0.5,"u:primary":0.5,"u:priority":1.5,"u:production":0.5,"u:progress":0.5,"u:project":0.5,"u:projects":1.0,"u:prominent":0.5,"u:prompt":1.0,"u:public":1.0,"u:publication":0.5,"u:publish":1.0,"u:published":1.5,"u:quality":-0.5,"u:query":-0.5,"u:question":1.5,"u:queue":1.0,"u:quick":0.5,"u:quiet":1.0,"u:rail":-2.0,"u:range":-1.0,"u:ranked":0.5,"u:rate":0.5,"u:read":0.5,"u:readiness":-0.5,"u:reading":0.5,"u:reason":-0.5,"u:reasoning":-0.5,"u:recording":0.5,"u:reference":0.5,"u:region":-1.0,"u:release":0.5,"u:rename":-0.5,"u:report":1.0,"u:reporting":-0.5,"u:reports":0.5,"u:request":0.5,"u:requirement":-0.5,"u:resizable":-0.5,"u:response":-1.0,"u:responsive":-0.5,"u:result":-0.5,"u:results":0.5,"u:retain":-1.0,"u:retry":-1.0,"u:review":0.5,"u:reviewed":0.5,"u:rollout":-0.5,"u:routing":1.0,"u:rows":0.5,"u:rule":-0.5,"u:running":-1.5,"u:runs":0.5,"u:save":-1.5,"u:saved":0.5,"u:scoped":0.5,"u:score":0.5,"u:scorecard":0.5,"u:scroll":-1.5,"u:scrollable":0.5,"u:scrolling":-0.5,"u:search":0.5,"u:section":-1.0,"u:sections":1.0,"u:segment":-1.0,"u:select":-1.0,"u:selectable":-0.5,"u:selecting":-0.5,"u:selection":0.5,"u:semantic":-0.5,"u:send":-0.5,"u:separate":-1.0,"u:separated":-1.0,"u:series":-0.5,"u:server":0.5,"u:service":0.5,"u:sessions":0.5,"u:setup":0.5,"u:share":-1.0,"u:shared":-0.5,"u:shell":0.5,"u:short":0.5,"u:show":-0.5,"u:shows":1.0,"u:side":0.5,"u:sidebar":-0.5,"u:single":0.5,"u:six":1.0,"u:small":-0.5,"u:snapshot":-1.0,"u:sortable":0.5,"u:sources":-1.0,"u:spacing":-1.0,"u:stacked":-1.0,"u:stage":0.5,"u:stale":-1.0,"u:step":-0.5,"u:stepper":1.0,"u:steps":0.5,"u:sticky":0.5,"u:strip":-1.0,"u:style":1.0,"u:submission":0.5,"u:submit":1.0,"u:suggestions":-1.0,"u:summaries":0.5,"u:surface":-0.5,"u:svg":0.5,"u:system":1.5,"u:tab":-0.5,"u:table":0.5,"u:tables":0.5,"u:tabs":0.5,"u:tag":-1.0,"u:tags":-0.5,"u:target":-0.5,"u:team":1.0,"u:technical":-0.5,"u:text":-0.5,"u:that":-0.5,"u:the":-1.0,"u:theme":0.5,"u:then":2.0,"u:tiles":1.0,"u:timestamp":-1.5,"u:timing":0.5,"u:to":-0.5,"u:toggles":1.0,"u:token":-0.5,"u:tokens":-0.5,"u:tool":1.0,"u:toolbar":-0.5,"u:tools":0.5,"u:top":-1.0,"u:totals":-0.5,"u:trace":-0.5,"u:tracker":0.5,"u:tracking":1.0,"u:transcript":-0.5,"u:tree":1.0,"u:trends":2.0,"u:triage":0.5,"u:turn":-0.5,"u:type":-0.5,"u:typed":-0.5,"u:types":-1.5,"u:unavailable":-1.5,"u:up":-0.5,"u:updated":0.5,"u:upload":1.0,"u:url":0.5,"u:usage":-1.0,"u:use":-0.5,"u:using":0.5,"u:validation":-1.0,"u:value":-0.5,"u:values":-1.0,"u:version":-1.0,"u:versus":-0.5,"u:vertical":-0.5,"u:vertically":-0.5,"u:view":0.5,"u:viewer":1.0,"u:visible":-0.5,"u:visual":1.0,"u:visualization":-0.5,"u:volume":0.5,"u:warning":-1.0,"u:warnings":0.5,"u:weekly":1.5,"u:when":-2.0,"u:where":1.0,"u:while":-2.0,"u:widget":-1.0,"u:widgets":-1.5,"u:windows":1.0,"u:with":0.5,"u:without":-1.5,"u:wizard":-0.5,"u:work":0.5,"u:workflow":0.5,"u:workspace":1.0,"u:wrapped":-0.5,"u:wrapping":-0.5}}
@@ -0,0 +1,26 @@
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
+ * Whether an idea carries an edit phrase. It needs no word table.
6
+ * @param {string} idea
7
+ * @returns {boolean}
8
+ */
9
+ export function hasEditPhrase(idea: string): boolean;
10
+ /**
11
+ * The ranker's best page template that is not a shell, or undefined.
12
+ * @param {import('./rank.mjs').RankedPage[]} ranked
13
+ */
14
+ export function bestPage(ranked: import("./rank.mjs").RankedPage[]): import("./words.mjs").RankedPage | undefined;
15
+ /**
16
+ * The text score without its threshold, and whether the edit rule fires.
17
+ * Null without the table or a page to weigh.
18
+ * @param {string} idea
19
+ * @param {import('./rank.mjs').IdeaKind} kind
20
+ * @param {import('./rank.mjs').RankedPage[]} ranked
21
+ * @returns {{edit: boolean, score: number} | null}
22
+ */
23
+ export function shellCallScore(idea: string, kind: import("./rank.mjs").IdeaKind, ranked: import("./rank.mjs").RankedPage[]): {
24
+ edit: boolean;
25
+ score: number;
26
+ } | null;
@@ -0,0 +1,87 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file Whether an idea that build would start on the app shell still asks
5
+ * for a whole page.
6
+ *
7
+ * @input The idea, its kind (`ideaKind`), and the page ranker's output.
8
+ * @output True when the idea reads as a new page, so build starts from the
9
+ * closest page template instead of the empty shell.
10
+ * @position Beside start.mjs (api/build/kit/). It runs only on a shell start,
11
+ * after the placement rules. An idea with an edit phrase keeps the shell.
12
+ *
13
+ * The call is a linear score over fixed weights
14
+ * (`shell.weights.json`): the idea's words and word pairs, its kind, its
15
+ * length, and how strongly the ranker's best page template matched.
16
+ */
17
+
18
+ import {loadShellWeights} from '../_adapter.mjs';
19
+ import {SHELL_FAMILY} from './words.mjs';
20
+
21
+ /**
22
+ * Words that mark a change to a page or app the builder already has.
23
+ */
24
+ const EDIT =
25
+ /\b(existing|current|my (page|app|dashboard|screen|site)|add (a |an |the )?\w* ?to|change|fix|move|rename|restyle|update|modify|replace|remove|tweak|adjust|improve|refactor|our (page|app))\b/;
26
+
27
+ /**
28
+ * Whether an idea carries an edit phrase. It needs no word table.
29
+ * @param {string} idea
30
+ * @returns {boolean}
31
+ */
32
+ export function hasEditPhrase(idea) {
33
+ return EDIT.test(String(idea).toLowerCase());
34
+ }
35
+
36
+ /**
37
+ * The features the weights are keyed by.
38
+ * @param {string} text the idea, lower case
39
+ * @param {string} kind
40
+ * @param {import('./rank.mjs').RankedPage | undefined} best the ranker's best
41
+ * page template that is not a shell
42
+ * @returns {Set<string>}
43
+ */
44
+ function featuresOf(text, kind, best) {
45
+ const words = text.match(/[a-z]+/g) ?? [];
46
+ const features = new Set(['bias', `k:${kind}`]);
47
+ words.forEach((word, i) => {
48
+ features.add(`u:${word}`);
49
+ if (i > 0) features.add(`b:${words[i - 1]}_${word}`);
50
+ });
51
+ if (best) {
52
+ features.add(`s:${Math.min(Math.floor(best.score / 5), 6)}`);
53
+ features.add(`h:${Math.min(best.hits, 4)}`);
54
+ if (best.familyNamed) features.add('fam');
55
+ if (best.base) features.add('base');
56
+ }
57
+ features.add(`len:${Math.min(Math.floor(words.length / 5), 6)}`);
58
+ features.add(`commas:${Math.min((text.match(/,/g) ?? []).length, 4)}`);
59
+ return features;
60
+ }
61
+
62
+ /**
63
+ * The ranker's best page template that is not a shell, or undefined.
64
+ * @param {import('./rank.mjs').RankedPage[]} ranked
65
+ */
66
+ export function bestPage(ranked) {
67
+ return ranked.find(r => r.family !== SHELL_FAMILY && r.score > 0);
68
+ }
69
+
70
+ /**
71
+ * The text score without its threshold, and whether the edit rule fires.
72
+ * Null without the table or a page to weigh.
73
+ * @param {string} idea
74
+ * @param {import('./rank.mjs').IdeaKind} kind
75
+ * @param {import('./rank.mjs').RankedPage[]} ranked
76
+ * @returns {{edit: boolean, score: number} | null}
77
+ */
78
+ export function shellCallScore(idea, kind, ranked) {
79
+ const weights = loadShellWeights();
80
+ if (!weights) return null;
81
+ const text = String(idea).toLowerCase();
82
+ const best = bestPage(ranked);
83
+ let score = 0;
84
+ for (const feature of featuresOf(text, kind, best))
85
+ score += weights.weights[feature] ?? 0;
86
+ return {edit: EDIT.test(text), score};
87
+ }
@@ -8,7 +8,8 @@
8
8
  import {loadWeights} from '../_adapter.mjs';
9
9
  import {asksForNewPage} from './kind.mjs';
10
10
  import {pickAlternatives, pickStart} from './rank.mjs';
11
- import {blendOrder, weighStart} from './weights.mjs';
11
+ import {hasEditPhrase, shellCallScore} from './shellcall.mjs';
12
+ import {blendOrder, blendSummary, weighStart} from './weights.mjs';
12
13
 
13
14
  /**
14
15
  * @typedef {import('../../search/search.type.mjs').SearchResultEntry} SearchResultEntry
@@ -57,6 +58,60 @@ function placement(kind, inPage) {
57
58
  return null;
58
59
  }
59
60
 
61
+ /**
62
+ * Fixed coefficients of a logistic decision over build's own numbers: bias,
63
+ * whole page, edit, blend margin over the shell, the shell's blend score, the
64
+ * gap to the blend's second template, the idea's comma count, the text score
65
+ * (shellcall.mjs) and its edit-word flag. Fixed constants; nothing is trained
66
+ * at run time. An edit phrase keeps the shell before the decision runs, so the
67
+ * two edit inputs are 0 whenever it runs; they stay because the constants were
68
+ * fit with them.
69
+ */
70
+ const LIFT = [
71
+ -0.7707, 0.6706, -0.2642, 0.2815, -0.1621, 0.1759, 0.1713, 0.2891, -0.3491,
72
+ ];
73
+
74
+ /** The decision replaces the shell with a page when p >= 0.30. */
75
+ const LIFT_AT = 0.3;
76
+
77
+ /**
78
+ * The page template that replaces an app-shell start, or null to keep the
79
+ * shell. The blend's best template takes the start when the decision's
80
+ * whole-page probability is at least 0.30.
81
+ * @param {import('./rank.mjs').RankedPage[]} ranked
82
+ * @param {import('./rank.mjs').IdeaKind} kind
83
+ * @param {PageTemplate[]} catalog
84
+ * @param {string} idea
85
+ * @returns {PageTemplate | null}
86
+ */
87
+ function liftFromShell(ranked, kind, catalog, idea) {
88
+ const b = blendSummary(
89
+ idea,
90
+ ranked,
91
+ pickStart(ranked, 'page'),
92
+ catalog,
93
+ loadWeights(),
94
+ );
95
+ if (!b || !b.best) return null;
96
+ // A change to a page or app the builder already has keeps its shell.
97
+ if (hasEditPhrase(idea)) return null;
98
+ const text = shellCallScore(idea, kind, ranked);
99
+ const x = [
100
+ 1,
101
+ kind === 'page' ? 1 : 0,
102
+ kind === 'edit' ? 1 : 0,
103
+ b.bestScore - b.shell,
104
+ b.shell,
105
+ b.bestScore - b.secondScore,
106
+ (String(idea).match(/,/g) ?? []).length,
107
+ text?.score ?? 0,
108
+ text?.edit ? 1 : 0,
109
+ ];
110
+ const logit = x.reduce((s, v, i) => s + v * LIFT[i], 0);
111
+ if (1 / (1 + Math.exp(-logit)) < LIFT_AT) return null;
112
+ return catalog.find(t => t.name === b.best) ?? null;
113
+ }
114
+
60
115
  /**
61
116
  * The template to start from: the ready page the ranker puts first when it
62
117
  * has the evidence to lead, else the first fallback shell the project can
@@ -113,10 +168,18 @@ export function chooseStart(ranked, kind, pages, directMatch, catalog, idea) {
113
168
  ? proposed
114
169
  : null
115
170
  : (ranked.find(r => r.name === weighed) ?? proposed);
116
- const closest = pick && catalog.find(t => t.name === pick.name);
117
- if (pick && closest) {
171
+ // An idea that would start on the app shell starts from the blend's best page
172
+ // when the decision's whole-page probability is at least 0.30. A direct match,
173
+ // ready or not, keeps the start and reason it already has.
174
+ const lifted =
175
+ !direct && (!pick || pick.family === 'Shell')
176
+ ? liftFromShell(ranked, kind, catalog, idea)
177
+ : null;
178
+ const closest = lifted ?? (pick && catalog.find(t => t.name === pick.name));
179
+ if (closest) {
118
180
  const agrees = closest.name === direct;
119
- const place = placement(kind, pick.base && pick.familyNamed);
181
+ const place =
182
+ lifted || !pick ? null : placement(kind, pick.base && pick.familyNamed);
120
183
  return {
121
184
  ...asTemplate(closest),
122
185
  basis: agrees ? 'direct' : 'closest',
@@ -40,6 +40,21 @@ export function weighStart(idea: string, ranked: import("./rank.mjs").RankedPage
40
40
  weights?: WeightsFile | null;
41
41
  newPage?: boolean;
42
42
  }): string | null | undefined;
43
+ /**
44
+ * The blend's scores: the app shell's, and the best non-shell template with
45
+ * its score and the runner-up's. Null without weights.
46
+ * @param {string} idea
47
+ * @param {import('./rank.mjs').RankedPage[]} ranked
48
+ * @param {import('./rank.mjs').RankedPage | null} pick
49
+ * @param {DescribedTemplate[]} catalog
50
+ * @param {WeightsFile | null} weights
51
+ */
52
+ export function blendSummary(idea: string, ranked: import("./rank.mjs").RankedPage[], pick: import("./rank.mjs").RankedPage | null, catalog: DescribedTemplate[], weights: WeightsFile | null): {
53
+ shell: number;
54
+ best: string;
55
+ bestScore: number;
56
+ secondScore: number;
57
+ } | null;
43
58
  /** The app shell, as one candidate. */
44
59
  export const SHELL: "SHELL";
45
60
  export type WeightTable = {
@@ -77,4 +92,6 @@ export type DescribedTemplate = {
77
92
  displayName?: string | undefined;
78
93
  category?: string | undefined;
79
94
  keywords?: string[] | undefined;
95
+ description?: string | undefined;
96
+ components?: string[] | undefined;
80
97
  };