paper-search-cli 0.1.3 → 0.3.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 (59) hide show
  1. package/.env.example +14 -5
  2. package/README.md +151 -617
  3. package/README.zh.md +268 -0
  4. package/dist/cli.js +199 -21
  5. package/dist/cli.js.map +1 -1
  6. package/dist/config/ConfigService.d.ts +1 -1
  7. package/dist/config/ConfigService.d.ts.map +1 -1
  8. package/dist/config/ConfigService.js +2 -2
  9. package/dist/config/ConfigService.js.map +1 -1
  10. package/dist/config/ResultCaps.d.ts +4 -0
  11. package/dist/config/ResultCaps.d.ts.map +1 -0
  12. package/dist/config/ResultCaps.js +10 -0
  13. package/dist/config/ResultCaps.js.map +1 -0
  14. package/dist/core/capabilityProfile.d.ts +18 -0
  15. package/dist/core/capabilityProfile.d.ts.map +1 -0
  16. package/dist/core/capabilityProfile.js +153 -0
  17. package/dist/core/capabilityProfile.js.map +1 -0
  18. package/dist/core/diagnostics.d.ts.map +1 -1
  19. package/dist/core/diagnostics.js +35 -15
  20. package/dist/core/diagnostics.js.map +1 -1
  21. package/dist/core/handleToolCall.d.ts.map +1 -1
  22. package/dist/core/handleToolCall.js +27 -0
  23. package/dist/core/handleToolCall.js.map +1 -1
  24. package/dist/core/liveSmoke.d.ts +42 -0
  25. package/dist/core/liveSmoke.d.ts.map +1 -0
  26. package/dist/core/liveSmoke.js +226 -0
  27. package/dist/core/liveSmoke.js.map +1 -0
  28. package/dist/core/platformMetadata.js +2 -2
  29. package/dist/core/platformMetadata.js.map +1 -1
  30. package/dist/core/schemas.d.ts +77 -2
  31. package/dist/core/schemas.d.ts.map +1 -1
  32. package/dist/core/schemas.js +57 -3
  33. package/dist/core/schemas.js.map +1 -1
  34. package/dist/core/textReports.d.ts +21 -0
  35. package/dist/core/textReports.d.ts.map +1 -0
  36. package/dist/core/textReports.js +85 -0
  37. package/dist/core/textReports.js.map +1 -0
  38. package/dist/core/tools.d.ts.map +1 -1
  39. package/dist/core/tools.js +31 -1
  40. package/dist/core/tools.js.map +1 -1
  41. package/dist/platforms/CORESearcher.d.ts.map +1 -1
  42. package/dist/platforms/CORESearcher.js +39 -9
  43. package/dist/platforms/CORESearcher.js.map +1 -1
  44. package/dist/platforms/OpenAIRESearcher.js +1 -1
  45. package/dist/platforms/OpenAIRESearcher.js.map +1 -1
  46. package/dist/services/JournalMetricsService.d.ts +38 -0
  47. package/dist/services/JournalMetricsService.d.ts.map +1 -0
  48. package/dist/services/JournalMetricsService.js +142 -0
  49. package/dist/services/JournalMetricsService.js.map +1 -0
  50. package/dist/skills/SkillInstaller.d.ts +108 -0
  51. package/dist/skills/SkillInstaller.d.ts.map +1 -0
  52. package/dist/skills/SkillInstaller.js +389 -0
  53. package/dist/skills/SkillInstaller.js.map +1 -0
  54. package/package.json +2 -2
  55. package/skills/paper-search/SKILL.md +53 -127
  56. package/skills/paper-search/references/capability-routing.md +134 -0
  57. package/skills/paper-search/references/cli-contract.md +133 -0
  58. package/skills/paper-search/references/management-layer.md +139 -0
  59. package/README-sc.md +0 -734
@@ -4,147 +4,98 @@ description: |
4
4
  学术文献检索与论文获取调度器,基于 paper-search CLI,而不是 MCP server。
5
5
  用于:搜索论文、查找相似研究、做文献综述初筛、验证 PMID/DOI、下载论文 PDF、
6
6
  调用 Crossref/OpenAlex/PubMed/PMC/Europe PMC/arXiv/bioRxiv/medRxiv/Semantic Scholar/CORE/OpenAIRE/DBLP/ACM/USENIX/OpenReview/IACR 等来源,
7
- 以及使用 Semantic Scholar Open Access snippet 索引检索论文正文片段中的方法学细节。
7
+ 使用 Semantic Scholar Open Access snippet 索引检索论文正文片段中的方法学细节,
8
+ 以及通过 EasyScholar 查询期刊影响因子、JCR/SSCI 分区、中科院分区、JCI、ESI、预警和等级指标。
8
9
  当用户提到“搜文献”“找论文”“文献检索”“search papers”“find papers”“literature search”
9
- “查一下有没有相关研究”“帮我找几篇参考文献”“看看别人怎么做的”“下载论文 PDF”
10
- “验证 PMID”“验证 DOI”“正文片段检索”“snippet search”“Methods 里怎么做的”
11
- “方法学细节检索”等任务时使用。
10
+ “查一下有没有相关研究”“帮我找几篇参考文献”“看看别人怎么做的”“别人怎么写”
11
+ “Methods 里怎么做的”“Methods 写法”“方法学写法对照”“下载论文 PDF”
12
+ “验证 PMID”“验证 DOI”“正文片段检索”“snippet search”“方法学细节检索”
13
+ “影响因子”“IF”“JCR 分区”“中科院分区”“期刊分区”“期刊等级”
14
+ “目标期刊指标”“journal metrics”等任务时使用。
12
15
  此 skill 只负责指导 agent 调用 paper-search CLI;API key 必须通过 paper-search setup、
