@astryxdesign/cli 0.6.5-canary.fcd44d1 → 0.6.5-vanilla-poc.6e25cfc

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 (193) hide show
  1. package/CHANGELOG.md +3 -0
  2. package/README.md +36 -3
  3. package/api/_vanilla-assets.d.mts +10 -0
  4. package/api/_vanilla-assets.mjs +59 -0
  5. package/api/component/_adapter.d.mts +51 -1
  6. package/api/component/_adapter.mjs +110 -3
  7. package/api/component/component.d.mts +9 -1
  8. package/api/component/component.doc.mjs +52 -7
  9. package/api/component/component.mjs +276 -3
  10. package/api/component/component.type.d.mts +28 -1
  11. package/api/component/component.type.mjs +20 -1
  12. package/api/component/html/html.d.mts +12 -0
  13. package/api/component/html/html.doc.d.mts +5 -0
  14. package/api/component/html/html.doc.mjs +66 -0
  15. package/api/component/html/html.mjs +25 -0
  16. package/api/component/html/html.test.mjs +61 -0
  17. package/api/component/html/html.type.d.mts +23 -0
  18. package/api/component/html/html.type.mjs +27 -0
  19. package/api/component/web-components/web-components.d.mts +12 -0
  20. package/api/component/web-components/web-components.doc.d.mts +5 -0
  21. package/api/component/web-components/web-components.doc.mjs +70 -0
  22. package/api/component/web-components/web-components.mjs +32 -0
  23. package/api/component/web-components/web-components.test.mjs +50 -0
  24. package/api/component/web-components/web-components.type.d.mts +23 -0
  25. package/api/component/web-components/web-components.type.mjs +27 -0
  26. package/api/gap-report/gap-report.d.mts +3 -1
  27. package/api/gap-report/gap-report.mjs +12 -2
  28. package/api/gap-report/gap-report.test.mjs +106 -0
  29. package/api/index.d.mts +8 -0
  30. package/api/index.mjs +8 -0
  31. package/api/search/search.d.mts +4 -4
  32. package/api/search/search.doc.mjs +5 -5
  33. package/api/search/search.mjs +106 -21
  34. package/api/search/search.test.mjs +29 -15
  35. package/api/search/search.type.d.mts +15 -5
  36. package/api/search/search.type.mjs +6 -5
  37. package/api/template/_adapter.d.mts +38 -0
  38. package/api/template/_adapter.mjs +90 -0
  39. package/api/template/cdn/cdn.test.mjs +50 -2
  40. package/api/template/html/html.d.mts +17 -0
  41. package/api/template/html/html.doc.d.mts +5 -0
  42. package/api/template/html/html.doc.mjs +72 -0
  43. package/api/template/html/html.mjs +61 -0
  44. package/api/template/html/html.test.mjs +71 -0
  45. package/api/template/html/html.type.d.mts +26 -0
  46. package/api/template/html/html.type.mjs +28 -0
  47. package/api/template/template.d.mts +6 -0
  48. package/api/template/template.doc.mjs +56 -4
  49. package/api/template/template.mjs +82 -0
  50. package/api/template/template.type.d.mts +12 -0
  51. package/api/template/template.type.mjs +7 -0
  52. package/api/template/web-components/web-components.d.mts +13 -0
  53. package/api/template/web-components/web-components.doc.d.mts +5 -0
  54. package/api/template/web-components/web-components.doc.mjs +69 -0
  55. package/api/template/web-components/web-components.mjs +51 -0
  56. package/api/template/web-components/web-components.test.mjs +73 -0
  57. package/api/template/web-components/web-components.type.d.mts +26 -0
  58. package/api/template/web-components/web-components.type.mjs +28 -0
  59. package/api/theme/build/build.icon-lineage.test.mjs +117 -0
  60. package/api/theme/build/build.icon-preservation.test.mjs +639 -0
  61. package/api/theme/build/build.mjs +146 -69
  62. package/api/theme/build/build.test.mjs +190 -1
  63. package/api/theme/build/icon-imports.d.mts +47 -0
  64. package/api/theme/build/icon-imports.mjs +691 -0
  65. package/api/theme/themeBuild.doc.d.mts +4 -1
  66. package/api/theme/themeBuild.doc.mjs +14 -3
  67. package/assets/cdn.template.html +19 -5
  68. package/assets/docs/theme.doc.mjs +2 -1
  69. package/assets/docs/tree/debug-and-gap-reports.doc.mjs +1 -1
  70. package/assets/docs/tree/troubleshooting.doc.mjs +4 -4
  71. package/assets/generated/core-component-docs.json +1 -0
  72. package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupShowcase.doc.mjs +15 -0
  73. package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupShowcase.tsx +38 -0
  74. package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupWithSelectable.doc.mjs +20 -0
  75. package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupWithSelectable.tsx +48 -0
  76. package/assets/vanilla/elements-markup/Avatar.html +27 -0
  77. package/assets/vanilla/elements-markup/Badge.html +16 -0
  78. package/assets/vanilla/elements-markup/Banner.html +32 -0
  79. package/assets/vanilla/elements-markup/Breadcrumbs.html +23 -0
  80. package/assets/vanilla/elements-markup/Button.html +37 -0
  81. package/assets/vanilla/elements-markup/Card.html +24 -0
  82. package/assets/vanilla/elements-markup/CheckboxInput.html +28 -0
  83. package/assets/vanilla/elements-markup/Collapsible.html +26 -0
  84. package/assets/vanilla/elements-markup/DateInput.html +28 -0
  85. package/assets/vanilla/elements-markup/Dialog.html +33 -0
  86. package/assets/vanilla/elements-markup/Divider.html +20 -0
  87. package/assets/vanilla/elements-markup/DropdownMenu.html +26 -0
  88. package/assets/vanilla/elements-markup/EmptyState.html +27 -0
  89. package/assets/vanilla/elements-markup/Heading.html +18 -0
  90. package/assets/vanilla/elements-markup/HoverCard.html +39 -0
  91. package/assets/vanilla/elements-markup/Layout.html +28 -0
  92. package/assets/vanilla/elements-markup/Lightbox.html +33 -0
  93. package/assets/vanilla/elements-markup/Link.html +23 -0
  94. package/assets/vanilla/elements-markup/NumberInput.html +34 -0
  95. package/assets/vanilla/elements-markup/ProgressBar.html +47 -0
  96. package/assets/vanilla/elements-markup/RadioList.html +28 -0
  97. package/assets/vanilla/elements-markup/Selector.html +34 -0
  98. package/assets/vanilla/elements-markup/SideNav.html +32 -0
  99. package/assets/vanilla/elements-markup/Skeleton.html +18 -0
  100. package/assets/vanilla/elements-markup/Slider.html +31 -0
  101. package/assets/vanilla/elements-markup/Stack.html +33 -0
  102. package/assets/vanilla/elements-markup/StatusDot.html +19 -0
  103. package/assets/vanilla/elements-markup/Switch.html +28 -0
  104. package/assets/vanilla/elements-markup/Tab.html +18 -0
  105. package/assets/vanilla/elements-markup/TabList.html +31 -0
  106. package/assets/vanilla/elements-markup/Table.html +31 -0
  107. package/assets/vanilla/elements-markup/Text.html +24 -0
  108. package/assets/vanilla/elements-markup/TextArea.html +32 -0
  109. package/assets/vanilla/elements-markup/TextInput.html +92 -0
  110. package/assets/vanilla/elements-markup/Theme.html +16 -0
  111. package/assets/vanilla/elements-markup/TimeInput.html +29 -0
  112. package/assets/vanilla/elements-markup/Toast.html +22 -0
  113. package/assets/vanilla/elements-markup/Tooltip.html +30 -0
  114. package/assets/vanilla/elements-markup/TopNav.html +85 -0
  115. package/assets/vanilla/elements-markup/Typeahead.html +31 -0
  116. package/assets/vanilla/elements-templates/dashboard.html +167 -0
  117. package/assets/vanilla/elements-templates/detail-page.html +145 -0
  118. package/assets/vanilla/elements-templates/form-two-column.html +135 -0
  119. package/assets/vanilla/elements-templates/kanban-board.html +141 -0
  120. package/assets/vanilla/elements-templates/login.html +100 -0
  121. package/assets/vanilla/elements-templates/product-detail.html +128 -0
  122. package/assets/vanilla/elements-templates/settings.html +130 -0
  123. package/assets/vanilla/elements-templates/shell-side-nav.html +160 -0
  124. package/assets/vanilla/elements-templates/table-filter.html +154 -0
  125. package/assets/vanilla/markup/Avatar.html +24 -0
  126. package/assets/vanilla/markup/Badge.html +12 -0
  127. package/assets/vanilla/markup/Banner.html +49 -0
  128. package/assets/vanilla/markup/Breadcrumbs.html +38 -0
  129. package/assets/vanilla/markup/Button.html +37 -0
  130. package/assets/vanilla/markup/Card.html +16 -0
  131. package/assets/vanilla/markup/CheckboxInput.html +45 -0
  132. package/assets/vanilla/markup/Collapsible.html +9 -0
  133. package/assets/vanilla/markup/DateInput.html +42 -0
  134. package/assets/vanilla/markup/Dialog.html +45 -0
  135. package/assets/vanilla/markup/Divider.html +9 -0
  136. package/assets/vanilla/markup/DropdownMenu.html +30 -0
  137. package/assets/vanilla/markup/EmptyState.html +41 -0
  138. package/assets/vanilla/markup/Heading.html +9 -0
  139. package/assets/vanilla/markup/HoverCard.html +85 -0
  140. package/assets/vanilla/markup/Layout.html +35 -0
  141. package/assets/vanilla/markup/Lightbox.html +107 -0
  142. package/assets/vanilla/markup/Link.html +6 -0
  143. package/assets/vanilla/markup/NumberInput.html +55 -0
  144. package/assets/vanilla/markup/ProgressBar.html +101 -0
  145. package/assets/vanilla/markup/RadioList.html +90 -0
  146. package/assets/vanilla/markup/Selector.html +92 -0
  147. package/assets/vanilla/markup/SideNav.html +82 -0
  148. package/assets/vanilla/markup/Skeleton.html +26 -0
  149. package/assets/vanilla/markup/Slider.html +65 -0
  150. package/assets/vanilla/markup/Stack.html +13 -0
  151. package/assets/vanilla/markup/StatusDot.html +22 -0
  152. package/assets/vanilla/markup/Switch.html +47 -0
  153. package/assets/vanilla/markup/TabList.html +56 -0
  154. package/assets/vanilla/markup/Table.html +75 -0
  155. package/assets/vanilla/markup/Text.html +9 -0
  156. package/assets/vanilla/markup/TextArea.html +37 -0
  157. package/assets/vanilla/markup/TextInput.html +80 -0
  158. package/assets/vanilla/markup/Theme.html +48 -0
  159. package/assets/vanilla/markup/TimeInput.html +43 -0
  160. package/assets/vanilla/markup/Toast.html +42 -0
  161. package/assets/vanilla/markup/Tooltip.html +18 -0
  162. package/assets/vanilla/markup/TopNav.html +81 -0
  163. package/assets/vanilla/markup/Typeahead.html +60 -0
  164. package/assets/vanilla/templates/dashboard.html +462 -0
  165. package/assets/vanilla/templates/detail-page.html +536 -0
  166. package/assets/vanilla/templates/form-two-column.html +438 -0
  167. package/assets/vanilla/templates/kanban-board.html +443 -0
  168. package/assets/vanilla/templates/login.html +199 -0
  169. package/assets/vanilla/templates/product-detail.html +335 -0
  170. package/assets/vanilla/templates/settings.html +374 -0
  171. package/assets/vanilla/templates/shell-side-nav.html +440 -0
  172. package/assets/vanilla/templates/table-filter.html +514 -0
  173. package/clients/cli/commands/build-theme.mjs +8 -2
  174. package/clients/cli/commands/component/index.mjs +66 -9
  175. package/clients/cli/commands/component.doc.mjs +26 -4
  176. package/clients/cli/commands/discover.mjs +29 -1
  177. package/clients/cli/commands/discover.no-source.test.mjs +75 -0
  178. package/clients/cli/commands/gap-report.mjs +12 -0
  179. package/clients/cli/commands/gap-report.test.mjs +63 -0
  180. package/clients/cli/commands/search.doc.mjs +7 -5
  181. package/clients/cli/commands/search.mjs +35 -14
  182. package/clients/cli/commands/search.test.mjs +57 -8
  183. package/clients/cli/commands/template.doc.mjs +31 -3
  184. package/clients/cli/commands/template.mjs +37 -2
  185. package/clients/cli/commands/theme-list.behavior.test.mjs +41 -0
  186. package/clients/cli/commands/vanilla-html.test.mjs +245 -0
  187. package/foundation/agent-docs/agent-docs.mjs +2 -1
  188. package/foundation/agent-docs/agent-docs.test.mjs +8 -0
  189. package/foundation/discovery/bundled-component-docs.d.mts +39 -0
  190. package/foundation/discovery/bundled-component-docs.mjs +92 -0
  191. package/foundation/doc-compiler/doc-loads.test.mjs +1 -1
  192. package/foundation/response/response-types.doc.mjs +38 -0
  193. package/package.json +13 -9
package/CHANGELOG.md CHANGED
@@ -17,16 +17,19 @@
17
17
  One source file that four codemods each changed was reported as four files changed, so `filesChanged` matched `transformsApplied` and the documented meaning, "Total files changed", was not true. The human summary said the same thing: "Found 4 changes across 4 files" for one file.
18
18
 
19
19
  `filesChanged` is now the count of distinct files. `transformsApplied` is unchanged: a code or config codemod counts once for each file it changed, and a project codemod counts once. A file that both a core codemod and an integration codemod changed counts once in `filesChanged`.
20
+
20
21
  - A parse error prints the Astryx error format in text mode.
21
22
  `astryx theme list --lang zh-Hans` printed Commander's own line — `error: option '--lang <locale>' argument 'zh-Hans' is invalid…` — while every other CLI error prints `Error: …`. `--json` was already correct (`ERR_INVALID_LANG`), so the two modes agreed only on the exit code.
22
23
 
23
24
  Commander writes that line before any Astryx code runs, so the JSON shim — the one place that already sees every parse failure — now suppresses it and writes the Astryx line itself, from the same message, for both modes. Every parse failure is covered: unknown option, unknown command, missing argument, and an invalid value for a global option. `--help` and `--version` are untouched and still exit 0.
25
+
24
26
  - The CLI reference now matches what the commands do. Every `--help` ends with the command's examples and a `More:` line that names its full docs page. Function docs show each parameter's default, mark required parameters, list the error codes each function throws, and use examples that run. The response-type list adds `help`, `version`, and `upgrade.registry`, and `astryx manifest` now lists `upgrade.registry` for `upgrade`. The `--zh`, `--dense`, `--lang`, and `--detail` descriptions name the commands they change, and command summaries say when to use each command. When `astryx template` refuses to overwrite a file, it now says to re-run with `--overwrite` (or `-f`). The `upgrade` command page (`astryx docs cli/commands/upgrade`) now explains which files codemods never edit, what happens when one of them needs a change, and how to regenerate it.
