paper-search-cli 0.1.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.
Files changed (166) hide show
  1. package/.env.example +165 -0
  2. package/LICENSE +21 -0
  3. package/README-sc.md +642 -0
  4. package/README.md +642 -0
  5. package/dist/cli.d.ts +3 -0
  6. package/dist/cli.d.ts.map +1 -0
  7. package/dist/cli.js +637 -0
  8. package/dist/cli.js.map +1 -0
  9. package/dist/config/ConfigService.d.ts +26 -0
  10. package/dist/config/ConfigService.d.ts.map +1 -0
  11. package/dist/config/ConfigService.js +145 -0
  12. package/dist/config/ConfigService.js.map +1 -0
  13. package/dist/config/constants.d.ts +140 -0
  14. package/dist/config/constants.d.ts.map +1 -0
  15. package/dist/config/constants.js +93 -0
  16. package/dist/config/constants.js.map +1 -0
  17. package/dist/core/diagnostics.d.ts +43 -0
  18. package/dist/core/diagnostics.d.ts.map +1 -0
  19. package/dist/core/diagnostics.js +544 -0
  20. package/dist/core/diagnostics.js.map +1 -0
  21. package/dist/core/handleToolCall.d.ts +8 -0
  22. package/dist/core/handleToolCall.d.ts.map +1 -0
  23. package/dist/core/handleToolCall.js +440 -0
  24. package/dist/core/handleToolCall.js.map +1 -0
  25. package/dist/core/schemas.d.ts +454 -0
  26. package/dist/core/schemas.d.ts.map +1 -0
  27. package/dist/core/schemas.js +322 -0
  28. package/dist/core/schemas.js.map +1 -0
  29. package/dist/core/searchers.d.ts +45 -0
  30. package/dist/core/searchers.d.ts.map +1 -0
  31. package/dist/core/searchers.js +73 -0
  32. package/dist/core/searchers.js.map +1 -0
  33. package/dist/core/tools.d.ts +7 -0
  34. package/dist/core/tools.d.ts.map +1 -0
  35. package/dist/core/tools.js +640 -0
  36. package/dist/core/tools.js.map +1 -0
  37. package/dist/models/Paper.d.ts +64 -0
  38. package/dist/models/Paper.d.ts.map +1 -0
  39. package/dist/models/Paper.js +70 -0
  40. package/dist/models/Paper.js.map +1 -0
  41. package/dist/platforms/ArxivSearcher.d.ts +64 -0
  42. package/dist/platforms/ArxivSearcher.d.ts.map +1 -0
  43. package/dist/platforms/ArxivSearcher.js +531 -0
  44. package/dist/platforms/ArxivSearcher.js.map +1 -0
  45. package/dist/platforms/BioRxivSearcher.d.ts +47 -0
  46. package/dist/platforms/BioRxivSearcher.d.ts.map +1 -0
  47. package/dist/platforms/BioRxivSearcher.js +196 -0
  48. package/dist/platforms/BioRxivSearcher.js.map +1 -0
  49. package/dist/platforms/CORESearcher.d.ts +16 -0
  50. package/dist/platforms/CORESearcher.d.ts.map +1 -0
  51. package/dist/platforms/CORESearcher.js +148 -0
  52. package/dist/platforms/CORESearcher.js.map +1 -0
  53. package/dist/platforms/CrossrefSearcher.d.ts +34 -0
  54. package/dist/platforms/CrossrefSearcher.d.ts.map +1 -0
  55. package/dist/platforms/CrossrefSearcher.js +339 -0
  56. package/dist/platforms/CrossrefSearcher.js.map +1 -0
  57. package/dist/platforms/EuropePMCSearcher.d.ts +20 -0
  58. package/dist/platforms/EuropePMCSearcher.d.ts.map +1 -0
  59. package/dist/platforms/EuropePMCSearcher.js +173 -0
  60. package/dist/platforms/EuropePMCSearcher.js.map +1 -0
  61. package/dist/platforms/GoogleScholarSearcher.d.ts +77 -0
  62. package/dist/platforms/GoogleScholarSearcher.d.ts.map +1 -0
  63. package/dist/platforms/GoogleScholarSearcher.js +262 -0
  64. package/dist/platforms/GoogleScholarSearcher.js.map +1 -0
  65. package/dist/platforms/IACRSearcher.d.ts +51 -0
  66. package/dist/platforms/IACRSearcher.d.ts.map +1 -0
  67. package/dist/platforms/IACRSearcher.js +339 -0
  68. package/dist/platforms/IACRSearcher.js.map +1 -0
  69. package/dist/platforms/OpenAIRESearcher.d.ts +22 -0
  70. package/dist/platforms/OpenAIRESearcher.d.ts.map +1 -0
  71. package/dist/platforms/OpenAIRESearcher.js +223 -0
  72. package/dist/platforms/OpenAIRESearcher.js.map +1 -0
  73. package/dist/platforms/OpenAlexSearcher.d.ts +14 -0
  74. package/dist/platforms/OpenAlexSearcher.d.ts.map +1 -0
  75. package/dist/platforms/OpenAlexSearcher.js +114 -0
  76. package/dist/platforms/OpenAlexSearcher.js.map +1 -0
  77. package/dist/platforms/PMCSearcher.d.ts +20 -0
  78. package/dist/platforms/PMCSearcher.d.ts.map +1 -0
  79. package/dist/platforms/PMCSearcher.js +177 -0
  80. package/dist/platforms/PMCSearcher.js.map +1 -0
  81. package/dist/platforms/PaperSource.d.ts +143 -0
  82. package/dist/platforms/PaperSource.d.ts.map +1 -0
  83. package/dist/platforms/PaperSource.js +125 -0
  84. package/dist/platforms/PaperSource.js.map +1 -0
  85. package/dist/platforms/PubMedSearcher.d.ts +104 -0
  86. package/dist/platforms/PubMedSearcher.d.ts.map +1 -0
  87. package/dist/platforms/PubMedSearcher.js +422 -0
  88. package/dist/platforms/PubMedSearcher.js.map +1 -0
  89. package/dist/platforms/SciHubSearcher.d.ts +66 -0
  90. package/dist/platforms/SciHubSearcher.d.ts.map +1 -0
  91. package/dist/platforms/SciHubSearcher.js +398 -0
  92. package/dist/platforms/SciHubSearcher.js.map +1 -0
  93. package/dist/platforms/ScienceDirectSearcher.d.ts +42 -0
  94. package/dist/platforms/ScienceDirectSearcher.d.ts.map +1 -0
  95. package/dist/platforms/ScienceDirectSearcher.js +326 -0
  96. package/dist/platforms/ScienceDirectSearcher.js.map +1 -0
  97. package/dist/platforms/ScopusSearcher.d.ts +43 -0
  98. package/dist/platforms/ScopusSearcher.d.ts.map +1 -0
  99. package/dist/platforms/ScopusSearcher.js +364 -0
  100. package/dist/platforms/ScopusSearcher.js.map +1 -0
  101. package/dist/platforms/SemanticScholarSearcher.d.ts +96 -0
  102. package/dist/platforms/SemanticScholarSearcher.d.ts.map +1 -0
  103. package/dist/platforms/SemanticScholarSearcher.js +419 -0
  104. package/dist/platforms/SemanticScholarSearcher.js.map +1 -0
  105. package/dist/platforms/SpringerSearcher.d.ts +54 -0
  106. package/dist/platforms/SpringerSearcher.d.ts.map +1 -0
  107. package/dist/platforms/SpringerSearcher.js +407 -0
  108. package/dist/platforms/SpringerSearcher.js.map +1 -0
  109. package/dist/platforms/UnpaywallSearcher.d.ts +18 -0
  110. package/dist/platforms/UnpaywallSearcher.d.ts.map +1 -0
  111. package/dist/platforms/UnpaywallSearcher.js +115 -0
  112. package/dist/platforms/UnpaywallSearcher.js.map +1 -0
  113. package/dist/platforms/WebOfScienceSearcher.d.ts +111 -0
  114. package/dist/platforms/WebOfScienceSearcher.d.ts.map +1 -0
  115. package/dist/platforms/WebOfScienceSearcher.js +500 -0
  116. package/dist/platforms/WebOfScienceSearcher.js.map +1 -0
  117. package/dist/platforms/WileySearcher.d.ts +44 -0
  118. package/dist/platforms/WileySearcher.d.ts.map +1 -0
  119. package/dist/platforms/WileySearcher.js +148 -0
  120. package/dist/platforms/WileySearcher.js.map +1 -0
  121. package/dist/services/CitationService.d.ts +66 -0
  122. package/dist/services/CitationService.d.ts.map +1 -0
  123. package/dist/services/CitationService.js +237 -0
  124. package/dist/services/CitationService.js.map +1 -0
  125. package/dist/services/MultiSourceSearchService.d.ts +19 -0
  126. package/dist/services/MultiSourceSearchService.d.ts.map +1 -0
  127. package/dist/services/MultiSourceSearchService.js +96 -0
  128. package/dist/services/MultiSourceSearchService.js.map +1 -0
  129. package/dist/services/OpenAccessFallbackService.d.ts +20 -0
  130. package/dist/services/OpenAccessFallbackService.d.ts.map +1 -0
  131. package/dist/services/OpenAccessFallbackService.js +124 -0
  132. package/dist/services/OpenAccessFallbackService.js.map +1 -0
  133. package/dist/utils/ErrorHandler.d.ts +99 -0
  134. package/dist/utils/ErrorHandler.d.ts.map +1 -0
  135. package/dist/utils/ErrorHandler.js +266 -0
  136. package/dist/utils/ErrorHandler.js.map +1 -0
  137. package/dist/utils/Logger.d.ts +6 -0
  138. package/dist/utils/Logger.d.ts.map +1 -0
  139. package/dist/utils/Logger.js +26 -0
  140. package/dist/utils/Logger.js.map +1 -0
  141. package/dist/utils/PDFExtractor.d.ts +34 -0
  142. package/dist/utils/PDFExtractor.d.ts.map +1 -0
  143. package/dist/utils/PDFExtractor.js +130 -0
  144. package/dist/utils/PDFExtractor.js.map +1 -0
  145. package/dist/utils/PdfDownload.d.ts +7 -0
  146. package/dist/utils/PdfDownload.d.ts.map +1 -0
  147. package/dist/utils/PdfDownload.js +52 -0
  148. package/dist/utils/PdfDownload.js.map +1 -0
  149. package/dist/utils/QuotaManager.d.ts +32 -0
  150. package/dist/utils/QuotaManager.d.ts.map +1 -0
  151. package/dist/utils/QuotaManager.js +95 -0
  152. package/dist/utils/QuotaManager.js.map +1 -0
  153. package/dist/utils/RateLimiter.d.ts +50 -0
  154. package/dist/utils/RateLimiter.d.ts.map +1 -0
  155. package/dist/utils/RateLimiter.js +121 -0
  156. package/dist/utils/RateLimiter.js.map +1 -0
  157. package/dist/utils/RequestCache.d.ts +26 -0
  158. package/dist/utils/RequestCache.d.ts.map +1 -0
  159. package/dist/utils/RequestCache.js +66 -0
  160. package/dist/utils/RequestCache.js.map +1 -0
  161. package/dist/utils/SecurityUtils.d.ts +80 -0
  162. package/dist/utils/SecurityUtils.d.ts.map +1 -0
  163. package/dist/utils/SecurityUtils.js +357 -0
  164. package/dist/utils/SecurityUtils.js.map +1 -0
  165. package/package.json +111 -0
  166. package/skills/paper-search/SKILL.md +192 -0
package/README-sc.md ADDED
@@ -0,0 +1,642 @@
1
+ # Paper Search CLI
2
+
3
+ [English](README.md)
4
+
5
+ Paper Search CLI 是一个独立的 Node.js 命令行工具,用于跨多个学术来源检索论文、核验元数据和下载 PDF。它面向终端直接使用、自动化脚本和 agent 工作流,提供稳定命令入口和可预测的 JSON 输出。
6
+
7
+ 它继承了之前 Paper Search 实现中的平台覆盖、统一数据模型和详细功能说明,但运行方式已经收口为普通 CLI:每次调用执行一次命令,执行完即退出,不需要配置、启动或维护长期后台服务。
8
+
9
+ ![Node.js](https://img.shields.io/badge/node.js->=18.0.0-green.svg)
10
+ ![TypeScript](https://img.shields.io/badge/typescript-^5.5.3-blue.svg)
11
+ ![License](https://img.shields.io/badge/license-MIT-blue.svg)
12
+ ![Platforms](https://img.shields.io/badge/platforms-20-brightgreen.svg)
13
+ ![Version](https://img.shields.io/badge/version-0.1.0-blue.svg)
14
+
15
+ [快速开始](#快速开始) · [配置](#配置) · [Agent Skill](#agent-skill) · [支持的平台](#支持的平台) · [命令](#命令) · [工具参考](#工具参考) · [排障](#排障)
16
+
17
+ ## 设计目标
18
+
19
+ - **免费来源优先**:优先使用公开元数据和开放获取全文路径,再考虑受限或不稳定来源。
20
+ - **单一命令入口**:检索、状态检查、下载和精确工具调用都收口到同一个可执行命令。
21
+ - **适合 agent 解析**:默认输出稳定 JSON,避免让调用方解析终端文本。
22
+ - **来源能力透明**:明确区分哪些平台只能提供元数据、哪些能下载 PDF、哪些需要 API key。
23
+ - **无后台服务负担**:每次调用只执行一个命令,返回结果后退出。
24
+
25
+ ## 核心特性
26
+
27
+ - **20 个学术来源/平台**:Crossref、OpenAlex、PubMed、PubMed Central、Europe PMC、arXiv、bioRxiv、medRxiv、Semantic Scholar、CORE、OpenAIRE、Web of Science、Google Scholar、IACR ePrint、Sci-Hub、ScienceDirect、Springer Nature、Wiley、Scopus、Unpaywall。
28
+ - **单一命令入口**:安装后通过 `paper-search` 调用,适合终端、脚本和 agent。
29
+ - **JSON 优先输出**:stdout 默认输出 JSON,stderr 保留给人类可读日志和错误。
30
+ - **统一论文数据模型**:标准化标题、作者、DOI、来源、日期、摘要、PDF 链接、引用数和平台扩展字段。
31
+ - **多源检索与去重**:用 `--sources crossref,openalex,pmc` 选择来源,或用整理过的 `platform=all`,再按 DOI、标题+作者合并重复结果。
32
+ - **Semantic Scholar 正文片段检索**:`search_semantic_snippets` 用于检索 Semantic Scholar Open Access snippet 索引中的正文片段,适合查找论文中的方法学细节。该功能需要 `SEMANTIC_SCHOLAR_API_KEY`。
33
+ - **开放获取优先下载链**:`download_with_fallback` 会先尝试原生下载、结果里的 PDF URL、PMC/Europe PMC/CORE/OpenAIRE、Unpaywall DOI 解析,只有显式开启时才把 Sci-Hub 作为最后兜底。
34
+ - **限速与重试**:内置平台级限速和可重试 API 错误处理。
35
+ - **PDF 下载支持**:支持 arXiv、bioRxiv、medRxiv、Semantic Scholar、IACR、Sci-Hub、Springer 开放获取、Wiley DOI 下载等路径。
36
+ - **适合 agent 调用**:`tools`、`status`、`search`、`download`、`run` 覆盖简单检索和精确工具调用。
37
+
38
+ ## 快速开始
39
+
40
+ ### 安装
41
+
42
+ 要求 Node.js >= 18.0.0 和 npm。
43
+
44
+ ```bash
45
+ npm install -g paper-search-cli
46
+ paper-search setup
47
+ paper-search search "machine learning" --platform crossref --max-results 3 --pretty
48
+ ```
49
+
50
+ 安装后运行 `paper-search setup`,即可把可选 API key 和 email 写入用户级配置。
51
+
52
+ 如果仓库仍是私有状态,或 npm 包还没有正式发布,请先从已授权的仓库副本安装:
53
+
54
+ ```bash
55
+ git clone git@github.com:dr-dumpling/paper-search-cli.git
56
+ cd paper-search-cli
57
+ npm install
58
+ npm run build
59
+ npm install -g .
60
+ ```
61
+
62
+ ### 常用检查
63
+
64
+ ```bash
65
+ paper-search status --pretty
66
+ paper-search tools --pretty
67
+ paper-search config doctor --pretty
68
+ ```
69
+
70
+ ## 支持的平台
71
+
72
+ | 平台 | 搜索 | 下载 | 全文 | 被引统计 | API Key | 特色功能 |
73
+ | --- | --- | --- | --- | --- | --- | --- |
74
+ | Crossref | ✅ | ❌ | ❌ | ✅ | ❌ | 默认搜索平台,广泛元数据覆盖 |
75
+ | OpenAlex | ✅ | 🟡 条件支持 | ❌ | ✅ | ❌ | 广泛免费元数据;记录含开放链接时可用于回退下载 |
76
+ | arXiv | ✅ | ✅ | ✅ | ❌ | ❌ | 物理、计算机、数学等预印本 |
77
+ | Web of Science | ✅ | ❌ | ❌ | ✅ | ✅ 必需 | 引文数据库、日期排序、年份范围 |
78
+ | PubMed | ✅ | ❌ | ❌ | ❌ | 🟡 可选 | NCBI E-utilities 生物医学文献 |
79
+ | PubMed Central | ✅ | ✅ | ✅ | ❌ | ❌ | 生物医学开放全文和 PMC PDF |
80
+ | Europe PMC | ✅ | ✅ | ✅ | ❌ | ❌ | 生物医学元数据和开放全文链接 |
81
+ | Google Scholar | ✅ | ❌ | ❌ | ✅ | ❌ | 广泛学术发现,基于页面解析 |
82
+ | bioRxiv | ✅ | ✅ | ✅ | ❌ | ❌ | 生物学预印本 |
83
+ | medRxiv | ✅ | ✅ | ✅ | ❌ | ❌ | 医学预印本 |
84
+ | Semantic Scholar | ✅ | ✅ | ✅ 正文片段 | ✅ | 🟡 可选* | AI 语义检索 + OA 正文片段 |
85
+ | CORE | ✅ | 🟡 条件支持 | 🟡 条件支持 | ❌ | 🟡 可选 | 记录含 PDF 或全文链接时可下载 |
86
+ | OpenAIRE | ✅ | 🟡 条件支持 | ❌ | ❌ | 🟡 可选 | 记录含开放链接时可用于回退下载 |
87
+ | Unpaywall | 🟡 条件支持 | 🟡 条件支持 | ❌ | ❌ | ✅ 必需 | 仅支持 DOI 查询;需要 email;发现 OA PDF 时可下载 |
88
+ | IACR ePrint | ✅ | ✅ | ✅ | ❌ | ❌ | 密码学论文 |
89
+ | Sci-Hub | ✅ | ✅ | ❌ | ❌ | ❌ | 基于 DOI 查询和下载 |
90
+ | ScienceDirect | ✅ | ❌ | ❌ | ✅ | ✅ 必需 | Elsevier 元数据和摘要 |
91
+ | Springer Nature | ✅ | 🟡 条件支持 | ❌ | ❌ | ✅ 必需 | 开放获取记录可下载;元数据 API 需要 key |
92
+ | Wiley | ❌ 关键词搜索 | ✅ | ✅ | ❌ | ✅ 必需 | TDM API,仅支持 DOI 下载 PDF |
93
+ | Scopus | ✅ | ❌ | ❌ | ✅ | ✅ 必需 | 摘要和引文数据库 |
94
+
95
+ 说明:
96
+
97
+ - 能力列中,`✅` 表示直接支持,`❌` 表示不支持,`🟡 条件支持` 表示只在满足条件时可用,例如记录里含 PDF/开放获取链接、只能按 DOI 查询,或只能下载开放获取记录。
98
+ - API Key 列中,`❌` 表示不需要配置,`🟡 可选` 表示不配置也能用但限额或稳定性较弱,`✅ 必需` 表示只在启用该平台时必须配置,不代表新用户默认都要配置。Unpaywall 需要的是 email,不是传统 API key。
99
+ - Wiley TDM API 不支持关键词搜索。应先用 `search_crossref` 找到 Wiley 文章 DOI,再用 `download_paper` 配合 `platform=wiley` 下载。
100
+ - `platform=all` 使用整理过、相对稳定的免费/开放/API 来源:Crossref、OpenAlex、PubMed、PMC、Europe PMC、arXiv、bioRxiv、medRxiv、IACR、CORE、OpenAIRE。它默认不包含 Google Scholar、Sci-Hub、付费 key 平台、DOI-only 的 Unpaywall,以及容易触发限流的 Semantic Scholar。
101
+ - `--sources` 接受逗号分隔来源,例如 `--sources crossref,openalex,pmc`。
102
+ - `🟡 可选*` 对 Semantic Scholar 的含义是:普通检索可选;`search_semantic_snippets` 正文片段检索必需配置 `SEMANTIC_SCHOLAR_API_KEY`。
103
+
104
+ ## 配置
105
+
106
+ 多数免费元数据来源无需配置。API key 和 email 推荐写入用户级配置文件,这样 CLI 在任意目录运行都能读取:
107
+
108
+ ```bash
109
+ paper-search setup
110
+ paper-search config set SEMANTIC_SCHOLAR_API_KEY your_semantic_scholar_api_key_here
111
+ paper-search config set PAPER_SEARCH_UNPAYWALL_EMAIL you@example.com
112
+ paper-search config list --pretty
113
+ paper-search config doctor --pretty
114
+ paper-search diagnostics --pretty
115
+ ```
116
+
117
+ 默认配置路径:
118
+
119
+ ```text
120
+ ~/.config/paper-search-cli/config.json
121
+ ```
122
+
123
+ 配置文件权限会写成 `0600`。`config list` 和 `config doctor` 会自动脱敏。
124
+
125
+ `paper-search setup` 是引导式配置命令。默认只询问推荐配置:Semantic Scholar、Unpaywall email、Crossref email 和 CORE。需要遍历所有支持项时使用 `paper-search setup --all`;只想配置指定项时使用 `paper-search setup --keys SEMANTIC_SCHOLAR_API_KEY,CORE_API_KEY`。
126
+
127
+ `paper-search diagnostics --pretty` 会列出所有依赖 API key 或 email 的能力、相关配置项、当前是否已配置、常见失败原因和建议排查动作。检索命令在 key-backed 平台返回 0 结果,或遇到 401、403、400、429 时,也会在 JSON 输出里附带 `diagnostic` 字段。
128
+
129
+ ### API key 推荐策略
130
+
131
+ `paper-search setup` 默认只询问最适合普通新用户先配置的项目。平台表里的 `✅ 必需` 是“使用该平台必需”,不是“所有安装都建议配置”。
132
+
133
+ | 等级 | 配置项 | 是否建议新用户配置 | 说明 |
134
+ | --- | --- | --- | --- |
135
+ | 默认推荐 | `SEMANTIC_SCHOLAR_API_KEY` | 建议配置 | 开启 Semantic Scholar 正文片段检索,适合方法学细节检索,也能提高请求稳定性。 |
136
+ | 默认推荐 | `PAPER_SEARCH_UNPAYWALL_EMAIL` 或 `UNPAYWALL_EMAIL` | 建议配置 | 用 DOI 查找开放获取 PDF;只需要邮箱,不需要申请 API key。 |
137
+ | 默认推荐 | `CROSSREF_MAILTO` | 建议配置 | 让 Crossref 请求进入 polite pool,适合长期或高频检索。 |
138
+ | 默认推荐 | `CORE_API_KEY` 或 `PAPER_SEARCH_CORE_API_KEY` | 建议配置 | CORE 匿名访问容易限流;配置 key 后更适合开放仓储检索。 |
139
+ | 生物医学高频 | `PUBMED_API_KEY`、`NCBI_EMAIL`、`NCBI_TOOL` | 经常用 PubMed 时建议配置 | 提高 NCBI E-utilities 限额,并让请求带上明确客户端信息。 |
140
+ | 机构权限型 | `WOS_API_KEY` | 有 Web of Science API 权限再配置 | 用于 Web of Science 检索和引文数据;需要 Clarivate API 权限。 |
141
+ | 机构权限型 | `ELSEVIER_API_KEY` | 有 Scopus 或 ScienceDirect API 权限再配置 | 同一个 Elsevier key 不等于自动拥有两个产品权限,Scopus 和 ScienceDirect 需要分别开通。 |
142
+ | 机构权限型 | `SPRINGER_API_KEY`、`SPRINGER_OPENACCESS_API_KEY` | 需要 Springer 平台时再配置 | 用于 Springer 元数据和开放获取记录;401 通常表示 key 无效或产品权限未开通。 |
143
+ | 机构权限型 | `WILEY_TDM_TOKEN` | 有 Wiley TDM/机构全文权限再配置 | 仅支持 DOI 下载;能否下载取决于 token 和机构订阅权限。 |
144
+ | 通常不用 | `PAPER_SEARCH_OPENAIRE_API_KEY` 或 `OPENAIRE_API_KEY` | 不建议默认配置 | OpenAIRE 公开检索通常无需 key;只有账号或配额要求时再配置。 |
145
+
146
+ 也可以从现有 `.env` 导入:
147
+
148
+ ```bash
149
+ paper-search config import-env .env --pretty
150
+ ```
151
+
152
+ 配置优先级:
153
+
154
+ 1. shell 环境变量。
155
+ 2. 当前工作目录 `.env`。
156
+ 3. 用户级配置文件。
157
+ 4. 免费来源的内置默认值。
158
+
159
+ 仓库本地开发时,继续复制 `.env.example` 也可以:
160
+
161
+ ```bash
162
+ cp .env.example .env
163
+ ```
164
+
165
+ ### 环境变量
166
+
167
+ ```bash
168
+ # Web of Science,搜索 Web of Science 时必需
169
+ WOS_API_KEY=your_web_of_science_api_key_here
170
+ WOS_API_VERSION=v1
171
+
172
+ # PubMed,可选;从 3 requests/sec 提升到 10 requests/sec
173
+ PUBMED_API_KEY=your_ncbi_api_key_here
174
+ NCBI_EMAIL=you@example.com
175
+ NCBI_TOOL=paper-search-cli
176
+
177
+ # Semantic Scholar,正文片段检索必需,也可提升请求限额
178
+ SEMANTIC_SCHOLAR_API_KEY=your_semantic_scholar_api_key_here
179
+
180
+ # Elsevier,Scopus 和 ScienceDirect 必需;两个产品仍需要分别开通权限
181
+ ELSEVIER_API_KEY=your_elsevier_api_key_here
182
+
183
+ # Springer Nature,Springer 检索和开放获取下载必需
184
+ SPRINGER_API_KEY=your_springer_api_key_here
185
+ SPRINGER_OPENACCESS_API_KEY=your_openaccess_api_key_here
186
+
187
+ # Wiley TDM,Wiley DOI 下载必需
188
+ WILEY_TDM_TOKEN=your_wiley_tdm_token_here
189
+
190
+ # Crossref polite pool,可选但推荐
191
+ CROSSREF_MAILTO=you@example.com
192
+
193
+ # Unpaywall,DOI 开放获取解析必需
194
+ PAPER_SEARCH_UNPAYWALL_EMAIL=you@example.com
195
+ UNPAYWALL_EMAIL=you@example.com
196
+
197
+ # CORE,可选但推荐;匿名访问经常被强限流
198
+ PAPER_SEARCH_CORE_API_KEY=your_core_api_key_here
199
+ CORE_API_KEY=your_core_api_key_here
200
+
201
+ # OpenAIRE,可选;公开搜索无需 key
202
+ PAPER_SEARCH_OPENAIRE_API_KEY=your_openaire_api_key_here
203
+ OPENAIRE_API_KEY=your_openaire_api_key_here
204
+ ```
205
+
206
+ ### API Key 获取入口
207
+
208
+ - Web of Science: [Clarivate Developer Portal](https://developer.clarivate.com/apis)
209
+ - PubMed: [NCBI API Keys](https://ncbiinsights.ncbi.nlm.nih.gov/2017/11/02/new-api-keys-for-the-e-utilities/)
210
+ - Semantic Scholar: [Semantic Scholar API](https://www.semanticscholar.org/product/api)
211
+ - Elsevier: [Elsevier Developer Portal](https://dev.elsevier.com/apikey/manage)
212
+ - Springer Nature: [Springer Nature Developers](https://dev.springernature.com/)
213
+ - Wiley TDM: [Wiley Text and Data Mining](https://onlinelibrary.wiley.com/library-info/resources/text-and-datamining)
214
+ - Unpaywall: [Unpaywall Data Format and API](https://unpaywall.org/products/api)
215
+ - CORE: [CORE API](https://core.ac.uk/services/api)
216
+ - OpenAIRE: [OpenAIRE APIs](https://develop.openaire.eu/)
217
+
218
+ `.env` 已被 git 忽略。不要提交 API key 或 token。
219
+
220
+ ## Agent Skill
221
+
222
+ 本仓库提供一个可选的 agent skill,位置是 `skills/paper-search/SKILL.md`。如果你的 agent 支持 skills,可以把它安装到对应的 skill 目录。
223
+
224
+ 例如:
225
+
226
+ ```bash
227
+ mkdir -p ~/.agents/skills/paper-search
228
+ cp skills/paper-search/SKILL.md ~/.agents/skills/paper-search/SKILL.md
229
+ ```
230
+
231
+ 这个 skill 只负责告诉 agent 如何调用 `paper-search` CLI。API key 仍然通过 `paper-search setup`、`paper-search config`、`.env` 或 shell 环境变量配置。不要把密钥写进 skill 文件。
232
+
233
+ ## 输出约定
234
+
235
+ 默认所有命令都向 stdout 输出 JSON。
236
+
237
+ ```json
238
+ {
239
+ "ok": true,
240
+ "tool": "search_papers",
241
+ "message": "Found 1 papers.",
242
+ "data": []
243
+ }
244
+ ```
245
+
246
+ 使用 `--pretty` 输出格式化 JSON:
247
+
248
+ ```bash
249
+ paper-search search "machine learning" --platform crossref --max-results 1 --pretty
250
+ ```
251
+
252
+ 需要原始文本响应时使用 `--format text`:
253
+
254
+ ```bash
255
+ paper-search search "machine learning" --platform crossref --max-results 1 --format text
256
+ ```
257
+
258
+ 需要在 JSON 中保留原始响应文本时使用 `--include-text`:
259
+
260
+ ```bash
261
+ paper-search run search_crossref --arg query="machine learning" --arg maxResults=3 --include-text --pretty
262
+ ```
263
+
264
+ ## 命令
265
+
266
+ ### `paper-search search`
267
+
268
+ 统一检索入口。
269
+
270
+ ```bash
271
+ paper-search search <query> [options]
272
+ ```
273
+
274
+ 示例:
275
+
276
+ ```bash
277
+ paper-search search "machine learning" --platform crossref --max-results 10 --pretty
278
+ paper-search search "machine learning" --sources crossref,openalex --max-results 2 --pretty
279
+ paper-search search "cancer immunotherapy" --platform all --max-results 2 --pretty
280
+ paper-search search "transformer neural networks" --platform arxiv --category cs.AI --year 2023 --pretty
281
+ paper-search search "COVID-19 vaccine efficacy" --platform pubmed --max-results 20 --year 2023 --pretty
282
+ paper-search search "CRISPR gene editing" --platform webofscience --journal Nature --max-results 15 --pretty
283
+ ```
284
+
285
+ 常用选项:
286
+
287
+ | 参数 | 说明 |
288
+ | --- | --- |
289
+ | `--platform` | 数据来源。默认 `crossref` |
290
+ | `--sources` | 逗号分隔的多源检索列表,例如 `crossref,openalex,pmc` |
291
+ | `--max-results` | 最大返回数量 |
292
+ | `--year` | 年份过滤,例如 `2024`、`2020-2024`、`2020-` |
293
+ | `--author` | 作者过滤 |
294
+ | `--journal` | 期刊过滤 |
295
+ | `--category` | 分类过滤,主要用于 arXiv/bioRxiv/medRxiv |
296
+ | `--days` | bioRxiv/medRxiv 回溯天数 |
297
+ | `--sort-by` | `relevance`、`date` 或 `citations` |
298
+ | `--sort-order` | `asc` 或 `desc` |
299
+
300
+ ### `paper-search run`
301
+
302
+ 按内部工具名执行。这个入口最适合 agent 精确调用。
303
+
304
+ ```bash
305
+ paper-search run <tool-name> --arg key=value --arg key=value
306
+ paper-search run <tool-name> --json-args '{"key":"value"}'
307
+ paper-search run <tool-name> --json-args @args.json
308
+ ```
309
+
310
+ 示例:
311
+
312
+ ```bash
313
+ paper-search run search_crossref --arg query="machine learning" --arg maxResults=5 --pretty
314
+ paper-search run search_papers --json-args '{"query":"machine learning","sources":"crossref,openalex","maxResults":2}' --pretty
315
+ paper-search run search_pubmed --json-args '{"query":"osteoarthritis","maxResults":5,"sortBy":"date"}' --pretty
316
+ paper-search run get_paper_by_doi --arg doi="10.1038/nature12373" --pretty
317
+ ```
318
+
319
+ ### `paper-search tools`
320
+
321
+ 列出全部可用工具名、说明和输入 schema。
322
+
323
+ ```bash
324
+ paper-search tools --pretty
325
+ ```
326
+
327
+ ### `paper-search status`
328
+
329
+ 查看平台能力和 API key 状态。不会打印密钥内容。
330
+
331
+ ```bash
332
+ paper-search status --pretty
333
+ paper-search status --validate --pretty
334
+ ```
335
+
336
+ `--validate` 可能会向平台发起实时请求,只在确实需要验证凭证时使用。
337
+
338
+ ### `paper-search diagnostics`
339
+
340
+ 查看依赖 API key / email 的能力和排障建议。不会打印密钥内容。
341
+
342
+ ```bash
343
+ paper-search diagnostics --pretty
344
+ ```
345
+
346
+ 当命令在已配置 key 的平台返回 0 结果,或遇到 401、403、400、429 时,JSON 输出会包含 `diagnostic` 字段,说明可能原因和下一步操作。
347
+
348
+ ### `paper-search config`
349
+
350
+ 管理用户级配置文件。
351
+
352
+ ```bash
353
+ paper-search config init --pretty
354
+ paper-search config set SEMANTIC_SCHOLAR_API_KEY your_key --pretty
355
+ paper-search config set PAPER_SEARCH_UNPAYWALL_EMAIL you@example.com --pretty
356
+ paper-search config import-env .env --pretty
357
+ paper-search config list --pretty
358
+ paper-search config doctor --pretty
359
+ paper-search config path --pretty
360
+ paper-search config keys --pretty
361
+ ```
362
+
363
+ ### `paper-search download`
364
+
365
+ 从支持下载的平台下载论文 PDF。
366
+
367
+ ```bash
368
+ paper-search download <paper-id-or-doi> --platform <platform> [--save-path ./downloads]
369
+ ```
370
+
371
+ 示例:
372
+
373
+ ```bash
374
+ paper-search download 2301.00001 --platform arxiv --save-path ./downloads
375
+ paper-search download 10.1000/example --platform scihub --save-path ./downloads
376
+ paper-search download 10.1111/jtsb.12390 --platform wiley --save-path ./downloads
377
+ paper-search run download_with_fallback --arg source=arxiv --arg paperId=1201.0490 --arg doi=10.48550/arxiv.1201.0490 --arg savePath=./downloads --pretty
378
+ ```
379
+
380
+ ## 工具参考
381
+
382
+ 以下工具名可用于 `paper-search run`。
383
+
384
+ ### `search_papers`
385
+
386
+ 通过统一调度器检索。
387
+
388
+ ```bash
389
+ paper-search run search_papers --json-args '{"query":"machine learning","platform":"crossref","maxResults":10,"year":"2023","sortBy":"date"}' --pretty
390
+ ```
391
+
392
+ 支持的平台:
393
+
394
+ ```text
395
+ crossref, arxiv, webofscience, wos, pubmed, biorxiv, medrxiv, semantic,
396
+ iacr, googlescholar, scholar, scihub, sciencedirect, springer, scopus,
397
+ openalex, unpaywall, pmc, europepmc, core, openaire, all
398
+ ```
399
+
400
+ 多源检索使用 `sources`:
401
+
402
+ ```bash
403
+ paper-search run search_papers --json-args '{"query":"machine learning","sources":"crossref,openalex,pmc","maxResults":2}' --pretty
404
+ ```
405
+
406
+ ### `search_crossref`
407
+
408
+ 搜索 Crossref,默认免费元数据来源。
409
+
410
+ ```bash
411
+ paper-search run search_crossref --arg query="machine learning" --arg maxResults=10 --arg year=2023 --arg sortBy=relevance --arg sortOrder=desc --pretty
412
+ ```
413
+
414
+ ### `search_arxiv`
415
+
416
+ 搜索 arXiv 预印本。
417
+
418
+ ```bash
419
+ paper-search run search_arxiv --arg query="transformer neural networks" --arg maxResults=10 --arg category=cs.AI --arg year=2023 --arg sortBy=date --arg sortOrder=desc --pretty
420
+ ```
421
+
422
+ ### `search_pubmed`
423
+
424
+ 搜索 PubMed/MEDLINE 生物医学文献。
425
+
426
+ ```bash
427
+ paper-search run search_pubmed --json-args '{"query":"COVID-19 vaccine efficacy","maxResults":20,"year":"2023","journal":"New England Journal of Medicine","publicationType":["Journal Article","Clinical Trial"],"sortBy":"date"}' --pretty
428
+ ```
429
+
430
+ ### 开放元数据与全文来源
431
+
432
+ 这些命令用于开放元数据检索、开放全文发现和 PDF 回退查找:
433
+
434
+ ```bash
435
+ paper-search run search_openalex --arg query="machine learning" --arg maxResults=3 --pretty
436
+ paper-search run search_unpaywall --arg query="10.48550/arxiv.1201.0490" --pretty
437
+ paper-search run search_pmc --arg query="cancer immunotherapy" --arg maxResults=3 --pretty
438
+ paper-search run search_europepmc --arg query="cancer genomics" --arg maxResults=3 --pretty
439
+ paper-search run search_core --arg query="machine learning" --arg maxResults=3 --pretty
440
+ paper-search run search_openaire --arg query="machine learning" --arg maxResults=3 --pretty
441
+ ```
442
+
443
+ Unpaywall 只支持 DOI,且需要配置 email。CORE 匿名访问可能很快返回空结果或被限流,长期使用建议配置 API key。
444
+
445
+ ### `search_webofscience`
446
+
447
+ 搜索 Web of Science。需要 `WOS_API_KEY`。
448
+
449
+ ```bash
450
+ paper-search run search_webofscience --arg query="CRISPR gene editing" --arg maxResults=15 --arg year=2022 --arg journal=Nature --pretty
451
+ ```
452
+
453
+ ### `search_google_scholar`
454
+
455
+ 搜索 Google Scholar。
456
+
457
+ ```bash
458
+ paper-search run search_google_scholar --arg query="deep learning" --arg maxResults=10 --arg yearLow=2020 --arg yearHigh=2024 --pretty
459
+ ```
460
+
461
+ ### `search_biorxiv` 和 `search_medrxiv`
462
+
463
+ 按最近天数窗口和可选分类搜索预印本。
464
+
465
+ ```bash
466
+ paper-search run search_biorxiv --arg query="genomics" --arg maxResults=10 --arg days=30 --pretty
467
+ paper-search run search_medrxiv --arg query="epidemiology" --arg maxResults=10 --arg days=60 --pretty
468
+ ```
469
+
470
+ ### `search_semantic_scholar`
471
+
472
+ 搜索 Semantic Scholar,可附加领域过滤。
473
+
474
+ ```bash
475
+ paper-search run search_semantic_scholar --json-args '{"query":"graph neural networks","maxResults":10,"fieldsOfStudy":["Computer Science"]}' --pretty
476
+ ```
477
+
478
+ ### `search_semantic_snippets`
479
+
480
+ 搜索 Semantic Scholar 的 Open Access snippet 索引,用于定位论文正文中的方法学细节片段。需要 `SEMANTIC_SCHOLAR_API_KEY`。
481
+
482
+ ```bash
483
+ paper-search run search_semantic_snippets --arg query="CMAverse mediation bootstrap confidence interval" --arg limit=5 --arg fieldsOfStudy=Medicine --pretty
484
+ ```
485
+
486
+ ### `search_iacr`
487
+
488
+ 搜索 IACR ePrint Archive。
489
+
490
+ ```bash
491
+ paper-search run search_iacr --arg query="zero knowledge proof" --arg maxResults=10 --arg fetchDetails=true --pretty
492
+ ```
493
+
494
+ ### `search_sciencedirect`
495
+
496
+ 搜索 ScienceDirect。需要 `ELSEVIER_API_KEY`。
497
+
498
+ ```bash
499
+ paper-search run search_sciencedirect --arg query="materials science" --arg maxResults=10 --arg openAccess=true --pretty
500
+ ```
501
+
502
+ ### `search_scopus`
503
+
504
+ 搜索 Scopus。需要 `ELSEVIER_API_KEY`。
505
+
506
+ ```bash
507
+ paper-search run search_scopus --arg query="citation analysis" --arg maxResults=10 --arg documentType=ar --pretty
508
+ ```
509
+
510
+ ### `search_springer`
511
+
512
+ 搜索 Springer Nature。需要 `SPRINGER_API_KEY`。
513
+
514
+ ```bash
515
+ paper-search run search_springer --arg query="machine learning" --arg maxResults=10 --arg type=Journal --arg openAccess=true --pretty
516
+ ```
517
+
518
+ ### `search_scihub`
519
+
520
+ 通过 DOI 或文章 URL 查询 Sci-Hub,并可选择下载 PDF。
521
+
522
+ ```bash
523
+ paper-search run search_scihub --arg doiOrUrl="10.1038/nature12373" --arg downloadPdf=false --pretty
524
+ paper-search run search_scihub --arg doiOrUrl="10.1038/nature12373" --arg downloadPdf=true --arg savePath=./downloads --pretty
525
+ ```
526
+
527
+ ### `check_scihub_mirrors`
528
+
529
+ 查看 Sci-Hub 镜像状态。
530
+
531
+ ```bash
532
+ paper-search run check_scihub_mirrors --pretty
533
+ paper-search run check_scihub_mirrors --arg forceCheck=true --pretty
534
+ ```
535
+
536
+ ### `get_paper_by_doi`
537
+
538
+ 按 DOI 查询元数据。
539
+
540
+ ```bash
541
+ paper-search run get_paper_by_doi --arg doi="10.1038/nature12373" --arg platform=all --pretty
542
+ paper-search run get_paper_by_doi --arg doi="10.1038/nature12373" --arg platform=arxiv --pretty
543
+ ```
544
+
545
+ ### `download_paper`
546
+
547
+ 从支持的平台下载 PDF。
548
+
549
+ ```bash
550
+ paper-search run download_paper --arg paperId="2301.00001" --arg platform=arxiv --arg savePath=./downloads --pretty
551
+ ```
552
+
553
+ 支持下载的平台:
554
+
555
+ ```text
556
+ arxiv, biorxiv, medrxiv, semantic, iacr, scihub, springer, wiley,
557
+ pmc, europepmc, core
558
+ ```
559
+
560
+ ### `download_with_fallback`
561
+
562
+ 按开放获取优先顺序尝试下载:
563
+
564
+ ```bash
565
+ paper-search run download_with_fallback --arg source=arxiv --arg paperId=1201.0490 --arg doi=10.48550/arxiv.1201.0490 --arg savePath=./downloads --pretty
566
+ paper-search run download_with_fallback --arg source=crossref --arg paperId="10.1038/nature12373" --arg doi="10.1038/nature12373" --arg savePath=./downloads --arg useSciHub=false --pretty
567
+ ```
568
+
569
+ `useSciHub` 默认为 `false`;只有明确选择该最后兜底路径时才设置为 `true`。
570
+
571
+ ### `search_wiley`
572
+
573
+ Wiley TDM API 不支持关键词搜索。应先用 Crossref 检索,再按 DOI 下载:
574
+
575
+ ```bash
576
+ paper-search run search_crossref --arg query="site:wiley.com machine learning" --arg maxResults=10 --pretty
577
+ paper-search run download_paper --arg paperId="10.1111/example" --arg platform=wiley --pretty
578
+ ```
579
+
580
+ ### `get_platform_status`
581
+
582
+ 等价于 `paper-search status`。
583
+
584
+ ```bash
585
+ paper-search run get_platform_status --pretty
586
+ paper-search run get_platform_status --arg validate=true --pretty
587
+ ```
588
+
589
+ ## 排障
590
+
591
+ ### 找不到命令
592
+
593
+ 直接从项目运行:
594
+
595
+ ```bash
596
+ node dist/cli.js status --pretty
597
+ ```
598
+
599
+ 或注册为本机命令:
600
+
601
+ ```bash
602
+ npm link
603
+ paper-search status --pretty
604
+ ```
605
+
606
+ ### 缺少 API Key
607
+
608
+ 运行:
609
+
610
+ ```bash
611
+ paper-search status --pretty
612
+ ```
613
+
614
+ 如果某个平台显示 `missing`,通过 `paper-search setup`、用户级配置或 `.env` 添加对应 key 后重试。
615
+
616
+ 全局安装时推荐写入用户级配置:
617
+
618
+ ```bash
619
+ paper-search setup
620
+ paper-search config set SEMANTIC_SCHOLAR_API_KEY your_key
621
+ paper-search config doctor --pretty
622
+ ```
623
+
624
+ ### 平台限流
625
+
626
+ 减少 `--max-results`,避免反复实时验证,优先使用官方 API。PubMed、Semantic Scholar 和 CORE 可通过可选 key 提升限额。CORE 匿名访问可能返回 HTTP 429;如果要稳定使用,建议配置 `PAPER_SEARCH_CORE_API_KEY`。
627
+
628
+ ### 脚本解析 JSON
629
+
630
+ 默认解析 stdout 即可。人类可读诊断会写入 stderr。
631
+
632
+ ## 使用边界
633
+
634
+ 部分来源可能受平台条款、机构订阅或当地法律限制。请只在你具备相应访问权限、并符合所在机构和平台规则的前提下使用相关功能。
635
+
636
+ ## 项目来源
637
+
638
+ 本项目是参考 [openags/paper-search-mcp](https://github.com/openags/paper-search-mcp) 的独立 CLI 改写版本。当前定位是单命令终端工具,不需要 MCP 运行时。
639
+
640
+ ## License
641
+
642
+ MIT