@laoyuehanni/dsh-git-worktree 0.4.3-dsh-0.1.2-alpha.5 → 0.4.4

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
@@ -13,59 +13,46 @@ A dsh plugin for simple branch & worktree management in the Web UI. The composer
13
13
  Repo: <https://github.com/LaoYueHanNi/dsh-git-worktree>
14
14
 
15
15
  > [!IMPORTANT]
16
- > **Upgrading from a GitHub install of 0.3.2 or earlier?** Since 0.4.0 the plugin is distributed on npm as `@laoyuehanni/dsh-git-worktree` (the unscoped name was already taken on the registry). A legacy `github:` install **cannot be upgraded with `update`** — the package was renamed, and an in-place update leaves the plugin failing to load. From 0.4.0 on, remove the old package name first, then install again:
16
+ > **GitHub direct installs have ended** — the repository no longer carries prebuilt output. Install from npm instead:
17
17
  >
18
18
  > ```sh
19
- > dsh plugin --profile web remove dsh-git-worktree
20
19
  > dsh plugin --profile web add @laoyuehanni/dsh-git-worktree
21
20
  > ```
22
21
  >
23
- > Worktree folders under `~/.dsh/gitworktree/` and the plugin's settings are untouched by the migration — everything carries over.
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.
24
23
 
25
24
  ## Features
