跳到正文

FlashingChen/dsh-worktree

50最近提交 2026年8月13日

dsh-worktree DSH 插件

该插件支持创建永久 git 工作树,这些工作树在会话和重启后保持存在,类似于 Codex CLI 的 `codex worktree create --permanent`。它提供 agent 工具和聊天命令来创建、列出、打开和删除工作树。工作树存储在仓库根目录下的隐藏目录 `.dsh-worktrees` 中,并通过清单文件保证持久化。

如何安装 dsh-worktree DSH 插件

dsh plugin --profile web add dsh-worktree

复制不会执行命令。安装 dsh-worktree DSH 插件前请核对仓库和版本。

dsh-worktree DSH 插件数据来源

dsh-worktree DSH 插件快照日期:2026年8月16日

discovered

dsh-worktree DSH 插件能做什么

  • 通过 agent 工具或 `/worktree create` 命令创建永久分离工作树
  • 列出已注册的工作树及其实时 git 状态(存在状态、HEAD、分支)
  • 删除工作树,可选 `--force` 丢弃未提交更改,并阻止删除当前会话所在的工作树
  • 将工作树作为 DSH 工作区打开(注册到 workspaceRegistry)
  • 自动检测会话是否运行在已注册的工作树内,并向 agent 提供上下文提示

dsh-worktree DSH 插件适合哪些场景

  • 在不影响主工作树的情况下,维护用于功能开发的长期分支
  • Agent 在任务中临时创建永久工作区进行实验或并行工作
  • 在会话重启后恢复到同一工作树继续工作,保持状态不丢失

dsh-worktree DSH 插件适合谁

  • 希望获得类似 Codex CLI 的持久化 git 工作树管理的 DSH 用户
  • 需要将变更隔离在专用工作树中的 AI 代理开发者

dsh-worktree DSH 插件的限制

  • 需要 git ≥ 2.31(使用了 `git rev-parse --path-format=absolute --git-common-dir`)
  • 需要 DSH 配置文件包含 `tools`、`commands` 和 `subprocess` 服务(例如 `web` 配置文件)
  • 插件依赖固定在 harness 版本 0.1.0-rc.6;如果使用不同版本的 DSH,可能需要从源码安装并调整依赖
  • 当会话从仓库的子目录启动时,`.dsh-worktrees` 可能落在会话工作区之外,导致工作树文件无法写入

dsh-worktree DSH 插件的仓库 README 摘录

以下文字摘自 dsh-worktree DSH 插件的上游仓库 FlashingChen/dsh-worktree 的 README,版权归原作者,仅作引用。

English | [中文](README.zh.md) [![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE) Codex-style **permanent git worktrees** for DeepSeek Harness — a Cordis plugin that gives a DSH profile the same durable-worktree workflow as `codex worktree create --permanent`. A permanent worktree is a real `git worktree add --detach` checkout that **survives sessions and restarts**. You (or the agent) create it once, and any later session can be opened inside it to keep working where the previous one left off — without ever touching your main working tree. ## What you get | Codex CLI | dsh-worktree equivalent | |---|---| | `codex worktree create --permanent <name> [<base>]` | agent tool `worktree_create`, or `/worktree create <name> [<base>]` | | `codex worktree list` | agent tool `worktree_list`, or `/worktree` / `/worktree list` | | `codex worktree open <name>` | `/worktree open <name>` (registers the worktree as a DSH workspace; start a new session there) | | `codex worktree close/delete <name>` | agent tool `worktree_remove`, or `/worktree remove <name>` | | worktree shown in session context | one-shot context note when a session runs inside a registered worktree

阅读完整 README仓库许可: MIT

dsh-worktree DSH 插件常见问题

如何安装 dsh-worktree?

运行 `dsh plugin --profile web add dsh-worktree` 从 npm 安装插件。然后在配置文件的 cordis.patch.yml 中添加插件配置(具体 YAML 片段见 README)。最后重启 DSH 配置文件(例如重启 `dsh web` 进程)。

如何创建一个永久工作树?

可以使用 agent 工具 `worktree_create`,参数为 `{name, baseCommit?}`,或者使用聊天命令 `/worktree create <name> [<base-commit>]`。工作树会在指定基础提交处创建一个分离 HEAD,默认使用当前 HEAD。

如何列出所有已注册的工作树?

使用 agent 工具 `worktree_list` 或聊天命令 `/worktree`(或 `/worktree list`)。它会显示所有已注册的工作树及其实时 git 状态(是否存在、HEAD 提交、分支名)。

如何删除工作树?

使用 agent 工具 `worktree_remove` 并指定名称,或聊天命令 `/worktree remove <name>`。也可以使用 `/worktree close/delete <name>`。如果要丢弃未提交的更改,添加 `force: true`(聊天命令中加 `--force`)。插件会阻止删除当前会话正在使用的工作树。

重启 DSH 后工作树还会存在吗?

是的,工作树是永久性的。它们存储在仓库根目录下的 `.dsh-worktrees/manifest.json` 清单文件中,该文件在 DSH 重启后仍然保留。当你在已注册的工作树内启动新会话时,插件会自动检测并提供上下文给 agent。