papersearch 0.5.8 → 0.5.10

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 (53) hide show
  1. package/README.en.md +22 -16
  2. package/README.md +22 -16
  3. package/assets/overview.en.png +0 -0
  4. package/assets/overview.png +0 -0
  5. package/carsi/paper_search_carsi/adapters/base.py +5 -0
  6. package/carsi/paper_search_carsi/adapters/elsevier/__init__.py +28 -0
  7. package/carsi/paper_search_carsi/api_keys.py +10 -5
  8. package/carsi/paper_search_carsi/assets/api_keys.json +45 -15
  9. package/carsi/paper_search_carsi/assets/capsule.html +35 -18
  10. package/carsi/paper_search_carsi/assets/capsule_en.json +19 -5
  11. package/carsi/paper_search_carsi/engine/batch_institution.py +2 -0
  12. package/carsi/paper_search_carsi/progress_capsule.py +4 -10
  13. package/carsi/paper_search_carsi/progress_reporter.py +8 -4
  14. package/carsi/paper_search_carsi/progress_view.py +10 -2
  15. package/dist/capabilities/pdf-discovery/batch.js +3 -0
  16. package/dist/capabilities/pdf-discovery/batch.js.map +1 -1
  17. package/dist/capabilities/pdf-discovery/batchSummary.d.ts.map +1 -1
  18. package/dist/capabilities/pdf-discovery/batchSummary.js +14 -5
  19. package/dist/capabilities/pdf-discovery/batchSummary.js.map +1 -1
  20. package/dist/capabilities/pdf-discovery/carsi/CarsiMcpClient.js +1 -1
  21. package/dist/capabilities/pdf-discovery/carsi/CarsiMcpClient.js.map +1 -1
  22. package/dist/capabilities/pdf-discovery/carsi/types.d.ts +4 -1
  23. package/dist/capabilities/pdf-discovery/carsi/types.d.ts.map +1 -1
  24. package/dist/capabilities/pdf-discovery/handler.d.ts +12 -0
  25. package/dist/capabilities/pdf-discovery/handler.d.ts.map +1 -1
  26. package/dist/capabilities/pdf-discovery/handler.js +64 -5
  27. package/dist/capabilities/pdf-discovery/handler.js.map +1 -1
  28. package/dist/cli.js +11 -3
  29. package/dist/cli.js.map +1 -1
  30. package/dist/config/ConfigService.d.ts +4 -0
  31. package/dist/config/ConfigService.d.ts.map +1 -1
  32. package/dist/config/ConfigService.js +8 -0
  33. package/dist/config/ConfigService.js.map +1 -1
  34. package/dist/config/apiKeySignup.d.ts +8 -1
  35. package/dist/config/apiKeySignup.d.ts.map +1 -1
  36. package/dist/config/apiKeySignup.js +15 -2
  37. package/dist/config/apiKeySignup.js.map +1 -1
  38. package/dist/config/apiKeyTest.d.ts +1 -0
  39. package/dist/config/apiKeyTest.d.ts.map +1 -1
  40. package/dist/config/apiKeyTest.js +23 -5
  41. package/dist/config/apiKeyTest.js.map +1 -1
  42. package/dist/core/handleToolCall.js +2 -2
  43. package/dist/core/handleToolCall.js.map +1 -1
  44. package/dist/management/carsi/installer.d.ts +5 -0
  45. package/dist/management/carsi/installer.d.ts.map +1 -1
  46. package/dist/management/carsi/installer.js +16 -6
  47. package/dist/management/carsi/installer.js.map +1 -1
  48. package/package.json +1 -1
  49. package/skills/paper-search/SKILL.md +2 -2
  50. package/skills/paper-search/references/browser-download.md +1 -1
  51. package/skills/paper-search/references/cli-contract.md +1 -0
  52. package/skills/paper-search/references/setup.md +1 -1
  53. package/skills/paper-search/references/troubleshooting.md +1 -0
package/README.en.md CHANGED
@@ -40,7 +40,11 @@ PaperSearch provides the `paper-search` command and a bundled Skill. Once instal
40
40
 
41
41
 
42
42
 
43
- https://github.com/user-attachments/assets/9d54521b-bdb9-451c-89d8-889ec203bec1
43
+
44
+
45
+ https://github.com/user-attachments/assets/6c75c5de-9dd5-42e0-9dea-f44a1b4f3aac
46
+
47
+
44
48
 
45
49
 
46
50
 
