dsh-lit-watch 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/LICENSE +201 -0
  3. package/README-zh.md +106 -0
  4. package/README.md +105 -2
  5. package/cordis.patch.yml +18 -0
  6. package/lib/config.d.ts +42 -0
  7. package/lib/config.d.ts.map +1 -0
  8. package/lib/config.js +61 -0
  9. package/lib/config.js.map +1 -0
  10. package/lib/http.d.ts +52 -0
  11. package/lib/http.d.ts.map +1 -0
  12. package/lib/http.js +128 -0
  13. package/lib/http.js.map +1 -0
  14. package/lib/index.d.ts +37 -0
  15. package/lib/index.d.ts.map +1 -0
  16. package/lib/index.js +46 -0
  17. package/lib/index.js.map +1 -0
  18. package/lib/report.d.ts +19 -0
  19. package/lib/report.d.ts.map +1 -0
  20. package/lib/report.js +63 -0
  21. package/lib/report.js.map +1 -0
  22. package/lib/runtime.d.ts +78 -0
  23. package/lib/runtime.d.ts.map +1 -0
  24. package/lib/runtime.js +255 -0
  25. package/lib/runtime.js.map +1 -0
  26. package/lib/tools/lit-add.d.ts +12 -0
  27. package/lib/tools/lit-add.d.ts.map +1 -0
  28. package/lib/tools/lit-add.js +60 -0
  29. package/lib/tools/lit-add.js.map +1 -0
  30. package/lib/tools/lit-report.d.ts +12 -0
  31. package/lib/tools/lit-report.d.ts.map +1 -0
  32. package/lib/tools/lit-report.js +88 -0
  33. package/lib/tools/lit-report.js.map +1 -0
  34. package/lib/tools/lit-run.d.ts +12 -0
  35. package/lib/tools/lit-run.d.ts.map +1 -0
  36. package/lib/tools/lit-run.js +68 -0
  37. package/lib/tools/lit-run.js.map +1 -0
  38. package/lib/tools/shared.d.ts +20 -0
  39. package/lib/tools/shared.d.ts.map +1 -0
  40. package/lib/tools/shared.js +14 -0
  41. package/lib/tools/shared.js.map +1 -0
  42. package/lib/version.d.ts +7 -0
  43. package/lib/version.d.ts.map +1 -0
  44. package/lib/version.js +7 -0
  45. package/lib/version.js.map +1 -0
  46. package/lib/watch.d.ts +72 -0
  47. package/lib/watch.d.ts.map +1 -0
  48. package/lib/watch.js +102 -0
  49. package/lib/watch.js.map +1 -0
  50. package/package.json +78 -4
  51. package/src/config.ts +91 -0
  52. package/src/http.ts +159 -0
  53. package/src/index.ts +56 -0
  54. package/src/report.ts +69 -0
  55. package/src/runtime.ts +254 -0
  56. package/src/tools/lit-add.ts +59 -0
  57. package/src/tools/lit-report.ts +88 -0
  58. package/src/tools/lit-run.ts +65 -0
  59. package/src/tools/shared.ts +14 -0
  60. package/src/version.ts +7 -0
  61. package/src/watch.ts +141 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,55 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented here. The format follows
4
+ [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project
5
+ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [Unreleased]
8
+
9
+ ### Fixed
10
+
11
+ - Non-2xx Crossref responses are now a per-watch `http_error` failure instead of
12
+ being parsed as an empty result and advancing the watch window.
13
+ - A non-JSON or malformed Crossref body raises `invalid_response`, so the run
14
+ fails locally instead of leaking a `SyntaxError` out of `lit_watch_run`.
15
+ - The response cache wrote to a path containing the raw URL (including `/` and
16
+ `:`), so writes failed silently and the cache never hit; keys are now the
17
+ SHA-256 of the exact URL.
18
+ - `assertDate` accepted impossible calendar dates (e.g. `2026-02-31`) because
19
+ `Date` normalizes them; it now requires an exact round trip.
20
+ - `lit_watch_report` rejects malformed `runs` payloads with `INVALID_INPUT`.
21
+ - Removed the unused tool-level `NETWORK_ERROR` code and documented the actual
22
+ per-watch network error codes.
23
+ - A malformed 200 body is no longer written to the response cache (it would
24
+ keep failing the same watch until the TTL expired).
25
+ - A non-array `watches.json` or non-object `seen.json` is reported as
26
+ `STORE_ERROR` instead of being silently replaced by fresh state.
27
+
28
+ ### Added
29
+
30
+ - Offline HTTP-client tests for the allowlist, per-hop redirect re-validation,
31
+ redirect cap, non-2xx rejection, 429 retry, timeout, header injection and
32
+ per-host throttling; cache, corrupt-store and impossible-date regression
33
+ tests; plugin mount contract (30 tests total).
34
+
35
+ ## [0.1.0] - 2026-11-08
36
+
37
+ First release: literature watches over Crossref.
38
+
39
+ ### Added
40
+
41
+ - `lit_watch_add`: named watches over `query.bibliographic` with optional
42
+ Crossref filters, a fixed `since` and a row count.
43
+ - `lit_watch_run`: seen-store diff (only new DOIs), exact-URL recording,
44
+ per-watch failure isolation, and a time window that overlaps the previous run
45
+ by one day and is not advanced by a failed run.
46
+ - `lit_watch_report`: Markdown digest + SARIF 2.1.0.
47
+ - Bounded HTTP client (allowlist, per-hop redirect validation, timeout,
48
+ interval, retry) with an injectable fetch for offline tests.
49
+ - 12 tests.
50
+
51
+ ### Notes
52
+
53
+ - A watch reports new DOIs in a search window; it does not judge relevance.
54
+ - Local JSON state (`watches.json`, `seen.json`, `runs.jsonl`); no REP evidence.
55
+ - No scheduler and no alerts: runs are caller-driven.
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README-zh.md ADDED
@@ -0,0 +1,106 @@
1
+ # dsh-lit-watch
2
+
3
+ **这次检索相比上次新增了什么——而且只报新增。**
4
+
5
+ *保存带时间窗口的 Crossref 文献检索;用已见 DOI 库保证重复运行只返回真正新增的条目;输出 Markdown 摘要 + SARIF。*
6
+
7
+ [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE)
8
+ [![Node](https://img.shields.io/badge/node-%5E22.19%20%7C%7C%20%3E%3D24.9-brightgreen.svg)]()
9
+
10
+ [English](README.md) · 简体中文
11
+
12
+ ---
13
+
14
+ ## 它做什么
15
+
16
+ - **`lit_watch_add`** — 保存一个具名监视项:Crossref `query.bibliographic` 查询串、可选的额外过滤条件(`type:journal-article`)、固定的 `since` 日期和返回行数。
17
+ - **`lit_watch_run`** — 查询 Crossref,只保留本地已见库中没有的 DOI,记录实际使用的 URL,推进时间窗口,并追加写入 `runs.jsonl`。网络失败会按监视项分别报告,且**不会推进**该监视项。
18
+ - **`lit_watch_report`** — Markdown 摘要(每个监视项一张表)+ 针对新增条目的 SARIF 2.1.0 提示。
19
+
20
+ ## 已验证的数据源能力
21
+
22
+ `GET /works?query.bibliographic=…&filter=from-pub-date:…&rows=…&select=…` 已于 2026-11-08 在线验证(HTTP 200,`total-results` 与条目均可解析)。插件严格使用这一请求形式;每次运行都会保存 URL,以便摘要可以复现。
23
+
24
+ ## 它不做什么
25
+
26
+ - **不做相关性判断。** 监视项是 `日期窗口 × 查询`;新增 ≠ 重要,而且受 Crossref 收录范围与更新延迟影响。
27
+ - **不取全文、不取摘要、不取被引次数。** 只返回 `select` 中请求的字段。
28
+ - **不做邮件/webhook 告警。** 运行由调用方驱动(宿主调度器或用户)。
29
+ - **不接 Crossref 以外的来源。** PubMed/arXiv/CNKI 监视不在范围内。
30
+ - **不写 REP 证据。** 状态保存在本地 JSON(`watches.json`、`seen.json`、`runs.jsonl`),不是 REP 记录;这一点明确说明,不做暗示。
31
+
32
+ ## 时间窗口
33
+
34
+ - 监视项首次运行:除非该监视项设置了 `since`,否则不带 `from-pub-date`。
35
+ - 后续运行:`since = 上次成功运行日期 − 1 天`(重叠一天),这样晚收录的文献不会被漏掉;已见库会去掉重叠产生的重复项。
36
+ - 运行失败时 `lastRunAt` 保持不变,因此下次运行会重新覆盖这段时间,而不是直接跳过。
37
+
38
+ ## 工具
39
+
40
+ ### `lit_watch_add`
41
+
42
+ `{ name, query, filter?, since?, rows?, replace? }` → `{ ok, watch }`.
43
+
44
+ ### `lit_watch_run`
45
+
46
+ `{ name?, fresh? }` → `{ ok, runs, totalNew, warnings }`.
47
+
48
+ ### `lit_watch_report`
49
+
50
+ `{ runs? }`(默认:取历史中最近 50 条)→ `{ ok, markdown, sarif }`.
51
+
52
+ ### 错误码
53
+
54
+ 工具失败:`INVALID_INPUT` · `WATCH_UNKNOWN` · `WATCH_EXISTS` · `LIMIT` · `STORE_ERROR`。
55
+
56
+ 每个监视项的运行错误(位于 `runs[].error` 内):`blocked_host` · `invalid_url` · `too_many_redirects` · `timeout` · `http_error` · `invalid_response` · `network_error`。
57
+
58
+ ## 兼容性与安装
59
+
60
+ | | |
61
+ |---|---|
62
+ | DeepSeek Harness | **`dsh-v0.2.1-rc.5`**(2026-11-08 实测);peer `>=0.2.1-0 <0.3.0 \|\| >=0.2.2-0 <0.3.0` |
63
+ | Node | `^22.19.0 \|\| >=24.9.0`(实测 `24.22.1`),仅 ESM |
64
+ | Peer 依赖 | `@perrylink/dsh-research-core ^0.1.0`、`@deepseek-ai/cordis ^4.0.5-alpha.1`、`@deepseek-ai/dsh-tools`、`@deepseek-ai/schemastery ^3.18.5-alpha.1` |
65
+ | 运行时依赖 | **零** |
66
+
67
+ ```sh
68
+ dsh plugin --profile <name> add @perrylink/dsh-research-core dsh-lit-watch
69
+ dsh --profile <name> --dump-config | grep dsh-lit-watch
70
+ ```
71
+
72
+ ## 配置
73
+
74
+ | 键 | 默认值 | 含义 |
75
+ |---|---|---|
76
+ | `enabled` | `true` | `false` 时不挂载任何内容 |
77
+ | `root` | `.lit-watch` | 监视项、已见库、运行历史、缓存 |
78
+ | `userAgent` / `mailto` | `dsh-lit-watch/0.1.0 …` / — | Crossref polite pool |
79
+ | `timeoutMs` / `minIntervalMs` | `15000` / `150` | 请求超时与频率下限 |
80
+ | `retries` / `maxRedirects` | `1` / `3` | 有界重试/重定向 |
81
+ | `cacheTtlMs` | `21600000` | 6 小时响应缓存(`fresh` 可绕过) |
82
+ | `maxResults` / `maxWatches` | `100` / `50` | 行数上限与监视项上限 |
83
+
84
+ ## 安全边界
85
+
86
+ - 仅 HTTPS,精确 host 白名单(`api.crossref.org`),手动跟随重定向并逐跳重新校验。
87
+ - URL 中不含凭据,不使用自定义端口;除查询文本外不发送任何用户数据。
88
+ - 非 2xx 状态和非 JSON 响应体会让该监视项失败,而不是被当成空结果;响应缓存以实际 URL 的 SHA-256 为键。
89
+ - 监视文件是本地 JSON;只在 `root` 下写入。
90
+
91
+ ## 评测
92
+
93
+ **30 个测试**:URL 构造(查询、组合过滤、mailto)、日期/名称校验(含不存在的日历日期)、条目解析(DOI/标题必填,年份/期刊/作者)与畸形响应拒绝、大小写不敏感的差异比较、运行时三次运行的去重(2 → 0 → 1 条新增)及窗口推进、精确 URL 缓存命中、`fresh` 绕过与拒绝缓存畸形响应体、本地网络故障隔离(窗口不推进)、监视项替换/未知/上限、损坏存储拒绝、摘要 + 历史、HTTP 边界(白名单、逐跳重定向复验、重定向上限、非 2xx 拒绝、429 重试、超时、限速)、工具 schema、add→run→report 端到端、失败分支、插件契约、包契约。
94
+
95
+ 不宣称任何基准成绩:其价值在于对固定已见库做差异比较的正确性,测试已经把这一点固定下来;没有人工标注的相关性语料。
96
+
97
+ ## 已知限制(v0.1)
98
+
99
+ - `query.bibliographic` 的排序由 Crossref 决定;监视项可能漏掉排在 `rows` 之外的相关条目。
100
+ - 除原样透传 Crossref `filter` 外,不提供 ORCID/机构过滤。
101
+ - 不按标题去重(无 DOI 的记录按设计跳过)。
102
+ - 已见库会随每个新 DOI 增长;v0.1 没有自动清理机制。
103
+
104
+ ## 许可
105
+
106
+ Apache-2.0。运行时零第三方代码。
package/README.md CHANGED
@@ -1,3 +1,106 @@
1
- # Temporary Holding Version
1
+ # dsh-lit-watch
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ **What is new in this search since last time — and only that.**
4
+
5
+ *Saved Crossref bibliographic queries with time windows, a seen-DOI store so repeated runs return genuinely new items, and a Markdown digest + SARIF.*
6
+
7
+ [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE)
8
+ [![Node](https://img.shields.io/badge/node-%5E22.19%20%7C%7C%20%3E%3D24.9-brightgreen.svg)]()
9
+
10
+ English · [简体中文](README-zh.md)
11
+
12
+ ---
13
+
14
+ ## What it does
15
+
16
+ - **`lit_watch_add`** — save a named watch: a Crossref `query.bibliographic` string, optional extra filters (`type:journal-article`), a fixed `since` date and a row count.
17
+ - **`lit_watch_run`** — query Crossref, keep only DOIs not in the local seen store, record the exact URL, advance the time window, and append to `runs.jsonl`. A network failure is reported per watch and **does not advance** that watch.
18
+ - **`lit_watch_report`** — Markdown digest (one table per watch) + SARIF 2.1.0 notes for new items.
19
+
20
+ ## Verified provider capability
21
+
22
+ `GET /works?query.bibliographic=…&filter=from-pub-date:…&rows=…&select=…` was verified live on 2026-11-08 (HTTP 200, `total-results` and items parsed). The plugin uses exactly this form; the URL is stored with every run so a digest can be reproduced.
23
+
24
+ ## What it does not do
25
+
26
+ - **No relevance judgement.** A watch is a `date window × query`; new ≠ important, and Crossref coverage/lag applies.
27
+ - **No full text, no abstracts, no citation counts.** Only the fields requested in `select`.
28
+ - **No email/webhook alerts.** Runs are caller-driven (host scheduler or user).
29
+ - **No non-Crossref sources.** PubMed/arXiv/CNKI watches are out of scope.
30
+ - **No REP evidence.** State is local JSON (`watches.json`, `seen.json`, `runs.jsonl`), not a REP record; this is stated instead of implied.
31
+
32
+ ## Time windows
33
+
34
+ - First run of a watch: no `from-pub-date` unless the watch has `since`.
35
+ - Later runs: `since = last successful run date − 1 day` (overlap), so a publication indexed late is not missed; the seen store removes the overlap duplicates.
36
+ - A failed run leaves `lastRunAt` untouched, so the next run re-covers the interval instead of skipping it.
37
+
38
+ ## Tools
39
+
40
+ ### `lit_watch_add`
41
+
42
+ `{ name, query, filter?, since?, rows?, replace? }` → `{ ok, watch }`.
43
+
44
+ ### `lit_watch_run`
45
+
46
+ `{ name?, fresh? }` → `{ ok, runs, totalNew, warnings }`.
47
+
48
+ ### `lit_watch_report`
49
+
50
+ `{ runs? }` (default: last 50 from history) → `{ ok, markdown, sarif }`.
51
+
52
+ ### Error codes
53
+
54
+ Tool failures: `INVALID_INPUT` · `WATCH_UNKNOWN` · `WATCH_EXISTS` · `LIMIT` · `STORE_ERROR`.
55
+
56
+ Per-watch run errors (inside `runs[].error`): `blocked_host` · `invalid_url` · `too_many_redirects` · `timeout` · `http_error` · `invalid_response` · `network_error`.
57
+
58
+ ## Compatibility & install
59
+
60
+ | | |
61
+ |---|---|
62
+ | DeepSeek Harness | **`dsh-v0.2.1-rc.5`** (verified 2026-11-08); peer `>=0.2.1-0 <0.3.0 \|\| >=0.2.2-0 <0.3.0` |
63
+ | Node | `^22.19.0 \|\| >=24.9.0` (tested `24.22.1`), ESM only |
64
+ | Peers | `@perrylink/dsh-research-core ^0.1.0`, `@deepseek-ai/cordis ^4.0.5-alpha.1`, `@deepseek-ai/dsh-tools`, `@deepseek-ai/schemastery ^3.18.5-alpha.1` |
65
+ | Runtime dependencies | **zero** |
66
+
67
+ ```sh
68
+ dsh plugin --profile <name> add @perrylink/dsh-research-core dsh-lit-watch
69
+ dsh --profile <name> --dump-config | grep dsh-lit-watch
70
+ ```
71
+
72
+ ## Configuration
73
+
74
+ | Key | Default | Meaning |
75
+ |---|---|---|
76
+ | `enabled` | `true` | `false` mounts nothing |
77
+ | `root` | `.lit-watch` | watches, seen store, run history, cache |
78
+ | `userAgent` / `mailto` | `dsh-lit-watch/0.1.0 …` / — | Crossref polite pool |
79
+ | `timeoutMs` / `minIntervalMs` | `15000` / `150` | request bounds |
80
+ | `retries` / `maxRedirects` | `1` / `3` | bounded retry/redirect |
81
+ | `cacheTtlMs` | `21600000` | 6 h response cache (`fresh` bypasses) |
82
+ | `maxResults` / `maxWatches` | `100` / `50` | row cap and watch cap |
83
+
84
+ ## Security boundaries
85
+
86
+ - HTTPS only, exact-host allowlist (`api.crossref.org`), manual redirects re-validated hop by hop.
87
+ - No credentials in URLs, no custom ports; no user data beyond the query text is sent.
88
+ - Non-2xx statuses and non-JSON bodies fail the watch instead of being treated as an empty result; the response cache is keyed by a SHA-256 of the exact URL.
89
+ - Watch files are local JSON; writes only under `root`.
90
+
91
+ ## Evaluation
92
+
93
+ **30 tests**: URL construction (query, combined filter, mailto), date/name validation including impossible calendar days, item parsing (DOI/title required, year/venue/authors) and malformed-response rejection, case-insensitive diff, runtime dedupe across three runs (2 → 0 → 1 new) with window advancement, exact-URL cache hits, `fresh` bypass and refusing to cache a malformed body, local network-failure isolation with no window advance, watch replace/unknown/limits, corrupt-store refusal, digest + history, HTTP bounds (allowlist, per-hop redirect re-validation, redirect cap, non-2xx rejection, 429 retry, timeout, throttle), tool schemas, add→run→report end to end, failure branches, plugin contract, package contract.
94
+
95
+ No benchmark is claimed: the value is diff correctness against a fixed seen store, which the tests pin down; there is no labelled relevance corpus.
96
+
97
+ ## Known limitations (v0.1)
98
+
99
+ - `query.bibliographic` ranking is Crossref's; a watch can miss relevant items that rank below `rows`.
100
+ - No ORCID/affiliation filters beyond raw Crossref `filter` pass-through.
101
+ - No dedupe by title (DOI-less records are skipped by design).
102
+ - The seen store grows with every new DOI; no automatic pruning in v0.1.
103
+
104
+ ## License
105
+
106
+ Apache-2.0. No third-party runtime code.
@@ -0,0 +1,18 @@
1
+ # dsh-lit-watch bundle patch: mount the literature-watch tools.
2
+ #
3
+ # Every key below is a Config field (Schemastery schema); invalid values fail the
4
+ # profile load loudly. Only Crossref is contacted, over HTTPS.
5
+ - insert:
6
+ - id: dsh-lit-watch
7
+ name: dsh-lit-watch
8
+ config:
9
+ enabled: true
10
+ root: .lit-watch
11
+ userAgent: dsh-lit-watch/0.1.0 (https://github.com/PerryLink/dsh-lit-watch)
12
+ timeoutMs: 15000
13
+ minIntervalMs: 150
14
+ retries: 1
15
+ maxRedirects: 3
16
+ cacheTtlMs: 21600000
17
+ maxResults: 100
18
+ maxWatches: 50
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Config schema and resolution for `dsh-lit-watch`.
3
+ * @module dsh-lit-watch/config
4
+ */
5
+ import z from '@deepseek-ai/schemastery';
6
+ /** Raw plugin config. */
7
+ export interface Config {
8
+ enabled?: boolean;
9
+ root?: string;
10
+ userAgent?: string;
11
+ mailto?: string;
12
+ timeoutMs?: number;
13
+ minIntervalMs?: number;
14
+ retries?: number;
15
+ maxRedirects?: number;
16
+ cacheTtlMs?: number;
17
+ maxResults?: number;
18
+ maxWatches?: number;
19
+ }
20
+ /** Fully resolved config. */
21
+ export interface ResolvedConfig {
22
+ readonly enabled: boolean;
23
+ readonly root: string;
24
+ readonly userAgent: string;
25
+ readonly mailto: string | undefined;
26
+ readonly timeoutMs: number;
27
+ readonly minIntervalMs: number;
28
+ readonly retries: number;
29
+ readonly maxRedirects: number;
30
+ readonly cacheTtlMs: number;
31
+ readonly maxResults: number;
32
+ readonly maxWatches: number;
33
+ }
34
+ /** Schemastery schema. */
35
+ export declare const Config: z<Config>;
36
+ /**
37
+ * Validate raw values and fill explicit defaults.
38
+ * @param config - raw plugin config.
39
+ * @returns the fully resolved config.
40
+ */
41
+ export declare function resolveConfig(config?: Config): ResolvedConfig;
42
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,CAAC,MAAM,0BAA0B,CAAA;AAExC,yBAAyB;AACzB,MAAM,WAAW,MAAM;IACrB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAED,6BAA6B;AAC7B,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;IACnC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;IAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAC5B;AAED,0BAA0B;AAC1B,eAAO,MAAM,MAAM,EAAE,CAAC,CAAC,MAAM,CAY3B,CAAA;AAOF;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,MAAM,GAAE,MAAW,GAAG,cAAc,CA2BjE"}
package/lib/config.js ADDED
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Config schema and resolution for `dsh-lit-watch`.
3
+ * @module dsh-lit-watch/config
4
+ */
5
+ import path from 'node:path';
6
+ import z from '@deepseek-ai/schemastery';
7
+ /** Schemastery schema. */
8
+ export const Config = z.object({
9
+ enabled: z.boolean().default(true),
10
+ root: z.string().default('.lit-watch'),
11
+ userAgent: z.string().default('dsh-lit-watch/0.1.0 (https://github.com/PerryLink/dsh-lit-watch)'),
12
+ mailto: z.string(),
13
+ timeoutMs: z.number().default(15_000),
14
+ minIntervalMs: z.number().default(150),
15
+ retries: z.number().default(1),
16
+ maxRedirects: z.number().default(3),
17
+ cacheTtlMs: z.number().default(6 * 60 * 60 * 1000),
18
+ maxResults: z.number().default(100),
19
+ maxWatches: z.number().default(50),
20
+ });
21
+ /** Throw unless the value is a non-negative safe integer. */
22
+ function assertNonNegativeInt(name, value) {
23
+ if (!Number.isSafeInteger(value) || value < 0)
24
+ throw new TypeError(`${name} must be a non-negative safe integer, got ${String(value)}`);
25
+ }
26
+ /**
27
+ * Validate raw values and fill explicit defaults.
28
+ * @param config - raw plugin config.
29
+ * @returns the fully resolved config.
30
+ */
31
+ export function resolveConfig(config = {}) {
32
+ const root = config.root ?? '.lit-watch';
33
+ if (typeof root !== 'string' || root.trim() === '')
34
+ throw new TypeError('root must be a non-empty path');
35
+ const timeoutMs = config.timeoutMs ?? 15_000;
36
+ const minIntervalMs = config.minIntervalMs ?? 150;
37
+ const retries = config.retries ?? 1;
38
+ const maxRedirects = config.maxRedirects ?? 3;
39
+ const cacheTtlMs = config.cacheTtlMs ?? 6 * 60 * 60 * 1000;
40
+ const maxResults = config.maxResults ?? 100;
41
+ const maxWatches = config.maxWatches ?? 50;
42
+ for (const [name, value] of Object.entries({ timeoutMs, minIntervalMs, retries, maxRedirects, cacheTtlMs, maxResults, maxWatches })) {
43
+ assertNonNegativeInt(name, value);
44
+ }
45
+ if (timeoutMs <= 0 || maxResults <= 0 || maxWatches <= 0)
46
+ throw new TypeError('timeoutMs, maxResults and maxWatches must be positive');
47
+ return {
48
+ enabled: config.enabled ?? true,
49
+ root: path.resolve(root),
50
+ userAgent: config.userAgent ?? 'dsh-lit-watch/0.1.0 (https://github.com/PerryLink/dsh-lit-watch)',
51
+ ...(config.mailto === undefined || config.mailto.trim() === '' ? { mailto: undefined } : { mailto: config.mailto }),
52
+ timeoutMs,
53
+ minIntervalMs,
54
+ retries,
55
+ maxRedirects,
56
+ cacheTtlMs,
57
+ maxResults,
58
+ maxWatches,
59
+ };
60
+ }
61
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,CAAC,MAAM,0BAA0B,CAAA;AAgCxC,0BAA0B;AAC1B,MAAM,CAAC,MAAM,MAAM,GAAc,CAAC,CAA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EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC;QACnH,SAAS;QACT,aAAa;QACb,OAAO;QACP,YAAY;QACZ,UAAU;QACV,UAAU;QACV,UAAU;KACX,CAAA;AACH,CAAC"}
package/lib/http.d.ts ADDED
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Bounded HTTP client for Crossref (HTTPS, exact-host allowlist, manual
3
+ * redirect re-validation, timeout, per-host interval, one retry on 429/503,
4
+ * non-2xx rejection).
5
+ * The fetch implementation is injectable so tests never touch the network.
6
+ * @module dsh-lit-watch/http
7
+ */
8
+ /** The only host this plugin talks to. */
9
+ export declare const ALLOWED_HOSTS: readonly string[];
10
+ /** Stable network failure codes. */
11
+ export type NetworkErrorCode = 'blocked_host' | 'invalid_url' | 'too_many_redirects' | 'timeout' | 'network_error' | 'http_error' | 'invalid_response';
12
+ /** A transport-level failure. */
13
+ export declare class WatchNetworkError extends Error {
14
+ /** Stable code. */
15
+ readonly code: NetworkErrorCode;
16
+ constructor(code: NetworkErrorCode, message: string);
17
+ }
18
+ /** One HTTP response. */
19
+ export interface HttpResponse {
20
+ readonly status: number;
21
+ readonly body: string;
22
+ readonly url: string;
23
+ }
24
+ /** The HTTP surface the runtime depends on. */
25
+ export interface HttpClient {
26
+ get(url: string, options?: {
27
+ readonly accept?: string;
28
+ }): Promise<HttpResponse>;
29
+ }
30
+ /** The minimal fetch shape needed. */
31
+ export type FetchLike = (input: string, init?: RequestInit) => Promise<Response>;
32
+ /** Options for {@link createHttpClient}. */
33
+ export interface HttpClientOptions {
34
+ readonly fetchImpl?: FetchLike;
35
+ readonly timeoutMs: number;
36
+ readonly minIntervalMs: number;
37
+ readonly retries: number;
38
+ readonly maxRedirects: number;
39
+ readonly userAgent: string;
40
+ readonly allowedHosts?: readonly string[];
41
+ readonly now?: () => number;
42
+ readonly sleep?: (ms: number) => Promise<void>;
43
+ }
44
+ /** Validate a URL against the allowlist. */
45
+ export declare function assertAllowed(url: string, allowedHosts?: readonly string[]): URL;
46
+ /**
47
+ * Create the bounded client.
48
+ * @param options - bounds and injection points.
49
+ * @returns the client.
50
+ */
51
+ export declare function createHttpClient(options: HttpClientOptions): HttpClient;
52
+ //# sourceMappingURL=http.d.ts.map