dsh-task-worktree: Task-based Isolation of Git Worktrees in DSH

Preface

Letting models modify code in DeepSeek Harness (DSH) typically involves editing files directly in the main workspace. When running multiple tasks in parallel or keeping the main branch clean, this can lead to interference, making rollbacks and merges cumbersome. Environments like Qoder, Codex, and Claude Code feature a “separate checkout per task” worktree workflow; DSH itself is a pluginized host, and community plugins can integrate similar capabilities.

Below is an introduction to dsh-task-worktree (maintained by epik7th), a Git worktree plugin targeting the DSH 0.2.0 host line. Forked from Letter2025/dsh-task-worktree, it is categorized as a workflow in the SkillHub directory. Each task develops in an independent worktree and branch, with state written to a per-repo manifest, allowing recovery after session restarts; the main workspace is not automatically registered as a new workspace, and a branch badge on the session title indicates the worktree bound to the current conversation.

What is this

dsh-task-worktree provides complete, task-granular git worktree support for DSH: creating isolated checkouts, listing and viewing status, merging changes back to the main branch or committing on the worktree branch, and cleaning up directories and branches. The design references Qoder’s Worktree execution environment, Codex’s codex worktree create --permanent, and Claude Code’s --worktree sessions, adapted to DSH’s session/workspace model.

Relationship with the upstream npm package dsh-task-worktree@0.4.3: The host peer declared by upstream is incompatible with dsh 0.2.0, and the browser side still relies on the sessions.current field which was removed in dsh 0.1.6. This fork raises the peer range and derives the current session from the main view retention (consistent with the shell). Tools, commands, and the security model follow the upstream design; see the migration record in the repository for details.

The physical path for Worktrees is <repo>/.dsh-worktrees/; each task typically corresponds to a branch and relative path in the form of worktree/<name> (names may contain slashes).

Core Features

Conceptual Mapping with Common Products

This Plugin Qoder Codex Claude Code
Task-level isolated checkout Worktree execution environment codex worktree create --permanent claude --worktree <name>
Directory <repo>/.dsh-worktrees/ Background worktree .codex/worktrees/ .claude/worktrees/
Persistent registry Per-session Global index Session-bound
Independent branch per task Branch selector — worktree-<name>
Session marker session badge — —
Merge back to main branch Move to local — Exit/cleanup prompt
Commit directly on worktree branch Review & commit Commit within worktree Commit within worktree

Tools Callable by the Model

Delivery and cleanup (finish / bring-back / remove) are human-only operations; the model cannot call them.

Tool Function
worktree_create {name, baseCommit?, includeUncommitted?} Create a task worktree; optionally bring uncommitted changes from the main workspace
worktree_list List managed worktrees in the repository (status / dirty status / branch)
worktree_status {name?} View the status of a specified or the current session’s worktree

Human Commands (Excerpt)

Wrap-up, merging, deletion, and other operations are performed via slash commands, for example:

  • /worktree bring-back worktree/<name>: Merge the branch into the main branch (requires main workspace to be clean)
  • /worktree finish worktree/<name> <msg>: Commit and retain on the worktree branch
  • /worktree remove worktree/<name> --force: Delete worktree and branch (--force discards uncommitted changes)
  • /worktree list, /worktree status, /worktree prune: View and clean up (prune also removes stale workspace registrations for deleted checkouts)

In a blank conversation, you can check worktree in the dock and select a base branch; equivalently, you can directly tell the model “Use worktree isolation to work, the task is called xxx,” and the model will call worktree_create.

Installation and Activation

In a profile running the Web GUI, install from a public Git repository (package name dsh-task-worktree):

dsh plugin --profile desktop add github:epik7th/dsh-task-worktree

The install field in the plugin manager can also be filled with the same address: github:epik7th/dsh-task-worktree. Executing the plugin requires a composed dsh.bundle patch, which add will wire up automatically.

Environment Requirements (from the original README):

  • DeepSeek Harness 0.2.0-rc.1 host line (including rc.2 and the 0.2.0 official release)
  • Git 2.31+
  • Node 20+

Note: Do not install this simultaneously with the upstream npm package dsh-task-worktree@0.4.3; the host resolves the client bundle by package name, and if two sources resolve to the same package name, it will be rejected. You should uninstall one before installing the other.

The current repository package.json version is 0.6.4, license MIT.

Typical Usage

Entering Worktree Mode from a Blank Conversation

  1. In a blank conversation where no messages have been sent, the dock will display a worktree checkbox and a branch selector. The selector defaults to showing the starting branch for the new task worktree (usually the repository’s current branch) and allows searching local and remote-tracking branches; checking it is equivalent to mode-on --base <branch> and fixes the baseCommit for worktree_create.
  2. After sending the first message, the host injects an instructions context before your message (displayed as an injected-context line in the UI), guiding the model to call worktree_create in this turn, create a worktree under a branch with the worktree/ prefix, and work using absolute paths within the checkout; at the end, it reminds of available cleanup commands.
  3. Under the hood, this is equivalent to executing something like:
git worktree add -b worktree/<name> <repo>/.dsh-worktrees/worktree/worktree/<name> <base>

It does not register a new workspace nor switch the conversation; the session title badge displays the bound branch name. The model continues to modify code inside the worktree directory.

Verbalizing Tasks Directly Without GUI

Instruct the model, for example: “Use worktree isolation to work, the task is called xxx.” The model calls worktree_create; name serves as both the branch name and the relative path.

After Task Completion

The human chooses one of the following:

  • Merge back to main branch: /worktree bring-back worktree/<name>
  • Commit and retain on worktree branch: /worktree finish worktree/<name> <msg>
  • Force delete: /worktree remove worktree/<name> --force

Use /worktree list and /worktree status to verify state; for long-term maintenance, use /worktree prune to clean up stale entries.

Use Cases and Considerations

Suitable for: DSH users running multiple parallel Agent tasks on the same repository, wanting to keep the main workspace directory untouched, needing a recoverable worktree registry, and accustomed to the Qoder/Codex/Claude Code style of “one checkout per task.”

Branch Selector Limitations: Relies on the shell’s workspaceFiles Remote to read <repo>/.git; if the service is unavailable, or if the loose refs of the session’s checkout are not under the workspace root, the selector will prompt and fall back to HEAD. Workspaces that are not Git repositories will not offer worktree mode after ref reading is completed.

Security and Trust: The plugin executes Git and subprocess operations with the current DSH process permissions; please review the GitHub source code and the MIT license before installing. The DSH ecosystem emphasizes “everything is a plugin”; community directories like SkillHub are independent sites and have no official affiliation with DeepSeek / High-Flyer.

Coexistence with Upstream: Please use this fork if you only need the dsh 0.2.0 host line; if you are still on the ^0.1.7-rc.2 host peer declared by upstream, you should use the upstream package instead of this fork.

Conclusion

dsh-task-worktree connects “task-isolated Git worktrees + persistent manifests + session badges + human-controlled merge/commit/delete” to DSH 0.2.0, keeping the main sidebar uncluttered with workspaces while ensuring task boundaries are clearly trackable.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye