Skip to content

#1 Persistent memory for AI coding agents based on real-world benchmarks

feat(connect): Qwen Code + Antigravity + Kiro adapters; docs(ports) (#651)

Rohit Ghumarebfb5e667115c
diff --git a/README.md b/README.md
index d2f18290..04137b75 100644
--- a/README.md
+++ b/README.md
@@ -540,6 +540,9 @@ The agentmemory entry is the **same MCP server block** across every host that us
| **OpenCode (full plugin)** | `plugin/opencode/` | 22 auto-capture hooks covering session lifecycle, messages, tools, errors. Two slash commands (`/recall`, `/remember`). Copy `plugin/opencode/` into your OpenCode workspace and add the plugin entry to `opencode.json`. See [`plugin/opencode/README.md`](plugin/opencode/README.md) for the full hook table + gap analysis. |
| **pi** | `~/.pi/agent/extensions/agentmemory` | Copy [`integrations/pi`](integrations/pi/) and restart pi. |
| **Hermes Agent** | `~/.hermes/config.yaml` | Use the deeper [memory provider plugin](integrations/hermes/) with `memory.provider: agentmemory`. |
+| **Qwen Code** | `~/.qwen/settings.json` | `agentmemory connect qwen` writes the standard `mcpServers` block. Hook payload is field-compatible with Claude Code, so the existing 12-hook scripts work without modification — wire them via the `hooks` section in the same `settings.json`. |
+| **Antigravity** (replaces Gemini CLI) | `mcp_config.json` (in Antigravity's User dir) | `agentmemory connect antigravity` writes the standard `mcpServers` block. macOS: `~/Library/Application Support/Antigravity/User/`. Linux: `~/.config/Antigravity/User/`. Use after the 2026-06-18 Gemini CLI sunset. |
+| **Kiro** | `~/.kiro/settings/mcp.json` | `agentmemory connect kiro` writes the user-level config. Workspace overrides go in `.kiro/settings/mcp.json` next to your code. |
| **Goose** | Goose MCP settings UI | Same `mcpServers` block. |
| **Aider** | n/a | Talk to the REST API directly: `curl -X POST http://localhost:3111/agentmemory/smart-search -d '{"query": "auth"}'`. |
| **Any agent (32+)** | n/a | `npx skillkit install agentmemory` auto-detects the host and merges. |
@@ -1089,6 +1092,32 @@ agentmemory auto-detects from your environment. By default, no LLM calls are mad
| OpenRouter | `OPENROUTER_API_KEY` | Any model |
| Claude subscription fallback | `AGENTMEMORY_ALLOW_AGENT_SDK=true` | Opt-in only. Spawns `@anthropic-ai/claude-agent-sdk` sessions — used to cause unbounded Stop-hook recursion (#149 follow-up) so it is no longer the default. |
+### Ports
+
+agentmemory + iii-engine bind four ports by default. If a restart fails with `port in use`, this table tells you which process to look for.
+
+| Port | Process | Purpose | Env override |
+|------|---------|---------|--------------|
+| `3111` | agentmemory | REST API + MCP HTTP + `/agentmemory/health` + `/agentmemory/livez` | `III_REST_PORT` |
+| `3112` | iii-engine | Internal streams worker (consumed by agentmemory + viewer) | `III_STREAMS_PORT` |
+| `3113` | agentmemory | Real-time viewer (`http://localhost:3113`) | `AGENTMEMORY_VIEWER_PORT` |
+| `49134` | iii-engine | WebSocket — workers register here, OTel telemetry flows over it | `III_ENGINE_URL` (full URL, default `ws://localhost:49134`) |
+
+Stale-process cleanup when ports stay bound after a crashed run:
+
+```bash
+# macOS / Linux — find whatever is on each port and kill it
+lsof -i :3111,3112,3113,49134
+pkill -f agentmemory || true
+pkill -f 'iii ' || true
+
+# Windows
+netstat -ano | findstr ":3111 :3112 :3113 :49134"
+taskkill /F /PID <pid>
+```
+
+`agentmemory stop` reaps both the worker and the engine pidfile cleanly on graceful shutdown (#640, #474). The manual cleanup above is only for the post-crash case where neither pidfile is left behind.
+
### Config File
Put agentmemory runtime configuration in `~/.agentmemory/.env` instead of exporting variables in every shell. If the viewer shows a setup hint like `export ANTHROPIC_API_KEY=...`, copy it into this file as `ANTHROPIC_API_KEY=...` without the `export` prefix, then restart agentmemory.
diff --git a/src/cli/connect/antigravity.ts b/src/cli/connect/antigravity.ts
new file mode 100644
index 00000000..559a7b7c
--- /dev/null
+++ b/src/cli/connect/antigravity.ts
@@ -0,0 +1,25 @@
+import { homedir, platform } from "node:os";
+import { join } from "node:path";
+import { createJsonMcpAdapter } from "./json-mcp-adapter.js";
+
+// Antigravity stores MCP config in mcp_config.json under its app
+// support directory. The schema follows the standard MCP envelope —
+// `{ mcpServers: { ... } }`. Path varies by platform:
+// macOS: ~/Library/Application Support/Antigravity/User/mcp_config.json
+// Linux: ~/.config/Antigravity/User/mcp_config.json
+// Windows: %APPDATA%/Antigravity/User/mcp_config.json
+// Connect is gated on win32 elsewhere; we cover macOS + Linux here.
+const ANTIGRAVITY_DIR =
+ platform() === "darwin"
+ ? join(homedir(), "Library", "Application Support", "Antigravity", "User")
+ : join(homedir(), ".config", "Antigravity", "User");
+
+export const adapter = createJsonMcpAdapter({
+ name: "antigravity",
+ displayName: "Antigravity",
+ detectDir: ANTIGRAVITY_DIR,
+ configPath: join(ANTIGRAVITY_DIR, "mcp_config.json"),
+ docs: "https://github.com/rohitg00/agentmemory#other-agents",
+ protocolNote:
+ "→ Using MCP via mcp_config.json. Antigravity replaces Gemini CLI (sunset 2026-06-18).",
+});
diff --git a/src/cli/connect/index.ts b/src/cli/connect/index.ts
index 48c23c66..b7fa2e71 100644
--- a/src/cli/connect/index.ts
+++ b/src/cli/connect/index.ts
@@ -1,20 +1,26 @@
import { platform } from "node:os";
import * as p from "@clack/prompts";
import type { ConnectAdapter, ConnectOptions, ConnectResult } from "./types.js";
+import { adapter as antigravity } from "./antigravity.js";
import { adapter as claudeCode } from "./claude-code.js";
import { adapter as codex } from "./codex.js";
import { adapter as cursor } from "./cursor.js";
import { adapter as geminiCli } from "./gemini-cli.js";
import { adapter as hermes } from "./hermes.js";
+import { adapter as kiro } from "./kiro.js";
import { adapter as openclaw } from "./openclaw.js";
import { adapter as openhuman } from "./openhuman.js";
import { adapter as pi } from "./pi.js";
+import { adapter as qwen } from "./qwen.js";
export const ADAPTERS: readonly ConnectAdapter[] = [
claudeCode,
codex,
cursor,
geminiCli,
+ qwen,
+ antigravity,
+ kiro,
openclaw,
hermes,
pi,
diff --git a/src/cli/connect/kiro.ts b/src/cli/connect/kiro.ts
new file mode 100644
index 00000000..487a9ffe
--- /dev/null
+++ b/src/cli/connect/kiro.ts
@@ -0,0 +1,16 @@
+import { homedir } from "node:os";
+import { join } from "node:path";
+import { createJsonMcpAdapter } from "./json-mcp-adapter.js";
+
+// Kiro stores user-level MCP servers in ~/.kiro/settings/mcp.json.
+// Schema follows the standard MCP envelope { mcpServers: { ... } }.
+// Source: kiro.dev/docs/cli/mcp
+export const adapter = createJsonMcpAdapter({
+ name: "kiro",
+ displayName: "Kiro",
+ detectDir: join(homedir(), ".kiro"),
+ configPath: join(homedir(), ".kiro", "settings", "mcp.json"),
+ docs: "https://github.com/rohitg00/agentmemory#other-agents",
+ protocolNote:
+ "→ Using MCP via ~/.kiro/settings/mcp.json (user-level). Workspace overrides live in .kiro/settings/mcp.json.",
+});
diff --git a/src/cli/connect/qwen.ts b/src/cli/connect/qwen.ts
new file mode 100644
index 00000000..53296849
--- /dev/null
+++ b/src/cli/connect/qwen.ts
@@ -0,0 +1,17 @@
+import { homedir } from "node:os";
+import { join } from "node:path";
+import { createJsonMcpAdapter } from "./json-mcp-adapter.js";
+
+// Qwen Code stores its settings (mcpServers + hooks) in
+// ~/.qwen/settings.json. Schema for mcpServers matches Claude Code's
+// shape, so the shared JSON adapter handles the wiring.
+// Source: qwenlm.github.io/qwen-code-docs/en/users/features/mcp
+export const adapter = createJsonMcpAdapter({
+ name: "qwen",
+ displayName: "Qwen Code",
+ detectDir: join(homedir(), ".qwen"),
+ configPath: join(homedir(), ".qwen", "settings.json"),
+ docs: "https://github.com/rohitg00/agentmemory#other-agents",
+ protocolNote:
+ "→ Using MCP via ~/.qwen/settings.json. Qwen Code's hook system can also be wired separately — see docs.",
+});
diff --git a/test/cli-connect.test.ts b/test/cli-connect.test.ts
index 37b0b00e..83dfb66e 100644
--- a/test/cli-connect.test.ts
+++ b/test/cli-connect.test.ts
@@ -29,20 +29,24 @@ describe("agentmemory connect — dispatcher", () => {
expect(resolveAdapter("")).toBeNull();
});
- it("ships exactly the 8 agents specified by the spec", () => {
+ it("ships the supported agent list", () => {
+ // Bumped to 11 with Qwen Code (#647), Antigravity (#614), Kiro (#618).
expect(knownAgents().sort()).toEqual(
[
+ "antigravity",
"claude-code",
"codex",
"cursor",
"gemini-cli",
"hermes",
+ "kiro",
"openclaw",
"openhuman",
"pi",
+ "qwen",
].sort(),
);
- expect(ADAPTERS.length).toBe(8);
+ expect(ADAPTERS.length).toBe(11);
});
it("every adapter exposes detect() and install()", () => {
diff --git a/test/connect-new-agents.test.ts b/test/connect-new-agents.test.ts
new file mode 100644
index 00000000..8120eae3
--- /dev/null
+++ b/test/connect-new-agents.test.ts
@@ -0,0 +1,130 @@
+import { describe, it, expect, beforeEach, afterEach, vi } from "vitest";
+import { mkdtempSync, mkdirSync, rmSync, readFileSync, existsSync } from "node:fs";
+import { tmpdir, platform } from "node:os";
+import { join } from "node:path";
+
+// #647 / #614 / #618: connect adapters for Qwen Code, Antigravity, and
+// Kiro. Each writes the canonical agentmemory MCP block (npx
+// @agentmemory/mcp + env defaults from PR #650) into the agent's
+// documented config path.
+
+function freshHome(): string {
+ return mkdtempSync(join(tmpdir(), "am-connect-"));
+}
+
+describe("connect: Qwen Code (#647)", () => {
+ let home: string;
+ const ORIG = process.env["HOME"];
+ beforeEach(() => {
+ home = freshHome();
+ vi.resetModules();
+ process.env["HOME"] = home;
+ });
+ afterEach(() => {
+ process.env["HOME"] = ORIG;
+ rmSync(home, { recursive: true, force: true });
+ });
+
+ it("does not detect when ~/.qwen/ is absent", async () => {
+ const { adapter } = await import("../src/cli/connect/qwen.js");
+ expect(adapter.detect()).toBe(false);
+ });
+
+ it("writes mcpServers.agentmemory to ~/.qwen/settings.json", async () => {
+ mkdirSync(join(home, ".qwen"), { recursive: true });
+ const { adapter } = await import("../src/cli/connect/qwen.js");
+ expect(adapter.detect()).toBe(true);
+ const result = await adapter.install({ dryRun: false, force: false });
+ expect(result.kind).toBe("installed");
+ const cfg = JSON.parse(
+ readFileSync(join(home, ".qwen", "settings.json"), "utf-8"),
+ );
+ expect(cfg.mcpServers.agentmemory.command).toBe("npx");
+ expect(cfg.mcpServers.agentmemory.args).toContain("@agentmemory/mcp");
+ expect(cfg.mcpServers.agentmemory.env.AGENTMEMORY_URL).toMatch(
+ /\$\{AGENTMEMORY_URL:-/,
+ );
+ expect(cfg.mcpServers.agentmemory.env.AGENTMEMORY_TOOLS).toMatch(
+ /\$\{AGENTMEMORY_TOOLS:-all\}/,
+ );
+ });
+});
+
+describe("connect: Antigravity (#614)", () => {
+ let home: string;
+ const ORIG = process.env["HOME"];
+ beforeEach(() => {
+ home = freshHome();
+ vi.resetModules();
+ process.env["HOME"] = home;
+ });
+ afterEach(() => {
+ process.env["HOME"] = ORIG;
+ rmSync(home, { recursive: true, force: true });
+ });
+
+ it("writes mcpServers.agentmemory to the platform-specific config path", async () => {
+ const isMac = platform() === "darwin";
+ const userDir = isMac
+ ? join(home, "Library", "Application Support", "Antigravity", "User")
+ : join(home, ".config", "Antigravity", "User");
+ mkdirSync(userDir, { recursive: true });
+ const { adapter } = await import("../src/cli/connect/antigravity.js");
+ expect(adapter.detect()).toBe(true);
+ const result = await adapter.install({ dryRun: false, force: false });
+ expect(result.kind).toBe("installed");
+ const cfg = JSON.parse(
+ readFileSync(join(userDir, "mcp_config.json"), "utf-8"),
+ );
+ expect(cfg.mcpServers.agentmemory.command).toBe("npx");
+ expect(cfg.mcpServers.agentmemory.env.AGENTMEMORY_URL).toMatch(
+ /\$\{AGENTMEMORY_URL:-/,
+ );
+ });
+});
+
+describe("connect: Kiro (#618)", () => {
+ let home: string;
+ const ORIG = process.env["HOME"];
+ beforeEach(() => {
+ home = freshHome();
+ vi.resetModules();
+ process.env["HOME"] = home;
+ });
+ afterEach(() => {
+ process.env["HOME"] = ORIG;
+ rmSync(home, { recursive: true, force: true });
+ });
+
+ it("does not detect when ~/.kiro/ is absent", async () => {
+ const { adapter } = await import("../src/cli/connect/kiro.js");
+ expect(adapter.detect()).toBe(false);
+ });
+
+ it("writes mcpServers.agentmemory to ~/.kiro/settings/mcp.json", async () => {
+ mkdirSync(join(home, ".kiro"), { recursive: true });
+ const { adapter } = await import("../src/cli/connect/kiro.js");
+ expect(adapter.detect()).toBe(true);
+ const result = await adapter.install({ dryRun: false, force: false });
+ expect(result.kind).toBe("installed");
+ const cfgPath = join(home, ".kiro", "settings", "mcp.json");
+ expect(existsSync(cfgPath)).toBe(true);
+ const cfg = JSON.parse(readFileSync(cfgPath, "utf-8"));
+ expect(cfg.mcpServers.agentmemory.command).toBe("npx");
+ expect(cfg.mcpServers.agentmemory.args).toContain("@agentmemory/mcp");
+ });
+});
+
+describe("connect: all three agents registered in ADAPTERS", () => {
+ beforeEach(() => {
+ vi.resetModules();
+ });
+
+ it("knownAgents includes qwen, antigravity, kiro", async () => {
+ const { knownAgents } = await import("../src/cli/connect/index.js");
+ const agents = knownAgents();
+ expect(agents).toContain("qwen");
+ expect(agents).toContain("antigravity");
+ expect(agents).toContain("kiro");
+ });
+});