@astryxdesign/cli 0.6.3-canary.1f7db5b → 0.6.3-canary.2c831e4

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 (126) hide show
  1. package/api/build/build.type.d.mts +2 -2
  2. package/api/build/build.type.mjs +2 -2
  3. package/api/component/component.type.d.mts +6 -6
  4. package/api/component/component.type.mjs +19 -19
  5. package/api/discover/discover.type.d.mts +4 -4
  6. package/api/discover/discover.type.mjs +10 -10
  7. package/api/docs/_adapter.d.mts +30 -27
  8. package/api/docs/_adapter.mjs +154 -124
  9. package/api/docs/compiled-topics.test.mjs +78 -0
  10. package/api/docs/detail/detail.d.mts +0 -15
  11. package/api/docs/detail/detail.mjs +14 -78
  12. package/api/docs/detail/section/section.mjs +22 -18
  13. package/api/docs/detail/section/section.test.mjs +4 -3
  14. package/api/docs/docs.type.d.mts +4 -4
  15. package/api/docs/docs.type.mjs +10 -10
  16. package/api/docs/index/index.mjs +6 -5
  17. package/api/doctor/doctor.mjs +3 -7
  18. package/api/hook/hook.type.d.mts +3 -3
  19. package/api/hook/hook.type.mjs +11 -11
  20. package/api/integration/add-contribution.mjs +5 -3
  21. package/api/integration/add-contribution.test.mjs +4 -4
  22. package/api/integration/pack-check.mjs +49 -7
  23. package/api/integration/pack-check.test.mjs +249 -0
  24. package/api/search/search.mjs +5 -5
  25. package/api/search/search.type.d.mts +1 -1
  26. package/api/search/search.type.mjs +1 -1
  27. package/api/swizzle/swizzle.type.d.mts +2 -2
  28. package/api/swizzle/swizzle.type.mjs +2 -2
  29. package/api/template/template.type.d.mts +5 -5
  30. package/api/template/template.type.mjs +12 -12
  31. package/api/theme/build/build.mjs +20 -6
  32. package/api/theme/build/build.test.mjs +127 -0
  33. package/api/theme/palette/generate/generate.mjs +1 -1
  34. package/api/theme/palette/generate/generator.d.mts +10 -13
  35. package/api/theme/palette/generate/generator.mjs +7 -3
  36. package/api/theme/theme.type.d.mts +170 -11
  37. package/api/theme/theme.type.mjs +94 -27
  38. package/api/upgrade/upgrade.doc.mjs +4 -3
  39. package/api/upgrade/upgrade.type.d.mts +5 -5
  40. package/api/upgrade/upgrade.type.mjs +11 -11
  41. package/assets/codemods/integration-discovery.mjs +40 -2
  42. package/assets/codemods/integration-discovery.test.mjs +58 -0
  43. package/assets/codemods/transforms/v0.3.0/__tests__/unwrap-authoring-factories.test.mjs +27 -5
  44. package/assets/codemods/transforms/v0.3.0/unwrap-authoring-factories.mjs +20 -5
  45. package/assets/docs/cli-integrations.doc.mjs +81 -14
  46. package/assets/docs/styling-libraries.doc.mjs +1 -1
  47. package/assets/docs/working-with-ai.doc.mjs +1 -1
  48. package/authoring/_shared/contract.ts +22 -0
  49. package/authoring/codemod/codemod.doc.mjs +6 -1
  50. package/authoring/codemod/parse.d.mts +8 -8
  51. package/authoring/codemod/parse.mjs +8 -6
  52. package/authoring/config/parse.d.mts +13 -13
  53. package/authoring/config/parse.mjs +8 -8
  54. package/authoring/config/type.ts +3 -3
  55. package/authoring/debug/parse.d.mts +4 -4
  56. package/authoring/debug/parse.mjs +3 -3
  57. package/authoring/doctypes/_schema.d.mts +121 -11
  58. package/authoring/doctypes/_schema.mjs +144 -13
  59. package/authoring/doctypes/base/graph-fields.doc.mjs +11 -4
  60. package/authoring/doctypes/base/type.ts +8 -4
  61. package/authoring/doctypes/command/command.doc.mjs +3 -2
  62. package/authoring/doctypes/command/parse.d.mts +2 -2
  63. package/authoring/doctypes/command/parse.mjs +1 -1
  64. package/authoring/doctypes/command/type.ts +2 -2
  65. package/authoring/doctypes/component/component.doc.mjs +5 -2
  66. package/authoring/doctypes/component/parse.d.mts +2 -2
  67. package/authoring/doctypes/component/parse.mjs +1 -1
  68. package/authoring/doctypes/component/type.ts +1 -1
  69. package/authoring/doctypes/enum/parse.d.mts +2 -2
  70. package/authoring/doctypes/enum/parse.mjs +1 -1
  71. package/authoring/doctypes/enum/type.ts +1 -1
  72. package/authoring/doctypes/function/function.doc.mjs +4 -0
  73. package/authoring/doctypes/function/parse.d.mts +2 -2
  74. package/authoring/doctypes/function/parse.mjs +1 -1
  75. package/authoring/doctypes/function/type.ts +1 -1
  76. package/authoring/doctypes/hook/hook.doc.mjs +4 -0
  77. package/authoring/doctypes/hook/parse.d.mts +2 -2
  78. package/authoring/doctypes/hook/parse.mjs +1 -1
  79. package/authoring/doctypes/hook/type.ts +1 -1
  80. package/authoring/doctypes/legacy.d.mts +6 -6
  81. package/authoring/doctypes/legacy.mjs +3 -3
  82. package/authoring/doctypes/load-contract.test.mjs +207 -0
  83. package/authoring/doctypes/namespace/namespace.doc.mjs +7 -3
  84. package/authoring/doctypes/namespace/parse.d.mts +2 -2
  85. package/authoring/doctypes/namespace/parse.mjs +1 -1
  86. package/authoring/doctypes/namespace/type.ts +2 -2
  87. package/authoring/doctypes/parse.d.mts +18 -18
  88. package/authoring/doctypes/parse.mjs +9 -9
  89. package/authoring/doctypes/reference/parse.d.mts +2 -2
  90. package/authoring/doctypes/reference/parse.mjs +1 -1
  91. package/authoring/doctypes/reference/reference.doc.mjs +6 -2
  92. package/authoring/doctypes/reference/type.ts +1 -1
  93. package/authoring/doctypes/schema/parse.d.mts +2 -2
  94. package/authoring/doctypes/schema/parse.mjs +1 -1
  95. package/authoring/doctypes/schema/type.ts +2 -2
  96. package/authoring/doctypes/template/parse.d.mts +92 -1
  97. package/authoring/doctypes/template/parse.mjs +33 -1
  98. package/authoring/doctypes/template/template.doc.mjs +4 -0
  99. package/authoring/doctypes/template/type.ts +4 -1
  100. package/authoring/doctypes/types.ts +10 -10
  101. package/authoring/gap-report/parse.d.mts +9 -9
  102. package/authoring/gap-report/parse.mjs +6 -6
  103. package/authoring/gap-report/type.ts +1 -1
  104. package/authoring/identity/identity.doc.mjs +3 -2
  105. package/authoring/identity/type.ts +10 -10
  106. package/authoring/index.d.ts +19 -19
  107. package/authoring/integration/parse.d.mts +2 -2
  108. package/authoring/integration/parse.mjs +1 -1
  109. package/authoring/integration/schema.d.mts +4 -4
  110. package/authoring/integration/schema.mjs +3 -3
  111. package/authoring/integration/type.ts +16 -3
  112. package/clients/cli/commands/integration-authoring.test.mjs +13 -9
  113. package/clients/cli/commands/theme-palette-generate.doc.mjs +8 -4
  114. package/clients/cli/commands/upgrade.doc.mjs +2 -2
  115. package/foundation/discovery/authoring-self-docs.test.mjs +71 -12
  116. package/foundation/discovery/docs-discovery.d.mts +4 -0
  117. package/foundation/discovery/docs-discovery.mjs +16 -2
  118. package/foundation/discovery/docs-discovery.test.mjs +47 -11
  119. package/foundation/doc-compiler/compile.d.mts +162 -0
  120. package/foundation/doc-compiler/compile.mjs +262 -0
  121. package/foundation/doc-compiler/doc-compiler.test.mjs +687 -0
  122. package/foundation/doc-compiler/ir.d.mts +9 -0
  123. package/foundation/doc-compiler/ir.mjs +287 -0
  124. package/foundation/doc-compiler/lenses.d.mts +33 -0
  125. package/foundation/doc-compiler/lenses.mjs +127 -0
  126. package/package.json +9 -11