13
16
  paper-search config、.env 或环境变量配置,绝不要写入 Skill 文件。
14
17
  ---
15
18
 
16
19
  # Paper Search CLI
17
20
 
18
- 你是学术文献检索调度器。所有检索、验证和下载动作优先通过 `paper-search` CLI 完成。Skill 只说明如何调用 CLI,不保存 API key,也不替用户生成或暴露密钥。
21
+ 你是学术文献检索调度器。本 Skill 是 Routing Skill:负责把用户意图路由到 `paper-search` CLI,并维护证据、密钥和下载边界。优先通过 `paper-search` CLI 完成论文检索、元数据核验、正文片段检索、期刊指标查询和 PDF 获取;不要把本 Skill 当作密钥、cookie、账号或下载策略的存储位置。
19
22
 
20
- ## 先做配置检查
23
+ Reference 读取规则:
21
24
 
22
- 处理检索任务前,先确认 CLI 可用:
25
+ - 需要确认安装、配置、doctor、smoke、Skill 同步或健康状态时,读 `references/management-layer.md`。
26
+ - 需要在搜索、期刊指标、PDF 获取、正文片段检索之间做路由时,读 `references/capability-routing.md`。
27
+ - 需要核对稳定 CLI 命令、`paper-search run` 工具名、输出格式或密钥边界时,读 `references/cli-contract.md`。
28
+ - 如果 reference 和实际 `paper-search --help` / `paper-search tools` 冲突,以实际 CLI 为准,并报告需要更新 Skill。
23
29
 
24
- ```bash
25
- command -v paper-search
26
- paper-search status --pretty
27
- ```
30
+ ## 快速自检
28
31
 
29
- 如果涉及 Semantic Scholar 正文片段、CORE、Unpaywall、Web of Science、IEEE Xplore、Scopus、ScienceDirect、Springer/SpringerLink 或 Wiley 等需要 key/邮箱的能力,再运行:
32
+ 第一次使用、环境不确定,或用户问“现在能用哪些能力”时:
30
33
 
31
34
  ```bash
32
- paper-search config doctor --pretty
35
+ command -v paper-search
36
+ paper-search doctor --pretty
33
37
  ```
34
38
 
35
- 缺少 key 时,不要让用户把 key 发给 agent。提示用户在本机运行:
39
+ 需要给用户一份可读健康报告时:
36
40
 
37
41
  ```bash
38
- paper-search setup
39
- paper-search config set SEMANTIC_SCHOLAR_API_KEY your_key
40
- paper-search config doctor --pretty
42
+ paper-search doctor --format text
41
43
  ```
42
44
 
43
- CLI 的配置优先级:
44
-
45
- 1. shell 环境变量
46
- 2. 当前目录 `.env`
47
- 3. 用户级配置 `~/.config/paper-search-cli/config.json`
48
- 4. 免费来源的内置默认值
49
-
50
- ## 安装缺失时
51
-
52
- 如果 `paper-search` 不存在,先告知用户需要安装。用户要求你安装时再执行:
45
+ 安装缺失时先说明缺失;用户要求安装时再执行:
53
46
 
54
47
  ```bash
55
48
  npm install -g paper-search-cli
56
49
  paper-search setup
57
- paper-search status --pretty
50
+ paper-search doctor --pretty
58
51
  ```
59
52
 
60
- ## 常用命令
61
-
62
- ### 快速检索
63
-
64
- ```bash
65
- paper-search search "machine learning" --platform crossref --max-results 5 --pretty
66
- paper-search search "osteoarthritis occupational exposure" --platform pubmed --max-results 10 --pretty
67
- paper-search search "transformer attention mechanism" --sources arxiv,semantic,crossref --max-results 5 --pretty
68
- paper-search search "graph neural networks" --platform dblp --max-results 5 --pretty
69
- paper-search search "large language models" --platform openreview --max-results 5 --pretty
70
- ```
71
-
72
- `--platform all` 或 `--sources all` 只用于需要广覆盖召回时。精确任务优先指定平台或 `--sources`。
73
-
74
- ### 精确工具调用
75
-
76
- ```bash
77
- paper-search run search_pubmed --arg query="osteoarthritis occupational exposure" --arg maxResults=10 --pretty
78
- paper-search run search_openalex --arg query="causal inference target trial emulation" --arg maxResults=5 --pretty
79
- paper-search run search_acm --arg query="software testing" --arg maxResults=5 --pretty
80
- paper-search run search_usenix --arg query="file systems" --arg maxResults=5 --pretty
81
- paper-search run get_paper_by_doi --arg doi="10.xxxx/xxxxx" --pretty
82
- ```
53
+ 用户问“如何更新”、安装后怀疑 Skill 过期,或 `doctor`/`skills status` 显示 Skill 不同步时,先区分包本体更新和 Skill 同步;不要只运行 `skills update`。完整流程查看 `references/management-layer.md` 的 `Package Update And Capability Setup`。
83
54
 
84
- 复杂参数使用 JSON:
55
+ 普通用户更新:
85
56
 
86
57
  ```bash
87
- paper-search run search_semantic_scholar --json-args '{"query":"graph neural network medicine","maxResults":5,"year":"2020-2025"}' --pretty
58
+ npm install -g paper-search-cli@latest
59
+ paper-search skills update --targets agents --pretty
60
+ paper-search doctor --pretty
88
61
  ```
89
62
 
