@astryxdesign/cli 0.7.2-canary.081ccea → 0.7.2-canary.0d5d64e

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 (324) hide show
  1. package/README.md +104 -84
  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.mjs +3 -11
  7. package/api/component/component.doc.mjs +6 -1
  8. package/api/discover/_adapter.d.mts +13 -0
  9. package/api/discover/_adapter.mjs +39 -17
  10. package/api/discover/discover.doc.mjs +3 -2
  11. package/api/discover/discover.mjs +22 -8
  12. package/api/discover/discover.type.d.mts +5 -3
  13. package/api/discover/discover.type.mjs +5 -3
  14. package/api/docs/_adapter.mjs +3 -2
  15. package/api/docs/docs.doc.mjs +2 -1
  16. package/api/docs/docs.mjs +2 -1
  17. package/api/docs/docs.test.mjs +5 -2
  18. package/api/docs/reference-blocks.test.mjs +1 -3
  19. package/api/doctor/_adapter.d.mts +108 -0
  20. package/api/doctor/_adapter.mjs +223 -4
  21. package/api/doctor/doctor.d.mts +199 -0
  22. package/api/doctor/doctor.doc.mjs +3 -2
  23. package/api/doctor/doctor.mjs +503 -31
  24. package/api/doctor/doctor.test.mjs +137 -14
  25. package/api/doctor/release-checks.test.mjs +156 -0
  26. package/api/doctor/theme-checks.mjs +16 -3
  27. package/api/doctor/theme-checks.test.mjs +87 -7
  28. package/api/error.d.mts +10 -0
  29. package/api/error.mjs +25 -0
  30. package/api/hook/_adapter.mjs +3 -11
  31. package/api/hook/hook.doc.mjs +4 -0
  32. package/api/hook/list/list.d.mts +1 -1
  33. package/api/init/_adapter.d.mts +22 -0
  34. package/api/init/_adapter.mjs +59 -0
  35. package/api/init/init.d.mts +7 -5
  36. package/api/init/init.doc.mjs +28 -7
  37. package/api/init/init.mjs +28 -4
  38. package/api/init/init.type.d.mts +48 -3
  39. package/api/init/init.type.mjs +37 -3
  40. package/api/init/run/run.d.mts +1 -1
  41. package/api/init/run/run.mjs +15 -4
  42. package/api/init/user/user.d.mts +14 -0
  43. package/api/init/user/user.mjs +87 -0
  44. package/api/init/user/user.test.mjs +232 -0
  45. package/api/integration/authoring-checks.mjs +2 -2
  46. package/api/integration/integrationCheck.doc.mjs +1 -1
  47. package/api/integration/pack-check.mjs +10 -9
  48. package/api/integration/pack-check.test.mjs +9 -15
  49. package/api/integration/validate-integration.d.mts +8 -0
  50. package/api/integration/validate-integration.mjs +27 -6
  51. package/api/integration/validate-integration.type.d.mts +8 -0
  52. package/api/integration/validate-integration.type.mjs +3 -1
  53. package/api/integration/validate-unread-theme-folders.test.mjs +3 -2
  54. package/api/integration/validateIntegration.doc.mjs +1 -1
  55. package/api/search/_adapter.d.mts +11 -0
  56. package/api/search/_adapter.mjs +25 -0
  57. package/api/search/search.d.mts +1 -1
  58. package/api/search/search.doc.mjs +8 -3
  59. package/api/search/search.mjs +38 -14
  60. package/api/search/search.test.mjs +4 -1
  61. package/api/search/search.type.d.mts +14 -1
  62. package/api/search/search.type.mjs +6 -1
  63. package/api/swizzle/_adapter.mjs +2 -2
  64. package/api/swizzle/copy/copy.mjs +1 -1
  65. package/api/template/template-integration.test.mjs +1 -1
  66. package/api/theme/_adapter.d.mts +16 -0
  67. package/api/theme/_adapter.mjs +32 -5
  68. package/api/theme/build/build.d.mts +2 -1
  69. package/api/theme/build/build.mjs +70 -14
  70. package/api/theme/build/build.packed-old-core.test.mjs +20 -3
  71. package/api/theme/build/font-warning.mjs +5 -3
  72. package/api/theme/build/font-warning.test.mjs +2 -1
  73. package/api/theme/remove/remove.test.mjs +2 -2
  74. package/api/theme/targets/targets.mjs +3 -10
  75. package/api/theme/themeTargets.doc.mjs +4 -0
  76. package/api/theme/use/use.test.mjs +1 -1
  77. package/api/upgrade/_adapter.mjs +1 -1
  78. package/api/upgrade/run/run.mjs +5 -1
  79. package/api/upgrade/upgrade.doc.mjs +2 -1
  80. package/api/upgrade/upgrade.mjs +5 -1
  81. package/assets/docs/getting-started.doc.mjs +23 -3
  82. package/assets/docs/tree/add-a-component.doc.mjs +11 -1
  83. package/assets/docs/tree/add-a-theme.doc.mjs +12 -2
  84. package/assets/docs/tree/add-a-topic.doc.mjs +43 -1
  85. package/assets/docs/tree/agent-guidance.doc.mjs +18 -4
  86. package/assets/docs/tree/building-blocks.doc.mjs +4 -0
  87. package/assets/docs/tree/check-the-props.doc.mjs +1 -1
  88. package/assets/docs/tree/check-your-docs.doc.mjs +5 -5
  89. package/assets/docs/tree/checks.doc.mjs +9 -9
  90. package/assets/docs/tree/ci-and-containers.doc.mjs +88 -0
  91. package/assets/docs/tree/cli-command.doc.mjs +142 -0
  92. package/assets/docs/tree/cli.doc.mjs +6 -0
  93. package/assets/docs/tree/codemods.doc.mjs +13 -3
  94. package/assets/docs/tree/commands.doc.mjs +7 -1
  95. package/assets/docs/tree/component-imports.doc.mjs +11 -1
  96. package/assets/docs/tree/components.doc.mjs +6 -0
  97. package/assets/docs/tree/computer-agent-guide.doc.mjs +160 -0
  98. package/assets/docs/tree/computer-integrations.doc.mjs +93 -0
  99. package/assets/docs/tree/configuration.doc.mjs +7 -3
  100. package/assets/docs/tree/debug-and-gap-reports.doc.mjs +11 -1
  101. package/assets/docs/tree/define-the-theme.doc.mjs +1 -1
  102. package/assets/docs/tree/describe-the-component.doc.mjs +1 -1
  103. package/assets/docs/tree/docs.doc.mjs +6 -0
  104. package/assets/docs/tree/extend-or-replace.doc.mjs +13 -3
  105. package/assets/docs/tree/generate-a-palette.doc.mjs +2 -2
  106. package/assets/docs/tree/global-integrations.doc.mjs +124 -0
  107. package/assets/docs/tree/global.doc.mjs +131 -0
  108. package/assets/docs/tree/grade-template-with-agent.doc.mjs +4 -4
  109. package/assets/docs/tree/install-once.doc.mjs +105 -0
  110. package/assets/docs/tree/integrations.doc.mjs +5 -1
  111. package/assets/docs/tree/layout.doc.mjs +1 -1
  112. package/assets/docs/tree/links.doc.mjs +1 -1
  113. package/assets/docs/tree/monorepos.doc.mjs +84 -0
  114. package/assets/docs/tree/problems.doc.mjs +205 -0
  115. package/assets/docs/tree/project-global-or-both.doc.mjs +131 -0
  116. package/assets/docs/tree/publishing.doc.mjs +2 -2
  117. package/assets/docs/tree/quick-start.doc.mjs +15 -5
  118. package/assets/docs/tree/reference.doc.mjs +192 -0
  119. package/assets/docs/tree/replace-a-core-component.doc.mjs +11 -1
  120. package/assets/docs/tree/replace-a-core-template.doc.mjs +4 -4
  121. package/assets/docs/tree/scaffold.doc.mjs +1 -1
  122. package/assets/docs/tree/sections-and-placement.doc.mjs +3 -3
  123. package/assets/docs/tree/see-it-in-an-app.doc.mjs +13 -3
  124. package/assets/docs/tree/short-and-findable.doc.mjs +3 -3
  125. package/assets/docs/tree/single-component.doc.mjs +3 -3
  126. package/assets/docs/tree/start-a-template.doc.mjs +15 -5
  127. package/assets/docs/tree/template-doc-overview.doc.mjs +1 -1
  128. package/assets/docs/tree/templates.doc.mjs +6 -0
  129. package/assets/docs/tree/test-in-an-app.doc.mjs +4 -4
  130. package/assets/docs/tree/test-template-in-app.doc.mjs +4 -4
  131. package/assets/docs/tree/themes.doc.mjs +4 -0
  132. package/assets/docs/tree/troubleshooting.doc.mjs +15 -7
  133. package/assets/docs/tree/uninstall.doc.mjs +109 -0
  134. package/assets/docs/tree/updates.doc.mjs +92 -0
  135. package/assets/docs/tree/upgrading.doc.mjs +2 -2
  136. package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +11 -1
  137. package/assets/docs/tree/verify-packed-template.doc.mjs +2 -2
  138. package/assets/docs/tree/versioning.doc.mjs +3 -3
  139. package/assets/docs/tree/who-answers.doc.mjs +119 -0
  140. package/assets/docs/tree/write-the-template-file.doc.mjs +3 -3
  141. package/assets/docs/working-with-ai.doc.mjs +23 -9
  142. package/authoring/debug/parse.d.mts +5 -5
  143. package/authoring/discover/discover.doc.mjs +6 -0
  144. package/authoring/doctypes/_schema.d.mts +8 -3
  145. package/authoring/doctypes/_schema.mjs +1 -0
  146. package/authoring/doctypes/command/command.doc.mjs +6 -0
  147. package/authoring/doctypes/command/type.ts +14 -0
  148. package/authoring/doctypes/reference/reference.doc.mjs +1 -1
  149. package/authoring/index.d.ts +1 -0
  150. package/authoring/integration/integration.doc.mjs +18 -2
  151. package/authoring/integration/parse.test.mjs +11 -0
  152. package/authoring/integration/schema.d.mts +14 -3
  153. package/authoring/integration/schema.mjs +33 -2
  154. package/authoring/integration/type.ts +8 -0
  155. package/clients/cli/bin/astryx.mjs +20 -3
  156. package/clients/cli/cli-command.test.mjs +166 -0
  157. package/clients/cli/commands/blog.doc.mjs +1 -0
  158. package/clients/cli/commands/build-theme.batch-report.test.mjs +14 -2
  159. package/clients/cli/commands/build-theme.font-warning.test.mjs +3 -3
  160. package/clients/cli/commands/build-theme.mjs +25 -12
  161. package/clients/cli/commands/build.doc.mjs +1 -0
  162. package/clients/cli/commands/build.exit-codes-doc.test.mjs +4 -0
  163. package/clients/cli/commands/component.doc.mjs +1 -0
  164. package/clients/cli/commands/discover.broken-integration.test.mjs +7 -6
  165. package/clients/cli/commands/discover.doc.mjs +8 -0
  166. package/clients/cli/commands/discover.no-source.test.mjs +1 -0
  167. package/clients/cli/commands/docs.doc.mjs +1 -0
  168. package/clients/cli/commands/docs.mjs +49 -19
  169. package/clients/cli/commands/docs.test.mjs +2 -2
  170. package/clients/cli/commands/doctor-integration-components.doc.mjs +1 -0
  171. package/clients/cli/commands/doctor-integration-docs.doc.mjs +1 -0
  172. package/clients/cli/commands/doctor-integration-templates.doc.mjs +1 -0
  173. package/clients/cli/commands/doctor-integration-validate.doc.mjs +10 -1
  174. package/clients/cli/commands/doctor-integration.test.mjs +4 -3
  175. package/clients/cli/commands/doctor.doc.mjs +12 -2
  176. package/clients/cli/commands/doctor.mjs +12 -3
  177. package/clients/cli/commands/doctor.test.mjs +10 -4
  178. package/clients/cli/commands/gap-report.doc.mjs +1 -0
  179. package/clients/cli/commands/hook.doc.mjs +1 -0
  180. package/clients/cli/commands/init.behavior.test.mjs +5 -0
  181. package/clients/cli/commands/init.doc.mjs +29 -3
  182. package/clients/cli/commands/integration-add.doc.mjs +7 -0
  183. package/clients/cli/commands/integration-authoring.test.mjs +3 -3
  184. package/clients/cli/commands/integration-check.doc.mjs +10 -2
  185. package/clients/cli/commands/integration-check.test.mjs +31 -1
  186. package/clients/cli/commands/integration-pack.doc.mjs +8 -1
  187. package/clients/cli/commands/integration-verify.doc.mjs +8 -1
  188. package/clients/cli/commands/integration.mjs +3 -2
  189. package/clients/cli/commands/json-contract.test.mjs +6 -1
  190. package/clients/cli/commands/manifest.doc.mjs +1 -0
  191. package/clients/cli/commands/outside-project.test.mjs +774 -0
  192. package/clients/cli/commands/search.doc.mjs +1 -0
  193. package/clients/cli/commands/search.mjs +16 -11
  194. package/clients/cli/commands/search.test.mjs +429 -296
  195. package/clients/cli/commands/setup-nudge.test.mjs +26 -4
  196. package/clients/cli/commands/swizzle.doc.mjs +7 -0
  197. package/clients/cli/commands/swizzle.routing.test.mjs +1 -1
  198. package/clients/cli/commands/template.doc.mjs +1 -0
  199. package/clients/cli/commands/theme-add-lifecycle.test.mjs +3 -3
  200. package/clients/cli/commands/theme-add.doc.mjs +8 -1
  201. package/clients/cli/commands/theme-build.doc.mjs +1 -0
  202. package/clients/cli/commands/theme-eject.doc.mjs +1 -0
  203. package/clients/cli/commands/theme-list.behavior.test.mjs +6 -0
  204. package/clients/cli/commands/theme-list.doc.mjs +1 -0
  205. package/clients/cli/commands/theme-palette-generate.doc.mjs +1 -0
  206. package/clients/cli/commands/theme-remove.doc.mjs +7 -0
  207. package/clients/cli/commands/theme-targets.doc.mjs +1 -0
  208. package/clients/cli/commands/theme-template.doc.mjs +1 -0
  209. package/clients/cli/commands/theme-use.doc.mjs +7 -0
  210. package/clients/cli/commands/upgrade.config-ordering.test.mjs +2 -1
  211. package/clients/cli/commands/upgrade.doc.mjs +8 -1
  212. package/clients/cli/commands/upgrade.file-protection.test.mjs +3 -2
  213. package/clients/cli/commands/upgrade.hook-output.test.mjs +2 -1
  214. package/clients/cli/index.mjs +84 -13
  215. package/clients/cli/lib/cli-error.mjs +4 -1
  216. package/clients/cli/lib/component-format.test.mjs +1 -1
  217. package/clients/cli/lib/define-command.mjs +2 -2
  218. package/clients/cli/lib/json-shim.mjs +3 -1
  219. package/clients/cli/lib/manifest.d.ts +9 -0
  220. package/clients/cli/lib/manifest.mjs +17 -1
  221. package/clients/cli/lib/manifest.test.mjs +25 -0
  222. package/foundation/agent-docs/agent-doc-state.d.mts +21 -6
  223. package/foundation/agent-docs/agent-doc-state.mjs +29 -7
  224. package/foundation/agent-docs/agent-docs.d.mts +2 -2
  225. package/foundation/agent-docs/agent-docs.mjs +3 -3
  226. package/foundation/agent-docs/computer-agent-text.d.mts +133 -0
  227. package/foundation/agent-docs/computer-agent-text.mjs +623 -0
  228. package/foundation/agent-docs/computer-agent-text.test.mjs +602 -0
  229. package/foundation/config/project.d.mts +35 -3
  230. package/foundation/config/project.mjs +145 -8
  231. package/foundation/config/project.test.mjs +66 -0
  232. package/foundation/config/theme-state.mjs +5 -4
  233. package/foundation/discovery/cli-self-docs.mjs +20 -3
  234. package/foundation/discovery/cli-self-docs.test.mjs +3 -2
  235. package/foundation/discovery/component-replacement.mjs +2 -1
  236. package/foundation/discovery/runner-allowlist.d.mts +40 -0
  237. package/foundation/discovery/runner-allowlist.mjs +53 -0
  238. package/foundation/discovery/template-needs.mjs +5 -2
  239. package/foundation/discovery/theme-imports.mjs +8 -4
  240. package/foundation/discovery/theme-imports.test.mjs +1 -1
  241. package/foundation/doc-compiler/doc-loads.test.mjs +20 -0
  242. package/foundation/doc-compiler/inputs.mjs +4 -1
  243. package/foundation/doc-compiler/read.d.mts +1 -1
  244. package/foundation/doc-compiler/tree.test.mjs +1 -1
  245. package/foundation/env/cli-command.d.mts +83 -0
  246. package/foundation/env/cli-command.mjs +152 -0
  247. package/foundation/env/cli-command.test.mjs +129 -0
  248. package/foundation/env/node-version.test.mjs +15 -3
  249. package/foundation/env/package-manager.d.mts +61 -9
  250. package/foundation/env/package-manager.global.test.mjs +66 -0
  251. package/foundation/env/package-manager.mjs +137 -13
  252. package/foundation/env/package-manager.test.mjs +148 -9
  253. package/foundation/env/project-scope.d.mts +9 -0
  254. package/foundation/env/project-scope.mjs +33 -0
  255. package/foundation/env/search-path.d.mts +42 -0
  256. package/foundation/env/search-path.mjs +205 -0
  257. package/foundation/env/search-path.test.mjs +122 -0
  258. package/foundation/env/user-dirs.d.mts +39 -0
  259. package/foundation/env/user-dirs.mjs +93 -0
  260. package/foundation/env/user-dirs.test.mjs +72 -0
  261. package/foundation/env/user-settings.d.mts +46 -0
  262. package/foundation/env/user-settings.mjs +106 -0
  263. package/foundation/env/user-settings.test.mjs +64 -0
  264. package/foundation/fs/file-protection.mjs +15 -1
  265. package/foundation/fs/module-loader.stdout.test.mjs +3 -2
  266. package/foundation/fs/path-compare.d.mts +33 -0
  267. package/foundation/fs/path-compare.mjs +73 -0
  268. package/foundation/fs/paths.d.mts +57 -1
  269. package/foundation/fs/paths.mjs +131 -3
  270. package/foundation/fs/paths.test.mjs +10 -1
  271. package/foundation/integrations/computer-integrations.d.mts +78 -0
  272. package/foundation/integrations/computer-integrations.mjs +316 -0
  273. package/foundation/integrations/computer-integrations.test.mjs +292 -0
  274. package/foundation/integrations/integration-warnings.mjs +3 -2
  275. package/foundation/integrations/integration-warnings.test.mjs +8 -9
  276. package/foundation/integrations/integrations.d.mts +25 -1
  277. package/foundation/integrations/integrations.mjs +46 -3
  278. package/foundation/integrations/validate-contributions.d.mts +2 -0
  279. package/foundation/integrations/validate-contributions.mjs +11 -0
  280. package/foundation/release/agent-text-worker.d.mts +4 -0
  281. package/foundation/release/agent-text-worker.mjs +52 -0
  282. package/foundation/release/cache.d.mts +310 -0
  283. package/foundation/release/cache.mjs +1216 -0
  284. package/foundation/release/cache.test.mjs +920 -0
  285. package/foundation/release/choose.d.mts +207 -0
  286. package/foundation/release/choose.mjs +677 -0
  287. package/foundation/release/choose.test.mjs +427 -0
  288. package/foundation/release/core-worker.d.mts +4 -0
  289. package/foundation/release/core-worker.mjs +38 -0
  290. package/foundation/release/global-state.d.mts +259 -0
  291. package/foundation/release/global-state.mjs +472 -0
  292. package/foundation/release/global-state.test.mjs +381 -0
  293. package/foundation/release/handoff.d.mts +60 -0
  294. package/foundation/release/handoff.e2e.test.mjs +278 -0
  295. package/foundation/release/handoff.mjs +357 -0
  296. package/foundation/release/lock-lease.d.mts +23 -0
  297. package/foundation/release/lock-lease.mjs +80 -0
  298. package/foundation/release/notices.d.mts +253 -0
  299. package/foundation/release/notices.mjs +596 -0
  300. package/foundation/release/notices.test.mjs +565 -0
  301. package/foundation/release/npm-guard.d.mts +4 -0
  302. package/foundation/release/npm-guard.mjs +126 -0
  303. package/foundation/release/project.d.mts +141 -0
  304. package/foundation/release/project.mjs +466 -0
  305. package/foundation/release/project.test.mjs +288 -0
  306. package/foundation/release/refresh-worker.d.mts +4 -0
  307. package/foundation/release/refresh-worker.mjs +27 -0
  308. package/foundation/release/run-context.d.mts +47 -0
  309. package/foundation/release/run-context.mjs +149 -0
  310. package/foundation/release/update-notice-env.d.mts +28 -0
  311. package/foundation/release/update-notice-env.mjs +39 -0
  312. package/foundation/response/base.d.ts +26 -3
  313. package/foundation/response/error-codes.d.mts +3 -1
  314. package/foundation/response/error-codes.doc.mjs +12 -0
  315. package/foundation/response/error-codes.mjs +17 -0
  316. package/foundation/response/error-codes.test.mjs +2 -0
  317. package/foundation/response/json-contract.test.mjs +7 -2
  318. package/foundation/response/json.mjs +4 -1
  319. package/foundation/response/response-types.doc.mjs +8 -3
  320. package/foundation/response/response-types.doc.test.mjs +46 -0
  321. package/foundation/response/response.doc.mjs +3 -3
  322. package/foundation/xle/browser-imports.test.mjs +74 -0
  323. package/package.json +9 -9
  324. package/scripts/postinstall.mjs +21 -2
