Skip to content

添加biblatex导出和zotero 原生引用文献导出功能,增加zotero内文献搜索功能 - #92

Open
cloneorcopy wants to merge 14 commits into
cookjohn:mainfrom
cloneorcopy:main
Open

cloneorcopy wants to merge 14 commits into
cookjohn:mainfrom
cloneorcopy:main

Conversation

@cloneorcopy

Copy link
Copy Markdown

利用AI(GLM5.2)增加了添加biblatex导出和zotero 原生引用文献导出功能,增加zotero内文献搜索功能。biblatex导出依赖于zotero-better-bibtex库json-rpc功能;zotero内文献搜索功能则是复刻了Zotseek库的界面(个人认为比默认搜索在查找片段时很有用,此功能仅利用了zotero MCP的语义数据库进行实现,无外部依赖),作者可以选用接受。

@cloneorcopy

Copy link
Copy Markdown
Author

搜索功能
image

- Updated package version in package.json to 1.5.2.
- Added sync_bib method to export the entire Zotero library to a .bib file.
- Implemented cite method to insert citations into LaTeX or Markdown drafts.
- Enhanced citationExportService with new methods for exporting and managing citations.
- Updated httpServer to streamline logging and improve readability.
- Cleaned up i10n typings by removing unused message IDs.
- Added new entries in update.json for version 1.5.1.
@jingkaimori

jingkaimori commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

addon/content/searchDialog.xhtml 是不是没推送到你的在线分支?我拉取下来发现新界面无法展示

这个文件在gitignore里被忽略,需要手工强制添加

zotero-mcp-plugin/addon/ 规则自 v1.1.0 起误将插件源文件目录整体忽略,导致此后 addon/ 下新增文件(语义搜索对话框 xhtml/css、工具栏图标)无法提交推送,拉取方构建的插件缺少 chrome://zotero-mcp-plugin/content/searchDialog.xhtml,对话框无法打开。删除该规则并补交 4 个被遗漏文件。
@cloneorcopy

Copy link
Copy Markdown
Author

@cookjohn 此前搜索界面无法显示的原因:.gitignore 中的 zotero-mcp-plugin/addon/ 规则会静默忽略该目录下的新增文件,导致 searchDialog.xhtml、searchDialog.css 及图标文件一直未被提交。已在 c616d62 删除该规则并补齐全部缺失文件,PR 现已完整,欢迎审阅。

