@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
@@ -0,0 +1,232 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file `init({user})` and `astryx init --user`: the `init.user` receipt, the
5
+ * install warning, the refused combinations, and that it touches nothing in
6
+ * the folder it runs in. Every test uses a temporary home folder and search
7
+ * path.
8
+ */
9
+
10
+ import * as fs from 'node:fs';
11
+ import * as os from 'node:os';
12
+ import * as path from 'node:path';
13
+ import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest';
14
+ import {init} from '../init.mjs';
15
+ import {user} from './user.mjs';
16
+ import {runWithCliDoor} from '../../../foundation/env/cli-command.mjs';
17
+ import {renderComputerAgentText} from '../../../foundation/agent-docs/computer-agent-text.mjs';
18
+ import {runCli} from '../../../test-utils/run-cli.mjs';
19
+ import {settingsFile} from '../../../foundation/env/user-settings.mjs';
20
+ import {readGlobalState} from '../../../foundation/release/global-state.mjs';
21
+ import {cliVersion} from '../../../foundation/release/run-context.mjs';
22
+
23
+ /** @type {string[]} */
24
+ const dirs = [];
25
+ /** @param {string} label */
26
+ function tmp(label) {
27
+ const dir = fs.mkdtempSync(
28
+ path.join(os.tmpdir(), `astryx-init-user-${label}-`),
29
+ );
30
+ dirs.push(dir);
31
+ return dir;
32
+ }
33
+
34
+ let home = '';
35
+ let emptyPath = '';
36
+ beforeEach(() => {
37
+ home = tmp('home');
38
+ emptyPath = tmp('path');
39
+ vi.stubEnv('HOME', home);
40
+ vi.stubEnv('USERPROFILE', home);
41
+ vi.stubEnv('PATH', emptyPath);
42
+ // The settings file and the cache live under this home folder too.
43
+ vi.stubEnv('XDG_CONFIG_HOME', path.join(home, '.config'));
44
+ vi.stubEnv('XDG_CACHE_HOME', path.join(home, '.cache'));
45
+ vi.stubEnv('APPDATA', path.join(home, 'AppData', 'Roaming'));
46
+ vi.stubEnv('LOCALAPPDATA', path.join(home, 'AppData', 'Local'));
47
+ });
48
+
49
+ /** The settings file under the temporary home folder. */
50
+ const settings = () => {
51
+ try {
52
+ return JSON.parse(fs.readFileSync(settingsFile(), 'utf8'));
53
+ } catch {
54
+ return null;
55
+ }
56
+ };
57
+ afterEach(() => {
58
+ vi.unstubAllEnvs();
59
+ while (dirs.length) {
60
+ fs.rmSync(/** @type {string} */ (dirs.pop()), {
61
+ recursive: true,
62
+ force: true,
63
+ });
64
+ }
65
+ });
66
+
67
+ const FILE = path.join('.agents', 'skills', 'astryx', 'SKILL.md');
68
+ const CLAUDE = path.join('.claude', 'skills', 'astryx');
69
+
70
+ /** Put a linked Astryx CLI first on the search path. */
71
+ function installCliOnPath() {
72
+ const prefix = tmp('prefix');
73
+ const pkg = path.join(prefix, 'lib', 'node_modules', '@astryxdesign', 'cli');
74
+ fs.mkdirSync(pkg, {recursive: true});
75
+ fs.writeFileSync(
76
+ path.join(pkg, 'package.json'),
77
+ '{"name":"@astryxdesign/cli"}',
78
+ );
79
+ fs.writeFileSync(path.join(pkg, 'bin.mjs'), '#!/usr/bin/env node\n');
80
+ fs.chmodSync(path.join(pkg, 'bin.mjs'), 0o755);
81
+ fs.mkdirSync(path.join(prefix, 'bin'));
82
+ fs.symlinkSync(path.join(pkg, 'bin.mjs'), path.join(prefix, 'bin', 'astryx'));
83
+ vi.stubEnv('PATH', path.join(prefix, 'bin'));
84
+ }
85
+
86
+ describe('init({user: true})', () => {
87
+ it('writes the file, links Claude Code to it, and returns the init.user receipt, warning when no astryx runs the CLI', async () => {
88
+ const r = await init({user: true}, {cwd: tmp('cwd')});
89
+ expect(r.type).toBe('init.user');
90
+ if (r.type !== 'init.user') return;
91
+ expect(r.data.files).toEqual([
92
+ {path: path.join(home, FILE), action: 'written'},
93
+ {path: path.join(home, CLAUDE), action: 'linked'},
94
+ ]);
95
+ expect(r.data.command).toBe('astryx');
96
+ expect(r.data.warnings).toHaveLength(1);
97
+ expect(r.data.warnings[0]).toContain('npm i -g @astryxdesign/cli');
98
+ expect(fs.readFileSync(path.join(home, FILE), 'utf8')).toBe(
99
+ renderComputerAgentText({command: 'astryx'}),
100
+ );
101
+ expect(fs.readFileSync(path.join(home, CLAUDE, 'SKILL.md'), 'utf8')).toBe(
102
+ renderComputerAgentText({command: 'astryx'}),
103
+ );
104
+ });
105
+
106
+ it.skipIf(process.platform === 'win32')(
107
+ 'does not warn when the astryx on the search path is the Astryx CLI',
108
+ async () => {
109
+ installCliOnPath();
110
+ const r = await user();
111
+ expect(r.data.warnings).toEqual([]);
112
+ },
113
+ );
114
+
115
+ it("names the host's door and does not ask for a global install", async () => {
116
+ const r = await runWithCliDoor('acme astryx', () => user());
117
+ expect(r.data.command).toBe('acme astryx');
118
+ expect(r.data.warnings).toEqual([]);
119
+ expect(fs.readFileSync(path.join(home, FILE), 'utf8')).toContain(
120
+ "`acme astryx search '<what you need>'`",
121
+ );
122
+ });
123
+
124
+ it('works inside a project and writes nothing in it', async () => {
125
+ const dir = tmp('project');
126
+ fs.writeFileSync(
127
+ path.join(dir, 'package.json'),
128
+ '{"name":"app","dependencies":{"@astryxdesign/core":"*"}}',
129
+ );
130
+ const before = fs.readdirSync(dir).sort();
131
+ const r = await init({user: true}, {cwd: dir});
132
+ expect(r.type).toBe('init.user');
133
+ expect(fs.readdirSync(dir).sort()).toEqual(before);
134
+ });
135
+
136
+ it('records the links it made, and the release that wrote the text', async () => {
137
+ await init({user: true});
138
+ expect(settings()).toEqual({
139
+ computerAgentText: {install: true, links: [path.join(home, CLAUDE)]},
140
+ });
141
+ expect(readGlobalState().agentText).toEqual({writtenBy: cliVersion()});
142
+ });
143
+
144
+ it('keeps every other setting when it records the choice', async () => {
145
+ fs.mkdirSync(path.dirname(settingsFile()), {recursive: true});
146
+ fs.writeFileSync(settingsFile(), '{"other": 1}');
147
+ await init({user: true, removeAgents: true});
148
+ expect(settings()).toEqual({
149
+ other: 1,
150
+ computerAgentText: {install: false, links: []},
151
+ });
152
+ });
153
+
154
+ it('with removeAgents removes the file and the links it made, and records that the text is not wanted', async () => {
155
+ await init({user: true});
156
+ const r = await init({user: true, removeAgents: true});
157
+ expect(r.type).toBe('init.user');
158
+ if (r.type !== 'init.user') return;
159
+ expect(r.data.files).toEqual([
160
+ {path: path.join(home, FILE), action: 'removed'},
161
+ {path: path.join(home, CLAUDE), action: 'removed'},
162
+ ]);
163
+ expect(r.data.warnings).toEqual([]);
164
+ expect(fs.existsSync(path.join(home, FILE))).toBe(false);
165
+ expect(fs.existsSync(path.join(home, CLAUDE))).toBe(false);
166
+ expect(settings()).toEqual({
167
+ computerAgentText: {install: false, links: []},
168
+ });
169
+ });
170
+
171
+ it.each([
172
+ [{features: 'agents'}, '--features'],
173
+ [{all: true}, '--all'],
174
+ [{agentDocsPath: 'X.md'}, '--agent-docs-path'],
175
+ [{agent: 'claude'}, '--agent'],
176
+ [{removeAgents: true, agent: 'claude'}, '--agent'],
177
+ ])(
178
+ 'refuses %o with ERR_INVALID_ARGUMENT and writes nothing',
179
+ async (extra, flag) => {
180
+ await expect(init({user: true, ...extra})).rejects.toMatchObject({
181
+ code: 'ERR_INVALID_ARGUMENT',
182
+ message: expect.stringContaining(flag),
183
+ });
184
+ expect(fs.existsSync(path.join(home, '.agents'))).toBe(false);
185
+ expect(fs.existsSync(path.join(home, '.claude'))).toBe(false);
186
+ },
187
+ );
188
+ });
189
+
190
+ describe('astryx init --user', () => {
191
+ it('prints the file, the link, and the install warning in text mode', async () => {
192
+ const r = await runCli(['init', '--user'], tmp('cwd'));
193
+ expect(r.status).toBe(0);
194
+ expect(r.stdout).toContain(`Wrote ~${path.sep}${FILE}`);
195
+ expect(r.stdout).toContain(`Linked ~${path.sep}${CLAUDE}`);
196
+ expect(r.stderr).toContain('npm i -g @astryxdesign/cli');
197
+ });
198
+
199
+ it('emits the init.user envelope under --json', async () => {
200
+ const r = await runCli(['--json', 'init', '--user'], tmp('cwd'));
201
+ expect(r.status).toBe(0);
202
+ const env = JSON.parse(r.stdout);
203
+ expect(env.type).toBe('init.user');
204
+ expect(
205
+ env.data.files.map((/** @type {{action: string}} */ f) => f.action),
206
+ ).toEqual(['written', 'linked']);
207
+ expect(env.data.command).toBe('astryx');
208
+ });
209
+
210
+ it('names a file a person edited as kept, and why', async () => {
211
+ await runCli(['init', '--user'], tmp('cwd'));
212
+ const file = path.join(home, FILE);
213
+ fs.appendFileSync(file, 'my note\n');
214
+ const r = await runCli(['init', '--user'], tmp('cwd'));
215
+ expect(r.status).toBe(0);
216
+ expect(r.stdout).toContain(
217
+ `Kept (edited since Astryx wrote it; delete it to get the current text): ~${path.sep}${FILE}`,
218
+ );
219
+ expect(fs.readFileSync(file, 'utf8')).toMatch(/my note\n$/u);
220
+ });
221
+
222
+ it('exits 1 with ERR_INVALID_ARGUMENT when combined with --all or --agent', async () => {
223
+ for (const extra of [['--all'], ['--agent', 'claude']]) {
224
+ const r = await runCli(
225
+ ['--json', 'init', '--user', ...extra],
226
+ tmp('cwd'),
227
+ );
228
+ expect(r.status).toBe(1);
229
+ expect(JSON.parse(r.stdout).code).toBe('ERR_INVALID_ARGUMENT');
230
+ }
231
+ });
232
+ });
@@ -25,7 +25,7 @@ import {
25
25
  packageDocsProblems,
26
26
  packageReferenceProblems,
27
27
  } from '../docs/_adapter.mjs';
