@astryxdesign/cli 0.7.4-canary.3f6ea7d → 0.7.4-canary.626f01e

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 (200) 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/integration-check.type.d.mts +8 -0
  33. package/api/integration/integration-check.type.mjs +4 -1
  34. package/api/integration/integrationCheck.doc.mjs +8 -1
  35. package/api/integration/integrationDocConflicts.doc.mjs +1 -1
  36. package/api/integration/pack-check.mjs +65 -1
  37. package/api/integration/pack-check.test.mjs +63 -0
  38. package/api/integration/validate-integration-case-disk.test.mjs +2 -0
  39. package/api/integration/validate-integration-gaps.test.mjs +7 -4
  40. package/api/integration/validate-integration.mjs +96 -14
  41. package/api/integration/validate-integration.type.d.mts +10 -4
  42. package/api/integration/validate-integration.type.mjs +10 -5
  43. package/api/integration/validateIntegration.doc.mjs +1 -1
  44. package/api/search/_candidate-score.d.mts +9 -3
  45. package/api/search/_candidate-score.mjs +90 -3
  46. package/api/search/_gather-components.mjs +48 -1
  47. package/api/search/_gather-docs.mjs +12 -2
  48. package/api/search/_lexical.d.mts +12 -0
  49. package/api/search/_lexical.mjs +3 -0
  50. package/api/search/_priority.mjs +5 -2
  51. package/api/search/_score.d.mts +2 -1
  52. package/api/search/_score.mjs +4 -3
  53. package/api/search/search.doc.mjs +1 -1
  54. package/api/search/search.family-members.test.mjs +124 -0
  55. package/api/search/search.family-word.test.mjs +146 -0
  56. package/api/search/search.mjs +28 -0
  57. package/api/theme/themeBuild.doc.mjs +1 -1
  58. package/api/theme/themeList.doc.mjs +1 -1
  59. package/api/theme/themeTargets.doc.mjs +1 -1
  60. package/assets/discover/official-packages.json +16 -0
  61. package/assets/docs/author-a-theme.doc.mjs +15 -15
  62. package/assets/docs/browser-support.doc.mjs +1 -1
  63. package/assets/docs/getting-started.doc.mjs +16 -16
  64. package/assets/docs/is-my-code-good.doc.mjs +6 -6
  65. package/assets/docs/styling-overview.doc.mjs +5 -5
  66. package/assets/docs/theme.doc.mjs +5 -5
  67. package/assets/docs/tree/add-a-component.doc.mjs +1 -1
  68. package/assets/docs/tree/add-a-theme.doc.mjs +2 -2
  69. package/assets/docs/tree/add-a-topic.doc.mjs +6 -6
  70. package/assets/docs/tree/agent-guidance.doc.mjs +5 -5
  71. package/assets/docs/tree/authoring.doc.mjs +2 -2
  72. package/assets/docs/tree/block-template.doc.mjs +1 -1
  73. package/assets/docs/tree/check-the-props.doc.mjs +3 -3
  74. package/assets/docs/tree/check-your-docs.doc.mjs +6 -6
  75. package/assets/docs/tree/checks.doc.mjs +11 -11
  76. package/assets/docs/tree/ci-and-containers.doc.mjs +1 -1
  77. package/assets/docs/tree/cli-command.doc.mjs +6 -6
  78. package/assets/docs/tree/codemods.doc.mjs +7 -7
  79. package/assets/docs/tree/component-family.doc.mjs +1 -1
  80. package/assets/docs/tree/component-imports.doc.mjs +2 -2
  81. package/assets/docs/tree/component-lookups.doc.mjs +6 -5
  82. package/assets/docs/tree/computer-agent-guide.doc.mjs +7 -7
  83. package/assets/docs/tree/computer-integrations.doc.mjs +5 -5
  84. package/assets/docs/tree/debug-and-gap-reports.doc.mjs +3 -3
  85. package/assets/docs/tree/define-the-theme.doc.mjs +1 -1
  86. package/assets/docs/tree/describe-the-component.doc.mjs +1 -1
  87. package/assets/docs/tree/doc-syntax.doc.mjs +219 -0
  88. package/assets/docs/tree/export-template-assets.doc.mjs +1 -1
  89. package/assets/docs/tree/extend-or-replace.doc.mjs +39 -7
  90. package/assets/docs/tree/font-setup.doc.mjs +1 -1
  91. package/assets/docs/tree/generate-a-palette.doc.mjs +1 -1
  92. package/assets/docs/tree/global-integrations.doc.mjs +11 -11
  93. package/assets/docs/tree/global.doc.mjs +2 -2
  94. package/assets/docs/tree/host-entry.doc.mjs +1 -1
  95. package/assets/docs/tree/install-once.doc.mjs +4 -4
  96. package/assets/docs/tree/layout.doc.mjs +1 -1
  97. package/assets/docs/tree/links.doc.mjs +2 -2
  98. package/assets/docs/tree/migration-setup.doc.mjs +15 -15
  99. package/assets/docs/tree/migration.doc.mjs +2 -1
  100. package/assets/docs/tree/other-libraries.doc.mjs +1 -1
  101. package/assets/docs/tree/page-template.doc.mjs +2 -2
  102. package/assets/docs/tree/problems.doc.mjs +8 -8
  103. package/assets/docs/tree/project-global-or-both.doc.mjs +2 -2
  104. package/assets/docs/tree/publishing.doc.mjs +7 -7
  105. package/assets/docs/tree/quick-start.doc.mjs +9 -9
  106. package/assets/docs/tree/reference.doc.mjs +2 -2
  107. package/assets/docs/tree/replace-a-core-component.doc.mjs +1 -1
  108. package/assets/docs/tree/replace-a-core-template.doc.mjs +4 -4
  109. package/assets/docs/tree/scaffold.doc.mjs +1 -1
  110. package/assets/docs/tree/sections-and-placement.doc.mjs +3 -3
  111. package/assets/docs/tree/see-it-in-an-app.doc.mjs +3 -3
  112. package/assets/docs/tree/short-and-findable.doc.mjs +3 -3
  113. package/assets/docs/tree/single-component.doc.mjs +4 -4
  114. package/assets/docs/tree/start-a-template.doc.mjs +5 -5
  115. package/assets/docs/tree/styling-advanced.doc.mjs +1 -1
  116. package/assets/docs/tree/styling-libraries.doc.mjs +2 -1
  117. package/assets/docs/tree/styling.doc.mjs +1 -1
  118. package/assets/docs/tree/tailwind.doc.mjs +1 -1
  119. package/assets/docs/tree/test-in-an-app.doc.mjs +5 -5
  120. package/assets/docs/tree/test-template-in-app.doc.mjs +6 -6
  121. package/assets/docs/tree/tokens-and-setup.doc.mjs +1 -1
  122. package/assets/docs/tree/troubleshooting.doc.mjs +24 -20
  123. package/assets/docs/tree/uninstall.doc.mjs +2 -2
  124. package/assets/docs/tree/updates.doc.mjs +1 -1
  125. package/assets/docs/tree/upgrading.doc.mjs +3 -3
  126. package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +1 -1
  127. package/assets/docs/tree/verify-packed-template.doc.mjs +3 -3
  128. package/assets/docs/tree/versioning.doc.mjs +4 -4
  129. package/assets/docs/tree/who-answers.doc.mjs +4 -4
  130. package/assets/docs/tree/write-the-template-file.doc.mjs +4 -4
  131. package/assets/docs/use-a-theme.doc.mjs +10 -10
  132. package/assets/docs/use-integrations.doc.mjs +1 -1
  133. package/assets/docs/working-with-ai.doc.mjs +15 -15
  134. package/assets/templates/themes/butter/butterPaletteRefs.generated.ts +54 -0
  135. package/assets/templates/themes/butter/butterPalettes.generated.receipt.json +1499 -0
  136. package/assets/templates/themes/butter/butterPalettes.generated.ts +550 -0
  137. package/assets/templates/themes/butter/butterTheme.ts +274 -234
  138. package/assets/templates/themes/butter/palette.config.json +484 -0
  139. package/assets/templates/themes/matcha/matchaPaletteRefs.generated.ts +51 -0
  140. package/assets/templates/themes/matcha/matchaPalettes.generated.receipt.json +1502 -0
  141. package/assets/templates/themes/matcha/matchaPalettes.generated.ts +501 -0
  142. package/assets/templates/themes/matcha/matchaPalettes.ts +21 -0
  143. package/assets/templates/themes/matcha/matchaTheme.ts +164 -103
  144. package/assets/templates/themes/matcha/palette.config.json +448 -0
  145. package/assets/templates/themes/y2k/palette.config.json +166 -0
  146. package/assets/templates/themes/y2k/y2kPaletteRefs.generated.ts +54 -0
  147. package/assets/templates/themes/y2k/y2kPalettes.generated.receipt.json +872 -0
  148. package/assets/templates/themes/y2k/y2kPalettes.generated.ts +550 -0
  149. package/assets/templates/themes/y2k/y2kPalettes.ts +257 -0
  150. package/assets/templates/themes/y2k/y2kTheme.ts +164 -391
  151. package/authoring/codemod/codemod.doc.mjs +1 -1
  152. package/authoring/config/config.doc.mjs +4 -4
  153. package/authoring/debug/parse.d.mts +1 -1
  154. package/authoring/discover/discover.doc.mjs +1 -1
  155. package/authoring/doctypes/_schema.d.mts +4 -0
  156. package/authoring/doctypes/_schema.mjs +4 -0
  157. package/authoring/doctypes/reference/type.ts +14 -2
  158. package/authoring/gap-report/gap-report.doc.mjs +1 -1
  159. package/authoring/integration/integration.doc.mjs +6 -6
  160. package/clients/cli/commands/docs.doc.mjs +1 -1
  161. package/clients/cli/commands/docs.mjs +27 -2
  162. package/clients/cli/commands/docs.test.mjs +1 -1
  163. package/clients/cli/commands/doctor-integration-docs.doc.mjs +1 -1
  164. package/clients/cli/commands/doctor.doc.mjs +1 -1
  165. package/clients/cli/commands/doctor.mjs +2 -1
  166. package/clients/cli/commands/integration-check.doc.mjs +11 -0
  167. package/clients/cli/commands/integration-check.test.mjs +36 -3
  168. package/clients/cli/commands/integration-pack.doc.mjs +1 -1
  169. package/clients/cli/commands/integration-verify.doc.mjs +1 -1
  170. package/clients/cli/commands/integration.mjs +15 -3
  171. package/clients/cli/commands/theme-targets.doc.mjs +1 -1
  172. package/clients/cli/commands/upgrade.doc.mjs +2 -2
  173. package/clients/cli/lib/define-command.mjs +5 -3
  174. package/foundation/agent-docs/agent-docs.d.mts +14 -2
  175. package/foundation/agent-docs/agent-docs.mjs +65 -4
  176. package/foundation/agent-docs/agent-docs.test.mjs +107 -0
  177. package/foundation/discovery/docs-discovery.d.mts +93 -2
  178. package/foundation/discovery/docs-discovery.mjs +237 -8
  179. package/foundation/discovery/runner-allowlist.d.mts +2 -0
  180. package/foundation/discovery/runner-allowlist.mjs +4 -0
  181. package/foundation/discovery/runner-commands.d.mts +29 -13
  182. package/foundation/discovery/runner-commands.mjs +253 -17
  183. package/foundation/discovery/stray-pointers.mjs +11 -5
  184. package/foundation/discovery/stray-pointers.test.mjs +6 -0
  185. package/foundation/doc-compiler/compile.mjs +8 -1
  186. package/foundation/doc-compiler/doc-loads.test.mjs +3 -0
  187. package/foundation/doc-compiler/doc-syntax.d.mts +194 -0
  188. package/foundation/doc-compiler/doc-syntax.mjs +739 -0
  189. package/foundation/doc-compiler/doc-syntax.test.mjs +383 -0
  190. package/foundation/doc-compiler/links.d.mts +13 -16
  191. package/foundation/doc-compiler/links.mjs +40 -7
  192. package/foundation/doc-compiler/tree.d.mts +5 -0
  193. package/foundation/doc-compiler/tree.mjs +9 -0
  194. package/foundation/env/package-manager.d.mts +18 -0
  195. package/foundation/env/package-manager.mjs +40 -0
  196. package/foundation/integrations/cli-requirement.d.mts +29 -0
  197. package/foundation/integrations/cli-requirement.mjs +47 -0
  198. package/foundation/integrations/cli-requirement.test.mjs +23 -2
  199. package/foundation/response/response-types.doc.mjs +6 -6
  200. package/package.json +9 -9
