maxwell-feng/dsh-windows-ocr ↗★ 2
windows-ocr
dsh plugin: recognize attached images with the built-in Windows OCR engine (Windows.Media.Ocr) and send only the recognized text to the model — image bytes never leave the machine.
安装
npx -p @deepseek-ai/dsh dsh plugin --profile web add github:maxwell-feng/dsh-windows-ocr说明文档
阅读完整 README ↗windows-ocr
一个 DeepSeek Harness(dsh)插件:让纯文本模型也能"看"附件图片——图片在本机用 Windows 自带 OCR 引擎(Windows.Media.Ocr)识别,只有识别出的文字会发给模型 API。图片字节永远不会离开你的电脑。
- 不需要改任何模型配置——不用在
settings.yaml里给模型加input: [text, image]。 - 对 dsh 里的任何 provider/模型通用;OCR 只作用于文本模型。
- 真正的视觉模型(本身声明支持图片)默认原样透传图片,不受影响。
- 默认安全(fail-closed):插件没加载时,模型保持纯文本,图片附件会被拒绝——不存在静默泄漏。
为什么是插件而不是 skill
dsh 的 skill 只是注入模型上下文的 Markdown 指令:不能执行代码、不能钩住请求管线、更拦不住图片被序列化上传。这个功能恰好需要这些,所以它是一个 cordis 插件,钩住 llm 服务的两个公开接缝:
- 能力声明(shim)——包装
ctx.llm.resolveModelInfo(以及listModels)。宿主在三处用inputModalities.includes("image")拦截图片:发送准入、切换模型、read_image工具。shim 让回答变成"支持",文本模型即可收图。 - 请求改写——包装
registration.adapter.stream(ctx.llm.stream和prepareCall().stream两条路径的唯一汇聚点)。适配器序列化请求前,所有image内容块已被替换成 OCR 文本块,适配器的图片检查永远不会触发,附件字节不会为出站请求被读取,也永远不会生成image_url。
你附加图片
→ 准入层问 ctx.llm.resolveModelInfo(shim 返回含 "image" ✓)
→ 图片存入本地附件库(会话日志、UI 预览)
→ agent 组装请求 → adapter.stream(被包装)
→ 本地读取图片字节(ctx.attachments.readImage)→ Windows OCR
→ 图片块替换为 …识别文字…
→ 适配器序列化纯文本请求 → 发给服务商
环境要求
- Windows 10/11(自带 Windows PowerShell 5.1,无需安装任何东西)
- 你所用语言对应的 OCR 语言包(设置 → 时间和语言 → 语言)。英文一般自带;中文需要安装中文语言包(含 OCR 能力)。
- 已安装
dsh及 profile(在 dsh0.1.0-rc.6上验证)
安装
安装
两种官方加载方式,patch 行都用绝对路径指向插件文件(见 docs/user/develop/basic)。Windows 上路径必须是 file:// URL——裸写 C:/... 会被解析成 c: URL scheme 而被 loader 拒绝。
永久安装:profile 补丁层
在 profile 的 cordis.patch.yml(如 ~/.dsh/profiles/web/cordis.patch.yml)追加:
- insert:
- id: windows-ocr
name: 'file:///C:/绝对路径/windows-ocr/lib/index.js'
config:
language: ''
passthrough: true
然后重启 dsh web。删掉这几行即卸载,不残留任何东西。
临时加载:--patch overlay
把同样的行写进一个 overlay 文件,启动时带上;profile 保持不动:
dsh --profile web --patch C:/path/to/overlay.yml