@laoyuehanni/dsh-git-worktree 0.4.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 LaoYueHanNi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,82 @@
1
+ # dsh-git-worktree
2
+
3
+ ![dsh-git-worktree in the Web UI](gitworktree.png)
4
+
5
+ [简体中文](./README.zh.md) | English
6
+
7
+ 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.
8
+
9
+ [dsh]: https://github.com/cordiverse/dsh
10
+
11
+ Repo: <https://github.com/LaoYueHanNi/dsh-git-worktree>
12
+
13
+ ## Features
14
+
15
+ - **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. 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.
16
+ - **Branch switching**: pick a branch from the chip's menu and confirm — an in-place `git switch`. Inside a linked worktree it switches within that worktree only.
17
+ - **Worktree isolation**: on a blank session, checking the **Worktree** toggle pops the cutout confirm right above the chip — confirming it cuts a NEW branch (`<current>-wt`, `-wt2`, … past taken names) 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.
18
+ - **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).
19
+
20
+ ## Install
21
+
22
+ ### From GitHub (recommended)
23
+
24
+ ```sh
25
+ dsh plugin --profile web add github:LaoYueHanNi/dsh-git-worktree
26
+ ```
27
+
28
+ > The package declares `dsh.bundle`, so `add` wires the plugin into the profile's layer stack automatically — no config editing needed. The built `lib/` ships in the repo (there is no `prepare` script), so git installs work out of the box without any build allowlist. Requires the `web` profile (`dsh web`).
29
+
30
+ ### From a local directory (development)
31
+
32
+ ```sh
33
+ dsh plugin --profile web add link:D:/Code/dsh-worktree
34
+ ```
35
+
36
+ `link:` installs a symlink: rebuild the plugin and restart `dsh web` to apply changes.
37
+
38
+ ## Update
39
+
40
+ ```sh
41
+ dsh plugin --profile web update dsh-git-worktree
42
+ ```
43
+
44
+ ## Remove
45
+
46
+ ```sh
47
+ dsh plugin --profile web remove dsh-git-worktree
48
+ ```
49
+
50
+ 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.
51
+
52
+ ## Development
53
+
54
+ Build the plugin once:
55
+
56
+ ```sh
57
+ npm install
58
+ npm run build && npm run build:client
59
+ npm test # vitest (60 tests)
60
+ node scripts/smoke.mjs # real-git smoke over the built lib
61
+ ```
62
+
63
+ > **No `prepare` script — by design.** The compiled `lib/` output is committed to the repo. pnpm ≥ 10 refuses to run build scripts of git-hosted dependencies unless they are allowlisted (`ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED`), so a `prepare` script would break the zero-config `github:` install for every user. Shipping prebuilt output instead keeps `dsh plugin add github:LaoYueHanNi/dsh-git-worktree` working out of the box. **After changing anything under `src/`, always rebuild and commit the updated `lib/`**, or installs will get stale output:
64
+
65
+ ```sh
66
+ npm run build && npm run build:client
67
+ git add lib/
68
+ ```
69
+
70
+ 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):
71
+
72
+ ```yml
73
+ - insert:
74
+ - id: git-worktree
75
+ name: 'file:///D:/Code/dsh-worktree/lib/index.js'
76
+ ```
77
+
78
+ ```sh
79
+ dsh web --patch <plugin-dir>/cordis.yml
80
+ ```
81
+
82
+ 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.
package/README.zh.md ADDED
@@ -0,0 +1,82 @@
1
+ # dsh-git-worktree
2
+
3
+ ![Web 界面中的 dsh-git-worktree](gitworktree.png)
4
+
5
+ 简体中文 | [English](./README.md)
6
+
7
+ 一个 [dsh] 插件:在 Web 界面进行简单的分支与 worktree 管理。输入框工具行显示当前分支 —— 选其他分支原地切换;勾选**「工作树」**则获得一个注册为真实工作区的隔离 worktree,效果见上图。
8
+
9
+ [dsh]: https://github.com/cordiverse/dsh
10
+
11
+ 仓库:<https://github.com/LaoYueHanNi/dsh-git-worktree>
12
+
13
+ ## 功能
14
+
15
+ - **IDEA 风格分支选择器**:分支菜单把 `/` 视为文件夹层级 —— 可折叠文件夹、末段标签,当前分支所在链路默认展开并居中。单击选中(蓝底),双击或 Enter 弹出右侧确认弹层。左侧工具栏提供**定位当前分支**与**全部展开/折叠**;底部搜索保留匹配分支的祖先文件夹并高亮命中字符;超长标签悬停显示全名。
16
+ - **分支切换**:从 chip 菜单选分支、确认后原地 `git switch`。在 worktree 会话内只作用于该 worktree。
17
+ - **工作树隔离**:空白会话上勾选**「工作树」**立即在 chip 上方弹出「从当前分支切出」确认弹窗——确认后从当前检出切出**新分支**(`<当前分支>-wt`,重名自动递增 `-wt2`、`-wt3`…)并隔离到全新 worktree;分支 chip 的菜单仍可打开,选其他分支则在 `~/.dsh/gitworktree/<仓库>-<分支>/` 下执行 `git worktree add`。两条路径都会注册为真实工作区并跳转到新目录的空白会话。重复选同一分支直接复用;失效注册自动 prune 恢复。取消确认弹窗后直接发消息,即默许在当前目录开始会话。
18
+ - **存放根路径可配**:**设置 → 插件**页签下的 **Git 工作树** 卡片 —— 原生目录选择器或手输绝对路径,保存即生效(新建的 worktree 落在新目录,已有的留在原地,git 仍能识别复用)。留空使用默认 `$DSH_HOME/gitworktree`(`~/.dsh/gitworktree`)。设置存于 dsh 统一设置文档;旧版 `~/.dsh/git-work-tree/settings.json` 的已保存值会在升级后自动迁入(原文件改名 `.migrated` 保留)。
19
+
20
+ ## 安装
21
+
22
+ ### 从 GitHub 安装(推荐)
23
+
24
+ ```sh
25
+ dsh plugin --profile web add github:LaoYueHanNi/dsh-git-worktree
26
+ ```
27
+
28
+ > 包声明了 `dsh.bundle`,`add` 会自动把插件挂进 profile 的层栈,无需手动改配置。构建产物 `lib/` 随仓库提交(没有 `prepare` 脚本),git 安装开箱即用,无需任何构建白名单。需要 `web` profile(`dsh web`)。
29
+
30
+ ### 从本地目录安装(开发调试用)
31
+
32
+ ```sh
33
+ dsh plugin --profile web add link:D:/Code/dsh-worktree
34
+ ```
35
+
36
+ `link:` 安装的是符号链接:重新构建插件后重启 `dsh web` 即可生效。
37
+
38
+ ## 更新
39
+
40
+ ```sh
41
+ dsh plugin --profile web update dsh-git-worktree
42
+ ```
43
+
44
+ ## 移除
45
+
46
+ ```sh
47
+ dsh plugin --profile web remove dsh-git-worktree
48
+ ```
49
+
50
+ 插件会从 profile 移除并停止加载。`~/.dsh/gitworktree/` 下的 worktree 目录会保留;已迁移的旧设置文件(`settings.json.migrated`)如不需要可手动删除,插件自身的设置项存于 dsh 设置文档。
51
+
52
+ ## 开发
53
+
54
+ 先构建一次插件:
55
+
56
+ ```sh
57
+ npm install
58
+ npm run build && npm run build:client
59
+ npm test # vitest(60 项测试)
60
+ node scripts/smoke.mjs # 基于构建产物的真实 git 冒烟
61
+ ```
62
+
63
+ > **刻意不设 `prepare` 脚本。** 编译产物 `lib/` 已提交进仓库。pnpm ≥ 10 默认拒绝执行 git-hosted 依赖的构建脚本,除非加入白名单(报错 `ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED`),因此若保留 `prepare`,每个用户用 `github:` 安装都会失败。改为随仓库分发预构建产物后,`dsh plugin add github:LaoYueHanNi/dsh-git-worktree` 才能零配置开箱即用。**改动 `src/` 下的任何文件后,务必重新构建并提交更新后的 `lib/`**,否则别人安装到的是旧产物:
64
+
65
+ ```sh
66
+ npm run build && npm run build:client
67
+ git add lib/
68
+ ```
69
+
70
+ 临时挂载 —— 仅当次启动生效,不动 profile。在仓库旁建一个 `cordis.yml` 指向构建出的 host 半边(Windows 需要 `file:///` 形式):
71
+
72
+ ```yml
73
+ - insert:
74
+ - id: git-worktree
75
+ name: 'file:///D:/Code/dsh-worktree/lib/index.js'
76
+ ```
77
+
78
+ ```sh
79
+ dsh web --patch <插件目录>/cordis.yml
80
+ ```
81
+
82
+ 此模式只挂载 host 半边(`/plugin/git-worktree/*` 三条路由照常工作);分支 chip 依赖按包名解析的客户端 bundle,因此开发 UI 请用上面的 `link:` 安装方式:执行 `npm run build && npm run build:client`(或在插件目录跑 `npx tsdown --watch`)并重启 `dsh web` 后,浏览器端插件会自动热重载。
@@ -0,0 +1,5 @@
1
+ # The dsh-git-worktree bundle patch: one insert over the profile root. Later
2
+ # layers (the user's profile cordis.patch.yml) may address the row by id.
3
+ - insert:
4
+ - id: git-worktree
5
+ name: '@laoyuehanni/dsh-git-worktree'