dsh-zotero
English | 中文
DeepSeek Harness 的 Zotero 工具插件:让 agent 直接检索你的 Zotero 文献库、阅读条目元数据与摘要、列出分类和 PDF 附件、读 PDF 全文、代写读书笔记。通过 Zotero 本地 API(7 代及以上可用,实测 9.x;http://127.0.0.1:23119)访问,无需 API Key,纯 Node 实现,零核心改动。
兼容版本:按 DSH 运行时 0.2.0-rc.x(桌面版 44.x 内核)的插件规范更新——schemastery Config 配置校验与设置表单、locale/ 插件管理器元信息、预构建 lib/ 直装、dsh.plugin.json 已按新规范移除(新运行时不读取该文件)。插件本体不声明任何 @deepseek-ai/dsh-* peer,能通过所有版本的兼容门禁;并用真实 @deepseek-ai/dsh-tools 注册表做契约测试(见「开发」)。
前置条件
- 本机安装并运行 Zotero 7 及以上(本地 API 自 7 代引入;本项目在 Zotero 9.0.6 / Windows 上实测通过);
- 打开 Zotero:设置 → 高级 → 通用 → 勾选「允许本机上的其他应用程序与 Zotero 通信」。
兼容性说明:读取类工具(检索/条目/全文/附件路径/笔记读取)在 Zotero 9 上全部实测通过。笔记写入(create/append/update/delete)受本地 API 只读限制不可用(见工具表说明)。
工具一览
| 工具 | 作用 |
|---|
zotero_collections | 列出文献库的所有分类(collectionKey + 条目数),用于限定检索范围 |
zotero_search | 按关键词检索文献库(标题/作者/年份),支持条目类型、分类、标签、年份区间(sinceYear/beforeYear)、排序、分页;mode 控制返回粒度省 token |
zotero_recent | 列出最近添加的条目("我刚导入的文献"场景) |
zotero_item | 按 key 读取条目详情:作者、期刊、DOI、摘要、标签、附件列表 |
zotero_fulltext | 读条目全文纯文本:优先读 Zotero 全文缓存(.zotero-ft-cache,零下载),无缓存时现场解析本地 PDF(pdfjs-dist,约 0.3s)并写缓存;仅远程链接附件才下载到工作区 |
zotero_attachment_path | 返回附件在 storage 的原始绝对路径,让 read 工具零拷贝直读 |
zotero_download | 把条目的 PDF 附件下载到会话工作区(默认),供模型用 read 工具阅读 |
zotero_notes | 列出某条目的子笔记,或全库按关键词搜笔记正文 |
zotero_note | 笔记写入:create 新增 / append 追加 / update 更新 / delete 删除。⚠️ 部分版本本地 API 为只读或要求额外握手(428 Zotero-Server-ID),写操作会返回明确提示 |
zotero_export | 把条目导出为引用格式:BibTeX / RIS / CSL JSON(逐 key 抓取后拼接,最多 25 条/次),可直接贴进 .bib/.ris 或引用管理器 |
zotero_annotations | 读取条目附件上的 PDF 批注(高亮、批注笔记),带 PDF 页码、文中页码标签、引文和你的评论;自动翻页拉全(实测有附件挂 1000+ 条批注) |
zotero_browse | 列出库内用户标签(可喂给 zotero_search 的 tag 参数)和保存的智能搜索 |
zotero_retrieve | 段落级检索:在条目的全文+笔记+批注里按 query 打分(BM25 风格 tf-idf,中英文分词),返回 Top-K 最相关段落,带页码锚点,适合精确引用和"这篇哪里说了 X" |
zotero_digest | 一次打包条目简报:完整元数据 + 摘要 + BibTeX 引用 + 附件列表 + 与 query 最相关的段落(缺省用标题词),"总结这篇论文"的首选入口 |
示例对话:
在我的 Zotero 里搜一下 transformer 相关的论文,挑 2020 年以后的,把第一篇的全文读一遍,给我写个摘要存进笔记。
安装
方式一:GUI 插件管理器(桌面版 44.x)——设置 → 插件 → 安装,填入仓库地址:
github:Hongcheng-LI/dsh-zotero
方式二:CLI(web / desktop profile 均可):
dsh plugin add github:Hongcheng-LI/dsh-zotero # 当前 profile
dsh plugin --profile web add github:Hongcheng-LI/dsh-zotero
装好后重启 DSH。仓库自带预构建的 lib/,且不声明任何生命周期脚本——pnpm 10 对声明 prepare 的 git 依赖会直接拒装(ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED),本插件零脚本、免白名单直装;插件自带空配置,不会弄崩启动;Zotero 未运行时工具会返回明确的连接提示。
配置(可选)
默认配置即可用(本地库、端口 23119)。插件导出了 schemastery Config schema:
- GUI:插件管理器 → dsh-zotero → 配置,直接用表单改(中英双语描述);
- cordis.patch.yml:在你的 profile(
$DSH_HOME/profiles/<name>/)里覆盖 tool-zotero 行,然后重启:
- id: tool-zotero
config:
baseUrl: http://127.0.0.1:23119 # Zotero 本地 API 地址
library: user # user(我的文献库)或 group:<群组ID>
downloadDir: D:/papers # 附件下载目录,缺省存到会话工作区
dataDir: D:/ZoteroData # Zotero 数据目录(含 profiles.ini),默认自动探测
storageDir: .../zotero/storage # 直接指定 storage 目录(zotero_fulltext / attachment_path 用)
maxAttachmentBytes: 67108864 # 单附件下载上限,默认 64MB
maxFulltextChars: 80000 # zotero_fulltext 返回的最大字符数,默认 80000
maxLimit: 50 # 检索结果条数上限,默认 50
timeoutMs: 15000 # 本地 API 超时(毫秒)
非法配置(比如 library: abc)会在加载期被 Config schema 拒绝并明确报错,而不是等到调用才失败。
全文与附件路径:插件通过本地 API /file 端点的 302 重定向拿到附件的真实磁盘路径(自定义数据目录也能自动识别,无需配置),全文优先读 Zotero 自己维护的 .zotero-ft-cache 缓存(与附件同目录)。dataDir/storageDir 配置仅在重定向不可用时作为兜底。
开发
npm install
npm test # 构建单元测试(离线,不需要 Zotero)
npm run audit # 运行时审计:清单 / patch / 构建产物 / locale / 兼容门禁
npm run test:smoke # 真实环境冒烟测试:对本机 Zotero 完整跑一遍工具链
运行时契约测试(可选但推荐):test/registry-contract.test.mjs 会用真实的 DSH 工具注册表注册全部 9 个工具,并跑一遍 execute → output schema 校验 → render 管线(mock 的 Zotero 本地 API,离线可跑)。@deepseek-ai/dsh-tools 刻意不出现在 package.json(插件对 DSH 零运行时依赖),想跑契约测试时装一份与目标运行时一致的版本即可,不装则自动跳过:
npm install --no-save @deepseek-ai/dsh-tools@0.2.0-rc.2
npm test
lib/ 是入库的,且没有 prepare 脚本:DSH 的插件安装走 pnpm,pnpm 10 对声明了 prepare 的 git 依赖会硬性拒装(不是静默跳过),所以构建产物必须入库、生命周期脚本必须为空。改动 src/ 后先 npm run build,把刷新后的 lib/ 一起提交。
结构遵循 DSH 插件规范(0.2.0-rc.x):package.json 的 dsh.bundle.patch 声明、cordis.patch.yml 运行时注入行、schemastery Config 配置 schema、locale/ 插件管理器元信息、src/ 源码、lib/ 构建产物。
Zotero tools for DeepSeek Harness: search your library, read item metadata and abstracts, list collections and PDF attachments, read full text, download PDFs into the session workspace, and attach notes — all through the Zotero local API (no API key needed).
Compatibility: updated for the DSH 0.2.0-rc.x plugin contract (desktop 44.x core) — schemastery Config (validated config + settings form), locale/ metadata for the plugin manager, prebuilt lib/ shipped in-repo (pnpm 10 blocks dependency build scripts), dsh.plugin.json removed per the current spec. The plugin declares no @deepseek-ai/dsh-* peers, so it passes the version-compatibility gate on every DSH release; a contract test runs every tool through the real @deepseek-ai/dsh-tools registry.
Requires Zotero 7+ (tested on 9.0.6 / Windows) running locally with "Allow other applications on this computer" enabled in Settings → Advanced.
| Tool | What it does |
|---|
zotero_collections | List library collections with keys and counts |
zotero_search | Quick-search items; filters by type, collection, tag, year range; sort/pagination; mode controls verbosity |
zotero_recent | Recently added items |
zotero_item | Full metadata of one item plus attachment keys |
zotero_fulltext | Full text as plain text (Zotero fulltext cache first, PDF download fallback) |
zotero_attachment_path | On-disk path of a stored attachment (zero-copy read) |
zotero_download | Download an attachment (PDF) to the workspace |
zotero_notes | List an item's child notes or search notes library-wide |
zotero_note | Create / append / update / delete notes |
zotero_export | Export items as BibTeX / RIS / CSL JSON (keys fetched one by one, up to 25 per call) |
zotero_annotations | Read PDF annotations on an item's attachments: highlight text, your comments, PDF page numbers and printed page labels (auto-paginates past 100) |
zotero_browse | List user tags (feed them to zotero_search's tag) and saved searches |
zotero_retrieve | Passage-level retrieval: rank the item's full text + notes + annotations against a query (tf-idf, mixed Latin/CJK), top-K passages with page anchors |
zotero_digest | One-shot briefing: metadata + abstract + BibTeX citation + attachments + top query-relevant passages (defaults to title-derived query) |
Install: dsh plugin add github:Hongcheng-LI/dsh-zotero (or via the desktop plugin manager), then restart DSH. Optional config (baseUrl, library, downloadDir, maxAttachmentBytes, maxLimit, timeoutMs, …) is available both as a settings form (schemastery Config) and under the tool-zotero row of your profile's cordis.patch.yml.
Development: npm install && npm test (offline unit tests), npm run audit (runtime audit), npm run test:smoke (live Zotero). Opt-in contract test against the real DSH registry: npm install --no-save @deepseek-ai/dsh-tools@0.2.0-rc.2 && npm test. lib/ is committed on purpose and the package declares no lifecycle scripts — pnpm 10 hard-fails git installs of packages that declare prepare (ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED).
License
MIT