@astryxdesign/cli 0.7.2-canary.55d8dff → 0.7.2-canary.577a62e

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 (404) hide show
  1. package/README.md +163 -143
  2. package/api/build/_adapter.d.mts +8 -0
  3. package/api/build/_adapter.mjs +12 -1
  4. package/api/build/build.doc.mjs +4 -0
  5. package/api/build/kit/kit.mjs +3 -11
  6. package/api/component/_adapter.d.mts +31 -0
  7. package/api/component/_adapter.mjs +119 -11
  8. package/api/component/component.doc.mjs +6 -1
  9. package/api/component/component.mjs +60 -10
  10. package/api/component/doc-links.test.mjs +386 -0
  11. package/api/discover/_adapter.d.mts +132 -12
  12. package/api/discover/_adapter.mjs +488 -27
  13. package/api/discover/_adapter.test.mjs +599 -17
  14. package/api/discover/_catalog-view.d.mts +16 -5
  15. package/api/discover/_catalog-view.mjs +32 -8
  16. package/api/discover/detail/doc/doc.mjs +9 -1
  17. package/api/discover/discover.d.mts +11 -0
  18. package/api/discover/discover.doc.mjs +9 -7
  19. package/api/discover/discover.mjs +121 -19
  20. package/api/discover/discover.type.d.mts +20 -7
  21. package/api/discover/discover.type.mjs +17 -7
  22. package/api/discover/list/list.d.mts +4 -3
  23. package/api/discover/list/list.mjs +17 -10
  24. package/api/docs/_adapter.d.mts +63 -0
  25. package/api/docs/_adapter.mjs +312 -18
  26. package/api/docs/docs.doc.mjs +2 -1
  27. package/api/docs/docs.mjs +2 -1
  28. package/api/docs/docs.test.mjs +5 -2
  29. package/api/docs/integration-tree.test.mjs +22 -0
  30. package/api/docs/list/list.mjs +12 -2
  31. package/api/docs/reference-blocks.test.mjs +1 -3
  32. package/api/doctor/_adapter.d.mts +108 -0
  33. package/api/doctor/_adapter.mjs +223 -4
  34. package/api/doctor/doctor.d.mts +199 -0
  35. package/api/doctor/doctor.doc.mjs +3 -2
  36. package/api/doctor/doctor.mjs +503 -31
  37. package/api/doctor/doctor.test.mjs +137 -14
  38. package/api/doctor/release-checks.test.mjs +156 -0
  39. package/api/doctor/theme-checks.mjs +16 -3
  40. package/api/doctor/theme-checks.test.mjs +223 -7
  41. package/api/error.d.mts +10 -0
  42. package/api/error.mjs +25 -0
  43. package/api/gap-report/gap-report.d.mts +3 -0
  44. package/api/gap-report/gap-report.doc.mjs +11 -3
  45. package/api/gap-report/gap-report.mjs +152 -48
  46. package/api/gap-report/gap-report.test.mjs +233 -0
  47. package/api/gap-report/gap-report.type.d.mts +41 -0
  48. package/api/gap-report/gap-report.type.mjs +18 -0
  49. package/api/hook/_adapter.mjs +3 -11
  50. package/api/hook/hook.doc.mjs +4 -0
  51. package/api/hook/list/list.d.mts +1 -1
  52. package/api/init/_adapter.d.mts +22 -0
  53. package/api/init/_adapter.mjs +59 -0
  54. package/api/init/init.d.mts +7 -5
  55. package/api/init/init.doc.mjs +28 -7
  56. package/api/init/init.mjs +28 -4
  57. package/api/init/init.type.d.mts +48 -3
  58. package/api/init/init.type.mjs +37 -3
  59. package/api/init/run/run.d.mts +1 -1
  60. package/api/init/run/run.mjs +15 -4
  61. package/api/init/user/user.d.mts +14 -0
  62. package/api/init/user/user.mjs +87 -0
  63. package/api/init/user/user.test.mjs +232 -0
  64. package/api/integration/_adapter.d.mts +33 -0
  65. package/api/integration/_adapter.mjs +58 -0
  66. package/api/integration/authoring-checks.mjs +100 -5
  67. package/api/integration/authoring-checks.test.mjs +769 -0
  68. package/api/integration/authoring-checks.type.d.mts +134 -0
  69. package/api/integration/authoring-checks.type.mjs +60 -1
  70. package/api/integration/integrationCheck.doc.mjs +1 -1
  71. package/api/integration/integrationComponentConflicts.doc.mjs +3 -1
  72. package/api/integration/integrationDocConflicts.doc.mjs +22 -5
  73. package/api/integration/pack-check.mjs +303 -13
  74. package/api/integration/pack-check.test.mjs +371 -10
  75. package/api/integration/validate-integration-fixes.test.mjs +67 -0
  76. package/api/integration/validate-integration.d.mts +8 -0
  77. package/api/integration/validate-integration.mjs +55 -9
  78. package/api/integration/validate-integration.test.mjs +77 -8
  79. package/api/integration/validate-integration.type.d.mts +8 -0
  80. package/api/integration/validate-integration.type.mjs +3 -1
  81. package/api/integration/validate-unread-theme-folders.test.mjs +3 -2
  82. package/api/integration/validateIntegration.doc.mjs +1 -1
  83. package/api/search/_adapter.d.mts +11 -0
  84. package/api/search/_adapter.mjs +25 -0
  85. package/api/search/search.d.mts +10 -8
  86. package/api/search/search.doc.mjs +8 -3
  87. package/api/search/search.mjs +130 -57
  88. package/api/search/search.test.mjs +15 -1
  89. package/api/search/search.type.d.mts +14 -1
  90. package/api/search/search.type.mjs +6 -1
  91. package/api/swizzle/_adapter.mjs +2 -2
  92. package/api/swizzle/copy/copy.mjs +1 -1
  93. package/api/template/template-integration.test.mjs +1 -1
  94. package/api/theme/_adapter.d.mts +16 -0
  95. package/api/theme/_adapter.mjs +32 -5
  96. package/api/theme/build/build.d.mts +2 -1
  97. package/api/theme/build/build.mjs +70 -14
  98. package/api/theme/build/build.packed-old-core.test.mjs +20 -3
  99. package/api/theme/build/font-warning.mjs +5 -3
  100. package/api/theme/build/font-warning.test.mjs +2 -1
  101. package/api/theme/remove/remove.test.mjs +2 -2
  102. package/api/theme/targets/targets.mjs +3 -10
  103. package/api/theme/themeTargets.doc.mjs +4 -0
  104. package/api/theme/use/use.test.mjs +1 -1
  105. package/api/upgrade/_adapter.d.mts +40 -2
  106. package/api/upgrade/_adapter.mjs +118 -5
  107. package/api/upgrade/run/cli-behind-core.test.mjs +438 -0
  108. package/api/upgrade/run/run.mjs +35 -2
  109. package/api/upgrade/status/status.d.mts +21 -5
  110. package/api/upgrade/status/status.mjs +45 -8
  111. package/api/upgrade/upgrade.doc.mjs +6 -3
  112. package/api/upgrade/upgrade.mjs +5 -1
  113. package/api/upgrade/upgrade.type.d.mts +23 -0
  114. package/api/upgrade/upgrade.type.mjs +16 -1
  115. package/assets/codemods/runner.mjs +7 -1
  116. package/assets/discover/official-packages.json +367 -0
  117. package/assets/docs/author-a-theme.doc.mjs +2 -2
  118. package/assets/docs/browser-support.doc.mjs +1 -1
  119. package/assets/docs/getting-started.doc.mjs +23 -3
  120. package/assets/docs/styling-overview.doc.mjs +1 -1
  121. package/assets/docs/theme.doc.mjs +1 -1
  122. package/assets/docs/tree/add-a-component.doc.mjs +11 -1
  123. package/assets/docs/tree/add-a-theme.doc.mjs +12 -2
  124. package/assets/docs/tree/add-a-topic.doc.mjs +46 -4
  125. package/assets/docs/tree/agent-guidance.doc.mjs +18 -4
  126. package/assets/docs/tree/building-blocks.doc.mjs +4 -0
  127. package/assets/docs/tree/check-the-props.doc.mjs +8 -3
  128. package/assets/docs/tree/check-your-docs.doc.mjs +20 -8
  129. package/assets/docs/tree/checks.doc.mjs +14 -14
  130. package/assets/docs/tree/ci-and-containers.doc.mjs +88 -0
  131. package/assets/docs/tree/cli-command.doc.mjs +142 -0
  132. package/assets/docs/tree/cli.doc.mjs +6 -0
  133. package/assets/docs/tree/codemods.doc.mjs +13 -3
  134. package/assets/docs/tree/commands.doc.mjs +7 -1
  135. package/assets/docs/tree/component-imports.doc.mjs +11 -1
  136. package/assets/docs/tree/components.doc.mjs +6 -0
  137. package/assets/docs/tree/computer-agent-guide.doc.mjs +160 -0
  138. package/assets/docs/tree/computer-integrations.doc.mjs +93 -0
  139. package/assets/docs/tree/configuration.doc.mjs +7 -3
  140. package/assets/docs/tree/debug-and-gap-reports.doc.mjs +36 -6
  141. package/assets/docs/tree/define-the-theme.doc.mjs +1 -1
  142. package/assets/docs/tree/describe-the-component.doc.mjs +1 -1
  143. package/assets/docs/tree/docs.doc.mjs +6 -0
  144. package/assets/docs/tree/document-the-theme.doc.mjs +2 -2
  145. package/assets/docs/tree/extend-or-replace.doc.mjs +13 -3
  146. package/assets/docs/tree/generate-a-palette.doc.mjs +2 -2
  147. package/assets/docs/tree/global-integrations.doc.mjs +124 -0
  148. package/assets/docs/tree/global.doc.mjs +131 -0
  149. package/assets/docs/tree/grade-template-with-agent.doc.mjs +4 -4
  150. package/assets/docs/tree/install-once.doc.mjs +105 -0
  151. package/assets/docs/tree/integrations.doc.mjs +5 -1
  152. package/assets/docs/tree/layout-spacing.doc.mjs +2 -3
  153. package/assets/docs/tree/layout.doc.mjs +6 -6
  154. package/assets/docs/tree/links.doc.mjs +1 -1
  155. package/assets/docs/tree/migration-setup.doc.mjs +2 -2
  156. package/assets/docs/tree/monorepos.doc.mjs +84 -0
  157. package/assets/docs/tree/problems.doc.mjs +205 -0
  158. package/assets/docs/tree/project-global-or-both.doc.mjs +131 -0
  159. package/assets/docs/tree/publishing.doc.mjs +5 -5
  160. package/assets/docs/tree/quick-start.doc.mjs +17 -7
  161. package/assets/docs/tree/reference.doc.mjs +192 -0
  162. package/assets/docs/tree/replace-a-core-component.doc.mjs +11 -1
  163. package/assets/docs/tree/replace-a-core-template.doc.mjs +4 -4
  164. package/assets/docs/tree/scaffold.doc.mjs +1 -1
  165. package/assets/docs/tree/sections-and-placement.doc.mjs +5 -5
  166. package/assets/docs/tree/see-it-in-an-app.doc.mjs +13 -3
  167. package/assets/docs/tree/short-and-findable.doc.mjs +3 -3
  168. package/assets/docs/tree/single-component.doc.mjs +3 -3
  169. package/assets/docs/tree/start-a-template.doc.mjs +15 -5
  170. package/assets/docs/tree/template-doc-overview.doc.mjs +2 -2
  171. package/assets/docs/tree/templates.doc.mjs +6 -0
  172. package/assets/docs/tree/test-in-an-app.doc.mjs +4 -4
  173. package/assets/docs/tree/test-template-in-app.doc.mjs +4 -4
  174. package/assets/docs/tree/themes.doc.mjs +4 -0
  175. package/assets/docs/tree/troubleshooting.doc.mjs +19 -11
  176. package/assets/docs/tree/uninstall.doc.mjs +109 -0
  177. package/assets/docs/tree/updates.doc.mjs +92 -0
  178. package/assets/docs/tree/upgrading.doc.mjs +3 -3
  179. package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +11 -1
  180. package/assets/docs/tree/verify-packed-template.doc.mjs +2 -2
  181. package/assets/docs/tree/versioning.doc.mjs +3 -3
  182. package/assets/docs/tree/who-answers.doc.mjs +119 -0
  183. package/assets/docs/tree/write-the-template-file.doc.mjs +3 -3
  184. package/assets/docs/working-with-ai.doc.mjs +23 -9
  185. package/authoring/debug/parse.d.mts +5 -5
  186. package/authoring/discover/discover.doc.mjs +7 -1
  187. package/authoring/doctypes/_schema.d.mts +8 -3
  188. package/authoring/doctypes/_schema.mjs +1 -0
  189. package/authoring/doctypes/command/command.doc.mjs +6 -0
  190. package/authoring/doctypes/command/type.ts +14 -0
  191. package/authoring/doctypes/component/component.doc.mjs +1 -1
  192. package/authoring/doctypes/component/type.ts +8 -0
  193. package/authoring/doctypes/hook/type.ts +4 -0
  194. package/authoring/doctypes/reference/reference.doc.mjs +1 -1
  195. package/authoring/index.d.ts +1 -0
  196. package/authoring/integration/integration.doc.mjs +18 -2
  197. package/authoring/integration/parse.test.mjs +11 -0
  198. package/authoring/integration/schema.d.mts +14 -3
  199. package/authoring/integration/schema.mjs +33 -2
  200. package/authoring/integration/type.ts +8 -0
  201. package/clients/cli/bin/astryx.mjs +20 -3
  202. package/clients/cli/cli-command.test.mjs +166 -0
  203. package/clients/cli/commands/blog.doc.mjs +1 -0
  204. package/clients/cli/commands/build-theme.batch-report.test.mjs +14 -2
  205. package/clients/cli/commands/build-theme.font-warning.test.mjs +3 -3
  206. package/clients/cli/commands/build-theme.mjs +25 -12
  207. package/clients/cli/commands/build.doc.mjs +1 -0
  208. package/clients/cli/commands/build.exit-codes-doc.test.mjs +4 -0
  209. package/clients/cli/commands/component.doc.mjs +1 -0
  210. package/clients/cli/commands/discover.broken-integration.test.mjs +11 -7
  211. package/clients/cli/commands/discover.doc.mjs +9 -1
  212. package/clients/cli/commands/discover.mjs +144 -93
  213. package/clients/cli/commands/discover.no-source.test.mjs +448 -33
  214. package/clients/cli/commands/discover.sources.test.mjs +20 -1
  215. package/clients/cli/commands/docs.doc.mjs +1 -0
  216. package/clients/cli/commands/docs.mjs +49 -19
  217. package/clients/cli/commands/docs.test.mjs +2 -2
  218. package/clients/cli/commands/doctor-integration-components.doc.mjs +4 -2
  219. package/clients/cli/commands/doctor-integration-docs.doc.mjs +20 -5
  220. package/clients/cli/commands/doctor-integration-templates.doc.mjs +1 -0
  221. package/clients/cli/commands/doctor-integration-validate.doc.mjs +10 -1
  222. package/clients/cli/commands/doctor-integration.test.mjs +52 -4
  223. package/clients/cli/commands/doctor.doc.mjs +12 -2
  224. package/clients/cli/commands/doctor.mjs +102 -7
  225. package/clients/cli/commands/doctor.test.mjs +10 -4
  226. package/clients/cli/commands/gap-report.doc.mjs +15 -2
  227. package/clients/cli/commands/gap-report.mjs +24 -2
  228. package/clients/cli/commands/gap-report.test.mjs +79 -0
  229. package/clients/cli/commands/hook.doc.mjs +1 -0
  230. package/clients/cli/commands/init.behavior.test.mjs +5 -0
  231. package/clients/cli/commands/init.doc.mjs +29 -3
  232. package/clients/cli/commands/integration-add.doc.mjs +7 -0
  233. package/clients/cli/commands/integration-authoring.test.mjs +49 -3
  234. package/clients/cli/commands/integration-check.doc.mjs +10 -2
  235. package/clients/cli/commands/integration-check.test.mjs +175 -1
  236. package/clients/cli/commands/integration-pack.doc.mjs +8 -1
  237. package/clients/cli/commands/integration-verify.doc.mjs +8 -1
  238. package/clients/cli/commands/integration.mjs +15 -9
  239. package/clients/cli/commands/json-contract.test.mjs +11 -2
  240. package/clients/cli/commands/manifest.doc.mjs +1 -0
  241. package/clients/cli/commands/outside-project.test.mjs +774 -0
  242. package/clients/cli/commands/search.doc.mjs +1 -0
  243. package/clients/cli/commands/search.mjs +16 -11
  244. package/clients/cli/commands/search.test.mjs +429 -296
  245. package/clients/cli/commands/setup-nudge.test.mjs +26 -4
  246. package/clients/cli/commands/swizzle.doc.mjs +7 -0
  247. package/clients/cli/commands/swizzle.routing.test.mjs +1 -1
  248. package/clients/cli/commands/template.doc.mjs +1 -0
  249. package/clients/cli/commands/theme-add-lifecycle.test.mjs +3 -3
  250. package/clients/cli/commands/theme-add.doc.mjs +8 -1
  251. package/clients/cli/commands/theme-build.doc.mjs +1 -0
  252. package/clients/cli/commands/theme-eject.doc.mjs +1 -0
  253. package/clients/cli/commands/theme-list.behavior.test.mjs +6 -0
  254. package/clients/cli/commands/theme-list.doc.mjs +1 -0
  255. package/clients/cli/commands/theme-palette-generate.doc.mjs +1 -0
  256. package/clients/cli/commands/theme-remove.doc.mjs +7 -0
  257. package/clients/cli/commands/theme-targets.doc.mjs +1 -0
  258. package/clients/cli/commands/theme-template.doc.mjs +1 -0
  259. package/clients/cli/commands/theme-use.doc.mjs +7 -0
  260. package/clients/cli/commands/upgrade.config-ordering.test.mjs +2 -1
  261. package/clients/cli/commands/upgrade.doc.mjs +22 -1
  262. package/clients/cli/commands/upgrade.file-protection.test.mjs +3 -2
  263. package/clients/cli/commands/upgrade.hook-output.test.mjs +2 -1
  264. package/clients/cli/commands/upgrade.older-cli.test.mjs +160 -0
  265. package/clients/cli/index.mjs +84 -13
  266. package/clients/cli/lib/cli-error.mjs +4 -1
  267. package/clients/cli/lib/component-format.test.mjs +1 -1
  268. package/clients/cli/lib/define-command.mjs +2 -2
  269. package/clients/cli/lib/json-shim.mjs +3 -1
  270. package/clients/cli/lib/manifest.d.ts +9 -0
  271. package/clients/cli/lib/manifest.mjs +17 -1
  272. package/clients/cli/lib/manifest.test.mjs +25 -0
  273. package/foundation/agent-docs/agent-doc-state.d.mts +21 -6
  274. package/foundation/agent-docs/agent-doc-state.mjs +29 -7
  275. package/foundation/agent-docs/agent-docs.d.mts +2 -2
  276. package/foundation/agent-docs/agent-docs.mjs +3 -3
  277. package/foundation/agent-docs/computer-agent-text.d.mts +133 -0
  278. package/foundation/agent-docs/computer-agent-text.mjs +623 -0
  279. package/foundation/agent-docs/computer-agent-text.test.mjs +602 -0
  280. package/foundation/config/project.d.mts +35 -3
  281. package/foundation/config/project.mjs +145 -8
  282. package/foundation/config/project.test.mjs +66 -0
  283. package/foundation/config/theme-state.mjs +5 -4
  284. package/foundation/discovery/cli-self-docs.mjs +20 -3
  285. package/foundation/discovery/cli-self-docs.test.mjs +3 -2
  286. package/foundation/discovery/component-replacement.mjs +2 -1
  287. package/foundation/discovery/copied-passages.d.mts +216 -0
  288. package/foundation/discovery/copied-passages.mjs +720 -0
  289. package/foundation/discovery/copied-passages.test.mjs +124 -0
  290. package/foundation/discovery/doc-consistency.d.mts +34 -0
  291. package/foundation/discovery/doc-consistency.mjs +513 -0
  292. package/foundation/discovery/doc-consistency.test.mjs +347 -0
  293. package/foundation/discovery/doc-fluff.d.mts +112 -0
  294. package/foundation/discovery/doc-fluff.mjs +328 -0
  295. package/foundation/discovery/doc-fluff.test.mjs +142 -0
  296. package/foundation/discovery/doc-types.mjs +12 -5
  297. package/foundation/discovery/doc-types.test.mjs +46 -2
  298. package/foundation/discovery/docs-discovery.d.mts +7 -0
  299. package/foundation/discovery/docs-discovery.mjs +26 -2
  300. package/foundation/discovery/prop-drift.d.mts +25 -6
  301. package/foundation/discovery/prop-drift.mjs +171 -6
  302. package/foundation/discovery/prop-drift.test.mjs +65 -0
  303. package/foundation/discovery/runner-allowlist.d.mts +40 -0
  304. package/foundation/discovery/runner-allowlist.mjs +53 -0
  305. package/foundation/discovery/stray-pointers.d.mts +52 -0
  306. package/foundation/discovery/stray-pointers.mjs +293 -0
  307. package/foundation/discovery/stray-pointers.test.mjs +86 -0
  308. package/foundation/discovery/template-needs.mjs +5 -2
  309. package/foundation/discovery/theme-imports.mjs +8 -4
  310. package/foundation/discovery/theme-imports.test.mjs +1 -1
  311. package/foundation/doc-compiler/doc-loads.test.mjs +36 -0
  312. package/foundation/doc-compiler/inputs.mjs +4 -1
  313. package/foundation/doc-compiler/links.d.mts +32 -0
  314. package/foundation/doc-compiler/links.mjs +163 -26
  315. package/foundation/doc-compiler/links.test.mjs +97 -4
  316. package/foundation/doc-compiler/read.d.mts +1 -1
  317. package/foundation/doc-compiler/tree.mjs +30 -1
  318. package/foundation/doc-compiler/tree.test.mjs +8 -1
  319. package/foundation/env/cli-command.d.mts +83 -0
  320. package/foundation/env/cli-command.mjs +152 -0
  321. package/foundation/env/cli-command.test.mjs +129 -0
  322. package/foundation/env/node-version.test.mjs +15 -3
  323. package/foundation/env/package-manager.d.mts +93 -9
  324. package/foundation/env/package-manager.global.test.mjs +66 -0
  325. package/foundation/env/package-manager.mjs +184 -13
  326. package/foundation/env/package-manager.test.mjs +341 -15
  327. package/foundation/env/project-scope.d.mts +9 -0
  328. package/foundation/env/project-scope.mjs +33 -0
  329. package/foundation/env/search-path.d.mts +42 -0
  330. package/foundation/env/search-path.mjs +205 -0
  331. package/foundation/env/search-path.test.mjs +122 -0
  332. package/foundation/env/user-dirs.d.mts +39 -0
  333. package/foundation/env/user-dirs.mjs +93 -0
  334. package/foundation/env/user-dirs.test.mjs +72 -0
  335. package/foundation/env/user-settings.d.mts +46 -0
  336. package/foundation/env/user-settings.mjs +106 -0
  337. package/foundation/env/user-settings.test.mjs +64 -0
  338. package/foundation/fs/file-protection.mjs +15 -1
  339. package/foundation/fs/module-loader.d.mts +2 -1
  340. package/foundation/fs/module-loader.mjs +60 -4
  341. package/foundation/fs/module-loader.stdout.test.mjs +3 -2
  342. package/foundation/fs/module-loader.test.mjs +194 -0
  343. package/foundation/fs/path-compare.d.mts +33 -0
  344. package/foundation/fs/path-compare.mjs +73 -0
  345. package/foundation/fs/paths.d.mts +57 -1
  346. package/foundation/fs/paths.mjs +131 -3
  347. package/foundation/fs/paths.test.mjs +10 -1
  348. package/foundation/integrations/computer-integrations.d.mts +78 -0
  349. package/foundation/integrations/computer-integrations.mjs +316 -0
  350. package/foundation/integrations/computer-integrations.test.mjs +292 -0
  351. package/foundation/integrations/contribution-inventory.d.mts +11 -0
  352. package/foundation/integrations/contribution-inventory.mjs +50 -2
  353. package/foundation/integrations/integration-warnings.mjs +3 -2
  354. package/foundation/integrations/integration-warnings.test.mjs +8 -9
  355. package/foundation/integrations/integrations.d.mts +25 -1
  356. package/foundation/integrations/integrations.mjs +46 -3
  357. package/foundation/integrations/issue.ts +6 -0
  358. package/foundation/integrations/validate-contributions.d.mts +2 -0
  359. package/foundation/integrations/validate-contributions.mjs +41 -1
  360. package/foundation/release/agent-text-worker.d.mts +4 -0
  361. package/foundation/release/agent-text-worker.mjs +52 -0
  362. package/foundation/release/cache.d.mts +310 -0
  363. package/foundation/release/cache.mjs +1216 -0
  364. package/foundation/release/cache.test.mjs +920 -0
  365. package/foundation/release/choose.d.mts +207 -0
  366. package/foundation/release/choose.mjs +677 -0
  367. package/foundation/release/choose.test.mjs +427 -0
  368. package/foundation/release/core-worker.d.mts +4 -0
  369. package/foundation/release/core-worker.mjs +38 -0
  370. package/foundation/release/global-state.d.mts +259 -0
  371. package/foundation/release/global-state.mjs +472 -0
  372. package/foundation/release/global-state.test.mjs +381 -0
  373. package/foundation/release/handoff.d.mts +60 -0
  374. package/foundation/release/handoff.e2e.test.mjs +278 -0
  375. package/foundation/release/handoff.mjs +357 -0
  376. package/foundation/release/lock-lease.d.mts +23 -0
  377. package/foundation/release/lock-lease.mjs +80 -0
  378. package/foundation/release/notices.d.mts +253 -0
  379. package/foundation/release/notices.mjs +596 -0
  380. package/foundation/release/notices.test.mjs +565 -0
  381. package/foundation/release/npm-guard.d.mts +4 -0
  382. package/foundation/release/npm-guard.mjs +126 -0
  383. package/foundation/release/project.d.mts +141 -0
  384. package/foundation/release/project.mjs +466 -0
  385. package/foundation/release/project.test.mjs +288 -0
  386. package/foundation/release/refresh-worker.d.mts +4 -0
  387. package/foundation/release/refresh-worker.mjs +27 -0
  388. package/foundation/release/run-context.d.mts +47 -0
  389. package/foundation/release/run-context.mjs +149 -0
  390. package/foundation/release/update-notice-env.d.mts +28 -0
  391. package/foundation/release/update-notice-env.mjs +39 -0
  392. package/foundation/response/base.d.ts +26 -3
  393. package/foundation/response/error-codes.d.mts +3 -1
  394. package/foundation/response/error-codes.doc.mjs +12 -0
  395. package/foundation/response/error-codes.mjs +17 -0
  396. package/foundation/response/error-codes.test.mjs +2 -0
  397. package/foundation/response/json-contract.test.mjs +7 -2
  398. package/foundation/response/json.mjs +4 -1
  399. package/foundation/response/response-types.doc.mjs +17 -11
  400. package/foundation/response/response-types.doc.test.mjs +46 -0
  401. package/foundation/response/response.doc.mjs +3 -3
  402. package/foundation/xle/browser-imports.test.mjs +74 -0
  403. package/package.json +11 -11
  404. package/scripts/postinstall.mjs +21 -2
@@ -0,0 +1,64 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ import * as fs from 'node:fs';
4
+ import * as os from 'node:os';
5
+ import * as path from 'node:path';
6
+ import {afterEach, describe, expect, it} from 'vitest';
7
+ import {
8
+ computerAgentTextSettings,
9
+ readSettings,
10
+ recordComputerAgentTextSettings,
11
+ settingsFile,
12
+ } from './user-settings.mjs';
13
+
14
+ /** @type {string[]} */
15
+ const dirs = [];
16
+ const tmp = () => {
17
+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-settings-'));
18
+ dirs.push(dir);
19
+ return dir;
20
+ };
21
+ afterEach(() => {
22
+ for (const dir of dirs.splice(0)) {
23
+ fs.rmSync(dir, {recursive: true, force: true});
24
+ }
25
+ });
26
+
27
+ describe('the settings file (spec AST-081 FR8)', () => {
28
+ it('means install, with no links, when missing or unreadable', () => {
29
+ const dir = tmp();
30
+ expect(computerAgentTextSettings(dir)).toEqual({install: true, links: []});
31
+ fs.writeFileSync(settingsFile(dir), 'not json');
32
+ expect(readSettings(dir)).toEqual({});
33
+ expect(computerAgentTextSettings(dir)).toEqual({install: true, links: []});
34
+ });
35
+
36
+ it('records and reads the choice and the links Astryx made, keeping other settings', () => {
37
+ const dir = tmp();
38
+ fs.writeFileSync(settingsFile(dir), '{"other":true}');
39
+ expect(
40
+ recordComputerAgentTextSettings(
41
+ {install: true, links: ['/h/.claude/skills/astryx']},
42
+ dir,
43
+ ),
44
+ ).toBe(true);
45
+ expect(JSON.parse(fs.readFileSync(settingsFile(dir), 'utf8'))).toEqual({
46
+ other: true,
47
+ computerAgentText: {install: true, links: ['/h/.claude/skills/astryx']},
48
+ });
49
+ expect(computerAgentTextSettings(dir)).toEqual({
50
+ install: true,
51
+ links: ['/h/.claude/skills/astryx'],
52
+ });
53
+ recordComputerAgentTextSettings({install: false, links: []}, dir);
54
+ expect(computerAgentTextSettings(dir)).toEqual({install: false, links: []});
55
+ });
56
+
57
+ it('never fails when the folder cannot be written', () => {
58
+ const file = path.join(tmp(), 'file');
59
+ fs.writeFileSync(file, '');
60
+ expect(
61
+ recordComputerAgentTextSettings({install: false, links: []}, file),
62
+ ).toBe(false);
63
+ });
64
+ });
@@ -9,8 +9,22 @@
9
9
  */
