dsh-plugin-zotero 0.1.7 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -20,8 +20,8 @@
20
20
  - **读文献**:读摘要、PDF 全文、笔记与标注,写综述、做对比、提取数据都行;需要精确引用时会保留原文措辞。
21
21
  - **整理文库**:新建、重命名、移动、删除分类,批量把条目加入或移出分类。你说一句「把这几篇归到『待读』里」,它就照做。
22
22
  - **帮你入库**:把本地下载好的论文、PDF 交给 DSH 导入 Zotero;也可以让它读完外文文献后,把译文作为附件挂回条目。
23
- - **带进对话**:右侧面板单条目引用、全文划词摘录或整分类引用,一键写进当前会话草稿(不自动发送),你再接着说要求。
24
- - **安全可控**:浏览面板严格只读;模型能用的每一项工具都能单独开关,想彻底只读就把写操作关掉。
23
+ - **带进对话**:右侧面板单条目引用、全文划词摘录或整分类引用,一键写进当前会话草稿(不自动发送),你再接着说要求。条目和整分类以「引用胶囊」的形式出现,草稿里一眼看清引了哪几篇,单独删掉某一条也不影响其他内容。
24
+ - **安全可控**:浏览面板严格只读;模型能用的每一项工具都能单独开关,想彻底只读就把写操作关掉;写操作优先走集成 MCP,它在 Zotero 进程内直接执行,不触发本地 API 的授权弹窗。
25
25
 
26
26
  面板分三块:顶部状态栏显示连接状态并提供刷新;左侧分类树按分类浏览与搜索;右侧详情区展示正文与「参考文献 / 笔记 / 标注 / 附件」标签页。
27
27
 
@@ -80,7 +80,8 @@ curl http://127.0.0.1:23119/api/ # 期望输出:Zotero is running
80
80
  - **摘要默认折叠**:标题行右侧的箭头按钮展开 / 收起摘要,默认把空间留给正文与全文。
81
81
  - **笔记可读**:独立笔记(文库里的全局笔记)打开后正文直接占据上方正文区,跟普通条目一样阅读;条目下的子笔记仍进「笔记」tab,以折叠列表呈现(默认收起,点击标题展开),正文保留 Zotero 的引用块、标注高亮、表格与外链图片。Host 侧已清洗脚本与事件属性,避免注入。「引用」把该条笔记转成纯文本写进会话草稿。
82
82
  - **标注可读**:PDF 上的高亮与划线汇总进「标注」tab(带颜色、页码、原文与评论,可按类型 / 颜色筛选);全文块里原位标出底色与下划线,点列表条目可滚动定位并闪烁,「引用」把该条标注写进会话草稿。
83
- - **五种插入方式**:单条目引用、全文划词摘录、单条标注、单条笔记、整目录引用,均只写进会话草稿(不自动发送、不抢焦点),文本携带 `itemKey` / `collectionKey` 供模型接续操作。
83
+ - **五种插入方式**:单条目引用与整目录引用以「引用胶囊」写进草稿——胶囊只显示标题,发送那一刻才展开成完整引用文本,模型拿到的内容与以前一致;全文划词摘录、单条标注、单条笔记仍按纯文本插入。所有方式都只写进会话草稿(不自动发送、不抢焦点),文本携带 `itemKey` / `collectionKey` 供模型接续操作。
84
+ - **胶囊依赖本插件展开**:草稿里留着引用胶囊时禁用或卸载本插件,发送会失败并提示找不到引用来源,把胶囊删掉即可继续正常发送。
84
85
  - **面板严格只读**:不提供任何新建 / 改名 / 删除分类的按钮。
85
86
  - **模型侧工具可逐个开关**:插件自持连接集成 MCP,把工具以 `mcp__zotero__*` 注册进 dsh,可在插件页按工具启用 / 禁用。
86
87
 
@@ -234,11 +235,13 @@ dsh --profile demo # 启动
234
235
 
235
236
  ### 模型侧 MCP 与权限边界
236
237
 
237
- 模型侧工具由**插件自己**桥接:[src/host/mcp-bridge.ts](src/host/mcp-bridge.ts) 直连本机 Zotero 集成 MCP(本机实测 `zotero-integrated-mcp v1.1.0`,暴露 20 个工具),按配置里的 `disabledMcpTools` 过滤后以 `mcp__zotero__*` 注册给模型。[cordis.patch.yml](cordis.patch.yml) **不再**插入 `@deepseek-ai/dsh-mcp-client` —— 它不支持按工具开关,且同 `serverName` 会与自注册工具重名冲突。
238
+ 模型侧工具由**插件自己**桥接:[src/host/mcp-bridge.ts](src/host/mcp-bridge.ts) 直连本机 Zotero 集成 MCP(本机实测暴露 25 个工具),按配置里的 `disabledMcpTools` 过滤后以 `mcp__zotero__*` 注册给模型。[cordis.patch.yml](cordis.patch.yml) **不再**插入 `@deepseek-ai/dsh-mcp-client` —— 它不支持按工具开关,且同 `serverName` 会与自注册工具重名冲突。
238
239
 
