first commit

This commit is contained in:
王性驊 2026-04-01 21:36:55 +08:00
parent 663b2f4c63
commit 10ac210f10
6 changed files with 64 additions and 30 deletions

8
.idea/.gitignore vendored Normal file
View File

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="MaterialThemeProjectNewConfig">
<option name="metadata">
<MTProjectMetadataState>
<option name="migrated" value="true" />
<option name="pristineConfig" value="false" />
<option name="userId" value="-31530129:19584ea2536:-7ff9" />
</MTProjectMetadataState>
</option>
</component>
</project>

8
.idea/modules.xml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/opencode-cursor-agent.iml" filepath="$PROJECT_DIR$/.idea/opencode-cursor-agent.iml" />
</modules>
</component>
</project>

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="Go" enabled="true" />
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

6
.idea/vcs.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

View File

@ -1,4 +1,4 @@
# Cursor API Proxy
# Total Cursor API Proxy (偷偷代理)
一個讓你可以透過標準 OpenAI/Anthropic API 格式存取 Cursor AI 編輯器的代理伺服器。
@ -16,16 +16,24 @@
---
## 🐳 Docker Compose 部署(推薦,跨電腦通用)
使用 Docker Compose 可以讓代理在任何有 Docker 的電腦上一鍵啟動,**無需安裝 Go 環境**。
> **前提**:宿主機需已安裝 Cursor CLI`agent` 二進位檔),且已登入至少一個帳號。
### 快速開始(三步驟)
### 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
# 1. Clone 專案
git clone https://github.com/your-repo/cursor-api-proxy-go.git
git clone https://code.30cm.net/daniel.w/opencode-cursor-agent.git
cd cursor-api-proxy-go
# 2. 建立並編輯 .env首次執行會提示你先填寫設定
@ -48,13 +56,14 @@ curl http://localhost:8766/health
### .env 關鍵設定
| 變數 | 說明 | 範例 |
|------|------|------|
| 變數 | 說明 | 範例 |
|------|--------------------------------|------|
| `CURSOR_AGENT_HOST_BIN` | 宿主機 Cursor agent 二進位檔的**完整路徑** | `/usr/local/bin/agent` |
| `CURSOR_ACCOUNTS_DIR` | 宿主機帳號資料目錄 | `~/.cursor-api-proxy` |
| `WORKSPACE_DIR` | 要掛載進容器的工作區目錄 | `/home/user/projects` |
| `CURSOR_BRIDGE_PORT` | 監聽連接埠(預設 8766 | `8766` |
| `CURSOR_BRIDGE_API_KEY` | API 鑑別金鑰(選用,建議設定) | `my-secret-key` |
| `CURSOR_ACCOUNTS_DIR` | 宿主機帳號資料目錄 | `~/.cursor-api-proxy` |
| `WORKSPACE_DIR` | 要掛載進容器的工作區目錄 | `/home/user/projects` |
| `CURSOR_BRIDGE_PORT` | 監聽連接埠(預設 8766 | `8766` |
| `CURSOR_BRIDGE_API_KEY` | API 鑑別金鑰(選用,建議設定) | `my-secret-key` |
| `CURSOR_BRIDGE_TIMEOUT_MS` | 超時建議必選,否則可能用到一半被截斷 | `3600000` |
### 尋找 Cursor agent 路徑
@ -80,7 +89,6 @@ make docker-shell # 進入容器 shell除錯用
```
### 接入 Claude CodeDocker 模式)
```bash
# 代理啟動後,設定 Claude Code 使用代理
export ANTHROPIC_BASE_URL=http://localhost:8766
@ -93,26 +101,12 @@ make claude-onboarding
claude
```
### 在其他電腦(或同區網)使用
1. 在一台電腦上啟動 Docker Compose`CURSOR_BRIDGE_HOST=0.0.0.0`
2. 確認 `CURSOR_BRIDGE_PORT` 防火牆已開放
3. 其他電腦將 `ANTHROPIC_BASE_URL` 指向這台的 IP
```bash
export ANTHROPIC_BASE_URL=http://192.168.1.100:8766
export ANTHROPIC_API_KEY=my-secret-key
claude
```
---
## 本機直接執行pm2 模式)
### 1. 建置
```bash
git clone https://github.com/your-repo/cursor-api-proxy-go.git
git clone https://code.30cm.net/daniel.w/opencode-cursor-agent.git
cd cursor-api-proxy-go
go build -o cursor-api-proxy .
```
@ -126,9 +120,6 @@ go build -o cursor-api-proxy .
### 3. 啟動伺服器
```bash
# 直接執行(前景)
./cursor-api-proxy
# 用 pm2 背景執行
make env PORT=8766 API_KEY=mysecret
make pm2