dsh-cite 0.9.4 → 0.10.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # 更新记录
2
2
 
3
+ ## 0.10.0 (2026-11-18)
4
+
5
+ - 新增文献条目安全删除(`remove` 操作,支持单条与批量删除、二次确认弹窗、修订号 `409` 冲突保护与孤立原始源清理,删除后可干净重导)。
6
+ - 打通「DOI 核查 → 一键送入导入预览」流转,导入页新增「填入示例 DOI / BibTeX」零门槛按钮,并补充可折叠四步论文引用工作流与一键复制对话指令。
7
+ - Add atomic citation removal (`remove` action/operation with single & batch delete confirmation, `409` revision guards, and orphan source pruning).
8
+ - Add 1-click verified-DOI handoff from DOI Check to Import preview, a sample BibTeX/DOI starter button, and a collapsible 4-step workflow guide with copyable chat prompt chips.
9
+
3
10
  ## 0.9.4 (2026-11-18)
4
11
 
5
12
  - 更新区底部新增克制、无打扰的 GitHub 点赞与问题反馈快捷链接,并完善中英文检索关键词。
package/README.en.md CHANGED
@@ -22,9 +22,10 @@ Built for DeepSeek Harness `>=0.2.2-rc.3`, with five switchable light/warm workb
22
22
 
23
23
  ## Features
24
24
 
25
- - Filter, search, and inspect references in a three-pane library, copy formatted citations or BibTeX entries, and inspect raw records in a native modal.
26
- - Preview duplicates and missing fields locally before importing a DOI list or BibTeX.
27
- - Check manuscript DOIs against Crossref, or fill gaps in saved references and review differences.
25
+ - Filter, search, and inspect references in a three-pane library, copy formatted citations or BibTeX entries, inspect raw records in a native modal, and safely remove single or selected entries with revision-conflict protection.
26
+ - Preview duplicates and missing fields locally before importing a DOI list or BibTeX, with a 1-click **Fill sample BibTeX / DOI** starter.
27
+ - Check manuscript DOIs against Crossref (and send verified DOIs directly to Import preview in 1 click), or fill gaps in saved references and review differences.
28
+ - Expand the compact **How it works: 4-step citation workflow** bar at the top of the workbench to copy ready-to-send DSH chat prompts.
28
29
  - Export selected references or the entire library. Download a full backup with the original sources.
29
30
  - Switch between five workbench styles (Harness Native, Cream Paper, Claude Warm, 8-Bit Pixel, Mint Air) synced to portaled dialogs and menus, adapted to DSH `>=0.2.2-rc.3` host primitives and frame clearances.
30
31
 
@@ -47,14 +48,18 @@ For the web profile, replace `desktop` with `web`. Restart that DSH profile afte
47
48
  <img src="https://raw.githubusercontent.com/STARDUSTLC666/dsh-cite/master/docs/assets/intro/workflow-en-light.svg" alt="Turn scattered DOIs and BibTeX into a reference library. · workflow illustration" width="100%">
48
49
  </picture>
49
50
 
50
- 1. Open Citations in the sidebar and prepare DOI entries or a BibTeX file.
51
- 2. Preview the import locally; inspect entries, duplicates and fields before saving selected references.
52
- 3. Select entries and explicitly request Crossref enrichment when needed, then review the returned fields.
53
- 4. Select references, export a bibliography or BibTeX, and download a library backup when needed.
51
+ ### Typical workflow: from finding papers to final bibliography
54
52
 
55
- Example request:
53
+ 1. **Check your draft or load a sample**: Open **Reference library** in the sidebar. Paste manuscript text in **DOI check** to verify DOIs against Crossref and click **Send to Import preview** to carry valid DOIs over—or click **Fill sample BibTeX / DOI** in **Import** to test the flow immediately.
54
+ 2. **Preview & deduplicate locally**: Run **Local preview** offline to catch library duplicates, repeated batch DOIs, and missing fields before saving selected references.
55
+ 3. **Enrich & clean up**: Select entries in **Library** to run **Crossref enrichment** (preserving local edits and highlighting differences), or click **Remove** to delete unwanted/duplicate entries with confirmation and revision protection.
56
+ 4. **Format & back up for submission**: Switch between `GB/T 7714`, `APA`, `MLA`, and `Chicago` to copy formatted citations, or open **Export** to download `.bib`, `.txt`, and full `.json` source backups.
56
57
 
57
- > Look up these DOI records and highlight fields I should verify.
58
+ You can also expand the workflow bar inside the workbench to copy ready-made DSH chat prompts in one click:
59
+
60
+ - `Use cite_check to verify every DOI in my draft below against Crossref and list any missing or invalid references:`
61
+ - `Read my local citation library (cite_batch list) and format a clean GB/T 7714 bibliography, noting any missing fields.`
62
+ - `Read my local citation library (cite_batch list), format the bibliography in APA style, and check year, volume, and page completeness.`
58
63
 
59
64
  ## Before you start
60
65
 
package/README.md CHANGED
@@ -22,9 +22,10 @@
22
22
 
23
23
  ## 功能
24
24
 
25
- - 在三栏文献库筛选、搜索和查看文献,复制引文或 BibTeX,并在详情中弹出查看原始题录来源。
26
- - 导入 DOI 列表或 BibTeX 前,在本地预览重复项与缺失字段。
27
- - 通过 Crossref 核查文稿中的 DOI,或补全已存文献的空字段并查看差异。
25
+ - 在三栏文献库筛选、搜索和查看文献,复制引文或 BibTeX,在详情弹窗查看原始题录来源,并支持带版本冲突保护的单条/批量删除。
26
+ - 导入 DOI 列表或 BibTeX 前,支持一键填入示例题录,并在本地预览重复项与缺失字段。
27
+ - 通过 Crossref 核查文稿中的 DOI(核查通过后可一键送入导入预览),或补全已存文献的空字段并查看差异。
28
+ - 工作台顶部内置可折叠「4 步管理论文引用」指南与一键复制的对话指令标签。
28
29
  - 导出所选文献或全库引文,下载包含原始来源的完整备份。
29
30
  - 内置 5 套工作台视觉风格(原生清透 / 米白纸感 / Claude 暖书卷 / 8-Bit 像素 / 晴空薄荷),同步至弹层菜单与弹窗,适配 DSH `>=0.2.2-rc.3` 宿主控件与窗口留白。
30
31
 
@@ -47,14 +48,18 @@ dsh plugin --profile desktop add dsh-cite
47
48
  <img src="https://raw.githubusercontent.com/STARDUSTLC666/dsh-cite/master/docs/assets/intro/workflow-zh-light.svg" alt="把零散 DOI 和 BibTeX 整理成可用的文献库。 · 流程示意" width="100%">
48
49
  </picture>
49
50
 
50
- 1. 从左侧栏打开“引文库”,准备 DOI 列表或 BibTeX 文件。
51
- 2. 先做本地导入预览,检查条目、重复项和字段,再保存选中的文献。
52
- 3. 需要联网补全时,选择条目后主动执行 Crossref 补全,核对返回字段。
53
- 4. 选择要引用的文献,导出参考文献或 BibTeX,并按需要下载文献库备份。
51
+ ### 典型使用流程:从查文献到定稿排版
54
52
 
55
- 可以这样说:
53
+ 1. **核查初稿或试水示例**:从左侧栏打开「引文库」。若手上已有论文初稿,切到「DOI 核查」粘贴文稿校验真伪,核查通过的 DOI 可点**「送入导入预览」**一键带入;首次体验也可直接在「导入预览」点**「填入示例 DOI / BibTeX」**。
54
+ 2. **本地预览去重后入库**:点击「本地预览」,离线检查库内重复、同批重复与缺失字段,勾选确认无误的文献保存入库。
55
+ 3. **Crossref 补全与清理误导入**:在「引文库」勾选缺字段条目执行「Crossref 补全」(保留本地已有值并对比差异);若导入了错误或多余文献,可在详情栏或批量栏点击「删除」并在弹窗确认移除。
56
+ 4. **一键定稿排版与来源备份**:切换 `GB/T 7714`、`APA`、`MLA` 或 `Chicago` 直接复制标准引文,或在「导出备份」下载 `.bib`、参考文献文本与含原始输入的完整 `.json` 备份。
56
57
 
