@astryxdesign/cli 0.6.0 → 0.6.1

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 (219) hide show
  1. package/CHANGELOG.md +48 -1
  2. package/README.md +76 -67
  3. package/api/build/build.test.mjs +37 -0
  4. package/api/build/build.type.mjs +1 -1
  5. package/api/build/kit/kit.mjs +31 -1
  6. package/api/component/_adapter.mjs +14 -28
  7. package/api/component/integration-import-agreement.test.mjs +318 -0
  8. package/api/doctor/doctor.d.mts +32 -3
  9. package/api/doctor/doctor.doc.mjs +2 -1
  10. package/api/doctor/doctor.mjs +97 -4
  11. package/api/doctor/doctor.test.mjs +90 -1
  12. package/api/gap-report/gap-report-worker.d.mts +4 -0
  13. package/api/gap-report/gap-report-worker.mjs +73 -0
  14. package/api/gap-report/gap-report.d.mts +81 -0
  15. package/api/gap-report/gap-report.doc.d.mts +9 -0
  16. package/api/gap-report/gap-report.doc.mjs +127 -0
  17. package/api/gap-report/gap-report.mjs +707 -0
  18. package/api/gap-report/gap-report.test.mjs +1210 -0
  19. package/api/gap-report/gap-report.type.d.mts +88 -0
  20. package/api/gap-report/gap-report.type.mjs +69 -0
  21. package/api/index.d.mts +8 -1
  22. package/api/index.mjs +24 -1
  23. package/api/integration/add-contribution.d.mts +44 -0
  24. package/api/integration/add-contribution.mjs +1160 -0
  25. package/api/integration/add-contribution.test.mjs +733 -0
  26. package/api/integration/add-helpers.d.mts +80 -0
  27. package/api/integration/add-helpers.mjs +333 -0
  28. package/api/integration/add-helpers.test.mjs +161 -0
  29. package/api/integration/add-theme.d.mts +10 -0
  30. package/api/integration/add-theme.mjs +332 -0
  31. package/api/integration/add-theme.test.mjs +194 -0
  32. package/api/integration/integration-authoring.type.d.mts +55 -0
  33. package/api/integration/integration-authoring.type.mjs +76 -0
  34. package/api/integration/integration-block-exports.test.mjs +4 -0
  35. package/api/integration/integrationAdd.doc.d.mts +5 -0
  36. package/api/integration/integrationAdd.doc.mjs +100 -0
  37. package/api/integration/integrationAddAgentDoc.doc.d.mts +5 -0
  38. package/api/integration/integrationAddAgentDoc.doc.mjs +49 -0
  39. package/api/integration/integrationAddCodemod.doc.d.mts +5 -0
  40. package/api/integration/integrationAddCodemod.doc.mjs +55 -0
  41. package/api/integration/integrationAddComponent.doc.d.mts +5 -0
  42. package/api/integration/integrationAddComponent.doc.mjs +49 -0
  43. package/api/integration/integrationAddDoc.doc.d.mts +5 -0
  44. package/api/integration/integrationAddDoc.doc.mjs +59 -0
  45. package/api/integration/integrationAddTemplate.doc.d.mts +5 -0
  46. package/api/integration/integrationAddTemplate.doc.mjs +55 -0
  47. package/api/integration/integrationAddTheme.doc.d.mts +5 -0
  48. package/api/integration/integrationAddTheme.doc.mjs +85 -0
  49. package/api/integration/integrationPackCheck.doc.d.mts +5 -0
  50. package/api/integration/integrationPackCheck.doc.mjs +35 -0
  51. package/api/integration/pack-check.d.mts +27 -0
  52. package/api/integration/pack-check.mjs +795 -0
  53. package/api/integration/pack-check.test.mjs +569 -0
  54. package/api/integration/pack-check.type.d.mts +45 -0
  55. package/api/integration/pack-check.type.mjs +56 -0
  56. package/api/integration/public-api.test.mjs +21 -0
  57. package/api/integration/validate-integration.mjs +221 -11
  58. package/api/integration/validate-integration.test.mjs +189 -5
  59. package/api/integration/validateIntegration.doc.mjs +2 -2
  60. package/api/json/index.ts +1 -0
  61. package/api/search/search.mjs +19 -1
  62. package/api/theme/_adapter.d.mts +26 -28
  63. package/api/theme/_adapter.mjs +101 -38
  64. package/api/theme/add/add.d.mts +2 -1
  65. package/api/theme/add/add.mjs +56 -20
  66. package/api/theme/add/add.test.mjs +1 -0
  67. package/api/theme/build/build.d.mts +25 -0
  68. package/api/theme/build/build.mjs +101 -70
  69. package/api/theme/build/build.test.mjs +77 -44
  70. package/api/theme/integration-themes.test.mjs +183 -0
  71. package/api/theme/list/list.d.mts +10 -2
  72. package/api/theme/list/list.mjs +31 -10
  73. package/api/theme/list/list.test.mjs +102 -23
  74. package/api/theme/listThemes.doc.d.mts +1 -5
  75. package/api/theme/listThemes.doc.mjs +6 -13
  76. package/api/theme/targets/targets.test.mjs +22 -8
  77. package/api/theme/theme.d.mts +1 -1
  78. package/api/theme/theme.mjs +1 -1
  79. package/api/theme/theme.type.d.mts +9 -0
  80. package/api/theme/theme.type.mjs +3 -1
  81. package/api/theme/themeAdd.doc.d.mts +1 -4
  82. package/api/theme/themeAdd.doc.mjs +31 -31
  83. package/api/theme/themeBuild.doc.mjs +1 -1
  84. package/api/theme/themeList.doc.d.mts +1 -4
  85. package/api/theme/themeList.doc.mjs +7 -15
  86. package/api/theme/themeListAvailable.doc.d.mts +8 -0
  87. package/api/theme/themeListAvailable.doc.mjs +57 -0
  88. package/api/theme/themeTargets.doc.mjs +21 -7
  89. package/api/upgrade/_adapter.d.mts +2 -0
  90. package/api/upgrade/_adapter.mjs +1 -0
  91. package/api/upgrade/registry/registry.d.mts +40 -0
  92. package/api/upgrade/registry/registry.mjs +1154 -0
  93. package/api/upgrade/registry/registry.test.mjs +826 -0
  94. package/api/upgrade/run/run.mjs +49 -8
  95. package/api/upgrade/status/status.d.mts +6 -4
  96. package/api/upgrade/status/status.mjs +26 -8
  97. package/api/upgrade/upgrade.d.mts +2 -2
  98. package/api/upgrade/upgrade.doc.mjs +33 -9
  99. package/api/upgrade/upgrade.mjs +34 -7
  100. package/api/upgrade/upgrade.test.mjs +198 -8
  101. package/api/upgrade/upgrade.type.d.mts +90 -1
  102. package/api/upgrade/upgrade.type.mjs +51 -2
  103. package/assets/docs/cli-integrations.doc.mjs +152 -28
  104. package/assets/docs/getting-started.doc.mjs +1 -1
  105. package/assets/docs/{shadcn-compatibility.doc.mjs → shadcn-compatibility.doc.draft.mjs} +23 -13
  106. package/assets/docs/styling.doc.mjs +3 -3
  107. package/assets/docs/theme.doc.dense.mjs +2 -2
  108. package/assets/docs/theme.doc.mjs +23 -13
  109. package/assets/docs/theme.doc.zh.mjs +1 -1
  110. package/assets/templates/blocks/components/BaseTypeahead/BaseTypeaheadCustomSearch.doc.mjs +2 -1
  111. package/assets/templates/blocks/components/BaseTypeahead/BaseTypeaheadCustomSearch.tsx +38 -12
  112. package/assets/templates/blocks/components/BaseTypeahead/BaseTypeaheadShowcase.doc.mjs +15 -0
  113. package/assets/templates/blocks/components/BaseTypeahead/BaseTypeaheadShowcase.tsx +87 -0
  114. package/assets/templates/blocks/components/BottomSheet/BottomSheetSwitcherReviewFlow.doc.mjs +23 -0
  115. package/assets/templates/blocks/components/BottomSheet/BottomSheetSwitcherReviewFlow.tsx +75 -0
  116. package/assets/templates/blocks/components/BreadcrumbItem/BreadcrumbItemShowcase.tsx +5 -19
  117. package/assets/templates/blocks/components/Center/CenterHorizontal.doc.mjs +3 -2
  118. package/assets/templates/blocks/components/Center/CenterHorizontal.tsx +4 -5
  119. package/assets/templates/blocks/components/Toast/ToastAction.tsx +2 -1
  120. package/assets/templates/blocks/components/Toast/ToastDeduplication.tsx +2 -1
  121. package/assets/templates/blocks/components/Toast/ToastDismiss.tsx +2 -1
  122. package/assets/templates/blocks/components/Toast/ToastShowcase.tsx +2 -1
  123. package/assets/templates/blocks/components/Toast/ToastStacking.tsx +2 -1
  124. package/assets/templates/blocks/components/Toast/ToastTypes.tsx +2 -1
  125. package/assets/templates/pages/dashboard/template.doc.mjs +2 -2
  126. package/assets/templates/pages/dashboard-alert-rail/template.doc.mjs +3 -2
  127. package/assets/templates/pages/dashboard-cohort-funnel/template.doc.mjs +3 -2
  128. package/assets/templates/pages/dashboard-comparison/template.doc.mjs +3 -3
  129. package/assets/templates/pages/dashboard-composition/template.doc.mjs +2 -2
  130. package/assets/templates/pages/dashboard-progress/template.doc.mjs +2 -2
  131. package/assets/templates/pages/dashboard-scorecard/template.doc.mjs +2 -2
  132. package/assets/templates/themes/butter/butterTheme.ts +3 -3
  133. package/assets/templates/themes/neutral/neutralTheme.ts +2 -2
  134. package/assets/templates/themes/stone/stoneTheme.ts +3 -3
  135. package/assets/theme.template.ts +4 -7
  136. package/authoring/config/config.doc.mjs +9 -1
  137. package/authoring/config/parse.d.mts +2 -0
  138. package/authoring/config/parse.mjs +28 -3
  139. package/authoring/config/parse.test.mjs +25 -3
  140. package/authoring/config/type.ts +3 -0
  141. package/authoring/doctypes/_schema.d.mts +3 -0
  142. package/authoring/doctypes/_schema.mjs +6 -1
  143. package/authoring/doctypes/base/type.ts +6 -6
  144. package/authoring/doctypes/component/component.doc.mjs +6 -0
  145. package/authoring/doctypes/component/type.ts +2 -0
  146. package/authoring/gap-report/parse.d.mts +63 -0
  147. package/authoring/gap-report/parse.mjs +121 -0
  148. package/authoring/gap-report/parse.test.mjs +172 -0
  149. package/authoring/gap-report/type.ts +107 -0
  150. package/authoring/index.d.mts +1 -0
  151. package/authoring/index.d.ts +12 -0
  152. package/authoring/index.mjs +4 -0
  153. package/authoring/integration/integration.doc.mjs +14 -2
  154. package/authoring/integration/parse.test.mjs +9 -4
  155. package/authoring/integration/schema.d.mts +2 -0
  156. package/authoring/integration/schema.mjs +1 -0
  157. package/authoring/integration/type.ts +23 -6
  158. package/authoring/shadcn/receipt.d.mts +219 -0
  159. package/authoring/shadcn/receipt.mjs +248 -0
  160. package/authoring/shadcn/receipt.test.mjs +187 -0
  161. package/authoring/shadcn/source-variants.d.mts +28 -0
  162. package/authoring/shadcn/source-variants.mjs +176 -0
  163. package/authoring/shadcn/source-variants.test.mjs +120 -0
  164. package/clients/cli/commands/build-theme.mjs +54 -19
  165. package/clients/cli/commands/build-theme.variants.test.mjs +15 -12
  166. package/clients/cli/commands/component/index.mjs +1 -1
  167. package/clients/cli/commands/docs.test.mjs +1 -0
  168. package/clients/cli/commands/doctor-integration.doc.mjs +1 -1
  169. package/clients/cli/commands/gap-report.doc.mjs +73 -0
  170. package/clients/cli/commands/gap-report.mjs +114 -0
  171. package/clients/cli/commands/gap-report.test.mjs +198 -0
  172. package/clients/cli/commands/import-hint-correctness.test.mjs +88 -0
  173. package/clients/cli/commands/integration-add.doc.mjs +88 -0
  174. package/clients/cli/commands/integration-authoring.test.mjs +177 -0
  175. package/clients/cli/commands/integration-pack.doc.mjs +34 -0
  176. package/clients/cli/commands/integration-real-world.test.mjs +618 -0
  177. package/clients/cli/commands/integration.doc.mjs +28 -0
  178. package/clients/cli/commands/integration.mjs +153 -0
  179. package/clients/cli/commands/theme-add.doc.mjs +11 -6
  180. package/clients/cli/commands/theme-list.doc.mjs +21 -5
  181. package/clients/cli/commands/theme-targets.behavior.test.mjs +19 -2
  182. package/clients/cli/commands/theme.doc.mjs +2 -2
  183. package/clients/cli/commands/upgrade.doc.mjs +17 -4
  184. package/clients/cli/commands/upgrade.mjs +12 -1
  185. package/clients/cli/commands/upgrade.test.mjs +41 -0
  186. package/clients/cli/index.mjs +5 -0
  187. package/clients/cli/lib/component-format.mjs +42 -26
  188. package/clients/cli/lib/component-format.test.mjs +34 -3
  189. package/clients/cli/lib/manifest.mjs +12 -0
  190. package/foundation/config/project-themes.test.mjs +127 -0
  191. package/foundation/config/project.d.mts +23 -4
  192. package/foundation/config/project.mjs +96 -9
  193. package/foundation/config/project.test.mjs +132 -6
  194. package/foundation/discovery/component-discovery.d.mts +36 -0
  195. package/foundation/discovery/component-discovery.mjs +96 -0
  196. package/foundation/discovery/theme-discovery.d.mts +39 -0
  197. package/foundation/discovery/theme-discovery.mjs +650 -0
  198. package/foundation/discovery/theme-discovery.test.mjs +375 -0
  199. package/foundation/discovery/theming-targets.d.mts +16 -0
  200. package/foundation/discovery/theming-targets.mjs +39 -3
  201. package/foundation/discovery/theming-targets.test.mjs +139 -0
  202. package/foundation/integrations/autolink.d.mts +96 -0
  203. package/foundation/integrations/autolink.mjs +265 -0
  204. package/foundation/integrations/autolink.test.mjs +430 -0
  205. package/foundation/integrations/contribution-inventory.d.mts +152 -0
  206. package/foundation/integrations/contribution-inventory.mjs +497 -0
  207. package/foundation/integrations/contribution-inventory.test.mjs +361 -0
  208. package/foundation/integrations/integrations.d.mts +73 -9
  209. package/foundation/integrations/integrations.mjs +158 -8
  210. package/foundation/integrations/integrations.test.mjs +152 -29
  211. package/foundation/integrations/manifest-writer.d.mts +56 -0
  212. package/foundation/integrations/manifest-writer.mjs +328 -0
  213. package/foundation/integrations/manifest-writer.test.mjs +229 -0
  214. package/foundation/integrations/validate-contributions.mjs +81 -6
  215. package/foundation/response/error-codes.d.mts +4 -1
  216. package/foundation/response/error-codes.doc.mjs +16 -1
  217. package/foundation/response/error-codes.mjs +10 -1
  218. package/foundation/response/response-types.doc.mjs +23 -2
  219. package/package.json +8 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,52 @@
