@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,71 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ 'use client';
4
+
5
+ import {useState} from 'react';
6
+ import {Button} from '@astryxdesign/core/Button';
7
+ import {
8
+ Table,
9
+ TableSelectionToolbar,
10
+ useTableSelection,
11
+ useTableSelectionState,
12
+ proportional,
13
+ } from '@astryxdesign/core/Table';
14
+ import type {TableColumn} from '@astryxdesign/core/Table';
15
+
16
+ interface User extends Record<string, unknown> {
17
+ id: string;
18
+ name: string;
19
+ email: string;
20
+ role: string;
21
+ }
22
+
23
+ const users: User[] = [
24
+ {id: '1', name: 'Alice', email: 'alice@example.com', role: 'Engineer'},
25
+ {id: '2', name: 'Bob', email: 'bob@example.com', role: 'Designer'},
26
+ {id: '3', name: 'Charlie', email: 'charlie@example.com', role: 'Manager'},
27
+ {id: '4', name: 'Diana', email: 'diana@example.com', role: 'Engineer'},
28
+ {id: '5', name: 'Eve', email: 'eve@example.com', role: 'Admin'},
29
+ ];
30
+
31
+ const columns: TableColumn<User>[] = [
32
+ {key: 'name', header: 'Name', width: proportional(1)},
33
+ {key: 'email', header: 'Email', width: proportional(2)},
34
+ {key: 'role', header: 'Role', width: proportional(1)},
35
+ ];
36
+
37
+ export default function TableBulkActionsTable() {
38
+ const [selectedKeys, setSelectedKeys] = useState<Set<string>>(new Set());
39
+
40
+ const {selectionConfig, selectionState} = useTableSelectionState<User>({
41
+ data: users,
42
+ idKey: 'id',
43
+ selectedKeys,
44
+ setSelectedKeys,
45
+ });
46
+ const selectionPlugin = useTableSelection<User>(selectionConfig);
47
+
48
+ return (
49
+ <div>
50
+ <TableSelectionToolbar
51
+ selection={selectionState}
52
+ startContent={
53
+ <>
54
+ <Button label="Export" variant="ghost" onClick={() => {}} />
55
+ <Button
56
+ label="Delete"
57
+ variant="ghost"
58
+ onClick={selectionState.clearSelection}
59
+ />
60
+ </>
61
+ }
62
+ />
63
+ <Table
64
+ data={users}
65
+ columns={columns}
66
+ idKey="id"
67
+ plugins={{selection: selectionPlugin}}
68
+ />
69
+ </div>
70
+ );
71
+ }
@@ -0,0 +1,19 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /** @type {import('@astryxdesign/cli/authoring').TemplateDoc} */
4
+ export const doc = {
5
+ type: 'block',
6
+ exampleFor: 'useTableSelection',
7
+ name: 'Table: Floating Bulk Actions',
8
+ displayName: 'Table: Floating Bulk Actions',
9
+ description:
10
+ 'The reusable TableSelectionToolbar inside a capped, self-contained scroll region for a long non-sticky table below metric cards. The caller-owned sticky placement keeps actions 16px from the example scrollport without moving the table when selection changes.',
11
+ isReady: true,
12
+ aspectRatio: 16 / 9,
13
+ componentsUsed: [
14
+ 'Table',
15
+ 'TableSelectionToolbar',
16
+ 'Button',
17
+ 'ScrollableArea',
18
+ ],
19
+ };
@@ -0,0 +1,139 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ 'use client';
4
+
5
+ import {useState} from 'react';
6
+ import * as stylex from '@stylexjs/stylex';
7
+ import {Button} from '@astryxdesign/core/Button';
8
+ import {ScrollableArea} from '@astryxdesign/core/ScrollableArea';
9
+ import {
10
+ Table,
11
+ TableSelectionToolbar,
12
+ useTableSelection,
13
+ useTableSelectionState,
14
+ proportional,
15
+ } from '@astryxdesign/core/Table';
16
+ import type {TableColumn} from '@astryxdesign/core/Table';
17
+ import {
18
+ colorVars,
19
+ radiusVars,
20
+ shadowVars,
21
+ sizeVars,
22
+ spacingVars,
23
+ } from '@astryxdesign/core/theme/tokens.stylex';
24
+
25
+ interface User extends Record<string, unknown> {
26
+ id: string;
27
+ name: string;
28
+ email: string;
29
+ role: string;
30
+ }
31
+
32
+ const baseUsers: Array<Pick<User, 'name' | 'email' | 'role'>> = [
33
+ {name: 'Alice', email: 'alice@example.com', role: 'Engineer'},
34
+ {name: 'Bob', email: 'bob@example.com', role: 'Designer'},
35
+ {name: 'Charlie', email: 'charlie@example.com', role: 'Manager'},
36
+ {name: 'Diana', email: 'diana@example.com', role: 'Engineer'},
37
+ {name: 'Eve', email: 'eve@example.com', role: 'Admin'},
38
+ ];
39
+
40
+ const users: User[] = Array.from({length: 40}, (_, index) => {
41
+ const user = baseUsers[index % baseUsers.length];
42
+ return {...user, id: String(index + 1), name: `${user.name} ${index + 1}`};
43
+ });
44
+
45
+ const columns: TableColumn<User>[] = [
46
+ {key: 'name', header: 'Name', width: proportional(1)},
47
+ {key: 'email', header: 'Email', width: proportional(1)},
48
+ {key: 'role', header: 'Role', width: proportional(1)},
49
+ ];
50
+
51
+ const styles = stylex.create({
52
+ page: {
53
+ maxBlockSize: 640,
54
+ isolation: 'isolate',
55
+ scrollbarGutter: 'stable',
56
+ },
57
+ metrics: {
58
+ display: 'grid',
59
+ gridTemplateColumns: 'repeat(3, minmax(0, 1fr))',
60
+ gap: spacingVars['--spacing-3'],
61
+ marginBlockEnd: spacingVars['--spacing-6'],
62
+ },
63
+ metricCard: {
64
+ padding: spacingVars['--spacing-4'],
65
+ borderRadius: radiusVars['--radius-container'],
66
+ backgroundColor: colorVars['--color-background-muted'],
67
+ },
68
+ metricLabel: {
69
+ display: 'block',
70
+ color: colorVars['--color-text-secondary'],
71
+ },
72
+ metricValue: {
73
+ display: 'block',
74
+ marginBlockStart: spacingVars['--spacing-1'],
75
+ color: colorVars['--color-text-primary'],
76
+ },
77
+ tableRegion: {
78
+ '--table-bulk-actions-space': `calc(${sizeVars['--size-element-sm']} + ${spacingVars['--spacing-2']} + ${spacingVars['--spacing-2']} + ${spacingVars['--spacing-4']})`,
79
+ position: 'relative',
80
+ paddingBlockStart: 'var(--table-bulk-actions-space)',
81
+ },
82
+ toolbar: {
83
+ position: 'sticky',
84
+ insetBlockStart: `calc(var(--table-bulk-actions-space) + ${spacingVars['--spacing-4']})`,
85
+ transform: 'translateY(calc(0px - var(--table-bulk-actions-space)))',
86
+ marginBlockEnd: `calc(${spacingVars['--spacing-4']} - var(--table-bulk-actions-space))`,
87
+ zIndex: 1,
88
+ borderRadius: radiusVars['--radius-element'],
89
+ boxShadow: shadowVars['--shadow-med'],
90
+ },
91
+ });
92
+
93
+ export default function TableFloatingBulkActionsTable() {
94
+ const [selectedKeys, setSelectedKeys] = useState<Set<string>>(new Set());
95
+
96
+ const {selectionConfig, selectionState} = useTableSelectionState<User>({
97
+ data: users,
98
+ idKey: 'id',
99
+ selectedKeys,
100
+ setSelectedKeys,
101
+ });
102
+ const selectionPlugin = useTableSelection<User>(selectionConfig);
103
+
104
+ return (
105
+ <ScrollableArea
106
+ axis="block"
107
+ label="Bulk actions example"
108
+ overscroll="contain"
109
+ xstyle={styles.page}>
110
+ <div {...stylex.props(styles.metrics)}>
111
+ {[
112
+ ['Active users', '12,840'],
113
+ ['Selection rate', '18.4%'],
114
+ ['Pending reviews', '247'],
115
+ ].map(([label, value]) => (
116
+ <div key={label} {...stylex.props(styles.metricCard)}>
117
+ <span {...stylex.props(styles.metricLabel)}>{label}</span>
118
+ <strong {...stylex.props(styles.metricValue)}>{value}</strong>
119
+ </div>
120
+ ))}
121
+ </div>
122
+ <div {...stylex.props(styles.tableRegion)}>
123
+ <TableSelectionToolbar
124
+ selection={selectionState}
125
+ xstyle={styles.toolbar}
126
+ startContent={
127
+ <Button label="Approve" variant="ghost" onClick={() => {}} />
128
+ }
129
+ />
130
+ <Table
131
+ data={users}
132
+ columns={columns}
133
+ idKey="id"
134
+ plugins={{selection: selectionPlugin}}
135
+ />
136
+ </div>
137
+ </ScrollableArea>
138
+ );
139
+ }
@@ -93,6 +93,52 @@ export const GraphContentBlockSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
93
93
  full: "full";
94
94
  }>>;
95
95
  }, z.core.$strict>], "type">;
96
+ /**
97
+ * A topic section's blocks: the stable union, plus a reference block, which a
98
+ * read inlines as the doc it includes.
99
+ */
100
+ export const SectionContentBlockSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
101
+ type: z.ZodLiteral<"prose">;
102
+ text: z.ZodString;
103
+ }, z.core.$strict>, z.ZodObject<{
104
+ type: z.ZodLiteral<"heading">;
105
+ level: z.ZodUnion<readonly [z.ZodLiteral<3>, z.ZodLiteral<4>, z.ZodLiteral<5>, z.ZodLiteral<6>]>;
106
+ text: z.ZodString;
107
+ }, z.core.$strict>, z.ZodObject<{
108
+ type: z.ZodLiteral<"code">;
109
+ lang: z.ZodString;
110
+ code: z.ZodString;
111
+ label: z.ZodOptional<z.ZodString>;
112
+ }, z.core.$strict>, z.ZodObject<{
113
+ type: z.ZodLiteral<"table">;
114
+ headers: z.ZodArray<z.ZodString>;
115
+ rows: z.ZodArray<z.ZodArray<z.ZodString>>;
116
+ }, z.core.$strict>, z.ZodObject<{
117
+ type: z.ZodLiteral<"list">;
118
+ style: z.ZodEnum<{
119
+ ordered: "ordered";
120
+ unordered: "unordered";
121
+ do: "do";
122
+ dont: "dont";
123
+ }>;
124
+ items: z.ZodArray<z.ZodString>;
125
+ }, z.core.$strict>, z.ZodObject<{
126
+ type: z.ZodLiteral<"token-ref">;
127
+ topic: z.ZodString;
128
+ section: z.ZodString;
129
+ }, z.core.$strict>, z.ZodObject<{
130
+ type: z.ZodLiteral<"reference">;
131
+ target: z.ZodString;
132
+ projection: z.ZodOptional<z.ZodObject<{
133
+ fields: z.ZodOptional<z.ZodArray<z.ZodString>>;
134
+ sections: z.ZodOptional<z.ZodArray<z.ZodString>>;
135
+ }, z.core.$strict>>;
136
+ presentation: z.ZodOptional<z.ZodEnum<{
137
+ compact: "compact";
138
+ summary: "summary";
139
+ full: "full";
140
+ }>>;
141
+ }, z.core.$strict>], "type">;
96
142
  /** Namespace content accepts both stable reference blocks and graph-only blocks. */
