用 Cursor 模型接入 DeepSeek Harness

前言

DeepSeek Harness(DSH)采用「一切皆插件」的理念,通过插件扩展能力。在本地开发或使用 DeepSeek Desktop 时,如果希望用 Cursor 的模型作为 LLM 提供方,就需要一个把 Cursor 接入 DSH 的插件。cursor-to-dsh 正是为此设计,它通过官方 @cursor/sdk 把 Cursor 注册为 DSH 的 cursor 提供方,让 DSH 继续管理 agent 循环、工具和权限,Cursor 只作为模型层。

这是什么

cursor-to-dsh 是 DeepSeek Harness 的一个插件,由维护者 lukeinx 开发,分类为「模型推理」。它把 Cursor 的模型能力以 cursor 提供方的形式挂载到 DSH,每个 DSH 会话对应一个 Cursor agent。插件通过 DSH 的 ctx.llm.registerAdapter 注册,不改动宿主代码,也不依赖 Cursor IDE 的登录态。插件使用官方 @cursor/sdk 和你自己的 Cursor API Key,对 Cursor 私有协议进行逆向,也不读取登录态。

核心功能

  • 官方接口:只用 Cursor 官方 @cursor/sdk 和你的 API Key,通过 DSH 的 ctx.llm.registerAdapter 注册,不改宿主代码。
  • 工具归 DSH:Cursor 内置工具全部关闭,读写文件、执行命令都由 DSH 执行,沿用 DSH 的沙箱和审批。
  • 缓存复用:每个 DSH 会话对应一个 Cursor agent,只发送新增内容;工具结果回填到同一个 run 继续。
  • 模型与用量:模型和推理强度来自 Cursor 实时目录,始终 fast=false;按 DSH 互不重叠的用量桶上报,不误报超限。
  • 图片:用户消息和工具结果里的图片转给 Cursor。

安装与启用

前置条件:DSH 0.2.0-rc.2 及以上(DeepSeek Desktop 内置 0.2.1-rc.2)。

  • CLI 或其他 profile:
dsh plugin --profile <名称> add cursor-to-dsh
  • DeepSeek Desktop:

desktop profile 由 Desktop 独占,dsh plugin add 会报 managed exclusively by the Electron application,需要手动修改 ~/.dsh/profiles/desktop/package.json:

  1. 完全退出 DeepSeek Harness Desktop。
  2. 在 ~/.dsh/profiles/desktop/package.json 里追加两处,已有条目不动:
{
  "dependencies": { "cursor-to-dsh": "^0.1.1" },
  "dsh": { "profile": { "bundles": ["…已有条目…", "cursor-to-dsh"] } }
}
  1. 用 Desktop 自带的 pnpm 安装,然后启动:
cd ~/.dsh/profiles/desktop
node "/Applications/DeepSeek Harness.app/Contents/Resources/runtime/primary-runtime/dependencies/pnpm/bin/pnpm.mjs" install
open -a "DeepSeek Harness"

升级:改版本号后重复第 3 步。

配置 API Key

在 cursor.com/dashboard → API Keys → New API Key 创建(个人 key 或 service account key,不支持 Team Admin key)。

Desktop 的「模型」设置页不能给第三方插件填 key,推荐写进 ~/.dsh/.credentials.yaml(权限 0600,热加载);文件已存在时只在 refs: 下加一行:

version: 1
refs:
  CURSOR_API_KEY: <你的 key>

查找顺序:凭据文件 → 环境变量 CURSOR_API_KEY → 插件配置 apiKey。

验证与典型用法

在「设置 → 模型」里出现 Cursor,模型选择里有 cursor 下的模型即成功。也可以把 agent-default-model 设为 provider: cursor。

典型用法示例(命令行):

DSH="/Applications/DeepSeek Harness.app/Contents/Resources/runtime/cli/bin/dsh"
CURSOR_API_KEY=... DSH_CURSOR_DEBUG=1 "$DSH" --profile headless --json "Read README.md and summarize it in one line"

调试日志里工具结果回填那次应显示 plan=results,多轮对话的第二轮应显示 plan=send。

配置项与环境变量

默认不用配。需要时在 profile 的 cordis.patch.yml 覆盖插件这一行(patch 会替换整个 config,要写全):

- id: llm-cursor
  name: cursor-to-dsh
  config:
    apiKeyEnv: CURSOR_API_KEY
    context: min
配置项 默认值 环境变量覆盖 含义
apiKeyEnv CURSOR_API_KEY 存 key 的凭据名 / 环境变量名
apiKey 无 明文 key,不推荐
context min DSH_CURSOR_CONTEXT 上下文档位:min、max 或如 300k;被拒时自动降档
cwd 会话工作目录 DSH_CURSOR_CWD Cursor agent 的工作目录

其他环境变量:

  • DSH_CURSOR_DEBUG=1:输出调试日志到 stderr。
  • DSH_CURSOR_PREWARM=0:关闭预热(插件加载后在后台预建一次 agent,省掉 Cursor SDK 首次约 8 秒的初始化)。

已知限制

  • 文件附件、已卸载(offloaded)或读不出的图片不转给 Cursor,只留占位说明;重放历史时只带最后一条用户消息的图片。
  • 工具交接期间不报用量,上下文用量在 run 结束时更新。
  • 不支持 stop(报 UNSUPPORTED_OPTION);temperature、maxTokens 被忽略。

开发与调试

本地开发时,先安装依赖并构建:

npm install && npm run build   # DSH 加载的是 lib/,改源码后要重新 build 并重启 DSH
npm test                       # 假 Cursor agent 的单测
npm run check                  # 类型检查
npm run check:public           # 推 GitHub / 发 npm 前:不含内网链接和本机路径
CURSOR_API_KEY=... node --experimental-strip-types scripts/live.ts [模型 id]   # 真实 Cursor 实测

本地源码接入 Desktop:安装第 2 步的依赖写成 "cursor-to-dsh": "link:<仓库绝对路径>"。

适用场景与注意

适合希望在 DSH 或 DeepSeek Desktop 中使用 Cursor 模型,并希望由 DSH 统一管理工具和权限的用户。插件以当前 dsh 进程的权限运行,安装前应检查源码与许可证(MIT)。目录页与 GitHub 仓库提供更多信息。

短结尾

通过 cursor-to-dsh,你可以把 Cursor 的模型接入 DeepSeek Harness,同时保留 DSH 对 agent 循环、工具和权限的控制。目录页:https://www.skillhub.cn/plugins/lukeinx/cursor-to-dsh;GitHub:https://github.com/lukeinx/cursor-to-dsh。

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye