@astryxdesign/cli 0.6.3-canary.f839b67 → 0.6.4-canary.06c8fa3

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 (189) hide show
  1. package/CHANGELOG.md +194 -0
  2. package/README.md +64 -66
  3. package/api/component/_adapter.d.mts +25 -0
  4. package/api/component/_adapter.mjs +59 -5
  5. package/api/component/component.d.mts +6 -3
  6. package/api/component/component.doc.mjs +23 -10
  7. package/api/component/component.mjs +249 -9
  8. package/api/component/component.type.d.mts +25 -0
  9. package/api/component/component.type.mjs +44 -0
  10. package/api/discover/_adapter.d.mts +114 -6
  11. package/api/discover/_adapter.mjs +372 -17
  12. package/api/discover/_adapter.test.mjs +215 -0
  13. package/api/discover/_catalog-view.d.mts +115 -0
  14. package/api/discover/_catalog-view.mjs +203 -0
  15. package/api/discover/_catalog-view.test.mjs +128 -0
  16. package/api/discover/detail/detail.d.mts +18 -6
  17. package/api/discover/detail/detail.mjs +67 -13
  18. package/api/discover/detail/detail.test.mjs +85 -0
  19. package/api/discover/detail/item/item.d.mts +26 -0
  20. package/api/discover/detail/item/item.mjs +78 -0
  21. package/api/discover/detail/item/item.test.mjs +73 -0
  22. package/api/discover/discover.d.mts +3 -9
  23. package/api/discover/discover.doc.mjs +61 -18
  24. package/api/discover/discover.mjs +220 -36
  25. package/api/discover/discover.test.mjs +11 -2
  26. package/api/discover/discover.type.d.mts +147 -8
  27. package/api/discover/discover.type.mjs +102 -12
  28. package/api/discover/list/list.d.mts +20 -6
  29. package/api/discover/list/list.mjs +45 -12
  30. package/api/discover/list/list.test.mjs +46 -0
  31. package/api/discover/search/search.d.mts +18 -16
  32. package/api/discover/search/search.mjs +102 -56
  33. package/api/discover/search/search.test.mjs +144 -10
  34. package/api/docs/_adapter.d.mts +49 -7
  35. package/api/docs/_adapter.mjs +284 -33
  36. package/api/docs/docs.doc.mjs +4 -3
  37. package/api/docs/docs.test.mjs +2 -0
  38. package/api/docs/docs.type.d.mts +21 -5
  39. package/api/docs/docs.type.mjs +21 -5
  40. package/api/docs/integration-tree.test.mjs +9 -1
  41. package/api/docs/reference-blocks.test.mjs +406 -0
  42. package/api/doctor/doctor.d.mts +8 -3
  43. package/api/doctor/doctor.mjs +95 -10
  44. package/api/doctor/doctor.test.mjs +122 -10
  45. package/api/index.d.mts +1 -2
  46. package/api/index.mjs +4 -4
  47. package/api/integration/add-helpers.d.mts +5 -2
  48. package/api/integration/add-helpers.mjs +36 -9
  49. package/api/integration/authoring-checks.mjs +14 -1
  50. package/api/integration/pack-check.lifecycle-output.test.mjs +105 -0
  51. package/api/integration/pack-check.mjs +28 -3
  52. package/api/json/index.ts +0 -1
  53. package/api/search/search.test.mjs +18 -0
  54. package/api/template/table-floating-bulk-actions.test.mjs +66 -0
  55. package/api/template/template-integration.test.mjs +1 -65
  56. package/api/template/template.mjs +1 -1
  57. package/api/theme/add/add.mjs +17 -25
  58. package/api/theme/add/add.rollback.test.mjs +158 -0
  59. package/api/theme/add/add.staging.test.mjs +40 -23
  60. package/api/theme/build/build.family.test.mjs +7 -12
  61. package/api/theme/build/build.mjs +8 -18
  62. package/api/theme/build/build.rollback.test.mjs +148 -0
  63. package/api/upgrade/run/files-changed.test.mjs +111 -0
  64. package/api/upgrade/run/run.mjs +6 -4
  65. package/api/upgrade/upgrade.type.mjs +2 -2
  66. package/assets/codemods/__tests__/registry.test.mjs +1 -0
  67. package/assets/codemods/__tests__/runner.test.mjs +3 -1
  68. package/assets/codemods/file-count.test.mjs +163 -0
  69. package/assets/codemods/integration-runner.mjs +3 -3
  70. package/assets/codemods/registry.mjs +1 -0
  71. package/assets/codemods/runner.mjs +5 -4
  72. package/assets/codemods/transforms/next/index.mjs +1 -19
  73. package/assets/codemods/transforms/v0.6.4/index.mjs +31 -0
  74. package/assets/docs/internationalization.doc.mjs +7 -5
  75. package/assets/docs/styling-libraries.doc.mjs +1 -1
  76. package/assets/docs/theme.doc.mjs +1 -1
  77. package/assets/docs/tree/component-lookups.doc.mjs +149 -0
  78. package/assets/docs/tree/integrations.doc.mjs +20 -1
  79. package/assets/templates/blocks/components/CheckboxList/CheckboxListSelectAllPattern.doc.mjs +1 -1
  80. package/assets/templates/blocks/components/CheckboxList/CheckboxListSelectAllPattern.tsx +1 -3
  81. package/assets/templates/blocks/components/InternationalizationProvider/InternationalizationProvider01ShippedLocale.tsx +1 -1
  82. package/assets/templates/blocks/components/Table/TableBulkActionsTable.doc.mjs +14 -0
  83. package/assets/templates/blocks/components/Table/TableBulkActionsTable.tsx +71 -0
  84. package/assets/templates/blocks/components/Table/TableFloatingBulkActionsTable.doc.mjs +19 -0
  85. package/assets/templates/blocks/components/Table/TableFloatingBulkActionsTable.tsx +139 -0
  86. package/authoring/config/config.doc.mjs +9 -1
  87. package/authoring/config/parse.d.mts +2 -0
  88. package/authoring/config/parse.mjs +19 -0
  89. package/authoring/config/parse.test.mjs +8 -0
  90. package/authoring/config/type.ts +13 -2
  91. package/authoring/discover/discover.doc.d.mts +13 -0
  92. package/authoring/discover/discover.doc.mjs +138 -0
  93. package/authoring/discover/parse.d.mts +24 -0
  94. package/authoring/discover/parse.mjs +128 -0
  95. package/authoring/discover/parse.test.mjs +124 -0
  96. package/authoring/discover/type.ts +87 -0
  97. package/authoring/doctypes/_schema.d.mts +72 -0
  98. package/authoring/doctypes/_schema.mjs +25 -1
  99. package/authoring/doctypes/command/command.doc.mjs +1 -1
  100. package/authoring/doctypes/command/type.ts +1 -1
  101. package/authoring/doctypes/load-contract.test.mjs +25 -0
  102. package/authoring/doctypes/reference/reference.doc.mjs +31 -4
  103. package/authoring/doctypes/reference/type.ts +20 -5
  104. package/authoring/index.d.mts +1 -0
  105. package/authoring/index.d.ts +10 -0
  106. package/authoring/index.mjs +1 -0
  107. package/clients/cli/command-result-coverage.test.mjs +7 -7
  108. package/clients/cli/commands/component/index.mjs +152 -55
  109. package/clients/cli/commands/component-batch.test.mjs +341 -0
  110. package/clients/cli/commands/component-ownership.test.mjs +89 -0
  111. package/clients/cli/commands/component.doc.mjs +23 -6
  112. package/clients/cli/commands/debug-result-summary.test.mjs +2 -2
  113. package/clients/cli/commands/discover.doc.mjs +53 -9
  114. package/clients/cli/commands/discover.mjs +393 -118
  115. package/clients/cli/commands/discover.sources.test.mjs +267 -0
  116. package/clients/cli/commands/docs.mjs +2 -2
  117. package/clients/cli/commands/docs.test.mjs +29 -0
  118. package/clients/cli/commands/doctor-integration-docs.doc.mjs +1 -1
  119. package/clients/cli/commands/text-json-parity.test.mjs +0 -17
  120. package/clients/cli/index.mjs +0 -4
  121. package/clients/cli/lib/exit-codes.test.mjs +1 -8
  122. package/clients/cli/lib/json-shim.mjs +24 -14
  123. package/clients/cli/lib/json-shim.test.mjs +6 -20
  124. package/clients/cli/lib/manifest.mjs +3 -8
  125. package/clients/cli/lib/manifest.test.mjs +5 -2
  126. package/clients/cli/lib/parse-error-format.test.mjs +81 -0
  127. package/foundation/discovery/authoring-self-docs.d.mts +12 -0
  128. package/foundation/discovery/authoring-self-docs.mjs +21 -8
  129. package/foundation/discovery/authoring-self-docs.test.mjs +7 -2
  130. package/foundation/discovery/docs-discovery.d.mts +4 -1
  131. package/foundation/discovery/docs-discovery.mjs +40 -6
  132. package/foundation/discovery/docs-discovery.test.mjs +40 -0
  133. package/foundation/discovery/template-adapter.mjs +1 -1
  134. package/foundation/doc-compiler/doc-loads.test.mjs +0 -12
  135. package/foundation/doc-compiler/lenses.d.mts +5 -3
  136. package/foundation/doc-compiler/lenses.mjs +48 -3
  137. package/foundation/doc-compiler/links.d.mts +30 -3
  138. package/foundation/doc-compiler/links.mjs +46 -5
  139. package/foundation/doc-compiler/links.test.mjs +53 -0
  140. package/foundation/doc-compiler/tree.test.mjs +9 -1
  141. package/foundation/integrations/cli-requirement.test.mjs +17 -42
  142. package/foundation/integrations/integrations.d.mts +14 -1
  143. package/foundation/integrations/integrations.mjs +41 -1
  144. package/foundation/integrations/integrations.test.mjs +31 -0
  145. package/foundation/response/batch.type.d.mts +33 -0
  146. package/foundation/response/batch.type.mjs +34 -0
  147. package/foundation/response/response-types.doc.mjs +15 -21
  148. package/foundation/response/response-types.doc.test.mjs +23 -0
  149. package/foundation/xle/browser.d.mts +3 -3
  150. package/foundation/xle/browser.mjs +3 -3
  151. package/foundation/xle/expand.mjs +2 -2
  152. package/foundation/xle/parse.mjs +1 -1
  153. package/foundation/xle/print.mjs +2 -2
  154. package/foundation/xle/splice.mjs +1 -1
  155. package/package.json +9 -9
  156. package/api/layout/_adapter.d.mts +0 -34
  157. package/api/layout/_adapter.mjs +0 -148
  158. package/api/layout/check/check.d.mts +0 -16
  159. package/api/layout/check/check.mjs +0 -40
  160. package/api/layout/expand/expand.d.mts +0 -22
  161. package/api/layout/expand/expand.mjs +0 -155
  162. package/api/layout/expand/expand.path-safety.test.mjs +0 -53
  163. package/api/layout/grammar/grammar.d.mts +0 -13
  164. package/api/layout/grammar/grammar.mjs +0 -87
  165. package/api/layout/layout.d.mts +0 -6
  166. package/api/layout/layout.mjs +0 -17
  167. package/api/layout/layout.test.mjs +0 -297
  168. package/api/layout/layout.type.d.mts +0 -89
  169. package/api/layout/layout.type.mjs +0 -103
  170. package/api/layout/layoutCheck.doc.d.mts +0 -11
  171. package/api/layout/layoutCheck.doc.mjs +0 -85
  172. package/api/layout/layoutExpand.doc.d.mts +0 -11
  173. package/api/layout/layoutExpand.doc.mjs +0 -107
  174. package/api/layout/layoutGrammar.doc.d.mts +0 -11
  175. package/api/layout/layoutGrammar.doc.mjs +0 -57
  176. package/clients/cli/commands/layout-check.doc.mjs +0 -65
  177. package/clients/cli/commands/layout-expand.doc.mjs +0 -83
  178. package/clients/cli/commands/layout-grammar.doc.mjs +0 -30
  179. package/clients/cli/commands/layout.doc.mjs +0 -34
  180. package/clients/cli/commands/layout.error-codes.test.mjs +0 -66
  181. package/clients/cli/commands/layout.exit-parity.test.mjs +0 -41
  182. package/clients/cli/commands/layout.mjs +0 -275
  183. package/clients/cli/commands/layout.path-help.test.mjs +0 -33
  184. package/clients/cli/commands/layout.stdin-cap.test.mjs +0 -47
  185. package/clients/cli/commands/layout.text-fields.test.mjs +0 -39
  186. /package/assets/codemods/transforms/{next → v0.6.4}/__tests__/migrate-native-picker-to-presentation.test.mjs +0 -0
  187. /package/assets/codemods/transforms/{next → v0.6.4}/__tests__/migrate-theme-catalog-to-descriptors.test.mjs +0 -0
  188. /package/assets/codemods/transforms/{next → v0.6.4}/migrate-native-picker-to-presentation.mjs +0 -0
  189. /package/assets/codemods/transforms/{next → v0.6.4}/migrate-theme-catalog-to-descriptors.mjs +0 -0
