dsh-tool-ocr: Extract text from images and PDFs in DSH

Introduction

Agents in DeepSeek Harness (DSH) can read text files, but they often have to “guess” when dealing with screenshots, scanned documents, tables taken with mobile phones, and PDFs without a copyable text layer. The community plugin dsh-tool-ocr (Maintainer: yuehancn, Category: Model Inference) bridges this gap: it reads the text layer directly for PDFs with one, and for scanned PDFs and images, it utilizes an OCR engine configured by you to return the extracted text in the tool call results. The plugin can be found in the SkillHub directory and on GitHub. It has no official affiliation with DeepSeek or Hyperbolic. In terms of ecosystem, it follows the “Everything is a Plugin” philosophy, and the directory site is an independent community platform.

The following section introduces the plugin’s positioning, capabilities, installation, and configuration. Facts are subject to the repository’s README and package.json. The README states that it was built and tested on dsh 0.2.0-rc.2 (preview); the apply(ctx) plugin specification is stable, but if you are using a newer version of dsh, please verify compatibility yourself.

What is this

dsh-tool-ocr is a custom tool plugin for DeepSeek Harness, responsible for Image OCR + PDF Text Extraction. The English brief is: Extract text from images and PDFs in DeepSeek Harness: read a born-digital text layer, or OCR a scan with any engine you configure.

The plugin itself runs only in Node and does not bundle Python OCR packages; external engines and poppler tools must be installed on your local machine as needed and declared in the configuration.

Core Features

How Input is Processed

Input Behavior
PDF with a text layer (e-contracts, exported reports, etc.) Reads the text layer, does not call OCR
Scanned / Image-based PDFs If the text layer is empty, rasterizes the page and calls OCR
Images (screenshots, photos, tables) Directly passed to the OCR engine

There are two key points: First, determine if it is an electronic PDF to avoid running OCR unnecessarily on electronic PDFs; The OCR engine is configured by you, allowing integration of tesseract, PaddleOCR, or internal command-line clients.

Two Tools

ocr_read

ocr_read(path, engine?, lang?, pages?, saveAs?)
  • path: Absolute path to the image or PDF
  • engine: Specifies the engine; if omitted, uses the default engine
  • lang: Language hint, e.g., chi_sim+eng
  • pages: PDF page range, e.g., 1-3 or 2,5
  • saveAs: Whether to save the extracted text to the configured output directory

Return fields include text, kind (image / pdf), the actual engine used, pages, textPath, and note (explaining which path was taken and any reminders). The note is provided for the Agent to judge the credibility of the result, rather than blindly adopting the full text.

ocr_status

Probes whether the locally configured engines are available (e.g., by executing --version) one by one and reports the current backend. The README suggests calling this before starting OCR to avoid wasted time on long-running tasks.

Installation and Activation

One-line installation (Command from the README, supports desktop and web profiles):

dsh plugin --profile desktop add github:yuehancn/dsh-tool-ocr

For the Web version, replace --profile desktop with web. Restart dsh after installation.

The version in package.json is 1.0.0, License is MIT, and it depends on dsh >=0.2.0-rc.2.

Configure OCR Engine

Default backend: native: Uses only poppler to read PDF text layers, no OCR installation required.

To process scanned documents, change backend to command in ~/.dsh/profiles/<profile>/cordis.patch.yml and register the engine under engines, for example, Tesseract:

# ~/.dsh/profiles/<profile>/cordis.patch.yml
- id: tool-ocr
  config:
    backend: command
    outputDir: C:/Users/you/Documents/ocr-output
    engines:
      - id: tesseract
        label: Tesseract Chinese-English Mix
        command: tesseract
        args: ["{input}", "{output}", "-l", "chi_sim+eng"]
        isDefault: true

Available placeholders in args:

Placeholder Meaning
{input} Absolute path of the image provided to the engine
{output} Absolute path where the engine should write the plain text
{lang} The lang argument from the current ocr_read (can be empty)

The engine can write text to {output} or output to stdout; the plugin recognizes both. For multiple engines, append entries under engines and specify isDefault. For instance, use tesseract for body text and configure PaddleOCR separately for table scenarios (example args are available in the README).

External Dependencies

Dependency Purpose Impact if not installed
pdftotext (poppler) Read PDF text layer Electronic PDFs cannot be read, note will explain
pdftoppm (poppler) Rasterize PDF pages to images Scanned PDFs cannot be OCR’d
Any configured OCR engine Recognize text in images Image input will error and prompt for configuration

On Windows, poppler can be downloaded via poppler-windows; add bin to the PATH or write the full path to pdftotext.exe in the config. Tesseract is available via the UB-Mannheim installer; ensure the Chinese language pack (chi_sim) is checked, otherwise -l chi_sim will lack traineddata.

Typical Usage (Agent Side)

  1. Call ocr_status to confirm the backend and available engines.
  2. Call ocr_read for local files, passing the absolute path; PDFs can include pages to limit the range; use saveAs if saving to disk is needed.
  3. Decide whether to adopt the result or retry with a different engine / lang based on the returned text and note.

The plugin only reads the single file you specify; it does not scan directories, upload files, or connect to the internet. OCR is invoked via spawn for local commands without shell path concatenation. Extracted text is only written to the configured outputDir besides being returned.

Use Cases and Notes

Suitable for: Developers who need the Agent to read invoice screenshots, scanned contracts, or image-based PDFs within DSH conversations or workflows, and want electronic PDFs to use the text layer while scanned files use a self-selected OCR.

Notes:

  • The plugin runs with the permissions of the current dsh process. Please review the source code and MIT license before installation, and only configure local commands you trust.
  • If there is no text layer and no OCR is configured, the image path will fail directly; scanned PDFs cannot be recognized with only the native backend.
  • The repository provides tests against the real dsh runtime (see node _test/run-all.mjs and the three test suite descriptions in the README) to facilitate self-verification of behavior.

Conclusion

dsh-tool-ocr encapsulates the branches for “is there text in the image, is the PDF electronic or scanned” into two tools, leaving the choice of engine to you. Directory and Documentation:

  • SkillHub: https://www.skillhub.cn/plugins/yuehancn/dsh-tool-ocr
  • GitHub: https://github.com/yuehancn/dsh-tool-ocr
羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye