@astryxdesign/cli 0.6.0 → 0.6.1

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 (219) hide show
  1. package/CHANGELOG.md +48 -1
  2. package/README.md +76 -67
  3. package/api/build/build.test.mjs +37 -0
  4. package/api/build/build.type.mjs +1 -1
  5. package/api/build/kit/kit.mjs +31 -1
  6. package/api/component/_adapter.mjs +14 -28
  7. package/api/component/integration-import-agreement.test.mjs +318 -0
  8. package/api/doctor/doctor.d.mts +32 -3
  9. package/api/doctor/doctor.doc.mjs +2 -1
  10. package/api/doctor/doctor.mjs +97 -4
  11. package/api/doctor/doctor.test.mjs +90 -1
  12. package/api/gap-report/gap-report-worker.d.mts +4 -0
  13. package/api/gap-report/gap-report-worker.mjs +73 -0
  14. package/api/gap-report/gap-report.d.mts +81 -0
  15. package/api/gap-report/gap-report.doc.d.mts +9 -0
  16. package/api/gap-report/gap-report.doc.mjs +127 -0
  17. package/api/gap-report/gap-report.mjs +707 -0
  18. package/api/gap-report/gap-report.test.mjs +1210 -0
  19. package/api/gap-report/gap-report.type.d.mts +88 -0
  20. package/api/gap-report/gap-report.type.mjs +69 -0
  21. package/api/index.d.mts +8 -1
  22. package/api/index.mjs +24 -1
  23. package/api/integration/add-contribution.d.mts +44 -0
  24. package/api/integration/add-contribution.mjs +1160 -0
  25. package/api/integration/add-contribution.test.mjs +733 -0
  26. package/api/integration/add-helpers.d.mts +80 -0
  27. package/api/integration/add-helpers.mjs +333 -0
  28. package/api/integration/add-helpers.test.mjs +161 -0
  29. package/api/integration/add-theme.d.mts +10 -0
  30. package/api/integration/add-theme.mjs +332 -0
  31. package/api/integration/add-theme.test.mjs +194 -0
  32. package/api/integration/integration-authoring.type.d.mts +55 -0
  33. package/api/integration/integration-authoring.type.mjs +76 -0
  34. package/api/integration/integration-block-exports.test.mjs +4 -0
  35. package/api/integration/integrationAdd.doc.d.mts +5 -0
  36. package/api/integration/integrationAdd.doc.mjs +100 -0
  37. package/api/integration/integrationAddAgentDoc.doc.d.mts +5 -0
  38. package/api/integration/integrationAddAgentDoc.doc.mjs +49 -0
  39. package/api/integration/integrationAddCodemod.doc.d.mts +5 -0
  40. package/api/integration/integrationAddCodemod.doc.mjs +55 -0
  41. package/api/integration/integrationAddComponent.doc.d.mts +5 -0
  42. package/api/integration/integrationAddComponent.doc.mjs +49 -0
  43. package/api/integration/integrationAddDoc.doc.d.mts +5 -0
  44. package/api/integration/integrationAddDoc.doc.mjs +59 -0
  45. package/api/integration/integrationAddTemplate.doc.d.mts +5 -0
  46. package/api/integration/integrationAddTemplate.doc.mjs +55 -0
  47. package/api/integration/integrationAddTheme.doc.d.mts +5 -0
  48. package/api/integration/integrationAddTheme.doc.mjs +85 -0
  49. package/api/integration/integrationPackCheck.doc.d.mts +5 -0
  50. package/api/integration/integrationPackCheck.doc.mjs +35 -0
  51. package/api/integration/pack-check.d.mts +27 -0
  52. package/api/integration/pack-check.mjs +795 -0
  53. package/api/integration/pack-check.test.mjs +569 -0
  54. package/api/integration/pack-check.type.d.mts +45 -0
  55. package/api/integration/pack-check.type.mjs +56 -0
  56. package/api/integration/public-api.test.mjs +21 -0
  57. package/api/integration/validate-integration.mjs +221 -11
  58. package/api/integration/validate-integration.test.mjs +189 -5
  59. package/api/integration/validateIntegration.doc.mjs +2 -2
  60. package/api/json/index.ts +1 -0
  61. package/api/search/search.mjs +19 -1
  62. package/api/theme/_adapter.d.mts +26 -28
  63. package/api/theme/_adapter.mjs +101 -38
  64. package/api/theme/add/add.d.mts +2 -1
  65. package/api/theme/add/add.mjs +56 -20
  66. package/api/theme/add/add.test.mjs +1 -0
  67. package/api/theme/build/build.d.mts +25 -0
  68. package/api/theme/build/build.mjs +101 -70
  69. package/api/theme/build/build.test.mjs +77 -44
  70. package/api/theme/integration-themes.test.mjs +183 -0
  71. package/api/theme/list/list.d.mts +10 -2
  72. package/api/theme/list/list.mjs +31 -10
  73. package/api/theme/list/list.test.mjs +102 -23
  74. package/api/theme/listThemes.doc.d.mts +1 -5
  75. package/api/theme/listThemes.doc.mjs +6 -13
  76. package/api/theme/targets/targets.test.mjs +22 -8
  77. package/api/theme/theme.d.mts +1 -1
  78. package/api/theme/theme.mjs +1 -1
  79. package/api/theme/theme.type.d.mts +9 -0
  80. package/api/theme/theme.type.mjs +3 -1
  81. package/api/theme/themeAdd.doc.d.mts +1 -4
  82. package/api/theme/themeAdd.doc.mjs +31 -31
  83. package/api/theme/themeBuild.doc.mjs +1 -1
  84. package/api/theme/themeList.doc.d.mts +1 -4
  85. package/api/theme/themeList.doc.mjs +7 -15
  86. package/api/theme/themeListAvailable.doc.d.mts +8 -0
  87. package/api/theme/themeListAvailable.doc.mjs +57 -0
  88. package/api/theme/themeTargets.doc.mjs +21 -7
  89. package/api/upgrade/_adapter.d.mts +2 -0
  90. package/api/upgrade/_adapter.mjs +1 -0
  91. package/api/upgrade/registry/registry.d.mts +40 -0
  92. package/api/upgrade/registry/registry.mjs +1154 -0
  93. package/api/upgrade/registry/registry.test.mjs +826 -0
  94. package/api/upgrade/run/run.mjs +49 -8
  95. package/api/upgrade/status/status.d.mts +6 -4
  96. package/api/upgrade/status/status.mjs +26 -8
  97. package/api/upgrade/upgrade.d.mts +2 -2
  98. package/api/upgrade/upgrade.doc.mjs +33 -9
  99. package/api/upgrade/upgrade.mjs +34 -7
  100. package/api/upgrade/upgrade.test.mjs +198 -8
  101. package/api/upgrade/upgrade.type.d.mts +90 -1
  102. package/api/upgrade/upgrade.type.mjs +51 -2
  103. package/assets/docs/cli-integrations.doc.mjs +152 -28
  104. package/assets/docs/getting-started.doc.mjs +1 -1
  105. package/assets/docs/{shadcn-compatibility.doc.mjs → shadcn-compatibility.doc.draft.mjs} +23 -13
  106. package/assets/docs/styling.doc.mjs +3 -3
  107. package/assets/docs/theme.doc.dense.mjs +2 -2
  108. package/assets/docs/theme.doc.mjs +23 -13
  109. package/assets/docs/theme.doc.zh.mjs +1 -1
  110. package/assets/templates/blocks/components/BaseTypeahead/BaseTypeaheadCustomSearch.doc.mjs +2 -1
  111. package/assets/templates/blocks/components/BaseTypeahead/BaseTypeaheadCustomSearch.tsx +38 -12
  112. package/assets/templates/blocks/components/BaseTypeahead/BaseTypeaheadShowcase.doc.mjs +15 -0
  113. package/assets/templates/blocks/components/BaseTypeahead/BaseTypeaheadShowcase.tsx +87 -0
  114. package/assets/templates/blocks/components/BottomSheet/BottomSheetSwitcherReviewFlow.doc.mjs +23 -0
  115. package/assets/templates/blocks/components/BottomSheet/BottomSheetSwitcherReviewFlow.tsx +75 -0
  116. package/assets/templates/blocks/components/BreadcrumbItem/BreadcrumbItemShowcase.tsx +5 -19
  117. package/assets/templates/blocks/components/Center/CenterHorizontal.doc.mjs +3 -2
  118. package/assets/templates/blocks/components/Center/CenterHorizontal.tsx +4 -5
  119. package/assets/templates/blocks/components/Toast/ToastAction.tsx +2 -1
  120. package/assets/templates/blocks/components/Toast/ToastDeduplication.tsx +2 -1
  121. package/assets/templates/blocks/components/Toast/ToastDismiss.tsx +2 -1
  122. package/assets/templates/blocks/components/Toast/ToastShowcase.tsx +2 -1
  123. package/assets/templates/blocks/components/Toast/ToastStacking.tsx +2 -1
  124. package/assets/templates/blocks/components/Toast/ToastTypes.tsx +2 -1
  125. package/assets/templates/pages/dashboard/template.doc.mjs +2 -2
  126. package/assets/templates/pages/dashboard-alert-rail/template.doc.mjs +3 -2
  127. package/assets/templates/pages/dashboard-cohort-funnel/template.doc.mjs +3 -2
  128. package/assets/templates/pages/dashboard-comparison/template.doc.mjs +3 -3
  129. package/assets/templates/pages/dashboard-composition/template.doc.mjs +2 -2
  130. package/assets/templates/pages/dashboard-progress/template.doc.mjs +2 -2
  131. package/assets/templates/pages/dashboard-scorecard/template.doc.mjs +2 -2
  132. package/assets/templates/themes/butter/butterTheme.ts +3 -3
  133. package/assets/templates/themes/neutral/neutralTheme.ts +2 -2
  134. package/assets/templates/themes/stone/stoneTheme.ts +3 -3
  135. package/assets/theme.template.ts +4 -7
  136. package/authoring/config/config.doc.mjs +9 -1
  137. package/authoring/config/parse.d.mts +2 -0
  138. package/authoring/config/parse.mjs +28 -3
  139. package/authoring/config/parse.test.mjs +25 -3
  140. package/authoring/config/type.ts +3 -0
  141. package/authoring/doctypes/_schema.d.mts +3 -0
  142. package/authoring/doctypes/_schema.mjs +6 -1
  143. package/authoring/doctypes/base/type.ts +6 -6
  144. package/authoring/doctypes/component/component.doc.mjs +6 -0
  145. package/authoring/doctypes/component/type.ts +2 -0
  146. package/authoring/gap-report/parse.d.mts +63 -0
  147. package/authoring/gap-report/parse.mjs +121 -0
  148. package/authoring/gap-report/parse.test.mjs +172 -0
  149. package/authoring/gap-report/type.ts +107 -0
  150. package/authoring/index.d.mts +1 -0
  151. package/authoring/index.d.ts +12 -0
  152. package/authoring/index.mjs +4 -0
  153. package/authoring/integration/integration.doc.mjs +14 -2
  154. package/authoring/integration/parse.test.mjs +9 -4
  155. package/authoring/integration/schema.d.mts +2 -0
  156. package/authoring/integration/schema.mjs +1 -0
  157. package/authoring/integration/type.ts +23 -6
  158. package/authoring/shadcn/receipt.d.mts +219 -0
  159. package/authoring/shadcn/receipt.mjs +248 -0
  160. package/authoring/shadcn/receipt.test.mjs +187 -0
  161. package/authoring/shadcn/source-variants.d.mts +28 -0
  162. package/authoring/shadcn/source-variants.mjs +176 -0
  163. package/authoring/shadcn/source-variants.test.mjs +120 -0
  164. package/clients/cli/commands/build-theme.mjs +54 -19
  165. package/clients/cli/commands/build-theme.variants.test.mjs +15 -12
  166. package/clients/cli/commands/component/index.mjs +1 -1
  167. package/clients/cli/commands/docs.test.mjs +1 -0
  168. package/clients/cli/commands/doctor-integration.doc.mjs +1 -1
  169. package/clients/cli/commands/gap-report.doc.mjs +73 -0
  170. package/clients/cli/commands/gap-report.mjs +114 -0
  171. package/clients/cli/commands/gap-report.test.mjs +198 -0
  172. package/clients/cli/commands/import-hint-correctness.test.mjs +88 -0
  173. package/clients/cli/commands/integration-add.doc.mjs +88 -0
  174. package/clients/cli/commands/integration-authoring.test.mjs +177 -0
  175. package/clients/cli/commands/integration-pack.doc.mjs +34 -0
  176. package/clients/cli/commands/integration-real-world.test.mjs +618 -0
  177. package/clients/cli/commands/integration.doc.mjs +28 -0
  178. package/clients/cli/commands/integration.mjs +153 -0
  179. package/clients/cli/commands/theme-add.doc.mjs +11 -6
  180. package/clients/cli/commands/theme-list.doc.mjs +21 -5
  181. package/clients/cli/commands/theme-targets.behavior.test.mjs +19 -2
  182. package/clients/cli/commands/theme.doc.mjs +2 -2
  183. package/clients/cli/commands/upgrade.doc.mjs +17 -4
  184. package/clients/cli/commands/upgrade.mjs +12 -1
  185. package/clients/cli/commands/upgrade.test.mjs +41 -0
  186. package/clients/cli/index.mjs +5 -0
  187. package/clients/cli/lib/component-format.mjs +42 -26
  188. package/clients/cli/lib/component-format.test.mjs +34 -3
  189. package/clients/cli/lib/manifest.mjs +12 -0
  190. package/foundation/config/project-themes.test.mjs +127 -0
  191. package/foundation/config/project.d.mts +23 -4
  192. package/foundation/config/project.mjs +96 -9
  193. package/foundation/config/project.test.mjs +132 -6
  194. package/foundation/discovery/component-discovery.d.mts +36 -0
  195. package/foundation/discovery/component-discovery.mjs +96 -0
  196. package/foundation/discovery/theme-discovery.d.mts +39 -0
  197. package/foundation/discovery/theme-discovery.mjs +650 -0
  198. package/foundation/discovery/theme-discovery.test.mjs +375 -0
  199. package/foundation/discovery/theming-targets.d.mts +16 -0
  200. package/foundation/discovery/theming-targets.mjs +39 -3
  201. package/foundation/discovery/theming-targets.test.mjs +139 -0
  202. package/foundation/integrations/autolink.d.mts +96 -0
  203. package/foundation/integrations/autolink.mjs +265 -0
  204. package/foundation/integrations/autolink.test.mjs +430 -0
  205. package/foundation/integrations/contribution-inventory.d.mts +152 -0
  206. package/foundation/integrations/contribution-inventory.mjs +497 -0
  207. package/foundation/integrations/contribution-inventory.test.mjs +361 -0
  208. package/foundation/integrations/integrations.d.mts +73 -9
  209. package/foundation/integrations/integrations.mjs +158 -8
  210. package/foundation/integrations/integrations.test.mjs +152 -29
  211. package/foundation/integrations/manifest-writer.d.mts +56 -0
  212. package/foundation/integrations/manifest-writer.mjs +328 -0
  213. package/foundation/integrations/manifest-writer.test.mjs +229 -0
  214. package/foundation/integrations/validate-contributions.mjs +81 -6
  215. package/foundation/response/error-codes.d.mts +4 -1
  216. package/foundation/response/error-codes.doc.mjs +16 -1
  217. package/foundation/response/error-codes.mjs +10 -1
  218. package/foundation/response/response-types.doc.mjs +23 -2
  219. package/package.json +8 -1
@@ -0,0 +1,318 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file The import specifier an integration component is reported under has to
5
+ * be the SAME at every surface, and it has to resolve.
6
+ *
7
+ * `component` reports it as ownership metadata and `search` reports it on every
8
+ * hit. Each used to resolve it independently, and they disagreed: `component`
9
+ * honored a doc-authored `import` and otherwise derived the subpath from the
10
+ * doc's directory against the owning package's `exports`, while `search` handed
11
+ * back the bare package name — a specifier that does not resolve for a package
12
+ * whose components live behind subpaths. An agent that searched and then
13
+ * imported what it was told got a broken file.
14
+ *
15
+ * The two now share one resolver and one precedence rule, so the agreement is
16
+ * structural. These tests pin the property rather than the implementation: ask
17
+ * both surfaces about the same component and require the same answer, across
18
+ * every shape a real package's `exports` takes.
19
+ *
20
+ * Fixtures live under a repo-local temp dir, not /tmp, because Vite refuses to
21
+ * dynamically import a module from outside the project root.
22
+ */
23
+
24
+ import {afterEach, beforeEach, describe, expect, it} from 'vitest';
25
+ import * as fs from 'node:fs';
26
+ import * as path from 'node:path';
27
+ import {component} from './component.mjs';
28
+ import {search} from '../search/search.mjs';
29
+ import {resolveIntegrationImportPath} from '../../foundation/discovery/component-discovery.mjs';
30
+
31
+ const SLOW = 30_000;
32
+
33
+ let tmpDir;
34
+
35
+ /**
36
+ * A consumer project with one configured integration that ships a single
37
+ * component, `AcmeCarousel`, in a directory named after the concept rather
38
+ * than after the component — the shape real packages use when one entry point
39
+ * exports several components, and the case the bare-package answer got wrong.
40
+ *
41
+ * @param {object} [options]
42
+ * @param {Record<string, string>} [options.exports] the owning package's
43
+ * `exports` map; omit it for a package that publishes no subpaths.
44
+ * @param {string} [options.docImport] an `import` the component's doc states
45
+ * for itself, which is canonical and must win over any resolved subpath.
46
+ */
47
+ function scaffold({exports: exportsMap, docImport} = {}) {
48
+ fs.writeFileSync(
49
+ path.join(tmpDir, 'package.json'),
50
+ JSON.stringify({name: 'consumer', version: '1.0.0'}),
51
+ );
52
+ fs.writeFileSync(
53
+ path.join(tmpDir, 'astryx.config.mjs'),
54
+ "export default {integrations: ['@acme/widgets']};\n",
55
+ );
56
+
57
+ const pkgDir = path.join(tmpDir, 'node_modules', '@acme', 'widgets');
58
+ const componentDir = path.join(pkgDir, 'src', 'Carousel');
59
+ fs.mkdirSync(componentDir, {recursive: true});
60
+
61
+ fs.writeFileSync(
62
+ path.join(pkgDir, 'package.json'),
63
+ JSON.stringify({
64
+ name: '@acme/widgets',
65
+ version: '1.0.0',
66
+ ...(exportsMap ? {exports: exportsMap} : {}),
67
+ }),
68
+ );
69
+ fs.writeFileSync(
70
+ path.join(pkgDir, 'astryx.integration.mjs'),
71
+ "export default {components: './src'};\n",
72
+ );
73
+ fs.writeFileSync(
74
+ path.join(componentDir, 'AcmeCarousel.tsx'),
75
+ 'export const AcmeCarousel = () => null;\n',
76
+ );
77
+ fs.writeFileSync(
78
+ path.join(componentDir, 'AcmeCarousel.doc.mjs'),
79
+ `export const docs = ${JSON.stringify(
80
+ {
81
+ type: 'component',
82
+ name: 'AcmeCarousel',
83
+ displayName: 'Acme Carousel',
84
+ keywords: ['carousel', 'slides'],
85
+ usage: {description: 'A carousel that cycles through slides.'},
86
+ props: [],
87
+ ...(docImport ? {import: docImport} : {}),
88
+ },
89
+ null,
90
+ 2,
91
+ )};\n`,
92
+ );
93
+ }
94
+
95
+ /** The import `search` reports for a named component, or null. */
96
+ function searchImportFor(result, name) {
97
+ for (const group of Object.values(result.data ?? {})) {
98
+ if (!Array.isArray(group)) continue;
99
+ const hit = group.find(entry => entry?.name === name);
100
+ if (hit) return hit.import ?? null;
101
+ }
102
+ return null;
103
+ }
104
+
105
+ /** Both surfaces' answer for AcmeCarousel, as `{detail, found}`. */
106
+ async function bothSurfaces() {
107
+ const detail = await component('AcmeCarousel', {cwd: tmpDir});
108
+ const found = await search('carousel', {cwd: tmpDir});
109
+ return {detail: detail.data.import, found: searchImportFor(found, 'AcmeCarousel')};
110
+ }
111
+
112
+ const SUBPATH_EXPORTS = {
113
+ '.': './src/index.js',
114
+ './Carousel': './src/Carousel/index.js',
115
+ };
116
+
117
+ beforeEach(() => {
118
+ tmpDir = fs.mkdtempSync(path.join(process.cwd(), '.astryx-import-agreement-test-'));
119
+ });
120
+
121
+ afterEach(() => {
122
+ fs.rmSync(tmpDir, {recursive: true, force: true});
123
+ });
124
+
125
+ describe('integration component import specifiers', () => {
126
+ it(
127
+ 'component and search report the same import for the same component',
128
+ async () => {
129
+ scaffold({exports: SUBPATH_EXPORTS});
130
+ const {detail, found} = await bothSurfaces();
131
+
132
+ expect(detail).toBe('@acme/widgets/Carousel');
133
+ expect(found).toBe(detail);
134
+ },
135
+ SLOW,
136
+ );
137
+
138
+ it(
139
+ 'neither surface reports the bare package when a subpath is exported',
140
+ async () => {
141
+ scaffold({exports: SUBPATH_EXPORTS});
142
+ const {detail, found} = await bothSurfaces();
143
+
144
+ expect(detail).not.toBe('@acme/widgets');
145
+ expect(found).not.toBe('@acme/widgets');
146
+ },
147
+ SLOW,
148
+ );
149
+
150
+ it(
151
+ 'both fall back to the package root when it exports no matching subpath',
152
+ async () => {
153
+ scaffold();
154
+ const {detail, found} = await bothSurfaces();
155
+
156
+ // The bare package is the honest answer here: it is what a consumer
157
+ // would have to write by hand. What matters is that both agree on it.
158
+ expect(detail).toBe('@acme/widgets');
159
+ expect(found).toBe('@acme/widgets');
160
+ },
161
+ SLOW,
162
+ );
163
+
164
+ it(
165
+ 'a doc-authored import wins at both surfaces, over any resolved subpath',
166
+ async () => {
167
+ // The alias case: the package canonically publishes this component under
168
+ // a name that is not its directory, and says so in its doc. Resolving the
169
+ // directory would produce `/Carousel`, which is why the two surfaces have
170
+ // to share the precedence rule and not just the resolver.
171
+ scaffold({exports: SUBPATH_EXPORTS, docImport: '@acme/widgets/Alias'});
172
+ const {detail, found} = await bothSurfaces();
173
+
174
+ expect(detail).toBe('@acme/widgets/Alias');
175
+ expect(found).toBe(detail);
176
+ },
177
+ SLOW,
178
+ );
179
+
180
+ it(
181
+ 'a doc-authored import is honored even with no exports map at all',
182
+ async () => {
183
+ scaffold({docImport: '@acme/widgets/Alias'});
184
+ const {detail, found} = await bothSurfaces();
185
+
186
+ expect(detail).toBe('@acme/widgets/Alias');
187
+ expect(found).toBe(detail);
188
+ },
189
+ SLOW,
190
+ );
191
+
192
+ it(
193
+ 'a wildcard exports map resolves to the exported subpath at both surfaces',
194
+ async () => {
195
+ // `./*` publishes `./Carousel` exactly as a literal key would, so the
196
+ // subpath is the correct answer. An earlier version of this test asserted
197
+ // only that the two surfaces AGREED, and both agreed on the bare package
198
+ // — a specifier that need not resolve at all here, since this package
199
+ // publishes no `.` export. Agreement is necessary and not sufficient.
200
+ scaffold({exports: {'./*': './src/*/index.js'}});
201
+ const {detail, found} = await bothSurfaces();
202
+
203
+ expect(detail).toBe('@acme/widgets/Carousel');
204
+ expect(found).toBe(detail);
205
+ },
206
+ SLOW,
207
+ );
208
+
209
+ it(
210
+ 'a wildcard whose target is null does not publish the subpath',
211
+ async () => {
212
+ // `null` blocks a subpath rather than publishing it, so the honest answer
213
+ // is the package root at both surfaces.
214
+ scaffold({exports: {'.': './src/index.js', './*': null}});
215
+ const {detail, found} = await bothSurfaces();
216
+
217
+ expect(detail).toBe('@acme/widgets');
218
+ expect(found).toBe(detail);
219
+ },
220
+ SLOW,
221
+ );
222
+
223
+ it(
224
+ 'a prefixed wildcard only matches the subpaths it covers',
225
+ async () => {
226
+ // `./components/*` does not cover `./Carousel`, so this falls back.
227
+ scaffold({exports: {'.': './src/index.js', './components/*': './src/*/index.js'}});
228
+ const {detail, found} = await bothSurfaces();
229
+
230
+ expect(detail).toBe('@acme/widgets');
231
+ expect(found).toBe(detail);
232
+ },
233
+ SLOW,
234
+ );
235
+
236
+ it(
237
+ 'an exact key still wins where a wildcard would also match',
238
+ async () => {
239
+ scaffold({
240
+ exports: {
241
+ '.': './src/index.js',
242
+ './Carousel': './src/Carousel/index.js',
243
+ './*': './src/*/index.js',
244
+ },
245
+ });
246
+ const {detail, found} = await bothSurfaces();
247
+
248
+ expect(detail).toBe('@acme/widgets/Carousel');
249
+ expect(found).toBe(detail);
250
+ },
251
+ SLOW,
252
+ );
253
+
254
+ it(
255
+ 'one matching pattern among several is enough',
256
+ async () => {
257
+ scaffold({
258
+ exports: {
259
+ '.': './src/index.js',
260
+ './blocks/*': './src/blocks/*.js',
261
+ './*': './src/*/index.js',
262
+ './themes/*': './themes/*.css',
263
+ },
264
+ });
265
+ const {detail, found} = await bothSurfaces();
266
+
267
+ expect(detail).toBe('@acme/widgets/Carousel');
268
+ expect(found).toBe(detail);
269
+ },
270
+ SLOW,
271
+ );
272
+
273
+ it(
274
+ 'a conditional export object still counts as published',
275
+ async () => {
276
+ // The target may be a conditions object rather than a string; what
277
+ // matters for a specifier is that the subpath is published at all.
278
+ scaffold({
279
+ exports: {
280
+ '.': './src/index.js',
281
+ './Carousel': {import: './src/Carousel/index.js', require: './cjs/Carousel.js'},
282
+ },
283
+ });
284
+ const {detail, found} = await bothSurfaces();
285
+
286
+ expect(detail).toBe('@acme/widgets/Carousel');
287
+ expect(found).toBe(detail);
288
+ },
289
+ SLOW,
290
+ );
291
+
292
+ it('resolves from disk for a record that carries no parsed exports map', () => {
293
+ // `loadIntegrations` parses the map onto every integration it loads, but a
294
+ // record built by hand — as several tests and callers do — has no such
295
+ // field. Resolution must read the manifest rather than quietly reporting
296
+ // the bare package, because a silent degradation is how the original bug
297
+ // reached users. `undefined` means "nobody parsed it"; `null` means the
298
+ // loader looked and there was none.
299
+ scaffold({exports: SUBPATH_EXPORTS});
300
+ const pkgDir = path.join(tmpDir, 'node_modules', '@acme', 'widgets');
301
+ const docPath = path.join(pkgDir, 'src', 'Carousel', 'AcmeCarousel.doc.mjs');
302
+
303
+ expect(
304
+ resolveIntegrationImportPath(
305
+ {packageDir: pkgDir, docPath, packageName: '@acme/widgets'},
306
+ 'AcmeCarousel',
307
+ ),
308
+ ).toBe('@acme/widgets/Carousel');
309
+
310
+ // A parsed `null` is an answer, not a gap: it must not fall back to a read.
311
+ expect(
312
+ resolveIntegrationImportPath(
313
+ {exportsMap: null, packageDir: pkgDir, docPath, packageName: '@acme/widgets'},
314
+ 'AcmeCarousel',
315
+ ),
316
+ ).toBe('@acme/widgets');
317
+ });
318
+ });
@@ -32,19 +32,43 @@ export function checkThemes(ctx: DoctorContext): DoctorCheck;
32
32
  */