239
240
  ⚠️ 前提是 [Zotero 里已装好集成 MCP 插件](#1-安装-zotero-mcp-插件)(或改用其他 MCP 插件并在配置卡填对 `mcpUrl`),并且开启了「允许写操作」。插件未安装或服务未起时,模型侧工具全部不可用;插件装了但没开写操作时,读类工具正常,`create_collection` 等写工具会被插件拒绝(返回「写操作已禁用」),表现为让模型帮忙新建分类直接报错——此时到 MCP 插件设置里打开写操作并重试即可,无需重启 dsh。
240
241
 
241
- ⚠️ 面板只读,**但模型侧工具不是**:20 个工具中含 5 个改变文库结构的写工具(`create_collection` / `update_collection` / `delete_collection` / `add_items_to_collection` / `remove_items_from_collection`)。想收紧为纯只读,直接在插件页配置卡的「MCP 工具」里关掉它们并保存即可;面板功能不受影响。
242
+ ⚠️ 面板只读,**但模型侧工具不是**:25 个工具中含 10 个写工具(`write_item` / `write_note` / `write_tag` / `write_metadata` / `add_by_identifier` / `create_collection` / `update_collection` / `delete_collection` / `add_items_to_collection` / `remove_items_from_collection`)。想收紧为纯只读,直接在插件页配置卡的「MCP 工具」里关掉它们并保存即可;面板功能不受影响。
243
+
244
+ **写操作为什么优先走 MCP**:这些工具在 Zotero 进程内直接改库,不经过本地 API,因此**不会触发 Zotero 的「本地 API 授权」弹窗**。反过来,若让模型用 shell/curl 直接打 `127.0.0.1:23119` 的写接口,就必须先用 `POST /api/local/authorize` 换 key —— 该端点每次调用都会弹一次授权框,用户点「允许」拿到的 key 还是一次性的(首个写请求即被 Zotero 删除),这就是「每写一次就要点一次允许」的根源。为此插件在 [mcp-bridge.ts](src/host/mcp-bridge.ts) 里给所有写工具的描述统一注入了「首选写通道」引导语;「导入本地文件并挂到某条目下」用 `write_item` 的 `action: "import"` + `filePath` + `parentItemKey`,一条工具调用即可。
242
245
 
243
246
  ## 相关文档
244
247
 
package/client/client.js CHANGED
@@ -37,6 +37,7 @@ const dicts = {
37
37
  "status.mcpOn": "模型工具可用",
38
38
  "status.mcpOff": "模型工具不可用",
39
39
  "status.loading": "加载中…",
40
+ "item.lastRead": "最后阅读:{date}",
40
41
  "tree.library": "我的文库",
41
42
  "tree.publications": "我的出版物",
42
43
  "tree.unfiled": "未分类条目",
@@ -75,7 +76,8 @@ const dicts = {
75
76
  "detail.annotationNotAnchoredNoFulltext": "该附件没有全文索引,无法定位",
76
77
  "detail.fulltext": "全文",
77
78
  "detail.noteBody": "笔记正文",
78
- "detail.noFulltext": "该附件没有可用的全文索引",
79
+ "detail.noFulltext": "该条目的附件都没有全文索引;可在 Zotero 中右键附件,选择「重新索引条目」",
80
+ "detail.fulltextFallback": "首选附件没有全文索引,已显示同条目其他附件的全文",
79
81
  "detail.fulltextTruncated": "(已按长度截断)",
80
82
  "detail.collectionSummary": "分类:{name}",
81
83
  "detail.collectionCount": "共 {n} 条条目",
@@ -142,7 +144,9 @@ const dicts = {
142
144
  "cmp.excerpt.quote": "“{value}”",
143
145
  "cmp.collection.header": "【Zotero 目录|{name}|{key}】共 {n} 条",
144
146
  "cmp.collection.line": "- {title}({meta})",
145
- "cmp.collection.more": "……(仅列出前 {n} 条;完整清单可用 mcp__zotero__get_collection_items 获取)"
147
+ "cmp.collection.more": "……(仅列出前 {n} 条;完整清单可用 mcp__zotero__get_collection_items 获取)",
148
+ "cmp.missing.item": "【Zotero 条目|{key}】该条目已不在文库中,引用文本未能生成。",
149
+ "cmp.missing.collection": "【Zotero 目录|{key}】该目录已不存在,条目清单未能生成。"
146
150
  },
147
151
  en: {
148
152
  "tab.title": "Zotero Library",
@@ -160,6 +164,7 @@ const dicts = {
160
164
  "status.mcpOn": "Model tools available",
161
165
  "status.mcpOff": "Model tools unavailable",
162
166
  "status.loading": "Loading…",
167
+ "item.lastRead": "Last read: {date}",
163
168
  "tree.library": "My Library",
164
169
  "tree.publications": "My Publications",
165
170
  "tree.unfiled": "Unfiled Items",
@@ -198,7 +203,8 @@ const dicts = {
198
203
  "detail.annotationNotAnchoredNoFulltext": "No full-text index for this attachment, so it cannot be located",
199
204
  "detail.fulltext": "Full text",
200
205
  "detail.noteBody": "Note",
201
- "detail.noFulltext": "No full-text index available for this attachment",
206
+ "detail.noFulltext": "None of this item’s attachments have a full-text index. Right-click the attachment in Zotero and choose “Reindex Item”.",
207
+ "detail.fulltextFallback": "The preferred attachment has no full-text index; showing another attachment from this item",
202
208
  "detail.fulltextTruncated": "(truncated by length)",
203
209
  "detail.collectionSummary": "Collection: {name}",
204
210
  "detail.collectionCount": "{n} items",
@@ -265,7 +271,9 @@ const dicts = {
265
271
  "cmp.excerpt.quote": "“{value}”",
266
272
  "cmp.collection.header": "[Zotero collection | {name} | {key}] {n} items",
267
273
  "cmp.collection.line": "- {title} ({meta})",
268
- "cmp.collection.more": "… (first {n} only; use mcp__zotero__get_collection_items for the full list)"
274
+ "cmp.collection.more": "… (first {n} only; use mcp__zotero__get_collection_items for the full list)",
275
+ "cmp.missing.item": "[Zotero item | {key}] this item is no longer in the library; citation text unavailable.",
276
+ "cmp.missing.collection": "[Zotero collection | {key}] this collection no longer exists; item list unavailable."
269
277
  }
270
278
  };
271
279
  //#endregion
@@ -286,10 +294,10 @@ function buildUrl(action, query = {}) {
286
294
  const search = params.toString();
287
295
  return `${BASE}/${action}${search === "" ? "" : `?${search}`}`;
288
296
  }
289
- async function get(action, query = {}) {
297
+ async function get(action, query = {}, signal) {
290
298
  let res;
291
299
  try {
292
- res = await fetch(buildUrl(action, query));
300
+ res = await fetch(buildUrl(action, query), { signal });
293
301
  } catch (error) {
294
302
  throw new ApiFailure("network_error", `无法访问 Host 端点:${error instanceof Error ? error.message : String(error)}`);
295
303
  }
@@ -301,17 +309,17 @@ async function get(action, query = {}) {
301
309
  function fetchHealth() {
302
310
  return get("health");
303
311
  }
304
- function fetchTree() {
305
- return get("tree");
312
+ function fetchTree(signal) {
313
+ return get("tree", {}, signal);
306
314
  }
307
- function fetchItems(query = {}) {
308
- return get("items", query);
315
+ function fetchItems(query = {}, signal) {
316
+ return get("items", query, signal);
309
317
  }
310
- function fetchItem(key, style = "apa") {
318
+ function fetchItem(key, style = "apa", signal) {
311
319
  return get("item", {
312
320
  key,
313
321
  style
314
- });
322
+ }, signal);
315
323
  }
316
324
  function fetchCollectionBib(key, style = "apa") {
317
325
  return get("collection-bib", {
@@ -569,6 +577,258 @@ function resetPaneStore() {
569
577
  for (const listener of listeners) listener();
570
578
  }
571
579
  //#endregion
580
+ //#region src/client/annotationComment.ts
581
+ /** 只有这些标签有意义;属性不会出现,仍容忍以防手改。 */
582
+ const TAG_SOURCE = "<\\/?(?:b|i|sub|sup|br|div)\\b[^>]*>";
583
+ function tagRegex() {
584
+ return new RegExp(TAG_SOURCE, "giu");
585
+ }
586
+ /** 评论 → 渲染 token;不平衡的闭合标签直接忽略。 */
587
+ function parseComment(comment) {
588
+ const tokens = [];
589
+ let bold = 0;
590
+ let italic = 0;
591
+ let sub = 0;
592
+ let sup = 0;
593
+ let last = 0;
594
+ const pushText = (text) => {
595
+ if (text === "") return;
596
+ tokens.push({
597
+ kind: "text",
598
+ text,
599
+ bold: bold > 0,
600
+ italic: italic > 0,
601
+ sub: sub > 0,
602
+ sup: sup > 0
603
+ });
604
+ };
605
+ for (const match of comment.matchAll(tagRegex())) {
606
+ const index = match.index ?? 0;
607
+ pushText(comment.slice(last, index));
608
+ last = index + match[0].length;
609
+ const tag = match[0].toLowerCase();
610
+ const closing = tag.startsWith("</");
611
+ const name = tag.replace(/[</>\s]/gu, "");
612
+ if (name === "br" || name === "div") {
613
+ if (!closing) tokens.push({
614
+ kind: "break",
615
+ text: "",
616
+ bold: false,
617
+ italic: false,
618
+ sub: false,
619
+ sup: false
620
+ });
621
+ continue;
622
+ }
623
+ const delta = closing ? -1 : 1;
624
+ if (name === "b") bold = Math.max(0, bold + delta);
625
+ else if (name === "i") italic = Math.max(0, italic + delta);
626
+ else if (name === "sub") sub = Math.max(0, sub + delta);
627
+ else if (name === "sup") sup = Math.max(0, sup + delta);
628
+ }
629
+ pushText(comment.slice(last));
630
+ while (tokens[0]?.kind === "break") tokens.shift();
631
+ while (tokens[tokens.length - 1]?.kind === "break") tokens.pop();
632
+ return tokens;
633
+ }
634
+ /** 去标签与换行,供插入草稿使用。 */
635
+ function commentPlain(comment) {
636
+ return comment.replace(tagRegex(), " ").replace(/\s+/gu, " ").trim();
637
+ }
638
+ /** 是否有可显示的内容(纯空白不算)。 */
639
+ function hasComment(comment) {
640
+ return commentPlain(comment) !== "";
641
+ }
642
+ function line(t, key, value) {
643
+ return tpl(t(key), { value });
644
+ }
645
+ /** 单条目的引用文本。 */
646
+ function itemText(t, detail) {
647
+ const lines = [tpl(t("cmp.item.header"), {
648
+ key: detail.key,
649
+ title: detail.title
650
+ })];
651
+ if (detail.creators.length > 0) lines.push(line(t, "cmp.item.creators", detail.creators.join("、")));
652
+ if (detail.year !== "") lines.push(line(t, "cmp.item.year", detail.year));
653
+ if (detail.publicationTitle !== "") lines.push(line(t, "cmp.item.source", detail.publicationTitle));
654
+ if (detail.doi !== "") lines.push(line(t, "cmp.item.doi", detail.doi));
655
+ if (detail.url !== "") lines.push(line(t, "cmp.item.url", detail.url));
656
+ if (detail.tags.length > 0) lines.push(line(t, "cmp.item.tags", detail.tags.join("、")));
657
+ if (detail.abstract !== "") lines.push(line(t, "cmp.item.abstract", detail.abstract));
658
+ return lines.join("\n");
659
+ }
660
+ /** 选中片段的摘录文本。 */
661
+ function excerptText(t, detail, quote) {
662
+ return `${tpl(t("cmp.excerpt.header"), {
663
+ title: detail.title,
664
+ key: detail.key
665
+ })}\n${tpl(t("cmp.excerpt.quote"), { value: quote })}`;
666
+ }
667
+ /**
668
+ * PDF 抽取会在汉字之间插空格(`硫 化 氢`),展示与插入时去掉;
669
+ * 只处理汉字与汉字之间的空格,避免动到西文词距。
670
+ */
671
+ function tidyAnnotation(text) {
672
+ return text.replace(/\s+/gu, " ").replace(/(?<=[\u3400-\u9fff])\s+(?=[\u3400-\u9fff])/gu, "").trim();
673
+ }
674
+ /** 一条标注的引用文本:原文 + 类型 + 页码 + 评论 + 标注 key。 */
675
+ function annotationText(t, detail, annotation) {
676
+ const comment = commentPlain(annotation.comment);
677
+ const quote = tidyAnnotation(annotation.text) || comment;
678
+ const type = annotation.type === "underline" ? t("annotation.type.underline") : t("annotation.type.highlight");
679
+ const lines = [excerptText(t, detail, quote), tpl(t("cmp.annotation.type"), { value: type })];
680
+ if (annotation.pageLabel !== "") lines.push(tpl(t("cmp.annotation.page"), { value: annotation.pageLabel }));
681
+ if (comment !== "" && quote !== comment) lines.push(tpl(t("cmp.annotation.comment"), { value: comment }));
682
+ lines.push(tpl(t("cmp.annotation.key"), { value: annotation.key }));
683
+ return lines.join("\n");
684
+ }
685
+ /** 命名实体的最小集合(与 Host 清洗后的笔记 HTML 对齐)。 */
686
+ const NAMED_ENTITIES = {
687
+ nbsp: " ",
688
+ amp: String.fromCharCode(38),
689
+ lt: String.fromCharCode(60),
690
+ gt: String.fromCharCode(62),
691
+ quot: String.fromCharCode(34),
692
+ apos: String.fromCharCode(39)
693
+ };
694
+ /** 解码 HTML 实体;未识别的实体原样保留。 */
695
+ function decodeEntities(text) {
696
+ return text.replace(/&(#x[0-9a-f]+|#[0-9]+|[a-z]+);/giu, (match, body) => {
697
+ if (body.startsWith("#x") || body.startsWith("#X")) {
698
+ const code = Number.parseInt(body.slice(2), 16);
699
+ return Number.isFinite(code) ? String.fromCodePoint(code) : match;
700
+ }
701
+ if (body.startsWith("#")) {
702
+ const code = Number.parseInt(body.slice(1), 10);
703
+ return Number.isFinite(code) ? String.fromCodePoint(code) : match;
704
+ }
705
+ return NAMED_ENTITIES[body.toLowerCase()] ?? match;
706
+ });
707
+ }
708
+ /**
709
+ * 笔记 HTML → 纯文本:块级标签转换行、列表项加 `- `,剥标签后解码实体。
710
+ *
711
+ * 只保留段落与列表结构,图片等没有文本的可选内容自然消失。
712
+ */
713
+ function noteHtmlToText(html) {
714
+ return decodeEntities(html.replace(/<br\s*\/?>/giu, "\n").replace(/<\/(?:p|div|h[1-6]|blockquote|li|tr|ul|ol|table|figure|figcaption|pre)>/giu, "\n").replace(/<li\b[^>]*>/giu, "- ").replace(/<[^>]*>/gu, "")).replace(/\u00a0/gu, " ").replace(/[ \t]+/gu, " ").replace(/ *\n */gu, "\n").replace(/(^|\n)- *\n/gu, "$1- ").replace(/\n{2,}(?=- )/gu, "\n").replace(/\n{3,}/gu, "\n\n").trim();
715
+ }
716
+ /** 单条笔记的引用文本:所属条目 + 正文纯文本 + 截断提示 + 更新日期 + 笔记 key。 */
717
+ function noteText(t, detail, note) {
718
+ const head = tpl(t("cmp.note.header"), {
719
+ title: detail.title,
720
+ key: detail.key
721
+ });
722
+ const body = noteHtmlToText(note.html);
723
+ const lines = [head];
724
+ if (body !== "") lines.push(body);
725
+ if (note.truncated) lines.push(t("cmp.note.truncated"));
726
+ const date = note.dateModified.slice(0, 10);
727
+ if (date !== "") lines.push(tpl(t("cmp.note.date"), { value: date }));
728
+ lines.push(tpl(t("cmp.note.key"), { value: note.key }));
729
+ return lines.join("\n");
730
+ }
731
+ /** 整目录的引用文本(标题清单 + 稳定标识)。 */
732
+ function collectionText(t, collection, items, total) {
733
+ const head = tpl(t("cmp.collection.header"), {
734
+ name: collection.name,
735
+ key: collection.key,
736
+ n: total
737
+ });
738
+ const preview = items.slice(0, 50);
739
+ const lines = preview.map((item) => {
740
+ const meta = [item.creators, item.year].filter((part) => part !== "").join(", ");
741
+ return tpl(t("cmp.collection.line"), {
742
+ title: item.title,
743
+ meta
744
+ });
745
+ });
746
+ if (total > preview.length) lines.push(tpl(t("cmp.collection.more"), { n: preview.length }));
747
+ return [head, ...lines].join("\n");
748
+ }
749
+ //#endregion
750
+ //#region src/client/cite.ts
751
+ /** 文库里已经没有这个对象(与「连不上 Zotero」区分开)。 */
752
+ function isMissing(error) {
753
+ return error instanceof ApiFailure && error.code === "zotero_not_found";
754
+ }
755
+ async function itemCitation(t, key, signal) {
756
+ try {
757
+ return itemText(t, await fetchItem(key, "apa", signal));
758
+ } catch (error) {
759
+ if (isMissing(error)) return tpl(t("cmp.missing.item"), { key });
760
+ throw error;
761
+ }
762
+ }
763
+ async function collectionCitation(t, key, signal) {
764
+ const collection = (await fetchTree(signal)).collections.find((node) => node.key === key);
765
+ if (collection === void 0) return tpl(t("cmp.missing.collection"), { key });
766
+ const data = await fetchItems({
767
+ scope: collection.scope,
768
+ collectionKey: collection.scope === void 0 ? collection.key : void 0,
769
+ limit: 50
770
+ }, signal);
771
+ return collectionText(t, collection, data.items, data.total);
772
+ }
773
+ //#endregion
774
+ //#region src/client/reference.ts
775
+ /**
776
+ * 写进 chip 的持久标识:一旦发布就不能改名,老草稿里的 chip 靠它找回 codec。
777
+ */
778
+ const REF_SOURCE = "zotero";
779
+ const ITEM_PREFIX = "item:";
780
+ const COLLECTION_PREFIX = "col:";
781
+ /** 按 ref 前缀分派到对应的引用文本构建。 */
782
+ function citationForRef(t, ref, signal) {
783
+ if (ref.startsWith(ITEM_PREFIX)) return itemCitation(t, ref.slice(5), signal);
784
+ if (ref.startsWith(COLLECTION_PREFIX)) return collectionCitation(t, ref.slice(4), signal);
785
+ return Promise.reject(/* @__PURE__ */ new Error(`无法识别的 Zotero 引用:${ref}`));
786
+ }
787
+ function createZoteroSource(t) {
788
+ return {
789
+ trigger: "@",
790
+ name: REF_SOURCE,
791
+ candidates: () => Promise.resolve([]),
792
+ onPick: () => void 0,
793
+ codec: {
794
+ clipboardText: (ref) => `@${ref}`,
795
+ serialize: (ref, signal) => citationForRef(t, ref, signal)
796
+ }
797
+ };
798
+ }
799
+ function reference(prefix, key, title, appearance) {
800
+ const ref = `${prefix}${key}`;
801
+ return {
802
+ source: REF_SOURCE,
803
+ ref,
804
+ label: title === "" ? key : title,
805
+ appearance,
806
+ clipboardText: `@${ref}`
807
+ };
808
+ }
809
+ /** 一条文献的 chip。 */
810
+ function itemReference(key, title) {
811
+ return reference(ITEM_PREFIX, key, title, "file");
812
+ }
813
+ /** 一个目录的 chip。 */
814
+ function collectionReference(key, name) {
815
+ return reference(COLLECTION_PREFIX, key, name, "folder");
816
+ }
817
+ /**
818
+ * 把 chip 插进该会话的输入框。
819
+ *
820
+ * `thisArg` 必须显式传会话 ctx:cordis 的事件表挂在根 ctx 上,不带过滤参数会把
821
+ * **所有**会话的监听器都跑一遍,第一个返回 true 的赢——多开几个会话就会插错地方。
822
+ */
823
+ function insertChip(sessions, sessionId, reference, span) {
824
+ const actx = sessionId === void 0 ? void 0 : sessions.scope(sessionId);
825
+ if (!actx) return false;
826
+ return actx.bail(actx, "slash/input-insert-reference", {
827
+ reference,
828
+ span
829
+ }) === true;
830
+ }
831
+ //#endregion
572
832
  //#region src/client/ZoteroCard.tsx
573
833
  /**
574
834
  * 插件页配置卡(浏览器半)。
@@ -883,6 +1143,45 @@ function ZoteroCard(props) {
883
1143
  });
884
1144
  }
885
1145
  //#endregion
1146
+ //#region src/client/readState.tsx
1147
+ /**
1148
+ * 已读圆点颜色:柔和的粉色。
1149
+ *
1150
+ * 不用主题蓝:蓝点在列表里很像「未读消息」徽标,粉色更接近 Zotero Style 的
1151
+ * 阅读进度条配色,读起来是「标记」而不是「待办」。
1152
+ */
1153
+ const READ_DOT_COLOR = "#e8798d";
1154
+ /** 已读条目标题的淡化程度:留一点提示,又不至于看成禁用态。 */
1155
+ const READ_TITLE_OPACITY = .75;
1156
+ function isRead(item) {
1157
+ return item.lastRead !== null;
1158
+ }
1159
+ /** 圆点槽位:未读时透明但仍占宽,避免已读/未读行的标题起点错位。 */
1160
+ function ReadDot({ read }) {
1161
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1162
+ "aria-hidden": true,
1163
+ style: {
1164
+ width: 4,
1165
+ height: 4,
1166
+ borderRadius: "50%",
1167
+ flexShrink: 0,
1168
+ alignSelf: "center",
1169
+ background: read ? READ_DOT_COLOR : "transparent",
1170
+ opacity: read ? .9 : 0
1171
+ }
1172
+ });
1173
+ }
1174
+ /** 已读条目的标题淡化;未读返回空对象,直接展开不影响原有样式。 */
1175
+ function readTitleStyle(read) {
1176
+ return read ? { opacity: READ_TITLE_OPACITY } : {};
1177
+ }
1178
+ /** 行内 hover 提示:读过的在标题后补一行最后阅读时间。 */
1179
+ function itemTooltip(t, item) {
1180
+ if (item.lastRead === null) return item.title;
1181
+ const date = (/* @__PURE__ */ new Date(item.lastRead * 1e3)).toLocaleDateString();
1182
+ return `${item.title}\n${tpl(t("item.lastRead"), { date })}`;
1183
+ }
1184
+ //#endregion
886
1185
  //#region src/client/CollectionTree.tsx
887
1186
  /**
888
1187
  * 左栏:文库分类树 + 条目叶子(Zotero 风格)。
@@ -1060,12 +1359,13 @@ function Chevron({ open, onToggle }) {
1060
1359
  function ItemRow({ ctx, item, depth }) {
1061
1360
  const [menuOpen, setMenuOpen] = (0, react.useState)(false);
1062
1361
  const meta = [item.creators, item.year].filter((part) => part !== "").join(" · ");
1362
+ const read = isRead(item);
1063
1363
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Menu, {
1064
1364
  open: menuOpen,
1065
1365
  onClose: () => setMenuOpen(false),
1066
1366
  onSelect: (id) => {
1067
1367
  setMenuOpen(false);
1068
- if (id === "insert-item") ctx.onInsertItem(item.key);
1368
+ if (id === "insert-item") ctx.onInsertItem(item);
1069
1369
  },
1070
1370
  align: "end",
1071
1371
  portal: true,
@@ -1074,6 +1374,7 @@ function ItemRow({ ctx, item, depth }) {
1074
1374
  label: ctx.t("action.insertItem")
1075
1375
  }],
1076
1376
  anchor: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1377
+ title: itemTooltip(ctx.t, item),
1077
1378
  onClick: () => ctx.onSelectItem(item.key),
1078
1379
  onContextMenu: (event) => {
1079
1380
  event.preventDefault();
@@ -1090,9 +1391,12 @@ function ItemRow({ ctx, item, depth }) {
1090
1391
  style: iconBox,
1091
1392
  children: glyph(ITEM_ICON)
1092
1393
  }),
1394
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ReadDot, { read }),
1093
1395
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1094
- style: titleStyle,
1095
- title: item.title,
1396
+ style: {
1397
+ ...titleStyle,
1398
+ ...readTitleStyle(read)
1399
+ },
1096
1400
  children: item.title
1097
1401
  }),
1098
1402
  meta !== "" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
@@ -1321,180 +1625,6 @@ function CollectionTree(props) {
1321
1625
  });
1322
1626
  }
1323
1627
  //#endregion
1324
- //#region src/client/annotationComment.ts
1325
- /** 只有这些标签有意义;属性不会出现,仍容忍以防手改。 */
1326
- const TAG_SOURCE = "<\\/?(?:b|i|sub|sup|br|div)\\b[^>]*>";
1327
- function tagRegex() {
1328
- return new RegExp(TAG_SOURCE, "giu");
1329
- }
1330
- /** 评论 → 渲染 token;不平衡的闭合标签直接忽略。 */
1331
- function parseComment(comment) {
1332
- const tokens = [];
1333
- let bold = 0;
1334
- let italic = 0;
1335
- let sub = 0;
1336
- let sup = 0;
1337
- let last = 0;
1338
- const pushText = (text) => {
1339
- if (text === "") return;
1340
- tokens.push({
1341
- kind: "text",
1342
- text,
1343
- bold: bold > 0,
1344
- italic: italic > 0,
1345
- sub: sub > 0,
1346
- sup: sup > 0
1347
- });
1348
- };
1349
- for (const match of comment.matchAll(tagRegex())) {
1350
- const index = match.index ?? 0;
1351
- pushText(comment.slice(last, index));
1352
- last = index + match[0].length;
1353
- const tag = match[0].toLowerCase();
1354
- const closing = tag.startsWith("</");
1355
- const name = tag.replace(/[</>\s]/gu, "");
1356
- if (name === "br" || name === "div") {
1357
- if (!closing) tokens.push({
1358
- kind: "break",
1359
- text: "",
1360
- bold: false,
1361
- italic: false,
1362
- sub: false,
1363
- sup: false
1364
- });
1365
- continue;
1366
- }
1367
- const delta = closing ? -1 : 1;
1368
- if (name === "b") bold = Math.max(0, bold + delta);
1369
- else if (name === "i") italic = Math.max(0, italic + delta);
1370
- else if (name === "sub") sub = Math.max(0, sub + delta);
1371
- else if (name === "sup") sup = Math.max(0, sup + delta);
1372
- }
1373
- pushText(comment.slice(last));
1374
- while (tokens[0]?.kind === "break") tokens.shift();
1375
- while (tokens[tokens.length - 1]?.kind === "break") tokens.pop();
1376
- return tokens;
1377
- }
1378
- /** 去标签与换行,供插入草稿使用。 */
1379
- function commentPlain(comment) {
1380
- return comment.replace(tagRegex(), " ").replace(/\s+/gu, " ").trim();
1381
- }
1382
- /** 是否有可显示的内容(纯空白不算)。 */
1383
- function hasComment(comment) {
1384
- return commentPlain(comment) !== "";
1385
- }
1386
- //#endregion
1387
- //#region src/client/compose.ts
1388
- /** 整目录插入时最多列出多少条(完整清单交给模型的 MCP 工具)。 */
1389
- const COLLECTION_PREVIEW_LIMIT$1 = 50;
1390
- function line(t, key, value) {
1391
- return tpl(t(key), { value });
1392
- }
1393
- /** 单条目的引用文本。 */
1394
- function itemText(t, detail) {
1395
- const lines = [tpl(t("cmp.item.header"), {
1396
- key: detail.key,
1397
- title: detail.title
1398
- })];
1399
- if (detail.creators.length > 0) lines.push(line(t, "cmp.item.creators", detail.creators.join("、")));
1400
- if (detail.year !== "") lines.push(line(t, "cmp.item.year", detail.year));
1401
- if (detail.publicationTitle !== "") lines.push(line(t, "cmp.item.source", detail.publicationTitle));
1402
- if (detail.doi !== "") lines.push(line(t, "cmp.item.doi", detail.doi));
1403
- if (detail.url !== "") lines.push(line(t, "cmp.item.url", detail.url));
1404
- if (detail.tags.length > 0) lines.push(line(t, "cmp.item.tags", detail.tags.join("、")));
1405
- if (detail.abstract !== "") lines.push(line(t, "cmp.item.abstract", detail.abstract));
1406
- return lines.join("\n");
1407
- }
1408
- /** 选中片段的摘录文本。 */
1409
- function excerptText(t, detail, quote) {
1410
- return `${tpl(t("cmp.excerpt.header"), {
1411
- title: detail.title,
1412
- key: detail.key
1413
- })}\n${tpl(t("cmp.excerpt.quote"), { value: quote })}`;
1414
- }
1415
- /**
1416
- * PDF 抽取会在汉字之间插空格(`硫 化 氢`),展示与插入时去掉;
1417
- * 只处理汉字与汉字之间的空格,避免动到西文词距。
1418
- */
1419
- function tidyAnnotation(text) {
1420
- return text.replace(/\s+/gu, " ").replace(/(?<=[\u3400-\u9fff])\s+(?=[\u3400-\u9fff])/gu, "").trim();
1421
- }
1422
- /** 一条标注的引用文本:原文 + 类型 + 页码 + 评论 + 标注 key。 */
1423
- function annotationText(t, detail, annotation) {
1424
- const comment = commentPlain(annotation.comment);
1425
- const quote = tidyAnnotation(annotation.text) || comment;
1426
- const type = annotation.type === "underline" ? t("annotation.type.underline") : t("annotation.type.highlight");
1427
- const lines = [excerptText(t, detail, quote), tpl(t("cmp.annotation.type"), { value: type })];
1428
- if (annotation.pageLabel !== "") lines.push(tpl(t("cmp.annotation.page"), { value: annotation.pageLabel }));
1429
- if (comment !== "" && quote !== comment) lines.push(tpl(t("cmp.annotation.comment"), { value: comment }));
1430
- lines.push(tpl(t("cmp.annotation.key"), { value: annotation.key }));
1431
- return lines.join("\n");
1432
- }
1433
- /** 命名实体的最小集合(与 Host 清洗后的笔记 HTML 对齐)。 */
1434
- const NAMED_ENTITIES = {
1435
- nbsp: " ",
1436
- amp: String.fromCharCode(38),
1437
- lt: String.fromCharCode(60),
1438
- gt: String.fromCharCode(62),
1439
- quot: String.fromCharCode(34),
1440
- apos: String.fromCharCode(39)
1441
- };
1442
- /** 解码 HTML 实体;未识别的实体原样保留。 */
1443
- function decodeEntities(text) {
1444
- return text.replace(/&(#x[0-9a-f]+|#[0-9]+|[a-z]+);/giu, (match, body) => {
1445
- if (body.startsWith("#x") || body.startsWith("#X")) {
1446
- const code = Number.parseInt(body.slice(2), 16);
1447
- return Number.isFinite(code) ? String.fromCodePoint(code) : match;
1448
- }
1449
- if (body.startsWith("#")) {
1450
- const code = Number.parseInt(body.slice(1), 10);
1451
- return Number.isFinite(code) ? String.fromCodePoint(code) : match;
1452
- }
1453
- return NAMED_ENTITIES[body.toLowerCase()] ?? match;
1454
- });
1455
- }
1456
- /**
1457
- * 笔记 HTML → 纯文本:块级标签转换行、列表项加 `- `,剥标签后解码实体。
1458
- *
1459
- * 只保留段落与列表结构,图片等没有文本的可选内容自然消失。
1460
- */
1461
- function noteHtmlToText(html) {
1462
- return decodeEntities(html.replace(/<br\s*\/?>/giu, "\n").replace(/<\/(?:p|div|h[1-6]|blockquote|li|tr|ul|ol|table|figure|figcaption|pre)>/giu, "\n").replace(/<li\b[^>]*>/giu, "- ").replace(/<[^>]*>/gu, "")).replace(/\u00a0/gu, " ").replace(/[ \t]+/gu, " ").replace(/ *\n */gu, "\n").replace(/(^|\n)- *\n/gu, "$1- ").replace(/\n{2,}(?=- )/gu, "\n").replace(/\n{3,}/gu, "\n\n").trim();
1463
- }
1464
- /** 单条笔记的引用文本:所属条目 + 正文纯文本 + 截断提示 + 更新日期 + 笔记 key。 */
1465
- function noteText(t, detail, note) {
1466
- const head = tpl(t("cmp.note.header"), {
1467
- title: detail.title,
1468
- key: detail.key
1469
- });
1470
- const body = noteHtmlToText(note.html);
1471
- const lines = [head];
1472
- if (body !== "") lines.push(body);
1473
- if (note.truncated) lines.push(t("cmp.note.truncated"));
1474
- const date = note.dateModified.slice(0, 10);
1475
- if (date !== "") lines.push(tpl(t("cmp.note.date"), { value: date }));
1476
- lines.push(tpl(t("cmp.note.key"), { value: note.key }));
1477
- return lines.join("\n");
1478
- }
1479
- /** 整目录的引用文本(标题清单 + 稳定标识)。 */
1480
- function collectionText(t, collection, items, total) {
1481
- const head = tpl(t("cmp.collection.header"), {
1482
- name: collection.name,
1483
- key: collection.key,
1484
- n: total
1485
- });
1486
- const preview = items.slice(0, COLLECTION_PREVIEW_LIMIT$1);
1487
- const lines = preview.map((item) => {
1488
- const meta = [item.creators, item.year].filter((part) => part !== "").join(", ");
1489
- return tpl(t("cmp.collection.line"), {
1490
- title: item.title,
1491
- meta
1492
- });
1493
- });
1494
- if (total > preview.length) lines.push(tpl(t("cmp.collection.more"), { n: preview.length }));
1495
- return [head, ...lines].join("\n");
1496
- }
1497
- //#endregion
1498
1628
  //#region src/client/inline.ts
1499
1629
  /**
1500
1630
  * 捕获草稿当前位置,再构建文本并插入。
@@ -2633,82 +2763,93 @@ function ItemDetail({ t, detail, onInsertItem, onInsertExcerpt, onInsertAnnotati
2633
2763
  flexDirection: "column",
2634
2764
  padding: "2px 14px 14px"
2635
2765
  },
2636
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2637
- style: {
2638
- display: "flex",
2639
- alignItems: "center",
2640
- gap: 6,
2641
- marginBottom: 6
2642
- },
2643
- children: [
2644
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("h3", {
2645
- style: {
2646
- ...sectionTitleStyle,
2647
- margin: 0
2648
- },
2649
- children: [t(selfNote !== null ? "detail.noteBody" : "detail.fulltext"), bodyKey !== "" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2766
+ children: [
2767
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2768
+ style: {
2769
+ display: "flex",
2770
+ alignItems: "center",
2771
+ gap: 6,
2772
+ marginBottom: 6
2773
+ },
2774
+ children: [
2775
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("h3", {
2650
2776
  style: {
2651
- opacity: .55,
2652
- fontWeight: 400,
2653
- marginLeft: 8
2777
+ ...sectionTitleStyle,
2778
+ margin: 0
2654
2779
  },
2655
- children: bodyKey
2656
- })]
2657
- }),
2658
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { style: { flex: 1 } }),
2659
- selfNote !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
2660
- variant: "outline",
2661
- size: "sm",
2662
- onClick: () => onInsertNote(selfNote),
2663
- title: t("action.insertToChat"),
2664
- style: insertButtonStyle,
2665
- children: t("action.insertItemShort")
2666
- })
2667
- ]
2668
- }), !hasBody ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2669
- style: {
2670
- margin: 0,
2671
- opacity: .6
2672
- },
2673
- children: t("detail.noFulltext")
2674
- }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2675
- ref: boxRef,
2676
- onMouseUp: handleMouseUp,
2677
- style: selfNote === null ? textBodyStyle : noteBodyStyle,
2678
- children: [selfNote !== null ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2679
- className: "dsh-zotero-note",
2680
- dangerouslySetInnerHTML: { __html: selfNote.html }
2681
- }), selfNote.truncated && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2682
- style: truncatedHintStyle,
2683
- children: t("detail.noteTruncated")
2684
- })] }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(AnnotatedText, { segments }), fulltext?.truncated === true && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2685
- style: truncatedHintStyle,
2686
- children: t("detail.fulltextTruncated")
2687
- })] }), selection !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2688
- type: "button",
2689
- onMouseDown: (event) => event.preventDefault(),
2690
- onClick: () => {
2691
- onInsertExcerpt(selection.text);
2692
- window.getSelection()?.removeAllRanges();
2693
- setSelection(null);
2780
+ children: [t(selfNote !== null ? "detail.noteBody" : "detail.fulltext"), bodyKey !== "" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2781
+ style: {
2782
+ opacity: .55,
2783
+ fontWeight: 400,
2784
+ marginLeft: 8
2785
+ },
2786
+ children: bodyKey
2787
+ })]
2788
+ }),
2789
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { style: { flex: 1 } }),
2790
+ selfNote !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
2791
+ variant: "outline",
2792
+ size: "sm",
2793
+ onClick: () => onInsertNote(selfNote),
2794
+ title: t("action.insertToChat"),
2795
+ style: insertButtonStyle,
2796
+ children: t("action.insertItemShort")
2797
+ })
2798
+ ]
2799
+ }),
2800
+ fulltext?.fallback === true && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2801
+ style: {
2802
+ margin: "0 0 6px",
2803
+ opacity: .6,
2804
+ fontSize: 12
2694
2805
  },
2806
+ children: t("detail.fulltextFallback")
2807
+ }),
2808
+ !hasBody ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2695
2809
  style: {
2696
- position: "absolute",
2697
- left: selection.x,
2698
- top: selection.y,
2699
- transform: "translate(-50%, -130%)",
2700
- padding: "3px 8px",
2701
- fontSize: 12,
2702
- borderRadius: 6,
2703
- border: "1px solid rgba(127,127,127,0.35)",
2704
- background: "rgba(40,40,40,0.92)",
2705
- color: "#fff",
2706
- cursor: "pointer",
2707
- zIndex: 5
2810
+ margin: 0,
2811
+ opacity: .6
2708
2812
  },
2709
- children: t("action.insertExcerpt")
2710
- })]
2711
- })]
2813
+ children: t("detail.noFulltext")
2814
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2815
+ ref: boxRef,
2816
+ onMouseUp: handleMouseUp,
2817
+ style: selfNote === null ? textBodyStyle : noteBodyStyle,
2818
+ children: [selfNote !== null ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2819
+ className: "dsh-zotero-note",
2820
+ dangerouslySetInnerHTML: { __html: selfNote.html }
2821
+ }), selfNote.truncated && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2822
+ style: truncatedHintStyle,
2823
+ children: t("detail.noteTruncated")
2824
+ })] }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(AnnotatedText, { segments }), fulltext?.truncated === true && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2825
+ style: truncatedHintStyle,
2826
+ children: t("detail.fulltextTruncated")
2827
+ })] }), selection !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2828
+ type: "button",
2829
+ onMouseDown: (event) => event.preventDefault(),
2830
+ onClick: () => {
2831
+ onInsertExcerpt(selection.text);
2832
+ window.getSelection()?.removeAllRanges();
2833
+ setSelection(null);
2834
+ },
2835
+ style: {
2836
+ position: "absolute",
2837
+ left: selection.x,
2838
+ top: selection.y,
2839
+ transform: "translate(-50%, -130%)",
2840
+ padding: "3px 8px",
2841
+ fontSize: 12,
2842
+ borderRadius: 6,
2843
+ border: "1px solid rgba(127,127,127,0.35)",
2844
+ background: "rgba(40,40,40,0.92)",
2845
+ color: "#fff",
2846
+ cursor: "pointer",
2847
+ zIndex: 5
2848
+ },
2849
+ children: t("action.insertExcerpt")
2850
+ })]
2851
+ })
2852
+ ]
2712
2853
  })]
2713
2854
  }),
2714
2855
  hasBottom && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
@@ -2766,11 +2907,10 @@ const linkRowStyle = {
2766
2907
  * 右侧栏面板容器:头部状态栏 + 左分类树 + 右详情。
2767
2908
  *
2768
2909
  * 两栏之间是可拖动的分隔条(宽度存 localStorage,跨会话/重启都记住)。
2769
- * 数据与选择状态都在 {@link paneStore} 的模块级单例里(跨会话共用同一块面板);
2770
- * 「添加到会话」通过 ui-conversation 下发的会话级标准 prop `inputActions` 完成。
2910
+ * 数据与选择状态都在 {@link paneStore} 的模块级单例里(跨会话共用同一块面板)。
2911
+ * 「添加到会话」走 ui-conversation 下发的会话级标准 prop:条目与整目录插引用
2912
+ * chip(见 reference.ts),摘录 / 标注 / 笔记仍是纯文本插入。
2771
2913
  */
2772
- /** 整目录插入时拉取的条目数(与 compose 的预览上限一致)。 */
2773
- const COLLECTION_PREVIEW_LIMIT = 50;
2774
2914
  /** 左栏宽度的存储键与取值范围。 */
2775
2915
  const TREE_WIDTH_KEY = "dsh-plugin-zotero.treeWidth";
2776
2916
  const TREE_WIDTH_DEFAULT = 260;
@@ -2806,7 +2946,7 @@ function StatusDot({ ok, label }) {
2806
2946
  } }), label]
2807
2947
  });
2808
2948
  }
2809
- function ZoteroPane({ t, inputActions }) {
2949
+ function ZoteroPane({ t, inputActions, sessions, sessionId }) {
2810
2950
  const { health, libraryName, collections, treeError, treeLoading, query, results, selectedItemKey, selectedCollection, detail, detailLoading, detailError, collectionBib, nodeItems, nodeErrors, toast } = usePaneState();
2811
2951
  (0, react.useEffect)(() => {
2812
2952
  loadTree();
@@ -2847,16 +2987,24 @@ function ZoteroPane({ t, inputActions }) {
2847
2987
  else if (outcome === "no-editor") showToast(t("error.noEditor"));
2848
2988
  else showToast(t("error.draftChanged"));
2849
2989
  }, [t]);
2850
- const insertItem = (0, react.useCallback)(async (key) => {
2851
- report(await insertBuilt(inputActions, async () => {
2852
- return itemText(t, detail !== null && detail.key === key ? detail : await fetchItem(key));
2853
- }));
2990
+ /**
2991
+ * 插一个引用 chip:草稿里只留 key,完整文本在提交那一刻由引用源的 codec 现取。
2992
+ */
2993
+ const insertReference = (0, react.useCallback)((reference) => {
2994
+ if (!inputActions) {
2995
+ report("no-editor");
2996
+ return;
2997
+ }
2998
+ report(insertChip(sessions, sessionId, reference, inputActions.captureInsertion()) ? "inserted" : "draft-changed");
2854
2999
  }, [
2855
- detail,
2856
3000
  inputActions,
2857
3001
  report,
2858
- t
3002
+ sessionId,
3003
+ sessions
2859
3004
  ]);
3005
+ const insertItem = (0, react.useCallback)((key, title) => {
3006
+ insertReference(itemReference(key, title));
3007
+ }, [insertReference]);
2860
3008
  const insertExcerpt = (0, react.useCallback)(async (target, quote) => {
2861
3009
  report(await insertBuilt(inputActions, () => excerptText(t, target, quote)));
2862
3010
  }, [
@@ -2878,20 +3026,9 @@ function ZoteroPane({ t, inputActions }) {
2878
3026
  report,
2879
3027
  t
2880
3028
  ]);
2881
- const insertCollection = (0, react.useCallback)(async (collection) => {
2882
- report(await insertBuilt(inputActions, async () => {
2883
- const data = await fetchItems({
2884
- scope: collection.scope,
2885
- collectionKey: collection.scope === void 0 ? collection.key : void 0,
2886
- limit: COLLECTION_PREVIEW_LIMIT
2887
- });
2888
- return collectionText(t, collection, data.items, data.total);
2889
- }));
2890
- }, [
2891
- inputActions,
2892
- report,
2893
- t
2894
- ]);
3029
+ const insertCollection = (0, react.useCallback)((collection) => {
3030
+ insertReference(collectionReference(collection.key, collection.name));
3031
+ }, [insertReference]);
2895
3032
  /** 分类详情里的条目列表:与左侧树共用同一份缓存(选中分类时树已按需拉取)。 */
2896
3033
  const collectionItems = selectedCollection === null ? void 0 : nodeItems[selectedCollection.key];
2897
3034
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
@@ -2981,21 +3118,31 @@ function ZoteroPane({ t, inputActions }) {
2981
3118
  children: t("tree.empty")
2982
3119
  }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2983
3120
  style: { padding: "8px 6px" },
2984
- children: results.map((item) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2985
- onClick: () => openItem(item.key),
2986
- style: {
2987
- ...resultRowStyle,
2988
- background: selectedItemKey === item.key ? "rgba(127,127,127,0.16)" : "transparent"
2989
- },
2990
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2991
- style: resultTitleStyle,
2992
- title: item.title,
2993
- children: item.title
2994
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2995
- style: resultMetaStyle,
2996
- children: [item.creators, item.year].filter((p) => p !== "").join(" · ")
2997
- })]
2998
- }, item.key))
3121
+ children: results.map((item) => {
3122
+ const read = isRead(item);
3123
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3124
+ title: itemTooltip(t, item),
3125
+ onClick: () => openItem(item.key),
3126
+ style: {
3127
+ ...resultRowStyle,
3128
+ background: selectedItemKey === item.key ? "rgba(127,127,127,0.16)" : "transparent"
3129
+ },
3130
+ children: [
3131
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ReadDot, { read }),
3132
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3133
+ style: {
3134
+ ...resultTitleStyle,
3135
+ ...readTitleStyle(read)
3136
+ },
3137
+ children: item.title
3138
+ }),
3139
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3140
+ style: resultMetaStyle,
3141
+ children: [item.creators, item.year].filter((p) => p !== "").join(" · ")
3142
+ })
3143
+ ]
3144
+ }, item.key);
3145
+ })
2999
3146
  }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CollectionTree, {
3000
3147
  t,
3001
3148
  collections,
@@ -3003,8 +3150,8 @@ function ZoteroPane({ t, inputActions }) {
3003
3150
  selectedCollectionKey: selectedCollection?.key ?? null,
3004
3151
  onSelectItem: openItem,
3005
3152
  onSelectCollection: selectCollection,
3006
- onInsertItem: (key) => void insertItem(key),
3007
- onInsertCollection: (collection) => void insertCollection(collection)
3153
+ onInsertItem: (item) => insertItem(item.key, item.title),
3154
+ onInsertCollection: insertCollection
3008
3155
  })
