Skip to content

Conversation

@codegirl-007
Copy link
Contributor

@codegirl-007 codegirl-007 commented Jan 26, 2026

Add ACP (Agent Client Protocol) support for OpenCode. This works for all functions (fill in, over-range, refactor, etc). This implementation is faster (especially when trying to refactor with 99 across multiple files) than using the CLI to get responses because we're able to persist the session (which I don't do yet) and parallelize the requests to OpenCode (which is implemented).

Tested in Neovim but some of tests fail despite the feature working. I never updated them really so probably need to fix them. and the tests pass.

If you also want to trade higher complexity for better performance 😉, configure 99 with:

{
  "ThePrimeagen/99",
  config = function()
    local _99 = require("99")
    _99.setup({
      -- Use the ACP provider instead of the default CLI provider
      provider = _99.ACPProvider,
      -- Optional: specify model (defaults to anthropic/claude-sonnet-4-5)
      model = "anthropic/claude-sonnet-4-5",
      -- Standard config...
      logger = {
        level = _99.DEBUG,
        path = "/tmp/99.debug",
      },
      md_files = { "AGENT.md" },
    })
    vim.keymap.set("n", "<leader>9f", function()
      _99.fill_in_function()
    end)
    vim.keymap.set("v", "<leader>9v", function()
      _99.visual()
    end)
    vim.keymap.set("n", "<leader>9r", function()
      _99.refactor()
    end)
  end,
}

Demo videos:
ACP:

acpprovider.mp4

Open Code
https://github.com/user-attachments/assets/3a294e1d-79bd-4904-8dd6-d45471457509

Claude Code

Screen.Recording.2026-01-26.at.6.44.25.PM.mov

Cursor

Screen.Recording.2026-01-26.at.6.53.53.PM.mov

@codegirl-007
Copy link
Contributor Author

It occurs to me now that maybe those failing tests are from parallelizing requests in the refactor command and the other providers don’t have ACP available. I didn’t read which tests failed but this is an issue regardless.

I probably screwed the pooch and need to fallback to cli prompting sequentially when ACP is not available (unless you can parallelize CLI commands but I imagine the other providers have locking mechanisms where you can’t do that).

Just a note for my future self.

@ThePrimeagen
Copy link
Owner

ill look at this at some point :)

I dont know what this is so ill have to read up on it before proceeding!

@codegirl-007
Copy link
Contributor Author

ill look at this at some point :)

I dont know what this is so ill have to read up on it before proceeding!

There’s still stuff I need to fix so no rush.

@ThePrimeagen
Copy link
Owner

Let me look at this in the morning :)

After I get skills in. I think it's good to go... But I want to make sure it's good

@codegirl-007
Copy link
Contributor Author

Let me look at this in the morning :)

After I get skills in. I think it's good to go... But I want to make sure it's good

No rush. Just easier to review in PR.

@XandeCommits
Copy link

Hey this looks really cool, I want to use it!

Is this gonna be merged soon??

@codegirl-007
Copy link
Contributor Author

Hey this looks really cool, I want to use it!

Technically it works but I think it can be better organized to make it more self explanatory. Right now when I read the code, it reads like I'm building the entire internet instead of just using the ACP protocol. Unfortunately, I couldn't find an Agent Client Protocol library for lua so I had to reinvent some wheels. Would have been a nice abstraction to have though.

Is this gonna be merged soon??

Don't know but thanks for coming to my tech talk.

@ThePrimeagen
Copy link
Owner

I will likely merge tonight, but first I have to merge skills-v2

Implement adding quickfix list and multifile refactoring.

bug fix

fixes to acp implementation

refactoring across files with acp works

parallel requests

clean up
@codegirl-007
Copy link
Contributor Author

The minimal config you'd need to try the acp stuff is:

_99.setup({
  -- this by default uses `opencode acp` command instead of `opencode run`
  provider = _99.ACPProvider, 
  add_to_quickfix = true,  -- This enables quickfix tracking for any changes (not just refactor)
})

To refactor across multiple files, I mapped it with this. Interested to see the limitations on this. This finds references via LSP so I'm sure we'll find some limitations.

vim.keymap.set('n', '<leader>9r', function()
    _99.refactor_prompt()
end)

The ACP code is gnarly looking (to me) but it's ready to go (as in working functionally) as is.

@codegirl-007
Copy link
Contributor Author

Okay, I'm done. I'll stop now. I have beaten the dead horse because of borderline pedantics.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants