Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Thank you to the following people:

- :speech_balloon: [Copilot Chat](https://github.com/features/copilot) meets [Zed AI](https://zed.dev/blog/zed-ai), in Neovim
- :electric_plug: Support for LLMs from Anthropic, Copilot, GitHub Models, DeepSeek, Gemini, Mistral AI, Novita, Ollama, OpenAI, Azure OpenAI, HuggingFace and xAI (or [bring your own](https://codecompanion.olimorris.dev/extending/adapters.html))
- :robot: Support for [Agent Client Protocol](https://agentclientprotocol.com), enabling coding with agents like [Claude Code](https://docs.anthropic.com/en/docs/claude-code/overview) and [Gemini CLI](https://github.com/google-gemini/gemini-cli)
- :robot: Support for [Agent Client Protocol](https://agentclientprotocol.com), enabling coding with agents like [Claude Code](https://docs.anthropic.com/en/docs/claude-code/overview), [Gemini CLI](https://github.com/google-gemini/gemini-cli) and [Goose](https://github.com/block/goose)
- :heart_hands: User contributed and supported [adapters](https://codecompanion.olimorris.dev/configuration/adapters#community-adapters)
- :rocket: [Inline transformations](https://codecompanion.olimorris.dev/usage/inline-assistant.html), code creation and refactoring
- :art: [Variables](https://codecompanion.olimorris.dev/usage/chat-buffer/variables.html), [Slash Commands](https://codecompanion.olimorris.dev/usage/chat-buffer/slash-commands.html), [Tools](https://codecompanion.olimorris.dev/usage/chat-buffer/tools.html) and [Workflows](https://codecompanion.olimorris.dev/usage/workflows.html) to improve LLM output
Expand Down
34 changes: 33 additions & 1 deletion doc/codecompanion.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*codecompanion.txt* For NVIM v0.11 Last change: 2025 September 04
*codecompanion.txt* For NVIM v0.11 Last change: 2025 September 13

==============================================================================
Table of Contents *codecompanion-table-of-contents*
Expand Down Expand Up @@ -1048,6 +1048,38 @@ AN API KEY
<


SETUP: GOOSE VIA ACP ~

Goose <https://github.com/block/goose> is an open-source developer agent that
can be used with CodeCompanion via the Agent Client Protocol (ACP).

To use Goose within CodeCompanion:

1. Install <https://github.com/block/goose#installation> Goose
2. Configure the adapter in your CodeCompanion config:

>lua
require("codecompanion").setup({
adapters = {
acp = {
goose = function()
return require("codecompanion.adapters").extend("goose", {
defaults = {
timeout = 20000, -- 20 seconds
},
})
end,
},
},
})
<

1. Select "goose" as your adapter when using CodeCompanion

The Goose adapter supports vision capabilities and file system operations
(read/write) through ACP.


SETUP: USING OLLAMA REMOTELY ~

To use Ollama remotely, change the URL in the env table, set an API key and
Expand Down
29 changes: 29 additions & 0 deletions doc/configuration/adapters.md
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,35 @@ require("codecompanion").setup({
})
```

## Setup: Goose via ACP

[Goose](https://github.com/block/goose) is an open-source developer agent that can be used with CodeCompanion via the Agent Client Protocol (ACP).

To use Goose within CodeCompanion:

1. [Install](https://github.com/block/goose#installation) Goose
2. Configure the adapter in your CodeCompanion config:

```lua
require("codecompanion").setup({
adapters = {
acp = {
goose = function()
return require("codecompanion.adapters").extend("goose", {
defaults = {
timeout = 20000, -- 20 seconds
},
})
end,
},
},
})
```

3. Select "goose" as your adapter when using CodeCompanion

The Goose adapter supports vision capabilities and file system operations (read/write) through ACP.

## Setup: Using Ollama Remotely

To use Ollama remotely, change the URL in the env table, set an API key and pass it via an "Authorization" header:
Expand Down
56 changes: 56 additions & 0 deletions lua/codecompanion/adapters/acp/goose.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
local helpers = require("codecompanion.adapters.acp.helpers")

---@class CodeCompanion.ACPAdapter.Goose: CodeCompanion.ACPAdapter
return {
name = "goose",
formatted_name = "Goose",
type = "acp",
roles = {
llm = "assistant",
user = "user",
},
opts = {
vision = true,
},
commands = {
default = {
"goose",
"acp",
},
},
defaults = {
timeout = 20000, -- 20 seconds
},
env = {},
parameters = {
protocolVersion = 1,
clientCapabilities = {
fs = { readTextFile = true, writeTextFile = true },
},
clientInfo = {
name = "CodeCompanion.nvim",
version = "1.0.0",
},
},
handlers = {
---@param self CodeCompanion.ACPAdapter
---@return boolean
setup = function(self)
return true
end,

---@param self CodeCompanion.ACPAdapter
---@param messages table
---@param capabilities table
---@return table
form_messages = function(self, messages, capabilities)
return helpers.form_messages(self, messages, capabilities)
end,

---Function to run when the request has completed. Useful to catch errors
---@param self CodeCompanion.ACPAdapter
---@param code number
---@return nil
on_exit = function(self, code) end,
},
}
1 change: 1 addition & 0 deletions lua/codecompanion/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ local defaults = {
acp = {
claude_code = "claude_code",
gemini_cli = "gemini_cli",
goose = "goose",
opts = {
show_defaults = true, -- Show default adapters
},
Expand Down
110 changes: 110 additions & 0 deletions tests/adapters/acp/test_goose.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
local h = require("tests.helpers")

local new_set = MiniTest.new_set
local child = MiniTest.new_child_neovim()

T = new_set({
hooks = {
pre_case = function()
h.child_start(child)
child.lua([[
h = require("tests.helpers")
h.setup_plugin()
package.loaded["codecompanion.config"] = require("tests.config")
]])
end,
post_case = child.stop,
},
})

T["Goose ACP Adapter"] = new_set()

T["Goose ACP Adapter"]["can resolve goose adapter"] = function()
local result = child.lua([[
local adapter = require("codecompanion.adapters").resolve("goose")
return {
name = adapter.name,
formatted_name = adapter.formatted_name,
type = adapter.type,
resolved = require("codecompanion.adapters").resolved(adapter)
}
]])

h.eq({
name = "goose",
formatted_name = "Goose",
type = "acp",
resolved = true,
}, result)
end

T["Goose ACP Adapter"]["has correct default configuration"] = function()
local result = child.lua([[
local adapter = require("codecompanion.adapters").resolve("goose")
return {
roles = adapter.roles,
opts = adapter.opts,
commands = adapter.commands,
defaults = adapter.defaults,
}
]])

h.eq({
roles = { llm = "assistant", user = "user" },
opts = { vision = true },
commands = { default = { "goose", "acp" }, selected = { "goose", "acp" } },
defaults = { timeout = 20000 },
}, result)
end

T["Goose ACP Adapter"]["has correct parameters"] = function()
local result = child.lua([[
local adapter = require("codecompanion.adapters").resolve("goose")
return adapter.parameters
]])

h.eq({
protocolVersion = 1,
clientCapabilities = {
fs = { readTextFile = true, writeTextFile = true },
},
clientInfo = {
name = "CodeCompanion.nvim",
version = "1.0.0",
},
}, result)
end

T["Goose ACP Adapter"]["handlers setup returns true"] = function()
local result = child.lua([[
local adapter = require("codecompanion.adapters").resolve("goose")
return adapter.handlers.setup(adapter)
]])

h.eq(true, result)
end

T["Goose ACP Adapter"]["form_messages handler works correctly"] = function()
local result = child.lua([[
local adapter = require("codecompanion.adapters").resolve("goose")
local messages = {
{ role = "user", content = "Hello", _meta = { sent = false } },
{ role = "assistant", content = "Hi there!", _meta = { sent = true } }
}
local capabilities = { promptCapabilities = {} }
local formed = adapter.handlers.form_messages(adapter, messages, capabilities)

-- Basic check that messages are returned (only unsent user messages should be returned)
return {
count = #formed,
first_type = formed[1] and formed[1].type or "text"
}
]])

h.eq({
count = 1,
first_type = "text",
}, result)
end

return T
3 changes: 3 additions & 0 deletions tests/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ return {
command = { "node", "test-agent.js" },
roles = { user = "user", assistant = "assistant" },
},
goose = function()
return require("codecompanion.adapters.acp.goose")
end,
},
},
strategies = {
Expand Down