33
33
  export function checkConfig(ctx: DoctorContext): Promise<DoctorCheck>;
34
34
  /**
35
- * Check 6 — agent docs exist and contain the Astryx section markers.
35
+ * Check 6 — integrations that are loaded without an astryx.config entry.
36
+ *
37
+ * The CLI autolinks an installed dependency that ships an
38
+ * `astryx.integration.*` manifest, so a project can be getting components,
39
+ * templates, themes, docs and codemods from a package nothing in the project mentions.
40
+ * Two questions follow, and this line is the answer to both:
41
+ *
42
+ * - "Why can the CLI see this?" — asked by an author who greps the project
43
+ * for the package name and finds nothing. Reading our source should not be
44
+ * part of that answer.
45
+ * - "Can I delete this dependency?" — asked by an unused-dependency sweep,
46
+ * which decides by looking for source imports. In exactly this population
47
+ * there are none: the manifest is the whole link. Naming the dependency
48
+ * here marks it load-bearing.
49
+ *
50
+ * Always informational. Doctor is a CI gate, and a project that acquired an
51
+ * integration correctly has done nothing to warn about — the point is to say
52
+ * what is loaded, never to push anyone into writing a config entry.
53
+ *
54
+ * @param {DoctorContext} ctx
55
+ * @returns {DoctorCheck}
56
+ */
57
+ export function checkImplicitIntegrations(ctx: DoctorContext): DoctorCheck;
58
+ /**
59
+ * Check 7 — agent docs exist and contain the Astryx section markers.
36
60
  * @param {DoctorContext} ctx
37
61
  * @returns {DoctorCheck}
38
62
  */
39
63
  export function checkAgentDocs(ctx: DoctorContext): DoctorCheck;
40
64
  /**
41
- * Check 7 — @astryxdesign/core peer dependencies are satisfied by installed packages.
65
+ * Check 8 — @astryxdesign/core peer dependencies are satisfied by installed packages.
42
66
  * @param {DoctorContext} ctx
43
67
  * @returns {DoctorCheck}
44
68
  */
45
69
  export function checkPeerDeps(ctx: DoctorContext): DoctorCheck;
46
70
  /**
47
- * Check 8 — report the detected package manager, and say so when the project's
71
+ * Check 9 — report the detected package manager, and say so when the project's
48
72
  * own declaration disagrees with what is on disk.
49
73
  *
50
74
  * Two states are worth surfacing rather than guessing past, because in both the
@@ -140,6 +164,11 @@ export type DoctorContext = {
140
164
  * - theme value read from config, or null.
141
165
  */
142
166
  configTheme: string | null;
167
+ /**
168
+ * Every integration the project loaded, or null when the project could not be
169
+ * read at all.
170
+ */
171
+ integrations?: import("../../foundation/integrations/integrations.mjs").LoadedIntegration[] | null | undefined;
143
172
  /**
144
173
  * - Error thrown while resolving the config
145
174
  * path (e.g. multiple config files present), surfaced by checkConfig as a FAIL.
@@ -16,7 +16,8 @@ export const doc = {
16
16
  description:
17
17
  'Runs a series of side-effect-free diagnostics: Node version, ' +
18
18
  '@astryxdesign/core install and version alignment with the CLI, installed ' +
19
- 'themes and wiring, astryx.config validity, agent docs, core peer ' +
19
+ 'themes and wiring, astryx.config validity, integrations linked from ' +
20
+ 'package.json without a config entry, agent docs, core peer ' +
20
21
  'dependencies, and the detected package manager, and returns a structured ' +
21
22
  'report. It only reads (never installs, writes, or mutates), so it is safe ' +
22
23
  'as a CI gate and for agents to invoke.',
@@ -52,6 +52,9 @@ const _require = createRequire(import.meta.url);
52
52
  * @property {string|null} coreDir - Resolved core package directory, or null.
53
53
  * @property {string|null} configPath - Resolved astryx.config.mjs path, or null.
54
54
  * @property {string|null} configTheme - theme value read from config, or null.
55
+ * @property {import('../../foundation/integrations/integrations.mjs').LoadedIntegration[]|null} [integrations]
56
+ * Every integration the project loaded, or null when the project could not be
57
+ * read at all.
55
58
  * @property {Error|null} [configError] - Error thrown while resolving the config
56
59
  * path (e.g. multiple config files present), surfaced by checkConfig as a FAIL.
57
60
  */
@@ -354,7 +357,91 @@ export async function checkConfig(ctx) {
354
357
  }
355
358
 
356
359
  /**
357
- * Check 6 — agent docs exist and contain the Astryx section markers.
360
+ * Check 6 — integrations that are loaded without an astryx.config entry.
361
+ *
362
+ * The CLI autolinks an installed dependency that ships an
363
+ * `astryx.integration.*` manifest, so a project can be getting components,
364
+ * templates, themes, docs and codemods from a package nothing in the project mentions.
365
+ * Two questions follow, and this line is the answer to both:
366
+ *
367
+ * - "Why can the CLI see this?" — asked by an author who greps the project
368
+ * for the package name and finds nothing. Reading our source should not be
369
+ * part of that answer.
370
+ * - "Can I delete this dependency?" — asked by an unused-dependency sweep,
371
+ * which decides by looking for source imports. In exactly this population
372
+ * there are none: the manifest is the whole link. Naming the dependency
373
+ * here marks it load-bearing.
374
+ *
375
+ * Always informational. Doctor is a CI gate, and a project that acquired an
376
+ * integration correctly has done nothing to warn about — the point is to say
377
+ * what is loaded, never to push anyone into writing a config entry.
378
+ *
379
+ * @param {DoctorContext} ctx
380
+ * @returns {DoctorCheck}
381
+ */
382
+ export function checkImplicitIntegrations(ctx) {
383
+ const id = 'implicit-integrations';
384
+ const label = 'Implicitly linked integrations';
385
+
386
+ if (ctx.integrations == null) {
387
+ return {
388
+ id,
389
+ label,
390
+ status: 'info',
391
+ message: 'Skipped — the project configuration could not be read.',
392
+ };
393
+ }
394
+
395
+ const implicit = ctx.integrations.filter(
396
+ integration => integration.__autolinked,
397
+ );
398
+
399
+ if (implicit.length === 0) {
400
+ return {
401
+ id,
402
+ label,
403
+ status: 'info',
404
+ message:
405
+ ctx.integrations.length > 0
406
+ ? 'None — every loaded integration is named in astryx.config.'
407
+ : 'None — no installed dependency ships an astryx.integration.* manifest.',
408
+ };
409
+ }
410
+
411
+ const described = implicit.map(integration => {
412
+ const version = integration.version ? `@${integration.version}` : '';
413
+ // An npm alias installs a package under a different key. The package's own
414
+ // name is its identity; the KEY is what package.json says and what a
415
+ // dependency sweep reads, so when they differ both have to be here.
416
+ const alias =
417
+ integration.__spec && integration.__spec !== integration.name
418
+ ? ` (declared as "${integration.__spec}")`
419
+ : '';
420
+ const roots = ['components', 'templates', 'themes', 'docs', 'codemods'].filter(
421
+ root => integration[/** @type {'components'} */ (root)],
422
+ );
423
+ const contributes = roots.length > 0 ? roots.join(', ') : 'nothing';
424
+ return `${integration.name}${version}${alias} from ${integration.__dependencyField}, contributing ${contributes}`;
425
+ });
426
+
427
+ const plural = implicit.length === 1 ? '' : 's';
428
+ return {
429
+ id,
430
+ label,
431
+ status: 'info',
432
+ message:
433
+ `${implicit.length} integration${plural} loaded from installed ` +
434
+ `dependencies with no astryx.config entry: ${described.join('; ')}.`,
435
+ fix:
436
+ 'Nothing to fix. Keep these dependencies installed. The CLI links them ' +
437
+ 'from package.json, so an unused-dependency check that looks only for ' +
438
+ 'source imports will report them as unused. Add them to `integrations` ' +
439
+ 'in astryx.config.* to make the link explicit.',
440
+ };
441
+ }
442
+
443
+ /**
444
+ * Check 7 — agent docs exist and contain the Astryx section markers.
358
445
  * @param {DoctorContext} ctx
359
446
  * @returns {DoctorCheck}
360
447
  */
