@agentmemory/agentmemory 0.9.27 → 0.9.28

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 (122) hide show
  1. package/AGENTS.md +5 -5
  2. package/README.md +97 -37
  3. package/dist/cli.d.mts.map +1 -1
  4. package/dist/cli.mjs +206 -154
  5. package/dist/cli.mjs.map +1 -1
  6. package/dist/config-ChC9EtgV.mjs +259 -0
  7. package/dist/config-ChC9EtgV.mjs.map +1 -0
  8. package/dist/{connect-bmZ5eqYN.mjs → connect-JnsJXc68.mjs} +136 -42
  9. package/dist/connect-JnsJXc68.mjs.map +1 -0
  10. package/dist/hooks/notification.mjs +2 -1
  11. package/dist/hooks/notification.mjs.map +1 -1
  12. package/dist/hooks/post-commit.mjs +2 -1
  13. package/dist/hooks/post-commit.mjs.map +1 -1
  14. package/dist/hooks/post-tool-failure.mjs +2 -1
  15. package/dist/hooks/post-tool-failure.mjs.map +1 -1
  16. package/dist/hooks/post-tool-use.mjs +2 -1
  17. package/dist/hooks/post-tool-use.mjs.map +1 -1
  18. package/dist/hooks/pre-compact.mjs +2 -1
  19. package/dist/hooks/pre-compact.mjs.map +1 -1
  20. package/dist/hooks/pre-tool-use.mjs +2 -1
  21. package/dist/hooks/pre-tool-use.mjs.map +1 -1
  22. package/dist/hooks/prompt-submit.mjs +2 -1
  23. package/dist/hooks/prompt-submit.mjs.map +1 -1
  24. package/dist/hooks/session-end.mjs +2 -1
  25. package/dist/hooks/session-end.mjs.map +1 -1
  26. package/dist/hooks/session-start.mjs +2 -1
  27. package/dist/hooks/session-start.mjs.map +1 -1
  28. package/dist/hooks/stop.mjs +2 -1
  29. package/dist/hooks/stop.mjs.map +1 -1
  30. package/dist/hooks/subagent-start.mjs +2 -1
  31. package/dist/hooks/subagent-start.mjs.map +1 -1
  32. package/dist/hooks/subagent-stop.mjs +2 -1
  33. package/dist/hooks/subagent-stop.mjs.map +1 -1
  34. package/dist/hooks/task-completed.mjs +2 -1
  35. package/dist/hooks/task-completed.mjs.map +1 -1
  36. package/dist/image-refs-BKLmp_sD.mjs +34 -0
  37. package/dist/image-refs-BKLmp_sD.mjs.map +1 -0
  38. package/dist/{image-refs-B5Zf_Djo.mjs → image-refs-C2YU7BIm.mjs} +3 -21
  39. package/dist/image-refs-C2YU7BIm.mjs.map +1 -0
  40. package/dist/index.mjs +118 -150
  41. package/dist/index.mjs.map +1 -1
  42. package/dist/{image-store-Gpo2mgM9.mjs → keyed-mutex-DTHtcZrt.mjs} +14 -11
  43. package/dist/keyed-mutex-DTHtcZrt.mjs.map +1 -0
  44. package/dist/{logger-yHTcEBAI.mjs → logger-BEB7pCI9.mjs} +1 -1
  45. package/dist/{logger-yHTcEBAI.mjs.map → logger-BEB7pCI9.mjs.map} +1 -1
  46. package/dist/{src-MOg2zKJs.mjs → src-CzgoepGU.mjs} +49 -30
  47. package/dist/src-CzgoepGU.mjs.map +1 -0
  48. package/dist/{standalone-BORXC71-.mjs → standalone-YsZFFQBM.mjs} +7 -4
  49. package/dist/standalone-YsZFFQBM.mjs.map +1 -0
  50. package/dist/standalone.d.mts.map +1 -1
  51. package/dist/standalone.mjs +6 -2
  52. package/dist/standalone.mjs.map +1 -1
  53. package/dist/{tools-registry-D8XVVPbJ.mjs → tools-registry-D3NEoe5m.mjs} +4 -256
  54. package/dist/tools-registry-D3NEoe5m.mjs.map +1 -0
  55. package/package.json +4 -1
  56. package/plugin/.claude-plugin/plugin.json +1 -1
  57. package/plugin/.codex-plugin/plugin.json +1 -1
  58. package/plugin/plugin.json +2 -2
  59. package/plugin/scripts/notification.mjs +2 -1
  60. package/plugin/scripts/notification.mjs.map +1 -1
  61. package/plugin/scripts/post-commit.mjs +2 -1
  62. package/plugin/scripts/post-commit.mjs.map +1 -1
  63. package/plugin/scripts/post-tool-failure.mjs +2 -1
  64. package/plugin/scripts/post-tool-failure.mjs.map +1 -1
  65. package/plugin/scripts/post-tool-use.mjs +2 -1
  66. package/plugin/scripts/post-tool-use.mjs.map +1 -1
  67. package/plugin/scripts/pre-compact.mjs +2 -1
  68. package/plugin/scripts/pre-compact.mjs.map +1 -1
  69. package/plugin/scripts/pre-tool-use.mjs +2 -1
  70. package/plugin/scripts/pre-tool-use.mjs.map +1 -1
  71. package/plugin/scripts/prompt-submit.mjs +2 -1
  72. package/plugin/scripts/prompt-submit.mjs.map +1 -1
  73. package/plugin/scripts/session-end.mjs +2 -1
  74. package/plugin/scripts/session-end.mjs.map +1 -1
  75. package/plugin/scripts/session-start.mjs +2 -1
  76. package/plugin/scripts/session-start.mjs.map +1 -1
  77. package/plugin/scripts/stop.mjs +2 -1
  78. package/plugin/scripts/stop.mjs.map +1 -1
  79. package/plugin/scripts/subagent-start.mjs +2 -1
  80. package/plugin/scripts/subagent-start.mjs.map +1 -1
  81. package/plugin/scripts/subagent-stop.mjs +2 -1
  82. package/plugin/scripts/subagent-stop.mjs.map +1 -1
  83. package/plugin/scripts/task-completed.mjs +2 -1
  84. package/plugin/scripts/task-completed.mjs.map +1 -1
  85. package/plugin/skills/_shared/TROUBLESHOOTING.md +38 -0
  86. package/plugin/skills/agentmemory-agents/REFERENCE.md +28 -0
  87. package/plugin/skills/agentmemory-agents/SKILL.md +34 -0
  88. package/plugin/skills/agentmemory-architecture/SKILL.md +33 -0
  89. package/plugin/skills/agentmemory-config/REFERENCE.md +42 -0
  90. package/plugin/skills/agentmemory-config/SKILL.md +37 -0
  91. package/plugin/skills/agentmemory-hooks/REFERENCE.md +20 -0
  92. package/plugin/skills/agentmemory-hooks/SKILL.md +39 -0
  93. package/plugin/skills/agentmemory-mcp-tools/REFERENCE.md +65 -0
  94. package/plugin/skills/agentmemory-mcp-tools/SKILL.md +39 -0
  95. package/plugin/skills/agentmemory-rest-api/REFERENCE.md +129 -0
  96. package/plugin/skills/agentmemory-rest-api/SKILL.md +43 -0
  97. package/plugin/skills/commit-context/EXAMPLES.md +71 -0
  98. package/plugin/skills/commit-context/SKILL.md +53 -8
  99. package/plugin/skills/commit-history/EXAMPLES.md +71 -0
  100. package/plugin/skills/commit-history/SKILL.md +51 -9
  101. package/plugin/skills/forget/EXAMPLES.md +75 -0
  102. package/plugin/skills/forget/SKILL.md +54 -14
  103. package/plugin/skills/handoff/EXAMPLES.md +56 -0
  104. package/plugin/skills/handoff/SKILL.md +56 -9
  105. package/plugin/skills/recall/EXAMPLES.md +74 -0
  106. package/plugin/skills/recall/SKILL.md +50 -11
  107. package/plugin/skills/recap/EXAMPLES.md +60 -0
  108. package/plugin/skills/recap/SKILL.md +51 -13
  109. package/plugin/skills/remember/EXAMPLES.md +67 -0
  110. package/plugin/skills/remember/SKILL.md +53 -17
  111. package/plugin/skills/session-history/EXAMPLES.md +59 -0
  112. package/plugin/skills/session-history/SKILL.md +54 -11
  113. package/plugin/skills/write-agentmemory-skill/SKILL.md +40 -0
  114. package/dist/connect-bmZ5eqYN.mjs.map +0 -1
  115. package/dist/image-refs-B5Zf_Djo.mjs.map +0 -1
  116. package/dist/image-store-Gpo2mgM9.mjs.map +0 -1
  117. package/dist/rolldown-runtime-twds-ZHy.mjs +0 -14
  118. package/dist/src-MOg2zKJs.mjs.map +0 -1
  119. package/dist/standalone-BORXC71-.mjs.map +0 -1
  120. package/dist/tools-registry-D8XVVPbJ.mjs.map +0 -1
  121. package/dist/version-9DNrRyph.mjs +0 -6
  122. package/dist/version-9DNrRyph.mjs.map +0 -1
