dsh-git-worktree 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,21 @@
2
2
 
3
3
  本项目的显著变更记录在此文件中。版本号遵循 Semantic Versioning;在 `0.x` 阶段,minor 版本可能包含需要迁移的公开能力调整。
4
4
 
5
+ ## [0.3.1] - 2026-08-18
6
+
7
+ `0.3.1` 修复验收卡操作菜单被卡片裁剪的问题,并将项目文档重组为中文优先、带完整产品流程截图的发布入口。
8
+
9
+ ### Fixed
10
+
11
+ - Ready for Review Tool 卡片允许操作菜单溢出显示,避免菜单被卡片边界裁剪。
12
+ - 验收卡菜单改为向下展开,composer dock 中的同类菜单继续向上展开,并增加对应 CSS 回归测试。
13
+
14
+ ### Changed
15
+
16
+ - 中文 README 成为默认入口,英文文档迁移到 `README.en.md`。
17
+ - 重写 Worktree 产品文档、迁移说明与架构入口,补充创建、Ready、Local Preview、提交、保留环境和下一轮修改的产品截图。
18
+ - 本地 DSH 开发 tarball staging 同步包含 `README.en.md`。
19
+
5
20
  ## [0.3.0] - 2026-08-17
6
21
 
7
22
  `0.3.0` 完善同一 isolated Session 的连续修改体验:未同步 Review 可以安全恢复编辑,成功交付并 cleanup 后也能保留 Session ID、immutable cwd 与完整对话开始下一轮。
@@ -47,7 +62,7 @@
47
62
  - Create/Ready ToolView;
48
63
  - Header Session Target 状态胶囊;
49
64
  - `conversation.input.dock` 的 Ready、Preview 与 Recovery 状态条。
50
- - Domi 式交付生命周期:
65
+ - 两阶段验收交付生命周期:
51
66
  - Ready for Review;
52
67
  - 不提交、可撤回的 Local Preview;
53
68
  - Preview 验收提交;
@@ -86,8 +101,9 @@
86
101
 
87
102
  ## [0.1.2] - 2026-07-28
88
103
 
89
- - 发布初版 Domi-grade Worktree 管理、基础 apply/finish/discard 生命周期和安全清理。
104
+ - 发布初版生产级 Worktree 管理、基础 apply/finish/discard 生命周期和安全清理。
90
105
 
106
+ [0.3.1]: https://github.com/wloops/dsh-git-worktree/compare/v0.3.0...v0.3.1
91
107
  [0.3.0]: https://github.com/wloops/dsh-git-worktree/compare/v0.2.0...v0.3.0
92
108
  [0.2.0]: https://github.com/wloops/dsh-git-worktree/compare/v0.1.2...v0.2.0
93
109
  [0.1.2]: https://github.com/wloops/dsh-git-worktree/releases/tag/v0.1.2
