@astryxdesign/cli 0.7.2 → 0.7.3-canary.02f5fe4

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 (373) hide show
  1. package/README.md +104 -71
  2. package/api/build/_adapter.d.mts +58 -0
  3. package/api/build/_adapter.mjs +127 -3
  4. package/api/build/blocks/blocks.d.mts +92 -0
  5. package/api/build/blocks/blocks.mjs +528 -0
  6. package/api/build/blocks/blocks.test.mjs +238 -0
  7. package/api/build/blocks/blocks.weights.json +1 -0
  8. package/api/build/build.mjs +25 -6
  9. package/api/build/build.type.mjs +1 -1
  10. package/api/build/kit/answer.d.mts +18 -0
  11. package/api/build/kit/answer.mjs +195 -0
  12. package/api/build/kit/answer.test.mjs +108 -0
  13. package/api/build/kit/kind.d.mts +25 -0
  14. package/api/build/kit/kind.mjs +170 -0
  15. package/api/build/kit/kit.d.mts +2 -4
  16. package/api/build/kit/kit.mjs +8 -398
  17. package/api/build/kit/rank.d.mts +3 -32
  18. package/api/build/kit/rank.mjs +25 -342
  19. package/api/build/kit/rank.test.mjs +2 -1
  20. package/api/build/kit/signals.d.mts +79 -0
  21. package/api/build/kit/signals.mjs +295 -0
  22. package/api/build/kit/start.d.mts +32 -0
  23. package/api/build/kit/start.mjs +163 -0
  24. package/api/build/kit/words.d.mts +72 -0
  25. package/api/build/kit/words.mjs +202 -0
  26. package/api/build/tree.d.mts +20 -0
  27. package/api/build/tree.mjs +53 -0
  28. package/api/build/tree.test.mjs +185 -0
  29. package/api/build/tree.weights.json +1 -0
  30. package/api/component/_adapter.mjs +39 -5
  31. package/api/component/component-replacement.test.mjs +1 -0
  32. package/api/component/component.mjs +17 -3
  33. package/api/component/component.test.mjs +15 -0
  34. package/api/component/doc-links.test.mjs +2 -2
  35. package/api/discover/_adapter.d.mts +1 -2
  36. package/api/discover/_adapter.mjs +42 -17
  37. package/api/discover/_adapter.test.mjs +42 -0
  38. package/api/discover/discover.mjs +0 -1
  39. package/api/docs/_adapter.d.mts +2 -2
  40. package/api/docs/_adapter.mjs +82 -23
  41. package/api/docs/docs-homes.test.mjs +127 -0
  42. package/api/docs/docs.doc.mjs +3 -3
  43. package/api/docs/docs.test.mjs +35 -19
  44. package/api/docs/integration-tree.test.mjs +20 -20
  45. package/api/docs/integrationDocs.test.mjs +1 -1
  46. package/api/docs/namespace-section.test.mjs +6 -6
  47. package/api/docs/reference-blocks.test.mjs +2 -2
  48. package/api/doctor/_adapter.d.mts +33 -13
  49. package/api/doctor/_adapter.mjs +55 -25
  50. package/api/doctor/doctor.d.mts +23 -5
  51. package/api/doctor/doctor.mjs +183 -40
  52. package/api/doctor/doctor.test.mjs +95 -12
  53. package/api/hook/hook.mjs +1 -1
  54. package/api/init/init.doc.mjs +20 -6
  55. package/api/init/init.test.mjs +18 -2
  56. package/api/init/init.type.d.mts +3 -3
  57. package/api/init/init.type.mjs +3 -3
  58. package/api/init/remove/remove.mjs +17 -4
  59. package/api/init/remove/remove.test.mjs +114 -2
  60. package/api/init/run/run.mjs +69 -6
  61. package/api/integration/_adapter.d.mts +8 -0
  62. package/api/integration/_adapter.mjs +21 -1
  63. package/api/integration/authoring-checks.mjs +83 -9
  64. package/api/integration/authoring-checks.test.mjs +220 -0
  65. package/api/integration/pack-check.mjs +123 -4
  66. package/api/integration/pack-check.test.mjs +87 -0
  67. package/api/integration/validate-integration-case-disk.test.mjs +111 -0
  68. package/api/integration/validate-integration-fixes.test.mjs +6 -5
  69. package/api/integration/validate-integration-gaps.test.mjs +1975 -0
  70. package/api/integration/validate-integration.d.mts +15 -2
  71. package/api/integration/validate-integration.mjs +298 -39
  72. package/api/integration/validate-integration.type.d.mts +90 -1
  73. package/api/integration/validate-integration.type.mjs +67 -2
  74. package/api/integration/validateIntegration.doc.mjs +1 -1
  75. package/api/search/ORDERING.md +28 -0
  76. package/api/search/_adapter.d.mts +82 -2
  77. package/api/search/_adapter.mjs +157 -10
  78. package/api/search/_adapter.test.mjs +173 -0
  79. package/api/search/_candidate-score.d.mts +40 -0
  80. package/api/search/_candidate-score.mjs +238 -0
  81. package/api/search/_cards.json +6098 -0
  82. package/api/search/_compound.d.mts +50 -0
  83. package/api/search/_compound.mjs +170 -0
  84. package/api/search/_doc-searcher.d.mts +4 -0
  85. package/api/search/_doc-searcher.mjs +23 -0
  86. package/api/search/_doc-searcher.test.mjs +36 -0
  87. package/api/search/_doc-searcher.weights.json +1 -0
  88. package/api/search/_doc-text.d.mts +30 -0
  89. package/api/search/_doc-text.mjs +87 -0
  90. package/api/search/_entries.d.mts +63 -0
  91. package/api/search/_entries.mjs +232 -0
  92. package/api/search/_entries.test.mjs +48 -0
  93. package/api/search/_features.d.mts +35 -0
  94. package/api/search/_features.mjs +155 -0
  95. package/api/search/_gather-components.d.mts +26 -0
  96. package/api/search/_gather-components.mjs +284 -0
  97. package/api/search/_gather-docs.d.mts +20 -0
  98. package/api/search/_gather-docs.mjs +254 -0
  99. package/api/search/_gather-hooks.d.mts +12 -0
  100. package/api/search/_gather-hooks.mjs +52 -0
  101. package/api/search/_gather-templates.d.mts +25 -0
  102. package/api/search/_gather-templates.mjs +107 -0
  103. package/api/search/_lexical.d.mts +135 -0
  104. package/api/search/_lexical.mjs +351 -0
  105. package/api/search/_main-searcher.d.mts +19 -0
  106. package/api/search/_main-searcher.mjs +115 -0
  107. package/api/search/_main-searcher.test.mjs +106 -0
  108. package/api/search/_main-searcher.weights.json +1 -0
  109. package/api/search/_module-doc.d.mts +32 -0
  110. package/api/search/_module-doc.mjs +78 -0
  111. package/api/search/_order.d.mts +32 -0
  112. package/api/search/_order.mjs +162 -0
  113. package/api/search/_order.test.mjs +72 -0
  114. package/api/search/_priority.d.mts +50 -0
  115. package/api/search/_priority.mjs +139 -0
  116. package/api/search/_query-words.d.mts +25 -0
  117. package/api/search/_query-words.mjs +92 -0
  118. package/api/search/_query.d.mts +65 -0
  119. package/api/search/_query.mjs +176 -0
  120. package/api/search/_result.d.mts +97 -0
  121. package/api/search/_result.mjs +150 -0
  122. package/api/search/_score.d.mts +60 -0
  123. package/api/search/_score.mjs +283 -0
  124. package/api/search/_synonyms.d.mts +21 -0
  125. package/api/search/_synonyms.mjs +67 -0
  126. package/api/search/_template-searcher.d.mts +4 -0
  127. package/api/search/_template-searcher.mjs +23 -0
  128. package/api/search/_template-searcher.test.mjs +40 -0
  129. package/api/search/_template-searcher.weights.json +1 -0
  130. package/api/search/_titles.d.mts +33 -0
  131. package/api/search/_titles.mjs +65 -0
  132. package/api/search/_words.d.mts +64 -0
  133. package/api/search/_words.mjs +157 -0
  134. package/api/search/search.d.mts +22 -305
  135. package/api/search/search.doc.mjs +8 -6
  136. package/api/search/search.mjs +56 -2482
  137. package/api/search/search.test.mjs +14 -14
  138. package/api/search/search.type.d.mts +6 -1
  139. package/api/search/search.type.mjs +6 -1
  140. package/api/search/tree.d.mts +15 -0
  141. package/api/search/tree.mjs +40 -0
  142. package/api/search/tree.test.mjs +66 -0
  143. package/api/search/tree.weights.json +1 -0
  144. package/api/template/template.mjs +5 -1
  145. package/api/theme/build/build.packed-old-core.test.mjs +1 -0
  146. package/api/upgrade/_adapter.d.mts +57 -9
  147. package/api/upgrade/_adapter.mjs +198 -28
  148. package/api/upgrade/registry/registry.d.mts +10 -4
  149. package/api/upgrade/registry/registry.mjs +33 -16
  150. package/api/upgrade/registry/registry.test.mjs +85 -0
  151. package/api/upgrade/run/run.d.mts +4 -2
  152. package/api/upgrade/run/run.mjs +13 -2
  153. package/api/upgrade/run/run.test.mjs +417 -3
  154. package/api/upgrade/upgrade.doc.mjs +10 -5
  155. package/api/upgrade/upgrade.mjs +13 -2
  156. package/api/upgrade/upgrade.test.mjs +194 -0
  157. package/api/upgrade/upgrade.type.d.mts +5 -3
  158. package/api/upgrade/upgrade.type.mjs +8 -6
  159. package/assets/codemods/transforms/v0.7.0/__tests__/validate-data-token-ownership.test.mjs +11 -0
  160. package/assets/codemods/transforms/v0.7.0/validate-data-token-ownership.mjs +3 -3
  161. package/assets/docs/author-a-theme.doc.mjs +2 -2
  162. package/assets/docs/is-my-code-good.doc.mjs +287 -0
  163. package/assets/docs/tree/add-a-component.doc.mjs +1 -1
  164. package/assets/docs/tree/add-a-theme.doc.mjs +1 -1
  165. package/assets/docs/tree/add-a-topic.doc.mjs +2 -2
  166. package/assets/docs/tree/agent-guidance.doc.mjs +1 -1
  167. package/assets/docs/tree/api.doc.mjs +6 -0
  168. package/assets/docs/tree/{integrations.doc.mjs → authoring.doc.mjs} +15 -6
  169. package/assets/docs/tree/block-template.doc.mjs +1 -1
  170. package/assets/docs/tree/build-the-template.doc.mjs +1 -1
  171. package/assets/docs/tree/building-blocks.doc.mjs +2 -2
  172. package/assets/docs/tree/check-the-props.doc.mjs +1 -1
  173. package/assets/docs/tree/check-your-docs.doc.mjs +2 -2
  174. package/assets/docs/tree/checks.doc.mjs +3 -3
  175. package/assets/docs/tree/ci-and-containers.doc.mjs +13 -0
  176. package/assets/docs/tree/cli-command.doc.mjs +1 -1
  177. package/assets/docs/tree/cli.doc.mjs +1 -1
  178. package/assets/docs/tree/codemods.doc.mjs +1 -1
  179. package/assets/docs/tree/component-family.doc.mjs +1 -1
  180. package/assets/docs/tree/component-imports.doc.mjs +1 -1
  181. package/assets/docs/tree/components.doc.mjs +1 -1
  182. package/assets/docs/tree/configuration.doc.mjs +1 -1
  183. package/assets/docs/tree/debug-and-gap-reports.doc.mjs +1 -1
  184. package/assets/docs/tree/define-the-theme.doc.mjs +1 -1
  185. package/assets/docs/tree/describe-the-component.doc.mjs +1 -1
  186. package/assets/docs/tree/docs.doc.mjs +1 -1
  187. package/assets/docs/tree/document-the-template.doc.mjs +1 -1
  188. package/assets/docs/tree/document-the-theme.doc.mjs +1 -1
  189. package/assets/docs/tree/export-template-assets.doc.mjs +1 -1
  190. package/assets/docs/tree/extend-or-replace.doc.mjs +1 -1
  191. package/assets/docs/{authoring.doc.mjs → tree/field-reference.doc.mjs} +4 -3
  192. package/assets/docs/tree/fonts-and-assets.doc.mjs +1 -1
  193. package/assets/docs/tree/generate-a-palette.doc.mjs +1 -1
  194. package/assets/docs/tree/global-integrations.doc.mjs +2 -2
  195. package/assets/docs/tree/grade-template-with-agent.doc.mjs +4 -4
  196. package/assets/docs/tree/help.doc.mjs +2 -2
  197. package/assets/docs/tree/host-entry.doc.mjs +128 -0
  198. package/assets/docs/tree/links.doc.mjs +1 -1
  199. package/assets/docs/tree/package-and-test.doc.mjs +1 -1
  200. package/assets/docs/tree/page-template.doc.mjs +1 -1
  201. package/assets/docs/tree/publishing.doc.mjs +1 -1
  202. package/assets/docs/tree/quick-start.doc.mjs +1 -1
  203. package/assets/docs/tree/replace-a-core-component.doc.mjs +1 -1
  204. package/assets/docs/tree/replace-a-core-template.doc.mjs +1 -1
  205. package/assets/docs/tree/sections-and-placement.doc.mjs +1 -1
  206. package/assets/docs/tree/see-it-in-an-app.doc.mjs +1 -1
  207. package/assets/docs/tree/ship.doc.mjs +2 -2
  208. package/assets/docs/tree/short-and-findable.doc.mjs +1 -1
  209. package/assets/docs/tree/single-component.doc.mjs +1 -1
  210. package/assets/docs/tree/start-a-template.doc.mjs +1 -1
  211. package/assets/docs/tree/subcomponent.doc.mjs +1 -1
  212. package/assets/docs/tree/template-assets.doc.mjs +1 -1
  213. package/assets/docs/tree/template-doc-overview.doc.mjs +2 -2
  214. package/assets/docs/tree/template-fonts.doc.mjs +1 -1
  215. package/assets/docs/tree/template-grading-rubric.doc.mjs +17 -38
  216. package/assets/docs/tree/template-icons.doc.mjs +1 -1
  217. package/assets/docs/tree/template-images-media.doc.mjs +1 -1
  218. package/assets/docs/tree/template-styles.doc.mjs +1 -1
  219. package/assets/docs/tree/templates.doc.mjs +1 -1
  220. package/assets/docs/tree/test-in-an-app.doc.mjs +1 -1
  221. package/assets/docs/tree/test-template-in-app.doc.mjs +1 -1
  222. package/assets/docs/tree/themes.doc.mjs +1 -1
  223. package/assets/docs/tree/tokens-data.doc.mjs +2 -2
  224. package/assets/docs/tree/troubleshooting.doc.mjs +1 -1
  225. package/assets/docs/tree/upgrading.doc.mjs +1 -1
  226. package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +1 -1
  227. package/assets/docs/tree/verify-packed-template.doc.mjs +1 -1
  228. package/assets/docs/tree/versioning.doc.mjs +5 -1
  229. package/assets/docs/tree/write-good-templates.doc.mjs +1 -1
  230. package/assets/docs/tree/write-the-template-file.doc.mjs +1 -1
  231. package/assets/docs/use-integrations.doc.mjs +120 -0
  232. package/assets/docs/working-with-ai.doc.mjs +6 -2
  233. package/assets/templates/themes/butter/butterTheme.ts +4 -2
  234. package/assets/templates/themes/stone/stoneTheme.ts +4 -2
  235. package/assets/templates/themes/y2k/y2kTheme.ts +4 -2
  236. package/authoring/debug/parse.d.mts +1 -1
  237. package/authoring/doctypes/schema/schema.doc.mjs +1 -1
  238. package/authoring/integration/integration.doc.mjs +1 -1
  239. package/authoring/integration/type.ts +1 -1
  240. package/clients/cli/bin/astryx.mjs +7 -78
  241. package/clients/cli/command-result-coverage.test.mjs +6 -5
  242. package/clients/cli/commands/build-theme.color-scheme.test.mjs +1 -1
  243. package/clients/cli/commands/{component/index.mjs → component.mjs} +37 -37
  244. package/clients/cli/commands/component.test.mjs +6 -6
  245. package/clients/cli/commands/docs.doc.mjs +2 -2
  246. package/clients/cli/commands/docs.mjs +1 -1
  247. package/clients/cli/commands/docs.test.mjs +14 -14
  248. package/clients/cli/commands/doctor-integration.test.mjs +49 -1
  249. package/clients/cli/commands/doctor.doc.mjs +1 -1
  250. package/clients/cli/commands/doctor.mjs +40 -0
  251. package/clients/cli/commands/doctor.test.mjs +65 -0
  252. package/clients/cli/commands/{hook/index.mjs → hook.mjs} +22 -22
  253. package/clients/cli/commands/import-hint-correctness.test.mjs +1 -1
  254. package/clients/cli/commands/init.behavior.test.mjs +230 -1
  255. package/clients/cli/commands/init.doc.mjs +28 -9
  256. package/clients/cli/commands/init.flag-help.test.mjs +1 -0
  257. package/clients/cli/commands/init.mjs +2 -2
  258. package/clients/cli/commands/integration-check.test.mjs +48 -0
  259. package/clients/cli/commands/integration.doc.mjs +1 -1
  260. package/clients/cli/commands/manifest.doc.mjs +1 -1
  261. package/clients/cli/commands/manifest.mjs +67 -0
  262. package/clients/cli/commands/outside-project.test.mjs +101 -1
  263. package/clients/cli/commands/postinstall.doc.mjs +23 -0
  264. package/clients/cli/commands/postinstall.mjs +31 -0
  265. package/clients/cli/commands/setup-nudge.test.mjs +78 -0
  266. package/clients/cli/commands/{build-theme.mjs → theme.mjs} +1 -1
  267. package/clients/cli/commands/upgrade.doc.mjs +4 -2
  268. package/clients/cli/commands/upgrade.mjs +9 -2
  269. package/clients/cli/commands/upgrade.subfolder-path.test.mjs +97 -0
  270. package/clients/cli/index.mjs +54 -94
  271. package/clients/cli/lib/component-format.mjs +1 -1
  272. package/clients/cli/lib/define-command.mjs +12 -7
  273. package/clients/cli/lib/exit-codes.test.mjs +5 -0
  274. package/clients/cli/lib/manifest.test.mjs +12 -0
  275. package/clients/cli/lib/welcome-box.mjs +50 -0
  276. package/clients/cli/run.mjs +108 -0
  277. package/foundation/agent-docs/agent-doc-state.d.mts +32 -7
  278. package/foundation/agent-docs/agent-doc-state.mjs +58 -9
  279. package/foundation/agent-docs/agent-docs.d.mts +100 -12
  280. package/foundation/agent-docs/agent-docs.mjs +1017 -105
  281. package/foundation/agent-docs/agent-docs.path-safety.test.mjs +1239 -17
  282. package/foundation/agent-docs/agent-docs.test.mjs +683 -39
  283. package/foundation/agent-docs/computer-agent-text.d.mts +39 -2
  284. package/foundation/agent-docs/computer-agent-text.mjs +135 -8
  285. package/foundation/agent-docs/computer-agent-text.test.mjs +99 -2
  286. package/foundation/config/project.mjs +20 -22
  287. package/foundation/config/project.test.mjs +56 -0
  288. package/foundation/discovery/authoring-self-docs.d.mts +7 -0
  289. package/foundation/discovery/authoring-self-docs.mjs +16 -4
  290. package/foundation/discovery/authoring-self-docs.test.mjs +15 -3
  291. package/foundation/discovery/authoring-surface.d.mts +1 -1
  292. package/foundation/discovery/authoring-surface.mjs +2 -2
  293. package/foundation/discovery/authoring-surface.test.mjs +1 -1
  294. package/foundation/discovery/cli-self-docs.d.mts +2 -1
  295. package/foundation/discovery/cli-self-docs.mjs +4 -3
  296. package/foundation/discovery/cli-self-docs.test.mjs +2 -2
  297. package/foundation/discovery/component-discovery.d.mts +37 -0
  298. package/foundation/discovery/component-discovery.mjs +80 -5
  299. package/foundation/discovery/component-loader.d.mts +1 -1
  300. package/foundation/discovery/docs-discovery.mjs +14 -1
  301. package/foundation/discovery/module-exports.d.mts +41 -0
  302. package/foundation/discovery/module-exports.mjs +253 -0
  303. package/foundation/discovery/runner-allowlist.d.mts +2 -4
  304. package/foundation/discovery/runner-allowlist.mjs +2 -4
  305. package/foundation/discovery/runner-commands.d.mts +77 -0
  306. package/foundation/discovery/runner-commands.mjs +294 -0
  307. package/foundation/discovery/runner-commands.test.mjs +128 -0
  308. package/foundation/discovery/stray-pointers.test.mjs +1 -1
  309. package/foundation/discovery/template-adapter.mjs +18 -1
  310. package/foundation/discovery/template-needs.mjs +1 -44
  311. package/foundation/discovery/theme-discovery.mjs +147 -3
  312. package/foundation/doc-compiler/doc-loads.test.mjs +33 -9
  313. package/foundation/doc-compiler/read.mjs +59 -1
  314. package/foundation/doc-compiler/read.test.mjs +11 -2
  315. package/foundation/doc-compiler/split-topic-keywords.test.mjs +3 -2
  316. package/foundation/doc-compiler/tree.d.mts +32 -6
  317. package/foundation/doc-compiler/tree.mjs +77 -43
  318. package/foundation/doc-compiler/tree.test.mjs +7 -7
  319. package/foundation/fs/paths.d.mts +70 -8
  320. package/foundation/fs/paths.mjs +556 -38
  321. package/foundation/fs/paths.test.mjs +430 -54
  322. package/foundation/fs/read-record.d.mts +18 -0
  323. package/foundation/fs/read-record.mjs +131 -0
  324. package/foundation/fs/read-record.test.mjs +77 -0
  325. package/foundation/integrations/autolink.d.mts +2 -1
  326. package/foundation/integrations/autolink.mjs +4 -13
  327. package/foundation/integrations/cli-peer-version.d.mts +36 -0
  328. package/foundation/integrations/cli-peer-version.mjs +132 -0
  329. package/foundation/integrations/cli-peer-version.test.mjs +354 -0
  330. package/foundation/integrations/computer-integrations.d.mts +6 -3
  331. package/foundation/integrations/computer-integrations.mjs +38 -9
  332. package/foundation/integrations/contribution-inventory.d.mts +15 -20
  333. package/foundation/integrations/contribution-inventory.mjs +41 -5
  334. package/foundation/integrations/exports-subpaths.d.mts +57 -0
  335. package/foundation/integrations/exports-subpaths.mjs +113 -0
  336. package/foundation/integrations/integrations.d.mts +27 -1
  337. package/foundation/integrations/integrations.mjs +61 -2
  338. package/foundation/integrations/public-imports.d.mts +118 -0
  339. package/foundation/integrations/public-imports.mjs +1769 -0
  340. package/foundation/integrations/public-imports.test.mjs +1793 -0
  341. package/foundation/integrations/validate-contributions.d.mts +115 -0
  342. package/foundation/integrations/validate-contributions.mjs +1168 -13
  343. package/foundation/release/cache.test.mjs +24 -21
  344. package/foundation/release/global-state.d.mts +8 -4
  345. package/foundation/release/global-state.mjs +4 -2
  346. package/foundation/release/handoff.d.mts +23 -4
  347. package/foundation/release/handoff.mjs +175 -8
  348. package/foundation/release/notices.d.mts +62 -8
  349. package/foundation/release/notices.mjs +136 -25
  350. package/foundation/release/notices.test.mjs +21 -0
  351. package/foundation/release/run-context.mjs +14 -0
  352. package/foundation/response/response-types.doc.mjs +1 -1
  353. package/foundation/route/route.d.mts +285 -0
  354. package/foundation/route/route.mjs +324 -0
  355. package/foundation/route/route.test.mjs +153 -0
  356. package/foundation/runtime/hosted-runtime.test.mjs +403 -0
  357. package/foundation/runtime/locked-versions.d.mts +32 -0
  358. package/foundation/runtime/locked-versions.mjs +65 -0
  359. package/foundation/runtime/package-root.d.mts +91 -0
  360. package/foundation/runtime/package-root.mjs +174 -0
  361. package/foundation/runtime/package-set.d.mts +62 -0
  362. package/foundation/runtime/package-set.mjs +130 -0
  363. package/foundation/runtime/package-set.test.mjs +432 -0
  364. package/foundation/text/string-utils.d.mts +2 -1
  365. package/foundation/text/string-utils.mjs +16 -5
  366. package/foundation/text/suggest-order.d.mts +72 -0
  367. package/foundation/text/suggest-order.mjs +363 -0
  368. package/foundation/text/suggest-order.test.mjs +259 -0
  369. package/host/door-conformance.test.mjs +274 -0
  370. package/host/index.d.ts +116 -0
  371. package/host/index.mjs +295 -0
  372. package/host/index.test.mjs +302 -0
  373. package/package.json +14 -9
