@a1st/aix-core 0.0.12 → 0.2.0

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 (366) hide show
  1. package/dist/backup.d.ts.map +1 -1
  2. package/dist/backup.js +13 -14
  3. package/dist/backup.js.map +1 -1
  4. package/dist/cache/cleanup.d.ts.map +1 -1
  5. package/dist/cache/cleanup.js +7 -8
  6. package/dist/cache/cleanup.js.map +1 -1
  7. package/dist/cache/clear.js +4 -4
  8. package/dist/cache/clear.js.map +1 -1
  9. package/dist/cache/status.d.ts.map +1 -1
  10. package/dist/cache/status.js +4 -5
  11. package/dist/cache/status.js.map +1 -1
  12. package/dist/discovery.d.ts.map +1 -1
  13. package/dist/discovery.js +18 -17
  14. package/dist/discovery.js.map +1 -1
  15. package/dist/editors/adapters/base.d.ts +8 -4
  16. package/dist/editors/adapters/base.d.ts.map +1 -1
  17. package/dist/editors/adapters/base.js +131 -40
  18. package/dist/editors/adapters/base.js.map +1 -1
  19. package/dist/editors/adapters/claude-code.d.ts +3 -3
  20. package/dist/editors/adapters/claude-code.d.ts.map +1 -1
  21. package/dist/editors/adapters/claude-code.js +7 -6
  22. package/dist/editors/adapters/claude-code.js.map +1 -1
  23. package/dist/editors/adapters/codex.d.ts +20 -10
  24. package/dist/editors/adapters/codex.d.ts.map +1 -1
  25. package/dist/editors/adapters/codex.js +67 -30
  26. package/dist/editors/adapters/codex.js.map +1 -1
  27. package/dist/editors/adapters/copilot.d.ts +6 -3
  28. package/dist/editors/adapters/copilot.d.ts.map +1 -1
  29. package/dist/editors/adapters/copilot.js +53 -10
  30. package/dist/editors/adapters/copilot.js.map +1 -1
  31. package/dist/editors/adapters/cursor.d.ts +2 -2
  32. package/dist/editors/adapters/cursor.d.ts.map +1 -1
  33. package/dist/editors/adapters/cursor.js +3 -2
  34. package/dist/editors/adapters/cursor.js.map +1 -1
  35. package/dist/editors/adapters/gemini.d.ts +44 -0
  36. package/dist/editors/adapters/gemini.d.ts.map +1 -0
  37. package/dist/editors/adapters/gemini.js +139 -0
  38. package/dist/editors/adapters/gemini.js.map +1 -0
  39. package/dist/editors/adapters/index.d.ts +2 -0
  40. package/dist/editors/adapters/index.d.ts.map +1 -1
  41. package/dist/editors/adapters/index.js +2 -0
  42. package/dist/editors/adapters/index.js.map +1 -1
  43. package/dist/editors/adapters/opencode.d.ts +25 -0
  44. package/dist/editors/adapters/opencode.d.ts.map +1 -0
  45. package/dist/editors/adapters/opencode.js +74 -0
  46. package/dist/editors/adapters/opencode.js.map +1 -0
  47. package/dist/editors/adapters/windsurf.d.ts +1 -1
  48. package/dist/editors/adapters/windsurf.d.ts.map +1 -1
  49. package/dist/editors/adapters/windsurf.js +2 -1
  50. package/dist/editors/adapters/windsurf.js.map +1 -1
  51. package/dist/editors/adapters/zed.d.ts.map +1 -1
  52. package/dist/editors/adapters/zed.js +8 -3
  53. package/dist/editors/adapters/zed.js.map +1 -1
  54. package/dist/editors/import.d.ts +62 -1
  55. package/dist/editors/import.d.ts.map +1 -1
  56. package/dist/editors/import.js +431 -188
  57. package/dist/editors/import.js.map +1 -1
  58. package/dist/editors/index.d.ts +4 -4
  59. package/dist/editors/index.d.ts.map +1 -1
  60. package/dist/editors/index.js +2 -2
  61. package/dist/editors/index.js.map +1 -1
  62. package/dist/editors/install.d.ts.map +1 -1
  63. package/dist/editors/install.js +57 -11
  64. package/dist/editors/install.js.map +1 -1
  65. package/dist/editors/prompt-skill-installer.d.ts +17 -0
  66. package/dist/editors/prompt-skill-installer.d.ts.map +1 -0
  67. package/dist/editors/prompt-skill-installer.js +23 -0
  68. package/dist/editors/prompt-skill-installer.js.map +1 -0
  69. package/dist/editors/section-managed-markdown.d.ts +33 -0
  70. package/dist/editors/section-managed-markdown.d.ts.map +1 -0
  71. package/dist/editors/section-managed-markdown.js +97 -0
  72. package/dist/editors/section-managed-markdown.js.map +1 -0
  73. package/dist/editors/strategies/claude-code/hooks.d.ts +6 -1
  74. package/dist/editors/strategies/claude-code/hooks.d.ts.map +1 -1
  75. package/dist/editors/strategies/claude-code/hooks.js +278 -29
  76. package/dist/editors/strategies/claude-code/hooks.js.map +1 -1
  77. package/dist/editors/strategies/claude-code/mcp.d.ts +3 -2
  78. package/dist/editors/strategies/claude-code/mcp.d.ts.map +1 -1
  79. package/dist/editors/strategies/claude-code/mcp.js +8 -7
  80. package/dist/editors/strategies/claude-code/mcp.js.map +1 -1
  81. package/dist/editors/strategies/claude-code/prompts.d.ts +1 -1
  82. package/dist/editors/strategies/claude-code/prompts.d.ts.map +1 -1
  83. package/dist/editors/strategies/claude-code/prompts.js +18 -39
  84. package/dist/editors/strategies/claude-code/prompts.js.map +1 -1
  85. package/dist/editors/strategies/claude-code/rules.d.ts +1 -0
  86. package/dist/editors/strategies/claude-code/rules.d.ts.map +1 -1
  87. package/dist/editors/strategies/claude-code/rules.js +6 -3
  88. package/dist/editors/strategies/claude-code/rules.js.map +1 -1
  89. package/dist/editors/strategies/codex/prompts.d.ts +6 -5
  90. package/dist/editors/strategies/codex/prompts.d.ts.map +1 -1
  91. package/dist/editors/strategies/codex/prompts.js +34 -55
  92. package/dist/editors/strategies/codex/prompts.js.map +1 -1
  93. package/dist/editors/strategies/codex/rules.d.ts +2 -1
  94. package/dist/editors/strategies/codex/rules.d.ts.map +1 -1
  95. package/dist/editors/strategies/codex/rules.js +22 -0
  96. package/dist/editors/strategies/codex/rules.js.map +1 -1
  97. package/dist/editors/strategies/copilot/hooks.d.ts +8 -4
  98. package/dist/editors/strategies/copilot/hooks.d.ts.map +1 -1
  99. package/dist/editors/strategies/copilot/hooks.js +231 -60
  100. package/dist/editors/strategies/copilot/hooks.js.map +1 -1
  101. package/dist/editors/strategies/copilot/mcp.d.ts +4 -2
  102. package/dist/editors/strategies/copilot/mcp.d.ts.map +1 -1
  103. package/dist/editors/strategies/copilot/mcp.js +83 -41
  104. package/dist/editors/strategies/copilot/mcp.js.map +1 -1
  105. package/dist/editors/strategies/copilot/prompts.d.ts +2 -1
  106. package/dist/editors/strategies/copilot/prompts.d.ts.map +1 -1
  107. package/dist/editors/strategies/copilot/prompts.js +21 -71
  108. package/dist/editors/strategies/copilot/prompts.js.map +1 -1
  109. package/dist/editors/strategies/cursor/hooks.d.ts +8 -2
  110. package/dist/editors/strategies/cursor/hooks.d.ts.map +1 -1
  111. package/dist/editors/strategies/cursor/hooks.js +174 -22
  112. package/dist/editors/strategies/cursor/hooks.js.map +1 -1
  113. package/dist/editors/strategies/cursor/prompts.d.ts.map +1 -1
  114. package/dist/editors/strategies/cursor/prompts.js +11 -44
  115. package/dist/editors/strategies/cursor/prompts.js.map +1 -1
  116. package/dist/editors/strategies/cursor/rules.js +3 -3
  117. package/dist/editors/strategies/cursor/rules.js.map +1 -1
  118. package/dist/editors/strategies/gemini/hooks.d.ts +18 -0
  119. package/dist/editors/strategies/gemini/hooks.d.ts.map +1 -0
  120. package/dist/editors/strategies/gemini/hooks.js +152 -0
  121. package/dist/editors/strategies/gemini/hooks.js.map +1 -0
  122. package/dist/editors/strategies/gemini/index.d.ts +5 -0
  123. package/dist/editors/strategies/gemini/index.d.ts.map +1 -0
  124. package/dist/editors/strategies/gemini/index.js +5 -0
  125. package/dist/editors/strategies/gemini/index.js.map +1 -0
  126. package/dist/editors/strategies/gemini/mcp.d.ts +19 -0
  127. package/dist/editors/strategies/gemini/mcp.d.ts.map +1 -0
  128. package/dist/editors/strategies/gemini/mcp.js +73 -0
  129. package/dist/editors/strategies/gemini/mcp.js.map +1 -0
  130. package/dist/editors/strategies/gemini/prompts.d.ts +34 -0
  131. package/dist/editors/strategies/gemini/prompts.d.ts.map +1 -0
  132. package/dist/editors/strategies/gemini/prompts.js +92 -0
  133. package/dist/editors/strategies/gemini/prompts.js.map +1 -0
  134. package/dist/editors/strategies/gemini/rules.d.ts +19 -0
  135. package/dist/editors/strategies/gemini/rules.d.ts.map +1 -0
  136. package/dist/editors/strategies/gemini/rules.js +58 -0
  137. package/dist/editors/strategies/gemini/rules.js.map +1 -0
  138. package/dist/editors/strategies/index.d.ts +1 -0
  139. package/dist/editors/strategies/index.d.ts.map +1 -1
  140. package/dist/editors/strategies/index.js +1 -0
  141. package/dist/editors/strategies/index.js.map +1 -1
  142. package/dist/editors/strategies/opencode/import-utils.d.ts +5 -0
  143. package/dist/editors/strategies/opencode/import-utils.d.ts.map +1 -0
  144. package/dist/editors/strategies/opencode/import-utils.js +181 -0
  145. package/dist/editors/strategies/opencode/import-utils.js.map +1 -0
  146. package/dist/editors/strategies/opencode/index.d.ts +4 -0
  147. package/dist/editors/strategies/opencode/index.d.ts.map +1 -0
  148. package/dist/editors/strategies/opencode/index.js +4 -0
  149. package/dist/editors/strategies/opencode/index.js.map +1 -0
  150. package/dist/editors/strategies/opencode/mcp.d.ts +19 -0
  151. package/dist/editors/strategies/opencode/mcp.d.ts.map +1 -0
  152. package/dist/editors/strategies/opencode/mcp.js +145 -0
  153. package/dist/editors/strategies/opencode/mcp.js.map +1 -0
  154. package/dist/editors/strategies/opencode/prompts.d.ts +22 -0
  155. package/dist/editors/strategies/opencode/prompts.d.ts.map +1 -0
  156. package/dist/editors/strategies/opencode/prompts.js +102 -0
  157. package/dist/editors/strategies/opencode/prompts.js.map +1 -0
  158. package/dist/editors/strategies/opencode/rules.d.ts +19 -0
  159. package/dist/editors/strategies/opencode/rules.d.ts.map +1 -0
  160. package/dist/editors/strategies/opencode/rules.js +99 -0
  161. package/dist/editors/strategies/opencode/rules.js.map +1 -0
  162. package/dist/editors/strategies/shared/global-mcp.d.ts.map +1 -1
  163. package/dist/editors/strategies/shared/global-mcp.js +4 -6
  164. package/dist/editors/strategies/shared/global-mcp.js.map +1 -1
  165. package/dist/editors/strategies/shared/hook-import-utils.d.ts +21 -0
  166. package/dist/editors/strategies/shared/hook-import-utils.d.ts.map +1 -0
  167. package/dist/editors/strategies/shared/hook-import-utils.js +98 -0
  168. package/dist/editors/strategies/shared/hook-import-utils.js.map +1 -0
  169. package/dist/editors/strategies/shared/native-skills.d.ts +10 -4
  170. package/dist/editors/strategies/shared/native-skills.d.ts.map +1 -1
  171. package/dist/editors/strategies/shared/native-skills.js +29 -23
  172. package/dist/editors/strategies/shared/native-skills.js.map +1 -1
  173. package/dist/editors/strategies/shared/no-hooks.d.ts +8 -3
  174. package/dist/editors/strategies/shared/no-hooks.d.ts.map +1 -1
  175. package/dist/editors/strategies/shared/no-hooks.js +17 -2
  176. package/dist/editors/strategies/shared/no-hooks.js.map +1 -1
  177. package/dist/editors/strategies/shared/pointer-skills.d.ts +7 -2
  178. package/dist/editors/strategies/shared/pointer-skills.d.ts.map +1 -1
  179. package/dist/editors/strategies/shared/pointer-skills.js +21 -10
  180. package/dist/editors/strategies/shared/pointer-skills.js.map +1 -1
  181. package/dist/editors/strategies/shared/prompt-utils.d.ts +30 -0
  182. package/dist/editors/strategies/shared/prompt-utils.d.ts.map +1 -0
  183. package/dist/editors/strategies/shared/prompt-utils.js +101 -0
  184. package/dist/editors/strategies/shared/prompt-utils.js.map +1 -0
  185. package/dist/editors/strategies/types.d.ts +104 -2
  186. package/dist/editors/strategies/types.d.ts.map +1 -1
  187. package/dist/editors/strategies/windsurf/hooks.d.ts +6 -1
  188. package/dist/editors/strategies/windsurf/hooks.d.ts.map +1 -1
  189. package/dist/editors/strategies/windsurf/hooks.js +106 -20
  190. package/dist/editors/strategies/windsurf/hooks.js.map +1 -1
  191. package/dist/editors/strategies/windsurf/prompts.d.ts.map +1 -1
  192. package/dist/editors/strategies/windsurf/prompts.js +14 -62
  193. package/dist/editors/strategies/windsurf/prompts.js.map +1 -1
  194. package/dist/editors/strategies/windsurf/rules.js +3 -3
  195. package/dist/editors/strategies/windsurf/rules.js.map +1 -1
  196. package/dist/editors/strategies/windsurf/skills.d.ts +1 -1
  197. package/dist/editors/strategies/windsurf/skills.d.ts.map +1 -1
  198. package/dist/editors/strategies/windsurf/skills.js +4 -2
  199. package/dist/editors/strategies/windsurf/skills.js.map +1 -1
  200. package/dist/editors/strategies/zed/prompts.d.ts +2 -12
  201. package/dist/editors/strategies/zed/prompts.d.ts.map +1 -1
  202. package/dist/editors/strategies/zed/prompts.js +2 -19
  203. package/dist/editors/strategies/zed/prompts.js.map +1 -1
  204. package/dist/editors/strategies/zed/rules.d.ts +2 -1
  205. package/dist/editors/strategies/zed/rules.d.ts.map +1 -1
  206. package/dist/editors/strategies/zed/rules.js +27 -0
  207. package/dist/editors/strategies/zed/rules.js.map +1 -1
  208. package/dist/editors/types.d.ts +44 -1
  209. package/dist/editors/types.d.ts.map +1 -1
  210. package/dist/entity-hash.d.ts +26 -0
  211. package/dist/entity-hash.d.ts.map +1 -0
  212. package/dist/entity-hash.js +106 -0
  213. package/dist/entity-hash.js.map +1 -0
  214. package/dist/env/ci.d.ts +0 -4
  215. package/dist/env/ci.d.ts.map +1 -1
  216. package/dist/env/ci.js +10 -8
  217. package/dist/env/ci.js.map +1 -1
  218. package/dist/errors.d.ts +5 -0
  219. package/dist/errors.d.ts.map +1 -1
  220. package/dist/errors.js +13 -1
  221. package/dist/errors.js.map +1 -1
  222. package/dist/format-error.d.ts +16 -3
  223. package/dist/format-error.d.ts.map +1 -1
  224. package/dist/format-error.js +101 -22
  225. package/dist/format-error.js.map +1 -1
  226. package/dist/frontmatter-utils.d.ts +7 -2
  227. package/dist/frontmatter-utils.d.ts.map +1 -1
  228. package/dist/frontmatter-utils.js +9 -2
  229. package/dist/frontmatter-utils.js.map +1 -1
  230. package/dist/fs/safe-rm.d.ts +2 -3
  231. package/dist/fs/safe-rm.d.ts.map +1 -1
  232. package/dist/fs/safe-rm.js +21 -10
  233. package/dist/fs/safe-rm.js.map +1 -1
  234. package/dist/git-download.js +4 -4
  235. package/dist/git-download.js.map +1 -1
  236. package/dist/git-loader.d.ts.map +1 -1
  237. package/dist/git-loader.js +5 -6
  238. package/dist/git-loader.js.map +1 -1
  239. package/dist/global/index.d.ts +3 -4
  240. package/dist/global/index.d.ts.map +1 -1
  241. package/dist/global/index.js +2 -3
  242. package/dist/global/index.js.map +1 -1
  243. package/dist/global/processor.d.ts.map +1 -1
  244. package/dist/global/processor.js +21 -59
  245. package/dist/global/processor.js.map +1 -1
  246. package/dist/global/types.d.ts +2 -0
  247. package/dist/global/types.d.ts.map +1 -1
  248. package/dist/import-writer.d.ts +2 -0
  249. package/dist/import-writer.d.ts.map +1 -1
  250. package/dist/import-writer.js +22 -24
  251. package/dist/import-writer.js.map +1 -1
  252. package/dist/index.d.ts +6 -0
  253. package/dist/index.d.ts.map +1 -1
  254. package/dist/index.js +6 -0
  255. package/dist/index.js.map +1 -1
  256. package/dist/inheritance.d.ts.map +1 -1
  257. package/dist/inheritance.js +18 -17
  258. package/dist/inheritance.js.map +1 -1
  259. package/dist/json.js.map +1 -1
  260. package/dist/loader.d.ts +8 -1
  261. package/dist/loader.d.ts.map +1 -1
  262. package/dist/loader.js +25 -12
  263. package/dist/loader.js.map +1 -1
  264. package/dist/lockfile.d.ts +31 -0
  265. package/dist/lockfile.d.ts.map +1 -0
  266. package/dist/lockfile.js +270 -0
  267. package/dist/lockfile.js.map +1 -0
  268. package/dist/mcp/env.d.ts.map +1 -1
  269. package/dist/mcp/env.js +3 -2
  270. package/dist/mcp/env.js.map +1 -1
  271. package/dist/merge.d.ts +9 -5
  272. package/dist/merge.d.ts.map +1 -1
  273. package/dist/merge.js +8 -6
  274. package/dist/merge.js.map +1 -1
  275. package/dist/npm/resolve.d.ts.map +1 -1
  276. package/dist/npm/resolve.js +15 -17
  277. package/dist/npm/resolve.js.map +1 -1
  278. package/dist/prompts/index.d.ts +1 -0
  279. package/dist/prompts/index.d.ts.map +1 -1
  280. package/dist/prompts/index.js +1 -0
  281. package/dist/prompts/index.js.map +1 -1
  282. package/dist/prompts/loader.d.ts.map +1 -1
  283. package/dist/prompts/loader.js +4 -5
  284. package/dist/prompts/loader.js.map +1 -1
  285. package/dist/prompts/to-skills.d.ts +26 -0
  286. package/dist/prompts/to-skills.d.ts.map +1 -0
  287. package/dist/prompts/to-skills.js +87 -0
  288. package/dist/prompts/to-skills.js.map +1 -0
  289. package/dist/reference-resolver.d.ts +86 -0
  290. package/dist/reference-resolver.d.ts.map +1 -0
  291. package/dist/reference-resolver.js +250 -0
  292. package/dist/reference-resolver.js.map +1 -0
  293. package/dist/remote-loader.d.ts.map +1 -1
  294. package/dist/remote-loader.js +35 -19
  295. package/dist/remote-loader.js.map +1 -1
  296. package/dist/rules/loader.d.ts.map +1 -1
  297. package/dist/rules/loader.js +4 -5
  298. package/dist/rules/loader.js.map +1 -1
  299. package/dist/rules/merger.d.ts.map +1 -1
  300. package/dist/rules/merger.js +2 -2
  301. package/dist/rules/merger.js.map +1 -1
  302. package/dist/rules/skill-rules.d.ts.map +1 -1
  303. package/dist/rules/skill-rules.js +2 -2
  304. package/dist/rules/skill-rules.js.map +1 -1
  305. package/dist/rules/utils.js.map +1 -1
  306. package/dist/runtime/browser-dummy.d.ts +3 -0
  307. package/dist/runtime/browser-dummy.d.ts.map +1 -0
  308. package/dist/runtime/browser-dummy.js +46 -0
  309. package/dist/runtime/browser-dummy.js.map +1 -0
  310. package/dist/runtime/index.d.ts +9 -0
  311. package/dist/runtime/index.d.ts.map +1 -0
  312. package/dist/runtime/index.js +23 -0
  313. package/dist/runtime/index.js.map +1 -0
  314. package/dist/runtime/node.d.ts +3 -0
  315. package/dist/runtime/node.d.ts.map +1 -0
  316. package/dist/runtime/node.js +219 -0
  317. package/dist/runtime/node.js.map +1 -0
  318. package/dist/runtime/types.d.ts +130 -0
  319. package/dist/runtime/types.d.ts.map +1 -0
  320. package/dist/runtime/types.js +2 -0
  321. package/dist/runtime/types.js.map +1 -0
  322. package/dist/skills/cache.js +2 -2
  323. package/dist/skills/cache.js.map +1 -1
  324. package/dist/skills/parser.d.ts.map +1 -1
  325. package/dist/skills/parser.js +6 -2
  326. package/dist/skills/parser.js.map +1 -1
  327. package/dist/skills/reference-parser.d.ts.map +1 -1
  328. package/dist/skills/reference-parser.js +6 -6
  329. package/dist/skills/reference-parser.js.map +1 -1
  330. package/dist/skills/resolve.js.map +1 -1
  331. package/dist/skills/resolvers/git.d.ts.map +1 -1
  332. package/dist/skills/resolvers/git.js +4 -5
  333. package/dist/skills/resolvers/git.js.map +1 -1
  334. package/dist/skills/resolvers/local.d.ts.map +1 -1
  335. package/dist/skills/resolvers/local.js +2 -2
  336. package/dist/skills/resolvers/local.js.map +1 -1
  337. package/dist/skills/resolvers/npm.d.ts.map +1 -1
  338. package/dist/skills/resolvers/npm.js +2 -2
  339. package/dist/skills/resolvers/npm.js.map +1 -1
  340. package/dist/skills/validate.d.ts.map +1 -1
  341. package/dist/skills/validate.js +4 -4
  342. package/dist/skills/validate.js.map +1 -1
  343. package/dist/state/index.d.ts +3 -0
  344. package/dist/state/index.d.ts.map +1 -0
  345. package/dist/state/index.js +3 -0
  346. package/dist/state/index.js.map +1 -0
  347. package/dist/state/tracker.d.ts +68 -0
  348. package/dist/state/tracker.d.ts.map +1 -0
  349. package/dist/state/tracker.js +143 -0
  350. package/dist/state/tracker.js.map +1 -0
  351. package/dist/state/types.d.ts +37 -0
  352. package/dist/state/types.d.ts.map +1 -0
  353. package/dist/state/types.js +2 -0
  354. package/dist/state/types.js.map +1 -0
  355. package/dist/updater.d.ts.map +1 -1
  356. package/dist/updater.js +18 -19
  357. package/dist/updater.js.map +1 -1
  358. package/dist/url-parsing.d.ts +12 -1
  359. package/dist/url-parsing.d.ts.map +1 -1
  360. package/dist/url-parsing.js +26 -3
  361. package/dist/url-parsing.js.map +1 -1
  362. package/package.json +14 -5
  363. package/dist/global/tracking.d.ts +0 -109
  364. package/dist/global/tracking.d.ts.map +0 -1
  365. package/dist/global/tracking.js +0 -193
  366. package/dist/global/tracking.js.map +0 -1
@@ -1,67 +1,37 @@
1
- import { readFile, readdir } from 'node:fs/promises';
2
- import { homedir } from 'node:os';
3
1
  import { join } from 'pathe';
4
- import { WindsurfRulesStrategy } from './strategies/windsurf/rules.js';
5
- import { WindsurfPromptsStrategy } from './strategies/windsurf/prompts.js';
6
- import { WindsurfMcpStrategy } from './strategies/windsurf/mcp.js';
7
- import { StandardMcpStrategy } from './strategies/shared/standard-mcp.js';
8
- import { CursorRulesStrategy } from './strategies/cursor/rules.js';
9
- import { CursorPromptsStrategy } from './strategies/cursor/prompts.js';
10
- import { ClaudeCodeMcpStrategy } from './strategies/claude-code/mcp.js';
11
- import { ClaudeCodeRulesStrategy } from './strategies/claude-code/rules.js';
12
- import { ClaudeCodePromptsStrategy } from './strategies/claude-code/prompts.js';
13
- import { CopilotMcpStrategy } from './strategies/copilot/mcp.js';
14
- import { CopilotRulesStrategy } from './strategies/copilot/rules.js';
15
- import { CopilotPromptsStrategy } from './strategies/copilot/prompts.js';
16
- import { ZedMcpStrategy } from './strategies/zed/mcp.js';
17
- import { ZedRulesStrategy } from './strategies/zed/rules.js';
18
- import { ZedPromptsStrategy } from './strategies/zed/prompts.js';
19
- import { CodexRulesStrategy } from './strategies/codex/rules.js';
20
- import { CodexPromptsStrategy } from './strategies/codex/prompts.js';
21
- import { CodexMcpStrategy } from './strategies/codex/mcp.js';
22
- /**
23
- * Get the import strategies for an editor.
24
- */
25
- function getImportStrategies(editor) {
26
- switch (editor) {
27
- case 'windsurf':
28
- return {
29
- mcp: new WindsurfMcpStrategy(),
30
- rules: new WindsurfRulesStrategy(),
31
- prompts: new WindsurfPromptsStrategy(),
32
- };
33
- case 'cursor':
34
- return {
35
- mcp: new StandardMcpStrategy(),
36
- rules: new CursorRulesStrategy(),
37
- prompts: new CursorPromptsStrategy(),
38
- };
39
- case 'claude-code':
40
- return {
41
- mcp: new ClaudeCodeMcpStrategy(),
42
- rules: new ClaudeCodeRulesStrategy(),
43
- prompts: new ClaudeCodePromptsStrategy(),
44
- };
45
- case 'copilot':
46
- return {
47
- mcp: new CopilotMcpStrategy(),
48
- rules: new CopilotRulesStrategy(),
49
- prompts: new CopilotPromptsStrategy(),
50
- };
51
- case 'zed':
52
- return {
53
- mcp: new ZedMcpStrategy(),
54
- rules: new ZedRulesStrategy(),
55
- prompts: new ZedPromptsStrategy(),
56
- };
57
- case 'codex':
58
- return {
59
- mcp: new CodexMcpStrategy(),
60
- rules: new CodexRulesStrategy(),
61
- prompts: new CodexPromptsStrategy(),
62
- };
2
+ import { createEmptyConfig, } from '@a1st/aix-schema';
3
+ import { getAdapter } from './install.js';
4
+ import { UnsupportedRuntimeCapabilityError } from '../errors.js';
5
+ import { getRuntimeAdapter } from '../runtime/index.js';
6
+ function existsSync(path) {
7
+ return getRuntimeAdapter().fs.existsSync(path);
8
+ }
9
+ function homedir() {
10
+ return getRuntimeAdapter().os.homedir();
11
+ }
12
+ function assertGlobalHomeAccess(action) {
13
+ if (!getRuntimeAdapter().host.supportsGlobalHomeAccess()) {
14
+ throw new UnsupportedRuntimeCapabilityError('global-home-access', action);
63
15
  }
64
16
  }
17
+ function readFile(path, encoding) {
18
+ return getRuntimeAdapter().fs.readFile(path, encoding);
19
+ }
20
+ function readdir(path, options) {
21
+ if (options) {
22
+ return getRuntimeAdapter().fs.readdir(path, options);
23
+ }
24
+ return getRuntimeAdapter().fs.readdir(path);
25
+ }
26
+ function buildGlobalPath(relativePath) {
27
+ return relativePath ? join(homedir(), relativePath) : null;
28
+ }
29
+ function buildProjectPath(relativePath, projectRoot, configDir, isProjectRootConfig = false) {
30
+ if (!projectRoot) {
31
+ return null;
32
+ }
33
+ return isProjectRootConfig ? join(projectRoot, relativePath) : join(projectRoot, configDir, relativePath);
34
+ }
65
35
  /**
66
36
  * Import configuration from an editor and convert to ai.json format.
67
37
  * Merges global config with project-local editor config: Object.assign({}, global, local)
@@ -75,223 +45,496 @@ export async function importFromEditor(editor, options = {}) {
75
45
  rules: [],
76
46
  skills: {},
77
47
  prompts: {},
48
+ hooks: {},
49
+ paths: { mcp: {}, rules: {}, skills: {}, prompts: {}, hooks: {} },
50
+ scopes: { mcp: {}, rules: {}, skills: {}, prompts: {}, hooks: {} },
78
51
  warnings: [],
79
52
  sources: { global: false, local: false },
80
- }, strategies = getImportStrategies(editor), projectRoot = options.projectRoot ?? process.cwd();
81
- // 1. Import from GLOBAL config first (base layer)
82
- const globalMcp = await importMcpConfig(strategies.mcp, editor, 'global');
83
- if (Object.keys(globalMcp.mcp).length > 0) {
84
- result.sources.global = true;
85
- }
86
- Object.assign(result.mcp, globalMcp.mcp);
87
- result.warnings.push(...globalMcp.warnings);
88
- const globalRules = await importGlobalRules(strategies.rules);
89
- if (globalRules.rules.length > 0) {
90
- result.sources.global = true;
91
- }
92
- result.rules.push(...globalRules.rules);
93
- result.warnings.push(...globalRules.warnings);
94
- const globalPrompts = await importPrompts(strategies.prompts, 'global');
95
- if (Object.keys(globalPrompts.prompts).length > 0) {
96
- result.sources.global = true;
97
- }
98
- Object.assign(result.prompts, globalPrompts.prompts);
99
- result.warnings.push(...globalPrompts.warnings);
100
- // 2. Import from LOCAL editor config (overlay - overrides global)
101
- const localMcp = await importLocalMcpConfig(strategies.mcp, editor, projectRoot);
102
- if (Object.keys(localMcp.mcp).length > 0) {
103
- result.sources.local = true;
104
- }
105
- Object.assign(result.mcp, localMcp.mcp);
106
- result.warnings.push(...localMcp.warnings);
107
- const localRules = await importLocalRules(strategies.rules, editor, projectRoot);
108
- if (localRules.rules.length > 0) {
109
- result.sources.local = true;
110
- }
111
- result.rules.push(...localRules.rules);
112
- result.warnings.push(...localRules.warnings);
113
- const localPrompts = await importLocalPrompts(strategies.prompts, editor, projectRoot);
114
- if (Object.keys(localPrompts.prompts).length > 0) {
115
- result.sources.local = true;
116
- }
117
- Object.assign(result.prompts, localPrompts.prompts);
118
- result.warnings.push(...localPrompts.warnings);
53
+ }, strategies = getAdapter(editor).getStrategyBundle(), projectRoot = options.projectRoot ?? getRuntimeAdapter().process.cwd(), scope = options.scope ?? 'all';
54
+ if (scope === 'all' || scope === 'user') {
55
+ assertGlobalHomeAccess(`importing global ${editor} configuration`);
56
+ mergeImportMcp(result, await importMcpConfig(strategies.mcpStrategy, strategies.configDir, 'global'));
57
+ mergeImportRules(result, await importGlobalRules(strategies.rulesStrategy, strategies.configDir));
58
+ mergeImportPrompts(result, await importPrompts(strategies.promptsStrategy, strategies.configDir, 'global'));
59
+ mergeImportSkills(result, await importSkills(strategies.skillsStrategy, 'user', projectRoot));
60
+ mergeImportHooks(result, await importHooks(strategies.hooksStrategy, strategies.configDir, 'global'));
61
+ }
62
+ if (scope === 'all' || scope === 'project') {
63
+ mergeImportMcp(result, await importLocalMcpConfig(strategies.mcpStrategy, strategies.configDir, projectRoot));
64
+ mergeImportRules(result, await importLocalRules(strategies.rulesStrategy, strategies.configDir, projectRoot));
65
+ mergeImportPrompts(result, await importLocalPrompts(strategies.promptsStrategy, strategies.configDir, projectRoot));
66
+ mergeImportSkills(result, await importSkills(strategies.skillsStrategy, 'project', projectRoot));
67
+ mergeImportHooks(result, await importHooks(strategies.hooksStrategy, strategies.configDir, 'project', projectRoot));
68
+ }
119
69
  return result;
120
70
  }
121
- /** Editor config directory names */
122
- const EDITOR_CONFIG_DIRS = {
123
- windsurf: '.windsurf',
124
- cursor: '.cursor',
125
- 'claude-code': '.claude',
126
- copilot: '.vscode',
127
- zed: '.zed',
128
- codex: '.codex',
129
- };
71
+ function mergeImportMcp(result, imported) {
72
+ if (Object.keys(imported.mcp).length > 0) {
73
+ for (const scope of Object.values(imported.scopes)) {
74
+ result.sources[scope === 'user' ? 'global' : 'local'] = true;
75
+ }
76
+ }
77
+ Object.assign(result.mcp, imported.mcp);
78
+ Object.assign(result.paths.mcp, imported.paths);
79
+ Object.assign(result.scopes.mcp, imported.scopes);
80
+ result.warnings.push(...imported.warnings);
81
+ }
82
+ function mergeImportRules(result, imported) {
83
+ if (imported.rules.length > 0) {
84
+ for (const scope of Object.values(imported.scopes)) {
85
+ result.sources[scope === 'user' ? 'global' : 'local'] = true;
86
+ }
87
+ }
88
+ result.rules.push(...imported.rules);
89
+ Object.assign(result.paths.rules, imported.paths);
90
+ Object.assign(result.scopes.rules, imported.scopes);
91
+ result.warnings.push(...imported.warnings);
92
+ }
93
+ function mergeImportPrompts(result, imported) {
94
+ if (Object.keys(imported.prompts).length > 0) {
95
+ for (const scope of Object.values(imported.scopes)) {
96
+ result.sources[scope === 'user' ? 'global' : 'local'] = true;
97
+ }
98
+ }
99
+ Object.assign(result.prompts, imported.prompts);
100
+ Object.assign(result.paths.prompts, imported.paths);
101
+ Object.assign(result.scopes.prompts, imported.scopes);
102
+ result.warnings.push(...imported.warnings);
103
+ }
104
+ function mergeImportSkills(result, imported) {
105
+ if (Object.keys(imported.skills).length > 0) {
106
+ for (const scope of Object.values(imported.scopes)) {
107
+ result.sources[scope === 'user' ? 'global' : 'local'] = true;
108
+ }
109
+ }
110
+ Object.assign(result.skills, imported.skills);
111
+ Object.assign(result.paths.skills, imported.paths);
112
+ Object.assign(result.scopes.skills, imported.scopes);
113
+ result.warnings.push(...imported.warnings);
114
+ }
115
+ function mergeImportHooks(result, imported) {
116
+ if (Object.keys(imported.hooks).length > 0) {
117
+ for (const scope of Object.values(imported.scopes)) {
118
+ result.sources[scope === 'user' ? 'global' : 'local'] = true;
119
+ }
120
+ }
121
+ Object.assign(result.hooks, imported.hooks);
122
+ Object.assign(result.paths.hooks, imported.paths);
123
+ Object.assign(result.scopes.hooks, imported.scopes);
124
+ result.warnings.push(...imported.warnings);
125
+ }
126
+ function sanitizeImportedName(name) {
127
+ return name
128
+ .trim()
129
+ .toLowerCase()
130
+ .replace(/[^a-z0-9-]/g, '-')
131
+ .replace(/-+/g, '-')
132
+ .replace(/^-|-$/g, '') || 'imported-item';
133
+ }
134
+ function dedupeImportedName(name, used) {
135
+ const baseName = sanitizeImportedName(name);
136
+ let candidate = baseName, index = 1;
137
+ while (used.has(candidate)) {
138
+ candidate = `${baseName}-${index}`;
139
+ index += 1;
140
+ }
141
+ used.add(candidate);
142
+ return candidate;
143
+ }
144
+ function normalizeImportedRule(strategy, rule, usedNames) {
145
+ const normalized = {
146
+ name: dedupeImportedName(rule.name, usedNames),
147
+ sourceName: rule.name,
148
+ rawContent: rule.content,
149
+ content: rule.content,
150
+ };
151
+ if (!strategy.parseFrontmatter) {
152
+ return normalized;
153
+ }
154
+ const parsed = strategy.parseFrontmatter(rule.content);
155
+ normalized.content = parsed.content;
156
+ normalized.description = parsed.metadata.description;
157
+ normalized.activation = parsed.metadata.activation;
158
+ normalized.globs = parsed.metadata.globs;
159
+ return normalized;
160
+ }
161
+ function normalizeImportedPrompt(strategy, [sourceName, rawContent], usedNames) {
162
+ const normalized = {
163
+ name: dedupeImportedName(sourceName, usedNames),
164
+ sourceName,
165
+ rawContent,
166
+ content: rawContent,
167
+ };
168
+ if (!strategy.parseFrontmatter) {
169
+ return normalized;
170
+ }
171
+ const parsed = strategy.parseFrontmatter(rawContent);
172
+ normalized.content = parsed.content;
173
+ normalized.description = parsed.description;
174
+ normalized.argumentHint = Array.isArray(parsed.argumentHint)
175
+ ? parsed.argumentHint.join(', ')
176
+ : parsed.argumentHint;
177
+ return normalized;
178
+ }
130
179
  /**
131
- * Import MCP configuration from an editor's global config.
180
+ * Convert imported editor content into normalized aix data that can be written to ai.json or
181
+ * passed through another editor adapter.
132
182
  */
133
- async function importMcpConfig(strategy, _editor, _source) {
134
- const warnings = [], configPath = strategy.getGlobalMcpConfigPath();
183
+ export function normalizeEditorImport(editor, result) {
184
+ const strategies = getAdapter(editor).getStrategyBundle(), usedRuleNames = new Set(), usedPromptNames = new Set(), usedSkillNames = new Set();
185
+ return {
186
+ mcp: result.mcp,
187
+ rules: result.rules.map((rule) => normalizeImportedRule(strategies.rulesStrategy, rule, usedRuleNames)),
188
+ prompts: Object.entries(result.prompts)
189
+ .map((entry) => normalizeImportedPrompt(strategies.promptsStrategy, entry, usedPromptNames)),
190
+ skills: Object.entries(result.skills).map(([sourceName, ref]) => ({
191
+ name: dedupeImportedName(sourceName, usedSkillNames),
192
+ sourceName,
193
+ ref,
194
+ })),
195
+ hooks: result.hooks,
196
+ };
197
+ }
198
+ /**
199
+ * Build an ai.json-shaped config object from imported editor content. This is the bridge used by
200
+ * `aix init --from` and `aix sync`, so editor-to-editor sync does not require a custom
201
+ * converter for every source/destination pair.
202
+ */
203
+ export function buildConfigFromEditorImport(editor, result) {
204
+ const normalized = normalizeEditorImport(editor, result), config = createEmptyConfig();
205
+ config.mcp = normalized.mcp;
206
+ config.rules = Object.fromEntries(normalized.rules.map((rule) => {
207
+ const value = {
208
+ content: rule.content,
209
+ };
210
+ if (rule.description) {
211
+ value.description = rule.description;
212
+ }
213
+ if (rule.activation) {
214
+ value.activation = rule.activation;
215
+ }
216
+ if (rule.globs && rule.globs.length > 0) {
217
+ value.globs = rule.globs;
218
+ }
219
+ return [rule.name, value];
220
+ }));
221
+ config.prompts = Object.fromEntries(normalized.prompts.map((prompt) => {
222
+ const value = {
223
+ content: prompt.content,
224
+ };
225
+ if (prompt.description) {
226
+ value.description = prompt.description;
227
+ }
228
+ if (prompt.argumentHint) {
229
+ value.argumentHint = prompt.argumentHint;
230
+ }
231
+ return [prompt.name, value];
232
+ }));
233
+ config.skills = Object.fromEntries(normalized.skills.map((skill) => [skill.name, skill.ref]));
234
+ if (Object.keys(normalized.hooks).length > 0) {
235
+ config.hooks = normalized.hooks;
236
+ }
237
+ return config;
238
+ }
239
+ async function importHooks(strategy, configDir, source, projectRoot) {
240
+ const configPath = source === 'global'
241
+ ? buildGlobalPath(strategy.getGlobalConfigPath())
242
+ : buildProjectPath(strategy.getConfigPath(), projectRoot, configDir);
135
243
  if (!configPath) {
136
- // Not a warning - some editors don't have global MCP config
137
- return { mcp: {}, warnings };
244
+ return { hooks: {}, paths: {}, scopes: {}, warnings: [] };
138
245
  }
139
- const fullPath = join(homedir(), configPath);
140
246
  try {
141
- const content = await readFile(fullPath, 'utf-8'), result = strategy.parseGlobalMcpConfig(content);
142
- return result;
247
+ const content = await readFile(configPath, 'utf-8'), parsed = strategy.parseImportedConfig(content), scope = source === 'global' ? 'user' : 'project', eventNames = Object.keys(parsed.hooks);
248
+ return {
249
+ hooks: parsed.hooks,
250
+ paths: pathMapForNames(eventNames, configPath),
251
+ scopes: scopeMapForNames(eventNames, scope),
252
+ warnings: parsed.warnings,
253
+ };
143
254
  }
144
255
  catch (err) {
145
- if (err.code !== 'ENOENT') {
146
- warnings.push(`Failed to read global MCP config at ${fullPath}: ${err.message}`);
256
+ if (err.code === 'ENOENT') {
257
+ return { hooks: {}, paths: {}, scopes: {}, warnings: [] };
147
258
  }
259
+ return {
260
+ hooks: {},
261
+ paths: {},
262
+ scopes: {},
263
+ warnings: [`Failed to read hooks config at ${configPath}: ${err.message}`],
264
+ };
148
265
  }
149
- return { mcp: {}, warnings };
266
+ }
267
+ /**
268
+ * Import MCP configuration from an editor's global config.
269
+ */
270
+ async function importMcpConfig(strategy, _configDir, _source) {
271
+ return importMcpFromPaths(strategy, getGlobalMcpImportPaths(strategy), 'user', 'global MCP config');
150
272
  }
151
273
  /**
152
274
  * Import MCP configuration from project-local editor config.
153
275
  */
154
- async function importLocalMcpConfig(strategy, editor, projectRoot) {
155
- const warnings = [], configDir = EDITOR_CONFIG_DIRS[editor], mcpConfigPath = strategy.getConfigPath(), baseDir = strategy.isProjectRootConfig?.() ? projectRoot : join(projectRoot, configDir), fullPath = join(baseDir, mcpConfigPath);
276
+ async function importLocalMcpConfig(strategy, configDir, projectRoot) {
277
+ const warnings = [];
156
278
  // Skip if MCP is not supported for project-local config (e.g., global-only editors)
157
279
  if (!strategy.isSupported() || strategy.isGlobalOnly?.()) {
158
- return { mcp: {}, warnings };
280
+ return { mcp: {}, paths: {}, scopes: {}, warnings };
159
281
  }
160
- try {
161
- const content = await readFile(fullPath, 'utf-8'), result = strategy.parseGlobalMcpConfig(content);
162
- return result;
282
+ for (const fullPath of getLocalMcpImportPaths(strategy, projectRoot, configDir)) {
283
+ try {
284
+ // eslint-disable-next-line no-await-in-loop -- Sequential keeps warning order deterministic
285
+ const content = await readFile(fullPath, 'utf-8'), result = strategy.parseGlobalMcpConfig(content);
286
+ return {
287
+ ...result,
288
+ paths: pathMapForNames(Object.keys(result.mcp), fullPath),
289
+ scopes: scopeMapForNames(Object.keys(result.mcp), 'project'),
290
+ };
291
+ }
292
+ catch (err) {
293
+ if (err.code !== 'ENOENT' &&
294
+ err.code !== 'EISDIR') {
295
+ warnings.push(`Failed to read local MCP config at ${fullPath}: ${err.message}`);
296
+ }
297
+ }
163
298
  }
164
- catch (err) {
165
- if (err.code !== 'ENOENT' &&
166
- err.code !== 'EISDIR') {
167
- warnings.push(`Failed to read local MCP config at ${fullPath}: ${err.message}`);
299
+ return { mcp: {}, paths: {}, scopes: {}, warnings };
300
+ }
301
+ function getGlobalMcpImportPaths(strategy) {
302
+ const configuredPaths = strategy.getGlobalImportPaths?.();
303
+ if (configuredPaths && configuredPaths.length > 0) {
304
+ return configuredPaths.map((path) => buildGlobalPath(path)).filter((path) => Boolean(path));
305
+ }
306
+ const defaultPath = buildGlobalPath(strategy.getGlobalMcpConfigPath());
307
+ return defaultPath ? [defaultPath] : [];
308
+ }
309
+ function getLocalMcpImportPaths(strategy, projectRoot, configDir) {
310
+ const configuredPaths = strategy.getProjectImportPaths?.(projectRoot, configDir);
311
+ if (configuredPaths && configuredPaths.length > 0) {
312
+ return configuredPaths;
313
+ }
314
+ const defaultPath = buildProjectPath(strategy.getConfigPath(), projectRoot, configDir, strategy.isProjectRootConfig?.());
315
+ return defaultPath ? [defaultPath] : [];
316
+ }
317
+ async function importMcpFromPaths(strategy, paths, scope, label) {
318
+ const warnings = [];
319
+ for (const fullPath of paths) {
320
+ try {
321
+ // eslint-disable-next-line no-await-in-loop -- Sequential keeps warning order deterministic
322
+ const content = await readFile(fullPath, 'utf-8'), result = strategy.parseGlobalMcpConfig(content);
323
+ return {
324
+ ...result,
325
+ paths: pathMapForNames(Object.keys(result.mcp), fullPath),
326
+ scopes: scopeMapForNames(Object.keys(result.mcp), scope),
327
+ };
328
+ }
329
+ catch (err) {
330
+ if (err.code !== 'ENOENT' &&
331
+ err.code !== 'EISDIR') {
332
+ warnings.push(`Failed to read ${label} at ${fullPath}: ${err.message}`);
333
+ }
168
334
  }
169
335
  }
170
- return { mcp: {}, warnings };
336
+ return { mcp: {}, paths: {}, scopes: {}, warnings };
171
337
  }
172
338
  /**
173
339
  * Import rules from an editor's global config. Tags each rule with the name 'global'.
174
340
  */
175
- async function importGlobalRules(strategy) {
176
- const warnings = [], rulesPath = strategy.getGlobalRulesPath();
177
- if (!rulesPath) {
178
- return { rules: [], warnings };
341
+ async function importGlobalRules(strategy, _configDir) {
342
+ if (strategy.importGlobalRules) {
343
+ return strategy.importGlobalRules();
344
+ }
345
+ const warnings = [], rulesPath = strategy.getGlobalRulesPath(), rules = [], paths = {}, scopes = {};
346
+ if (rulesPath) {
347
+ const fullPath = join(homedir(), rulesPath);
348
+ try {
349
+ const content = await readFile(fullPath, 'utf-8'), parsed = strategy.parseGlobalRules(content);
350
+ for (const [index, rule] of parsed.rules.entries()) {
351
+ const name = index === 0 ? 'global' : `global-${index + 1}`;
352
+ rules.push({ content: rule, name, path: fullPath, scope: 'user' });
353
+ paths[name] = fullPath;
354
+ scopes[name] = 'user';
355
+ }
356
+ warnings.push(...parsed.warnings);
357
+ }
358
+ catch (err) {
359
+ if (err.code !== 'ENOENT') {
360
+ warnings.push(`Failed to read global rules from ${fullPath}: ${err.message}`);
361
+ }
362
+ }
363
+ }
364
+ const ruleDirs = strategy.getGlobalRuleImportDirs?.() ?? [];
365
+ for (const ruleDir of ruleDirs) {
366
+ const fullPath = join(homedir(), ruleDir);
367
+ try {
368
+ // eslint-disable-next-line no-await-in-loop -- Sequential keeps warning order deterministic
369
+ const files = await readdir(fullPath), ext = strategy.getFileExtension(), ruleFiles = files.filter((file) => file.endsWith(ext)).toSorted();
370
+ for (const file of ruleFiles) {
371
+ const path = join(fullPath, file), name = file.slice(0, -ext.length);
372
+ // eslint-disable-next-line no-await-in-loop -- Sequential keeps warning order deterministic
373
+ const rule = await readGlobalRuleFile(path, name, warnings);
374
+ if (rule) {
375
+ rules.push(rule);
376
+ paths[name] = path;
377
+ scopes[name] = 'user';
378
+ }
379
+ }
380
+ }
381
+ catch (err) {
382
+ if (err.code !== 'ENOENT') {
383
+ warnings.push(`Failed to read global rules from ${fullPath}: ${err.message}`);
384
+ }
385
+ }
179
386
  }
180
- const fullPath = join(homedir(), rulesPath);
387
+ return { rules, paths, scopes, warnings };
388
+ }
389
+ async function readGlobalRuleFile(path, name, warnings) {
181
390
  try {
182
- const content = await readFile(fullPath, 'utf-8'), parsed = strategy.parseGlobalRules(content);
183
- return {
184
- rules: parsed.rules.map((r) => ({ content: r, name: 'global' })),
185
- warnings: parsed.warnings,
186
- };
391
+ const content = await readFile(path, 'utf-8'), trimmed = content.trim();
392
+ if (!trimmed) {
393
+ return undefined;
394
+ }
395
+ return { content: trimmed, name, path, scope: 'user' };
187
396
  }
188
397
  catch (err) {
189
- if (err.code !== 'ENOENT') {
190
- warnings.push(`Failed to read global rules from ${fullPath}: ${err.message}`);
191
- }
398
+ warnings.push(`Failed to read global rule ${path}: ${err.message}`);
399
+ return undefined;
192
400
  }
193
- return { rules: [], warnings };
194
401
  }
195
402
  /**
196
403
  * Import rules from project-local editor config. Tags each rule with its filename (sans extension).
197
404
  */
198
- async function importLocalRules(strategy, editor, projectRoot) {
199
- // Codex uses AGENTS.md at the project root (not inside .codex/), so use a dedicated reader
200
- if (editor === 'codex') {
201
- return importCodexLocalRules(projectRoot);
405
+ async function importLocalRules(strategy, configDir, projectRoot) {
406
+ if (strategy.importProjectRules) {
407
+ return strategy.importProjectRules(projectRoot, configDir);
202
408
  }
203
- const warnings = [], configDir = EDITOR_CONFIG_DIRS[editor], rulesDir = strategy.getRulesDir(), fullPath = join(projectRoot, configDir, rulesDir);
409
+ const warnings = [], rulesDir = strategy.getRulesDir(), fullPath = join(projectRoot, configDir, rulesDir);
204
410
  try {
205
- const files = await readdir(fullPath), ext = strategy.getFileExtension(), ruleFiles = files.filter((f) => f.endsWith(ext)), rules = [];
411
+ const files = await readdir(fullPath), ext = strategy.getFileExtension(), ruleFiles = files.filter((f) => f.endsWith(ext)), rules = [], paths = {}, scopes = {};
206
412
  for (const file of ruleFiles) {
207
413
  try {
414
+ const path = join(fullPath, file);
208
415
  // eslint-disable-next-line no-await-in-loop -- Sequential for simplicity
209
- const content = await readFile(join(fullPath, file), 'utf-8'), name = file.endsWith(ext) ? file.slice(0, -ext.length) : file;
210
- rules.push({ content, name });
416
+ const content = await readFile(path, 'utf-8'), name = file.endsWith(ext) ? file.slice(0, -ext.length) : file;
417
+ rules.push({ content, name, path, scope: 'project' });
418
+ paths[name] = path;
419
+ scopes[name] = 'project';
211
420
  }
212
421
  catch {
213
422
  // Skip files that can't be read
214
423
  }
215
424
  }
216
- return { rules, warnings };
425
+ return { rules, paths, scopes, warnings };
217
426
  }
218
427
  catch (err) {
219
428
  if (err.code !== 'ENOENT') {
220
429
  warnings.push(`Failed to read local rules from ${fullPath}: ${err.message}`);
221
430
  }
222
431
  }
223
- return { rules: [], warnings };
224
- }
225
- /**
226
- * Import Codex rules from AGENTS.md at the project root. Codex discovers one AGENTS.md per
227
- * directory from root→CWD, so we read the root file and tag it accordingly.
228
- */
229
- async function importCodexLocalRules(projectRoot) {
230
- const warnings = [], agentsPath = join(projectRoot, 'AGENTS.md');
231
- try {
232
- const content = await readFile(agentsPath, 'utf-8');
233
- if (content.trim()) {
234
- return { rules: [{ content: content.trim(), name: 'AGENTS' }], warnings };
235
- }
236
- }
237
- catch (err) {
238
- if (err.code !== 'ENOENT') {
239
- warnings.push(`Failed to read Codex rules from ${agentsPath}: ${err.message}`);
240
- }
241
- }
242
- return { rules: [], warnings };
432
+ return { rules: [], paths: {}, scopes: {}, warnings };
243
433
  }
244
434
  /**
245
435
  * Import prompts/workflows from an editor's global config.
246
436
  */
247
- async function importPrompts(strategy, _source) {
437
+ async function importPrompts(strategy, _configDir, _source) {
438
+ if (strategy.importGlobalPrompts) {
439
+ return strategy.importGlobalPrompts();
440
+ }
248
441
  const warnings = [], promptsPath = strategy.getGlobalPromptsPath();
249
442
  if (!promptsPath) {
250
- return { prompts: {}, warnings };
443
+ return { prompts: {}, paths: {}, scopes: {}, warnings };
251
444
  }
252
445
  const fullPath = join(homedir(), promptsPath);
253
446
  try {
254
447
  const files = await readdir(fullPath), fileReader = async (filename) => {
255
448
  return readFile(join(fullPath, filename), 'utf-8');
449
+ }, result = await strategy.parseGlobalPrompts(files, fileReader);
450
+ const imported = {
451
+ ...result,
452
+ paths: promptPathMap(Object.keys(result.prompts), files, fullPath),
453
+ scopes: scopeMapForNames(Object.keys(result.prompts), 'user'),
256
454
  };
257
- return strategy.parseGlobalPrompts(files, fileReader);
455
+ return imported;
258
456
  }
259
457
  catch (err) {
260
458
  if (err.code !== 'ENOENT') {
261
459
  warnings.push(`Failed to read global prompts from ${fullPath}: ${err.message}`);
262
460
  }
263
461
  }
264
- return { prompts: {}, warnings };
462
+ return { prompts: {}, paths: {}, scopes: {}, warnings };
265
463
  }
266
464
  /**
267
465
  * Import prompts/workflows from project-local editor config.
268
466
  */
269
- async function importLocalPrompts(strategy, editor, projectRoot) {
270
- const warnings = [], configDir = EDITOR_CONFIG_DIRS[editor], promptsDir = strategy.getPromptsDir(), fullPath = join(projectRoot, configDir, promptsDir);
467
+ async function importLocalPrompts(strategy, configDir, projectRoot) {
468
+ if (strategy.importProjectPrompts) {
469
+ return strategy.importProjectPrompts(projectRoot, configDir);
470
+ }
471
+ const warnings = [], promptsDir = strategy.getPromptsDir(), fullPath = join(projectRoot, configDir, promptsDir);
271
472
  if (!strategy.isSupported()) {
272
- return { prompts: {}, warnings };
473
+ return { prompts: {}, paths: {}, scopes: {}, warnings };
273
474
  }
274
475
  try {
275
476
  const files = await readdir(fullPath), fileReader = async (filename) => {
276
477
  return readFile(join(fullPath, filename), 'utf-8');
478
+ }, result = await strategy.parseGlobalPrompts(files, fileReader);
479
+ const imported = {
480
+ ...result,
481
+ paths: promptPathMap(Object.keys(result.prompts), files, fullPath),
482
+ scopes: scopeMapForNames(Object.keys(result.prompts), 'project'),
277
483
  };
278
- return strategy.parseGlobalPrompts(files, fileReader);
484
+ return imported;
279
485
  }
280
486
  catch (err) {
281
487
  if (err.code !== 'ENOENT') {
282
488
  warnings.push(`Failed to read local prompts from ${fullPath}: ${err.message}`);
283
489
  }
284
490
  }
285
- return { prompts: {}, warnings };
491
+ return { prompts: {}, paths: {}, scopes: {}, warnings };
492
+ }
493
+ async function importSkills(strategy, source, projectRoot) {
494
+ const warnings = [], skills = {}, paths = {}, scopes = {}, skillDirs = source === 'user' ? strategy.getGlobalImportDirs() : strategy.getProjectImportDirs(), root = source === 'user' ? homedir() : projectRoot;
495
+ for (const skillDir of skillDirs) {
496
+ const fullPath = join(root, skillDir);
497
+ try {
498
+ // eslint-disable-next-line no-await-in-loop -- Sequential keeps warning order deterministic
499
+ const entries = await readdir(fullPath, { withFileTypes: true });
500
+ for (const entry of entries) {
501
+ if (!entry.isDirectory() && !entry.isSymbolicLink()) {
502
+ continue;
503
+ }
504
+ const path = join(fullPath, entry.name);
505
+ if (!existsSync(join(path, 'SKILL.md'))) {
506
+ continue;
507
+ }
508
+ skills[entry.name] = path;
509
+ paths[entry.name] = path;
510
+ scopes[entry.name] = source;
511
+ }
512
+ }
513
+ catch (err) {
514
+ if (err.code !== 'ENOENT') {
515
+ warnings.push(`Failed to read skills from ${fullPath}: ${err.message}`);
516
+ }
517
+ }
518
+ }
519
+ return { skills, paths, scopes, warnings };
520
+ }
521
+ function pathMapForNames(names, path) {
522
+ return Object.fromEntries(names.map((name) => [name, path]));
523
+ }
524
+ function scopeMapForNames(names, scope) {
525
+ return Object.fromEntries(names.map((name) => [name, scope]));
526
+ }
527
+ function promptPathMap(names, files, basePath) {
528
+ const fileByName = new Map(files.map((file) => [file.replace(/\.md$/, ''), file]));
529
+ return Object.fromEntries(names.flatMap((name) => {
530
+ const file = fileByName.get(name);
531
+ return file ? [[name, join(basePath, file)]] : [];
532
+ }));
286
533
  }
287
534
  /**
288
535
  * Get the global config path for an editor.
289
536
  */
290
537
  export function getGlobalConfigPath(editor) {
291
- const strategies = getImportStrategies(editor), configPath = strategies.mcp.getGlobalMcpConfigPath();
292
- if (!configPath) {
293
- return null;
294
- }
295
- return join(homedir(), configPath);
538
+ return buildGlobalPath(getAdapter(editor).getStrategyBundle().mcpStrategy.getGlobalMcpConfigPath());
296
539
  }
297
540
  //# sourceMappingURL=import.js.map