26
25
 
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 by default and is centered on open. The list renders in two collapsible groups, **local branches** and **remote branches**; under a single remote the remote group strips its `<remote>/` prefix, with several remotes the full names stay (`origin`/`upstream` become the folder layer). Single click selects a row; double-click or Enter opens the right-side confirm flyout. The left tool strip offers **locate current branch** and **expand/collapse all**; the bottom search keeps the matching branches' ancestor folders and highlights the hit substring. Clipped labels expose the full name on hover. Local branches with an upstream trail **↑N/↓N divergence marks** (hover for the full meaning).
28
- - **Remote branch checkout**: pick `origin/feat-x` in the remote group and confirm — it checks out in place with a tracking local branch `feat-x` created by git's dwim; with the worktree toggle on, the pick creates the twin branch isolated in its own worktree instead.
29
- - **Worktree quick hop**: the main checkout's blank-session branch menu collects the branches held by live worktrees into a「工作树」(Worktrees) group (hover shows the directory path) — **double-click hops the session straight into that directory** and starts a fresh session there. No git action, no confirm; the group hides once a session has started.
30
- - **Branch switching**: pick a branch from the chip's menu and confirm — an in-place `git switch`. Inside a **linked worktree** the whole entry scopes down: a blank session still lists every branch (dimmed), but any branch action (worktree hops and in-place creation included) answers with a hint to start from the main checkout — and the worktree toggle doesn't render there; a started session's menu shows nothing but its own branch (fetch and update-current still work — neither moves the checkout).
31
- - **In-place branch creation**: the branch menu's toolbar plus opens a create flyout right of the card — type the name there (validated as you type against git's ref-name rules plus a duplicate check; an illegal or already-taken name shows an inline error) and press Create: the NEW branch is cut from the session directory's current checkout and checked out in place in one stroke (`git switch -c`), detached HEAD included. A failure toasts and keeps the flyout open for a renamed retry — the worktree-less sibling of the cutout flow.
32
- - **Remote sync**: the branch menu's last toolbar tool fetches every remote and prunes stale tracking branches (`git fetch --all --prune`) — remote-side additions and deletions show up in the list the moment it lands, no terminal round-trip. The menu stays open and refreshes in place; a failure toasts.
33
- - **Branch update**: the solid arrow next to the dashed one updates the CURRENT branch — fetch every remote, then fast-forward it to its upstream (`--ff-only`). A diverged branch, a missing upstream, or conflicting uncommitted changes are refused with git's own explanation; the plugin never stashes or rewrites history on your behalf.
34
- - **Worktree isolation**: on a blank session, checking the **Worktree** toggle pops the cutout dialog right above the chip — the new branch's name is editable there (pre-filled with the first free `<current>-wt`, suffixing past taken names), and confirming cuts it out of the current checkout into a fresh isolated worktree; the chip's branch picker stays available for picking another branch, which turns the pick into `git worktree add` under `~/.dsh/gitworktree/<repo>-<branch>/`. Either way the folder registers as a real workspace with a fresh blank session. Same-branch re-picks reuse the existing worktree; stale registrations recover via `git worktree prune`. Dismissing the confirm and sending the message anyway knowingly stays in the current directory.
35
- - **Worktree removal**: the ⋯ menu of a worktree row in the grouped sidebar gains **Remove worktree** — one confirmed flow that closes the lifecycle. The dialog inspects the folder first (`POST /inspect`): the **uncommitted-file count** in red (those die with the folder), the branch's **ahead count** neutrally (the branch ref survives the removal — nothing is lost), plus a heads-up that the workspace's sessions will be **archived along** (never dumped into Ungrouped; unarchive brings them back). Confirming runs `git worktree remove` first (`--force` rides along when there are uncommitted files; a stale registration prunes instead), and only then archives the sessions and drops the workspace registration — git is the step most likely to fail (locked files on Windows), so leading with it leaves the DSH side untouched and the dialog retries in place. Rows with a running or currently-browsed session don't offer the action (archive or switch away first); the main checkout row never does.
36
- - **Ungrouped virtual directory groups**: the grouped view gains a trailing **Ungrouped** section — sessions no workspace accounts for (leftovers of a deleted-then-recreated registration, or history that appeared after first-boot grouping) cluster by their header cwd into **virtual directory groups** (a dashed folder glyph, one indent step, and a lighter title set them apart from real workspaces at a glance; case-insensitive; a directory renamed long ago still clusters under its old path), hover reveals the full path. A cluster whose directory matches a registered workspace is marked as that workspace's **stray sessions**; an unmatched cluster offers **Register as workspace** in one click **only after the host pre-flights the directory** (new sessions land in it from then on; the old strays stay loose until a re-adoption feature exists). A GONE directory gets one of two treatments: a path sitting directly under the worktree storage root is a slot this plugin planned — hover explains that rebuilding it reattaches the historical sessions automatically (DSH keeps the accounting; membership is a realpath projection), and a one-click **Rebuild empty directory** does exactly that (strictly gated to one level under the root — escaping paths and corrupted cwds are refused); anything else stays action-free with the reason in hover. Either way a bad path never reaches the DSH workspace API.
37
- - **Storage root configurable**: the **Git Worktree** card under **Settings → Plugins** — a native folder picker or a typed absolute path, effective on save (new worktrees land in the new location; existing ones stay put and remain listable/reusable by git). Empty selects the default `$DSH_HOME/gitworktree` (`~/.dsh/gitworktree`). The value lives in the shared dsh settings document; a legacy `~/.dsh/git-worktree/settings.json` value migrates into it automatically on upgrade (the old file is renamed `.migrated` and kept).
38
- - **Sidebar workspace grouping**: because DSH has no multi-workspace grouping API, the plugin replaces the native sidebar 1:1 and clusters same-repository workspaces (main checkout plus worktrees) under a collapsible **repository group**. The main row reads `Main (branch)`, worktree rows read their branch, grouping is derived from on-disk git facts (nothing extra is stored), and a repository without worktrees stays a single native-looking row. The card's **Group workspaces** switch (experimental, default on) restores the native list instantly.
26
+ - **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 ↑N/↓N divergence marks on tracking branches.
27
+ - **Remote branch checkout**: pick `origin/feat-x` in the remote group and confirm — it checks out in place with a tracking branch; the worktree toggle sends the pick to an isolated worktree instead.
28
+ - **Worktree quick hop**: the main checkout's blank-session menu groups branches held by live worktrees under **Worktrees** (hover shows the directory) — double-click hops straight into that directory and starts a fresh session.
29
+ - **Branch switching**: pick a branch and confirm — an in-place switch. 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).
30
+ - **In-place branch creation**: the menu toolbar's plus opens a create flyout with as-you-type validation (git ref rules plus a duplicate check); Create cuts and checks out the new branch in one stroke (detached HEAD included), a failure keeps the flyout open for a renamed retry.
31
+ - **Remote sync**: the last toolbar tool fetches every remote and prunes stale tracking branches — the list refreshes in place, no terminal round-trip.
32
+ - **Branch update**: update the CURRENT branch to its upstream (fast-forward only); 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.
33
+ - **Worktree isolation**: on a blank session, the **Worktree** toggle pops the cutout dialog with an editable branch name (pre-filled with the first free `<current>-wt`); confirming cuts it into a fresh isolated worktree that registers as a real workspace. The branch picker stays available — picking another branch creates the worktree under `~/.dsh/gitworktree/<repo>-<branch>/` instead, and same-branch re-picks reuse the existing worktree.
34
+ - **Worktree removal**: the ⋯ menu of a worktree row offers **Remove worktree** — the dialog first counts uncommitted files (red) and ahead commits, and warns the workspace's sessions will be archived; confirming removes the worktree, then archives the sessions. A git failure leaves the DSH side untouched and retries in place.
35
+ - **Ungrouped virtual directory groups**: sessions no workspace accounts for cluster by directory under a trailing **Ungrouped** section (a dashed folder glyph sets them apart). A cluster matching a registered workspace is marked as its strays; an existing directory registers as a workspace in one click; a vanished slot under the storage root can be rebuilt empty — its historical sessions reattach automatically.
36
+ - **Storage root configurable**: the **Git Worktree** card under **Settings → Plugins** — a folder picker or a typed path, effective on save; blank keeps the default `$DSH_HOME/gitworktree`. A legacy `~/.dsh/gitworktree/settings.json` value migrates automatically on upgrade.
37
+ - **Sidebar workspace grouping**: the plugin replaces the native sidebar and clusters same-repository workspaces (main checkout plus worktrees) under collapsible repository groups — grouping derives from on-disk git facts, nothing extra is stored. The **Group workspaces** switch (experimental, default on) restores the native list instantly.
39
38
 
