acp.mdx 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. ---
  2. title: ACP Support
  3. description: Use OpenCode in any ACP-compatible editor.
  4. ---
  5. OpenCode supports the [Agent Client Protocol](https://agentclientprotocol.com) or (ACP), allowing you to use it directly in compatible editors and IDEs.
  6. :::tip
  7. For a list of editors and tools that support ACP, check out the [ACP progress report](https://zed.dev/blog/acp-progress-report#available-now).
  8. :::
  9. ACP is an open protocol that standardizes communication between code editors and AI coding agents.
  10. ---
  11. ## Configure
  12. To use OpenCode via ACP, configure your editor to run the `opencode acp` command.
  13. The command starts OpenCode as an ACP-compatible subprocess that communicates with your editor over JSON-RPC via stdio.
  14. Below are examples for popular editors that support ACP.
  15. ---
  16. ### Zed
  17. Add to your [Zed](https://zed.dev) configuration (`~/.config/zed/settings.json`):
  18. ```json title="~/.config/zed/settings.json"
  19. {
  20. "agent_servers": {
  21. "OpenCode": {
  22. "command": "opencode",
  23. "args": ["acp"]
  24. }
  25. }
  26. }
  27. ```
  28. To open it, use the `agent: new thread` action in the **Command Palette**.
  29. You can also bind a keyboard shortcut by editing your `keymap.json`:
  30. ```json title="keymap.json"
  31. [
  32. {
  33. "bindings": {
  34. "cmd-alt-o": [
  35. "agent::NewExternalAgentThread",
  36. {
  37. "agent": {
  38. "custom": {
  39. "name": "OpenCode",
  40. "command": {
  41. "command": "opencode",
  42. "args": ["acp"]
  43. }
  44. }
  45. }
  46. }
  47. ]
  48. }
  49. }
  50. ]
  51. ```
  52. ---
  53. ### JetBrains IDEs
  54. Add to your [JetBrains IDE](https://www.jetbrains.com/) acp.json according to the [documentation](https://www.jetbrains.com/help/ai-assistant/acp.html):
  55. ```json title="~/.config/zed/settings.json"
  56. {
  57. "agent_servers": {
  58. "OpenCode": {
  59. "command": "/absolute/path/bin/opencode",
  60. "args": ["acp"]
  61. }
  62. }
  63. }
  64. ```
  65. To open it, use the new 'OpenCode' agent in the AI Chat agent selector.
  66. ---
  67. ### Avante.nvim
  68. Add to your [Avante.nvim](https://github.com/yetone/avante.nvim) configuration:
  69. ```lua
  70. {
  71. acp_providers = {
  72. ["opencode"] = {
  73. command = "opencode",
  74. args = { "acp" }
  75. }
  76. }
  77. }
  78. ```
  79. If you need to pass environment variables:
  80. ```lua {6-8}
  81. {
  82. acp_providers = {
  83. ["opencode"] = {
  84. command = "opencode",
  85. args = { "acp" },
  86. env = {
  87. OPENCODE_API_KEY = os.getenv("OPENCODE_API_KEY")
  88. }
  89. }
  90. }
  91. }
  92. ```
  93. ---
  94. ### CodeCompanion.nvim
  95. To use OpenCode as an ACP agent in [CodeCompanion.nvim](https://github.com/olimorris/codecompanion.nvim), add the following to your Neovim config:
  96. ```lua
  97. require("codecompanion").setup({
  98. strategies = {
  99. chat = {
  100. adapter = {
  101. name = "opencode",
  102. model = "claude-sonnet-4",
  103. },
  104. },
  105. },
  106. })
  107. ```
  108. This config sets up CodeCompanion to use OpenCode as the ACP agent for chat.
  109. If you need to pass environment variables (like `OPENCODE_API_KEY`), refer to [Configuring Adapters: Environment Variables](https://codecompanion.olimorris.dev/configuration/adapters#environment-variables-setting-an-api-key) in the CodeCompanion.nvim documentation for full details.
  110. ## Support
  111. OpenCode works the same via ACP as it does in the terminal. All features are supported:
  112. :::note
  113. Some built-in slash commands like `/undo` and `/redo` are currently unsupported.
  114. :::
  115. - Built-in tools (file operations, terminal commands, etc.)
  116. - Custom tools and slash commands
  117. - MCP servers configured in your OpenCode config
  118. - Project-specific rules from `AGENTS.md`
  119. - Custom formatters and linters
  120. - Agents and permissions system