dsh-office-extractor
v0.5.0
Published
Office (docx/xlsx) text / table / metadata extraction CLI and library for DeepSeek Harness (DSH) agents, plus a bundled DSH skill.
Maintainers
Readme
dsh-office-extractor
为 DeepSeek Harness (DSH) 代理准备的 Office 文档解析包(阶段一:docx + xlsx):
提供 dsh-office 命令行工具与 Node.js API,支持全文、表格、元数据提取与关键词搜索。
不修改 DSH 任何核心代码 —— 以「独立 npm 包 + 一份 DSH Skill 指令」的插件形式接入。
功能
| 能力 | CLI | API |
| --- | --- | --- |
| 元信息(类型/页数/sheet 数/标题/作者…) | dsh-office info | officeInfo() |
| 全文 | dsh-office text | extractText() |
| 分页/sheet 分隔 | dsh-office pages | extractText() |
| 表格(Markdown/CSV/JSON) | dsh-office tables | extractTables() |
| 关键词搜索(页码 + 片段) | dsh-office search | searchText() |
--pages:xlsx 工作表索引(1-based);docx 忽略。- 加密 xlsx:
--password <密码>。
格式映射
- docx:整篇视为 1 页;
meta含 core 文档属性;表格从文档 HTML 中提取。 - xlsx:每工作表为 1 页(即一张表,首行表头);
meta含工作表名与工作簿属性。
安装 CLI
npm install -g dsh-office-extractor
dsh-office --help安装 DSH Skill
# 项目级(写入 <项目>/.dsh/skills/office-extractor/SKILL.md)
node scripts/install-skill.mjs --project <项目目录>
# 用户级
node scripts/install-skill.mjs --user安装后新建 DSH 会话即被发现。
使用
dsh-office info report.docx
dsh-office text ledger.xlsx --pages 1-2
dsh-office tables ledger.xlsx --format csv
dsh-office search report.docx "conclusion"安全说明
解析基于 mammoth(docx)、xlsx(SheetJS)与 cheerio/jszip。npm 官方发布的
[email protected] 存在已知安全提示(原型污染/ReDoS),对本地可信任文件解析可接受;
如需处理不可信来源,请升级到 SheetJS 官方 CDN 维护版或改用 exceljs。
测试
npm run build
npm run gen-sample # 生成 test/sample.docx 与 test/sample.xlsx
npm run smoke # 冒烟测试(23 项断言)发布
仓库附带 .github/workflows/publish.yml:推送 v*
tag 触发 CI(npm ci → build → smoke → npm publish --access public)。认证用仓库
Secret NPM_TOKEN(npm 自动化 token,绝不写入提交)。