40
39
  ![Same-repository workspaces grouped in the sidebar](sidebar-grouping.png)
41
40
 
42
41
  ## Install
43
42
 
44
- ### From npm
45
-
46
43
  ```sh
47
44
  dsh plugin --profile web add @laoyuehanni/dsh-git-worktree
48
45
  ```
49
46
 
50
- > The package declares `dsh.bundle`, so `add` wires the plugin into the profile's layer stack automatically — no config editing needed. The compiled `lib/` ships in the npm tarball, so installs work out of the box without any build step. Requires the `web` profile (`dsh web`).
51
-
52
- ### From npm — dsh 0.1.2-alpha.x host
47
+ > 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.1.2-rc.1** (or later 0.1.2) host.
53
48
 
54
- The `latest` line above tracks the stable host (rc series). If you run a dsh **0.1.2 alpha** host, install the dedicated compatibility build instead:
49
+ Running a dsh **0.1.2 alpha** host? Install the dedicated compatibility build instead:
55
50
 
56
51
  ```sh
57
52
  dsh plugin --profile web add @laoyuehanni/dsh-git-worktree@dsh-alpha
58
53
  ```
59
54
 
60
- > `@dsh-alpha` is a dist-tag (not a literal version), so the registry resolves it to the latest compatibility build — currently `0.4.1-dsh-0.1.2-alpha.3`. Its peer range is pinned to `>=0.1.2-alpha.3 <0.2.0`, while the stable line stays on the rc peers: the two channels never get mixed by a plain `update`, and `dsh plugin update` keeps pulling from the matching channel only. Upgrading your host back to the stable line? Remove this package first, then install the default one from the section above.
61
-
62
- ### From a local directory (development)
63
-
64
- ```sh
65
- dsh plugin --profile web add link:D:/Code/dsh-worktree
66
- ```
67
-
68
- `link:` installs a symlink: rebuild the plugin and restart `dsh web` to apply changes.
55
+ > `@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.1.2-rc.1 or later, use the default line above.
69
56
 
70
57
  ## Update
71
58
 
@@ -79,27 +66,23 @@ dsh plugin --profile web update @laoyuehanni/dsh-git-worktree
79
66
  dsh plugin --profile web remove @laoyuehanni/dsh-git-worktree
80
67
  ```
