@astryxdesign/cli 0.7.17-canary.g17f7ffc → 0.7.17-canary.g27bb774

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 (204) hide show
  1. package/README.md +1 -1
  2. package/api/build/_adapter.d.mts +11 -0
  3. package/api/build/_adapter.mjs +18 -0
  4. package/api/build/build.doc.mjs +2 -2
  5. package/api/build/build.type.d.mts +1 -1
  6. package/api/build/build.type.mjs +1 -1
  7. package/api/build/kit/kit.mjs +1 -1
  8. package/api/build/kit/signals.mjs +13 -2
  9. package/api/build/kit/start.d.mts +4 -2
  10. package/api/build/kit/start.mjs +42 -12
  11. package/api/build/kit/weights.d.mts +14 -4
  12. package/api/build/kit/weights.json +1 -1
  13. package/api/build/kit/weights.mjs +34 -9
  14. package/api/component/__fixtures__/resolutions/modules.txt +1 -1
  15. package/api/component/_adapter.d.mts +14 -7
  16. package/api/component/_adapter.mjs +95 -18
  17. package/api/component/component.mjs +1 -0
  18. package/api/discover/discover.mjs +12 -3
  19. package/api/doctor/_adapter.d.mts +11 -0
  20. package/api/doctor/_adapter.mjs +29 -0
  21. package/api/doctor/doctor.d.mts +11 -0
  22. package/api/doctor/doctor.mjs +42 -23
  23. package/api/doctor/theme-checks.mjs +2 -2
  24. package/api/integration/check/check.mjs +6 -1
  25. package/api/integration/pack-check.mjs +35 -3
  26. package/api/integration/validate-integration.mjs +14 -5
  27. package/api/integration/validate-integration.type.d.mts +4 -0
  28. package/api/integration/validate-integration.type.mjs +1 -0
  29. package/api/integration/validateIntegration.doc.mjs +1 -1
  30. package/api/template/copy/copy.mjs +60 -20
  31. package/api/template/template.doc.mjs +3 -3
  32. package/api/template/template.mjs +38 -2
  33. package/api/template/template.type.mjs +1 -1
  34. package/api/theme/_adapter.d.mts +8 -0
  35. package/api/theme/_adapter.mjs +29 -0
  36. package/api/theme/_app-provider.d.mts +31 -0
  37. package/api/theme/_app-provider.mjs +135 -0
  38. package/api/theme/add/add.mjs +3 -1
  39. package/api/theme/build/build.d.mts +48 -5
  40. package/api/theme/build/build.mjs +814 -211
  41. package/api/theme/build/family.mjs +43 -14
  42. package/api/theme/build/font-warning.d.mts +27 -1
  43. package/api/theme/build/font-warning.mjs +88 -22
  44. package/api/theme/build/null-values.mjs +22 -4
  45. package/api/theme/build/self-contained.d.mts +90 -0
  46. package/api/theme/build/self-contained.mjs +312 -0
  47. package/api/theme/build/style-keys.d.mts +75 -0
  48. package/api/theme/build/style-keys.mjs +487 -0
  49. package/api/theme/build/written-values.d.mts +35 -0
  50. package/api/theme/build/written-values.mjs +223 -0
  51. package/api/theme/remove/remove.mjs +4 -1
  52. package/api/theme/theme.type.d.mts +28 -0
  53. package/api/theme/theme.type.mjs +18 -1
  54. package/api/theme/themeAdd.doc.mjs +1 -1
  55. package/api/theme/themeRemove.doc.mjs +1 -1
  56. package/api/theme-edit/_adapter.d.mts +3 -1
  57. package/api/theme-edit/_adapter.mjs +59 -3
  58. package/api/theme-edit/_catalog.d.mts +8 -2
  59. package/api/theme-edit/_catalog.mjs +55 -8
  60. package/api/theme-edit/_check.d.mts +54 -8
  61. package/api/theme-edit/_check.mjs +761 -140
  62. package/api/theme-edit/_compiler.d.mts +1 -0
  63. package/api/theme-edit/_compiler.mjs +82 -6
  64. package/api/theme-edit/_context.d.mts +37 -1
  65. package/api/theme-edit/_context.mjs +178 -34
  66. package/api/theme-edit/_css.d.mts +13 -0
  67. package/api/theme-edit/_css.mjs +37 -11
  68. package/api/theme-edit/_edit.d.mts +10 -0
  69. package/api/theme-edit/_edit.mjs +1741 -323
  70. package/api/theme-edit/_how-commands.d.mts +11 -0
  71. package/api/theme-edit/_how-commands.mjs +352 -10
  72. package/api/theme-edit/_how-question.d.mts +16 -1
  73. package/api/theme-edit/_how-question.mjs +3873 -329
  74. package/api/theme-edit/_how.d.mts +8 -0
  75. package/api/theme-edit/_how.mjs +73 -4
  76. package/api/theme-edit/_normal.d.mts +16 -8
  77. package/api/theme-edit/_normal.mjs +187 -37
  78. package/api/theme-edit/_palette.mjs +45 -12
  79. package/api/theme-edit/_part-words.mjs +23 -2
  80. package/api/theme-edit/_parts.d.mts +4 -0
  81. package/api/theme-edit/_parts.mjs +102 -15
  82. package/api/theme-edit/_preview-app.d.mts +8 -1
  83. package/api/theme-edit/_preview-app.mjs +382 -198
  84. package/api/theme-edit/_preview.d.mts +51 -1
  85. package/api/theme-edit/_preview.mjs +280 -25
  86. package/api/theme-edit/_settings.d.mts +104 -13
  87. package/api/theme-edit/_settings.mjs +1586 -280
  88. package/api/theme-edit/_tables.d.mts +5 -0
  89. package/api/theme-edit/_tables.mjs +12 -4
  90. package/api/theme-edit/theme-edit.type.d.mts +18 -0
  91. package/api/theme-edit/theme-edit.type.mjs +4 -0
  92. package/api/upgrade/upgrade.mjs +16 -1
  93. package/assets/codemods/integration-runner.mjs +1 -1
  94. package/assets/codemods/jscodeshift.d.ts +1 -1
  95. package/assets/codemods/run-codemod.mjs +71 -18
  96. package/assets/codemods/runner.mjs +1 -4
  97. package/assets/component-list.generated.json +1 -1
  98. package/assets/docs/theme.doc.dense.mjs +11 -1
  99. package/assets/docs/theme.doc.mjs +11 -1
  100. package/assets/docs/theme.doc.zh.mjs +11 -1
  101. package/assets/docs/tree/checks.doc.mjs +2 -2
  102. package/assets/docs/tree/install-once.doc.mjs +1 -1
  103. package/assets/docs-routes.generated.json +1 -1
  104. package/assets/docs.generated.json +2 -2
  105. package/assets/search-catalog.generated.json +2 -2
  106. package/assets/self-audit.generated.json +1 -1
  107. package/assets/templates/blocks/components/ChatComposerInput/useChatPasteAsTokenHookUsage.doc.mjs +14 -0
  108. package/assets/templates/blocks/components/ChatComposerInput/useChatPasteAsTokenHookUsage.tsx +32 -0
  109. package/assets/templates/components.generated.json +1 -1
  110. package/assets/templates/pages/ai-chat-landing/page.tsx +31 -4
  111. package/assets/templates/pages/documentation-technical/page.tsx +13 -13
  112. package/assets/templates/pages/editor/page.tsx +14 -2
  113. package/assets/templates/pages/file-explorer/page.tsx +9 -0
  114. package/assets/templates/pages/form-wizard-vertical/page.tsx +23 -3
  115. package/assets/templates/pages/kanban-board/page.tsx +11 -1
  116. package/assets/templates/pages/login-card/page.tsx +16 -0
  117. package/assets/templates/pages/login-split/page.tsx +19 -6
  118. package/assets/templates/pages/messaging-shell/template.doc.mjs +6 -0
  119. package/assets/templates/pages/payment-form/page.tsx +30 -4
  120. package/assets/templates/pages/product-detail/page.tsx +26 -2
  121. package/assets/templates/pages/settings-dialog/page.tsx +162 -12
  122. package/assets/templates/pages/shell-side-nav/page.tsx +11 -3
  123. package/assets/templates/pages/table-grouped/page.tsx +161 -133
  124. package/assets/templates/pages/work-item-detail/page.tsx +47 -7
  125. package/authoring/integration/integration.doc.mjs +4 -3
  126. package/authoring/integration/schema.d.mts +18 -4
  127. package/authoring/integration/schema.mjs +93 -15
  128. package/authoring/integration/type.ts +4 -0
  129. package/clients/cli/build-id.generated.json +1 -1
  130. package/clients/cli/commands/component.mjs +85 -38
  131. package/clients/cli/commands/doctor.mjs +42 -2
  132. package/clients/cli/commands/experimental/theme.mjs +228 -57
  133. package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +1 -1
  134. package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +1 -1
  135. package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +2 -2
  136. package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +1 -1
  137. package/clients/cli/commands/init.mjs +14 -6
  138. package/clients/cli/commands/template.doc.mjs +1 -1
  139. package/clients/cli/commands/theme-add.doc.mjs +1 -1
  140. package/clients/cli/commands/theme-build.doc.mjs +8 -0
  141. package/clients/cli/commands/theme-remove.doc.mjs +1 -1
  142. package/clients/cli/commands/theme.mjs +65 -7
  143. package/clients/cli/commands/upgrade.mjs +7 -3
  144. package/clients/cli/index.mjs +8 -18
  145. package/clients/cli/lib/cli-error.mjs +21 -0
  146. package/clients/cli/lib/json-shim.mjs +214 -31
  147. package/clients/cli/lib/stray-option.mjs +478 -0
  148. package/clients/cli/lib/unknown-command.mjs +353 -0
  149. package/clients/cli/manifest.generated.json +1 -1
  150. package/foundation/config/theme-build-header.d.mts +14 -0
  151. package/foundation/config/theme-build-header.mjs +14 -0
  152. package/foundation/config/theme-private-vars.d.mts +26 -2
  153. package/foundation/config/theme-private-vars.mjs +65 -5
  154. package/foundation/discovery/core-theme-facts.d.mts +70 -0
  155. package/foundation/discovery/core-theme-facts.mjs +384 -0
  156. package/foundation/discovery/hook-discovery.d.mts +10 -0
  157. package/foundation/discovery/hook-discovery.mjs +77 -40
  158. package/foundation/discovery/integration-component-views.d.mts +15 -0
  159. package/foundation/discovery/integration-component-views.mjs +91 -0
  160. package/foundation/discovery/next-routes.d.mts +48 -0
  161. package/foundation/discovery/next-routes.mjs +197 -0
  162. package/foundation/discovery/template-destination.d.mts +28 -0
  163. package/foundation/discovery/template-destination.mjs +106 -0
  164. package/foundation/discovery/theme-discovery.d.mts +3 -1
  165. package/foundation/discovery/theme-discovery.mjs +1 -1
  166. package/foundation/discovery/theming-targets.d.mts +7 -0
  167. package/foundation/discovery/theming-targets.mjs +11 -1
  168. package/foundation/fonts/font-stylesheet.d.mts +15 -0
  169. package/foundation/fonts/font-stylesheet.mjs +41 -7
  170. package/foundation/fs/gather-cache.d.mts +10 -6
  171. package/foundation/fs/gather-cache.mjs +50 -15
  172. package/foundation/fs/kept-tree.d.mts +8 -4
  173. package/foundation/fs/kept-tree.mjs +46 -21
  174. package/foundation/fs/module-loader.d.mts +10 -1
  175. package/foundation/fs/module-loader.mjs +138 -8
  176. package/foundation/fs/path-safety.d.mts +23 -0
  177. package/foundation/fs/path-safety.mjs +62 -0
  178. package/foundation/fs/read-record.d.mts +30 -1
  179. package/foundation/fs/read-record.mjs +72 -2
  180. package/foundation/integrations/integrations.d.mts +17 -3
  181. package/foundation/integrations/integrations.mjs +16 -3
  182. package/foundation/integrations/pack-state.d.mts +10 -0
  183. package/foundation/integrations/pack-state.mjs +200 -5
  184. package/foundation/integrations/shipped-imports.d.mts +9 -6
  185. package/foundation/integrations/shipped-imports.mjs +38 -5
  186. package/foundation/integrations/validate-contributions.mjs +75 -30
  187. package/foundation/render/embedded-imports.mjs +102 -26
  188. package/foundation/render/layers.d.mts +6 -0
  189. package/foundation/render/layers.mjs +107 -10
  190. package/foundation/render/page-worker.mjs +38 -1
  191. package/foundation/render/picture-chrome.mjs +12 -0
  192. package/foundation/render/picture-playwright.mjs +4 -1
  193. package/foundation/response/response-types.doc.mjs +3 -3
  194. package/foundation/runtime/css-tree.d.mts +11 -0
  195. package/foundation/runtime/css-tree.mjs +49 -0
  196. package/foundation/runtime/lazy-dependencies.d.mts +1 -0
  197. package/foundation/runtime/lazy-dependencies.mjs +17 -4
  198. package/foundation/suggest/other-command.d.mts +45 -11
  199. package/foundation/suggest/other-command.mjs +125 -25
  200. package/foundation/text/string-utils.d.mts +43 -4
  201. package/foundation/text/string-utils.mjs +100 -16
  202. package/foundation/text/suggest-order.d.mts +19 -4
  203. package/foundation/text/suggest-order.mjs +98 -4
  204. package/package.json +7 -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, 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. |
