Community plugin

liubaibuliuyan / @liubaibuliuyan/dsh-pdf-toolkit

Read any PDF as DeepSeek Harness agent tools: page-scoped text, geometric table reconstruction, pages rendered straight into the conversation, full-text search and on-demand OCR. Pure JavaScript, no environment dependencies.

  • JavaScript
  • MIT
  • 0 stars
  • Nov 21, 2026

About this plugin

Written by the registry from verified metadata, not from the README.

@liubaibuliuyan/dsh-pdf-toolkit is a DSH plugin published from the liubaibuliuyan/dsh-pdf-toolkit repository.

  • Listing statusManifest verified
  • Manifest checkedNov 21, 2026
  • Package@liubaibuliuyan/dsh-pdf-toolkit
  • Package version1.0.0
  • Source commit36294d7
  • Repository createdNov 21, 2026

Capabilities and topics

agent-toolsdeepseek-harnessocrpdf
From the repository README

README

Everything below this line is the repository's own document, cached here. This site did not write or review it.

Cached versionView on GitHub

@liubaibuliuyan/dsh-pdf-toolkit

把 PDF 读成 agent 能直接用的东西。零环境依赖、按需调用、自带全部依赖。

PDF 工具箱

七个工具

工具作用
pdf_info页数、标题、有没有文字层、哪些页是扫描件、每页文字量
pdf_text按页抽文本,保留版面换行与阅读顺序
pdf_render页面/指定矩形渲成图并直接内联进对话,模型当场就能看
pdf_search全文检索,只回命中页与片段
pdf_outline书签目录树,带起始页码
pdf_tables表格几何重建,输出带 colspan 的 HTML 或对齐文本
pdf_ocr扫描件 OCR(首次调用才下载语言包)

三条设计约束

零环境依赖。 只用插件自带的 npm 包:pdfjs-dist 解析、@napi-rs/canvas 栅格化、 tesseract.js OCR。不需要 Python、LibreOffice、poppler、任何命令行工具或模型文件。

按需调用。 这些包都在工具真正执行时才 import,插件加载阶段只做注册。 不调用就完全不占资源,宿主启动也不受影响。

版本独立。 engines 只声明 node >= 20,不锁定 dsh 版本; 除可选的 @deepseek-ai/dsh-tools 外不 import 任何宿主内部模块。

图片怎么喂进模型

不是「渲染到磁盘再让你去 read_image」,而是走宿主的附件通道直接变成图像内容块:

  1. pdf_render 执行时先把页面栅格化成 PNG
  2. 通过 ctx.get('attachments') 拿到附件库,saveImages() 换回 ImageAttachmentRef
  3. output.render 返回 [{type:'text'}, {type:'image', attachment}, ...]
  4. 模型这一步就看见了,不再多一次工具调用

会先用 llm.resolveModelInfo() 确认当前模型声明了 image 输入模态。 不支持就自动退化为只回路径,提示改用 read_image——图片通道的失败不会让工具本身挂掉。

表格重建怎么做的

不靠模型,纯几何:

  1. 按 y 把文字聚成行
  2. 用列对齐特征把行分组——同一张表的行,各列 x 起点必然一致; 正文段落每行断字位置随机,天然不满足这条
  3. 按列锚点吸收多行表头、竖排标题
  4. 只从数据行切列(表头的跨列宽项会桥接空档,必须排除)
  5. 按每项的 x 覆盖范围算 colspan
  6. 三道过滤挡误报:至少 3 行、排除 A./B./C./D. 选项列、要求单元格短且多为数值

实测:29 页全本扫描 107 ms,热电偶分度表还原成 11 列 × 10 行,数值与 PDF 原文逐格一致。

性能

同一份 29 页复习题实测:

操作耗时
pdf_info 全本113 ms
pdf_text 全本103 ms
pdf_tables 全本扫描107 ms
pdf_search 全本108 ms
pdf_render 单页144 ms
冷启动(首次加载 pdfjs)281 ms
峰值内存296 MB

已知边界

  • 表格的 rowspan 尚未还原(colspan 已还原)
  • 公式只做文本级抽取,不转 LaTeX —— 需要精确结构时用 pdf_render 放大看图
  • 扫描件 OCR 用 tesseract,中文识别弱于专用 OCR 模型
  • 双栏排版按几何顺序读取,未做分栏语义判定

安装

在 DSH 里通过插件市场安装,或手动挂进 profile:

"dependencies": {
  "@liubaibuliuyan/dsh-pdf-toolkit": "link:D:/aitest/plugins/dsh-pdf-toolkit"
},
"dsh": { "profile": { "bundles": [ "...", "@liubaibuliuyan/dsh-pdf-toolkit" ] } }

然后重启 DSH。

典型用法

  1. pdf_info → 29 页、有文字层、第 5 和第 21 页是扫描页
  2. pdf_text pages:"1-3" → 读前三页正文
  3. pdf_tables pages:"20" → 把分度表还原成表格
  4. pdf_render pages:"7" scale:3 → 渲整页看插图
  5. pdf_render pages:"7" region:"60,260,540,420" scale:4 → 只放大插图那块

License

MIT

Badge

Listed here? Link back with this badge — paste the snippet into your repository README.

Listed on DSH Plugin badge
[![Listed on DSH Plugin](https://dsh-plugin.com/badges/listed.svg)](https://dsh-plugin.com/plugins/liubaibuliuyan/dsh-pdf-toolkit)