Your Agent in Zed over ACP

medium10 minacp-agent.ts

Your team uses Zed, JetBrains or Neovim. Your Cogitator agent should show up there as a coding agent, with its diffs, terminals and permission questions in the editor.

What it shows

  • A SessionHost keeps the sessions as threads, createAcpAgent() speaks the Agent Client Protocol over it
  • Edits and commands ask in the editor, an "always" answer saves a permission rule
  • Files and terminals go through the editor when it offers them

The code

acp-agent.ts
import { Agent, Cogitator, workspaceTools } from '@cogitator-ai/core';
import { SessionHost } from '@cogitator-ai/app-server';
import { createAcpAgent, serveAcpStdio } from '@cogitator-ai/acp';

const apiKey = process.env.GOOGLE_API_KEY;
if (!apiKey) throw new Error('Set GOOGLE_API_KEY');

const cogitator = new Cogitator({
  llm: { providers: { google: { apiKey } } },
  memory: { adapter: 'sqlite', sqlite: { path: './sessions.db' } },
  permissions: {},
});
const coder = new Agent({
  name: 'coder',
  model: 'google/gemini-3.5-flash-lite',
  instructions: 'You are a careful coding agent. Read before you edit, keep changes small.',
  tools: workspaceTools(),
  todos: true,
});

const host = new SessionHost({ cogitator, agents: { coder } });
const acp = createAcpAgent({
  host,
  cogitator,
  agentInfo: { name: 'my-coder', title: 'My coder', version: '1.0.0' },
});

await serveAcpStdio(acp);
await host.close();
await cogitator.close();

Run it

install · bash
pnpm add @cogitator-ai/acp @cogitator-ai/app-server @cogitator-ai/core better-sqlite3
EnvironmentGOOGLE_API_KEY
run · bash
GOOGLE_API_KEY=your-key npx tsx acp-agent.ts

An editor launches it: in Zed, add it to agent_servers in settings.json with "command": "npx" and "args": ["tsx", "/path/to/acp-agent.ts"]. Run by hand it waits for an editor on stdin.

Zed settings.json, with the CLI instead of your own file

Zed settings.json, with the CLI instead of your own file · jsonc
{
  "agent_servers": {
    "Cogitator": {
      "command": "npx",
      "args": ["-y", "@cogitator-ai/cli", "acp", "-m", "ollama/qwen3:8b"]
    }
  }
}

Learn more