dsh-reading-inbox 0.0.0-stage → 0.1.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Bit0620
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.en.md ADDED
@@ -0,0 +1,202 @@
1
+ # dsh-reading-inbox
2
+
3
+ > **A reading inbox for DeepSeek Harness.** Clip a web page into clean Markdown, keep the original HTML, tag it, search it, and let the agent use it.
4
+
5
+ [![license](https://img.shields.io/badge/license-MIT-green)](LICENSE)
6
+ [![dsh-plugin](https://img.shields.io/badge/topic-dsh--plugin-6f42c1)](https://github.com/topics/dsh-plugin)
7
+ [![node](https://img.shields.io/badge/node-%3E%3D22.12-339933)](package.json)
8
+ [![dsh](https://img.shields.io/badge/dsh-%3E%3D0.2.0%20%3C0.3.0-1f6feb)](package.json)
9
+
10
+ [中文](README.md) | English
11
+
12
+ ![Reading inbox](docs/demo.jpg)
13
+
14
+ ## Why an inbox
15
+
16
+ Pages disappear. Links rot. Bookmarks turn into a pile nobody opens again.
17
+
18
+ DSH already has `web_fetch` and `read_url` for reading a page once. They do not solve three things:
19
+
20
+ 1. **Keep it** — turn the article into Markdown, keep the original HTML as an archive, so a dead link is still readable.
21
+ 2. **Find it later** — full-text search over title, body, tags and source; unread / reading / read / archived states.
22
+ 3. **Let the agent use it** — the model can clip, search, read and update clips instead of only seeing the current page.
23
+
24
+ This plugin is the small implementation of those three things. Everything stays on your machine.
25
+
26
+ ## Features
27
+
28
+ - **One-step clipping** — paste a URL; Readability extracts the article; Markdown + original HTML + title/author/date/source/excerpt are saved.
29
+ - **Inbox UI** — unread / reading / read / archived, search, tag filters, reading view, copy link, export Markdown.
30
+ - **Local full-text search** — CJK is indexed as unigrams + bigrams, Latin as words; title and tags are boosted. No model call.
31
+ - **Agent tools** — `reading_clip`, `reading_search`, `reading_list`, `reading_read`, `reading_update`.
32
+ - **Slash command** — `/inbox <url> [tag1,tag2]` without leaving the conversation.
33
+ - **Chinese-web friendly** — detects GBK / GB2312 / UTF-8 / Big5 so pages do not turn into mojibake.
34
+ - **Safe defaults** — http/https only; every redirect hop is re-validated; DNS answers are checked again at connect time (DNS rebinding defense); loopback, private networks, CGNAT, link-local and cloud metadata addresses are rejected; hard caps of 5 MB, 20 seconds and 5 redirects.
35
+ - **Local-first** — no telemetry, no account, no third-party service.
36
+ - **Exportable** — Markdown with YAML frontmatter, ready for Obsidian / Logseq / any notes folder.
37
+
38
+ ## Install
39
+
40
+ Requires **DSH >= 0.2.0 < 0.3.0** and **Node.js >= 22.12**. DSH 0.2.2 itself requires Node.js >= 24.9, so the DSH runtime is the effective floor.
41
+
42
+ From npm:
43
+
44
+ ```sh
45
+ dsh plugin --profile web add dsh-reading-inbox
46
+ ```
47
+
48
+ From GitHub:
49
+
50
+ ```sh
51
+ dsh plugin --profile web add github:Bit0620/dsh-reading-inbox
52
+ ```
53
+
54
+ Local development:
55
+
56
+ ```sh
57
+ dsh plugin --profile web add file:/absolute/path/to/dsh-reading-inbox
58
+ ```
59
+
60
+ Restart `dsh web`. A **Reading inbox** row appears in the sidebar, and `/inbox` is available in chat.
61
+
62
+ > DSH Desktop manages its own profile. If the row does not appear after a CLI install, install `dsh-reading-inbox` through **Plugins → Add plugin** in the desktop app, or install it into the profile the app uses.
63
+
64
+ ## Usage
65
+
66
+ ### In the inbox
67
+
68
+ 1. Paste a URL into the top bar and press Enter.
69
+ 2. Click an item to read it. Mark read, archive, copy the link, export Markdown, or edit tags on the right.
70
+ 3. The search box searches title, body, tags and source as you type.
71
+ 4. Click any tag to filter by it.
72
+
73
+ ### Ask the agent
74
+
75
+ ```text
76
+ Clip https://example.com/article into my reading inbox, tags: architecture, reading
77
+ ```
78
+
79
+ ```text
80
+ Search my saved articles about SSRF and read the key paragraphs
81
+ ```
82
+
83
+ ```text
84
+ Mark that article as read and add the tag security
85
+ ```
86
+
87
+ The model calls `reading_clip`, `reading_search`, `reading_read` and `reading_update`. The plugin adds a system-prompt section explaining when to use them.
88
+
89
+ ### Slash command
90
+
91
+ ```text
92
+ /inbox https://example.com/article architecture, reading
93
+ ```
94
+
95
+ Command output is shown in the UI only; the full article is not pushed into model context.
96
+
97
+ ## Tools
98
+
99
+ | Tool | What it does |
100
+ | --- | --- |
101
+ | `reading_clip` | Fetch a URL, extract the article, save Markdown + original HTML, update the index. Duplicate URLs return the existing clip; `force: true` re-fetches. |
102
+ | `reading_search` | Full-text search with `status` / `tag` filters and pagination. Metadata only, not the body. |
103
+ | `reading_list` | List by date, filtered by status/tag. |
104
+ | `reading_read` | Read a Markdown slice by id; use `offset` / `nextOffset` for long articles and `hasMore` to know whether it is complete. |
105
+ | `reading_update` | Change status or tags. Status: `unread` / `reading` / `read` / `archived`. |
106
+
107
+ ## Configuration
108
+
109
+ Set these in the shell that starts DSH, or in the profile's `.env`, then restart.
110
+
111
+ | Variable | Default | Meaning |
112
+ | --- | --- | --- |
113
+ | `DSH_READING_INBOX_DIR` | `~/.dsh-reading-inbox` | Data directory |
114
+ | `DSH_READING_INBOX_TIMEOUT_MS` | `20000` | Per-fetch timeout |
115
+ | `DSH_READING_INBOX_MAX_BYTES` | `5242880` | Max page size (5 MB) |
116
+ | `DSH_READING_INBOX_MAX_MARKDOWN_CHARS` | `400000` | Max Markdown chars per article; longer content is truncated and flagged |
117
+ | `DSH_READING_INBOX_MAX_REDIRECTS` | `5` | Max redirects |
118
+ | `DSH_READING_INBOX_ALLOW_PRIVATE` | `0` | Set to `1` to allow localhost/private targets; for local tests only |
119
+ | `DSH_READING_INBOX_USER_AGENT` | `dsh-reading-inbox/0.1 ...` | User-Agent for fetches |
120
+ | `DSH_READING_INBOX_PROXY` | falls back to `HTTPS_PROXY` / `HTTP_PROXY` | HTTP proxy URL, e.g. `http://127.0.0.1:7890`; the proxy resolves the destination |
121
+ | `DSH_READING_INBOX_BLOCK_FAKE_IP` | `0` | Set to `1` to reject Clash/Mihomo TUN fake-IPs in `198.18.0.0/15`; stricter, but fake-IP networks can no longer clip |
122
+ | `DSH_READING_INBOX_DEFAULT_TAGS` | empty | Default tags, comma-separated; used only when the user supplies none |
123
+
124
+ ## Data layout
125
+
126
+ ```text
127
+ ~/.dsh-reading-inbox/
128
+ ├── index.json # metadata + the source for full-text search
129
+ └── clips/
130
+ └── <id>/
131
+ ├── article.md # clean Markdown body
132
+ ├── original.html # original HTML snapshot (archive only, never rendered)
133
+ └── meta.json # title, URL, author, date, tags, status
134
+ ```
135
+
136
+ Back up the whole directory, or sync `clips/` and `index.json`.
137
+
138
+ ## Security and boundaries
139
+
140
+ - **Loopback only** — every route accepts `127.0.0.1` / `::1` only, and checks Host, Origin and `Sec-Fetch-Site`; cross-site requests get 403.
141
+ - **SSRF fence** — each redirect hop is re-resolved and re-validated; the DNS answer is checked again when the socket connects, closing the DNS rebinding window; loopback, private networks, CGNAT, link-local, multicast and cloud metadata addresses are rejected.
142
+ - **Clash/Mihomo TUN exception** — fake-IPs in `198.18.0.0/15` are allowed by default, because blocking them would break clipping for many Chinese networks. In fake-IP mode the local pre-check only sees the fake address and cannot learn the real destination, so SSRF protection then depends on the proxy's routing rules. Set `DSH_READING_INBOX_BLOCK_FAKE_IP=1` to reject the range. With an HTTP proxy the destination is resolved by the proxy; use a trusted proxy.
143
+ - **Bounded fetches** — hard limits of 5 MB, 20 seconds and 5 redirects.
144
+ - **Raw HTML is never rendered** — `original.html` is an archive; the UI renders Turndown Markdown through a `sanitize-html` allowlist.
145
+ - **No credentials** — the plugin does not read, store or print account passwords, and does not reuse page login sessions.
146
+ - **No telemetry** — the only network requests are the URLs you explicitly clip.
147
+ - **Copyright** — keep a personal reading copy only; do not use this to redistribute copyrighted content.
148
+
149
+ ## Verify (source checkout)
150
+
151
+ These commands run from a source checkout; the npm package ships runtime files only, without tests or development scripts.
152
+
153
+ ```sh
154
+ npm install
155
+ npm test
156
+ npm run verify
157
+ ```
158
+
159
+ `npm run verify` starts a local test page and walks the whole path: fetch → extract → index → search → read → export. It prints machine-readable JSON.
160
+
161
+ Local UI:
162
+
163
+ ```sh
164
+ npm run seed # write four demo articles into .dev-inbox
165
+ npm run dev # http://127.0.0.1:4173/dsh-reading-inbox/
166
+ ```
167
+
168
+ See [VERIFY.md](VERIFY.md) for the end-to-end check inside a real DSH.
169
+
170
+ ## Development
171
+
172
+ ```sh
173
+ npm run build:client # rebuild client/client.js with esbuild
174
+ npm test # 15 tests: extraction, rendering, SSRF, DNS checks, store races, search, routes, client bundle
175
+ npm run verify # end-to-end self-check
176
+ ```
177
+
178
+ Layout:
179
+
180
+ - `index.js` — DSH plugin entry: tools, routes, command, system prompt.
181
+ - `src/store.js` — clipping, Markdown files, index, search, status.
182
+ - `src/markdown.js` — Readability + Turndown + sanitize-html.
183
+ - `src/fetch.js` — redirect loop, SSRF checks, charset detection, byte caps.
184
+ - `src/routes.js` — loopback-only HTTP routes and JSON API.
185
+ - `src/tools.js` — `reading_*` tools.
186
+ - `web/` — the inbox UI (plain HTML/CSS/JS, no build).
187
+ - `src/client.js` — DSH sidebar entry that frames `web/`.
188
+
189
+ ## Limits and roadmap
190
+
191
+ 0.1.0 is deliberately small:
192
+
193
+ - [ ] SPA / login / anti-bot pages may yield no article; add a Playwright fallback.
194
+ - [ ] Images still point at remote URLs; download them into `clips/<id>/assets/` for a full offline archive.
195
+ - [ ] No PDF support; use `dsh-pdf-mineru` or a document reader for PDFs.
196
+ - [ ] No browser extension or RSS import yet.
197
+ - [ ] No sync/backup yet; the directory is portable.
198
+ - [ ] Search is local BM25-style ranking; add chunking and highlighting next.
199
+
200
+ ## License
201
+
202
+ MIT © 2026 Bit0620. See [LICENSE](LICENSE).
package/README.md CHANGED
@@ -1,3 +1,202 @@
1
- # Temporary Holding Version
1
+ # dsh-reading-inbox
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
+ > **把网页剪进 DeepSeek Harness 的阅读收件箱。** 干净正文、原文快照、标签、全文检索,以及给 Agent 的 `reading_*` 工具。
4
+
5
+ [![license](https://img.shields.io/badge/license-MIT-green)](LICENSE)
6
+ [![dsh-plugin](https://img.shields.io/badge/topic-dsh--plugin-6f42c1)](https://github.com/topics/dsh-plugin)
7
+ [![node](https://img.shields.io/badge/node-%3E%3D22.12-339933)](package.json)
8
+ [![dsh](https://img.shields.io/badge/dsh-%3E%3D0.2.0%20%3C0.3.0-1f6feb)](package.json)
9
+
10
+ 中文 | [English](README.en.md)
11
+
12
+ ![阅读收件箱](docs/demo.jpg)
13
+
14
+ ## 为什么是收件箱
15
+
16
+ 网页会消失,链接会失效,收藏夹会变成一个再也不打开的垃圾场。
17
+
18
+ DSH 已经有 `web_fetch`、`read_url` 这类“读一次”的工具,但它们不解决三件事:
19
+
20
+ 1. **存下来**:正文变成 Markdown,原文 HTML 也留一份,链接失效还能读。
21
+ 2. **找得到**:标题、正文、标签、来源全文检索;按未读/在读/已读/归档管理。
22
+ 3. **Agent 能用**:模型可以剪藏、搜索、读取、改状态,而不是只能看当前这一页。
23
+
24
+ `dsh-reading-inbox` 就是这三件事的最小实现。数据全部在本机,不经过任何第三方服务。
25
+
26
+ ## 功能
27
+
28
+ - **一键剪藏**:粘贴 URL → Readability 提取正文 → Markdown + 原文 HTML + 标题/作者/日期/来源/摘要。
29
+ - **收件箱界面**:未读 / 在读 / 已读 / 归档,搜索、标签筛选、详情阅读、复制链接、导出 Markdown。
30
+ - **全文检索**:中文按单字 + 二元组切分,英文按词切分;标题和标签权重更高。纯本地,不调用模型。
31
+ - **Agent 工具**:`reading_clip`、`reading_search`、`reading_list`、`reading_read`、`reading_update`。
32
+ - **斜杠命令**:`/inbox <url> [tag1,tag2]`,不离开对话就能收藏。
33
+ - **中文网页友好**:自动识别 GBK / GB2312 / UTF-8 / Big5 编码,避免乱码。
34
+ - **安全默认**:只允许 http/https;逐跳校验重定向;DNS 解析结果在连接时再校验一次(防 DNS rebinding);拒绝本机/内网/云元数据地址;5 MB、20 秒、5 次重定向的硬上限。
35
+ - **本地优先**:没有遥测,没有账号,不把正文发到任何服务器。
36
+ - **可导出**:带 YAML frontmatter 的 Markdown,直接放进 Obsidian / Logseq / 任何笔记库。
37
+
38
+ ## 安装
39
+
40
+ 要求 **DSH >= 0.2.0 < 0.3.0**、**Node.js >= 22.12**。DSH 0.2.2 自身要求 Node.js >= 24.9,实际以 DSH 的运行时为准。
41
+
42
+ 从 npm 安装:
43
+
44
+ ```sh
45
+ dsh plugin --profile web add dsh-reading-inbox
46
+ ```
47
+
48
+ 直接从 GitHub 安装:
49
+
50
+ ```sh
51
+ dsh plugin --profile web add github:Bit0620/dsh-reading-inbox
52
+ ```
53
+
54
+ 本地开发:
55
+
56
+ ```sh
57
+ dsh plugin --profile web add file:C:/path/to/dsh-reading-inbox
58
+ ```
59
+
60
+ 安装后重启 `dsh web`。侧栏会出现 **阅读收件箱**;也可以在对话里用 `/inbox`。
61
+
62
+ > DSH Desktop 的 profile 由桌面应用管理;如果命令行安装后侧栏没有出现,请用桌面应用的 **Plugins → Add plugin** 安装 `dsh-reading-inbox`,或在应用使用的 profile 里安装。
63
+
64
+ ## 用法
65
+
66
+ ### 在收件箱里
67
+
68
+ 1. 把网页链接粘贴到顶部的输入框,回车。
69
+ 2. 左侧点击文章开始阅读;右侧可以标记已读、归档、复制链接、导出 Markdown、编辑标签。
70
+ 3. 搜索框支持标题、正文、标签、来源;输入即搜。
71
+ 4. 点标签可以按标签筛选。
72
+
73
+ ### 让 Agent 帮你
74
+
75
+ ```text
76
+ 把 https://example.com/article 收藏到阅读收件箱,标签:架构, 阅读
77
+ ```
78
+
79
+ ```text
80
+ 搜索我收藏的关于 SSRF 的文章,读出关键段落
81
+ ```
82
+
83
+ ```text
84
+ 把刚才那篇标记为已读,再加一个标签:security
85
+ ```
86
+
87
+ 模型会调用 `reading_clip`、`reading_search`、`reading_read`、`reading_update`。系统提示里已经写了这些工具的使用时机。
88
+
89
+ ### 斜杠命令
90
+
91
+ ```text
92
+ /inbox https://example.com/article 架构, 阅读
93
+ ```
94
+
95
+ 命令只把结果文本显示在界面里,不会把整篇文章塞进模型上下文。
96
+
97
+ ## 工具
98
+
99
+ | 工具 | 作用 |
100
+ | --- | --- |
101
+ | `reading_clip` | 抓取 URL,提取正文,保存 Markdown + 原文 HTML,写入索引。重复 URL 默认返回已有条目;`force: true` 重新抓取。 |
102
+ | `reading_search` | 全文搜索,支持 `status` / `tag` 过滤和分页。只返回元数据,不返回全文。 |
103
+ | `reading_list` | 按时间列出,支持状态/标签过滤。 |
104
+ | `reading_read` | 按 id 读取 Markdown 切片;用 `offset` / `nextOffset` 翻长文,`hasMore` 判断是否读完。 |
105
+ | `reading_update` | 修改阅读状态或标签。状态:`unread` / `reading` / `read` / `archived`。 |
106
+
107
+ ## 配置
108
+
109
+ 在启动 DSH 的 shell 或 profile 的 `.env` 里设置,然后重启。
110
+
111
+ | 变量 | 默认值 | 含义 |
112
+ | --- | --- | --- |
113
+ | `DSH_READING_INBOX_DIR` | `~/.dsh-reading-inbox` | 数据目录 |
114
+ | `DSH_READING_INBOX_TIMEOUT_MS` | `20000` | 单次抓取超时 |
115
+ | `DSH_READING_INBOX_MAX_BYTES` | `5242880` | 单页最大字节数(5 MB) |
116
+ | `DSH_READING_INBOX_MAX_MARKDOWN_CHARS` | `400000` | 单篇 Markdown 最大字符数,超出截断并标记 |
117
+ | `DSH_READING_INBOX_MAX_REDIRECTS` | `5` | 最大重定向次数 |
118
+ | `DSH_READING_INBOX_ALLOW_PRIVATE` | `0` | 设为 `1` 才允许抓取本机/内网;只用于本地测试 |
119
+ | `DSH_READING_INBOX_USER_AGENT` | `dsh-reading-inbox/0.1 ...` | 抓取时的 User-Agent |
120
+ | `DSH_READING_INBOX_PROXY` | 读 `HTTPS_PROXY` / `HTTP_PROXY` | HTTP 代理地址,例如 `http://127.0.0.1:7890`;走代理时目标由代理解析 |
121
+ | `DSH_READING_INBOX_BLOCK_FAKE_IP` | `0` | 设为 `1` 时拒绝 Clash/Mihomo TUN 的 `198.18.0.0/15` fake-IP;更严格,但会让 fake-IP 环境无法剪藏 |
122
+ | `DSH_READING_INBOX_DEFAULT_TAGS` | 空 | 默认标签,逗号分隔;用户没给标签时生效 |
123
+
124
+ ## 数据目录
125
+
126
+ ```text
127
+ ~/.dsh-reading-inbox/
128
+ ├── index.json # 元数据 + 全文检索的源数据
129
+ └── clips/
130
+ └── <id>/
131
+ ├── article.md # 干净正文(Markdown)
132
+ ├── original.html # 原始 HTML 快照(只存档,不渲染)
133
+ └── meta.json # 标题、URL、作者、日期、标签、状态
134
+ ```
135
+
136
+ `index.json` 是唯一索引;可以直接备份整个目录,或只同步 `clips/` 和 `index.json`。
137
+
138
+ ## 安全与边界
139
+
140
+ - **只监听回环**:所有路由只接受 `127.0.0.1` / `::1`,并校验 Host、Origin 和 `Sec-Fetch-Site`,跨站请求返回 403。
141
+ - **SSRF 防护**:每一跳重定向都重新解析并校验目标;连接时的 DNS 结果会再校验一次,防止校验与连接之间被 DNS rebinding 换地址;拒绝 loopback、私有网段、CGNAT、link-local、组播、云元数据地址。
142
+ - **Clash/Mihomo TUN 例外**:`198.18.0.0/15` fake-IP 默认放行,否则大量中文网络环境下无法剪藏。fake-IP 模式下,本地预检只能看到假地址,无法得知真实目的地,此时 SSRF 防护依赖代理的路由规则;需要严格拦截时设置 `DSH_READING_INBOX_BLOCK_FAKE_IP=1`。使用 HTTP 代理时同理,目标由代理解析,请使用可信代理。
143
+ - **有界抓取**:5 MB、20 秒、5 次重定向的硬上限;超限直接失败,不会无限下载。
144
+ - **不渲染原始 HTML**:`original.html` 只作为存档;界面渲染的是 Turndown 生成的 Markdown,再经过 `sanitize-html` 白名单。
145
+ - **不碰凭据**:插件不读取、不保存、不打印任何账号密码;页面里的登录态不会被复用。
146
+ - **无遥测**:没有统计、没有上报、没有第三方请求(除了你主动剪藏的 URL 本身)。
147
+ - **版权**:只保存你个人阅读所需的副本;不要用插件批量转发或再分发受版权保护的内容。
148
+
149
+ ## 验证(源码仓库)
150
+
151
+ 以下命令需要在源码仓库里运行;npm 包只包含运行时文件,不含测试和开发脚本。
152
+
153
+ ```sh
154
+ npm install
155
+ npm test
156
+ npm run verify
157
+ ```
158
+
159
+ `npm run verify` 会启动一个本地测试页,走完“抓取 → 提取 → 索引 → 搜索 → 读取 → 导出”整条链路,并输出机器可读的 JSON。
160
+
161
+ 本地看界面:
162
+
163
+ ```sh
164
+ npm run seed # 写入 4 篇演示文章到 .dev-inbox
165
+ npm run dev # http://127.0.0.1:4173/dsh-reading-inbox/
166
+ ```
167
+
168
+ 在真实 DSH 里验证的步骤见 [VERIFY.md](VERIFY.md)。
169
+
170
+ ## 开发
171
+
172
+ ```sh
173
+ npm run build:client # 重新构建 client/client.js(esbuild)
174
+ npm test # 15 个测试:提取、渲染、SSRF、DNS 校验、存储竞态、检索、路由、客户端 bundle
175
+ npm run verify # 端到端自检
176
+ ```
177
+
178
+ 代码结构:
179
+
180
+ - `index.js`:DSH 插件入口,注册工具、路由、命令、系统提示。
181
+ - `src/store.js`:剪藏、Markdown 落盘、索引、检索、状态管理。
182
+ - `src/markdown.js`:Readability + Turndown + sanitize-html。
183
+ - `src/fetch.js`:逐跳重定向、SSRF 校验、编码识别、字节上限。
184
+ - `src/routes.js`:回环限定的 HTTP 路由与 JSON API。
185
+ - `src/tools.js`:`reading_*` 工具。
186
+ - `web/`:收件箱界面(原生 HTML/CSS/JS,无构建)。
187
+ - `src/client.js`:DSH 侧栏入口,用 iframe 装载 `web/`。
188
+
189
+ ## 限制与 Roadmap
190
+
191
+ 当前版本是 0.1.0,刻意不做大而全:
192
+
193
+ - [ ] SPA / 登录页 / 反爬页可能提取不到正文;下一步加 Playwright fallback。
194
+ - [ ] 图片仍引用远程地址;下一步下载到 `clips/<id>/assets/` 做完整离线存档。
195
+ - [ ] 暂不支持 PDF;PDF 请用 `dsh-pdf-mineru` 或文档阅读插件。
196
+ - [ ] 暂无浏览器扩展 / RSS 导入;先做 URL 输入和 Agent 工具。
197
+ - [ ] 暂无同步/备份;先保证本地目录可复制。
198
+ - [ ] 检索是本地 BM25 风格排序;下一步加标题/正文分块与高亮。
199
+
200
+ ## 许可
201
+
202
+ MIT © 2026 Bit0620。见 [LICENSE](LICENSE)。
package/VERIFY.md ADDED
@@ -0,0 +1,109 @@
1
+ # 在真实 DSH 里验证 dsh-reading-inbox
2
+
3
+ 这份清单给有 DSH 环境的机器用。目标:确认插件能装、能出现在侧栏、能剪藏、能被 Agent 调用。
4
+
5
+ ## 0. 准备
6
+
7
+ - DSH **0.2.0 – 0.2.x**,Node.js >= 22.12(DSH 0.2.2 自身要求 >= 24.9)。
8
+ - 一个可写的 profile,例如 `web`。建议先用测试 profile,避免影响主环境:
9
+
10
+ ```sh
11
+ dsh plugin --profile inbox-test add file:C:/path/to/dsh-reading-inbox
12
+ ```
13
+
14
+ > 注意:`inbox-test` 是全新 profile 时只有 base,没有 `webServer`,插件会 pending。测试侧栏请用 web 模板创建 profile,或直接装进 `web`。
15
+
16
+ 从 web 模板创建测试 profile:
17
+
18
+ ```sh
19
+ dsh --profile inbox-web --from-default-profile web --dump-config
20
+ dsh plugin --profile inbox-web add file:C:/path/to/dsh-reading-inbox
21
+ ```
22
+
23
+ ## 1. 启动
24
+
25
+ ```sh
26
+ dsh --profile inbox-web --no-open --port 4191
27
+ ```
28
+
29
+ 打开终端打印的 `http://127.0.0.1:4191/?token=...`。
30
+
31
+ ## 2. 侧栏
32
+
33
+ - 左侧栏应出现 **阅读收件箱**。
34
+ - 点开后应看到顶部“粘贴网页链接”输入框、左侧列表、右侧空状态。
35
+ - 如果侧栏没有出现:
36
+ - 看启动日志里 `dsh-reading-inbox` 是否 `pending` / `failed`;
37
+ - 确认 profile 有 `webServer`(web 模板);
38
+ - 确认 `client/client.js` 存在(`npm run build:client`)。
39
+
40
+ ## 3. 手动剪藏
41
+
42
+ 1. 粘贴一个公开文章 URL,例如 `https://example.com/`。
43
+ 2. 点“保存”。
44
+ 3. 期望:右侧出现文章标题和正文;左侧列表出现条目;`~/.dsh-reading-inbox/clips/<id>/` 下有 `article.md`、`original.html`、`meta.json`。
45
+ 4. 点“导出 Markdown”,应下载带 YAML frontmatter 的 `.md`。
46
+
47
+ 如果 `example.com` 正文太短,换一篇真实文章。错误应显示在底部 toast,而不是空白。
48
+
49
+ ## 4. Agent 工具
50
+
51
+ 在对话里说:
52
+
53
+ ```text
54
+ 把 https://example.com/article 收藏到阅读收件箱,标签:测试
55
+ ```
56
+
57
+ 期望:模型调用 `reading_clip`,返回 `id`、标题、字数、标签。
58
+
59
+ 再问:
60
+
61
+ ```text
62
+ 搜索我收藏的“测试”,读出来
63
+ ```
64
+
65
+ 期望:模型调用 `reading_search`,再调用 `reading_read`,回答里引用收藏内容。
66
+
67
+ 再问:
68
+
69
+ ```text
70
+ 把刚才那篇标记为已读
71
+ ```
72
+
73
+ 期望:`reading_update` 成功,收件箱里状态变为“已读”。
74
+
75
+ ## 5. 斜杠命令
76
+
77
+ ```text
78
+ /inbox https://example.com/article 测试
79
+ ```
80
+
81
+ 期望:界面显示“已保存《…》到阅读收件箱”,不把全文塞进模型上下文。
82
+
83
+ ## 6. 安全检查
84
+
85
+ - 在浏览器地址栏直接访问 `http://127.0.0.1:4191/dsh-reading-inbox/api/health`,应返回 JSON。
86
+ - 从另一个源(例如 `http://localhost:3000` 的页面)fetch 这个地址,应被 403 / CORS 拦截。
87
+ - 让 Agent 剪藏 `http://127.0.0.1:4191/`、`http://169.254.169.254/` 或 `http://[::ffff:127.0.0.1]/`,应被 SSRF 检查拒绝(除非显式设置 `DSH_READING_INBOX_ALLOW_PRIVATE=1`)。
88
+ - 如果机器使用 Clash/Mihomo TUN fake-IP,再设置 `DSH_READING_INBOX_BLOCK_FAKE_IP=1` 重启,剪藏公网页面应报解析到 `198.18.x.x` 并拒绝;确认严格模式生效后再按需关闭。
89
+ - 剪藏一个超过 `DSH_READING_INBOX_MAX_BYTES` 的页面,应报“页面超过大小上限”。
90
+
91
+ ## 7. 清理
92
+
93
+ 测试 profile 可以保留,也可以删除:
94
+
95
+ ```sh
96
+ rm -rf ~/.dsh/profiles/inbox-web
97
+ ```
98
+
99
+ 数据在 `~/.dsh-reading-inbox/`;确认不需要后再删除。
100
+
101
+ ## 结果记录
102
+
103
+ 在 issue / PR 里请附:
104
+
105
+ - DSH 版本(`dsh --version`)
106
+ - 操作系统
107
+ - 侧栏是否出现
108
+ - 手动剪藏、Agent 工具、斜杠命令各自的结果
109
+ - 失败时的启动日志片段(不要贴 token)
@@ -0,0 +1,86 @@
1
+ /* dsh-reading-inbox client — built by scripts/build-client.mjs */
2
+ window.__ModuleLoader__.load({
3
+ id: 'dsh-reading-inbox',
4
+ factory: (e) => {
5
+ const module = { exports: {} }
6
+ const exports = module.exports
7
+ const require = e
8
+ var __defProp = Object.defineProperty;
9
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
10
+ var __getOwnPropNames = Object.getOwnPropertyNames;
11
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
12
+ var __export = (target, all) => {
13
+ for (var name2 in all)
14
+ __defProp(target, name2, { get: all[name2], enumerable: true });
15
+ };
16
+ var __copyProps = (to, from, except, desc) => {
17
+ if (from && typeof from === "object" || typeof from === "function") {
18
+ for (let key of __getOwnPropNames(from))
19
+ if (!__hasOwnProp.call(to, key) && key !== except)
20
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
21
+ }
22
+ return to;
23
+ };
24
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
+
26
+ // src/client.js
27
+ var client_exports = {};
28
+ __export(client_exports, {
29
+ apply: () => apply,
30
+ inject: () => inject,
31
+ name: () => name
32
+ });
33
+ module.exports = __toCommonJS(client_exports);
34
+ var import_react = require("react");
35
+ var name = "dsh-reading-inbox-client";
36
+ var inject = ["slots"];
37
+ var ID = "dsh-reading-inbox";
38
+ var LABEL = "\u9605\u8BFB\u6536\u4EF6\u7BB1";
39
+ function InboxIcon(owner = {}) {
40
+ const size = owner.size ?? 16;
41
+ return (0, import_react.createElement)(
42
+ "svg",
43
+ {
44
+ width: size,
45
+ height: size,
46
+ viewBox: "0 0 24 24",
47
+ fill: "none",
48
+ stroke: "currentColor",
49
+ strokeWidth: 2,
50
+ strokeLinecap: "round",
51
+ strokeLinejoin: "round",
52
+ "aria-hidden": "true"
53
+ },
54
+ (0, import_react.createElement)("path", { d: "M4 4h16v16H4z" }),
55
+ (0, import_react.createElement)("path", { d: "M4 13h4l2 3h4l2-3h4" })
56
+ );
57
+ }
58
+ function apply(ctx) {
59
+ const slots = ctx.slots;
60
+ slots.inject("sidebar.panellist", () => slots.register({
61
+ name: "sidebar.panellist",
62
+ id: ID,
63
+ order: 2,
64
+ label: () => LABEL
65
+ }, InboxIcon));
66
+ slots.inject("main", () => slots.register({
67
+ name: "main",
68
+ id: ID,
69
+ key: ID,
70
+ order: 2
71
+ }, () => (0, import_react.createElement)("iframe", {
72
+ src: "/dsh-reading-inbox/",
73
+ title: LABEL,
74
+ style: {
75
+ display: "block",
76
+ width: "100%",
77
+ height: "100%",
78
+ border: "0",
79
+ background: "transparent"
80
+ }
81
+ })));
82
+ }
83
+
84
+ return module.exports
85
+ },
86
+ });
@@ -0,0 +1,6 @@
1
+ # dsh-reading-inbox is a self-contained bundle: it stores clipped articles
2
+ # under ~/.dsh-reading-inbox, serves its own web UI on the host's webserver,
3
+ # and registers reading_* tools. No MCP row and no credentials are involved.
4
+ - insert:
5
+ - id: dsh-reading-inbox
6
+ name: dsh-reading-inbox
package/docs/demo.jpg ADDED
Binary file