@astryxdesign/cli 0.6.4-canary.10dd683 → 0.6.4-canary.1745a95

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 (233) hide show
  1. package/README.md +97 -91
  2. package/api/build/build.doc.mjs +6 -1
  3. package/api/build/build.test.mjs +22 -0
  4. package/api/build/kit/kit.mjs +44 -5
  5. package/api/component/_adapter.d.mts +25 -0
  6. package/api/component/_adapter.mjs +59 -5
  7. package/api/component/component.d.mts +6 -3
  8. package/api/component/component.doc.mjs +37 -17
  9. package/api/component/component.mjs +249 -9
  10. package/api/component/component.type.d.mts +25 -0
  11. package/api/component/component.type.mjs +44 -0
  12. package/api/docs/_adapter.d.mts +8 -3
  13. package/api/docs/_adapter.mjs +14 -6
  14. package/api/docs/docOverlays.test.mjs +27 -1
  15. package/api/docs/docs.doc.mjs +2 -2
  16. package/api/doctor/doctor.d.mts +8 -3
  17. package/api/doctor/doctor.doc.mjs +17 -8
  18. package/api/doctor/doctor.mjs +90 -9
  19. package/api/doctor/doctor.test.mjs +122 -10
  20. package/api/doctor/doctor.type.d.mts +1 -1
  21. package/api/doctor/doctor.type.mjs +1 -1
  22. package/api/gap-report/gap-report.doc.mjs +19 -10
  23. package/api/hook/hook.doc.mjs +6 -3
  24. package/api/index.d.mts +1 -0
  25. package/api/index.mjs +5 -3
  26. package/api/init/init.doc.mjs +17 -12
  27. package/api/integration/add-theme.mjs +22 -1
  28. package/api/integration/add-theme.test.mjs +34 -0
  29. package/api/integration/authoring-checks.mjs +2 -2
  30. package/api/integration/integrationPackCheck.doc.mjs +3 -3
  31. package/api/integration/pack-check.lifecycle-output.test.mjs +107 -0
  32. package/api/integration/pack-check.mjs +82 -9
  33. package/api/integration/pack-check.test.mjs +90 -0
  34. package/api/integration/pack-check.type.mjs +1 -1
  35. package/api/json/assertResponse.doc.mjs +1 -1
  36. package/api/json/isError.doc.mjs +1 -1
  37. package/api/search/search.d.mts +27 -1
  38. package/api/search/search.doc.mjs +2 -2
  39. package/api/search/search.mjs +228 -16
  40. package/api/swizzle/swizzle.doc.mjs +7 -5
  41. package/api/template/copy/copy.mjs +1 -1
  42. package/api/template/copy/copy.test.mjs +9 -0
  43. package/api/template/template.doc.mjs +2 -1
  44. package/api/theme/generateTonalPalette.doc.mjs +1 -2
  45. package/api/theme/listThemes.doc.mjs +1 -1
  46. package/api/theme/themeAdd.doc.mjs +9 -10
  47. package/api/theme/themeBuild.doc.mjs +13 -13
  48. package/api/theme/themeList.doc.mjs +1 -1
  49. package/api/theme/themeListAvailable.doc.mjs +2 -1
  50. package/api/theme/themePaletteGenerate.doc.mjs +15 -8
  51. package/api/theme/themeTargets.doc.mjs +3 -2
  52. package/api/theme/themeTemplate.doc.mjs +2 -1
  53. package/api/upgrade/run/files-changed.test.mjs +111 -0
  54. package/api/upgrade/run/run.mjs +5 -3
  55. package/api/upgrade/upgrade.doc.mjs +24 -22
  56. package/api/upgrade/upgrade.type.mjs +2 -2
  57. package/assets/codemods/__tests__/runner.test.mjs +3 -1
  58. package/assets/codemods/file-count.test.mjs +163 -0
  59. package/assets/codemods/integration-runner.mjs +3 -3
  60. package/assets/codemods/runner.mjs +5 -4
  61. package/assets/docs/README.md +4 -2
  62. package/assets/docs/browser-support.doc.mjs +11 -11
  63. package/assets/docs/color.doc.mjs +8 -2
  64. package/assets/docs/elevation.doc.mjs +6 -4
  65. package/assets/docs/getting-started.doc.mjs +5 -16
  66. package/assets/docs/icons.doc.mjs +2 -21
  67. package/assets/docs/illustrations.doc.mjs +7 -15
  68. package/assets/docs/layout.doc.dense.mjs +130 -82
  69. package/assets/docs/layout.doc.mjs +133 -77
  70. package/assets/docs/migration.doc.mjs +19 -21
  71. package/assets/docs/motion.doc.mjs +16 -3
  72. package/assets/docs/principles.doc.dense.mjs +5 -5
  73. package/assets/docs/principles.doc.mjs +8 -0
  74. package/assets/docs/principles.doc.zh.mjs +6 -6
  75. package/assets/docs/shape.doc.mjs +8 -3
  76. package/assets/docs/spacing.doc.mjs +7 -2
  77. package/assets/docs/styling-libraries.doc.mjs +6 -2
  78. package/assets/docs/styling.doc.mjs +19 -23
  79. package/assets/docs/theme.doc.dense.mjs +58 -18
  80. package/assets/docs/theme.doc.mjs +56 -46
  81. package/assets/docs/theme.doc.zh.mjs +9 -8
  82. package/assets/docs/tokens.doc.dense.mjs +2 -2
  83. package/assets/docs/tokens.doc.mjs +389 -8
  84. package/assets/docs/tokens.doc.zh.mjs +2 -2
  85. package/assets/docs/tree/add-a-component.doc.mjs +75 -0
  86. package/assets/docs/tree/add-a-theme.doc.mjs +85 -0
  87. package/assets/docs/tree/add-a-topic.doc.mjs +144 -0
  88. package/assets/docs/tree/agent-guidance.doc.mjs +138 -0
  89. package/assets/docs/tree/block-template.doc.mjs +130 -0
  90. package/assets/docs/tree/build-the-template.doc.mjs +28 -0
  91. package/assets/docs/tree/building-blocks.doc.mjs +46 -0
  92. package/assets/docs/tree/check-your-docs.doc.mjs +137 -0
  93. package/assets/docs/tree/checks.doc.mjs +119 -0
  94. package/assets/docs/tree/codemods.doc.mjs +147 -0
  95. package/assets/docs/tree/component-family.doc.mjs +113 -0
  96. package/assets/docs/tree/component-imports.doc.mjs +69 -0
  97. package/assets/docs/tree/component-lookups.doc.mjs +149 -0
  98. package/assets/docs/tree/components.doc.mjs +23 -0
  99. package/assets/docs/tree/configuration.doc.mjs +23 -0
  100. package/assets/docs/tree/debug-and-gap-reports.doc.mjs +182 -0
  101. package/assets/docs/tree/define-the-theme.doc.mjs +118 -0
  102. package/assets/docs/tree/describe-the-component.doc.mjs +57 -0
  103. package/assets/docs/tree/docs.doc.mjs +21 -0
  104. package/assets/docs/tree/document-the-template.doc.mjs +28 -0
  105. package/assets/docs/tree/document-the-theme.doc.mjs +68 -0
  106. package/assets/docs/tree/export-template-assets.doc.mjs +147 -0
  107. package/assets/docs/tree/extend-or-replace.doc.mjs +103 -0
  108. package/assets/docs/tree/fonts-and-assets.doc.mjs +106 -0
  109. package/assets/docs/tree/generate-a-palette.doc.mjs +66 -0
  110. package/assets/docs/tree/grade-template-with-agent.doc.mjs +105 -0
  111. package/assets/docs/tree/help.doc.mjs +16 -0
  112. package/assets/docs/tree/integrations.doc.mjs +25 -470
  113. package/assets/docs/tree/links.doc.mjs +98 -0
  114. package/assets/docs/tree/package-and-test.doc.mjs +32 -0
  115. package/assets/docs/tree/page-template.doc.mjs +71 -0
  116. package/assets/docs/tree/publishing.doc.mjs +111 -0
  117. package/assets/docs/tree/quick-start.doc.mjs +272 -0
  118. package/assets/docs/tree/replace-a-core-component.doc.mjs +104 -0
  119. package/assets/docs/tree/replace-a-core-template.doc.mjs +172 -0
  120. package/assets/docs/tree/sections-and-placement.doc.mjs +108 -0
  121. package/assets/docs/tree/see-it-in-an-app.doc.mjs +59 -0
  122. package/assets/docs/tree/ship.doc.mjs +16 -0
  123. package/assets/docs/tree/short-and-findable.doc.mjs +108 -0
  124. package/assets/docs/tree/single-component.doc.mjs +165 -0
  125. package/assets/docs/tree/start-a-template.doc.mjs +143 -0
  126. package/assets/docs/tree/subcomponent.doc.mjs +115 -0
  127. package/assets/docs/tree/template-assets.doc.mjs +64 -0
  128. package/assets/docs/tree/template-doc-overview.doc.mjs +109 -0
  129. package/assets/docs/tree/template-fonts.doc.mjs +102 -0
  130. package/assets/docs/tree/template-grading-rubric.doc.mjs +452 -0
  131. package/assets/docs/tree/template-icons.doc.mjs +97 -0
  132. package/assets/docs/tree/template-images-media.doc.mjs +127 -0
  133. package/assets/docs/tree/template-styles.doc.mjs +93 -0
  134. package/assets/docs/tree/templates.doc.mjs +34 -0
  135. package/assets/docs/tree/test-in-an-app.doc.mjs +115 -0
  136. package/assets/docs/tree/test-template-in-app.doc.mjs +128 -0
  137. package/assets/docs/tree/themes.doc.mjs +39 -0
  138. package/assets/docs/tree/troubleshooting.doc.mjs +149 -0
  139. package/assets/docs/tree/upgrading.doc.mjs +103 -0
  140. package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +51 -0
  141. package/assets/docs/tree/verify-packed-template.doc.mjs +77 -0
  142. package/assets/docs/tree/versioning.doc.mjs +161 -0
  143. package/assets/docs/tree/write-good-templates.doc.mjs +64 -0
  144. package/assets/docs/tree/write-the-template-file.doc.mjs +154 -0
  145. package/assets/docs/typography.doc.mjs +24 -4
  146. package/assets/docs/working-with-ai.doc.mjs +30 -22
  147. package/authoring/config/config.doc.mjs +1 -1
  148. package/authoring/doctypes/_schema.d.mts +3 -2
  149. package/authoring/doctypes/_schema.mjs +6 -0
  150. package/authoring/doctypes/base/graph-fields.doc.mjs +3 -3
  151. package/authoring/doctypes/base/type.ts +4 -2
  152. package/authoring/doctypes/component/component.doc.mjs +6 -0
  153. package/authoring/doctypes/component/type.ts +8 -0
  154. package/authoring/doctypes/reference/reference.doc.mjs +7 -0
  155. package/authoring/doctypes/reference/type.ts +5 -0
  156. package/authoring/doctypes/schema/schema.doc.mjs +2 -2
  157. package/authoring/doctypes/template/template.doc.mjs +1 -1
  158. package/authoring/doctypes/template/type.ts +2 -2
  159. package/authoring/integration/integration.doc.mjs +12 -10
  160. package/clients/cli/commands/component/index.mjs +152 -55
  161. package/clients/cli/commands/component-batch.test.mjs +341 -0
  162. package/clients/cli/commands/component-ownership.test.mjs +89 -0
  163. package/clients/cli/commands/component.doc.mjs +27 -9
  164. package/clients/cli/commands/docs.doc.mjs +1 -1
  165. package/clients/cli/commands/docs.mjs +60 -17
  166. package/clients/cli/commands/doctor-integration-docs.doc.mjs +3 -2
  167. package/clients/cli/commands/doctor-integration.test.mjs +53 -0
  168. package/clients/cli/commands/doctor.doc.mjs +3 -1
  169. package/clients/cli/commands/doctor.mjs +49 -5
  170. package/clients/cli/commands/gap-report.doc.mjs +10 -9
  171. package/clients/cli/commands/init.doc.mjs +9 -6
  172. package/clients/cli/commands/integration-add.doc.mjs +9 -9
  173. package/clients/cli/commands/integration-authoring.test.mjs +61 -10
  174. package/clients/cli/commands/integration-pack.doc.mjs +5 -9
  175. package/clients/cli/commands/integration-real-world.test.mjs +1 -1
  176. package/clients/cli/commands/integration-verify.doc.mjs +22 -0
  177. package/clients/cli/commands/integration.doc.mjs +4 -4
  178. package/clients/cli/commands/integration.mjs +74 -43
  179. package/clients/cli/commands/manifest.doc.mjs +1 -1
  180. package/clients/cli/commands/search.doc.mjs +10 -3
  181. package/clients/cli/commands/search.mjs +21 -2
  182. package/clients/cli/commands/search.test.mjs +21 -4
  183. package/clients/cli/commands/swizzle.doc.mjs +1 -1
  184. package/clients/cli/commands/template.doc.mjs +1 -1
  185. package/clients/cli/commands/text-json-parity.test.mjs +7 -1
  186. package/clients/cli/commands/theme-add.doc.mjs +1 -1
  187. package/clients/cli/commands/theme-palette-generate.doc.mjs +3 -2
  188. package/clients/cli/commands/theme-palette.doc.mjs +1 -2
  189. package/clients/cli/commands/theme-targets.doc.mjs +2 -2
  190. package/clients/cli/commands/theme.doc.mjs +2 -1
  191. package/clients/cli/commands/upgrade.doc.mjs +62 -3
  192. package/clients/cli/index.mjs +28 -6
  193. package/clients/cli/lib/define-command.mjs +28 -4
  194. package/clients/cli/lib/define-command.test.mjs +54 -0
  195. package/clients/cli/lib/exit-codes.test.mjs +17 -1
  196. package/clients/cli/lib/json-shim.mjs +24 -14
  197. package/clients/cli/lib/manifest.mjs +17 -5
  198. package/clients/cli/lib/manifest.test.mjs +5 -2
  199. package/clients/cli/lib/parse-error-format.test.mjs +81 -0
  200. package/foundation/agent-docs/agent-docs.mjs +1 -1
  201. package/foundation/discovery/authoring-self-docs.test.mjs +6 -2
  202. package/foundation/discovery/cli-self-docs.mjs +16 -2
  203. package/foundation/discovery/cli-self-docs.test.mjs +20 -0
  204. package/foundation/discovery/docs-discovery.mjs +5 -1
  205. package/foundation/discovery/docs-discovery.test.mjs +21 -0
  206. package/foundation/discovery/docs-section-key.d.mts +1 -1
  207. package/foundation/discovery/docs-section-key.mjs +1 -1
  208. package/foundation/doc-compiler/doc-loads.test.mjs +3 -2
  209. package/foundation/doc-compiler/inputs.test.mjs +0 -1
  210. package/foundation/doc-compiler/tree.d.mts +4 -0
  211. package/foundation/doc-compiler/tree.mjs +6 -1
  212. package/foundation/integrations/cli-requirement.d.mts +26 -6
  213. package/foundation/integrations/cli-requirement.mjs +46 -11
  214. package/foundation/integrations/cli-requirement.test.mjs +7 -2
  215. package/foundation/integrations/contribution-inventory.mjs +1 -1
  216. package/foundation/response/batch.type.d.mts +33 -0
  217. package/foundation/response/batch.type.mjs +34 -0
  218. package/foundation/response/error-codes.doc.mjs +6 -8
  219. package/foundation/response/error-codes.test.mjs +30 -5
  220. package/foundation/response/response-types.doc.d.mts +4 -3
  221. package/foundation/response/response-types.doc.mjs +30 -6
  222. package/foundation/response/response-types.doc.test.mjs +23 -0
  223. package/foundation/response/response.doc.mjs +11 -10
  224. package/package.json +9 -9
  225. package/api/docs/docs.test.mjs +0 -243
  226. package/api/docs/integration-tree.test.mjs +0 -555
  227. package/api/docs/integrationDocs.test.mjs +0 -314
  228. package/api/search/search.test.mjs +0 -512
  229. package/assets/docs/tree/integrations.test.mjs +0 -62
  230. package/assets/docs/tree/writing-docs.doc.mjs +0 -286
  231. package/clients/cli/commands/docs.test.mjs +0 -294
  232. package/foundation/agent-docs/agent-docs.test.mjs +0 -1159
  233. package/foundation/doc-compiler/tree.test.mjs +0 -598
package/README.md CHANGED
@@ -30,7 +30,8 @@ The CLI documents itself, so these commands print what the installed version doe
30
30
  `astryx.integration.*` manifest, codemods, and every doc type (`ComponentDoc`,
31
31
  `TemplateDoc`, `ThemeDoc`, and the rest). Read one section with
32
32
  `astryx docs authoring <section>`, for example `astryx docs authoring config`.
33
- - `astryx docs cli/integrations`: the guide to building an integration package.
33
+ - `astryx docs cli/integrations`: the guides to building an integration package,
34
+ from a quick start to publishing.
34
35
  - `astryx docs`: every docs topic, including the design-system guides (for
35
36
  example `tokens`, `theme`, and `layout`).
36
37
 
@@ -77,37 +78,37 @@ Options:
77
78
 
78
79
  <!-- BEGIN GENERATED: commands -->
79
80
 
80
- | Command | Description |
81
- | ------------- | ----------------------------------------------------------------------------- |
82
- | `blog` | Read the Astryx blog from the published feed |
83
- | `build` | Build a page: the template to start from, or the workflow playbook (no query) |
84
- | `component` | List components or print component docs |
85
- | `discover` | Browse and search integrations: the ones you have and the ones you could add |
86
- | `docs` | Print reference docs |
87
- | `doctor` | Diagnose Astryx projects and integration packages |
88
- | `gap-report` | Route a design-system gap to its owning package |
89
- | `hook` | List hooks or print hook docs |
90
- | `init` | Initialize the design system in your project |
91
- | `integration` | Author and verify an Astryx integration package |
92
- | `layout` | Generate XDS layouts from compressed expressions (XLE/XLO) |
93
- | `search` | Search components, hooks, docs, and templates in one ranked list |
94
- | `swizzle` | Copy component source for customization |
95
- | `template` | Inject a page or block template |
96
- | `theme` | Theme tools: build, export, and manage themes |
97
- | `upgrade` | Migrate versions and update ShadCN-copied compositions |
81
+ | Command | Description |
82
+ | ------------- | --------------------------------------------------------------------------------------------- |
83
+ | `blog` | Read the Astryx blog from the published feed |
84
+ | `build` | Build a page: the template to start from, or the workflow playbook (no query) |
85
+ | `component` | List components or print component docs |
86
+ | `discover` | Browse and search integrations: the ones you have and the ones you could add |
87
+ | `docs` | Print reference docs |
88
+ | `doctor` | Diagnose Astryx projects and integration packages |
89
+ | `gap-report` | Report a missing component or feature to the package that owns it |
90
+ | `hook` | List hooks or print hook docs |
91
+ | `init` | Initialize the design system in your project |
92
+ | `integration` | Author and verify an Astryx integration package |
93
+ | `layout` | Generate XDS layouts from compressed expressions (XLE/XLO) |
94
+ | `search` | Search components, hooks, docs, and templates in one ranked list |
95
+ | `swizzle` | Copy component source for customization |
96
+ | `template` | List, show, or scaffold page and block templates |
97
+ | `theme` | Create and build themes: add a shipped one, compile to CSS, or list what a theme can override |
98
+ | `upgrade` | Update your code after upgrading Astryx, and refresh ShadCN-copied components |
98
99
 
99
100
  <!-- END GENERATED: commands -->
100
101
  <!-- Generated by scripts/generate-cli-readme.mjs from `astryx manifest`. Run `pnpm -F @astryxdesign/cli readme`. -->
101
102
 
102
103
  ### Global options
103
104
 
104
- These flags work with any command:
105
+ `--json` works with every command listed in `jsonSupported` (`astryx manifest --json`), which is every command except the bare groups such as `astryx theme`. The other four change only the reads named here; other commands ignore them:
105
106
 
106
107
  - `--json`: Output as typed JSON envelope: `{ apiVersion, type, data, meta? }` (errors: `{ apiVersion, error, code, suggestions? }`)
107
- - `--detail <level>`: Detail level for list views, increasing in size: `brief` (names only, default for `--list`) < `compact` (names + 1-line descriptions) < `full` (full docs per entry). Single-item views default to `full`.
108
- - `--zh`: Output docs in Chinese Simplified
109
- - `--dense`: Compressed format (token-efficient, useful for AI agents)
110
- - `--lang <locale>`: Language/format shorthand (`en`, `zh`, `dense`)
108
+ - `--detail <level>`: Detail level for `component`, `hook`, and docs tree reads (such as `astryx docs cli/commands/build`), increasing in size: `brief` (names only, default for lists) < `compact` (names + 1-line descriptions) < `full` (full docs per entry). Single-item views default to `full`.
109
+ - `--zh`: Simplified Chinese for component reads and for docs topics that have a translation (English otherwise)
110
+ - `--dense`: Token-efficient dense text for `astryx component <Name>` and `astryx docs <topic>`
111
+ - `--lang <locale>`: Language or format for component and docs reads: `en` (default), `zh` (as `--zh`), or `dense` (as `--dense`)
111
112
 
112
113
  ## JSON API
113
114
 
@@ -164,9 +165,9 @@ if (isError(result)) {
164
165
  | `ERR_UNKNOWN` | Fallback for any error without a more specific code. |
165
166
  | `ERR_UNKNOWN_COMMAND` | A top-level command name was not recognized (e.g. `astryx bogus`). |
166
167
  | `ERR_UNKNOWN_SUBCOMMAND` | A subcommand under a command group was not recognized (e.g. `astryx theme bogus`). |
167
- | `ERR_INVALID_OPTION` | An unknown flag/option was passed (Commander `unknownOption`). |
168
- | `ERR_INVALID_ARGUMENT` | An option/argument had a value Commander's parser rejected. |
169
- | `ERR_MISSING_ARGUMENT` | A required positional argument was omitted (Commander `missingArgument`). |
168
+ | `ERR_INVALID_OPTION` | An unknown option was passed, --json was given to a command without JSON output, or layout --form got a value other than compact, outline, or auto. |
169
+ | `ERR_INVALID_ARGUMENT` | An argument or option value is invalid: wrong type, out of range, an unknown choice, an extra argument, or a conflicting combination. |
170
+ | `ERR_MISSING_ARGUMENT` | A required argument or option value was omitted. |
170
171
  | `ERR_INVALID_LANG` | `--lang` was given a value outside its choices (en, zh, dense). |
171
172
  | `ERR_INVALID_DETAIL` | `--detail` was given a value outside its choices (full, compact, brief). |
172
173
  | `ERR_NODE_VERSION` | The running Node.js version is below the supported minimum. |
@@ -184,8 +185,8 @@ if (isError(result)) {
184
185
  | `ERR_UNKNOWN_THEME` | No theme matched the requested slug (theme add). |
185
186
  | `ERR_INTEGRATION_ROOT_CONFLICT` | An integration manifest already declares a different path for the requested contribution root. |
186
187
  | `ERR_INTEGRATION_EXPORT_CONFLICT` | A package export already maps a generated contribution subpath to a different target. |
187
- | `ERR_UNKNOWN_PACKAGE` | No package matched the requested name (discover). |
188
- | `ERR_UNKNOWN_AGENT` | An unrecognized `--agent` value was passed to agent-docs/init. |
188
+ | `ERR_UNKNOWN_PACKAGE` | No package matched the requested name. |
189
+ | `ERR_UNKNOWN_AGENT` | An unrecognized `--agent` value was passed to init. |
189
190
  | `ERR_UNKNOWN_FEATURE` | An unrecognized `--features` value was passed to init. |
190
191
  | `ERR_UNKNOWN_CODEMOD` | A `--codemod` value did not match any registered codemod (upgrade). |
191
192
  | `ERR_CODEMOD_FAILED` | One or more codemods failed during an upgrade run. |
@@ -211,7 +212,7 @@ if (isError(result)) {
211
212
  | `ERR_FETCH_FAILED` | A network fetch (RSS feed or post text) failed. |
212
213
  | `ERR_LAYOUT_PARSE` | A layout expression failed to parse (syntax error, with line/col). |
213
214
  | `ERR_LAYOUT_INVALID` | A layout expression parsed but failed validation (unknown component/prop/enum/block). |
214
- | `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. |
215
+ | `ERR_UNCLASSIFIED_EXIT` | Recorded in the debug log, never printed: a command exited non-zero without reporting an error code. |
215
216
  | `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. |
216
217
 
217
218
  <!-- END GENERATED: error-codes -->
@@ -418,65 +419,69 @@ Every response has a `type` discriminant. The full set is below (generated from
418
419
 
419
420
  <!-- BEGIN GENERATED: response-types -->
420
421
 
421
- | Type | What `data` carries |
422
- | --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
423
- | `init.run` | The install receipt: the `mode` (`default` \| `features`), the features run, agent-doc files written, any soft `docsError`, whether theme guidance was emitted, the template outcome (`workflow` \| `created` \| `skipped`) plus its path, and whether the next-steps were emitted. |
424
- | `init.remove` | Confirmation that the managed agent-docs block was removed (`data.removed: true`) — returned when --remove-agents is set. |
425
- | `component.list` | The component catalog grouped by category: `detail` (the level: names \| compact \| full) and `components`, the grouped map of names entries ({name, package, and optional canonical import for integrations}), brief entries, or a full ComponentDoc per entry. |
426
- | `component.detail` | One component's authored ComponentDoc plus ownership fields (package, the owner; import, the specifier; sourceAvailable, whether source exists) and parentDoc (present when the component is documented inside another component's doc, naming that doc). |
427
- | `component.detail.props` | Just one component's props table (ComponentPropDoc[]). |
428
- | `component.detail.source` | One component's source file, as {component, source}. |
429
- | `component.detail.showcase` | One component's showcase example, as {component, aspectRatio, source}. |
430
- | `component.detail.blocks` | One component's example blocks, as {component, showcase, examples, related} of BlockEntry. |
431
- | `docs.list` | All reference-doc topics as DocsListEntry[] ({topic, description, package, replaces?}), in read order; meta.namespaces lists the docs tree's top-level namespaces, and meta.notLoaded each package whose docs did not load. |
432
- | `docs.detail` | One topic's full ReferenceDoc (the JSON read of a topic, --full, --dense, or a topic with one section), with token-ref blocks inlined, plus links ({up, previous, next}: the commands that open the level it sits in and its neighbors there). |
433
- | `docs.index` | One topic's section index, the text read of a topic with more than one section (and --index): the topic's name, title, and description, plus sections, each {id, title, summary} (pass the id as the section argument; summary is the section's one-line summary), and links ({up, previous, next}: the commands that open the level it sits in and its neighbors there). |
434
- | `docs.detail.section` | One ReferenceSection of a topic, found by key or title, with token-ref blocks inlined, plus links ({up, previous, next}: the commands that open its topic index and the sections before and after it). |
435
- | `docs.node` | One node of the docs tree, read by its route: its id, kind, package, title, summary, and breadcrumb, plus a namespace's slots with their children (one level down) or a typed doc's content, and links ({up, previous, next, related}: the commands that open its parent, its neighbors, and the docs it names). |
436
- | `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. |
437
- | `blog.detail` | One post's metadata plus the feed URL and the post's full plaintext body. |
438
- | `discover.list` | The integrations the project loads (name, category, components, version, a list per other kind they add, and latest when a source knows it); with a discover source, meta.available lists what the project could add and meta.sources reports each source; when empty it carries meta.configured to tell "nothing configured" from "nothing discovered". |
439
- | `discover.detail` | One package, for an @scope/name or @scope/name@version query: what the shown version adds, whether the project has it, and, when a source knows the package, its versions, latest release, and the command that adds it. |
440
- | `discover.detail.doc` | The validated ComponentDoc for one installed component, for an @scope/name/Component query. |
441
- | `discover.item` | One item that is not an installed component, for an @scope/name/<item> query: its kind, name, package, version, and whether the project has the package. |
442
- | `discover.search` | The echoed query plus every matching item and package across all packages, each with its kind and whether the project has it, even when only one matches; total is set when --limit cut the list. |
443
- | `search` | The echoed query, `matchCount` (total matches, before `limit`), and results, a ranked SearchResultEntry[] bounded by `limit`: each {domain, name, score, reason, description, command}, plus import (components, hooks), title, parent (the command that opens the level above), package (for a docs-tree hit), and, for a hit on one section, section (docs), or displayName and kind (templates). |
444
- | `build.help` | The how-to-build-a-page playbook, emitted when no query is given: `playbook: true`, a title, the ordered steps (title, commands, optional returns), the on-system rules, and related lookups. Commands are bare subcommands for the caller to render with its own invocation. |
445
- | `build.kit` | The template to start from and its kit: query, hasResults, matchCount (never a cap), directMatch, start {name, command, basis, reason, alternatives, ...}, pages (search's closest templates), blocks and domain as SearchResultEntry[], frame, foundation, and hint {reason, commands} when thin. |
446
- | `swizzle.list` | The names of swizzlable components discoverable from cwd's @astryxdesign/core. |
447
- | `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. |
448
- | `gap-report.categories` | The fixed gap category values and human-readable labels. |
449
- | `gap-report.file` | An aggregate receipt: overall status, the selected package, issuesUrl (or null), deliveries in handler order, each {handlerType: project \| integration \| fallback, handler, audience, status, url, message}, and filedCount/routedOnlyCount totals. |
450
- | `template.list` | The effective discovered TemplateListEntry[] for pages and blocks. A winning replacement entry includes optional `replaces`, naming the Core id omitted from the default list. |
451
- | `template.show` | The resolved template's raw source plus its description, kind, and the component names it composes. |
452
- | `template.skeleton` | A layout skeleton (structural tags with spatial annotations) plus the template's description and the components it composes. |
453
- | `template.copy` | A scaffold receipt: template id, output directory, written file name, and file count. |
454
- | `template.cdn` | A write receipt for the no-build-step CDN starter page: the path (relative to cwd), the Astryx version every CDN URL was pinned to, whether it was written, and the reason it was not. `exists` when a file was already there, which is a success. |
455
- | `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. |
456
- | `hook.detail` | One hook's full authored HookDoc. |
457
- | `hook.detail.params` | Just one hook's parameters table (HookParamDoc[]). |
458
- | `theme.build` | A theme build receipt: name, tokenCount and componentCount (override counts), sizeKB, the written outputs {css, js, dts, and variantsDts when applicable}, warnings (defects to fix), and notices (advisories about a correct theme, such as a named font it does not load). |
459
- | `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. |
460
- | `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. |
461
- | `theme.list` | Every bundled or installed integration theme as a ThemeListEntry[]: each with slug, displayName, description, maintained flag, and owner package. |
462
- | `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. |
463
- | `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. |
464
- | `theme.targets` | The whole themeable surface: the echoed filter, componentCount, and targets, one per theming target — {key, className, component, props, states, deprecatedFor?}, where props and states are its legal override keys and deprecatedFor names the canonical replacement key. |
465
- | `theme.palette.generate` | An author-reviewable OKLCH palette candidate, its reproducibility receipt, summary counts, and optional candidate/receipt file-write result. |
466
- | `upgrade.list` | Every available codemod, oldest→newest, as {name, title, version, optional}; returned for --list without running anything. |
467
- | `upgrade.status` | A short-circuit outcome with no codemods run (up_to_date, no_codemods, or config_fixable), each carrying the agent-docs summary. |
468
- | `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. |
469
- | `manifest` | The CLI capability manifest: name, version, apiVersion, description, globalOptions, commands (each name, description, arguments, options, json, aliases?, responseTypes?, examples?, exitCodes? as [{code, when}], subcommands?), jsonSupported, and the flat responseTypes index. |
470
- | `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. |
471
- | `integration.add` | A contribution-writer receipt: kind, name, optional root {path, created}, integration-manifest path, every affected project-relative path, written, and dryRun. |
472
- | `integration.pack-check` | The packed-package check: name, version, packable, tarball {filename, fileCount, size, unpackedSize} or null, inventory {manifest, roots [{kind, path, expectedFiles, missingFiles, complete}], expectedFiles, packedFiles}, contributions {local, packed}, each null or {themes [{slug, exportName}], components, templates [{id, type, name}], codemods [{version, id}], docs, agentDocsAppend}, and issues [{code, severity, message}]. |
473
- | `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}. |
474
- | `integration.template-conflicts` | The integration identity, structural issues, and non-blocking Core template-id conflicts as {id, severity: warning, integrationPackage, integrationType, integrationName, coreMatches, message, command}. |
475
- | `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. |
476
- | `integration.doc-conflicts` | The integration identity, structural issues, and Core doc overlaps. Each finding includes `severity` (`info` \| `error`) and `relationship` (`replaces` \| `extends` \| `accidental`). |
477
- | `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). |
478
- | `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). |
479
- | `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. |
422
+ | Type | What `data` carries |
423
+ | --------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
424
+ | `init.run` | The install receipt: the `mode` (`default` \| `features`), the features run, agent-doc files written, any soft `docsError`, whether theme guidance was emitted, the template outcome (`workflow` \| `created` \| `skipped`) plus its path, and whether the next-steps were emitted. |
425
+ | `init.remove` | Confirmation that the managed agent-docs block was removed (`data.removed: true`) — returned when --remove-agents is set. |
426
+ | `component.list` | The component catalog grouped by component group (each component's group field): `detail` (the level: names \| compact \| full) and `components`, the grouped map of names entries ({name, package, and optional canonical import for integrations}), brief entries, or a full ComponentDoc per entry. |
427
+ | `component.batch` | The component specialization of the shared `BatchResponse` and `BatchRow` types. An explicit programmatic selector array, or two or more CLI selectors, returns one ordered receipt: `count` plus `results`, one row per selector including duplicates. Every row carries `selector` and `status` (found \| not_found \| ambiguous \| error). A found row carries `result`, the same {type, data} response as one selector. An ambiguous row carries `code`, `error`, and `candidates` ({package, component, kind, installed}). Other failed rows carry `code`, `error`, and optional `suggestions` ({name, reason}). |
428
+ | `component.detail` | One component's authored ComponentDoc plus ownership fields (package, the owner; import, the specifier; sourceAvailable, whether source exists) and parentDoc (present when the component is documented inside another component's doc, naming that doc). |
429
+ | `component.detail.props` | Just one component's props table (ComponentPropDoc[]). |
430
+ | `component.detail.source` | One component's source file, as {component, source}. |
431
+ | `component.detail.showcase` | One component's showcase example, as {component, aspectRatio, source}. |
432
+ | `component.detail.blocks` | One component's example blocks, as {component, showcase, examples, related} of BlockEntry. |
433
+ | `docs.list` | All reference-doc topics as DocsListEntry[] ({topic, description, package, replaces?}), in read order; meta.namespaces lists the docs tree's top-level namespaces, and meta.notLoaded each package whose docs did not load. |
434
+ | `docs.detail` | One topic's full ReferenceDoc (the JSON read of a topic, --full, --dense, or a topic with one section), with token-ref blocks inlined, plus links ({up, previous, next}: the commands that open the level it sits in and its neighbors there). |
435
+ | `docs.index` | One topic's section index, the text read of a topic with more than one section (and --index): the topic's name, title, and description, plus sections, each {id, title, summary} (pass the id as the section argument; summary is the section's one-line summary), and links ({up, previous, next}: the commands that open the level it sits in and its neighbors there). |
436
+ | `docs.detail.section` | One ReferenceSection of a topic, found by key or title, with token-ref blocks inlined, plus links ({up, previous, next}: the commands that open its topic index and the sections before and after it). |
437
+ | `docs.node` | One node of the docs tree, read by its route: its id, kind, package, title, summary, and breadcrumb, plus a namespace's slots with their children (one level down) or a typed doc's content, and links ({up, previous, next, related}: the commands that open its parent, its neighbors, and the docs it names). |
438
+ | `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. |
439
+ | `blog.detail` | One post's metadata plus the feed URL and the post's full plaintext body. |
440
+ | `discover.list` | The integrations the project loads (name, category, components, version, a list per other kind they add, and latest when a source knows it); with a discover source, meta.available lists what the project could add and meta.sources reports each source; when empty it carries meta.configured to tell "nothing configured" from "nothing discovered". |
441
+ | `discover.detail` | One package, for an @scope/name or @scope/name@version query: what the shown version adds, whether the project has it, and, when a source knows the package, its versions, latest release, and the command that adds it. |
442
+ | `discover.detail.doc` | The validated ComponentDoc for one installed component, for an @scope/name/Component query. |
443
+ | `discover.item` | One item that is not an installed component, for an @scope/name/<item> query: its kind, name, package, version, and whether the project has the package. |
444
+ | `discover.search` | The echoed query plus every matching item and package across all packages, each with its kind and whether the project has it, even when only one matches; total is set when --limit cut the list. |
445
+ | `search` | The echoed query, `matchCount` (total matches, before `limit`), and results, a ranked SearchResultEntry[] bounded by `limit`: each {domain, name, score, reason, description, command}, plus import (components, hooks), title, parent (the command that opens the level above), package (for a docs-tree hit), and, for a hit on one section, section (docs), or displayName and kind (templates). |
446
+ | `build.help` | The how-to-build-a-page playbook, emitted when no query is given: `playbook: true`, a title, the ordered steps (title, commands, optional returns), the on-system rules, and related lookups. Commands are bare subcommands for the caller to render with its own invocation. |
447
+ | `build.kit` | The template to start from and its kit: query, hasResults, matchCount (never a cap), directMatch, start {name, command, basis, reason, alternatives, ...}, pages (search's closest templates), blocks and domain as SearchResultEntry[], frame, foundation, and hint {reason, commands} when thin. |
448
+ | `swizzle.list` | The names of swizzlable components discoverable from cwd's @astryxdesign/core. |
449
+ | `swizzle.copy` | An eject receipt: component name, owning package, output directory, files-copied count, the written file names, whether any file uses StyleX, and, when the owner has an issues URL, feedback ({issuesUrl, ghCommand?}): where to report the gap that led to swizzling. |
450
+ | `gap-report.categories` | The fixed gap category values and human-readable labels. |
451
+ | `gap-report.file` | An aggregate receipt: overall status, the selected package, issuesUrl (or null), deliveries in handler order, each {handlerType: project \| integration \| fallback, handler, audience, status, url, message}, and filedCount/routedOnlyCount totals. |
452
+ | `template.list` | The effective discovered TemplateListEntry[] for pages and blocks. A winning replacement entry includes optional `replaces`, naming the Core id omitted from the default list. |
453
+ | `template.show` | The resolved template's raw source plus its description, kind, and the component names it composes. |
454
+ | `template.skeleton` | A layout skeleton (structural tags with spatial annotations) plus the template's description and the components it composes. |
455
+ | `template.copy` | A scaffold receipt: template id, output directory, written file name, and file count. |
456
+ | `template.cdn` | A write receipt for the no-build-step CDN starter page: the path (relative to cwd), the Astryx version every CDN URL was pinned to, whether it was written, and the reason it was not. `exists` when a file was already there, which is a success. |
457
+ | `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. |
458
+ | `hook.detail` | One hook's full authored HookDoc. |
459
+ | `hook.detail.params` | Just one hook's parameters table (HookParamDoc[]). |
460
+ | `theme.build` | A theme build receipt: name, tokenCount and componentCount (override counts), sizeKB, the written outputs {css, js, dts, and variantsDts when applicable}, warnings (defects to fix), and notices (advisories about a correct theme, such as a named font it does not load). |
461
+ | `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. |
462
+ | `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. |
463
+ | `theme.list` | Every bundled or installed integration theme as a ThemeListEntry[]: each with slug, displayName, description, maintained flag, and owner package. |
464
+ | `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. |
465
+ | `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. |
466
+ | `theme.targets` | The whole themeable surface: the echoed filter, componentCount, and targets, one per theming target — {key, className, component, props, states, deprecatedFor?}, where props and states are its legal override keys and deprecatedFor names the canonical replacement key. |
467
+ | `theme.palette.generate` | An author-reviewable OKLCH palette candidate, its reproducibility receipt, summary counts, and optional candidate/receipt file-write result. |
468
+ | `upgrade.list` | Every available codemod, oldest→newest, as {name, title, version, optional}; returned for --list without running anything. |
469
+ | `upgrade.registry` | The copied-composition receipt for --registry: applied, ok, the counts (found, current, wouldUpdate, updated, wouldMerge, merged, wouldRefreshReceipt, receiptsRefreshed, conflicts, missing, invalid, failed), and items. |
470
+ | `upgrade.status` | A short-circuit outcome with no codemods run (up_to_date, no_codemods, or config_fixable), each carrying the agent-docs summary. |
471
+ | `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. |
472
+ | `manifest` | The CLI capability manifest: name, version, apiVersion, description, globalOptions, commands (each name, description, arguments, options, json, aliases?, responseTypes?, examples?, exitCodes? as [{code, when}], subcommands?), jsonSupported, and the flat responseTypes index. |
473
+ | `help` | Help, in one of two shapes. A bare `astryx --json` returns the root manifest: name, version, commands (the command names), jsonSupported, and manifest (the full payload `astryx manifest --json` returns). `--help --json` on any command, or `astryx help [command] --json`, returns that command's help: command, description, usage, options (each flags, description, and defaultValue and choices when set), and subcommands (each name and description). data.manifest marks the first shape; data.usage marks the second. |
474
+ | `version` | The CLI version, for `astryx --version --json`: {version}. |
475
+ | `doctor` | The health-check report: `checks` (each with id, label, status: pass \| warn \| fail \| info, a message, and an optional fix, always present on warn and fail) plus a `summary` of counts per status. |
476
+ | `integration.add` | A contribution-writer receipt: kind, name, optional root {path, created}, integration-manifest path, every affected project-relative path, written, and dryRun. |
477
+ | `integration.pack-check` | The packed-package check: name, version, packable, tarball {filename, fileCount, size, unpackedSize} or null, inventory {manifest, roots [{kind, path, expectedFiles, missingFiles, complete}], expectedFiles, packedFiles}, contributions {local, packed}, each null or {themes [{slug, exportName}], components, templates [{id, type, name}], codemods [{version, id}], docs, agentDocsAppend}, and issues [{code, severity, message}]. |
478
+ | `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}. |
479
+ | `integration.template-conflicts` | The integration identity, structural issues, and non-blocking Core template-id conflicts as {id, severity: warning, integrationPackage, integrationType, integrationName, coreMatches, message, command}. |
480
+ | `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. |
481
+ | `integration.doc-conflicts` | The integration identity, structural issues, and Core doc overlaps. Each finding includes `severity` (`info` \| `error`) and `relationship` (`replaces` \| `extends` \| `accidental`). |
482
+ | `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). |
483
+ | `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). |
484
+ | `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. |
480
485
 
481
486
  <!-- END GENERATED: response-types -->
482
487
  <!-- Generated by scripts/generate-cli-readme.mjs from the response-types EnumDoc. Run `pnpm -F @astryxdesign/cli readme`. -->
@@ -678,9 +683,10 @@ Warnings go to stderr and never corrupt a `--json` envelope. To inspect problems
678
683
  Core identity overlaps before publishing. Bare `astryx doctor` checks overall
679
684
  project health.
680
685
 
681
- For the full authoring walkthrough (component doc format, template packaging
682
- and `exports` requirements, and codemod authoring), see the guide:
686
+ For the full walkthrough, from an empty folder to a published package, see the
687
+ guides:
683
688
 
684
689
  ```bash
685
690
  astryx docs cli/integrations
691
+ astryx docs cli/integrations/quick-start
686
692
  ```
@@ -40,6 +40,7 @@ export const doc = {
40
40
  type: 'string',
41
41
  description:
42
42
  'Directory to resolve @astryxdesign/core and templates from.',
43
+ default: 'process.cwd()',
43
44
  },
44
45
  {
45
46
  name: 'options.type',
@@ -69,7 +70,11 @@ export const doc = {
69
70
  throws: [
70
71
  {
71
72
  code: 'ERR_INVALID_ARGUMENT',
72
- when: 'options.type is not a known domain, or options.limit is not a positive integer',
73
+ when: 'a query is given and options.type is not a known domain, or options.limit is not a positive integer',
74
+ },
75
+ {
76
+ code: 'ERR_CORE_NOT_FOUND',
77
+ when: 'a query is given and @astryxdesign/core cannot be found from cwd',
73
78
  },
74
79
  ],
75
80
  examples: [
@@ -179,6 +179,28 @@ describe('build kit — coverage gates the pages group', () => {
179
179
  }
180
180
  });
181
181
 
182
+ it('does not call a page that only mentions every word a direct match', async () => {
183
+ // `empty state` and `command palette` name components. A page whose text
184
+ // mentions both words, or that renders the component, is a layout
185
+ // reference, not the page the reader asked for.
186
+ for (const query of ['empty state', 'command palette']) {
187
+ const r = await build(query, {cwd: REPO});
188
+ if (r.type !== 'build.kit') throw new Error('expected build.kit');
189
+ expect(r.data.directMatch, query).toBe(false);
190
+ }
191
+ });
192
+
193
+ it('keeps the page and component a query names first', async () => {
194
+ const pageOf = async (/** @type {string} */ query) => {
195
+ const r = await build(query, {cwd: REPO});
196
+ if (r.type !== 'build.kit') throw new Error('expected build.kit');
197
+ return r.data;
198
+ };
199
+ expect((await pageOf('checkout flow')).pages[0]).toMatchObject({name: 'checkout-wizard'});
200
+ expect((await pageOf('sign in with sso')).pages[0]).toMatchObject({name: 'login-sso'});
201
+ expect((await pageOf('search results')).domain.map(e => e.name)).toContain('PowerSearch');
202
+ });
203
+
182
204
  it('leaves single-concept queries alone (nothing to cover)', async () => {
183
205
  const r = await build('dashboard', {cwd: REPO});
184
206
  expect(r.type).toBe('build.kit');
@@ -28,6 +28,9 @@
28
28
  */
29
29
 
30
30
  import {search} from '../../search/search.mjs';
31
+ import {findCoreDir} from '../../../foundation/fs/paths.mjs';
32
+ import {AstryxError} from '../../error.mjs';
33
+ import {ERROR_CODES} from '../../../foundation/response/error-codes.mjs';
31
34
  import {getResultCoverage} from '../../search/coverage.mjs';
32
35
  import {loadPageTemplates} from '../_adapter.mjs';
33
36
  import {pickAlternatives, pickStart, rankPages} from './rank.mjs';
@@ -188,12 +191,30 @@ function chooseStart(ranked, pages, directMatch, catalog) {
188
191
  */
189
192
  export async function buildKit(query, options = {}) {
190
193
  const {cwd = process.cwd(), type, limit = 60} = options;
194
+ // A kit is built from Core's components, hooks, and templates. An open
195
+ // search without core covers the docs alone, so the kit asks for core here.
196
+ if (type !== 'doc' && !findCoreDir(cwd)) {
197
+ throw new AstryxError(
198
+ 'Could not find @astryxdesign/core package',
199
+ undefined,
200
+ ERROR_CODES.ERR_CORE_NOT_FOUND,
201
+ );
202
+ }
191
203
  // search()'s JSDoc @returns widens results to object[]; the SearchResponse
192
204
  // shape is the contract (api/search/search.type.mjs). Cast locally rather than
193
205
  // tightening the search @returns (a separate follow-up).
194
206
  const result =
195
207
  /** @type {import('../../search/search.type.mjs').SearchResponse} */ (
196
- await search(query, {cwd, type, limit})
208
+ await search(query, {
209
+ cwd,
210
+ type,
211
+ // Search wider than the surfaced kit so a flood of doc matches cannot
212
+ // bury the page templates past the cutoff; the caller's `limit` still
213
+ // caps the kit below. A non-positive or non-integer limit is passed
214
+ // through unchanged so search rejects it (ERR_INVALID_ARGUMENT).
215
+ limit:
216
+ Number.isInteger(limit) && limit > 0 ? Math.max(limit, 200) : limit,
217
+ })
197
218
  );
198
219
  const results = result.data.results;
199
220
  // The TOTAL number of matches, not the number that survived `limit`. The kit
@@ -257,6 +278,24 @@ export async function buildKit(query, options = {}) {
257
278
  command: `${page.command} --skeleton`,
258
279
  }));
259
280
 
281
+ // The caller's `limit` caps the surfaced kit, even though the search above
282
+ // ran wider to find templates that a flood of doc matches would otherwise
283
+ // bury past the cutoff. Keep pages first, then blocks, then components.
284
+ let budget = limit;
285
+ /**
286
+ * @template T
287
+ * @param {T[]} arr
288
+ * @returns {T[]}
289
+ */
290
+ const toLimit = arr => {
291
+ const out = arr.slice(0, Math.max(0, budget));
292
+ budget -= out.length;
293
+ return out;
294
+ };
295
+ const pagesKept = toLimit(pages);
296
+ const blocksKept = toLimit(blocks);
297
+ const domainKept = toLimit(domain);
298
+
260
299
  // A kit narrowed to components or hooks has no page to start from; every
261
300
  // other kit does, so the reader is never left to compose a page from scratch.
262
301
  const wantsPages = !type || type === 'template';
@@ -288,7 +327,7 @@ export async function buildKit(query, options = {}) {
288
327
  // not resolve — the same defect `getCliInvocation` exists to prevent, and
289
328
  // the renderer applies it. A JSON caller gets the parts, not a sentence.
290
329
  const hint =
291
- pages.length + blocks.length + domain.length < THIN_KIT
330
+ pagesKept.length + blocksKept.length + domainKept.length < THIN_KIT
292
331
  ? {
293
332
  reason:
294
333
  'Few matches. This is keyword search, not semantic — try other wordings.',
@@ -306,9 +345,9 @@ export async function buildKit(query, options = {}) {
306
345
  matchCount,
307
346
  directMatch,
308
347
  start,
309
- pages,
310
- blocks,
311
- domain,
348
+ pages: pagesKept,
349
+ blocks: blocksKept,
350
+ domain: domainKept,
312
351
  frame: FRAME,
313
352
  foundation: FOUNDATION,
314
353
  hint,