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

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 (197) hide show
  1. package/CHANGELOG.md +84 -0
  2. package/README.md +1 -34
  3. package/api/build/_adapter.d.mts +14 -0
  4. package/api/build/_adapter.mjs +58 -1
  5. package/api/build/build.test.mjs +74 -1
  6. package/api/build/kit/kit.mjs +39 -7
  7. package/api/build/kit/rank.d.mts +8 -0
  8. package/api/build/kit/rank.mjs +14 -0
  9. package/api/build/kit/weights.d.mts +82 -0
  10. package/api/build/kit/weights.json +1 -0
  11. package/api/build/kit/weights.mjs +305 -0
  12. package/api/build/kit/weights.test.mjs +190 -0
  13. package/api/component/_adapter.d.mts +1 -51
  14. package/api/component/_adapter.mjs +3 -110
  15. package/api/component/component.d.mts +1 -9
  16. package/api/component/component.doc.mjs +7 -52
  17. package/api/component/component.mjs +3 -276
  18. package/api/component/component.type.d.mts +1 -28
  19. package/api/component/component.type.mjs +1 -20
  20. package/api/docs/docs.d.mts +6 -0
  21. package/api/docs/docs.depth.test.mjs +132 -0
  22. package/api/docs/docs.doc.mjs +31 -2
  23. package/api/docs/docs.mjs +44 -1
  24. package/api/docs/docs.type.d.mts +38 -1
  25. package/api/docs/docs.type.mjs +18 -1
  26. package/api/docs/node/node.d.mts +28 -3
  27. package/api/docs/node/node.mjs +146 -23
  28. package/api/hook/list/list.d.mts +1 -1
  29. package/api/index.d.mts +0 -8
  30. package/api/index.mjs +0 -8
  31. package/api/integration/add-theme.mjs +93 -3
  32. package/api/integration/add-theme.test.mjs +100 -0
  33. package/api/integration/integrationAddTheme.doc.mjs +1 -1
  34. package/api/search/search.d.mts +8 -1
  35. package/api/search/search.doc.mjs +3 -3
  36. package/api/search/search.mjs +58 -73
  37. package/api/search/search.test.mjs +122 -21
  38. package/api/search/search.type.d.mts +0 -10
  39. package/api/search/search.type.mjs +0 -1
  40. package/api/template/cdn/cdn.test.mjs +2 -50
  41. package/api/template/template.d.mts +0 -6
  42. package/api/template/template.doc.mjs +4 -56
  43. package/api/template/template.mjs +0 -82
  44. package/api/template/template.type.d.mts +0 -12
  45. package/api/template/template.type.mjs +0 -7
  46. package/assets/cdn.template.html +5 -19
  47. package/assets/docs/tokens.doc.mjs +3 -3
  48. package/assets/docs/tree/add-a-theme.doc.mjs +4 -0
  49. package/assets/docs/tree/troubleshooting.doc.mjs +4 -4
  50. package/clients/cli/commands/component/index.mjs +9 -66
  51. package/clients/cli/commands/component.doc.mjs +4 -26
  52. package/clients/cli/commands/docs.depth.test.mjs +219 -0
  53. package/clients/cli/commands/docs.doc.mjs +15 -2
  54. package/clients/cli/commands/docs.mjs +222 -5
  55. package/clients/cli/commands/integration-add.doc.mjs +1 -1
  56. package/clients/cli/commands/search.doc.mjs +2 -3
  57. package/clients/cli/commands/search.mjs +11 -8
  58. package/clients/cli/commands/search.test.mjs +35 -40
  59. package/clients/cli/commands/template.doc.mjs +3 -31
  60. package/clients/cli/commands/template.mjs +2 -37
  61. package/foundation/discovery/theme-discovery.d.mts +6 -0
  62. package/foundation/discovery/theme-discovery.mjs +9 -0
  63. package/foundation/response/response-types.doc.mjs +0 -38
  64. package/package.json +5 -9
  65. package/api/_vanilla-assets.d.mts +0 -10
  66. package/api/_vanilla-assets.mjs +0 -59
  67. package/api/component/html/html.d.mts +0 -12
  68. package/api/component/html/html.doc.d.mts +0 -5
  69. package/api/component/html/html.doc.mjs +0 -66
  70. package/api/component/html/html.mjs +0 -25
  71. package/api/component/html/html.test.mjs +0 -61
  72. package/api/component/html/html.type.d.mts +0 -23
  73. package/api/component/html/html.type.mjs +0 -27
  74. package/api/component/web-components/web-components.d.mts +0 -12
  75. package/api/component/web-components/web-components.doc.d.mts +0 -5
  76. package/api/component/web-components/web-components.doc.mjs +0 -70
  77. package/api/component/web-components/web-components.mjs +0 -32
  78. package/api/component/web-components/web-components.test.mjs +0 -50
  79. package/api/component/web-components/web-components.type.d.mts +0 -23
  80. package/api/component/web-components/web-components.type.mjs +0 -27
  81. package/api/template/_adapter.d.mts +0 -38
  82. package/api/template/_adapter.mjs +0 -90
  83. package/api/template/html/html.d.mts +0 -17
  84. package/api/template/html/html.doc.d.mts +0 -5
  85. package/api/template/html/html.doc.mjs +0 -72
  86. package/api/template/html/html.mjs +0 -61
  87. package/api/template/html/html.test.mjs +0 -71
  88. package/api/template/html/html.type.d.mts +0 -26
  89. package/api/template/html/html.type.mjs +0 -28
  90. package/api/template/web-components/web-components.d.mts +0 -13
  91. package/api/template/web-components/web-components.doc.d.mts +0 -5
  92. package/api/template/web-components/web-components.doc.mjs +0 -69
  93. package/api/template/web-components/web-components.mjs +0 -51
  94. package/api/template/web-components/web-components.test.mjs +0 -73
  95. package/api/template/web-components/web-components.type.d.mts +0 -26
  96. package/api/template/web-components/web-components.type.mjs +0 -28
  97. package/assets/generated/core-component-docs.json +0 -1
  98. package/assets/vanilla/elements-markup/Avatar.html +0 -27
  99. package/assets/vanilla/elements-markup/Badge.html +0 -16
  100. package/assets/vanilla/elements-markup/Banner.html +0 -32
  101. package/assets/vanilla/elements-markup/Breadcrumbs.html +0 -23
  102. package/assets/vanilla/elements-markup/Button.html +0 -37
  103. package/assets/vanilla/elements-markup/Card.html +0 -24
  104. package/assets/vanilla/elements-markup/CheckboxInput.html +0 -28
  105. package/assets/vanilla/elements-markup/Collapsible.html +0 -26
  106. package/assets/vanilla/elements-markup/DateInput.html +0 -28
  107. package/assets/vanilla/elements-markup/Dialog.html +0 -33
  108. package/assets/vanilla/elements-markup/Divider.html +0 -20
  109. package/assets/vanilla/elements-markup/DropdownMenu.html +0 -26
  110. package/assets/vanilla/elements-markup/EmptyState.html +0 -27
  111. package/assets/vanilla/elements-markup/Heading.html +0 -18
  112. package/assets/vanilla/elements-markup/HoverCard.html +0 -39
  113. package/assets/vanilla/elements-markup/Layout.html +0 -28
  114. package/assets/vanilla/elements-markup/Lightbox.html +0 -33
  115. package/assets/vanilla/elements-markup/Link.html +0 -23
  116. package/assets/vanilla/elements-markup/NumberInput.html +0 -34
  117. package/assets/vanilla/elements-markup/ProgressBar.html +0 -47
  118. package/assets/vanilla/elements-markup/RadioList.html +0 -28
  119. package/assets/vanilla/elements-markup/Selector.html +0 -34
  120. package/assets/vanilla/elements-markup/SideNav.html +0 -32
  121. package/assets/vanilla/elements-markup/Skeleton.html +0 -18
  122. package/assets/vanilla/elements-markup/Slider.html +0 -31
  123. package/assets/vanilla/elements-markup/Stack.html +0 -33
  124. package/assets/vanilla/elements-markup/StatusDot.html +0 -19
  125. package/assets/vanilla/elements-markup/Switch.html +0 -28
  126. package/assets/vanilla/elements-markup/Tab.html +0 -18
  127. package/assets/vanilla/elements-markup/TabList.html +0 -31
  128. package/assets/vanilla/elements-markup/Table.html +0 -31
  129. package/assets/vanilla/elements-markup/Text.html +0 -24
  130. package/assets/vanilla/elements-markup/TextArea.html +0 -32
  131. package/assets/vanilla/elements-markup/TextInput.html +0 -92
  132. package/assets/vanilla/elements-markup/Theme.html +0 -16
  133. package/assets/vanilla/elements-markup/TimeInput.html +0 -29
  134. package/assets/vanilla/elements-markup/Toast.html +0 -22
  135. package/assets/vanilla/elements-markup/Tooltip.html +0 -30
  136. package/assets/vanilla/elements-markup/TopNav.html +0 -85
  137. package/assets/vanilla/elements-markup/Typeahead.html +0 -31
  138. package/assets/vanilla/elements-templates/dashboard.html +0 -167
  139. package/assets/vanilla/elements-templates/detail-page.html +0 -145
  140. package/assets/vanilla/elements-templates/form-two-column.html +0 -135
  141. package/assets/vanilla/elements-templates/kanban-board.html +0 -141
  142. package/assets/vanilla/elements-templates/login.html +0 -100
  143. package/assets/vanilla/elements-templates/product-detail.html +0 -128
  144. package/assets/vanilla/elements-templates/settings.html +0 -130
  145. package/assets/vanilla/elements-templates/shell-side-nav.html +0 -160
  146. package/assets/vanilla/elements-templates/table-filter.html +0 -154
  147. package/assets/vanilla/markup/Avatar.html +0 -24
  148. package/assets/vanilla/markup/Badge.html +0 -12
  149. package/assets/vanilla/markup/Banner.html +0 -49
  150. package/assets/vanilla/markup/Breadcrumbs.html +0 -38
  151. package/assets/vanilla/markup/Button.html +0 -37
  152. package/assets/vanilla/markup/Card.html +0 -16
  153. package/assets/vanilla/markup/CheckboxInput.html +0 -45
  154. package/assets/vanilla/markup/Collapsible.html +0 -9
  155. package/assets/vanilla/markup/DateInput.html +0 -42
  156. package/assets/vanilla/markup/Dialog.html +0 -45
  157. package/assets/vanilla/markup/Divider.html +0 -9
  158. package/assets/vanilla/markup/DropdownMenu.html +0 -30
  159. package/assets/vanilla/markup/EmptyState.html +0 -41
  160. package/assets/vanilla/markup/Heading.html +0 -9
  161. package/assets/vanilla/markup/HoverCard.html +0 -85
  162. package/assets/vanilla/markup/Layout.html +0 -35
  163. package/assets/vanilla/markup/Lightbox.html +0 -107
  164. package/assets/vanilla/markup/Link.html +0 -6
  165. package/assets/vanilla/markup/NumberInput.html +0 -55
  166. package/assets/vanilla/markup/ProgressBar.html +0 -101
  167. package/assets/vanilla/markup/RadioList.html +0 -90
  168. package/assets/vanilla/markup/Selector.html +0 -92
  169. package/assets/vanilla/markup/SideNav.html +0 -82
  170. package/assets/vanilla/markup/Skeleton.html +0 -26
  171. package/assets/vanilla/markup/Slider.html +0 -65
  172. package/assets/vanilla/markup/Stack.html +0 -13
  173. package/assets/vanilla/markup/StatusDot.html +0 -22
  174. package/assets/vanilla/markup/Switch.html +0 -47
  175. package/assets/vanilla/markup/TabList.html +0 -56
  176. package/assets/vanilla/markup/Table.html +0 -75
  177. package/assets/vanilla/markup/Text.html +0 -9
  178. package/assets/vanilla/markup/TextArea.html +0 -37
  179. package/assets/vanilla/markup/TextInput.html +0 -80
  180. package/assets/vanilla/markup/Theme.html +0 -48
  181. package/assets/vanilla/markup/TimeInput.html +0 -43
  182. package/assets/vanilla/markup/Toast.html +0 -42
  183. package/assets/vanilla/markup/Tooltip.html +0 -18
  184. package/assets/vanilla/markup/TopNav.html +0 -81
  185. package/assets/vanilla/markup/Typeahead.html +0 -60
  186. package/assets/vanilla/templates/dashboard.html +0 -462
  187. package/assets/vanilla/templates/detail-page.html +0 -536
  188. package/assets/vanilla/templates/form-two-column.html +0 -438
  189. package/assets/vanilla/templates/kanban-board.html +0 -443
  190. package/assets/vanilla/templates/login.html +0 -199
  191. package/assets/vanilla/templates/product-detail.html +0 -335
  192. package/assets/vanilla/templates/settings.html +0 -374
  193. package/assets/vanilla/templates/shell-side-nav.html +0 -440
  194. package/assets/vanilla/templates/table-filter.html +0 -514
  195. package/clients/cli/commands/vanilla-html.test.mjs +0 -245
  196. package/foundation/discovery/bundled-component-docs.d.mts +0 -39
  197. package/foundation/discovery/bundled-component-docs.mjs +0 -92
