@chenhui2422/dsh-tool-git
v0.1.1
Published
Model-facing git tools for DeepSeek Harness: status, diff, log, add, commit (with conventional-commit checking), stash, branch
Maintainers
Readme
dsh-tool-git
面向 DeepSeek Harness 的模型侧 git 工具集:git_status、git_diff、git_log、git_add、git_commit(带 conventional-commit 校验)、git_stash、git_branch。
一切都是插件 —— 本包通过 ctx.tools 注册普通模型工具,schema 会自动流入 Agent 的系统提示词。
安装
本包声明为 dsh bundle,一条命令即可安装并激活:
dsh plugin --profile web add @chenhui2422/dsh-tool-git(然后重启 profile。)手动方式:在 profile 的 cordis.patch.yml 中加入:
- insert:
- id: tool-git
name: '@chenhui2422/dsh-tool-git'工具
| 工具 | 读写 | 功能 |
|---|---|---|
| git_status | 只读 | 分支、ahead/behind、已暂存/未暂存/未跟踪/冲突文件 |
| git_diff | 只读 | 工作区或已暂存差异;--stat 摘要;路径过滤;行数上限 |
| git_log | 只读 | 最近提交;可选带每个提交的文件列表 |
| git_add | 写 | 暂存显式路径("." 默认禁止) |
| git_commit | 写 | 提交暂存改动,带 conventional-commit 校验 |
| git_stash | 写 | stash push / pop / list |
| git_branch | 只读 | 分支列表 + 当前分支 |
Conventional commits
git_commit 默认校验 <type>(<scope>)?: <description> 格式,不合规时拒绝提交并给出可操作的错误提示。类型采用 Conventional Commits 规范:feat fix docs style refactor perf test build ci chore revert。
配置
| 键 | 默认值 | 说明 |
|---|---|---|
| repoRoot | —(必填) | 操作的仓库;必填,确保模型不会自行选择工作目录 |
| gitBin | git | git 可执行文件 |
| conventional | true | 是否强制 conventional-commit 格式 |
| allowDot | false | 是否允许 git_add 使用 "." |
| allowedTypes | 规范列表 | 提交校验接受的类型 |
| maxDiffLines | 200 | diff 输出行数上限 |
| maxLogCount | 20 | git_log 数量上限 |
示例:
- patch:
- id: tool-git
config:
repoRoot: /path/to/repo
allowedTypes: [feat, fix, docs, chore]安全说明
写工具(git_add、git_commit、git_stash)当前直接执行。接入 harness 审批缝(tools/pre-execute)在路线图中;在共享环境里建议优先使用只读工具。
开发
npm install
npm test # 用一个临时 git 仓库驱动全部工具路线图
- 写工具接入审批门
git_commit自动生成信息:读 diff → 模型总结 → 规范 subjectgit_checkout/git_reset(危险操作,需审批)、git_show、git_tag
License
MIT
