opencode-devin 0.1.0 → 0.1.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.
Files changed (4) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +107 -107
  3. package/dist/index.js +11 -5
  4. package/package.json +1 -1
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 opencode-devin contributors
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 opencode-devin contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,107 +1,107 @@
1
- # opencode-devin
2
-
3
- [OpenCode v2](https://opencode.ai) plugin that connects your [Devin](https://devin.ai) subscription to OpenCode:
4
-
5
- - **Native `/connect` integration** — log in with Devin straight from the OpenCode TUI using the same browser PKCE flow as the Devin CLI. The credential is stored in OpenCode's own auth store; no config files or API keys to copy.
6
- - **`devin/*` models in `/models`** — the live, per-account catalog (SWE, Claude Opus, GPT, Gemini, Grok, Kimi and more, with reasoning-effort and speed variants), streamed from Cognition's Cascade inference API.
7
-
8
- > **Requires OpenCode v2.** This plugin targets the v2 plugin API (`Plugin.define`). The official [`@cognitionai/opencode-devin`](https://www.npmjs.com/package/@cognitionai/opencode-devin) plugin is v1-only at the time of writing and does not load on v2.
9
-
10
- ## Install
11
-
12
- Add the plugin to `opencode.json` (project or `~/.config/opencode/opencode.json`):
13
-
14
- ```jsonc
15
- {
16
- "$schema": "https://opencode.ai/config.json",
17
- "plugins": ["opencode-devin"]
18
- }
19
- ```
20
-
21
- OpenCode installs it automatically on the next start.
22
-
23
- ## Connect
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
36
-
37
- Skip `/connect` entirely:
38
-
39
- ```sh
40
- export DEVIN_LLM_API_KEY=devin-session-token$your_token_here
41
- ```
42
-
43
- ## Use
44
-
45
- Pick any `devin/` model in the `/models` picker, or set a default:
46
-
47
- ```jsonc
48
- // opencode.json
49
- {
50
- "model": "devin/swe-2-max"
51
- }
52
- ```
53
-
54
- From the CLI:
55
-
56
- ```sh
57
- opencode run --model devin/swe-2-max "Refactor the auth module"
58
- ```
59
-
60
- ## How it works
61
-
62
- ```
63
- /connect ──▶ app.devin.ai PKCE login ──▶ devin-session-token$<JWT>
64
- │ │
65
- ▼ ▼
66
- stored as an OpenCode credential GetCascadeModelConfigs (gRPC)
67
- │
68
- ▼
69
- provider `devin`
70
- │
71
- ▼
72
- ai-sdk-devin ──▶ Cascade gRPC (GetUserJwt + GetChatMessage)
73
- ```
74
-
75
- 1. **Integration** — the plugin registers a `devin` integration with the Devin CLI login flow: PKCE (S256) against `app.devin.ai/auth/cli/continue`, a loopback callback on `127.0.0.1` (or manual code paste), and a token exchange at `api.devin.ai/auth/cli/token`.
76
- 2. **Catalog** — model families come from Cognition's Cascade API for the logged-in account (the same source the Devin CLI uses). The OpenAI-compatible REST gateway (`/api/v1`) is not provisioned for most accounts, so chat streams through Cascade gRPC instead.
77
- 3. **Provider** — the plugin publishes a `devin` provider whose package specifier self-references the plugin's own installed location (`aisdk:<this-package>`), so OpenCode's dynamic AI-SDK loader imports it directly with no registry round-trip — both from a repo checkout during development and from the npm cache once installed. Its `LanguageModelV3` implementation lives in `src/protocol/`: a short-lived `user_jwt` is minted per session (`GetUserJwt`) and chat streams through `GetChatMessage`.
78
- 4. **Reactivity** — the inventory re-publishes whenever a credential is connected, switched, or removed, so connecting mid-session updates `/models` without a restart.
79
-
80
- ## Troubleshooting
81
-
82
- - **No `devin/` models** — the credential is missing or the catalog fetch failed. Run `/connect` again.
83
- - **401 during chat** — the session token was revoked. Re-run `/connect`.
84
-
85
- ## Development
86
-
87
- ```sh
88
- bun install
89
- npm run typecheck
90
- npm run build # emits dist/
91
- ```
92
-
93
- To test a local checkout without publishing, create a bridge file that re-exports the build:
94
-
95
- ```ts
96
- // ~/.config/opencode/plugins/devin.ts
97
- export { default } from "file:///absolute/path/to/opencode-devin/dist/index.js"
98
- ```
99
-
100
- ## Credits
101
-
102
- - 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.
103
- - [`@cognitionai/opencode-devin`](https://www.npmjs.com/package/@cognitionai/opencode-devin) — reference for the Devin CLI PKCE login flow.
104
-
105
- ## License
106
-
107
- [MIT](LICENSE)
1
+ # opencode-devin
2
+
3
+ [OpenCode v2](https://opencode.ai) plugin that connects your [Devin](https://devin.ai) subscription to OpenCode:
4
+
5
+ - **Native `/connect` integration** — log in with Devin straight from the OpenCode TUI using the same browser PKCE flow as the Devin CLI. The credential is stored in OpenCode's own auth store; no config files or API keys to copy.
6
+ - **`devin/*` models in `/models`** — the live, per-account catalog (SWE, Claude Opus, GPT, Gemini, Grok, Kimi and more, with reasoning-effort and speed variants), streamed from Cognition's Cascade inference API.
7
+
8
+ > **Requires OpenCode v2.** This plugin targets the v2 plugin API (`Plugin.define`). The official [`@cognitionai/opencode-devin`](https://www.npmjs.com/package/@cognitionai/opencode-devin) plugin is v1-only at the time of writing and does not load on v2.
9
+
10
+ ## Install
11
+
12
+ Add the plugin to `opencode.json` (project or `~/.config/opencode/opencode.json`):
13
+
14
+ ```jsonc
15
+ {
16
+ "$schema": "https://opencode.ai/config.json",
17
+ "plugins": ["opencode-devin"]
18
+ }
19
+ ```
20
+
21
+ OpenCode installs it automatically on the next start.
22
+
23
+ ## Connect
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
36
+
37
+ Skip `/connect` entirely:
38
+
39
+ ```sh
40
+ export DEVIN_LLM_API_KEY=devin-session-token$your_token_here
41
+ ```
42
+
43
+ ## Use
44
+
45
+ Pick any `devin/` model in the `/models` picker, or set a default:
46
+
47
+ ```jsonc
48
+ // opencode.json
49
+ {
50
+ "model": "devin/swe-2-max"
51
+ }
52
+ ```
53
+
54
+ From the CLI:
55
+
56
+ ```sh
57
+ opencode run --model devin/swe-2-max "Refactor the auth module"
58
+ ```
59
+
60
+ ## How it works
61
+
62
+ ```
63
+ /connect ──▶ app.devin.ai PKCE login ──▶ devin-session-token$<JWT>
64
+ │ │
65
+ ▼ ▼
66
+ stored as an OpenCode credential GetCascadeModelConfigs (gRPC)
67
+ │
68
+ ▼
69
+ provider `devin`
70
+ │
71
+ ▼
72
+ ai-sdk-devin ──▶ Cascade gRPC (GetUserJwt + GetChatMessage)
73
+ ```
74
+
75
+ 1. **Integration** — the plugin registers a `devin` integration with the Devin CLI login flow: PKCE (S256) against `app.devin.ai/auth/cli/continue`, a loopback callback on `127.0.0.1` (or manual code paste), and a token exchange at `api.devin.ai/auth/cli/token`.
76
+ 2. **Catalog** — model families come from Cognition's Cascade API for the logged-in account (the same source the Devin CLI uses). The OpenAI-compatible REST gateway (`/api/v1`) is not provisioned for most accounts, so chat streams through Cascade gRPC instead.
77
+ 3. **Provider** — the plugin publishes a `devin` provider whose package specifier self-references the plugin's own installed location (`aisdk:<this-package>`), so OpenCode's dynamic AI-SDK loader imports it directly with no registry round-trip — both from a repo checkout during development and from the npm cache once installed. Its `LanguageModelV3` implementation lives in `src/protocol/`: a short-lived `user_jwt` is minted per session (`GetUserJwt`) and chat streams through `GetChatMessage`.
78
+ 4. **Reactivity** — the inventory re-publishes whenever a credential is connected, switched, or removed, so connecting mid-session updates `/models` without a restart.
79
+
80
+ ## Troubleshooting
81
+
82
+ - **No `devin/` models** — the credential is missing or the catalog fetch failed. Run `/connect` again.
83
+ - **401 during chat** — the session token was revoked. Re-run `/connect`.
84
+
85
+ ## Development
86
+
87
+ ```sh
88
+ bun install
89
+ npm run typecheck
90
+ npm run build # emits dist/
91
+ ```
92
+
93
+ To test a local checkout without publishing, create a bridge file that re-exports the build:
94
+
95
+ ```ts
96
+ // ~/.config/opencode/plugins/devin.ts
97
+ export { default } from "file:///absolute/path/to/opencode-devin/dist/index.js"
98
+ ```
99
+
100
+ ## Credits
101
+
102
+ - 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.
103
+ - [`@cognitionai/opencode-devin`](https://www.npmjs.com/package/@cognitionai/opencode-devin) — reference for the Devin CLI PKCE login flow.
104
+
105
+ ## License
106
+
107
+ [MIT](LICENSE)
package/dist/index.js CHANGED
@@ -21,11 +21,17 @@ import { exchangeCode } from "./auth/exchange.js";
21
21
  import { fetchModels } from "./catalog.js";
22
22
  export { createDevinProvider } from "./provider.js";
23
23
  function openBrowser(url) {
24
- const cmd = process.platform === "win32"
25
- ? ["cmd", "/c", "start", "", url]
26
- : process.platform === "darwin"
27
- ? ["open", url]
28
- : ["xdg-open", url];
24
+ if (process.platform === "win32") {
25
+ // `cmd /c start` truncates URLs at "&" (cmd metacharacter) when spawned
26
+ // from Bun — rundll32 hands the URL to the default browser verbatim.
27
+ Bun.spawn(["rundll32", "url.dll,FileProtocolHandler", url], {
28
+ stdin: "ignore",
29
+ stdout: "ignore",
30
+ stderr: "ignore",
31
+ });
32
+ return;
33
+ }
34
+ const cmd = process.platform === "darwin" ? ["open", url] : ["xdg-open", url];
29
35
  Bun.spawn(cmd, { stdin: "ignore", stdout: "ignore", stderr: "ignore" });
30
36
  }
31
37
  export default Plugin.define({
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "opencode-devin",
4
- "version": "0.1.0",
4
+ "version": "0.1.1",
5
5
  "description": "OpenCode v2 plugin: connect your Devin subscription to opencode with native /connect login and devin/* models",
6
6
  "type": "module",
7
7
  "main": "./dist/index.js",