@astryxdesign/cli 0.6.3-canary.ee13359 → 0.6.3-canary.eedc844

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 (77) hide show
  1. package/README.md +3 -3
  2. package/api/build/_adapter.d.mts +50 -0
  3. package/api/build/_adapter.mjs +60 -0
  4. package/api/build/build.doc.mjs +13 -7
  5. package/api/build/build.test.mjs +184 -6
  6. package/api/build/build.type.d.mts +57 -2
  7. package/api/build/build.type.mjs +30 -7
  8. package/api/build/help/help.d.mts +4 -0
  9. package/api/build/help/help.mjs +24 -11
  10. package/api/build/kit/kit.d.mts +4 -1
  11. package/api/build/kit/kit.mjs +165 -49
  12. package/api/build/kit/rank.d.mts +44 -0
  13. package/api/build/kit/rank.mjs +432 -0
  14. package/api/build/kit/rank.test.mjs +196 -0
  15. package/api/docs/_adapter.d.mts +49 -7
  16. package/api/docs/_adapter.mjs +284 -33
  17. package/api/docs/docs.doc.mjs +4 -3
  18. package/api/docs/docs.type.d.mts +21 -5
  19. package/api/docs/docs.type.mjs +21 -5
  20. package/api/docs/integration-tree.test.mjs +9 -1
  21. package/api/docs/reference-blocks.test.mjs +406 -0
  22. package/api/doctor/doctor.mjs +5 -1
  23. package/api/integration/authoring-checks.mjs +56 -23
  24. package/api/integration/authoring-checks.test.mjs +8 -1
  25. package/api/integration/authoring-checks.type.d.mts +1 -3
  26. package/api/integration/authoring-checks.type.mjs +7 -4
  27. package/api/integration/integrationTemplateConflicts.doc.d.mts +3 -0
  28. package/api/integration/integrationTemplateConflicts.doc.mjs +8 -6
  29. package/api/integration/template-conflict-compatibility.test.mjs +73 -0
  30. package/api/search/search.d.mts +33 -0
  31. package/api/search/search.mjs +134 -42
  32. package/api/template/table-floating-bulk-actions.test.mjs +66 -0
  33. package/api/template/template-integration.test.mjs +50 -0
  34. package/assets/docs/layout.doc.dense.mjs +2 -2
  35. package/assets/docs/layout.doc.mjs +1 -1
  36. package/assets/docs/working-with-ai.doc.mjs +3 -3
  37. package/assets/templates/blocks/components/CheckboxList/CheckboxListSelectAllPattern.doc.mjs +1 -1
  38. package/assets/templates/blocks/components/CheckboxList/CheckboxListSelectAllPattern.tsx +1 -3
  39. package/assets/templates/blocks/components/Table/TableBulkActionsTable.doc.mjs +14 -0
  40. package/assets/templates/blocks/components/Table/TableBulkActionsTable.tsx +71 -0
  41. package/assets/templates/blocks/components/Table/TableFloatingBulkActionsTable.doc.mjs +19 -0
  42. package/assets/templates/blocks/components/Table/TableFloatingBulkActionsTable.tsx +139 -0
  43. package/authoring/doctypes/_schema.d.mts +72 -0
  44. package/authoring/doctypes/_schema.mjs +25 -1
  45. package/authoring/doctypes/load-contract.test.mjs +25 -0
  46. package/authoring/doctypes/reference/reference.doc.mjs +31 -4
  47. package/authoring/doctypes/reference/type.ts +20 -5
  48. package/clients/cli/commands/build.doc.mjs +11 -6
  49. package/clients/cli/commands/build.mjs +105 -70
  50. package/clients/cli/commands/build.text-fields.test.mjs +41 -0
  51. package/clients/cli/commands/docs.mjs +2 -2
  52. package/clients/cli/commands/doctor-integration-docs.doc.mjs +1 -1
  53. package/clients/cli/commands/doctor-integration.test.mjs +7 -0
  54. package/clients/cli/commands/doctor.mjs +39 -17
  55. package/foundation/agent-docs/agent-docs.d.mts +3 -2
  56. package/foundation/agent-docs/agent-docs.mjs +12 -9
  57. package/foundation/agent-docs/agent-docs.test.mjs +9 -0
  58. package/foundation/discovery/authoring-self-docs.d.mts +12 -0
  59. package/foundation/discovery/authoring-self-docs.mjs +20 -8
  60. package/foundation/discovery/authoring-self-docs.test.mjs +7 -2
  61. package/foundation/discovery/docs-discovery.d.mts +4 -1
  62. package/foundation/discovery/docs-discovery.mjs +40 -6
  63. package/foundation/discovery/docs-discovery.test.mjs +40 -0
  64. package/foundation/discovery/template-conflict-release.d.mts +13 -0
  65. package/foundation/discovery/template-conflict-release.mjs +40 -0
  66. package/foundation/discovery/template-conflict-release.test.mjs +40 -0
  67. package/foundation/doc-compiler/lenses.d.mts +5 -3
  68. package/foundation/doc-compiler/lenses.mjs +48 -3
  69. package/foundation/doc-compiler/links.d.mts +30 -3
  70. package/foundation/doc-compiler/links.mjs +46 -5
  71. package/foundation/doc-compiler/links.test.mjs +53 -0
  72. package/foundation/integrations/cli-requirement.test.mjs +17 -42
  73. package/foundation/response/response-types.doc.d.mts +5 -1
  74. package/foundation/response/response-types.doc.mjs +8 -4
  75. package/foundation/text/string-utils.d.mts +8 -0
  76. package/foundation/text/string-utils.mjs +18 -0
  77. package/package.json +9 -9
