omdsh-dev/dsh-tool-diff

DSH Diff Tool Plugin: Structured comparison of text/JSON/CSV/Markdown and unified diff, zero-dependency read-only, registers diff tools.

Project Overview项目介绍

This is a difference comparison tool built natively for DeepSeek Harness (DSH). It provides structured comparison for four common content types: plain text, JSON, CSV, and Markdown, and can output standard unified diff results. It addresses common pain points when agents need to compare two content blocks: spawning a new system diff process is especially slow on Windows, system diff cannot detect structured changes for nested JSON, and hand-written comparison logic is highly error-prone. For DSH 0.1.5-rc.1 and newer, you can install the plugin with one command, adding it to either your interactive web profile or headless batch profile.

The plugin follows a zero-dependency design, with all core logic written from scratch. This includes the Myers line-level diff algorithm, RFC 4180 CSV parser, and recursive JSON comparison. It operates as a read-only tool, meaning it never reads or writes local files, connects to the network, or invokes git. All patch generation and validation happens strictly in memory, so it never modifies any content on your local disk. Input and output sizes are strictly bounded to keep memory usage and runtime within controlled, reasonable limits.

The plugin exposes five different diff actions: text, json, csv, markdown, and patch. Each action outputs a standardized JSON envelope with common summary fields including equal, truncated, beforeBytes, afterBytes, and a list of changes. It is released under the permissive MIT open source license, so you can use it freely in both personal and commercial projects. If you prefer to build from source, you can clone the repository, run npm install and npm pack to create a tarball, then install it locally to your DSH profile.

这是一款专为 DeepSeek Harness (DSH) 开发的原生差异比较插件,支持文本、JSON、CSV、Markdown 四种格式的结构化差异对比,可生成标准的 unified diff 输出。它解决了调用系统 diff 进程开销大(尤其是 Windows 平台)、系统 diff 无法识别结构化变更、手写对比逻辑容易出错的问题,一次调用即可在毫秒级返回结构化结果。

插件采用零依赖设计,所有核心逻辑(Myers行级diff、RFC 4180格式解析、JSON递归比较)都是纯手写实现。它是只读工具,不会读写本地文件、联网或调用git,所有补丁操作仅在内存中完成,不会写入本地磁盘。同时对输入输出做了明确的大小限制,保障运行效率和资源占用始终可控。

插件支持文本、JSON、CSV、Markdown、patch五种diff动作,兼容DSH 0.1.5-rc.1及以上版本,可通过DSH的bundle命令一键安装到web或headless配置profile。它使用MIT许可开源,用户也可以克隆源码通过npm打包后本地安装,适合需要对比不同内容片段的DSH Agent开发工作流。

Pre-install check安装前体检Compatibility · Security兼容性 · 安全性 1 warning1 项注意
  • Only 4 stars - very few users, little community feedback星标只有 4,几乎没人在用,遇到问题缺少社区反馈
DSH walks through these 9 checksDSH 会逐条核对这 9 项

Compatibility兼容性

  • DSH, Node, OS and profile requirementsDSH 版本 / Node 版本 / 操作系统 / profile 是否满足要求
  • External dependencies and runtimes (Electron / Python / Docker, ...)外部依赖与运行时(Electron / Python / Docker 等)是否齐备
  • Conflicts with installed plugins: command names, skill / tool names, ports, duplicate MCP registration与已装插件是否冲突:命令名、skill / tool 重名、端口占用、重复 MCP 注册

Security安全性

  • Repo matches the facts registered here; archived or abandoned?仓库是否与页面登记一致,是否归档或长期停更
  • Safety of preinstall / install / postinstall and install.sh / setup.ps1preinstall / install / postinstall 与 install.sh、setup.ps1 是否安全
  • curl|bash, download-then-execute, obfuscation, unrelated domains → stop immediatelycurl|bash、下载即执行、混淆代码、无关域名 → 立刻停止
  • Typosquatting or unmaintained packages among the new dependencies新增依赖里有没有 typosquatting 或无人维护的包
  • Requested permissions vs. what the feature actually needs申请了哪些权限、是否超出功能所需(filesystem / network / shell / clipboard)
  • Any sudo / admin requirement, plus uninstall and rollback是否要求 sudo / 管理员权限,以及卸载与回滚方式

