@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
@@ -21,7 +21,8 @@ export const doc = {
21
21
  'incidental prose mentions, so an exact match always sorts first. A component\'s ' +
22
22
  'usage guidance (its best practices) is indexed one tier below its description, ' +
23
23
  'so the words a reader types still find it — but a component that IS the answer ' +
24
- 'always outranks one whose advice merely mentions the term.',
24
+ 'always outranks one whose advice merely mentions the term.' +
25
+ " In global mode: with `cwd` outside a project, items from integrations installed next to this CLI package globally are searched too, and theme results name no step that adds a theme to an app; inside a project, only the project's own integrations count. See {@link namespace:global} and {@link generic:computer-integrations}.",
25
26
  importPath: '@astryxdesign/cli/api',
26
27
  signature:
27
28
  'search(query: string, options?: SearchOptions): Promise<SearchResponse>',
@@ -48,14 +49,14 @@ export const doc = {
48
49
  name: 'options.cwd',
49
50
  type: 'string',
50
51
  description:
51
- "Directory to resolve @astryxdesign/core from. A docs-only or themes-only search (`type: 'doc'` or `type: 'theme'`) does not need it, and a search with no `type` covers the docs and themes alone when core is missing.",
52
+ "Directory to resolve @astryxdesign/core from: the project's installed Core, else, outside a project or in a project with nothing installed, the Core of the release that answers, installed into the per-user cache first when needed. A docs-only or themes-only search (`type: 'doc'` or `type: 'theme'`) does not need it. A search with no `type` covers the docs and themes alone only when that Core cannot be obtained, and then says so in `meta.partial`.",
52
53
  },
53
54
  ],
54
55
  returns: [
55
56
  {
56
57
  type: 'search',
57
58
  description:
58
- 'The query echoed back, `matchCount` (how many candidates matched in total, before `limit`), plus a ranked SearchResultEntry[] bounded by `limit`: each has domain, name, score, reason, description, and follow-up command, plus `import` for components and hooks, `title` for docs, `displayName` and `kind` for templates, and `displayName` for themes. A doc result is the smallest part that answers: one section (with `section`, and a command that reads only it), one docs-tree route, or a topic, whose command lists its sections. `parent` is the command that opens the level above it: the section list of its topic, the namespace a tree node sits in, the Unorganized level for a flat topic, or the topic list for a top-level namespace. Every doc result also carries `package`, the npm package that authored it (for a section, the package its file came from). A theme result is one theme you can import: `name` is its slug, its command is `astryx theme add <slug>`, and `package` is the npm package that ships it (`@astryxdesign/cli` for the CLI\'s own themes).',
59
+ 'The query echoed back, `matchCount` (how many candidates matched in total, before `limit`), plus a ranked SearchResultEntry[] bounded by `limit`: each has domain, name, score, reason, description, and follow-up command, plus `import` for components and hooks, `title` for docs, `displayName` and `kind` for templates, and `displayName` for themes. A doc result is the smallest part that answers: one section (with `section`, and a command that reads only it), one docs-tree route, or a topic, whose command lists its sections. `parent` is the command that opens the level above it: the section list of its topic, the namespace a tree node sits in, the Unorganized level for a flat topic, or the topic list for a top-level namespace. Every doc result also carries `package`, the npm package that authored it (for a section, the package its file came from). A theme result is one theme you can import: `name` is its slug, its command is `astryx theme add <slug>` (outside a project, where there is no app to add it to, `astryx theme eject <slug>`), and `package` is the npm package that ships it (`@astryxdesign/cli` for the CLI\'s own themes). When a search with no `type` could not obtain @astryxdesign/core, `meta.partial` is `{skipped, reason}`: the domains it skipped (`component`, `hook`, `template`) and why; the results are the docs and themes, and text mode prints one line on standard error.',
59
60
  },
60
61
  ],
61
62
  throws: [
@@ -67,6 +68,10 @@ export const doc = {
67
68
  code: 'ERR_CORE_NOT_FOUND',
68
69
  when: '@astryxdesign/core cannot be found from the cwd, and `type` names a domain that reads it: `component`, `hook`, or `template`',
69
70
  },
71
+ {
72
+ code: 'ERR_VERSIONS_UNAVAILABLE',
73
+ when: "`type` names a domain that reads @astryxdesign/core, and outside a project, or in a project with nothing installed, the Core of the release that answers cannot be installed into the per-user cache; a search with no `type` answers with `meta.partial` instead",
74
+ },
70
75
  ],
