opencode-cursor-agent/README.md

103 lines
2.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Cursor API Proxy
[English](./README.md) | 繁體中文
一個讓你可以透過標準 OpenAI/Anthropic API 格式存取 Cursor AI 編輯器的代理伺服器。
## 功能特色
- **API 相容**:支援 OpenAI 格式和 Anthropic 格式的 API 呼叫
- **多帳號管理**:支援新增、移除、切換多個 Cursor 帳號
- **Tailscale 支援**:可綁定到 `0.0.0.0` 供區域網路存取
- **HWID 重置**:內建反偵測功能,可重置機器識別碼
- **連線池**:最佳化的連線管理
## 安裝
```bash
git clone https://github.com/your-repo/cursor-api-proxy-go.git
cd cursor-api-proxy-go
go build -o cursor-api-proxy .
```
## 使用方式
### 啟動伺服器
```bash
./cursor-api-proxy
```
預設監聽 `127.0.0.1:8080`
### 登入帳號
```bash
# 登入帳號
./cursor-api-proxy login myaccount
# 使用代理登入
./cursor-api-proxy login myaccount --proxy=http://127.0.0.1:7890
```
### 列出帳號
```bash
./cursor-api-proxy accounts
```
### 登出帳號
```bash
./cursor-api-proxy logout myaccount
```
### 重置 HWID反BAN
```bash
# 基本重置
./cursor-api-proxy reset-hwid
# 深度清理(清除 session 和 cookies
./cursor-api-proxy reset-hwid --deep-clean
```
### 其他選項
| 選項 | 說明 |
|------|------|
| `--tailscale` | 綁定到 `0.0.0.0` 供區域網路存取 |
| `-h, --help` | 顯示說明 |
## API 端點
| 端點 | 方法 | 說明 |
|------|------|------|
| `http://127.0.0.1:8080/v1/chat/completions` | POST | OpenAI 格式聊天完成 |
| `http://127.0.0.1:8080/v1/models` | GET | 列出可用模型 |
| `http://127.0.0.1:8080/v1/chat/messages` | POST | Anthropic 格式聊天 |
| `http://127.0.0.1:8080/health` | GET | 健康檢查 |
## 環境變數
| 變數 | 預設值 | 說明 |
|------|--------|------|
| `CURSOR_BRIDGE_HOST` | `127.0.0.1` | 監聽位址 |
| `CURSOR_BRIDGE_PORT` | `8080` | 監聽連接埠 |
| `HTTPS_PROXY` | - | HTTP 代理伺服器 |
## 常見問題
**Q: 為什麼需要登入帳號?**
A: Cursor API 需要驗證才能使用,請先登入你的 Cursor 帳號。
**Q: 如何處理被BAN的問題**
A: 使用 `reset-hwid` 命令重置機器識別碼,加上 `--deep-clean` 進行更徹底的清理。
**Q: 可以在其他設備上使用嗎?**
A: 可以,使用 `--tailscale` 選項啟動伺服器,然後透過區域網路 IP 存取。
## 授權
MIT License