Files
bruno 6ebfb24fd9 fix: Update runner Docker socket configuration and Gitea instance URL
- Changed docker-compose.yml to mount OrbStack Docker socket path (/Users/brunogao/.orbstack/run/docker.sock)
- Updated GITEA_INSTANCE_URL to use 192.168.1.83:33000 instead of gitea:3000 for proper DNS resolution
- Both runner-docker and runner-k8s now correctly point to OrbStack Docker daemon
- This resolves the 'Cannot connect to the Docker daemon' error and DNS resolution failures
2025-11-13 17:59:28 +08:00
..

Cursor AI 配置工具

通过 cursor-agent 调用 OpenRouter API 的完整解决方案。

快速开始

使用 OpenRouter API

./cursor-agent.sh openrouter

或

./cursor-agent.sh cloud

使用本地 Ollama

./cursor-agent.sh local

或

./cursor-agent.sh ollama

配置说明

统一配置文件

所有配置变量统一在 config.sh 中管理,避免重复定义:

  • OPENROUTER_KEY: OpenRouter API Key
  • LOCAL_API: 本地 Ollama API 地址
  • CLOUD_API: OpenRouter API 地址
  • LOCAL_MODEL: 本地模型名称
  • CLOUD_MODEL: 云端模型名称

修改 API Key

编辑 config.sh 文件,修改 OPENROUTER_KEY 变量:

OPENROUTER_KEY="sk-or-v1-your-api-key-here"

工具说明

cursor-agent.sh

主要工具 - 通过环境变量配置并启动 Cursor:

  • 自动设置 OPENAI_API_KEY 和 OPENAI_API_BASE 环境变量
  • 支持 OpenRouter 和本地 Ollama 两种模式
  • 自动检查并启动 Ollama 服务(本地模式)

使用方法:

./cursor-agent.sh openrouter  # 使用 OpenRouter
./cursor-agent.sh local       # 使用本地 Ollama

cursor-model-switch.sh

模型切换工具 - 快速切换 Cursor 使用的模型来源:

./cursor-model-switch.sh cloud  # 切换到 OpenRouter
./cursor-model-switch.sh local  # 切换到本地 Ollama

cursor-openrouter-proxy.sh

OpenRouter 代理服务器 - 通过本地代理转发请求到 OpenRouter(实验性):

./cursor-openrouter-proxy.sh start   # 启动代理并打开 Cursor
./cursor-openrouter-proxy.sh stop    # 停止代理服务
./cursor-openrouter-proxy.sh restart # 重启代理服务
./cursor-openrouter-proxy.sh status  # 查看代理状态

注意:由于 Cursor 在应用层面检查订阅状态,此方案可能仍会被拦截。

git-proxy-fix.sh

Git 代理管理工具:

./git-proxy-fix.sh on   # 开启代理
./git-proxy-fix.sh off  # 关闭代理
./git-proxy-fix.sh      # 自动检测并修复

工作原理

Cursor 通过环境变量 OPENAI_API_KEY 和 OPENAI_API_BASE 来配置 API 连接:

  • OpenRouter 模式: 设置 OPENAI_API_KEY 为 OpenRouter API Key,OPENAI_API_BASE 为 https://openrouter.ai/api/v1,模型为 anthropic/claude-4.5-sonnet
  • 本地模式: 设置 OPENAI_API_KEY 为 ollama,OPENAI_API_BASE 为 http://localhost:11434/v1

cursor-agent.sh 脚本会:

  1. 设置环境变量并通过 launchctl setenv 设置系统级环境变量
  2. 在启动 Cursor 时传递环境变量,确保 Cursor 使用正确的 API 配置

免费用户使用 Claude 4.5

即使你是 Cursor 免费用户,通过 OpenRouter API 仍然可以访问 Claude 4.5:

  • Cursor 免费版限制:只能使用 GPT 4.1 或 Auto
  • 通过 OpenRouter:可以使用任何 OpenRouter 支持的模型(包括 Claude 4.5)
  • 使用方法:运行 ./cursor-agent.sh openrouter 即可通过 OpenRouter API 使用 Claude 4.5

注意事项

  1. 首次使用前请修改 config.sh 中的 OPENROUTER_KEY 为你的实际 API Key
  2. 使用本地模式前确保已安装并运行 Ollama
  3. 所有脚本需要执行权限,已自动设置