@laoyuehanni/dsh-git-worktree 0.4.5 → 0.4.6-rc.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/README.md CHANGED
@@ -25,19 +25,21 @@ Repo: <https://github.com/LaoYueHanNi/dsh-git-worktree>
25
25
 
26
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
27
  - **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.
28
- - **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. 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.
28
+ - **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.
29
29
  - **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.
30
30
  - **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).
31
31
  - **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.
32
32
  - **Remote sync**: the last toolbar tool fetches every remote and prunes stale tracking branches — the list refreshes in place, no terminal round-trip.
33
33
  - **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.
34
- - **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 `~/.dsh/gitworktree/<repo>-<branch>/` and registers a real workspace, with same-branch re-creates reusing the existing worktree. Once the session starts the directory is fixed — the worktree verbs hide along with the Worktrees group.
35
- - **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.
36
- - **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.
37
- - **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.
38
- - **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.
34
+ - **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.
35
+ - **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.
36
+ - **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.
37
+ - **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.
39
38
 
40
- ![Same-repository workspaces grouped in the sidebar](sidebar-grouping.png)
39
+ > [!NOTE]
40
+ > - 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).
41
+ > - `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.
42
+ > - 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.
41
43
 
42
44
  ## Install
43
45
 
@@ -45,7 +47,7 @@ Repo: <https://github.com/LaoYueHanNi/dsh-git-worktree>
45
47
  dsh plugin --profile web add @laoyuehanni/dsh-git-worktree
46
48
  ```
47
49
 
48
- > 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.
50
+ > 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.6-alpha.2** (or later) host.
49
51
 
50
52
  Running a dsh **0.1.2 alpha** host? Install the dedicated compatibility build instead:
51
53
 
@@ -67,21 +69,21 @@ dsh plugin --profile web update @laoyuehanni/dsh-git-worktree
67
69
  dsh plugin --profile web remove @laoyuehanni/dsh-git-worktree
68
70
  ```
69
71
 
70
- Worktree folders under `~/.dsh/gitworktree/` are kept; the plugin's own settings live in the dsh settings document.
72
+ 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.
71
73
 
72
74
  ## Development
73
75
 
74
76
  Build once, install a symlink, iterate:
75
77
 
76
78
  ```sh
77
- npm install
78
- npm run build && npm run build:client
79
- npm test # vitest
79
+ pnpm install
80
+ pnpm build:all
81
+ pnpm test # vitest
80
82
  node scripts/smoke.mjs # real-git smoke over the built lib
81
83
  dsh plugin --profile web add link:D:/Code/dsh-worktree
