@astryxdesign/cli 0.7.3-canary.f94e962 → 0.7.3

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 (205) hide show
  1. package/CHANGELOG.md +115 -0
  2. package/README.md +68 -68
  3. package/api/build/_adapter.mjs +37 -25
  4. package/api/build/blocks/blocks.d.mts +68 -18
  5. package/api/build/blocks/blocks.mjs +475 -116
  6. package/api/build/blocks/blocks.test.mjs +191 -61
  7. package/api/build/blocks/blocks.weights.json +1 -1
  8. package/api/build/build.type.mjs +1 -1
  9. package/api/build/kit/answer.d.mts +9 -5
  10. package/api/build/kit/answer.mjs +123 -13
  11. package/api/build/kit/answer.test.mjs +73 -3
  12. package/api/build/kit/signals.d.mts +19 -0
  13. package/api/build/kit/signals.mjs +18 -7
  14. package/api/build/kit/weights.d.mts +8 -22
  15. package/api/build/kit/weights.mjs +87 -8
  16. package/api/build/kit/weights.test.mjs +96 -0
  17. package/api/build/tree.mjs +2 -1
  18. package/api/build/tree.test.mjs +37 -29
  19. package/api/component/_adapter.mjs +39 -5
  20. package/api/component/component-replacement.test.mjs +1 -0
  21. package/api/component/component.mjs +1 -1
  22. package/api/component/doc-links.test.mjs +2 -2
  23. package/api/discover/_adapter.d.mts +1 -2
  24. package/api/discover/_adapter.mjs +6 -8
  25. package/api/discover/discover.mjs +0 -1
  26. package/api/docs/_adapter.d.mts +2 -2
  27. package/api/docs/_adapter.mjs +65 -18
  28. package/api/docs/docs-homes.test.mjs +127 -0
  29. package/api/docs/docs.doc.mjs +3 -3
  30. package/api/docs/docs.test.mjs +28 -18
  31. package/api/docs/integration-tree.test.mjs +20 -20
  32. package/api/docs/integrationDocs.test.mjs +1 -1
  33. package/api/docs/namespace-section.test.mjs +6 -6
  34. package/api/docs/reference-blocks.test.mjs +2 -2
  35. package/api/doctor/_adapter.d.mts +33 -13
  36. package/api/doctor/_adapter.mjs +55 -25
  37. package/api/doctor/doctor.d.mts +23 -5
  38. package/api/doctor/doctor.mjs +97 -28
  39. package/api/doctor/doctor.test.mjs +67 -9
  40. package/api/hook/hook.mjs +1 -1
  41. package/api/integration/validate-integration-fixes.test.mjs +6 -5
  42. package/api/integration/validate-integration-gaps.test.mjs +12 -1
  43. package/api/integration/validate-integration.d.mts +4 -0
  44. package/api/integration/validate-integration.mjs +48 -7
  45. package/api/integration/validate-integration.type.d.mts +36 -5
  46. package/api/integration/validate-integration.type.mjs +27 -6
  47. package/api/integration/validateIntegration.doc.mjs +1 -1
  48. package/api/search/_adapter.d.mts +16 -0
  49. package/api/search/_adapter.mjs +39 -0
  50. package/api/search/_adapter.test.mjs +173 -0
  51. package/api/search/_candidate-score.mjs +1 -1
  52. package/api/search/_entries.d.mts +11 -0
  53. package/api/search/_entries.mjs +35 -17
  54. package/api/search/_entries.test.mjs +48 -0
  55. package/api/search/_gather-docs.mjs +3 -3
  56. package/api/search/_gather-templates.d.mts +0 -1
  57. package/api/search/_gather-templates.mjs +25 -0
  58. package/api/search/search.doc.mjs +1 -1
  59. package/api/search/search.integration-block.test.mjs +100 -0
  60. package/api/search/search.mjs +6 -2
  61. package/api/search/search.test.mjs +14 -14
  62. package/api/template/template.mjs +5 -1
  63. package/assets/docs/author-a-theme.doc.mjs +2 -2
  64. package/assets/docs/tree/add-a-component.doc.mjs +1 -1
  65. package/assets/docs/tree/add-a-theme.doc.mjs +1 -1
  66. package/assets/docs/tree/add-a-topic.doc.mjs +1 -1
  67. package/assets/docs/tree/agent-guidance.doc.mjs +1 -1
  68. package/assets/docs/tree/{integrations.doc.mjs → authoring.doc.mjs} +15 -6
  69. package/assets/docs/tree/block-template.doc.mjs +1 -1
  70. package/assets/docs/tree/build-the-template.doc.mjs +1 -1
  71. package/assets/docs/tree/building-blocks.doc.mjs +2 -2
  72. package/assets/docs/tree/check-the-props.doc.mjs +1 -1
  73. package/assets/docs/tree/check-your-docs.doc.mjs +2 -2
  74. package/assets/docs/tree/checks.doc.mjs +2 -2
  75. package/assets/docs/tree/ci-and-containers.doc.mjs +13 -0
  76. package/assets/docs/tree/cli-command.doc.mjs +1 -1
  77. package/assets/docs/tree/cli.doc.mjs +1 -1
  78. package/assets/docs/tree/codemods.doc.mjs +1 -1
  79. package/assets/docs/tree/component-family.doc.mjs +1 -1
  80. package/assets/docs/tree/component-imports.doc.mjs +1 -1
  81. package/assets/docs/tree/components.doc.mjs +1 -1
  82. package/assets/docs/tree/configuration.doc.mjs +1 -1
  83. package/assets/docs/tree/debug-and-gap-reports.doc.mjs +1 -1
  84. package/assets/docs/tree/define-the-theme.doc.mjs +1 -1
  85. package/assets/docs/tree/describe-the-component.doc.mjs +1 -1
  86. package/assets/docs/tree/docs.doc.mjs +1 -1
  87. package/assets/docs/tree/document-the-template.doc.mjs +1 -1
  88. package/assets/docs/tree/document-the-theme.doc.mjs +1 -1
  89. package/assets/docs/tree/export-template-assets.doc.mjs +1 -1
  90. package/assets/docs/tree/extend-or-replace.doc.mjs +1 -1
  91. package/assets/docs/{authoring.doc.mjs → tree/field-reference.doc.mjs} +4 -3
  92. package/assets/docs/tree/fonts-and-assets.doc.mjs +1 -1
  93. package/assets/docs/tree/generate-a-palette.doc.mjs +1 -1
  94. package/assets/docs/tree/global-integrations.doc.mjs +2 -2
  95. package/assets/docs/tree/grade-template-with-agent.doc.mjs +4 -4
  96. package/assets/docs/tree/help.doc.mjs +2 -2
  97. package/assets/docs/tree/links.doc.mjs +1 -1
  98. package/assets/docs/tree/package-and-test.doc.mjs +1 -1
  99. package/assets/docs/tree/page-template.doc.mjs +1 -1
  100. package/assets/docs/tree/publishing.doc.mjs +1 -1
  101. package/assets/docs/tree/quick-start.doc.mjs +1 -1
  102. package/assets/docs/tree/replace-a-core-component.doc.mjs +1 -1
  103. package/assets/docs/tree/replace-a-core-template.doc.mjs +1 -1
  104. package/assets/docs/tree/sections-and-placement.doc.mjs +1 -1
  105. package/assets/docs/tree/see-it-in-an-app.doc.mjs +1 -1
  106. package/assets/docs/tree/ship.doc.mjs +2 -2
  107. package/assets/docs/tree/short-and-findable.doc.mjs +1 -1
  108. package/assets/docs/tree/single-component.doc.mjs +1 -1
  109. package/assets/docs/tree/start-a-template.doc.mjs +1 -1
  110. package/assets/docs/tree/subcomponent.doc.mjs +1 -1
  111. package/assets/docs/tree/template-assets.doc.mjs +1 -1
  112. package/assets/docs/tree/template-doc-overview.doc.mjs +2 -2
  113. package/assets/docs/tree/template-fonts.doc.mjs +1 -1
  114. package/assets/docs/tree/template-grading-rubric.doc.mjs +1 -1
  115. package/assets/docs/tree/template-icons.doc.mjs +1 -1
  116. package/assets/docs/tree/template-images-media.doc.mjs +1 -1
  117. package/assets/docs/tree/template-styles.doc.mjs +1 -1
  118. package/assets/docs/tree/templates.doc.mjs +1 -1
  119. package/assets/docs/tree/test-in-an-app.doc.mjs +1 -1
  120. package/assets/docs/tree/test-template-in-app.doc.mjs +1 -1
  121. package/assets/docs/tree/themes.doc.mjs +1 -1
  122. package/assets/docs/tree/troubleshooting.doc.mjs +1 -1
  123. package/assets/docs/tree/upgrading.doc.mjs +1 -1
  124. package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +1 -1
  125. package/assets/docs/tree/verify-packed-template.doc.mjs +1 -1
  126. package/assets/docs/tree/versioning.doc.mjs +5 -1
  127. package/assets/docs/tree/write-good-templates.doc.mjs +1 -1
  128. package/assets/docs/tree/write-the-template-file.doc.mjs +1 -1
  129. package/assets/docs/use-integrations.doc.mjs +120 -0
  130. package/authoring/doctypes/schema/schema.doc.mjs +1 -1
  131. package/authoring/integration/integration.doc.mjs +1 -1
  132. package/authoring/integration/type.ts +1 -1
  133. package/clients/cli/command-result-coverage.test.mjs +6 -5
  134. package/clients/cli/commands/build-theme.color-scheme.test.mjs +1 -1
  135. package/clients/cli/commands/{component/index.mjs → component.mjs} +37 -37
  136. package/clients/cli/commands/component.test.mjs +6 -6
  137. package/clients/cli/commands/docs.doc.mjs +2 -2
  138. package/clients/cli/commands/docs.mjs +1 -1
  139. package/clients/cli/commands/docs.test.mjs +14 -14
  140. package/clients/cli/commands/doctor-integration.test.mjs +49 -1
  141. package/clients/cli/commands/doctor.doc.mjs +1 -1
  142. package/clients/cli/commands/doctor.mjs +10 -0
  143. package/clients/cli/commands/{hook/index.mjs → hook.mjs} +22 -22
  144. package/clients/cli/commands/import-hint-correctness.test.mjs +1 -1
  145. package/clients/cli/commands/integration.doc.mjs +1 -1
  146. package/clients/cli/commands/manifest.doc.mjs +1 -1
  147. package/clients/cli/commands/manifest.mjs +67 -0
  148. package/clients/cli/commands/outside-project.test.mjs +99 -0
  149. package/clients/cli/commands/postinstall.doc.mjs +23 -0
  150. package/clients/cli/commands/postinstall.mjs +31 -0
  151. package/clients/cli/commands/setup-nudge.test.mjs +17 -0
  152. package/clients/cli/commands/{build-theme.mjs → theme.mjs} +1 -1
  153. package/clients/cli/index.mjs +35 -93
  154. package/clients/cli/lib/component-format.mjs +1 -1
  155. package/clients/cli/lib/define-command.mjs +12 -7
  156. package/clients/cli/lib/exit-codes.test.mjs +5 -0
  157. package/clients/cli/lib/manifest.test.mjs +12 -0
  158. package/clients/cli/lib/welcome-box.mjs +50 -0
  159. package/foundation/agent-docs/agent-doc-state.d.mts +12 -0
  160. package/foundation/agent-docs/agent-doc-state.mjs +24 -2
  161. package/foundation/agent-docs/agent-docs.mjs +7 -6
  162. package/foundation/agent-docs/agent-docs.test.mjs +5 -4
  163. package/foundation/agent-docs/computer-agent-text.d.mts +39 -2
  164. package/foundation/agent-docs/computer-agent-text.mjs +135 -8
  165. package/foundation/agent-docs/computer-agent-text.test.mjs +99 -2
  166. package/foundation/discovery/authoring-self-docs.d.mts +7 -0
  167. package/foundation/discovery/authoring-self-docs.mjs +16 -4
  168. package/foundation/discovery/authoring-self-docs.test.mjs +15 -3
  169. package/foundation/discovery/authoring-surface.d.mts +1 -1
  170. package/foundation/discovery/authoring-surface.mjs +2 -2
  171. package/foundation/discovery/authoring-surface.test.mjs +1 -1
  172. package/foundation/discovery/cli-self-docs.d.mts +2 -1
  173. package/foundation/discovery/cli-self-docs.mjs +4 -3
  174. package/foundation/discovery/cli-self-docs.test.mjs +2 -2
  175. package/foundation/discovery/runner-commands.mjs +1 -0
  176. package/foundation/discovery/stray-pointers.test.mjs +1 -1
  177. package/foundation/doc-compiler/doc-loads.test.mjs +21 -9
  178. package/foundation/doc-compiler/split-topic-keywords.test.mjs +3 -2
  179. package/foundation/doc-compiler/tree.d.mts +32 -6
  180. package/foundation/doc-compiler/tree.mjs +77 -43
  181. package/foundation/doc-compiler/tree.test.mjs +7 -7
  182. package/foundation/fs/read-record.d.mts +18 -0
  183. package/foundation/fs/read-record.mjs +131 -0
  184. package/foundation/fs/read-record.test.mjs +77 -0
  185. package/foundation/integrations/cli-peer-version.d.mts +36 -0
  186. package/foundation/integrations/cli-peer-version.mjs +132 -0
  187. package/foundation/integrations/cli-peer-version.test.mjs +354 -0
  188. package/foundation/integrations/exports-subpaths.d.mts +57 -0
  189. package/foundation/integrations/exports-subpaths.mjs +113 -0
  190. package/foundation/integrations/public-imports.d.mts +118 -0
  191. package/foundation/integrations/public-imports.mjs +1769 -0
  192. package/foundation/integrations/public-imports.test.mjs +1793 -0
  193. package/foundation/release/cache.test.mjs +24 -21
  194. package/foundation/release/global-state.d.mts +8 -4
  195. package/foundation/release/global-state.mjs +4 -2
  196. package/foundation/release/notices.d.mts +62 -8
  197. package/foundation/release/notices.mjs +136 -25
  198. package/foundation/release/notices.test.mjs +21 -0
  199. package/foundation/response/response-types.doc.mjs +1 -1
  200. package/foundation/text/string-utils.d.mts +2 -1
  201. package/foundation/text/string-utils.mjs +16 -5
  202. package/foundation/text/suggest-order.d.mts +72 -0
  203. package/foundation/text/suggest-order.mjs +363 -0
  204. package/foundation/text/suggest-order.test.mjs +259 -0
  205. package/package.json +9 -9
