Skip to content

Repository files navigation

dsh-git

Provides DeepSeek Harness agents with automatic checkpoints before risky edits, structured Git tools, and approval-gated write operations in a single npm bundle.

English | 中文

Overview

  1. Automatic rollback protection. Before each risky operation—write, edit, str_replace_editor, and, by default, bash—the worktree is snapshotted under refs/harness-checkpoints/<session-id>. git_checkpoint_list shows the session's checkpoint history and git_checkpoint_restore rolls back to any one of them — not just the latest. Because shell commands cannot be integrated directly into the agent's edit pipeline, the system prompt defines a mandatory Git safety procedure: create a checkpoint before every mutating tool call, verify the result with git_status, and restore the checkpoint if an error occurs.
  2. Structured repository state. git_status, git_diff, and git_log return typed data parsed from porcelain v2, allowing the model to reason over repository state without parsing terminal formatting.
  3. Durable, session-scoped checkpoints. Snapshots are stored as local refs under refs/harness-checkpoints/<session-id>. They are not pushed or pruned, and rollback does not remove untracked files. If no checkpoint exists—typically during the first edit after a clean state—git_checkpoint_restore restores from HEAD.

All mutating tools are approval-gated through the Harness UI, using the same approval mechanism as bash.

Tools

Tool Purpose
git_status / git_diff / git_log Structured reads of the working tree
git_commit Commit staged changes (approval-gated)
git_restore Discard worktree changes (approval-gated)
git_checkpoint Manual snapshot (approval-gated)
git_checkpoint_list List session checkpoints, newest first, for selection
git_checkpoint_restore Roll back to a selected checkpoint, or the latest when omitted (approval-gated; falls back to HEAD when none exists)

Requirements

  • DeepSeek Harness — dev checkout or local build; the @deepseek-ai/* packages it needs come with the install and are declared as peers
  • A git executable on the host

Install

Install through the Harness plugin command:

dsh plugin --profile web add dsh-git

dsh plugin runs pnpm add dsh-git inside the profile and auto-registers the bundle through its dsh.bundle.patch. Restart, and the three plugins (git-local, tool-git, git-checkpoint-policy) plus the eight git_* tools are live.

Alternatively, install the package manually and mount the plugins:

cd ~/.dsh/profiles/<profile>
npm install dsh-git
- insert:
    - id: git-local
      name: 'dsh-git/local'
    - id: tool-git
      name: 'dsh-git/tool'
    - id: git-checkpoint-policy
      name: 'dsh-git/checkpoint-policy'

Restart after editing the profile's cordis.patch.yml.

Do not mount dsh-git/git as a plugin entry. The definition registers ctx.git automatically; mounting it alongside git-local causes a duplicate-service error.

Verify

  1. Confirm that the plugin inventory in Settings contains git-local, tool-git, and git-checkpoint-policy.
  2. Run git_status and confirm that it returns a structured report containing branch:.
  3. Run git_commit, approve the operation, and confirm that it returns committed <sha>.
  4. Edit a file, confirm that a checkpoint ref is created under refs/harness-checkpoints/, list it with git_checkpoint_list, and use git_checkpoint_restore to restore the pre-edit state.

Development

The built lib/ directory is synchronized from the upstream Harness repository (packages/git/ at https://github.com/deepseek-ai/deepseek-harness) with ./sync.sh [UPSTREAM_DIR]. The script copies each component's lib/ directory to lib/<component>/, rewrites internal @deepseek-ai/dsh-git imports to the package self-reference dsh-git/git, and pins the version. The upstream repository contains src/ and tests/; this repository distributes the build output.

Known limitations

  • Remote and pull request operations are not supported; push, fetch, and gh workflows remain shell-driven.
  • Checkpoint restoration does not remove untracked files; support for git clean is deferred.
  • refs/harness-checkpoints/* are local refs and are neither fetched nor pushed or pruned.
  • If no approval service is mounted, mutating tools run without approval gating.
  • The @deepseek-ai/* peer dependencies are provided by Harness rather than published as registry packages. dsh-git must be installed in a profile belonging to a compatible Harness installation.

Related projects

About

No description or website provided.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages