dsh-cite 0.3.0 → 0.3.1

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.en.md CHANGED
@@ -1,8 +1,10 @@
1
1
  # dsh-cite
2
2
 
3
+ ![npm](https://img.shields.io/npm/v/dsh-cite) ![downloads](https://img.shields.io/npm/dm/dsh-cite) ![license](https://img.shields.io/github/license/STARDUSTLC666/dsh-cite) ![stars](https://img.shields.io/github/stars/STARDUSTLC666/dsh-cite?style=social)
4
+
3
5
  > Give it a DOI, get a proper citation — GB/T 7714 / APA / MLA / Chicago / BibTeX.
4
6
 
5
- A DeepSeek Harness plugin for bibliographic references: query Crossref and format citations. Four tools, zero runtime dependencies.
7
+ A DeepSeek Harness plugin for bibliographic references: query Crossref and format citations. Five tools (including the `cite_health` self-check), zero runtime dependencies.
6
8
 
7
9
  ## Tools
8
10
 
@@ -12,10 +14,11 @@ A DeepSeek Harness plugin for bibliographic references: query Crossref and forma
12
14
  | `cite_format` | Generate a formatted citation | `doi`; `style`: gb-t-7714 / apa / mla / chicago |
13
15
  | `cite_bibtex` | Generate a BibTeX entry | `doi`; `key` optional |
14
16
  | `cite_check` | Extract DOIs from text and validate them | `text`; `maxChecks` 1-50, default 10 |
17
+ | `cite_health` | Self-check: probe Crossref connectivity and report latency | none |
15
18
 
16
19
  ## Compatibility
17
20
 
18
- Verified against `@deepseek-ai/dsh@0.1.1-rc.2` on 2026-08-26. Built for the cordis patch-bundle plugin model (`cordis.patch.yml` + `dsh.bundle.patch`). No runtime imports of `@deepseek-ai/*` internals.
21
+ Verified against `@deepseek-ai/dsh@0.1.2-alpha.2` on 2026-08-31. Built for the cordis patch-bundle plugin model (`cordis.patch.yml` + `dsh.bundle.patch`). No runtime imports of `@deepseek-ai/*` internals.
19
22
 
20
23
  ## Install
21
24
 
@@ -23,8 +26,6 @@ Verified against `@deepseek-ai/dsh@0.1.1-rc.2` on 2026-08-26. Built for the cord
23
26
  dsh plugin --profile web add dsh-cite
24
27
  ```
25
28
 
26
- MIT
27
-
28
29
  ## Uninstall
29
30
 
30
31
  ```bash
package/README.md CHANGED
@@ -1,8 +1,10 @@
1
1
  # dsh-cite
2
2
 
3
+ ![npm](https://img.shields.io/npm/v/dsh-cite) ![downloads](https://img.shields.io/npm/dm/dsh-cite) ![license](https://img.shields.io/github/license/STARDUSTLC666/dsh-cite) ![stars](https://img.shields.io/github/stars/STARDUSTLC666/dsh-cite?style=social)
4
+
3
5
  > 给一个 DOI,还你规范参考文献——GB/T 7714 / APA / MLA / Chicago / BibTeX。
4
6
 
5
- DeepSeek Harness 参考文献工具插件:通过 Crossref API 查询文献元数据并格式化引用。四个工具、零运行时依赖、全平台通用。
7
+ DeepSeek Harness 参考文献工具插件:通过 Crossref API 查询文献元数据并格式化引用。五个工具(含 `cite_health` 自检)、零运行时依赖、全平台通用。
6
8
 
7
9
  ## 工具
8
10
 
@@ -12,10 +14,11 @@ DeepSeek Harness 参考文献工具插件:通过 Crossref API 查询文献元
12
14
  | `cite_format` | 生成规范引文 | `doi` 必填;`style`:gb-t-7714 / apa / mla / chicago |
13
15
  | `cite_bibtex` | 生成 BibTeX 条目 | `doi` 必填;`key` 可选 |
14
16
  | `cite_check` | 从文本提取 DOI 并并发校验是否存在(并发 3,保持输入顺序) | `text` 必填;`maxChecks` 1-50 默认 10 |
17
+ | `cite_health` | 自检:探测 Crossref 连通性并报告延迟 | 无 |
15
18
 
16
19
  ## 兼容性
17
20
 
18
- 在 `@deepseek-ai/dsh@0.1.1-rc.2` 上验证(2026-08-26)。遵循 cordis 组合包补丁模型(`cordis.patch.yml` + `dsh.bundle.patch`),运行时不 import 任何 `@deepseek-ai/*` 内部模块。
21
+ 在 `@deepseek-ai/dsh@0.1.2-alpha.2` 上验证(2026-08-31)。遵循 cordis 组合包补丁模型(`cordis.patch.yml` + `dsh.bundle.patch`),运行时不 import 任何 `@deepseek-ai/*` 内部模块。
19
22
 
20
23
  ## 安装
21
24
 
package/lib/config.d.ts CHANGED
@@ -11,6 +11,7 @@ export interface ResolvedCiteConfig {
11
11
  timeoutMs: number;
12
12
  userAgent: string;
13
13
  }
14
+ export declare const DEFAULT_USER_AGENT = "dsh-cite/0.3.1 (DeepSeek Harness citation plugin; mailto:STARDUSTLC666@users.noreply.github.com)";
14
15
  export declare const CITE_TIMEOUT_ENV = "DSH_CITE_TIMEOUT_MS";
15
16
  export declare const CITE_USER_AGENT_ENV = "DSH_CITE_USER_AGENT";
16
17
  export declare function resolveConfig(config: CiteConfig | undefined | null, env?: NodeJS.ProcessEnv): ResolvedCiteConfig;
package/lib/config.js CHANGED
@@ -4,7 +4,7 @@
4
4
  * @module dsh-cite/config
5
5
  */
6
6
  const DEFAULT_TIMEOUT_MS = 15000;
7
- const DEFAULT_USER_AGENT = 'dsh-cite/0.2.0 (DeepSeek Harness citation plugin; mailto:STARDUSTLC666@users.noreply.github.com)';
7
+ export const DEFAULT_USER_AGENT = 'dsh-cite/0.3.1 (DeepSeek Harness citation plugin; mailto:STARDUSTLC666@users.noreply.github.com)';
8
8
  export const CITE_TIMEOUT_ENV = 'DSH_CITE_TIMEOUT_MS';
9
9
  export const CITE_USER_AGENT_ENV = 'DSH_CITE_USER_AGENT';
10
10
  export function resolveConfig(config, env = process.env) {
package/lib/crossref.js CHANGED
@@ -6,7 +6,7 @@
6
6
  const CROSSREF_API = 'https://api.crossref.org/works/';
7
7
  const DOI_PATTERN = /^10\.\d{4,9}\/[-._;()/:A-Za-z0-9]+$/i;
8
8
  export function assertDoi(value) {
9
- const doi = value.trim().replace(/^https?:\/\/doi\.org\//i, '').replace(/^doi:\s*/i, '');
9
+ const doi = value.trim().replace(/^https?:\/\/(dx\.)?doi\.org\//i, '').replace(/^doi:\s*/i, '');
10
10
  if (!DOI_PATTERN.test(doi))
11
11
  throw new Error('DOI 格式不正确:' + value + '(示例:10.1038/nature12345)。');
12
12
  return doi;
package/lib/format.js CHANGED
@@ -146,14 +146,15 @@ function buildApa(work) {
146
146
  text += '(' + work.issue + ')';
147
147
  if (work.page !== '')
148
148
  text += ', ' + work.page;
149
- text += '. ';
150
- text += work.doi !== '' ? 'https://doi.org/' + work.doi : work.url;
151
- return text;
149
+ const tail = work.doi !== '' ? 'https://doi.org/' + work.doi : work.url;
150
+ if (tail !== '')
151
+ return text + '. ' + tail;
152
+ return text + '.';
152
153
  }
153
154
  if (work.type === 'book' || work.type === 'monograph' || work.type === 'edited-book') {
154
- return authors + ' (' + year + '). ' + title + '. ' + (work.publisher !== '' ? work.publisher + '.' : '');
155
+ return authors + ' (' + year + '). ' + title + '.' + (work.publisher !== '' ? ' ' + work.publisher + '.' : '');
155
156
  }
156
- return authors + ' (' + year + '). ' + title + '. ' + (work.url !== '' ? work.url : '');
157
+ return authors + ' (' + year + '). ' + title + '.' + (work.url !== '' ? ' ' + work.url : '');
157
158
  }
158
159
  /** 生成 MLA 9 参考文献条目。 */
159
160
  function buildMla(work) {
@@ -241,7 +242,7 @@ function bibtexType(work) {
241
242
  export function buildBibtex(work, key) {
242
243
  const first = work.authors[0];
243
244
  const firstWord = titleOf(work).split(/[^\p{L}\p{N}]+/u).find((part) => part !== '') ?? 'work';
244
- const baseKey = key !== undefined && key.trim() !== '' ? sanitizeBibtexKey(key.trim()) : ((first?.family ?? first?.name ?? 'author') + yearText(work) + firstWord).toLowerCase();
245
+ const baseKey = key !== undefined && key.trim() !== '' ? sanitizeBibtexKey(key.trim()) : sanitizeBibtexKey(((first?.family || first?.name || 'author') + yearText(work) + firstWord).toLowerCase());
245
246
  const type = bibtexType(work);
246
247
  const fields = [];
247
248
  const authors = work.authors.map((author) => fullName(author)).join(' and ');
package/lib/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * dsh-cite —— 参考文献工具插件(node 半身,配置走 cordis.patch.yml)。
3
3
  *
4
- * 插件导出 apply(ctx, config):注册四个面向模型的工具(cite_lookup / cite_format /
5
- * cite_bibtex / cite_check),通过 Crossref API 查询元数据并生成 GB/T 7714 / APA /
6
- * MLA / Chicago 引文。零运行时依赖。
4
+ * 插件导出 apply(ctx, config):注册五个面向模型的工具(cite_lookup / cite_format /
5
+ * cite_bibtex / cite_check / cite_health),通过 Crossref API 查询元数据并生成
6
+ * GB/T 7714 / APA / MLA / Chicago 引文。零运行时依赖。
7
7
  *
8
8
  * @module dsh-cite
9
9
  */
package/lib/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * dsh-cite —— 参考文献工具插件(node 半身,配置走 cordis.patch.yml)。
3
3
  *
4
- * 插件导出 apply(ctx, config):注册四个面向模型的工具(cite_lookup / cite_format /
5
- * cite_bibtex / cite_check),通过 Crossref API 查询元数据并生成 GB/T 7714 / APA /
6
- * MLA / Chicago 引文。零运行时依赖。
4
+ * 插件导出 apply(ctx, config):注册五个面向模型的工具(cite_lookup / cite_format /
5
+ * cite_bibtex / cite_check / cite_health),通过 Crossref API 查询元数据并生成
6
+ * GB/T 7714 / APA / MLA / Chicago 引文。零运行时依赖。
7
7
  *
8
8
  * @module dsh-cite
9
9
  */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-cite",
3
- "version": "0.3.0",
4
- "description": "DSH 参考文献工具插件:cite_lookup/cite_format/cite_bibtex/cite_check 四工具,Crossref 元数据查询(含 DOI 精确解析与并发校验),GB/T 7714 / APA / MLA / Chicago 格式化,零运行时依赖。",
3
+ "version": "0.3.1",
4
+ "description": "DSH 参考文献工具插件:cite_lookup/cite_format/cite_bibtex/cite_check/cite_health 五工具(含自检),Crossref 元数据查询(含 DOI 精确解析与并发校验),GB/T 7714 / APA / MLA / Chicago 格式化,零运行时依赖。",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
7
7
  "types": "lib/index.d.ts",