Anything uncertain must be marked unknown with a note on how to confirm it. This site's signal screen is a static snapshot, not a security audit.拿不准的必须标「未知」并说明要我怎么确认。本站的信号筛查是静态快照,不能替代安全审计。

Or use CLI install (for developers)或使用命令行安装(适合开发者)

CLI Install命令行安装

dsh plugin --profile web add github:omdsh-dev/dsh-tool-diff

把 omdsh-dev/dsh-tool-diff 加入你的 DSH 配置(web profile)即可启用。

READMEREADME

dsh-tool-diff

English

DSH Diff 文本差异工具插件 —— 文本 / JSON / CSV / Markdown 结构化比较与 unified diff 生成。零依赖、纯函数、只读。

License

动机

Agent 需要对比两份内容(配置片段、API 响应、表格、文档修订)时,现有路径是起 bash 进程调用系统 diff 或手写比较逻辑:

  1. 每次调用都起进程——Windows 上尤其昂贵
  2. 系统 diff 不懂结构——JSON 只能给整段文本差异,看不出 $.user.name 这样的路径级变更
  3. 手写比较代码不可验证——边界(引号内逗号、嵌套数组、标题重命名)极易出错

本插件提供确定性、零依赖、纯函数的差异比较:一次函数调用,毫秒级返回结构化 JSON 报告或标准 unified diff。

安全模型

  • 零依赖:Myers 行级 diff、RFC 4180 解析器、JSON 递归比较全部手写
  • 只读:不读文件、不写文件、不联网、不调 git;patch action 只在内存中生成并校验补丁,绝不落盘
  • 预算:
    • 输入单侧 ≤ 256 KiB(超限直接报错)
    • 输出 ≤ 64 KiB(超限按 maxChanges 与字节预算截断并置 truncated)
    • Myers diagonal 预算 2000 + 蛇步总预算 2000 万 + 公共前后缀修剪 + hash 快速拒绝 + 规模上限 4000 行 → 恶意重复/全异文本有界完成
    • 行数 ≤ 50K、JSON 嵌套 ≤ 64 层、CSV ≤ 50K 行 / 512 列
    • timeoutMs: 2000
  • 工具参数会记入会话日志,不要传入敏感数据

工具声明

注册 diff 工具(@deepseek-ai/dsh-tool-diff,row id tool-diff),统一输出 JSON 文本字符串信封:所有 action 都带通用摘要 { equal, truncated, beforeBytes, afterBytes, changes }。

action 作用 输出
text 行级 Myers diff unified diff(--- before / +++ after / @@ hunks,无时间戳)+ 统计;format=structured 输出带行号的操作列表
json 递归比较两个 JSON 值 $ 路径化变更($.user.name、$.items[0]、$['a.b'])+ add/remove/replace 汇总
csv RFC 4180 解析后按主键或位置比较 addedRows / removedRows / changedRows(列级)/ duplicateKeys / 列集合变化
markdown 轻量块级 tokenizer(标题/代码块/列表/引用/表格) headingChanges(rename 识别)/ blockChanges(h2[1]/p[0] 路径)/ codeBlockChanges + 全文 diff
patch 生成 unified diff 并在内存中校验 patch 文本 + valid / hunks / targetMatchesAfter / hunk 级错误
参数 类型 必填 说明
action string ✅ text / json / csv / markdown / patch
before string ✅ 原内容(任意 action 的输入侧)
after string ✅ 新内容
format string unified(默认 text/patch)/ structured(默认 json/csv/markdown)/ both
context integer unified 上下文行数,默认 3,范围 0..20
key string CSV 主键列名或 1-based 索引;缺省 → 位置比较
delimiter string CSV 分隔符,默认 ,,单字符或 tab
ignoreWhitespace boolean 比较时忽略空白差异(text/csv/markdown);patch action 拒绝(精确文本协议)
ignoreCase boolean 比较时忽略大小写(text/json/csv/markdown);patch action 拒绝
sortKeys boolean JSON 键排序,默认 true
maxChanges integer 最大报告变更数,默认 1000,硬顶 10000

Showing the opening section of the README — the full document lives in the repository以上为 README 开头摘要,完整文档在仓库内 · View the full README on GitHub →在 GitHub 查看完整 README →

← 上一个 Prev dsh-recover-context 下一个 Next dsh-provider-rate-limit →