@astryxdesign/cli 0.7.0-canary.450c68d → 0.7.0-canary.4ec1f4e

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 (168) hide show
  1. package/README.md +30 -33
  2. package/api/doctor/doctor.doc.mjs +1 -1
  3. package/api/doctor/doctor.test.mjs +28 -0
  4. package/api/doctor/theme-checks.mjs +10 -10
  5. package/api/doctor/theme-checks.test.mjs +5 -4
  6. package/api/gap-report/gap-report.doc.mjs +1 -1
  7. package/api/gap-report/gap-report.mjs +15 -0
  8. package/api/gap-report/gap-report.test.mjs +1 -1
  9. package/api/index.d.mts +0 -2
  10. package/api/index.mjs +0 -2
  11. package/api/init/init.doc.mjs +5 -1
  12. package/api/init/init.mjs +22 -0
  13. package/api/init/init.type.d.mts +4 -1
  14. package/api/init/init.type.mjs +1 -1
  15. package/api/init/remove/remove.mjs +8 -3
  16. package/api/init/remove/remove.test.mjs +12 -0
  17. package/api/init/run/run.d.mts +1 -1
  18. package/api/init/run/run.mjs +3 -3
  19. package/api/integration/validate-integration.d.mts +4 -0
  20. package/api/integration/validate-integration.mjs +5 -2
  21. package/api/integration/validateIntegration.doc.mjs +1 -1
  22. package/api/json/index.ts +0 -1
  23. package/api/search/search.doc.mjs +1 -1
  24. package/api/search/search.mjs +1 -1
  25. package/api/search/search.test.mjs +1 -1
  26. package/api/search/search.type.d.mts +1 -1
  27. package/api/search/search.type.mjs +1 -1
  28. package/api/template/template-integration.test.mjs +37 -100
  29. package/api/template/template.doc.mjs +5 -1
  30. package/api/template/template.mjs +45 -0
  31. package/api/theme/_adapter.mjs +3 -3
  32. package/api/theme/add/add.d.mts +11 -5
  33. package/api/theme/add/add.mjs +19 -192
  34. package/api/theme/add/add.test.mjs +68 -258
  35. package/api/theme/add/add.types.test.mjs +0 -1
  36. package/api/theme/build/build.d.mts +3 -3
  37. package/api/theme/build/build.mjs +22 -36
  38. package/api/theme/build/build.test.mjs +11 -24
  39. package/api/theme/eject/eject.copy-compat.test.mjs +168 -0
  40. package/api/theme/integration-themes.test.mjs +3 -3
  41. package/api/theme/remove/remove.test.mjs +1 -1
  42. package/api/theme/targets/targets.test.mjs +0 -4
  43. package/api/theme/template/template.mjs +1 -1
  44. package/api/theme/theme.type.d.mts +1 -30
  45. package/api/theme/theme.type.mjs +3 -13
  46. package/api/theme/themeAdd.doc.mjs +19 -27
  47. package/api/theme/themeTargets.doc.mjs +3 -4
  48. package/api/theme/themeTemplate.doc.mjs +1 -1
  49. package/api/theme/use/use.test.mjs +1 -1
  50. package/api/upgrade/upgrade.doc.mjs +1 -1
  51. package/api/upgrade/upgrade.mjs +19 -0
  52. package/assets/codemods/transforms/next/README.md +15 -17
  53. package/assets/codemods/transforms/next/__tests__/migrate-deprecated-theme-surface.test.mjs +322 -0
  54. package/assets/codemods/transforms/next/index.mjs +11 -1
  55. package/assets/codemods/transforms/next/migrate-deprecated-theme-surface-v0.6-data.mjs +229 -0
  56. package/assets/codemods/transforms/next/migrate-deprecated-theme-surface.mjs +624 -0
  57. package/assets/codemods/transforms/v0.6.0/migrate-astryx-theme-selectors-to-data-attrs.mjs +38 -18
  58. package/assets/docs/author-a-theme.doc.mjs +1 -1
  59. package/assets/docs/getting-started.doc.mjs +2 -2
  60. package/assets/docs/theme.doc.dense.mjs +1 -1
  61. package/assets/docs/theme.doc.mjs +2 -2
  62. package/assets/docs/tree/add-a-theme.doc.mjs +1 -1
  63. package/assets/docs/tree/document-the-theme.doc.mjs +2 -2
  64. package/assets/docs/tree/fonts-and-assets.doc.mjs +3 -3
  65. package/assets/docs/tree/styling-advanced.doc.mjs +21 -14
  66. package/assets/docs/tree/themes.doc.mjs +1 -1
  67. package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +2 -2
  68. package/assets/docs/tree/versioning.doc.mjs +1 -4
  69. package/assets/docs/use-a-theme.doc.mjs +16 -16
  70. package/authoring/debug/type.ts +2 -2
  71. package/authoring/doctypes/base/type.ts +0 -9
  72. package/authoring/integration/integration.doc.mjs +1 -1
  73. package/clients/cli/command-result-coverage.test.mjs +1 -1
  74. package/clients/cli/commands/build-theme.adaptations.test.mjs +4 -0
  75. package/clients/cli/commands/build-theme.ascii-output.test.mjs +35 -8
  76. package/clients/cli/commands/build-theme.mjs +31 -67
  77. package/clients/cli/commands/build-theme.registry.test.mjs +0 -10
  78. package/clients/cli/commands/debug-result-summary.test.mjs +0 -16
  79. package/clients/cli/commands/discover.mjs +2 -1
  80. package/clients/cli/commands/doctor.mjs +5 -2
  81. package/clients/cli/commands/empty-argument.test.mjs +16 -0
  82. package/clients/cli/commands/gap-report.doc.mjs +1 -1
  83. package/clients/cli/commands/gap-report.test.mjs +2 -2
  84. package/clients/cli/commands/init.doc.mjs +4 -4
  85. package/clients/cli/commands/init.flag-help.test.mjs +7 -10
  86. package/clients/cli/commands/init.next-steps.test.mjs +1 -1
  87. package/clients/cli/commands/option-pair-refusals.test.mjs +37 -0
  88. package/clients/cli/commands/search.test.mjs +1 -1
  89. package/clients/cli/commands/swizzle.mjs +4 -1
  90. package/clients/cli/commands/template.doc.mjs +3 -3
  91. package/clients/cli/commands/template.flag-help.test.mjs +18 -11
  92. package/clients/cli/commands/template.mjs +7 -1
  93. package/clients/cli/commands/text-json-parity.test.mjs +0 -17
  94. package/clients/cli/commands/theme-add-lifecycle.test.mjs +142 -49
  95. package/clients/cli/commands/theme-add.doc.mjs +10 -17
  96. package/clients/cli/commands/theme-list.behavior.test.mjs +2 -1
  97. package/clients/cli/commands/theme-targets.behavior.test.mjs +8 -6
  98. package/clients/cli/commands/theme-template.doc.mjs +1 -1
  99. package/clients/cli/commands/theme.doc.mjs +2 -2
  100. package/clients/cli/commands/upgrade.doc.mjs +1 -1
  101. package/clients/cli/commands/upgrade.flag-help.test.mjs +7 -11
  102. package/clients/cli/commands/validate-nothing-exits-nonzero.test.mjs +67 -0
  103. package/clients/cli/index.mjs +0 -4
  104. package/clients/cli/lib/cli-error.mjs +19 -0
  105. package/clients/cli/lib/component-format.mjs +111 -57
  106. package/clients/cli/lib/component-format.test.mjs +28 -39
  107. package/clients/cli/lib/doc-text-ascii.test.mjs +5 -2
  108. package/clients/cli/lib/exit-codes.test.mjs +0 -7
  109. package/clients/cli/lib/json-shim.test.mjs +0 -24
  110. package/foundation/agent-docs/agent-docs.d.mts +2 -1
  111. package/foundation/agent-docs/agent-docs.mjs +6 -1
  112. package/foundation/agent-docs/app-theme-workflow.test.mjs +3 -0
  113. package/foundation/config/theme-state.mjs +3 -3
  114. package/foundation/debug/debug-fields.test.mjs +13 -35
  115. package/foundation/debug/event.mjs +13 -78
  116. package/foundation/debug/privacy-contract.test.mjs +20 -12
  117. package/foundation/debug/redact.d.mts +2 -2
  118. package/foundation/debug/redact.mjs +2 -2
  119. package/foundation/discovery/theme-imports.mjs +1 -1
  120. package/foundation/discovery/theming-targets.d.mts +1 -20
  121. package/foundation/discovery/theming-targets.mjs +1 -38
  122. package/foundation/discovery/theming-targets.test.mjs +9 -175
  123. package/foundation/doc-compiler/doc-loads.test.mjs +0 -12
  124. package/foundation/response/error-codes.doc.mjs +1 -1
  125. package/foundation/response/response-types.doc.mjs +11 -30
  126. package/foundation/response/response-types.doc.test.mjs +36 -14
  127. package/foundation/response/response.doc.mjs +1 -1
  128. package/foundation/xle/browser.d.mts +2 -2
  129. package/foundation/xle/browser.mjs +2 -2
  130. package/foundation/xle/expand.mjs +1 -1
  131. package/foundation/xle/print.mjs +1 -1
  132. package/package.json +9 -9
  133. package/api/layout/_adapter.d.mts +0 -34
  134. package/api/layout/_adapter.mjs +0 -148
  135. package/api/layout/check/check.d.mts +0 -17
  136. package/api/layout/check/check.mjs +0 -41
  137. package/api/layout/expand/expand.d.mts +0 -23
  138. package/api/layout/expand/expand.mjs +0 -161
  139. package/api/layout/expand/expand.path-safety.test.mjs +0 -53
  140. package/api/layout/expand/expand.receipt.test.mjs +0 -74
  141. package/api/layout/grammar/grammar.d.mts +0 -14
  142. package/api/layout/grammar/grammar.mjs +0 -88
  143. package/api/layout/layout.d.mts +0 -6
  144. package/api/layout/layout.mjs +0 -17
  145. package/api/layout/layout.test.mjs +0 -297
  146. package/api/layout/layout.type.d.mts +0 -90
  147. package/api/layout/layout.type.mjs +0 -104
  148. package/api/layout/layoutCheck.doc.d.mts +0 -11
  149. package/api/layout/layoutCheck.doc.mjs +0 -85
  150. package/api/layout/layoutExpand.doc.d.mts +0 -11
  151. package/api/layout/layoutExpand.doc.mjs +0 -107
  152. package/api/layout/layoutGrammar.doc.d.mts +0 -11
  153. package/api/layout/layoutGrammar.doc.mjs +0 -57
  154. package/api/theme/add/add.binary.test.mjs +0 -157
  155. package/api/theme/add/add.rollback.test.mjs +0 -158
  156. package/api/theme/add/add.staging.test.mjs +0 -83
  157. package/clients/cli/commands/layout-check.doc.mjs +0 -67
  158. package/clients/cli/commands/layout-expand.doc.mjs +0 -87
  159. package/clients/cli/commands/layout-grammar.doc.mjs +0 -32
  160. package/clients/cli/commands/layout.deprecation-lifecycle.test.mjs +0 -140
  161. package/clients/cli/commands/layout.doc.mjs +0 -36
  162. package/clients/cli/commands/layout.error-codes.test.mjs +0 -66
  163. package/clients/cli/commands/layout.exit-parity.test.mjs +0 -41
  164. package/clients/cli/commands/layout.expand-receipt.test.mjs +0 -94
  165. package/clients/cli/commands/layout.mjs +0 -327
  166. package/clients/cli/commands/layout.path-help.test.mjs +0 -33
  167. package/clients/cli/commands/layout.stdin-cap.test.mjs +0 -47
  168. package/clients/cli/commands/layout.text-fields.test.mjs +0 -39
