@astryxdesign/cli 0.7.0-canary.0686fad → 0.7.0-canary.1180dee

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 (223) hide show
  1. package/README.md +88 -91
  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/pack-check.test.mjs +8 -0
  25. package/api/integration/validate-integration.d.mts +4 -0
  26. package/api/integration/validate-integration.mjs +5 -2
  27. package/api/integration/validateIntegration.doc.mjs +1 -1
  28. package/api/json/index.ts +0 -1
  29. package/api/search/search.doc.mjs +1 -1
  30. package/api/search/search.mjs +1 -1
  31. package/api/search/search.test.mjs +1 -1
  32. package/api/search/search.type.d.mts +1 -1
  33. package/api/search/search.type.mjs +1 -1
  34. package/api/template/list/list.mjs +23 -2
  35. package/api/template/list/list.test.mjs +52 -0
  36. package/api/template/template-integration.test.mjs +37 -100
  37. package/api/template/template.doc.mjs +8 -3
  38. package/api/template/template.mjs +45 -0
  39. package/api/template/template.type.mjs +1 -1
  40. package/api/theme/_adapter.mjs +3 -3
  41. package/api/theme/add/add.d.mts +11 -5
  42. package/api/theme/add/add.mjs +19 -192
  43. package/api/theme/add/add.test.mjs +68 -258
  44. package/api/theme/add/add.types.test.mjs +0 -1
  45. package/api/theme/build/build.d.mts +3 -4
  46. package/api/theme/build/build.mjs +26 -65
  47. package/api/theme/build/build.test.mjs +11 -24
  48. package/api/theme/build/family.mjs +1 -1
  49. package/api/theme/eject/eject.copy-compat.test.mjs +168 -0
  50. package/api/theme/integration-themes.test.mjs +3 -3
  51. package/api/theme/remove/remove.test.mjs +1 -1
  52. package/api/theme/targets/targets.test.mjs +0 -4
  53. package/api/theme/template/template.mjs +1 -1
  54. package/api/theme/theme.type.d.mts +1 -30
  55. package/api/theme/theme.type.mjs +3 -13
  56. package/api/theme/themeAdd.doc.mjs +19 -27
  57. package/api/theme/themeTargets.doc.mjs +3 -4
  58. package/api/theme/themeTemplate.doc.mjs +1 -1
  59. package/api/theme/use/use.test.mjs +1 -1
  60. package/api/upgrade/upgrade.doc.mjs +1 -1
  61. package/api/upgrade/upgrade.mjs +19 -0
  62. package/assets/codemods/transforms/next/README.md +15 -17
  63. package/assets/codemods/transforms/next/__tests__/migrate-deprecated-theme-surface.test.mjs +322 -0
  64. package/assets/codemods/transforms/next/__tests__/validate-data-token-ownership.test.mjs +84 -0
  65. package/assets/codemods/transforms/next/index.mjs +19 -1
  66. package/assets/codemods/transforms/next/migrate-deprecated-theme-surface-v0.6-data.mjs +229 -0
  67. package/assets/codemods/transforms/next/migrate-deprecated-theme-surface.mjs +624 -0
  68. package/assets/codemods/transforms/next/validate-data-token-ownership.mjs +102 -0
  69. package/assets/codemods/transforms/v0.6.0/migrate-astryx-theme-selectors-to-data-attrs.mjs +38 -18
  70. package/assets/docs/author-a-theme.doc.mjs +5 -5
  71. package/assets/docs/getting-started.doc.mjs +2 -2
  72. package/assets/docs/theme.doc.dense.mjs +1 -1
  73. package/assets/docs/theme.doc.mjs +2 -2
  74. package/assets/docs/tree/add-a-theme.doc.mjs +1 -1
  75. package/assets/docs/tree/document-the-theme.doc.mjs +2 -2
  76. package/assets/docs/tree/fonts-and-assets.doc.mjs +3 -3
  77. package/assets/docs/tree/styling-advanced.doc.mjs +21 -14
  78. package/assets/docs/tree/themes.doc.mjs +1 -1
  79. package/assets/docs/tree/tokens-data.doc.mjs +2 -2
  80. package/assets/docs/tree/tokens-usage.doc.mjs +1 -1
  81. package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +2 -2
  82. package/assets/docs/tree/versioning.doc.mjs +1 -4
  83. package/assets/docs/use-a-theme.doc.mjs +16 -16
  84. package/assets/templates/blocks/components/ComplexSelector/ComplexSelectorDeadlinePicker.tsx +1 -1
  85. package/assets/templates/blocks/components/ComplexSelector/ComplexSelectorShowcase.tsx +1 -1
  86. package/assets/templates/blocks/components/ComplexSelector/ComplexSelectorTreeSearch.tsx +1 -1
  87. package/assets/templates/blocks/components/InternationalizationProvider/InternationalizationProvider01ShippedLocale.tsx +1 -1
  88. package/assets/templates/blocks/components/InternationalizationProvider/InternationalizationProvider02Overrides.tsx +1 -1
  89. package/assets/templates/blocks/components/Selector/SelectorClearable.tsx +1 -1
  90. package/assets/templates/blocks/components/Selector/SelectorOptionDescriptions.tsx +2 -2
  91. package/assets/templates/blocks/components/Selector/SelectorShowcase.tsx +1 -1
  92. package/assets/templates/blocks/components/Selector/SelectorWithSections.tsx +1 -1
  93. package/assets/templates/blocks/components/SelectorOption/SelectorOptionBasic.tsx +1 -1
  94. package/assets/templates/blocks/components/SelectorOption/SelectorOptionShowcase.tsx +1 -1
  95. package/assets/templates/blocks/components/Slider/SliderFormattedValue.tsx +1 -1
  96. package/assets/templates/blocks/components/Slider/SliderRangeSlider.tsx +1 -1
  97. package/assets/templates/blocks/components/Slider/SliderShowcase.tsx +1 -1
  98. package/assets/templates/blocks/components/Slider/SliderWithMarks.tsx +1 -1
  99. package/assets/templates/blocks/components/Tokenizer/TokenizerClear.tsx +1 -1
  100. package/assets/templates/blocks/components/Tokenizer/TokenizerCreatable.tsx +2 -2
  101. package/assets/templates/blocks/components/Tokenizer/TokenizerEndContent.tsx +1 -1
  102. package/assets/templates/blocks/components/Tokenizer/TokenizerIcon.tsx +1 -1
  103. package/assets/templates/blocks/components/Tokenizer/TokenizerMaxEntries.tsx +1 -1
  104. package/assets/templates/blocks/components/Tokenizer/TokenizerOverflow.tsx +2 -2
  105. package/assets/templates/blocks/components/Tokenizer/TokenizerShowcase.tsx +1 -1
  106. package/assets/templates/blocks/components/Tokenizer/TokenizerStates.tsx +4 -4
  107. package/assets/templates/blocks/components/Toolbar/ToolbarTableFilter.tsx +1 -1
  108. package/assets/templates/pages/canvas-editor/page.tsx +2 -2
  109. package/assets/templates/pages/form-wizard-vertical/page.tsx +1 -1
  110. package/assets/templates/pages/payment-form/page.tsx +1 -1
  111. package/assets/templates/pages/table-filter/page.tsx +3 -3
  112. package/assets/templates/pages/theme-showcase/page.tsx +2 -2
  113. package/assets/templates/themes/neutral/neutralPaletteRefs.generated.ts +10 -9
  114. package/authoring/debug/type.ts +2 -2
  115. package/authoring/doctypes/base/type.ts +0 -9
  116. package/authoring/integration/integration.doc.mjs +1 -1
  117. package/clients/cli/command-result-coverage.test.mjs +1 -1
  118. package/clients/cli/commands/build-theme.adaptations.test.mjs +4 -0
  119. package/clients/cli/commands/build-theme.ascii-output.test.mjs +35 -8
  120. package/clients/cli/commands/build-theme.color-scheme.test.mjs +10 -6
  121. package/clients/cli/commands/build-theme.data-tokens.test.mjs +23 -75
  122. package/clients/cli/commands/build-theme.mjs +31 -67
  123. package/clients/cli/commands/build-theme.registry.test.mjs +0 -10
  124. package/clients/cli/commands/build.doc.mjs +1 -1
  125. package/clients/cli/commands/build.mjs +1 -1
  126. package/clients/cli/commands/component-ownership.test.mjs +2 -2
  127. package/clients/cli/commands/debug-result-summary.test.mjs +0 -16
  128. package/clients/cli/commands/discover.mjs +2 -1
  129. package/clients/cli/commands/doctor.mjs +5 -2
  130. package/clients/cli/commands/empty-argument.test.mjs +16 -0
  131. package/clients/cli/commands/gap-report.doc.mjs +1 -1
  132. package/clients/cli/commands/gap-report.test.mjs +2 -2
  133. package/clients/cli/commands/init.doc.mjs +4 -4
  134. package/clients/cli/commands/init.flag-help.test.mjs +7 -10
  135. package/clients/cli/commands/init.next-steps.test.mjs +1 -1
  136. package/clients/cli/commands/integration.mjs +2 -1
  137. package/clients/cli/commands/option-pair-refusals.test.mjs +37 -0
  138. package/clients/cli/commands/search.test.mjs +1 -1
  139. package/clients/cli/commands/silent-success-refusals.test.mjs +15 -0
  140. package/clients/cli/commands/swizzle.mjs +4 -1
  141. package/clients/cli/commands/template.doc.mjs +4 -4
  142. package/clients/cli/commands/template.flag-help.test.mjs +18 -11
  143. package/clients/cli/commands/template.mjs +7 -1
  144. package/clients/cli/commands/text-json-parity.test.mjs +0 -17
  145. package/clients/cli/commands/theme-add-lifecycle.test.mjs +142 -49
  146. package/clients/cli/commands/theme-add.doc.mjs +10 -17
  147. package/clients/cli/commands/theme-list.behavior.test.mjs +2 -1
  148. package/clients/cli/commands/theme-targets.behavior.test.mjs +8 -6
  149. package/clients/cli/commands/theme-template.doc.mjs +1 -1
  150. package/clients/cli/commands/theme.doc.mjs +2 -2
  151. package/clients/cli/commands/upgrade.doc.mjs +1 -1
  152. package/clients/cli/commands/upgrade.flag-help.test.mjs +7 -11
  153. package/clients/cli/commands/validate-nothing-exits-nonzero.test.mjs +67 -0
  154. package/clients/cli/index.mjs +0 -4
  155. package/clients/cli/lib/cli-error.mjs +19 -0
  156. package/clients/cli/lib/component-format.mjs +111 -57
  157. package/clients/cli/lib/component-format.test.mjs +28 -39
  158. package/clients/cli/lib/doc-text-ascii.test.mjs +5 -2
  159. package/clients/cli/lib/exit-codes.test.mjs +0 -7
  160. package/clients/cli/lib/json-shim.test.mjs +0 -24
  161. package/foundation/agent-docs/agent-docs.d.mts +2 -1
  162. package/foundation/agent-docs/agent-docs.mjs +6 -1
  163. package/foundation/agent-docs/app-theme-workflow.test.mjs +3 -0
  164. package/foundation/config/theme-state.mjs +3 -3
  165. package/foundation/debug/debug-fields.test.mjs +13 -35
  166. package/foundation/debug/event.mjs +13 -78
  167. package/foundation/debug/privacy-contract.test.mjs +20 -12
  168. package/foundation/debug/redact.d.mts +2 -2
  169. package/foundation/debug/redact.mjs +2 -2
  170. package/foundation/discovery/template-needs.mjs +93 -11
  171. package/foundation/discovery/template-needs.test.mjs +106 -3
  172. package/foundation/discovery/theme-imports.mjs +1 -1
  173. package/foundation/discovery/theming-targets.d.mts +1 -20
  174. package/foundation/discovery/theming-targets.mjs +1 -38
  175. package/foundation/discovery/theming-targets.test.mjs +9 -175
  176. package/foundation/doc-compiler/doc-loads.test.mjs +0 -12
  177. package/foundation/env/package-manager.d.mts +13 -0
  178. package/foundation/env/package-manager.mjs +106 -63
  179. package/foundation/response/error-codes.doc.mjs +1 -1
  180. package/foundation/response/response-types.doc.mjs +11 -31
  181. package/foundation/response/response-types.doc.test.mjs +36 -14
  182. package/foundation/response/response.doc.mjs +1 -1
  183. package/foundation/xle/browser.d.mts +2 -2
  184. package/foundation/xle/browser.mjs +2 -2
  185. package/foundation/xle/expand.mjs +1 -1
  186. package/foundation/xle/print.mjs +1 -1
  187. package/package.json +9 -9
  188. package/api/layout/_adapter.d.mts +0 -34
  189. package/api/layout/_adapter.mjs +0 -148
  190. package/api/layout/check/check.d.mts +0 -17
  191. package/api/layout/check/check.mjs +0 -41
  192. package/api/layout/expand/expand.d.mts +0 -23
  193. package/api/layout/expand/expand.mjs +0 -161
  194. package/api/layout/expand/expand.path-safety.test.mjs +0 -53
  195. package/api/layout/expand/expand.receipt.test.mjs +0 -74
  196. package/api/layout/grammar/grammar.d.mts +0 -14
  197. package/api/layout/grammar/grammar.mjs +0 -88
  198. package/api/layout/layout.d.mts +0 -6
  199. package/api/layout/layout.mjs +0 -17
  200. package/api/layout/layout.test.mjs +0 -297
  201. package/api/layout/layout.type.d.mts +0 -90
  202. package/api/layout/layout.type.mjs +0 -104
  203. package/api/layout/layoutCheck.doc.d.mts +0 -11
  204. package/api/layout/layoutCheck.doc.mjs +0 -85
  205. package/api/layout/layoutExpand.doc.d.mts +0 -11
  206. package/api/layout/layoutExpand.doc.mjs +0 -107
  207. package/api/layout/layoutGrammar.doc.d.mts +0 -11
  208. package/api/layout/layoutGrammar.doc.mjs +0 -57
  209. package/api/theme/add/add.binary.test.mjs +0 -157
  210. package/api/theme/add/add.rollback.test.mjs +0 -158
  211. package/api/theme/add/add.staging.test.mjs +0 -83
  212. package/clients/cli/commands/layout-check.doc.mjs +0 -67
  213. package/clients/cli/commands/layout-expand.doc.mjs +0 -87
  214. package/clients/cli/commands/layout-grammar.doc.mjs +0 -32
  215. package/clients/cli/commands/layout.deprecation-lifecycle.test.mjs +0 -140
  216. package/clients/cli/commands/layout.doc.mjs +0 -36
  217. package/clients/cli/commands/layout.error-codes.test.mjs +0 -66
  218. package/clients/cli/commands/layout.exit-parity.test.mjs +0 -41
  219. package/clients/cli/commands/layout.expand-receipt.test.mjs +0 -94
  220. package/clients/cli/commands/layout.mjs +0 -327
  221. package/clients/cli/commands/layout.path-help.test.mjs +0 -33
  222. package/clients/cli/commands/layout.stdin-cap.test.mjs +0 -47
  223. package/clients/cli/commands/layout.text-fields.test.mjs +0 -39
@@ -69,7 +69,7 @@ function unavailableChecks(message, moduleError = null) {
69
69
  moduleError && id === 'theme-module' ? moduleError.message : message,
70
70
  ...(moduleError && id === 'theme-module'
71
71
  ? {
72
- fix: 'Keep one CLI-generated astryx-themes.ts or astryx-themes.js file, then run `astryx theme add <slug> --import`.',
72
+ fix: 'Keep one CLI-generated astryx-themes.ts or astryx-themes.js file, then run `astryx theme add <slug>`.',
73
73
  }
74
74
  : {}),
75
75
  }));
@@ -101,12 +101,12 @@ function refreshThemeCommand(projectDir, run, available, slug, owner) {
101
101
  );
102
102
  if (!isLocalThemeOwner(owner)) {
103
103
  const selector = theme?.package ?? owner;
104
- return `npm install ${owner}@latest; ${run} theme add ${slug} --import --package ${selector}`;
104
+ return `npm install ${owner}@latest; ${run} theme add ${slug} --package ${selector}`;
105
105
  }
106
106
  const source = theme
107
107
  ? relative(projectDir, path.join(theme.sourceDir, theme.entry))
108
108
  : projectPath(path.join(owner, slug, `${slug}Theme.ts`));
109
- return `${run} theme build ${source}; ${run} theme add ${slug} --import`;
109
+ return `${run} theme build ${source}; ${run} theme add ${slug}`;
110
110
  }
