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

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 (76) hide show
  1. package/README.md +14 -13
  2. package/api/error.d.mts +22 -0
  3. package/api/error.mjs +42 -0
  4. package/api/integration/add-contribution.d.mts +2 -1
  5. package/api/integration/add-contribution.mjs +7 -3
  6. package/api/integration/add-theme.mjs +243 -22
  7. package/api/integration/add-theme.test.mjs +213 -0
  8. package/api/integration/authoring-checks.mjs +10 -7
  9. package/api/integration/authoring-checks.type.d.mts +8 -0
  10. package/api/integration/authoring-checks.type.mjs +7 -3
  11. package/api/integration/integration-authoring.type.d.mts +4 -1
  12. package/api/integration/integration-authoring.type.mjs +6 -1
  13. package/api/integration/integrationAdd.doc.mjs +6 -0
  14. package/api/integration/integrationAddTheme.doc.mjs +10 -0
  15. package/api/integration/integrationComponentConflicts.doc.mjs +1 -1
  16. package/api/integration/integrationDocConflicts.doc.mjs +1 -1
  17. package/api/integration/integrationTemplateConflicts.doc.mjs +1 -1
  18. package/api/integration/validate-integration.d.mts +4 -2
  19. package/api/integration/validate-integration.mjs +7 -2
  20. package/api/integration/validate-integration.test.mjs +55 -0
  21. package/api/integration/validate-integration.type.d.mts +5 -0
  22. package/api/integration/validate-integration.type.mjs +5 -1
  23. package/api/integration/validateIntegration.doc.mjs +1 -1
  24. package/api/layout/expand/expand.mjs +12 -7
  25. package/api/layout/expand/expand.receipt.test.mjs +74 -0
  26. package/api/layout/layout.type.d.mts +1 -0
  27. package/api/layout/layout.type.mjs +1 -0
  28. package/api/layout/layoutExpand.doc.mjs +1 -1
  29. package/api/swizzle/copy/copy.mjs +66 -3
  30. package/api/swizzle/swizzle.doc.mjs +4 -0
  31. package/api/template/copy/copy.mjs +14 -8
  32. package/api/template/copy/copy.receipt.test.mjs +77 -0
  33. package/api/template/show/show.mjs +15 -4
  34. package/api/template/show/show.test.mjs +76 -0
  35. package/api/template/template.d.mts +1 -1
  36. package/api/template/template.doc.mjs +6 -2
  37. package/api/template/template.mjs +1 -0
  38. package/api/template/template.type.d.mts +2 -0
  39. package/api/template/template.type.mjs +2 -0
  40. package/api/theme/build/build.d.mts +24 -0
  41. package/api/theme/build/build.mjs +235 -8
  42. package/api/theme/build/build.project-core.test.mjs +165 -0
  43. package/api/upgrade/run/run.mjs +20 -3
  44. package/api/upgrade/run/run.test.mjs +45 -1
  45. package/api/upgrade/upgrade.doc.mjs +1 -1
  46. package/api/upgrade/upgrade.type.d.mts +1 -0
  47. package/api/upgrade/upgrade.type.mjs +1 -0
  48. package/assets/docs/icons.doc.mjs +1 -0
  49. package/assets/templates/themes/butter/icons.tsx +2 -0
  50. package/assets/templates/themes/chocolate/icons.tsx +2 -0
  51. package/assets/templates/themes/gothic/icons.tsx +2 -0
  52. package/assets/templates/themes/matcha/icons.tsx +2 -0
  53. package/assets/templates/themes/neutral/icons.tsx +2 -0
  54. package/assets/templates/themes/stone/icons.tsx +2 -0
  55. package/assets/templates/themes/y2k/icons.tsx +2 -0
  56. package/clients/cli/commands/doctor.mjs +4 -4
  57. package/clients/cli/commands/integration-add.doc.mjs +10 -0
  58. package/clients/cli/commands/integration-authoring.test.mjs +12 -2
  59. package/clients/cli/commands/integration.mjs +3 -1
  60. package/clients/cli/commands/layout-expand.doc.mjs +3 -1
  61. package/clients/cli/commands/layout.expand-receipt.test.mjs +94 -0
  62. package/clients/cli/commands/layout.mjs +16 -0
  63. package/clients/cli/commands/template.copy-receipt.test.mjs +60 -0
  64. package/clients/cli/commands/template.mjs +19 -5
  65. package/clients/cli/commands/template.show-media.test.mjs +62 -0
  66. package/clients/cli/commands/upgrade.ascii-output.test.mjs +14 -0
  67. package/clients/cli/commands/write-failure.test.mjs +175 -0
  68. package/clients/cli/lib/manifest.mjs +44 -165
  69. package/clients/cli/lib/manifest.test.mjs +98 -7
  70. package/foundation/discovery/template-adapter.d.mts +13 -0
  71. package/foundation/discovery/template-adapter.fixture-refs.test.mjs +37 -1
  72. package/foundation/discovery/template-adapter.mjs +16 -1
  73. package/foundation/doc-compiler/doc-loads.test.mjs +2 -2
  74. package/foundation/response/response-types.doc.d.mts +5 -5
  75. package/foundation/response/response-types.doc.mjs +13 -13
  76. package/package.json +9 -9
@@ -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
- * 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:
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.
15
18
  *
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.
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.
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,166 +40,28 @@ import {commandDocsOf} from './define-command.mjs';
40
40
  import {doc as manifestDoc} from '../commands/manifest.doc.mjs';
41
41
 
42
42
  /**
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
- *
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.
49
49
  * @type {Record<string, string[]>}
50
50
  */
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'],
51
+ const CLI_LAYER_RESPONSE_TYPES = {
99
52
  manifest: ['manifest'],
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'],
53
+ 'theme build': ['theme.build.batch'],
54
+ 'theme add': ['theme.list'],
108
55
  };
109
56
 
110
57
  /**
111
58
  * Response types no single command owns: `help` (a bare `astryx --json`, and
112
59
  * `--help --json` on any command) and `version` (`astryx --version --json`).
113
- * The response-types enum lists them beside {@link RESPONSE_TYPES}.
60
+ * The response-types enum lists them beside the per-command response types.
114
61
  * @type {readonly string[]}
115
62
  */
116
63
  export const ROOT_RESPONSE_TYPES = Object.freeze(['help', 'version']);
117
64
 
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
-
203
65
  /**
204
66
  * Map a Commander Option to a flag descriptor. Derives type from whether the
205
67
  * option takes a value (boolean vs string), surfaces `choices` and `default`.
@@ -314,11 +176,17 @@ function describeCommand(cmd, root, jsonSupported) {
314
176
  const aliases = cmd.aliases ? cmd.aliases() : [];
315
177
  if (aliases && aliases.length > 0) entry.aliases = [...aliases];
316
178
 
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]];
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;
320
187
 
321
- if (EXAMPLES[name]) entry.examples = [...EXAMPLES[name]];
188
+ const examples = (docs?.doc.examples ?? []).map(e => e.cli);
189
+ if (examples.length > 0) entry.examples = examples;
322
190
 
323
191
  const exitCodes = (docs?.doc.exitCodes ?? []).map(({code, when}) => ({
324
192
  code,
@@ -361,6 +229,15 @@ function describeGlobalOptions(program) {
361
229
  return opts;
362
230
  }
363
231
 
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
+
364
241
  /**
365
242
  * Build the full capability manifest from a configured Commander program.
366
243
  *
@@ -391,7 +268,9 @@ export function buildManifest(program, opts = {}) {
391
268
  // Flat index of every response `type` discriminator the CLI can emit,
392
269
  // keyed by command — lets an agent know what to expect back per call.
393
270
  responseTypes: Object.fromEntries(
394
- Object.entries(RESPONSE_TYPES).map(([k, v]) => [k, [...v]]),
271
+ flattenCommands(commands)
272
+ .filter(c => c.responseTypes)
273
+ .map(c => [c.name, [...c.responseTypes]]),
395
274
  ),
396
275
  };
397
276
  }
@@ -14,11 +14,46 @@
14
14
  * surfaces emit valid, enriched JSON.
15
15
  */
16
16
 
17
+ import * as fs from 'node:fs';
18
+ import * as os from 'node:os';
19
+ import * as path from 'node:path';
20
+ import {fileURLToPath, pathToFileURL} from 'node:url';
17
21
  import {describe, it, expect} from 'vitest';
18
22
  import {program, JSON_SUPPORTED} from '../index.mjs';
19
- import {buildManifest, RESPONSE_TYPES} from './manifest.mjs';
23
+ import {buildManifest} from './manifest.mjs';
20
24
  import {runCli} from '../../../test-utils/run-cli.mjs';
21
25
 
26
+ const HERE = path.dirname(fileURLToPath(import.meta.url));
27
+
28
+ /**
29
+ * Import every `*.doc.mjs` under `dir` whose doc has the given type, keyed by
30
+ * its `name`.
31
+ * @param {string} dir @param {string} type @returns {Promise<Map<string, any>>}
32
+ */
33
+ async function loadDocs(dir, type) {
34
+ const out = new Map();
35
+ for (const entry of fs.readdirSync(dir, {withFileTypes: true, recursive: true})) {
36
+ if (!entry.isFile() || !entry.name.endsWith('.doc.mjs')) continue;
37
+ const file = path.join(entry.parentPath, entry.name);
38
+ const {doc} = await import(pathToFileURL(file).href);
39
+ if (doc?.type === type) out.set(doc.name, doc);
40
+ }
41
+ return out;
42
+ }
43
+
44
+ const commandDocs = await loadDocs(path.join(HERE, '../commands'), 'command');
45
+ const functionDocs = await loadDocs(path.join(HERE, '../../../api'), 'function');
46
+
47
+ /**
48
+ * Envelopes built in the CLI layer, which no FunctionDoc can declare. Pinned so
49
+ * an entry is dropped once its type moves behind an API function.
50
+ */
51
+ const CLI_LAYER_TYPES = {
52
+ manifest: ['manifest'],
53
+ 'theme build': ['theme.build.batch'],
54
+ 'theme add': ['theme.list'],
55
+ };
56
+
22
57
  const manifest = buildManifest(program, {jsonSupported: JSON_SUPPORTED, version: '0.0.0-test'});
23
58
 
24
59
  /** Flatten the manifest command tree into fully-qualified names. */
@@ -64,17 +99,73 @@ describe('manifest: drift guards', () => {
64
99
 
65
100
  it('declares response types for every JSON-supported command', () => {
66
101
  for (const name of JSON_SUPPORTED) {
102
+ const entry = allEntries.find((c) => c.name === name);
67
103
  expect(
68
- RESPONSE_TYPES[name],
69
- `JSON-supported command "${name}" has no response-type entry`,
70
- ).toBeDefined();
71
- expect(RESPONSE_TYPES[name].length).toBeGreaterThan(0);
104
+ entry?.responseTypes?.length,
105
+ `JSON-supported command "${name}" has no response types`,
106
+ ).toBeGreaterThan(0);
107
+ expect(manifest.responseTypes[name]).toEqual(entry.responseTypes);
72
108
  }
73
109
  });
74
110
 
75
111
  it('has no response-type entry for a command that does not exist', () => {
76
- for (const name of Object.keys(RESPONSE_TYPES)) {
77
- expect(allNames.has(name), `RESPONSE_TYPES key "${name}" is not a real command`).toBe(true);
112
+ for (const name of Object.keys(manifest.responseTypes)) {
113
+ expect(allNames.has(name), `responseTypes key "${name}" is not a real command`).toBe(true);
114
+ }
115
+ });
116
+
117
+ it('takes every command example from its CommandDoc', () => {
118
+ for (const [name, doc] of commandDocs) {
119
+ const entry = allEntries.find((c) => c.name === name);
120
+ expect(entry, `CommandDoc "${name}" has no manifest entry`).toBeDefined();
121
+ expect(entry.examples ?? [], name).toEqual((doc.examples ?? []).map((e) => e.cli));
122
+ }
123
+ });
124
+
125
+ it('lists every response type the wrapped API function returns', () => {
126
+ for (const [name, doc] of commandDocs) {
127
+ if (!doc.fn) continue;
128
+ const entry = allEntries.find((c) => c.name === name);
129
+ for (const {type} of functionDocs.get(doc.fn).returns) {
130
+ expect(entry.responseTypes, `${name} can emit ${type}`).toContain(type);
131
+ }
132
+ }
133
+ });
134
+
135
+ it('lists upgrade.registry, which `upgrade --registry --json` emits', async () => {
136
+ const cwd = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-manifest-'));
137
+ fs.writeFileSync(path.join(cwd, 'package.json'), '{"name":"app","version":"1.0.0"}');
138
+ const {status, stdout} = await runCli(['--json', 'upgrade', '--registry'], {cwd});
139
+ expect(status).toBe(0);
140
+ expect(JSON.parse(stdout).type).toBe('upgrade.registry');
141
+ expect(manifest.responseTypes.upgrade).toContain('upgrade.registry');
142
+ });
143
+
144
+ it('lists theme.list for theme add, which lists themes when given no slug', async () => {
145
+ const cwd = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-manifest-'));
146
+ fs.writeFileSync(path.join(cwd, 'package.json'), '{"name":"app","version":"1.0.0"}');
147
+ const {status, stdout} = await runCli(['--json', 'theme', 'add'], {cwd});
148
+ expect(status).toBe(0);
149
+ expect(JSON.parse(stdout).type).toBe('theme.list');
150
+ expect(manifest.responseTypes['theme add']).toContain('theme.list');
151
+ });
152
+
153
+ it('takes response types from the wrapped FunctionDoc, plus CLI-layer envelopes', () => {
154
+ for (const [name, doc] of commandDocs) {
155
+ const entry = allEntries.find((c) => c.name === name);
156
+ const returns = doc.fn ? functionDocs.get(doc.fn).returns.map((r) => r.type) : [];
157
+ const expected = [...returns, ...(CLI_LAYER_TYPES[name] ?? [])];
158
+ expect(entry.responseTypes ?? [], name).toEqual(expected);
159
+ }
160
+ });
161
+
162
+ it('pins only CLI-layer envelopes that no FunctionDoc declares', () => {
163
+ for (const [name, types] of Object.entries(CLI_LAYER_TYPES)) {
164
+ const fn = commandDocs.get(name)?.fn;
165
+ const declared = fn ? functionDocs.get(fn).returns.map((r) => r.type) : [];
166
+ for (const type of types) {
167
+ expect(declared, `${type} is declared by ${fn}(); unpin it`).not.toContain(type);
168
+ }
78
169
  }
79
170
  });
80
171
 
@@ -49,6 +49,19 @@ export function effectiveTemplateDiscovery(templates: DiscoveredTemplate[]): Dis
49
49
  * @returns {string} Source with demo asset references replaced.
50
50
  */
51
51
  export function stripTemplateAssetRefs(source: string): string;
52
+ /**
53
+ * {@link stripTemplateAssetRefs}, plus how many references it replaced: one per
54
+ * replaced reference, however many fixture paths its URL carries (a reference
55
+ * is replaced whole, query included), and none for a prose mention or a
56
+ * third-party URL left as written. That count is what a receipt discloses.
57
+ *
58
+ * @param {string} source - Template source code.
59
+ * @returns {{source: string, demoMediaReplaced: number}}
60
+ */
61
+ export function replaceDemoMedia(source: string): {
62
+ source: string;
63
+ demoMediaReplaced: number;
64
+ };
52
65
  /**
53
66
  * List the core page-template directory names (sorted). The `template --list`
54
67
  * view discovers far more; this is the minimal core-page set `init` scaffolds
@@ -5,7 +5,7 @@ import * as fs from 'node:fs';
5
5
  import * as path from 'node:path';
6
6
  import {fileURLToPath} from 'node:url';
7
7
  import jscodeshift from 'jscodeshift';
8
- import {stripTemplateAssetRefs} from './template-adapter.mjs';
8
+ import {replaceDemoMedia, stripTemplateAssetRefs} from './template-adapter.mjs';
9
9
 
10
10
  const PLACEHOLDER = stripTemplateAssetRefs("'/template-assets/x.png'").slice(
11
11
  1,
@@ -212,6 +212,42 @@ describe('stripTemplateAssetRefs fixture references', () => {
212
212
  });
213
213
  });
214
214
 
215
+ describe('replaceDemoMedia', () => {
216
+ it('counts a reference once, however many fixture paths its URL carries', () => {
217
+ const source =
218
+ "const hero = '/template-assets/a.png?f=/template-assets/b.png';";
219
+ expect(replaceDemoMedia(source)).toEqual({
220
+ source: stripTemplateAssetRefs(source),
221
+ demoMediaReplaced: 1,
222
+ });
223
+ });
224
+
225
+ it('counts a poster and a video as two references', () => {
226
+ const source =
227
+ '<video poster="/template-assets/poster.jpg" src="/template-assets/clip.mp4" />';
228
+ const result = replaceDemoMedia(source);
229
+ expect(result).toEqual({
230
+ source: stripTemplateAssetRefs(source),
231
+ demoMediaReplaced: 2,
232
+ });
233
+ expect(result.source).not.toContain('/template-assets/');
234
+ });
235
+
236
+ it.each([
237
+ [
238
+ 'a prose mention',
239
+ '<p>Demo media lives under /template-assets/ in the docsite.</p>',
240
+ ],
241
+ [
242
+ 'a third-party URL',
243
+ "const u = 'https://example.com/template-assets/a.png';",
244
+ ],
245
+ ['source with no fixture', 'const x = 1;'],
246
+ ])('counts nothing for %s it leaves as written', (_label, source) => {
247
+ expect(replaceDemoMedia(source)).toEqual({source, demoMediaReplaced: 0});
248
+ });
249
+ });
250
+
215
251
  describe('shipped templates', () => {
216
252
  it('copy with every fixture replaced and still parse', () => {
217
253
  const root = path.resolve(
@@ -321,9 +321,23 @@ function toPosixPath(p) {
321
321
  * @returns {string} Source with demo asset references replaced.
322
322
  */
323
323
  export function stripTemplateAssetRefs(source) {
324
+ return replaceDemoMedia(source).source;
325
+ }
326
+
327
+ /**
328
+ * {@link stripTemplateAssetRefs}, plus how many references it replaced: one per
329
+ * replaced reference, however many fixture paths its URL carries (a reference
330
+ * is replaced whole, query included), and none for a prose mention or a
331
+ * third-party URL left as written. That count is what a receipt discloses.
332
+ *
333
+ * @param {string} source - Template source code.
334
+ * @returns {{source: string, demoMediaReplaced: number}}
335
+ */
336
+ export function replaceDemoMedia(source) {
324
337
  const needle = `/${FIXTURE_SEGMENT}`;
325
338
  let output = '';
326
339
  let copied = 0;
340
+ let demoMediaReplaced = 0;
327
341
  /** @type {Array<[number, number]> | undefined} */
328
342
  let comments;
329
343
  let at = source.indexOf(needle);
@@ -344,10 +358,11 @@ export function stripTemplateAssetRefs(source) {
344
358
  if (edit) {
345
359
  output += source.slice(copied, start) + edit.text;
346
360
  copied = edit.end;
361
+ demoMediaReplaced += 1;
347
362
  }
348
363
  at = source.indexOf(needle, end);
349
364
  }
350
- return output + source.slice(copied);
365
+ return {source: output + source.slice(copied), demoMediaReplaced};
351
366
  }
352
367
 
353
368
  /** @param {string | undefined} char */
@@ -61,13 +61,13 @@ const RUNNERS = {
61
61
  sites: ['child_process.execFileSync'],
62
62
  },
63
63
  'api/theme/build/build.mjs': {
64
- runs: 'theme source modules, through jiti; eval for legacy theme object literals',
64
+ runs: "theme source modules, through jiti; eval for legacy theme object literals; the project's installed Core",
65
65
  sites: [
66
66
  '.evalModule() ×2',
67
67
  '.import()',
68
68
  'createJiti ×4',
69
69
  'eval ×2',
70
- 'import(<computed>)',
70
+ 'import(<computed>) ×3',
71
71
  ],
72
72
  },
73
73
  'api/theme/build/core-interception.mjs': {
@@ -3,11 +3,11 @@
3
3
 
4
4
  /**
5
5
  * @file EnumDoc for the `type` discriminant carried on every --json success
6
- * envelope. The vocabulary mirrors the RESPONSE_TYPES map (each command's
7
- * `jsonOut(...)` call sites) plus ROOT_RESPONSE_TYPES (help, version) in
8
- * `clients/cli/lib/manifest.mjs`; a consumer switches on `type` to narrow the
9
- * `data` payload. Descriptions follow the currently published response
10
- * projection, not a future package-version boundary.
6
+ * envelope. The vocabulary equals the manifest's response types (each
7
+ * command's FunctionDoc returns; see `clients/cli/lib/manifest.mjs`) plus
8
+ * ROOT_RESPONSE_TYPES (help, version) there; a consumer switches on `type` to
9
+ * narrow the `data` payload. Descriptions follow the currently published
10
+ * response projection, not a future package-version boundary.
11
11
  *
12
12
  * @input Public response discriminants and their currently released payloads.
13
13
  * @output Generated consumer reference for every typed JSON success response.
@@ -2,11 +2,11 @@
2
2
 
3
3
  /**
4
4
  * @file EnumDoc for the `type` discriminant carried on every --json success
5
- * envelope. The vocabulary mirrors the RESPONSE_TYPES map (each command's
6
- * `jsonOut(...)` call sites) plus ROOT_RESPONSE_TYPES (help, version) in
7
- * `clients/cli/lib/manifest.mjs`; a consumer switches on `type` to narrow the
8
- * `data` payload. Descriptions follow the currently published response
9
- * projection, not a future package-version boundary.
5
+ * envelope. The vocabulary equals the manifest's response types (each
6
+ * command's FunctionDoc returns; see `clients/cli/lib/manifest.mjs`) plus
7
+ * ROOT_RESPONSE_TYPES (help, version) there; a consumer switches on `type` to
8
+ * narrow the `data` payload. Descriptions follow the currently published
9
+ * response projection, not a future package-version boundary.
10
10
  *
11
11
  * @input Public response discriminants and their currently released payloads.
12
12
  * @output Generated consumer reference for every typed JSON success response.
@@ -184,7 +184,7 @@ export const doc = {
184
184
  {
185
185
  value: 'template.show',
186
186
  description:
187
- "The resolved template's raw source plus its description, kind, and the component names it composes.",
187
+ "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 were replaced with placeholders for you to swap for your own media).",
188
188
  },
189
189
  {
190
190
  value: 'template.skeleton',
@@ -194,7 +194,7 @@ export const doc = {
194
194
  {
195
195
  value: 'template.copy',
196
196
  description:
197
- 'A scaffold receipt: template id, output directory, written file name, and file count.',
197
+ 'A scaffold receipt: template id, output directory, written file name, file count, and demoMediaReplaced (how many Astryx demo media references were replaced with placeholders for you to swap for your own media).',
198
198
  },
199
199
 
200
200
  {
@@ -276,7 +276,7 @@ export const doc = {
276
276
  {
277
277
  value: 'upgrade.run',
278
278
  description:
279
- 'The run receipt: from/to versions, codemod count, integrations processed, the agent-docs summary, and (apply mode) filesChanged, transformsApplied, and per-codemod errors.',
279
+ 'The run receipt: from/to versions, codemod count, integrations processed, the agent-docs summary, sourcePathFound (false when the resolved source directory does not exist, so no source file was read), and (apply mode) filesChanged, transformsApplied, and per-codemod errors.',
280
280
  },
281
281
 
282
282
  // manifest
@@ -320,29 +320,29 @@ export const doc = {
320
320
  {
321
321
  value: 'integration.validate',
322
322
  description:
323
- 'The validation result: the package name and version (both null when no local manifest is found) plus issues, an AstryxIntegrationIssue[] of {code, severity: warning | error, message}.',
323
+ 'The validation result: validated (false when no integration manifest was found, so nothing was checked and the empty issues list proves nothing), the package name and version (both null when validated is false) plus issues, an AstryxIntegrationIssue[] of {code, severity: warning | error, message}.',
324
324
  },
325
325
  {
326
326
  value: 'integration.template-conflicts',
327
327
  description:
328
- 'The integration identity, structural issues, and non-blocking Core template-id conflicts as {id, severity: warning, integrationPackage, integrationType, integrationName, coreMatches, message, command}.',
328
+ 'validated (false when no integration manifest was found, so nothing was inspected), the integration identity, structural issues, and non-blocking Core template-id conflicts as {id, severity: warning, integrationPackage, integrationType, integrationName, coreMatches, message, command}.',
329
329
  },
330
330
  {
331
331
  value: 'integration.component-conflicts',
332
332
  description:
333
- 'The integration identity, structural issues, and non-blocking conflicts where an integration component name is also owned by Core; each conflict includes the exact package-qualified command.',
333
+ 'validated (false when no integration manifest was found, so nothing was inspected), the integration identity, structural issues, and non-blocking conflicts where an integration component name is also owned by Core; each conflict includes the exact package-qualified command.',
334
334
  },
335
335
  {
336
336
  value: 'integration.doc-conflicts',
337
337
  description:
338
- 'The integration identity, structural issues, and Core doc overlaps. Each finding includes `severity` (`info` | `error`) and `relationship` (`replaces` | `extends` | `accidental`).',
338
+ 'validated (false when no integration manifest was found, so nothing was inspected), the integration identity, structural issues, and Core doc overlaps. Each finding includes `severity` (`info` | `error`) and `relationship` (`replaces` | `extends` | `accidental`).',
339
339
  },
340
340
 
341
341
  // layout (XLE/XLO)
342
342
  {
343
343
  value: 'layout.expand',
344
344
  description:
345
- 'The expansion: parsed form, generated TSX code, componentsUsed, states (count of useState hooks scaffolded), todos, blocksReferenced (each {name, mode}), warnings, and written (the output path, or null when nothing was written).',
345
+ 'The expansion: parsed form, generated TSX code, componentsUsed, states (count of useState hooks scaffolded), todos, blocksReferenced (each {name, mode}), warnings, written (the output path, or null when nothing was written), and demoMediaReplaced (count of demo media placeholders).',
346
346
  },
347
347
  {
348
348
  value: 'layout.check',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astryxdesign/cli",
3
- "version": "0.6.5-canary.f261d2f",
3
+ "version": "0.6.5-canary.f27f749",
4
4
  "displayName": "CLI",
5
5
  "description": "Scaffold projects, browse templates, generate themes, and get agent-ready docs from the command line.",
6
6
  "author": "Meta Open Source",
@@ -101,10 +101,10 @@
101
101
  "zod": "^4.4.3"
102
102
  },
103
103
  "peerDependencies": {
104
- "@astryxdesign/charts": "0.6.5-canary.f261d2f",
105
- "@astryxdesign/core": "0.6.5-canary.f261d2f",
106
- "@astryxdesign/lab": "0.6.5-canary.f261d2f",
107
- "@astryxdesign/theme-neutral": "0.6.5-canary.f261d2f"
104
+ "@astryxdesign/charts": "0.6.5-canary.f27f749",
105
+ "@astryxdesign/core": "0.6.5-canary.f27f749",
106
+ "@astryxdesign/lab": "0.6.5-canary.f27f749",
107
+ "@astryxdesign/theme-neutral": "0.6.5-canary.f27f749"
108
108
  },
109
109
  "peerDependenciesMeta": {
110
110
  "@astryxdesign/charts": {
@@ -121,10 +121,10 @@
121
121
  }
122
122
  },
123
123
  "devDependencies": {
124
- "@astryxdesign/charts": "0.6.5-canary.f261d2f",
125
- "@astryxdesign/core": "0.6.5-canary.f261d2f",
126
- "@astryxdesign/lab": "0.6.5-canary.f261d2f",
127
- "@astryxdesign/theme-neutral": "0.6.5-canary.f261d2f",
124
+ "@astryxdesign/charts": "0.6.5-canary.f27f749",
125
+ "@astryxdesign/core": "0.6.5-canary.f27f749",
126
+ "@astryxdesign/lab": "0.6.5-canary.f27f749",
127
+ "@astryxdesign/theme-neutral": "0.6.5-canary.f27f749",
128
128
  "@heroicons/react": "^2.2.0",
129
129
  "@stylexjs/stylex": "^0.19.0",
130
130
  "@types/babel__core": "^7.20.5",