@@ -4,7 +4,11 @@
4
4
  * @file Component doc formatting — render ComponentDoc objects to text
5
5
  */
6
6
 
7
- import {discoverComponents, findComponentReadme, resolveImportPath} from '../../../foundation/discovery/component-discovery.mjs';
7
+ import {
8
+ discoverComponents,
9
+ findComponentReadme,
10
+ resolveImportPath,
11
+ } from '../../../foundation/discovery/component-discovery.mjs';
8
12
  import {loadDocs} from '../../../foundation/discovery/component-loader.mjs';
9
13
  import {getCliInvocation} from '../../../foundation/env/package-manager.mjs';
10
14
 
@@ -26,15 +30,6 @@ function targetKey(target) {
26
30
  return target.className.replace(/^astryx-/, '');
27
31
  }
28
32
 
29
- /**
30
- * Keep deprecated targets visible in reference tables while excluding them from
31
- * snippets readers copy into newly authored themes.
32
- * @param {import('@astryxdesign/cli/authoring').ComponentThemingTarget[]} targets
33
- */
34
- function canonicalTargets(targets) {
35
- return targets.filter(target => target.deprecatedFor == null);
36
- }
37
-
38
33
  /** @param {string} name @returns {string} */
39
34
  function dataAttrForName(name) {
40
35
  return `data-${name.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase()}`;
@@ -117,7 +112,9 @@ function formatSubComponent(comp) {
117
112
  if (table) {
118
113
  out.push(table + '\n');
119
114
  } else {
120
- out.push(`See \`${getCliInvocation()} component ${comp.name}\` for props and usage.\n`);
115
+ out.push(
116
+ `See \`${getCliInvocation()} component ${comp.name}\` for props and usage.\n`,
117
+ );
121
118
  }
122
119
  return out;
123
120
  }
@@ -136,8 +133,10 @@ function getTargetVariants(target, docs) {
136
133
 
137
134
  // If variant is a visualProp, try to resolve the actual variant values from props
138
135
  if (target.visualProps.includes('variant')) {
139
- const allProps = docs.props || (docs.components?.[0]?.props) || [];
140
- const variantProp = allProps.find((/** @type {any} */ p) => p.name === 'variant');
136
+ const allProps = docs.props || docs.components?.[0]?.props || [];
137
+ const variantProp = allProps.find(
138
+ (/** @type {any} */ p) => p.name === 'variant',
139
+ );
141
140
  if (variantProp && variantProp.type.includes('|')) {
142
141
  return variantProp.type
143
142
  .replace(/['"]/g, '')
@@ -172,8 +171,12 @@ function formatTargetsTable(docs, themeData) {
172
171
 
173
172
  /** @type {string[]} */
174
173
  const lines = [];
175
- lines.push('| Component class | Preferred data attributes | Props | States |');
176
- lines.push('|-----------------|---------------------------|-------|--------|');
174
+ lines.push(
175
+ '| Component class | Preferred data attributes | Props | States |',
176
+ );
177
+ lines.push(
178
+ '|-----------------|---------------------------|-------|--------|',
179
+ );
177
180
 
178
181
  for (const target of docs.theming.targets) {
179
182
  const coreVariants = getTargetVariants(target, docs);
@@ -194,11 +197,11 @@ function formatTargetsTable(docs, themeData) {
194
197
  const statesStr = states.length > 0 ? states.join(', ') : '-';
195
198
  const dataAttrs = getTargetDataAttributes(target);
196
199
  const dataAttrsStr =
197
- dataAttrs.length > 0 ? dataAttrs.map(attr => `\`${attr}\``).join(', ') : '-';
200
+ dataAttrs.length > 0
201
+ ? dataAttrs.map(attr => `\`${attr}\``).join(', ')
202
+ : '-';
198
203
 
199
- const className = target.deprecatedFor
200
- ? `\`${target.className}\` _(deprecated; use \`${target.deprecatedFor}\`)_`
201
- : `\`${target.className}\``;
204
+ const className = `\`${target.className}\``;
202
205
  lines.push(
203
206
  `| ${className} | ${dataAttrsStr} | ${variantsStr} | ${statesStr} |`,
204
207
  );
@@ -229,7 +232,9 @@ export function formatFull(docs, options = {}) {
229
232
  // agents to conflate the primary with a sub-component and hallucinate props
230
233
  // (origin/main #2860). Bare name per the un-prefix migration (P5a).
231
234
  const displayName = docs.name;
232
- sections.push(`**Import:** \`import {${displayName}} from '${options.importHint}';\`\n`);
235
+ sections.push(
236
+ `**Import:** \`import {${displayName}} from '${options.importHint}';\`\n`,
237
+ );
233
238
  }
234
239
 
235
240
  if (docs.usage?.anatomy?.length) {
@@ -238,7 +243,9 @@ export function formatFull(docs, options = {}) {
238
243
  sections.push('|---------|----------|-------------|');
239
244
  for (const el of docs.usage.anatomy) {
240
245
  const req = el.required ? 'Yes' : 'No';
241
- sections.push(`| ${mdCell(el.name)} | ${req} | ${mdCell(el.description)} |`);
246
+ sections.push(
247
+ `| ${mdCell(el.name)} | ${req} | ${mdCell(el.description)} |`,
248
+ );
242
249
  }
243
250
  sections.push('');
244
251
  }
@@ -246,7 +253,7 @@ export function formatFull(docs, options = {}) {
246
253
  if (docs.usage?.bestPractices?.length) {
247
254
  sections.push('## Best Practices\n');
248
255
  for (const bp of docs.usage.bestPractices) {
249
- const badge = bp.guidance ? '**Do:**' : '**Don\'t:**';
256
+ const badge = bp.guidance ? '**Do:**' : "**Don't:**";
250
257
  sections.push(`- ${badge} ${bp.description}`);
251
258
  }
252
259
  sections.push('');
@@ -283,24 +290,30 @@ export function formatFull(docs, options = {}) {
283
290
  }
284
291
 
285
292
  if (docs.theming) {
286
- const { themeData = null } = options;
293
+ const {themeData = null} = options;
287
294
  sections.push('## Theming\n');
288
- // Targets table with theme variant merging
295
+ // Targets table with theme variant merging
289
296
  if (docs.theming.targets?.length) {
290
297
  const targetsTable = formatTargetsTable(docs, themeData);
291
298
  sections.push(targetsTable + '\n');
292
299
 
293
300
  // Note about theme variants if any are present
294
301
  if (themeData?.variants) {
295
- const componentKeys = docs.theming.targets.map((/** @type {any} */ t) => targetKey(t));
296
- const hasThemeVariants = componentKeys.some((/** @type {any} */ k) => themeData.variants[k]?.length > 0);
302
+ const componentKeys = docs.theming.targets.map((/** @type {any} */ t) =>
303
+ targetKey(t),
304
+ );
305
+ const hasThemeVariants = componentKeys.some(
306
+ (/** @type {any} */ k) => themeData.variants[k]?.length > 0,
307
+ );
297
308
  if (hasThemeVariants) {
298
- sections.push(`_\\* = custom variant from ${themeData.name || 'active'} theme_\n`);
309
+ sections.push(
310
+ `_\\* = custom variant from ${themeData.name || 'active'} theme_\n`,
311
+ );
299
312
  }
300
313
  }
301
314
 
302
315
  // Generate defineTheme example with canonical component selectors only.
303
- const exampleTargets = canonicalTargets(docs.theming.targets);
316
+ const exampleTargets = docs.theming.targets;
304
317
  if (exampleTargets.length > 0) {
305
318
  const exampleLines = ['Override in defineTheme:\n```ts\ncomponents: {'];
306
319
  const rootTarget = exampleTargets[0];
@@ -309,7 +322,9 @@ export function formatFull(docs, options = {}) {
309
322
  exampleLines.push(` base: { /* CSS properties */ },`);
310
323
  if (rootTarget.visualProps?.length) {
311
324
  const firstVariant = rootTarget.visualProps[0];
312
- exampleLines.push(` '${firstVariant}:value': { /* variant-specific */ },`);
325
+ exampleLines.push(
326
+ ` '${firstVariant}:value': { /* variant-specific */ },`,
327
+ );
313
328
  }
314
329
  if (rootTarget.states?.length) {
315
330
  const firstState = rootTarget.states[0];
@@ -339,10 +354,14 @@ export function formatFull(docs, options = {}) {
339
354
 
340
355
  // Component CSS vars — split into public (directly settable) and private (set via derived)
341
356
  if (docs.theming?.vars?.length) {
342
- const publicVars = docs.theming.vars.filter((/** @type {any} */ v) => !v.private && !v.derived);
357
+ const publicVars = docs.theming.vars.filter(
358
+ (/** @type {any} */ v) => !v.private && !v.derived,
359
+ );
343
360
 
344
361
  if (publicVars.length > 0) {
345
- sections.push('**Themeable CSS variables** - additional properties that can be overridden in `defineTheme` component overrides.\n');
362
+ sections.push(
363
+ '**Themeable CSS variables** - additional properties that can be overridden in `defineTheme` component overrides.\n',
364
+ );
346
365
  const varLines = [];
347
366
  varLines.push('| CSS Variable | Default | Description |');
348
367
  varLines.push('|-------------|---------|-------------|');
@@ -356,25 +375,37 @@ export function formatFull(docs, options = {}) {
356
375
 
357
376
  // Show derived property examples — the recommended way to theme
358
377
  if (docs.theming?.derived?.length) {
359
- const canonical = canonicalTargets(docs.theming.targets || []);
360
- const varsKey = canonical.length ? targetKey(canonical[0]) : docs.theming.componentKey || '';
378
+ const canonical = docs.theming.targets || [];
379
+ const varsKey = canonical.length
380
+ ? targetKey(canonical[0])
381
+ : docs.theming.componentKey || '';
361
382
  const derivedExamples = docs.theming.derived
362
383
  .filter((/** @type {any} */ d) => d.vars?.length)
363
384
  .map((/** @type {any} */ d) => ` ${d.property}: '...',`)
364
385
  .join('\n');
365
386
  const expandExamples = docs.theming.derived
366
387
  .filter((/** @type {any} */ d) => d.expand === 'container')
367
- .map((/** @type {any} */ d) => ` ${d.property}: '...', // expands to container layout tokens`)
388
+ .map(
389
+ (/** @type {any} */ d) =>
390
+ ` ${d.property}: '...', // expands to container layout tokens`,
391
+ )
392
+ .join('\n');
393
+ const allExamples = [derivedExamples, expandExamples]
394
+ .filter(Boolean)
368
395
  .join('\n');
369
- const allExamples = [derivedExamples, expandExamples].filter(Boolean).join('\n');
370
396
  if (allExamples) {
371
- sections.push('Some properties are set via standard CSS in component overrides:\n```ts\ncomponents: {\n ' + varsKey + ': {\n base: {\n' + allExamples + '\n },\n },\n}\n```\n');
397
+ sections.push(
398
+ 'Some properties are set via standard CSS in component overrides:\n```ts\ncomponents: {\n ' +
399
+ varsKey +
400
+ ': {\n base: {\n' +
401
+ allExamples +
402
+ '\n },\n },\n}\n```\n',
403
+ );
372
404
  }
373
405
  }
374
406
  }
375
407
  }
376
408
 
377
-
378
409
  return sections.join('\n');
379
410
  }
380
411
 
@@ -401,21 +432,29 @@ export function formatCompact(docs, componentName, importHint) {
401
432
  sections.push(desc + '\n');
402
433
 
403
434
  if (docs.usage?.anatomy?.length) {
404
- sections.push('Anatomy: ' + docs.usage.anatomy.map((/** @type {any} */ el) => {
405
- const req = el.required ? '' : ' (optional)';
406
- return `${el.name}${req}`;
407
- }).join(', ') + '\n');
435
+ sections.push(
436
+ 'Anatomy: ' +
437
+ docs.usage.anatomy
438
+ .map((/** @type {any} */ el) => {
439
+ const req = el.required ? '' : ' (optional)';
440
+ return `${el.name}${req}`;
441
+ })
442
+ .join(', ') +
443
+ '\n',
444
+ );
408
445
  }
409
446
 
410
447
  if (importHint) {
411
448
  sections.push('## Import\n');
412
- sections.push(`\`\`\`tsx\nimport { ${displayName} } from '${importHint}';\n\`\`\`\n`);
449
+ sections.push(
450
+ `\`\`\`tsx\nimport { ${displayName} } from '${importHint}';\n\`\`\`\n`,
451
+ );
413
452
  }
414
453
 
415
454
  if (docs.usage?.bestPractices?.length) {
416
455
  sections.push('## Best Practices\n');
417
456
  for (const bp of docs.usage.bestPractices) {
418
- const badge = bp.guidance ? '**Do:**' : '**Don\'t:**';
457
+ const badge = bp.guidance ? '**Do:**' : "**Don't:**";
419
458
  sections.push(`- ${badge} ${bp.description}`);
420
459
  }
421
460
  sections.push('');
@@ -453,7 +492,12 @@ export function formatCompact(docs, componentName, importHint) {
453
492
  propLines.push('| CSS Property | Sets |');
454
493
  propLines.push('|-------------|------|');
455
494
  for (const d of docs.theming.derived) {
456
- const target = d.expand === 'container' ? 'container layout tokens' : (d.vars || []).map((/** @type {any} */ v) => `\`${mdCell(v)}\``).join(', ');
495
+ const target =
496
+ d.expand === 'container'
497
+ ? 'container layout tokens'
498
+ : (d.vars || [])
499
+ .map((/** @type {any} */ v) => `\`${mdCell(v)}\``)
500
+ .join(', ');
457
501
  propLines.push(`| \`${mdCell(d.property)}\` | ${target} |`);
458
502
  }
459
503
  sections.push(propLines.join('\n') + '\n');
@@ -504,7 +548,9 @@ export function formatBrief(docs, componentName, importHint, options = {}) {
504
548
  if ('props' in docs) {
505
549
  props = docs.props;
506
550
  } else if ('components' in docs) {
507
- const entry = docs.components.find((/** @type {any} */ c) => c.name === displayName);
551
+ const entry = docs.components.find(
552
+ (/** @type {any} */ c) => c.name === displayName,
553
+ );
508
554
  if (entry) {
509
555
  props = entry.props;
510
556
  description = entry.description;
@@ -549,9 +595,7 @@ export function formatBrief(docs, componentName, importHint, options = {}) {
549
595
  // Description (shortened)
550
596
  if (description) {
551
597
  const shortDesc =
552
- description.length > 80
553
- ? description.slice(0, 77) + '...'
554
- : description;
598
+ description.length > 80 ? description.slice(0, 77) + '...' : description;
555
599
  output.push(` ${shortDesc}`);
556
600
  }
557
601
 
@@ -569,25 +613,33 @@ export function formatBrief(docs, componentName, importHint, options = {}) {
569
613
  // Derived properties (if any)
570
614
  if (docs.theming?.derived?.length) {
571
615
  const derivedNames = docs.theming.derived
572
- .map((/** @type {any} */ d) => d.expand === 'container' ? `${d.property} -> container tokens` : `${d.property} -> ${(d.vars || []).join(', ')}`)
616
+ .map((/** @type {any} */ d) =>
617
+ d.expand === 'container'
618
+ ? `${d.property} -> container tokens`
619
+ : `${d.property} -> ${(d.vars || []).join(', ')}`,
620
+ )
573
621
  .join('; ');
574
622
  output.push(` Derived: ${derivedNames}`);
575
623
  }
576
624
 
577
- // Theme targets (component class, preferred data attrs, props, states) with theme variant merging
625
+ // Theme targets (component class, preferred data attrs, props, states) with theme variant merging
578
626
  if (docs.theming?.targets?.length) {
579
- const { themeData = null } = options;
627
+ const {themeData = null} = options;
580
628
  const targetParts = docs.theming.targets.map((/** @type {any} */ t) => {
581
629
  const parts = [t.className];
582
- if (t.deprecatedFor) parts.push(`deprecated->${t.deprecatedFor}`);
583
630
  const dataAttrs = getTargetDataAttributes(t);
584
- if (dataAttrs.length) parts.push(`preferred attrs: ${dataAttrs.join(', ')}`);
585
- if (t.visualProps?.length) parts.push(`variants: ${t.visualProps.join(', ')}`);
631
+ if (dataAttrs.length)
632
+ parts.push(`preferred attrs: ${dataAttrs.join(', ')}`);
633
+ if (t.visualProps?.length)
634
+ parts.push(`variants: ${t.visualProps.join(', ')}`);
586
635
  if (t.states?.length) parts.push(`states: ${t.states.join(', ')}`);
587
636
  // Merge theme variants
588
637
  const componentKey = targetKey(t);
589
638
  const themeVars = themeData?.variants?.[componentKey];
590
- if (themeVars?.length) parts.push(`theme: ${themeVars.map((/** @type {any} */ v) => v + '*').join(', ')}`);
639
+ if (themeVars?.length)
640
+ parts.push(
641
+ `theme: ${themeVars.map((/** @type {any} */ v) => v + '*').join(', ')}`,
642
+ );
591
643
  return parts.join(' ');
592
644
  });
593
645
  output.push(` Targets: ${targetParts.join(' | ')}`);
@@ -602,7 +654,9 @@ export function formatBrief(docs, componentName, importHint, options = {}) {
602
654
  if (examples.length > 0) {
603
655
  const code = examples[0].code;
604
656
  const codeLine =
605
- code.split('\n').find((/** @type {string} */ l) => l.trim().startsWith('<XDS')) ||
657
+ code
658
+ .split('\n')
659
+ .find((/** @type {string} */ l) => l.trim().startsWith('<XDS')) ||
606
660
  code.split('\n')[0];
607
661
  output.push(` ${codeLine.trim()}`);
608
662
  }
@@ -682,7 +736,7 @@ export async function formatBriefAll(
682
736
  if (readmePath && readmePath.endsWith('.doc.mjs')) {
683
737
  const docs = await loadDocs(readmePath, {zh, lang});
684
738
  const importPath = resolveImportPath(coreDir, comp);
685
- output.push(formatBrief(docs, comp, importPath, { themeData }));
739
+ output.push(formatBrief(docs, comp, importPath, {themeData}));
686
740
  } else {
687
741
  output.push(`${comp}\n (no docs)\n`);
688
742
  }
@@ -9,7 +9,10 @@ describe('component accessibility guidance', () => {
9
9
  description: 'An action.',
10
10
  usage: {
11
11
  accessibility: [
12
- {name: 'Loading', description: 'Expose aria-busy and block duplicate activation.'},
12
+ {
13
+ name: 'Loading',
14
+ description: 'Expose aria-busy and block duplicate activation.',
15
+ },
13
16
  ],
14
17
  },
15
18
  props: [],
@@ -18,7 +21,9 @@ describe('component accessibility guidance', () => {
18
21
  it('renders a dedicated section in full output', () => {
19
22
  const out = formatFull(docs);
20
23
  expect(out).toContain('## Accessibility');
21
- expect(out).toContain('- **Loading:** Expose aria-busy and block duplicate activation.');
24
+ expect(out).toContain(
25
+ '- **Loading:** Expose aria-busy and block duplicate activation.',
26
+ );
22
27
  });
23
28
 
24
29
  it('keeps accessibility guidance in compact agent output', () => {
@@ -32,11 +37,16 @@ describe('component accessibility guidance', () => {
32
37
  });
33
38
 
34
39
  it('ignores legacy non-array accessibility content', () => {
35
- const legacyDocs = {...docs, usage: {accessibility: 'Follow WCAG guidance.'}};
40
+ const legacyDocs = {
41
+ ...docs,
42
+ usage: {accessibility: 'Follow WCAG guidance.'},
43
+ };
36
44
 
37
45
  expect(() => formatFull(legacyDocs)).not.toThrow();
38
46
  expect(formatFull(legacyDocs)).not.toContain('## Accessibility');
39
- expect(formatCompact(legacyDocs, 'Button')).not.toContain('## Accessibility');
47
+ expect(formatCompact(legacyDocs, 'Button')).not.toContain(
48
+ '## Accessibility',
49
+ );
40
50
  });
41
51
  });
42
52
 
@@ -56,7 +66,9 @@ describe('formatFull sub-component rendering', () => {
56
66
  expect(out).toContain('### XDSRadioListItem');
57
67
  expect(out).not.toContain('undefined');
58
68
  // Points the reader at the sub-component's own docs instead of a blank.
59
- expect(out).toMatch(/(?:astryx|@astryxdesign\/cli) component XDSRadioListItem/);
69
+ expect(out).toMatch(
70
+ /(?:astryx|@astryxdesign\/cli) component XDSRadioListItem/,
71
+ );
60
72
  });
61
73
 
62
74
  it('renders a full props table for a sub-component that has inline props', () => {
@@ -100,7 +112,9 @@ describe('formatFull theming override keys', () => {
100
112
  const docs = {
101
113
  name: 'Button',
102
114
  description: 'A button.',
103
- theming: {targets: [{className: 'astryx-button', visualProps: ['variant']}]},
115
+ theming: {
116
+ targets: [{className: 'astryx-button', visualProps: ['variant']}],
117
+ },
104
118
  };
105
119
  const out = formatFull(docs);
106
120
 
@@ -131,37 +145,6 @@ describe('formatFull theming override keys', () => {
131
145
  });
132
146
  });
133
147
 
134
- describe('deprecated theming target guidance', () => {
135
- const docs = {
136
- name: 'Example',
137
- description: 'An example.',
138
- theming: {
139
- targets: [
140
- {className: 'astryx-old-target', deprecatedFor: 'new-target'},
141
- {className: 'astryx-new-target'},
142
- ],
143
- },
144
- };
145
-
146
- it('names the canonical replacement in full component docs', () => {
147
- expect(formatFull(docs)).toContain(
148
- '`astryx-old-target` _(deprecated; use `new-target`)_',
149
- );
150
- });
151
-
152
- it('excludes deprecated targets from copyable defineTheme examples', () => {
153
- const out = formatFull(docs);
154
- expect(out).not.toContain("'old-target': {");
155
- expect(out).toContain("'new-target': {");
156
- });
157
-
158
- it('keeps the replacement in brief agent guidance', () => {
159
- expect(formatBrief(docs, 'Example')).toContain(
160
- 'astryx-old-target deprecated->new-target',
161
- );
162
- });
163
- });
164
-
165
148
  /** Pipes that actually separate cells — a `\|` is content, not a separator. */
166
149
  function cellPipes(row) {
167
150
  return (row.match(/(?<!\\)\|/g) || []).length;
@@ -236,7 +219,11 @@ describe('formatBrief signature stays terse', () => {
236
219
  type: '0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10',
237
220
  description: 'Gap.',
238
221
  },
239
- {name: 'wrap', type: "'nowrap' | 'wrap' | 'wrap-reverse'", description: 'Wrap.'},
222
+ {
223
+ name: 'wrap',
224
+ type: "'nowrap' | 'wrap' | 'wrap-reverse'",
225
+ description: 'Wrap.',
226
+ },
240
227
  {
241
228
  name: 'hAlign',
242
229
  type: "'start' | 'center' | 'end' | 'between' | 'around' | 'evenly'",
@@ -248,7 +235,9 @@ describe('formatBrief signature stays terse', () => {
248
235
 
249
236
  // Short enums still earn their place in the signature.
250
237
  expect(signature).toContain('wrap: nowrap|wrap|wrap-reverse');
251
- expect(signature).toContain('hAlign: start|center|end|between|around|evenly');
238
+ expect(signature).toContain(
239
+ 'hAlign: start|center|end|between|around|evenly',
240
+ );
252
241
  // The long scale does not.
253
242
  expect(signature).not.toContain('0|0.5|1|1.5|2|3|4|5|6|8|10');
254
243
  // But the prop is still named, so it is not lost.
@@ -42,7 +42,7 @@ const componentDoc = {
42
42
  {property: 'radius', vars: ['--widget-radius']},
43
43
  ],
44
44
  targets: [
45
- {className: 'astryx-widget', deprecatedFor: 'astryx-widget-v2'},
45
+ {className: 'astryx-widget'},
46
46
  {className: 'astryx-widget-v2', visualProps: ['variant']},
47
47
  ],
48
48
  },
@@ -63,7 +63,10 @@ describe('component text output is ASCII', () => {
63
63
  it.each([
64
64
  ['formatFull', () => formatFull(componentDoc)],
65
65
  ['formatCompact', () => formatCompact(componentDoc, 'Widget')],
66
- ['formatBrief', () => formatBrief(componentDoc, 'Widget', '@astryxdesign/core/Widget')],
66
+ [
67
+ 'formatBrief',
68
+ () => formatBrief(componentDoc, 'Widget', '@astryxdesign/core/Widget'),
69
+ ],
67
70
  ['formatProps', () => formatProps(componentDoc, 'Widget')],
68
71
  ])('%s', (_name, render) => {
69
72
  expect(nonAscii(render())).toEqual([]);
@@ -70,13 +70,6 @@ describe('command exit codes', () => {
70
70
  },
71
71
  );
72
72
 
73
- it('bare `astryx layout` exits 1 in both modes, as documented', async () => {
74
- const doc = commandDocs.find((d) => d.name === 'layout');
75
- expect(doc.exitCodes.find((e) => e.code === 1)?.when).toMatch(/^no subcommand/);
76
- expect((await runCli(['layout'])).status).toBe(1);
77
- expect((await runCli(['layout', '--json'])).status).toBe(1);
78
- });
79
-
80
73
  it('`astryx discover` with a blank query exits 1 only when packages are discovered', async () => {
81
74
  const doc = commandDocs.find((d) => d.name === 'discover');
82
75
  expect(doc.exitCodes.find((e) => e.code === 1)?.when).toMatch(/blank query when packages are discovered/);
@@ -225,23 +225,6 @@ describe('--json shim: help shown for a failed invocation is an error envelope',
225
225
  expect(parsed.error).toMatch(/bogus/);
226
226
  });
227
227
 
228
- it('astryx layout --json (group, no subcommand) emits ERR_MISSING_ARGUMENT, exit 1', async () => {
229
- const {status, stdout, stderr} = await runCli(['layout', '--json']);
230
- expect(status).toBe(1);
231
- expect(stderr).toBe('');
232
- const parsed = parseJson(stdout);
233
- expect(parsed).not.toHaveProperty('type');
234
- expect(parsed.code).toBe('ERR_MISSING_ARGUMENT');
235
- expect(parsed.suggestions.map((s) => s.name)).toContain('layout expand');
236
- });
237
-
238
- it('astryx layout (no --json) still prints help to stderr, exit 1', async () => {
239
- const {status, stdout, stderr} = await runCli(['layout']);
240
- expect(status).toBe(1);
241
- expect(stdout).toBe('');
242
- expect(stderr).toMatch(/Usage: astryx layout/);
243
- });
244
-
245
228
  it('the real binary emits the same envelope for help bogus --json', () => {
246
229
  // One program per process, so the root's own outputHelp patch is used here.
247
230
  const bin = fileURLToPath(new URL('../bin/astryx.mjs', import.meta.url));
@@ -282,11 +265,4 @@ describe('--json shim: help shown for a failed invocation is an error envelope',
282
265
  expect(parsed.suggestions).toEqual([{name: 'late child', reason: 'available subcommand'}]);
283
266
  });
284
267
 
285
- it('astryx help layout --json still emits the help envelope, exit 0', async () => {
286
- const {status, stdout} = await runCli(['help', 'layout', '--json']);
287
- expect(status).toBe(0);
288
- const parsed = parseJson(stdout);
289
- expect(parsed.type).toBe('help');
290
- expect(parsed.data.command).toBe('astryx layout');
291
- });
292
268
  });
@@ -183,10 +183,11 @@ export function removeXdsBlock(filePath: string, { deleteIfEmpty }?: {
183
183
  /**
184
184
  * Remove Astryx section from all known agent doc files.
185
185
  * @param {string} targetDir
186
+ * @returns {string[]} the project-relative files a block was removed from.
186
187
  * @throws {PathSafetyError} `ERR_PATH_TRAVERSAL` when a file it would change
187
188
  * resolves outside `targetDir`; nothing is changed.
188
189
  */
189
- export function removeAgentDocs(targetDir: string): void;
190
+ export function removeAgentDocs(targetDir: string): string[];
190
191
  /**
191
192
  * Programmatic entry point for installing agent docs.
192
193
  * Used by the init command, upgrade command, and agent-docs command.
@@ -458,7 +458,7 @@ export function generateCompressedIndex(
458
458
  } else {
459
459
  lines.push("- Style with component props first, then tokens (var(--color-*|--spacing-*|--radius-*)). No raw hex/px. No StyleX/Tailwind compiler here — don't use xstyle/utility classes directly. Some templates use StyleX and need a compiler plugin; see `astryx docs styling-overview`.");
460
460
  }
461
- lines.push('- Palettes and custom colors go through the theme, never :root overrides. See `astryx docs theme`.');
461
+ lines.push('- Palettes and custom colors go through the theme, never :root overrides. Run `astryx theme add <slug>` to import; `theme eject <slug>` only forks source. See `astryx docs theme`.');
462
462
  // Self-check — post-generation pass. Validated via vibe tests (internal/vibe-tests/
463
463
  // prompt-purity-test): on complex multi-step UIs the rules above alone still leave raw
464
464
  // CSS in ~11-13% of runs; a re-read-and-fix pass cuts that ~4x at negligible token cost.
@@ -773,6 +773,7 @@ function assertTargetsWithin(targetDir, relPaths) {
773
773
  /**
774
774
  * Remove Astryx section from all known agent doc files.
775
775
  * @param {string} targetDir
776
+ * @returns {string[]} the project-relative files a block was removed from.
776
777
  * @throws {PathSafetyError} `ERR_PATH_TRAVERSAL` when a file it would change
777
778
  * resolves outside `targetDir`; nothing is changed.
778
779
  */
@@ -789,11 +790,14 @@ export function removeAgentDocs(targetDir) {
789
790
  throw new PathSafetyError(err.message, ERROR_CODES.ERR_PATH_TRAVERSAL);
790
791
  }
791
792
 
793
+ /** @type {string[]} */
794
+ const removedFrom = [];
792
795
  for (const p of allPaths) {
793
796
  const filePath = path.join(targetDir, p);
794
797
  // Delete if empty for files we created (AGENTS.md, .claude/CLAUDE.md)
795
798
  const deleteIfEmpty = p === AGENTS_MD || p === CLAUDE_DIR_MD;
796
799
  if (removeXdsBlock(filePath, {deleteIfEmpty})) {
800
+ removedFrom.push(p);
797
801
  if (!fs.existsSync(filePath)) {
798
802
  humanLog(`[ok] Removed empty ${p}`);
799
803
  } else {
@@ -801,6 +805,7 @@ export function removeAgentDocs(targetDir) {
801
805
  }
802
806
  }
803
807
  }
808
+ return removedFrom;
804
809
  }
805
810
 
806
811
  /**
@@ -9,5 +9,8 @@ describe('generated agent docs app-theme workflow', () => {
9
9
 
10
10
  expect(result).toContain('astryx docs theme');
11
11
  expect(result).toContain('never :root overrides');
12
+ expect(result).toContain('theme add <slug>');
13
+ expect(result).toContain('theme eject <slug>');
14
+ expect(result).not.toContain('theme add <slug> --import');
12
15
  });
13
16
  });
@@ -106,7 +106,7 @@ export function themeModuleCandidates(projectDir) {
106
106
  function validThemeRecord(value, label) {
107
107
  if (!isRecord(value) || !isRecord(value.themes)) {
108
108
  throw new ThemeStateError(
109
- `${label} must carry a static ${THEME_RECORD_MARKER} header. Regenerate it with \`astryx theme add <slug> --import\`.`,
109
+ `${label} must carry a static ${THEME_RECORD_MARKER} header. Regenerate it with \`astryx theme add <slug>\`.`,
110
110
  );
111
111
  }
112
112
  const keys = Object.keys(value);
@@ -159,7 +159,7 @@ export function parseThemeModuleRecord(source, label = 'theme module') {
159
159
  .filter(line => /^\s*\*\s*@astryx-theme-record\s+/u.test(line));
160
160
  if (recordLines.length !== 1) {
161
161
  throw new ThemeStateError(
162
- `${label} must carry exactly one static ${THEME_RECORD_MARKER} header. Regenerate it with \`astryx theme add <slug> --import\`.`,
162
+ `${label} must carry exactly one static ${THEME_RECORD_MARKER} header. Regenerate it with \`astryx theme add <slug>\`.`,
163
163
  );
164
164
  }
165
165
  const payload = recordLines[0].replace(
@@ -318,7 +318,7 @@ export function readThemeState(cwd = process.cwd()) {
318
318
  export function renderThemeModule(themes, defaultSlug, typescript) {
319
319
  if (!themes.some(theme => theme.slug === defaultSlug)) {
320
320
  throw new ThemeStateError(
321
- `Default theme "${defaultSlug}" is not added. Run \`astryx theme add ${defaultSlug} --import\` first.`,
321
+ `Default theme "${defaultSlug}" is not added. Run \`astryx theme add ${defaultSlug}\` first.`,
322
322
  );
323
323
  }
324
324
  /** @type {string[]} */