111
111
 
112
112
  /** @param {string} source */
@@ -478,7 +478,7 @@ export function checkThemes(cwd, appChecks) {
478
478
  label,
479
479
  status: 'warn',
480
480
  message: 'No @astryxdesign/theme-* packages are installed.',
481
- fix: `Install a theme, e.g. \`npm install @astryxdesign/theme-neutral\`, then add it to the app with \`${run} theme add neutral --import\`.`,
481
+ fix: `Install a theme, e.g. \`npm install @astryxdesign/theme-neutral\`, then add it to the app with \`${run} theme add neutral\`.`,
482
482
  };
483
483
  }
484
484
  const names = packages.join(', ');
@@ -488,7 +488,7 @@ export function checkThemes(cwd, appChecks) {
488
488
  label,
489
489
  status: 'warn',
490
490
  message: `Theme package(s) installed (${names}) but no theme appears wired.`,
491
- fix: `Add one to the app with \`${run} theme add <slug> --import\`.`,
491
+ fix: `Add one to the app with \`${run} theme add <slug>\`.`,
492
492
  };
493
493
  }
494
494
  return {
@@ -538,7 +538,7 @@ export async function checkAppThemes(cwd) {
538
538
  message: state.legacyTheme
539
539
  ? `The CLI manages no themes. The released package.json astryx.theme value ${JSON.stringify(state.legacyTheme)} remains active.`
540
540
  : 'The CLI manages no themes because this project has no generated theme module.',
541
- fix: `Start managing app themes with \`${run} theme add <slug> --import\`.`,
541
+ fix: `Start managing app themes with \`${run} theme add <slug>\`.`,
542
542
  },
543
543
  ];
544
544
  const migration = unmigratedCopyCheck(state.projectDir);
@@ -656,7 +656,7 @@ export async function checkAppThemes(cwd) {
656
656
  label: 'Theme owners and built imports',
657
657
  status: 'fail',
658
658
  message: 'The generated record has no added themes.',
659
- fix: `${run} theme add <slug> --import`,
659
+ fix: `${run} theme add <slug>`,
660
660
  });
661
661
  } else if (discoveryError) {
662
662
  checks.push({
@@ -664,7 +664,7 @@ export async function checkAppThemes(cwd) {
664
664
  label: 'Theme owners and built imports',
665
665
  status: 'fail',
666
666
  message: discoveryError.message,
667
- fix: `${run} theme add <slug> --import`,
667
+ fix: `${run} theme add <slug>`,
668
668
  });
669
669
  } else if (resolutionProblems.length > 0) {
670
670
  checks.push({
@@ -1003,7 +1003,7 @@ export async function checkAppThemes(cwd) {
1003
1003
  fix:
1004
1004
  ownerEntries.length > 0
1005
1005
  ? `${run} theme use ${ownerEntries[0][0]}`
1006
- : `${run} theme add <slug> --import`,
1006
+ : `${run} theme add <slug>`,
1007
1007
  },
1008
1008
  );
1009
1009
 
@@ -1083,7 +1083,7 @@ export async function checkAppThemes(cwd) {
1083
1083
  if (localWarnings.length > 0) {
1084
1084
  fontWarningFixes.push(
1085
1085
  `Add <slug>.fonts.css beside each built local theme output, then ${localWarnings
1086
- .map(problem => `${run} theme add ${problem.theme.slug} --import`)
1086
+ .map(problem => `${run} theme add ${problem.theme.slug}`)
1087
1087
  .join('; ')}.`,
1088
1088
  );
1089
1089
  }
@@ -172,7 +172,7 @@ describe('the released themes check', () => {
172
172
  label: 'Theme packages',
173
173
  status: 'warn',
174
174
  message: 'No @astryxdesign/theme-* packages are installed.',
175
- fix: expect.stringContaining('theme add neutral --import'),
175
+ fix: expect.stringContaining('theme add neutral`.'),
176
176
  });
177
177
 
178
178
  installThemePackage(dir, 'neutral');
@@ -183,7 +183,7 @@ describe('the released themes check', () => {
183
183
  status: 'warn',
184
184
  message:
185
185
  'Theme package(s) installed (@astryxdesign/theme-neutral) but no theme appears wired.',
186
- fix: expect.stringContaining('theme add <slug> --import'),
186
+ fix: expect.stringContaining('theme add <slug>`.'),
187
187
  });
188
188
  expect(unwired.fix).not.toContain('ASTRYX_THEME');
189
189
 
@@ -390,7 +390,7 @@ describe('app-theme doctor checks', () => {
390
390
 
391
391
  expect(check(await checkAppThemes(dir), 'theme-owners')).toMatchObject({
392
392
  status: 'fail',
393
- fix: expect.stringContaining('theme add ocean --import'),
393
+ fix: expect.stringContaining('theme add ocean'),
394
394
  });
395
395
  });
396
396
 
@@ -592,9 +592,10 @@ describe('app-theme doctor checks', () => {
592
592
  id: 'theme-management',
593
593
  status: 'info',
594
594
  message: expect.stringContaining('manages no themes'),
595
- fix: expect.stringContaining('theme add <slug> --import'),
595
+ fix: expect.stringContaining('theme add <slug>'),
596
596
  }),
597
597
  ]);
598
+ expect(checks[0]?.fix).not.toContain('--import');
598
599
  });
599
600
 
600
601
  it('reads astryx.theme from the app package when node_modules is hoisted to a workspace root', async () => {
@@ -74,7 +74,7 @@ export const doc = {
74
74
  name: 'options.listCategories',
75
75
  type: 'boolean',
76
76
  description:
77
- 'Return categories without resolving a route or writing; the component and every other option are ignored.',
77
+ 'Return categories without resolving a route or writing; the component and every other option are refused with ERR_INVALID_ARGUMENT.',
78
78
  default: 'false',
79
79
  },
80
80
  {
@@ -595,6 +595,21 @@ function aggregateStatus(deliveries) {
595
595
  */
596
596
  export async function gapReport(component, options = {}) {
597
597
  if (options.listCategories) {
598
+ const ignored = [
599
+ component ? 'component' : null,
600
+ options.category ? '--category' : null,
601
+ options.reason ? '--reason' : null,
602
+ options.detail ? '--additional-context' : null,
603
+ options.package ? '--package' : null,
604
+ options.confirmPublic ? '--confirm-public' : null,
605
+ ].filter(Boolean);
606
+ if (ignored.length > 0) {
607
+ throw new AstryxError(
608
+ `\`--list-categories\` cannot be combined with ${ignored.join(', ')}: it lists categories and ignores submission options.`,
609
+ undefined,
610
+ ERROR_CODES.ERR_INVALID_ARGUMENT,
611
+ );
612
+ }
598
613
  return {
599
614
  type: 'gap-report.categories',
600
615
  data: GAP_REPORT_CATEGORIES.map(category => ({...category})),
@@ -1195,7 +1195,7 @@ describe('gapReport aggregate status and CLI exit', () => {
1195
1195
  `,
1196
1196
  });
1197
1197
  configure(['@test/inspector']);
1198
- vi.stubEnv('ASTRYX_AGENT_ID', 'secret-agent');
1198
+ vi.stubEnv('AGENT', 'secret-agent');
1199
1199
 
1200
1200
  const result = await gapReport('Button', {
1201
1201
  ...reportOptions,
package/api/index.d.mts CHANGED
@@ -33,14 +33,12 @@ export * from "./gap-report/gap-report.type.mjs";
33
33
  export * from "./upgrade/upgrade.type.mjs";
34
34
  export * from "./init/init.type.mjs";
35
35
  export * from "./doctor/doctor.type.mjs";
36
- export * from "./layout/layout.type.mjs";
37
36
  export * from "./integration/integration-authoring.type.mjs";
38
37
  export * from "./integration/pack-check.type.mjs";
39
38
  export * from "./integration/validate-integration.type.mjs";
40
39
  export * from "./integration/authoring-checks.type.mjs";
41
40
  export type Logger = import("./logger.mjs").Logger;
42
41
  export { themeBuild, themeAdd, themeRemove, themeUse, themeEject, themeTemplate, themeList, themeListAvailable, themeListCopySources, themeTargets, themePaletteGenerate, generateTonalPalette, listThemes } from "./theme/theme.mjs";
43
- export { layoutExpand, layoutCheck, layoutGrammar } from "./layout/layout.mjs";
44
42
  export { integrationAdd, integrationAddAgentDoc, integrationAddCodemod, integrationAddComponent, integrationAddDoc, integrationAddTemplate } from "./integration/add-contribution.mjs";
45
43
  export { validateIntegration, summarizeIssues } from "./integration/validate-integration.mjs";
46
44
  export { integrationTemplateConflicts, integrationComponentConflicts, integrationDocConflicts } from "./integration/authoring-checks.mjs";
package/api/index.mjs CHANGED
@@ -48,7 +48,6 @@ export {gapReport} from './gap-report/gap-report.mjs';
48
48
  export {upgrade} from './upgrade/upgrade.mjs';
49
49
  export {init} from './init/init.mjs';
50
50
  export {doctor} from './doctor/doctor.mjs';
51
- export {layoutExpand, layoutCheck, layoutGrammar} from './layout/layout.mjs';
52
51
  export {
53
52
  integrationAdd,
54
53
  integrationAddAgentDoc,
@@ -97,7 +96,6 @@ export * from './gap-report/gap-report.type.mjs';
97
96
  export * from './upgrade/upgrade.type.mjs';
98
97
  export * from './init/init.type.mjs';
99
98
  export * from './doctor/doctor.type.mjs';
100
- export * from './layout/layout.type.mjs';
101
99
  export * from './integration/integration-authoring.type.mjs';
102
100
  export * from './integration/pack-check.type.mjs';
103
101
  export * from './integration/validate-integration.type.mjs';
@@ -76,10 +76,14 @@ export const doc = {
76
76
  {
77
77
  type: 'init.remove',
78
78
  description:
79
- 'Returned when `removeAgents` is set. `data.removed` is always true, even when no managed block was found.',
79
+ 'The removal receipt, returned when `removeAgents` is set: `data.removed` is true when a managed agent-docs block was found and removed, and false when there was none to remove.',
80
80
  },
81
81
  ],
82
82
  throws: [
83
+ {
84
+ code: 'ERR_INVALID_ARGUMENT',
85
+ when: '--remove-agents is combined with --features, --all, --agent, or --agent-docs-path; or --all is combined with --features',
86
+ },
83
87
  {
84
88
  code: 'ERR_UNKNOWN_AGENT',
85
89
  when: 'the agents feature runs (default mode, features includes agents, or all) and `agent` is not one of claude, cursor, codex, hermes, muse, all',
package/api/init/init.mjs CHANGED
@@ -18,6 +18,8 @@
18
18
 
19
19
  import {run} from './run/run.mjs';
20
20
  import {remove} from './remove/remove.mjs';
21
+ import {AstryxError} from '../error.mjs';
22
+ import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
21
23
 
22
24
  export {getNextSteps} from './run/run.mjs';
23
25
 
@@ -42,7 +44,27 @@ export {getNextSteps} from './run/run.mjs';
42
44
  */
43
45
  export async function init(options = {}, {cwd = process.cwd()} = {}) {
44
46
  if (options.removeAgents) {
47
+ const ignored = [
48
+ options.features ? '--features' : null,
49
+ options.all ? '--all' : null,
50
+ options.agent ? '--agent' : null,
51
+ options.agentDocsPath ? '--agent-docs-path' : null,
52
+ ].filter(Boolean);
53
+ if (ignored.length > 0) {
54
+ throw new AstryxError(
55
+ `\`--remove-agents\` cannot be combined with ${ignored.join(', ')}: it removes the managed block and ignores install options.`,
56
+ undefined,
57
+ ERROR_CODES.ERR_INVALID_ARGUMENT,
58
+ );
59
+ }
45
60
  return remove({cwd});
46
61
  }
62
+ if (options.all && options.features) {
63
+ throw new AstryxError(
64
+ '`--all` and `--features` cannot be used together: `--all` installs every feature, so a feature list is redundant.',
65
+ undefined,
66
+ ERROR_CODES.ERR_INVALID_ARGUMENT,
67
+ );
68
+ }
47
69
  return run(options, {cwd});
48
70
  }
@@ -52,8 +52,11 @@ export type InitRunResponse = {
52
52
  };
53
53
  export type InitRemoveResponse = {
54
54
  type: "init.remove";
55
+ /**
56
+ * False when no managed agent-docs block was found, so nothing was removed.
57
+ */
55
58
  data: {
56
- removed: true;
59
+ removed: boolean;
57
60
  };
58
61
  };
59
62
  /**
@@ -29,7 +29,7 @@
29
29
  /**
30
30
  * @typedef {object} InitRemoveResponse
31
31
  * @property {'init.remove'} type
32
- * @property {{removed: true}} data
32
+ * @property {{removed: boolean}} data False when no managed agent-docs block was found, so nothing was removed.
33
33
  */
34
34
 
35
35
  /**
@@ -23,7 +23,12 @@ import {logger} from '../../logger.mjs';
23
23
  * @returns {Promise<import('../init.type.mjs').InitRemoveResponse>}
24
24
  */
25
25
  export async function remove({cwd = process.cwd()} = {}) {
26
- removeAgentDocs(cwd);
27
- logger.log('[ok] AI agent docs removed.');
28
- return {type: 'init.remove', data: {removed: true}};
26
+ const removedFrom = removeAgentDocs(cwd);
27
+ const removed = removedFrom.length > 0;
28
+ logger.log(
29
+ removed
30
+ ? '[ok] AI agent docs removed.'
31
+ : '[ok] Nothing to remove: no Astryx agent-docs block was found.',
32
+ );
33
+ return {type: 'init.remove', data: {removed}};
29
34
  }
@@ -0,0 +1,12 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ import {describe, it, expect, beforeEach, afterEach, vi} from 'vitest';
3
+ import * as fs from 'node:fs'; import * as path from 'node:path';
4
+ import {init} from '../init.mjs'; import {remove} from './remove.mjs'; import {logger} from '../../logger.mjs';
5
+ let dir;
6
+ beforeEach(() => { dir = fs.mkdtempSync(path.join(process.cwd(), '.astryx-rm-')); fs.writeFileSync(path.join(dir,'package.json'),JSON.stringify({name:'c',version:'1.0.0'})); });
7
+ afterEach(() => { fs.rmSync(dir,{recursive:true,force:true}); logger.setSilent(true); });
8
+ describe('init.remove says whether anything was removed', () => {
9
+ it('false on clean', async () => { const r=await remove({cwd:dir}); expect(r.type).toBe('init.remove'); expect(r.data.removed).toBe(false); });
10
+ it('true then false', async () => { await init({features:['agents']},{cwd:dir}); expect(fs.readFileSync(path.join(dir,'AGENTS.md'),'utf8')).toContain('<!-- ASTRYX:START -->'); const a=await remove({cwd:dir}); expect(a.data.removed).toBe(true); const b=await remove({cwd:dir}); expect(b.data.removed).toBe(false); });
11
+ it('human line', async () => { const l=[]; const s=vi.spyOn(console,'log').mockImplementation((...a)=>l.push(a.join(' '))); logger.setSilent(false); try{await remove({cwd:dir});}finally{logger.setSilent(true);s.mockRestore();} expect(l.join('\n')).toContain('Nothing to remove'); });
12
+ });
@@ -4,7 +4,7 @@
4
4
  /**
5
5
  * Build the "Next steps" lines printed at the end of `astryx init`.
6
6
  *
7
- * Theme guidance follows the generated app-module workflow. `theme add --import` records
7
+ * Theme guidance follows the generated app-module workflow. `theme add` records
8
8
  * installed built themes and imports their production and font stylesheets. The
9
9
  * app imports that module once and passes its default to <Theme>.
10
10
  *
@@ -35,7 +35,7 @@ const VALID_AGENTS = ['claude', 'cursor', 'codex', 'hermes', 'muse', 'all'];
35
35
  /**
36
36
  * Build the "Next steps" lines printed at the end of `astryx init`.
37
37
  *
38
- * Theme guidance follows the generated app-module workflow. `theme add --import` records
38
+ * Theme guidance follows the generated app-module workflow. `theme add` records
39
39
  * installed built themes and imports their production and font stylesheets. The
40
40
  * app imports that module once and passes its default to <Theme>.
41
41
  *
@@ -53,7 +53,7 @@ export function getNextSteps(invocation) {
53
53
  " 3. Import components: import { Button } from '@astryxdesign/core'",
54
54
  ' 4. Add and wire a theme:',
55
55
  ' npm install @astryxdesign/theme-neutral',
56
- ` ${invocation} theme add neutral --import`,
56
+ ` ${invocation} theme add neutral`,
57
57
  " import { Theme } from '@astryxdesign/core'",
58
58
  " import { themes, defaultThemeSlug } from './astryx-themes'",
59
59
  ' <Theme theme={themes[defaultThemeSlug]}>...</Theme>',
@@ -141,7 +141,7 @@ function applyTheme(cwd, invocation, data) {
141
141
  logger.error('Could not write the theme template.');
142
142
  }
143
143
  logger.log(
144
- ` Edit the blank template for a new theme, or run \`${invocation} theme add <slug> --import\` to import an installed built theme (\`${invocation} theme list\` to browse). Extend an imported theme for ordinary customization; use \`${invocation} theme eject <slug>\` only to fork source.`,
144
+ ` Edit the blank template for a new theme, or run \`${invocation} theme add <slug>\` to import an installed built theme (\`${invocation} theme list\` to browse). Extend an imported theme for ordinary customization; use \`${invocation} theme eject <slug>\` only to fork source.`,
145
145
  );
146
146
  }
147
147
 
@@ -504,6 +504,14 @@ describe('integrationPackCheck', () => {
504
504
  message:
505
505
  'Theme "ocean" exports @acme/widgets/theme.css without a complete built module and stylesheet pair. Missing partner exports alone do not block packing; add the matching export when the theme should be importable. Every declared export must resolve. Staleness is a warning until the complete importable pair is declared.',
506
506
  },
507
+ // A 0.6.5-built stylesheet still carries the root data-color defaults
508
+ // that theme output no longer emits, so it no longer matches its source.
509
+ {
510
+ code: 'theme_stylesheet_stale',
511
+ severity: 'warning',
512
+ message:
513
+ 'Theme "ocean" stylesheet does not match themes/ocean/oceanTheme.ts. This incomplete export remains packable, but run `astryx theme build themes/ocean/oceanTheme.ts` before adding its matching export.',
514
+ },
507
515
  ]);
508
516
  const cli = runCliVerify();
509
517
  expect(cli.status, cli.stderr).toBe(0);
@@ -62,6 +62,10 @@ export type ValidateResult = {
62
62
  * Absolute path to the loaded manifest.
63
63
  */
64
64
  manifestFile?: string | undefined;
65
+ /**
66
+ * Why nothing was validated (internal).
67
+ */
68
+ reason?: "no_package_json" | undefined;
65
69
  issues: Issue[];
66
70
  integration?: import("../../foundation/integrations/integrations.mjs").LoadedIntegration | undefined;
67
71
  };
@@ -72,6 +72,7 @@ export {validateLoadedIntegration};
72
72
  * @property {string} [name] Integration package name (from package.json).
73
73
  * @property {string} [version] Integration package version.
74
74
  * @property {string} [manifestFile] Absolute path to the loaded manifest.
75
+ * @property {'no_package_json'} [reason] Why nothing was validated (internal).
75
76
  * @property {Issue[]} issues
76
77
  * @property {import('../../foundation/integrations/integrations.mjs').LoadedIntegration} [integration]
77
78
  */
@@ -349,7 +350,7 @@ async function validateAtPackageDir(
349
350
  export async function validateLocalIntegration(cwd = process.cwd()) {
350
351
  const pkgJsonPath = findNearestPackageJson(cwd);
351
352
  if (!pkgJsonPath) {
352
- return {found: false, issues: []};
353
+ return {found: false, reason: 'no_package_json', issues: []};
353
354
  }
354
355
  const packageDir = path.dirname(pkgJsonPath);
355
356
 
@@ -468,7 +469,9 @@ export async function validateIntegration(pkg, options = {}) {
468
469
  validated: result.found,
469
470
  name: result.found ? (result.name ?? null) : null,
470
471
  version: result.found ? (result.version ?? null) : null,
471
- issues: result.issues,
472
+ issues: result.reason === 'no_package_json'
473
+ ? [{code: 'no_package', severity: 'error', message: 'No package.json found. Run this command inside a package directory.'}]
474
+ : result.issues,
472
475
  },
473
476
  };
474
477
  }
@@ -46,7 +46,7 @@ export const doc = {
46
46
  {
47
47
  type: 'integration.validate',
48
48
  description:
49
- 'The result envelope: `data.validated`, false only when no integration manifest was found — nothing was checked, so the empty `data.issues` means "not looked at", not "healthy"; `data.name` and `data.version` of the validated package (both null when `data.validated` is false; `data.name` is `(local package)` when the local package.json has no readable name), plus `data.issues`, an AstryxIntegrationIssue[] of {code, severity: `warning` | `error`, message}.',
49
+ 'The result envelope: `data.validated`, false when nothing was validated — with no `package.json` at all, `data.issues` carries one `no_package` error-severity issue so the command exits 1; with a `package.json` but no integration manifest, `data.issues` is empty, which means "not looked at", not "healthy"; `data.name` and `data.version` of the validated package (both null when `data.validated` is false; `data.name` is `(local package)` when the local package.json has no readable name), plus `data.issues`, an AstryxIntegrationIssue[] of {code, severity: `warning` | `error`, message}.',
50
50
  },
51
51
  ],
52
52
  examples: [
package/api/json/index.ts CHANGED
@@ -26,7 +26,6 @@ export type * from '../gap-report/gap-report.type.mjs';
26
26
  export type * from '../upgrade/upgrade.type.mjs';
27
27
  export type * from '../init/init.type.mjs';
28
28
  export type * from '../doctor/doctor.type.mjs';
29
- export type * from '../layout/layout.type.mjs';
30
29
  export type * from '../integration/validate-integration.type.mjs';
31
30
  export type * from '../integration/authoring-checks.type.mjs';
32
31
  export type * from '../integration/pack-check.type.mjs';
@@ -55,7 +55,7 @@ export const doc = {
55
55
  {
56
56
  type: 'search',
57
57
  description:
58
- 'The query echoed back, `matchCount` (how many candidates matched in total, before `limit`), plus a ranked SearchResultEntry[] bounded by `limit`: each has domain, name, score, reason, description, and follow-up command, plus `import` for components and hooks, `title` for docs, `displayName` and `kind` for templates, and `displayName` for themes. A doc result is the smallest part that answers: one section (with `section`, and a command that reads only it), one docs-tree route, or a topic, whose command lists its sections. `parent` is the command that opens the level above it: the section list of its topic, the namespace a tree node sits in, the Unorganized level for a flat topic, or the topic list for a top-level namespace. Every doc result also carries `package`, the npm package that authored it (for a section, the package its file came from). A theme result is one theme you can import: `name` is its slug, its command is `astryx theme add --import <slug>`, and `package` is the npm package that ships it (`@astryxdesign/cli` for the CLI\'s own themes).',
58
+ 'The query echoed back, `matchCount` (how many candidates matched in total, before `limit`), plus a ranked SearchResultEntry[] bounded by `limit`: each has domain, name, score, reason, description, and follow-up command, plus `import` for components and hooks, `title` for docs, `displayName` and `kind` for templates, and `displayName` for themes. A doc result is the smallest part that answers: one section (with `section`, and a command that reads only it), one docs-tree route, or a topic, whose command lists its sections. `parent` is the command that opens the level above it: the section list of its topic, the namespace a tree node sits in, the Unorganized level for a flat topic, or the topic list for a top-level namespace. Every doc result also carries `package`, the npm package that authored it (for a section, the package its file came from). A theme result is one theme you can import: `name` is its slug, its command is `astryx theme add <slug>`, and `package` is the npm package that ships it (`@astryxdesign/cli` for the CLI\'s own themes).',
59
59
  },
60
60
  ],
61
61
  throws: [
@@ -1749,7 +1749,7 @@ function toResult(c, score, reason, matchedTerms, queryTerms) {
1749
1749
  result = {
1750
1750
  ...base,
1751
1751
  displayName: c._displayName,
1752
- command: `astryx theme add --import ${c.name}`,
1752
+ command: `astryx theme add ${c.name}`,
1753
1753
  };
1754
1754
  break;
1755
1755
  default:
@@ -99,7 +99,7 @@ describe('search leaf — per-domain result fields', () => {
99
99
  expect(['page', 'block']).toContain(res.kind);
100
100
  } else if (res.domain === 'theme') {
101
101
  expect(res.displayName).toMatch(/\S/);
102
- expect(res.command).toMatch(/^astryx theme add /);
102
+ expect(res.command).toBe(`astryx theme add ${res.name}`);
103
103
  }
104
104
  }
105
105
  }, SLOW);
@@ -30,7 +30,7 @@ export type SearchResultEntry = {
30
30
  */
31
31
  description: string;
32
32
  /**
33
- * - Follow-up command to act on this result (e.g. `astryx component Button`, or `astryx theme add --import neutral` for a theme).
33
+ * - Follow-up command to act on this result (e.g. `astryx component Button`, or `astryx theme add neutral` for a theme).
34
34
  */
35
35
  command: string;
36
36
  /**
@@ -20,7 +20,7 @@
20
20
  * @property {number} score - Relevance score (higher is better).
21
21
  * @property {string} reason - Human-readable reason the candidate matched (e.g. `keyword "button"`).
22
22
  * @property {string} description - One-line description, when available.
23
- * @property {string} command - Follow-up command to act on this result (e.g. `astryx component Button`, or `astryx theme add --import neutral` for a theme).
23
+ * @property {string} command - Follow-up command to act on this result (e.g. `astryx component Button`, or `astryx theme add neutral` for a theme).
24
24
  * @property {string} [import] - Import path — present for component and hook results.
25
25
  * @property {string} [title] - Doc title — present for doc results.
26
26
  * @property {string} [section] - Section key — present when a doc result is one section of a topic; `command` reads only that section.
@@ -10,6 +10,8 @@
10
10
  */
11
11
 
12
12
  import {pkgOf} from '../../../foundation/discovery/template-adapter.mjs';
13
+ import {AstryxError} from '../../error.mjs';
14
+ import {ERROR_CODES} from '../../../foundation/response/error-codes.mjs';
13
15
 
14
16
  /**
15
17
  * Project a discovered template set into the `template.list` envelope.
@@ -19,10 +21,29 @@ import {pkgOf} from '../../../foundation/discovery/template-adapter.mjs';
19
21
  */
20
22
  export function templateList(templates, options = {}) {
21
23
  const {type, package: packageFilter} = options;
24
+ const VALID_TYPES = ['page', 'block'];
22
25
  let filtered = templates;
23
- if (type) filtered = filtered.filter(t => t.type === type);
24
- if (packageFilter)
26
+ if (type) {
27
+ if (!VALID_TYPES.includes(type)) {
28
+ throw new AstryxError(
29
+ `Unknown template type "${type}". Valid types: ${VALID_TYPES.join(', ')}.`,
30
+ VALID_TYPES.map(t => ({name: t, reason: 'valid type'})),
31
+ ERROR_CODES.ERR_INVALID_ARGUMENT,
32
+ );
33
+ }
34
+ filtered = filtered.filter(t => t.type === type);
35
+ }
36
+ if (packageFilter) {
37
+ const allPackages = [...new Set(templates.map(t => pkgOf(t)))];
38
+ if (!allPackages.includes(packageFilter)) {
39
+ throw new AstryxError(
40
+ `No templates found in package "${packageFilter}".`,
41
+ allPackages.sort().map(p => ({name: p, reason: 'has templates'})),
42
+ ERROR_CODES.ERR_INVALID_ARGUMENT,
43
+ );
44
+ }
25
45
  filtered = filtered.filter(t => pkgOf(t) === packageFilter);
46
+ }
26
47
  return {
27
48
  type: 'template.list',
28
49
  data: filtered.map(t => ({
@@ -0,0 +1,52 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ import {describe, expect, it} from 'vitest';
3
+ import {templateList} from './list.mjs';
4
+
5
+ const t = (type, dirName, pkg) => ({
6
+ type,
7
+ dirName,
8
+ name: dirName,
9
+ description: dirName,
10
+ ...(pkg ? {package: pkg} : {}),
11
+ });
12
+
13
+ const templates = [
14
+ t('page', 'dashboard'),
15
+ t('block', 'hero'),
16
+ t('block', 'promo', '@acme/blocks'),
17
+ ];
18
+
19
+ describe('templateList filters', () => {
20
+ it('returns an empty list for a valid filter that matches nothing', () => {
21
+ // @acme/blocks ships only blocks, so asking it for pages is a valid
22
+ // filter with no match: an empty list, not an error.
23
+ const response = templateList(templates, {
24
+ type: 'page',
25
+ package: '@acme/blocks',
26
+ });
27
+ expect(response.type).toBe('template.list');
28
+ expect(response.data).toEqual([]);
29
+ });
30
+
31
+ it('refuses a type outside page or block', () => {
32
+ expect(() => templateList(templates, {type: 'bogus'})).toThrow(
33
+ /Unknown template type "bogus"/,
34
+ );
35
+ });
36
+
37
+ it('refuses a package that provides no templates', () => {
38
+ expect(() => templateList(templates, {package: '@nope/x'})).toThrow(
39
+ /No templates found in package "@nope\/x"/,
40
+ );
41
+ });
42
+
43
+ it('keeps a matching type and package filter', () => {
44
+ const response = templateList(templates, {
45
+ type: 'block',
46
+ package: '@acme/blocks',
47
+ });
48
+ expect(response.data.map(item => item.id ?? item.dirName)).toEqual([
49
+ 'promo',
50
+ ]);
51
+ });
52
+ });