|
9 | 9 | </p> |
10 | 10 |
|
11 | 11 | <p align="center"> |
12 | | - <a href="https://nomadcxx.github.io/opencode-cursor/">Documentation</a> |
| 12 | + <a href="https://nomadcxx.github.io/opencode-cursor/docs/">Documentation</a> |
13 | 13 | </p> |
14 | 14 |
|
| 15 | +`open-cursor` connects OpenCode to the models available through your Cursor |
| 16 | +subscription. It translates prompts, streaming responses, thinking, and tool |
| 17 | +calls between OpenCode and `cursor-agent`. |
| 18 | + |
15 | 19 | ## Installation |
16 | 20 |
|
17 | | -### Option A — npm global + install |
| 21 | +You need OpenCode, a Cursor subscription, and the `cursor-agent` command. |
| 22 | + |
| 23 | +Install the package and configure OpenCode: |
18 | 24 |
|
19 | 25 | ```bash |
20 | 26 | npm install -g @rama_nigg/open-cursor |
21 | 27 | open-cursor install |
22 | 28 | ``` |
23 | 29 |
|
24 | | -`open-cursor install` writes OpenCode config. It does not touch `.cursor` by default. The runtime bridge is built into the plugin. |
| 30 | +Authenticate and verify the provider: |
25 | 31 |
|
26 | | -Optional: `open-cursor install --install-cursor-bridge` also writes `.cursor/hooks.json`, `.cursor/hooks/opencode-bridge-context.mjs`, and `.cursor/rules/opencode-bridge.mdc`. Use `--cursor-bridge-scope user` to write under `~/.cursor` instead. |
27 | | - |
28 | | -Then authenticate and verify: |
29 | 32 | ```bash |
30 | 33 | cursor-agent login |
31 | 34 | opencode models | grep cursor-acp |
32 | 35 | ``` |
33 | 36 |
|
34 | | -Upgrade: `npm update -g @rama_nigg/open-cursor`, then restart opencode so it loads the new plugin process. |
35 | | - |
36 | | -<details> |
37 | | -<summary><b>Option B</b> — shell installer</summary> |
38 | | - |
39 | | -**Linux & macOS:** |
40 | | - |
41 | | -```bash |
42 | | -curl -fsSL https://raw.githubusercontent.com/Nomadcxx/opencode-cursor/main/install.sh | bash |
43 | | -``` |
44 | | - |
45 | | -The shell installer prefers the npm package. If npm is not available, it falls back to the Go TUI or a shell-only path. The default path writes OpenCode config only. |
46 | | - |
47 | | -</details> |
48 | | - |
49 | | -<details> |
50 | | -<summary><b>Option C</b> — Add to opencode.json</summary> |
51 | | - |
52 | | -Add to `~/.config/opencode/opencode.json` (or `%USERPROFILE%\.config\opencode\opencode.json` on Windows): |
53 | | - |
54 | | -```json |
55 | | -{ |
56 | | - "plugin": ["@rama_nigg/open-cursor@latest"], |
57 | | - "provider": { |
58 | | - "cursor-acp": { |
59 | | - "name": "Cursor ACP", |
60 | | - "npm": "@ai-sdk/openai-compatible", |
61 | | - "options": { |
62 | | - "baseURL": "http://127.0.0.1:32124/v1" |
63 | | - }, |
64 | | - "models": { |
65 | | - "cursor-acp/auto": { "name": "Auto" } |
66 | | - } |
67 | | - } |
68 | | - } |
69 | | -} |
70 | | -``` |
71 | | - |
72 | | -Manual config does not install the optional Cursor bridge hook and rule. Run Option A with `--install-cursor-bridge` from a workspace if you want those files. |
73 | | - |
74 | | -> **Refresh models anytime** with the bundled CLI: |
75 | | -> ```bash |
76 | | -> open-cursor sync-models # plain list |
77 | | -> open-cursor sync-models --variants --compact # group thinking / fast / -low/-high variants under each base |
78 | | -> ``` |
79 | | -> The `--variants --compact` form folds dozens of `*-thinking-fast`, `*-high-fast`, etc. into a single entry per family with a `variants` map, and includes `cost` from the Cursor pricing table so OpenCode TokenSpeed can render usage correctly. |
80 | | -</details> |
81 | | -
|
82 | | -<details> |
83 | | -<summary><b>Option D</b> — Go TUI installer</summary> |
84 | | -
|
85 | | -```bash |
86 | | -git clone https://github.com/Nomadcxx/opencode-cursor.git |
87 | | -cd opencode-cursor |
88 | | -go build -o ./installer ./cmd/installer && ./installer |
89 | | -``` |
90 | | -
|
91 | | -The TUI writes OpenCode config. Use `./installer --install-cursor-bridge` only if you want the optional `.cursor` hook and rule. |
92 | | -</details> |
| 37 | +The final command should list `cursor-acp/auto`. The installer backs up your |
| 38 | +existing OpenCode configuration before writing it and does not touch `.cursor` |
| 39 | +by default. |
93 | 40 |
|
94 | | -<details> |
95 | | -<summary><b>Option E</b> — LLM paste</summary> |
96 | | - |
97 | | -``` |
98 | | -Install open-cursor for opencode: run `npm install -g @rama_nigg/open-cursor`, then run `open-cursor install` from the workspace so it writes opencode config. Auth with `cursor-agent login`. Verify with `opencode models | grep cursor-acp`. If you want the optional cursor hook/rule fallback, run `open-cursor install --install-cursor-bridge`. |
99 | | -``` |
100 | | -</details> |
| 41 | +For shell, manual, and source installation, see the |
| 42 | +[installation guide](https://nomadcxx.github.io/opencode-cursor/docs/getting-started/installation/). |
101 | 43 |
|
102 | | -<details> |
103 | | -<summary><b>Option F</b> — Development (from source)</summary> |
104 | | - |
105 | | -```bash |
106 | | -git clone https://github.com/Nomadcxx/opencode-cursor.git |
107 | | -cd opencode-cursor |
108 | | -./scripts/install-plugin.sh |
109 | | -``` |
110 | | - |
111 | | -Verify: `opencode models | grep cursor-acp` |
112 | | -</details> |
113 | | - |
114 | | -## Authentication |
115 | | - |
116 | | -Most users: |
117 | | -```bash |
118 | | -cursor-agent login |
119 | | -``` |
120 | | - |
121 | | -Or via OpenCode: |
122 | | -```bash |
123 | | -opencode auth login --provider cursor-acp |
124 | | -``` |
125 | | - |
126 | | -<details> |
127 | | -<summary><b>SDK backend auth</b> (only if using <code>CURSOR_ACP_BACKEND=sdk</code> or SDK fallback)</summary> |
128 | | - |
129 | | -Set a real Cursor API key from [cursor.com/settings](https://cursor.com/settings): |
130 | | - |
131 | | -```bash |
132 | | -export CURSOR_API_KEY=<your-api-key> |
133 | | -``` |
134 | | - |
135 | | -Other supported methods (priority order): OpenCode auth store (`opencode auth login --provider cursor-acp`), or `apiKey` in the `cursor-acp` provider options in `opencode.json`. |
136 | | - |
137 | | -Do not use the historical `cursor-agent` placeholder string as an SDK key. |
138 | | -</details> |
| 44 | +Upgrade with `npm update -g @rama_nigg/open-cursor`, then restart OpenCode. |
139 | 45 |
|
140 | 46 | ## Usage |
141 | 47 |
|
142 | | -```bash |
143 | | -opencode run "your prompt" --model cursor-acp/auto |
144 | | -opencode run "your prompt" --model cursor-acp/sonnet-4.5 |
145 | | -``` |
146 | | - |
147 | | -## MCP Tool Bridge |
148 | | - |
149 | | -Any MCP servers already configured in your `opencode.json` work automatically with cursor-acp models — no extra setup needed. The plugin discovers them at startup and injects usage instructions into the system prompt so the model calls them via cursor-agent's Shell tool. |
150 | | - |
151 | | -`mcptool` is a shell CLI, so opencode applies your `bash` permission rules to `mcptool call ...`. If you rely on MCP tools asking for confirmation, keep `bash` as `ask` or add explicit `ask`/`deny` rules for `mcptool call *`. |
| 48 | +Run a prompt with automatic model selection: |
152 | 49 |
|
153 | 50 | ```bash |
154 | | -mcptool servers # list discovered servers |
155 | | -mcptool tools [server] # list available tools |
156 | | -mcptool call hybrid-memory memory_stats # call a tool manually |
157 | | -mcptool call playwright browser_navigate '{"url":"https://example.com"}' |
158 | | -``` |
159 | | - |
160 | | -Any MCP server using stdio transport works. Tested with hybrid-memory, @modelcontextprotocol/server-filesystem, @playwright/mcp, and @modelcontextprotocol/server-everything. |
161 | | - |
162 | | -## Architecture |
163 | | - |
164 | | -```mermaid |
165 | | -flowchart TB |
166 | | - OPEN["OpenCode<br/>messages + tools"] |
167 | | - PROXY["open-cursor proxy :32124<br/>prompt + backend selection"] |
168 | | - AGENT["cursor-agent<br/>default · per request"] |
169 | | - SDK["Cursor SDK runner<br/>optional fallback"] |
170 | | - API["Cursor API"] |
171 | | - BOUNDARY["Provider boundary<br/>stream-json → SSE<br/>schema + loop guards"] |
172 | | - TEXT["OpenCode renders<br/>assistant + thinking"] |
173 | | - TOOLS["OpenCode executes tool<br/>result enters next request ↺"] |
174 | | -
|
175 | | - OPEN -->|"@ai-sdk/openai-compatible"| PROXY |
176 | | - PROXY -->|"default"| AGENT |
177 | | - PROXY -. "API-key fallback" .-> SDK |
178 | | - AGENT -->|"HTTPS"| API |
179 | | - SDK -. "HTTPS" .-> API |
180 | | - API --> BOUNDARY |
181 | | - BOUNDARY -->|"text / thinking"| TEXT |
182 | | - BOUNDARY -->|"tool_call"| TOOLS |
183 | | -
|
184 | | - classDef host fill:#161b22,stroke:#8b949e,color:#f0f6fc,stroke-width:2px |
185 | | - classDef bridge fill:#172f4d,stroke:#8b949e,color:#f0f6fc,stroke-width:2px |
186 | | - classDef cursorAgent fill:#e3b341,stroke:#8b949e,color:#111820,stroke-width:2px |
187 | | - classDef cursorApi fill:#f2cc60,stroke:#8b949e,color:#111820,stroke-width:2px |
188 | | - classDef optional fill:#21262d,stroke:#8b949e,color:#c9d1d9,stroke-width:2px,stroke-dasharray:5 5 |
189 | | - classDef tool fill:#161b22,stroke:#8b949e,color:#f0f6fc,stroke-width:2px |
190 | | - class OPEN,TEXT host |
191 | | - class PROXY,BOUNDARY bridge |
192 | | - class AGENT cursorAgent |
193 | | - class API cursorApi |
194 | | - class SDK optional |
195 | | - class TOOLS tool |
| 51 | +opencode run "Summarise this repository in five bullets." \ |
| 52 | + --model cursor-acp/auto |
196 | 53 | ``` |
197 | 54 |
|
198 | | -<details> |
199 | | -<summary><b>How the proxy works</b></summary> |
200 | | - |
201 | | -The proxy uses a dual-backend runtime. In `auto` mode (default) it prefers the `cursor-agent` binary when available. If `cursor-agent` is unavailable and a real Cursor API key is configured, or if `CURSOR_ACP_BACKEND=sdk` is set, a persistent Node.js child process (`scripts/sdk-runner.mjs`) runs `@cursor/sdk` on behalf of the proxy. |
202 | | - |
203 | | -By default, the SDK Agent runs in isolated mode (`settingSources: []`). To load Cursor environment settings in SDK mode, set `CURSOR_ACP_SETTING_SOURCES=all`. |
204 | | - |
205 | | -Default tool-loop mode: `CURSOR_ACP_TOOL_LOOP_MODE=opencode`. Details: [docs/architecture/runtime-tool-loop.md](docs/architecture/runtime-tool-loop.md). |
206 | | - |
207 | | -Startup model refresh is additive by default. Use `CURSOR_ACP_MODEL_AUTO_REFRESH=false` to disable it, or `CURSOR_ACP_MODEL_AUTO_REFRESH=compact` to fold Cursor model variants into opencode variants. |
208 | | -</details> |
209 | | - |
210 | | -## Troubleshooting |
| 55 | +You can also start `opencode` and choose a `cursor-acp/*` model from its model |
| 56 | +picker. |
211 | 57 |
|
212 | | -- `fetch() URL is invalid` or auth errors → `cursor-agent login` or `opencode auth login --provider cursor-acp` |
213 | | -- `CURSOR_API_KEY not set` in SDK mode → set a real API key from [cursor.com/settings](https://cursor.com/settings), or use `CURSOR_ACP_BACKEND=auto` with a working `cursor-agent` |
214 | | -- `SchemaError(Missing key at ["oldString"])` or `["filePath"]` during Composer file writes → update `@rama_nigg/open-cursor`, then restart opencode and cursor-agent so stale processes cannot keep the old tool schema |
215 | | -- Model not responding → verify your API key/quota |
216 | | -- Quota exceeded → [cursor.com/settings](https://cursor.com/settings) |
217 | | -- Proxy not starting → ensure port 32124 is available |
| 58 | +## Documentation |
218 | 59 |
|
219 | | -Debug logging: `CURSOR_ACP_LOG_LEVEL=debug opencode` for TUI use, or `CURSOR_ACP_LOG_LEVEL=debug opencode run "your prompt" --model cursor-acp/auto` |
| 60 | +- [Installation](https://nomadcxx.github.io/opencode-cursor/docs/getting-started/installation/) |
| 61 | +- [Authentication](https://nomadcxx.github.io/opencode-cursor/docs/getting-started/authentication/) |
| 62 | +- [Configuration](https://nomadcxx.github.io/opencode-cursor/docs/reference/configuration/) |
| 63 | +- [Choosing a model](https://nomadcxx.github.io/opencode-cursor/docs/guides/choosing-a-model/) |
| 64 | +- [MCP servers](https://nomadcxx.github.io/opencode-cursor/docs/guides/mcp-servers/) |
| 65 | +- [Troubleshooting](https://nomadcxx.github.io/opencode-cursor/docs/getting-started/troubleshooting/) |
| 66 | +- [Architecture](https://nomadcxx.github.io/opencode-cursor/docs/architecture/overview/) |
| 67 | +- [Development](https://nomadcxx.github.io/opencode-cursor/docs/development/building/) |
220 | 68 |
|
221 | 69 | ## License |
222 | 70 |
|
|
0 commit comments