@astryxdesign/cli 0.6.3-canary.db4e378 → 0.6.3-canary.ddb63c3

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 (236) hide show
  1. package/README.md +20 -1
  2. package/api/blog/blog.doc.mjs +1 -0
  3. package/api/build/build.doc.mjs +1 -0
  4. package/api/component/component.doc.mjs +1 -0
  5. package/api/discover/discover.doc.mjs +1 -0
  6. package/api/docs/_adapter.d.mts +3 -8
  7. package/api/docs/_adapter.mjs +13 -105
  8. package/api/docs/docs.doc.mjs +1 -0
  9. package/api/docs/list/list.mjs +3 -7
  10. package/api/doctor/doctor.d.mts +25 -3
  11. package/api/doctor/doctor.doc.mjs +1 -0
  12. package/api/doctor/doctor.mjs +185 -13
  13. package/api/doctor/doctor.test.mjs +326 -1
  14. package/api/gap-report/gap-report.doc.mjs +1 -0
  15. package/api/hook/_adapter.mjs +19 -5
  16. package/api/hook/hook.doc.mjs +1 -0
  17. package/api/hook/list/list.d.mts +1 -1
  18. package/api/hook/list/list.mjs +69 -17
  19. package/api/init/init.doc.mjs +1 -0
  20. package/api/integration/add-contribution.mjs +7 -7
  21. package/api/integration/add-contribution.test.mjs +37 -3
  22. package/api/integration/add-theme.mjs +34 -64
  23. package/api/integration/add-theme.test.mjs +105 -21
  24. package/api/integration/authoring-checks.test.mjs +8 -4
  25. package/api/integration/integration-block-exports.test.mjs +10 -6
  26. package/api/integration/integrationAdd.doc.mjs +1 -0
  27. package/api/integration/integrationAddAgentDoc.doc.mjs +1 -0
  28. package/api/integration/integrationAddCodemod.doc.mjs +1 -0
  29. package/api/integration/integrationAddComponent.doc.mjs +1 -0
  30. package/api/integration/integrationAddDoc.doc.mjs +1 -0
  31. package/api/integration/integrationAddTemplate.doc.mjs +1 -0
  32. package/api/integration/integrationAddTheme.doc.mjs +6 -5
  33. package/api/integration/integrationComponentConflicts.doc.mjs +1 -0
  34. package/api/integration/integrationDocConflicts.doc.mjs +1 -0
  35. package/api/integration/integrationPackCheck.doc.mjs +1 -0
  36. package/api/integration/integrationTemplateConflicts.doc.mjs +1 -0
  37. package/api/integration/pack-check.test.mjs +17 -47
  38. package/api/integration/summarizeIssues.doc.mjs +1 -0
  39. package/api/integration/validate-integration-fixes.test.mjs +1389 -0
  40. package/api/integration/validate-integration.mjs +50 -102
  41. package/api/integration/validate-integration.test.mjs +85 -23
  42. package/api/integration/validate-unread-theme-folders.test.mjs +110 -0
  43. package/api/integration/validateIntegration.doc.mjs +1 -0
  44. package/api/json/assertResponse.doc.mjs +1 -0
  45. package/api/json/isError.doc.mjs +1 -0
  46. package/api/json/parseResponse.doc.mjs +1 -0
  47. package/api/layout/layoutCheck.doc.mjs +1 -0
  48. package/api/layout/layoutExpand.doc.mjs +1 -0
  49. package/api/layout/layoutGrammar.doc.mjs +1 -0
  50. package/api/search/search.doc.mjs +1 -0
  51. package/api/search/search.mjs +16 -6
  52. package/api/swizzle/swizzle.doc.mjs +1 -0
  53. package/api/template/template-suffix.test.mjs +41 -21
  54. package/api/template/template.doc.mjs +1 -0
  55. package/api/theme/_adapter.d.mts +2 -3
  56. package/api/theme/_adapter.mjs +4 -5
  57. package/api/theme/add/add.binary.test.mjs +10 -17
  58. package/api/theme/add/add.test.mjs +14 -1
  59. package/api/theme/generateTonalPalette.doc.mjs +1 -0
  60. package/api/theme/integration-themes.test.mjs +39 -28
  61. package/api/theme/list/list.test.mjs +19 -20
  62. package/api/theme/listThemes.doc.mjs +6 -5
  63. package/api/theme/themeAdd.doc.mjs +4 -3
  64. package/api/theme/themeBuild.doc.mjs +1 -0
  65. package/api/theme/themeList.doc.mjs +6 -3
  66. package/api/theme/themeListAvailable.doc.mjs +5 -3
  67. package/api/theme/themePaletteGenerate.doc.mjs +1 -0
  68. package/api/theme/themeTargets.doc.mjs +1 -0
  69. package/api/theme/themeTemplate.doc.mjs +1 -0
  70. package/api/upgrade/_adapter.d.mts +12 -3
  71. package/api/upgrade/_adapter.mjs +81 -66
  72. package/api/upgrade/provider-agreement.test.mjs +152 -0
  73. package/api/upgrade/run/run.mjs +1 -0
  74. package/api/upgrade/upgrade.doc.mjs +1 -0
  75. package/assets/codemods/integration-discovery.mjs +8 -2
  76. package/assets/codemods/integration-discovery.test.mjs +15 -0
  77. package/assets/codemods/runner.mjs +115 -5
  78. package/assets/codemods/transforms/next/__tests__/migrate-theme-catalog-to-descriptors.test.mjs +216 -0
  79. package/assets/codemods/transforms/next/index.mjs +11 -1
  80. package/assets/codemods/transforms/next/migrate-theme-catalog-to-descriptors.mjs +141 -0
  81. package/assets/docs/cli-integrations.doc.mjs +17 -30
  82. package/assets/docs/cli.doc.mjs +15 -0
  83. package/assets/docs/theme.doc.mjs +1 -1
  84. package/assets/templates/themes/butter/butterTheme.doc.mjs +11 -0
  85. package/assets/templates/themes/chocolate/chocolateTheme.doc.mjs +11 -0
  86. package/assets/templates/themes/gothic/gothicTheme.doc.mjs +11 -0
  87. package/assets/templates/themes/matcha/matchaTheme.doc.mjs +11 -0
  88. package/assets/templates/themes/neutral/neutralTheme.doc.mjs +11 -0
  89. package/assets/templates/themes/stone/stoneTheme.doc.mjs +11 -0
  90. package/assets/templates/themes/y2k/y2kTheme.doc.mjs +11 -0
  91. package/authoring/codemod/codemod.doc.mjs +1 -1
  92. package/authoring/config/config.doc.mjs +1 -1
  93. package/authoring/debug/debug.doc.d.mts +11 -0
  94. package/authoring/debug/debug.doc.mjs +182 -0
  95. package/authoring/doctypes/base/graph-fields.doc.mjs +1 -1
  96. package/authoring/doctypes/command/command.doc.mjs +1 -1
  97. package/authoring/doctypes/command/type.ts +1 -1
  98. package/authoring/doctypes/component/type.ts +2 -2
  99. package/authoring/doctypes/doctypes-new.test.mjs +48 -6
  100. package/authoring/doctypes/enum/enum.doc.mjs +1 -1
  101. package/authoring/doctypes/enum/type.ts +1 -1
  102. package/authoring/doctypes/function/function.doc.mjs +1 -1
  103. package/authoring/doctypes/function/type.ts +1 -1
  104. package/authoring/doctypes/hook/type.ts +2 -2
  105. package/authoring/doctypes/load-contract.test.mjs +2 -1
  106. package/authoring/doctypes/parse.d.mts +4 -2
  107. package/authoring/doctypes/parse.mjs +7 -3
  108. package/authoring/doctypes/reference/reference.doc.mjs +1 -1
  109. package/authoring/doctypes/reference/type.ts +2 -2
  110. package/authoring/doctypes/schema/schema.doc.mjs +1 -1
  111. package/authoring/doctypes/schema/type.ts +1 -2
  112. package/authoring/doctypes/template/template.doc.mjs +3 -3
  113. package/authoring/doctypes/theme/parse.d.mts +35 -0
  114. package/authoring/doctypes/theme/parse.mjs +76 -0
  115. package/authoring/doctypes/theme/theme.doc.d.mts +9 -0
  116. package/authoring/doctypes/theme/theme.doc.mjs +79 -0
  117. package/authoring/doctypes/theme/type.ts +42 -0
  118. package/authoring/doctypes/types.ts +2 -1
  119. package/authoring/gap-report/gap-report.doc.d.mts +12 -0
  120. package/authoring/gap-report/gap-report.doc.mjs +183 -0
  121. package/authoring/index.d.mts +1 -0
  122. package/authoring/index.d.ts +6 -4
  123. package/authoring/index.mjs +2 -1
  124. package/authoring/integration/integration.doc.mjs +2 -2
  125. package/authoring/integration/type.ts +3 -9
  126. package/clients/cli/__tests__/cliManifest.test.ts +27 -29
  127. package/clients/cli/commands/blog.doc.mjs +1 -1
  128. package/clients/cli/commands/build.doc.mjs +1 -1
  129. package/clients/cli/commands/component.doc.mjs +1 -1
  130. package/clients/cli/commands/discover.doc.mjs +1 -1
  131. package/clients/cli/commands/docs.doc.mjs +1 -1
  132. package/clients/cli/commands/doctor-integration-components.doc.mjs +1 -1
  133. package/clients/cli/commands/doctor-integration-docs.doc.mjs +1 -1
  134. package/clients/cli/commands/doctor-integration-templates.doc.mjs +1 -1
  135. package/clients/cli/commands/doctor-integration-validate.doc.mjs +1 -1
  136. package/clients/cli/commands/doctor-integration.doc.mjs +1 -1
  137. package/clients/cli/commands/doctor-integration.test.mjs +15 -7
  138. package/clients/cli/commands/doctor.doc.mjs +1 -1
  139. package/clients/cli/commands/gap-report.doc.mjs +1 -1
  140. package/clients/cli/commands/hook.doc.mjs +1 -1
  141. package/clients/cli/commands/init.doc.mjs +1 -1
  142. package/clients/cli/commands/integration-add.controls.test.mjs +1 -1
  143. package/clients/cli/commands/integration-add.doc.mjs +1 -1
  144. package/clients/cli/commands/integration-pack.doc.mjs +1 -1
  145. package/clients/cli/commands/integration-real-world.test.mjs +3 -9
  146. package/clients/cli/commands/integration.doc.mjs +1 -1
  147. package/clients/cli/commands/layout-check.doc.mjs +1 -1
  148. package/clients/cli/commands/layout-expand.doc.mjs +1 -1
  149. package/clients/cli/commands/layout-grammar.doc.mjs +1 -1
  150. package/clients/cli/commands/layout.doc.mjs +1 -1
  151. package/clients/cli/commands/manifest.doc.mjs +1 -1
  152. package/clients/cli/commands/search.doc.mjs +1 -1
  153. package/clients/cli/commands/swizzle.doc.mjs +1 -1
  154. package/clients/cli/commands/template.doc.mjs +1 -1
  155. package/clients/cli/commands/theme-add.doc.mjs +2 -2
  156. package/clients/cli/commands/theme-build.doc.mjs +1 -1
  157. package/clients/cli/commands/theme-list.doc.mjs +2 -2
  158. package/clients/cli/commands/theme-palette-generate.doc.mjs +3 -3
  159. package/clients/cli/commands/theme-palette.doc.mjs +1 -1
  160. package/clients/cli/commands/theme-targets.doc.mjs +1 -1
  161. package/clients/cli/commands/theme-template.doc.mjs +1 -1
  162. package/clients/cli/commands/theme.doc.mjs +1 -1
  163. package/clients/cli/commands/upgrade.doc.mjs +1 -1
  164. package/clients/cli/lib/hook-format.mjs +14 -5
  165. package/foundation/config/project-themes.test.mjs +11 -19
  166. package/foundation/config/project.d.mts +8 -0
  167. package/foundation/config/project.mjs +50 -21
  168. package/foundation/config/project.test.mjs +3 -16
  169. package/foundation/discovery/authoring-self-docs.d.mts +6 -0
  170. package/foundation/discovery/authoring-self-docs.mjs +17 -7
  171. package/foundation/discovery/authoring-surface.d.mts +74 -0
  172. package/foundation/discovery/authoring-surface.mjs +525 -0
  173. package/foundation/discovery/authoring-surface.test.mjs +392 -0
  174. package/foundation/discovery/cli-self-docs.d.mts +113 -0
  175. package/foundation/discovery/cli-self-docs.mjs +514 -0
  176. package/foundation/discovery/cli-self-docs.test.mjs +437 -0
  177. package/foundation/discovery/component-loader.d.mts +35 -38
  178. package/foundation/discovery/component-loader.mjs +53 -222
  179. package/foundation/discovery/docs-discovery.d.mts +3 -2
  180. package/foundation/discovery/docs-discovery.mjs +8 -12
  181. package/foundation/discovery/docs-discovery.test.mjs +8 -5
  182. package/foundation/discovery/template-adapter.d.mts +7 -0
  183. package/foundation/discovery/template-adapter.mjs +27 -40
  184. package/foundation/discovery/template-adapter.test.mjs +15 -0
  185. package/foundation/discovery/theme-discovery.d.mts +67 -7
  186. package/foundation/discovery/theme-discovery.mjs +916 -186
  187. package/foundation/discovery/theme-discovery.test.mjs +613 -219
  188. package/foundation/doc-compiler/bundle.d.mts +47 -0
  189. package/foundation/doc-compiler/bundle.mjs +218 -0
  190. package/foundation/doc-compiler/bundle.test.mjs +255 -0
  191. package/foundation/doc-compiler/compile.d.mts +200 -0
  192. package/foundation/doc-compiler/compile.mjs +254 -5
  193. package/foundation/doc-compiler/diagnostics.d.mts +126 -0
  194. package/foundation/doc-compiler/diagnostics.mjs +277 -0
  195. package/foundation/doc-compiler/doc-compiler.test.mjs +28 -1
  196. package/foundation/doc-compiler/doc-loads.test.mjs +1642 -0
  197. package/foundation/doc-compiler/import.d.mts +24 -0
  198. package/foundation/doc-compiler/import.mjs +59 -0
  199. package/foundation/doc-compiler/inputs.d.mts +102 -0
  200. package/foundation/doc-compiler/inputs.mjs +286 -0
  201. package/foundation/doc-compiler/inputs.test.mjs +299 -0
  202. package/foundation/doc-compiler/ir.d.mts +13 -0
  203. package/foundation/doc-compiler/ir.mjs +189 -12
  204. package/foundation/doc-compiler/lower-doc.test.mjs +492 -0
  205. package/foundation/doc-compiler/overlays.d.mts +37 -0
  206. package/foundation/doc-compiler/overlays.mjs +206 -0
  207. package/foundation/doc-compiler/parse-readable.d.mts +9 -0
  208. package/foundation/doc-compiler/parse-readable.mjs +29 -0
  209. package/foundation/doc-compiler/read.d.mts +126 -0
  210. package/foundation/doc-compiler/read.mjs +320 -0
  211. package/foundation/doc-compiler/read.test.mjs +313 -0
  212. package/foundation/doc-compiler/source.d.mts +33 -0
  213. package/foundation/doc-compiler/source.mjs +128 -0
  214. package/foundation/integrations/autolink.d.mts +58 -1
  215. package/foundation/integrations/autolink.mjs +143 -57
  216. package/foundation/integrations/contribution-fixes.d.mts +145 -0
  217. package/foundation/integrations/contribution-fixes.mjs +1284 -0
  218. package/foundation/integrations/contribution-inventory.d.mts +1 -1
  219. package/foundation/integrations/contribution-inventory.mjs +17 -20
  220. package/foundation/integrations/contribution-inventory.test.mjs +67 -27
  221. package/foundation/integrations/integrations.d.mts +3 -0
  222. package/foundation/integrations/integrations.mjs +11 -97
  223. package/foundation/integrations/provider-ledger.test.mjs +275 -0
  224. package/foundation/integrations/provider-resolution.d.mts +152 -0
  225. package/foundation/integrations/provider-resolution.mjs +576 -0
  226. package/foundation/integrations/provider-resolution.test.mjs +369 -0
  227. package/foundation/integrations/theme-descriptor.d.mts +8 -0
  228. package/foundation/integrations/theme-descriptor.mjs +44 -0
  229. package/foundation/integrations/validate-contributions.mjs +104 -10
  230. package/foundation/response/error-codes.doc.mjs +2 -2
  231. package/foundation/response/error-codes.mjs +1 -1
  232. package/foundation/response/response-types.doc.mjs +1 -1
  233. package/foundation/response/response.doc.mjs +1 -1
  234. package/foundation/text/string-utils.mjs +22 -10
  235. package/package.json +9 -9
  236. package/assets/templates/themes/manifest.json +0 -95