@@ -408,7 +495,7 @@ export function checkAgentDocs(ctx) {
408
495
  }
409
496
 
410
497
  /**
411
- * Check 7 — @astryxdesign/core peer dependencies are satisfied by installed packages.
498
+ * Check 8 — @astryxdesign/core peer dependencies are satisfied by installed packages.
412
499
  * @param {DoctorContext} ctx
413
500
  * @returns {DoctorCheck}
414
501
  */
@@ -495,7 +582,7 @@ export function checkPeerDeps(ctx) {
495
582
  }
496
583
 
497
584
  /**
498
- * Check 8 — report the detected package manager, and say so when the project's
585
+ * Check 9 — report the detected package manager, and say so when the project's
499
586
  * own declaration disagrees with what is on disk.
500
587
  *
501
588
  * Two states are worth surfacing rather than guessing past, because in both the
@@ -561,6 +648,7 @@ export const SYNC_CHECKS = [
561
648
  checkCoreInstalled,
562
649
  checkVersionAlignment,
563
650
  checkThemes,
651
+ checkImplicitIntegrations,
564
652
  checkAgentDocs,
565
653
  checkPeerDeps,
566
654
  checkPackageManager,
@@ -587,12 +675,16 @@ export async function runChecks(options = {}) {
587
675
  configError = /** @type {Error} */ (err);
