@astryxdesign/cli 0.6.5-canary.eb58bba → 0.6.5-canary.f261d2f

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 (41) hide show
  1. package/README.md +11 -12
  2. package/api/error.d.mts +0 -22
  3. package/api/error.mjs +0 -42
  4. package/api/integration/authoring-checks.mjs +7 -10
  5. package/api/integration/authoring-checks.type.d.mts +0 -8
  6. package/api/integration/authoring-checks.type.mjs +3 -7
  7. package/api/integration/integrationComponentConflicts.doc.mjs +1 -1
  8. package/api/integration/integrationDocConflicts.doc.mjs +1 -1
  9. package/api/integration/integrationTemplateConflicts.doc.mjs +1 -1
  10. package/api/integration/validate-integration.d.mts +2 -4
  11. package/api/integration/validate-integration.mjs +2 -7
  12. package/api/integration/validate-integration.test.mjs +0 -55
  13. package/api/integration/validate-integration.type.d.mts +0 -5
  14. package/api/integration/validate-integration.type.mjs +1 -5
  15. package/api/integration/validateIntegration.doc.mjs +1 -1
  16. package/api/swizzle/copy/copy.mjs +3 -66
  17. package/api/swizzle/swizzle.doc.mjs +0 -4
  18. package/api/template/copy/copy.mjs +5 -9
  19. package/api/template/show/show.mjs +4 -15
  20. package/api/template/template.doc.mjs +1 -5
  21. package/api/template/template.type.d.mts +0 -1
  22. package/api/template/template.type.mjs +0 -1
  23. package/api/upgrade/run/run.mjs +3 -20
  24. package/api/upgrade/run/run.test.mjs +1 -45
  25. package/api/upgrade/upgrade.doc.mjs +1 -1
  26. package/api/upgrade/upgrade.type.d.mts +0 -1
  27. package/api/upgrade/upgrade.type.mjs +0 -1
  28. package/clients/cli/commands/doctor.mjs +4 -4
  29. package/clients/cli/commands/template.mjs +2 -11
  30. package/clients/cli/commands/upgrade.ascii-output.test.mjs +0 -14
  31. package/clients/cli/lib/manifest.mjs +165 -44
  32. package/clients/cli/lib/manifest.test.mjs +7 -98
  33. package/foundation/discovery/template-adapter.d.mts +0 -13
  34. package/foundation/discovery/template-adapter.fixture-refs.test.mjs +1 -37
  35. package/foundation/discovery/template-adapter.mjs +1 -16
  36. package/foundation/response/response-types.doc.d.mts +5 -5
  37. package/foundation/response/response-types.doc.mjs +11 -11
  38. package/package.json +9 -9
  39. package/api/template/show/show.test.mjs +0 -76
  40. package/clients/cli/commands/template.show-media.test.mjs +0 -62
  41. package/clients/cli/commands/write-failure.test.mjs +0 -175
@@ -1,8 +1,8 @@
1
1
  // Copyright (c) Meta Platforms, Inc. and affiliates.
2
2
 
