@astryxdesign/cli 0.7.0-canary.9eb7c76 → 0.7.0-canary.e3c1cfd

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 (87) hide show
  1. package/README.md +19 -23
  2. package/api/build/build.mjs +9 -0
  3. package/api/component/_adapter.d.mts +2 -0
  4. package/api/component/_adapter.mjs +3 -1
  5. package/api/component/component.doc.mjs +5 -1
  6. package/api/docs/compiled-topics.test.mjs +16 -0
  7. package/api/gap-report/gap-report.doc.mjs +1 -1
  8. package/api/gap-report/gap-report.mjs +15 -0
  9. package/api/index.d.mts +0 -2
  10. package/api/index.mjs +0 -2
  11. package/api/init/init.mjs +22 -0
  12. package/api/integration/validate-integration.d.mts +4 -0
  13. package/api/integration/validate-integration.mjs +5 -2
  14. package/api/integration/validateIntegration.doc.mjs +1 -1
  15. package/api/json/index.ts +0 -1
  16. package/api/template/list/list.mjs +23 -2
  17. package/api/template/list/list.test.mjs +52 -0
  18. package/api/template/template-integration.test.mjs +37 -100
  19. package/api/template/template.doc.mjs +7 -2
  20. package/api/template/template.mjs +45 -0
  21. package/api/upgrade/upgrade.doc.mjs +1 -1
  22. package/api/upgrade/upgrade.mjs +19 -0
  23. package/assets/docs/author-a-theme.doc.mjs +3 -3
  24. package/clients/cli/command-result-coverage.test.mjs +1 -1
  25. package/clients/cli/commands/build.doc.mjs +1 -1
  26. package/clients/cli/commands/build.mjs +1 -1
  27. package/clients/cli/commands/component-ownership.test.mjs +2 -2
  28. package/clients/cli/commands/debug-result-summary.test.mjs +0 -16
  29. package/clients/cli/commands/doctor.mjs +5 -2
  30. package/clients/cli/commands/gap-report.doc.mjs +1 -1
  31. package/clients/cli/commands/gap-report.test.mjs +2 -2
  32. package/clients/cli/commands/init.doc.mjs +4 -4
  33. package/clients/cli/commands/init.flag-help.test.mjs +7 -10
  34. package/clients/cli/commands/integration.mjs +2 -1
  35. package/clients/cli/commands/option-pair-refusals.test.mjs +37 -0
  36. package/clients/cli/commands/silent-success-refusals.test.mjs +15 -0
  37. package/clients/cli/commands/template.doc.mjs +4 -4
  38. package/clients/cli/commands/template.flag-help.test.mjs +18 -11
  39. package/clients/cli/commands/text-json-parity.test.mjs +0 -17
  40. package/clients/cli/commands/upgrade.doc.mjs +1 -1
  41. package/clients/cli/commands/upgrade.flag-help.test.mjs +7 -11
  42. package/clients/cli/commands/validate-nothing-exits-nonzero.test.mjs +67 -0
  43. package/clients/cli/index.mjs +0 -4
  44. package/clients/cli/lib/exit-codes.test.mjs +0 -7
  45. package/clients/cli/lib/json-shim.test.mjs +0 -24
  46. package/foundation/doc-compiler/doc-loads.test.mjs +0 -12
  47. package/foundation/response/error-codes.doc.mjs +1 -1
  48. package/foundation/response/response-types.doc.mjs +1 -17
  49. package/foundation/response/response.doc.mjs +1 -1
  50. package/foundation/xle/browser.d.mts +2 -2
  51. package/foundation/xle/browser.mjs +2 -2
  52. package/foundation/xle/expand.mjs +1 -1
  53. package/foundation/xle/print.mjs +1 -1
  54. package/package.json +9 -9
  55. package/api/layout/_adapter.d.mts +0 -34
  56. package/api/layout/_adapter.mjs +0 -148
  57. package/api/layout/check/check.d.mts +0 -17
  58. package/api/layout/check/check.mjs +0 -41
  59. package/api/layout/expand/expand.d.mts +0 -23
  60. package/api/layout/expand/expand.mjs +0 -161
  61. package/api/layout/expand/expand.path-safety.test.mjs +0 -53
  62. package/api/layout/expand/expand.receipt.test.mjs +0 -74
  63. package/api/layout/grammar/grammar.d.mts +0 -14
  64. package/api/layout/grammar/grammar.mjs +0 -88
  65. package/api/layout/layout.d.mts +0 -6
  66. package/api/layout/layout.mjs +0 -17
  67. package/api/layout/layout.test.mjs +0 -297
  68. package/api/layout/layout.type.d.mts +0 -90
  69. package/api/layout/layout.type.mjs +0 -104
  70. package/api/layout/layoutCheck.doc.d.mts +0 -11
  71. package/api/layout/layoutCheck.doc.mjs +0 -85
  72. package/api/layout/layoutExpand.doc.d.mts +0 -11
  73. package/api/layout/layoutExpand.doc.mjs +0 -107
  74. package/api/layout/layoutGrammar.doc.d.mts +0 -11
  75. package/api/layout/layoutGrammar.doc.mjs +0 -57
  76. package/clients/cli/commands/layout-check.doc.mjs +0 -67
  77. package/clients/cli/commands/layout-expand.doc.mjs +0 -87
  78. package/clients/cli/commands/layout-grammar.doc.mjs +0 -32
  79. package/clients/cli/commands/layout.deprecation-lifecycle.test.mjs +0 -140
  80. package/clients/cli/commands/layout.doc.mjs +0 -36
  81. package/clients/cli/commands/layout.error-codes.test.mjs +0 -66
  82. package/clients/cli/commands/layout.exit-parity.test.mjs +0 -41
  83. package/clients/cli/commands/layout.expand-receipt.test.mjs +0 -94
  84. package/clients/cli/commands/layout.mjs +0 -327
  85. package/clients/cli/commands/layout.path-help.test.mjs +0 -33
  86. package/clients/cli/commands/layout.stdin-cap.test.mjs +0 -47
  87. package/clients/cli/commands/layout.text-fields.test.mjs +0 -39
@@ -86,6 +86,51 @@ export async function template(name, options = {}) {
86
86
  cwd = process.cwd(),
87
87
  } = options;
88
88
 
89
+ if (cdn) {
90
+ const ignored = [
91
+ name ? '<name>' : null,
92
+ list ? '--list' : null,
93
+ skeleton ? '--skeleton' : null,
94
+ type ? '--type' : null,
95
+ packageFilter ? '--package' : null,
96
+ ].filter(Boolean);
97
+ if (ignored.length > 0) {
98
+ throw new AstryxError(
99
+ `\`--cdn\` cannot be combined with ${ignored.join(', ')}: the CDN starter does not use templates.`,
100
+ undefined,
101
+ ERROR_CODES.ERR_INVALID_ARGUMENT,
102
+ );
103
+ }
104
+ }
105
+ if (list) {
106
+ const ignored = [
107
+ name ? '<name>' : null,
108
+ targetPath ? '<path>' : null,
109
+ skeleton ? '--skeleton' : null,
110
+ overwrite ? '--overwrite' : null,
111
+ ].filter(Boolean);
112
+ if (ignored.length > 0) {
113
+ throw new AstryxError(
114
+ `\`--list\` cannot be combined with ${ignored.join(', ')}: it lists templates and does not scaffold.`,
115
+ undefined,
116
+ ERROR_CODES.ERR_INVALID_ARGUMENT,
117
+ );
118
+ }
119
+ }
120
+ if (skeleton) {
121
+ const ignored = [
122
+ targetPath ? '<path>' : null,
123
+ overwrite ? '--overwrite' : null,
124
+ ].filter(Boolean);
125
+ if (ignored.length > 0) {
126
+ throw new AstryxError(
127
+ `\`--skeleton\` cannot be combined with ${ignored.join(', ')}: it prints the skeleton and does not write files.`,
128
+ undefined,
129
+ ERROR_CODES.ERR_INVALID_ARGUMENT,
130
+ );
131
+ }
132
+ }
133
+
89
134
  // The CDN starter ships as an asset rather than as a discovered template, so
90
135
  // it answers before discovery — nothing here needs a name resolved.
91
136
  if (cdn) {
@@ -129,7 +129,7 @@ export const doc = {
129
129
  throws: [
130
130
  {
131
131
  code: 'ERR_INVALID_ARGUMENT',
132
- when: '`from` is missing (and neither `list` nor `registry` is set); `list` and `registry` are both set; `registry` is combined with `from`, `force`, `codemod`, `skipCodemod`, `integration` or `installDeps`; an `integration` specifier is invalid or not installed; or astryx.config fails to load or validate and no pending config codemod repairs it',
132
+ when: '`from` is missing (and neither `list` nor `registry` is set); `list` and `registry` are both set; `list` is combined with `from`, `force`, `apply`, `path` (non-default), `codemod`, `skipCodemod`, `integration` or `installDeps`; `registry` is combined with `from`, `force`, `codemod`, `skipCodemod`, `integration` or `installDeps`; an `integration` specifier is invalid or not installed; or astryx.config fails to load or validate and no pending config codemod repairs it',
133
133
  },
134
134
  {code: 'ERR_INVALID_VERSION', when: '`from` is not a valid semver string'},
135
135
  {code: 'ERR_PATH_TRAVERSAL', when: '`path` resolves outside cwd'},
@@ -53,6 +53,25 @@ export async function upgrade(options = {}, {cwd = process.cwd()} = {}) {
53
53
  throw new AstryxError(msg, undefined, ERROR_CODES.ERR_INVALID_ARGUMENT);
54
54
  }
55
55
 
56
+ if (options.list) {
57
+ const ignored = [
58
+ options.from ? '--from' : null,
59
+ options.force ? '--force' : null,
60
+ options.apply ? '--apply' : null,
61
+ options.path && options.path !== './src' ? '--path' : null,
62
+ options.codemod ? '--codemod' : null,
63
+ options.skipCodemod?.length ? '--skip-codemod' : null,
64
+ options.integration?.length ? '--integration' : null,
65
+ options.installDeps ? '--install-deps' : null,
66
+ ].filter(Boolean);
67
+ if (ignored.length > 0) {
68
+ const msg = `\`--list\` cannot be combined with ${ignored.join(', ')}: it lists available codemods and does not run a migration.`;
69
+ logger.error(msg);
70
+ logger.log('Aborted\n');
71
+ throw new AstryxError(msg, undefined, ERROR_CODES.ERR_INVALID_ARGUMENT);
72
+ }
73
+ }
74
+
56
75
  if (options.registry) {
57
76
  const incompatible = [
58
77
  options.from ? '--from' : null,
@@ -34,10 +34,10 @@ export const docs = {
34
34
  {
35
35
  title: 'defineTheme',
36
36
  content: [
37
- {type: 'prose', text: "defineTheme creates a theme from token overrides and optional scale configs. Only override tokens that differ from defaults; omitted tokens use the design system defaults. Scale configs generate tokens from parameters. Explicit token overrides always take precedence over scale-generated values, token by token. localTokens accepts any valid CSS custom-property name; prefixes do not establish ownership. One caveat for the accent: overriding --color-accent in tokens re-points the reference tokens (--color-accent-muted, --color-text-accent, --color-icon-accent) but NOT --color-on-accent, which stays baked from the color.accent seed. To give each scheme its own accent with a consistent derived palette, pass a [light, dark] tuple to color.accent instead of overriding the token."},
38
- {type: 'code', lang: 'tsx', label: 'defineTheme with scale configs', code: "import {defineTheme} from '@astryxdesign/core/theme';\n\nconst myTheme = defineTheme({\n name: 'my-theme',\n // accent: single hex, or [light, dark] tuple to seed each scheme separately\n color: { accent: ['#7B61FF', '#9B85FF'], neutralStyle: 'cool' },\n typography: {\n scale: { base: 14, ratio: 1.2 },\n body: { family: 'Inter', fallbacks: '-apple-system, sans-serif' },\n },\n radius: { base: 4, multiplier: 1 },\n motion: { fast: 175, medium: 410, ratio: 0.75 },\n tokens: {\n // Explicit overrides take precedence over scale-generated values\n '--color-background-body': ['#FFFFFF', '#0A0A0A'],\n },\n});"},
37
+ {type: 'prose', text: 'defineTheme creates a theme from explicit token overrides and optional scale configs. Existing themes may use `color` to expand an accent seed into neutral, surface, text, border, and related values; it is not an accent-only edit. Keep that configuration when preserving existing output. For new complete palettes, generate and review a committed palette module, then import its `palette` export and reference stable stops from semantic tokens. This keeps mapped roles coherent when the accepted palette is regenerated; generation itself does not rewrite the theme. Other scale configs generate typography, radius, and motion values from parameters. Explicit token overrides always take precedence over scale-generated values, token by token. When an existing `color` config is in use, overriding `--color-accent` in `tokens` re-points `--color-accent-muted`, `--color-text-accent`, and `--color-icon-accent`, but `--color-on-accent` stays baked from the `color.accent` seed. Prefer a `[light, dark]` tuple for `color.accent` over overriding `--color-accent` alone. localTokens accepts any valid CSS custom-property name; prefixes do not establish ownership.'},
38
+ {type: 'code', lang: 'tsx', label: 'defineTheme with generated palette references and non-color scale configs', code: "import {defineTheme} from '@astryxdesign/core/theme';\nimport {palette} from './palette.generated';\n\nconst myTheme = defineTheme({\n name: 'my-theme',\n typography: {\n scale: { base: 14, ratio: 1.2 },\n body: { family: 'Inter', fallbacks: '-apple-system, sans-serif' },\n },\n radius: { base: 4, multiplier: 1 },\n motion: { fast: 175, medium: 410, ratio: 0.75 },\n tokens: {\n '--color-background-surface': [\n palette.neutral.light[100],\n palette.neutral.dark[15],\n ],\n },\n});"},
39
39
  {type: 'table', headers: ['Config', 'Generates', 'Parameters'], rows: [
40
- ['color', '--color-accent, --color-background-*, --color-text-*, --color-border, etc.', 'accent? (hex or [light, dark] tuple; omit for neutral-only), neutralStyle? (warm|cool|neutral), contrast? (standard|high)'],
40
+ ['color (existing themes)', '--color-accent, --color-background-*, --color-text-*, --color-border, etc.', 'Supported broad scale: accent? (hex or [light, dark] tuple), neutralStyle? (warm|cool|neutral), contrast? (standard|high). Use theme palette generate for new complete palettes.'],
41
41
  ['typography.scale', '--text-heading-*-size/weight/leading, --text-body-size/weight/leading', 'base (px), ratio'],
42
42
  ['typography.body/heading/code', '--font-family-body, --font-family-heading, --font-family-code', 'family, fallbacks?, url?, weight?'],
43
43
  ['radius', '--radius-inner, --radius-element, --radius-container, --radius-page, --radius-chat', 'base (px), multiplier (0–2)'],
@@ -39,7 +39,7 @@ import {reportsResult, reportsResultVia} from './lib/define-command.mjs';
39
39
  * other. Its bare form prints help and never returns from that action, which
40
40
  * the recorder covers where help is recorded, not here.)
41
41
  */
42
- const NO_ACTION_OF_THEIR_OWN = ['layout'];
42
+ const NO_ACTION_OF_THEIR_OWN = [];
43
43
 
44
44
  /**
45
45
  * Commands that record for themselves instead of returning a descriptor.
@@ -51,7 +51,7 @@ export const doc = {
51
51
  {code: 0, when: 'success (including zero matches)'},
52
52
  {
53
53
  code: 1,
54
- when: 'invalid --type, a non-positive --limit, or a query when @astryxdesign/core cannot be found (the playbook needs no core)',
54
+ when: 'invalid --type, a --limit that is not a positive integer, or a query when @astryxdesign/core cannot be found (the playbook needs no core)',
55
55
  },
56
56
  ],
57
57
  related: ['search', 'template', 'component', 'hook', 'init'],
@@ -101,7 +101,7 @@ export function registerBuild(program) {
101
101
  // throws ERR_INVALID_ARGUMENT, so we pass NaN through rather than
102
102
  // pre-rejecting with a generic code here (parity with `search`).
103
103
  const limit =
104
- options.limit != null ? Number.parseInt(options.limit, 10) : 60;
104
+ options.limit != null ? Number(options.limit) : 60;
105
105
 
106
106
  /** @type {import('../../../api/build/build.type.mjs').BuildKitResponse} */
107
107
  let result;
@@ -223,7 +223,7 @@ describe('component() — integration ownership via config', () => {
223
223
  caught = e;
224
224
  }
225
225
  expect(caught).toBeTruthy();
226
- expect(caught.code).toBe('ERR_UNKNOWN_COMPONENT');
226
+ expect(caught.code).toBe('ERR_AMBIGUOUS_COMPONENT');
227
227
  const pkgs = (caught.suggestions ?? []).map(s => s.name);
228
228
  expect(pkgs).toContain(CORE_PACKAGE);
229
229
  expect(pkgs).toContain(INTEGRATION_NAME);
@@ -288,7 +288,7 @@ describe('component() — integration ownership via config', () => {
288
288
  expect(result.data.results[1]).toMatchObject({
289
289
  selector: 'AppShell',
290
290
  status: 'ambiguous',
291
- code: 'ERR_UNKNOWN_COMPONENT',
291
+ code: 'ERR_AMBIGUOUS_COMPONENT',
292
292
  });
293
293
  expect(result.data.results[1].candidates).toEqual(
294
294
  expect.arrayContaining([
@@ -176,22 +176,6 @@ describe('DebugEvent result summary', () => {
176
176
  SLOW,
177
177
  );
178
178
 
179
- it(
180
- 'says so explicitly when a command has no result set',
181
- async () => {
182
- // `layout check` returns a verdict on one expression: nothing was looked
183
- // up, and the run says that rather than leaving four ambiguous nulls.
184
- const {event} = await runWithDebug(['layout', 'check', 'VStack>Text']);
185
- expect(event.output).toMatchObject({
186
- resultKind: 'none',
187
- resultCount: null,
188
- emptyResult: null,
189
- directMatch: null,
190
- });
191
- },
192
- SLOW,
193
- );
194
-
195
179
  it(
196
180
  'only claims a direct match when the filter resolved one component',
197
181
  async () => {
@@ -259,10 +259,13 @@ async function runIntegrationValidation(program, pkg) {
259
259
  const result = await validateIntegration(pkg);
260
260
  if (program.opts().json) jsonOut(result);
261
261
  else if (!result.data.validated) {
262
+ const noPackage = result.data.issues.some(i => i.code === 'no_package');
262
263
  emit(
263
264
  text(
264
- 'Nothing was validated: no astryx.integration.* found next to package.json. ' +
265
- 'To validate an installed integration: astryx doctor integration validate <package>',
265
+ noPackage
266
+ ? 'Nothing was validated: no package.json found. Run this command inside a package directory.'
267
+ : 'Nothing was validated: no astryx.integration.* found next to package.json. ' +
268
+ 'To validate an installed integration: astryx doctor integration validate <package>',
266
269
  ),
267
270
  );
268
271
  } else printIntegrationValidation(result.data);
@@ -61,7 +61,7 @@ export const doc = {
61
61
  flag: '--list-categories',
62
62
  param: 'options.listCategories',
63
63
  description:
64
- 'List valid report categories without filing; the component and the other gap-report options are ignored',
64
+ 'List valid report categories without filing; the component and the other gap-report options are refused with ERR_INVALID_ARGUMENT',
65
65
  },
66
66
  ],
67
67
  examples: [
@@ -282,7 +282,7 @@ describe('gap-report control docs', () => {
282
282
  expect(help.stdout).toContain(text);
283
283
  }
284
284
  expect(option('--list-categories')).toContain(
285
- 'the component and the other gap-report options are ignored',
285
+ 'the component and the other gap-report options are refused with ERR_INVALID_ARGUMENT',
286
286
  );
287
287
 
288
288
  const cwd = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-gap-limits-'));
@@ -328,6 +328,6 @@ describe('gap-report control docs', () => {
328
328
  }
329
329
  await expect(
330
330
  gapReport(undefined, {listCategories: true, category: 'not_real', package: 'nope'}),
331
- ).resolves.toMatchObject({type: 'gap-report.categories'});
331
+ ).rejects.toMatchObject({code: 'ERR_INVALID_ARGUMENT'});
332
332
  });
333
333
  });
@@ -27,13 +27,13 @@ export const doc = {
27
27
  param: 'options.features',
28
28
  description:
29
29
  'Comma-separated features: agents (agent docs), theme (writes theme.template.ts), template (prints the page-building commands; writes no file). ' +
30
- 'An unknown feature exits 1 with ERR_UNKNOWN_FEATURE. Ignored with --all or --remove-agents',
30
+ 'An unknown feature exits 1 with ERR_UNKNOWN_FEATURE. Refused with --all or --remove-agents',
31
31
  },
32
32
  {
33
33
  flag: '--all',
34
34
  param: 'options.all',
35
35
  description:
36
- 'Install all features (agents, theme, template); overrides --features. Prints their guidance instead of the getting-started steps',
36
+ 'Install all features (agents, theme, template); refused with --features. Prints their guidance instead of the getting-started steps',
37
37
  },
38
38
  {
39
39
  flag: '--remove-agents',
@@ -41,7 +41,7 @@ export const doc = {
41
41
  description:
42
42
  'Remove the managed block from AGENTS.md, CLAUDE.md, .claude/CLAUDE.md, .cursorrules, .hermes.md and HERMES.md ' +
43
43
  "(deleting AGENTS.md or .claude/CLAUDE.md when only init's heading is left) and do nothing else. " +
44
- '--features, --all, --agent and --agent-docs-path are ignored; a file written with --agent-docs-path keeps its block',
44
+ '--features, --all, --agent and --agent-docs-path are refused; a file written with --agent-docs-path keeps its block',
45
45
  },
46
46
  {
47
47
  flag: '--agent <tool>',
@@ -74,7 +74,7 @@ export const doc = {
74
74
  },
75
75
  {
76
76
  code: 1,
77
- when: 'an unknown --agent or feature, or an --agent-docs-path outside the project',
77
+ when: 'an unknown --agent or feature, an --agent-docs-path outside the project, --remove-agents combined with install options, or --all with --features (ERR_INVALID_ARGUMENT)',
78
78
  },
79
79
  ],
80
80
  related: ['doctor', 'upgrade', 'build', 'theme'],
@@ -66,7 +66,7 @@ describe('astryx init flag interactions', () => {
66
66
  for (const file of ['AGENTS.md', '.claude/CLAUDE.md', '.cursorrules', '.hermes.md', 'HERMES.md']) {
67
67
  expect(help).toContain(file);
68
68
  }
69
- expect(help).toMatch(/--agent-docs-path keeps its block/);
69
+ expect(help).toMatch(/--agent-docs-path are refused/);
70
70
 
71
71
  await initJson(['--agent-docs-path', 'docs/AI.md']);
72
72
  await initJson([]);
@@ -82,22 +82,19 @@ describe('astryx init flag interactions', () => {
82
82
  '--agent-docs-path',
83
83
  'docs/AI.md',
84
84
  ]);
85
- expect(removed.status).toBe(0);
86
- expect(removed.envelope.type).toBe('init.remove');
87
- expect(exists('AGENTS.md')).toBe(false);
88
- expect(exists('theme.template.ts')).toBe(false);
89
- expect(read('docs/AI.md')).toContain(MARKER_START);
85
+ expect(removed.status).toBe(1);
86
+ expect(removed.envelope.code).toBe('ERR_INVALID_ARGUMENT');
90
87
  });
91
88
 
92
89
  it('--all: help says it overrides --features, and an unknown feature beside it is not checked', async () => {
93
90
  const options = await initOptions();
94
- expect(options['--all']).toMatch(/overrides --features/);
95
- expect(options['--features']).toMatch(/Ignored with --all or --remove-agents/);
91
+ expect(options['--all']).toMatch(/refused with --features/);
92
+ expect(options['--features']).toMatch(/Refused with --all or --remove-agents/);
96
93
  expect(options['--features']).toContain('ERR_UNKNOWN_FEATURE');
97
94
 
98
95
  const {status, envelope} = await initJson(['--all', '--features', 'bogus']);
99
- expect(status).toBe(0);
100
- expect(envelope.data.features).toEqual(['agents', 'theme', 'template']);
96
+ expect(status).toBe(1);
97
+ expect(envelope.code).toBe('ERR_INVALID_ARGUMENT');
101
98
  });
102
99
 
103
100
  it('--agent and --agent-docs-path: help states their scope and precedence, and the CLI follows it', async () => {
@@ -101,7 +101,7 @@ export function registerIntegration(program) {
101
101
  // still parses its own options.
102
102
  integration.allowUnknownOption(true);
103
103
 
104
- defineCommand(integration, integrationAddCommand, {
104
+ const addCmd = defineCommand(integration, integrationAddCommand, {
105
105
  fn: integrationAddFn,
106
106
  action: async (kind, name, options) => {
107
107
  const json = program.opts().json || false;
@@ -157,6 +157,7 @@ export function registerIntegration(program) {
157
157
  return NO_RESULT_SET;
158
158
  },
159
159
  });
160
+ addCmd.allowExcessArguments(false);
160
161
 
161
162
  defineCommand(integration, integrationVerifyCommand, {
162
163
  fn: integrationPackCheckFn,
@@ -0,0 +1,37 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ import {describe, it, expect, beforeEach, afterEach} from 'vitest';
3
+ import * as fs from 'node:fs'; import * as os from 'node:os'; import * as path from 'node:path';
4
+ import {runCli} from '../../../test-utils/run-cli.mjs';
5
+ let dir;
6
+ beforeEach(() => { dir = fs.mkdtempSync(path.join(os.tmpdir(),'astryx-op-')); fs.writeFileSync(path.join(dir,'package.json'),JSON.stringify({name:'s',version:'1.0.0',dependencies:{'@astryxdesign/core':'0.6.3'}})); const c=path.join(dir,'node_modules','@astryxdesign','core'); fs.mkdirSync(c,{recursive:true}); fs.writeFileSync(path.join(c,'package.json'),JSON.stringify({name:'@astryxdesign/core',version:'0.6.3'})); });
7
+ afterEach(() => fs.rmSync(dir, {recursive:true,force:true}));
8
+ const json = async a => { const {status,stdout}=await runCli(['--json',...a],{cwd:dir}); return {status,body:JSON.parse(stdout)}; };
9
+ describe('option-pair refusals (AST-042 FR5)', () => {
10
+ it('template --list + name', async () => { const {status,body}=await json(['template','ai-chat','--list']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });
11
+ it('template --list + path', async () => { const {status,body}=await json(['template','ai-chat','src/p.tsx','--list']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });
12
+ it('template --list + --skeleton', async () => { const {status,body}=await json(['template','--list','--skeleton']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });
13
+ it('template --cdn + --list', async () => { const {status,body}=await json(['template','--cdn','--list']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });
14
+ it('template --cdn + name', async () => { const {status,body}=await json(['template','ai-chat','--cdn']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });
15
+ it('template --cdn + --type', async () => { const {status,body}=await json(['template','--cdn','--type','page']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });
16
+ it('template --cdn + --package', async () => { const {status,body}=await json(['template','--cdn','--package','@astryxdesign/core']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });
17
+ it('template --skeleton + --overwrite', async () => { const {status,body}=await json(['template','ai-chat','--skeleton','--overwrite']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });
18
+ it('upgrade --list + --from', async () => { const {status,body}=await json(['upgrade','--list','--from','0.5.0']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });
19
+ it('upgrade --list + --force', async () => { const {status,body}=await json(['upgrade','--list','--force']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });
20
+ it('upgrade --list + --apply', async () => { const {status,body}=await json(['upgrade','--list','--apply']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });
21
+ it('upgrade --list + --path', async () => { const {status,body}=await json(['upgrade','--list','--path','../x']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });
22
+ it('upgrade --list + --codemod', async () => { const {status,body}=await json(['upgrade','--list','--codemod','x']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });
23
+ it('upgrade --list + --skip-codemod', async () => { const {status,body}=await json(['upgrade','--list','--skip-codemod','x']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });
24
+ it('upgrade --list + --integration', async () => { const {status,body}=await json(['upgrade','--list','--integration','@acme/x']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });
25
+ it('upgrade --list + --install-deps', async () => { const {status,body}=await json(['upgrade','--list','--install-deps']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });
26
+ it('init --remove-agents + --features', async () => { const {status,body}=await json(['init','--remove-agents','--features','agents']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });
27
+ it('init --remove-agents + --all', async () => { const {status,body}=await json(['init','--remove-agents','--all']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });
28
+ it('init --remove-agents + --agent', async () => { const {status,body}=await json(['init','--remove-agents','--agent','claude']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });
29
+ it('init --remove-agents + --agent-docs-path', async () => { const {status,body}=await json(['init','--remove-agents','--agent-docs-path','docs/AI.md']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });
30
+ it('init --all + --features', async () => { const {status,body}=await json(['init','--all','--features','agents']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });
31
+ it('gap-report --list-categories + component', async () => { const {status,body}=await json(['gap-report','Button','--list-categories']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });
32
+ it('gap-report --list-categories + --category', async () => { const {status,body}=await json(['gap-report','--list-categories','--category','docs_gap']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });
33
+ it('gap-report --list-categories + --reason', async () => { const {status,body}=await json(['gap-report','--list-categories','--reason','test']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });
34
+ it('gap-report --list-categories + --package', async () => { const {status,body}=await json(['gap-report','--list-categories','--package','@acme/x']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });
35
+ it('gap-report --list-categories + --additional-context', async () => { const {status,body}=await json(['gap-report','--list-categories','--additional-context','extra']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });
36
+ it('gap-report --list-categories + --confirm-public', async () => { const {status,body}=await json(['gap-report','--list-categories','--confirm-public']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });
37
+ });
@@ -0,0 +1,15 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ import {describe, it, expect, beforeEach, afterEach} from 'vitest';
3
+ import * as fs from 'node:fs'; import * as os from 'node:os'; import * as path from 'node:path';
4
+ import {runCli} from '../../../test-utils/run-cli.mjs';
5
+ let dir;
6
+ beforeEach(() => { dir = fs.mkdtempSync(path.join(os.tmpdir(),'astryx-ss-')); fs.writeFileSync(path.join(dir,'package.json'),JSON.stringify({name:'s',version:'1.0.0',dependencies:{'@astryxdesign/core':'0.6.3'}})); const c=path.join(dir,'node_modules','@astryxdesign','core'); fs.mkdirSync(c,{recursive:true}); fs.writeFileSync(path.join(c,'package.json'),JSON.stringify({name:'@astryxdesign/core',version:'0.6.3'})); });
7
+ afterEach(() => fs.rmSync(dir, {recursive:true,force:true}));
8
+ const json = async a => { const {status,stdout}=await runCli(['--json',...a],{cwd:dir}); return {status,body:JSON.parse(stdout)}; };
9
+ describe('refuse invalid input (IFIX-0007)', () => {
10
+ it('template --type bogus', async () => { const {status,body}=await json(['template','--list','--type','bogus']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });
11
+ it('template --package @nope/x', async () => { const {status,body}=await json(['template','--list','--package','@nope/x']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });
12
+ it('template valid type+package filter keeps the matching templates', async () => { const {status,body}=await json(['template','--list','--type','block','--package','@astryxdesign/core']); expect(status).toBe(0); expect(body.type).toBe('template.list'); expect(body.data.length).toBeGreaterThan(0); expect(body.data.every(t => t.type === 'block')).toBe(true); });
13
+ it('build --limit 2.5', async () => { const {status,body}=await json(['build','pricing','--limit','2.5']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });
14
+ it('integration add excess args', async () => { fs.writeFileSync(path.join(dir,'package.json'),JSON.stringify({name:'@t/p',version:'1.0.0'})); const {status}=await json(['integration','add','agent-doc','Run','acme','verify']); expect(status).toBe(1); });
15
+ });
@@ -46,7 +46,7 @@ export const doc = {
46
46
  flag: '--list',
47
47
  param: 'options.list',
48
48
  description:
49
- 'List available templates (narrow with --type and --package) and do nothing else: <name>, <path>, --skeleton and --overwrite are ignored',
49
+ 'List available templates (narrow with --type and --package) and do nothing else: <name>, <path>, --skeleton and --overwrite are refused',
50
50
  },
51
51
  {
52
52
  flag: '--type <type>',
@@ -65,13 +65,13 @@ export const doc = {
65
65
  param: 'options.skeleton',
66
66
  description:
67
67
  'Show layout skeleton with spatial annotations (padding, gap, nesting) instead of the source. Needs <name>. ' +
68
- 'It writes nothing, so <path> and --overwrite are ignored; --list and --cdn take precedence',
68
+ 'It writes nothing, so <path> and --overwrite are refused with ERR_INVALID_ARGUMENT',
69
69
  },
70
70
  {
71
71
  flag: '--cdn [path]',
72
72
  param: 'options.cdn',
73
73
  description:
74
- 'Write the no-build-step CDN starter page and do nothing else: <name>, --list, --skeleton, --type and --package are ignored. ' +
74
+ 'Write the no-build-step CDN starter page and do nothing else: <name>, --list, --skeleton, --type and --package are refused. ' +
75
75
  'The page goes to the --cdn value, else to <path>, else cdn.template.html, and that path is always the file itself. ' +
76
76
  'A value right after --cdn (anything not starting with -) is taken as that path',
77
77
  },
@@ -109,7 +109,7 @@ export const doc = {
109
109
  },
110
110
  {
111
111
  code: 1,
112
- when: 'unknown or ambiguous template, no source, a path escape, or an existing target without --overwrite',
112
+ when: 'unknown or ambiguous template, no source, a path escape, an existing target without --overwrite, or --list with a type outside page or block or a package that provides no templates',
113
113
  },
114
114
  ],
115
115
  related: ['component', 'search', 'discover', 'init'],
@@ -56,12 +56,12 @@ async function templateJson(args) {
56
56
  }
57
57
 
58
58
  describe('astryx template flag precedence', () => {
59
- it('--list: help says <name>, <path>, --skeleton and --overwrite are ignored, and they are', async () => {
59
+ it('--list: help says <name>, <path>, --skeleton and --overwrite are refused, and they are', async () => {
60
60
  const help = (await templateOptions())['--list'];
61
61
  for (const ignored of ['<name>', '<path>', '--skeleton', '--overwrite']) {
62
62
  expect(help).toContain(ignored);
63
63
  }
64
- expect(help).toMatch(/are ignored/);
64
+ expect(help).toMatch(/are refused/);
65
65
 
66
66
  const {status, envelope} = await templateJson([
67
67
  'dashboard',
@@ -70,22 +70,25 @@ describe('astryx template flag precedence', () => {
70
70
  '--skeleton',
71
71
  '--overwrite',
72
72
  ]);
73
- expect(status).toBe(0);
74
- expect(envelope.type).toBe('template.list');
75
- expect(written()).toEqual([]);
73
+ expect(status).toBe(1);
74
+ expect(envelope.code).toBe('ERR_INVALID_ARGUMENT');
76
75
  }, SLOW);
77
76
 
78
77
  it('--skeleton: help says it needs <name> and writes nothing, and it does', async () => {
79
78
  const help = (await templateOptions())['--skeleton'];
80
79
  expect(help).toMatch(/Needs <name>/);
81
- expect(help).toMatch(/writes nothing, so <path> and --overwrite are ignored/);
82
- expect(help).toMatch(/--list and --cdn take precedence/);
80
+ expect(help).toMatch(/writes nothing, so <path> and --overwrite are refused/);
81
+ // --list and --cdn are now refused, not precedence
83
82
 
84
- const shown = await templateJson(['dashboard', './src/page.tsx', '--skeleton', '--overwrite']);
83
+ const shown = await templateJson(['dashboard', '--skeleton']);
85
84
  expect(shown.status).toBe(0);
86
85
  expect(shown.envelope.type).toBe('template.skeleton');
87
86
  expect(written()).toEqual([]);
88
87
 
88
+ const refused = await templateJson(['dashboard', './src/page.tsx', '--skeleton', '--overwrite']);
89
+ expect(refused.status).toBe(1);
90
+ expect(refused.envelope.code).toBe('ERR_INVALID_ARGUMENT');
91
+
89
92
  const nameless = await templateJson(['--skeleton']);
90
93
  expect(nameless.status).toBe(1);
91
94
  expect(nameless.envelope.code).toBe('ERR_UNKNOWN_TEMPLATE');
@@ -101,11 +104,15 @@ describe('astryx template flag precedence', () => {
101
104
  expect(help).toMatch(/value right after --cdn/);
102
105
 
103
106
  const everything = await templateJson(['dashboard', '--list', '--skeleton', '--type', 'bogus', '--cdn']);
104
- expect(everything.envelope.type).toBe('template.cdn');
105
- expect(everything.envelope.data.path).toBe('cdn.template.html');
107
+ expect(everything.status).toBe(1);
108
+ expect(everything.envelope.code).toBe('ERR_INVALID_ARGUMENT');
109
+
110
+ const bare = await templateJson(['--cdn']);
111
+ expect(bare.envelope.type).toBe('template.cdn');
112
+ expect(bare.envelope.data.path).toBe('cdn.template.html');
106
113
 
107
114
  // A bare --cdn writes to <path>, and a path with no extension is still the file.
108
- const positional = await templateJson(['dashboard', 'demo', '--cdn']);
115
+ const positional = await templateJson(['--cdn', 'demo']);
109
116
  expect(positional.envelope.data.path).toBe('demo');
110
117
  expect(fs.statSync(path.join(tmpDir, 'demo')).isFile()).toBe(true);
111
118
 
@@ -394,23 +394,6 @@ const CASES = [
394
394
  args: ['integration', 'pack', '--check'],
395
395
  skipFieldChecks: true,
396
396
  },
397
- // ── Layout command: remove these cases when the layout command is deleted ──
398
- {
399
- name: 'layout check',
400
- args: ['layout', 'check', 'Button'],
401
- skipFieldChecks: true,
402
- },
403
- {
404
- name: 'layout expand',
405
- args: ['layout', 'expand', 'Button'],
406
- skipFieldChecks: true,
407
- },
408
- {
409
- name: 'layout grammar',
410
- args: ['layout', 'grammar'],
411
- skipFieldChecks: true,
412
- },
413
- // ── End layout cases ──
414
397
  {
415
398
  name: 'manifest',
416
399
  args: ['manifest'],
@@ -90,7 +90,7 @@ export const doc = {
90
90
  flag: '--list',
91
91
  param: 'options.list',
92
92
  description:
93
- 'List available codemods and do nothing else. Every other flag is ignored, except --registry, which is refused (exit 1)',
93
+ 'List available codemods and do nothing else. Every other flag is refused, as is --registry (exit 1)',
94
94
  default: false,
95
95
  },
96
96
  ],
@@ -79,22 +79,18 @@ const MIGRATION_FLAGS = [
79
79
  describe('astryx upgrade flag interactions', () => {
80
80
  it('--list: help says it ignores every other flag but --registry, and it does', async () => {
81
81
  const options = await upgradeOptions();
82
- expect(options['--list']).toMatch(/Every other flag is ignored, except --registry/);
82
+ expect(options['--list']).toMatch(/Every other flag is refused, as is --registry/);
83
83
 
84
84
  installPackage('@astryxdesign/core', '0.6.0');
85
- const listed = await upgradeJson([
86
- '--list',
87
- '--from',
88
- 'bogus',
89
- '--codemod',
90
- 'bogus',
91
- '--apply',
92
- '--path',
93
- '../outside',
94
- ]);
85
+
86
+ const listed = await upgradeJson(['--list']);
95
87
  expect(listed.status).toBe(0);
96
88
  expect(listed.envelope.type).toBe('upgrade.list');
97
89
 
90
+ const withFlags = await upgradeJson(['--list', '--from', 'bogus']);
91
+ expect(withFlags.status).toBe(1);
92
+ expect(withFlags.envelope.code).toBe('ERR_INVALID_ARGUMENT');
93
+
98
94
  const refused = await upgradeJson(['--list', '--registry']);
99
95
  expect(refused.status).toBe(1);
100
96
  expect(refused.envelope.code).toBe('ERR_INVALID_ARGUMENT');
@@ -0,0 +1,67 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ import {describe, it, expect, beforeEach, afterEach} from 'vitest';
3
+ import * as fs from 'node:fs'; import * as os from 'node:os'; import * as path from 'node:path';
4
+ import {runCli} from '../../../test-utils/run-cli.mjs';
5
+ import {validateIntegration} from '../../../api/integration/validate-integration.mjs';
6
+ import {integrationTemplateConflicts, integrationComponentConflicts, integrationDocConflicts} from '../../../api/integration/authoring-checks.mjs';
7
+ let dir;
8
+ beforeEach(() => { dir = fs.mkdtempSync(path.join(os.tmpdir(),'astryx-val-')); });
9
+ afterEach(() => fs.rmSync(dir, {recursive:true,force:true}));
10
+ const json = async a => { const {status,stdout}=await runCli(['--json',...a],{cwd:dir}); return {status,body:JSON.parse(stdout)}; };
11
+ const text = async a => runCli(a, {cwd: dir});
12
+
13
+ describe('doctor integration validate exit codes (IFIX-0008)', () => {
14
+ it('exits 1 with no package.json (JSON has no_package issue)', async () => {
15
+ const {status, body} = await json(['doctor','integration','validate']);
16
+ expect(status).toBe(1);
17
+ expect(body.data.validated).toBe(false);
18
+ expect(body.data.issues).toEqual([
19
+ expect.objectContaining({code: 'no_package', severity: 'error'}),
20
+ ]);
21
+ });
22
+
23
+ it('text mode says no package.json when there is none', async () => {
24
+ const {status, stdout} = await text(['doctor','integration','validate']);
25
+ expect(status).toBe(1);
26
+ expect(stdout).toContain('no package.json found');
27
+ });
28
+
29
+ it('exits 0 with package.json but no manifest (byte-identical to published)', async () => {
30
+ fs.writeFileSync(path.join(dir,'package.json'), JSON.stringify({name:'myapp',version:'1.0.0'}));
31
+ const {status, body} = await json(['doctor','integration','validate']);
32
+ expect(status).toBe(0);
33
+ expect(body.data).toEqual({validated: false, name: null, version: null, issues: []});
34
+ });
35
+
36
+ it('text mode says no manifest when package.json exists', async () => {
37
+ fs.writeFileSync(path.join(dir,'package.json'), JSON.stringify({name:'myapp',version:'1.0.0'}));
38
+ const {status, stdout} = await text(['doctor','integration','validate']);
39
+ expect(status).toBe(0);
40
+ expect(stdout).toContain('no astryx.integration');
41
+ });
42
+
43
+ it('exported API returns the no_package issue', async () => {
44
+ const result = await validateIntegration(undefined, {cwd: dir});
45
+ expect(result.type).toBe('integration.validate');
46
+ expect(result.data.validated).toBe(false);
47
+ expect(result.data.issues).toEqual([
48
+ expect.objectContaining({code: 'no_package', severity: 'error'}),
49
+ ]);
50
+ });
51
+
52
+ it('integration verify exits 1 with a data envelope', async () => {
53
+ const {status, body} = await json(['integration','verify']);
54
+ expect(status).toBe(1);
55
+ expect(body.type).toBe('integration.pack-check');
56
+ expect(body.data.issues.some(i => i.code === 'no_package')).toBe(true);
57
+ });
58
+
59
+ it('sibling commands stay unchanged with no package.json', async () => {
60
+ for (const sub of ['templates', 'components', 'docs']) {
61
+ const {status, body} = await json(['doctor','integration', sub]);
62
+ expect(status, `doctor integration ${sub}`).toBe(0);
63
+ expect(body.data.validated).toBe(false);
64
+ expect(body.data.issues).toEqual([]);
65
+ }
66
+ });
67
+ });