package/README.en.md ADDED
@@ -0,0 +1,334 @@
1
+ # dsh-git-worktree
2
+
3
+ [![npm](https://img.shields.io/npm/v/dsh-git-worktree)](https://www.npmjs.com/package/dsh-git-worktree)
4
+ [![CI](https://github.com/wloops/dsh-git-worktree/actions/workflows/ci.yml/badge.svg)](https://github.com/wloops/dsh-git-worktree/actions/workflows/ci.yml)
5
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
6
+
7
+ **Let agents work in real Git worktrees, preview the result in Local, and commit only after explicit human approval.**
8
+
9
+ `dsh-git-worktree` is an experimental Session Target plugin for [DeepSeek Harness](https://github.com/deepseek-ai/DeepSeek-Harness). Each coding task runs in its own checkout and Session, so the Local workspace controlled by the user does not become the agent's construction site.
10
+
11
+ This is more than a wrapper around `git worktree`. It provides a complete delivery lifecycle: create an isolated environment, iterate safely, prepare a review, preview the task in Local without committing, finalize one task-only commit, and preserve recovery evidence when safety cannot be proven.
12
+
13
+ > Its Worktree safety foundation originates from workflows used in the author's internal desktop project **Domi**. This plugin is independently adapted for Harness and does not require Domi to install or run.
14
+
15
+ [中文文档](README.md)
16
+
17
+ ## What problem does it solve?
18
+
19
+ When an agent edits the current working tree directly, several concerns become entangled:
20
+
21
+ - task changes mix with existing staged, unstaged, and untracked Local state;
22
+ - multiple agent tasks sharing one checkout can overwrite files, switch branches, or contaminate each other's commit boundaries;
23
+ - multiple tasks writing results into Local at the same time can interfere with Preview, conflict handling, and cleanup;
24
+ - it becomes difficult to tell which bytes belong to the current task;
25
+ - “show me the result” may already mean an irreversible write into Local;
26
+ - commit, cleanup, and recovery decisions may depend too heavily on model judgment;
27
+ - starting another coding round often means losing the original conversation or rebuilding its context.
28
+
29
+ This plugin separates a coding task into two explicit boundaries:
30
+
31
+ 1. **The agent implements and validates in an Isolated Worktree.**
32
+ 2. **The user reviews the result in Local and decides whether to commit it.**
33
+
34
+ ## Highlights
35
+
36
+ - **Real isolation** — every task gets a distinct Git worktree, Harness Workspace, cwd, and Session ID.
37
+ - **Human-gated delivery** — the model may prepare a review, but it cannot Preview, Commit, Discard, or delete the Worktree by itself.
38
+ - **Reversible Local Preview** — inspect the task in Local without creating a commit, then accept it or remove only that Preview.
39
+ - **Local state preservation** — existing staged, unstaged, and untracked Local changes are not automatically folded into the task commit.
40
+ - **Parallel preparation, serialized acceptance** — multiple Isolated Worktrees may prepare tasks concurrently, while one active Preview per Local project prevents review drafts from being written over each other.
41
+ - **Stop on conflict instead of overwriting** — overlapping changes, Local drift, branch movement, or an inseparable delta enters conflict/recovery rather than silently choosing one side.
42
+ - **Task-only commit** — acceptance creates one commit for the isolated task while preserving separable Local work.
43
+ - **Continuous Session iterations** — after delivery and cleanup, iteration + 1 can start in the same Session with the full conversation intact.
44
+ - **Review-to-edit recovery** — an unsynced review does not block discussion; a later file change safely resumes the current iteration first.
45
+ - **Fail-closed recovery** — stale reviews, Local drift, branch changes, concurrent Previews, and uncertain cleanup stop instead of overwriting data.
46
+
47
+ > The current scope is a project-scoped Worktree Session workflow, not a cross-project global Worktree Manager. The project is still experimental; use it first in Git repositories that you can recover independently.
48
+
49
+ ### Parallel tasks and conflict boundaries
50
+
51
+ Multiple tasks can edit, test, and prepare reviews concurrently in separate Worktrees, Workspaces, and Sessions without sharing one checkout. Local acceptance is deliberately serialized: one canonical Local project has one acceptance slot. Until the active Preview is committed or rolled back, another task receives `project_acceptance_busy` instead of layering another write into Local.
52
+
53
+ “Parallel tasks” does not mean “automatically merge every conflict.” If a task overlaps Local changes, its review becomes stale, the branch moves non-fast-forward, or the Host cannot prove that Rollback/Finalize will preserve unrelated work, the operation stops and retains recovery evidence for the user to resolve.
54
+
55
+ ## Workflow
56
+
57
+ ```text
58
+ Local Session
59
+ │
60
+ ├─ Create isolated Worktree Session
61
+ ▼
62
+ Agent edits and validates in the Worktree
63
+ │
64
+ ├─ worktree_ready_for_review
65
+ ▼
66
+ Ready for Review
67
+ │
68
+ ├─ Sync to Local Preview ── Accept and commit
69
+ │ └─ Roll back and continue editing
70
+ ├─ Skip Preview and commit directly
71
+ └─ Discard
72
+ │
73
+ └─ After cleanup: start iteration + 1 in the same Session
74
+ ```
75
+
76
+ ### 1. Create an isolated Session
77
+
78
+ In a blank/new Local Session, enable **Worktree** and confirm creation. Nothing is created before confirmation. After confirmation, the unsent text and image draft is transferred to the new isolated Session.
79
+
80
+ An existing Local Session may also ask the model to call `worktree_create`. The source Session remains Local and is never silently switched to another cwd.
81
+
82
+ ### 2. Work inside the Worktree
83
+
84
+ The agent reads, edits, and validates only inside the isolated cwd. That cwd is a real Git worktree and is registered as a Harness Workspace, so Harness Workspace and Session boundaries remain authoritative.
85
+
86
+ ### 3. Prepare the review
87
+
88
+ When implementation and validation are complete, the agent calls `worktree_ready_for_review` with:
89
+
90
+ - a change summary;
91
+ - changed files;
92
+ - validation status and test commands;
93
+ - a suggested commit message.
94
+
95
+ This stores a review report. It does not write to Local and does not create a commit.
96
+
97
+ ### 4. Choose how to deliver
98
+
99
+ The user can then:
100
+
101
+ - **Sync to Local for review** — create an uncommitted, reversible Preview;
102
+ - **Accept and commit** — commit only the task delta;
103
+ - **Roll back and continue editing** — remove the Preview and return to the Worktree;
104
+ - **Skip review and commit directly** — use the guarded direct-delivery path after explicit confirmation;
105
+ - **Discard** — clean up the task environment when all safety conditions pass.
106
+
107
+ ### 5. Start the next round in the same conversation
108
+
109
+ After a successful commit and cleanup, the current Worktree cwd is removed, but the Session and conversation remain. When the user requests more code or file changes, the plugin can recreate the immutable cwd from the latest Local HEAD and start the next iteration safely.
110
+
111
+ Retained, cleanup-pending, and recovery states are never removed silently. They must be handled before another iteration can begin.
112
+
113
+ ## Screenshots
114
+
115
+ The following screenshots show the primary delivery flow in the order a task normally follows it.
116
+
117
+ ### Create a Worktree Session
118
+
119
+ After Worktree is enabled in a new Local Session, Harness explains the Session-switch boundary. The isolated Session is created and selected only after explicit confirmation.
120
+
121
+ ![Confirm creation and switch to a Worktree Session](docs/screenshots/01-create-worktree.png)
122
+
123
+ ### Prepare the review
124
+
125
+ When implementation and validation finish, the agent prepares a Ready for Review report. The user can inspect the summary and validation evidence before syncing anything to Local.
126
+
127
+ ![Worktree changes ready for review](docs/screenshots/02-ready-for-review.png)
128
+
129
+ ### Review the Local Preview
130
+
131
+ After synchronization, the task delta waits in Local as a reversible Preview. The user can commit it, roll it back and continue editing, or discard the task.
132
+
133
+ ![Task changes waiting for acceptance in Local Preview](docs/screenshots/03-local-preview.png)
134
+
135
+ ### Confirm the commit and choose retention
136
+
137
+ The default path confirms the Commit Message and cleans up the Worktree after submission. When further investigation is useful, the frozen runtime environment can instead be retained for the selected period.
138
+
139
+ | Commit and clean up | Commit and retain the runtime environment |
140
+ | --- | --- |
141
+ | ![Confirm the task-only commit and clean up the Worktree](docs/screenshots/04-commit-confirmation.png) | ![Confirm the task-only commit and retain the runtime environment](docs/screenshots/06-retain-environment.png) |
142
+
143
+ ### Start the next iteration in the same Session
144
+
145
+ After delivery and cleanup succeed, the conversation remains available and can begin another iteration from the latest Local HEAD.
146
+
147
+ ![Delivered Session ready to start the next iteration](docs/screenshots/05-next-iteration.png)
148
+
149
+ ## Design foundation and Harness adaptation
150
+
151
+ The Worktree lifecycle and Git delivery engine are adapted from a mature desktop implementation that has been exercised in real workflows. The goal is not to copy its UI, but to preserve proven safety invariants:
152
+
153
+ - managed checkout registry and revision CAS;
154
+ - canonical path, Git common-dir, and git-dir identity checks;
155
+ - complete fingerprints for staged, unstaged, untracked, binary, and deleted files;
156
+ - receipt-first Local Preview, Rollback, and Finalize;
157
+ - task-only commits that preserve unrelated Local work;
158
+ - internal refs, journal recovery, retention, quarantine, and conservative cleanup;
159
+ - fail closed whenever the Host cannot prove that a write is safe.
160
+
161
+ DeepSeek Harness has a different Host and Session model from the original desktop host, so the integration was adapted rather than copied mechanically:
162
+
163
+ - Harness Workspace and Session cwd are authoritative; the plugin registry is supporting state only;
164
+ - Host capabilities are exposed through strict Typert Remote, while browser UI uses public Harness Client Slots;
165
+ - Local source and Isolated target always use separate Sessions;
166
+ - cleanup does not mutate Harness's persisted Session cwd; the next iteration recreates the same path only after strict identity checks;
167
+ - the model creates targets, resumes editing, and prepares reviews, while user-controlled surfaces own Local writes, commits, and cleanup.
168
+
169
+ See [Session Target porting notes](docs/PORTING.md) for the detailed identity, state, and recovery boundary mapping.
170
+
171
+ ## Requirements
172
+
173
+ - Node.js 20 or newer;
174
+ - DeepSeek Harness `0.1.0-rc.6` package line;
175
+ - Harness Web Client for the complete Worktree creation and acceptance UI;
176
+ - a Git repository as the current Workspace.
177
+
178
+ ## Install
179
+
180
+ Install the npm package:
181
+
182
+ ```bash
183
+ dsh plugin --profile web add dsh-git-worktree
184
+ ```
185
+
186
+ Or install a specific Git tag:
187
+
188
+ ```bash
189
+ dsh plugin --profile web add github:wloops/dsh-git-worktree#v0.3.1
190
+ ```
191
+
192
+ With pnpm 10 or newer, a Git install may require this entry in the profile's `pnpm-workspace.yaml` before retrying:
193
+
194
+ ```yaml
195
+ allowBuilds:
196
+ dsh-git-worktree: true
197
+ ```
198
+
199
+ Start Harness normally after installation and open a Git repository as the Workspace.
200
+
201
+ ## Model tools and user controls
202
+
203
+ ### Model tools
204
+
205
+ | Tool | Purpose |
206
+ | --- | --- |
207
+ | `worktree_create` | Create a managed Worktree from a Local Session and reserve a distinct target Session |
208
+ | `worktree_list` | List Worktrees visible to the current Session in the original project |
209
+ | `worktree_resume_revision` | Invalidate an unsynced review and resume the current iteration without touching Local |
210
+ | `worktree_begin_next_iteration` | Recreate the Worktree cwd for a delivered and successfully cleaned Session |
211
+ | `worktree_ready_for_review` | Save the delivery report and stop for explicit human acceptance |
212
+
213
+ Finish, Discard, Remove, and Local Preview are not model tools. Ordinary discussion leaves a Ready review unchanged; only new code or file work needs to resume Working.
214
+
215
+ ### User controls
216
+
217
+ The Web UI provides the normal create, Preview, rollback, commit, retention, continue-editing, and discard actions. Equivalent Host-controlled operations are also available through `/worktree` commands:
218
+
219
+ ```text
220
+ /worktree status
221
+ /worktree list
222
+ /worktree continue
223
+ /worktree next
224
+ /worktree finalize [<reviewId> <revision>] [cleanup|retain_24h|retain_3d|retain_manual]
225
+ /worktree finish <commit message>
226
+ /worktree discard
227
+ /worktree remove <checkoutId>
228
+ ```
229
+
230
+ `finalize` uses the suggested commit message from the current review. `finish` is the explicit direct-commit path with a user-provided message.
231
+
232
+ ## Safety model
233
+
234
+ Every acceptance operation is revalidated by the Host. Browser display state and model-provided identity data are never treated as authority.
235
+
236
+ Important rules include:
237
+
238
+ - Local source and Isolated target use different Session IDs;
239
+ - an active target Workspace must canonicalize to the managed root recorded by the Host;
240
+ - one canonical Local project can have only one active Preview;
241
+ - Preview receipts and internal refs are persisted before Local writes;
242
+ - Preview, Rollback, Finalize, Discard, and resume-editing paths bind checkout, revision, review, and fingerprint identity;
243
+ - Rollback removes only the delta proven to belong to the Preview and preserves separable Local changes made during review;
244
+ - branch switches, non-fast-forward history, overlapping conflicts, committed Preview bytes, or additional drift enter recovery instead of being overwritten;
245
+ - cleanup verifies managed-path identity, Git metadata, and the final fingerprint; uncertain residue is retained or quarantined;
246
+ - historical records from the old irreversible Apply flow are not automatically finished or discarded.
247
+
248
+ See [Worktree Console architecture](docs/WORKTREE-CONSOLE-ARCHITECTURE.md) for the complete state model and authorization matrix.
249
+
250
+ ## Current limitations
251
+
252
+ - There is no cross-project global Worktree Manager yet.
253
+ - The project-scoped Worktree Console Host capabilities and components remain available, but the visible `conversation.view` tab is not mounted in `v0.3.1`.
254
+ - Workflow `agent({ isolation })` integration is not available in the verified Harness `0.1.0-rc.6` line.
255
+ - Subagents inherit their parent Session cwd; they share the isolated boundary only when the parent is already a Worktree Session.
256
+ - Dependency snapshot/restore and the complete collaborator handoff UI have not yet been implemented.
257
+ - A reviewed stage cannot yet be saved as an internal checkpoint before continuing development.
258
+ - An Isolated Session cannot yet request a bounded transaction to repair the real Local checkout directly.
259
+ - Cleanup removes the current Worktree cwd, but a delivered Session can recreate the path and start another iteration after strict validation.
260
+
261
+ ## Roadmap
262
+
263
+ The following items describe possible directions for continuing the project. They are not release-date commitments.
264
+
265
+ ### Near term
266
+
267
+ - Continue improving marketplace presentation and end-to-end examples.
268
+ - Continue hardening Ready, Preview, Rollback, Finalize, cleanup, and iteration recovery.
269
+ - Improve error categories, recovery guidance, and compatibility across real Harness releases.
270
+ - Re-evaluate mounting the project-scoped Worktree Console tab after the primary flow stabilizes.
271
+
272
+ ### Medium term
273
+
274
+ - Add “save stage and continue” so long tasks can record reviewed stages inside the isolated checkout, continue from a clean worktree, and retain stage history in final acceptance.
275
+ - Evaluate a bounded Local repair transaction: a user-approved temporary authorization tied to the current Local state, allowing an Isolated Session to repair Local through restricted tools without changing its Session Target, then automatically resume the original task.
276
+ - Port dependency snapshot/restore to reduce repeated setup across Worktrees.
277
+ - Complete the collaborator/subagent handoff lifecycle so delegated work can be released and delivered safely.
278
+ - Add richer project-scoped Worktree listing, inspection, retention, and cleanup management.
279
+ - Improve review presentation with clearer diff and validation information without weakening Host authority.
280
+
281
+ ### Long term
282
+
283
+ - Build a cross-project global Worktree Manager.
284
+ - Integrate Workflow-level `agent({ isolation })` when Harness exposes a stable seam.
285
+ - Add richer audit, runtime metrics, and recovery diagnostics.
286
+ - Explore richer multi-task orchestration, serialized acceptance, and cross-Session handoff while preserving explicit human approval for every Local write.
287
+
288
+ ## Local development
289
+
290
+ Install dependencies and run the standard checks:
291
+
292
+ ```bash
293
+ pnpm install
294
+ pnpm run typecheck
295
+ pnpm test
296
+ pnpm run build
297
+ pnpm run check:publish
298
+ ```
299
+
300
+ For an end-to-end local Harness run:
301
+
302
+ ```bash
303
+ pnpm run dev:dsh
304
+ ```
305
+
306
+ This command builds the current checkout, packs a temporary tarball, installs it into the `web` profile, validates the composed configuration, prepares a marker-protected disposable Git fixture, and starts `dsh web` at `http://127.0.0.1:3081` by default. It does not publish packages or push Git refs.
307
+
308
+ Useful variants:
309
+
310
+ ```bash
311
+ # Install and verify the snapshot without starting Web
312
+ pnpm run dev:dsh:install
313
+
314
+ # Verify the already-installed profile
315
+ pnpm run dev:dsh:smoke
316
+
317
+ # Select another Git root, port, profile, or Harness source checkout
318
+ pnpm run dev:dsh -- --repo G:/path/to/repo --port 4090 --profile web
319
+
320
+ # Remove the development install and cached local archives
321
+ pnpm run dev:dsh:remove
322
+ ```
323
+
324
+ ## Documentation
325
+
326
+ - [Session Target porting notes](docs/PORTING.md)
327
+ - [Worktree Console architecture](docs/WORKTREE-CONSOLE-ARCHITECTURE.md)
328
+ - [UI development notes](docs/UI-DEVELOPMENT.md)
329
+ - [Release checklist](docs/RELEASE.md)
330
+ - [Changelog](CHANGELOG.md)
331
+
332
+ ## License
333
+
334
+ [MIT](LICENSE)
package/README.md CHANGED
@@ -4,100 +4,233 @@
4
4
  [![CI](https://github.com/wloops/dsh-git-worktree/actions/workflows/ci.yml/badge.svg)](https://github.com/wloops/dsh-git-worktree/actions/workflows/ci.yml)
5
5
  [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
6
6
 
7
- **Run coding tasks in real Git worktrees, review the result in Local, and commit only after explicit human approval.**
7
+ **让 Agent 在真实 Git Worktree 中执行任务,把结果同步到 Local 验收,并且只在用户明确确认后提交。**
8
8
 
9
- `dsh-git-worktree` is an experimental [DeepSeek Harness](https://github.com/deepseek-ai/DeepSeek-Harness) plugin that turns a Git worktree into an isolated Session Target. The agent works in a separate checkout and Session; the original Local checkout stays under human control.
9
+ `dsh-git-worktree` 是面向 [DeepSeek Harness](https://github.com/deepseek-ai/DeepSeek-Harness) 的实验性 Session Target 插件。每个编码任务都在独立 checkout 和独立 Session 中运行,用户正在使用的 Local 工作区不会直接变成 Agent 的施工现场。
10
10
 
11
- [中文文档](README.zh.md)
11
+ 它不是一个简单的 `git worktree` 命令包装器,而是一套完整的任务交付流程:创建隔离环境、持续修改、生成验收报告、可撤回地同步到 Local、确认后创建单个提交,以及失败时保留恢复证据。
12
12
 
13
- ## Why use it?
13
+ > Worktree 安全基础源自作者内部桌面项目 **Domi** 的实际工作流;本插件已针对 Harness 独立适配,安装和使用均不依赖 Domi。
14
14
 
15
- A normal agent session can modify the same working tree you are using. This plugin separates execution from acceptance:
15
+ [English](README.en.md)
16
16
 
17
- - **Real isolation** — each task gets a distinct Git worktree, Workspace, cwd, and Session ID.
18
- - **Human-gated delivery** — the model can prepare a review, but it cannot commit, discard, or clean up by itself.
19
- - **Reversible Local Preview** — inspect the exact change in Local before committing, then accept it or roll it back.
20
- - **Local changes are preserved** — staged, unstaged, and untracked Local state is kept separate from the task change.
21
- - **Fail-closed recovery** — stale reviews, conflicting edits, changed branches, and uncertain cleanup stop instead of overwriting data.
17
+ ## 它解决什么问题?
22
18
 
23
- > The project is still experimental. It provides a project-scoped Worktree Session workflow, not a cross-project global worktree manager.
19
+ 普通 Agent Session 直接修改当前工作区时,用户容易遇到几个问题:
24
20
 
25
- ## Workflow
21
+ - Agent 的修改与 Local 中已有的 staged、unstaged、untracked 内容混在一起;
22
+ - 多个 Agent 任务共用一个 checkout 时,会相互覆盖文件、切换分支或污染彼此的提交边界;
23
+ - 多个任务同时把结果写入 Local 时,Preview、冲突处理和清理操作容易互相干扰;
24
+ - 任务完成前,用户很难确认哪些修改属于本次任务;
25
+ - “查看结果”常常已经等于“写入 Local”,不容易安全撤回;
26
+ - 提交、清理或恢复操作如果依赖模型自行判断,会放大误操作风险;
27
+ - 长对话完成一轮后,开始下一轮通常需要换 Session、重新解释上下文。
28
+
29
+ 本插件把一次编码任务分成两个边界清晰的阶段:
30
+
31
+ 1. **Agent 在 Isolated Worktree 中施工和验证**;
32
+ 2. **用户在 Local 中验收并决定是否提交**。
33
+
34
+ ## 核心能力
35
+
36
+ - **真实隔离**:每个任务拥有独立的 Git Worktree、Harness Workspace、cwd 和 Session ID。
37
+ - **用户掌握交付权**:模型可以准备验收报告,但不能自行 Preview、Commit、Discard 或删除 Worktree。
38
+ - **可撤回的 Local Preview**:先把任务增量同步到 Local 查看,不创建 Commit;不满意时可以只撤回这次 Preview。
39
+ - **保留 Local 现场**:Local 原有的 staged、unstaged 和 untracked 内容不会被自动混入任务提交。
40
+ - **并行施工、有序验收**:多个 Isolated Worktree 可以并行准备任务,但同一 Local 项目同时只允许一个 active Preview,避免多个验收稿交叉写入。
41
+ - **冲突时停止而非覆盖**:重叠修改、Local 漂移、分支变化或无法安全拆分的增量会进入 conflict/recovery,不自动选择一方覆盖。
42
+ - **单任务提交**:验收通过后,只为本次任务创建一个 Commit,并继续保留可分离的 Local 修改。
43
+ - **同一 Session 连续迭代**:本轮成功交付并 cleanup 后,可在原 Session 中开始 iteration + 1,保留完整对话。
44
+ - **Review 可恢复编辑**:尚未同步的验收稿不会阻断普通讨论;后续需要改文件时,Agent 会先安全恢复当前 iteration。
45
+ - **保守恢复**:Review 过期、Local 漂移、分支变化、并发 Preview 或清理身份不确定时停止写入,不覆盖用户数据。
46
+
47
+ > 当前定位是“项目级 Worktree Session 工作流”,不是跨项目全局 Worktree Manager。项目仍处于实验阶段,建议先在可恢复的 Git 仓库中使用。
48
+
49
+ ### 多任务与冲突边界
50
+
51
+ 多个任务可以各自在独立 Worktree、Workspace 和 Session 中并行修改、测试与准备 Review,不需要共享同一个 checkout。进入 Local 验收时则刻意串行化:同一 canonical Local 项目只有一个 acceptance slot,已有 Preview 未提交或撤回前,其他任务会收到 `project_acceptance_busy`,而不是继续叠加写入。
52
+
53
+ 插件不会把“支持并行任务”解释成“自动合并所有冲突”。如果任务增量与 Local 修改重叠、Review 已过期、分支发生非快进变化,或 Host 无法证明 Rollback/Finalize 能保留其他修改,操作会停止并保留恢复证据,交给用户决定下一步。
54
+
55
+ ## 工作流程
26
56
 
27
57
  ```text
28
58
  Local Session
29
59
  │
30
- ├─ Create isolated Worktree Session
60
+ ├─ 创建隔离的 Worktree Session
31
61
  ▼
32
- Agent edits and validates in the Worktree
62
+ Agent 在 Worktree 中修改、测试
33
63
  │
34
64
  ├─ worktree_ready_for_review
35
65
  ▼
36
66
  Ready for Review
37
67
  │
38
- ├─ Sync to Local Preview ── Accept and commit
39
- │ └─ Roll back and continue editing
40
- ├─ Skip Preview and commit directly
41
- └─ Discard
68
+ ├─ 同步到 Local Preview ── 验收并提交
69
+ │ └─ 撤回 Preview,继续修改
70
+ ├─ 跳过 Preview,直接提交
71
+ └─ 放弃任务
42
72
  │
43
- └─ After cleanup: start iteration + 1 in the same Session
73
+ └─ cleanup 后在原 Session 开始 iteration + 1
44
74
  ```
45
75
 
46
- 1. In a blank Local Session, turn on **Worktree** and confirm creation. The unsent text/image draft moves to the isolated Session; cancelling creates nothing.
47
- 2. For an existing Local Session, the model can call `worktree_create`, after which you open the isolated Session from its ToolView.
48
- 3. The agent edits and validates only inside the isolated cwd.
49
- 4. The agent ends with `worktree_ready_for_review`, including changed files, validation evidence, and a suggested commit message.
50
- 5. You choose what happens next:
51
- - **Sync to Local for review**, then commit or roll the Preview back;
52
- - **Skip review and commit directly**;
53
- - **Discard** the task.
54
- 6. After a successful commit and cleanup, the delivered Session can start the next iteration without losing its conversation. Harness keeps Session cwd immutable, so the plugin recreates only the previously cleaned, Host-owned managed path after strict identity checks.
76
+ ### 1. 创建隔离 Session
77
+
78
+ 在 blank/new Local Session 中打开 **Worktree** 开关并确认。确认之前不会创建 Worktree;确认后,未发送的文字和图片草稿会迁移到新的隔离 Session。
79
+
80
+ 已有 Local Session 也可以由模型调用 `worktree_create` 创建目标 Session。源 Session 始终保持 Local,不会被偷偷切换到另一个 cwd。
81
+
82
+ ### 2. Agent 在 Worktree 中工作
83
+
84
+ Agent 只在隔离 cwd 中读取、修改和验证项目。该 cwd 对应真实 Git Worktree,同时注册为 Harness Workspace,因此 Harness 的 Workspace 和 Session 边界仍然有效。
85
+
86
+ ### 3. 准备验收
87
+
88
+ 实现和验证完成后,Agent 调用 `worktree_ready_for_review`,提交:
89
+
90
+ - 变更摘要;
91
+ - changed files;
92
+ - 验证状态与测试命令;
93
+ - 建议 Commit Message。
94
+
95
+ 该操作只保存验收报告,不写入 Local,也不创建 Commit。
55
96
 
56
- All acceptance paths revalidate the review revision, Worktree HEAD/fingerprint, and Local state before writing. Retained or cleanup-pending environments must be cleaned first; starting another iteration never silently removes them.
97
+ ### 4. 用户决定如何交付
57
98
 
58
- ## Requirements
99
+ 用户可以选择:
59
100
 
60
- - Node.js 20 or newer
61
- - DeepSeek Harness `0.1.0-rc.6` package line
62
- - Harness Web client for the interactive Worktree controls
63
- - A Git repository
101
+ - **同步到 Local 验收**:创建一个未提交、可撤回的 Preview;
102
+ - **验收通过并提交**:只提交本次任务增量;
103
+ - **撤回并继续修改**:移除 Preview,返回原 Worktree;
104
+ - **跳过验收直接提交**:显式确认后走受保护的直接交付路径;
105
+ - **放弃任务**:在满足安全条件后清理任务环境。
64
106
 
65
- ## Install
107
+ ### 5. 在原对话开始下一轮
108
+
109
+ 成功提交并 cleanup 后,本轮 Worktree cwd 会被删除,但 Session 和对话仍然保留。用户提出新的代码或文件修改时,插件可以基于最新 Local HEAD,安全重建该 Session 的 immutable cwd,并进入下一轮 iteration。
110
+
111
+ Retained、cleanup-pending 或 recovery 状态不会被静默清理,必须先完成对应的人工处理。
112
+
113
+ ## 界面预览
114
+
115
+ 以下截图按一次完整任务的实际顺序展示主要交付流程。
116
+
117
+ ### 创建 Worktree Session
118
+
119
+ 在新的 Local Session 中启用 Worktree 后,Harness 会先说明会话切换边界;只有用户确认后才会创建并切换到隔离 Session。
120
+
121
+ ![确认创建并切换到 Worktree Session](docs/screenshots/01-create-worktree.png)
122
+
123
+ ### 准备验收
124
+
125
+ Agent 完成实现和验证后生成 Ready for Review,用户可以查看变更摘要与验证结果,再决定是否同步到 Local。
126
+
127
+ ![Worktree 修改已准备验收](docs/screenshots/02-ready-for-review.png)
128
+
129
+ ### 在 Local Preview 中验收
130
+
131
+ 同步后,本次任务增量会以可撤回的 Local Preview 等待验收;用户可以提交、撤回后继续修改,或放弃任务。
132
+
133
+ ![任务修改正在 Local Preview 中等待验收](docs/screenshots/03-local-preview.png)
134
+
135
+ ### 确认提交与环境保留
136
+
137
+ 默认路径会确认 Commit Message 并在提交后清理 Worktree;需要继续排查时,也可以按所选时长暂时保留冻结的运行环境。
138
+
139
+ | 提交并清理 | 提交并保留运行环境 |
140
+ | --- | --- |
141
+ | ![确认提交任务增量并清理 Worktree](docs/screenshots/04-commit-confirmation.png) | ![确认提交任务增量并保留运行环境](docs/screenshots/06-retain-environment.png) |
142
+
143
+ ### 在同一 Session 开始下一轮
144
+
145
+ 交付与 cleanup 成功后,原对话会保留,并可以基于最新 Local HEAD 开始下一轮修改。
146
+
147
+ ![本轮已交付并可以开始下一轮修改](docs/screenshots/05-next-iteration.png)
148
+
149
+ ## 术语说明
150
+
151
+ 文档保留部分英文术语,以便与 Harness 界面、工具名和错误码对应;首次阅读时可以按下表理解:
152
+
153
+ | 术语 | 中文注解 | 在本项目中的含义 |
154
+ | --- | --- | --- |
155
+ | Session Target | 会话执行目标 | 当前 Session 被固定到的实际工作位置与执行边界,可以是 Local 或 Isolated Worktree |
156
+ | Isolated Worktree / checkout | 隔离 Worktree / checkout | Agent 独立施工的 Git 工作副本,不直接修改用户的 Local checkout |
157
+ | Review / Ready for Review | 验收稿 / 等待验收 | Agent 完成当前阶段后提交的摘要、文件、验证结果和建议 Commit Message |
158
+ | Local Preview | Local 预览 | 将任务增量临时同步到 Local 查看,但暂不创建 Commit |
159
+ | Rollback / Finalize | 撤回预览 / 确认提交 | 分别表示安全移除本次 Preview,或将验收通过的任务增量提交到 Local |
160
+ | acceptance slot | 验收槽位 | 同一 Local 项目唯一的 Preview 写入名额,用于避免多个任务同时写入 Local |
161
+ | cleanup / retention | 清理 / 保留运行环境 | 交付后立即删除 Worktree,或按用户选择暂时保留冻结环境 |
162
+ | iteration | 任务轮次 | 同一 Session 中一次完整的创建、修改、验收与交付周期 |
163
+ | fail closed / recovery | 保守拒绝 / 恢复处理 | 无法证明安全时停止写入并保留证据,而不是自动猜测或覆盖 |
164
+
165
+ ## 设计基础与 Harness 适配
166
+
167
+ 本项目的 Worktree 生命周期与 Git 交付引擎基于一套经过实际使用验证的桌面端实现重新适配。重点不是复制原有界面,而是保留已经验证过的安全不变量:
168
+
169
+ - managed checkout registry 与 revision CAS;
170
+ - canonical path、Git common-dir 和 git-dir 身份校验;
171
+ - staged、unstaged、untracked、binary 和 deletion 状态的完整 fingerprint;
172
+ - receipt-first Local Preview、Rollback 与 Finalize;
173
+ - 只提交任务增量,同时保留 Local 其他修改;
174
+ - internal refs、journal recovery、retention、quarantine 和保守 cleanup;
175
+ - 无法证明安全时 fail closed,而不是猜测后继续写入。
176
+
177
+ DeepSeek Harness 与原桌面端宿主模型不同,因此本插件对产品和权限边界做了重新适配:
178
+
179
+ - Harness 的 Workspace 与 Session cwd 是权威身份,插件 registry 只作为辅助状态;
180
+ - Host 能力通过 strict Typert Remote 暴露,浏览器 UI 使用 Harness 的公开 Client Slots;
181
+ - Local source Session 与 Isolated target Session 始终分离;
182
+ - cleanup 后不修改 Harness 已持久化的 Session cwd,而是在下一轮严格校验后重建同一路径;
183
+ - 模型只负责创建、恢复编辑和准备验收,最终写入 Local、提交与清理由用户入口控制。
184
+
185
+ 详细的身份、状态与恢复边界见 [Session Target 迁移说明](docs/PORTING.md)。
186
+
187
+ ## 环境要求
188
+
189
+ - Node.js 20 或更高版本;
190
+ - DeepSeek Harness `0.1.0-rc.6` 包线;
191
+ - Harness Web Client,用于完整的 Worktree 创建和验收界面;
192
+ - 当前 Workspace 是 Git 仓库。
193
+
194
+ ## 安装
195
+
196
+ 推荐直接安装 npm 包:
66
197
 
67
198
  ```bash
68
- # npm package
69
199
  dsh plugin --profile web add dsh-git-worktree
200
+ ```
70
201
 
71
- # Git tag; prepare builds the Host and Client bundles
72
- dsh plugin --profile web add github:wloops/dsh-git-worktree#v0.3.0
202
+ 也可以安装指定 Git tag:
203
+
204
+ ```bash
205
+ dsh plugin --profile web add github:wloops/dsh-git-worktree#v0.3.1
73
206
  ```
74
207
 
75
- With pnpm 10 or newer, a Git install may require this entry in the profile's `pnpm-workspace.yaml` before retrying:
208
+ 使用 pnpm 10 或更高版本时,Git 源安装可能需要先在 profile 的 `pnpm-workspace.yaml` 中允许该包执行 `prepare`:
76
209
 
77
210
  ```yaml
78
211
  allowBuilds:
79
212
  dsh-git-worktree: true
80
213
  ```
81
214
 
82
- Start Harness normally after installation and open a Git repository as the workspace.
215
+ 安装完成后正常启动 Harness,并打开一个 Git 仓库作为 Workspace。
83
216
 
84
- ## User and model controls
217
+ ## 模型工具与用户入口
85
218
 
86
- ### Model tools
219
+ ### 模型工具
87
220
 
88
- | Tool | Purpose |
221
+ | 工具 | 作用 |
89
222
  | --- | --- |
90
- | `worktree_create` | Create a managed Worktree and reserve a distinct target Session without changing the current Session cwd |
91
- | `worktree_list` | List Worktrees visible to the current Session within the original project |
92
- | `worktree_resume_revision` | Automatically invalidate an unsynced review before new code/file changes and resume the same iteration without touching Local |
93
- | `worktree_begin_next_iteration` | Recreate a successfully cleaned delivered Session cwd for iteration + 1, preserving the same Session and conversation |
94
- | `worktree_ready_for_review` | Save the delivery report and stop for explicit human acceptance |
223
+ | `worktree_create` | 从 Local Session 创建 managed Worktree,并预留独立 target Session |
224
+ | `worktree_list` | 列出当前 Session 在原项目中可见的 Worktree |
225
+ | `worktree_resume_revision` | 使尚未同步的旧 Review 失效,在不触碰 Local 的情况下恢复当前 iteration |
226
+ | `worktree_begin_next_iteration` | 为已交付且 cleanup 完成的 Session 重建下一轮 Worktree cwd |
227
+ | `worktree_ready_for_review` | 保存交付报告并停止,等待用户验收 |
95
228
 
96
- Finish, Discard, and Remove are deliberately excluded from the model tool surface. While an unsynced review is waiting, ordinary discussion continues without changing it; if a follow-up requests code or file changes, the model calls `worktree_resume_revision` automatically. The user does not need to synchronize Local or click a recovery control.
229
+ Finish、Discard、Remove 和 Local Preview 不属于模型工具。普通讨论不会让 Ready Review 失效;只有新的代码或文件修改才需要恢复 Working。
97
230
 
98
- ### User controls
231
+ ### 用户操作
99
232
 
100
- The Web UI provides the normal create, Preview, rollback, commit, retention, and discard actions. The same Host-controlled operations are also available through `/worktree` commands:
233
+ Web UI 提供日常所需的创建、Preview、撤回、提交、保留、继续修改和放弃入口。Host 控制的同类能力也可通过 `/worktree` 命令使用:
101
234
 
102
235
  ```text
103
236
  /worktree status
@@ -110,26 +243,67 @@ The Web UI provides the normal create, Preview, rollback, commit, retention, and
110
243
  /worktree remove <checkoutId>
111
244
  ```
112
245
 
113
- `finalize` uses the suggested commit message from the active review. `finish` is the explicit direct-commit path with a custom message.
246
+ `finalize` 使用当前验收报告中的建议 Commit Message;`finish` 是用户提供自定义消息的显式直接提交路径。
247
+
248
+ ## 安全模型
249
+
250
+ 所有验收操作都由 Host 重新校验,不信任浏览器展示状态或模型输出中的身份信息。
251
+
252
+ 关键规则包括:
253
+
254
+ - Local source 与 Isolated target 使用不同 Session ID;
255
+ - active target 的 Workspace 必须 canonicalize 到 registry 记录的 managed root;
256
+ - 同一 canonical Local 项目同时最多存在一个 active Preview;
257
+ - Preview receipt 和 internal refs 在写入 Local 前持久化;
258
+ - Preview、Rollback、Finalize、Discard 和继续修改都绑定 checkout、revision、review 与 fingerprint;
259
+ - Rollback 只移除可以证明属于本次 Preview 的增量,并尽量保留验收期间新增的无关 Local 修改;
260
+ - branch switch、non-fast-forward、重叠冲突、Preview 已进入 Commit 或额外漂移会进入 recovery,而不是强行覆盖;
261
+ - cleanup 前验证 managed path、Git metadata 和最终 fingerprint;未知残余会保留或 quarantine;
262
+ - 历史不可逆 Apply 记录不会被自动 Finish 或 Discard。
263
+
264
+ 更完整的状态机和权限矩阵见 [Worktree Console 架构](docs/WORKTREE-CONSOLE-ARCHITECTURE.md)。
265
+
266
+ ## 当前限制
114
267
 
115
- ## Safety model
268
+ - 暂无跨项目全局 Worktree Manager(Worktree 管理器);
269
+ - 项目级 Worktree Console(Worktree 管理面板)的 Host 能力和组件仍保留,但 `v0.3.1` 暂不挂载可见的 `conversation.view` 标签页;
270
+ - 在已验证的 Harness `0.1.0-rc.6` 包线中,Workflow `agent({ isolation })` 集成尚不可用;
271
+ - 子 Agent 继承父 Session cwd;只有父 Session 已经位于 Worktree Session 时,子 Agent 才处于相同隔离边界;
272
+ - dependency snapshot/restore(依赖快照与恢复)与完整 collaborator handoff UI(协作者交接界面)尚未实现;
273
+ - 暂不支持把已验收阶段固化为内部检查点后继续开发;
274
+ - 暂不支持 Isolated Session 申请受控事务直接维修真实 Local;
275
+ - cleanup 会删除本轮 Worktree cwd,但已交付 Session 可以在严格校验后重建路径并开始下一轮。
116
276
 
117
- The implementation ports Domi's hardened checkout/apply foundations to Harness's authoritative Workspace and Session cwd model. Important invariants include:
277
+ ## 后续计划
118
278
 
119
- - The initial Local source and isolated target use different Session IDs; later iterations keep the same isolated Session ID.
120
- - An active target is trusted only when its Harness Workspace resolves to the recorded managed root. A cleaned delivered target may temporarily reference its missing immutable cwd only when the Host path identity exactly matches the predecessor record.
121
- - One canonical Local project can have only one active Preview.
122
- - Preview receipts are persisted before Local writes so rollback/finalize can recover after a Host restart.
123
- - Preview, commit, rollback, and resume-revision paths use revision and identity checks; review-based paths bind the review ID, and resume-revision changes only registry delivery state after validating the managed checkout.
124
- - Cleanup verifies path identity, Git metadata, and the final fingerprint; uncertain residue is retained or quarantined.
125
- - Next iteration creation only reuses an absent path from a successfully cleaned predecessor, creates a new checkout record, and preserves the predecessor as recovery evidence.
126
- - Legacy records created by the old irreversible Apply flow are not automatically finished or discarded.
279
+ 以下是继续完善项目的可能方向,不代表已经承诺的发布时间:
127
280
 
128
- For the detailed boundary and recovery design, see [Porting notes](docs/PORTING.md) and [Worktree Console architecture](docs/WORKTREE-CONSOLE-ARCHITECTURE.md).
281
+ ### 近期
129
282
 
130
- ## Local development
283
+ - 持续完善市场展示和端到端使用示例;
284
+ - 继续稳定 Ready(待验收)、Preview(Local 预览)、Rollback(撤回预览)、Finalize(确认提交)、cleanup(清理)与 iteration(任务轮次)恢复流程;
285
+ - 改善错误分类、recovery(恢复处理)指引和真实 Harness 版本兼容性;
286
+ - 根据实际使用反馈,评估重新开放项目级 Worktree Console(Worktree 管理面板)标签页。
131
287
 
132
- Install dependencies and run the standard checks:
288
+ ### 中期
289
+
290
+ - 增加“保存阶段并继续”:让长任务可以把已验收阶段固化到隔离 checkout、清理工作区后继续开发,并在最终验收中保留阶段记录;
291
+ - 评估受控 Local 维修事务:由用户批准一次绑定当前 Local 状态的临时授权,让 Isolated Session 在不改变会话执行目标的情况下通过受限工具修复真实 Local,并自动恢复原任务;
292
+ - 迁移 dependency snapshot/restore(依赖快照与恢复),减少不同 Worktree 间重复安装依赖的成本;
293
+ - 完成 collaborator / subagent handoff(协作者 / 子 Agent 交接)生命周期,让协作任务可以安全释放并交付;
294
+ - 提供更完整的项目级 Worktree 列表、状态检查、保留期与清理管理;
295
+ - 丰富 Review(验收)展示,在不改变 Host 权威边界的前提下提供更清晰的差异和验证信息。
296
+
297
+ ### 长期
298
+
299
+ - 建设跨项目全局 Worktree Manager(Worktree 管理器);
300
+ - 在 Harness 提供稳定接口后接入 Workflow 级 `agent({ isolation })`(工作流级隔离);
301
+ - 增加更完整的审计、运行指标和恢复诊断能力;
302
+ - 探索更完整的多任务并行调度、有序验收与跨 Session handoff(跨 Session 交接),同时继续保持 Local 写入必须由用户确认。
303
+
304
+ ## 本地开发
305
+
306
+ 安装依赖并运行标准检查:
133
307
 
134
308
  ```bash
135
309
  pnpm install
@@ -139,49 +313,38 @@ pnpm run build
139
313
  pnpm run check:publish
140
314
  ```
141
315
 
142
- For an end-to-end local Harness run:
316
+ 端到端启动本地 Harness:
143
317
 
144
318
  ```bash
145
319
  pnpm run dev:dsh
146
320
  ```
147
321
 
148
- This command builds the current checkout, packs it into a temporary local tarball, installs it into the `web` profile, verifies the composed configuration, prepares a marker-protected disposable Git fixture, and starts `dsh web` at `http://127.0.0.1:3081` by default. It does not publish to npm or push Git refs.
322
+ 该命令会构建当前 checkout、打包临时 tarball、安装到 `web` profile、验证组合配置、准备受 marker 保护的临时 Git fixture,并默认在 `http://127.0.0.1:3081` 启动 `dsh web`。它不会发布 npm 包或 push Git refs。
149
323
 
150
- Useful variants:
324
+ 常用变体:
151
325
 
152
326
  ```bash
153
- # Install and verify the snapshot without starting Web
327
+ # 只安装并验证当前快照,不启动 Web
154
328
  pnpm run dev:dsh:install
155
329
 
156
- # Verify the already-installed profile
330
+ # 验证已安装的 profile
157
331
  pnpm run dev:dsh:smoke
158
332
 
159
- # Use an existing Git root, another port, or another profile
333
+ # 指定 Git 根目录、端口或 Harness 源码 checkout
160
334
  pnpm run dev:dsh -- --repo G:/path/to/repo --port 4090 --profile web
161
335
 
162
- # Remove the development install and cached local archives
336
+ # 移除开发安装和缓存的本地归档
163
337
  pnpm run dev:dsh:remove
164
338
  ```
165
339
 
166
- When nearby DeepSeek Harness source checkouts are found, `dev:dsh` prefers a runnable candidate with `node_modules/tsx` installed. Select a checkout in any other location with `DSH_HARNESS_ROOT` or `--harness <path>`. Once a source checkout is selected, plugin installation, config validation, removal, and Web startup all use that source CLI without requiring a globally installed `dsh`. If an explicitly selected checkout has not installed its dependencies, the workflow fails before building and prints the corresponding `pnpm --dir <path> install` command. Only runs without a source checkout fall back to `dsh` on PATH.
167
-
168
- ## Current limitations
169
-
170
- - No cross-project global sidebar manager yet.
171
- - The project-scoped Worktree Console implementation exists, but its visible `conversation.view` tab is not mounted in `v0.3.0` while the primary flow is stabilised.
172
- - In the verified Harness `0.1.0-rc.6` line, Workflow `agent({ isolation })` integration is not available.
173
- - In that Harness line, subagents inherit the parent Session cwd; they are isolated only when the parent is already a Worktree Session.
174
- - Dependency snapshot/restore and the complete collaborator handoff UI are deferred.
175
- - Immediate cleanup removes the isolated cwd, making that Session terminal; continue from Local or start a new iteration.
176
-
177
- ## Documentation
340
+ ## 文档
178
341
 
179
- - [Porting from Domi to Harness](docs/PORTING.md)
180
- - [Worktree Console architecture](docs/WORKTREE-CONSOLE-ARCHITECTURE.md)
181
- - [UI development notes](docs/UI-DEVELOPMENT.md)
182
- - [Release checklist](docs/RELEASE.md)
183
- - [Changelog](CHANGELOG.md)
342
+ - [Session Target 迁移说明](docs/PORTING.md)
343
+ - [Worktree Console 架构](docs/WORKTREE-CONSOLE-ARCHITECTURE.md)
344
+ - [UI 开发说明](docs/UI-DEVELOPMENT.md)
345
+ - [发布清单](docs/RELEASE.md)
346
+ - [变更记录](CHANGELOG.md)
184
347
 
185
- ## License
348
+ ## 许可证
186
349
 
187
350
  [MIT](LICENSE)
@@ -40,7 +40,8 @@ export const REVIEW_CONSOLE_STYLES = String.raw `
40
40
  .dsh-wt-more-menu { position:relative; }
41
41
  .dsh-wt-more-trigger { display:grid; place-items:center; width:32px; height:30px; border:1px solid var(--wt-line); border-radius:8px; cursor:pointer; list-style:none; font-weight:800; letter-spacing:1px; }
42
42
  .dsh-wt-more-trigger::-webkit-details-marker { display:none; }
43
- .dsh-wt-more-content { position:absolute; right:0; bottom:calc(100% + 6px); z-index:40; min-width:150px; padding:4px; border:1px solid var(--wt-line); border-radius:9px; background:Canvas; box-shadow:0 10px 30px color-mix(in srgb, black 18%, transparent); }
43
+ .dsh-wt-more-content { position:absolute; right:0; top:calc(100% + 6px); bottom:auto; z-index:40; min-width:150px; padding:4px; border:1px solid var(--wt-line); border-radius:9px; background:Canvas; box-shadow:0 10px 30px color-mix(in srgb, black 18%, transparent); }
44
+ .dsh-wt-review-dock .dsh-wt-more-content { top:auto; bottom:calc(100% + 6px); }
44
45
  .dsh-wt-more-item { width:100%; border:0; border-radius:6px; padding:7px 9px; background:transparent; color:inherit; text-align:left; font:inherit; cursor:pointer; }
45
46
  .dsh-wt-more-item:hover:not(:disabled) { background:color-mix(in srgb, currentColor 7%, transparent); }
46
47
  .dsh-wt-more-item:disabled { opacity:.5; cursor:not-allowed; }
@@ -1 +1 @@
1
- {"version":3,"file":"review-console.styles.js","sourceRoot":"","sources":["../../../src/client/review-console/review-console.styles.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+E9C,CAAA"}
1
+ {"version":3,"file":"review-console.styles.js","sourceRoot":"","sources":["../../../src/client/review-console/review-console.styles.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgF9C,CAAA"}
@@ -16,6 +16,7 @@ export const WORKTREE_STYLES = String.raw `
16
16
  overflow: hidden;
17
17
  font-size: 13px;
18
18
  }
19
+ .dsh-wt-card[data-tool="worktree_ready_for_review"] { overflow:visible; }
19
20
  .dsh-wt-head { display:flex; align-items:center; gap:10px; padding:10px 12px; min-width:0; }
20
21
  .dsh-wt-mark { width:9px; height:9px; flex:0 0 auto; border-radius:999px; background:var(--wt-green); box-shadow:0 0 0 4px color-mix(in srgb, var(--wt-green) 14%, transparent); }
21
22
  .dsh-wt-card[data-state="running"] .dsh-wt-mark { background:var(--wt-amber); animation:dsh-wt-pulse 1.4s ease-in-out infinite; }
@@ -1 +1 @@
1
- {"version":3,"file":"styles.js","sourceRoot":"","sources":["../../src/client/styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,2CAA2C,CAAA;AAEjF,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0EvC,qBAAqB;CACtB,CAAA"}
1
+ {"version":3,"file":"styles.js","sourceRoot":"","sources":["../../src/client/styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,2CAA2C,CAAA;AAEjF,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2EvC,qBAAqB;CACtB,CAAA"}
package/lib/client.js CHANGED
@@ -5945,7 +5945,8 @@ const REVIEW_CONSOLE_STYLES = String.raw`
5945
5945
  .dsh-wt-more-menu { position:relative; }
5946
5946
  .dsh-wt-more-trigger { display:grid; place-items:center; width:32px; height:30px; border:1px solid var(--wt-line); border-radius:8px; cursor:pointer; list-style:none; font-weight:800; letter-spacing:1px; }
5947
5947
  .dsh-wt-more-trigger::-webkit-details-marker { display:none; }
5948
- .dsh-wt-more-content { position:absolute; right:0; bottom:calc(100% + 6px); z-index:40; min-width:150px; padding:4px; border:1px solid var(--wt-line); border-radius:9px; background:Canvas; box-shadow:0 10px 30px color-mix(in srgb, black 18%, transparent); }
5948
+ .dsh-wt-more-content { position:absolute; right:0; top:calc(100% + 6px); bottom:auto; z-index:40; min-width:150px; padding:4px; border:1px solid var(--wt-line); border-radius:9px; background:Canvas; box-shadow:0 10px 30px color-mix(in srgb, black 18%, transparent); }
5949
+ .dsh-wt-review-dock .dsh-wt-more-content { top:auto; bottom:calc(100% + 6px); }
5949
5950
  .dsh-wt-more-item { width:100%; border:0; border-radius:6px; padding:7px 9px; background:transparent; color:inherit; text-align:left; font:inherit; cursor:pointer; }
5950
5951
  .dsh-wt-more-item:hover:not(:disabled) { background:color-mix(in srgb, currentColor 7%, transparent); }
5951
5952
  .dsh-wt-more-item:disabled { opacity:.5; cursor:not-allowed; }
@@ -6003,6 +6004,7 @@ const WORKTREE_STYLES = String.raw`
6003
6004
  overflow: hidden;
6004
6005
  font-size: 13px;
6005
6006
  }
6007
+ .dsh-wt-card[data-tool="worktree_ready_for_review"] { overflow:visible; }
6006
6008
  .dsh-wt-head { display:flex; align-items:center; gap:10px; padding:10px 12px; min-width:0; }
6007
6009
  .dsh-wt-mark { width:9px; height:9px; flex:0 0 auto; border-radius:999px; background:var(--wt-green); box-shadow:0 0 0 4px color-mix(in srgb, var(--wt-green) 14%, transparent); }
6008
6010
  .dsh-wt-card[data-state="running"] .dsh-wt-mark { background:var(--wt-amber); animation:dsh-wt-pulse 1.4s ease-in-out infinite; }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-git-worktree",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Experimental Git worktree Session Targets for DeepSeek Harness with real isolated sessions, review ToolViews, human-confirmed delivery, and safe cleanup.",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -462,7 +462,7 @@ export function installLocalSnapshot(options) {
462
462
  scripts: {},
463
463
  }
464
464
  writeFileSync(join(stagingRoot, 'package.json'), `${JSON.stringify(stagedManifest, null, 2)}\n`)
465
- for (const entry of ['lib', 'cordis.patch.yml', 'README.md', 'README.zh.md', 'LICENSE']) {
465
+ for (const entry of ['lib', 'cordis.patch.yml', 'README.md', 'README.en.md', 'LICENSE']) {
466
466
  const source = join(options.projectRoot, entry)
467
467
  if (existsSync(source)) copyPackageEntry(source, join(stagingRoot, entry))
468
468
  }
package/README.zh.md DELETED
@@ -1,187 +0,0 @@
1
- # dsh-git-worktree
2
-
3
- [![npm](https://img.shields.io/npm/v/dsh-git-worktree)](https://www.npmjs.com/package/dsh-git-worktree)
4
- [![CI](https://github.com/wloops/dsh-git-worktree/actions/workflows/ci.yml/badge.svg)](https://github.com/wloops/dsh-git-worktree/actions/workflows/ci.yml)
5
- [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
6
-
7
- **让 Agent 在真实 Git Worktree 中完成任务,在 Local 中验收,并且只在用户明确确认后提交。**
8
-
9
- `dsh-git-worktree` 是一个实验性的 [DeepSeek Harness](https://github.com/deepseek-ai/DeepSeek-Harness) 插件。它把 Git Worktree 变成独立的 Session Target:Agent 使用单独的 checkout 和 Session 工作,原始 Local 工作区始终由用户控制。
10
-
11
- [English](README.md)
12
-
13
- ## 为什么需要它?
14
-
15
- 普通 Agent Session 可能直接修改你正在使用的工作区。本插件把“执行任务”和“接受结果”分开:
16
-
17
- - **真实隔离**:每个任务都有独立的 Git Worktree、Workspace、cwd 和 Session ID。
18
- - **用户掌握交付权**:模型可以准备验收报告,但不能自行提交、放弃或清理。
19
- - **可撤回的 Local Preview**:提交前先在 Local 查看精确变更,可以验收提交,也可以撤回后继续修改。
20
- - **保留 Local 现场**:Local 中已有的 staged、unstaged 和 untracked 内容不会被混入任务提交。
21
- - **保守恢复**:历史验收卡、并发修改、分支变化或清理身份不确定时直接停止,不覆盖用户数据。
22
-
23
- > 项目仍处于实验阶段。当前提供的是项目级 Worktree Session 工作流,还不是跨项目的全局 Worktree Manager。
24
-
25
- ## 工作流程
26
-
27
- ```text
28
- Local Session
29
- │
30
- ├─ 创建隔离的 Worktree Session
31
- ▼
32
- Agent 在 Worktree 中修改并验证
33
- │
34
- ├─ worktree_ready_for_review
35
- ▼
36
- 等待验收
37
- │
38
- ├─ 同步到 Local Preview ── 验收并提交
39
- │ └─ 撤回并继续修改
40
- ├─ 跳过 Preview,直接提交
41
- └─ 放弃任务
42
- │
43
- └─ cleanup 后在原 Session 开始 iteration + 1
44
- ```
45
-
46
- 1. 在 blank/new Local Session 中打开 **Worktree** 开关并确认。未发送的文字和图片草稿会迁移到隔离 Session;取消不会创建任何资源。
47
- 2. 已存在的 Local Session 可以由模型调用 `worktree_create`,然后由用户从 ToolView 打开隔离 Session。
48
- 3. Agent 只在隔离 cwd 中修改和验证代码。
49
- 4. Agent 最后调用 `worktree_ready_for_review`,写入变更摘要、验证证据和建议 Commit Message,然后停止。
50
- 5. 用户决定如何处理:
51
- - **同步到 Local 验收**,再提交或撤回 Preview;
52
- - **跳过验收,直接提交**;
53
- - **放弃任务**。
54
- 6. 成功提交并 cleanup 后,可以在原隔离 Session 中开始下一轮,不丢失现有对话。Harness 的 Session cwd 不可变,因此插件只会在严格身份校验后重建上一轮已经清理的 Host-owned managed path。
55
-
56
- 所有验收路径在写入前都会重新校验 review revision、Worktree HEAD/fingerprint 和 Local 状态。Retained 或 cleanup-pending 环境必须先完成清理;开始下一轮不会静默删除这些环境。
57
-
58
- ## 环境要求
59
-
60
- - Node.js 20 或更高版本
61
- - DeepSeek Harness `0.1.0-rc.6` 包线
62
- - 使用 Harness Web Client 才能获得完整交互界面
63
- - 当前 Workspace 必须是 Git 仓库
64
-
65
- ## 安装
66
-
67
- ```bash
68
- # npm 包
69
- dsh plugin --profile web add dsh-git-worktree
70
-
71
- # Git tag;prepare 会构建 Host 和 Client bundle
72
- dsh plugin --profile web add github:wloops/dsh-git-worktree#v0.3.0
73
- ```
74
-
75
- 使用 pnpm 10 或更高版本时,Git 源安装可能需要先在 profile 的 `pnpm-workspace.yaml` 中加入:
76
-
77
- ```yaml
78
- allowBuilds:
79
- dsh-git-worktree: true
80
- ```
81
-
82
- 安装后正常启动 Harness,并以一个 Git 仓库作为 Workspace。
83
-
84
- ## 用户与模型入口
85
-
86
- ### 模型工具
87
-
88
- | 工具 | 作用 |
89
- | --- | --- |
90
- | `worktree_create` | 创建 managed Worktree 并预留独立 target Session,不修改当前 Session cwd |
91
- | `worktree_list` | 列出当前 Session 在原始项目中可见的 Worktree |
92
- | `worktree_resume_revision` | 新的代码/文件修改前自动使未同步 Review 失效,在不触碰 Local 的情况下恢复同一 iteration |
93
- | `worktree_begin_next_iteration` | 为已成功清理的 delivered Session 重建 iteration + 1,并保持同一 Session 与完整对话 |
94
- | `worktree_ready_for_review` | 保存交付报告并停止,等待用户明确验收 |
95
-
96
- Finish、Discard、Remove 不向模型开放,避免用模型参数代替用户授权。未同步 Review 等待期间,普通讨论会直接继续且不改变验收稿;如果 follow-up 要求修改代码或文件,模型会自动调用 `worktree_resume_revision`。用户不需要先同步 Local,也不需要点击恢复编辑。
97
-
98
- ### 用户操作
99
-
100
- Web UI 提供创建、Preview、撤回、提交、保留和放弃等常用操作。Host 控制的同类能力也可以通过 `/worktree` 命令调用:
101
-
102
- ```text
103
- /worktree status
104
- /worktree list
105
- /worktree continue
106
- /worktree next
107
- /worktree finalize [<reviewId> <revision>] [cleanup|retain_24h|retain_3d|retain_manual]
108
- /worktree finish <Commit Message>
109
- /worktree discard
110
- /worktree remove <checkoutId>
111
- ```
112
-
113
- `finalize` 使用当前验收报告中的建议 Commit Message;`finish` 是由用户提供自定义消息的直接提交路径。
114
-
115
- ## 安全模型
116
-
117
- 实现把 Domi 中经过生产验证的 checkout/apply 安全基础迁移到 Harness 的权威 Workspace / Session cwd 模型。关键不变量包括:
118
-
119
- - 初始 Local source 与 isolated target 使用不同的 Session ID;后续 iteration 保持同一个 isolated Session ID。
120
- - 活动 target 的 Harness Workspace 必须解析到 Host 记录的 managed root。已清理的 delivered target 只在 Host Workspace 原始路径与 predecessor 记录精确一致时,才允许暂时引用缺失的 immutable cwd。
121
- - 同一 canonical Local 项目同时只允许一个活动 Preview。
122
- - 在写入 Local 前先持久化 Preview receipt,使 Host 重启后仍可恢复 rollback/finalize。
123
- - Preview、Commit、rollback 与 resume-revision 路径都使用 revision 和身份校验;基于验收报告的路径绑定 review ID,resume-revision 在验证 managed checkout 后只改变 registry delivery state。
124
- - 清理前验证路径身份、Git 元数据和最终 fingerprint;无法确认的残余会保留或 quarantine。
125
- - 下一轮只复用已成功清理且当前不存在的 predecessor path,创建新的 checkout record,并保留上一轮记录作为恢复证据。
126
- - 旧版不可逆 Apply 流程产生的历史记录不会被自动 Finish 或 Discard。
127
-
128
- 详细边界与恢复设计见 [Domi 到 Harness 的迁移说明](docs/PORTING.md) 和 [Worktree Console 架构](docs/WORKTREE-CONSOLE-ARCHITECTURE.md)。
129
-
130
- ## 本地开发
131
-
132
- 安装依赖并运行标准检查:
133
-
134
- ```bash
135
- pnpm install
136
- pnpm run typecheck
137
- pnpm test
138
- pnpm run build
139
- pnpm run check:publish
140
- ```
141
-
142
- 端到端启动本地 Harness:
143
-
144
- ```bash
145
- pnpm run dev:dsh
146
- ```
147
-
148
- 该命令会构建当前 checkout,将其打成临时本地 tarball,安装到 `web` profile,验证组合配置,准备受 marker 保护的临时 Git fixture,并默认在 `http://127.0.0.1:3081` 启动 `dsh web`。它不会发布 npm 包,也不会 push Git refs。
149
-
150
- 常用变体:
151
-
152
- ```bash
153
- # 只安装并验证当前快照,不启动 Web
154
- pnpm run dev:dsh:install
155
-
156
- # 验证已经安装的 profile
157
- pnpm run dev:dsh:smoke
158
-
159
- # 使用现有 Git 根目录、其他端口或其他 profile
160
- pnpm run dev:dsh -- --repo G:/path/to/repo --port 4090 --profile web
161
-
162
- # 移除开发安装和缓存的本地归档
163
- pnpm run dev:dsh:remove
164
- ```
165
-
166
- 如果发现附近的 DeepSeek Harness 源码 checkout,`dev:dsh` 会优先选择已经安装 `node_modules/tsx`、可直接运行的候选;源码位于任意其他目录时,可以通过 `DSH_HARNESS_ROOT` 或 `--harness <path>` 指定。选择源码 checkout 后,插件安装、配置验证、移除和 Web 启动都会使用该源码 CLI,不再要求全局安装 `dsh`;显式指定的 checkout 尚未安装依赖时,脚本会在构建前提示对应的 `pnpm --dir <path> install` 命令。只有未选择源码 checkout 时才回退到 PATH 中的 `dsh`。
167
-
168
- ## 当前限制
169
-
170
- - 暂无跨项目全局侧栏 Manager。
171
- - 项目级 Worktree Console 实现仍保留,但 `v0.3.0` 暂不挂载可见的 `conversation.view` 标签页,当前优先稳定主流程。
172
- - 在已验证的 Harness `0.1.0-rc.6` 包线中,Workflow `agent({ isolation })` 集成尚不可用。
173
- - 在该 Harness 包线中,子 Agent 继承父 Session cwd;只有父 Session 已经是 Worktree Session 时才处于隔离环境。
174
- - dependency snapshot/restore 和完整 collaborator handoff UI 尚未实现。
175
- - 选择立即清理后,隔离 cwd 会被删除,该 Session 随即进入终态;后续应回到 Local 或开始新一轮任务。
176
-
177
- ## 文档
178
-
179
- - [Domi 到 Harness 的迁移说明](docs/PORTING.md)
180
- - [Worktree Console 架构](docs/WORKTREE-CONSOLE-ARCHITECTURE.md)
181
- - [UI 开发说明](docs/UI-DEVELOPMENT.md)
182
- - [发布清单](docs/RELEASE.md)
183
- - [变更记录](CHANGELOG.md)
184
-
185
- ## 许可证
186
-
187
- [MIT](LICENSE)