Nwflower/dsh-file-claim5

dsh-file-claim

多会话工作区文件独占与保护插件,提供文件占用/释放、超时接管及基于 Git 的异步三路合并功能。

AI 分析

核心用途是防止多个并发 AI 会话在同一工作区内冲突或覆盖代码。适合多 Agent 协作、多窗口并发编写代码的复杂开发任务;必要条件是系统需安装 Git。

套件
dsh-file-claim
版本
0.1.7
授權
MIT
最近更新
2026年8月16日

安裝

$npx -p @deepseek-ai/dsh dsh plugin --profile web add github:Nwflower/dsh-file-claim

Usage Examples

Two sessions, one workspace. Session A owns README.md; session B wants to edit it too:

// Session A
claim_files({ paths: ["README.md"], note: "rewriting the docs" })
write  ...  README.md          // allowed: own claim
release_files({ paths: ["README.md"] })

// Session B — meanwhile
who_claims({ paths: ["README.md"] })          // → claimed by A
write ... README.md                           // → DENIED with a hint
pending_write({ path: "README.md", content: "..." })  // async, no blocking
// When A releases, the entry is auto 3-way merged (or surfaced for manual pending_apply)

Recover from a crashed session. Session A dies mid-work; its claims expire after staleMs (2h default), then:

claim_status()                      # → A shows [stale]
claim_files({ paths: ["README.md"], force: true })   # take over

Configuration

Passed as plugin config in the bundle (cordis.patch.yml):

KeyDefaultMeaning
staleMs7200000 (2h)Heartbeat expiry before a session is considered stale
stateDirName.dsh-file-claimRegistry + pending area directory under the workspace root
guardtrueSet false to disable the pre-execute write guard
guardCommitfalseOpt-in: also deny git commit that explicitly stages paths actively claimed by another session
heartbeatMs600000 (10min)Fallback heartbeat interval
- insert:
    - id: dsh-file-claim
      name: dsh-file-claim
      config:
        staleMs: 3600000        # 1h
        guardCommit: true       # also guard explicit git commits

The claim registry and pending area live in // — recommend adding it to .gitignore. State survives restarts; nothing ever touches .git/.