CSY656/dsh-worktree1

dsh-worktree

Git worktree filesystem isolation plugin for DeepSeek Harness

AI Analysis

核心用途是为 Agent 提供干净、隔离的代码运行环境,防止并发任务冲突。适合进行多分支并行开发或自动化测试的任务。需 DSH >= 0.1.0-rc.6。

Package
dsh-worktree
Version
0.1.0
License
MIT
Last updated
Aug 14, 2026

Install

$npx -p @deepseek-ai/dsh dsh plugin --profile web add github:CSY656/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 /.dsh/worktrees//; 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
}