@@ -0,0 +1,406 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file A topic section's `reference` block (spec:AST-047 FR9). A read
5
+ * includes the doc it names from that doc's own source, narrowed by its
6
+ * projection, and still returns only the stable block kinds. A block that
7
+ * cannot include what it names fails the authoring check.
8
+ */
9
+
10
+ import * as fs from 'node:fs';
11
+ import * as path from 'node:path';
12
+ import {afterEach, beforeEach, describe, expect, it} from 'vitest';
13
+ import {docs} from './docs.mjs';
14
+ import {
15
+ builtinCatalog,
16
+ docsLinkProblems,
17
+ linkResolver,
18
+ loadDocsCatalog,
19
+ projectTree,
20
+ } from './_adapter.mjs';
21
+ import {integrationDocConflicts} from '../integration/authoring-checks.mjs';
22
+ import {checkDocsTree} from '../doctor/doctor.mjs';
23
+ import {createDocId} from '../../foundation/identity/provider-identity.mjs';
24
+ import {CLI_PROVIDER_ID} from '../../foundation/identity/providers.mjs';
25
+ import {runCli} from '../../test-utils/run-cli.mjs';
26
+
27
+ const SLOW = 60_000;
28
+
29
+ /** The block kinds a read returns: a token reference and a reference block are inlined. */
30
+ const READ_KINDS = new Set(['prose', 'heading', 'code', 'table', 'list']);
31
+
32
+ /** The primary fixture: two fields of the CLI's integration manifest schema. */
33
+ const MANIFEST_FIELDS = {
34
+ type: 'reference',
35
+ target: '@astryxdesign/cli:schema:integration',
36
+ projection: {fields: ['components', 'docs']},
37
+ };
38
+
39
+ /** A topic whose sections include canonical CLI docs. */
40
+ const SETUP = {
41
+ type: 'generic',
42
+ name: 'acme-setup',
43
+ title: 'Acme setup',
44
+ description: 'Set up the Acme kit.',
45
+ sections: [
46
+ {
47
+ id: 'manifest',
48
+ title: 'Point the manifest at your folders',
49
+ content: [
50
+ {type: 'prose', text: 'Add these fields to astryx.integration.mjs.'},
51
+ MANIFEST_FIELDS,
52
+ ],
53
+ },
54
+ {
55
+ id: 'check',
56
+ title: 'Check the docs',
57
+ content: [
58
+ {type: 'prose', text: 'Run the check before you publish.'},
59
+ {
60
+ type: 'reference',
61
+ target: '@astryxdesign/cli:command:doctor integration docs',
62
+ presentation: 'compact',
63
+ },
64
+ ],
65
+ },
66
+ {
67
+ id: 'more',
68
+ title: 'Read more',
69
+ content: [
70
+ {
71
+ type: 'reference',
72
+ target: '@astryxdesign/cli:function:docs',
73
+ presentation: 'summary',
74
+ },
75
+ {type: 'reference', target: '@astryxdesign/cli:generic:theme'},
76
+ ],
77
+ },
78
+ ],
79
+ };
80
+
81
+ /** A topic whose reference blocks each name something they cannot include. */
82
+ const BROKEN = {
83
+ type: 'generic',
84
+ name: 'acme-broken',
85
+ title: 'Acme broken',
86
+ description: 'References that include nothing.',
87
+ sections: [
88
+ {
89
+ id: 'gaps',
90
+ title: 'Gaps',
91
+ content: [
92
+ {
93
+ type: 'reference',
94
+ target: '@astryxdesign/cli:schema:integration',
95
+ projection: {fields: ['components', 'nope']},
96
+ },
97
+ {type: 'reference', target: '@astryxdesign/cli:schema:nothing'},
98
+ {
99
+ type: 'reference',
100
+ target: '@astryxdesign/cli:command:doctor',
101
+ projection: {fields: ['--json']},
102
+ },
103
+ {
104
+ type: 'reference',
105
+ target: '@astryxdesign/cli:schema:config',
106
+ projection: {sections: ['fields']},
107
+ },
108
+ {
109
+ type: 'reference',
110
+ target: '@astryxdesign/cli:generic:theme',
111
+ presentation: 'full',
112
+ },
113
+ ],
114
+ },
115
+ ],
116
+ };
117
+
118
+ /** @type {string} */
119
+ let tmpDir;
120
+
121
+ beforeEach(() => {
122
+ tmpDir = fs.mkdtempSync(path.join(process.cwd(), '.astryx-reference-test-'));
123
+ });
124
+
125
+ afterEach(() => {
126
+ fs.rmSync(tmpDir, {recursive: true, force: true});
127
+ });
128
+
129
+ /**
130
+ * A consumer project that configures `@acme/kit`, which ships these docs.
131
+ * @param {Record<string, object>} files doc file name -> doc
132
+ */
133
+ function scaffold(files) {
134
+ fs.writeFileSync(path.join(tmpDir, 'package.json'), '{"name": "consumer"}\n');
135
+ fs.writeFileSync(
136
+ path.join(tmpDir, 'astryx.config.mjs'),
137
+ "export default {integrations: ['@acme/kit']};\n",
138
+ );
139
+ const kit = path.join(tmpDir, 'node_modules', '@acme', 'kit');
140
+ fs.mkdirSync(path.join(kit, 'docs'), {recursive: true});
141
+ fs.writeFileSync(
142
+ path.join(kit, 'package.json'),
143
+ JSON.stringify({name: '@acme/kit', version: '1.0.0'}),
144
+ );
145
+ fs.writeFileSync(
146
+ path.join(kit, 'astryx.integration.mjs'),
147
+ "export default {docs: './docs'};\n",
148
+ );
149
+ for (const [file, doc] of Object.entries(files)) {
150
+ fs.writeFileSync(
151
+ path.join(kit, 'docs', file),
152
+ `export const docs = ${JSON.stringify(doc, null, 2)};\n`,
153
+ );
154
+ }
155
+ }
156
+
157
+ /**
158
+ * @param {string} topic
159
+ * @param {string} [section]
160
+ */
161
+ async function read(topic, section) {
162
+ return (await docs(topic, section, {cwd: tmpDir})).data;
163
+ }
164
+
165
+ describe('a reference block in a topic section', () => {
166
+ it(
167
+ 'includes the fields a schema reference names, then where they come from',
168
+ async () => {
169
+ scaffold({'acme-setup.doc.mjs': SETUP});
170
+ const section = await read('acme-setup', 'manifest');
171
+ expect(section.content.map(block => block.type)).toEqual([
172
+ 'prose',
173
+ 'table',
174
+ 'prose',
175
+ ]);
176
+ const table = section.content[1];
177
+ expect(table.headers).toEqual([
178
+ 'Field',
179
+ 'Type',
180
+ 'Required',
181
+ 'Description',
182
+ ]);
183
+ // The fields the block names, in the order it names them.
184
+ expect(table.rows.map(row => row[0])).toEqual(['components', 'docs']);
185
+ expect(section.content[2]).toEqual({
186
+ type: 'prose',
187
+ text: 'From Astryx Integration: `astryx docs authoring integration`',
188
+ });
189
+ },
190
+ SLOW,
191
+ );
192
+
193
+ it(
194
+ "reads the included fields from the schema's own doc, not a copy",
195
+ async () => {
196
+ scaffold({'acme-setup.doc.mjs': SETUP});
197
+ const included = (await read('acme-setup', 'manifest')).content[1].rows;
198
+ const schema = (await docs('authoring', 'integration')).data.content.find(
199
+ block => block.type === 'table',
200
+ );
201
+ expect(included).toEqual(
202
+ MANIFEST_FIELDS.projection.fields.map(name =>
203
+ schema.rows.find(row => row[0] === name),
204
+ ),
205
+ );
206
+ },
207
+ SLOW,
208
+ );
209
+
210
+ it(
211
+ 'returns only the stable block kinds in every read, in JSON and in each language',
212
+ async () => {
213
+ scaffold({'acme-setup.doc.mjs': SETUP});
214
+ for (const lang of [null, 'zh']) {
215
+ const whole = (await docs('acme-setup', undefined, {cwd: tmpDir, lang}))
216
+ .data;
217
+ const kinds = new Set(
218
+ whole.sections.flatMap(section => section.content.map(b => b.type)),
219
+ );
220
+ expect([...kinds].filter(kind => !READ_KINDS.has(kind))).toEqual([]);
221
+ for (const {id} of whole.sections) {
222
+ const one = (await docs('acme-setup', id, {cwd: tmpDir, lang})).data;
223
+ expect(one.content.every(block => READ_KINDS.has(block.type))).toBe(
224
+ true,
225
+ );
226
+ }
227
+ }
228
+ },
229
+ SLOW,
230
+ );
231
+
232
+ it(
233
+ 'includes a whole command doc, without code when compact; a summary and a topic show as one line',
234
+ async () => {
235
+ scaffold({'acme-setup.doc.mjs': SETUP});
236
+ const check = (await read('acme-setup', 'check')).content;
237
+ expect(check.some(block => block.type === 'code')).toBe(false);
238
+ expect(check.find(block => block.type === 'table')?.headers).toEqual([
239
+ 'Argument',
240
+ 'Description',
241
+ ]);
242
+ // The included doc's own links resolve against its own provider.
243
+ expect(
244
+ check.some(
245
+ block =>
246
+ block.type === 'prose' &&
247
+ block.text.includes(
248
+ 'Read it with `astryx docs cli/api/functions/integration-doc-conflicts`.',
249
+ ),
250
+ ),
251
+ ).toBe(true);
252
+ expect(check.at(-1)).toEqual({
253
+ type: 'prose',
254
+ text: 'From astryx doctor integration docs: `astryx docs cli/commands/doctor-integration-docs`',
255
+ });
256
+ const more = (await read('acme-setup', 'more')).content;
257
+ expect(more).toHaveLength(2);
258
+ expect(more[0].text).toMatch(
259
+ /^docs\(\): Read the reference docs: .* Read it with `astryx docs cli\/api\/functions\/docs`\.$/,
260
+ );
261
+ expect(more[1].text).toMatch(
262
+ /^Theme System: .* Read it with `astryx docs theme`\.$/,
263
+ );
264
+ },
265
+ SLOW,
266
+ );
267
+
268
+ it(
269
+ 'prints the included content in text',
270
+ async () => {
271
+ scaffold({'acme-setup.doc.mjs': SETUP});
272
+ const {status, stdout} = await runCli(
273
+ ['docs', 'acme-setup', 'manifest'],
274
+ tmpDir,
275
+ );
276
+ expect(status).toBe(0);
277
+ expect(stdout).toMatch(/^Field +\| Type +\| Required +\| Description/m);
278
+ expect(stdout).toMatch(/^components +\| string +\| no +\| /m);
279
+ expect(stdout).toContain(
280
+ 'From Astryx Integration: `astryx docs authoring integration`',
281
+ );
282
+ },
283
+ SLOW,
284
+ );
285
+ });
286
+
287
+ describe('a reference block that includes what it names', () => {
288
+ it(
289
+ 'passes the authoring check',
290
+ async () => {
291
+ scaffold({'acme-setup.doc.mjs': SETUP});
292
+ const {data} = await integrationDocConflicts('@acme/kit', {cwd: tmpDir});
293
+ expect(data.issues).toEqual([]);
294
+ const cli = await runCli(
295
+ ['doctor', 'integration', 'docs', '@acme/kit'],
296
+ tmpDir,
297
+ );
298
+ expect(cli.status).toBe(0);
299
+ },
300
+ SLOW,
301
+ );
302
+ });
303
+
304
+ describe('what a reference block names', () => {
305
+ it('resolves a CLI authoring schema by identity, to its section of `astryx docs authoring`', async () => {
306
+ const resolve = await linkResolver(builtinCatalog(), CLI_PROVIDER_ID);
307
+ expect(await resolve('schema:integration')).toMatchObject({
308
+ id: createDocId(CLI_PROVIDER_ID, 'schema', 'integration'),
309
+ route: 'authoring',
310
+ title: 'Astryx Integration',
311
+ command: 'astryx docs authoring integration',
312
+ });
313
+ const opened = await docs('authoring', 'integration');
314
+ expect(opened.type).toBe('docs.detail.section');
315
+ expect(opened.data.id).toBe('integration');
316
+ });
317
+
318
+ it(
319
+ "leaves no reference in the CLI's own docs that cannot include what it names",
320
+ async () => {
321
+ const catalog = builtinCatalog();
322
+ expect(
323
+ await docsLinkProblems(catalog, await projectTree(catalog), {
324
+ references: true,
325
+ }),
326
+ ).toEqual([]);
327
+ },
328
+ SLOW,
329
+ );
330
+ });
331
+
332
+ describe('a reference block that cannot include what it names', () => {
333
+ it(
334
+ 'fails the authoring check, once for each part it cannot include',
335
+ async () => {
336
+ scaffold({'acme-broken.doc.mjs': BROKEN});
337
+ const {data} = await integrationDocConflicts('@acme/kit', {cwd: tmpDir});
338
+ const errors = data.issues.filter(
339
+ issue => issue.code === 'invalid_doc_reference',
340
+ );
341
+ expect(errors.every(issue => issue.severity === 'error')).toBe(true);
342
+ const messages = errors.map(issue => issue.message);
343
+ expect(messages).toHaveLength(5);
344
+ expect(messages[0]).toMatch(
345
+ /^acme-broken § gaps: projection\.fields: "nope" is not a field of Astryx Integration/,
346
+ );
347
+ expect(messages[1]).toMatch(
348
+ /"@astryxdesign\/cli:schema:nothing" names no doc/,
349
+ );
350
+ expect(messages[2]).toMatch(
351
+ /projection\.fields: names the fields of a schema doc/,
352
+ );
353
+ expect(messages[3]).toMatch(/projection\.sections: /);
354
+ expect(messages[4]).toMatch(
355
+ /"@astryxdesign\/cli:generic:theme" is a topic/,
356
+ );
357
+ // They are not also reported as links that print as written.
358
+ expect(
359
+ data.issues.filter(issue => issue.code === 'invalid_doc_graph'),
360
+ ).toEqual([]);
361
+ const cli = await runCli(
362
+ ['doctor', 'integration', 'docs', '@acme/kit'],
363
+ tmpDir,
364
+ );
365
+ expect(cli.status).toBe(1);
366
+ },
367
+ SLOW,
368
+ );
369
+
370
+ it(
371
+ 'marks the missing content where a read would show it',
372
+ async () => {
373
+ scaffold({'acme-broken.doc.mjs': BROKEN});
374
+ const texts = (await read('acme-broken', 'gaps')).content
375
+ .filter(block => block.type === 'prose')
376
+ .map(block => block.text);
377
+ expect(texts).toContain(
378
+ '[reference: field "nope" not found in "@astryxdesign/cli:schema:integration"]',
379
+ );
380
+ expect(texts).toContain(
381
+ '[reference: "@astryxdesign/cli:schema:nothing" names no doc]',
382
+ );
383
+ // The field it could include is still there.
384
+ const table = (await read('acme-broken', 'gaps')).content.find(
385
+ block => block.type === 'table',
386
+ );
387
+ expect(table.rows.map(row => row[0])).toEqual(['components']);
388
+ },
389
+ SLOW,
390
+ );
391
+
392
+ it(
393
+ "warns in a project's doctor, which an app cannot fix",
394
+ async () => {
395
+ scaffold({'acme-broken.doc.mjs': BROKEN});
396
+ const check = await checkDocsTree({
397
+ docsCatalog: await loadDocsCatalog(tmpDir),
398
+ });
399
+ expect(check.status).toBe('warn');
400
+ expect(check.message).toContain(
401
+ '"nope" is not a field of Astryx Integration',
402
+ );
403
+ },
404
+ SLOW,
405
+ );
406
+ });
@@ -257,15 +257,20 @@ export type DoctorContext = {
257
257
  * could not be built, when it could not.
258
258
  */
259
259
  docsCatalogError?: string | null | undefined;
260
- /**
261
- * Combined project-level integration issues, including cross-package template replacement warnings.
262
- */
263
260
  integrationIssues?: {
264
261
  package: string;
265
262
  code: string;
266
263
  severity: "warning" | "error";
267
264
  message: string;
268
265
  }[] | null | undefined;
266
+ /**
267
+ * installed dependencies whose integration manifest could not be loaded
268
+ * Combined project-level integration issues, including cross-package template replacement warnings.
269
+ */
270
+ autolinkFailures?: {
271
+ spec: string;
272
+ error: string;
273
+ }[] | null | undefined;
269
274
  /**
270
275
  * - Error thrown while resolving the config
271
276
  * path (e.g. multiple config files present), surfaced by checkConfig as a FAIL.
@@ -26,7 +26,11 @@ import * as path from 'node:path';
26
26
  import {MIN_NODE_VERSION, isNodeVersionSupported} from '../../foundation/env/node-version.mjs';
27
27
  import {CLI_ROOT, findCoreDir, findInstalledPackage} from '../../foundation/fs/paths.mjs';
28
28
  import {explainPackageManager, getCliInvocation} from '../../foundation/env/package-manager.mjs';
29
- import {findConfigPath, Project} from '../../foundation/config/project.mjs';
29
+ import {
30
+ findConfigPath,
31
+ Project,
32
+ providerLedgerOf,
33
+ } from '../../foundation/config/project.mjs';
30
34
  import {DocsCatalog} from '../../foundation/discovery/docs-discovery.mjs';
31
35
  import {buildDocsIndexData} from '../../foundation/discovery/docs-section-key.mjs';
32
36
  import {
@@ -76,6 +80,8 @@ import {semverCompare, isValidSemver, satisfiesRange} from '../../foundation/env
76
80
  * @property {string|null} [docsCatalogError] - Why the project's docs catalog
77
81
  * could not be built, when it could not.
78
82
  * @property {Array<{package: string, code: string, severity: 'warning'|'error', message: string}>|null} [integrationIssues]
83
+ * @property {Array<{spec: string, error: string}>|null} [autolinkFailures]
84
+ * installed dependencies whose integration manifest could not be loaded
79
85
  * Combined project-level integration issues, including cross-package template replacement warnings.
80
86
  * @property {Error|null} [configError] - Error thrown while resolving the config
81
87
  * path (e.g. multiple config files present), surfaced by checkConfig as a FAIL.
@@ -417,6 +423,9 @@ export function checkImplicitIntegrations(ctx) {
417
423
  const implicit = ctx.integrations.filter(
418
424
  integration => integration.__autolinked,
419
425
  );
426
+ // A dependency whose manifest cannot be loaded leaves no loaded record, so
427
+ // without this line doctor would say no dependency ships a manifest at all.
428
+ const unreadable = describeUnreadableManifests(ctx.autolinkFailures ?? []);
420
429
 
421
430
  if (implicit.length === 0) {
422
431
  return {
@@ -424,9 +433,12 @@ export function checkImplicitIntegrations(ctx) {
424
433
  label,
425
434
  status: 'info',
426
435
  message:
427
- ctx.integrations.length > 0
436
+ (ctx.integrations.length > 0
428
437
  ? 'None — every loaded integration is named in astryx.config.'
429
- : 'None — no installed dependency ships an astryx.integration.* manifest.',
438
+ : unreadable
439
+ ? 'None loaded.'
440
+ : 'None — no installed dependency ships an astryx.integration.* manifest.') +
441
+ unreadable,
430
442
  };
431
443
  }
432
444
 
@@ -439,11 +451,25 @@ export function checkImplicitIntegrations(ctx) {
439
451
  integration.__spec && integration.__spec !== integration.name
440
452
  ? ` (declared as "${integration.__spec}")`
441
453
  : '';
442
- const roots = ['components', 'templates', 'themes', 'docs', 'codemods'].filter(
454
+ // A declared root counts only when it exists: the manifest's keys are a
455
+ // claim, and `integration-issues` reports the ones that are not true.
456
+ const declared = ['components', 'templates', 'themes', 'docs', 'codemods'].filter(
443
457
  root => integration[/** @type {'components'} */ (root)],
