dsh-cite 0.7.9 → 0.8.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/lib/tools.d.ts CHANGED
@@ -25,4 +25,21 @@ export interface CiteToolDefinition {
25
25
  execute(args: unknown, exec: unknown): Promise<unknown>;
26
26
  timeoutMs?: number;
27
27
  }
28
+ export declare const MAX_DOI_CHECKS = 50;
29
+ export declare function checkDois(text: string, cfg: ResolvedCiteConfig, limit: number, fetchImpl?: FetchLike, signal?: AbortSignal): Promise<{
30
+ count: number;
31
+ results: ({
32
+ doi: string;
33
+ ok: boolean;
34
+ title: string;
35
+ url: string;
36
+ error?: undefined;
37
+ } | {
38
+ doi: string;
39
+ ok: boolean;
40
+ title: string;
41
+ url: string;
42
+ error: string;
43
+ })[];
44
+ }>;
28
45
  export declare function buildCiteTools(cfg: ResolvedCiteConfig, fetchImpl?: FetchLike): CiteToolDefinition[];
package/lib/tools.js CHANGED
@@ -97,7 +97,22 @@ function executionSignal(exec) {
97
97
  return signal instanceof AbortSignal ? signal : undefined;
98
98
  }
99
99
  const CHECK_CONCURRENCY = 3;
100
- const MAX_CHECKS = 50;
100
+ export const MAX_DOI_CHECKS = 50;
101
+ export async function checkDois(text, cfg, limit, fetchImpl, signal) {
102
+ signal?.throwIfAborted();
103
+ const dois = extractDois(text).slice(0, limit);
104
+ const results = await mapWithConcurrency(dois, CHECK_CONCURRENCY, async (doi) => {
105
+ try {
106
+ const work = await lookupDoi(doi, cfg, fetchImpl, signal);
107
+ return { doi, ok: true, title: work.title, url: work.url };
108
+ }
109
+ catch (error) {
110
+ signal?.throwIfAborted();
111
+ return { doi, ok: false, title: '', url: '', error: error instanceof Error ? error.message : String(error) };
112
+ }
113
+ }, signal);
114
+ return { count: results.length, results };
115
+ }
101
116
  function workLabel(work) {
102
117
  const title = work.title !== '' ? work.title : '(无标题)';
103
118
  return title + '(' + (work.year > 0 ? work.year + ', ' : '') + (work.containerTitle !== '' ? work.containerTitle : work.publisher) + ')';
@@ -201,22 +216,10 @@ export function buildCiteTools(cfg, fetchImpl) {
201
216
  async execute(rawArgs, exec) {
202
217
  const args = (rawArgs ?? {});
203
218
  const text = requiredString(args, 'text', '待检查文本');
204
- const maxChecks = optionalInteger(args, 'maxChecks', '校验数量', 1, 50, 10);
205
- const dois = extractDois(text).slice(0, maxChecks);
206
- const signal = executionSignal(exec);
207
- const results = await mapWithConcurrency(dois, CHECK_CONCURRENCY, async (doi) => {
208
- try {
209
- const work = await lookupDoi(doi, cfg, fetchImpl, signal);
210
- return { doi, ok: true, title: work.title, url: work.url };
211
- }
212
- catch (error) {
213
- signal?.throwIfAborted();
214
- return { doi, ok: false, title: '', url: '', error: error instanceof Error ? error.message : String(error) };
215
- }
216
- }, signal);
217
- return { count: results.length, results };
219
+ const maxChecks = optionalInteger(args, 'maxChecks', '校验数量', 1, MAX_DOI_CHECKS, 10);
220
+ return checkDois(text, cfg, maxChecks, fetchImpl, executionSignal(exec));
218
221
  },
219
- timeoutMs: cfg.timeoutMs * Math.ceil(MAX_CHECKS / CHECK_CONCURRENCY) + 5000,
222
+ timeoutMs: cfg.timeoutMs * Math.ceil(MAX_DOI_CHECKS / CHECK_CONCURRENCY) + 5000,
220
223
  };
221
224
  const citeHealth = {
222
225
  name: 'cite_health',
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-cite",
3
- "version": "0.7.9",
4
- "description": "DSH 文献工作台:DOI / BibTeX 导入预览、去重、Crossref 补全、引文导出与来源备份。欢迎提交 issues 和 PR。",
3
+ "version": "0.8.0",
4
+ "description": "DeepSeek Harness 引文工作台。支持 DOI / BibTeX 导入去重、Crossref 核查与补全、引文导出和原始来源备份。",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
7
7
  "types": "lib/index.d.ts",
@@ -57,7 +57,7 @@
57
57
  "license": "MIT",
58
58
  "engines": {
59
59
  "node": "^22.19.0 || >=24.0.0",
60
- "dsh": ">=0.2.1-rc.3"
60
+ "dsh": ">=0.2.2-rc.3"
61
61
  },
62
62
  "devDependencies": {
63
63
  "@types/node": "^24.0.0",