dsh-jj — Jujutsu 版本控制 MCP stdio 服务器

DeepSeek Harness(DSH)遵循「一切皆插件」的理念。在智能体开发中,处理版本控制往往受限于 git 的语义。本插件通过一个零依赖的 MCP stdio server 将本机 jj CLI 暴露为 mcp__jj__* 工具,让模型在 jj 仓库中使用 jj 的语义执行版本控制操作。

前置条件

  • jj 版本 ≥ 0.2x(可通过 brew install jujutsu 安装,或参考 官方文档)。
  • Node.js ≥ 18(服务器仅使用标准库,无额外依赖)。

安装与启用

通过官方目录添加 bundle:

dsh plugin --profile web add github:LosEcher/dsh-jj#main

本地开发或修改源码时:

dsh plugin --profile web add link:/path/to/dsh-jj

新 bundle 安装后必须重启 dsh web(HMR 通常不覆盖配置变更):

~/.dsh/scripts/dsh-web-restart.sh

配置注意事项

bundle patch 中使用 command: jj-mcp(包的 bin 入口)。若 dsh 进程的 PATH 不含 node_modules/.bin 目录(常见于 launchd 托管场景),MCP 服务启动会失败。此时需要在用户 patch 层覆盖为绝对路径:

- id: mcp-jj
  config:
    serverName: jj
    transport: stdio
    command: node
    args: ['/absolute/path/to/dsh-jj/server.mjs']
    env:
      JJ_MCP_BIN: '/path/to/jj'
    failOnStartupError: false
    toolCallTimeoutMs: 120000

核心功能

插件将 jj 的常用操作封装为 mcp__jj__* 工具,所有工具均支持可选的 repo 参数。

工具 作用
jj_status 获取当前 change 摘要及工作区改动
jj_log 查看变更图(替代 git log)
jj_diff 查看指定 change 的 diff
jj_describe 设置或更新 change 描述
jj_new 开启新的空 change
jj_commit 封存当前 change 并开启新 change
jj_edit 跳转至已有 change 继续编辑
jj_abandon 丢弃 change(可 undo)
jj_undo 撤销上一次 jj 操作
jj_rebase 将 change 移动到新的父节点
jj_fetch 拉取远程分支到 bookmark
jj_push 推送 bookmark 到远程
jj_bookmark 管理 bookmark(如 git 分支)
jj_run 通用透传(需注意安全限制)

安全设计:
* 所有工具通过 spawn 数组参数调用 jj,无 shell 介入,参数注入免疫。
* jj_run 工具会过滤 --config / --config-toml / --config-file 参数,防止通过配置项执行任意命令。
* jj 本身支持 jj undo / jj op restore,破坏性操作风险较低。

环境变量

变量 默认值 说明
JJ_MCP_BIN /opt/homebrew/bin/jj 或 jj jj 二进制路径,自动探测失败时需手动配置
JJ_MCP_TIMEOUT_MS 60000 单次调用超时时间
JJ_MCP_DEFAULT_REPO 空 默认仓库目录
JJ_MCP_LOG 1 0 可关闭 stderr 启动横幅

独立使用

该 server 是标准 MCP stdio server,也可直接用于 Claude Code 或 Codex:

npx -y jj-mcp

总结

该插件适用于需要在 DeepSeek Harness 中使用 Jujutsu 进行版本控制的场景。它将 jj 的原生语义映射为 MCP 工具,避免了模型使用 git 思维硬套 jj 操作。安装后需重启 dsh web,若运行环境特殊(如 launchd),需注意 PATH 配置。

  • 目录页:https://www.skillhub.cn/plugins/LosEcher/dsh-jj
  • GitHub 仓库:https://github.com/LosEcher/dsh-jj
羽毛球分组比赛记分
小程序二维码

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

小夜