@@ -19,9 +19,12 @@
19
19
 
20
20
  import {createHash} from 'node:crypto';
21
21
  import * as fs from 'node:fs';
22
- import * as os from 'node:os';
23
22
  import * as path from 'node:path';
24
- import {Project} from '../../foundation/config/project.mjs';
23
+ import {
24
+ Project,
25
+ availableComputerIntegrations,
26
+ } from '../../foundation/config/project.mjs';
27
+ import {isOutsideProject} from '../../foundation/env/project-scope.mjs';
25
28
  import {
26
29
  scanAllPackages,
27
30
  findComponentInPackages,
@@ -31,6 +34,7 @@ import {collectIdentities} from '../../foundation/integrations/contribution-inve
31
34
  import {detectPackageManager} from '../../foundation/env/package-manager.mjs';
32
35
  import {isValidSemver, semverCompare} from '../../foundation/env/semver.mjs';
33
36
  import {assertWithin} from '../../foundation/fs/path-safety.mjs';
37
+ import {userCacheDir} from '../../foundation/env/user-dirs.mjs';
34
38
  import {CLI_ROOT, findInstalledPackage} from '../../foundation/fs/paths.mjs';
35
39
  import {parseDiscoverCatalog} from '../../authoring/discover/parse.mjs';
36
40
  import {AstryxError} from '../error.mjs';
@@ -245,6 +249,38 @@ export function hasSources(project) {
245
249
  );
246
250
  }
