@astryxdesign/cli 0.7.3 → 0.7.4-canary.1a552f2

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 (244) hide show
  1. package/README.md +63 -63
  2. package/api/component/_adapter.mjs +4 -3
  3. package/api/component/component.mjs +13 -6
  4. package/api/component/doc-links.test.mjs +33 -0
  5. package/api/discover/_adapter.mjs +22 -10
  6. package/api/discover/_catalog-view.d.mts +2 -0
  7. package/api/discover/_catalog-view.mjs +1 -0
  8. package/api/discover/_catalog-view.test.mjs +1 -0
  9. package/api/discover/detail/detail.mjs +1 -0
  10. package/api/discover/detail/detail.test.mjs +3 -0
  11. package/api/discover/detail/doc/doc.mjs +5 -1
  12. package/api/discover/detail/doc/doc.test.mjs +1 -0
  13. package/api/discover/detail/item/item.mjs +2 -0
  14. package/api/discover/detail/item/item.test.mjs +2 -0
  15. package/api/discover/discover.doc.mjs +4 -4
  16. package/api/discover/discover.type.d.mts +20 -0
  17. package/api/discover/discover.type.mjs +5 -0
  18. package/api/discover/list/list.test.mjs +2 -0
  19. package/api/discover/search/search.d.mts +3 -2
  20. package/api/discover/search/search.mjs +26 -7
  21. package/api/discover/search/search.test.mjs +67 -0
  22. package/api/docs/_adapter.d.mts +80 -0
  23. package/api/docs/_adapter.mjs +261 -11
  24. package/api/docs/detail/detail.mjs +8 -0
  25. package/api/docs/docOverlays.test.mjs +2 -1
  26. package/api/docs/docs.d.mts +16 -6
  27. package/api/docs/docs.doc.mjs +1 -1
  28. package/api/docs/docs.mjs +55 -6
  29. package/api/docs/docs.type.d.mts +28 -2
  30. package/api/docs/docs.type.mjs +13 -3
  31. package/api/docs/guide-route-targets.test.mjs +1002 -0
  32. package/api/docs/index/index.mjs +9 -0
  33. package/api/docs/integration-tree.test.mjs +22 -0
  34. package/api/docs/integrationDocs.test.mjs +85 -0
  35. package/api/docs/list/list.mjs +7 -1
  36. package/api/docs/node/node.mjs +9 -1
  37. package/api/docs/reference-blocks.test.mjs +1 -1
  38. package/api/doctor/_adapter.d.mts +40 -0
  39. package/api/doctor/_adapter.mjs +171 -1
  40. package/api/doctor/built-checks.d.mts +85 -0
  41. package/api/doctor/built-checks.mjs +837 -0
  42. package/api/doctor/built-checks.test.mjs +531 -0
  43. package/api/doctor/doctor.d.mts +6 -5
  44. package/api/doctor/doctor.doc.mjs +11 -1
  45. package/api/doctor/doctor.mjs +18 -3
  46. package/api/doctor/doctor.type.d.mts +6 -0
  47. package/api/doctor/doctor.type.mjs +3 -0
  48. package/api/hook/list/list.d.mts +1 -1
  49. package/api/integration/_adapter.d.mts +11 -2
  50. package/api/integration/_adapter.mjs +30 -4
  51. package/api/integration/authoring-checks.mjs +29 -2
  52. package/api/integration/authoring-checks.test.mjs +131 -1
  53. package/api/integration/check/check.d.mts +4 -1
  54. package/api/integration/check/check.mjs +34 -4
  55. package/api/integration/check/check.test.mjs +49 -0
  56. package/api/integration/integration-check.type.d.mts +8 -0
  57. package/api/integration/integration-check.type.mjs +4 -1
  58. package/api/integration/integrationCheck.doc.mjs +8 -1
  59. package/api/integration/integrationDocConflicts.doc.mjs +1 -1
  60. package/api/integration/pack-check.mjs +71 -2
  61. package/api/integration/pack-check.test.mjs +77 -0
  62. package/api/integration/validate-integration-case-disk.test.mjs +2 -0
  63. package/api/integration/validate-integration-gaps.test.mjs +7 -4
  64. package/api/integration/validate-integration.mjs +96 -14
  65. package/api/integration/validate-integration.type.d.mts +10 -4
  66. package/api/integration/validate-integration.type.mjs +10 -5
  67. package/api/integration/validateIntegration.doc.mjs +1 -1
  68. package/api/search/_candidate-score.d.mts +3 -2
  69. package/api/search/_candidate-score.mjs +66 -3
  70. package/api/search/_gather-docs.mjs +12 -2
  71. package/api/search/_priority.mjs +2 -1
  72. package/api/search/_score.d.mts +2 -1
  73. package/api/search/_score.mjs +2 -2
  74. package/api/search/search.doc.mjs +1 -1
  75. package/api/search/search.family-members.test.mjs +124 -0
  76. package/api/search/search.mjs +28 -0
  77. package/api/theme/palette/generate/generate.d.mts +8 -0
  78. package/api/theme/palette/generate/generate.mjs +38 -11
  79. package/api/theme/palette/generate/generate.test.mjs +83 -4
  80. package/api/theme/palette/generate/generator.d.mts +6 -0
  81. package/api/theme/palette/generate/generator.mjs +6 -0
  82. package/api/theme/theme.type.d.mts +12 -1
  83. package/api/theme/theme.type.mjs +7 -1
  84. package/api/theme/themeBuild.doc.mjs +1 -1
  85. package/api/theme/themeList.doc.mjs +1 -1
  86. package/api/theme/themePaletteGenerate.doc.mjs +1 -1
  87. package/api/theme/themeTargets.doc.mjs +1 -1
  88. package/assets/discover/official-packages.json +16 -0
  89. package/assets/docs/author-a-theme.doc.mjs +15 -15
  90. package/assets/docs/browser-support.doc.mjs +1 -1
  91. package/assets/docs/getting-started.doc.mjs +16 -16
  92. package/assets/docs/is-my-code-good.doc.mjs +6 -6
  93. package/assets/docs/styling-overview.doc.mjs +5 -5
  94. package/assets/docs/theme.doc.mjs +5 -5
  95. package/assets/docs/tree/add-a-component.doc.mjs +1 -1
  96. package/assets/docs/tree/add-a-theme.doc.mjs +2 -2
  97. package/assets/docs/tree/add-a-topic.doc.mjs +6 -6
  98. package/assets/docs/tree/agent-guidance.doc.mjs +5 -5
  99. package/assets/docs/tree/authoring.doc.mjs +2 -2
  100. package/assets/docs/tree/block-template.doc.mjs +1 -1
  101. package/assets/docs/tree/check-the-props.doc.mjs +3 -3
  102. package/assets/docs/tree/check-your-docs.doc.mjs +6 -6
  103. package/assets/docs/tree/checks.doc.mjs +11 -11
  104. package/assets/docs/tree/ci-and-containers.doc.mjs +1 -1
  105. package/assets/docs/tree/cli-command.doc.mjs +6 -6
  106. package/assets/docs/tree/codemods.doc.mjs +7 -7
  107. package/assets/docs/tree/component-family.doc.mjs +1 -1
  108. package/assets/docs/tree/component-imports.doc.mjs +2 -2
  109. package/assets/docs/tree/component-lookups.doc.mjs +6 -5
  110. package/assets/docs/tree/computer-agent-guide.doc.mjs +7 -7
  111. package/assets/docs/tree/computer-integrations.doc.mjs +5 -5
  112. package/assets/docs/tree/debug-and-gap-reports.doc.mjs +3 -3
  113. package/assets/docs/tree/define-the-theme.doc.mjs +1 -1
  114. package/assets/docs/tree/describe-the-component.doc.mjs +1 -1
  115. package/assets/docs/tree/doc-syntax.doc.mjs +219 -0
  116. package/assets/docs/tree/export-template-assets.doc.mjs +1 -1
  117. package/assets/docs/tree/extend-or-replace.doc.mjs +39 -7
  118. package/assets/docs/tree/font-setup.doc.mjs +1 -1
  119. package/assets/docs/tree/generate-a-palette.doc.mjs +1 -1
  120. package/assets/docs/tree/global-integrations.doc.mjs +11 -11
  121. package/assets/docs/tree/global.doc.mjs +2 -2
  122. package/assets/docs/tree/host-entry.doc.mjs +1 -1
  123. package/assets/docs/tree/install-once.doc.mjs +4 -4
  124. package/assets/docs/tree/layout.doc.mjs +1 -1
  125. package/assets/docs/tree/links.doc.mjs +2 -2
  126. package/assets/docs/tree/migration-setup.doc.mjs +15 -15
  127. package/assets/docs/tree/migration.doc.mjs +2 -1
  128. package/assets/docs/tree/other-libraries.doc.mjs +1 -1
  129. package/assets/docs/tree/page-template.doc.mjs +2 -2
  130. package/assets/docs/tree/problems.doc.mjs +8 -8
  131. package/assets/docs/tree/project-global-or-both.doc.mjs +2 -2
  132. package/assets/docs/tree/publishing.doc.mjs +7 -7
  133. package/assets/docs/tree/quick-start.doc.mjs +9 -9
  134. package/assets/docs/tree/reference.doc.mjs +2 -2
  135. package/assets/docs/tree/replace-a-core-component.doc.mjs +1 -1
  136. package/assets/docs/tree/replace-a-core-template.doc.mjs +4 -4
  137. package/assets/docs/tree/scaffold.doc.mjs +1 -1
  138. package/assets/docs/tree/sections-and-placement.doc.mjs +3 -3
  139. package/assets/docs/tree/see-it-in-an-app.doc.mjs +3 -3
  140. package/assets/docs/tree/short-and-findable.doc.mjs +3 -3
  141. package/assets/docs/tree/single-component.doc.mjs +4 -4
  142. package/assets/docs/tree/start-a-template.doc.mjs +5 -5
  143. package/assets/docs/tree/styling-advanced.doc.mjs +1 -1
  144. package/assets/docs/tree/styling-libraries.doc.mjs +2 -1
  145. package/assets/docs/tree/styling.doc.mjs +1 -1
  146. package/assets/docs/tree/tailwind.doc.mjs +1 -1
  147. package/assets/docs/tree/test-in-an-app.doc.mjs +5 -5
  148. package/assets/docs/tree/test-template-in-app.doc.mjs +6 -6
  149. package/assets/docs/tree/tokens-and-setup.doc.mjs +1 -1
  150. package/assets/docs/tree/troubleshooting.doc.mjs +24 -20
  151. package/assets/docs/tree/uninstall.doc.mjs +2 -2
  152. package/assets/docs/tree/updates.doc.mjs +1 -1
  153. package/assets/docs/tree/upgrading.doc.mjs +3 -3
  154. package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +1 -1
  155. package/assets/docs/tree/verify-packed-template.doc.mjs +3 -3
  156. package/assets/docs/tree/versioning.doc.mjs +4 -4
  157. package/assets/docs/tree/who-answers.doc.mjs +4 -4
  158. package/assets/docs/tree/write-the-template-file.doc.mjs +4 -4
  159. package/assets/docs/use-a-theme.doc.mjs +10 -10
  160. package/assets/docs/use-integrations.doc.mjs +1 -1
  161. package/assets/docs/working-with-ai.doc.mjs +15 -15
  162. package/assets/templates/blocks/components/BottomSheet/BottomSheetSwitcherReviewFlow.doc.mjs +1 -1
  163. package/assets/templates/blocks/components/BottomSheet/BottomSheetSwitcherShowcase.doc.mjs +1 -1
  164. package/assets/templates/themes/butter/butterPaletteRefs.generated.ts +54 -0
  165. package/assets/templates/themes/butter/butterPalettes.generated.receipt.json +1499 -0
  166. package/assets/templates/themes/butter/butterPalettes.generated.ts +550 -0
  167. package/assets/templates/themes/butter/butterTheme.ts +274 -234
  168. package/assets/templates/themes/butter/palette.config.json +484 -0
  169. package/assets/templates/themes/gothic/gothicPaletteRefs.generated.ts +41 -0
  170. package/assets/templates/themes/gothic/gothicPalettes.generated.receipt.json +979 -0
  171. package/assets/templates/themes/gothic/gothicPalettes.generated.ts +271 -0
  172. package/assets/templates/themes/gothic/gothicTheme.ts +130 -160
  173. package/assets/templates/themes/gothic/palette.config.json +371 -0
  174. package/assets/templates/themes/matcha/matchaPaletteRefs.generated.ts +51 -0
  175. package/assets/templates/themes/matcha/matchaPalettes.generated.receipt.json +1502 -0
  176. package/assets/templates/themes/matcha/matchaPalettes.generated.ts +501 -0
  177. package/assets/templates/themes/matcha/matchaPalettes.ts +21 -0
  178. package/assets/templates/themes/matcha/matchaTheme.ts +164 -103
  179. package/assets/templates/themes/matcha/palette.config.json +448 -0
  180. package/assets/templates/themes/stone/palette.config.json +262 -0
  181. package/assets/templates/themes/stone/stonePaletteRefs.generated.ts +51 -0
  182. package/assets/templates/themes/stone/stonePalettes.generated.receipt.json +840 -0
  183. package/assets/templates/themes/stone/stonePalettes.generated.ts +501 -0
  184. package/assets/templates/themes/stone/stoneTheme.ts +190 -207
  185. package/assets/templates/themes/y2k/palette.config.json +166 -0
  186. package/assets/templates/themes/y2k/y2kPaletteRefs.generated.ts +54 -0
  187. package/assets/templates/themes/y2k/y2kPalettes.generated.receipt.json +872 -0
  188. package/assets/templates/themes/y2k/y2kPalettes.generated.ts +550 -0
  189. package/assets/templates/themes/y2k/y2kPalettes.ts +257 -0
  190. package/assets/templates/themes/y2k/y2kTheme.ts +164 -391
  191. package/authoring/codemod/codemod.doc.mjs +1 -1
  192. package/authoring/config/config.doc.mjs +4 -4
  193. package/authoring/debug/parse.d.mts +1 -1
  194. package/authoring/discover/discover.doc.mjs +1 -1
  195. package/authoring/doctypes/_schema.d.mts +4 -0
  196. package/authoring/doctypes/_schema.mjs +4 -0
  197. package/authoring/doctypes/reference/type.ts +14 -2
  198. package/authoring/gap-report/gap-report.doc.mjs +1 -1
  199. package/authoring/integration/integration.doc.mjs +6 -6
  200. package/clients/cli/commands/discover.mjs +1 -1
  201. package/clients/cli/commands/discover.sources.test.mjs +6 -0
  202. package/clients/cli/commands/docs.doc.mjs +1 -1
  203. package/clients/cli/commands/docs.mjs +27 -2
  204. package/clients/cli/commands/docs.test.mjs +1 -1
  205. package/clients/cli/commands/doctor-integration-docs.doc.mjs +1 -1
  206. package/clients/cli/commands/doctor.doc.mjs +13 -1
  207. package/clients/cli/commands/doctor.mjs +25 -9
  208. package/clients/cli/commands/integration-check.doc.mjs +11 -0
  209. package/clients/cli/commands/integration-check.test.mjs +36 -3
  210. package/clients/cli/commands/integration-pack.doc.mjs +1 -1
  211. package/clients/cli/commands/integration-verify.doc.mjs +1 -1
  212. package/clients/cli/commands/integration.mjs +15 -3
  213. package/clients/cli/commands/theme-targets.doc.mjs +1 -1
  214. package/clients/cli/commands/upgrade.doc.mjs +2 -2
  215. package/clients/cli/lib/define-command.mjs +5 -3
  216. package/foundation/agent-docs/agent-docs.d.mts +14 -2
  217. package/foundation/agent-docs/agent-docs.mjs +65 -4
  218. package/foundation/agent-docs/agent-docs.test.mjs +107 -0
  219. package/foundation/discovery/docs-discovery.d.mts +93 -2
  220. package/foundation/discovery/docs-discovery.mjs +237 -8
  221. package/foundation/discovery/runner-allowlist.d.mts +2 -0
  222. package/foundation/discovery/runner-allowlist.mjs +4 -0
  223. package/foundation/discovery/runner-commands.d.mts +29 -13
  224. package/foundation/discovery/runner-commands.mjs +253 -17
  225. package/foundation/discovery/stray-pointers.mjs +11 -5
  226. package/foundation/discovery/stray-pointers.test.mjs +6 -0
  227. package/foundation/doc-compiler/compile.mjs +8 -1
  228. package/foundation/doc-compiler/doc-loads.test.mjs +3 -0
  229. package/foundation/doc-compiler/doc-syntax.d.mts +194 -0
  230. package/foundation/doc-compiler/doc-syntax.mjs +739 -0
  231. package/foundation/doc-compiler/doc-syntax.test.mjs +383 -0
  232. package/foundation/doc-compiler/links.d.mts +13 -16
  233. package/foundation/doc-compiler/links.mjs +40 -7
  234. package/foundation/doc-compiler/tree.d.mts +5 -0
  235. package/foundation/doc-compiler/tree.mjs +9 -0
  236. package/foundation/env/package-manager.d.mts +18 -0
  237. package/foundation/env/package-manager.mjs +40 -0
  238. package/foundation/integrations/cli-requirement.d.mts +29 -0
  239. package/foundation/integrations/cli-requirement.mjs +47 -0
  240. package/foundation/integrations/cli-requirement.test.mjs +23 -2
  241. package/foundation/response/error-codes.test.mjs +9 -0
  242. package/foundation/response/response-types.doc.mjs +11 -11
  243. package/foundation/response/response-types.doc.test.mjs +29 -0
  244. package/package.json +9 -9
