@astryxdesign/cli 0.7.0-canary.db75a96 → 0.7.0-canary.de3959f

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 (181) hide show
  1. package/README.md +30 -33
  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/doctor/doctor.doc.mjs +1 -1
  8. package/api/doctor/doctor.test.mjs +28 -0
  9. package/api/doctor/theme-checks.mjs +10 -10
  10. package/api/doctor/theme-checks.test.mjs +5 -4
  11. package/api/gap-report/gap-report.doc.mjs +1 -1
  12. package/api/gap-report/gap-report.mjs +15 -0
  13. package/api/gap-report/gap-report.test.mjs +1 -1
  14. package/api/index.d.mts +0 -2
  15. package/api/index.mjs +0 -2
  16. package/api/init/init.doc.mjs +5 -1
  17. package/api/init/init.mjs +22 -0
  18. package/api/init/init.type.d.mts +4 -1
  19. package/api/init/init.type.mjs +1 -1
  20. package/api/init/remove/remove.mjs +8 -3
  21. package/api/init/remove/remove.test.mjs +12 -0
  22. package/api/init/run/run.d.mts +1 -1
  23. package/api/init/run/run.mjs +3 -3
  24. package/api/integration/validate-integration.d.mts +4 -0
  25. package/api/integration/validate-integration.mjs +5 -2
  26. package/api/integration/validateIntegration.doc.mjs +1 -1
  27. package/api/json/index.ts +0 -1
  28. package/api/search/search.doc.mjs +1 -1
  29. package/api/search/search.mjs +1 -1
  30. package/api/search/search.test.mjs +1 -1
  31. package/api/search/search.type.d.mts +1 -1
  32. package/api/search/search.type.mjs +1 -1
  33. package/api/template/list/list.mjs +23 -2
  34. package/api/template/list/list.test.mjs +52 -0
  35. package/api/template/template-integration.test.mjs +37 -100
  36. package/api/template/template.doc.mjs +7 -2
  37. package/api/template/template.mjs +45 -0
  38. package/api/theme/_adapter.mjs +3 -3
  39. package/api/theme/add/add.d.mts +11 -5
  40. package/api/theme/add/add.mjs +19 -192
  41. package/api/theme/add/add.test.mjs +68 -258
  42. package/api/theme/add/add.types.test.mjs +0 -1
  43. package/api/theme/build/build.d.mts +3 -3
  44. package/api/theme/build/build.mjs +22 -36
  45. package/api/theme/build/build.test.mjs +11 -24
  46. package/api/theme/eject/eject.copy-compat.test.mjs +168 -0
  47. package/api/theme/integration-themes.test.mjs +3 -3
  48. package/api/theme/remove/remove.test.mjs +1 -1
  49. package/api/theme/targets/targets.test.mjs +0 -4
  50. package/api/theme/template/template.mjs +1 -1
  51. package/api/theme/theme.type.d.mts +1 -30
  52. package/api/theme/theme.type.mjs +3 -13
  53. package/api/theme/themeAdd.doc.mjs +19 -27
  54. package/api/theme/themeTargets.doc.mjs +3 -4
  55. package/api/theme/themeTemplate.doc.mjs +1 -1
  56. package/api/theme/use/use.test.mjs +1 -1
  57. package/api/upgrade/upgrade.doc.mjs +1 -1
  58. package/api/upgrade/upgrade.mjs +19 -0
  59. package/assets/codemods/transforms/next/README.md +15 -17
  60. package/assets/codemods/transforms/next/__tests__/migrate-deprecated-theme-surface.test.mjs +322 -0
  61. package/assets/codemods/transforms/next/index.mjs +11 -1
  62. package/assets/codemods/transforms/next/migrate-deprecated-theme-surface-v0.6-data.mjs +229 -0
  63. package/assets/codemods/transforms/next/migrate-deprecated-theme-surface.mjs +624 -0
  64. package/assets/codemods/transforms/v0.6.0/migrate-astryx-theme-selectors-to-data-attrs.mjs +38 -18
  65. package/assets/docs/author-a-theme.doc.mjs +4 -4
  66. package/assets/docs/getting-started.doc.mjs +2 -2
  67. package/assets/docs/theme.doc.dense.mjs +1 -1
  68. package/assets/docs/theme.doc.mjs +2 -2
  69. package/assets/docs/tree/add-a-theme.doc.mjs +1 -1
  70. package/assets/docs/tree/document-the-theme.doc.mjs +2 -2
  71. package/assets/docs/tree/fonts-and-assets.doc.mjs +3 -3
  72. package/assets/docs/tree/styling-advanced.doc.mjs +21 -14
  73. package/assets/docs/tree/themes.doc.mjs +1 -1
  74. package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +2 -2
  75. package/assets/docs/tree/versioning.doc.mjs +1 -4
  76. package/assets/docs/use-a-theme.doc.mjs +16 -16
  77. package/assets/templates/themes/neutral/neutralPaletteRefs.generated.ts +10 -9
  78. package/authoring/debug/type.ts +2 -2
  79. package/authoring/doctypes/base/type.ts +0 -9
  80. package/authoring/integration/integration.doc.mjs +1 -1
  81. package/clients/cli/command-result-coverage.test.mjs +1 -1
  82. package/clients/cli/commands/build-theme.adaptations.test.mjs +4 -0
  83. package/clients/cli/commands/build-theme.ascii-output.test.mjs +35 -8
  84. package/clients/cli/commands/build-theme.mjs +31 -67
  85. package/clients/cli/commands/build-theme.registry.test.mjs +0 -10
  86. package/clients/cli/commands/build.doc.mjs +1 -1
  87. package/clients/cli/commands/build.mjs +1 -1
  88. package/clients/cli/commands/component-ownership.test.mjs +2 -2
  89. package/clients/cli/commands/debug-result-summary.test.mjs +0 -16
  90. package/clients/cli/commands/discover.mjs +2 -1
  91. package/clients/cli/commands/doctor.mjs +5 -2
  92. package/clients/cli/commands/empty-argument.test.mjs +16 -0
  93. package/clients/cli/commands/gap-report.doc.mjs +1 -1
  94. package/clients/cli/commands/gap-report.test.mjs +2 -2
  95. package/clients/cli/commands/init.doc.mjs +4 -4
  96. package/clients/cli/commands/init.flag-help.test.mjs +7 -10
  97. package/clients/cli/commands/init.next-steps.test.mjs +1 -1
  98. package/clients/cli/commands/integration.mjs +2 -1
  99. package/clients/cli/commands/option-pair-refusals.test.mjs +37 -0
  100. package/clients/cli/commands/search.test.mjs +1 -1
  101. package/clients/cli/commands/silent-success-refusals.test.mjs +15 -0
  102. package/clients/cli/commands/swizzle.mjs +4 -1
  103. package/clients/cli/commands/template.doc.mjs +4 -4
  104. package/clients/cli/commands/template.flag-help.test.mjs +18 -11
  105. package/clients/cli/commands/template.mjs +7 -1
  106. package/clients/cli/commands/text-json-parity.test.mjs +0 -17
  107. package/clients/cli/commands/theme-add-lifecycle.test.mjs +142 -49
  108. package/clients/cli/commands/theme-add.doc.mjs +10 -17
  109. package/clients/cli/commands/theme-list.behavior.test.mjs +2 -1
  110. package/clients/cli/commands/theme-targets.behavior.test.mjs +8 -6
  111. package/clients/cli/commands/theme-template.doc.mjs +1 -1
  112. package/clients/cli/commands/theme.doc.mjs +2 -2
  113. package/clients/cli/commands/upgrade.doc.mjs +1 -1
  114. package/clients/cli/commands/upgrade.flag-help.test.mjs +7 -11
  115. package/clients/cli/commands/validate-nothing-exits-nonzero.test.mjs +67 -0
  116. package/clients/cli/index.mjs +0 -4
  117. package/clients/cli/lib/cli-error.mjs +19 -0
  118. package/clients/cli/lib/component-format.mjs +111 -57
  119. package/clients/cli/lib/component-format.test.mjs +28 -39
  120. package/clients/cli/lib/doc-text-ascii.test.mjs +5 -2
  121. package/clients/cli/lib/exit-codes.test.mjs +0 -7
  122. package/clients/cli/lib/json-shim.test.mjs +0 -24
  123. package/foundation/agent-docs/agent-docs.d.mts +2 -1
  124. package/foundation/agent-docs/agent-docs.mjs +6 -1
  125. package/foundation/agent-docs/app-theme-workflow.test.mjs +3 -0
  126. package/foundation/config/theme-state.mjs +3 -3
  127. package/foundation/debug/debug-fields.test.mjs +13 -35
  128. package/foundation/debug/event.mjs +13 -78
  129. package/foundation/debug/privacy-contract.test.mjs +20 -12
  130. package/foundation/debug/redact.d.mts +2 -2
  131. package/foundation/debug/redact.mjs +2 -2
  132. package/foundation/discovery/theme-imports.mjs +1 -1
  133. package/foundation/discovery/theming-targets.d.mts +1 -20
  134. package/foundation/discovery/theming-targets.mjs +1 -38
  135. package/foundation/discovery/theming-targets.test.mjs +9 -175
  136. package/foundation/doc-compiler/doc-loads.test.mjs +0 -12
  137. package/foundation/response/error-codes.doc.mjs +1 -1
  138. package/foundation/response/response-types.doc.mjs +11 -30
  139. package/foundation/response/response-types.doc.test.mjs +36 -14
  140. package/foundation/response/response.doc.mjs +1 -1
  141. package/foundation/xle/browser.d.mts +2 -2
  142. package/foundation/xle/browser.mjs +2 -2
  143. package/foundation/xle/expand.mjs +1 -1
  144. package/foundation/xle/print.mjs +1 -1
  145. package/package.json +9 -9
  146. package/api/layout/_adapter.d.mts +0 -34
  147. package/api/layout/_adapter.mjs +0 -148
  148. package/api/layout/check/check.d.mts +0 -17
  149. package/api/layout/check/check.mjs +0 -41
  150. package/api/layout/expand/expand.d.mts +0 -23
  151. package/api/layout/expand/expand.mjs +0 -161
  152. package/api/layout/expand/expand.path-safety.test.mjs +0 -53
  153. package/api/layout/expand/expand.receipt.test.mjs +0 -74
  154. package/api/layout/grammar/grammar.d.mts +0 -14
  155. package/api/layout/grammar/grammar.mjs +0 -88
  156. package/api/layout/layout.d.mts +0 -6
  157. package/api/layout/layout.mjs +0 -17
  158. package/api/layout/layout.test.mjs +0 -297
  159. package/api/layout/layout.type.d.mts +0 -90
  160. package/api/layout/layout.type.mjs +0 -104
  161. package/api/layout/layoutCheck.doc.d.mts +0 -11
  162. package/api/layout/layoutCheck.doc.mjs +0 -85
  163. package/api/layout/layoutExpand.doc.d.mts +0 -11
  164. package/api/layout/layoutExpand.doc.mjs +0 -107
  165. package/api/layout/layoutGrammar.doc.d.mts +0 -11
  166. package/api/layout/layoutGrammar.doc.mjs +0 -57
  167. package/api/theme/add/add.binary.test.mjs +0 -157
  168. package/api/theme/add/add.rollback.test.mjs +0 -158
  169. package/api/theme/add/add.staging.test.mjs +0 -83
  170. package/clients/cli/commands/layout-check.doc.mjs +0 -67
  171. package/clients/cli/commands/layout-expand.doc.mjs +0 -87
  172. package/clients/cli/commands/layout-grammar.doc.mjs +0 -32
  173. package/clients/cli/commands/layout.deprecation-lifecycle.test.mjs +0 -140
  174. package/clients/cli/commands/layout.doc.mjs +0 -36
  175. package/clients/cli/commands/layout.error-codes.test.mjs +0 -66
  176. package/clients/cli/commands/layout.exit-parity.test.mjs +0 -41
  177. package/clients/cli/commands/layout.expand-receipt.test.mjs +0 -94
  178. package/clients/cli/commands/layout.mjs +0 -327
  179. package/clients/cli/commands/layout.path-help.test.mjs +0 -33
  180. package/clients/cli/commands/layout.stdin-cap.test.mjs +0 -47
  181. package/clients/cli/commands/layout.text-fields.test.mjs +0 -39
@@ -71,9 +71,9 @@ function run(args) {
71
71
  }
72
72
 
73
73
  describe('theme command human output is plain ASCII', () => {
74
- it('a standalone build: ok, warning, error, notice, and font help lines', async () => {
74
+ it('a private-variable build keeps its output and exits 1', async () => {
75
75
  const short = await run(['build', 'ocean.mjs']);
76
- expect(short.code).toBe(0);
76
+ expect(short.code).toBe(1);
77
77
  expect(short.stdout).toContain(
78
78
  '[note] Fonts named but not loaded: "Inter"',
79
79
  );
@@ -84,19 +84,46 @@ describe('theme command human output is plain ASCII', () => {
84
84
  dir,
85
85
  );
86
86
 
87
- expect(result.code).toBe(0);
87
+ expect(result.code).toBe(1);
88
88
  expect(result.stdout).toContain('[ok] ocean.css');
89
- expect(result.stderr).toContain('[warn] Deprecated component target');
89
+ expect(result.stderr).toContain('[warn] Unknown component "progressbar"');
90
90
  expect(result.stderr).toContain('[error] Component "button"');
91
91
  expect(result.stdout).toContain('note: Font "Inter"');
92
92
  expect(result.stdout).toContain('[note] Theme "ocean" names fonts');
93
93
  expect(nonAscii(result)).toEqual([]);
94
94
  });
95
95
 
96
+ it('JSON build and check keep their receipts and exit 1', async () => {
97
+ const built = await runCli(['--json', 'theme', 'build', 'ocean.mjs'], dir);
98
+ expect(built.code).toBe(1);
99
+ expect(built.stderr).toBe('');
100
+ const receipt = JSON.parse(built.stdout);
101
+ expect(receipt.type).toBe('theme.build');
102
+ expect(receipt.data.name).toBe('ocean');
103
+ expect(receipt.data.warnings).toEqual(
104
+ expect.arrayContaining([expect.stringContaining('--_button-radius')]),
105
+ );
106
+
107
+ const checked = await runCli(
108
+ ['--json', 'theme', 'build', 'ocean.mjs', '--check'],
109
+ dir,
110
+ );
111
+ expect(checked.code).toBe(1);
112
+ expect(checked.stderr).toBe('');
113
+ expect(JSON.parse(checked.stdout)).toMatchObject({
114
+ type: 'theme.build.check',
115
+ data: {name: 'ocean', upToDate: true, stale: []},
116
+ });
117
+
118
+ for (const extension of ['css', 'css.d.ts', 'js', 'd.ts']) {
119
+ expect(fs.existsSync(path.join(dir, `ocean.${extension}`))).toBe(true);
120
+ }
121
+ });
122
+
96
123
  it('--check, up to date and stale', async () => {
97
124
  await run(['build', 'ocean.mjs']);
98
125
  const upToDate = await run(['build', 'ocean.mjs', '--check']);
99
- expect(upToDate.code).toBe(0);
126
+ expect(upToDate.code).toBe(1);
100
127
  expect(upToDate.stdout).toContain('[ok] Theme outputs are up to date');
101
128
  expect(nonAscii(upToDate)).toEqual([]);
102
129
 
@@ -109,7 +136,7 @@ describe('theme command human output is plain ASCII', () => {
109
136
 
110
137
  it('a batch build and check', async () => {
111
138
  const built = await run(['build', 'ocean.mjs', 'ocean-calm.mjs']);
112
- expect(built.code).toBe(0);
139
+ expect(built.code).toBe(1);
113
140
  expect(built.stdout).toContain('[ok] Built 2 themes.');
114
141
  expect(nonAscii(built)).toEqual([]);
115
142
 
@@ -119,7 +146,7 @@ describe('theme command human output is plain ASCII', () => {
119
146
  'ocean-calm.mjs',
120
147
  '--check',
121
148
  ]);
122
- expect(checked.code).toBe(0);
149
+ expect(checked.code).toBe(1);
123
150
  expect(checked.stdout).toContain('[ok] Checked 2 themes.');
124
151
  expect(nonAscii(checked)).toEqual([]);
125
152
  });
@@ -134,7 +161,7 @@ describe('theme command human output is plain ASCII', () => {
134
161
  'ocean-family',
135
162
  ];
136
163
  const built = await run(familyArgs);
137
- expect(built.code).toBe(0);
164
+ expect(built.code).toBe(1);
138
165
  expect(built.stdout).toContain('[ok] ocean-family.css');
139
166
  expect(nonAscii(built)).toEqual([]);
140
167
 
@@ -6,9 +6,11 @@
6
6
  * Thin CLI wrapper. The `build` compiler lives in the programmatic API
7
7
  * (../../api/theme/build/build.mjs); `list`/`add` delegate to the
8
8
  * ../../api/theme/list/list.mjs and ../../api/theme/add/add.mjs leaves. This
9
- * file only parses options, injects a logger, renders human output, and maps
10
- * AstryxError → cliError. Watch mode (a human-interactive, long-running loop)
11
- * stays here because it re-invokes `theme build` as a child process.
9
+ * file only parses options, injects a logger, renders human output, maps
10
+ * AstryxError → cliError, and turns reported private-variable errors into exit 1
11
+ * after preserving the build output. Watch mode (a human-interactive,
12
+ * long-running loop) stays here because it re-invokes `theme build` as a child
13
+ * process.
12
14
  *
13
15
  * The command surface (group + subcommand descriptions, args, flags) is sourced
14
16
  * from the colocated CommandDocs via `defineCommand`; this file supplies only
@@ -62,7 +64,6 @@ import {
62
64
  themePaletteGenerate,
63
65
  } from '../../../api/theme/palette/generate/generate.mjs';
64
66
  import {
65
- importSpecifier,
66
67
  printBatchTrailer,
67
68
  printCompactTrailer,
68
69
  themeBuild,
@@ -230,8 +231,8 @@ async function warnOnThemeIntegrationIssues(json) {
230
231
  }
231
232
 
232
233
  /**
233
- * Print `theme add --list`. Its JSON stays the released `theme.list`; its text
234
- * names the commands of the current lifecycle stage (AST-050 FR12).
234
+ * Print cleanup-stage `theme add --list`. Its JSON stays the released
235
+ * `theme.list`; its text names the cleanup commands (AST-050 FR12).
235
236
  * @param {import('../../../api/theme/theme.type.mjs').ThemeListEntry[]} themes
236
237
  */
237
238
  function printThemeAddList(themes) {
@@ -255,7 +256,7 @@ function printThemeAddList(themes) {
255
256
  }),
256
257
  ),
257
258
  text(
258
- `Import one: ${run} theme add <slug> --import [--package <package>]\n` +
259
+ `Import one: ${run} theme add <slug> [--package <package>]\n` +
259
260
  `Fork source: ${run} theme eject <slug> [target-path]`,
260
261
  ),
261
262
  more,
@@ -297,7 +298,7 @@ function printThemeList(themes, unmigratedCopies = []) {
297
298
  },
298
299
  }),
299
300
  text(
300
- `Import one: ${run} theme add <slug> --import [--package <package>]\n` +
301
+ `Import one: ${run} theme add <slug> [--package <package>]\n` +
301
302
  `Fork source: ${run} theme eject <slug> [target-path]`,
302
303
  ),
303
304
  more,
@@ -633,6 +634,10 @@ export function registerTheme(program) {
633
634
  // [ok]/[warn] lines, and the install instructions are all emitted from
634
635
  // inside themeBuild via the shared logger.
635
636
  logger.setSilent(json);
637
+ let privateVarError = false;
638
+ const onPrivateVarError = () => {
639
+ privateVarError = true;
640
+ };
636
641
 
637
642
  if (options.family) {
638
643
  try {
@@ -642,11 +647,15 @@ export function registerTheme(program) {
642
647
  familyKey: /** @type {string} */ (options.familyKey),
643
648
  check: options.check,
644
649
  iconsSpecifier: options.iconsSpecifier,
650
+ __onPrivateVarError: onPrivateVarError,
645
651
  },
646
652
  {cwd: process.cwd()},
647
653
  );
648
654
  if (json) jsonOut(result);
649
- if (result.type === 'theme.build.check' && !result.data.upToDate) {
655
+ if (
656
+ privateVarError ||
657
+ (result.type === 'theme.build.check' && !result.data.upToDate)
658
+ ) {
650
659
  process.exitCode = 1;
651
660
  }
652
661
  return NO_RESULT_SET;
@@ -674,6 +683,7 @@ export function registerTheme(program) {
674
683
  out: options.out,
675
684
  check: options.check,
676
685
  iconsSpecifier: options.iconsSpecifier,
686
+ __onPrivateVarError: onPrivateVarError,
677
687
  };
678
688
  let result;
679
689
  if (report) {
@@ -753,10 +763,10 @@ export function registerTheme(program) {
753
763
  );
754
764
  }
755
765
 
756
- // In --check mode a stale/missing output is a failure: exit non-zero
757
- // (after emitting the receipt) so CI can gate on it. The receipt is
758
- // already printed above (shared logger or --json envelope).
759
- if (options.check && stale) {
766
+ // Private-variable diagnostics are build failures even though the released
767
+ // output and generated files stay unchanged. Stale --check output is also
768
+ // a failure after its receipt has been emitted.
769
+ if (privateVarError || (options.check && stale)) {
760
770
  process.exitCode = 1;
761
771
  }
762
772
 
@@ -801,15 +811,14 @@ export function registerTheme(program) {
801
811
  },
802
812
  });
803
813
 
804
- defineCommand(theme, themeAddCommand, {
814
+ const themeAddCli = defineCommand(theme, themeAddCommand, {
805
815
  fn: themeAddFn,
806
816
  action: async (
807
817
  /** @type {string | undefined} */ slug,
808
- /** @type {string | undefined} */ targetPath,
809
- /** @type {{list?: boolean, overwrite?: boolean, import?: boolean, package?: string}} */ options,
818
+ /** @type {{list?: boolean, import?: boolean, package?: string}} */ options,
810
819
  ) => {
811
820
  const json = program.opts().json || false;
812
- /** @type {import('../../../api/theme/theme.type.mjs').ThemeListResponse | import('../../../api/theme/theme.type.mjs').ThemeAddResponse | import('../../../api/theme/theme.type.mjs').ThemeAppResponse} */
821
+ /** @type {import('../../../api/theme/theme.type.mjs').ThemeListResponse | import('../../../api/theme/theme.type.mjs').ThemeAppResponse} */
813
822
  let result;
814
823
  try {
815
824
  result =
@@ -819,8 +828,6 @@ export function registerTheme(program) {
819
828
  package: options.package,
820
829
  })
821
830
  : await themeAdd(slug, {
822
- targetPath,
823
- overwrite: options.overwrite,
824
831
  import: options.import,
825
832
  cwd: process.cwd(),
826
833
  package: options.package,
@@ -848,44 +855,12 @@ export function registerTheme(program) {
848
855
  printThemeAddList(result.data);
849
856
  return answered;
850
857
  }
851
- if (result.type === 'theme.app') {
852
- printThemeApp(result);
853
- return answered;
854
- }
855
-
856
- const {
857
- displayName,
858
- outputDir,
859
- entry,
860
- exportName,
861
- files,
862
- package: owner,
863
- } = result.data;
864
- const entryModule = importSpecifier(
865
- outputDir,
866
- entry.replace(/\.tsx?$/, ''),
867
- );
868
- emit(
869
- text(`[ok] Added ${displayName} theme from ${owner} to ${outputDir}/`),
870
- list(files.map(file => `${outputDir}/${file}`)),
871
- text(
872
- 'Use it in your app (import path is relative to a file in src/ — adjust if yours lives elsewhere):',
873
- ),
874
- code(
875
- "import { Theme } from '@astryxdesign/core';\n" +
876
- `import { ${exportName} } from '${entryModule}';\n\n` +
877
- `<Theme theme={${exportName}}>\n <App />\n</Theme>`,
878
- ),
879
- text(
880
- `This is your copy of the ${displayName} theme — edit ${entry} to make it your own.`,
881
- ),
882
- );
883
- console.error(
884
- `Warning: \`theme add\` source copying is deprecated (DEP-0005). Run \`${getCliInvocation()} theme eject ${result.data.slug}\` to fork source or \`${getCliInvocation()} theme add ${result.data.slug} --import\` to use the built theme.`,
885
- );
858
+ printThemeApp(result);
886
859
  return answered;
887
860
  },
888
861
  });
862
+ // Reject the removed target-path argument in Commander's standard parse path.
863
+ themeAddCli.allowExcessArguments(false);
889
864
 
890
865
  defineCommand(theme, themeRemoveCommand, {
891
866
  fn: themeRemoveFn,
@@ -1062,22 +1037,11 @@ export function registerTheme(program) {
1062
1037
  emit(
1063
1038
  section(
1064
1039
  'Theming targets',
1065
- `${targets.length} across ${componentCount} component${componentCount === 1 ? '' : 's'}\n(key - component - props - states - className - deprecatedFor)`,
1040
+ `${targets.length} across ${componentCount} component${componentCount === 1 ? '' : 's'}\n(key - component - props - states - className)`,
1066
1041
  ),
1067
1042
  records(targets, {
1068
- fields: [
1069
- 'key',
1070
- 'component',
1071
- 'props',
1072
- 'states',
1073
- 'className',
1074
- 'deprecatedFor',
1075
- ],
1043
+ fields: ['key', 'component', 'props', 'states', 'className'],
1076
1044
  layout: 'inline',
1077
- format: {
1078
- deprecatedFor: (/** @type {string|null} */ v) =>
1079
- v ? `deprecated; use ${v}` : '',
1080
- },
1081
1045
  }),
1082
1046
  text(
1083
1047
  [
@@ -83,16 +83,6 @@ function renderedClassLiterals() {
83
83
  while ((sm = surfaceRe.exec(text)) !== null) {
84
84
  classes.add(sm[1]);
85
85
  }
86
- // Renamed targets emit their old name too, via themeProps'
87
- // `legacyNames`. Those classes are just as rendered as the primary
88
- // one, so a doc entry for the old name is still backed by real output.
89
- const legacyRe = /legacyNames:\s*\[([^\]]*)\]/g;
90
- let lm;
91
- while ((lm = legacyRe.exec(text)) !== null) {
92
- for (const nm of lm[1].matchAll(/'([^']+)'/g)) {
93
- classes.add(nm[1]);
94
- }
95
- }
96
86
  }
97
87
  }
98
88
  };
@@ -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 () => {
@@ -26,7 +26,7 @@ import {
26
26
  list,
27
27
  code,
28
28
  } from '../formatters/index.mjs';
29
- import {cliError} from '../lib/cli-error.mjs';
29
+ import {cliError, rejectEmptyArgument} from '../lib/cli-error.mjs';
30
30
  import {discover as discoverApi} from '../../../api/discover/discover.mjs';
31
31
  import {Project} from '../../../foundation/config/project.mjs';
32
32
  import {warnOnIntegrationIssues} from '../../../foundation/integrations/integration-warnings.mjs';
@@ -212,6 +212,7 @@ export function registerDiscover(program) {
212
212
  * @param {{components?: boolean, type?: string, installed?: boolean, available?: boolean, limit?: string}} options
213
213
  */
214
214
  async (query, options) => {
215
+ rejectEmptyArgument('query', query, 'astryx discover');
215
216
  const detail = program.opts().detail || 'full';
216
217
  const json = program.opts().json || false;
217
218
  const lang = program.opts().lang || null;
@@ -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);
@@ -0,0 +1,16 @@
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-ea-')); fs.writeFileSync(path.join(dir, 'package.json'), JSON.stringify({name:'s',version:'1.0.0',dependencies:{'@astryxdesign/core':'0.6.3'}})); fs.mkdirSync(path.join(dir,'src'),{recursive:true}); 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('an empty-string argument is rejected, not ignored', () => {
10
+ it.each([['template',['template','','src/z.tsx'],'name'],['template path',['template','ai-chat',''],'path'],['swizzle',['swizzle',''],'component'],['discover',['discover',''],'query']])('%s', async (_,args,an) => { const {status,body}=await json(args); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); expect(body.error).toContain(`<${an}>`); });
11
+ it('writes nothing', async () => { const b=fs.readdirSync(path.join(dir,'src')); await json(['template','ai-chat','']); expect(fs.readdirSync(path.join(dir,'src'))).toEqual(b); });
12
+ it('exits same without --json', async () => { const {status,stderr}=await runCli(['template','','src/z.tsx'],{cwd:dir}); expect(status).toBe(1); expect(stderr).toContain('<name>'); });
13
+ it('ignoring modes pass', async () => { for (const [a,t] of [[['template','','--list'],'template.list'],[['template','','--cdn'],'template.cdn'],[['template','ai-chat','','--skeleton'],'template.skeleton'],[['swizzle','','--list'],'swizzle.list']]) { const {status,body}=await json(a); expect(status).toBe(0); expect(body.type).toBe(t); } });
14
+ it('bare --cdn empty path rejected', async () => { const {status,body}=await json(['template','ai-chat','','--cdn']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });
15
+ it('omitted lists', async () => { for (const [a,t] of [[['template','--list'],'template.list'],[['discover'],'discover.list'],[['swizzle','--list'],'swizzle.list']]) { const {status,body}=await json(a); expect(status).toBe(0); expect(body.type).toBe(t); } });
16
+ });
@@ -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 () => {
@@ -21,7 +21,7 @@ describe('init Next steps theme guidance', () => {
21
21
 
22
22
  it('adds an installed theme through the CLI', () => {
23
23
  expect(text).toContain('npm install @astryxdesign/theme-neutral');
24
- expect(text).toContain('npx astryx theme add neutral --import');
24
+ expect(text).toContain('npx astryx theme add neutral');
25
25
  });
26
26
 
27
27
  it('wires the generated theme record once', () => {
@@ -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
+ });
@@ -127,7 +127,7 @@ describe('search() API — filters', () => {
127
127
  expect(data.results.map(r => r.name)).toContain('neutral');
128
128
  for (const r of data.results) {
129
129
  expect(r.domain).toBe('theme');
130
- expect(r.command).toBe(`astryx theme add --import ${r.name}`);
130
+ expect(r.command).toBe(`astryx theme add ${r.name}`);
131
131
  }
132
132
  });
133
133
 
@@ -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
+ });