247
251
 
252
+ /** The source name of a package installed for the computer. */
253
+ const COMPUTER_SOURCE = 'installed for this computer';
254
+
255
+ /**
256
+ * The integrations installed for the computer that a project could add, as
257
+ * available entries with the project's install command (spec AST-081 FR12).
258
+ * Empty outside a project, where they load instead.
259
+ * @param {Project | undefined} project
260
+ * @param {Array<{name: string}>} installed
261
+ * @param {Set<string>} declared
262
+ * @param {(name: string, version?: string) => string} add
263
+ * @returns {Promise<import('./discover.type.mjs').DiscoverAvailableEntry[]>}
264
+ */
265
+ export async function computerAvailableEntries(
266
+ project,
267
+ installed,
268
+ declared,
269
+ add,
270
+ ) {
271
+ const cwd = project?.cwd ?? process.cwd();
272
+ if (isOutsideProject(cwd)) return [];
273
+ const have = new Set([...installed.map(pkg => pkg.name), ...declared]);
274
+ return (await availableComputerIntegrations(cwd, have)).map(c => ({
275
+ name: c.name,
276
+ components: [],
277
+ ...(c.version ? {version: c.version} : {}),
278
+ ...(c.description ? {description: c.description} : {}),
279
+ source: COMPUTER_SOURCE,
280
+ install: add(c.name),
281
+ }));
282
+ }
283
+
248
284
  /**
249
285
  * Package names the project's package.json declares in any dependency field.
250
286
  * @param {Project | undefined} project
@@ -438,21 +474,7 @@ export function addCommand(project, {official = []} = {}) {
438
474
  * @returns {string}
439
475
  */
440
476
  export function defaultCacheDir() {
441
- const home = os.homedir();
442
- if (process.platform === 'win32') {
443
- return path.join(
444
- process.env.LOCALAPPDATA || path.join(home, 'AppData', 'Local'),
445
- 'astryx',
446
- 'Cache',
447
- );
448
- }
449
- if (process.platform === 'darwin') {
450
- return path.join(home, 'Library', 'Caches', 'astryx');
451
- }
452
- return path.join(
453
- process.env.XDG_CACHE_HOME || path.join(home, '.cache'),
454
- 'astryx',
455
- );
477
+ return userCacheDir();
456
478
  }
457
479
 
458
480
  /**
@@ -21,7 +21,8 @@ export const doc = {
21
21
  'project and its integrations list, with what each one adds per kind. An @scope/name query shows one package with every ' +
22
22
  'version its source knows; @scope/name@version shows one version; @scope/name/Component returns an installed ' +
23
23
  "component's validated doc, and any other item path returns that item. A free-text term searches every item and " +
24
- 'package. Discover only reads: it prints the command that adds a package and never runs it.',
24
+ 'package. Discover only reads: it prints the command that adds a package and never runs it.' +
25
+ " In global mode: with `cwd` outside a project, integrations installed next to this CLI package globally are listed as installed; inside a project, only the project's own are, and the compatible global ones are listed in `meta.available` with source `installed for this computer` and an `install` command. See {@link namespace:global} and {@link generic:computer-integrations}.",
25
26
  importPath: '@astryxdesign/cli/api',
26
27
  signature:
27
28
  'discover(query?: string, options?: DiscoverOptions): Promise<DiscoverListResponse | DiscoverDetailResponse | DiscoverDetailDocResponse | DiscoverItemResponse | DiscoverSearchResponse>',
@@ -90,7 +91,7 @@ export const doc = {
90
91
  {
91
92
  type: 'discover.list',
92
93
  description:
93
- 'What the project has: the integrations it loads and the official packages it declares (name, category, components, version, and a list per other kind they add), official packages first. meta.available lists what the project could add, official packages first, each with the command that adds it, and meta.sources reports each source, the official list last. When it lists no integration it carries meta.configured.',
94
+ 'What the project has: the integrations it loads and the official packages it declares (name, category, components, version, and a list per other kind they add), official packages first. meta.available lists what the project could add, official packages first, each with the command that adds it; inside a project, an integration installed for the computer that the project does not install is listed there too, with source `installed for this computer` and the install command for the project in `install`. meta.sources reports each source, the official list last. When it lists no integration it carries meta.configured.',
94
95
  },
95
96
  {
96
97
  type: 'discover.detail',
@@ -27,6 +27,7 @@ export {OFFICIAL_SOURCE_NAME} from './_adapter.mjs';
27
27
  import {
28
28
  addCommand,
29
29
  callSources,
30
+ computerAvailableEntries,
30
31
  declaredDependencies,
31
32
  describeInstalled,
32
33
  discoverPackages,
@@ -216,18 +217,31 @@ export async function discover(query, options = {}) {
216
217
  if (!query || (integrations.length === 0 && !hasSources(project))) {
217
218
  const catalog = await catalogFor();
218
219
  const packages = installedFor(catalog);
220
+ // Inside a project, the integrations installed for the computer are
221
+ // available, never loaded (spec AST-081 FR12).
222
+ const computer = await computerAvailableEntries(
223
+ project,
224
+ packages,
225
+ declared,
226
+ add,
227
+ );
228
+ const fromSources = officialFirst(
229
+ availableEntries(catalog, packages, declared, {
230
+ officialDeclared: declarations.any,
231
+ install: installFor,
232
+ }),
233
+ official.packages,
234
+ entry => entry.name,
235
+ );
236
+ const named = new Set(fromSources.map(entry => entry.name));
219
237
  return list(withLatest(packages, catalog), {
220
238
  configured,
221
239
  type,
222
240
  only,
223
- available: officialFirst(
224
- availableEntries(catalog, packages, declared, {
225
- officialDeclared: declarations.any,
226
- install: installFor,
227
- }),
228
- official.packages,
229
- entry => entry.name,
230
- ),
241
+ available: [
242
+ ...fromSources,
243
+ ...computer.filter(entry => !named.has(entry.name)),
244
+ ],
231
245
  sources: catalog.sources,
232
246
  });
233
247
  }
@@ -94,12 +94,14 @@ export type DiscoverAvailableEntry = {
94
94
  aliases?: string[] | undefined;
95
95
  /**
96
96
  * The discover source that lists it; `Astryx` for
97
- * the official list.
97
+ * the official list; `installed for this computer` for an integration
98
+ * installed beside the CLI that the project does not install (spec AST-081
99
+ * FR12).
98
100
  */
99
101
  source: string;
100
102
  /**
101
- * The package-manager command that adds it;
102
- * discover prints it and never runs it.
103
+ * The package-manager command that adds it to
104
+ * this project; discover prints it and never runs it.
103
105
  */
104
106
  install?: string | undefined;
105
107
  };
@@ -71,9 +71,11 @@
71
71
  * @property {string} [description]
72
72
  * @property {string[]} [aliases] The integration's other package names.
73
73
  * @property {string} source The discover source that lists it; `Astryx` for
74
- * the official list.
75
- * @property {string} [install] The package-manager command that adds it;
76
- * discover prints it and never runs it.
74
+ * the official list; `installed for this computer` for an integration
75
+ * installed beside the CLI that the project does not install (spec AST-081
76
+ * FR12).
77
+ * @property {string} [install] The package-manager command that adds it to
78
+ * this project; discover prints it and never runs it.
77
79
  */
78
80
 
79
81
  /**
@@ -70,6 +70,7 @@ import {
70
70
  import {findCoreDir} from '../../foundation/fs/paths.mjs';
71
71
  import {AstryxError} from '../error.mjs';
72
72
  import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
73
+ import {formatCliCommand} from '../../foundation/env/package-manager.mjs';
73
74
 
74
75
  export {OVERLAY_LANGUAGES, overlayLanguages};
75
76
 
@@ -1596,7 +1597,7 @@ export async function unknownTopicError(topic, catalog) {
1596
1597
  export function notLoaded(catalog) {
1597
1598
  const packages = [...new Set(catalog.issues.map(issue => issue.package))];
1598
1599
  if (packages.length === 0) return '';
1599
- return `. The docs of ${packages.join(', ')} did not load; run \`astryx doctor integration docs\` in that package to see why.`;
1600
+ return `. The docs of ${packages.join(', ')} did not load; run \`${formatCliCommand('doctor integration docs')}\` in that package to see why.`;
1600
1601
  }
1601
1602
 
1602
1603
  /**
@@ -1614,7 +1615,7 @@ export async function resolveTopicDocs(topic, options = {}) {
1614
1615
  if (found.kind !== 'topic') {
1615
1616
  throw found.kind === 'node'
1616
1617
  ? new AstryxError(
1617
- `"${found.node.route}" is a ${found.node.kind === 'namespace' ? 'namespace' : `${found.node.kind} doc`} in the docs tree, not a topic. Read it with \`astryx docs ${found.node.route}\`.`,
1618
+ `"${found.node.route}" is a ${found.node.kind === 'namespace' ? 'namespace' : `${found.node.kind} doc`} in the docs tree, not a topic. Read it with \`${formatCliCommand(`docs ${found.node.route}`)}\`.`,
1618
1619
  undefined,
1619
1620
  ERROR_CODES.ERR_UNKNOWN_TOPIC,
1620
1621
  )
@@ -34,7 +34,8 @@ export const doc = {
34
34
  'for a typed doc, `related` to the docs it names (its command or function, ' +
35
35
  'and its related docs); `previous` and `next` ' +
36
36
  'to the section or node before and after it. ' +
37
- 'Overlay options select localized or dense variants.',
37
+ 'Overlay options select localized or dense variants.' +
38
+ " In global mode: with `cwd` outside a project, doc topics from integrations installed next to this CLI package globally are listed too; inside a project, only the project's own integrations count. See {@link namespace:global} and {@link generic:computer-integrations}.",
38
39
  importPath: '@astryxdesign/cli/api',
39
40
  signature:
40
41
  'docs(topic?: string, section?: string, options?: DocsOptions): Promise<DocsListResponse | DocsIndexResponse | DocsDetailResponse | DocsDetailSectionResponse | DocsNodeResponse>',
package/api/docs/docs.mjs CHANGED
@@ -34,6 +34,7 @@ import {node as nodeLeaf, nodeView} from './node/node.mjs';
34
34
  import {resolveDocsArgument} from './_adapter.mjs';
35
35
  import {AstryxError} from '../error.mjs';
36
36
  import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
37
+ import {formatCliCommand} from '../../foundation/env/package-manager.mjs';
37
38
 
38
39
  export {list, index, detail, sectionLeaf as section, nodeLeaf as node};
39
40
 
@@ -108,7 +109,7 @@ export async function docs(topic, section, options = {}) {
108
109
  return namespaceSection(found.tree, found.node, section, options);
109
110
  }
110
111
  throw new AstryxError(
111
- `"${found.node.route}" has no sections. Read it whole: astryx docs ${found.node.route}.`,
112
+ `"${found.node.route}" has no sections. Read it whole: ${formatCliCommand(`docs ${found.node.route}`)}.`,
112
113
  [{name: found.node.route, reason: found.node.summary}],
113
114
  ERROR_CODES.ERR_UNKNOWN_SECTION,
114
115
  );
@@ -11,6 +11,7 @@
11
11
  import {describe, it, expect} from 'vitest';
12
12
  import {docs} from './docs.mjs';
13
13
  import {AstryxError} from '../error.mjs';
14
+ import {formatCliCommand} from '../../foundation/env/package-manager.mjs';
14
15
 
15
16
  const SLOW = 30_000;
16
17
 
@@ -92,7 +93,7 @@ describe('docs() dispatcher routing', () => {
92
93
 
93
94
  it("lists the docs tree's namespaces in meta, so every data entry reads as a topic", async () => {
94
95
  const res = await docs();
95
- expect(res.meta.namespaces.map(entry => entry.topic)).toEqual(['cli', 'internationalization', 'layout', 'migration', 'styling', 'styling-libraries', 'tokens', 'typography', 'unorganized']);
96
+ expect(res.meta.namespaces.map(entry => entry.topic)).toEqual(['cli', 'global', 'internationalization', 'layout', 'migration', 'styling', 'styling-libraries', 'tokens', 'typography', 'unorganized']);
96
97
  for (const entry of res.data) {
97
98
  expect((await docs(entry.topic)).type).toBe('docs.detail');
98
99
  }
@@ -107,7 +108,9 @@ describe('docs() dispatcher routing', () => {
107
108
  it('a section of a typed doc -> ERR_UNKNOWN_SECTION, suggesting the doc itself', async () => {
108
109
  const err = await docs('cli/api/functions/search', 'x').catch(e => e);
109
110
  expect(err.code).toBe('ERR_UNKNOWN_SECTION');
110
- expect(err.message).toContain('astryx docs cli/api/functions/search');
111
+ expect(err.message).toContain(
112
+ formatCliCommand('docs cli/api/functions/search'),
113
+ );
111
114
  expect(err.suggestions.map(s => s.name)).toEqual(['cli/api/functions/search']);
112
115
  }, SLOW);
113
116
 
@@ -276,9 +276,7 @@ describe('a reference block in a topic section', () => {
276
276
  expect(status).toBe(0);
277
277
  expect(stdout).toMatch(/^Field +\| Type +\| Required +\| Description/m);
278
278
  expect(stdout).toMatch(/^components +\| string +\| no +\| /m);
279
- expect(stdout).toContain(
280
- 'From Astryx Integration: `astryx docs authoring integration`',
281
- );
279
+ expect(stdout).toContain(' docs authoring integration`');
282
280
  },
283
281
  SLOW,
284
282
  );
@@ -43,8 +43,116 @@ export function findDoctorInstalledPackage(projectDir: string, packageName: stri
43
43
  export function listDoctorThemePackages(cwd: string): string[];
44
44
  /** @param {string} file */
45
45
  export function readPackageJson(file: string): any;
46
+ /**
47
+ * The integrations installed for the computer, and, outside a project, which
48
+ * of them the folder loads (spec AST-081 FR12): those it uses, and the names
49
+ * of the integrations the folder loads itself, whose copies win.
50
+ * @param {string} cwd
51
+ * @returns {Promise<{computerIntegrations: import('../../foundation/integrations/computer-integrations.mjs').ComputerIntegrationCandidate[], loadedComputerIntegrations: string[], folderIntegrations: string[]}>}
52
+ */
53
+ export function computerIntegrationsOutside(cwd: string): Promise<{
54
+ computerIntegrations: import("../../foundation/integrations/computer-integrations.mjs").ComputerIntegrationCandidate[];
55
+ loadedComputerIntegrations: string[];
56
+ folderIntegrations: string[];
57
+ }>;
58
+ /**
59
+ * Inside a project: the integrations installed for the computer it could add
60
+ * (spec AST-081 FR12), leaving out every package it loads or declares.
61
+ * @param {string} cwd
62
+ * @param {string[]} loadedNames the integrations the project loads
63
+ * @returns {Promise<import('../../foundation/integrations/computer-integrations.mjs').ComputerIntegrationCandidate[]>}
64
+ */
65
+ export function computerIntegrationsToAdd(cwd: string, loadedNames: string[]): Promise<import("../../foundation/integrations/computer-integrations.mjs").ComputerIntegrationCandidate[]>;
66
+ /**
67
+ * The computer-level agent text's setting and its state on disk.
68
+ * @returns {{settings: import('../../foundation/env/user-settings.mjs').ComputerAgentTextSettings, entries: Array<{path: string, state: import('../../foundation/agent-docs/computer-agent-text.mjs').ComputerAgentTextState, link?: true}>}}
69
+ */
70
+ export function computerAgentTextState(): {
71
+ settings: import("../../foundation/env/user-settings.mjs").ComputerAgentTextSettings;
72
+ entries: Array<{
73
+ path: string;
74
+ state: import("../../foundation/agent-docs/computer-agent-text.mjs").ComputerAgentTextState;
75
+ link?: true;
76
+ }>;
77
+ };
78
+ /**
79
+ * The release facts doctor reports, read here so the checks stay pure
80
+ * (spec AST-081 FR5, FR6, FR10; architecture:cli-surface INV21): who
81
+ * answered, the newest release the computer knows of, how far the global copy
82
+ * or the project is behind, and every `astryx` on the search path with the
83
+ * command that upgrades it.
84
+ * @param {string} cwd
85
+ * @param {{project: boolean}} options
86
+ * @returns {{answeredBy: {cli: string, core: string | null, copy: string}, latest: string | null, globalBehind: ReturnType<typeof globalBehind> | null, projectLag: ReturnType<typeof projectLag> | null, lastNoticeSkip: ReturnType<typeof lastNoticeSkip>, lastCheckFailure: ReturnType<typeof lastCheckFailure>, stateLock: ReturnType<typeof stateLockHolder>, searchPathCommands: Array<import('../../foundation/env/search-path.mjs').SearchPathCommand & {upgrade: string | null}>}}
87
+ */
88
+ export function releaseFacts(cwd: string, { project }: {
89
+ project: boolean;
90
+ }): {
91
+ answeredBy: {
92
+ cli: string;
93
+ core: string | null;
94
+ copy: string;
95
+ };
96
+ latest: string | null;
97
+ globalBehind: ReturnType<typeof globalBehind> | null;
98
+ projectLag: ReturnType<typeof projectLag> | null;
99
+ lastNoticeSkip: ReturnType<typeof lastNoticeSkip>;
100
+ lastCheckFailure: ReturnType<typeof lastCheckFailure>;
101
+ stateLock: ReturnType<typeof stateLockHolder>;
102
+ searchPathCommands: Array<import("../../foundation/env/search-path.mjs").SearchPathCommand & {
103
+ upgrade: string | null;
104
+ }>;
105
+ };
106
+ /** Whether `cwd` is outside every project. */
107
+ export function outsideProject(cwd: string): boolean;
108
+ /**
109
+ * The commands that bring a project's own CLI and Core to one release, with
110
+ * the project's package manager: Core up to the CLI, then its codemods, when
111
+ * the CLI is newer; else the CLI to the Core's release.
112
+ * @param {string} cwd
113
+ * @param {string} cli
114
+ * @param {string} core
115
+ * @returns {string}
116
+ */
117
+ export function alignCommand(cwd: string, cli: string, core: string): string;
118
+ /**
119
+ * The Core release the project at `cwd` names: installed, else locked, else
120
+ * declared; the version the daily hint and notice compare against (spec
121
+ * AST-081 FR2). Null outside a project or when it names none.
122
+ * @param {string} cwd
123
+ * @returns {string | null}
124
+ */
125
+ export function projectCoreVersion(cwd: string): string | null;
126
+ /**
127
+ * Whether the project at `cwd` installs its own CLI (spec AST-081 FR2).
128
+ * @param {string} cwd
129
+ * @returns {boolean}
130
+ */
131
+ export function projectHasOwnCli(cwd: string): boolean;
132
+ /**
133
+ * The command that adds the CLI at `version` with the project's package
134
+ * manager.
135
+ * @param {string} cwd
136
+ * @param {string} version
137
+ * @returns {string}
138
+ */
139
+ export function addCliCommandFor(cwd: string, version: string): string;
140
+ /**
141
+ * The command that adds a package with the folder's package manager, read
142
+ * from its lockfiles and `packageManager` field.
143
+ * @param {string} cwd
144
+ * @returns {(name: string) => string}
145
+ */
146
+ export function installCommandFor(cwd: string): (name: string) => string;
46
147
  export { resolveRecordedTheme } from "../theme/theme.mjs";
