@astryxdesign/cli 0.1.6-canary.e8d4c3f → 0.1.6-canary.eb549c8

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 (39) hide show
  1. package/package.json +9 -13
  2. package/src/api/template.mjs +1 -1
  3. package/src/api/validate-integration.mjs +8 -0
  4. package/src/codemods/__tests__/registry.test.mjs +0 -1
  5. package/src/codemods/registry.mjs +0 -1
  6. package/src/config.mjs +14 -5
  7. package/src/integration.mjs +15 -4
  8. package/src/lib/component-discovery.mjs +5 -15
  9. package/src/lib/component-format.mjs +13 -45
  10. package/src/lib/component-format.test.mjs +1 -95
  11. package/src/lib/component-loader.mjs +2 -104
  12. package/src/lib/config-schema.mjs +30 -0
  13. package/src/lib/hook-format.mjs +3 -8
  14. package/src/lib/xle/registry.mjs +5 -0
  15. package/src/template.mjs +67 -9
  16. package/src/types/config.d.ts +66 -11
  17. package/src/types/integration.d.ts +18 -7
  18. package/src/types/template-api.d.ts +50 -14
  19. package/templates/pages/ide/page.tsx +41 -35
  20. package/templates/themes/neutral/neutralTheme.ts +32 -63
  21. package/docs/internationalization.doc.mjs +0 -243
  22. package/src/codemods/transforms/v0.1.7/__tests__/migrate-table-tableprops-to-direct-props.test.mjs +0 -120
  23. package/src/codemods/transforms/v0.1.7/index.mjs +0 -19
  24. package/src/codemods/transforms/v0.1.7/migrate-table-tableprops-to-direct-props.mjs +0 -188
  25. package/src/doc.mjs +0 -27
  26. package/src/doc.test.mjs +0 -383
  27. package/src/lib/component-discovery.importpath.test.mjs +0 -59
  28. package/src/lib/componentDocOverlay.test.mjs +0 -111
  29. package/src/schemas/doc-schema.mjs +0 -226
  30. package/src/schemas/template-schema.mjs +0 -47
  31. package/src/types/doc.d.ts +0 -23
  32. package/templates/blocks/components/VisuallyHidden/VisuallyHiddenLiveRegion.doc.mjs +0 -14
  33. package/templates/blocks/components/VisuallyHidden/VisuallyHiddenLiveRegion.tsx +0 -41
  34. package/templates/blocks/components/VisuallyHidden/VisuallyHiddenShowcase.doc.mjs +0 -13
  35. package/templates/blocks/components/VisuallyHidden/VisuallyHiddenShowcase.tsx +0 -78
  36. package/templates/blocks/components/VisuallyHidden/VisuallyHiddenStructuralHeading.doc.mjs +0 -14
  37. package/templates/blocks/components/VisuallyHidden/VisuallyHiddenStructuralHeading.tsx +0 -38
  38. package/templates/blocks/components/VisuallyHidden/VisuallyHiddenSupplementaryContext.doc.mjs +0 -14
  39. package/templates/blocks/components/VisuallyHidden/VisuallyHiddenSupplementaryContext.tsx +0 -47
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astryxdesign/cli",
3
- "version": "0.1.6-canary.e8d4c3f",
3
+ "version": "0.1.6-canary.eb549c8",
4
4
  "displayName": "CLI",
5
5
  "description": "Scaffold projects, browse templates, generate themes, and get agent-ready docs from the command line.",
6
6
  "author": "Meta Open Source",
@@ -47,10 +47,6 @@
47
47
  "types": "./src/types/integration.d.ts",
48
48
  "import": "./src/integration.mjs"
49
49
  },
50
- "./doc": {
51
- "types": "./src/types/doc.d.ts",
52
- "import": "./src/doc.mjs"
53
- },
54
50
  "./template": {
55
51
  "types": "./src/types/template-api.d.ts",
56
52
  "import": "./src/template.mjs"
@@ -79,10 +75,10 @@
79
75
  "zod": "^4.4.3"
80
76
  },
