@astryxdesign/cli 0.6.6-canary.fcf255b → 0.6.6-canary.ffa4f72

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 (184) hide show
  1. package/README.md +83 -83
  2. package/api/build/_adapter.d.mts +15 -0
  3. package/api/build/_adapter.mjs +22 -0
  4. package/api/build/build.doc.mjs +1 -1
  5. package/api/build/build.type.d.mts +4 -0
  6. package/api/build/build.type.mjs +1 -0
  7. package/api/build/help/help.mjs +1 -1
  8. package/api/build/kit/kit.mjs +12 -1
  9. package/api/component/component-replacement.test.mjs +12 -0
  10. package/api/component/component.doc.mjs +5 -2
  11. package/api/docs/_adapter.mjs +48 -1
  12. package/api/docs/compiled-topics.test.mjs +1 -1
  13. package/api/docs/detail/section/section.d.mts +44 -0
  14. package/api/docs/detail/section/section.mjs +164 -13
  15. package/api/docs/detail/section/section.test.mjs +4 -4
  16. package/api/docs/docOverlays.test.mjs +28 -17
  17. package/api/docs/docs.doc.mjs +3 -3
  18. package/api/docs/docs.mjs +11 -16
  19. package/api/docs/docs.test.mjs +9 -10
  20. package/api/docs/integration-tree.test.mjs +26 -26
  21. package/api/docs/integrationDocs.test.mjs +2 -2
  22. package/api/docs/namespace-section.test.mjs +260 -0
  23. package/api/docs/token-tables.test.mjs +93 -0
  24. package/api/doctor/_adapter.d.mts +7 -0
  25. package/api/doctor/_adapter.mjs +48 -0
  26. package/api/doctor/doctor.d.mts +6 -0
  27. package/api/doctor/doctor.mjs +154 -43
  28. package/api/doctor/doctor.test.mjs +104 -0
  29. package/api/doctor/theme-checks.d.mts +12 -0
  30. package/api/doctor/theme-checks.mjs +115 -1
  31. package/api/doctor/theme-checks.test.mjs +142 -1
  32. package/api/gap-report/gap-report.doc.mjs +2 -1
  33. package/api/init/run/run.mjs +1 -0
  34. package/api/integration/validate-integration.mjs +20 -4
  35. package/api/integration/validate-integration.test.mjs +73 -0
  36. package/api/layout/check/check.d.mts +1 -0
  37. package/api/layout/check/check.mjs +1 -0
  38. package/api/layout/expand/expand.d.mts +1 -0
  39. package/api/layout/expand/expand.mjs +1 -0
  40. package/api/layout/grammar/grammar.d.mts +1 -0
  41. package/api/layout/grammar/grammar.mjs +1 -0
  42. package/api/layout/layoutCheck.doc.mjs +1 -1
  43. package/api/layout/layoutExpand.doc.mjs +1 -1
  44. package/api/layout/layoutGrammar.doc.mjs +1 -1
  45. package/api/search/search.d.mts +44 -0
  46. package/api/search/search.domain-priority.test.mjs +261 -0
  47. package/api/search/search.mjs +191 -29
  48. package/api/swizzle/swizzle.doc.mjs +5 -2
  49. package/api/template/copy/copy.mjs +12 -0
  50. package/api/template/template.doc.mjs +1 -1
  51. package/api/template/template.type.d.mts +3 -0
  52. package/api/template/template.type.mjs +3 -0
  53. package/api/theme/build/build.d.mts +70 -0
  54. package/api/theme/build/build.mjs +205 -41
  55. package/api/theme/build/font-warning.d.mts +11 -0
  56. package/api/theme/build/font-warning.mjs +28 -3
  57. package/assets/docs/author-a-theme.doc.mjs +19 -14
  58. package/assets/docs/getting-started.doc.mjs +2 -2
  59. package/assets/docs/principles.doc.dense.mjs +3 -3
  60. package/assets/docs/principles.doc.mjs +4 -4
  61. package/assets/docs/principles.doc.zh.mjs +3 -3
  62. package/assets/docs/styling-overview.doc.mjs +211 -0
  63. package/assets/docs/theme.doc.dense.mjs +1 -1
  64. package/assets/docs/theme.doc.mjs +5 -5
  65. package/assets/docs/theme.doc.zh.mjs +1 -1
  66. package/assets/docs/tree/component-migration.doc.mjs +107 -0
  67. package/assets/docs/tree/css-and-stylex.doc.mjs +150 -0
  68. package/assets/docs/tree/font-setup.doc.mjs +122 -0
  69. package/assets/docs/tree/headers-and-footers.doc.mjs +0 -1
  70. package/assets/docs/tree/i18n-library-integration.doc.mjs +167 -0
  71. package/assets/docs/tree/i18n-quick-start.doc.mjs +101 -0
  72. package/assets/docs/{internationalization.doc.mjs → tree/i18n-rtl-and-testing.doc.mjs} +17 -223
  73. package/assets/docs/tree/internationalization.doc.mjs +29 -0
  74. package/assets/docs/tree/layout.doc.mjs +23 -0
  75. package/assets/docs/{migration.doc.mjs → tree/migration-setup.doc.mjs} +24 -129
  76. package/assets/docs/tree/migration-verification.doc.mjs +67 -0
  77. package/assets/docs/tree/migration.doc.mjs +28 -0
  78. package/assets/docs/tree/non-css-processing.doc.mjs +112 -0
  79. package/assets/docs/tree/other-libraries.doc.mjs +218 -0
  80. package/assets/docs/tree/responsive.doc.mjs +0 -4
  81. package/assets/docs/tree/scaffold.doc.mjs +0 -5
  82. package/assets/docs/tree/side-panels.doc.mjs +0 -1
  83. package/assets/docs/tree/structure.doc.mjs +0 -4
  84. package/assets/docs/tree/styling-advanced.doc.mjs +159 -0
  85. package/assets/docs/tree/styling-basics.doc.mjs +181 -0
  86. package/assets/docs/tree/styling-libraries.doc.mjs +30 -0
  87. package/assets/docs/tree/styling.doc.mjs +29 -0
  88. package/assets/docs/tree/tailwind.doc.mjs +65 -0
  89. package/assets/docs/tree/tokens-and-setup.doc.mjs +128 -0
  90. package/assets/docs/tree/tokens-border.doc.mjs +46 -0
  91. package/assets/docs/tree/tokens-color.doc.dense.mjs +10 -0
  92. package/assets/docs/tree/tokens-color.doc.mjs +438 -0
  93. package/assets/docs/tree/tokens-color.doc.zh.mjs +10 -0
  94. package/assets/docs/tree/tokens-data.doc.mjs +323 -0
  95. package/assets/docs/tree/tokens-duration.doc.mjs +78 -0
  96. package/assets/docs/tree/tokens-ease.doc.mjs +46 -0
  97. package/assets/docs/tree/tokens-focus.doc.mjs +57 -0
  98. package/assets/docs/tree/tokens-font-weight.doc.mjs +58 -0
  99. package/assets/docs/tree/tokens-radius.doc.dense.mjs +10 -0
  100. package/assets/docs/tree/tokens-radius.doc.mjs +70 -0
  101. package/assets/docs/tree/tokens-radius.doc.zh.mjs +10 -0
  102. package/assets/docs/tree/tokens-shadow.doc.dense.mjs +10 -0
  103. package/assets/docs/tree/tokens-shadow.doc.mjs +74 -0
  104. package/assets/docs/tree/tokens-shadow.doc.zh.mjs +10 -0
  105. package/assets/docs/tree/tokens-size.doc.dense.mjs +10 -0
  106. package/assets/docs/tree/tokens-size.doc.mjs +54 -0
  107. package/assets/docs/tree/tokens-size.doc.zh.mjs +10 -0
  108. package/assets/docs/tree/tokens-spacing.doc.dense.mjs +10 -0
  109. package/assets/docs/tree/tokens-spacing.doc.mjs +102 -0
  110. package/assets/docs/tree/tokens-spacing.doc.zh.mjs +10 -0
  111. package/assets/docs/tree/tokens-syntax.doc.mjs +98 -0
  112. package/assets/docs/tree/tokens-text-size.doc.mjs +90 -0
  113. package/assets/docs/tree/tokens-type-scale.doc.mjs +210 -0
  114. package/assets/docs/tree/tokens-typography.doc.mjs +54 -0
  115. package/assets/docs/tree/tokens-usage.doc.dense.mjs +10 -0
  116. package/assets/docs/tree/tokens-usage.doc.mjs +36 -0
  117. package/assets/docs/tree/tokens-usage.doc.zh.mjs +10 -0
  118. package/assets/docs/tree/tokens.doc.mjs +28 -0
  119. package/assets/docs/tree/type-scale.doc.mjs +147 -0
  120. package/assets/docs/tree/typography-best-practices.doc.mjs +55 -0
  121. package/assets/docs/tree/typography.doc.mjs +29 -0
  122. package/assets/docs/use-a-theme.doc.mjs +162 -47
  123. package/assets/templates/pages/incident-console/page.tsx +1 -1
  124. package/assets/templates/pages/table-comparison/template.doc.mjs +1 -1
  125. package/assets/theme.template.ts +4 -3
  126. package/authoring/doctypes/template/type.ts +1 -0
  127. package/clients/cli/commands/blog.mjs +3 -3
  128. package/clients/cli/commands/build-theme.adaptations.test.mjs +1 -1
  129. package/clients/cli/commands/build-theme.ascii-output.test.mjs +11 -1
  130. package/clients/cli/commands/build-theme.batch-report.test.mjs +335 -0
  131. package/clients/cli/commands/build-theme.font-warning.test.mjs +36 -7
  132. package/clients/cli/commands/build-theme.import-path.test.mjs +3 -3
  133. package/clients/cli/commands/build-theme.mjs +68 -18
  134. package/clients/cli/commands/build-theme.watch.test.mjs +33 -0
  135. package/clients/cli/commands/build.mjs +1 -0
  136. package/clients/cli/commands/component/index.mjs +4 -1
  137. package/clients/cli/commands/component-replacement.text.test.mjs +45 -0
  138. package/clients/cli/commands/docs.doc.mjs +2 -1
  139. package/clients/cli/commands/docs.test.mjs +16 -13
  140. package/clients/cli/commands/doctor-integration-components.doc.mjs +1 -1
  141. package/clients/cli/commands/doctor.doc.mjs +1 -1
  142. package/clients/cli/commands/doctor.test.mjs +50 -1
  143. package/clients/cli/commands/import-hint-correctness.test.mjs +23 -0
  144. package/clients/cli/commands/layout-check.doc.mjs +1 -0
  145. package/clients/cli/commands/layout-expand.doc.mjs +1 -0
  146. package/clients/cli/commands/layout-grammar.doc.mjs +1 -0
  147. package/clients/cli/commands/layout.deprecation-lifecycle.test.mjs +140 -0
  148. package/clients/cli/commands/layout.doc.mjs +1 -0
  149. package/clients/cli/commands/layout.mjs +6 -11
  150. package/clients/cli/commands/search.test.mjs +6 -2
  151. package/clients/cli/commands/swizzle.routing.test.mjs +2 -1
  152. package/clients/cli/commands/template.mjs +4 -3
  153. package/clients/cli/commands/theme-add-lifecycle.test.mjs +9 -6
  154. package/clients/cli/commands/theme-build.doc.mjs +3 -1
  155. package/clients/cli/commands/upgrade.config-ordering.test.mjs +2 -1
  156. package/clients/cli/index.mjs +1 -1
  157. package/clients/cli/lib/component-format.mjs +13 -3
  158. package/clients/cli/lib/component-format.test.mjs +1 -1
  159. package/clients/cli/lib/define-command.mjs +4 -0
  160. package/foundation/agent-docs/agent-docs.mjs +18 -2
  161. package/foundation/agent-docs/agent-docs.test.mjs +18 -0
  162. package/foundation/config/project.test.mjs +1 -1
  163. package/foundation/discovery/docs-discovery.test.mjs +1 -1
  164. package/foundation/discovery/template-needs.d.mts +31 -0
  165. package/foundation/discovery/template-needs.mjs +156 -0
  166. package/foundation/discovery/template-needs.test.mjs +203 -0
  167. package/foundation/doc-compiler/bundle.mjs +52 -1
  168. package/foundation/doc-compiler/split-topic-keywords.test.mjs +73 -0
  169. package/foundation/doc-compiler/tree.d.mts +10 -0
  170. package/foundation/doc-compiler/tree.mjs +22 -0
  171. package/foundation/doc-compiler/tree.test.mjs +3 -2
  172. package/foundation/env/package-manager.d.mts +31 -8
  173. package/foundation/env/package-manager.mjs +120 -13
  174. package/foundation/env/package-manager.test.mjs +174 -1
  175. package/foundation/integrations/validate-contributions.d.mts +16 -0
  176. package/foundation/integrations/validate-contributions.mjs +56 -8
  177. package/foundation/response/response-types.doc.mjs +4 -4
  178. package/package.json +9 -9
  179. package/assets/docs/styling-libraries.doc.mjs +0 -469
  180. package/assets/docs/styling.doc.mjs +0 -412
  181. package/assets/docs/tokens.doc.dense.mjs +0 -15
  182. package/assets/docs/tokens.doc.mjs +0 -1491
  183. package/assets/docs/tokens.doc.zh.mjs +0 -15
  184. package/assets/docs/typography.doc.mjs +0 -286
