@astryxdesign/cli 0.7.2-canary.b06a093 → 0.7.2-canary.b40ba52

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 (289) hide show
  1. package/README.md +20 -19
  2. package/api/build/help/help.mjs +1 -1
  3. package/api/component/_adapter.d.mts +41 -1
  4. package/api/component/_adapter.mjs +93 -7
  5. package/api/component/component.mjs +22 -5
  6. package/api/component/component.test.mjs +420 -167
  7. package/api/component/integration-export-name.test.mjs +644 -0
  8. package/api/component/list/list.mjs +42 -4
  9. package/api/discover/_adapter.d.mts +119 -12
  10. package/api/discover/_adapter.mjs +449 -10
  11. package/api/discover/_adapter.test.mjs +599 -17
  12. package/api/discover/_catalog-view.d.mts +16 -5
  13. package/api/discover/_catalog-view.mjs +32 -8
  14. package/api/discover/discover.d.mts +11 -0
  15. package/api/discover/discover.doc.mjs +7 -6
  16. package/api/discover/discover.mjs +107 -19
  17. package/api/discover/discover.type.d.mts +18 -7
  18. package/api/discover/discover.type.mjs +15 -7
  19. package/api/discover/list/list.d.mts +4 -3
  20. package/api/discover/list/list.mjs +17 -10
  21. package/api/docs/_adapter.d.mts +11 -0
  22. package/api/docs/_adapter.mjs +244 -1
  23. package/api/docs/integrationDocs.test.mjs +124 -0
  24. package/api/doctor/doctor.mjs +27 -3
  25. package/api/doctor/doctor.test.mjs +43 -0
  26. package/api/doctor/theme-checks.mjs +1 -1
  27. package/api/doctor/theme-checks.test.mjs +136 -0
  28. package/api/gap-report/gap-report.d.mts +3 -0
  29. package/api/gap-report/gap-report.doc.mjs +11 -3
  30. package/api/gap-report/gap-report.mjs +219 -52
  31. package/api/gap-report/gap-report.test.mjs +233 -0
  32. package/api/gap-report/gap-report.type.d.mts +41 -0
  33. package/api/gap-report/gap-report.type.mjs +18 -0
  34. package/api/index.d.mts +2 -0
  35. package/api/index.mjs +2 -0
  36. package/api/init/run/run.mjs +2 -2
  37. package/api/integration/_adapter.d.mts +12 -0
  38. package/api/integration/_adapter.mjs +54 -0
  39. package/api/integration/add-contribution.component-names.test.mjs +66 -0
  40. package/api/integration/add-contribution.mjs +8 -4
  41. package/api/integration/add-contribution.test.mjs +4 -2
  42. package/api/integration/authoring-checks.mjs +11 -2
  43. package/api/integration/authoring-checks.test.mjs +39 -0
  44. package/api/integration/authoring-checks.type.d.mts +9 -0
  45. package/api/integration/authoring-checks.type.mjs +14 -1
  46. package/api/integration/check/check.d.mts +96 -0
  47. package/api/integration/check/check.mjs +357 -0
  48. package/api/integration/check/check.test.mjs +489 -0
  49. package/api/integration/integration-check.type.d.mts +118 -0
  50. package/api/integration/integration-check.type.mjs +84 -0
  51. package/api/integration/integrationCheck.doc.d.mts +10 -0
  52. package/api/integration/integrationCheck.doc.mjs +73 -0
  53. package/api/integration/integrationComponentConflicts.doc.mjs +43 -6
  54. package/api/integration/pack-check.mjs +353 -114
  55. package/api/integration/pack-check.test.mjs +700 -0
  56. package/api/integration/validate-integration.mjs +8 -0
  57. package/api/integration/validate-integration.test.mjs +11 -0
  58. package/api/integration/validate-integration.type.d.mts +8 -0
  59. package/api/integration/validate-integration.type.mjs +12 -1
  60. package/api/integration/validateIntegration.doc.mjs +19 -3
  61. package/api/search/search.d.mts +81 -12
  62. package/api/search/search.domain-priority.test.mjs +108 -18
  63. package/api/search/search.integration-check.test.mjs +24 -0
  64. package/api/search/search.mjs +609 -53
  65. package/api/search/search.test.mjs +175 -0
  66. package/api/swizzle/copy/copy.mjs +28 -14
  67. package/api/template/template.test.mjs +120 -3
  68. package/api/theme/build/build.family.test.mjs +64 -0
  69. package/api/theme/build/build.mjs +180 -24
  70. package/api/theme/themeBuild.doc.mjs +4 -4
  71. package/api/upgrade/_adapter.d.mts +40 -2
  72. package/api/upgrade/_adapter.mjs +117 -4
  73. package/api/upgrade/run/cli-behind-core.test.mjs +438 -0
  74. package/api/upgrade/run/run.mjs +30 -1
  75. package/api/upgrade/status/status.d.mts +21 -5
  76. package/api/upgrade/status/status.mjs +45 -8
  77. package/api/upgrade/upgrade.doc.mjs +5 -3
  78. package/api/upgrade/upgrade.type.d.mts +23 -0
  79. package/api/upgrade/upgrade.type.mjs +16 -1
  80. package/assets/codemods/runner.mjs +7 -1
  81. package/assets/codemods/transforms/next/__tests__/migrate-list-edge-compensation-to-edge.test.mjs +120 -0
  82. package/assets/codemods/transforms/next/index.mjs +11 -1
  83. package/assets/codemods/transforms/next/migrate-list-edge-compensation-to-edge.mjs +198 -0
  84. package/assets/discover/official-packages.json +367 -0
  85. package/assets/docs/README.md +10 -0
  86. package/assets/docs/author-a-theme.doc.mjs +1 -1
  87. package/assets/docs/getting-started.doc.mjs +3 -3
  88. package/assets/docs/styling-overview.doc.mjs +1 -1
  89. package/assets/docs/theme.doc.dense.mjs +1 -1
  90. package/assets/docs/theme.doc.mjs +1 -1
  91. package/assets/docs/theme.doc.zh.mjs +1 -1
  92. package/assets/docs/tree/add-a-component.doc.mjs +11 -1
  93. package/assets/docs/tree/add-a-theme.doc.mjs +1 -1
  94. package/assets/docs/tree/add-a-topic.doc.mjs +10 -7
  95. package/assets/docs/tree/agent-guidance.doc.mjs +2 -2
  96. package/assets/docs/tree/block-template.doc.mjs +8 -20
  97. package/assets/docs/tree/build-the-template.doc.mjs +1 -1
  98. package/assets/docs/tree/check-the-props.doc.mjs +196 -0
  99. package/assets/docs/tree/check-your-docs.doc.mjs +51 -5
  100. package/assets/docs/tree/checks.doc.mjs +24 -16
  101. package/assets/docs/tree/codemods.doc.mjs +4 -4
  102. package/assets/docs/tree/component-family.doc.mjs +8 -6
  103. package/assets/docs/tree/component-imports.doc.mjs +10 -2
  104. package/assets/docs/tree/components.doc.mjs +1 -1
  105. package/assets/docs/tree/debug-and-gap-reports.doc.mjs +25 -16
  106. package/assets/docs/tree/define-the-theme.doc.mjs +6 -5
  107. package/assets/docs/tree/describe-the-component.doc.mjs +2 -2
  108. package/assets/docs/tree/docs.doc.mjs +3 -3
  109. package/assets/docs/tree/document-the-template.doc.mjs +1 -1
  110. package/assets/docs/tree/document-the-theme.doc.mjs +1 -1
  111. package/assets/docs/tree/export-template-assets.doc.mjs +1 -1
  112. package/assets/docs/tree/extend-or-replace.doc.mjs +6 -6
  113. package/assets/docs/tree/fonts-and-assets.doc.mjs +2 -2
  114. package/assets/docs/tree/generate-a-palette.doc.mjs +5 -3
  115. package/assets/docs/tree/grade-template-with-agent.doc.mjs +1 -1
  116. package/assets/docs/tree/integrations.doc.mjs +8 -0
  117. package/assets/docs/tree/links.doc.mjs +6 -5
  118. package/assets/docs/tree/migration-setup.doc.mjs +1 -0
  119. package/assets/docs/tree/migration-verification.doc.mjs +0 -1
  120. package/assets/docs/tree/migration.doc.mjs +0 -1
  121. package/assets/docs/tree/package-and-test.doc.mjs +1 -1
  122. package/assets/docs/tree/page-template.doc.mjs +4 -8
  123. package/assets/docs/tree/publishing.doc.mjs +1 -1
  124. package/assets/docs/tree/quick-start.doc.mjs +37 -21
  125. package/assets/docs/tree/replace-a-core-component.doc.mjs +4 -6
  126. package/assets/docs/tree/replace-a-core-template.doc.mjs +6 -8
  127. package/assets/docs/tree/sections-and-placement.doc.mjs +4 -6
  128. package/assets/docs/tree/see-it-in-an-app.doc.mjs +4 -2
  129. package/assets/docs/tree/short-and-findable.doc.mjs +6 -5
  130. package/assets/docs/tree/single-component.doc.mjs +15 -6
  131. package/assets/docs/tree/start-a-template.doc.mjs +3 -3
  132. package/assets/docs/tree/subcomponent.doc.mjs +6 -6
  133. package/assets/docs/tree/template-assets.doc.mjs +2 -2
  134. package/assets/docs/tree/template-doc-overview.doc.mjs +4 -15
  135. package/assets/docs/tree/template-fonts.doc.mjs +1 -1
  136. package/assets/docs/tree/template-icons.doc.mjs +1 -1
  137. package/assets/docs/tree/template-images-media.doc.mjs +1 -1
  138. package/assets/docs/tree/template-styles.doc.mjs +2 -2
  139. package/assets/docs/tree/templates.doc.mjs +1 -1
  140. package/assets/docs/tree/test-in-an-app.doc.mjs +3 -3
  141. package/assets/docs/tree/test-template-in-app.doc.mjs +1 -1
  142. package/assets/docs/tree/tokens-and-setup.doc.mjs +19 -15
  143. package/assets/docs/tree/troubleshooting.doc.mjs +13 -5
  144. package/assets/docs/tree/type-scale.doc.mjs +3 -3
  145. package/assets/docs/tree/upgrading.doc.mjs +3 -3
  146. package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +3 -1
  147. package/assets/docs/tree/verify-packed-template.doc.mjs +1 -1
  148. package/assets/docs/tree/versioning.doc.mjs +7 -6
  149. package/assets/docs/tree/write-the-template-file.doc.mjs +4 -3
  150. package/assets/docs/use-a-theme.doc.mjs +2 -2
  151. package/assets/docs/working-with-ai.doc.mjs +43 -4
  152. package/assets/templates/blocks/components/Drawer/DrawerForm.doc.mjs +24 -0
  153. package/assets/templates/blocks/components/Drawer/DrawerForm.tsx +62 -0
  154. package/assets/templates/blocks/components/Drawer/DrawerScrim.doc.mjs +22 -0
  155. package/assets/templates/blocks/components/Drawer/DrawerScrim.tsx +68 -0
  156. package/assets/templates/blocks/components/Drawer/DrawerShowcase.doc.mjs +22 -0
  157. package/assets/templates/blocks/components/Drawer/DrawerShowcase.tsx +41 -0
  158. package/assets/templates/blocks/components/Drawer/DrawerStart.doc.mjs +21 -0
  159. package/assets/templates/blocks/components/Drawer/DrawerStart.tsx +41 -0
  160. package/assets/templates/blocks/components/Drawer/DrawerWidths.doc.mjs +22 -0
  161. package/assets/templates/blocks/components/Drawer/DrawerWidths.tsx +54 -0
  162. package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderShowcase.doc.mjs +15 -0
  163. package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderShowcase.tsx +73 -0
  164. package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderSubtitleEndContent.doc.mjs +22 -0
  165. package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderSubtitleEndContent.tsx +49 -0
  166. package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderWithCloseButton.doc.mjs +21 -0
  167. package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderWithCloseButton.tsx +42 -0
  168. package/assets/templates/pages/detail-page/page.tsx +3 -3
  169. package/assets/templates/pages/table-inbox/page.tsx +10 -8
  170. package/assets/theme.template.ts +1 -1
  171. package/authoring/codemod/codemod.doc.mjs +7 -3
  172. package/authoring/config/config.doc.mjs +9 -6
  173. package/authoring/config/type.ts +4 -2
  174. package/authoring/discover/discover.doc.mjs +1 -1
  175. package/authoring/doctypes/base/graph-fields.doc.mjs +6 -4
  176. package/authoring/doctypes/base/type.ts +6 -0
  177. package/authoring/doctypes/command/command.doc.mjs +14 -12
  178. package/authoring/doctypes/component/component.doc.mjs +31 -28
  179. package/authoring/doctypes/component/type.ts +13 -8
  180. package/authoring/doctypes/enum/enum.doc.mjs +7 -4
  181. package/authoring/doctypes/function/function.doc.mjs +9 -8
  182. package/authoring/doctypes/hook/hook.doc.mjs +5 -4
  183. package/authoring/doctypes/namespace/namespace.doc.mjs +7 -6
  184. package/authoring/doctypes/reference/reference.doc.mjs +11 -10
  185. package/authoring/doctypes/schema/schema.doc.mjs +9 -9
  186. package/authoring/doctypes/template/integration-template.doc.d.mts +11 -0
  187. package/authoring/doctypes/template/integration-template.doc.mjs +49 -0
  188. package/authoring/doctypes/template/parse.d.mts +6 -2
  189. package/authoring/doctypes/template/parse.mjs +3 -1
  190. package/authoring/doctypes/template/template.doc.mjs +3 -3
  191. package/authoring/doctypes/template/type.ts +22 -0
  192. package/authoring/doctypes/theme/theme.doc.mjs +2 -2
  193. package/authoring/gap-report/gap-report.doc.mjs +2 -2
  194. package/authoring/identity/identity.doc.mjs +3 -3
  195. package/authoring/index.d.ts +1 -0
  196. package/authoring/integration/integration.doc.mjs +12 -4
  197. package/authoring/integration/parse.test.mjs +10 -0
  198. package/authoring/integration/schema.d.mts +2 -0
  199. package/authoring/integration/schema.mjs +1 -0
  200. package/authoring/integration/type.ts +4 -0
  201. package/clients/cli/commands/build-theme.batch-report.test.mjs +3 -1
  202. package/clients/cli/commands/build-theme.mjs +1 -1
  203. package/clients/cli/commands/build-theme.path-safety.test.mjs +224 -6
  204. package/clients/cli/commands/build-theme.registry.test.mjs +5 -2
  205. package/clients/cli/commands/cli-postinstall.test.mjs +49 -1
  206. package/clients/cli/commands/discover.broken-integration.test.mjs +4 -1
  207. package/clients/cli/commands/discover.doc.mjs +1 -1
  208. package/clients/cli/commands/discover.mjs +144 -93
  209. package/clients/cli/commands/discover.no-source.test.mjs +447 -33
  210. package/clients/cli/commands/discover.sources.test.mjs +20 -1
  211. package/clients/cli/commands/doctor-integration-components.doc.mjs +17 -4
  212. package/clients/cli/commands/doctor-integration-validate.doc.mjs +13 -2
  213. package/clients/cli/commands/doctor-integration.test.mjs +837 -0
  214. package/clients/cli/commands/doctor.mjs +190 -0
  215. package/clients/cli/commands/gap-report.doc.mjs +14 -2
  216. package/clients/cli/commands/gap-report.mjs +24 -2
  217. package/clients/cli/commands/gap-report.test.mjs +79 -0
  218. package/clients/cli/commands/integration-check.doc.mjs +85 -0
  219. package/clients/cli/commands/integration-check.test.mjs +284 -0
  220. package/clients/cli/commands/integration.doc.mjs +6 -2
  221. package/clients/cli/commands/integration.mjs +106 -1
  222. package/clients/cli/commands/json-contract.test.mjs +5 -1
  223. package/clients/cli/commands/setup-nudge.test.mjs +79 -1
  224. package/clients/cli/commands/swizzle.mjs +5 -3
  225. package/clients/cli/commands/swizzle.routing.test.mjs +18 -1
  226. package/clients/cli/commands/text-json-parity.test.mjs +5 -0
  227. package/clients/cli/commands/theme-build.doc.mjs +2 -2
  228. package/clients/cli/commands/upgrade.doc.mjs +14 -0
  229. package/clients/cli/commands/upgrade.older-cli.test.mjs +160 -0
  230. package/clients/cli/index.mjs +30 -5
  231. package/clients/cli/lib/component-format.mjs +5 -1
  232. package/foundation/agent-docs/agent-doc-state.d.mts +14 -0
  233. package/foundation/agent-docs/agent-doc-state.mjs +38 -0
  234. package/foundation/agent-docs/agent-docs.d.mts +2 -1
  235. package/foundation/agent-docs/agent-docs.mjs +8 -6
  236. package/foundation/config/project.mjs +82 -0
  237. package/foundation/discovery/authoring-self-docs.mjs +2 -1
  238. package/foundation/discovery/component-discovery.d.mts +190 -10
  239. package/foundation/discovery/component-discovery.export-names.test.mjs +760 -0
  240. package/foundation/discovery/component-discovery.mjs +864 -56
  241. package/foundation/discovery/component-discovery.test.mjs +96 -0
  242. package/foundation/discovery/component-replacement.mjs +18 -0
  243. package/foundation/discovery/component-replacement.test.mjs +40 -0
  244. package/foundation/discovery/doc-types.d.mts +157 -0
  245. package/foundation/discovery/doc-types.mjs +1224 -0
  246. package/foundation/discovery/doc-types.test.mjs +700 -0
  247. package/foundation/discovery/docs-discovery.d.mts +81 -0
  248. package/foundation/discovery/docs-discovery.mjs +57 -0
  249. package/foundation/discovery/integration-doc-files.d.mts +22 -0
  250. package/foundation/discovery/integration-doc-files.mjs +231 -0
  251. package/foundation/discovery/integration-doc-files.test.mjs +246 -0
  252. package/foundation/discovery/module-exports.d.mts +27 -0
  253. package/foundation/discovery/module-exports.mjs +356 -31
  254. package/foundation/discovery/module-exports.test.mjs +172 -0
  255. package/foundation/discovery/package-tsconfig.d.mts +14 -0
  256. package/foundation/discovery/package-tsconfig.mjs +228 -0
  257. package/foundation/discovery/package-tsconfig.test.mjs +210 -0
  258. package/foundation/discovery/project-typescript.d.mts +32 -0
  259. package/foundation/discovery/project-typescript.mjs +89 -0
  260. package/foundation/discovery/prop-drift.d.mts +278 -0
  261. package/foundation/discovery/prop-drift.mjs +2263 -0
  262. package/foundation/discovery/prop-drift.test.mjs +2272 -0
  263. package/foundation/discovery/template-adapter.mjs +74 -5
  264. package/foundation/discovery/type-match.d.mts +53 -0
  265. package/foundation/discovery/type-match.mjs +660 -0
  266. package/foundation/discovery/type-match.test.mjs +169 -0
  267. package/foundation/discovery/type-text.d.mts +68 -0
  268. package/foundation/discovery/type-text.mjs +658 -0
  269. package/foundation/discovery/type-text.test.mjs +196 -0
  270. package/foundation/discovery/unresolved-references.d.mts +62 -0
  271. package/foundation/discovery/unresolved-references.mjs +790 -0
  272. package/foundation/discovery/unresolved-references.test.mjs +567 -0
  273. package/foundation/doc-compiler/doc-loads.test.mjs +15 -1
  274. package/foundation/doc-compiler/inputs.mjs +23 -0
  275. package/foundation/doc-compiler/inputs.test.mjs +0 -1
  276. package/foundation/doc-compiler/links.d.mts +9 -5
  277. package/foundation/doc-compiler/links.mjs +4 -2
  278. package/foundation/env/package-manager.d.mts +32 -0
  279. package/foundation/env/package-manager.mjs +47 -0
  280. package/foundation/env/package-manager.test.mjs +194 -7
  281. package/foundation/fs/module-loader.d.mts +2 -1
  282. package/foundation/fs/module-loader.mjs +60 -4
  283. package/foundation/fs/module-loader.test.mjs +194 -0
  284. package/foundation/integrations/contribution-inventory.mjs +6 -1
  285. package/foundation/response/response-types.doc.mjs +13 -7
  286. package/foundation/xle/registry.mjs +4 -0
  287. package/foundation/xle/registry.test.mjs +28 -0
  288. package/package.json +10 -10
  289. package/scripts/postinstall.mjs +3 -3
@@ -27,6 +27,10 @@
27
27
  * files; an internal callback lets the CLI make only the process status fail.
28
28
  * Human progress is emitted through the shared `logger` (silent by default), so
29
29
  * the CLI keeps its exact output while a programmatic caller stays quiet.
30
+ * Every output a build writes, explicit or beside the theme file, stays inside
31
+ * `cwd` (`ERR_PATH_TRAVERSAL` otherwise). Check mode writes nothing, so it
32
+ * compares outputs outside `cwd` read-only; only a relative `out` path that
33
+ * escapes `cwd` is refused there too.
30
34
  *
31
35
  * The installed `@astryxdesign/core` is an independently versioned optional
32
36
  * peer, so it can be older than the CLI. A theme that uses only baseline
@@ -58,7 +62,10 @@ import {isBuiltin} from 'node:module';
58
62
  import {fileURLToPath, pathToFileURL} from 'node:url';
59
63
  import {parse} from '@babel/parser';
60
64
  import {createJiti} from 'jiti';
61
- import {getCliInvocation} from '../../../foundation/env/package-manager.mjs';
65
+ import {
66
+ formatCliCommand,
67
+ getCliInvocation,
68
+ } from '../../../foundation/env/package-manager.mjs';
62
69
  import {
63
70
  CLI_ROOT,
64
71
  findCoreDir,
@@ -270,6 +277,25 @@ function realOrSelf(file) {
270
277
  }
271
278
  }