@@ -0,0 +1,124 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file A family member named by short words is found by them spelled out:
5
+ * "vertical stack" is VStack, whose own description says so, and a member whose
6
+ * name is its head word after single letters is a match for that head word.
7
+ * The same holds for any integration's members, which no learned weights know.
8
+ */
9
+
10
+ import fs from 'node:fs';
11
+ import os from 'node:os';
12
+ import path from 'node:path';
13
+ import {afterAll, beforeAll, describe, expect, it} from 'vitest';
14
+ import {search} from './search.mjs';
15
+
16
+ const SLOW = 60_000;
17
+
18
+ describe('family members found by their spelled-out names', () => {
19
+ it.each([
20
+ ['vertical stack', 'VStack'],
21
+ ['horizontal stack', 'HStack'],
22
+ ])('`%s` ranks %s first', async (query, name) => {
23
+ const {results} = (await search(query)).data;
24
+ expect(results[0], JSON.stringify(results.slice(0, 3))).toMatchObject({
25
+ domain: 'component',
26
+ name,
27
+ });
28
+ });
29
+
30
+ it('`stack` keeps Stack first and lists VStack and HStack', async () => {
31
+ const {results} = (await search('stack')).data;
32
+ expect(results[0]).toMatchObject({domain: 'component', name: 'Stack'});
33
+ const top = results.slice(0, 8).map(r => r.name);
34
+ expect(top).toContain('VStack');
35
+ expect(top).toContain('HStack');
36
+ });
37
+
38
+ it('only a single-letter word is spelled out', async () => {
39
+ // "without" begins with "With" but spells out no letter of the name.
40
+ const {results} = (await search('checkbox list without end content')).data;
41
+ expect(results[0]?.reason).not.toMatch(/spelled out/);
42
+ });
43
+
44
+ it('a longer query keeps Stack first', async () => {
45
+ // Stack in VStack counts as a keyword hit only when it is the whole query.
46
+ const {results} = (await search('vertical stack of cards')).data;
47
+ expect(results[0]).toMatchObject({domain: 'component', name: 'Stack'});
48
+ });
49
+
50
+ it("a longer query does not lift a head word's members", async () => {
51
+ const {results} = (await search('stack direction')).data;
52
+ const top = results.slice(0, 3).map(r => r.name);
53
+ expect(top).not.toContain('VStack');
54
+ expect(top).not.toContain('HStack');
55
+ });
56
+
57
+ it('a word the description does not spell out is no name', async () => {
58
+ const {results} = (await search('visual stack')).data;
59
+ expect(results[0]?.name).not.toBe('VStack');
60
+ });
61
+ });
62
+
63
+ describe("an integration's family members (cold start)", () => {
64
+ /** @type {string} */
65
+ let dir;
66
+ beforeAll(() => {
67
+ dir = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-family-members-'));
68
+ const pkg = path.join(dir, 'node_modules', '@acme', 'grids');
69
+ fs.mkdirSync(path.join(pkg, 'components'), {recursive: true});
70
+ fs.mkdirSync(
71
+ path.join(dir, 'node_modules', '@astryxdesign', 'core', 'src'),
72
+ {
73
+ recursive: true,
74
+ },
75
+ );
76
+ fs.writeFileSync(path.join(dir, 'package.json'), '{"name":"consumer"}');
77
+ fs.writeFileSync(
78
+ path.join(dir, 'astryx.config.mjs'),
79
+ "export default { integrations: ['@acme/grids'] };\n",
80
+ );
81
+ fs.writeFileSync(
82
+ path.join(pkg, 'package.json'),
83
+ '{"name":"@acme/grids","version":"1.0.0"}',
84
+ );
85
+ fs.writeFileSync(
86
+ path.join(pkg, 'astryx.integration.mjs'),
87
+ "export default { components: './components' };\n",
88
+ );
89
+ for (const [name, description] of [
90
+ ['VGrid', 'Vertical grid for arranging tiles in columns.'],
91
+ ['HGrid', 'Horizontal grid for arranging tiles in rows.'],
92
+ ]) {
93
+ fs.writeFileSync(
94
+ path.join(pkg, 'components', `${name}.doc.mjs`),
95
+ `export default {
96
+ type: 'component',
97
+ name: '${name}',
98
+ usage: {description: '${description}'},
99
+ props: [],
100
+ };\n`,
101
+ );
102
+ fs.writeFileSync(
103
+ path.join(pkg, 'components', `${name}.tsx`),
104
+ `export function ${name}() { return null; }\n`,
105
+ );
106
+ }
107
+ });
108
+ afterAll(() => fs.rmSync(dir, {recursive: true, force: true}));
109
+
110
+ it.each([
111
+ ['vertical grid', 'VGrid'],
112
+ ['horizontal grid', 'HGrid'],
113
+ ])(
114
+ '`%s` ranks %s first',
115
+ async (query, name) => {
116
+ const {results} = (await search(query, {cwd: dir, type: 'component'}))
117
+ .data;
118
+ expect(results[0], JSON.stringify(results.slice(0, 3))).toMatchObject({
119
+ name,
120
+ });
121
+ },
122
+ SLOW,
123
+ );
124
+ });
@@ -14,6 +14,10 @@
14
14
  * reads it, so build's output does not move when search's tree does.
15
15
  */
16
16
 
17
+ import {
18
+ docPackageManager,
19
+ runWithDocPackageManager,
20
+ } from '../../foundation/env/package-manager.mjs';
17
21
  import {withListingCache} from '../../foundation/fs/listing-cache.mjs';
18
22
  import {
19
23
  gatherCandidates,
@@ -52,6 +56,18 @@ export {componentKeywords} from './_adapter.mjs';
52
56
  */
53
57
  export async function search(query, options = {}) {
54
58
  checkSearchArgs(query, options);
59
+ return runWithDocPackageManager(
60
+ docPackageManager(options.cwd ?? process.cwd()),
61
+ () => searchRead(query, options),
62
+ );
63
+ }
64
+
65
+ /**
66
+ * The search itself, inside its project's package-manager scope.
67
+ * @param {string} query
68
+ * @param {any} options
69
+ */
70
+ async function searchRead(query, options) {
55
71
  return withListingCache(
56
72
  async () =>
57
73
  /** @type {import('./search.type.mjs').SearchResponse} */ (
@@ -79,6 +95,18 @@ export async function search(query, options = {}) {
79
95
  */
80
96
  export async function searchCore(query, options = {}) {
81
97
  checkSearchArgs(query, options);
98
+ return runWithDocPackageManager(
99
+ docPackageManager(options.cwd ?? process.cwd()),
100
+ () => searchCoreRead(query, options),
101
+ );
102
+ }
103
+
104
+ /**
105
+ * The lexical search itself, inside its project's package-manager scope.
106
+ * @param {string} query
107
+ * @param {any} options
108
+ */
109
+ async function searchCoreRead(query, options) {
82
110
  return withListingCache(async () =>
83
111
  linkSearchResponse(
84
112
  rankLexical(query, options, await gatherCandidates(options)),
@@ -18,6 +18,10 @@ export function themePaletteGenerate(configPath: string, options?: {
18
18
  }, { cwd }?: {
19
19
  cwd?: string;
20
20
  }): import("../../theme.type.mjs").ThemePaletteGenerateResponse;
21
+ /** Format of the TypeScript candidate module written for a `.ts` output. */
22
+ export const PALETTE_TYPESCRIPT_FORMAT_VERSION: "palette-typescript-v1";
23
+ /** Format of the canonical JSON candidate the recipe fixtures pin. */
24
+ export const PALETTE_JSON_FORMAT_VERSION: "palette-json-v1";
21
25
  export type TonalPaletteCandidate = import("../../theme.type.mjs").TonalPaletteCandidate;
22
26
  export type TonalPaletteGenerationInput = import("../../theme.type.mjs").TonalPaletteGenerationInput;
23
27
  export type PaletteMode = "light" | "dark";
@@ -26,4 +30,8 @@ export type PendingFile = {
26
30
  path: string;
27
31
  next: string;
28
32
  };
33
+ export type SerializedCandidate = {
34
+ format: typeof PALETTE_TYPESCRIPT_FORMAT_VERSION | typeof PALETTE_JSON_FORMAT_VERSION;
35
+ text: string;
36
+ };
29
37
  import { generatePaletteSet } from './generator.mjs';
@@ -12,16 +12,23 @@ import {AstryxError} from '../../../error.mjs';
12
12
  import {
13
13
  generatePaletteSet,
14
14
  PALETTE_BLACK,
15
+ PALETTE_GENERATOR_VERSION,
15
16
  PALETTE_WHITE,
16
17
  serializeGenerationResult,
17
18
  } from './generator.mjs';
18
19
  import {PALETTE_PREVIEW_VERSION, renderPalettePreview} from './preview.mjs';
19
20
 
21
+ /** Format of the TypeScript candidate module written for a `.ts` output. */
22
+ export const PALETTE_TYPESCRIPT_FORMAT_VERSION = 'palette-typescript-v1';
23
+ /** Format of the canonical JSON candidate the recipe fixtures pin. */
24
+ export const PALETTE_JSON_FORMAT_VERSION = 'palette-json-v1';
25
+
20
26
  /** @typedef {import('../../theme.type.mjs').TonalPaletteCandidate} TonalPaletteCandidate */
21
27
  /** @typedef {import('../../theme.type.mjs').TonalPaletteGenerationInput} TonalPaletteGenerationInput */
22
28
  /** @typedef {'light' | 'dark'} PaletteMode */
23
29
  /** @typedef {ReturnType<typeof generatePaletteSet>} PaletteGenerationResult */
24
30
  /** @typedef {{path: string, next: string}} PendingFile */
31
+ /** @typedef {{format: typeof PALETTE_TYPESCRIPT_FORMAT_VERSION | typeof PALETTE_JSON_FORMAT_VERSION, text: string}} SerializedCandidate */
25
32
 
26
33
  /** @param {PaletteGenerationResult} result @returns {TonalPaletteCandidate} */
27
34
  function paletteSnapshot(result) {
@@ -90,10 +97,28 @@ export function serializePaletteCandidate(candidate) {
90
97
  return `{\n "schemaVersion": 1,\n "status": "candidate",\n "recipe": ${JSON.stringify(candidate.recipe)},\n "black": ${JSON.stringify(candidate.black)},\n "white": ${JSON.stringify(candidate.white)},\n "stops": [\n${stops.join(',\n')}\n ],\n "palette": ${serializePalette(candidate.palette, 2)}\n}\n`;
91
98
  }
92
99
 
93
- /** @param {TonalPaletteCandidate} candidate @param {string} outputPath */
100
+ /**
101
+ * Serialize a candidate for its destination and name the format of the exact
102
+ * bytes produced. Without a destination, the canonical JSON form identifies
103
+ * the candidate.
104
+ *
105
+ * @param {TonalPaletteCandidate} candidate
106
+ * @param {string | null} outputPath
107
+ * @returns {SerializedCandidate}
108
+ */
94
109
  function serializeCandidate(candidate, outputPath) {
95
- if (outputPath.endsWith('.ts')) return serializePaletteModule(candidate);
96
- if (outputPath.endsWith('.json')) return serializePaletteCandidate(candidate);
110
+ if (outputPath != null && outputPath.endsWith('.ts')) {
111
+ return {
112
+ format: PALETTE_TYPESCRIPT_FORMAT_VERSION,
113
+ text: serializePaletteModule(candidate),
114
+ };
115
+ }
116
+ if (outputPath == null || outputPath.endsWith('.json')) {
117
+ return {
118
+ format: PALETTE_JSON_FORMAT_VERSION,
119
+ text: serializePaletteCandidate(candidate),
120
+ };
121
+ }
97
122
  throw new AstryxError(
98
123
  'Palette output must end in .ts or .json.',
99
124
  undefined,
@@ -101,12 +126,14 @@ function serializeCandidate(candidate, outputPath) {
101
126
  );
102
127
  }
103
128
 
104
- /** @param {PaletteGenerationResult} result @param {string} candidateText @param {string | null} [previewText] @returns {import('../../theme.type.mjs').TonalPaletteGenerationReceipt} */
105
- function receiptFor(result, candidateText, previewText = null) {
129
+ /** @param {PaletteGenerationResult} result @param {SerializedCandidate} serialized @param {string | null} [previewText] @returns {import('../../theme.type.mjs').TonalPaletteGenerationReceipt} */
130
+ function receiptFor(result, serialized, previewText = null) {
106
131
  return {
107
132
  schemaVersion: 1,
108
133
  recipe: result.recipe,
109
- candidateSha256: createHash('sha256').update(candidateText).digest('hex'),
134
+ generatorVersion: PALETTE_GENERATOR_VERSION,
135
+ candidateFormatVersion: serialized.format,
136
+ candidateSha256: createHash('sha256').update(serialized.text).digest('hex'),
110
137
  ...(previewText
111
138
  ? {
112
139
  preview: {
@@ -345,9 +372,9 @@ export function themePaletteGenerate(
345
372
  }
346
373
 
347
374
  const candidate = paletteSnapshot(result);
348
- let candidateText = serializePaletteCandidate(candidate);
375
+ let serialized = serializeCandidate(candidate, null);
349
376
  const previewText = options.preview ? renderPalettePreview(candidate) : null;
350
- let receipt = receiptFor(result, candidateText, previewText);
377
+ let receipt = receiptFor(result, serialized, previewText);
351
378
  /** @type {string | null} */
352
379
  let output = null;
353
380
  /** @type {string | null} */
@@ -363,13 +390,13 @@ export function themePaletteGenerate(
363
390
  if (options.out) {
364
391
  const resolvedOutput = resolveSafe(options.out, cwd, 'palette output path');
365
392
  const resolvedReceipt = receiptPathFor(resolvedOutput);
366
- candidateText = serializeCandidate(candidate, resolvedOutput);
367
- receipt = receiptFor(result, candidateText, previewText);
393
+ serialized = serializeCandidate(candidate, resolvedOutput);
394
+ receipt = receiptFor(result, serialized, previewText);
368
395
  const receiptText = serializeGenerationResult(receipt);
369
396
  output = path.relative(cwd, resolvedOutput);
370
397
  receiptOutput = path.relative(cwd, resolvedReceipt);
371
398
  files.push(
372
- {path: resolvedOutput, next: candidateText},
399
+ {path: resolvedOutput, next: serialized.text},
373
400
  {path: resolvedReceipt, next: receiptText},
374
401
  );
375
402
  }
@@ -6,7 +6,12 @@ import * as os from 'node:os';
6
6
  import * as path from 'node:path';
7
7
  import {afterEach, describe, expect, it} from 'vitest';
8
8
  import {isErrorCode} from '../../../../foundation/response/error-codes.mjs';
9
- import {themePaletteGenerate} from './generate.mjs';
9
+ import {
10
+ PALETTE_JSON_FORMAT_VERSION,
11
+ PALETTE_TYPESCRIPT_FORMAT_VERSION,
12
+ themePaletteGenerate,
13
+ } from './generate.mjs';
14
+ import {PALETTE_GENERATOR_VERSION} from './generator.mjs';
10
15
 
11
16
  const temporaryDirectories = [];
12
17
 
@@ -79,7 +84,12 @@ describe('themePaletteGenerate', () => {
79
84
  fs.readFileSync(path.join(cwd, 'ocean.palette.receipt.json'), 'utf-8'),
80
85
  );
81
86
  expect(receipt.recipe).toBe('astryx-oklch-v1');
82
- expect(receipt.candidateSha256).toMatch(/^[0-9a-f]{64}$/);
87
+ expect(receipt.generatorVersion).toBe('palette-generator-v1');
88
+ expect(receipt.candidateFormatVersion).toBe('palette-typescript-v1');
89
+ expect(receipt.candidateSha256).toBe(
90
+ createHash('sha256').update(candidate).digest('hex'),
91
+ );
92
+ expect(receipt).toEqual(result.data.generationReceipt);
83
93
  expect(candidate).toContain('// prettier-ignore');
84
94
  expect(candidate).toContain("export const black = '#000000' as const;");
85
95
  expect(candidate).toContain("export const white = '#ffffff' as const;");
@@ -103,6 +113,69 @@ describe('themePaletteGenerate', () => {
103
113
  expect(result.data.receipt).toBe('ocean.palette.receipt.json');
104
114
  });
105
115
 
116
+ it('names the generator and the format of the exact bytes each receipt covers', () => {
117
+ expect(PALETTE_GENERATOR_VERSION).toBe('palette-generator-v1');
118
+ expect(PALETTE_TYPESCRIPT_FORMAT_VERSION).toBe('palette-typescript-v1');
119
+ expect(PALETTE_JSON_FORMAT_VERSION).toBe('palette-json-v1');
120
+
121
+ const cwd = fixture();
122
+ const sha256 = file =>
123
+ createHash('sha256')
124
+ .update(fs.readFileSync(path.join(cwd, file)))
125
+ .digest('hex');
126
+ const printed = themePaletteGenerate('palette.config.json', {}, {cwd}).data
127
+ .generationReceipt;
128
+ const typescript = themePaletteGenerate(
129
+ 'palette.config.json',
130
+ {out: 'ocean.palette.ts'},
131
+ {cwd},
132
+ ).data.generationReceipt;
133
+ const json = themePaletteGenerate(
134
+ 'palette.config.json',
135
+ {out: 'ocean-json.palette.json'},
136
+ {cwd},
137
+ ).data.generationReceipt;
138
+
139
+ // Existing receipt fields keep their positions; the versions sit beside
140
+ // the digest they qualify.
141
+ expect(Object.keys(typescript)).toEqual([
142
+ 'schemaVersion',
143
+ 'recipe',
144
+ 'generatorVersion',
145
+ 'candidateFormatVersion',
146
+ 'candidateSha256',
147
+ 'request',
148
+ 'diagnostics',
149
+ ]);
150
+ expect(typescript).toMatchObject({
151
+ generatorVersion: PALETTE_GENERATOR_VERSION,
152
+ candidateFormatVersion: PALETTE_TYPESCRIPT_FORMAT_VERSION,
153
+ candidateSha256: sha256('ocean.palette.ts'),
154
+ });
155
+ expect(json).toMatchObject({
156
+ generatorVersion: PALETTE_GENERATOR_VERSION,
157
+ candidateFormatVersion: PALETTE_JSON_FORMAT_VERSION,
158
+ candidateSha256: sha256('ocean-json.palette.json'),
159
+ });
160
+ // Without an output path, the receipt covers the canonical JSON bytes.
161
+ expect(printed).toEqual(json);
162
+ // Only the serialized bytes differ between formats, never the generation.
163
+ expect(typescript.candidateSha256).not.toBe(json.candidateSha256);
164
+ expect({
165
+ ...typescript,
166
+ candidateFormatVersion: null,
167
+ candidateSha256: null,
168
+ }).toEqual({...json, candidateFormatVersion: null, candidateSha256: null});
169
+ for (const [file, receipt] of [
170
+ ['ocean.palette.receipt.json', typescript],
171
+ ['ocean-json.palette.receipt.json', json],
172
+ ]) {
173
+ expect(
174
+ JSON.parse(fs.readFileSync(path.join(cwd, file), 'utf-8')),
175
+ ).toEqual(receipt);
176
+ }
177
+ });
178
+
106
179
  it('writes candidate JSON byte-identical to the recipe fixtures', () => {
107
180
  const families = [
108
181
  {id: 'neutral', name: 'Neutral', seed: '#777777', kind: 'neutral'},
@@ -164,7 +237,10 @@ describe('themePaletteGenerate', () => {
164
237
  );
165
238
 
166
239
  const printed = themePaletteGenerate('palette.config.json', {}, {cwd});
167
- expect(printed.data.generationReceipt.candidateSha256).toBe(sha256);
240
+ expect(printed.data.generationReceipt).toMatchObject({
241
+ candidateFormatVersion: 'palette-json-v1',
242
+ candidateSha256: sha256,
243
+ });
168
244
 
169
245
  const result = themePaletteGenerate(
170
246
  'palette.config.json',
@@ -174,7 +250,10 @@ describe('themePaletteGenerate', () => {
174
250
  const written = fs.readFileSync(path.join(cwd, 'candidate.json'));
175
251
  expect(written.length).toBe(bytes);
176
252
  expect(createHash('sha256').update(written).digest('hex')).toBe(sha256);
177
- expect(result.data.generationReceipt.candidateSha256).toBe(sha256);
253
+ expect(result.data.generationReceipt).toMatchObject({
254
+ candidateFormatVersion: 'palette-json-v1',
255
+ candidateSha256: sha256,
256
+ });
178
257
  }
179
258
  });
180
259
 
@@ -34,6 +34,12 @@ export function serializeGenerationResult(result: unknown): string;
34
34
  /** @typedef {{id: string, name: string, seed: string, light?: GeneratedRamp, dark?: GeneratedRamp}} GeneratedFamily */
35
35
  /** @typedef {{recipe: typeof PALETTE_RECIPE, status: 'candidate', request: NormalizedRequest, families: GeneratedFamily[], coordination: TonalPaletteCoordinationDiagnostics[], errors: {familyId: string, message: string}[]}} PaletteGenerationResult */
36
36
  export const PALETTE_RECIPE: "astryx-oklch-v1";
37
+ /**
38
+ * Identity of this generator implementation. `PALETTE_RECIPE` names the
39
+ * normative algorithm; this names the code that ran it, so a receipt can tell
40
+ * two implementations of one recipe apart.
41
+ */
42
+ export const PALETTE_GENERATOR_VERSION: "palette-generator-v1";
37
43
  export const PALETTE_BLACK: "#000000";
38
44
  export const PALETTE_WHITE: "#ffffff";
39
45
  export const DEFAULT_21_STOPS: readonly number[];
@@ -25,6 +25,12 @@ import {
25
25
  /** @typedef {{recipe: typeof PALETTE_RECIPE, status: 'candidate', request: NormalizedRequest, families: GeneratedFamily[], coordination: TonalPaletteCoordinationDiagnostics[], errors: {familyId: string, message: string}[]}} PaletteGenerationResult */
26
26
 
27
27
  export const PALETTE_RECIPE = 'astryx-oklch-v1';
28
+ /**
29
+ * Identity of this generator implementation. `PALETTE_RECIPE` names the
30
+ * normative algorithm; this names the code that ran it, so a receipt can tell
31
+ * two implementations of one recipe apart.
32
+ */
33
+ export const PALETTE_GENERATOR_VERSION = 'palette-generator-v1';
28
34
  export const PALETTE_BLACK = '#000000';
29
35
  export const PALETTE_WHITE = '#ffffff';
30
36
  export const DEFAULT_21_STOPS = Object.freeze([
@@ -417,7 +417,18 @@ export type TonalPaletteGenerationReceipt = {
417
417
  */
418
418
  recipe: "astryx-oklch-v1";
419
419
  /**
420
- * SHA-256 over the candidate bytes as written.
420
+ * Generator
421
+ * implementation that ran the recipe.
422
+ */
423
+ generatorVersion: "palette-generator-v1";
424
+ /**
425
+ * Format of the candidate bytes `candidateSha256` covers: the TypeScript
426
+ * module for a `.ts` output, otherwise canonical JSON.
427
+ */
428
+ candidateFormatVersion: "palette-typescript-v1" | "palette-json-v1";
429
+ /**
430
+ * SHA-256 over the candidate bytes in
431
+ * `candidateFormatVersion`, exactly as written when an output path is given.
421
432
  */
422
433
  candidateSha256: string;
423
434
  /**
@@ -245,7 +245,13 @@
245
245
  * @typedef {object} TonalPaletteGenerationReceipt
246
246
  * @property {1} schemaVersion
247
247
  * @property {'astryx-oklch-v1'} recipe Recipe that produced the candidate.
248
- * @property {string} candidateSha256 SHA-256 over the candidate bytes as written.
248
+ * @property {'palette-generator-v1'} generatorVersion Generator
249
+ * implementation that ran the recipe.
250
+ * @property {'palette-typescript-v1' | 'palette-json-v1'} candidateFormatVersion
251
+ * Format of the candidate bytes `candidateSha256` covers: the TypeScript
252
+ * module for a `.ts` output, otherwise canonical JSON.
253
+ * @property {string} candidateSha256 SHA-256 over the candidate bytes in
254
+ * `candidateFormatVersion`, exactly as written when an output path is given.
249
255
  * @property {{version: string, sha256: string}} [preview] Present when preview
250
256
  * content was generated for the request, even if no file was written because
251
257
  * the target already exists.
@@ -20,7 +20,7 @@ export const doc = {
20
20
  summary:
21
21
  'Compile a defineTheme() file to scoped CSS, a JS module, and type declarations, or check committed outputs for drift in CI.',
22
22
  description:
23
- 'The compiler behind `astryx theme build`. Reads a file that calls defineTheme() and ' +
23
+ 'The compiler behind `{@command theme build}`. Reads a file that calls defineTheme() and ' +
24
24
  'writes a scoped CSS file, a JS module that re-exports the built theme, and a .d.ts ' +
25
25
  '(plus an optional .variants.d.ts when the theme adds custom prop values). It uses ' +
26
26
  "@astryxdesign/core's own generator, so the CSS matches what the <Theme> runtime emits. " +
@@ -13,7 +13,7 @@ export const doc = {
13
13
  displayName: 'themeList()',
14
14
  summary: 'List themes bundled with this CLI build.',
15
15
  description:
16
- 'Synchronous list of the themes bundled with the CLI. It does not include themes from installed integrations; use themeListAvailable() for the list `astryx theme list` shows.',
16
+ 'Synchronous list of the themes bundled with the CLI. It does not include themes from installed integrations; use themeListAvailable() for the list `{@command theme list}` shows.',
17
17
  importPath: '@astryxdesign/cli/api',
18
18
  signature: 'themeList(): ThemeListResponse',
19
19
  keywords: ['theme', 'list', 'themes', 'bundled', 'available'],
@@ -61,7 +61,7 @@ export const doc = {
61
61
  {
62
62
  type: 'theme.palette.generate',
63
63
  description:
64
- 'The candidate, generation receipt, summary counts, and optional file-write receipt.',
64
+ 'The candidate, summary counts, optional file-write result, and generationReceipt. The generationReceipt identifies generatorVersion `palette-generator-v1` and candidateFormatVersion `palette-typescript-v1` or `palette-json-v1` beside the candidate digest.',
65
65
  },
66
66
  ],
67
67
  throws: [
@@ -18,7 +18,7 @@ export const doc = {
18
18
  description:
19
19
  'Enumerates the whole themeable surface: each `defineTheme` components key, the stable ' +
20
20
  'class it paints, the component that declares it, and the props and states that are legal ' +
21
- 'override keys under it. Same source as the Theming table `astryx component <Name>` prints ' +
21
+ 'override keys under it. Same source as the Theming table `{@command component <Name>}` prints ' +
22
22
  '(the component docs), so the list cannot drift from the components, and `theme build` ' +
23
23
  'validates overrides against this exact set. A filter naming a component gives that ' +
24
24
  "component's set; anything else is a case-insensitive substring search over each target's key, class and component.",
@@ -243,6 +243,22 @@
243
243
  {
244
244
  "kind": "template",
245
245
  "name": "EmojiPickerShowcase"
246
+ },
247
+ {
248
+ "kind": "template",
249
+ "name": "ListInputBudgetAllocation"
250
+ },
251
+ {
252
+ "kind": "template",
253
+ "name": "ListInputFamilyMembers"
254
+ },
255
+ {
256
+ "kind": "template",
257
+ "name": "ListInputMailingList"
258
+ },
259
+ {
260
+ "kind": "template",
261
+ "name": "ListInputShowcase"
246
262
  }
247
263
  ]
248
264
  },