@young1lin/dsh-ui-gitworkbench 0.1.0 → 0.1.2

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/CHANGELOG.md ADDED
@@ -0,0 +1,28 @@
1
+ # 更新日志
2
+
3
+ 本文件记录面向使用者的变更。格式参考 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/),版本号遵循语义化版本。
4
+
5
+ ## [0.1.2] - 2026-08-17
6
+
7
+ ### 修复
8
+
9
+ - **抽屉关着时,会话头状态卡的统计不再冻结在挂载时刻**:此前 agent 整轮改文件期间,芯片上的文件数 / 增删行数 / ↑↓ 计数一直停在 turn 开始前的数字,只能点开抽屉强制刷新。现在芯片跟踪 dsh 会话 store 实时镜像的 `running` 信号——turn 一结束(agent 副作用落定的时刻)自动取一次最新统计:不重置抽屉里的树展开状态、不闪加载占位;turn 进行中不刷(数字在结束时一次到位),空闲会话保持零轮询开销。↑/↓ 计数随同一载荷返回,agent 提交完领先数立即对上。编辑器等会话外的改动仍以打开抽屉为准(维持原有设计)。
10
+
11
+ ## [0.1.1] - 2026-08-17
12
+
13
+ ### 修复
14
+
15
+ - **`worktree_enter` 的名称校验过度限制**:`+` 在 git 分支名与 Windows 目录名里都合法,却被旧的白名单 `[A-Za-z0-9._-]{1,40}` 拒绝——真实名字 `feature+20260810-...` 被静默改写成自动生成的 `wt-<hex>`。字符集改为「git ref 规则 ∩ Windows 目录规则」的交集:`+` 放行;`..`、结尾点、`.lock` 结尾、Windows 保留设备名(CON/NUL/COM1-9/LPT1-9,含点前部分、不区分大小写)与 `head` 拒绝;必须以字母或数字开头;上限放宽到 64 字符。
16
+ - **分支名不再强制 `wt/` 前缀**:新建 worktree 的分支就是名字本身;名字缺省或非法时自动生成的回退名也改为 `worktree-<hex>`,任何环节都不再出现强制的 `wt`。
17
+ - **「复用」改为 realpath 匹配**:目标目录已是注册 worktree 时(包括其他工具创建的、或 `.agents/worktrees` 是指向 `.claude/worktrees` 的 Junction 而 git 登记的是另一种拼写),直接绑定该 worktree 并**保留它自己的分支**,不再无条件 `git worktree add` 撞路径报错(`fatal: ... already exists`)。
18
+ - CI:`pnpm/action-setup` 不再在 workflow 里声明 pnpm 版本,以 `package.json` 的 `packageManager` 为唯一事实源(两处声明会让 action 直接报错)。
19
+
20
+ ### 新增
21
+
22
+ - 绑定记录新增可选 `branch` 字段:系统提示与状态卡徽标显示绑定 worktree 的真实分支,不再按名字推导;旧记录无此字段完全兼容。
23
+ - diff 视图新增 **SQL / XML(含 xsl、xsd、svg)/ INI(含 properties、conf、cfg)/ diff(patch)** 语法高亮。
24
+ - README 中文版重写(安装以官方插件命令置顶,一键脚本降为备选);新增地道英文版 `README_EN.md`;两个 README 顶部嵌入演示视频。
25
+
26
+ ## [0.1.0] - 2026-08-17
27
+
28
+ 首个发布。会话头状态卡(分支 / 领先落后 / 增删计数)+ 工作台面板(变更、历史、对比三页签),逐文件 diff(双列行号、词级高亮、Shiki 语法着色),树上勾选即真实暂存,配提交框与 fetch / pull / push 同步条;七套主题族 × 亮暗、背景图与自定义 CSS(项目 / 全局两作用域);worktree 仿真(`worktree_enter` / `worktree_exit` / `worktree_status` 三个 agent 工具 + 会话绑定)。详见 [README](./README.md)。
@@ -0,0 +1,28 @@
1
+ # Changelog
2
+
3
+ User-facing changes, newest first. Format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/); versioning follows SemVer.
4
+
5
+ ## [0.1.2] - 2026-08-17
6
+
7
+ ### Fixed
8
+
9
+ - **The session-header stats card no longer freezes while the drawer is shut.** Through a whole agent turn of edits, the chip's file count, +/− line totals and ahead/behind markers kept showing pre-turn numbers until you opened the drawer and forced a refresh. The chip now tracks the `running` signal dsh mirrors live in the sessions store: the moment a turn ends — when agent side effects have settled — it fetches fresh stats on its own, without resetting the drawer's tree expansion or flashing a loading placeholder. Mid-turn it does not churn (numbers land once, at the end) and idle sessions stay free of polling. Ahead/behind ride in the same payload, so the ↑ count catches up right after the agent commits. Out-of-session edits (your editor, other shells) still wait for the drawer to open, as before.
10
+
11
+ ## [0.1.1] - 2026-08-17
12
+
13
+ ### Fixed
14
+
15
+ - **`worktree_enter` rejected names git accepts.** `+` is legal in both git refs and NTFS directories, but the old allowlist `[A-Za-z0-9._-]{1,40}` refused it — a real `feature+20260810-...` was silently rewritten to a generated `wt-<hex>`. The charset is now the intersection of git's ref rules and Windows' directory rules: `+` allowed; `..`, trailing dots, `.lock` endings, Windows reserved device names (CON/NUL/COM1-9/LPT1-9, checked before the first dot, case-insensitive) and `head` refused; must start alphanumeric; cap raised to 64 characters.
16
+ - **No forced `wt/` branch prefix.** A freshly created worktree's branch is the name verbatim, and the generated fallback name is `worktree-<hex>` — no `wt` anywhere, at any layer.
17
+ - **Reuse now matches on real paths.** When the target directory already holds a registered worktree — one made by another tool, or reached through a junction (`.agents/worktrees` pointing at `.claude/worktrees`) where git lists a different spelling — the session binds to it and **keeps its own branch**, instead of unconditionally running `git worktree add` into a `fatal: ... already exists`.
18
+ - CI: `pnpm/action-setup` no longer declares a pnpm version in the workflows — `package.json`'s `packageManager` is the single source of truth (specifying both aborts the action).
19
+
20
+ ### Added
21
+
22
+ - Optional `branch` field on session bindings: the system prompt and the status-card badge state the bound worktree's real branch instead of deriving one; records written before the field existed remain valid.
23
+ - Syntax highlighting for **SQL, XML (xsl/xsd/svg), INI (properties/conf/cfg), and diff (patch)** files in the diff view.
24
+ - The Chinese README was rewritten (the official plugin command now leads the install section, one-liner scripts demoted to an alternative) and an idiomatic `README_EN.md` was added; both embed the demo video up top.
25
+
26
+ ## [0.1.0] - 2026-08-17
27
+
28
+ Initial release. A session-header status card (branch / ahead-behind / counts) plus a workbench panel (Changes, History, Compare tabs); per-file diffs with dual line numbers, word-level highlights, and Shiki coloring; ticking a file in the tree is a real stage; a commit box and a fetch / pull / push sync bar; seven theme families × light/dark, background image and custom CSS in project/global scopes; and worktree emulation (`worktree_enter` / `worktree_exit` / `worktree_status` agent tools with per-session bindings). See the [README](./README.md).
package/README.md CHANGED
@@ -14,6 +14,11 @@
14
14
 
