opencode-cursor-agent/README.md

153 lines
2.0 KiB
Markdown
Raw Normal View History

2026-04-01 14:15:55 +00:00
# Cursor API Proxy (整理版)
2026-03-30 14:09:15 +00:00
2026-04-01 14:15:55 +00:00
一個代理伺服器,讓你用標準 OpenAI / Anthropic API 存取 Cursor CLI 模型。
2026-03-30 14:09:15 +00:00
2026-04-01 14:15:55 +00:00
可接入:
- Claude Code
- OpenCode
- 任何支援 OpenAI / Anthropic API 的工具
2026-04-01 00:53:34 +00:00
2026-04-01 14:15:55 +00:00
---
2026-03-30 14:09:15 +00:00
2026-04-01 14:15:55 +00:00
## 功能
2026-03-30 14:09:15 +00:00
2026-04-01 14:15:55 +00:00
- API 相容OpenAI / Anthropic
- 多帳號管理
- 模型自動對映(轉成 claude-*
- 支援區網存取0.0.0.0
- 連線池優化
2026-04-01 04:32:17 +00:00
2026-04-01 14:15:55 +00:00
---
2026-04-01 04:32:17 +00:00
2026-04-01 14:15:55 +00:00
## 快速開始(本機)
### 看幫助
2026-04-01 13:36:55 +00:00
```bash
2026-04-01 14:15:55 +00:00
make help
2026-04-01 13:36:55 +00:00
```
2026-04-01 14:15:55 +00:00
### 安裝依賴
2026-04-01 13:36:55 +00:00
```bash
2026-04-01 14:15:55 +00:00
curl https://cursor.com/install -fsS | bash
curl -fsSL https://claude.ai/install.sh | bash
2026-04-01 13:36:55 +00:00
```
2026-04-01 14:15:55 +00:00
### 下載與建置
2026-04-01 04:32:17 +00:00
2026-03-30 14:09:15 +00:00
```bash
2026-04-01 13:36:55 +00:00
git clone https://code.30cm.net/daniel.w/opencode-cursor-agent.git
2026-03-30 14:09:15 +00:00
cd cursor-api-proxy-go
go build -o cursor-api-proxy .
```
2026-04-01 14:15:55 +00:00
### 登入
2026-04-01 00:53:34 +00:00
```bash
./cursor-api-proxy login myaccount
```
2026-04-01 14:15:55 +00:00
### 啟動
2026-04-01 00:53:34 +00:00
```bash
2026-04-01 04:32:17 +00:00
make env PORT=8766 API_KEY=mysecret
make pm2
```
2026-03-30 14:09:15 +00:00
2026-04-01 14:15:55 +00:00
---
## Claude Code 設定
2026-03-30 14:09:15 +00:00
```bash
2026-04-01 04:32:17 +00:00
make claude-settings PORT=8766
make claude-onboarding
claude
2026-03-30 14:09:15 +00:00
```
2026-04-01 00:53:34 +00:00
---
2026-04-01 14:15:55 +00:00
## OpenCode 設定
2026-04-01 00:53:34 +00:00
2026-04-01 14:15:55 +00:00
編輯:
2026-04-01 00:53:34 +00:00
2026-04-01 14:15:55 +00:00
~/.config/opencode/opencode.json
2026-04-01 00:53:34 +00:00
```json
{
"provider": {
"cursor": {
"options": {
2026-04-01 14:15:55 +00:00
"baseURL": "http://127.0.0.1:8766/v1"
2026-04-01 00:53:34 +00:00
}
}
}
}
```
2026-04-01 14:12:21 +00:00
---
2026-04-01 14:15:55 +00:00
## Docker簡化版
2026-04-01 14:12:21 +00:00
```bash
make docker-setup
vim .env
make docker-setup
```
2026-04-01 14:15:55 +00:00
檢查:
2026-04-01 14:12:21 +00:00
```bash
curl http://localhost:8766/health
```
2026-04-01 14:15:55 +00:00
---
2026-04-01 14:12:21 +00:00
2026-04-01 14:15:55 +00:00
## 常用指令
2026-04-01 14:12:21 +00:00
```bash
2026-04-01 14:15:55 +00:00
make docker-up
make docker-down
make docker-logs
make docker-restart
2026-04-01 14:12:21 +00:00
```
2026-04-01 00:53:34 +00:00
---
2026-04-01 14:15:55 +00:00
## API
2026-04-01 00:53:34 +00:00
2026-04-01 14:15:55 +00:00
| 路徑 | 方法 |
|------|------|
| /v1/chat/completions | POST |
| /v1/messages | POST |
| /v1/models | GET |
| /health | GET |
2026-04-01 00:53:34 +00:00
2026-04-01 14:15:55 +00:00
---
2026-04-01 00:53:34 +00:00
2026-04-01 14:15:55 +00:00
## 環境變數(核心)
2026-04-01 00:53:34 +00:00
2026-04-01 14:15:55 +00:00
| 變數 | 預設 |
|------|------|
| CURSOR_BRIDGE_HOST | 127.0.0.1 |
| CURSOR_BRIDGE_PORT | 8766 |
| CURSOR_BRIDGE_TIMEOUT_MS | 3600000 |
2026-04-01 00:53:34 +00:00
---
2026-04-01 14:15:55 +00:00
## 帳號操作
2026-03-30 14:09:15 +00:00
```bash
./cursor-api-proxy login myaccount
./cursor-api-proxy accounts
./cursor-api-proxy logout myaccount
./cursor-api-proxy reset-hwid
```
2026-04-01 00:53:34 +00:00
---
2026-04-01 14:15:55 +00:00
## 備註
2026-03-31 01:26:33 +00:00
2026-04-01 14:15:55 +00:00
- Docker 預設開放區網0.0.0.0
- 模型自動同步
- 支援多模型切換
2026-03-30 14:09:15 +00:00
2026-04-01 00:53:34 +00:00
---