3009
3156
  })]
3010
3157
  }),
@@ -3060,7 +3207,7 @@ function ZoteroPane({ t, inputActions }) {
3060
3207
  }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ItemDetail, {
3061
3208
  t,
3062
3209
  detail,
3063
- onInsertItem: () => void insertItem(detail.key),
3210
+ onInsertItem: () => insertItem(detail.key, detail.title),
3064
3211
  onInsertExcerpt: (quote) => void insertExcerpt(detail, quote),
3065
3212
  onInsertAnnotation: (annotation) => void insertAnnotation(detail, annotation),
3066
3213
  onInsertNote: (note) => void insertNote(detail, note),
@@ -3085,7 +3232,7 @@ function ZoteroPane({ t, inputActions }) {
3085
3232
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
3086
3233
  variant: "outline",
3087
3234
  size: "sm",
3088
- onClick: () => void insertCollection(selectedCollection),
3235
+ onClick: () => insertCollection(selectedCollection),
3089
3236
  children: t("action.insertCollection")
3090
3237
  }),
3091
3238
  selectedCollection.scope === void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
@@ -3121,18 +3268,28 @@ function ZoteroPane({ t, inputActions }) {
3121
3268
  margin: "16px 0 6px"
3122
3269
  },
3123
3270
  children: t("detail.items")
3124
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: collectionItems.map((item) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3125
- onClick: () => openItem(item.key),
3126
- style: resultRowStyle,
3127
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3128
- style: resultTitleStyle,
3129
- title: item.title,
3130
- children: item.title
3131
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3132
- style: resultMetaStyle,
3133
- children: [item.creators, item.year].filter((part) => part !== "").join(" · ")
3134
- })]
3135
- }, item.key)) })] })
3271
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: collectionItems.map((item) => {
3272
+ const read = isRead(item);
3273
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3274
+ title: itemTooltip(t, item),
3275
+ onClick: () => openItem(item.key),
3276
+ style: resultRowStyle,
3277
+ children: [
3278
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ReadDot, { read }),
3279
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3280
+ style: {
3281
+ ...resultTitleStyle,
3282
+ ...readTitleStyle(read)
3283
+ },
3284
+ children: item.title
3285
+ }),
3286
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3287
+ style: resultMetaStyle,
3288
+ children: [item.creators, item.year].filter((part) => part !== "").join(" · ")
3289
+ })
3290
+ ]
3291
+ }, item.key);
3292
+ }) })] })
3136
3293
  ]
3137
3294
  }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3138
3295
  style: hintStyle,
@@ -3195,7 +3352,11 @@ const resultMetaStyle = {
3195
3352
  *
3196
3353
  * 在右侧栏注册一个「页」类型 tab(不给 patterns,走 guide 入口),并把面板
3197
3354
  * 正文注册到 `sidebar.right.pane.tab` 席位。会话级标准 prop `inputActions`
3198
- * 由 ui-conversation 通过 `uiSession.provide` 下发,随槽位作用域透传给正文。
3355
+ * (ui-conversation 下发)与 `sessionId`(ui-session 下发)随槽位作用域透传给
3356
+ * 正文。
3357
+ *
3358
+ * 同时注册一个 Zotero 引用源(见 reference.ts):面板插的引用 chip 靠它的 codec
3359
+ * 在提交时展开成模型文本。它不进 `@` 菜单(候选恒空)。
3199
3360
  *
3200
3361
  * 注意:cordis 的对象式 inject 是「拦截 config」,不是 {required,optional},
3201
3362
  * 因此这里用数组式 inject。
@@ -3207,7 +3368,9 @@ const inject = [
3207
3368
  "slots",
3208
3369
  "locale",
3209
3370
  "sidebarRightTabs",
3210
- "configForms"
3371
+ "configForms",
3372
+ "inputTriggers",
3373
+ "sessions"
3211
3374
  ];
3212
3375
  function apply(ctx) {
3213
3376
  ctx.effect(() => ctx.locale.register(NS, dicts), "dsh-plugin-zotero: dictionaries");
@@ -3223,9 +3386,12 @@ function apply(ctx) {
3223
3386
  order: 10
3224
3387
  }]
3225
3388
  }), "dsh-plugin-zotero: sidebar tab");