90
- ### 下载 PDF
63
+ 本地维护者更新:
91
64
 
92
65
  ```bash
93
- paper-search download 2301.12345 --platform arxiv --save-path ./downloads --pretty
94
- paper-search run download_paper --arg paperId="10.xxxx/xxxxx" --arg platform=springer --arg savePath="./downloads" --pretty
95
- paper-search run download_with_fallback --json-args '{"source":"crossref","paperId":"10.xxxx/xxxxx","doi":"10.xxxx/xxxxx","title":"Paper title","savePath":"./downloads"}' --pretty
66
+ git pull
67
+ npm install
68
+ npm run build
69
+ npm install -g .
70
+ paper-search skills update --targets agents --pretty
71
+ paper-search doctor --pretty
96
72
  ```
97
73
 
98
- 下载漏斗默认包含 Sci-Hub 作为最后兜底;只有用户明确要求关闭该阶段时,才把 `useSciHub` 设为 `false`。
74
+ 缺少 API key 或 email 时,不要让用户在聊天里发送密钥;提示用户用 `paper-search setup` `paper-search config` 在本机配置。
99
75
 
100
- ## 平台选择
76
+ ## 功能地图
101
77
 
102
- | 任务 | 首选 | 补充 |
103
- |---|---|---|
104
- | 生物医学、临床、药学、公卫 | `pubmed` | `pmc`, `europepmc`, `semantic`, `crossref` |
105
- | 正文方法学片段 | `search_semantic_snippets` | 先用 `pubmed`/`semantic` 找题名和同义词 |
106
- | 计算机、AI、数学、物理 | `arxiv` | `semantic`, `crossref`, `openalex` |
107
- | 计算机文献目录/会议元数据 | `dblp` | `acm`, `usenix`, `openreview`, `ieee` 需要 key |
108
- | 跨学科广覆盖 | `crossref` | `openalex`, `semantic` |
109
- | 开放获取全文发现 | `pmc`, `europepmc`, `core`, `openaire`, `unpaywall` | `download_with_fallback` |
110
- | 密码学 | `iacr` | `arxiv` |
111
- | 引用统计排序 | `semantic`, `crossref`, `openalex` | `webofscience`, `scopus` 需要 key |
112
- | 出版商/付费数据库 | `webofscience`, `ieee`, `scopus`, `sciencedirect`, `springer`/`springerlink`, `wiley` | 仅在 key 已配置时使用 |
78
+ Skill 只有四个文献主功能。`doctor`、`smoke`、`config`、`skills` 是管理层命令,不属于文献任务本身。
113
79
 
114
- 平台边界:
80
+ | 用户意图 | 能力名 | 首选入口 | 关键边界 |
81
+ |---|---|---|---|
82
+ | 搜论文、找相关研究、验证 DOI/PMID、做文献初筛 | `metadata_search` | `paper-search search` 集成入口 / `paper-search run search_*` 精确工具入口 | 只返回和核验论文元数据;Sci-Hub 不属于搜索源 |
83
+ | 查影响因子、JCR/SSCI/中科院分区、JCI、ESI、预警、期刊等级 | `journal_metrics` | `paper-search journal-metrics` / `paper-search run query_journal_metrics` | 这是期刊指标查询,不是论文检索;需要 `EASYSCHOLAR_KEY` |
84
+ | 获取或下载已确认论文的 PDF | `pdf_discovery` | `paper-search download` / `paper-search run download_with_fallback` | 先核验论文身份,再下载;Sci-Hub 是默认开启的最后 fallback |
85
+ | 在论文正文片段中找 Methods/参数/写法线索 | `body_snippet_search` | `paper-search run search_semantic_snippets` | 查 Semantic Scholar OA snippet 索引;需要 `SEMANTIC_SCHOLAR_API_KEY`;不是完整全文解析 |
115
86
 
116
- - `acm` 通过 Crossref 的 ACM DOI 前缀检索元数据,不抓取 ACM Digital Library 页面。
117
- - `usenix` 通过 DBLP 返回 USENIX 相关会议/期刊元数据,不抓取 USENIX 搜索页。
118
- - `springerlink` 是 `springer` 的别名,仍需要 Springer API key。
87
+ ## 默认工作流
119
88
 
120
- 查询构建规则:
89
+ 开放式文献任务使用 Two-Stage Paper Workflow:
121
90
 
122
- - 默认把中文问题转为英文关键词。
123
- - 3-8 个核心概念词,不要写成长句。
124
- - 医学主题可加入 MeSH 或标准术语。
125
- - 找方法细节时加入软件名、参数名、模型名、章节词,例如 `methods`, `statistical analysis`, `adjusted for`, `bootstrap`, `sensitivity analysis`。
91
+ 1. 先做 `metadata_search`:检索和核验文献条目,确认题名、作者、年份、期刊、DOI、PMID/PMCID、URL、摘要线索和相关性。
92
+ 2. 用户确认条目或任务明确需要 PDF 后,再做 `pdf_discovery`:下载选中的已核验条目;下载失败项记录原因,不阻塞其他条目。
126
93
 
127
- ## 正文片段检索
94
+ Direct Paper Request 可以跳过广泛发现:用户给出单个 DOI、PMID、PMCID、arXiv ID 或已核验清单并明确要求下载时,先核验目标身份,再进入下载。
128
95
 
129
- PubMed 只提供题名、作者、摘要、PMID、DOI、期刊和年份等元数据,不提供论文正文抓取。
96
+ ## 验证与输出边界
130
97
 