@@ -1,9 +1,22 @@
1
- import { t as __exportAll } from "./rolldown-runtime-twds-ZHy.mjs";
1
+ import "node:module";
2
2
  import { copyFileSync, existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
3
3
  import { dirname, join, resolve } from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
5
  import { homedir, platform } from "node:os";
6
6
  import * as p from "@clack/prompts";
7
+ import pc from "picocolors";
8
+ //#region \0rolldown/runtime.js
9
+ var __defProp = Object.defineProperty;
10
+ var __exportAll = (all, no_symbols) => {
11
+ let target = {};
12
+ for (var name in all) __defProp(target, name, {
13
+ get: all[name],
14
+ enumerable: true
15
+ });
16
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
17
+ return target;
18
+ };
19
+ //#endregion
7
20
  //#region src/cli/connect/util.ts
8
21
  const AGENTMEMORY_MCP_BLOCK = {
9
22
  command: "npx",
@@ -80,7 +93,7 @@ function logBackup(target) {
80
93
  }
81
94
  //#endregion
82
95
  //#region src/cli/connect/json-mcp-adapter.ts
83
- function entryMatches$2(entry) {
96
+ function entryMatches$3(entry) {
84
97
  if (!entry || typeof entry !== "object") return false;
85
98
  const e = entry;
86
99
  if (e["command"] !== "npx") return false;
@@ -91,6 +104,7 @@ function createJsonMcpAdapter(config) {
91
104
  return {
92
105
  name: config.name,
93
106
  displayName: config.displayName,
107
+ category: config.category ?? "mcp",
94
108
  ...config.docs !== void 0 && { docs: config.docs },
95
109
  ...config.protocolNote !== void 0 && { protocolNote: config.protocolNote },
96
110
  detect() {
@@ -100,7 +114,7 @@ function createJsonMcpAdapter(config) {
100
114
  const existing = readJsonSafe(config.configPath);
101
115
  const next = existing ? { ...existing } : {};
102
116
  const servers = { ...next[wrapperKey] ?? {} };
103
- const alreadyHas = entryMatches$2(servers["agentmemory"]);
117
+ const alreadyHas = entryMatches$3(servers["agentmemory"]);
104
118
  if (alreadyHas && !opts.force) {
105
119
  logAlreadyWired(config.displayName, config.configPath);
106
120
  return {
@@ -127,7 +141,7 @@ function createJsonMcpAdapter(config) {
127
141
  next[wrapperKey] = servers;
128
142
  writeJsonAtomic(config.configPath, next);
129
143
  const verifyServers = readJsonSafe(config.configPath)?.[wrapperKey];
130
- if (!entryMatches$2(verifyServers?.["agentmemory"])) {
144
+ if (!entryMatches$3(verifyServers?.["agentmemory"])) {
131
145
  p.log.error(`Verification failed: ${config.configPath} did not contain ${wrapperKey}.agentmemory after write.`);
132
146
  return {
133
147
  kind: "skipped",
@@ -146,7 +160,7 @@ function createJsonMcpAdapter(config) {
146
160
  //#endregion
147
161
  //#region src/cli/connect/antigravity.ts
148
162
  const ANTIGRAVITY_DIR = platform() === "darwin" ? join(homedir(), "Library", "Application Support", "Antigravity", "User") : join(homedir(), ".config", "Antigravity", "User");
149
- const adapter$16 = createJsonMcpAdapter({
163
+ const adapter$17 = createJsonMcpAdapter({
150
164
  name: "antigravity",
151
165
  displayName: "Antigravity",
152
166
  detectDir: ANTIGRAVITY_DIR,
@@ -218,17 +232,18 @@ function normalizePathForCommandMatch(value) {
218
232
  const CLAUDE_DIR = join(homedir(), ".claude");
219
233
  const CLAUDE_JSON = join(homedir(), ".claude.json");
220
234
  const CLAUDE_SETTINGS = join(CLAUDE_DIR, "settings.json");
221
- function entryMatches$1(entry) {
235
+ function entryMatches$2(entry) {
222
236
  if (!entry || typeof entry !== "object") return false;
223
237
  const e = entry;
224
238
  if (e["command"] !== "npx") return false;
225
239
  return (Array.isArray(e["args"]) ? e["args"] : []).includes("@agentmemory/mcp");
226
240
  }
227
- const adapter$15 = {
241
+ const adapter$16 = {
228
242
  name: "claude-code",
229
243
  displayName: "Claude Code",
244
+ category: "native",
230
245
  docs: "https://github.com/rohitg00/agentmemory#claude-code-one-block-paste-it",
231
- protocolNote: "→ Using MCP. Hooks are also available — see docs/claude-code.md.",
246
+ protocolNote: "→ Using MCP. Hooks are also available — see https://github.com/rohitg00/agentmemory#claude-code-one-block-paste-it.",
232
247
  detect() {
233
248
  return existsSync(CLAUDE_DIR);
234
249
  },
@@ -236,7 +251,7 @@ const adapter$15 = {
236
251
  const existing = readJsonSafe(CLAUDE_JSON);
237
252
  const next = existing ? { ...existing } : {};
238
253
  const servers = { ...next.mcpServers ?? {} };
239
- const alreadyHas = entryMatches$1(servers["agentmemory"]);
254
+ const alreadyHas = entryMatches$2(servers["agentmemory"]);
240
255
  if (alreadyHas && !opts.force) {
241
256
  logAlreadyWired("Claude Code", CLAUDE_JSON);
242
257
  if (opts.withHooks) {
@@ -266,7 +281,7 @@ const adapter$15 = {
266
281
  servers["agentmemory"] = AGENTMEMORY_MCP_BLOCK;
267
282
  next.mcpServers = servers;
268
283
  writeJsonAtomic(CLAUDE_JSON, next);
269
- if (!entryMatches$1(readJsonSafe(CLAUDE_JSON)?.mcpServers?.["agentmemory"])) {
284
+ if (!entryMatches$2(readJsonSafe(CLAUDE_JSON)?.mcpServers?.["agentmemory"])) {
270
285
  p.log.error(`Verification failed: ${CLAUDE_JSON} did not contain mcpServers.agentmemory after write.`);
271
286
  return {
272
287
  kind: "skipped",
@@ -335,7 +350,7 @@ function installClaudeHooks(opts) {
335
350
  }
336
351
  //#endregion
337
352
  //#region src/cli/connect/cline.ts
338
- const adapter$14 = createJsonMcpAdapter({
353
+ const adapter$15 = createJsonMcpAdapter({
339
354
  name: "cline",
340
355
  displayName: "Cline",
341
356
  detectDir: join(homedir(), ".cline"),
@@ -347,13 +362,14 @@ const adapter$14 = createJsonMcpAdapter({
347
362
  //#region src/cli/connect/copilot-cli.ts
348
363
  const COPILOT_DIR = process.env["COPILOT_HOME"] || join(homedir(), ".copilot");
349
364
  const COPILOT_MCP_JSON = join(COPILOT_DIR, "mcp-config.json");
350
- function entryMatches(entry) {
365
+ function entryMatches$1(entry) {
351
366
  if (!entry || typeof entry !== "object") return false;
352
367
  return JSON.stringify(entry) === JSON.stringify(AGENTMEMORY_COPILOT_MCP_BLOCK);
353
368
  }
354
- const adapter$13 = {
369
+ const adapter$14 = {
355
370
  name: "copilot-cli",
356
371
  displayName: "GitHub Copilot CLI",
372
+ category: "native",
357
373
  docs: "https://github.com/rohitg00/agentmemory#github-copilot-cli",
358
374
  protocolNote: "→ Using MCP. Install the plugin too for full hooks/skills coverage.",
359
375
  detect() {
@@ -363,7 +379,7 @@ const adapter$13 = {
363
379
  const existing = readJsonSafe(COPILOT_MCP_JSON);
364
380
  const next = existing ? { ...existing } : {};
365
381
  const servers = { ...next.mcpServers ?? {} };
366
- const alreadyHas = entryMatches(servers["agentmemory"]);
382
+ const alreadyHas = entryMatches$1(servers["agentmemory"]);
367
383
  if (alreadyHas && !opts.force) {
368
384
  logAlreadyWired("GitHub Copilot CLI", COPILOT_MCP_JSON);
369
385
  return {
@@ -386,7 +402,7 @@ const adapter$13 = {
386
402
  servers["agentmemory"] = AGENTMEMORY_COPILOT_MCP_BLOCK;
387
403
  next.mcpServers = servers;
388
404
  writeJsonAtomic(COPILOT_MCP_JSON, next);
389
- if (!entryMatches(readJsonSafe(COPILOT_MCP_JSON)?.mcpServers?.["agentmemory"])) {
405
+ if (!entryMatches$1(readJsonSafe(COPILOT_MCP_JSON)?.mcpServers?.["agentmemory"])) {
390
406
  p.log.error(`Verification failed: ${COPILOT_MCP_JSON} did not contain mcpServers.agentmemory after write.`);
391
407
  return {
392
408
  kind: "skipped",
@@ -433,9 +449,10 @@ function stripExistingBlock(toml) {
433
449
  }
434
450
  return out.join("\n").replace(/\n{3,}$/, "\n\n").trimEnd() + "\n";
435
451
  }
436
- const adapter$12 = {
452
+ const adapter$13 = {
437
453
  name: "codex",
438
454
  displayName: "Codex CLI",
455
+ category: "native",
439
456
  docs: "https://github.com/rohitg00/agentmemory#codex-cli-codex-plugin-platform",
440
457
  protocolNote: "→ Using MCP. Hooks ship via the Codex plugin; on Codex Desktop, also pass --with-hooks to install the global hooks.json workaround for openai/codex#16430.",
441
458
  detect() {
@@ -557,9 +574,10 @@ function renderFreshYaml() {
557
574
  ""
558
575
  ].join("\n");
559
576
  }
560
- const adapter$11 = {
577
+ const adapter$12 = {
561
578
  name: "continue",
562
579
  displayName: "Continue",
580
+ category: "mcp",
563
581
  docs: "https://github.com/rohitg00/agentmemory#other-agents",
564
582
  protocolNote: "→ Using MCP via ~/.continue/config.yaml (preferred) or config.json (legacy, only when no yaml).",
565
583
  detect() {
@@ -636,7 +654,7 @@ const adapter$11 = {
636
654
  };
637
655
  //#endregion
638
656
  //#region src/cli/connect/cursor.ts
639
- const adapter$10 = createJsonMcpAdapter({
657
+ const adapter$11 = createJsonMcpAdapter({
640
658
  name: "cursor",
641
659
  displayName: "Cursor",
642
660
  detectDir: join(homedir(), ".cursor"),
@@ -646,7 +664,7 @@ const adapter$10 = createJsonMcpAdapter({
646
664
  });
647
665
  //#endregion
648
666
  //#region src/cli/connect/droid.ts
649
- const adapter$9 = createJsonMcpAdapter({
667
+ const adapter$10 = createJsonMcpAdapter({
650
668
  name: "droid",
651
669
  displayName: "Droid (Factory.ai)",
652
670
  detectDir: join(homedir(), ".factory"),
@@ -657,7 +675,7 @@ const adapter$9 = createJsonMcpAdapter({
657
675
  });
658
676
  //#endregion
659
677
  //#region src/cli/connect/gemini-cli.ts
660
- const adapter$8 = createJsonMcpAdapter({
678
+ const adapter$9 = createJsonMcpAdapter({
661
679
  name: "gemini-cli",
662
680
  displayName: "Gemini CLI",
663
681
  detectDir: join(homedir(), ".gemini"),
@@ -670,11 +688,12 @@ const adapter$8 = createJsonMcpAdapter({
670
688
  const HERMES_DIR = join(homedir(), ".hermes");
671
689
  const HERMES_CONFIG = join(HERMES_DIR, "config.yaml");
672
690
  const DOCS$2 = "https://github.com/rohitg00/agentmemory/tree/main/integrations/hermes";
673
- const adapter$7 = {
691
+ const adapter$8 = {
674
692
  name: "hermes",
675
693
  displayName: "Hermes Agent",
694
+ category: "native",
676
695
  docs: DOCS$2,
677
- protocolNote: "→ Using MCP. Hooks are also available — see docs/hermes.md.",
696
+ protocolNote: "→ Using MCP. Hooks are also available — see https://github.com/rohitg00/agentmemory/tree/main/integrations/hermes.",
678
697
  detect() {
679
698
  return existsSync(HERMES_DIR);
680
699
  },
@@ -701,7 +720,7 @@ const adapter$7 = {
701
720
  };
702
721
  //#endregion
703
722
  //#region src/cli/connect/kiro.ts
704
- const adapter$6 = createJsonMcpAdapter({
723
+ const adapter$7 = createJsonMcpAdapter({
705
724
  name: "kiro",
706
725
  displayName: "Kiro",
707
726
  detectDir: join(homedir(), ".kiro"),
@@ -711,21 +730,94 @@ const adapter$6 = createJsonMcpAdapter({
711
730
  });
712
731
  //#endregion
713
732
  //#region src/cli/connect/openclaw.ts
714
- const adapter$5 = createJsonMcpAdapter({
733
+ const adapter$6 = createJsonMcpAdapter({
715
734
  name: "openclaw",
716
735
  displayName: "OpenClaw",
736
+ category: "native",
717
737
  detectDir: join(homedir(), ".openclaw"),
718
738
  configPath: join(homedir(), ".openclaw", "openclaw.json"),
719
739
  docs: "https://github.com/rohitg00/agentmemory/tree/main/integrations/openclaw",
720
- protocolNote: "→ Using MCP. Hooks are also available — see docs/openclaw.md."
740
+ protocolNote: "→ Using MCP. Hooks are also available — see https://github.com/rohitg00/agentmemory/tree/main/integrations/openclaw."
721
741
  });
722
742
  //#endregion
743
+ //#region src/cli/connect/opencode.ts
744
+ const CONFIG_PATH = join(homedir(), ".config", "opencode", "opencode.json");
745
+ const DETECT_DIR = join(homedir(), ".config", "opencode");
746
+ const OPENCODE_ENTRY = {
747
+ type: "local",
748
+ command: [
749
+ "npx",
750
+ "-y",
751
+ "@agentmemory/mcp"
752
+ ],
753
+ enabled: true
754
+ };
755
+ function entryMatches(entry) {
756
+ if (!entry || typeof entry !== "object") return false;
757
+ const command = entry["command"];
758
+ return Array.isArray(command) && command.includes("@agentmemory/mcp");
759
+ }
760
+ const adapter$5 = {
761
+ name: "opencode",
762
+ displayName: "OpenCode",
763
+ category: "mcp",
764
+ docs: "https://github.com/rohitg00/agentmemory#other-agents",
765
+ protocolNote: "Using MCP via ~/.config/opencode/opencode.json (top-level `mcp` key). For full auto-capture, also install the bundled plugin in plugin/opencode/.",
766
+ detect() {
767
+ return existsSync(DETECT_DIR);
768
+ },
769
+ async install(opts) {
770
+ const existing = readJsonSafe(CONFIG_PATH);
771
+ const next = existing ? { ...existing } : {};
772
+ const existingMcp = next["mcp"];
773
+ const mcp = existingMcp && typeof existingMcp === "object" && !Array.isArray(existingMcp) ? { ...existingMcp } : {};
774
+ const alreadyHas = entryMatches(mcp["agentmemory"]);
775
+ if (alreadyHas && !opts.force) {
776
+ logAlreadyWired(this.displayName, CONFIG_PATH);
777
+ return {
778
+ kind: "already-wired",
779
+ mutatedPath: CONFIG_PATH
780
+ };
781
+ }
782
+ if (opts.dryRun) {
783
+ p.log.info(`[dry-run] Would ${alreadyHas ? "overwrite" : "add"} mcp.agentmemory in ${CONFIG_PATH}`);
784
+ return {
785
+ kind: "installed",
786
+ mutatedPath: CONFIG_PATH
787
+ };
788
+ }
789
+ let backupPath;
790
+ if (existsSync(CONFIG_PATH)) {
791
+ backupPath = backupFile(CONFIG_PATH, this.name);
792
+ logBackup(backupPath);
793
+ } else mkdirSync(dirname(CONFIG_PATH), { recursive: true });
794
+ mcp["agentmemory"] = { ...OPENCODE_ENTRY };
795
+ next["mcp"] = mcp;
796
+ writeJsonAtomic(CONFIG_PATH, next);
797
+ const verifyMcp = readJsonSafe(CONFIG_PATH)?.["mcp"];
798
+ if (!entryMatches(verifyMcp?.["agentmemory"])) {
799
+ p.log.error(`Verification failed: ${CONFIG_PATH} did not contain mcp.agentmemory after write.`);
800
+ return {
801
+ kind: "skipped",
802
+ reason: "verification-failed"
803
+ };
804
+ }
805
+ logInstalled(this.displayName, CONFIG_PATH);
806
+ return {
807
+ kind: "installed",
808
+ mutatedPath: CONFIG_PATH,
809
+ ...backupPath !== void 0 && { backupPath }
810
+ };
811
+ }
812
+ };
813
+ //#endregion
723
814
  //#region src/cli/connect/openhuman.ts
724
815
  const OPENHUMAN_DIR = join(homedir(), ".openhuman");
725
816
  const DOCS$1 = "https://github.com/tinyhumansai/openhuman";
726
817
  const adapter$4 = {
727
818
  name: "openhuman",
728
819
  displayName: "OpenHuman",
820
+ category: "native",
729
821
  docs: DOCS$1,
730
822
  protocolNote: "→ Using native hooks (REST API at :3111). MCP not required.",
731
823
  detect() {
@@ -755,6 +847,7 @@ const DOCS = "https://github.com/rohitg00/agentmemory/tree/main/integrations/pi"
755
847
  const adapter$3 = {
756
848
  name: "pi",
757
849
  displayName: "pi",
850
+ category: "native",
758
851
  docs: DOCS,
759
852
  protocolNote: "→ Using native hooks (REST API at :3111). MCP not required.",
760
853
  detect() {
@@ -822,21 +915,22 @@ var connect_exports = /* @__PURE__ */ __exportAll({
822
915
  runConnect: () => runConnect
823
916
  });
824
917
  const ADAPTERS = [
825
- adapter$15,
826
- adapter$13,
827
- adapter$12,
828
- adapter$10,
829
- adapter$8,
830
- adapter$2,
831
918
  adapter$16,
832
- adapter$6,
833
- adapter$1,
834
919
  adapter$14,
920
+ adapter$13,
835
921
  adapter$11,
836
- adapter,
837
922
  adapter$9,
838
- adapter$5,
923
+ adapter$2,
924
+ adapter$17,
839
925
  adapter$7,
926
+ adapter$1,
927
+ adapter$15,
928
+ adapter$12,
929
+ adapter,
930
+ adapter$10,
931
+ adapter$5,
932
+ adapter$6,
933
+ adapter$8,
840
934
  adapter$3,
841
935
  adapter$4
842
936
  ];
@@ -963,19 +1057,19 @@ async function runConnect(args) {
963
1057
  function summarize(results) {
964
1058
  const lines = results.map(({ name, result }) => {
965
1059
  switch (result.kind) {
966
- case "installed": return ` ✓ ${name}${result.mutatedPath ? ` → ${result.mutatedPath}` : ""}`;
967
- case "already-wired": return ` ✓ ${name} (already wired)`;
968
- case "stub": return ` ⚠ ${name} (manual install required: ${result.reason})`;
969
- case "skipped": return ` ✗ ${name} (skipped: ${result.reason})`;
1060
+ case "installed": return ` ${pc.green("✓")} ${pc.bold(name)}${result.mutatedPath ? ` ${pc.dim("→")} ${pc.cyan(result.mutatedPath)}` : ""}`;
1061
+ case "already-wired": return ` ${pc.green("✓")} ${pc.bold(name)} ${pc.dim("(already wired)")}`;
1062
+ case "stub": return ` ${pc.yellow("⚠")} ${pc.bold(name)} ${pc.yellow(`(manual install required: ${result.reason})`)}`;
1063
+ case "skipped": return ` ${pc.red("✗")} ${pc.bold(name)} ${pc.dim(`(skipped: ${result.reason})`)}`;
970
1064
  }
971
1065
  });
972
1066
  p.note(lines.join("\n"), "summary");
973
1067
  const stubs = results.filter((r) => r.result.kind === "stub");
974
1068
  if (stubs.length > 0) p.log.info(`${stubs.length} agent(s) require manual install — see docs links above.`);
975
- if (results.some((r) => r.result.kind === "installed" || r.result.kind === "already-wired")) p.log.info("Next: install agentmemory's 8 skills into the same agent(s) so they know when to call the tools:\n npx skills add rohitg00/agentmemory -y");
1069
+ if (results.some((r) => r.result.kind === "installed" || r.result.kind === "already-wired")) p.log.info("Next: install agentmemory's 15 skills into the same agent(s) so they know when to call the tools:\n npx skills add rohitg00/agentmemory -y");
976
1070
  p.outro("Restart any wired agent (or open a new session) to pick up agentmemory.");
977
1071
  }
978
1072
  //#endregion
979
- export { resolveAdapter as n, runAdapter as r, connect_exports as t };
1073
+ export { runAdapter as a, resolveAdapter as i, connect_exports as n, knownAgents as r, ADAPTERS as t };
980
1074
 
981
- //# sourceMappingURL=connect-bmZ5eqYN.mjs.map
1075
+ //# sourceMappingURL=connect-JnsJXc68.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connect-JnsJXc68.mjs","names":["entryMatches","adapter","entryMatches","adapter","adapter","entryMatches","adapter","adapter","adapter","adapter","adapter","adapter","DOCS","adapter","adapter","adapter","adapter","DOCS","adapter","adapter","adapter","adapter","claudeCode","copilotCli","codex","cursor","geminiCli","qwen","antigravity","kiro","warp","cline","continueDev","zed","droid","opencode","openclaw","hermes","pi","openhuman"],"sources":["../src/cli/connect/util.ts","../src/cli/connect/json-mcp-adapter.ts","../src/cli/connect/antigravity.ts","../src/cli/connect/codex-hooks.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/droid.ts","../src/cli/connect/gemini-cli.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/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 } from \"node:path\";\nimport { homedir } from \"node:os\";\nimport * as p from \"@clack/prompts\";\n\n// Env values use ${VAR:-default} expansion so the wired MCP entry\n// inherits AGENTMEMORY_URL / AGENTMEMORY_SECRET / AGENTMEMORY_TOOLS\n// from the user's shell, but never fails parse when the var is unset\n// (#510). Earlier `${VAR}` form caused Claude Code to silently drop the\n// server when no shell-level export existed — per the Claude Code MCP\n// docs, \"If a required environment variable is not set and has no\n// default value, Claude Code will fail to parse the config.\"\n//\n// Defaults match the documented runtime: localhost:3111 (no auth, all\n// tools). One wired entry now serves local AND remote (Kubernetes /\n// reverse-proxied) deployments without doctor-warning duplicates (#375)\n// AND fresh installs that haven't exported envs (#510).\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 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 mkdirSync(dirname(path), { recursive: true });\n const tmp = `${path}.tmp-${process.pid}-${Date.now()}`;\n writeFileSync(tmp, `${JSON.stringify(value, null, 2)}\\n`, \"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 } 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};\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 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 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 return {\n kind: \"installed\",\n mutatedPath: config.configPath,\n ...(backupPath !== undefined && { backupPath }),\n };\n },\n };\n}\n","import { homedir, platform } from \"node:os\";\nimport { join } from \"node:path\";\nimport { createJsonMcpAdapter } from \"./json-mcp-adapter.js\";\n\n// Antigravity stores MCP config in mcp_config.json under its app\n// support directory. The schema follows the standard MCP envelope —\n// `{ mcpServers: { ... } }`. Path varies by platform:\n// macOS: ~/Library/Application Support/Antigravity/User/mcp_config.json\n// Linux: ~/.config/Antigravity/User/mcp_config.json\n// Windows: %APPDATA%/Antigravity/User/mcp_config.json\n// Connect is gated on win32 elsewhere; we cover macOS + Linux here.\nconst ANTIGRAVITY_DIR =\n platform() === \"darwin\"\n ? join(homedir(), \"Library\", \"Application Support\", \"Antigravity\", \"User\")\n : join(homedir(), \".config\", \"Antigravity\", \"User\");\n\nexport const adapter = createJsonMcpAdapter({\n name: \"antigravity\",\n displayName: \"Antigravity\",\n detectDir: ANTIGRAVITY_DIR,\n configPath: join(ANTIGRAVITY_DIR, \"mcp_config.json\"),\n docs: \"https://github.com/rohitg00/agentmemory#other-agents\",\n protocolNote:\n \"→ Using MCP via mcp_config.json. Antigravity replaces Gemini CLI (sunset 2026-06-18).\",\n});\n","import { existsSync, readFileSync } from \"node:fs\";\nimport { dirname, join, resolve } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\n/**\n * Workaround for openai/codex#16430 — Codex Desktop does not dispatch\n * plugin-local `hooks.json` even though both `CodexHooks` and `PluginHooks`\n * feature flags are stable + default-enabled in\n * `codex-rs/features/src/lib.rs`. Until upstream fixes plugin-scope\n * dispatch, the same hook commands can be mirrored into the global\n * `~/.codex/hooks.json`, which is loaded reliably.\n *\n * This module builds that mirror, with `${CLAUDE_PLUGIN_ROOT}` resolved to\n * the bundled `plugin/` directory so the user-scope file does not depend\n * on env-var expansion (Codex only injects `CLAUDE_PLUGIN_ROOT` for\n * plugin-scope hooks).\n *\n * Identification on re-install: every command we write contains the\n * resolved `<pluginRoot>/scripts/` prefix, so subsequent installs can\n * strip our entries and re-add cleanly without touching the user's other\n * hook entries.\n */\n\ntype HookHandler = { type: string; command: string };\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 any entry from `existing` whose first hook command points\n * under `<pluginRoot>/scripts/`. This lets us re-install idempotently\n * without leaving stale references.\n * 2. Append fresh entries from the bundled Codex manifest with\n * `${CLAUDE_PLUGIN_ROOT}` rewritten to the absolute plugin path.\n * Matcher values from the bundled manifest are preserved so PreToolUse\n * 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.filter((entry) => !isAgentmemoryEntry(entry, scriptsDir));\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 type: handler.type,\n command: handler.command.replace(/\\$\\{CLAUDE_PLUGIN_ROOT\\}/g, pluginRoot),\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 isAgentmemoryEntry(entry: HookEntry, scriptsDir: string): boolean {\n const normalizedScriptsDir = normalizePathForCommandMatch(scriptsDir);\n return entry.hooks.some((handler) =>\n normalizePathForCommandMatch(handler.command).includes(normalizedScriptsDir),\n );\n}\n\nfunction normalizePathForCommandMatch(value: string): string {\n return value.replace(/\\\\/g, \"/\");\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 // --with-hooks is independent of MCP wiring (issue #508). Run the\n // hooks fallback even when MCP is already in place so users with a\n // healthy MCP setup can still pick up version-stable hook paths.\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\n/**\n * Merge the bundled `plugin/hooks/hooks.json` into\n * `~/.claude/settings.json`'s top-level `hooks` field with absolute\n * script paths. Use this when agentmemory is NOT installed through\n * `/plugin marketplace add` (e.g. MCP standalone wiring), so the\n * hook scripts survive version bumps without `${CLAUDE_PLUGIN_ROOT}`\n * expansion (issue #508).\n *\n * Re-install strips entries whose command points under\n * `<pluginRoot>/scripts/`; unrelated user hook entries survive.\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 (workaround for #508)\", 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 for openai/codex#16430.\",\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\n/**\n * Install the global `~/.codex/hooks.json` fallback. See\n * `codex-hooks.ts` for context (openai/codex#16430). Returns a result\n * describing the side effect for the caller's summary; failures here do\n * not roll back the MCP wiring.\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 (workaround for openai/codex#16430)\", CODEX_HOOKS);\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.\",\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 detectDir: join(homedir(), \".cursor\"),\n configPath: join(homedir(), \".cursor\", \"mcp.json\"),\n docs: \"https://github.com/rohitg00/agentmemory#other-agents\",\n protocolNote:\n \"→ Using MCP (the only protocol Cursor speaks). Memory bridge runs at :3111 underneath.\",\n});\n","import { homedir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { createJsonMcpAdapter } from \"./json-mcp-adapter.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\nexport const adapter = createJsonMcpAdapter({\n name: \"droid\",\n displayName: \"Droid (Factory.ai)\",\n detectDir: join(homedir(), \".factory\"),\n configPath: join(homedir(), \".factory\", \"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.\",\n // Droid requires `type` per the documented schema. stdio for npx-spawned shim.\n extraEntryFields: { type: \"stdio\" },\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 { 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 HERMES_DIR = join(homedir(), \".hermes\");\nconst HERMES_CONFIG = join(HERMES_DIR, \"config.yaml\");\nconst DOCS = \"https://github.com/rohitg00/agentmemory/tree/main/integrations/hermes\";\n\nexport const adapter: ConnectAdapter = {\n name: \"hermes\",\n displayName: \"Hermes Agent\",\n category: \"native\",\n docs: DOCS,\n protocolNote:\n \"→ Using MCP. Hooks are also available — see https://github.com/rohitg00/agentmemory/tree/main/integrations/hermes.\",\n\n detect(): boolean {\n return existsSync(HERMES_DIR);\n },\n\n async install(_opts: ConnectOptions): Promise<ConnectResult> {\n p.log.warn(\n \"Hermes uses YAML config. Automated merge isn't implemented yet — manual install required.\",\n );\n p.note(\n [\n `Add to ${HERMES_CONFIG}:`,\n \"\",\n \" mcp_servers:\",\n \" agentmemory:\",\n \" command: npx\",\n ' args: [\"-y\", \"@agentmemory/mcp\"]',\n \"\",\n \" memory:\",\n \" provider: agentmemory\",\n \"\",\n `Full guide: ${DOCS}`,\n ].join(\"\\n\"),\n \"Hermes manual install\",\n );\n return {\n kind: \"stub\",\n reason: \"yaml-merge-not-implemented\",\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 { homedir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { createJsonMcpAdapter } from \"./json-mcp-adapter.js\";\n\nexport const adapter = createJsonMcpAdapter({\n name: \"openclaw\",\n displayName: \"OpenClaw\",\n category: \"native\",\n detectDir: join(homedir(), \".openclaw\"),\n configPath: join(homedir(), \".openclaw\", \"openclaw.json\"),\n docs: \"https://github.com/rohitg00/agentmemory/tree/main/integrations/openclaw\",\n protocolNote:\n \"→ Using MCP. Hooks are also available — see https://github.com/rohitg00/agentmemory/tree/main/integrations/openclaw.\",\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 } 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 PI_DIR = join(homedir(), \".pi\");\nconst PI_EXT_DIR = join(PI_DIR, \"agent\", \"extensions\", \"agentmemory\");\nconst DOCS = \"https://github.com/rohitg00/agentmemory/tree/main/integrations/pi\";\n\nexport const adapter: ConnectAdapter = {\n name: \"pi\",\n displayName: \"pi\",\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(PI_DIR);\n },\n\n async install(_opts: ConnectOptions): Promise<ConnectResult> {\n p.log.warn(\n \"pi uses a TypeScript extension file. Automated copy + register isn't implemented yet — manual install required.\",\n );\n p.note(\n [\n \"Run these from the agentmemory repo root:\",\n \"\",\n ` mkdir -p ${PI_EXT_DIR}`,\n ` cp integrations/pi/index.ts ${PI_EXT_DIR}/index.ts`,\n ` cp integrations/pi/security.ts ${PI_EXT_DIR}/security.ts`,\n \"\",\n \"Then add to ~/.pi/agent/settings.json:\",\n ' { \"extensions\": [\"~/.pi/agent/extensions/agentmemory\"] }',\n \"\",\n `Full guide: ${DOCS}`,\n ].join(\"\\n\"),\n \"pi manual install\",\n );\n return {\n kind: \"stub\",\n reason: \"ts-extension-copy-not-implemented\",\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 { adapter as antigravity } from \"./antigravity.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 droid } from \"./droid.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 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 geminiCli,\n qwen,\n antigravity,\n kiro,\n warp,\n cline,\n continueDev,\n zed,\n droid,\n opencode,\n openclaw,\n hermes,\n pi,\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 positional: string[];\n} {\n const positional: string[] = [];\n let dryRun = false;\n let force = false;\n let all = false;\n let withHooks = false;\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.startsWith(\"-\")) positional.push(a);\n }\n return { dryRun, force, all, withHooks, 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 return await adapter.install(opts);\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, positional } = 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 };\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) => r.result.kind === \"installed\" || r.result.kind === \"already-wired\",\n );\n if (wiredAny) {\n p.log.info(\n \"Next: install agentmemory's 15 skills into the same agent(s) so they know when to call the tools:\\n npx skills 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":";;;;;;;;;;;;;;;;;;;;AAwBA,MAAa,wBAAwB;CACnC,SAAS;CACT,MAAM,CAAC,MAAM,mBAAmB;CAChC,KAAK;EACH,iBAAiB;EACjB,oBAAoB;EACpB,mBAAmB;EACpB;CACF;AAaD,MAAa,gCAAgC;CAC3C,MAAM;CACN,GAZA,QAAQ,aAAa,UACjB;EACE,SAAS,QAAQ,IAAI,cAAc,QAAQ,IAAI,cAAc;EAC7D,MAAM;GAAC;GAAM;GAAM;GAAM;GAAO;GAAM;GAAmB;EAC1D,GACD;EACE,SAAS;EACT,MAAM,CAAC,MAAM,mBAAmB;EACjC;CAKL,KAAK;EACH,iBAAiB;EACjB,oBAAoB;EACpB,mBAAmB;EACpB;CACD,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AAK,GAAG,OAAO,cAAc,IAAI,GAAG,IAAI,IAAI,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,EAAE,OAAO,SAAS,eAAe,EAAE,OAAO,SAAS,gBAEhD,CACV,GAAE,IAAI,KACJ,8IACD;AAGH,GAAE,MAAM,0EAA0E"}
@@ -43,6 +43,7 @@ async function main() {
43
43
  } catch {
44
44
  return;
45
45
  }
46
+ if (!data || typeof data !== "object") return;
46
47
  if (isSdkChildContext(data)) return;
47
48
  const notificationType = data.notification_type ?? data.notificationType;
48
49
  if (notificationType !== "permission_prompt") return;
@@ -67,7 +68,7 @@ async function main() {
67
68
  }).catch(() => {});
68
69
  setTimeout(() => process.exit(0), 500).unref();
69
70
  }
70
- main();
71
+ main().catch(() => process.exit(0));
71
72
  //#endregion
72
73
  export {};
73
74
 
@@ -1 +1 @@
1
- {"version":3,"file":"notification.mjs","names":[],"sources":["../../src/hooks/_project.ts","../../src/hooks/notification.ts"],"sourcesContent":["import { execSync } from \"node:child_process\";\nimport { basename } from \"node:path\";\n\n// Resolution order: AGENTMEMORY_PROJECT_NAME env → git toplevel basename → cwd basename.\nexport function resolveProject(cwd?: string): string {\n const explicit = process.env[\"AGENTMEMORY_PROJECT_NAME\"];\n if (explicit && explicit.trim()) return explicit.trim();\n const dir = cwd && cwd.trim() ? cwd : process.cwd();\n try {\n const top = execSync(\"git rev-parse --show-toplevel\", {\n cwd: dir,\n stdio: [\"ignore\", \"pipe\", \"ignore\"],\n timeout: 500,\n })\n .toString()\n .trim();\n if (top) return basename(top);\n } catch {}\n return basename(dir);\n}\n","#!/usr/bin/env node\nimport { resolveProject } from \"./_project.js\";\n\nfunction isSdkChildContext(payload: unknown): boolean {\n if (process.env[\"AGENTMEMORY_SDK_CHILD\"] === \"1\") return true;\n if (!payload || typeof payload !== \"object\") return false;\n return (payload as { entrypoint?: unknown }).entrypoint === \"sdk-ts\";\n}\n\nconst REST_URL = process.env[\"AGENTMEMORY_URL\"] || \"http://localhost:3111\";\nconst SECRET = process.env[\"AGENTMEMORY_SECRET\"] || \"\";\n\nfunction authHeaders(): Record<string, string> {\n const h: Record<string, string> = { \"Content-Type\": \"application/json\" };\n if (SECRET) h[\"Authorization\"] = `Bearer ${SECRET}`;\n return h;\n}\n\nasync function main() {\n let input = \"\";\n for await (const chunk of process.stdin) {\n input += chunk;\n }\n\n let data: Record<string, unknown>;\n try {\n data = JSON.parse(input);\n } catch {\n return;\n }\n\n if (isSdkChildContext(data)) return;\n const notificationType = data.notification_type ?? data.notificationType;\n if (notificationType !== \"permission_prompt\") return;\n\n const rawSessionId = data.session_id ?? data.sessionId;\n const sessionId =\n typeof rawSessionId === \"string\" && rawSessionId.length > 0\n ? rawSessionId\n : \"unknown\";\n\n fetch(`${REST_URL}/agentmemory/observe`, {\n method: \"POST\",\n headers: authHeaders(),\n body: JSON.stringify({\n hookType: \"notification\",\n sessionId,\n project: resolveProject(data.cwd as string | undefined),\n cwd: (data.cwd as string | undefined) || process.cwd(),\n timestamp: new Date().toISOString(),\n data: {\n notification_type: notificationType,\n title: data.title,\n message: data.message,\n },\n }),\n signal: AbortSignal.timeout(2000),\n }).catch(() => {});\n setTimeout(() => process.exit(0), 500).unref();\n}\n\nmain();\n"],"mappings":";;;;AAIA,SAAgB,eAAe,KAAsB;CACnD,MAAM,WAAW,QAAQ,IAAI;AAC7B,KAAI,YAAY,SAAS,MAAM,CAAE,QAAO,SAAS,MAAM;CACvD,MAAM,MAAM,OAAO,IAAI,MAAM,GAAG,MAAM,QAAQ,KAAK;AACnD,KAAI;EACF,MAAM,MAAM,SAAS,iCAAiC;GACpD,KAAK;GACL,OAAO;IAAC;IAAU;IAAQ;IAAS;GACnC,SAAS;GACV,CAAC,CACC,UAAU,CACV,MAAM;AACT,MAAI,IAAK,QAAO,SAAS,IAAI;SACvB;AACR,QAAO,SAAS,IAAI;;;;ACftB,SAAS,kBAAkB,SAA2B;AACpD,KAAI,QAAQ,IAAI,6BAA6B,IAAK,QAAO;AACzD,KAAI,CAAC,WAAW,OAAO,YAAY,SAAU,QAAO;AACpD,QAAQ,QAAqC,eAAe;;AAG9D,MAAM,WAAW,QAAQ,IAAI,sBAAsB;AACnD,MAAM,SAAS,QAAQ,IAAI,yBAAyB;AAEpD,SAAS,cAAsC;CAC7C,MAAM,IAA4B,EAAE,gBAAgB,oBAAoB;AACxE,KAAI,OAAQ,GAAE,mBAAmB,UAAU;AAC3C,QAAO;;AAGT,eAAe,OAAO;CACpB,IAAI,QAAQ;AACZ,YAAW,MAAM,SAAS,QAAQ,MAChC,UAAS;CAGX,IAAI;AACJ,KAAI;AACF,SAAO,KAAK,MAAM,MAAM;SAClB;AACN;;AAGF,KAAI,kBAAkB,KAAK,CAAE;CAC7B,MAAM,mBAAmB,KAAK,qBAAqB,KAAK;AACxD,KAAI,qBAAqB,oBAAqB;CAE9C,MAAM,eAAe,KAAK,cAAc,KAAK;CAC7C,MAAM,YACJ,OAAO,iBAAiB,YAAY,aAAa,SAAS,IACtD,eACA;AAEN,OAAM,GAAG,SAAS,uBAAuB;EACvC,QAAQ;EACR,SAAS,aAAa;EACtB,MAAM,KAAK,UAAU;GACnB,UAAU;GACV;GACA,SAAS,eAAe,KAAK,IAA0B;GACvD,KAAM,KAAK,OAA8B,QAAQ,KAAK;GACtD,4BAAW,IAAI,MAAM,EAAC,aAAa;GACnC,MAAM;IACJ,mBAAmB;IACnB,OAAO,KAAK;IACZ,SAAS,KAAK;IACf;GACF,CAAC;EACF,QAAQ,YAAY,QAAQ,IAAK;EAClC,CAAC,CAAC,YAAY,GAAG;AAClB,kBAAiB,QAAQ,KAAK,EAAE,EAAE,IAAI,CAAC,OAAO;;AAGhD,MAAM"}
1
+ {"version":3,"file":"notification.mjs","names":[],"sources":["../../src/hooks/_project.ts","../../src/hooks/notification.ts"],"sourcesContent":["import { execSync } from \"node:child_process\";\nimport { basename } from \"node:path\";\n\n// Resolution order: AGENTMEMORY_PROJECT_NAME env → git toplevel basename → cwd basename.\nexport function resolveProject(cwd?: string): string {\n const explicit = process.env[\"AGENTMEMORY_PROJECT_NAME\"];\n if (explicit && explicit.trim()) return explicit.trim();\n const dir = cwd && cwd.trim() ? cwd : process.cwd();\n try {\n const top = execSync(\"git rev-parse --show-toplevel\", {\n cwd: dir,\n stdio: [\"ignore\", \"pipe\", \"ignore\"],\n timeout: 500,\n })\n .toString()\n .trim();\n if (top) return basename(top);\n } catch {}\n return basename(dir);\n}\n","#!/usr/bin/env node\nimport { resolveProject } from \"./_project.js\";\n\nfunction isSdkChildContext(payload: unknown): boolean {\n if (process.env[\"AGENTMEMORY_SDK_CHILD\"] === \"1\") return true;\n if (!payload || typeof payload !== \"object\") return false;\n return (payload as { entrypoint?: unknown }).entrypoint === \"sdk-ts\";\n}\n\nconst REST_URL = process.env[\"AGENTMEMORY_URL\"] || \"http://localhost:3111\";\nconst SECRET = process.env[\"AGENTMEMORY_SECRET\"] || \"\";\n\nfunction authHeaders(): Record<string, string> {\n const h: Record<string, string> = { \"Content-Type\": \"application/json\" };\n if (SECRET) h[\"Authorization\"] = `Bearer ${SECRET}`;\n return h;\n}\n\nasync function main() {\n let input = \"\";\n for await (const chunk of process.stdin) {\n input += chunk;\n }\n\n let data: Record<string, unknown>;\n try {\n data = JSON.parse(input);\n } catch {\n return;\n }\n\n if (!data || typeof data !== \"object\") return;\n if (isSdkChildContext(data)) return;\n const notificationType = data.notification_type ?? data.notificationType;\n if (notificationType !== \"permission_prompt\") return;\n\n const rawSessionId = data.session_id ?? data.sessionId;\n const sessionId =\n typeof rawSessionId === \"string\" && rawSessionId.length > 0\n ? rawSessionId\n : \"unknown\";\n\n fetch(`${REST_URL}/agentmemory/observe`, {\n method: \"POST\",\n headers: authHeaders(),\n body: JSON.stringify({\n hookType: \"notification\",\n sessionId,\n project: resolveProject(data.cwd as string | undefined),\n cwd: (data.cwd as string | undefined) || process.cwd(),\n timestamp: new Date().toISOString(),\n data: {\n notification_type: notificationType,\n title: data.title,\n message: data.message,\n },\n }),\n signal: AbortSignal.timeout(2000),\n }).catch(() => {});\n setTimeout(() => process.exit(0), 500).unref();\n}\n\nmain().catch(() => process.exit(0));\n"],"mappings":";;;;AAIA,SAAgB,eAAe,KAAsB;CACnD,MAAM,WAAW,QAAQ,IAAI;AAC7B,KAAI,YAAY,SAAS,MAAM,CAAE,QAAO,SAAS,MAAM;CACvD,MAAM,MAAM,OAAO,IAAI,MAAM,GAAG,MAAM,QAAQ,KAAK;AACnD,KAAI;EACF,MAAM,MAAM,SAAS,iCAAiC;GACpD,KAAK;GACL,OAAO;IAAC;IAAU;IAAQ;IAAS;GACnC,SAAS;GACV,CAAC,CACC,UAAU,CACV,MAAM;AACT,MAAI,IAAK,QAAO,SAAS,IAAI;SACvB;AACR,QAAO,SAAS,IAAI;;;;ACftB,SAAS,kBAAkB,SAA2B;AACpD,KAAI,QAAQ,IAAI,6BAA6B,IAAK,QAAO;AACzD,KAAI,CAAC,WAAW,OAAO,YAAY,SAAU,QAAO;AACpD,QAAQ,QAAqC,eAAe;;AAG9D,MAAM,WAAW,QAAQ,IAAI,sBAAsB;AACnD,MAAM,SAAS,QAAQ,IAAI,yBAAyB;AAEpD,SAAS,cAAsC;CAC7C,MAAM,IAA4B,EAAE,gBAAgB,oBAAoB;AACxE,KAAI,OAAQ,GAAE,mBAAmB,UAAU;AAC3C,QAAO;;AAGT,eAAe,OAAO;CACpB,IAAI,QAAQ;AACZ,YAAW,MAAM,SAAS,QAAQ,MAChC,UAAS;CAGX,IAAI;AACJ,KAAI;AACF,SAAO,KAAK,MAAM,MAAM;SAClB;AACN;;AAGF,KAAI,CAAC,QAAQ,OAAO,SAAS,SAAU;AACvC,KAAI,kBAAkB,KAAK,CAAE;CAC7B,MAAM,mBAAmB,KAAK,qBAAqB,KAAK;AACxD,KAAI,qBAAqB,oBAAqB;CAE9C,MAAM,eAAe,KAAK,cAAc,KAAK;CAC7C,MAAM,YACJ,OAAO,iBAAiB,YAAY,aAAa,SAAS,IACtD,eACA;AAEN,OAAM,GAAG,SAAS,uBAAuB;EACvC,QAAQ;EACR,SAAS,aAAa;EACtB,MAAM,KAAK,UAAU;GACnB,UAAU;GACV;GACA,SAAS,eAAe,KAAK,IAA0B;GACvD,KAAM,KAAK,OAA8B,QAAQ,KAAK;GACtD,4BAAW,IAAI,MAAM,EAAC,aAAa;GACnC,MAAM;IACJ,mBAAmB;IACnB,OAAO,KAAK;IACZ,SAAS,KAAK;IACf;GACF,CAAC;EACF,QAAQ,YAAY,QAAQ,IAAK;EAClC,CAAC,CAAC,YAAY,GAAG;AAClB,kBAAiB,QAAQ,KAAK,EAAE,EAAE,IAAI,CAAC,OAAO;;AAGhD,MAAM,CAAC,YAAY,QAAQ,KAAK,EAAE,CAAC"}
@@ -34,6 +34,7 @@ async function main() {
34
34
  if (input.trim()) try {
35
35
  data = JSON.parse(input);
36
36
  } catch {}
37
+ if (!data || typeof data !== "object") data = {};
37
38
  if (isSdkChildContext(data)) return;
38
39
  const cwd = data.cwd || process.env["AGENTMEMORY_CWD"] || process.cwd();
39
40
  const sessionId = data.session_id || process.env["AGENTMEMORY_SESSION_ID"] || void 0;
@@ -94,7 +95,7 @@ async function main() {
94
95
  });
95
96
  } catch {}
96
97
  }
97
- main();
98
+ main().catch(() => process.exit(0));
98
99
  //#endregion
99
100
  export {};
100
101