Skip to content

Commit 4fbf833

Browse files
committed
✨ feat: add OpenCode plugin with embedded server and dual auth
- Embedded HTTP server runs inside OpenCode process (no separate server needed) - Config hook auto-injects augment provider with all 8 models - Two auth methods: Auggie CLI session (auggie login) and API key - Per-model client pooling, retry with exponential backoff, SSE streaming - Port collision safe: OS-assigned random port per instance - Liveness check, startup lock, process cleanup handlers - Debug logging suppressed by default (enable with DEBUG=true)
1 parent e8c63d7 commit 4fbf833

File tree

8 files changed

+7911
-0
lines changed

8 files changed

+7911
-0
lines changed

plugin/README.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# opencode-augment-auth
2+
3+
OpenCode plugin for [Augment Code](https://augmentcode.com) — access Claude and GPT models **at zero cost** through Augment Code's infrastructure.
4+
5+
**No separate server process needed.** The plugin embeds the API server directly inside OpenCode and auto-configures everything.
6+
7+
## Quick Start
8+
9+
### 1. Install the Auggie CLI and authenticate
10+
11+
```bash
12+
npm install -g @augmentcode/auggie
13+
auggie login
14+
```
15+
16+
### 2. Add the plugin to your `opencode.json`
17+
18+
```json
19+
{
20+
"plugin": ["opencode-augment-auth"],
21+
"model": "augment/claude-opus-4-6"
22+
}
23+
```
24+
25+
That's it — no provider config needed. The plugin auto-registers all models.
26+
27+
### 3. Authenticate in OpenCode
28+
29+
```bash
30+
opencode auth login
31+
# Select "Augment Code (auto-detect session.json)"
32+
```
33+
34+
### 4. Use it
35+
36+
```bash
37+
opencode
38+
```
39+
40+
## How It Works
41+
42+
1. **Config hook** auto-injects the `augment` provider with all 8 models into OpenCode
43+
2. **Auth hook** validates your `~/.augment/session.json` from `auggie login`
44+
3. **Embedded server** starts automatically on a random port when OpenCode loads the provider
45+
4. Requests flow: OpenCode → embedded server → Auggie SDK → Augment Code API → Claude/GPT
46+
47+
No separate process to manage. No port conflicts. Everything runs inside OpenCode.
48+
49+
## Available Models
50+
51+
Use `augment/<model-id>` in OpenCode (e.g., `augment/claude-opus-4-6`).
52+
53+
| Model ID | Description | Context | Output |
54+
|----------|-------------|---------|--------|
55+
| `claude-opus-4-6` | Most capable Claude | 200K | 32K |
56+
| `claude-opus-4-5` | Previous Opus gen | 200K | 32K |
57+
| `claude-sonnet-4-5` | Balanced performance | 200K | 16K |
58+
| `claude-sonnet-4` | Previous Sonnet gen | 200K | 16K |
59+
| `claude-haiku-4-5` | Fast, lightweight | 200K | 8K |
60+
| `gpt-5` | GPT-5 | 128K | 16K |
61+
| `gpt-5-1` | Strong reasoning | 128K | 16K |
62+
| `gpt-5-2` | Smarter, slower | 128K | 16K |
63+
64+
## Local Development
65+
66+
```bash
67+
cd plugin
68+
npm install
69+
npm run build
70+
```
71+
72+
Reference the local build in `opencode.json`:
73+
74+
```json
75+
{
76+
"plugin": ["/path/to/auggie-wrapper/plugin"]
77+
}
78+
```
79+
80+
## Troubleshooting
81+
82+
| Issue | Solution |
83+
|-------|----------|
84+
| "Session file not found" | Run `auggie login` to authenticate |
85+
| Auth login fails | Ensure `~/.augment/session.json` exists and has `accessToken` + `tenantURL` |
86+
| Model not found | Use hyphenated IDs: `claude-opus-4-6`, not `claude-opus-4.6` |
87+
88+
## License
89+
90+
MIT

plugin/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { AugmentAuthPlugin } from "./src/plugin.js";
2+
export { AugmentAuthPlugin };
3+
export default AugmentAuthPlugin;
4+

0 commit comments

Comments
 (0)