@astryxdesign/cli 0.3.0-canary.82d4dab → 0.3.0-canary.d1b7d82

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 (195) hide show
  1. package/README.md +121 -85
  2. package/api/api-docs-parse.test.mjs +47 -0
  3. package/api/blog/blog.doc.d.mts +10 -0
  4. package/api/blog/blog.doc.mjs +66 -0
  5. package/api/build/build.doc.d.mts +10 -0
  6. package/api/build/build.doc.mjs +81 -0
  7. package/api/component/_adapter.mjs +3 -0
  8. package/api/component/component.doc.d.mts +11 -0
  9. package/api/component/component.doc.mjs +180 -0
  10. package/api/discover/discover.doc.d.mts +10 -0
  11. package/api/discover/discover.doc.mjs +109 -0
  12. package/api/docs/docs.doc.d.mts +10 -0
  13. package/api/docs/docs.doc.mjs +98 -0
  14. package/api/doctor/doctor.doc.d.mts +10 -0
  15. package/api/doctor/doctor.doc.mjs +49 -0
  16. package/api/hook/hook.doc.d.mts +10 -0
  17. package/api/hook/hook.doc.mjs +111 -0
  18. package/api/init/init.doc.d.mts +10 -0
  19. package/api/init/init.doc.mjs +100 -0
  20. package/api/integration/summarizeIssues.doc.d.mts +11 -0
  21. package/api/integration/summarizeIssues.doc.mjs +59 -0
  22. package/api/integration/validate-integration.d.mts +2 -18
  23. package/api/integration/validate-integration.mjs +16 -141
  24. package/api/integration/validateIntegration.doc.d.mts +11 -0
  25. package/api/integration/validateIntegration.doc.mjs +63 -0
  26. package/api/json/assertResponse.doc.d.mts +10 -0
  27. package/api/json/assertResponse.doc.mjs +62 -0
  28. package/api/json/isError.doc.d.mts +10 -0
  29. package/api/json/isError.doc.mjs +47 -0
  30. package/api/json/parseResponse.doc.d.mts +10 -0
  31. package/api/json/parseResponse.doc.mjs +54 -0
  32. package/api/layout/layoutCheck.doc.d.mts +11 -0
  33. package/api/layout/layoutCheck.doc.mjs +84 -0
  34. package/api/layout/layoutExpand.doc.d.mts +11 -0
  35. package/api/layout/layoutExpand.doc.mjs +106 -0
  36. package/api/layout/layoutGrammar.doc.d.mts +11 -0
  37. package/api/layout/layoutGrammar.doc.mjs +56 -0
  38. package/api/search/search.d.mts +1 -1
  39. package/api/search/search.doc.d.mts +10 -0
  40. package/api/search/search.doc.mjs +71 -0
  41. package/api/swizzle/swizzle.doc.d.mts +10 -0
  42. package/api/swizzle/swizzle.doc.mjs +119 -0
  43. package/api/template/copy/copy.d.mts +2 -2
  44. package/api/template/copy/copy.mjs +2 -2
  45. package/api/template/list/list.d.mts +2 -2
  46. package/api/template/list/list.mjs +2 -2
  47. package/api/template/show/show.d.mts +2 -2
  48. package/api/template/show/show.mjs +2 -2
  49. package/api/template/skeleton/skeleton.d.mts +3 -3
  50. package/api/template/skeleton/skeleton.mjs +3 -3
  51. package/api/template/template.d.mts +7 -7
  52. package/api/template/template.doc.d.mts +10 -0
  53. package/api/template/template.doc.mjs +142 -0
  54. package/api/template/template.mjs +7 -7
  55. package/api/theme/listThemes.doc.d.mts +12 -0
  56. package/api/theme/listThemes.doc.mjs +44 -0
  57. package/api/theme/themeAdd.doc.d.mts +11 -0
  58. package/api/theme/themeAdd.doc.mjs +92 -0
  59. package/api/theme/themeBuild.doc.d.mts +11 -0
  60. package/api/theme/themeBuild.doc.mjs +108 -0
  61. package/api/theme/themeList.doc.d.mts +11 -0
  62. package/api/theme/themeList.doc.mjs +43 -0
  63. package/api/upgrade/upgrade.doc.d.mts +10 -0
  64. package/api/upgrade/upgrade.doc.mjs +139 -0
  65. package/authoring/_shared/errors.d.mts +21 -0
  66. package/authoring/codemod/codemod.doc.d.mts +11 -0
  67. package/authoring/codemod/codemod.doc.mjs +155 -0
  68. package/authoring/codemod/parse.d.mts +48 -2
  69. package/authoring/config/config.doc.d.mts +10 -0
  70. package/authoring/config/config.doc.mjs +72 -0
  71. package/authoring/config/parse.d.mts +54 -2
  72. package/authoring/doctypes/_schema.d.mts +248 -0
  73. package/authoring/doctypes/_schema.mjs +140 -2
  74. package/authoring/doctypes/command/command.doc.d.mts +12 -0
  75. package/authoring/doctypes/command/command.doc.mjs +241 -0
  76. package/authoring/doctypes/command/parse.d.mts +13 -0
  77. package/authoring/doctypes/command/parse.mjs +26 -0
  78. package/authoring/doctypes/command/type.ts +87 -0
  79. package/authoring/doctypes/component/component.doc.d.mts +11 -0
  80. package/authoring/doctypes/component/component.doc.mjs +254 -0
  81. package/authoring/doctypes/component/parse.d.mts +11 -2
  82. package/authoring/doctypes/doctypes-new.test.mjs +120 -0
  83. package/authoring/doctypes/enum/enum.doc.d.mts +11 -0
  84. package/authoring/doctypes/enum/enum.doc.mjs +114 -0
  85. package/authoring/doctypes/enum/parse.d.mts +13 -0
  86. package/authoring/doctypes/enum/parse.mjs +26 -0
  87. package/authoring/doctypes/enum/type.ts +39 -0
  88. package/authoring/doctypes/function/function.doc.d.mts +11 -0
  89. package/authoring/doctypes/function/function.doc.mjs +266 -0
  90. package/authoring/doctypes/function/parse.d.mts +13 -0
  91. package/authoring/doctypes/function/parse.mjs +30 -0
  92. package/authoring/doctypes/function/type.ts +91 -0
  93. package/authoring/doctypes/hook/hook.doc.d.mts +10 -0
  94. package/authoring/doctypes/hook/hook.doc.mjs +200 -0
  95. package/authoring/doctypes/hook/parse.d.mts +11 -2
  96. package/authoring/doctypes/legacy.d.mts +13 -2
  97. package/authoring/doctypes/parse.d.mts +29 -3
  98. package/authoring/doctypes/parse.mjs +16 -2
  99. package/authoring/doctypes/reference/parse.d.mts +11 -2
  100. package/authoring/doctypes/reference/reference.doc.d.mts +11 -0
  101. package/authoring/doctypes/reference/reference.doc.mjs +146 -0
  102. package/authoring/doctypes/schema/parse.d.mts +13 -0
  103. package/authoring/doctypes/schema/parse.mjs +26 -0
  104. package/authoring/doctypes/schema/schema.doc.d.mts +11 -0
  105. package/authoring/doctypes/schema/schema.doc.mjs +197 -0
  106. package/authoring/doctypes/schema/type.ts +62 -0
  107. package/authoring/doctypes/template/parse.d.mts +12 -2
  108. package/authoring/doctypes/template/template.doc.d.mts +11 -0
  109. package/authoring/doctypes/template/template.doc.mjs +162 -0
  110. package/authoring/doctypes/types.ts +4 -0
  111. package/authoring/index.d.mts +16 -0
  112. package/authoring/index.d.ts +20 -0
  113. package/authoring/index.mjs +4 -0
  114. package/authoring/integration/integration.doc.d.mts +10 -0
  115. package/authoring/integration/integration.doc.mjs +75 -0
  116. package/authoring/integration/parse.d.mts +30 -2
  117. package/clients/cli/commands/blog.doc.mjs +32 -0
  118. package/clients/cli/commands/blog.mjs +8 -5
  119. package/clients/cli/commands/build-theme.mjs +163 -169
  120. package/clients/cli/commands/build.doc.mjs +50 -0
  121. package/clients/cli/commands/build.mjs +8 -8
  122. package/clients/cli/commands/component/index.mjs +8 -12
  123. package/clients/cli/commands/component.doc.mjs +76 -0
  124. package/clients/cli/commands/discover.doc.mjs +43 -0
  125. package/clients/cli/commands/discover.mjs +8 -6
  126. package/clients/cli/commands/docs.doc.mjs +38 -0
  127. package/clients/cli/commands/docs.mjs +8 -5
  128. package/clients/cli/commands/doctor.doc.mjs +31 -0
  129. package/clients/cli/commands/doctor.mjs +13 -11
  130. package/clients/cli/commands/hook/index.mjs +8 -8
  131. package/clients/cli/commands/hook.doc.mjs +51 -0
  132. package/clients/cli/commands/init.doc.mjs +65 -0
  133. package/clients/cli/commands/init.mjs +8 -10
  134. package/clients/cli/commands/layout-check.doc.mjs +54 -0
  135. package/clients/cli/commands/layout-expand.doc.mjs +66 -0
  136. package/clients/cli/commands/layout-grammar.doc.mjs +30 -0
  137. package/clients/cli/commands/layout.doc.mjs +34 -0
  138. package/clients/cli/commands/layout.mjs +28 -25
  139. package/clients/cli/commands/manifest.doc.mjs +30 -0
  140. package/clients/cli/commands/search.doc.mjs +51 -0
  141. package/clients/cli/commands/search.mjs +17 -11
  142. package/clients/cli/commands/swizzle.doc.mjs +58 -0
  143. package/clients/cli/commands/swizzle.mjs +8 -9
  144. package/clients/cli/commands/template.doc.mjs +67 -0
  145. package/clients/cli/commands/template.mjs +8 -10
  146. package/clients/cli/commands/theme-add.doc.mjs +50 -0
  147. package/clients/cli/commands/theme-build.doc.mjs +58 -0
  148. package/clients/cli/commands/theme-list.doc.mjs +28 -0
  149. package/clients/cli/commands/theme.doc.mjs +31 -0
  150. package/clients/cli/commands/upgrade.doc.mjs +90 -0
  151. package/clients/cli/commands/upgrade.mjs +19 -15
  152. package/clients/cli/commands/validate-integration.doc.mjs +36 -0
  153. package/clients/cli/commands/validate-integration.mjs +16 -16
  154. package/clients/cli/lib/define-command.mjs +72 -0
  155. package/clients/cli/lib/define-command.test.mjs +49 -0
  156. package/clients/cli/lib/manifest.mjs +1 -1
  157. package/foundation/agent-docs/agent-docs.d.mts +197 -0
  158. package/foundation/config/config-cache.d.mts +53 -0
  159. package/foundation/config/project.d.mts +154 -0
  160. package/foundation/config/project.mjs +3 -3
  161. package/foundation/discovery/component-discovery.d.mts +140 -0
  162. package/foundation/discovery/component-loader.d.mts +50 -0
  163. package/foundation/discovery/hook-discovery.d.mts +28 -0
  164. package/{api/template/_adapter.d.mts → foundation/discovery/template-adapter.d.mts} +1 -1
  165. package/{api/template/_adapter.mjs → foundation/discovery/template-adapter.mjs} +20 -15
  166. package/foundation/env/node-version.d.mts +52 -0
  167. package/foundation/env/package-manager.d.mts +84 -0
  168. package/foundation/env/semver.d.mts +56 -0
  169. package/foundation/fs/module-loader.d.mts +36 -0
  170. package/foundation/fs/path-safety.d.mts +74 -0
  171. package/foundation/fs/paths.d.mts +35 -0
  172. package/foundation/integrations/integration-warnings.d.mts +17 -0
  173. package/foundation/integrations/integration-warnings.mjs +1 -1
  174. package/foundation/integrations/integrations.d.mts +80 -0
  175. package/foundation/integrations/validate-contributions.d.mts +22 -0
  176. package/foundation/integrations/validate-contributions.mjs +162 -0
  177. package/foundation/response/error-codes.d.mts +103 -0
  178. package/foundation/response/error-codes.doc.d.mts +11 -0
  179. package/foundation/response/error-codes.doc.mjs +239 -0
  180. package/foundation/response/json.d.mts +75 -0
  181. package/foundation/response/response-types.doc.d.mts +12 -0
  182. package/foundation/response/response-types.doc.mjs +242 -0
  183. package/foundation/response/response.doc.d.mts +11 -0
  184. package/foundation/response/response.doc.mjs +161 -0
  185. package/foundation/text/levenshtein.d.mts +21 -0
  186. package/foundation/text/string-utils.d.mts +43 -0
  187. package/foundation/xle/browser.d.mts +89 -0
  188. package/foundation/xle/expand.d.mts +23 -0
  189. package/foundation/xle/parse.d.mts +72 -0
  190. package/foundation/xle/print.d.mts +7 -0
  191. package/foundation/xle/registry-core.d.mts +168 -0
  192. package/foundation/xle/registry.d.mts +19 -0
  193. package/foundation/xle/splice.d.mts +42 -0
  194. package/foundation/xle/validate.d.mts +94 -0
  195. package/package.json +14 -10