82
84
  ```
83
85
 
84
- 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.
86
+ 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.
85
87
 
86
88
  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:
87
89
 
package/README.zh.md CHANGED
@@ -25,19 +25,21 @@
25
25
 
26
26
  - **IDEA 风格分支选择器**:分支菜单把 `/` 视为文件夹层级——可折叠文件夹、末段标签,当前分支所在链路默认展开并居中。本地与远程分支分两个可折叠分组(单远程自动剥掉前缀),底部搜索保留匹配分支的祖先文件夹并高亮命中,左侧工具栏提供定位当前分支与全部展开/折叠,有上游的本地分支行尾显示 ↑N/↓N 领先落后标记。
27
27
  - **远程分支检出**:远程组里选中 `origin/feat-x` 直接原地检出并自动创建跟踪分支(免确认);勾选工作树开关则改为隔离进独立 worktree。
28
- - **行级右键菜单**:分支行右键弹出六个动作——签出(免确认直接切)、新建、新建并检出、重命名分支(本地行)、删除分支(本地行,安全 `-d`,git 拒绝未合并提交与被占用分支)、复制分支;工作树行为跳到此工作树 + 复制路径。二级弹窗(命名/确认)直接在菜单位置就地展开,原地动作完成后菜单保持打开,可连续操作。键盘走方向键 + Enter。
28
+ - **行级右键菜单**:分支行右键弹出六个动作——签出(免确认直接切)、新建、新建并检出、重命名分支(本地行)、删除分支(本地行,安全 `-d`,git 拒绝未合并提交与被占用分支)、复制分支;工作树行为跳到此工作树 + 复制路径 + 删除工作树。二级弹窗(命名/确认)直接在菜单位置就地展开,原地动作完成后菜单保持打开,可连续操作。键盘走方向键 + Enter。
29
29
  - **工作树快捷入口**:主仓库空白会话的分支菜单把被 worktree 占用的分支收进**「工作树」**分组(hover 显示目录路径),右键「跳到此工作树」直接跳进对应目录开始新会话。
30
30
  - **分支切换**:选分支即原地 `git switch`(免确认)。worktree 会话里入口整体收敛:其他分支照常展示但置灰,操作提示去主仓库发起;已启动的会话菜单只显示自己的分支(提取与更新仍可用)。
31
31
  - **从任意分支新建/重命名**:右键任意分支行即可**从该分支**新建(不动当前检出)或新建并检出(当场签出),创建弹窗边输边校验(git ref 规则 + 重名检查)、一把执行,失败后弹窗保留、可改名重试;本地行还可原地重命名。
32
32
  - **远程同步**:工具栏末位的刷新按钮 fetch 全部远程并清理失效跟踪分支——列表原地刷新,无需去终端。
33
33
  - **更新当前分支**:把当前分支快进到其上游;本地分叉、无上游、工作区改动冲突都会被拒绝并给出 git 原话——插件绝不代你 stash 或改写历史。
34
- - **工作树隔离**:未开始的会话里,右键任意分支行即可**「创建工作树」**(复用或新建目录)或**「新建分支并创建工作树」**(从该分支切出新分支,名字手动输入),确认后隔离到 `~/.dsh/gitworktree/<仓库>-<分支>/` 并注册为真实工作区,重复创建直接复用已有的;会话开始后目录固定,工作树选项随「工作树」分组一并隐藏。
35
- - **删除工作树**:工作树行的 ⋯ 菜单提供**「删除工作树」**——弹窗先红色列出未提交文件数、标注领先提交数,并预告工作区下的会话将一并归档;确认后先删 worktree、再归档会话。git 失败时 DSH 侧零变更、弹窗原地重试。
36
- - **未分组虚拟目录组**:不属于任何工作区的会话按目录聚成分组视图尾部的**「未分组」**区(虚线文件夹图标区分)。目录与已注册工作区匹配的组标注为失联会话;目录真实存在的组可一键注册为工作区;存放位直下消失的目录可一键重建空目录——历史会话自动归位。
37
- - **存放根路径可配**:**设置 → 插件**下的 **Git 工作树** 卡片——目录选择器或手输路径,保存即生效;留空使用默认 `$DSH_HOME/gitworktree`。旧版 `~/.dsh/gitworktree/settings.json` 的值升级后自动迁入。
38
- - **聚合工作区**:插件替换原生侧边栏,把同一仓库的主仓库与 worktree 聚成可折叠的仓库组——分组从磁盘 git 事实派生、不存关系数据。设置卡**聚合工作区**开关(测试功能,默认开)可随时切回原生列表。
34
+ - **工作树隔离**:未开始的会话里,右键任意分支行即可**「创建工作树」**(复用或新建目录)或**「新建分支并创建工作树」**(从该分支切出新分支,名字手动输入),确认后隔离到仓库内的 `<repo>/.dsh/gitworktree/<分支>/`(通过 `.git/info/exclude` 本地忽略——源仓库 `git status` 保持干净)并注册为真实工作区,重复创建复用已有(无论它位于何处);会话开始后目录固定,工作树选项随「工作树」分组一并隐藏。
35
+ - **删除工作树**:分支菜单**「工作树」**分组的行右键(及管理弹窗)提供**「删除工作树」**——弹窗先红色列出未提交文件数、标注领先提交数,并预告工作区下的会话将一并归档;确认后先删 git worktree(分支本身保留),再归档会话、注销工作区。git 失败时 DSH 侧零变更、弹窗原地重试;有正在运行的会话时该项禁用。
36
+ - **工作树管理**:**设置 → 插件**里的插件配置页可打开管理弹窗,跨仓库列出两处存放位置(各仓库的 `.dsh/gitworktree` 布局与旧的集中根目录)的全部工作树,按仓库分组并带来源标识,无法识别的目录也在列。
37
+ - **历史位置只读**:同一页面只读展示历史集中存放根(默认 `~/.dsh/gitworktree`)——已有工作树原地保留、照常可用,新建的落在各仓库内。旧版 `~/.dsh/gitworktree/settings.json` 的值升级后自动迁入。
39
38
 
40
- ![侧边栏按仓库聚合工作区](sidebar-grouping_zh.png)
39
+ > [!NOTE]
40
+ > - 原生侧边栏不受影响:工作树是普通注册工作区,工作区树会把各仓库内的布局自动归到其仓库之下(集中存放的旧工作树位置不变,只有新建的才归位)。
41
+ > - `git clean -xdff`(双 `-f`)会删掉仓库内的工作树目录(单 `-f` 会跳过嵌套仓库);删后 `git worktree prune` 可恢复注册,但其中未提交的改动会丢。
42
+ > - 某仓库的工作区全部注销后,它的工作树不再出现在管理弹窗与自动清理中;重新注册该仓库任一目录即可找回。
41
43
 
42
44
  ## 安装
43
45
 
@@ -45,7 +47,7 @@
45
47
  dsh plugin --profile web add @laoyuehanni/dsh-git-worktree
46
48
  ```
