
Security News
PHP Foundation Says Chainguard Broke Security Embargo Ahead of Emergency Patches
The PHP Foundation says Chainguard broke a security embargo ahead of critical RCE patches, as leaks disrupted the coordinated release.
dsh-diff-writer
Advanced tools
Precise file editing for DeepSeek Harness: apply search/replace patches to files instead of full-file rewrites, minimizing accidental changes.
精确文件编辑插件(v0.2.1):用 search/replace 补丁和行号模式补丁修改文件,避免整文件覆盖带来的误改风险。与 dsh-file-manager-cli(整体读写)和 dsh-git-helper(提交)形成互补的文件工作流。
npm install dsh-diff-writer
import { apply_patch } from "./index.js"
// 示例:修改配置文件中的特定值
await apply_patch({
path: "config.json",
patches: [
{
search: '"debug": false',
replace: '"debug": true',
all: true
},
{
search: '"port": 3000',
replace: '"port": 8080'
}
]
})
// 示例:使用行号范围删除和插入
await apply_patch({
path: "README.md",
patches: [
{
startLine: 10,
endLine: 15,
replace: "" // 删除第 10-15 行
},
{
startLine: 20,
endLine: 20,
replace: "# 新增内容\n" // 在第 20 行前插入
}
]
})
// 示例:创建新文件
await apply_patch({
path: "new-file.js",
create: true,
patches: [
{
search: "",
replace: "console.log('Hello World!')"
}
]
})
apply_patch对目标文件按顺序应用一组补丁,支持两种补丁模式。
| 参数 | 类型 | 说明 |
|---|---|---|
path | string | 必填,目标文件路径(相对或绝对,必须在工作目录内) |
patches | array | 必填,补丁列表,按顺序应用 |
create | boolean | 可选,文件不存在时创建新文件(此时 patches 可为空) |
{
search: "要匹配的内容",
replace: "替换后的内容",
all?: false // 可选,默认 false,仅替换唯一匹配处
}
{
startLine: 10, // 起始行号(1 基)
endLine: 20, // 结束行号(包含)
replace: "替换内容" // 空字符串表示删除该行范围
}
匹配规则:
search 必须与文件内容精确匹配(含缩进与换行)all: true 时全量替换所有匹配search 不允许;空 replace 表示删除安全边界:
create=true 不能用于已存在的文件A: 补丁失败时会立即中止执行,失败的补丁之前的修改已经写入文件(不自动回滚)。你需要根据错误信息修复问题后重试整个操作。建议在非生产环境或使用版本控制操作。
A: 精确匹配确保不会意外修改相似但不完全相同的内容,避免产生误改。如果需要模糊匹配,可以扩展搜索内容包含更多上下文使其唯一。
A: 有两种方式:
all: true 参数替换所有匹配处(需谨慎使用)A: 行号模式适用于:
搜索模式适用于:
A:
{ startLine, endLine, replace }create=true 且 patches=[])npm test
覆盖所有核心功能:
cd dsh-diff-writer
npm install
npm test
package.json 中的版本号npm test 确保测试通过npm publishFAQs
Precise file editing for DeepSeek Harness: apply search/replace patches to files instead of full-file rewrites, minimizing accidental changes.
The npm package dsh-diff-writer receives a total of 10 weekly downloads. As such, dsh-diff-writer popularity was classified as not popular.
We found that dsh-diff-writer demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.

Security News
The PHP Foundation says Chainguard broke a security embargo ahead of critical RCE patches, as leaks disrupted the coordinated release.

Security News
PHP releases emergency patches for two critical RCE vulnerabilities as agencies urge organizations to take unpatched sites offline.

Threat Research
/Security News
A supply chain attack compromised LiteLLM 1.107.0 on PyPI and Docker, spreading malware that steals cloud credentials, developer secrets, and AI provider keys.