@astryxdesign/cli 0.7.4-canary.3f6ea7d → 0.7.4-canary.78641f8

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 (206) hide show
  1. package/README.md +63 -63
  2. package/api/component/_adapter.mjs +4 -3
  3. package/api/component/component.mjs +13 -6
  4. package/api/component/doc-links.test.mjs +33 -0
  5. package/api/docs/_adapter.d.mts +80 -0
  6. package/api/docs/_adapter.mjs +261 -11
  7. package/api/docs/detail/detail.mjs +8 -0
  8. package/api/docs/docOverlays.test.mjs +2 -1
  9. package/api/docs/docs.d.mts +16 -6
  10. package/api/docs/docs.doc.mjs +1 -1
  11. package/api/docs/docs.mjs +55 -6
  12. package/api/docs/docs.type.d.mts +28 -2
  13. package/api/docs/docs.type.mjs +13 -3
  14. package/api/docs/guide-route-targets.test.mjs +1002 -0
  15. package/api/docs/index/index.mjs +9 -0
  16. package/api/docs/integration-tree.test.mjs +22 -0
  17. package/api/docs/integrationDocs.test.mjs +85 -0
  18. package/api/docs/list/list.mjs +7 -1
  19. package/api/docs/node/node.mjs +9 -1
  20. package/api/docs/reference-blocks.test.mjs +1 -1
  21. package/api/doctor/built-checks.mjs +43 -13
  22. package/api/doctor/built-checks.test.mjs +29 -0
  23. package/api/doctor/doctor.doc.mjs +2 -2
  24. package/api/hook/list/list.d.mts +1 -1
  25. package/api/integration/_adapter.d.mts +11 -2
  26. package/api/integration/_adapter.mjs +30 -4
  27. package/api/integration/authoring-checks.mjs +29 -2
  28. package/api/integration/authoring-checks.test.mjs +131 -1
  29. package/api/integration/check/check.d.mts +4 -1
  30. package/api/integration/check/check.mjs +34 -4
  31. package/api/integration/check/check.test.mjs +49 -0
  32. package/api/integration/example-checks.no-npm.test.mjs +140 -0
  33. package/api/integration/example-checks.test.mjs +776 -0
  34. package/api/integration/integration-check.type.d.mts +8 -0
  35. package/api/integration/integration-check.type.mjs +4 -1
  36. package/api/integration/integrationCheck.doc.mjs +8 -1
  37. package/api/integration/integrationDocConflicts.doc.mjs +1 -1
  38. package/api/integration/pack-check.mjs +65 -1
  39. package/api/integration/pack-check.test.mjs +63 -0
  40. package/api/integration/validate-integration-case-disk.test.mjs +14 -2
  41. package/api/integration/validate-integration-gaps.test.mjs +43 -19
  42. package/api/integration/validate-integration.mjs +112 -14
  43. package/api/integration/validate-integration.type.d.mts +23 -4
  44. package/api/integration/validate-integration.type.mjs +14 -5
  45. package/api/integration/validateIntegration.doc.mjs +1 -1
  46. package/api/search/_candidate-score.d.mts +9 -3
  47. package/api/search/_candidate-score.mjs +90 -3
  48. package/api/search/_gather-components.mjs +48 -1
  49. package/api/search/_gather-docs.mjs +12 -2
  50. package/api/search/_lexical.d.mts +12 -0
  51. package/api/search/_lexical.mjs +3 -0
  52. package/api/search/_priority.mjs +5 -2
  53. package/api/search/_score.d.mts +2 -1
  54. package/api/search/_score.mjs +4 -3
  55. package/api/search/search.doc.mjs +1 -1
  56. package/api/search/search.family-members.test.mjs +124 -0
  57. package/api/search/search.family-word.test.mjs +146 -0
  58. package/api/search/search.mjs +28 -0
  59. package/api/template/template-suffix.test.mjs +26 -0
  60. package/api/theme/themeBuild.doc.mjs +1 -1
  61. package/api/theme/themeList.doc.mjs +1 -1
  62. package/api/theme/themeTargets.doc.mjs +1 -1
  63. package/assets/discover/official-packages.json +16 -0
  64. package/assets/docs/author-a-theme.doc.mjs +15 -15
  65. package/assets/docs/browser-support.doc.mjs +1 -1
  66. package/assets/docs/getting-started.doc.mjs +16 -16
  67. package/assets/docs/is-my-code-good.doc.mjs +6 -6
  68. package/assets/docs/styling-overview.doc.mjs +5 -5
  69. package/assets/docs/theme.doc.mjs +5 -5
  70. package/assets/docs/tree/add-a-component.doc.mjs +1 -1
  71. package/assets/docs/tree/add-a-theme.doc.mjs +2 -2
  72. package/assets/docs/tree/add-a-topic.doc.mjs +6 -6
  73. package/assets/docs/tree/agent-guidance.doc.mjs +5 -5
  74. package/assets/docs/tree/authoring.doc.mjs +2 -2
  75. package/assets/docs/tree/block-template.doc.mjs +1 -1
  76. package/assets/docs/tree/check-the-props.doc.mjs +3 -3
  77. package/assets/docs/tree/check-your-docs.doc.mjs +6 -6
  78. package/assets/docs/tree/checks.doc.mjs +11 -11
  79. package/assets/docs/tree/ci-and-containers.doc.mjs +1 -1
  80. package/assets/docs/tree/cli-command.doc.mjs +6 -6
  81. package/assets/docs/tree/codemods.doc.mjs +7 -7
  82. package/assets/docs/tree/component-family.doc.mjs +1 -1
  83. package/assets/docs/tree/component-imports.doc.mjs +2 -2
  84. package/assets/docs/tree/component-lookups.doc.mjs +6 -5
  85. package/assets/docs/tree/computer-agent-guide.doc.mjs +7 -7
  86. package/assets/docs/tree/computer-integrations.doc.mjs +5 -5
  87. package/assets/docs/tree/debug-and-gap-reports.doc.mjs +3 -3
  88. package/assets/docs/tree/define-the-theme.doc.mjs +1 -1
  89. package/assets/docs/tree/describe-the-component.doc.mjs +1 -1
  90. package/assets/docs/tree/doc-syntax.doc.mjs +219 -0
  91. package/assets/docs/tree/export-template-assets.doc.mjs +1 -1
  92. package/assets/docs/tree/extend-or-replace.doc.mjs +39 -7
  93. package/assets/docs/tree/font-setup.doc.mjs +1 -1
  94. package/assets/docs/tree/generate-a-palette.doc.mjs +1 -1
  95. package/assets/docs/tree/global-integrations.doc.mjs +11 -11
  96. package/assets/docs/tree/global.doc.mjs +2 -2
  97. package/assets/docs/tree/host-entry.doc.mjs +1 -1
  98. package/assets/docs/tree/install-once.doc.mjs +4 -4
  99. package/assets/docs/tree/layout.doc.mjs +1 -1
  100. package/assets/docs/tree/links.doc.mjs +2 -2
  101. package/assets/docs/tree/migration-setup.doc.mjs +15 -15
  102. package/assets/docs/tree/migration.doc.mjs +2 -1
  103. package/assets/docs/tree/other-libraries.doc.mjs +1 -1
  104. package/assets/docs/tree/page-template.doc.mjs +2 -2
  105. package/assets/docs/tree/problems.doc.mjs +8 -8
  106. package/assets/docs/tree/project-global-or-both.doc.mjs +2 -2
  107. package/assets/docs/tree/publishing.doc.mjs +7 -7
  108. package/assets/docs/tree/quick-start.doc.mjs +9 -9
  109. package/assets/docs/tree/reference.doc.mjs +2 -2
  110. package/assets/docs/tree/replace-a-core-component.doc.mjs +1 -1
  111. package/assets/docs/tree/replace-a-core-template.doc.mjs +4 -4
  112. package/assets/docs/tree/scaffold.doc.mjs +1 -1
  113. package/assets/docs/tree/sections-and-placement.doc.mjs +3 -3
  114. package/assets/docs/tree/see-it-in-an-app.doc.mjs +3 -3
  115. package/assets/docs/tree/short-and-findable.doc.mjs +3 -3
  116. package/assets/docs/tree/single-component.doc.mjs +4 -4
  117. package/assets/docs/tree/start-a-template.doc.mjs +5 -5
  118. package/assets/docs/tree/styling-advanced.doc.mjs +1 -1
  119. package/assets/docs/tree/styling-libraries.doc.mjs +2 -1
  120. package/assets/docs/tree/styling.doc.mjs +1 -1
  121. package/assets/docs/tree/tailwind.doc.mjs +1 -1
  122. package/assets/docs/tree/test-in-an-app.doc.mjs +5 -5
  123. package/assets/docs/tree/test-template-in-app.doc.mjs +6 -6
  124. package/assets/docs/tree/tokens-and-setup.doc.mjs +1 -1
  125. package/assets/docs/tree/troubleshooting.doc.mjs +24 -20
  126. package/assets/docs/tree/uninstall.doc.mjs +2 -2
  127. package/assets/docs/tree/updates.doc.mjs +1 -1
  128. package/assets/docs/tree/upgrading.doc.mjs +3 -3
  129. package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +1 -1
  130. package/assets/docs/tree/verify-packed-template.doc.mjs +3 -3
  131. package/assets/docs/tree/versioning.doc.mjs +4 -4
  132. package/assets/docs/tree/who-answers.doc.mjs +4 -4
  133. package/assets/docs/tree/write-the-template-file.doc.mjs +4 -4
  134. package/assets/docs/use-a-theme.doc.mjs +10 -10
  135. package/assets/docs/use-integrations.doc.mjs +1 -1
  136. package/assets/docs/working-with-ai.doc.mjs +15 -15
  137. package/assets/templates/themes/butter/butterPaletteRefs.generated.ts +54 -0
  138. package/assets/templates/themes/butter/butterPalettes.generated.receipt.json +1499 -0
  139. package/assets/templates/themes/butter/butterPalettes.generated.ts +550 -0
  140. package/assets/templates/themes/butter/butterTheme.ts +274 -234
  141. package/assets/templates/themes/butter/palette.config.json +484 -0
  142. package/assets/templates/themes/matcha/matchaPaletteRefs.generated.ts +51 -0
  143. package/assets/templates/themes/matcha/matchaPalettes.generated.receipt.json +1502 -0
  144. package/assets/templates/themes/matcha/matchaPalettes.generated.ts +501 -0
  145. package/assets/templates/themes/matcha/matchaPalettes.ts +21 -0
  146. package/assets/templates/themes/matcha/matchaTheme.ts +164 -103
  147. package/assets/templates/themes/matcha/palette.config.json +448 -0
  148. package/assets/templates/themes/y2k/palette.config.json +166 -0
  149. package/assets/templates/themes/y2k/y2kPaletteRefs.generated.ts +54 -0
  150. package/assets/templates/themes/y2k/y2kPalettes.generated.receipt.json +872 -0
  151. package/assets/templates/themes/y2k/y2kPalettes.generated.ts +550 -0
  152. package/assets/templates/themes/y2k/y2kPalettes.ts +257 -0
  153. package/assets/templates/themes/y2k/y2kTheme.ts +164 -391
  154. package/authoring/codemod/codemod.doc.mjs +1 -1
  155. package/authoring/config/config.doc.mjs +4 -4
  156. package/authoring/debug/parse.d.mts +1 -1
  157. package/authoring/discover/discover.doc.mjs +1 -1
  158. package/authoring/doctypes/_schema.d.mts +4 -0
  159. package/authoring/doctypes/_schema.mjs +4 -0
  160. package/authoring/doctypes/reference/type.ts +14 -2
  161. package/authoring/gap-report/gap-report.doc.mjs +1 -1
  162. package/authoring/integration/integration.doc.mjs +6 -6
  163. package/clients/cli/commands/docs.doc.mjs +1 -1
  164. package/clients/cli/commands/docs.mjs +27 -2
  165. package/clients/cli/commands/docs.test.mjs +1 -1
  166. package/clients/cli/commands/doctor-integration-docs.doc.mjs +1 -1
  167. package/clients/cli/commands/doctor.doc.mjs +1 -1
  168. package/clients/cli/commands/doctor.mjs +12 -1
  169. package/clients/cli/commands/integration-check.doc.mjs +11 -0
  170. package/clients/cli/commands/integration-check.test.mjs +36 -3
  171. package/clients/cli/commands/integration-pack.doc.mjs +1 -1
  172. package/clients/cli/commands/integration-verify.doc.mjs +1 -1
  173. package/clients/cli/commands/integration.mjs +15 -3
  174. package/clients/cli/commands/theme-targets.doc.mjs +1 -1
  175. package/clients/cli/commands/upgrade.doc.mjs +2 -2
  176. package/clients/cli/lib/define-command.mjs +5 -3
  177. package/foundation/agent-docs/agent-docs.d.mts +14 -2
  178. package/foundation/agent-docs/agent-docs.mjs +65 -4
  179. package/foundation/agent-docs/agent-docs.test.mjs +107 -0
  180. package/foundation/discovery/docs-discovery.d.mts +93 -2
  181. package/foundation/discovery/docs-discovery.mjs +237 -8
  182. package/foundation/discovery/runner-allowlist.d.mts +2 -0
  183. package/foundation/discovery/runner-allowlist.mjs +4 -0
  184. package/foundation/discovery/runner-commands.d.mts +29 -13
  185. package/foundation/discovery/runner-commands.mjs +253 -17
  186. package/foundation/discovery/stray-pointers.mjs +11 -5
  187. package/foundation/discovery/stray-pointers.test.mjs +6 -0
  188. package/foundation/discovery/template-adapter.mjs +11 -0
  189. package/foundation/doc-compiler/compile.mjs +8 -1
  190. package/foundation/doc-compiler/doc-loads.test.mjs +7 -0
  191. package/foundation/doc-compiler/doc-syntax.d.mts +194 -0
  192. package/foundation/doc-compiler/doc-syntax.mjs +739 -0
  193. package/foundation/doc-compiler/doc-syntax.test.mjs +383 -0
  194. package/foundation/doc-compiler/links.d.mts +13 -16
  195. package/foundation/doc-compiler/links.mjs +40 -7
  196. package/foundation/doc-compiler/tree.d.mts +5 -0
  197. package/foundation/doc-compiler/tree.mjs +9 -0
  198. package/foundation/env/package-manager.d.mts +18 -0
  199. package/foundation/env/package-manager.mjs +40 -0
  200. package/foundation/integrations/cli-requirement.d.mts +29 -0
  201. package/foundation/integrations/cli-requirement.mjs +47 -0
  202. package/foundation/integrations/cli-requirement.test.mjs +23 -2
  203. package/foundation/integrations/validate-contributions.d.mts +53 -0
  204. package/foundation/integrations/validate-contributions.mjs +788 -0
  205. package/foundation/response/response-types.doc.mjs +6 -6
  206. package/package.json +9 -9
@@ -35,6 +35,15 @@ export async function index(topic, options = {}) {
35
35
  ...view,
36
36
  // A guide the docs tree places is read by its route, not its doc name.
37
37
  name: entry.tree ? entry.name : view.name,
38
+ // What it took the place of, and whose that was (INV28).
39
+ ...(entry.replaces != null
40
+ ? {
41
+ replaces: entry.replaces,
42
+ ...(entry.replacedPackage != null
43
+ ? {replacedPackage: entry.replacedPackage}
44
+ : {}),
45
+ }
46
+ : {}),
38
47
  // Each section names the package that wrote it: the topic's own, or an
39
48
  // extension's.
40
49
  sections: view.sections.map(s => ({
@@ -189,6 +189,28 @@ describe('integration docs in the docs tree', () => {
189
189
  ).toEqual(['acme/setup', 'acme/deploy']);
190
190
  }, SLOW);
191
191
 
192
+ it('renders a placed guide summary once, so an escaped token stays written', async () => {
193
+ scaffold({
194
+ ...kit(),
195
+ 'deploy.doc.mjs': guide('deploy', {
196
+ description: 'Show the syntax {@@pm run build} beside {@pm run build}.',
197
+ placement: {parent: 'namespace:acme', slot: 'guides', order: 2},
198
+ }),
199
+ });
200
+ const top = await docs('acme', undefined, {cwd: tmpDir});
201
+ const deploy = top.data.slots[0].children.find((/** @type {any} */ c) => c.route === 'acme/deploy');
202
+ expect(deploy.summary).toMatch(/^Show the syntax \{@pm run build\} beside `\S+ run build`\.$/);
203
+ }, SLOW);
204
+
205
+ it('renders a flat topic summary once, so an escaped token stays written', async () => {
206
+ scaffold({
207
+ ...kit(),
208
+ 'notes.doc.mjs': {...kit()['notes.doc.mjs'], description: 'Show the syntax {@@pm run build} beside {@pm run build}.'},
209
+ });
210
+ const listed = await docs('guides', undefined, {cwd: tmpDir});
211
+ expect(JSON.stringify(listed.data)).toContain('Show the syntax {@pm run build} beside `');
212
+ }, SLOW);
213
+
192
214
  it('reads a placed guide one level at a time, with its links resolved', async () => {
193
215
  scaffold(kit());
194
216
  const index = await docs('acme/setup', undefined, {cwd: tmpDir, index: true});
@@ -164,6 +164,46 @@ describe('integration-contributed topics', () => {
164
164
  expect(prose).not.toContain('{@link');
165
165
  }, SLOW);
166
166
 
167
+ it('renders a linked component or template summary once, so an escaped token stays written', async () => {
168
+ scaffold({
169
+ 'using-widgets.doc.mjs': topic({
170
+ name: 'using-widgets',
171
+ title: 'Using widgets',
172
+ sections: [
173
+ {
174
+ title: 'Overview',
175
+ content: [
176
+ {type: 'reference', target: 'component:AcmeButton'},
177
+ {type: 'reference', target: 'block:acme-card'},
178
+ ],
179
+ },
180
+ ],
181
+ }),
182
+ });
183
+ const pkgDir = path.join(tmpDir, 'node_modules', '@acme', 'widgets');
184
+ fs.writeFileSync(
185
+ path.join(pkgDir, 'astryx.integration.mjs'),
186
+ "export default {components: './components', templates: './templates', docs: './docs'};\n",
187
+ );
188
+ fs.mkdirSync(path.join(pkgDir, 'components'));
189
+ fs.writeFileSync(
190
+ path.join(pkgDir, 'components', 'AcmeButton.doc.mjs'),
191
+ "export default {type: 'component', name: 'AcmeButton', displayName: 'Acme Button', description: 'Shows {@@pm run build}.', props: []};\n",
192
+ );
193
+ fs.writeFileSync(path.join(pkgDir, 'components', 'AcmeButton.tsx'), 'export function AcmeButton() { return null; }\n');
194
+ fs.mkdirSync(path.join(pkgDir, 'templates'));
195
+ fs.writeFileSync(
196
+ path.join(pkgDir, 'templates', 'acme-card.doc.mjs'),
197
+ "export default {type: 'block', name: 'Acme card', description: 'Card for {@@pm run build}.'};\n",
198
+ );
199
+ fs.writeFileSync(path.join(pkgDir, 'templates', 'acme-card.tsx'), 'export default function Fixture() { return null; }\n');
200
+
201
+ const detail = await docs('using-widgets', undefined, {cwd: tmpDir, full: true});
202
+ const text = JSON.stringify(detail.data);
203
+ expect(text).toContain('Shows {@pm run build}.');
204
+ expect(text).toContain('Card for {@pm run build}.');
205
+ }, SLOW);
206
+
167
207
  it('selects Core in a link only where the bare name would open something else', async () => {
168
208
  const core = await discoverCoreTemplates();
169
209
  const page = core.find(template => template.type === 'page')?.dirName;
@@ -459,3 +499,48 @@ describe('integration-contributed topics', () => {
459
499
  expect(catalog.resolve('deploying')).toBeUndefined();
460
500
  }, SLOW);
461
501
  });
502
+
503
+ describe('doc tokens in a contributed topic', () => {
504
+ it(
505
+ 'render in the list, the read and search, for the project the read is about',
506
+ async () => {
507
+ scaffold({
508
+ 'deploying.doc.mjs': topic({
509
+ description:
510
+ 'Install with {@pm install @acme/widgets}, then run {@command doctor}.',
511
+ sections: [
512
+ {
513
+ title: 'Overview',
514
+ content: [{type: 'prose', text: 'Run {@command doctor} first.'}],
515
+ },
516
+ ],
517
+ }),
518
+ });
519
+ // The project in tmpDir uses Bun; the process's own folder uses pnpm.
520
+ fs.writeFileSync(path.join(tmpDir, 'bun.lock'), '{}\n');
521
+
522
+ const listed = await docs(undefined, undefined, {cwd: tmpDir});
523
+ const entry = listed.data.find(t => t.topic === 'deploying');
524
+ expect(entry.description).toBe(
525
+ 'Install with `bun add @acme/widgets`, then run `astryx doctor`.',
526
+ );
527
+ const detail = await docs('deploying', undefined, {
528
+ cwd: tmpDir,
529
+ full: true,
530
+ });
531
+ expect(JSON.stringify(detail)).not.toContain('{@');
532
+ expect(detail.data.sections[0].content[0].text).toBe(
533
+ 'Run `astryx doctor` first.',
534
+ );
535
+ // Core's own docs show tokens as written on purpose; this topic's render.
536
+ const found = await search('deploying', {cwd: tmpDir, type: 'doc'});
537
+ const hit = found.data.results.find(
538
+ (/** @type {any} */ result) => result.name === 'deploying',
539
+ );
540
+ expect(hit.description).toBe(
541
+ 'Install with `bun add @acme/widgets`, then run `astryx doctor`.',
542
+ );
543
+ },
544
+ SLOW,
545
+ );
546
+ });
@@ -52,7 +52,13 @@ export async function list({cwd} = {}) {
52
52
  ),
53
53
  package: entry.package,
54
54
  };
55
- if (entry.replaces != null) listed.replaces = entry.replaces;
55
+ if (entry.replaces != null) {
56
+ listed.replaces = entry.replaces;
57
+ // INV28: the package whose topic it replaced, beside its own.
58
+ if (entry.replacedPackage != null) {
59
+ listed.replacedPackage = entry.replacedPackage;
60
+ }
61
+ }
56
62
  entries.push(listed);
57
63
  }
58
64
  // The docs tree's top-level namespaces, the CLI's and each integration's,
@@ -94,7 +94,15 @@ function childIdentity(child) {
94
94
  return {
95
95
  route: child.route,
96
96
  name: child.route.slice(child.route.lastIndexOf('/') + 1),
97
- package: child.provider,
97
+ package: child.guideOverlay?.replacement?.package ?? child.provider,
98
+ // A guide an integration's doc took the place of names whose it was.
99
+ ...(child.guideOverlay?.replacement
100
+ ? {
101
+ replaces: child.route,
102
+ replacedPackage:
103
+ child.guideOverlay.replacedPackage ?? child.provider,
104
+ }
105
+ : {}),
98
106
  kind: child.kind,
99
107
  title: child.title,
100
108
  summary: child.summary,
@@ -259,7 +259,7 @@ describe('a reference block in a topic section', () => {
259
259
  /^docs\(\): Read the reference docs: .* Read it with `astryx docs cli\/api\/functions\/docs`\.$/,
260
260
  );
261
261
  expect(more[1].text).toMatch(
262
- /^Theme System: .* Read it with `astryx docs theme`\.$/,
262
+ /^Theming: .* Read it with `astryx docs theme`\.$/,
263
263
  );
264
264
  },
265
265
  SLOW,
@@ -9,7 +9,7 @@
9
9
  * built `.html` page or a source file), and the package names whose
10
10
  * components count as Astryx: every `@astryxdesign/*` package and each
11
11
  * integration the project loads (its component catalog's providers).
12
- * @output `built-astryx-usage`: fails when the path holds no import from those
12
+ * @output `built-astryx-usage`: fails when the path holds no value import from those
13
13
  * packages, no use of a component imported from them, and no Astryx
14
14
  * stylesheet in built CSS or HTML. `built-astryx-purity`: warns with the
15
15
  * findings of the source check in `astryx docs is-my-code-good` (raw
@@ -323,12 +323,17 @@ function astImports(ast) {
323
323
  /** @type {{spec: string, names: string[], at: number}[]} */
324
324
  const found = [];
325
325
  for (const node of ast.program.body) {
326
+ // A type-only import or re-export is erased from the built page, so it
327
+ // is not Astryx use.
328
+ if (node.importKind === 'type' || node.exportKind === 'type') continue;
326
329
  if (node.type === 'ImportDeclaration') {
330
+ const values = node.specifiers.filter(
331
+ (/** @type {any} */ each) => each.importKind !== 'type',
332
+ );
333
+ if (node.specifiers.length > 0 && values.length === 0) continue;
327
334
  found.push({
328
335
  spec: node.source.value,
329
- names: node.specifiers.map(
330
- (/** @type {any} */ each) => each.local.name,
331
- ),
336
+ names: values.map((/** @type {any} */ each) => each.local.name),
332
337
  at: node.start,
333
338
  });
334
339
  } else if (
@@ -336,6 +341,15 @@ function astImports(ast) {
336
341
  node.type === 'ExportAllDeclaration') &&
337
342
  node.source
338
343
  ) {
344
+ const specifiers = node.specifiers ?? [];
345
+ if (
346
+ specifiers.length > 0 &&
347
+ specifiers.every(
348
+ (/** @type {any} */ each) => each.exportKind === 'type',
349
+ )
350
+ ) {
351
+ continue;
352
+ }
339
353
  found.push({spec: node.source.value, names: [], at: node.start});
340
354
  }
341
355
  }
@@ -406,14 +420,26 @@ function importsOf(text) {
406
420
  /** @type {{spec: string, names: string[], at: number}[]} */
407
421
  const found = [];
408
422
  const fromImport =
409
- /\bimport\s+(?:type\s+)?([^'";]*?)\s+from\s+['"]([^'"]+)['"]|\bimport\s+['"]([^'"]+)['"]/g;
423
+ /\bimport\s+(type\s+)?([^'";]*?)\s+from\s+['"]([^'"]+)['"]|\bimport\s+['"]([^'"]+)['"]/g;
424
+ /** Whether every name in a `{…}` list is marked `type`. */
425
+ const allTypes = (/** @type {string} */ list) => {
426
+ const parts = list
427
+ .split(',')
428
+ .map(part => part.trim())
429
+ .filter(Boolean);
430
+ return parts.length > 0 && parts.every(part => /^type\s/.test(part));
431
+ };
410
432
  for (const match of text.matchAll(fromImport)) {
411
433
  const at = /** @type {number} */ (match.index);
412
- if (match[3]) {
413
- found.push({spec: match[3], names: [], at});
434
+ if (match[4]) {
435
+ found.push({spec: match[4], names: [], at});
414
436
  continue;
415
437
  }
416
- const clause = match[1];
438
+ // A type-only import is erased from the build, so it is not use.
439
+ if (match[1]) continue;
440
+ const clause = match[2];
441
+ const onlyBraces = /^\{([\s\S]*)\}$/.exec(clause.trim());
442
+ if (onlyBraces && allTypes(onlyBraces[1])) continue;
417
443
  /** @type {string[]} */
418
444
  const names = [];
419
445
  const braces = /\{([\s\S]*)\}/.exec(clause);
@@ -433,14 +459,18 @@ function importsOf(text) {
433
459
  const name = part.trim().replace(/^\*\s+as\s+/, '');
434
460
  if (/^[A-Za-z_$][\w$]*$/.test(name)) names.push(name);
435
461
  }
436
- found.push({spec: match[2], names, at});
462
+ found.push({spec: match[3], names, at});
437
463
  }
438
- // A barrel that re-exports a package reaches it as an import does.
464
+ // A barrel that re-exports a package reaches it as an import does; a
465
+ // type-only re-export is erased like a type-only import.
439
466
  for (const match of text.matchAll(
440
- /\bexport\s+(?:type\s+)?(?:\*(?:\s+as\s+[\w$]+)?|\{[^}]*\})\s*from\s+['"]([^'"]+)['"]/g,
467
+ /\bexport\s+(type\s+)?(\*(?:\s+as\s+[\w$]+)?|\{[^}]*\})\s*from\s+['"]([^'"]+)['"]/g,
441
468
  )) {
469
+ if (match[1]) continue;
470
+ const list = /^\{([\s\S]*)\}$/.exec(match[2]);
471
+ if (list && allTypes(list[1])) continue;
442
472
  found.push({
443
- spec: match[1],
473
+ spec: match[3],
444
474
  names: [],
445
475
  at: /** @type {number} */ (match.index),
446
476
  });
@@ -738,7 +768,7 @@ export function checkBuilt(target, {cwd, packages}) {
738
768
  id: 'built-astryx-usage',
739
769
  label: 'Built output uses Astryx',
740
770
  status: 'fail',
741
- message: `Read ${read}: no import from an Astryx package, no Astryx component, and no Astryx styles, so this output does not use Astryx.`,
771
+ message: `Read ${read}: no value import from an Astryx package (a type-only import is erased from the build), no Astryx component, and no Astryx styles, so this output does not use Astryx.`,
742
772
  fix: `Rebuild the page from an Astryx template: run \`${formatCliCommand('build "<what the page is>"', cwd)}\`, scaffold the template it names, and fill it with Astryx components. Do not deliver this output.`,
743
773
  };
744
774
  const unreadNames =
@@ -425,6 +425,35 @@ describe('--built edge cases', () => {
425
425
  expect(check('dist').usage.status).toBe('fail');
426
426
  });
427
427
 
428
+ it('does not count a type-only Astryx import as use', () => {
429
+ write({
430
+ 'src/Page.tsx': [
431
+ "import type {ButtonProps} from '@astryxdesign/core/Button';",
432
+ "import {type TextProps} from '@astryxdesign/core/Text';",
433
+ "export type {CardProps} from '@astryxdesign/core/Card';",
434
+ "export {type BadgeProps} from '@astryxdesign/core/Badge';",
435
+ 'export const Page = (props: ButtonProps & TextProps) => null;',
436
+ '',
437
+ ].join('\n'),
438
+ });
439
+ expect(check('src').usage.status).toBe('fail');
440
+ });
441
+
442
+ it('does not count a type-only import in a file the parser cannot read', () => {
443
+ write({
444
+ 'src/Broken.tsx': [
445
+ "import type {ButtonProps} from '@astryxdesign/core/Button';",
446
+ "import {type TextProps} from '@astryxdesign/core/Text';",
447
+ "export type {CardProps} from '@astryxdesign/core/Card';",
448
+ "export {type BadgeProps} from '@astryxdesign/core/Badge';",
449
+ 'export const B = () => <div>{</div>;',
450
+ '@@ enum ;',
451
+ '',
452
+ ].join('\n'),
453
+ });
454
+ expect(check('src').usage.status).not.toBe('pass');
455
+ });
456
+
428
457
  it('does not count an import written only in a string or JSX text', () => {
429
458
  write({
430
459
  'src/Page.tsx': [
@@ -24,7 +24,7 @@ export const doc = {
24
24
  'integration provider identity and contribution issues, agent docs, the ' +
25
25
  'detected package manager, and the health of the docs the CLI reads (authoring ' +
26
26
  'and CLI docs, the docs tree, doc size), and returns a structured ' +
27
- 'report. Theme checks run when the generated app module exists; without one, doctor reports that the CLI manages no themes and names theme add. Earlier descriptor-less copies are a non-failing upgrade warning. It never installs, writes, or mutates. It imports astryx.config, executes every added theme source while validating private inputs, and loads every recorded built theme module to prove its runtime imports work, including themes from installed packages. Local theme source also runs during build-freshness checks. Stylesheets are parsed without execution. Config and theme top-level code therefore run, so use doctor only with project code you trust. Outside a project it checks the computer instead: the Node version (`node-version`), the release that answered (`answering-release`), the newest release the computer knows of (`newest-release`), the astryx commands on the search path (`cli-on-path`), the integrations installed for the computer (`computer-integrations`: each one used outside a project, and a warning for one skipped because its peer range excludes the answering release or that fails to load), and the computer-level agent text (`computer-agent-text`): present and matching this release, present but different, edited, absent, or turned off, and where it is linked, with `astryx init --user` as the fix for the stale and absent cases. The agent-text check is always info. The newest-release check also runs inside a project: it names a newer release when the computer knows of one; inside a project whose release is older it names the install and upgrade commands; outside one, when the CLI installed for the computer is older, it names the command of the package manager that installed it, after the Node the newest release needs when the computer runs an older one. It is always info and installs nothing. The `cli-on-path` check also runs inside a project: it lists every astryx command on the search path in order, passes when the first is a release that hands each project run to the release of that project, and warns when the first is another program or a release that predates the hand-off, naming `npm i -g @astryxdesign/cli@latest`. Inside a project, `computer-integrations` lists, as info, the integrations installed for the computer that the project does not install, with its install command; they are not used there. It never fails a check because the folder has no project, and installs nothing.' +
27
+ 'report. Theme checks run when the generated app module exists; without one, doctor reports that the CLI manages no themes and names theme add. Earlier descriptor-less copies are a non-failing upgrade warning. It never installs, writes, or mutates. It imports astryx.config, executes every added theme source while validating private inputs, and loads every recorded built theme module to prove its runtime imports work, including themes from installed packages. Local theme source also runs during build-freshness checks. Stylesheets are parsed without execution. Config and theme top-level code therefore run, so use doctor only with project code you trust. Outside a project it checks the computer instead: the Node version (`node-version`), the release that answered (`answering-release`), the newest release the computer knows of (`newest-release`), the astryx commands on the search path (`cli-on-path`), the integrations installed for the computer (`computer-integrations`: each one used outside a project, and a warning for one skipped because its peer range excludes the answering release or that fails to load), and the computer-level agent text (`computer-agent-text`): present and matching this release, present but different, edited, absent, or turned off, and where it is linked, with `{@command init --user}` as the fix for the stale and absent cases. The agent-text check is always info. The newest-release check also runs inside a project: it names a newer release when the computer knows of one; inside a project whose release is older it names the install and upgrade commands; outside one, when the CLI installed for the computer is older, it names the command of the package manager that installed it, after the Node the newest release needs when the computer runs an older one. It is always info and installs nothing. The `cli-on-path` check also runs inside a project: it lists every astryx command on the search path in order, passes when the first is a release that hands each project run to the release of that project, and warns when the first is another program or a release that predates the hand-off, naming `{@pm install @astryxdesign/cli@latest --global}`. Inside a project, `computer-integrations` lists, as info, the integrations installed for the computer that the project does not install, with its install command; they are not used there. It never fails a check because the folder has no project, and installs nothing.' +
28
28
  ' In global mode: with `cwd` outside a project, it checks the computer instead (the Node version, the version that answered, the newest version it knows of, the astryx commands on the search path, the integrations installed globally, and the agent guide for the computer) and never fails a check because the folder has no project. See {@link namespace:global} and {@link generic:who-answers}.',
29
29
  importPath: '@astryxdesign/cli/api',
30
30
  signature: 'doctor(options?: DoctorOptions): Promise<DoctorResponse>',
@@ -41,7 +41,7 @@ export const doc = {
41
41
  name: 'options.built',
42
42
  type: 'string',
43
43
  description:
44
- 'A finished build to check before you deliver it: a project folder, a build output folder, or one built `.html` file, relative to `cwd`. Adds two checks after the others. `built-astryx-usage` fails when the path holds no import from an Astryx package (any `@astryxdesign/*` package or an integration the project installs), no component imported from one, and no Astryx styles in built CSS or HTML. `built-astryx-purity` warns with the source check of `astryx docs is-my-code-good`: raw elements Astryx has a component for, raw SVG and icon-library icons, inline styles, classes, `stylex.create` and imported stylesheets, each with its file and line, in `.tsx` and `.jsx` files and JSX in `.js` source, found by parsing it; it is info, not inspected, when the path holds no source with JSX, such as a bundle. It reads at most 20,000 files, each up to 5 MB, skipping installs and version control; when either limit leaves source unread and nothing was found, the purity check is info, not fully inspected, and when the file limit ends the read before any Astryx turns up, `built-astryx-usage` warns that the rest went unread instead of failing. Given one built `.html` file, it also reads the local stylesheets and scripts that page links, finding a root-relative link from the nearest folder above the page that holds it; a linked file that is not there makes `built-astryx-usage` warn instead of fail. An empty folder fails with nothing checked, like a missing path. A source tree counts as using Astryx through an import, a re-export (`export … from`) or a stylesheet `@import` of an Astryx package. `--built` goes with `doctor` alone; a `doctor integration` check refuses it. A path that does not exist fails `built-astryx-usage` with nothing checked, and the purity check is left out. The integrations that count are the dependencies the nearest package.json above the path declares whose installed copy, found the way the CLI autolinks (a hoisted workspace copy included), has an integration manifest. The files under the path, and that configuration, are only read, never run. Without it, doctor runs exactly as before.',
44
+ 'A finished build to check before you deliver it: a project folder, a build output folder, or one built `.html` file, relative to `cwd`. Adds two checks after the others. `built-astryx-usage` fails when the path holds no value import from an Astryx package (any `@astryxdesign/*` package or an integration the project installs), no component imported from one, and no Astryx styles in built CSS or HTML. `built-astryx-purity` warns with the source check of `astryx docs is-my-code-good`: raw elements Astryx has a component for, raw SVG and icon-library icons, inline styles, classes, `stylex.create` and imported stylesheets, each with its file and line, in `.tsx` and `.jsx` files and JSX in `.js` source, found by parsing it; it is info, not inspected, when the path holds no source with JSX, such as a bundle. It reads at most 20,000 files, each up to 5 MB, skipping installs and version control; when either limit leaves source unread and nothing was found, the purity check is info, not fully inspected, and when the file limit ends the read before any Astryx turns up, `built-astryx-usage` warns that the rest went unread instead of failing. Given one built `.html` file, it also reads the local stylesheets and scripts that page links, finding a root-relative link from the nearest folder above the page that holds it; a linked file that is not there makes `built-astryx-usage` warn instead of fail. An empty folder fails with nothing checked, like a missing path. A source tree counts as using Astryx through an import, a re-export (`export … from`) or a stylesheet `@import` of an Astryx package; a type-only import or re-export (`import type`, `export type`, or a list whose names are all `type`) does not count, since the build erases it. `--built` goes with `doctor` alone; a `doctor integration` check refuses it. A path that does not exist fails `built-astryx-usage` with nothing checked, and the purity check is left out. The integrations that count are the dependencies the nearest package.json above the path declares whose installed copy, found the way the CLI autolinks (a hoisted workspace copy included), has an integration manifest. The files under the path, and that configuration, are only read, never run. Without it, doctor runs exactly as before.',
45
45
  },
46
46
  ],
47
47
  returns: [
@@ -13,7 +13,7 @@
13
13
  export function list({ cwd, category, detail, zh, lang, }?: {
14
14
  cwd?: string | undefined;
15
15
  category?: string | undefined;
16
- detail?: "names" | "compact" | "full" | "brief" | undefined;
16
+ detail?: "compact" | "full" | "names" | "brief" | undefined;
17
17
  zh?: boolean | undefined;
18
18
  lang?: string | null | undefined;
19
19
  }): Promise<import("../hook.type.mjs").HookListResponse>;
@@ -41,13 +41,22 @@ export function integrationFluff(discovered: Parameters<typeof findFluff>[0]): P
41
41
  */
42
42
  export function integrationStrayPointers(discovered: Parameters<typeof findStrayPointers>[0], integration?: any): Promise<import("./authoring-checks.type.mjs").StrayPointer[]>;
43
43
  /**
44
- * Each Astryx command a package's topics write with a package runner. A
44
+ * What each doc in one integration's docs replaces or extends, read against
45
+ * the CLI's docs and the package's own (see `packageDocTargets`); empty when
46
+ * the docs do not load, which other checks report.
47
+ * @param {any} integration a loaded integration
48
+ * @returns {Promise<import('../docs/_adapter.mjs').DocTarget[]>}
49
+ */
50
+ export function integrationDocTargets(integration: any): Promise<import("../docs/_adapter.mjs").DocTarget[]>;
51
+ /**
52
+ * The doc-syntax findings in a package's topics: commands written with a
53
+ * runner, for one package manager, or bare, and tokens that do not parse. A
45
54
  * package whose topics cannot be discovered has none here: the other checks
46
55
  * report topics that do not load.
47
56
  * @param {any} integration a loaded integration
48
57
  * @returns {Promise<import('../../foundation/discovery/runner-commands.mjs').RunnerCommand[]>}
49
58
  */
50
- export function integrationRunnerCommands(integration: any): Promise<import("../../foundation/discovery/runner-commands.mjs").RunnerCommand[]>;
59
+ export function integrationDocCommands(integration: any): Promise<import("../../foundation/discovery/runner-commands.mjs").RunnerCommand[]>;
51
60
  import { findCopiedPassages } from '../../foundation/discovery/copied-passages.mjs';
52
61
  import { findFluff } from '../../foundation/discovery/doc-fluff.mjs';
53
62
  import { findStrayPointers } from '../../foundation/discovery/stray-pointers.mjs';
@@ -16,10 +16,11 @@ import {
16
16
  integrationSourceForDoc,
17
17
  } from '../../foundation/discovery/component-discovery.mjs';
18
18
  import {discoverIntegrationDocs} from '../../foundation/discovery/docs-discovery.mjs';
19
+ import {packageDocTargets} from '../docs/_adapter.mjs';
19
20
  import {comparePropDocs} from '../../foundation/discovery/prop-drift.mjs';
20
21
  import {findCopiedPassages} from '../../foundation/discovery/copied-passages.mjs';
21
22
  import {findFluff} from '../../foundation/discovery/doc-fluff.mjs';
22
- import {findRunnerCommands} from '../../foundation/discovery/runner-commands.mjs';
23
+ import {findDocCommands} from '../../foundation/discovery/runner-commands.mjs';
23
24
  import {findStrayPointers} from '../../foundation/discovery/stray-pointers.mjs';
24
25
 
25
26
  /**
@@ -115,18 +116,43 @@ export async function integrationStrayPointers(discovered, integration) {
115
116
  }
116
117
 
117
118
  /**
118
- * Each Astryx command a package's topics write with a package runner. A
119
+ * What each doc in one integration's docs replaces or extends, read against
120
+ * the CLI's docs and the package's own (see `packageDocTargets`); empty when
121
+ * the docs do not load, which other checks report.
122
+ * @param {any} integration a loaded integration
123
+ * @returns {Promise<import('../docs/_adapter.mjs').DocTarget[]>}
124
+ */
125
+ export async function integrationDocTargets(integration) {
126
+ let discovered;
127
+ try {
128
+ discovered = await discoverIntegrationDocs(integration);
129
+ } catch {
130
+ return [];
131
+ }
132
+ // A doc that does not load is an issue already; its targets are not read.
133
+ if (discovered.errors.length > 0) return [];
134
+ try {
135
+ return await packageDocTargets(integration, discovered);
136
+ } catch {
137
+ // A package whose docs cannot form a tree is reported by the docs check.
138
+ return [];
139
+ }
140
+ }
141
+
142
+ /**
143
+ * The doc-syntax findings in a package's topics: commands written with a
144
+ * runner, for one package manager, or bare, and tokens that do not parse. A
119
145
  * package whose topics cannot be discovered has none here: the other checks
120
146
  * report topics that do not load.
121
147
  * @param {any} integration a loaded integration
122
148
  * @returns {Promise<import('../../foundation/discovery/runner-commands.mjs').RunnerCommand[]>}
123
149
  */
124
- export async function integrationRunnerCommands(integration) {
150
+ export async function integrationDocCommands(integration) {
125
151
  let discovered;
126
152
  try {
127
153
  discovered = await discoverIntegrationDocs(integration);
128
154
  } catch {
129
155
  return [];
130
156
  }
131
- return findRunnerCommands(discovered);
157
+ return findDocCommands(discovered);
132
158
  }
@@ -22,6 +22,7 @@ import path from 'node:path';
22
22
  import {getCliInvocation} from '../../foundation/env/package-manager.mjs';
23
23
  import {
24
24
  packageComponentLinkProblems,
25
+ packageDocTargets,
25
26
  packageDocsProblems,
26
27
  packageReferenceProblems,
27
28
  } from '../docs/_adapter.mjs';
@@ -38,8 +39,10 @@ import {
38
39
  integrationStrayPointers,
39
40
  } from './_adapter.mjs';
40
41
  import {
42
+ BUILTIN_DOCS_PACKAGE,
41
43
  discoverBuiltinTopics,
42
44
  discoverIntegrationDocs,
45
+ isGuideRoute,
43
46
  } from '../../foundation/discovery/docs-discovery.mjs';
44
47
  import {
45
48
  applyTemplateReplacements,
@@ -489,11 +492,14 @@ export async function integrationDocConflicts(pkg, options = {}) {
489
492
  });
490
493
  }
491
494
 
492
- // An extension never owns its own name. A replacement does, so it may only
493
- // reuse a Core name when that is the Core topic it explicitly replaces.
495
+ // An extension never owns its own name, and neither does a doc that
496
+ // replaces a guide by its route: readers open the route. A topic
497
+ // replacement does, so it may only reuse a Core name when that is the
498
+ // Core topic it explicitly replaces.
494
499
  if (
495
500
  sameNameCore != null &&
496
501
  record.extendsTopic == null &&
502
+ !isGuideRoute(record.replaces) &&
497
503
  replacedCore !== sameNameCore
498
504
  ) {
499
505
  findings.push({
@@ -507,6 +513,27 @@ export async function integrationDocConflicts(pkg, options = {}) {
507
513
  });
508
514
  }
509
515
  }
516
+ // A doc that replaces or extends one of the CLI's guides by its route is
517
+ // as intentional as one that names a Core topic.
518
+ if (errors.length === 0) {
519
+ for (const target of await packageDocTargets(
520
+ /** @type {{name: string}} */ (docsIntegration),
521
+ discovered,
522
+ )) {
523
+ if (target.kind !== 'guide' || target.owner !== BUILTIN_DOCS_PACKAGE) {
524
+ continue;
525
+ }
526
+ // A route the guide moved from names the guide at its route now.
527
+ const route = target.guide ?? target.target;
528
+ findings.push({
529
+ topic: target.topic,
530
+ severity: 'info',
531
+ relationship: target.relationship,
532
+ coreTopic: route,
533
+ message: `Intentional ${target.relationship === 'replaces' ? 'override' : 'extension'}: "${target.topic}" ${target.relationship} the CLI guide "${route}".`,
534
+ });
535
+ }
536
+ }
510
537
  findings.sort((a, b) =>
511
538
  `${a.topic}:${a.relationship}`.localeCompare(
512
539
  `${b.topic}:${b.relationship}`,