@@ -106,10 +106,6 @@ import {
106
106
  import {AstryxError} from '../error.mjs';
107
107
  import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
108
108
  import {setResultCoverage} from './coverage.mjs';
109
- import {
110
- getBundledComponentDocsMeta,
111
- getBundledComponentRecords,
112
- } from '../../foundation/discovery/bundled-component-docs.mjs';
113
109
 
114
110
  /**
115
111
  * A search candidate gathered from one content domain. Extra underscore-
@@ -117,6 +113,8 @@ import {
117
113
  * @typedef {object} Candidate
118
114
  * @property {'component'|'hook'|'doc'|'template'|'theme'} domain
119
115
  * @property {string} name
116
+ * @property {string[]} [aliases] - Other names the candidate answers to, scored
117
+ * with the same name signals: a theme's display name.
120
118
  * @property {string[]} [keywords]
121
119
  * @property {string[]} [weakKeywords]
122
120
  * @property {string} [description]
@@ -721,6 +719,7 @@ export function scoreQuery(term, tokens, candidate) {
721
719
  * @param {string} term - Lowercased search term.
722
720
  * @param {object} candidate
723
721
  * @param {string} candidate.name - Primary identifier (component/hook name, topic, template name).
722
+ * @param {string[]} [candidate.aliases] - Other names, scored like the name (a theme's display name).
724
723
  * @param {string} [candidate.domain] - A component, hook, or template name
725
724
  * also matches typed as words: `command palette` is CommandPalette.
726
725
  * @param {string[]} [candidate.keywords] - Authored intent (componentsUsed, category words).
@@ -735,6 +734,7 @@ export function scoreCandidate(
735
734
  term,
736
735
  {
737
736
  name,
737
+ aliases = [],
738
738
  domain,
739
739
  keywords = [],
740
740
  weakKeywords = [],
@@ -757,40 +757,44 @@ export function scoreCandidate(
757
757
  }
758
758
  };
759
759
 
760
- const nameLower = name.toLowerCase();
761
- // A placed guide's name is its route, and the route's last segment is its
762
- // name too, as a flat topic's is: `codemods` is cli/integrations/codemods.
763
- const leafLower = nameLower.slice(nameLower.lastIndexOf('/') + 1);
764
-
765
760
  // ── Name signals ────────────────────────────────────────────────
766
- // A plural of the name is the name: `integration` is the `integrations`
767
- // guides, `tab` the `tabs` doc.
768
- // A component, hook, or template name typed as words is its name:
769
- // `command palette` is CommandPalette. A doc's name is a route or key,
770
- // matched as written.
771
- const spelled =
772
- domain !== 'doc' &&
773
- !/[\s_-]/.test(nameLower) &&
774
- nameLower === term.replace(/\s+/g, '');
775
- if (nameLower === term || leafLower === term || spelled) {
776
- consider(100, 'exact name');
777
- } else if (pluralOf(nameLower, term) || pluralOf(term, nameLower)) {
778
- // One point under the exact spelling, so the doc named `tokens` still
779
- // outranks the Token component for `tokens`.
780
- consider(99, 'plural of the name');
781
- } else {
782
- if (sameWord(term, nameLower)) consider(95, `name "${name}"`);
783
- // The term is a word of the name, or starts one: "input" in TextInput.
784
- else if (startsAWordOf(term, name)) {
785
- consider(60, `name contains "${term}"`);
786
- }
787
- if (fuzzy) {
788
- const dist = levenshteinDistance(term, nameLower);
789
- if (isTypo(term, nameLower, dist)) {
790
- consider(
791
- dist === 1 ? 80 : dist === 2 ? 40 : 20,
792
- `similar name (distance ${dist})`,
793
- );
761
+ // An alias is a name too: a theme answers to its display name as well as
762
+ // its slug.
763
+ for (const candidateName of [name, ...aliases.filter(Boolean)]) {
764
+ const nameLower = candidateName.toLowerCase();
765
+ // A placed guide's name is its route, and the route's last segment is its
766
+ // name too, as a flat topic's is: `codemods` is cli/integrations/codemods.
767
+ const leafLower = nameLower.slice(nameLower.lastIndexOf('/') + 1);
768
+
769
+ // A plural of the name is the name: `integration` is the `integrations`
770
+ // guides, `tab` the `tabs` doc.
771
+ // A component, hook, or template name typed as words is its name:
772
+ // `command palette` is CommandPalette. A doc's name is a route or key,
773
+ // matched as written.
774
+ const spelled =
775
+ domain !== 'doc' &&
776
+ !/[\s_-]/.test(nameLower) &&
777
+ nameLower === term.replace(/\s+/g, '');
778
+ if (nameLower === term || leafLower === term || spelled) {
779
+ consider(100, 'exact name');
780
+ } else if (pluralOf(nameLower, term) || pluralOf(term, nameLower)) {
781
+ // One point under the exact spelling, so the doc named `tokens` still
782
+ // outranks the Token component for `tokens`.
783
+ consider(99, 'plural of the name');
784
+ } else {
785
+ if (sameWord(term, nameLower)) consider(95, `name "${candidateName}"`);
786
+ // The term is a word of the name, or starts one: "input" in TextInput.
787
+ else if (startsAWordOf(term, candidateName)) {
788
+ consider(60, `name contains "${term}"`);
789
+ }
790
+ if (fuzzy) {
791
+ const dist = levenshteinDistance(term, nameLower);
792
+ if (isTypo(term, nameLower, dist)) {
793
+ consider(
794
+ dist === 1 ? 80 : dist === 2 ? 40 : 20,
795
+ `similar name (distance ${dist})`,
796
+ );
797
+ }
794
798
  }
795
799
  }
796
800
  }
@@ -969,22 +973,6 @@ async function gatherCoreComponents(coreDir) {
969
973
  return candidates;
970
974
  }
971
975
 
972
- /**
973
- * Build component candidates from the version-matched snapshot shipped with
974
- * the CLI. Used only when Core is not installed in the consuming project.
975
- * @returns {Candidate[]}
976
- */
977
- function gatherBundledCoreComponents() {
978
- return getBundledComponentRecords().map(({name, doc}) => ({
979
- domain: 'component',
980
- name,
981
- keywords: Array.isArray(doc.keywords) ? doc.keywords : [],
982
- description: doc.usage?.description || doc.description || '',
983
- guidance: guidanceFrom(doc),
984
- _import: doc.import,
985
- }));
986
- }
987
-
988
976
  /**
989
977
  * Build component candidates contributed by the project's configured
990
978
  * integrations (astryx.config's `integrations`): name + keywords +
@@ -1507,6 +1495,12 @@ async function gatherTemplates(cwd) {
1507
1495
  * Build theme candidates from bundled and integration-provided themes. Without
1508
1496
  * this, an integration's themes are invisible to `search` even though
1509
1497
  * `theme list` and `discover` already resolve them.
1498
+ *
1499
+ * A theme's slug and display name are its names, and its description is prose
1500
+ * (`spec:AST-050/FR14`). A theme declares no keywords, so a word it shares with
1501
+ * the query only through its description is a description mention: read as a
1502
+ * keyword, every word of the description would outrank the components and docs
1503
+ * that declare that word.
1510
1504
  * @param {string} cwd
1511
1505
  * @returns {Promise<Candidate[]>}
1512
1506
  */
@@ -1520,10 +1514,7 @@ async function gatherThemes(cwd) {
1520
1514
  return themes.map(t => ({
1521
1515
  domain: 'theme',
1522
1516
  name: t.slug,
1523
- keywords: [
1524
- t.displayName,
1525
- ...(t.description ? t.description.split(/[^A-Za-z0-9]+/).filter(w => w.length > 3) : []),
1526
- ],
1517
+ aliases: t.displayName ? [t.displayName] : [],
1527
1518
  description: t.description || '',
1528
1519
  _displayName: t.displayName,
1529
1520
  _package: t.package,
@@ -1643,31 +1634,28 @@ export async function search(query, options = {}) {
1643
1634
  const term = String(query).trim().toLowerCase();
1644
1635
  const tokens = tokenizeQuery(term);
1645
1636
 
1646
- // Component docs, docs topics, and bundled themes work without an installed
1647
- // Core package. Hooks, templates, and configured integration components still
1648
- // require one. An open search outside an app covers the three coreless domains.
1649
- const coreDir = ['doc', 'theme'].includes(type ?? '') ? null : findCoreDir(cwd);
1650
- if (type && ['hook', 'template'].includes(type) && !coreDir) {
1637
+ // `astryx docs` reads docs without @astryxdesign/core, and `astryx theme
1638
+ // list` reads themes without it (bundled themes need no project), so a
1639
+ // search of either must too. Every other domain reads core: asked for by
1640
+ // name, it is an error without core; an open search then covers the docs
1641
+ // and themes alone.
1642
+ const needsCore = !type || !CORELESS_DOMAINS.includes(type);
1643
+ const coreDir = needsCore ? findCoreDir(cwd) : null;
1644
+ if (type && needsCore && !coreDir) {
1651
1645
  throw new AstryxError(
1652
1646
  'Could not find @astryxdesign/core package',
1653
1647
  undefined,
1654
1648
  ERROR_CODES.ERR_CORE_NOT_FOUND,
1655
1649
  );
1656
1650
  }
1657
- const usesBundledComponents =
1658
- coreDir == null && (type == null || type === 'component');
1659
1651
 
1660
1652
  // Gather candidates from each requested domain in parallel.
1661
1653
  /** @param {string} d */
1662
1654
  const wants = d =>
1663
- type
1664
- ? type === d
1665
- : coreDir != null || CORELESS_DOMAINS.includes(d) || d === 'component';
1655
+ (!type && (coreDir != null || CORELESS_DOMAINS.includes(d))) || type === d;
1666
1656
  const [components, hooks, docTopics, templates, themes] = await Promise.all([
1667
1657
  wants('component')
1668
- ? coreDir
1669
- ? gatherComponents(coreDir, cwd)
1670
- : gatherBundledCoreComponents()
1658
+ ? gatherComponents(/** @type {string} */ (coreDir), cwd)
1671
1659
  : [],
1672
1660
  wants('hook') ? gatherHooks(/** @type {string} */ (coreDir)) : [],
1673
1661
  wants('doc') ? gatherDocs(cwd) : [],
@@ -1719,9 +1707,6 @@ export async function search(query, options = {}) {
1719
1707
  ),
1720
1708
  },
1721
1709
  };
1722
- if (usesBundledComponents) {
1723
- response.meta = getBundledComponentDocsMeta();
1724
- }
1725
1710
  if (wants('component')) {
1726
1711
  searchedComponentsOf.set(
1727
1712
  response,
@@ -25,6 +25,8 @@ import * as os from 'node:os';
25
25
  import * as path from 'node:path';
26
26
  import {fileURLToPath} from 'node:url';
27
27
  import {docs} from '../docs/docs.mjs';
28
+ import {listAvailableThemes} from '../theme/_adapter.mjs';
29
+ import {doc as themeAddCommandDoc} from '../../clients/cli/commands/theme-add.doc.mjs';
28
30
  import {
29
31
  headingWithPhrase,
30
32
  titleInQuery,
@@ -76,7 +78,10 @@ describe('search leaf — envelope + ranking', () => {
76
78
 
77
79
  describe('search leaf — per-domain result fields', () => {
78
80
  it('carries import for components and hooks, title for docs, displayName and kind for templates, displayName for themes', async () => {
79
- const r = await search('theme', {cwd, limit: 60});
81
+ // `theme` reaches every domain, but a theme matches it only through its
82
+ // description, a prose mention below every name and keyword hit, so read
83
+ // the whole result list.
84
+ const r = await search('theme', {cwd, limit: 400});
80
85
  expect(new Set(r.data.results.map(res => res.domain))).toEqual(
81
86
  new Set(SEARCH_DOMAINS),
82
87
  );
@@ -459,28 +464,16 @@ describe('search leaf — error paths (pinned)', () => {
459
464
  ).rejects.toMatchObject({code: 'ERR_INVALID_ARGUMENT'});
460
465
  }, SLOW);
461
466
 
462
- it('uses bundled component docs without Core and still rejects source-backed domains', async () => {
467
+ it('searches the docs without @astryxdesign/core, and throws for a domain that needs it', async () => {
463
468
  const empty = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-search-no-core-'));
464
469
  try {
465
- // Open search combines ordinary docs with the CLI's bundled Core snapshot.
466
- const open = await search('button', {cwd: empty});
467
- expect(open.data.results.some(r => r.domain === 'component')).toBe(true);
468
- expect(open.meta?.componentDocs).toMatchObject({
469
- source: 'bundled',
470
- package: '@astryxdesign/core',
471
- });
472
-
473
- const components = await search('button', {
474
- cwd: empty,
475
- type: 'component',
476
- });
477
- expect(components.data.results[0]).toMatchObject({
478
- domain: 'component',
479
- name: 'Button',
480
- import: '@astryxdesign/core/Button',
481
- });
482
-
483
- for (const type of ['hook', 'template']) {
470
+ // An open search outside an app covers the docs, as `astryx docs` does.
471
+ const open = await search('make an integration', {cwd: empty});
472
+ expect(open.data.results.length).toBeGreaterThan(0);
473
+ expect(new Set(open.data.results.map(r => r.domain))).toEqual(
474
+ new Set(['doc']),
475
+ );
476
+ for (const type of ['component', 'hook', 'template']) {
484
477
  await expect(
485
478
  search('button', {cwd: empty, type: /** @type {any} */ (type)}),
486
479
  ).rejects.toMatchObject({code: 'ERR_CORE_NOT_FOUND'});
@@ -511,6 +504,114 @@ describe('search leaf — limit validation (API matches the CLI contract)', () =
511
504
  }, SLOW);
512
505
  });
513
506
 
507
+ describe('search leaf — a theme is found by its names; its description is prose (AST-050 FR14)', () => {
508
+ /** A result that answers the query by a name or a declared keyword, not a typo or a mention. */
509
+ const matchesByNameOrKeyword = (/** @type {{reason: string}} */ result) =>
510
+ /^(exact name|plural of the name|name "|name contains ")/.test(result.reason) ||
511
+ /^keyword "[^"]*"$/.test(result.reason);
512
+
513
+ /**
514
+ * The `theme add` command AST-050 FR12 and FR13 name for the stage that
515
+ * `theme add` itself declares: no `--import` yet, a deprecated copy default
516
+ * beside `--import`, or the cleanup, which keeps `--import` and drops the
517
+ * copy's `--overwrite`.
518
+ * @param {string} slug
519
+ */
520
+ function themeAddCommandForStage(slug) {
521
+ const flags = themeAddCommandDoc.options.flatMap(option => option.flag.split(/[\s,]+/));
522
+ if (!flags.includes('--import')) return `astryx theme add ${slug}`;
523
+ if (flags.includes('--overwrite')) return `astryx theme add --import ${slug}`;
524
+ return `astryx theme add ${slug}`;
525
+ }
526
+
527
+ it(
528
+ 'ranks a theme found only through its description below every name and keyword match',
529
+ async () => {
530
+ for (const [query, slugs] of [
531
+ ['focus', ['neutral']],
532
+ ['content', ['matcha', 'neutral']],
533
+ ]) {
534
+ const {results} = (await search(query, {cwd, limit: 400})).data;
535
+ const strong = results.filter(
536
+ result => result.domain !== 'theme' && matchesByNameOrKeyword(result),
537
+ );
538
+ expect(strong.length).toBeGreaterThan(0);
539
+ const lastStrong = Math.max(...strong.map(result => results.indexOf(result)));
540
+ for (const slug of slugs) {
541
+ const at = results.findIndex(result => result.domain === 'theme' && result.name === slug);
542
+ expect(at).toBeGreaterThan(-1);
543
+ expect(results[at].reason).toMatch(/^description mentions /);
544
+ expect(at).toBeGreaterThan(lastStrong);
545
+ }
546
+ }
547
+ },
548
+ SLOW,
549
+ );
550
+
551
+ it(
552
+ 'scores a word in a theme description the same as a word in a component description',
553
+ async () => {
554
+ const {results} = (await search('minimal', {cwd, limit: 400})).data;
555
+ const neutral = results.find(result => result.domain === 'theme' && result.name === 'neutral');
556
+ const topNav = results.find(result => result.domain === 'component' && result.name === 'TopNav');
557
+ expect(neutral?.reason).toMatch(/^description mentions /);
558
+ expect(topNav?.reason).toMatch(/^description mentions /);
559
+ expect(neutral?.score).toBe(topNav?.score);
560
+ },
561
+ SLOW,
562
+ );
563
+
564
+ it(
565
+ 'keeps a theme that matches every word only in its description below results with a keyword hit',
566
+ async () => {
567
+ // Overlay and Dialog declare `focus` and mention `content`; neutral only
568
+ // mentions both, in "so the content stays the focus".
569
+ const {results} = (await search('content focus', {cwd, limit: 400})).data;
570
+ const neutral = results.findIndex(result => result.domain === 'theme' && result.name === 'neutral');
571
+ expect(neutral).toBeGreaterThan(-1);
572
+ for (const name of ['Overlay', 'Dialog']) {
573
+ const at = results.findIndex(result => result.domain === 'component' && result.name === name);
574
+ expect(at).toBeGreaterThan(-1);
575
+ expect(at).toBeLessThan(neutral);
576
+ }
577
+ },
578
+ SLOW,
579
+ );
580
+
581
+ it(
582
+ 'still finds a theme first by its slug or its display name',
583
+ async () => {
584
+ for (const query of ['neutral', 'Matcha', 'Y2K']) {
585
+ const [first] = (await search(query, {cwd})).data.results;
586
+ expect(first).toMatchObject({domain: 'theme', name: query.toLowerCase(), reason: 'exact name'});
587
+ }
588
+ },
589
+ SLOW,
590
+ );
591
+
592
+ it('scores a display name with the same name signals as the slug', () => {
593
+ const theme = {name: 'ocean', aliases: ['Ocean Blue'], description: 'Deep blues for calm reading.'};
594
+ expect(scoreCandidate('ocean blue', theme)).toEqual(scoreCandidate('ocean', theme));
595
+ expect(scoreCandidate('ocean blue', {...theme, aliases: []})?.score ?? 0).toBeLessThan(
596
+ scoreCandidate('ocean', theme).score,
597
+ );
598
+ });
599
+
600
+ it(
601
+ 'names the theme add command for the stage theme add declares',
602
+ async () => {
603
+ const themes = await listAvailableThemes(cwd);
604
+ expect(themes.length).toBeGreaterThan(0);
605
+ for (const {slug} of themes) {
606
+ const {results} = (await search(slug, {cwd, type: 'theme'})).data;
607
+ const result = results.find(entry => entry.name === slug);
608
+ expect(result?.command).toBe(themeAddCommandForStage(slug));
609
+ }
610
+ },
611
+ SLOW,
612
+ );
613
+ });
614
+
514
615
  describe('search leaf — integration components', () => {
515
616
  /**
516
617
  * A minimal consumer project: a stub `@astryxdesign/core` (so `findCoreDir`
@@ -72,16 +72,6 @@ export type SearchResponse = {
72
72
  matchCount: number;
73
73
  results: SearchResultEntry[];
74
74
  };
75
- /**
76
- * - Present when component results came from the CLI's bundled Core snapshot.
77
- */
78
- meta?: {
79
- componentDocs: {
80
- source: "bundled";
81
- package: string;
82
- version: string;
83
- };
84
- } | undefined;
85
75
  };
86
76
  /**
87
77
  * Options for `search()`.
@@ -38,7 +38,6 @@
38
38
  * @property {string} data.query
39
39
  * @property {number} data.matchCount - How many candidates matched the query in total, before `limit` was applied. `results` is the bounded slice of that set, so `matchCount > results.length` means the answer was capped.
40
40
  * @property {SearchResultEntry[]} data.results
41
- * @property {{componentDocs: {source: 'bundled'; package: string; version: string}}} [meta] - Present when component results came from the CLI's bundled Core snapshot.
42
41
  */
43
42
 
44
43
  /**
@@ -6,13 +6,11 @@
6
6
  *
7
7
  * Two things matter here: it never destroys work (the page lands once, a second
8
8
  * run leaves an edited copy alone, a path that escapes the project is refused),
9
- * and every CDN recipe is pinned and reuses the import map's React. A leftover
10
- * version placeholder would ship URLs that 404; an unexternalized Astryx module
11
- * would bundle a second React and fail when a themed icon reads context.
9
+ * and the page it writes is pinned — a leftover version placeholder would ship
10
+ * a file whose every CDN URL 404s.
12
11
  */
13
12
 
14
13
  import {describe, it, expect, beforeEach, afterEach} from 'vitest';
15
- import {spawnSync} from 'node:child_process';
16
14
  import * as fs from 'node:fs';
17
15
  import * as path from 'node:path';
18
16
  import * as os from 'node:os';
@@ -32,22 +30,6 @@ afterEach(() => {
32
30
 
33
31
  const written = () =>
34
32
  fs.readFileSync(path.join(tmpDir, CDN_TEMPLATE_DEFAULT_PATH), 'utf-8');
35
- const repoRoot = path.resolve(import.meta.dirname, '../../../../..');
36
- const trackedSurfacePaths = () => {
37
- const listed = spawnSync(
38
- 'git',
39
- ['ls-files', '-z', '--', '*.md', '*.html', '*.mjs'],
40
- {cwd: repoRoot, encoding: 'utf-8'},
41
- );
42
- if (listed.status !== 0) {
43
- throw new Error(`Could not list tracked CDN recipe surfaces: ${listed.stderr}`);
44
- }
45
- return listed.stdout.split('\0').filter(Boolean);
46
- };
47
- const astryxEsmImports = source =>
48
- source.match(
49
- /https:\/\/esm\.sh\/(?:v\d+\/)?@astryxdesign\/[^\s"'<>`]+/g,
50
- ) ?? [];
51
33
 
52
34
  describe('templateCdn()', () => {
53
35
  it('writes the page and returns a template.cdn receipt', () => {
@@ -73,36 +55,6 @@ describe('templateCdn()', () => {
73
55
  }
74
56
  });
75
57
 
76
- it('recognizes versioned esm.sh build paths', () => {
77
- const url = [
78
- 'https://esm.sh/v135/',
79
- '@astryxdesign/core@1.2.3?external=react,react-dom',
80
- ].join('');
81
-
82
- expect(astryxEsmImports(url)).toEqual([url]);
83
- });
84
-
85
- it('externalizes React for every tracked Astryx esm.sh import', () => {
86
- templateCdn({cwd: tmpDir});
87
- const surfaces = trackedSurfacePaths().map(filename => [
88
- filename,
89
- fs.readFileSync(path.join(repoRoot, filename), 'utf-8'),
90
- ]);
91
- surfaces.push(['generated CDN page', written()]);
92
- let importCount = 0;
93
-
94
- for (const [label, source] of surfaces) {
95
- const urls = astryxEsmImports(source);
96
- importCount += urls.length;
97
- for (const url of urls) {
98
- const external =
99
- new URL(url).searchParams.get('external')?.split(',') ?? [];
100
- expect(external, `${label}: ${url}`).toEqual(['react', 'react-dom']);
101
- }
102
- }
103
- expect(importCount).toBeGreaterThan(0);
104
- });
105
-
106
58
  it('loads the font family the theme names', () => {
107
59
  templateCdn({cwd: tmpDir});
108
60
  const html = written();
@@ -18,9 +18,6 @@
18
18
  * @param {boolean} [options.list]
19
19
  * @param {boolean} [options.skeleton]
20
20
  * @param {boolean | string} [options.cdn] - Write the no-build-step CDN starter page; a string is used as the destination path.
21
- * @param {boolean} [options.html] - Deprecated alias for framework='html'.
22
- * @param {'react'|'html'|'web-components'} [options.framework] - Output framework; defaults to react.
23
- * @param {string} [options.cdnRef] - Git ref used for vanilla jsDelivr URLs; valid only with html or web-components.
24
21
  * @param {boolean} [options.show]
25
22
  * @param {'page'|'block'} [options.type] - Filter list views / narrow lookups by template kind.
26
23
  * @param {string} [options.package] - Narrow lookups to a specific package (id-only matches across packages are ambiguous).
@@ -33,9 +30,6 @@ export function template(name?: string, options?: {
33
30
  list?: boolean | undefined;
34
31
  skeleton?: boolean | undefined;
35
32
  cdn?: string | boolean | undefined;
36
- html?: boolean | undefined;
37
- framework?: "react" | "html" | "web-components" | undefined;
38
- cdnRef?: string | undefined;
39
33
  show?: boolean | undefined;
40
34
  type?: "page" | "block" | undefined;
41
35
  package?: string | undefined;
@@ -13,7 +13,7 @@ export const doc = {
13
13
  name: 'template',
14
14
  namespace: 'cli/api',
15
15
  displayName: 'template()',
16
- summary: 'List, inspect, scaffold, or render page and block templates.',
16
+ summary: 'List, inspect, or scaffold page and block templates.',
17
17
  description:
18
18
  'One entry point for the template family: with no name it lists the discovered ' +
19
19
  "templates; with a name it returns that template's source, a layout skeleton, or " +
@@ -22,12 +22,10 @@ export const doc = {
22
22
  'addresses the Core original. Other duplicate ids remain ambiguous and can be ' +
23
23
  'narrowed by type and/or package. The cdn option writes the annotated ' +
24
24
  'no-build-step CDN starter page, which ships as an asset rather than as ' +
25
- 'a discovered template. The framework option selects React templates (default), ' +
26
- 'standalone HTML pages, or standalone web-component pages. Vanilla pages ' +
27
- 'substitute a commit-pinned jsDelivr base URL; html is a deprecated alias for framework=html.',
25
+ 'a discovered template.',
28
26
  importPath: '@astryxdesign/cli/api',
29
27
  signature:
30
- 'template(name?: string, options?: TemplateOptions): Promise<TemplateListResponse | TemplateShowResponse | TemplateSkeletonResponse | TemplateCopyResponse | TemplateCdnResponse | TemplateHtmlListResponse | TemplateHtmlResponse | TemplateWebComponentsListResponse | TemplateWebComponentsResponse>',
28
+ 'template(name?: string, options?: TemplateOptions): Promise<TemplateListResponse | TemplateShowResponse | TemplateSkeletonResponse | TemplateCopyResponse | TemplateCdnResponse>',
31
29
  keywords: [
32
30
  'template',
33
31
  'scaffold',
@@ -67,26 +65,6 @@ export const doc = {
67
65
  'Write the annotated no-build-step CDN starter page instead of resolving a template. Answers before discovery, so no name is involved; pass a string to use it as the destination path.',
68
66
  default: 'false',
69
67
  },
70
- {
71
- name: 'options.framework',
72
- type: "'react' | 'html' | 'web-components'",
73
- description:
74
- 'Choose React templates (default), standalone vanilla HTML, or standalone vanilla web-component pages.',
75
- default: "'react'",
76
- },
77
- {
78
- name: 'options.html',
79
- type: 'boolean',
80
- description: 'Deprecated alias for options.framework=html.',
81
- default: 'false',
82
- },
83
- {
84
- name: 'options.cdnRef',
85
- type: 'string',
86
- description:
87
- 'Override the Git ref inserted into the vanilla jsDelivr base URL. Requires framework=html or web-components and a named template.',
88
- default: 'ASTRYX_VANILLA_CDN_REF',
89
- },
90
68
  {
91
69
  name: 'options.show',
92
70
  type: 'boolean',
@@ -111,7 +89,7 @@ export const doc = {
111
89
  type: 'string',
112
90
  description:
113
91
  'Destination (relative to cwd) to scaffold the template into. Its presence switches a named lookup into a copy. ' +
114
- "A path that ends in .tsx, .ts, .jsx, .js, .mjs, .cjs, .css, .scss, .json, .md or .html is the file to write; any other path is a directory, which receives page.tsx for a page template or the block's own file name for a block.",
92
+ 'A path that ends in .tsx, .ts, .jsx, .js, .mjs, .cjs, .css, .scss, .json, .md or .html is the file to write; any other path is a directory, which receives page.tsx for a page template or the block\'s own file name for a block.',
115
93
  },
116
94
  {
117
95
  name: 'options.overwrite',
@@ -153,30 +131,8 @@ export const doc = {
153
131
  description:
154
132
  'A write receipt for the 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.',
155
133
  },
156
- {
157
- type: 'template.html.list',
158
- description: 'The sorted vanilla standalone page files as {id, file}.',
159
- },
160
- {
161
- type: 'template.html',
162
- description:
163
- 'One vanilla standalone page as {template, file, cdnRef, cdnBase, source}, with every CDN placeholder substituted.',
164
- },
165
- {
166
- type: 'template.web-components.list',
167
- description: 'The sorted vanilla web-component page files as {id, file}.',
168
- },
169
- {
170
- type: 'template.web-components',
171
- description:
172
- 'One vanilla web-component page as {template, file, cdnRef, cdnBase, source}, with every CDN placeholder substituted.',
173
- },
174
134
  ],
175
135
  throws: [
176
- {
177
- code: 'ERR_INVALID_ARGUMENT',
178
- when: 'the framework is unknown; html and framework are combined; cdnRef is used with react/list; or a vanilla framework is missing its required name/list shape or combined with cdn, skeleton, targetPath, overwrite, type, or package',
179
- },
180
136
  {
181
137
  code: 'ERR_UNKNOWN_TEMPLATE',
182
138
  when: 'the named template does not exist, or options.skeleton is set without a name',
@@ -225,14 +181,6 @@ export const doc = {
225
181
  label: 'CDN starter page',
226
182
  code: 'await template(undefined, {cdn: true});',
227
183
  },
228
- {
229
- label: 'Vanilla standalone HTML',
230
- code: "await template('dashboard', {framework: 'html'});",
231
- },
232
- {
233
- label: 'Vanilla web-component page',
234
- code: "await template('dashboard', {framework: 'web-components'});",
235
- },
236
184
  ],
237
185
  command: 'template',
238
186
  related: ['component', 'search', 'discover', 'init'],