3
3
  /**
4
- * @file `template.show` leaf — return a resolved template's source, exactly as
5
- * `template.copy` writes it, plus the components it composes.
4
+ * @file `template.show` leaf — return a resolved template's raw source plus the
5
+ * components it composes.
6
6
  *
7
7
  * @position api/template/show — reads the resolved match's source file; the
8
8
  * template dispatcher routes `show` (and the no-target-path default) here.
@@ -11,10 +11,7 @@
11
11
  import * as fs from 'node:fs';
12
12
  import {AstryxError} from '../../error.mjs';
13
13
  import {ERROR_CODES} from '../../../foundation/response/error-codes.mjs';
14
- import {
15
- extractComponents,
16
- replaceDemoMedia,
17
- } from '../../../foundation/discovery/template-adapter.mjs';
14
+ import {extractComponents} from '../../../foundation/discovery/template-adapter.mjs';
18
15
 
19
16
  /**
20
17
  * Build the `template.show` envelope for an already-resolved template.
@@ -30,13 +27,6 @@ export function templateShow(match) {
30
27
  );
31
28
  }
32
29
 
33
- // The source template.copy writes (spec:AST-028 FR7): a template printed and
34
- // pasted must not keep a media path only Astryx's previews serve, and the
35
- // caller is told how many it replaced, the way the copy receipt tells it.
36
- const {source, demoMediaReplaced} = replaceDemoMedia(
37
- fs.readFileSync(match.filePath, 'utf-8'),
38
- );
39
-
40
30
  return {
41
31
  type: 'template.show',
42
32
  data: {
@@ -44,8 +34,7 @@ export function templateShow(match) {
44
34
  description: match.description,
45
35
  type: match.type,
46
36
  components: extractComponents(match.filePath),
47
- source,
48
- demoMediaReplaced,
37
+ source: fs.readFileSync(match.filePath, 'utf-8'),
49
38
  },
50
39
  };
51
40
  }
@@ -114,7 +114,7 @@ export const doc = {
114
114
  {
115
115
  type: 'template.show',
116
116
  description:
117
- "The resolved template's source, exactly as a copy writes it, plus its description, kind, the component names it composes, and `demoMediaReplaced` — how many Astryx demo media references (images, posters, videos) in the source were replaced with placeholders for you to swap for your own media.",
117
+ "The resolved template's raw source plus its description, kind, and the component names it composes.",
118
118
  },
119
119
  {
120
120
  type: 'template.skeleton',
@@ -153,10 +153,6 @@ export const doc = {
153
153
  code: 'ERR_FILE_EXISTS',
154
154
  when: 'the copy target already exists and overwrite is not set',
155
155
  },
156
- {
157
- code: 'ERR_WRITE_FAILED',
158
- when: 'the copy target could not be written (no permission, read-only mount, full disk); nothing is written',
159
- },
160
156
  ],
161
157
  examples: [
162
158
  {label: 'List templates', code: 'const {data} = await template();'},
@@ -67,7 +67,6 @@ export type TemplateShowResponse = {
67
67
  type: "page" | "block";
68
68
  components: string[];
69
69
  source: string;
70
- demoMediaReplaced: number;
71
70
  };
72
71
  };
73
72
  /**
@@ -53,7 +53,6 @@
53
53
  * @property {'page' | 'block'} data.type
54
54
  * @property {string[]} data.components
55
55
  * @property {string} data.source
56
- * @property {number} data.demoMediaReplaced Astryx demo media references (images, posters, videos) replaced in the returned source: images with a neutral placeholder, videos with an empty source. Swap in your own media at those points; no media is installed. 0 when the template carried none.
57
56
  */
58
57
 
59
58
  /**
@@ -137,12 +137,6 @@ export async function run(options = {}, {cwd = process.cwd()} = {}) {
137
137
  }
138
138
  const apply = options.apply ?? false;
139
139
 
140
- // One fact about the resolved source directory, captured before anything
141
- // runs. `--path` defaults to `./src`, so a project laid out as `app/` (or a
142
- // typo) skips every code codemod; without this the receipt is byte-identical
143
- // to a clean, fully migrated project.
144
- const sourcePathFound = fs.existsSync(path_);
145
-
146
140
  const currentVersion = /** @type {string} */ (options.from);
147
141
  const installed = detectInstalledTargetVersion(cwd);