588
676
  }
589
677
 
590
- // Resolve a possible theme key from config (best-effort; never throws).
678
+ // Resolve a possible theme key from config, and the integrations the project
679
+ // actually loaded (best-effort; never throws).
591
680
  let configTheme = null;
681
+ /** @type {import('../../foundation/integrations/integrations.mjs').LoadedIntegration[]|null} */
682
+ let integrations = null;
592
683
  try {
593
684
  const project = await Project.load(cwd);
594
685
  configTheme =
595
686
  /** @type {{theme?: string}} */ (project.config ?? {}).theme ?? null;
687
+ integrations = project.loadedIntegrations;
596
688
  } catch {
597
689
  // Best-effort: a missing/invalid config leaves configTheme null.
598
690
  }
@@ -604,6 +696,7 @@ export async function runChecks(options = {}) {
604
696
  coreDir,
605
697
  configPath,
606
698
  configTheme,
699
+ integrations,
607
700
  configError,
608
701
  };
609
702
 
@@ -11,7 +11,12 @@ import * as fs from 'node:fs';
11
11
  import * as os from 'node:os';
12
12
  import * as path from 'node:path';
13
13
  import {fileURLToPath} from 'node:url';
14
- import {doctor, checkVersionAlignment, checkPackageManager} from './doctor.mjs';
14
+ import {
15
+ doctor,
16
+ checkImplicitIntegrations,
17
+ checkVersionAlignment,
18
+ checkPackageManager,
19
+ } from './doctor.mjs';
15
20
 
