前言¶
在 DeepSeek Harness(DSH)智能体场景中,会话经常需要在指定工作区里查看 Git 状态、读取差异、暂存文件、创建提交,或处理分支和合并。dsh-tool-git 面向这类需求,把常用 Git 操作整理成 DSH 可调用的工具。
这是什么¶
dsh-tool-git 是 Huasfan 维护的 DSH 插件,许可证为 MIT。它为 DeepSeek Harness 智能体提供 9 个 Git 工具:
git_status
git_diff
git_log
git_add
git_commit
git_branch
git_show
git_restore
git_merge
所有工具都接受 workdir 参数。默认使用会话工作区,相对路径基于该目录解析。
核心功能¶
git_status 用于查看工作区状态。
git_diff 用于差异查看,默认查看未暂存差异。
git_log 用于查看提交历史。
git_add 用于暂存文件。
git_commit 用于创建提交。
git_branch 用于列出、创建、检出或删除分支。
git_show 用于查看提交,或查看指定版本中的文件。
git_restore 用于丢弃工作区变更,或取消暂存。
git_merge 用于合并分支或提交。
安装与启用¶
下面从 GitHub 安装到 web profile:
dsh plugin --profile web add github:Huasfan/dsh-tool-git
首次安装时,可能需要在 profile 的 pnpm-workspace.yaml 中添加:
allowBuilds:
dsh-tool-git: true
cordis.yml 配置示例如下:
- id: git-tool
name: dsh-tool-git
config:
gitPath: git
timeoutMs: 30000
配置项包括 gitPath 和 timeoutMs。该插件使用 Schemastery schema 描述配置,非法配置会在加载时失败。
本地开发或补丁方式可以这样使用:
dsh --profile web --patch /abs/path/to/dsh-tool-git/cordis.patch.yml
也可以直接加载 TypeScript 源文件:
name: '/abs/path/to/dsh-tool-git/src/index.ts'
适用场景与注意¶
适合需要在 DSH 智能体会话中执行 Git 状态查看、提交、分支和合并操作的开发者。
使用前注意:
- 要求
git≥ 2.23,因为涉及--porcelain=v2和git restore。 - 该插件已针对 DeepSeek Harness
0.1.0-rc.6测试。 - DSH 插件接口在 preview 阶段仍在演化;升级
dsh后应重跑pnpm test并报告问题。 - 非零 git 退出作为领域结果返回,基础设施故障抛出;超时进入
error,取消以AbortError/TOOL_ABORTED重新抛出。 - 插件使用
execFile参数数组避免 shell 注入,固定环境LC_ALL=C、GIT_TERMINAL_PROMPT=0、GIT_PAGER=cat,只读命令使用--no-optional-locks。 - 插件以当前 dsh 进程权限运行。安装前应检查源码与许可证。
结尾¶
dsh-tool-git 的价值在于把常用 Git 操作整理为 DSH 可调用的工具,方便在智能体会话中执行相关任务。仓库地址:https://github.com/Huasfan/dsh-tool-git