15
15
  另带 **worktree 仿真**:模型在会话里调用 `worktree_enter` / `worktree_exit` / `worktree_status` 三个工具,即可在 `.agents/worktrees/<name>` 下建立或退出隔离 worktree,并把会话绑定过去。绑定后状态卡点亮绑定标记,面板头部出现 worktree 切换器(按分支列出仓库全部 worktree),统计随之切换。
16
16
 
17
+ <div align="center">
18
+ <video src="https://github.com/user-attachments/assets/c6a73c7b-bf69-4b97-80a2-9175bc293d7d" muted autoplay loop playsinline controls width="100%"></video>
19
+ <sub>演示(2 分 24 秒):状态卡 → 变更页(勾选暂存 / 逐文件 diff / 提交)→ 外观(明暗 + 七套配色 + 背景图)→ 历史页(提交图 / worktree 切换)</sub>
20
+ </div>
21
+
17
22
  > 这份 README 同时是**交接文档**:插件是什么、怎么写的、踩过哪些坑、怎么继续改,全部记录在案。接手开发前请先读「§6 踩坑实录」——那里是真实调试换来的关键事实。
18
23
 
19
24
  ## 0. 安装
@@ -155,7 +160,7 @@ export function apply(ctx) {
155
160
  ### 2.4 worktree 仿真(`src/worktree.ts` 纯逻辑 + `src/index.ts` 里的 RPC/工具)
156
161
 
157
162
  - **宿主 RPC**(同一 `GitWorkbenchService` 上多挂 4 个 `@Remote`,参数照 §6.8 裸标识符、signal 最后):
158
- - `worktreeEnter(sessionId, repoPath, name, signal)`——`repoRootOf` 解析仓库根;在 `<repoRoot>/.agents/worktrees/<name>` 创建(或复用)worktree、分支 `wt/<name>`,写绑定;返回 `{ok, worktreePath, branch, hint}`,hint 教模型怎么用相对路径(会话 cwd 不可变)。
163
+ - `worktreeEnter(sessionId, repoPath, name, signal)`——`repoRootOf` 解析仓库根;在 `<repoRoot>/.agents/worktrees/<name>` 创建(或复用)worktree、**分支 = 名字本身**(不加强制前缀),写绑定;返回 `{ok, worktreePath, branch, hint}`,hint 教模型怎么用相对路径(会话 cwd 不可变)。复用判定走 **realpath**:目标目录已是注册 worktree(别的工具建的、或经 Junction 映射进来的,git 登记的是另一种拼写)→ 直接绑定并保留**它自己的分支**,不再 `worktree add`。
159
164
  - `worktreeExit(sessionId, remove, signal)`——解绑;`remove:true` 且树干净才 `git worktree remove`,脏树拒绝。
160
165
  - `worktreeStatus(sessionId, signal)`——绑定 + 仓库全部 worktree 列表。
161
166
  - `sessionWorktree(sessionId, signal)`——`{worktreePath, name}`,未绑定为双 `null`;客户端轮询已改用 `worktreeStatus`(绑定+列表一次拿全),这个 RPC 保留作轻量单查。
@@ -334,7 +339,7 @@ window.__ModuleLoader__.load({ id: "@young1lin/dsh-ui-gitworkbench", factory: (r
334
339
  - **输出 schema 必须容纳所有早退返回形状**:`worktree_status` 的无会话早退 `{ok:false, error}` 与正常 `{ok, binding, worktrees}` 共用一个 schema,所以 `ok`/`error` 声明为可选、`binding` 用 oneOf——否则真实调用时校验失败。
335
340
 
336
341
  ### 6.12 worktree 的 Windows 细节
337
- - **`git worktree remove` 保留分支**(exit 从不删 `wt/<name>`——可能有未合并提交)。之后再 enter:`worktree add -b wt/<name> <dir>` 会因分支已存在而失败 → 先 `rev-parse --verify --quiet refs/heads/wt/<name>` 探测,幸存则改用 `worktree add <dir> <branch>` **检出既有分支**(hint 注明 reused,提醒模型里面有旧提交)。
342
+ - **`git worktree remove` 保留分支**(exit 从不删 `<name>`——可能有未合并提交)。之后再 enter:`worktree add -b <name> <dir>` 会因分支已存在而失败 → 先 `rev-parse --verify --quiet refs/heads/<name>` 探测,幸存则改用 `worktree add <dir> <name>` **检出既有分支**(hint 注明 reused,提醒模型里面有旧提交)。
338
343
  - **绑定文件的 rename 在 Windows 可能 EPERM**:页面 15s 轮询短暂持有读句柄/杀毒扫描,rename 撞上就 EPERM。做法:tmp + rename,EPERM 按 25/50/100/200/400ms 退避重试后再抛(见 `src/worktree.ts` 的 `saveBindings`)。
339
344
  - **路径一律正斜杠规范化**:`rev-parse --show-toplevel` 的输出、porcelain 的 worktree path 都要做 `.replace(/\\/g,'/')` 再比对——宿主在 Windows 返回反斜杠,两边不统一就匹配不上(复用判定会失灵)。
340
345
 
@@ -382,14 +387,14 @@ window.__ModuleLoader__.load({ id: "@young1lin/dsh-ui-gitworkbench", factory: (r
382
387
  - 环境**卡**(非状态卡)常驻会话头:branch/detached + ↑↓ ahead-behind + `+N −M 文件数`。
383
388
  - 左侧为**可折叠文件树**:目录节点带文件数徽章与聚合 +N/−N;>12 文件的目录默认折叠;「展开全部/收起全部」;选中文件自动展开祖先链;展开状态会话级持久(见 §6.0c)。
384
389
  - 词级高亮 = 相邻 −/+ 行按 token LCS 对齐(`diff-model.ts`),行底色之上叠加强调色;语法着色 = **Shiki**(`highlight.ts`:本地包、JS regex 引擎、语法按需分包加载)——`lib/client.js` 2.3MB 的主因即它。bundle 纯度门禁的是 `@deepseek-ai/*` 的**值导入**(运行时由 profile 提供),不是第三方库;早期「正则单遍扫描」的实现已被替换。
385
- - **状态卡是会话的环境信息位**:git 仓库内常驻显示分支(或 detached sha)+↑↓+计数,**干净树也显示**;仅 `stats.error`(非 git 目录 / git 不可用)时隐藏。绑定标记 = 树形图标:dsh 自建 worktree 的分支必为 `wt/<name>`,徽标印名只会把分支名说两遍,所以只留图标;外部建的 worktree 徽标 = 图标+name——那是唯一点名目录的地方。
390
+ - **状态卡是会话的环境信息位**:git 仓库内常驻显示分支(或 detached sha)+↑↓+计数,**干净树也显示**;仅 `stats.error`(非 git 目录 / git 不可用)时隐藏。绑定标记 = 树形图标:插件所建 worktree 的分支就是名字本身(旧绑定为 `wt/<name>`),徽标印名只会把分支名说两遍,所以只留图标;外部建的 worktree 徽标 = 图标+name——那是唯一点名目录的地方。
386
391
  - **面板是浮起的卡片**(四边留白 + 圆角 + 投影),左缘可拖拽改宽、有最大化满屏;宽度与外观都存 localStorage,且读回时校验(旧版本写的族名不会漏到 `data-gs-theme` 上)。
387
392
  - **明暗默认跟随操作系统**(`prefers-color-scheme`),可显式覆盖;主题族 7 套(GitHub / IntelliJ IDEA / VS Code / One / Solarized / Nord / Cyberpunk)各带亮暗。面板内滚动条也按当前调色板重绘——**按类名逐个列举是不行的**:文件树那栏改过名之后就一直漏在外面、保持系统原生的浅色滚动条,所以规则写成 `.drawer *`。
388
393
  - **背景图与自定义 CSS 按「项目 / 全局」两个作用域存在宿主**(`~/.dsh/gitworkbench-style.json`),项目优先;背景图整条取项目的,自定义 CSS 两边叠加、项目在后。详见 §2.3b。
389
394
  - **worktree 语义**:
390
- - 目录 = 仓库根下 `.agents/worktrees/<name>`(仓库内,无沙箱越界);分支 = `wt/<name>`;name 规则 `[A-Za-z0-9._-]{1,40}`,非法或缺省自动生成 `wt-<hex6>`。
395
+ - 目录 = 仓库根下 `.agents/worktrees/<name>`(仓库内,无沙箱越界);**分支 = 名字本身,不加强制前缀**。name 规则 = git ref 字符集 ∩ Windows 目录名:字母/数字开头,可用 `. _ - +`,最长 64;拒绝 `..`、尾部点、`.lock` 结尾、Windows 保留名(CON/NUL 等)与 `head`;非法或缺省自动生成 `worktree-<hex6>`。
391
396
  - **退出默认保留目录**,`remove:true` 才删;删除前 `git status --porcelain` 检查,**脏树拒绝且绝不加 `--force`**(保守,防丢改动)。
392
397
  - **会话 cwd 不可变**(dsh 本体约束):enter 不切 cwd,而是返回 hint 指引模型——file 工具用 `.agents/worktrees/<name>/` 前缀的相对路径,shell 命令传 per-call workdir `.agents/worktrees/<name>`(相对会话 cwd 解析)。
393
- - **再进入**:目录仍是注册 worktree 直接复用、只补绑定;目录已删但分支 `wt/<name>` 幸存 → `worktree add <dir> <branch>` 检出旧分支(hint 注明 reused)。
398
+ - **再进入**:目录仍是注册 worktree(含外部工具建的、经 Junction 映射的——realpath 判定)→ 直接复用、只补绑定并保留其分支;目录已删但分支 `<name>` 幸存 → `worktree add <dir> <name>` 检出旧分支(hint 注明 reused)。
394
399
  - **绑定**(per-session)持久化于 `~/.dsh/gitworkbench-worktree-bindings.json`;损坏/缺失视为无绑定并重建。写入原子(tmp+rename)+ 互斥(promise 队列)+ EPERM 退避重试(§6.12)。
395
400
  - **状态卡纪律例外**:有绑定时即使 bound worktree 干净也显示状态卡——绑定标记(树形图标)是绑定指示器与面板入口;面板打开期间空视图也保持挂载(可从空源切走)。头部选择器只改显示对象,不动绑定。
package/README_EN.md CHANGED
@@ -14,6 +14,11 @@ Every session header gets a small status card showing the current branch, ahead/
14
14
 
15
15
  It also ships **worktree emulation**: the model can call the `worktree_enter` / `worktree_exit` / `worktree_status` agent tools to create or leave an isolated worktree under `.agents/worktrees/<name>` and bind the session to it. The status card lights up its binding marker, the panel header gains a worktree switcher listing every worktree in the repository, and the stats follow the binding.
16
16
 
17
+ <div align="center">
18
+ <video src="https://github.com/user-attachments/assets/c6a73c7b-bf69-4b97-80a2-9175bc293d7d" muted autoplay loop playsinline controls width="100%"></video>
19
+ <sub>Demo (2:24) — status card → Changes (ticking to stage, per-file diffs, committing) → Appearance (light/dark, seven palettes, background image) → History (commit graph, worktree switching)</sub>
20
+ </div>
21
+
17
22
  > The Chinese [README.md](./README.md) is the project's deep handoff document — including the pitfall catalog (§6) that every contributor should read before changing the build, the RPC layer, or the Windows-specific handling.
18
23
 
19
24
  ## Install