Preface¶
When writing agents in DeepSeek Harness (DSH), Git operations are common: checking status, viewing diffs, committing, staging, pulling, and switching branches. Relying solely on raw bash introduces two types of problems: first, commands are assembled through shell strings, which can introduce shell injection risks; second, output is often text, making it difficult for models to parse reliably.
dsh-tool-git is a DSH plugin maintained by lxj808624, licensed under MIT. It breaks down common Git operations into structured tools and intercepts destructive commands through pre-execution safety checks.
What This Is¶
dsh-tool-git is a Git tool plugin for DeepSeek Harness. Its core positioning is:
- Providing structured Git tools;
- Avoiding direct execution of Git commands through shell strings;
- Parsing Git output into structured JSON;
- Adding destructive command protection before tool execution.
It is suitable for scenarios where DSH agents need to reliably execute Git workflows.
Core Capabilities¶
dsh-tool-git provides structured tools for the following Git operations:
statusdifflogbranchstagecommitstashshowfetchpullremotecheckout
These tools run git through a shell-free subprocess runner, using execFile and explicit argument arrays to avoid shell interpretation of model input.
It also parses the following output into structured JSON:
- porcelain v2
--numstat--format
This is easier for agents to process than directly reading terminal text.
The plugin also adds safety checks on tools/pre-execute to handle destructive Git operations and shell commands.
Destructive Command Policy¶
dsh-tool-git provides a destructivePolicy option with three values:
deny: Default value, rejects destructive operations;ask: Goes through an approval flow; if no approval service is mounted, it degrades todeny;allow: Allows the operation.
By default, destructive operations are rejected unless explicitly configured as ask or allow.
It should be noted that this is policy-level protection, not a sandbox. If an agent can execute arbitrary code, it may still bypass string-matching style protection. This gate is primarily designed to make accidental operations fail explicitly with clear explanations.
Installation and Activation¶
It is recommended to install from npm:
dsh plugin --profile web add dsh-tool-git
You can also install a specific version from GitHub:
dsh plugin --profile web add github:lxj808624/dsh-tool-git#v0.1.3
After installation, restart the corresponding profile:
dsh --profile web
When installing from GitHub, you may need to allow the pnpm prepare build script once.
Typical Usage¶
Below are two common configuration points.
Configuring the Destructive Command Policy¶
Set destructivePolicy to one of the following values:
deny
ask
allow
If not configured, the default is deny.
Specifying the Repository Discovery Directory¶
The tool supports an optional repoDir parameter for specifying the starting directory for repository discovery. By default, it uses the process’s current working directory.
The tool reports the resolved repository root directory in its execution results.
Applicable Scenarios and Notes¶
dsh-tool-git is suitable for the following scenarios:
- Reliably performing Git status queries in DSH agents;
- Letting models read structured diff, log, and branch information;
- Completing routine Git workflows such as stage, commit, stash, fetch, pull, and checkout;
- Reducing injection and output parsing issues caused by executing Git commands through raw shell.
Things to note before use:
- The plugin runs with the current
dshprocess’s permissions; check the source code and license before installation; - It is policy-based protection, not a sandbox;
- Destructive operations are rejected by default;
askrelies on an available approval service; otherwise, it degrades todeny.
Conclusion¶
The value of dsh-tool-git lies in turning common Git operations into structured, parseable tool calls with default safety policies, making it suitable for replacing some raw shell Git usage in DSH.
GitHub repository:
https://github.com/lxj808624/dsh-tool-git
To find it via the DSH community directory, search for the plugin name dsh-tool-git.