Skip to content

About

OpenCode v2 plugin: connect your Devin subscription to opencode with native /connect login and devin/* models

Topics

Resources

Security policy

Stars

7 stars

Watchers

0 watching

Forks

Repository files navigation

opencode-devin

Devin (Cognition) provider for opencode — clean-room.

No third-party Devin libraries: protobuf wire encoding, Connect-RPC framing, the PKCE OAuth flow and the Cascade streaming client are all implemented here.

Status: dev / pre-release. Provider devin, plugin opencode-devin. This replaces the previous opencode-devin@0.x package entirely; nothing from it carries over. Major version bump to 2.0.0.

Layout

src/index.ts       # package entry (npm: "main") — re-exports the plugin
src/plugin.ts      # the plugin: aisdk hooks, /connect methods, catalog → models
src/provider/      # loaded through the aisdk: specifier (own entry point)
  index.ts        # CascadeLanguageModel (aisdk spec v3) + provider factory
  cascade.ts      # Connect-RPC framing, catalog fetch, chat streaming, usage
  auth.ts         # PKCE login (browser + headless), user_jwt mint, Metadata proto
  proto.ts        # protobuf wire primitives
  paths.ts        # per-user data dir resolution
  log.ts          # structured JSONL logger + in-memory ring buffer
.opencode/plugin/opencode-devin.ts   # dev shim → src/plugin.ts (auto-loaded)
scripts/
  login.ts        # standalone PKCE login → writes the session file
  dump-log.ts     # print the log tail for bug reports

No build step: opencode runs on Bun and loads the TypeScript sources directly (src/index.ts is main, and src/provider/package.json points the aisdk entry at src/provider/index.ts).

Quick start

bun install
bun run login          # browser PKCE login → writes the session file
opencode run -m "devin/swe-2#high" "hello"

Use from a local checkout (no npm)

main is src/index.ts and opencode runs on Bun — load the plugin straight from a local directory with a file:/// URL. No npm install opencode-devin, no publish, no build step. Just bun install once inside the repo.

// ~/.config/opencode/opencode.json  (global)  — or .opencode/opencode.json in a project
{
  "$schema": "https://opencode.ai/config.json",
  "plugins": [
    {
      "package": "file:///C:/Users/Josemi/dev/opencode-devin",   // absolute path to this repo
      "options": { "uncensored": true }                          // optional, see Uncensored mode
    }
  ]
}

Every edit under src/ applies on the next opencode restart. On POSIX use file:///home/you/opencode-devin; on Windows use forward slashes after file:///C:/. Don't keep a second opencode-devin (npm) entry loaded at the same time. opencode also auto-loads *.ts shims from .opencode/plugin/ — this repo ships .opencode/plugin/opencode-devin.ts for in-repo dev, which is equivalent to running from bun install + this repo as cwd.

Check it loaded: bun run log 30 shows plugin.setup, publish.start, provider.catalog in <data dir>/opencode-devin.log.

Inside the TUI, /connect → Devin offers three methods:

method what it does
browser (auto) opens the Devin OAuth page; a loopback callback finishes the login and stores the token — no paste
code (headless) prints the auth URL; you paste back the code shown on the page
env var reads DEVIN_API_KEY (the session token itself)

Models

/models shows one entry per family — swe-2, swe-2-flash, swe-2-1, swe-2-1-lightning, swe-2-lightning (the Ultrafast tiers), claude-opus-4-8, gemini-4-carbon, muse-wonder-1-0, … — each with the effort variants that family ships (minimal/low/medium/high/xhigh/ max, selected as #<effort>). The exact set of families and variants comes from your account's catalog; raw catalog uids like swe-2-flash-medium correspond to devin/swe-2-flash#medium.

Select a variant with #:

opencode run -m "devin/swe-2#medium"        "..."
opencode run -m "devin/swe-2-flash#high"    "..."
opencode run -m "devin/muse-wonder-1-0#max" "..."

A bare family (-m devin/swe-2, or the picker without a variant) resolves to the family default: bare uid if present, else medium, else high, else the first member.

Families without per-token pricing ride the plan quota and get a · Free suffix in the picker. Paid families publish the real $ / 1M input, output and cached-input rates from the catalog, so opencode's cost counter is exact.

Token counts: the Cascade local-agent path reports no token metrics (only display stats like agent_messages/model). The provider therefore falls back to a chars / 4 estimate for input/output so context accounting and auto-compaction keep working; if the API ever sends real metrics they win.

Uncensored mode

Flips the provider into an unrestricted operator mode. Nothing is renamed — same family, same effort, same model uid sent to Devin; the only change is a preamble injected ahead of your system block in the first user turn (Cascade has no system role): no refusals, no disclaimers, no moral commentary, security/reverse-engineering treated as ordinary engineering, complete untruncated output. Your own system prompt still applies after it.

Activation, any of:

mechanism example
per-variant (combined with effort) -m "devin/swe-2#medium-uncensored"
per-call providerOptions providerOptions.devin.uncensored: true
global env var OPENCODE_DEVIN_UNCENSORED=1

Activation is always per-variant/per-call. plugins[].options is not used: current opencode doesn't deliver it to plugins, and the catalog has no listing knob — every family is always published with both stock and -uncensored variants.

Selecting variants

For every effort X the picker offers #X and #X-uncensored, in that order. The suffix is combined with the effort, never replacing it. There is no standalone #uncensored row — pick a level.

opencode run -m "devin/swe-2#medium"            "..."   # stock
opencode run -m "devin/swe-2#medium-uncensored" "..."   # + uncensored

Uncensored calls log chat.request { uncensored: true }. Note this only removes the client refusal layer: a model-side content_filter stop (StopReason 11) or a server-side policy can still block output, which you'll see as finish: content_filter / chat.eos_error in the log.

Data directory

Session and logs live in a fixed per-user directory, never in the project — opencode launches from any repo, and state belongs to your account:

platform path
Windows %APPDATA%\opencode-devin\
macOS/Linux ~/.config/opencode-devin/ (honours XDG_CONFIG_HOME)

Contents:

file what
session the devin-session-token$<jwt> written by login / /connect
opencode-devin.log the JSONL debug log

The dir is namespaced opencode-devin on purpose — nothing called plain devin is touched, so official Devin tooling can't collide with us.

Environment variables

var required used by purpose
DEVIN_API_KEY one auth path plugin + provider Session token (devin-session-token$<jwt>). Beats the session file; a /connect credential still wins.
OPENCODE_DEVIN_DIR no paths.ts Override the whole data directory (session + log).
OPENCODE_DEVIN_LOG no log.ts, dump-log.ts Absolute path for the log file only.
OPENCODE_DEVIN_UNCENSORED no index.ts 1 activates the uncensored preamble on every call.
OPENCODE_DEVIN_SESSION no paths.ts Absolute path for the session file only.

Credential resolution order

  1. providerOptions.devin.sessionToken (per-call override)
  2. /connect stored credential for provider devin
  3. DEVIN_API_KEY env var
  4. session file — OPENCODE_DEVIN_SESSION or <data dir>/session

No legacy paths are read: the dev phase broke compatibility on purpose.

Logging & debugging

One JSON line per event in <data dir>/opencode-devin.log:

{"t":"…","lvl":"info","ev":"chat.finish","d":{"modelUid":"swe-2-high","reason":"stop","textLen":124,"ms":1830}}

Events: plugin.setup, publish.start, provider.catalog, credential.resolve_fail, auth.mint.*, catalog.fetch, model.call, chat.request, chat.tool_call, chat.finish, chat.usage, chat.401_remint, chat.eos_error, *.fail.

Session tokens and JWTs are redacted (first14…last6) before they hit disk; free-form server text is scrubbed for secrets (scrubSecrets), tool-call arguments are not logged, the file is 0600, and it rotates at ~5 MB (one .1 backup) — the log is safe to paste into a bug report.

bun run log           # last 120 lines
bun run log 400       # more

Security

Clean-room; no third-party Devin code; no bundled credentials; state in a private opencode-devin dir (never devin/cognition); https only; server-returned cascade hosts are allow-listed (sanitizeCascadeHost); no eval, no shell-string exec; scrubbed 0600 logs. Full notes in SECURITY.md. Breaking changes in CHANGELOG.md.

bun run typecheck && npm audit --omit=dev && npm pack --dry-run

Release

Provider devin / "Devin", plugin opencode-devin, version 2.0.0. Replaces opencode-devin@0.x. Publish checklist in CHANGELOG.md + SECURITY.md.

bun run typecheck && npm audit --omit=dev && npm pack --dry-run
npm publish

Storage and env vars are final (opencode-devin / OPENCODE_DEVIN_*); no data migration from the old package is done.

About

OpenCode v2 plugin: connect your Devin subscription to opencode with native /connect login and devin/* models

Topics

Resources

Security policy

Stars

7 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages