ZSLlearn
dsh-git-tools
Structured, safety-guarded git tools for [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) agent presets — a zero-dependency Cordis plugin (plain ESM, no npm dependencies), hardened through real-repo testing.
- Stars
- 0
- Language
- JavaScript
- Created
- Aug 14, 2026
- Updated
- Aug 14, 2026
Introduction
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>/
- 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