Back to home@xby-skill

dsh-ocr-plugin

No description

Stars
0
Language
TypeScript
Created
Aug 26, 2026
Updated
Aug 26, 2026
GitHub repo

Introduction

dsh-ocr-plugin

DeepSeek Harness (DSH) 的 OCR 插件,为纯文本模型提供图片文字识别能力。

基于 小笨羊 OCR API,支持图片 URL、Base64 编码、本地文件路径三种输入方式。

功能

  • set_ocr_api_key — 在聊天中设置 API 密钥(自动持久化,重启有效)
  • ocr — 通过图片 URL 识别文字
  • ocr_for_data_base64 — 通过 Base64 编码识别文字
  • ocr_for_data_file — 通过本地文件路径识别文字

安装

方式一:从 GitHub 直接安装(推荐)

# 格式: dsh plugin --profile <profile> add github:<owner>/<repo>
dsh plugin --profile web add github:your-github-username/dsh-ocr-plugin

your-github-username 替换为实际的 GitHub 用户名或组织名。

方式二:从本地目录安装(开发模式)

# 仅用于本地开发调试
dsh plugin --profile web add /absolute/path/to/dsh-ocr-plugin

方式三:通过 cordis.patch.yml 开发调试

dsh web --profile web --patch /absolute/path/to/dsh-ocr-plugin/cordis.patch.yml

使用

插件加载后,在聊天中直接对话:

  1. 设置 API 密钥(只需首次):

    "我的 OCR API 密钥是 xxxx"

    Agent 会自动调用 set_ocr_api_key 工具保存密钥,密钥持久化到 $DSH_HOME/storages/xby-apikey.json

  2. 识别图片文字

    "请识别这张图片中的文字:https://example.com/screenshot.png"

    或识别本地文件:

    "请识别 /Users/xxx/Documents/receipt.png 中的文字"

配置

获取 API 密钥

前往 小笨羊官网 注册并获取 API 密钥。

配置方式(可选,推荐用聊天方式设置)

环境变量

export XBY_APIKEY=your_api_key_here

Profile 级配置cordis.patch.yml 中):

- insert:
    - id: dsh-ocr-plugin
      name: 'dsh-ocr-plugin'
      config:
        apiKey: your_api_key_here
        baseUrl: https://mcp.xiaobenyang.com   # 可选
        timeoutMs: 30000                        # 可选

项目结构

dsh-ocr-plugin/
├── src/
│   ├── index.ts    # 主插件入口,注册 4 个工具
│   ├── config.ts   # 配置默认值(dict 形式,通用)
│   └── api.ts      # 通用 MCP API 客户端(callApi)
├── cordis.patch.yml    # DSH 安装入口(由 dsh.bundle.patch 引用)
├── package.json        # npm 包清单 + dsh 插件清单
├── tsconfig.json
├── LICENSE
└── README.md

发布到 GitHub

  1. 创建 GitHub 仓库 dsh-ocr-plugin
  2. 初始化 git 并推送:
cd dsh-ocr-plugin
git init
git add -A
git commit -m "Initial release: dsh-ocr-plugin v1.0.0"
git branch -M main
git remote add origin git@github.com:your-github-username/dsh-ocr-plugin.git
git push -u origin main
  1. 在 GitHub 上打 tag 发布(可选,让用户按版本安装):
git tag v1.0.0
git push origin v1.0.0

安装指定版本 / 分支

# 安装特定 tag
dsh plugin --profile web add github:your-github-username/dsh-ocr-plugin#v1.0.0

# 安装特定分支
dsh plugin --profile web add github:your-github-username/dsh-ocr-plugin#dev

License

MIT