opencode-devin 0.2.11 → 2.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +79 -0
- package/LICENSE +1 -1
- package/README.md +183 -209
- package/SECURITY.md +81 -0
- package/package.json +19 -25
- package/scripts/dump-log.ts +22 -0
- package/scripts/login.ts +46 -0
- package/src/index.ts +5 -0
- package/src/plugin.ts +364 -0
- package/src/provider/auth.ts +339 -0
- package/src/provider/cascade.ts +491 -0
- package/src/provider/index.ts +346 -0
- package/src/provider/log.ts +99 -0
- package/src/provider/package.json +6 -0
- package/src/provider/paths.ts +33 -0
- package/src/provider/proto.ts +197 -0
- package/dist/catalog.d.ts +0 -22
- package/dist/catalog.js +0 -111
- package/dist/constants.d.ts +0 -19
- package/dist/constants.js +0 -19
- package/dist/credentials.d.ts +0 -23
- package/dist/credentials.js +0 -57
- package/dist/index.d.ts +0 -17
- package/dist/index.js +0 -135
- package/dist/protocol/model.d.ts +0 -68
- package/dist/protocol/model.js +0 -738
- package/dist/provider.d.ts +0 -43
- package/dist/provider.js +0 -30
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [2.0.0-beta.1] — beta
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- **Uncensored mode.** Optional per-call/plugin/env switch that injects an
|
|
8
|
+
unrestricted-operator preamble ahead of the folded system block (Cascade
|
|
9
|
+
has no system role); nothing is renamed and no model uid changes.
|
|
10
|
+
- Per-variant: every effort `X` also publishes `X-uncensored`
|
|
11
|
+
(`swe-2#medium-uncensored`); composed with effort, not a replacement
|
|
12
|
+
for it. No standalone `#uncensored` row.
|
|
13
|
+
- **One tri-state plugin switch**, `options.mode`:
|
|
14
|
+
`"censored"` (DEFAULT — stock picker, no uncensored rows, no
|
|
15
|
+
advertisement; nothing needs to be set) / `"both"` (list both, no
|
|
16
|
+
forcing) / `"uncensored"` (list uncensored only + force preamble on
|
|
17
|
+
every call, same as `OPENCODE_DEVIN_UNCENSORED=1`).
|
|
18
|
+
- `providerOptions.devin.uncensored: true`.
|
|
19
|
+
- Global env `OPENCODE_DEVIN_UNCENSORED=1`.
|
|
20
|
+
- `CascadeLanguageModel` 4th constructor arg; `ChatRequest.uncensored`.
|
|
21
|
+
- Log event `model.uncensored`. Client refusal layer removed only;
|
|
22
|
+
server `content_filter`/policy still applies.
|
|
23
|
+
- **Local-plugin docs.** README section: load from a local checkout with
|
|
24
|
+
`"package": "file:///…/opencode-devin"` — no npm publish/install.
|
|
25
|
+
|
|
26
|
+
## [2.0.0-beta.0] — beta (major rewrite)
|
|
27
|
+
|
|
28
|
+
Complete clean-room re-implementation. **Nothing from the previous
|
|
29
|
+
`opencode-devin` package is retained**; this is a breaking major bump
|
|
30
|
+
(`0.2.x` → `2.0.0`). Published as `2.0.0-beta.0` under the `beta` dist-tag; `latest` still points at `0.2.11`.
|
|
31
|
+
|
|
32
|
+
### Breaking
|
|
33
|
+
|
|
34
|
+
- **Identity.** provider `devin` / "Devin", plugin id `opencode-devin`
|
|
35
|
+
(replaces `opencode-devin@0.x`; provider id `devin` matches opencode's
|
|
36
|
+
existing `devin/swe-2` model namespace). No provisional `poc` names.
|
|
37
|
+
- **New data dir.** State moved out of any `devin`/`cognition` directory to
|
|
38
|
+
a private per-user `opencode-devin` dir
|
|
39
|
+
(`%APPDATA%\opencode-devin`, `~/.config/opencode-devin`, or
|
|
40
|
+
`OPENCODE_DEVIN_DIR`). No legacy migration. Env prefix
|
|
41
|
+
`OPENCODE_DEVIN_*`. (Devin CLI's own `%APPDATA%\devin` is never touched.)
|
|
42
|
+
- **Clean-room provider.** No `devin-core` / `devin-engine` / `@ai-sdk/*`
|
|
43
|
+
/ shim dependency; protobuf + Connect-RPC + PKCE implemented in
|
|
44
|
+
`src/provider/*`. Single dependency `@opencode/plugin`.
|
|
45
|
+
- **Model catalog.** One model per family (`baseModelUid`); effort is a
|
|
46
|
+
variant (`#low`/`#medium`/`#high`/`#xhigh`/`#max`/…) carrying
|
|
47
|
+
`{reasoningEffort}`; bare family → `medium` → `high` → first. Plan-quota
|
|
48
|
+
models get `· Free`; paid families publish real `$/1M` `cost`. All
|
|
49
|
+
account models are listed.
|
|
50
|
+
- **Auth.** `/connect` → three methods (browser PKCE auto, paste-code,
|
|
51
|
+
`DEVIN_API_KEY` env). `DEVIN_API_KEY` name kept; session token still
|
|
52
|
+
`devin-session-token$<jwt>`.
|
|
53
|
+
- **No build step.** `main`/`exports` → `src/index.ts`; provider loaded via
|
|
54
|
+
`aisdk:…/src/provider/` → `index.ts`. Removed `dist/` and `*-devin@1`
|
|
55
|
+
deps; package renamed `opencode-devin@2.0.0-dev.0`.
|
|
56
|
+
- **Usage/cost.** Tokens now reported (real metrics when sent; chars/4
|
|
57
|
+
estimate otherwise); `cacheRead/cacheWrite/reasoning`; cost for paid
|
|
58
|
+
models. Previously always 0.
|
|
59
|
+
- **Logging.** Structured JSONL + ring buffer; `scrubSecrets`, redaction,
|
|
60
|
+
`0o600`, 5 MB rotation; `bun run log`.
|
|
61
|
+
- `doGenerate` no longer returns empty usage.
|
|
62
|
+
|
|
63
|
+
### Security
|
|
64
|
+
|
|
65
|
+
- **Cascade host hardening.** Server-returned `customApiServerUrl` is
|
|
66
|
+
sanitized (`sanitizeCascadeHost`): https-only DNS name, no userinfo /
|
|
67
|
+
path / query / fragment / IP / `localhost`, allowlisted domains. Stops
|
|
68
|
+
session-token + `user_jwt` exfiltration to an attacker host.
|
|
69
|
+
- **Log scrubbing** for server error bodies (see `scrubSecrets`).
|
|
70
|
+
- **No credential output** in `scripts/login.ts`; session file `0o600`.
|
|
71
|
+
- No `eval`, no shell-string exec; `Bun.spawn` argv only.
|
|
72
|
+
- `SECURITY.md` added; `bun audit` clean except transitive
|
|
73
|
+
`glob`/`minimatch` inside host `@opencode/plugin` (not shipped).
|
|
74
|
+
|
|
75
|
+
### Fixed
|
|
76
|
+
|
|
77
|
+
- Bare-family `swe-2` no longer "retrying": default-member resolution
|
|
78
|
+
(`defaultUidFor`, `withEffortSuffix`, `defaultMember`).
|
|
79
|
+
- Pricing decoded from catalog field 32 (float32).
|
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,277 +1,251 @@
|
|
|
1
1
|
# opencode-devin
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Devin (Cognition) provider for [opencode](https://opencode.ai) — clean-room.
|
|
4
4
|
|
|
5
|
-
-
|
|
6
|
-
|
|
5
|
+
No third-party Devin libraries: protobuf wire encoding, Connect-RPC framing,
|
|
6
|
+
the PKCE OAuth flow and the Cascade streaming client are all implemented here.
|
|
7
7
|
|
|
8
|
-
> **
|
|
8
|
+
> **Status: dev / pre-release.** Provider `devin`, plugin `opencode-devin`.
|
|
9
|
+
> This replaces the previous `opencode-devin@0.x` package entirely; nothing
|
|
10
|
+
> from it carries over. Major version bump to `2.0.0`.
|
|
9
11
|
|
|
10
|
-
##
|
|
12
|
+
## Layout
|
|
11
13
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
```
|
|
15
|
+
src/index.ts # package entry (npm: "main") — re-exports the plugin
|
|
16
|
+
src/plugin.ts # the plugin: aisdk hooks, /connect methods, catalog → models
|
|
17
|
+
src/provider/ # loaded through the aisdk: specifier (own entry point)
|
|
18
|
+
index.ts # CascadeLanguageModel (aisdk spec v3) + provider factory
|
|
19
|
+
cascade.ts # Connect-RPC framing, catalog fetch, chat streaming, usage
|
|
20
|
+
auth.ts # PKCE login (browser + headless), user_jwt mint, Metadata proto
|
|
21
|
+
proto.ts # protobuf wire primitives
|
|
22
|
+
paths.ts # per-user data dir resolution
|
|
23
|
+
log.ts # structured JSONL logger + in-memory ring buffer
|
|
24
|
+
.opencode/plugin/opencode-devin.ts # dev shim → src/plugin.ts (auto-loaded)
|
|
25
|
+
scripts/
|
|
26
|
+
login.ts # standalone PKCE login → writes the session file
|
|
27
|
+
dump-log.ts # print the log tail for bug reports
|
|
19
28
|
```
|
|
20
29
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
Start OpenCode, run `/connect`, pick **Devin**, then choose a method:
|
|
26
|
-
|
|
27
|
-
| Method | How it works | Best for |
|
|
28
|
-
| --- | --- | --- |
|
|
29
|
-
| **Log in with Devin (browser)** | Opens the Devin sign-in page (PKCE + S256) and captures the authorization code through a local loopback callback. | Interactive terminals |
|
|
30
|
-
| **Paste code (headless)** | Opens the same login page without a redirect; the page shows a code to copy and paste back into the TUI. | Headless machines, SSH |
|
|
31
|
-
| **`DEVIN_LLM_API_KEY`** | Reads a `devin-session-token$...` token from the environment. | CI, scripting |
|
|
32
|
-
|
|
33
|
-
After connecting, the model list refreshes automatically and `devin/<model>` entries appear in `/models`.
|
|
34
|
-
|
|
35
|
-
### Environment variable alternative
|
|
30
|
+
No build step: opencode runs on Bun and loads the TypeScript sources directly
|
|
31
|
+
(`src/index.ts` is `main`, and `src/provider/package.json` points the aisdk
|
|
32
|
+
entry at `src/provider/index.ts`).
|
|
36
33
|
|
|
37
|
-
|
|
34
|
+
## Quick start
|
|
38
35
|
|
|
39
|
-
```
|
|
40
|
-
|
|
36
|
+
```bash
|
|
37
|
+
bun install
|
|
38
|
+
bun run login # browser PKCE login → writes the session file
|
|
39
|
+
opencode run -m "devin/swe-2#high" "hello"
|
|
41
40
|
```
|
|
42
41
|
|
|
43
|
-
|
|
42
|
+
### Use from a local checkout (no npm)
|
|
44
43
|
|
|
45
|
-
|
|
44
|
+
`main` is `src/index.ts` and opencode runs on Bun — load the plugin straight
|
|
45
|
+
from a local directory with a `file:///` URL. No `npm install opencode-devin`,
|
|
46
|
+
no publish, no build step. Just `bun install` once inside the repo.
|
|
46
47
|
|
|
47
48
|
```jsonc
|
|
48
|
-
// opencode.json
|
|
49
|
+
// ~/.config/opencode/opencode.json (global) — or .opencode/opencode.json in a project
|
|
49
50
|
{
|
|
50
|
-
"
|
|
51
|
+
"$schema": "https://opencode.ai/config.json",
|
|
52
|
+
"plugins": [
|
|
53
|
+
{
|
|
54
|
+
"package": "file:///C:/Users/Josemi/dev/opencode-devin", // absolute path to this repo
|
|
55
|
+
"options": { "uncensored": true } // optional, see Uncensored mode
|
|
56
|
+
}
|
|
57
|
+
]
|
|
51
58
|
}
|
|
52
59
|
```
|
|
53
60
|
|
|
54
|
-
|
|
61
|
+
Every edit under `src/` applies on the next opencode restart. On POSIX use
|
|
62
|
+
`file:///home/you/opencode-devin`; on Windows use forward slashes after
|
|
63
|
+
`file:///C:/`. Don't keep a second `opencode-devin` (npm) entry loaded at the
|
|
64
|
+
same time. opencode also auto-loads `*.ts` shims from `.opencode/plugin/` —
|
|
65
|
+
this repo ships `.opencode/plugin/opencode-devin.ts` for in-repo dev, which is
|
|
66
|
+
equivalent to running from `bun install` + this repo as cwd.
|
|
55
67
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
```
|
|
68
|
+
Check it loaded: `bun run log 30` shows `plugin.setup`, `publish.start`,
|
|
69
|
+
`provider.catalog` in `<data dir>/opencode-devin.log`.
|
|
59
70
|
|
|
60
|
-
|
|
71
|
+
Inside the TUI, `/connect` → *Devin* offers three methods:
|
|
61
72
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
73
|
+
| method | what it does |
|
|
74
|
+
|---|---|
|
|
75
|
+
| **browser (auto)** | opens the Devin OAuth page; a loopback callback finishes the login and stores the token — no paste |
|
|
76
|
+
| **code (headless)** | prints the auth URL; you paste back the code shown on the page |
|
|
77
|
+
| **env var** | reads `DEVIN_API_KEY` (the session token itself) |
|
|
65
78
|
|
|
66
|
-
|
|
67
|
-
- From the CLI or config, append it: `devin/claude-opus-5-5#high`.
|
|
68
|
-
- With no variant selected, the family runs at medium, or at high when it has
|
|
69
|
-
no medium.
|
|
79
|
+
## Models
|
|
70
80
|
|
|
71
|
-
|
|
72
|
-
`
|
|
73
|
-
`
|
|
81
|
+
`/models` shows **one entry per family** — `swe-2`, `swe-2-flash`, `swe-2-1`,
|
|
82
|
+
`swe-2-1-lightning`, `swe-2-lightning` (the Ultrafast tiers),
|
|
83
|
+
`claude-opus-4-8`, `gemini-4-carbon`, `muse-wonder-1-0`, … — each with the
|
|
84
|
+
effort variants that family ships (`minimal`/`low`/`medium`/`high`/`xhigh`/
|
|
85
|
+
`max`, selected as `#<effort>`). The exact set of families and variants
|
|
86
|
+
comes from your account's catalog; raw catalog uids like
|
|
87
|
+
`swe-2-flash-medium` correspond to `devin/swe-2-flash#medium`.
|
|
74
88
|
|
|
75
|
-
|
|
89
|
+
Select a variant with `#`:
|
|
76
90
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
91
|
+
```bash
|
|
92
|
+
opencode run -m "devin/swe-2#medium" "..."
|
|
93
|
+
opencode run -m "devin/swe-2-flash#high" "..."
|
|
94
|
+
opencode run -m "devin/muse-wonder-1-0#max" "..."
|
|
95
|
+
```
|
|
82
96
|
|
|
83
|
-
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
transparently resamples — escalating temperature, framing the request as
|
|
87
|
-
continuing work already agreed on — whenever the model opens a refusal.
|
|
88
|
-
Retries are invisible downstream; only the final attempt passes a refusal
|
|
89
|
-
through.
|
|
97
|
+
A bare family (`-m devin/swe-2`, or the picker without a variant) resolves to the
|
|
98
|
+
family default: bare uid if present, else `medium`, else `high`, else the first
|
|
99
|
+
member.
|
|
90
100
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
"plugins": [
|
|
95
|
-
{
|
|
96
|
-
"package": "opencode-devin",
|
|
97
|
-
"options": {
|
|
98
|
-
"mode": "uncensored"
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
]
|
|
102
|
-
}
|
|
103
|
-
```
|
|
101
|
+
Families without per-token pricing ride the plan quota and get a **· Free**
|
|
102
|
+
suffix in the picker. Paid families publish the real `$ / 1M` input, output
|
|
103
|
+
and cached-input rates from the catalog, so opencode's cost counter is exact.
|
|
104
104
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
| `mode` | `"normal"` | `"uncensored"` enables the pipeline. |
|
|
110
|
-
| `guardChars` | `700` | Head-window size the refusal guard scans before releasing text. |
|
|
111
|
-
| `guardFull` | `false` | Buffer and scan the whole reply instead — catches comply-then-pivot refusals at the cost of streaming. |
|
|
112
|
-
| `maxRetries` | `3` | Resample attempts after the first one. |
|
|
113
|
-
| `retryTemps` | `"0.85,1.0,1.1"` | Comma-separated retry temperature ladder. |
|
|
114
|
-
| `overrideFile` | bundled EN | Override prompt: a filesystem path, or a bundled language name — `"en"` / `"english"`, `"es"` / `"spanish"`. A file at `~/.devin-proxy/override-compact.txt` is picked up too, same as the standalone proxy. |
|
|
115
|
-
| `keepClientSystem` | `false` | Keep OpenCode's own system prompt ahead of the override instead of replacing it. |
|
|
116
|
-
| `planPreamble` | `false` | Have the model announce briefly what it is about to do before tool calls. |
|
|
117
|
-
| `maxInputTokens` | unset | Estimated-input-token budget — older history turns are pruned past it (system head and newest turns stay). Useful ceiling for long agent sessions. |
|
|
118
|
-
| `pruneKeepTurns` | `12` | Minimum history turns kept when pruning. |
|
|
119
|
-
|
|
120
|
-
The plugin forwards these options into the published provider settings, so
|
|
121
|
-
they can also be set — or overridden per-install — through a classic provider
|
|
122
|
-
stanza, which wins over the plugin options in opencode's settings merge:
|
|
105
|
+
Token counts: the Cascade local-agent path reports no token metrics (only
|
|
106
|
+
display stats like `agent_messages`/`model`). The provider therefore falls
|
|
107
|
+
back to a `chars / 4` estimate for `input`/`output` so context accounting and
|
|
108
|
+
auto-compaction keep working; if the API ever sends real metrics they win.
|
|
123
109
|
|
|
124
|
-
|
|
125
|
-
{ "provider": { "devin": { "options": { "mode": "uncensored" } } } }
|
|
126
|
-
```
|
|
110
|
+
## Uncensored mode
|
|
127
111
|
|
|
128
|
-
|
|
112
|
+
Flips the provider into an unrestricted operator mode. Nothing is renamed —
|
|
113
|
+
same family, same effort, same model uid sent to Devin; the only change is a
|
|
114
|
+
**preamble injected ahead of your system block** in the first user turn
|
|
115
|
+
(Cascade has no system role): no refusals, no disclaimers, no moral
|
|
116
|
+
commentary, security/reverse-engineering treated as ordinary engineering,
|
|
117
|
+
complete untruncated output. Your own system prompt still applies after it.
|
|
129
118
|
|
|
130
|
-
|
|
119
|
+
Activation, any of:
|
|
131
120
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
end
|
|
121
|
+
| mechanism | example |
|
|
122
|
+
|---|---|
|
|
123
|
+
| per-variant (combined with effort) | `-m "devin/swe-2#medium-uncensored"`, `-m "devin/swe-2#uncensored"` |
|
|
124
|
+
| per-call providerOptions | `providerOptions.devin.uncensored: true` |
|
|
125
|
+
| global env var | `OPENCODE_DEVIN_UNCENSORED=1` |
|
|
126
|
+
| plugin option | `"options": { "mode": "uncensored" }` on the plugin entry |
|
|
139
127
|
|
|
140
|
-
|
|
141
|
-
D --> E["GetCascadeModelConfigs (gRPC)<br/>live per-account model list"]
|
|
142
|
-
E --> F["devin/* models"]
|
|
143
|
-
end
|
|
128
|
+
### One switch: `options.mode`
|
|
144
129
|
|
|
145
|
-
|
|
146
|
-
D --> G["GetUserJwt → short-lived user_jwt"]
|
|
147
|
-
G --> H["GetChatMessage<br/>Cascade gRPC streaming"]
|
|
148
|
-
end
|
|
130
|
+
A single tri-state. Nothing needs to be set for the default.
|
|
149
131
|
|
|
150
|
-
|
|
151
|
-
|
|
132
|
+
| `options.mode` | listing | activation |
|
|
133
|
+
|---|---|---|
|
|
134
|
+
| `"censored"` (default) | sólo `#X` stock, sin uncensored rows | off |
|
|
135
|
+
| `"both"` | `#X` + `#X-uncensored` por cada effort | off |
|
|
136
|
+
| `"uncensored"` | sólo `#X-uncensored` | **force on every call** |
|
|
152
137
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
138
|
+
```jsonc
|
|
139
|
+
// ~/.config/opencode/opencode.json → plugins[].options
|
|
140
|
+
"mode": "uncensored" // or omit `mode` entirely for "censored"
|
|
141
|
+
```
|
|
157
142
|
|
|
158
|
-
|
|
143
|
+
Separately, per-call `providerOptions.devin.uncensored`, the `#X-uncensored`
|
|
144
|
+
variant, and env `OPENCODE_DEVIN_UNCENSORED=1` trigger activation without
|
|
145
|
+
any plugin-level option.
|
|
159
146
|
|
|
160
|
-
|
|
161
|
-
- **A model is rejected even though `/models` lists it**: the account can see a uid it is not entitled to. The error names the tier.
|
|
162
|
-
- **Costs look wrong or absent**: OpenCode reads cost from the pricing published to `/models`, not from the stream. Check the model has a non-zero price there — `bun scripts/devin.ts verify` dumps what the catalog actually reports.
|
|
163
|
-
- **A 401 during chat**: the short-lived token is refreshed automatically. Reconnect only if the session token itself was revoked.
|
|
164
|
-
- **`Plugin failed to load`**: rebuild and `opencode reload`. See the FAQ on atomic builds.
|
|
165
|
-
- **A path in `plugins` is ignored**: only `name@file:<absolute-path>` links a local build.
|
|
147
|
+
### Selecting variants
|
|
166
148
|
|
|
167
|
-
|
|
149
|
+
Per effort `X`, in `"both"` listing the picker offers `#X` and
|
|
150
|
+
`#X-uncensored`. Combined with effort, never replacing it. No standalone
|
|
151
|
+
`#uncensored` row; `#X-uncensored` without an effort isn't emitted — pick a
|
|
152
|
+
level, or use `mode: "uncensored"` / env to force it regardless.
|
|
168
153
|
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
bun test
|
|
173
|
-
npm run build
|
|
154
|
+
```bash
|
|
155
|
+
opencode run -m "devin/swe-2#medium" "..." # stock
|
|
156
|
+
opencode run -m "devin/swe-2#medium-uncensored" "..." # + uncensored
|
|
174
157
|
```
|
|
175
158
|
|
|
176
|
-
|
|
177
|
-
|
|
159
|
+
Uncensored calls log `model.uncensored`. Note this only removes the *client*
|
|
160
|
+
refusal layer: a model-side `content_filter` stop (StopReason 11) or a
|
|
161
|
+
server-side policy can still block output, which you'll see as
|
|
162
|
+
`finish: content_filter` / `chat.eos_error` in the log.
|
|
178
163
|
|
|
179
|
-
|
|
180
|
-
(fake JWTs, protobuf `modelConfig`/`catalogReply` encoders, `stubFetch`).
|
|
164
|
+
## Data directory
|
|
181
165
|
|
|
182
|
-
|
|
166
|
+
Session and logs live in a **fixed per-user directory**, never in the project —
|
|
167
|
+
opencode launches from any repo, and state belongs to your account:
|
|
183
168
|
|
|
184
|
-
|
|
185
|
-
|
|
169
|
+
| platform | path |
|
|
170
|
+
|---|---|
|
|
171
|
+
| Windows | `%APPDATA%\opencode-devin\` |
|
|
172
|
+
| macOS/Linux | `~/.config/opencode-devin/` (honours `XDG_CONFIG_HOME`) |
|
|
186
173
|
|
|
187
|
-
|
|
188
|
-
// this repository
|
|
189
|
-
{ "plugins": ["opencode-devin@file:C:/path/to/opencode-devin"] }
|
|
174
|
+
Contents:
|
|
190
175
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
176
|
+
| file | what |
|
|
177
|
+
|---|---|
|
|
178
|
+
| `session` | the `devin-session-token$<jwt>` written by login / `/connect` |
|
|
179
|
+
| `opencode-devin.log` | the JSONL debug log |
|
|
194
180
|
|
|
195
|
-
The
|
|
196
|
-
|
|
181
|
+
The dir is namespaced `opencode-devin` on purpose — nothing called plain
|
|
182
|
+
`devin` is touched, so official Devin tooling can't collide with us.
|
|
197
183
|
|
|
198
|
-
|
|
184
|
+
## Environment variables
|
|
199
185
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
186
|
+
| var | required | used by | purpose |
|
|
187
|
+
|---|---|---|---|
|
|
188
|
+
| `DEVIN_API_KEY` | one auth path | plugin + provider | Session token (`devin-session-token$<jwt>`). Beats the session file; a `/connect` credential still wins. |
|
|
189
|
+
| `OPENCODE_DEVIN_DIR` | no | `paths.ts` | Override the whole data directory (session + log). |
|
|
190
|
+
| `OPENCODE_DEVIN_LOG` | no | `log.ts`, `dump-log.ts` | Absolute path for the log file only. |
|
|
191
|
+
| `OPENCODE_DEVIN_UNCENSORED` | no | `index.ts` | `1` forces [uncensored mode](#uncensored-mode) on every call. |
|
|
192
|
+
| `OPENCODE_DEVIN_SESSION` | no | `paths.ts` | Absolute path for the session file only. |
|
|
203
193
|
|
|
204
|
-
###
|
|
194
|
+
### Credential resolution order
|
|
205
195
|
|
|
206
|
-
|
|
207
|
-
|
|
196
|
+
1. `providerOptions.devin.sessionToken` (per-call override)
|
|
197
|
+
2. `/connect` stored credential for provider `devin`
|
|
198
|
+
3. `DEVIN_API_KEY` env var
|
|
199
|
+
4. session file — `OPENCODE_DEVIN_SESSION` or `<data dir>/session`
|
|
208
200
|
|
|
209
|
-
|
|
210
|
-
bun scripts/devin.ts all # login (if needed) → catalog dump → live tests
|
|
211
|
-
bun scripts/devin.ts login # just the PKCE login → .devin-token.env
|
|
212
|
-
bun scripts/devin.ts verify # dump live catalog pricing
|
|
213
|
-
bun scripts/devin.ts test # run test/live.test.ts
|
|
214
|
-
```
|
|
201
|
+
No legacy paths are read: the dev phase broke compatibility on purpose.
|
|
215
202
|
|
|
216
|
-
|
|
217
|
-
`--manual` for paste-code on headless machines). The token lands in
|
|
218
|
-
`.devin-token.env`, which `verify`/`test`/`all` pick up automatically, so a
|
|
219
|
-
second `all` run skips the browser entirely.
|
|
203
|
+
## Logging & debugging
|
|
220
204
|
|
|
221
|
-
|
|
205
|
+
One JSON line per event in `<data dir>/opencode-devin.log`:
|
|
222
206
|
|
|
223
|
-
```
|
|
224
|
-
|
|
207
|
+
```json
|
|
208
|
+
{"t":"…","lvl":"info","ev":"chat.finish","d":{"modelUid":"swe-2-high","reason":"stop","textLen":124,"ms":1830}}
|
|
225
209
|
```
|
|
226
210
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
lets a reload land mid-write and fail, which shows up as `ENOENT reading
|
|
232
|
-
dist/index.js` or `Cannot find module '.../constants.js'`. `build` compiles to a
|
|
233
|
-
staging directory and swaps it in.
|
|
211
|
+
Events: `plugin.setup`, `publish.start`, `provider.catalog`,
|
|
212
|
+
`credential.resolve_fail`, `auth.mint.*`, `catalog.fetch`, `model.call`,
|
|
213
|
+
`chat.request`, `chat.tool_call`, `chat.finish`, `chat.usage`,
|
|
214
|
+
`chat.401_remint`, `chat.eos_error`, `*.fail`.
|
|
234
215
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
`
|
|
239
|
-
dependency.
|
|
216
|
+
Session tokens and JWTs are **redacted** (`first14…last6`) before they hit
|
|
217
|
+
disk; free-form server text is scrubbed for secrets (`scrubSecrets`),
|
|
218
|
+
tool-call arguments are not logged, the file is `0600`, and it rotates at
|
|
219
|
+
~5 MB (one `.1` backup) — the log is safe to paste into a bug report.
|
|
240
220
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
real responses would, and there is not one yet.
|
|
246
|
-
|
|
247
|
-
**Why doesn't a missing model fail immediately?** Because the catalog is not
|
|
248
|
-
guaranteed to list every uid Cascade accepts, and refusing one that works would
|
|
249
|
-
be worse than a vague error. Disabled models are refused outright; unknown ones
|
|
250
|
-
are warned about, and the likely reason is appended if the request fails.
|
|
251
|
-
|
|
252
|
-
**Why is the session token in the provider registry?** It is passed as
|
|
253
|
-
`settings.apiKey`, which is how the provider receives it. `opencode api
|
|
254
|
-
provider.list` therefore returns it in clear text. Treat that output as a
|
|
255
|
-
secret.
|
|
221
|
+
```bash
|
|
222
|
+
bun run log # last 120 lines
|
|
223
|
+
bun run log 400 # more
|
|
224
|
+
```
|
|
256
225
|
|
|
257
|
-
##
|
|
226
|
+
## Security
|
|
258
227
|
|
|
259
|
-
-
|
|
260
|
-
|
|
228
|
+
Clean-room; no third-party Devin code; no bundled credentials; state in a
|
|
229
|
+
private `opencode-devin` dir (never `devin`/`cognition`); **https only**;
|
|
230
|
+
server-returned cascade hosts are allow-listed (`sanitizeCascadeHost`); no
|
|
231
|
+
`eval`, no shell-string exec; scrubbed `0600` logs. Full notes in
|
|
232
|
+
[SECURITY.md](./SECURITY.md). Breaking changes in
|
|
233
|
+
[CHANGELOG.md](./CHANGELOG.md).
|
|
261
234
|
|
|
262
|
-
|
|
235
|
+
```bash
|
|
236
|
+
bun run typecheck && npm audit --omit=dev && npm pack --dry-run
|
|
237
|
+
```
|
|
263
238
|
|
|
264
|
-
|
|
239
|
+
## Release
|
|
265
240
|
|
|
266
|
-
|
|
241
|
+
Provider `devin` / "Devin", plugin `opencode-devin`, version `2.0.0`.
|
|
242
|
+
Replaces `opencode-devin@0.x`. Publish checklist in
|
|
243
|
+
[CHANGELOG.md](./CHANGELOG.md) + `SECURITY.md`.
|
|
267
244
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
| `devin-proxy` | standalone OpenAI-compatible proxy |
|
|
273
|
-
| `devin-proxy-py` | Python reference implementation |
|
|
274
|
-
| **`opencode-devin`** (this) | OpenCode v2 plugin — `LanguageModelV3` adapter + `/connect` login |
|
|
275
|
-
| `claude-devin` | Claude/Anthropic-compatible surface — same core |
|
|
245
|
+
```bash
|
|
246
|
+
bun run typecheck && npm audit --omit=dev && npm pack --dry-run
|
|
247
|
+
npm publish
|
|
248
|
+
```
|
|
276
249
|
|
|
277
|
-
|
|
250
|
+
Storage and env vars are final (`opencode-devin` / `OPENCODE_DEVIN_*`); no
|
|
251
|
+
data migration from the old package is done.
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# Security
|
|
2
|
+
|
|
3
|
+
`opencode-devin` is a clean-room opencode plugin that talks to Devin /
|
|
4
|
+
Cognition's Cascade API with your own session token. This document records
|
|
5
|
+
the security posture and how we harden it.
|
|
6
|
+
|
|
7
|
+
## Reporting a vulnerability
|
|
8
|
+
|
|
9
|
+
Please **do not** open a public issue. Email **joshmiquel.cs@gmail.com** (or
|
|
10
|
+
use GitHub private vulnerability reporting on
|
|
11
|
+
[JoShMiQueL/opencode-devin](https://github.com/JoShMiQueL/opencode-devin)).
|
|
12
|
+
Include reproduction steps and affected version; we'll acknowledge within a
|
|
13
|
+
few days.
|
|
14
|
+
|
|
15
|
+
## Credentials
|
|
16
|
+
|
|
17
|
+
- provider `devin`, plugin `opencode-devin`; no remnants of `opencode-devin@0.x`.
|
|
18
|
+
- **No credentials are bundled or committed.** The session token
|
|
19
|
+
(`devin-session-token$<jwt>`) comes from `/connect`, `DEVIN_API_KEY`, or
|
|
20
|
+
`<data dir>/session`. `.env`, `.gitignore`, and npm `files` exclude them.
|
|
21
|
+
- The session file is written with `0o600`.
|
|
22
|
+
- The plugin never writes anywhere named `devin` / `cognition`; state lives
|
|
23
|
+
in a private `opencode-devin` dir (no collision with official Devin tools,
|
|
24
|
+
no symlink/shared-dir ambiguity).
|
|
25
|
+
|
|
26
|
+
## What is sent where
|
|
27
|
+
|
|
28
|
+
- Only two origins are contacted, both **https**:
|
|
29
|
+
`https://server.codeium.com` (+ `https://app.devin.ai` for PKCE OAuth).
|
|
30
|
+
- The long-lived session token travels inside the `Metadata` protobuf
|
|
31
|
+
(`apiKey`, and `user_jwt` in field 21). The short-lived minted `user_jwt`
|
|
32
|
+
travels in `Metadata` field 21 and, for unary calls, `Authorization:
|
|
33
|
+
Bearer`.
|
|
34
|
+
- **Server-returned hosts are not trusted.** `GetUserJwt` can return a
|
|
35
|
+
`customApiServerUrl`; `sanitizeCascadeHost()` (auth.ts) accepts it only if
|
|
36
|
+
it is a plain `https` DNS name under `codeium.com` / `devin.ai` /
|
|
37
|
+
`cognition.ai` / the trusted host's own domain — no userinfo, no
|
|
38
|
+
path/query/fragment, no IP literal, no `localhost`, no port tricks, no
|
|
39
|
+
scheme override. Otherwise we keep the trusted host. (Prevents
|
|
40
|
+
credential exfiltration to an attacker-controlled endpoint.)
|
|
41
|
+
- No `eval`, no `new Function`, no shell injection. `Bun.spawn` is always
|
|
42
|
+
argv-array, never a shell. `openBrowser` spawns `rundll32`/`open`/
|
|
43
|
+
`xdg-open` with our own OAuth URL.
|
|
44
|
+
- OAuth uses PKCE (`S256`) with a stateless loopback listener on
|
|
45
|
+
`127.0.0.1`; nothing is printed to logs.
|
|
46
|
+
|
|
47
|
+
## Logging
|
|
48
|
+
|
|
49
|
+
`opencode-devin.log` is designed to be safe to share for bug reports:
|
|
50
|
+
|
|
51
|
+
- session tokens / JWTs are **redacted** (`first14…last6`) via `redact()`;
|
|
52
|
+
- free-form server text (error bodies, trailers) is passed through
|
|
53
|
+
`scrubSecrets()`, which strips `devin-session-token$…`, JWTs,
|
|
54
|
+
`Bearer …`, and `"token"/"api_key"/"access"/"refresh"/"secret"/
|
|
55
|
+
"password"` JSON values;
|
|
56
|
+
- tool-call **arguments are not logged** (names + ids only);
|
|
57
|
+
- log file is `0o600`, capped at ~5 MB with one `.1` rotation.
|
|
58
|
+
|
|
59
|
+
`bun run log` prints the scrubbed tail.
|
|
60
|
+
|
|
61
|
+
## Supply chain
|
|
62
|
+
|
|
63
|
+
- **No third-party Devin/Cascade code.** protobuf wire, Connect-RPC, PKCE,
|
|
64
|
+
and the Cascade client are implemented here (`src/provider/*`); we do not
|
|
65
|
+
depend on `devin-core`, `devin-engine`, `@ai-sdk/*`, or any shim.
|
|
66
|
+
- Single runtime dependency: `@opencode/plugin` (host provides it). Nothing from the previous `opencode-devin` package carries over.
|
|
67
|
+
- No postinstall scripts, no network installs at runtime.
|
|
68
|
+
- `npm audit` / `bun audit`: our package ships no vendored `node_modules`;
|
|
69
|
+
transitive advisories live in `@opencode/plugin` (host-managed). See the
|
|
70
|
+
publish checklist in README.
|
|
71
|
+
|
|
72
|
+
## Dependency floor & publish checklist
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
bun run typecheck # strict tsc, clean
|
|
76
|
+
npm audit --omit=dev # review
|
|
77
|
+
npm pack --dry-run # only src/** + README + LICENSE ship
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
No secrets in `files`; `src/provider/package.json` is the aisdk sub-entry
|
|
81
|
+
and contains no data.
|