cookjohn added a commit that referenced this pull request Sep 2, 2026
Tracked files were unaffected, but NEW files under addon/ were being
silently ignored - contributors repeatedly lost locale/asset additions
(it cost PR #92 a missing dialog file for six weeks). Extracted from
PR #92 by @cloneorcopy.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@cookjohn

cookjohn commented Sep 2, 2026

Copy link
Copy Markdown
Owner

感谢 @cloneorcopy 的大量工作,也感谢用中文详细说明了设计取舍。先说最有价值的一点:.gitignorezotero-mcp-plugin/addon/ 规则确实是仓库的真实 bug(已跟踪文件不受影响,但 addon/ 下新增文件会被静默忽略——你的 searchDialog.xhtml 缺失六周就是它造成的),这个一行修复已单独摘出合入 main(728c645)并注明出处。

这个 PR 目前混合了至少五块独立内容(BBT 导出三工具、sync_bib/cite 文件写入、语义搜索对话框、外部工具注册 API、版本号与日志杂项),无法整体审阅合并,需要拆分。具体审阅意见:

必须回退:package.json 1.5.0→1.5.2、update.json 新增的 v1.5.1 条目(该 release 并不存在,update.json 由发布流程生成)、package-lock 的 1.4.8(与 1.5.2 也不一致)、README 版本徽章。版本号与发布统一由维护者处理。

已确认的 bug(get_citation)mode: 'citation' 时代码构造 citation=<styleID> 传给 Zotero.QuickCopy.getContentFromItems,但 Zotero 的 unserializeSetting 正则只识别 (bibliography|export) 前缀,解析失败后 format.mode 为 undefined,直接抛 "Invalid mode"。正确做法是始终用 bibliography= 前缀,并靠第 4 个参数(你已经传的 asCitations)切换文内引用。另外该函数第 3 个参数是 callback 而不是 libraryID,请不要把 lib 传进去;默认 Quick Copy 为 bibliography/html=STYLEsplit("=")[0] 会误判为非引文格式而退回 APA,也请一并处理。

安全(sync_bib / cite):这两个工具用 IOUtils.writeUTF8 直接写任意调用方指定的路径,且完全不受 write.enabled 或任何开关约束(tools/list 过滤只覆盖 write_* 工具)——在未认证的本地 HTTP 服务上暴露任意文件写入,和我们在 #83/#85 对 inject_citations 的要求相悖。需要:默认关闭的独立开关(关闭时从 tools/list 隐藏、tools/call 拒绝)、路径校验(绝对路径/扩展名)、覆盖保护;cite 会改写用户的 .tex/.md 草稿,风险更高。另外 sync_bib 整库导出走单次 BBT JSON-RPC,bbtRpc 固定 30s 超时,大库必超时,建议分批或可配置。

语义搜索对话框:这不与 MCP 的 search_library/semantic_search 重复(是 Zotero 内的 UI,复用现有向量库),我们欢迎这个方向。需要修改:ZotSeek 是 MIT 协议,界面复刻和 zotseek-favicon 图标请在文件头和 README 保留版权归属;chrome://zotero-mcp-plugin/... 请改用 addon 模板的 __addonRef__ 占位符(src 侧用 config.addonRef),这正是 #65 出过的模板展开问题;工具栏按钮/右键菜单目前无条件注册,语义搜索未启用时应隐藏或给出引导;addon.ftl 新增的 menu-find-similar 等 key 实际没接上(代码里硬编码了英文 'Find Similar Documents' / 'SS');locateItem 用了同步 getByLibraryAndKey 且只查用户库。

外部工具注册 API:允许任意插件向 MCP 注入 AI 可调用工具是一个重要的公共 API 与安全面决策,请单独提 PR 专门审(顺带:BUILTIN_TOOL_NAMES 漏了 sync_bib/cite)。

建议拆分:① BBT 导出三工具(修掉 citation bug 后很接近可合,正好回应 #38);② sync_bib/cite(补安全门槛);③ 搜索对话框;④ 注册 API。httpServer/preferenceScript 的日志与轮询修复没问题,随任一拆分 PR 携带即可。期待拆分后的版本!

Yyu-ang added a commit to Yyu-ang/zotero-mcp-plus that referenced this pull request Sep 4, 2026
Split the read-only citation/export work from cookjohn#92.

- add Better BibTeX-backed export_bibliography
- add Zotero-native get_citation and list_citation_styles
- fix Quick Copy citation mode/callback/default-setting handling
- add regression coverage for BBT export and Quick Copy behavior
Yyu-ang added a commit to Yyu-ang/zotero-mcp-plus that referenced this pull request Sep 4, 2026
review: guarded external tool API split from cookjohn#92
Yyu-ang added a commit to Yyu-ang/zotero-mcp-plus that referenced this pull request Sep 4, 2026
review: HTTP logging and semantic polling cleanup from cookjohn#92
Yyu-ang added a commit to Yyu-ang/zotero-mcp-plus that referenced this pull request Sep 4, 2026
Yyu-ang added a commit to Yyu-ang/zotero-mcp-plus that referenced this pull request Sep 4, 2026
Yyu-ang added a commit to Yyu-ang/zotero-mcp-plus that referenced this pull request Sep 4, 2026
github-actions Bot pushed a commit to Yyu-ang/zotero-mcp-plus that referenced this pull request Sep 5, 2026
Split the read-only citation/export work from cookjohn#92.

- add Better BibTeX-backed export_bibliography
- add Zotero-native get_citation and list_citation_styles
- fix Quick Copy citation mode/callback/default-setting handling
- add regression coverage for BBT export and Quick Copy behavior
@cookjohn

cookjohn commented Sep 9, 2026

Copy link
Copy Markdown
Owner

@cloneorcopy @Yyu-ang 感谢 9 月 5 日这批跟进——看到了几处切实采纳的修改:本地引用文件写入加了安全守卫(citationFileSafety)、保留了工具名、对话框的悬停/滚动与 ZotSeek 对齐、删掉了临时 CI 工作流,还补了不少测试。这些方向都对。

不过有两点想确认:

1. #107 为什么关闭了? 那个 PR(只读的 export_bibliography / get_citation / list_citation_styles + Quick Copy citation 模式修复 + 回归测试)正是我们要求的拆分件 ①,而且已经非常接近可合——它能直接回应 #38 的需求。如果是想把改动先集中到 #92 再拆,可以理解;但如果是打算放弃拆分、整体合并 #92,那这条路走不通:#92 现在 37 个文件,仍然捆绑四块独立内容(引用导出、文件写入工具、语义搜索对话框、外部工具注册 API),我们无法对这个体量做出可靠的整体审阅和合并决策。

2. 拆分仍是硬要求,这与代码质量无关,而是每一块的风险等级和审阅深度完全不同:

  • 只读导出三工具——低风险,重开 feat(citation): add bibliography export and CSL citation tools #107(rebase 到 main)我们可以很快合;
  • 文件写入工具(sync_bib / cite)——需要单独审安全门槛和路径校验,你们新加的守卫正好放这里;
  • 语义搜索对话框——UI 与许可归属(ZotSeek MIT 署名)的审阅;
  • 外部工具注册 API——公共 API 与安全面的独立讨论。

另外几项之前提过的仍在 diff 里:package.json / update.json / README 徽章的版本号变更(发布由维护者统一处理,请回退)、以及分支目前与 main 有冲突(我们这几周合了 #101/#102/#103/#77 等)。

建议的下一步:先重开或新开拆分件 ①(基于当前 main),我们优先审;其余三块各自独立提 PR,可以引用本 PR 的讨论。这样每一块都能尽快落地,比整体卡在这里强。再次感谢你们的投入。

@Yyu-ang

Yyu-ang commented Sep 13, 2026

Copy link
Copy Markdown

Thank you for the detailed review and for clarifying how this work should be split.

I have reorganized #92 accordingly. I used GPT-5.6 Sol in ChatGPT to assist with code review, diff inspection, rebasing, and checking the implementation against the review comments. The final branches and PRs are submitted under my account, and I remain responsible for the changes.

The work is now split into:

  1. Read-only citation/exportexport_bibliography, get_citation, list_citation_styles
    Submitted separately as feat(citation): add bibliography export and CSL citation tools #111, replacing the closed feat(citation): add bibliography export and CSL citation tools #107. The Quick Copy issues from the review were addressed, and the full test suite/build pass.

  2. sync_bib / cite
    Kept separate because these tools write local files. This part includes a default-off toggle, path/extension validation, overwrite protection, and timeout handling. I will submit it after feat(citation): add bibliography export and CSL citation tools #111 is merged so the PR contains only this delta.

  3. Semantic Search Dialog
    Split into its own branch, with ZotSeek MIT attribution, localization, semantic-disabled UI hiding, group-library lookup, scrolling, and hover-result behavior preserved.

  4. External Tool Registration API
    Split independently, with reserved built-in tool names including sync_bib and cite. Tests and production build pass.

Unrelated version/release changes and the already-fixed .gitignore issue are excluded.

Thank you again for the guidance. The split makes each change much easier to review.


感谢您之前详细的审查意见和拆分建议。

我已经重新整理了 #92,并使用 ChatGPT 中的 GPT-5.6 Sol 辅助进行代码审查、diff 检查、rebase 和 review comments 对照。最终分支和 PR 均由我的账户提交,相关改动由我本人负责。

目前拆分如下:

  1. 只读引用/导出功能export_bibliographyget_citationlist_citation_styles
    已作为 feat(citation): add bibliography export and CSL citation tools #111 单独提交,用于替代关闭的 feat(citation): add bibliography export and CSL citation tools #107。Quick Copy 相关问题已经修正,完整测试和 build 均通过。

  2. sync_bib / cite
    因为涉及本地文件写入,继续单独拆分,包含默认关闭开关、路径/扩展名校验、覆盖保护和 timeout。计划在 feat(citation): add bibliography export and CSL citation tools #111 合并后再提交,避免重复包含 citation/export 的 diff。

  3. Semantic Search Dialog
    已独立拆分,保留 ZotSeek MIT attribution、本地化、semantic 关闭时隐藏 UI、group library 定位、滚动和 hover 结果展示等行为。

  4. External Tool Registration API
    已独立拆分,并保留包括 sync_bibcite 在内的内置工具名保护。测试和 production build 均通过。

无关的版本/发布修改以及已经单独修复的 .gitignore 问题均未包含在这些拆分中。

再次感谢您的建议,这样拆分后每部分都更容易独立审核。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants