rea
morluto
Reverse engineer anything with agents, from app behavior down to native binaries.
PROJECT TOPICS
INSTALL REFERENCE
dsh plugin --profile web add github:Daneel0001/dsh-plugin-zh-cn
该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。
PROJECT README
把 DeepSeek Harness(DSH)已安装插件的显示名与描述,在启动时翻译成简体中文并缓存到本地。 翻译后端可以选:微软翻译免费接口(默认,不用账号、不用 Key)、任意 OpenAI 兼容 API,或 DSH 里的模型。
没有硬编码词典,也不碰 DOM。译文按 { en, zh } 投给 DSH 自己的 resolveText(),
所以在英文界面下显示结果与安装前逐字相同。
安装前 billion-context A context-compression plugin — small context windows…
安装后 十亿级上下文插件 小上下文窗口即可容纳超大仓库上下文
English:
dsh-plugin-zh-cnrenders installed DSH plugin titles and descriptions in Simplified Chinese. At startup it reads a local translation cache, projects{ en }plugin metadata into{ en, zh }so DSH's ownresolveText()renders Chinese, and translates any installed plugin the cache does not know yet — with the free Bing translator (default, no account or key), any OpenAI-compatible API, or DSH's built-inllmservice. No built-in dictionary, no DOM manipulation. See English summary.
| 界面语言 | 插件标题 | 插件描述 |
|---|---|---|
| 中文 | 中文标题 | 中文描述 |
| English / 其它 | 与安装前逐字相同 | 与安装前逐字相同 |
entry.enabled 与 pluginManager.setPluginEnabled,
和元数据毫无交集。zh 的插件(含全部官方内置插件)一律跳过,
一个字节都不改。已经自带中文的内置选项(「语音输入」「终端」……)自然不会被碰。ctx.effect 的清理回调原样撤销。在 DSH 桌面版的「插件」页点「添加插件」,填入本仓库地址:
github:Daneel0001/dsh-plugin-zh-cn
装好后 重启 Harness。客户端模块图是在渲染页面时写进 index.html 的,
仅刷新页面不会把新插件送进已打开的窗口。
# 1. 把 tgz 放进 profile 的 plugins 目录
Copy-Item .\dsh-plugin-zh-cn-<version>.tgz "$env:DSH_PROFILE_DIR\plugins\"
# 2. 在 <profile>/package.json 里登记两处
# dependencies: "dsh-plugin-zh-cn": "file:<profile>/plugins/dsh-plugin-zh-cn-<version>.tgz"
# dsh.profile.bundles: 追加 "dsh-plugin-zh-cn"
# 3. 用 pnpm 真正安装(这一步才会写入 lockfile 与 .modules.yaml)
node "$pnpm" install --dir "$env:DSH_PROFILE_DIR"
必须走第 3 步。 只把 tgz 放进
plugins/、再手工复制目录到node_modules/是不够的: DSH 组合 profile 时以 pnpm 的安装结果为依据,未进入pnpm-lock.yaml/node_modules/.modules.yaml的包会被静默跳过。
换了插件版本之后必须重启 DSH。 实测在运行中的实例里用「禁用 → 启用」热重载插件,不会让 Node 重新加载模块(ESM 模块缓存命中),跑的还是旧代码;只有重启 Harness 才会真正换版本。
local-cache.json 交给 seedFiles
(格式见 examples/local-cache.example.json)。DSH 的插件列表渲染链是(均为 app.asar 内官方源码):
客户端 UI 组件 PluginInventorySettingsTab
└─ ctx.remote.pluginInventory.list() dsh-client-ui-settings-plugin-inventory/lib/client.js
└─ 宿主服务 pluginInventory.list() dsh-host-plugin-inventory/lib/index.js
└─ readPluginInventory(ctx)
├─ ctx.loader.entries() ← 「已安装」的插件行
└─ ctx.get('pluginPackages').metaOf(name, base) → { title, description }
而屏幕上真正出现的文字,只在客户端这一个出口被解析:
// dsh-client-locale/lib/client.js
resolveText(text) {
if (typeof text === 'string') return text;
return this.fallbackChain(this.snapshot.active)
.reduceRight((resolved, locale) => text[localeKey(locale)] ?? resolved, text.en);
}
LocalizedText = string | { en: string, [locale]: string } —— 中文界面取 zh,英文界面取 en。
这正是官方内置插件显示「智能体团队」而英文界面仍显示原文的机制。
所以本插件只做一件事:在数据层把 meta.title / meta.description 从 { en } 补成 { en, zh }。
包装两处返回值,任一生效即可:
| 目标 | 位置 | 说明 |
|---|---|---|
pluginPackages.metaOf |
dsh-app-boot 的 cordis Service |
readPluginInventory 的直接取数处 |
pluginInventory.list |
dsh-host-plugin-inventory 的 Remote 网关 |
界面调用的入口,兜底 |
事后补救。React 每次重渲染都会把改过的文本节点覆盖回去,需要持续对抗; 而且一旦插件的元数据或 DOM 结构稍有变化就容易误伤布局。 数据层注入则从根上解决问题:DOM 从头到尾就没有被改过,中文是 DSH 自己渲染出来的。
运行时缓存位置(原子写入:先写 .tmp 再 rename):
<DSH_PROFILE_DIR>/dsh-plugin-zh-cn/local-cache.json
# 例如 C:\Users\<你>\.dsh\profiles\desktop\dsh-plugin-zh-cn\local-cache.json
{
"version": 2,
"generator": "dsh-plugin-zh-cn",
"updatedAt": "2026-10-16T10:43:30.000Z",
"entries": {
"billion-context": {
"en": { "title": "billion-context", "description": "A context-compression plugin — …" },
"zh": { "title": "十亿级上下文插件", "description": "小上下文窗口即可…" },
"model": "deepseek/deepseek-chat",
"translatedAt": "2026-10-16T10:43:30.000Z"
}
}
}
en 是英文指纹,指纹没变就一个请求都不发,变了才重译。{ "<包名>": { "title": "…", "description": "…" } }
会被当作中文译文直接吸收,可以作为初值平滑迁移。local-cache.json 与 seedFiles 都是初值,
运行时缓存里的同键条目优先,绝不会被清空覆盖。backend 决定用哪个后端,默认 bing(微软翻译免费接口,不用账号、不用 Key):
| backend | 说明 | 需要的配置 |
|---|---|---|
bing(默认) |
微软翻译免费网页接口(cn.bing.com) |
无 |
api |
任意 OpenAI 兼容接口 | apiBaseUrl + apiKey + apiModel |
llm |
DeepSeek 账号:用「设置 → 模型」里选中的模型 | 无 |
bing 把名称与描述分成两次请求直接拿到译文(不需要提示词);api / llm 一次请求
同时把两者交给模型,要求它只回一个 JSON:
系统提示词(要点)
只输出 {"name":"<中文名称>","desc":"<中文描述>"},不要解释、不要 Markdown 围栏
名称 ≤ 12 个汉字;描述 ≤ 40 个汉字、一句话
API / Token / MCP / SSH / Git / JSON / LLM 等专有名词照抄不译
拿到译文后会先校验再落盘:api / llm 必须能解析出 JSON,且译文必须真的含中文;
bing 直接取返回文本。不满足就当失败,保留英文原文。
插件导出 Config(Schemastery schema)用于校验配置;2.2.0 起还带浏览器侧卡片,
在「设置 → 插件」→ dsh-plugin-zh-cn 的详情页里选翻译后端
(保存会写回 profile 的 cordis.patch.yml,下一轮启动生效)。
卡片上是三行:
| 行 | 可改的字段 |
|---|---|
| 微软翻译 | 翻译页地址(一般不用改) |
| 自定义 API | Base URL / API Key / 模型名 |
| DeepSeek 账号 | 没有字段 —— 直接用「设置 → 模型」里选中的模型 |
其余字段也可以直接写进 profile 的 cordis.patch.yml:
- id: zh-cn-plugin-locale
name: dsh-plugin-zh-cn
config:
enabled: true # 总开关
strict: true # 名称+描述都有译文才写入缓存
backend: bing # bing(微软翻译,免费)| api(OpenAI 兼容)| llm(DSH 里的模型)
bingEndpoint: '' # 留空 = https://cn.bing.com
apiBaseUrl: '' # 留空 = https://api.deepseek.com/v1(含 /v1)
apiKey: '' # backend: api 时必填
apiModel: '' # 留空 = deepseek-chat
timeoutMs: 60000 # 单条翻译超时(描述很长的插件要给足时间)
maxTokens: 4096 # 单条翻译输出上限(仅 api / llm 用)
provider: '' # 兼容旧配置,卡片已不暴露;llm 后端留空 = 跟随「设置 → 模型」
model: '' # 同上
fallbackToAccount: true # 同上;llm 后端本身就是账号渠道,默认开启
retryDelayMs: 180000 # 仅 backend: llm;没等到可用模型/服务时,隔多久自动重试一轮(毫秒)
cacheFile: '' # 留空 = <profile>/dsh-plugin-zh-cn/local-cache.json
seedFiles: [] # 额外的缓存初值(绝对路径),只合并、不覆盖
maxPerStart: 500 # 每次启动最多新翻几个插件(默认实质上不限,一个全新 profile 也就几百条)
delayMs: 200 # 两条翻译之间的间隔
saveEvery: 8 # 每翻译成功几条落一次盘,中途退出不丢已完成的部分
retry: 3 # 每条最多尝试几次(设为 1 即关闭重试)
debug: false # 把每条翻译结果写进 debug 日志
模型解析顺序(仅 backend: "llm" 时适用;前一个拿不到才用下一个):
provider + model(显式指定);fallbackToAccount: true(默认)时,回退到 DSH 账号渠道的 deepseek-account/deepseek-flash。注意:DSH 账号渠道只对自己允许的目的地签发 token(resolveToken(endpoint)),
插件发起的请求可能得到 ACCOUNT_SIGN_IN_REQUIRED(实测 dsh-kb-lite 必失败)。
遇到这种情况改用默认的 backend: "bing" 或 backend: "api" 即可。
fallbackToAccount 是 2.1.0 加的:以前启动早期读不到默认模型,整轮翻译会一条都不翻(缓存里的
lastRun 停在 model: "(未就绪)"、translated: 0)。现在第 3 级兜底保证能翻;实在没模型时,
插件会按 retryDelayMs 自动重试,不再「本轮放弃、等下辈子启动」。
package.json;不写入任何其它插件的目录。local-cache.json(及其 .tmp),位置就在插件自己的数据目录。bing → cn.bing.com(可用 bingEndpoint 换地址);
api → apiBaseUrl;llm → DSH 自己的模型调用。不执行外部命令。configForms / configEditor,
由 DSH 写进 cordis.patch.yml;插件自己只写 local-cache.json。warn 日志,不会影响 DSH 启动。在插件设置里关掉「插件简体中文化」,然后重启。
注入层随插件 fiber 一起卸载(ctx.effect 清理回调会还原被包装的两个方法)。
运行时缓存 local-cache.json 会留在 profile 里,想彻底清干净就手动删掉
<DSH_PROFILE_DIR>/dsh-plugin-zh-cn/ 目录。
npm run check # 静态自检:清单、语法、可导入性,以及「不许硬编码词典」
npm run check:syntax # 只做语法检查
npm test # 60 项验收测试(含 8 项 apply 集成测试)
npm test 零依赖,在源码目录里就能跑完 60 项(含 8 项 apply 端到端集成测试)。
测试全部在系统临时目录里工作,永远不会碰真实 profile。
导出:apply、resolveConfig、DEFAULTS、inject、name,以及供测试使用的纯函数
resolveCacheFile、nearestProfileDir、collectInstalledPlugins、
extractEnglish、alreadyLocalized、resolveSelection、runTranslationPass。
lib/index.js 插件入口:读缓存 → 装注入 → 异步扫描翻译
lib/client.js 浏览器侧:插件详情页的「翻译模型」卡片(卡片行 + 编辑,2.2.0+)
lib/inject.js 数据层注入:包装 metaOf / pluginInventory.list(实例 + 原型,动态 this)
lib/cache.js local-cache.json 的读取、合并、原子写
lib/translate.js 三种后端:Bing 免费翻译 / OpenAI 兼容 API / DSH llm;提示词、JSON 解析与中文校验
lib/text.js LocalizedText 工具与「值不值得翻译」的判定
locale/*.json 本插件自身的语言字典(自举)
cordis.patch.yml bundle 补丁:把插件行插进组合配置树
test/acceptance.mjs 60 项验收测试(另有 1 项按环境跳过)
scripts/check.mjs 静态自检(CI / prepack)
examples/ local-cache.json 格式示例
dsh-plugin-zh-cn renders the titles and descriptions of installed DSH plugins in
Simplified Chinese.
At startup the host half:
<profile>/dsh-plugin-zh-cn/local-cache.json synchronously, so the first render
already has Chinese for everything it has seen before;pluginPackages.metaOf and pluginInventory.list — the exact functions the
settings UI reads plugin metadata through — projecting { en } into { en, zh }.
DSH's own resolveText() then renders Chinese on a Chinese UI and the original English
everywhere else. No DOM node, class, style, or the enable/disable toggle is touched.backend):
bing (default — the free Bing translator endpoint, no account or API key),
api (any OpenAI-compatible endpoint: apiBaseUrl + apiKey + apiModel), or
llm (DSH's built-in llm service, default model from agentDefaultModel).
api / llm send name and description in one request and expect
{"name": …, "desc": …}; results are merged back into the cache.No built-in dictionary. The only network traffic is the translation request itself
(cn.bing.com, your apiBaseUrl, or DSH's own model route). Any failure — timeout, bad
JSON, non-Chinese output, network or model error — leaves the English original in place and
logs a warning.
CLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: deepseek-harness。