v0.1.0
dsh-diff-stat v0.1.0
Second release. One shared LCS arithmetic for badge, body and footer, full coverage for the minimal preset's
str_replace_editor, a summary card for pure Code-Mode turns, real file context around PTC fragments, and a self-contained build — plus fixes for a render-loop freeze and Explorer's reveal action.
Install / 安装
# from npm / 从 npm 安装
dsh plugin --profile web add dsh-diff-stat
# or from GitHub / 或从 GitHub 安装
dsh plugin --profile web add github:HaoyueQin/dsh-diff-statUninstall:
dsh plugin --profile web remove dsh-diff-statHighlights / 亮点
- One arithmetic — badge, body, footer: the inline badge and the window footer now count the real changed lines from the same LCS walk the diff renders — locator/context lines shared by both sides count nowhere, so a
+6 −4badge can no longer open as two green rows. Running rows keep the argument estimate; settled rows switch to the exact result-view hunks. - Minimal preset &
str_replace_editor: the minimal preset's editor joins the takeover keys — itscreate/str_replace/insertcommands map to the same hunk shapes overpath/old_str/new_str/file_text(the read-onlyviewrenders through the row body as before). - Code-Mode turns get their card: dispatch sub-calls carry no turn coordinate, so a pure Code-Mode turn never showed a summary card. The accumulator flags
run_codeturns, and the card joins their files from the stock chat tool tree — thetool-callnodes fold every dispatch into its root call'ssubCalls— merged with native files for display and undo. - Real file context for PTC fragments: argument-derived hunks are marked by object identity; on expand the booster reads the file through the fenced API (LRU-cached), locates the fragment's post-image and rebuilds it with up to ±3 shared lines per side. Best-effort — unlocatable fragments render bare, and totals are unaffected.
- Aligned diff window: both sides are LCS-aligned before rendering — shared lines become ±3 context around each change, untouched runs fold into
⋯, the window scrolls instead of collapsing, and the footer counts exactly the rendered rows.
Fixes / 修复
- Render-loop freeze on Code-Mode turns: reviewing a second file froze the page beyond refresh. Three identity hazards chained into an endless render loop — the chain select rebuilt its match array every render, the join selector returned a fresh array under uSES's
Object.isequality, and the boost effect keyed on churning state. The select is now memoized per published data, the selector returns the snapshot itself with extraction in a memo, and the boost effect keys on user interaction only; native-only turns never wrote state, which is why they were immune. - "Reveal in Explorer" opened the default view: spawn's array form re-escapes the embedded quotes of explorer's
/select,"<path>"syntax, and explorer — seeing a mangled argument — falls back silently. Both openers pass their literal command line through the shell now, with quote and%rejected up front (cmd expands%VAR%inside quotes). - UTF-8 read-cap boundary:
files.read's 512 KiB cap could cut mid-sequence and turn the truncated tail into U+FFFD; the cap now slices at the last complete sequence boundary. - npm script-shell pin moved to the user npmrc (a repo file broke Linux CI); Windows checkout paths are translated for the build.
Infrastructure / 基建
- Self-contained build (
build!): the checkout-coupled bash + junction pipeline is gone — onetsdownrun builds both halves, every dependency resolves inside the project, andlib/stays committed forgithub:direct installs. CI verifies typecheck, the diff-alignment assertions and a committed-libfreshness gate; the release workflow attaches a versioned tarball plus the fixed-namedsh-diff-stat.tgz. - Check-script coverage: 15 assertion groups now cover the aligner, the badge arithmetic, the PTC join, the context booster, the editor command mapping and the turnTail claim decision — pure functions live in the zero-dependency
turn-mergemodule so the script can reach them directly.
中文说明
第二个版本。本版把「数字与渲染一致」做成硬约束,并把覆盖面补齐到极简预设与纯 Code-Mode 轮:
- 同一套算术——徽标、正文、页脚:行内徽标与窗口页脚改为统计真实变更行数(与渲染共用同一趟 LCS),两侧共同的定位/上下文行不再计数——「+6 −4 展开只有两行绿」的口径分裂从根上消除;运行中保持参数预估,结算后精确。
- 极简预设与
str_replace_editor:极简预设的编辑器加入接管键,create/str_replace/insert按path/old_str/new_str/file_text映射为同样的 hunk 形态(只读view照旧走行体渲染)。 - 纯 Code-Mode 轮也有汇总卡:dispatch 子调用没有轮坐标,此前纯 PTC 轮从不显示轮末卡;现在聚合器标记
run_code轮,卡片从 stock 会话工具树 join 出其文件(tool-call节点已按 rootCallId 折叠subCalls),与原生文件合并展示并参与撤销。 - PTC 片段的真实文件上下文:参数来源的 hunk 按对象身份标记;展开时经围栏 API(LRU 缓存)读取文件、定位片段 after 形态并以每侧至多 ±3 行共享行重建。尽力而为:无法定位的片段保持原样,统计不受影响。
- 对齐 diff 窗口:渲染前两侧 LCS 对齐——共同行作 ±3 上下文、未变更折叠
⋯、窗口滚动替代折叠,页脚与正文完全同源。
修复:
- Code-Mode 轮点第二个文件的「审查」导致页面卡死且刷新无效——三重身份不稳定链成无限渲染循环(链 select 每渲染重建数组、join selector 在 uSES 的 Object.is 相等下返回新数组、boost effect 依赖抖动状态);现 select 按发布数据记忆化、selector 返回快照自身并在 memo 中提取、boost 只由用户交互触发。纯原生轮不写状态,因此免疫。
- 「在资源管理器中显示」只打开默认视图——spawn 数组形式会再转义
/select,"<path>"的引号导致 explorer 静默回退;两个打开器改为 shell 字面量传参,并预先拒绝引号与%(cmd 在引号内展开%VAR%)。 files.read的 512 KiB 截断可能切断 UTF-8 序列产生 U+FFFD;现按最后完整序列边界截取。- npm script-shell 固定迁移到用户 npmrc(仓库内文件曾破坏 Linux CI);Windows 检出路径已转换。
基建:
- 自包含构建(
build!):移除依赖 harness 检出的 bash + junction 构建链——一次tsdown构建双端,全部依赖落在项目内,lib/入库支持github:直装;CI 校验 typecheck、diff 对齐断言与入库 lib 的新鲜度门,release 工作流附加版本号 tarball 与固定名dsh-diff-stat.tgz。 - 检查脚本覆盖:15 组断言覆盖对齐引擎、徽标算术、PTC join、上下文增强、编辑器命令映射与 turnTail 认领决策(纯函数集中于零依赖的
turn-merge模块,脚本可直接触达)。