Back to home

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

PathWhat it is
src/index.jsThe plugin: apply registers 10 git tools; consumes only ctx.get('subprocess') / ctx.get('fs') / ctx.tools.register
test/register-check.mjsZero-dependency self-check: runs apply against a mock context, asserts 10 complete tool schemas + guardrails
docs/dsh-git-tools-plan.mdDesign 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.

ToolWhat it doesGuardrails
git_reporepo root, current branch, HEAD, remotes, git versionread-only
git_statusbranch, upstream tracking, ahead/behind, staged/unstaged/untracked/conflictsread-only
git_logrecent commits (hash, author, date, subject); count/branch/path filtersread-only
git_branchbranches with current marker, upstream, ahead/behind counts; all for remote refsread-only
git_diffname-status / numstat / --stat / full unified diff; base/target/pathread-only
git_stagegit add / git restore --staged for explicit pathspaths required
git_commitcommit staged changes; allow_empty/amend opt-inmessage required
git_resetsoft / mixed / hard resethard requires confirm: true
git_pushpush branch or tagsforce requires confirm: true (uses --force-with-lease)
git_fetchfetch from a remote or all; prune by defaultread-only-ish

Design highlights:

  • Safety-first: reset --hard / push --force refuse to run unless the model passes confirm: true; force-push uses --force-with-lease; no git 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 truncated flags, cooperative cancellation via exec.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

  • git on PATH (or a known C:\Program Files\Git\cmd\git.exe fallback on Windows)
  • A harness subprocess service (standard in DeepSeek Harness)

License

MIT