57
- > 帮我查询这些 DOI 的题录信息,并指出需要人工核对的字段。
58
+ 工作台顶部可展开「怎么用最顺手:4 步管理论文引用」,点击指令气泡即可复制给 DSH 对话助手,例如:
59
+
60
+ - `请用 cite_check 核查我这段论文初稿中的所有 DOI 是否在 Crossref 真实存在,并列出缺失或异常条目:`
61
+ - `请读取我的本地引文库(cite_batch list),按 GB/T 7714 格式整理成可直接粘贴到论文末尾的参考文献列表,并提醒字段缺失项。`
62
+ - `请读取我的本地引文库(cite_batch list),按 APA 格式输出参考文献列表,并检查年份、卷期和页码是否完整。`
58
63
 
59
64
  ## 开始前要知道
60
65
 
package/docs/USAGE.en.md CHANGED
@@ -33,9 +33,9 @@ Local BibTeX parsing uses Citation.js, including macros, nested braces, literal
33
33
  | `cite_bibtex` | Generate a BibTeX entry | `doi`; `key` optional |
34
34
  | `cite_check` | Extract DOIs from text and validate them | `text`; `maxChecks` 1-50, default 10 |
35
35
  | `cite_health` | Self-check: probe Crossref connectivity and report latency | none |
36
- | `cite_batch` | Local library shared with the settings page | `action`: list / preview / import / enrich / job / cancel / export |
36
+ | `cite_batch` | Local library shared with the settings page | `action` (or `operation`): list / preview / import / enrich / remove / job / cancel / export |
37
37
 
38
- `preview` accepts `kind: doi / bibtex`, `text` and optional `label`, returning a preview ID and zero-based row indices. `import` accepts that `preview` and a `selection` array. `enrich` accepts saved entry `ids` and the current `revision`, returning a job ID; use `job` / `cancel` to inspect or cancel it. `export` accepts `kind: bibtex / references / backup`, optional `style` / `lang`, and optional entry `ids`; full backups cannot be scoped to a selection.
38
+ `preview` accepts `kind: doi / bibtex`, `text` and optional `label`, returning a preview ID and zero-based row indices. `import` accepts that `preview` and a `selection` array. `enrich` accepts saved entry `ids` and the current `revision`, returning a job ID; use `job` / `cancel` to inspect or cancel it. `remove` deletes entries atomically by `id`, unique `citekey`, or `ids` with `expectedRevision` conflict protection. `export` accepts `kind: bibtex / references / backup`, optional `style` / `lang`, and optional entry `ids`; full backups cannot be scoped to a selection.
39
39
 
40
40
  ## Network and data
41
41
 
package/docs/USAGE.md CHANGED
@@ -35,9 +35,9 @@ BibTeX 解析使用 Citation.js 的本地解析器,支持宏、嵌套括号、
35
35
  | `cite_bibtex` | 生成 BibTeX 条目 | `doi` 必填;`key` 可选 |
36
36
  | `cite_check` | 从文本提取 DOI 并并发校验是否存在(并发 3,保持输入顺序) | `text` 必填;`maxChecks` 1-50 默认 10 |
37
37
  | `cite_health` | 自检:探测 Crossref 连通性并报告延迟 | 无 |
38
- | `cite_batch` | 本地文献工作台,与设置页共用文献库 | `action`:list / preview / import / enrich / job / cancel / export |
38
+ | `cite_batch` | 本地文献工作台,与设置页共用文献库 | `action`(或 `operation`):list / preview / import / enrich / remove / job / cancel / export |
39
39
 
40
- `cite_batch` 的 `preview` 接受 `kind: doi / bibtex`、`text` 和可选 `label`;返回预览编号和零起始行编号。`import` 接受 `preview` 与 `selection` 数组。`enrich` 接受已保存条目的 `ids` 与当前 `revision`,返回 `job` 编号;用 `job` / `cancel` 操作查询或取消。`export` 的 `kind` 为 bibtex / references / backup,可指定 `style`、`lang`;条目选择为可选 `ids`,完整备份不得附带选择。
40
+ `cite_batch` 的 `preview` 接受 `kind: doi / bibtex`、`text` 和可选 `label`;返回预览编号和零起始行编号。`import` 接受 `preview` 与 `selection` 数组。`enrich` 接受已保存条目的 `ids` 与当前 `revision`,返回 `job` 编号;用 `job` / `cancel` 操作查询或取消。`remove` 支持按单条 `id`、`citekey`(唯一匹配时生效)或批量 `ids` 配合 `expectedRevision` 冲突保护原子删除条目。`export` 的 `kind` 为 bibtex / references / backup,可指定 `style`、`lang`;条目选择为可选 `ids`,完整备份不得附带选择。
41
41
 
42
42
  ## 安装
43
43
 
package/docs/WORKBENCH.md CHANGED
@@ -36,7 +36,7 @@ Edit the template sources and run pnpm run build. Commit generated lib/client.js
36
36
 
37
37
  ## 验收范围 / Validation boundary
38
38
 
39
- 2026-10-25:Windows、官方 DSH 0.2.1-rc.3 Web,后台 Chrome/Playwright 实际点击和输入;覆盖中英文、浅深色、1536px 与 390px、状态读回与控制台。Browser plugin 不可用,因此使用本地 Playwright。
39
+ 当前版本要求宿主 DSH `>=0.2.2-rc.3`。工作台顶部内置可折叠「4 步管理论文引用」指南与一键复制的对话指令,文献库支持带修订冲突保护的单条与批量确认删除。历史回归基线:Windows 后台 Chrome/Playwright 实际点击和输入;覆盖中英文、浅深色、1536px 与 390px、状态读回与控制台。Browser plugin 不可用,因此使用本地 Playwright。
40
40
 
41
41
  邮件使用受控 AgentMail HTTP 服务,日历使用受控 CalDAV 协议传输;插件处理器、存储、校验和原生宿主均实际运行。未使用真实邮箱、真实日历账号或付费模型。RSS 访问 Node.js 官方公开来源。PPT 实际生成并渲染 PPTX、下载 ZIP;两个视频插件实际运行官方引擎并播放 MP4。
42
42
 