131
- 正文片段检索使用:
132
-
133
- ```bash
134
- paper-search run search_semantic_snippets --arg query="CMAverse mediation bootstrap confidence interval" --arg limit=5 --arg fieldsOfStudy=Medicine --pretty
135
- ```
136
-
137
- 使用规则:
138
-
139
- 1. 该工具需要 `SEMANTIC_SCHOLAR_API_KEY`。
140
- 2. 它检索 Semantic Scholar Open Access snippet 索引,不等于完整全文解析。
141
- 3. 只有 `snippetKind="body"` 的结果才能作为正文片段证据;`title` 或 `abstract` 只能作为线索。
142
- 4. 输出正文片段前,必须补齐和核验标题、作者、年份、期刊、DOI 或 PMID。
143
- 5. 如果 snippet 无结果,不代表研究不存在;回退到 `search_pubmed`、`search_semantic_scholar` 或 `search_crossref` 做摘要级检索。
144
-
145
- ## 验证规范
146
-
147
- 输出给用户前,关键论文必须尽量验证:
98
+ 关键论文输出前尽量验证:
148
99
 
149
100
  ```bash
150
101
  paper-search run search_pubmed --arg query="37654321[PMID]" --arg maxResults=1 --pretty
@@ -155,41 +106,17 @@ paper-search run search_crossref --arg query="full paper title" --arg maxResults
155
106
  规则:
156
107
 
157
108
  - 不凭模型记忆编造 PMID、DOI、期刊、年份或作者。
158
- - PMID 必须能被 PubMed 查询确认。
159
- - DOI 必须能被 DOI 查询或 Crossref/OpenAlex/Semantic Scholar 结果支持。
109
+ - PMID 必须能被 PubMed 查询确认;DOI 必须能被 DOI 查询或 Crossref/OpenAlex/Semantic Scholar 结果支持。
160
110
  - 同一论文的 PMID、DOI、题名、第一作者和年份应一致;不一致时标记为可疑。
161
- - snippet 结果缺少元数据时,先用完整标题二次检索补齐。
162
-
163
- ## 输出格式
164
-
165
- ### 文献列表
166
-
167
- ```markdown
168
- | # | 标题 | 作者 | 年份 | 期刊/来源 | DOI | PMID | 验证 |
169
- |---|---|---|---:|---|---|---|---|
170
- | 1 | [Title](URL) | First Author et al. | 2024 | Journal | 10.xxxx/xxxxx | 12345678 | 已验证 |
171
- ```
172
-
173
- ### 正文片段结果
174
-
175
- ```markdown
176
- ### 发现 1
177
-
178
- **论文:** Full paper title
179
- **引用:** Author et al. Journal. Year. DOI/PMID.
180
- **片段类型:** body
181
- **章节:** Methods / Statistical Analysis
182
- **来源:** Semantic Scholar URL
183
-
184
- > snippet text
185
- ```
111
+ - `config` / `doctor` 输出应视为已脱敏,但不要复述、保存或写入任何原始密钥。
186
112
 
187
- ## 错误处理
113
+ ## 常见失败处理
188
114
 
189
115
  | 场景 | 处理 |
190
116
  |---|---|
191
117
  | CLI 不存在 | 提示安装 `npm install -g paper-search-cli` |
192
118
  | API key 缺失 | 提示运行 `paper-search setup`;不要索要或保存 key |
119
+ | EasyScholar key 缺失 | 提示运行 `paper-search setup EASYSCHOLAR_KEY`;不要让用户在聊天中发送 SecretKey |
193
120
  | 429 限流 | 降低 `--max-results`,换平台,或提示配置可选 key |
194
121
  | 0 结果 | 放宽关键词,换英文同义词,换平台,或用 `--sources` 扩展 |
195
122
  | 下载失败 | 优先开放获取来源和 `download_with_fallback`,报告失败原因 |
@@ -200,4 +127,3 @@ paper-search run search_crossref --arg query="full paper title" --arg maxResults
200
127
  - 不管理 Zotero、Obsidian 或其他文献库。
201
128
  - 不写论文正文,不做语言润色。
202
129
  - 不把 API key、token、cookie 写入 Skill、README 或回复。
203
- - 当前公开 CLI 不提供期刊 IF、JCR 分区或中科院分区查询;遇到这类请求时说明能力边界,除非用户另行指定本地私有工具。
@@ -0,0 +1,134 @@
1
+ # Capability Routing Reference
2
+
3
+ Use this reference when mapping a user literature request to one of the four main `paper-search` workflow capabilities.
4
+
5
+ ## Functional Map
6
+
7
+ | User Intent | Capability | Preferred Entrypoint | Boundary |
8
+ |---|---|---|---|
9
+ | Search papers, find related work, verify DOI/PMID, screen literature | `metadata_search` | `paper-search search` integrated entrypoint / `paper-search run search_*` precise tool entrypoint | Returns and verifies paper metadata only; Sci-Hub is not a search source |
10
+ | Query impact factor, JCR/SSCI/CAS quartiles, JCI, ESI, warnings, journal rank | `journal_metrics` | `paper-search journal-metrics` / `paper-search run query_journal_metrics` | Journal-level lookup, not paper search; requires `EASYSCHOLAR_KEY` |
11
+ | Get or download a verified paper PDF | `pdf_discovery` | `paper-search download` / `paper-search run download_with_fallback` | Verify identity before download; Sci-Hub is the default enabled final fallback |
12
+ | Find Methods text, parameters, software, models, or statistical wording in body snippets | `body_snippet_search` | `paper-search run search_semantic_snippets` | Searches Semantic Scholar OA snippet index; requires `SEMANTIC_SCHOLAR_API_KEY`; not full-text parsing |
13
+
14
+ ## Workflow Boundaries
15
+
16
+ Open-ended literature tasks use the Two-Stage Paper Workflow:
17
+
18
+ 1. Run `metadata_search`: build and verify a paper list with title, authors, year, journal/source, DOI, PMID/PMCID, URL, abstract clues, and relevance.
19
+ 2. Run `pdf_discovery` only after the user confirms selected papers or the task explicitly requires PDFs. Record failed downloads without blocking other items.
20
+
21
+ Direct Paper Requests may skip broad discovery when the user provides a DOI, PMID, PMCID, arXiv ID, or already verified paper list. The target identity still needs verification before download.
22
+
23
+ Do not fabricate PMID, DOI, title, author, journal, or year from model memory. Important citations should include the supported claim, title, authors, journal/source, year, DOI or PMID when available, and a stable URL.
24
+
25
+ ## Metadata Search
26
+
27
+ Use `metadata_search` for finding papers, expanding keywords, literature screening, and verifying DOI/PMID/PMCID/arXiv ID.
28
+
29
+ `paper-search search` is the integrated metadata entrypoint:
30
+
31
+ - use `--platform NAME` for one source
32
+ - use `--sources a,b,c` for explicit multi-source search
33
+ - use `--platform all` or `--sources all` only when broad recall matters more than precision
34
+
35
+ It does not call `journal_metrics`, `pdf_discovery`, or `body_snippet_search`.
36
+
37
+ ```bash
38
+ paper-search search "machine learning" --platform crossref --max-results 5 --pretty
39
+ paper-search search "osteoarthritis occupational exposure" --platform pubmed --max-results 10 --pretty
40
+ paper-search search "transformer attention mechanism" --sources arxiv,semantic,crossref --max-results 5 --pretty
41
+ paper-search search "causal inference target trial emulation" --sources all --max-results 5 --pretty
42
+ ```
43
+
44
+ Precise tool entrypoints:
45
+
46
+ ```bash
47
+ paper-search run search_pubmed --arg query="osteoarthritis occupational exposure" --arg maxResults=10 --pretty
48
+ paper-search run search_openalex --arg query="causal inference target trial emulation" --arg maxResults=5 --pretty
49
+ paper-search run get_paper_by_doi --arg doi="10.xxxx/xxxxx" --pretty
50
+ ```
51
+
52
+ Do not treat `search_scihub` as a search source. It is DOI/URL-targeted lookup, not `metadata_search`.
53
+
54
+ ## Journal Metrics
55
+
56
+ Use `journal_metrics` for journal-level metrics: impact factor, JCR/SSCI quartiles, CAS quartiles, JCI, ESI, warnings, and rank.
57
+
58
+ ```bash
59
+ paper-search journal-metrics "Nature" "BMJ" --pretty
60
+ paper-search journal-metrics --file journals.txt --include-raw --pretty
61
+ paper-search run query_journal_metrics --json-args '{"journals":["Nature"],"includeRaw":true}' --pretty
62
+ ```
63
+
64
+ `journal_metrics` requires `EASYSCHOLAR_KEY`. If missing, tell the user to configure it locally:
65
+
66
+ ```bash
67
+ paper-search setup EASYSCHOLAR_KEY
68
+ ```
69
+
70
+ For batch journal lookups, prefer one `journal-metrics` call with multiple journal names or `--file`; do not run parallel EasyScholar requests.
71
+
72
+ ## PDF Discovery
73
+
74
+ Use `pdf_discovery` to get an already verified paper PDF. For open-ended literature tasks, do not begin with batch downloads.
75
+
76
+ ```bash
77
+ paper-search download 2301.12345 --platform arxiv --save-path ./downloads --pretty
78
+ paper-search run download_paper --arg paperId="10.xxxx/xxxxx" --arg platform=springer --arg savePath="./downloads" --pretty
79
+ paper-search run download_with_fallback --json-args '{"source":"crossref","paperId":"10.xxxx/xxxxx","doi":"10.xxxx/xxxxx","title":"Paper title","savePath":"./downloads"}' --pretty
80
+ ```
81
+
82
+ `download_with_fallback` order:
83
+
84
+ 1. source-native download
85
+ 2. metadata PDF URL
86
+ 3. repository discovery through PMC, Europe PMC, CORE, OpenAIRE
87
+ 4. Unpaywall DOI resolution
88
+ 5. Sci-Hub as the final fallback
89
+
90
+ Sci-Hub Fallback is enabled by default. To suppress that final stage for one request:
91
+
92
+ ```bash
93
+ paper-search run download_with_fallback --json-args '{"source":"crossref","paperId":"10.xxxx/xxxxx","doi":"10.xxxx/xxxxx","title":"Paper title","savePath":"./downloads","useSciHub":false}' --pretty
94
+ ```
95
+
96
+ PDF source groups:
97
+
98
+ - `open_access_sources`: arXiv, bioRxiv, medRxiv, PMC, Europe PMC, CORE, OpenAIRE, Unpaywall, OpenAlex OA metadata, Semantic Scholar openAccessPdf, publisher open-access modes, IACR
99
+ - `entitled_access_sources`: Web of Science, ScienceDirect, Scopus, Springer, IEEE, Wiley TDM, or other sources requiring user keys, subscriptions, TDM tokens, or institutional entitlements
100
+ - `scihub_sources`: Sci-Hub, separately identified as the default enabled final fallback; not OA and not entitled access
101
+
102
+ ## Body Snippet Search
103
+
104
+ Use `body_snippet_search` to find Methods wording, parameters, software names, model descriptions, statistical analysis text, or similar body-snippet clues.
105
+
106
+ ```bash
107
+ paper-search run search_semantic_snippets --arg query="comparative risk assessment methods uncertainty propagation" --arg limit=5 --arg fieldsOfStudy=Medicine --pretty
108
+ ```
109
+
110
+ `search_semantic_snippets` requires `SEMANTIC_SCHOLAR_API_KEY` and uses `limit`, not `maxResults`.
111
+
112
+ Only results with `snippetKind="body"` can be used as body-snippet evidence. Results from `title` or `abstract` are clues only. Before quoting or relying on a snippet, verify title, authors, year, journal/source, DOI or PMID.
113
+
114
+ ## Platform Selection
115
+
116
+ | Task | First Choice | Supplements |
117
+ |---|---|---|
118
+ | Biomedical, clinical, pharmaceutical, public health | `pubmed` | `pmc`, `europepmc`, `semantic`, `crossref` |
119
+ | Methods/body snippet clues | `search_semantic_snippets` | Use `pubmed`/`semantic` first for titles and synonyms |
120
+ | Computer science, AI, math, physics | `arxiv` | `semantic`, `crossref`, `openalex` |
121
+ | CS bibliographies and conference metadata | `dblp` | `acm`, `usenix`, `openreview`, `ieee` requires key |
122
+ | Cross-disciplinary coverage | `crossref` | `openalex`, `semantic` |
123
+ | Open-access full-text discovery | `pmc`, `europepmc`, `core`, `openaire`, `unpaywall` | `download_with_fallback` |
124
+ | Journal IF/quartiles/rank | `journal-metrics` | `query_journal_metrics` |
125
+ | Cryptography | `iacr` | `arxiv` |
126
+ | Citation-count sorting | `semantic`, `crossref`, `openalex` | `webofscience`, `scopus` require keys |
127
+ | Publisher or paid databases | `webofscience`, `ieee`, `scopus`, `sciencedirect`, `springer`/`springerlink`, `wiley` | Use only when key is configured |
128
+
129
+ ## Query Construction
130
+
131
+ - Translate Chinese research questions into English keywords by default.
132
+ - Use 3-8 core concept terms rather than long sentences.
133
+ - For medical topics, include MeSH or standard terminology when useful.
134
+ - For method details, include software names, parameter names, model names, or section words such as `methods`, `statistical analysis`, `adjusted for`, `bootstrap`, `sensitivity analysis`.
@@ -0,0 +1,133 @@
1
+ # Paper Search CLI Contract
2
+
3
+ This contract records the stable CLI surface that the `paper-search` Routing Skill may rely on. The Routing Skill should stay short and should not describe commands, flags, or defaults that are absent from this contract and the current CLI.
4
+
5
+ ## Entrypoints
6
+
7
+ - `paper-search` is the primary executable.
8
+ - `paper-search --version`, `paper-search -v`, and `paper-search version` print the installed version.
9
+ - `paper-search --help` and `paper-search help` print usage.
10
+ - `paper-search tools --pretty` lists direct `run` tool names and schemas.
11
+ - Private API keys, emails, and tokens must be configured through `paper-search setup`, `paper-search config`, `.env`, or shell environment variables. They must not be written into Skill files.
12
+
13
+ ## Top-Level Commands
14
+
15
+ - `paper-search search <query> [--platform NAME] [--sources CSV] [--max-results N] [--year YEAR] [--pretty]`
16
+ - `paper-search run <tool-name> --arg key=value --json-args '{"key":"value"}' [--pretty]`
17
+ - `paper-search download <paper-id> --platform NAME [--save-path PATH] [--pretty]`
18
+ - `paper-search journal-metrics <journal...> [--file PATH] [--include-raw] [--pretty]`
19
+ - `paper-search metrics ...` is an alias for `journal-metrics`.
20
+ - `paper-search status [--validate] [--pretty]`
21
+ - `paper-search doctor [--validate] [--format text] [--pretty]`
22
+ - `paper-search smoke --mock [--pretty]`
23
+ - `paper-search smoke --live [--pretty]`
24
+ - `paper-search skills status [--targets CSV] [--pretty]`
25
+ - `paper-search skills diff [--targets CSV] [--format text] [--pretty]`
26
+ - `paper-search skills update [--targets CSV] [--pretty]`
27
+ - `paper-search setup [--all] [--keys CSV] [--install-skills CSV] [--skip-skills]`
28
+ - `paper-search tools [--pretty]`
29
+ - `paper-search diagnostics [--pretty]`
30
+ - `paper-search requirements [--pretty]` is an alias for `diagnostics`.
31
+ - `paper-search config init [--pretty]`
32
+ - `paper-search config path [--pretty]`
33
+ - `paper-search config keys [--pretty]`
34
+ - `paper-search config list [--all] [--pretty]`
35
+ - `paper-search config doctor [--pretty]` is a compatibility config summary; use top-level `doctor` for the full health report.
36
+ - `paper-search config get KEY [--raw] [--pretty]`
37
+ - `paper-search config set KEY VALUE [--pretty]`
38
+ - `paper-search config unset KEY [--pretty]`
39
+ - `paper-search config delete KEY [--pretty]` and `paper-search config remove KEY [--pretty]` are aliases for `unset`.
40
+ - `paper-search config import-env [file] [--pretty]`
41
+
42
+ ## Direct Run Tools
43
+
44
+ These names can be used with `paper-search run <tool-name>`:
45
+
46
+ - `search_papers`
47
+ - `search_arxiv`
48
+ - `search_webofscience`
49
+ - `search_pubmed`
50
+ - `search_biorxiv`
51
+ - `search_medrxiv`
52
+ - `search_semantic_scholar`
53
+ - `search_semantic_snippets`
54
+ - `search_iacr`
55
+ - `download_paper`
56
+ - `search_google_scholar`
57
+ - `get_paper_by_doi`
58
+ - `search_scihub`
59
+ - `check_scihub_mirrors`
60
+ - `get_platform_status`
61
+ - `query_journal_metrics`
62
+ - `search_sciencedirect`
63
+ - `search_springer`
64
+ - `search_wiley`
65
+ - `search_scopus`
66
+ - `search_crossref`
67
+ - `search_openalex`
68
+ - `search_unpaywall`
69
+ - `search_pmc`
70
+ - `search_europepmc`
71
+ - `search_core`
72
+ - `search_openaire`
73
+ - `download_with_fallback`
74
+ - `search_dblp`
75
+ - `search_ieee`
76
+ - `search_acm`
77
+ - `search_usenix`
78
+ - `search_openreview`
79
+ - `search_springerlink`
80
+
81
+ ## Output Expectations
82
+
83
+ - JSON is the default machine-readable output for agent and script callers.
84
+ - `--pretty` pretty-prints JSON.
85
+ - `--format text` is supported by top-level `doctor` and `skills diff` for explicitly requested human-readable reports.
86
+ - `--include-text` keeps raw tool response text in JSON for commands where the CLI supports it.
87
+ - The Routing Skill should parse JSON when making decisions and use text format only when the user needs a readable report.
88
+
89
+ ## Search Command Contract
90
+
91
+ - `paper-search search` is the integrated metadata search entrypoint.
92
+ - Use `--platform NAME` for one source and `--sources a,b,c` for explicit multi-source search.
93
+ - Use `--platform all` or `--sources all` only when broad recall matters more than precision.
94
+ - `search_papers` is the direct tool behind the integrated `search` command.
95
+ - `search_semantic_snippets` uses `limit`, not `maxResults`, and is for body/title/abstract snippets rather than complete full text.
96
+ - `search_unpaywall` resolves DOI-based OA metadata and returns at most one result.
97
+ - `search_scihub` is DOI/URL-targeted lookup and is not a metadata search source.
98
+ - `CORE_MAX_RESULTS_CAP` controls the configurable CORE-only result cap. Default is `100`; hard maximum is `500`. Other platforms keep their own current limits.
99
+
100
+ ## Download Command Contract
101
+
102
+ `download_paper` tries source-native download first when available. Unsupported or failed native downloads route into the same fallback funnel used by `download_with_fallback`.
103
+
104
+ `download_with_fallback` order is source-native download, metadata PDF URL, repository discovery through PMC/Europe PMC/CORE/OpenAIRE, Unpaywall DOI resolution, then Sci-Hub as the final fallback.
105
+
106
+ Sci-Hub Fallback is enabled by default. To suppress that final stage for a request, pass:
107
+
108
+ ```json
109
+ {"useSciHub": false}
110
+ ```
111
+
112
+ The Routing Skill must not describe future-only download commands or strategy flags until they appear in `paper-search --help` or `paper-search tools`.
113
+
114
+ ## Configuration And Secret Boundaries
115
+
116
+ Configuration sources, in priority order:
117
+
118
+ 1. Shell environment variables
119
+ 2. Current directory `.env`
120
+ 3. User config file under `~/.config/paper-search-cli/config.json`
121
+ 4. Free-source built-in defaults
122
+
123
+ Useful configuration commands:
124
+
125
+ ```bash
126
+ paper-search setup
127
+ paper-search config set SEMANTIC_SCHOLAR_API_KEY your_key
128
+ paper-search setup EASYSCHOLAR_KEY
129
+ paper-search config list --pretty
130
+ paper-search doctor --pretty
131
+ ```
132
+
133
+ Do not ask users to paste secrets into chat. Do not write secrets into Skill, README, tests, or logs. `doctor` and `config` output should mask configured secret values.
@@ -0,0 +1,139 @@
1
+ # Management Layer Reference
2
+
3
+ Use this reference when checking whether `paper-search` is installed, configured, healthy, and synchronized with the installed agent Skill. These commands help the agent decide readiness; they do not perform literature tasks.
4
+
5
+ ## Management Commands
6
+
7
+ ```bash
8
+ paper-search doctor --pretty
9
+ paper-search doctor --format text
10
+ paper-search smoke --mock --pretty
11
+ paper-search smoke --live --pretty
12
+ paper-search skills status --pretty
13
+ paper-search skills diff --targets agents --format text
14
+ paper-search skills update --targets agents --pretty
15
+ paper-search tools --pretty
16
+ paper-search config list --pretty
17
+ ```
18
+
19
+ | Command | Purpose | Use When |
20
+ |---|---|---|
21
+ | `paper-search doctor --pretty` | Complete health report: masked config, Capability Profile, platform status, and missing items | First use, uncertain environment, or user asks what capabilities are available |
22
+ | `paper-search doctor --format text` | Human-readable health report | You need to summarize health for the user |
23
+ | `paper-search smoke --mock --pretty` | Offline check of CLI wiring, Capability Profile logic, and Skill sync status logic | After code/install changes, or when network is unavailable |
24
+ | `paper-search smoke --live --pretty` | Small real checks of free metadata, configured key-backed capabilities, and Sci-Hub mirror availability | User asks for local live verification or provider/network issues are suspected |
25
+ | `paper-search skills status --pretty` | Shows whether Installed Skill files match the Bundled Skill | Install/update checks or debugging why an agent reads old Skill text |
26
+ | `paper-search skills diff --targets agents --format text` | Previews managed-file diffs between Bundled Skill and Installed Skill | Before updating Skill files |
27
+ | `paper-search skills update --targets agents --pretty` | Syncs package-managed Skill files into the user Skill directory while preserving Extra Skill Files | After the user confirms Skill update |
28
+ | `paper-search tools --pretty` | Lists `paper-search run` tool names and argument schemas | Unsure about exact tool name or arguments |
29
+ | `paper-search config list --pretty` | Shows masked configuration status | Need to confirm whether key/email/caps are configured |
30
+
31
+ ## Doctor
32
+
33
+ `paper-search doctor` is the main health report. It combines masked configuration, Capability Profile, and platform status.
34
+
35
+ Capability Profile entries are independent workflow capabilities:
36
+
37
+ - `metadata_search`: metadata search through configured/free literature sources. Sci-Hub must not be included in metadata search.
38
+ - `body_snippet_search`: Semantic Scholar Open Access snippet search. It requires `SEMANTIC_SCHOLAR_API_KEY`.
39
+ - `journal_metrics`: EasyScholar journal metrics. It requires `EASYSCHOLAR_KEY`.
40
+ - `pdf_discovery`: PDF discovery and download through source-native download, metadata PDF URLs, open-access sources, entitled-access sources when configured, and the default enabled Sci-Hub Fallback.
41
+ - `entitled_access`: user-specific access rights such as publisher API keys, database keys, TDM tokens, or institutional entitlements.
42
+
43
+ Use JSON output for agent decisions. Use `--format text` only when the user needs a readable report.
44
+
45
+ ## Smoke
46
+
47
+ `paper-search smoke --mock` is offline and should pass without provider keys.
48
+
49
+ `paper-search smoke --live` performs small real checks:
50
+
51
+ - free metadata check always runs
52
+ - Sci-Hub mirror availability is checked by default without downloading PDFs
53
+ - configured key-backed capabilities get lightweight checks
54
+ - unconfigured key-backed capabilities are marked `skipped`
55
+
56
+ Live smoke severity:
57
+
58
+ - `critical` failures make the command fail.
59
+ - `degraded` means a configured or default-enabled capability did not work as expected and must include remediation, but it is not the same as whole-tool failure.
60
+ - `warning` and `skipped` are informational.
61
+
62
+ When reporting live smoke results, include any `message` and `remediation` for degraded cases.
63
+
64
+ ## Skill Sync
65
+
66
+ The npm package ships a Bundled Skill under `skills/paper-search`. Installing or updating user-visible Skill files is explicit.
67
+
68
+ Supported targets:
69
+
70
+ - `agents`
71
+ - `codex`
72
+ - `claude`
73
+ - `cursor`
74
+ - `gemini`
75
+ - `antigravity`
76
+
77
+ Routine sync after package updates:
78
+
79
+ ```bash
80
+ paper-search skills status --targets agents --pretty
81
+ paper-search skills diff --targets agents --format text
82
+ paper-search skills update --targets agents --pretty
83
+ ```
84
+
85
+ `skills update` overwrites package-managed files and preserves Extra Skill Files. `skills diff` may show diffs only for Managed Skill Files; extra files are listed by name only.
86
+
87
+ ## Package Update And Capability Setup
88
+
89
+ `skills update` only syncs Bundled Skill files into the selected Installed Skill directory. It does not update the npm package, GitHub checkout, compiled CLI files, or provider configuration.
90
+
91
+ `paper-search setup` only configures keys, email, and install destinations for the currently installed CLI. It does not update the package body.
92
+
93
+ Ordinary user update path:
94
+
95
+ ```bash
96
+ npm install -g paper-search-cli@latest
97
+ paper-search skills update --targets agents --pretty
98
+ paper-search doctor --pretty
99
+ paper-search setup
100
+ paper-search smoke --mock --pretty
101
+ ```
102
+
103
+ Use `doctor` before or after `setup` to inspect the Capability Profile. Missing, unavailable, or degraded capability entries should tell the agent which key, email, source, or environment item the user needs to configure.
104
+
105
+ Maintainer or local-dev update path:
106
+
107
+ ```bash
108
+ git pull
109
+ npm install
110
+ npm run build
111
+ npm install -g .
112
+ paper-search skills update --targets agents --pretty
113
+ paper-search doctor --pretty
114
+ paper-search setup
115
+ paper-search smoke --mock --pretty
116
+ ```
117
+
118
+ Use the local-dev path when validating this repository checkout before publishing or before installing a local build globally.
119
+
120
+ ## Configuration Checks
121
+
122
+ Configuration sources, in priority order:
123
+
124
+ 1. Shell environment variables
125
+ 2. Current directory `.env`
126
+ 3. User config file under `~/.config/paper-search-cli/config.json`
127
+ 4. Free-source built-in defaults
128
+
129
+ Useful commands:
130
+
131
+ ```bash
132
+ paper-search setup
133
+ paper-search config list --pretty
134
+ paper-search config get SEMANTIC_SCHOLAR_API_KEY --pretty
135
+ paper-search config get EASYSCHOLAR_KEY --pretty
136
+ paper-search doctor --pretty
137
+ ```
138
+
139
+ Do not ask users to paste secrets into chat. Do not write secrets into Skill, README, tests, or logs. `doctor` and `config` output should mask configured secret values.