@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
@@ -145,14 +145,15 @@ const BLOCK_FIELDS = {
145
145
  table: ['headers', 'rows'],
146
146
  list: ['style', 'items'],
147
147
  'token-ref': ['topic', 'section'],
148
+ // A read inlines it as the doc it names includes (spec:AST-047 FR9).
149
+ reference: ['target'],
148
150
  };
149
151
 
150
- /** Blocks that are valid authoring but require the compiled graph renderer. */
151
- export const GRAPH_BLOCK_TYPES = new Set([
152
- 'workflow',
153
- 'collection',
154
- 'reference',
155
- ]);
152
+ /**
153
+ * Blocks that are valid authoring but require the compiled graph renderer: a
154
+ * namespace doc's `blocks` hold them, a topic section does not.
155
+ */
156
+ export const GRAPH_BLOCK_TYPES = new Set(['workflow', 'collection']);
156
157
 
157
158
  /**
158
159
  * Doc fields only the docs tree reads. A flat topic that sets one fails to
@@ -168,6 +169,7 @@ export const GRAPH_ONLY_FIELDS = ['placement', 'aliases', 'audience'];
168
169
  /** @type {Record<string, string[]>} */
169
170
  const OPTIONAL_BLOCK_FIELDS = {
170
171
  code: ['label'],
172
+ reference: ['projection', 'presentation'],
171
173
  };
172
174
 
173
175
  /**
@@ -179,8 +181,12 @@ const OPTIONAL_BLOCK_FIELDS = {
179
181
  const BLOCK_FIELD_VALUES = {
180
182
  heading: {level: [3, 4, 5, 6]},
181
183
  list: {style: ['ordered', 'unordered', 'do', 'dont']},
184
+ reference: {presentation: ['summary', 'compact', 'full']},
182
185
  };
183
186
 
187
+ /** The parts of a doc a reference block's `projection` may select. */
188
+ const PROJECTION_FIELDS = ['fields', 'sections'];
189
+
184
190
  /** Keys a section may carry. */
185
191
  const SECTION_FIELDS = ['id', 'title', 'category', 'content', 'previewType'];
186
192
 
@@ -325,6 +331,34 @@ export function problemsInTopic(doc, {placement = false} = {}) {
325
331
  );
326
332
  }
327
333
  }
334
+ // A projection names the parts of the doc to include, so each part
335
+ // it names is a non-empty list of names.
336
+ if (block.type === 'reference' && block.projection != null) {
337
+ const projection = block.projection;
338
+ if (typeof projection !== 'object' || Array.isArray(projection)) {
339
+ problems.push(
340
+ `${blockAt}.projection: expected {fields?, sections?}, naming the parts of the doc to include`,
341
+ );
342
+ } else {
343
+ for (const [key, names] of Object.entries(projection)) {
344
+ if (!PROJECTION_FIELDS.includes(key)) {
345
+ problems.push(
346
+ `${blockAt}.projection.${key}: not a field of a projection`,
347
+ );
348
+ } else if (
349
+ !Array.isArray(names) ||
350
+ names.length === 0 ||
351
+ names.some(
352
+ name => typeof name !== 'string' || name.trim() === '',
353
+ )
354
+ ) {
355
+ problems.push(
356
+ `${blockAt}.projection.${key}: expected a non-empty array of names`,
357
+ );
358
+ }
359
+ }
360
+ }
361
+ }
328
362
  },
329
363
  );
330
364
  },
@@ -310,6 +310,46 @@ describe('problemsInTopic', () => {
310
310
  }
311
311
  });
312
312
 
313
+ it('takes a reference block, and checks its projection and presentation', () => {
314
+ /** @param {any[]} content */
315
+ const withBlocks = content =>
316
+ problemsInTopic(topic({sections: [{title: 'Overview', content}]}));
317
+ expect(
318
+ withBlocks([
319
+ {type: 'reference', target: 'schema:integration'},
320
+ {
321
+ type: 'reference',
322
+ target: '@astryxdesign/cli:schema:integration',
323
+ projection: {fields: ['docs']},
324
+ presentation: 'compact',
325
+ },
326
+ ]),
327
+ ).toEqual([]);
328
+ expect(
329
+ withBlocks([
330
+ {type: 'reference', target: ''},
331
+ {type: 'reference', target: 'schema:x', presentation: 'card'},
332
+ {type: 'reference', target: 'schema:x', projection: {fields: []}},
333
+ {type: 'reference', target: 'schema:x', projection: {rows: ['a']}},
334
+ {type: 'reference', target: 'schema:x', projection: ['docs']},
335
+ {type: 'reference', target: 'schema:x', link: {}},
336
+ ]),
337
+ ).toEqual([
338
+ 'sections[0].content[0].target: expected a non-empty string',
339
+ 'sections[0].content[1].presentation: "card" is not one of summary, compact, full',
340
+ 'sections[0].content[2].projection.fields: expected a non-empty array of names',
341
+ 'sections[0].content[3].projection.rows: not a field of a projection',
342
+ 'sections[0].content[4].projection: expected {fields?, sections?}, naming the parts of the doc to include',
343
+ 'sections[0].content[5].link: not a field of a reference block',
344
+ ]);
345
+ // Workflow and collection blocks stay in a namespace doc's `blocks`.
346
+ for (const type of ['workflow', 'collection']) {
347
+ expect(withBlocks([{type}]).join('\n')).toContain(
348
+ 'requires the compiled graph renderer',
349
+ );
350
+ }
351
+ });
352
+
313
353
  it('rejects a name that is not URL-safe', () => {
314
354
  expect(problemsInTopic(topic({name: 'not a topic'})).join('\n')).toContain(
315
355
  'URL-safe',
@@ -0,0 +1,13 @@
1
+ // @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
2
+ // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
+
4
+ /**
5
+ * Whether this release exposes replacement relationships in the public conflict API.
6
+ * Both the supported version and a deliberate projection update are required;
7
+ * a routine package-version bump cannot expand the public shape by itself.
8
+ *
9
+ * @param {string} [version]
10
+ * @param {'warning-only' | 'expanded'} [projection]
11
+ * @returns {boolean}
12
+ */
13
+ export function expandedTemplateConflictSchemaActive(version?: string, projection?: "warning-only" | "expanded"): boolean;
@@ -0,0 +1,40 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file Release boundary for the expanded integration-template conflict schema.
5
+ *
6
+ * @input The CLI package version and an explicit public-schema projection.
7
+ * @output Whether replacement-specific conflict fields may reach the stable API.
8
+ * @position Private compatibility gate for integration authoring diagnostics.
9
+ */
10
+
11
+ import * as fs from 'node:fs';
12
+ import * as path from 'node:path';
13
+ import {semverCompare} from '../env/semver.mjs';
14
+ import {CLI_ROOT} from '../fs/paths.mjs';
15
+
16
+ const EXPANDED_TEMPLATE_CONFLICT_SCHEMA_CLI = '0.7.0';
17
+ /** @type {'warning-only' | 'expanded'} */
18
+ const TEMPLATE_CONFLICT_SCHEMA_PROJECTION = 'warning-only';
19
+ const CLI_VERSION = JSON.parse(
20
+ fs.readFileSync(path.join(CLI_ROOT, 'package.json'), 'utf8'),
21
+ ).version;
22
+
23
+ /**
24
+ * Whether this release exposes replacement relationships in the public conflict API.
25
+ * Both the supported version and a deliberate projection update are required;
26
+ * a routine package-version bump cannot expand the public shape by itself.
27
+ *
28
+ * @param {string} [version]
29
+ * @param {'warning-only' | 'expanded'} [projection]
30
+ * @returns {boolean}
31
+ */
32
+ export function expandedTemplateConflictSchemaActive(
33
+ version = CLI_VERSION,
34
+ projection = TEMPLATE_CONFLICT_SCHEMA_PROJECTION,
35
+ ) {
36
+ return (
37
+ projection === 'expanded' &&
38
+ semverCompare(version, EXPANDED_TEMPLATE_CONFLICT_SCHEMA_CLI) >= 0
39
+ );
40
+ }
@@ -0,0 +1,40 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file Unit coverage for the integration-template conflict release boundary.
5
+ * @input CLI versions and explicit warning-only or expanded projections.
6
+ * @output Boolean activation assertions for the expanded conflict schema.
7
+ * @position Colocated coverage for the private release gate.
8
+ */
9
+
10
+ import {describe, expect, it} from 'vitest';
11
+ import {expandedTemplateConflictSchemaActive} from './template-conflict-release.mjs';
12
+
13
+ describe('expandedTemplateConflictSchemaActive', () => {
14
+ it.each(['0.6.3', '0.6.4', '0.6.99'])(
15
+ 'keeps %s narrow even when the expanded projection is requested',
16
+ version => {
17
+ expect(expandedTemplateConflictSchemaActive(version, 'expanded')).toBe(
18
+ false,
19
+ );
20
+ },
21
+ );
22
+
23
+ it.each(['0.7.0-rc.1', '0.7.0', '0.8.0'])(
24
+ 'does not let version %s expand the warning-only projection',
25
+ version => {
26
+ expect(
27
+ expandedTemplateConflictSchemaActive(version, 'warning-only'),
28
+ ).toBe(false);
29
+ },
30
+ );
31
+
32
+ it.each(['0.7.0-rc.1', '0.7.0', '0.8.0'])(
33
+ 'allows the deliberate expanded projection in %s',
34
+ version => {
35
+ expect(expandedTemplateConflictSchemaActive(version, 'expanded')).toBe(
36
+ true,
37
+ );
38
+ },
39
+ );
40
+ });
@@ -24,9 +24,11 @@ export function detailView(node: import("./compile.mjs").CompiledReferenceNode):
24
24
  */
25
25
  export function indexView(node: import("./compile.mjs").CompiledReferenceNode): Omit<import("../../api/docs/docs.type.mjs").DocsIndex, "links">;
26
26
  /**
27
- * `docs.detail.section`: one section with its token references inlined. A
28
- * referenced section's content takes the reference's place; the section takes
29
- * the preview type of the last reference that has one, unless it has its own.
27
+ * `docs.detail.section`: one section with its token references and reference
28
+ * blocks inlined, so a read returns only the stable block kinds. A referenced
29
+ * section's content takes the token reference's place; the section takes the
30
+ * preview type of the last reference that has one, unless it has its own. A
31
+ * reference block becomes the content it includes (see referenceView).
30
32
  * @param {import('./compile.mjs').CompiledReferenceNode} node
31
33
  * @param {any} section a linked section of `node`
32
34
  * @returns {any}
@@ -71,9 +71,11 @@ export function indexView(node) {
71
71
  }
72
72
 
73
73
  /**
74
- * `docs.detail.section`: one section with its token references inlined. A
75
- * referenced section's content takes the reference's place; the section takes
76
- * the preview type of the last reference that has one, unless it has its own.
74
+ * `docs.detail.section`: one section with its token references and reference
75
+ * blocks inlined, so a read returns only the stable block kinds. A referenced
76
+ * section's content takes the token reference's place; the section takes the
77
+ * preview type of the last reference that has one, unless it has its own. A
78
+ * reference block becomes the content it includes (see referenceView).
77
79
  * @param {import('./compile.mjs').CompiledReferenceNode} node
78
80
  * @param {any} section a linked section of `node`
79
81
  * @returns {any}
@@ -84,6 +86,10 @@ export function sectionView(node, section) {
84
86
  /** @type {string | null} */
85
87
  let previewType = null;
86
88
  for (const block of section.content) {
89
+ if (block?.type === 'reference') {
90
+ content.push(...referenceView(node, block));
91
+ continue;
92
+ }
87
93
  if (block?.type !== 'token-ref') {
88
94
  content.push(structuredClone(block));
89
95
  continue;
@@ -126,3 +132,42 @@ export function sectionView(node, section) {
126
132
  view.content = content;
127
133
  return withSourceTitle(view, authoredTitle(node, section));
128
134
  }
135
+
136
+ /**
137
+ * A reference block as a read shows it (spec:AST-047 FR9): the content it
138
+ * includes, then where that content comes from and the command that opens it.
139
+ * A reference that includes nothing (a summary, or a doc that is not included
140
+ * whole) shows the doc's title and summary; one whose doc is missing says so
141
+ * where its content would be, as a token reference does.
142
+ * @param {import('./compile.mjs').CompiledReferenceNode} node
143
+ * @param {any} block a linked reference block
144
+ * @returns {any[]}
145
+ */
146
+ function referenceView(node, block) {
147
+ if (!('link' in block)) {
148
+ throw new Error(
149
+ `The reference to "${block.target}" in "${node.id}" was read before it was linked.`,
150
+ );
151
+ }
152
+ const link = block.link;
153
+ if (link == null) {
154
+ return [
155
+ {type: 'prose', text: `[reference: "${block.target}" names no doc]`},
156
+ ];
157
+ }
158
+ const included = (block.content ?? []).map((/** @type {any} */ each) =>
159
+ structuredClone(each),
160
+ );
161
+ if (included.length === 0) {
162
+ const summary = String(link.summary ?? '').trim();
163
+ const lead =
164
+ summary === ''
165
+ ? link.title
166
+ : `${link.title}: ${summary}${/[.!?]$/.test(summary) ? '' : '.'}`;
167
+ return [{type: 'prose', text: `${lead} Read it with \`${link.command}\`.`}];
168
+ }
169
+ return [
170
+ ...included,
171
+ {type: 'prose', text: `From ${link.title}: \`${link.command}\``},
172
+ ];
173
+ }
@@ -27,6 +27,15 @@
27
27
  * @property {string} target the target as written
28
28
  * @property {string} message
29
29
  * @property {string} [section] the key of the section the link sits in
30
+ * @property {true} [include] the problem is in a `reference` block, which
31
+ * includes content rather than linking to it: a reader loses that content,
32
+ * so the authoring check fails on it
33
+ */
34
+ /**
35
+ * What a `reference` block in a topic section includes of the doc it names:
36
+ * stable content blocks, with anything it could not include named in
37
+ * `problems`.
38
+ * @typedef {(block: any) => Promise<{content: any[], problems: string[]}>} DocIncluder
30
39
  */
31
40
  /**
32
41
  * Parse `[<provider>:]<kind>:<name>`. A name may hold spaces
@@ -49,11 +58,13 @@ export function unlinkText(text: string): string;
49
58
  * @param {any[]} blocks
50
59
  * @param {LinkResolver} resolve
51
60
  * @param {{section?: string}} [at]
61
+ * @param {DocIncluder} [include] how a `reference` block includes the doc it
62
+ * names; without it, the block only carries its `link`
52
63
  * @returns {Promise<{content: any[], problems: LinkProblem[]}>}
53
64
  */
54
65
  export function linkBlocks(blocks: any[], resolve: LinkResolver, at?: {
55
66
  section?: string;
56
- }): Promise<{
67
+ }, include?: DocIncluder): Promise<{
57
68
  content: any[];
58
69
  problems: LinkProblem[];
59
70
  }>;
@@ -75,8 +86,9 @@ export function linkSections(sections: any[], resolve: LinkResolver): Promise<{
75
86
  * `{@link <target>}`; and a resolver that finds the doc a target names.
76
87
  * @output The same content with every link resolved: an inline link becomes
77
88
  * the `astryx docs` command that opens its doc, and a block carries a `link`
78
- * with the doc's identity, route, title, summary, and command. A link that
79
- * names no doc is a problem, never a guess.
89
+ * with the doc's identity, route, title, summary, and command. A reference
90
+ * block in a topic section also carries the `content` it includes. A link
91
+ * that names no doc is a problem, never a guess.
80
92
  * @position Pure. The docs adapter owns the resolver (the project's docs tree
81
93
  * and topic catalog) and applies this to every read and every doctor check.
82
94
  */
@@ -132,4 +144,19 @@ export type LinkProblem = {
132
144
  * the key of the section the link sits in
133
145
  */
134
146
  section?: string | undefined;
147
+ /**
148
+ * the problem is in a `reference` block, which
149
+ * includes content rather than linking to it: a reader loses that content,
150
+ * so the authoring check fails on it
151
+ */
152
+ include?: true | undefined;
135
153
  };
154
+ /**
155
+ * What a `reference` block in a topic section includes of the doc it names:
156
+ * stable content blocks, with anything it could not include named in
157
+ * `problems`.
158
+ */
159
+ export type DocIncluder = (block: any) => Promise<{
160
+ content: any[];
161
+ problems: string[];
162
+ }>;
@@ -8,8 +8,9 @@
8
8
  * `{@link <target>}`; and a resolver that finds the doc a target names.
9
9
  * @output The same content with every link resolved: an inline link becomes
10
10
  * the `astryx docs` command that opens its doc, and a block carries a `link`
11
- * with the doc's identity, route, title, summary, and command. A link that
12
- * names no doc is a problem, never a guess.
11
+ * with the doc's identity, route, title, summary, and command. A reference
12
+ * block in a topic section also carries the `content` it includes. A link
13
+ * that names no doc is a problem, never a guess.
13
14
  * @position Pure. The docs adapter owns the resolver (the project's docs tree
14
15
  * and topic catalog) and applies this to every read and every doctor check.
15
16
  */
@@ -62,6 +63,16 @@ const CODE_SPAN = /(`[^`]*`)/;
62
63
  * @property {string} target the target as written
63
64
  * @property {string} message
64
65
  * @property {string} [section] the key of the section the link sits in
66
+ * @property {true} [include] the problem is in a `reference` block, which
67
+ * includes content rather than linking to it: a reader loses that content,
68
+ * so the authoring check fails on it
69
+ */
70
+
71
+ /**
72
+ * What a `reference` block in a topic section includes of the doc it names:
73
+ * stable content blocks, with anything it could not include named in
74
+ * `problems`.
75
+ * @typedef {(block: any) => Promise<{content: any[], problems: string[]}>} DocIncluder
65
76
  */
66
77
 
67
78
  /**
@@ -119,9 +130,11 @@ export function unlinkText(text) {
119
130
  * @param {any[]} blocks
120
131
  * @param {LinkResolver} resolve
121
132
  * @param {{section?: string}} [at]
133
+ * @param {DocIncluder} [include] how a `reference` block includes the doc it
134
+ * names; without it, the block only carries its `link`
122
135
  * @returns {Promise<{content: any[], problems: LinkProblem[]}>}
123
136
  */
124
- export async function linkBlocks(blocks, resolve, at = {}) {
137
+ export async function linkBlocks(blocks, resolve, at = {}, include) {
125
138
  /** @type {LinkProblem[]} */
126
139
  const problems = [];
127
140
  const where = at.section ? {section: at.section} : {};
@@ -195,9 +208,37 @@ export async function linkBlocks(blocks, resolve, at = {}) {
195
208
  });
196
209
  break;
197
210
  }
198
- case 'reference':
199
- content.push({...block, link: await find(block.target)});
211
+ case 'reference': {
212
+ // A reference includes content, so what it cannot include is a
213
+ // problem the authoring check fails on, not one that prints as written.
214
+ const found = await resolve(block.target);
215
+ if ('problem' in found) {
216
+ problems.push({
217
+ target: block.target,
218
+ message: found.problem,
219
+ include: true,
220
+ ...where,
221
+ });
222
+ content.push({...block, link: null});
223
+ break;
224
+ }
225
+ /** @type {any} */
226
+ const linked = {...block, link: found};
227
+ if (include) {
228
+ const included = await include(block);
229
+ for (const message of included.problems) {
230
+ problems.push({
231
+ target: block.target,
232
+ message,
233
+ include: true,
234
+ ...where,
235
+ });
236
+ }
237
+ linked.content = included.content;
238
+ }
239
+ content.push(linked);
200
240
  break;
241
+ }
201
242
  case 'workflow': {
202
243
  const steps = [];
203
244
  for (const step of block.steps ?? []) {
@@ -105,6 +105,59 @@ describe('linkBlocks', () => {
105
105
  );
106
106
  });
107
107
 
108
+ it('includes what a reference block names, and marks what it cannot include', async () => {
109
+ /** @type {any[]} */
110
+ const asked = [];
111
+ const include = async (/** @type {any} */ block) => {
112
+ asked.push(block.target);
113
+ return {
114
+ content: [{type: 'prose', text: 'The doctor command.'}],
115
+ problems: block.projection ? ['projection.fields: no such field'] : [],
116
+ };
117
+ };
118
+ const {content, problems} = await linkBlocks(
119
+ [
120
+ {type: 'reference', target: 'command:doctor'},
121
+ {
122
+ type: 'reference',
123
+ target: 'command:doctor',
124
+ projection: {fields: ['--nope']},
125
+ },
126
+ {type: 'reference', target: 'command:gone'},
127
+ ],
128
+ resolve,
129
+ {section: 'check'},
130
+ include,
131
+ );
132
+ // A target that names no doc is never handed to the includer.
133
+ expect(asked).toEqual(['command:doctor', 'command:doctor']);
134
+ expect(content[0]).toMatchObject({
135
+ link: {command: 'astryx docs cli/commands/doctor'},
136
+ content: [{type: 'prose', text: 'The doctor command.'}],
137
+ });
138
+ expect(content[2]).toEqual({
139
+ type: 'reference',
140
+ target: 'command:gone',
141
+ link: null,
142
+ });
143
+ // Both are the authoring check's: the block includes content, where a
144
+ // link only points at it.
145
+ expect(problems).toEqual([
146
+ {
147
+ target: 'command:doctor',
148
+ message: 'projection.fields: no such field',
149
+ include: true,
150
+ section: 'check',
151
+ },
152
+ {
153
+ target: 'command:gone',
154
+ message: '"command:gone" names no doc',
155
+ include: true,
156
+ section: 'check',
157
+ },
158
+ ]);
159
+ });
160
+
108
161
  it('names every link that finds no doc, and never guesses', async () => {
109
162
  const {content, problems} = await linkSections(
110
163
  [
@@ -1,10 +1,6 @@
1
1
  // Copyright (c) Meta Platforms, Inc. and affiliates.
2
2
 
3
3
  import {describe, expect, it} from 'vitest';
4
- import * as fs from 'node:fs';
5
- import * as path from 'node:path';
6
- import {CLI_ROOT} from '../fs/paths.mjs';
7
- import {semverCompare} from '../env/semver.mjs';
8
4
  import {
9
5
  DOCS_TREE_CLI,
10
6
  lowestAdmitted,
@@ -55,55 +51,34 @@ describe('docsTreeCliProblem', () => {
55
51
 
56
52
  it('declares the peer as optional, and keeps what the package says of it', () => {
57
53
  const declared = withDocsTreeCli({name: '@acme/kit'});
58
- expect(declared.peerDependencies).toEqual({'@astryxdesign/cli': `>=${DOCS_TREE_CLI}`});
59
- expect(declared.peerDependenciesMeta).toEqual({'@astryxdesign/cli': {optional: true}});
54
+ expect(declared.peerDependencies).toEqual({
55
+ '@astryxdesign/cli': `>=${DOCS_TREE_CLI}`,
56
+ });
57
+ expect(declared.peerDependenciesMeta).toEqual({
58
+ '@astryxdesign/cli': {optional: true},
59
+ });
60
60
  expect(docsTreeCliProblem(declared)).toBeNull();
61
61
  const required = withDocsTreeCli({
62
62
  peerDependencies: {react: '^19.0.0', '@astryxdesign/cli': '^0.6.0'},
63
63
  peerDependenciesMeta: {'@astryxdesign/cli': {optional: false}},
64
64
  });
65
65
  expect(required.peerDependencies.react).toBe('^19.0.0');
66
- expect(required.peerDependenciesMeta['@astryxdesign/cli']).toEqual({optional: false});
66
+ expect(required.peerDependenciesMeta['@astryxdesign/cli']).toEqual({
67
+ optional: false,
68
+ });
67
69
  });
68
70
  });
69
71
 
70
72
  describe('replacesCliProblem', () => {
71
73
  it('asks a package that sets replaces for a CLI that reads the field', () => {
72
- expect(replacesCliProblem({name: '@acme/kit'})).toContain('sets `replaces`');
73
- expect(replacesCliProblem({peerDependencies: {'@astryxdesign/cli': '^0.6.0'}})).toContain(
74
- 'admits a CLI older than',
75
- );
76
- expect(replacesCliProblem({peerDependencies: {'@astryxdesign/cli': '>=0.7.0'}})).toBeNull();
77
- });
78
- });
79
-
80
- describe('DOCS_TREE_CLI', () => {
81
- it('is no later than the release the pending changesets make', () => {
82
- const {version} = JSON.parse(
83
- fs.readFileSync(path.join(CLI_ROOT, 'package.json'), 'utf-8'),
74
+ expect(replacesCliProblem({name: '@acme/kit'})).toContain(
75
+ 'sets `replaces`',
84
76
  );
85
- const dir = path.join(CLI_ROOT, '..', '..', '.changeset');
86
- /** @type {Record<string, number>} */
87
- const rank = {patch: 1, minor: 2, major: 3};
88
- let bump = 0;
89
- for (const file of fs.readdirSync(dir)) {
90
- if (!file.endsWith('.md') || file === 'README.md') continue;
91
- const head = fs.readFileSync(path.join(dir, file), 'utf-8').split('---')[1] ?? '';
92
- const m = /['"]@astryxdesign\/cli['"]\s*:\s*(patch|minor|major)/.exec(head);
93
- if (m) bump = Math.max(bump, rank[m[1]]);
94
- }
95
- const [major, minor, patch] = version.split('-')[0].split('.').map(Number);
96
- const next =
97
- bump === 3
98
- ? `${major + 1}.0.0`
99
- : bump === 2
100
- ? `${major}.${minor + 1}.0`
101
- : bump === 1
102
- ? `${major}.${minor}.${patch + 1}`
103
- : version;
104
- // The first release that reads namespace docs is this one or an earlier
105
- // one; a later constant would make every author wait for a CLI that does
106
- // not exist yet.
107
- expect(semverCompare(DOCS_TREE_CLI, next)).toBeLessThanOrEqual(0);
77
+ expect(
78
+ replacesCliProblem({peerDependencies: {'@astryxdesign/cli': '^0.6.0'}}),
79
+ ).toContain('admits a CLI older than');
80
+ expect(
81
+ replacesCliProblem({peerDependencies: {'@astryxdesign/cli': '>=0.7.0'}}),
82
+ ).toBeNull();
108
83
  });
109
84
  });
@@ -5,7 +5,11 @@
5
5
  * @file EnumDoc for the `type` discriminant carried on every --json success
6
6
  * envelope. The vocabulary mirrors the RESPONSE_TYPES map (each command's
7
7
  * `jsonOut(...)` call sites) in `clients/cli/lib/manifest.mjs`; a consumer
8
- * switches on `type` to narrow the `data` payload.
8
+ * switches on `type` to narrow the `data` payload. Descriptions follow the
9
+ * currently published response projection, not a future package-version boundary.
10
+ *
11
+ * @input Public response discriminants and their currently released payloads.
12
+ * @output Generated consumer reference for every typed JSON success response.
9
13
  * @position packages/cli/foundation/response — enum documentation
10
14
  */
11
15
  /** @type {import('@astryxdesign/cli/authoring').EnumDoc} */
@@ -4,7 +4,11 @@
4
4
  * @file EnumDoc for the `type` discriminant carried on every --json success
5
5
  * envelope. The vocabulary mirrors the RESPONSE_TYPES map (each command's
6
6
  * `jsonOut(...)` call sites) in `clients/cli/lib/manifest.mjs`; a consumer
7
- * switches on `type` to narrow the `data` payload.
7
+ * switches on `type` to narrow the `data` payload. Descriptions follow the
8
+ * currently published response projection, not a future package-version boundary.
9
+ *
10
+ * @input Public response discriminants and their currently released payloads.
11
+ * @output Generated consumer reference for every typed JSON success response.
8
12
  * @position packages/cli/foundation/response — enum documentation
9
13
  */
10
14
 
@@ -61,7 +65,7 @@ export const doc = {
61
65
  {
62
66
  value: 'docs.list',
63
67
  description:
64
- 'All reference-doc topics as DocsListEntry[] ({topic, description, package, replaces?}), in read order; meta.namespaces lists the docs tree\'s top-level namespaces, and meta.notLoaded each package whose docs did not load.',
68
+ "All reference-doc topics as DocsListEntry[] ({topic, description, package, replaces?}), in read order; meta.namespaces lists the docs tree's top-level namespaces, and meta.notLoaded each package whose docs did not load.",
65
69
  },
66
70
  {
67
71
  value: 'docs.detail',
@@ -133,7 +137,7 @@ export const doc = {
133
137
  {
134
138
  value: 'build.kit',
135
139
  description:
136
- 'The composition kit: echoed query, hasResults, matchCount (total matched, never a cap), directMatch, pages (closest templates), blocks (drop-in patterns) and domain (idea components/hooks) as SearchResultEntry[], frame and foundation name arrays, and hint {reason, commands} when thin.',
140
+ "The template to start from and its kit: query, hasResults, matchCount (never a cap), directMatch, start {name, command, basis, reason, alternatives, ...}, pages (search's closest templates), blocks and domain as SearchResultEntry[], frame, foundation, and hint {reason, commands} when thin.",
137
141
  },
138
142
 
139
143
  // swizzle
@@ -291,7 +295,7 @@ export const doc = {
291
295
  {
292
296
  value: 'integration.template-conflicts',
293
297
  description:
294
- 'The integration identity, issues, and conflicts as {severity: info | warning, relationship: replaces | accidental, replaces?, command}.',
298
+ 'The integration identity, structural issues, and non-blocking Core template-id conflicts as {id, severity: warning, integrationPackage, integrationType, integrationName, coreMatches, message, command}.',
295
299
  },
296
300
  {
297
301
  value: 'integration.component-conflicts',
@@ -40,4 +40,12 @@ export function searchComponents(needle: string, coreDir: string, components: Re
40
40
  score: number;
41
41
  reason: string;
42
42
  }[]>;
43
+ /**
44
+ * The first sentence of a text, whitespace collapsed. A period after "e.g" or
45
+ * "i.e" does not end the sentence. Used where a description has to fit on one
46
+ * line: `build`'s alternatives and its text kit.
47
+ * @param {string} text
48
+ * @returns {string}
49
+ */
50
+ export function firstSentence(text: string): string;
43
51
  export { levenshteinDistance } from "./levenshtein.mjs";