opencode icon indicating copy to clipboard operation
opencode copied to clipboard

feat: Adds support for Cursor provider and other ACP backends

Open aweis89 opened this issue 1 month ago • 20 comments

Summary

  • While ACP is already supported for custom IDE integrations (IDE/ACP-> OpenCode -> LLM), this adds support to use ACP as a backend LLM provider (OpenCode -> ACP)
  • Enables OpenCode to consume tokens from Cursor CLI for example while still using the regular OpenCode TUI.
  • This is useful for folks who have Cursor subscriptions for example, but want to use OpenCode's (amazing!) TUI
  • By enabling ACP as a backend provider, we don't need a uniq translation layer for OpenCode to multiple CLI backends

Resolves

  • Closes #3735 - CLI Providers feature request
  • Closes #2072 - Support for Cursor CLI
  • Closes #402 - Gemini CLI support for free tier access
  • Closes #5182

Implementation Details

Core Components

  1. ACPClient (client.ts) - Manages subprocess lifecycle and ACP protocol communication
  2. ACPLanguageModel (model.ts) - Implements LanguageModelV2 interface with streaming support
  3. Message Converters (converters.ts) - Bidirectional conversion between Vercel AI SDK and ACP message formats
  4. MCP Converter (mcp-converter.ts) - Converts OpenCode MCP configurations to ACP format
  5. Provider Factory (factory.ts) - Creates ACP provider instances from configuration

Key Features

  • Full streaming support for real-time responses
  • Tool execution, passes along MCP servers, which are executed by the ACP
  • MCP server integration - OpenCode MCP servers exposed to ACP backends
  • Proper subprocess lifecycle management and cleanup
  • Comprehensive error handling

Testing

  • Tested with cursor-agent integration
  • Verified streaming responses
  • Confirmed MCP server exposure to ACP backend

Documentation

  • Added comprehensive README.md with setup instructions
  • Includes configuration examples for cursor-agent, goose, and gemini-cli
  • Documents architecture and design decisions

aweis89 avatar Dec 05 '25 03:12 aweis89

we already have acp support, whats this for

rekram1-node avatar Dec 05 '25 03:12 rekram1-node

we already have acp support, whats this for

This is for an ACP backend provider. For example, if you have a cursor account, and you want to use Opencode TUI's interface, but you want it to use cursor CLI agent as it's backend LLM:

Screenshot 2025-12-04 at 7 37 02 PM

Right now we have: IDE via ACP -> OpenCode -> LLM Provider With this change you can now do: OpenCode -> Cursor CLI via ACP The ACP becomes the LLM provider as apposed to the frontend interface. This is useful for folks who want to use OpenCode but already have a subscription for cursor. They can now use OpenCode while comsuming their tokens from Cursor

aweis89 avatar Dec 05 '25 03:12 aweis89

okay i see

rekram1-node avatar Dec 05 '25 03:12 rekram1-node

okay i see

Been using this all morning. It's pretty awesome to be able to use my Cursor subscription with OpenCode's best-in-class TUI!

aweis89 avatar Dec 05 '25 21:12 aweis89

Screenshot 2025-12-20 at 8 29 02 PM

aweis89 avatar Dec 21 '25 04:12 aweis89

Any chance this is something we can merge @rekram1-node?

aweis89 avatar Dec 21 '25 04:12 aweis89