1
1
  # @xds/cli
2
2
 
3
+ # 0.6.1
4
+
5
+ #### New Features
6
+
7
+ - Load an installed integration even when no `astryx.config` names it (#6202)
8
+ A package the project declares as a dependency, and that ships a root `astryx.integration.*` manifest, is now loaded on sight — no config entry required. A scaffold that adds the dependency and writes no config used to leave the integration invisible: its components, templates, docs and codemods all reported as missing, which is indistinguishable from not having installed it at all.
9
+
10
+ Only DECLARED dependencies are probed — `dependencies`, `devDependencies` and `optionalDependencies` — and only by key. `node_modules` is never walked, so a transitive dependency of a dependency cannot contribute; and because the value is never parsed, a dependency that is not a semver range (`npm:` aliases, `workspace:`, `file:`, `link:`, `catalog:`) resolves like any other. Identity comes from the resolved package's own `name`, so an aliased dependency reports the package it actually is, and two dependency keys naming one package load it once.
11
+
12
+ An explicit `astryx.config` entry keeps its precedence and its position, and a dependency whose manifest fails to load is dropped quietly rather than reported as the consuming project's problem.
13
+
14
+ `astryx doctor` gains an `implicit-integrations` line naming each integration linked this way, the package.json field that declared it, and what it contributes — so an author can answer "why can the CLI see this?" without reading the CLI's source, and an unused-dependency check has something to read that says the dependency is load-bearing. The line is always informational, so the doctor CI gate is unaffected.
15
+ - Replace executable gap-report writers with composable handlers. (#6200)
16
+ Gap reports now fan out to every configured handler — project config first, then each loaded integration in config order — instead of selecting one writer. Each handler gets its own report copy and an abort signal under a 30 s budget. A failed handler cannot stop later handlers, and the aggregate receipt shows every outcome.
17
+
18
+ Public types: `GapReportHandler` replaces `GapReportWriter`; the handler receives a normalized `GapReport` event and returns a strict `GapReportHandlerReceipt`. Project config gains a `gapReport` field; the integration named export uses the same type.
19
+ - Add integration authoring and packed-package verification. `astryx integration add <kind> <name>` and the per-kind `integrationAddComponent`, `integrationAddDoc`, `integrationAddTemplate`, `integrationAddCodemod`, `integrationAddAgentDoc`, and `integrationAddTheme` APIs write complete contributions. Existing component, docs, template, and theme commands see the package being authored without publishing it first. `astryx integration pack --check` proves the same contributions survive the npm tarball and that packed components remain available through their public imports. Doctor now names source-only components, unreachable metadata, codemods outside a version folder, and invalid version folders. (#6245)
20
+ - Remove the prefix requirement from theme-local tokens (#6285)
21
+ - Add upgrade receipts and safe three-way reconciliation for ShadCN-copied compositions. (#6228)
22
+ - Let integration packages contribute source themes (#6245)
23
+ An integration can declare a themes root using the same bundle shape as Astryx's built-in themes. Installed themes now appear in `theme list`, and `theme add` can copy one by owner.
24
+
25
+ #### Fixes
26
+
27
+ - build: recommend `template <name> --skeleton` in the kit payload when the top page is not a direct match, matching what the renderer already tells a human (#6255)
28
+ - Center: preserve component-owned axis reflection and correct the horizontal-centering example. (#6207)
29
+ - `astryx component <Name>`'s plain-text output always showed `import {Name} from '@astryxdesign/core/...'`, even for a component owned by an integration package. The JSON response already resolved the import against the correct owner, but the command's text formatter recomputed its own hint via the core-only resolver and ignored that value. (#5294)
30
+ The command now uses the already-resolved `import` field from the component's detail response, so the plain-text output matches the JSON output and shows the integration's own package.
31
+ - Prefer canonical component target names in maintained themes and new examples while preserving deprecated runtime aliases and released bare prop/state selector classes through the 0.7.0 removal window. Theme discovery labels deprecated targets, theme build warns with each exact canonical replacement, and `astryx upgrade --apply` provides the forward-compatible bare-selector migration. (#6126)
32
+ - `component` and `search` now report the same import specifier for an integration component, resolved once in `foundation/discovery/component-discovery.mjs`. `search` previously returned the bare package name, which does not resolve for a package whose components are exported behind subpaths. (#6203)
33
+ - Keep ShadCN composition upgrades safe in JavaScript projects and publish precompiled JSX with strict TypeScript declarations. (#6246)
34
+ - Make generated ShadCN compositions match the exact bytes written by the stock client, include package peer dependencies, and require full-catalog install/build coverage in CI. (#6231)
35
+ - Keep copied integration theme files inside the target project. (#6270)
36
+ - Show all seven dashboard page templates in the templates gallery and playground. (#6264)
37
+
38
+ #### Contributors
39
+
40
+ Thanks to everyone who contributed to this release:
41
+
42
+ - @andrskr
43
+ - @cixzhang
44
+ - @ernestt
45
+ - @josephfarina
46
+ - @kentonquatman
47
+
48
+ ---
49
+
3
50
  # 0.6.0
4
51
 
5
52
  #### Breaking Changes
@@ -548,7 +595,7 @@ Thanks to everyone who contributed to this release:
548
595
  Kept honest by a drift harness (docs vs the live CLI), `check:cli-structure` (each doc-type and `api/` leaf ships its full file set), and lint rules for the CLI's layering.
549
596
 
550
597
  - Add themeable indicators — the componentized check, checkbox, and radio visuals. `defineTheme({indicators: {check: RadioIndicator}})` replaces one by name, and every component drawing it follows. (#4712)
551
- Theme targets now follow the component-name convention: `checkbox-indicator`, `radio-indicator`, `radio-indicator-dot`. The old names (`checkbox`, `radio`, `radio-dot`) are still emitted on the same element, so existing themes keep working — migrate at your convenience; they go away in the next major.
598
+ Theme targets now follow the component-name convention: `checkbox-indicator`, `radio-indicator`, `radio-indicator-dot`. The old names (`checkbox`, `radio`, `radio-dot`) remain emitted on the same element so existing themes keep working. New themes should use the canonical names; deprecation does not set an automatic removal deadline.
552
599
 
553
600
  Migration: menu radios use those shared targets now. `dropdown-menu-radio-dot` is removed — target `radio-indicator-dot`; `astryx upgrade` rewrites it for you.
554
601
 
package/README.md CHANGED
@@ -58,22 +58,24 @@ Options:
58
58
 
59
59
  <!-- BEGIN GENERATED: commands -->
60
60
 
61
- | Command | Description |
62
- | ----------- | ----------------------------------------------------------------------------- |
63
- | `blog` | Read the Astryx blog from the published feed |
64
- | `build` | Build a page: composition kit for an idea, or the workflow playbook (no args) |
65
- | `component` | List components or print component docs |
66
- | `discover` | Discover external packages and components |
67
- | `docs` | Print reference docs |
68
- | `doctor` | Diagnose Astryx projects and integration packages |
69
- | `hook` | List hooks or print hook docs |
70
- | `init` | Initialize the design system in your project |
71
- | `layout` | Generate XDS layouts from compressed expressions (XLE/XLO) |
72
- | `search` | Search components, hooks, docs, and templates in one ranked list |
73
- | `swizzle` | Copy component source for customization |
74
- | `template` | Inject a page or block template |
75
- | `theme` | Theme tools: build, export, and manage themes |
76
- | `upgrade` | Run codemods to migrate between versions |
61
+ | Command | Description |
62
+ | ------------- | ----------------------------------------------------------------------------- |
63
+ | `blog` | Read the Astryx blog from the published feed |
64
+ | `build` | Build a page: composition kit for an idea, or the workflow playbook (no args) |
65
+ | `component` | List components or print component docs |
66
+ | `discover` | Discover external packages and components |
67
+ | `docs` | Print reference docs |
68
+ | `doctor` | Diagnose Astryx projects and integration packages |
69
+ | `gap-report` | Route a design-system gap to its owning package |
70
+ | `hook` | List hooks or print hook docs |
71
+ | `init` | Initialize the design system in your project |
72
+ | `integration` | Author and verify an Astryx integration package |
73
+ | `layout` | Generate XDS layouts from compressed expressions (XLE/XLO) |
74
+ | `search` | Search components, hooks, docs, and templates in one ranked list |
75
+ | `swizzle` | Copy component source for customization |
76
+ | `template` | Inject a page or block template |
77
+ | `theme` | Theme tools: build, export, and manage themes |
78
+ | `upgrade` | Migrate versions and update ShadCN-copied compositions |
77
79
 
78
80
  <!-- END GENERATED: commands -->
79
81
  <!-- Generated by scripts/generate-cli-readme.mjs from `astryx manifest`. Run `pnpm -F @astryxdesign/cli readme`. -->
@@ -137,55 +139,58 @@ if (isError(result)) {
137
139
 
138
140
  <!-- BEGIN GENERATED: error-codes -->
139
141
 
140
- | Code | Meaning |
141
- | ------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
142
- | `ERR_UNKNOWN` | Fallback for any error without a more specific code. |
143
- | `ERR_UNKNOWN_COMMAND` | A top-level command name was not recognized (e.g. `astryx bogus`). |
144
- | `ERR_UNKNOWN_SUBCOMMAND` | A subcommand under a command group was not recognized (e.g. `astryx theme bogus`). |
145
- | `ERR_INVALID_OPTION` | An unknown flag/option was passed (Commander `unknownOption`). |
146
- | `ERR_INVALID_ARGUMENT` | An option/argument had a value Commander's parser rejected. |
147
- | `ERR_MISSING_ARGUMENT` | A required positional argument was omitted (Commander `missingArgument`). |
148
- | `ERR_INVALID_LANG` | `--lang` was given a value outside its choices (en, zh, dense). |
149
- | `ERR_INVALID_DETAIL` | `--detail` was given a value outside its choices (full, compact, brief). |
150
- | `ERR_NODE_VERSION` | The running Node.js version is below the supported minimum. |
151
- | `ERR_CORE_NOT_FOUND` | `@astryxdesign/core` could not be located (not installed / not in a monorepo). |
152
- | `ERR_CORE_INCOMPATIBLE` | The installed `@astryxdesign/core` loaded but is too old for this input — it lacks a capability the CLI must call to emit correct output (upgrade core). |
153
- | `ERR_UNKNOWN_COMPONENT` | No component matched the requested name. |
154
- | `ERR_UNKNOWN_HOOK` | No hook matched the requested name. |
155
- | `ERR_UNKNOWN_TOPIC` | No docs topic matched the requested name. |
156
- | `ERR_UNKNOWN_SECTION` | A docs topic exists but the requested section within it does not. |
157
- | `ERR_UNKNOWN_CATEGORY` | A `--category` filter value did not match any known category. |
158
- | `ERR_UNKNOWN_TEMPLATE` | No template matched the requested name. |
159
- | `ERR_AMBIGUOUS_TEMPLATE` | A template id matched more than one template (narrow with --type/--package). |
160
- | `ERR_AMBIGUOUS_COMPONENT` | A component name is owned by more than one package (narrow with --package). |
161
- | `ERR_UNKNOWN_THEME` | No theme matched the requested slug (theme add). |
162
- | `ERR_UNKNOWN_PACKAGE` | No package matched the requested name (discover). |
163
- | `ERR_UNKNOWN_AGENT` | An unrecognized `--agent` value was passed to agent-docs/init. |
164
- | `ERR_UNKNOWN_FEATURE` | An unrecognized `--features` value was passed to init. |
165
- | `ERR_UNKNOWN_CODEMOD` | A `--codemod` value did not match any registered codemod (upgrade). |
166
- | `ERR_CODEMOD_FAILED` | One or more codemods failed during an upgrade run. |
167
- | `ERR_NOT_FOUND` | A generic discover/lookup query matched nothing in any package. |
168
- | `ERR_NO_DOC` | A component exists but has no typed `.doc.mjs` file. |
169
- | `ERR_NO_SHOWCASE` | No showcase exists for the requested component. |
170
- | `ERR_NO_SOURCE` | No source file could be located for the requested component/template. |
171
- | `ERR_INVALID_DOC` | A component's docs failed validation (malformed `.doc.mjs`). |
172
- | `ERR_FILE_NOT_FOUND` | A required input file did not exist. |
173
- | `ERR_FILE_EXISTS` | Refused to overwrite an existing file in non-interactive mode. |
174
- | `ERR_PATH_TRAVERSAL` | A path escaped its allowed root, or a name contained traversal markers. |
175
- | `ERR_WRITE_FAILED` | Writing output files failed (and was rolled back). |
176
- | `ERR_THEME_INVALID` | A theme definition was missing a required property (e.g. `name`). |
177
- | `ERR_THEME_LOAD` | A theme file could not be loaded / parsed into a defineTheme result. |
178
- | `ERR_PALETTE_GENERATION` | A palette generation request or one of its constraints was invalid. |
179
- | `ERR_VERSION_DETECT` | The current `@astryxdesign/core` version could not be detected. |
180
- | `ERR_INVALID_VERSION` | A `--from`/`--to` value was not a valid semver string. |
181
- | `ERR_DEP_MISSING` | A required external dependency (e.g. jscodeshift) is missing. |
182
- | `ERR_GH_CLI` | GitHub CLI (`gh`) is not installed or not authenticated. |
183
- | `ERR_UNKNOWN_POST` | No blog post matched the requested slug in the feed. |
184
- | `ERR_FETCH_FAILED` | A network fetch (RSS feed or post text) failed. |
185
- | `ERR_LAYOUT_PARSE` | A layout expression failed to parse (syntax error, with line/col). |
186
- | `ERR_LAYOUT_INVALID` | A layout expression parsed but failed validation (unknown component/prop/enum/block). |
187
- | `ERR_UNCLASSIFIED_EXIT` | Recorded in the debug log, never printed: a command exited non-zero without going through cliError/jsonError, so no stable code was available. |
188
- | `ERR_SIGNAL_TERMINATED` | Recorded in the debug log, never printed: the process was ended by a signal (Ctrl-C, SIGTERM) before the command reached a terminal path. |
142
+ | Code | Meaning |
143
+ | --------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
144
+ | `ERR_UNKNOWN` | Fallback for any error without a more specific code. |
145
+ | `ERR_UNKNOWN_COMMAND` | A top-level command name was not recognized (e.g. `astryx bogus`). |
146
+ | `ERR_UNKNOWN_SUBCOMMAND` | A subcommand under a command group was not recognized (e.g. `astryx theme bogus`). |
147
+ | `ERR_INVALID_OPTION` | An unknown flag/option was passed (Commander `unknownOption`). |
148
+ | `ERR_INVALID_ARGUMENT` | An option/argument had a value Commander's parser rejected. |
149
+ | `ERR_MISSING_ARGUMENT` | A required positional argument was omitted (Commander `missingArgument`). |
150
+ | `ERR_INVALID_LANG` | `--lang` was given a value outside its choices (en, zh, dense). |
151
+ | `ERR_INVALID_DETAIL` | `--detail` was given a value outside its choices (full, compact, brief). |
152
+ | `ERR_NODE_VERSION` | The running Node.js version is below the supported minimum. |
153
+ | `ERR_CORE_NOT_FOUND` | `@astryxdesign/core` could not be located (not installed / not in a monorepo). |
154
+ | `ERR_CORE_INCOMPATIBLE` | The installed `@astryxdesign/core` loaded but is too old for this input — it lacks a capability the CLI must call to emit correct output (upgrade core). |
155
+ | `ERR_UNKNOWN_COMPONENT` | No component matched the requested name. |
156
+ | `ERR_UNKNOWN_HOOK` | No hook matched the requested name. |
157
+ | `ERR_UNKNOWN_TOPIC` | No docs topic matched the requested name. |
158
+ | `ERR_UNKNOWN_SECTION` | A docs topic exists but the requested section within it does not. |
159
+ | `ERR_UNKNOWN_CATEGORY` | A `--category` filter value did not match any known category. |
160
+ | `ERR_UNKNOWN_TEMPLATE` | No template matched the requested name. |
161
+ | `ERR_AMBIGUOUS_TEMPLATE` | A template id matched more than one template (narrow with --type/--package). |
162
+ | `ERR_AMBIGUOUS_COMPONENT` | A component name is owned by more than one package (narrow with --package). |
163
+ | `ERR_AMBIGUOUS_THEME` | A theme slug is owned by more than one package (narrow with --package). |
164
+ | `ERR_UNKNOWN_THEME` | No theme matched the requested slug (theme add). |
165
+ | `ERR_INTEGRATION_ROOT_CONFLICT` | An integration manifest already declares a different path for the requested contribution root. |
166
+ | `ERR_INTEGRATION_EXPORT_CONFLICT` | A package export already maps a generated contribution subpath to a different target. |
167
+ | `ERR_UNKNOWN_PACKAGE` | No package matched the requested name (discover). |
168
+ | `ERR_UNKNOWN_AGENT` | An unrecognized `--agent` value was passed to agent-docs/init. |
169
+ | `ERR_UNKNOWN_FEATURE` | An unrecognized `--features` value was passed to init. |
170
+ | `ERR_UNKNOWN_CODEMOD` | A `--codemod` value did not match any registered codemod (upgrade). |
171
+ | `ERR_CODEMOD_FAILED` | One or more codemods failed during an upgrade run. |
172
+ | `ERR_NOT_FOUND` | A generic discover/lookup query matched nothing in any package. |
173
+ | `ERR_NO_DOC` | A component exists but has no typed `.doc.mjs` file. |
174
+ | `ERR_NO_SHOWCASE` | No showcase exists for the requested component. |
175
+ | `ERR_NO_SOURCE` | No source file could be located for the requested component/template. |
176
+ | `ERR_INVALID_DOC` | A component's docs failed validation (malformed `.doc.mjs`). |
177
+ | `ERR_FILE_NOT_FOUND` | A required input file did not exist. |
178
+ | `ERR_FILE_EXISTS` | Refused to overwrite an existing file in non-interactive mode. |
179
+ | `ERR_PATH_TRAVERSAL` | A path escaped its allowed root, or a name contained traversal markers. |
180
+ | `ERR_WRITE_FAILED` | Writing output files failed (and was rolled back). |
181
+ | `ERR_THEME_INVALID` | A theme definition or contributed theme catalog is invalid. |
182
+ | `ERR_THEME_LOAD` | A theme file could not be loaded / parsed into a defineTheme result. |
183
+ | `ERR_PALETTE_GENERATION` | A palette generation request or one of its constraints was invalid. |
184
+ | `ERR_VERSION_DETECT` | The current `@astryxdesign/core` version could not be detected. |
185
+ | `ERR_INVALID_VERSION` | A `--from`/`--to` value was not a valid semver string. |
186
+ | `ERR_DEP_MISSING` | A required external dependency (e.g. jscodeshift) is missing. |
187
+ | `ERR_GH_CLI` | GitHub CLI (`gh`) is not installed or not authenticated. |
188
+ | `ERR_UNKNOWN_POST` | No blog post matched the requested slug in the feed. |
189
+ | `ERR_FETCH_FAILED` | A network fetch (RSS feed or post text) failed. |
190
+ | `ERR_LAYOUT_PARSE` | A layout expression failed to parse (syntax error, with line/col). |
191
+ | `ERR_LAYOUT_INVALID` | A layout expression parsed but failed validation (unknown component/prop/enum/block). |
192
+ | `ERR_UNCLASSIFIED_EXIT` | Recorded in the debug log, never printed: a command exited non-zero without going through cliError/jsonError, so no stable code was available. |
193
+ | `ERR_SIGNAL_TERMINATED` | Recorded in the debug log, never printed: the process was ended by a signal (Ctrl-C, SIGTERM) before the command reached a terminal path. |
189
194
 
190
195
  <!-- END GENERATED: error-codes -->
191
196
  <!-- Generated by scripts/generate-cli-readme.mjs from the error-codes EnumDoc (== ERROR_CODES). Run `pnpm -F @astryxdesign/cli readme`. -->
@@ -410,6 +415,8 @@ Every response has a `type` discriminant. The full set is below (generated from
410
415
  | `build.kit` | The grouped composition kit: echoed query, hasResults/matchCount/directMatch fields (matchCount is the total matched, never a cap read back), the closest page templates, drop-in block patterns, idea-specific components/hooks, and the always-on frame + foundation component-name arrays. |
411
416
  | `swizzle.list` | The names of swizzlable components discoverable from cwd's @astryxdesign/core. |
412
417
  | `swizzle.copy` | An eject receipt: component name, owning package, output directory, files-copied count, the written file names, whether any file uses StyleX, and an optional maintainer note. |
418
+ | `gap-report.categories` | The fixed gap category values and human-readable labels. |
419
+ | `gap-report.file` | An aggregate receipt with overall status, the selected package and issues URL, ordered per-handler deliveries, and filedCount/routedOnlyCount totals. |
413
420
  | `template.list` | Every discovered template (page + block); each entry carries id, name, description, kind, owning package, optional category and componentsUsed, and readiness flags. |
414
421
  | `template.show` | The resolved template's raw source plus its description, kind, and the component names it composes. |
415
422
  | `template.skeleton` | A layout skeleton (structural tags with spatial annotations) plus the template's description and the components it composes. |
@@ -421,8 +428,8 @@ Every response has a `type` discriminant. The full set is below (generated from
421
428
  | `theme.build` | A theme build receipt: name, token- and component-override counts, output size, the written outputs {css, js, dts, and variantsDts when applicable}, and any validation warnings. |
422
429
  | `theme.build.check` | The --check receipt: theme name, an upToDate flag, the stale outputs (each {path, reason: missing \| outdated}), and the full list of checked paths. Writes nothing. |
423
430
  | `theme.build.batch` | Several themes built in one invocation: `count` plus one {file, receipt} per theme in argument order, where receipt is that theme's theme.build (or theme.build.check) envelope, or null when it produced no CSS. |
424
- | `theme.list` | Every bundled theme as a ThemeListEntry[]: each with slug, displayName, description, and a maintained flag. |
425
- | `theme.add` | A scaffold receipt: resolved slug, displayName, maintained flag, outputDir (relative to cwd), the theme entry file, its exportName, and the files written. |
431
+ | `theme.list` | Every bundled or installed integration theme as a ThemeListEntry[]: each with slug, displayName, description, maintained flag, and owner package. |
432
+ | `theme.add` | A scaffold receipt: resolved slug, displayName, maintained flag, owner package, outputDir (relative to cwd), the theme entry file, its exportName, and the files written. |
426
433
  | `theme.template` | A write receipt for the annotated theme template: the path (relative to cwd), whether it was written, and the reason it was not. `exists` when a file was already there, which is a success. |
427
434
  | `theme.targets` | The whole themeable surface: the echoed filter, the component count, and one entry per theming target — {key, className, component, props, states}, where props and states are its legal override keys. |
428
435
  | `theme.palette.generate` | An author-reviewable OKLCH palette candidate, its reproducibility receipt, summary counts, and optional candidate/receipt file-write result. |
@@ -431,6 +438,8 @@ Every response has a `type` discriminant. The full set is below (generated from
431
438
  | `upgrade.run` | The run receipt: from/to versions, codemod count, integrations processed, the agent-docs summary, and (apply mode) filesChanged, transformsApplied, and per-codemod errors. |
432
439
  | `manifest` | The self-describing CLI capability manifest: name, version, apiVersion, global options, the command tree (args, options, json flag, response types, examples), the jsonSupported allowlist, and the flat responseTypes index. |
433
440
  | `doctor` | The health-check report: `checks` (each with id, label, status: pass \| warn \| fail \| info, a message, and a fix when not passing) plus a `summary` of counts per status. |
441
+ | `integration.add` | A contribution-writer receipt: kind, name, optional root {path, created}, integration-manifest path, every affected project-relative path, written, and dryRun. |
442
+ | `integration.pack-check` | The packed-package check: package identity, tarball facts, local and packed contribution inventories, and issues. |
434
443
  | `integration.validate` | The validation result: the package name and version (both null when no local manifest is found) plus issues, an AstryxIntegrationIssue[] of {code, severity: warning \| error, message}. |
435
444
  | `integration.template-conflicts` | The integration identity, structural issues, and non-blocking conflicts where an integration template id is also owned by Core; each conflict includes the exact package-qualified command. |
436
445
  | `integration.component-conflicts` | The integration identity, structural issues, and non-blocking conflicts where an integration component name is also owned by Core; each conflict includes the exact package-qualified command. |
@@ -198,6 +198,43 @@ describe('build kit — a thin kit says what to try next', () => {
198
198
  expect(r.data.hint).toBeTruthy();
199
199
  });
200
200
 
201
+ it('recommends reading the layout, not scaffolding it, on a loose match', async () => {
202
+ // The kit already decides this: `directMatch` false means the top page is
203
+ // a reference, and the renderer says so in prose. The page's `command` is
204
+ // what a program reads instead of that prose, so it has to agree — before
205
+ // this it still said `template <name>`, the scaffold.
206
+ const r = await build('notifications', {cwd: REPO});
207
+ expect(r.type).toBe('build.kit');
208
+ if (r.type !== 'build.kit') return;
209
+ expect(r.data.directMatch).toBe(false);
210
+ expect(r.data.pages.length).toBeGreaterThan(0);
211
+ for (const page of r.data.pages) {
212
+ expect(page.command).toMatch(/--skeleton$/);
213
+ }
214
+ });
215
+
216
+ it('recommends scaffolding on a direct match', async () => {
217
+ const r = await build('contact form', {cwd: REPO});
218
+ expect(r.type).toBe('build.kit');
219
+ if (r.type !== 'build.kit') return;
220
+ expect(r.data.directMatch).toBe(true);
221
+ expect(r.data.pages.length).toBeGreaterThan(0);
222
+ for (const page of r.data.pages) {
223
+ expect(page.command).not.toMatch(/--skeleton/);
224
+ }
225
+ });
226
+
227
+ it('keeps the recommendation package-manager-agnostic', async () => {
228
+ // Appending a flag must not turn into prefixing an invocation; that stays
229
+ // the renderer's job.
230
+ const r = await build('notifications', {cwd: REPO});
231
+ expect(r.type).toBe('build.kit');
232
+ if (r.type !== 'build.kit') return;
233
+ for (const page of r.data.pages) {
234
+ expect(page.command).not.toMatch(/^(pnpm|npm|yarn|bun|npx)\b/);
235
+ }
236
+ });
237
+
201
238
  it('keeps recovery commands bare, for the caller to render', async () => {
202
239
  // The API cannot know how a project invokes the CLI. A baked-in `astryx
203
240
  // component --list` does not resolve in a pnpm workspace.
@@ -29,7 +29,7 @@
29
29
  * @property {boolean} data.hasResults False when search returned nothing (renderer shows "No matches").
30
30
  * @property {number} data.matchCount Total ranked search matches for the query — counted before the search `limit`, the kit's score floors, and its per-group caps, so it is never a cap read back.
31
31
  * @property {boolean} data.directMatch True when the top page template is a confident direct match.
32
- * @property {import('../search/search.type.mjs').SearchResultEntry[]} data.pages Closest page templates (≤3).
32
+ * @property {import('../search/search.type.mjs').SearchResultEntry[]} data.pages Closest page templates (≤3). Each entry's `command` carries `--skeleton` when `directMatch` is false, so it recommends reading the layout rather than scaffolding it.
33
33
  * @property {import('../search/search.type.mjs').SearchResultEntry[]} data.blocks Drop-in block patterns covering parts of the idea (≤5).
34
34
  * @property {import('../search/search.type.mjs').SearchResultEntry[]} data.domain Idea-specific components/hooks (≤6), excluding frame/foundation.
35
35
  * @property {string[]} data.frame Always-on page-shell component names.
@@ -11,6 +11,11 @@
11
11
  * never pre-formatted command strings. All CLI prefixing (formatCliCommand /
12
12
  * getCliInvocation) and the section prose live in the command renderer, so the
13
13
  * JSON shape stays package-manager-agnostic and stable across environments.
14
+ *
15
+ * The one adjustment it makes is on a page's `command`: when the top page is
16
+ * not a direct match the kit appends `--skeleton`, so the field agrees with
17
+ * the recommendation the kit itself computed. That is still not prefixing —
18
+ * the invocation stays the renderer's job.
14
19
  */
15
20
 
16
21
  import {search} from '../../search/search.mjs';
@@ -132,6 +137,31 @@ export async function buildKit(query, options = {}) {
132
137
  .slice(0, 6);
133
138
  const directMatch = pages.length > 0 && pages[0].score >= PAGE_DIRECT;
134
139
 
140
+ /**
141
+ * On a loose match, recommend reading the layout rather than scaffolding it.
142
+ *
143
+ * A page entry's `command` is what a caller runs next, and it was always the
144
+ * scaffold command — `template <name>` — even when the kit had just decided
145
+ * the top page was NOT a direct match. The renderer already says the right
146
+ * thing to a human in that case: RECOMMENDED START prints
147
+ * `template <name> --skeleton` and the PAGE TEMPLATES heading reads "use as
148
+ * a layout reference". But prose is not what a program reads. A JSON caller
149
+ * takes `command` and gets the scaffold, so the two audiences were given
150
+ * opposite advice from the same kit.
151
+ *
152
+ * That matters most for the caller least able to notice. `template <name>`
153
+ * emits the whole page, and an agent handed a full template it did not quite
154
+ * ask for tends to adapt it anyway — which is how a request for one thing
155
+ * comes back as a competent version of another. `--skeleton` gives the
156
+ * layout without the invitation.
157
+ *
158
+ * Copied rather than mutated: these entries come from `search()` and are not
159
+ * this function's to modify.
160
+ */
161
+ const recommendedPages = directMatch
162
+ ? pages
163
+ : pages.map(page => ({...page, command: `${page.command} --skeleton`}));
164
+
135
165
  // What to try when the kit comes back thin. Keyword search over a design
136
166
  // system misses in a predictable way — the reader's words and the package's
137
167
  // often do not overlap — so name the two commands that browse rather than
@@ -160,7 +190,7 @@ export async function buildKit(query, options = {}) {
160
190
  hasResults: matchCount > 0,
161
191
  matchCount,
162
192
  directMatch,
163
- pages,
193
+ pages: recommendedPages,
164
194
  blocks,
165
195
  domain,
166
196
  frame: FRAME,
@@ -18,8 +18,6 @@
18
18
  * deduped, so each leaf stays a thin projection.
19
19
  */
20
20
 
21
- import * as fs from 'node:fs';
22
- import * as path from 'node:path';
23
21
  import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
24
22
  import {findCoreDir, discoverExternalPackages} from '../../foundation/fs/paths.mjs';
25
23
  import {
@@ -31,6 +29,7 @@ import {
31
29
  findIntegrationComponentDoc,
32
30
  findIntegrationComponentSource,
33
31
  resolveImportPath,
32
+ resolveIntegrationImportPath as resolveIntegrationImport,
34
33
  } from '../../foundation/discovery/component-discovery.mjs';
35
34
  import {Project} from '../../foundation/config/project.mjs';
36
35
  import {loadDocs} from '../../foundation/discovery/component-loader.mjs';
@@ -388,39 +387,26 @@ export function withOwnership(docs, owner, componentName, coreDir) {
388
387
  }
389
388
 
390
389
  /**
391
- * Resolve the specifier an integration component is imported from, against the
392
- * owning package's `exports` map.
390
+ * Resolve the specifier an integration component is imported from.
393
391
  *
394
- * A component lives in a directory that need not share its name — several
395
- * components can be exported from one entry point — so the specifier has to
396
- * come from the directory the doc file sits in, checked against `exports`,
397
- * rather than from the component name. Falls back to the package root when the
398
- * directory is not an exported subpath, matching what a consumer would have to
399
- * write by hand.
392
+ * Thin adapter over the shared resolver in foundation, which `search` also
393
+ * uses; the two surfaces have to report the same specifier for the same
394
+ * component.
400
395
  *
401
396
  * @param {OwnershipSubject} owner
402
397
  * @param {string} componentName
403
398
  * @returns {string}
404
399
  */
405
400
  function resolveIntegrationImportPath(owner, componentName) {
406
- const packageDir = owner.integration?.__packageDir;
407
- const directory = owner.docPath
408
- ? path.basename(path.dirname(owner.docPath))
409
- : componentName;
410
- if (!packageDir) {
411
- return owner.package;
412
- }
413
- try {
414
- const manifest = JSON.parse(
415
- fs.readFileSync(path.join(packageDir, 'package.json'), 'utf-8'),
416
- );
417
- if (manifest.exports?.[`./${directory}`]) {
418
- return `${owner.package}/${directory}`;
419
- }
420
- } catch {
421
- // An unreadable or malformed manifest is not worth failing a lookup over.
422
- }
423
- return owner.package;
401
+ return resolveIntegrationImport(
402
+ {
403
+ exportsMap: owner.integration?.__packageExports,
404
+ packageDir: owner.integration?.__packageDir,
405
+ docPath: owner.docPath,
406
+ packageName: owner.package,
407
+ },
408
+ componentName,
409
+ );
424
410
  }
425
411
 
426
412
  /**