@laoyuehanni/dsh-git-worktree 0.4.1 → 0.4.3
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 +12 -0
- package/README.zh.md +12 -0
- package/lib/client.js +840 -100
- package/lib/client.js.map +1 -1
- package/lib/git.d.ts +46 -2
- package/lib/git.js +72 -10
- package/lib/index.js +34 -2
- package/lib/routes.d.ts +55 -2
- package/lib/routes.js +178 -6
- package/lib/wire.d.ts +68 -0
- package/lib/wire.js +8 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -32,6 +32,8 @@ Repo: <https://github.com/LaoYueHanNi/dsh-git-worktree>
|
|
|
32
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
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
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.
|
|
35
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).
|
|
36
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.
|
|
37
39
|
|
|
@@ -47,6 +49,16 @@ dsh plugin --profile web add @laoyuehanni/dsh-git-worktree
|
|
|
47
49
|
|
|
48
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`).
|
|
49
51
|
|
|
52
|
+
### From npm — dsh 0.1.2-alpha.x host
|
|
53
|
+
|
|
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:
|
|
55
|
+
|
|
56
|
+
```sh
|
|
57
|
+
dsh plugin --profile web add @laoyuehanni/dsh-git-worktree@dsh-alpha
|
|
58
|
+
```
|
|
59
|
+
|
|
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
|
+
|
|
50
62
|
### From a local directory (development)
|
|
51
63
|
|
|
52
64
|
```sh
|
package/README.zh.md
CHANGED
|
@@ -32,6 +32,8 @@
|
|
|
32
32
|
- **远程同步**:分支菜单工具栏末位的刷新按钮执行 `git fetch --all --prune`——远程新增/删除的分支当场出现在列表里,无需去终端;菜单保持打开并原地刷新,失败 toast。
|
|
33
33
|
- **更新当前分支**:实线箭头(虚线提取旁)更新**当前分支**——先 fetch 全部远程,再把当前分支快进(`--ff-only`)到其上游。本地分叉、无上游、工作区改动冲突都会被拒绝并给出 git 原话;插件绝不代你 stash 或改写历史。
|
|
34
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 接口。
|
|
35
37
|
- **存放根路径可配**:**设置 → 插件**页签下的 **Git 工作树** 卡片 —— 原生目录选择器或手输绝对路径,保存即生效(新建的 worktree 落在新目录,已有的留在原地,git 仍能识别复用)。留空使用默认 `$DSH_HOME/gitworktree`(`~/.dsh/gitworktree`)。设置存于 dsh 统一设置文档;旧版 `~/.dsh/git-work-tree/settings.json` 的已保存值会在升级后自动迁入(原文件改名 `.migrated` 保留)。
|
|
36
38
|
- **聚合工作区**:DSH 尚未开放多工作区聚合接口,故按原生侧边栏 1:1 替换左侧列表,并把同一仓库的主仓库与 worktree 工作区聚成可折叠的**仓库组**——主行显示 `主仓库(分支)`,工作树行显示分支。分组从磁盘 git 事实派生、不存关系数据;没有 worktree 的仓库保持单行。设置卡 **聚合工作区**(测试功能,默认开)可随时切回原生。
|
|
37
39
|
|
|
@@ -47,6 +49,16 @@ dsh plugin --profile web add @laoyuehanni/dsh-git-worktree
|
|
|
47
49
|
|
|
48
50
|
> 包声明了 `dsh.bundle`,`add` 会自动把插件挂进 profile 的层栈,无需手动改配置。编译产物 `lib/` 随 npm 包分发,安装开箱即用,无需任何构建步骤。需要 `web` profile(`dsh web`)。
|
|
49
51
|
|
|
52
|
+
### 从 npm 安装 —— dsh 0.1.2-alpha.x 宿主
|
|
53
|
+
|
|
54
|
+
上面的 `latest` 通道面向稳定宿主(rc 系列)。若你运行的是 dsh **0.1.2 alpha** 宿主,请改装专用兼容版本:
|
|
55
|
+
|
|
56
|
+
```sh
|
|
57
|
+
dsh plugin --profile web add @laoyuehanni/dsh-git-worktree@dsh-alpha
|
|
58
|
+
```
|
|
59
|
+
|
|
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
|
+
|
|
50
62
|
### 从本地目录安装(开发调试用)
|
|
51
63
|
|
|
52
64
|
```sh
|