47
148
  export { collectUnloadedFonts } from "../theme/build/font-warning.mjs";
48
149
  export const SOURCE_EXTENSIONS: Set<string>;
150
+ export { displayHomePath };
151
+ import { globalBehind } from '../../foundation/release/notices.mjs';
152
+ import { projectLag } from '../../foundation/release/notices.mjs';
153
+ import { lastNoticeSkip } from '../../foundation/release/notices.mjs';
154
+ import { lastCheckFailure } from '../../foundation/release/global-state.mjs';
155
+ import { stateLockHolder } from '../../foundation/release/global-state.mjs';
156
+ import { displayHomePath } from '../../foundation/agent-docs/computer-agent-text.mjs';
49
157
  export { isLocalThemeOwner, planThemeAppWrite, readThemeState, resolveThemeModule } from "../../foundation/config/theme-state.mjs";
50
158
  export { themeBuild, validateThemePrivateInputs } from "../theme/build/build.mjs";
@@ -2,15 +2,52 @@
2
2
 
3
3
  /** @file Environment adapter for app-theme doctor evidence. */
4
4
 
5
+ import {isOutsideProject} from '../../foundation/env/project-scope.mjs';
6
+ import {answeredBy} from '../../foundation/release/run-context.mjs';
7
+ import {
8
+ knownLatestRelease,
9
+ lastCheckFailure,
10
+ stateLockHolder,
11
+ } from '../../foundation/release/global-state.mjs';
12
+ import {
13
+ addCliCommand,
14
+ alignCliAndCore,
15
+ globalBehind,
16
+ globalUpgradeCommand,
17
+ lastNoticeSkip,
18
+ projectLag,
19
+ } from '../../foundation/release/notices.mjs';
20
+ import {
21
+ coreVersionOf,
22
+ isGlobalCopy,
23
+ projectRootOf,
24
+ } from '../../foundation/release/choose.mjs';
25
+ import {readReleaseFacts} from '../../foundation/release/project.mjs';
26
+ import {detectPackageManager} from '../../foundation/env/package-manager.mjs';
27
+ import {astryxCommandsOnSearchPath} from '../../foundation/env/search-path.mjs';
28
+ import {readDeclaredDependencies} from '../../foundation/integrations/autolink.mjs';
29
+ import {
30
+ displayHomePath,
31
+ inspectComputerAgentText,
32
+ } from '../../foundation/agent-docs/computer-agent-text.mjs';
33
+ import {computerAgentTextSettings} from '../../foundation/env/user-settings.mjs';
5
34
  import * as fs from 'node:fs';
6
35
  import * as path from 'node:path';
7
- import {Project} from '../../foundation/config/project.mjs';
36
+ import {
37
+ Project,
38
+ availableComputerIntegrations,
39
+ computerIntegrationCandidates,
40
+ } from '../../foundation/config/project.mjs';
8
41
  import {
9
42
  discoverUnmigratedThemeCopies,
10
43
  themeImportPackage,
11
44
  } from '../../foundation/discovery/theme-discovery.mjs';
12
45
  import {resolveThemeImports} from '../../foundation/discovery/theme-imports.mjs';
