dsh-book-reader 0.1.0 → 0.2.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.
- package/CHANGELOG.md +41 -1
- package/README.md +35 -475
- package/README.zh-CN.md +55 -0
- package/SKILL.md +1 -2
- package/cordis.patch.yml +9 -8
- package/lib/client.js +513 -22
- package/lib/index.js +415 -104
- package/package.json +15 -6
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# dsh-book-reader
|
|
2
|
+
|
|
3
|
+
给 DSH 官方 PDF 预览加一条读书工具栏,并给模型三个 PDF 工具。
|
|
4
|
+
|
|
5
|
+
[English](README.md)
|
|
6
|
+
|
|
7
|
+
## 功能
|
|
8
|
+
|
|
9
|
+
**阅读工具栏** —— 只在右侧栏的 `.pdf` 预览上出现,不替换官方预览器。
|
|
10
|
+
|
|
11
|
+
- 上一页/下一页、跟随滚动的页码读数、跳页框(印刷页码,或 `p152` 表示 PDF 第 152 页)。
|
|
12
|
+
- 全文搜索(`Cmd/Ctrl+Shift+F`):点结果跳页,或把该页引用插入对话框。
|
|
13
|
+
- AI 位置提示:每轮对话开始前,模型可能收到一行“你正在看第 N 页”的短提示(`AI●` 开关,默认开)。
|
|
14
|
+
- **记住阅读位置**:再次打开同一本书时恢复上次的页码和缩放;状态按书保存在 DSH 侧,重启后仍有效。
|
|
15
|
+
- 每个控件都有悬停/聚焦说明,跟随 DSH 界面语言(中文或英文)。
|
|
16
|
+
|
|
17
|
+
**模型工具** —— 你问 PDF 内容时由模型调用。
|
|
18
|
+
|
|
19
|
+
| 工具 | 作用 |
|
|
20
|
+
| --- | --- |
|
|
21
|
+
| `pdf_info` | 页数、印刷页↔物理页偏移、目录/TOC |
|
|
22
|
+
| `pdf_search` | 字面全文搜索;返回页码和摘要 |
|
|
23
|
+
| `pdf_read_pages` | 读取指定页的文本,也可返回页面图片 |
|
|
24
|
+
|
|
25
|
+
## 安装
|
|
26
|
+
|
|
27
|
+
1. DSH 的 **Plugins → Add plugin** 输入 `dsh-book-reader`(或命令行 `dsh plugin add dsh-book-reader`)。
|
|
28
|
+
2. 安装或升级后重启 DSH。
|
|
29
|
+
3. 可选:把 skill 软链到工作区,让模型拿到阅读流程说明:
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
ln -sfn "<已安装的包目录>" "<workspace>/.dsh/skills/pdf-reader"
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## 配置
|
|
36
|
+
|
|
37
|
+
全部可选,默认值即安全值。常用:
|
|
38
|
+
|
|
39
|
+
- `rememberView`(默认 `true`)—— 按书记住页码/缩放。
|
|
40
|
+
- `maxPagesPerCall`(默认 `4`)—— 单次读页上限。
|
|
41
|
+
- `defaultScale`(默认 `2.5`)—— 图片渲染倍率。
|
|
42
|
+
- `autoShare`(默认 `true`)—— AI 位置提示。
|
|
43
|
+
|
|
44
|
+
完整键和默认值见 [`cordis.patch.yml`](cordis.patch.yml) 注释。
|
|
45
|
+
|
|
46
|
+
## 说明
|
|
47
|
+
|
|
48
|
+
- 只支持官方 PDF 预览;工具栏依赖该预览的私有 DOM 标记,DSH 升级可能影响行为。
|
|
49
|
+
- 工具默认只在会话工作区内读取(可设 `allowOutsideWorkspace`);本地 HTTP 路由只认回环地址、无鉴权。
|
|
50
|
+
- 扫描件没有文本层,只能看图(没有 OCR)。
|
|
51
|
+
- `pdfjs-dist` 锁定 `6.3.289`,以和宿主进程一致。
|
|
52
|
+
|
|
53
|
+
## 更多
|
|
54
|
+
|
|
55
|
+
[`SKILL.md`](SKILL.md) —— 模型使用手册 · [`CHANGELOG.md`](CHANGELOG.md) · [`LICENSE`](LICENSE)(MIT)
|
package/SKILL.md
CHANGED
|
@@ -5,7 +5,7 @@ description: 'Read a PDF (book, paper, manual) cheaply and accurately with the d
|
|
|
5
5
|
|
|
6
6
|
# Reading a PDF with `dsh-book-reader`
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
Three tools, two cost tiers. **The default is text.** Images are a deliberate
|
|
9
9
|
expense, not the first move.
|
|
10
10
|
|
|
11
11
|
| Tool | Cost | Use for |
|
|
@@ -14,7 +14,6 @@ expense, not the first move.
|
|
|
14
14
|
| `pdf_search` | ~0 (text) | locating a phrase, theorem number, or figure caption |
|
|
15
15
|
| `pdf_read_pages` + `include_image:false` | ~0 (text, per page) | prose, theorem statements, exercise text |
|
|
16
16
|
| `pdf_read_pages` (images on) | **~350–1024 tokens/page** | formulas, diagrams, tables, layout |
|
|
17
|
-
| `pdf_current_page` | ~0 | which page the user is looking at |
|
|
18
17
|
|
|
19
18
|
## Default loop (text-first)
|
|
20
19
|
|
package/cordis.patch.yml
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
# dsh-book-reader bundle patch: mount the plugin into the active profile.
|
|
2
|
-
# Host half: pdf_info / pdf_search / pdf_read_pages
|
|
3
|
-
# /dsh-
|
|
4
|
-
#
|
|
5
|
-
#
|
|
2
|
+
# Host half: pdf_info / pdf_search / pdf_read_pages tools,
|
|
3
|
+
# /dsh-pdf-reader/* routes (PDF info/search, reading position, saved
|
|
4
|
+
# page/zoom), and a minimal per-turn reading-position line injected
|
|
5
|
+
# through agent/pre-step.
|
|
6
|
+
# Browser half: page readout, jump, search panel, remembered page/zoom on top of
|
|
6
7
|
# the official PDF preview's document-header slot.
|
|
7
8
|
#
|
|
8
9
|
# All config keys are optional. The defaults shown are the shipped behavior.
|
|
@@ -11,11 +12,11 @@
|
|
|
11
12
|
name: 'dsh-book-reader'
|
|
12
13
|
# config:
|
|
13
14
|
# enabled: true
|
|
14
|
-
#
|
|
15
|
+
# rememberView: true # remember last page + zoom per book
|
|
16
|
+
# autoShare: true # false stops position hints
|
|
15
17
|
# autoShareSection: true # include the outline section in the line
|
|
16
|
-
# autoShareMinIntervalMs:
|
|
17
|
-
# autoSharePageDelta: 1 # require a page change
|
|
18
|
-
# autoShareMinSteps: 1 # at most once per step
|
|
18
|
+
# autoShareMinIntervalMs: 0 # optional: min ms between hints (0 = no time throttle)
|
|
19
|
+
# autoSharePageDelta: 1 # require a page change before another hint
|
|
19
20
|
# autoShareMaxAgeMs: 0 # 0 = no age limit on a reported position
|
|
20
21
|
# allowOutsideWorkspace: false # tools may only read inside the session cwd
|
|
21
22
|
# routeAllowedRoots: [] # extra dirs the HTTP routes may serve; [] = any
|