dsh-auto-collapse 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 dsh-auto-collapse contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.en.md ADDED
@@ -0,0 +1,80 @@
1
+ # dsh-auto-collapse
2
+
3
+ > A DeepSeek Harness Web client plugin that auto-collapses tool cards and Think blocks into one-line summaries, so the chat keeps only what the model says.
4
+ >
5
+ > 中文: [README.md](./README.md)
6
+
7
+ ## What it does
8
+
9
+ `dsh-auto-collapse` is a pure front-end DOM plugin for the DeepSeek Harness Web chat UI. It collapses the working process into one-line summaries — tool calls and reasoning no longer fill the screen, giving the chat the collapsible look of the VSCode Codex desktop client, **and it also rewrites “Deep diving” to “Deep sleeping”**. It never modifies message content — it only controls visibility of the working process.
10
+
11
+ ## Preview
12
+
13
+ ![Collapsed workflow](assets/screenshot.png)
14
+
15
+ ## Features
16
+
17
+ - **Turn-level auto collapse** (Level 1): when a turn finishes, the whole working process collapses into a `已处理 X秒` (processed in Xs) row, leaving only the model's final text. Click to expand the full workflow (context injections → thinking → tool calls → intermediate text → final text).
18
+ - **Second-level rows**: after expanding level one, tool-call groups and think blocks each collapse into a single chip row (`正在运行 {command}` / `运行了命令` / `已思考`), click to expand/collapse; adjacent tool groups merge, while body text serves as a hard boundary (never merged across).
19
+ - **Third-level think merge**: expanding `已思考` shows consecutive think rows merged into one row titled `Think · first line`, click to reveal the merged content block; raw fourth-level rows never appear.
20
+ - **Native visual alignment**: 16px icon box / 14px glyph / 24px line height / 16px row gap; colors use DSH native tokens (`--dsw-alias-label-*`); think and command icons come from DSH native icons (`IconThinkOutline14` / `IconApiOutline14`).
21
+ - **Stream-friendly**: in-place `assistant-step` body updates, React node replacement, and out-of-order history mounting are reconciled on every pass; running rows use a smooth text pulse motion, disabled by `prefers-reduced-motion`.
22
+ - **Complete work-node coverage**: top-level `command` / `manual-compaction`, context nodes, and image-only finals follow the same turn semantics as tool calls.
23
+ - **Fully reversible**: uninstalling (HMR stop) restores every collapsed/hidden/rewritten node.
24
+
25
+ ## Install
26
+
27
+ ```bash
28
+ dsh plugin --profile web add "github:a179-sanae/dsh-auto-collapse#main"
29
+ ```
30
+
31
+ Restart the DSH web service (or trigger plugin HMR), then hard-refresh the page (`Ctrl+Shift+R`). No configuration needed.
32
+
33
+ ## Development
34
+
35
+ ### Project layout
36
+
37
+ ```
38
+ src/fold.ts core: FoldController (state machine) + findBlocks (block recognition) + collapse/expand logic
39
+ src/client.ts browser entry (plugin registration)
40
+ src/index.ts host half
41
+ build.mjs esbuild build (the client registration id lives in the banner)
42
+ deploy.mjs safe deploy: validate → back up → replace → verified restart → hash check/rollback
43
+ cordis.patch.yml profile tree mounting
44
+ test/ fake-DOM contract, race, session-switch, and 40-order permutation regressions
45
+ ```
46
+
47
+ ### Checks
48
+
49
+ ```bash
50
+ npm run check
51
+ ```
52
+
53
+ Runs TypeScript checking, a fresh build, and the complete regression suite.
54
+
55
+ ### Quick deploy (local dev)
56
+
57
+ ```bash
58
+ npm run deploy
59
+ ```
60
+
61
+ Validates the plugin/DSH package identities and the process listening on port 3080, then creates a timestamped backup, replaces the bundle, restarts DSH, and verifies the served hash. Failures restore the old bundle. Override defaults with `DSH_AUTO_COLLAPSE_LIB`, `DSH_DIR`, `DSH_WEB_PORT`, and `DSH_LOG_DIR`.
62
+
63
+ ### Publishing a new version
64
+
65
+ ```bash
66
+ npm pack --pack-destination <local-plugin-dir> # packing auto-triggers the build via the prepack hook
67
+ ```
68
+
69
+ Point the plugin dependency in the profile's `package.json` to the new tarball and reinstall the plugin.
70
+
71
+ ### Key mechanisms
72
+
73
+ - **Block recognition** (`findBlocks`): top-level nodes are classified as tool calls, command/manual-compaction cards, contexts, thinking, or body content; user/steering/turn-tail nodes are hard boundaries.
74
+ - **Segment reconciliation**: every pass rebuilds segments from current DOM order. The last `assistant-step` containing text or media is final; earlier bodies are intermediate work. Stable flow/node keys preserve UI state without one-shot mutation bookkeeping.
75
+ - **Duration**: streaming segments each track their own first running observation; historical segments parse official duration or the `timeStart`/turn-tail range. Whole minutes omit the seconds field.
76
+ - **React coexistence and reversibility**: replaced nodes rebind by stable key, removed level-one rows rebuild with their expansion state, and every inline `display` value is saved before mutation and restored exactly.
77
+
78
+ ## License
79
+
80
+ MIT
package/README.md ADDED
@@ -0,0 +1,80 @@
1
+ # dsh-auto-collapse
2
+
3
+ > DeepSeek Harness Web 客户端插件:把会话里的工具卡片与 Think 推理块自动折叠成一行摘要,让界面只保留模型说的话。
4
+ >
5
+ > English: [README.en.md](./README.en.md)
6
+
7
+ ## 这是什么
8
+
9
+ `dsh-auto-collapse` 是一个纯前端 DOM 插件,挂在 DeepSeek Harness Web 聊天界面上,把工作流程折叠成一行行摘要——工具调用、推理过程不再占据整屏,呈现接近 VSCode Codex 桌面端的折叠体验,**同时将“Deep diving” 修改为 “Deep sleeping”**。它不改动消息内容,只控制工作流程的显示状态。
10
+
11
+ ## 效果预览
12
+
13
+ ![折叠效果](assets/screenshot.png)
14
+
15
+ ## 特性
16
+
17
+ - **回合完成自动收起**(一级):每个回合完成后,工作过程收成一行 `已处理 X秒`,只留模型最终正文;点击展开完整工作流程(上下文注入 → 思考 → 工具调用 → 过程正文 → 最终正文)。
18
+ - **二级折叠行**:展开一级后,工具调用组与思考块各自折叠成一行 chip(`正在运行 {命令}` / `运行了命令` / `已思考`),点击展开/收起;相邻工具组合并,正文输出是硬边界(不会跨正文合并)。
19
+ - **三级思考合并**:展开 `已思考` 后,连续思考合并为一个三级思考行(标题 `Think · 第一句`),点击展开合并内容块;原始四级行不出现。
20
+ - **原生视觉对齐**:图标盒 16px / glyph 14px / 行高 24px / 行距 16px,颜色使用 DSH 原生 token(`--dsw-alias-label-*`),思考与命令图标取自 DSH 原生图标(`IconThinkOutline14` / `IconApiOutline14`)。
21
+ - **流式友好**:同一个 `assistant-step` 原地补正文、React 换节点和历史乱序挂载都会重新协调;running 状态带文字平滑呼吸动画,`prefers-reduced-motion` 下停止动画。
22
+ - **完整工作类型**:除 tool-call 外,顶层 `command` / `manual-compaction`、context 和纯图片 final 都按同一回合语义处理。
23
+ - **可逆**:卸载(HMR stop)时完整还原所有折叠/隐藏/改写。
24
+
25
+ ## 安装
26
+
27
+ ```bash
28
+ dsh plugin --profile web add "github:a179-sanae/dsh-auto-collapse#main"
29
+ ```
30
+
31
+ 安装后重启 DSH web 服务(或触发插件 HMR),页面 `Ctrl+Shift+R` 硬刷新即可生效。无需任何配置。
32
+
33
+ ## 开发
34
+
35
+ ### 项目结构
36
+
37
+ ```
38
+ src/fold.ts 核心:FoldController(状态机)+ findBlocks(块识别)+ 折叠/展开逻辑
39
+ src/client.ts 浏览器端入口(注册插件)
40
+ src/index.ts host half
41
+ build.mjs esbuild 构建(lib/client.js 的注册 id 在 banner 里)
42
+ deploy.mjs 安全部署:校验 → 备份 → 替换 → 身份核验重启 → 哈希验证/回滚
43
+ cordis.patch.yml profile 树挂载
44
+ test/ fake DOM 契约、竞态、会话切换与 40 组乱序排列回归
45
+ ```
46
+
47
+ ### 检查
48
+
49
+ ```bash
50
+ npm run check
51
+ ```
52
+
53
+ 依次执行 TypeScript 检查、构建和全部回归测试。
54
+
55
+ ### 快速部署(本机开发)
56
+
57
+ ```bash
58
+ npm run deploy
59
+ ```
60
+
61
+ 脚本先核验插件/DSH 包名和 3080 监听进程身份,再做时间戳备份、替换、重启与服务端哈希验证;失败自动恢复旧 bundle。可用 `DSH_AUTO_COLLAPSE_LIB`、`DSH_DIR`、`DSH_WEB_PORT`、`DSH_LOG_DIR` 覆盖默认路径。
62
+
63
+ ### 发布新版本
64
+
65
+ ```bash
66
+ npm pack --pack-destination <本地插件目录> # 打包(prepack 钩子自动构建)
67
+ ```
68
+
69
+ 将 profile 的 `package.json` 中插件依赖更新为新 tgz 路径后重新安装插件。
70
+
71
+ ### 关键机制
72
+
73
+ - **块识别**(`findBlocks`):顶层节点按 tool-call、command/manual-compaction、context、thinking 和正文分类;user/steering/turn-tail 是不可跨越的硬边界。
74
+ - **segment 协调**:每轮根据当前 DOM 顺序重建 segment;最后一个含文本或媒体的 `assistant-step` 是 final,其余正文是中间过程。稳定 flow/key 复用展开状态,不依赖一次性 mutation 事件。
75
+ - **时长**:流式回合按 segment 分别记录 running 起点;历史回合从官方时长或 `timeStart`/turn-tail 解析。格式 `X秒` / `X分Y秒`,整分省略秒位。
76
+ - **React 共存与可逆性**:节点替换后按稳定 key 重新绑定;一级行被移除会按原展开状态重建;所有 inline `display` 在首次改写前保存并精确恢复。
77
+
78
+ ## 许可
79
+
80
+ MIT
@@ -0,0 +1,4 @@
1
+ # dsh-auto-collapse bundle patch layer —— insert 一行:把本插件挂载进 profile 树。
2
+ - insert:
3
+ - id: dsh-auto-collapse
4
+ name: dsh-auto-collapse