New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

dsh-text-diff

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dsh-text-diff

Line-level text/file diff plugin for DeepSeek Harness: LCS-based unified diff format with configurable context. Pairs with dsh-diff-writer to form a find-and-fix loop.

npmnpm
Version
0.1.0
Version published
Weekly downloads
213
249.18%
Maintainers
1
Weekly downloads
 
Created
Source

dsh-text-diff

两文本 / 两文件的行级 diff 插件(dsh / DeepSeek Harness)。基于 LCS(最长公共子序列)动态规划,输出 unified diff 格式变更块。零依赖,与 dsh-diff-writer 组成找差-修复闭环。

安装

npm install dsh-text-diff

cordis.patch.yml 已随包声明,dsh 宿主加载后自动注册 diff_text。

工具

diff_text — 行级 diff

参数类型说明
a_text / a_filestring文本或文件路径(A 侧,二选一)
b_text / b_filestring文本或文件路径(B 侧,二选一)
contextnumber每个变更块的上下文行数(默认 3,0 只显示变更行,上限 50)
diff_text { a_file: "a.js", b_file: "b.js" }
diff_text { a_text: "old code...", b_text: "new code..." }

输出格式:

diff: +1 -2(8 行未变,1 个变更块,上下文 1 行)

@@ -3,3 +3,2 @@
 keep2
-old-a
-old-b
+new-a
 keep3

一致性时返回 两份内容完全一致(N 行)。;A/B 侧为空时另一侧全部记为 add/del。

约束

  • 输入文本上限 1MB,单行上限 3000 行(LCS 矩阵内存约 9MB)
  • 超长输出截断到 8000 字符并提示
  • CRLF/LF 已归一,跨平台比较无需预处理

与其他插件配合

  • 找差-修复闭环:diff_text 定位差异 → dsh-line-ops extract_lines 查看上下文 → dsh-diff-writer apply_patch 精确修复
  • A/B 均为大文件时复杂 diff 建议改用 git 本地 git diff(可通过 dsh-git-helper 触发)

测试

npm test

Roadmap(v0.2 候选)

  • 文件级别 diff(多文件批量对比)
  • --stat 概览模式(仅统计不显示内容)
  • 忽略空白差异(尾空格 / 前导缩进变化不算变更)
  • 移动检测(同一块被移走记为 move 而非 del+add)

Keywords

dsh

FAQs

Package last updated on 15 Sep 2026

Related posts