opencode-devin 0.2.10 → 2.0.0-beta.0
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 +56 -0
- package/LICENSE +1 -1
- package/README.md +118 -228
- package/SECURITY.md +81 -0
- package/package.json +52 -58
- package/scripts/dump-log.ts +22 -0
- package/scripts/login.ts +46 -0
- package/src/index.ts +5 -0
- package/src/plugin.ts +293 -0
- package/src/provider/auth.ts +339 -0
- package/src/provider/cascade.ts +469 -0
- package/src/provider/index.ts +321 -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 -735
- package/dist/provider.d.ts +0 -43
- package/dist/provider.js +0 -30
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [2.0.0-beta.0] — beta (major rewrite)
|
|
4
|
+
|
|
5
|
+
Complete clean-room re-implementation. **Nothing from the previous
|
|
6
|
+
`opencode-devin` package is retained**; this is a breaking major bump
|
|
7
|
+
(`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`.
|
|
8
|
+
|
|
9
|
+
### Breaking
|
|
10
|
+
|
|
11
|
+
- **Identity.** provider `devin` / "Devin", plugin id `opencode-devin`
|
|
12
|
+
(replaces `opencode-devin@0.x`; provider id `devin` matches opencode's
|
|
13
|
+
existing `devin/swe-2` model namespace). No provisional `poc` names.
|
|
14
|
+
- **New data dir.** State moved out of any `devin`/`cognition` directory to
|
|
15
|
+
a private per-user `opencode-devin` dir
|
|
16
|
+
(`%APPDATA%\opencode-devin`, `~/.config/opencode-devin`, or
|
|
17
|
+
`OPENCODE_DEVIN_DIR`). No legacy migration. Env prefix
|
|
18
|
+
`OPENCODE_DEVIN_*`. (Devin CLI's own `%APPDATA%\devin` is never touched.)
|
|
19
|
+
- **Clean-room provider.** No `devin-core` / `devin-engine` / `@ai-sdk/*`
|
|
20
|
+
/ shim dependency; protobuf + Connect-RPC + PKCE implemented in
|
|
21
|
+
`src/provider/*`. Single dependency `@opencode/plugin`.
|
|
22
|
+
- **Model catalog.** One model per family (`baseModelUid`); effort is a
|
|
23
|
+
variant (`#low`/`#medium`/`#high`/`#xhigh`/`#max`/…) carrying
|
|
24
|
+
`{reasoningEffort}`; bare family → `medium` → `high` → first. Plan-quota
|
|
25
|
+
models get `· Free`; paid families publish real `$/1M` `cost`. All
|
|
26
|
+
account models are listed.
|
|
27
|
+
- **Auth.** `/connect` → three methods (browser PKCE auto, paste-code,
|
|
28
|
+
`DEVIN_API_KEY` env). `DEVIN_API_KEY` name kept; session token still
|
|
29
|
+
`devin-session-token$<jwt>`.
|
|
30
|
+
- **No build step.** `main`/`exports` → `src/index.ts`; provider loaded via
|
|
31
|
+
`aisdk:…/src/provider/` → `index.ts`. Removed `dist/` and `*-devin@1`
|
|
32
|
+
deps; package renamed `opencode-devin@2.0.0-dev.0`.
|
|
33
|
+
- **Usage/cost.** Tokens now reported (real metrics when sent; chars/4
|
|
34
|
+
estimate otherwise); `cacheRead/cacheWrite/reasoning`; cost for paid
|
|
35
|
+
models. Previously always 0.
|
|
36
|
+
- **Logging.** Structured JSONL + ring buffer; `scrubSecrets`, redaction,
|
|
37
|
+
`0o600`, 5 MB rotation; `bun run log`.
|
|
38
|
+
- `doGenerate` no longer returns empty usage.
|
|
39
|
+
|
|
40
|
+
### Security
|
|
41
|
+
|
|
42
|
+
- **Cascade host hardening.** Server-returned `customApiServerUrl` is
|
|
43
|
+
sanitized (`sanitizeCascadeHost`): https-only DNS name, no userinfo /
|
|
44
|
+
path / query / fragment / IP / `localhost`, allowlisted domains. Stops
|
|
45
|
+
session-token + `user_jwt` exfiltration to an attacker host.
|
|
46
|
+
- **Log scrubbing** for server error bodies (see `scrubSecrets`).
|
|
47
|
+
- **No credential output** in `scripts/login.ts`; session file `0o600`.
|
|
48
|
+
- No `eval`, no shell-string exec; `Bun.spawn` argv only.
|
|
49
|
+
- `SECURITY.md` added; `bun audit` clean except transitive
|
|
50
|
+
`glob`/`minimatch` inside host `@opencode/plugin` (not shipped).
|
|
51
|
+
|
|
52
|
+
### Fixed
|
|
53
|
+
|
|
54
|
+
- Bare-family `swe-2` no longer "retrying": default-member resolution
|
|
55
|
+
(`defaultUidFor`, `withEffortSuffix`, `defaultMember`).
|
|
56
|
+
- Pricing decoded from catalog field 32 (float32).
|
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,277 +1,167 @@
|
|
|
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
|
+
Inside the TUI, `/connect` → *Devin* offers three methods:
|
|
44
43
|
|
|
45
|
-
|
|
44
|
+
| method | what it does |
|
|
45
|
+
|---|---|
|
|
46
|
+
| **browser (auto)** | opens the Devin OAuth page; a loopback callback finishes the login and stores the token — no paste |
|
|
47
|
+
| **code (headless)** | prints the auth URL; you paste back the code shown on the page |
|
|
48
|
+
| **env var** | reads `DEVIN_API_KEY` (the session token itself) |
|
|
46
49
|
|
|
47
|
-
|
|
48
|
-
// opencode.json
|
|
49
|
-
{
|
|
50
|
-
"model": "devin/swe-2-max"
|
|
51
|
-
}
|
|
52
|
-
```
|
|
50
|
+
## Models
|
|
53
51
|
|
|
54
|
-
|
|
52
|
+
`/models` shows **one entry per family** — `swe-2`, `swe-2-flash`, `swe-2-1`,
|
|
53
|
+
`swe-2-1-lightning`, `swe-2-lightning` (the Ultrafast tiers),
|
|
54
|
+
`claude-opus-4-8`, `gemini-4-carbon`, `muse-wonder-1-0`, … — each with the
|
|
55
|
+
effort variants that family ships (`minimal`/`low`/`medium`/`high`/`xhigh`/
|
|
56
|
+
`max`, selected as `#<effort>`). The exact set of families and variants
|
|
57
|
+
comes from your account's catalog; raw catalog uids like
|
|
58
|
+
`swe-2-flash-medium` correspond to `devin/swe-2-flash#medium`.
|
|
55
59
|
|
|
56
|
-
|
|
57
|
-
opencode run --model devin/swe-2-max "Refactor the auth module"
|
|
58
|
-
```
|
|
60
|
+
Select a variant with `#`:
|
|
59
61
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
`devin/claude-opus-5-5`, with the efforts as variants:
|
|
65
|
-
|
|
66
|
-
- In the TUI, cycle the effort with `ctrl+t` (`variant.cycle`).
|
|
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.
|
|
70
|
-
|
|
71
|
-
Speed and context modifiers are separate families (`devin/claude-opus-5-5-fast`,
|
|
72
|
-
`devin/glm-5-2-1m`). The per-effort UIDs are still accepted, so an existing
|
|
73
|
-
`devin/claude-opus-5-5-high` keeps working; they are only hidden from the picker.
|
|
74
|
-
|
|
75
|
-
### Uncensored mode
|
|
76
|
-
|
|
77
|
-
By default (`"normal"`) the plugin streams the model's answer through
|
|
78
|
-
unchanged. Setting `mode` to `"uncensored"` runs every request through the
|
|
79
|
-
[devin-engine](https://www.npmjs.com/package/devin-engine) guarded-retry
|
|
80
|
-
pipeline — the same machinery the standalone
|
|
81
|
-
[devin-proxy](https://www.npmjs.com/package/devin-proxy) serves over HTTP:
|
|
82
|
-
|
|
83
|
-
- an override system prompt tuned for direct, mechanism-level answers,
|
|
84
|
-
- history sanitizing, so earlier refusals do not anchor later turns,
|
|
85
|
-
- a refusal guard that holds back the first characters of every reply and
|
|
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.
|
|
90
|
-
|
|
91
|
-
```jsonc
|
|
92
|
-
// opencode.json — object form of the plugins entry
|
|
93
|
-
{
|
|
94
|
-
"plugins": [
|
|
95
|
-
{
|
|
96
|
-
"package": "opencode-devin",
|
|
97
|
-
"options": {
|
|
98
|
-
"mode": "uncensored"
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
]
|
|
102
|
-
}
|
|
62
|
+
```bash
|
|
63
|
+
opencode run -m "devin/swe-2#medium" "..."
|
|
64
|
+
opencode run -m "devin/swe-2-flash#high" "..."
|
|
65
|
+
opencode run -m "devin/muse-wonder-1-0#max" "..."
|
|
103
66
|
```
|
|
104
67
|
|
|
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:
|
|
123
|
-
|
|
124
|
-
```jsonc
|
|
125
|
-
{ "provider": { "devin": { "options": { "mode": "uncensored" } } } }
|
|
126
|
-
```
|
|
68
|
+
A bare family (`-m devin/swe-2`, or the picker without a variant) resolves to the
|
|
69
|
+
family default: bare uid if present, else `medium`, else `high`, else the first
|
|
70
|
+
member.
|
|
127
71
|
|
|
128
|
-
|
|
72
|
+
Families without per-token pricing ride the plan quota and get a **· Free**
|
|
73
|
+
suffix in the picker. Paid families publish the real `$ / 1M` input, output
|
|
74
|
+
and cached-input rates from the catalog, so opencode's cost counter is exact.
|
|
129
75
|
|
|
130
|
-
|
|
76
|
+
Token counts: the Cascade local-agent path reports no token metrics (only
|
|
77
|
+
display stats like `agent_messages`/`model`). The provider therefore falls
|
|
78
|
+
back to a `chars / 4` estimate for `input`/`output` so context accounting and
|
|
79
|
+
auto-compaction keep working; if the API ever sends real metrics they win.
|
|
131
80
|
|
|
132
|
-
|
|
133
|
-
flowchart TD
|
|
134
|
-
subgraph Login["Login — /connect"]
|
|
135
|
-
A["/connect → Log in with Devin"] --> B["app.devin.ai/auth/cli/continue<br/>PKCE + S256, loopback callback on 127.0.0.1"]
|
|
136
|
-
B --> C["api.devin.ai/auth/cli/token"]
|
|
137
|
-
C --> D[("devin-session-token$JWT<br/>stored as an OpenCode credential")]
|
|
138
|
-
end
|
|
81
|
+
## Data directory
|
|
139
82
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
E --> F["devin/* models"]
|
|
143
|
-
end
|
|
83
|
+
Session and logs live in a **fixed per-user directory**, never in the project —
|
|
84
|
+
opencode launches from any repo, and state belongs to your account:
|
|
144
85
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
86
|
+
| platform | path |
|
|
87
|
+
|---|---|
|
|
88
|
+
| Windows | `%APPDATA%\opencode-devin\` |
|
|
89
|
+
| macOS/Linux | `~/.config/opencode-devin/` (honours `XDG_CONFIG_HOME`) |
|
|
149
90
|
|
|
150
|
-
|
|
151
|
-
```
|
|
91
|
+
Contents:
|
|
152
92
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
93
|
+
| file | what |
|
|
94
|
+
|---|---|
|
|
95
|
+
| `session` | the `devin-session-token$<jwt>` written by login / `/connect` |
|
|
96
|
+
| `opencode-devin.log` | the JSONL debug log |
|
|
157
97
|
|
|
158
|
-
|
|
98
|
+
The dir is namespaced `opencode-devin` on purpose — nothing called plain
|
|
99
|
+
`devin` is touched, so official Devin tooling can't collide with us.
|
|
159
100
|
|
|
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.
|
|
101
|
+
## Environment variables
|
|
166
102
|
|
|
167
|
-
|
|
103
|
+
| var | required | used by | purpose |
|
|
104
|
+
|---|---|---|---|
|
|
105
|
+
| `DEVIN_API_KEY` | one auth path | plugin + provider | Session token (`devin-session-token$<jwt>`). Beats the session file; a `/connect` credential still wins. |
|
|
106
|
+
| `OPENCODE_DEVIN_DIR` | no | `paths.ts` | Override the whole data directory (session + log). |
|
|
107
|
+
| `OPENCODE_DEVIN_LOG` | no | `log.ts`, `dump-log.ts` | Absolute path for the log file only. |
|
|
108
|
+
| `OPENCODE_DEVIN_SESSION` | no | `paths.ts` | Absolute path for the session file only. |
|
|
168
109
|
|
|
169
|
-
|
|
170
|
-
bun install
|
|
171
|
-
npm run typecheck
|
|
172
|
-
bun test
|
|
173
|
-
npm run build
|
|
174
|
-
```
|
|
110
|
+
### Credential resolution order
|
|
175
111
|
|
|
176
|
-
`
|
|
177
|
-
`
|
|
112
|
+
1. `providerOptions.devin.sessionToken` (per-call override)
|
|
113
|
+
2. `/connect` stored credential for provider `devin`
|
|
114
|
+
3. `DEVIN_API_KEY` env var
|
|
115
|
+
4. session file — `OPENCODE_DEVIN_SESSION` or `<data dir>/session`
|
|
178
116
|
|
|
179
|
-
|
|
180
|
-
(fake JWTs, protobuf `modelConfig`/`catalogReply` encoders, `stubFetch`).
|
|
117
|
+
No legacy paths are read: the dev phase broke compatibility on purpose.
|
|
181
118
|
|
|
182
|
-
|
|
119
|
+
## Logging & debugging
|
|
183
120
|
|
|
184
|
-
|
|
185
|
-
`npm run build && opencode reload`:
|
|
121
|
+
One JSON line per event in `<data dir>/opencode-devin.log`:
|
|
186
122
|
|
|
187
|
-
```
|
|
188
|
-
|
|
189
|
-
{ "plugins": ["opencode-devin@file:C:/path/to/opencode-devin"] }
|
|
190
|
-
|
|
191
|
-
// the published package
|
|
192
|
-
{ "plugins": ["opencode-devin"] }
|
|
123
|
+
```json
|
|
124
|
+
{"t":"…","lvl":"info","ev":"chat.finish","d":{"modelUid":"swe-2-high","reason":"stop","textLen":124,"ms":1830}}
|
|
193
125
|
```
|
|
194
126
|
|
|
195
|
-
|
|
196
|
-
|
|
127
|
+
Events: `plugin.setup`, `publish.start`, `provider.catalog`,
|
|
128
|
+
`credential.resolve_fail`, `auth.mint.*`, `catalog.fetch`, `model.call`,
|
|
129
|
+
`chat.request`, `chat.tool_call`, `chat.finish`, `chat.usage`,
|
|
130
|
+
`chat.401_remint`, `chat.eos_error`, `*.fail`.
|
|
197
131
|
|
|
198
|
-
|
|
132
|
+
Session tokens and JWTs are **redacted** (`first14…last6`) before they hit
|
|
133
|
+
disk; free-form server text is scrubbed for secrets (`scrubSecrets`),
|
|
134
|
+
tool-call arguments are not logged, the file is `0600`, and it rotates at
|
|
135
|
+
~5 MB (one `.1` backup) — the log is safe to paste into a bug report.
|
|
199
136
|
|
|
200
|
-
```
|
|
201
|
-
|
|
137
|
+
```bash
|
|
138
|
+
bun run log # last 120 lines
|
|
139
|
+
bun run log 400 # more
|
|
202
140
|
```
|
|
203
141
|
|
|
204
|
-
|
|
142
|
+
## Security
|
|
205
143
|
|
|
206
|
-
|
|
207
|
-
|
|
144
|
+
Clean-room; no third-party Devin code; no bundled credentials; state in a
|
|
145
|
+
private `opencode-devin` dir (never `devin`/`cognition`); **https only**;
|
|
146
|
+
server-returned cascade hosts are allow-listed (`sanitizeCascadeHost`); no
|
|
147
|
+
`eval`, no shell-string exec; scrubbed `0600` logs. Full notes in
|
|
148
|
+
[SECURITY.md](./SECURITY.md). Breaking changes in
|
|
149
|
+
[CHANGELOG.md](./CHANGELOG.md).
|
|
208
150
|
|
|
209
|
-
```
|
|
210
|
-
bun
|
|
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
|
|
151
|
+
```bash
|
|
152
|
+
bun run typecheck && npm audit --omit=dev && npm pack --dry-run
|
|
214
153
|
```
|
|
215
154
|
|
|
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.
|
|
155
|
+
## Release
|
|
220
156
|
|
|
221
|
-
|
|
157
|
+
Provider `devin` / "Devin", plugin `opencode-devin`, version `2.0.0`.
|
|
158
|
+
Replaces `opencode-devin@0.x`. Publish checklist in
|
|
159
|
+
[CHANGELOG.md](./CHANGELOG.md) + `SECURITY.md`.
|
|
222
160
|
|
|
223
|
-
```
|
|
224
|
-
|
|
161
|
+
```bash
|
|
162
|
+
bun run typecheck && npm audit --omit=dev && npm pack --dry-run
|
|
163
|
+
npm publish
|
|
225
164
|
```
|
|
226
165
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
**Why is `build` atomic?** OpenCode reloads a linked plugin the moment its
|
|
230
|
-
entrypoint changes, and a failed load is not retried. Writing `dist/` in place
|
|
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.
|
|
234
|
-
|
|
235
|
-
**Why a second protobuf implementation in the tests?** The suite encodes and
|
|
236
|
-
decodes with the same module, which only proves the two halves agree — they
|
|
237
|
-
could both be wrong. `wire-conformance.test.ts` checks the framing against
|
|
238
|
-
`protobufjs`, which shares no code with this repository. It is a dev-only
|
|
239
|
-
dependency.
|
|
240
|
-
|
|
241
|
-
**What the tests cannot check.** The Cascade field numbers were recovered by
|
|
242
|
-
reverse-engineering the Devin CLI. Only `test/live.test.ts`, which talks to
|
|
243
|
-
Cognition, can notice them changing. All three RPCs have been exercised against
|
|
244
|
-
the live API, but nothing guards a future upstream change; a committed capture of
|
|
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.
|
|
256
|
-
|
|
257
|
-
## Credits
|
|
258
|
-
|
|
259
|
-
- The Cascade protocol client is a **typed TypeScript port**, owned in `src/protocol/` (see `ATTRIBUTION.md`) — originally from [`ai-sdk-devin`](https://www.npmjs.com/package/ai-sdk-devin) by [karthiknish](https://github.com/karthiknish) and `pi-devin-auth` by nmzpy, both MIT. Owning the port keeps the credential path free of third-party runtime dependencies.
|
|
260
|
-
- [`@cognitionai/opencode-devin`](https://www.npmjs.com/package/@cognitionai/opencode-devin) — reference for the Devin CLI PKCE login flow.
|
|
261
|
-
|
|
262
|
-
## License
|
|
263
|
-
|
|
264
|
-
[MIT](LICENSE)
|
|
265
|
-
|
|
266
|
-
## Ecosystem
|
|
267
|
-
|
|
268
|
-
| Package | Role |
|
|
269
|
-
| --- | --- |
|
|
270
|
-
| `devin-core` | Cascade wire + PKCE auth + catalog — consumed here as `devin-core@^0.0.3` (replaces the old `src/protocol` + `src/auth`) |
|
|
271
|
-
| `devin-engine` | guarded-retry pipeline (embeddable) |
|
|
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 |
|
|
276
|
-
|
|
277
|
-
Topic `devin-ecosystem` groups the repos on GitHub.
|
|
166
|
+
Storage and env vars are final (`opencode-devin` / `OPENCODE_DEVIN_*`); no
|
|
167
|
+
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.
|