@astryxdesign/cli 0.7.3-canary.b74cf21 → 0.7.3-canary.be42333

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 (229) hide show
  1. package/README.md +68 -68
  2. package/api/build/blocks/blocks.d.mts +6 -4
  3. package/api/build/blocks/blocks.mjs +103 -20
  4. package/api/build/blocks/blocks.test.mjs +126 -13
  5. package/api/build/blocks/blocks.weights.json +1 -1
  6. package/api/build/kit/answer.d.mts +5 -4
  7. package/api/build/kit/answer.mjs +114 -12
  8. package/api/build/kit/answer.test.mjs +73 -3
  9. package/api/build/kit/signals.d.mts +8 -0
  10. package/api/build/kit/signals.mjs +10 -0
  11. package/api/build/tree.test.mjs +19 -11
  12. package/api/component/component-replacement.test.mjs +1 -0
  13. package/api/component/component.mjs +17 -3
  14. package/api/component/component.test.mjs +15 -0
  15. package/api/component/doc-links.test.mjs +2 -2
  16. package/api/discover/_adapter.d.mts +1 -2
  17. package/api/discover/_adapter.mjs +6 -8
  18. package/api/discover/discover.mjs +0 -1
  19. package/api/docs/_adapter.d.mts +2 -2
  20. package/api/docs/_adapter.mjs +61 -18
  21. package/api/docs/docs-homes.test.mjs +127 -0
  22. package/api/docs/docs.doc.mjs +3 -3
  23. package/api/docs/docs.test.mjs +28 -18
  24. package/api/docs/integration-tree.test.mjs +20 -20
  25. package/api/docs/integrationDocs.test.mjs +1 -1
  26. package/api/docs/namespace-section.test.mjs +6 -6
  27. package/api/docs/reference-blocks.test.mjs +2 -2
  28. package/api/doctor/_adapter.d.mts +24 -10
  29. package/api/doctor/_adapter.mjs +28 -25
  30. package/api/doctor/doctor.d.mts +7 -4
  31. package/api/doctor/doctor.mjs +68 -26
  32. package/api/doctor/doctor.test.mjs +95 -12
  33. package/api/hook/hook.mjs +1 -1
  34. package/api/integration/_adapter.d.mts +8 -0
  35. package/api/integration/_adapter.mjs +21 -1
  36. package/api/integration/authoring-checks.test.mjs +220 -0
  37. package/api/integration/pack-check.mjs +110 -4
  38. package/api/integration/pack-check.test.mjs +69 -0
  39. package/api/integration/validate-integration-fixes.test.mjs +6 -5
  40. package/api/integration/validate-integration-gaps.test.mjs +304 -1
  41. package/api/integration/validate-integration.d.mts +6 -1
  42. package/api/integration/validate-integration.mjs +82 -13
  43. package/api/integration/validate-integration.type.d.mts +37 -4
  44. package/api/integration/validate-integration.type.mjs +28 -5
  45. package/api/integration/validateIntegration.doc.mjs +1 -1
  46. package/api/search/_adapter.d.mts +16 -0
  47. package/api/search/_adapter.mjs +39 -0
  48. package/api/search/_adapter.test.mjs +173 -0
  49. package/api/search/_candidate-score.mjs +1 -1
  50. package/api/search/_entries.d.mts +11 -0
  51. package/api/search/_entries.mjs +77 -3
  52. package/api/search/_entries.test.mjs +48 -0
  53. package/api/search/_gather-docs.mjs +3 -3
  54. package/api/search/search.doc.mjs +1 -1
  55. package/api/search/search.mjs +6 -2
  56. package/api/search/search.test.mjs +14 -14
  57. package/api/upgrade/_adapter.d.mts +57 -3
  58. package/api/upgrade/_adapter.mjs +149 -27
  59. package/api/upgrade/registry/registry.d.mts +10 -4
  60. package/api/upgrade/registry/registry.mjs +33 -16
  61. package/api/upgrade/registry/registry.test.mjs +85 -0
  62. package/api/upgrade/run/run.d.mts +4 -2
  63. package/api/upgrade/run/run.mjs +13 -2
  64. package/api/upgrade/run/run.test.mjs +417 -3
  65. package/api/upgrade/upgrade.doc.mjs +10 -5
  66. package/api/upgrade/upgrade.mjs +13 -2
  67. package/api/upgrade/upgrade.type.d.mts +5 -3
  68. package/api/upgrade/upgrade.type.mjs +8 -6
  69. package/assets/docs/author-a-theme.doc.mjs +2 -2
  70. package/assets/docs/is-my-code-good.doc.mjs +287 -0
  71. package/assets/docs/tree/add-a-component.doc.mjs +1 -1
  72. package/assets/docs/tree/add-a-theme.doc.mjs +1 -1
  73. package/assets/docs/tree/add-a-topic.doc.mjs +2 -2
  74. package/assets/docs/tree/agent-guidance.doc.mjs +1 -1
  75. package/assets/docs/tree/{integrations.doc.mjs → authoring.doc.mjs} +15 -6
  76. package/assets/docs/tree/block-template.doc.mjs +1 -1
  77. package/assets/docs/tree/build-the-template.doc.mjs +1 -1
  78. package/assets/docs/tree/building-blocks.doc.mjs +2 -2
  79. package/assets/docs/tree/check-the-props.doc.mjs +1 -1
  80. package/assets/docs/tree/check-your-docs.doc.mjs +2 -2
  81. package/assets/docs/tree/checks.doc.mjs +3 -3
  82. package/assets/docs/tree/cli-command.doc.mjs +1 -1
  83. package/assets/docs/tree/cli.doc.mjs +1 -1
  84. package/assets/docs/tree/codemods.doc.mjs +1 -1
  85. package/assets/docs/tree/component-family.doc.mjs +1 -1
  86. package/assets/docs/tree/component-imports.doc.mjs +1 -1
  87. package/assets/docs/tree/components.doc.mjs +1 -1
  88. package/assets/docs/tree/configuration.doc.mjs +1 -1
  89. package/assets/docs/tree/debug-and-gap-reports.doc.mjs +1 -1
  90. package/assets/docs/tree/define-the-theme.doc.mjs +1 -1
  91. package/assets/docs/tree/describe-the-component.doc.mjs +1 -1
  92. package/assets/docs/tree/docs.doc.mjs +1 -1
  93. package/assets/docs/tree/document-the-template.doc.mjs +1 -1
  94. package/assets/docs/tree/document-the-theme.doc.mjs +1 -1
  95. package/assets/docs/tree/export-template-assets.doc.mjs +1 -1
  96. package/assets/docs/tree/extend-or-replace.doc.mjs +1 -1
  97. package/assets/docs/{authoring.doc.mjs → tree/field-reference.doc.mjs} +4 -3
  98. package/assets/docs/tree/fonts-and-assets.doc.mjs +1 -1
  99. package/assets/docs/tree/generate-a-palette.doc.mjs +1 -1
  100. package/assets/docs/tree/global-integrations.doc.mjs +2 -2
  101. package/assets/docs/tree/grade-template-with-agent.doc.mjs +4 -4
  102. package/assets/docs/tree/help.doc.mjs +2 -2
  103. package/assets/docs/tree/links.doc.mjs +1 -1
  104. package/assets/docs/tree/package-and-test.doc.mjs +1 -1
  105. package/assets/docs/tree/page-template.doc.mjs +1 -1
  106. package/assets/docs/tree/publishing.doc.mjs +1 -1
  107. package/assets/docs/tree/quick-start.doc.mjs +1 -1
  108. package/assets/docs/tree/replace-a-core-component.doc.mjs +1 -1
  109. package/assets/docs/tree/replace-a-core-template.doc.mjs +1 -1
  110. package/assets/docs/tree/sections-and-placement.doc.mjs +1 -1
  111. package/assets/docs/tree/see-it-in-an-app.doc.mjs +1 -1
  112. package/assets/docs/tree/ship.doc.mjs +2 -2
  113. package/assets/docs/tree/short-and-findable.doc.mjs +1 -1
  114. package/assets/docs/tree/single-component.doc.mjs +1 -1
  115. package/assets/docs/tree/start-a-template.doc.mjs +1 -1
  116. package/assets/docs/tree/subcomponent.doc.mjs +1 -1
  117. package/assets/docs/tree/template-assets.doc.mjs +1 -1
  118. package/assets/docs/tree/template-doc-overview.doc.mjs +2 -2
  119. package/assets/docs/tree/template-fonts.doc.mjs +1 -1
  120. package/assets/docs/tree/template-grading-rubric.doc.mjs +17 -38
  121. package/assets/docs/tree/template-icons.doc.mjs +1 -1
  122. package/assets/docs/tree/template-images-media.doc.mjs +1 -1
  123. package/assets/docs/tree/template-styles.doc.mjs +1 -1
  124. package/assets/docs/tree/templates.doc.mjs +1 -1
  125. package/assets/docs/tree/test-in-an-app.doc.mjs +1 -1
  126. package/assets/docs/tree/test-template-in-app.doc.mjs +1 -1
  127. package/assets/docs/tree/themes.doc.mjs +1 -1
  128. package/assets/docs/tree/troubleshooting.doc.mjs +1 -1
  129. package/assets/docs/tree/upgrading.doc.mjs +1 -1
  130. package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +1 -1
  131. package/assets/docs/tree/verify-packed-template.doc.mjs +1 -1
  132. package/assets/docs/tree/versioning.doc.mjs +5 -1
  133. package/assets/docs/tree/write-good-templates.doc.mjs +1 -1
  134. package/assets/docs/tree/write-the-template-file.doc.mjs +1 -1
  135. package/assets/docs/use-integrations.doc.mjs +120 -0
  136. package/assets/templates/themes/butter/butterTheme.ts +4 -2
  137. package/assets/templates/themes/stone/stoneTheme.ts +4 -2
  138. package/assets/templates/themes/y2k/y2kTheme.ts +4 -2
  139. package/authoring/doctypes/schema/schema.doc.mjs +1 -1
  140. package/authoring/integration/integration.doc.mjs +1 -1
  141. package/authoring/integration/type.ts +1 -1
  142. package/clients/cli/command-result-coverage.test.mjs +6 -5
  143. package/clients/cli/commands/build-theme.color-scheme.test.mjs +1 -1
  144. package/clients/cli/commands/{component/index.mjs → component.mjs} +37 -37
  145. package/clients/cli/commands/component.test.mjs +6 -6
  146. package/clients/cli/commands/docs.doc.mjs +2 -2
  147. package/clients/cli/commands/docs.mjs +1 -1
  148. package/clients/cli/commands/docs.test.mjs +14 -14
  149. package/clients/cli/commands/doctor-integration.test.mjs +49 -1
  150. package/clients/cli/commands/doctor.mjs +10 -0
  151. package/clients/cli/commands/{hook/index.mjs → hook.mjs} +22 -22
  152. package/clients/cli/commands/import-hint-correctness.test.mjs +1 -1
  153. package/clients/cli/commands/integration-check.test.mjs +48 -0
  154. package/clients/cli/commands/integration.doc.mjs +1 -1
  155. package/clients/cli/commands/manifest.doc.mjs +1 -1
  156. package/clients/cli/commands/manifest.mjs +67 -0
  157. package/clients/cli/commands/postinstall.doc.mjs +23 -0
  158. package/clients/cli/commands/postinstall.mjs +31 -0
  159. package/clients/cli/commands/setup-nudge.test.mjs +17 -0
  160. package/clients/cli/commands/{build-theme.mjs → theme.mjs} +1 -1
  161. package/clients/cli/commands/upgrade.doc.mjs +4 -2
  162. package/clients/cli/commands/upgrade.mjs +9 -2
  163. package/clients/cli/commands/upgrade.subfolder-path.test.mjs +97 -0
  164. package/clients/cli/index.mjs +35 -93
  165. package/clients/cli/lib/component-format.mjs +1 -1
  166. package/clients/cli/lib/define-command.mjs +12 -7
  167. package/clients/cli/lib/exit-codes.test.mjs +5 -0
  168. package/clients/cli/lib/manifest.test.mjs +12 -0
  169. package/clients/cli/lib/welcome-box.mjs +50 -0
  170. package/foundation/agent-docs/agent-doc-state.d.mts +12 -0
  171. package/foundation/agent-docs/agent-doc-state.mjs +24 -2
  172. package/foundation/agent-docs/agent-docs.mjs +7 -6
  173. package/foundation/agent-docs/agent-docs.test.mjs +5 -4
  174. package/foundation/agent-docs/computer-agent-text.mjs +16 -1
  175. package/foundation/agent-docs/computer-agent-text.test.mjs +23 -2
  176. package/foundation/config/project.mjs +5 -20
  177. package/foundation/config/project.test.mjs +56 -0
  178. package/foundation/discovery/authoring-self-docs.d.mts +7 -0
  179. package/foundation/discovery/authoring-self-docs.mjs +16 -4
  180. package/foundation/discovery/authoring-self-docs.test.mjs +15 -3
  181. package/foundation/discovery/authoring-surface.d.mts +1 -1
  182. package/foundation/discovery/authoring-surface.mjs +2 -2
  183. package/foundation/discovery/authoring-surface.test.mjs +1 -1
  184. package/foundation/discovery/cli-self-docs.d.mts +2 -1
  185. package/foundation/discovery/cli-self-docs.mjs +4 -3
  186. package/foundation/discovery/cli-self-docs.test.mjs +2 -2
  187. package/foundation/discovery/runner-allowlist.d.mts +2 -4
  188. package/foundation/discovery/runner-allowlist.mjs +2 -4
  189. package/foundation/discovery/runner-commands.d.mts +77 -0
  190. package/foundation/discovery/runner-commands.mjs +294 -0
  191. package/foundation/discovery/runner-commands.test.mjs +128 -0
  192. package/foundation/discovery/stray-pointers.test.mjs +1 -1
  193. package/foundation/discovery/template-adapter.mjs +18 -1
  194. package/foundation/discovery/template-needs.mjs +1 -44
  195. package/foundation/discovery/theme-discovery.mjs +147 -3
  196. package/foundation/doc-compiler/doc-loads.test.mjs +25 -9
  197. package/foundation/doc-compiler/read.mjs +59 -1
  198. package/foundation/doc-compiler/read.test.mjs +11 -2
  199. package/foundation/doc-compiler/split-topic-keywords.test.mjs +3 -2
  200. package/foundation/doc-compiler/tree.d.mts +32 -6
  201. package/foundation/doc-compiler/tree.mjs +77 -43
  202. package/foundation/doc-compiler/tree.test.mjs +7 -7
  203. package/foundation/fs/paths.d.mts +70 -8
  204. package/foundation/fs/paths.mjs +526 -35
  205. package/foundation/fs/paths.test.mjs +430 -54
  206. package/foundation/fs/read-record.d.mts +18 -0
  207. package/foundation/fs/read-record.mjs +131 -0
  208. package/foundation/fs/read-record.test.mjs +77 -0
  209. package/foundation/integrations/autolink.d.mts +2 -1
  210. package/foundation/integrations/autolink.mjs +4 -13
  211. package/foundation/integrations/cli-peer-version.d.mts +36 -0
  212. package/foundation/integrations/cli-peer-version.mjs +132 -0
  213. package/foundation/integrations/cli-peer-version.test.mjs +354 -0
  214. package/foundation/integrations/exports-subpaths.d.mts +57 -0
  215. package/foundation/integrations/exports-subpaths.mjs +113 -0
  216. package/foundation/integrations/integrations.d.mts +20 -1
  217. package/foundation/integrations/integrations.mjs +59 -2
  218. package/foundation/integrations/public-imports.d.mts +118 -0
  219. package/foundation/integrations/public-imports.mjs +1769 -0
  220. package/foundation/integrations/public-imports.test.mjs +1793 -0
  221. package/foundation/integrations/validate-contributions.d.mts +19 -0
  222. package/foundation/integrations/validate-contributions.mjs +172 -3
  223. package/foundation/release/global-state.d.mts +8 -4
  224. package/foundation/release/global-state.mjs +4 -2
  225. package/foundation/release/notices.d.mts +62 -8
  226. package/foundation/release/notices.mjs +136 -25
  227. package/foundation/release/notices.test.mjs +21 -0
  228. package/foundation/response/response-types.doc.mjs +1 -1
  229. package/package.json +9 -9
@@ -2,10 +2,11 @@
2
2
  // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
3
 
4
4
  /**
5
- * The kit for a request. `blocks` re-orders the blocks build names itself:
6
- * each keeps build's own entry (its score and reason), and a name build did
7
- * not give is dropped, so the kit never lists more blocks than build's own.
8
- * Blocks of the same name from two packages are both kept.
5
+ * The kit for a request. `blocks` names the blocks to list, best first: a
6
+ * block build names itself keeps build's entry, another keeps search's own
7
+ * entry (its real score and reason), a name search did not return is
8
+ * dropped, and the kit never lists more blocks than build's own. Blocks of
9
+ * the same name from two packages are both kept.
9
10
  *
10
11
  * @param {import('./signals.mjs').KitSignals} signals
11
12
  * @param {string[]} [blocks] block names; build's own when omitted
@@ -10,6 +10,7 @@
10
10
  * calls it with the block picker's list.
11
11
  */
12
12
 
13
+ import {firstSentence} from '../../../foundation/text/string-utils.mjs';
13
14
  import {FOUNDATION, FRAME} from './signals.mjs';
14
15
 
15
16
  /**
@@ -23,10 +24,11 @@ import {FOUNDATION, FRAME} from './signals.mjs';
23
24
  const THIN_KIT = 3;
24
25
 
25
26
  /**
26
- * The kit for a request. `blocks` re-orders the blocks build names itself:
27
- * each keeps build's own entry (its score and reason), and a name build did
28
- * not give is dropped, so the kit never lists more blocks than build's own.
29
- * Blocks of the same name from two packages are both kept.
27
+ * The kit for a request. `blocks` names the blocks to list, best first: a
28
+ * block build names itself keeps build's entry, another keeps search's own
29
+ * entry (its real score and reason), a name search did not return is
30
+ * dropped, and the kit never lists more blocks than build's own. Blocks of
31
+ * the same name from two packages are both kept.
30
32
  *
31
33
  * @param {import('./signals.mjs').KitSignals} signals
32
34
  * @param {string[]} [blocks] block names; build's own when omitted
@@ -40,10 +42,22 @@ export function kitAnswer(signals, blocks = signals.kitBlocks) {
40
42
  const own = new Map();
41
43
  for (const b of signals.blocks)
42
44
  own.set(b.name, [...(own.get(b.name) ?? []), b]);
43
- const named = blocks.flatMap(name => {
44
- const entry = own.get(name)?.shift();
45
- return entry ? [entry] : [];
46
- });
45
+ /** @type {Set<string>} */
46
+ const added = new Set();
47
+ const named = blocks
48
+ .flatMap(name => {
49
+ const entry = own.get(name)?.shift();
50
+ if (entry) return [entry];
51
+ // A block build does not name itself keeps search's own entry, once.
52
+ const found =
53
+ own.has(name) || added.has(name)
54
+ ? undefined
55
+ : signals.searchedEntries.get(name);
56
+ if (!found) return [];
57
+ added.add(name);
58
+ return [found];
59
+ })
60
+ .slice(0, signals.blocks.length);
47
61
 
