From 9e85039c80f81270a5def4f6ef73a1b55f4ff484 Mon Sep 17 00:00:00 2001 From: Rohit Ghumare Date: Wed, 10 Jun 2026 18:01:06 +0100 Subject: [PATCH] refactor(connect): adapters declare category so onboarding needs no hardcoded list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Onboarding still kept a hardcoded NATIVE_AGENTS set to label the picker (native plugin vs MCP server), decoupled from the adapters and prone to the same drift as the agent list (#872) — it had even mislabeled openclaw. Add a category field to ConnectAdapter (default mcp; factory sets mcp; the 7 native plugin/hook adapters set native), derive the onboarding hint from a.category, and assert every adapter declares one so a future adapter without a category fails CI. --- src/cli/connect/claude-code.ts | 1 + src/cli/connect/codex.ts | 1 + src/cli/connect/continue.ts | 1 + src/cli/connect/copilot-cli.ts | 1 + src/cli/connect/hermes.ts | 1 + src/cli/connect/json-mcp-adapter.ts | 5 +++++ src/cli/connect/openclaw.ts | 1 + src/cli/connect/opencode.ts | 1 + src/cli/connect/openhuman.ts | 1 + src/cli/connect/pi.ts | 1 + src/cli/connect/types.ts | 7 +++++++ src/cli/onboarding.ts | 15 +-------------- test/cli-connect.test.ts | 9 +++++++++ 13 files changed, 31 insertions(+), 14 deletions(-) diff --git a/src/cli/connect/claude-code.ts b/src/cli/connect/claude-code.ts index 76df149203..8fcb2ccab7 100644 --- a/src/cli/connect/claude-code.ts +++ b/src/cli/connect/claude-code.ts @@ -39,6 +39,7 @@ function entryMatches(entry: unknown): boolean { export const adapter: ConnectAdapter = { name: "claude-code", displayName: "Claude Code", + category: "native", docs: "https://github.com/rohitg00/agentmemory#claude-code-one-block-paste-it", protocolNote: "→ Using MCP. Hooks are also available — see docs/claude-code.md.", diff --git a/src/cli/connect/codex.ts b/src/cli/connect/codex.ts index c85808da68..3dbc1882f9 100644 --- a/src/cli/connect/codex.ts +++ b/src/cli/connect/codex.ts @@ -63,6 +63,7 @@ function stripExistingBlock(toml: string): string { export const adapter: ConnectAdapter = { name: "codex", displayName: "Codex CLI", + category: "native", docs: "https://github.com/rohitg00/agentmemory#codex-cli-codex-plugin-platform", 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.", diff --git a/src/cli/connect/continue.ts b/src/cli/connect/continue.ts index 4a2cb820ba..c09107c09e 100644 --- a/src/cli/connect/continue.ts +++ b/src/cli/connect/continue.ts @@ -73,6 +73,7 @@ function renderFreshYaml(): string { export const adapter: ConnectAdapter = { name: "continue", displayName: "Continue", + category: "mcp", docs: "https://github.com/rohitg00/agentmemory#other-agents", protocolNote: "→ Using MCP via ~/.continue/config.yaml (preferred) or config.json (legacy, only when no yaml).", diff --git a/src/cli/connect/copilot-cli.ts b/src/cli/connect/copilot-cli.ts index 8cce5a5422..1f7b43dd87 100644 --- a/src/cli/connect/copilot-cli.ts +++ b/src/cli/connect/copilot-cli.ts @@ -30,6 +30,7 @@ function entryMatches(entry: unknown): boolean { export const adapter: ConnectAdapter = { name: "copilot-cli", displayName: "GitHub Copilot CLI", + category: "native", docs: "https://github.com/rohitg00/agentmemory#github-copilot-cli", protocolNote: "→ Using MCP. Install the plugin too for full hooks/skills coverage.", diff --git a/src/cli/connect/hermes.ts b/src/cli/connect/hermes.ts index 578e2a23a6..a9e15b8a93 100644 --- a/src/cli/connect/hermes.ts +++ b/src/cli/connect/hermes.ts @@ -11,6 +11,7 @@ const DOCS = "https://github.com/rohitg00/agentmemory/tree/main/integrations/her export const adapter: ConnectAdapter = { name: "hermes", displayName: "Hermes Agent", + category: "native", docs: DOCS, protocolNote: "→ Using MCP. Hooks are also available — see docs/hermes.md.", diff --git a/src/cli/connect/json-mcp-adapter.ts b/src/cli/connect/json-mcp-adapter.ts index 14ba41b6f7..35998e0dc5 100644 --- a/src/cli/connect/json-mcp-adapter.ts +++ b/src/cli/connect/json-mcp-adapter.ts @@ -19,6 +19,10 @@ export type JsonMcpAdapterConfig = { configPath: string; docs?: string; protocolNote?: string; + // Integration style for onboarding grouping. Defaults to "mcp" since a + // JSON MCP config writer is MCP-only by construction; hosts that also + // ship hooks (e.g. OpenClaw) pass "native". + category?: "native" | "mcp"; // Wrapper key under which servers live. Default "mcpServers". // Zed uses "context_servers"; otherwise same shape. wrapperKey?: string; @@ -45,6 +49,7 @@ export function createJsonMcpAdapter( return { name: config.name, displayName: config.displayName, + category: config.category ?? "mcp", ...(config.docs !== undefined && { docs: config.docs }), ...(config.protocolNote !== undefined && { protocolNote: config.protocolNote, diff --git a/src/cli/connect/openclaw.ts b/src/cli/connect/openclaw.ts index e417e267ab..66b69b0ac4 100644 --- a/src/cli/connect/openclaw.ts +++ b/src/cli/connect/openclaw.ts @@ -5,6 +5,7 @@ import { createJsonMcpAdapter } from "./json-mcp-adapter.js"; export const adapter = createJsonMcpAdapter({ name: "openclaw", displayName: "OpenClaw", + category: "native", detectDir: join(homedir(), ".openclaw"), configPath: join(homedir(), ".openclaw", "openclaw.json"), docs: "https://github.com/rohitg00/agentmemory/tree/main/integrations/openclaw", diff --git a/src/cli/connect/opencode.ts b/src/cli/connect/opencode.ts index 6306572020..76ddbf63d1 100644 --- a/src/cli/connect/opencode.ts +++ b/src/cli/connect/opencode.ts @@ -44,6 +44,7 @@ function entryMatches(entry: unknown): boolean { export const adapter: ConnectAdapter = { name: "opencode", displayName: "OpenCode", + category: "mcp", docs: "https://github.com/rohitg00/agentmemory#other-agents", protocolNote: "Using MCP via ~/.config/opencode/opencode.json (top-level `mcp` key). For full auto-capture, also install the bundled plugin in plugin/opencode/.", diff --git a/src/cli/connect/openhuman.ts b/src/cli/connect/openhuman.ts index 108b811715..8b9136f9de 100644 --- a/src/cli/connect/openhuman.ts +++ b/src/cli/connect/openhuman.ts @@ -10,6 +10,7 @@ const DOCS = "https://github.com/tinyhumansai/openhuman"; export const adapter: ConnectAdapter = { name: "openhuman", displayName: "OpenHuman", + category: "native", docs: DOCS, protocolNote: "→ Using native hooks (REST API at :3111). MCP not required.", diff --git a/src/cli/connect/pi.ts b/src/cli/connect/pi.ts index 669d81279f..3056d31d48 100644 --- a/src/cli/connect/pi.ts +++ b/src/cli/connect/pi.ts @@ -11,6 +11,7 @@ const DOCS = "https://github.com/rohitg00/agentmemory/tree/main/integrations/pi" export const adapter: ConnectAdapter = { name: "pi", displayName: "pi", + category: "native", docs: DOCS, protocolNote: "→ Using native hooks (REST API at :3111). MCP not required.", diff --git a/src/cli/connect/types.ts b/src/cli/connect/types.ts index 8abd2745e5..169dde1382 100644 --- a/src/cli/connect/types.ts +++ b/src/cli/connect/types.ts @@ -21,6 +21,13 @@ export type ConnectAdapter = { * opt-in bridge for MCP-only clients. */ protocolNote?: string; + /** + * Integration style, used by onboarding to group agents. "native" = + * ships a first-party plugin / lifecycle hooks; "mcp" = wires the MCP + * server only. Declared on the adapter so the picker never needs a + * separate hardcoded list (#872). Defaults to "mcp" when omitted. + */ + category?: "native" | "mcp"; detect(): boolean; install(opts: ConnectOptions): Promise; }; diff --git a/src/cli/onboarding.ts b/src/cli/onboarding.ts index 5d9ed7adf5..6d04935549 100644 --- a/src/cli/onboarding.ts +++ b/src/cli/onboarding.ts @@ -48,19 +48,6 @@ const AGENT_GLYPH: Record = { opencode: "⬡", }; -// Agents wired through a native plugin / lifecycle hooks rather than the -// MCP server. Cosmetic grouping only; everything still goes through an -// adapter. -const NATIVE_AGENTS = new Set([ - "claude-code", - "copilot-cli", - "codex", - "openhuman", - "openclaw", - "hermes", - "pi", -]); - const PROVIDERS: { value: string; label: string; envKey: string | null }[] = [ { value: "anthropic", label: "Anthropic — claude", envKey: "ANTHROPIC_API_KEY" }, { value: "openai", label: "OpenAI — gpt", envKey: "OPENAI_API_KEY" }, @@ -82,7 +69,7 @@ export function buildAgentOptions(): { value: string; label: string; hint?: stri const options = ADAPTERS.map((a) => ({ value: a.name, label: `${AGENT_GLYPH[a.name] ?? "◇"} ${a.displayName}`, - hint: NATIVE_AGENTS.has(a.name) ? "native plugin" : "MCP server", + hint: a.category === "native" ? "native plugin" : "MCP server", })); return [ ...options.filter((o) => o.hint === "native plugin"), diff --git a/test/cli-connect.test.ts b/test/cli-connect.test.ts index 39822ec099..46a1f240b6 100644 --- a/test/cli-connect.test.ts +++ b/test/cli-connect.test.ts @@ -74,6 +74,15 @@ describe("agentmemory connect — dispatcher", () => { expect(typeof a.displayName).toBe("string"); } }); + + it("every adapter declares a category so onboarding never needs a separate list (#872)", () => { + for (const a of ADAPTERS) { + expect( + ["native", "mcp"].includes(a.category as string), + `adapter ${a.name} must set category to "native" or "mcp"`, + ).toBe(true); + } + }); }); describe("agentmemory connect — claude-code adapter (mock filesystem)", () => {