dsh-plugin-documents
一个 DeepSeek Harness (DSH / Cordis) 插件,给模型提供两个工具,用来读写 Word (.docx)、PDF 和纯文本 (.txt/.md 等) 文件。
工具
read_document
读取一个 .docx / .pdf / 文本文件,返回提取出的纯文本内容。
| 参数 | 类型 | 必填 | 说明 |
|---|
file_path | string | 是 | 要读取的文件路径(相对路径按会话工作目录解析) |
format | string | 否 | auto(默认,按扩展名识别)/ text / docx / pdf |
write_document
把纯文本内容写入一个 .docx / .pdf / 文本文件。输出格式由扩展名决定。
| 参数 | 类型 | 必填 | 说明 |
|---|
file_path | string | 是 | 目标路径;扩展名决定格式(.docx / .pdf / 文本) |
content | string | 是 | 要写入的文本内容 |
能力与限制
- 文本:读写
.txt .md 等 UTF-8 文本文件。
- Word (.docx):读——提取
word/document.xml 中的段落/表格文本;写——生成一个最小但合法、可用 Word/WPS 打开的 .docx(每个换行一个段落,支持中文)。
- PDF:读——扫描对象、解压 Flate/ASCIIHex/ASCII85/RunLength 流,提取
Tj/TJ/'/"/T* 文本,支持 CID 字体的 UTF-16BE(中文可提取);写——生成带经典 xref 的合法 PDF,使用内置 Adobe STSong-Light + UniGB-UCS2-H 绘制,中文/英文可直接显示(Adobe Reader、Chrome/Edge、Foxit、WPS)。
限制(best-effort):PDF 读取无法 OCR 图片型 PDF,也不处理加密 PDF;复杂排版(表格、分栏)会按内容流顺序摊平成文本。.doc(老式二进制 Word)不支持,请先另存为 .docx。
安装
插件是一个带 dsh.bundle 声明的 npm 包。用 dsh 命令行装进某个 profile:
# 从本地目录安装(profile 名按你的实际 profile 填,桌面默认通常是 web)
dsh plugin --profile web add "C:\\Users\\李\\Desktop\\知识点\\dsh-plugin-documents"
dsh plugin 会在 profile 目录里用 pnpm 安装这个包,并自动把它加进 dsh.profile.bundles。装完后重启 DSH Desktop 即可。
也可以手动安装:把本目录放进 profile 的 node_modules,并在 profile 的 package.json 里把 dsh-plugin-documents 加进 dsh.profile.bundles 数组。
目录结构
dsh-plugin-documents/
├── package.json # 声明 dsh.bundle.patch + adm-zip 依赖
├── cordis.patch.yml # 把插件插入 entry list
├── README.md
└── lib/
├── index.js # 插件入口,注册 read_document / write_document
├── util.js # 格式识别 + XML 转义
├── docx.js # Word 读写
└── pdf.js # PDF 读写