25
27
  - `astryx integration pack --check` now checks the tarball when a `prepack`, `prepare`, or `postpack` script prints to stdout. Before, any lifecycle output made the check fail with "npm pack produced unparseable JSON output" before it looked at the tarball. A failing lifecycle script still fails the check, and its output stays in the `pack_failed` message.
26
28
  - `astryx doctor integration docs` fails when a namespace doc or a placement fails, as its help says.
27
29
  Such a failure hides the doc from the docs tree, so it now exits 1 with an `invalid_doc_graph` error instead of a warning. A link that names no doc still only warns, since it prints as written. `doctor integration docs` and `doctor integration components` also no longer print an `[ok]` line after a check that failed.
28
30
 
29
31
  A mistyped subcommand under `doctor` now fails and lists the subcommands the group has: `astryx doctor integrations` used to run the project checks, and `astryx doctor integration bogus` exited 0 in text though it exited 1 with `--json`.
32
+
30
33
  - A package that ships a theme, or a doc section with an `id`, now declares the CLI that can read it.
31
34
  A stable CLI before 0.7.0 rejects both: it cannot read the typed theme descriptors that `astryx integration add theme` writes, and it rejects a section `id`. Either way it hides the package's themes or doc topics with no warning. `astryx integration add theme` now adds `"@astryxdesign/cli": ">=0.7.0"` to `peerDependencies`, marked optional, and `astryx integration verify` fails with `themes_need_cli` or `section_ids_need_cli` when a package needs that peer range and does not declare it.