510
+ | `template.copy` | A scaffold receipt: template id, output directory (relative to the project; absolute for a scratch copy in the system temp folder), 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. |
@@ -117,6 +117,17 @@ export function isWeightsFile(file: any): file is import("./kit/weights.mjs").We
117
117
  * @returns {string[]} Setup notes (empty when the template needs nothing).
118
118
  */
119
119
  export function templateSetupNotes(template: PageTemplate, cwd: string): string[];
120
+ /**
121
+ * Where a page template goes in the project where build ran, quoted for a
122
+ * printed command: the path `astryx template` names for it from the
123
+ * project's layout (in a Next app, the App Router folder). Null when that
124
+ * folder has no package.json, so no project layout is known.
125
+ *
126
+ * @param {string} id the template's own id
127
+ * @param {string} cwd the folder build ran in
128
+ * @returns {string | null}
129
+ */
130
+ export function pageDestination(id: string, cwd: string): string | null;
120
131
  /**
121
132
  * The Core a build answers from: the project's, else the release's own,
122
133
  * installed into the per-user cache first when needed (a network install
@@ -21,6 +21,7 @@
21
21
  */
22
22
 
23
23
  import fs from 'node:fs';
24
+ import path from 'node:path';
24
25
  import {fileURLToPath} from 'node:url';
25
26
 
26
27
  import {discoverTemplates} from '../template/template.mjs';
@@ -29,6 +30,8 @@ import {findCoreDir, requireCoreDir} from '../../foundation/fs/paths.mjs';
29
30
  import {persistedDerived} from '../../foundation/fs/gather-cache.mjs';
30
31
  import {analyzeTemplateNeeds} from '../../foundation/discovery/template-needs.mjs';
31
32
  import {extractComponents} from '../../foundation/discovery/template-adapter.mjs';
33
+ import {templateDestination} from '../../foundation/discovery/template-destination.mjs';
34
+ import {quoteCommandArgument} from '../../foundation/env/package-manager.mjs';
32
35
  import {isWordModel} from './kit/word-model.mjs';
33
36
 
34
37
  /**
@@ -343,6 +346,21 @@ export function templateSetupNotes(template, cwd) {
343
346
  }
344
347
  }
345
348
 
349
+ /**
350
+ * Where a page template goes in the project where build ran, quoted for a
351
+ * printed command: the path `astryx template` names for it from the
352
+ * project's layout (in a Next app, the App Router folder). Null when that
353
+ * folder has no package.json, so no project layout is known.
354
+ *
355
+ * @param {string} id the template's own id
356
+ * @param {string} cwd the folder build ran in
357
+ * @returns {string | null}
358
+ */
359
+ export function pageDestination(id, cwd) {
360
+ if (!fs.existsSync(path.join(cwd, 'package.json'))) return null;
361
+ return quoteCommandArgument(templateDestination(cwd, 'page', id));
362
+ }
363
+
346
364
  /**
347
365
  * The Core a build answers from: the project's, else the release's own,
348
366
  * installed into the per-user cache first when needed (a network install
@@ -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 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".',
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 and names where it goes in the project (`<path>` stays a placeholder outside a project), 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: [
@@ -86,7 +86,7 @@ export const doc = {
86
86
  {label: 'Get the playbook', code: 'const r = await build();'},
87
87
  {
88
88
  label: 'Find the template to start from',
89
- code: "const {data} = await build('analytics dashboard');\n// data.start.command: 'astryx template dashboard --type page <path>'",
89
+ code: "const {data} = await build('analytics dashboard');\n// in a Next app: data.start.command: 'astryx template dashboard --type page app/dashboard'",
90
90
  },
91
91
  {
92
92
  label: 'Restrict + limit',
@@ -65,7 +65,7 @@ export type BuildStart = {
65
65
  */
66
66
  package: string;
67
67
  /**
68
- * 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.
68
+ * 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 the path `astryx template` names for the template in the project where build ran, from the project's layout and the template's own id (not the Core id a replacement stands in for): in a Next app, `<id>` in its App Router folder (`app/<id>` or `src/app/<id>`, in the route group with the root layout when that folder has none), or the page file `pages/<id>.tsx` or `src/pages/<id>.tsx` with only the Pages Router; else `src/pages/<id>`; `<id>-2` and on when that path is taken; quoted for a shell. It is the placeholder `<path>` when that folder has no package.json (`architecture:cli-surface` INV38), and the `astryx` prefix is for the caller to replace with its own invocation.
69
69
  */
70
70
  command: string;
71
71
  /**
@@ -43,7 +43,7 @@
43
43
  * @property {string} displayName Human-facing template name.
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
- * @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.
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 the path `astryx template` names for the template in the project where build ran, from the project's layout and the template's own id (not the Core id a replacement stands in for): in a Next app, `<id>` in its App Router folder (`app/<id>` or `src/app/<id>`, in the route group with the root layout when that folder has none), or the page file `pages/<id>.tsx` or `src/pages/<id>.tsx` with only the Pages Router; else `src/pages/<id>`; `<id>-2` and on when that path is taken; quoted for a shell. It is the placeholder `<path>` when that folder has no package.json (`architecture:cli-surface` INV38), and the `astryx` prefix is for the caller to replace with its own invocation.
47
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
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.
@@ -26,7 +26,7 @@
26
26
  * JSON shape stays package-manager-agnostic and stable across environments.
27
27
  *
28
28
  * Two commands are the kit's own: `start.command`, the scaffold (`astryx
29
- * template <id> --type page <path>`, with `<path>` a placeholder), and the `--skeleton`
29
+ * template <id> --type page <path>`, with `<path>` where it goes in the project), and the `--skeleton`
30
30
  * a page entry carries when it is not a direct match, so a loose page reads
31
31
  * as a layout preview rather than the thing to build. Neither is prefixing —
32
32
  * the invocation stays the renderer's job.
@@ -23,6 +23,7 @@ import {CORE_PROVIDER_ID} from '../../../foundation/identity/providers.mjs';
23
23
  import {
24
24
  loadComponents,
25
25
  loadTemplates,
26
+ pageDestination,
26
27
  requireBuildCoreDir,
27
28
  templateSetupNotes,
28
29
  } from '../_adapter.mjs';
@@ -246,8 +247,18 @@ export async function kitSignals(query, options = {}) {
246
247
  ? (searchedComponents(result) ?? (await loadComponents(cwd)))
247
248
  : [];
248
249
  const kind = wantsPages ? ideaKind(query, catalog, components) : 'page';
250
+ /** @param {import('../_adapter.mjs').PageTemplate} t */
251
+ const placeOf = t => pageDestination(t.name, cwd);
249
252
  const chosen = wantsPages
250
- ? chooseStart(ranked, kind, matchedPages, directMatch, catalog, query)
253
+ ? chooseStart(
254
+ ranked,
255
+ kind,
256
+ matchedPages,
257
+ directMatch,
258
+ catalog,
259
+ query,
260
+ placeOf,
261
+ )
251
262
  : null;
252
263
  // Name the ranker's next two templates beside the start: the reader judges
253
264
  // meaning better than keywords do, and an acceptable template is in these
@@ -263,7 +274,7 @@ export async function kitSignals(query, options = {}) {
263
274
  query,
264
275
  ).flatMap(r => {
265
276
  const t = catalog.find(c => c.name === r.name);
266
- return t ? [asTemplate(t)] : [];
277
+ return t ? [asTemplate(t, placeOf(t))] : [];
267
278
  }),
268
279
  };
269
280
 
@@ -18,9 +18,11 @@
18
18
  * @param {boolean} directMatch
19
19
  * @param {PageTemplate[]} catalog
20
20
  * @param {string} idea
21
+ * @param {(t: PageTemplate) => string | null} [placeOf] the path a template
22
+ * is scaffolded to, quoted for a shell; null when none is known
21
23
  * @returns {Omit<BuildStart, 'alternatives'> | null}
22
24
  */
23
- export function chooseStart(ranked: import("./rank.mjs").RankedPage[], kind: import("./rank.mjs").IdeaKind, pages: SearchResultEntry[], directMatch: boolean, catalog: PageTemplate[], idea: string): Omit<BuildStart, "alternatives"> | null;
25
+ export function chooseStart(ranked: import("./rank.mjs").RankedPage[], kind: import("./rank.mjs").IdeaKind, pages: SearchResultEntry[], directMatch: boolean, catalog: PageTemplate[], idea: string, placeOf?: (t: PageTemplate) => string | null): Omit<BuildStart, "alternatives"> | null;
24
26
  /**
25
27
  * The next best page templates beside the start (spec:AST-048/FR7), in the
26
28
  * order the start itself is chosen from. The candidates are the ranker's (a
@@ -40,7 +42,7 @@ export function chooseStart(ranked: import("./rank.mjs").RankedPage[], kind: imp
40
42
  * @returns {import('./rank.mjs').RankedPage[]}
41
43
  */