@@ -17,11 +17,22 @@ export const doc = {
17
17
  'Non-interactive project setup: install agent docs and point at the theme + build workflows.',
18
18
  description:
19
19
  'Sets a project up with NO prompts, so it behaves identically for humans, ' +
20
- 'agents, CI, and piped I/O. By default it installs the AGENTS.md/CLAUDE.md ' +
21
- 'agent-docs cheat sheet, including guidance from configured integrations, and ' +
20
+ 'agents, CI, and piped I/O. By default it writes the agent-docs cheat sheet, ' +
21
+ 'including guidance from configured integrations, at the project root (the nearest ' +
22
+ 'package.json that declares an @astryxdesign package, else the nearest package.json, ' +
23
+ 'searching no higher than the repository root): to AGENTS.md, ' +
24
+ "to the project's Claude Code file (CLAUDE.md, else .claude/CLAUDE.md; when CLAUDE.md " +
25
+ 'exists, a block in .claude/CLAUDE.md is removed, unless the project ignores CLAUDE.md, in which case a ' +
26
+ '.claude/CLAUDE.md the project commits keeps a copy), and as a ' +
27
+ 'one-line import of AGENTS.md in GEMINI.md unless GEMINI.md already imports it. ' +
28
+ 'In the home folder, or in a settings folder in it outside a project, it writes none: every ' +
29
+ 'folder of the home folder whose name starts with a dot is a settings folder, and such a folder itself never ' +
30
+ 'counts as a project, even with a package.json; a folder below it with a package.json does. ' +
31
+ 'The managed block is Astryx-owned: it is written, refreshed, and removed whatever ignore rules ' +
32
+ 'or generated markers say, and the text around it is never changed. It then ' +
22
33
  "prints getting-started guidance; `features` / `all` print only the chosen features' " +
23
34
  'guidance instead (the theme feature also writes the annotated theme template). ' +
24
- 'With `removeAgents` it removes the managed agent-docs block instead of installing. ' +
35
+ 'With `removeAgents` it removes the managed agent-docs block, at the project root and in `ctx.cwd`, instead of installing. ' +
25
36
  'Outside a project it writes the same files but prints no getting-started steps and no step that adds a theme to an app, since those set up a project the folder does not have. ' +
26
37
  "With `user` it sets up the computer instead of the folder: it writes the computer-level agent text, one skill file at `~/.agents/skills/astryx/SKILL.md`, linked into the skill folders of agents that read only their own (`~/.claude/skills` always; Kiro, Windsurf, Letta, Xcode's coding assistant, and `~/.config/agents/skills` when that folder exists), with a managed copy for Continue, whose scanner skips links,, telling agents anywhere on the computer that Astryx is there and when to use it; with `user` and `removeAgents` it removes the file and the links it made and records that the text is turned off. " +
27
38
  'The CLI installed for the computer refreshes the file in the background after each upgrade; package install scripts, project setup, and upgrade never write it.' +
@@ -46,7 +57,7 @@ export const doc = {
46
57
  name: 'options.removeAgents',
47
58
  type: 'boolean',
48
59
  description:
49
- 'Remove the managed agent-docs block instead of installing. With `user`, remove the computer-level agent text instead.',
60
+ 'Remove the managed agent-docs block, at the project root and in `ctx.cwd`, instead of installing. With `user`, remove the computer-level agent text instead.',
50
61
  },
51
62
  {
52
63
  name: 'options.user',
@@ -62,7 +73,10 @@ export const doc = {
62
73
  name: 'options.agent',
63
74
  type: 'string',
64
75
  description:
65
- 'Agent preset: claude, cursor, codex, hermes, muse, all. Used only when the agents feature runs. Refused with `user`.',
76
+ 'Agent preset: claude, cursor, codex, hermes, muse, all. `all` writes every existing agent doc except GEMINI.md, ' +
77
+ 'which keeps its one-line import of AGENTS.md. With claude and all, when CLAUDE.md gets the block, a block in ' +
78
+ '.claude/CLAUDE.md is removed, unless the project ignores CLAUDE.md, in which case a .claude/CLAUDE.md the ' +
79
+ 'project commits gets a copy too. Used only when the agents feature runs. Refused with `user`.',
66
80
  },
67
81
  {
68
82
  name: 'options.agentDocsPath',
@@ -122,7 +136,7 @@ export const doc = {
122
136
  },
123
137
  {
124
138
  code: 'ERR_PATH_TRAVERSAL',
125
- when: 'the template output path resolves outside cwd (for example through a symlinked src directory), or, with removeAgents, a managed agent-docs file resolves outside cwd through a symlink',
139
+ when: 'the template output path resolves outside cwd (for example through a symlinked src directory), or, with removeAgents, a managed agent-docs file in cwd, or at the project root when run there, resolves outside that folder through a symlink (run below the root, a project-root file is left as it is with a note)',
126
140
  },
127
141
  ],
128
142
  examples: [
@@ -10,6 +10,7 @@
10
10
 
11
11
  import {describe, it, expect, beforeEach, afterEach, vi} from 'vitest';
12
12
  import * as fs from 'node:fs';
13
+ import * as os from 'node:os';
13
14
  import * as path from 'node:path';
14
15
  import {init, getNextSteps} from './init.mjs';
15
16
  import {logger} from '../logger.mjs';
@@ -21,7 +22,8 @@ const MARKER_START = '<!-- ASTRYX:START -->';
21
22
  let tmpDir;
22
23
 
23
24
  beforeEach(() => {
24
- tmpDir = fs.mkdtempSync(path.join(process.cwd(), '.astryx-init-api-'));
25
+ // Outside any package: init writes agent docs at the nearest package.json.
26
+ tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-init-api-'));
25
27
  });
26
28
 
27
29
  afterEach(() => {
@@ -30,6 +32,18 @@ afterEach(() => {
30
32
 
31
33
  /** @param {string} rel */
32
34
  const read = rel => fs.readFileSync(path.join(tmpDir, rel), 'utf8');
35
+
36
+ /**
37
+ * Make tmpDir a project that declares Astryx: a folder that declares nothing
38
+ * is outside a project, where init prints no getting-started steps (spec
39
+ * AST-081 FR3).
40
+ */
41
+ function asProject() {
42
+ fs.writeFileSync(
43
+ path.join(tmpDir, 'package.json'),
44
+ JSON.stringify({name: 'app', dependencies: {'@astryxdesign/core': '*'}}),
45
+ );
46
+ }
33
47
  /** @param {string} rel */
34
48
  const exists = rel => fs.existsSync(path.join(tmpDir, rel));
35
49
 
@@ -58,6 +72,7 @@ function writeIntegration() {
58
72
 
59
73
  describe('init() — receipts + side effects', () => {
60
74
  it('default mode installs AGENTS.md and returns an init.run receipt', async () => {
75
+ asProject();
61
76
  const res = await init({}, {cwd: tmpDir});
62
77
  expect(res.type).toBe('init.run');
63
78
  if (res.type !== 'init.run') return;
@@ -217,6 +232,7 @@ describe('init() — logger', () => {
217
232
  });
218
233
 
219
234
  it('emits the install line + full next-steps through the shared logger', async () => {
235
+ asProject();
220
236
  /** @type {string[]} */
221
237
  const lines = [];
222
238
  const logSpy = vi.spyOn(console, 'log').mockImplementation((...a) => lines.push(a.join(' ')));
@@ -243,7 +259,7 @@ describe('init() — ASCII output', () => {
243
259
  const lines = [];
244
260
  const logSpy = vi.spyOn(console, 'log').mockImplementation((...a) => lines.push(a.join(' ')));
245
261
  const errSpy = vi.spyOn(console, 'error').mockImplementation((...a) => lines.push(a.join(' ')));
246
- const empty = fs.mkdtempSync(path.join(process.cwd(), '.astryx-init-remove-'));
262
+ const empty = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-init-remove-'));
247
263
  logger.setSilent(false);
248
264
  try {
249
265
  await init({}, {cwd: tmpDir});
@@ -11,11 +11,11 @@ export type InitRunData = {
11
11
  */
12
12
  features: string[];
13
13
  /**
14
- * Agent-doc files written (empty if agents weren't run or install failed).
14
+ * Agent-doc files written, relative to the directory init ran in (empty if agents weren't run or install failed). Without --agent-docs-path they sit at the project root: the nearest folder at or above it whose package.json declares an Astryx package, else the nearest with any package.json, within its repository and never the home folder; with none, the directory init ran in.
15
15
  */
16
16
  docsWritten: string[];
17
17
  /**
18
- * Soft agent-docs failure, if any. `path-safety` also implies a non-zero exit.
18
+ * Soft agent-docs failure, if any. `path-safety` also implies a non-zero exit. `install-failed` carries a message when init wrote no agent docs (the home folder, or a settings folder in it outside a project) or skipped a file that resolves outside the project; docsWritten then lists what was written.
19
19
  */
20
20
  docsError: {
21
21
  kind: "path-safety" | "install-failed";
@@ -113,7 +113,7 @@ export type InitOptions = {
113
113
  */
114
114
  all?: boolean | undefined;
115
115
  /**
116
- * Remove the managed agent-docs block instead of installing; with `user`, remove the computer-level agent text.
116
+ * Remove the managed agent-docs block, at the project root and in the folder init runs in, instead of installing; with `user`, remove the computer-level agent text.
117
117
  */
118
118
  removeAgents?: boolean | undefined;
119
119
  /**
@@ -10,8 +10,8 @@
10
10
  * @typedef {object} InitRunData
11
11
  * @property {'default' | 'features'} mode `default` (no flags) or `features` (--features/--all).
12
12
  * @property {string[]} features Features that were run, in order.
13
- * @property {string[]} docsWritten Agent-doc files written (empty if agents weren't run or install failed).
14
- * @property {{kind: 'path-safety' | 'install-failed', message?: string} | null} docsError Soft agent-docs failure, if any. `path-safety` also implies a non-zero exit.
13
+ * @property {string[]} docsWritten Agent-doc files written, relative to the directory init ran in (empty if agents weren't run or install failed). Without --agent-docs-path they sit at the project root: the nearest folder at or above it whose package.json declares an Astryx package, else the nearest with any package.json, within its repository and never the home folder; with none, the directory init ran in.
14
+ * @property {{kind: 'path-safety' | 'install-failed', message?: string} | null} docsError Soft agent-docs failure, if any. `path-safety` also implies a non-zero exit. `install-failed` carries a message when init wrote no agent docs (the home folder, or a settings folder in it outside a project) or skipped a file that resolves outside the project; docsWritten then lists what was written.
15
15
  * @property {boolean} theme Whether the theme feature ran.
16
16
  * @property {'created' | 'skipped' | 'failed' | null} themeTemplate Outcome of writing the annotated theme template (`skipped` = a file was already there).
17
17
  * @property {string | null} themeTemplatePath Relative output path when `themeTemplate === 'created'`.
@@ -70,7 +70,7 @@
70
70
  * @typedef {object} InitOptions
71
71
  * @property {string} [features] Comma-separated features to install (agents, theme, template).
72
72
  * @property {boolean} [all] Install all features.
73
- * @property {boolean} [removeAgents] Remove the managed agent-docs block instead of installing; with `user`, remove the computer-level agent text.
73
+ * @property {boolean} [removeAgents] Remove the managed agent-docs block, at the project root and in the folder init runs in, instead of installing; with `user`, remove the computer-level agent text.
74
74
  * @property {boolean} [user] Write the computer-level agent text (`~/.agents/skills/astryx/SKILL.md`, linked into `~/.claude/skills` and the skill folders of other installed tools, with a copy for Continue) instead of setting up the folder.
75
75
  * @property {string} [agent] Agent preset: claude, cursor, codex, hermes, muse, all. Refused with `user`.
76
76
  * @property {string | string[]} [agentDocsPath] Explicit agent-docs file path(s).
@@ -4,15 +4,16 @@
4
4
  * @file init.remove leaf — the `--remove-agents` path behind `astryx init`.
5
5
  *
6
6
  * `remove(ctx)` deletes the managed agent-docs block from every agent-doc file
7
- * and returns an `init.remove` receipt. The removal engine lives in
8
- * lib/agent-docs; this leaf only wires the cwd.
7
+ * at the project root, where init writes it, and in the working folder, and
8
+ * returns an `init.remove` receipt. The removal engine lives in
9
+ * foundation/agent-docs; this leaf only wires the cwd.
9
10
  *
10
11
  * Note: removeAgentDocs() still logs its own per-file lines via humanLog
11
12
  * (shared lib behavior) — so a programmatic remove is not perfectly silent yet.
12
13
  * Threading a logger through agent-docs is a separate cleanup.
13
14
  */
14
15
 
15
- import {removeAgentDocs} from '../../../foundation/agent-docs/agent-docs.mjs';
16
+ import {removeProjectAgentDocs} from '../../../foundation/agent-docs/agent-docs.mjs';
16
17
  import {logger} from '../../logger.mjs';
17
18
 
18
19
  /**
@@ -23,7 +24,19 @@ import {logger} from '../../logger.mjs';
23
24
  * @returns {Promise<import('../init.type.mjs').InitRemoveResponse>}
24
25
  */
25
26
  export async function remove({cwd = process.cwd()} = {}) {
26
- const removedFrom = removeAgentDocs(cwd);
27
+ /** @type {string[]} */
28
+ const skipped = [];
29
+ const removedFrom = removeProjectAgentDocs(cwd, {
30
+ onSkipped: (rel, reason) => skipped.push(`${rel} (${reason})`),
31
+ });
32
+ if (skipped.length > 0) {
33
+ // Below the project root, as install does there (0.7.x touched only the
34
+ // working folder): a root agent file outside the project is left alone.
35
+ logger.warn(
36
+ `Note: Left as ${skipped.length === 1 ? 'it is' : 'they are'}: ${skipped.join('; ')}. ` +
37
+ 'To remove the Astryx block there, delete it by hand.',
38
+ );
39
+ }
27
40
  const removed = removedFrom.length > 0;
28
41
  logger.log(
29
42
  removed
@@ -1,12 +1,124 @@
1
1
  // Copyright (c) Meta Platforms, Inc. and affiliates.
2
2
  import {describe, it, expect, beforeEach, afterEach, vi} from 'vitest';
3
- import * as fs from 'node:fs'; import * as path from 'node:path';
3
+ import * as fs from 'node:fs'; import * as path from 'node:path'; import * as os from 'node:os';
4
4
  import {init} from '../init.mjs'; import {remove} from './remove.mjs'; import {logger} from '../../logger.mjs';
5
5
  let dir;
6
- beforeEach(() => { dir = fs.mkdtempSync(path.join(process.cwd(), '.astryx-rm-')); fs.writeFileSync(path.join(dir,'package.json'),JSON.stringify({name:'c',version:'1.0.0'})); });
6
+ beforeEach(() => { dir = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-rm-')); fs.writeFileSync(path.join(dir,'package.json'),JSON.stringify({name:'c',version:'1.0.0'})); });
7
7
  afterEach(() => { fs.rmSync(dir,{recursive:true,force:true}); logger.setSilent(true); });
8
8
  describe('init.remove says whether anything was removed', () => {
9
9
  it('false on clean', async () => { const r=await remove({cwd:dir}); expect(r.type).toBe('init.remove'); expect(r.data.removed).toBe(false); });
10
10
  it('true then false', async () => { await init({features:['agents']},{cwd:dir}); expect(fs.readFileSync(path.join(dir,'AGENTS.md'),'utf8')).toContain('<!-- ASTRYX:START -->'); const a=await remove({cwd:dir}); expect(a.data.removed).toBe(true); const b=await remove({cwd:dir}); expect(b.data.removed).toBe(false); });
11
11
  it('human line', async () => { const l=[]; const s=vi.spyOn(console,'log').mockImplementation((...a)=>l.push(a.join(' '))); logger.setSilent(false); try{await remove({cwd:dir});}finally{logger.setSilent(true);s.mockRestore();} expect(l.join('\n')).toContain('Nothing to remove'); });
12
12
  });
13
+
14
+ describe('init.remove acts where init writes, the project root, and in the folder it runs in', () => {
15
+ /** @type {string} */
16
+ let project;
17
+ beforeEach(() => {
18
+ project = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-rm-root-'));
19
+ fs.writeFileSync(
20
+ path.join(project, 'package.json'),
21
+ JSON.stringify({name: 'app', dependencies: {'@astryxdesign/core': '1.0.0'}}),
22
+ );
23
+ fs.mkdirSync(path.join(project, 'src', 'app'), {recursive: true});
24
+ });
25
+ afterEach(() => { fs.rmSync(project, {recursive: true, force: true}); });
26
+ const block = '<!-- ASTRYX:START -->\nAstryx v0.7.0 · old\n<!-- ASTRYX:END -->\n';
27
+
28
+ it('removes from a subfolder what init wrote at the project root', async () => {
29
+ const sub = path.join(project, 'src', 'app');
30
+ const written = await init({features: ['agents']}, {cwd: sub});
31
+ expect(written.data.docsWritten).toEqual(['../../AGENTS.md', '../../GEMINI.md']);
32
+
33
+ const r = await remove({cwd: sub});
34
+ expect(r).toEqual({type: 'init.remove', data: {removed: true}});
35
+ // Both files held only what init wrote, so they are deleted.
36
+ expect(fs.existsSync(path.join(project, 'AGENTS.md'))).toBe(false);
37
+ expect(fs.existsSync(path.join(project, 'GEMINI.md'))).toBe(false);
38
+ expect((await remove({cwd: sub})).data.removed).toBe(false);
39
+ });
40
+
41
+ it('removes a block an earlier version left in the subfolder, and keeps the files\' own text', async () => {
42
+ const sub = path.join(project, 'src', 'app');
43
+ fs.writeFileSync(path.join(project, 'AGENTS.md'), `# Agents\n\nRoot rules.\n\n${block}`);
44
+ fs.writeFileSync(path.join(sub, 'AGENTS.md'), `# App\n\nApp rules.\n\n${block}`);
45
+
46
+ expect((await remove({cwd: sub})).data.removed).toBe(true);
47
+ expect(fs.readFileSync(path.join(project, 'AGENTS.md'), 'utf8').trimEnd()).toBe('# Agents\n\nRoot rules.');
48
+ expect(fs.readFileSync(path.join(sub, 'AGENTS.md'), 'utf8').trimEnd()).toBe('# App\n\nApp rules.');
49
+ });
50
+
51
+ it('run at the project root, leaves a subfolder alone', async () => {
52
+ const sub = path.join(project, 'src', 'app');
53
+ fs.writeFileSync(path.join(project, 'AGENTS.md'), `# Agents\n\n${block}`);
54
+ fs.writeFileSync(path.join(sub, 'AGENTS.md'), `# App\n\n${block}`);
55
+
56
+ expect((await remove({cwd: project})).data.removed).toBe(true);
57
+ expect(fs.readFileSync(path.join(sub, 'AGENTS.md'), 'utf8')).toContain('<!-- ASTRYX:START -->');
58
+ });
59
+
60
+ it('below the root, leaves a root agent file linked outside the project with a note, and removes the rest (0.7.x exited 0)', async () => {
61
+ // A workspace member whose CLAUDE.md links to the monorepo's.
62
+ const monorepo = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-rm-mono-'));
63
+ try {
64
+ const web = path.join(monorepo, 'apps', 'web');
65
+ const sub = path.join(web, 'src');
66
+ fs.mkdirSync(sub, {recursive: true});
67
+ fs.writeFileSync(
68
+ path.join(web, 'package.json'),
69
+ JSON.stringify({name: 'web', dependencies: {'@astryxdesign/core': '1.0.0'}}),
70
+ );
71
+ fs.writeFileSync(path.join(monorepo, 'CLAUDE.md'), `# Shared\n\n${block}`);
72
+ fs.symlinkSync('../../CLAUDE.md', path.join(web, 'CLAUDE.md'));
73
+ fs.writeFileSync(path.join(web, 'AGENTS.md'), `# Web\n\n${block}`);
74
+ fs.writeFileSync(path.join(sub, 'AGENTS.md'), `# Src\n\n${block}`);
75
+ const warned = [];
76
+ const warn = vi.spyOn(console, 'error').mockImplementation((...a) => warned.push(a.join(' ')));
77
+ logger.setSilent(false);
78
+ let r;
79
+ try {
80
+ r = await remove({cwd: sub});
81
+ } finally {
82
+ logger.setSilent(true);
83
+ warn.mockRestore();
84
+ }
85
+ expect(r).toEqual({type: 'init.remove', data: {removed: true}});
86
+ expect(fs.readFileSync(path.join(web, 'AGENTS.md'), 'utf8').trimEnd()).toBe('# Web');
87
+ expect(fs.readFileSync(path.join(sub, 'AGENTS.md'), 'utf8').trimEnd()).toBe('# Src');
88
+ // The file outside the project keeps its block.
89
+ expect(fs.readFileSync(path.join(monorepo, 'CLAUDE.md'), 'utf8')).toContain('<!-- ASTRYX:START -->');
90
+ expect(warned.join('\n')).toMatch(/Note: Left as it is: \.\.\/CLAUDE\.md \(/u);
91
+ } finally {
92
+ fs.rmSync(monorepo, {recursive: true, force: true});
93
+ }
94
+ });
95
+
96
+ it('at the root, a root agent file linked outside the project still refuses the run', async () => {
97
+ const outside = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-rm-outside-'));
98
+ try {
99
+ fs.writeFileSync(path.join(outside, 'CLAUDE.md'), `# Shared\n\n${block}`);
100
+ fs.symlinkSync(path.join(outside, 'CLAUDE.md'), path.join(project, 'CLAUDE.md'));
101
+ fs.writeFileSync(path.join(project, 'AGENTS.md'), `# Agents\n\n${block}`);
102
+ await expect(remove({cwd: project})).rejects.toMatchObject({code: 'ERR_PATH_TRAVERSAL'});
103
+ expect(fs.readFileSync(path.join(project, 'AGENTS.md'), 'utf8')).toContain('<!-- ASTRYX:START -->');
104
+ } finally {
105
+ fs.rmSync(outside, {recursive: true, force: true});
106
+ }
107
+ });
108
+
109
+ it('a link in the subfolder that escapes it refuses the run before anything is written', async () => {
110
+ const sub = path.join(project, 'src', 'app');
111
+ const outside = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-rm-outside-'));
112
+ try {
113
+ fs.writeFileSync(path.join(project, 'AGENTS.md'), `# Agents\n\n${block}`);
114
+ fs.writeFileSync(path.join(outside, 'CLAUDE.md'), `# Shared\n\n${block}`);
115
+ fs.symlinkSync(path.join(outside, 'CLAUDE.md'), path.join(sub, 'CLAUDE.md'));
116
+
117
+ await expect(remove({cwd: sub})).rejects.toMatchObject({code: 'ERR_PATH_TRAVERSAL'});
118
+ expect(fs.readFileSync(path.join(project, 'AGENTS.md'), 'utf8')).toContain('<!-- ASTRYX:START -->');
119
+ expect(fs.readFileSync(path.join(outside, 'CLAUDE.md'), 'utf8')).toContain('<!-- ASTRYX:START -->');
120
+ } finally {
121
+ fs.rmSync(outside, {recursive: true, force: true});
122
+ }
123
+ });
124
+ });
@@ -4,10 +4,12 @@
4
4
  * @file init.run leaf — non-interactive project setup + feature installer.
5
5
  *
6
6
  * `run(options, ctx)` is the default / `--features` / `--all` path behind
7
- * `astryx init`. It installs the AGENTS.md/CLAUDE.md agent-docs cheat sheet,
8
- * points at the theme + page-building workflows, and (optionally) scaffolds a
9
- * starter template — with NO prompts, so it behaves identically for humans,
10
- * agents, CI, and piped I/O. It performs the side effects and returns an
7
+ * `astryx init`. It installs the agent-docs cheat sheet at the project root so
8
+ * every agent reads it (AGENTS.md, a copy in the project's Claude Code file, and
9
+ * a GEMINI.md import), points at the theme + page-building workflows, and
10
+ * (optionally) scaffolds a starter template — with NO prompts, so it behaves
11
+ * identically for humans, agents, CI, and piped I/O. It performs the side
12
+ * effects and returns an
11
13
  * `init.run` receipt. Hard errors (unknown feature/template) throw AstryxError
12
14
  * with a stable code. Human output is emitted through the shared `logger`
13
15
  * (silent by default) so the CLI keeps its exact plain output and a
@@ -21,8 +23,11 @@ import {PathSafetyError, assertWithin} from '../../../foundation/fs/path-safety.
21
23
  import {getCliInvocation} from '../../../foundation/env/package-manager.mjs';
22
24
  import {isOutsideProject} from '../../../foundation/env/project-scope.mjs';
23
25
  import {
26
+ AgentDocsHomeError,
27
+ assertAgentDocsTarget,
24
28
  installAgentDocs,
25
29
  renderAgentDocsBlock,
30
+ agentDocsTargetDir,
26
31
  } from '../../../foundation/agent-docs/agent-docs.mjs';
27
32
  import {themeTemplate} from '../../theme/template/template.mjs';
28
33
  import {listTemplates} from '../../template/template.mjs';
@@ -64,6 +69,24 @@ export function getNextSteps(invocation) {
64
69
  ];
65
70
  }
66
71
 
72
+ /**
73
+ * Whether two paths name one folder, links resolved.
74
+ * @param {string} a
75
+ * @param {string} b
76
+ * @returns {boolean}
77
+ */
78
+ function sameFolder(a, b) {
79
+ /** @param {string} p */
80
+ const real = p => {
81
+ try {
82
+ return fs.realpathSync(p);
83
+ } catch {
84
+ return path.resolve(p);
85
+ }
86
+ };
87
+ return real(a) === real(b);
88
+ }
89
+
67
90
  /**
68
91
  * Install the agent-docs block; records the outcome (or soft error) on `data`.
69
92
  * Mirrors the CLI's historical soft-error policy: a PathSafetyError surfaces its
@@ -92,14 +115,46 @@ async function applyAgents(cwd, options, invocation, data) {
92
115
  ? options.agentDocsPath
93
116
  : [options.agentDocsPath]
94
117
  : undefined;
95
- const renderedBlock = await renderAgentDocsBlock(cwd);
96
- const written = installAgentDocs(cwd, {
118
+ // The docs belong at the project root, not in the subfolder init ran in;
119
+ // with no project above, they go where init ran, as before. Explicit
120
+ // --agent-docs-path entries stay relative to where init ran.
121
+ const root = agentDocsTargetDir(cwd);
122
+ const targetDir = paths ? cwd : root;
123
+ // With explicit paths, installAgentDocs checks each file's own folder.
124
+ if (!paths) assertAgentDocsTarget(targetDir);
125
+ const renderedBlock = await renderAgentDocsBlock(root);
126
+ /** @type {string[]} */
127
+ const skipped = [];
128
+ const files = installAgentDocs(targetDir, {
97
129
  agent: options.agent,
98
130
  paths,
99
131
  renderedBlock,
132
+ onSkipped: (rel, reason) => skipped.push(`${rel} (${reason})`),
133
+ // Below the project root, 0.7.1 wrote in the folder init ran in, so a
134
+ // project-root file that escapes the project is skipped and reported,
135
+ // not refused.
136
+ refuseEscapes: sameFolder(targetDir, cwd),
100
137
  });
138
+ // Each file is reported from where init ran, as before.
139
+ const written =
140
+ path.resolve(targetDir) === path.resolve(cwd)
141
+ ? files
142
+ : files.map(rel =>
143
+ path.relative(cwd, path.join(targetDir, rel)).split(path.sep).join('/'),
144
+ );
101
145
  data.docsWritten = written;
102
146
  logger.log(`[ok] AI agent docs installed -> ${written.join(', ')}`);
147
+ // A file 0.7.1 did not write (GEMINI.md, or a project-root file when init
148
+ // runs below the root) that resolves outside the project is left as it
149
+ // is, reported in docsError with one note; the exit code stays 0. A file
150
+ // 0.7.1 wrote whose path escapes the project still fails the run (below).
151
+ if (skipped.length > 0) {
152
+ const message =
153
+ `Left as ${skipped.length === 1 ? 'it is' : 'they are'}: ${skipped.join('; ')}. ` +
154
+ 'To have init write the Astryx block there, make it a regular file inside the project, or copy the block from AGENTS.md by hand.';
155
+ logger.warn(`Note: ${message}`);
156
+ data.docsError = {kind: 'install-failed', message};
157
+ }
103
158
  } catch (err) {
104
159
  // PathSafetyError carries a precise, user-actionable message — surface it
105
160
  // (and flag exit 1) instead of the generic "could not install" warning so
@@ -109,6 +164,14 @@ async function applyAgents(cwd, options, invocation, data) {
109
164
  data.docsError = {kind: 'path-safety', message: err.message};
110
165
  return;
111
166
  }
167
+ // The home folder, and a settings folder in it outside a project, are
168
+ // refused: nothing is written, the reason is printed as a note, and the
169
+ // exit code stays 0.
170
+ if (err instanceof AgentDocsHomeError) {
171
+ logger.warn(`Note: ${err.message}`);
172
+ data.docsError = {kind: 'install-failed', message: err.message};
173
+ return;
174
+ }
112
175
  logger.error(
113
176
  `Could not install agent docs. Try again with \`${invocation} init --features agents\`.`,
114
177
  );
@@ -40,6 +40,14 @@ export function integrationFluff(discovered: Parameters<typeof findFluff>[0]): P
40
40
  * read too
41
41
  */
42
42
  export function integrationStrayPointers(discovered: Parameters<typeof findStrayPointers>[0], integration?: any): Promise<import("./authoring-checks.type.mjs").StrayPointer[]>;
43
+ /**
44
+ * Each Astryx command a package's topics write with a package runner. A
45
+ * package whose topics cannot be discovered has none here: the other checks
46
+ * report topics that do not load.
47
+ * @param {any} integration a loaded integration
48
+ * @returns {Promise<import('../../foundation/discovery/runner-commands.mjs').RunnerCommand[]>}
49
+ */
50
+ export function integrationRunnerCommands(integration: any): Promise<import("../../foundation/discovery/runner-commands.mjs").RunnerCommand[]>;
43
51
  import { findCopiedPassages } from '../../foundation/discovery/copied-passages.mjs';
44
52
  import { findFluff } from '../../foundation/discovery/doc-fluff.mjs';
45
53
  import { findStrayPointers } from '../../foundation/discovery/stray-pointers.mjs';
@@ -2,7 +2,8 @@
2
2
 
3
3
  /**
4
4
  * @file The integration subject's access to the environment (INV21): reading
5
- * one package's component docs and sources with the project's own TypeScript.
5
+ * one package's component docs and sources with the project's own TypeScript,
6
+ * and its topics.
6
7
  *
7
8
  * @input a loaded integration and the directory the command runs in
8
9
  * @output the reports the integration checks attach to their results
@@ -14,9 +15,11 @@ import {
14
15
  forEachIntegrationDoc,
15
16
  integrationSourceForDoc,
16
17
  } from '../../foundation/discovery/component-discovery.mjs';
18
+ import {discoverIntegrationDocs} from '../../foundation/discovery/docs-discovery.mjs';
17
19
  import {comparePropDocs} from '../../foundation/discovery/prop-drift.mjs';
18
20
  import {findCopiedPassages} from '../../foundation/discovery/copied-passages.mjs';
19
21
  import {findFluff} from '../../foundation/discovery/doc-fluff.mjs';
22
+ import {findRunnerCommands} from '../../foundation/discovery/runner-commands.mjs';
20
23
  import {findStrayPointers} from '../../foundation/discovery/stray-pointers.mjs';
21
24
 
22
25
  /**
@@ -110,3 +113,20 @@ export async function integrationStrayPointers(discovered, integration) {
110
113
  }
111
114
  return findStrayPointers({...discovered, components});
112
115
  }
116
+
117
+ /**
118
+ * Each Astryx command a package's topics write with a package runner. A
119
+ * package whose topics cannot be discovered has none here: the other checks
120
+ * report topics that do not load.
121
+ * @param {any} integration a loaded integration
122
+ * @returns {Promise<import('../../foundation/discovery/runner-commands.mjs').RunnerCommand[]>}
123
+ */
124
+ export async function integrationRunnerCommands(integration) {
125
+ let discovered;
126
+ try {
127
+ discovered = await discoverIntegrationDocs(integration);
128
+ } catch {
129
+ return [];
130
+ }
131
+ return findRunnerCommands(discovered);
132
+ }