444
458
  );
459
+ const missing = declared.filter(root => {
460
+ const dir = integration[/** @type {'components'} */ (root)];
461
+ if (typeof dir !== 'string') return false;
462
+ const base =
463
+ typeof integration.__packageDir === 'string'
464
+ ? integration.__packageDir
465
+ : (ctx.cwd ?? process.cwd());
466
+ return !fs.existsSync(path.isAbsolute(dir) ? dir : path.resolve(base, dir));
467
+ });
468
+ const roots = declared.filter(root => !missing.includes(root));
445
469
  const contributes = roots.length > 0 ? roots.join(', ') : 'nothing';
446
- return `${integration.name}${version}${alias} from ${integration.__dependencyField}, contributing ${contributes}`;
470
+ const absent =
471
+ missing.length > 0 ? ` (declared ${missing.join(', ')} missing on disk)` : '';
472
+ return `${integration.name}${version}${alias} from ${integration.__dependencyField}, contributing ${contributes}${absent}`;
447
473
  });
448
474
 
449
475
  const plural = implicit.length === 1 ? '' : 's';
@@ -453,7 +479,8 @@ export function checkImplicitIntegrations(ctx) {
453
479
  status: 'info',
454
480
  message:
455
481
  `${implicit.length} integration${plural} loaded from installed ` +
456
- `dependencies with no astryx.config entry: ${described.join('; ')}.`,
482
+ `dependencies with no astryx.config entry: ${described.join('; ')}.` +
483
+ unreadable,
457
484
  fix:
458
485
  'Nothing to fix. Keep these dependencies installed. The CLI links them ' +
459
486
  'from package.json, so an unused-dependency check that looks only for ' +
@@ -462,6 +489,30 @@ export function checkImplicitIntegrations(ctx) {
462
489
  };
463
490
  }
464
491
 
492
+ /**
493
+ * The sentence `implicit-integrations` adds for dependencies whose manifest
494
+ * could not be loaded, or '' when there are none. Still informational: the
495
+ * package is a dependency's own bug, which `doctor integration validate`
496
+ * diagnoses, but doctor must not report it as absent.
497
+ * @param {Array<{spec: string, error: string}>} failures
498
+ * @returns {string}
499
+ */
500
+ function describeUnreadableManifests(failures) {
501
+ if (failures.length === 0) return '';
502
+ const one = failures.length === 1;
503
+ const listed = failures
504
+ .map(({spec, error}) => {
505
+ const reason = String(error).split('\n')[0].slice(0, 160);
506
+ return `${spec} (${reason})`;
507
+ })
508
+ .join('; ');
509
+ return (
510
+ ` ${failures.length} installed ${one ? 'dependency ships' : 'dependencies ship'} ` +
511
+ `an astryx.integration.* manifest that could not be loaded, so ${one ? 'it contributes' : 'they contribute'} ` +
512
+ `nothing: ${listed}. Run \`astryx doctor integration validate <package>\` for details.`
513
+ );
514
+ }
515
+
465
516
  /**
466
517
  * Check 7 — agent docs exist and contain the Astryx section markers.
467
518
  * @param {DoctorContext} ctx
@@ -738,12 +789,26 @@ export function checkProviderIdentity(ctx) {
738
789
  integration =>
739
790
  integration.providerId != null && integration.__loadError == null,
740
791
  ).length;
792
+ // An integration that could not be read has no provider ID to check, so the
793
+ // count above is not a complete survey. Say so instead of counting silently.
794
+ const unread = ctx.integrations.filter(
795
+ integration => integration.__loadError != null,
796
+ ).length;
797
+ const unreadNote =
798
+ unread === 0
799
+ ? ''
800
+ : unread === 1
801
+ ? ' 1 loaded integration could not be read, so its provider ID is unknown.'
802
+ : ` ${unread} loaded integrations could not be read, so their provider IDs are unknown.`;
741
803
  if (count === 0) {
742
804
  return {
743
805
  id,
744
806
  label,
745
807
  status: 'info',
746
- message: 'None — no loaded integration has a provider identity.',
808
+ message:
809
+ (unread === 0
810
+ ? 'None — no loaded integration has a provider identity.'
811
+ : 'No readable integration has a provider identity.') + unreadNote,
747
812
  };
748
813
  }
749
814
  return {
@@ -751,9 +816,10 @@ export function checkProviderIdentity(ctx) {
751
816
  label,
752
817
  status: 'pass',
753
818
  message:
754
- count === 1
819
+ (count === 1
755
820
  ? '1 loaded integration has its own provider ID.'
756
- : `${count} loaded integrations each have their own provider ID.`,
821
+ : `${count} loaded integrations each have their own provider ID.`) +
822
+ unreadNote,
757
823
  };
758
824
  }
759
825
 
@@ -1032,13 +1098,17 @@ export async function checkDocsTree(_ctx, options = {}) {
1032
1098
  }
1033
1099
  }
1034
1100
  // Every link between docs names a doc that exists (spec:AST-047 FR9):
1035
- // typed fields, reference and workflow blocks, and inline links.
1101
+ // typed fields, reference and workflow blocks, and inline links. A
1102
+ // reference block also includes all it names.
1036
1103
  for (const node of tree.nodes.values()) {
1037
1104
  for (const edge of typedEdges(tree, node).unresolved) {
1038
1105
  problems.push(`${node.route}: ${edge}`);
1039
1106
  }
1040
1107
  }
1041
1108
  problems.push(...(await docsLinkProblems(catalog, tree)));
1109
+ problems.push(
1110
+ ...(await docsLinkProblems(catalog, tree, {references: true})),
1111
+ );
1042
1112
  }
1043
1113
  // New findings warn: a project that passed before keeps passing
1044
1114
  // (0.6 compatibility), and the warning names what to fix.
@@ -1194,11 +1264,25 @@ export async function runChecks(options = {}) {
1194
1264
  let docsCatalogError = null;
1195
1265
  /** @type {Array<{package: string, code: string, severity: 'warning'|'error', message: string}>|null} */