42
44
  export function pickStartAlternatives(ranked: import("./rank.mjs").RankedPage[], kind: import("./rank.mjs").IdeaKind, startName: string, catalog: PageTemplate[], idea: string): import("./rank.mjs").RankedPage[];
43
- export function asTemplate(t: PageTemplate): {
45
+ export function asTemplate(t: PageTemplate, to?: string | null): {
44
46
  name: string;
45
47
  package: string;
46
48
  displayName: string;
@@ -11,8 +11,13 @@ 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';
15
- import {blendOrder, blendSummary, weighStart} from './weights.mjs';
14
+ import {isAppShell, readNames} from './words.mjs';
15
+ import {
16
+ blendOrder,
17
+ blendSummary,
18
+ sharesOwnWord,
19
+ weighStart,
20
+ } from './weights.mjs';
16
21
 
17
22
  /**
18
23
  * @typedef {import('../../search/search.type.mjs').SearchResultEntry} SearchResultEntry
@@ -31,16 +36,17 @@ const FALLBACK_STARTS = ['shell-top-nav', 'blank'];
31
36
 
32
37
  /**
33
38
  * A page template as the kit names it: the command that selects exactly that
34
- * template, scaffolding into `<path>`, a placeholder for the file or folder to
35
- * write it to.
39
+ * template and scaffolds it to `to`, or to the `<path>` placeholder when no
40
+ * path is known.
36
41
  * @param {PageTemplate} t
42
+ * @param {string | null} [to] the path, quoted for a shell
37
43
  */
38
- export const asTemplate = t => ({
44
+ export const asTemplate = (t, to = null) => ({
39
45
  name: t.name,
40
46
  package: t.package,
41
47
  displayName: t.displayName,
42
48
  description: t.description,
43
- command: `${t.command} <path>`,
49
+ command: `${t.command} ${to ?? '<path>'}`,
44
50
  });
45
51
 
46
52
  /**
@@ -85,9 +91,11 @@ const LIFT_AT = 0.3;
85
91
  * @param {import('./rank.mjs').IdeaKind} kind
86
92
  * @param {PageTemplate[]} catalog
87
93
  * @param {string} idea
94
+ * @param {string | null} [unsupported] a page the weights chose that shares no
95
+ * word with the idea; the lift may not bring it back
88
96
  * @returns {PageTemplate | null}
89
97
  */
90
- function liftFromShell(ranked, kind, catalog, idea) {
98
+ function liftFromShell(ranked, kind, catalog, idea, unsupported = null) {
91
99
  const b = blendSummary(
92
100
  idea,
93
101
  ranked,
@@ -112,6 +120,7 @@ function liftFromShell(ranked, kind, catalog, idea) {
112
120
  ];
113
121
  const logit = x.reduce((s, v, i) => s + v * LIFT[i], 0);
114
122
  if (1 / (1 + Math.exp(-logit)) < LIFT_AT) return null;
123
+ if (b.best === unsupported) return null;
115
124
  return catalog.find(t => t.name === b.best) ?? null;
116
125
  }
117
126
 
@@ -132,9 +141,19 @@ function liftFromShell(ranked, kind, catalog, idea) {
132
141
  * @param {boolean} directMatch
133
142
  * @param {PageTemplate[]} catalog
134
143
  * @param {string} idea
144
+ * @param {(t: PageTemplate) => string | null} [placeOf] the path a template
145
+ * is scaffolded to, quoted for a shell; null when none is known
135
146
  * @returns {Omit<BuildStart, 'alternatives'> | null}
136
147
  */
137
- export function chooseStart(ranked, kind, pages, directMatch, catalog, idea) {
148
+ export function chooseStart(
149
+ ranked,
150
+ kind,
151
+ pages,
152
+ directMatch,
153
+ catalog,
154
+ idea,
155
+ placeOf = () => null,
156
+ ) {
138
157
  const direct = directMatch ? pages[0].name : null;
139
158
  const unready =
140
159
  direct && !catalog.some(t => t.name === direct) ? direct : null;
@@ -156,13 +175,24 @@ export function chooseStart(ranked, kind, pages, directMatch, catalog, idea) {
156
175
  // scores, decide the start of a whole page, so it can differ from the
157
176
  // ranker's own pick, its head-noun family included. A part or an edit starts
158
177
  // where the ranker's placement rules put it (spec:AST-048/FR3).
159
- const weighed =
178
+ const weighedPage =
160
179
  kind === 'page'
161
180
  ? weighStart(idea, ranked, proposed, catalog, {
162
181
  weights: loadWeights(),
163
182
  newPage: asksForNewPage(idea, catalog),
164
183
  })
165
184
  : undefined;
185
+ // When the ranker proposes no page, a page the word weights lean to but
186
+ // whose own docs share no word with the idea is no start; the shell lift
187
+ // may not bring that same page back.
188
+ const unsupported =
189
+ weighedPage &&
190
+ !directMatch &&
191
+ !proposed &&
192
+ !sharesOwnWord(weighedPage, readNames(idea, catalog), catalog)
193
+ ? weighedPage
194
+ : null;
195
+ const weighed = unsupported ? null : weighedPage;
166
196
  // A shell start keeps the shell the ranker named, if any, and never replaces
167
197
  // the template the ranker chose for a page search matched directly.
168
198
  const pick =
@@ -178,7 +208,7 @@ export function chooseStart(ranked, kind, pages, directMatch, catalog, idea) {
178
208
  // ready or not, keeps the start and reason it already has.
179
209
  const lifted =
180
210
  !direct && (!pick || pick.family === 'Shell')
181
- ? liftFromShell(ranked, kind, catalog, idea)
211
+ ? liftFromShell(ranked, kind, catalog, idea, unsupported)
182
212
  : null;
183
213
  const closest = lifted ?? (pick && catalog.find(t => t.name === pick.name));
184
214
  if (closest) {
@@ -186,7 +216,7 @@ export function chooseStart(ranked, kind, pages, directMatch, catalog, idea) {
186
216
  const place =
187
217
  lifted || !pick ? null : placement(kind, pick.base && pick.familyNamed);
188
218
  return {
189
- ...asTemplate(closest),
219
+ ...asTemplate(closest, placeOf(closest)),
190
220
  basis: agrees ? 'direct' : 'closest',
191
221
  reason: unready
192
222
  ? `\`${unready}\` matches but is not ready yet; this is the closest ready template.`
@@ -209,7 +239,7 @@ export function chooseStart(ranked, kind, pages, directMatch, catalog, idea) {
209
239
  (weighed === null && !!proposed && proposed.family !== 'Shell');
210
240
  const place = placement(kind, false);
211
241
  return {
212
- ...asTemplate(shell),
242
+ ...asTemplate(shell, placeOf(shell)),
213
243
  basis: 'fallback',
214
244
  reason: unready
215
245
  ? `\`${unready}\` matches but is not ready yet, so start from the app shell.`
@@ -79,6 +79,15 @@ export function blendSummary(idea: string, ranked: import("./rank.mjs").RankedPa
79
79
  bestScore: number;
80
80
  secondScore: number;
81
81
  } | null;
82
+ /**
83
+ * Whether the idea names at least one content word of a template's own
84
+ * descriptor (display name, category, keywords, description, components).
85
+ * @param {string} name
86
+ * @param {string} idea
87
+ * @param {DescribedTemplate[]} catalog
88
+ * @returns {boolean}
89
+ */
90
+ export function sharesOwnWord(name: string, idea: string, catalog: DescribedTemplate[]): boolean;
82
91
  /** The app shell, as one candidate. */
83
92
  export const SHELL: "SHELL";
84
93
  export type WeightTable = {
@@ -112,12 +121,13 @@ export type WeightsFile = {
112
121
  blend: number[];
113
122
  /**
114
123
  * the pick
115
- * model: its own tables and blend numbers, used only to choose which page
116
- * starts once the call model (the top-level tables and blend) has called a
117
- * page. Without it, one model does both.
124
+ * model: its own blend numbers, used only to choose which page starts once
125
+ * the call model (the top-level tables and blend) has called a page. It
126
+ * reads the top-level tables unless it carries its own. Without it, one
127
+ * model does both.
118
128
  */
119
129
  pick?: {
120
- tables: WeightTable[];
130
+ tables?: WeightTable[];
121
131
  blend: number[];
122
132
  } | undefined;
123
133
  };