@astryxdesign/cli 0.6.3-canary.7ada42e → 0.6.3-canary.7ec7be0

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 (221) hide show
  1. package/README.md +21 -19
  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/component/_adapter.d.mts +6 -12
  16. package/api/component/_adapter.mjs +20 -10
  17. package/api/component/component.mjs +60 -12
  18. package/api/component/list/list.mjs +3 -2
  19. package/api/docs/_adapter.d.mts +251 -28
  20. package/api/docs/_adapter.mjs +918 -35
  21. package/api/docs/detail/detail.mjs +11 -3
  22. package/api/docs/detail/section/section.mjs +24 -13
  23. package/api/docs/detail/section/section.test.mjs +15 -6
  24. package/api/docs/docs.d.mts +5 -3
  25. package/api/docs/docs.doc.mjs +38 -17
  26. package/api/docs/docs.mjs +44 -8
  27. package/api/docs/docs.test.mjs +158 -4
  28. package/api/docs/docs.type.d.mts +181 -2
  29. package/api/docs/docs.type.mjs +117 -3
  30. package/api/docs/index/index.mjs +11 -3
  31. package/api/docs/index/index.test.mjs +1 -1
  32. package/api/docs/integration-tree.test.mjs +555 -0
  33. package/api/docs/integrationDocs.test.mjs +14 -14
  34. package/api/docs/list/list.mjs +25 -5
  35. package/api/docs/node/node.d.mts +43 -0
  36. package/api/docs/node/node.mjs +192 -0
  37. package/api/docs/reference-blocks.test.mjs +406 -0
  38. package/api/doctor/doctor.d.mts +30 -2
  39. package/api/doctor/doctor.mjs +151 -8
  40. package/api/doctor/doctor.test.mjs +95 -7
  41. package/api/index.d.mts +1 -1
  42. package/api/index.mjs +1 -0
  43. package/api/init/init.doc.mjs +1 -1
  44. package/api/integration/add-contribution.d.mts +2 -1
  45. package/api/integration/add-contribution.mjs +107 -5
  46. package/api/integration/add-contribution.test.mjs +137 -0
  47. package/api/integration/authoring-checks.mjs +138 -28
  48. package/api/integration/authoring-checks.test.mjs +171 -3
  49. package/api/integration/authoring-checks.type.mjs +6 -1
  50. package/api/integration/integration-authoring.type.d.mts +2 -0
  51. package/api/integration/integration-authoring.type.mjs +2 -0
  52. package/api/integration/integrationAdd.doc.mjs +6 -0
  53. package/api/integration/integrationAddDoc.doc.mjs +7 -1
  54. package/api/integration/integrationDocConflicts.doc.mjs +1 -1
  55. package/api/integration/integrationPackCheck.doc.mjs +1 -1
  56. package/api/integration/integrationTemplateConflicts.doc.d.mts +3 -0
  57. package/api/integration/integrationTemplateConflicts.doc.mjs +3 -0
  58. package/api/integration/pack-check.mjs +34 -0
  59. package/api/integration/pack-check.test.mjs +121 -0
  60. package/api/integration/pack-check.type.d.mts +26 -2
  61. package/api/integration/pack-check.type.mjs +14 -1
  62. package/api/integration/template-conflict-compatibility.test.mjs +73 -0
  63. package/api/integration/validate-integration.test.mjs +3 -3
  64. package/api/integration/validateIntegration.doc.mjs +1 -1
  65. package/api/json/index.ts +2 -0
  66. package/api/layout/_adapter.mjs +20 -5
  67. package/api/search/search.d.mts +59 -1
  68. package/api/search/search.doc.mjs +4 -3
  69. package/api/search/search.mjs +442 -71
  70. package/api/search/search.test.mjs +91 -2
  71. package/api/search/search.type.d.mts +13 -1
  72. package/api/search/search.type.mjs +4 -1
  73. package/api/template/list/list.mjs +1 -0
  74. package/api/template/table-floating-bulk-actions.test.mjs +66 -0
  75. package/api/template/template-integration.test.mjs +1072 -3
  76. package/api/template/template.doc.mjs +27 -7
  77. package/api/template/template.mjs +45 -8
  78. package/api/template/template.type.d.mts +6 -8
  79. package/api/template/template.type.mjs +3 -2
  80. package/api/theme/template/template.test.mjs +5 -0
  81. package/api/theme/themeTemplate.doc.mjs +1 -1
  82. package/assets/docs/getting-started.doc.mjs +2 -2
  83. package/assets/docs/layout.doc.dense.mjs +2 -2
  84. package/assets/docs/layout.doc.mjs +1 -1
  85. package/assets/docs/principles.doc.mjs +6 -6
  86. package/assets/docs/styling-libraries.doc.mjs +3 -3
  87. package/assets/docs/styling.doc.mjs +4 -4
  88. package/assets/docs/theme.doc.mjs +4 -4
  89. package/assets/docs/tokens.doc.mjs +1 -1
  90. package/assets/docs/tree/api.doc.mjs +30 -0
  91. package/assets/docs/tree/cli.doc.mjs +23 -0
  92. package/assets/docs/tree/commands.doc.mjs +25 -0
  93. package/assets/docs/{cli-integrations.doc.mjs → tree/integrations.doc.mjs} +37 -9
  94. package/assets/docs/tree/integrations.test.mjs +62 -0
  95. package/assets/docs/tree/writing-docs.doc.mjs +286 -0
  96. package/assets/docs/working-with-ai.doc.mjs +3 -3
  97. package/assets/templates/blocks/components/CheckboxList/CheckboxListSelectAllPattern.doc.mjs +1 -1
  98. package/assets/templates/blocks/components/CheckboxList/CheckboxListSelectAllPattern.tsx +1 -3
  99. package/assets/templates/blocks/components/Table/TableBulkActionsTable.doc.mjs +14 -0
  100. package/assets/templates/blocks/components/Table/TableBulkActionsTable.tsx +71 -0
  101. package/assets/templates/blocks/components/Table/TableFloatingBulkActionsTable.doc.mjs +19 -0
  102. package/assets/templates/blocks/components/Table/TableFloatingBulkActionsTable.tsx +139 -0
  103. package/authoring/debug/parse.d.mts +3 -3
  104. package/authoring/doctypes/_schema.d.mts +119 -117
  105. package/authoring/doctypes/_schema.mjs +54 -3
  106. package/authoring/doctypes/base/graph-fields.doc.mjs +7 -5
  107. package/authoring/doctypes/base/type.ts +6 -5
  108. package/authoring/doctypes/command/command.doc.mjs +1 -1
  109. package/authoring/doctypes/command/type.ts +2 -2
  110. package/authoring/doctypes/enum/enum.doc.mjs +1 -1
  111. package/authoring/doctypes/enum/type.ts +1 -1
  112. package/authoring/doctypes/function/function.doc.mjs +3 -2
  113. package/authoring/doctypes/function/type.ts +3 -2
  114. package/authoring/doctypes/load-contract.test.mjs +26 -1
  115. package/authoring/doctypes/namespace/namespace.doc.mjs +6 -10
  116. package/authoring/doctypes/namespace/parse.test.mjs +23 -25
  117. package/authoring/doctypes/namespace/type.ts +5 -2
  118. package/authoring/doctypes/parse.mjs +3 -2
  119. package/authoring/doctypes/reference/reference.doc.mjs +34 -5
  120. package/authoring/doctypes/reference/type.ts +28 -11
  121. package/authoring/doctypes/schema/schema.doc.mjs +1 -1
  122. package/authoring/doctypes/schema/type.ts +1 -1
  123. package/authoring/doctypes/template/parse.d.mts +2 -0
  124. package/authoring/doctypes/template/parse.mjs +4 -0
  125. package/authoring/doctypes/template/parse.test.mjs +18 -0
  126. package/authoring/doctypes/template/template.doc.mjs +6 -0
  127. package/authoring/doctypes/template/type.ts +8 -0
  128. package/authoring/identity/identity.doc.mjs +2 -2
  129. package/authoring/index.d.ts +1 -0
  130. package/authoring/integration/type.ts +1 -1
  131. package/clients/cli/commands/build-theme.adaptations.test.mjs +100 -1
  132. package/clients/cli/commands/build-theme.mjs +1 -1
  133. package/clients/cli/commands/build.doc.mjs +11 -6
  134. package/clients/cli/commands/build.mjs +105 -67
  135. package/clients/cli/commands/build.text-fields.test.mjs +41 -0
  136. package/clients/cli/commands/component/index.mjs +1 -1
  137. package/clients/cli/commands/component-ownership.test.mjs +3 -3
  138. package/clients/cli/commands/discover.broken-integration.test.mjs +7 -8
  139. package/clients/cli/commands/discover.mjs +1 -1
  140. package/clients/cli/commands/docs.doc.mjs +20 -8
  141. package/clients/cli/commands/docs.mjs +183 -69
  142. package/clients/cli/commands/docs.test.mjs +120 -16
  143. package/clients/cli/commands/doctor-integration-docs.doc.mjs +2 -2
  144. package/clients/cli/commands/doctor-integration-templates.doc.mjs +14 -7
  145. package/clients/cli/commands/doctor-integration.test.mjs +75 -1
  146. package/clients/cli/commands/doctor.mjs +53 -16
  147. package/clients/cli/commands/integration-add.doc.mjs +10 -0
  148. package/clients/cli/commands/integration.mjs +1 -0
  149. package/clients/cli/commands/search.mjs +11 -2
  150. package/clients/cli/commands/setup-nudge.test.mjs +6 -0
  151. package/clients/cli/commands/template.doc.mjs +23 -6
  152. package/clients/cli/commands/template.mjs +4 -91
  153. package/clients/cli/index.mjs +8 -0
  154. package/clients/cli/lib/manifest.mjs +9 -2
  155. package/foundation/agent-docs/agent-docs.d.mts +3 -2
  156. package/foundation/agent-docs/agent-docs.mjs +13 -9
  157. package/foundation/agent-docs/agent-docs.test.mjs +19 -1
  158. package/foundation/config/project.d.mts +12 -11
  159. package/foundation/config/project.mjs +73 -59
  160. package/foundation/config/project.test.mjs +141 -5
  161. package/foundation/discovery/authoring-self-docs.d.mts +12 -0
  162. package/foundation/discovery/authoring-self-docs.mjs +20 -8
  163. package/foundation/discovery/authoring-self-docs.test.mjs +25 -9
  164. package/foundation/discovery/cli-self-docs.d.mts +40 -34
  165. package/foundation/discovery/cli-self-docs.mjs +91 -115
  166. package/foundation/discovery/cli-self-docs.test.mjs +104 -166
  167. package/foundation/discovery/component-discovery.d.mts +38 -0
  168. package/foundation/discovery/component-discovery.mjs +48 -0
  169. package/foundation/discovery/docs-discovery.d.mts +109 -9
  170. package/foundation/discovery/docs-discovery.mjs +223 -24
  171. package/foundation/discovery/docs-discovery.test.mjs +103 -27
  172. package/foundation/discovery/docs-output-budget.d.mts +2 -2
  173. package/foundation/discovery/docs-output-budget.mjs +1 -1
  174. package/foundation/discovery/docs-section-key.d.mts +28 -10
  175. package/foundation/discovery/docs-section-key.mjs +134 -33
  176. package/foundation/discovery/docs-section-key.test.mjs +41 -19
  177. package/foundation/discovery/template-adapter.d.mts +92 -6
  178. package/foundation/discovery/template-adapter.mjs +453 -17
  179. package/foundation/discovery/template-adapter.test.mjs +42 -0
  180. package/foundation/discovery/template-conflict-release.d.mts +13 -0
  181. package/foundation/discovery/template-conflict-release.mjs +40 -0
  182. package/foundation/discovery/template-conflict-release.test.mjs +40 -0
  183. package/foundation/doc-compiler/bundle.mjs +61 -1
  184. package/foundation/doc-compiler/bundle.test.mjs +21 -10
  185. package/foundation/doc-compiler/compile.d.mts +113 -132
  186. package/foundation/doc-compiler/compile.mjs +57 -10
  187. package/foundation/doc-compiler/diagnostics.mjs +28 -0
  188. package/foundation/doc-compiler/doc-loads.test.mjs +2 -2
  189. package/foundation/doc-compiler/inputs.d.mts +2 -2
  190. package/foundation/doc-compiler/inputs.mjs +6 -1
  191. package/foundation/doc-compiler/ir.mjs +7 -0
  192. package/foundation/doc-compiler/lenses.d.mts +8 -5
  193. package/foundation/doc-compiler/lenses.mjs +50 -4
  194. package/foundation/doc-compiler/links.d.mts +162 -0
  195. package/foundation/doc-compiler/links.mjs +294 -0
  196. package/foundation/doc-compiler/links.test.mjs +192 -0
  197. package/foundation/doc-compiler/lower-doc.test.mjs +5 -2
  198. package/foundation/doc-compiler/read.d.mts +3 -2
  199. package/foundation/doc-compiler/read.mjs +6 -1
  200. package/foundation/doc-compiler/tree.d.mts +288 -0
  201. package/foundation/doc-compiler/tree.mjs +876 -0
  202. package/foundation/doc-compiler/tree.test.mjs +598 -0
  203. package/foundation/integrations/autolink.test.mjs +1 -1
  204. package/foundation/integrations/cli-requirement.d.mts +45 -0
  205. package/foundation/integrations/cli-requirement.mjs +154 -0
  206. package/foundation/integrations/cli-requirement.test.mjs +84 -0
  207. package/foundation/integrations/contribution-inventory.d.mts +2 -1
  208. package/foundation/integrations/contribution-inventory.mjs +10 -4
  209. package/foundation/integrations/contribution-inventory.test.mjs +19 -0
  210. package/foundation/integrations/integration-warnings.d.mts +9 -2
  211. package/foundation/integrations/integration-warnings.mjs +51 -26
  212. package/foundation/integrations/integration-warnings.test.mjs +74 -1
  213. package/foundation/integrations/validate-contributions.mjs +25 -27
  214. package/foundation/response/response-types.doc.d.mts +5 -1
  215. package/foundation/response/response-types.doc.mjs +19 -10
  216. package/foundation/text/string-utils.d.mts +8 -0
  217. package/foundation/text/string-utils.mjs +18 -0
  218. package/foundation/xle/expand.mjs +1 -1
  219. package/foundation/xle/xle.test.mjs +13 -0
  220. package/package.json +9 -9
  221. package/assets/docs/cli.doc.mjs +0 -15
