@astryxdesign/cli 0.7.4-canary.b25f95e → 0.7.4-canary.ccdb1b8

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 (93) hide show
  1. package/README.md +63 -63
  2. package/api/docs/_adapter.d.mts +80 -0
  3. package/api/docs/_adapter.mjs +248 -5
  4. package/api/docs/detail/detail.mjs +8 -0
  5. package/api/docs/docs.doc.mjs +1 -1
  6. package/api/docs/docs.type.d.mts +28 -2
  7. package/api/docs/docs.type.mjs +13 -3
  8. package/api/docs/guide-route-targets.test.mjs +998 -0
  9. package/api/docs/index/index.mjs +9 -0
  10. package/api/docs/list/list.mjs +7 -1
  11. package/api/docs/node/node.mjs +9 -1
  12. package/api/docs/reference-blocks.test.mjs +1 -1
  13. package/api/doctor/_adapter.d.mts +40 -0
  14. package/api/doctor/_adapter.mjs +171 -1
  15. package/api/doctor/built-checks.d.mts +85 -0
  16. package/api/doctor/built-checks.mjs +837 -0
  17. package/api/doctor/built-checks.test.mjs +531 -0
  18. package/api/doctor/doctor.d.mts +6 -5
  19. package/api/doctor/doctor.doc.mjs +10 -0
  20. package/api/doctor/doctor.mjs +18 -3
  21. package/api/doctor/doctor.type.d.mts +6 -0
  22. package/api/doctor/doctor.type.mjs +3 -0
  23. package/api/integration/_adapter.d.mts +8 -0
  24. package/api/integration/_adapter.mjs +25 -0
  25. package/api/integration/authoring-checks.mjs +29 -2
  26. package/api/integration/pack-check.mjs +32 -1
  27. package/api/integration/pack-check.test.mjs +33 -0
  28. package/api/integration/validate-integration.mjs +66 -1
  29. package/api/integration/validateIntegration.doc.mjs +1 -1
  30. package/api/search/_candidate-score.d.mts +3 -2
  31. package/api/search/_candidate-score.mjs +66 -3
  32. package/api/search/_gather-docs.mjs +12 -2
  33. package/api/search/_priority.mjs +2 -1
  34. package/api/search/_score.d.mts +2 -1
  35. package/api/search/_score.mjs +2 -2
  36. package/api/search/search.family-members.test.mjs +124 -0
  37. package/assets/discover/official-packages.json +16 -0
  38. package/assets/docs/browser-support.doc.mjs +1 -1
  39. package/assets/docs/theme.doc.mjs +2 -2
  40. package/assets/docs/tree/component-lookups.doc.mjs +2 -1
  41. package/assets/docs/tree/extend-or-replace.doc.mjs +36 -4
  42. package/assets/docs/tree/migration.doc.mjs +2 -1
  43. package/assets/docs/tree/styling-libraries.doc.mjs +2 -1
  44. package/assets/docs/tree/styling.doc.mjs +1 -1
  45. package/assets/templates/themes/butter/butterPaletteRefs.generated.ts +54 -0
  46. package/assets/templates/themes/butter/butterPalettes.generated.receipt.json +1499 -0
  47. package/assets/templates/themes/butter/butterPalettes.generated.ts +550 -0
  48. package/assets/templates/themes/butter/butterTheme.ts +274 -234
  49. package/assets/templates/themes/butter/palette.config.json +484 -0
  50. package/assets/templates/themes/gothic/gothicPaletteRefs.generated.ts +41 -0
  51. package/assets/templates/themes/gothic/gothicPalettes.generated.receipt.json +979 -0
  52. package/assets/templates/themes/gothic/gothicPalettes.generated.ts +271 -0
  53. package/assets/templates/themes/gothic/gothicTheme.ts +130 -160
  54. package/assets/templates/themes/gothic/palette.config.json +371 -0
  55. package/assets/templates/themes/matcha/matchaPaletteRefs.generated.ts +51 -0
  56. package/assets/templates/themes/matcha/matchaPalettes.generated.receipt.json +1502 -0
  57. package/assets/templates/themes/matcha/matchaPalettes.generated.ts +501 -0
  58. package/assets/templates/themes/matcha/matchaPalettes.ts +21 -0
  59. package/assets/templates/themes/matcha/matchaTheme.ts +164 -103
  60. package/assets/templates/themes/matcha/palette.config.json +448 -0
  61. package/assets/templates/themes/stone/palette.config.json +262 -0
  62. package/assets/templates/themes/stone/stonePaletteRefs.generated.ts +51 -0
  63. package/assets/templates/themes/stone/stonePalettes.generated.receipt.json +840 -0
  64. package/assets/templates/themes/stone/stonePalettes.generated.ts +501 -0
  65. package/assets/templates/themes/stone/stoneTheme.ts +190 -207
  66. package/assets/templates/themes/y2k/palette.config.json +166 -0
  67. package/assets/templates/themes/y2k/y2kPaletteRefs.generated.ts +54 -0
  68. package/assets/templates/themes/y2k/y2kPalettes.generated.receipt.json +872 -0
  69. package/assets/templates/themes/y2k/y2kPalettes.generated.ts +550 -0
  70. package/assets/templates/themes/y2k/y2kPalettes.ts +257 -0
  71. package/assets/templates/themes/y2k/y2kTheme.ts +164 -391
  72. package/authoring/doctypes/_schema.d.mts +4 -0
  73. package/authoring/doctypes/_schema.mjs +4 -0
  74. package/authoring/doctypes/reference/type.ts +14 -2
  75. package/clients/cli/commands/docs.mjs +27 -2
  76. package/clients/cli/commands/docs.test.mjs +1 -1
  77. package/clients/cli/commands/doctor.doc.mjs +12 -0
  78. package/clients/cli/commands/doctor.mjs +23 -8
  79. package/foundation/agent-docs/agent-docs.d.mts +14 -2
  80. package/foundation/agent-docs/agent-docs.mjs +54 -2
  81. package/foundation/agent-docs/agent-docs.test.mjs +61 -0
  82. package/foundation/discovery/docs-discovery.d.mts +93 -2
  83. package/foundation/discovery/docs-discovery.mjs +236 -8
  84. package/foundation/doc-compiler/compile.mjs +8 -1
  85. package/foundation/doc-compiler/doc-loads.test.mjs +3 -0
  86. package/foundation/doc-compiler/tree.d.mts +5 -0
  87. package/foundation/doc-compiler/tree.mjs +3 -0
  88. package/foundation/integrations/cli-requirement.d.mts +14 -0
  89. package/foundation/integrations/cli-requirement.mjs +23 -0
  90. package/foundation/integrations/cli-requirement.test.mjs +1 -0
  91. package/foundation/response/error-codes.test.mjs +9 -0
  92. package/foundation/response/response-types.doc.mjs +5 -5
  93. package/package.json +9 -9
@@ -16,6 +16,7 @@ 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';
@@ -114,6 +115,30 @@ export async function integrationStrayPointers(discovered, integration) {
114
115
  return findStrayPointers({...discovered, components});
115
116
  }
116
117
 
118
+ /**
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
+
117
142
  /**
118
143
  * Each Astryx command a package's topics write with a package runner. A
119
144
  * package whose topics cannot be discovered has none here: the other checks
@@ -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}`,
@@ -37,6 +37,7 @@ import {
37
37
  keywordsCliProblem,
38
38
  replacesCliProblem,
39
39
  sectionIdsCliProblem,
40
+ sectionPositionCliProblem,
40
41
  themesCliProblem,
41
42
  } from '../../foundation/integrations/cli-requirement.mjs';
42
43
  import {
@@ -328,13 +329,27 @@ function extractTarball(tgzPath, extractDir) {
328
329
  * @returns {Promise<boolean>}
329
330
  */
330
331
  async function setsSectionIds(files) {
332
+ return setsSectionField(files, ['id']);
333
+ }
334
+
335
+ /**
336
+ * Whether any of these doc files has a section that sets one of `fields`.
337
+ * @param {string[]} files
338
+ * @param {string[]} fields
339
+ * @returns {Promise<boolean>}
340
+ */
341
+ async function setsSectionField(files, fields) {
331
342
  for (const file of files) {
332
343
  if (typeof file !== 'string') continue;
333
344
  const doc = /** @type {any} */ (
334
345
  await loadTopicModule(file).catch(() => null)
335
346
  );
336
347
  const sections = Array.isArray(doc?.sections) ? doc.sections : [];
337
- if (sections.some((/** @type {any} */ section) => section?.id != null)) {
348
+ if (
349
+ sections.some((/** @type {any} */ section) =>
350
+ fields.some(field => section?.[field] != null),
351
+ )
352
+ ) {
338
353
  return true;
339
354
  }
340
355
  }
@@ -1383,6 +1398,22 @@ export async function integrationPackCheck(options = {}) {
1383
1398
  issues.push(error('section_ids_need_cli', idProblem));
1384
1399
  }
1385
1400
  }
1401
+ // `before` and `after` need a newer CLI than any field above. Added in a
1402
+ // patch release, it warns and never fails the check (INV35).
1403
+ if (
1404
+ await setsSectionField(
1405
+ [
1406
+ ...records.map(record => record.path),
1407
+ ...guides.map(guide => /** @type {any} */ (guide.ref).topicFile),
1408
+ ],
1409
+ ['before', 'after'],
1410
+ )
1411
+ ) {
1412
+ const positionProblem = sectionPositionCliProblem(pkg);
1413
+ if (positionProblem != null) {
1414
+ issues.push(warning('section_position_needs_cli', positionProblem));
1415
+ }
1416
+ }
1386
1417
  }
