@laoyuehanni/dsh-git-worktree 0.4.13 → 0.4.15

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/README.md CHANGED
@@ -1,94 +1,165 @@
1
+ <div align="center">
2
+
3
+ <img src="./icon.svg" width="64" height="64" alt="dsh-git-worktree icon" />
4
+
1
5
  # dsh-git-worktree
2
6
 
3
- [![Awesome DSH Plugin](https://awesome-dsh-plugin.com/badge.svg)](https://awesome-dsh-plugin.com)
7
+ **IDEA-style branch picker, commit graph, non-blocking git actions & worktree isolation for [DeepSeek Harness (dsh)][dsh].**
4
8
 
5
- ![dsh-git-worktree in the Web UI](docs/images/gitworktree.png)
9
+ <p>
10
+ <a href="https://awesome-dsh-plugin.com"><img src="https://awesome-dsh-plugin.com/badge.svg" alt="awesome · DSH plugin" height="20" /></a>
11
+ <a href="https://www.npmjs.com/package/@laoyuehanni/dsh-git-worktree"><img src="https://img.shields.io/npm/v/%40laoyuehanni%2Fdsh-git-worktree?color=cb3837" alt="npm version" height="20" /></a>
12
+ <a href="https://www.npmjs.com/package/@laoyuehanni/dsh-git-worktree"><img src="https://img.shields.io/npm/dm/%40laoyuehanni%2Fdsh-git-worktree?color=0ea5e9" alt="npm downloads" height="20" /></a>
13
+ <a href="https://github.com/deepseek-ai/deepseek-harness"><img src="https://img.shields.io/badge/dsh-%3E%3D0.2.0--rc.1-6366f1" alt="dsh >= 0.2.0-rc.1" height="20" /></a>
14
+ <a href="./LICENSE"><img src="https://img.shields.io/github/license/LaoYueHanNi/dsh-git-worktree" alt="MIT License" height="20" /></a>
15
+ </p>
6
16
 
7
- [简体中文](./README.zh.md) | English
17
+ [简体中文](./README.zh.md) · **English**
8
18
 
9
- A dsh plugin for simple branch & worktree management in the Web UI. The composer tool row shows the current branch: pick another to switch in place, or flip the **Worktree** toggle to get an isolated worktree as a real workspace — as shown in the screenshot above.
19
+ [Install](#install) · [Features](#features) · [Worktree Isolation & Manager](#4-worktree-isolation-removal--manager) · [Development](#development)
10
20
 
11
- [dsh]: https://github.com/cordiverse/dsh
21
+ </div>
12
22
 
13
- Repo: <https://github.com/LaoYueHanNi/dsh-git-worktree>
23
+ <p align="center">
24
+ <img src="docs/images/gitworktree.png" alt="dsh-git-worktree in the Web UI" width="100%" />
25
+ </p>
14
26
 
15
- > [!IMPORTANT]
16
- > **GitHub direct installs have ended** — the repository no longer carries prebuilt output. Install from npm instead:
17
- >
18
- > ```sh
19
- > dsh plugin --profile web add @laoyuehanni/dsh-git-worktree
20
- > ```
21
- >
22
- > **Upgrading from a legacy `github:` install (≤ 0.3.2, package name `dsh-git-worktree`)?** An in-place `update` fails to load — remove the old name first, then add again. Worktree folders and the plugin's settings carry over untouched.
27
+ ---
23
28
 
24
- ## Features
29
+ ## Highlights
25
30
 
26
- - **Commit graph**: expand the branch popup in place to browse branches on the left and their real commit history and merge graph on the right. Browsing does not check out a branch. Select a commit to see its author, date, full message and file summary; bodies start with a three-line preview and expand into an internally scrolling area. History loads the next page when its list scrolls to the end, and a Load more button remains; search covers loaded titles and hashes. The author menu lists every author on the branch and keeps that list in memory for the commit; a branch update, fetch, or reload drops the cache.
27
- - **IDEA-style branch picker**: the branch menu treats `/` as a folder hierarchy — collapsible folders, last-segment labels, the checked-out branch's chain opens centered. Local and remote branches render as two collapsible groups (a single remote strips its prefix), with bottom search (ancestor folders kept, hits highlighted), locate-current-branch and expand/collapse tools, and green ↗N / blue ↙N divergence marks on tracking branches.
28
- - **Remote branch checkout**: pick `origin/feat-x` in the remote group and it checks out in place with a tracking branch directly (no confirmation); the worktree toggle sends the pick to an isolated worktree instead.
29
- - **Row context menu**: right-click a branch row for six verbs — check out (immediate, no confirmation), new branch, new branch and check out, rename branch (local rows), delete branch (local rows, the safe `-d`: git refuses unmerged commits and occupied branches), copy branch; a worktree row offers go-to-worktree, copy path, and remove worktree. Second-level dialogs open IN PLACE of the menu; in-place actions keep the menu open, so rows can be acted on in a run. Keyboard: arrow keys + Enter.
30
- - **Worktree quick hop**: the main checkout's blank-session menu groups branches held by live worktrees under **Worktrees** (hover shows the directory) — the row menu's "Go to this worktree" hops straight into that directory and starts a fresh session.
31
- - **Branch switching**: pick a branch — an in-place switch, no confirmation. Inside a linked worktree the entry scopes down: other branches stay listed but dimmed, with a hint to act from the main checkout; a started session's menu shows only its own branch (fetch and update still work).
32
- - **Create from any branch, rename in place**: right-clicking any branch row creates FROM that branch (checkouts untouched) or creates-and-checks-out (checked out on the spot); the create flyout validates as you type (git ref rules plus a duplicate check) and fires in one stroke, a failure keeping it open for a renamed retry. Local rows rename in place too.
33
- - **Remote sync**: the last toolbar tool fetches every remote and prunes stale tracking branches — the list refreshes in place, no terminal round-trip.
34
- - **Live progress**: fetch, update and push run under a floating card (like IDEA's background task) that shows the remote, git's own stage, count and speed, and a × to cancel — it never blocks the page, survives switching sessions, and a long transfer is no longer cut off after 20 or 120 seconds (only five silent minutes end it). Other git actions on that directory wait until it finishes; the fast-forward step at the end of an update can no longer be cancelled.
35
- - **Branch push**: **Push** on local and worktree rows opens a compact review dialog. Choose a remote only when several exist, edit the target branch (Enter applies it; the editor closes only with Enter, Esc or ×, and a click elsewhere never closes it or the dialog), and scroll first-line commit subjects independently of the fixed footer. Local commits appear while the remote is checked in the background; pushing is enabled only after verification. Optional tags support **All** or **Follow commits**. The split menu offers **Force push** with an explicit lease that rejects remote updates made after preview. Push acts on the selected branch without switching checkouts or committing working files; clicking Push closes the dialog and the push continues under the progress card (cancel any time); a failed push brings the dialog back with the reason and your previous remote, target and tags, explains the usual causes (remote moved on, expired lease, protected branch, authentication) and re-reads the destination for the retry. Green ↗N / blue ↙N show divergence, a green ↗ without a number marks an unpublished branch (shown only where the repository has a remote), and `!` marks a missing upstream.
36
- - **Branch update**: update the CURRENT branch to its upstream (fast-forward only), from the toolbar or the current row's context menu; divergence, a missing upstream, or conflicting uncommitted changes are refused with git's own explanation — the plugin never stashes or rewrites history on your behalf.
37
- - **Worktree isolation**: in a session that has not started, right-clicking any branch row offers **Create worktree** (reuse or fresh directory) or **New branch and worktree** (cut a new branch off that row, name typed by hand); confirming isolates into `<repo>/.dsh/gitworktree/<branch>/` inside the repository (locally ignored through `.git/info/exclude` — the repo's `git status` stays clean) and registers a real workspace, with same-branch re-creates reusing the existing worktree wherever it lives. Once the session starts the directory is fixed — the worktree verbs hide along with the Worktrees group.
38
- - **Worktree removal**: the **Worktrees** group's row menu (and the manager dialog) offers **Remove worktree** — the confirm first counts uncommitted files (red) and ahead commits, and warns the workspace's sessions will be archived; confirming removes the git worktree (the branch itself survives), then archives the sessions and drops the workspace registration. A git failure leaves the DSH side untouched and retries in place. A directory with a running session withholds the verb.
39
- - **Worktree manager**: the plugin's configuration page on **Settings → Plugins** opens a dialog listing every worktree across both storage locations — the per-repository `.dsh/gitworktree` layouts (new) and the legacy central root (old, kept for existing worktrees) — grouped by repository with a source badge, orphan directories included.
40
- - **Legacy storage, read-only**: the same page shows the historical central storage root (`~/.dsh/gitworktree` by default) read-only — existing worktrees stay put and keep working; new ones are created inside their repository. A legacy `~/.dsh/gitworktree/settings.json` value migrates automatically on upgrade.
31
+ | Capability | What you get |
32
+ | --- | --- |
33
+ | **IDEA-Style Branch Picker** | `/` folder hierarchy, local & remote groups, instant search, locate-current-branch, and colored `↗N` / `↙N` / `↗` / `!` tracking marks. |
34
+ | **In-Place Commit Graph** | Expand the popup to browse real commit history & merge graphs across any branch without switching checkouts. |
35
+ | **One-Click Worktree Isolation** | Isolate sessions into `<repo>/.dsh/gitworktree/<branch>/` as real DSH workspaces while keeping the main repo's `git status` clean. |
36
+ | **Safe Push, Update & Sync** | Compact push review dialog with tag options and explicit `force-with-lease`, fast-forward-only updates, and non-blocking floating progress cards. |
37
+ | **Cross-Repo Worktree Manager** | Manage per-repo and legacy central worktrees from **Settings → Plugins**, with uncommitted-file warnings and safe session archival on removal. |
41
38
 
42
- > [!NOTE]
43
- > - The native sidebar is untouched: worktrees are ordinary registered workspaces, and the workspace tree nests the per-repository layouts under their repository automatically (existing centrally-stored worktrees keep their old location — only new ones nest).
44
- > - `git clean -xdff` (double `-f`) deletes the in-repository worktree directories (a single `-f` skips nested repositories). `git worktree prune` restores the registrations afterwards, but uncommitted work inside them is lost.
45
- > - If every workspace of a repository is deregistered, its worktrees no longer appear in the manager (or the auto-prune); re-register any directory of that repository to bring them back.
39
+ ---
46
40
 
47
41
  ## Install
48
42
 
43
+ Requires the `web` profile (`dsh web`) and **dsh `0.2.0-rc.1`** or newer.
44
+
49
45
  ```sh
50
46
  dsh plugin --profile web add @laoyuehanni/dsh-git-worktree
51
47
  ```
52
48
 
53
- > The package declares `dsh.bundle`, so `add` wires the plugin into the profile's layer stack automatically — no config editing needed. Requires the `web` profile (`dsh web`) and a dsh **0.2.0-rc.1** (or later) host.
49
+ > [!TIP]
50
+ > The package declares `dsh.bundle`, so `add` wires the plugin into the profile's layer stack automatically — no manual config editing needed.
54
51
 
55
- Running a dsh **0.1.2 alpha** host? Install the dedicated compatibility build instead:
52
+ **Update & Remove**
56
53
 
57
54
  ```sh
58
- dsh plugin --profile web add @laoyuehanni/dsh-git-worktree@dsh-alpha
55
+ # Update
56
+ dsh plugin --profile web update @laoyuehanni/dsh-git-worktree
57
+
58
+ # Remove (keeps worktree folders at both storage locations; settings stay in the dsh settings document)
59
+ dsh plugin --profile web remove @laoyuehanni/dsh-git-worktree
59
60
  ```
60
61
 
61
- > `@dsh-alpha` is a dist-tag resolving to the latest alpha-host compatibility build (currently `0.4.3-dsh-0.1.2-alpha.5`) with peers pinned to the alpha line — a plain `update` never mixes the two channels. On 0.2.0-rc.1 or later, use the default line above.
62
+ <details>
63
+ <summary>Running dsh <code>0.1.2 alpha</code> or upgrading from a legacy <code>github:</code> install (≤ 0.3.2)?</summary>
62
64
 
63
- ## Update
65
+ **For dsh `0.1.2 alpha` hosts**, install the dedicated compatibility dist-tag (currently `0.4.3-dsh-0.1.2-alpha.5`, peers pinned so plain `update` never mixes channels):
64
66
 
65
67
  ```sh
66
- dsh plugin --profile web update @laoyuehanni/dsh-git-worktree
68
+ dsh plugin --profile web add @laoyuehanni/dsh-git-worktree@dsh-alpha
67
69
  ```
68
70
 
69
- ## Remove
71
+ **Upgrading from a legacy `github:` install (≤ 0.3.2, package name `dsh-git-worktree`)?** GitHub direct installs have ended and an in-place `update` fails to load — remove the old name first, then install from npm:
70
72
 
71
73
  ```sh
72
- dsh plugin --profile web remove @laoyuehanni/dsh-git-worktree
74
+ dsh plugin --profile web remove dsh-git-worktree
75
+ dsh plugin --profile web add @laoyuehanni/dsh-git-worktree
73
76
  ```
74
77
 
75
- Worktree folders are kept at both locations (the per-repository `.dsh/gitworktree` layouts and the legacy central root); the plugin's own settings live in the dsh settings document.
78
+ Existing worktree folders and plugin settings carry over untouched.
76
79
 
77
- ## Development
80
+ </details>
81
+
82
+ ---
83
+
84
+ ## Features
85
+
86
+ ### 1. IDEA-Style Branch Picker & Commit Graph
87
+
88
+ - **Hierarchical branch tree**: treats `/` as collapsible folders with last-segment labels and centers the checked-out branch's chain on open. Local and remote branches split into two collapsible groups (a single remote strips its prefix).
89
+ - **Search & tracking indicators**: bottom search preserves ancestor folders and highlights hits; toolbar buttons locate the current branch and expand/collapse all. Tracking rows show green `↗N` / blue `↙N` divergence, a bare green `↗` for unpublished branches (only when the repo has a remote), and `!` for missing upstreams.
90
+ - **In-place commit graph**: expand the branch popup to browse branches on the left and their real commit history and merge graph on the right without checking anything out. Select a commit for author, date, full message (3-line preview expanding into a scrollable body), and file summary.
91
+
92
+ <details>
93
+ <summary>Details: Commit graph pagination, search & author cache</summary>
94
+
95
+ - History automatically loads the next page when scrolled to the bottom (a **Load more** button remains available), and search filters loaded titles and hashes.
96
+ - The author filter lists every author on the branch and caches that list in memory for the commit; any branch update, fetch, or reload drops the cache.
97
+
98
+ </details>
78
99
 
79
- Build once, install a symlink, iterate:
100
+ ---
101
+
102
+ ### 2. Branch Actions & Row Context Menu
103
+
104
+ - **One-click switching & remote checkout**: pick any local branch for an immediate `git switch` (no confirmation), or pick `origin/feat-x` to check out in place with a tracking branch automatically. Inside a linked worktree, other branches stay listed but dimmed (hinting to act from the main checkout); a started session's menu scopes down to its own branch (fetch and update still work).
105
+ - **Row context menu (keyboard: arrow keys + Enter)**: right-click any branch row for **Check out**, **New branch**, **New branch and check out**, **Rename** (local), **Delete** (local, safe `-d` — git refuses unmerged commits or occupied branches), and **Copy branch**; worktree rows offer **Go to this worktree**, **Copy path**, and **Remove worktree**.
106
+ - **In-place flyouts**: secondary dialogs (create / rename / confirm) open in place of the menu, validate git ref rules and duplicates as you type, and keep the menu open after in-place actions so you can act on multiple rows in a run (failures keep the flyout open for retry).
107
+
108
+ ---
109
+
110
+ ### 3. Remote Sync, Fast-Forward Update, Push & Live Progress
111
+
112
+ - **Remote sync**: the last toolbar button fetches every remote and prunes stale tracking branches, refreshing the list in place without a terminal round-trip.
113
+ - **Fast-forward branch update**: update the current branch to its upstream from the toolbar or row menu. Divergence, missing upstreams, or conflicting working-tree changes are refused with git's own message — the plugin never stashes or rewrites history on your behalf.
114
+ - **Compact branch push**: right-click **Push** on any local or worktree row to preview local commits (independent scroll above a fixed footer) while verifying the remote in the background, without switching checkouts or committing working files. Supports tag options (**All** / **Follow commits**) and **Force push** with an explicit lease (`--force-with-lease`).
115
+ - **Floating live progress card**: fetch, update, and push run under a non-blocking IDEA-style floating card showing remote, git stage, count, speed, and a `×` cancel button. Survives switching sessions; long transfers are no longer killed by 20s/120s timeouts (only 5 silent minutes abort them).
116
+
117
+ <details>
118
+ <summary>Details: Push dialog behavior & concurrency rules</summary>
119
+
120
+ - **Remote & target editing**: the remote selector appears only when multiple remotes exist; target branch editing applies on `Enter` and closes only via `Enter`, `Esc`, or `×` (clicking outside never dismisses it or the push dialog).
121
+ - **Failure recovery**: clicking **Push** closes the dialog and continues in the progress card; if push fails, the dialog reopens with the reason (remote moved on, expired lease, protected branch, auth), restores your previous remote/target/tag choices, and re-reads the destination for retry.
122
+ - **Directory serialization**: other git actions on the same directory wait until the active transfer finishes; the final fast-forward step of an update cannot be cancelled once started.
123
+
124
+ </details>
125
+
126
+ ---
127
+
128
+ ### 4. Worktree Isolation, Removal & Manager
129
+
130
+ - **Worktree isolation**: in a blank session, right-click any branch row for **Create worktree** or **New branch and worktree** (or flip the worktree toggle when picking a remote branch). Isolates into `<repo>/.dsh/gitworktree/<branch>/` (locally ignored via `.git/info/exclude` so `git status` stays clean) and registers a real workspace; recreating the same branch reuses its existing worktree wherever it lives. Once a session starts, the directory is locked and worktree creation verbs hide.
131
+ - **Worktree quick hop**: the main checkout's blank-session menu groups live worktree branches under **Worktrees** (hover shows the path); **Go to this worktree** jumps straight into that directory for a fresh session.
132
+ - **Safe worktree removal**: available from the **Worktrees** row menu and the manager dialog (disabled while a session is running). The confirmation dialog counts uncommitted files (red) and ahead commits, warns that workspace sessions will be archived, removes the git worktree (keeping the branch), and archives sessions / drops workspace registration only after git succeeds.
133
+ - **Worktree manager & legacy storage**: open from **Settings → Plugins** to view every worktree across both per-repository `.dsh/gitworktree` layouts and the read-only legacy central root (`~/.dsh/gitworktree` by default, auto-migrating `~/.dsh/gitworktree/settings.json`), grouped by repository with source badges and orphan directories included; each row shows whether it is attached as a standalone workspace or a session directory.
134
+ - **Blank name = random branch**: when cutting a new branch into a worktree, leave the name empty to get `<base>-<4 hex>`, avoiding existing branches and folders.
135
+ - **Official entry takeover** (setting "Take over official new-worktree entry", on by default): hides DSH's own new-worktree control in the top-right of blank sessions so worktrees are created from the branch menu, and withdraws any leftover official worktree request on that session to prevent nested creation. The changes and review panels are unaffected.
136
+ - **Session directory mode** (setting "Switch worktree directory in current workspace", off by default): worktrees are no longer registered as standalone workspaces; the session's working directory moves inside its repository workspace, as DSH's own worktrees do. A new worktree is created only when the first message is sent: a pending bar above the composer can be cancelled until then, creation reports each phase, and a failure offers Retry or Continue without worktree. Opening an existing worktree that already has a standalone workspace enters that workspace.
137
+ - **Official worktree management** (setting "Manage official worktrees", off by default): the manager also lists `<repo>/.agents/worktrees` under a "DSH official" group, which can be opened and removed manually but is never auto-pruned.
138
+
139
+ > [!NOTE]
140
+ > - **Native sidebar untouched**: worktrees are ordinary registered workspaces, and the workspace tree nests per-repository layouts under their repository automatically (legacy centrally-stored worktrees keep their old location). Session directory mode adds no workspace; worktree sessions in both modes show a worktree badge on their row.
141
+ > - A pending worktree in session directory mode lives only in the dsh server's memory: restarting dsh or reloading the plugin drops the pending bar, and the worktree must be chosen again.
142
+ > - **`git clean -xdff` (double `-f`)** deletes in-repository worktree directories (a single `-f` skips nested repos); `git worktree prune` restores registrations afterwards, but uncommitted work inside them is lost.
143
+ > - If every workspace of a repository is deregistered, its worktrees no longer appear in the manager or auto-prune; re-register any directory of that repository to bring them back.
144
+
145
+ ---
146
+
147
+ ## Development
80
148
 
81
149
  ```sh
82
150
  pnpm install
83
151
  pnpm build:all
84
152
  pnpm test # vitest
85
- node scripts/smoke.mjs # real-git smoke over the built lib
153
+ node scripts/smoke.mjs # real-git smoke over the built lib
86
154
  dsh plugin --profile web add link:D:/Code/dsh-worktree
87
155
  ```
88
156
 
89
- Rebuild and restart `dsh web` to apply changes (`pnpm watch:client` in the plugin directory hot-reloads the client). No `prepare` script by design — `lib/` never enters the repo; `pnpm publish` builds it fresh into the tarball.
157
+ Rebuild and restart `dsh web` to apply host changes, or run `pnpm watch:client` for client hot reload. `lib/` is intentionally excluded from git and built fresh on `pnpm publish`.
90
158
 
91
- Temporary host-only mount (this launch only, no profile changes): create a `cordis.yml` next to the repo pointing at the built host half (Windows needs the `file:///` form), then launch with it:
159
+ <details>
160
+ <summary>Temporary host-only mount (without modifying profile)</summary>
161
+
162
+ Create a `cordis.yml` next to the repo pointing at the built host entry (Windows requires the `file:///` form):
92
163
 
93
164
  ```yml
94
165
  - insert:
@@ -96,8 +167,16 @@ Temporary host-only mount (this launch only, no profile changes): create a `cord
96
167
  name: 'file:///D:/Code/dsh-worktree/lib/index.js'
97
168
  ```
98
169
 
170
+ Then launch with:
171
+
99
172
  ```sh
100
173
  dsh web --patch <plugin-dir>/cordis.yml
101
174
  ```
102
175
 
103
- Only the host half mounts in this mode (the `/plugin/git-worktree/*` routes keep working); for UI work use the `link:` install above.
176
+ Only the host half mounts in this mode (the `/plugin/git-worktree/*` routes keep working); for UI development use the `link:` install above.
177
+
178
+ </details>
179
+
180
+ ---
181
+
182
+ [dsh]: https://github.com/deepseek-ai/deepseek-harness
package/README.zh.md CHANGED
@@ -1,94 +1,165 @@
1
+ <div align="center">
2
+
3
+ <img src="./icon.svg" width="64" height="64" alt="dsh-git-worktree 图标" />
4
+
1
5
  # dsh-git-worktree
2
6
 
3
- [![Awesome DSH Plugin](https://awesome-dsh-plugin.com/badge.svg)](https://awesome-dsh-plugin.com)
7
+ **面向 [DeepSeek Harness (dsh)][dsh] 的 IDEA 风格分支管理、提交图谱、实时 Git 操作与 Worktree 隔离插件。**
4
8
 
5
- ![Web 界面中的 dsh-git-worktree](docs/images/gitworktree_zh.png)
9
+ <p>
10
+ <a href="https://awesome-dsh-plugin.com"><img src="https://awesome-dsh-plugin.com/badge.svg" alt="awesome · DSH plugin" height="20" /></a>
11
+ <a href="https://www.npmjs.com/package/@laoyuehanni/dsh-git-worktree"><img src="https://img.shields.io/npm/v/%40laoyuehanni%2Fdsh-git-worktree?color=cb3837" alt="npm version" height="20" /></a>
12
+ <a href="https://www.npmjs.com/package/@laoyuehanni/dsh-git-worktree"><img src="https://img.shields.io/npm/dm/%40laoyuehanni%2Fdsh-git-worktree?color=0ea5e9" alt="npm downloads" height="20" /></a>
13
+ <a href="https://github.com/deepseek-ai/deepseek-harness"><img src="https://img.shields.io/badge/dsh-%3E%3D0.2.0--rc.1-6366f1" alt="dsh >= 0.2.0-rc.1" height="20" /></a>
14
+ <a href="./LICENSE"><img src="https://img.shields.io/github/license/LaoYueHanNi/dsh-git-worktree" alt="MIT License" height="20" /></a>
15
+ </p>
6
16
 
7
- 简体中文 | [English](./README.md)
17
+ **简体中文** · [English](./README.md)
8
18
 
9
- 一个 [dsh] 插件:在 Web 界面进行简单的分支与 worktree 管理。输入框工具行显示当前分支 —— 选其他分支原地切换;勾选**「工作树」**则获得一个注册为真实工作区的隔离 worktree,效果见上图。
19
+ [快速安装](#安装) · [核心功能](#核心功能) · [Worktree 隔离与管理](#4-worktree-隔离删除与跨仓库管理) · [本地开发](#开发)
10
20
 
11
- [dsh]: https://github.com/cordiverse/dsh
21
+ </div>
12
22
 
13
- 仓库:<https://github.com/LaoYueHanNi/dsh-git-worktree>
23
+ <p align="center">
24
+ <img src="docs/images/gitworktree_zh.png" alt="Web 界面中的 dsh-git-worktree" width="100%" />
25
+ </p>
14
26
 
15
- > [!IMPORTANT]
16
- > **GitHub 直装已终止**——仓库不再携带构建产物,请改从 npm 安装:
17
- >
18
- > ```sh
19
- > dsh plugin --profile web add @laoyuehanni/dsh-git-worktree
20
- > ```
21
- >
22
- > **从旧 `github:` 安装升级(≤ 0.3.2,包名 `dsh-git-worktree`)?** 原地 `update` 会加载失败——先移除旧包名,再重新安装。worktree 目录与插件设置完整保留。
27
+ ---
23
28
 
24
- ## 功能
29
+ ## 核心亮点
25
30
 
26
- - **提交图谱**:分支菜单左侧的图谱按钮原位扩大浮层,左侧浏览分支,右侧查看真实提交与合并关系。浏览不会检出分支;选中提交可查看作者、时间、完整正文与文件摘要。正文默认三行缩略,可展开并内部滚动;历史滚到列表末端自动加载下一页,也可点“加载更多”;搜索已加载提交的标题或哈希。作者下拉列出该分支的全部作者,同一提交的名单缓存在内存里;分支更新、抓取或刷新后缓存失效。
27
- - **IDEA 风格分支选择器**:分支菜单把 `/` 视为文件夹层级——可折叠文件夹、末段标签,当前分支所在链路默认展开并居中。本地与远程分支分两个可折叠分组(单远程自动剥掉前缀),底部搜索保留匹配分支的祖先文件夹并高亮命中,左侧工具栏提供定位当前分支与全部展开/折叠。本地和工作树行用绿色 ↗N / 蓝色 ↙N 表示领先/落后,分叉同时显示;未发布(无上游)显示不带数字的绿色 ↗(仓库没有任何远程时不显示),上游失效显示 `!`。
28
- - **远程分支检出**:远程组里选中 `origin/feat-x` 直接原地检出并自动创建跟踪分支(免确认);勾选工作树开关则改为隔离进独立 worktree。
29
- - **行级右键菜单**:分支行右键弹出六个动作——签出(免确认直接切)、新建、新建并检出、重命名分支(本地行)、删除分支(本地行,安全 `-d`,git 拒绝未合并提交与被占用分支)、复制分支;工作树行为跳到此工作树 + 复制路径 + 删除工作树。二级弹窗(命名/确认)直接在菜单位置就地展开,原地动作完成后菜单保持打开,可连续操作。键盘走方向键 + Enter。
30
- - **工作树快捷入口**:主仓库空白会话的分支菜单把被 worktree 占用的分支收进**「工作树」**分组(hover 显示目录路径),右键「跳到此工作树」直接跳进对应目录开始新会话。
31
- - **分支切换**:选分支即原地 `git switch`(免确认)。worktree 会话里入口整体收敛:其他分支照常展示但置灰,操作提示去主仓库发起;已启动的会话菜单只显示自己的分支(提取与更新仍可用)。
32
- - **从任意分支新建/重命名**:右键任意分支行即可**从该分支**新建(不动当前检出)或新建并检出(当场签出),创建弹窗边输边校验(git ref 规则 + 重名检查)、一把执行,失败后弹窗保留、可改名重试;本地行还可原地重命名。
33
- - **远程同步**:工具栏末位的刷新按钮 fetch 全部远程并清理失效跟踪分支——列表原地刷新,无需去终端。
34
- - **实时进度**:提取、更新与推送期间出现悬浮进度卡片(类似 IDEA 的后台任务),显示当前远程、git 原话的阶段/计数/速度,右上角 × 可取消——不挡页面、切换会话后仍在,长传输也不再被 20 秒(推送为 120 秒)超时误杀(仅 5 分钟无任何输出才终止)。期间该目录的其它 git 动作会等它结束;更新末尾的快进一步不可再取消。
35
- - **分支推送**:本地分支和工作树行右键「推送」打开紧凑的独立窗口。展示来源、远程和目标分支,只有多个远程时显示远程选择;目标分支可编辑,Enter 应用;编辑弹窗只通过 Enter、Esc 或 × 关闭,点击别处既不关闭它也不关闭推送窗口。待推送提交只显示第一行消息,列表独立滚动;先显示本地预览,后台校验远程,校验完成后才能推送。支持推送 Git 标记(所有 / 跟随提交),下拉「强制推送」使用 force-with-lease,拒绝覆盖预览后新增的远程提交。操作针对右键分支,无需切换检出或提交工作区文件;点击「推送」后窗口立即关闭,推送在进度卡片中继续(可随时取消);失败时窗口带着原因和之前选的远程、目标、标记弹回,说明常见原因(远端已前进、lease 过期、受保护分支、认证),并为重试重新读取目的地。
36
- - **更新当前分支**:工具栏与当前行右键可把当前分支快进到其上游;本地分叉、无上游、工作区改动冲突都会被拒绝并给出 git 原话——插件绝不代你 stash 或改写历史。
37
- - **工作树隔离**:未开始的会话里,右键任意分支行即可**「创建工作树」**(复用或新建目录)或**「新建分支并创建工作树」**(从该分支切出新分支,名字手动输入),确认后隔离到仓库内的 `<repo>/.dsh/gitworktree/<分支>/`(通过 `.git/info/exclude` 本地忽略——源仓库 `git status` 保持干净)并注册为真实工作区,重复创建复用已有(无论它位于何处);会话开始后目录固定,工作树选项随「工作树」分组一并隐藏。
38
- - **删除工作树**:分支菜单**「工作树」**分组的行右键(及管理弹窗)提供**「删除工作树」**——弹窗先红色列出未提交文件数、标注领先提交数,并预告工作区下的会话将一并归档;确认后先删 git worktree(分支本身保留),再归档会话、注销工作区。git 失败时 DSH 侧零变更、弹窗原地重试;有正在运行的会话时该项禁用。
39
- - **工作树管理**:**设置 → 插件**里的插件配置页可打开管理弹窗,跨仓库列出两处存放位置(各仓库的 `.dsh/gitworktree` 布局与旧的集中根目录)的全部工作树,按仓库分组并带来源标识,无法识别的目录也在列。
40
- - **历史位置只读**:同一页面只读展示历史集中存放根(默认 `~/.dsh/gitworktree`)——已有工作树原地保留、照常可用,新建的落在各仓库内。旧版 `~/.dsh/gitworktree/settings.json` 的值升级后自动迁入。
31
+ | 能力 | 一句话说明 |
32
+ | --- | --- |
33
+ | **IDEA 风格分支树** | 按 `/` 折叠目录、本地/远程分组、实时搜索与定位当前分支,支持彩色 `↗N` / `↙N` / `↗` / `!` 上游状态标记。 |
34
+ | **原位提交图谱** | 在分支弹窗内直接展开浏览任意分支的真实提交历史与合并图谱,无需切换检出。 |
35
+ | **一键 Worktree 隔离** | 将会话隔离到 `<repo>/.dsh/gitworktree/<分支>/` 并注册为真实工作区,保持主仓库 `git status` 干净。 |
36
+ | **安全推送与后台进度** | 独立推送预览窗(支持 Tag 与 `force-with-lease`)、严格快进更新,以及不挡页面的悬浮实时进度卡。 |
37
+ | **跨仓库工作树管理** | 在 **设置 → 插件** 中统一管理各仓库内与历史集中存放的 worktree,删除前风险提示并安全归档会话。 |
41
38
 
42
- > [!NOTE]
43
- > - 原生侧边栏不受影响:工作树是普通注册工作区,工作区树会把各仓库内的布局自动归到其仓库之下(集中存放的旧工作树位置不变,只有新建的才归位)。
44
- > - `git clean -xdff`(双 `-f`)会删掉仓库内的工作树目录(单 `-f` 会跳过嵌套仓库);删后 `git worktree prune` 可恢复注册,但其中未提交的改动会丢。
45
- > - 某仓库的工作区全部注销后,它的工作树不再出现在管理弹窗与自动清理中;重新注册该仓库任一目录即可找回。
39
+ ---
46
40
 
47
41
  ## 安装
48
42
 
43
+ 需要 `web` profile(`dsh web`)以及 **dsh `0.2.0-rc.1`** 或更新宿主。
44
+
49
45
  ```sh
50
46
  dsh plugin --profile web add @laoyuehanni/dsh-git-worktree
51
47
  ```
52
48
 
53
- > 包声明了 `dsh.bundle`,`add` 会自动把插件挂进 profile 的层栈,无需手动改配置。需要 `web` profile(`dsh web`)以及 dsh **0.2.0-rc.1**(或更新)宿主。
49
+ > [!TIP]
50
+ > 包已声明 `dsh.bundle`,执行 `add` 会自动把插件挂进 profile 层栈,无需手动修改配置。
54
51
 
55
- 运行 dsh **0.1.2 alpha** 宿主?请改装专用兼容版本:
52
+ **更新与移除**
56
53
 
57
54
  ```sh
58
- dsh plugin --profile web add @laoyuehanni/dsh-git-worktree@dsh-alpha
55
+ # 更新插件
56
+ dsh plugin --profile web update @laoyuehanni/dsh-git-worktree
57
+
58
+ # 移除插件(两处位置的 worktree 目录会保留,插件设置存于 dsh 设置文档)
59
+ dsh plugin --profile web remove @laoyuehanni/dsh-git-worktree
59
60
  ```
60
61
 
61
- > `@dsh-alpha` 是 dist-tag,解析为最新的 alpha 宿主兼容构建(当前 `0.4.3-dsh-0.1.2-alpha.5`),peer 锁定 alpha 线——普通 `update` 不会把两条通道混装。已在 0.2.0-rc.1 或更新宿主上,请用上面的默认线。
62
+ <details>
63
+ <summary>使用 dsh <code>0.1.2 alpha</code> 宿主,或从旧版 <code>github:</code> 直装(≤ 0.3.2)升级?</summary>
62
64
 
63
- ## 更新
65
+ **运行 dsh `0.1.2 alpha` 宿主**请安装专用兼容通道(当前解析到 `0.4.3-dsh-0.1.2-alpha.5`,peer 锁定 alpha 线,普通 `update` 不会混装):
64
66
 
65
67
  ```sh
66
- dsh plugin --profile web update @laoyuehanni/dsh-git-worktree
68
+ dsh plugin --profile web add @laoyuehanni/dsh-git-worktree@dsh-alpha
67
69
  ```
68
70
 
69
- ## 移除
71
+ **从旧版 `github:` 直装(≤ 0.3.2,包名 `dsh-git-worktree`)升级?** GitHub 直装已终止,原地 `update` 会加载失败,请先移除旧包名再从 npm 重新安装:
70
72
 
71
73
  ```sh
72
- dsh plugin --profile web remove @laoyuehanni/dsh-git-worktree
74
+ dsh plugin --profile web remove dsh-git-worktree
75
+ dsh plugin --profile web add @laoyuehanni/dsh-git-worktree
73
76
  ```
74
77
 
75
- 两处位置(各仓库的 `.dsh/gitworktree` 布局与旧的集中根目录)的 worktree 目录都会保留;插件自身的设置存于 dsh 设置文档。
78
+ 已有 worktree 目录与插件设置会完整保留。
76
79
 
77
- ## 开发
80
+ </details>
81
+
82
+ ---
83
+
84
+ ## 核心功能
85
+
86
+ ### 1. IDEA 风格分支选择器 & 提交图谱
87
+
88
+ - **树形目录结构**:把 `/` 视为可折叠文件夹并以末段为标签,打开时自动展开并居中定位当前分支。本地与远程分支分为两组(单远程自动剥离前缀)。
89
+ - **搜索与上游标记**:底部搜索保留匹配分支的祖先目录并高亮命中;左侧工具栏提供定位当前分支及全部展开/折叠。本地与工作树行用绿色 `↗N` / 蓝色 `↙N` 表示领先与落后,无上游显示绿色 `↗`(无远程时不显示),上游失效显示 `!`。
90
+ - **原位提交图谱**:点击分支菜单左侧图谱按钮即可原位扩大浮层,左侧浏览分支、右侧查看真实提交与合并关系,全程不检出分支。选中提交可查看作者、时间、完整正文(默认三行缩略,可展开内部滚动)与文件摘要。
91
+
92
+ <details>
93
+ <summary>展开详情:提交图谱分页、搜索与作者缓存</summary>
94
+
95
+ - 列表滚到底部自动加载下一页(同时保留「加载更多」按钮),支持按已加载提交的标题或哈希搜索。
96
+ - 作者下拉列出该分支的全部作者并缓存于内存;分支更新、抓取或刷新后自动失效。
97
+
98
+ </details>
99
+
100
+ ---
78
101
 
79
- 构建一次、装符号链接、迭代:
102
+ ### 2. 分支操作 & 行级右键菜单
103
+
104
+ - **免确认切分支与远程检出**:点击本地分支直接原地 `git switch`;在远程组点击 `origin/feat-x` 直接原地检出并自动建立跟踪分支(勾选工作树开关则隔离进独立 worktree)。在 worktree 会话内其他分支置灰并提示去主仓库操作;已启动会话的菜单只显示当前分支(提取与更新仍可用)。
105
+ - **行级右键菜单(键盘支持方向键 + Enter)**:分支行提供「签出 / 新建 / 新建并检出 / 重命名(本地)/ 删除(本地,安全 `-d`,拒绝未合并或被占用分支)/ 复制分支」六个动作;工作树行提供「跳到此工作树 / 复制路径 / 删除工作树」。
106
+ - **就地弹窗与连续操作**:新建、重命名、确认等二级弹窗直接在菜单位置展开,边输边校验 git ref 规则与重名;原地动作完成后菜单保持打开可连续操作,失败时保留弹窗便于改名重试。
107
+
108
+ ---
109
+
110
+ ### 3. 远程同步、快进更新、分支推送 & 实时进度
111
+
112
+ - **远程同步**:工具栏末位刷新按钮一键 fetch 全部远程并清理失效跟踪分支,列表原地刷新,无需切去终端。
113
+ - **快进更新当前分支**:工具栏或当前行右键可将当前分支快进到上游;本地分叉、无上游或工作区改动冲突时直接拒绝并给出 git 原话——插件绝不代你 stash 或改写历史。
114
+ - **分支推送预览窗**:本地与工作树行右键「推送」打开独立预览窗,先展示本地待推送提交(独立滚动于固定底栏之上)并在后台校验远端,无需切换检出或提交工作区文件。支持推送 Git 标记(所有 / 跟随提交),下拉「强制推送」采用 `force-with-lease` 防止覆盖新提交。
115
+ - **悬浮实时进度卡片**:提取、更新、推送期间显示类似 IDEA 后台任务的悬浮卡片,展示远程、git 原始阶段/计数/速度及右上角 `×` 取消按钮。不挡页面、切换会话仍在,长传输不再被 20s / 120s 超时误杀(仅 5 分钟无输出才终止)。
116
+
117
+ <details>
118
+ <summary>展开详情:推送弹窗交互与并发规则</summary>
119
+
120
+ - **远程与目标编辑**:仅在存在多个远程时显示远程下拉;目标分支按 `Enter` 应用,编辑浮层仅通过 `Enter`、`Esc` 或 `×` 关闭(点击别处不会误关编辑框或推送窗口)。
121
+ - **失败自动回弹**:点击「推送」后窗口关闭、进度卡接管;若失败则自动带回错误原因(远端已前进、lease 过期、受保护分支、认证失败)及上次选择的远程/目标/标记,并重新读取目的地供重试。
122
+ - **同目录串行保护**:同一目录的其它 git 动作会等待当前传输完成;更新末尾的快进一步开始后不可再取消。
123
+
124
+ </details>
125
+
126
+ ---
127
+
128
+ ### 4. Worktree 隔离、删除与跨仓库管理
129
+
130
+ - **Worktree 隔离**:未开始的会话中,右键任意分支即可**「创建工作树」**或**「新建分支并创建工作树」**,隔离至 `<repo>/.dsh/gitworktree/<分支>/`(通过 `.git/info/exclude` 本地忽略,源仓库 `git status` 保持干净)并注册为真实工作区;重复创建同一分支自动复用已有 worktree。会话启动后目录锁定,工作树选项自动隐藏。
131
+ - **工作树快捷入口**:主仓库空白会话把被 worktree 占用的分支归入**「工作树」**分组(hover 显示路径),右键「跳到此工作树」直接进入对应目录开启新会话。
132
+ - **安全删除工作树**:在「工作树」分组右键或管理弹窗中操作(有运行中会话时禁用)。确认弹窗会用红色标出未提交文件数、领先提交数,并提示对应工作区会话将归档;确认后先删 git worktree(分支保留),仅在 git 成功后才归档会话并注销工作区,失败则 DSH 侧零变更且支持原地重试。
133
+ - **工作树管理 & 历史位置只读**:在 **设置 → 插件** 中打开管理弹窗,跨仓库列出各仓库 `.dsh/gitworktree` 与只读历史集中根(默认 `~/.dsh/gitworktree`,旧版 `settings.json` 自动迁入)下的全部工作树(含孤儿目录),按仓库分组并带来源标识;每行标出接入形态「独立工作区 / 会话目录」。
134
+ - **留空即随机分支**:「新建分支并创建工作树」时分支名可留空,自动以 `<基分支>-<4位十六进制>` 命名并避开已有分支与目录。
135
+ - **接管官方入口**(设置「接管官方新建工作树入口」,默认开):隐藏空白会话右上角 DSH 官方的新建工作树按钮,统一由左下角分支菜单创建,并撤销该会话上残留的官方工作树请求,避免嵌套创建;右侧变更与评审面板不受影响。
136
+ - **会话目录模式**(设置「在当前工作区下切换工作树目录」,默认关):开启后工作树不再注册为独立工作区,而是在所属仓库工作区下切换会话工作目录(与 DSH 官方方式一致)。新建工作树延迟到发送首条消息时才执行,输入框上方显示待建条,可随时取消;创建过程分步显示进度,失败可「重试」或「不使用工作树继续」。打开已有工作树时,若它已有独立工作区则直接进入该工作区。
137
+ - **纳管官方工作树**(设置「管理官方创建的工作树」,默认关):管理弹窗一并列出 `<repo>/.agents/worktrees` 下的官方工作树(「DSH 官方」分组),可打开与手动删除,但始终不参与自动清理。
138
+
139
+ > [!NOTE]
140
+ > - **不影响原生侧边栏**:工作树即普通注册工作区,工作区树会自动把各仓库内的新建工作树归到对应仓库之下(旧的集中存放工作树保持原位)。会话目录模式下不新增工作区;两种模式下的工作树会话行均会显示工作树角标。
141
+ > - 会话目录模式的待建状态只保存在 dsh 服务进程内存中:重启 dsh 或重载插件后待建条消失,需要重新选择。
142
+ > - **`git clean -xdff`(双 `-f`)** 会删掉仓库内的工作树目录(单 `-f` 会跳过嵌套仓库);删后可通过 `git worktree prune` 恢复注册,但其中未提交的改动会丢失。
143
+ > - 某仓库的工作区全部注销后,其工作树不再出现在管理弹窗与自动清理中;重新注册该仓库任一目录即可找回。
144
+
145
+ ---
146
+
147
+ ## 开发
80
148
 
81
149
  ```sh
82
150
  pnpm install
83
151
  pnpm build:all
84
152
  pnpm test # vitest
85
- node scripts/smoke.mjs # 基于构建产物的真实 git 冒烟
153
+ node scripts/smoke.mjs # 基于构建产物的真实 git 冒烟
86
154
  dsh plugin --profile web add link:D:/Code/dsh-worktree
87
155
  ```
88
156
 
89
- 重新构建并重启 `dsh web` 即可生效(插件目录里跑 `pnpm watch:client` 可热重载客户端)。刻意不设 `prepare` 脚本——`lib/` 不入库,`pnpm publish` 现场构建打进 tarball。
157
+ 重新构建并重启 `dsh web` 即可生效,客户端开发可在插件目录运行 `pnpm watch:client` 热重载。刻意不设 `prepare` 脚本——`lib/` 不入库,`pnpm publish` 时现场构建打进 tarball。
90
158
 
91
- 临时只挂 host 半边(仅当次启动生效,不动 profile):在仓库旁建 `cordis.yml` 指向构建出的 host 半边(Windows 需要 `file:///` 形式),随补丁启动:
159
+ <details>
160
+ <summary>临时只挂 host 半边(仅当次启动生效,不动 profile)</summary>
161
+
162
+ 在仓库旁创建 `cordis.yml` 指向构建出的 host 入口(Windows 需要 `file:///` 形式):
92
163
 
93
164
  ```yml
94
165
  - insert:
@@ -96,8 +167,16 @@ dsh plugin --profile web add link:D:/Code/dsh-worktree
96
167
  name: 'file:///D:/Code/dsh-worktree/lib/index.js'
97
168
  ```
98
169
 
170
+ 然后随补丁启动:
171
+
99
172
  ```sh
100
173
  dsh web --patch <插件目录>/cordis.yml
101
174
  ```
102
175
 
103
- 此模式只挂载 host 半边(`/plugin/git-worktree/*` 三条路由照常工作);开发 UI 请用上面的 `link:` 安装方式。
176
+ 此模式仅挂载 host 半边(`/plugin/git-worktree/*` 路由照常工作);开发 UI 请使用上面的 `link:` 安装方式。
177
+
178
+ </details>
179
+
180
+ ---
181
+
182
+ [dsh]: https://github.com/deepseek-ai/deepseek-harness
package/docs/DETAIL.md ADDED
@@ -0,0 +1,18 @@
1
+ The composer tool row gains a branch button: it opens the repository's branch menu, and picking a branch switches in place; tick Worktree on a blank session and the new session starts inside its own Git worktree in the repository, isolated from the main checkout.
2
+
3
+ ## What you can do
4
+
5
+ - **Inspect and switch branches**: local and remote branches in collapsible groups, `/` folding like folders, with arrows marking how far each row leads or trails its upstream. Picking a branch switches immediately; picking a remote branch checks it out with a tracking branch.
6
+ - **Act on any branch**: right-click a row to check out, create, create-and-check-out from it, rename, delete, or copy it; the current branch can fast-forward to its upstream or open the compact push window (pending-commit list, Git tags, force-with-lease, enabled after the remote check).
7
+ - **Read the history**: the graph button next to the menu expands the commit graph in place — browsing never checks out, selecting a commit shows its author, date, full message, and file summary; more pages load at the end, and loaded titles and hashes are searchable.
8
+ - **Isolate into a worktree**: tick Worktree on a blank session (or right-click a branch and pick Create worktree) and the session starts at `<repo>/.dsh/gitworktree/<branch>` registered as a real workspace, reusing the directory when it already exists; branches held by worktrees collect in the Worktrees group, and Jump to this worktree opens a new session inside. Leave the new branch name blank to get a random `<base>-<4 hex>` name.
9
+ - **Stay in one workspace if you prefer**: turn on "Switch worktree directory in current workspace" and worktrees open by moving the session's directory under its repository, as DSH's own worktrees do; a new worktree is created only when you send the first message, with Retry or Continue without worktree if it fails.
10
+ - **Sync remotes**: the toolbar refresh fetches every remote and prunes stale tracking branches; pushes and updates show a cancellable floating progress card that survives switching sessions.
11
+
12
+ ## Some limits
13
+
14
+ - The directory is fixed once a session starts; inside a worktree session the branch menu shows only its own branch — go back to the main repository for the rest.
15
+ - Delete worktree first lists uncommitted files and ahead commits; after confirmation it removes the git worktree, archives its sessions, and unregisters the workspace — the branch itself stays. It is disabled while a session is running.
16
+ - Every git command runs outside your sessions; the plugin never stashes, rewrites history, or touches the main checkout for you.
17
+ - The plugin's configuration page (Settings → Plugins) opens the cross-repository worktree manager; it can also include DSH's own worktrees under `<repo>/.agents/worktrees`, which are never auto-pruned.
18
+ - By default the plugin hides DSH's own new-worktree button on blank sessions so there is a single entry; turn the takeover off in the settings to bring it back.
@@ -0,0 +1,18 @@
1
+ 输入框工具行多一个分支按钮:点开是当前仓库的分支菜单,选中即原地切换;空白会话再勾选「工作树」,新会话就落进仓库内的独立 Git 工作树,与主检出互不干扰。
2
+
3
+ ## 你可以这样用
4
+
5
+ - **看分支、切分支**:本地与远程分支分组展示,`/` 按文件夹层级折叠,行上箭头标出与上游的领先/落后。选中即切换(免确认);选远程分支直接检出并自动建跟踪。
6
+ - **分支上的操作**:右键任意分支行——签出、新建、从它新建并检出、重命名、删除、复制;当前分支可快进更新到上游,或打开紧凑的推送窗口(待推送清单、Git 标记、force-with-lease,远程校验通过后才能推)。
7
+ - **看提交历史**:菜单旁的图谱按钮原位展开提交图谱:浏览不检出,选中看作者、时间、正文与文件摘要;滚到底自动加载,可按标题或哈希搜索。
8
+ - **隔离进工作树**:空白会话勾选「工作树」(或右键分支行「创建工作树」),会话在 `<repo>/.dsh/gitworktree/<分支>` 开始并注册为真实工作区,重复创建复用已有目录;被占用的分支收进「工作树」分组,「跳到此工作树」直接进去开新会话。新分支名留空即自动生成 `<基分支>-<4位十六进制>`。
9
+ - **想留在同一个工作区也行**:开启「在当前工作区下切换工作树目录」后,工作树改为在所属仓库下切换会话目录(同 DSH 官方方式);新建工作树延迟到发送首条消息时才执行,失败可「重试」或「不使用工作树继续」。
10
+ - **同步远程**:工具栏刷新按钮 fetch 全部远程并清理失效跟踪分支;推送、更新期间有可取消的悬浮进度卡片,切换会话也在。
11
+
12
+ ## 一些边界
13
+
14
+ - 会话开始后目录固定;工作树会话的分支菜单只显示自己的分支,其余操作请回主仓库发起。
15
+ - 「删除工作树」会先列出未提交文件数与领先提交数,确认后删除 git 工作树、归档其会话并注销工作区——分支本身保留;有会话正在运行时不可删。
16
+ - 所有 git 操作由插件在会话之外执行;绝不替你 stash、改写历史或动主检出的文件。
17
+ - 设置 → 插件里本插件的配置页可打开跨仓库的工作树管理弹窗;也可一并纳管 `<repo>/.agents/worktrees` 下的 DSH 官方工作树,它们永不参与自动清理。
18
+ - 插件默认隐藏空白会话右上角 DSH 官方的新建工作树按钮,保持单一入口;在设置中关闭「接管官方新建工作树入口」即可恢复。
package/icon.svg ADDED
@@ -0,0 +1,22 @@
1
+ <svg width="36" height="36" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M11.5 13.3V22.7" stroke="url(#dsh_git_worktree_trunk)" stroke-width="2.4" stroke-linecap="round" />
3
+ <path d="M13.95 24.15C18.55 23.25 23.65 21.1 23.65 16.5" stroke="url(#dsh_git_worktree_branch)" stroke-width="2.4" stroke-linecap="round" />
4
+ <circle cx="11.5" cy="10.5" r="2.8" stroke="#7AC2FF" stroke-width="2.4" />
5
+ <circle cx="11.5" cy="25.5" r="2.8" stroke="#4A65E8" stroke-width="2.4" />
6
+ <path d="M18.8 10.1C18.8 9.216 19.516 8.5 20.4 8.5H22.7C23.16 8.5 23.6 8.698 23.9 9.045L24.55 9.8H26.9C27.784 9.8 28.5 10.516 28.5 11.4V15.3C28.5 16.184 27.784 16.9 26.9 16.9H20.4C19.516 16.9 18.8 16.184 18.8 15.3V10.1Z" fill="url(#dsh_git_worktree_folder)" fill-opacity="0.9" />
7
+ <path d="M21.4 13.35H25.9" stroke="#FFFFFF" stroke-width="1.6" stroke-linecap="round" />
8
+ <defs>
9
+ <linearGradient id="dsh_git_worktree_trunk" x1="11.5" y1="13.3" x2="11.5" y2="22.7" gradientUnits="userSpaceOnUse">
10
+ <stop stop-color="#7AC2FF" />
11
+ <stop offset="1" stop-color="#4A65E8" />
12
+ </linearGradient>
13
+ <linearGradient id="dsh_git_worktree_branch" x1="13.95" y1="24.15" x2="23.65" y2="16.5" gradientUnits="userSpaceOnUse">
14
+ <stop stop-color="#4A65E8" />
15
+ <stop offset="1" stop-color="#22B8A6" />
16
+ </linearGradient>
17
+ <linearGradient id="dsh_git_worktree_folder" x1="23.65" y1="8.5" x2="23.65" y2="16.9" gradientUnits="userSpaceOnUse">
18
+ <stop stop-color="#52E5B5" />
19
+ <stop offset="1" stop-color="#0C8F9A" />
20
+ </linearGradient>
21
+ </defs>
22
+ </svg>