48
62
  // What to try when the kit comes back thin. Keyword search over a design
49
63
  // system misses in a predictable way — the reader's words and the package's
@@ -64,8 +78,8 @@ export function kitAnswer(signals, blocks = signals.kitBlocks) {
64
78
  }
65
79
  : undefined;
66
80
 
67
- return {
68
- type: 'build.kit',
81
+ const answer = (/** @type {typeof named} */ list) => ({
82
+ type: /** @type {const} */ ('build.kit'),
69
83
  data: {
70
84
  query: signals.query,
71
85
  // Distinguishes "search found nothing" from a weak-but-non-empty result
@@ -75,11 +89,99 @@ export function kitAnswer(signals, blocks = signals.kitBlocks) {
75
89
  directMatch: signals.directMatch,
76
90
  start: signals.start,
77
91
  pages: signals.pages,
78
- blocks: named,
92
+ blocks: list,
79
93
  domain: signals.domain,
80
94
  frame: FRAME,
81
95
  foundation: FOUNDATION,
82
96
  hint,
83
97
  },
84
- };
98
+ });
99
+
100
+ // An added block must not make the answer longer than build's own, as JSON
101
+ // or as text: trim the added blocks' descriptions, never which blocks are
102
+ // listed.
103
+ const fitted = fitDescriptions(named, signals.blocks, {
104
+ json: list => bytes(answer(list)),
105
+ text: textSize,
106
+ });
107
+ return answer(fitted);
108
+ }
109
+
110
+ /** @param {unknown} value */
111
+ const bytes = value => Buffer.byteLength(JSON.stringify(value));
112
+
113
+ /**
114
+ * What the blocks add to the text answer, which prints each block's name,
115
+ * package, and the first sentence of its description.
116
+ * @param {{name: string, package?: string, description?: string}[]} list
117
+ */
118
+ const textSize = list =>
119
+ list.reduce(
120
+ (n, b) =>
121
+ n +
122
+ Buffer.byteLength(
123
+ `${b.name}${b.package ?? ''}${firstSentence(b.description ?? '')}`,
124
+ ),
125
+ 0,
126
+ );
127
+
128
+ /** An added block keeps at least this much of its description. */
129
+ const MIN_DESCRIPTION = 24;
130
+
131
+ /**
132
+ * A description cut to about `keep` characters (never fewer than
133
+ * {@link MIN_DESCRIPTION}) at a word boundary, with an ellipsis. Never empty:
134
+ * a description already that short is kept whole.
135
+ * @param {string} description
136
+ * @param {number} keep
137
+ */
138
+ function cutTo(description, keep) {
139
+ const room = Math.max(keep, MIN_DESCRIPTION);
140
+ if (description.length <= room) return description;
141
+ const cut = description.slice(0, room);
142
+ const at = cut.lastIndexOf(' ');
143
+ return `${(at > 0 ? cut.slice(0, at) : cut).trimEnd()}…`;
144
+ }
145
+
146
+ /**
147
+ * The listed blocks with the added blocks' descriptions shortened until
148
+ * neither the JSON nor the text answer is longer than with build's own
149
+ * blocks, or every added description is as short as it may get. A
150
+ * description is never emptied, and build's own entries never change.
151
+ * @template {{name: string, package?: string, description?: string}} B
152
+ * @param {B[]} list
153
+ * @param {B[]} own build's own entries
154
+ * @param {{json: (list: B[]) => number, text: (list: B[]) => number}} size
155
+ * @returns {B[]}
156
+ */
157
+ function fitDescriptions(list, own, size) {
158
+ const limit = {json: size.json(own), text: size.text(own)};
159
+ let out = list;
160
+ /** The bytes over each limit; 0 when within. */
161
+ const over = (/** @type {B[]} */ l) => ({
162
+ text: Math.max(0, size.text(l) - limit.text),
163
+ json: Math.max(0, size.json(l) - limit.json),
164
+ });
165
+ // The last added block first, each cut by what is still over and never
166
+ // below MIN_DESCRIPTION; when one is as short as it may get, the next one
167
+ // up is cut, and passes repeat while any cut still helps.
168
+ for (let changed = true; changed;) {
169
+ changed = false;
170
+ for (let k = out.length - 1; k >= 0; k--) {
171
+ const o = over(out);
172
+ if (o.text === 0 && o.json === 0) return out;
173
+ const b = out[k];
174
+ if (own.includes(b) || !b.description) continue;
175
+ const first = firstSentence(b.description);
176
+ const keep = Math.min(
177
+ o.text > 0 ? first.length - o.text - 1 : b.description.length,
178
+ o.json > 0 ? b.description.length - o.json - 1 : b.description.length,
179
+ );
180
+ const description = cutTo(b.description, keep);
181
+ if (description.length >= b.description.length) continue;
182
+ out = out.map((x, i) => (i === k ? {...x, description} : x));
183
+ changed = true;
184
+ }
185
+ }
186
+ return out;
85
187
  }
@@ -3,8 +3,11 @@
3
3
  import {describe, it, expect} from 'vitest';
4
4
  import {kitAnswer} from './answer.mjs';
5
5
 
6
- /** @param {any[]} blocks */
7
- const signals = blocks =>
6
+ /**
7
+ * @param {any[]} blocks
8
+ * @param {any[]} [searched] blocks search returned that build did not name
9
+ */
10
+ const signals = (blocks, searched = []) =>
8
11
  /** @type {any} */ ({
9
12
  query: 'q',
10
13
  matchCount: blocks.length,
@@ -14,6 +17,7 @@ const signals = blocks =>
14
17
  blocks,
15
18
  kitBlocks: blocks.map(b => b.name),
16
19
  domain: [],
20
+ searchedEntries: new Map(searched.map(b => [b.name, b])),
17
21
  });
18
22
 
19
23
  describe('kitAnswer', () => {
@@ -31,8 +35,74 @@ describe('kitAnswer', () => {
31
35
  expect(kit.data.blocks).toEqual([c, a, b]);
32
36
  });
33
37
 
34
- it('never lists a block build did not give, or more than it gave', () => {
38
+ it('never lists a block neither build nor search gave, or more than build gave', () => {
35
39
  const kit = kitAnswer(signals([a, c]), ['Hero', 'Hero', 'Nav', 'Footer']);
36
40
  expect(kit.data.blocks).toEqual([a, c]);
37
41
  });
42
+
43
+ it('lists a block search returned with search’s own entry, within build’s count', () => {
44
+ const nav = {name: 'Nav', package: '@a/one', score: 60, reason: 'keyword'};
45
+ const kit = kitAnswer(signals([a, c], [nav]), [
46
+ 'Nav',
47
+ 'Nav',
48
+ 'Hero',
49
+ 'Footer',
50
+ ]);
51
+ expect(kit.data.blocks).toEqual([nav, a]);
52
+ });
53
+
54
+ it('trims an added block’s description so the answer is never longer than build’s own', () => {
55
+ const hero = {
56
+ ...a,
57
+ description: 'A wide hero with a title and two buttons.',
58
+ };
59
+ const foot = {...c, description: 'A footer with links in three columns.'};
60
+ const nav = {
61
+ name: 'Nav',
62
+ package: '@a/one',
63
+ score: 60,
64
+ reason: 'keyword',
65
+ description: 'word '.repeat(200).trim(),
66
+ };
67
+ const own = kitAnswer(signals([hero, foot]));
68
+ const kit = kitAnswer(signals([hero, foot], [nav]), ['Nav', 'Hero']);
69
+ expect(kit.data.blocks.map(b => b.name)).toEqual(['Nav', 'Hero']);
70
+ expect(kit.data.blocks[1]).toEqual(hero);
71
+ expect(Buffer.byteLength(JSON.stringify(kit))).toBeLessThanOrEqual(
72
+ Buffer.byteLength(JSON.stringify(own)),
73
+ );
74
+ expect(kit.data.blocks[0].description).toMatch(/…$/);
75
+ });
76
+ it('trims an added block’s first sentence so the text answer is never longer either', () => {
77
+ const long = ' More words follow here. '.repeat(20);
78
+ const hero = {...a, description: `A hero.${long}`};
79
+ const foot = {...c, description: `A footer.${long}`};
80
+ const nav = {
81
+ name: 'Nav',
82
+ package: '@a/one',
83
+ score: 60,
84
+ reason: 'keyword',
85
+ description:
86
+ 'A navigation bar with a logo, five links, a search box and a menu.',
87
+ };
88
+ const kit = kitAnswer(signals([hero, foot], [nav]), ['Nav', 'Hero']);
89
+ const d = kit.data.blocks[0].description;
90
+ expect(d).toMatch(/…$/);
91
+ expect(d.length).toBeLessThan(nav.description.length);
92
+ expect(nav.description.startsWith(d.slice(0, -1))).toBe(true);
93
+ expect(kit.data.blocks[1]).toEqual(hero);
94
+ });
95
+ it('never empties an added block’s description', () => {
96
+ const nav = {
97
+ name: 'Nav',
98
+ package: '@a/one',
99
+ score: 60,
100
+ reason: 'keyword',
101
+ description:
102
+ 'A navigation bar with a logo, five links, a search box and a menu.',
103
+ };
104
+ const kit = kitAnswer(signals([a, c], [nav]), ['Nav', 'Hero']);
105
+ expect(kit.data.blocks[0].name).toBe('Nav');
106
+ expect(kit.data.blocks[0].description.length).toBeGreaterThan(0);
107
+ });
38
108
  });
@@ -53,6 +53,14 @@ export type KitSignals = {
53
53
  * every block search returned, in its order
54
54
  */
55
55
  searched: BlockScore[];
56
+ /**
57
+ * search's entry for each of those blocks (the first of a name)
58
+ */
59
+ searchedEntries: Map<string, SearchResultEntry>;
60
+ /**
61
+ * each of those blocks' display name and description, from the catalog
62
+ */
63
+ blockText: Map<string, string>;
56
64
  /**
57
65
  * the blocks, named, searched or scaffoldable, whose package is not Core's
58
66
  */
@@ -100,6 +100,8 @@ const ALWAYS = new Set([...FRAME, ...FOUNDATION]);
100
100
  * @property {SearchResultEntry[]} domain
101
101
  * @property {string[]} kitBlocks the names of `blocks`
102
102
  * @property {BlockScore[]} searched every block search returned, in its order
103
+ * @property {Map<string, SearchResultEntry>} searchedEntries search's entry for each of those blocks (the first of a name)
104
+ * @property {Map<string, string>} blockText each of those blocks' display name and description, from the catalog
103
105
  * @property {string[]} foreign the blocks, named, searched or scaffoldable, whose package is not Core's
104
106
  */
105
107
 
@@ -273,6 +275,14 @@ export async function kitSignals(query, options = {}) {
273
275
  domain: domainKept,
274
276
  kitBlocks: blocksKept.map(r => r.name),
275
277
  searched: searchedBlocks.map(blockScore),
278
+ searchedEntries: new Map(
279
+ [...searchedBlocks].reverse().map(r => [r.name, r]),
280
+ ),
281
+ blockText: new Map(
282
+ templates.blocks
283
+ .filter(b => searchedBlocks.some(r => r.name === b.name))
284
+ .map(b => [b.name, `${b.displayName} ${b.description}`]),
285
+ ),
276
286
  foreign: [
277
287
  ...new Set(
278
288
  [...blocksKept, ...searchedBlocks, ...templates.blocks]
@@ -59,8 +59,8 @@ const PINNED = [
59
59
  [
60
60
  'analytics dashboard with a KPI row and a sortable table',
61
61
  [
62
- 'PaginationPageSize',
63
- 'GridDashboardLayout',
62
+ 'TableSortableTable',
63
+ 'TableRichCellTable',
64
64
  'TableBulkActionsTable',
65
65
  'TableGridDividersTable',
66
66
  'TableRowExpansionTable',
@@ -83,17 +83,17 @@ const PINNED = [
83
83
  'EmptyStateCompact',
84
84
  'EmptyStateContainer',
85
85
  'EmptyStateShowcase',
86
- 'ToolbarTableFilter',
86
+ 'BannerWithActionButton',
87
87
  ],
88
88
  ],
89
89
  [
90
90
  'login form with single sign-on buttons',
91
91
  [
92
+ 'DialogFormDialog',
92
93
  'CardWithInnerLayout',
93
- 'BottomSheetMobileKeyboard',
94
94
  'ButtonGroupBasic',
95
- 'CollapsibleControlledAccordion',
96
- 'BottomSheetSwitcherReviewFlow',
95
+ 'ToggleButtonGroup',
96
+ 'BannerWithActionButton',
97
97
  ],
98
98
  ],
99
99
  [
@@ -108,7 +108,7 @@ const PINNED = [
108
108
  ],
109
109
  [
110
110
  'kanban board for sprint tasks with a filter bar',
111
- ['ToolbarTableFilter', 'PowerSearchShowcase'],
111
+ ['ToolbarTableFilter', 'PowerSearchFullFeatured'],
112
112
  ],
113
113
  ];
114
114
 
@@ -166,12 +166,20 @@ describe('build tree', () => {
166
166
  expect(answer.data.start?.alternatives).toEqual(
167
167
  own.data.start?.alternatives,
168
168
  );
169
- // The picker only re-orders build's own blocks: each keeps build's
170
- // entry (its real score and reason), none is added, none is dropped.
169
+ // Every block is build's own entry or one search returned, with its real
170
+ // score and reason; never more blocks than build's own.
171
171
  expect(answer.data.blocks.length).toBe(own.data.blocks.length);
172
- for (const b of answer.data.blocks)
173
- expect(own.data.blocks.find(o => o.name === b.name)).toEqual(b);
172
+ for (const b of answer.data.blocks) {
173
+ expect(b.score).toBeGreaterThan(0);
174
+ expect(typeof b.reason).toBe('string');
175
+ const mine = own.data.blocks.find(o => o.name === b.name);
176
+ if (mine) expect(mine).toEqual(b);
177
+ }
174
178
  expect(answer.data.blocks.map(b => b.name)).toEqual(blocks);
179
+ // Never longer than build's own answer for the same request.
180
+ expect(Buffer.byteLength(JSON.stringify(answer))).toBeLessThanOrEqual(
181
+ Buffer.byteLength(JSON.stringify(own)),
182
+ );
175
183
  });
176
184
  }
177
185
  });
@@ -64,6 +64,7 @@ function writeIntegration(name, components, peers) {
64
64
  type: 'component',
65
65
  name: componentName,
66
66
  displayName: componentName,
67
+ import: `${name}/components/${componentName}`,
67
68
  ...(replaces ? {replaces} : {}),
68
69
  keywords: ['acme'],
69
70
  usage: {description: `${componentName} for Acme apps.`},
@@ -293,7 +293,7 @@ async function componentRead(name, options = {}) {
293
293
  const selectorList = Array.isArray(name) ? name : null;
294
294
  const noName = selectorList == null && !name;
295
295
 
296
- // Default detail level mirrors the CLI (see commands/component/index.mjs):
296
+ // Default detail level mirrors the CLI (see commands/component.mjs):
297
297
  // single-component views default to 'full', list-style views (--list,
298
298
  // --category, or no name) default to 'brief' (scannable name lists).
299
299
  // An explicit array remains a batch even when it is empty or a caller also
@@ -461,8 +461,22 @@ async function componentRead(name, options = {}) {
461
461
  return componentDetailBlocks(dirName, cwd, owner.package);
462
462
  }
463
463
  const loaded = await loadComponentDoc(owner.docPath, docOpts);
464
- // A family member an integration lists under its own name reads as that
465
- // member, the way a Core sub-component does below.
464
+ // A family member reads as that member, scoped the way the unscoped
465
+ // lookup scopes it: an integration member by its own entry, a Core
466
+ // sub-component (HStack in the Stack doc) by scopeSubComponent.
467
+ const sub =
468
+ scoped.kind === 'core'
469
+ ? scopeSubComponent(loaded, dirName, coreDir)
470
+ : null;
471
+ if (sub) {
472
+ if (props) {
473
+ return componentDetailProps(
474
+ {props: sub.matchingComponent.props},
475
+ owner.package,
476
+ );
477
+ }
478
+ return componentDetail(sub.scoped, owner, dirName, coreDir);
479
+ }
466
480
  const docs =
467
481
  scoped.kind === 'integration'
468
482
  ? scopeIntegrationMember(loaded, owner, dirName)
@@ -135,6 +135,21 @@ describe('component list — components whose docs live in a family folder', ()
135
135
  });
136
136
  }, SLOW);
137
137
 
138
+ it('answers a Core-scoped lookup of a member with that member, as the unscoped lookup does', async () => {
139
+ for (const name of ['HStack', 'VStack']) {
140
+ const unscoped = await component(name, {cwd});
141
+ const scoped = await component(name, {
142
+ cwd,
143
+ package: '@astryxdesign/core',
144
+ });
145
+ expect(scoped.data.name).toBe(name);
146
+ expect(scoped.data.parentDoc).toBe('Stack');
147
+ expect(scoped.data.import).toBe(`@astryxdesign/core/${name}`);
148
+ expect(scoped.data.props).toEqual(unscoped.data.props);
149
+ expect(scoped.data.props.length).toBeGreaterThan(0);
150
+ }
151
+ }, SLOW);
152
+
138
153
  it('prints each one\'s own import path in the list, the detail, and search', async () => {
139
154
  // The path `component <Name>` prints is the one docs and examples teach:
140
155
  // the component's own entry point, never its family's (/Stack, /Text) or
@@ -250,14 +250,14 @@ describe("a link in a guide's description, as the docs tree shows it", () => {
250
250
  'Document a theme by extending the core theme topic, so an app reads it in `astryx docs theme`.';
251
251
  const guide = /** @type {any} */ (
252
252
  await docs(
253
- 'cli/integrations/building-blocks/themes/document-the-theme',
253
+ 'authoring/building-blocks/themes/document-the-theme',
254
254
  undefined,
255
255
  {cwd: tmpDir, full: true},
256
256
  )
257
257
  );
258
258
  expect(guide.data.description).toBe(expected);
259
259
  const namespace = /** @type {any} */ (
260
- await docs('cli/integrations/building-blocks/themes', undefined, {
260
+ await docs('authoring/building-blocks/themes', undefined, {
261
261
  cwd: tmpDir,
262
262
  })
263
263
  );
@@ -43,12 +43,11 @@ export function hasSources(project: Project | undefined): boolean;
43
43
  * @param {Project | undefined} project
44
44
  * @param {Array<{name: string}>} installed
45
45
  * @param {Set<string>} declared
46
- * @param {(name: string, version?: string) => string} add
47
46
  * @returns {Promise<import('./discover.type.mjs').DiscoverAvailableEntry[]>}
48
47
  */
49
48
  export function computerAvailableEntries(project: Project | undefined, installed: Array<{
50
49
  name: string;
51
- }>, declared: Set<string>, add: (name: string, version?: string) => string): Promise<import("./discover.type.mjs").DiscoverAvailableEntry[]>;
50
+ }>, declared: Set<string>): Promise<import("./discover.type.mjs").DiscoverAvailableEntry[]>;
52
51
  /**
53
52
  * Package names the project's package.json declares in any dependency field.
54
53
  * @param {Project | undefined} project
@@ -25,6 +25,7 @@ import {
25
25
  availableComputerIntegrations,
26
26
  } from '../../foundation/config/project.mjs';
27
27
  import {isOutsideProject} from '../../foundation/env/project-scope.mjs';
28
+ import {projectAddCommand} from '../../foundation/release/notices.mjs';
28
29
  import {hostedRun} from '../../foundation/runtime/package-root.mjs';
29
30
  import {
30
31
  scanAllPackages,
@@ -274,17 +275,14 @@ const COMPUTER_SOURCE = 'installed for this computer';
274
275
  * @param {Project | undefined} project
275
276
  * @param {Array<{name: string}>} installed
276
277
  * @param {Set<string>} declared
277
- * @param {(name: string, version?: string) => string} add
278
278
  * @returns {Promise<import('./discover.type.mjs').DiscoverAvailableEntry[]>}
279
279
  */
280
- export async function computerAvailableEntries(
281
- project,
282
- installed,
283
- declared,
284
- add,
285
- ) {
280
+ export async function computerAvailableEntries(project, installed, declared) {
286
281
  const cwd = project?.cwd ?? process.cwd();
287
282
  if (isOutsideProject(cwd)) return [];
283
+ // The same command doctor names: in the project spec:AST-040 FR9 defines,
284
+ // and none where FR9 finds no project.
285
+ const add = projectAddCommand(cwd);
288
286
  const have = new Set([...installed.map(pkg => pkg.name), ...declared]);
289
287
  return (await availableComputerIntegrations(cwd, have)).map(c => ({
290
288
  name: c.name,
@@ -292,7 +290,7 @@ export async function computerAvailableEntries(
292
290
  ...(c.version ? {version: c.version} : {}),
293
291
  ...(c.description ? {description: c.description} : {}),
294
292
  source: COMPUTER_SOURCE,
295
- install: add(c.name),
293
+ ...(add ? {install: add(c.name)} : {}),
296
294
  }));
297
295
  }
298
296
 
@@ -223,7 +223,6 @@ export async function discover(query, options = {}) {
223
223
  project,
224
224
  packages,
225
225
  declared,
226
- add,
227
226
  );
228
227
  const fromSources = officialFirst(
229
228
  availableEntries(catalog, packages, declared, {
@@ -226,7 +226,7 @@ export function topicUp(entry: import("../../foundation/discovery/docs-discovery
226
226
  export function placeLinks(tree: DocsTree, node: TreeNode): import("./docs.type.mjs").DocsLinks;
227
227
  /**
228
228
  * The moves a topic read offers: from its place in the tree, where a guide
229
- * sits in its namespace and a flat topic in the Unorganized level.
229
+ * sits in its namespace and a flat topic in its topic level.
230
230
  * @param {DocsCatalog} catalog
231
231
  * @param {import('../../foundation/discovery/docs-discovery.mjs').DocsTopicEntry} entry
232
232
  * @returns {Promise<import('./docs.type.mjs').DocsLinks>}
@@ -290,7 +290,7 @@ export function holdsOwnName(tree: DocsTree, catalog: DocsCatalog, entry: import
290
290
  /**
291
291
  * The doc that took a flat topic's route in the docs tree, when it is not
292
292
  * that topic (spec:AST-046 FR11): the CLI keeps its routes, such as `cli`
293
- * and `unorganized`, and a namespace keeps its route over a topic of the same
293
+ * and `guides`, and a namespace keeps its route over a topic of the same
294
294
  * name. Null when the topic owns its route, or the tree has no node there.
295
295
  * @param {DocsTree} tree
296
296
  * @param {import('../../foundation/discovery/docs-discovery.mjs').DocsTopicEntry} entry