10
10
 
11
11
  import * as fs from 'node:fs';
12
+ import {createRequire} from 'node:module';
12
13
  import * as path from 'node:path';
13
- import ignore from 'ignore';
14
+
15
+ /**
16
+ * The `ignore` matcher factory, loaded on first use: this module is reached
17
+ * from every CLI run through the agent-docs helpers, and only a run that
18
+ * classifies a file needs the matcher.
19
+ * @type {typeof import('ignore') | undefined}
20
+ */
21
+ let ignoreFactory;
22
+
23
+ /** @param {import('ignore').Options} [options] */
24
+ function ignore(options) {
25
+ ignoreFactory ??= createRequire(import.meta.url)('ignore');
26
+ return /** @type {typeof import('ignore')} */ (ignoreFactory)(options);
27
+ }
14
28
 
15
29
  const DEPENDENCY_DIRS = new Set([
16
30
  'node_modules',
@@ -21,7 +21,8 @@ export function importUserModule(file: string, { fresh }?: {
21
21
  /**
22
22
  * Load a generated theme artifact and its extensionless JS/JSX/TS/TSX graph.
23
23
  * Package specifiers resolve from the consumer project, while relative paths
24
- * resolve from that same project root.
24
+ * resolve from that same project root. An import of an existing `.css` file
25
+ * loads as an empty module.
25
26
  * @param {string} specifier
26
27
  * @param {string} cwd
27
28
  * @returns {Promise<Record<string, unknown>>}
@@ -7,9 +7,11 @@
7
7
  * user-authored module (`.ts` via jiti, `.mjs`/`.js` via native dynamic
8
8
  * import) and (b) find conventional files by basename in a fixed
9
9
  * load-precedence order. Generated theme artifacts also use a dedicated jiti
10
- * path that resolves extensionless JSX/TSX registry imports. These helpers
11
- * centralize that behavior so callers stay in lockstep. A module's stdout writes go to stderr while it loads, so
12
- * project code that prints cannot corrupt a `--json` envelope.
10
+ * path that resolves extensionless JSX/TSX registry imports and loads the
11
+ * stylesheets they import as empty modules. These helpers centralize that
12
+ * behavior so callers stay in lockstep. A module's stdout writes go to stderr
13
+ * while it loads, so project code that prints cannot corrupt a `--json`
14
+ * envelope.
13
15
  *
14
16
  * `loadModuleWithParser` builds on these primitives to provide the single
15
17
  * load/validation boundary shared by config, integration, codemod, and
@@ -125,6 +127,56 @@ const THEME_ARTIFACT_EXTENSIONS = [
125
127
  '.cts',
126
128
  ];
127
129
 
130
+ /**
131
+ * @param {string | symbol} specifier
132
+ * @returns {specifier is string}
133
+ */
134
+ function isStylesheetSpecifier(specifier) {
135
+ return typeof specifier === 'string' && specifier.endsWith('.css');
136
+ }
137
+
138
+ /**
139
+ * Whether `specifier`, resolved from the module at `from`, names an existing
140
+ * `.css` file.
141
+ * @param {string} specifier
142
+ * @param {string} from
143
+ */
144
+ function resolvesToStylesheet(specifier, from) {
145
+ try {
146
+ return createRequire(from).resolve(specifier).endsWith('.css');
147
+ } catch {
148
+ return false;
149
+ }
150
+ }
151
+
152
+ /**
153
+ * A built theme module may import a stylesheet so that the app's bundler emits
154
+ * it. Node cannot load a stylesheet, so an import that ends in `.css` and
155
+ * resolves from the theme module to an existing `.css` file loads as an empty
156
+ * module. Any other import loads as before: a missing stylesheet fails like
157
+ * any missing import, and `./tokens.css` loads `tokens.css.js` when that is
158
+ * the file it names. jiti shows only the import text, so the check resolves it
159
+ * from the theme module's folder, not from the importing module's. A module in
160
+ * another folder fails on a stylesheet it reaches by a different relative
161
+ * path, and passes on a missing stylesheet whose path exists from the theme
162
+ * module's folder.
163
+ * @param {() => string} themeModule returns the theme module's path
164
+ * @returns {Record<string, unknown>}
165
+ */
166
+ function themeArtifactStylesheets(themeModule) {
167
+ return new Proxy(
168
+ {},
169
+ {
170
+ has: (_target, specifier) =>
171
+ specifier !== themeModule() &&
172
+ isStylesheetSpecifier(specifier) &&
173
+ resolvesToStylesheet(specifier, themeModule()),
174
+ get: (_target, specifier) =>
175
+ isStylesheetSpecifier(specifier) ? {} : undefined,
176
+ },
177
+ );
178
+ }
179
+
128
180
  class ThemeArtifactNotFoundError extends Error {
129
181
  code = 'ERR_THEME_ARTIFACT_NOT_FOUND';
130
182
 
@@ -153,17 +205,20 @@ function isMissingPackageExport(error) {
153
205
  /**
154
206
  * Load a generated theme artifact and its extensionless JS/JSX/TS/TSX graph.
155
207
  * Package specifiers resolve from the consumer project, while relative paths
156
- * resolve from that same project root.
208
+ * resolve from that same project root. An import of an existing `.css` file
209
+ * loads as an empty module.
157
210
  * @param {string} specifier
158
211
  * @param {string} cwd
159
212
  * @returns {Promise<Record<string, unknown>>}
160
213
  */
161
214
  export async function importThemeArtifact(specifier, cwd) {
215
+ let themeModule = path.join(cwd, 'package.json');
162
216
  const loader = createJiti(path.join(cwd, 'package.json'), {
163
217
  moduleCache: false,
164
218
  jsx: true,
165
219
  interopDefault: true,
166
220
  extensions: THEME_ARTIFACT_EXTENSIONS,
221
+ virtualModules: themeArtifactStylesheets(() => themeModule),
167
222
  });
168
223
  let target;
169
224
  if (specifier.startsWith('.') || path.isAbsolute(specifier)) {
@@ -179,6 +234,7 @@ export async function importThemeArtifact(specifier, cwd) {
179
234
  if (!fs.existsSync(target)) {
180
235
  throw new ThemeArtifactNotFoundError(specifier);
181
236
  }
237
+ themeModule = target;
182
238
  return await withStdoutOnStderr(() => loader.import(target));
183
239
  }
184
240
 
@@ -14,6 +14,7 @@ import * as fs from 'node:fs';
14
14
  import * as os from 'node:os';
15
15
  import * as path from 'node:path';
16
16
  import {fileURLToPath, pathToFileURL} from 'node:url';
17
+ import {CLI_VERSION} from '../../test-utils/release-fixtures.mjs';
17
18
 
18
19
  const HERE = path.dirname(fileURLToPath(import.meta.url));
19
20
  const LOADER_URL = pathToFileURL(path.join(HERE, 'module-loader.mjs')).href;
@@ -268,7 +269,7 @@ describe('--json stdout stays one envelope when project modules print', () => {
268
269
  write('package.json', JSON.stringify({name: 'consumer', private: true}));
269
270
  write(
270
271
  'node_modules/@astryxdesign/core/package.json',
271
- JSON.stringify({name: '@astryxdesign/core', version: '0.6.3'}),
272
+ JSON.stringify({name: '@astryxdesign/core', version: CLI_VERSION}),
272
273
  );
273
274
  write(
274
275
  'astryx.config.js',
@@ -289,7 +290,7 @@ describe('--json stdout stays one envelope when project modules print', () => {
289
290
  );
290
291
  write(
291
292
  'node_modules/@astryxdesign/core/package.json',
292
- JSON.stringify({name: '@astryxdesign/core', version: '0.6.3'}),
293
+ JSON.stringify({name: '@astryxdesign/core', version: CLI_VERSION}),
293
294
  );
294
295
  write(
295
296
  'astryx.config.mjs',
@@ -9,6 +9,7 @@ import {pathToFileURL} from 'node:url';
9
9
  import {z} from 'zod';
10
10
  import {
11
11
  findPresentFiles,
12
+ importThemeArtifact,
12
13
  importUserModule,
13
14
  loadModuleWithParser,
14
15
  } from './module-loader.mjs';
@@ -155,6 +156,199 @@ process.stdout.write(JSON.stringify({first: first.default?.answer, fresh: fresh.
155
156
  });
156
157
  });
157
158
 
159
+ describe('importThemeArtifact', () => {
160
+ const STYLESHEET_RAN = '__astryxThemeArtifactStylesheetRan';
161
+
162
+ /** @param {string} file @param {string} content */
163
+ function write(file, content) {
164
+ const target = path.join(tmpDir, file);
165
+ fs.mkdirSync(path.dirname(target), {recursive: true});
166
+ fs.writeFileSync(target, content);
167
+ }
168
+
169
+ beforeEach(() => {
170
+ write('package.json', JSON.stringify({type: 'module'}));
171
+ write(
172
+ 'ocean.css',
173
+ '[data-astryx-theme="ocean"] { --color-text: black; }\n',
174
+ );
175
+ });
176
+
177
+ afterEach(() => {
178
+ Reflect.deleteProperty(globalThis, STYLESHEET_RAN);
179
+ });
180
+
181
+ it('loads a built module that imports its stylesheet, without running the stylesheet', async () => {
182
+ // Valid JavaScript, so running this stylesheet would leave a trace.
183
+ write('ran.css', `globalThis.${STYLESHEET_RAN} = true;\n`);
184
+ write(
185
+ 'ocean.js',
186
+ "import './ocean.css';\nimport './ran.css';\nexport const oceanTheme = {name: 'ocean'};\n",
187
+ );
188
+
189
+ const mod = await importThemeArtifact('./ocean.js', tmpDir);
190
+
191
+ expect(mod.oceanTheme).toEqual({name: 'ocean'});
192
+ expect(Reflect.get(globalThis, STYLESHEET_RAN)).toBeUndefined();
193
+ });
194
+
195
+ it('loads a CommonJS built module that requires its stylesheet', async () => {
196
+ write('commonjs/package.json', JSON.stringify({type: 'commonjs'}));
197
+ write(
198
+ 'commonjs/ocean.css',
199
+ '[data-astryx-theme="ocean"] { --color-text: black; }\n',
200
+ );
201
+ write(
202
+ 'commonjs/ocean.js',
203
+ "require('./ocean.css');\nexports.oceanTheme = {name: 'ocean'};\n",
204
+ );
205
+
206
+ const mod = await importThemeArtifact('./commonjs/ocean.js', tmpDir);
207
+
208
+ expect(mod.oceanTheme).toEqual({name: 'ocean'});
209
+ });
210
+
211
+ it('loads stylesheets imported by a nested module, through a package export, and dynamically', async () => {
212
+ const packageDir = 'node_modules/@acme/themes';
213
+ write(
214
+ `${packageDir}/package.json`,
215
+ JSON.stringify({
216
+ name: '@acme/themes',
217
+ type: 'module',
218
+ exports: {
219
+ './themes/ocean': './dist/ocean.js',
220
+ './themes/ocean.css': './dist/ocean.css',
221
+ },
222
+ }),
223
+ );
224
+ write(
225
+ `${packageDir}/dist/ocean.css`,
226
+ '[data-astryx-theme="ocean"] { --color-text: black; }\n',
227
+ );
228
+ write(
229
+ `${packageDir}/dist/tokens.js`,
230
+ "import '@acme/themes/themes/ocean.css';\nexport const tokens = {};\n",
231
+ );
232
+ write(
233
+ `${packageDir}/dist/ocean.js`,
234
+ "import {tokens} from './tokens.js';\nawait import('./ocean.css');\nexport const oceanTheme = {name: 'ocean', tokens};\n",
235
+ );
236
+
237
+ const mod = await importThemeArtifact('@acme/themes/themes/ocean', tmpDir);
238
+
239
+ expect(mod.oceanTheme).toEqual({name: 'ocean', tokens: {}});
240
+ });
241
+
242
+ it('still resolves an extensionless import to its directory index beside a same-named stylesheet', async () => {
243
+ write('ocean/index.js', "export const oceanTheme = {name: 'ocean'};\n");
244
+ write(
245
+ 'entry.js',
246
+ "import './ocean.css';\nexport {oceanTheme} from './ocean';\n",
247
+ );
248
+
249
+ const mod = await importThemeArtifact('./entry.js', tmpDir);
250
+
251
+ expect(mod.oceanTheme).toEqual({name: 'ocean'});
252
+ });
253
+
254
+ it('loads a module whose import ends in .css but names a JavaScript file', async () => {
255
+ write('tokens.css.js', "export const vars = {accent: 'blue'};\n");
256
+ write(
257
+ 'ocean.js',
258
+ "import './ocean.css';\nimport {vars} from './tokens.css';\nexport const oceanTheme = {name: 'ocean', vars};\n",
259
+ );
260
+
261
+ const mod = await importThemeArtifact('./ocean.js', tmpDir);
262
+
263
+ expect(mod.oceanTheme).toEqual({name: 'ocean', vars: {accent: 'blue'}});
264
+ });
265
+
266
+ it.each([
267
+ ['a missing file', "import './fonts.css';\n", /fonts\.css/],
268
+ [
269
+ 'a package that is not installed',
270
+ "import '@acme/missing-fonts/inter.css';\n",
271
+ /@acme\/missing-fonts\/inter\.css/,
272
+ ],
273
+ ])(
274
+ 'still rejects a stylesheet import of %s',
275
+ async (_label, stylesheetImport, expected) => {
276
+ write(
277
+ 'ocean.js',
278
+ `import './ocean.css';\n${stylesheetImport}export const oceanTheme = {name: 'ocean'};\n`,
279
+ );
280
+
281
+ await expect(importThemeArtifact('./ocean.js', tmpDir)).rejects.toThrow(
282
+ expected,
283
+ );
284
+ },
285
+ );
286
+
287
+ it('still rejects a theme module path that names a stylesheet', async () => {
288
+ await expect(importThemeArtifact('./ocean.css', tmpDir)).rejects.toThrow(
289
+ /Unknown file extension "\.css"/,
290
+ );
291
+ });
292
+
293
+ it('still rejects a stylesheet import that its package does not export', async () => {
294
+ const packageDir = 'node_modules/@acme/themes';
295
+ write(
296
+ `${packageDir}/package.json`,
297
+ JSON.stringify({
298
+ name: '@acme/themes',
299
+ type: 'module',
300
+ exports: {'./themes/ocean': './dist/ocean.js'},
301
+ }),
302
+ );
303
+ write(
304
+ `${packageDir}/dist/ocean.css`,
305
+ '[data-astryx-theme="ocean"] { --color-text: black; }\n',
306
+ );
307
+ write(
308
+ `${packageDir}/dist/ocean.js`,
309
+ "import '@acme/themes/themes/ocean.css';\nexport const oceanTheme = {name: 'ocean'};\n",
310
+ );
311
+
312
+ await expect(
313
+ importThemeArtifact('@acme/themes/themes/ocean', tmpDir),
314
+ ).rejects.toThrow(/not defined by "exports"/);
315
+ });
316
+
317
+ it.each([
318
+ [
319
+ 'a missing dependency',
320
+ "import './missing.js';\nexport const oceanTheme = {name: 'ocean'};\n",
321
+ /missing\.js/,
322
+ ],
323
+ [
324
+ 'a syntax error in a module it imports',
325
+ "import './broken.js';\nexport const oceanTheme = {name: 'ocean'};\n",
326
+ /ParseError/,
327
+ ],
328
+ [
329
+ 'a throwing module',
330
+ "throw new Error('broken theme module');\n",
331
+ /broken theme module/,
332
+ ],
333
+ [
334
+ 'an asset that is not a stylesheet',
335
+ "import './logo.svg';\nexport const oceanTheme = {name: 'ocean'};\n",
336
+ /Unknown file extension "\.svg"/,
337
+ ],
338
+ ])(
339
+ 'still rejects a built module that imports its stylesheet and has %s',
340
+ async (_label, rest, expected) => {
341
+ write('logo.svg', '<svg xmlns="http://www.w3.org/2000/svg"/>\n');
342
+ write('broken.js', 'export const broken = ;\n');
343
+ write('ocean.js', `import './ocean.css';\n${rest}`);
344
+
345
+ await expect(importThemeArtifact('./ocean.js', tmpDir)).rejects.toThrow(
346
+ expected,
347
+ );
348
+ },
349
+ );
350
+ });
351
+
158
352
  describe('loadModuleWithParser', () => {
159
353
  // Temp module files live under a repo-local dir (not /tmp): Vite's dynamic
160
354
  // import blocks /tmp, so we mirror the existing repo-local temp pattern.
@@ -0,0 +1,33 @@
1
+ // @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
2
+ // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
+
4
+ /**
5
+ * Whether the platform's file systems ignore letter case by default.
6
+ * @param {NodeJS.Platform} [platform]
7
+ * @returns {boolean}
8
+ */
9
+ export function ignoresCase(platform?: NodeJS.Platform): boolean;
10
+ /**
11
+ * A path in the form two spellings of one folder share.
12
+ * @param {string} p
13
+ * @param {NodeJS.Platform} [platform]
14
+ * @returns {string}
15
+ */
16
+ export function pathKey(p: string, platform?: NodeJS.Platform): string;
17
+ /**
18
+ * Whether two paths name the same folder or file.
19
+ * @param {string} a
20
+ * @param {string} b
21
+ * @param {NodeJS.Platform} [platform]
22
+ * @returns {boolean}
23
+ */
24
+ export function samePath(a: string, b: string, platform?: NodeJS.Platform): boolean;
25
+ /**
26
+ * `child` relative to `parent`, compared the way the file system compares
27
+ * names; `null` when `child` is not inside `parent` (or is `parent`).
28
+ * @param {string} parent
29
+ * @param {string} child
30
+ * @param {NodeJS.Platform} [platform]
31
+ * @returns {string | null}
32
+ */
33
+ export function relativeWithin(parent: string, child: string, platform?: NodeJS.Platform): string | null;
@@ -0,0 +1,73 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file Path comparison that matches the file system (spec AST-081 FR11):
5
+ * Windows and macOS file systems ignore letter case by default, so two
6
+ * spellings that differ only in case name the same folder there, and the
7
+ * release choice must treat them as one.
8
+ *
9
+ * @input paths and the platform
10
+ * @output whether two paths are the same, and a path relative to a folder
11
+ * @position packages/cli/foundation/fs — used by the release choice and the
12
+ * release cache.
13
+ */
14
+
15
+ import * as path from 'node:path';
16
+
17
+ /**
18
+ * Whether the platform's file systems ignore letter case by default.
19
+ * @param {NodeJS.Platform} [platform]
20
+ * @returns {boolean}
21
+ */
22
+ export function ignoresCase(platform = process.platform) {
23
+ return platform === 'win32' || platform === 'darwin';
24
+ }
25
+
26
+ /**
27
+ * The path module of a platform.
28
+ * @param {NodeJS.Platform} platform
29
+ * @returns {typeof path.posix}
30
+ */
31
+ function pathsOf(platform) {
32
+ return platform === 'win32' ? path.win32 : path.posix;
33
+ }
34
+
35
+ /**
36
+ * A path in the form two spellings of one folder share.
37
+ * @param {string} p
38
+ * @param {NodeJS.Platform} [platform]
39
+ * @returns {string}
40
+ */
41
+ export function pathKey(p, platform = process.platform) {
42
+ const normal = pathsOf(platform).normalize(p);
43
+ return ignoresCase(platform) ? normal.toLowerCase() : normal;
44
+ }
45
+
46
+ /**
47
+ * Whether two paths name the same folder or file.
48
+ * @param {string} a
49
+ * @param {string} b
50
+ * @param {NodeJS.Platform} [platform]
51
+ * @returns {boolean}
52
+ */
53
+ export function samePath(a, b, platform = process.platform) {
54
+ return pathKey(a, platform) === pathKey(b, platform);
55
+ }
56
+
57
+ /**
58
+ * `child` relative to `parent`, compared the way the file system compares
59
+ * names; `null` when `child` is not inside `parent` (or is `parent`).
60
+ * @param {string} parent
61
+ * @param {string} child
62
+ * @param {NodeJS.Platform} [platform]
63
+ * @returns {string | null}
64
+ */
65
+ export function relativeWithin(parent, child, platform = process.platform) {
66
+ const paths = pathsOf(platform);
67
+ const rel = paths.relative(
68
+ pathKey(parent, platform),
69
+ pathKey(child, platform),
70
+ );
71
+ if (rel === '' || rel.startsWith('..') || paths.isAbsolute(rel)) return null;
72
+ return rel;
73
+ }
@@ -1,11 +1,67 @@
1
1
  // @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
2
2
  // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
3
 
4
+ /**
5
+ * The Core a command answers from: the project's (see
6
+ * {@link findProjectCoreDir}), else, when a copy other than the project's own
7
+ * CLI answers, the Core that copy carries (spec AST-081 FR3): the
8
+ * `@astryxdesign/core` of its own release, beside it or in the per-user
9
+ * release cache. Never fetches; {@link requireCoreDir} does.
10
+ *
11
+ * Commands that judge or change a project (`doctor`, `swizzle`, `upgrade`)
12
+ * read {@link findProjectCoreDir} instead, so a carried Core never passes a
13
+ * project check or lands in a folder that installed none.
14
+ *
15
+ * @param {string} [startDir]
16
+ * @returns {string | null}
17
+ */
18
+ export function findCoreDir(startDir?: string): string | null;
19
+ /**
20
+ * Why a command that reads Core cannot run, when the answering release's own
21
+ * Core is needed and cannot be installed: outside a project, or in a project
22
+ * with nothing installed (spec AST-081 FR3).
23
+ * @param {{unavailable: string | null, version?: string, reason?: string}} found
24
+ * @param {boolean} inProject
25
+ * @returns {string}
26
+ */
27
+ export function unavailableCoreMessage(found: {
28
+ unavailable: string | null;
29
+ version?: string;
30
+ reason?: string;
31
+ }, inProject: boolean): string;
32
+ /**
33
+ * Like {@link findCoreDir}, but a copy that carries no Core installs its
34
+ * release's Core into the per-user cache first. Throws ERR_CORE_NOT_FOUND
35
+ * when there is no Core to answer from, and ERR_VERSIONS_UNAVAILABLE when the
36
+ * carried Core is needed and cannot be installed.
37
+ *
38
+ * @param {string} [startDir]
39
+ * @returns {string}
40
+ */
41
+ export function requireCoreDir(startDir?: string): string;
42
+ /**
43
+ * The carried Core alone, for a caller that already looked for the project's
44
+ * Core its own way: the folder, or null when the copy answering in `startDir`
45
+ * is the project's own CLI or carries none.
46
+ * @param {string} startDir
47
+ * @param {{fetch?: boolean}} [options]
48
+ * @returns {string | null}
49
+ */
50
+ export function findCarriedCoreDir(startDir: string, { fetch }?: {
51
+ fetch?: boolean;
52
+ }): string | null;
4
53
  /**
5
54
  * Find packages/core directory by walking up from startDir.
6
55
  * Also checks node_modules/@astryxdesign/core for installed usage.
56
+ *
57
+ * The project's Core only: in the folder or four above it, the reach every
58
+ * released version used, else from the folder of the package.json that makes
59
+ * the folder part of a project, however deep the folder is.
60
+ *
61
+ * @param {string} [startDir]
62
+ * @returns {string | null}
7
63
  */
8
- export function findCoreDir(startDir?: string): string | null;
64
+ export function findProjectCoreDir(startDir?: string): string | null;
9
65
  /**
10
66
  * Locate a package the project at `startDir` actually installed.
11
67
  *