32
35
  - `astryx integration verify` resolves every public import in the packed package, not in your source folder.
package/README.md CHANGED
@@ -15,6 +15,31 @@ npx @astryxdesign/cli template --list
15
15
 
16
16
  Once it's a project dependency (`npm install -D @astryxdesign/cli`), drop the scope and use the shorter `astryx` — e.g. `npx astryx component Button` or `pnpm exec astryx component Button`. Bare `astryx` resolves to an unrelated npm package until the CLI is installed, so prefer the scoped form above for first-run/one-off use.
17
17
 
18
+ ## Install the preview CLI
19
+
20
+ Install the self-contained vanilla HTML preview from its immutable commit:
21
+
22
+ ```bash
23
+ npm install -g https://cdn.jsdelivr.net/gh/facebook/astryx@9bd9b20ef7dd4c91d72e7e0d0bbe03b48750dccb/packages/vanilla/dist/cli/astryx-cli-vanilla.tgz
24
+ ```
25
+
26
+ The preview package is `@astryxdesign/cli@0.6.5-vanilla.3eb9597f5`; it is not published to npm.
27
+
28
+ ## Choosing a framework
29
+
30
+ `component` and `template` default to the React catalog. Use `--framework html`
31
+ for the no-build vanilla markup, or `--framework web-components` for the
32
+ custom-element markup. Both alternatives support named reads and `--list`:
33
+
34
+ ```bash
35
+ astryx component Button --framework html
36
+ astryx component Button --framework web-components
37
+ astryx template dashboard --framework html
38
+ astryx template dashboard --framework web-components
39
+ ```
40
+
41
+ `--html` remains a deprecated alias for `--framework html`.
42
+
18
43
  ## Reading the CLI's own docs
19
44
 
20
45
  The CLI documents itself, so these commands print what the installed version does:
@@ -69,7 +94,7 @@ Results for "button" (20 of 239):
69
94
 
70
95
  Options:
71
96
 
72
- - `--type <component|hook|doc|template>`: restrict to a single domain
97
+ - `--type <component|hook|doc|template|theme>`: restrict to a single domain (`doc` and `theme` work outside an app too)
73
98
  - `--limit <n>`: cap the number of results (default 20)
74
99
  - `--verbose`: also print each result's match score and reason
75
100
  - `--json`: typed `{ apiVersion, type: 'search', data: { query, matchCount, results } }` envelope — `matchCount` is how many candidates matched in total, `results` the slice `--limit` allowed
@@ -91,9 +116,9 @@ Options:
91
116
  | `init` | Initialize the design system in your project |
92
117
  | `integration` | Author and verify an Astryx integration package |
93
118
  | `layout` | Generate XDS layouts from compressed expressions (XLE/XLO) |
94
- | `search` | Search components, hooks, docs, and templates in one ranked list |
119
+ | `search` | Search components, hooks, docs, templates, and themes in one ranked list |
95
120
  | `swizzle` | Copy component source for customization |
96
- | `template` | List, show, or scaffold page and block templates |
121
+ | `template` | List, show, scaffold, or render page and block templates |
97
122
  | `theme` | Create and build themes: add a shipped one, compile to CSS, or list what a theme can override |
98
123
  | `upgrade` | Update your code after upgrading Astryx, and refresh ShadCN-copied components |
99
124
 
@@ -431,6 +456,10 @@ Every response has a `type` discriminant. The full set is below (generated from
431
456
  | `component.detail.source` | One component's source file, as {component, source}. |
432
457
  | `component.detail.showcase` | One component's showcase example, as {component, aspectRatio, source}. |
433
458
  | `component.detail.blocks` | One component's example blocks, as {component, showcase, examples, related} of BlockEntry. |
459
+ | `component.html.list` | The sorted packages/vanilla/markup files as {name, file}. |
460
+ | `component.html` | One vanilla component markup file as {component, file, source}, preserving docs and variant comments verbatim. |
461
+ | `component.web-components.list` | The sorted packages/vanilla/elements-markup files as {name, file}. |
462
+ | `component.web-components` | One vanilla web-component markup file as {component, file, source}, preserving generated docs and variant comments verbatim. |
434
463
  | `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. |
435
464
  | `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). |
436
465
  | `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). |
@@ -455,6 +484,10 @@ Every response has a `type` discriminant. The full set is below (generated from
455
484
  | `template.skeleton` | A layout skeleton (structural tags with spatial annotations) plus the template's description and the components it composes. |
456
485
  | `template.copy` | A scaffold receipt: template id, output directory, written file name, file count, and demoMediaReplaced (how many Astryx demo media references were replaced with placeholders for you to swap for your own media). |
457
486
  | `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. |
487
+ | `template.html.list` | The sorted packages/vanilla/templates files as {id, file}. |
488
+ | `template.html` | One vanilla standalone page as {template, file, cdnRef, cdnBase, source}, with every CDN placeholder substituted. |
489
+ | `template.web-components.list` | The sorted packages/vanilla/elements-templates files as {id, file}. |
490
+ | `template.web-components` | One vanilla web-component page as {template, file, cdnRef, cdnBase, source}, with every CDN placeholder substituted. |
458
491
  | `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. |
459
492
  | `hook.detail` | One hook's full authored HookDoc. |
460
493
  | `hook.detail.params` | Just one hook's parameters table (HookParamDoc[]). |
@@ -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
+ * Prefer live checkout assets while developing, then fall back to the generated
6
+ * copy included in the published CLI package.
7
+ * @param {string} cwd
8
+ * @returns {string}
9
+ */
10
+ export function requireVanillaAssetsDir(cwd: string): string;
@@ -0,0 +1,59 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file Resolves vanilla framework assets from the source checkout or the CLI bundle.
5
+ *
6
+ * @input A caller working directory.
7
+ * @output The checkout's packages/vanilla directory when present, otherwise the
8
+ * generated assets/vanilla copy shipped with @astryxdesign/cli.
9
+ * @position Shared environment adapter used only by the component and template
10
+ * vanilla framework adapters so installed and source-checkout behavior agree.
11
+ */
12
+
13
+ import * as fs from 'node:fs';
14
+ import * as path from 'node:path';
15
+ import {ERROR_CODES} from '../foundation/response/error-codes.mjs';
16
+ import {AstryxError} from './error.mjs';
17
+
18
+ const BUNDLED_VANILLA_DIR = path.resolve(
19
+ import.meta.dirname,
20
+ '../assets/vanilla',
21
+ );
22
+
23
+ /** @param {string} candidate @returns {boolean} */
24
+ function isDirectory(candidate) {
25
+ return fs.existsSync(candidate) && fs.statSync(candidate).isDirectory();
26
+ }
27
+
28
+ /** @param {string} cwd @returns {string | null} */
29
+ function findCheckoutVanillaDir(cwd) {
30
+ let cursor = path.resolve(cwd);
31
+ while (true) {
32
+ const direct =
33
+ path.basename(cursor) === 'vanilla' &&
34
+ path.basename(path.dirname(cursor)) === 'packages'
35
+ ? cursor
36
+ : path.join(cursor, 'packages', 'vanilla');
37
+ if (isDirectory(direct)) return direct;
38
+ const parent = path.dirname(cursor);
39
+ if (parent === cursor) return null;
40
+ cursor = parent;
41
+ }
42
+ }
43
+
44
+ /**
45
+ * Prefer live checkout assets while developing, then fall back to the generated
46
+ * copy included in the published CLI package.
47
+ * @param {string} cwd
48
+ * @returns {string}
49
+ */
50
+ export function requireVanillaAssetsDir(cwd) {
51
+ const checkoutDir = findCheckoutVanillaDir(cwd);
52
+ if (checkoutDir) return checkoutDir;
53
+ if (isDirectory(BUNDLED_VANILLA_DIR)) return BUNDLED_VANILLA_DIR;
54
+ throw new AstryxError(
55
+ `Could not find vanilla framework assets from "${cwd}" or in the installed CLI`,
56
+ undefined,
57
+ ERROR_CODES.ERR_FILE_NOT_FOUND,
58
+ );
59
+ }
@@ -54,12 +54,56 @@
54
54
  * @property {string} resolvedOwnerPackage
55
55
  * @property {string|null} resolvedSourcePath
56
56
  */
57
+ /**
58
+ * Locate Core without failing so documentation callers can select the bundled
59
+ * fallback when a no-build project has no local installation.
60
+ * @param {string} cwd
61
+ * @returns {string|null}
62
+ */
63
+ export function findOptionalCoreDir(cwd: string): string | null;
57
64
  /**
58
65
  * Locate `@astryxdesign/core`, throwing the stable not-found error when absent.
59
66
  * @param {string} cwd
60
67
  * @returns {string}
61
68
  */
62
69
  export function requireCoreDir(cwd: string): string;
70
+ /**
71
+ * List the component markup files for a vanilla framework.
72
+ * @param {string} cwd
73
+ * @param {'html'|'web-components'} framework
74
+ * @returns {{name: string, file: string}[]}
75
+ */
76
+ export function listVanillaComponentMarkup(cwd: string, framework: "html" | "web-components"): {
77
+ name: string;
78
+ file: string;
79
+ }[];
80
+ /** @param {string} cwd @returns {{name: string, file: string}[]} */
81
+ export function listVanillaComponentHtml(cwd: string): {
82
+ name: string;
83
+ file: string;
84
+ }[];
85
+ /**
86
+ * Read one exact component markup file without permitting path traversal.
87
+ * @param {string} name
88
+ * @param {string} cwd
89
+ * @param {'html'|'web-components'} framework
90
+ * @returns {{component: string, file: string, source: string}}
91
+ */
92
+ export function readVanillaComponentMarkup(name: string, cwd: string, framework: "html" | "web-components"): {
93
+ component: string;
94
+ file: string;
95
+ source: string;
96
+ };
97
+ /**
98
+ * @param {string} name
99
+ * @param {string} cwd
100
+ * @returns {{component: string, file: string, source: string}}
101
+ */
102
+ export function readVanillaComponentHtml(name: string, cwd: string): {
103
+ component: string;
104
+ file: string;
105
+ source: string;
106
+ };
63
107
  /**
64
108
  * Load the configured integrations for `cwd`, swallowing any config errors so
65
109
  * component discovery never hard-fails on a malformed/absent integration. An
@@ -189,7 +233,6 @@ export function scopeSubComponent(docs: LoadedComponentDoc, dirName: string, cor
189
233
  };
190
234
  matchingComponent: any;
191
235
  } | null;
192
- export { CORE_PACKAGE };
193
236
  /**
194
237
  * Internal ambiguity marker. Single-component callers still receive the same
195
238
  * AstryxError code, message, and suggestions; batch callers can additionally
@@ -282,4 +325,11 @@ export type ResolvedUnscopedDoc = {
282
325
  resolvedSourcePath: string | null;
283
326
  };
284
327
  import { CORE_PACKAGE } from '../../foundation/discovery/component-discovery.mjs';
328
+ import { getBundledCoreVersion } from '../../foundation/discovery/bundled-component-docs.mjs';
329
+ import { getBundledComponentDoc } from '../../foundation/discovery/bundled-component-docs.mjs';
330
+ import { getBundledComponentDocsMeta } from '../../foundation/discovery/bundled-component-docs.mjs';
331
+ import { getBundledComponentGroups } from '../../foundation/discovery/bundled-component-docs.mjs';
332
+ import { getBundledComponentRecords } from '../../foundation/discovery/bundled-component-docs.mjs';
333
+ import { levenshteinDistance } from '../../foundation/text/string-utils.mjs';
285
334
  import { AstryxError } from '../error.mjs';
335
+ export { CORE_PACKAGE, getBundledCoreVersion, getBundledComponentDoc, getBundledComponentDocsMeta, getBundledComponentGroups, getBundledComponentRecords, levenshteinDistance };
@@ -3,7 +3,8 @@
3
3
  /**
4
4
  * @file Shared resolver for the `component` command leaves.
5
5
  *
6
- * @input a component name (+ cwd / package scope) and doc-load options
6
+ * @input a component name (+ cwd / package scope) and doc-load options;
7
+ * vanilla HTML reads resolve checkout assets before the bundled copy
7
8
  * @output resolved subjects the leaves project into their one `{type, data}`
8
9
  * envelope — owners across core/integration, the scoped/legacy/fuzzy
9
10
  * resolution, and the doc-loading / prop-extraction / ownership shaping
@@ -38,10 +39,29 @@ import {
38
39
  } from '../../foundation/discovery/component-discovery.mjs';
39
40
  import {Project} from '../../foundation/config/project.mjs';
40
41
  import {loadComponentDoc as loadValidatedComponentDoc} from '../../foundation/discovery/component-loader.mjs';
41
- import {searchComponents} from '../../foundation/text/string-utils.mjs';
42
+ import {
43
+ searchComponents,
44
+ levenshteinDistance,
45
+ } from '../../foundation/text/string-utils.mjs';
46
+ import {
47
+ getBundledCoreVersion,
48
+ getBundledComponentDoc,
49
+ getBundledComponentDocsMeta,
50
+ getBundledComponentGroups,
51
+ getBundledComponentRecords,
52
+ } from '../../foundation/discovery/bundled-component-docs.mjs';
42
53
  import {AstryxError} from '../error.mjs';
54
+ import {requireVanillaAssetsDir} from '../_vanilla-assets.mjs';
43
55
 
44
- export {CORE_PACKAGE};
56
+ export {
57
+ CORE_PACKAGE,
58
+ getBundledCoreVersion,
59
+ getBundledComponentDoc,
60
+ getBundledComponentDocsMeta,
61
+ getBundledComponentGroups,
62
+ getBundledComponentRecords,
63
+ levenshteinDistance,
64
+ };
45
65
 
46
66
  /**
47
67
  * A loaded component doc. The shared validated loader accepts stamped and legacy
@@ -103,6 +123,16 @@ export {CORE_PACKAGE};
103
123
  * @property {string|null} resolvedSourcePath
104
124
  */
105
125
 
126
+ /**
127
+ * Locate Core without failing so documentation callers can select the bundled
128
+ * fallback when a no-build project has no local installation.
129
+ * @param {string} cwd
130
+ * @returns {string|null}
131
+ */
132
+ export function findOptionalCoreDir(cwd) {
133
+ return findCoreDir(cwd);
134
+ }
135
+
106
136
  /**
107
137
  * Locate `@astryxdesign/core`, throwing the stable not-found error when absent.
108
138
  * @param {string} cwd
@@ -120,6 +150,83 @@ export function requireCoreDir(cwd) {
120
150
  return coreDir;
121
151
  }
122
152
 
153
+ /**
154
+ * List the component markup files for a vanilla framework.
155
+ * @param {string} cwd
156
+ * @param {'html'|'web-components'} framework
157
+ * @returns {{name: string, file: string}[]}
158
+ */
159
+ export function listVanillaComponentMarkup(cwd, framework) {
160
+ const assetDir =
161
+ framework === 'web-components' ? 'elements-markup' : 'markup';
162
+ const markupDir = path.join(requireVanillaAssetsDir(cwd), assetDir);
163
+ if (!fs.existsSync(markupDir)) return [];
164
+ return fs
165
+ .readdirSync(markupDir, {withFileTypes: true})
166
+ .filter(entry => entry.isFile() && entry.name.endsWith('.html'))
167
+ .map(entry => ({
168
+ name: entry.name.slice(0, -'.html'.length),
169
+ file: entry.name,
170
+ }))
171
+ .sort((a, b) => a.name.localeCompare(b.name));
172
+ }
173
+
174
+ /** @param {string} cwd @returns {{name: string, file: string}[]} */
175
+ export function listVanillaComponentHtml(cwd) {
176
+ return listVanillaComponentMarkup(cwd, 'html');
177
+ }
178
+
179
+ /**
180
+ * Read one exact component markup file without permitting path traversal.
181
+ * @param {string} name
182
+ * @param {string} cwd
183
+ * @param {'html'|'web-components'} framework
184
+ * @returns {{component: string, file: string, source: string}}
185
+ */
186
+ export function readVanillaComponentMarkup(name, cwd, framework) {
187
+ const entries = listVanillaComponentMarkup(cwd, framework);
188
+ if (!/^[A-Za-z][A-Za-z0-9]*$/.test(name)) {
189
+ throw new AstryxError(
190
+ `Invalid vanilla component name "${name}"`,
191
+ undefined,
192
+ ERROR_CODES.ERR_INVALID_ARGUMENT,
193
+ );
194
+ }
195
+ const match = entries.find(entry => entry.name === name);
196
+ const label = framework === 'web-components' ? 'web-component' : 'HTML';
197
+ if (!match) {
198
+ throw new AstryxError(
199
+ `No vanilla ${label} markup found for component "${name}"`,
200
+ entries.map(entry => ({
201
+ name: entry.name,
202
+ reason: `vanilla ${label} component`,
203
+ })),
204
+ ERROR_CODES.ERR_UNKNOWN_COMPONENT,
205
+ );
206
+ }
207
+ const assetDir =
208
+ framework === 'web-components' ? 'elements-markup' : 'markup';
209
+ const filePath = path.join(
210
+ requireVanillaAssetsDir(cwd),
211
+ assetDir,
212
+ match.file,
213
+ );
214
+ return {
215
+ component: name,
216
+ file: match.file,
217
+ source: fs.readFileSync(filePath, 'utf8'),
218
+ };
219
+ }
220
+
221
+ /**
222
+ * @param {string} name
223
+ * @param {string} cwd
224
+ * @returns {{component: string, file: string, source: string}}
225
+ */
226
+ export function readVanillaComponentHtml(name, cwd) {
227
+ return readVanillaComponentMarkup(name, cwd, 'html');
228
+ }
229
+
123
230
  /**
124
231
  * Load the configured integrations for `cwd`, swallowing any config errors so
125
232
  * component discovery never hard-fails on a malformed/absent integration. An
@@ -12,6 +12,8 @@
12
12
  * @param {boolean} [options.source]
13
13
  * @param {boolean} [options.showcase]
14
14
  * @param {boolean} [options.blocks]
15
+ * @param {boolean} [options.html] - Deprecated alias for framework='html'.
16
+ * @param {'react'|'html'|'web-components'} [options.framework] - Output framework; defaults to react.
15
17
  * @param {'full'|'compact'|'brief'} [options.detail] - Defaults to 'full' for a single component, 'brief' for list views (list/category/no name), matching the CLI.
16
18
  * @param {string} [options.lang]
17
19
  * @param {boolean} [options.zh]
@@ -24,6 +26,10 @@
24
26
  * | import('./component.type.mjs').ComponentDetailSourceResponse
25
27
  * | import('./component.type.mjs').ComponentDetailShowcaseResponse
26
28
  * | import('./component.type.mjs').ComponentDetailBlocksResponse
29
+ * | import('./html/html.type.mjs').ComponentHtmlListResponse
30
+ * | import('./html/html.type.mjs').ComponentHtmlResponse
31
+ * | import('./web-components/web-components.type.mjs').ComponentWebComponentsListResponse
32
+ * | import('./web-components/web-components.type.mjs').ComponentWebComponentsResponse
27
33
  * )>}
28
34
  */
29
35
  export function component(name?: string | string[], options?: {
@@ -35,10 +41,12 @@ export function component(name?: string | string[], options?: {
35
41
  source?: boolean | undefined;
36
42
  showcase?: boolean | undefined;
37
43
  blocks?: boolean | undefined;
44
+ html?: boolean | undefined;
45
+ framework?: "react" | "html" | "web-components" | undefined;
38
46
  detail?: "compact" | "full" | "brief" | undefined;
39
47
  lang?: string | undefined;
40
48
  zh?: boolean | undefined;
41
49
  dense?: boolean | undefined;
42
- }): Promise<(import("./component.type.mjs").ComponentListResponse | import("./component.type.mjs").ComponentBatchResponse | import("./component.type.mjs").ComponentDetailResponse | import("./component.type.mjs").ComponentDetailPropsResponse | import("./component.type.mjs").ComponentDetailSourceResponse | import("./component.type.mjs").ComponentDetailShowcaseResponse | import("./component.type.mjs").ComponentDetailBlocksResponse)>;
50
+ }): Promise<(import("./component.type.mjs").ComponentListResponse | import("./component.type.mjs").ComponentBatchResponse | import("./component.type.mjs").ComponentDetailResponse | import("./component.type.mjs").ComponentDetailPropsResponse | import("./component.type.mjs").ComponentDetailSourceResponse | import("./component.type.mjs").ComponentDetailShowcaseResponse | import("./component.type.mjs").ComponentDetailBlocksResponse | import("./html/html.type.mjs").ComponentHtmlListResponse | import("./html/html.type.mjs").ComponentHtmlResponse | import("./web-components/web-components.type.mjs").ComponentWebComponentsListResponse | import("./web-components/web-components.type.mjs").ComponentWebComponentsResponse)>;
43
51
  /** Maximum selectors accepted before any component resolution starts. */
44
52
  export const COMPONENT_BATCH_SELECTOR_LIMIT: 100;
@@ -15,16 +15,21 @@ export const doc = {
15
15
  namespace: 'cli/api',
16
16
  displayName: 'component()',
17
17
  summary:
18
- 'Resolve one or several components by name, or list the catalog, with optional focused slices (props, source, showcase, blocks).',
18
+ 'Resolve components by name, list the catalog, or read vanilla HTML/web-component markup, with optional focused slices (props, source, showcase, blocks).',
19
19
  description:
20
20
  'Routes on its arguments: one string resolves that component across core and ' +
21
21
  'integration packages; an array returns one ordered result row per selector at ' +
22
22
  'every array length; and no name returns the catalog grouped by category. ' +
23
23
  'Boolean flags narrow each resolved component to just its props, source, ' +
24
- 'showcase, or example blocks.',
24
+ 'showcase, or example blocks. The framework option selects React docs (default), ' +
25
+ 'vanilla HTML markup, or vanilla web-component markup. The html option is a ' +
26
+ 'deprecated alias for framework=html. When Core is not installed, details, props, ' +
27
+ 'and lists come from the version-matched Core snapshot shipped with the CLI; the ' +
28
+ 'response meta identifies that package version. Configured integration components ' +
29
+ 'remain available only when Core is installed.',
25
30
  importPath: '@astryxdesign/cli/api',
26
31
  signature:
27
- 'component(name?: string | string[], options?: ComponentOptions): Promise<ComponentListResponse | ComponentBatchResponse | ComponentDetailResponse | ComponentDetailPropsResponse | ComponentDetailSourceResponse | ComponentDetailShowcaseResponse | ComponentDetailBlocksResponse>',
32
+ 'component(name?: string | string[], options?: ComponentOptions): Promise<ComponentListResponse | ComponentBatchResponse | ComponentDetailResponse | ComponentDetailPropsResponse | ComponentDetailSourceResponse | ComponentDetailShowcaseResponse | ComponentDetailBlocksResponse | ComponentHtmlListResponse | ComponentHtmlResponse | ComponentWebComponentsListResponse | ComponentWebComponentsResponse>',
28
33
  keywords: [
29
34
  'component',
30
35
  'components',
@@ -44,7 +49,8 @@ export const doc = {
44
49
  {
45
50
  name: 'options.cwd',
46
51
  type: 'string',
47
- description: 'Directory to resolve @astryxdesign/core from.',
52
+ description:
53
+ 'Directory to resolve @astryxdesign/core from. Without a local installation, list, detail, and props reads use the version-matched Core snapshot bundled with the CLI.',
48
54
  default: 'process.cwd()',
49
55
  },
50
56
  {
@@ -85,6 +91,18 @@ export const doc = {
85
91
  description:
86
92
  "Return the component's example blocks (showcase, examples, related).",
87
93
  },
94
+ {
95
+ name: 'options.framework',
96
+ type: "'react' | 'html' | 'web-components'",
97
+ description:
98
+ 'Choose React component docs (default), vanilla HTML markup, or vanilla web-component markup.',
99
+ default: "'react'",
100
+ },
101
+ {
102
+ name: 'options.html',
103
+ type: 'boolean',
104
+ description: 'Deprecated alias for options.framework=html.',
105
+ },
88
106
  {
89
107
  name: 'options.detail',
90
108
  type: "'full' | 'compact' | 'brief'",
@@ -123,7 +141,7 @@ export const doc = {
123
141
  {
124
142
  type: 'component.detail',
125
143
  description:
126
- "One component's authored ComponentDoc plus ownership metadata (owner package, import specifier, whether source is available). When the name is a sub-component documented in a parent's doc, the payload is scoped to it and parentDoc names that parent.",
144
+ "One component's authored ComponentDoc plus ownership metadata (owner package, import specifier, whether source is available). When bundled docs are used, meta.componentDocs names their package, version, and bundled source. When the name is a sub-component documented in a parent's doc, the payload is scoped to it and parentDoc names that parent.",
127
145
  },
128
146
  {
129
147
  type: 'component.detail.props',
@@ -143,11 +161,30 @@ export const doc = {
143
161
  description:
144
162
  "The component's example blocks, as {component, showcase, examples, related} of BlockEntry.",
145
163
  },
164
+ {
165
+ type: 'component.html.list',
166
+ description: 'The sorted vanilla component markup files as {name, file}.',
167
+ },
168
+ {
169
+ type: 'component.html',
170
+ description:
171
+ 'One vanilla markup file as {component, file, source}; source includes its docs and variant comments verbatim.',
172
+ },
173
+ {
174
+ type: 'component.web-components.list',
175
+ description:
176
+ 'The sorted vanilla web-component markup files as {name, file}.',
177
+ },
178
+ {
179
+ type: 'component.web-components',
180
+ description:
181
+ 'One vanilla web-component markup file as {component, file, source}.',
182
+ },
146
183
  ],
147
184
  throws: [
148
185
  {
149
186
  code: 'ERR_INVALID_ARGUMENT',
150
- when: 'a selector array has more than 100 entries, a package-shaped selector has no component item, or its package conflicts with options.package',
187
+ when: 'the framework is unknown; html and framework are combined; a selector array has more than 100 entries; a package-shaped selector has no component item; its package conflicts with options.package; or a vanilla framework is missing its required name/list shape or combined with another projection',
151
188
  },
152
189
  {
153
190
  code: 'ERR_INVALID_DETAIL',
@@ -159,7 +196,7 @@ export const doc = {
159
196
  },
160
197
  {
161
198
  code: 'ERR_CORE_NOT_FOUND',
162
- when: '@astryxdesign/core cannot be resolved from cwd',
199
+ when: '@astryxdesign/core cannot be resolved from cwd and a source, showcase, or block view requires installed package files',
163
200
  },
164
201
  {
165
202
  code: 'ERR_UNKNOWN_CATEGORY',
@@ -200,6 +237,14 @@ export const doc = {
200
237
  code: "await component(['Button', 'Badge']);",
201
238
  },
202
239
  {label: 'Props only', code: "await component('Button', {props: true});"},
240
+ {
241
+ label: 'Vanilla HTML',
242
+ code: "await component('Button', {framework: 'html'});",
243
+ },
244
+ {
245
+ label: 'Vanilla web component',
246
+ code: "await component('Button', {framework: 'web-components'});",
247
+ },
203
248
  {
204
249
  label: 'Browse one group',
205
250
  code: "await component(undefined, {category: 'Layout', detail: 'compact'});",