@@ -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
+ });
@@ -1032,13 +1032,17 @@ export async function checkDocsTree(_ctx, options = {}) {
1032
1032
  }
1033
1033
  }
1034
1034
  // Every link between docs names a doc that exists (spec:AST-047 FR9):
1035
- // typed fields, reference and workflow blocks, and inline links.
1035
+ // typed fields, reference and workflow blocks, and inline links. A
1036
+ // reference block also includes all it names.
1036
1037
  for (const node of tree.nodes.values()) {
1037
1038
  for (const edge of typedEdges(tree, node).unresolved) {
1038
1039
  problems.push(`${node.route}: ${edge}`);
1039
1040
  }
1040
1041
  }
1041
1042
  problems.push(...(await docsLinkProblems(catalog, tree)));
1043
+ problems.push(
1044
+ ...(await docsLinkProblems(catalog, tree, {references: true})),
1045
+ );
1042
1046
  }
1043
1047
  // New findings warn: a project that passed before keeps passing
1044
1048
  // (0.6 compatibility), and the warning names what to fix.
@@ -4,12 +4,21 @@
4
4
  * @file Integration authoring diagnostics against the built-in Core catalog.
5
5
  *
6
6
  * Templates may intentionally replace Core identities; undeclared same-id
7
- * overlaps stay fail-closed and require package selection. Docs have explicit
8
- * `replaces` / `extends` relationships with parallel validation semantics.
7
+ * overlaps stay fail-closed and require package selection. The CLI package
8
+ * version gates replacement-specific fields so 0.6.x keeps its released shape.
9
+ * Docs have explicit `replaces` / `extends` relationships with parallel
10
+ * validation semantics.
11
+ *
12
+ * @input Integration packages, built-in catalogs, and the CLI release boundary.
13
+ * @output Typed template, component, and documentation authoring diagnostics.
14
+ * @position Public integration-authoring API over private discovery adapters.
9
15
  */
10
16
 
11
17
  import {getCliInvocation} from '../../foundation/env/package-manager.mjs';
12
- import {packageDocsProblems} from '../docs/_adapter.mjs';
18
+ import {
19
+ packageDocsProblems,
20
+ packageReferenceProblems,
21
+ } from '../docs/_adapter.mjs';
13
22
  import {findCoreDir} from '../../foundation/fs/paths.mjs';