@@ -54,10 +58,12 @@ Send your AI tool this sentence (Claude Code, Codex, DeepSeek, GLM, Kimi Code, Q
54
58
  Please install the PaperSearch Skill: npx skills add dr-dumpling/PaperSearch -g -y
55
59
  ```
56
60
 
61
+ On Windows the command needs Git; install [Git for Windows](https://git-scm.com/download/win) first if you do not have it.
62
+
57
63
  Once it is installed, mention the Skill and send:
58
64
 
59
65
  ```text
60
- $paper-search Start setup
66
+ /paper-search Start setup
61
67
  ```
62
68
 
63
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.
@@ -84,15 +90,13 @@ After "Start setup", your AI first asks whether you want school subscription dow
84
90
 
85
91
  Once set up, mention the PaperSearch Skill and say what you want to search for, for example:
86
92
 
87
- <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
-
89
93
  | To do | You can say |
90
94
  |---|---|
91
- | Search papers | `$paper-search` Find randomized trials of SGLT2 inhibitors in heart failure since 2020, and verify the DOIs |
92
- | Search full-text snippets | `$paper-search` How did these trials define their primary endpoint? Quote a few passages |
93
- | Look up journal IF and quartiles | `$paper-search` Which journals were they published in, and what are their impact factors and quartiles? |
94
- | Look up citations and references | `$paper-search` Which studies have cited the DAPA-HF trial since it was published? |
95
- | Download full texts and supplementary files | `$paper-search` Download the full texts and supplementary files of these papers to ./downloads |
95
+ | Search papers | `/paper-search` Find randomized trials of SGLT2 inhibitors in heart failure since 2020, and verify the DOIs |
96
+ | Search full-text snippets | `/paper-search` How did these trials define their primary endpoint? Quote a few passages |
97
+ | Look up journal IF and quartiles | `/paper-search` Which journals were they published in, and what are their impact factors and quartiles? |
98
+ | Look up citations and references | `/paper-search` Which studies have cited the DAPA-HF trial since it was published? |
99
+ | Download full texts and supplementary files | `/paper-search` Download the full texts and supplementary files of these papers to ./downloads |
96
100
 
97
101
  **Results:**
98
102
 
@@ -101,7 +105,7 @@ Once set up, mention the PaperSearch Skill and say what you want to search for,
101
105
  <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
106
 
103
107
  - Search results, snippets, journal metrics and citations come back in the conversation.
104
- - Downloaded papers are organized into folders, one per paper, with supplementary files in supplements/; you are told why any paper was not obtained.
108
+ - 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
109
 
106
110
  ## Optional setup
107
111
 
@@ -165,16 +169,17 @@ paper-search carsi status --format text # check that it is ready
165
169
 
166
170
  ### 2. API keys
167
171
 
168
- 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).
172
+ Keys fall into four groups by what they are for. Get the key you need (an email needs no sign-up) and enter it any of the ways in [Quick start step 3](#3-add-api-keys-when-you-need-them).
169
173
 
170
- #### Journal metrics and full-text snippets (recommended)
174
+ #### Journal metrics, full-text snippets and free full texts (recommended)
171
175
 
172
176
  | Feature | Key | Where to get it |
173
177
  |---|---|---|
174
178
  | Look up impact factors and quartiles | `EASYSCHOLAR_KEY` | [EasyScholar](https://www.easyscholar.cc/) ([guide](https://docs.qq.com/aio/DTUxwZ3hUckVtZVJN), in Chinese) |
175
179
  | 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) |
180
+ | Find free full texts when downloading | `PAPER_SEARCH_UNPAYWALL_EMAIL` | No sign-up ([Unpaywall: about](https://unpaywall.org/products/api)) |
176
181
 
177
- #### Subscribed full texts through publisher APIs (optional)
182
+ #### Subscribed full texts (optional)
178
183
 
179
184
  | Publisher | Key | Where to get it |
180
185
  |---|---|---|
@@ -190,16 +195,17 @@ Keys fall into four groups by what they are for. Get the key you need and enter
190
195
  | ScienceDirect, Scopus | `ELSEVIER_API_KEY` (the same key as above) | [Elsevier](https://dev.elsevier.com/apikey/manage) |
191
196
  | Springer | `SPRINGER_API_KEY` (the same key as above) | [Springer Nature](https://dev.springernature.com/) |
192
197
 
193
- #### Higher limits, steadier access (optional)
198
+ #### Faster, steadier search (optional)
194
199
 
195
200
  | Source | Key | Where to get it |
196
201
  |---|---|---|
202
+ | Crossref (search papers, check that DOIs are real) | `CROSSREF_MAILTO` | No sign-up ([about](https://www.crossref.org/documentation/retrieve-metadata/rest-api/tips-for-using-the-crossref-rest-api/)) |
197
203
  | PubMed | `PUBMED_API_KEY` | [NCBI](https://ncbiinsights.ncbi.nlm.nih.gov/2017/11/02/new-api-keys-for-the-e-utilities/) |
204
+ | OpenAlex (all citing papers past 10,000) | `OPENALEX_API_KEY` | [OpenAlex](https://openalex.org/settings/api) |
198
205
  | CORE | `CORE_API_KEY` | [CORE](https://core.ac.uk/services/api) |
199
206
  | OpenAIRE | `OPENAIRE_API_KEY` | [OpenAIRE](https://develop.openaire.eu/) |
200
- | OpenAlex (all citing papers past 10,000) | `OPENALEX_API_KEY` | [OpenAlex](https://openalex.org/settings/api) |
201
207
 
202
- Settings are saved in `~/.config/paper-search-cli/config.json`, readable only by you. The download folder, contact emails, proxy, automatic updates and other settings are in [Guide · Other settings](docs/guide.en.md#other-settings).
208
+ Settings are saved in `~/.config/paper-search-cli/config.json`, readable only by you. The download folder, proxy, automatic updates and other settings are in [Guide · Other settings](docs/guide.en.md#other-settings).
203
209
 
204
210
  ## More documentation
205
211
 
package/README.md CHANGED
@@ -40,7 +40,11 @@ PaperSearch 提供 `paper-search` 命令和一份随包 Skill。装好后,Clau
40
40
 
41
41
 
42
42
 
43
- https://github.com/user-attachments/assets/7573a2a8-0778-4062-aa3e-4ccffb482b0b
43
+
44
+
45
+ https://github.com/user-attachments/assets/c6ba529d-0b4e-4c2a-82cb-1ef8ba53274c
46
+
47
+
44
48
 
45
49
 
46
50
 
@@ -54,10 +58,12 @@ https://github.com/user-attachments/assets/7573a2a8-0778-4062-aa3e-4ccffb482b0b
54
58
  请帮我安装 PaperSearch 的 Skill:npx skills add dr-dumpling/PaperSearch -g -y
55
59
  ```
56
60
 
61
+ Windows 上这条命令需要 Git,没有的话先装 [Git for Windows](https://git-scm.com/download/win)。
62
+
57
63
  装好后引用 Skill,发这句:
58
64
 
59
65
  ```text
60
- $paper-search 请开始配置
66
+ /paper-search 请开始配置
61
67
  ```
62
68
 
63
69
  AI 会先问你要不要装 PaperSearch 的命令行程序,你同意后装好,再带你配置学校订阅下载(CARSI)和 API key。
@@ -84,15 +90,13 @@ AI 会先问你要不要装 PaperSearch 的命令行程序,你同意后装好
84
90
 
85
91
  配置好后,引用 PaperSearch 的 Skill,说出你需要搜索的内容,比如:
86
92
 
87
- <p align="center"><img src="assets/ask-with-skill.png" width="645" alt="在输入框里引用 PaperSearch 的 Skill:要做的事后面带着 Paper Search 标签"></p>
88
-
89
93
  | 想做什么 | 可以这样说 |
90
94
  |---|---|
91
- | 检索论文 | `$paper-search` 找 2020 年以来 SGLT2 抑制剂治疗心力衰竭的随机对照试验,核对 DOI |
92
- | 搜正文片段 | `$paper-search` 这些试验的主要终点,原文是怎么定义的?摘几段原文 |
93
- | 查期刊 IF 与分区 | `$paper-search` 它们发表在哪些期刊?影响因子和分区各是多少 |
94
- | 查引文和参考文献 | `$paper-search` DAPA-HF 试验发表后,有哪些研究引用了它 |
95
- | 下载全文和补充材料 | `$paper-search` 把这些论文的全文和补充材料下载到 ./downloads |
95
+ | 检索论文 | `/paper-search` 找 2020 年以来 SGLT2 抑制剂治疗心力衰竭的随机对照试验,核对 DOI |
96
+ | 搜正文片段 | `/paper-search` 这些试验的主要终点,原文是怎么定义的?摘几段原文 |
97
+ | 查期刊 IF 与分区 | `/paper-search` 它们发表在哪些期刊?影响因子和分区各是多少 |
98
+ | 查引文和参考文献 | `/paper-search` DAPA-HF 试验发表后,有哪些研究引用了它 |
99
+ | 下载全文和补充材料 | `/paper-search` 把这些论文的全文和补充材料下载到 ./downloads |
96
100
 
97
101
  **拿到结果:**
98
102
 
@@ -101,7 +105,7 @@ AI 会先问你要不要装 PaperSearch 的命令行程序,你同意后装好
101
105
  <p align="center"><img src="assets/results.webp" width="840" alt="拿到结果:对话里列出下好的 6 篇和各自的补充材料数量;下载文件夹里每篇一个文件夹,补充材料在 supplements/ 里"></p>
102
106
 
103
107
  - 检索、正文片段、期刊指标和引文,直接在对话里列给你。
104
- - 下载的论文整理成文件夹,每篇一个文件夹,补充材料在 supplements/ 里;没拿到的篇目告诉你原因。
108
+ - 每次下载在下载文件夹里新建一个 `年月日-时分秒_PaperSearchDownload` 文件夹,里面每篇一个文件夹,补充材料在 supplements/ 里;没拿到的篇目告诉你原因。
105
109
 
106
110
  ## 可选配置
107
111
 
@@ -165,16 +169,17 @@ paper-search carsi status --format text # 查看是否装好
165
169
 
166
170
  ### 2. API key
167
171
 
168
- 按用途分四类,需要哪类就申请对应的 key,再用[快速开始第 3 步](#3-按需填-api-key)里的任一方式填入。
172
+ 按用途分四类,需要哪类就申请对应的 key(邮箱直接填,不用申请),再用[快速开始第 3 步](#3-按需填-api-key)里的任一方式填入。
169
173
 
170
- #### 查期刊、搜正文(推荐配置)
174
+ #### 查期刊、搜正文、找免费全文(推荐配置)
171
175
 
172
176
  | 功能 | 要填的 key | 去哪里申请 |
173
177
  |---|---|---|
174
178
  | 查影响因子和分区 | `EASYSCHOLAR_KEY` | [EasyScholar](https://www.easyscholar.cc/)([申请教程](https://docs.qq.com/aio/DTUxwZ3hUckVtZVJN)) |
175
179
  | 搜正文片段 | `SEMANTIC_SCHOLAR_API_KEY` | [Semantic Scholar](https://www.semanticscholar.org/product/api)([申请教程](https://docs.qq.com/aio/DTW9RdFVHc2hJUmpx)) |
180
+ | 下载时找免费全文 | `PAPER_SEARCH_UNPAYWALL_EMAIL` | 不用申请([Unpaywall 说明](https://unpaywall.org/products/api)) |
176
181
 
177
- #### 下载订阅全文(出版社接口,非必须)
182
+ #### 下载订阅全文(非必须)
178
183
 
179
184
  | 出版社 | 要填的 key | 去哪里申请 |
180
185
  |---|---|---|
@@ -190,16 +195,17 @@ paper-search carsi status --format text # 查看是否装好
190
195
  | ScienceDirect、Scopus | `ELSEVIER_API_KEY`(和上面同一个) | [Elsevier](https://dev.elsevier.com/apikey/manage) |
191
196
  | Springer | `SPRINGER_API_KEY`(和上面同一个) | [Springer Nature](https://dev.springernature.com/) |
192
197
 
193
- #### 提高限额、更稳定(非必须)
198
+ #### 检索更快、更稳定(非必须)
194
199
 
195
200
  | 来源 | 要填的 key | 去哪里申请 |
196
201
  |---|---|---|
202
+ | Crossref(检索论文、核对 DOI 是否真实) | `CROSSREF_MAILTO` | 不用申请([说明](https://www.crossref.org/documentation/retrieve-metadata/rest-api/tips-for-using-the-crossref-rest-api/)) |
197
203
  | PubMed | `PUBMED_API_KEY` | [NCBI](https://ncbiinsights.ncbi.nlm.nih.gov/2017/11/02/new-api-keys-for-the-e-utilities/) |
204
+ | OpenAlex(被引超过 1 万篇时列全) | `OPENALEX_API_KEY` | [OpenAlex](https://openalex.org/settings/api) |
198
205
  | CORE | `CORE_API_KEY` | [CORE](https://core.ac.uk/services/api) |
199
206
  | OpenAIRE | `OPENAIRE_API_KEY` | [OpenAIRE](https://develop.openaire.eu/) |
200
- | OpenAlex(被引超过 1 万篇时列全) | `OPENALEX_API_KEY` | [OpenAlex](https://openalex.org/settings/api) |
201
207
 
202
- 配置保存在 `~/.config/paper-search-cli/config.json`,只有你自己能读。下载文件夹、联系邮箱、代理和自动更新等其他设置,见 [使用说明 · 其他设置](docs/guide.zh.md#其他设置)。
208
+ 配置保存在 `~/.config/paper-search-cli/config.json`,只有你自己能读。下载文件夹、代理和自动更新等其他设置,见 [使用说明 · 其他设置](docs/guide.zh.md#其他设置)。
203
209
 
204
210
  ## 更多文档
205
211
 
Binary file
Binary file
@@ -231,6 +231,11 @@ class PublisherAdapter:
231
231
  school is chosen (``choose_institution``) and nothing else is clicked."""
232
232
  return False
233
233
 
234
+ def leave_email_step(self, page: Any, result: Any) -> bool:
235
+ """The publisher's sign-in asks for the user's work email, not the school:
236
+ go back to its school search before anything is typed; True when clicked."""
237
+ return False
238
+
234
239
  def prepare_institution_choice(self, page: Any, result: Any) -> bool | None:
235
240
  """In the CARSI school choice, after the federation form and the school
236
241
  assistance, before the SeamlessAccess and publisher choosers: the
@@ -19,6 +19,7 @@ import re
19
19
  from typing import Any
20
20
  from urllib.parse import quote, urlparse
21
21
 
22
+ from ...browser.driver import is_driver_error
22
23
  from ...engine.router import elsevier_journal_article, extract_elsevier_pii
23
24
  from ..base import PublisherAdapter, SupplementLink, register
24
25
  from . import journal_site, sciencedirect
@@ -67,6 +68,20 @@ def supplement_links_from_rows(rows: Any, page_url: str, doi: str) -> list[Suppl
67
68
  # In CARSI mode only the generic chooser is used (never a remembered school's
68
69
  # InstitutionLogin shortcut); otherwise a remembered entry must name the
69
70
  # configured school.
71
+ # Elsevier ID's "Enter your organizational email" (Windows, 2026-11-11): the same
72
+ # #bdd-email field as "Find your organization", but for an email only; its
73
+ # "Access via another organization" leads back to the search by name.
74
+ _EMAIL_STEP_JS = """() => {
75
+ const shown = (el) => !!el && el.getClientRects().length > 0;
76
+ const field = document.querySelector("#bdd-email");
77
+ const label = (document.querySelector("#emaillabel") || {}).textContent || "";
78
+ const other = document.querySelector("#bdd-elsSecondaryBtn");
79
+ if (!shown(field) || !/e-?mail/i.test(label) || /name/i.test(label) || !shown(other)
80
+ || !/another organi[sz]ation/i.test(other.textContent || "")) return false;
81
+ other.click();
82
+ return true;
83
+ }"""
84
+
70
85
  _ENTRY_JS = """
71
86
  ({manualSelection, institutionQuery}) => {
72
87
  const visible = (el) => {
@@ -235,6 +250,19 @@ class ElsevierAdapter(PublisherAdapter):
235
250
  return True
236
251
  return False
237
252
 
253
+ def leave_email_step(self, page: Any, result: Any) -> bool:
254
+ if not self.is_institution_chooser(str(getattr(page, "url", "") or "")):
255
+ return False
256
+ try:
257
+ clicked = page.evaluate(_EMAIL_STEP_JS) is True
258
+ except Exception as exc:
259
+ if not is_driver_error(exc):
260
+ raise
261
+ return False # the page moved on while it was read
262
+ if clicked:
263
+ self.d._event(result, "elsevier_email_step_left", "Access via another organization")
264
+ return clicked
265
+
238
266
  def is_redirect_page(self, url: str) -> bool:
239
267
  # doi.org -> linkinghub "Redirecting" -> ScienceDirect, the journal's site or
240
268
  # ClinicalKey; and Elsevier ID's sign-in round trip a PDF request may take
@@ -21,6 +21,7 @@ from . import cli_config
21
21
  CATALOG = Path(__file__).resolve().parent / "assets" / "api_keys.json"
22
22
  MAX_LENGTH = 512
23
23
  _PRINTABLE = re.compile(r"^[\x21-\x7e]+$") # visible ASCII: no spaces, line breaks or full-width characters
24
+ _EMAIL = re.compile(r"^[^@\s]+@[^@\s]+\.[^@\s]+$")
24
25
 
25
26
 
26
27
  def groups() -> list[dict[str, Any]]:
@@ -48,10 +49,12 @@ def _status(service: dict[str, Any], config: dict) -> dict[str, Any]:
48
49
  keys = []
49
50
  for key in service["keys"]:
50
51
  value = str(config.get(key["key"]) or "").strip()
51
- keys.append({"key": key["key"], "label": key["label"], "set": bool(value), "masked": mask(value) if value else ""})
52
+ keys.append({"key": key["key"], "label": key["label"], "kind": key.get("kind", "key"),
53
+ "set": bool(value), "masked": mask(value) if value else ""})
52
54
  primary = keys[0]
53
55
  return {"id": service["id"], "name": service["name"], "use": service.get("use", ""), "url": service["url"],
54
56
  "guide": service.get("guide", ""), "guide_label": service.get("guide_label", ""),
57
+ "signup_label": service.get("signup_label", ""), "note": service.get("note", ""),
55
58
  "keys": keys, "set": primary["set"], "masked": primary["masked"]}
56
59
 
57
60
 
@@ -63,9 +66,11 @@ def listing() -> dict[str, Any]:
63
66
  return {"groups": shown, "filled": sum(1 for s in every if s["set"]), "total": len(every)}
64
67
 
65
68
 
66
- def check(value: str) -> tuple[str, str]:
67
- """A pasted value, trimmed, or why it cannot be a key."""
69
+ def check(value: str, kind: str = "key") -> tuple[str, str]:
70
+ """A pasted value, trimmed, or why it cannot be a key (an email for an email field)."""
68
71
  value = str(value or "").strip()
72
+ if kind == "email":
73
+ return (value, "") if not value or (len(value) <= 254 and _EMAIL.match(value)) else ("", "邮箱格式不对")
69
74
  if len(value) > MAX_LENGTH:
70
75
  return "", "太长了,请确认粘贴的是 key"
71
76
  if value and not _PRINTABLE.match(value):
@@ -91,11 +96,11 @@ def save(service_id: str, values: dict[str, str]) -> None:
91
96
  service = _service(service_id)
92
97
  changes: dict[str, str | None] = {}
93
98
  for key in service["keys"]:
94
- value, problem = check((values or {}).get(key["key"], ""))
99
+ value, problem = check((values or {}).get(key["key"], ""), key.get("kind", "key"))
95
100
  if problem:
96
101
  raise ValueError(problem)
97
102
  if not value:
98
- raise ValueError("请先粘贴 key;要删除请点“清除”")
103
+ raise ValueError("请先填写邮箱;要删除请点“清除”" if key.get("kind") == "email" else "请先粘贴 key;要删除请点“清除”")
99
104
  changes[key["key"]] = value
100
105
  cli_config.update(changes)
101
106
 
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "groups": [
3
3
  {
4
- "title": "查期刊、搜正文(推荐配置)",
4
+ "title": "查期刊、搜正文、找免费全文(推荐配置)",
5
5
  "services": [
6
6
  {
7
7
  "id": "easyscholar",
@@ -30,11 +30,26 @@
30
30
  "label": "API key"
31
31
  }
32
32
  ]
33
+ },
34
+ {
35
+ "id": "unpaywall",
36
+ "name": "Unpaywall",
37
+ "use": "下载时找免费全文",
38
+ "note": "填你常用的邮箱就行,不用注册",
39
+ "url": "https://unpaywall.org/products/api",
40
+ "signup_label": "说明",
41
+ "keys": [
42
+ {
43
+ "key": "PAPER_SEARCH_UNPAYWALL_EMAIL",
44
+ "label": "email",
45
+ "kind": "email"
46
+ }
47
+ ]
33
48
  }
34
49
  ]
35
50
  },
36
51
  {
37
- "title": "出版社接口(非必须)",
52
+ "title": "下载订阅全文(非必须)",
38
53
  "services": [
39
54
  {
40
55
  "id": "elsevier",
@@ -92,8 +107,23 @@
92
107
  ]
93
108
  },
94
109
  {
95
- "title": "提高限额(非必须)",
110
+ "title": "检索更快、更稳定(非必须)",
96
111
  "services": [
112
+ {
113
+ "id": "crossref",
114
+ "name": "Crossref",
115
+ "use": "检索论文、核对 DOI 是否真实",
116
+ "note": "填你常用的邮箱就行,不用注册",
117
+ "url": "https://www.crossref.org/documentation/retrieve-metadata/rest-api/tips-for-using-the-crossref-rest-api/",
118
+ "signup_label": "说明",
119
+ "keys": [
120
+ {
121
+ "key": "CROSSREF_MAILTO",
122
+ "label": "email",
123
+ "kind": "email"
124
+ }
125
+ ]
126
+ },
97
127
  {
98
128
  "id": "pubmed",
99
129
  "name": "PubMed",
@@ -106,6 +136,18 @@
106
136
  }
107
137
  ]
108
138
  },
139
+ {
140
+ "id": "openalex",
141
+ "name": "OpenAlex",
142
+ "use": "查引文的限额更高,被引过万也能列全",
143
+ "url": "https://openalex.org/settings/api",
144
+ "keys": [
145
+ {
146
+ "key": "OPENALEX_API_KEY",
147
+ "label": "API key"
148
+ }
149
+ ]
150
+ },
109
151
  {
110
152
  "id": "core",
111
153
  "name": "CORE",
@@ -129,18 +171,6 @@
129
171
  "label": "API key"
130
172
  }
131
173
  ]
132
- },
133
- {
134
- "id": "openalex",
135
- "name": "OpenAlex",
136
- "use": "查引文的限额更高,被引过万也能列全",
137
- "url": "https://openalex.org/settings/api",
138
- "keys": [
139
- {
140
- "key": "OPENALEX_API_KEY",
141
- "label": "API key"
142
- }
143
- ]
144
174
  }
145
175
  ]
146
176
  }
@@ -166,6 +166,7 @@ svg.i { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-widt
166
166
  .key-row .btn { pointer-events: none; }
167
167
  .key-edit { background: var(--hover); border-radius: 8px; padding: 8px 10px; margin: 0 0 6px; }
168
168
  .settings .key-edit input { width: 100%; text-align: left; background: var(--bg); }
169
+ .key-note { font-size: 11px; line-height: 1.5; color: var(--dim); margin-bottom: 8px; }
169
170
  .key-edit .err { text-align: left; margin: 6px 0 0; }
170
171
  .key-edit .err:empty { display: none; }
171
172
  .key-edit .err.ok { color: var(--ok); }
@@ -202,6 +203,7 @@ svg.i { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-widt
202
203
  .sec { margin-top: 14px; }
203
204
  .sec-h { display: flex; align-items: baseline; gap: 6px; font-size: 12px; color: var(--dim); margin-bottom: 4px; }
204
205
  .sec-h b { color: var(--fg); font-weight: 600; font-size: 13px; }
206
+ .list-sub { margin-top: 10px; }
205
207
  .saved-line { font-size: 12px; color: var(--dim); line-height: 1.6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
206
208
  .grp { border-top: 0.5px solid var(--line); padding: 8px 0; }
207
209
  .grp:last-child { border-bottom: 0.5px solid var(--line); }
@@ -216,7 +218,7 @@ svg.i { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-widt
216
218
  .paper-list.scroll { -webkit-mask-image: linear-gradient(to bottom, #000 80%, transparent); mask-image: linear-gradient(to bottom, #000 80%, transparent); }
217
219
  .paper-list li { font-size: 12px; padding: 3px 0; }
218
220
  /* A list page scrolls as one, up to half the screen; its groups open in full inside it. */
219
- .papers-scroll { overflow-y: auto; overscroll-behavior: contain; }
221
+ .papers-scroll, .keys-scroll { overflow-y: auto; overscroll-behavior: contain; }
220
222
  .papers-scroll .paper-list { max-height: none; overflow: visible; }
221
223
  .paper-list .t, .paper-list .w { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
222
224
  .paper-list .w, .paper-list .more { color: var(--faint); }
@@ -522,11 +524,12 @@ function listRow(g, i) {
522
524
  return html + '<ul class="paper-list">'
523
525
  + g.papers.map((p) => {
524
526
  const lines = '<div class="t">' + esc(p.title) + "</div>" + (p.where ? '<div class="w">' + esc(p.where) + "</div>" : "");
525
- // A saved paper shows its PDF in its folder; a failed one opens its article page, to fetch it by hand.
527
+ // A saved paper shows its PDF in its folder; a failed one opens its article page, to fetch it by hand,
528
+ // and so does one still waiting (user, 2026-11-11).
526
529
  if (papersKind === "ok") {
527
530
  return '<li><button type="button" class="open-article" data-act="show_paper" data-index="' + p.index + '" title="打开所在文件夹">' + lines + "</button></li>";
528
531
  }
529
- if (papersKind === "failed" && p.doi) {
532
+ if ((papersKind === "failed" || papersKind === "left") && p.doi) {
530
533
  return '<li><button type="button" class="open-article" data-act="open_article" data-doi="' + esc(p.doi)
531
534
  + '" title="在浏览器打开这篇文章">' + lines + "</button></li>";
532
535
  }
@@ -535,6 +538,9 @@ function listRow(g, i) {
535
538
  + (g.more ? '<li class="more">另有 ' + g.more + " 篇未列出</li>" : "") + "</ul></div>";
536
539
  }
537
540
 
541
+ // A long list scrolls within half the screen at most, its title staying in place above it (user, 2026-11-10).
542
+ function listMaxHeight() { return Math.max(240, Math.round((screen.availHeight || 900) / 2) - 64); }
543
+
538
544
  function papersCard() {
539
545
  const list = shownList();
540
546
  const note = flash.text && Date.now() < flash.until ? flash.text : "";
@@ -542,10 +548,11 @@ function papersCard() {
542
548
  + '<div class="drag capsule-drag-region"><div class="text"><div class="title">' + LIST_TITLES[papersKind] + " " + list.count + " 篇</div></div></div></div>";
543
549
  if (note) html += '<div class="line">' + esc(note) + "</div>";
544
550
  if (!list.groups.length) html += '<div class="line">' + (papersList ? "没有论文" : "正在读取…") + "</div>";
545
- // Half the screen at most, the title staying in place above it (user, 2026-11-10).
546
- const most = Math.max(240, Math.round((screen.availHeight || 900) / 2) - 64);
547
- return html + '<div class="sec papers-scroll" style="max-height:' + most + 'px">'
548
- + list.groups.map((g, i) => listRow(g, i)).join("") + "</div></div>";
551
+ // Saved papers missing supplementary files follow the failed ones, as on the finished card (user, 2026-11-11).
552
+ const heading = (g, i) => g.supplement && !(list.groups[i - 1] || {}).supplement
553
+ ? '<div class="sec-h list-sub"><b>附录未下全 ' + (list.supplement_count || 0) + " 篇</b><span>正文已保存</span></div>" : "";
554
+ return html + '<div class="sec papers-scroll" style="max-height:' + listMaxHeight() + 'px">'
555
+ + list.groups.map((g, i) => heading(g, i) + listRow(g, i)).join("") + "</div></div>";
549
556
  }
550
557
 
551
558
  function idleCard() {
@@ -642,16 +649,19 @@ function keyRow(s) {
642
649
  + (s.set ? '<span class="key-set">' + esc(s.masked) + "</span>" : '<span class="dim" style="font-size:12px">未填</span>')
643
650
  + '</div><div class="key-edit">';
644
651
  // A saved key is in its field, hidden until the eye shows it.
652
+ // A contact email: what it is for above its field, and the field in plain text (user, 2026-11-11).
653
+ const emails = s.keys.every((k) => k.kind === "email");
654
+ if (s.note) html += '<div class="key-note">' + esc(s.note) + "</div>";
645
655
  for (const k of s.keys) {
646
- html += '<input id="key-' + esc(k.key) + '" data-key="' + esc(k.key) + '" type="' + (revealed ? "text" : "password")
656
+ html += '<input id="key-' + esc(k.key) + '" data-key="' + esc(k.key) + '" type="' + (revealed || k.kind === "email" ? "text" : "password")
647
657
  + '" value="' + esc(editValues[k.key] || "") + '" autocomplete="off" spellcheck="false" aria-label="' + esc(s.name + " " + k.label)
648
- + '" placeholder="粘贴 key">';
658
+ + '" placeholder="' + (k.kind === "email" ? "填你常用的邮箱" : "粘贴 key") + '">';
649
659
  }
650
660
  return html + '<div class="key-links">'
651
- + '<button class="btn link" data-act="signup" data-service="' + esc(s.id) + '">去申请' + icon("external") + "</button>"
661
+ + '<button class="btn link" data-act="signup" data-service="' + esc(s.id) + '">' + esc(s.signup_label || "去申请") + icon("external") + "</button>"
652
662
  + (s.guide ? '<button class="btn link" data-act="guide" data-service="' + esc(s.id) + '">' + esc(s.guide_label || "教程") + icon("external") + "</button>" : "")
653
663
  + '<span class="grow"></span>'
654
- + '<button class="iconbtn" data-act="reveal" aria-label="显示 key" aria-pressed="' + revealed + '">' + icon("eye") + "</button></div>"
664
+ + (emails ? "" : '<button class="iconbtn" data-act="reveal" aria-label="显示 key" aria-pressed="' + revealed + '">' + icon("eye") + "</button>") + "</div>"
655
665
  + '<div class="err" id="key-error" role="status"></div><div class="key-actions">'
656
666
  + '<button class="btn" data-act="test_key" data-service="' + esc(s.id) + '">测试</button><span class="grow"></span>'
657
667
  + (s.set ? '<button class="btn danger" data-act="clear_key" data-service="' + esc(s.id) + '">清除</button>' : "")
@@ -662,10 +672,10 @@ function keyRow(s) {
662
672
  function settingsKeys() {
663
673
  let html = settingsHead("API key");
664
674
  if (!apiKeys || !apiKeys.ok) return html + '<div class="err" style="text-align:left">' + esc((apiKeys && apiKeys.error) || "读取配置失败") + "</div>";
665
- for (const group of apiKeys.groups) {
666
- html += '<div class="key-group">' + esc(group.title) + "</div>" + group.services.map(keyRow).join("");
667
- }
668
- return html;
675
+ // Twelve services and an opened one's editor: a list of their own (user, 2026-11-11).
676
+ return html + '<div class="keys-scroll" style="max-height:' + listMaxHeight() + 'px">'
677
+ + apiKeys.groups.map((group) => '<div class="key-group">' + esc(group.title) + "</div>" + group.services.map(keyRow).join("")).join("")
678
+ + "</div>";
669
679
  }
670
680
 
671
681
  function settingsCard() {
@@ -770,7 +780,7 @@ function keyError(text, tone) {
770
780
  if (line) { line.textContent = tr(text); line.className = "err" + (tone ? " " + tone : ""); }
771
781
  }
772
782
 
773
- let lastCls = "", hovering = false, closing = false, dragging = false, endingDrag = false;
783
+ let lastCls = "", lastPlace = "", hovering = false, closing = false, dragging = false, endingDrag = false;
774
784
  let dragReady = Promise.resolve();
775
785
  let attentionPointer = null;
776
786
  let renderedAttention = null;
@@ -808,8 +818,14 @@ function render(force) {
808
818
  root.style.width = ""; root.style.height = "";
809
819
  root.style.removeProperty("--content-max-height");
810
820
  if (!unchanged) {
821
+ // A scrolled list keeps its place while its page is redrawn (a key opened or saved, a group opened).
822
+ const place = panel + ":" + (panel === "settings" ? settingsPage : papersKind);
823
+ const scrolled = place === lastPlace ? root.querySelector(".papers-scroll, .keys-scroll")?.scrollTop || 0 : 0;
824
+ lastPlace = place;
811
825
  root.className = cls + " capsule-drag-region" + (cls !== lastCls ? " fade" : "");
812
826
  root.innerHTML = '<div class="surface">' + html + "</div>";
827
+ const list = root.querySelector(".papers-scroll, .keys-scroll");
828
+ if (list) list.scrollTop = scrolled;
813
829
  localize(root);
814
830
  if (attention) updateAttentionCountdown();
815
831
  renderedAttention = attention ? V : null;
@@ -949,7 +965,8 @@ async function act(action, target) {
949
965
  case "edit_key":
950
966
  editValues = await savedValues(target.dataset.service);
951
967
  editing = target.dataset.service; confirmClear = ""; revealed = false; render(true);
952
- return root.querySelector(".key-edit input")?.focus();
968
+ root.querySelector(".key-edit")?.scrollIntoView({ block: "nearest" });
969
+ return root.querySelector(".key-edit input")?.focus({ preventScroll: true });
953
970
  case "cancel_key": editing = ""; editValues = {}; confirmClear = ""; return render(true);
954
971
  case "reveal":
955
972
  revealed = !revealed;
@@ -1037,7 +1054,7 @@ async function act(action, target) {
1037
1054
  }
1038
1055
 
1039
1056
  // A paper list scrolls; pressing in it must not drag the window.
1040
- const interactive = (target) => target.closest('button, input, select, textarea, a, [contenteditable="true"], [role="button"], .paper-list, .papers-scroll');
1057
+ const interactive = (target) => target.closest('button, input, select, textarea, a, [contenteditable="true"], [role="button"], .paper-list, .papers-scroll, .keys-scroll');
1041
1058
  root.addEventListener("pointerdown", (event) => {
1042
1059
  if (event.button === 0 && api().activate_on_input) inputActivation = api().activate_on_input();
1043
1060
  if (event.button === 0 && event.target.closest(".attention-target")) {
@@ -195,10 +195,7 @@
195
195
  "每家出版社每小时最多": "Per publisher per hour",
196
196
  "秒": "s",
197
197
  "篇": "papers",
198
- "查期刊、搜正文(推荐配置)": "Journals & snippets (recommended)",
199
- "出版社接口(非必须)": "Publisher APIs (optional)",
200
198
  "增加检索来源(非必须)": "More sources (optional)",
201
- "提高限额(非必须)": "Higher limits (optional)",
202
199
  "查影响因子和分区": "Impact factor & rank",
203
200
  "搜正文片段": "Full-text snippets",
204
201
  "下载全文,检索 ScienceDirect、Scopus": "Full text; search ScienceDirect, Scopus",
@@ -248,7 +245,6 @@
248
245
  "没有论文": "No papers",
249
246
  "正在读取…": "Loading…",
250
247
  "打开失败:没有这篇的 PDF": "Couldn't open: no PDF saved",
251
- "打开失败:PDF 不在这批的下载文件夹里": "Couldn't open: PDF outside the batch folder",
252
248
  "打开失败:文件已被移走或删除": "Couldn't open: file moved or deleted",
253
249
  "打开所在文件夹": "Show in folder",
254
250
  "已打开所在文件夹": "Shown in its folder",
@@ -270,7 +266,21 @@
270
266
  "测试通知没有发出:这台电脑不发系统通知": "Test not sent: no system notifications here",
271
267
  "✓ 已发出,右上角应弹出一条通知": "✓ Sent; see the top right",
272
268
  "✓ 已发出,右下角应弹出一条通知": "✓ Sent; see the bottom right",
273
- "改好后再点一次“测试”": "Then press Test again"
269
+ "改好后再点一次“测试”": "Then press Test again",
270
+ "说明": "About",
271
+ "邮箱格式不对": "Not an email address",
272
+ "请先填写邮箱;要删除请点“清除”": "Enter an email first; Clear removes it",
273
+ "填你常用的邮箱": "Your usual email",
274
+ "可以用:Unpaywall 接受这个邮箱": "Works: Unpaywall takes it",
275
+ "被拒绝:Unpaywall 不接受这个邮箱,请填你自己常用的邮箱": "Rejected by Unpaywall: use your own email",
276
+ "可以用:已走 Crossref 优先通道": "Works: Crossref polite pool",
277
+ "Crossref 没有认这个邮箱,仍走普通通道": "Crossref didn't take it: public pool",
278
+ "查期刊、搜正文、找免费全文(推荐配置)": "Journals, snippets, free texts (recommended)",
279
+ "下载订阅全文(非必须)": "Subscribed texts (optional)",
280
+ "检索更快、更稳定(非必须)": "Faster, steady search (optional)",
281
+ "下载时找免费全文": "Finds free full texts",
282
+ "检索论文、核对 DOI 是否真实": "Search papers; check DOIs are real",
283
+ "填你常用的邮箱就行,不用注册": "Your usual email will do; no sign-up"
274
284
  },
275
285
  "patterns": [
276
286
  [
@@ -433,6 +443,10 @@
433
443
  "^被拒绝:key 不对,或已失效((.+))$",
434
444
  "Rejected: wrong or expired key ($1)"
435
445
  ],
446
+ [
447
+ "^被拒绝:Unpaywall 不接受这个邮箱,请填你自己常用的邮箱((.+))$",
448
+ "Rejected by Unpaywall: use your own email ($1)"
449
+ ],
436
450
  [
437
451
  "^服务器限流,稍后再试;key 本身可能没问题((.+))$",
438
452
  "Rate-limited; try later ($1)"
@@ -71,6 +71,8 @@ class InstitutionMixin:
71
71
  def _select_institution(self, page: Any, result: DownloadResult) -> bool:
72
72
  if getattr(self, "_manual_school", False):
73
73
  return False # the user reported a wrong school: they choose it in the window
74
+ if self.adapter.leave_email_step(page, result):
75
+ return True # an email field takes no school name (Elsevier ID, 2026-11-11)
74
76
  if self.config.get("publisher_institution_federation") == "carsi":
75
77
  if self._has_publisher_institution_session(page):
76
78
  # The publisher already shows a signed-in school: nothing to choose