@@ -37,7 +37,10 @@ import {assertWithin} from '../../foundation/fs/path-safety.mjs';
37
37
  import {normalizeProviderId} from '../../foundation/identity/provider-identity.mjs';
38
38
  import {integrationDocTypes} from '../docs/_adapter.mjs';
39
39
  import {integrationDocConsistency} from '../../foundation/discovery/doc-consistency.mjs';
40
- import {integrationRunnerCommands} from './_adapter.mjs';
40
+ import {
41
+ integrationDocCommands,
42
+ integrationDocTargets,
43
+ } from './_adapter.mjs';
41
44
  import {
42
45
  THEME_SLUG_RE,
43
46
  unreadThemeFolders,
@@ -77,6 +80,15 @@ import {runChoice} from '../../foundation/release/run-context.mjs';
77
80
  /** The running CLI is outside the package's `@astryxdesign/cli` peer range. */
78
81
  const CLI_PEER_VERSION = 'cli_peer_version';
79
82
 
83
+ /** A doc replaces or extends a name that holds no topic and no guide. */
84
+ const DOC_TARGET_NOT_FOUND = 'doc_target_not_found';
85
+
86
+ /** An extension section's `before` or `after` names no section of the base. */
87
+ const DOC_SECTION_UNPLACED = 'doc_section_unplaced';
88
+
89
+ /** Two docs of one package replace one guide; only the last one is read. */
90
+ const DUPLICATE_GUIDE_REPLACEMENT = 'duplicate_guide_replacement';
91
+
80
92
  export {validateLoadedIntegration, isListedIssue};
81
93
 
82
94
  /**
@@ -477,8 +489,11 @@ async function validateAtPackageDir(
477
489
  const publicImports = await publicImportIssues(packageDir, loaded);
478
490
  issues.push(...publicImports.issues);
479
491
  // Each finding is a note until the next minor makes it a warning.
492
+ // Listed now, a warning from the next minor release: `next`.
480
493
  if (publicImports.notes.length > 0)
481
- (result.notes ??= []).push(...publicImports.notes);
494
+ (result.notes ??= []).push(
495
+ ...publicImports.notes.map(note => ({...note, next: true})),
496
+ );
482
497
  result.publicImports = publicImports.report;
483
498
  if (scanUnreachable) {
484
499
  issues.push(
@@ -686,23 +701,78 @@ export async function validateInstalledIntegration(spec, cwd = process.cwd()) {
686
701
  }
687
702
 
688
703
  /**
689
- * The runner-command notes for a package's topics: each Astryx command a topic
690
- * writes with a package runner, where the doc file is, and the bare command to
691
- * write.
704
+ * The doc-syntax notes for a package's topics: each command a topic writes
705
+ * with a runner (`runner_command`), for one package manager
706
+ * (`package_manager_command`), or bare (`plain_command`), and each token that
707
+ * does not parse (`doc_token`), with the file, line and what to write
708
+ * instead. The next minor release turns them into warnings: `next`.
692
709
  * @param {any} integration a loaded integration
693
- * @returns {Promise<Array<{code: string, message: string}>>}
710
+ * @returns {Promise<Array<{code: string, message: string, next: true}>>}
694
711
  */
695
- async function runnerCommandNotes(integration) {
712
+ async function docCommandNotes(integration) {
696
713
  const packageDir = integration.__packageDir;
697
- return (await integrationRunnerCommands(integration)).map(each => ({
698
- code: 'runner_command',
714
+ return (await integrationDocCommands(integration)).map(each => ({
715
+ code: each.code,
699
716
  message:
700
717
  typeof packageDir === 'string'
701
718
  ? `${path.relative(packageDir, each.file).split(path.sep).join('/')}: ${each.message}`
702
719
  : each.message,
720
+ next: true,
703
721
  }));
704
722
  }
705
723
 
724
+ /**
725
+ * The notes for docs that replace or extend a topic or a guide the docs tree
726
+ * places, or place an extension's section with `before` or `after`: a name
727
+ * that holds neither (such as a namespace) applies nothing, and a key that
728
+ * names no section adds the section at the end. Each is listed, failing nothing, until
729
+ * the next minor release (architecture:cli-surface INV35).
730
+ * @param {any} integration a loaded integration
731
+ * @returns {Promise<Array<{code: string, message: string}>>}
732
+ */
733
+ async function docTargetNotes(integration) {
734
+ /** @type {Array<{code: string, message: string}>} */
735
+ const notes = [];
736
+ const targets = await integrationDocTargets(integration);
737
+ /** @type {Map<string, string[]>} lowercased route → the docs replacing it */
738
+ const replacers = new Map();
739
+ for (const each of targets) {
740
+ if (each.kind !== 'guide' || each.relationship !== 'replaces') continue;
741
+ // An old route and the new one name one guide.
742
+ const key = each.guide ?? each.target.toLowerCase();
743
+ replacers.set(key, [...(replacers.get(key) ?? []), each.topic]);
744
+ }
745
+ for (const [route, topics] of replacers) {
746
+ if (topics.length < 2) continue;
747
+ notes.push({
748
+ code: DUPLICATE_GUIDE_REPLACEMENT,
749
+ message: `"${topics.join('", "')}" all replace the guide "${route}", and only the last, "${topics.at(-1)}", is read. Fix: keep one replacement, or make the others extend it.`,
750
+ });
751
+ }
752
+ for (const each of targets) {
753
+ if (each.kind === 'namespace') {
754
+ const shown = each.guidesBelow.slice(0, 8);
755
+ const more = each.guidesBelow.length - shown.length;
756
+ notes.push({
757
+ code: DOC_TARGET_NOT_FOUND,
758
+ message: `"${each.topic}" ${each.relationship} "${each.target}", which is a namespace of the docs tree: it holds no sections to ${each.relationship === 'replaces' ? 'replace' : 'extend'}, so this changes nothing. Fix: name the route of a guide below it${shown.length > 0 ? `: ${shown.join(', ')}${more > 0 ? `, and ${more} more` : ''}` : ''}.`,
759
+ });
760
+ } else if (each.kind == null) {
761
+ notes.push({
762
+ code: DOC_TARGET_NOT_FOUND,
763
+ message: `"${each.topic}" ${each.relationship} "${each.target}", which is neither a topic nor a guide of the CLI's docs or this package's own: it changes nothing unless an app also installs a package that provides it. Fix: if it should name one of those, name a topic as \`${formatCliCommand('docs')}\` lists it, or a guide's route as \`${formatCliCommand('docs authoring --depth all')}\` or \`${formatCliCommand('docs cli --depth all')}\` lists it.`,
764
+ });
765
+ }
766
+ for (const {section, field, key} of each.unplaced) {
767
+ notes.push({
768
+ code: DOC_SECTION_UNPLACED,
769
+ message: `Section "${section}" of "${each.topic}" goes ${field} "${key}", which is no section of "${each.guide ?? each.target}", so it is added at the end. Fix: use a key \`${formatCliCommand(`docs ${each.guide ?? each.target} --index`)}\` lists.`,
770
+ });
771
+ }
772
+ }
773
+ return notes;
774
+ }
775
+
706
776
  /**
707
777
  * Unified entry: validate the LOCAL integration (no `pkg`) or an INSTALLED one
708
778
  * (`pkg` given) and return the `integration.validate` envelope. The no-manifest
@@ -743,20 +813,32 @@ export async function validateIntegration(pkg, options = {}) {
743
813
  // after the last minor release, each with its fix in the message, which
744
814
  // may not fail `--strict` until the next (architecture:cli-surface INV35):
745
815
  // the layout findings and the component names judged wrong.
816
+ // A finding the next minor release turns into a warning is marked `next`:
817
+ // `integration check --strict --next` fails on it today.
746
818
  const notes = result.found
747
819
  ? [
748
- ...(result.notes ?? []),
820
+ // A malformed cliCommand fails --strict from the next minor
821
+ // (spec:AST-081 FR5).
822
+ ...(result.notes ?? []).map(note =>
823
+ note.code === INVALID_CLI_COMMAND ? {...note, next: true} : note,
824
+ ),
749
825
  ...(result.listed ?? []).map(issue => ({
750
826
  code: issue.code,
751
827
  message: issue.message,
828
+ next: true,
752
829
  })),
753
- ...(names ?? []).flatMap(each => each.notes),
830
+ ...(names ?? []).flatMap(each =>
831
+ each.notes.map(note => ({...note, next: true})),
832
+ ),
754
833
  ]
755
834
  : [];
756
- // Each Astryx command a topic writes with a package runner, as a
757
- // `runner_command` note with its fix, the same way.
835
+ // The doc-syntax findings in the package's topics, as `next` notes with
836
+ // their fixes, the same way.
758
837
  if (integration?.docs) {
759
- notes.push(...(await runnerCommandNotes(integration)));
838
+ notes.push(...(await docCommandNotes(integration)));
839
+ notes.push(
840
+ ...(await docTargetNotes(integration)).map(note => ({...note, next: true})),
841
+ );
760
842
  }
761
843
  return {
762
844
  type: 'integration.validate',
@@ -36,8 +36,11 @@ export type ValidateIntegrationOptions = {
36
36
  export type ValidateIntegrationResponse = {
37
37
  type: "integration.validate";
38
38
  /**
39
- * `notes`: information beside the issues that fails nothing, such as
40
- * `invalid_cli_command`, a `cliCommand` that was ignored as malformed;
39
+ * `notes`: information beside the issues. A note fails nothing by default;
40
+ * one with `next: true` counts as a warning under `integration check
41
+ * --next`, fails `integration check --strict --next`, and fails `--strict`
42
+ * from the next minor release. Notes include `invalid_cli_command`, a
43
+ * `cliCommand` that was ignored as malformed;
41
44
  * `cli_peer_version`, the running CLI outside the package's
42
45
  * `@astryxdesign/cli` peer range; and
43
46
  * the package layout findings added after the last minor release, each with
@@ -50,8 +53,10 @@ export type ValidateIntegrationResponse = {
50
53
  * still pair (`source_without_component_doc`); `doc_name_mismatch` and
51
54
  * `unknown_block_component` (see `docNames` and `blockComponents`); and
52
55
  * since 0.7.3 each public-import finding; they become warnings in the next
53
- * minor release; and `runner_command`, an Astryx command a topic writes
54
- * with a package runner
56
+ * minor release; and, for the commands a topic writes, `runner_command`
57
+ * (written with a package runner), `plain_command` (written bare),
58
+ * `package_manager_command` (written for one package manager) and
59
+ * `doc_token` (a token that does not parse), each with the token to write
55
60
  */
56
61
  data: {
57
62
  validated: boolean;
@@ -61,6 +66,7 @@ export type ValidateIntegrationResponse = {
61
66
  notes?: Array<{
62
67
  code: string;
63
68
  message: string;
69
+ next?: boolean;
64
70
  }>;
65
71
  docTypes?: DocTypesReport;
66
72
  docNames?: DocNamesReport;
@@ -39,9 +39,12 @@
39
39
  * "healthy" — the two are otherwise byte-identical.
40
40
  * @typedef {object} ValidateIntegrationResponse
41
41
  * @property {'integration.validate'} type
42
- * @property {{validated: boolean, name: string | null, version: string | null, issues: import('../../foundation/integrations/issue').AstryxIntegrationIssue[], notes?: Array<{code: string, message: string}>, docTypes?: DocTypesReport, docNames?: DocNamesReport, blockComponents?: BlockComponentsReport, publicImports?: PublicImportsReport}} data
43
- * `notes`: information beside the issues that fails nothing, such as
44
- * `invalid_cli_command`, a `cliCommand` that was ignored as malformed;
42
+ * @property {{validated: boolean, name: string | null, version: string | null, issues: import('../../foundation/integrations/issue').AstryxIntegrationIssue[], notes?: Array<{code: string, message: string, next?: boolean}>, docTypes?: DocTypesReport, docNames?: DocNamesReport, blockComponents?: BlockComponentsReport, publicImports?: PublicImportsReport}} data
43
+ * `notes`: information beside the issues. A note fails nothing by default;
44
+ * one with `next: true` counts as a warning under `integration check
45
+ * --next`, fails `integration check --strict --next`, and fails `--strict`
46
+ * from the next minor release. Notes include `invalid_cli_command`, a
47
+ * `cliCommand` that was ignored as malformed;
45
48
  * `cli_peer_version`, the running CLI outside the package's
46
49
  * `@astryxdesign/cli` peer range; and
47
50
  * the package layout findings added after the last minor release, each with
@@ -54,8 +57,10 @@
54
57
  * still pair (`source_without_component_doc`); `doc_name_mismatch` and
55
58
  * `unknown_block_component` (see `docNames` and `blockComponents`); and
56
59
  * since 0.7.3 each public-import finding; they become warnings in the next
57
- * minor release; and `runner_command`, an Astryx command a topic writes
58
- * with a package runner
60
+ * minor release; and, for the commands a topic writes, `runner_command`
61
+ * (written with a package runner), `plain_command` (written bare),
62
+ * `package_manager_command` (written for one package manager) and
63
+ * `doc_token` (a token that does not parse), each with the token to write
59
64
  */
60
65
 
61
66
  /**
@@ -62,7 +62,7 @@ export const doc = {
62
62
  {
63
63
  type: 'integration.validate',
64
64
  description:
65
- "The result envelope: `data.validated`, false when nothing was validated — with no `package.json` at all, `data.issues` carries one `no_package` error-severity issue so the command exits 1; with a `package.json` but no integration manifest, `data.issues` is empty, which means \"not looked at\", not \"healthy\"; `data.name` and `data.version` of the validated package (both null when `data.validated` is false; `data.name` is `(local package)` when the local package.json has no readable name), plus `data.issues`, an AstryxIntegrationIssue[] of {code, severity: `warning` | `error`, message, fix?, file?, line?}: `fix` is the change that resolves the issue, and `file` and `line` where it is, relative to the package, when the check knows them; and `data.notes` when there are any: {code, message} information that fails nothing, such as `invalid_cli_command` for a `cliCommand` that was ignored as malformed 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 `name` or `version`), `no_provider_id`, and `source_without_component_doc` for a doc whose file name differs from its source only in letter case where the two still pair; and `doc_name_mismatch` and `unknown_block_component` (see `docNames` and `blockComponents`); they become warnings in the next minor release. A `runner_command` note lists each Astryx command a topic writes with a package runner, with its file, line and the bare command to write. When the manifest loads, `data.docTypes` holds the doc type check: `status` (`checked` | `skipped`), `reason` when skipped, `typescript`, `docs` (doc values checked), `findings` ({doc, line, export, type, field, problem: `unknown_field` | `missing_field` | `wrong_type`, severity: `warning`, message, fix}), `unchecked` ({doc, reason}: a doc that could not be fully checked, or a root its reader cannot read), and `fixtures` when the components or docs root holds test fixture docs under `__tests__`: how many, none of them checked. When the manifest loads, `data.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, `data.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 a note in `data.notes`, its fix inside the message, listed only: it does not fail this command or `integration check --strict`, and fails `--strict` from the next minor release. The codes are `component_import_not_exported`, `component_import_other_package`, `component_import_missing_name`, `example_import_not_exported`, `example_import_missing_name`, `template_import_not_exported`, `template_import_outside_root`, `template_private_import`, `template_import_missing_name` and `template_no_default_export`. When the manifest loads, `data.publicImports` is `{status: 'checked', findings: [], unchecked}`: `unchecked` lists each import the check could not judge, as {file, specifier, reason}, the reason starting `example <label>:` for an import in a component example: an `exports` target not built yet; a module whose export list cannot be read in full (CommonJS, or a declaration file it cannot read); a root import in a package with no `exports` (the root module `main` names is not read); every name an import (other than a component doc's own component) names that its module does not export, while a TypeScript file in the package has a `declare module` block for a relative path or the package's own name or a subpath of it, which can add names to that module (a `declare module` in a comment, `declare global`, a wildcard such as `'*.css'`, and another package's name do not count; a file whose text has `declare module` but that cannot be parsed counts); the same for every such name when the package has more than 5,000 files to search for that block; a deep path into build output not built yet in a package with no `exports`; a template import of Core when `@astryxdesign/core` is not installed beside the package (a `packages/core` of the workspace under another name does not count); every import of the package's own name when package.json has no `name` or a `name` that is not a bare package name; one entry for the whole check when package.json cannot be read; and an import of a subpath whose `exports` entry has only a `types` target, unless it is `import type`, every binding is an inline `type`, or every name it imports is a type its types file declares: a value import of a name that file does not declare as a type, a namespace or side-effect import, or any import when the types file cannot be read (it may be build output). `integration check` counts the unchecked as not compared; they never fail it.",
65
+ "The result envelope: `data.validated`, false when nothing was validated — with no `package.json` at all, `data.issues` carries one `no_package` error-severity issue so the command exits 1; with a `package.json` but no integration manifest, `data.issues` is empty, which means \"not looked at\", not \"healthy\"; `data.name` and `data.version` of the validated package (both null when `data.validated` is false; `data.name` is `(local package)` when the local package.json has no readable name), plus `data.issues`, an AstryxIntegrationIssue[] of {code, severity: `warning` | `error`, message, fix?, file?, line?}: `fix` is the change that resolves the issue, and `file` and `line` where it is, relative to the package, when the check knows them; and `data.notes` when there are any: {code, message, next?} information beside the issues; a note fails nothing by default, and one with `next: true` counts as a warning under `integration check --next`, fails `integration check --strict --next`, and fails `--strict` from the next minor release. Notes include `invalid_cli_command` for a `cliCommand` that was ignored as malformed 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 `name` or `version`), `no_provider_id`, and `source_without_component_doc` for a doc whose file name differs from its source only in letter case where the two still pair; and `doc_name_mismatch` and `unknown_block_component` (see `docNames` and `blockComponents`); they become warnings in the next minor release. For the commands a topic writes, `runner_command` (written with a package runner), `plain_command` (written bare), `package_manager_command` (written for one package manager) and `doc_token` (a token that does not parse) notes each give the file, line and the token to write. A `doc_target_not_found` note names a doc whose `replaces` or `extends` names no topic and no guide of the CLI's docs or the package's own (such as a namespace, with the guides below it), so it changes nothing unless an app also installs a package that provides it, and a `doc_section_unplaced` note a section whose `before` or `after` names no section of the topic or guide it extends, so it is added at the end, and a `duplicate_guide_replacement` note two docs of the package that replace one guide, of which only the last is read; they become warnings in the next minor release. When the manifest loads, `data.docTypes` holds the doc type check: `status` (`checked` | `skipped`), `reason` when skipped, `typescript`, `docs` (doc values checked), `findings` ({doc, line, export, type, field, problem: `unknown_field` | `missing_field` | `wrong_type`, severity: `warning`, message, fix}), `unchecked` ({doc, reason}: a doc that could not be fully checked, or a root its reader cannot read), and `fixtures` when the components or docs root holds test fixture docs under `__tests__`: how many, none of them checked. When the manifest loads, `data.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, `data.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 a note in `data.notes`, its fix inside the message, listed only: it does not fail this command or `integration check --strict`, and fails `--strict` from the next minor release. The codes are `component_import_not_exported`, `component_import_other_package`, `component_import_missing_name`, `example_import_not_exported`, `example_import_missing_name`, `template_import_not_exported`, `template_import_outside_root`, `template_private_import`, `template_import_missing_name` and `template_no_default_export`. When the manifest loads, `data.publicImports` is `{status: 'checked', findings: [], unchecked}`: `unchecked` lists each import the check could not judge, as {file, specifier, reason}, the reason starting `example <label>:` for an import in a component example: an `exports` target not built yet; a module whose export list cannot be read in full (CommonJS, or a declaration file it cannot read); a root import in a package with no `exports` (the root module `main` names is not read); every name an import (other than a component doc's own component) names that its module does not export, while a TypeScript file in the package has a `declare module` block for a relative path or the package's own name or a subpath of it, which can add names to that module (a `declare module` in a comment, `declare global`, a wildcard such as `'*.css'`, and another package's name do not count; a file whose text has `declare module` but that cannot be parsed counts); the same for every such name when the package has more than 5,000 files to search for that block; a deep path into build output not built yet in a package with no `exports`; a template import of Core when `@astryxdesign/core` is not installed beside the package (a `packages/core` of the workspace under another name does not count); every import of the package's own name when package.json has no `name` or a `name` that is not a bare package name; one entry for the whole check when package.json cannot be read; and an import of a subpath whose `exports` entry has only a `types` target, unless it is `import type`, every binding is an inline `type`, or every name it imports is a type its types file declares: a value import of a name that file does not declare as a type, a namespace or side-effect import, or any import when the types file cannot be read (it may be build output). `integration check` counts the unchecked as not compared; they never fail it.",
66
66
  },
67
67
  ],
68
68
  examples: [
@@ -17,11 +17,13 @@
17
17
  * @param {string} [candidate.description]
18
18
  * @param {string[]} [candidate.prose] - Extra free-text blobs (doc section text, best practices).
19
19
  * @param {string[]} [candidate.guidance] - Usage guidance (features, best practices) — scored a tier below description.
20
- * @param {{fuzzy?: boolean, joins?: boolean}} [opts] - `fuzzy`: allow edit-distance (typo) matches. Default true; multi-word queries pass false. `joins`: read a spaced query joined into a name or keyword (default true); off when the query names an entry outright.
20
+ * @param {string} [candidate._family] - The family whose doc lists the entry as a member.
21
+ * @param {number} [candidate._familyIndex] - The entry's place among that family's members.
22
+ * @param {{fuzzy?: boolean, joins?: boolean, part?: boolean, synonym?: boolean}} [opts] - `fuzzy`: allow edit-distance (typo) matches. Default true; multi-word queries pass false. `joins`: read a spaced query joined into a name or keyword (default true); off when the query names an entry outright. `part`: the term is one word of a longer query, so a name's head word after single letters (Stack in VStack) does not count as a keyword hit for it. `synonym`: the term stands in for a word of the query, so it names no family.
21
23
  * @returns {{score: number, reason: string, alias?: 'partial' | 'keyword'} | null}
22
24
  * `alias` marks a hit that read the query's words joined.
23
25
  */
24
- export function scoreCandidate(term: string, { name, aliases, domain, keywords, weakKeywords, description, prose, guidance, }: {
26
+ export function scoreCandidate(term: string, { name, aliases, domain, keywords, weakKeywords, description, prose, guidance, _family, _familyIndex, }: {
25
27
  name: string;
26
28
  aliases?: string[] | undefined;
27
29
  domain?: string | undefined;
@@ -30,9 +32,13 @@ export function scoreCandidate(term: string, { name, aliases, domain, keywords,
30
32
  description?: string | undefined;
31
33
  prose?: string[] | undefined;
32
34
  guidance?: string[] | undefined;
33
- }, { fuzzy, joins }?: {
35
+ _family?: string | undefined;
36
+ _familyIndex?: number | undefined;
37
+ }, { fuzzy, joins, part, synonym }?: {
34
38
  fuzzy?: boolean;
35
39
  joins?: boolean;
40
+ part?: boolean;
41
+ synonym?: boolean;
36
42
  }): {
37
43
  score: number;
38
44
  reason: string;
@@ -41,11 +41,59 @@ import {
41
41
  wordForms,
42
42
  sameWord,
43
43
  startsAWordOf,
44
+ wordsOf,
44
45
  joined,
45
46
  isTypo,
46
47
  } from './_words.mjs';
47
48
  import {pluralOf} from './_query.mjs';
48
49
 
50
+ /**
51
+ * Whether a multi-word term spells out a name word by word: as many words as
52
+ * the name, each the name's word in order or, for a single-letter word, a word
53
+ * starting with that letter ("vertical" for V) that the entry's own
54
+ * description names. `vertical stack` spells out VStack when its description says
55
+ * "vertical"; `visual stack` does not.
56
+ * @param {string} term
57
+ * @param {string} name
58
+ * @param {string} description
59
+ */
60
+ function spellsOut(term, name, description) {
61
+ const words = term.split(/\s+/).filter(Boolean);
62
+ const parts = wordsOf(name);
63
+ if (words.length < 2 || words.length !== parts.length) return false;
64
+ const described = wordsOf(description);
65
+ let expanded = false;
66
+ for (let i = 0; i < words.length; i++) {
67
+ const w = words[i];
68
+ const p = parts[i];
69
+ if (sameWord(w, p)) continue;
70
+ // Only a single-letter word is an abbreviation to spell out: "With" in a
71
+ // name is not spelled out by "without".
72
+ if (p.length !== 1 || !w.startsWith(p)) return false;
73
+ if (!described.some(d => sameWord(d, w))) return false;
74
+ expanded = true;
75
+ }
76
+ return expanded;
77
+ }
78
+
79
+ /**
80
+ * Whether a one-word term is a name's last word and every word before it is a
81
+ * single letter: Stack in VStack and HStack.
82
+ * @param {string} term
83
+ * @param {string} name
84
+ */
85
+ function headOfLetters(term, name) {
86
+ const parts = wordsOf(name);
87
+ return (
88
+ parts.length >= 2 &&
89
+ sameWord(term, parts[parts.length - 1]) &&
90
+ parts.slice(0, -1).every(p => p.length === 1)
91
+ );
92
+ }
93
+
94
+ /** How many of a family's members a query naming the family lists. */
95
+ const FAMILY_MEMBERS = 3;
96
+
49
97
  /**
50
98
  * Score a single candidate against the search term across name, keywords,
51
99
  * and prose signals. Returns the best (highest) score plus a human reason,
@@ -62,7 +110,9 @@ import {pluralOf} from './_query.mjs';
62
110
  * @param {string} [candidate.description]
63
111
  * @param {string[]} [candidate.prose] - Extra free-text blobs (doc section text, best practices).
64
112
  * @param {string[]} [candidate.guidance] - Usage guidance (features, best practices) — scored a tier below description.
65
- * @param {{fuzzy?: boolean, joins?: boolean}} [opts] - `fuzzy`: allow edit-distance (typo) matches. Default true; multi-word queries pass false. `joins`: read a spaced query joined into a name or keyword (default true); off when the query names an entry outright.
113
+ * @param {string} [candidate._family] - The family whose doc lists the entry as a member.
114
+ * @param {number} [candidate._familyIndex] - The entry's place among that family's members.
115
+ * @param {{fuzzy?: boolean, joins?: boolean, part?: boolean, synonym?: boolean}} [opts] - `fuzzy`: allow edit-distance (typo) matches. Default true; multi-word queries pass false. `joins`: read a spaced query joined into a name or keyword (default true); off when the query names an entry outright. `part`: the term is one word of a longer query, so a name's head word after single letters (Stack in VStack) does not count as a keyword hit for it. `synonym`: the term stands in for a word of the query, so it names no family.
66
116
  * @returns {{score: number, reason: string, alias?: 'partial' | 'keyword'} | null}
67
117
  * `alias` marks a hit that read the query's words joined.
68
118
  */
@@ -77,8 +127,10 @@ export function scoreCandidate(
77
127
  description = '',
78
128
  prose = [],
79
129
  guidance = [],
130
+ _family,
131
+ _familyIndex,
80
132
  },
81
- {fuzzy = true, joins = true} = {},
133
+ {fuzzy = true, joins = true, part = false, synonym = false} = {},
82
134
  ) {
83
135
  let best = 0;
84
136
  let reason = '';
@@ -128,6 +180,15 @@ export function scoreCandidate(
128
180
  // Most of the name typed as words, cut short: `complex select` is
129
181
  // ComplexSelector, ahead of a one-word keyword elsewhere.
130
182
  consider(95, `name "${candidateName}" spelled`, 'partial');
183
+ } else if (
184
+ domain !== 'doc' &&
185
+ domain !== 'theme' &&
186
+ spellsOut(term, candidateName, description)
187
+ ) {
188
+ // The name's short words spelled out, in order, as the entry's own
189
+ // description spells them: `vertical stack` is VStack ("Vertical stack
190
+ // for arranging items top-to-bottom").
191
+ consider(95, `name "${candidateName}" spelled out`);
131
192
  } else if (pluralOf(nameLower, term) || pluralOf(term, nameLower)) {
132
193
  // One point under the exact spelling, so the doc named `tokens` still
133
194
  // outranks the Token component for `tokens`.
@@ -135,7 +196,16 @@ export function scoreCandidate(
135
196
  } else {
136
197
  if (sameWord(term, nameLower)) consider(95, `name "${candidateName}"`);
137
198
  // The term is a word of the name, or starts one: "input" in TextInput.
138
- else if (startsAWordOf(term, candidateName)) {
199
+ else if (
200
+ !part &&
201
+ domain !== 'doc' &&
202
+ domain !== 'theme' &&
203
+ headOfLetters(term, candidateName)
204
+ ) {
205
+ // The whole query is the name's head word after single letters (Stack
206
+ // in VStack, HStack): a variant named by its head, as a keyword is.
207
+ consider(90, `name "${candidateName}" ends in "${term}"`);
208
+ } else if (startsAWordOf(term, candidateName)) {
139
209
  consider(60, `name contains "${term}"`);
140
210
  }
141
211
  if (fuzzy) {
@@ -150,6 +220,23 @@ export function scoreCandidate(
150
220
  }
151
221
  }
152
222
 
223
+ // ── Family signal ───────────────────────────────────────────────
224
+ // A query naming a family lists its first members as a keyword would: the
225
+ // family doc names them, whether or not a component of the family's name
226
+ // exists ("chat" lists ChatMessage and its siblings). Only the whole query
227
+ // names the family: a word of a longer query lifts no member.
228
+ if (
229
+ !part &&
230
+ !synonym &&
231
+ _family &&
232
+ (_familyIndex ?? Infinity) < FAMILY_MEMBERS &&
233
+ (term === _family.toLowerCase() ||
234
+ term === wordsOf(_family).join(' ') ||
235
+ term.replace(/\s+/g, '') === _family.toLowerCase())
236
+ ) {
237
+ consider(90, `member of ${_family}`);
238
+ }
239
+
153
240
  // ── Keyword signals ─────────────────────────────────────────────
154
241
  const termJoined = joined(term);
155
242
  for (const kw of keywords) {
@@ -5,6 +5,8 @@
5
5
  * integrations contribute, read from their docs. Imported only by the adapter.
6
6
  */
7
7
 
8
+ import fs from 'node:fs';
9
+ import path from 'node:path';
8
10
  import {discoverExternalPackages} from '../../foundation/fs/paths.mjs';
9
11
  import {
10
12
  discoverComponents,
@@ -29,6 +31,28 @@ import {loadModuleDoc, guidanceFrom} from './_module-doc.mjs';
29
31
 
30
32
  /** @typedef {import('./_lexical.mjs').Candidate} Candidate */
31
33
 
34
+ /**
35
+ * The members a family doc names, each with the family and its place among
36
+ * the members (the family's own entry left out). A query naming the family
37
+ * lists its first members (see scoreCandidate).
38
+ * @param {any} docs
39
+ * @returns {Map<string, {_family: string, _familyIndex: number}>}
40
+ */
41
+ function familyPlaces(docs) {
42
+ /** @type {Map<string, {_family: string, _familyIndex: number}>} */
43
+ const out = new Map();
44
+ if (!docs || typeof docs.name !== 'string') return out;
45
+ (Array.isArray(docs.components) ? docs.components : [])
46
+ .map((/** @type {any} */ m) => (typeof m === 'string' ? m : m?.name))
47
+ .filter(
48
+ (/** @type {unknown} */ n) => typeof n === 'string' && n !== docs.name,
49
+ )
50
+ .forEach((/** @type {string} */ n, /** @type {number} */ i) =>
51
+ out.set(n, {_family: docs.name, _familyIndex: i}),
52
+ );
53
+ return out;
54
+ }
55
+
32
56
  /**
33
57
  * Build component candidates from core's own tree: name + keywords +
34
58
  * usage/description from the component's .doc.mjs.
@@ -40,6 +64,8 @@ async function gatherCoreComponents(coreDir) {
40
64
  const names = Object.values(grouped).flat();
41
65
  /** @type {Candidate[]} */
42
66
  const candidates = [];
67
+ /** @type {Map<string, {_family: string, _familyIndex: number}>} */
68
+ const places = new Map();
43
69
  for (const comp of names) {
44
70
  const readme = findComponentReadme(coreDir, comp);
45
71
  /** @type {string[]} */
@@ -58,6 +84,7 @@ async function gatherCoreComponents(coreDir) {
58
84
  description = doc.usage?.description || doc.description || '';
59
85
  guidance = guidanceFrom(doc);
60
86
  }
87
+ for (const [n, place] of familyPlaces(loaded)) places.set(n, place);
61
88
  }
62
89
  candidates.push({
63
90
  domain: 'component',
@@ -69,7 +96,17 @@ async function gatherCoreComponents(coreDir) {
69
96
  _import: resolveImportPath(coreDir, comp),
70
97
  });
71
98
  }
72
- return candidates;
99
+ // A family doc with no component of its own name (Chat) names members too.
100
+ const srcDir = path.join(coreDir, 'src');
101
+ const listed = new Set(names);
102
+ for (const dir of fs.existsSync(srcDir) ? fs.readdirSync(srcDir) : []) {
103
+ const doc = path.join(srcDir, dir, `${dir}.doc.mjs`);
104
+ if (listed.has(dir) || !fs.existsSync(doc)) continue;
105
+ for (const [n, place] of familyPlaces(await loadModuleDoc(doc)))
106
+ places.set(n, place);
107
+ }
108
+ // A family doc names its members, whose own docs may sit elsewhere.
109
+ return candidates.map(c => ({...c, ...places.get(c.name)}));
73
110
  }
74
111
 
75
112
  /**
@@ -105,9 +142,18 @@ async function gatherIntegrationComponents(loadedIntegrations) {
105
142
  .filter(rec => !isIntegrationMember(rec))
106
143
  .map(rec => rec.docPath),
107
144
  );
145
+ /** @type {string[]} */
146
+ const docPaths = [];
108
147
  forEachIntegrationDoc(integration.components, (docPath, stem) => {
109
148
  if (!renamed.has(docPath)) hold(fileNamed, stem, docPath);
149
+ docPaths.push(docPath);
110
150
  });
151
+ // A family doc names its members, whose own docs may sit beside it.
152
+ /** @type {Map<string, {_family: string, _familyIndex: number}>} */
153
+ const places = new Map();
154
+ for (const docPath of docPaths)
155
+ for (const [n, place] of familyPlaces(await loadModuleDoc(docPath)))
156
+ places.set(n, place);
111
157
  for (const rec of components) {
112
158
  const loaded = await loadModuleDoc(rec.docPath);
113
159
  // A family member is indexed from its own entry: the family's keywords
@@ -132,6 +178,7 @@ async function gatherIntegrationComponents(loadedIntegrations) {
132
178
  keywords: doc && Array.isArray(doc.keywords) ? doc.keywords : [],
133
179
  description: doc ? doc.usage?.description || doc.description || '' : '',
134
180
  guidance: guidanceFrom(doc),
181
+ ...places.get(rec.name),
135
182
  _package: rec.package ?? integration.name,
136
183
  // Exactly what `component` reports: a doc may state its own specifier
137
184
  // (one entry point exporting several components), and only when it
@@ -7,6 +7,7 @@
7
7
 
8
8
  import {
9
9
  guideEntry,
10
+ sectionPackageOf,
10
11
  loadDocsCatalog,
11
12
  lowerTopic,
12
13
  projectTree,
@@ -104,9 +105,17 @@ export async function gatherDocs(cwd) {
104
105
  // A tree hit names where it lives: its ancestors' titles, then its own.
105
106
  const path = [...tree.ancestors(node).map(a => a.title), node.title];
106
107
  if (node.kind === 'generic') {
108
+ // A guide an integration replaced or extended names the package that
109
+ // wrote it, and each section the package that wrote that section, as
110
+ // reads do (INV28).
111
+ const entry = guideEntry(node);
107
112
  let doc = null;
113
+ /** @type {((key: string) => string) | undefined} */
114
+ let sectionPackage;
108
115
  try {
109
- doc = (await lowerTopic(catalog, guideEntry(node))).doc;
116
+ const lowered = await lowerTopic(catalog, entry);
117
+ doc = lowered.doc;
118
+ sectionPackage = sectionPackageOf(entry, lowered);
110
119
  } catch {
111
120
  // As above: the owning commands report it.
112
121
  }
@@ -118,7 +127,8 @@ export async function gatherDocs(cwd) {
118
127
  node.summary,
119
128
  path.join(' › '),
120
129
  node.parent == null ? undefined : `astryx docs ${node.parent}`,
121
- node.provider,
130
+ entry.package,
131
+ sectionPackage,
122
132
  ),
123
133
  );
124
134
  continue;
@@ -31,6 +31,9 @@
31
31
  * Core's package for its components, hooks, and templates, the integration's
32
32
  * for what it contributed, and for a doc part the package that wrote it.
33
33
  * @property {string} [_displayName]
34
+ * @property {string} [_family] - The family whose doc lists a component as a
35
+ * member; a query naming the family lists its first members.
36
+ * @property {number} [_familyIndex] - The member's place in that doc's list.
34
37
  * @property {'page'|'block'} [_kind]
35
38
  * @property {string} [_resultName]
36
39
  * @property {string} [_commandName]
@@ -120,6 +123,15 @@ export type Candidate = {
120
123
  */
121
124
  _package?: string | undefined;
122
125
  _displayName?: string | undefined;
126
+ /**
127
+ * - The family whose doc lists a component as a
128
+ * member; a query naming the family lists its first members.
129
+ */
130
+ _family?: string | undefined;
131
+ /**
132
+ * - The member's place in that doc's list.
133
+ */
134
+ _familyIndex?: number | undefined;
123
135
  _kind?: "page" | "block" | undefined;
124
136
  _resultName?: string | undefined;
125
137
  _commandName?: string | undefined;
@@ -90,6 +90,9 @@ import {toResult, searchedComponentsOf} from './_result.mjs';
90
90
  * Core's package for its components, hooks, and templates, the integration's
91
91
  * for what it contributed, and for a doc part the package that wrote it.
92
92
  * @property {string} [_displayName]
93
+ * @property {string} [_family] - The family whose doc lists a component as a
94
+ * member; a query naming the family lists its first members.
95
+ * @property {number} [_familyIndex] - The member's place in that doc's list.
93
96
  * @property {'page'|'block'} [_kind]
94
97
  * @property {string} [_resultName]
95
98
  * @property {string} [_commandName]
@@ -130,9 +130,12 @@ export function domainPriority(
130
130
  return 1;
131
131
  }
132
132
  const fuzzy = tokens.length <= 1;
133
+ // The whole query is read as the whole query; its words are parts of it
134
+ // only when there are several.
133
135
  return words.some(
134
- w =>
135
- (bestForToken(w, candidate, {fuzzy})?.score ?? 0) >= STRONG_TOKEN_SCORE,
136
+ (w, i) =>
137
+ (bestForToken(w, candidate, {fuzzy, part: i > 0 && tokens.length > 1})
138
+ ?.score ?? 0) >= STRONG_TOKEN_SCORE,
136
139
  )
137
140
  ? 1
138
141
  : 0;
@@ -6,11 +6,12 @@
6
6
  * (synonym hits are discounted so a direct hit always wins).
7
7
  * @param {string} tok
8
8
  * @param {Candidate} candidate
9
- * @param {{fuzzy?: boolean}} [opts]
9
+ * @param {{fuzzy?: boolean, part?: boolean}} [opts] - see scoreCandidate
10
10
  * @returns {{score: number, reason: string} | null}
11
11
  */
12
12
  export function bestForToken(tok: string, candidate: Candidate, opts?: {
13
13
  fuzzy?: boolean;
14
+ part?: boolean;
14
15
  }): {
15
16
  score: number;
16
17
  reason: string;