@@ -802,8 +802,28 @@ describe('stopped and damaged installs heal', () => {
802
802
  });
803
803
  });
804
804
 
805
+ /** @param {number} pid */
806
+ const alive = pid => {
807
+ try {
808
+ process.kill(pid, 0);
809
+ return true;
810
+ } catch {
811
+ return false;
812
+ }
813
+ };
814
+
815
+ /** @param {() => boolean} done @param {number} ms */
816
+ const waitFor = async (done, ms) => {
817
+ const end = Date.now() + ms;
818
+ while (Date.now() < end) {
819
+ if (done()) return true;
820
+ await new Promise(r => setTimeout(r, 100));
821
+ }
822
+ return done();
823
+ };
824
+
805
825
  describe('runNpm time limit', () => {
806
- it('ends a package manager that ignores SIGTERM, leaving no process behind', () => {
826
+ it('ends a package manager that ignores SIGTERM, leaving no process behind', async () => {
807
827
  const marker = tempDir('npm-pid');
808
828
  const pidFile = path.join(marker, 'pid');
809
829
  const result = runNpm([], {
@@ -819,30 +839,13 @@ describe('runNpm time limit', () => {
819
839
  });
820
840
  expect(/** @type {any} */ (result.error)?.code).toBe('ETIMEDOUT');
821
841
  const pid = Number(fs.readFileSync(pidFile, 'utf-8'));
822
- expect(() => process.kill(pid, 0)).toThrow();
842
+ // The guard sends SIGKILL and exits at once; the killed process can still
843
+ // exist for a moment (the signal in flight, or awaiting reaping).
844
+ expect(await waitFor(() => !alive(pid), 5_000)).toBe(true);
823
845
  });
824
846
  });
825
847
 
826
848
  describe('no install outlives its run', () => {
827
- /** @param {number} pid */
828
- const alive = pid => {
829
- try {
830
- process.kill(pid, 0);
831
- return true;
832
- } catch {
833
- return false;
834
- }
835
- };
836
- /** @param {() => boolean} done @param {number} ms */
837
- const waitFor = async (done, ms) => {
838
- const end = Date.now() + ms;
839
- while (Date.now() < end) {
840
- if (done()) return true;
841
- await new Promise(r => setTimeout(r, 100));
842
- }
843
- return done();
844
- };
845
-
846
849
  it('ends npm when the run that started it is killed outright, and removes its process-id record', async () => {
847
850
  const dir = tempDir('orphan');
848
851
  const pidFile = path.join(dir, 'npm-pid');
@@ -20,9 +20,11 @@
20
20
  */
21
21
  /**
22
22
  * Why an update notice did not print: `already-shown` (it printed within the
23
- * day) or `no-newer` (nothing newer is known). Recorded only while the run
23
+ * day), `no-newer` (nothing newer is known), or `no-project` (the folder
24
+ * installs Core but belongs to no Astryx project, so no install command
25
+ * fits). Recorded only while the run
24
26
  * holds the state file's lock.
25
- * @typedef {{reason: 'already-shown' | 'no-newer', at: number}} NoticeSkip
27
+ * @typedef {{reason: 'already-shown' | 'no-newer' | 'no-project', at: number}} NoticeSkip
26
28
  */
27
29
  /**
28
30
  * The state file.
@@ -242,11 +244,13 @@ export type GlobalState = {
242
244
  };
243
245
  /**
244
246
  * Why an update notice did not print: `already-shown` (it printed within the
245
- * day) or `no-newer` (nothing newer is known). Recorded only while the run
247
+ * day), `no-newer` (nothing newer is known), or `no-project` (the folder
248
+ * installs Core but belongs to no Astryx project, so no install command
249
+ * fits). Recorded only while the run
246
250
  * holds the state file's lock.
247
251
  */
248
252
  export type NoticeSkip = {
249
- reason: "already-shown" | "no-newer";
253
+ reason: "already-shown" | "no-newer" | "no-project";
250
254
  at: number;
251
255
  };
252
256
  /**
@@ -68,9 +68,11 @@ export const CHECK_INTERVAL_MS = 24 * 60 * 60_000;
68
68
 
69
69
  /**
70
70
  * Why an update notice did not print: `already-shown` (it printed within the
71
- * day) or `no-newer` (nothing newer is known). Recorded only while the run
71
+ * day), `no-newer` (nothing newer is known), or `no-project` (the folder
72
+ * installs Core but belongs to no Astryx project, so no install command
73
+ * fits). Recorded only while the run
72
74
  * holds the state file's lock.
73
- * @typedef {{reason: 'already-shown' | 'no-newer', at: number}} NoticeSkip
75
+ * @typedef {{reason: 'already-shown' | 'no-newer' | 'no-project', at: number}} NoticeSkip
74
76
  */
75
77
 
76
78
  /**
@@ -91,24 +91,71 @@ export function globalBehind({ self, stateDir }: {
91
91
  };
92
92
  stateDir?: string;
93
93
  }): GlobalBehind | null;
94
+ /**
95
+ * The command that adds a package to the project of a run in `cwd`, with the
96
+ * project's package manager (spec AST-081 FR12). Null when `cwd` belongs to
97
+ * no project `spec:AST-040` FR9 defines, and in a folder inside the project
98
+ * whose package.json is not the project's (see {@link installFolder}): a run
99
+ * there loads integrations from that package.json, so a package added to the
100
+ * project would stay unused there, and the advice is
101
+ * {@link RUN_FROM_PROJECT}.
102
+ * @param {string} cwd
103
+ * @returns {((name: string) => string) | null}
104
+ */
105
+ export function projectAddCommand(cwd: string): ((name: string) => string) | null;
94
106
  /**
95
107
  * The commands that bring a project's own CLI and Core to one release, with
96
108
  * the project's package manager: when the CLI is newer, Core up to it and then
97
109
  * the codemods from Core's release; otherwise the CLI to Core's release.
110
+ * Null in a folder that belongs to no project, or whose package.json is not
111
+ * the project's (see {@link installFolder}).
98
112
  * @param {{cwd: string, cli: string, core: string}} options
99
- * @returns {string}
113
+ * @returns {string | null}
100
114
  */
101
115
  export function alignCliAndCore({ cwd, cli, core }: {
102
116
  cwd: string;
103
117
  cli: string;
104
118
  core: string;
105
- }): string;
119
+ }): string | null;
120
+ /**
121
+ * Where a command that adds an Astryx package runs, for a run in `cwd`: in
122
+ * the project `spec:AST-040` FR9 defines, which stops at a repository root
123
+ * and never counts the home folder (spec AST-081 FR2, FR10). Null when `cwd`
124
+ * belongs to no such project, so no command adds anything. When `cwd`'s
125
+ * nearest package.json is not the project's, as in a tool folder that
126
+ * installs its own Core, a package manager would add to the tool's
127
+ * package.json, so `moved` says the command runs in the project's folder.
128
+ * @param {string} cwd
129
+ * @returns {{dir: string, moved: boolean} | null}
130
+ */
131
+ export function installFolder(cwd: string): {
132
+ dir: string;
133
+ moved: boolean;
134
+ } | null;
135
+ /**
136
+ * The command that adds the CLI at Core's version, for a run in `cwd` whose
137
+ * Core is `core`, with the project's package manager in the project root.
138
+ * `command` is null in a folder inside the project whose package.json is not
139
+ * the project's (see {@link installFolder}), where the advice is
140
+ * {@link RUN_FROM_PROJECT}. Null when the folder belongs to no project.
141
+ * @param {{cwd: string, core: string}} options
142
+ * @returns {{root: string, core: string, command: string | null} | null}
143
+ */
144
+ export function cliInstallAdvice({ cwd, core }: {
145
+ cwd: string;
146
+ core: string;
147
+ }): {
148
+ root: string;
149
+ core: string;
150
+ command: string | null;
151
+ } | null;
106
152
  /**
107
153
  * The hint for a project with no CLI of its own, answered by `answered` while
108
154
  * its Core is `core`: the command that adds the CLI at Core's version, with
109
- * the project's package manager.
155
+ * the project's package manager (see {@link cliInstallAdvice}). Null when no
156
+ * command fits, or when the project the command adds to already matches.
110
157
  * @param {{cwd: string, answered: string, core: string}} options
111
- * @returns {{root: string, line: string}}
158
+ * @returns {{root: string, line: string} | null}
112
159
  */
113
160
  export function noCliHint({ cwd, answered, core }: {
114
161
  cwd: string;
@@ -117,15 +164,16 @@ export function noCliHint({ cwd, answered, core }: {
117
164
  }): {
118
165
  root: string;
119
166
  line: string;
120
- };
167
+ } | null;
121
168
  /**
122
169
  * The hint's text.
123
170
  * @param {string} answered
124
171
  * @param {string} core
125
- * @param {string} command the command that adds the CLI at Core's version
172
+ * @param {string | null} command the command that adds the CLI at Core's
173
+ * version; null in a folder whose package.json is not the project's
126
174
  * @returns {string}
127
175
  */
128
- export function noCliHintLine(answered: string, core: string, command: string): string;
176
+ export function noCliHintLine(answered: string, core: string, command: string | null): string;
129
177
  /**
130
178
  * The command that installs the CLI at `version` in the project at `root`,
131
179
  * with its package manager.
@@ -140,7 +188,7 @@ export function addCliCommand(root: string, version: string): string;
140
188
  * @param {{cwd: string, current: string, stateDir?: string}} options
141
189
  * @returns {ProjectLag | null}
142
190
  */
143
- export function projectLag({ cwd, current, stateDir }: {
191
+ export function projectLag({ cwd, current: given, stateDir }: {
144
192
  cwd: string;
145
193
  current: string;
146
194
  stateDir?: string;
@@ -207,6 +255,12 @@ export function noticeLines({ cwd, self, choice, json, stateDir, cacheDir, now,
207
255
  }): string[];
208
256
  /** A notice prints at most once in this long. */
209
257
  export const NOTICE_INTERVAL_MS: number;
258
+ /**
259
+ * What to tell a run in a folder inside a project whose package.json is not
260
+ * the project's: run from the project's folder, since adding there would make
261
+ * the folder a project of its own (spec AST-081 FR2).
262
+ */
263
+ export const RUN_FROM_PROJECT: "Run this from the Astryx project's folder, or declare an Astryx package in this folder's package.json to make it a project of its own.";
210
264
  export type GlobalBehind = {
211
265
  /**
212
266
  * the global copy's version
@@ -43,9 +43,11 @@ import {userConfigDir} from '../env/user-dirs.mjs';
43
43
  import {astryxCommandsOnSearchPath} from '../env/search-path.mjs';
44
44
  import {
45
45
  CLI_PACKAGE,
46
+ commandInFolder,
46
47
  detectPackageManager,
47
48
  getCliInvocation,
48
49
  } from '../env/package-manager.mjs';
50
+ import {findAstryxProject, findPackageRoot} from '../fs/paths.mjs';
49
51
  import {satisfiesRange, semverCompare} from '../env/semver.mjs';
50
52
  import {isInReleaseCache, isReleaseVersion} from './cache.mjs';
51
53
  import {
@@ -55,7 +57,12 @@ import {
55
57
  tryStateLock,
56
58
  writeGlobalState,
57
59
  } from './global-state.mjs';
58
- import {globalFolderOf, isGlobalCopy, projectRootOf} from './choose.mjs';
60
+ import {
61
+ coreVersionOf,
62
+ globalFolderOf,
63
+ isGlobalCopy,
64
+ projectRootOf,
65
+ } from './choose.mjs';
59
66
  import {readReleaseFacts} from './project.mjs';
60
67
  import {samePath} from '../fs/path-compare.mjs';
61
68
  import {updateNoticesOff} from './update-notice-env.mjs';
@@ -375,16 +382,49 @@ const ADD = {
375
382
  bun: 'bun add',
376
383
  };
377
384
 
385
+ /**
386
+ * The command that adds a package to the project of a run in `cwd`, with the
387
+ * project's package manager (spec AST-081 FR12). Null when `cwd` belongs to
388
+ * no project `spec:AST-040` FR9 defines, and in a folder inside the project
389
+ * whose package.json is not the project's (see {@link installFolder}): a run
390
+ * there loads integrations from that package.json, so a package added to the
391
+ * project would stay unused there, and the advice is
392
+ * {@link RUN_FROM_PROJECT}.
393
+ * @param {string} cwd
394
+ * @returns {((name: string) => string) | null}
395
+ */
396
+ export function projectAddCommand(cwd) {
397
+ const target = installFolder(cwd);
398
+ if (target == null || target.moved) return null;
399
+ const add = ADD[detectPackageManager(cwd)] ?? ADD.npm;
400
+ return name => `${add} ${name}`;
401
+ }
402
+
378
403
  /**
379
404
  * The commands that bring a project's own CLI and Core to one release, with
380
405
  * the project's package manager: when the CLI is newer, Core up to it and then
381
406
  * the codemods from Core's release; otherwise the CLI to Core's release.
407
+ * Null in a folder that belongs to no project, or whose package.json is not
408
+ * the project's (see {@link installFolder}).
382
409
  * @param {{cwd: string, cli: string, core: string}} options
383
- * @returns {string}
410
+ * @returns {string | null}
384
411
  */
385
412
  export function alignCliAndCore({cwd, cli, core}) {
386
- const facts = readReleaseFacts(cwd);
387
- const root = projectRootOf(facts) ?? cwd;
413
+ const target = installFolder(cwd);
414
+ if (target == null || target.moved) return null;
415
+ const root = projectRootOf(readReleaseFacts(cwd)) ?? cwd;
416
+ return alignIn(root, cli, core);
417
+ }
418
+
419
+ /**
420
+ * The commands that bring the CLI and Core of the project at `root` to one
421
+ * release, run in `root`.
422
+ * @param {string} root
423
+ * @param {string} cli
424
+ * @param {string} core
425
+ * @returns {string}
426
+ */
427
+ function alignIn(root, cli, core) {
388
428
  const add = ADD[detectPackageManager(root)] ?? ADD.npm;
389
429
  if (semverCompare(cli, core) > 0) {
390
430
  return `${add} @astryxdesign/core@${cli}, then ${getCliInvocation(root, {installed: true})} upgrade --from ${core} --apply`;
@@ -392,27 +432,81 @@ export function alignCliAndCore({cwd, cli, core}) {
392
432
  return `${add} ${CLI_PACKAGE}@${core}`;
393
433
  }
394
434
 
435
+ /**
436
+ * Where a command that adds an Astryx package runs, for a run in `cwd`: in
437
+ * the project `spec:AST-040` FR9 defines, which stops at a repository root
438
+ * and never counts the home folder (spec AST-081 FR2, FR10). Null when `cwd`
439
+ * belongs to no such project, so no command adds anything. When `cwd`'s
440
+ * nearest package.json is not the project's, as in a tool folder that
441
+ * installs its own Core, a package manager would add to the tool's
442
+ * package.json, so `moved` says the command runs in the project's folder.
443
+ * @param {string} cwd
444
+ * @returns {{dir: string, moved: boolean} | null}
445
+ */
446
+ export function installFolder(cwd) {
447
+ const project = findAstryxProject(cwd);
448
+ if (project == null) return null;
449
+ const nearest = findPackageRoot(cwd);
450
+ if (nearest == null || nearest === project) return {dir: cwd, moved: false};
451
+ return {dir: project, moved: true};
452
+ }
453
+
454
+ /**
455
+ * What to tell a run in a folder inside a project whose package.json is not
456
+ * the project's: run from the project's folder, since adding there would make
457
+ * the folder a project of its own (spec AST-081 FR2).
458
+ */
459
+ export const RUN_FROM_PROJECT =
460
+ "Run this from the Astryx project's folder, or declare an Astryx package in this folder's package.json to make it a project of its own.";
461
+
462
+ /**
463
+ * The command that adds the CLI at Core's version, for a run in `cwd` whose
464
+ * Core is `core`, with the project's package manager in the project root.
465
+ * `command` is null in a folder inside the project whose package.json is not
466
+ * the project's (see {@link installFolder}), where the advice is
467
+ * {@link RUN_FROM_PROJECT}. Null when the folder belongs to no project.
468
+ * @param {{cwd: string, core: string}} options
469
+ * @returns {{root: string, core: string, command: string | null} | null}
470
+ */
471
+ export function cliInstallAdvice({cwd, core}) {
472
+ const target = installFolder(cwd);
473
+ if (target == null) return null;
474
+ if (target.moved) return {root: target.dir, core, command: null};
475
+ const root = projectRootOf(readReleaseFacts(cwd)) ?? cwd;
476
+ return {root, core, command: addCliCommand(root, core)};
477
+ }
478
+
395
479
  /**
396
480
  * The hint for a project with no CLI of its own, answered by `answered` while
397
481
  * its Core is `core`: the command that adds the CLI at Core's version, with
398
- * the project's package manager.
482
+ * the project's package manager (see {@link cliInstallAdvice}). Null when no
483
+ * command fits, or when the project the command adds to already matches.
399
484
  * @param {{cwd: string, answered: string, core: string}} options
400
- * @returns {{root: string, line: string}}
485
+ * @returns {{root: string, line: string} | null}
401
486
  */
402
487
  export function noCliHint({cwd, answered, core}) {
403
- const root = projectRootOf(readReleaseFacts(cwd)) ?? cwd;
404
- return {root, line: noCliHintLine(answered, core, addCliCommand(root, core))};
488
+ if (core === answered) return null;
489
+ const advice = cliInstallAdvice({cwd, core});
490
+ if (advice == null) return null;
491
+ return {
492
+ root: advice.root,
493
+ line: noCliHintLine(answered, core, advice.command),
494
+ };
405
495
  }
406
496
 
407
497
  /**
408
498
  * The hint's text.
409
499
  * @param {string} answered
410
500
  * @param {string} core
411
- * @param {string} command the command that adds the CLI at Core's version
501
+ * @param {string | null} command the command that adds the CLI at Core's
502
+ * version; null in a folder whose package.json is not the project's
412
503
  * @returns {string}
413
504
  */
414
505
  export function noCliHintLine(answered, core, command) {
415
- return `astryx: this project has no Astryx CLI installed; answered by CLI ${answered} while its Core is ${core}. To match, run: ${command}`;
506
+ const head = `astryx: this project has no Astryx CLI installed; answered by CLI ${answered} while its Core is ${core}.`;
507
+ return command
508
+ ? `${head} To match, run: ${command}`
509
+ : `${head} ${RUN_FROM_PROJECT}`;
416
510
  }
417
511
 
418
512
  /**
@@ -432,17 +526,29 @@ export function addCliCommand(root, version) {
432
526
  * @param {{cwd: string, current: string, stateDir?: string}} options
433
527
  * @returns {ProjectLag | null}
434
528
  */
435
- export function projectLag({cwd, current, stateDir = userConfigDir()}) {
529
+ export function projectLag({cwd, current: given, stateDir = userConfigDir()}) {
436
530
  const latest = knownLatest(stateDir);
437
- if (!latest || !isBehind(current, latest.version)) return null;
438
- const newest = latest.version;
531
+ if (!latest) return null;
439
532
  const facts = readReleaseFacts(cwd);
440
533
  if (!facts.inProject) return null;
441
- const root = projectRootOf(facts) ?? cwd;
534
+ const target = installFolder(cwd);
535
+ if (target == null) return null;
536
+ const root = target.moved ? target.dir : (projectRootOf(facts) ?? cwd);
537
+ // From a folder inside the project, the project's own release: its CLI's,
538
+ // else its Core's, so the project gets one notice and one --from.
539
+ const projectFacts = target.moved ? readReleaseFacts(root) : null;
540
+ const current = projectFacts
541
+ ? (projectFacts.cli?.version ?? coreVersionOf(projectFacts) ?? given)
542
+ : given;
543
+ if (!isBehind(current, latest.version)) return null;
544
+ const newest = latest.version;
442
545
  const pm = detectPackageManager(root);
443
546
  // The CLI is always installed beside Core: a project that installed only
444
547
  // Core gets it too, as recommended, so its version is pinned with Core's.
445
- const install = `${ADD[pm] ?? ADD.npm} @astryxdesign/core@${newest} ${CLI_PACKAGE}@${newest}`;
548
+ // From a folder inside the project whose package.json is not the
549
+ // project's, the install runs in the project's folder (see installFolder).
550
+ const add = `${ADD[pm] ?? ADD.npm} @astryxdesign/core@${newest} ${CLI_PACKAGE}@${newest}`;
551
+ const install = target.moved ? commandInFolder(root, add) : add;
446
552
  // The command runs after the install above, so the picker's guess is the
447
553
  // project's own CLI (spec AST-081 FR5).
448
554
  const stem = getCliInvocation(root, {installed: true});
@@ -452,7 +558,9 @@ export function projectLag({cwd, current, stateDir = userConfigDir()}) {
452
558
  newest,
453
559
  node: latest.node,
454
560
  install,
455
- upgrade: `${stem} upgrade --from ${current} --apply`,
561
+ upgrade: target.moved
562
+ ? commandInFolder(root, `${stem} upgrade --from ${current} --apply`)
563
+ : `${stem} upgrade --from ${current} --apply`,
456
564
  };
457
565
  }
458
566
 
@@ -536,18 +644,13 @@ export function noticeLines({
536
644
  try {
537
645
  // A project with no CLI of its own, answered by a release other than its
538
646
  // Core's: once a day per project, how to match them (FR2).
539
- if (
540
- choice.inProject &&
541
- choice.copy === 'starting' &&
542
- choice.coreVersion &&
543
- choice.coreVersion !== choice.version
544
- ) {
647
+ if (choice.inProject && choice.copy === 'starting' && choice.coreVersion) {
545
648
  const hint = noCliHint({
546
649
  cwd,
547
650
  answered: choice.version,
548
651
  core: choice.coreVersion,
549
652
  });
550
- if (take(`no-cli:${hint.root}`)) lines.push(hint.line);
653
+ if (hint && take(`no-cli:${hint.root}`)) lines.push(hint.line);
551
654
  }
552
655
  } catch {
553
656
  // A hint never fails a run.
@@ -559,8 +662,16 @@ export function noticeLines({
559
662
  choice.copy === 'starting' && choice.coreVersion
560
663
  ? choice.coreVersion
561
664
  : choice.version;
562
- const lag = projectLag({cwd, current, stateDir});
563
- if (!lag) recordNoticeSkip('project', 'no-newer', {stateDir, now});
665
+ // A folder that belongs to no project (spec AST-040 FR9) gets no
666
+ // project notice; the skip says why.
667
+ const noProject = installFolder(cwd) == null;
668
+ const lag = noProject ? null : projectLag({cwd, current, stateDir});
669
+ if (!lag) {
670
+ recordNoticeSkip('project', noProject ? 'no-project' : 'no-newer', {
671
+ stateDir,
672
+ now,
673
+ });
674
+ }
564
675
  if (lag && take(`project:${lag.root}`)) {
565
676
  lines.push(
566
677
  availableLine(lag.current, lag.newest),
@@ -355,6 +355,27 @@ describe('globalBehind and projectLag', () => {
355
355
  });
356
356
  });
357
357
 
358
+ describe('projectLag from a tool folder inside a project', () => {
359
+ it("uses the project's own CLI release, so the project gets one notice and one --from", () => {
360
+ const stateDir = checked('0.7.3');
361
+ const app = project(tempDir(), {
362
+ '@astryxdesign/core': '0.7.1',
363
+ '@astryxdesign/cli': '0.7.2',
364
+ });
365
+ writeJson(path.join(app, 'package-lock.json'), {lockfileVersion: 3});
366
+ installCore(app, '0.7.1');
367
+ installStandInCli(app, '0.7.2');
368
+ const tool = path.join(app, 'tools', 'codegen');
369
+ writeJson(path.join(tool, 'package.json'), {name: 'codegen'});
370
+ installCore(tool, '0.7.0');
371
+
372
+ const fromApp = projectLag({cwd: app, current: '0.7.2', stateDir});
373
+ const fromTool = projectLag({cwd: tool, current: '0.7.0', stateDir});
374
+ expect(fromTool).toMatchObject({root: app, current: '0.7.2'});
375
+ expect(fromTool?.upgrade).toBe(`cd ${app} && ${fromApp?.upgrade}`);
376
+ });
377
+ });
378
+
358
379
  describe('the commands notices print go through the command-name picker (spec AST-081 FR5)', () => {
359
380
  /** A Core-only npm project behind the newest release. */
360
381
  const coreOnlyProject = () => {
@@ -338,7 +338,7 @@ export const doc = {
338
338
  {
339
339
  value: 'integration.validate',
340
340
  description:
341
- 'The validation result: validated (false when nothing was validated: with no package.json the issues list carries one no_package error so the command exits 1, and with a package.json but no integration manifest the issues list is empty and proves nothing), the package name and version (both null when validated is false) plus issues, an AstryxIntegrationIssue[] of {code, severity: warning | error, message, fix?, file?, line?} (fix: the change that resolves it; file and line: where, relative to the package), and notes when there are any: {code, message} information that fails nothing, such as invalid_cli_command for a malformed cliCommand, and the package layout findings added after the last minor release, each with its fix in the message (duplicate_component_doc, symlinked_root, unreadable_file, invalid_package_json, no_provider_id, source_without_component_doc where a doc and its source still pair), and doc_name_mismatch and unknown_block_component, until they become warnings in the next minor release. A runner_command note lists each Astryx command a topic writes with a package runner (its file, line and the bare command to write). When the manifest loads, docTypes checks each doc against its published authoring type: status (checked | skipped), reason, typescript, docs, findings (all warnings, each naming the field and a fix), unchecked, and fixtures (test fixture docs not checked). When the manifest loads, docNames lists the component doc names it could not judge: status (checked), findings (always empty; a doc name the module its import names provably does not export is a doc_name_mismatch note, with its fix in the message) and unchecked ({file, name, reason}: a doc whose name differs from the name it is listed under and whose source exports cannot all be read, such as a re-export from another package). When the manifest loads, blockComponents lists the component names templates give in exampleFor or componentsUsed that could not be judged: status (checked), findings (always empty; a name neither the package nor Core has, and the template does not import, is an unknown_block_component note, with its fix in the message) and unchecked ({file, name, reason}: a name the template may reach through anything other than named imports and re-exports from Core, React, StyleX, local helpers or the entry of the package itself, such as an import from another package, a default or namespace import, an alias of or member read off an imported binding, require() or a dynamic import(), or a local module that cannot be read, or any name Core would have to resolve when Core is not installed).',
341
+ 'The validation result: validated (false when nothing was validated: with no package.json the issues list carries one no_package error so the command exits 1, and with a package.json but no integration manifest the issues list is empty and proves nothing), the package name and version (both null when validated is false) plus issues, an AstryxIntegrationIssue[] of {code, severity: warning | error, message, fix?, file?, line?} (fix: the change that resolves it; file and line: where, relative to the package), and notes when there are any: {code, message} information that fails nothing, such as invalid_cli_command for a malformed cliCommand and cli_peer_version when the running CLI is outside the @astryxdesign/cli peer range of the package, and the package layout findings added after the last minor release, each with its fix in the message (duplicate_component_doc, symlinked_root, unreadable_file, invalid_package_json, no_provider_id, source_without_component_doc where a doc and its source still pair), and doc_name_mismatch and unknown_block_component, until they become warnings in the next minor release. A runner_command note lists each Astryx command a topic writes with a package runner (its file, line and the bare command to write). When the manifest loads, docTypes checks each doc against its published authoring type: status (checked | skipped), reason, typescript, docs, findings (all warnings, each naming the field and a fix), unchecked, and fixtures (test fixture docs not checked). When the manifest loads, docNames lists the component doc names it could not judge: status (checked), findings (always empty; a doc name the module its import names provably does not export is a doc_name_mismatch note, with its fix in the message) and unchecked ({file, name, reason}: a doc whose name differs from the name it is listed under and whose source exports cannot all be read, such as a re-export from another package). When the manifest loads, blockComponents lists the component names templates give in exampleFor or componentsUsed that could not be judged: status (checked), findings (always empty; a name neither the package nor Core has, and the template does not import, is an unknown_block_component note, with its fix in the message) and unchecked ({file, name, reason}: a name the template may reach through anything other than named imports and re-exports from Core, React, StyleX, local helpers or the entry of the package itself, such as an import from another package, a default or namespace import, an alias of or member read off an imported binding, require() or a dynamic import(), or a local module that cannot be read, or any name Core would have to resolve when Core is not installed). Since 0.7.3 each import apps cannot use is also a note (its fix in the message), listed only and failing --strict from the next minor. publicImports ({status: checked, findings: [], unchecked}) lists each import the check could not judge as {file, specifier, reason}; never counted or failed on.',
342
342
  },
343
343
  {
344
344
  value: 'integration.template-conflicts',
@@ -28,7 +28,8 @@ export function findClosestComponents(name: string, components: Record<string, s
28
28
  * 30 keyword Levenshtein distance 2
29
29
  * 20 name Levenshtein distance 3
30
30
  *
31
- * Each result: { name, score, reason }
31
+ * Each result: { name, score, reason }, plus `keywordAt` when a keyword set
32
+ * the component's score: the position of the keyword that set it.
32
33
  *
33
34
  * @param {string} needle
34
35
  * @param {string} coreDir
@@ -48,7 +48,8 @@ export function findClosestComponents(name, components, maxDistance = 3) {
48
48
  * 30 keyword Levenshtein distance 2
49
49
  * 20 name Levenshtein distance 3
50
50
  *
51
- * Each result: { name, score, reason }
51
+ * Each result: { name, score, reason }, plus `keywordAt` when a keyword set
52
+ * the component's score: the position of the keyword that set it.
52
53
  *
53
54
  * @param {string} needle
54
55
  * @param {string} coreDir
@@ -64,6 +65,9 @@ export async function searchComponents(needle, coreDir, components) {
64
65
  const allNames = Object.values(components).flat();
65
66
  /** @type {Map<string, {name: string, score: number, reason: string}>} */
66
67
  const scored = new Map();
68
+ /** Position of the keyword that set each component's score. */
69
+ /** @type {Map<string, number>} */
70
+ const keywordAt = new Map();
67
71
 
68
72
  /**
69
73
  * @param {string} name
@@ -146,12 +150,14 @@ export async function searchComponents(needle, coreDir, components) {
146
150
 
147
151
  // Keyword matching
148
152
  if (docs.keywords && Array.isArray(docs.keywords)) {
149
- for (const kw of docs.keywords) {
153
+ for (const [at, kw] of docs.keywords.entries()) {
150
154
  const kwLower = kw.toLowerCase();
155
+ const before = scored.get(comp)?.score ?? 0;
151
156
 
152
157
  // Exact keyword
153
158
  if (kwLower === term) {
154
159
  addMatch(comp, 90, 'keyword "' + kw + '"');
160
+ if (!keywordAt.has(comp) || before < 90) keywordAt.set(comp, at);
155
161
  break;
156
162
  }
157
163
 
@@ -170,6 +176,7 @@ export async function searchComponents(needle, coreDir, components) {
170
176
  addMatch(comp, 70, 'keyword "' + kw + '" (distance ' + dist + ')');
171
177
  else if (dist === 2)
172
178
  addMatch(comp, 30, 'keyword "' + kw + '" (distance ' + dist + ')');
179
+ if ((scored.get(comp)?.score ?? 0) > before) keywordAt.set(comp, at);
173
180
  }
174
181
  }
175
182
 
@@ -202,9 +209,13 @@ export async function searchComponents(needle, coreDir, components) {
202
209
  }
203
210
  }
204
211
 
205
- const results = Array.from(scored.values()).sort(
206
- (a, b) => b.score - a.score || a.name.localeCompare(b.name),
207
- );
212
+ const results = Array.from(scored.values())
213
+ .map(r =>
214
+ keywordAt.has(r.name)
215
+ ? {...r, keywordAt: /** @type {number} */ (keywordAt.get(r.name))}
216
+ : r,
217
+ )
218
+ .sort((a, b) => b.score - a.score || a.name.localeCompare(b.name));
208
219
 
209
220
  return results;
210
221
  }
@@ -0,0 +1,72 @@
1
+ // @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
2
+ // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
+
4
+ /**
5
+ * A name's words, lowercase and singular: camelCase, PascalCase, kebab-case,
6
+ * snake_case, slashes and spaces all split.
7
+ * @param {string} text
8
+ * @returns {string[]}
9
+ */
10
+ export function nameWords(text: string): string[];
11
+ /**
12
+ * The same items, closest to the typed name first; each item is as close as
13
+ * its closest name. Equal matches keep their original order.
14
+ * @template T
15
+ * @param {string} typedName
16
+ * @param {T[]} items
17
+ * @param {(item: T) => Array<string | undefined>} namesOf
18
+ * @returns {T[]}
19
+ */
20
+ export function orderByAffinity<T>(typedName: string, items: T[], namesOf: (item: T) => Array<string | undefined>): T[];
21
+ /**
22
+ * Docs route suggestions, closest to the typed route first. When every
23
+ * suggestion sits under one namespace the typed route also starts with, that
24
+ * shared part is left out of the comparison: it says nothing about which page
25
+ * was meant. Equal matches keep their order.
26
+ * @template {{name: string}} T
27
+ * @param {string} topic - the typed route
28
+ * @param {T[]} suggestions
29
+ * @returns {T[]}
30
+ */
31
+ export function orderRouteSuggestions<T extends {
32
+ name: string;
33
+ }>(topic: string, suggestions: T[]): T[];
34
+ /**
35
+ * The components whose synonyms name what was typed. A synonym matches when
36
+ * its words, with or without a leading library name, are the typed words
37
+ * (`MUI TextField` matches `MUI TextField`, `TextField` and `text-field`).
38
+ * @param {string} needle
39
+ * @param {Record<string, {synonyms?: string[]}>} cards - component name → its search card
40
+ * @returns {Set<string>}
41
+ */
42
+ export function synonymMatches(needle: string, cards: Record<string, {
43
+ synonyms?: string[];
44
+ }>): Set<string>;
45
+ /**
46
+ * Rank component suggestions for a name that resolved to nothing.
47
+ *
48
+ * Every component `searchComponents` scored keeps its score. A component whose
49
+ * name has exactly the typed words (`chat-messages` for `ChatMessage`) scores
50
+ * like an exact name; one of whose synonyms is the typed name (see
51
+ * {@link synonymMatches}) like an exact keyword; one whose name shares the
52
+ * typed compound name's words (see {@link compoundMatch}) just below a
53
+ * one-letter typo of a name. Equal scores put synonym matches first, then order by how many of the typed words the
54
+ * name carries, then by how early the keyword that matched sits in the
55
+ * component's keywords, then by edit distance, then by shared leading letters,
56
+ * then by name. The caller decides how many to print.
57
+ * @param {string} needle - the typed component name (no `XDS` prefix)
58
+ * @param {Array<{name: string, score: number, reason: string, keywordAt?: number}>} results - `searchComponents` output
59
+ * @param {string[]} allNames - every component name
60
+ * @param {Set<string>} [synonyms] - {@link synonymMatches} for the typed name
61
+ * @returns {Array<{name: string, score: number, reason: string}>}
62
+ */
63
+ export function rankComponentSuggestions(needle: string, results: Array<{
64
+ name: string;
65
+ score: number;
66
+ reason: string;
67
+ keywordAt?: number;
68
+ }>, allNames: string[], synonyms?: Set<string>): Array<{
69
+ name: string;
70
+ score: number;
71
+ reason: string;
72
+ }>;