272
279
 
280
+ /**
281
+ * `target` spelled through real directories: the deepest ancestor that exists
282
+ * is resolved through its symlinks, and the missing rest is appended as given.
283
+ * @param {string} target absolute path
284
+ * @returns {string}
285
+ */
286
+ function realLocation(target) {
287
+ /** @type {string[]} */
288
+ const missing = [];
289
+ let existing = target;
290
+ while (!fs.existsSync(existing)) {
291
+ const parent = path.dirname(existing);
292
+ if (parent === existing) break;
293
+ missing.unshift(path.basename(existing));
294
+ existing = parent;
295
+ }
296
+ return path.join(realOrSelf(existing), ...missing);
297
+ }
298
+
273
299
  /**
274
300
  * The Core the project at `cwd` installed, when it differs from the one the
275
301
  * CLI's own import found and loads. The app's `<Theme>` runs on the app's
@@ -506,6 +532,127 @@ function checkedBuildOutputs(writes, cwd) {
506
532
  .map(write => path.relative(cwd, write.dest));
507
533
  }
508
534
 
535
+ /** Remedies that end a confinement error, by where the output path came from. */
536
+ const OUT_REMEDY = 'Pass an --out path inside it.';
537
+ const SOURCE_REMEDY =
538
+ 'Without --out the outputs go beside the theme file, so run the build from a directory that contains the theme file, or pass an --out path inside the working directory.';
539
+ const FAMILY_REMEDY =
540
+ "Family outputs go beside the family's root theme file, so run the build from a directory that contains it.";
541
+
542
+ /**
543
+ * Refuse an output outside `root`: every write is confined, whether `out` names
544
+ * the path or it defaults to the theme file's directory (architecture:cli-surface
545
+ * INV10). Both sides are compared by real location, so an absolute path that
546
+ * reaches the working directory through a symlink is inside it, and a symlink
547
+ * inside it that leads elsewhere is not.
548
+ * @param {string} dest absolute output path
549
+ * @param {string} root the directory writes stay inside: the working directory
550
+ * @param {string} remedy what to do instead; ends the error message
551
+ * @param {string} [shown] the path as the caller wrote it, for the message
552
+ */
553
+ function confineOutput(dest, root, remedy, shown = dest) {
554
+ try {
555
+ assertWithin(realLocation(dest), realOrSelf(path.resolve(root)), {
556
+ allowAbsolute: true,
557
+ label: 'output path',
558
+ });
559
+ } catch (err) {
560
+ if (!(err instanceof PathSafetyError)) throw err;
561
+ throw new AstryxError(
562
+ err.code === ERROR_CODES.ERR_PATH_TRAVERSAL
563
+ ? `Output path "${shown}" is outside the working directory (${root}). ${remedy}`
564
+ : err.message,
565
+ undefined,
566
+ ERROR_CODES.ERR_PATH_TRAVERSAL,
567
+ );
568
+ }
569
+ }
570
+
571
+ /** @param {Array<{dest: string}>} writes @param {string} root @param {string} remedy */
572
+ function confineOutputs(writes, root, remedy) {
573
+ for (const write of writes) confineOutput(write.dest, root, remedy);
574
+ }
575
+
576
+ /** @param {string} dest absolute output path @param {string} root @returns {boolean} whether a build at `root` refuses to write `dest` */
577
+ function refusedOutput(dest, root) {
578
+ try {
579
+ confineOutput(dest, root, '');
580
+ return false;
581
+ } catch (err) {
582
+ if (
583
+ err instanceof AstryxError &&
584
+ err.code === ERROR_CODES.ERR_PATH_TRAVERSAL
585
+ )
586
+ return true;
587
+ throw err;
588
+ }
589
+ }
590
+
591
+ /** @param {string[]} dirs absolute directories @returns {string | null} the deepest directory containing all of them, or null across roots */
592
+ function commonDirectory(dirs) {
593
+ let common = dirs[0];
594
+ for (const dir of dirs.slice(1)) {
595
+ while (
596
+ path.relative(common, dir).startsWith('..') ||
597
+ path.isAbsolute(path.relative(common, dir))
598
+ ) {
599
+ const parent = path.dirname(common);
600
+ if (parent === common) return null;
601
+ common = parent;
602
+ }
603
+ }
604
+ return common;
605
+ }
606
+
607
+ /** @param {string} value @returns {string} `value` as one shell word */
608
+ function shellWord(value) {
609
+ if (/^[A-Za-z0-9@%+=:,./_-]+$/.test(value)) return value;
610
+ return `'${value.replace(/'/g, `'\\''`)}'`;
611
+ }
612
+
613
+ /**
614
+ * How a stale check report ends when outputs sit outside the write root. A
615
+ * build there refuses them, and each output's `Source:` header records the
616
+ * directory its build ran from, so the build and the check both run from the
617
+ * nearest directory that contains every theme file and output.
618
+ * @param {Array<{dest: string}>} writes
619
+ * @param {string[]} sources absolute theme files the build reads
620
+ * @param {string} root the directory a build here keeps its writes inside
621
+ * @param {(relative: (file: string) => string) => string[]} args the arguments after `theme build`, given each path relative to the directory to run from
622
+ * @returns {string[] | null} report lines, or null when every output is inside `root`
623
+ */
624
+ function outsideCheckRemedy(writes, sources, root, args) {
625
+ if (!writes.some(write => refusedOutput(write.dest, root))) return null;
626
+ const real = (/** @type {string} */ file) => realLocation(path.resolve(file));
627
+ const dir = commonDirectory([
628
+ ...sources.map(file => path.dirname(real(file))),
629
+ ...writes.map(write => path.dirname(real(write.dest))),
630
+ ]);
631
+ if (!dir) {
632
+ return [
633
+ 'These outputs are outside the working directory, so a build here refuses them. Build and check them from one directory that contains the theme files and the outputs.',
634
+ ];
635
+ }
636
+ const command = (/** @type {string[]} */ extra) =>
637
+ formatCliCommand(
638
+ [
639
+ 'theme',
640
+ 'build',
641
+ ...args(file => path.relative(dir, real(file))),
642
+ ...extra,
643
+ ]
644
+ .map(shellWord)
645
+ .join(' '),
646
+ dir,
647
+ );
648
+ return [
649
+ 'These outputs are outside the working directory, so a build here refuses them, and each output records the directory it was built from. Build and check them from a directory that contains them:',
650
+ ` cd ${shellWord(dir)}`,
651
+ ` ${command([])}`,
652
+ ` ${command(['--check'])}`,
653
+ ];
654
+ }
655
+
509
656
  /** @param {Array<{dest: string, content: string}>} writes */
510
657
  function writeBuildOutputs(writes) {
511
658
  if (writes.length === 0) return;
@@ -2344,9 +2491,10 @@ function validateHeadingTypeAugmentationSupport(themeDef) {
2344
2491
  * `logger` (silent by default).
2345
2492
  *
2346
2493
  * @param {string} file - Theme file path, resolved against `cwd`.
2347
- * @param {{out?: string, check?: boolean, iconsSpecifier?: string, __prepareFamily?: boolean, __familyLoader?: any, __familyInterception?: any, __onPrivateVarError?: () => void}} [options] -
2494
+ * @param {{out?: string, check?: boolean, iconsSpecifier?: string, __prepareFamily?: boolean, __familyLoader?: any, __familyInterception?: any, __onPrivateVarError?: () => void, __writeRoot?: string}} [options] -
2348
2495
  * `out` overrides the output CSS path; `check` compares against on-disk outputs
2349
- * instead of writing. `iconsSpecifier` overrides the icon registry import
2496
+ * instead of writing. `__writeRoot` replaces `cwd` as the directory every
2497
+ * output must stay inside, for a CLI-internal scratch build. `iconsSpecifier` overrides the icon registry import
2350
2498
  * specifier in the generated module (e.g. `./icons.mjs`); when omitted, the
2351
2499
  * direct registry specifiers from the theme source are emitted unchanged.
2352
2500
  * @param {{cwd?: string}} [ctx]
@@ -2791,24 +2939,17 @@ async function themeBuildInternal(
2791
2939
  // Derive the default CSS name from the theme name so .css/.js/.d.ts
2792
2940
  // share one scheme; an explicit --out still wins.
2793
2941
  const baseName = themeDef.name;
2942
+ // Every write stays inside cwd. A CLI-internal caller that renders into a
2943
+ // scratch directory it creates and removes names that directory instead.
2944
+ const writeRoot = options.__writeRoot ?? cwd;
2794
2945
  let outPath;
2795
2946
  if (options.out) {
2796
2947
  outPath = path.resolve(cwd, options.out);
2797
- // Guard: relative paths must not escape cwd via `../`. Absolute paths are
2798
- // trusted (the user explicitly controls where output goes, like gcc -o).
2799
- if (!path.isAbsolute(options.out)) {
2800
- try {
2801
- assertWithin(options.out, cwd, {label: 'output path'});
2802
- } catch (err) {
2803
- if (err instanceof PathSafetyError) {
2804
- throw new AstryxError(
2805
- err.message,
2806
- undefined,
2807
- ERROR_CODES.ERR_PATH_TRAVERSAL,
2808
- );
2809
- }
2810
- throw err;
2811
- }
2948
+ // A build keeps the explicit output inside the write root, relative or
2949
+ // absolute. Check mode writes nothing, so it refuses only a relative path
2950
+ // that escapes cwd.
2951
+ if (!options.check || !path.isAbsolute(options.out)) {
2952
+ confineOutput(outPath, writeRoot, OUT_REMEDY, options.out);
2812
2953
  }
2813
2954
  } else {
2814
2955
  outPath = path.join(path.dirname(filePath), `${baseName}.css`);
@@ -2905,6 +3046,13 @@ async function themeBuildInternal(
2905
3046
  writes.push({dest: variantDtsPath, content: variantContent});
2906
3047
  }
2907
3048
 
3049
+ // Every output a build writes stays inside cwd, including the defaults
3050
+ // beside the theme file. Check mode writes nothing, so it compares outputs
3051
+ // outside cwd read-only.
3052
+ if (!options.check) {
3053
+ confineOutputs(writes, writeRoot, options.out ? OUT_REMEDY : SOURCE_REMEDY);
3054
+ }
3055
+
2908
3056
  // Check mode: compare generated content against what's on disk instead of
2909
3057
  // writing. A file is "stale" if it's missing or its content differs once the
2910
3058
  // volatile @generated `Command:` line is ignored. Returns a
@@ -2923,7 +3071,10 @@ async function themeBuildInternal(
2923
3071
  ` ${s.reason === 'missing' ? 'missing' : 'stale'}: ${s.path}`,
2924
3072
  );
2925
3073
  }
2926
- logger.error(`\n Rebuild with: ${buildCommand}`);
3074
+ // prettier-ignore
3075
+ const remedy = outsideCheckRemedy(writes, [filePath], writeRoot, relative => [relative(filePath), ...(options.out ? ['--out', relative(outPath)] : []), ...(options.iconsSpecifier ? ['--icons-specifier', options.iconsSpecifier] : [])]);
3076
+ if (remedy) logger.error(`\n ${remedy.join('\n ')}`);
3077
+ else logger.error(`\n Rebuild with: ${buildCommand}`);
2927
3078
  }
2928
3079
  return {
2929
3080
  type: 'theme.build.check',
@@ -3036,7 +3187,7 @@ function printBuildTrailer(trailer) {
3036
3187
  logger.log(`
3037
3188
  Install in your app (paths are relative to a file in src/; adjust if yours lives elsewhere):
3038
3189
 
3039
- import { Theme } from '@astryxdesign/core';
3190
+ import { Theme } from '@astryxdesign/core/theme';
3040
3191
  import { ${trailer.exportName} } from '${trailer.jsImport}';
3041
3192
  import '${trailer.cssImport}';
3042
3193
 
@@ -3046,7 +3197,7 @@ Install in your app (paths are relative to a file in src/; adjust if yours lives
3046
3197
 
3047
3198
  Or with a <link> tag:
3048
3199
 
3049
- import { Theme } from '@astryxdesign/core';
3200
+ import { Theme } from '@astryxdesign/core/theme';
3050
3201
  import { ${trailer.exportName} } from '${trailer.jsImport}';
3051
3202
 
3052
3203
  <link rel="stylesheet" href="${trailer.cssImport}" />
@@ -3072,7 +3223,7 @@ export function printBatchTrailer(trailers) {
3072
3223
  logger.log(`
3073
3224
  Install in your app (paths are relative to a file in src/; adjust if yours lives elsewhere):
3074
3225
 
3075
- import { Theme } from '@astryxdesign/core';
3226
+ import { Theme } from '@astryxdesign/core/theme';
3076
3227
  import { ${first.exportName} } from '${first.jsImport}';
3077
3228
  import '${first.cssImport}';
3078
3229
 
@@ -3082,7 +3233,7 @@ Install in your app (paths are relative to a file in src/; adjust if yours lives
3082
3233
 
3083
3234
  Or with a <link> tag:
3084
3235
 
3085
- import { Theme } from '@astryxdesign/core';
3236
+ import { Theme } from '@astryxdesign/core/theme';
3086
3237
  import { ${first.exportName} } from '${first.jsImport}';
3087
3238
 
3088
3239
  <link rel="stylesheet" href="${first.cssImport}" />
@@ -3449,6 +3600,8 @@ export async function themeBuildFamily(
3449
3600
  js: path.relative(cwd, jsPath),
3450
3601
  dts: path.relative(cwd, dtsPath),
3451
3602
  };
3603
+ // A family build's outputs stay inside cwd too; check mode only reads them.
3604
+ if (!options.check) confineOutputs(writes, cwd, FAMILY_REMEDY);
3452
3605
  if (options.check) {
3453
3606
  const stale = staleBuildOutputs(writes, cwd);
3454
3607
  const upToDate = stale.length === 0;
@@ -3465,7 +3618,10 @@ export async function themeBuildFamily(
3465
3618
  ` ${entry.reason === 'missing' ? 'missing' : 'stale'}: ${entry.path}`,
3466
3619
  );
3467
3620
  }
3468
- logger.error(`\n Rebuild with: ${buildCommand}`);
3621
+ // prettier-ignore
3622
+ const remedy = outsideCheckRemedy(writes, members.map(member => member.filePath), cwd, relative => ['--family', ...members.map(member => relative(member.filePath)), '--family-key', baseName, ...(options.iconsSpecifier ? ['--icons-specifier', options.iconsSpecifier] : [])]);
3623
+ if (remedy) logger.error(`\n ${remedy.join('\n ')}`);
3624
+ else logger.error(`\n Rebuild with: ${buildCommand}`);
3469
3625
  }
3470
3626
  return {
3471
3627
  type: 'theme.build.check',
@@ -58,13 +58,13 @@ export const doc = {
58
58
  name: 'options.out',
59
59
  type: 'string',
60
60
  description:
61
- 'Override the output CSS path. The .js, .d.ts and any .variants.d.ts are written in the same directory, named after the theme (<name>.js), not after the CSS file. A relative path must stay within cwd.',
61
+ 'Override the output CSS path, relative or absolute; a build refuses a path outside cwd, and check mode refuses only a relative path that escapes cwd. The .js, .d.ts and any .variants.d.ts are written in the same directory, named after the theme (<name>.js), not after the CSS file.',
62
62
  },
63
63
  {
64
64
  name: 'options.check',
65
65
  type: 'boolean',
66
66
  description:
67
- 'Compile in memory and compare each output against what is on disk instead of writing: the CI drift guard.',
67
+ 'Compile in memory and compare each output against what is on disk instead of writing: the CI drift guard. Because it writes nothing, it also compares outputs outside cwd; when those are stale, the report names the directory that contains them and the build and check commands to run from there, since a build refuses them and each output records the directory it was built from.',
68
68
  default: 'false',
69
69
  },
70
70
  {
@@ -77,7 +77,7 @@ export const doc = {
77
77
  name: 'ctx.cwd',
78
78
  type: 'string',
79
79
  description:
80
- 'Directory the theme file, a relative out path, and the returned output paths resolve against.',
80
+ 'Directory the theme file, a relative out path, and the returned output paths resolve against. Every output a build writes is inside it, including the default outputs beside the theme file.',
81
81
  default: 'process.cwd()',
82
82
  },
83
83
  ],
@@ -105,7 +105,7 @@ export const doc = {
105
105
  },
106
106
  {
107
107
  code: 'ERR_PATH_TRAVERSAL',
108
- when: 'the theme name contains a path separator or traversal marker, or a relative `out` path resolves outside cwd (including through a symlink)',
108
+ when: 'the theme name contains a path separator or traversal marker, or a written output resolves outside cwd (including through a symlink): an `out` path, relative or absolute, or the default outputs beside a theme file outside cwd. Check mode writes nothing, so it refuses only a relative `out` path that escapes cwd',
109
109
  },
110
110
  {
111
111
  code: 'ERR_CORE_NOT_FOUND',
@@ -31,6 +31,43 @@ export function detectInstalledTargetVersion(cwd: string): {
31
31
  version: string;
32
32
  packageName: string;
33
33
  } | null;
34
+ /**
35
+ * Whether the installed Core is newer than this CLI, so part of the requested
36
+ * range has no codemods here.
37
+ *
38
+ * Core codemods ship inside the CLI. A CLI older than the installed
39
+ * `@astryxdesign/core` has none for the releases after its own version, so it
40
+ * can find no codemods, or stop partway, while the code still needs those
41
+ * releases' migrations. The returned command repeats this upgrade with the CLI
42
+ * release that matches the installed Core.
43
+ *
44
+ * Where an upgrade runs decides what it finds: the installed Core is read
45
+ * from that folder, and `--path` must stay inside it. So the command first
46
+ * changes to `cwd`, the folder this run used, then names `sourcePath`, the
47
+ * directory this run scanned, as an absolute `--path`. Both are named by their
48
+ * physical paths, with every symbolic link resolved: a shell's `cd` follows a
49
+ * link, but the CLI it starts reads its folder with every link resolved and
50
+ * checks `--path` against that. Pasted from any folder, the command finds the
51
+ * same Core and scans the same directory, even after a package runner moved
52
+ * this run (Yarn 1 runs `yarn astryx` at the project root). It is written for
53
+ * a POSIX shell, or for PowerShell on Windows (cmd.exe is not a target), with
54
+ * every argument quoted for that shell.
55
+ *
56
+ * Returns null when the CLI covers the whole range (`to` is not newer than
57
+ * both the CLI and `from`), when the CLI's own version cannot be read, or when
58
+ * the target is legacy `@xds/core`, which no CLI release shares a version with.
59
+ *
60
+ * @param {{from: string, to: string, packageName: string, options: UpgradeOptions, cwd: string, sourcePath: string}} input
61
+ * @returns {import('./upgrade.type.mjs').CliBehindCore | null}
62
+ */
63
+ export function detectCliBehindCore({ from, to, packageName, options, cwd, sourcePath, }: {
64
+ from: string;
65
+ to: string;
66
+ packageName: string;
67
+ options: UpgradeOptions;
68
+ cwd: string;
69
+ sourcePath: string;
70
+ }): import("./upgrade.type.mjs").CliBehindCore | null;
34
71
  /**
35
72
  * @param {(string | null | undefined | false)[] | undefined} files
36
73
  * @returns {string[]}
@@ -104,9 +141,9 @@ export function ensureCodemodDeps({ installDeps }?: {
104
141
  * Run the CORE registry codemods. Runs BEFORE the config is loaded so a core
105
142
  * CONFIG codemod can repair a config the strict loader would otherwise reject.
106
143
  * @param {CoreVersionManifest[]} versionManifests
107
- * @param {{apply: boolean, path: string, codemod?: string, skipCodemods: Set<string>, root?: string, protection?: {root: string, classify: (file: string) => import('../../foundation/fs/file-protection.mjs').FileProtection[]}, silent?: boolean}} options
144
+ * @param {{apply: boolean, path: string, codemod?: string, skipCodemods: Set<string>, root?: string, protection?: {root: string, classify: (file: string) => import('../../foundation/fs/file-protection.mjs').FileProtection[]}, silent?: boolean, coversTarget?: boolean}} options
108
145
  */
109
- export function runCoreCodemods(versionManifests: CoreVersionManifest[], { apply, path: srcPath, codemod, skipCodemods, root, protection, silent }: {
146
+ export function runCoreCodemods(versionManifests: CoreVersionManifest[], { apply, path: srcPath, codemod, skipCodemods, root, protection, silent, coversTarget, }: {
110
147
  apply: boolean;
111
148
  path: string;
112
149
  codemod?: string;
@@ -117,6 +154,7 @@ export function runCoreCodemods(versionManifests: CoreVersionManifest[], { apply
117
154
  classify: (file: string) => import("../../foundation/fs/file-protection.mjs").FileProtection[];
118
155
  };
119
156
  silent?: boolean;
157
+ coversTarget?: boolean;
120
158
  }): Promise<{
121
159
  totalFilesChanged: number;
122
160
  totalTransformsApplied: number;
@@ -34,7 +34,15 @@ import {
34
34
  inspectAgentDocs,
35
35
  renderAgentDocsBlock,
36
36
  } from '../../foundation/agent-docs/agent-docs.mjs';
37
- import {formatCliCommand} from '../../foundation/env/package-manager.mjs';
37
+ import {
38
+ CLI_PACKAGE,
39
+ commandInFolder,
40
+ formatCliCommand,
41
+ getDlxPrefix,
42
+ quoteCommandArgument,
43
+ } from '../../foundation/env/package-manager.mjs';
44
+ import {isValidSemver, semverGt} from '../../foundation/env/semver.mjs';
45
+ import {CLI_ROOT} from '../../foundation/fs/paths.mjs';
38
46
  import {Project, providerLedgerOf} from '../../foundation/config/project.mjs';
39
47
  import {loadIntegrations} from '../../foundation/integrations/integrations.mjs';
40
48
  import {resolveProviders} from '../../foundation/integrations/provider-resolution.mjs';
@@ -96,6 +104,99 @@ export function detectInstalledTargetVersion(cwd) {
96
104
  return null;
97
105
  }
98
106
 
107
+ /**
108
+ * The running CLI's own version, read from its package.json.
109
+ * @returns {string | null} null when it cannot be read or is not semver
110
+ */
111
+ function readRunningCliVersion() {
112
+ try {
113
+ const pkg = JSON.parse(
114
+ fs.readFileSync(path.join(CLI_ROOT, 'package.json'), 'utf-8'),
115
+ );
116
+ return isValidSemver(pkg.version) ? pkg.version : null;
117
+ } catch {
118
+ return null;
119
+ }
120
+ }
121
+
122
+ /**
123
+ * Whether the installed Core is newer than this CLI, so part of the requested
124
+ * range has no codemods here.
125
+ *
126
+ * Core codemods ship inside the CLI. A CLI older than the installed
127
+ * `@astryxdesign/core` has none for the releases after its own version, so it
128
+ * can find no codemods, or stop partway, while the code still needs those
129
+ * releases' migrations. The returned command repeats this upgrade with the CLI
130
+ * release that matches the installed Core.
131
+ *
132
+ * Where an upgrade runs decides what it finds: the installed Core is read
133
+ * from that folder, and `--path` must stay inside it. So the command first
134
+ * changes to `cwd`, the folder this run used, then names `sourcePath`, the
135
+ * directory this run scanned, as an absolute `--path`. Both are named by their
136
+ * physical paths, with every symbolic link resolved: a shell's `cd` follows a
137
+ * link, but the CLI it starts reads its folder with every link resolved and
138
+ * checks `--path` against that. Pasted from any folder, the command finds the
139
+ * same Core and scans the same directory, even after a package runner moved
140
+ * this run (Yarn 1 runs `yarn astryx` at the project root). It is written for
141
+ * a POSIX shell, or for PowerShell on Windows (cmd.exe is not a target), with
142
+ * every argument quoted for that shell.
143
+ *
144
+ * Returns null when the CLI covers the whole range (`to` is not newer than
145
+ * both the CLI and `from`), when the CLI's own version cannot be read, or when
146
+ * the target is legacy `@xds/core`, which no CLI release shares a version with.
147
+ *
148
+ * @param {{from: string, to: string, packageName: string, options: UpgradeOptions, cwd: string, sourcePath: string}} input
149
+ * @returns {import('./upgrade.type.mjs').CliBehindCore | null}
150
+ */
151
+ export function detectCliBehindCore({
152
+ from,
153
+ to,
154
+ packageName,
155
+ options,
156
+ cwd,
157
+ sourcePath,
158
+ }) {
159
+ if (packageName !== '@astryxdesign/core') return null;
160
+ const cliVersion = readRunningCliVersion();
161
+ if (!cliVersion || !semverGt(to, cliVersion) || !semverGt(to, from)) {
162
+ return null;
163
+ }
164
+ const runFolder = path.resolve(cwd);
165
+ const folder = physicalFolder(runFolder);
166
+ const scanned = path.join(folder, path.relative(runFolder, sourcePath));
167
+ const args = ['upgrade', '--from', from, '--path', scanned];
168
+ if (options.codemod) args.push('--codemod', options.codemod);
169
+ for (const name of options.skipCodemod ?? []) {
170
+ args.push('--skip-codemod', name);
171
+ }
172
+ for (const spec of options.integration ?? []) {
173
+ args.push('--integration', spec);
174
+ }
175
+ if (options.force) args.push('--force');
176
+ if (options.installDeps) args.push('--install-deps');
177
+ if (options.apply) args.push('--apply');
178
+ const upgrade = [
179
+ getDlxPrefix(cwd),
180
+ ...[`${CLI_PACKAGE}@${to}`, ...args].map(arg => quoteCommandArgument(arg)),
181
+ ].join(' ');
182
+ return {cliVersion, command: commandInFolder(folder, upgrade)};
183
+ }
184
+
185
+ /**
186
+ * A folder as the operating system reports it to a process that runs there,
187
+ * with every symbolic link on the way resolved. Falls back to the path as
188
+ * given when it cannot be resolved.
189
+ * @param {string} dir an absolute folder
190
+ * @returns {string}
191
+ */
192
+ function physicalFolder(dir) {
193
+ try {
194
+ return fs.realpathSync(dir);
195
+ } catch {
196
+ return dir;
197
+ }
198
+ }
199
+
99
200
  /**
100
201
  * @param {(string | null | undefined | false)[] | undefined} files
101
202
  * @returns {string[]}
@@ -332,11 +433,20 @@ export async function ensureCodemodDeps({installDeps} = {}) {
332
433
  * Run the CORE registry codemods. Runs BEFORE the config is loaded so a core
333
434
  * CONFIG codemod can repair a config the strict loader would otherwise reject.
334
435
  * @param {CoreVersionManifest[]} versionManifests
335
- * @param {{apply: boolean, path: string, codemod?: string, skipCodemods: Set<string>, root?: string, protection?: {root: string, classify: (file: string) => import('../../foundation/fs/file-protection.mjs').FileProtection[]}, silent?: boolean}} options
436
+ * @param {{apply: boolean, path: string, codemod?: string, skipCodemods: Set<string>, root?: string, protection?: {root: string, classify: (file: string) => import('../../foundation/fs/file-protection.mjs').FileProtection[]}, silent?: boolean, coversTarget?: boolean}} options
336
437
  */
337
438
  export async function runCoreCodemods(
338
439
  versionManifests,
339
- {apply, path: srcPath, codemod, skipCodemods, root, protection, silent},
440
+ {
441
+ apply,
442
+ path: srcPath,
443
+ codemod,
444
+ skipCodemods,
445
+ root,
446
+ protection,
447
+ silent,
448
+ coversTarget,
449
+ },
340
450
  ) {
341
451
  return runCodemods(versionManifests, {
342
452
  apply,
@@ -346,6 +456,7 @@ export async function runCoreCodemods(
346
456
  silent: silent ?? logger.silent,
347
457
  root,
348
458
  protection,
459
+ coversTarget,
349
460
  });
350
461
  }
351
462
 
@@ -411,7 +522,9 @@ export async function loadProjectContext(cwd, extraIntegrationSpecs = []) {
411
522
  const extras =
412
523
  extraSpecs.length === 0
413
524
  ? []
414
- : await loadIntegrations(extraSpecs, {resolveProviders: false});
525
+ : // Resolved from the project, as --integration names a package it
526
+ // installed, not from whichever folder the process started in.
527
+ await loadIntegrations(extraSpecs, {cwd, resolveProviders: false});
415
528
  const {integrations, ledger} = resolveProviders(
416
529
  [
417
530
  ...candidates,