13
- import {findCoreDir, findInstalledPackage} from '../../foundation/fs/paths.mjs';
46
+ import {
47
+ CLI_ROOT,
48
+ findProjectCoreDir,
49
+ findInstalledPackage,
50
+ } from '../../foundation/fs/paths.mjs';
14
51
  export {
15
52
  isLocalThemeOwner,
16
53
  planThemeAppWrite,
@@ -104,7 +141,7 @@ export function listProjectSourceFiles(root, generatedModule) {
104
141
 
105
142
  /** @param {string} projectDir */
106
143
  export async function discoverDoctorThemes(projectDir) {
107
- const project = await Project.load(projectDir);
144
+ const project = await Project.load(projectDir, {core: 'project'});
108
145
  return project.themes();
109
146
  }
110
147
 
@@ -124,7 +161,7 @@ export function discoverDoctorUnmigratedCopies(projectDir) {
124
161
 
125
162
  /** @param {string} projectDir */
126
163
  export function findDoctorCoreDir(projectDir) {
127
- return findCoreDir(projectDir);
164
+ return findProjectCoreDir(projectDir);
128
165
  }
129
166
 
130
167
  /** @param {string} projectDir @param {string} packageName */
@@ -188,3 +225,185 @@ export function readPackageJson(file) {
188
225
  return null;
189
226
  }
190
227
  }
228
+
229
+ /**
230
+ * The integrations installed for the computer, and, outside a project, which
231
+ * of them the folder loads (spec AST-081 FR12): those it uses, and the names
232
+ * of the integrations the folder loads itself, whose copies win.
233
+ * @param {string} cwd
234
+ * @returns {Promise<{computerIntegrations: import('../../foundation/integrations/computer-integrations.mjs').ComputerIntegrationCandidate[], loadedComputerIntegrations: string[], folderIntegrations: string[]}>}
235
+ */
236
+ export async function computerIntegrationsOutside(cwd) {
237
+ const computerIntegrations = computerIntegrationCandidates(cwd);
238
+ if (computerIntegrations.length === 0) {
239
+ return {
240
+ computerIntegrations,
241
+ loadedComputerIntegrations: [],
242
+ folderIntegrations: [],
243
+ };
244
+ }
245
+ try {
246
+ const project = await Project.load(cwd, {core: 'project'});
247
+ /** @type {Array<{name: string, __computer?: boolean, __loadError?: string}>} */
248
+ const loaded = project.loadedIntegrations;
249
+ return {
250
+ computerIntegrations,
251
+ loadedComputerIntegrations: loaded
252
+ .filter(i => i.__computer && !i.__loadError)
253
+ .map(i => i.name),
254
+ folderIntegrations: loaded.filter(i => !i.__computer).map(i => i.name),
255
+ };
256
+ } catch {
257
+ return {
258
+ computerIntegrations,
259
+ loadedComputerIntegrations: [],
260
+ folderIntegrations: [],
261
+ };
262
+ }
263
+ }
264
+
265
+ /**
266
+ * Inside a project: the integrations installed for the computer it could add
267
+ * (spec AST-081 FR12), leaving out every package it loads or declares.
268
+ * @param {string} cwd
269
+ * @param {string[]} loadedNames the integrations the project loads
270
+ * @returns {Promise<import('../../foundation/integrations/computer-integrations.mjs').ComputerIntegrationCandidate[]>}
271
+ */
272
+ export async function computerIntegrationsToAdd(cwd, loadedNames) {
273
+ const installed = new Set([...loadedNames, ...declaredPackageNames(cwd)]);
274
+ return availableComputerIntegrations(cwd, installed);
275
+ }
276
+
277
+ /**
278
+ * The package names the folder's package.json declares, nearest first.
279
+ * @param {string} cwd
280
+ * @returns {string[]}
281
+ */
282
+ function declaredPackageNames(cwd) {
283
+ for (let dir = path.resolve(cwd); ;) {
284
+ if (fs.existsSync(path.join(dir, 'package.json'))) {
285
+ return readDeclaredDependencies(dir).map(d => d.name);
286
+ }
287
+ const parent = path.dirname(dir);
288
+ if (parent === dir) return [];
289
+ dir = parent;
290
+ }
291
+ }
292
+
293
+ /**
294
+ * The computer-level agent text's setting and its state on disk.
295
+ * @returns {{settings: import('../../foundation/env/user-settings.mjs').ComputerAgentTextSettings, entries: Array<{path: string, state: import('../../foundation/agent-docs/computer-agent-text.mjs').ComputerAgentTextState, link?: true}>}}
296
+ */
297
+ export function computerAgentTextState() {
298
+ const settings = computerAgentTextSettings();
299
+ return {settings, entries: inspectComputerAgentText({links: settings.links})};
300
+ }
301
+
302
+ export {displayHomePath};
303
+
304
+ /**
305
+ * The release facts doctor reports, read here so the checks stay pure
306
+ * (spec AST-081 FR5, FR6, FR10; architecture:cli-surface INV21): who
307
+ * answered, the newest release the computer knows of, how far the global copy
308
+ * or the project is behind, and every `astryx` on the search path with the
309
+ * command that upgrades it.
310
+ * @param {string} cwd
311
+ * @param {{project: boolean}} options
312
+ * @returns {{answeredBy: {cli: string, core: string | null, copy: string}, latest: string | null, globalBehind: ReturnType<typeof globalBehind> | null, projectLag: ReturnType<typeof projectLag> | null, lastNoticeSkip: ReturnType<typeof lastNoticeSkip>, lastCheckFailure: ReturnType<typeof lastCheckFailure>, stateLock: ReturnType<typeof stateLockHolder>, searchPathCommands: Array<import('../../foundation/env/search-path.mjs').SearchPathCommand & {upgrade: string | null}>}}
313
+ */
314
+ export function releaseFacts(cwd, {project}) {
315
+ const answered = answeredBy(cwd);
316
+ return {
317
+ answeredBy: answered,
318
+ latest: knownLatestRelease(),
319
+ lastNoticeSkip: lastNoticeSkip(),
320
+ lastCheckFailure: lastCheckFailure(),
321
+ stateLock: stateLockHolder(),
322
+ globalBehind:
323
+ !project && isGlobalCopy(CLI_ROOT)
324
+ ? globalBehind({self: {version: answered.cli, root: CLI_ROOT}})
325
+ : null,
326
+ // The project's version is its own CLI's, or, with none, its Core's:
327
+ // installed, else locked, else declared, as the daily notice reads it.
328
+ projectLag: project
329
+ ? projectLag({
330
+ cwd,
331
+ current:
332
+ (answered.copy === 'starting' && projectCoreVersion(cwd)) ||
333
+ answered.cli,
334
+ })
335
+ : null,
336
+ searchPathCommands: astryxCommandsOnSearchPath().map(row => ({
337
+ ...row,
338
+ upgrade: row.cliRoot ? globalUpgradeCommand(row.cliRoot) : null,
339
+ })),
340
+ };
341
+ }
342
+
343
+ /** Whether `cwd` is outside every project. */
344
+ export function outsideProject(/** @type {string} */ cwd) {
345
+ return isOutsideProject(cwd);
346
+ }
347
+
348
+ /**
349
+ * The commands that bring a project's own CLI and Core to one release, with
350
+ * the project's package manager: Core up to the CLI, then its codemods, when
351
+ * the CLI is newer; else the CLI to the Core's release.
352
+ * @param {string} cwd
353
+ * @param {string} cli
354
+ * @param {string} core
355
+ * @returns {string}
356
+ */
357
+ export function alignCommand(cwd, cli, core) {
358
+ return alignCliAndCore({cwd, cli, core});
359
+ }
360
+
361
+ /**
362
+ * The Core release the project at `cwd` names: installed, else locked, else
363
+ * declared; the version the daily hint and notice compare against (spec
364
+ * AST-081 FR2). Null outside a project or when it names none.
365
+ * @param {string} cwd
366
+ * @returns {string | null}
367
+ */
368
+ export function projectCoreVersion(cwd) {
369
+ return coreVersionOf(readReleaseFacts(cwd));
370
+ }
371
+
372
+ /**
373
+ * Whether the project at `cwd` installs its own CLI (spec AST-081 FR2).
374
+ * @param {string} cwd
375
+ * @returns {boolean}
376
+ */
377
+ export function projectHasOwnCli(cwd) {
378
+ return Boolean(readReleaseFacts(cwd).cli);
379
+ }
380
+
381
+ /**
382
+ * The command that adds the CLI at `version` with the project's package
383
+ * manager.
384
+ * @param {string} cwd
385
+ * @param {string} version
386
+ * @returns {string}
387
+ */
388
+ export function addCliCommandFor(cwd, version) {
389
+ return addCliCommand(projectRootOf(readReleaseFacts(cwd)) ?? cwd, version);
390
+ }
391
+
392
+ /**
393
+ * The command that adds a package with the folder's package manager, read
394
+ * from its lockfiles and `packageManager` field.
395
+ * @param {string} cwd
396
+ * @returns {(name: string) => string}
397
+ */
398
+ export function installCommandFor(cwd) {
399
+ const pm = detectPackageManager(cwd);
400
+ const verb =
401
+ pm === 'pnpm'
402
+ ? 'pnpm add'
403
+ : pm === 'yarn'
404
+ ? 'yarn add'
405
+ : pm === 'bun'
406
+ ? 'bun add'
407
+ : 'npm install';
408
+ return name => `${verb} ${name}`;
409
+ }