@@ -0,0 +1,78 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file Every shipped topic compiles to a plain-JSON node that answers every
5
+ * docs read exactly as the live one does, and no read can change another read
6
+ * of the same catalog.
7
+ */
8
+
9
+ import {describe, expect, it} from 'vitest';
10
+ import {parseCompiledReferenceNode} from '../../foundation/doc-compiler/ir.mjs';
11
+ import {detailView, indexView} from '../../foundation/doc-compiler/lenses.mjs';
12
+ import {
13
+ compileTopic,
14
+ loadDocsCatalog,
15
+ lowerTopic,
16
+ overlayLanguages,
17
+ } from './_adapter.mjs';
18
+
19
+ const SLOW = 60_000;
20
+
21
+ describe('every shipped topic compiles to plain JSON', () => {
22
+ it(
23
+ 'survives a JSON round trip with identical responses in every language',
24
+ async () => {
25
+ const catalog = await loadDocsCatalog();
26
+ let compiled = 0;
27
+ for (const entry of catalog.entries()) {
28
+ for (const lang of [null, ...overlayLanguages(entry)]) {
29
+ const lowered = await lowerTopic(catalog, entry, lang);
30
+ expect(parseCompiledReferenceNode(lowered)).toBe(lowered);
31
+ const node = await compileTopic(catalog, entry, lang);
32
+ expect(parseCompiledReferenceNode(node)).toBe(node);
33
+ const copy = parseCompiledReferenceNode(
34
+ JSON.parse(JSON.stringify(node)),
35
+ );
36
+ expect(JSON.stringify(detailView(copy))).toBe(
37
+ JSON.stringify(detailView(node)),
38
+ );
39
+ expect(JSON.stringify(indexView(copy))).toBe(
40
+ JSON.stringify(indexView(node)),
41
+ );
42
+ compiled += 1;
43
+ }
44
+ }
45
+ expect(compiled).toBeGreaterThan(catalog.entries().length);
46
+ },
47
+ SLOW,
48
+ );
49
+ });
50
+
51
+ describe('reads that share a catalog', () => {
52
+ it(
53
+ 'never let one read change another',
54
+ async () => {
55
+ const catalog = await loadDocsCatalog();
56
+ const tokens = catalog.resolve('tokens');
57
+ const first = detailView(await compileTopic(catalog, tokens));
58
+ for (const section of first.sections) {
59
+ section.title = 'EDITED';
60
+ for (const block of section.content) {
61
+ if (typeof block.text === 'string') block.text = 'EDITED';
62
+ if (Array.isArray(block.rows)) block.rows.push(['EDITED']);
63
+ }
64
+ }
65
+ const again = detailView(await compileTopic(catalog, tokens));
66
+ const index = indexView(await lowerTopic(catalog, tokens));
67
+ const spacing = detailView(
68
+ await compileTopic(catalog, catalog.resolve('spacing')),
69
+ );
70
+ for (const read of [again, index, spacing]) {
71
+ expect(JSON.stringify(read)).not.toContain('EDITED');
72
+ }
73
+ const lowered = await lowerTopic(catalog, tokens);
74
+ expect(Object.isFrozen(lowered.doc.sections[0].content)).toBe(true);
75
+ },
76
+ SLOW,
77
+ );
78
+ });
@@ -1,21 +1,6 @@
1
1
  // @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
2
2
  // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
3
 
4
- /**
5
- * Resolve token-ref blocks by inlining the referenced section's table.
6
- * This allows section docs to reference token tables without duplicating data.
7
- *
8
- * The reference is resolved through the catalog, so a topic may point at one
9
- * an integration contributed (or replaced) rather than only at a built-in. It
10
- * names the section by key or authored title, so it resolves in every language.
11
- * @param {import('../docs.type.mjs').DocsDetailResponse['data']} docsData
12
- * @param {import('../../../foundation/discovery/docs-discovery.mjs').DocsCatalog} catalog
13
- * @param {{lang?: string | null}} [options]
14
- * @returns {Promise<import('../docs.type.mjs').DocsDetailResponse['data']>}
15
- */
16
- export function resolveTokenRefs(docsData: import("../docs.type.mjs").DocsDetailResponse["data"], catalog: import("../../../foundation/discovery/docs-discovery.mjs").DocsCatalog, { lang }?: {
17
- lang?: string | null;
18
- }): Promise<import("../docs.type.mjs").DocsDetailResponse["data"]>;
19
4
  /**
20
5
  * @param {string} topic
21
6
  * @param {object} [options]
@@ -3,84 +3,17 @@
3
3
  /**
4
4
  * @file docs.detail leaf — load one topic's full reference doc.
5
5
  *
6
- * @input A topic name plus optional {lang, zh, dense}. Resolves and loads the
7
- * topic via the shared adapter, then inlines any token-ref blocks.
6
+ * @input A topic name plus optional {lang, zh, dense, cwd}. Resolves the topic
7
+ * via the shared adapter and compiles it with its token references linked.
8
8
  * @output { type: 'docs.detail', data: ReferenceDoc } — the full doc with
9
- * token-refs resolved, matching `xds --json docs <topic>`.
10
- * @position Leaf under api/docs. Owns resolveTokenRefs (used only here); shares
11
- * discovery/loading/topic-resolution with the section leaf via _adapter.mjs.
9
+ * token-refs inlined, matching `astryx --json docs <topic>`.
10
+ * @position Leaf under api/docs. Reads the compiled node through the detail
11
+ * lens; resolution, overlays and extensions happen in the compiler.
12
12
  */
13
13
 
