Introduction¶
When developing agents with DeepSeek Harness (DSH), you may frequently encounter this requirement: you want a new session to start from an existing Git worktree, while keeping the current session’s workspace membership unchanged. Manually running git worktree add and switching directories breaks the session’s context isolation; using git checkout directly changes the session’s working directory, causing subsequent steps to run in the wrong directory. This problem is especially prominent in scenarios requiring multi-repo, multi-branch collaboration.
dsh-worktree-picker is a local plugin for DSH 0.2.2-rc.3 that provides a worktree picker in the “New Session” Hero row, allowing users to directly select an existing worktree when creating a session. Once selected, the session enters that worktree in the first agent/pre-step, while the immutable header working directory (cwd) remains unchanged. This satisfies the need to “execute in a new directory” without breaking the session’s workspace membership.
Plugin Positioning¶
This is a DSH local plugin maintained by hbosslab. It implements the capability defined in Implementation Plan.md (v2): when creating a new session in DSH Desktop, select from existing worktrees listed within the repository’s writable root directory, and switch to that worktree in the session’s first pre-step while keeping the session’s workspace membership unchanged. The plugin does not depend on any build step and is installed directly as a local bundle.
Core Features¶
- Displays a worktree picker in the “New Session” Hero row
- Lists registered Git worktrees under the current repository (excluding entries whose directories have been lost)
- Supports creating a new worktree: via a modal form specifying the source branch, project name, and target path; the backend executes
git worktree addand records the selection in the same request - Supports clearing the selected worktree: restores to the unselected state
- Worktree status feedback: for read-only worktrees, worktrees outside the writable root directory, or non-checkout directories, the UI annotates writability and prevents non-writable worktrees from being selected
- IDEA-style local setup: after creating a new worktree, you can optionally auto-copy untracked files (based on
.worktreeincluderules) and run a setup script (supports shebang or extension inference; timeout only issues a warning without rolling back) - Security and limitations: all Git commands execute under the session’s sandbox policy; command timeouts and subprocess termination are governed by configurable timeout and output size limits
Installation & Activation¶
The plugin is installed as a local bundle. It requires DSH Desktop ≥ 0.2.2-rc.3, and the runtime environment must include the standard services webServer, sessionProjections, workingDirectory, sandbox*, subprocess, etc.
- Clone the repository locally:
git clone https://github.com/hbosslab/dsh-worktree-picker.git
- Install the directory in DSH Desktop:
- Via GUI: open “Plugins → Add plugin” and select the cloned directory
- Via CLI:plugin_manager install_bundle, passing the directory as the target
After installation, refresh the GUI page to ensure the browser-side components are loaded.
Configuration¶
The plugin provides the following configuration keys in cordis.patch.yml:
| key | default | meaning |
|---|---|---|
enabled |
true |
Set to false to disable the plugin |
gitCommand |
git |
Path to the Git executable |
gitTimeoutMs |
10000 |
Timeout for a single Git command (milliseconds) |
graceMs |
1000 |
Grace period when terminating a subprocess |
maxOutputBytes |
1048576 |
Maximum bytes per output stream |
inspectTimeoutMs |
20000 |
Total time budget per inspection request |
Typical Usage¶
Taking the CLI as an example, assuming the plugin is installed and configured:
- Open DSH Desktop. In the “New Session” Hero row, you will see a dropdown picker listing all available Git worktrees under the current repository
- Click the picker and select a worktree from the list; the session will automatically switch to that worktree in the first
agent/pre-step, while the header working directory remains unchanged - To switch back to the original workspace, click “Clear” in the picker to restore the unselected state
- To create a new worktree, click the “New” button at the bottom of the picker, fill in the source branch, project name, and target path. The plugin will validate the path and branch availability, then execute
git worktree addunder the sandbox policy. Upon completion, the newly created worktree is automatically selected - After creating a new worktree, you can check “Copy local files” and “Run setup script” at the bottom of the modal: the former copies untracked files according to
.worktreeincluderules, and the latter runs the specified script in the new worktree (timeout only issues a warning)
Use Cases & Cautions¶
This plugin is suitable for developers who need to collaborate across multiple worktree branches in new sessions, especially those using DSH for local agent development and needing to preserve session workspace membership.
Note: the plugin runs with the privileges of the current DSH process. It is recommended to review the source code and license before installation. All Git operations and subprocesses are executed under the session’s sandbox policy constraints with explicit output and timeout limits, but caution is still advised when operating in sensitive directories.
Summary¶
dsh-worktree-picker resolves the conflict between “execute in a new directory” and “preserve workspace membership” by providing worktree selection and creation capabilities during session creation. Combined with IDEA-style local file copying and script setup, it enables smoother management of multi-branch, multi-worktree development workflows.
- Plugin directory page: https://www.skillhub.cn/plugins/hbosslab/dsh-worktree-picker
- GitHub: https://github.com/hbosslab/dsh-worktree-picker