@@ -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
+ });
@@ -25,7 +25,7 @@ import {
25
25
  } from './compile.mjs';
26
26
  import {diagnostic as rawDiagnostic, sortDiagnostics} from './diagnostics.mjs';
27
27
  import {collectDocInputs} from './inputs.mjs';
28
- import {compileDocFile, loadTopicInput} from './read.mjs';
28
+ import {compileDocFile, loadTopicInput, readDocView} from './read.mjs';
29
29
  import {packageSource, scrubPaths} from './source.mjs';
30
30
 
31
31
  /**
@@ -127,6 +127,50 @@ export async function compileDocs(project, {lang = null} = {}) {
127
127
  /** @type {Array<CompiledDocNode | CompiledReferenceNode>} */
128
128
  const nodes = [];
129
129
  for (const input of inputs) {
130
+ // A guide the docs tree places is a reference topic, lowered and linked
131
+ // like one; a namespace doc lowers like any typed descriptor below.
132
+ if (
133
+ input.root === 'tree' &&
134
+ (await treeDocType(input.file)) === 'generic'
135
+ ) {
136
+ const entry = {
137
+ name: input.name,
138
+ package: input.owner,
139
+ path: input.file,
140
+ extensions: [],
141
+ tree: true,
142
+ };
143
+ const topic = await loadTopicInput(entry, lang);
144
+ if ('error' in topic.base || 'overlayError' in topic.base) {
145
+ const failure =
146
+ 'error' in topic.base ? topic.base.error : topic.base.overlayError;
147
+ diagnostics.push(
148
+ diagnostic('error' in topic.base ? 'load_failed' : 'overlay_failed', {
149
+ provider: input.owner,
150
+ source: input.source,
151
+ message: `${topic.base.file}: ${messageOf(failure)}`,
152
+ }),
153
+ );
154
+ continue;
155
+ }
156
+ try {
157
+ const linked = await linkReferenceTopic(
158
+ lowerReferenceTopic(topic),
159
+ lowerTarget,
160
+ );
161
+ diagnostics.push(...unresolvedReferences(linked, input));
162
+ nodes.push(linked);
163
+ } catch (error) {
164
+ diagnostics.push(
165
+ diagnostic('invalid_topic', {
166
+ provider: input.owner,
167
+ source: input.source,
168
+ message: messageOf(error),
169
+ }),
170
+ );
171
+ }
172
+ continue;
173
+ }
130
174
  if (input.root === 'docs') {
131
175
  if (input.role !== 'base') continue;
132
176
  const lowered = topics.get(input.name.toLowerCase());
@@ -146,6 +190,7 @@ export async function compileDocs(project, {lang = null} = {}) {
146
190
  input.root === 'components' || input.root === 'hooks' ? lang : null,
147
191
  check: true,
148
192
  ...(input.root === 'templates' ? {loader: 'template'} : {}),
193
+ ...(input.root === 'tree' ? {loader: 'native'} : {}),
149
194
  ...(input.root === 'themes'
150
195
  ? {
151
196
  label: themeDescriptorLabel(input.file, input.owner),
@@ -174,6 +219,21 @@ export async function compileDocs(project, {lang = null} = {}) {
174
219
  };
175
220
  }
176
221
 
222
+ /**
223
+ * The stamped type of a docs-tree file, or null when it cannot be read; the
224
+ * compile that follows reports why.
225
+ * @param {string} file
226
+ * @returns {Promise<string | null>}
227
+ */
228
+ async function treeDocType(file) {
229
+ try {
230
+ const doc = await readDocView(file, {root: 'tree', loader: 'native'});
231
+ return typeof doc?.type === 'string' ? doc.type : null;
232
+ } catch {
233
+ return null;
234
+ }
235
+ }
236
+
177
237
  /**
178
238
  * A warning for each token reference in a linked topic that finds no topic or
179
239
  * no section.
@@ -144,19 +144,26 @@ describe('compileDocs over a broken integration', () => {
144
144
  expect(bundle.nodes.some(node => node.id === 'acme-guide')).toBe(true);
145
145
  });
146
146
 
147
- it('reports a component doc that fails to load, and compiles the rest', async () => {
147
+ it('withdraws a component doc that fails to load, reports it, and compiles the rest', async () => {
148
148
  write(
149
149
  'components/AcmeCard.doc.mjs',
150
150
  "throw new Error('boom');\nexport default {};\n",
151
151
  );
152
152
  const project = await Project.load(tmpDir);
153
153
  const bundle = await compileDocs(project);
154
- const found = bundle.diagnostics.filter(d => d.provider === '@acme/kit');
155
- // Discovery lists the doc; compiling it fails at load, and only it.
156
- expect(found.map(d => [d.code, d.source])).toEqual([
157
- ['load_failed', '@acme/kit/components/AcmeCard.doc.mjs'],
158
- ]);
159
- expect(found[0].message).toMatch(/boom/);
154
+ // Discovery loads each integration component doc and withdraws one that
155
+ // fails, so the project reports it and the compiler never reads it.
156
+ const issues = (await project.issues()).filter(
157
+ issue => issue.package === '@acme/kit',
158
+ );
159
+ expect(issues.map(issue => issue.code)).toEqual(['invalid_component']);
160
+ expect(issues[0].message).toMatch(/boom/);
161
+ expect(
162
+ bundle.diagnostics.filter(d => d.provider === '@acme/kit'),
163
+ ).toEqual([]);
164
+ expect(
165
+ bundle.nodes.some(node => node.id === '@acme/kit:components:AcmeCard'),
166
+ ).toBe(false);
160
167
  expect(bundle.nodes.some(node => node.kind === 'reference')).toBe(true);
161
168
  });
162
169
 
@@ -165,9 +172,13 @@ describe('compileDocs over a broken integration', () => {
165
172
  'components/AcmeCard.doc.mjs',
166
173
  "export default {type: 'component', displayName: 'No name'};\n",
167
174
  );
168
- const bundle = await compileDocs(await Project.load(tmpDir));
169
- const found = bundle.diagnostics.filter(d => d.provider === '@acme/kit');
170
- expect(found.map(d => d.code)).toEqual(['invalid_doc']);
175
+ const project = await Project.load(tmpDir);
176
+ const bundle = await compileDocs(project);
177
+ const issues = (await project.issues()).filter(
178
+ issue => issue.package === '@acme/kit',
179
+ );
180
+ expect(issues.map(issue => issue.code)).toEqual(['invalid_component']);
181
+ expect(issues[0].message).toMatch(/invalid metadata/);
171
182
  expect(
172
183
  bundle.nodes.some(node => node.id === '@acme/kit:components:AcmeCard'),
173
184
  ).toBe(false);
@@ -1,44 +1,6 @@
1
1
  // @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
2
2
  // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
3
 
4
- /**
5
- * One authored file, as discovery loaded it.
6
- * @typedef {object} AuthoredFile
7
- * @property {string} file the file's name, for messages only
8
- * @property {any} [doc] the parsed doc, when it loaded
9
- * @property {unknown} [error] why it did not load or parse
10
- * @property {any} [overlay] the language overlay's export, when one applies
11
- * @property {unknown} [overlayError] why the overlay did not load
12
- */
13
- /**
14
- * @typedef {object} ReferenceTopicInput
15
- * @property {string} id the topic's name in the catalog
16
- * @property {string} provider the package that owns the topic
17
- * @property {string | null} replaces the topic it took the place of
18
- * @property {string | null} lang the overlay language, or null for authored text
19
- * @property {AuthoredFile} base
20
- * @property {Array<AuthoredFile & {provider: string}>} extensions in merge order
21
- */
22
- /**
23
- * A token reference after linking: the target section's content, or why it
24
- * has none.
25
- * @typedef {{status: 'resolved', topic: string, section: string, previewType?: string, content: any[]}
26
- * | {status: 'unknown-topic'}
27
- * | {status: 'unknown-section'}} TokenRefResolution
28
- */
29
- /**
30
- * @typedef {object} CompiledReferenceNode
31
- * @property {number} schemaVersion
32
- * @property {'reference'} kind
33
- * @property {'lowered' | 'linked'} stage `linked` once every token reference
34
- * carries its resolution; a lowered node carries none
35
- * @property {string} id the topic's name in the catalog
36
- * @property {string | null} lang
37
- * @property {{provider: string, replaces: string | null, extensions: string[]}} provenance
38
- * @property {Record<string, string>} sourceTitles section key -> authored title
39
- * @property {any} doc the topic: authored fields in authored order, every
40
- * section keyed; a linked node's token references carry `resolved`
41
- */
42
4
  /**
43
5
  * Lower one topic: overlay each file, merge the extensions in order, and stamp
44
6
  * every section with its key.
@@ -148,106 +110,13 @@ export function lowerDoc(input: DocFileInput, { check, node: wantNode }?: {
148
110
  /** Bumped whenever the shape of a compiled node changes. */
149
111
  export const COMPILED_DOC_SCHEMA_VERSION: 1;
150
112
  /** Every kind a compiled node has: one per authored doc kind a root reads. */
151
- export const COMPILED_DOC_KINDS: readonly ["component", "function", "reference", "page", "block", "schema", "command", "enum", "theme"];
113
+ export const COMPILED_DOC_KINDS: readonly ["component", "function", "reference", "page", "block", "schema", "command", "enum", "theme", "namespace"];
152
114
  /**
153
115
  * The roots that read docs, and the kinds each may hold. A doc without a
154
116
  * stamped `type` (the legacy form) takes its root's first kind.
155
117
  * @type {Readonly<Record<string, readonly string[]>>}
156
118
  */
157
119
  export const ROOT_KINDS: Readonly<Record<string, readonly string[]>>;
158
- /**
159
- * One authored file, as discovery loaded it.
160
- */
161
- export type AuthoredFile = {
162
- /**
163
- * the file's name, for messages only
164
- */
165
- file: string;
166
- /**
167
- * the parsed doc, when it loaded
168
- */
169
- doc?: any;
170
- /**
171
- * why it did not load or parse
172
- */
173
- error?: unknown;
174
- /**
175
- * the language overlay's export, when one applies
176
- */
177
- overlay?: any;
178
- /**
179
- * why the overlay did not load
180
- */
181
- overlayError?: unknown;
182
- };
183
- export type ReferenceTopicInput = {
184
- /**
185
- * the topic's name in the catalog
186
- */
187
- id: string;
188
- /**
189
- * the package that owns the topic
190
- */
191
- provider: string;
192
- /**
193
- * the topic it took the place of
194
- */
195
- replaces: string | null;
196
- /**
197
- * the overlay language, or null for authored text
198
- */
199
- lang: string | null;
200
- base: AuthoredFile;
201
- /**
202
- * in merge order
203
- */
204
- extensions: Array<AuthoredFile & {
205
- provider: string;
206
- }>;
207
- };
208
- /**
209
- * A token reference after linking: the target section's content, or why it
210
- * has none.
211
- */
212
- export type TokenRefResolution = {
213
- status: "resolved";
214
- topic: string;
215
- section: string;
216
- previewType?: string;
217
- content: any[];
218
- } | {
219
- status: "unknown-topic";
220
- } | {
221
- status: "unknown-section";
222
- };
223
- export type CompiledReferenceNode = {
224
- schemaVersion: number;
225
- kind: "reference";
226
- /**
227
- * `linked` once every token reference
228
- * carries its resolution; a lowered node carries none
229
- */
230
- stage: "lowered" | "linked";
231
- /**
232
- * the topic's name in the catalog
233
- */
234
- id: string;
235
- lang: string | null;
236
- provenance: {
237
- provider: string;
238
- replaces: string | null;
239
- extensions: string[];
240
- };
241
- /**
242
- * section key -> authored title
243
- */
244
- sourceTitles: Record<string, string>;
245
- /**
246
- * the topic: authored fields in authored order, every
247
- * section keyed; a linked node's token references carry `resolved`
248
- */
249
- doc: any;
250
- };
251
120
  export type CompilerDiagnostic = import("./diagnostics.mjs").CompilerDiagnostic;
252
121
  /**
253
122
  * One authored doc of any kind but a reference topic, as its root loaded it.
@@ -360,3 +229,115 @@ export type LoweredDoc = {
360
229
  */
361
230
  overlayFailure?: unknown;
362
231
  };
232
+ /**
233
+ * One authored file, as discovery loaded it.
234
+ */
235
+ export type AuthoredFile = {
236
+ /**
237
+ * the file's name, for messages only
238
+ */
239
+ file: string;
240
+ /**
241
+ * the parsed doc, when it loaded
242
+ */
243
+ doc?: any;
244
+ /**
245
+ * why it did not load or parse
246
+ */
247
+ error?: unknown;
248
+ /**
249
+ * the language overlay's export, when one applies
250
+ */
251
+ overlay?: any;
252
+ /**
253
+ * why the overlay did not load
254
+ */
255
+ overlayError?: unknown;
256
+ };
257
+ export type ReferenceTopicInput = {
258
+ /**
259
+ * the topic's name in the catalog
260
+ */
261
+ id: string;
262
+ /**
263
+ * the package that owns the topic
264
+ */
265
+ provider: string;
266
+ /**
267
+ * the topic it took the place of
268
+ */
269
+ replaces: string | null;
270
+ /**
271
+ * the overlay language, or null for authored text
272
+ */
273
+ lang: string | null;
274
+ /**
275
+ * the owner's provider id; the package name
276
+ * when absent. The base file's sections resolve their links against it.
277
+ */
278
+ providerId?: string | undefined;
279
+ base: AuthoredFile;
280
+ /**
281
+ * in merge order; each extension's sections resolve their links against its
282
+ * own provider id
283
+ */
284
+ extensions: Array<AuthoredFile & {
285
+ provider: string;
286
+ providerId?: string;
287
+ }>;
288
+ /**
289
+ * a guide the docs tree places: its `placement` is
290
+ * read by the tree, so the topic reader accepts it
291
+ */
292
+ tree?: boolean | undefined;
293
+ };
294
+ /**
295
+ * A token reference after linking: the target section's content, or why it
296
+ * has none.
297
+ */
298
+ export type TokenRefResolution = {
299
+ status: "resolved";
300
+ topic: string;
301
+ section: string;
302
+ previewType?: string;
303
+ content: any[];
304
+ } | {
305
+ status: "unknown-topic";
306
+ } | {
307
+ status: "unknown-section";
308
+ };
309
+ export type CompiledReferenceNode = {
310
+ schemaVersion: number;
311
+ kind: "reference";
312
+ /**
313
+ * `linked` once every token reference
314
+ * carries its resolution; a lowered node carries none
315
+ */
316
+ stage: "lowered" | "linked";
317
+ /**
318
+ * the topic's name in the catalog
319
+ */
320
+ id: string;
321
+ lang: string | null;
322
+ provenance: {
323
+ provider: string;
324
+ replaces: string | null;
325
+ extensions: string[];
326
+ };
327
+ /**
328
+ * section key -> authored title
329
+ */
330
+ sourceTitles: Record<string, string>;
331
+ /**
332
+ * section key -> the
333
+ * provider id that wrote the section: a topic merges sections from its base
334
+ * and its extensions, and each section's links resolve against its own
335
+ * provider (spec:AST-047 FR9)
336
+ */
337
+ sectionProviders: Record<string, string>;
338
+ /**
339
+ * the topic: authored fields in authored order, every
340
+ * section keyed; a linked node's token references carry `resolved`
341
+ */
342
+ doc: any;
343
+ };
@@ -26,7 +26,7 @@ import {parseTheme} from '../../authoring/doctypes/theme/parse.mjs';
26
26
  import {mergeTopic, problemsInTopic} from '../discovery/docs-discovery.mjs';
27
27
  import {
28
28
  sectionKey,
29
- sectionKeyProblems,
29
+ sectionKeyErrors,
30
30
  sourceTitle,
31
31
  withSectionKeys,
32
32
  withSourceTitle,
@@ -63,6 +63,7 @@ export const COMPILED_DOC_KINDS = /** @type {const} */ ([
63
63
  'command',
64
64
  'enum',
65
65
  'theme',
66
+ 'namespace',
66
67
  ]);
67
68
 
68
69
  /**
@@ -76,6 +77,7 @@ export const ROOT_KINDS = Object.freeze({
76
77
  templates: ['page', 'block'],
77
78
  themes: ['theme'],
78
79
  'self-docs': ['command', 'function', 'schema', 'enum'],
80
+ tree: ['namespace', 'generic'],
79
81
  });
80
82
 
81
83
  /**
@@ -94,8 +96,14 @@ export const ROOT_KINDS = Object.freeze({
94
96
  * @property {string} provider the package that owns the topic
95
97
  * @property {string | null} replaces the topic it took the place of
96
98
  * @property {string | null} lang the overlay language, or null for authored text
99
+ * @property {string} [providerId] the owner's provider id; the package name
100
+ * when absent. The base file's sections resolve their links against it.
97
101
  * @property {AuthoredFile} base
98
- * @property {Array<AuthoredFile & {provider: string}>} extensions in merge order
102
+ * @property {Array<AuthoredFile & {provider: string, providerId?: string}>} extensions
103
+ * in merge order; each extension's sections resolve their links against its
104
+ * own provider id
105
+ * @property {boolean} [tree] a guide the docs tree places: its `placement` is
106
+ * read by the tree, so the topic reader accepts it
99
107
  */
100
108
 
101
109
  /**
@@ -116,10 +124,33 @@ export const ROOT_KINDS = Object.freeze({
116
124
  * @property {string | null} lang
117
125
  * @property {{provider: string, replaces: string | null, extensions: string[]}} provenance
118
126
  * @property {Record<string, string>} sourceTitles section key -> authored title
127
+ * @property {Record<string, string>} sectionProviders section key -> the
128
+ * provider id that wrote the section: a topic merges sections from its base
129
+ * and its extensions, and each section's links resolve against its own
130
+ * provider (spec:AST-047 FR9)
119
131
  * @property {any} doc the topic: authored fields in authored order, every
120
132
  * section keyed; a linked node's token references carry `resolved`
121
133
  */
122
134
 
135
+ /** Which provider wrote a section, until lowering records it by key. */
136
+ const SECTION_PROVIDER = Symbol('astryx.docs.sectionProvider');
137
+
138
+ /**
139
+ * Mark each section of one authored file with the provider that wrote it. The
140
+ * overlay, the merge, and the key stamp copy the mark with the section.
141
+ * @param {any} doc
142
+ * @param {string} provider
143
+ * @returns {any}
144
+ */
145
+ function markProvider(doc, provider) {
146
+ return {
147
+ ...doc,
148
+ sections: doc.sections.map((/** @type {any} */ section) =>
149
+ withSourceTitle({...section, [SECTION_PROVIDER]: provider}, sourceTitle(section)),
150
+ ),
151
+ };
152
+ }
153
+
123
154
  /**
124
155
  * Lower one topic: overlay each file, merge the extensions in order, and stamp
125
156
  * every section with its key.
@@ -127,14 +158,24 @@ export const ROOT_KINDS = Object.freeze({
127
158
  * @returns {CompiledReferenceNode}
128
159
  */
129
160
  export function lowerReferenceTopic(input) {
130
- let doc = readAuthoredFile(input.base);
161
+ let doc = markProvider(
162
+ readAuthoredFile(input.base, {placement: input.tree === true}),
163
+ input.providerId ?? input.provider,
164
+ );
131
165
  for (const extension of input.extensions) {
132
- doc = mergeTopic(doc, readAuthoredFile(extension));
133
- // Merging matches on keys, so this holds unless merge itself regresses.
134
- const problems = sectionKeyProblems(doc.sections);
166
+ doc = mergeTopic(
167
+ doc,
168
+ markProvider(
169
+ readAuthoredFile(extension),
170
+ extension.providerId ?? extension.provider,
171
+ ),
172
+ );
173
+ // Explicit authored IDs remain strict. Legacy title-derived collisions are
174
+ // assigned deterministic compatibility keys after every extension merges.
175
+ const problems = sectionKeyErrors(doc.sections);
135
176
  if (problems.length > 0) {
136
177
  throw new Error(
137
- `${extension.file}, extending ${input.id}, leaves two sections with one key: ${problems.join('; ')}`,
178
+ `${extension.file}, extending ${input.id}, leaves duplicate authored section IDs: ${problems.join('; ')}`,
138
179
  );
139
180
  }
140
181
  }
@@ -142,8 +183,12 @@ export function lowerReferenceTopic(input) {
142
183
  const keyed = withSectionKeys(doc);
143
184
  /** @type {Record<string, string>} */
144
185
  const sourceTitles = {};
186
+ /** @type {Record<string, string>} */
187
+ const sectionProviders = {};
145
188
  for (const section of keyed.sections) {
146
189
  sourceTitles[section.id] = sourceTitle(section);
190
+ sectionProviders[section.id] =
191
+ section[SECTION_PROVIDER] ?? input.providerId ?? input.provider;
147
192
  }
148
193
  return {
149
194
  schemaVersion: COMPILED_DOC_SCHEMA_VERSION,
@@ -157,7 +202,9 @@ export function lowerReferenceTopic(input) {
157
202
  extensions: input.extensions.map(extension => extension.provider),
158
203
  },
159
204
  sourceTitles,
160
- // The authored title travels in sourceTitles; JSON drops the symbol.
205
+ sectionProviders,
206
+ // The authored title and provider travel in sourceTitles and
207
+ // sectionProviders; JSON drops the symbols.
161
208
  doc: asJson(keyed, input.id),
162
209
  };
163
210
  }
@@ -254,13 +301,13 @@ function asJson(value, topic) {
254
301
  * @param {AuthoredFile} file
255
302
  * @returns {any}
256
303
  */
257
- function readAuthoredFile(file) {
304
+ function readAuthoredFile(file, {placement = false} = {}) {
258
305
  if ('error' in file) throw file.error;
259
306
  const parsed = file.doc;
260
307
  if (!('sections' in parsed)) {
261
308
  throw new Error(`${file.file} is not a reference document.`);
262
309
  }
263
- const problems = problemsInTopic(parsed);
310
+ const problems = problemsInTopic(parsed, {placement});
264
311
  if (problems.length > 0) {
265
312
  throw new Error(`${file.file} is invalid: ${problems.join('; ')}`);
266
313
  }
@@ -123,6 +123,34 @@ export const DIAGNOSTIC_CODES = Object.freeze(
123
123
  remediation:
124
124
  'Point the token reference at a topic and section that exist; `astryx docs <topic> --index` lists the section keys.',
125
125
  },
126
+ invalid_namespace: {
127
+ phase: 'link',
128
+ severity: 'error',
129
+ scope: 'node',
130
+ remediation:
131
+ 'Give each namespace a route-safe name (lowercase letters and digits joined by hyphens) that no other namespace in its package uses.',
132
+ },
133
+ invalid_placement: {
134
+ phase: 'link',
135
+ severity: 'error',
136
+ scope: 'node',
137
+ remediation:
138
+ 'Point placement.parent at a namespace of the same package ("namespace:<name>"), name one of its slots, and use a slot that accepts the doc\'s kind; `astryx docs authoring namespace-doc` lists the fields.',
139
+ },
140
+ overlapping_adoption: {
141
+ phase: 'link',
142
+ severity: 'error',
143
+ scope: 'node',
144
+ remediation:
145
+ 'Change the adoption rules so exactly one namespace adopts the doc, or give the doc an explicit placement.',
146
+ },
147
+ duplicate_route: {
148
+ phase: 'link',
149
+ severity: 'error',
150
+ scope: 'node',
151
+ remediation:
152
+ 'Rename or move one of the two docs, so each route in the docs tree belongs to one doc.',
153
+ },
126
154
  not_json: {
127
155
  phase: 'serialize',
128
156
  severity: 'error',
@@ -252,8 +252,8 @@ const RUNNERS = {
252
252
  sites: ['importDocModule'],
253
253
  },
254
254
  'foundation/discovery/template-adapter.mjs': {
255
- runs: '@babel/parser, to find the fixture references in template source',
256
- sites: ['require(@babel/parser)'],
255
+ runs: '@babel/parser, to find the fixture references in template source; and a template doc that does not validate, to read the replacement it declares',
256
+ sites: ['importDocModule', 'require(@babel/parser)'],
257
257
  },
258
258
  'foundation/discovery/theme-discovery.mjs': {
259
259
  runs: '@babel/parser and jscodeshift (CommonJS), each on first use, so listing bundled themes never loads jscodeshift',
@@ -2,7 +2,7 @@
2
2
  // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
3
 
4
4
  /**
5
- * @typedef {'components' | 'hooks' | 'templates' | 'themes' | 'docs' | 'self-docs'} DocRoot
5
+ * @typedef {'components' | 'hooks' | 'templates' | 'themes' | 'docs' | 'self-docs' | 'tree'} DocRoot
6
6
  */
7
7
  /**
8
8
  * One authored descriptor, as the compiler will read it.
@@ -45,7 +45,7 @@ export function selfDocFiles(): string[];
45
45
  export { packageSource };
46
46
  /** Where the CLI keeps self-documentation, relative to its package root. */
47
47
  export const SELF_DOC_TREES: string[];
48
- export type DocRoot = "components" | "hooks" | "templates" | "themes" | "docs" | "self-docs";
48
+ export type DocRoot = "components" | "hooks" | "templates" | "themes" | "docs" | "self-docs" | "tree";
49
49
  /**
50
50
  * One authored descriptor, as the compiler will read it.
51
51
  */
@@ -24,6 +24,7 @@ import {
24
24
  import {discoverHooks, findHookDoc} from '../discovery/hook-discovery.mjs';
25
25
  import {CLI_ROOT, findCoreDir} from '../fs/paths.mjs';
26
26
  import {packageSource} from './source.mjs';
27
+ import {treeDocFiles} from './tree.mjs';
27
28
 
28
29
  export {packageSource};
29
30
 
@@ -42,7 +43,7 @@ const NON_DESCRIPTOR_DIRS = new Set([
42
43
  ]);
43
44
 
44
45
  /**
45
- * @typedef {'components' | 'hooks' | 'templates' | 'themes' | 'docs' | 'self-docs'} DocRoot
46
+ * @typedef {'components' | 'hooks' | 'templates' | 'themes' | 'docs' | 'self-docs' | 'tree'} DocRoot
46
47
  */
47
48
 
48
49
  /**
@@ -125,6 +126,10 @@ export async function collectDocInputs(project) {
125
126
  }
126
127
  }
127
128
 
129
+ // The docs tree's own files: its namespaces and the guides it places.
130
+ for (const file of treeDocFiles()) {
131
+ list.add('tree', path.basename(file, '.doc.mjs'), CLI_PACKAGE, file);
132
+ }
128
133
  for (const file of selfDocFiles()) {
129
134
  const name = path
130
135
  .relative(CLI_ROOT, file)