@@ -63,8 +63,11 @@ import {
63
63
  } from '../../../api/theme/palette/generate/generate.mjs';
64
64
  import {
65
65
  importSpecifier,
66
+ printBatchTrailer,
67
+ printCompactTrailer,
66
68
  themeBuild,
67
69
  themeBuildFamily,
70
+ themeBuildForReport,
68
71
  } from '../../../api/theme/build/build.mjs';
69
72
  import {defineCommand} from '../lib/define-command.mjs';
70
73
  import {NO_RESULT_SET, resultSet} from '../../../foundation/debug/index.mjs';
@@ -105,13 +108,17 @@ function resolveCliBin() {
105
108
  * Resolves with the child's exit code; never rejects.
106
109
  *
107
110
  * @param {string} file - The theme file argument, as the user passed it.
108
- * @param {{out?: string, iconsSpecifier?: string}} options - Parsed command
109
- * options that affect generated output.
111
+ * @param {{out?: string, iconsSpecifier?: string, detail?: string}} options -
112
+ * Parsed command options that affect generated output, plus the detail
113
+ * level the user chose.
110
114
  * @returns {Promise<number>}
111
115
  */
112
116
  function runThemeBuildOnceChild(file, options) {
113
117
  const cliBin = resolveCliBin();
114
- const args = [cliBin, 'theme', 'build', file];
118
+ // A detail level the user chose applies to every rebuild.
119
+ const args = options.detail
120
+ ? [cliBin, '--detail', options.detail, 'theme', 'build', file]
121
+ : [cliBin, 'theme', 'build', file];
115
122
  if (options.out) args.push('--out', options.out);
116
123
  if (options.iconsSpecifier)
117
124
  args.push('--icons-specifier', options.iconsSpecifier);
@@ -135,7 +142,7 @@ function runThemeBuildOnceChild(file, options) {
135
142
  *
136
143
  * @param {Array<{file: string, filePath: string}>} entries - The theme file
137
144
  * arguments as the user passed them, with their resolved absolute paths.
138
- * @param {{out?: string, iconsSpecifier?: string}} options - Parsed command options.
145
+ * @param {{out?: string, iconsSpecifier?: string, detail?: string}} options - Parsed command options, plus the detail level the user chose.
139
146
  * @returns {Promise<void>} Resolves when the watcher is stopped (Ctrl-C).
140
147
  */
141
148
  async function runThemeBuildWatch(entries, options) {
@@ -361,7 +368,8 @@ function printThemeApp(result) {
361
368
  emit(
362
369
  text('Wire the generated module once in the app root:'),
363
370
  code(
364
- `import {themes, defaultThemeSlug} from './${stem}';\n\n` +
371
+ "import {Theme} from '@astryxdesign/core';\n" +
372
+ `import {themes, defaultThemeSlug} from './${stem}';\n\n` +
365
373
  '<Theme theme={themes[defaultThemeSlug]}>\n <App />\n</Theme>',
366
374
  ),
367
375
  );
@@ -533,6 +541,13 @@ export function registerTheme(program) {
533
541
  /** @type {{out?: string, watch?: boolean, check?: boolean, iconsSpecifier?: string, family?: boolean, familyKey?: string}} */ options,
534
542
  ) => {
535
543
  const json = program.opts().json || false;
544
+ // The report is one line per theme unless the user asks for
545
+ // `--detail full`, which prints the install example and the font
546
+ // guidance: once for one theme, as it always has, and once for the whole
547
+ // batch rather than per theme.
548
+ const detailChosen = program.getOptionValueSource('detail') !== 'default';
549
+ const detail = detailChosen ? program.opts().detail : undefined;
550
+ const compact = detail !== 'full';
536
551
  const entries = files.map(file => ({
537
552
  file,
538
553
  filePath: path.resolve(process.cwd(), file),
@@ -608,7 +623,7 @@ export function registerTheme(program) {
608
623
  code: ERROR_CODES.ERR_THEME_INVALID,
609
624
  });
610
625
  }
611
- await runThemeBuildWatch(entries, options);
626
+ await runThemeBuildWatch(entries, {...options, detail});
612
627
  return NO_RESULT_SET;
613
628
  }
614
629
 
@@ -645,20 +660,44 @@ export function registerTheme(program) {
645
660
  }
646
661
  }
647
662
 
663
+ // --json and --check keep their own output at every detail level.
664
+ const report = !json && !options.check && (entries.length > 1 || compact);
665
+ /** @type {import('../../../api/theme/build/build.mjs').ThemeBuildTrailer[]} */
666
+ const trailers = [];
667
+
648
668
  /** @type {Array<{file: string, receipt: import('../../../api/theme/theme.type.mjs').ThemeBuildResponse | import('../../../api/theme/theme.type.mjs').ThemeBuildCheckResponse | null}>} */
649
669
  const results = [];
650
670
  let stale = false;
651
671
  for (const entry of entries) {
652
672
  try {
653
- const result = await themeBuild(
654
- entry.file,
655
- {
656
- out: options.out,
657
- check: options.check,
658
- iconsSpecifier: options.iconsSpecifier,
659
- },
660
- {cwd: process.cwd()},
661
- );
673
+ const buildOptions = {
674
+ out: options.out,
675
+ check: options.check,
676
+ iconsSpecifier: options.iconsSpecifier,
677
+ };
678
+ let result;
679
+ if (report) {
680
+ const built = await themeBuildForReport(
681
+ entry.file,
682
+ buildOptions,
683
+ {cwd: process.cwd()},
684
+ {compact},
685
+ );
686
+ result = built.receipt;
687
+ if (built.trailer) trailers.push(built.trailer);
688
+ if (compact && result?.type === 'theme.build') {
689
+ const {outputs, sizeKB, tokenCount, componentCount} = result.data;
690
+ emit(
691
+ text(
692
+ `[ok] ${outputs.css} (${sizeKB} KB, ${tokenCount} token overrides, ${componentCount} component overrides)`,
693
+ ),
694
+ );
695
+ }
696
+ } else {
697
+ result = await themeBuild(entry.file, buildOptions, {
698
+ cwd: process.cwd(),
699
+ });
700
+ }
662
701
  results.push({file: entry.file, receipt: result ?? null});
663
702
  if (
664
703
  options.check &&
@@ -673,7 +712,10 @@ export function registerTheme(program) {
673
712
  /** @type {import('../../../api/error.mjs').AstryxError} */ (e);
674
713
  // Stop at the first failure, as a shell loop under `set -e` does.
675
714
  // With several themes in flight the message alone rarely says which
676
- // one broke, so name it.
715
+ // one broke, so name it. Themes already written keep their install
716
+ // and font guidance.
717
+ if (report && compact) printCompactTrailer(trailers);
718
+ else if (report) printBatchTrailer(trailers);
677
719
  return cliError(
678
720
  entries.length > 1 ? `${entry.file}: ${err.message}` : err.message,
679
721
  {suggestions: err.suggestions, code: err.code},
@@ -694,7 +736,14 @@ export function registerTheme(program) {
694
736
  };
695
737
  jsonOut(batch);
696
738
  }
697
- } else if (entries.length > 1) {
739
+ } else {
740
+ if (report && compact) {
741
+ printCompactTrailer(trailers, {hint: !detailChosen});
742
+ } else if (report) {
743
+ printBatchTrailer(trailers);
744
+ }
745
+ }
746
+ if (!json && entries.length > 1) {
698
747
  emit(
699
748
  text(
700
749
  options.check
@@ -823,7 +872,8 @@ export function registerTheme(program) {
823
872
  'Use it in your app (import path is relative to a file in src/ — adjust if yours lives elsewhere):',
824
873
  ),
825
874
  code(
826
- `import { ${exportName} } from '${entryModule}';\n\n` +
875
+ "import { Theme } from '@astryxdesign/core';\n" +
876
+ `import { ${exportName} } from '${entryModule}';\n\n` +
827
877
  `<Theme theme={${exportName}}>\n <App />\n</Theme>`,
828
878
  ),
829
879
  text(
@@ -157,6 +157,39 @@ describe('theme build --watch', () => {
157
157
  expect(stdout).toMatch(/Stopped watching/);
158
158
  }, 30_000);
159
159
 
160
+ it.each([
161
+ [[], false],
162
+ [['--detail', 'full'], true],
163
+ ])(
164
+ 'keeps the detail level for each build (%j)',
165
+ async (detail, full) => {
166
+ fs.writeFileSync(
167
+ path.join(tmpDir, 'wd.mjs'),
168
+ `export default { name: 'wd', tokens: { '--color-bg': '#ffffff' } };\n`,
169
+ );
170
+ const child = spawn(
171
+ process.execPath,
172
+ [CLI_BIN, ...detail, 'theme', 'build', 'wd.mjs', '--watch'],
173
+ {cwd: tmpDir, env: {...process.env, FORCE_COLOR: '0'}},
174
+ );
175
+ let stdout = '';
176
+ child.stdout.on('data', d => (stdout += d.toString()));
177
+ child.stderr.on('data', d => (stdout += d.toString()));
178
+ try {
179
+ expect(await waitFor(() => /Watching/i.test(stdout))).toBe(true);
180
+ } finally {
181
+ child.kill('SIGINT');
182
+ }
183
+ await new Promise(resolve => {
184
+ child.on('exit', resolve);
185
+ setTimeout(resolve, 4000);
186
+ });
187
+ expect(stdout.includes('Install in your app')).toBe(full);
188
+ expect(/\[ok\] wd\.css \(/.test(stdout)).toBe(!full);
189
+ },
190
+ 30_000,
191
+ );
192
+
160
193
  it('watches every file it was given and rebuilds only the one that changed', async () => {
161
194
  const first = path.join(tmpDir, 'w1.mjs');
162
195
  const second = path.join(tmpDir, 'w2.mjs');
@@ -226,6 +226,7 @@ export function registerBuild(program) {
226
226
  }
227
227
  : brief(['name', 'package', 'description', 'command']),
228
228
  ),
229
+ ...(start.notes ?? []).map(note => text(note)),
229
230
  );
230
231
  if (start.alternatives.length) {
231
232
  out.push(
@@ -292,7 +292,9 @@ export function registerComponent(program) {
292
292
  // --detail full — dense per-component docs (signature, props, theming,
293
293
  // examples). Verbatim doc block from the shared formatter. A Core slot
294
294
  // an integration component replaces prints that component, from the
295
- // list result (spec:AST-035 FR11).
295
+ // list result (spec:AST-035 FR11). Only the result's groups print, so
296
+ // `--category` text shows what its JSON shows and every printed slot
297
+ // is covered by the replacement map built from that result.
296
298
  /** @type {Map<string, any>} */
297
299
  const replacements = new Map();
298
300
  for (const items of Object.values(result.data.components)) {
@@ -312,6 +314,7 @@ export function registerComponent(program) {
312
314
  lang,
313
315
  themeData,
314
316
  replacements,
317
+ categories: Object.keys(result.data.components),
315
318
  }),
316
319
  ),
317
320
  );
@@ -218,6 +218,51 @@ describe('component list text', () => {
218
218
  expect(run.stdout).toContain('AcmeSideNav');
219
219
  },
220
220
  );
221
+
222
+ it('prints only the requested category at full detail', async () => {
223
+ const layout = await runCli(
224
+ ['component', '--list', '--category', 'Layout', '--detail', 'full'],
225
+ {cwd: tmpDir},
226
+ );
227
+ expect(layout.status, layout.stderr).toBe(0);
228
+ expect(layout.stdout.match(/^## .+$/gm)).toEqual(['## Layout']);
229
+ expect(layout.stdout).not.toContain('@astryxdesign/core/SideNav');
230
+ expect(layout.stdout).not.toContain('AcmeSideNav');
231
+
232
+ const navigation = await runCli(
233
+ ['component', '--list', '--category', 'Navigation', '--detail', 'full'],
234
+ {cwd: tmpDir},
235
+ );
236
+ expect(navigation.status, navigation.stderr).toBe(0);
237
+ expect(navigation.stdout.match(/^## .+$/gm)).toEqual(['## Navigation']);
238
+ expect(navigation.stdout).toMatch(
239
+ /^AcmeSideNav {2}<- from '@acme\/nav\/components\/AcmeSideNav' {2}\[@acme\/nav\]$/m,
240
+ );
241
+ expect(navigation.stdout).not.toMatch(/^SideNav[( ]/m);
242
+ });
243
+
244
+ it.each(['brief', 'compact'])(
245
+ 'prints only the requested category at %s detail',
246
+ async detail => {
247
+ const layout = await runCli(
248
+ ['component', '--category', 'Layout', '--detail', detail],
249
+ {cwd: tmpDir},
250
+ );
251
+ expect(layout.status, layout.stderr).toBe(0);
252
+ expect(layout.stdout).not.toContain('@astryxdesign/core/SideNav');
253
+ expect(layout.stdout).not.toContain('AcmeSideNav');
254
+
255
+ const navigation = await runCli(
256
+ ['component', '--category', 'Navigation', '--detail', detail],
257
+ {cwd: tmpDir},
258
+ );
259
+ expect(navigation.status, navigation.stderr).toBe(0);
260
+ expect(navigation.stdout).toContain(
261
+ '@acme/nav/components/AcmeSideNav [@acme/nav]',
262
+ );
263
+ expect(navigation.stdout).not.toMatch(/^name: +SideNav$/m);
264
+ },
265
+ );
221
266
  });
222
267
 
223
268
  describe('help documents the replacement', () => {
@@ -22,7 +22,8 @@ export const doc = {
22
22
  'does, and `--index` its section index. A route ' +
23
23
  'opens a node of the docs tree: `cli` lists its guides and reference, ' +
24
24
  '`cli/api/functions` lists every API function, and `cli/api/functions/search` prints ' +
25
- 'one. `--depth` reads as far down the tree as you ask, from the doc alone (0) to ' +
25
+ 'one. A namespace plus a section prints that section from the one guide below it ' +
26
+ 'that has it (`astryx docs layout side-panels`). `--depth` reads as far down the tree as you ask, from the doc alone (0) to ' +
26
27
  'everything below it (all), and with it `--detail` sets how much of each doc below ' +
27
28
  'shows: one line (brief, the default), its sections (compact), or all of it (full).',
28
29
  fn: 'docs',
@@ -98,8 +98,7 @@ describe('migration docs', () => {
98
98
 
99
99
  const output = console.log.mock.calls.map(c => c[0]).join('\n');
100
100
  expect(output).toContain('Migration Guide');
101
- expect(output).toContain('Recommended Order');
102
- expect(output).toContain('Map shadcn and Radix Primitives');
101
+ expect(output).toContain('migration');
103
102
  });
104
103
  });
105
104
 
@@ -113,7 +112,8 @@ describe('progressive reads', () => {
113
112
  expect(status).toBe(0);
114
113
  expect(stdout).toMatch(/^principles +\S/m);
115
114
  expect(widest(stdout)).toBeLessThanOrEqual(120);
116
- expect(stdout).toContain('Usage: pnpm exec astryx docs <topic>');
115
+ // The repo root has no `astryx` bin, so the CLI names the scoped package.
116
+ expect(stdout).toMatch(/Usage: \S+(?: dlx)? (?:astryx|@astryxdesign\/cli) docs <topic>/);
117
117
  }, SLOW);
118
118
 
119
119
  it("prints a topic's section index with the keys to read by", async () => {
@@ -198,7 +198,7 @@ describe('blocks as text', () => {
198
198
  it('prints the labels of a real section above their fences', async () => {
199
199
  const {status, stdout} = await runCli(['docs', 'theme', 'quick-start']);
200
200
  expect(status).toBe(0);
201
- expect(stdout).toContain('Basic theme setup:\n```tsx\nimport {Theme}');
201
+ expect(stdout).toContain('Wire the generated module once:\n```tsx\nimport {Theme}');
202
202
  }, SLOW);
203
203
  });
204
204
 
@@ -329,22 +329,25 @@ describe('the docs tree, one level at a time', () => {
329
329
  expect(old.stderr).toContain('Unknown topic "cli-integrations"');
330
330
  }, SLOW);
331
331
 
332
- it('returns docs.node as JSON, and fails a section of a namespace', async () => {
332
+ it('returns docs.node as JSON, and reads a section of a namespace from its guide', async () => {
333
333
  const node = JSON.parse((await runCli(['docs', 'cli', '--json'])).stdout);
334
334
  expect(node).toMatchObject({
335
335
  type: 'docs.node',
336
336
  data: {route: 'cli', kind: 'namespace', breadcrumb: []},
337
337
  });
338
338
  expect(node.data.slots.map(slot => slot.name)).toEqual(['guides', 'reference']);
339
- const section = await runCli(['docs', 'cli', 'commands', '--json']);
340
- expect(section.status).toBe(1);
341
- const error = JSON.parse(section.stdout);
342
- expect(error).toMatchObject({code: 'ERR_UNKNOWN_SECTION'});
343
- // It names the namespace's children, in the order its slots list them.
344
- expect(error.suggestions.map(s => s.name)).toEqual(
345
- node.data.slots.flatMap(slot => slot.children.map(child => child.route)),
339
+ const section = JSON.parse(
340
+ (await runCli(['docs', 'layout', 'side-panels', '--json'])).stdout,
346
341
  );
347
- expect(error.suggestions.map(s => s.name)).toContain('cli/commands');
342
+ expect(section).toMatchObject({
343
+ type: 'docs.detail.section',
344
+ data: {id: 'side-panels', title: 'Side panels'},
345
+ });
346
+ const missing = await runCli(['docs', 'cli', 'zzzz-nope', '--json']);
347
+ expect(missing.status).toBe(1);
348
+ const error = JSON.parse(missing.stdout);
349
+ expect(error).toMatchObject({code: 'ERR_UNKNOWN_SECTION'});
350
+ expect(error.suggestions.map(s => s.name)).toContain('cli/integrations/quick-start');
348
351
  }, SLOW);
349
352
  });
350
353
 
@@ -17,7 +17,7 @@ export const doc = {
17
17
  'range that turns replacement on, a missing Core target, an invalid value, a ' +
18
18
  'component named after a different Core component, or two replacements for one ' +
19
19
  'Core component is an error. In a package without that range they are warnings, ' +
20
- 'with one more warning naming the range to declare.',
20
+ 'with a warning for each such component, naming the range to declare.',
21
21
  fn: 'integrationComponentConflicts',
22
22
  args: [
23
23
  {
@@ -16,7 +16,7 @@ export const doc = {
16
16
  summary: 'Diagnose Astryx projects and integration packages',
17
17
  description:
18
18
  'Runs read-only project health diagnostics by default: Node version, @astryxdesign/core ' +
19
- 'install and version alignment, generated app themes when present, earlier copied-theme migration, config, integrations (linked without a config entry, ' +
19
+ 'install and version alignment, theme packages, generated app themes when present, earlier copied-theme migration, config, integrations (linked without a config entry, ' +
20
20
  'provider identity, contribution issues), agent docs, core peer dependencies, package manager, ' +
21
21
  "and the docs the CLI reads. It writes nothing, but loading astryx.config runs that file's code. " +
22
22
  'The `integration` subcommands provide authoring checks for one integration package.',
@@ -168,7 +168,23 @@ describe('doctor — individual checks', () => {
168
168
  it('agent-docs: INFO when no docs present', () => {
169
169
  const res = checkAgentDocs({cwd: tmpDir});
170
170
  expect(res.status).toBe('info');
171
- expect(res.fix).toContain('astryx init');
171
+ expect(res.fix).toContain('init --features agents');
172
+ });
173
+
174
+ // The npm package named `astryx` is not this CLI: a project without the
175
+ // `astryx` bin gets the scoped package in the fix, one with it keeps the bin.
176
+ it('agent-docs: the fix names the scoped package when the project has no local CLI', () => {
177
+ fs.writeFileSync(path.join(tmpDir, 'package-lock.json'), '{}');
178
+ const res = checkAgentDocs({cwd: tmpDir});
179
+ expect(res.fix).toContain('`npx @astryxdesign/cli init --features agents`');
180
+ });
181
+
182
+ it('agent-docs: the fix keeps `npx astryx` when the project has a local CLI', () => {
183
+ fs.writeFileSync(path.join(tmpDir, 'package-lock.json'), '{}');
184
+ fs.mkdirSync(path.join(tmpDir, 'node_modules', '.bin'), {recursive: true});
185
+ fs.writeFileSync(path.join(tmpDir, 'node_modules', '.bin', 'astryx'), '');
186
+ const res = checkAgentDocs({cwd: tmpDir});
187
+ expect(res.fix).toContain('`npx astryx init --features agents`');
172
188
  });
173
189
 
174
190
  it('agent-docs: WARN when docs exist without XDS markers', () => {
@@ -186,6 +202,39 @@ describe('doctor — individual checks', () => {
186
202
  expect(res.status).toBe('pass');
187
203
  });
188
204
 
205
+ it('agent-docs: PASS from a subfolder, reading the project root', () => {
206
+ fs.writeFileSync(path.join(tmpDir, 'package.json'), '{"name":"app"}');
207
+ fs.writeFileSync(
208
+ path.join(tmpDir, 'AGENTS.md'),
209
+ '<!-- ASTRYX:START -->\nstuff\n<!-- ASTRYX:END -->\n',
210
+ );
211
+ const src = path.join(tmpDir, 'src');
212
+ fs.mkdirSync(src);
213
+ const res = checkAgentDocs({cwd: src});
214
+ expect(res.status).toBe('pass');
215
+ expect(res.message).toBe(
216
+ `Astryx agent docs section present in ${path.join('..', 'AGENTS.md')}.`,
217
+ );
218
+ });
219
+
220
+ it('agent-docs: reads every file init can write, Hermes included', () => {
221
+ fs.writeFileSync(
222
+ path.join(tmpDir, 'HERMES.md'),
223
+ '<!-- ASTRYX:START -->\nstuff\n<!-- ASTRYX:END -->\n',
224
+ );
225
+ expect(checkAgentDocs({cwd: tmpDir})).toMatchObject({
226
+ status: 'pass',
227
+ message: 'Astryx agent docs section present in HERMES.md.',
228
+ });
229
+ });
230
+
231
+ it('agent-docs: INFO names what it looked for and where', () => {
232
+ const res = checkAgentDocs({cwd: tmpDir});
233
+ expect(res.status).toBe('info');
234
+ expect(res.message).toContain('AGENTS.md, CLAUDE.md');
235
+ expect(res.message).toContain('HERMES.md');
236
+ });
237
+
189
238
  it('peer-deps: INFO when core not installed', () => {
190
239
  const res = checkPeerDeps({cwd: tmpDir, coreDir: null});
191
240
  expect(res.status).toBe('info');
@@ -248,4 +248,27 @@ describe('import hint correctness', () => {
248
248
  });
249
249
  }
250
250
  });
251
+
252
+ describe('CLI --detail brief text output for a single component', () => {
253
+ it('brief text output names the component and its package', async () => {
254
+ const result = await runCli(['component', 'Button', '--detail', 'brief'], REPO_ROOT);
255
+ expect(result.code).toBe(0);
256
+ expect(result.stdout).toContain('Button');
257
+ expect(result.stdout).toContain('@astryxdesign/core');
258
+ });
259
+
260
+ it('brief text is shorter than compact text', async () => {
261
+ const brief = await runCli(['component', 'Button', '--detail', 'brief'], REPO_ROOT);
262
+ const compact = await runCli(['component', 'Button', '--detail', 'compact'], REPO_ROOT);
263
+ expect(brief.code).toBe(0);
264
+ expect(compact.code).toBe(0);
265
+ expect(brief.stdout.length).toBeLessThan(compact.stdout.length);
266
+ });
267
+
268
+ it('brief text shows the import path in the signature line', async () => {
269
+ const result = await runCli(['component', 'Button', '--detail', 'brief'], REPO_ROOT);
270
+ expect(result.code).toBe(0);
271
+ expect(result.stdout).toContain('@astryxdesign/core/Button');
272
+ });
273
+ });
251
274
  });
@@ -62,5 +62,6 @@ export const doc = {
62
62
  },
63
63
  ],
64
64
  deprecated: 'DEP-0006: Use `astryx build` to start from a template, `astryx template` to scaffold, and `astryx docs layout` for guidance.',
65
+ notes: [{"type": "prose", "text": "**Deprecated (DEP-0006).** Use `astryx build` to choose the template to start from, `astryx template` to scaffold it, and `astryx docs layout` for layout guidance. This command will be removed in a future minor release."}],
65
66
  related: ['layout expand', 'layout grammar'],
66
67
  };
@@ -82,5 +82,6 @@ export const doc = {
82
82
  },
83
83
  ],
84
84
  deprecated: 'DEP-0006: Use `astryx build` to start from a template, `astryx template` to scaffold, and `astryx docs layout` for guidance.',
85
+ notes: [{"type": "prose", "text": "**Deprecated (DEP-0006).** Use `astryx build` to choose the template to start from, `astryx template` to scaffold it, and `astryx docs layout` for layout guidance. This command will be removed in a future minor release."}],
85
86
  related: ['layout check', 'layout grammar'],
86
87
  };
@@ -27,5 +27,6 @@ export const doc = {
27
27
  {code: 1, when: 'the component registry cannot be read'},
28
28
  ],
29
29
  deprecated: 'DEP-0006: Use `astryx build` to start from a template, `astryx template` to scaffold, and `astryx docs layout` for guidance.',
30
+ notes: [{"type": "prose", "text": "**Deprecated (DEP-0006).** Use `astryx build` to choose the template to start from, `astryx template` to scaffold it, and `astryx docs layout` for layout guidance. This command will be removed in a future minor release."}],
30
31
  related: ['layout expand', 'layout check'],
31
32
  };
@@ -0,0 +1,140 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file Deprecation lifecycle coverage for the layout command group (DEP-0006).
5
+ *
6
+ * Mirrors the DEP-0005 theme-add-lifecycle tests: pins the JSON
7
+ * `meta.deprecations` entry, the human-mode stderr warning, the help label,
8
+ * and the docs reference pages.
9
+ */
10
+
11
+ import {describe, it, expect} from 'vitest';
12
+ import {runCli} from '../../../test-utils/run-cli.mjs';
13
+
14
+ const SLOW = 30_000;
15
+
16
+ describe('layout DEP-0006 lifecycle', () => {
17
+ it('JSON mode carries meta.deprecations with DEP-0006 and its replacements', async () => {
18
+ const result = await runCli(['layout', 'grammar', '--json']);
19
+ expect(result.status).toBe(0);
20
+ const envelope = JSON.parse(result.stdout);
21
+ expect(envelope.meta).toBeDefined();
22
+ expect(envelope.meta.deprecations).toEqual([
23
+ {
24
+ id: 'DEP-0006',
25
+ replacements: ['build', 'template', 'docs layout'],
26
+ },
27
+ ]);
28
+ // Canonical data is unchanged
29
+ expect(envelope.type).toBe('layout.grammar');
30
+ expect(envelope.data.text).toBeDefined();
31
+ expect(envelope.data.aliases).toBeDefined();
32
+ }, SLOW);
33
+
34
+ it('human mode emits one stderr deprecation warning', async () => {
35
+ const result = await runCli(['layout', 'grammar']);
36
+ expect(result.status).toBe(0);
37
+ expect(result.stderr).toContain('[DEP-0006]');
38
+ expect(result.stderr).toContain('astryx layout is deprecated');
39
+ expect(result.stderr).toContain('astryx build');
40
+ expect(result.stderr).toContain('astryx template');
41
+ expect(result.stderr).toContain('astryx docs layout');
42
+ }, SLOW);
43
+
44
+ it('JSON mode does NOT emit the stderr warning', async () => {
45
+ const result = await runCli(['layout', 'grammar', '--json']);
46
+ expect(result.stderr).not.toContain('[DEP-0006]');
47
+ }, SLOW);
48
+
49
+ it('layout --help labels the command as deprecated', async () => {
50
+ const result = await runCli(['layout', '--help']);
51
+ expect(result.stdout).toContain('DEPRECATED');
52
+ expect(result.stdout).toContain('DEP-0006');
53
+ });
54
+
55
+ it('layout expand --json carries the same meta.deprecations', async () => {
56
+ const result = await runCli([
57
+ 'layout', 'expand', 'V[g6] > C*2', '--json',
58
+ ]);
59
+ expect(result.status).toBe(0);
60
+ const envelope = JSON.parse(result.stdout);
61
+ expect(envelope.meta.deprecations).toEqual([
62
+ {
63
+ id: 'DEP-0006',
64
+ replacements: ['build', 'template', 'docs layout'],
65
+ },
66
+ ]);
67
+ expect(envelope.type).toBe('layout.expand');
68
+ }, SLOW);
69
+
70
+ it('layout check --json carries the same meta.deprecations', async () => {
71
+ const result = await runCli([
72
+ 'layout', 'check', 'V[g6] > C*2', '--json',
73
+ ]);
74
+ expect(result.status).toBe(0);
75
+ const envelope = JSON.parse(result.stdout);
76
+ expect(envelope.meta.deprecations).toEqual([
77
+ {
78
+ id: 'DEP-0006',
79
+ replacements: ['build', 'template', 'docs layout'],
80
+ },
81
+ ]);
82
+ expect(envelope.type).toBe('layout.check');
83
+ }, SLOW);
84
+
85
+ // FR29d: every reference page names DEP-0006 and the replacements.
86
+ // Removing the label from any single page must fail this test.
87
+ describe('docs reference pages name DEP-0006', () => {
88
+ const COMMAND_PAGES = [
89
+ 'cli/commands/layout',
90
+ 'cli/commands/layout-expand',
91
+ 'cli/commands/layout-check',
92
+ 'cli/commands/layout-grammar',
93
+ ];
94
+
95
+ const FUNCTION_PAGES = [
96
+ 'cli/api/functions/layout-expand',
97
+ 'cli/api/functions/layout-check',
98
+ 'cli/api/functions/layout-grammar',
99
+ ];
100
+
101
+ for (const page of COMMAND_PAGES) {
102
+ it(`${page} names DEP-0006 and replacements`, async () => {
103
+ const result = await runCli(['docs', page, '--json']);
104
+ expect(result.status, result.stderr).toBe(0);
105
+ const body = result.stdout;
106
+ expect(body).toContain('DEP-0006');
107
+ expect(body).toContain('build');
108
+ expect(body).toContain('template');
109
+ expect(body).toContain('docs layout');
110
+ }, SLOW);
111
+ }
112
+
113
+ for (const page of FUNCTION_PAGES) {
114
+ it(`${page} names DEP-0006 and replacements`, async () => {
115
+ const result = await runCli(['docs', page, '--json']);
116
+ expect(result.status, result.stderr).toBe(0);
117
+ const body = result.stdout;
118
+ expect(body).toContain('DEP-0006');
119
+ expect(body).toContain('build');
120
+ expect(body).toContain('template');
121
+ expect(body).toContain('docs layout');
122
+ }, SLOW);
123
+ }
124
+ });
125
+
126
+ it('response-types reference names DEP-0006 in each layout entry description', async () => {
127
+ const result = await runCli(['docs', 'cli/api/enums/response-types', '--json']);
128
+ expect(result.status, result.stderr).toBe(0);
129
+ const envelope = JSON.parse(result.stdout);
130
+ // The enum page has a table in its content; each row is [value, description].
131
+ const tables = envelope.data.content.filter(b => b.type === 'table');
132
+ const rows = tables.flatMap(t => t.rows || []);
133
+ for (const type of ['layout.expand', 'layout.check', 'layout.grammar']) {
134
+ const row = rows.find(r => r[0] && r[0].includes(type));
135
+ expect(row, `${type} not found in response-types table`).toBeDefined();
136
+ expect(row[1], `${type} description missing DEP-0006`).toContain('DEP-0006');
137
+ expect(row[1], `${type} description missing replacements`).toContain('replacement');
138
+ }
139
+ }, SLOW);
140
+ });
@@ -31,5 +31,6 @@ export const doc = {
31
31
  {code: 1, when: 'no subcommand (help is printed) or an unknown subcommand'},
32
32
  ],
33
33
  deprecated: 'DEP-0006: Use `astryx build` to start from a template, `astryx template` to scaffold, and `astryx docs layout` for guidance.',
34
+ notes: [{"type": "prose", "text": "**Deprecated (DEP-0006).** Use `astryx build` to choose the template to start from, `astryx template` to scaffold it, and `astryx docs layout` for layout guidance. This command will be removed in a future minor release."}],
34
35
  related: ['template', 'build'],
35
36
  };