dsh-toolfold 0.1.7 → 0.1.9
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 +41 -1
- package/README.en.md +130 -90
- package/README.md +118 -63
- package/lib/client.js +1954 -1836
- package/lib/index.js +265 -128
- package/package.json +17 -3
- package/lib/build-dynamic.cjs +0 -69
- package/lib/dynamic-body.js +0 -1732
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,44 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
所有显著变更将记录于此。版本号遵循 [语义化版本](https://semver.org/lang/zh-CN/)。
|
|
4
|
+
|
|
5
|
+
## [0.1.9] - 2026-09-05
|
|
6
|
+
|
|
7
|
+
> ⚠️ **版本支持**:本节改动将随 `0.1.9` 发布;自 `0.1.9` 起,本插件仅支持 DSH `>= 0.1.2-rc.1` 且 `< 0.1.3`(安装节有同样提示)。
|
|
8
|
+
|
|
9
|
+
### 缺陷修复
|
|
10
|
+
- **折叠条行距对齐官方**:`.ccxBar` 去掉上下 `3px` 透明内边距(`padding:0`)。条是无边框无背景元素,透明 padding 会被读成行间白边——实测每侧多出 3px(条↔行 30px、条↔条 33px,而官方行↔行字墨边距 27px = 流 `margin-top:16px` + 24px 行盒内字墨各 ~5.5px)。官方行本身零内边距,去掉后折叠条回到同一节奏。
|
|
11
|
+
- **思考行复活**:答案流进曾被清空隐藏的思考行时自动恢复可见,不再误判为空行。
|
|
12
|
+
- **关引擎保留卡片样式**:引擎规则与卡片 chrome 拆成两个 style 标签,停用折叠不再剥掉卡片外观。
|
|
13
|
+
- **压掉 16px 空带**:隐藏思考的 wrapper 一并折叠,回答上方不再留空。
|
|
14
|
+
|
|
15
|
+
### 功能变更
|
|
16
|
+
- **思考显示三档下拉**(自动跟随官方折叠 / 始终保留 / 始终隐藏,默认自动):原来自动开着时保留是个摆设,现在没有无效组合;老配置自动沿用,可回滚。设置卡与 README 已同步。
|
|
17
|
+
- **总开关**:一键停用/恢复全部折叠(关闭后聊天回到产品默认显示,卡片常驻随时可重开)。
|
|
18
|
+
- **跟随官方 Compact 折叠**:官方收起整块过程时思考自动保留可见(即下拉的默认档)。
|
|
19
|
+
- **版本不匹配警告**:运行的 DSH 超出支持范围时,设置卡显示 ⚠ 图标(hover 看详情)并打一条一次性 console 警告。
|
|
20
|
+
- **适配 DSH 0.1.2**:`settingsNamespace()` helper 被移除,改用裸字符串命名空间;新增 `engines.dsh` 下限,删除 `dsh-settings` peer 依赖。
|
|
21
|
+
|
|
22
|
+
### 工程变更
|
|
23
|
+
- **浏览器半模块化**:`lib/client.js`(约 2244 行单文件)与字符串手术生成的 `lib/dynamic-body.js` 重构为 `src/client/` 下的模块源(`settings` / `bridge` / `styles` / `engine` / `card` / `react-env` / `index`),由 tsdown 构建(`tsdown.config.mjs`,与 host 半共三个 entry):
|
|
24
|
+
- `lib/client.js(.map)` —— 安装通道 loader 产物(`window.__ModuleLoader__.load`,经 `exports["./client"]` 加载),行为与旧文件一致;
|
|
25
|
+
- `lib/dynamic-body.js(.map)` —— 动态通道 body(同一模块图去掉 loader 包装),供动态插件会话与 `tools/live-probe.mjs` 使用;
|
|
26
|
+
- React 不再静态导入:构建 wrapper 将通道提供的 React 种入 `globalThis.__dshToolfoldReact`(安装通道 `require('react')` / 动态通道闭包参数 `React`),无 React 的无头环境仅跳过设置卡片注册。
|
|
27
|
+
- **构建期产物**(删除旧生成器 `lib/build-dynamic.cjs`):`lib/client.js` / `lib/dynamic-body.js`(及 `.map`)已 gitignore,由 `prepare: pnpm build`(tsdown)重建——`pnpm publish` 与 git-hosted 安装都会先跑 prepare 再打包,`files` 白名单只含构建产物(`lib/index.js`、`lib/client.js`,不含 src / map)。`package.json` 增加 `prepare` / `build` / `build:watch` 脚本与 `tsdown` devDependency。改动流程:只改 `src/` → `pnpm build` → 验证。
|
|
28
|
+
- **host 半搬家**:`lib/index.js` → `src/host/index.js`(与 `src/client/` 对称;ESM,无需 scoped package.json),由 tsdown 第三个 entry(`platform: 'node'`,`schemastery` 保持 external)构建回 `lib/index.js`——`main` / `exports["."]` / `files` 指向不变。至此 `lib/` 下 100% 生成物,`.gitignore` 收成一行 `lib/`(源码层/产物层不再混放)。
|
|
29
|
+
- **工具去本机硬编码**:`jsdom`(29.1.1)与 `playwright`(1.61.1)收为 devDependencies,`tools/engine-smoke.mjs` / `tools/live-probe.mjs` 改按包名解析;live-probe 的 Chrome 路径改为 `CHROME_PATH` 环境变量优先,否则按平台取第一个存在的默认位置。`pnpm install` 后 `test:engine` / `probe:live` 开箱即用。
|
|
30
|
+
- **新增 `pnpm-lock.yaml`**:安装可重复。
|
|
31
|
+
- **发布管线**:Publish 前加 `pnpm install`;dry-run 校验 + `--provenance` OIDC 可信发布;发布条件收窄为仅 release 触发(取消手动发布);`engines.dsh` 上限收窄到 `<0.1.3`。
|
|
32
|
+
|
|
33
|
+
## [0.1.8] - 2026-08-28
|
|
34
|
+
|
|
35
|
+
### Fixed
|
|
36
|
+
- 修复运行时收起"先动一下再突然收起":当模型产生大量工具调用、且它们是最新信息时,run 在收起动画期间仍在增长。旧实现(自 0.1.3 起)假定行集合固定:折叠条点击闭包持有的是创建时的旧 run 快照,动画只覆盖原始行,随后按旧行数计时的完成定时器把整个增长后的 run 一次性合并,新流入的行瞬间消失。现点击改为操作当前 run(`bar._ccxRun`)而非创建时快照;`syncBars` 将动画期间新增的行折入同一瀑布(`extendCollapse`:rise 类 + 高度收缩 + 各自 stagger)并重排完成定时器(`armCollapseFinish`),最后一行动画结束才应用合并。(`lib/client.js`, `lib/dynamic-body.js`)
|
|
37
|
+
|
|
38
|
+
### Changed
|
|
39
|
+
- npm 发布工作流增加 OIDC 权限(`id-token: write`、`contents: read`),发布改用 OIDC 身份认证(移除 `NODE_AUTH_TOKEN` 环境变量),并禁用 `package-manager-cache`。
|
|
40
|
+
- `package.json` 增加 `repository` 字段指向 GitHub 仓库。
|
|
41
|
+
- 重构 README:重组章节(安装、快速开始、默认行为、功能、设置、性能、限制),新增"默认行为 – 首次使用"说明(为什么思考会消失、为什么调用默认分组,以及快速修复指引),补充安装方法与徽章,并同步翻译为 `README.en.md`。
|
|
4
42
|
|
|
5
43
|
## [0.1.7] - 2026-08-26
|
|
6
44
|
|
|
@@ -54,6 +92,8 @@
|
|
|
54
92
|
- 首个可用版本:连续 `tool-call` 折叠为最后一条的单行摘要 + “已折叠 N 个工具调用”,支持 `durMs / keepThink / splitThink / stats` 四项设置(DSH `settings` 服务 → `~/.dsh/settings.yaml`,回退到 Host 路由与 `localStorage`)与瀑布动画。
|
|
55
93
|
- `toolfold` 远端包与一键安装、设置双半通信(Host `GET/POST /api/dsh-toolfold/settings` + Client 桥)。
|
|
56
94
|
|
|
95
|
+
[0.1.9]: https://github.com/Minecraftbe/dsh-toolfold/compare/v0.1.8...v0.1.9
|
|
96
|
+
[0.1.8]: https://github.com/Minecraftbe/dsh-toolfold/compare/v0.1.7...v0.1.8
|
|
57
97
|
[0.1.7]: https://github.com/Minecraftbe/dsh-toolfold/compare/v0.1.6...v0.1.7
|
|
58
98
|
[0.1.6]: https://github.com/Minecraftbe/dsh-toolfold/compare/v0.1.5...v0.1.6
|
|
59
99
|
[0.1.5]: https://github.com/Minecraftbe/dsh-toolfold/compare/v0.1.4...v0.1.5
|
package/README.en.md
CHANGED
|
@@ -1,136 +1,176 @@
|
|
|
1
1
|
# dsh-toolfold · Tool Call Folding
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
-
|
|
23
|
-
|
|
24
|
-
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
- **Bottom-pinned expand**: expanding near the bottom pins the bar's viewport position, so the
|
|
28
|
-
chat's auto-scroll never shoves it off the top of the screen;
|
|
29
|
-
- **Near-zero performance cost**: no page-wide observer, zero work while content streams, and
|
|
30
|
-
everything pauses when the tab is hidden — measured ≈0.03% of one core while idle
|
|
31
|
-
(see [Performance](#performance)).
|
|
32
|
-
|
|
33
|
-

|
|
34
|
-
<!-- 🖼️ IMAGE SLOT: assets/expand-collapse.gif — close-up of one 3–4 call run expanding (waterfall + label slide) and collapsing (rise + height shrink), square or 4:3, ≤2MB -->
|
|
3
|
+
[](https://awesome-dsh-plugin.com)
|
|
4
|
+
|
|
5
|
+
English | [中文](README.md)
|
|
6
|
+
|
|
7
|
+
> A DSH Web GUI plugin that provides a **simple tool call collapsing**: consecutive **tool calls** are collapsed into a single compact bar showing only a one‑line summary of the last call. Click to expand/collapse.
|
|
8
|
+
> It does not replace any built‑in renderer, and uninstallation restores the UI completely.
|
|
9
|
+
|
|
10
|
+

|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Table of Contents
|
|
15
|
+
|
|
16
|
+
- [Installation](#installation)
|
|
17
|
+
- [Quick Start](#quick-start)
|
|
18
|
+
- [Default Behaviour – First Use](#default-behaviour--first-use)
|
|
19
|
+
- [Features](#features)
|
|
20
|
+
- [Settings](#settings)
|
|
21
|
+
- [Options](#options)
|
|
22
|
+
- [Storage Location](#storage-location)
|
|
23
|
+
- [Performance](#performance)
|
|
24
|
+
- [Limitations & Compatibility](#limitations--compatibility)
|
|
25
|
+
|
|
26
|
+
---
|
|
35
27
|
|
|
36
28
|
## Installation
|
|
37
29
|
|
|
38
|
-
###
|
|
30
|
+
### Recommended (via npm)
|
|
39
31
|
|
|
40
32
|
```sh
|
|
41
|
-
dsh plugin --profile web add
|
|
33
|
+
dsh plugin --profile web add dsh-toolfold
|
|
42
34
|
```
|
|
43
35
|
|
|
44
|
-
###
|
|
36
|
+
### Alternative Methods
|
|
45
37
|
|
|
46
38
|
```sh
|
|
39
|
+
# From GitHub
|
|
40
|
+
dsh plugin --profile web add github:Minecraftbe/dsh-toolfold
|
|
41
|
+
|
|
42
|
+
# From source
|
|
47
43
|
git clone https://github.com/Minecraftbe/dsh-toolfold.git
|
|
48
44
|
dsh plugin --profile web add ./dsh-toolfold
|
|
49
45
|
```
|
|
50
46
|
|
|
51
|
-
After
|
|
52
|
-
at boot). Verify the plugin reached the final config with:
|
|
47
|
+
After installation, **restart dsh and refresh your browser** – the plugin will be active. You can verify that it is included in the final bundle with:
|
|
53
48
|
|
|
54
49
|
```sh
|
|
55
50
|
dsh --profile web --dump-config
|
|
56
51
|
```
|
|
57
52
|
|
|
58
|
-
|
|
59
|
-
> remove that row before switching to this channel to avoid double-mounting.
|
|
60
|
-
|
|
61
|
-
### Uninstall
|
|
53
|
+
### Uninstallation
|
|
62
54
|
|
|
63
55
|
```sh
|
|
64
56
|
dsh plugin --profile web remove dsh-toolfold
|
|
65
57
|
```
|
|
66
58
|
|
|
67
|
-
After
|
|
59
|
+
After restart, the interface returns to its original state.
|
|
60
|
+
|
|
61
|
+
> ⚠️ **Version support**: starting from `0.1.9`, this plugin only supports DSH `>= 0.1.2-rc.1` and `< 0.1.3`. On DSH versions outside this range, the settings card shows a version-mismatch warning and folding may not work correctly.
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## Quick Start
|
|
66
|
+
|
|
67
|
+
Once installed, consecutive tool calls are automatically folded into a single bar in any DSH conversation.
|
|
68
|
+
|
|
69
|
+
- **Click the fold bar** to expand or collapse the tool‑call cards (keyboard `Enter` / `Space` also work)
|
|
70
|
+
- **The bar shows**: a one‑line summary of the last call plus the label “N tool calls folded · click to expand”
|
|
71
|
+
|
|
72
|
+

|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## Default Behaviour – First Use
|
|
77
|
+
|
|
78
|
+
The plugin works immediately after installation, but you might notice two things that seem “unexpected” at first. Both are intentional defaults and can be changed easily.
|
|
79
|
+
|
|
80
|
+
### ❓ Why did my thinking content disappear?
|
|
81
|
+
|
|
82
|
+
**Reason**: “Thinking display” defaults to “Auto-follow official fold” — completed thinking is hidden unless the official Compact view folds the whole process block.
|
|
68
83
|
|
|
69
|
-
|
|
84
|
+
**How to restore**: go to `Settings → Plugins → Tool Fold` and set **“Thinking display”** to **“Always keep”**.
|
|
70
85
|
|
|
71
|
-
|
|
72
|
-
|
|
86
|
+
### ❓ Why are my tool calls split into two separate fold bars?
|
|
87
|
+
|
|
88
|
+
**Reason**: “Split thinking across call groups” is on by default (`splitThink: true`). The plugin treats a completed thinking block as a logical separator, folding calls before and after it independently.
|
|
89
|
+
|
|
90
|
+
**How to merge them**: go to `Settings → Plugins → Tool Fold` and turn off **“Split thinking across call groups”**.
|
|
91
|
+
|
|
92
|
+
> Ongoing (streaming) thinking is always visible regardless of these settings, and will only be processed according to the rules once it finishes.
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## Features
|
|
97
|
+
|
|
98
|
+
### Core Folding Behaviour
|
|
99
|
+
|
|
100
|
+
- **Automatic folding of consecutive tool calls** – adjacent tool calls are collapsed into one bar, showing only the last call’s summary line and the number of folded items.
|
|
101
|
+
- **Thinking splits call groups (enabled by default)** – a completed thinking block separates the tool calls before and after it into two independent fold bars; they are never merged across a thinking block.
|
|
102
|
+
- **Thinking display (three modes)** – “Auto-follow official fold” by default: thinking is kept when the official view folds the whole process block, hidden otherwise; “Always keep” shows it between fold bars (split mode) or interpolated back on expansion; “Always hide” never shows completed thinking.
|
|
103
|
+
- **Ongoing thinking always visible** – streaming thinking remains visible until it finishes, then follows the above rules.
|
|
104
|
+
|
|
105
|
+
### Animation & Experience
|
|
106
|
+
|
|
107
|
+
- **Spring‑loaded waterfall animation** – cards drop one by one on expand (with spring bounce), and on collapse they rise while heights shrink synchronously, so content below moves continuously without jumping.
|
|
108
|
+
- **Sticks to the bottom without pushing out** – when expanding near the bottom, the fold bar’s viewport position is pinned so that automatic scrolling does not push it off screen.
|
|
109
|
+
- **Respects system preferences** – if the system has “Reduce motion” enabled, animations are automatically disabled.
|
|
110
|
+
|
|
111
|
+
### Performance & Resource Usage
|
|
112
|
+
|
|
113
|
+
- **Near‑zero performance impact** – no page‑wide observers, zero engine work during streaming, and all activity is paused when the tab is hidden. Measured idle overhead is about 0.03% of a single CPU core.
|
|
114
|
+
- **Optional real‑time stats** – enable “Performance stats” in the settings card to see per‑step timings and verify overhead.
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## Settings
|
|
119
|
+
|
|
120
|
+
Settings are found at: **Settings → Plugins → Tool Fold** (the card looks like other built‑in plugin cards and follows the light/dark theme).
|
|
73
121
|
|
|
74
122
|

|
|
75
|
-
<!-- 🖼️ IMAGE SLOT: assets/settings.png — screenshot of the expanded "工具折叠" card in Settings → Plugins (duration slider + keep-think toggle + stats toggle + storage-location hint), light theme, PNG/WebP ≤1MB -->
|
|
76
123
|
|
|
77
|
-
|
|
124
|
+
### Options
|
|
125
|
+
|
|
126
|
+
| Option | Description |
|
|
78
127
|
| --- | --- |
|
|
79
|
-
|
|
|
80
|
-
|
|
|
81
|
-
|
|
|
82
|
-
|
|
|
128
|
+
| **Expand animation duration** | Duration of the expand/collapse animation per card (0–1000 ms, default 240 ms; 0 = instant) |
|
|
129
|
+
| **Thinking display** | How completed thinking is shown: auto-follow official fold (default) / always keep / always hide |
|
|
130
|
+
| **Split thinking across call groups** | Enabled by default: a completed thinking block separates tool calls before and after it into independent fold bars. Disabled: thinking is folded together with the surrounding call group (legacy behaviour) |
|
|
131
|
+
| **Performance stats** | Show real‑time plugin timing in the card (cumulative count and ms/s for observation callbacks, engine refresh, merge recalculation, safe rescan, summary cloning, plus the number of streaming batches short‑circuited with zero overhead) |
|
|
132
|
+
|
|
133
|
+
---
|
|
83
134
|
|
|
84
|
-
|
|
135
|
+
### Storage Location
|
|
85
136
|
|
|
86
|
-
|
|
137
|
+
Plugin settings are persisted automatically, with the following priority:
|
|
87
138
|
|
|
88
|
-
- **
|
|
89
|
-
`~/.dsh/settings.yaml` (namespace `toolfold`) — the same document the product and other
|
|
90
|
-
plugins use, host-side, so they survive browser/device changes. The card footer shows
|
|
91
|
-
"设置保存在 DSH 主机配置". The file is editable directly:
|
|
139
|
+
- **Primary (installed/bundle mode)** – stored via the DSH **settings service** in `~/.dsh/settings.yaml` (namespace `toolfold`). They follow the dsh host, so they persist across browsers/devices. You can also edit the file manually:
|
|
92
140
|
|
|
93
141
|
```yaml
|
|
94
142
|
toolfold:
|
|
95
|
-
durMs: 240 # expand animation duration
|
|
96
|
-
|
|
97
|
-
splitThink: true #
|
|
98
|
-
stats: false # performance
|
|
143
|
+
durMs: 240 # expand animation duration 0–2000 ms
|
|
144
|
+
thinkMode: auto # completed-thinking display: auto-follow official fold / keep always / hide always
|
|
145
|
+
splitThink: true # whether to split call groups by thinking
|
|
146
|
+
stats: false # whether to enable performance stats
|
|
99
147
|
```
|
|
100
148
|
|
|
101
|
-
- **
|
|
102
|
-
settings bridge): degrades to browser `localStorage` (key `dsh-toolfold.settings.v1`) and the
|
|
103
|
-
card says "仅保存在本浏览器"; the legacy key `dsh-codex-collapse.settings.v1` migrates
|
|
104
|
-
automatically on first load.
|
|
149
|
+
- **Fallback (when settings service is unavailable)** – falls back to browser `localStorage` (key `dsh-toolfold.settings.v1`), so settings are only kept in that browser. The old key `dsh-codex-collapse.settings.v1` is automatically migrated on first load.
|
|
105
150
|
|
|
106
|
-
|
|
107
|
-
|
|
151
|
+
The settings card shows the current storage method (“Settings saved in DSH host config” or “Saved only in this browser”).
|
|
152
|
+
|
|
153
|
+
---
|
|
108
154
|
|
|
109
155
|
## Performance
|
|
110
156
|
|
|
111
|
-
- **Measured on
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
-
|
|
123
|
-
|
|
124
|
-
- **
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
- Expanded state is remembered per session flow + node key; reopening a session with the same keys
|
|
128
|
-
restores it;
|
|
129
|
-
- Settings are owned by the DSH host config (`~/.dsh/settings.yaml`); browser `localStorage` is
|
|
130
|
-
only the fallback when the host bridge is unreachable (then each browser needs its own setup);
|
|
131
|
-
- Requires `MutationObserver` and `requestAnimationFrame`; without them it degrades to "fold once on
|
|
132
|
-
initial render".
|
|
157
|
+
- **Measured on a real GUI page (8 s idle window)** – total engine time ~1.6–2.8 ms (~0.3 ms/s, ~0.03% single‑core); during a 5‑s CPU profile, engine functions appeared zero times.
|
|
158
|
+
- **Zero work during streaming** – streaming thinking/text tokens are short‑circuited with O(1) checks and do not trigger any recalculation (~0.1–0.4 µs per node).
|
|
159
|
+
- **Hidden tab = literally zero** – all observers and timers are disconnected when the tab is hidden; they are re‑attached and a single reconciliation run is performed when the tab becomes visible again.
|
|
160
|
+
- Enable **“Performance stats”** in the settings card to see detailed timings for every plugin operation.
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
## Limitations & Compatibility
|
|
165
|
+
|
|
166
|
+
- **DOM‑based** – folding relies on stable product DOM markers. If markers change, the worst case is that folding stops working – it will not break the chat.
|
|
167
|
+
- **Splitting rules**:
|
|
168
|
+
- Ongoing thinking and plain text output separate tool call groups.
|
|
169
|
+
- Completed thinking also separates groups by default (when “Split thinking across call groups” is on); when off, thinking is folded together with its surrounding call group.
|
|
170
|
+
- **State memory** – expand/collapse state is remembered per conversation flow and node key; re‑opening a conversation with the same key restores the state.
|
|
171
|
+
- **Browser requirements** – needs `MutationObserver` and `requestAnimationFrame`. If unsupported, it falls back to “fold once on initial render”.
|
|
172
|
+
- **Settings storage** – uses the DSH host config (`~/.dsh/settings.yaml`) when available; only falls back to `localStorage` when the host bridge is unreachable (in which case settings are browser‑local only).
|
|
133
173
|
|
|
134
174
|
---
|
|
135
175
|
|
|
136
|
-
This project
|
|
176
|
+
> This project is entirely built with dsh + deepseek v4 flash(max).
|
package/README.md
CHANGED
|
@@ -1,56 +1,54 @@
|
|
|
1
1
|
# dsh-toolfold · 工具调用折叠
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
[](https://awesome-dsh-plugin.com)
|
|
4
|
+
|
|
5
|
+
中文 | [English](README.en.md)
|
|
6
|
+
|
|
7
|
+
> DSH Web GUI 插件,提供**简单的工具调用折叠体验**:把连续的**工具调用**折叠成一条简洁的折叠条,只展示最后一个调用的一行摘要,点击即可展开/收起。不替换任何内置渲染器,卸载后界面完全恢复原样。
|
|
6
8
|
|
|
7
9
|

|
|
8
|
-
<!-- 🖼️ 图片位:assets/demo-fold.gif —— 建议录制 6~10s:多个工具调用自动折成一条 → 点击展开(卡片瀑布落下)→ 点击收起(卡片上行、高度收缩),16:9,≤2MB -->
|
|
9
|
-
|
|
10
|
-
## 特性一览
|
|
11
|
-
|
|
12
|
-
- **连续工具调用折叠为一条**:相邻的工具调用整段收起,条内直接显示**最后一个调用**的一行
|
|
13
|
-
摘要,并标注「已折叠 N 个工具调用 · 点击展开」;
|
|
14
|
-
- **思考分隔调用组(默认开启)**:已完成的思考会把前后两组工具调用**隔开、各自独立折叠**,
|
|
15
|
-
不会把思考前后的调用合并成一条;关闭后恢复原折叠方式——思考并入所在工具组一起折叠;
|
|
16
|
-
- **思考默认隐藏,可保留**:已完成的思考默认隐藏(不占版面);开启「保留思考」后思考不再
|
|
17
|
-
消失——分隔模式下显示在两条折叠条之间,合并模式下展开时按**原顺序插回调用之间**;
|
|
18
|
-
- **进行中的思考独立显示**:流式思考保持原样可见,完成后按「思考分隔」设置处理;
|
|
19
|
-
- **弹性瀑布动画**:展开时卡片自上而下逐张落下(spring 回弹),收起时逐张上行且行高度同步收缩,
|
|
20
|
-
下方内容连续上移、结尾无跳变;系统开启「减少动态效果」时动画自动关闭;
|
|
21
|
-
- **贴底不顶出**:靠近底部展开时,折叠条视口位置被钉住,不会因聊天自动滚动被顶出屏幕;
|
|
22
|
-
- **接近零性能占用**:无页面级观察器、流式期间引擎零工作、标签页隐藏时全部暂停——
|
|
23
|
-
实机测量空闲开销约 0.03% 单核(详见[性能](#性能))。
|
|
24
10
|
|
|
25
|
-
|
|
26
|
-
<!-- 🖼️ 图片位:assets/expand-collapse.gif —— 建议:单段 3~4 个调用的展开(瀑布落下 + 标签滑左)与收起(上行 + 高度收缩)特写,正方形或 4:3,≤2MB -->
|
|
11
|
+
---
|
|
27
12
|
|
|
28
|
-
##
|
|
13
|
+
## 目录
|
|
29
14
|
|
|
15
|
+
- [安装](#安装)
|
|
16
|
+
- [快速上手](#快速上手)
|
|
17
|
+
- [初次使用·默认行为说明](#初次使用默认行为说明)
|
|
18
|
+
- [功能特性](#功能特性)
|
|
19
|
+
- [设置说明](#设置说明)
|
|
20
|
+
- [设置项](#设置项)
|
|
21
|
+
- [存储位置](#存储位置)
|
|
22
|
+
- [性能](#性能)
|
|
23
|
+
- [限制与兼容性](#限制与兼容性)
|
|
30
24
|
|
|
25
|
+
---
|
|
31
26
|
|
|
32
|
-
|
|
27
|
+
## 安装
|
|
28
|
+
|
|
29
|
+
### 推荐(通过 npm)
|
|
33
30
|
|
|
34
31
|
```sh
|
|
35
|
-
dsh plugin --profile web add
|
|
32
|
+
dsh plugin --profile web add dsh-toolfold
|
|
36
33
|
```
|
|
37
34
|
|
|
38
|
-
###
|
|
35
|
+
### 其他方式
|
|
39
36
|
|
|
40
37
|
```sh
|
|
38
|
+
# 从 GitHub 安装
|
|
39
|
+
dsh plugin --profile web add github:Minecraftbe/dsh-toolfold
|
|
40
|
+
|
|
41
|
+
# 从源码安装
|
|
41
42
|
git clone https://github.com/Minecraftbe/dsh-toolfold.git
|
|
42
43
|
dsh plugin --profile web add ./dsh-toolfold
|
|
43
44
|
```
|
|
44
45
|
|
|
45
|
-
|
|
46
|
-
最终配置:
|
|
46
|
+
安装后**重启 dsh 并刷新浏览器**即可生效。可通过以下命令确认配置已生效:
|
|
47
47
|
|
|
48
48
|
```sh
|
|
49
49
|
dsh --profile web --dump-config
|
|
50
50
|
```
|
|
51
51
|
|
|
52
|
-
> 早期版本若曾在 `cordis.patch.yml` 手工加过 `toolfold` 行,先删除该行再切换,避免双挂载。
|
|
53
|
-
|
|
54
52
|
### 卸载
|
|
55
53
|
|
|
56
54
|
```sh
|
|
@@ -59,62 +57,119 @@ dsh plugin --profile web remove dsh-toolfold
|
|
|
59
57
|
|
|
60
58
|
重启后界面完全恢复原样。
|
|
61
59
|
|
|
62
|
-
|
|
60
|
+
> ⚠️ **版本支持**:自 `0.1.9` 起,本插件仅支持 DSH `>= 0.1.2-rc.1` 且 `< 0.1.3`。在此范围之外的 DSH 上,设置卡片会显示版本不匹配警告,折叠功能可能无法正常工作。
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## 快速上手
|
|
65
|
+
|
|
66
|
+
安装完成后,在 DSH 对话界面中,连续的工具调用会自动折叠为一条折叠条。
|
|
67
|
+
|
|
68
|
+
- **点击折叠条**:展开或收起工具调用卡片(键盘 `Enter` / `Space` 同样有效)
|
|
69
|
+
- **折叠条显示**:最后一个工具调用的一行摘要 + “已折叠 N 个工具调用 · 点击展开”
|
|
70
|
+
|
|
71
|
+

|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## 初次使用·默认行为说明
|
|
76
|
+
|
|
77
|
+
插件安装后立即生效,你可能首先注意到两个“异常”现象——这都是默认设置所致,可按需调整。
|
|
78
|
+
|
|
79
|
+
### ❓ 思考内容怎么消失了?
|
|
80
|
+
|
|
81
|
+
**原因**:默认「思考显示」为「自动跟随官方折叠」——官方未收起整块过程时,已完成的思考默认隐藏以节省空间。
|
|
63
82
|
|
|
64
|
-
|
|
83
|
+
**改回**:`设置 → 插件 → 工具折叠` → 「思考显示」选「始终保留」。
|
|
84
|
+
|
|
85
|
+
### ❓ 工具调用为什么被切成了两段?
|
|
86
|
+
|
|
87
|
+
**原因**:默认开启「思考分隔调用组」(`splitThink: true`),插件把思考视为逻辑分界线,将前后的工具调用各自独立折叠。
|
|
88
|
+
|
|
89
|
+
**改回**:`设置 → 插件 → 工具折叠` → 关闭「思考分隔调用组」。
|
|
90
|
+
|
|
91
|
+
> 进行中的思考不受任何开关影响,始终保持可见,完成后再按规则处理。
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## 功能特性
|
|
96
|
+
|
|
97
|
+
### 核心折叠行为
|
|
98
|
+
|
|
99
|
+
- **连续工具调用自动折叠**:相邻工具调用整段收起,仅显示最后一个调用的摘要行,并标注折叠数量
|
|
100
|
+
- **思考分隔调用组(默认开启)**:已完成的思考会将前后两组工具调用**隔开、各自独立折叠**,不会跨思考合并
|
|
101
|
+
- **思考显示(三档)**:默认「自动跟随官方折叠」——官方收起整块过程时保留思考,其余时候隐藏;也可切「始终保留」(分隔模式下显示在两条折叠条之间,合并模式下展开时插回调用之间)或「始终隐藏」
|
|
102
|
+
- **进行中的思考独立显示**:流式思考始终保持可见,完成后按上述规则处理
|
|
103
|
+
|
|
104
|
+
### 动画与体验
|
|
105
|
+
|
|
106
|
+
- **弹性瀑布动画**:展开时卡片逐张落下(带 spring 回弹),收起时逐张上行且高度同步收缩,下方内容连续上移、无跳变
|
|
107
|
+
- **贴底不顶出**:靠近底部展开时,折叠条视口位置固定,不会因自动滚动被顶出屏幕
|
|
108
|
+
- **尊重系统偏好**:系统开启「减少动态效果」时,动画自动关闭
|
|
109
|
+
|
|
110
|
+
### 性能与资源
|
|
111
|
+
|
|
112
|
+
- **接近零性能占用**:无页面级观察器,流式期间引擎零工作,标签页隐藏时全部暂停(空闲开销约 0.03% 单核)
|
|
113
|
+
- **实时性能统计**(可选):在设置卡片内显示插件各环节耗时,便于验证开销
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## 设置说明
|
|
118
|
+
|
|
119
|
+
设置入口:**设置 → 插件 → 工具折叠**(卡片外观与内置插件一致,跟随深浅主题)。
|
|
65
120
|
|
|
66
121
|

|
|
67
|
-
|
|
122
|
+
|
|
123
|
+
### 设置项
|
|
68
124
|
|
|
69
125
|
| 设置项 | 说明 |
|
|
70
126
|
| --- | --- |
|
|
71
|
-
| **展开动画时长** |
|
|
72
|
-
|
|
|
73
|
-
| **思考分隔调用组** |
|
|
74
|
-
| **性能统计** |
|
|
127
|
+
| **展开动画时长** | 单张卡片的展开/收起动画时长(0–1000ms,默认 240ms;设为 0 为瞬时切换) |
|
|
128
|
+
| **思考显示** | 已完成思考的显示方式:自动跟随官方折叠(默认)/ 始终保留 / 始终隐藏 |
|
|
129
|
+
| **思考分隔调用组** | 开启(默认):已完成的思考把前后两组工具调用隔开、各自独立折叠;关闭:思考并入所在工具组一起折叠 |
|
|
130
|
+
| **性能统计** | 在卡片内实时显示插件自身耗时(观察回调/引擎刷新/合并重算/安全重扫/摘要克隆的累计次数与耗时,以及被零开销短路忽略的流式批次) |
|
|
75
131
|
|
|
76
|
-
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
### 存储位置
|
|
77
135
|
|
|
78
|
-
|
|
136
|
+
插件设置会自动持久化,优先级如下:
|
|
79
137
|
|
|
80
|
-
-
|
|
81
|
-
`~/.dsh/settings.yaml`(命名空间 `toolfold`),与产品和其他插件的设置在同一个文档里,
|
|
82
|
-
随 dsh 主机走,换浏览器/设备不丢失;卡片底部会显示「设置保存在 DSH 主机配置」。
|
|
83
|
-
也可以直接手工编辑该文件:
|
|
138
|
+
- **优先(已安装模式)**:由 DSH **设置服务**写入 `~/.dsh/settings.yaml`(命名空间 `toolfold`),随主机走,换浏览器/设备不丢失。手工编辑示例:
|
|
84
139
|
|
|
85
140
|
```yaml
|
|
86
141
|
toolfold:
|
|
87
142
|
durMs: 240 # 展开动画时长 0–2000ms
|
|
88
|
-
|
|
89
|
-
splitThink: true #
|
|
143
|
+
thinkMode: auto # 已完成思考的显示方式:auto 自动跟随官方折叠 / keep 始终保留 / hide 始终隐藏
|
|
144
|
+
splitThink: true # 是否让已完成的思考隔开前后两组工具调用
|
|
90
145
|
stats: false # 是否开启性能统计
|
|
91
146
|
```
|
|
92
147
|
|
|
93
|
-
-
|
|
94
|
-
|
|
95
|
-
|
|
148
|
+
- **降级(无设置服务时)**:退化为浏览器 `localStorage`(键 `dsh-toolfold.settings.v1`),仅保存在当前浏览器。旧版键 `dsh-codex-collapse.settings.v1` 会在首次加载时自动迁移。
|
|
149
|
+
|
|
150
|
+
设置卡片底部会显示当前使用的存储位置(“设置保存在 DSH 主机配置”或“仅保存在本浏览器”)。
|
|
96
151
|
|
|
97
|
-
|
|
98
|
-
<!-- 🖼️ 图片位:assets/keep-think.gif —— 建议:同一段调用分别以「保留思考 关 / 开」各演示一次展开,展示思考不显示 / 按原顺序插回,≤2MB -->
|
|
152
|
+
---
|
|
99
153
|
|
|
100
154
|
## 性能
|
|
101
155
|
|
|
102
|
-
-
|
|
103
|
-
|
|
104
|
-
-
|
|
105
|
-
-
|
|
106
|
-
|
|
156
|
+
- **实测数据(真实 GUI 页面,空闲窗口 8s)**:引擎总耗时约 1.6–2.8ms(≈0.3ms/s,约 0.03% 单核);同窗口 5s CPU 采样中引擎函数零样本。
|
|
157
|
+
- **流式零工作**:思考/文本 token 流式变更被 O(1) 短路忽略,不触发任何重算(约 0.1–0.4µs/节点)。
|
|
158
|
+
- **标签页隐藏 = 零占用**:隐藏时断开全部观察器与定时器,恢复可见时重挂并补一次对账。
|
|
159
|
+
- 打开「性能统计」即可在设置卡片内查看各项耗时明细。
|
|
160
|
+
|
|
161
|
+
---
|
|
107
162
|
|
|
108
|
-
##
|
|
163
|
+
## 限制与兼容性
|
|
109
164
|
|
|
110
|
-
-
|
|
111
|
-
-
|
|
112
|
-
|
|
113
|
-
-
|
|
114
|
-
-
|
|
115
|
-
|
|
116
|
-
-
|
|
165
|
+
- **基于 DOM 标记**:折叠依赖产品稳定的渲染标记;若标记变动,最坏情况是折叠停止生效,但不会破坏聊天。
|
|
166
|
+
- **分隔规则**:
|
|
167
|
+
- 进行中的思考与 AI 文字输出会隔开工具调用
|
|
168
|
+
- 已完成的思考默认也隔开(「思考分隔调用组」开启时);关闭后已完成的思考并入所在工具组一起折叠
|
|
169
|
+
- **状态记忆**:展开状态按会话流 + 节点 key 记忆;会话重开且 key 相同时会恢复展开状态。
|
|
170
|
+
- **浏览器要求**:需要支持 `MutationObserver` 与 `requestAnimationFrame`;不支持时退化为“初始渲染折叠一次”。
|
|
171
|
+
- **设置存储**:以 DSH 主机配置(`~/.dsh/settings.yaml`)为准;仅当主机桥不可达时才退化为 `localStorage`(换浏览器/设备需重新设置)。
|
|
117
172
|
|
|
118
173
|
---
|
|
119
174
|
|
|
120
|
-
本项目完全由 dsh + deepseek v4 flash(max) 完成。
|
|
175
|
+
> 本项目完全由 dsh + deepseek v4 flash(max) 完成。
|