前言¶
在 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