81
77
  "peerDependencies": {
82
- "@astryxdesign/charts": "0.1.6-canary.e8d4c3f",
83
- "@astryxdesign/core": "0.1.6-canary.e8d4c3f",
84
- "@astryxdesign/lab": "0.1.6-canary.e8d4c3f",
85
- "@astryxdesign/theme-neutral": "0.1.6-canary.e8d4c3f",
78
+ "@astryxdesign/charts": "0.1.6-canary.eb549c8",
79
+ "@astryxdesign/core": "0.1.6-canary.eb549c8",
80
+ "@astryxdesign/lab": "0.1.6-canary.eb549c8",
81
+ "@astryxdesign/theme-neutral": "0.1.6-canary.eb549c8",
86
82
  "gpt-tokenizer": "^3.4.0"
87
83
  },
88
84
  "peerDependenciesMeta": {
@@ -100,10 +96,10 @@
100
96
  }
101
97
  },
102
98
  "devDependencies": {
103
- "@astryxdesign/charts": "0.1.6-canary.e8d4c3f",
104
- "@astryxdesign/core": "0.1.6-canary.e8d4c3f",
105
- "@astryxdesign/lab": "0.1.6-canary.e8d4c3f",
106
- "@astryxdesign/theme-neutral": "0.1.6-canary.e8d4c3f",
99
+ "@astryxdesign/charts": "0.1.6-canary.eb549c8",
100
+ "@astryxdesign/core": "0.1.6-canary.eb549c8",
101
+ "@astryxdesign/lab": "0.1.6-canary.eb549c8",
102
+ "@astryxdesign/theme-neutral": "0.1.6-canary.eb549c8",
107
103
  "gpt-tokenizer": "^3.4.0"
108
104
  },
109
105
  "scripts": {
@@ -8,7 +8,7 @@ import * as fs from 'node:fs';
8
8
  import * as path from 'node:path';
9
9
  import {createJiti} from 'jiti';
10
10
  import {loadModuleWithSchema} from '../lib/module-loader.mjs';
11
- import {TemplateEnvelopeSchema} from '../schemas/template-schema.mjs';
11
+ import {TemplateEnvelopeSchema} from '../template.mjs';
12
12
  import {CLI_ROOT, discoverExternalPackages} from '../utils/paths.mjs';
13
13
  import {
14
14
  assertWithin,
@@ -67,6 +67,11 @@ function error(code, message) {
67
67
  return {code, severity: 'error', message};
68
68
  }
69
69
 
70
+ /** @param {string} code @param {string} message @returns {Issue} */
71
+ function warning(code, message) {
72
+ return {code, severity: 'warning', message};
73
+ }
74
+
70
75
  /**
71
76
  * Verify each declared contribution root exists on disk. A declared-but-missing
72
77
  * root is a `missing_root` error.
@@ -360,3 +365,6 @@ export function summarizeIssues(issues) {
360
365
  }
361
366
  return {errors, warnings};
362
367
  }
368
+
369
+ // Re-export issue constructors for callers/tests that want them.
370
+ export {error as integrationError, warning as integrationWarning};
@@ -20,7 +20,6 @@ describe('registry', () => {
20
20
  '0.1.2',
21
21
  '0.1.3',
22
22
  '0.1.5',
23
- '0.1.7',
24
23
  ]);
25
24
  });
26
25
  });
@@ -21,7 +21,6 @@ const registry = new Map([
21
21
  ['0.1.2', () => import('./transforms/v0.1.2/index.mjs')],
22
22
  ['0.1.3', () => import('./transforms/v0.1.3/index.mjs')],
23
23
  ['0.1.5', () => import('./transforms/v0.1.5/index.mjs')],
24
- ['0.1.7', () => import('./transforms/v0.1.7/index.mjs')],
25
24
  ]);
26
25
 
27
26
  // Re-export from the shared utility so registry callers and other consumers
package/src/config.mjs CHANGED
@@ -1,9 +1,18 @@
1
1
  // Copyright (c) Meta Platforms, Inc. and affiliates.
2
2
 
3
3
  /**
4
- * Re-export of the config-authoring helper, which now lives in
5
- * `@astryxdesign/core/config` so an app's config file gets type feedback
6
- * without depending on the CLI. Kept here so existing
7
- * `@astryxdesign/cli/config` imports continue to work unchanged.
4
+ * Type-preserving helper for the Astryx config file.
5
+ *
6
+ * This is an intentionally tiny runtime identity function: it returns its
7
+ * argument unchanged. Its value is the exported TypeScript surface from
8
+ * `@astryxdesign/cli/config`, so config files get editor/type feedback without
9
+ * coupling to CLI internals. Validation is NOT performed here — it happens at
10
+ * the load boundary (see `loadModuleWithSchema` + `AstryxConfigSchema`).
11
+ *
12
+ * @template {import('./types/config').AstryxConfig} T
13
+ * @param {T} config
14
+ * @returns {T}
8
15
  */
9
- export {createConfig} from '@astryxdesign/core/config';
16
+ export function createConfig(config) {
17
+ return config;
18
+ }
@@ -1,8 +1,19 @@
1
1
  // Copyright (c) Meta Platforms, Inc. and affiliates.
2
2
 
3
3
  /**
4
- * Re-export of the integration-authoring helper, which now lives in
5
- * `@astryxdesign/core/authoring`. Kept here so existing
6
- * `@astryxdesign/cli/integration` imports continue to work unchanged.
4
+ * Type-preserving helper for an Astryx integration manifest.
5
+ *
6
+ * This is an intentionally tiny runtime identity function: it returns its
7
+ * argument unchanged. Its value is the exported TypeScript surface from
8
+ * `@astryxdesign/cli/integration`, so manifests get editor/type feedback
9
+ * without coupling to CLI internals. Validation is NOT performed here — it
10
+ * happens at the load boundary (see `loadModuleWithSchema` +
11
+ * `AstryxIntegrationSchema`).
12
+ *
13
+ * @template {import('./types/integration').AstryxIntegration} T
14
+ * @param {T} integration
15
+ * @returns {T}
7
16
  */
8
- export {createIntegration} from '@astryxdesign/core/authoring';
17
+ export function createIntegration(integration) {
18
+ return integration;
19
+ }
@@ -273,24 +273,14 @@ export function findComponentReadme(coreDir, name) {
273
273
  * For "Button" finds src/Button/XDSButton.tsx
274
274
  * For "Layout" finds src/Layout/XDSLayout/XDSLayout.tsx
275
275
  * For "Card" finds src/Layout/Container/XDSCard.tsx (deep search fallback)
276
- *
277
- * Hooks and other functions are authored as `.ts` (e.g. `useMediaQuery.ts`,
278
- * `useResizable.ts`), so `.ts` candidates are searched alongside `.tsx`. Without
279
- * this, deriving the import path for a `.ts`-authored function falls back to the
280
- * bare `@astryxdesign/core` root instead of its tree-shakeable subpath.
281
276
  */
282
277
  export function findComponentSource(coreDir, name) {
283
278
  const srcDir = path.join(coreDir, 'src');
284
- // Try the prefixed forms (`XDSButton.tsx`) first since that is the current
285
- // on-disk convention, then the bare forms (`Button.tsx`) that the Astryx-prefix
286
- // migration (P4) renames to. `.tsx` before `.ts` within each so a component's
287
- // `.tsx` wins over a same-named `.ts` helper; `.ts` covers hooks/functions.
288
- const candidateFiles = [
289
- `XDS${name}.tsx`,
290
- `${name}.tsx`,
291
- `XDS${name}.ts`,
292
- `${name}.ts`,
293
- ];
279
+ // Try the prefixed form (`XDSButton.tsx`) first since that is the current
280
+ // on-disk convention, then the bare form (`Button.tsx`) that the Astryx-prefix
281
+ // migration (P4) renames to. Listing the prefixed name first keeps behavior
282
+ // identical until files are actually renamed.
283
+ const candidateFiles = [`XDS${name}.tsx`, `${name}.tsx`];
294
284
 
295
285
  function searchDir(dirPath) {
296
286
  if (!fs.existsSync(dirPath)) return null;
@@ -34,30 +34,15 @@ function getTargetDataAttributes(target) {
34
34
  ];
35
35
  }
36
36
 
37
- /**
38
- * Escape a value for a markdown table cell.
39
- *
40
- * A prop type is a union, and a union is spelled with the same `|` that GFM
41
- * uses to separate cells — backticks do not protect it. A row with more cells
42
- * than the header has columns gets the excess *discarded*, so an unescaped
43
- * `gap: 0 | 0.5 | ...` silently eats its own Default and Description columns.
44
- * <!-- SYNC: packages/core/src/Markdown/parser.ts (splits on unescaped pipes) -->
45
- */
46
- export function mdCell(value) {
47
- return String(value ?? '').replace(/\|/g, '\\|');
48
- }
49
-
50
37
  function formatPropsTable(props) {
51
38
  if (!props || props.length === 0) return '';
52
39
  const lines = [];
53
40
  lines.push('| Prop | Type | Default | Description |');
54
41
  lines.push('|------|------|---------|-------------|');
55
42
  for (const p of props) {
56
- const def = p.default ? `\`${mdCell(p.default)}\`` : '—';
43
+ const def = p.default ? `\`${p.default}\`` : '—';
57
44
  const req = p.required ? ' **(required)**' : '';
58
- lines.push(
59
- `| \`${mdCell(p.name)}\` | \`${mdCell(p.type)}\` | ${def} | ${mdCell(p.description)}${req} |`,
60
- );
45
+ lines.push(`| \`${p.name}\` | \`${p.type}\` | ${def} | ${p.description}${req} |`);
61
46
  }
62
47
  return lines.join('\n');
63
48
  }
@@ -192,7 +177,7 @@ export function formatFull(docs, options = {}) {
192
177
  sections.push('|---------|----------|-------------|');
193
178
  for (const el of docs.usage.anatomy) {
194
179
  const req = el.required ? 'Yes' : 'No';
195
- sections.push(`| ${mdCell(el.name)} | ${req} | ${mdCell(el.description)} |`);
180
+ sections.push(`| ${el.name} | ${req} | ${el.description} |`);
196
181
  }
197
182
  sections.push('');
198
183
  }
@@ -297,9 +282,7 @@ export function formatFull(docs, options = {}) {
297
282
  varLines.push('| CSS Variable | Default | Description |');
298
283
  varLines.push('|-------------|---------|-------------|');
299
284
  for (const v of publicVars) {
300
- varLines.push(
301
- `| \`${mdCell(v.name)}\` | \`${mdCell(v.default)}\` | ${mdCell(v.description)} |`,
302
- );
285
+ varLines.push(`| \`${v.name}\` | \`${v.default}\` | ${v.description} |`);
303
286
  }
304
287
  sections.push(varLines.join('\n') + '\n');
305
288
  }
@@ -395,8 +378,8 @@ export function formatCompact(docs, componentName, importHint) {
395
378
  propLines.push('| CSS Property | Sets |');
396
379
  propLines.push('|-------------|------|');
397
380
  for (const d of docs.theming.derived) {
398
- const target = d.expand === 'container' ? 'container layout tokens' : (d.vars || []).map(v => `\`${mdCell(v)}\``).join(', ');
399
- propLines.push(`| \`${mdCell(d.property)}\` | ${target} |`);
381
+ const target = d.expand === 'container' ? 'container layout tokens' : (d.vars || []).map(v => `\`${v}\``).join(', ');
382
+ propLines.push(`| \`${d.property}\` | ${target} |`);
400
383
  }
401
384
  sections.push(propLines.join('\n') + '\n');
402
385
  }
@@ -412,19 +395,6 @@ export function formatCompact(docs, componentName, importHint) {
412
395
  *
413
396
  * For multi-component docs, extracts the entry matching componentName.
414
397
  */
415
- /**
416
- * Longest union `--detail brief` will spell out inside the one-line signature.
417
- *
418
- * The signature is a glance, not a reference: a six-member enum like
419
- * `start|center|end|between|around|evenly` reads at a glance, an eleven-member
420
- * spacing scale does not — and Stack carries four of them (gap, padding,
421
- * paddingInline, paddingBlock), so it printed the same scale four times. Longer
422
- * unions fall through to the terse prop list, exactly as they did when the type
423
- * was still the bare name `SpacingStep`. The full values are always one
424
- * `astryx component <Name>` away.
425
- */
426
- const SIGNATURE_UNION_MAX_MEMBERS = 8;
427
-
428
398
  export function formatBrief(docs, componentName, importHint, options = {}) {
429
399
  const displayName = componentName.startsWith('XDS')
430
400
  ? componentName.slice(3)
@@ -451,15 +421,13 @@ export function formatBrief(docs, componentName, importHint, options = {}) {
451
421
  const otherProps = [];
452
422
 
453
423
  for (const prop of props) {
454
- const values =
455
- prop.type.includes('|') && !prop.type.includes('ReactNode')
456
- ? prop.type
457
- .replace(/['"]/g, '')
458
- .split('|')
459
- .map(v => v.trim())
460
- : null;
461
- if (values && values.length <= SIGNATURE_UNION_MAX_MEMBERS) {
462
- signatureProps.push(`${prop.name}: ${values.join('|')}`);
424
+ if (prop.type.includes('|') && !prop.type.includes('ReactNode')) {
425
+ const values = prop.type
426
+ .replace(/['"]/g, '')
427
+ .split('|')
428
+ .map(v => v.trim())
429
+ .join('|');
430
+ signatureProps.push(`${prop.name}: ${values}`);
463
431
  } else if (prop.required) {
464
432
  otherProps.unshift(`${prop.name}: ${prop.type.split('|')[0].trim()}`);
465
433
  } else {
@@ -1,7 +1,7 @@
1
1
  // Copyright (c) Meta Platforms, Inc. and affiliates.
2
2
 
3
3
  import {describe, it, expect} from 'vitest';
4
- import {formatBrief, formatFull} from './component-format.mjs';
4
+ import {formatFull} from './component-format.mjs';
5
5
 
6
6
  describe('formatFull sub-component rendering', () => {
7
7
  // Regression guard: sub-components are sometimes declared as a bare
@@ -93,97 +93,3 @@ describe('formatFull theming override keys', () => {
93
93
  expect(out).not.toContain("'astryx-table-cell': {");
94
94
  });
95
95
  });
96
-
97
- /** Pipes that actually separate cells — a `\|` is content, not a separator. */
98
- function cellPipes(row) {
99
- return (row.match(/(?<!\\)\|/g) || []).length;
100
- }
101
-
102
- describe('markdown table cells escape their pipes', () => {
103
- // A prop type is a union, and a union is spelled with `|` — the very
104
- // character GFM uses to separate cells. Backticks do not protect it: a row
105
- // with more cells than the header has columns gets its excess *discarded*,
106
- // so an unescaped `gap: 0 | 0.5 | ...` silently eats its own Default and
107
- // Description columns. See packages/core/src/Markdown/parser.ts, which
108
- // splits on unescaped pipes and preserves `\|` as literal.
109
- it('keeps a union-typed prop row at four cells', () => {
110
- const docs = {
111
- name: 'Grid',
112
- description: 'A grid.',
113
- props: [
114
- {
115
- name: 'gap',
116
- type: '0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10',
117
- default: '2',
118
- description: 'Spacing between all items.',
119
- },
120
- ],
121
- };
122
- const row = formatFull(docs)
123
- .split('\n')
124
- .find(l => l.startsWith('| `gap`'));
125
-
126
- // A 4-column row has exactly 5 separators. Unescaped, this row had 15.
127
- expect(cellPipes(row)).toBe(5);
128
- expect(row).toContain('\\|');
129
- // The columns the unescaped pipes were swallowing.
130
- expect(row).toContain('`2`');
131
- expect(row).toContain('Spacing between all items.');
132
- });
133
-
134
- it('escapes pipes in a description too', () => {
135
- const docs = {
136
- name: 'AppShell',
137
- description: 'A shell.',
138
- props: [
139
- {
140
- name: 'mobileNav',
141
- type: 'ReactNode',
142
- description: "Config. breakpoint is 'sm' | 'md' | 'lg' | 'none'.",
143
- },
144
- ],
145
- };
146
- const row = formatFull(docs)
147
- .split('\n')
148
- .find(l => l.startsWith('| `mobileNav`'));
149
-
150
- expect(cellPipes(row)).toBe(5);
151
- });
152
- });
153
-
154
- describe('formatBrief signature stays terse', () => {
155
- // `--detail brief` exists to be token-cheap. It hoists union-typed props into
156
- // the signature because a short enum reads at a glance — but an 11-member
157
- // spacing scale does not, and Stack carries four of them (gap, padding,
158
- // paddingInline, paddingBlock), so the same scale got printed four times.
159
- // Long unions stay in the terse prop list, exactly as they did when the type
160
- // was still the bare name `SpacingStep`.
161
- it('hoists a short enum but not a long scale', () => {
162
- const docs = {
163
- name: 'HStack',
164
- description: 'A stack.',
165
- props: [
166
- {
167
- name: 'gap',
168
- type: '0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10',
169
- description: 'Gap.',
170
- },
171
- {name: 'wrap', type: "'nowrap' | 'wrap' | 'wrap-reverse'", description: 'Wrap.'},
172
- {
173
- name: 'hAlign',
174
- type: "'start' | 'center' | 'end' | 'between' | 'around' | 'evenly'",
175
- description: 'Align.',
176
- },
177
- ],
178
- };
179
- const signature = formatBrief(docs, 'HStack', '').split('\n')[0];
180
-
181
- // Short enums still earn their place in the signature.
182
- expect(signature).toContain('wrap: nowrap|wrap|wrap-reverse');
183
- expect(signature).toContain('hAlign: start|center|end|between|around|evenly');
184
- // The long scale does not.
185
- expect(signature).not.toContain('0|0.5|1|1.5|2|3|4|5|6|8|10');
186
- // But the prop is still named, so it is not lost.
187
- expect(formatBrief(docs, 'HStack', '')).toContain('gap');
188
- });
189
- });
@@ -5,59 +5,6 @@
5
5
  */
6
6
 
7
7
  import {pathToFileURL} from 'node:url';
8
- import {importUserModule} from './module-loader.mjs';
9
- import {formatZodError} from './config-schema.mjs';
10
- import {ComponentDocSchema} from '../schemas/doc-schema.mjs';
11
-
12
- /**
13
- * Load a component doc through the shared load/validation boundary.
14
- *
15
- * This is the typed counterpart to {@link loadDocs}: it loads `.doc.ts` via
16
- * jiti (and `.doc.mjs`/`.doc.js` via native import) and validates against
17
- * {@link ComponentDocSchema}. That schema accepts BOTH formats, so this loader
18
- * reads whichever the file uses:
19
- * - NEW: the factory default export
20
- * (`export default createComponentDoc({...})` / `createFunctionDoc` /
21
- * `createDoc`) — the same single-export convention
22
- * {@link loadModuleWithSchema} uses for config/integration/template. These
23
- * carry a stamped `type` and validate against the matching per-kind schema.
24
- * - OLD: the legacy loose `export const docs = {...}` (no `type`), validated
25
- * against the permissive legacy union.
26
- * The default export wins when both are present. Throws a readable
27
- * `formatZodError`-style message on failure. Translations (`docsZh`/
28
- * `docsDense`) are merged exactly as {@link loadDocs} does so callers see
29
- * identical output.
30
- *
31
- * @param {string} docPath absolute path to a `.doc.{ts,mjs,js}` file
32
- * @param {{zh?: boolean, dense?: boolean, lang?: string}} [opts]
33
- * @returns {Promise<object>} the validated (and optionally translated) doc
34
- */
35
- export async function loadComponentDoc(
36
- docPath,
37
- {zh = false, dense = false, lang} = {},
38
- ) {
39
- const mod = await importUserModule(docPath);
40
- const authored = mod?.default ?? mod?.docs;
41
-
42
- const result = ComponentDocSchema.safeParse(authored);
43
- if (!result.success) {
44
- throw new Error(formatZodError(docPath, result.error));
45
- }
46
- const docs = authored;
47
-
48
- const locale = lang || (dense ? 'dense' : zh ? 'zh' : null);
49
- if (!locale) return docs;
50
-
51
- const translationKey =
52
- locale === 'zh' ? 'docsZh' : locale === 'dense' ? 'docsDense' : null;
53
- if (!translationKey || !mod[translationKey]) return docs;
54
-
55
- const translation = mod[translationKey];
56
- if (translation.props || translation.components?.some(c => c.props)) {
57
- return translation;
58
- }
59
- return mergeTranslation(docs, translation);
60
- }
61
8
 
62
9
  export function mergeTranslation(docs, translation) {
63
10
  if (!translation) return docs;
@@ -144,64 +91,15 @@ export async function loadDocs(readmePath, {zh = false, dense = false, lang} = {
144
91
 
145
92
  const translation = mod[translationKey];
146
93
 
147
- // A full ComponentDoc-shaped translation (legacy docsZh shape) used to be
148
- // returned wholesale. That made it a REPLACEMENT, not an overlay: any prop
149
- // the translation had not caught up with simply ceased to exist —
150
- // `component Button --zh` silently omitted `isInterruptible` and
151
- // `isIconOnly`. A reader of the translated docs cannot discover a prop that
152
- // is not there. Overlay it instead, so an untranslated prop falls back to
153
- // its English entry. (Same principle as the reference-doc overlays, #2182.)
94
+ // If the translation is a full ComponentDoc (legacy docsZh shape), return it directly
154
95
  if (translation.props || translation.components?.some(c => c.props)) {
155
- return overlayComponentDoc(docs, translation);
96
+ return translation;
156
97
  }
157
98
 
158
99
  // Otherwise it's a TranslationDoc — merge it onto docs
159
100
  return mergeTranslation(docs, translation);
160
101
  }
161
102
 
162
- /**
163
- * Overlay a full-ComponentDoc-shaped translation onto the English doc.
164
- *
165
- * Base order and completeness win; the translation supplies text for the
166
- * entries it covers. Props are matched by name, never by position, so a
167
- * translation that is missing entries (or lists them in another order) can no
168
- * longer drop or misattribute one.
169
- *
170
- * @param {any} docs Base (English) component doc.
171
- * @param {any} translation Translated doc, possibly covering only some props.
172
- * @returns {any} Merged doc with every base prop present.
173
- */
174
- function overlayComponentDoc(docs, translation) {
175
- /** Merge one prop list: keep base entries and order, translate what's covered. */
176
- const overlayProps = (baseProps, tProps) => {
177
- if (!baseProps) return baseProps;
178
- const byName = new Map((tProps ?? []).map(p => [p.name, p]));
179
- return baseProps.map(prop => {
180
- const t = byName.get(prop.name);
181
- // Take the translated text, but never let it drop the prop's contract
182
- // (type/default/required stay authoritative from the English doc).
183
- return t ? {...prop, ...t, name: prop.name, type: prop.type} : prop;
184
- });
185
- };
186
-
187
- const merged = {...docs, ...translation};
188
-
189
- merged.props = overlayProps(docs.props, translation.props);
190
-
191
- if (docs.components) {
192
- const tByName = new Map(
193
- (translation.components ?? []).map(c => [c.name, c]),
194
- );
195
- merged.components = docs.components.map(base => {
196
- const t = tByName.get(base.name);
197
- if (!t) return base;
198
- return {...base, ...t, props: overlayProps(base.props, t.props)};
199
- });
200
- }
201
-
202
- return merged;
203
- }
204
-
205
103
  /**
206
104
  * Find the doc file for a component, checking both top-level
207
105
  * and nested directories. Prefers {Name}.doc.mjs, then README.md
@@ -73,3 +73,33 @@ export function formatZodError(label, error) {
73
73
  .join('; ');
74
74
  return `${label} is invalid: ${issues}`;
75
75
  }
76
+
77
+ /**
78
+ * @param {unknown} config
79
+ * @returns {import('../types/config').AstryxConfig}
80
+ */
81
+ export function validateConfig(config) {
82
+ const result = AstryxConfigSchema.safeParse(config);
83
+ if (!result.success) {
84
+ throw new Error(
85
+ formatZodError('astryx.config default export', result.error),
86
+ );
87
+ }
88
+ return result.data;
89
+ }
90
+
91
+ /**
92
+ * @param {unknown} integration
93
+ * @param {string} [label]
94
+ * @returns {import('../types/integration').AstryxIntegration}
95
+ */
96
+ export function validateIntegration(
97
+ integration,
98
+ label = 'integration manifest',
99
+ ) {
100
+ const result = AstryxIntegrationSchema.safeParse(integration);
101
+ if (!result.success) {
102
+ throw new Error(formatZodError(label, result.error));
103
+ }
104
+ return result.data;
105
+ }
@@ -11,7 +11,6 @@
11
11
 
12
12
  import {discoverHooks, findHookDoc} from './hook-discovery.mjs';
13
13
  import {loadDocs} from './component-loader.mjs';
14
- import {mdCell} from './component-format.mjs';
15
14
 
16
15
  /**
17
16
  * Build a signature string from hook docs.
@@ -52,11 +51,9 @@ function formatParamsTable(params) {
52
51
  lines.push('| Param | Type | Default | Description |');
53
52
  lines.push('|-------|------|---------|-------------|');
54
53
  for (const p of params) {
55
- const def = p.default ? `\`${mdCell(p.default)}\`` : '\u2014';
54
+ const def = p.default ? `\`${p.default}\`` : '\u2014';
56
55
  const req = p.required ? ' **(required)**' : '';
57
- lines.push(
58
- `| \`${mdCell(p.name)}\` | \`${mdCell(p.type)}\` | ${def} | ${mdCell(p.description)}${req} |`,
59
- );
56
+ lines.push(`| \`${p.name}\` | \`${p.type}\` | ${def} | ${p.description}${req} |`);
60
57
  }
61
58
  return lines.join('\n');
62
59
  }
@@ -70,9 +67,7 @@ function formatReturnsTable(returns) {
70
67
  lines.push('| Field | Type | Description |');
71
68
  lines.push('|-------|------|-------------|');
72
69
  for (const r of returns) {
73
- lines.push(
74
- `| \`${mdCell(r.name)}\` | \`${mdCell(r.type)}\` | ${mdCell(r.description)} |`,
75
- );
70
+ lines.push(`| \`${r.name}\` | \`${r.type}\` | ${r.description} |`);
76
71
  }
77
72
  return lines.join('\n');
78
73
  }
@@ -230,3 +230,8 @@ export async function buildRegistry({cwd = process.cwd()} = {}) {
230
230
  };
231
231
  return cachedRegistry;
232
232
  }
233
+
234
+ /** Test seam — drop the module-level cache. */
235
+ export function resetRegistryCache() {
236
+ cachedRegistry = null;
237
+ }