dsh-git-tools
Structured, safety-guarded git tools (status/log/diff/branch/repo/stage/commit/reset/push/fetch) for DeepSeek Harness agent presets. Zero runtime dependencies.
AI 분석
核心用途是赋予 Agent 安全、规范的 Git 版本控制操作能力。适合需要 Agent 自动管理代码提交、分支切换及代码比对,且要求操作安全的开发任务。
설치
검증된 bundle이 없거나 호환성 검사에 실패했습니다. 먼저 저장소 설명을 읽어 주세요. 전체 README 읽기 ↗
dsh-git-tools
Structured, safety-guarded git tools for DeepSeek Harness agent presets — a zero-dependency Cordis plugin (plain ESM, no npm dependencies), hardened through real-repo testing.
Contents
| Path | What it is |
|---|---|
src/index.js | The plugin: apply registers 10 git tools; consumes only ctx.get('subprocess') / ctx.get('fs') / ctx.tools.register |
test/register-check.mjs | Zero-dependency self-check: runs apply against a mock context, asserts 10 complete tool schemas + guardrails |
docs/dsh-git-tools-plan.md | Design document: architecture decisions, safety-guardrail list, full test matrix, iteration/fix log |
testdata/ | Test fixtures (throwaway, gitignored): a diverged repo with a bare remote, a Chinese-named repo, a scratch repo, a non-repo dir |
The plugin
10 model tools: git_repo, git_status, git_log, git_branch, git_diff, git_stage, git_commit, git_reset, git_push, git_fetch.
| Tool | What it does | Guardrails |
|---|---|---|
git_repo | repo root, current branch, HEAD, remotes, git version | read-only |
git_status | branch, upstream tracking, ahead/behind, staged/unstaged/untracked/conflicts | read-only |
git_log | recent commits (hash, author, date, subject); count/branch/path filters | read-only |
git_branch | branches with current marker, upstream, ahead/behind counts; all for remote refs | read-only |
git_diff | name-status / numstat / --stat / full unified diff; base/target/path | read-only |
git_stage | git add / git restore --staged for explicit paths | paths required |
git_commit | commit staged changes; allow_empty/amend opt-in | message required |
git_reset | soft / mixed / hard reset | hard requires confirm: true |
git_push | push branch or tags | force requires confirm: true (uses --force-with-lease) |
git_fetch | fetch from a remote or all; prune by default | read-only-ish |
Design highlights:
- Safety-first:
reset --hard/push --forcerefuse to run unless the model passesconfirm: true; force-push uses--force-with-lease; nogit clean/checkout -- ./branch -D/push --delete; interactive prompts disabled everywhere (no hang); commands run as raw argv, never through a shell. - Structured output: porcelain-format parsing into typed fields instead of free-form shell text.
- Context-safe: per-list truncation with
truncatedflags, cooperative cancellation viaexec.signal, explicit timeouts.
Install / use in DeepSeek Harness
Point a preset row straight at the source file (absolute paths work everywhere; Windows drive letters are converted to file: URLs by the preset loader):
# agent.cordis.yml under ~/.dsh/.agent-presets//
- id: dsh-git-tools
name: 'D:/absolute/path/to/dsh-git-tools/src/index.js'
Or npm install dsh-git-tools and reference the package name. See the plan doc for the full design, test matrix, and iteration log.
Self-check
node test/register-check.mjs
Runs apply against a mock Cordis context and asserts all 10 tools register with complete schemas, guarded tools expose confirm, and executes fail gracefully without the subprocess service — catching schema-compilation regressions that preset mount-validation cannot see.
Requirements
gitonPATH(or a knownC:\Program Files\Git\cmd\git.exefallback on Windows)- A harness
subprocessservice (standard in DeepSeek Harness)
License
MIT