148
142
  if (!installed) {
@@ -288,7 +282,6 @@ export async function run(options = {}, {cwd = process.cwd()} = {}) {
288
282
  refreshed: false,
289
283
  action: 'none',
290
284
  },
291
- sourcePathFound,
292
285
  filesChanged: coreResult?.totalFilesChanged ?? 0,
293
286
  transformsApplied: coreResult?.totalTransformsApplied ?? 0,
294
287
  modifiedFiles: uniqueFiles(coreResult?.changedFiles).map(file =>
@@ -414,12 +407,6 @@ export async function run(options = {}, {cwd = process.cwd()} = {}) {
414
407
  refreshed: false,
415
408
  action: 'none',
416
409
  }),
417
- // A missing source directory is the one way this command can migrate
418
- // nothing and still look complete: every codemod is skipped, filesChanged
419
- // stays 0, and errors stays empty. The receipt carries the fact so a
420
- // machine consumer can tell "nothing needed changing" from "nothing was
421
- // ever read" — the human text says so via the runner's own error line.
422
- sourcePathFound,
423
410
  };
424
411
 
425
412
  let integrationResult = null;
@@ -655,16 +642,12 @@ export async function run(options = {}, {cwd = process.cwd()} = {}) {
655
642
  }
656
643
 
657
644
  const registryOk = receipt.registryCompositions?.ok ?? true;
658
- const done = apply ? 'Upgrade complete' : 'Dry run complete';
659
645
  logger.log(
660
646
  protectedFiles.length > 0
661
647
  ? 'Upgrade incomplete: protected changes remain\n'
662
- : !registryOk
663
- ? 'Upgrade finished with unresolved registry items\n'
664
- : sourcePathFound
665
- ? done + '\n'
666
- : `${done}, but ${path.relative(cwd, path_) || '.'} does not exist, so no source files were scanned. ` +
667
- `Pass --path <your source directory> if your code does not live in ./src.\n`,
648
+ : registryOk
649
+ ? (apply ? 'Upgrade complete' : 'Dry run complete') + '\n'
650
+ : 'Upgrade finished with unresolved registry items\n',
668
651
  );
669
652
  return {
670
653
  type: 'upgrade.run',
@@ -3,8 +3,7 @@
3
3
  /**
4
4
  * @file Colocated tests for the upgrade.run leaf — the --path scan dir must be
5
5
  * confined to cwd (upgrade rewrites source in place with --apply, so an escaping
6
- * or out-of-tree path must be rejected), and the receipt must say whether that
7
- * dir existed at all.
6
+ * or out-of-tree path must be rejected).
8
7
  */
9
8
 
10
9
  import {describe, it, expect, beforeEach, afterEach} from 'vitest';
@@ -52,46 +51,3 @@ describe('upgrade.run — --path confinement', () => {
52
51
  ).rejects.toMatchObject({code: 'ERR_PATH_TRAVERSAL'});
53
52
  }, SLOW);
54
53
  });
55
-
56
- describe('upgrade.run — sourcePathFound', () => {
57
- let dir;
58
- beforeEach(() => {
59
- dir = fs.mkdtempSync(path.join(os.tmpdir(), 'upg-srcpath-'));
60
- seedProject(dir);
61
- });
62
- afterEach(() => fs.rmSync(dir, {recursive: true, force: true}));
63
-
64
- // The receipt for a project whose source lives somewhere other than ./src was
65
- // byte-identical to a fully migrated one: exit 0, filesChanged 0, errors [].
66
- // The only signal was a human log line --json suppresses by design.
67
- it('reports false when the resolved source directory is missing, and still counts nothing', async () => {
68
- fs.rmSync(path.join(dir, 'src'), {recursive: true, force: true});
69
- fs.mkdirSync(path.join(dir, 'app'), {recursive: true});
70
- fs.writeFileSync(path.join(dir, 'app', 'index.ts'), 'const x = 1;\n');
71
-
72
- const res = await upgrade({from: '0.0.1', apply: true}, {cwd: dir});
73
-
74
- expect(res.type).toBe('upgrade.run');
75
- expect(res.data.sourcePathFound).toBe(false);
76
- expect(res.data.filesChanged).toBe(0);
77
- expect(res.data.errors).toEqual([]);
78
- }, SLOW);
79
-
80
- it('reports true for a source directory that exists', async () => {
81
- const res = await upgrade({from: '0.0.1', apply: true}, {cwd: dir});
82
-
83
- expect(res.type).toBe('upgrade.run');
84
- expect(res.data.sourcePathFound).toBe(true);
85
- }, SLOW);
86
-
87
- it('follows --path, so the right directory under another name reports true', async () => {
88
- fs.rmSync(path.join(dir, 'src'), {recursive: true, force: true});
89
- fs.mkdirSync(path.join(dir, 'app'), {recursive: true});
90
- fs.writeFileSync(path.join(dir, 'app', 'index.ts'), 'const x = 1;\n');
91
-
92
- const res = await upgrade({from: '0.0.1', path: 'app'}, {cwd: dir});
93
-
94
- expect(res.type).toBe('upgrade.run');
95
- expect(res.data.sourcePathFound).toBe(true);
96
- }, SLOW);
97
- });
@@ -123,7 +123,7 @@ export const doc = {
123
123
  {
124
124
  type: 'upgrade.run',
125
125
  description:
126
- 'The terminal run receipt: from, to, codemods (count), integrations, agentDocs, agentDocsRefreshed, registryCompositions (when receipts are found), sourcePathFound (false when the resolved `path` does not exist, so nothing was scanned), filesChanged, transformsApplied, modifiedFiles, protectedFiles, declinedCandidates, errors, and complete. When a protected file still requires a change, complete is false and errorCode is ERR_CODEMOD_PROTECTED; the CLI exits nonzero while preserving the structured receipt.',
126
+ 'The terminal run receipt: from, to, codemods (count), integrations, agentDocs, agentDocsRefreshed, registryCompositions (when receipts are found), filesChanged, transformsApplied, modifiedFiles, protectedFiles, declinedCandidates, errors, and complete. When a protected file still requires a change, complete is false and errorCode is ERR_CODEMOD_PROTECTED; the CLI exits nonzero while preserving the structured receipt.',
127
127
  },
128
128
  ],
