@astryxdesign/cli 0.7.2-canary.64e1dde → 0.7.2-canary.6c792d8

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 (71) hide show
  1. package/README.md +62 -62
  2. package/api/component/_adapter.d.mts +31 -0
  3. package/api/component/_adapter.mjs +116 -0
  4. package/api/component/component.mjs +60 -10
  5. package/api/component/doc-links.test.mjs +386 -0
  6. package/api/discover/detail/doc/doc.mjs +9 -1
  7. package/api/docs/_adapter.d.mts +63 -0
  8. package/api/docs/_adapter.mjs +309 -16
  9. package/api/docs/integration-tree.test.mjs +22 -0
  10. package/api/docs/list/list.mjs +12 -2
  11. package/api/integration/_adapter.d.mts +23 -0
  12. package/api/integration/_adapter.mjs +45 -0
  13. package/api/integration/authoring-checks.mjs +87 -3
  14. package/api/integration/authoring-checks.test.mjs +443 -0
  15. package/api/integration/authoring-checks.type.d.mts +84 -0
  16. package/api/integration/authoring-checks.type.mjs +40 -1
  17. package/api/integration/integrationComponentConflicts.doc.mjs +3 -1
  18. package/api/integration/integrationDocConflicts.doc.mjs +7 -2
  19. package/api/integration/pack-check.mjs +4 -0
  20. package/api/integration/pack-check.test.mjs +26 -0
  21. package/api/integration/validate-integration-fixes.test.mjs +67 -0
  22. package/api/integration/validate-integration.mjs +28 -3
  23. package/api/integration/validate-integration.test.mjs +77 -8
  24. package/api/integration/validateIntegration.doc.mjs +1 -1
  25. package/api/search/search.mjs +2 -1
  26. package/assets/docs/browser-support.doc.mjs +1 -1
  27. package/assets/docs/tree/add-a-topic.doc.mjs +2 -2
  28. package/assets/docs/tree/check-the-props.doc.mjs +5 -0
  29. package/assets/docs/tree/check-your-docs.doc.mjs +10 -2
  30. package/assets/docs/tree/checks.doc.mjs +4 -4
  31. package/assets/docs/tree/debug-and-gap-reports.doc.mjs +7 -7
  32. package/assets/docs/tree/document-the-theme.doc.mjs +2 -2
  33. package/assets/docs/tree/publishing.doc.mjs +2 -2
  34. package/assets/docs/tree/sections-and-placement.doc.mjs +2 -2
  35. package/authoring/doctypes/component/type.ts +8 -0
  36. package/authoring/doctypes/hook/type.ts +4 -0
  37. package/clients/cli/commands/doctor-integration-components.doc.mjs +3 -2
  38. package/clients/cli/commands/doctor-integration-docs.doc.mjs +3 -1
  39. package/clients/cli/commands/doctor-integration.test.mjs +48 -1
  40. package/clients/cli/commands/doctor.mjs +60 -5
  41. package/clients/cli/commands/integration-authoring.test.mjs +46 -0
  42. package/clients/cli/commands/integration-check.test.mjs +79 -0
  43. package/clients/cli/commands/integration.mjs +10 -4
  44. package/foundation/discovery/copied-passages.d.mts +8 -0
  45. package/foundation/discovery/copied-passages.mjs +2 -2
  46. package/foundation/discovery/doc-consistency.d.mts +34 -0
  47. package/foundation/discovery/doc-consistency.mjs +513 -0
  48. package/foundation/discovery/doc-consistency.test.mjs +347 -0
  49. package/foundation/discovery/doc-fluff.d.mts +112 -0
  50. package/foundation/discovery/doc-fluff.mjs +328 -0
  51. package/foundation/discovery/doc-fluff.test.mjs +142 -0
  52. package/foundation/discovery/doc-types.mjs +12 -5
  53. package/foundation/discovery/doc-types.test.mjs +46 -2
  54. package/foundation/discovery/prop-drift.d.mts +25 -6
  55. package/foundation/discovery/prop-drift.mjs +171 -6
  56. package/foundation/discovery/prop-drift.test.mjs +65 -0
  57. package/foundation/discovery/stray-pointers.d.mts +52 -0
  58. package/foundation/discovery/stray-pointers.mjs +293 -0
  59. package/foundation/discovery/stray-pointers.test.mjs +86 -0
  60. package/foundation/doc-compiler/doc-loads.test.mjs +12 -0
  61. package/foundation/doc-compiler/links.d.mts +32 -0
  62. package/foundation/doc-compiler/links.mjs +163 -26
  63. package/foundation/doc-compiler/links.test.mjs +97 -4
  64. package/foundation/doc-compiler/tree.mjs +30 -1
  65. package/foundation/doc-compiler/tree.test.mjs +7 -0
  66. package/foundation/integrations/contribution-inventory.d.mts +11 -0
  67. package/foundation/integrations/contribution-inventory.mjs +50 -2
  68. package/foundation/integrations/issue.ts +6 -0
  69. package/foundation/integrations/validate-contributions.mjs +30 -1
  70. package/foundation/response/response-types.doc.mjs +4 -4
  71. package/package.json +9 -9
@@ -68,6 +68,45 @@
68
68
  * @property {string} message what is repeated, and the exact fix: the passage in `topic` replaced by a link to `owner`
69
69
  */
70
70
 
71
+ /**
72
+ * Fluff in a topic's prose: a padding phrase (`kind: 'phrase'`, with the
73
+ * phrase, its section, and the file line where it was found), or a topic of
74
+ * 80 or more prose words of which fewer than half are content words
75
+ * (`kind: 'density'`, with the share). Each is also a `doc_fluff` warning, so
76
+ * `integration check --strict` fails on it (architecture:cli-surface DEC-8).
77
+ *
78
+ * @typedef {object} DocFluff
79
+ * @property {string} topic
80
+ * @property {'phrase' | 'density'} kind
81
+ * @property {string | null} phrase the padding phrase, for `kind: 'phrase'`
82
+ * @property {string | null} section the title of the section it is in
83
+ * @property {string} file the doc file, relative to the package root
84
+ * @property {number | null} line the file line that holds the phrase, when one line does
85
+ * @property {number | null} density the share of content words, for `kind: 'density'`
86
+ * @property {string} message what to cut or write instead
87
+ */
88
+
89
+ /**
90
+ * A code span in prose that is exactly `astryx docs <name>` for a doc that
91
+ * exists, where the doc's `{@link generic:<name>}` would be checked. Each is
92
+ * also a `stray_doc_pointer` warning, so `integration check --strict` fails on
93
+ * it (architecture:cli-surface DEC-8).
94
+ *
95
+ * @typedef {object} StrayPointer
96
+ * @property {string} topic the package topic, or component doc, that has it
97
+ * @property {'topic' | 'component'} kind whether it sits in a topic or a
98
+ * component doc
99
+ * @property {string | null} section the title of the section it is in
100
+ * @property {string | null} field the field it is in outside any section: a
101
+ * topic's `description` or `summary`, or a component doc's field path, such
102
+ * as `usage.bestPractices[0].description`
103
+ * @property {string} file the doc file, relative to the package root
104
+ * @property {number | null} line the file line that holds it, when found
105
+ * @property {string} pointer the written command, `astryx docs <name>`
106
+ * @property {string} link the link that replaces it
107
+ * @property {string} message the exact replacement
108
+ */
109
+
71
110
  /**
72
111
  * Each of the three authoring checks reports `validated`: false means no
73
112
  * integration manifest was found, so nothing was inspected and the empty
@@ -100,7 +139,7 @@
100
139
  /**
101
140
  * @typedef {object} IntegrationDocConflictResponse
102
141
  * @property {'integration.doc-conflicts'} type
103
- * @property {{validated: boolean, name: string | null, version: string | null, findings: IntegrationDocFinding[], copiedPassages: CopiedPassage[], issues: import('../../foundation/integrations/issue').AstryxIntegrationIssue[]}} data
142
+ * @property {{validated: boolean, name: string | null, version: string | null, findings: IntegrationDocFinding[], copiedPassages: CopiedPassage[], fluff: DocFluff[], strayPointers: StrayPointer[], issues: import('../../foundation/integrations/issue').AstryxIntegrationIssue[]}} data
104
143
  */
105
144
 
106
145
  export {};
