|
1 | | -# opencode-commandcode |
| 1 | +<p align="center"> |
| 2 | + <img src="docs/header.svg" width="828" alt="opencode-commandcode — Command Code in OpenCode, Laguna S 2.1 gateway"> |
| 3 | +</p> |
| 4 | + |
| 5 | +<p align="center"> |
| 6 | + <a href="https://www.npmjs.com/package/@otto-assistant/opencode-commandcode"><img src="https://img.shields.io/npm/v/%40otto-assistant%2Fopencode-commandcode?style=flat-square&color=7dcea0&labelColor=0c1412&label=npm" alt="npm version"></a> |
| 7 | + <a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-7dcea0?style=flat-square&labelColor=0c1412" alt="MIT license"></a> |
| 8 | + <img src="https://img.shields.io/badge/linux%20·%20macos%20·%20windows-7dcea0?style=flat-square&labelColor=0c1412" alt="linux, macos, windows"> |
| 9 | +</p> |
| 10 | + |
| 11 | +<p align="center"> |
| 12 | + <strong>Command Code inside OpenCode</strong> — Go-plan ($1) browser login,<br> |
| 13 | + gateway proxy, free Laguna S 2.1, tools/MCP, attachments, compact, usage. |
| 14 | +</p> |
| 15 | + |
| 16 | +--- |
| 17 | + |
| 18 | +Run [Command Code](https://commandcode.ai) models from OpenCode by proxying the same gateway that `npm i -g command-code@latest` uses (`POST /alpha/generate`). Default and exclusive live-test target: **Laguna S 2.1 free** (`poolside/laguna-s-2.1-free`, 256k context, $0). |
| 19 | + |
| 20 | +Plugin shape mirrors [@otto-assistant/opencode-claude](https://github.com/otto-assistant/opencode-claude) and [@otto-assistant/opencode-cursor](https://github.com/otto-assistant/opencode-cursor). |
| 21 | + |
| 22 | +## Install |
| 23 | + |
| 24 | +```bash |
| 25 | +# global (recommended) |
| 26 | +opencode plugin @otto-assistant/opencode-commandcode -g |
| 27 | + |
| 28 | +# or project-local |
| 29 | +opencode plugin @otto-assistant/opencode-commandcode |
| 30 | +``` |
| 31 | + |
| 32 | +Optional provider naming: |
| 33 | + |
| 34 | +```jsonc |
| 35 | +{ |
| 36 | + "$schema": "https://opencode.ai/config.json", |
| 37 | + "plugin": ["@otto-assistant/opencode-commandcode"], |
| 38 | + "provider": { |
| 39 | + "command-code": { "name": "Command Code" } |
| 40 | + } |
| 41 | +} |
| 42 | +``` |
| 43 | + |
| 44 | +From source: |
| 45 | + |
| 46 | +```bash |
| 47 | +git clone https://github.com/otto-assistant/opencode-commandcode.git |
| 48 | +cd opencode-commandcode |
| 49 | +bun install && bun run build |
| 50 | +opencode plugin file://$PWD |
| 51 | +``` |
| 52 | + |
| 53 | +## Authenticate |
| 54 | + |
| 55 | +Uses the **Command Code Go plan ($1/mo)** — same browser login as `cmd login`. No Studio API key. |
| 56 | + |
| 57 | +```bash |
| 58 | +npm i -g command-code@latest |
| 59 | +cmd login # browser → Studio CLI auth (Go plan). Laguna S 2.1 is $0 credits. |
| 60 | + |
| 61 | +opencode auth login --provider command-code |
| 62 | +# pick "Login with Command Code (Go $1)" — or "Use existing cmd login session" |
| 63 | +``` |
| 64 | + |
| 65 | +Then: |
| 66 | + |
| 67 | +```bash |
| 68 | +opencode run "Summarise this repository in five bullets." --model command-code/laguna-s-2.1-free |
| 69 | +``` |
| 70 | + |
| 71 | +Laguna S 2.1 free requires an active Go (or higher) account with credits on file; requests on that model still bill **$0**. |
| 72 | + |
| 73 | +## Why this plugin |
| 74 | + |
| 75 | +| | | |
| 76 | +|---|---| |
| 77 | +| **Gateway proxy** | Talks to `api.commandcode.ai/alpha/generate` — same transport as the `cmd` CLI. | |
| 78 | +| **Laguna S 2.1 free** | 256k context, reasoning, $0 while the deal lasts. | |
| 79 | +| **Go-plan auth** | Browser OAuth like `cmd login` ($1/mo). Syncs `~/.commandcode/auth.json`. No API key. | |
| 80 | +| **Agent-grade tools** | OpenCode tool calls park and resume; MCP-prefixed tools are tracked separately. | |
| 81 | +| **Attachments** | Images, PDFs, text/binary files from OpenCode. Text-only models get image placeholders (Command Code behavior). | |
| 82 | +| **Compact** | Context-fraction tips + tiered client compact before the 256k window overflows. | |
| 83 | +| **Usage** | Per-turn and session totals via SSE `usage` + `GET /v1/usage`. | |
| 84 | + |
| 85 | +## Architecture |
| 86 | + |
| 87 | +```text |
| 88 | +OpenCode |
| 89 | + └─ /v1/chat/completions |
| 90 | + └─ Bun.serve proxy (port 8797) |
| 91 | + └─ POST https://api.commandcode.ai/alpha/generate |
| 92 | + └─ poolside/laguna-s-2.1-free (default) |
| 93 | +``` |
| 94 | + |
| 95 | +## Requirements |
| 96 | + |
| 97 | +- [OpenCode](https://opencode.ai) |
| 98 | +- [Command Code CLI](https://www.npmjs.com/package/command-code) (`npm i -g command-code@latest`) and a free account |
| 99 | +- Bun (plugin runtime) · Node.js ≥ 18 (CLI needs ≥ 22) |
| 100 | + |
| 101 | +## Development |
| 102 | + |
| 103 | +```bash |
| 104 | +bun install |
| 105 | +bun run build |
| 106 | +bun run test # mocked gateway — attachments, tools, compact, usage |
| 107 | +bun run test:live # live Laguna S 2.1 (needs `cmd login` / Go plan session) |
| 108 | +``` |
| 109 | + |
| 110 | +Debug: `OPENCODE_COMMANDCODE_DEBUG=1`. |
| 111 | + |
| 112 | +Optional knobs: |
| 113 | + |
| 114 | +- `OPENCODE_COMMANDCODE_PROXY_PORT` — fixed local proxy port (default `8797`) |
| 115 | +- `OPENCODE_COMMANDCODE_CWD` — working directory reported to the gateway |
| 116 | +- `COMMANDCODE_API_URL` — override API base (default `https://api.commandcode.ai`) |
| 117 | + |
| 118 | +## License |
| 119 | + |
| 120 | +[MIT](LICENSE) |
0 commit comments