feat(extensions): adapt CodeCompanion extension for v19 compatibility#279
feat(extensions): adapt CodeCompanion extension for v19 compatibility#279bahaaza wants to merge 2 commits into
Conversation
Migrate the CodeCompanion extension to support CodeCompanion v19's
breaking API changes while maintaining the same user-facing behavior.
Changes:
- Tool config: callback = { table } → callback = function() return table end
- Tool cmds handler: (agent, args, _, output_handler) → (self, action, opts)
- Tool output handler: (self, agent, cmd, data) → (self, data, meta)
- Variables → Editor Context: config.interactions.chat.variables →
config.interactions.chat.editor_context
- Image handling: helpers.add_image() → Chat:add_image_message()
- Group system_prompt: function(self) → function(group_config, ctx)
Files modified:
- lua/mcphub/extensions/codecompanion/tools.lua
- lua/mcphub/extensions/codecompanion/core.lua
- lua/mcphub/extensions/codecompanion/variables.lua
- lua/mcphub/extensions/codecompanion/slash_commands.lua
|
Works for me, thanks! |
|
Would like to see this merged!!! |
|
Yes, we're really looking forward to seeing it happen. |
|
Can this be merged pretty please @ravitemer? |
|
I can confirm that this seems to work pretty well on my system. |
Co-authored-by: Carlos Galan Cladera <cgcladera@gmail.com>
|
The maintainer isn't active on github for quite a while already... Perhaps its time to consider a fork to keep the project going :/ |
|
Well, you can use my fork for the meanwhile, I'll be using mcphub for a while, codecompanion has built in support for mcps but its not as mature as mcphub. |
|
@bahaaza I don't suppose you have any interest in forking the mcp-hub server as well? Locally I updated the @modelcontextprotocol/sdk dependency to something a bit more current, and oauth support works a ton better. (I'd do it myself, but there's an annoying amount of paperwork involved with my employer, and bumping the dependency is really the only change.) |
Not a bad idea. In the meantime, @powerman on an issue highlighted how you can use the lazy-local-patcher.nvim plugin, if you're using Lazy, to apply a patch while waiting for something to be merged. For me this was as simple as adding the file return {
"polirritmico/lazy-local-patcher.nvim",
config = true,
ft = "lazy", -- for lazy loading
}And then adding a patch file to |
|
Alternatively: # via https://www.jvt.me/posts/2019/01/19/git-ref-github-pull-requests/
# in the directory that you have `mcphub.nvim` checked out
git config remote.origin.fetch '+refs/pull/*:refs/remotes/origin/pull/*'Then: return {
"ravitemer/mcphub.nvim",
branch = "pull/279/merge"
} |
|
when can this PR be merged |
|
Hate to ask this and huge respect to the developer for investing their time in making this excellent plugin. @ravitemer do you need help maintaining this plugin? |
Summary
Migrate the CodeCompanion extension to support CodeCompanion v19's breaking API changes while maintaining the same user-facing behavior.
Motivation
CodeCompanion v19 introduced several breaking changes to its tool, variable, and image APIs. This PR updates all four CodeCompanion extension modules to work with the new API surface.
Changes
Tool Config Structure (
tools.lua)callback = { table }→callback = function() return { table } endTools.resolve()requirescallbackto be a function, not a table.Tool
cmdsHandlers (tools.lua,core.lua)(agent, args, _, output_handler)→(self, action, opts)opts.output_cbinstead of the 4th positional arg.Tool Output Handlers (
core.lua)(self, agent, cmd, data)→(self, data, meta)meta.tools.chatinstead of theagentparameter.Variables → Editor Context (
variables.lua)config.interactions.chat.variables→config.interactions.chat.editor_contextmcp:) instead of the customidfield.idfield from registrations.Image Handling (
variables.lua,slash_commands.lua)require("codecompanion.interactions.chat.helpers").add_image(chat, img)→chat:add_image_message(img)helpersmodule have been eliminated.Group System Prompts (
tools.lua)system_prompt = function(self)→system_prompt = function(group_config, ctx)Files Modified
lua/mcphub/extensions/codecompanion/tools.lualua/mcphub/extensions/codecompanion/core.lualua/mcphub/extensions/codecompanion/variables.lualua/mcphub/extensions/codecompanion/slash_commands.luaTesting
make test)stylua(make format)