47
49
 
48
- > 包声明了 `dsh.bundle`,`add` 会自动把插件挂进 profile 的层栈,无需手动改配置。需要 `web` profile(`dsh web`)以及 dsh **0.1.2-rc.1**(或之后的 0.1.2)宿主。
50
+ > 包声明了 `dsh.bundle`,`add` 会自动把插件挂进 profile 的层栈,无需手动改配置。需要 `web` profile(`dsh web`)以及 dsh **0.1.6-alpha.2**(或更新)宿主。
49
51
 
50
52
  运行 dsh **0.1.2 alpha** 宿主?请改装专用兼容版本:
51
53
 
@@ -67,21 +69,21 @@ dsh plugin --profile web update @laoyuehanni/dsh-git-worktree
67
69
  dsh plugin --profile web remove @laoyuehanni/dsh-git-worktree
68
70
  ```
69
71
 
70
- `~/.dsh/gitworktree/` 下的 worktree 目录会保留;插件自身的设置存于 dsh 设置文档。
72
+ 两处位置(各仓库的 `.dsh/gitworktree` 布局与旧的集中根目录)的 worktree 目录都会保留;插件自身的设置存于 dsh 设置文档。
71
73
 
72
74
  ## 开发
73
75
 
74
76
  构建一次、装符号链接、迭代:
75
77
 
76
78
  ```sh
77
- npm install
78
- npm run build && npm run build:client
79
- npm test # vitest
79
+ pnpm install
80
+ pnpm build:all
81
+ pnpm test # vitest
80
82
  node scripts/smoke.mjs # 基于构建产物的真实 git 冒烟
81
83
  dsh plugin --profile web add link:D:/Code/dsh-worktree
82
84
  ```
83
85
 
84
- 重新构建并重启 `dsh web` 即可生效(插件目录里跑 `npx tsdown --watch` 可热重载客户端)。刻意不设 `prepare` 脚本——`lib/` 不入库,`npm publish` 现场构建打进 tarball。
86
+ 重新构建并重启 `dsh web` 即可生效(插件目录里跑 `pnpm watch:client` 可热重载客户端)。刻意不设 `prepare` 脚本——`lib/` 不入库,`pnpm publish` 现场构建打进 tarball。
85
87
 
86
88
  临时只挂 host 半边(仅当次启动生效,不动 profile):在仓库旁建 `cordis.yml` 指向构建出的 host 半边(Windows 需要 `file:///` 形式),随补丁启动:
87
89