@@ -9,7 +9,7 @@ export const doc = {
9
9
  type: 'command',
10
10
  name: 'doctor integration validate',
11
11
  displayName: 'astryx doctor integration validate',
12
- namespace: 'cli',
12
+ namespace: 'cli/commands',
13
13
  summary: 'Validate an integration manifest and its contributions',
14
14
  description:
15
15
  'Validates one integration at a time: the local package rooted at cwd, or an ' +
@@ -9,7 +9,7 @@ export const doc = {
9
9
  type: 'command',
10
10
  name: 'doctor integration',
11
11
  displayName: 'astryx doctor integration',
12
- namespace: 'cli',
12
+ namespace: 'cli/commands',
13
13
  summary: 'Check an integration package while authoring it',
14
14
  description:
15
15
  'The integration-authoring diagnostics group. Validate a manifest and all ' +
@@ -44,7 +44,7 @@ function writeIntegration({
44
44
  const stem = path.join(tmpDir, 'templates', id);
45
45
  fs.mkdirSync(path.dirname(stem), {recursive: true});
46
46
  fs.writeFileSync(
47
- `${stem}.template.mjs`,
47
+ `${stem}.doc.mjs`,
48
48
  `export default {type: 'page', name: ${JSON.stringify(name)}, description: 'fixture'};\n`,
49
49
  );
50
50
  fs.writeFileSync(
@@ -124,7 +124,12 @@ describe('doctor integration — command', () => {
124
124
  return true;
125
125
  });
126
126
 
127
- await createProgram().parseAsync(['node', 'astryx', 'doctor', 'integration']);
127
+ await createProgram().parseAsync([
128
+ 'node',
129
+ 'astryx',
130
+ 'doctor',
131
+ 'integration',
132
+ ]);
128
133
 
129
134
  const output = writes.join('');
130
135
  expect(output).toContain('validate [package]');
@@ -136,7 +141,9 @@ describe('doctor integration — command', () => {
136
141
 
137
142
  it('explains the optional package argument in every leaf help', () => {
138
143
  const program = createProgram();
139
- const doctor = program.commands.find(command => command.name() === 'doctor');
144
+ const doctor = program.commands.find(
145
+ command => command.name() === 'doctor',
146
+ );
140
147
  const integration = doctor?.commands.find(
141
148
  command => command.name() === 'integration',
142
149
  );
@@ -152,7 +159,10 @@ describe('doctor integration — command', () => {
152
159
  });
153
160
 
154
161
  it('templates explains how to check an installed package when no local manifest exists', async () => {
155
- fs.writeFileSync(path.join(tmpDir, 'package.json'), JSON.stringify({name: 'plain'}));
162
+ fs.writeFileSync(
163
+ path.join(tmpDir, 'package.json'),
164
+ JSON.stringify({name: 'plain'}),
165
+ );
156
166
  process.chdir(tmpDir);
157
167
 
158
168
  await createProgram().parseAsync([
@@ -278,9 +288,7 @@ describe('doctor integration — command', () => {
278
288
  const output = logCalls.join('\n');
279
289
  expect(output).toContain('[warn]');
280
290
  expect(output).toContain(core.name);
281
- expect(output).toContain(
282
- `component ${core.name} --package @acme/widgets`,
283
- );
291
+ expect(output).toContain(`component ${core.name} --package @acme/widgets`);
284
292
  expect(process.exitCode).toBeUndefined();
285
293
  });
286
294
 
@@ -12,7 +12,7 @@ export const doc = {
12
12
  type: 'command',
13
13
  name: 'doctor',
14
14
  displayName: 'astryx doctor',
15
- namespace: 'cli',
15
+ namespace: 'cli/commands',
16
16
  summary: 'Diagnose Astryx projects and integration packages',
17
17
  description:
18
18
  'Runs read-only project health diagnostics by default: Node version, @astryxdesign/core ' +
@@ -10,7 +10,7 @@ export const doc = {
10
10
  type: 'command',
11
11
  name: 'gap-report',
12
12
  displayName: 'astryx gap-report',
13
- namespace: 'cli',
13
+ namespace: 'cli/commands',
14
14
  summary: 'Route a design-system gap to its owning package',
15
15
  description:
16
16
  'Reports a missing component, variant, layout, styling, accessibility, API, or documentation capability. The command selects an explicit package first, then a unique component owner, then Core. The report fans out to every effective handler: project config first, then each loaded integration in config order. Public handlers require --confirm-public per handler; internal handlers always run. A handler failure is isolated and does not prevent later handlers.',
@@ -12,7 +12,7 @@ export const doc = {
12
12
  type: 'command',
13
13
  name: 'hook',
14
14
  displayName: 'astryx hook',
15
- namespace: 'cli',
15
+ namespace: 'cli/commands',
16
16
  summary: 'List hooks or print hook docs',
17
17
  description:
18
18
  'Resolves a hook by name and prints its authored doc, or lists the catalog grouped ' +
@@ -12,7 +12,7 @@ export const doc = {
12
12
  type: 'command',
13
13
  name: 'init',
14
14
  displayName: 'astryx init',
15
- namespace: 'cli',
15
+ namespace: 'cli/commands',
16
16
  summary: 'Initialize the design system in your project',
17
17
  description:
18
18
  'Non-interactive project setup (no prompts, so it behaves the same for humans, ' +
@@ -126,7 +126,7 @@ describe('integration add control definitions', () => {
126
126
  );
127
127
  expect(page.status).toBe(0);
128
128
  expect(
129
- fs.readFileSync(path.join(tmpDir, 'templates', 'acme-page.template.mjs'), 'utf-8'),
129
+ fs.readFileSync(path.join(tmpDir, 'templates', 'acme-page.doc.mjs'), 'utf-8'),
130
130
  ).toContain("type: 'page'");
131
131
  });
132
132
  });
@@ -5,7 +5,7 @@ export const doc = {
5
5
  type: 'command',
6
6
  name: 'integration add',
7
7
  displayName: 'astryx integration add',
8
- namespace: 'cli',
8
+ namespace: 'cli/commands',
9
9
  summary: 'Add one working contribution to an integration package',
10
10
  description:
11
11
  'Writes the complete minimum shape the selected contribution needs, creates the integration manifest on first use, declares the root only after a valid contribution exists, and verifies the result through the same discovery contract the packed-package check uses.',
@@ -5,7 +5,7 @@ export const doc = {
5
5
  type: 'command',
6
6
  name: 'integration pack',
7
7
  displayName: 'astryx integration pack',
8
- namespace: 'cli',
8
+ namespace: 'cli/commands',
9
9
  summary: 'Prove the packed integration is what consumers receive',
10
10
  description:
11
11
  'Runs the package lifecycle, packs with npm, checks every required contribution file against the real tarball, extracts it into a scratch consumer, and compares the local and packed contribution inventories through one shared contract.',
@@ -201,13 +201,6 @@ export const oceanTheme = defineTheme({
201
201
  });
202
202
  `,
203
203
  );
204
- const catalogFile = path.join(providerDir, 'themes', 'manifest.json');
205
- const catalog = JSON.parse(fs.readFileSync(catalogFile, 'utf-8'));
206
- catalog.themes[0].files.push(
207
- 'tokens/ocean.palette.ts',
208
- 'tokens/ocean.palette.receipt.json',
209
- );
210
- writeJson(catalogFile, catalog);
211
204
 
212
205
  const providerPackage = JSON.parse(
213
206
  fs.readFileSync(path.join(providerDir, 'package.json'), 'utf-8'),
@@ -464,8 +457,9 @@ export const oceanTheme = defineTheme({
464
457
  outputDir: target,
465
458
  files: [
466
459
  'oceanTheme.ts',
467
- 'tokens/ocean.palette.ts',
460
+ 'oceanTheme.doc.mjs',
468
461
  'tokens/ocean.palette.receipt.json',
462
+ 'tokens/ocean.palette.ts',
469
463
  ],
470
464
  },
471
465
  });
@@ -612,7 +606,7 @@ export const oceanTheme = defineTheme({
612
606
  expect(corruptedInstall.status).not.toBe(0);
613
607
  expect(parseEnvelope(corruptedInstall.stdout)).toMatchObject({
614
608
  code: 'ERR_THEME_INVALID',
615
- error: expect.stringContaining('ocean.palette.ts'),
609
+ error: expect.stringContaining('./tokens/ocean.palette'),
616
610
  });
617
611
  }, 120_000);
618
612
  });
@@ -5,7 +5,7 @@ export const doc = {
5
5
  type: 'command',
6
6
  name: 'integration',
7
7
  displayName: 'astryx integration',
8
- namespace: 'cli',
8
+ namespace: 'cli/commands',
9
9
  summary: 'Author and verify an Astryx integration package',
10
10
  description:
11
11
  'Add contributions that are valid on arrival, then prove the packed package exposes the same contributions a consumer will receive.',
@@ -13,7 +13,7 @@ export const doc = {
13
13
  type: 'command',
14
14
  name: 'layout check',
15
15
  displayName: 'astryx layout check',
16
- namespace: 'cli',
16
+ namespace: 'cli/commands',
17
17
  summary:
18
18
  'Validate a layout expression and echo canonical compact/outline forms',
19
19
  description:
@@ -13,7 +13,7 @@ export const doc = {
13
13
  type: 'command',
14
14
  name: 'layout expand',
15
15
  displayName: 'astryx layout expand',
16
- namespace: 'cli',
16
+ namespace: 'cli/commands',
17
17
  summary: 'Expand a layout expression into validated XDS TSX',
18
18
  description:
19
19
  'Parses and validates a compressed XLE/XLO expression, then expands it into ' +
@@ -13,7 +13,7 @@ export const doc = {
13
13
  type: 'command',
14
14
  name: 'layout grammar',
15
15
  displayName: 'astryx layout grammar',
16
- namespace: 'cli',
16
+ namespace: 'cli/commands',
17
17
  summary:
18
18
  'Print the XLE/XLO cheatsheet (alias table generated from this branch)',
19
19
  description:
@@ -12,7 +12,7 @@ export const doc = {
12
12
  type: 'command',
13
13
  name: 'layout',
14
14
  displayName: 'astryx layout',
15
- namespace: 'cli',
15
+ namespace: 'cli/commands',
16
16
  summary: 'Generate XDS layouts from compressed expressions (XLE/XLO)',
17
17
  description:
18
18
  'The layout command group. Running astryx layout with no subcommand prints the ' +
@@ -12,7 +12,7 @@ export const doc = {
12
12
  type: 'command',
13
13
  name: 'manifest',
14
14
  displayName: 'astryx manifest',
15
- namespace: 'cli',
15
+ namespace: 'cli/commands',
16
16
  summary: 'Print the full CLI capability manifest (use with --json).',
17
17
  description:
18
18
  'Emits the complete CLI surface: every command with its arguments, options, ' +
@@ -12,7 +12,7 @@ export const doc = {
12
12
  type: 'command',
13
13
  name: 'search',
14
14
  displayName: 'astryx search',
15
- namespace: 'cli',
15
+ namespace: 'cli/commands',
16
16
  summary: 'Search components, hooks, docs, and templates in one ranked list',
17
17
  description:
18
18
  'Terminal front-end to search(): prints one ranked, greppable list across ' +
@@ -12,7 +12,7 @@ export const doc = {
12
12
  type: 'command',
13
13
  name: 'swizzle',
14
14
  displayName: 'astryx swizzle',
15
- namespace: 'cli',
15
+ namespace: 'cli/commands',
16
16
  summary: 'Copy component source for customization',
17
17
  description:
18
18
  "Ejects a component's source from the resolved @astryxdesign/core (or its owning " +
@@ -13,7 +13,7 @@ export const doc = {
13
13
  type: 'command',
14
14
  name: 'template',
15
15
  displayName: 'astryx template',
16
- namespace: 'cli',
16
+ namespace: 'cli/commands',
17
17
  summary: 'Inject a page or block template',
18
18
  description:
19
19
  'One entry point for the template family: with no name it lists the discovered ' +
@@ -13,7 +13,7 @@ export const doc = {
13
13
  type: 'command',
14
14
  name: 'theme add',
15
15
  displayName: 'astryx theme add',
16
- namespace: 'cli',
16
+ namespace: 'cli/commands',
17
17
  summary: 'Scaffold a theme into your project as editable source',
18
18
  description:
19
19
  "Copies a bundled or installed integration theme's source into your project so you own it. " +
@@ -49,7 +49,7 @@ export const doc = {
49
49
  {code: 0, when: 'success'},
50
50
  {
51
51
  code: 1,
52
- when: 'unknown or ambiguous theme, a path escape, a missing catalog file, or an existing file without --overwrite',
52
+ when: 'unknown or ambiguous theme, a path escape, a missing descriptor or source, or an existing file without --overwrite',
53
53
  },
54
54
  ],
55
55
  related: ['theme list', 'theme build'],
@@ -13,7 +13,7 @@ export const doc = {
13
13
  type: 'command',
14
14
  name: 'theme build',
15
15
  displayName: 'astryx theme build',
16
- namespace: 'cli',
16
+ namespace: 'cli/commands',
17
17
  summary: 'Compile standalone themes or one keyed theme family',
18
18
  description:
19
19
  'Compiles defineTheme() sources through the same theme pipeline into scoped CSS, ' +
@@ -13,7 +13,7 @@ export const doc = {
13
13
  type: 'command',
14
14
  name: 'theme list',
15
15
  displayName: 'astryx theme list',
16
- namespace: 'cli',
16
+ namespace: 'cli/commands',
17
17
  summary: 'List themes available to add',
18
18
  description:
19
19
  'Lists themes bundled with this CLI and source themes contributed by installed integrations, ' +
@@ -37,7 +37,7 @@ export const doc = {
37
37
  {code: 0, when: 'success'},
38
38
  {
39
39
  code: 1,
40
- when: 'the bundled-theme manifest or an installed theme catalog cannot be read',
40
+ when: 'a bundled or installed theme descriptor cannot be read',
41
41
  },
42
42
  ],
43
43
  related: ['theme add', 'theme build'],
@@ -5,7 +5,7 @@ export const doc = {
5
5
  type: 'command',
6
6
  name: 'theme palette generate',
7
7
  displayName: 'astryx theme palette generate',
8
- namespace: 'cli',
8
+ namespace: 'cli/commands',
9
9
  summary: 'Generate an OKLCH palette candidate for human review',
10
10
  description:
11
11
  'Reads an explicit JSON request and runs the versioned astryx-oklch-v1 recipe. ' +
@@ -21,8 +21,8 @@ export const doc = {
21
21
  'JSON is also supported. Existing author-owned files are left untouched unless --overwrite is explicit. ' +
22
22
  'When used in a theme integration, keep the palette request under the theme slug, ' +
23
23
  'write the candidate and receipt under that same slug, import the candidate from the theme source, ' +
24
- "and list all three paths in the theme catalog entry's `files` array " +
25
- 'so `astryx theme add` copies them into the consumer project.',
24
+ 'and keep all three inside the theme directory: `astryx theme add` copies that whole ' +
25
+ 'directory into the consumer project, so nothing else has to list them.',
26
26
  fn: 'themePaletteGenerate',
27
27
  args: [{name: 'config', param: 'configPath', required: true}],
28
28
  options: [
@@ -5,7 +5,7 @@ export const doc = {
5
5
  type: 'command',
6
6
  name: 'theme palette',
7
7
  displayName: 'astryx theme palette',
8
- namespace: 'cli',
8
+ namespace: 'cli/commands',
9
9
  summary: 'Create and work with theme-owned color palettes',
10
10
  description:
11
11
  'Palette authoring tools. The initial generate command creates reviewable candidates. ' +
@@ -13,7 +13,7 @@ export const doc = {
13
13
  type: 'command',
14
14
  name: 'theme targets',
15
15
  displayName: 'astryx theme targets',
16
- namespace: 'cli',
16
+ namespace: 'cli/commands',
17
17
  summary: 'List the component theming targets a theme can override',
18
18
  description:
19
19
  'Prints every `defineTheme` components key across the system: the stable class it paints, ' +
@@ -13,7 +13,7 @@ export const doc = {
13
13
  type: 'command',
14
14
  name: 'theme template',
15
15
  displayName: 'astryx theme template',
16
- namespace: 'cli',
16
+ namespace: 'cli/commands',
17
17
  summary: 'Write the annotated theme template into your project',
18
18
  description:
19
19
  'Writes theme.template.ts: the annotated reference for the whole theme surface, covering every ' +
@@ -12,7 +12,7 @@ export const doc = {
12
12
  type: 'command',
13
13
  name: 'theme',
14
14
  displayName: 'astryx theme',
15
- namespace: 'cli',
15
+ namespace: 'cli/commands',
16
16
  summary: 'Theme tools: build, export, and manage themes',
17
17
  description:
18
18
  'The theme command group. Running astryx theme with no subcommand prints the ' +
@@ -12,7 +12,7 @@ export const doc = {
12
12
  type: 'command',
13
13
  name: 'upgrade',
14
14
  displayName: 'astryx upgrade',
15
- namespace: 'cli',
15
+ namespace: 'cli/commands',
16
16
  summary: 'Migrate versions and update ShadCN-copied compositions',
17
17
  description:
18
18
  'Migrates project source from a previous Astryx version to the installed one by ' +
@@ -9,7 +9,10 @@
9
9
  * - Brief: signature line with import hint, description, key params
10
10
  */
11
11
 
12
- import {discoverHooks, findHookDoc} from '../../../foundation/discovery/hook-discovery.mjs';
12
+ import {
13
+ discoverHooks,
14
+ findHookDoc,
15
+ } from '../../../foundation/discovery/hook-discovery.mjs';
13
16
  import {loadDocs} from '../../../foundation/discovery/component-loader.mjs';
14
17
  import {formatAccessibility, mdCell} from './component-format.mjs';
15
18
 
@@ -23,7 +26,9 @@ function buildSignature(docs) {
23
26
  const name = docs.name;
24
27
 
25
28
  // Build params string — only top-level params (skip options.foo nested params)
26
- const topParams = (docs.params || []).filter((/** @type {any} */ p) => !p.name.includes('.'));
29
+ const topParams = (docs.params || []).filter(
30
+ (/** @type {any} */ p) => !p.name.includes('.'),
31
+ );
27
32
  const paramStr = topParams
28
33
  .map((/** @type {any} */ p) => {
29
34
  const opt = p.required ? '' : '?';
@@ -150,7 +155,9 @@ export function formatHookCompact(docs, importPath) {
150
155
  const imp = importPath || docs.importPath;
151
156
  if (imp) {
152
157
  sections.push('## Import\n');
153
- sections.push(`\`\`\`tsx\nimport { ${docs.name} } from '${imp}';\n\`\`\`\n`);
158
+ sections.push(
159
+ `\`\`\`tsx\nimport { ${docs.name} } from '${imp}';\n\`\`\`\n`,
160
+ );
154
161
  }
155
162
 
156
163
  // Best Practices (matches component compact)
@@ -228,7 +235,9 @@ export function formatHookBrief(docs) {
228
235
  // Key params (matches component brief 'prop, prop' line)
229
236
  const paramNames = (docs.params || [])
230
237
  .filter((/** @type {any} */ p) => !p.name.includes('.'))
231
- .map((/** @type {any} */ p) => p.required ? `${p.name}: ${p.type.split('|')[0].trim()}` : p.name);
238
+ .map((/** @type {any} */ p) =>
239
+ p.required ? `${p.name}: ${p.type.split('|')[0].trim()}` : p.name,
240
+ );
232
241
  if (paramNames.length > 0) {
233
242
  output.push(` ${paramNames.join(', ')}`);
234
243
  }
@@ -253,7 +262,7 @@ export async function formatHookBriefAll(coreDir) {
253
262
  const docPath = findHookDoc(coreDir, hookName);
254
263
  if (docPath) {
255
264
  try {
256
- const docs = await loadDocs(docPath);
265
+ const docs = await loadDocs(docPath, {root: 'hooks'});
257
266
  output.push(formatHookBrief(docs));
258
267
  } catch {
259
268
  output.push(`${hookName}\n (no docs)\n`);
@@ -15,6 +15,7 @@ function installThemeIntegration(packageName, slug) {
15
15
  ...packageName.split('/'),
16
16
  );
17
17
  const themeDir = path.join(packageDir, 'themes', slug);
18
+ const stem = `${slug.replace(/-([a-z0-9])/gu, (_, character) => character.toUpperCase())}Theme`;
18
19
  fs.mkdirSync(themeDir, {recursive: true});
19
20
  fs.writeFileSync(
20
21
  path.join(packageDir, 'package.json'),
@@ -22,28 +23,19 @@ function installThemeIntegration(packageName, slug) {
22
23
  );
23
24
  fs.writeFileSync(
24
25
  path.join(packageDir, 'astryx.integration.mjs'),
25
- `export default {themes: './themes'};\n`,
26
+ `export default {themes: './themes'};
27
+ `,
26
28
  );
27
29
  fs.writeFileSync(
28
- path.join(packageDir, 'themes', 'manifest.json'),
29
- JSON.stringify({
30
- version: 1,
31
- themes: [
32
- {
33
- slug,
34
- displayName: 'Ocean',
35
- description: 'Blue and calm.',
36
- maintained: true,
37
- entry: 'oceanTheme.ts',
38
- exportName: 'oceanTheme',
39
- files: ['oceanTheme.ts'],
40
- },
41
- ],
42
- }),
30
+ path.join(themeDir, `${stem}.doc.mjs`),
31
+ `/** @type {import('@astryxdesign/cli/authoring').ThemeDoc} */
32
+ export default {type: 'theme', name: '${slug}', displayName: 'Ocean', description: 'Blue and calm.', maintained: true};
33
+ `,
43
34
  );
44
35
  fs.writeFileSync(
45
- path.join(themeDir, 'oceanTheme.ts'),
46
- `export const oceanTheme = {};\n`,
36
+ path.join(themeDir, `${stem}.ts`),
37
+ `export const ${stem} = {};
38
+ `,
47
39
  );
48
40
  }
49
41
 
@@ -99,7 +91,7 @@ describe('Project themes', () => {
99
91
  ]);
100
92
  });
101
93
 
102
- it('records an invalid integration theme catalog as an issue', async () => {
94
+ it('records an invalid integration theme descriptor as an issue', async () => {
103
95
  installThemeIntegration('@acme/themes', 'ocean');
104
96
  fs.rmSync(
105
97
  path.join(
@@ -9,6 +9,14 @@
9
9
  * @returns {string|null}
10
10
  */
11
11
  export function findConfigPath(startDir?: string): string | null;
12
+ /**
13
+ * The provider ledger a Project resolved at load: one outcome for every
14
+ * package directory configured, autolinked, or authored. Internal: upgrade
15
+ * resolves on top of it, and tests account for every candidate with it.
16
+ * @param {Project} project
17
+ * @returns {import('../integrations/provider-resolution.mjs').ProviderLedger}
18
+ */
19
+ export function providerLedgerOf(project: Project): import("../integrations/provider-resolution.mjs").ProviderLedger;
12
20
  /**
13
21
  * An integration issue tagged with the owner package. The base
14
22
  * {@link import('../integrations/issue').AstryxIntegrationIssue} fields plus the
@@ -15,7 +15,9 @@
15
15
  * async). It does what loadConfig did — find the config sibling-of
16
16
  * package.json, import + validate it, load the configured integrations —
17
17
  * plus autolink the installed ones no config names, and self-resolve the
18
- * package being authored when it carries a manifest. Discovery is LAZY.
18
+ * package being authored when it carries a manifest. Provider identity is
19
+ * resolved once over all three (see integrations/provider-resolution), and
20
+ * the ledger is kept for {@link providerLedgerOf}. Discovery is LAZY.
19
21
  * - Discovery methods (components/templates/codemods/docs/themes) are MEMOIZED per
20
22
  * instance (via the pluggable cache) and orchestrate the EXISTING discovery
21
23
  * functions — Project never reimplements discovery.
@@ -38,10 +40,10 @@ import {parseConfig} from '../../authoring/config/parse.mjs';
38
40
  import {
39
41
  loadIntegrations,
40
42
  loadLocalIntegration,
41
- markProviderConflicts,
42
43
  resolvePackageDir,
43
44
  } from '../integrations/integrations.mjs';
44
- import {autolinkIntegrations} from '../integrations/autolink.mjs';
45
+ import {loadAutolinkCandidates} from '../integrations/autolink.mjs';
46
+ import {resolveProviders} from '../integrations/provider-resolution.mjs';
45
47
  import {
46
48
  setProject as setDebugProject,
47
49
  setEventHandler as setDebugEventHandler,
@@ -297,6 +299,24 @@ export function findConfigPath(startDir = process.cwd()) {
297
299
  return present.length === 1 ? present[0] : null;
298
300
  }
299
301
 
302
+ /**
303
+ * The provider ledger each loaded Project resolved, kept off the class so it
304
+ * is not part of the Project API.
305
+ * @type {WeakMap<Project, import('../integrations/provider-resolution.mjs').ProviderLedger>}
306
+ */
307
+ const PROVIDER_LEDGERS = new WeakMap();
308
+
309
+ /**
310
+ * The provider ledger a Project resolved at load: one outcome for every
311
+ * package directory configured, autolinked, or authored. Internal: upgrade
312
+ * resolves on top of it, and tests account for every candidate with it.
313
+ * @param {Project} project
314
+ * @returns {import('../integrations/provider-resolution.mjs').ProviderLedger}
315
+ */
316
+ export function providerLedgerOf(project) {
317
+ return PROVIDER_LEDGERS.get(project) ?? new Map();
318
+ }
319
+
300
320
  /**
301
321
  * The single API for reading resolved project configuration. Construct via the
302
322
  * async {@link Project.load} factory.
@@ -402,17 +422,14 @@ export class Project {
402
422
  // This runs whether or not a config exists, because the projects it reaches
403
423
  // are overwhelmingly the ones with no astryx.config at all: a scaffold adds
404
424
  // the dependency and writes no config, and the integration then contributes
405
- // nothing for want of a line nobody knew to write. Appended AFTER the
425
+ // nothing for want of a line nobody knew to write. Resolved AFTER the
406
426
  // configured ones so an explicit entry keeps its position and its
407
427
  // precedence in every discovery order.
408
- loadedIntegrations = [
409
- ...loadedIntegrations,
410
- ...(await autolinkIntegrations({
411
- projectDir,
412
- loaded: loadedIntegrations,
413
- fresh,
414
- })),
415
- ];
428
+ const autolinked = await loadAutolinkCandidates({
429
+ projectDir,
430
+ loaded: loadedIntegrations,
431
+ fresh,
432
+ });
416
433
 
417
434
  // The package being authored is the one package that cannot install itself.
418
435
  // When it carries a manifest, resolve its working bytes directly so every
@@ -420,17 +437,27 @@ export class Project {
420
437
  // replaces the same installed package in place, preserving configured
421
438
  // precedence while making the source being edited authoritative.
422
439
  const localIntegration = await loadLocalIntegrationSafely(projectDir, fresh);
423
- if (localIntegration) {
424
- const existing = loadedIntegrations.findIndex(
425
- integration => integration.name === localIntegration.name,
426
- );
427
- if (existing === -1) loadedIntegrations.push(localIntegration);
428
- else loadedIntegrations[existing] = localIntegration;
429
- }
430
440
 
431
441
  // Autolinked and local packages can claim a provider ID that a configured
432
442
  // package already holds, so identity is resolved once over the final set.
433
- loadedIntegrations = markProviderConflicts(loadedIntegrations);
443
+ const resolution = resolveProviders([
444
+ ...loadedIntegrations.map(integration => ({
445
+ source: /** @type {const} */ ('configured'),
446
+ integration,
447
+ spec: integration.__spec,
448
+ })),
449
+ ...autolinked,
450
+ ...(localIntegration
451
+ ? [
452
+ {
453
+ source: /** @type {const} */ ('local'),
454
+ integration: localIntegration,
455
+ spec: localIntegration.__spec,
456
+ },
457
+ ]
458
+ : []),
459
+ ]);
460
+ loadedIntegrations = resolution.integrations;
434
461
 
435
462
  // The debug recorder resolves its settings synchronously, long before any
436
463
  // command gets here, so this is where a project's `debug` block gets a
@@ -461,7 +488,7 @@ export class Project {
461
488
  // Never let recording break config loading.
462
489
  }
463
490
 
464
- return new Project({
491
+ const project = new Project({
465
492
  cwd,
466
493
  configPath,
467
494
  config,
@@ -470,6 +497,8 @@ export class Project {
470
497
  cache: resolvedCache,
471
498
  hash,
472
499
  });
500
+ PROVIDER_LEDGERS.set(project, resolution.ledger);
501
+ return project;
473
502
  }
474
503
 
475
504
  /**