@@ -17,6 +17,8 @@ export const doc = {
17
17
  "component command required to keep an intentional overlap. Each component's " +
18
18
  'replaces is checked too: its findings are issues, errors for a package that ' +
19
19
  'declares the CLI range that turns replacement on and warnings otherwise. ' +
20
+ "A `{@link}` in a component doc's text that names no doc is an `invalid_doc_graph` " +
21
+ 'warning, since it prints as written. ' +
20
22
  "Each component doc's props are compared with the component's TypeScript props, " +
21
23
  "read with the project's own `typescript` (or, where `typescript` is missing or has no " +
22
24
  'JavaScript compiler API, as TypeScript 7 does, the `@typescript/typescript6` it ' +
@@ -63,7 +65,7 @@ export const doc = {
63
65
  {
64
66
  type: 'integration.component-conflicts',
65
67
  description:
66
- "`validated` (false when no integration manifest was found, so nothing was inspected), integration identity, structural and replaces issues, and Core component-name conflicts with package-qualified commands. An active replacement that keeps the Core name it replaces is not a conflict. When the manifest loads and declares a components root, `propDrift` holds the props comparison: `status` (`checked` | `skipped`), `reason` when skipped, `typescript`, `components` compared, `typesCompared` (documented prop types judged), `typesSkipped` (why none was, with a TypeScript older than 4.8), `findings` ({component, prop, kind: `not_in_code` | `not_in_doc` | `required_mismatch` | `type_mismatch`, severity: `warning`, message, doc, source, docType?, codeType?, docRequired?, codeRequired?}), `unchecked` ({component, doc, reason}), `typesNotCompared` ({component, doc, reason, props}: every other documented prop type, grouped by why it was not judged: not a form the check judges exactly (a doc type that does not parse, or a prop a mapped type builds from keys the check cannot trace, included), a field the prop's variants give different types, a standard prop such as `className`, or a prop declared outside the package), and `propsNotChecked` when a mapped type builds props from keys the check cannot trace to the package ({component, doc, reason, props}: no warning is drawn for those props).",
68
+ "`validated` (false when no integration manifest was found, so nothing was inspected), integration identity, structural and replaces issues, and Core component-name conflicts with package-qualified commands. An active replacement that keeps the Core name it replaces is not a conflict. When the manifest loads and declares a components root, `propDrift` holds the props comparison: `status` (`checked` | `skipped`), `reason` when skipped, `typescript`, `components` compared, `typesCompared` (documented prop types judged), `typesSkipped` (why none was, with a TypeScript older than 4.8), `findings` ({component, prop, kind: `not_in_code` | `not_in_doc` | `required_mismatch` | `type_mismatch` | `default_mismatch`, severity: `warning`, message, doc, source, docType?, codeType?, docRequired?, codeRequired?, docDefault?, codeDefault?, fix?}), `unchecked` ({component, doc, reason}), `typesNotCompared` ({component, doc, reason, props}: every other documented prop type, grouped by why it was not judged: not a form the check judges exactly (a doc type that does not parse, or a prop a mapped type builds from keys the check cannot trace, included), a field the prop's variants give different types, a standard prop such as `className`, or a prop declared outside the package), and `propsNotChecked` when a mapped type builds props from keys the check cannot trace to the package ({component, doc, reason, props}: no warning is drawn for those props).",
67
69
  },
68
70
  ],
69
71
  examples: [
@@ -17,7 +17,12 @@ export const doc = {
17
17
  'conflicts that need an explicit relationship or a rename. `copiedPassages` lists each ' +
18
18
  'pair of topics that repeat 10 or more words of prose word for word: two of the ' +
19
19
  "package's topics, or one of them and a Core topic other than the one it replaces. " +
20
- 'Code and examples are not compared. Each entry is also a `copied_passage` warning, so ' +
20
+ 'Code and examples are not compared. `fluff` lists each padding phrase, with its file ' +
21
+ 'line, and each topic of 80 or more prose words in which fewer than half carry content. ' +
22
+ '`strayPointers` lists each code span that is exactly `astryx docs <name>` for a doc that ' +
23
+ "exists, in a topic's prose, description or summary or a component doc's text fields, " +
24
+ 'with the `{@link}` that replaces it. ' +
25
+ 'Each entry of these lists is also a warning (`copied_passage`, `doc_fluff`, `stray_doc_pointer`), so ' +
21
26
  '`integration check --strict` fails on it; the check itself still fails only on errors.',
22
27
  importPath: '@astryxdesign/cli/api',
23
28
  signature:
@@ -35,7 +40,7 @@ export const doc = {
35
40
  {
36
41
  type: 'integration.doc-conflicts',
37
42
  description:
38
- '`validated` (false when no integration manifest was found, so nothing was inspected), integration identity, structural issues, classified Core doc relationships, and `copiedPassages`.',
43
+ '`validated` (false when no integration manifest was found, so nothing was inspected), integration identity, structural issues, classified Core doc relationships, `copiedPassages`, `fluff`, and `strayPointers`.',
39
44
  },
40
45
  ],
41
46
  examples: [
@@ -1539,6 +1539,10 @@ export async function integrationPackCheck(options = {}) {
1539
1539
  code: `packed_${issue.code}`,
1540
1540
  severity: issue.severity,
1541
1541
  message: `Packed: ${issue.message}`,
1542
+ // The packed tree keeps the package's own paths.
1543
+ ...(issue.fix != null ? {fix: issue.fix} : {}),
1544
+ ...(issue.file != null ? {file: issue.file} : {}),
1545
+ ...(issue.line != null ? {line: issue.line} : {}),
1542
1546
  });
1543
1547
  }
1544
1548
 
@@ -213,6 +213,7 @@ function writePackage({
213
213
  themeExports = false,
214
214
  npmignore,
215
215
  components = false,
216
+ templates = false,
216
217
  scripts,
217
218
  } = {}) {
218
219
  const pkg = {name, version};
@@ -272,6 +273,14 @@ export default {type: 'theme', name: 'ocean', displayName: 'Ocean', description:
272
273
  'export default function Card() { return null; }\n',
273
274
  );
274
275
  }
276
+ if (templates) {
277
+ const root = path.join(tmpDir, 'templates');
278
+ fs.mkdirSync(root, {recursive: true});
279
+ fs.writeFileSync(
280
+ path.join(root, 'stray.tsx'),
281
+ 'export default function Stray() { return null; }\n',
282
+ );
283
+ }
275
284
  if (npmignore) {
276
285
  fs.writeFileSync(path.join(tmpDir, '.npmignore'), npmignore);
277
286
  }
@@ -1899,6 +1908,23 @@ describe('integrationPackCheck', () => {
1899
1908
  expect(sourceWarnings[0].message).toContain('Card.tsx');
1900
1909
  });
1901
1910
 
1911
+ it('reports template sources without metadata as warnings', async () => {
1912
+ writePackage({
1913
+ manifest:
1914
+ "export default {themes: './themes', templates: './templates'};\n",
1915
+ files: ['astryx.integration.mjs', 'themes', 'templates'],
1916
+ templates: true,
1917
+ });
1918
+ const result = await integrationPackCheck({cwd: tmpDir});
1919
+
1920
+ const sourceWarnings = result.data.issues.filter(
1921
+ issue => issue.code === 'source_without_template_doc',
1922
+ );
1923
+ expect(sourceWarnings).toHaveLength(1);
1924
+ expect(sourceWarnings[0].severity).toBe('warning');
1925
+ expect(sourceWarnings[0].message).toContain('stray.tsx');
1926
+ });
1927
+
1902
1928
  it('cleans up its scratch consumer when npm pack fails', async () => {
1903
1929
  writePackage({
1904
1930
  files: ['astryx.integration.mjs', 'themes'],
@@ -37,6 +37,8 @@ const componentDoc = name =>
37
37
  `export default {type: 'component', name: '${name}', displayName: '${name}', usage: {description: '${name}.'}, props: []};\n`;
38
38
  /** @param {string} name */
39
39
  const componentSource = name => `export function ${name}() { return null; }\n`;
40
+ const templateSource = name =>
41
+ `export default function ${name}() { return null; }\n`;
40
42
  /** @param {string} name */
41
43
  const topic = name =>
42
44
  `export default ${JSON.stringify({
@@ -1131,6 +1133,71 @@ describe('source_without_component_doc fixes hold when followed', () => {
1131
1133
  });
1132
1134
  });
1133
1135
 
1136
+ describe('source_without_template_doc fixes hold when followed', () => {
1137
+ it('adds the named doc, which resolves the warning', async () => {
1138
+ const dir = writePackage({
1139
+ [MANIFEST]: manifest({templates: './templates'}),
1140
+ 'templates/hero.tsx': templateSource('Hero'),
1141
+ 'templates/hero.test.tsx': templateSource('HeroTest'),
1142
+ });
1143
+
1144
+ const message = only(await issuesOf(dir), 'source_without_template_doc');
1145
+ expect(message).toBe(
1146
+ "Template source \"hero.tsx\" has no same-stem metadata file hero.doc.mjs, so `astryx template` never lists it. Fix: add hero.doc.mjs beside it with type: 'page' or 'block'; `astryx docs authoring integration-template-doc` lists its fields. If it is not a template, move it out of the templates root.",
1147
+ );
1148
+
1149
+ const fixed = follow(dir, {
1150
+ write: {
1151
+ 'templates/hero.doc.mjs': `export default {type: 'page', name: 'hero', displayName: 'Hero'};\n`,
1152
+ },
1153
+ });
1154
+ expect(await issuesOf(fixed)).toEqual([]);
1155
+ });
1156
+
1157
+ it('checks a dotted template id, but no test, spec or story file', async () => {
1158
+ const dir = writePackage({
1159
+ [MANIFEST]: manifest({templates: './templates'}),
1160
+ 'templates/landing.page.tsx': templateSource('LandingPage'),
1161
+ 'templates/hero.test.tsx': templateSource('HeroTest'),
1162
+ 'templates/hero.spec.tsx': templateSource('HeroSpec'),
1163
+ 'templates/hero.stories.tsx': templateSource('HeroStories'),
1164
+ });
1165
+
1166
+ const message = only(await issuesOf(dir), 'source_without_template_doc');
1167
+ expect(message).toContain(
1168
+ 'Template source "landing.page.tsx" has no same-stem metadata file landing.page.doc.mjs',
1169
+ );
1170
+
1171
+ const fixed = follow(dir, {
1172
+ write: {
1173
+ 'templates/landing.page.doc.mjs': `export default {type: 'page', name: 'landing.page', displayName: 'Landing'};\n`,
1174
+ },
1175
+ });
1176
+ expect(await issuesOf(fixed)).toEqual([]);
1177
+ });
1178
+
1179
+ it('never flags a helper in a subfolder of the templates root', async () => {
1180
+ const dir = writePackage({
1181
+ [MANIFEST]: manifest({templates: './templates'}),
1182
+ 'templates/hero.doc.mjs': `export default {type: 'page', name: 'hero', displayName: 'Hero'};\n`,
1183
+ 'templates/hero.tsx': templateSource('Hero'),
1184
+ 'templates/hero/HeroCard.tsx': templateSource('HeroCard'),
1185
+ });
1186
+
1187
+ expect(await issuesOf(dir)).toEqual([]);
1188
+ });
1189
+
1190
+ it('accepts a released .template.mjs spec as the metadata', async () => {
1191
+ const dir = writePackage({
1192
+ [MANIFEST]: manifest({templates: './templates'}),
1193
+ 'templates/hero.tsx': templateSource('Hero'),
1194
+ 'templates/hero.template.mjs': `export default {type: 'page', name: 'hero', displayName: 'Hero'};\n`,
1195
+ });
1196
+
1197
+ expect(await issuesOf(dir)).toEqual([]);
1198
+ });
1199
+ });
1200
+
1134
1201
  describe('codemod fixes hold when followed', () => {
1135
1202
  it('moves a stray codemod into a version folder, and renames a mis-named one', async () => {
1136
1203
  const dir = writePackage({
@@ -35,6 +35,7 @@ import * as fs from 'node:fs';
35
35
  import * as path from 'node:path';
36
36
  import {assertWithin} from '../../foundation/fs/path-safety.mjs';
37
37
  import {integrationDocTypes} from '../docs/_adapter.mjs';
38
+ import {integrationDocConsistency} from '../../foundation/discovery/doc-consistency.mjs';
38
39
  import {
39
40
  THEME_SLUG_RE,
40
41
  unreadThemeFolders,
@@ -332,6 +333,22 @@ async function validateAtPackageDir(
332
333
  issues.push(...(await validateLoadedIntegration(loaded)));
333
334
  if (loaded.themes && !rootProblem(loaded.themes))
334
335
  issues.push(...unreadThemeFolderIssues(packageDir, loaded));
336
+ // What the docs say that no reader serves: a prop listed twice, an
337
+ // overlay's text for a prop the doc lacks, an empty or unreachable section,
338
+ // and an overlay of no topic.
339
+ issues.push(
340
+ ...(await integrationDocConsistency(
341
+ {
342
+ components:
343
+ loaded.components && !rootProblem(loaded.components)
344
+ ? loaded.components
345
+ : undefined,
346
+ docs:
347
+ loaded.docs && !rootProblem(loaded.docs) ? loaded.docs : undefined,
348
+ },
349
+ packageDir,
350
+ )),
351
+ );
335
352
  if (scanUnreachable) {
336
353
  issues.push(
337
354
  ...(await findUnreachableContributionIssues(packageDir, loaded)),
@@ -476,9 +493,17 @@ export async function validateIntegration(pkg, options = {}) {
476
493
  validated: result.found,
477
494
  name: result.found ? (result.name ?? null) : null,
478
495
  version: result.found ? (result.version ?? null) : null,
479
- issues: result.reason === 'no_package_json'
480
- ? [{code: 'no_package', severity: 'error', message: 'No package.json found. Run this command inside a package directory.'}]
481
- : result.issues,
496
+ issues:
497
+ result.reason === 'no_package_json'
498
+ ? [
499
+ {
500
+ code: 'no_package',
501
+ severity: 'error',
502
+ message:
503
+ 'No package.json found. Run this command inside a package directory.',
504
+ },
505
+ ]
506
+ : result.issues,
482
507
  ...(docTypes ? {docTypes} : {}),
483
508
  },
484
509
  };
@@ -80,6 +80,28 @@ describe('validate-integration API', () => {
80
80
  expect(errors).toBe(0);
81
81
  });
82
82
 
83
+ it('warns, with a fix and the file, on docs no reader can serve', async () => {
84
+ const pkgDir = path.join(tmpDir, 'pkg');
85
+ writePackage(pkgDir, {
86
+ manifest: `export default { docs: './docs' };\n`,
87
+ });
88
+ fs.mkdirSync(path.join(pkgDir, 'docs'), {recursive: true});
89
+ fs.writeFileSync(
90
+ path.join(pkgDir, 'docs', 'ghost.doc.zh.mjs'),
91
+ "export default {title: 'ghost'};\n",
92
+ );
93
+
94
+ const result = await validateLocalIntegration(pkgDir);
95
+
96
+ expect(byCode(result.issues, 'orphan_doc_overlay')).toEqual([
97
+ expect.objectContaining({
98
+ severity: 'warning',
99
+ file: 'docs/ghost.doc.zh.mjs',
100
+ fix: expect.stringContaining('Delete docs/ghost.doc.zh.mjs'),
101
+ }),
102
+ ]);
103
+ });
104
+
83
105
  it('reports an unknown manifest key as a warning, and still loads the rest', async () => {
84
106
  // The manifest used to be parsed with a strict schema, so a single unknown
85
107
  // key failed the parse — and an integration whose manifest fails to parse
@@ -321,6 +343,36 @@ export default {type: 'theme', name: 'ocean', displayName: 'Ocean', description:
321
343
  );
322
344
  });
323
345
 
346
+ it('warns when a template source has no same-stem metadata, skipping test files', async () => {
347
+ const pkgDir = path.join(tmpDir, 'pkg');
348
+ writePackage(pkgDir, {
349
+ manifest: `export default { templates: './templates' };\n`,
350
+ });
351
+ fs.mkdirSync(path.join(pkgDir, 'templates'));
352
+ fs.writeFileSync(
353
+ path.join(pkgDir, 'templates', 'stray.tsx'),
354
+ 'export default function Stray() { return null; }\n',
355
+ );
356
+ fs.writeFileSync(
357
+ path.join(pkgDir, 'templates', 'stray.test.tsx'),
358
+ "import {it} from 'vitest';\nit('renders', () => {});\n",
359
+ );
360
+
361
+ const result = await validateLocalIntegration(pkgDir);
362
+
363
+ const warnings = byCode(result.issues, 'source_without_template_doc');
364
+ expect(warnings).toEqual([
365
+ expect.objectContaining({
366
+ severity: 'warning',
367
+ message: expect.stringContaining('"stray.tsx"'),
368
+ }),
369
+ ]);
370
+ expect(warnings[0].message).not.toContain('stray.test.tsx');
371
+ expect(warnings[0].message).toContain(
372
+ "Fix: add stray.doc.mjs beside it with type: 'page' or 'block'",
373
+ );
374
+ });
375
+
324
376
  it('reports codemods outside semver folders and invalid folder names', async () => {
325
377
  const pkgDir = path.join(tmpDir, 'pkg');
326
378
  writePackage(pkgDir, {
@@ -593,7 +645,10 @@ describe('integration diagnostics are read-only', () => {
593
645
  'components/Orphan.doc.mjs',
594
646
  "export default {type: 'component', name: 'Orphan', props: []};\n",
595
647
  );
596
- write('templates/dash.doc.mjs', "export default {type: 'page', name: 'Dash'};\n");
648
+ write(
649
+ 'templates/dash.doc.mjs',
650
+ "export default {type: 'page', name: 'Dash'};\n",
651
+ );
597
652
  write(
598
653
  'docs/theme.doc.mjs',
599
654
  "export default {type: 'generic', name: 'theme', title: 'Theme', description: 'x', sections: [{title: 'A', content: [{type: 'prose', text: 'x'}]}]};\n",
@@ -614,7 +669,9 @@ describe('integration diagnostics are read-only', () => {
614
669
  path.join(consumer, 'package.json'),
615
670
  JSON.stringify({name: 'consumer'}),
616
671
  );
617
- writeDiagnosedPackage(path.join(consumer, 'node_modules', '@acme', 'widgets'));
672
+ writeDiagnosedPackage(
673
+ path.join(consumer, 'node_modules', '@acme', 'widgets'),
674
+ );
618
675
  const before = {pkg: snapshot(pkgDir), consumer: snapshot(consumer)};
619
676
 
620
677
  const local = await validateIntegration(undefined, {cwd: pkgDir});
@@ -631,9 +688,13 @@ describe('integration diagnostics are read-only', () => {
631
688
  }
632
689
 
633
690
  expect(summarizeIssues(local.data.issues).errors).toBeGreaterThan(0);
634
- expect(byCode(local.data.issues, 'unreachable_contribution')).toHaveLength(1);
691
+ expect(byCode(local.data.issues, 'unreachable_contribution')).toHaveLength(
692
+ 1,
693
+ );
635
694
  expect(summarizeIssues(installed.data.issues).errors).toBeGreaterThan(0);
636
- expect({pkg: snapshot(pkgDir), consumer: snapshot(consumer)}).toEqual(before);
695
+ expect({pkg: snapshot(pkgDir), consumer: snapshot(consumer)}).toEqual(
696
+ before,
697
+ );
637
698
  });
638
699
  });
639
700
 
@@ -655,7 +716,9 @@ describe('validated separates "checked and clean" from "never checked"', () => {
655
716
  expect(validate.data.issues).toEqual([]);
656
717
 
657
718
  const templates = await integrationTemplateConflicts(undefined, {cwd: dir});
658
- const components = await integrationComponentConflicts(undefined, {cwd: dir});
719
+ const components = await integrationComponentConflicts(undefined, {
720
+ cwd: dir,
721
+ });
659
722
  const docs = await integrationDocConflicts(undefined, {cwd: dir});
660
723
  expect(templates.data.validated).toBe(false);
661
724
  expect(components.data.validated).toBe(false);
@@ -671,7 +734,9 @@ describe('validated separates "checked and clean" from "never checked"', () => {
671
734
  expect(validate.data.name).toBe('@acme/widgets');
672
735
 
673
736
  const templates = await integrationTemplateConflicts(undefined, {cwd: dir});
674
- const components = await integrationComponentConflicts(undefined, {cwd: dir});
737
+ const components = await integrationComponentConflicts(undefined, {
738
+ cwd: dir,
739
+ });
675
740
  const docs = await integrationDocConflicts(undefined, {cwd: dir});
676
741
  expect(templates.data.validated).toBe(true);
677
742
  expect(components.data.validated).toBe(true);
@@ -743,8 +808,12 @@ describe('unreadable folders are reported, never fatal', () => {
743
808
  expect(
744
809
  byCode(result.issues, 'unreadable_root').map(issue => issue.message),
745
810
  ).toEqual([
746
- expect.stringMatching(/^Declared codemods root cannot be read \(EACCES\)/),
747
- expect.stringMatching(/^Declared themes root cannot be read \(EACCES\)/),
811
+ expect.stringMatching(
812
+ /^Declared codemods root cannot be read \(EACCES\)/,
813
+ ),
814
+ expect.stringMatching(
815
+ /^Declared themes root cannot be read \(EACCES\)/,
816
+ ),
748
817
  ]);
749
818
  },
750
819
  );
@@ -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}. 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.',
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. 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.',
66
66
  },
67
67
  ],
68
68
  examples: [
@@ -129,6 +129,7 @@ import {
129
129
  import {AstryxError} from '../error.mjs';
130
130
  import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
131
131
  import {setResultCoverage} from './coverage.mjs';
132
+ import {linkSearchResponse} from '../component/_adapter.mjs';
132
133
 
133
134
  /**
134
135
  * A search candidate gathered from one content domain. Extra underscore-
@@ -2485,5 +2486,5 @@ async function searchOnce(query, options) {
2485
2486
  components.map(c => ({name: c.name, keywords: c.keywords ?? []})),
2486
2487
  );
2487
2488
  }
2488
- return response;
2489
+ return linkSearchResponse(response, cwd);
2489
2490
  }
@@ -149,7 +149,7 @@ export const docs = {
149
149
  type: 'list',
150
150
  style: 'ordered',
151
151
  items: [
152
- 'Polyfill anchor positioning. Load a CSS anchor positioning polyfill conditionally behind an `@supports` check so it costs nothing on Tier 1. This is the lowest-effort way to get correct positioning; note that polyfills may not cover every position-fallback feature.',
152
+ 'Polyfill anchor positioning. Load a CSS anchor positioning polyfill conditionally behind an `@supports` check so it costs nothing on Tier 1. This is the lowest-effort way to get correct positioning; polyfills may not cover every position-fallback feature.',
153
153
  'Provide a JS positioning fallback. Detect missing support with `CSS.supports("anchor-name", "--x")` and position layers with a measurement-based library (e.g. a floating-element positioner) when it returns false. More code, full control.',
154
154
  'Accept degraded positioning. Document for your users that on Tier 2 browsers, layered surfaces open correctly but may not sit next to their trigger. Cheapest, and often fine for internal tools on evergreen browsers.',
155
155
  ],
@@ -40,7 +40,7 @@ export const docs = {
40
40
  items: [
41
41
  'Name the topic in lowercase kebab-case, such as `deploying`. Readers type the name as a command argument, so it holds only letters, digits, `_`, and `-`.',
42
42
  'Keep the name stable: readers and links find the topic by it.',
43
- 'Pick a name that `astryx docs` does not already list: no Core topic, and no section such as `tokens` or `layout`. To take over or add to a Core topic, see {@link generic:extend-or-replace}.',
43
+ 'Pick a name `astryx docs` does not already list: no Core topic, and no section such as `tokens` or `layout`. To take over or add to a Core topic, see {@link generic:extend-or-replace}.',
44
44
  ],
45
45
  },
46
46
  ],
@@ -67,7 +67,7 @@ export const docs = {
67
67
  type: 'list',
68
68
  style: 'unordered',
69
69
  items: [
70
- 'Replace the `Overview` placeholder that `integration add` writes.',
70
+ 'Replace the `Overview` placeholder `integration add` writes.',
71
71
  'Every field is in {@link schema:reference-doc}.',
72
72
  ],
73
73
  },
@@ -96,6 +96,11 @@ docType: boolean
96
96
  "The documented `type` differs from the code's, where both read exactly",
97
97
  'Copy the type from the source, or fix the code. The next section says which types are judged',
98
98
  ],
99
+ [
100
+ '`default_mismatch`',
101
+ "The documented `default` differs from the literal default the component writes in its props destructuring, such as `size = 'md'`",
102
+ 'Copy the default from the source, quoted as code: `default: "\'md\'"`. Quotes and spacing are ignored, and a default that is not a literal on either side (a constant, a call, prose) is not compared',
103
+ ],
99
104
  ],
100
105
  },
101
106
  ],
@@ -32,12 +32,20 @@ export const docs = {
32
32
  {
33
33
  type: 'code',
34
34
  lang: 'text',
35
- code: 'Checking integration docs: @acme/astryx-widgets@1.0.0\n\n[ok] The docs tree and every link in these docs check out.\n\n[ok] No doc topics overlap with Core.\n[ok] No topic copies a passage from another.',
35
+ code: 'Checking integration docs: @acme/astryx-widgets@1.0.0\n\n[ok] The docs tree and every link in these docs check out.\n\n[ok] No doc topics overlap with Core.\n[ok] No topic copies a passage from another.\n[ok] No filler phrases or low-density topics.',
36
36
  },
37
37
  {
38
38
  type: 'prose',
39
39
  text: 'Write each fact in one topic. When two of your topics, or one of yours and a Core topic, repeat 10 or more words of prose word for word, the check lists the pair as a `copied_passage` warning. It names the topic that keeps the text (a Core topic, or of your two the one the passage fits) and the line in the other where to put the link instead ({@link generic:links}). Code and examples are not compared, and a topic may carry the text of the Core topic it replaces. A run with fewer than 4 distinct content words (words other than function words such as \"the\", \"in\" or \"it\"), or one that three or more topics share (a series lead-in), is not listed. Each listed pair is also a warning (`copied_passage`): `doctor integration docs` still exits 0, and `integration check --strict` fails until you fix it.',
40
40
  },
41
+ {
42
+ type: 'prose',
43
+ text: "Keep docs dense. The check lists, as a `doc_fluff` warning, each padding phrase in your prose, with its file line and what to write instead, and each topic of 80 or more prose words in which fewer than half the words carry content (words other than function words such as the, and, in), with its measured share and the floor of 0.5. `doctor integration docs` still exits 0, and `integration check --strict` fails until you cut it. Code, examples, and quoted text are not read. The phrases: `it\'s important to note`, `it is important to note`, `important to note that`, `it\'s worth noting`, `it is worth noting`, `worth noting that`, `it should be noted`, `please note`, `note that` (opening a sentence), `as mentioned above`, `as mentioned earlier`, `as mentioned before`, `as noted above`, `as you can see`, `needless to say`, `in order to`, `due to the fact that`, `for the purpose of`, `at this point in time`, `in other words`, `basically`, `essentially`, `obviously`.",
44
+ },
45
+ {
46
+ type: 'prose',
47
+ text: "Point at another doc with a link, never by writing `astryx docs <name>` in prose: `{@link generic:<name>}` for one of your package's topics, or `{@link @astryxdesign/cli:generic:<name>}` for a Core doc (`namespace:` for a Core namespace). The CLI prints the link as the command that opens the doc, and doctor checks that the doc exists. The check lists each written pointer to a doc that exists as a `stray_doc_pointer` warning, with the link to write instead. A command with more words, or one in a code block, is a walkthrough and is not listed.",
48
+ },
41
49
  {
42
50
  type: 'prose',
43
51
  text: 'Its arguments and exit codes are in {@link command:doctor integration docs}.',
@@ -125,7 +133,7 @@ fix: Remove \`summary\`: SingleComponentDoc has no field \`summary\`.`,
125
133
  "The folder decides the type: `ComponentDoc` in your components root, `IntegrationTemplateDoc` in your templates root, `ThemeDoc` in your themes root, and in your docs root the type the doc's `type` names. Keep the `@type` comment above each doc's export too, so your editor shows the same problems as you type.",
126
134
  'Every finding is a warning, so the exit code stays 0. With `--json`, they are in `data.docTypes.findings`.',
127
135
  'It uses the `typescript` your package installs. Where `typescript` is missing or has no JavaScript compiler API, as TypeScript 7 does, it uses `@typescript/typescript6`, the TypeScript 6 API package, if your package installs it. Without either, it prints `[skip] Docs not type-checked` and the reason.',
128
- 'Every field of every doc type is in `astryx docs authoring`.',
136
+ 'Every field of every doc type is in {@link generic:authoring}.',
129
137
  ],
130
138
  },
131
139
  ],
@@ -32,13 +32,13 @@ export const docs = {
32
32
  '`npx astryx doctor integration validate`',
33
33
  'The manifest loads, each root holds contributions the CLI can read, and each doc matches its authoring type',
34
34
  'A declared root is missing (`missing_root`), a contribution does not load (`invalid_doc`, `invalid_component`, `invalid_theme`), or two templates in the package replace one Core id (`ambiguous_template_replacement`)',
35
- "The manifest has a key this CLI does not know (`unknown_manifest_key`), or a doc field does not match the doc's authoring type: a field the type does not have, a missing required field, or a value outside the field's type. It checks docs with your installed `typescript`, or, where that is missing or has no JavaScript compiler API (TypeScript 7), with an installed `@typescript/typescript6`; without either, it prints `[skip] Docs not type-checked`. With no `astryx.integration.mjs` it prints a hint and exits 0",
35
+ "The manifest has a key this CLI does not know (`unknown_manifest_key`), or a doc field does not match the doc's authoring type: a field the type does not have, a missing required field, or a value outside the field's type. It also warns on what no reader can serve: a prop listed twice (`duplicate_prop`), a `propDescriptions` key that names no documented prop (`unknown_translated_prop`), a section with no content (`empty_section`), two sections of a topic with one key (`duplicate_section_key`), or a `.doc.zh.mjs` or `.doc.dense.mjs` overlay beside no topic file (`orphan_doc_overlay`). It checks docs with your installed `typescript`, or, where that is missing or has no JavaScript compiler API (TypeScript 7), with an installed `@typescript/typescript6`; without either, it prints `[skip] Docs not type-checked`. With no `astryx.integration.mjs` it prints a hint and exits 0",
36
36
  ],
37
37
  [
38
38
  '`npx astryx doctor integration components`',
39
39
  "No component name clashes with a Core component, each `replaces` names one Core component, and each component doc's props match the component's TypeScript props",
40
40
  'Core is not installed (`core_not_found`). In a package that declares the CLI range that turns replacement on, a `replaces` target is missing (`missing_component_replacement_target`) or invalid (`invalid_component_replacement`), or two components replace one Core component (`ambiguous_component_replacement`)',
41
- 'A name clashes with Core, a component sets `replaces` in a package without that range (`inactive_component_replacement`, plus any missing, invalid, or duplicate `replaces` reported as a warning), or a documented prop differs from the code: it is missing there (`not_in_code`), the doc omits a prop the package declares (`not_in_doc`), or its `required` (`required_mismatch`) or type (`type_mismatch`) disagrees. It reads props with your installed `typescript`; without it, it prints `[skip] Props not compared`',
41
+ 'A name clashes with Core, a component sets `replaces` in a package without that range (`inactive_component_replacement`, plus any missing, invalid, or duplicate `replaces` reported as a warning), or a documented prop differs from the code: it is missing there (`not_in_code`), the doc omits a prop the package declares (`not_in_doc`), or its `required` (`required_mismatch`), type (`type_mismatch`), or literal `default` (`default_mismatch`) disagrees, or a `{@link}` in a component doc names no doc (`invalid_doc_graph`). It reads props with your installed `typescript`; without it, it prints `[skip] Props not compared`',
42
42
  ],
43
43
  [
44
44
  '`npx astryx doctor integration templates`',
@@ -48,9 +48,9 @@ export const docs = {
48
48
  ],
49
49
  [
50
50
  '`npx astryx doctor integration docs`',
51
- 'Your docs tree, every link, topic names against Core, and passages two topics repeat word for word',
51
+ 'Your docs tree, every link, topic names against Core, passages two topics repeat word for word, padding phrases and low-density topics, and written pointers to docs',
52
52
  'A topic takes a Core topic name without `replaces` or `extends`, a doc is invalid (`invalid_doc`), or a namespace or placement fails, which hides the doc (`invalid_doc_graph`)',
53
- 'A link names no doc (`invalid_doc_graph`), or two topics repeat a passage word for word (`copied_passage`)',
53
+ 'A link names no doc (`invalid_doc_graph`), two topics repeat a passage word for word (`copied_passage`), prose pads with a listed phrase or falls under the density floor (`doc_fluff`), or prose, a description or summary, or the text of a component doc writes `astryx docs <name>` where a link would be checked (`stray_doc_pointer`)',
54
54
  ],
55
55
  [
56
56
  '`npx astryx integration check`',
@@ -23,7 +23,7 @@ export const docs = {
23
23
  content: [
24
24
  {
25
25
  type: 'prose',
26
- text: 'Export a `debug` function from `astryx.integration.mjs`, and the CLI calls it once for each command run in an app that loads your package.',
26
+ text: 'Export a `debug` function from `astryx.integration.mjs`; the CLI calls it once per command run in an app loading your package.',
27
27
  },
28
28
  {
29
29
  type: 'code',
@@ -52,11 +52,11 @@ export default {
52
52
  },
53
53
  {
54
54
  type: 'prose',
55
- text: "An app records every command only when its `astryx.config` names `integrations` or `debug`, as listing your package does. Otherwise your handler runs only for commands that load the app's project, such as `component` and `docs`, and not for `--version` or a mistyped command. In an app whose config names neither word, each of those commands also prints a warning on stderr.",
55
+ text: "An app records every command only when its `astryx.config` names `integrations` or `debug`, as listing your package does. Otherwise your handler runs only for commands loading the app's project, such as `component` and `docs`, never for `--version` or a mistyped command. In an app whose config names neither word, those commands also print a stderr warning.",
56
56
  },
57
57
  {
58
58
  type: 'prose',
59
- text: '`debug` is a named export, not a manifest field, so a CLI that does not know it ignores it and loads the rest of your manifest.',
59
+ text: '`debug` is a named export, not a manifest field, so an older CLI ignores it and loads the rest of your manifest.',
60
60
  },
61
61
  ],
62
62
  },
@@ -75,7 +75,7 @@ export default {
75
75
  },
76
76
  {
77
77
  type: 'prose',
78
- text: 'From then on, your handler no longer runs in that app.',
78
+ text: 'Your handler then no longer runs in that app.',
79
79
  },
80
80
  ],
81
81
  },
@@ -150,7 +150,7 @@ message: Rerun with --confirm-public to file this report.`,
150
150
  content: [
151
151
  {
152
152
  type: 'prose',
153
- text: "When the app has no `gapReport` handler at all, the CLI routes the report to the target package's `issuesUrl` from its manifest instead.",
153
+ text: "With no `gapReport` handler in the app, the CLI routes the report to the target package's manifest `issuesUrl`.",
154
154
  },
155
155
  {
156
156
  type: 'list',
@@ -173,14 +173,14 @@ message: Rerun with --confirm-public to file this report.`,
173
173
  content: [
174
174
  {
175
175
  type: 'prose',
176
- text: 'When an app loads packages that name their own `issuesUrl`, a report can go to the default (the handlers, or the fallback above) or to one of those packages. `astryx gap-report --list-categories` and the receipt of a report filed without `--to` list every destination, with a line telling the agent to ask the person.',
176
+ text: 'When an app loads packages naming their own `issuesUrl`, a report can go to the default (the handlers, or the fallback above) or to one of those packages. `astryx gap-report --list-categories` and the receipt of a report filed without `--to` list every destination, with a line telling the agent to ask the person.',
177
177
  },
178
178
  {
179
179
  type: 'list',
180
180
  style: 'unordered',
181
181
  items: [
182
182
  'An agent asks the person where to file. It never picks a package destination on its own.',
183
- "`--to <package>` carries the person's choice: the report goes only to that package's `issuesUrl`, under the same `--confirm-public` rule, and the handlers do not run.",
183
+ "`--to <package>` carries the person's choice: the report goes only to that package's `issuesUrl`, under the same `--confirm-public` rule, and no handler runs.",
184
184
  'Without a choice, leave out `--to`; the report goes to the default.',
185
185
  'A `--to` that names no destination fails before anything is sent and lists the destinations.',
186
186
  ],