3389
+ ctx.effect(() => ctx.inputTriggers.registerSource(createZoteroSource(t)), "dsh-plugin-zotero: reference codec");
3226
3390
  const Body = (props) => (0, react.createElement)(ZoteroPane, {
3227
3391
  t,
3228
- inputActions: props.inputActions
3392
+ sessions: ctx.sessions,
3393
+ inputActions: props.inputActions,
3394
+ sessionId: props.sessionId
3229
3395
  });
3230
3396
  ctx.effect(() => ctx.slots.register({
3231
3397
  name: "sidebar.right.pane.tab",
@@ -32,11 +32,53 @@ function blocksToText(content) {
32
32
  })
33
33
  .join('\n');
34
34
  }
35
+ /**
36
+ * 写工具判定:集成 MCP 里所有会改库的工具名都以这些动词开头
37
+ * (`write_item` / `create_collection` / `add_by_identifier` / `remove_items_from_collection` …)。
38
+ */
39
+ const WRITE_TOOL_RE = /^(write|add|create|update|delete|remove)_/i;
40
+ /** 破坏性写工具:删除/移除类,需要额外的确认提示。 */
41
+ const DESTRUCTIVE_TOOL_RE = /^(delete|remove)_/i;
42
+ /**
43
+ * 注入到写工具描述前面的引导语。
44
+ *
45
+ * 背景:Zotero 的本地 API(23119)写接口必须先用 `POST /api/local/authorize`
46
+ * 换一个 key,而该端点**每次调用都会弹授权框**、且不像应用名复用;模型若绕开
47
+ * MCP 手写 curl,就会每次写都让用户点一次「允许」。集成 MCP 的写工具在 Zotero
48
+ * 进程内直接改库,完全不触发这套授权,因此这里明确把 MCP 标成首选通道。
49
+ *
50
+ * 注意措辞是「优先」而不是「禁止」:集成 MCP 某些场景确实可能失败,必须给模型
51
+ * 留下降级空间,否则它会在报错后继续硬试或改用更糟的方式。
52
+ */
53
+ const WRITE_PREFIX = '[首选写通道] 本工具在 Zotero 进程内执行,不会触发本地 API 授权弹窗。写 Zotero 优先用它。' +
54
+ '仅当本工具不可用或调用失败时再考虑其他方式;不要直接用 shell/curl 访问 http://127.0.0.1:23119,' +
55
+ '那会每次都弹出「本地 API 授权」框让用户点允许。';
56
+ /** 针对「导入本地文件挂到条目下」这一高频场景,直接点明参数组合,省得模型去猜。 */
57
+ const WRITE_ITEM_HINT = '「导入 PDF/文件并挂到某个条目下」用本工具:action=import、filePath=<文件绝对路径>、parentItemKey=<目标条目 key>,title 可选。';
58
+ /** 按标识符入库优先走 Zotero 自带解析器,元数据比模型手填准确。 */
59
+ const IDENTIFIER_HINT = '「按 DOI/arXiv/ISBN/PMID 入库」优先用本工具,它调用 Zotero 自带的元数据解析器,比手填字段准确。';
60
+ const DESTRUCTIVE_HINT = '[破坏性写操作] 执行前必须先与用户确认要操作的具体条目/分类,不要凭推断批量删除或移除。';
61
+ /** 在不改动上游对象的前提下,给写工具的描述拼上引导语。 */
62
+ function descriptionFor(tool) {
63
+ const parts = [];
64
+ if (DESTRUCTIVE_TOOL_RE.test(tool.name))
65
+ parts.push(DESTRUCTIVE_HINT);
66
+ if (WRITE_TOOL_RE.test(tool.name))
67
+ parts.push(WRITE_PREFIX);
68
+ if (tool.name === 'write_item')
69
+ parts.push(WRITE_ITEM_HINT);
70
+ if (tool.name === 'add_by_identifier')
71
+ parts.push(IDENTIFIER_HINT);
72
+ const base = tool.description ?? '';
73
+ if (parts.length === 0)
74
+ return base;
75
+ return `${parts.join('\n\n')}\n\n${base}`;
76
+ }
35
77
  /** 由 MCP 工具造一条 dsh 工具定义(参数直接沿用上游 JSON Schema)。 */
36
78
  function definitionFor(tool) {
37
79
  return {
38
80
  name: publicName(tool.name),
39
- description: tool.description,
81
+ description: descriptionFor(tool),
40
82
  parameters: tool.parameters,
41
83
  output: {
42
84
  schema: {
@@ -45,6 +45,8 @@ interface RawItemData {
45
45
  note?: string;
46
46
  /** 标注所属附件,仅 `itemType === 'annotation'` 有。 */
47
47
  parentItem?: string | false;
48
+ /** 附件最后阅读时间(Unix 秒);本地 API 在附件 JSON 里直接给出。 */
49
+ lastRead?: number;
48
50
  annotationType?: string;
49
51
  annotationText?: string;
50
52
  annotationComment?: string;
@@ -173,7 +173,7 @@ function toNote(raw) {
173
173
  truncated,
174
174
  };
175
175
  }
176
- function toSummary(raw) {
176
+ function toSummary(raw, lastRead) {
177
177
  const data = raw.data ?? {};
178
178
  const itemType = data.itemType ?? '';
179
179
  const hasAttachment = itemType === 'attachment'
@@ -193,8 +193,24 @@ function toSummary(raw) {
193
193
  year: yearOf(raw.meta, data),
194
194
  itemType,
195
195
  hasAttachment,
196
+ lastRead,
196
197
  };
197
198
  }
199
+ /** 附件自己的 `lastRead` 就在它的 JSON 里,笔记没有,其余条目去问子附件。 */
200
+ function lastReadOf(raw) {
201
+ const data = raw.data ?? {};
202
+ if (data.itemType === 'attachment') {
203
+ const value = data.lastRead;
204
+ return Promise.resolve(typeof value === 'number' && value > 0 ? value : null);
205
+ }
206
+ if (data.itemType === 'note')
207
+ return Promise.resolve(null);
208
+ return itemLastRead(raw.key);
209
+ }
210
+ /** 列表归一化:已读状态并发取,单条失败按未读(不拖垮整页)。 */
211
+ async function toSummaries(raws) {
212
+ return Promise.all(raws.map(async (raw) => toSummary(raw, await lastReadOf(raw))));
213
+ }
198
214
  /** 从库名 `library.name` 或条目数据里取文库名(缺省回退)。 */
199
215
  function libraryNameOf(raw) {
200
216
  const first = raw[0];
@@ -327,6 +343,42 @@ export async function listCollections() {
327
343
  const UNFILED_SCAN_MAX = 1000;
328
344
  /** 一页扫描条数(本地 API 上限 100)。 */
329
345
  const PAGE_SIZE = 100;
346
+ // ---- 已读状态 ---------------------------------------------------------------
347
+ /** 已读状态缓存时长:`lastRead` 由 Zotero 阅读器写入,分钟级刷新足够。 */
348
+ const READ_STATE_TTL_MS = 60_000;
349
+ /** 单条已读状态缓存的上限;超了就整体丢弃(重新查一遍即可)。 */
350
+ const READ_STATE_CACHE_MAX = 5000;
351
+ const readStateCache = new Map();
352
+ /**
353
+ * 条目(父条目)的最晚阅读时间(Unix 秒),`null` 表示没读过。
354
+ *
355
+ * 已读状态只记在附件上,父条目要问它的子附件(原生 `getItemLastRead()` 同理)。
356
+ * 按条目查而不是扫全库:单条约 6ms,只查当前列表里的条目,大口库也不会卡。
357
+ * 取不到按未读处理——已读标志是附加信息,不能拖垮条目列表。
358
+ */
359
+ async function itemLastRead(key) {
360
+ const cached = readStateCache.get(key);
361
+ if (cached !== undefined && Date.now() - cached.at < READ_STATE_TTL_MS)
362
+ return cached.lastRead;
363
+ try {
364
+ const { body } = await requestJson(`${libraryBase()}/items/${encode(key)}/children?itemType=attachment`);
365
+ let lastRead = null;
366
+ for (const child of Array.isArray(body) ? body : []) {
367
+ const value = child.data?.lastRead;
368
+ if (typeof value !== 'number' || value <= 0)
369
+ continue;
370
+ if (lastRead === null || value > lastRead)
371
+ lastRead = value;
372
+ }
373
+ if (readStateCache.size >= READ_STATE_CACHE_MAX)
374
+ readStateCache.clear();
375
+ readStateCache.set(key, { at: Date.now(), lastRead });
376
+ return lastRead;
377
+ }
378
+ catch {
379
+ return null;
380
+ }
381
+ }
330
382
  /** 把 options 折成「顶层条目」端点基址 + 查询参数。 */
331
383
  function itemListQuery(options) {
332
384
  const base = options.scope === 'publications'
@@ -356,12 +408,13 @@ async function listUnfiled(offset, limit) {
356
408
  break;
357
409
  for (const raw of body) {
358
410
  if ((raw.data?.collections ?? []).length === 0)
359
- all.push(toSummary(raw));
411
+ all.push(raw);
360
412
  }
361
413
  if (body.length < PAGE_SIZE)
362
414
  break;
363
415
  }
364
- return { total: all.length, items: all.slice(offset, offset + limit) };
416
+ const page = all.slice(offset, offset + limit);
417
+ return { total: all.length, items: await toSummaries(page) };
365
418
  }
366
419
  /** 顶层条目列表(按虚拟分类、真实分类、或全库,或关键字搜索)。 */
367
420
  export async function listItems(options) {
@@ -369,8 +422,8 @@ export async function listItems(options) {
369
422
  return listUnfiled(options.offset, options.limit);
370
423
  const { base, params } = itemListQuery(options);
371
424
  const { body, total } = await requestJson(`${base}?${params.toString()}`);
372
- const items = Array.isArray(body) ? body.map(toSummary) : [];
373
- return { total: total ?? items.length, items };
425
+ const raws = Array.isArray(body) ? body : [];
426
+ return { total: total ?? raws.length, items: await toSummaries(raws) };
374
427
  }
375
428
  /** 子条目(附件 / 笔记)。 */
376
429
  export async function getItemChildren(key) {
@@ -450,8 +503,24 @@ export async function getItemFulltext(attachmentKey) {
450
503
  attachmentKey,
451
504
  content: truncated ? content.slice(0, maxBytes) : content,
452
505
  truncated,
506
+ fallback: false,
453
507
  };
454
508
  }
509
+ /**
510
+ * 依次尝试候选附件的全文,返回第一份可用的。
511
+ *
512
+ * 条目常同时挂原文与中文译本:译本若尚未建索引(`/fulltext` 404),
513
+ * 不能直接判定整条无全文,应回退到原文等其他附件。
514
+ */
515
+ async function getFirstFulltext(candidates) {
516
+ const preferredKey = candidates[0]?.key ?? '';
517
+ for (const attachment of candidates) {
518
+ const fulltext = await getItemFulltext(attachment.key);
519
+ if (fulltext !== null)
520
+ return { ...fulltext, fallback: attachment.key !== preferredKey };
521
+ }
522
+ return null;
523
+ }
455
524
  /** 单条条目的 CSL HTML(`format=bib`);失败返回 null。 */
456
525
  export async function getItemBib(key, style) {
457
526
  try {
@@ -478,11 +547,15 @@ export async function getItemDetail(key, style) {
478
547
  // 笔记是子条目(itemType=note);条目本身就是笔记时(独立笔记),正文即自身。
479
548
  const childNotes = children.filter((c) => c.data?.itemType === 'note');
480
549
  const notes = (itemType === 'note' ? [raw] : childNotes).map(toNote);
481
- const readable = isAttachment
482
- ? raw
483
- : childAttachments.find((c) => c.data?.contentType === 'application/pdf') ?? childAttachments[0];
550
+ // 候选顺序:PDF 优先,其余附件随后;逐份尝试直到拿到全文。
551
+ const candidates = isAttachment
552
+ ? [raw]
553
+ : [
554
+ ...childAttachments.filter((c) => c.data?.contentType === 'application/pdf'),
555
+ ...childAttachments.filter((c) => c.data?.contentType !== 'application/pdf'),
556
+ ];
484
557
  const [fulltext, bib] = await Promise.all([
485
- readable ? getItemFulltext(readable.key) : Promise.resolve(null),
558
+ getFirstFulltext(candidates),
486
559
  getItemBib(key, style),
487
560
  ]);
488
561
  // 展示顺序:当前附件的标注排前,同附件内按 PDF 位置(annotationSortIndex 零填充,可字典序比较)。
@@ -31,6 +31,11 @@ export interface ZoteroItemSummary {
31
31
  itemType: string;
32
32
  /** 是否有可读附件(决定详情里能否取全文)。 */
33
33
  hasAttachment: boolean;
34
+ /**
35
+ * 子附件里最晚的阅读时间(Unix **秒**),与 Zotero 原生 `getItemLastRead()` 一致;
36
+ * `null` 表示从未读过。Zotero 不记录读到第几页,只有这一个「读过没有」的信号。
37
+ */
38
+ lastRead: number | null;
34
39
  }
35
40
  /** 条目下的一个附件。 */
36
41
  export interface ZoteroAttachment {
@@ -105,6 +110,8 @@ export interface ZoteroFulltext {
105
110
  attachmentKey: string;
106
111
  content: string;
107
112
  truncated: boolean;
113
+ /** 首选附件没有全文索引,正文取自同条目的其他附件。 */
114
+ fallback: boolean;
108
115
  }
109
116
  /** 探活结果。 */
110
117
  export interface ZoteroHealth {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-plugin-zotero",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "description": "Install this plugin and DSH can operate your Zotero for you: search the library, read PDF full text, summarize highlights and notes, organize collections by topic, import your downloaded papers, and attach a translated version back to an item. The right sidebar also gains a Zotero library panel that brings an item, an excerpt or a whole collection into the conversation with one click.",
5
5
  "keywords": [
6
6
  "dsh",
@@ -35,20 +35,14 @@
35
35
  "engines": {
36
36
  "dsh": ">=0.2.1-rc.3 <0.3.0-0"
37
37
  },
38
- "scripts": {
39
- "build": "tsc -p tsconfig.json",
40
- "build:client": "tsdown",
41
- "typecheck:client": "tsc -p tsconfig.client.json --noEmit",
42
- "prepack": "pnpm build && pnpm build:client"
43
- },
44
38
  "peerDependencies": {
45
39
  "@deepseek-ai/cordis": "^4.0.5",
46
40
  "@deepseek-ai/schemastery": "^3.18.5"
47
41
  },
48
42
  "devDependencies": {
49
43
  "@deepseek-ai/cordis": "^4.0.5",
50
- "@deepseek-ai/dsh": "0.2.1-rc.3",
51
- "@deepseek-ai/dsh-tools": "0.2.1-rc.3",
44
+ "@deepseek-ai/dsh": "0.2.1-rc.5",
45
+ "@deepseek-ai/dsh-tools": "0.2.1-rc.5",
52
46
  "@deepseek-ai/schemastery": "3.18.5",
53
47
  "@types/node": "^24.19.2",
54
48
  "@types/react": "~18.3.1",
@@ -70,5 +64,10 @@
70
64
  ],
71
65
  "platform": "web"
72
66
  }
67
+ },
68
+ "scripts": {
69
+ "build": "tsc -p tsconfig.json",
70
+ "build:client": "tsdown",
71
+ "typecheck:client": "tsc -p tsconfig.client.json --noEmit"
73
72
  }
74
73
  }