@agentmemory/agentmemory 0.9.29 → 0.9.31

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 (352) hide show
  1. package/.env.example +102 -35
  2. package/AGENTS.md +19 -26
  3. package/README.md +417 -525
  4. package/dist/.env.example +102 -35
  5. package/dist/cli.d.mts.map +1 -1
  6. package/dist/cli.mjs +2316 -655
  7. package/dist/cli.mjs.map +1 -1
  8. package/dist/compression-recovery-CnhLQC6N.mjs +5912 -0
  9. package/dist/compression-recovery-CnhLQC6N.mjs.map +1 -0
  10. package/dist/{connect-Qaeq15TQ.mjs → connect-BSLIAMpw.mjs} +900 -302
  11. package/dist/connect-BSLIAMpw.mjs.map +1 -0
  12. package/dist/hooks/_capture.d.mts +25 -0
  13. package/dist/hooks/_capture.d.mts.map +1 -0
  14. package/dist/hooks/_capture.mjs +944 -0
  15. package/dist/hooks/_capture.mjs.map +1 -0
  16. package/dist/hooks/antigravity-bridge.d.mts +1 -1
  17. package/dist/hooks/antigravity-bridge.d.mts.map +1 -1
  18. package/dist/hooks/antigravity-bridge.mjs +24 -15
  19. package/dist/hooks/antigravity-bridge.mjs.map +1 -1
  20. package/dist/hooks/notification.mjs +35 -29
  21. package/dist/hooks/notification.mjs.map +1 -1
  22. package/dist/hooks/post-commit.mjs +91 -1
  23. package/dist/hooks/post-commit.mjs.map +1 -1
  24. package/dist/hooks/post-tool-failure.mjs +71 -29
  25. package/dist/hooks/post-tool-failure.mjs.map +1 -1
  26. package/dist/hooks/post-tool-use.mjs +99 -39
  27. package/dist/hooks/post-tool-use.mjs.map +1 -1
  28. package/dist/hooks/pre-compact.mjs +113 -6
  29. package/dist/hooks/pre-compact.mjs.map +1 -1
  30. package/dist/hooks/pre-tool-use.mjs +91 -1
  31. package/dist/hooks/pre-tool-use.mjs.map +1 -1
  32. package/dist/hooks/prompt-submit.mjs +25 -25
  33. package/dist/hooks/prompt-submit.mjs.map +1 -1
  34. package/dist/hooks/session-end.mjs +67 -31
  35. package/dist/hooks/session-end.mjs.map +1 -1
  36. package/dist/hooks/session-start.mjs +110 -6
  37. package/dist/hooks/session-start.mjs.map +1 -1
  38. package/dist/hooks/stop.mjs +80 -8
  39. package/dist/hooks/stop.mjs.map +1 -1
  40. package/dist/hooks/subagent-start.mjs +28 -29
  41. package/dist/hooks/subagent-start.mjs.map +1 -1
  42. package/dist/hooks/subagent-stop.mjs +33 -29
  43. package/dist/hooks/subagent-stop.mjs.map +1 -1
  44. package/dist/hooks/task-completed.mjs +31 -31
  45. package/dist/hooks/task-completed.mjs.map +1 -1
  46. package/dist/{image-refs-BKLmp_sD.mjs → image-refs-BaT-9oMU.mjs} +2 -2
  47. package/dist/image-refs-BaT-9oMU.mjs.map +1 -0
  48. package/dist/{image-refs-CJgZmb9X.mjs → image-refs-Cyta4Lf9.mjs} +3 -3
  49. package/dist/image-refs-Cyta4Lf9.mjs.map +1 -0
  50. package/dist/{keyed-mutex-DTHtcZrt.mjs → image-store-BsN4vyjr.mjs} +2 -14
  51. package/dist/image-store-BsN4vyjr.mjs.map +1 -0
  52. package/dist/index.mjs +15180 -4119
  53. package/dist/index.mjs.map +1 -1
  54. package/dist/integrations/dsh.d.mts +55 -0
  55. package/dist/integrations/dsh.d.mts.map +1 -0
  56. package/dist/integrations/dsh.mjs +1145 -0
  57. package/dist/integrations/dsh.mjs.map +1 -0
  58. package/dist/{schema-BFZhNTF7.mjs → keyed-mutex-DCUh7PG-.mjs} +81 -8
  59. package/dist/keyed-mutex-DCUh7PG-.mjs.map +1 -0
  60. package/dist/secret-store-D9GwO0xp.mjs +2449 -0
  61. package/dist/secret-store-D9GwO0xp.mjs.map +1 -0
  62. package/dist/session-arguments-zxsbbd8y.mjs +113 -0
  63. package/dist/session-arguments-zxsbbd8y.mjs.map +1 -0
  64. package/dist/{src-G7yt8gGm.mjs → src-DaMtDzt_.mjs} +8320 -4260
  65. package/dist/src-DaMtDzt_.mjs.map +1 -0
  66. package/dist/{standalone-BqNJDJ04.mjs → standalone-BlqshyZ5.mjs} +246 -62
  67. package/dist/standalone-BlqshyZ5.mjs.map +1 -0
  68. package/dist/standalone.d.mts +1 -1
  69. package/dist/standalone.d.mts.map +1 -1
  70. package/dist/standalone.mjs +866 -78
  71. package/dist/standalone.mjs.map +1 -1
  72. package/dist/viewer/index.html +7394 -2816
  73. package/integrations/hermes/README.md +84 -0
  74. package/integrations/hermes/__init__.py +669 -0
  75. package/integrations/hermes/plugin.yaml +27 -0
  76. package/integrations/omp/LICENSE +190 -0
  77. package/integrations/omp/README.md +76 -0
  78. package/integrations/omp/capture.ts +1 -0
  79. package/integrations/omp/dist/index.mjs +1450 -0
  80. package/integrations/omp/index.ts +488 -0
  81. package/integrations/omp/package.json +13 -0
  82. package/integrations/omp/security.ts +67 -0
  83. package/integrations/omp/skills/agentmemory-agents/REFERENCE.md +32 -0
  84. package/integrations/omp/skills/agentmemory-agents/SKILL.md +48 -0
  85. package/integrations/omp/skills/agentmemory-agents/TROUBLESHOOTING.md +70 -0
  86. package/integrations/omp/skills/agentmemory-architecture/SKILL.md +33 -0
  87. package/integrations/omp/skills/agentmemory-architecture/TROUBLESHOOTING.md +70 -0
  88. package/integrations/omp/skills/agentmemory-config/REFERENCE.md +90 -0
  89. package/integrations/omp/skills/agentmemory-config/SKILL.md +78 -0
  90. package/integrations/omp/skills/agentmemory-config/TROUBLESHOOTING.md +70 -0
  91. package/integrations/omp/skills/agentmemory-hooks/REFERENCE.md +20 -0
  92. package/integrations/omp/skills/agentmemory-hooks/SKILL.md +49 -0
  93. package/integrations/omp/skills/agentmemory-hooks/TROUBLESHOOTING.md +70 -0
  94. package/integrations/omp/skills/agentmemory-mcp-tools/REFERENCE.md +66 -0
  95. package/integrations/omp/skills/agentmemory-mcp-tools/SKILL.md +42 -0
  96. package/integrations/omp/skills/agentmemory-mcp-tools/TROUBLESHOOTING.md +70 -0
  97. package/integrations/omp/skills/agentmemory-rest-api/REFERENCE.md +158 -0
  98. package/integrations/omp/skills/agentmemory-rest-api/SKILL.md +49 -0
  99. package/integrations/omp/skills/agentmemory-rest-api/TROUBLESHOOTING.md +70 -0
  100. package/integrations/omp/skills/commit-context/EXAMPLES.md +71 -0
  101. package/integrations/omp/skills/commit-context/SKILL.md +64 -0
  102. package/integrations/omp/skills/commit-context/TROUBLESHOOTING.md +70 -0
  103. package/integrations/omp/skills/commit-history/EXAMPLES.md +71 -0
  104. package/integrations/omp/skills/commit-history/SKILL.md +62 -0
  105. package/integrations/omp/skills/commit-history/TROUBLESHOOTING.md +70 -0
  106. package/integrations/omp/skills/forget/EXAMPLES.md +40 -0
  107. package/integrations/omp/skills/forget/SKILL.md +73 -0
  108. package/integrations/omp/skills/forget/TROUBLESHOOTING.md +70 -0
  109. package/integrations/omp/skills/handoff/EXAMPLES.md +57 -0
  110. package/integrations/omp/skills/handoff/SKILL.md +75 -0
  111. package/integrations/omp/skills/handoff/TROUBLESHOOTING.md +70 -0
  112. package/integrations/omp/skills/lesson/SKILL.md +64 -0
  113. package/integrations/omp/skills/lesson/TROUBLESHOOTING.md +70 -0
  114. package/integrations/omp/skills/memory-discipline/SKILL.md +65 -0
  115. package/integrations/omp/skills/memory-discipline/TROUBLESHOOTING.md +70 -0
  116. package/integrations/omp/skills/recall/EXAMPLES.md +74 -0
  117. package/integrations/omp/skills/recall/SKILL.md +74 -0
  118. package/integrations/omp/skills/recall/TROUBLESHOOTING.md +70 -0
  119. package/integrations/omp/skills/recap/EXAMPLES.md +62 -0
  120. package/integrations/omp/skills/recap/SKILL.md +68 -0
  121. package/integrations/omp/skills/recap/TROUBLESHOOTING.md +70 -0
  122. package/integrations/omp/skills/remember/EXAMPLES.md +67 -0
  123. package/integrations/omp/skills/remember/SKILL.md +66 -0
  124. package/integrations/omp/skills/remember/TROUBLESHOOTING.md +70 -0
  125. package/integrations/omp/skills/session-history/EXAMPLES.md +59 -0
  126. package/integrations/omp/skills/session-history/SKILL.md +67 -0
  127. package/integrations/omp/skills/session-history/TROUBLESHOOTING.md +70 -0
  128. package/integrations/omp/skills/write-agentmemory-skill/SKILL.md +41 -0
  129. package/integrations/omp/skills/write-agentmemory-skill/TROUBLESHOOTING.md +70 -0
  130. package/integrations/openclaw/LICENSE +190 -0
  131. package/integrations/openclaw/README.md +88 -0
  132. package/integrations/openclaw/openclaw.plugin.json +71 -0
  133. package/integrations/openclaw/package.json +38 -0
  134. package/integrations/openclaw/plugin.mjs +425 -0
  135. package/integrations/openclaw/plugin.yaml +26 -0
  136. package/integrations/openclaw/skills/agentmemory-agents/REFERENCE.md +32 -0
  137. package/integrations/openclaw/skills/agentmemory-agents/SKILL.md +48 -0
  138. package/integrations/openclaw/skills/agentmemory-agents/TROUBLESHOOTING.md +70 -0
  139. package/integrations/openclaw/skills/agentmemory-architecture/SKILL.md +33 -0
  140. package/integrations/openclaw/skills/agentmemory-architecture/TROUBLESHOOTING.md +70 -0
  141. package/integrations/openclaw/skills/agentmemory-config/REFERENCE.md +90 -0
  142. package/integrations/openclaw/skills/agentmemory-config/SKILL.md +78 -0
  143. package/integrations/openclaw/skills/agentmemory-config/TROUBLESHOOTING.md +70 -0
  144. package/integrations/openclaw/skills/agentmemory-hooks/REFERENCE.md +20 -0
  145. package/integrations/openclaw/skills/agentmemory-hooks/SKILL.md +49 -0
  146. package/integrations/openclaw/skills/agentmemory-hooks/TROUBLESHOOTING.md +70 -0
  147. package/integrations/openclaw/skills/agentmemory-mcp-tools/REFERENCE.md +66 -0
  148. package/integrations/openclaw/skills/agentmemory-mcp-tools/SKILL.md +42 -0
  149. package/integrations/openclaw/skills/agentmemory-mcp-tools/TROUBLESHOOTING.md +70 -0
  150. package/integrations/openclaw/skills/agentmemory-rest-api/REFERENCE.md +158 -0
  151. package/integrations/openclaw/skills/agentmemory-rest-api/SKILL.md +49 -0
  152. package/integrations/openclaw/skills/agentmemory-rest-api/TROUBLESHOOTING.md +70 -0
  153. package/integrations/openclaw/skills/commit-context/EXAMPLES.md +71 -0
  154. package/integrations/openclaw/skills/commit-context/SKILL.md +64 -0
  155. package/integrations/openclaw/skills/commit-context/TROUBLESHOOTING.md +70 -0
  156. package/integrations/openclaw/skills/commit-history/EXAMPLES.md +71 -0
  157. package/integrations/openclaw/skills/commit-history/SKILL.md +62 -0
  158. package/integrations/openclaw/skills/commit-history/TROUBLESHOOTING.md +70 -0
  159. package/integrations/openclaw/skills/forget/EXAMPLES.md +40 -0
  160. package/integrations/openclaw/skills/forget/SKILL.md +73 -0
  161. package/integrations/openclaw/skills/forget/TROUBLESHOOTING.md +70 -0
  162. package/integrations/openclaw/skills/handoff/EXAMPLES.md +57 -0
  163. package/integrations/openclaw/skills/handoff/SKILL.md +75 -0
  164. package/integrations/openclaw/skills/handoff/TROUBLESHOOTING.md +70 -0
  165. package/integrations/openclaw/skills/lesson/SKILL.md +64 -0
  166. package/integrations/openclaw/skills/lesson/TROUBLESHOOTING.md +70 -0
  167. package/integrations/openclaw/skills/memory-discipline/SKILL.md +65 -0
  168. package/integrations/openclaw/skills/memory-discipline/TROUBLESHOOTING.md +70 -0
  169. package/integrations/openclaw/skills/recall/EXAMPLES.md +74 -0
  170. package/integrations/openclaw/skills/recall/SKILL.md +74 -0
  171. package/integrations/openclaw/skills/recall/TROUBLESHOOTING.md +70 -0
  172. package/integrations/openclaw/skills/recap/EXAMPLES.md +62 -0
  173. package/integrations/openclaw/skills/recap/SKILL.md +68 -0
  174. package/integrations/openclaw/skills/recap/TROUBLESHOOTING.md +70 -0
  175. package/integrations/openclaw/skills/remember/EXAMPLES.md +67 -0
  176. package/integrations/openclaw/skills/remember/SKILL.md +66 -0
  177. package/integrations/openclaw/skills/remember/TROUBLESHOOTING.md +70 -0
  178. package/integrations/openclaw/skills/session-history/EXAMPLES.md +59 -0
  179. package/integrations/openclaw/skills/session-history/SKILL.md +67 -0
  180. package/integrations/openclaw/skills/session-history/TROUBLESHOOTING.md +70 -0
  181. package/integrations/openclaw/skills/write-agentmemory-skill/SKILL.md +41 -0
  182. package/integrations/openclaw/skills/write-agentmemory-skill/TROUBLESHOOTING.md +70 -0
  183. package/integrations/pi/LICENSE +190 -0
  184. package/integrations/pi/README.md +45 -51
  185. package/integrations/pi/dist/index.mjs +1379 -0
  186. package/integrations/pi/index.ts +139 -173
  187. package/integrations/pi/package.json +16 -6
  188. package/integrations/pi/security.ts +54 -22
  189. package/integrations/pi/skills/agentmemory-agents/REFERENCE.md +32 -0
  190. package/integrations/pi/skills/agentmemory-agents/SKILL.md +48 -0
  191. package/integrations/pi/skills/agentmemory-agents/TROUBLESHOOTING.md +70 -0
  192. package/integrations/pi/skills/agentmemory-architecture/SKILL.md +33 -0
  193. package/integrations/pi/skills/agentmemory-architecture/TROUBLESHOOTING.md +70 -0
  194. package/integrations/pi/skills/agentmemory-config/REFERENCE.md +90 -0
  195. package/integrations/pi/skills/agentmemory-config/SKILL.md +78 -0
  196. package/integrations/pi/skills/agentmemory-config/TROUBLESHOOTING.md +70 -0
  197. package/integrations/pi/skills/agentmemory-hooks/REFERENCE.md +20 -0
  198. package/integrations/pi/skills/agentmemory-hooks/SKILL.md +49 -0
  199. package/integrations/pi/skills/agentmemory-hooks/TROUBLESHOOTING.md +70 -0
  200. package/integrations/pi/skills/agentmemory-mcp-tools/REFERENCE.md +66 -0
  201. package/integrations/pi/skills/agentmemory-mcp-tools/SKILL.md +42 -0
  202. package/integrations/pi/skills/agentmemory-mcp-tools/TROUBLESHOOTING.md +70 -0
  203. package/integrations/pi/skills/agentmemory-rest-api/REFERENCE.md +158 -0
  204. package/integrations/pi/skills/agentmemory-rest-api/SKILL.md +49 -0
  205. package/integrations/pi/skills/agentmemory-rest-api/TROUBLESHOOTING.md +70 -0
  206. package/integrations/pi/skills/commit-context/EXAMPLES.md +71 -0
  207. package/integrations/pi/skills/commit-context/SKILL.md +64 -0
  208. package/integrations/pi/skills/commit-context/TROUBLESHOOTING.md +70 -0
  209. package/integrations/pi/skills/commit-history/EXAMPLES.md +71 -0
  210. package/integrations/pi/skills/commit-history/SKILL.md +62 -0
  211. package/integrations/pi/skills/commit-history/TROUBLESHOOTING.md +70 -0
  212. package/integrations/pi/skills/forget/EXAMPLES.md +40 -0
  213. package/integrations/pi/skills/forget/SKILL.md +73 -0
  214. package/integrations/pi/skills/forget/TROUBLESHOOTING.md +70 -0
  215. package/integrations/pi/skills/handoff/EXAMPLES.md +57 -0
  216. package/integrations/pi/skills/handoff/SKILL.md +75 -0
  217. package/integrations/pi/skills/handoff/TROUBLESHOOTING.md +70 -0
  218. package/integrations/pi/skills/lesson/SKILL.md +64 -0
  219. package/integrations/pi/skills/lesson/TROUBLESHOOTING.md +70 -0
  220. package/integrations/pi/skills/memory-discipline/SKILL.md +65 -0
  221. package/integrations/pi/skills/memory-discipline/TROUBLESHOOTING.md +70 -0
  222. package/integrations/pi/skills/recall/EXAMPLES.md +74 -0
  223. package/integrations/pi/skills/recall/SKILL.md +74 -0
  224. package/integrations/pi/skills/recall/TROUBLESHOOTING.md +70 -0
  225. package/integrations/pi/skills/recap/EXAMPLES.md +62 -0
  226. package/integrations/pi/skills/recap/SKILL.md +68 -0
  227. package/integrations/pi/skills/recap/TROUBLESHOOTING.md +70 -0
  228. package/integrations/pi/skills/remember/EXAMPLES.md +67 -0
  229. package/integrations/pi/skills/remember/SKILL.md +66 -0
  230. package/integrations/pi/skills/remember/TROUBLESHOOTING.md +70 -0
  231. package/integrations/pi/skills/session-history/EXAMPLES.md +59 -0
  232. package/integrations/pi/skills/session-history/SKILL.md +67 -0
  233. package/integrations/pi/skills/session-history/TROUBLESHOOTING.md +70 -0
  234. package/integrations/pi/skills/write-agentmemory-skill/SKILL.md +41 -0
  235. package/integrations/pi/skills/write-agentmemory-skill/TROUBLESHOOTING.md +70 -0
  236. package/package.json +42 -12
  237. package/plugin/.claude-plugin/plugin.json +2 -2
  238. package/plugin/.codex-plugin/plugin.json +27 -4
  239. package/plugin/.devin-plugin/plugin.json +5 -3
  240. package/plugin/.mcp.codex.json +12 -0
  241. package/plugin/.mcp.copilot.json +2 -7
  242. package/plugin/.mcp.json +2 -7
  243. package/plugin/assets/icon.svg +35 -0
  244. package/plugin/cursor/hooks.json +23 -8
  245. package/plugin/hooks/hooks.copilot.json +11 -11
  246. package/plugin/hooks.json +67 -0
  247. package/plugin/opencode/README.md +267 -31
  248. package/plugin/opencode/agentmemory-capture.ts +594 -11
  249. package/plugin/opencode/plugin.json +1 -1
  250. package/plugin/plugin.json +1 -1
  251. package/plugin/scripts/_capture.d.mts +25 -0
  252. package/plugin/scripts/_capture.d.mts.map +1 -0
  253. package/plugin/scripts/_capture.mjs +944 -0
  254. package/plugin/scripts/_capture.mjs.map +1 -0
  255. package/plugin/scripts/antigravity-bridge.d.mts +1 -1
  256. package/plugin/scripts/antigravity-bridge.d.mts.map +1 -1
  257. package/plugin/scripts/antigravity-bridge.mjs +24 -15
  258. package/plugin/scripts/antigravity-bridge.mjs.map +1 -1
  259. package/plugin/scripts/cursor/run-detached.d.mts +1 -0
  260. package/plugin/scripts/cursor/run-detached.mjs +786 -0
  261. package/plugin/scripts/cursor/run-detached.mjs.map +1 -0
  262. package/plugin/scripts/cursor/run-hook.d.mts +1 -0
  263. package/plugin/scripts/cursor/run-hook.mjs +704 -0
  264. package/plugin/scripts/cursor/run-hook.mjs.map +1 -0
  265. package/plugin/scripts/notification.mjs +35 -29
  266. package/plugin/scripts/notification.mjs.map +1 -1
  267. package/plugin/scripts/plugin-bridge.mjs +409 -0
  268. package/plugin/scripts/post-commit.mjs +91 -1
  269. package/plugin/scripts/post-commit.mjs.map +1 -1
  270. package/plugin/scripts/post-tool-failure.mjs +71 -29
  271. package/plugin/scripts/post-tool-failure.mjs.map +1 -1
  272. package/plugin/scripts/post-tool-use.mjs +99 -39
  273. package/plugin/scripts/post-tool-use.mjs.map +1 -1
  274. package/plugin/scripts/pre-compact.mjs +113 -6
  275. package/plugin/scripts/pre-compact.mjs.map +1 -1
  276. package/plugin/scripts/pre-tool-use.mjs +91 -1
  277. package/plugin/scripts/pre-tool-use.mjs.map +1 -1
  278. package/plugin/scripts/prompt-submit.mjs +25 -25
  279. package/plugin/scripts/prompt-submit.mjs.map +1 -1
  280. package/plugin/scripts/session-end.mjs +67 -31
  281. package/plugin/scripts/session-end.mjs.map +1 -1
  282. package/plugin/scripts/session-start.mjs +110 -6
  283. package/plugin/scripts/session-start.mjs.map +1 -1
  284. package/plugin/scripts/stop.mjs +80 -8
  285. package/plugin/scripts/stop.mjs.map +1 -1
  286. package/plugin/scripts/subagent-start.mjs +28 -29
  287. package/plugin/scripts/subagent-start.mjs.map +1 -1
  288. package/plugin/scripts/subagent-stop.mjs +33 -29
  289. package/plugin/scripts/subagent-stop.mjs.map +1 -1
  290. package/plugin/scripts/task-completed.mjs +31 -31
  291. package/plugin/scripts/task-completed.mjs.map +1 -1
  292. package/plugin/skills/_shared/TROUBLESHOOTING.md +42 -12
  293. package/plugin/skills/agentmemory-agents/REFERENCE.md +10 -9
  294. package/plugin/skills/agentmemory-agents/SKILL.md +19 -5
  295. package/plugin/skills/agentmemory-agents/TROUBLESHOOTING.md +70 -0
  296. package/plugin/skills/agentmemory-architecture/SKILL.md +4 -4
  297. package/plugin/skills/agentmemory-architecture/TROUBLESHOOTING.md +70 -0
  298. package/plugin/skills/agentmemory-config/REFERENCE.md +48 -3
  299. package/plugin/skills/agentmemory-config/SKILL.md +51 -10
  300. package/plugin/skills/agentmemory-config/TROUBLESHOOTING.md +70 -0
  301. package/plugin/skills/agentmemory-hooks/SKILL.md +15 -5
  302. package/plugin/skills/agentmemory-hooks/TROUBLESHOOTING.md +70 -0
  303. package/plugin/skills/agentmemory-mcp-tools/REFERENCE.md +5 -5
  304. package/plugin/skills/agentmemory-mcp-tools/SKILL.md +6 -3
  305. package/plugin/skills/agentmemory-mcp-tools/TROUBLESHOOTING.md +70 -0
  306. package/plugin/skills/agentmemory-rest-api/REFERENCE.md +18 -2
  307. package/plugin/skills/agentmemory-rest-api/SKILL.md +12 -6
  308. package/plugin/skills/agentmemory-rest-api/TROUBLESHOOTING.md +70 -0
  309. package/plugin/skills/commit-context/SKILL.md +1 -1
  310. package/plugin/skills/commit-context/TROUBLESHOOTING.md +70 -0
  311. package/plugin/skills/commit-history/SKILL.md +1 -1
  312. package/plugin/skills/commit-history/TROUBLESHOOTING.md +70 -0
  313. package/plugin/skills/forget/EXAMPLES.md +19 -54
  314. package/plugin/skills/forget/SKILL.md +16 -12
  315. package/plugin/skills/forget/TROUBLESHOOTING.md +70 -0
  316. package/plugin/skills/handoff/EXAMPLES.md +5 -4
  317. package/plugin/skills/handoff/SKILL.md +13 -6
  318. package/plugin/skills/handoff/TROUBLESHOOTING.md +70 -0
  319. package/plugin/skills/lesson/SKILL.md +1 -1
  320. package/plugin/skills/lesson/TROUBLESHOOTING.md +70 -0
  321. package/plugin/skills/memory-discipline/SKILL.md +14 -6
  322. package/plugin/skills/memory-discipline/TROUBLESHOOTING.md +70 -0
  323. package/plugin/skills/recall/SKILL.md +18 -7
  324. package/plugin/skills/recall/TROUBLESHOOTING.md +70 -0
  325. package/plugin/skills/recap/EXAMPLES.md +5 -3
  326. package/plugin/skills/recap/SKILL.md +11 -6
  327. package/plugin/skills/recap/TROUBLESHOOTING.md +70 -0
  328. package/plugin/skills/remember/EXAMPLES.md +3 -3
  329. package/plugin/skills/remember/SKILL.md +1 -1
  330. package/plugin/skills/remember/TROUBLESHOOTING.md +70 -0
  331. package/plugin/skills/session-history/EXAMPLES.md +2 -2
  332. package/plugin/skills/session-history/SKILL.md +10 -4
  333. package/plugin/skills/session-history/TROUBLESHOOTING.md +70 -0
  334. package/plugin/skills/write-agentmemory-skill/SKILL.md +2 -1
  335. package/plugin/skills/write-agentmemory-skill/TROUBLESHOOTING.md +70 -0
  336. package/dist/connect-Qaeq15TQ.mjs.map +0 -1
  337. package/dist/docker-compose.yml +0 -47
  338. package/dist/iii-config.docker.yaml +0 -53
  339. package/dist/iii-config.yaml +0 -61
  340. package/dist/image-refs-BKLmp_sD.mjs.map +0 -1
  341. package/dist/image-refs-CJgZmb9X.mjs.map +0 -1
  342. package/dist/keyed-mutex-DTHtcZrt.mjs.map +0 -1
  343. package/dist/logger-BEB7pCI9.mjs +0 -43
  344. package/dist/logger-BEB7pCI9.mjs.map +0 -1
  345. package/dist/schema-BFZhNTF7.mjs.map +0 -1
  346. package/dist/src-G7yt8gGm.mjs.map +0 -1
  347. package/dist/standalone-BqNJDJ04.mjs.map +0 -1
  348. package/dist/tools-registry-BV_2bu7z.mjs +0 -1405
  349. package/dist/tools-registry-BV_2bu7z.mjs.map +0 -1
  350. package/docker-compose.yml +0 -47
  351. package/iii-config.docker.yaml +0 -53
  352. package/iii-config.yaml +0 -61
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connect-BSLIAMpw.mjs","names":["upsertBlock","entryMatches","normalizePathForCommandMatch","CUSTOMIZATION_DIR","adapter","adapter","entryMatches","adapter","adapter","entryMatches","adapter","adapter","adapter","adapter","adapter","adapter","adapter","adapter","DOCS","stringList","adapter","adapter","adapter","adapter","adapter","adapter","adapter","adapter","adapter","claudeCode","copilotCli","codex","cursor","devin","geminiCli","qwen","antigravity","antigravityCli","kiro","warp","cline","continueDev","zed","droid","dsh","opencode","openclaw","hermes","pi","omp","openhuman"],"sources":["../src/cli/connect/util.ts","../src/cli/connect/guidelines.ts","../src/cli/connect/json-mcp-adapter.ts","../src/cli/connect/antigravity-hooks.ts","../src/cli/connect/codex-hooks.ts","../src/cli/connect/antigravity-cli.ts","../src/cli/connect/antigravity.ts","../src/cli/connect/claude-code.ts","../src/cli/connect/cline.ts","../src/cli/connect/copilot-cli.ts","../src/cli/connect/codex.ts","../src/cli/connect/continue.ts","../src/cli/connect/cursor.ts","../src/cli/connect/devin.ts","../src/cli/connect/droid.ts","../src/cli/connect/dsh.ts","../src/cli/connect/gemini-cli.ts","../src/cli/connect/native-install.ts","../src/cli/connect/hermes.ts","../src/cli/connect/kiro.ts","../src/cli/connect/openclaw.ts","../src/cli/connect/opencode.ts","../src/cli/connect/openhuman.ts","../src/cli/connect/omp.ts","../src/cli/connect/pi.ts","../src/cli/connect/qwen.ts","../src/cli/connect/warp.ts","../src/cli/connect/zed.ts","../src/cli/connect/index.ts"],"sourcesContent":["import {\n existsSync,\n mkdirSync,\n readFileSync,\n writeFileSync,\n copyFileSync,\n renameSync,\n} from \"node:fs\";\nimport { dirname, join, resolve } from \"node:path\";\nimport { homedir } from \"node:os\";\nimport * as p from \"@clack/prompts\";\n\nexport const AGENTMEMORY_MCP_BLOCK = {\n command: \"npx\",\n args: [\"-y\", \"@agentmemory/mcp\"],\n env: {\n AGENTMEMORY_URL: \"${AGENTMEMORY_URL:-http://localhost:3111}\",\n AGENTMEMORY_SECRET: \"${AGENTMEMORY_SECRET:-}\",\n AGENTMEMORY_TOOLS: \"${AGENTMEMORY_TOOLS:-all}\",\n },\n};\n\nconst COPILOT_MCP_COMMAND =\n process.platform === \"win32\"\n ? {\n command: process.env[\"ComSpec\"] || process.env[\"COMSPEC\"] || \"cmd.exe\",\n args: [\"/d\", \"/s\", \"/c\", \"npx\", \"-y\", \"@agentmemory/mcp\"],\n }\n : {\n command: \"npx\",\n args: [\"-y\", \"@agentmemory/mcp\"],\n };\n\nexport const AGENTMEMORY_COPILOT_MCP_BLOCK = {\n type: \"local\" as const,\n ...COPILOT_MCP_COMMAND,\n env: {\n AGENTMEMORY_URL: \"${AGENTMEMORY_URL:-http://localhost:3111}\",\n AGENTMEMORY_SECRET: \"${AGENTMEMORY_SECRET:-}\",\n AGENTMEMORY_TOOLS: \"${AGENTMEMORY_TOOLS:-all}\",\n },\n tools: [\"*\"],\n};\n\nexport function resolveDshHome(home: string = homedir()): string {\n const override = process.env[\"DSH_HOME\"];\n const value = override?.trim() ? override : join(home, \".dsh\");\n if (value === \"~\") return resolve(home);\n if (value.startsWith(\"~/\") || value.startsWith(\"~\\\\\")) return resolve(join(home, value.slice(2)));\n return resolve(value);\n}\n\nexport function backupsDir(): string {\n return join(homedir(), \".agentmemory\", \"backups\");\n}\n\nexport function ensureBackupsDir(): string {\n const dir = backupsDir();\n mkdirSync(dir, { recursive: true });\n return dir;\n}\n\nexport function timestampSlug(): string {\n return new Date().toISOString().replace(/[:.]/g, \"-\");\n}\n\nexport function backupFile(\n sourcePath: string,\n agent: string,\n ext = \"json\",\n): string {\n ensureBackupsDir();\n const stamp = timestampSlug();\n const target = join(backupsDir(), `${agent}-${stamp}.${ext}`);\n copyFileSync(sourcePath, target);\n return target;\n}\n\nexport function readJsonSafe<T = unknown>(path: string): T | null {\n if (!existsSync(path)) return null;\n try {\n return JSON.parse(readFileSync(path, \"utf-8\")) as T;\n } catch {\n return null;\n }\n}\n\nexport function writeJsonAtomic(path: string, value: unknown): void {\n writeTextAtomic(path, `${JSON.stringify(value, null, 2)}\\n`);\n}\n\nexport function writeTextAtomic(path: string, content: string): void {\n mkdirSync(dirname(path), { recursive: true });\n const tmp = `${path}.tmp-${process.pid}-${Date.now()}`;\n writeFileSync(tmp, content, \"utf-8\");\n renameSync(tmp, path);\n}\n\nexport function logInstalled(label: string, target: string): void {\n p.log.success(`${label} → wired into ${target}`);\n}\n\nexport function logAlreadyWired(label: string, target: string): void {\n p.log.info(`${label} already wired in ${target} (use --force to re-install)`);\n}\n\nexport function logBackup(target: string): void {\n p.log.info(`Backup: ${target}`);\n}\n","import { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { dirname, join } from \"node:path\";\nimport { resolveDshHome } from \"./util.js\";\n\n// Activating memory for agents that have no auto-capture hooks: write a short\n// \"use the memory tools\" guideline into each agent's native rules mechanism so\n// the agent proactively calls memory_recall / memory_save. Paths + formats are\n// verified against each agent's OFFICIAL docs (cited per entry below). Claude\n// Code / Codex are omitted here: they already auto-capture via lifecycle hooks.\n\nconst START = \"<!-- agentmemory:start -->\";\nconst END = \"<!-- agentmemory:end -->\";\n\nconst GUIDELINE_BODY = `## Agent memory (agentmemory)\n\nYou have persistent long-term memory via the agentmemory MCP server. Tools: \\`memory_recall\\`, \\`memory_smart_search\\`, \\`memory_save\\`, \\`memory_sessions\\`.\n\n- At the START of a task, call \\`memory_recall\\` (or \\`memory_smart_search\\`) with the task context to load relevant past decisions, fixes, and preferences before asking the user to repeat anything.\n- When you learn something durable (a decision, a fix, a gotcha, a user preference, a project convention), call \\`memory_save\\` to persist it.\n- Prefer recalling over re-deriving, and save concise reusable facts rather than transcripts.`;\n\n// \"block\" -> upsert a marked block inside a shared instructions file\n// \"mdc\" -> Cursor project rule: dedicated .mdc with alwaysApply frontmatter\n// \"steering\" -> Kiro steering file: dedicated .md with inclusion:always frontmatter\n// \"rule\" -> dedicated always-on markdown rule file (own file, safe to own)\ntype GuidelineFormat = \"block\" | \"mdc\" | \"steering\" | \"rule\";\n\ntype GuidelineTarget = {\n // Preferred user-global rules file (absolute). Omitted when the agent has no\n // clean global rules FILE (UI-only or project-scoped), forcing the project\n // fallback. Global is preferred so memory activates across all repos.\n globalPath?: string;\n // Project fallback, relative to cwd.\n projectPath: string;\n format: GuidelineFormat;\n scope: \"global\" | \"project\";\n source: string; // official doc URL the path/format was verified against\n};\n\nexport function guidelineTargets(\n home: string = homedir(),\n): Record<string, GuidelineTarget> {\n return {\n // No global rules FILE (User Rules are UI-only) -> project .cursor/rules/*.mdc\n cursor: {\n projectPath: join(\".cursor\", \"rules\", \"agentmemory.mdc\"),\n format: \"mdc\",\n scope: \"project\",\n source: \"https://cursor.com/docs/rules\",\n },\n // Cline's global rules dir is a non-standard ~/Documents path; the dedicated\n // project rule (no frontmatter = always active) is the verified stable form.\n cline: {\n projectPath: join(\".clinerules\", \"agentmemory.md\"),\n format: \"rule\",\n scope: \"project\",\n source: \"https://docs.cline.bot/customization/cline-rules\",\n },\n // Continue does not auto-read AGENTS.md; rules live in .continue/rules/*.md.\n continue: {\n projectPath: join(\".continue\", \"rules\", \"00-agentmemory.md\"),\n format: \"rule\",\n scope: \"project\",\n source: \"https://docs.continue.dev/customize/deep-dives/rules\",\n },\n zed: {\n globalPath: join(home, \".config\", \"zed\", \"AGENTS.md\"),\n projectPath: \"AGENTS.md\",\n format: \"block\",\n scope: \"global\",\n source: \"https://zed.dev/docs/ai/instructions\",\n },\n // Warp global Rules are UI-managed (no file path) -> project AGENTS.md.\n warp: {\n projectPath: \"AGENTS.md\",\n format: \"block\",\n scope: \"project\",\n source: \"https://docs.warp.dev/agent-platform/capabilities/rules\",\n },\n kiro: {\n globalPath: join(home, \".kiro\", \"steering\", \"agentmemory.md\"),\n projectPath: join(\".kiro\", \"steering\", \"agentmemory.md\"),\n format: \"steering\",\n scope: \"global\",\n source: \"https://kiro.dev/docs/steering\",\n },\n \"gemini-cli\": {\n globalPath: join(home, \".gemini\", \"GEMINI.md\"),\n projectPath: \"GEMINI.md\",\n format: \"block\",\n scope: \"global\",\n source: \"https://github.com/google-gemini/gemini-cli/blob/main/docs/cli/gemini-md.md\",\n },\n qwen: {\n globalPath: join(home, \".qwen\", \"QWEN.md\"),\n projectPath: \"QWEN.md\",\n format: \"block\",\n scope: \"global\",\n source: \"https://github.com/QwenLM/qwen-code/blob/main/docs/users/features/memory.md\",\n },\n opencode: {\n globalPath: join(home, \".config\", \"opencode\", \"AGENTS.md\"),\n projectPath: \"AGENTS.md\",\n format: \"block\",\n scope: \"global\",\n source: \"https://opencode.ai/docs/rules\",\n },\n droid: {\n globalPath: join(home, \".factory\", \"AGENTS.md\"),\n projectPath: \"AGENTS.md\",\n format: \"block\",\n scope: \"global\",\n source: \"https://docs.factory.ai/cli/configuration/agents-md\",\n },\n // DeepSeek Harness loads $DSH_HOME/AGENTS.md into every session's first\n // step via @deepseek-ai/dsh-agent-instructions (same mechanism as the\n // project-level AGENTS.md chain). DSH_HOME override keeps this aligned\n // with the dsh adapter, which resolves its profile paths through DSH_HOME.\n dsh: {\n globalPath: join(resolveDshHome(home), \"AGENTS.md\"),\n projectPath: \"AGENTS.md\",\n format: \"block\",\n scope: \"global\",\n source: \"https://github.com/deepseek-ai/deepseek-harness\",\n },\n // Antigravity does NOT read AGENTS.md; global rules live in ~/.gemini/GEMINI.md.\n antigravity: {\n globalPath: join(home, \".gemini\", \"GEMINI.md\"),\n projectPath: join(\".agents\", \"rules\", \"agentmemory.md\"),\n format: \"block\",\n scope: \"global\",\n source: \"https://antigravity.google/docs/rules-workflows\",\n },\n // The agy CLI reads the same ~/.gemini/GEMINI.md as the IDE.\n \"antigravity-cli\": {\n globalPath: join(home, \".gemini\", \"GEMINI.md\"),\n projectPath: join(\".agents\", \"rules\", \"agentmemory.md\"),\n format: \"block\",\n scope: \"global\",\n source: \"https://antigravity.google/docs/rules-workflows\",\n },\n \"copilot-cli\": {\n globalPath: join(home, \".copilot\", \"copilot-instructions.md\"),\n projectPath: join(\".github\", \"copilot-instructions.md\"),\n format: \"block\",\n scope: \"global\",\n source:\n \"https://docs.github.com/en/copilot/how-tos/copilot-cli/customize-copilot/add-custom-instructions\",\n },\n };\n}\n\nfunction renderDedicated(format: GuidelineFormat): string {\n if (format === \"mdc\") {\n return `---\\ndescription: agentmemory long-term memory usage\\nalwaysApply: true\\n---\\n\\n${GUIDELINE_BODY}\\n`;\n }\n if (format === \"steering\") {\n return `---\\ninclusion: always\\n---\\n\\n${GUIDELINE_BODY}\\n`;\n }\n // plain dedicated rule (Cline / Continue)\n return `${GUIDELINE_BODY}\\n`;\n}\n\n// Insert or replace the marked block in a shared instructions file, preserving\n// any surrounding user content. Idempotent: re-running updates only our block.\nfunction upsertBlock(existing: string): string {\n const block = `${START}\\n${GUIDELINE_BODY}\\n${END}`;\n const startIdx = existing.indexOf(START);\n const endIdx = existing.indexOf(END);\n if (startIdx !== -1 && endIdx !== -1 && endIdx > startIdx) {\n return (\n existing.slice(0, startIdx) + block + existing.slice(endIdx + END.length)\n );\n }\n // Malformed marker state: a lone or reversed marker. Appending here would\n // let a later run pair the orphan marker with the appended block's twin and\n // cut the user's content between them. Leave the file untouched.\n if (startIdx !== -1 || endIdx !== -1) {\n return existing;\n }\n const sep = existing.length === 0 || existing.endsWith(\"\\n\") ? \"\" : \"\\n\";\n const lead = existing.length === 0 ? \"\" : \"\\n\";\n return `${existing}${sep}${lead}${block}\\n`;\n}\n\nexport type GuidelineResult =\n | { kind: \"written\"; path: string; scope: string; source: string }\n | { kind: \"unchanged\"; path: string; scope: string }\n | { kind: \"would-write\"; path: string; scope: string }\n | { kind: \"no-target\" };\n\nexport function writeGuideline(\n agentName: string,\n opts: { cwd: string; home?: string; dryRun?: boolean } = { cwd: process.cwd() },\n): GuidelineResult {\n const home = opts.home ?? homedir();\n const target = guidelineTargets(home)[agentName];\n if (!target) return { kind: \"no-target\" };\n\n const path = target.globalPath ?? join(opts.cwd, target.projectPath);\n const dedicated = target.format !== \"block\";\n\n const existing = existsSync(path) ? readFileSync(path, \"utf8\") : \"\";\n const next = dedicated ? renderDedicated(target.format) : upsertBlock(existing);\n\n if (existing === next) {\n return { kind: \"unchanged\", path, scope: target.scope };\n }\n if (opts.dryRun) {\n return { kind: \"would-write\", path, scope: target.scope };\n }\n mkdirSync(dirname(path), { recursive: true });\n writeFileSync(path, next, \"utf8\");\n return { kind: \"written\", path, scope: target.scope, source: target.source };\n}\n","import { existsSync, mkdirSync } from \"node:fs\";\nimport { dirname } from \"node:path\";\nimport * as p from \"@clack/prompts\";\nimport type { ConnectAdapter, ConnectOptions, ConnectResult } from \"./types.js\";\nimport {\n AGENTMEMORY_MCP_BLOCK,\n backupFile,\n logAlreadyWired,\n logBackup,\n logInstalled,\n readJsonSafe,\n writeJsonAtomic,\n} from \"./util.js\";\n\nexport type JsonMcpAdapterConfig = {\n name: string;\n displayName: string;\n detectDir: string;\n configPath: string;\n docs?: string;\n protocolNote?: string;\n // Integration style for onboarding grouping. Defaults to \"mcp\" since a\n // JSON MCP config writer is MCP-only by construction; hosts that also\n // ship hooks (e.g. OpenClaw) pass \"native\".\n category?: \"native\" | \"mcp\";\n // Wrapper key under which servers live. Default \"mcpServers\".\n // Zed uses \"context_servers\"; otherwise same shape.\n wrapperKey?: string;\n // Extra fields merged into the agentmemory entry. Droid requires\n // type: \"stdio\"; other hosts ignore unknown fields.\n extraEntryFields?: Record<string, unknown>;\n installHooks?: (opts: ConnectOptions) => ConnectResult;\n};\n\ntype McpEntry = typeof AGENTMEMORY_MCP_BLOCK;\ntype McpConfig = Record<string, unknown>;\n\nfunction entryMatches(entry: unknown): boolean {\n if (!entry || typeof entry !== \"object\") return false;\n const e = entry as Record<string, unknown>;\n if (e[\"command\"] !== \"npx\") return false;\n const args = Array.isArray(e[\"args\"]) ? (e[\"args\"] as string[]) : [];\n return args.includes(\"@agentmemory/mcp\");\n}\n\nexport function createJsonMcpAdapter(\n config: JsonMcpAdapterConfig,\n): ConnectAdapter {\n const wrapperKey = config.wrapperKey ?? \"mcpServers\";\n return {\n name: config.name,\n displayName: config.displayName,\n category: config.category ?? \"mcp\",\n ...(config.docs !== undefined && { docs: config.docs }),\n ...(config.protocolNote !== undefined && {\n protocolNote: config.protocolNote,\n }),\n\n detect(): boolean {\n return existsSync(config.detectDir);\n },\n\n async install(opts: ConnectOptions): Promise<ConnectResult> {\n const existing = readJsonSafe<McpConfig>(config.configPath);\n const next: McpConfig = existing ? { ...existing } : {};\n const servers: Record<string, McpEntry> = {\n ...((next[wrapperKey] as Record<string, McpEntry>) ?? {}),\n };\n\n const alreadyHas = entryMatches(servers[\"agentmemory\"]);\n if (alreadyHas && !opts.force) {\n logAlreadyWired(config.displayName, config.configPath);\n if (opts.withHooks && config.installHooks) {\n const hookResult = config.installHooks(opts);\n if (hookResult.kind === \"skipped\") {\n p.log.warn(\n `${config.displayName} hooks skipped: ${hookResult.reason}.`,\n );\n }\n }\n return { kind: \"already-wired\", mutatedPath: config.configPath };\n }\n\n if (opts.dryRun) {\n p.log.info(\n `[dry-run] Would ${alreadyHas ? \"overwrite\" : \"add\"} ${wrapperKey}.agentmemory in ${config.configPath}`,\n );\n if (opts.withHooks && config.installHooks) {\n const hookResult = config.installHooks(opts);\n if (hookResult.kind === \"skipped\") {\n p.log.warn(\n `${config.displayName} hooks skipped: ${hookResult.reason}.`,\n );\n }\n }\n return { kind: \"installed\", mutatedPath: config.configPath };\n }\n\n let backupPath: string | undefined;\n if (existsSync(config.configPath)) {\n backupPath = backupFile(config.configPath, config.name);\n logBackup(backupPath);\n } else {\n mkdirSync(dirname(config.configPath), { recursive: true });\n }\n\n servers[\"agentmemory\"] = {\n ...AGENTMEMORY_MCP_BLOCK,\n ...(config.extraEntryFields ?? {}),\n };\n next[wrapperKey] = servers;\n writeJsonAtomic(config.configPath, next);\n\n const verify = readJsonSafe<McpConfig>(config.configPath);\n const verifyServers = verify?.[wrapperKey] as\n | Record<string, McpEntry>\n | undefined;\n if (!entryMatches(verifyServers?.[\"agentmemory\"])) {\n p.log.error(\n `Verification failed: ${config.configPath} did not contain ${wrapperKey}.agentmemory after write.`,\n );\n return { kind: \"skipped\", reason: \"verification-failed\" };\n }\n\n logInstalled(config.displayName, config.configPath);\n\n if (opts.withHooks && config.installHooks) {\n const hookResult = config.installHooks(opts);\n if (hookResult.kind === \"skipped\") {\n p.log.warn(\n `${config.displayName} hooks skipped: ${hookResult.reason}. MCP wiring still applied.`,\n );\n }\n }\n\n return {\n kind: \"installed\",\n mutatedPath: config.configPath,\n ...(backupPath !== undefined && { backupPath }),\n };\n },\n };\n}\n","import { readFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\n\n/**\n * Merge engine for Antigravity CLI's `hooks.json`.\n *\n * Antigravity does not use the `{ hooks: { <Event>: [...] } }` envelope\n * that `codex-hooks.ts` handles for Claude Code, Codex and Droid. Its file\n * is a map of *named* hook bundles at the root:\n *\n * {\n * \"<hook-name>\": {\n * \"enabled\": true,\n * \"PreToolUse\": [ { \"matcher\": \"…\", \"hooks\": [ { type, command, timeout } ] } ],\n * \"Stop\": [ { type, command, timeout } ]\n * }\n * }\n *\n * The two shapes are not a typo: tool events take the `{ matcher, hooks }`\n * wrapper, lifecycle events a flat handler list. Wrapping a lifecycle event\n * makes agy read the wrapper as a handler and reject the *whole file*\n * (`command hook must specify 'command'`), disabling every other bundle in\n * it too.\n *\n * Named bundles make the merge simpler than the Codex one: agentmemory owns\n * exactly the top-level keys whose commands point under\n * `<pluginRoot>/scripts/`, so a re-install drops those wholesale and re-adds\n * a fresh bundle, preserving user keys and their order.\n *\n * `${CLAUDE_PLUGIN_ROOT}` is resolved at install time — agy expands no env\n * vars and requires absolute paths. The resolved path must also be bare and\n * space-free: agy runs no shell and strips no quotes, so `node \"<root>/…\"`\n * looks for a module whose name starts with a quote, and a space truncates\n * the argument with no escaping form that works.\n *\n * Behaviour above verified against agy 1.0.15.\n * Source: antigravity.google/docs/hooks\n */\n\ntype HookHandler = { type: string; command: string; timeout?: number };\ntype HookEntry = { matcher?: string; hooks: HookHandler[] };\nexport type NamedHook = { enabled?: boolean } & Record<\n string,\n boolean | HookEntry[] | HookHandler[] | undefined\n>;\nexport type AntigravityHookManifest = Record<string, NamedHook>;\n\n/** Tool events: `[ { matcher, hooks: [...] } ]`. */\nconst TOOL_EVENT_KEYS = new Set([\"PreToolUse\", \"PostToolUse\"]);\n\n/** Lifecycle events: a flat `[ { type, command } ]` handler list. */\nconst LIFECYCLE_EVENT_KEYS = new Set([\n \"PreInvocation\",\n \"PostInvocation\",\n \"Stop\",\n]);\n\n/** Events Antigravity dispatches. Anything else in a bundle is metadata. */\nconst EVENT_KEYS = new Set([...TOOL_EVENT_KEYS, ...LIFECYCLE_EVENT_KEYS]);\n\nexport function buildMergedAntigravityHooks(\n existing: AntigravityHookManifest | null,\n pluginRoot: string,\n manifestFile = \"hooks.antigravity.json\",\n): AntigravityHookManifest {\n const ours = JSON.parse(\n readFileSync(join(pluginRoot, \"hooks\", manifestFile), \"utf-8\"),\n ) as AntigravityHookManifest;\n const scriptsDir = join(pluginRoot, \"scripts\");\n\n const out: AntigravityHookManifest = {};\n\n for (const [name, bundle] of Object.entries(existing ?? {})) {\n if (isAgentmemoryBundle(bundle, scriptsDir)) continue;\n out[name] = bundle;\n }\n\n for (const [name, bundle] of Object.entries(ours)) {\n out[name] = resolveBundle(bundle, pluginRoot);\n }\n\n return out;\n}\n\n/** True when `pluginRoot` cannot be expressed in an Antigravity `command`. */\nexport function containsSpaces(pluginRoot: string): boolean {\n return /\\s/.test(pluginRoot);\n}\n\n/**\n * Every handler in a bundle, across both event shapes: an entry that carries\n * no `hooks` array is itself the handler.\n */\nfunction allHandlers(bundle: NamedHook): HookHandler[] {\n const out: HookHandler[] = [];\n for (const [key, value] of Object.entries(bundle)) {\n if (!EVENT_KEYS.has(key) || !Array.isArray(value)) continue;\n for (const entry of value as (HookEntry | HookHandler)[]) {\n if (!entry || typeof entry !== \"object\") continue;\n const nested = (entry as HookEntry).hooks;\n if (Array.isArray(nested)) out.push(...nested);\n else out.push(entry as HookHandler);\n }\n }\n return out;\n}\n\nfunction isAgentmemoryBundle(bundle: unknown, scriptsDir: string): boolean {\n if (!bundle || typeof bundle !== \"object\" || Array.isArray(bundle)) {\n return false;\n }\n const normalizedScriptsDir = normalizePathForCommandMatch(scriptsDir);\n return allHandlers(bundle as NamedHook).some((handler) =>\n normalizePathForCommandMatch(handler?.command ?? \"\").includes(\n normalizedScriptsDir,\n ),\n );\n}\n\nfunction resolveBundle(bundle: NamedHook, pluginRoot: string): NamedHook {\n const out: NamedHook = {};\n for (const [key, value] of Object.entries(bundle)) {\n if (!EVENT_KEYS.has(key) || !Array.isArray(value)) {\n out[key] = value as boolean;\n continue;\n }\n if (LIFECYCLE_EVENT_KEYS.has(key)) {\n out[key] = (value as HookHandler[]).map((handler) =>\n resolveHandler(handler, pluginRoot),\n );\n continue;\n }\n out[key] = (value as HookEntry[]).map((entry) => {\n const next: HookEntry = {\n hooks: entry.hooks.map((handler) => resolveHandler(handler, pluginRoot)),\n };\n if (entry.matcher !== undefined) next.matcher = entry.matcher;\n return next;\n });\n }\n return out;\n}\n\nfunction resolveHandler(\n handler: HookHandler,\n pluginRoot: string,\n): HookHandler {\n return {\n type: handler.type,\n // Replacer function, not a string: a plugin path containing `$$`, `$&`,\n // \"$`\" or `$'` would otherwise be read as a replacement pattern and\n // silently mangle the installed command.\n command: handler.command.replace(\n /\\$\\{CLAUDE_PLUGIN_ROOT\\}/g,\n () => pluginRoot,\n ),\n ...(handler.timeout !== undefined && { timeout: handler.timeout }),\n };\n}\n\nfunction normalizePathForCommandMatch(value: string): string {\n return value.replace(/\\\\/g, \"/\");\n}\n","import { existsSync, readFileSync } from \"node:fs\";\nimport { dirname, join, resolve } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\ntype HookHandler = { type: string; command?: string; [key: string]: unknown };\ntype HookEntry = { matcher?: string; hooks: HookHandler[] };\nexport type HookManifest = { hooks: Record<string, HookEntry[]> };\n\n/**\n * Locate the bundled `plugin/` directory at runtime. Walks up from the\n * module's own location looking for `plugin/scripts/` + `plugin/hooks/`,\n * both shipped via the npm `files` field. Works for both `dist/cli.mjs`\n * (bundled) and `src/cli/connect/codex-hooks.ts` (dev) layouts.\n */\nexport function findPluginRoot(startUrl: string = import.meta.url): string {\n const here = dirname(fileURLToPath(startUrl));\n let dir = here;\n for (let i = 0; i < 12; i++) {\n if (\n existsSync(join(dir, \"plugin\", \"scripts\")) &&\n existsSync(join(dir, \"plugin\", \"hooks\"))\n ) {\n return resolve(join(dir, \"plugin\"));\n }\n const parent = dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n throw new Error(\n `agentmemory: could not locate bundled plugin/ directory (searched up from ${here})`,\n );\n}\n\n/**\n * Build the merged hooks.json content.\n *\n * 1. Strip every handler in `existing` whose command points under\n * `<pluginRoot>/scripts/`, and an entry only once nothing else is left\n * in it. This lets us re-install idempotently without leaving stale\n * references or dropping the user's own handlers.\n * 2. Append fresh entries from the bundled Codex manifest with\n * `${CLAUDE_PLUGIN_ROOT}` rewritten to the absolute plugin path.\n * Matchers and the other handler fields from the bundled manifest are\n * preserved so PreToolUse event routing keeps working.\n */\nexport function buildMergedHooks(\n existing: HookManifest | null,\n pluginRoot: string,\n manifestFile = \"hooks.codex.json\",\n): HookManifest {\n const bundledManifestPath = join(pluginRoot, \"hooks\", manifestFile);\n const ours = JSON.parse(readFileSync(bundledManifestPath, \"utf-8\")) as HookManifest;\n const scriptsDir = join(pluginRoot, \"scripts\");\n\n const out: HookManifest = { hooks: {} };\n\n if (existing?.hooks) {\n for (const [event, entries] of Object.entries(existing.hooks)) {\n const kept = entries.flatMap((entry) => {\n const hooks = entry.hooks.filter(\n (handler) => !isAgentmemoryHandler(handler, scriptsDir),\n );\n if (hooks.length === entry.hooks.length) return [entry];\n return hooks.length > 0 ? [{ ...entry, hooks }] : [];\n });\n if (kept.length > 0) out.hooks[event] = kept;\n }\n }\n\n for (const [event, entries] of Object.entries(ours.hooks)) {\n const resolvedEntries: HookEntry[] = entries.map((entry) => {\n const next: HookEntry = {\n hooks: entry.hooks.map((handler) => ({\n ...handler,\n command: handler.command?.replace(\n /\\$\\{CLAUDE_PLUGIN_ROOT\\}/g,\n () => pluginRoot,\n ),\n })),\n };\n if (entry.matcher !== undefined) next.matcher = entry.matcher;\n return next;\n });\n out.hooks[event] = [...(out.hooks[event] ?? []), ...resolvedEntries];\n }\n\n return out;\n}\n\nfunction isAgentmemoryHandler(handler: HookHandler, scriptsDir: string): boolean {\n return (\n typeof handler.command === \"string\" &&\n normalizePathForCommandMatch(handler.command).includes(\n normalizePathForCommandMatch(scriptsDir),\n )\n );\n}\n\nfunction normalizePathForCommandMatch(value: string): string {\n return value.replace(/\\\\/g, \"/\");\n}\n","import { existsSync, mkdirSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { join } from \"node:path\";\nimport * as p from \"@clack/prompts\";\nimport { createJsonMcpAdapter } from \"./json-mcp-adapter.js\";\nimport type { ConnectOptions, ConnectResult } from \"./types.js\";\nimport {\n buildMergedAntigravityHooks,\n containsSpaces,\n type AntigravityHookManifest,\n} from \"./antigravity-hooks.js\";\nimport { findPluginRoot } from \"./codex-hooks.js\";\nimport {\n backupFile,\n logBackup,\n logInstalled,\n readJsonSafe,\n writeJsonAtomic,\n} from \"./util.js\";\n\n// Current Antigravity surfaces share ~/.gemini/config customizations.\n// Detection keys off the CLI's own state directory, not Gemini CLI's home.\n// Sources: antigravity.google/docs/hooks, antigravity.google/docs/cli/using\nconst GEMINI_DIR = join(homedir(), \".gemini\");\nconst ANTIGRAVITY_CLI_DIR = join(GEMINI_DIR, \"antigravity-cli\");\nconst CUSTOMIZATION_DIR = join(GEMINI_DIR, \"config\");\nconst ANTIGRAVITY_CLI_HOOKS = join(CUSTOMIZATION_DIR, \"hooks.json\");\n\nexport const adapter = createJsonMcpAdapter({\n name: \"antigravity-cli\",\n displayName: \"Antigravity CLI (agy)\",\n detectDir: ANTIGRAVITY_CLI_DIR,\n configPath: join(CUSTOMIZATION_DIR, \"mcp_config.json\"),\n // agy does not expand shell-style ${NAME:-default} values. Inherit the\n // runtime environment so custom endpoints and credentials survive.\n extraEntryFields: { env: {} },\n docs: \"https://github.com/rohitg00/agentmemory#other-agents\",\n protocolNote:\n \"→ Using MCP via ~/.gemini/config/mcp_config.json, shared with current Antigravity IDE versions. The `/mcp` slash command inside agy lists configured servers. Pass --with-hooks to also install the native ~/.gemini/config/hooks.json auto-capture hooks.\",\n installHooks: installAntigravityCliHooks,\n});\n\n/**\n * Merge the bundled `plugin/hooks/hooks.antigravity.json` into\n * `~/.gemini/config/hooks.json`, replacing only the bundle agentmemory owns.\n */\nexport function installAntigravityCliHooks(opts: ConnectOptions): ConnectResult {\n let pluginRoot: string;\n try {\n pluginRoot = findPluginRoot();\n } catch (err) {\n return {\n kind: \"skipped\",\n reason: err instanceof Error ? err.message : String(err),\n };\n }\n\n // agy honours no quoting, so a space in the path yields hooks that load\n // but never run. Refuse rather than install something that can only fail.\n if (containsSpaces(pluginRoot)) {\n return {\n kind: \"skipped\",\n reason: `Antigravity CLI cannot run hook commands whose path contains spaces, and agentmemory is installed at ${pluginRoot}. Reinstall it under a space-free path to use --with-hooks; MCP works either way.`,\n };\n }\n\n const existing = readJsonSafe<AntigravityHookManifest>(ANTIGRAVITY_CLI_HOOKS);\n const merged = buildMergedAntigravityHooks(existing, pluginRoot);\n\n if (opts.dryRun) {\n p.log.info(\n `[dry-run] Would ${existing ? \"merge\" : \"create\"} ${ANTIGRAVITY_CLI_HOOKS} with ${Object.keys(merged).length} hook bundle(s)`,\n );\n return { kind: \"installed\", mutatedPath: ANTIGRAVITY_CLI_HOOKS };\n }\n\n let backupPath: string | undefined;\n if (existsSync(ANTIGRAVITY_CLI_HOOKS)) {\n backupPath = backupFile(ANTIGRAVITY_CLI_HOOKS, \"antigravity-cli-hooks\", \"json\");\n logBackup(backupPath);\n } else {\n mkdirSync(CUSTOMIZATION_DIR, { recursive: true });\n }\n\n writeJsonAtomic(ANTIGRAVITY_CLI_HOOKS, merged);\n\n logInstalled(\"Antigravity CLI hooks\", ANTIGRAVITY_CLI_HOOKS);\n p.log.info(\n \"User-scope hooks reference absolute paths under the bundled plugin/ dir. Re-run `agentmemory connect antigravity-cli --with-hooks` after upgrading agentmemory to refresh them.\",\n );\n\n return {\n kind: \"installed\",\n mutatedPath: ANTIGRAVITY_CLI_HOOKS,\n ...(backupPath !== undefined && { backupPath }),\n };\n}\n","import { existsSync } from \"node:fs\";\nimport { homedir, platform } from \"node:os\";\nimport { join } from \"node:path\";\nimport { createJsonMcpAdapter } from \"./json-mcp-adapter.js\";\nimport { installAntigravityCliHooks } from \"./antigravity-cli.js\";\n\nconst LEGACY_USER_DIR =\n platform() === \"darwin\"\n ? join(homedir(), \"Library\", \"Application Support\", \"Antigravity\", \"User\")\n : join(homedir(), \".config\", \"Antigravity\", \"User\");\n\nconst CUSTOMIZATION_DIR = join(homedir(), \".gemini\", \"config\");\nconst mcpAdapter = createJsonMcpAdapter({\n name: \"antigravity\",\n displayName: \"Antigravity\",\n detectDir: join(homedir(), \".gemini\", \"antigravity-ide\"),\n configPath: join(CUSTOMIZATION_DIR, \"mcp_config.json\"),\n extraEntryFields: { env: {} },\n docs: \"https://github.com/rohitg00/agentmemory#other-agents\",\n protocolNote:\n \"→ Using MCP via ~/.gemini/config/mcp_config.json, shared by current Antigravity surfaces. Pass --with-hooks for capture through ~/.gemini/config/hooks.json.\",\n installHooks: installAntigravityCliHooks,\n});\n\nexport const adapter = {\n ...mcpAdapter,\n detect: () => mcpAdapter.detect() || existsSync(join(homedir(), \".gemini\", \"antigravity\")) || existsSync(LEGACY_USER_DIR),\n};\n","import { existsSync, mkdirSync, writeFileSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { join } from \"node:path\";\nimport * as p from \"@clack/prompts\";\nimport type { ConnectAdapter, ConnectOptions, ConnectResult } from \"./types.js\";\nimport {\n AGENTMEMORY_MCP_BLOCK,\n backupFile,\n logAlreadyWired,\n logBackup,\n logInstalled,\n readJsonSafe,\n writeJsonAtomic,\n} from \"./util.js\";\nimport {\n buildMergedHooks,\n findPluginRoot,\n type HookManifest,\n} from \"./codex-hooks.js\";\n\nconst CLAUDE_DIR = join(homedir(), \".claude\");\nconst CLAUDE_JSON = join(homedir(), \".claude.json\");\nconst CLAUDE_SETTINGS = join(CLAUDE_DIR, \"settings.json\");\n\ntype ClaudeMcpEntry = typeof AGENTMEMORY_MCP_BLOCK;\ntype ClaudeConfig = {\n mcpServers?: Record<string, ClaudeMcpEntry>;\n [key: string]: unknown;\n};\n\nfunction entryMatches(entry: unknown): boolean {\n if (!entry || typeof entry !== \"object\") return false;\n const e = entry as Record<string, unknown>;\n if (e[\"command\"] !== \"npx\") return false;\n const args = Array.isArray(e[\"args\"]) ? (e[\"args\"] as string[]) : [];\n return args.includes(\"@agentmemory/mcp\");\n}\n\nexport const adapter: ConnectAdapter = {\n name: \"claude-code\",\n displayName: \"Claude Code\",\n category: \"native\",\n docs: \"https://github.com/rohitg00/agentmemory#claude-code-one-block-paste-it\",\n protocolNote:\n \"→ Using MCP. Hooks are also available — see https://github.com/rohitg00/agentmemory#claude-code-one-block-paste-it.\",\n\n detect(): boolean {\n return existsSync(CLAUDE_DIR);\n },\n\n async install(opts: ConnectOptions): Promise<ConnectResult> {\n const existing = readJsonSafe<ClaudeConfig>(CLAUDE_JSON);\n const next: ClaudeConfig = existing ? { ...existing } : {};\n const servers: Record<string, ClaudeMcpEntry> = {\n ...((next.mcpServers as Record<string, ClaudeMcpEntry>) ?? {}),\n };\n\n const alreadyHas = entryMatches(servers[\"agentmemory\"]);\n if (alreadyHas && !opts.force) {\n logAlreadyWired(\"Claude Code\", CLAUDE_JSON);\n if (opts.withHooks) {\n const hookResult = installClaudeHooks(opts);\n if (hookResult.kind === \"skipped\") {\n p.log.warn(\n `Claude Code hooks fallback skipped: ${hookResult.reason}.`,\n );\n }\n }\n return { kind: \"already-wired\", mutatedPath: CLAUDE_JSON };\n }\n\n if (opts.dryRun) {\n p.log.info(\n `[dry-run] Would ${alreadyHas ? \"overwrite\" : \"add\"} mcpServers.agentmemory in ${CLAUDE_JSON}`,\n );\n return { kind: \"installed\", mutatedPath: CLAUDE_JSON };\n }\n\n let backupPath: string | undefined;\n if (existsSync(CLAUDE_JSON)) {\n backupPath = backupFile(CLAUDE_JSON, \"claude-code\");\n logBackup(backupPath);\n } else {\n mkdirSync(CLAUDE_DIR, { recursive: true });\n writeFileSync(CLAUDE_JSON, \"{}\\n\", \"utf-8\");\n }\n\n servers[\"agentmemory\"] = AGENTMEMORY_MCP_BLOCK;\n next.mcpServers = servers;\n writeJsonAtomic(CLAUDE_JSON, next);\n\n const verify = readJsonSafe<ClaudeConfig>(CLAUDE_JSON);\n if (!entryMatches(verify?.mcpServers?.[\"agentmemory\"])) {\n p.log.error(\n `Verification failed: ${CLAUDE_JSON} did not contain mcpServers.agentmemory after write.`,\n );\n return { kind: \"skipped\", reason: \"verification-failed\" };\n }\n\n logInstalled(\"Claude Code\", CLAUDE_JSON);\n p.log.info(\n \"Restart Claude Code (or run `/mcp` inside a session) to pick up the new server.\",\n );\n\n if (opts.withHooks) {\n const hookResult = installClaudeHooks(opts);\n if (hookResult.kind === \"skipped\") {\n p.log.warn(\n `Claude Code hooks fallback skipped: ${hookResult.reason}. MCP wiring still applied.`,\n );\n }\n }\n\n return { kind: \"installed\", mutatedPath: CLAUDE_JSON, backupPath };\n },\n};\n\nfunction installClaudeHooks(opts: ConnectOptions): ConnectResult {\n let pluginRoot: string;\n try {\n pluginRoot = findPluginRoot();\n } catch (err) {\n return {\n kind: \"skipped\",\n reason: err instanceof Error ? err.message : String(err),\n };\n }\n\n type ClaudeSettings = { hooks?: HookManifest[\"hooks\"]; [key: string]: unknown };\n const existing = readJsonSafe<ClaudeSettings>(CLAUDE_SETTINGS) ?? {};\n const existingHooks: HookManifest | null = existing.hooks\n ? { hooks: existing.hooks }\n : null;\n const merged = buildMergedHooks(existingHooks, pluginRoot, \"hooks.json\");\n\n if (opts.dryRun) {\n p.log.info(\n `[dry-run] Would merge agentmemory hook entries into ${CLAUDE_SETTINGS} (${Object.keys(merged.hooks).length} event(s))`,\n );\n return { kind: \"installed\", mutatedPath: CLAUDE_SETTINGS };\n }\n\n let backupPath: string | undefined;\n if (existsSync(CLAUDE_SETTINGS)) {\n backupPath = backupFile(CLAUDE_SETTINGS, \"claude-settings\", \"json\");\n logBackup(backupPath);\n } else {\n mkdirSync(CLAUDE_DIR, { recursive: true });\n }\n\n const next: ClaudeSettings = { ...existing, hooks: merged.hooks };\n writeJsonAtomic(CLAUDE_SETTINGS, next);\n\n logInstalled(\"Claude Code hooks\", CLAUDE_SETTINGS);\n p.log.info(\n \"User-scope hook entries reference absolute paths under the bundled plugin/ dir. Re-run `agentmemory connect claude-code --with-hooks` after upgrading agentmemory to refresh them.\",\n );\n\n return {\n kind: \"installed\",\n mutatedPath: CLAUDE_SETTINGS,\n ...(backupPath !== undefined && { backupPath }),\n };\n}\n","import { homedir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { createJsonMcpAdapter } from \"./json-mcp-adapter.js\";\n\n// Cline CLI stores MCP server config at ~/.cline/mcp.json with the\n// canonical `mcpServers` wrapper — same schema as Claude Code with\n// optional `disabled` and `autoApprove` fields per entry.\n// VS Code extension users manage MCP through Cline's Settings UI;\n// this adapter targets the standalone CLI surface.\n// Source: github.com/cline/cline/blob/main/docs/mcp/mcp-overview.mdx\nexport const adapter = createJsonMcpAdapter({\n name: \"cline\",\n displayName: \"Cline\",\n detectDir: join(homedir(), \".cline\"),\n configPath: join(homedir(), \".cline\", \"mcp.json\"),\n docs: \"https://github.com/rohitg00/agentmemory#other-agents\",\n protocolNote:\n \"→ Using MCP via ~/.cline/mcp.json (CLI). VS Code users: add the same block via Cline Settings → MCP Servers → Edit JSON.\",\n});\n","import { existsSync, mkdirSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { dirname, join } from \"node:path\";\nimport * as p from \"@clack/prompts\";\nimport type { ConnectAdapter, ConnectOptions, ConnectResult } from \"./types.js\";\nimport {\n AGENTMEMORY_COPILOT_MCP_BLOCK,\n backupFile,\n logAlreadyWired,\n logBackup,\n logInstalled,\n readJsonSafe,\n writeJsonAtomic,\n} from \"./util.js\";\n\nconst COPILOT_DIR = process.env[\"COPILOT_HOME\"] || join(homedir(), \".copilot\");\nconst COPILOT_MCP_JSON = join(COPILOT_DIR, \"mcp-config.json\");\n\ntype CopilotMcpEntry = typeof AGENTMEMORY_COPILOT_MCP_BLOCK;\ntype CopilotConfig = {\n mcpServers?: Record<string, CopilotMcpEntry>;\n [key: string]: unknown;\n};\n\nfunction entryMatches(entry: unknown): boolean {\n if (!entry || typeof entry !== \"object\") return false;\n return JSON.stringify(entry) === JSON.stringify(AGENTMEMORY_COPILOT_MCP_BLOCK);\n}\n\nexport const adapter: ConnectAdapter = {\n name: \"copilot-cli\",\n displayName: \"GitHub Copilot CLI\",\n category: \"native\",\n docs: \"https://github.com/rohitg00/agentmemory#github-copilot-cli\",\n protocolNote:\n \"→ Using MCP. Install the plugin too for full hooks/skills coverage.\",\n\n detect(): boolean {\n return existsSync(COPILOT_DIR);\n },\n\n async install(opts: ConnectOptions): Promise<ConnectResult> {\n const existing = readJsonSafe<CopilotConfig>(COPILOT_MCP_JSON);\n const next: CopilotConfig = existing ? { ...existing } : {};\n const servers: Record<string, CopilotMcpEntry> = {\n ...((next.mcpServers as Record<string, CopilotMcpEntry>) ?? {}),\n };\n\n const alreadyHas = entryMatches(servers[\"agentmemory\"]);\n if (alreadyHas && !opts.force) {\n logAlreadyWired(\"GitHub Copilot CLI\", COPILOT_MCP_JSON);\n return { kind: \"already-wired\", mutatedPath: COPILOT_MCP_JSON };\n }\n\n if (opts.dryRun) {\n p.log.info(\n `[dry-run] Would ${alreadyHas ? \"overwrite\" : \"add\"} mcpServers.agentmemory in ${COPILOT_MCP_JSON}`,\n );\n return { kind: \"installed\", mutatedPath: COPILOT_MCP_JSON };\n }\n\n let backupPath: string | undefined;\n if (existsSync(COPILOT_MCP_JSON)) {\n backupPath = backupFile(COPILOT_MCP_JSON, \"copilot-cli\");\n logBackup(backupPath);\n } else {\n mkdirSync(dirname(COPILOT_MCP_JSON), { recursive: true });\n }\n\n servers[\"agentmemory\"] = AGENTMEMORY_COPILOT_MCP_BLOCK;\n next.mcpServers = servers;\n writeJsonAtomic(COPILOT_MCP_JSON, next);\n\n const verify = readJsonSafe<CopilotConfig>(COPILOT_MCP_JSON);\n if (!entryMatches(verify?.mcpServers?.[\"agentmemory\"])) {\n p.log.error(\n `Verification failed: ${COPILOT_MCP_JSON} did not contain mcpServers.agentmemory after write.`,\n );\n return { kind: \"skipped\", reason: \"verification-failed\" };\n }\n\n logInstalled(\"GitHub Copilot CLI\", COPILOT_MCP_JSON);\n p.log.info(\n \"Copilot picks up MCP servers on next launch or after `/mcp`. Install the plugin too for full hooks/skills.\",\n );\n return {\n kind: \"installed\",\n mutatedPath: COPILOT_MCP_JSON,\n ...(backupPath !== undefined && { backupPath }),\n };\n },\n};\n","import { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { join, dirname } from \"node:path\";\nimport * as p from \"@clack/prompts\";\nimport type { ConnectAdapter, ConnectOptions, ConnectResult } from \"./types.js\";\nimport {\n backupFile,\n logAlreadyWired,\n logBackup,\n logInstalled,\n readJsonSafe,\n writeJsonAtomic,\n} from \"./util.js\";\nimport {\n buildMergedHooks,\n findPluginRoot,\n type HookManifest,\n} from \"./codex-hooks.js\";\n\nconst CODEX_DIR = join(homedir(), \".codex\");\nconst CODEX_TOML = join(CODEX_DIR, \"config.toml\");\nconst CODEX_HOOKS = join(CODEX_DIR, \"hooks.json\");\n\nconst TOML_BLOCK = `[mcp_servers.agentmemory]\ncommand = \"npx\"\nargs = [\"-y\", \"@agentmemory/mcp\"]\n\n[mcp_servers.agentmemory.env]\nAGENTMEMORY_URL = \"http://localhost:3111\"\n`;\n\nconst SECTION_HEADER = \"[mcp_servers.agentmemory]\";\n\nfunction isWiredText(toml: string): boolean {\n return toml.includes(SECTION_HEADER);\n}\n\nfunction stripExistingBlock(toml: string): string {\n const lines = toml.split(/\\r?\\n/);\n const out: string[] = [];\n let skipping = false;\n for (const line of lines) {\n const trimmed = line.trim();\n if (\n trimmed === SECTION_HEADER ||\n trimmed === \"[mcp_servers.agentmemory.env]\"\n ) {\n skipping = true;\n continue;\n }\n if (\n skipping &&\n trimmed.startsWith(\"[\") &&\n trimmed !== \"[mcp_servers.agentmemory.env]\"\n ) {\n skipping = false;\n }\n if (!skipping) out.push(line);\n }\n return out.join(\"\\n\").replace(/\\n{3,}$/, \"\\n\\n\").trimEnd() + \"\\n\";\n}\n\nexport const adapter: ConnectAdapter = {\n name: \"codex\",\n displayName: \"Codex CLI\",\n category: \"native\",\n docs: \"https://github.com/rohitg00/agentmemory#codex-cli-codex-plugin-platform\",\n protocolNote:\n \"→ Using MCP. Hooks ship via the Codex plugin; on Codex Desktop, also pass --with-hooks to install the global hooks.json workaround.\",\n\n detect(): boolean {\n return existsSync(CODEX_DIR);\n },\n\n async install(opts: ConnectOptions): Promise<ConnectResult> {\n const exists = existsSync(CODEX_TOML);\n const current = exists ? readFileSync(CODEX_TOML, \"utf-8\") : \"\";\n const wired = isWiredText(current);\n\n if (wired && !opts.force) {\n logAlreadyWired(\"Codex CLI\", CODEX_TOML);\n return { kind: \"already-wired\", mutatedPath: CODEX_TOML };\n }\n\n if (opts.dryRun) {\n p.log.info(\n `[dry-run] Would ${wired ? \"rewrite\" : \"append\"} [mcp_servers.agentmemory] in ${CODEX_TOML}`,\n );\n if (opts.withHooks) installCodexHooks(opts);\n return { kind: \"installed\", mutatedPath: CODEX_TOML };\n }\n\n let backupPath: string | undefined;\n if (exists) {\n backupPath = backupFile(CODEX_TOML, \"codex\", \"toml\");\n logBackup(backupPath);\n } else {\n mkdirSync(dirname(CODEX_TOML), { recursive: true });\n }\n\n const cleaned = wired ? stripExistingBlock(current) : current;\n const joiner = cleaned.length === 0 || cleaned.endsWith(\"\\n\") ? \"\" : \"\\n\";\n const next = `${cleaned}${joiner}${cleaned.length > 0 ? \"\\n\" : \"\"}${TOML_BLOCK}`;\n writeFileSync(CODEX_TOML, next, \"utf-8\");\n\n const verify = readFileSync(CODEX_TOML, \"utf-8\");\n if (!isWiredText(verify)) {\n p.log.error(\n `Verification failed: ${CODEX_TOML} did not contain ${SECTION_HEADER} after write.`,\n );\n return { kind: \"skipped\", reason: \"verification-failed\" };\n }\n\n logInstalled(\"Codex CLI\", CODEX_TOML);\n p.log.info(\n \"Codex picks up MCP servers on next launch. For the deeper plugin install, run: codex plugin marketplace add rohitg00/agentmemory && codex plugin add agentmemory@agentmemory\",\n );\n\n if (opts.withHooks) {\n const hookResult = installCodexHooks(opts);\n if (hookResult.kind === \"skipped\") {\n p.log.warn(\n `Codex hooks fallback skipped: ${hookResult.reason}. MCP wiring still applied.`,\n );\n }\n }\n\n return {\n kind: \"installed\",\n mutatedPath: CODEX_TOML,\n ...(backupPath !== undefined && { backupPath }),\n };\n },\n};\n\nfunction installCodexHooks(opts: ConnectOptions): ConnectResult {\n let pluginRoot: string;\n try {\n pluginRoot = findPluginRoot();\n } catch (err) {\n return {\n kind: \"skipped\",\n reason: err instanceof Error ? err.message : String(err),\n };\n }\n\n const existing = readJsonSafe<HookManifest>(CODEX_HOOKS);\n const merged = buildMergedHooks(existing, pluginRoot);\n\n if (opts.dryRun) {\n p.log.info(\n `[dry-run] Would ${existing ? \"merge\" : \"create\"} ${CODEX_HOOKS} with ${Object.keys(merged.hooks).length} event(s)`,\n );\n return { kind: \"installed\", mutatedPath: CODEX_HOOKS };\n }\n\n let backupPath: string | undefined;\n if (existsSync(CODEX_HOOKS)) {\n backupPath = backupFile(CODEX_HOOKS, \"codex-hooks\", \"json\");\n logBackup(backupPath);\n }\n\n writeJsonAtomic(CODEX_HOOKS, merged);\n\n logInstalled(\"Codex hooks\", CODEX_HOOKS);\n p.log.warn(\n \"Codex runs only trusted hooks: launch `codex` (the TUI) once and choose \\\"Trust all and continue\\\" at the \\\"Hooks need review\\\" prompt. `codex exec` never shows the prompt, so hooks stay inert until then.\",\n );\n p.log.info(\n \"User-scope hooks reference absolute paths under the bundled plugin/ dir. Re-run `agentmemory connect codex --with-hooks` after upgrading agentmemory to refresh them, then re-approve in the TUI.\",\n );\n\n return {\n kind: \"installed\",\n mutatedPath: CODEX_HOOKS,\n ...(backupPath !== undefined && { backupPath }),\n };\n}\n","import { existsSync, mkdirSync, writeFileSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { dirname, join } from \"node:path\";\nimport * as p from \"@clack/prompts\";\nimport type { ConnectAdapter, ConnectOptions, ConnectResult } from \"./types.js\";\nimport {\n AGENTMEMORY_MCP_BLOCK,\n backupFile,\n logAlreadyWired,\n logBackup,\n logInstalled,\n readJsonSafe,\n writeJsonAtomic,\n} from \"./util.js\";\n\n// Continue.dev v1+ prefers ~/.continue/config.yaml; config.json is\n// deprecated and ignored when yaml is present. Three branches:\n// - config.yaml exists → emit stub with manual edit instructions\n// (no YAML dep in tree; preserving comments/anchors safely needs it)\n// - config.json exists → modify it (legacy path still loaded when no yaml)\n// - neither → create config.yaml from scratch (no merge risk)\n// Source: docs.continue.dev/reference/yaml-migration\nconst CONTINUE_DIR = join(homedir(), \".continue\");\nconst YAML_PATH = join(CONTINUE_DIR, \"config.yaml\");\nconst JSON_PATH = join(CONTINUE_DIR, \"config.json\");\n\ntype ContinueEntry = {\n name: string;\n command: string;\n args: string[];\n env?: Record<string, string>;\n};\n\ntype ContinueJsonConfig = {\n mcpServers?: ContinueEntry[];\n [key: string]: unknown;\n};\n\nfunction buildEntry(): ContinueEntry {\n return {\n name: \"agentmemory\",\n command: AGENTMEMORY_MCP_BLOCK.command,\n args: [...AGENTMEMORY_MCP_BLOCK.args],\n env: { ...AGENTMEMORY_MCP_BLOCK.env },\n };\n}\n\nfunction entryIsAgentmemory(entry: ContinueEntry | undefined): boolean {\n if (!entry) return false;\n return entry.name === \"agentmemory\" && entry.args.includes(\"@agentmemory/mcp\");\n}\n\n// Minimal YAML emitter for the agentmemory entry. Quotes string values\n// that contain ${ ... } expansion to keep parsers happy. Only used when\n// creating a fresh config.yaml — never when modifying an existing one.\nfunction renderFreshYaml(): string {\n const e = buildEntry();\n const envLines = Object.entries(e.env ?? {})\n .map(([k, v]) => ` ${k}: \"${v}\"`)\n .join(\"\\n\");\n return [\n \"mcpServers:\",\n ` - name: ${e.name}`,\n ` command: ${e.command}`,\n \" args:\",\n ...e.args.map((a) => ` - \"${a}\"`),\n \" env:\",\n envLines,\n \"\",\n ].join(\"\\n\");\n}\n\nexport const adapter: ConnectAdapter = {\n name: \"continue\",\n displayName: \"Continue\",\n category: \"mcp\",\n docs: \"https://github.com/rohitg00/agentmemory#other-agents\",\n protocolNote:\n \"→ Using MCP via ~/.continue/config.yaml (preferred) or config.json (legacy, only when no yaml).\",\n\n detect(): boolean {\n return existsSync(CONTINUE_DIR);\n },\n\n async install(opts: ConnectOptions): Promise<ConnectResult> {\n const yamlExists = existsSync(YAML_PATH);\n const jsonExists = existsSync(JSON_PATH);\n\n // Branch 1: yaml present — refuse to silently mutate user's yaml\n // config (preserving comments/anchors needs a proper parser).\n if (yamlExists) {\n const indented = renderFreshYaml()\n .split(\"\\n\")\n .map((l) => (l ? ` ${l}` : l))\n .join(\"\\n\");\n const manual = `\\nMerge this block into ~/.continue/config.yaml (the snippet already includes the top-level mcpServers key — if your config already has a mcpServers list, append the agentmemory entry to it instead of duplicating the key):\\n\\n${indented}`;\n p.log.info(\n `Continue: ${YAML_PATH} already exists. Manual edit needed.${manual}`,\n );\n return { kind: \"stub\", reason: \"config.yaml-needs-manual-edit\" };\n }\n\n // Branch 2: legacy json present — modify in place.\n if (jsonExists) {\n const existing = readJsonSafe<ContinueJsonConfig>(JSON_PATH);\n const next: ContinueJsonConfig = existing ? { ...existing } : {};\n const servers = Array.isArray(next.mcpServers)\n ? [...next.mcpServers]\n : [];\n\n const idx = servers.findIndex((s) => s?.name === \"agentmemory\");\n const alreadyHas = idx >= 0 && entryIsAgentmemory(servers[idx]);\n if (alreadyHas && !opts.force) {\n logAlreadyWired(\"Continue\", JSON_PATH);\n return { kind: \"already-wired\", mutatedPath: JSON_PATH };\n }\n\n if (opts.dryRun) {\n p.log.info(\n `[dry-run] Would ${alreadyHas ? \"overwrite\" : \"add\"} mcpServers[agentmemory] in ${JSON_PATH}`,\n );\n return { kind: \"installed\", mutatedPath: JSON_PATH };\n }\n\n const backupPath = backupFile(JSON_PATH, \"continue\");\n logBackup(backupPath);\n\n const entry = buildEntry();\n if (idx >= 0) servers[idx] = entry;\n else servers.push(entry);\n next.mcpServers = servers;\n writeJsonAtomic(JSON_PATH, next);\n\n const verify = readJsonSafe<ContinueJsonConfig>(JSON_PATH);\n const verifyEntry = verify?.mcpServers?.find(\n (s) => s?.name === \"agentmemory\",\n );\n if (!entryIsAgentmemory(verifyEntry)) {\n p.log.error(\n `Verification failed: ${JSON_PATH} did not contain mcpServers[agentmemory] after write.`,\n );\n return { kind: \"skipped\", reason: \"verification-failed\" };\n }\n\n logInstalled(\"Continue (legacy config.json)\", JSON_PATH);\n return {\n kind: \"installed\",\n mutatedPath: JSON_PATH,\n backupPath,\n };\n }\n\n // Branch 3: neither exists — create config.yaml from scratch (modern path).\n if (opts.dryRun) {\n p.log.info(`[dry-run] Would create ${YAML_PATH} with agentmemory entry`);\n return { kind: \"installed\", mutatedPath: YAML_PATH };\n }\n\n mkdirSync(dirname(YAML_PATH), { recursive: true });\n writeFileSync(YAML_PATH, renderFreshYaml(), \"utf-8\");\n logInstalled(\"Continue\", YAML_PATH);\n return { kind: \"installed\", mutatedPath: YAML_PATH };\n },\n};\n","import { homedir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { createJsonMcpAdapter } from \"./json-mcp-adapter.js\";\n\nexport const adapter = createJsonMcpAdapter({\n name: \"cursor\",\n displayName: \"Cursor\",\n // Cursor speaks lifecycle hooks as well as MCP, so it groups with the\n // native hosts rather than the MCP-only ones.\n category: \"native\",\n detectDir: join(homedir(), \".cursor\"),\n configPath: join(homedir(), \".cursor\", \"mcp.json\"),\n docs: \"https://github.com/rohitg00/agentmemory#cursor\",\n // Deliberately no --with-hooks here, unlike Codex and Claude Code. Theirs\n // mirror the plugin's hooks into a user-scope file to work around hosts\n // that fail to dispatch plugin-scope hooks; Cursor dispatches them fine.\n // Writing ~/.cursor/hooks.json as well would just make both copies fire and\n // record every observation twice.\n protocolNote:\n \"→ Using MCP. Lifecycle hooks ship in the Cursor plugin: Settings → Plugins → Add marketplace → this repo, then enable agentmemory.\",\n});\n","import { existsSync, mkdirSync } from \"node:fs\";\nimport { homedir, platform } from \"node:os\";\nimport { join } from \"node:path\";\nimport * as p from \"@clack/prompts\";\nimport { createJsonMcpAdapter } from \"./json-mcp-adapter.js\";\nimport type { ConnectOptions, ConnectResult } from \"./types.js\";\nimport {\n buildMergedHooks,\n findPluginRoot,\n type HookManifest,\n} from \"./codex-hooks.js\";\nimport {\n backupFile,\n logBackup,\n logInstalled,\n readJsonSafe,\n writeJsonAtomic,\n} from \"./util.js\";\n\nfunction devinDir(): string {\n if (platform() === \"win32\") {\n const appData = process.env[\"APPDATA\"];\n if (appData) return join(appData, \"devin\");\n }\n const xdg = process.env[\"XDG_CONFIG_HOME\"];\n return xdg ? join(xdg, \"devin\") : join(homedir(), \".config\", \"devin\");\n}\n\nconst DEVIN_DIR = devinDir();\nconst DEVIN_CONFIG = join(DEVIN_DIR, \"config.json\");\n\nexport const adapter = createJsonMcpAdapter({\n name: \"devin\",\n displayName: \"Devin CLI\",\n detectDir: DEVIN_DIR,\n configPath: DEVIN_CONFIG,\n docs: \"https://github.com/rohitg00/agentmemory#other-agents\",\n protocolNote:\n \"→ Using MCP via the user config. Devin CLI migrates mcpServers into mcp_config.json on newer builds. Pass --with-hooks for native auto-capture.\",\n installHooks: installDevinHooks,\n});\n\nfunction installDevinHooks(opts: ConnectOptions): ConnectResult {\n let pluginRoot: string;\n try {\n pluginRoot = findPluginRoot();\n } catch (err) {\n return {\n kind: \"skipped\",\n reason: err instanceof Error ? err.message : String(err),\n };\n }\n\n const existing = readJsonSafe<Record<string, unknown>>(DEVIN_CONFIG) ?? {};\n const existingHooks = existing[\"hooks\"]\n ? ({ hooks: existing[\"hooks\"] } as HookManifest)\n : null;\n const merged = buildMergedHooks(existingHooks, pluginRoot, \"hooks.devin.json\");\n const next = { ...existing, hooks: merged.hooks };\n\n if (opts.dryRun) {\n p.log.info(\n `[dry-run] Would write ${Object.keys(merged.hooks).length} hook event(s) into ${DEVIN_CONFIG}`,\n );\n return { kind: \"installed\", mutatedPath: DEVIN_CONFIG };\n }\n\n let backupPath: string | undefined;\n if (existsSync(DEVIN_CONFIG)) {\n backupPath = backupFile(DEVIN_CONFIG, \"devin-hooks\", \"json\");\n logBackup(backupPath);\n } else {\n mkdirSync(DEVIN_DIR, { recursive: true });\n }\n\n writeJsonAtomic(DEVIN_CONFIG, next);\n\n logInstalled(\"Devin CLI hooks\", DEVIN_CONFIG);\n p.log.info(\n \"Verify with `/hooks` inside devin. Re-run `agentmemory connect devin --with-hooks` after upgrading agentmemory so the plugin paths stay current.\",\n );\n\n return {\n kind: \"installed\",\n mutatedPath: DEVIN_CONFIG,\n ...(backupPath !== undefined && { backupPath }),\n };\n}\n","import { existsSync, mkdirSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { join } from \"node:path\";\nimport * as p from \"@clack/prompts\";\nimport { createJsonMcpAdapter } from \"./json-mcp-adapter.js\";\nimport type { ConnectOptions, ConnectResult } from \"./types.js\";\nimport {\n buildMergedHooks,\n findPluginRoot,\n type HookManifest,\n} from \"./codex-hooks.js\";\nimport { backupFile, logBackup, logInstalled, readJsonSafe, writeJsonAtomic } from \"./util.js\";\n\n// Factory.ai's Droid CLI stores MCP server config at ~/.factory/mcp.json\n// with the canonical `mcpServers` wrapper. Project-scoped overrides live\n// at <repo>/.factory/mcp.json. Each entry adds an optional `type` field\n// (\"stdio\" | \"http\") and `disabled` boolean — agentmemory's stdio block\n// works against the same shape without needing the explicit type tag.\n// Source: docs.factory.ai/cli/configuration/mcp\n//\n// Droid also ships a native, first-party hooks system (SessionStart,\n// SessionEnd, UserPromptSubmit, PreToolUse, PostToolUse) configured via\n// `~/.factory/hooks.json`, in the same `{ hooks: { <event>: [{ matcher?,\n// hooks: [{ type, command }] }] } }` shape Claude Code and Codex use — so\n// `--with-hooks` reuses `buildMergedHooks` from codex-hooks.ts with the\n// bundled `hooks.droid.json` manifest instead of writing a new merge\n// strategy. Source: docs.factory.ai/cli/configuration/hooks-guide\nconst DROID_DIR = join(homedir(), \".factory\");\nconst DROID_HOOKS = join(DROID_DIR, \"hooks.json\");\n\nexport const adapter = createJsonMcpAdapter({\n name: \"droid\",\n displayName: \"Droid (Factory.ai)\",\n detectDir: DROID_DIR,\n configPath: join(DROID_DIR, \"mcp.json\"),\n docs: \"https://github.com/rohitg00/agentmemory#other-agents\",\n protocolNote:\n \"→ Using MCP via ~/.factory/mcp.json. The `/mcp` slash command inside droid lists configured servers. Pass --with-hooks to also install the native ~/.factory/hooks.json auto-capture hooks.\",\n // Droid requires `type` per the documented schema. stdio for npx-spawned shim.\n extraEntryFields: { type: \"stdio\" },\n installHooks: installDroidHooks,\n});\n\n/**\n * Merge the bundled `plugin/hooks/hooks.droid.json` into\n * `~/.factory/hooks.json`. Same idempotent merge/strip-by-script-path\n * behavior as the Codex and Claude Code hook installers: re-running keeps\n * user-authored hook entries and only replaces the ones agentmemory owns.\n */\nfunction installDroidHooks(opts: ConnectOptions): ConnectResult {\n let pluginRoot: string;\n try {\n pluginRoot = findPluginRoot();\n } catch (err) {\n return {\n kind: \"skipped\",\n reason: err instanceof Error ? err.message : String(err),\n };\n }\n\n const existing = readJsonSafe<HookManifest>(DROID_HOOKS);\n const merged = buildMergedHooks(existing, pluginRoot, \"hooks.droid.json\");\n\n if (opts.dryRun) {\n p.log.info(\n `[dry-run] Would ${existing ? \"merge\" : \"create\"} ${DROID_HOOKS} with ${Object.keys(merged.hooks).length} event(s)`,\n );\n return { kind: \"installed\", mutatedPath: DROID_HOOKS };\n }\n\n let backupPath: string | undefined;\n if (existsSync(DROID_HOOKS)) {\n backupPath = backupFile(DROID_HOOKS, \"droid-hooks\", \"json\");\n logBackup(backupPath);\n } else {\n mkdirSync(DROID_DIR, { recursive: true });\n }\n\n writeJsonAtomic(DROID_HOOKS, merged);\n\n logInstalled(\"Droid hooks\", DROID_HOOKS);\n p.log.info(\n \"User-scope hooks reference absolute paths under the bundled plugin/ dir. Re-run `agentmemory connect droid --with-hooks` after upgrading agentmemory to refresh them.\",\n );\n\n return {\n kind: \"installed\",\n mutatedPath: DROID_HOOKS,\n ...(backupPath !== undefined && { backupPath }),\n };\n}\n","import { existsSync, mkdirSync, readFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport * as p from \"@clack/prompts\";\nimport { isMap, isSeq, parseDocument, type YAMLMap } from \"yaml\";\nimport type { ConnectAdapter, ConnectOptions, ConnectResult } from \"./types.js\";\nimport {\n backupFile,\n resolveDshHome,\n logAlreadyWired,\n logBackup,\n logInstalled,\n writeTextAtomic,\n} from \"./util.js\";\nimport { findPluginRoot } from \"./codex-hooks.js\";\n\n// Harness evaluates !!js before scrubbing secrets from the MCP child env.\nconst MCP_BLOCK = `- insert:\n - id: agentmemory\n name: '@deepseek-ai/dsh-mcp-client'\n config:\n transport: stdio\n serverName: agentmemory\n command: npx\n args: ['-y', '@agentmemory/mcp']\n env:\n AGENTMEMORY_URL: !!js process.env.AGENTMEMORY_URL || 'http://localhost:3111'\n AGENTMEMORY_SECRET: !!js process.env.AGENTMEMORY_SECRET || ''\n`;\n\nconst MCP_MARKER = \"serverName: agentmemory\";\nconst HOOKS_MARKER = \"id: agentmemory-hooks\";\n\nfunction hooksBlock(pluginPath: string): string {\n return `- insert:\n - id: agentmemory-hooks\n name: ${JSON.stringify(pluginPath)}\n`;\n}\n\nfunction parsePatch(content: string) {\n const doc = parseDocument(content);\n if (doc.contents === null) doc.contents = doc.createNode([]);\n if (doc.errors.length || !isSeq(doc.contents)) {\n throw new Error(\"Cannot update dsh cordis.patch.yml: expected a valid YAML sequence.\");\n }\n return { doc, operations: doc.contents };\n}\n\nfunction isManaged(entry: unknown, marker: string): entry is YAMLMap {\n if (!isMap(entry)) return false;\n return marker === MCP_MARKER\n ? entry.get(\"name\") === \"@deepseek-ai/dsh-mcp-client\" && entry.getIn([\"config\", \"serverName\"]) === \"agentmemory\"\n : entry.get(\"id\") === \"agentmemory-hooks\" && typeof entry.get(\"name\") === \"string\" &&\n (entry.get(\"name\") === \"@deepseek-ai/dsh-hooks-claude-code\" || /[\\\\/]dist[\\\\/]integrations[\\\\/]dsh\\.mjs$/.test(String(entry.get(\"name\"))));\n}\n\nfunction managedEntries(content: string, marker: string): YAMLMap[] {\n return parsePatch(content).operations.items.flatMap((operation) => {\n const entries = isMap(operation) ? operation.get(\"insert\", true) : null;\n return isSeq(entries) ? entries.items.filter((entry) => isManaged(entry, marker)) : [];\n });\n}\n\nfunction hasBlock(content: string, marker: string): boolean {\n return managedEntries(content, marker).length > 0;\n}\n\nfunction upsertBlock(content: string, marker: string, block: string): string {\n const { doc, operations } = parsePatch(content);\n const addition = parsePatch(block).operations;\n const replacement = addition.getIn([0, \"insert\", 0], true);\n let replaced = false;\n for (let i = 0; i < operations.items.length; i++) {\n const operation = operations.items[i];\n if (!isMap(operation)) continue;\n const entries = operation.get(\"insert\", true);\n if (!isSeq(entries)) continue;\n let removed = false;\n for (let j = 0; j < entries.items.length; j++) {\n if (!isManaged(entries.items[j], marker)) continue;\n if (!replaced) {\n entries.set(j, replacement);\n replaced = true;\n } else {\n entries.delete(j--);\n removed = true;\n }\n }\n if (removed && entries.items.length === 0) operations.delete(i--);\n }\n if (!replaced) operations.items.push(...addition.items);\n operations.flow = false;\n return doc.toString();\n}\n\nexport const adapter: ConnectAdapter = {\n name: \"dsh\",\n displayName: \"DeepSeek Harness\",\n docs: \"https://github.com/rohitg00/agentmemory/blob/main/docs/dsh.md\",\n protocolNote:\n \"→ Using MCP via $DSH_HOME/cordis.patch.yml (the home-level patch layer every profile loads). Tools appear as mcp__agentmemory__*. Pass --with-hooks to also wire auto-capture with the bundled native DSH plugin.\",\n category: \"native\",\n detect(): boolean {\n return existsSync(resolveDshHome());\n },\n async install(opts: ConnectOptions): Promise<ConnectResult> {\n const home = resolveDshHome();\n const configPath = join(home, \"cordis.patch.yml\");\n const existing = existsSync(configPath)\n ? readFileSync(configPath, \"utf-8\")\n : \"\";\n\n const wantHooks = opts.withHooks === true;\n const hasMcp = hasBlock(existing, MCP_MARKER);\n const hooks = managedEntries(existing, HOOKS_MARKER);\n const pluginPath = wantHooks ? join(dirname(findPluginRoot()), \"dist\", \"integrations\", \"dsh.mjs\") : \"\";\n const hooksReady = hooks.length === 1 && hooks[0].get(\"name\") === pluginPath && existsSync(pluginPath);\n\n if (wantHooks && !opts.force && hooks.some(entry => entry.get(\"name\") === \"@deepseek-ai/dsh-hooks-claude-code\")) {\n throw new Error(\"Legacy DSH hooks bridge found. Run agentmemory connect dsh --with-hooks --force to replace it with the bundled native plugin. Existing manifest files will be preserved.\");\n }\n\n if (hasMcp && (!wantHooks || hooksReady) && !opts.force) {\n logAlreadyWired(this.displayName, configPath);\n return { kind: \"already-wired\", mutatedPath: configPath };\n }\n\n if (opts.dryRun) {\n p.log.info(\n `[dry-run] Would update the agentmemory mcp-client row${wantHooks ? \" and the bundled capture plugin\" : \"\"} in ${configPath}`,\n );\n return { kind: \"installed\", mutatedPath: configPath };\n }\n\n if (wantHooks && !existsSync(pluginPath)) {\n throw new Error(\"Bundled DSH plugin is missing. Reinstall AgentMemory, or run npm run build in a source checkout.\");\n }\n\n let backupPath: string | undefined;\n if (existsSync(configPath)) {\n backupPath = backupFile(configPath, this.name, \"yml\");\n logBackup(backupPath);\n } else {\n mkdirSync(dirname(configPath), { recursive: true });\n }\n\n let next = hasMcp && !opts.force ? existing : upsertBlock(existing, MCP_MARKER, MCP_BLOCK);\n\n if (wantHooks && (!hooksReady || opts.force)) {\n next = upsertBlock(next, HOOKS_MARKER, hooksBlock(pluginPath));\n }\n\n writeTextAtomic(configPath, next);\n\n const written = readFileSync(configPath, \"utf-8\");\n if (!hasBlock(written, MCP_MARKER) || (wantHooks && !hasBlock(written, HOOKS_MARKER))) {\n p.log.error(\n `Verification failed: ${configPath} did not contain the agentmemory rows after write.`,\n );\n return { kind: \"skipped\", reason: \"verification-failed\" };\n }\n\n logInstalled(this.displayName, configPath);\n return { kind: \"installed\", mutatedPath: configPath, backupPath };\n },\n};\n","import { homedir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { createJsonMcpAdapter } from \"./json-mcp-adapter.js\";\n\nexport const adapter = createJsonMcpAdapter({\n name: \"gemini-cli\",\n displayName: \"Gemini CLI\",\n detectDir: join(homedir(), \".gemini\"),\n configPath: join(homedir(), \".gemini\", \"settings.json\"),\n docs: \"https://github.com/rohitg00/agentmemory#other-agents\",\n protocolNote:\n \"→ Using MCP (the only protocol Gemini CLI speaks). Memory bridge runs at :3111 underneath.\",\n});\n","import { createHash, randomUUID } from \"node:crypto\";\nimport { cpSync, existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, writeFileSync } from \"node:fs\";\nimport { dirname, join, relative, resolve, sep } from \"node:path\";\nimport { findPluginRoot } from \"./codex-hooks.js\";\nimport { backupFile, ensureBackupsDir } from \"./util.js\";\n\nconst MANIFEST = \".agentmemory-install.json\";\nconst digest = (content: Buffer) => createHash(\"sha256\").update(content).digest(\"hex\");\nexport const record = (value: unknown): value is Record<string, unknown> =>\n value !== null && typeof value === \"object\" && !Array.isArray(value);\n\nexport function nativePackageRoot(): string {\n return dirname(findPluginRoot());\n}\n\nexport function nativeUserPath(value: string, home: string): string {\n return resolve(value.replace(/^~(?=$|[/\\\\])/, () => home));\n}\n\nexport function nativeMcpEntry(packageRoot: string): Record<string, unknown> {\n const entry = join(packageRoot, \"dist\", \"standalone.mjs\");\n if (!existsSync(entry)) throw new Error(\"Bundled MCP runtime is missing; reinstall AgentMemory before connecting.\");\n return { command: process.execPath, args: [entry], env: { AGENTMEMORY_TOOLS: \"all\", AGENTMEMORY_FORCE_PROXY: \"1\" } };\n}\n\nfunction filesUnder(dir: string, prefix = \"\"): Map<string, Buffer> {\n const files = new Map<string, Buffer>();\n for (const item of readdirSync(dir, { withFileTypes: true })) {\n if ([\"__pycache__\", \".git\", \"node_modules\", MANIFEST].includes(item.name) || item.name.endsWith(\".pyc\")) continue;\n const path = join(dir, item.name);\n if (item.isSymbolicLink()) throw new Error(`Native installation does not follow symbolic links: ${path}`);\n const name = join(prefix, item.name);\n if (item.isDirectory()) for (const [key, value] of filesUnder(path, name)) files.set(key, value);\n else if (item.isFile()) files.set(name, readFileSync(path));\n }\n return files;\n}\n\nfunction rejectSymlink(path: string): void {\n if (existsSync(path) && lstatSync(path).isSymbolicLink()) throw new Error(`Native installation does not replace symbolic links: ${path}`);\n}\n\nexport type NativeBundle = { target: string; label: string; files: Map<string, Buffer>; previous: Record<string, string>; changed: boolean };\n\nexport function prepareNativeBundle(source: string, target: string, label: string, required: string[], force: boolean, skillsSource?: string, extraFiles: Record<string, string> = {}): NativeBundle {\n if (!required.every((name) => existsSync(join(source, name)))) throw new Error(`Bundled ${label} files are missing; reinstall AgentMemory before connecting.`);\n rejectSymlink(target);\n const files = filesUnder(source);\n if (skillsSource) {\n if (![\"remember/SKILL.md\", \"recall/SKILL.md\"].every((name) => existsSync(join(skillsSource, name)))) throw new Error(\"Bundled skills are missing; reinstall AgentMemory before connecting.\");\n for (const [name, content] of filesUnder(skillsSource)) files.set(join(\"skills\", name), content);\n }\n for (const [name, content] of Object.entries(extraFiles)) files.set(name, Buffer.from(content));\n let previous: Record<string, string> = {};\n if (existsSync(join(target, MANIFEST))) {\n let stored: unknown;\n try { stored = JSON.parse(readFileSync(join(target, MANIFEST), \"utf8\")); } catch { stored = null; }\n if (!record(stored) || !record(stored.files) || !Object.values(stored.files).every((hash) => typeof hash === \"string\")) throw new Error(`Invalid native install manifest in ${target}; restore its backup before reconnecting.`);\n previous = stored.files as Record<string, string>;\n for (const name of Object.keys(previous)) {\n const location = relative(target, resolve(target, name));\n if (!location || location === \"..\" || location.startsWith(`..${sep}`) || resolve(target, name) === resolve(target, MANIFEST)) throw new Error(`Invalid native install path in ${target}.`);\n }\n }\n const installed = existsSync(target) ? filesUnder(target) : new Map<string, Buffer>();\n if (!force) {\n for (const [name, content] of installed) {\n if (!files.has(name) && !(name in previous)) continue;\n if (previous[name] ? digest(content) !== previous[name] : !files.get(name)?.equals(content)) {\n throw new Error(`Customized ${label} file ${name} was preserved; use --force to replace it with a backup.`);\n }\n }\n }\n const changed = !existsSync(join(target, MANIFEST)) || [...files].some(([name, content]) => !installed.get(name)?.equals(content)) || Object.keys(previous).some((name) => !files.has(name) && installed.has(name));\n return { target, label, files, previous, changed };\n}\n\nexport function installNativeBundles(bundles: NativeBundle[], configPath: string, configText: string): string | undefined {\n rejectSymlink(configPath);\n const transaction = randomUUID();\n const configStage = `${configPath}.stage-${transaction}`;\n const staged: { bundle: NativeBundle; stage: string; rollback: string; replaced: boolean; installed: boolean }[] = [];\n let backupPath: string | undefined;\n try {\n for (const bundle of bundles.filter((item) => item.changed)) {\n mkdirSync(dirname(bundle.target), { recursive: true });\n const stage = `${bundle.target}.stage-${transaction}`;\n const rollback = `${bundle.target}.previous-${transaction}`;\n const item = { bundle, stage, rollback, replaced: false, installed: false };\n staged.push(item);\n if (existsSync(bundle.target)) cpSync(bundle.target, stage, { recursive: true });\n else mkdirSync(stage);\n for (const name of Object.keys(bundle.previous)) if (!bundle.files.has(name)) rmSync(join(stage, name), { force: true });\n for (const [name, content] of bundle.files) {\n mkdirSync(dirname(join(stage, name)), { recursive: true });\n writeFileSync(join(stage, name), content);\n }\n writeFileSync(join(stage, MANIFEST), JSON.stringify({ files: Object.fromEntries([...bundle.files].map(([name, content]) => [name, digest(content)])) }) + \"\\n\");\n if (existsSync(bundle.target)) {\n const backup = join(ensureBackupsDir(), `${bundle.label}-${transaction}`);\n cpSync(bundle.target, backup, { recursive: true });\n backupPath ??= backup;\n }\n }\n const configChanged = !existsSync(configPath) || readFileSync(configPath, \"utf8\") !== configText;\n if (configChanged && existsSync(configPath)) backupPath = backupFile(configPath, `native-config-${transaction}`, \"config\");\n if (configChanged) {\n mkdirSync(dirname(configPath), { recursive: true });\n writeFileSync(configStage, configText, { mode: existsSync(configPath) ? lstatSync(configPath).mode & 0o777 : 0o600 });\n }\n for (const item of staged) {\n if (existsSync(item.bundle.target)) { renameSync(item.bundle.target, item.rollback); item.replaced = true; }\n renameSync(item.stage, item.bundle.target); item.installed = true;\n }\n if (configChanged) renameSync(configStage, configPath);\n } catch (error) {\n for (const item of [...staged].reverse()) {\n if (item.installed) rmSync(item.bundle.target, { recursive: true, force: true });\n if (item.replaced) renameSync(item.rollback, item.bundle.target);\n }\n throw error;\n } finally {\n for (const item of staged) rmSync(item.stage, { recursive: true, force: true });\n rmSync(configStage, { force: true });\n }\n for (const item of staged) rmSync(item.rollback, { recursive: true, force: true });\n return backupPath;\n}\n","import { existsSync, readFileSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { join } from \"node:path\";\nimport * as p from \"@clack/prompts\";\nimport { parseDocument } from \"yaml\";\nimport type { ConnectAdapter } from \"./types.js\";\nimport { installNativeBundles, nativeMcpEntry, nativePackageRoot, nativeUserPath, prepareNativeBundle, record } from \"./native-install.js\";\nimport { logAlreadyWired, logBackup, logInstalled } from \"./util.js\";\n\nconst hermesHome = () => {\n const value = process.env.HERMES_HOME?.trim() || join(homedir(), `.hermes${process.env.HERMES_DATA_DIR_SUFFIX ?? \"\"}`);\n return nativeUserPath(value.replace(/\\$(?:\\{([^}]+)\\}|([A-Za-z_][A-Za-z_0-9]*))/g, (match, braced, plain) => process.env[braced ?? plain] ?? match), homedir());\n};\nconst DOCS = \"https://github.com/rohitg00/agentmemory/tree/main/integrations/hermes\";\nconst stringList = (value: unknown) => value === undefined || (Array.isArray(value) && value.every((item) => typeof item === \"string\"));\n\nexport const adapter: ConnectAdapter = {\n name: \"hermes\",\n displayName: \"Hermes Agent\",\n category: \"native\",\n docs: DOCS,\n protocolNote: \"→ Installs the native memory provider and bundled skills into the active Hermes profile. Credentials stay managed by Hermes.\",\n detect: () => existsSync(hermesHome()),\n\n async install(opts) {\n const home = hermesHome();\n const path = join(home, \"config.yaml\");\n const raw = existsSync(path) ? readFileSync(path, \"utf8\") : \"\";\n const doc = parseDocument(raw);\n let existing: unknown;\n try { existing = doc.contents === null ? {} : doc.toJS({ maxAliasCount: 100 }); } catch { existing = null; }\n if (doc.errors.length || !record(existing) ||\n (existing.memory !== undefined && !record(existing.memory)) ||\n (existing.plugins !== undefined && !record(existing.plugins)) ||\n (existing.mcp_servers !== undefined && !record(existing.mcp_servers))) {\n p.log.warn(`Hermes config is not a valid YAML mapping. Left ${path} unchanged.`);\n return { kind: \"skipped\", reason: \"invalid-config\" };\n }\n const memory = (existing.memory ?? {}) as Record<string, unknown>;\n const plugins = (existing.plugins ?? {}) as Record<string, unknown>;\n const servers = (existing.mcp_servers ?? {}) as Record<string, unknown>;\n if (!stringList(plugins.enabled) || !stringList(plugins.disabled) ||\n (memory.provider !== undefined && typeof memory.provider !== \"string\")) {\n p.log.warn(`Hermes provider or plugin settings are invalid. Left ${path} unchanged.`);\n return { kind: \"skipped\", reason: \"invalid-config\" };\n }\n if (servers.agentmemory !== undefined && !record(servers.agentmemory) && !(opts.force && opts.withMcp)) {\n p.log.warn(\"Hermes's AgentMemory MCP entry is invalid. Repair it or use --force --with-mcp.\");\n return { kind: \"skipped\", reason: \"invalid-entry\" };\n }\n if (memory.provider && memory.provider !== \"agentmemory\" && !opts.force) {\n p.log.warn(\"Hermes already selects another memory provider. Use --force to select AgentMemory and keep a backup.\");\n return { kind: \"skipped\", reason: \"memory-provider-conflict\" };\n }\n if ((plugins.disabled as string[] | undefined)?.includes(\"agentmemory\") && !opts.force) {\n p.log.warn(\"AgentMemory is disabled in this Hermes profile. Use --force to enable it.\");\n return { kind: \"skipped\", reason: \"plugin-disabled\" };\n }\n try {\n const root = nativePackageRoot();\n const bundles = [\n prepareNativeBundle(join(root, \"integrations\", \"hermes\"), join(home, \"plugins\", \"agentmemory\"), \"hermes-provider\", [\"__init__.py\", \"plugin.yaml\"], opts.force),\n prepareNativeBundle(join(root, \"plugin\", \"skills\"), join(home, \"skills\", \"agentmemory\"), \"hermes-skills\", [\"remember/SKILL.md\", \"recall/SKILL.md\"], opts.force),\n ];\n if (memory.provider !== \"agentmemory\") doc.setIn([\"memory\", \"provider\"], \"agentmemory\");\n const enabled = (plugins.enabled ?? []) as string[];\n if (!enabled.includes(\"agentmemory\")) doc.setIn([\"plugins\", \"enabled\"], [...enabled, \"agentmemory\"]);\n if ((plugins.disabled as string[] | undefined)?.includes(\"agentmemory\")) doc.setIn([\"plugins\", \"disabled\"], (plugins.disabled as string[]).filter((name) => name !== \"agentmemory\"));\n if (opts.withMcp) {\n p.log.warn(\"MCP exposes all AgentMemory tools against the configured backend. It does not enforce the native provider's profile scope; enable it only for a trusted, deliberately shared backend.\");\n if (servers.agentmemory === undefined || opts.force) {\n const entry = nativeMcpEntry(root);\n entry.env = { ...(entry.env as Record<string, string>), AGENTMEMORY_URL: \"${AGENTMEMORY_URL}\", AGENTMEMORY_SECRET: \"${AGENTMEMORY_SECRET}\", AGENTMEMORY_CREDENTIAL_MODE: \"explicit\" };\n doc.setIn([\"mcp_servers\", \"agentmemory\"], entry);\n } else p.log.info(\"Preserved the existing AgentMemory MCP entry. After moving the installed package, review its settings and reconnect with --with-mcp --force to refresh its runtime path.\");\n }\n const configText = doc.toString();\n if (opts.dryRun) {\n p.log.info(`[dry-run] Would install the native provider and skills, then activate AgentMemory in ${path}`);\n return { kind: \"installed\", mutatedPath: path };\n }\n let backupPath: string | undefined;\n const unchanged = !bundles.some((bundle) => bundle.changed) && configText === raw;\n if (unchanged) logAlreadyWired(this.displayName, path);\n else {\n backupPath = installNativeBundles(bundles, path, configText);\n if (backupPath) logBackup(backupPath);\n logInstalled(this.displayName, path);\n }\n p.log.info(\"Authentication is not verified. Start AgentMemory, then run `hermes memory setup` in this same HERMES_HOME to set its URL and scoped secret. Verify a save and recall in a new session. Skills needing tools beyond native save, recall and search require the optional --with-mcp connection.\");\n return unchanged ? { kind: \"already-wired\", mutatedPath: path } : { kind: \"installed\", mutatedPath: path, ...(backupPath ? { backupPath } : {}) };\n } catch (error) {\n p.log.warn(error instanceof Error ? error.message : \"Hermes installation failed; configuration was not activated.\");\n return { kind: \"skipped\", reason: \"native-install-failed\" };\n }\n },\n};\n","import { homedir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { createJsonMcpAdapter } from \"./json-mcp-adapter.js\";\n\n// Kiro stores user-level MCP servers in ~/.kiro/settings/mcp.json.\n// Schema follows the standard MCP envelope { mcpServers: { ... } }.\n// Source: kiro.dev/docs/cli/mcp\nexport const adapter = createJsonMcpAdapter({\n name: \"kiro\",\n displayName: \"Kiro\",\n detectDir: join(homedir(), \".kiro\"),\n configPath: join(homedir(), \".kiro\", \"settings\", \"mcp.json\"),\n docs: \"https://github.com/rohitg00/agentmemory#other-agents\",\n protocolNote:\n \"→ Using MCP via ~/.kiro/settings/mcp.json (user-level). Workspace overrides live in .kiro/settings/mcp.json.\",\n});\n","import { existsSync, readFileSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { join } from \"node:path\";\nimport * as p from \"@clack/prompts\";\nimport JSON5 from \"json5\";\nimport type { ConnectAdapter } from \"./types.js\";\nimport { logAlreadyWired, logBackup, logInstalled } from \"./util.js\";\nimport { installNativeBundles, nativeMcpEntry, nativePackageRoot, nativeUserPath, prepareNativeBundle, record } from \"./native-install.js\";\n\nconst paths = () => {\n const home = nativeUserPath(process.env.OPENCLAW_HOME?.trim() || homedir(), homedir());\n const preferred = join(home, \".openclaw\");\n const legacy = join(home, \".clawdbot\");\n const state = process.env.OPENCLAW_STATE_DIR?.trim()\n ? nativeUserPath(process.env.OPENCLAW_STATE_DIR.trim(), home)\n : !existsSync(preferred) && existsSync(legacy) ? legacy : preferred;\n const config = process.env.OPENCLAW_CONFIG_PATH?.trim()\n ? nativeUserPath(process.env.OPENCLAW_CONFIG_PATH.trim(), home)\n : !existsSync(join(state, \"openclaw.json\")) && existsSync(join(state, \"clawdbot.json\")) ? join(state, \"clawdbot.json\") : join(state, \"openclaw.json\");\n return { state, config };\n};\nconst stringList = (value: unknown) => value === undefined || (Array.isArray(value) && value.every((item) => typeof item === \"string\"));\n\nexport const adapter: ConnectAdapter = {\n name: \"openclaw\",\n displayName: \"OpenClaw\",\n category: \"native\",\n docs: \"https://github.com/rohitg00/agentmemory/tree/main/integrations/openclaw\",\n protocolNote: \"→ Installs native recall/capture and bundled skills into the active OpenClaw state directory. MCP tools are opt-in with --with-mcp.\",\n detect: () => existsSync(paths().config) || existsSync(paths().state),\n async install(opts) {\n const { state, config: configPath } = paths();\n const raw = existsSync(configPath) ? readFileSync(configPath, \"utf8\") : \"\";\n let existing: unknown;\n try { existing = raw ? JSON5.parse(raw) : {}; } catch { existing = null; }\n if (!record(existing) || [\"mcp\", \"plugins\", \"skills\"].some((key) => existing[key] !== undefined && !record(existing[key]))) {\n p.log.warn(`OpenClaw config is not a valid JSON/JSON5 object. Left ${configPath} unchanged.`);\n return { kind: \"skipped\", reason: \"invalid-config\" };\n }\n const next = { ...existing };\n const mcp = { ...((next.mcp ?? {}) as Record<string, unknown>) };\n if (mcp.servers !== undefined && !record(mcp.servers)) return { kind: \"skipped\", reason: \"invalid-config\" };\n const servers = { ...((mcp.servers ?? {}) as Record<string, unknown>) };\n const legacyServers = record(next.mcpServers) ? { ...next.mcpServers } : {};\n const legacy = legacyServers.agentmemory;\n const migrateLegacy = record(legacy) && legacy.command === \"npx\" && Array.isArray(legacy.args) && legacy.args.includes(\"@agentmemory/mcp\");\n if (next.mcpServers !== undefined && (!migrateLegacy || Object.keys(legacyServers).some((key) => key !== \"agentmemory\"))) {\n p.log.warn(\"OpenClaw rejects the legacy mcpServers key. Left the file unchanged; migrate custom servers with OpenClaw's native configuration tools first.\");\n return { kind: \"skipped\", reason: \"legacy-config-needs-migration\" };\n }\n if (servers.agentmemory !== undefined && !record(servers.agentmemory) && !(opts.force && opts.withMcp)) {\n p.log.warn(\"OpenClaw's AgentMemory MCP entry is invalid. Repair it or use --force --with-mcp.\");\n return { kind: \"skipped\", reason: \"invalid-entry\" };\n }\n const plugins = { ...((next.plugins ?? {}) as Record<string, unknown>) };\n const skills = { ...((next.skills ?? {}) as Record<string, unknown>) };\n if ([\"entries\", \"slots\"].some((key) => plugins[key] !== undefined && !record(plugins[key])) ||\n (skills.load !== undefined && !record(skills.load)) || !stringList(plugins.allow) || !stringList(plugins.deny)) return { kind: \"skipped\", reason: \"invalid-config\" };\n const entries = { ...((plugins.entries ?? {}) as Record<string, unknown>) };\n const slots = { ...((plugins.slots ?? {}) as Record<string, unknown>) };\n const load = { ...((skills.load ?? {}) as Record<string, unknown>) };\n if (!stringList(load.extraDirs) || (entries.agentmemory !== undefined && !record(entries.agentmemory)) ||\n (slots.memory !== undefined && typeof slots.memory !== \"string\")) return { kind: \"skipped\", reason: \"invalid-config\" };\n if (slots.memory !== undefined && slots.memory !== \"agentmemory\" && !opts.force) {\n p.log.warn(\"OpenClaw already selects another memory plugin. Use --force to select AgentMemory and keep a backup.\");\n return { kind: \"skipped\", reason: \"memory-provider-conflict\" };\n }\n const entry = { ...((entries.agentmemory ?? {}) as Record<string, unknown>) };\n if (entry.hooks !== undefined && !record(entry.hooks)) return { kind: \"skipped\", reason: \"invalid-config\" };\n const hooks = { ...((entry.hooks ?? {}) as Record<string, unknown>) };\n if (plugins.enabled === false || (!opts.force && (entry.enabled === false || hooks.allowConversationAccess === false || (plugins.deny as string[] | undefined)?.includes(\"agentmemory\")))) {\n p.log.warn(\"OpenClaw plugin execution or AgentMemory conversation access is disabled. Enable it explicitly before connecting, or use --force for AgentMemory's own settings.\");\n return { kind: \"skipped\", reason: \"plugin-disabled\" };\n }\n try {\n const root = nativePackageRoot();\n const bundles = [\n prepareNativeBundle(join(root, \"integrations\", \"openclaw\"), join(state, \"extensions\", \"agentmemory\"), \"openclaw-plugin\", [\"plugin.mjs\", \"openclaw.plugin.json\", \"package.json\"], opts.force, join(root, \"plugin\", \"skills\")),\n ];\n if (opts.withMcp || migrateLegacy) {\n p.log.warn(\"MCP exposes all AgentMemory tools against the configured backend. It does not enforce native profile scope; use it only for a trusted, deliberately shared backend.\");\n if (servers.agentmemory === undefined || opts.force) {\n const migrated = migrateLegacy && !opts.force ? { ...legacy } : {};\n const runtime = nativeMcpEntry(root);\n const env = { ...(runtime.env as Record<string, string>), ...(record(migrated.env) ? migrated.env : {}) } as Record<string, unknown>;\n for (const [key, value] of Object.entries(env)) {\n if ((key === \"AGENTMEMORY_URL\" && value === \"${AGENTMEMORY_URL:-http://localhost:3111}\") ||\n (key === \"AGENTMEMORY_SECRET\" && value === \"${AGENTMEMORY_SECRET:-}\")) delete env[key];\n if (key === \"AGENTMEMORY_TOOLS\" && value === \"${AGENTMEMORY_TOOLS:-all}\") env[key] = \"all\";\n }\n servers.agentmemory = { ...migrated, ...runtime, transport: \"stdio\", env };\n } else p.log.info(\"Preserved the existing AgentMemory MCP entry. After moving the installed package, review its settings and reconnect with --with-mcp --force to refresh its runtime path.\");\n if (migrateLegacy) delete next.mcpServers;\n next.mcp = { ...mcp, servers };\n }\n entries.agentmemory = { ...entry, enabled: true, hooks: { ...hooks, allowConversationAccess: true } };\n plugins.entries = entries;\n plugins.slots = { ...slots, memory: \"agentmemory\" };\n if (plugins.allow !== undefined) plugins.allow = [...new Set([...(plugins.allow as string[]), \"agentmemory\"])];\n if ((plugins.deny as string[] | undefined)?.includes(\"agentmemory\")) plugins.deny = (plugins.deny as string[]).filter((name) => name !== \"agentmemory\");\n next.plugins = plugins;\n const configText = JSON.stringify(next) === JSON.stringify(existing) ? raw : JSON.stringify(next, null, 2) + \"\\n\";\n if (opts.dryRun) {\n p.log.info(`[dry-run] Would install native plugin and skills, then activate AgentMemory in ${configPath}`);\n return { kind: \"installed\", mutatedPath: configPath };\n }\n const unchanged = !bundles.some((bundle) => bundle.changed) && configText === raw;\n if (unchanged) { logAlreadyWired(this.displayName, configPath); return { kind: \"already-wired\", mutatedPath: configPath }; }\n const backupPath = installNativeBundles(bundles, configPath, configText);\n if (backupPath) logBackup(backupPath);\n logInstalled(this.displayName, configPath);\n p.log.info(\"Start AgentMemory and verify capture and recall in a new OpenClaw session. Skills that call memory tools require --with-mcp; authentication and connectivity are not yet verified.\");\n return { kind: \"installed\", mutatedPath: configPath, ...(backupPath ? { backupPath } : {}) };\n } catch (error) {\n p.log.warn(error instanceof Error ? error.message : \"OpenClaw installation failed; configuration was not activated.\");\n return { kind: \"skipped\", reason: \"native-install-failed\" };\n }\n },\n};\n","import { existsSync, mkdirSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { dirname, join } from \"node:path\";\nimport * as p from \"@clack/prompts\";\nimport type { ConnectAdapter, ConnectOptions, ConnectResult } from \"./types.js\";\nimport {\n backupFile,\n logAlreadyWired,\n logBackup,\n logInstalled,\n readJsonSafe,\n writeJsonAtomic,\n} from \"./util.js\";\n\n// OpenCode does not use the standard `mcpServers` block. Its config is a\n// top-level `mcp` key whose entries carry `type`, `command` as an array,\n// and `enabled` (docs: README \"OpenCode (MCP only)\"). So it needs its own\n// adapter rather than createJsonMcpAdapter.\n\nconst CONFIG_PATH = join(homedir(), \".config\", \"opencode\", \"opencode.json\");\nconst DETECT_DIR = join(homedir(), \".config\", \"opencode\");\n\n// No `environment` block: OpenCode does not expand shell-style\n// `${VAR:-default}` values, and writing them literally would override the\n// user's real shell AGENTMEMORY_URL with an unexpanded string. The stdio\n// child inherits the shell environment (an exported AGENTMEMORY_URL /\n// AGENTMEMORY_SECRET still reaches the server), and the @agentmemory/mcp\n// shim defaults unset vars (URL -> localhost:3111, no secret, all tools).\nconst OPENCODE_ENTRY = {\n type: \"local\",\n command: [\"npx\", \"-y\", \"@agentmemory/mcp\"],\n enabled: true,\n};\n\ntype OpencodeConfig = Record<string, unknown>;\ntype McpEntry = Record<string, unknown>;\n\nfunction entryMatches(entry: unknown): boolean {\n if (!entry || typeof entry !== \"object\") return false;\n const command = (entry as McpEntry)[\"command\"];\n return Array.isArray(command) && command.includes(\"@agentmemory/mcp\");\n}\n\nexport const adapter: ConnectAdapter = {\n name: \"opencode\",\n displayName: \"OpenCode\",\n category: \"mcp\",\n docs: \"https://github.com/rohitg00/agentmemory#other-agents\",\n protocolNote:\n \"Using MCP via ~/.config/opencode/opencode.json (top-level `mcp` key). For full auto-capture, also install the bundled plugin in plugin/opencode/.\",\n\n detect(): boolean {\n return existsSync(DETECT_DIR);\n },\n\n async install(opts: ConnectOptions): Promise<ConnectResult> {\n const existing = readJsonSafe<OpencodeConfig>(CONFIG_PATH);\n const next: OpencodeConfig = existing ? { ...existing } : {};\n const existingMcp = next[\"mcp\"];\n const mcp: Record<string, McpEntry> =\n existingMcp &&\n typeof existingMcp === \"object\" &&\n !Array.isArray(existingMcp)\n ? { ...(existingMcp as Record<string, McpEntry>) }\n : {};\n\n const alreadyHas = entryMatches(mcp[\"agentmemory\"]);\n if (alreadyHas && !opts.force) {\n logAlreadyWired(this.displayName, CONFIG_PATH);\n return { kind: \"already-wired\", mutatedPath: CONFIG_PATH };\n }\n\n if (opts.dryRun) {\n p.log.info(\n `[dry-run] Would ${alreadyHas ? \"overwrite\" : \"add\"} mcp.agentmemory in ${CONFIG_PATH}`,\n );\n return { kind: \"installed\", mutatedPath: CONFIG_PATH };\n }\n\n let backupPath: string | undefined;\n if (existsSync(CONFIG_PATH)) {\n backupPath = backupFile(CONFIG_PATH, this.name);\n logBackup(backupPath);\n } else {\n mkdirSync(dirname(CONFIG_PATH), { recursive: true });\n }\n\n mcp[\"agentmemory\"] = { ...OPENCODE_ENTRY };\n next[\"mcp\"] = mcp;\n writeJsonAtomic(CONFIG_PATH, next);\n\n const verify = readJsonSafe<OpencodeConfig>(CONFIG_PATH);\n const verifyMcp = verify?.[\"mcp\"] as Record<string, McpEntry> | undefined;\n if (!entryMatches(verifyMcp?.[\"agentmemory\"])) {\n p.log.error(\n `Verification failed: ${CONFIG_PATH} did not contain mcp.agentmemory after write.`,\n );\n return { kind: \"skipped\", reason: \"verification-failed\" };\n }\n\n logInstalled(this.displayName, CONFIG_PATH);\n return {\n kind: \"installed\",\n mutatedPath: CONFIG_PATH,\n ...(backupPath !== undefined && { backupPath }),\n };\n },\n};\n","import { existsSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { join } from \"node:path\";\nimport * as p from \"@clack/prompts\";\nimport type { ConnectAdapter, ConnectOptions, ConnectResult } from \"./types.js\";\n\nconst OPENHUMAN_DIR = join(homedir(), \".openhuman\");\nconst DOCS = \"https://github.com/tinyhumansai/openhuman\";\n\nexport const adapter: ConnectAdapter = {\n name: \"openhuman\",\n displayName: \"OpenHuman\",\n category: \"native\",\n docs: DOCS,\n protocolNote:\n \"→ Using native hooks (REST API at :3111). MCP not required.\",\n\n detect(): boolean {\n return existsSync(OPENHUMAN_DIR);\n },\n\n async install(_opts: ConnectOptions): Promise<ConnectResult> {\n p.log.warn(\n \"OpenHuman integration is not yet automated. No `integrations/openhuman/` folder exists in the agentmemory repo today.\",\n );\n p.note(\n [\n \"OpenHuman is a Memory-trait host. The expected wiring is the REST\",\n \"proxy at http://localhost:3111 plus an OpenHuman-side Memory trait\",\n \"impl. Once integrations/openhuman/ lands in agentmemory we'll wire\",\n \"this up automatically.\",\n \"\",\n `Tracking: ${DOCS}`,\n ].join(\"\\n\"),\n \"OpenHuman manual install\",\n );\n return {\n kind: \"stub\",\n reason: \"no-integration-folder-yet\",\n };\n },\n};\n","import { existsSync, readFileSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { join, resolve } from \"node:path\";\nimport * as p from \"@clack/prompts\";\nimport { Document, parseDocument } from \"yaml\";\nimport type { ConnectAdapter } from \"./types.js\";\nimport { installNativeBundles, nativeMcpEntry, nativePackageRoot, nativeUserPath, prepareNativeBundle, record } from \"./native-install.js\";\nimport { logAlreadyWired, logBackup, logInstalled } from \"./util.js\";\n\nexport function ompPaths() {\n const root = join(homedir(), process.env.PI_CONFIG_DIR || \".omp\");\n const profile = (process.env.OMP_PROFILE ?? process.env.PI_PROFILE ?? \"\").trim();\n if (profile && profile !== \"default\" && (!/^[a-z0-9][a-z0-9._-]{0,63}$/.test(profile) || profile.endsWith(\".\") || /^(?:con|prn|aux|nul|com[0-9]|lpt[0-9])(?:\\..*)?$/i.test(profile))) {\n throw new Error(\"Invalid OMP profile; use the same valid OMP_PROFILE as Oh My Pi.\");\n }\n const configRoot = profile && profile !== \"default\" ? join(root, \"profiles\", profile) : root;\n const agent = configRoot !== root ? join(configRoot, \"agent\") : process.env.PI_CODING_AGENT_DIR ? resolve(process.env.PI_CODING_AGENT_DIR) : join(root, \"agent\");\n return { root: configRoot, agent, profile: profile && profile !== \"default\" ? profile : undefined };\n}\n\nexport const adapter: ConnectAdapter = {\n name: \"omp\",\n displayName: \"Oh My Pi\",\n category: \"native\",\n docs: \"https://github.com/rohitg00/agentmemory/tree/main/integrations/omp\",\n protocolNote: \"Installs native recall, capture and skills. Add --with-mcp for the full memory toolset.\",\n detect: () => { try { const paths = ompPaths(); return existsSync(paths.agent) || existsSync(paths.root); } catch { return false; } },\n async install(opts) {\n try {\n const paths = ompPaths();\n const target = join(paths.agent, \"agentmemory\");\n const config = join(paths.agent, existsSync(join(paths.agent, \"config.yml\")) || !existsSync(join(paths.agent, \"config.yaml\")) ? \"config.yml\" : \"config.yaml\");\n const raw = existsSync(config) ? readFileSync(config, \"utf8\") : \"\";\n const legacy = join(paths.agent, \"settings.json\");\n const doc = !existsSync(config) && existsSync(legacy) ? new Document(JSON.parse(readFileSync(legacy, \"utf8\"))) : parseDocument(raw);\n const existing = doc.contents === null ? {} : doc.toJS({ maxAliasCount: 100 });\n if (doc.errors.length || !record(existing) || (existing.extensions !== undefined && (!Array.isArray(existing.extensions) || !existing.extensions.every(item => typeof item === \"string\")))) {\n throw new Error(`Invalid OMP configuration; left ${config} unchanged.`);\n }\n const extensions = (existing.extensions ?? []) as string[];\n const oldRoots = [\n ...extensions.map(value => nativeUserPath(value, homedir())).filter(value => value !== target),\n join(paths.root, \"plugins/node_modules/agentmemory-omp-extension\"),\n join(paths.agent, \"plugins/node_modules/agentmemory-omp-extension\"),\n join(process.cwd(), \".omp/plugins/node_modules/agentmemory-omp-extension\"),\n join(paths.agent, \"extensions/agentmemory\"),\n ];\n if (process.platform === \"linux\") {\n const dataRoot = join(process.env.XDG_DATA_HOME || join(homedir(), \".local/share\"), \"omp\");\n oldRoots.push(join(dataRoot, ...(paths.profile ? [\"profiles\", paths.profile] : []), \"plugins/node_modules/agentmemory-omp-extension\"));\n }\n for (const old of oldRoots) {\n const manifest = join(old, \"package.json\");\n if (existsSync(manifest) && JSON.parse(readFileSync(manifest, \"utf8\")).name === \"agentmemory-omp-extension\") {\n throw new Error(`Another OMP AgentMemory extension exists at ${old}. Uninstall it with 'omp plugin uninstall agentmemory-omp-extension' or remove its extensions entry before reconnecting, to prevent duplicate capture.`);\n }\n }\n const root = nativePackageRoot();\n const mcpPath = join(target, \".mcp.json\");\n const extra: Record<string, string> = {};\n if (existsSync(mcpPath)) extra[\".mcp.json\"] = readFileSync(mcpPath, \"utf8\");\n let userOwnsMcp = false;\n if (opts.withMcp || existsSync(mcpPath)) {\n const nativeMcpPath = join(paths.agent, \"mcp.json\");\n const nativeMcp = existsSync(nativeMcpPath) ? JSON.parse(readFileSync(nativeMcpPath, \"utf8\")) : {};\n userOwnsMcp = nativeMcp.mcpServers?.agentmemory !== undefined;\n if (userOwnsMcp) {\n delete extra[\".mcp.json\"];\n p.log.info(\"Preserved the existing AgentMemory MCP server in OMP's mcp.json.\");\n } else if (opts.withMcp) extra[\".mcp.json\"] = JSON.stringify({ mcpServers: { agentmemory: nativeMcpEntry(root) } }, null, 2) + \"\\n\";\n }\n const bundle = prepareNativeBundle(join(root, \"integrations/omp\"), target, \"omp-extension\", [\"package.json\", \"dist/index.mjs\"], opts.force, join(root, \"plugin/skills\"), extra);\n if (userOwnsMcp && existsSync(mcpPath) && !bundle.previous[\".mcp.json\"] && JSON.parse(readFileSync(mcpPath, \"utf8\")).mcpServers?.agentmemory !== undefined) throw new Error(`Unmanaged ${mcpPath} conflicts with OMP's mcp.json. Remove the duplicate AgentMemory configuration before reconnecting.`);\n if (!extensions.includes(target)) doc.set(\"extensions\", [...extensions, target]);\n const text = doc.toString();\n if (opts.dryRun) {\n p.log.info(`[dry-run] Would install OMP's extension and skills into ${target}, then register it in ${config}.`);\n return { kind: \"installed\", mutatedPath: config };\n }\n const unchanged = !bundle.changed && text === raw;\n const backupPath = unchanged ? undefined : installNativeBundles([bundle], config, text);\n if (backupPath) logBackup(backupPath);\n if (unchanged) logAlreadyWired(this.displayName, config); else logInstalled(this.displayName, config);\n p.log.info(\"Restart OMP and run /agentmemory-status. Native save/search work without MCP; the other bundled skills require --with-mcp. Project extensions arrays override this user setting: include the installed directory there when overriding extensions.\");\n return unchanged ? { kind: \"already-wired\", mutatedPath: config } : { kind: \"installed\", mutatedPath: config, ...(backupPath ? { backupPath } : {}) };\n } catch (error) {\n p.log.warn(error instanceof Error ? error.message : \"OMP installation failed.\");\n return { kind: \"skipped\", reason: \"native-install-failed\" };\n }\n },\n};\n","import { createHash } from \"node:crypto\";\nimport { existsSync, lstatSync, readFileSync, rmSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { dirname, join, resolve } from \"node:path\";\nimport * as p from \"@clack/prompts\";\nimport type { ConnectAdapter } from \"./types.js\";\nimport { installNativeBundles, nativeMcpEntry, nativePackageRoot, nativeUserPath, prepareNativeBundle, record } from \"./native-install.js\";\nimport { logAlreadyWired, logBackup, logInstalled } from \"./util.js\";\n\nconst agentDir = () => process.env.PI_CODING_AGENT_DIR ? nativeUserPath(process.env.PI_CODING_AGENT_DIR, homedir()) : join(homedir(), \".pi/agent\");\n\nconst entryHash = (entry: unknown) => createHash(\"sha256\").update(JSON.stringify(entry)).digest(\"hex\");\n\nfunction readConfig(path: string): Record<string, unknown> {\n if (!existsSync(path)) return {};\n if (lstatSync(path).isSymbolicLink()) throw new Error(`Pi configuration is a symbolic link; left ${path} unchanged.`);\n const value: unknown = JSON.parse(readFileSync(path, \"utf8\"));\n if (!record(value)) throw new Error(`Invalid Pi configuration; left ${path} unchanged.`);\n return value;\n}\n\nfunction hasPackage(config: Record<string, unknown>, configDir: string, target: string): boolean {\n if (config.packages === undefined) return false;\n if (!Array.isArray(config.packages)) throw new Error(\"Pi settings.packages must be an array.\");\n return config.packages.some(item => {\n const source = typeof item === \"string\" ? item : record(item) ? item.source : undefined;\n if (typeof source !== \"string\") throw new Error(\"Invalid Pi package entry; configuration was preserved.\");\n if (/^npm:@agentmemory\\/pi(?:@|$)/.test(source)) return true;\n const path = source.startsWith(\"~\") ? nativeUserPath(source, homedir()) : resolve(configDir, source);\n if (path === target) return false;\n const manifest = join(path, \"package.json\");\n return existsSync(manifest) && JSON.parse(readFileSync(manifest, \"utf8\")).name === \"@agentmemory/pi\";\n });\n}\n\nexport const adapter: ConnectAdapter = {\n name: \"pi\", displayName: \"Pi\", category: \"native\",\n docs: \"https://github.com/rohitg00/agentmemory/tree/main/integrations/pi\",\n protocolNote: \"Installs native recall, capture and skills. Add --with-mcp for the full memory toolset.\",\n detect: () => existsSync(agentDir()) || existsSync(join(homedir(), \".pi\")),\n async install(opts) {\n try {\n const dir = agentDir();\n const target = join(dir, \"agentmemory\");\n const configPath = join(dir, \"settings.json\");\n const config = readConfig(configPath);\n const projectPath = join(process.cwd(), \".pi/settings.json\");\n const packaged = hasPackage(config, dir, target);\n const projectConfig = readConfig(projectPath);\n if (!packaged && hasPackage(projectConfig, dirname(projectPath), target)) throw new Error(\"AgentMemory is configured as a project Pi package. Remove that package entry before installing globally, or keep using the project installation.\");\n for (const [settings, base] of [[config, dir], [projectConfig, dirname(projectPath)]] as const) {\n if (!Array.isArray(settings.extensions)) continue;\n for (const entry of settings.extensions) {\n if (typeof entry !== \"string\") continue;\n const path = entry.startsWith(\"~\") ? nativeUserPath(entry, homedir()) : resolve(base, entry);\n const manifest = join(/\\.[cm]?[jt]s$/.test(path) ? dirname(path) : path, \"package.json\");\n if (existsSync(manifest) && JSON.parse(readFileSync(manifest, \"utf8\")).name === \"@agentmemory/pi\") throw new Error(\"Remove the explicit AgentMemory extensions entry before connecting; the package already declares its extension.\");\n }\n }\n const legacy = join(dir, \"extensions/agentmemory\");\n if (existsSync(legacy)) throw new Error(`Move the old copied extension at ${legacy} outside Pi's extensions directory before reconnecting, to prevent duplicate capture. Keep it as a backup.`);\n const root = nativePackageRoot();\n const bundle = packaged ? undefined : prepareNativeBundle(join(root, \"integrations/pi\"), target, \"pi-extension\", [\"package.json\", \"dist/index.mjs\"], opts.force, join(root, \"plugin/skills\"));\n if (packaged) p.log.info(\"Using the existing AgentMemory Pi package; no second extension was installed.\");\n else {\n const packages = (config.packages ?? []) as unknown[];\n if (!packages.some(item => (typeof item === \"string\" ? item : record(item) ? item.source : undefined) === target)) config.packages = [...packages, target];\n }\n const text = JSON.stringify(config, null, 2) + \"\\n\";\n const raw = existsSync(configPath) ? readFileSync(configPath, \"utf8\") : undefined;\n const mcpPath = join(dir, \"mcp.json\");\n const mcpRaw = existsSync(mcpPath) ? readFileSync(mcpPath, \"utf8\") : undefined;\n let mcpText = mcpRaw;\n if (opts.withMcp) {\n const mcp = readConfig(mcpPath);\n if (mcp.mcpServers !== undefined && !record(mcp.mcpServers)) throw new Error(\"Invalid Pi mcpServers configuration; nothing was changed.\");\n const servers = (mcp.mcpServers ?? {}) as Record<string, unknown>;\n const managed = servers.agentmemory !== undefined && record(mcp._agentmemoryConnector) && mcp._agentmemoryConnector.entryHash === entryHash(servers.agentmemory);\n if (servers.agentmemory !== undefined && !managed) {\n p.log.info(\"Preserved the existing AgentMemory MCP server. Project MCP settings apply only to trusted projects.\");\n } else {\n const entry = { ...nativeMcpEntry(root), exposure: \"direct\" };\n mcpText = JSON.stringify({ ...mcp, mcpServers: { ...servers, agentmemory: entry }, _agentmemoryConnector: { entryHash: entryHash(entry) } }, null, 2) + \"\\n\";\n }\n }\n if (opts.dryRun) {\n p.log.info(`[dry-run] Would configure Pi in ${dir}.`);\n return { kind: \"installed\", mutatedPath: configPath };\n }\n const configChanged = !packaged && (bundle!.changed || text !== raw);\n const mcpChanged = mcpText !== mcpRaw;\n let backupPath: string | undefined;\n if (mcpChanged) {\n backupPath = installNativeBundles([], mcpPath, mcpText!);\n }\n try {\n if (configChanged) backupPath = installNativeBundles([bundle!], configPath, text) ?? backupPath;\n } catch (error) {\n if (mcpChanged) {\n if (mcpRaw === undefined) rmSync(mcpPath, { force: true });\n else installNativeBundles([], mcpPath, mcpRaw);\n }\n throw error;\n }\n if (backupPath) logBackup(backupPath);\n const changed = configChanged || mcpChanged;\n if (changed) logInstalled(this.displayName, dir); else logAlreadyWired(this.displayName, dir);\n p.log.info(\"Restart Pi or /reload, then /agentmemory-status. Skills appear as /skill:<name>; the wider workflows require MCP. Reconnect after upgrading AgentMemory to refresh bundled runtime paths.\");\n return { kind: changed ? \"installed\" : \"already-wired\", mutatedPath: configPath, ...(backupPath ? { backupPath } : {}) };\n } catch (error) {\n p.log.warn(error instanceof Error ? error.message : \"Pi installation failed.\");\n return { kind: \"skipped\", reason: \"native-install-failed\" };\n }\n },\n};\n","import { homedir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { createJsonMcpAdapter } from \"./json-mcp-adapter.js\";\n\n// Qwen Code stores its settings (mcpServers + hooks) in\n// ~/.qwen/settings.json. Schema for mcpServers matches Claude Code's\n// shape, so the shared JSON adapter handles the wiring.\n// Source: qwenlm.github.io/qwen-code-docs/en/users/features/mcp\nexport const adapter = createJsonMcpAdapter({\n name: \"qwen\",\n displayName: \"Qwen Code\",\n detectDir: join(homedir(), \".qwen\"),\n configPath: join(homedir(), \".qwen\", \"settings.json\"),\n docs: \"https://github.com/rohitg00/agentmemory#other-agents\",\n protocolNote:\n \"→ Using MCP via ~/.qwen/settings.json. Qwen Code's hook system can also be wired separately — see docs.\",\n});\n","import { homedir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { createJsonMcpAdapter } from \"./json-mcp-adapter.js\";\n\n// Warp stores MCP server config at ~/.warp/.mcp.json with the\n// canonical `mcpServers` wrapper — identical schema to Claude Code.\n// Warp also auto-discovers skills from .claude/skills/ so the\n// agentmemory plugin's 8 skills are surfaced natively once the\n// Claude Code plugin is installed.\n// Source: docs.warp.dev/agent-platform/capabilities/mcp/\nexport const adapter = createJsonMcpAdapter({\n name: \"warp\",\n displayName: \"Warp\",\n detectDir: join(homedir(), \".warp\"),\n configPath: join(homedir(), \".warp\", \".mcp.json\"),\n docs: \"https://github.com/rohitg00/agentmemory#other-agents\",\n protocolNote:\n \"→ Using MCP via ~/.warp/.mcp.json. Skills auto-discover from .claude/skills/ if the Claude Code plugin is also installed.\",\n});\n","import { homedir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { createJsonMcpAdapter } from \"./json-mcp-adapter.js\";\n\n// Zed stores its settings (including MCP servers) under \"context_servers\"\n// in settings.json — NOT \"mcpServers\". User config lives at\n// ~/.config/zed/settings.json on all platforms (Zed uses the XDG path\n// even on macOS; ~/Library/Application Support/Zed/ holds runtime data\n// like the database + cached language servers, not the config).\n// Source: zed.dev/docs/ai/mcp + zed.dev/docs/configuring-zed\nconst zedConfigDir = join(homedir(), \".config\", \"zed\");\n\nexport const adapter = createJsonMcpAdapter({\n name: \"zed\",\n displayName: \"Zed\",\n detectDir: zedConfigDir,\n configPath: join(zedConfigDir, \"settings.json\"),\n wrapperKey: \"context_servers\",\n docs: \"https://github.com/rohitg00/agentmemory#other-agents\",\n protocolNote:\n \"→ Using MCP via ~/.config/zed/settings.json (key: context_servers).\",\n});\n","import { platform } from \"node:os\";\nimport * as p from \"@clack/prompts\";\nimport pc from \"picocolors\";\nimport type { ConnectAdapter, ConnectOptions, ConnectResult } from \"./types.js\";\nimport { writeGuideline } from \"./guidelines.js\";\nimport { adapter as antigravity } from \"./antigravity.js\";\nimport { adapter as antigravityCli } from \"./antigravity-cli.js\";\nimport { adapter as claudeCode } from \"./claude-code.js\";\nimport { adapter as cline } from \"./cline.js\";\nimport { adapter as copilotCli } from \"./copilot-cli.js\";\nimport { adapter as codex } from \"./codex.js\";\nimport { adapter as continueDev } from \"./continue.js\";\nimport { adapter as cursor } from \"./cursor.js\";\nimport { adapter as devin } from \"./devin.js\";\nimport { adapter as droid } from \"./droid.js\";\nimport { adapter as dsh } from \"./dsh.js\";\nimport { adapter as geminiCli } from \"./gemini-cli.js\";\nimport { adapter as hermes } from \"./hermes.js\";\nimport { adapter as kiro } from \"./kiro.js\";\nimport { adapter as openclaw } from \"./openclaw.js\";\nimport { adapter as opencode } from \"./opencode.js\";\nimport { adapter as openhuman } from \"./openhuman.js\";\nimport { adapter as omp } from \"./omp.js\";\nimport { adapter as pi } from \"./pi.js\";\nimport { adapter as qwen } from \"./qwen.js\";\nimport { adapter as warp } from \"./warp.js\";\nimport { adapter as zed } from \"./zed.js\";\n\nexport const ADAPTERS: readonly ConnectAdapter[] = [\n claudeCode,\n copilotCli,\n codex,\n cursor,\n devin,\n geminiCli,\n qwen,\n antigravity,\n antigravityCli,\n kiro,\n warp,\n cline,\n continueDev,\n zed,\n droid,\n dsh,\n opencode,\n openclaw,\n hermes,\n pi,\n omp,\n openhuman,\n];\n\nexport function resolveAdapter(name: string): ConnectAdapter | null {\n const lower = name.toLowerCase();\n return ADAPTERS.find((a) => a.name === lower) ?? null;\n}\n\nexport function knownAgents(): string[] {\n return ADAPTERS.map((a) => a.name);\n}\n\nfunction parseFlags(args: string[]): {\n dryRun: boolean;\n force: boolean;\n all: boolean;\n withHooks: boolean;\n withMcp: boolean;\n guidelines: boolean;\n positional: string[];\n} {\n const positional: string[] = [];\n let dryRun = false;\n let force = false;\n let all = false;\n let withHooks = false;\n let withMcp = false;\n let guidelines = true; // memory-usage guideline is written by default\n for (const a of args) {\n if (a === \"--dry-run\") dryRun = true;\n else if (a === \"--force\") force = true;\n else if (a === \"--all\") all = true;\n else if (a === \"--with-hooks\") withHooks = true;\n else if (a === \"--with-mcp\") withMcp = true;\n else if (a === \"--no-guidelines\") guidelines = false;\n else if (!a.startsWith(\"-\")) positional.push(a);\n }\n return { dryRun, force, all, withHooks, withMcp, guidelines, positional };\n}\n\nexport async function runAdapter(\n adapter: ConnectAdapter,\n opts: ConnectOptions,\n): Promise<ConnectResult> {\n if (!adapter.detect()) {\n p.log.warn(\n `${adapter.displayName}: not detected on this machine (skipping).${adapter.docs ? ` Docs: ${adapter.docs}` : \"\"}`,\n );\n return { kind: \"skipped\", reason: \"not-detected\" };\n }\n p.log.step(`Wiring ${adapter.displayName}…`);\n if (adapter.protocolNote) {\n p.log.message(adapter.protocolNote);\n }\n try {\n const result = await adapter.install(opts);\n // After MCP/hooks are wired, activate memory for hook-less agents by\n // writing a memory-usage guideline into their native rules file. Best\n // effort: never fail the connect over the guideline.\n if (\n opts.guidelines !== false &&\n (result.kind === \"installed\" || result.kind === \"already-wired\")\n ) {\n try {\n const g = writeGuideline(adapter.name, {\n cwd: process.cwd(),\n dryRun: opts.dryRun,\n });\n if (g.kind === \"written\") {\n p.log.message(\n ` ${pc.dim(\"guideline\")} ${g.scope} → ${g.path} (memory auto-use)`,\n );\n } else if (g.kind === \"would-write\") {\n p.log.message(` ${pc.dim(\"[dry-run] guideline\")} → ${g.path}`);\n }\n } catch (gerr) {\n p.log.warn(\n `${adapter.displayName}: guideline not written (${gerr instanceof Error ? gerr.message : String(gerr)})`,\n );\n }\n }\n return result;\n } catch (err) {\n p.log.error(\n `${adapter.displayName}: ${err instanceof Error ? err.message : String(err)}`,\n );\n return { kind: \"skipped\", reason: \"exception\" };\n }\n}\n\nexport async function runConnect(args: string[]): Promise<void> {\n const { dryRun, force, all, withHooks, withMcp, guidelines, positional } =\n parseFlags(args);\n const allowWindowsAdapter =\n positional.length === 1 && positional[0]?.toLowerCase() === \"copilot-cli\";\n if (platform() === \"win32\" && !allowWindowsAdapter) {\n p.intro(\"agentmemory connect\");\n p.log.warn(\n \"Windows: automated `connect` is not supported yet. See https://github.com/rohitg00/agentmemory#other-agents for manual install steps.\",\n );\n p.outro(\"Windows: manual install required — see docs\");\n return;\n }\n\n const opts: ConnectOptions = { dryRun, force, withHooks, withMcp, guidelines };\n\n p.intro(\"agentmemory connect\");\n\n if (positional.length === 0 && !all) {\n const detected = ADAPTERS.filter((a) => a.detect());\n if (detected.length === 0) {\n p.log.error(\"No supported agents detected on this machine.\");\n p.outro(`Supported: ${knownAgents().join(\", \")}`);\n process.exit(1);\n }\n const picked = await p.multiselect<string>({\n message: \"Wire agentmemory into which agents?\",\n options: detected.map((a) => ({ value: a.name, label: a.displayName })),\n required: true,\n });\n if (p.isCancel(picked)) {\n p.cancel(\"Cancelled.\");\n return;\n }\n const results: { name: string; result: ConnectResult }[] = [];\n for (const name of picked as string[]) {\n const adapter = resolveAdapter(name);\n if (!adapter) continue;\n results.push({ name, result: await runAdapter(adapter, opts) });\n }\n summarize(results);\n return;\n }\n\n if (all) {\n const detected = ADAPTERS.filter((a) => a.detect());\n if (detected.length === 0) {\n p.log.error(\"No supported agents detected on this machine.\");\n process.exit(1);\n }\n const results: { name: string; result: ConnectResult }[] = [];\n for (const adapter of detected) {\n results.push({\n name: adapter.name,\n result: await runAdapter(adapter, opts),\n });\n }\n summarize(results);\n return;\n }\n\n const agentName = positional[0]!;\n const adapter = resolveAdapter(agentName);\n if (!adapter) {\n p.log.error(`Unknown agent: ${agentName}`);\n p.outro(`Supported: ${knownAgents().join(\", \")}`);\n process.exit(1);\n }\n\n const result = await runAdapter(adapter, opts);\n summarize([{ name: agentName, result }]);\n if (result.kind === \"skipped\" && (result as { reason: string }).reason !== \"not-detected\") {\n process.exit(1);\n }\n}\n\nfunction summarize(\n results: { name: string; result: ConnectResult }[],\n): void {\n const lines = results.map(({ name, result }) => {\n switch (result.kind) {\n case \"installed\":\n return ` ${pc.green(\"✓\")} ${pc.bold(name)}${result.mutatedPath ? ` ${pc.dim(\"→\")} ${pc.cyan(result.mutatedPath)}` : \"\"}`;\n case \"already-wired\":\n return ` ${pc.green(\"✓\")} ${pc.bold(name)} ${pc.dim(\"(already wired)\")}`;\n case \"stub\":\n return ` ${pc.yellow(\"⚠\")} ${pc.bold(name)} ${pc.yellow(`(manual install required: ${result.reason})`)}`;\n case \"skipped\":\n return ` ${pc.red(\"✗\")} ${pc.bold(name)} ${pc.dim(`(skipped: ${result.reason})`)}`;\n }\n });\n p.note(lines.join(\"\\n\"), \"summary\");\n\n const stubs = results.filter((r) => r.result.kind === \"stub\");\n if (stubs.length > 0) {\n p.log.info(\n `${stubs.length} agent(s) require manual install — see docs links above.`,\n );\n }\n\n const wiredAny = results.some(\n (r) => ![\"hermes\", \"hermes-agent\", \"openclaw\", \"claw\", \"omp\", \"pi\"].includes(r.name) && (r.result.kind === \"installed\" || r.result.kind === \"already-wired\"),\n );\n if (wiredAny) {\n p.log.info(\n \"Next: install agentmemory's 17 skills into the same agent(s) so they know when to call the tools:\\n npx skills@1.7.1 add rohitg00/agentmemory -y\",\n );\n }\n\n p.outro(\"Restart any wired agent (or open a new session) to pick up agentmemory.\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAYA,MAAa,wBAAwB;CACnC,SAAS;CACT,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,CAAC,GAAG,GAAG,KAAK,OAAO,YAAY,KAAK;GACvH,KAAK,gBACH,QAAO,KAAK,GAAG,MAAM,IAAI,CAAC,GAAG,GAAG,KAAK,KAAK,CAAC,GAAG,GAAG,IAAI,kBAAkB;GACzE,KAAK,OACH,QAAO,KAAK,GAAG,OAAO,IAAI,CAAC,GAAG,GAAG,KAAK,KAAK,CAAC,GAAG,GAAG,OAAO,6BAA6B,OAAO,OAAO,GAAG;GACzG,KAAK,UACH,QAAO,KAAK,GAAG,IAAI,IAAI,CAAC,GAAG,GAAG,KAAK,KAAK,CAAC,GAAG,GAAG,IAAI,aAAa,OAAO,OAAO,GAAG;;GAErF;AACF,GAAE,KAAK,MAAM,KAAK,KAAK,EAAE,UAAU;CAEnC,MAAM,QAAQ,QAAQ,QAAQ,MAAM,EAAE,OAAO,SAAS,OAAO;AAC7D,KAAI,MAAM,SAAS,EACjB,GAAE,IAAI,KACJ,GAAG,MAAM,OAAO,0DACjB;AAMH,KAHiB,QAAQ,MACtB,MAAM,CAAC;EAAC;EAAU;EAAgB;EAAY;EAAQ;EAAO;EAAK,CAAC,SAAS,EAAE,KAAK,KAAK,EAAE,OAAO,SAAS,eAAe,EAAE,OAAO,SAAS,iBAElI,CACV,GAAE,IAAI,KACJ,oJACD;AAGH,GAAE,MAAM,0EAA0E"}
@@ -0,0 +1,25 @@
1
+ //#region src/functions/privacy.d.ts
2
+ declare function stripPrivateData(input: string): string;
3
+ //#endregion
4
+ //#region src/hooks/_capture.d.ts
5
+ declare const REST_URL: any;
6
+ type CaptureOutcome = "delivered" | "duplicate" | "rejected" | "spooled" | "dropped";
7
+ interface ObserveBody {
8
+ hookType: string;
9
+ sessionId: string;
10
+ project: string;
11
+ cwd: string;
12
+ timestamp: string;
13
+ data: unknown;
14
+ eventId?: string;
15
+ }
16
+ declare function authHeaders(): Record<string, string>;
17
+ declare function withEventId(body: ObserveBody, host: Record<string, unknown>, content?: unknown, options?: {
18
+ stable?: boolean;
19
+ }): ObserveBody;
20
+ declare function captureObservation(body: ObserveBody, timeoutMs: number): Promise<CaptureOutcome>;
21
+ declare function isDrainChild(): boolean;
22
+ declare function runDrainChild(): Promise<void>;
23
+ //#endregion
24
+ export { CaptureOutcome, ObserveBody, REST_URL, authHeaders, captureObservation, isDrainChild, runDrainChild, stripPrivateData, withEventId };
25
+ //# sourceMappingURL=_capture.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_capture.d.mts","names":[],"sources":["../../src/functions/privacy.ts","../../src/hooks/_capture.ts"],"mappings":";iBA2BgB,gBAAA,CAAiB,KAAA;;;cCTpB,QAAA;AAAA,KAOD,cAAA;AAAA,UAEK,WAAA;EACf,QAAA;EACA,SAAA;EACA,OAAA;EACA,GAAA;EACA,SAAA;EACA,IAAA;EACA,OAAA;AAAA;AAAA,iBAGc,WAAA,CAAA,GAAe,MAAA;AAAA,iBAMf,WAAA,CACd,IAAA,EAAM,WAAA,EACN,IAAA,EAAM,MAAA,mBACN,OAAA,YACA,OAAA;EAAW,MAAA;AAAA,IACV,WAAA;AAAA,iBAoDmB,kBAAA,CAAmB,IAAA,EAAM,WAAA,EAAa,SAAA,WAAoB,OAAA,CAAQ,cAAA;AAAA,iBAmBxE,YAAA,CAAA;AAAA,iBAIM,aAAA,CAAA,GAAiB,OAAA"}