dsh-edit-diff 0.2.0 → 0.3.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/README.md +36 -18
- package/docs//344/274/230/345/214/226diff.webp +0 -0
- package/docs//345/216/237/347/211/210diff.webp +0 -0
- package/lib/client.js +603 -438
- package/lib/client.js.map +1 -0
- package/lib/index.d.ts +15 -0
- package/lib/index.js +8 -7
- package/package.json +22 -5
- package/docs//345/216/273/351/207/215/345/244/215diff.webp +0 -0
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# dsh
|
|
1
|
+
# dsh·修改显示优化插件
|
|
2
2
|
|
|
3
3
|
接管 DSH 浏览器的 `edit` / `write` 工具卡片,用近线性行级 diff 做真正的差异展示,消除内置 DiffBlock 把「未变化的相同行」在删除区红 `-` 行和新增区绿 `+` 行各渲染一遍的重复。
|
|
4
4
|
|
|
@@ -6,13 +6,11 @@
|
|
|
6
6
|
|
|
7
7
|
## 引言
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
原版 diff 的显示相当离谱:一次只修改一行,它却把这行连同上下各三行一起带进 diff,共十四行,其中七行被折叠,正好红区和绿区完全不重叠。不点开二级展开根本看不出到底改了什么——点开了也照样看花眼。
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
这个插件把无关的相同行全部去除。只修改一行时,就只显示一行红一行绿,真正的修改加粗划线,一眼就能看清改在哪里。
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
于是这个插件接管了 `edit` 和 `write` 两个工具卡片,用近线性算法算出真实差异,相同行一行不渲染,替换行还把改动到的具体字符用下划线标出来。一眼就知道到底改了什么。
|
|
13
|
+
另外,PTC 模式下默认只显示调用成功与否,本插件也做了适配,能正常显示修改内容。
|
|
16
14
|
|
|
17
15
|
## 功能
|
|
18
16
|
|
|
@@ -24,28 +22,38 @@ DeepSeek Harness 内置的 DiffBlock 展示工具改动时有个毛病:它拿
|
|
|
24
22
|
- **对齐原生观感**:字号、圆角、配色复用内置 DiffBlock/ToolRow 同一批 `--dsw-*` 主题变量,视觉上就是原生卡片。
|
|
25
23
|
- **复制与统计**:复制只含差异行,`- `/`+ ` 前缀;底部 `└ +A -R · N file(s)` 变更统计。
|
|
26
24
|
- **单文件与多文件**:`edit` / `write` 双双接管,覆盖新建只显示绿色新增,纯删、多 hunk 等场景。
|
|
27
|
-
- **PTC 模式兼容**:`run_code` 子调用中的 `edit` / `write`
|
|
25
|
+
- **PTC 模式兼容**:`run_code` 子调用中的 `edit` / `write` 同样显示优化后的修改 diff,通过 `callId` 中的 `:code:` 标记识别子调用。注意 `write` 是全文件覆写,无旧内容,只能显示全新增;想看精确 diff 应使用 `edit`。
|
|
28
26
|
|
|
29
27
|
## 它长什么样
|
|
30
28
|
|
|
31
|
-
|
|
29
|
+
| | 效果图 |
|
|
30
|
+
| --- | --- |
|
|
31
|
+
| 原版 diff |  |
|
|
32
|
+
| 本插件 |  |
|
|
33
|
+
|
|
34
|
+
## 演示视频
|
|
32
35
|
|
|
33
|
-
|
|
36
|
+
光看静态截图不过瘾?看看这个插件的实际演示效果:
|
|
34
37
|
|
|
35
|
-
-
|
|
36
|
-
|
|
37
|
-
-
|
|
38
|
-
- **底部统计**:`└ +1 -1 · 1 file`,列明净增删行数与文件数。
|
|
38
|
+
| dsh-edit-diff 插件演示 · 66 秒 |
|
|
39
|
+
| :---: |
|
|
40
|
+
| [](https://www.bilibili.com/video/BV1ect76CENM/) |
|
|
39
41
|
|
|
40
42
|
## 安装
|
|
41
43
|
|
|
44
|
+
**从 GitHub 安装**:源码在 `src/`,`lib/` 不入仓库,安装时 npm 会触发 `prepare` 脚本现场构建。
|
|
45
|
+
|
|
42
46
|
```powershell
|
|
43
47
|
dsh plugin --profile web add github:better-er/dsh-edit-diff
|
|
44
48
|
```
|
|
45
49
|
|
|
46
|
-
|
|
50
|
+
**从 npm 安装**:包内已含构建产物 `lib/index.js` 与 `lib/client.js`,安装时不再构建。
|
|
51
|
+
|
|
52
|
+
```powershell
|
|
53
|
+
dsh plugin --profile web add dsh-edit-diff
|
|
54
|
+
```
|
|
47
55
|
|
|
48
|
-
|
|
56
|
+
两种方式装完都会自动挂载,重启 DSH web 后启用,无需手工编辑任何文件。
|
|
49
57
|
|
|
50
58
|
## 卸载
|
|
51
59
|
|
|
@@ -63,9 +71,19 @@ dsh plugin --profile web remove dsh-edit-diff
|
|
|
63
71
|
- **UI 挂载点**:接管 keyed 槽位 `tool.call.toolview` 的 `edit` 与 `write` 两个 key。
|
|
64
72
|
- **遮蔽而非冲突**:注册时显式传 `priority: -1`低于内置 `file-mutation-toolview` 的默认 0,用更低优先级遮蔽默认渲染,而不是在同一优先级上 clash。
|
|
65
73
|
- **PTC 模式**:通过 `callId` 包含 `:code:` 判断是否为 `run_code` 子调用,从 `argsRaw` 中提取 `old_string`/`new_string` 即 edit 或 `content` 即 write 动态构建 diff。
|
|
66
|
-
-
|
|
67
|
-
-
|
|
74
|
+
- **构建型**:TypeScript 源码位于 `src/`,`pnpm build` 通过 tsdown 生成 `lib/index.js`、`lib/index.d.ts`、`lib/client.js` 与 sourcemap,运行时只加载 `lib/` 发布产物。
|
|
75
|
+
- 无运行时 npm 依赖,diff 算法就地内联;浏览器端只向宿主模块表请求 react。
|
|
76
|
+
|
|
77
|
+
本地开发:
|
|
78
|
+
|
|
79
|
+
```powershell
|
|
80
|
+
pnpm install
|
|
81
|
+
pnpm typecheck
|
|
82
|
+
pnpm build
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
改完源码需重新 `pnpm build`,DSH web 的 HMR 观察到 `lib/client.js` 变化后自动重载。
|
|
68
86
|
|
|
69
87
|
## License
|
|
70
88
|
|
|
71
|
-
[MIT](./LICENSE)
|
|
89
|
+
[MIT](./LICENSE)
|
|
Binary file
|
|
Binary file
|