DeepSeek Harness 插件

dsh-worktree

Git worktree filesystem isolation for DeepSeek Harness subagents.(英文原文)

跳到安装方式

来源信息

GitHub 仓库
CSY656/dsh-worktree
最近更新
2026年8月14日
分类
自动化与任务
GitHub stars
1
载体类型
plugin
目录证据
上游声明已找到 dsh.bundle
证据路径
package.json#dsh.bundle
核对版本
0.1.0-rc.8
上游核对日期
2026-08-20

该证据由上游目录提供。本站没有安装、运行或安全审核这个插件。

安装

默认先复制一段 Prompt,让 Agent 读 GitHub 仓库和源码;需要自己装时再切到命令。

复制这段 Prompt,发给 DSH、Codex 或其他 Agent,让它先读 GitHub 仓库和源码。

请先不要安装或执行任何命令。阅读这个插件的 GitHub 仓库、README 和关键源码,然后用清楚、直接的方式回答以下问题,帮助我判断它是否适合我的需求:

1. 这个插件是什么,解决什么问题;
2. 适合哪些用户和典型使用场景;
3. 安装后如何使用,并给出一个最小使用示例;
4. 有哪些已知限制,以及隐私、安全、兼容性或维护风险;
5. 给出“推荐 / 有条件推荐 / 不推荐”的明确建议和理由。

请区分仓库明确说明、根据源码推断和未知信息。证据不足时请明确说明,不要猜测或照抄 README。

GitHub:https://github.com/CSY656/dsh-worktree
插件名:dsh-worktree
作者:CSY656

检查来源文件

安装前先看这个插件目录里的 README 和其他文件。

文件资源管理器3 个文件
README.md来源说明 · 只读预览

dsh-worktree

Filesystem isolation for DeepSeek Harness subagents via git worktrees. Subagents already isolate messages, permission policy, and tool sets — this plugin isolates the filesystem: each child runs in its own worktree under <repoRoot>/.dsh/worktrees/, sharing the repository object store while keeping the working tree private.

Two entries, one package:

  • dsh-worktree — the ctx.worktree service: create/restore/list/remove git worktrees with strict slug validation, change protection, best-effort post-creation setup, and periodic sweeping of stale temporary worktrees.
  • dsh-worktree/commands — the human-facing /worktree create <slug> | list | remove <slug> [--discard] slash commands.

Install

Requires the DeepSeek Harness next line (dsh ≥ 0.1.0-rc.6). From GitHub:

dsh plugin --profile default add github:you/dsh-worktree

pnpm ≥ 10 asks you to allow the build — add the printed package key to the profile's pnpm-workspace.yaml:

allowBuilds:
  dsh-worktree: true

Then re-run the add. From npm (prebuilt):

dsh plugin --profile default add dsh-worktree

Usage

/worktree create feature/demo    → creates .dsh/worktrees/feature+demo, branch worktree-feature+demo
/worktree list                   → name/path/branch rows
/worktree remove feature/demo    → refuses while dirty; --discard forces

Service API (for plugin authors):

const lease = await ctx.worktree.acquire('agent-abc1234', cwd)  // create/restore at HEAD
// ...run an isolated child with its session header.cwd = lease.entry.path...
const { kept, path, branch } = await lease.release()            // clean → removed; dirty → kept + reported
  • Worktrees live at <repoRoot>/.dsh/worktrees/<flatSlug>/; nested slugs flatten / to + (team/aliceteam+alice), branch worktree-team+alice.
  • validateSlug enforces [a-zA-Z0-9._-] per segment, length ≤ 64, rejecting ., .., //, and leading/trailing separators.
  • Post-creation setup is best-effort: copies project .dsh config, inherits core.hooksPath, symlinks node_modules/.venv/vendor (Windows symlink failures degrade to a warning), copies .worktreeinclude-listed ignored files.
  • Change detection is fail-closed: any git failure counts as "has changes", so a broken worktree is kept rather than deleted.
  • Per-repository mutations serialize; concurrent acquires of the same slug are idempotent (fast restore, no git subprocess).

Configuration

interface Config {
  sweepIntervalMs?: number  // default 3_600_000 (1h)
  sweepMaxAgeMs?: number    // default 86_400_000 (24h); only agent-* temp worktrees are swept
}

Automatic subagent isolation

The one-line integration — subagent(..., worktree: true) creating a worktree per child run with automatic cleanup — needs a small upstream capability in dsh-subagent/dsh-tool-subagent (an optional cwd on SubagentStartRequest). See [UPSTREAM-PR.md](./UPSTREAM-PR.md) for the exact changes and their in-tree implementation; until the upstream accepts them, use ctx.worktree.acquire() in your own plugins or the /worktree commands manually.

Known limitations

  • In-process isolation only — child-session cwd overrides are stamped by in-process backends; out-of-process backends (acp, claude-code, codex, dsh-sdk) ignore them.
  • No cross-process sharing — one DSH instance owns its worktrees.
  • No merge strategy — merging kept worktrees is the delegating agent's job (git merge worktree-<flatSlug>).

Contributing to the ecosystem

  • Tagged with the dsh-plugin topic — browse other plugins.
  • Tests run with pnpm install && pnpm test (real temporary git repositories, no network).
  • The behavior ported here comes from CsyCode chapter 14's worktree isolation.

License

MIT