14
- import {loadTopicDoc, resolveTopicDocs} from '../_adapter.mjs';
15
- import {
16
- sectionKey,
17
- sourceTitle,
18
- withSourceTitle,
19
- } from '../../../foundation/discovery/docs-section-key.mjs';
20
-
21
- /**
22
- * Resolve token-ref blocks by inlining the referenced section's table.
23
- * This allows section docs to reference token tables without duplicating data.
24
- *
25
- * The reference is resolved through the catalog, so a topic may point at one
26
- * an integration contributed (or replaced) rather than only at a built-in. It
27
- * names the section by key or authored title, so it resolves in every language.
28
- * @param {import('../docs.type.mjs').DocsDetailResponse['data']} docsData
29
- * @param {import('../../../foundation/discovery/docs-discovery.mjs').DocsCatalog} catalog
30
- * @param {{lang?: string | null}} [options]
31
- * @returns {Promise<import('../docs.type.mjs').DocsDetailResponse['data']>}
32
- */
33
- export async function resolveTokenRefs(docsData, catalog, {lang = null} = {}) {
34
- const resolved = {...docsData, sections: [...docsData.sections]};
35
- for (let si = 0; si < resolved.sections.length; si++) {
36
- const section = resolved.sections[si];
37
- /** @type {import('@astryxdesign/cli/authoring').ReferenceContentBlock[]} */
38
- const newContent = [];
39
- for (const block of section.content) {
40
- if (block.type === 'token-ref') {
41
- const refEntry = catalog.resolve(block.topic);
42
- if (!refEntry) {
43
- newContent.push({type: 'prose', text: `[token-ref: unknown topic "${block.topic}"]`});
44
- continue;
45
- }
46
- const refDocs = await loadTopicDoc(refEntry, {lang});
47
- const wanted = block.section.toLowerCase();
48
- const refSection = refDocs.sections.find(
49
- (/** @type {import('@astryxdesign/cli/authoring').ReferenceSection} */ s) =>
50
- sectionKey(s) === block.section ||
51
- sourceTitle(s).toLowerCase() === wanted,
52
- );
53
- if (!refSection) {
54
- newContent.push({type: 'prose', text: `[token-ref: section "${block.section}" not found in "${block.topic}"]`});
55
- continue;
56
- }
57
- // Inline the referenced section's content blocks (tables, prose, etc.)
58
- // and carry over the previewType
59
- for (const refBlock of refSection.content) {
60
- newContent.push(refBlock);
61
- }
62
- // If the referenced section has a previewType, attach it to our section
63
- if (refSection.previewType && !section.previewType) {
64
- resolved.sections[si] = withSourceTitle(
65
- {...section, previewType: refSection.previewType, content: newContent},
66
- sourceTitle(section),
67
- );
68
- }
69
- } else {
70
- newContent.push(block);
71
- }
72
- }
73
- if (resolved.sections[si] === section) {
74
- resolved.sections[si] = withSourceTitle(
75
- {...section, content: newContent},
76
- sourceTitle(section),
77
- );
78
- } else {
79
- resolved.sections[si].content = newContent;
80
- }
81
- }
82
- return resolved;
83
- }
14
+ import {linkReferenceTopic} from '../../../foundation/doc-compiler/compile.mjs';
15
+ import {detailView} from '../../../foundation/doc-compiler/lenses.mjs';
16
+ import {referenceTargets, resolveTopicDocs} from '../_adapter.mjs';
84
17
 
85
18
  /**
86
19
  * @param {string} topic
@@ -92,7 +25,10 @@ export async function resolveTokenRefs(docsData, catalog, {lang = null} = {}) {
92
25
  * @returns {Promise<import('../docs.type.mjs').DocsDetailResponse>}
93
26
  */
94
27
  export async function detail(topic, options = {}) {
95
- const {catalog, docsData, lang} = await resolveTopicDocs(topic, options);
96
- const resolved = await resolveTokenRefs(docsData, catalog, {lang});
97
- return {type: 'docs.detail', data: resolved};
28
+ const {catalog, node, lang} = await resolveTopicDocs(topic, options);
29
+ const linked = await linkReferenceTopic(
30
+ node,
31
+ referenceTargets(catalog, lang),
32
+ );
33
+ return {type: 'docs.detail', data: detailView(linked)};
98
34
  }
@@ -4,14 +4,15 @@
4
4
  * @file docs.detail.section leaf — load a single section of a topic.
5
5
  *
6
6
  * @input A topic name, a section query, and optional {lang, zh, dense}. Resolves
7
- * and loads the topic via the shared adapter, then finds the section by its
8
- * stable key, then by exact title, then by a title that contains the query.
7
+ * the topic via the shared adapter, finds the section in its lowered compiled
8
+ * node by its stable key, then by exact title, then by a title that contains
9
+ * the query, and links only that section.
9
10
  * @output { type: 'docs.detail.section', data: ReferenceSection } with any
10
11
  * token-ref blocks inlined — matching `astryx --json docs <topic> <section>`.
11
12
  * Throws ERR_UNKNOWN_SECTION when nothing matches, or when the query matches
12
13
  * more than one section (the candidates come back as suggestions).
13
- * @position Leaf nested under api/docs/detail. Shares discovery/loading/
14
- * topic-resolution with the detail leaf via _adapter.mjs.
14
+ * @position Leaf nested under api/docs/detail. Shares topic resolution with the
15
+ * detail leaf via _adapter.mjs and reads through the compiler's lenses.
15
16
  */
16
17
 
17
18
  import {AstryxError} from '../../../error.mjs';
@@ -20,8 +21,12 @@ import {
20
21
  findDocSection,
21
22
  sectionKey,
22
23
  } from '../../../../foundation/discovery/docs-section-key.mjs';
23
- import {resolveTopicDocs} from '../../_adapter.mjs';
24
- import {resolveTokenRefs} from '../detail.mjs';
24
+ import {linkReferenceSection} from '../../../../foundation/doc-compiler/compile.mjs';
25
+ import {
26
+ readerSections,
27
+ sectionView,
28
+ } from '../../../../foundation/doc-compiler/lenses.mjs';
29
+ import {referenceTargets, resolveTopicDocs} from '../../_adapter.mjs';
25
30
 
26
31
  /**
27
32
  * @param {string} topic
@@ -44,31 +49,30 @@ export async function section(topic, sectionName, options = {}) {
44
49
  ERROR_CODES.ERR_UNKNOWN_SECTION,
45
50
  );
46
51
  }
47
- const {catalog, docsData, lang} = await resolveTopicDocs(topic, options);
48
52
 
49
- const {section: match, candidates} = findDocSection(
50
- docsData.sections,
51
- sectionName,
52
- );
53
+ const {catalog, node, lang} = await resolveTopicDocs(topic, options);
54
+ const sections = readerSections(node);
55
+ const {section: match, candidates} = findDocSection(sections, sectionName);
53
56
  if (!match) {
54
57
  const ambiguous = candidates.length > 1;
55
58
  throw new AstryxError(
56
59
  ambiguous
57
60
  ? `Section "${sectionName}" matches ${candidates.length} sections in "${topic}". Read one by its key.`
58
61
  : `Section "${sectionName}" not found in "${topic}"`,
59
- (ambiguous ? candidates : docsData.sections).map(s => ({
62
+ (ambiguous ? candidates : sections).map(s => ({
60
63
  name: sectionKey(s),
61
64
  reason: s.title,
62
65
  })),
63
66
  ERROR_CODES.ERR_UNKNOWN_SECTION,
64
67
  );
65
68
  }
69
+
66
70
  // A section read on its own inlines its token refs, as the whole topic does;
67
- // otherwise a section that is only a token-ref prints blank.
68
- const {sections} = await resolveTokenRefs(
69
- {...docsData, sections: [match]},
70
- catalog,
71
- {lang},
71
+ // otherwise a section that is only a token-ref prints blank. Only this
72
+ // section is linked, so a broken reference elsewhere cannot fail the read.
73
+ const linked = await linkReferenceSection(
74
+ match,
75
+ referenceTargets(catalog, lang),
72
76
  );
73
- return {type: 'docs.detail.section', data: sections[0]};
77
+ return {type: 'docs.detail.section', data: sectionView(node, linked)};
74
78
  }
@@ -10,7 +10,7 @@
10
10
  import {describe, it, expect} from 'vitest';
11
11
  import {section} from './section.mjs';
12
12
  import {AstryxError} from '../../../error.mjs';
13
- import {loadDocsCatalog, loadTopicDoc} from '../../_adapter.mjs';
13
+ import {loadDocsCatalog, lowerTopic} from '../../_adapter.mjs';
14
14
 
15
15
  const SLOW = 30_000;
16
16
 
@@ -42,7 +42,8 @@ describe('docs.detail.section leaf', () => {
42
42
  }, SLOW);
43
43
 
44
44
  it('reads a section by its stable key', async () => {
45
- const doc = await loadTopicDoc((await loadDocsCatalog()).resolve('theme'));
45
+ const catalog = await loadDocsCatalog();
46
+ const {doc} = await lowerTopic(catalog, catalog.resolve('theme'));
46
47
  const target = doc.sections[doc.sections.length - 1];
47
48
  const res = await section('theme', target.id);
48
49
  expect(res.data.title).toBe(target.title);
@@ -63,7 +64,7 @@ describe('docs.detail.section leaf', () => {
63
64
  const catalog = await loadDocsCatalog();
64
65
  let checked = 0;
65
66
  for (const entry of catalog.entries()) {
66
- const doc = await loadTopicDoc(entry);
67
+ const {doc} = await lowerTopic(catalog, entry);
67
68
  for (const own of doc.sections) {
68
69
  if (!own.content.some(block => block.type === 'token-ref')) continue;
69
70
  const res = await section(entry.name, own.id, lang ? {lang} : {});
@@ -2,7 +2,7 @@
2
2
  // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
3
 
4
4
  /**
5
- * xds --json docs
5
+ * astryx --json docs
6
6
  */
7
7
  export type DocsListResponse = {
8
8
  type: "docs.list";
@@ -23,14 +23,14 @@ export type DocsListEntry = {
23
23
  replaces?: string | undefined;
24
24
  };
25
25
  /**
26
- * xds --json docs <topic> --index
26
+ * astryx --json docs <topic> --index
27
27
  */
28
28
  export type DocsIndexResponse = {
29
29
  type: "docs.index";
30
30
  data: DocsIndex;
31
31
  };
32
32
  /**
33
- * xds --json docs <topic>
33
+ * astryx --json docs <topic>
34
34
  */
35
35
  export type DocsDetailResponse = {
36
36
  type: "docs.detail";
@@ -62,7 +62,7 @@ export type DocsIndexSection = {
62
62
  summary: string;
63
63
  };
64
64
  /**
65
- * xds --json docs <topic> <section>
65
+ * astryx --json docs <topic> <section>
66
66
  */
67
67
  export type DocsDetailSectionResponse = {
68
68
  type: "docs.detail.section";
@@ -4,17 +4,17 @@
4
4
  * @file Colocated types for the `docs` command — source of truth for the docs
5
5
  * command JSON responses. `types/docs.d.ts` re-exports these.
6
6
  *
7
- * Invocation -> type discriminator
7
+ * Invocation -> type discriminator
8
8
  * ------------------------------------------------------------
9
- * xds --json docs -> docs.list
10
- * xds --json docs <topic> -> docs.detail
11
- * xds --json docs <topic> --index -> docs.index
12
- * xds --json docs <topic> <section> -> docs.detail.section
13
- * (unknown topic/section) -> CLIError
9
+ * astryx --json docs -> docs.list
10
+ * astryx --json docs <topic> -> docs.detail
11
+ * astryx --json docs <topic> --index -> docs.index
12
+ * astryx --json docs <topic> <section> -> docs.detail.section
13
+ * (unknown topic/section) -> CLIError
14
14
  */
15
15
 
16
16
  /**
17
- * xds --json docs
17
+ * astryx --json docs
18
18
  * @typedef {object} DocsListResponse
19
19
  * @property {'docs.list'} type
20
20
  * @property {DocsListEntry[]} data
@@ -31,14 +31,14 @@
31
31
  */
32
32
 
33
33
  /**
34
- * xds --json docs <topic> --index
34
+ * astryx --json docs <topic> --index
35
35
  * @typedef {object} DocsIndexResponse
36
36
  * @property {'docs.index'} type
37
37
  * @property {DocsIndex} data
38
38
  */
39
39
 
40
40
  /**
41
- * xds --json docs <topic>
41
+ * astryx --json docs <topic>
42
42
  * @typedef {object} DocsDetailResponse
43
43
  * @property {'docs.detail'} type
44
44
  * @property {import('@astryxdesign/cli/authoring').ReferenceDoc} data
@@ -63,7 +63,7 @@
63
63
  */
64
64
 
65
65
  /**
66
- * xds --json docs <topic> <section>
66
+ * astryx --json docs <topic> <section>
67
67
  * @typedef {object} DocsDetailSectionResponse
68
68
  * @property {'docs.detail.section'} type
69
69
  * @property {import('@astryxdesign/cli/authoring').ReferenceSection} data
@@ -3,8 +3,9 @@
3
3
  /**
4
4
  * @file docs.index leaf — the section index of one topic.
5
5
  *
6
- * @input A topic name plus optional {lang, zh, dense, cwd}. Resolves and loads
7
- * the topic via the shared adapter.
6
+ * @input A topic name plus optional {lang, zh, dense, cwd}. Resolves the topic
7
+ * via the shared adapter and reads its lowered compiled node; nothing is
8
+ * linked, since the index never inlines a token reference.
8
9
  * @output { type: 'docs.index', data: DocsIndex } — the topic's name, title and
9
10
  * description and, for each section, the key it is read by, its title, and a
10
11
  * one-line summary. Matches `astryx --json docs <topic> --index`.
@@ -13,7 +14,7 @@
13
14
  * read, is the detail leaf.
14
15
  */
15
16
 
16
- import {buildDocsIndexData} from '../../../foundation/discovery/docs-section-key.mjs';
17
+ import {indexView} from '../../../foundation/doc-compiler/lenses.mjs';
17
18
  import {resolveTopicDocs} from '../_adapter.mjs';
18
19
 
19
20
  /**
@@ -26,6 +27,6 @@ import {resolveTopicDocs} from '../_adapter.mjs';
26
27
  * @returns {Promise<import('../docs.type.mjs').DocsIndexResponse>}
27
28
  */
28
29
  export async function index(topic, options = {}) {
29
- const {docsData} = await resolveTopicDocs(topic, options);
30
- return {type: 'docs.index', data: buildDocsIndexData(docsData)};
30
+ const {node} = await resolveTopicDocs(topic, options);
31
+ return {type: 'docs.index', data: indexView(node)};
31
32
  }
@@ -34,8 +34,8 @@ import {
34
34
  docsIndexBytes,
35
35
  oversizedDocSections,
36
36
  } from '../../foundation/discovery/docs-output-budget.mjs';
37
- import {loadTopicDoc, overlayLanguages} from '../docs/_adapter.mjs';
38
- import {resolveTokenRefs} from '../docs/detail/detail.mjs';
37
+ import {compileTopic, overlayLanguages} from '../docs/_adapter.mjs';
38
+ import {detailView} from '../../foundation/doc-compiler/lenses.mjs';
39
39
  import {semverCompare, isValidSemver, satisfiesRange} from '../../foundation/env/semver.mjs';
40
40
 
41
41
  /**
@@ -798,11 +798,7 @@ export async function checkDocsProgressiveDisclosure(ctx) {
798
798
  for (const lang of [null, ...overlayLanguages(entry)]) {
799
799
  const where = lang ? `${entry.name} [${lang}]` : entry.name;
800
800
  try {
801
- const doc = await resolveTokenRefs(
802
- await loadTopicDoc(entry, {lang}),
803
- catalog,
804
- {lang},
805
- );
801
+ const doc = detailView(await compileTopic(catalog, entry, lang));
806
802
  if (lang == null) topics += 1;
807
803
  const indexBytes = docsIndexBytes(buildDocsIndexData(doc));
808
804
  if (indexBytes > DOC_OUTPUT_BUDGET_BYTES) {
@@ -4,7 +4,7 @@
4
4
  export type HookDoc = import("@astryxdesign/cli/authoring").HookDoc;
5
5
  export type HookParamDoc = import("@astryxdesign/cli/authoring").HookParamDoc;
6
6
  /**
7
- * xds --json hook [--list] [--category X] [--detail names|compact|full]
7
+ * astryx --json hook [--list] [--category X] [--detail names|compact|full]
8
8
  *
9
9
  * The list view emits ONE `hook.list` type across all three detail levels; the
10
10
  * depth is carried in `data.detail` and `data.components` holds the grouped map
@@ -39,14 +39,14 @@ export type HookBriefEntry = {
39
39
  import: string;
40
40
  };
41
41
  /**
42
- * xds --json hook <name>
42
+ * astryx --json hook <name>
43
43
  */
44
44
  export type HookDetailResponse = {
45
45
  type: "hook.detail";
46
46
  data: HookDoc;
47
47
  };
48
48
  /**
49
- * xds --json hook <name> --params
49
+ * astryx --json hook <name> --params
50
50
  */
51
51
  export type HookDetailParamsResponse = {
52
52
  type: "hook.detail.params";
@@ -11,14 +11,14 @@
11
11
  *
12
12
  * Invocation -> type discriminator
13
13
  * ------------------------------------------------------------------
14
- * xds --json hook -> hook.list (data.detail='names')
15
- * xds --json hook --list -> hook.list (data.detail='names')
16
- * xds --json hook --category State -> hook.list (filtered)
17
- * xds --json hook --list --detail compact -> hook.list (data.detail='compact')
18
- * xds --json hook --list --detail full -> hook.list (data.detail='full')
19
- * xds --json hook useMediaQuery -> hook.detail
20
- * xds --json hook useMediaQuery --params -> hook.detail.params
21
- * (not found) -> CLIError
14
+ * astryx --json hook -> hook.list (data.detail='names')
15
+ * astryx --json hook --list -> hook.list (data.detail='names')
16
+ * astryx --json hook --category State -> hook.list (filtered)
17
+ * astryx --json hook --list --detail compact -> hook.list (data.detail='compact')
18
+ * astryx --json hook --list --detail full -> hook.list (data.detail='full')
19
+ * astryx --json hook useMediaQuery -> hook.detail
20
+ * astryx --json hook useMediaQuery --params -> hook.detail.params
21
+ * (not found) -> CLIError
22
22
  */
23
23
 
24
24
  // Re-export the authored-doc types from core so the hook leaves reference these
@@ -28,7 +28,7 @@
28
28
  /** @typedef {import('@astryxdesign/cli/authoring').HookParamDoc} HookParamDoc */
29
29
 
30
30
  /**
31
- * xds --json hook [--list] [--category X] [--detail names|compact|full]
31
+ * astryx --json hook [--list] [--category X] [--detail names|compact|full]
32
32
  *
33
33
  * The list view emits ONE `hook.list` type across all three detail levels; the
34
34
  * depth is carried in `data.detail` and `data.components` holds the grouped map
@@ -56,14 +56,14 @@
56
56
  */
57
57
 
58
58
  /**
59
- * xds --json hook <name>
59
+ * astryx --json hook <name>
60
60
  * @typedef {object} HookDetailResponse
61
61
  * @property {'hook.detail'} type
62
62
  * @property {HookDoc} data
63
63
  */
64
64
 
65
65
  /**
66
- * xds --json hook <name> --params
66
+ * astryx --json hook <name> --params
67
67
  * @typedef {object} HookDetailParamsResponse
68
68
  * @property {'hook.detail.params'} type
69
69
  * @property {HookParamDoc[]} data
@@ -250,7 +250,8 @@ async function addComponent(name, options) {
250
250
  }
251
251
 
252
252
  const sourcePath = projectPath(path.relative(packageDir, sourceFile));
253
- const importSpecifier = `${owner}/${sourcePath}`;
253
+ const extensionlessPath = sourcePath.replace(/\.tsx?$/u, '');
254
+ const importSpecifier = `${owner}/${extensionlessPath}`;
254
255
  const docContents = `export default {\n type: 'component',\n name: '${name}',\n import: ${JSON.stringify(importSpecifier)},\n description: '${name} component.',\n props: [],\n};\n`;
255
256
  const sourceContents = `export function ${name}() {\n return <div>${name}</div>;\n}\n`;
256
257
 
@@ -263,7 +264,7 @@ async function addComponent(name, options) {
263
264
  packageFile,
264
265
  rootPath,
265
266
  path.basename(manifestFile),
266
- [{subpath: sourcePath, target: sourcePath}],
267
+ [{subpath: extensionlessPath, target: sourcePath}],
267
268
  );
268
269
  if (pkgUpdate != null) {
269
270
  plans.push({
@@ -576,6 +577,7 @@ async function addTemplate(name, options) {
576
577
 
577
578
  const pascalName = kebabToPascal(name);
578
579
  const sourcePath = projectPath(path.relative(packageDir, sourceFile));
580
+ const extensionlessPath = sourcePath.replace(/\.tsx?$/u, '');
579
581
  const specContents = `export default {\n type: '${templateType}',\n name: '${name}',\n description: '${kebabToTitle(name)} template.',\n};\n`;
580
582
  const sourceContents = `export default function ${pascalName}() {\n return <div>${kebabToTitle(name)}</div>;\n}\n`;
581
583
 
@@ -588,7 +590,7 @@ async function addTemplate(name, options) {
588
590
  packageFile,
589
591
  rootPath,
590
592
  path.basename(manifestFile),
591
- [{subpath: sourcePath, target: sourcePath}],
593
+ [{subpath: extensionlessPath, target: sourcePath}],
592
594
  );
593
595
  if (pkgUpdate != null) {
594
596
  plans.push({
@@ -118,14 +118,14 @@ describe('integrationAdd component', () => {
118
118
  );
119
119
  expect(pkg.exports).toEqual({
120
120
  '.': './index.mjs',
121
- './components/MyWidget.tsx': './components/MyWidget.tsx',
121
+ './components/MyWidget': './components/MyWidget.tsx',
122
122
  });
123
123
  expect(
124
124
  fs.readFileSync(
125
125
  path.join(tmpDir, 'components/MyWidget.doc.mjs'),
126
126
  'utf-8',
127
127
  ),
128
- ).toContain('import: "@acme/integration/components/MyWidget.tsx"');
128
+ ).toContain('import: "@acme/integration/components/MyWidget"');
129
129
  });
130
130
 
131
131
  it('does not create exports when the package has no exports map', async () => {
@@ -143,7 +143,7 @@ describe('integrationAdd component', () => {
143
143
  setup({
144
144
  exports: {
145
145
  '.': './index.mjs',
146
- './components/MyWidget.tsx': './different.tsx',
146
+ './components/MyWidget': './different.tsx',
147
147
  },
148
148
  });
149
149
 
@@ -421,7 +421,7 @@ describe('integrationAdd template', () => {
421
421
  );
422
422
  expect(pkg.exports).toEqual({
423
423
  '.': './index.mjs',
424
- './templates/my-widget.tsx': './templates/my-widget.tsx',
424
+ './templates/my-widget': './templates/my-widget.tsx',
425
425
  });
426
426
  });
427
427