diff --git a/README.md b/README.md index 2c29969d94..a0673a3083 100644 --- a/README.md +++ b/README.md @@ -197,6 +197,13 @@ agentmemory works with any agent that supports hooks, MCP, or REST API. All agen MCP server + + +Warp
+Warp
+connect + MCP + skills + +

@@ -558,7 +565,12 @@ The agentmemory entry is the **same MCP server block** across every host that us | **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. | +| **Warp** | `~/.warp/.mcp.json` | `agentmemory connect warp` writes the standard `mcpServers` block. Warp also auto-discovers skills from `.claude/skills/` — once the Claude Code plugin is installed the 8 agentmemory skills (`remember`, `recall`, `recap`, `handoff`, `forget`, `commit-context`, `commit-history`, `session-history`) appear natively in Warp's slash-command palette. | +| **Cline (CLI)** | `~/.cline/mcp.json` | `agentmemory connect cline` writes the standard `mcpServers` block. VS Code extension users: paste the same block via Cline Settings → MCP Servers → Edit JSON. | +| **Continue.dev** | `~/.continue/config.yaml` (preferred) or `config.json` (legacy) | `agentmemory connect continue` creates `config.yaml` from scratch when neither exists, or modifies existing `config.json`. **If you already have `config.yaml`** the adapter prints the exact block to paste under `mcpServers:` — it won't silently rewrite your yaml because preserving comments and anchors safely needs a YAML parser the package doesn't ship. Continue uses array form (not object) for `mcpServers`. | +| **Zed** | `~/.config/zed/settings.json` | `agentmemory connect zed` writes under `context_servers` (Zed's key, NOT `mcpServers`). Remote MCP servers can be wired via `{"url": "..."}` instead. | +| **Droid (Factory.ai)** | `~/.factory/mcp.json` | `agentmemory connect droid` writes the standard `mcpServers` block. Project-scoped overrides go in `/.factory/mcp.json`. The `/mcp` slash command inside droid lists configured servers. | +| **Goose** | Goose MCP settings UI | Same `mcpServers` block — use `goose configure` → Add Extension → MCP. Direct YAML edit at `~/.config/goose/config.yaml` is supported but the schema uses `extensions:` + `cmd` (not `mcpServers:` + `command`). | | **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. | diff --git a/src/cli/connect/cline.ts b/src/cli/connect/cline.ts new file mode 100644 index 0000000000..3fb44aedf2 --- /dev/null +++ b/src/cli/connect/cline.ts @@ -0,0 +1,19 @@ +import { homedir } from "node:os"; +import { join } from "node:path"; +import { createJsonMcpAdapter } from "./json-mcp-adapter.js"; + +// Cline CLI stores MCP server config at ~/.cline/mcp.json with the +// canonical `mcpServers` wrapper — same schema as Claude Code with +// optional `disabled` and `autoApprove` fields per entry. +// VS Code extension users manage MCP through Cline's Settings UI; +// this adapter targets the standalone CLI surface. +// Source: github.com/cline/cline/blob/main/docs/mcp/mcp-overview.mdx +export const adapter = createJsonMcpAdapter({ + name: "cline", + displayName: "Cline", + detectDir: join(homedir(), ".cline"), + configPath: join(homedir(), ".cline", "mcp.json"), + docs: "https://github.com/rohitg00/agentmemory#other-agents", + protocolNote: + "→ Using MCP via ~/.cline/mcp.json (CLI). VS Code users: add the same block via Cline Settings → MCP Servers → Edit JSON.", +}); diff --git a/src/cli/connect/continue.ts b/src/cli/connect/continue.ts new file mode 100644 index 0000000000..4a2cb820ba --- /dev/null +++ b/src/cli/connect/continue.ts @@ -0,0 +1,163 @@ +import { existsSync, mkdirSync, writeFileSync } from "node:fs"; +import { homedir } from "node:os"; +import { dirname, join } from "node:path"; +import * as p from "@clack/prompts"; +import type { ConnectAdapter, ConnectOptions, ConnectResult } from "./types.js"; +import { + AGENTMEMORY_MCP_BLOCK, + backupFile, + logAlreadyWired, + logBackup, + logInstalled, + readJsonSafe, + writeJsonAtomic, +} from "./util.js"; + +// Continue.dev v1+ prefers ~/.continue/config.yaml; config.json is +// deprecated and ignored when yaml is present. Three branches: +// - config.yaml exists → emit stub with manual edit instructions +// (no YAML dep in tree; preserving comments/anchors safely needs it) +// - config.json exists → modify it (legacy path still loaded when no yaml) +// - neither → create config.yaml from scratch (no merge risk) +// Source: docs.continue.dev/reference/yaml-migration +const CONTINUE_DIR = join(homedir(), ".continue"); +const YAML_PATH = join(CONTINUE_DIR, "config.yaml"); +const JSON_PATH = join(CONTINUE_DIR, "config.json"); + +type ContinueEntry = { + name: string; + command: string; + args: string[]; + env?: Record; +}; + +type ContinueJsonConfig = { + mcpServers?: ContinueEntry[]; + [key: string]: unknown; +}; + +function buildEntry(): ContinueEntry { + return { + name: "agentmemory", + command: AGENTMEMORY_MCP_BLOCK.command, + args: [...AGENTMEMORY_MCP_BLOCK.args], + env: { ...AGENTMEMORY_MCP_BLOCK.env }, + }; +} + +function entryIsAgentmemory(entry: ContinueEntry | undefined): boolean { + if (!entry) return false; + return entry.name === "agentmemory" && entry.args.includes("@agentmemory/mcp"); +} + +// Minimal YAML emitter for the agentmemory entry. Quotes string values +// that contain ${ ... } expansion to keep parsers happy. Only used when +// creating a fresh config.yaml — never when modifying an existing one. +function renderFreshYaml(): string { + const e = buildEntry(); + const envLines = Object.entries(e.env ?? {}) + .map(([k, v]) => ` ${k}: "${v}"`) + .join("\n"); + return [ + "mcpServers:", + ` - name: ${e.name}`, + ` command: ${e.command}`, + " args:", + ...e.args.map((a) => ` - "${a}"`), + " env:", + envLines, + "", + ].join("\n"); +} + +export const adapter: ConnectAdapter = { + name: "continue", + displayName: "Continue", + docs: "https://github.com/rohitg00/agentmemory#other-agents", + protocolNote: + "→ Using MCP via ~/.continue/config.yaml (preferred) or config.json (legacy, only when no yaml).", + + detect(): boolean { + return existsSync(CONTINUE_DIR); + }, + + async install(opts: ConnectOptions): Promise { + const yamlExists = existsSync(YAML_PATH); + const jsonExists = existsSync(JSON_PATH); + + // Branch 1: yaml present — refuse to silently mutate user's yaml + // config (preserving comments/anchors needs a proper parser). + if (yamlExists) { + const indented = renderFreshYaml() + .split("\n") + .map((l) => (l ? ` ${l}` : l)) + .join("\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}`; + p.log.info( + `Continue: ${YAML_PATH} already exists. Manual edit needed.${manual}`, + ); + return { kind: "stub", reason: "config.yaml-needs-manual-edit" }; + } + + // Branch 2: legacy json present — modify in place. + if (jsonExists) { + const existing = readJsonSafe(JSON_PATH); + const next: ContinueJsonConfig = existing ? { ...existing } : {}; + const servers = Array.isArray(next.mcpServers) + ? [...next.mcpServers] + : []; + + const idx = servers.findIndex((s) => s?.name === "agentmemory"); + const alreadyHas = idx >= 0 && entryIsAgentmemory(servers[idx]); + if (alreadyHas && !opts.force) { + logAlreadyWired("Continue", JSON_PATH); + return { kind: "already-wired", mutatedPath: JSON_PATH }; + } + + if (opts.dryRun) { + p.log.info( + `[dry-run] Would ${alreadyHas ? "overwrite" : "add"} mcpServers[agentmemory] in ${JSON_PATH}`, + ); + return { kind: "installed", mutatedPath: JSON_PATH }; + } + + const backupPath = backupFile(JSON_PATH, "continue"); + logBackup(backupPath); + + const entry = buildEntry(); + if (idx >= 0) servers[idx] = entry; + else servers.push(entry); + next.mcpServers = servers; + writeJsonAtomic(JSON_PATH, next); + + const verify = readJsonSafe(JSON_PATH); + const verifyEntry = verify?.mcpServers?.find( + (s) => s?.name === "agentmemory", + ); + if (!entryIsAgentmemory(verifyEntry)) { + p.log.error( + `Verification failed: ${JSON_PATH} did not contain mcpServers[agentmemory] after write.`, + ); + return { kind: "skipped", reason: "verification-failed" }; + } + + logInstalled("Continue (legacy config.json)", JSON_PATH); + return { + kind: "installed", + mutatedPath: JSON_PATH, + backupPath, + }; + } + + // Branch 3: neither exists — create config.yaml from scratch (modern path). + if (opts.dryRun) { + p.log.info(`[dry-run] Would create ${YAML_PATH} with agentmemory entry`); + return { kind: "installed", mutatedPath: YAML_PATH }; + } + + mkdirSync(dirname(YAML_PATH), { recursive: true }); + writeFileSync(YAML_PATH, renderFreshYaml(), "utf-8"); + logInstalled("Continue", YAML_PATH); + return { kind: "installed", mutatedPath: YAML_PATH }; + }, +}; diff --git a/src/cli/connect/droid.ts b/src/cli/connect/droid.ts new file mode 100644 index 0000000000..92ae69edd6 --- /dev/null +++ b/src/cli/connect/droid.ts @@ -0,0 +1,21 @@ +import { homedir } from "node:os"; +import { join } from "node:path"; +import { createJsonMcpAdapter } from "./json-mcp-adapter.js"; + +// Factory.ai's Droid CLI stores MCP server config at ~/.factory/mcp.json +// with the canonical `mcpServers` wrapper. Project-scoped overrides live +// at /.factory/mcp.json. Each entry adds an optional `type` field +// ("stdio" | "http") and `disabled` boolean — agentmemory's stdio block +// works against the same shape without needing the explicit type tag. +// Source: docs.factory.ai/cli/configuration/mcp +export const adapter = createJsonMcpAdapter({ + name: "droid", + displayName: "Droid (Factory.ai)", + detectDir: join(homedir(), ".factory"), + configPath: join(homedir(), ".factory", "mcp.json"), + docs: "https://github.com/rohitg00/agentmemory#other-agents", + protocolNote: + "→ Using MCP via ~/.factory/mcp.json. The `/mcp` slash command inside droid lists configured servers.", + // Droid requires `type` per the documented schema. stdio for npx-spawned shim. + extraEntryFields: { type: "stdio" }, +}); diff --git a/src/cli/connect/index.ts b/src/cli/connect/index.ts index b7fa2e718b..6fe4f54fa5 100644 --- a/src/cli/connect/index.ts +++ b/src/cli/connect/index.ts @@ -3,8 +3,11 @@ 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 cline } from "./cline.js"; import { adapter as codex } from "./codex.js"; +import { adapter as continueDev } from "./continue.js"; import { adapter as cursor } from "./cursor.js"; +import { adapter as droid } from "./droid.js"; import { adapter as geminiCli } from "./gemini-cli.js"; import { adapter as hermes } from "./hermes.js"; import { adapter as kiro } from "./kiro.js"; @@ -12,6 +15,8 @@ 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"; +import { adapter as warp } from "./warp.js"; +import { adapter as zed } from "./zed.js"; export const ADAPTERS: readonly ConnectAdapter[] = [ claudeCode, @@ -21,6 +26,11 @@ export const ADAPTERS: readonly ConnectAdapter[] = [ qwen, antigravity, kiro, + warp, + cline, + continueDev, + zed, + droid, openclaw, hermes, pi, diff --git a/src/cli/connect/json-mcp-adapter.ts b/src/cli/connect/json-mcp-adapter.ts index d72eb45cf5..14ba41b6f7 100644 --- a/src/cli/connect/json-mcp-adapter.ts +++ b/src/cli/connect/json-mcp-adapter.ts @@ -19,13 +19,16 @@ export type JsonMcpAdapterConfig = { configPath: string; docs?: string; protocolNote?: string; + // Wrapper key under which servers live. Default "mcpServers". + // Zed uses "context_servers"; otherwise same shape. + wrapperKey?: string; + // Extra fields merged into the agentmemory entry. Droid requires + // type: "stdio"; other hosts ignore unknown fields. + extraEntryFields?: Record; }; type McpEntry = typeof AGENTMEMORY_MCP_BLOCK; -type McpConfig = { - mcpServers?: Record; - [key: string]: unknown; -}; +type McpConfig = Record; function entryMatches(entry: unknown): boolean { if (!entry || typeof entry !== "object") return false; @@ -38,6 +41,7 @@ function entryMatches(entry: unknown): boolean { export function createJsonMcpAdapter( config: JsonMcpAdapterConfig, ): ConnectAdapter { + const wrapperKey = config.wrapperKey ?? "mcpServers"; return { name: config.name, displayName: config.displayName, @@ -54,7 +58,7 @@ export function createJsonMcpAdapter( const existing = readJsonSafe(config.configPath); const next: McpConfig = existing ? { ...existing } : {}; const servers: Record = { - ...((next.mcpServers as Record) ?? {}), + ...((next[wrapperKey] as Record) ?? {}), }; const alreadyHas = entryMatches(servers["agentmemory"]); @@ -65,7 +69,7 @@ export function createJsonMcpAdapter( if (opts.dryRun) { p.log.info( - `[dry-run] Would ${alreadyHas ? "overwrite" : "add"} mcpServers.agentmemory in ${config.configPath}`, + `[dry-run] Would ${alreadyHas ? "overwrite" : "add"} ${wrapperKey}.agentmemory in ${config.configPath}`, ); return { kind: "installed", mutatedPath: config.configPath }; } @@ -78,14 +82,20 @@ export function createJsonMcpAdapter( mkdirSync(dirname(config.configPath), { recursive: true }); } - servers["agentmemory"] = AGENTMEMORY_MCP_BLOCK; - next.mcpServers = servers; + servers["agentmemory"] = { + ...AGENTMEMORY_MCP_BLOCK, + ...(config.extraEntryFields ?? {}), + }; + next[wrapperKey] = servers; writeJsonAtomic(config.configPath, next); const verify = readJsonSafe(config.configPath); - if (!entryMatches(verify?.mcpServers?.["agentmemory"])) { + const verifyServers = verify?.[wrapperKey] as + | Record + | undefined; + if (!entryMatches(verifyServers?.["agentmemory"])) { p.log.error( - `Verification failed: ${config.configPath} did not contain mcpServers.agentmemory after write.`, + `Verification failed: ${config.configPath} did not contain ${wrapperKey}.agentmemory after write.`, ); return { kind: "skipped", reason: "verification-failed" }; } diff --git a/src/cli/connect/warp.ts b/src/cli/connect/warp.ts new file mode 100644 index 0000000000..5ce87f5151 --- /dev/null +++ b/src/cli/connect/warp.ts @@ -0,0 +1,19 @@ +import { homedir } from "node:os"; +import { join } from "node:path"; +import { createJsonMcpAdapter } from "./json-mcp-adapter.js"; + +// Warp stores MCP server config at ~/.warp/.mcp.json with the +// canonical `mcpServers` wrapper — identical schema to Claude Code. +// Warp also auto-discovers skills from .claude/skills/ so the +// agentmemory plugin's 8 skills are surfaced natively once the +// Claude Code plugin is installed. +// Source: docs.warp.dev/agent-platform/capabilities/mcp/ +export const adapter = createJsonMcpAdapter({ + name: "warp", + displayName: "Warp", + detectDir: join(homedir(), ".warp"), + configPath: join(homedir(), ".warp", ".mcp.json"), + docs: "https://github.com/rohitg00/agentmemory#other-agents", + protocolNote: + "→ Using MCP via ~/.warp/.mcp.json. Skills auto-discover from .claude/skills/ if the Claude Code plugin is also installed.", +}); diff --git a/src/cli/connect/zed.ts b/src/cli/connect/zed.ts new file mode 100644 index 0000000000..bad7730d85 --- /dev/null +++ b/src/cli/connect/zed.ts @@ -0,0 +1,22 @@ +import { homedir } from "node:os"; +import { join } from "node:path"; +import { createJsonMcpAdapter } from "./json-mcp-adapter.js"; + +// Zed stores its settings (including MCP servers) under "context_servers" +// in settings.json — NOT "mcpServers". User config lives at +// ~/.config/zed/settings.json on all platforms (Zed uses the XDG path +// even on macOS; ~/Library/Application Support/Zed/ holds runtime data +// like the database + cached language servers, not the config). +// Source: zed.dev/docs/ai/mcp + zed.dev/docs/configuring-zed +const zedConfigDir = join(homedir(), ".config", "zed"); + +export const adapter = createJsonMcpAdapter({ + name: "zed", + displayName: "Zed", + detectDir: zedConfigDir, + configPath: join(zedConfigDir, "settings.json"), + wrapperKey: "context_servers", + docs: "https://github.com/rohitg00/agentmemory#other-agents", + protocolNote: + "→ Using MCP via ~/.config/zed/settings.json (key: context_servers).", +}); diff --git a/test/cli-connect.test.ts b/test/cli-connect.test.ts index 11b2395b18..5f4faff678 100644 --- a/test/cli-connect.test.ts +++ b/test/cli-connect.test.ts @@ -30,13 +30,15 @@ describe("agentmemory connect — dispatcher", () => { }); it("ships the supported agent list", () => { - // Bumped to 11 after adding Qwen Code + Antigravity + Kiro. expect(knownAgents().sort()).toEqual( [ "antigravity", "claude-code", + "cline", "codex", + "continue", "cursor", + "droid", "gemini-cli", "hermes", "kiro", @@ -44,9 +46,11 @@ describe("agentmemory connect — dispatcher", () => { "openhuman", "pi", "qwen", + "warp", + "zed", ].sort(), ); - expect(ADAPTERS.length).toBe(11); + expect(ADAPTERS.length).toBe(16); }); it("every adapter exposes detect() and install()", () => { diff --git a/test/connect-new-agents.test.ts b/test/connect-new-agents.test.ts index d73f1c0f76..9ac4485ab5 100644 --- a/test/connect-new-agents.test.ts +++ b/test/connect-new-agents.test.ts @@ -114,16 +114,234 @@ describe("connect: Kiro", () => { }); }); -describe("connect: all three agents registered in ADAPTERS", () => { +describe("connect: Warp", () => { + 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 ~/.warp/ is absent", async () => { + const { adapter } = await import("../src/cli/connect/warp.js"); + expect(adapter.detect()).toBe(false); + }); + + it("writes mcpServers.agentmemory to ~/.warp/.mcp.json", async () => { + mkdirSync(join(home, ".warp"), { recursive: true }); + const { adapter } = await import("../src/cli/connect/warp.js"); + expect(adapter.detect()).toBe(true); + const result = await adapter.install({ dryRun: false, force: false }); + expect(result.kind).toBe("installed"); + const cfgPath = join(home, ".warp", ".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"); + expect(cfg.mcpServers.agentmemory.env.AGENTMEMORY_URL).toMatch( + /\$\{AGENTMEMORY_URL:-/, + ); + }); +}); + +describe("connect: Cline", () => { + 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 ~/.cline/ is absent", async () => { + const { adapter } = await import("../src/cli/connect/cline.js"); + expect(adapter.detect()).toBe(false); + }); + + it("writes mcpServers.agentmemory to ~/.cline/mcp.json", async () => { + mkdirSync(join(home, ".cline"), { recursive: true }); + const { adapter } = await import("../src/cli/connect/cline.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, ".cline", "mcp.json"), "utf-8"), + ); + expect(cfg.mcpServers.agentmemory.command).toBe("npx"); + expect(cfg.mcpServers.agentmemory.args).toContain("@agentmemory/mcp"); + }); +}); + +describe("connect: Droid (Factory.ai)", () => { + 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 ~/.factory/ is absent", async () => { + const { adapter } = await import("../src/cli/connect/droid.js"); + expect(adapter.detect()).toBe(false); + }); + + it("writes mcpServers.agentmemory to ~/.factory/mcp.json with type:stdio", async () => { + mkdirSync(join(home, ".factory"), { recursive: true }); + const { adapter } = await import("../src/cli/connect/droid.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, ".factory", "mcp.json"), "utf-8"), + ); + expect(cfg.mcpServers.agentmemory.command).toBe("npx"); + expect(cfg.mcpServers.agentmemory.args).toContain("@agentmemory/mcp"); + // Droid requires `type` per its documented schema + expect(cfg.mcpServers.agentmemory.type).toBe("stdio"); + }); +}); + +describe("connect: Zed", () => { + 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 ~/.config/zed/ is absent", async () => { + const { adapter } = await import("../src/cli/connect/zed.js"); + expect(adapter.detect()).toBe(false); + }); + + it("writes context_servers.agentmemory to ~/.config/zed/settings.json", async () => { + mkdirSync(join(home, ".config", "zed"), { recursive: true }); + const { adapter } = await import("../src/cli/connect/zed.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, ".config", "zed", "settings.json"), "utf-8"), + ); + expect(cfg.context_servers.agentmemory.command).toBe("npx"); + expect(cfg.context_servers.agentmemory.args).toContain("@agentmemory/mcp"); + expect(cfg.mcpServers).toBeUndefined(); + }); +}); + +describe("connect: Continue.dev", () => { + 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 ~/.continue/ is absent", async () => { + const { adapter } = await import("../src/cli/connect/continue.js"); + expect(adapter.detect()).toBe(false); + }); + + it("creates config.yaml from scratch when neither yaml nor json exists", async () => { + mkdirSync(join(home, ".continue"), { recursive: true }); + const { adapter } = await import("../src/cli/connect/continue.js"); + expect(adapter.detect()).toBe(true); + const result = await adapter.install({ dryRun: false, force: false }); + expect(result.kind).toBe("installed"); + const yamlPath = join(home, ".continue", "config.yaml"); + expect(existsSync(yamlPath)).toBe(true); + expect(existsSync(join(home, ".continue", "config.json"))).toBe(false); + const yaml = readFileSync(yamlPath, "utf-8"); + expect(yaml).toContain("mcpServers:"); + expect(yaml).toContain("name: agentmemory"); + expect(yaml).toContain("@agentmemory/mcp"); + expect(yaml).toContain("AGENTMEMORY_URL"); + }); + + it("modifies existing legacy config.json", async () => { + mkdirSync(join(home, ".continue"), { recursive: true }); + const { writeFileSync } = await import("node:fs"); + writeFileSync( + join(home, ".continue", "config.json"), + JSON.stringify({ models: [], mcpServers: [] }), + ); + const { adapter } = await import("../src/cli/connect/continue.js"); + const result = await adapter.install({ dryRun: false, force: false }); + expect(result.kind).toBe("installed"); + const cfg = JSON.parse( + readFileSync(join(home, ".continue", "config.json"), "utf-8"), + ); + expect(Array.isArray(cfg.mcpServers)).toBe(true); + const entry = cfg.mcpServers.find( + (s: { name: string }) => s.name === "agentmemory", + ); + expect(entry.command).toBe("npx"); + expect(entry.args).toContain("@agentmemory/mcp"); + }); + + it("returns stub when config.yaml already exists (refuses silent yaml mutation)", async () => { + mkdirSync(join(home, ".continue"), { recursive: true }); + const { writeFileSync } = await import("node:fs"); + writeFileSync( + join(home, ".continue", "config.yaml"), + "models: []\nmcpServers:\n - name: existing\n command: noop\n", + ); + const { adapter } = await import("../src/cli/connect/continue.js"); + const result = await adapter.install({ dryRun: false, force: false }); + expect(result.kind).toBe("stub"); + // user's yaml must be untouched + const yaml = readFileSync( + join(home, ".continue", "config.yaml"), + "utf-8", + ); + expect(yaml).toContain("existing"); + expect(yaml).not.toContain("agentmemory"); + }); +}); + +describe("connect: all eight new agents registered in ADAPTERS", () => { beforeEach(() => { vi.resetModules(); }); - it("knownAgents includes qwen, antigravity, kiro", async () => { + it("knownAgents includes qwen, antigravity, kiro, warp, cline, continue, zed, droid", 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"); + for (const name of [ + "qwen", + "antigravity", + "kiro", + "warp", + "cline", + "continue", + "zed", + "droid", + ]) { + expect(agents).toContain(name); + } }); });