dsh-plugin-pdf-text: Locally Reading PDF Text Layers in DSH

Introduction

When working with PDFs in DeepSeek Harness (DSH), common approaches include asking users to take screenshots, copy-paste, or convert to Word/text before feeding it to the agent. These steps interrupt the conversation and often result in lost page numbers and structure. If the PDF is on the local machine and has an extractable text layer, a more rational approach is to let the agent read the file directly via its path.

Below is an introduction to the community plugin dsh-plugin-pdf-text (maintainer: peanutcd2005, Category: Client-side). It registers the tool pdf_extract in DSH, returning text and page-level statistics page by page, and identifies “pure image scans.” It is implemented purely in Node, does not depend on Python, and by default does not access the network, ensuring files do not leave the local machine.

What is this

dsh-plugin-pdf-text is a Cordis bundle-type plugin for DSH (dsh.kind: server) with the entry point lib/index.js. The current version is 0.1.0 and the license is MIT. It exposes a tool pdf_extract to the agent within a profile, used to read the absolute path of a local PDF specified by the user and return the content with a text layer organized by page to the model.

The plugin’s disclosure fields indicate: cloud: false, offlineMode: true, and no external API keys. Permissions are limited to reading user-specified PDFs and optionally writing to a text file specified by saveTo.

Core Functionality

Capabilities of pdf_extract (derived from the repository README and implementation notes):

  1. Page-by-page text: Each page includes a header marker, e.g., ===== Page 3 =====.
  2. Header statistics: Total pages, pages read, and number of pages containing text.
  3. Scan hint: If no text layer can be extracted from any page in the PDF, it explicitly states “likely a pure image scan, requires OCR” and does not fabricate content.
  4. Return length limit: The content returned to the model is capped at 32000 characters; if exceeded, it is truncated at page boundaries with a prompt to use maxPages or saveTo.
  5. Optional saving: saveTo can save the full text (including statistics lines and page headers) as a UTF-8 text file; saved files are not subject to the 32000-character limit.
  6. Readable errors: Provides clear messages for file not found, directory not found, permission denied, encrypted PDF, etc., rather than failing silently.

Parsing relies on the npm package unpdf (^1.8.1) to extract text page by page; the plugin does not import any @deepseek-ai/* packages. The tool definition is hand-written following the ctx.tools.register() contract to avoid failures in the profile plugin directory resolving host packages.

Installation and Enablement

Prerequisites: DSH is installed on the local machine, and the profile name is known (the documentation example uses desktop).

dsh plugin --profile desktop add peanutcd2005/dsh-plugin-pdf-text

DSH is compatible with both install and add syntaxes; you can also search for dsh-plugin-pdf-text in “Settings → DSH Plugin Market” to install it.

A profile restart is required after installation to take effect (plugins are not hot-loaded). Uninstall example:

dsh plugin --profile desktop remove dsh-plugin-pdf-text

Offline tarball (Optional)

Network access is not required except for the first download of unpdf; if unpdf already exists in the profile, it can be fully offline. See the repository README for packaging and installation paths; it is recommended to use pure English paths to avoid garbled characters in Chinese paths.

Post-installation Reconciliation

  • Check the profile’s package.json; dsh-plugin-pdf-text should appear in bundles.
  • The desktop profile hosted by the desktop Electron app may reject dsh --profile desktop --dump-config; in this case, verify in the “Plugins” page of the interface instead.
  • After restarting the session, ask the agent to call pdf_extract to read a local PDF for smoke testing.

Node engine requirements: ^22.19.0 || >=24.0.0 (see package.json).

Typical Usage

How to say it in a session

In a DSH session, specify the PDF you want to read and provide the absolute path, and the agent will call pdf_extract. For example: “Read this PDF” along with the path.

Tool Parameters

Parameter Required Type Description
path Yes string The absolute path to the PDF file.
maxPages No integer ≥ 1 Only read the first N pages; if omitted, read all; if greater than total pages, treat as total pages.
saveTo No string Save the full extracted text to a text file at this absolute path; the directory must already exist, it will not create directories automatically.

Return example (excerpt):

File: C:\...\report.pdf (14.1 MB)
Total pages: 198; Read: 3 pages; Pages with text: 2

===== Page 1 =====
...

For pure image scans, the “Pages with text” count in the statistics will be 0, accompanied by a note that OCR is required. It will not return fabricated body text.

Large Files and Batch Reading

When the result exceeds 32000 characters, the model-side result will be truncated at page boundaries with a prompt: use maxPages to read in batches, or use saveTo to save the full text and then search for paragraphs locally.

Applicable Scenarios and Notes

Suitable for: Feasibility reports, contracts, papers, and other local PDFs with a text layer; scenarios where the agent needs to directly cite page numbers and paragraphs, and data must not leave the local machine.

Not suitable for: Full-page scanned images, photo-based PDFs—the plugin does not include OCR and will only prompt that an OCR tool is needed.

Other limitations (Key points from the README):

  • Determination of “page has text”: 20 or more non-whitespace characters; pages with very few headers/footers may be counted as having no text.
  • Reads only the PDF body; does not write files except for saveTo.
  • Encrypted or corrupted PDFs will return errors or prompts, not return empty content pretending to be successful.

Security and Trust: The plugin reads the disk with the current DSH process permissions; please review the GitHub repository source code and MIT license before installation. The community directory SkillHub Plugin Page has no official affiliation with DeepSeek / High-Flyer and is a third-party entry in the DSH “everything is a plugin” ecosystem.

In the maintainer’s local acceptance records, for a report of approximately 198 pages and 14.1 MB, the full extraction took about 0.8–1.4 seconds; scan samples correctly returned OCR prompts. The above represents the repository’s self-description; reader environments may vary.

Links

羽毛球分组比赛记分
小程序二维码

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

Xiaoye