1387
1418
  // A template that sets `replaces` (spec:AST-035) or `keywords` needs a CLI
1388
1419
  // that reads the field: an older CLI drops that template and can hide the
@@ -1724,6 +1724,39 @@ describe('integrationPackCheck', () => {
1724
1724
  expect(await codes()).not.toContain('section_ids_need_cli');
1725
1725
  }, 120_000);
1726
1726
 
1727
+ it('warns, without failing, when a doc section sets before or after on a CLI range that rejects them', async () => {
1728
+ writePackage({
1729
+ manifest: "export default {docs: './docs'};\n",
1730
+ themes: false,
1731
+ });
1732
+ fs.mkdirSync(path.join(tmpDir, 'docs'), {recursive: true});
1733
+ const pkgFile = path.join(tmpDir, 'package.json');
1734
+ const pkg = JSON.parse(fs.readFileSync(pkgFile, 'utf-8'));
1735
+ pkg.peerDependencies = {'@astryxdesign/cli': '>=0.7.0'};
1736
+ fs.writeFileSync(pkgFile, `${JSON.stringify(pkg, null, 2)}\n`);
1737
+ const issues = async () =>
1738
+ (await integrationPackCheck({cwd: tmpDir})).data.issues.filter(
1739
+ (/** @type {{code: string}} */ issue) =>
1740
+ issue.code === 'section_position_needs_cli',
1741
+ );
1742
+ // A placed guide's section counts too: an older CLI rejects the field in
1743
+ // any doc and hides the package's topics.
1744
+ fs.writeFileSync(
1745
+ path.join(tmpDir, 'docs', 'acme.doc.mjs'),
1746
+ "export default {type: 'namespace', name: 'acme', title: 'Acme', summary: 'Acme.', slots: {guides: {title: 'Guides', accepts: {kinds: ['generic']}}}};\n",
1747
+ );
1748
+ fs.writeFileSync(
1749
+ path.join(tmpDir, 'docs', 'setup.doc.mjs'),
1750
+ "export default {type: 'generic', name: 'setup', title: 'Setup', description: 'Set up.', placement: {parent: 'namespace:acme', slot: 'guides'}, sections: [{id: 'overview', title: 'Overview', after: 'nothing', content: [{type: 'prose', text: 'Set up.'}]}]};\n",
1751
+ );
1752
+ expect(await issues()).toEqual([
1753
+ expect.objectContaining({severity: 'warning'}),
1754
+ ]);
1755
+ pkg.peerDependencies = {'@astryxdesign/cli': '>=0.7.4'};
1756
+ fs.writeFileSync(pkgFile, `${JSON.stringify(pkg, null, 2)}\n`);
1757
+ expect(await issues()).toEqual([]);
1758
+ }, 120_000);
1759
+
1727
1760
  it('fails a package with a template that sets replaces on a CLI range that rejects the field', async () => {
1728
1761
  writePackage({
1729
1762
  manifest: "export default {templates: './templates'};\n",
@@ -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
+ integrationDocTargets,
42
+ integrationRunnerCommands,
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
  /**
@@ -703,6 +715,58 @@ async function runnerCommandNotes(integration) {
703
715
  }));
704
716
  }
705
717
 
718
+ /**
719
+ * The notes for docs that replace or extend a topic or a guide the docs tree
720
+ * places, or place an extension's section with `before` or `after`: a name
721
+ * that holds neither (such as a namespace) applies nothing, and a key that
722
+ * names no section adds the section at the end. Each is listed, failing nothing, until
723
+ * the next minor release (architecture:cli-surface INV35).
724
+ * @param {any} integration a loaded integration
725
+ * @returns {Promise<Array<{code: string, message: string}>>}
726
+ */
727
+ async function docTargetNotes(integration) {
728
+ /** @type {Array<{code: string, message: string}>} */
729
+ const notes = [];
730
+ const targets = await integrationDocTargets(integration);
731
+ /** @type {Map<string, string[]>} lowercased route → the docs replacing it */
732
+ const replacers = new Map();
733
+ for (const each of targets) {
734
+ if (each.kind !== 'guide' || each.relationship !== 'replaces') continue;
735
+ // An old route and the new one name one guide.
736
+ const key = each.guide ?? each.target.toLowerCase();
737
+ replacers.set(key, [...(replacers.get(key) ?? []), each.topic]);
738
+ }
739
+ for (const [route, topics] of replacers) {
740
+ if (topics.length < 2) continue;
741
+ notes.push({
742
+ code: DUPLICATE_GUIDE_REPLACEMENT,
743
+ 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.`,
744
+ });
745
+ }
746
+ for (const each of targets) {
747
+ if (each.kind === 'namespace') {
748
+ const shown = each.guidesBelow.slice(0, 8);
749
+ const more = each.guidesBelow.length - shown.length;
750
+ notes.push({
751
+ code: DOC_TARGET_NOT_FOUND,
752
+ 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` : ''}` : ''}.`,
753
+ });
754
+ } else if (each.kind == null) {
755
+ notes.push({
756
+ code: DOC_TARGET_NOT_FOUND,
757
+ 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.`,
758
+ });
759
+ }
760
+ for (const {section, field, key} of each.unplaced) {
761
+ notes.push({
762
+ code: DOC_SECTION_UNPLACED,
763
+ 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.`,
764
+ });
765
+ }
766
+ }
767
+ return notes;
768
+ }
769
+
706
770
  /**
707
771
  * Unified entry: validate the LOCAL integration (no `pkg`) or an INSTALLED one
708
772
  * (`pkg` given) and return the `integration.validate` envelope. The no-manifest
@@ -757,6 +821,7 @@ export async function validateIntegration(pkg, options = {}) {
757
821
  // `runner_command` note with its fix, the same way.
758
822
  if (integration?.docs) {
759
823
  notes.push(...(await runnerCommandNotes(integration)));
824
+ notes.push(...(await docTargetNotes(integration)));
760
825
  }
761
826
  return {
762
827
  type: 'integration.validate',
@@ -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} 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. 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,7 +17,7 @@
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 {{fuzzy?: boolean, joins?: boolean, part?: 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.
21
21
  * @returns {{score: number, reason: string, alias?: 'partial' | 'keyword'} | null}
22
22
  * `alias` marks a hit that read the query's words joined.
23
23
  */
@@ -30,9 +30,10 @@ export function scoreCandidate(term: string, { name, aliases, domain, keywords,
30
30
  description?: string | undefined;
31
31
  prose?: string[] | undefined;
32
32
  guidance?: string[] | undefined;
33
- }, { fuzzy, joins }?: {
33
+ }, { fuzzy, joins, part }?: {
34
34
  fuzzy?: boolean;
35
35
  joins?: boolean;
36
+ part?: boolean;
36
37
  }): {
37
38
  score: number;
38
39
  reason: string;
@@ -41,11 +41,56 @@ 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
+
49
94
  /**
50
95
  * Score a single candidate against the search term across name, keywords,
51
96
  * and prose signals. Returns the best (highest) score plus a human reason,
@@ -62,7 +107,7 @@ import {pluralOf} from './_query.mjs';
62
107
  * @param {string} [candidate.description]
63
108
  * @param {string[]} [candidate.prose] - Extra free-text blobs (doc section text, best practices).
64
109
  * @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.
110
+ * @param {{fuzzy?: boolean, joins?: boolean, part?: 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.
66
111
  * @returns {{score: number, reason: string, alias?: 'partial' | 'keyword'} | null}
67
112
  * `alias` marks a hit that read the query's words joined.
68
113
  */
@@ -78,7 +123,7 @@ export function scoreCandidate(
78
123
  prose = [],
79
124
  guidance = [],
80
125
  },
81
- {fuzzy = true, joins = true} = {},
126
+ {fuzzy = true, joins = true, part = false} = {},
82
127
  ) {
83
128
  let best = 0;
84
129
  let reason = '';
@@ -128,6 +173,15 @@ export function scoreCandidate(
128
173
  // Most of the name typed as words, cut short: `complex select` is
129
174
  // ComplexSelector, ahead of a one-word keyword elsewhere.
130
175
  consider(95, `name "${candidateName}" spelled`, 'partial');
176
+ } else if (
177
+ domain !== 'doc' &&
178
+ domain !== 'theme' &&
179
+ spellsOut(term, candidateName, description)
180
+ ) {
181
+ // The name's short words spelled out, in order, as the entry's own
182
+ // description spells them: `vertical stack` is VStack ("Vertical stack
183
+ // for arranging items top-to-bottom").
184
+ consider(95, `name "${candidateName}" spelled out`);
131
185
  } else if (pluralOf(nameLower, term) || pluralOf(term, nameLower)) {
132
186
  // One point under the exact spelling, so the doc named `tokens` still
133
187
  // outranks the Token component for `tokens`.
@@ -135,7 +189,16 @@ export function scoreCandidate(
135
189
  } else {
136
190
  if (sameWord(term, nameLower)) consider(95, `name "${candidateName}"`);
137
191
  // The term is a word of the name, or starts one: "input" in TextInput.
138
- else if (startsAWordOf(term, candidateName)) {
192
+ else if (
193
+ !part &&
194
+ domain !== 'doc' &&
195
+ domain !== 'theme' &&
196
+ headOfLetters(term, candidateName)
197
+ ) {
198
+ // The whole query is the name's head word after single letters (Stack
199
+ // in VStack, HStack): a variant named by its head, as a keyword is.
200
+ consider(90, `name "${candidateName}" ends in "${term}"`);
201
+ } else if (startsAWordOf(term, candidateName)) {
139
202
  consider(60, `name contains "${term}"`);
140
203
  }
141
204
  if (fuzzy) {
@@ -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;
@@ -132,7 +132,8 @@ export function domainPriority(
132
132
  const fuzzy = tokens.length <= 1;
133
133
  return words.some(
134
134
  w =>
135
- (bestForToken(w, candidate, {fuzzy})?.score ?? 0) >= STRONG_TOKEN_SCORE,
135
+ (bestForToken(w, candidate, {fuzzy, part: words.length > 1})?.score ??
136
+ 0) >= STRONG_TOKEN_SCORE,
136
137
  )
137
138
  ? 1
138
139
  : 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;
@@ -39,7 +39,7 @@ const MIN_TOKEN_SCORE = 50;
39
39
  * (synonym hits are discounted so a direct hit always wins).
40
40
  * @param {string} tok
41
41
  * @param {Candidate} candidate
42
- * @param {{fuzzy?: boolean}} [opts]
42
+ * @param {{fuzzy?: boolean, part?: boolean}} [opts] - see scoreCandidate
43
43
  * @returns {{score: number, reason: string} | null}
44
44
  */
45
45
  export function bestForToken(tok, candidate, opts = {}) {
@@ -187,7 +187,7 @@ export function scoreQuery(
187
187
  let alias = false;
188
188
  let aliasWords = 0;
189
189
  for (const tok of tokens) {
190
- let h = bestForToken(tok, candidate, {fuzzy});
190
+ let h = bestForToken(tok, candidate, {fuzzy, part: true});
191
191
  if (
192
192
  compound?.covered.has(joined(tok)) &&
193
193
  compound.score > (h?.score ?? 0)