diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -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 diff --git a/.idea/material_theme_project_new.xml b/.idea/material_theme_project_new.xml new file mode 100644 index 0000000..dcca0e3 --- /dev/null +++ b/.idea/material_theme_project_new.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..19667bb --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/opencode-cursor-agent.iml b/.idea/opencode-cursor-agent.iml new file mode 100644 index 0000000..5e764c4 --- /dev/null +++ b/.idea/opencode-cursor-agent.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/README.md b/README.md index 24d037d..da16702 100644 --- a/README.md +++ b/README.md @@ -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 Code(Docker 模式) - ```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