1196
1266
  let integrationIssues = null;
1267
+ /** @type {Array<{spec: string, error: string}>|null} */
1268
+ let autolinkFailures = null;
1197
1269
  try {
1198
1270
  const project = await Project.load(cwd);
1199
1271
  configTheme =
1200
1272
  /** @type {{theme?: string}} */ (project.config ?? {}).theme ?? null;
1201
1273
  integrations = project.loadedIntegrations;
1274
+ // An installed dependency whose manifest cannot be loaded is kept out of
1275
+ // loadedIntegrations on purpose. The provider ledger still records it.
1276
+ autolinkFailures = [...providerLedgerOf(project).values()]
1277
+ .filter(
1278
+ entry =>
1279
+ entry.outcome === 'load-failed' &&
1280
+ entry.candidate.source === 'autolinked',
1281
+ )
1282
+ .map(entry => ({
1283
+ spec: entry.candidate.spec ?? entry.label,
1284
+ error: entry.error ?? 'its manifest could not be loaded',
1285
+ }));
1202
1286
  try {
1203
1287
  docsCatalog = await project.docs();
1204
1288
  docsCatalogIssues = (await project.issues()).filter(
@@ -1225,6 +1309,7 @@ export async function runChecks(options = {}) {
1225
1309
  docsCatalogIssues,
1226
1310
  docsCatalogError,
1227
1311
  integrationIssues,
1312
+ autolinkFailures,
1228
1313
  configError,
1229
1314
  };
1230
1315