package/README.md CHANGED
@@ -56,19 +56,28 @@ Options:
56
56
 
57
57
  ## Commands
58
58
 
59
- | Command | Description |
60
- | ------------- | ---------------------------------------------------------------------------------------------------- |
61
- | `init` | Initialize the design system in your project: installs packages, sets up theming, adds AI agent docs |
62
- | `component` | List components or print detailed docs, props, usage examples, and source |
63
- | `search` | Find components, hooks, docs, and templates in one ranked, cross-domain result set |
64
- | `docs` | Print reference documentation (tokens, theme, color, typography, spacing, etc.) |
65
- | `template` | Inject page or block templates into your project |
66
- | `hook` | List hooks and print hook documentation |
67
- | `swizzle` | Copy component source into your project for deep customization |
68
- | `upgrade` | Run codemods to migrate between versions |
69
- | `theme build` | Compile a defineTheme file to production CSS and JS |
70
- | `discover` | Discover external packages and components |
71
- | `doctor` | Diagnose your Astryx setup and report problems with fixes (CI-friendly via exit code) |
59
+ <!-- BEGIN GENERATED: commands -->
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 your XDS setup and report problems with fixes |
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 |
77
+ | `validate-integration` | Validate an Astryx integration package (manifest + contributions) |
78
+
79
+ <!-- END GENERATED: commands -->
80
+ <!-- Generated by scripts/generate-cli-readme.mjs from `astryx manifest`. Run `pnpm -F @astryxdesign/cli readme`. -->
72
81
 
73
82
  ### Global options
74
83
 
@@ -127,45 +136,56 @@ if (isError(result)) {
127
136
 
128
137
  ### Error codes
129
138
 
130
- | Code | Meaning |
131
- | ------------------------ | -------------------------------------------------------------------------------------- |
132
- | `ERR_UNKNOWN` | Generic fallback for any error without a more specific code. |
133
- | `ERR_UNKNOWN_COMMAND` | A top-level command name was not recognized (e.g. `astryx bogus`). |
134
- | `ERR_UNKNOWN_SUBCOMMAND` | A subcommand under a group was not recognized (e.g. `astryx theme bogus`). |
135
- | `ERR_INVALID_OPTION` | An unknown flag was passed, or `--json` was used on a command that doesn't support it. |
136
- | `ERR_INVALID_ARGUMENT` | An option/argument value was rejected, or required flags were missing. |
137
- | `ERR_MISSING_ARGUMENT` | A required positional argument was omitted (e.g. `astryx theme build` with no file). |
138
- | `ERR_INVALID_LANG` | `--lang` was given a value outside its choices (`en`, `zh`, `dense`). |
139
- | `ERR_INVALID_DETAIL` | `--detail` was given a value outside its choices (`full`, `compact`, `brief`). |
140
- | `ERR_NODE_VERSION` | The running Node.js version is below the supported minimum. |
141
- | `ERR_CORE_NOT_FOUND` | `@astryxdesign/core` could not be located (not installed / not in a monorepo). |
142
- | `ERR_UNKNOWN_COMPONENT` | No component matched the requested name. |
143
- | `ERR_UNKNOWN_HOOK` | No hook matched the requested name. |
144
- | `ERR_UNKNOWN_TOPIC` | No docs topic matched the requested name. |
145
- | `ERR_UNKNOWN_SECTION` | A docs topic exists but the requested section within it does not. |
146
- | `ERR_UNKNOWN_CATEGORY` | A `--category` filter value did not match any known category. |
147
- | `ERR_UNKNOWN_TEMPLATE` | No template matched the requested name. |
148
- | `ERR_UNKNOWN_PACKAGE` | No package matched the requested name (discover). |
149
- | `ERR_UNKNOWN_AGENT` | An unrecognized `--agent` value was passed (agent docs / init). |
150
- | `ERR_UNKNOWN_FEATURE` | An unrecognized `--features` value was passed to `init`. |
151
- | `ERR_UNKNOWN_CODEMOD` | A `--codemod` value did not match any registered codemod (upgrade). |
152
- | `ERR_NOT_FOUND` | A discover/lookup query matched nothing in any package. |
153
- | `ERR_NO_DOC` | A component exists but has no typed `.doc.mjs` file. |
154
- | `ERR_NO_SHOWCASE` | No showcase exists for the requested component. |
155
- | `ERR_NO_SOURCE` | No source file could be located for the component/template. |
156
- | `ERR_INVALID_DOC` | A component's docs failed validation (malformed `.doc.mjs`). |
157
- | `ERR_FILE_NOT_FOUND` | A required input file did not exist. |
158
- | `ERR_FILE_EXISTS` | Refused to overwrite an existing file in non-interactive mode. |
159
- | `ERR_PATH_TRAVERSAL` | A path escaped its allowed root, or a name contained traversal markers. |
160
- | `ERR_WRITE_FAILED` | Writing output files failed (and was rolled back). |
161
- | `ERR_THEME_INVALID` | A theme definition was missing a required property (e.g. `name`). |
162
- | `ERR_THEME_LOAD` | A theme file could not be loaded / parsed into a `defineTheme` result. |
163
- | `ERR_TEMPLATE_CONFIG` | `template.get` is not configured in `astryx.config.mjs` (fetch-by-id). |
164
- | `ERR_TEMPLATE_GET` | A configured `template.get` threw or returned an invalid value. |
165
- | `ERR_VERSION_DETECT` | The current `@astryxdesign/core` version could not be detected. |
166
- | `ERR_INVALID_VERSION` | A `--from`/`--to` value was not a valid semver string. |
167
- | `ERR_DEP_MISSING` | A required external dependency (e.g. jscodeshift) is missing. |
168
- | `ERR_GH_CLI` | GitHub CLI (`gh`) is not installed or not authenticated. |
139
+ <!-- BEGIN GENERATED: error-codes -->
140
+
141
+ | Code | Meaning |
142
+ | ------------------------- | ------------------------------------------------------------------------------------- |
143
+ | `ERR_UNKNOWN` | Fallback for any error without a more specific code. |
144
+ | `ERR_UNKNOWN_COMMAND` | A top-level command name was not recognized (e.g. `astryx bogus`). |
145
+ | `ERR_UNKNOWN_SUBCOMMAND` | A subcommand under a command group was not recognized (e.g. `astryx theme bogus`). |
146
+ | `ERR_INVALID_OPTION` | An unknown flag/option was passed (Commander `unknownOption`). |
147
+ | `ERR_INVALID_ARGUMENT` | An option/argument had a value Commander's parser rejected. |
148
+ | `ERR_MISSING_ARGUMENT` | A required positional argument was omitted (Commander `missingArgument`). |
149
+ | `ERR_INVALID_LANG` | `--lang` was given a value outside its choices (en, zh, dense). |
150
+ | `ERR_INVALID_DETAIL` | `--detail` was given a value outside its choices (full, compact, brief). |
151
+ | `ERR_NODE_VERSION` | The running Node.js version is below the supported minimum. |
152
+ | `ERR_CORE_NOT_FOUND` | `@astryxdesign/core` could not be located (not installed / not in a monorepo). |
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_VERSION_DETECT` | The current `@astryxdesign/core` version could not be detected. |
179
+ | `ERR_INVALID_VERSION` | A `--from`/`--to` value was not a valid semver string. |
180
+ | `ERR_DEP_MISSING` | A required external dependency (e.g. jscodeshift) is missing. |
181
+ | `ERR_GH_CLI` | GitHub CLI (`gh`) is not installed or not authenticated. |
182
+ | `ERR_UNKNOWN_POST` | No blog post matched the requested slug in the feed. |
183
+ | `ERR_FETCH_FAILED` | A network fetch (RSS feed or post text) failed. |
184
+ | `ERR_LAYOUT_PARSE` | A layout expression failed to parse (syntax error, with line/col). |
185
+ | `ERR_LAYOUT_INVALID` | A layout expression parsed but failed validation (unknown component/prop/enum/block). |
186
+
187
+ <!-- END GENERATED: error-codes -->
188
+ <!-- Generated by scripts/generate-cli-readme.mjs from the error-codes EnumDoc (== ERROR_CODES). Run `pnpm -F @astryxdesign/cli readme`. -->
169
189
 
170
190
  ## Capability manifest (agent discovery)
171
191
 
@@ -359,39 +379,55 @@ detail.data.name; // narrowed
359
379
 
360
380
  ### Type discriminators
361
381
 
362
- Every response has a `type` string that uniquely identifies it:
363
-
364
- | Command | Type | Response |
365
- | ------------------------------------------------------------------ | ------------------------------------ | --------------------------------- |
366
- | `astryx --json component [--list] [--detail names\|compact\|full]` | `component.list` (see `data.detail`) | `ComponentListResponse` |
367
- | `astryx --json component <name>` | `component.detail` | `ComponentDetailResponse` |
368
- | `astryx --json component <name> --props` | `component.detail.props` | `ComponentDetailPropsResponse` |
369
- | `astryx --json component <name> --source` | `component.detail.source` | `ComponentDetailSourceResponse` |
370
- | `astryx --json component <name> --showcase` | `component.detail.showcase` | `ComponentDetailShowcaseResponse` |
371
- | `astryx --json component <name> --blocks` | `component.detail.blocks` | `ComponentDetailBlocksResponse` |
372
- | `astryx --json discover` | `discover.list` | `DiscoverListResponse` |
373
- | `astryx --json discover @scope/name` | `discover.detail` | `DiscoverDetailResponse` |
374
- | `astryx --json discover @scope/name/Comp` | `discover.detail.doc` | `DiscoverDetailDocResponse` |
375
- | `astryx --json discover <search>` | `discover.search` | `DiscoverSearchResponse` |
376
- | `astryx --json docs` | `docs.list` | `DocsListResponse` |
377
- | `astryx --json docs <topic>` | `docs.detail` | `DocsDetailResponse` |
378
- | `astryx --json docs <topic> <section>` | `docs.detail.section` | `DocsDetailSectionResponse` |
379
- | `astryx --json template [--list]` | `template.list` | `TemplateListResponse` |
380
- | `astryx --json template <name>` | `template.show` | `TemplateShowResponse` |
381
- | `astryx --json template <name> --skeleton` | `template.skeleton` | `TemplateSkeletonResponse` |
382
- | `astryx --json template <name> [path]` | `template.copy` | `TemplateCopyResponse` |
383
- | `astryx --json hook [--list] [--detail names\|compact\|full]` | `hook.list` (see `data.detail`) | `HookListResponse` |
384
- | `astryx --json hook <name>` | `hook.detail` | `HookDetailResponse` |
385
- | `astryx --json hook <name> --params` | `hook.detail.params` | `HookDetailParamsResponse` |
386
- | `astryx --json search <query>` | `search` | `SearchResponse` |
387
- | `astryx --json swizzle [--list]` | `swizzle.list` | `SwizzleListResponse` |
388
- | `astryx --json swizzle <component>` | `swizzle.copy` | `SwizzleCopyResponse` |
389
- | `astryx --json theme build <file>` | `theme.build` | `ThemeBuildResponse` |
390
- | `astryx --json upgrade --list` | `upgrade.list` | `UpgradeListResponse` |
391
- | `astryx --json upgrade [--apply]` | `upgrade.run` | `UpgradeRunResponse` |
392
- | `astryx --json doctor` | `doctor` | `DoctorResponse` |
393
- | any error | — | `CLIError` |
394
- | unsupported command | — | `CLIUnsupportedError` |
382
+ Every response has a `type` discriminant. The full set is below (generated from the manifest). Each command's `type`s are also listed in `astryx manifest --json`, and the matching `*Response` TypeScript types (e.g. `ComponentDetailResponse`) are exported from `@astryxdesign/cli/json`. Errors use `CLIError`, and unsupported commands use `CLIUnsupportedError`.
383
+
384
+ <!-- BEGIN GENERATED: response-types -->
385
+
386
+ | Type | What `data` carries |
387
+ | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
388
+ | `component.list` | The component catalog grouped by category: `detail` (the level — names \| compact \| full) and `components`, the grouped map of names+package, brief entries, or a full ComponentDoc per entry. |
389
+ | `component.detail` | One component's authored ComponentDoc plus ownership metadata (owner package, import specifier, and whether source is available). |
390
+ | `component.detail.props` | Just one component's props table (ComponentPropDoc[]). |
391
+ | `component.detail.source` | One component's source file, as {component, source}. |
392
+ | `component.detail.showcase` | One component's showcase example, as {component, aspectRatio, source}. |
393
+ | `component.detail.blocks` | One component's example blocks, as {component, showcase, examples, related} of BlockEntry. |
394
+ | `docs.list` | All reference-doc topics as DocsListEntry[] ({topic, description}), in discovery order. |
395
+ | `docs.detail` | One topic's full ReferenceDoc, with token-ref blocks inlined. |
396
+ | `docs.detail.section` | A single ReferenceSection of a topic — the first whose title contains the section query. |
397
+ | `blog.list` | The feed URL plus every post parsed from the RSS feed — each with slug, title, description, date, type, authors, link, and plaintext URL. |
398
+ | `blog.detail` | One post's metadata plus the feed URL and the post's full plaintext body. |
399
+ | `discover.list` | The configured external packages (name, category, components, version, description); when empty it carries meta.configured to tell "nothing configured" from "nothing discovered". |
400
+ | `discover.detail` | A single external package entry, for an @scope/name query. |
401
+ | `discover.detail.doc` | The validated ComponentDoc for one external component — an @scope/name/Component query, or a free-text term resolving to exactly one component. |
402
+ | `discover.search` | The echoed query plus the matching {package, component} pairs, when a free-text term matches several components. |
403
+ | `search` | The echoed query plus a ranked SearchResultEntry[] (domain, name, score, reason, description, follow-up command, and import path where relevant). |
404
+ | `build.help` | A marker (`playbook: true`) that the renderer expands into the how-to-build-a-page workflow; emitted when no query is given. |
405
+ | `build.kit` | The grouped composition kit: echoed query, hasResults/directMatch flags, the closest page templates, drop-in block patterns, idea-specific components/hooks, and the always-on frame + foundation component-name arrays. |
406
+ | `swizzle.list` | The names of swizzlable components discoverable from cwd's @astryxdesign/core. |
407
+ | `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. |
408
+ | `template.list` | Every discovered template (page + block); each entry carries id, name, description, kind, owning package, optional category and componentsUsed, and readiness flags. |
409
+ | `template.show` | The resolved template's raw source plus its description, kind, and the component names it composes. |
410
+ | `template.skeleton` | A layout skeleton (structural tags with spatial annotations) plus the template's description and the components it composes. |
411
+ | `template.copy` | A scaffold receipt: template id, output directory, written file name, and file count. |
412
+ | `hook.list` | The hook catalog grouped by category: `detail` (the level — names \| compact \| full) and `components`, the grouped map of hook names, brief entries, or a full HookDoc per entry. |
413
+ | `hook.detail` | One hook's full authored HookDoc. |
414
+ | `hook.detail.params` | Just one hook's parameters table (HookParamDoc[]). |
415
+ | `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. |
416
+ | `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. |
417
+ | `theme.list` | Every bundled theme as a ThemeListEntry[] — each with slug, displayName, description, and a maintained flag. |
418
+ | `theme.add` | A scaffold receipt: resolved slug, displayName, maintained flag, outputDir (relative to cwd), the theme entry file, its exportName, and the files written. |
419
+ | `upgrade.list` | Every available codemod, oldest→newest, as {name, title, version, optional}; returned for --list without running anything. |
420
+ | `upgrade.status` | A short-circuit outcome with no codemods run — up_to_date, no_codemods, or config_fixable — each carrying the agent-docs summary. |
421
+ | `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. |
422
+ | `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. |
423
+ | `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. |
424
+ | `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}. |
425
+ | `layout.expand` | The expansion: parsed form, generated TSX code, componentsUsed, states (count of useState hooks scaffolded), todos, blocksReferenced (each {name, mode}), warnings, and written (the output path, or null when nothing was written). |
426
+ | `layout.check` | The validation result: a valid flag, the detected form, errors (each with line/col, message, formatted text, and suggestions), warnings, and the expression re-printed in both canonical surfaces (compact and outline). |
427
+ | `layout.grammar` | The XLE/XLO grammar cheatsheet: a text field with the full reference plus an aliases map (short name → canonical component) generated from this install's registry. |
428
+
429
+ <!-- END GENERATED: response-types -->
430
+ <!-- Generated by scripts/generate-cli-readme.mjs from the response-types EnumDoc. Run `pnpm -F @astryxdesign/cli readme`. -->
395
431
 
396
432
  ## Doctor
397
433
 
@@ -0,0 +1,47 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file Validates every colocated FunctionDoc under `api/**` — each `*.doc.mjs`
5
+ * must export a `doc` that passes `parseDoc` (stamped `type: 'function'`). This
6
+ * is the safety net for the hand-authored API function docs.
7
+ */
8
+
9
+ import * as fs from 'node:fs';
10
+ import * as path from 'node:path';
11
+ import {fileURLToPath, pathToFileURL} from 'node:url';
12
+ import {describe, it, expect} from 'vitest';
13
+ import {parseDoc} from '../authoring/index.mjs';
14
+
15
+ const API_DIR = path.dirname(fileURLToPath(import.meta.url));
16
+
17
+ /** @param {string} dir @returns {string[]} */
18
+ function findDocs(dir) {
19
+ /** @type {string[]} */
20
+ const out = [];
21
+ for (const entry of fs.readdirSync(dir, {withFileTypes: true})) {
22
+ const p = path.join(dir, entry.name);
23
+ if (entry.isDirectory()) out.push(...findDocs(p));
24
+ else if (entry.name.endsWith('.doc.mjs')) out.push(p);
25
+ }
26
+ return out;
27
+ }
28
+
29
+ describe('api FunctionDocs', () => {
30
+ const files = findDocs(API_DIR);
31
+
32
+ it('discovers colocated function docs', () => {
33
+ expect(files.length).toBeGreaterThan(0);
34
+ });
35
+
36
+ for (const file of files) {
37
+ const rel = path.relative(API_DIR, file);
38
+ it(`parses ${rel}`, async () => {
39
+ const mod = await import(pathToFileURL(file).href);
40
+ const doc = mod.doc ?? mod.docs;
41
+ expect(doc, `${rel} must export \`doc\``).toBeTruthy();
42
+ expect(doc.type, `${rel} should be a function doc`).toBe('function');
43
+ const parsed = parseDoc(doc);
44
+ expect(parsed.name, `${rel} needs a name`).toBeTruthy();
45
+ });
46
+ }
47
+ });
@@ -0,0 +1,10 @@
1
+ // @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
2
+ // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
+
4
+ /**
5
+ * @file FunctionDoc for `blog()` / `astryx blog`. Colocated with the API
6
+ * function it documents; the shape source of truth stays in `blog.type.mjs`.
7
+ * @position packages/cli/api/blog — function documentation
8
+ */
9
+ /** @type {import('@astryxdesign/cli/authoring').FunctionDoc} */
10
+ export const doc: import("@astryxdesign/cli/authoring").FunctionDoc;
@@ -0,0 +1,66 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file FunctionDoc for `blog()` / `astryx blog`. Colocated with the API
5
+ * function it documents; the shape source of truth stays in `blog.type.mjs`.
6
+ * @position packages/cli/api/blog — function documentation
7
+ */
8
+
9
+ /** @type {import('@astryxdesign/cli/authoring').FunctionDoc} */
10
+ export const doc = {
11
+ type: 'function',
12
+ kind: 'api',
13
+ name: 'blog',
14
+ displayName: 'blog()',
15
+ summary: 'List blog posts, or read one, from the published RSS feed.',
16
+ description:
17
+ 'Reads the design system blog the same way any feed reader does — over the ' +
18
+ "published RSS feed, never the blog's source files. With no slug it lists every " +
19
+ "post parsed from the feed; with a slug it reads that post's full plaintext body " +
20
+ 'via the .txt alternate the feed advertises. Both envelopes carry feedUrl so a ' +
21
+ 'caller can hit the RSS feed directly.',
22
+ importPath: '@astryxdesign/cli/api',
23
+ signature:
24
+ 'blog(slug?: string): Promise<BlogListResponse | BlogDetailResponse>',
25
+ keywords: ['blog', 'posts', 'rss', 'feed', 'news', 'article'],
26
+ params: [
27
+ {
28
+ name: 'slug',
29
+ type: 'string',
30
+ description:
31
+ 'Post slug (matched case-insensitively) to read in full. Omit to list every post.',
32
+ },
33
+ ],
34
+ returns: [
35
+ {
36
+ type: 'blog.list',
37
+ description:
38
+ 'The feed URL plus every post parsed from the feed — each with slug, title, description, date, type, authors, link, and its plaintext URL.',
39
+ },
40
+ {
41
+ type: 'blog.detail',
42
+ description:
43
+ "One post's metadata plus the feed URL and the post's full plaintext body.",
44
+ },
45
+ ],
46
+ throws: [
47
+ {
48
+ code: 'ERR_INVALID_ARGUMENT',
49
+ when: 'the slug is provided but is not a string',
50
+ },
51
+ {
52
+ code: 'ERR_UNKNOWN_POST',
53
+ when: 'no post in the feed matches the requested slug',
54
+ },
55
+ {
56
+ code: 'ERR_FETCH_FAILED',
57
+ when: 'the RSS feed or post text cannot be fetched (network error, timeout, non-2xx, or oversized), or the post has no plaintext alternate in the feed',
58
+ },
59
+ ],
60
+ examples: [
61
+ {label: 'List posts', code: 'const {data} = await blog();'},
62
+ {label: 'Read one post', code: "await blog('introducing-astryx');"},
63
+ ],
64
+ command: 'blog',
65
+ related: ['docs', 'search'],
66
+ };
@@ -0,0 +1,10 @@
1
+ // @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
2
+ // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
+
4
+ /**
5
+ * @file FunctionDoc for `build()` / `astryx build`. Colocated with the API
6
+ * function it documents; the shape source of truth stays in `build.type.mjs`.
7
+ * @position packages/cli/api/build — function documentation
8
+ */
9
+ /** @type {import('@astryxdesign/cli/authoring').FunctionDoc} */
10
+ export const doc: import("@astryxdesign/cli/authoring").FunctionDoc;
@@ -0,0 +1,81 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file FunctionDoc for `build()` / `astryx build`. Colocated with the API
5
+ * function it documents; the shape source of truth stays in `build.type.mjs`.
6
+ * @position packages/cli/api/build — function documentation
7
+ */
8
+
9
+ /** @type {import('@astryxdesign/cli/authoring').FunctionDoc} */
10
+ export const doc = {
11
+ type: 'function',
12
+ kind: 'api',
13
+ name: 'build',
14
+ displayName: 'build()',
15
+ summary:
16
+ 'Page-building assistant: the how-to-build playbook, or a composition kit for an idea.',
17
+ description:
18
+ 'The "assemble a page" entry point. Called with no query it returns the ' +
19
+ 'playbook signal that the renderer expands into the how-to-build-a-page ' +
20
+ 'workflow. Called with a query it runs the unified search and groups the ' +
21
+ 'hits into a composition KIT: the closest page templates, drop-in blocks, ' +
22
+ 'and idea-specific components/hooks, plus the always-on frame + foundation.',
23
+ importPath: '@astryxdesign/cli/api',
24
+ signature:
25
+ 'build(query?: string, options?: BuildOptions): Promise<BuildHelpResponse | BuildKitResponse>',
26
+ keywords: ['build', 'compose', 'assemble', 'page', 'kit', 'scaffold'],
27
+ params: [
28
+ {
29
+ name: 'query',
30
+ type: 'string',
31
+ description:
32
+ 'What you\'re building (e.g. "analytics dashboard"). Omit for the how-to-build playbook.',
33
+ },
34
+ {
35
+ name: 'options.cwd',
36
+ type: 'string',
37
+ description:
38
+ 'Directory to resolve @astryxdesign/core and templates from.',
39
+ },
40
+ {
41
+ name: 'options.type',
42
+ type: "'component' | 'hook' | 'doc' | 'template'",
43
+ description: 'Restrict the underlying search to a single domain.',
44
+ },
45
+ {
46
+ name: 'options.limit',
47
+ type: 'number',
48
+ description:
49
+ 'Max results pulled from search before grouping into the kit.',
50
+ default: '60',
51
+ },
52
+ ],
53
+ returns: [
54
+ {
55
+ type: 'build.help',
56
+ description:
57
+ 'Emitted when the query is omitted — a pure marker (`data.playbook: true`) that the command renderer expands into the page-building workflow prose.',
58
+ },
59
+ {
60
+ type: 'build.kit',
61
+ description:
62
+ 'The grouped composition kit: the echoed query, hasResults/directMatch flags, the closest page templates (≤3), drop-in block patterns (≤5), idea-specific components/hooks (≤6), and the always-on frame + foundation component-name arrays.',
63
+ },
64
+ ],
65
+ throws: [
66
+ {
67
+ code: 'ERR_INVALID_ARGUMENT',
68
+ when: 'options.type is not a known domain, or options.limit is not a positive integer',
69
+ },
70
+ ],
71
+ examples: [
72
+ {label: 'Get the playbook', code: 'const r = await build();'},
73
+ {label: 'Compose a page', code: "await build('analytics dashboard');"},
74
+ {
75
+ label: 'Restrict + limit',
76
+ code: "await build('pricing', {type: 'template', limit: 10});",
77
+ },
78
+ ],
79
+ command: 'build',
80
+ related: ['search', 'template', 'component', 'hook', 'init'],
81
+ };
@@ -270,6 +270,9 @@ export async function resolveUnscopedDoc(dirName, {coreDir, cwd, name}) {
270
270
  let resolvedName = dirName;
271
271
  // Track the resolving owner so the detail payload can carry ownership info.
272
272
  // Defaults to core; the legacy-external fallback below may reassign it.
273
+ // Annotated because CORE_PACKAGE's generated declaration carries the literal
274
+ // type, which (unlike a fresh literal) does not widen on assignment.
275
+ /** @type {string} */
273
276
  let resolvedOwnerPackage = CORE_PACKAGE;
274
277
  let resolvedSourcePath = readmePath ? findComponentSource(coreDir, dirName) : null;
275
278
 
@@ -0,0 +1,11 @@
1
+ // @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
2
+ // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
+
4
+ /**
5
+ * @file FunctionDoc for `component()` / `astryx component`. Colocated with the
6
+ * API function it documents; the shape source of truth stays in
7
+ * `component.type.mjs`.
8
+ * @position packages/cli/api/component — function documentation
9
+ */
10
+ /** @type {import('@astryxdesign/cli/authoring').FunctionDoc} */
11
+ export const doc: import("@astryxdesign/cli/authoring").FunctionDoc;