dsh-patch-library
DiscoveredOfficial DSH core patches as data: ten self-contained patches plus an adaptive applier (locates the install path on its own, backs up each one, performs syntax checks, and offers one-click rollback), five ways to apply, zero hardcoded paths. DSH 1.5 only, with updates to follow.
dsh-patch-library
The official DSH core patches, as data — and five ways to apply them.
官方 DSH 内核补丁的数据化版本 —— 10 条补丁,5 种打法。
Ten self-contained patches for @deepseek-ai/dsh-* and @earendil-works/pi-ai, plus a small
applier that finds your DSH installation by itself. No hard-coded paths, no personal information
anywhere in this repository, no network access required.
十条自成体系的补丁,覆盖 @deepseek-ai/dsh-* 与 @earendil-works/pi-ai;配一个小巧的应用器,
它会自己找到你的 DSH 安装位置。零硬编码路径、仓库里没有任何个人信息、全程不需要联网。
🌐 中文完整说明(推荐中文读者从这里开始) → README.zh-CN.md
中文读者还应该看这两份:
教程-安装与官方补丁里的补丁库章节 与 给 agent 的中文提示词。
Built for
@deepseek-ai/dsh0.1.5-rc.2 (the 1.5 line). Every patch records the exact sha256 of both the file it expects and the file it produces, so the applier can tell youexact/applied/conflictbefore it touches anything.
Why this repository exists
Some fixes cannot be shipped as a plugin: they have to run inside an official file, in the middle
of a function that Cordis does not expose as a seam. Four of those fixes were already published as
plugins (dsh-context-reclaim, dsh-capability-composer, dsh-composer-launcher,
dsh-aux-degrade). The rest — plus the ones that only matter if you want the full set — live here,
as ordinary unified diffs that anyone can read, review, apply, revert, or regenerate.
Nothing here is a binary blob and nothing here is magic: patches/<id>/change.diff is a normal
patch, and manifest.json is the metadata that lets a script apply it safely and reversibly.
The ten patches
| id | package → file | kind | size | restart | already handled by a plugin? |
|---|---|---|---|---|---|
dsh-llm-writable-request | @deepseek-ai/dsh-llm → lib/index.js | lines | +18 −1 | yes | yes — dsh-context-reclaim |
agent-loop-snapshot-prompt | @deepseek-ai/dsh-agent-loop → lib/index.js | lines | +97 −20 | yes | no |
llm-pi-ai-system-prompt | @deepseek-ai/dsh-llm-pi-ai → lib/index.js | lines | +96 −54 | yes | no |
compaction-pruner | @deepseek-ai/dsh-compaction-tool-result-pruner → lib/index.js | lines | +354 −14 | yes | no |
ui-renderer-turntail | @deepseek-ai/dsh-client-ui-renderer → lib/client.js | lines | +9 −1 | no | no |
ui-sidebar-wrap | @deepseek-ai/dsh-client-ui-sidebar → lib/lib-client.js | regex | +1 −1 | no | no |
session-format-v1-to-v2 | @deepseek-ai/dsh-session-format-v1-to-v2 → lib/index.js | lines | +2 −1 | yes | no |
session-persistence-jsonl | @deepseek-ai/dsh-session-persistence-jsonl → lib/worker.cjs | lines | +2 −1 | yes | no |
mcp-client | @deepseek-ai/dsh-mcp-client → lib/index.js | lines | +59 −6 | yes | no |
pi-ai-max-tokens-floor | @earendil-works/pi-ai → dist/api/simple-options.js | lines | +11 −1 | yes | no |
Every patch has its own patches/<id>/NOTES.md with what it changes, when you want it, how to
verify it, and what to do if it does not fit your build — in English and Chinese.
ui-sidebar-wrap is a regex patch on purpose: the sidebar's class prefix is a build hash, so a
line diff would be invalidated by any rebuild. patches/<id>/change.json stores the pattern and its
explicit inverse.
Five ways to apply them
Pick whichever matches how you like to work. All five are documented step by step in
docs/methods.md (Chinese: docs/methods.zh-CN.md).
| method | command | |
|---|---|---|
| A | script (recommended) | node apply.mjs --check then node apply.mjs --apply --all |
| B | git apply | cd <pkg dir> && git apply -p1 <library>/patches/<id>/change.diff |
| C | your own AI agent | paste the block from PROMPT.md and let it do A or B for you |
| D | regenerate for your build | node tools/make-patch.mjs --file <patched> --orig <pristine> --pkg <pkg> --rel <rel> |
| E | revert | node apply.mjs --revert --all, or restore any *.orig by hand |
All ten diffs were verified with git apply -p1 --check inside the package directory, so method B
works on every one of them.
Method A in full
node apply.mjs --list # what is in here
node apply.mjs --roots # which DSH installations were found on this machine
node apply.mjs --check # per-file state: exact / applied / conflict / missing
node apply.mjs --apply --all # apply everything that fits
node apply.mjs --apply --only mcp-client,compaction-pruner
node apply.mjs --revert --all # put every .orig backup back
--check reports one of:
| state | meaning |
|---|---|
exact | the file is the pristine version this library was built from — applying is safe |
applied | the file already equals the patched version, nothing to do |
variant | same version, different build (hash differs) but the hunks still fit — needs --allow-variant, or method D |
conflict | the hunks do not fit. Nothing is written. Use method D to regenerate for your build |
missing | that package is not part of the installation that was found |
What the applier guarantees
- It finds your installation, it does not assume one.
--root,$DSH_APP_ROOT,$DSH_INSTALL_ROOT,$DSH_HOME(includingprofiles/*), the running process's own DSH path, anoderesolution from the current directory, and a bounded scan of the usual install locations for Windows / macOS / Linux — seelib/discover.mjs.--rootmeans exactly that root, never that root plus whatever else was found. .origis sacred. A backup is written once, next to the file, and never overwritten. If a.origalready exists, it is reused.- Every edit is syntax-checked.
node --checkruns after each write; on failure the backup is restored immediately and the patch is reported as failed. - A hunk that does not fit is a conflict, never a guess. The engine matches a hunk's old side exactly, exactly once, near the position it was recorded at.
- It only writes inside the resolved root. Nothing under
$DSH_HOMEis touched except, if you explicitly point--rootat a profile directory, that profile's ownnode_modulescopy of a package.
Exit codes: 0 success, 1 a requested action failed or conflicted, 2 no installation found.
If you already run the four DSH plugins
You can skip dsh-llm-writable-request — dsh-context-reclaim takes over that path from inside the
plugin, with the official patch reverted. --check says so explicitly:
= dsh-llm-writable-request already node_modules/@deepseek-ai/dsh-llm/lib/index.js
not needed: the dsh-context-reclaim plugin already handles this
The other nine are independent of the plugins: install neither, one, or both.
Self-test
node verify.mjs
Offline, no DSH installation required. It checks that every diff parses and its hunk counts agree, that the declared marker really is added by its patch, that the apply/revert engine round-trips on synthetic samples, that a duplicated context is rejected instead of guessed, that the regex patch round-trips through any class prefix — and that no file in this repository contains a drive letter, a personal home directory or a private workspace name (that scan is part of the test suite, not a promise).
verify.mjs finishes with a read-only --check summary of whatever installation it finds.
Repository layout
apply.mjs the applier: --list --roots --check --apply --revert --show
verify.mjs offline self-test + personal-information scan
manifest.json every patch's metadata: hashes, sizes, markers, risk, why, applyWhen
lib/manifest.mjs manifest loading and schema checks
lib/discover.mjs finds DSH installations (fully adaptive, platform-aware)
lib/unified.mjs unified-diff parse / apply / revert engine
lib/backup.mjs .orig backup and restore
lib/hash.mjs sha256 helpers
patches/<id>/change.diff the patch itself (package-relative paths)
patches/<id>/change.json regex patches: pattern + explicit inverse
patches/<id>/NOTES.md what / when / verify, in English and Chinese
tools/make-patch.mjs regenerate a patch for a different build of the same version
docs/methods.md the five methods, step by step
PROMPT.md copy-paste block for your own agent
Honest boundaries
- These patches are built against 0.1.5-rc.2.
--checkwill tell you if your build differs (variant/conflict) — that is information, not a failure. Method D exists for that case. - Applying a patch edits files under your DSH installation. That is what a patch is. The applier
keeps a
.origof every file it touches, and--revertputs them back. Uninstalling or updating DSH replaces the whole tree and therefore removes the patches. restartRequiredin the manifest tells you whether the affected code runs in the main process (restart DSH) or in the renderer (reload the window is enough).- The patches are the fixes; they are not a security review of DSH. Read
patches/<id>/change.diffbefore you apply it — that option is the whole point of shipping them as data.
License
MIT. Upstream packages remain the property of their authors; this repository only contains diffs against them.
Comments
Loading…
Similar plugins
by fazhu4
DSH plugin manager: official/community grouped plugin list with localized descriptions, one-click enable/disable and uninstall, plus a GitHub dsh-plugin market tab.
★ 4
↓ 262/wk
MIT
TypeScript
Aug 18, 2026
dsh plugin --profile web add dsh-plugin-studioby ymh0000123
DeepSeek Harness 插件:检测 DSH / @deepseek-ai npm 包与 GitHub 源插件的更新,设置页给出详细表格,并支持带显式构建授权的一键更新。A DSH plugin that detects updates for installed DSH/@deepseek-ai npm packages and GitHub-sourced plugins, with
★ 0
MIT
JavaScript
Aug 17, 2026
dsh plugin --profile web add dsh-update-checkerby fakechris
DSH 运维工具箱:升级、重启、故障都不用操心。① 官方每日快照 A/B 双槽轮换——旧插件迁移+构建+验收全过才原子切换,一键回滚,旧版本永远兜底;② 守护 10s 自动拉起 web + agent 断点自动续接,重启无人值守;③ web 全挂(A/B 都坏、agent 不可用)时 dsh-doctor 一条命令自救:九项诊断→机械修复配置→LLM 深度检测修复(完整推理实时可见)→拉起 web
★ 15
↓ 44/wk
MIT
Python
Sep 18, 2026
dsh plugin --profile agent add @fakechris/dsh-restart-recoverby Luaphes
DSH的插件创意市场来啦!~~~欢迎使用&提供反馈!!DSH 插件创意市场 · DeepSeek Harness 插件发现与一键安装面板 全量嗅探官方 dsh-plugin topic(900+),过滤蹭标签噪音,保留人工精选标记; 支持总星数/最新发布/最近推送排序、即时搜索、语言过滤; 点安装先校验 dsh.bundle 声明,装不了的一律拒绝。零依赖零构建,装进 Web UI 的 Plugi
★ 3
↓ 48/wk
MIT
JavaScript
Oct 14, 2026
dsh plugin --profile web add dsh-plugins-marketby 2BingLing
DeepSeek Harness 插件市场 · 持续收录 6000+ DSH 插件:中文搜索 + 实用五维评分 + 一键安装。Web 版与 DSH 侧边栏插件双形态。Plugin marketplace for DeepSeek Harness: 6000+ plugins, Chinese search, 5-dim scoring, one-click install.
★ 151
↓ 2.4k/wk
NOASSERTION
TypeScript
Oct 14, 2026
dsh plugin --profile web add @dsh-market/pluginby Hope-Phenom
DSH 插件:给 `/` 菜单加上 /simplify(不改行为的清理)与 /code-review(多角度找 bug + 独立验证,/review 为别名),适配 DSH 的工具、指令文件布局与 subagent 模型。|A DSH plugin adding /simplify and /code-review (alias /review) to the `/` menu.
★ 0
MIT
JavaScript
Oct 9, 2026
dsh plugin --profile web add @hope_phenom/dsh-plugin-code-quality