81
68
 
82
- The plugin is removed from the profile and stops loading. Worktree folders under `~/.dsh/gitworktree/` are kept; the migrated legacy settings file (`settings.json.migrated`) can be deleted manually if unwanted — the plugin's own settings live in the dsh settings document.
69
+ Worktree folders under `~/.dsh/gitworktree/` are kept; the plugin's own settings live in the dsh settings document.
83
70
 
84
71
  ## Development
85
72
 
86
- Build the plugin once:
73
+ Build once, install a symlink, iterate:
87
74
 
88
75
  ```sh
89
76
  npm install
90
77
  npm run build && npm run build:client
91
- npm test # vitest (60 tests)
78
+ npm test # vitest
92
79
  node scripts/smoke.mjs # real-git smoke over the built lib
80
+ dsh plugin --profile web add link:D:/Code/dsh-worktree
93
81
  ```
94
82
 
95
- > **No `prepare` script — by design.** The compiled `lib/` output is committed to the repo and ships in the npm tarball. pnpm ≥ 10 refuses to run dependency build scripts unless they are allowlisted, so a `prepare` script would surface as a skipped or failed install step for pnpm users. Shipping prebuilt output instead keeps `dsh plugin add @laoyuehanni/dsh-git-worktree` working out of the box. **After changing anything under `src/`, always rebuild and commit the updated `lib/`** (and release a new version), or installs will get stale output:
96
-
97
- ```sh
98
- npm run build && npm run build:client
99
- git add lib/
100
- ```
83
+ Rebuild and restart `dsh web` to apply changes (`npx tsdown --watch` in the plugin directory hot-reloads the client). No `prepare` script by design — `lib/` never enters the repo; `npm publish` builds it fresh into the tarball.
101
84
 
102
- Temporary mount — effective for 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):
85
+ 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:
103
86
 
104
87
  ```yml
105
88
  - insert:
@@ -111,4 +94,4 @@ Temporary mount — effective for this launch only, no profile changes. Create a
111
94
  dsh web --patch <plugin-dir>/cordis.yml
112
95
  ```
113
96
 
114
- This mode only mounts the host half (the three `/plugin/git-worktree/*` routes keep working); the chip needs the client bundle resolved by package name, so for UI development use the `link:` install above instead: run `npm run build && npm run build:client` (or `npx tsdown --watch` in the plugin directory), restart `dsh web`, and the browser plugin hot-reloads automatically.
97
+ Only the host half mounts in this mode (the `/plugin/git-worktree/*` routes keep working); for UI work use the `link:` install above.
package/README.zh.md CHANGED
@@ -13,59 +13,46 @@
13
13
  仓库:<https://github.com/LaoYueHanNi/dsh-git-worktree>
14
14
 
15
15
  > [!IMPORTANT]
16
- > **从 0.3.2 及更早的 GitHub 直装升级?** 0.4.0 起插件发布到 npm,包名变更为 `@laoyuehanni/dsh-git-worktree`(原裸名在 npm 上已被第三方占用)。旧的 `github:` 安装**无法通过 `update` 升级**——包名已变,原地 update 会导致插件加载失败。从 0.4.0 开始使用,需先移除旧包名,再重新安装:
16
+ > **GitHub 直装已终止**——仓库不再携带构建产物,请改从 npm 安装:
17
17
  >
18
18
  > ```sh
19
- > dsh plugin --profile web remove dsh-git-worktree
20
19
  > dsh plugin --profile web add @laoyuehanni/dsh-git-worktree
21
20
  > ```
22
21
  >
23
- > 迁移不影响数据:`~/.dsh/gitworktree/` 下的 worktree 目录与插件设置完整保留。
22
+ > **从旧 `github:` 安装升级(≤ 0.3.2,包名 `dsh-git-worktree`)?** 原地 `update` 会加载失败——先移除旧包名,再重新安装。worktree 目录与插件设置完整保留。
24
23
 
25
24
  ## 功能
26
25
 
27
- - **IDEA 风格分支选择器**:分支菜单把 `/` 视为文件夹层级 —— 可折叠文件夹、末段标签,当前分支所在链路默认展开并居中。列表分**本地分支**与**远程分支**两个可折叠分组;远程组在单远程仓库下自动剥掉 `<远程>/` 前缀,多远程则保留全名(`origin`/`upstream` 成为组内文件夹)。单击选中(蓝底),双击或 Enter 弹出右侧确认弹层。左侧工具栏提供**定位当前分支**与**全部展开/折叠**;底部搜索保留匹配分支的祖先文件夹并高亮命中字符;超长标签悬停显示全名。有上游的本地分支行尾显示 **↑N/↓N 领先落后标记**(悬停看完整含义)。
28
- - **远程分支检出**:远程组里选中 `origin/feat-x`,确认后原地检出并自动创建跟踪本地分支 `feat-x`(git dwim);勾选工作树模式则从远程分支新建孪生分支并隔离进独立 worktree。
29
- - **工作树快捷入口**:主仓库空白会话的分支菜单把被 worktree 占用的分支收进「工作树」分组(hover 显示目录路径),**双击直接跳进对应目录**开始新会话——零 git 动作、无确认弹层;已开始的会话不显示该分组。
30
- - **分支切换**:从 chip 菜单选分支、确认后原地 `git switch`。**worktree 会话的入口整体收敛**:未启动时其他分支照常展示但置灰,任何分支操作(含工作树跳转、新建分支)都会提示「分支操作请在主仓库发起」,工作树开关也不渲染——发起 worktree / 新分支是主仓库的决策;已启动时菜单仅展示该会话自己的分支(提取、更新当前分支仍可用,两者不动检出)。
31
- - **原地新建分支**:分支菜单左侧工具栏的加号在卡片右侧弹出创建弹窗——弹窗内输入名称(边输边校验 git ref-name 规则 + 重名检查,非法或重名时输入框下方标红提示),点「确认」一把完成新建并原地切换(`git switch -c`),detached HEAD 亦可用;失败 toast 后弹窗保留、可改名重试——即不带工作树的「切出」孪生流程。
32
- - **远程同步**:分支菜单工具栏末位的刷新按钮执行 `git fetch --all --prune`——远程新增/删除的分支当场出现在列表里,无需去终端;菜单保持打开并原地刷新,失败 toast。
33
- - **更新当前分支**:实线箭头(虚线提取旁)更新**当前分支**——先 fetch 全部远程,再把当前分支快进(`--ff-only`)到其上游。本地分叉、无上游、工作区改动冲突都会被拒绝并给出 git 原话;插件绝不代你 stash 或改写历史。
34
- - **工作树隔离**:空白会话上勾选**「工作树」**立即在 chip 上方弹出「从当前分支切出」确认弹窗——弹窗内可**编辑新分支名**(预填第一个空闲的 `<当前分支>-wt`,重名自动递增 `-wt2`、`-wt3`…),确认后从当前检出切出**新分支**并隔离到全新 worktree;分支 chip 的菜单仍可打开,选其他分支则在 `~/.dsh/gitworktree/<仓库>-<分支>/` 下执行 `git worktree add`。两条路径都会注册为真实工作区并跳转到新目录的空白会话。重复选同一分支直接复用;失效注册自动 prune 恢复。取消确认弹窗后直接发消息,即默许在当前目录开始会话。
35
- - **删除工作树**:聚合侧边栏里工作树行的 ⋯ 菜单新增**「删除工作树」**——一条确认流收尾整个生命周期:弹窗先检查目标目录(`POST /inspect`),红色列出**未提交文件数**(会随目录一并删除)、中性标注**领先上游的提交数**(分支保留在 git 里,提交不丢),并预告该工作区下的会话将**一并归档**(不会倾倒进「未分组」,取消归档可找回)。确认后先 `git worktree remove`(有未提交文件自动 `--force`;stale 注册直接 prune),成功后再归档会话、删除工作区注册——git 最易失败(Windows 文件占用),放在最前则失败时 DSH 侧零变更、弹窗原地重试。有进行中或正在浏览的会话时不显示该菜单项(先归档或切走再删);主仓库行不可删。
36
- - **未分组虚拟目录组**:分组视图尾部新增**「未分组」区**——不属于任何工作区的会话(删过注册又重建的残留、首启后才出现的历史)按会话头 cwd 聚成**虚拟目录组**(虚线文件夹图标 + 缩进 + 弱化标题,与真实工作区一眼区分;大小写不敏感,目录改名前的旧路径照聚),hover 显示完整路径。目录与某个已注册工作区匹配的组标注**「属于「X」的失联会话」**;未匹配且**经 host 预检确认目录真实存在**的组可一键**「注册为工作区」**(此后新会话自动归位;旧失联会话仍留在未分组直至收复功能落地)。目录已消失的组:若该路径位于工作树存放位直下(本插件规划的目录),hover 明示「重建后历史会话将自动归位」(DSH 记账保留、realpath 匹配即恢复),并提供**「重建空目录」**一键自愈(严格限定存放位直下一层,越界与损坏 cwd 一律拒绝);其余缺失目录仅提示原因——坏路径不会被发给 DSH 接口。
37
- - **存放根路径可配**:**设置 → 插件**页签下的 **Git 工作树** 卡片 —— 原生目录选择器或手输绝对路径,保存即生效(新建的 worktree 落在新目录,已有的留在原地,git 仍能识别复用)。留空使用默认 `$DSH_HOME/gitworktree`(`~/.dsh/gitworktree`)。设置存于 dsh 统一设置文档;旧版 `~/.dsh/git-work-tree/settings.json` 的已保存值会在升级后自动迁入(原文件改名 `.migrated` 保留)。
38
- - **聚合工作区**:DSH 尚未开放多工作区聚合接口,故按原生侧边栏 1:1 替换左侧列表,并把同一仓库的主仓库与 worktree 工作区聚成可折叠的**仓库组**——主行显示 `主仓库(分支)`,工作树行显示分支。分组从磁盘 git 事实派生、不存关系数据;没有 worktree 的仓库保持单行。设置卡 **聚合工作区**(测试功能,默认开)可随时切回原生。
26
+ - **IDEA 风格分支选择器**:分支菜单把 `/` 视为文件夹层级——可折叠文件夹、末段标签,当前分支所在链路默认展开并居中。本地与远程分支分两个可折叠分组(单远程自动剥掉前缀),底部搜索保留匹配分支的祖先文件夹并高亮命中,左侧工具栏提供定位当前分支与全部展开/折叠,有上游的本地分支行尾显示 ↑N/↓N 领先落后标记。
27
+ - **远程分支检出**:远程组里选中 `origin/feat-x` 确认后原地检出并自动创建跟踪分支;勾选工作树开关则改为隔离进独立 worktree。
28
+ - **工作树快捷入口**:主仓库空白会话的分支菜单把被 worktree 占用的分支收进**「工作树」**分组(hover 显示目录路径),双击直接跳进对应目录开始新会话。
29
+ - **分支切换**:选分支、确认,原地 `git switch`。worktree 会话里入口整体收敛:其他分支照常展示但置灰,操作提示去主仓库发起;已启动的会话菜单只显示自己的分支(提取与更新仍可用)。
30
+ - **原地新建分支**:菜单工具栏的加号弹出创建弹窗,边输边校验(git ref 规则 + 重名检查);「确认」一把完成新建并切换(detached HEAD 亦可用),失败后弹窗保留、可改名重试。
31
+ - **远程同步**:工具栏末位的刷新按钮 fetch 全部远程并清理失效跟踪分支——列表原地刷新,无需去终端。
32
+ - **更新当前分支**:把当前分支快进到其上游;本地分叉、无上游、工作区改动冲突都会被拒绝并给出 git 原话——插件绝不代你 stash 或改写历史。
33
+ - **工作树隔离**:空白会话勾选**「工作树」**弹出切出弹窗,分支名可编辑(预填第一个空闲的 `<当前分支>-wt`);确认后切出并隔离到全新 worktree,注册为真实工作区。分支菜单仍可用——选其他分支则改为在 `~/.dsh/gitworktree/<仓库>-<分支>/` 下创建 worktree,重复选同一分支直接复用已有的。
34
+ - **删除工作树**:工作树行的 ⋯ 菜单提供**「删除工作树」**——弹窗先红色列出未提交文件数、标注领先提交数,并预告工作区下的会话将一并归档;确认后先删 worktree、再归档会话。git 失败时 DSH 侧零变更、弹窗原地重试。
35
+ - **未分组虚拟目录组**:不属于任何工作区的会话按目录聚成分组视图尾部的**「未分组」**区(虚线文件夹图标区分)。目录与已注册工作区匹配的组标注为失联会话;目录真实存在的组可一键注册为工作区;存放位直下消失的目录可一键重建空目录——历史会话自动归位。
36
+ - **存放根路径可配**:**设置 → 插件**下的 **Git 工作树** 卡片——目录选择器或手输路径,保存即生效;留空使用默认 `$DSH_HOME/gitworktree`。旧版 `~/.dsh/gitworktree/settings.json` 的值升级后自动迁入。
37
+ - **聚合工作区**:插件替换原生侧边栏,把同一仓库的主仓库与 worktree 聚成可折叠的仓库组——分组从磁盘 git 事实派生、不存关系数据。设置卡**聚合工作区**开关(测试功能,默认开)可随时切回原生列表。
39
38
 
40
39
  ![侧边栏按仓库聚合工作区](sidebar-grouping_zh.png)
41
40
 
42
41
  ## 安装
43
42
 
44
- ### 从 npm 安装
45
-
46
43
  ```sh
47
44
  dsh plugin --profile web add @laoyuehanni/dsh-git-worktree
48
45
  ```
49
46
 
50
- > 包声明了 `dsh.bundle`,`add` 会自动把插件挂进 profile 的层栈,无需手动改配置。编译产物 `lib/` 随 npm 包分发,安装开箱即用,无需任何构建步骤。需要 `web` profile(`dsh web`)。
51
-
52
- ### 从 npm 安装 —— dsh 0.1.2-alpha.x 宿主
47
+ > 包声明了 `dsh.bundle`,`add` 会自动把插件挂进 profile 的层栈,无需手动改配置。需要 `web` profile(`dsh web`)以及 dsh **0.1.2-rc.1**(或之后的 0.1.2)宿主。
53
48
 
54
- 上面的 `latest` 通道面向稳定宿主(rc 系列)。若你运行的是 dsh **0.1.2 alpha** 宿主,请改装专用兼容版本:
49
+ 运行 dsh **0.1.2 alpha** 宿主?请改装专用兼容版本:
55
50
 
56
51
  ```sh
57
52
  dsh plugin --profile web add @laoyuehanni/dsh-git-worktree@dsh-alpha
58
53
  ```
59
54
 
60
- > `@dsh-alpha` 是 dist-tag(不是字面版本号),registry 会解析为最新的兼容构建——当前为 `0.4.1-dsh-0.1.2-alpha.3`。其 peer 范围锁定 `>=0.1.2-alpha.3 <0.2.0`,而稳定线保持在 rc peer 上:普通 `update` 不会把两条通道混装,`dsh plugin update` 也只会从对应通道拉取。宿主升回稳定线时,先移除此包,再按上一小节安装默认版本。
61
-
62
- ### 从本地目录安装(开发调试用)
63
-
64
- ```sh
65
- dsh plugin --profile web add link:D:/Code/dsh-worktree
66
- ```
67
-
68
- `link:` 安装的是符号链接:重新构建插件后重启 `dsh web` 即可生效。
55
+ > `@dsh-alpha` 是 dist-tag,解析为最新的 alpha 宿主兼容构建(当前 `0.4.3-dsh-0.1.2-alpha.5`),peer 锁定 alpha 线——普通 `update` 不会把两条通道混装。已在 0.1.2-rc.1 或更新宿主上,请用上面的默认线。
69
56
 
70
57
  ## 更新
71
58
 
@@ -79,27 +66,23 @@ dsh plugin --profile web update @laoyuehanni/dsh-git-worktree
79
66
  dsh plugin --profile web remove @laoyuehanni/dsh-git-worktree
