papersearch 0.5.7 → 0.5.9
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 +30 -24
- package/README.md +30 -24
- package/assets/overview.en.png +0 -0
- package/assets/overview.png +0 -0
- package/carsi/paper_search_carsi/assets/api_keys.json +6 -4
- package/carsi/paper_search_carsi/assets/capsule_en.json +4 -4
- package/dist/capabilities/pdf-discovery/carsi/CarsiMcpClient.js +1 -1
- package/dist/capabilities/pdf-discovery/handler.d.ts +6 -0
- package/dist/capabilities/pdf-discovery/handler.d.ts.map +1 -1
- package/dist/capabilities/pdf-discovery/handler.js +39 -5
- package/dist/capabilities/pdf-discovery/handler.js.map +1 -1
- package/dist/cli.js +11 -3
- package/dist/cli.js.map +1 -1
- package/dist/config/ConfigService.d.ts +4 -0
- package/dist/config/ConfigService.d.ts.map +1 -1
- package/dist/config/ConfigService.js +8 -0
- package/dist/config/ConfigService.js.map +1 -1
- package/dist/core/handleToolCall.js +2 -2
- package/dist/core/handleToolCall.js.map +1 -1
- package/dist/management/carsi/installer.d.ts +5 -0
- package/dist/management/carsi/installer.d.ts.map +1 -1
- package/dist/management/carsi/installer.js +16 -6
- package/dist/management/carsi/installer.js.map +1 -1
- package/dist/management/skills/nextSteps.js +1 -1
- package/dist/management/skills/nextSteps.js.map +1 -1
- package/dist/skills/SkillInstaller.d.ts +4 -0
- package/dist/skills/SkillInstaller.d.ts.map +1 -1
- package/dist/skills/SkillInstaller.js +20 -2
- package/dist/skills/SkillInstaller.js.map +1 -1
- package/package.json +2 -2
- package/skills/paper-search/SKILL.md +14 -10
- package/skills/paper-search/references/cli-contract.md +1 -0
- package/skills/paper-search/references/management-layer.md +20 -10
- package/skills/paper-search/references/setup.md +4 -4
- package/skills/paper-search/references/troubleshooting.md +3 -1
package/README.en.md
CHANGED
|
@@ -24,7 +24,7 @@ One sentence and your AI searches, verifies and downloads full texts and supplem
|
|
|
24
24
|
<a href="#demo-video">Demo video</a> · <a href="#quick-start">Quick start</a> · <a href="#1-school-subscription-downloads-carsi">School subscription downloads</a> · <a href="#2-api-keys">API keys</a> · <a href="docs/guide.en.md">Guide</a> · <a href="docs/ARCHITECTURE.zh.md">Architecture</a> · <a href="docs/ROADMAP.zh.md">Roadmap</a> · <a href="https://github.com/dr-dumpling/PaperSearch/issues/new/choose">Report an issue</a>
|
|
25
25
|
</p>
|
|
26
26
|
|
|
27
|
-
PaperSearch provides the `paper-search` command and a bundled Skill. Once installed, Claude Code, Codex,
|
|
27
|
+
PaperSearch provides the `paper-search` command and a bundled Skill. Once installed, Claude Code, Codex, DeepSeek, GLM, Kimi Code, Qwen Code, CodeBuddy and other AI tools that can run local commands can do this for you:
|
|
28
28
|
|
|
29
29
|
- **Search papers**: query more than 20 sources at once, including PubMed, Crossref, OpenAlex, Semantic Scholar and arXiv, with duplicates merged by DOI and DOIs verified.
|
|
30
30
|
- **Search full-text snippets**: search the paper bodies Semantic Scholar indexes for passages on methods or results, with their sources.
|
|
@@ -40,29 +40,35 @@ PaperSearch provides the `paper-search` command and a bundled Skill. Once instal
|
|
|
40
40
|
|
|
41
41
|
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
https://github.com/user-attachments/assets/6c75c5de-9dd5-42e0-9dea-f44a1b4f3aac
|
|
46
|
+
|
|
47
|
+
|
|
44
48
|
|
|
45
49
|
|
|
46
50
|
|
|
47
51
|
## Quick start
|
|
48
52
|
|
|
49
|
-
### 1. Install
|
|
53
|
+
### 1. Install
|
|
50
54
|
|
|
51
|
-
Send your AI tool this sentence (
|
|
55
|
+
Send your AI tool this sentence (Claude Code, Codex, DeepSeek, GLM, Kimi Code, Qwen Code, CodeBuddy and others all work):
|
|
52
56
|
|
|
53
57
|
```text
|
|
54
|
-
Please install PaperSearch:
|
|
58
|
+
Please install the PaperSearch Skill: npx skills add dr-dumpling/PaperSearch -g -y
|
|
55
59
|
```
|
|
56
60
|
|
|
57
|
-
|
|
61
|
+
On Windows the command needs Git; install [Git for Windows](https://git-scm.com/download/win) first if you do not have it.
|
|
58
62
|
|
|
59
|
-
|
|
63
|
+
Once it is installed, mention the Skill and send:
|
|
60
64
|
|
|
61
65
|
```text
|
|
62
|
-
Start setup
|
|
66
|
+
/paper-search Start setup
|
|
63
67
|
```
|
|
64
68
|
|
|
65
|
-
|
|
69
|
+
Your AI first asks whether to install the PaperSearch command-line program; once you agree, it installs it and then walks you through school subscription downloads (CARSI) and API keys.
|
|
70
|
+
|
|
71
|
+
<p align="center"><img src="assets/install.en.webp" width="840" alt="Install demo: send your AI one sentence and it installs the Skill; mention the Skill and say Start setup, and it asks before installing the command-line program, lists what works, and goes on to setup"></p>
|
|
66
72
|
|
|
67
73
|
### 2. Add school subscription downloads during setup
|
|
68
74
|
|
|
@@ -80,19 +86,19 @@ After "Start setup", your AI first asks whether you want school subscription dow
|
|
|
80
86
|
- **With school subscription downloads**: API keys, the download folder, waiting times and notifications all go in the settings window, and every key has a Test button. To change them later, ask your AI to open the settings, or click the gear on the capsule.
|
|
81
87
|
- **Without**: your AI lists the missing keys and where to get them (also in [API keys](#2-api-keys)); you enter them by running `paper-search setup` in a terminal, where the input is hidden, and your AI then tests each one.
|
|
82
88
|
|
|
83
|
-
### 4.
|
|
89
|
+
### 4. Start using it
|
|
84
90
|
|
|
85
|
-
Once set up, mention the PaperSearch Skill
|
|
91
|
+
Once set up, mention the PaperSearch Skill and say what you want to search for, for example:
|
|
86
92
|
|
|
87
93
|
<p align="center"><img src="assets/ask-with-skill.png" width="645" alt="Mentioning the PaperSearch Skill in the message box: the request ends with a Paper Search tag"></p>
|
|
88
94
|
|
|
89
95
|
| To do | You can say |
|
|
90
96
|
|---|---|
|
|
91
|
-
| Search papers |
|
|
92
|
-
| Search full-text snippets |
|
|
93
|
-
| Look up journal IF and quartiles |
|
|
94
|
-
| Look up citations and references |
|
|
95
|
-
| Download full texts and supplementary files |
|
|
97
|
+
| Search papers | `/paper-search` Find randomized trials of SGLT2 inhibitors in heart failure since 2020, and verify the DOIs |
|
|
98
|
+
| Search full-text snippets | `/paper-search` How did these trials define their primary endpoint? Quote a few passages |
|
|
99
|
+
| Look up journal IF and quartiles | `/paper-search` Which journals were they published in, and what are their impact factors and quartiles? |
|
|
100
|
+
| Look up citations and references | `/paper-search` Which studies have cited the DAPA-HF trial since it was published? |
|
|
101
|
+
| Download full texts and supplementary files | `/paper-search` Download the full texts and supplementary files of these papers to ./downloads |
|
|
96
102
|
|
|
97
103
|
**Results:**
|
|
98
104
|
|
|
@@ -101,7 +107,7 @@ Once set up, mention the PaperSearch Skill in the message box first, then say wh
|
|
|
101
107
|
<p align="center"><img src="assets/results.en.webp" width="840" alt="Results: the chat lists the 6 papers saved and how many supplementary files each has; the download folder holds one folder per paper, supplementary files in supplements/"></p>
|
|
102
108
|
|
|
103
109
|
- Search results, snippets, journal metrics and citations come back in the conversation.
|
|
104
|
-
-
|
|
110
|
+
- Each download gets its own `YYYYMMDD-HHmmss_PaperSearchDownload` folder inside your download folder, with one folder per paper and supplementary files in supplements/; you are told why any paper was not obtained.
|
|
105
111
|
|
|
106
112
|
## Optional setup
|
|
107
113
|
|
|
@@ -119,7 +125,7 @@ Feature comparison:
|
|
|
119
125
|
|  Open-access papers | ✅ | — | — |
|
|
120
126
|
|  Subscription papers | — | ✅ (Elsevier, Springer) | ✅ (30+ major publishers) |
|
|
121
127
|
|  Supplementary files | — | — | ✅ |
|
|
122
|
-
| **You need** | Node.js
|
|
128
|
+
| **You need** | Node.js 22 or later | Keys from each provider | Google Chrome, a school account |
|
|
123
129
|
| **How to turn it on** | Quick start step 1 | Settings window or terminal | Agree during setup |
|
|
124
130
|
|
|
125
131
|
### 1. School subscription downloads (CARSI)
|
|
@@ -167,21 +173,21 @@ paper-search carsi status --format text # check that it is ready
|
|
|
167
173
|
|
|
168
174
|
Keys fall into four groups by what they are for. Get the key you need and enter it any of the ways in [Quick start step 3](#3-add-api-keys-when-you-need-them).
|
|
169
175
|
|
|
170
|
-
#### Journal metrics and full-text snippets
|
|
176
|
+
#### Journal metrics and full-text snippets (recommended)
|
|
171
177
|
|
|
172
178
|
| Feature | Key | Where to get it |
|
|
173
179
|
|---|---|---|
|
|
174
|
-
| Look up impact factors and quartiles | `EASYSCHOLAR_KEY` | [EasyScholar](https://www.easyscholar.cc/) |
|
|
175
|
-
| Search full-text snippets | `SEMANTIC_SCHOLAR_API_KEY` | [Semantic Scholar](https://www.semanticscholar.org/product/api) |
|
|
180
|
+
| Look up impact factors and quartiles | `EASYSCHOLAR_KEY` | [EasyScholar](https://www.easyscholar.cc/) ([guide](https://docs.qq.com/aio/DTUxwZ3hUckVtZVJN), in Chinese) |
|
|
181
|
+
| Search full-text snippets | `SEMANTIC_SCHOLAR_API_KEY` | [Semantic Scholar](https://www.semanticscholar.org/product/api) ([guide](https://docs.qq.com/aio/DTW9RdFVHc2hJUmpx), in Chinese) |
|
|
176
182
|
|
|
177
|
-
#### Subscribed full texts through publisher APIs
|
|
183
|
+
#### Subscribed full texts through publisher APIs (optional)
|
|
178
184
|
|
|
179
185
|
| Publisher | Key | Where to get it |
|
|
180
186
|
|---|---|---|
|
|
181
187
|
| Elsevier | `ELSEVIER_API_KEY`; off campus, subscription articles also need `ELSEVIER_INSTTOKEN` | [Elsevier](https://dev.elsevier.com/apikey/manage) |
|
|
182
188
|
| Springer | `SPRINGER_API_KEY` | [Springer Nature](https://dev.springernature.com/) |
|
|
183
189
|
|
|
184
|
-
#### More search sources
|
|
190
|
+
#### More search sources (optional)
|
|
185
191
|
|
|
186
192
|
| Source | Key | Where to get it |
|
|
187
193
|
|---|---|---|
|
|
@@ -190,7 +196,7 @@ Keys fall into four groups by what they are for. Get the key you need and enter
|
|
|
190
196
|
| ScienceDirect, Scopus | `ELSEVIER_API_KEY` (the same key as above) | [Elsevier](https://dev.elsevier.com/apikey/manage) |
|
|
191
197
|
| Springer | `SPRINGER_API_KEY` (the same key as above) | [Springer Nature](https://dev.springernature.com/) |
|
|
192
198
|
|
|
193
|
-
#### Higher limits, steadier access
|
|
199
|
+
#### Higher limits, steadier access (optional)
|
|
194
200
|
|
|
195
201
|
| Source | Key | Where to get it |
|
|
196
202
|
|---|---|---|
|
package/README.md
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
<a href="#演示视频">演示视频</a> · <a href="#快速开始">快速开始</a> · <a href="#1-学校订阅下载carsi">学校订阅下载</a> · <a href="#2-api-key">API key</a> · <a href="docs/guide.zh.md">使用说明</a> · <a href="docs/ARCHITECTURE.zh.md">架构说明</a> · <a href="docs/ROADMAP.zh.md">路线图</a> · <a href="https://github.com/dr-dumpling/PaperSearch/issues/new/choose">反馈问题</a>
|
|
25
25
|
</p>
|
|
26
26
|
|
|
27
|
-
PaperSearch 提供 `paper-search` 命令和一份随包 Skill。装好后,Claude Code、Codex、
|
|
27
|
+
PaperSearch 提供 `paper-search` 命令和一份随包 Skill。装好后,Claude Code、Codex、DeepSeek、GLM、Kimi Code、Qwen Code、CodeBuddy 等支持本机命令调用的 AI 工具,就能替你:
|
|
28
28
|
|
|
29
29
|
- **检索论文**:一次查 PubMed、Crossref、OpenAlex、Semantic Scholar、arXiv 等 20 多个数据源,按 DOI 合并重复,核对 DOI。
|
|
30
30
|
- **搜正文片段**:利用 Semantic Scholar 收录的论文正文,搜原句,找到方法、结果的原文和出处。
|
|
@@ -40,29 +40,35 @@ PaperSearch 提供 `paper-search` 命令和一份随包 Skill。装好后,Clau
|
|
|
40
40
|
|
|
41
41
|
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
https://github.com/user-attachments/assets/c6ba529d-0b4e-4c2a-82cb-1ef8ba53274c
|
|
46
|
+
|
|
47
|
+
|
|
44
48
|
|
|
45
49
|
|
|
46
50
|
|
|
47
51
|
## 快速开始
|
|
48
52
|
|
|
49
|
-
### 1.
|
|
53
|
+
### 1. 安装
|
|
50
54
|
|
|
51
|
-
把这句话发给你的 AI
|
|
55
|
+
把这句话发给你的 AI 工具(Claude Code、Codex、DeepSeek、GLM、Kimi Code、Qwen Code、CodeBuddy 等等都行):
|
|
52
56
|
|
|
53
57
|
```text
|
|
54
|
-
请帮我安装 PaperSearch:
|
|
58
|
+
请帮我安装 PaperSearch 的 Skill:npx skills add dr-dumpling/PaperSearch -g -y
|
|
55
59
|
```
|
|
56
60
|
|
|
57
|
-
|
|
61
|
+
Windows 上这条命令需要 Git,没有的话先装 [Git for Windows](https://git-scm.com/download/win)。
|
|
58
62
|
|
|
59
|
-
|
|
63
|
+
装好后引用 Skill,发这句:
|
|
60
64
|
|
|
61
65
|
```text
|
|
62
|
-
请开始配置
|
|
66
|
+
/paper-search 请开始配置
|
|
63
67
|
```
|
|
64
68
|
|
|
65
|
-
|
|
69
|
+
AI 会先问你要不要装 PaperSearch 的命令行程序,你同意后装好,再带你配置学校订阅下载(CARSI)和 API key。
|
|
70
|
+
|
|
71
|
+
<p align="center"><img src="assets/install.webp" width="840" alt="安装演示:把一句话发给 AI,它先装好 Skill;引用 Skill 说“请开始配置”,它先问再装命令行程序,列出能用的功能,接着带你配置"></p>
|
|
66
72
|
|
|
67
73
|
### 2. 配置时装上学校订阅下载
|
|
68
74
|
|
|
@@ -80,19 +86,19 @@ https://github.com/user-attachments/assets/7573a2a8-0778-4062-aa3e-4ccffb482b0b
|
|
|
80
86
|
- **用学校订阅下载**:API key、下载文件夹、等待时间和提醒都在设置窗口里填,每个 key 都能点“测试”。之后想改,让 AI 打开设置,或点胶囊上的齿轮。
|
|
81
87
|
- **不用**:AI 列出还缺的 key 和申请入口(也见 [API key](#2-api-key)),你在终端运行 `paper-search setup` 填入,输入时不显示;填完 AI 逐个测试能不能用。
|
|
82
88
|
|
|
83
|
-
### 4.
|
|
89
|
+
### 4. 开始使用
|
|
84
90
|
|
|
85
|
-
|
|
91
|
+
配置好后,引用 PaperSearch 的 Skill,说出你需要搜索的内容,比如:
|
|
86
92
|
|
|
87
93
|
<p align="center"><img src="assets/ask-with-skill.png" width="645" alt="在输入框里引用 PaperSearch 的 Skill:要做的事后面带着 Paper Search 标签"></p>
|
|
88
94
|
|
|
89
95
|
| 想做什么 | 可以这样说 |
|
|
90
96
|
|---|---|
|
|
91
|
-
| 检索论文 |
|
|
92
|
-
| 搜正文片段 |
|
|
93
|
-
| 查期刊 IF 与分区 |
|
|
94
|
-
| 查引文和参考文献 |
|
|
95
|
-
| 下载全文和补充材料 |
|
|
97
|
+
| 检索论文 | `/paper-search` 找 2020 年以来 SGLT2 抑制剂治疗心力衰竭的随机对照试验,核对 DOI |
|
|
98
|
+
| 搜正文片段 | `/paper-search` 这些试验的主要终点,原文是怎么定义的?摘几段原文 |
|
|
99
|
+
| 查期刊 IF 与分区 | `/paper-search` 它们发表在哪些期刊?影响因子和分区各是多少 |
|
|
100
|
+
| 查引文和参考文献 | `/paper-search` DAPA-HF 试验发表后,有哪些研究引用了它 |
|
|
101
|
+
| 下载全文和补充材料 | `/paper-search` 把这些论文的全文和补充材料下载到 ./downloads |
|
|
96
102
|
|
|
97
103
|
**拿到结果:**
|
|
98
104
|
|
|
@@ -101,7 +107,7 @@ https://github.com/user-attachments/assets/7573a2a8-0778-4062-aa3e-4ccffb482b0b
|
|
|
101
107
|
<p align="center"><img src="assets/results.webp" width="840" alt="拿到结果:对话里列出下好的 6 篇和各自的补充材料数量;下载文件夹里每篇一个文件夹,补充材料在 supplements/ 里"></p>
|
|
102
108
|
|
|
103
109
|
- 检索、正文片段、期刊指标和引文,直接在对话里列给你。
|
|
104
|
-
-
|
|
110
|
+
- 每次下载在下载文件夹里新建一个 `年月日-时分秒_PaperSearchDownload` 文件夹,里面每篇一个文件夹,补充材料在 supplements/ 里;没拿到的篇目告诉你原因。
|
|
105
111
|
|
|
106
112
|
## 可选配置
|
|
107
113
|
|
|
@@ -119,7 +125,7 @@ https://github.com/user-attachments/assets/7573a2a8-0778-4062-aa3e-4ccffb482b0b
|
|
|
119
125
|
|  下载 OA 文章 | ✅ | — | — |
|
|
120
126
|
|  下载非 OA 文章 | — | ✅(Elsevier、Springer) | ✅(30+主流出版社) |
|
|
121
127
|
|  下载补充材料 | — | — | ✅ |
|
|
122
|
-
| **需要准备** | Node.js
|
|
128
|
+
| **需要准备** | Node.js 22 或以上 | 到各家网站申请 key | Google Chrome、学校账号 |
|
|
123
129
|
| **怎么开启** | 快速开始第 1 步 | 设置窗口或终端 | 配置时同意安装 |
|
|
124
130
|
|
|
125
131
|
### 1. 学校订阅下载(CARSI)
|
|
@@ -167,21 +173,21 @@ paper-search carsi status --format text # 查看是否装好
|
|
|
167
173
|
|
|
168
174
|
按用途分四类,需要哪类就申请对应的 key,再用[快速开始第 3 步](#3-按需填-api-key)里的任一方式填入。
|
|
169
175
|
|
|
170
|
-
####
|
|
176
|
+
#### 查期刊、搜正文(推荐配置)
|
|
171
177
|
|
|
172
178
|
| 功能 | 要填的 key | 去哪里申请 |
|
|
173
179
|
|---|---|---|
|
|
174
|
-
| 查影响因子和分区 | `EASYSCHOLAR_KEY` | [EasyScholar](https://www.easyscholar.cc/) |
|
|
175
|
-
| 搜正文片段 | `SEMANTIC_SCHOLAR_API_KEY` | [Semantic Scholar](https://www.semanticscholar.org/product/api) |
|
|
180
|
+
| 查影响因子和分区 | `EASYSCHOLAR_KEY` | [EasyScholar](https://www.easyscholar.cc/)([申请教程](https://docs.qq.com/aio/DTUxwZ3hUckVtZVJN)) |
|
|
181
|
+
| 搜正文片段 | `SEMANTIC_SCHOLAR_API_KEY` | [Semantic Scholar](https://www.semanticscholar.org/product/api)([申请教程](https://docs.qq.com/aio/DTW9RdFVHc2hJUmpx)) |
|
|
176
182
|
|
|
177
|
-
####
|
|
183
|
+
#### 下载订阅全文(出版社接口,非必须)
|
|
178
184
|
|
|
179
185
|
| 出版社 | 要填的 key | 去哪里申请 |
|
|
180
186
|
|---|---|---|
|
|
181
187
|
| Elsevier | `ELSEVIER_API_KEY`;校外下订阅文章还要 `ELSEVIER_INSTTOKEN` | [Elsevier](https://dev.elsevier.com/apikey/manage) |
|
|
182
188
|
| Springer | `SPRINGER_API_KEY` | [Springer Nature](https://dev.springernature.com/) |
|
|
183
189
|
|
|
184
|
-
####
|
|
190
|
+
#### 增加检索来源(非必须)
|
|
185
191
|
|
|
186
192
|
| 来源 | 要填的 key | 去哪里申请 |
|
|
187
193
|
|---|---|---|
|
|
@@ -190,7 +196,7 @@ paper-search carsi status --format text # 查看是否装好
|
|
|
190
196
|
| ScienceDirect、Scopus | `ELSEVIER_API_KEY`(和上面同一个) | [Elsevier](https://dev.elsevier.com/apikey/manage) |
|
|
191
197
|
| Springer | `SPRINGER_API_KEY`(和上面同一个) | [Springer Nature](https://dev.springernature.com/) |
|
|
192
198
|
|
|
193
|
-
####
|
|
199
|
+
#### 提高限额、更稳定(非必须)
|
|
194
200
|
|
|
195
201
|
| 来源 | 要填的 key | 去哪里申请 |
|
|
196
202
|
|---|---|---|
|
package/assets/overview.en.png
CHANGED
|
Binary file
|
package/assets/overview.png
CHANGED
|
Binary file
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"groups": [
|
|
3
3
|
{
|
|
4
|
-
"title": "
|
|
4
|
+
"title": "查期刊、搜正文(推荐配置)",
|
|
5
5
|
"services": [
|
|
6
6
|
{
|
|
7
7
|
"id": "easyscholar",
|
|
8
8
|
"name": "EasyScholar",
|
|
9
9
|
"use": "查影响因子和分区",
|
|
10
10
|
"url": "https://www.easyscholar.cc/",
|
|
11
|
+
"guide": "https://docs.qq.com/aio/DTUxwZ3hUckVtZVJN",
|
|
12
|
+
"guide_label": "申请教程",
|
|
11
13
|
"keys": [
|
|
12
14
|
{
|
|
13
15
|
"key": "EASYSCHOLAR_KEY",
|
|
@@ -32,7 +34,7 @@
|
|
|
32
34
|
]
|
|
33
35
|
},
|
|
34
36
|
{
|
|
35
|
-
"title": "
|
|
37
|
+
"title": "出版社接口(非必须)",
|
|
36
38
|
"services": [
|
|
37
39
|
{
|
|
38
40
|
"id": "elsevier",
|
|
@@ -61,7 +63,7 @@
|
|
|
61
63
|
]
|
|
62
64
|
},
|
|
63
65
|
{
|
|
64
|
-
"title": "
|
|
66
|
+
"title": "增加检索来源(非必须)",
|
|
65
67
|
"services": [
|
|
66
68
|
{
|
|
67
69
|
"id": "wos",
|
|
@@ -90,7 +92,7 @@
|
|
|
90
92
|
]
|
|
91
93
|
},
|
|
92
94
|
{
|
|
93
|
-
"title": "
|
|
95
|
+
"title": "提高限额(非必须)",
|
|
94
96
|
"services": [
|
|
95
97
|
{
|
|
96
98
|
"id": "pubmed",
|
|
@@ -195,10 +195,10 @@
|
|
|
195
195
|
"每家出版社每小时最多": "Per publisher per hour",
|
|
196
196
|
"秒": "s",
|
|
197
197
|
"篇": "papers",
|
|
198
|
-
"
|
|
199
|
-
"
|
|
200
|
-
"
|
|
201
|
-
"
|
|
198
|
+
"查期刊、搜正文(推荐配置)": "Journals & snippets (recommended)",
|
|
199
|
+
"出版社接口(非必须)": "Publisher APIs (optional)",
|
|
200
|
+
"增加检索来源(非必须)": "More sources (optional)",
|
|
201
|
+
"提高限额(非必须)": "Higher limits (optional)",
|
|
202
202
|
"查影响因子和分区": "Impact factor & rank",
|
|
203
203
|
"搜正文片段": "Full-text snippets",
|
|
204
204
|
"下载全文,检索 ScienceDirect、Scopus": "Full text; search ScienceDirect, Scopus",
|
|
@@ -18,7 +18,7 @@ export const CARSI_DOWNLOAD_TIMEOUT_MS = 1_200_000;
|
|
|
18
18
|
export const CARSI_CLEANUP_TIMEOUT_MS = 5_000;
|
|
19
19
|
const CARSI_BACKEND_SOURCE = "carsi";
|
|
20
20
|
// MCP clientInfo is informational only; keep in step with package.json on release.
|
|
21
|
-
const PAPER_SEARCH_MCP_CLIENT_VERSION = "0.5.
|
|
21
|
+
const PAPER_SEARCH_MCP_CLIENT_VERSION = "0.5.9";
|
|
22
22
|
const NO_BATCH_SUPPORT = {
|
|
23
23
|
downloadFields: false,
|
|
24
24
|
supplementsField: false,
|
|
@@ -2,6 +2,12 @@ import type { Searchers } from "../../core/searchers.js";
|
|
|
2
2
|
import { downloadWithFallback } from "./OpenAccessFallbackService.js";
|
|
3
3
|
import type { CarsiBackend } from "./carsi/index.js";
|
|
4
4
|
import { type DownloadBatchOptions } from "./batch.js";
|
|
5
|
+
/**
|
|
6
|
+
* The folder of this download (runDownloadFolder). A caller's own serial batch, several calls with one batch id,
|
|
7
|
+
* keeps the folder its first call got: remembered for two days in the run ledger's batch-folders.json. With the
|
|
8
|
+
* ledger turned off every call gets its own folder.
|
|
9
|
+
*/
|
|
10
|
+
export declare function downloadRunFolder(savePath?: string, batchId?: string, now?: Date): string;
|
|
5
11
|
export declare function handleDownloadPaper(args: {
|
|
6
12
|
paperId: string;
|
|
7
13
|
platform: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../src/capabilities/pdf-discovery/handler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../src/capabilities/pdf-discovery/handler.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEzD,OAAO,EAEL,oBAAoB,EACrB,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAOrD,OAAO,EAIL,KAAK,oBAAoB,EAC1B,MAAM,YAAY,CAAC;AAcpB;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,GAAE,IAAiB,GAAG,MAAM,CAqBrG;AA4BD,wBAAsB,mBAAmB,CACvC,IAAI,EAAE;IACJ,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B,EACD,SAAS,EAAE,SAAS,EACpB,YAAY,CAAC,EAAE,YAAY;;;;;GAqB5B;AAED,wBAAsB,0BAA0B,CAC9C,IAAI,EAAE,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC,CAAC,CAAC,EAChD,SAAS,EAAE,SAAS,EACpB,YAAY,CAAC,EAAE,YAAY;;;;;GAuB5B;AAED,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,oBAAoB,EAC1B,SAAS,EAAE,SAAS,EACpB,YAAY,CAAC,EAAE,YAAY;;;;;GAM5B"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { resolveDownloadPath } from "../../config/ConfigService.js";
|
|
2
|
-
import {
|
|
1
|
+
import { resolveDownloadPath, runDownloadFolder } from "../../config/ConfigService.js";
|
|
2
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
3
4
|
import { resolvePlatformId } from "../../registry/platformMetadata.js";
|
|
4
5
|
import { createDefaultDownloadTiers, downloadWithFallback, } from "./OpenAccessFallbackService.js";
|
|
5
|
-
import { RunLedger } from "../../infrastructure/runlog/RunLedger.js";
|
|
6
|
+
import { RunLedger, resolveRunLogRoot } from "../../infrastructure/runlog/RunLedger.js";
|
|
6
7
|
import { downloadBatch, downloadBatchItem, downloadSupplementsOnly, } from "./batch.js";
|
|
7
8
|
import { asWindowBatch } from "./batchSummary.js";
|
|
8
9
|
function jsonTextResponse(text) {
|
|
@@ -15,6 +16,38 @@ function jsonTextResponse(text) {
|
|
|
15
16
|
],
|
|
16
17
|
};
|
|
17
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* The folder of this download (runDownloadFolder). A caller's own serial batch, several calls with one batch id,
|
|
21
|
+
* keeps the folder its first call got: remembered for two days in the run ledger's batch-folders.json. With the
|
|
22
|
+
* ledger turned off every call gets its own folder.
|
|
23
|
+
*/
|
|
24
|
+
export function downloadRunFolder(savePath, batchId, now = new Date()) {
|
|
25
|
+
const root = batchId ? resolveRunLogRoot() : null;
|
|
26
|
+
if (!batchId || !root)
|
|
27
|
+
return runDownloadFolder(savePath, now);
|
|
28
|
+
const file = join(root, "batch-folders.json");
|
|
29
|
+
let known = {};
|
|
30
|
+
if (existsSync(file)) {
|
|
31
|
+
try {
|
|
32
|
+
known = JSON.parse(readFileSync(file, "utf8"));
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
// Only this function writes the file; an unreadable one starts afresh.
|
|
36
|
+
known = {};
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const key = `${resolveDownloadPath(savePath)}\n${batchId}`;
|
|
40
|
+
if (known[key])
|
|
41
|
+
return known[key].folder;
|
|
42
|
+
const folder = runDownloadFolder(savePath, now);
|
|
43
|
+
for (const [k, v] of Object.entries(known))
|
|
44
|
+
if (now.getTime() - v.at > 2 * 86_400_000)
|
|
45
|
+
delete known[k];
|
|
46
|
+
known[key] = { folder, at: now.getTime() };
|
|
47
|
+
mkdirSync(root, { recursive: true });
|
|
48
|
+
writeFileSync(file, `${JSON.stringify(known, null, 2)}\n`);
|
|
49
|
+
return folder;
|
|
50
|
+
}
|
|
18
51
|
/** One download recorded as its own run in the local run ledger. */
|
|
19
52
|
async function recordedDownload(options, download) {
|
|
20
53
|
options = { ...options, savePath: resolveDownloadPath(options.savePath) };
|
|
@@ -40,7 +73,7 @@ async function recordedDownload(options, download) {
|
|
|
40
73
|
}
|
|
41
74
|
export async function handleDownloadPaper(args, searchers, carsiBackend) {
|
|
42
75
|
const { paperId, platform, savePath, useEntitledAccess } = args;
|
|
43
|
-
const resolvedSavePath =
|
|
76
|
+
const resolvedSavePath = downloadRunFolder(savePath);
|
|
44
77
|
const resolvedPlatform = resolvePlatformId(platform);
|
|
45
78
|
const result = await recordedDownload({
|
|
46
79
|
source: resolvedPlatform,
|
|
@@ -53,6 +86,7 @@ export async function handleDownloadPaper(args, searchers, carsiBackend) {
|
|
|
53
86
|
return jsonTextResponse(`Download paper ${result.status}.\n\n${JSON.stringify(result, null, 2)}`);
|
|
54
87
|
}
|
|
55
88
|
export async function handleDownloadWithFallback(args, searchers, carsiBackend) {
|
|
89
|
+
args = { ...args, savePath: downloadRunFolder(args.savePath, args.batch?.id) };
|
|
56
90
|
const tiers = createDefaultDownloadTiers(carsiBackend);
|
|
57
91
|
// A caller's own serial batch reports each item; a lone download is a batch of one.
|
|
58
92
|
const download = async (options, callerBatch) => {
|
|
@@ -75,7 +109,7 @@ export async function handleDownloadWithFallback(args, searchers, carsiBackend)
|
|
|
75
109
|
return jsonTextResponse(`Download with fallback ${result.status}.\n\n${JSON.stringify(result, null, 2)}`);
|
|
76
110
|
}
|
|
77
111
|
export async function handleDownloadBatch(args, searchers, carsiBackend) {
|
|
78
|
-
const result = await downloadBatch(searchers, args, carsiBackend);
|
|
112
|
+
const result = await downloadBatch(searchers, { ...args, savePath: downloadRunFolder(args.savePath) }, carsiBackend);
|
|
79
113
|
return jsonTextResponse(`Download batch ${result.status}: ${result.succeeded}/${result.total} succeeded.\n\n${JSON.stringify(result, null, 2)}`);
|
|
80
114
|
}
|
|
81
115
|
//# sourceMappingURL=handler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.js","sourceRoot":"","sources":["../../../src/capabilities/pdf-discovery/handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"handler.js","sourceRoot":"","sources":["../../../src/capabilities/pdf-discovery/handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AACvF,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AACvE,OAAO,EACL,0BAA0B,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iB,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,YAAY,CAAC,CAAC;IACrH,OAAO,gBAAgB,CACrB,kBAAkB,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC,SAAS,IAAI,MAAM,CAAC,KAAK,kBAAkB,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CACxH,CAAC;AACJ,CAAC"}
|
package/dist/cli.js
CHANGED
|
@@ -197,10 +197,18 @@ function parseJsonArgs(value) {
|
|
|
197
197
|
if (typeof value !== "string") {
|
|
198
198
|
throw new CliError("--json-args expects a JSON string or @file path", "INVALID_JSON_ARGS");
|
|
199
199
|
}
|
|
200
|
-
|
|
200
|
+
// Windows PowerShell 5.1 writes UTF-8 files with a BOM.
|
|
201
|
+
const raw = (value.startsWith("@")
|
|
201
202
|
? readFileSync(value.slice(1), "utf8")
|
|
202
|
-
: value;
|
|
203
|
-
|
|
203
|
+
: value).replace(/^\uFEFF/, "");
|
|
204
|
+
let parsed;
|
|
205
|
+
try {
|
|
206
|
+
parsed = JSON.parse(raw);
|
|
207
|
+
}
|
|
208
|
+
catch (error) {
|
|
209
|
+
// Windows PowerShell drops the double quotes inside an argument it passes on (DeepSeek, 2026-11-11).
|
|
210
|
+
throw new CliError(`--json-args is not valid JSON (${error?.message || String(error)}). In Windows PowerShell the double quotes inside the argument are dropped before paper-search sees them: write the JSON to a UTF-8 file and pass --json-args '@<file>'.`, "INVALID_JSON_ARGS");
|
|
211
|
+
}
|
|
204
212
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
205
213
|
throw new CliError("--json-args must decode to a JSON object", "INVALID_JSON_ARGS");
|
|
206
214
|
}
|