71
76
  examples: [
72
77
  {label: 'Find a component', code: "const r = await search('button');"},
@@ -82,10 +82,9 @@
82
82
 
83
83
  import {withListingCache} from '../../foundation/fs/listing-cache.mjs';
84
84
  import {readDocView} from '../../foundation/doc-compiler/read.mjs';
85
- import {
86
- discoverExternalPackages,
87
- findCoreDir,
88
- } from '../../foundation/fs/paths.mjs';
85
+ import {discoverExternalPackages} from '../../foundation/fs/paths.mjs';
86
+ import {requireSearchCoreDir} from './_adapter.mjs';
87
+ import {isOutsideProject} from '../../foundation/env/project-scope.mjs';
89
88
  import {
90
89
  discoverComponents,
91
90
  discoverValidIntegrationComponents,
@@ -126,7 +125,7 @@ import {
126
125
  sectionKey,
127
126
  sectionSummary,
128
127
  } from '../../foundation/discovery/docs-section-key.mjs';
129
- import {AstryxError} from '../error.mjs';
128
+ import {AstryxError, coreDirOrThrow} from '../error.mjs';
130
129
  import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
131
130
  import {setResultCoverage} from './coverage.mjs';
132
131
  import {linkSearchResponse} from '../component/_adapter.mjs';
@@ -2128,8 +2127,11 @@ async function gatherThemes(cwd) {
2128
2127
  * @param {string} reason
2129
2128
  * @param {number} matchedTerms - Query concepts this result answered.
2130
2129
  * @param {number} queryTerms - Query concepts there were to answer.
2130
+ * @param {boolean} [outside] - The search runs outside a project, where a
2131
+ * theme cannot be added to an app, so its command forks the source instead
2132
+ * (spec AST-081 FR3).
2131
2133
  */
2132
- function toResult(c, score, reason, matchedTerms, queryTerms) {
2134
+ function toResult(c, score, reason, matchedTerms, queryTerms, outside = false) {
2133
2135
  const base = {
2134
2136
  domain: c.domain,
2135
2137
  name: c._resultName ?? c.name,
@@ -2178,7 +2180,9 @@ function toResult(c, score, reason, matchedTerms, queryTerms) {
2178
2180
  result = {
2179
2181
  ...base,
2180
2182
  displayName: c._displayName,
2181
- command: `astryx theme add ${c.name}`,
2183
+ command: outside
2184
+ ? `astryx theme eject ${c.name}`
2185
+ : `astryx theme add ${c.name}`,
2182
2186
  };
2183
2187
  break;
2184
2188
  default:
@@ -2245,13 +2249,23 @@ async function searchOnce(query, options) {
2245
2249
  // name, it is an error without core; an open search then covers the docs
2246
2250
  // and themes alone.
2247
2251
  const needsCore = !type || !CORELESS_DOMAINS.includes(type);
2248
- const coreDir = needsCore ? findCoreDir(cwd) : null;
2249
- if (type && needsCore && !coreDir) {
2250
- throw new AstryxError(
2251
- 'Could not find @astryxdesign/core package',
2252
- undefined,
2253
- ERROR_CODES.ERR_CORE_NOT_FOUND,
2254
- );
2252
+ // A domain that reads Core gets it as `component` does: the project's, else
2253
+ // the answering release's own, installed into the per-user cache on first
2254
+ // need (spec AST-081 FR3). Asked for by name, a Core that cannot be had is
2255
+ // the error; an open search answers from the rest and says what it skipped
2256
+ // and why, never silently.
2257
+ /** @type {string | null} */
2258
+ let coreDir = null;
2259
+ /** @type {string | null} */
2260
+ let coreSkipped = null;
2261
+ if (needsCore && type) {
2262
+ coreDir = coreDirOrThrow(requireSearchCoreDir, cwd);
2263
+ } else if (needsCore) {
2264
+ try {
2265
+ coreDir = requireSearchCoreDir(cwd);
2266
+ } catch (error) {
2267
+ coreSkipped = /** @type {Error} */ (error).message;
2268
+ }
2255
2269
  }
2256
2270
 
2257
2271
  // Gather candidates from each requested domain in parallel.
@@ -2362,6 +2376,7 @@ async function searchOnce(query, options) {
2362
2376
  // strongest PAGE, not outrank every component.
2363
2377
  /** @type {{result: any, priority: 0 | 1 | 2, key: number, alias: 'partial' | 'keyword' | false, aliasWords: number, candidate: Candidate, span: [number, number] | null, word: [number, number] | null}[]} */
2364
2378
  const ranked = [];
2379
+ const outside = themes.length > 0 && isOutsideProject(cwd);
2365
2380
  for (const candidate of all) {
2366
2381
  const hit = scoreQuery(term, tokens, candidate, words);
2367
2382
  if (hit)
@@ -2372,6 +2387,7 @@ async function searchOnce(query, options) {
2372
2387
  hit.reason,
2373
2388
  hit.matched,
2374
2389
  hit.total,
2390
+ outside,
2375
2391
  ),
2376
2392
  priority: domainPriority(term, tokens, candidate, hit, words),
2377
2393
  key: hit.score,
@@ -2480,6 +2496,14 @@ async function searchOnce(query, options) {
2480
2496
  ),
2481
2497
  },
2482
2498
  };
2499
+ if (coreSkipped) {
2500
+ response.meta = {
2501
+ partial: {
2502
+ skipped: ['component', 'hook', 'template'],
2503
+ reason: coreSkipped,
2504
+ },
2505
+ };
2506
+ }
2483
2507
  if (wants('component')) {
2484
2508
  searchedComponentsOf.set(
2485
2509
  response,
@@ -36,6 +36,7 @@ import {
36
36
  tokenizeQuery,
37
37
  SEARCH_DOMAINS,
38
38
  } from './search.mjs';
39
+ import {linkThisCliAsProjectCli} from '../../test-utils/release-fixtures.mjs';
39
40
 
40
41
  const REPO = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../../..');
41
42
  const cwd = REPO;
@@ -470,8 +471,10 @@ describe('search leaf — error paths (pinned)', () => {
470
471
 
471
472
  it('searches the docs without @astryxdesign/core, and throws for a domain that needs it', async () => {
472
473
  const empty = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-search-no-core-'));
474
+ // A project whose own CLI answers, with no Core installed.
475
+ linkThisCliAsProjectCli(empty);
473
476
  try {
474
- // An open search outside an app covers the docs, as `astryx docs` does.
477
+ // An open search without Core covers the docs, as `astryx docs` does.
475
478
  const open = await search('make an integration', {cwd: empty});
476
479
  expect(open.data.results.length).toBeGreaterThan(0);
477
480
  expect(new Set(open.data.results.map(r => r.domain))).toEqual(
@@ -30,7 +30,7 @@ export type SearchResultEntry = {
30
30
  */
31
31
  description: string;
32
32
  /**
33
- * - Follow-up command to act on this result (e.g. `astryx component Button`, or `astryx theme add neutral` for a theme).
33
+ * - Follow-up command to act on this result (e.g. `astryx component Button`, or `astryx theme add neutral` for a theme; `astryx theme eject neutral` outside a project).
34
34
  */
35
35
  command: string;
36
36
  /**
@@ -72,6 +72,19 @@ export type SearchResponse = {
72
72
  matchCount: number;
73
73
  results: SearchResultEntry[];
74
74
  };
75
+ /**
76
+ * -
77
+ * `partial`, when an open search could not get the Core that components,
78
+ * hooks, and templates are read from (such as outside a project, offline,
79
+ * before the release's Core was downloaded): the domains it skipped and why.
80
+ * The results are the docs and themes.
81
+ */
82
+ meta?: {
83
+ partial?: {
84
+ skipped: SearchDomain[];
85
+ reason: string;
86
+ };
87
+ } | undefined;
75
88
  };
76
89
  /**
77
90
  * Options for `search()`.
@@ -20,7 +20,7 @@
20
20
  * @property {number} score - Relevance score (higher is better).
21
21
  * @property {string} reason - Human-readable reason the candidate matched (e.g. `keyword "button"`).
22
22
  * @property {string} description - One-line description, when available.
23
- * @property {string} command - Follow-up command to act on this result (e.g. `astryx component Button`, or `astryx theme add neutral` for a theme).
23
+ * @property {string} command - Follow-up command to act on this result (e.g. `astryx component Button`, or `astryx theme add neutral` for a theme; `astryx theme eject neutral` outside a project).
24
24
  * @property {string} [import] - Import path — present for component and hook results.
25
25
  * @property {string} [title] - Doc title — present for doc results.
26
26
  * @property {string} [section] - Section key — present when a doc result is one section of a topic; `command` reads only that section.
@@ -38,6 +38,11 @@
38
38
  * @property {string} data.query
39
39
  * @property {number} data.matchCount - How many candidates matched the query in total, before `limit` was applied. `results` is the bounded slice of that set, so `matchCount > results.length` means the answer was capped.
40
40
  * @property {SearchResultEntry[]} data.results
41
+ * @property {{partial?: {skipped: SearchDomain[], reason: string}}} [meta] -
42
+ * `partial`, when an open search could not get the Core that components,
43
+ * hooks, and templates are read from (such as outside a project, offline,
44
+ * before the release's Core was downloaded): the domains it skipped and why.
45
+ * The results are the docs and themes.
41
46
  */
42
47
 
43
48
  /**
@@ -11,7 +11,7 @@
11
11
  * (ERR_CORE_NOT_FOUND) when core can't be located.
12
12
  */
13
13
 
14
- import {findCoreDir, listComponents} from '../../foundation/fs/paths.mjs';
14
+ import {findProjectCoreDir, listComponents} from '../../foundation/fs/paths.mjs';
15
15
  import {resolveComponentReplacements} from '../../foundation/discovery/component-replacement.mjs';
16
16
  import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
17
17
  import {AstryxError} from '../error.mjs';
@@ -44,7 +44,7 @@ export async function resolveComponentReplacement(
44
44
  * @returns {{coreDir: string, components: string[]}}
45
45
  */
46
46
  export function resolveCore(cwd) {
47
- const coreDir = findCoreDir(cwd);
47
+ const coreDir = findProjectCoreDir(cwd);
48
48
  if (!coreDir) {
49
49
  throw new AstryxError(
50
50
  'Could not find @astryxdesign/core package. Make sure you are inside the design system monorepo or have @astryxdesign/core installed.',
@@ -115,7 +115,7 @@ function buildFeedback(component, issuesUrl) {
115
115
  */
116
116
  async function loadConfigSafely(cwd) {
117
117
  try {
118
- const project = await Project.load(cwd);
118
+ const project = await Project.load(cwd, {core: 'project'});
119
119
  return {
120
120
  loadedIntegrations: project.loadedIntegrations,
121
121
  issuesUrl: project.config.issuesUrl,
@@ -736,7 +736,7 @@ describe('integration template discovery', () => {
736
736
  const command = await runCli(['template', 'shell-side-nav'], tmpDir);
737
737
  expect(command.status).toBe(0);
738
738
  expect(command.stderr).toContain('@acme/extra has 1 integration issue');
739
- expect(command.stderr).toContain('astryx doctor');
739
+ expect(command.stderr).toMatch(/Run: .+ doctor/);
740
740
 
741
741
  const doctor = await runCli(['doctor'], tmpDir);
742
742
  expect(doctor.status).toBe(0);
@@ -129,6 +129,22 @@ export function removeThemeFromApp(slug: string, options?: {
129
129
  export function useThemeInApp(slug: string, options?: {
130
130
  cwd?: string;
131
131
  }): Promise<import("./theme.type.mjs").ThemeAppResponse>;
132
+ /**
133
+ * The Core theme targets are read from: the project's, else the release's
134
+ * own, installed into the per-user cache first when needed (a network install
135
+ * and an npm subprocess; spec AST-081 FR3). Throws as requireCoreDir does.
136
+ * @param {string} cwd
137
+ * @returns {string}
138
+ */
139
+ export function requireThemeCoreDir(cwd: string): string;
140
+ /**
141
+ * The Core a theme build reads outside a project: the one the answering copy
142
+ * carries, installed into the per-user cache first when needed (a network
143
+ * install and an npm subprocess; spec AST-081 FR3); null when there is none.
144
+ * @param {string} cwd
145
+ * @returns {string | null}
146
+ */
147
+ export function fetchCarriedThemeCoreDir(cwd: string): string | null;
132
148
  /**
133
149
  * A bundled theme entry kept for the historical public `listThemes()` helper.
134
150
  */
@@ -11,6 +11,10 @@
11
11
 
12
12
  import * as fs from 'node:fs';
13
13
  import * as path from 'node:path';
14
+ import {
15
+ findCarriedCoreDir,
16
+ requireCoreDir,
17
+ } from '../../foundation/fs/paths.mjs';
14
18
  import {Project} from '../../foundation/config/project.mjs';
15
19
  import {
16
20
  BUNDLED_THEME_PACKAGE,
@@ -41,6 +45,7 @@ import {stripCopyrightHeader} from '../../foundation/text/copyright-header.mjs';
41
45
  import {loadIntegrations} from '../../foundation/integrations/integrations.mjs';
42
46
  import {importThemeArtifact} from '../../foundation/fs/module-loader.mjs';
43
47
  import {applyWrites} from '../integration/add-helpers.mjs';
48
+ import {formatCliCommand} from '../../foundation/env/package-manager.mjs';
44
49
 
45
50
  export {BUNDLED_THEME_PACKAGE, THEMES_DIR};
46
51
 
@@ -565,7 +570,7 @@ export function resolveRecordedThemes(state, available) {
565
570
  );
566
571
  if (!theme) {
567
572
  throw new AstryxError(
568
- `Added theme "${slug}" from ${owner} is unavailable. Reinstall the package or restore the local theme, then run \`astryx theme add ${slug} --package ${owner}\`.`,
573
+ `Added theme "${slug}" from ${owner} is unavailable. Reinstall the package or restore the local theme, then run \`${formatCliCommand(`theme add ${slug} --package ${owner}`, state.projectDir)}\`.`,
569
574
  undefined,
570
575
  ERROR_CODES.ERR_UNKNOWN_THEME,
571
576
  );
@@ -732,14 +737,14 @@ export async function removeThemeFromApp(slug, options = {}) {
732
737
  const recordedSlug = recordedThemeSlug(state, slug);
733
738
  if (!state.configured || recordedSlug == null) {
734
739
  throw new AstryxError(
735
- `Theme "${slug}" is not added. Run \`astryx theme add ${slug}\` first.`,
740
+ `Theme "${slug}" is not added. Run \`${formatCliCommand(`theme add ${slug}`, state.projectDir)}\` first.`,
736
741
  undefined,
737
742
  ERROR_CODES.ERR_UNKNOWN_THEME,
738
743
  );
739
744
  }
740
745
  if (state.defaultSlug === recordedSlug) {
741
746
  throw new AstryxError(
742
- `Theme "${recordedSlug}" is the default. Run \`astryx theme use <other-slug>\` before removing it.`,
747
+ `Theme "${recordedSlug}" is the default. Run \`${formatCliCommand('theme use <other-slug>', state.projectDir)}\` before removing it.`,
743
748
  undefined,
744
749
  ERROR_CODES.ERR_THEME_INVALID,
745
750
  );
@@ -748,7 +753,7 @@ export async function removeThemeFromApp(slug, options = {}) {
748
753
  delete themes[recordedSlug];
749
754
  if (state.defaultSlug == null) {
750
755
  throw new AstryxError(
751
- 'The generated theme module has no default theme. Run `astryx theme use <slug>` first.',
756
+ `The generated theme module has no default theme. Run \`${formatCliCommand('theme use <slug>', state.projectDir)}\` first.`,
752
757
  undefined,
753
758
  ERROR_CODES.ERR_THEME_INVALID,
754
759
  );
@@ -776,7 +781,7 @@ export async function useThemeInApp(slug, options = {}) {
776
781
  const recordedSlug = recordedThemeSlug(state, slug);
777
782
  if (!state.configured || recordedSlug == null) {
778
783
  throw new AstryxError(
779
- `Theme "${slug}" is not added. Run \`astryx theme add ${slug}\` first.`,
784
+ `Theme "${slug}" is not added. Run \`${formatCliCommand(`theme add ${slug}`, state.projectDir)}\` first.`,
780
785
  undefined,
781
786
  ERROR_CODES.ERR_UNKNOWN_THEME,
782
787
  );
@@ -792,3 +797,25 @@ export async function useThemeInApp(slug, options = {}) {
792
797
  available,
793
798
  );
794
799
  }
800
+
801
+ /**
802
+ * The Core theme targets are read from: the project's, else the release's
803
+ * own, installed into the per-user cache first when needed (a network install
804
+ * and an npm subprocess; spec AST-081 FR3). Throws as requireCoreDir does.
805
+ * @param {string} cwd
806
+ * @returns {string}
807
+ */
808
+ export function requireThemeCoreDir(cwd) {
809
+ return requireCoreDir(cwd);
810
+ }
811
+
812
+ /**
813
+ * The Core a theme build reads outside a project: the one the answering copy
814
+ * carries, installed into the per-user cache first when needed (a network
815
+ * install and an npm subprocess; spec AST-081 FR3); null when there is none.
816
+ * @param {string} cwd
817
+ * @returns {string | null}
818
+ */
819
+ export function fetchCarriedThemeCoreDir(cwd) {
820
+ return findCarriedCoreDir(cwd, {fetch: true});
821
+ }
@@ -110,13 +110,14 @@ export function themeBuildForReport(file: string, options?: {
110
110
  receipt: import("../theme.type.mjs").ThemeBuildResponse | import("../theme.type.mjs").ThemeBuildCheckResponse | null;
111
111
  trailer: ThemeBuildTrailer | null;
112
112
  }>;
113
- /** @param {string} file @param {{out?: string, check?: boolean, iconsSpecifier?: string}} [options] @param {{cwd?: string}} [ctx] @returns {Promise<import('../theme.type.mjs').ThemeBuildResponse | import('../theme.type.mjs').ThemeBuildCheckResponse | null>} */
113
+ /** @param {string} file @param {{out?: string, check?: boolean, iconsSpecifier?: string}} [options] @param {{cwd?: string, projectCore?: boolean}} [ctx] `projectCore`: read only the project's installed Core, never the carried one (doctor; spec AST-081 FR3) @returns {Promise<import('../theme.type.mjs').ThemeBuildResponse | import('../theme.type.mjs').ThemeBuildCheckResponse | null>} */
114
114
  export function themeBuild(file: string, options?: {
115
115
  out?: string;
116
116
  check?: boolean;
117
117
  iconsSpecifier?: string;
118
118
  }, ctx?: {
119
119
  cwd?: string;
120
+ projectCore?: boolean;
120
121
  }): Promise<import("../theme.type.mjs").ThemeBuildResponse | import("../theme.type.mjs").ThemeBuildCheckResponse | null>;
121
122
  /** @param {string[]} files @param {{familyKey: string, check?: boolean, iconsSpecifier?: string, __onPrivateVarError?: () => void}} options @param {{cwd?: string}} [ctx] */
122
123
  export function themeBuildFamily(files: string[], options: {
@@ -70,7 +70,11 @@ import {
70
70
  CLI_ROOT,
71
71
  findCoreDir,
72
72
  findInstalledPackage,
73
+ findProjectCoreDir,
73
74
  } from '../../../foundation/fs/paths.mjs';
75
+ import {isGlobalCopy} from '../../../foundation/release/choose.mjs';
76
+ import {isInReleaseCache} from '../../../foundation/release/cache.mjs';
77
+ import {fetchCarriedThemeCoreDir} from '../_adapter.mjs';
74
78
  import {
75
79
  assertWithin,
76
80
  sanitizeName,
@@ -306,10 +310,15 @@ function realLocation(target) {
306
310
  *
307
311
  * @param {string} cwd
308
312
  * @param {CoreBindings} cliCore - The CLI's own Core, from {@link loadCliCore}.
313
+ * @param {{projectOnly?: boolean}} [options] `projectOnly`: never the
314
+ * carried Core, as for doctor (spec AST-081 FR3)
309
315
  * @returns {Promise<CoreBindings | null>}
310
316
  */
311
- async function loadProjectCore(cwd, cliCore) {
312
- const dir = findInstalledPackage(cwd, '@astryxdesign/core');
317
+ async function loadProjectCore(cwd, cliCore, {projectOnly = false} = {}) {
318
+ // Outside a project, the Core the answering copy carries (spec AST-081 FR3).
319
+ const dir =
320
+ findInstalledPackage(cwd, '@astryxdesign/core') ??
321
+ (projectOnly ? null : fetchCarriedThemeCoreDir(cwd));
313
322
  const themeFile = dir ? importTarget(dir, './theme') : null;
314
323
  if (!dir || !themeFile) return null;
315
324
  if (cliCore.themeModule) {
@@ -355,14 +364,54 @@ const _projectCores = new Map();
355
364
 
356
365
  /**
357
366
  * Choose the Core this build generates with: the project's installed one when
358
- * {@link loadProjectCore} finds it, else the CLI's own.
367
+ * {@link loadProjectCore} finds it, else the CLI's own. With `projectOnly`,
368
+ * only the project's installed Core: a build that cannot use it fails rather
369
+ * than read the Core the answering copy carries (spec AST-081 FR3).
359
370
  * @param {string} cwd
371
+ * @param {{projectOnly?: boolean}} [options]
360
372
  */
361
- async function selectCore(cwd) {
373
+ async function selectCore(cwd, {projectOnly = false} = {}) {
362
374
  const cliCore = await loadCliCore();
363
- if (!_projectCores.has(cwd))
364
- _projectCores.set(cwd, await loadProjectCore(cwd, cliCore));
365
- setCore(_projectCores.get(cwd) ?? cliCore);
375
+ const key = `${projectOnly ? 'project' : 'any'}\0${cwd}`;
376
+ if (!_projectCores.has(key))
377
+ _projectCores.set(key, await loadProjectCore(cwd, cliCore, {projectOnly}));
378
+ const projectCore = _projectCores.get(key);
379
+ // A global or cached copy's own Core is the carried one.
380
+ if (projectOnly && !projectCore && carriesCore() && !cliCoreIsProjects(cwd)) {
381
+ throw new AstryxError(
382
+ "The project's Core isn't installed or does not load.",
383
+ undefined,
384
+ ERROR_CODES.ERR_CORE_NOT_FOUND,
385
+ );
386
+ }
387
+ setCore(projectCore ?? cliCore);
388
+ }
389
+
390
+ /**
391
+ * Whether this CLI copy is one installed for the computer or kept in the
392
+ * per-user release cache, whose own Core import is the carried Core.
393
+ * @returns {boolean}
394
+ */
395
+ function carriesCore() {
396
+ return isGlobalCopy(CLI_ROOT) || isInReleaseCache(CLI_ROOT);
397
+ }
398
+
399
+ /**
400
+ * Whether the Core the CLI's own import loads is the one the project at
401
+ * `cwd` installed.
402
+ * @param {string} cwd
403
+ * @returns {boolean}
404
+ */
405
+ function cliCoreIsProjects(cwd) {
406
+ const dir = findProjectCoreDir(cwd);
407
+ if (!dir) return false;
408
+ try {
409
+ const own = fileURLToPath(import.meta.resolve('@astryxdesign/core/theme'));
410
+ const theirs = importTarget(dir, './theme');
411
+ return theirs != null && realOrSelf(own) === realOrSelf(theirs);
412
+ } catch {
413
+ return false;
414
+ }
366
415
  }
367
416
 
368
417
  /**
@@ -401,8 +450,7 @@ function inAstryxRepository(cwd) {
401
450
  * @returns {string}
402
451
  */
403
452
  export function coreUnavailableMessage(cwd, importError) {
404
- const why =
405
- '`astryx theme build` generates CSS with @astryxdesign/core, the same code the runtime <Theme> uses';
453
+ const why = `\`${formatCliCommand('theme build')}\` generates CSS with @astryxdesign/core, the same code the runtime <Theme> uses`;
406
454
  const detail = importError ? `\n Import error: ${importError.message}` : '';
407
455
  if (inAstryxRepository(cwd)) {
408
456
  return (
@@ -2497,13 +2545,14 @@ function validateHeadingTypeAugmentationSupport(themeDef) {
2497
2545
  * output must stay inside, for a CLI-internal scratch build. `iconsSpecifier` overrides the icon registry import
2498
2546
  * specifier in the generated module (e.g. `./icons.mjs`); when omitted, the
2499
2547
  * direct registry specifiers from the theme source are emitted unchanged.
2500
- * @param {{cwd?: string}} [ctx]
2548
+ * @param {{cwd?: string, projectCore?: boolean}} [ctx] `projectCore`: only the
2549
+ * project's installed Core (spec AST-081 FR3)
2501
2550
  * @returns {Promise<any>}
2502
2551
  */
2503
2552
  async function themeBuildInternal(
2504
2553
  file,
2505
2554
  options = {},
2506
- {cwd = process.cwd()} = {},
2555
+ {cwd = process.cwd(), projectCore = false} = {},
2507
2556
  /** @type {{compact?: boolean, trailers?: ThemeBuildTrailer[]}} */ report = {},
2508
2557
  ) {
2509
2558
  const filePath = path.resolve(cwd, file);
@@ -2522,7 +2571,14 @@ async function themeBuildInternal(
2522
2571
  // A compact report has no per-theme heading, so each warning names its file.
2523
2572
  const source = report.compact ? `${path.relative(cwd, filePath)}: ` : '';
2524
2573
 
2525
- await selectCore(cwd);
2574
+ if (projectCore && !findProjectCoreDir(cwd)) {
2575
+ throw new AstryxError(
2576
+ "The project's Core isn't installed.",
2577
+ undefined,
2578
+ ERROR_CODES.ERR_CORE_NOT_FOUND,
2579
+ );
2580
+ }
2581
+ await selectCore(cwd, {projectOnly: projectCore});
2526
2582
 
2527
2583
  // Standalone builds only need interception when an older Core could erase
2528
2584
  // adaptations. Family preparation always supplies the same recorder as its
@@ -3272,7 +3328,7 @@ export function printCompactTrailer(trailers, {hint = false} = {}) {
3272
3328
  )
3273
3329
  .join(', ');
3274
3330
  logger.log(
3275
- `[note] Fonts named but not loaded: ${named}. Load them in your app (recipe: astryx docs typography).`,
3331
+ `[note] Fonts named but not loaded: ${named}. Load them in your app (recipe: ${formatCliCommand('docs typography')}).`,
3276
3332
  );
3277
3333
  }
3278
3334
  if (hint) {
@@ -3327,7 +3383,7 @@ export async function themeBuildForReport(
3327
3383
  return {receipt, trailer: trailers[0] ?? null};
3328
3384
  }
3329
3385
 
3330
- /** @param {string} file @param {{out?: string, check?: boolean, iconsSpecifier?: string}} [options] @param {{cwd?: string}} [ctx] @returns {Promise<import('../theme.type.mjs').ThemeBuildResponse | import('../theme.type.mjs').ThemeBuildCheckResponse | null>} */
3386
+ /** @param {string} file @param {{out?: string, check?: boolean, iconsSpecifier?: string}} [options] @param {{cwd?: string, projectCore?: boolean}} [ctx] `projectCore`: read only the project's installed Core, never the carried one (doctor; spec AST-081 FR3) @returns {Promise<import('../theme.type.mjs').ThemeBuildResponse | import('../theme.type.mjs').ThemeBuildCheckResponse | null>} */
3331
3387
  export async function themeBuild(file, options = {}, ctx = {}) {
3332
3388
  return /** @type {any} */ (themeBuildInternal(file, options, ctx));
3333
3389
  }
@@ -37,6 +37,7 @@ import * as path from 'node:path';
37
37
  import {fileURLToPath} from 'node:url';
38
38
 
39
39
  import {findInstalledPackage} from '../../../foundation/fs/paths.mjs';
40
+ import {CLI_VERSION} from '../../../test-utils/release-fixtures.mjs';
40
41
 
41
42
  const HERE = path.dirname(fileURLToPath(import.meta.url));
42
43
  const REPO_ROOT = path.resolve(HERE, '../../../../..');
@@ -55,8 +56,12 @@ const RUNTIME_DEPS = [
55
56
  'zod',
56
57
  ];
57
58
 
58
- const OLD_CORE_VERSION = '0.5.4';
59
- const CURRENT_CORE_VERSION = '0.6.0';
59
+ // Both Cores carry the packed CLI's own version: a run through the bin in a
60
+ // project whose Core is another release is handed to that release (spec
61
+ // AST-081 FR2), so the old surface is told apart by what it exports, not by
62
+ // its version.
63
+ const OLD_CORE_VERSION = CLI_VERSION;
64
+ const CURRENT_CORE_VERSION = CLI_VERSION;
60
65
  const TSC_BIN = path.join(REPO_ROOT, 'node_modules/typescript/bin/tsc');
61
66
 
62
67
  /**
@@ -278,8 +283,20 @@ function buildTheme(themeFile, extraArgs = []) {
278
283
  'node_modules/@astryxdesign/cli/clients/cli/bin/astryx.mjs',
279
284
  );
280
285
  try {
286
+ // A packed CLI outside any project's package.json reads as installed for
287
+ // the computer, so it gets a home folder of its own: nothing it keeps for
288
+ // the computer lands in the real one.
289
+ const home = path.join(root, 'home');
290
+ const env = {
291
+ ...process.env,
292
+ HOME: home,
293
+ USERPROFILE: home,
294
+ XDG_CONFIG_HOME: path.join(home, '.config'),
295
+ XDG_CACHE_HOME: path.join(home, '.cache'),
296
+ NO_UPDATE_NOTIFIER: '1',
297
+ };
281
298
  // prettier-ignore
282
- const stdout = execFileSync(process.execPath, [bin, 'theme', 'build', ...(Array.isArray(themeFile) ? themeFile : [themeFile]), ...extraArgs, '--json'], {cwd: consumer, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe']});
299
+ const stdout = execFileSync(process.execPath, [bin, 'theme', 'build', ...(Array.isArray(themeFile) ? themeFile : [themeFile]), ...extraArgs, '--json'], {cwd: consumer, encoding: 'utf8', env, stdio: ['ignore', 'pipe', 'pipe']});
283
300
  return {status: 0, envelope: JSON.parse(stdout)};
284
301
  } catch (error) {
285
302
  const e = /** @type {any} */ (error);
@@ -21,9 +21,11 @@
21
21
  * @output Ordered, case-insensitively deduped family names, and the human
22
22
  * help snippet (<link> pair + @font-face) printed after the install
23
23
  * instructions.
24
- * @position Sits beside build.mjs (api/theme/build/). Pure functions, no IO,
25
- * so the `--json` receipt and the human output share one source of truth.
24
+ * @position Sits beside build.mjs (api/theme/build/). Pure functions, no IO
25
+ * beyond the CLI invocation the human help names (formatCliCommand), so the
26
+ * `--json` receipt and the human output share one source of truth.
26
27
  */
28
+ import {formatCliCommand} from '../../../foundation/env/package-manager.mjs';
27
29
 
28
30
  // font-family values that never need loading: CSS generic families, the ui-*
29
31
  // system keywords, and CSS-wide keywords that can appear in a token value.
@@ -254,6 +256,6 @@ function fontLoadingRecipe(families) {
254
256
  font-display: swap;
255
257
  }
256
258
 
257
- Recipe and fallback-stack guidance: astryx docs typography
259
+ Recipe and fallback-stack guidance: ${formatCliCommand('docs typography')}
258
260
  `;
259
261
  }
@@ -15,6 +15,7 @@
15
15
 
16
16
  import {describe, it, expect} from 'vitest';
17
17
  import {collectUnloadedFonts, formatFontLoadingHelp} from './font-warning.mjs';
18
+ import {formatCliCommand} from '../../../foundation/env/package-manager.mjs';
18
19
 
19
20
  describe('collectUnloadedFonts', () => {
20
21
  it('returns webfont families from font-family tokens, skipping known fallbacks', () => {
@@ -255,7 +256,7 @@ describe('formatFontLoadingHelp', () => {
255
256
  });
256
257
 
257
258
  it('points at the docs recipe', () => {
258
- expect(help).toContain('astryx docs typography');
259
+ expect(help).toContain(formatCliCommand('docs typography'));
259
260
  });
260
261
 
261
262
  it('percent-encodes family names in the css2 URL', () => {
@@ -81,14 +81,14 @@ describe('themeRemove', () => {
81
81
  it('refuses to remove the default and names theme use', async () => {
82
82
  await expect(themeRemove('ocean', {cwd: tmpDir})).rejects.toMatchObject({
83
83
  code: 'ERR_THEME_INVALID',
84
- message: expect.stringContaining('astryx theme use'),
84
+ message: expect.stringContaining(' theme use <other-slug>`'),
85
85
  });
86
86
  });
87
87
 
88
88
  it('names theme add when the slug is not added', async () => {
89
89
  await expect(themeRemove('missing', {cwd: tmpDir})).rejects.toMatchObject({
90
90
  code: 'ERR_UNKNOWN_THEME',
91
- message: expect.stringContaining('astryx theme add missing'),
91
+ message: expect.stringContaining(' theme add missing`'),
92
92
  });
93
93
  });
94
94
  });