opencode-devin-plugin
v0.3.6
Published
OpenCode plugin to drive cloud Devin sessions and use Cognition LLM models (SWE-1.7, Claude, GPT-5.6, etc.) from the OpenCode agent.
Maintainers
Readme
devin-opencode
An OpenCode plugin that brings Devin / Cognition LLM models into OpenCode's /models picker and lets the OpenCode agent drive cloud Devin sessions.
What it does
- LLM provider — Adds 180+ Cognition models (SWE-1.7, Claude Opus 4.8, GPT-5.6, GLM-5.2, Gemini, Grok, etc.) to OpenCode's
/modelspicker, streamed directly from Cognition's gRPC server. - Devin session tools — Adds 6 tools the OpenCode agent can call to manage cloud Devin sessions.
| Tool | Purpose |
| --- | --- |
| devin_status | Check if Devin is connected and report auth sources |
| devin_create_session | Hand off a task to a cloud Devin session |
| devin_list_sessions | List recent sessions with status |
| devin_get_session | Fetch session details and message history |
| devin_send_message | Send a follow-up message to a session |
| devin_terminate_session | Stop a running session |
Quick start
1. Install the plugin
opencode plugin opencode-devin-plugin --globalThat's it for installation. The plugin auto-registers the devin provider in your config — no manual provider block needed.
2. Get a Windsurf OAuth token (for LLM models)
The LLM models are accessed via Cognition's Windsurf/Codeium gRPC server, which requires a Windsurf OAuth token. Get one with:
npx opencode-windsurf-auth loginThis opens a browser sign-in page. After you log in, the token is saved to ~/.config/opencode-windsurf-auth/credentials.json and the plugin picks it up automatically.
Alternative: If you already have a token (starts with
devin-session-token$...), set it as an env var instead:export DEVIN_LLM_API_KEY=devin-session-token$your_token_here
3. (Optional) Get a Devin API key (for session tools)
The session management tools use a separate Devin API key:
- Go to Settings > Service users in the Devin app and create a service user with
UseDevinSessionsandViewOrgSessionspermissions - Generate an API key — it starts with
cog_ - Set it as an env var:
export DEVIN_API_KEY=cog_your_key_here
You can also run
/connectin the OpenCode TUI and choose Devin to store the key as a credential instead of using an env var.
DEVIN_ORG_IDis optional — if not set, the plugin auto-discovers it from the Devin CLI config or the/v3/organizationsAPI.
4. Use it
Chat with Cognition models:
Start OpenCode, open /models, and pick any devin/ model (e.g. devin/swe-1-7). Or set it as your default:
// opencode.json
{
"model": "devin/swe-1-7"
}Hand off tasks to cloud Devin:
Ask the OpenCode agent:
Use devin_create_session to create a Devin session that refactors my auth module
Environment variables
| Variable | Required | Description |
| --- | --- | --- |
| DEVIN_LLM_API_KEY | No* | Windsurf OAuth token for LLM models (devin-session-token$...). Auto-detected from opencode-windsurf-auth credentials if not set. |
| DEVIN_API_KEY | No** | Devin API key for session tools (cog_..., apk_..., or apk_user_...). Also settable via /connect. |
| DEVIN_ORG_ID | No | Devin organization ID (org-...). Auto-discovered if not set. |
* Required for LLM models. Either set this env var or run npx opencode-windsurf-auth login.
* Required for session tools. Either set this env var or run /connect in the TUI.
How auth works
The plugin uses two separate credentials:
| Credential | Used for | How to get it |
| --- | --- | --- |
| Windsurf OAuth token (devin-session-token$...) | LLM model streaming (chat) | npx opencode-windsurf-auth login or DEVIN_LLM_API_KEY |
| Devin API key (cog_...) | Session management tools | /connect in TUI or DEVIN_API_KEY |
You can use just the LLM models without the session tools, or vice versa. Run devin_status to check which are connected.
Install from source
git clone https://github.com/karthiknish/devin-opencode.git
cd devin-opencode
npm installThen reference it in your config:
// opencode.json
{
"plugin": ["./devin-opencode/src/index.ts"]
}API versioning
The session tools use the Devin v3 API (/v3/organizations/{org_id}/sessions) for cog_ service user keys. For legacy apk_/apk_user_ keys, it automatically falls back to the deprecated v1 API.
| Key type | API version | Status |
| --- | --- | --- |
| cog_ (service user) | v3 | Current, recommended |
| apk_user_ (personal) | v1 (fallback) | Deprecated |
| apk_ (service) | v1 (fallback) | Deprecated |
Project layout
src/
index.ts # Plugin entrypoint (auth + LLM provider + tools)
devin.ts # Devin REST API client (v3 + v1 fallback)
packages/
ai-sdk-devin/ # AI SDK provider for Cognition gRPC (LanguageModelV3)
src/
index.ts # Provider factory + prompt/stream conversion
chat.ts # GetChatMessage streaming via Connect-RPC
catalog.ts # GetCascadeModelConfigs (model catalog)
auth.ts # GetUserJwt (short-lived JWT minting)
metadata.ts # gRPC metadata builder
wire.ts # Protobuf encoding helpers
examples/
opencode.v1.json # Example configReleasing
Every push to main automatically bumps the patch version and publishes to npm via OIDC trusted publishing. No tokens, no manual steps.
git pushThe workflow typechecks, bumps the version, commits it back, and publishes with --provenance.
Watch runs at https://github.com/karthiknish/devin-opencode/actions.
License
MIT