129
129
  throws: [
@@ -168,7 +168,6 @@ export type UpgradeRunResponse = {
168
168
  integrations: string[];
169
169
  agentDocsRefreshed: boolean;
170
170
  agentDocs: AgentDocsSummary;
171
- sourcePathFound: boolean;
172
171
  registryCompositions?: RegistryCompositionSummary | undefined;
173
172
  complete?: boolean | undefined;
174
173
  errorCode?: "ERR_CODEMOD_PROTECTED" | undefined;
@@ -116,7 +116,6 @@
116
116
  * @property {string[]} data.integrations Integration packages processed in this upgrade (by name/spec).
117
117
  * @property {boolean} data.agentDocsRefreshed
118
118
  * @property {AgentDocsSummary} data.agentDocs
119
- * @property {boolean} data.sourcePathFound Whether the resolved source directory (`path`, default `./src`) exists. False means no source file was read, so a zero `filesChanged` says nothing about the project being migrated.
120
119
  * @property {RegistryCompositionSummary} [data.registryCompositions]
121
120
  * @property {boolean} [data.complete] False when protected required changes remain.
122
121
  * @property {'ERR_CODEMOD_PROTECTED'} [data.errorCode] Stable incomplete-result code when complete is false.
@@ -258,10 +258,10 @@ async function runProjectDoctor(program) {
258
258
  async function runIntegrationValidation(program, pkg) {
259
259
  const result = await validateIntegration(pkg);
260
260
  if (program.opts().json) jsonOut(result);
261
- else if (!result.data.validated) {
261
+ else if (result.data.name === null) {
262
262
  emit(
263
263
  text(
264
- 'Nothing was validated: no astryx.integration.* found next to package.json. ' +
264
+ 'No astryx.integration.* found next to package.json. ' +
265
265
  'To validate an installed integration: astryx doctor integration validate <package>',
266
266
  ),
267
267
  );
@@ -284,10 +284,10 @@ async function runAuthoringCheck(program, pkg, kind) {
284
284
  : await integrationDocConflicts(pkg);
285
285
 
286
286
  if (program.opts().json) jsonOut(result);
287
- else if (!result.data.validated) {
287
+ else if (result.data.name === null) {
288
288
  emit(
289
289
  text(
290
- 'Nothing was checked: no astryx.integration.* found next to package.json. ' +
290
+ 'No astryx.integration.* found next to package.json. ' +
291
291
  `To check an installed integration: astryx doctor integration ${kind} <package>`,
292
292
  ),
293
293
  );
@@ -156,17 +156,8 @@ export function registerTemplate(program) {
156
156
  }
157
157
 
158
158
  case 'template.show': {
159
- // Source must survive piping byte-for-byte, so the note about
160
- // replaced demo media goes to stderr, in the copy receipt's words.
161
- // (Text mode only: --json returned above with the count in data.)
162
- const {source, demoMediaReplaced} = result.data;
163
- emit(code(source));
164
- if (demoMediaReplaced > 0) {
165
- console.error(
166
- `Replaced ${demoMediaReplaced} Astryx demo media reference${demoMediaReplaced === 1 ? '' : 's'}: ` +
167
- 'images now show a neutral placeholder and videos have an empty source. Supply your own media there.',
168
- );
169
- }
159
+ // Source must survive piping byte-for-byte.
160
+ emit(code(result.data.source));
170
161
  break;
171
162
  }
172
163
 
@@ -84,18 +84,4 @@ describe('upgrade human output is ASCII', () => {
84
84
  'minSize: 200',
85
85
  );
86
86
  });
87
-
88
- // Every fixture above has a real src/, so the completion line for a project
89
- // whose source is somewhere else was never reached — this suite was green on
90
- // that path by luck, not by coverage.
91
- it('reports a source directory that does not exist', async () => {
92
- fs.rmSync(path.join(tmpDir, 'src'), {recursive: true, force: true});
93
- fs.mkdirSync(path.join(tmpDir, 'app'), {recursive: true});
94
- write('app/panel.tsx', 'export const x = 1;\n');
95
-
96
- expect(await nonAsciiLines(['upgrade', '--from', '0.5.0'])).toEqual([]);
97
- expect(
98
- await nonAsciiLines(['upgrade', '--from', '0.5.0', '--apply']),
99
- ).toEqual([]);
100
- });
101
87
  });
@@ -7,19 +7,19 @@
7
7
  * lets an AI agent drive the entire CLI WITHOUT scraping `--help` text. It is
8
8
  * to the CLI what an OpenAPI spec is to an HTTP API.
9
9
  *
10
- * Its per-command facts come from the command's own definitions: names,
11
- * arguments and options from Commander metadata (program.commands, cmd.options,
12
- * cmd.registeredArguments, cmd.description()); examples from its CommandDoc;
13
- * response `type` discriminators from the returns of the FunctionDoc it wraps
14
- * (both attached by `defineCommand`); `--json` support from the JSON_SUPPORTED
15
- * allowlist in index.mjs. The hand-kept lists are CLI_LAYER_RESPONSE_TYPES,
16
- * for envelopes no API function returns, and ROOT_RESPONSE_TYPES, for the two
17
- * (help and version) that no single command owns.
10
+ * Most of the manifest is DERIVED from Commander metadata (program.commands,
11
+ * cmd.options, cmd.registeredArguments, cmd.description()) so it cannot drift
12
+ * out of sync with the real command definitions. The two pieces Commander does
13
+ * not know about — whether a command supports `--json`, and which response
14
+ * `type` discriminators it can emit — are layered on from:
18
15
  *
19
- * Drift-guard tests (manifest.test.mjs) assert every registered command appears
20
- * in the manifest, every JSON-supported command has response types, and the
21
- * examples and response types equal the docs, so adding a command without
22
- * describing it fails CI.
16
+ * - JSON_SUPPORTED (the allowlist in index.mjs), and
17
+ * - RESPONSE_TYPES (the declarative map below; ROOT_RESPONSE_TYPES names the
18
+ * two, help and version, that no single command owns).
19
+ *
20
+ * A drift-guard test (manifest.test.mjs) asserts every registered command
21
+ * appears in the manifest and every JSON-supported command has a response-type
22
+ * entry, so adding a command without describing it fails CI.
23
23
  *
24
24
  * DESIGN DECISION — manifest stays CLI-special; there is intentionally NO
25
25
  * `api/manifest`. It describes the CLI's own Commander tree, so it takes the live
@@ -40,28 +40,166 @@ import {commandDocsOf} from './define-command.mjs';
40
40
  import {doc as manifestDoc} from '../commands/manifest.doc.mjs';
41
41
 
42
42
  /**
43
- * Envelopes the CLI layer builds itself, so the wrapped FunctionDoc cannot
44
- * declare them: `manifest` wraps no API function, `theme build` batches several
45
- * `themeBuild()` receipts, and `theme add` with no slug (or `--list`) answers
46
- * with `themeListAvailable()`'s `theme.list` instead of calling `themeAdd()`.
47
- * manifest.test.mjs fails once the wrapped FunctionDoc declares one of these, so
48
- * the list only shrinks.
43
+ * Response `type` discriminators each fully-qualified command can emit in
44
+ * `--json` mode. Keyed by the same name Commander reports (parent + leaf,
45
+ * space-joined), e.g. `theme build`. Commander has no knowledge of these —
46
+ * they come from each command's `jsonOut(...)` call sites — so we keep them
47
+ * here, close to the JSON_SUPPORTED allowlist, and guard them with a test.
48
+ *
49
49
  * @type {Record<string, string[]>}
50
50
  */
51
- const CLI_LAYER_RESPONSE_TYPES = {
51
+ export const RESPONSE_TYPES = {
52
+ init: ['init.run', 'init.remove'],
53
+ component: [
54
+ 'component.list',
55
+ 'component.batch',
56
+ 'component.detail',
57
+ 'component.detail.props',
58
+ 'component.detail.source',
59
+ 'component.detail.showcase',
60
+ 'component.detail.blocks',
61
+ ],
62
+ docs: [
63
+ 'docs.list',
64
+ 'docs.index',
65
+ 'docs.detail',
66
+ 'docs.detail.section',
67
+ 'docs.node',
68
+ ],
69
+ blog: ['blog.list', 'blog.detail'],
70
+ discover: [
71
+ 'discover.list',
72
+ 'discover.detail',
73
+ 'discover.detail.doc',
74
+ 'discover.item',
75
+ 'discover.search',
76
+ ],
77
+ search: ['search'],
78
+ build: ['build.help', 'build.kit'],
79
+ swizzle: ['swizzle.list', 'swizzle.copy'],
80
+ 'gap-report': ['gap-report.categories', 'gap-report.file'],
81
+ template: [
82
+ 'template.list',
83
+ 'template.show',
84
+ 'template.skeleton',
85
+ 'template.copy',
86
+ 'template.cdn',
87
+ ],
88
+ hook: ['hook.list', 'hook.detail', 'hook.detail.params'],
89
+ 'theme build': ['theme.build', 'theme.build.check', 'theme.build.batch'],
90
+ 'theme list': ['theme.list'],
91
+ 'theme add': ['theme.list', 'theme.add'],
92
+ 'theme template': ['theme.template'],
93
+ 'theme targets': ['theme.targets'],
94
+ 'theme palette generate': ['theme.palette.generate'],
95
+ 'integration add': ['integration.add'],
96
+ 'integration verify': ['integration.pack-check'],
97
+ 'integration pack': ['integration.pack-check'],
98
+ upgrade: ['upgrade.list', 'upgrade.registry', 'upgrade.status', 'upgrade.run'],
52
99
  manifest: ['manifest'],
53
- 'theme build': ['theme.build.batch'],
54
- 'theme add': ['theme.list'],
100
+ doctor: ['doctor'],
101
+ 'doctor integration validate': ['integration.validate'],
102
+ 'doctor integration templates': ['integration.template-conflicts'],
103
+ 'doctor integration components': ['integration.component-conflicts'],
104
+ 'doctor integration docs': ['integration.doc-conflicts'],
105
+ 'layout expand': ['layout.expand'],
106
+ 'layout check': ['layout.check'],
107
+ 'layout grammar': ['layout.grammar'],
55
108
  };
56
109
 
57
110
  /**
58
111
  * Response types no single command owns: `help` (a bare `astryx --json`, and
59
112
  * `--help --json` on any command) and `version` (`astryx --version --json`).
60
- * The response-types enum lists them beside the per-command response types.
113
+ * The response-types enum lists them beside {@link RESPONSE_TYPES}.
61
114
  * @type {readonly string[]}
62
115
  */
63
116
  export const ROOT_RESPONSE_TYPES = Object.freeze(['help', 'version']);
64
117
 
118
+ /**
119
+ * Example invocations per fully-qualified command. Optional, agent-facing.
120
+ * @type {Record<string, string[]>}
121
+ */
122
+ const EXAMPLES = {
123
+ component: [
124
+ 'astryx component',
125
+ 'astryx component XDSButton',
126
+ 'astryx component Button Badge Text',
127
+ 'astryx component XDSButton --props --json',
128
+ ],
129
+ docs: [
130
+ 'astryx docs',
131
+ 'astryx docs spacing --json',
132
+ 'astryx docs theme',
133
+ 'astryx docs theme quick-start',
134
+ 'astryx docs cli/integrations/quick-start --full',
135
+ ],
136
+ discover: ['astryx discover --json'],
137
+ search: [
138
+ 'astryx search modal --json',
139
+ 'astryx search button --type component --json',
140
+ ],
141
+ build: ['astryx build', 'astryx build "analytics dashboard" --json'],
142
+ swizzle: ['astryx swizzle Button'],
143
+ 'gap-report': [
144
+ 'astryx gap-report --list-categories',
145
+ "astryx gap-report Button --category docs_gap --reason 'Missing keyboard example'",
146
+ ],
147
+ template: [
148
+ 'astryx template --json',
149
+ 'astryx template dashboard ./src/app',
150
+ 'astryx template --cdn',
151
+ ],
152
+ hook: ['astryx hook', 'astryx hook useFocusTrap --json'],
153
+ 'theme build': [
154
+ 'astryx theme build ./src/themes/ocean.ts --out ./dist/ocean.css',
155
+ 'astryx theme build ./src/themes/ocean.ts --check',
156
+ ],
157
+ 'theme list': ['astryx theme list --json'],
158
+ 'theme add': [
159
+ 'astryx theme add matcha',
160
+ 'astryx theme add matcha ./src/themes/matcha',
161
+ ],
162
+ 'theme template': ['astryx theme template', 'astryx theme template --json'],
163
+ 'theme targets': [
164
+ 'astryx theme targets Switch',
165
+ 'astryx --json theme targets',
166
+ ],
167
+ 'theme palette generate': [
168
+ 'astryx theme palette generate palette.config.json',
169
+ 'astryx theme palette generate palette.config.json --out ocean.palette.json',
170
+ ],
171
+ 'integration add': [
172
+ 'astryx integration add component AcmeWidget',
173
+ 'astryx integration add doc deploying --dry-run --json',
174
+ ],
175
+ 'integration verify': ['astryx integration verify --json'],
176
+ upgrade: ['astryx upgrade --json'],
177
+ manifest: ['astryx manifest --json', 'astryx --json'],
178
+ doctor: ['astryx doctor', 'astryx doctor --json'],
179
+ 'doctor integration validate': [
180
+ 'astryx doctor integration validate',
181
+ 'astryx doctor integration validate @acme/widgets --json',
182
+ ],
183
+ 'doctor integration templates': [
184
+ 'astryx doctor integration templates',
185
+ 'astryx doctor integration templates @acme/widgets --json',
186
+ ],
187
+ 'doctor integration components': [
188
+ 'astryx doctor integration components',
189
+ 'astryx doctor integration components @acme/widgets --json',
190
+ ],
191
+ 'doctor integration docs': [
192
+ 'astryx doctor integration docs',
193
+ 'astryx doctor integration docs @acme/widgets --json',
194
+ ],
195
+ init: ['astryx init', 'astryx init --all --json'],
196
+ 'layout expand': [
197
+ `astryx layout expand 'V[g6] > C{card-callout}*4' ./src/Page.tsx`,
198
+ ],
199
+ 'layout check': [`astryx layout check 'A[cp6] > L > LC > S[p6]' --json`],
200
+ 'layout grammar': ['astryx layout grammar'],
201
+ };
202
+
65
203
  /**
66
204
  * Map a Commander Option to a flag descriptor. Derives type from whether the
67
205
  * option takes a value (boolean vs string), surfaces `choices` and `default`.
@@ -176,17 +314,11 @@ function describeCommand(cmd, root, jsonSupported) {
176
314
  const aliases = cmd.aliases ? cmd.aliases() : [];
177
315
  if (aliases && aliases.length > 0) entry.aliases = [...aliases];
178
316
 
179
- // Response types this command can emit in --json mode: the returns of the
180
- // FunctionDoc it wraps, then any envelope the CLI layer builds. Subcommand
181
- // groups (e.g. bare `theme`) have none.
182
- const responseTypes = [
183
- ...(docs?.fn?.returns ?? []).map(r => r.type),
184
- ...(CLI_LAYER_RESPONSE_TYPES[name] ?? []),
185
- ];
186
- if (responseTypes.length > 0) entry.responseTypes = responseTypes;
317
+ // Response types this command can emit in --json mode (only meaningful for
318
+ // JSON-supported leaves). Subcommand groups (e.g. bare `theme`) have none.
319
+ if (RESPONSE_TYPES[name]) entry.responseTypes = [...RESPONSE_TYPES[name]];
187
320
 
188
- const examples = (docs?.doc.examples ?? []).map(e => e.cli);
189
- if (examples.length > 0) entry.examples = examples;
321
+ if (EXAMPLES[name]) entry.examples = [...EXAMPLES[name]];
190
322
 
191
323
  const exitCodes = (docs?.doc.exitCodes ?? []).map(({code, when}) => ({
192
324
  code,
@@ -229,15 +361,6 @@ function describeGlobalOptions(program) {
229
361
  return opts;
230
362
  }
231
363
 
232
- /**
233
- * Every command in a described tree, depth first.
234
- * @param {any[]} commands
235
- * @returns {any[]}
236
- */
237
- function flattenCommands(commands) {
238
- return commands.flatMap(c => [c, ...flattenCommands(c.subcommands || [])]);
239
- }
240
-
241
364
  /**
242
365
  * Build the full capability manifest from a configured Commander program.
243
366
  *
@@ -268,9 +391,7 @@ export function buildManifest(program, opts = {}) {
268
391
  // Flat index of every response `type` discriminator the CLI can emit,
269
392
  // keyed by command — lets an agent know what to expect back per call.
270
393
  responseTypes: Object.fromEntries(
271
- flattenCommands(commands)
272
- .filter(c => c.responseTypes)
273
- .map(c => [c.name, [...c.responseTypes]]),
394
+ Object.entries(RESPONSE_TYPES).map(([k, v]) => [k, [...v]]),
274
395
  ),
275
396
  };
276
397
  }