97
143
  export const NamespaceContentBlockSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
98
144
  type: z.ZodLiteral<"prose">;
@@ -303,6 +349,18 @@ export const GenericDocKindSchema: z.ZodObject<{
303
349
  type: z.ZodLiteral<"token-ref">;
304
350
  topic: z.ZodString;
305
351
  section: z.ZodString;
352
+ }, z.core.$strict>, z.ZodObject<{
353
+ type: z.ZodLiteral<"reference">;
354
+ target: z.ZodString;
355
+ projection: z.ZodOptional<z.ZodObject<{
356
+ fields: z.ZodOptional<z.ZodArray<z.ZodString>>;
357
+ sections: z.ZodOptional<z.ZodArray<z.ZodString>>;
358
+ }, z.core.$strict>>;
359
+ presentation: z.ZodOptional<z.ZodEnum<{
360
+ compact: "compact";
361
+ summary: "summary";
362
+ full: "full";
363
+ }>>;
306
364
  }, z.core.$strict>], "type">>;
307
365
  previewType: z.ZodOptional<z.ZodEnum<{
308
366
  swatch: "swatch";
@@ -840,6 +898,18 @@ export const LegacyDocSchema: z.ZodUnion<readonly [z.ZodObject<{
840
898
  type: z.ZodLiteral<"token-ref">;
841
899
  topic: z.ZodString;
842
900
  section: z.ZodString;
901
+ }, z.core.$strict>, z.ZodObject<{
902
+ type: z.ZodLiteral<"reference">;
903
+ target: z.ZodString;
904
+ projection: z.ZodOptional<z.ZodObject<{
905
+ fields: z.ZodOptional<z.ZodArray<z.ZodString>>;
906
+ sections: z.ZodOptional<z.ZodArray<z.ZodString>>;
907
+ }, z.core.$strict>>;
908
+ presentation: z.ZodOptional<z.ZodEnum<{
909
+ compact: "compact";
910
+ summary: "summary";
911
+ full: "full";
912
+ }>>;
843
913
  }, z.core.$strict>], "type">>;
844
914
  previewType: z.ZodOptional<z.ZodEnum<{
845
915
  swatch: "swatch";
@@ -862,6 +932,7 @@ export type AuthoredDocKind = import("./base/type.js").AuthoredDocKind;
862
932
  export type NamespaceDoc = import("./namespace/type.js").NamespaceDoc;
863
933
  export type ReferenceContentBlock = import("./reference/type.js").ReferenceContentBlock;
864
934
  export type GraphContentBlock = import("./reference/type.js").GraphContentBlock;
935
+ export type ReferenceSection = import("./reference/type.js").ReferenceSection;
865
936
  export type ReferenceDoc = import("./reference/type.js").ReferenceDoc;
866
937
  export type SingleComponentDoc = import("./component/type.js").SingleComponentDoc;
867
938
  export type ComponentPropDoc = import("./base/type.js").ComponentPropDoc;
@@ -874,6 +945,7 @@ export type _AuthoredDocKindDriftLock = import("../_shared/contract.js").Expect<
874
945
  export type _AuthoredDocGraphDriftLock = import("../_shared/contract.js").Expect<import("../_shared/contract.js").MutuallyAssignable<z.infer<typeof _AuthoredDocGraphSchema>, AuthoredDocGraphFieldsType>>;
875
946
  export type _ReferenceContentBlockDriftLock = import("../_shared/contract.js").Expect<import("../_shared/contract.js").Equal<z.infer<typeof ReferenceContentBlockSchema>, ReferenceContentBlock>>;
876
947
  export type _GraphContentBlockDriftLock = import("../_shared/contract.js").Expect<import("../_shared/contract.js").Equal<z.infer<typeof GraphContentBlockSchema>, GraphContentBlock>>;
948
+ export type _SectionContentBlockDriftLock = import("../_shared/contract.js").Expect<import("../_shared/contract.js").Equal<z.infer<typeof SectionContentBlockSchema>, ReferenceSection["content"][number]>>;
877
949
  /**
878
950
  * A stamped component doc as it loads. The loader accepts what the unstamped
879
951
  * format always accepted, so stamping an existing doc never breaks it:
@@ -16,6 +16,7 @@ import {z} from 'zod';
16
16
  /** @typedef {import('./namespace/type.js').NamespaceDoc} NamespaceDoc */
17
17
  /** @typedef {import('./reference/type.js').ReferenceContentBlock} ReferenceContentBlock */
18
18
  /** @typedef {import('./reference/type.js').GraphContentBlock} GraphContentBlock */
19
+ /** @typedef {import('./reference/type.js').ReferenceSection} ReferenceSection */
19
20
  /** @typedef {import('./reference/type.js').ReferenceDoc} ReferenceDoc */
20
21
  /** @typedef {import('./component/type.js').SingleComponentDoc} SingleComponentDoc */
21
22
  /** @typedef {import('./base/type.js').ComponentPropDoc} ComponentPropDoc */
@@ -179,6 +180,20 @@ export const GraphContentBlockSchema = z.discriminatedUnion('type', [
179
180
  ReferenceBlockSchema,
180
181
  ]);
181
182
 
183
+ /**
184
+ * A topic section's blocks: the stable union, plus a reference block, which a
185
+ * read inlines as the doc it includes.
186
+ */
187
+ export const SectionContentBlockSchema = z.discriminatedUnion('type', [
188
+ ProseBlockSchema,
189
+ HeadingBlockSchema,
190
+ CodeBlockSchema,
191
+ TableBlockSchema,
192
+ ListBlockSchema,
193
+ TokenReferenceBlockSchema,
194
+ ReferenceBlockSchema,
195
+ ]);
196
+
182
197
  /** Namespace content accepts both stable reference blocks and graph-only blocks. */
183
198
  export const NamespaceContentBlockSchema = z.discriminatedUnion('type', [
184
199
  ProseBlockSchema,
@@ -210,12 +225,21 @@ export const NamespaceContentBlockSchema = z.discriminatedUnion('type', [
210
225
  * >} _GraphContentBlockDriftLock
211
226
  */
212
227
 
228
+ /**
229
+ * @typedef {import('../_shared/contract.js').Expect<
230
+ * import('../_shared/contract.js').Equal<
231
+ * z.infer<typeof SectionContentBlockSchema>,
232
+ * ReferenceSection['content'][number]
233
+ * >
234
+ * >} _SectionContentBlockDriftLock
235
+ */
236
+
213
237
  const ReferenceSectionSchema = z
214
238
  .object({
215
239
  id: nonEmptyString.optional(),
216
240
  title: nonEmptyString,
217
241
  category: z.string().optional(),
218
- content: z.array(ReferenceContentBlockSchema),
242
+ content: z.array(SectionContentBlockSchema),
219
243
  previewType: z
220
244
  .enum([
221
245
  'swatch',
@@ -182,6 +182,31 @@ describe('unknown fields', () => {
182
182
  );
183
183
  });
184
184
 
185
+ it("are refused inside a section's reference block, which a section takes", () => {
186
+ const [section] = EXAMPLES.generic.sections;
187
+ const reference = {
188
+ type: 'reference',
189
+ target: '@astryxdesign/cli:schema:integration',
190
+ projection: {fields: ['docs']},
191
+ presentation: 'compact',
192
+ };
193
+ /** @param {object} block */
194
+ const withBlock = block =>
195
+ parseDoc(
196
+ {...EXAMPLES.generic, sections: [{...section, content: [block]}]},
197
+ 'r.doc.mjs',
198
+ );
199
+ expect(() => withBlock(reference)).not.toThrow();
200
+ expect(() => withBlock({...reference, notAField: true})).toThrow();
201
+ expect(() =>
202
+ withBlock({...reference, projection: {fields: ['docs'], rows: []}}),
203
+ ).toThrow();
204
+ // Workflow and collection blocks belong to a namespace doc.
205
+ expect(() =>
206
+ withBlock({type: 'collection', source: {slot: 'guides'}}),
207
+ ).toThrow();
208
+ });
209
+
185
210
  it('are refused inside sections and content blocks', () => {
186
211
  const [section] = EXAMPLES.generic.sections;
187
212
  expect(() =>
@@ -93,9 +93,9 @@ export const doc = {
93
93
  },
94
94
  {
95
95
  name: 'sections[].content',
96
- type: 'ReferenceContentBlock[]',
96
+ type: '(ReferenceContentBlock | ReferenceDocBlock)[]',
97
97
  description:
98
- 'Ordered content blocks: prose, heading, code, table, list, and token-ref. Graph-only workflow, collection, and reference blocks are available through GraphContentBlock on NamespaceDoc, without widening this stable union. Inside text, `{@link <target>}` links another doc by identity (`[<provider>:]<kind>:<name>`): the CLI prints the command that opens it, and `astryx doctor` warns on one that names no doc.',
98
+ "Ordered content blocks: prose, heading, code, table, list, token-ref, and reference. A `reference` block (`{type: 'reference', target, projection?, presentation?}`) includes another doc from its canonical source instead of a copy: a schema, command, function, or enum doc as `astryx docs` prints it, then the command that opens it. `projection.fields` keeps only those fields of a schema; `presentation` is `full` (the default), `compact` (no code blocks), or `summary` (only the doc's title, summary, and command). Any other doc shows as a summary. Graph-only workflow and collection blocks are available through GraphContentBlock on NamespaceDoc, without widening the stable ReferenceContentBlock union. Inside text, `{@link <target>}` links another doc by identity (`[<provider>:]<kind>:<name>`): the CLI prints the command that opens it, and `astryx doctor` warns on one that names no doc.",
99
99
  required: true,
100
100
  },
101
101
  {
@@ -144,7 +144,27 @@ export const docs = {
144
144
  },
145
145
  {
146
146
  type: 'prose',
147
- text: 'Each `sections[].content` is an ordered array of ReferenceContentBlock, the stable discriminated union of prose, heading, code, table, list, and token-ref. Docs-graph-only workflow, collection, and reference blocks are exported separately as GraphContentBlock and accepted by NamespaceDoc. choice, callout, and checklist remain invalid. ReferenceContentBlock is also reused by the `notes` field on SchemaDoc and CommandDoc. Inside text, `{@link <target>}` links another doc by identity (`[<provider>:]<kind>:<name>`): the CLI prints the command that opens it, and `astryx doctor` warns on one that names no doc.',
147
+ text: 'Each `sections[].content` is an ordered array of ReferenceContentBlock, the stable discriminated union of prose, heading, code, table, list, and token-ref, plus the reference block (ReferenceDocBlock). A read inlines a reference block the way it inlines a token-ref, so `astryx docs`, in text and in `--json`, returns only the stable block kinds. Docs-graph-only workflow and collection blocks are exported separately as GraphContentBlock and accepted by NamespaceDoc. choice, callout, and checklist remain invalid. ReferenceContentBlock is also reused by the `notes` field on SchemaDoc and CommandDoc. Inside text, `{@link <target>}` links another doc by identity (`[<provider>:]<kind>:<name>`): the CLI prints the command that opens it, and `astryx doctor` warns on one that names no doc.',
148
+ },
149
+ {
150
+ type: 'prose',
151
+ text: "A reference block includes content, where a link only points at it: `astryx doctor integration docs` fails when its target names no doc, when `projection.fields` names a field the schema does not have, or when the doc cannot take the projection or presentation it sets, and a read marks the missing content. A target without a provider names a doc of the package that wrote it, so an integration names the CLI's docs with the CLI's provider, as in `@astryxdesign/cli:schema:integration`.",
152
+ },
153
+ {
154
+ type: 'code',
155
+ lang: 'js',
156
+ label: 'A section that includes two fields of the integration manifest',
157
+ code: `{
158
+ title: 'Point the manifest at your folders',
159
+ content: [
160
+ {type: 'prose', text: 'Add these fields to astryx.integration.mjs.'},
161
+ {
162
+ type: 'reference',
163
+ target: '@astryxdesign/cli:schema:integration',
164
+ projection: {fields: ['components', 'docs']},
165
+ },
166
+ ],
167
+ }`,
148
168
  },
149
169
  {
150
170
  type: 'code',
@@ -158,10 +178,17 @@ export const docs = {
158
178
  | { type: 'list'; style: 'ordered' | 'unordered' | 'do' | 'dont'; items: string[] }
159
179
  | { type: 'token-ref'; topic: string; section: string };
160
180
 
181
+ type ReferenceDocBlock = {
182
+ type: 'reference';
183
+ target: string;
184
+ projection?: { fields?: string[]; sections?: string[] };
185
+ presentation?: 'summary' | 'compact' | 'full';
186
+ };
187
+
161
188
  type GraphContentBlock =
162
189
  | { type: 'workflow'; title?: string; steps: WorkflowStep[] }
163
190
  | { type: 'collection'; source: {slot: string}; presentation?: 'list' | 'cards' | 'compact'; whenEmpty?: 'show' | 'omit' }
164
- | { type: 'reference'; target: string; presentation?: 'summary' | 'compact' };`,
191
+ | ReferenceDocBlock;`,
165
192
  },
166
193
  {
167
194
  type: 'prose',
@@ -30,19 +30,32 @@ export interface CollectionDocBlock {
30
30
  whenEmpty?: 'show' | 'omit';
31
31
  }
32
32
 
33
- /** A bounded projection of one canonical doc. */
33
+ /**
34
+ * A bounded projection of one canonical doc. In a namespace doc's `blocks` it
35
+ * is layout the docs tree renders later. In a topic section, a read includes
36
+ * the doc it names in place of the block: a schema, command, function, or
37
+ * enum doc as `astryx docs` prints it (`projection.fields` keeps only those
38
+ * fields of a schema), then the command that opens that doc. Any other doc
39
+ * shows its title and summary.
40
+ */
34
41
  export interface ReferenceDocBlock {
35
42
  type: 'reference';
43
+ /** The doc it names, by identity: `[<provider>:]<kind>:<name>`. */
36
44
  target: string;
37
45
  projection?: {
38
46
  fields?: string[];
39
47
  sections?: string[];
40
48
  };
49
+ /** `summary`: only the doc's title, summary, and the command that opens it.
50
+ * `compact`: the included doc without its code blocks. `full`, the default:
51
+ * the included doc. */
41
52
  presentation?: 'summary' | 'compact' | 'full';
42
53
  }
43
54
 
44
- /** Graph-only content blocks. These are additive and do not widen the stable
45
- * {@link ReferenceContentBlock} union consumed by existing exhaustive renderers. */
55
+ /** Graph-only content blocks, for a namespace doc's `blocks`. These are
56
+ * additive and do not widen the stable {@link ReferenceContentBlock} union
57
+ * consumed by existing exhaustive renderers. A topic section accepts the
58
+ * `reference` block too, and a read inlines it as stable blocks. */
46
59
  export type GraphContentBlock =
47
60
  WorkflowDocBlock | CollectionDocBlock | ReferenceDocBlock;
48
61
 
@@ -148,8 +161,10 @@ export interface ReferenceSection {
148
161
  /** Navigation category ('guide' | 'foundations'). Mirrors the parent doc's
149
162
  * category so sections can be grouped independently in the docsite nav. */
150
163
  category?: string;
151
- /** Ordered content blocks. Mix prose, code, tables, and lists freely. */
152
- content: ReferenceContentBlock[];
164
+ /** Ordered content blocks. Mix prose, code, tables, and lists freely. A
165
+ * `reference` block includes another doc from its canonical source, so a
166
+ * guide never copies a schema's fields or a command's options. */
167
+ content: (ReferenceContentBlock | ReferenceDocBlock)[];
153
168
  /** Preview type for token tables in this section. When set, the docsite
154
169
  * renders a visual preview column using the token's computed CSS value
155
170
  * from the current theme. Omit for non-token sections. */
@@ -14,11 +14,12 @@ export const doc = {
14
14
  displayName: 'astryx build',
15
15
  namespace: 'cli/commands',
16
16
  summary:
17
- 'Build a page: composition kit for an idea, or the workflow playbook (no args)',
17
+ 'Build a page: the template to start from, or the workflow playbook (no query)',
18
18
  description:
19
- 'The assemble-a-page entry point. With no query it returns the how-to-build-a-page ' +
20
- 'playbook; with a query it groups the unified search hits into a composition kit: ' +
21
- 'the closest templates, drop-in blocks, and idea-specific components and hooks.',
19
+ 'The build-a-page entry point. With no query it returns the how-to-build-a-page ' +
20
+ 'playbook; with a query it names the page template to start from (always one: the ' +
21
+ 'closest page template, or the app shell when none matches), the next two templates, and the ' +
22
+ 'drop-in blocks and idea-specific components and hooks around it.',
22
23
  fn: 'build',
23
24
  args: [{name: 'query', param: 'query', required: false}],
24
25
  options: [
@@ -35,12 +36,16 @@ export const doc = {
35
36
  },
36
37
  {
37
38
  flag: '--verbose',
38
- description: 'Verbose output (include import paths and match reason)',
39
+ description:
40
+ 'Verbose output (every block and component, full descriptions, import paths and match reason)',
39
41
  },
40
42
  ],
41
43
  examples: [
42
44
  {label: 'Get the playbook', cli: 'astryx build'},
43
- {label: 'Compose a page', cli: 'astryx build "analytics dashboard" --json'},
45
+ {
46
+ label: 'Find the template to start from',
47
+ cli: 'astryx build "analytics dashboard" --json',
48
+ },
44
49
  ],
45
50
  exitCodes: [
46
51
  {code: 0, when: 'success (including zero matches)'},