Skip to content

Configuring ACP Adapters

This section contains configuration which is specific to Agent Client Protocol (ACP) adapters only. There is a lot of shared functionality between ACP and http adapters. Therefore it's recommended you read the two pages together.

Setup: Auggie CLI from Augment Code

To use Auggie CLI within CodeCompanion, you simply need to follow their Getting Started guide.

Setup: Cagent

To use Docker's Cagent within CodeCompanion, you need to follow these steps:

  1. Install Cagent as per their instructions
  2. Create an agent in the repository you're working from
  3. Test the agent by running cagent run your_agent.yaml in the CLI
  4. In your CodeCompanion config, extend the cagent adapter to include the agent:
lua
require("codecompanion").setup({
  adapters = {
    acp = {
      cagent = function()
        return require("codecompanion.adapters").extend("cagent", {
          commands = {
            default = {
              "cagent",
              "acp",
              "your_agent.yaml",
            },
          },
        })
      end,
    },
  },
})

If you have multiple agent files that you like to run separately, you can create multiple commands for each agent.

Setup: Claude Code

To use Claude Code within CodeCompanion, you'll need to take the following steps:

  1. Install Claude Code
  2. Install the Zed ACP adapter for Claude Code

Using Claude Pro Subscription

  1. In your CLI, run claude setup-token. You'll be redirected to the Claude.ai website for authorization:
  2. Back in your CLI, copy the OAuth token (in yellow):
  3. In your CodeCompanion config, extend the claude_code adapter and include the OAuth token (see the section on environment variables and setting API keys for other ways to do this):
lua
require("codecompanion").setup({
  adapters = {
    acp = {
      claude_code = function()
        return require("codecompanion.adapters").extend("claude_code", {
          env = {
            CLAUDE_CODE_OAUTH_TOKEN = "my-oauth-token",
          },
        })
      end,
    },
  },
})

Using an API Key

  1. Create an API key in your Anthropic console.
  2. In your CodeCompanion config, extend the claude_code adapter and set the ANTHROPIC_API_KEY:
lua
require("codecompanion").setup({
  adapters = {
    acp = {
      claude_code = function()
        return require("codecompanion.adapters").extend("claude_code", {
          env = {
            ANTHROPIC_API_KEY = "my-api-key",
          },
        })
      end,
    },
  },
})

Setup: Codex

To use OpenAI's Codex, install an ACP-compatible adapter like this one from Zed.

By default, the adapter will look for an OPENAI_API_KEY in your shell, however you can also authenticate via ChatGPT. This can be customized in the plugin configuration:

lua
require("codecompanion").setup({
  adapters = {
    acp = {
      codex = function()
        return require("codecompanion.adapters").extend("codex", {
          defaults = {
            auth_method = "openai-api-key", -- "openai-api-key"|"codex-api-key"|"chatgpt"
          },
          env = {
            OPENAI_API_KEY = "my-api-key",
          },
        })
      end,
    },
  },
})

Setup: Gemini CLI

  1. Install Gemini CLI
  2. Update your CodeCompanion config and select which authentication methods you'd like to use. Currently there are:
    • oauth-personal which uses your Google login
    • gemini-api-key
    • vertex-ai)

The example below uses the gemini-api-key method, pulling the API key from 1Password CLI:

lua
require("codecompanion").setup({
  adapters = {
    acp = {
      gemini_cli = function()
        return require("codecompanion.adapters").extend("gemini_cli", {
          defaults = {
            auth_method = "gemini-api-key", -- "oauth-personal"|"gemini-api-key"|"vertex-ai"
          },
          env = {
            GEMINI_API_KEY = "cmd:op read op://personal/Gemini_API/credential --no-newline",
          },
        })
      end,
    },
  },
})

Setup: Goose CLI

To use Goose in CodeCompanion, ensure you've followed their documentation to setup and install Goose CLI. Then ensure that in your chat buffer you select the goose adapter.

Setup: Kimi CLI

Install Kimi CLI as per their instructions. Then in the CLI, run kimi followed by /setup to configure your API key. Then ensure that in your chat buffer you select the kimi_cli adapter.

Setup: opencode

To use opencode in CodeCompanion, ensure you've followed their documentation to install and configure it. Then ensure that in your chat buffer you select the opencode adapter.

Released under the MIT License.