@@ -20,8 +20,18 @@ export function englishCitationError(raw) {
20
20
  return 'Crossref returned a different DOI. The local entry was preserved.';
21
21
  if (/已取消|解析已取消/.test(raw))
22
22
  return 'Cancelled. This job did not write its enrichment into the library.';
23
+ if (/另一窗口更新.*未执行删除/.test(raw))
24
+ return 'The library changed elsewhere, so nothing was removed. Refresh the library and confirm again.';
23
25
  if (/另一窗口更新|已更新|DOI 已存在/.test(raw))
24
26
  return 'The library changed elsewhere. Your input is retained. Refresh and preview again before saving.';
27
+ if (/请提供要删除的文献/.test(raw))
28
+ return 'Specify a reference id or citation key to remove.';
29
+ if (/引用键匹配多条文献/.test(raw))
30
+ return 'Multiple references share this citation key. Specify the reference id to remove.';
31
+ if (/id 与引用键不匹配/.test(raw))
32
+ return 'The reference id does not match the given citation key. Refresh and verify before removing.';
33
+ if (/当前文献库修订号/.test(raw))
34
+ return 'Provide the current library revision before saving or removing.';
25
35
  if (/预览已过期/.test(raw))
26
36
  return 'The preview expired or DSH restarted. Your input is retained; preview it again.';
27
37
  if (/文献库记录损坏|文献库文件无效/.test(raw))
@@ -94,6 +94,33 @@ export declare class CitationWorkbench {
94
94
  job(id: unknown): EnrichmentJob;
95
95
  cancel(id: unknown): EnrichmentJob;
96
96
  dispose(): void;
97
+ private exportedBibKeys;
98
+ remove(rawTarget: unknown, rawRevision?: unknown, signal?: AbortSignal): Promise<{
99
+ removed: number;
100
+ removedIds: string[];
101
+ revision: number;
102
+ entries: {
103
+ warnings: string[];
104
+ id: string;
105
+ work: Work;
106
+ bibKey: string;
107
+ sourceIds: string[];
108
+ createdAt: string;
109
+ updatedAt: string;
110
+ crossref?: {
111
+ doi: string;
112
+ fetchedAt: string;
113
+ filled: string[];
114
+ conflicts: FieldConflict[];
115
+ };
116
+ }[];
117
+ sources: {
118
+ id: string;
119
+ createdAt: string;
120
+ kind: "doi" | "bibtex";
121
+ label: string;
122
+ }[];
123
+ }>;
97
124
  private check;
98
125
  export(kind: unknown, style: unknown, lang: unknown, rawIds?: unknown): Promise<{
99
126
  filename: string;
@@ -194,6 +194,94 @@ export class CitationWorkbench {
194
194
  j.controller.abort(); return structuredClone(j.view); }
195
195
  dispose() { this.lifetime.abort(new Error('插件已卸载。')); for (const j of this.jobs.values())
196
196
  j.controller.abort(); }
197
+ exportedBibKeys(entries) {
198
+ const keys = new Map(), used = new Set();
199
+ for (const e of entries) {
200
+ const base = e.bibKey.replace(/[^A-Za-z0-9_.:\/-]+/g, '_').replace(/^_+|_+$/g, '') || 'work';
201
+ let key = base, n = 0;
202
+ while (used.has(key))
203
+ key = base + '-' + e.id.slice(0, 8) + (n++ ? '-' + n : '');
204
+ used.add(key);
205
+ keys.set(e.id, key);
206
+ }
207
+ return keys;
208
+ }
209
+ async remove(rawTarget, rawRevision, signal) {
210
+ this.live();
211
+ const effectiveSignal = signal ? AbortSignal.any([signal, this.lifetime.signal]) : this.lifetime.signal;
212
+ effectiveSignal.throwIfAborted();
213
+ if ([...this.jobs.values()].some(j => j.view.state === 'running'))
214
+ throw new Error('已有补全任务运行中,请等待或取消。');
215
+ const opts = rawTarget && typeof rawTarget === 'object' && !Array.isArray(rawTarget)
216
+ ? rawTarget
217
+ : Array.isArray(rawTarget) ? { ids: rawTarget, expectedRevision: rawRevision } : { id: rawTarget, expectedRevision: rawRevision };
218
+ const expectedRevision = opts.expectedRevision !== undefined ? opts.expectedRevision : (opts.revision !== undefined ? opts.revision : rawRevision);
219
+ if (typeof expectedRevision !== 'number' || !Number.isInteger(expectedRevision) || expectedRevision < 0) {
220
+ throw new Error('请提供当前文献库修订号。');
221
+ }
222
+ const rawIds = opts.ids, rawId = opts.id, rawCitekey = opts.citekey ?? opts.bibKey ?? opts.key;
223
+ if (rawIds === undefined && rawId === undefined && rawCitekey === undefined) {
224
+ throw new Error('请提供要删除的文献 id 或引用键。');
225
+ }
226
+ const checkedIds = rawIds !== undefined ? readSelection(rawIds) : undefined;
227
+ const checkedId = rawId !== undefined ? citationId(rawId) : undefined;
228
+ let normalizedKey;
229
+ if (rawCitekey !== undefined) {
230
+ if (typeof rawCitekey !== 'string' || !rawCitekey.trim() || rawCitekey.trim().length > 200) {
231
+ throw new Error('请提供要删除的文献 id 或引用键。');
232
+ }
233
+ normalizedKey = rawCitekey.trim().replace(/^@+/, '').trim();
234
+ if (!normalizedKey)
235
+ throw new Error('请提供要删除的文献 id 或引用键。');
236
+ }
237
+ let removedIds = [];
238
+ try {
239
+ const nextState = await this.store.edit(expectedRevision, state => {
240
+ const exportedKeys = this.exportedBibKeys(state.entries);
241
+ const targets = new Set();
242
+ if (checkedIds) {
243
+ for (const id of checkedIds) {
244
+ if (!state.entries.some(e => e.id === id))
245
+ throw new Error('所选文献已不存在,请刷新。');
246
+ targets.add(id);
247
+ }
248
+ }
249
+ if (checkedId) {
250
+ const entry = state.entries.find(e => e.id === checkedId);
251
+ if (!entry)
252
+ throw new Error('所选文献已不存在,请刷新。');
253
+ if (normalizedKey && entry.bibKey !== normalizedKey && exportedKeys.get(entry.id) !== normalizedKey) {
254
+ throw new Error('文献 id 与引用键不匹配,请刷新后核对。');
255
+ }
256
+ targets.add(entry.id);
257
+ }
258
+ else if (normalizedKey) {
259
+ const exactDisambiguated = state.entries.filter(e => exportedKeys.get(e.id) === normalizedKey && e.bibKey !== normalizedKey);
260
+ const matches = exactDisambiguated.length === 1
261
+ ? exactDisambiguated
262
+ : state.entries.filter(e => e.bibKey === normalizedKey || exportedKeys.get(e.id) === normalizedKey);
263
+ if (matches.length === 0)
264
+ throw new Error('所选文献已不存在,请刷新。');
265
+ if (matches.length > 1)
266
+ throw new Error('引用键匹配多条文献,请改用具体文献 id 删除。');
267
+ targets.add(matches[0].id);
268
+ }
269
+ if (!targets.size)
270
+ throw new Error('请提供要删除的文献 id 或引用键。');
271
+ removedIds = state.entries.filter(e => targets.has(e.id)).map(e => e.id);
272
+ state.entries = state.entries.filter(e => !targets.has(e.id));
273
+ const usedSources = new Set(state.entries.flatMap(e => e.sourceIds));
274
+ state.sources = state.sources.filter(s => usedSources.has(s.id));
275
+ }, effectiveSignal);
276
+ return { ...summary(nextState), removed: removedIds.length, removedIds };
277
+ }
278
+ catch (e) {
279
+ if (e instanceof LibraryConflict) {
280
+ throw new LibraryConflict('文献库已在另一窗口更新,未执行删除。请刷新文献库后重新确认。');
281
+ }
282
+ throw e;
283
+ }
284
+ }
197
285
  async check(text, signal) {
198
286
  this.live();
199
287
  if (typeof text !== 'string' || !text.trim())
@@ -219,16 +307,7 @@ export class CitationWorkbench {
219
307
  return { filename: 'references-' + readStyle(style) + '.txt', type: 'text/plain; charset=utf-8', content: entries.map((e, i) => `[${i + 1}] ` + buildCitation(e.work, readStyle(style), lang === 'en' ? 'en' : 'zh')).join('\n\n') + '\n' };
220
308
  if (kind !== 'bibtex')
221
309
  throw new Error('导出类型只能是 bibtex / references / backup。');
222
- const keys = new Map(), used = new Set();
223
- for (const e of state.entries) {
224
- const base = e.bibKey.replace(/[^A-Za-z0-9_.:\/-]+/g, '_').replace(/^_+|_+$/g, '') || 'work';
225
- let key = base;
226
- let n = 0;
227
- while (used.has(key))
228
- key = base + '-' + e.id.slice(0, 8) + (n++ ? '-' + n : '');
229
- used.add(key);
230
- keys.set(e.id, key);
231
- }
310
+ const keys = this.exportedBibKeys(state.entries);
232
311
  return { filename: 'references.bib', type: 'application/x-bibtex; charset=utf-8', content: entries.map(e => buildBibtex(e.work, keys.get(e.id))).join('\n\n') + '\n' };
233
312
  }
234
313
  async dispatch(value, signal) {
@@ -236,11 +315,13 @@ export class CitationWorkbench {
236
315
  if (!value || typeof value !== 'object')
237
316
  throw new Error('操作参数无效。');
238
317
  const v = value;
239
- switch (v.action) {
318
+ const op = v.action ?? v.operation;
319
+ switch (op) {
240
320
  case 'list': return this.list();
241
321
  case 'preview': return this.preview({ kind: v.kind, text: v.text, label: v.label }, signal);
242
322
  case 'import': return this.import(v.preview, v.selection);
243
- case 'enrich': return this.enrich(v.ids, v.revision);
323
+ case 'enrich': return this.enrich(v.ids, v.expectedRevision ?? v.revision);
324
+ case 'remove': return this.remove(v, undefined, signal);
244
325
  case 'job': return this.job(v.job);
245
326
  case 'cancel': return this.cancel(v.job);
246
327
  case 'export': return this.export(v.kind, v.style, v.lang, v.ids);
@@ -271,7 +352,8 @@ export class CitationWorkbench {
271
352
  if (Buffer.byteLength(text) > 2 * 1024 * 1024)
272
353
  throw new Error('请求超过容量限制,请拆分输入。');
273
354
  const input = JSON.parse(text);
274
- const value = input?.action === 'check'
355
+ const op = input?.action ?? input?.operation;
356
+ const value = op === 'check'
275
357
  ? await this.check(input.text, request.signal)
276
358
  : await this.dispatch(input, request.signal);
277
359
  return Response.json({ ok: true, value }, { headers: { 'cache-control': 'no-store' } });
@@ -283,8 +365,8 @@ export class CitationWorkbench {
283
365
  }
284
366
  export function buildBatchTool(workbench) {
285
367
  return {
286
- name: 'cite_batch', description: '本地文献库:显式 preview 解析 DOI 列表/BibTeX(不联网),import 选择预览条目保存,list 读取,enrich 才联网从 Crossref 补空字段且保留冲突原值,job/cancel 查进度或取消,export 导出基本引文/BibTeX/完整原始来源备份。单批最多100条、库最多500条;不得捏造缺失数据。',
287
- parameters: { type: 'object', properties: { action: { type: 'string', enum: ['list', 'preview', 'import', 'enrich', 'job', 'cancel', 'export'] }, kind: { type: 'string', enum: ['doi', 'bibtex', 'references', 'backup'] }, text: { type: 'string', description: 'DOI 每行一条;或 BibTeX 文本,最大256KiB。' }, label: { type: 'string' }, preview: { type: 'string' }, selection: { type: 'array', items: { type: 'integer' }, description: 'preview 返回的零起始 index(1–100个)。' }, ids: { type: 'array', items: { type: 'string' }, description: '已保存文献 id(1–100个)。' }, revision: { type: 'integer' }, job: { type: 'string' }, style: { type: 'string', enum: ['gb-t-7714', 'apa', 'mla', 'chicago'] }, lang: { type: 'string', enum: ['zh', 'en'] } }, required: ['action'] },
368
+ name: 'cite_batch', description: '本地文献库:显式 preview 解析 DOI 列表/BibTeX(不联网),import 选择预览条目保存,list 读取,enrich 才联网从 Crossref 补空字段且保留冲突原值,remove 按 id/citekey/ids 与 expectedRevision 冲突保护原子删除条目,job/cancel 查进度或取消,export 导出基本引文/BibTeX/完整原始来源备份。单批最多100条、库最多500条;不得捏造缺失数据。',
369
+ parameters: { type: 'object', properties: { action: { type: 'string', enum: ['list', 'preview', 'import', 'enrich', 'remove', 'job', 'cancel', 'export'] }, operation: { type: 'string', enum: ['list', 'preview', 'import', 'enrich', 'remove', 'job', 'cancel', 'export'], description: 'action 的兼容别名(如 remove)。' }, kind: { type: 'string', enum: ['doi', 'bibtex', 'references', 'backup'] }, text: { type: 'string', description: 'DOI 每行一条;或 BibTeX 文本,最大256KiB。' }, label: { type: 'string' }, preview: { type: 'string' }, selection: { type: 'array', items: { type: 'integer' }, description: 'preview 返回的零起始 index(1–100个)。' }, id: { type: 'string', description: '要删除的单条已保存文献 id。' }, citekey: { type: 'string', description: '要删除的单条文献引用键 bibKey(唯一匹配时生效)。' }, ids: { type: 'array', items: { type: 'string' }, description: '已保存文献 id(1–100个)。' }, expectedRevision: { type: 'integer', description: '期望的当前文献库修订号(冲突保护)。' }, revision: { type: 'integer', description: '当前文献库修订号。' }, job: { type: 'string' }, style: { type: 'string', enum: ['gb-t-7714', 'apa', 'mla', 'chicago'] }, lang: { type: 'string', enum: ['zh', 'en'] } } },
288
370
  output: { schema: { type: 'object', additionalProperties: true }, render(_args, value) { return [{ type: 'text', text: JSON.stringify(value, null, 2) }]; } },
289
371
  async execute(args, exec) { const signal = typeof exec === 'object' && exec && exec.signal instanceof AbortSignal ? exec.signal : undefined; signal?.throwIfAborted(); return workbench.dispatch(args, signal); }, timeoutMs: 15000,
290
372
  };