Skip to content

Commit 754979b

Browse files
authored
feat(acp): add acp session events (#2938)
1 parent 8f4a3d3 commit 754979b

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

doc/usage/events.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ In order to enable a tighter integration between CodeCompanion and your Neovim c
1010

1111
The events that are fired from within the plugin are:
1212

13+
- `CodeCompanionACPSessionPre` - Fired after ACP authentication completes but before a new session is established; allows subscribers to modify the connection (e.g. inject MCP servers) synchronously
1314
- `CodeCompanionChatACPModeChanged` - Fired after the ACP mode has been changed in the chat
1415
- `CodeCompanionChatCreated` - Fired after a chat has been created for the first time
1516
- `CodeCompanionChatOpened` - Fired after a chat has been opened

lua/codecompanion/acp/init.lua

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ local adapter_utils = require("codecompanion.utils.adapters")
2424
local config = require("codecompanion.config")
2525
local jsonrpc = require("codecompanion.utils.jsonrpc")
2626
local log = require("codecompanion.utils.log")
27+
local utils = require("codecompanion.utils")
2728

2829
local TIMEOUTS = {
2930
DEFAULT = 2e4, -- 20 seconds
@@ -168,6 +169,11 @@ function Connection:connect_and_initialize()
168169
return nil
169170
end
170171

172+
utils.fire("ACPSessionPre", {
173+
adapter_modified = self.adapter_modified,
174+
agent_capabilities = self._agent_info and self._agent_info.agentCapabilities,
175+
})
176+
171177
if not self:_establish_session() then
172178
return nil
173179
end
@@ -237,6 +243,11 @@ function Connection:ensure_session()
237243
return false
238244
end
239245

246+
utils.fire("ACPSessionPre", {
247+
adapter_modified = self.adapter_modified,
248+
agent_capabilities = self._agent_info and self._agent_info.agentCapabilities,
249+
})
250+
240251
if not self:_establish_session() then
241252
return false
242253
end

0 commit comments

Comments
 (0)