80
67
  ```
81
68
 
82
- 插件会从 profile 移除并停止加载。`~/.dsh/gitworktree/` 下的 worktree 目录会保留;已迁移的旧设置文件(`settings.json.migrated`)如不需要可手动删除,插件自身的设置项存于 dsh 设置文档。
69
+ `~/.dsh/gitworktree/` 下的 worktree 目录会保留;插件自身的设置存于 dsh 设置文档。
83
70
 
84
71
  ## 开发
85
72
 
86
- 先构建一次插件:
73
+ 构建一次、装符号链接、迭代:
87
74
 
88
75
  ```sh
89
76
  npm install
90
77
  npm run build && npm run build:client
91
- npm test # vitest(60 项测试)
78
+ npm test # vitest
92
79
  node scripts/smoke.mjs # 基于构建产物的真实 git 冒烟
80
+ dsh plugin --profile web add link:D:/Code/dsh-worktree
93
81
  ```
94
82
 
95
- > **刻意不设 `prepare` 脚本。** 编译产物 `lib/` 已提交进仓库,并随 npm 包分发。pnpm ≥ 10 默认拒绝执行依赖的构建脚本,除非加入白名单,因此若保留 `prepare`,pnpm 用户的安装会出现被跳过或失败的步骤。改为分发预构建产物后,`dsh plugin add @laoyuehanni/dsh-git-worktree` 才能开箱即用。**改动 `src/` 下的任何文件后,务必重新构建并提交更新后的 `lib/`**(并发布新版本),否则别人安装到的是旧产物:
96
-
97
- ```sh
98
- npm run build && npm run build:client
99
- git add lib/
100
- ```
83
+ 重新构建并重启 `dsh web` 即可生效(插件目录里跑 `npx tsdown --watch` 可热重载客户端)。刻意不设 `prepare` 脚本——`lib/` 不入库,`npm publish` 现场构建打进 tarball。
101
84
 
102
- 临时挂载 —— 仅当次启动生效,不动 profile。在仓库旁建一个 `cordis.yml` 指向构建出的 host 半边(Windows 需要 `file:///` 形式):
85
+ 临时只挂 host 半边(仅当次启动生效,不动 profile):在仓库旁建 `cordis.yml` 指向构建出的 host 半边(Windows 需要 `file:///` 形式),随补丁启动:
103
86
 
104
87
  ```yml
105
88
  - insert:
@@ -111,4 +94,4 @@ git add lib/
111
94
  dsh web --patch <插件目录>/cordis.yml
112
95
  ```
113
96
 
114
- 此模式只挂载 host 半边(`/plugin/git-worktree/*` 三条路由照常工作);分支 chip 依赖按包名解析的客户端 bundle,因此开发 UI 请用上面的 `link:` 安装方式:执行 `npm run build && npm run build:client`(或在插件目录跑 `npx tsdown --watch`)并重启 `dsh web` 后,浏览器端插件会自动热重载。
97
+ 此模式只挂载 host 半边(`/plugin/git-worktree/*` 三条路由照常工作);开发 UI 请用上面的 `link:` 安装方式。