16
21
  const REPO = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../../..');
17
22
  const cwd = REPO;
@@ -208,3 +213,87 @@ describe('checkPackageManager', () => {
208
213
  expect(c.message).toContain('yarn.lock');
209
214
  });
210
215
  });
216
+
217
+ describe('checkImplicitIntegrations', () => {
218
+ /** @param {object} [fields] */
219
+ const autolinked = (fields = {}) => ({
220
+ name: '@acme/widgets',
221
+ version: '1.0.0',
222
+ components: '/abs/components',
223
+ __spec: '@acme/widgets',
224
+ __autolinked: true,
225
+ __dependencyField: 'dependencies',
226
+ ...fields,
227
+ });
228
+
229
+ it('skips when the project could not be read', () => {
230
+ const c = checkImplicitIntegrations({integrations: null});
231
+ expect(c.status).toBe('info');
232
+ expect(c.message).toContain('Skipped');
233
+ });
234
+
235
+ it('reports none when nothing is installed', () => {
236
+ const c = checkImplicitIntegrations({integrations: []});
237
+ expect(c.status).toBe('info');
238
+ expect(c.message).toContain('no installed dependency');
239
+ expect(c.fix).toBeUndefined();
240
+ });
241
+
242
+ it('reports none when every loaded integration is configured', () => {
243
+ const c = checkImplicitIntegrations({
244
+ integrations: [autolinked({__autolinked: false})],
245
+ });
246
+ expect(c.status).toBe('info');
247
+ expect(c.message).toContain('named in astryx.config');
248
+ });
249
+
250
+ it('names the package, the field, and what it contributes', () => {
251
+ const c = checkImplicitIntegrations({
252
+ integrations: [
253
+ autolinked({templates: '/abs/templates', themes: '/abs/themes'}),
254
+ ],
255
+ });
256
+ expect(c.message).toContain('@acme/widgets@1.0.0');
257
+ expect(c.message).toContain('from dependencies');
258
+ expect(c.message).toContain(
259
+ 'contributing components, templates, themes',
260
+ );
261
+ });
262
+
263
+ it('names the declared key too when an npm alias makes them differ', () => {
264
+ const c = checkImplicitIntegrations({
265
+ integrations: [
266
+ autolinked({
267
+ name: '@acme/ui',
268
+ version: '0.1.22',
269
+ __spec: '@acme/legacy-ui',
270
+ }),
271
+ ],
272
+ });
273
+ expect(c.message).toContain('@acme/ui@0.1.22');
274
+ expect(c.message).toContain('declared as "@acme/legacy-ui"');
275
+ });
276
+
277
+ it('marks the dependency load-bearing for an unused-dependency check', () => {
278
+ const c = checkImplicitIntegrations({integrations: [autolinked()]});
279
+ expect(c.fix).toContain('unused-dependency check');
280
+ expect(c.fix).toContain('astryx.config');
281
+ });
282
+
283
+ it('is always informational, so the CI gate stays green', () => {
284
+ for (const integrations of [
285
+ null,
286
+ [],
287
+ [autolinked()],
288
+ [autolinked({components: undefined})],
289
+ [autolinked({__autolinked: false})],
290
+ ]) {
291
+ expect(checkImplicitIntegrations({integrations}).status).toBe('info');
292
+ }
293
+ });
294
+
295
+ it('is part of the report doctor returns', async () => {
296
+ const r = await doctor({cwd});
297
+ expect(r.data.checks.map(c => c.id)).toContain('implicit-integrations');
298
+ }, SLOW);
299
+ });
@@ -0,0 +1,4 @@
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
+ export {};