add ignore
This commit is contained in:
parent
018765f97d
commit
42f85e4538
199
README.md
199
README.md
|
|
@ -15,7 +15,106 @@
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 🐳 Docker Compose 部署(推薦,跨電腦通用)
|
## 本機直接執行(pm2 模式)
|
||||||
|
|
||||||
|
### 1. 建置
|
||||||
|
### Step 1 下載 cursor cli (如果你沒有)
|
||||||
|
```bash
|
||||||
|
curl https://cursor.com/install -fsS | bash
|
||||||
|
```
|
||||||
|
### Step 2 下載 claude (如果你沒有)
|
||||||
|
windows 請參考 https://code.claude.com/docs/en/quickstart#native-install-recommended
|
||||||
|
```bash
|
||||||
|
curl -fsSL https://claude.ai/install.sh | bash
|
||||||
|
```
|
||||||
|
|
||||||
|
### Step 3 下載 proxy
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git clone https://code.30cm.net/daniel.w/opencode-cursor-agent.git
|
||||||
|
cd cursor-api-proxy-go
|
||||||
|
go build -o cursor-api-proxy .
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. 登入 Cursor 帳號
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./cursor-api-proxy login myaccount
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3. 啟動伺服器
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 用 pm2 背景執行
|
||||||
|
make env PORT=8766 API_KEY=mysecret
|
||||||
|
make pm2
|
||||||
|
```
|
||||||
|
|
||||||
|
### 4. 設定 Claude Code
|
||||||
|
|
||||||
|
```bash
|
||||||
|
make claude-settings PORT=8766
|
||||||
|
make claude-onboarding
|
||||||
|
claude
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
### 切換模型
|
||||||
|
|
||||||
|
在 Claude Code 中輸入 `/model`,即可看到你 Cursor CLI 支援的所有模型。
|
||||||
|
|
||||||
|
代理會自動將 Cursor 模型 ID 轉換為 `claude-*` 格式:
|
||||||
|
|
||||||
|
| Cursor CLI 模型 | Claude Code 看到的 |
|
||||||
|
|---|---|
|
||||||
|
| `opus-4.6` | `claude-opus-4-6` |
|
||||||
|
| `sonnet-4.6` | `claude-sonnet-4-6` |
|
||||||
|
| `opus-4.5-thinking` | `claude-opus-4-5-thinking` |
|
||||||
|
| `sonnet-4.7`(未來) | `claude-sonnet-4-7`(自動生成) |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 接入 OpenCode
|
||||||
|
|
||||||
|
OpenCode 透過 `~/.config/opencode/opencode.json` 設定 provider,使用 OpenAI 相容格式。
|
||||||
|
|
||||||
|
1. 啟動代理伺服器
|
||||||
|
2. 編輯 `~/.config/opencode/opencode.json`:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"provider": {
|
||||||
|
"cursor": {
|
||||||
|
"npm": "@ai-sdk/openai-compatible",
|
||||||
|
"name": "Cursor Agent",
|
||||||
|
"options": {
|
||||||
|
"baseURL": "http://127.0.0.1:8766/v1",
|
||||||
|
"apiKey": "unused"
|
||||||
|
},
|
||||||
|
"models": {
|
||||||
|
"auto": { "name": "Cursor Auto" },
|
||||||
|
"sonnet-4.6": { "name": "Sonnet 4.6" },
|
||||||
|
"opus-4.6": { "name": "Opus 4.6" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
或使用指令一次設定:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
make opencode PORT=8766
|
||||||
|
make opencode-models PORT=8766
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
以下是有點小 bug
|
||||||
|
|
||||||
|
|
||||||
|
## 🐳 Docker Compose 部署(稍微有點小問題,跨電腦通用)
|
||||||
使用 Docker Compose 可以讓代理在任何有 Docker 的電腦上一鍵啟動,**無需安裝 Go 環境**。
|
使用 Docker Compose 可以讓代理在任何有 Docker 的電腦上一鍵啟動,**無需安裝 Go 環境**。
|
||||||
> **前提**:宿主機需已安裝 Cursor CLI(`agent` 二進位檔),且已登入至少一個帳號。
|
> **前提**:宿主機需已安裝 Cursor CLI(`agent` 二進位檔),且已登入至少一個帳號。
|
||||||
|
|
||||||
|
|
@ -101,104 +200,6 @@ make claude-onboarding
|
||||||
claude
|
claude
|
||||||
```
|
```
|
||||||
|
|
||||||
## 本機直接執行(pm2 模式)
|
|
||||||
|
|
||||||
### 1. 建置
|
|
||||||
|
|
||||||
```bash
|
|
||||||
git clone https://code.30cm.net/daniel.w/opencode-cursor-agent.git
|
|
||||||
cd cursor-api-proxy-go
|
|
||||||
go build -o cursor-api-proxy .
|
|
||||||
```
|
|
||||||
|
|
||||||
### 2. 登入 Cursor 帳號
|
|
||||||
|
|
||||||
```bash
|
|
||||||
./cursor-api-proxy login myaccount
|
|
||||||
```
|
|
||||||
|
|
||||||
### 3. 啟動伺服器
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# 用 pm2 背景執行
|
|
||||||
make env PORT=8766 API_KEY=mysecret
|
|
||||||
make pm2
|
|
||||||
```
|
|
||||||
|
|
||||||
### 4. 設定 Claude Code
|
|
||||||
|
|
||||||
```bash
|
|
||||||
make claude-settings PORT=8766
|
|
||||||
make claude-onboarding
|
|
||||||
claude
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 接入 Claude Code
|
|
||||||
|
|
||||||
Claude Code 使用 Anthropic SDK,透過環境變數設定即可改用你的代理。
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# 1. 啟動代理(Docker 或 pm2,確認已在背景執行)
|
|
||||||
|
|
||||||
# 2. 設定環境變數
|
|
||||||
export ANTHROPIC_BASE_URL=http://127.0.0.1:8766
|
|
||||||
export ANTHROPIC_API_KEY=my-secret-key # 若未設定 API_KEY,填任意值
|
|
||||||
|
|
||||||
# 3. 啟動 Claude Code
|
|
||||||
claude
|
|
||||||
```
|
|
||||||
|
|
||||||
### 切換模型
|
|
||||||
|
|
||||||
在 Claude Code 中輸入 `/model`,即可看到你 Cursor CLI 支援的所有模型。
|
|
||||||
|
|
||||||
代理會自動將 Cursor 模型 ID 轉換為 `claude-*` 格式:
|
|
||||||
|
|
||||||
| Cursor CLI 模型 | Claude Code 看到的 |
|
|
||||||
|---|---|
|
|
||||||
| `opus-4.6` | `claude-opus-4-6` |
|
|
||||||
| `sonnet-4.6` | `claude-sonnet-4-6` |
|
|
||||||
| `opus-4.5-thinking` | `claude-opus-4-5-thinking` |
|
|
||||||
| `sonnet-4.7`(未來) | `claude-sonnet-4-7`(自動生成) |
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 接入 OpenCode
|
|
||||||
|
|
||||||
OpenCode 透過 `~/.config/opencode/opencode.json` 設定 provider,使用 OpenAI 相容格式。
|
|
||||||
|
|
||||||
1. 啟動代理伺服器
|
|
||||||
2. 編輯 `~/.config/opencode/opencode.json`:
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"provider": {
|
|
||||||
"cursor": {
|
|
||||||
"npm": "@ai-sdk/openai-compatible",
|
|
||||||
"name": "Cursor Agent",
|
|
||||||
"options": {
|
|
||||||
"baseURL": "http://127.0.0.1:8766/v1",
|
|
||||||
"apiKey": "unused"
|
|
||||||
},
|
|
||||||
"models": {
|
|
||||||
"auto": { "name": "Cursor Auto" },
|
|
||||||
"sonnet-4.6": { "name": "Sonnet 4.6" },
|
|
||||||
"opus-4.6": { "name": "Opus 4.6" }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
或使用指令一次設定:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
make opencode PORT=8766
|
|
||||||
make opencode-models PORT=8766
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 模型對映原理
|
## 模型對映原理
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue