Sessions & Messages

deepseek-harness-translation

nanbujiwanfeng/deepseek-harness-translation · ★ 1

nanbujiwanfeng

Bidirectional Chinese↔English conversation translation for deepseek-harness: Chinese-speaking users converse in Chinese, each message is auto-translated to English for the agent, and English replies return as Chinese with bilingual rows in the Web Client.

README body is shown in Chinese.

License
MIT
Added
2026-08-16
Maintenance
active
Install kind
github
Manifest details
Manifest status
Not verified
Manifest path
-
Manifest checked
2026-08-19
Lifecycle scripts
None found

Static manifest checks report declarations only; they are not compatibility or security review.

安装

dsh plugin --profile web add github:nanbujiwanfeng/deepseek-harness-translation

GitHub 源码安装:首次需按提示配置 allowBuilds 构建授权后重试

For install and environment setup, plus plugin development tutorials, see DSH community docs ↗

README

Source README · body: zh · Read Chinese README

Table of contents
  1. 目录结构
  2. 前置要求
  3. 版本对应
  4. 安装(首次)
  5. 更新同步
  6. 手动安装(不用脚本)
  7. 配置项
  8. 验证
  9. 升级 harness 注意
  10. 常见问题
  11. 许可

deepseek-harness 的对话翻译插件(面向中国用户):用户用中文对话,插件自动把中文翻译成英文交给 agent 执行;agent 的英文回复自动回译成中文显示。页面同时展示「原文(中文)」和「中文翻译」双语行。

目录结构

路径 说明
packages/session/conversation-translator/ 宿主插件:翻译管线(zh2en 改写、双语记录、en2zh 回译、失败兜底)
packages/client/ui-translation/ 客户端插件:页面双语行渲染
examples/web-cordis/translator.cordis.yml 启用配置(--patch overlay)
apps/web/tests/translation-rows.e2e.ts 端到端测试:双语行渲染(可选)
apps/web/tests/translation-long-text.e2e.ts 端到端测试:长文本分块翻译(可选)
harness-integration.patch 对 harness 的接线改动(tsconfig、bundle 清单等)
sync-to-harness.mjs 一键安装/同步脚本
start-dsh-translation.bat / .mjs Windows 一键启动脚本(同步时拷入 harness 根目录)

前置要求

  • deepseek-harness 源码 checkout,版本锁定 commit 47f943859b(v0.1.0-rc.5)
  • Node.js 20+、pnpm
  • 可用的 DeepSeek API 配置(翻译会真实调用模型,消耗你自己的配额;不额外指定时直接复用 agent 的 provider/model 路由)

版本对应

每个版本锁定的 harness commit 见下表,升级 harness 前先确认有对应版本:

插件 tag 适配 harness commit 说明
v0.1.0-rc.5 47f943859b(v0.1.0-rc.5) 首个发布

详见 CHANGELOG.md。

安装(首次)

克隆插件仓库(国内网络走镜像):

git clone https://github.com/nanbujiwanfeng/deepseek-harness-translation.git
# 国内网络:
git clone https://ghfast.top/https://github.com/nanbujiwanfeng/deepseek-harness-translation.git

在任意目录执行(harness 仓库路径换成你自己的):

node <本仓库路径>/sync-to-harness.mjs <harness 仓库路径>
cd <harness 仓库路径>
pnpm install
npm run build
npm run dsh -- web --patch examples/web-cordis/translator.cordis.yml

打开 http://127.0.0.1:3080 ,用中文对话即可。用户消息旁会显示「原文(中文)」行,agent 回复下方会显示「中文翻译」行。

Windows 用户也可以直接双击同步进 harness 根目录的 start-dsh-translation.bat 一键启动:自动处理端口占用、构建过期,并自动带上 --patch 参数和校验插件加载(macOS/Linux 仍用上面的命令行)。

更新同步

插件作者推送更新后:

git pull                                    # 拉取插件仓库更新
node sync-to-harness.mjs <harness 仓库路径>  # 重跑同步(幂等,可放心重复执行)
pnpm install && npm run build

手动安装(不用脚本)

  1. 把 packages/session/conversation-translator、packages/client/ui-translation 拷进 harness 仓库对应目录
  2. 把 examples/web-cordis/translator.cordis.yml 拷到对应位置
  3. 把 apps/web/tests/translation-rows.e2e.ts 拷到对应位置
  4. 在 harness 仓库根目录执行 git apply <本仓库路径>/harness-integration.patch
  5. pnpm install && npm run build

配置项

见 examples/web-cordis/translator.cordis.yml 中的注释。所有字段都有默认值:

字段 默认 含义
enabled true 双向翻译总开关
provider / model 空 留空 = 复用 agent 自己的模型路由;成对填写可指定独立翻译模型
timeoutMs 30000 单次翻译调用的超时
maxTokens 4096 单次翻译的输出 token 上限
temperature 0.1 翻译是客观任务,默认低温度保证确定性

翻译失败不影响主流程:原始消息照常交给 agent 执行,控制台只打 warning。

验证

# 宿主单元测试(28 个用例)
npx vitest run packages/session/conversation-translator/tests/translator.spec.ts

# 浏览器端到端测试(可选,需要 Playwright;未下载浏览器时可用系统 Edge)
DSH_PLAYWRIGHT_EXECUTABLE_PATH="C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe" \
  npx vitest run --config vitest.web.config.ts apps/web/tests/translation-rows.e2e.ts

升级 harness 注意

harness-integration.patch 基于 commit 47f943859b 生成。如果之后升级 harness 本身,补丁可能冲突失效,需要插件作者针对新版本重新生成补丁(插件源码部分不受影响)。

常见问题

  • 翻译没触发:用户消息需含中文字符才会翻译;纯英文消息直接放行(本来就无需翻译)。
  • 端口被占:默认 3080,被占用时参考 harness 文档指定其他端口(--patch 一个覆盖 webserver.port 的 yml 即可)。
  • 想要关闭某一方向:删掉 translator.cordis.yml 里对应的那一行 insert 即可(宿主行关翻译管线,客户端行关页面展示)。
  • 启动报 duplicate loader entry id: conversation-translator:说明这个 harness checkout 的 packages/bundle/web-app/cordis.patch.yml 里已经内置了插件行(比如自己 fork 提交过),此时不要加 --patch,直接 dsh web 即可;本集成补丁本身不会往 bundle 里加行,标准 checkout 一律用 --patch 激活。
  • 对已集成的 fork 重跑同步:sync-to-harness.mjs 会先做补丁反向检查,接线已提交时自动跳过 git apply,只覆盖插件文件,随后 pnpm install && npm run build 即可。
  • npm 安装的 dsh(npx @deepseek-ai/dsh)能用吗:暂不支持。本插件面向源码 checkout 用户(同步脚本需要仓库目录来打接线补丁),npm 发布版没有源码目录;待 harness 提供 npm 插件安装机制后再适配。

许可

MIT(基于 deepseek-harness,Copyright (c) 2026 DeepSeek)。