dsh-edit-diff 0.2.1 → 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/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  接管 DSH 浏览器的 `edit` / `write` 工具卡片,用近线性行级 diff 做真正的差异展示,消除内置 DiffBlock 把「未变化的相同行」在删除区红 `-` 行和新增区绿 `+` 行各渲染一遍的重复。
4
4
 
5
- 纯浏览器端 client 插件,单击即换新渲染,不碰 DSH 源码。
5
+ 渲染全在浏览器端,主机端半身只负责把配置转成 settings 命名空间。单击即换新渲染,不碰 DSH 源码。
6
6
 
7
7
  ## 引言
8
8
 
@@ -23,6 +23,47 @@
23
23
  - **复制与统计**:复制只含差异行,`- `/`+ ` 前缀;底部 `└ +A -R · N file(s)` 变更统计。
24
24
  - **单文件与多文件**:`edit` / `write` 双双接管,覆盖新建只显示绿色新增,纯删、多 hunk 等场景。
25
25
  - **PTC 模式兼容**:`run_code` 子调用中的 `edit` / `write` 同样显示优化后的修改 diff,通过 `callId` 中的 `:code:` 标记识别子调用。注意 `write` 是全文件覆写,无旧内容,只能显示全新增;想看精确 diff 应使用 `edit`。