28
- import {findCoreDir} from '../../foundation/fs/paths.mjs';
28
+ import {findProjectCoreDir} from '../../foundation/fs/paths.mjs';
29
29
  import {
30
30
  discoverIntegrationComponents,
31
31
  discoverOwnedComponents,
@@ -271,7 +271,7 @@ export async function integrationComponentConflicts(pkg, options = {}) {
271
271
  issues.push({code: 'invalid_doc_graph', severity, message});
272
272
  }
273
273
 
274
- const coreDir = findCoreDir(cwd);
274
+ const coreDir = findProjectCoreDir(cwd);
275
275
  if (!coreDir) {
276
276
  issues.push({
277
277
  code: 'core_not_found',
@@ -42,7 +42,7 @@ export const doc = {
42
42
  type: 'boolean',
43
43
  default: 'false',
44
44
  description:
45
- 'Also fail on any warning and on any check that did not run, not only on errors.',
45
+ 'Also fail on any warning and on any check that did not run, not only on errors. A malformed `cliCommand` is reported as a note (`invalid_cli_command`) in `data.notes` of the validate check, which fails nothing until a minor release names it.',
46
46
  },
47
47
  ],
48
48
  returns: [
@@ -69,6 +69,7 @@ import {
69
69
  collectIdentities,
70
70
  compareIdentities,
71
71
  } from '../../foundation/integrations/contribution-inventory.mjs';
72
+ import {formatCliCommand} from '../../foundation/env/package-manager.mjs';
72
73
 
73
74
  /**
74
75
  * @typedef {import('../../foundation/integrations/issue').AstryxIntegrationIssue} Issue
@@ -623,7 +624,7 @@ async function validateIncompleteThemeExports(
623
624
  output.kind === 'module'
624
625
  ? 'theme_module_stale'
625
626
  : 'theme_stylesheet_stale',
626
- `Theme "${localTheme.slug}" ${output.kind} does not match ${sourceRelative}. This incomplete export remains packable, but run \`astryx theme build ${sourceRelative}\` before adding its matching export.`,
627
+ `Theme "${localTheme.slug}" ${output.kind} does not match ${sourceRelative}. This incomplete export remains packable, but run \`${formatCliCommand(`theme build ${sourceRelative}`, packageDir)}\` before adding its matching export.`,
627
628
  ),
628
629
  );
629
630
  }
@@ -642,7 +643,7 @@ async function validateIncompleteThemeExports(
642
643
  issues.push(
643
644
  error(
644
645
  'theme_build_failed',
645
- `Theme "${localTheme.slug}" could not be rebuilt from ${sourceRelative}: ${err instanceof Error ? err.message : String(err)} Run \`astryx theme build ${sourceRelative}\` before packing.`,
646
+ `Theme "${localTheme.slug}" could not be rebuilt from ${sourceRelative}: ${err instanceof Error ? err.message : String(err)} Run \`${formatCliCommand(`theme build ${sourceRelative}`, packageDir)}\` before packing.`,
646
647
  ),
647
648
  );
648
649
  } finally {
@@ -961,7 +962,7 @@ async function validatePackedThemeExports(
961
962
  issues.push(
962
963
  warning(
963
964
  'theme_exports_missing',
964
- `Theme "${localTheme.slug}" has no declared built exports. The package remains source-compatible. To make it importable, run \`astryx theme build ${sourceRelative}\` and export "./themes/${localTheme.slug}" plus "./themes/${localTheme.slug}.css" from package.json; \`astryx integration add theme ${localTheme.slug}\` creates those exports for a new theme.`,
965
+ `Theme "${localTheme.slug}" has no declared built exports. The package remains source-compatible. To make it importable, run \`${formatCliCommand(`theme build ${sourceRelative}`, localIntegration.__packageDir)}\` and export "./themes/${localTheme.slug}" plus "./themes/${localTheme.slug}.css" from package.json; \`${formatCliCommand(`integration add theme ${localTheme.slug}`, localIntegration.__packageDir)}\` creates those exports for a new theme.`,
965
966
  ),
966
967
  );
967
968
  continue;
@@ -1001,7 +1002,7 @@ async function validatePackedThemeExports(
1001
1002
  err instanceof ThemeImportError
1002
1003
  ? 'theme_import_unresolvable'
1003
1004
  : 'theme_import_invalid',
1004
- `${message} Run \`astryx theme build ${sourceRelative}\` before packing.`,
1005
+ `${message} Run \`${formatCliCommand(`theme build ${sourceRelative}`, localIntegration.__packageDir)}\` before packing.`,
1005
1006
  ),
1006
1007
  );
1007
1008
  continue;
@@ -1022,7 +1023,7 @@ async function validatePackedThemeExports(
1022
1023
  issues.push(
1023
1024
  error(
1024
1025
  'theme_build_failed',
1025
- `Theme "${localTheme.slug}" did not produce a complete build. Run \`astryx theme build ${sourceRelative}\` before packing.`,
1026
+ `Theme "${localTheme.slug}" did not produce a complete build. Run \`${formatCliCommand(`theme build ${sourceRelative}`, localIntegration.__packageDir)}\` before packing.`,
1026
1027
  ),
1027
1028
  );
1028
1029
  continue;
@@ -1093,10 +1094,10 @@ async function validatePackedThemeExports(
1093
1094
  error(
1094
1095
  output.staleCode,
1095
1096
  localWrapper && !localWrapper.ok && !localWrapper.rebuild
1096
- ? `Theme "${localTheme.slug}" module is not the module \`astryx theme build ${sourceRelative}\` writes and does not only wrap it: ${localWrapper.reason}. A module that wraps the built module may only import the theme's own stylesheet and font stylesheet for their side effects and re-export from the built module either everything or only its theme, as ${localTheme.exportName}.`
1097
+ ? `Theme "${localTheme.slug}" module is not the module \`${formatCliCommand(`theme build ${sourceRelative}`, localIntegration.__packageDir)}\` writes and does not only wrap it: ${localWrapper.reason}. A module that wraps the built module may only import the theme's own stylesheet and font stylesheet for their side effects and re-export from the built module either everything or only its theme, as ${localTheme.exportName}.`
1097
1098
  : localWrapper && !localWrapper.ok
1098
- ? `Theme "${localTheme.slug}" module re-exports ${localWrapper.reason}, which does not match ${sourceRelative}. Run \`astryx theme build ${sourceRelative}\` before packing.`
1099
- : `Theme "${localTheme.slug}" ${output.kind} does not match ${sourceRelative}. Run \`astryx theme build ${sourceRelative}\` before packing.`,
1099
+ ? `Theme "${localTheme.slug}" module re-exports ${localWrapper.reason}, which does not match ${sourceRelative}. Run \`${formatCliCommand(`theme build ${sourceRelative}`, localIntegration.__packageDir)}\` before packing.`
1100
+ : `Theme "${localTheme.slug}" ${output.kind} does not match ${sourceRelative}. Run \`${formatCliCommand(`theme build ${sourceRelative}`, localIntegration.__packageDir)}\` before packing.`,
1100
1101
  ),
1101
1102
  );
1102
1103
  }
@@ -1128,7 +1129,7 @@ async function validatePackedThemeExports(
1128
1129
  issues.push(
1129
1130
  error(
1130
1131
  'theme_build_failed',
1131
- `Theme "${localTheme.slug}" could not be rebuilt from ${sourceRelative}: ${err instanceof Error ? err.message : String(err)} Run \`astryx theme build ${sourceRelative}\` before packing.`,
1132
+ `Theme "${localTheme.slug}" could not be rebuilt from ${sourceRelative}: ${err instanceof Error ? err.message : String(err)} Run \`${formatCliCommand(`theme build ${sourceRelative}`, localIntegration.__packageDir)}\` before packing.`,
1132
1133
  ),
1133
1134
  );
1134
1135
  } finally {
@@ -17,6 +17,7 @@ import {
17
17
  integrationAddComponent,
18
18
  integrationAddTemplate,
19
19
  } from './add-contribution.mjs';
20
+ import {formatCliCommand} from '../../foundation/env/package-manager.mjs';
20
21
 
21
22
  let tmpDir;
22
23
 
@@ -502,7 +503,7 @@ describe('a theme module that loads its own styles', () => {
502
503
  {
503
504
  code: 'theme_module_stale',
504
505
  severity: 'error',
505
- message: `Theme "ocean" module is not the module \`astryx theme build themes/ocean/oceanTheme.ts\` writes and does not only wrap it: ${reason}. A module that wraps the built module may only import the theme's own stylesheet and font stylesheet for their side effects and re-export from the built module either everything or only its theme, as oceanTheme.`,
506
+ message: `Theme "ocean" module is not the module \`${formatCliCommand('theme build themes/ocean/oceanTheme.ts', tmpDir)}\` writes and does not only wrap it: ${reason}. A module that wraps the built module may only import the theme's own stylesheet and font stylesheet for their side effects and re-export from the built module either everything or only its theme, as oceanTheme.`,
506
507
  },
507
508
  ]);
508
509
  });
@@ -522,8 +523,7 @@ describe('a theme module that loads its own styles', () => {
522
523
  {
523
524
  code: 'theme_module_stale',
524
525
  severity: 'error',
525
- message:
526
- 'Theme "ocean" module re-exports ../themes/ocean/ocean.js, which does not match themes/ocean/oceanTheme.ts. Run `astryx theme build themes/ocean/oceanTheme.ts` before packing.',
526
+ message: `Theme "ocean" module re-exports ../themes/ocean/ocean.js, which does not match themes/ocean/oceanTheme.ts. Run \`${formatCliCommand('theme build themes/ocean/oceanTheme.ts', tmpDir)}\` before packing.`,
527
527
  },
528
528
  ]);
529
529
  });
@@ -539,8 +539,7 @@ describe('a theme module that loads its own styles', () => {
539
539
  {
540
540
  code: 'theme_module_stale',
541
541
  severity: 'error',
542
- message:
543
- 'Theme "ocean" module does not match themes/ocean/oceanTheme.ts. Run `astryx theme build themes/ocean/oceanTheme.ts` before packing.',
542
+ message: `Theme "ocean" module does not match themes/ocean/oceanTheme.ts. Run \`${formatCliCommand('theme build themes/ocean/oceanTheme.ts', tmpDir)}\` before packing.`,
544
543
  },
545
544
  ]);
546
545
  });
@@ -687,8 +686,7 @@ describe('integrationPackCheck', () => {
687
686
  {
688
687
  code: 'theme_exports_missing',
689
688
  severity: 'warning',
690
- message:
691
- 'Theme "ocean" has no declared built exports. The package remains source-compatible. To make it importable, run `astryx theme build themes/ocean/oceanTheme.ts` and export "./themes/ocean" plus "./themes/ocean.css" from package.json; `astryx integration add theme ocean` creates those exports for a new theme.',
689
+ message: `Theme "ocean" has no declared built exports. The package remains source-compatible. To make it importable, run \`${formatCliCommand('theme build themes/ocean/oceanTheme.ts', tmpDir)}\` and export "./themes/ocean" plus "./themes/ocean.css" from package.json; \`${formatCliCommand('integration add theme ocean', tmpDir)}\` creates those exports for a new theme.`,
692
690
  },
693
691
  ]);
694
692
  const cli = runCliVerify();
@@ -859,8 +857,7 @@ describe('integrationPackCheck', () => {
859
857
  {
860
858
  code: 'theme_stylesheet_stale',
861
859
  severity: 'warning',
862
- message:
863
- 'Theme "ocean" stylesheet does not match themes/ocean/oceanTheme.ts. This incomplete export remains packable, but run `astryx theme build themes/ocean/oceanTheme.ts` before adding its matching export.',
860
+ message: `Theme "ocean" stylesheet does not match themes/ocean/oceanTheme.ts. This incomplete export remains packable, but run \`${formatCliCommand('theme build themes/ocean/oceanTheme.ts', tmpDir)}\` before adding its matching export.`,
864
861
  },
865
862
  ]);
866
863
  const cli = runCliVerify();
@@ -893,8 +890,7 @@ describe('integrationPackCheck', () => {
893
890
  {
894
891
  code: 'theme_stylesheet_stale',
895
892
  severity: 'warning',
896
- message:
897
- 'Theme "ocean" stylesheet does not match themes/ocean/oceanTheme.ts. This incomplete export remains packable, but run `astryx theme build themes/ocean/oceanTheme.ts` before adding its matching export.',
893
+ message: `Theme "ocean" stylesheet does not match themes/ocean/oceanTheme.ts. This incomplete export remains packable, but run \`${formatCliCommand('theme build themes/ocean/oceanTheme.ts', tmpDir)}\` before adding its matching export.`,
898
894
  },
899
895
  ]);
900
896
  const cli = runCliVerify();
@@ -967,14 +963,12 @@ describe('integrationPackCheck', () => {
967
963
  {
968
964
  code: 'theme_module_stale',
969
965
  severity: 'error',
970
- message:
971
- 'Theme "ocean" module does not match themes/ocean/oceanTheme.ts. Run `astryx theme build themes/ocean/oceanTheme.ts` before packing.',
966
+ message: `Theme "ocean" module does not match themes/ocean/oceanTheme.ts. Run \`${formatCliCommand('theme build themes/ocean/oceanTheme.ts', tmpDir)}\` before packing.`,
972
967
  },
973
968
  {
974
969
  code: 'theme_stylesheet_stale',
975
970
  severity: 'error',
976
- message:
977
- 'Theme "ocean" stylesheet does not match themes/ocean/oceanTheme.ts. Run `astryx theme build themes/ocean/oceanTheme.ts` before packing.',
971
+ message: `Theme "ocean" stylesheet does not match themes/ocean/oceanTheme.ts. Run \`${formatCliCommand('theme build themes/ocean/oceanTheme.ts', tmpDir)}\` before packing.`,
978
972
  },
979
973
  ]);
980
974
  const cli = runCliVerify();
@@ -67,6 +67,14 @@ export type ValidateResult = {
67
67
  */
68
68
  reason?: "no_package_json" | undefined;
69
69
  issues: Issue[];
70
+ /**
71
+ * Information that
72
+ * fails nothing, such as `invalid_cli_command` (a malformed `cliCommand`).
73
+ */
74
+ notes?: {
75
+ code: string;
76
+ message: string;
77
+ }[] | undefined;
70
78
  integration?: import("../../foundation/integrations/integrations.mjs").LoadedIntegration | undefined;
71
79
  };
72
80
  import { validateLoadedIntegration } from '../../foundation/integrations/validate-contributions.mjs';
@@ -56,11 +56,13 @@ import {
56
56
  // The on-disk contribution validators live in foundation: Project and
57
57
  // integration-warnings need them too, and foundation must not depend on api.
58
58
  import {
59
+ INVALID_CLI_COMMAND,
59
60
  validateLoadedIntegration,
60
61
  issueError as error,
61
62
  issueWarning as warning,
62
63
  rootProblem,
63
64
  } from '../../foundation/integrations/validate-contributions.mjs';
65
+ import {formatCliCommand} from '../../foundation/env/package-manager.mjs';
64
66
 
65
67
  export {validateLoadedIntegration};
66
68
 
@@ -76,6 +78,8 @@ export {validateLoadedIntegration};
76
78
  * @property {string} [manifestFile] Absolute path to the loaded manifest.
77
79
  * @property {'no_package_json'} [reason] Why nothing was validated (internal).
78
80
  * @property {Issue[]} issues
81
+ * @property {Array<{code: string, message: string}>} [notes] Information that
82
+ * fails nothing, such as `invalid_cli_command` (a malformed `cliCommand`).
79
83
  * @property {import('../../foundation/integrations/integrations.mjs').LoadedIntegration} [integration]
80
84
  */
81
85
 
@@ -125,7 +129,7 @@ function unreadThemeFolderIssues(packageDir, loaded) {
125
129
  let fix;
126
130
  if (THEME_SLUG_RE.test(name)) {
127
131
  const stem = `${name.replace(/-([a-z0-9])/gu, (_, character) => character.toUpperCase())}Theme`;
128
- fix = `if it is a theme, add ${stem}.ts and ${stem}.doc.mjs to it (\`astryx integration add theme ${name}\` writes both) and move its code into ${stem}.ts; if not, ${hide}.`;
132
+ fix = `if it is a theme, add ${stem}.ts and ${stem}.doc.mjs to it (\`${formatCliCommand(`integration add theme ${name}`, packageDir)}\` writes both) and move its code into ${stem}.ts; if not, ${hide}.`;
129
133
  } else {
130
134
  fix = `${hide}; a theme folder needs a lower-kebab name.`;
131
135
  }
@@ -284,11 +288,14 @@ async function validateAtPackageDir(
284
288
  let unknownKeys;
285
289
  /** @type {string | undefined} */
286
290
  let agentDocsError;
291
+ /** @type {string | undefined} */
292
+ let cliCommandError;
287
293
  try {
288
- ({manifest, unknownKeys, agentDocsError} = await loadManifest(
289
- manifestFile,
290
- `Integration manifest (${path.basename(manifestFile)})`,
291
- ));
294
+ ({manifest, unknownKeys, agentDocsError, cliCommandError} =
295
+ await loadManifest(
296
+ manifestFile,
297
+ `Integration manifest (${path.basename(manifestFile)})`,
298
+ ));
292
299
  } catch (err) {
293
300
  issues.push(error('invalid_manifest', /** @type {any} */ (err).message));
294
301
  return result;
@@ -320,6 +327,8 @@ async function validateAtPackageDir(
320
327
  themes: resolveRoot(manifest.themes),
321
328
  issuesUrl: manifest.issuesUrl,
322
329
  agentDocs: manifest.agentDocs,
330
+ cliCommand: manifest.cliCommand,
331
+ __cliCommandError: cliCommandError,
323
332
  __agentDocsError: agentDocsError,
324
333
  __unknownKeys: unknownKeys,
325
334
  __spec: identity.name,
@@ -330,7 +339,17 @@ async function validateAtPackageDir(
330
339
 
331
340
  // Roots + contribution checks are shared with validateLoadedIntegration so
332
341
  // the everyday-command nudge runs the exact same validators.
333
- issues.push(...(await validateLoadedIntegration(loaded)));
342
+ // A malformed `cliCommand` is an info note beside the issues, not an issue:
343
+ // `integration check --strict` fails on any warning, and a new failure code
344
+ // joins only in a minor release (architecture:cli-surface INV35). Doctor's
345
+ // project check still warns about it.
346
+ for (const issue of await validateLoadedIntegration(loaded)) {
347
+ if (issue.code === INVALID_CLI_COMMAND) {
348
+ (result.notes ??= []).push({code: issue.code, message: issue.message});
349
+ } else {
350
+ issues.push(issue);
351
+ }
352
+ }
334
353
  if (loaded.themes && !rootProblem(loaded.themes))
335
354
  issues.push(...unreadThemeFolderIssues(packageDir, loaded));
336
355
  // What the docs say that no reader serves: a prop listed twice, an
@@ -485,6 +504,7 @@ export async function validateIntegration(pkg, options = {}) {
485
504
  const docTypes = integration
486
505
  ? await integrationDocTypes(integration, cwd)
487
506
  : undefined;
507
+ const notes = result.found ? (result.notes ?? []) : [];
488
508
  return {
489
509
  type: 'integration.validate',
490
510
  data: {
@@ -504,6 +524,7 @@ export async function validateIntegration(pkg, options = {}) {
504
524
  },
505
525
  ]
506
526
  : result.issues,
527
+ ...(notes.length > 0 ? {notes} : {}),
507
528
  ...(docTypes ? {docTypes} : {}),
508
529
  },
509
530
  };
@@ -34,11 +34,19 @@ export type ValidateIntegrationOptions = {
34
34
  */
35
35
  export type ValidateIntegrationResponse = {
36
36
  type: "integration.validate";
37
+ /**
38
+ * `notes`: information beside the issues that fails nothing, such as
39
+ * `invalid_cli_command`, a `cliCommand` that was ignored as malformed
40
+ */
37
41
  data: {
38
42
  validated: boolean;
39
43
  name: string | null;
40
44
  version: string | null;
41
45
  issues: import("../../foundation/integrations/issue").AstryxIntegrationIssue[];
46
+ notes?: Array<{
47
+ code: string;
48
+ message: string;
49
+ }>;
42
50
  docTypes?: DocTypesReport;
43
51
  };
44
52
  };
@@ -38,7 +38,9 @@
38
38
  * "healthy" — the two are otherwise byte-identical.
39
39
  * @typedef {object} ValidateIntegrationResponse
40
40
  * @property {'integration.validate'} type
41
- * @property {{validated: boolean, name: string | null, version: string | null, issues: import('../../foundation/integrations/issue').AstryxIntegrationIssue[], docTypes?: DocTypesReport}} data
41
+ * @property {{validated: boolean, name: string | null, version: string | null, issues: import('../../foundation/integrations/issue').AstryxIntegrationIssue[], notes?: Array<{code: string, message: string}>, docTypes?: DocTypesReport}} data
42
+ * `notes`: information beside the issues that fails nothing, such as
43
+ * `invalid_cli_command`, a `cliCommand` that was ignored as malformed
42
44
  */
43
45
 
44
46
  /**
@@ -15,6 +15,7 @@ import * as fs from 'node:fs';
15
15
  import * as path from 'node:path';
16
16
  import {validateLocalIntegration} from './validate-integration.mjs';
17
17
  import {integrationAddTheme} from './add-theme.mjs';
18
+ import {formatCliCommand} from '../../foundation/env/package-manager.mjs';
18
19
 
19
20
  let tmpDir;
20
21
 
@@ -76,8 +77,8 @@ describe('unread theme folders', () => {
76
77
  ]);
77
78
  expect(issues.map(issue => issue.message)).toEqual([
78
79
  'Folder "themes/Tide_Pool/" holds modules but no <name>Theme source or .doc.mjs descriptor, so Astryx does not read it as a theme. Fix: rename it to .Tide_Pool so Astryx skips it; a theme folder needs a lower-kebab name.',
79
- 'Folder "themes/reef/" holds modules but no <name>Theme source or .doc.mjs descriptor, so Astryx does not read it as a theme. Fix: if it is a theme, add reefTheme.ts and reefTheme.doc.mjs to it (`astryx integration add theme reef` writes both) and move its code into reefTheme.ts; if not, rename it to .reef so Astryx skips it.',
80
- 'Folder "themes/sand/" holds modules but no <name>Theme source or .doc.mjs descriptor, so Astryx does not read it as a theme. Fix: if it is a theme, add sandTheme.ts and sandTheme.doc.mjs to it (`astryx integration add theme sand` writes both) and move its code into sandTheme.ts; if not, rename it to .sand so Astryx skips it.',
80
+ `Folder "themes/reef/" holds modules but no <name>Theme source or .doc.mjs descriptor, so Astryx does not read it as a theme. Fix: if it is a theme, add reefTheme.ts and reefTheme.doc.mjs to it (\`${formatCliCommand('integration add theme reef', tmpDir)}\` writes both) and move its code into reefTheme.ts; if not, rename it to .reef so Astryx skips it.`,
81
+ `Folder "themes/sand/" holds modules but no <name>Theme source or .doc.mjs descriptor, so Astryx does not read it as a theme. Fix: if it is a theme, add sandTheme.ts and sandTheme.doc.mjs to it (\`${formatCliCommand('integration add theme sand', tmpDir)}\` writes both) and move its code into sandTheme.ts; if not, rename it to .sand so Astryx skips it.`,
81
82
  ]);
82
83
  });
83
84
 
@@ -62,7 +62,7 @@ export const doc = {
62
62
  {
63
63
  type: 'integration.validate',
64
64
  description:
65
- 'The result envelope: `data.validated`, false when nothing was validated — with no `package.json` at all, `data.issues` carries one `no_package` error-severity issue so the command exits 1; with a `package.json` but no integration manifest, `data.issues` is empty, which means "not looked at", not "healthy"; `data.name` and `data.version` of the validated package (both null when `data.validated` is false; `data.name` is `(local package)` when the local package.json has no readable name), plus `data.issues`, an AstryxIntegrationIssue[] of {code, severity: `warning` | `error`, message, fix?, file?, line?}: `fix` is the change that resolves the issue, and `file` and `line` where it is, relative to the package, when the check knows them. When the manifest loads, `data.docTypes` holds the doc type check: `status` (`checked` | `skipped`), `reason` when skipped, `typescript`, `docs` (doc values checked), `findings` ({doc, line, export, type, field, problem: `unknown_field` | `missing_field` | `wrong_type`, severity: `warning`, message, fix}), `unchecked` ({doc, reason}: a doc that could not be fully checked, or a root its reader cannot read), and `fixtures` when the components or docs root holds test fixture docs under `__tests__`: how many, none of them checked.',
65
+ 'The result envelope: `data.validated`, false when nothing was validated — with no `package.json` at all, `data.issues` carries one `no_package` error-severity issue so the command exits 1; with a `package.json` but no integration manifest, `data.issues` is empty, which means "not looked at", not "healthy"; `data.name` and `data.version` of the validated package (both null when `data.validated` is false; `data.name` is `(local package)` when the local package.json has no readable name), plus `data.issues`, an AstryxIntegrationIssue[] of {code, severity: `warning` | `error`, message, fix?, file?, line?}: `fix` is the change that resolves the issue, and `file` and `line` where it is, relative to the package, when the check knows them; and `data.notes` when there are any: {code, message} information that fails nothing, such as `invalid_cli_command` for a `cliCommand` that was ignored as malformed. When the manifest loads, `data.docTypes` holds the doc type check: `status` (`checked` | `skipped`), `reason` when skipped, `typescript`, `docs` (doc values checked), `findings` ({doc, line, export, type, field, problem: `unknown_field` | `missing_field` | `wrong_type`, severity: `warning`, message, fix}), `unchecked` ({doc, reason}: a doc that could not be fully checked, or a root its reader cannot read), and `fixtures` when the components or docs root holds test fixture docs under `__tests__`: how many, none of them checked.',
66
66
  },
67
67
  ],
68
68
  examples: [
@@ -0,0 +1,11 @@
1
+ // @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
2
+ // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
+
4
+ /**
5
+ * The Core a typed search reads: the project's, else the release's own,
6
+ * installed into the per-user cache first when needed. Throws as
7
+ * requireCoreDir does.
8
+ * @param {string} cwd
9
+ * @returns {string}
10
+ */
11
+ export function requireSearchCoreDir(cwd: string): string;
@@ -0,0 +1,25 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file Environment adapter for search: locating the Core a search reads,
5
+ * including the network install and npm subprocess that fetch a release's
6
+ * own Core outside a project (spec AST-081 FR3; architecture:cli-surface
7
+ * INV21).
8
+ *
9
+ * @input the folder a search runs in
10
+ * @output the Core folder a search reads
11
+ * @position packages/cli/api/search — imported by search.mjs only
12
+ */
13
+
14
+ import {requireCoreDir} from '../../foundation/fs/paths.mjs';
15
+
16
+ /**
17
+ * The Core a typed search reads: the project's, else the release's own,
18
+ * installed into the per-user cache first when needed. Throws as
19
+ * requireCoreDir does.
20
+ * @param {string} cwd
21
+ * @returns {string}
22
+ */
23
+ export function requireSearchCoreDir(cwd) {
24
+ return requireCoreDir(cwd);
25
+ }
@@ -226,7 +226,7 @@ export function componentKeywords(coreDir: string, cwd: string): Promise<{
226
226
  */
227
227
  export function search(query: string, options?: {
228
228
  cwd?: string | undefined;
229
- type?: "theme" | "component" | "hook" | "template" | "doc" | undefined;
229
+ type?: "component" | "hook" | "doc" | "template" | "theme" | undefined;
230
230
  limit?: number | undefined;
231
231
  }): Promise<import("./search.type.mjs").SearchResponse>;
232
232
  export namespace SYNONYMS {