-
-
Notifications
You must be signed in to change notification settings - Fork 352
refactor tools #965
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
refactor tools #965
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Deploying codecompanion with
|
| Latest commit: |
efbcdd1
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://58121901.codecompanion.pages.dev |
| Branch Preview URL: | https://refactor-tools.codecompanion.pages.dev |
lazymaniac
reviewed
Feb 23, 2025
cleong14
pushed a commit
to cleong14/codecompanion.nvim
that referenced
this pull request
May 21, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR sets out to streamline the agents and tools implementation in the plugin, with a view to moving to native tool/function calling in the near future. Currently, all the logic sits within a tools/init.lua file. It's difficult to distinguish between function tools and command tools. And every time I have to get my head back into the code, I need to refresh myself on how I've built the solution.
This PR sets out a significant number of improvements.
Test Coverage
There is now significant test coverage for the feature. Thanks to mini.test's child processes capability, it's now possible to run tool tests from within a separate Neovim process. This saves me from having to mock Plenary.job and to test the feature in the way users do in the real world.
Queuing system (FIFO)
There were edge cases with the previous implementation whereby if a user ran a function tool, then a command tool, then another function tool, the two function tools would complete before the command tool. For some cases, this might not have been an issue, but in the example that I give in the README, i.e. asking the LLM to create Snake, this is a definite flaw. In fact, it turns out the only reason that video worked at all was because the human authorization delayed the function tools enough for the command tool to complete. But in this update, all of that goes away and the plugin will only execute the next tool if the previous one has completed.
Refactor
There's also been a significant refactor in the plugin as well. Instead of everything being in a tool/init file, it is now structured as follows:
My hope is that it's much less daunting for users to make contributions to this particular feature in the plugin, and that it also provides a scalable base for the next phase of enhancements.