papersearch 0.5.6 → 0.5.7
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 +8 -6
- package/README.md +8 -6
- package/assets/ask-with-skill.png +0 -0
- package/carsi/paper_search_carsi/assets/capsule.html +173 -21
- package/carsi/paper_search_carsi/assets/capsule_en.json +64 -1
- package/carsi/paper_search_carsi/browser/watchdog.py +6 -1
- package/carsi/paper_search_carsi/capsule_placement.py +8 -5
- package/carsi/paper_search_carsi/capsule_window.py +495 -0
- package/carsi/paper_search_carsi/cli.py +2 -2
- package/carsi/paper_search_carsi/engine/batch_capture.py +11 -3
- package/carsi/paper_search_carsi/engine/batch_login.py +3 -2
- package/carsi/paper_search_carsi/engine/batch_waits.py +28 -7
- package/carsi/paper_search_carsi/i18n.py +5 -0
- package/carsi/paper_search_carsi/progress_capsule.py +177 -426
- package/carsi/paper_search_carsi/progress_macos.py +53 -6
- package/carsi/paper_search_carsi/progress_reporter.py +132 -20
- package/carsi/paper_search_carsi/progress_view.py +95 -14
- package/carsi/paper_search_carsi/server.py +25 -3
- package/dist/capabilities/pdf-discovery/OpenAccessFallbackService.js +1 -1
- package/dist/capabilities/pdf-discovery/OpenAccessFallbackService.js.map +1 -1
- package/dist/capabilities/pdf-discovery/batch.d.ts +4 -3
- package/dist/capabilities/pdf-discovery/batch.d.ts.map +1 -1
- package/dist/capabilities/pdf-discovery/batch.js +217 -85
- package/dist/capabilities/pdf-discovery/batch.js.map +1 -1
- package/dist/capabilities/pdf-discovery/batchPapers.d.ts +19 -0
- package/dist/capabilities/pdf-discovery/batchPapers.d.ts.map +1 -0
- package/dist/capabilities/pdf-discovery/batchPapers.js +44 -0
- package/dist/capabilities/pdf-discovery/batchPapers.js.map +1 -0
- package/dist/capabilities/pdf-discovery/batchSummary.d.ts +6 -1
- package/dist/capabilities/pdf-discovery/batchSummary.d.ts.map +1 -1
- package/dist/capabilities/pdf-discovery/batchSummary.js +33 -8
- package/dist/capabilities/pdf-discovery/batchSummary.js.map +1 -1
- package/dist/capabilities/pdf-discovery/carsi/CarsiAttempt.js +1 -1
- package/dist/capabilities/pdf-discovery/carsi/CarsiAttempt.js.map +1 -1
- package/dist/capabilities/pdf-discovery/carsi/CarsiMcpClient.d.ts +13 -1
- package/dist/capabilities/pdf-discovery/carsi/CarsiMcpClient.d.ts.map +1 -1
- package/dist/capabilities/pdf-discovery/carsi/CarsiMcpClient.js +77 -25
- package/dist/capabilities/pdf-discovery/carsi/CarsiMcpClient.js.map +1 -1
- package/dist/capabilities/pdf-discovery/carsi/CarsiReadiness.d.ts +4 -0
- package/dist/capabilities/pdf-discovery/carsi/CarsiReadiness.d.ts.map +1 -1
- package/dist/capabilities/pdf-discovery/carsi/CarsiReadiness.js +5 -0
- package/dist/capabilities/pdf-discovery/carsi/CarsiReadiness.js.map +1 -1
- package/dist/capabilities/pdf-discovery/carsi/CarsiResultNormalizer.d.ts.map +1 -1
- package/dist/capabilities/pdf-discovery/carsi/CarsiResultNormalizer.js +4 -3
- package/dist/capabilities/pdf-discovery/carsi/CarsiResultNormalizer.js.map +1 -1
- package/dist/capabilities/pdf-discovery/carsi/index.d.ts +1 -1
- package/dist/capabilities/pdf-discovery/carsi/index.d.ts.map +1 -1
- package/dist/capabilities/pdf-discovery/carsi/types.d.ts +51 -2
- package/dist/capabilities/pdf-discovery/carsi/types.d.ts.map +1 -1
- package/dist/capabilities/pdf-discovery/handler.d.ts.map +1 -1
- package/dist/capabilities/pdf-discovery/handler.js +2 -1
- package/dist/capabilities/pdf-discovery/handler.js.map +1 -1
- package/dist/capabilities/pdf-discovery/outputLayout.d.ts +27 -2
- package/dist/capabilities/pdf-discovery/outputLayout.d.ts.map +1 -1
- package/dist/capabilities/pdf-discovery/outputLayout.js +133 -29
- package/dist/capabilities/pdf-discovery/outputLayout.js.map +1 -1
- package/dist/capabilities/pdf-discovery/types.d.ts +5 -0
- package/dist/capabilities/pdf-discovery/types.d.ts.map +1 -1
- package/dist/cli.js +1 -31
- package/dist/cli.js.map +1 -1
- package/dist/infrastructure/runlog/RunLedger.d.ts +4 -0
- package/dist/infrastructure/runlog/RunLedger.d.ts.map +1 -1
- package/dist/infrastructure/runlog/RunLedger.js +11 -3
- package/dist/infrastructure/runlog/RunLedger.js.map +1 -1
- package/dist/management/carsi/autoUpdate.d.ts +2 -2
- package/dist/management/carsi/autoUpdate.d.ts.map +1 -1
- package/dist/management/carsi/autoUpdate.js +8 -2
- package/dist/management/carsi/autoUpdate.js.map +1 -1
- package/dist/management/carsi/cliProgress.d.ts +8 -0
- package/dist/management/carsi/cliProgress.d.ts.map +1 -0
- package/dist/management/carsi/cliProgress.js +38 -0
- package/dist/management/carsi/cliProgress.js.map +1 -0
- package/dist/management/carsi/installer.d.ts.map +1 -1
- package/dist/management/carsi/installer.js +3 -6
- package/dist/management/carsi/installer.js.map +1 -1
- package/package.json +1 -1
- package/skills/paper-search/SKILL.md +1 -1
- package/skills/paper-search/references/browser-download.md +4 -4
- package/skills/paper-search/references/cli-contract.md +2 -2
- package/carsi/paper_search_carsi/progress_bar.py +0 -684
package/README.en.md
CHANGED
|
@@ -82,15 +82,17 @@ After "Start setup", your AI first asks whether you want school subscription dow
|
|
|
82
82
|
|
|
83
83
|
### 4. Tell your AI tool what you need
|
|
84
84
|
|
|
85
|
-
Once set up,
|
|
85
|
+
Once set up, mention the PaperSearch Skill in the message box first, then say what you need: type `$` (`/` in Claude Code) and pick `paper-search`. With the Skill mentioned, the AI searches with PaperSearch rather than its own web search.
|
|
86
|
+
|
|
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>
|
|
86
88
|
|
|
87
89
|
| To do | You can say |
|
|
88
90
|
|---|---|
|
|
89
|
-
| Search papers | Find randomized trials of SGLT2 inhibitors in heart failure since 2020, and verify the DOIs |
|
|
90
|
-
| Search full-text snippets | How did these trials define their primary endpoint? Quote a few passages |
|
|
91
|
-
| Look up journal IF and quartiles | Which journals were they published in, and what are their impact factors and quartiles? |
|
|
92
|
-
| Look up citations and references | Which studies have cited the DAPA-HF trial since it was published? |
|
|
93
|
-
| Download full texts and supplementary files | Download the full texts and supplementary files of these papers to ./downloads |
|
|
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 |
|
|
94
96
|
|
|
95
97
|
**Results:**
|
|
96
98
|
|
package/README.md
CHANGED
|
@@ -82,15 +82,17 @@ https://github.com/user-attachments/assets/7573a2a8-0778-4062-aa3e-4ccffb482b0b
|
|
|
82
82
|
|
|
83
83
|
### 4. 对 AI 说一句话
|
|
84
84
|
|
|
85
|
-
|
|
85
|
+
配置好后,在输入框里先引用 PaperSearch 的 Skill,再说你要做什么:输入 `$`(Claude Code 里是 `/`),选 `paper-search`。引用了它,AI 就一定用 PaperSearch 来查,不会改用自带的网页搜索。
|
|
86
|
+
|
|
87
|
+
<p align="center"><img src="assets/ask-with-skill.png" width="645" alt="在输入框里引用 PaperSearch 的 Skill:要做的事后面带着 Paper Search 标签"></p>
|
|
86
88
|
|
|
87
89
|
| 想做什么 | 可以这样说 |
|
|
88
90
|
|---|---|
|
|
89
|
-
| 检索论文 | 找 2020 年以来 SGLT2 抑制剂治疗心力衰竭的随机对照试验,核对 DOI |
|
|
90
|
-
| 搜正文片段 | 这些试验的主要终点,原文是怎么定义的?摘几段原文 |
|
|
91
|
-
| 查期刊 IF 与分区 | 它们发表在哪些期刊?影响因子和分区各是多少 |
|
|
92
|
-
| 查引文和参考文献 | DAPA-HF 试验发表后,有哪些研究引用了它 |
|
|
93
|
-
| 下载全文和补充材料 | 把这些论文的全文和补充材料下载到 ./downloads |
|
|
91
|
+
| 检索论文 | `$paper-search` 找 2020 年以来 SGLT2 抑制剂治疗心力衰竭的随机对照试验,核对 DOI |
|
|
92
|
+
| 搜正文片段 | `$paper-search` 这些试验的主要终点,原文是怎么定义的?摘几段原文 |
|
|
93
|
+
| 查期刊 IF 与分区 | `$paper-search` 它们发表在哪些期刊?影响因子和分区各是多少 |
|
|
94
|
+
| 查引文和参考文献 | `$paper-search` DAPA-HF 试验发表后,有哪些研究引用了它 |
|
|
95
|
+
| 下载全文和补充材料 | `$paper-search` 把这些论文的全文和补充材料下载到 ./downloads |
|
|
94
96
|
|
|
95
97
|
**拿到结果:**
|
|
96
98
|
|
|
Binary file
|
|
@@ -5,19 +5,23 @@
|
|
|
5
5
|
<title>PaperSearch</title>
|
|
6
6
|
<style>
|
|
7
7
|
:root {
|
|
8
|
-
|
|
8
|
+
/* Opaque: a transparent window has nothing behind it to blur, and the desktop showed
|
|
9
|
+
through the card (user, 2026-11-10). */
|
|
10
|
+
--bg: #ffffff; --fg: #111827; --dim: #6b7280; --faint: #9ca3af;
|
|
9
11
|
--line: rgba(17, 24, 39, 0.10); --track: rgba(17, 24, 39, 0.10); --hover: rgba(17, 24, 39, 0.06);
|
|
10
12
|
--accent: #2563eb; --ok: #16a34a; --bad: #dc2626;
|
|
11
13
|
--warn: #92400e; --warn-bg: #fef3c7; --warn-line: #f3d27a; --warn-dot: #d97706;
|
|
12
|
-
|
|
14
|
+
/* Inside the window's 10 px margin (body.mac): a shadow running past it was cut off
|
|
15
|
+
square on the desktop (2026-11-10). */
|
|
16
|
+
--shadow: 0 3px 7px rgba(0, 0, 0, 0.14), 0 1px 2px rgba(0, 0, 0, 0.08);
|
|
13
17
|
}
|
|
14
18
|
@media (prefers-color-scheme: dark) {
|
|
15
19
|
:root {
|
|
16
|
-
--bg:
|
|
20
|
+
--bg: #202124; --fg: #f3f4f6; --dim: #a1a1aa; --faint: #71717a;
|
|
17
21
|
--line: rgba(255, 255, 255, 0.12); --track: rgba(255, 255, 255, 0.14); --hover: rgba(255, 255, 255, 0.08);
|
|
18
22
|
--accent: #60a5fa; --ok: #4ade80; --bad: #f87171;
|
|
19
23
|
--warn: #fbbf24; --warn-bg: #3a2d10; --warn-line: #6b5216; --warn-dot: #fbbf24;
|
|
20
|
-
--shadow: 0
|
|
24
|
+
--shadow: 0 3px 7px rgba(0, 0, 0, 0.42), 0 1px 2px rgba(0, 0, 0, 0.32);
|
|
21
25
|
}
|
|
22
26
|
}
|
|
23
27
|
html, body { margin: 0; background: transparent; overflow: hidden; }
|
|
@@ -29,7 +33,7 @@ body {
|
|
|
29
33
|
body.mac { padding: 10px; } /* room for the shadow around a transparent window */
|
|
30
34
|
#root { position: relative; box-sizing: border-box; overflow: hidden; display: inline-block; background: var(--bg); border: 0.5px solid var(--line); cursor: default; }
|
|
31
35
|
#root.dragging, #root.dragging * { cursor: default; }
|
|
32
|
-
body.mac #root { box-shadow: var(--shadow);
|
|
36
|
+
body.mac #root { box-shadow: var(--shadow); }
|
|
33
37
|
#root.pill { border-radius: 999px; }
|
|
34
38
|
#root.card { border-radius: 16px; width: 330px; box-sizing: border-box; }
|
|
35
39
|
body:not(.mac) #root { border-radius: 8px; border: none; }
|
|
@@ -98,7 +102,10 @@ svg.i { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-widt
|
|
|
98
102
|
.steps .label { font-size: 12px; color: var(--accent); white-space: nowrap; }
|
|
99
103
|
.line { font-size: 12px; color: var(--dim); margin-top: 8px; }
|
|
100
104
|
.stats { display: flex; padding: 12px 0; border-top: 0.5px solid var(--line); border-bottom: 0.5px solid var(--line); }
|
|
101
|
-
.stats div { flex: 1; }
|
|
105
|
+
.stats div, .stats .stat { flex: 1; }
|
|
106
|
+
.stats .stat { padding: 0; border: none; background: none; font: inherit; color: inherit; text-align: left; cursor: pointer; }
|
|
107
|
+
.stats .stat:hover span, .stats .stat:focus-visible span { color: var(--accent); }
|
|
108
|
+
.stats .stat:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
|
|
102
109
|
.stats b { display: block; font-size: 18px; font-weight: 600; line-height: 1.2; }
|
|
103
110
|
.stats span { font-size: 11px; color: var(--dim); }
|
|
104
111
|
.actions { display: flex; align-items: center; gap: 6px; margin-top: 12px; position: relative; }
|
|
@@ -125,6 +132,18 @@ svg.i { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-widt
|
|
|
125
132
|
background: var(--hover); border: 0.5px solid var(--line); border-radius: 6px; padding: 0 8px; }
|
|
126
133
|
.settings input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
|
|
127
134
|
.settings .err { color: var(--bad); font-size: 11px; text-align: right; margin: -6px 0 6px; }
|
|
135
|
+
/* The check of system notifications under its switch: a test, and what to change when they do not show. */
|
|
136
|
+
#notify-test-button { margin-left: auto; margin-right: 10px; }
|
|
137
|
+
#notify-test-button .btn { padding: 2px 9px; }
|
|
138
|
+
.nnote { font-size: 12px; color: var(--dim); margin: 2px 0 6px; }
|
|
139
|
+
.nnote.ok { color: var(--ok); }
|
|
140
|
+
.nnote.bad { color: var(--bad); }
|
|
141
|
+
.nnote .link-btn { border: none; background: none; padding: 0; font: inherit; color: var(--accent); cursor: pointer; }
|
|
142
|
+
.nbox { border-radius: 8px; padding: 9px 11px; margin: 4px 0 8px; font-size: 12px; line-height: 1.55;
|
|
143
|
+
background: var(--warn-bg); color: var(--warn); border: 0.5px solid var(--warn-line); }
|
|
144
|
+
.nbox b { display: block; font-size: 13px; margin-bottom: 3px; }
|
|
145
|
+
.nbox ol { margin: 4px 0 6px; padding-left: 18px; }
|
|
146
|
+
.nbox .btn { margin-top: 2px; color: var(--warn); border-color: var(--warn-line); }
|
|
128
147
|
.switch { width: 34px; height: 20px; border-radius: 10px; background: var(--track); position: relative; border: none; padding: 0; cursor: pointer; }
|
|
129
148
|
.switch::after { content: ""; position: absolute; left: 2px; top: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left .15s; }
|
|
130
149
|
.switch.on { background: var(--accent); }
|
|
@@ -196,6 +215,9 @@ svg.i { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-widt
|
|
|
196
215
|
.paper-list { list-style: none; margin: 6px 0 0; padding: 0; max-height: 196px; overflow-y: auto; }
|
|
197
216
|
.paper-list.scroll { -webkit-mask-image: linear-gradient(to bottom, #000 80%, transparent); mask-image: linear-gradient(to bottom, #000 80%, transparent); }
|
|
198
217
|
.paper-list li { font-size: 12px; padding: 3px 0; }
|
|
218
|
+
/* 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; }
|
|
220
|
+
.papers-scroll .paper-list { max-height: none; overflow: visible; }
|
|
199
221
|
.paper-list .t, .paper-list .w { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
200
222
|
.paper-list .w, .paper-list .more { color: var(--faint); }
|
|
201
223
|
.paper-list .open-article { display: block; width: 100%; padding: 0; border: none; background: none; text-align: left;
|
|
@@ -219,17 +241,26 @@ const EN = /*CAPSULE_EN*/null;
|
|
|
219
241
|
const EN_PATTERNS = EN ? EN.patterns.map(([source, target]) => [new RegExp(source), target]) : [];
|
|
220
242
|
const HAN = /[\u4e00-\u9fff]/;
|
|
221
243
|
let lang = "zh";
|
|
244
|
+
const BRACKETS = /^(.+?)((.+))$/;
|
|
245
|
+
function trOne(core) {
|
|
246
|
+
if (!HAN.test(core)) return core;
|
|
247
|
+
let english = Object.hasOwn(EN.exact, core) ? EN.exact[core] : null;
|
|
248
|
+
if (english === null) {
|
|
249
|
+
const found = EN_PATTERNS.find(([pattern]) => pattern.test(core));
|
|
250
|
+
if (found) english = core.replace(found[0], found[1]);
|
|
251
|
+
}
|
|
252
|
+
const parts = english === null && BRACKETS.exec(core);
|
|
253
|
+
// "开放下载 18(出版社 API 3、预印本 1)": the text and what its brackets list, each on its own.
|
|
254
|
+
if (parts) english = trOne(parts[1]) + " (" + parts[2].split("、").map(trOne).join(", ") + ")";
|
|
255
|
+
return english === null ? core : english;
|
|
256
|
+
}
|
|
222
257
|
function tr(text) {
|
|
223
258
|
if (lang !== "en" || !EN || !text || !HAN.test(text)) return text;
|
|
224
259
|
return String(text).split(" · ").map((part) => {
|
|
225
260
|
const core = part.trim();
|
|
226
261
|
if (!core || !HAN.test(core)) return part;
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
const found = EN_PATTERNS.find(([pattern]) => pattern.test(core));
|
|
230
|
-
if (found) english = core.replace(found[0], found[1]);
|
|
231
|
-
}
|
|
232
|
-
return english === null ? part : part.replace(core, english);
|
|
262
|
+
const english = trOne(core);
|
|
263
|
+
return english === core ? part : part.replace(core, english);
|
|
233
264
|
}).join(" · ");
|
|
234
265
|
}
|
|
235
266
|
function localize(node) {
|
|
@@ -293,6 +324,7 @@ let open = false; // the card is showing
|
|
|
293
324
|
let panel = ""; // "", "menu", "report", "confirm", "settings": kept until the user leaves it
|
|
294
325
|
let flash = { text: "", until: 0 };
|
|
295
326
|
let settings = null, settingsErrors = {}, notifyOn = true;
|
|
327
|
+
let notifyCheck = null; // the notification check under the switch: {state: testing, sent, off, unseen or failed}
|
|
296
328
|
// Settings pages: "home" lists download, wait and keys. settingsOnly: this window was started
|
|
297
329
|
// just to show them (`paper-search-carsi settings`), so it closes with them unless a download runs.
|
|
298
330
|
const SETTINGS_PAGES = ["home", "download", "wait", "keys"];
|
|
@@ -355,6 +387,8 @@ function paperBlock() {
|
|
|
355
387
|
} else if (v.line) {
|
|
356
388
|
html += '<div class="line">' + esc(v.line) + "</div>";
|
|
357
389
|
}
|
|
390
|
+
// What each lane got (开放下载, 机构下载), on one line.
|
|
391
|
+
if (v.lanes) html += '<div class="line">' + esc(v.lanes) + "</div>";
|
|
358
392
|
return html + "</div>";
|
|
359
393
|
}
|
|
360
394
|
|
|
@@ -382,13 +416,19 @@ function actionsBlock() {
|
|
|
382
416
|
return html;
|
|
383
417
|
}
|
|
384
418
|
|
|
419
|
+
// A count opens its list of papers once the batch has sent them (user, 2026-11-10).
|
|
420
|
+
function stat(list, value, label, color) {
|
|
421
|
+
const inner = "<b" + (color ? ' style="color:' + color + '"' : "") + ">" + value + "</b><span>" + label + "</span>";
|
|
422
|
+
return V.lists && list ? '<button type="button" class="stat" data-act="papers" data-list="' + list + '">' + inner + "</button>"
|
|
423
|
+
: "<div>" + inner + "</div>";
|
|
424
|
+
}
|
|
425
|
+
|
|
385
426
|
function runningCard() {
|
|
386
427
|
const v = V;
|
|
387
428
|
const sub = [v.total ? v.done + "/" + v.total : "", v.part, v.elapsed ? "已用 " + v.elapsed : ""].filter(Boolean).join(" · ");
|
|
388
429
|
return '<div class="card-body">' + header(v.headline, sub, false) + paperBlock()
|
|
389
|
-
+ '<div class="stats"
|
|
390
|
-
+
|
|
391
|
-
+ "<div><b>" + (v.left == null ? "—" : v.left) + "</b><span>剩余</span></div></div>"
|
|
430
|
+
+ '<div class="stats">' + stat("ok", v.ok, "成功", "var(--ok)") + stat("failed", v.bad, "失败", "var(--bad)")
|
|
431
|
+
+ stat("left", v.left == null ? "—" : v.left, "剩余") + "</div>"
|
|
392
432
|
+ actionsBlock() + "</div>";
|
|
393
433
|
}
|
|
394
434
|
|
|
@@ -443,9 +483,8 @@ function reasonRow(g, i, brief) {
|
|
|
443
483
|
function doneCard() {
|
|
444
484
|
const v = V, s = v.summary;
|
|
445
485
|
let html = '<div class="card-body">' + header(v.headline, v.total ? "共 " + v.total + " 篇" : "", true)
|
|
446
|
-
+ '<div class="stats done-stats"
|
|
447
|
-
+
|
|
448
|
-
+ "<div><b>" + esc(v.elapsed || "—") + "</b><span>用时</span></div></div>";
|
|
486
|
+
+ '<div class="stats done-stats">' + stat("ok", v.ok, "成功", "var(--ok)") + stat("failed", v.bad, "失败", v.bad ? "var(--bad)" : "")
|
|
487
|
+
+ stat("", esc(v.elapsed || "—"), "用时") + "</div>";
|
|
449
488
|
if (s && s.groups.length) {
|
|
450
489
|
const apart = s.supplement_groups && s.supplement_groups.length;
|
|
451
490
|
html += '<div class="sec"><div class="sec-h"><b>' + (apart ? "正文未下到 " : "未完成 ") + v.bad + " 篇</b><span>按原因</span></div>"
|
|
@@ -465,6 +504,50 @@ function doneCard() {
|
|
|
465
504
|
+ "</div>";
|
|
466
505
|
}
|
|
467
506
|
|
|
507
|
+
// The list behind a count: its groups (by way, by reason, by lane), each opened on its own.
|
|
508
|
+
const LIST_TITLES = { ok: "成功", failed: "失败", left: "剩余" };
|
|
509
|
+
let papersKind = "", papersList = null, listOpen = null;
|
|
510
|
+
function shownList() { return (papersList || {})[papersKind] || { count: 0, groups: [] }; }
|
|
511
|
+
function listGroupOpen(i) { return listOpen ? listOpen.has(i) : !!(shownList().groups[i] || {}).open; }
|
|
512
|
+
async function loadPapers() {
|
|
513
|
+
try { papersList = await api().paper_lists(); } catch (e) { papersList = papersList || {}; }
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
function listRow(g, i) {
|
|
517
|
+
const opened = listGroupOpen(i);
|
|
518
|
+
let html = '<div class="grp"><button type="button" class="row" data-act="list_group" data-group="' + i + '" aria-expanded="' + opened + '">'
|
|
519
|
+
+ (papersKind === "failed" ? '<span class="tag ' + esc(g.cls) + '">' + esc(CLASS_TAGS[g.cls] || "") + "</span>" : "")
|
|
520
|
+
+ '<span class="reason">' + esc(g.label) + '</span><span class="n">' + g.count + " 篇</span>" + icon(opened ? "down" : "right") + "</button>";
|
|
521
|
+
if (!opened) return html + "</div>";
|
|
522
|
+
return html + '<ul class="paper-list">'
|
|
523
|
+
+ g.papers.map((p) => {
|
|
524
|
+
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.
|
|
526
|
+
if (papersKind === "ok") {
|
|
527
|
+
return '<li><button type="button" class="open-article" data-act="show_paper" data-index="' + p.index + '" title="打开所在文件夹">' + lines + "</button></li>";
|
|
528
|
+
}
|
|
529
|
+
if (papersKind === "failed" && p.doi) {
|
|
530
|
+
return '<li><button type="button" class="open-article" data-act="open_article" data-doi="' + esc(p.doi)
|
|
531
|
+
+ '" title="在浏览器打开这篇文章">' + lines + "</button></li>";
|
|
532
|
+
}
|
|
533
|
+
return "<li>" + lines + "</li>";
|
|
534
|
+
}).join("")
|
|
535
|
+
+ (g.more ? '<li class="more">另有 ' + g.more + " 篇未列出</li>" : "") + "</ul></div>";
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
function papersCard() {
|
|
539
|
+
const list = shownList();
|
|
540
|
+
const note = flash.text && Date.now() < flash.until ? flash.text : "";
|
|
541
|
+
let html = '<div class="card-body"><div class="head"><button class="iconbtn" data-act="back" aria-label="返回">' + icon("left") + "</button>"
|
|
542
|
+
+ '<div class="drag capsule-drag-region"><div class="text"><div class="title">' + LIST_TITLES[papersKind] + " " + list.count + " 篇</div></div></div></div>";
|
|
543
|
+
if (note) html += '<div class="line">' + esc(note) + "</div>";
|
|
544
|
+
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>";
|
|
549
|
+
}
|
|
550
|
+
|
|
468
551
|
function idleCard() {
|
|
469
552
|
return '<div class="card-body">' + header("PaperSearch", "暂无下载任务", true) + "</div>";
|
|
470
553
|
}
|
|
@@ -541,8 +624,10 @@ function settingsDownload() {
|
|
|
541
624
|
|
|
542
625
|
function settingsWait() {
|
|
543
626
|
return settingsHead("等待和提醒") + fieldRows("wait")
|
|
544
|
-
+ '<div class="row"><span>需要处理时发系统通知</span><
|
|
627
|
+
+ '<div class="row"><span>需要处理时发系统通知</span><span id="notify-test-button">' + notifyTestButton() + "</span>"
|
|
628
|
+
+ '<button class="switch' + (notifyOn ? " on" : "")
|
|
545
629
|
+ '" data-act="notify" role="switch" aria-checked="' + notifyOn + '" aria-label="系统通知"></button></div>'
|
|
630
|
+
+ '<div id="notify-test">' + notifyTest() + "</div>"
|
|
546
631
|
+ '<div class="err" id="notify-error" role="status"></div>' + settingsFoot();
|
|
547
632
|
}
|
|
548
633
|
|
|
@@ -588,6 +673,50 @@ function settingsCard() {
|
|
|
588
673
|
return '<div class="card-body settings">' + page() + "</div>";
|
|
589
674
|
}
|
|
590
675
|
|
|
676
|
+
// The check of system notifications under the switch (user, 2026-11-10).
|
|
677
|
+
const NOTIFY_HELP = {
|
|
678
|
+
mac: { corner: "右上角", off: "macOS 没有允许 PaperSearch 发通知", button: "打开系统通知设置",
|
|
679
|
+
where: "在“系统设置 › 通知 › PaperSearch”里打开“允许通知”,提醒样式选“横幅”或“提醒”。",
|
|
680
|
+
checks: ["系统设置 › 通知 › PaperSearch:允许通知,样式选“横幅”", "勿扰或专注模式开着时,通知不会弹出"] },
|
|
681
|
+
win: { corner: "右下角", off: "Windows 关掉了 PaperSearch 的通知", button: "打开通知设置",
|
|
682
|
+
where: "通知以“Windows PowerShell”的名义发出:在“设置 › 系统 › 通知”里打开通知,并允许 Windows PowerShell。",
|
|
683
|
+
checks: ["设置 › 系统 › 通知:打开通知,并允许 Windows PowerShell", "勿扰模式开着时,通知不会弹出"] },
|
|
684
|
+
};
|
|
685
|
+
// The test sits on the switch's row (user, 2026-11-10); what it found goes under the row.
|
|
686
|
+
function notifyTestButton() {
|
|
687
|
+
return notifyOn ? '<button class="btn" data-act="test_notify"' + ((notifyCheck || {}).state === "testing" ? " disabled" : "") + ">测试</button>" : "";
|
|
688
|
+
}
|
|
689
|
+
function notifyTest() {
|
|
690
|
+
if (!notifyOn) return "";
|
|
691
|
+
const help = NOTIFY_HELP[document.body.classList.contains("mac") ? "mac" : "win"], c = notifyCheck || {};
|
|
692
|
+
let html = "";
|
|
693
|
+
if (c.state === "sent") {
|
|
694
|
+
html += '<div class="nnote ok">✓ 已发出,' + help.corner + "应弹出一条通知</div>"
|
|
695
|
+
+ '<div class="nnote">没看到?<button type="button" class="link-btn" data-act="notify_unseen">看看要改哪里</button></div>';
|
|
696
|
+
}
|
|
697
|
+
if (c.state === "failed") html += '<div class="nnote bad">' + esc(c.message || "测试通知没有发出") + "</div>";
|
|
698
|
+
const open = '<button class="btn" data-act="notify_settings">' + help.button + "</button>";
|
|
699
|
+
if (c.state === "off") html += '<div class="nbox"><b>' + help.off + "</b>" + help.where + "<br>" + open + "</div>";
|
|
700
|
+
if (c.state === "unseen") {
|
|
701
|
+
html += '<div class="nbox"><b>没看到通知时,检查这几处</b><ol>'
|
|
702
|
+
+ help.checks.concat(["改好后再点一次“测试”"]).map((line) => "<li>" + line + "</li>").join("") + "</ol>" + open + "</div>";
|
|
703
|
+
}
|
|
704
|
+
return html;
|
|
705
|
+
}
|
|
706
|
+
function updateNotifyTest() {
|
|
707
|
+
// Only this part, keeping what the user is typing in the fields above.
|
|
708
|
+
const box = root.querySelector("#notify-test"), button = root.querySelector("#notify-test-button");
|
|
709
|
+
if (!box || !button) return;
|
|
710
|
+
const previous = root.getBoundingClientRect();
|
|
711
|
+
box.innerHTML = notifyTest();
|
|
712
|
+
button.innerHTML = notifyTestButton();
|
|
713
|
+
localize(box); localize(button);
|
|
714
|
+
root.classList.remove("animating");
|
|
715
|
+
root.style.width = ""; root.style.height = "";
|
|
716
|
+
root.style.removeProperty("--content-max-height");
|
|
717
|
+
fit(previous);
|
|
718
|
+
}
|
|
719
|
+
|
|
591
720
|
function updateStrip() {
|
|
592
721
|
// Progress behind the settings: refresh only this line, keeping what the user is typing.
|
|
593
722
|
const strip = root.querySelector("#task-strip");
|
|
@@ -606,7 +735,7 @@ function updateStrip() {
|
|
|
606
735
|
}
|
|
607
736
|
|
|
608
737
|
async function loadSettings() {
|
|
609
|
-
settings = await api().settings(); notifyOn = settings.notify; settingsErrors = {};
|
|
738
|
+
settings = await api().settings(); notifyOn = settings.notify; settingsErrors = {}; notifyCheck = null;
|
|
610
739
|
try { apiKeys = await api().api_keys(); } catch (error) { apiKeys = null; }
|
|
611
740
|
}
|
|
612
741
|
|
|
@@ -663,6 +792,7 @@ function render(force) {
|
|
|
663
792
|
let html, shape = "card";
|
|
664
793
|
if (panel === "settings") html = settingsCard();
|
|
665
794
|
else if (!open) { html = pill(); shape = "pill"; }
|
|
795
|
+
else if (panel === "papers" && V.lists && (V.mode === "running" || V.mode === "done")) html = papersCard();
|
|
666
796
|
else if (V.mode === "attention") html = attentionCard();
|
|
667
797
|
else if (V.mode === "running") html = runningCard();
|
|
668
798
|
else if (V.mode === "done") html = doneCard();
|
|
@@ -763,6 +893,7 @@ async function tick() {
|
|
|
763
893
|
// A prompt only turns the capsule amber (with a system notification); hovering opens it.
|
|
764
894
|
// Once the prompt is handled an open card folds back unless the pointer is on it.
|
|
765
895
|
if (before === "attention" && V.mode !== "attention" && !hovering && !dragging && !panel) open = false;
|
|
896
|
+
if (panel === "papers" && open) await loadPapers(); // an open list follows the download
|
|
766
897
|
render(switched);
|
|
767
898
|
// Also detect a real pointer departure when clamping moved the window away
|
|
768
899
|
// from a stationary cursor (there may be no further native boundary event).
|
|
@@ -779,6 +910,15 @@ async function act(action, target) {
|
|
|
779
910
|
case "close": closing = true; ++fitGeneration; clearInterval(pollTimer); clearTimeout(hoverTimer); clearTimeout(leaveTimer); return api().request_close(); // no call left waiting on a closed page
|
|
780
911
|
case "folder": return api().open_folder();
|
|
781
912
|
case "open_article": return say(await api().open_article(target.dataset.doi));
|
|
913
|
+
case "papers": papersKind = target.dataset.list; panel = "papers"; listOpen = null; papersList = null; render(true);
|
|
914
|
+
await loadPapers(); return render(true);
|
|
915
|
+
case "list_group": {
|
|
916
|
+
const i = Number(target.dataset.group);
|
|
917
|
+
listOpen = new Set(shownList().groups.map((_, j) => j).filter(listGroupOpen));
|
|
918
|
+
if (!listOpen.delete(i)) listOpen.add(i);
|
|
919
|
+
return render(true);
|
|
920
|
+
}
|
|
921
|
+
case "show_paper": return say(await api().show_paper(Number(target.dataset.index)));
|
|
782
922
|
case "group": return toggleGroup(Number(target.dataset.group));
|
|
783
923
|
case "show_browser": {
|
|
784
924
|
try { await inputActivation; }
|
|
@@ -853,11 +993,23 @@ async function act(action, target) {
|
|
|
853
993
|
target.classList.toggle("on", notifyOn);
|
|
854
994
|
target.setAttribute("aria-checked", String(notifyOn));
|
|
855
995
|
root.querySelector('#notify-error').textContent = "";
|
|
996
|
+
// Turned on: say at once when the system keeps the notifications from showing.
|
|
997
|
+
notifyCheck = null;
|
|
998
|
+
if (notifyOn && (await api().check_notifications()).state === "off") notifyCheck = { state: "off" };
|
|
999
|
+
updateNotifyTest();
|
|
856
1000
|
} catch (error) {
|
|
857
1001
|
root.querySelector('#notify-error').textContent = error.message || "通知设置保存失败";
|
|
858
1002
|
} finally { target.disabled = false; }
|
|
859
1003
|
return;
|
|
860
1004
|
}
|
|
1005
|
+
case "test_notify": {
|
|
1006
|
+
notifyCheck = { state: "testing" };
|
|
1007
|
+
updateNotifyTest();
|
|
1008
|
+
try { notifyCheck = await api().test_notification(); } catch (e) { notifyCheck = { state: "failed" }; }
|
|
1009
|
+
return updateNotifyTest();
|
|
1010
|
+
}
|
|
1011
|
+
case "notify_unseen": notifyCheck = { state: "unseen" }; return updateNotifyTest();
|
|
1012
|
+
case "notify_settings": return api().open_notification_settings();
|
|
861
1013
|
case "choose_folder": {
|
|
862
1014
|
const selected = await api().choose_download_directory();
|
|
863
1015
|
if (selected) { settings.download_dir = selected; root.querySelector('#download-dir').value = selected; }
|
|
@@ -885,7 +1037,7 @@ async function act(action, target) {
|
|
|
885
1037
|
}
|
|
886
1038
|
|
|
887
1039
|
// A paper list scrolls; pressing in it must not drag the window.
|
|
888
|
-
const interactive = (target) => target.closest('button, input, select, textarea, a, [contenteditable="true"], [role="button"], .paper-list');
|
|
1040
|
+
const interactive = (target) => target.closest('button, input, select, textarea, a, [contenteditable="true"], [role="button"], .paper-list, .papers-scroll');
|
|
889
1041
|
root.addEventListener("pointerdown", (event) => {
|
|
890
1042
|
if (event.button === 0 && api().activate_on_input) inputActivation = api().activate_on_input();
|
|
891
1043
|
if (event.button === 0 && event.target.closest(".attention-target")) {
|
|
@@ -187,6 +187,8 @@
|
|
|
187
187
|
"预印本": "Preprint",
|
|
188
188
|
"出版社 API": "Publisher API",
|
|
189
189
|
"开放获取": "Open access",
|
|
190
|
+
"开放下载": "Open download",
|
|
191
|
+
"机构下载": "School download",
|
|
190
192
|
"学校登录页最多等": "Wait for school login",
|
|
191
193
|
"其他页面最多等": "Wait for other pages",
|
|
192
194
|
"验证提醒前最多等": "Wait before check alert",
|
|
@@ -239,7 +241,36 @@
|
|
|
239
241
|
"已中断": "Interrupted",
|
|
240
242
|
"被拒绝:key 不对,或已失效": "Rejected: wrong or expired key",
|
|
241
243
|
"服务器限流,稍后再试;key 本身可能没问题": "Rate-limited; try later",
|
|
242
|
-
"没连上服务器,没法判断;检查网络或代理后再试": "Couldn't reach the server"
|
|
244
|
+
"没连上服务器,没法判断;检查网络或代理后再试": "Couldn't reach the server",
|
|
245
|
+
"正在下载": "Downloading now",
|
|
246
|
+
"排队等机构下载": "Queued for school",
|
|
247
|
+
"开放下载还没查": "Open not checked yet",
|
|
248
|
+
"没有论文": "No papers",
|
|
249
|
+
"正在读取…": "Loading…",
|
|
250
|
+
"打开失败:没有这篇的 PDF": "Couldn't open: no PDF saved",
|
|
251
|
+
"打开失败:PDF 不在这批的下载文件夹里": "Couldn't open: PDF outside the batch folder",
|
|
252
|
+
"打开失败:文件已被移走或删除": "Couldn't open: file moved or deleted",
|
|
253
|
+
"打开所在文件夹": "Show in folder",
|
|
254
|
+
"已打开所在文件夹": "Shown in its folder",
|
|
255
|
+
"没看到?": "Didn't see it?",
|
|
256
|
+
"看看要改哪里": "What to change",
|
|
257
|
+
"测试通知没有发出": "Test not sent",
|
|
258
|
+
"macOS 没有允许 PaperSearch 发通知": "macOS blocks PaperSearch's notifications",
|
|
259
|
+
"Windows 关掉了 PaperSearch 的通知": "Windows turned PaperSearch's notifications off",
|
|
260
|
+
"打开系统通知设置": "Notification settings",
|
|
261
|
+
"打开通知设置": "Notification settings",
|
|
262
|
+
"在“系统设置 › 通知 › PaperSearch”里打开“允许通知”,提醒样式选“横幅”或“提醒”。": "In System Settings › Notifications › PaperSearch, allow notifications, style Banners or Alerts.",
|
|
263
|
+
"通知以“Windows PowerShell”的名义发出:在“设置 › 系统 › 通知”里打开通知,并允许 Windows PowerShell。": "They come as \"Windows PowerShell\": in Settings › System › Notifications, turn them on and allow it.",
|
|
264
|
+
"没看到通知时,检查这几处": "No notification? Check these",
|
|
265
|
+
"系统设置 › 通知 › PaperSearch:允许通知,样式选“横幅”": "System Settings › Notifications › PaperSearch: allow, Banners",
|
|
266
|
+
"勿扰或专注模式开着时,通知不会弹出": "Do Not Disturb or a Focus hides them",
|
|
267
|
+
"设置 › 系统 › 通知:打开通知,并允许 Windows PowerShell": "Settings › System › Notifications: on, allow PowerShell",
|
|
268
|
+
"勿扰模式开着时,通知不会弹出": "Do Not Disturb hides them",
|
|
269
|
+
"测试通知:需要你登录或验证时,会这样提醒你": "Test: this is how you'll be asked to sign in",
|
|
270
|
+
"测试通知没有发出:这台电脑不发系统通知": "Test not sent: no system notifications here",
|
|
271
|
+
"✓ 已发出,右上角应弹出一条通知": "✓ Sent; see the top right",
|
|
272
|
+
"✓ 已发出,右下角应弹出一条通知": "✓ Sent; see the bottom right",
|
|
273
|
+
"改好后再点一次“测试”": "Then press Test again"
|
|
243
274
|
},
|
|
244
275
|
"patterns": [
|
|
245
276
|
[
|
|
@@ -354,6 +385,14 @@
|
|
|
354
385
|
"^开放获取 (\\d+)$",
|
|
355
386
|
"Open access $1"
|
|
356
387
|
],
|
|
388
|
+
[
|
|
389
|
+
"^开放下载 (\\d+)(?: 篇)?$",
|
|
390
|
+
"Open download $1"
|
|
391
|
+
],
|
|
392
|
+
[
|
|
393
|
+
"^机构下载 (\\d+)(?: 篇)?$",
|
|
394
|
+
"School download $1"
|
|
395
|
+
],
|
|
357
396
|
[
|
|
358
397
|
"^附录 (\\d+) 个已保存$",
|
|
359
398
|
"$1 supp. saved"
|
|
@@ -437,6 +476,30 @@
|
|
|
437
476
|
[
|
|
438
477
|
"^找不到 paper-search 命令,没法测试;也可以在终端运行 (.+)$",
|
|
439
478
|
"paper-search not found; run $1 in a terminal"
|
|
479
|
+
],
|
|
480
|
+
[
|
|
481
|
+
"^成功 (\\d+) 篇$",
|
|
482
|
+
"Saved $1"
|
|
483
|
+
],
|
|
484
|
+
[
|
|
485
|
+
"^失败 (\\d+) 篇$",
|
|
486
|
+
"Failed $1"
|
|
487
|
+
],
|
|
488
|
+
[
|
|
489
|
+
"^剩余 (\\d+) 篇$",
|
|
490
|
+
"Left $1"
|
|
491
|
+
],
|
|
492
|
+
[
|
|
493
|
+
"^第 (\\d+) 篇$",
|
|
494
|
+
"Paper $1"
|
|
495
|
+
],
|
|
496
|
+
[
|
|
497
|
+
"^(\\d+) 篇$",
|
|
498
|
+
"$1"
|
|
499
|
+
],
|
|
500
|
+
[
|
|
501
|
+
"^测试通知没有发出:(.+)$",
|
|
502
|
+
"Test not sent: $1"
|
|
440
503
|
]
|
|
441
504
|
]
|
|
442
505
|
}
|
|
@@ -32,6 +32,11 @@ log = logging.getLogger(__name__)
|
|
|
32
32
|
# The longest legitimate call is a page load (60 s, the engine's longest
|
|
33
33
|
# timeout); waits for the user are made of short calls.
|
|
34
34
|
LIMIT_SEC = 90
|
|
35
|
+
# A call already sent when its step's budget ran out may finish within this; the
|
|
36
|
+
# next call then is not sent (BrowserBudgetExhausted) and the browser goes on. A
|
|
37
|
+
# 0 s title read or wait cut at the deadline was taken for a stalled browser and
|
|
38
|
+
# lost the PDF in hand (Science, 2026-11-09).
|
|
39
|
+
OPERATION_GRACE_SEC = 5
|
|
35
40
|
|
|
36
41
|
_inflight: dict[int, tuple[float, str, list[str], Any, Any, Any]] = {}
|
|
37
42
|
_call_deadlines: dict[int, tuple[float, str]] = {}
|
|
@@ -269,7 +274,7 @@ def check(limit_sec: float) -> bool:
|
|
|
269
274
|
deadlines = dict(_call_deadlines)
|
|
270
275
|
overdue = [(key, entry) for key, entry in list(_inflight.items())
|
|
271
276
|
if now - entry[0] > limit_sec
|
|
272
|
-
or (key in deadlines and now >= deadlines[key][0])]
|
|
277
|
+
or (key in deadlines and now >= deadlines[key][0] + OPERATION_GRACE_SEC)]
|
|
273
278
|
if not overdue:
|
|
274
279
|
return False
|
|
275
280
|
key, entry = min(overdue, key=lambda pair: pair[1][0])
|
|
@@ -260,14 +260,17 @@ class Placement:
|
|
|
260
260
|
self.home = after
|
|
261
261
|
self.direction = self._direction(pill_anchor(after, work))
|
|
262
262
|
else:
|
|
263
|
-
# The pill goes to the card's
|
|
264
|
-
#
|
|
265
|
-
#
|
|
263
|
+
# The pill goes to the card's corner on the side nearer the screen
|
|
264
|
+
# edge, so opening it again puts the card back where it was
|
|
265
|
+
# dropped: the bottom corner when docked there or when the card
|
|
266
|
+
# sits so low that it would open up from there (it no longer jumps
|
|
267
|
+
# up to the card's top, 2026-11-10), otherwise the top corner.
|
|
268
|
+
w, h = self.home.width, self.home.height
|
|
269
|
+
from_bottom = direction_for(Rect(after.x, after.bottom - h, w, h), work, after.height)[0]
|
|
266
270
|
self._dragged_card = after
|
|
267
|
-
self.direction = self._direction((
|
|
271
|
+
self.direction = self._direction((from_bottom, pill_anchor(after, work)[1]))
|
|
268
272
|
self._direction_fixed = True
|
|
269
273
|
vertical, horizontal = self.direction
|
|
270
|
-
w, h = self.home.width, self.home.height
|
|
271
274
|
self.home = Rect(after.right - w if horizontal == "left" else after.x,
|
|
272
275
|
after.bottom - h if vertical == "up" else after.y, w, h)
|
|
273
276
|
self.home = self._fit(self.home)
|