voltarenyah / dsh-tool-git
A DeepSeek Harness distribution built for industrial automation
About this plugin
Written by the registry from verified metadata, not from the README.
dsh-tool-git is a DSH plugin published from the packages/dsh-tool-git package in the voltarenyah/dsh-automation-suite repository.
Capabilities and topics
dsh-tool-git
Structured, safe Git tool family for DeepSeek Harness (dsh).
Coding agents reach for git constantly, but the stock runtime only offers raw bash.
dsh-tool-git gives the model twelve structured tools that run git through a
shell-free subprocess runner and return canonical JSON values — plus a
tools/pre-execute safety gate that stops destructive git operations
(force push, hard reset, rebase, amend, branch deletion, …) before they happen,
whether the model calls them through these tools or through a shell tool.
The package has two entries so a profile can grant the tools per agent:
| Entry | What it registers |
|---|---|
dsh-tool-git (host row) | the gitContext service and the safety gate. No model tools. |
dsh-tool-git/tools (tools row) | the twelve git_* tools. It injects gitContext, so without the host row it does not load at all (fail closed). |
- No shell injection: every command goes through
execFilewith an explicit argument array. Model-supplied paths and messages are never string-interpolated. - Machine output: porcelain v2,
--numstat, and--formatrecords are parsed into structured JSON, not prose. - Safety by default: destructive operations are denied with an explanation
unless you opt into
ask(approval prompt) orallow.
Tools
| Tool | What it does |
|---|---|
git_status | Working tree state: branch, ahead/behind, staged / unstaged / untracked files |
git_diff | Per-file insertion/deletion stats, optional unified patch, --cached / rev bases |
git_log | Commit history: hash, author, date, subject, body; maxCount, rev range, path filter |
git_branch | Branches with upstream and ahead/behind tracking state |
git_stage | Stage explicit paths, or all / tracked-only changes |
git_commit | Create a commit with a message; returns hash and statistics |
git_stash | list / push / pop stashes, with conflict-safe pop |
git_show | One commit: metadata, per-file stats, optional patch |
git_fetch | Download refs from a remote without touching the worktree |
git_pull | Fast-forward-only by default; reports not-fast-forward / conflict outcomes |
git_remote | List configured remotes with fetch/push URLs |
git_checkout | Switch branches, or create and switch (-b); never discards changes |
Every tool reports the resolved repository root in its result. No tool accepts a
repository path argument: each call resolves its root from the calling session's
working directory (exec.agent.session.header.cwd) — never from process.cwd()
and never from a model-supplied path.
Service API (gitContext)
The host row provides a cordis service, so sibling plugins can use git path resolution without importing this package or its model tools:
const gitContext = ctx.get('gitContext')!
await gitContext.isRepository(root) // boolean
await gitContext.repoRoot(root) // string | null (git rev-parse --show-toplevel)
await gitContext.init(root, { initialBranch: 'main' }) // fresh repo → GitContext
await gitContext.create(root) // GitContext bound to the containing repo
create / init return a GitContext:
| Member | Contract |
|---|---|
repoDir | absolute repository root |
run(args) | { code, stdout, stderr }; a non-zero exit is data, not an exception |
runChecked(args) | { stdout, stderr }; throws on a non-zero exit |
status(paths) | git status --porcelain lines, untracked included |
head() | HEAD hash, or null on an unborn branch |
commit(paths, message) | path-limited add+commit → { committed, hash } |
Every root argument is explicit and must be absolute; the service never falls
back to process.cwd(). run/runChecked also accept { signal }.
Safety gate
The gate listens on tools/pre-execute and inspects every tool call:
-
The plugin's own tools — e.g.
git_commitwithamend: true. -
Shell tools —
bash,tool:bash,bash_persistent,terminal,tool:terminal,pwsh— scanning their command text for destructive git invocations such as:push --force/--force-with-lease·push --delete·reset --hard·clean -f·branch -d/-D·tag -d·rebase·pull --rebase·commit --amend·checkout --/checkout ./checkout -f·switch -f·restore(discarding worktree) ·rm -r·update-ref -d·filter-branchPattern matching is per-command: it never crosses
|,;, or newline boundaries, sogit add . && git push --forceis still caught but innocent compound commands are not misread.
This is a policy guardrail, not a sandbox. An agent that can run arbitrary
code can always route around a string matcher (aliases, -c rewrites,
scripting). The gate exists to make accidental destructive calls fail loudly
with an explanation — deliberate destructive work is authorized through the
configured policy, not by bypassing the gate.
Install
npm (recommended) — from any directory:
dsh plugin --profile web add dsh-tool-git
From GitHub (or a local checkout / tarball):
dsh plugin --profile web add github:lxj808624/dsh-tool-git#v0.1.2
Then restart dsh --profile web. For GitHub installs, pnpm asks you to
allowlist the prepare build script once (see the
official packaging guide).
Configuration
All options are optional; the defaults are shown below:
# host row: service + safety gate (no model tools)
- id: tool-git
name: dsh-tool-git
config:
gitPath: git # git executable
destructivePolicy: deny # deny | ask | allow
extraDestructivePatterns: [] # extra case-insensitive regexes for the gate
logMaxCommits: 20 # git_log default count (cap 100)
diffContextLines: 3 # patch context lines for git_diff / git_show
# tools row: the twelve model tools (no config of its own)
- id: tool-git-tools
name: dsh-tool-git/tools
There is no workDir. Tool roots come from the calling session's cwd, and the
/tools row inherits logMaxCommits / diffContextLines from the host row's
service, so the host row is the single configuration surface.
deny(default) — destructive calls are rejected with the pattern name and an explanation.ask— destructive calls go through the runtime's approval seam (ctx.approval); without a mounted approval service they degrade todeny.allow— the gate passes everything through.
Development
This directory is a vendored copy of upstream
lxj808624/dsh-tool-gitv0.1.3, living inside thedsh-automation-suitemonorepo. The plugin's own source and tests are upstream's; what differs is how the development-time@deepseek-ai/*packages resolve. See this package'sAGENTS.md.
Prerequisites: Node.js ≥ 22.19 and pnpm. Inside this monorepo the @deepseek-ai/*
runtime packages are deliberately not installed from npm: the published
registry line stops at 0.1.0-rc.6, while the harness this repository develops
against ships a newer runtime, so type-checking or testing against the registry
copy would validate the plugin against the wrong API surface. Instead the
packages are linked out of the installed app's own resources/app.asar:
pnpm --filter dsh-tool-git run link:runtime # once per checkout
The test suite performs the same linking automatically on first run.
pnpm install
pnpm run typecheck # tsc against the runtime the local harness actually ships
pnpm test # vitest: boots the plugin, runs real git in temp repos
pnpm run build # tsc declarations + tsdown bundles (lib/index.mjs, lib/tools-entry.mjs)
The extracted runtime ships no .d.ts (the app's production build strips them),
so the runtime surface this plugin uses is declared in src/dsh-runtime.d.ts —
the same arrangement as packages/dsh-tia-openness-v17-min.
The tests create a disposable repository, register the plugin on a Cordis
context with the real dsh-tools runtime, and execute every tool through the
full pipeline (tools/pre-execute → dispatch → tools/result).
Publish
dsh.bundle.patchinpackage.jsonpoints atcordis.patch.yml, sodsh plugin addactivates the plugin as a profile layer.preparerunstsdown --config tsdown.prepare.config.ts, which transpilessrc/without project references — so GitHub installs build cleanly without a sibling harness checkout. Prefer publishing prebuilt tarballs / npm packages to avoid pnpm's build-script allowlist.
License
Contributors
- taonokenshin — found and fixed the
dsh-toolspeer-resolution issue that crashed the host tool dispatcher on DeepSeek Harness 0.1.0-rc.6 (#1, #2).
Badge
Listed here? Link back with this badge — paste the snippet into your repository README.
[](https://dsh-plugin.com/plugins/voltarenyah/dsh-automation-suite/packages/dsh-tool-git)