14
23
  import {
15
24
  discoverIntegrationComponents,
@@ -24,6 +33,7 @@ import {
24
33
  discoverCoreTemplates,
25
34
  discoverIntegrationTemplatesForOne,
26
35
  } from '../../foundation/discovery/template-adapter.mjs';
36
+ import {expandedTemplateConflictSchemaActive} from '../../foundation/discovery/template-conflict-release.mjs';
27
37
  import {
28
38
  validateInstalledIntegration,
29
39
  validateLocalIntegration,
@@ -99,6 +109,7 @@ export async function integrationTemplateConflicts(pkg, options = {}) {
99
109
  ]);
100
110
  addErrors(issues, errors, 'invalid_template');
101
111
 
112
+ const expandedConflictSchema = expandedTemplateConflictSchemaActive();
102
113
  const replacementResolution = applyTemplateReplacements(
103
114
  [...coreTemplates, ...templates],
104
115
  errors.filter(error => error.replacementTarget != null),
@@ -144,21 +155,29 @@ export async function integrationTemplateConflicts(pkg, options = {}) {
144
155
  const sameIdCore = coreById.get(template.dirName);
145
156
  const replacementIsActive = activeReplacementIds.has(template.dirName);
146
157
 
147
- if (replacementIsActive && template.replaces != null) {
148
- conflicts.push({
149
- id: template.dirName,
150
- severity: 'info',
151
- relationship: 'replaces',
152
- replaces: template.replaces,
153
- integrationPackage: name,
154
- integrationType: template.type,
155
- integrationName: template.name,
156
- coreMatches: coreById.get(template.replaces) ?? [],
157
- message:
158
- `Intentional replacement: "${template.dirName}" replaces the Core template ` +
159
- `"${template.replaces}" for unqualified lookup.`,
160
- command: `${run} template ${shellArg(template.replaces)} --package ${shellArg('@astryxdesign/core')}`,
161
- });
158
+ if (
159
+ expandedConflictSchema &&
160
+ replacementIsActive &&
161
+ template.replaces != null
162
+ ) {
163
+ // This branch is unreachable before the package reaches 0.7.0. Keep the
164
+ // published 0.6.x conflict typedef narrow until the activation change.
165
+ conflicts.push(
166
+ /** @type {any} */ ({
167
+ id: template.dirName,
168
+ severity: 'info',
169
+ relationship: 'replaces',
170
+ replaces: template.replaces,
171
+ integrationPackage: name,
172
+ integrationType: template.type,
173
+ integrationName: template.name,
174
+ coreMatches: coreById.get(template.replaces) ?? [],
175
+ message:
176
+ `Intentional replacement: "${template.dirName}" replaces the Core template ` +
177
+ `"${template.replaces}" for unqualified lookup.`,
178
+ command: `${run} template ${shellArg(template.replaces)} --package ${shellArg('@astryxdesign/core')}`,
179
+ }),
180
+ );
162
181
  }
163
182
 
164
183
  if (
@@ -174,20 +193,24 @@ export async function integrationTemplateConflicts(pkg, options = {}) {
174
193
  conflicts.push({
175
194
  id: template.dirName,
176
195
  severity: 'warning',
177
- relationship: 'accidental',
196
+ ...(expandedConflictSchema ? {relationship: 'accidental'} : {}),
178
197
  integrationPackage: name,
179
198
  integrationType: template.type,
180
199
  integrationName: template.name,
181
200
  coreMatches: sameIdCore,
182
- message: compatibleKind
183
- ? `Template id "${template.dirName}" conflicts with Core (${coreKinds}). Consider renaming it, or set replaces: ${JSON.stringify(template.dirName)} in its metadata to replace the Core template.`
184
- : `Template id "${template.dirName}" conflicts with Core (${coreKinds}), but a ${template.type} template cannot replace a different template kind. Rename the integration template.`,
201
+ message: expandedConflictSchema
202
+ ? compatibleKind
203
+ ? `Template id "${template.dirName}" conflicts with Core (${coreKinds}). Consider renaming it, or set replaces: ${JSON.stringify(template.dirName)} in its metadata to replace the Core template.`
204
+ : `Template id "${template.dirName}" conflicts with Core (${coreKinds}), but a ${template.type} template cannot replace a different template kind. Rename the integration template.`
205
+ : `Template id "${template.dirName}" conflicts with Core (${coreKinds}). Consider renaming the integration template. If you keep it, always select it with --package.`,
185
206
  command: `${run} template ${shellArg(template.dirName)} --package ${shellArg(name)}`,
186
207
  });
187
208
  }
188
209
  }
189
210
  conflicts.sort((a, b) =>
190
- `${a.id}:${a.relationship}`.localeCompare(`${b.id}:${b.relationship}`),
211
+ `${a.id}:${'relationship' in a ? a.relationship : ''}`.localeCompare(
212
+ `${b.id}:${'relationship' in b ? b.relationship : ''}`,
213
+ ),
191
214
  );
192
215
 
193
216
  return {
@@ -351,6 +374,16 @@ export async function integrationDocConflicts(pkg, options = {}) {
351
374
  )) {
352
375
  issues.push({code: 'invalid_doc_graph', severity: 'warning', message});
353
376
  }
377
+
378
+ // A reference block includes content rather than linking to it, so one
379
+ // that cannot include what it names loses that content for every reader:
380
+ // an error, where a link that names no doc still prints as written.
381
+ for (const message of await packageReferenceProblems(
382
+ /** @type {{name: string}} */ (resolved.integration),
383
+ discovered,
384
+ )) {
385
+ issues.push({code: 'invalid_doc_reference', severity: 'error', message});
386
+ }
354
387
  }
355
388
 
356
389
  return {
@@ -2,9 +2,16 @@
2
2
 
3
3
  /**
4
4
  * @file Hermetic integration authoring checks against the real Core catalogs.
5
+ * @input Integration fixtures and the post-0.7 conflict projection.
6
+ * @output Coverage for replacement validation and public diagnostics.
7
+ * @position Unit coverage; the 0.6.x compatibility shape has its own fixture.
5
8
  */
6
9
 
7
- import {afterEach, beforeEach, describe, expect, it} from 'vitest';
10
+ import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest';
11
+
12
+ vi.mock('../../foundation/discovery/template-conflict-release.mjs', () => ({
13
+ expandedTemplateConflictSchemaActive: () => true,
14
+ }));
8
15
  import * as fs from 'node:fs';
9
16
  import * as path from 'node:path';
10
17
  import {discoverCoreTemplates} from '../../foundation/discovery/template-adapter.mjs';
@@ -10,9 +10,7 @@ export type CoreTemplateMatch = {
10
10
  };
11
11
  export type IntegrationTemplateConflict = {
12
12
  id: string;
13
- severity: "info" | "warning";
14
- relationship: "replaces" | "accidental";
15
- replaces?: string | undefined;
13
+ severity: "warning";
16
14
  integrationPackage: string;
17
15
  integrationType: "page" | "block";
18
16
  integrationName: string;
@@ -1,6 +1,11 @@
1
1
  // Copyright (c) Meta Platforms, Inc. and affiliates.
2
2
 
3
- /** @file Colocated types for integration authoring diagnostics. */
3
+ /**
4
+ * @file Colocated public types for integration authoring diagnostics.
5
+ * @input Stable response fields exposed by integration-authoring APIs.
6
+ * @output JSDoc typedefs consumed by declarations, commands, and callers.
7
+ * @position Public type boundary for integration diagnostics.
8
+ */
4
9
 
5
10
  /**
6
11
  * @typedef {object} IntegrationAuthoringOptions
@@ -16,9 +21,7 @@
16
21
  /**
17
22
  * @typedef {object} IntegrationTemplateConflict
18
23
  * @property {string} id
19
- * @property {'info' | 'warning'} severity
20
- * @property {'replaces' | 'accidental'} relationship
21
- * @property {string} [replaces]
24
+ * @property {'warning'} severity
22
25
  * @property {string} integrationPackage
23
26
  * @property {'page' | 'block'} integrationType
24
27
  * @property {string} integrationName
@@ -3,6 +3,9 @@
3
3
 
4
4
  /**
5
5
  * @file FunctionDoc for integration template-conflict diagnostics.
6
+ * @input The stable 0.6.x `integrationTemplateConflicts` API contract.
7
+ * @output Generated CLI API reference metadata.
8
+ * @position Consumer-facing documentation for the public authoring API.
6
9
  */
7
10
  /** @type {import('@astryxdesign/cli/authoring').FunctionDoc} */
8
11
  export const doc: import("@astryxdesign/cli/authoring").FunctionDoc;
@@ -2,6 +2,9 @@
2
2
 
3
3
  /**
4
4
  * @file FunctionDoc for integration template-conflict diagnostics.
5
+ * @input The stable 0.6.x `integrationTemplateConflicts` API contract.
6
+ * @output Generated CLI API reference metadata.
7
+ * @position Consumer-facing documentation for the public authoring API.
5
8
  */
6
9
 
7
10
  /** @type {import('@astryxdesign/cli/authoring').FunctionDoc} */
@@ -11,12 +14,11 @@ export const doc = {
11
14
  name: 'integrationTemplateConflicts',
12
15
  namespace: 'cli/api',
13
16
  displayName: 'integrationTemplateConflicts()',
14
- summary: 'Validate integration template replacements and Core id overlaps.',
17
+ summary: 'Find integration template ids that also exist in Core.',
15
18
  description:
16
- 'Loads one local or installed integration, validates its template replacement ' +
17
- 'declarations against the built-in Core page and block templates, and reports ' +
18
- 'intentional replacements, missing targets, ambiguous declarations, type ' +
19
- 'mismatches, and undeclared same-id conflicts.',
19
+ 'Loads one local or installed integration, compares its template ids with the ' +
20
+ 'built-in Core page and block templates, and returns non-blocking conflicts with ' +
21
+ 'the exact package-qualified CLI command required to keep an intentional overlap.',
20
22
  importPath: '@astryxdesign/cli/api',
21
23
  signature:
22
24
  'integrationTemplateConflicts(pkg?: string, options?: IntegrationAuthoringOptions): Promise<IntegrationTemplateConflictResponse>',
@@ -39,7 +41,7 @@ export const doc = {
39
41
  {
40
42
  type: 'integration.template-conflicts',
41
43
  description:
42
- 'The integration identity, structural and replacement-declaration issues, intentional Core replacements, and undeclared same-id conflicts.',
44
+ 'The integration identity, structural issues, and every Core template-id conflict with a package-qualified command.',
43
45
  },
44
46
  ],
45
47
  examples: [