26
+ - **接管其他工具**:`extraTools` 让 [dsh-remote-file-system](https://github.com/better-er/dsh-remote-file-system) 的 `edit_remote`、`write_remote` 一并使用优化显示,插件已默认开启这两个,参数名不同的工具可逐项覆盖。
27
+
28
+ ## 配置
29
+
30
+ `extraTools` 列出 `edit` 与 `write` 之外要接管的工具。每条写工具名和读取参数用的参数名,参数名省略时按 `file_path`、`old_string`、`new_string`、`content` 取值。
31
+
32
+ 插件自带的 `cordis.patch.yml` 已经默认接管 [dsh-remote-file-system](https://github.com/better-er/dsh-remote-file-system) 的这两个远程工具:
33
+
34
+ ```yaml
35
+ - insert:
36
+ - id: dsh-edit-diff
37
+ name: dsh-edit-diff
38
+ config:
39
+ extraTools:
40
+ - name: edit_remote
41
+ - name: write_remote
42
+ ```
43
+
44
+ 它们的参数名和原生一致,只写名字即可。参数名不同的工具再补:
45
+
46
+ ```yaml
47
+ extraTools:
48
+ - name: some_tool
49
+ pathKey: target
50
+ oldKey: before
51
+ newKey: after
52
+ contentKey: body
53
+ ```
54
+
55
+ 要改这份默认,在 profile 的 `cordis.patch.yml` 里按 id 覆盖:
56
+
57
+ ```yaml
58
+ - id: dsh-edit-diff
59
+ config:
60
+ extraTools:
61
+ - name: some_tool
62
+ ```
63
+
64
+ 判断规则:参数里同时有旧文本与新文本就按 edit 型渲染,否则有整文件内容就按 write 型渲染。
65
+
66
+ 配置经 settings 命名空间 `dsh-edit-diff` 送到浏览器端,settings 变化会让浏览器端重建这批 key 的注册。
26
67
 
27
68
  ## 它长什么样
28
69
 
@@ -31,15 +72,29 @@
31
72
  | 原版 diff | ![原版离谱显示](docs/原版diff.webp) |
32
73
  | 本插件 | ![插件优化显示](docs/优化diff.webp) |
33
74
 
75
+ ## 演示视频
76
+
77
+ 光看静态截图不过瘾?看看这个插件的实际演示效果:
78
+
79
+ | dsh-edit-diff 插件演示 · 66 秒 |
80
+ | :---: |
81
+ | [![dsh-edit-diff 插件演示](https://i2.hdslb.com/bfs/archive/dd90d9de85da22eae537d53dd77a2034bf841b5e.jpg)](https://www.bilibili.com/video/BV1ect76CENM/) |
82
+
34
83
  ## 安装
35
84
 
85
+ **从 GitHub 安装**:源码在 `src/`,`lib/` 不入仓库,安装时 npm 会触发 `prepare` 脚本现场构建。
86
+
36
87
  ```powershell
37
88
  dsh plugin --profile web add github:better-er/dsh-edit-diff
38
89
  ```
39
90
 
40
- 或安装 npm 发布的版本:`dsh plugin --profile web add dsh-edit-diff`。
91
+ **从 npm 安装**:包内已含构建产物 `lib/index.js` `lib/client.js`,安装时不再构建。
92
+
93
+ ```powershell
94
+ dsh plugin --profile web add dsh-edit-diff
95
+ ```
41
96
 
42
- 一条命令装完即生效,自动挂载,重启 DSH web 后启用,无需手工编辑任何组合文件。
97
+ 两种方式装完都会自动挂载,重启 DSH web 后启用,无需手工编辑任何文件。
43
98
 
44
99
  ## 卸载
45
100
 
@@ -53,13 +108,23 @@ dsh plugin --profile web remove dsh-edit-diff
53
108
 
54
109
  - 是**标准形态的 dsh client 插件**,声明 `dsh.client`,导出 `./client`。
55
110
  - 同时声明了 `dsh.bundle`,因此也是一个**自挂载的 bundle 层插件**:用 `dsh plugin --profile <name> add` 从 GitHub 安装后,会被自动识别为 profile layer 并挂载,无需手工写组合 entry。
56
- - 纯浏览器半身,无 host 行为;`lib/index.js` 是无操作的 no-op 主机插件标准双面包约定。
57
- - **UI 挂载点**:接管 keyed 槽位 `tool.call.toolview` 的 `edit` 与 `write` 两个 key
111
+ - 主机端半身只做一件事:用 `ctx.settings.installSection()` entry 配置注册成 settings 命名空间 `dsh-edit-diff`。浏览器端拿不到 cordis 配置,这是双半插件传配置的唯一通道。
112
+ - **UI 挂载点**:接管 keyed 槽位 `tool.call.toolview` 的 `edit` 与 `write` 两个 key,以及 `extraTools` 里声明的每个工具名。
58
113
  - **遮蔽而非冲突**:注册时显式传 `priority: -1`低于内置 `file-mutation-toolview` 的默认 0,用更低优先级遮蔽默认渲染,而不是在同一优先级上 clash。
59
114
  - **PTC 模式**:通过 `callId` 包含 `:code:` 判断是否为 `run_code` 子调用,从 `argsRaw` 中提取 `old_string`/`new_string` 即 edit 或 `content` 即 write 动态构建 diff。
60
- - **无构建**:`lib/client.js` 是按 DSH client bundle 产出的注册式模块,源码即产物,改完即用。
61
- - JavaScript 单文件,不引入任何额外 npm 依赖diff 算法就地内联。
115
+ - **构建型**:TypeScript 源码位于 `src/`,`pnpm build` 通过 tsdown 生成 `lib/index.js`、`lib/index.d.ts`、`lib/client.js` sourcemap,运行时只加载 `lib/` 发布产物。
116
+ - diff 算法就地内联,浏览器端只向宿主模块表请求 react;主机端向宿主解析 `@deepseek-ai/schemastery`。
117
+
118
+ 本地开发:
119
+
120
+ ```powershell
121
+ pnpm install
122
+ pnpm typecheck
123
+ pnpm build
124
+ ```
125
+
126
+ 改完源码需重新 `pnpm build`,DSH web 的 HMR 观察到 `lib/client.js` 变化后自动重载。
62
127
 
63
128
  ## License
64
129
 
65
- [MIT](./LICENSE)
130
+ [MIT](./LICENSE)
package/cordis.patch.yml CHANGED
@@ -1,13 +1,12 @@
1
- # dsh-edit-diff bundle patch: mount the edit/write diff-card plugin.
2
- #
3
- # Applied when this bundle appears in a profile's dsh.profile.bundles list.
4
- # The node half (package root) is a no-op Cordis plugin; the browser half
5
- # (dsh.client) is discovered automatically through the package's
6
- # dsh.client declaration + exports["./client"]. It registers two keyed
7
- # `tool.call.toolview` occupants (`edit`, `write`) that replace the shipped
8
- # DiffBlock render, eliminating same-line duplication with a near-linear
9
- # line diff + intra-line character highlight.
10
-
1
+ # dsh-edit-diff bundle patch:把 edit/write diff 卡片插件插进 profile 的 layer stack。
2
+ # profile 引用本 bundle 时自动挂载。
3
+ # 浏览器半身由 dsh.client 声明自动发现,注册 tool.call.toolview edit、write extraTools 里的每个工具名,替换内置 DiffBlock。
4
+ # 主机端半身把 entry 配置注册成 settings 命名空间 dsh-edit-diff,浏览器端只能从这里拿到配置。
5
+ # 下面的默认顺带接管两个远程文件工具,参数名与原生一致,按 id 覆盖 extraTools 即可改。
11
6
  - insert:
12
7
  - id: dsh-edit-diff
13
- name: dsh-edit-diff
8
+ name: dsh-edit-diff
9
+ config:
10
+ extraTools:
11
+ - name: edit_remote
12
+ - name: write_remote