dsh-book-reader 0.1.1 → 0.3.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 CHANGED
@@ -4,6 +4,51 @@ All notable changes to this project are documented here. The format follows
4
4
  [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project
5
5
  adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [0.3.0] — 2026-10-20
8
+
9
+ ### Changed
10
+
11
+ - Search is now a basic in-page find bar: `Cmd/Ctrl+F` opens it, matches are
12
+ highlighted on the PDF text layer, and `Enter` / `Shift+Enter` (or the
13
+ previous/next buttons) jump between occurrences with an `n / total` counter.
14
+ - The search result list, its snippets, and the per-result “→ AI” insertion are
15
+ gone; search no longer inserts anything into the composer.
16
+ - `pdf_search` is now normalized text search: wrapping quotes/backticks and
17
+ `$…$` are stripped, NFKC folds math alphanumerics and ligatures, dashes and
18
+ line-break hyphenation are removed, and if no literal phrase matches it falls
19
+ back to a space-insensitive pass (`compact`) and then keyword AND (`terms`).
20
+ The result gains `mode`; hits rank body pages before front matter (at most 3
21
+ front-matter hits), `pages` counts every matched page, and the tool default
22
+ limit is 30. The tool description now states these rules so the model stops
23
+ passing quoted or LaTeX-marked phrases.
24
+ - `pdf_search` accepts an optional `pages` selection (the same syntax as
25
+ `pdf_read_pages`; printed pages by default, `page_numbers:"pdf"` for physical
26
+ pages) to scan only a page range and report matches inside it. This keeps a
27
+ late-chapter search from being crowded out by earlier pages.
28
+
29
+ ### Fixed
30
+
31
+ - Opening a book now jumps to the remembered page immediately, before a saved
32
+ fixed zoom is replayed, so the cover no longer flashes for a few hundred
33
+ milliseconds while the zoom settles. The scroll is re-applied after the zoom
34
+ commit so the page stays aligned.
35
+
36
+ ## [0.2.0] — 2026-10-20
37
+
38
+ ### Added
39
+
40
+ - View-state memory: the toolbar remembers the last page and zoom ratio per PDF
41
+ and restores them when the same book is reopened. The state is stored by the
42
+ Host in the `book_reader_views` storage domain through `ctx.storageDomain`
43
+ (schema-validated JSON under the DSH data directory), survives DSH restarts,
44
+ and degrades silently when that service is unavailable.
45
+ - New config key `rememberView` (default `true`).
46
+ - Host routes `GET /dsh-pdf-reader/view?path=…` and
47
+ `POST /dsh-pdf-reader/view` for the browser half.
48
+ - Docs: the README is split into an English `README.md` and a Simplified Chinese
49
+ `README.zh-CN.md`, both rewritten in a product-page style (badges, quick start,
50
+ feature table, model-tool examples, FAQ, data/privacy notes).
51
+
7
52
  ## [0.1.1] — 2026-10-18
8
53
 
9
54
  ### Changed
@@ -56,5 +101,7 @@ First public release.
56
101
  - `pdfjs-dist` is pinned to `6.3.289` to match the host process.
57
102
  - MIT licensed.
58
103
 
104
+ [0.3.0]: https://github.com/Strepsiades2/dsh-book-reader/releases/tag/v0.3.0
105
+ [0.2.0]: https://github.com/Strepsiades2/dsh-book-reader/releases/tag/v0.2.0
59
106
  [0.1.1]: https://github.com/Strepsiades2/dsh-book-reader/releases/tag/v0.1.1
60
107
  [0.1.0]: https://github.com/Strepsiades2/dsh-book-reader/releases/tag/v0.1.0
package/README.md CHANGED
@@ -1,101 +1,91 @@
1
1
  # dsh-book-reader
2
2
 
3
- Read books and papers in DSH: a reading toolbar on the official PDF preview, plus three PDF tools for the model.
3
+ [![npm version](https://img.shields.io/npm/v/dsh-book-reader.svg)](https://www.npmjs.com/package/dsh-book-reader)
4
+ [![license](https://img.shields.io/npm/l/dsh-book-reader.svg)](LICENSE)
5
+ [![DSH](https://img.shields.io/badge/DSH-0.2.x-blue)](https://github.com/deepseek-ai/deepseek-harness)
4
6
 
5
- **English** | [中文](#中文说明)
7
+ **Read PDFs in DSH together with the model.** A native toolbar on the official PDF preview, plus three tools the model can use to look up the TOC, search the full text, and read pages — page images included, when a formula or diagram needs to be seen.
6
8
 
7
- ## Features
9
+ [中文说明](README.zh-CN.md)
8
10
 
9
- **Reading toolbar** — appears only on `.pdf` previews in the right sidebar; the stock previewer (zoom, selection, reload) is untouched.
11
+ ## Why this one
10
12
 
11
- - Previous/next page, a page readout that follows scrolling, and a jump box that accepts printed page numbers (or `p152` for PDF page 152).
12
- - Full-text search panel (`Cmd/Ctrl+Shift+F`): click a result to jump there, or insert its page reference into the chat.
13
- - **AI position hint** (on by default): before a turn starts, the model may receive one short line with the page you are reading — at most once per turn, and only when the page changed since the last hint. Turn it off if you do not want the model to know your page automatically.
14
- - Every control has a hover/focus explanation in English or Chinese, following the DSH UI language.
13
+ - **Native, not a replacement.** It decorates DSH's own PDF preview, so zoom, text selection, reload, and Office→PDF keep working. No extra viewer, no sidebar dependency.
14
+ - **The model can actually read the book.** Three tools give it the page map, text search, and page content, with page images only when needed.
15
+ - **It remembers where you were.** Reopening a book restores the last page and zoom.
15
16
 
16
- **Model tools** — the model can look up the page map, search the text, or read chosen pages (as text or as page images) when you ask about a PDF.
17
+ ## Quick start
17
18
 
18
- | Tool | What it does |
19
- | --- | --- |
20
- | `pdf_info` | Page count, printed↔physical page offset, outline/TOC. Text only. |
21
- | `pdf_search` | Literal full-text search; returns page numbers and snippets. |
22
- | `pdf_read_pages` | Text of chosen pages, optionally as images (`include_image: false` for text only; images cost ~350–1024 tokens/page). |
19
+ 1. DSH **Plugins → Add plugin** → `dsh-book-reader` (or `dsh plugin add dsh-book-reader`). Restart DSH.
20
+ 2. Open any `.pdf` in the right sidebar — the toolbar appears in the preview header.
21
+ 3. Ask the model about the PDF; it can search and read from now on.
23
22
 
24
- Typical loop: `pdf_info` → `pdf_search` → `pdf_read_pages` (text) → images only for formulas, diagrams, or tables.
23
+ Optional — give the model the reading guide (costs, page numbering, pitfalls):
25
24
 
26
- ## Install
25
+ ```sh
26
+ ln -sfn "<installed package dir>" "<workspace>/.dsh/skills/pdf-reader"
27
+ ```
27
28
 
28
- - **From npm**: DSH **Plugins → Add plugin** → `dsh-book-reader` (or pin `dsh-book-reader@0.1.1`), or `dsh plugin add dsh-book-reader`.
29
- - A fresh install applies live (this profile has HMR); **upgrading a plugin that is already loaded needs a DSH restart** to load the new code.
30
- - **Optional skill** (gives the model the built-in PDF reading guide): symlink the package into the workspace:
31
- ```sh
32
- ln -sfn "<installed package dir>" "<workspace>/.dsh/skills/pdf-reader"
33
- ```
34
- - **Local checkout**: `dsh plugin add "/abs/path/to/dsh-book-reader"`; keep the checkout and its `node_modules/` in place.
29
+ ## Features
35
30
 
36
- ## Configuration
31
+ | | Feature | What it does |
32
+ | --- | --- | --- |
33
+ | 🧭 | Navigation | Previous/next page, page readout, jump box (printed page, or `p152` for PDF page 152) |
34
+ | 🔎 | Search | Full-text search (`Cmd/Ctrl+F`) with in-page highlights; `Enter` / `Shift+Enter` jump between occurrences, no snippets |
35
+ | 🤖 | AI position hint | One short “you are reading page N” line per turn, only when the page changed (`AI●` toggle) |
36
+ | 💾 | Reading memory | Remembers page and zoom per book; restores them when you reopen it |
37
+ | 💬 | Tooltips | Hover/focus explanations on every control, English or Chinese |
38
+ | 🧰 | Model tools | `pdf_info`, `pdf_search`, `pdf_read_pages` — see below |
37
39
 
38
- Every option is optional and the defaults are safe. Common ones: `maxPagesPerCall` (default 4), `defaultScale` (2.5), `autoShare` (automatic position hint), `allowOutsideWorkspace` (tools stay inside the session workspace by default), `routeAllowedRoots` (restrict the local HTTP routes). The full list with defaults is commented in [`cordis.patch.yml`](cordis.patch.yml).
40
+ ## Model tools
39
41
 
40
- ## Notes
42
+ | Tool | Use it for | Cost |
43
+ | --- | --- | --- |
44
+ | `pdf_info` | Page count, printed↔physical page offset, outline/TOC | text, ~free |
45
+ | `pdf_search` | Finding a phrase, theorem number, or figure caption. Tolerates quotes/LaTeX, hyphen and math-notation splits, with keyword fallbacks; body pages first; optional `pages` range | text, ~free |
46
+ | `pdf_read_pages` | Reading chosen pages as text, optionally with page images | text ~free; images ~350–1024 tokens/page |
41
47
 
42
- - HTTP routes are loopback-only and unauthenticated; the tools are workspace-scoped by default. Other local preview plugins make the same tradeoff.
43
- - Works only with the official PDF preview: it relies on that preview's DOM markers, which a DSH upgrade may change.
44
- - Scanned PDFs have no text layer — there is no OCR, so only page images help.
45
- - `pdfjs-dist` is pinned to `6.3.289` to match the host process.
48
+ Example prompts:
46
49
 
47
- ## More
50
+ > “What does chapter 5 of this book cover?” → `pdf_info` + `pdf_read_pages`
51
+ > “Find where ‘singular value’ appears.” → `pdf_search`
52
+ > “Search only chapter 7 (printed pp. 270–295) for ‘SVD’.” → `pdf_search` with `pages:"270-295"`
53
+ > “Show me the formula in theorem 5.6.” → `pdf_read_pages` with images
48
54
 
49
- - [`SKILL.md`](SKILL.md) — model-facing guide: costs, page numbering, pitfalls.
50
- - [`CHANGELOG.md`](CHANGELOG.md) · [`LICENSE`](LICENSE) (MIT)
55
+ The model decides when text is enough and when an image is worth it.
51
56
 
52
- ---
53
-
54
- ## 中文说明
57
+ ## Configuration
55
58
 
56
- 在 DSH 里读 PDF 书和论文:官方 PDF 预览上加一条读书工具栏,外加三个 PDF 工具给模型。
59
+ Every key is optional and the defaults are safe. Common ones:
57
60
 
58
- ### 功能
61
+ - `rememberView` (default `true`) — remember page/zoom per book.
62
+ - `maxPagesPerCall` (default `4`) — page cap per read call.
63
+ - `defaultScale` (default `2.5`) — image render scale (~180 DPI).
64
+ - `autoShare` (default `true`) — the AI position hint.
59
65
 
60
- **阅读工具栏** —— 只在右侧栏的 `.pdf` 预览上出现;不替换官方预览器(缩放、选中、刷新都保持原样)。
66
+ The full list with defaults is in [`cordis.patch.yml`](cordis.patch.yml).
61
67
 
62
- - 上一页/下一页、随滚动更新的页码读数、跳页框(输入印刷页码,或 `p152` 表示 PDF 第 152 页)。
63
- - 全文搜索面板(`Cmd/Ctrl+Shift+F`):点结果跳页,或把该页引用插入对话框。
64
- - **AI 位置提示**(默认开):每轮对话开始时,模型可能收到一行“你正在看第 N 页”的短提示 —— 每轮最多一次,且页码变了才发。关掉后,模型不会自动知道你在哪页。
65
- - 每个控件都有 hover / 键盘聚焦提示,跟随 DSH 界面语言(中文或英文)。
68
+ ## FAQ
66
69
 
67
- **模型工具** —— 默认只花文本 token,图片是按需付的钱。
70
+ **The toolbar does not appear.** Only `.pdf` previews get it (not `.docx`/`.pptx`/images). Update/reinstall the plugin and restart DSH.
68
71
 
69
- | 工具 | 作用 |
70
- | --- | --- |
71
- | `pdf_info` | 页数、印刷页↔物理页偏移、目录/TOC;纯文本。 |
72
- | `pdf_search` | 字面全文搜索;返回页码和摘要。 |
73
- | `pdf_read_pages` | 选中页的文本,也可返回页面图片(`include_image: false` 只取文本;图片约 350–1024 token/页)。 |
72
+ **The model does not know my page.** The hint is sent at most once per turn and only when the page changed; turn on `AI●`, or mention the page in your message.
74
73
 
75
- 典型流程:`pdf_info` → `pdf_search` → `pdf_read_pages`(文本)→ 只有公式、图表、表格才看图。
74
+ **Scanned PDFs.** No text layer: search finds nothing and text reads are empty. Page images still work — check `textCoverage.isLikelyScanned` from `pdf_info`.
76
75
 
77
- ### 安装
76
+ **Search finds nothing.** Quotes and `$…$` are stripped, hyphen/math splits and missing spaces have fallbacks, and when no literal phrase matches the tool falls back to keyword AND (`mode` in the result says which pass matched). Try one short distinctive word.
78
77
 
79
- - **从 npm 安装**:DSH **Plugins → Add plugin** → 输入 `dsh-book-reader`(或锁定版本 `dsh-book-reader@0.1.1`),或命令行 `dsh plugin add dsh-book-reader`。
80
- - 全新安装即时生效(本 profile 已启用 HMR);**升级已加载的插件需要完整重启 DSH** 才能加载新代码。
81
- - **可选 skill**(给模型一份内置的 PDF 阅读指南):把包目录软链到工作区:
82
- ```sh
83
- ln -sfn "<已安装的包目录>" "<workspace>/.dsh/skills/pdf-reader"
84
- ```
85
- - **本地开发**:`dsh plugin add "/abs/path/to/dsh-book-reader"`;源码目录和 `node_modules/` 必须留在原处。
78
+ **Does it modify my PDF?** No. It only reads and renders; nothing is written next to your books.
86
79
 
87
- ### 配置
80
+ **Where is the remembered state?** In DSH's data directory (`~/.dsh/storages/book_reader_views.json`), at most 500 books, keyed by file path.
88
81
 
89
- 全部可选,默认值即安全值。常用:`maxPagesPerCall`(默认 4)、`defaultScale`(2.5)、`autoShare`(自动位置提示)、`allowOutsideWorkspace`(工具默认只读会话工作区)、`routeAllowedRoots`(限制本地 HTTP 路由)。完整键和默认值见 [`cordis.patch.yml`](cordis.patch.yml) 注释。
82
+ **A DSH upgrade broke the toolbar.** The toolbar relies on the preview's private DOM markers; page tools keep working regardless.
90
83
 
91
- ### 说明
84
+ ## Notes
92
85
 
93
- - HTTP 路由只认回环地址且无鉴权;工具默认只在工作区内。其他本地预览插件也是同样的权衡。
94
- - 只支持官方 PDF 预览(依赖它的私有 DOM 标记,DSH 升级可能失效)。
95
- - 扫描件没有文本层,**没有 OCR**,只能看图。
96
- - `pdfjs-dist` 锁定 `6.3.289`,以和宿主进程保持一致。
86
+ - Local HTTP routes are loopback-only and unauthenticated; model tools stay inside the session workspace by default (`allowOutsideWorkspace` opts out).
87
+ - `pdfjs-dist` is pinned to `6.3.289` to match the DSH host process.
97
88
 
98
- ### 更多
89
+ ## More
99
90
 
100
- - [`SKILL.md`](SKILL.md) —— 模型使用手册:成本、页码、常见陷阱。
101
- - [`CHANGELOG.md`](CHANGELOG.md) · [`LICENSE`](LICENSE)(MIT)
91
+ [`SKILL.md`](SKILL.md) — the model's reading guide · [`CHANGELOG.md`](CHANGELOG.md) · [`LICENSE`](LICENSE) (MIT)
@@ -0,0 +1,91 @@
1
+ # dsh-book-reader
2
+
3
+ [![npm version](https://img.shields.io/npm/v/dsh-book-reader.svg)](https://www.npmjs.com/package/dsh-book-reader)
4
+ [![license](https://img.shields.io/npm/l/dsh-book-reader.svg)](LICENSE)
5
+ [![DSH](https://img.shields.io/badge/DSH-0.2.x-blue)](https://github.com/deepseek-ai/deepseek-harness)
6
+
7
+ **在 DSH 里和模型一起读 PDF。** 官方 PDF 预览上加一条原生工具栏,并给模型三个工具:查目录、全文搜索、读指定页——公式和图表需要时还能直接看页面图片。
8
+
9
+ [English](README.md)
10
+
11
+ ## 为什么用它
12
+
13
+ - **原生,不替换。** 装饰 DSH 自己的 PDF 预览器,缩放、选中、刷新、Office→PDF 都保持原样;不额外装阅读器、不依赖侧边栏插件。
14
+ - **模型真的能读这本书。** 三个工具给它页码/目录、文本搜索和页面内容;只有需要看公式、图表时才花图片 token。
15
+ - **记住你读到哪。** 再次打开同一本书,自动回到上次的页码和缩放。
16
+
17
+ ## 三步上手
18
+
19
+ 1. DSH 的 **Plugins → Add plugin** → `dsh-book-reader`(或 `dsh plugin add dsh-book-reader`),重启 DSH。
20
+ 2. 在右侧栏打开任意 `.pdf`,预览头部出现工具栏。
21
+ 3. 直接问模型关于这本书的问题,它就能自己搜、自己读。
22
+
23
+ 可选——把阅读指南交给模型(成本、页码规则、常见坑):
24
+
25
+ ```sh
26
+ ln -sfn "<已安装的包目录>" "<workspace>/.dsh/skills/pdf-reader"
27
+ ```
28
+
29
+ ## 功能
30
+
31
+ | | 功能 | 说明 |
32
+ | --- | --- | --- |
33
+ | 🧭 | 翻页与跳页 | 上一页/下一页、跟随滚动的页码读数、跳页框(印刷页码,或 `p152` 表示 PDF 第 152 页) |
34
+ | 🔎 | 全文搜索 | `Cmd/Ctrl+F` 打开搜索,命中文字在页面上高亮;`Enter` / `Shift+Enter` 在命中之间顺序跳转,不显示摘要 |
35
+ | 🤖 | AI 位置提示 | 每轮对话最多一行“你正在看第 N 页”,页码变了才发(`AI●` 开关) |
36
+ | 💾 | 阅读记忆 | 按书记住页码和缩放,重新打开时恢复 |
37
+ | 💬 | 悬停说明 | 每个控件都有悬停/聚焦提示,跟随 DSH 界面语言(中/英) |
38
+ | 🧰 | 模型工具 | `pdf_info`、`pdf_search`、`pdf_read_pages`,见下 |
39
+
40
+ ## 模型工具
41
+
42
+ | 工具 | 用途 | 成本 |
43
+ | --- | --- | --- |
44
+ | `pdf_info` | 页数、印刷页↔物理页偏移、目录/TOC | 文本,几乎免费 |
45
+ | `pdf_search` | 找短语、定理编号、图表标题。容忍引号/LaTeX、连字符与数学符号拆分,支持关键词回退;正文页优先;可用 `pages` 限定页范围 | 文本,几乎免费 |
46
+ | `pdf_read_pages` | 读指定页的文本,可选返回页面图片 | 文本几乎免费;图片约 350–1024 token/页 |
47
+
48
+ 可以这样问:
49
+
50
+ > “这本书第 5 章讲了什么?” → `pdf_info` + `pdf_read_pages`
51
+ > “找一下 singular value 出现在哪几页。” → `pdf_search`
52
+ > “只在第 7 章(印刷页 270–295)里找 SVD。” → `pdf_search` 加 `pages:"270-295"`
53
+ > “把定理 5.6 的公式截给我看。” → `pdf_read_pages` 带图片
54
+
55
+ 什么时候用文本、什么时候值得花图片 token,由模型自己判断。
56
+
57
+ ## 配置
58
+
59
+ 全部可选,默认值即安全值。常用:
60
+
61
+ - `rememberView`(默认 `true`)—— 按书记住页码/缩放。
62
+ - `maxPagesPerCall`(默认 `4`)—— 单次读页上限。
63
+ - `defaultScale`(默认 `2.5`)—— 图片渲染倍率(约 180 DPI)。
64
+ - `autoShare`(默认 `true`)—— AI 位置提示。
65
+
66
+ 完整键和默认值见 [`cordis.patch.yml`](cordis.patch.yml) 注释。
67
+
68
+ ## 常见问题
69
+
70
+ **看不到工具栏?** 只有 `.pdf` 预览会挂工具栏(`.docx`/`.pptx`/图片不会)。升级/重装插件后重启 DSH。
71
+
72
+ **模型不知道我在哪一页?** 位置提示每轮最多一次、页码变了才发;打开 `AI●`,或直接在消息里提页码。
73
+
74
+ **扫描件?** 没有文本层:搜索为空、文本读页为空;页面图片仍然可用,先用 `pdf_info` 的 `textCoverage.isLikelyScanned` 判断。
75
+
76
+ **搜索找不到东西?** 引号和 `$…$` 会被去掉,连字符/数学符号拆分、缺空格有回退;整句没有字面命中时会退化成关键词 AND 搜索(结果的 `mode` 会说明命中方式)。试一个更短、更独特的词。
77
+
78
+ **会改我的 PDF 吗?** 不会。只读取和渲染,不会往书目录写任何东西。
79
+
80
+ **记住的状态存哪?** DSH 数据目录下的 `~/.dsh/storages/book_reader_views.json`,按文件路径索引,最多保留 500 本。
81
+
82
+ **DSH 升级后工具栏失效?** 工具栏依赖预览器的私有 DOM 标记;即使失效,模型工具仍然可用。
83
+
84
+ ## 说明
85
+
86
+ - 本地 HTTP 路由只认回环地址、无鉴权;模型工具默认只在会话工作区内读取(可设 `allowOutsideWorkspace`)。
87
+ - `pdfjs-dist` 锁定 `6.3.289`,与 DSH 宿主进程保持一致。
88
+
89
+ ## 更多
90
+
91
+ [`SKILL.md`](SKILL.md) —— 模型使用手册 · [`CHANGELOG.md`](CHANGELOG.md) · [`LICENSE`](LICENSE)(MIT)
package/SKILL.md CHANGED
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: pdf-reader
3
- description: 'Read a PDF (book, paper, manual) cheaply and accurately with the dsh-book-reader tools: page map/TOC, literal full-text search, then selective page reads (text first, images only when typography matters). Use whenever the user asks about specific pages, a section, a theorem, a figure, or "this page" in a PDF.'
3
+ description: 'Read a PDF (book, paper, manual) cheaply and accurately with the dsh-book-reader tools: page map/TOC, normalized text search (quote/LaTeX-tolerant, with hyphen/space and keyword fallbacks), then selective page reads (text first, images only when typography matters). Use whenever the user asks about specific pages, a section, a theorem, a figure, or "this page" in a PDF.'
4
4
  ---
5
5
 
6
6
  # Reading a PDF with `dsh-book-reader`
@@ -11,7 +11,7 @@ expense, not the first move.
11
11
  | Tool | Cost | Use for |
12
12
  | --- | --- | --- |
13
13
  | `pdf_info` | ~0 (text) | page count, printed↔physical offset, outline/TOC |
14
- | `pdf_search` | ~0 (text) | locating a phrase, theorem number, or figure caption |
14
+ | `pdf_search` | ~0 (text) | locating a phrase, theorem number, or figure caption (quotes and `$…$` are stripped; optional `pages` range) |
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
17
 
@@ -19,7 +19,12 @@ expense, not the first move.
19
19
 
20
20
  1. `pdf_info` once per document → note `printedOffset` and the outline. Never
21
21
  hardcode an offset; it is detected (`printed = pdf − printedOffset`).
22
- 2. `pdf_search` for a distinctive phrase → page numbers.
22
+ 2. `pdf_search` for a short, distinctive phrase → page numbers. If the result's
23
+ `mode` is not `"phrase"` (i.e. `"compact"` or `"terms"`), treat the hits as
24
+ candidate pages and read them before quoting exact wording. When the reader
25
+ is late in the book (or the position hint says so), pass `pages:"…"` around
26
+ the current printed page (e.g. `pages:"270-295"`) so earlier chapters cannot
27
+ crowd the 30-hit budget; `page_numbers:"pdf"` switches to physical pages.
23
28
  3. `pdf_read_pages` with **`include_image:false`** to read those pages as text.
24
29
  4. Only if the text is ambiguous or the question is about typography (a formula,
25
30
  a diagram, a table) → call again with images on, and crop.
@@ -82,7 +87,20 @@ needs it, and prefer `include_image:false` first.
82
87
  - `pdf_info` also reports `title`, `author`, `fileSizeBytes`, `pageSize` and
83
88
  `textCoverage` (`isLikelyScanned`). Check `textCoverage.isLikelyScanned`
84
89
  *before* searching: a scanned PDF has no text layer, so go straight to images.
85
- - Search is literal: it does not unfold hyphenation and is not a regex engine.
90
+ - **`pdf_search` is normalized text search, not a regex engine.** Wrapping
91
+ quotes/backticks and `$…$` are stripped; NFKC folds math alphanumerics
92
+ (`ℒ (𝑉)`→`L (V)`) and ligatures; dash variants are dropped, so line-break
93
+ hyphenation (`com- plex`) matches `complex`. If no literal phrase matches, the
94
+ tool falls back to a space-insensitive pass (`mode: "compact"`, so `L(V)`
95
+ finds `ℒ (𝑉)`) and then to keyword AND (`mode: "terms"`). Body pages rank
96
+ before front matter (at most 3 front-matter hits), `pages` counts every matched
97
+ page before `limit`, and the default limit is 30. If a query finds nothing, try
98
+ one shorter distinctive word and read the pages rather than assuming absence.
99
+ - **`pdf_search` can be scoped to a page range.** `pages:"270-295"` (same syntax
100
+ as `pdf_read_pages`, printed pages by default) only scans those pages; the
101
+ returned `pages` count then counts matches inside that range. Use it when the
102
+ user is reading a later chapter and whole-book hits would be dominated by
103
+ earlier pages.
86
104
  - Page numbers are 1-based; relative paths resolve against the session directory.
87
105
  - No annotation/note features: this plugin reads and renders only.
88
106
 
package/cordis.patch.yml CHANGED
@@ -1,8 +1,9 @@
1
1
  # dsh-book-reader bundle patch: mount the plugin into the active profile.
2
2
  # Host half: pdf_info / pdf_search / pdf_read_pages tools,
3
- # /dsh-book-reader/* routes, and a minimal per-turn reading-position
4
- # line injected through agent/pre-step.
5
- # Browser half: page readout, jump, search panel, and share-to-chat on top of
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,6 +12,7 @@
11
12
  name: 'dsh-book-reader'
12
13
  # config:
13
14
  # enabled: true
15
+ # rememberView: true # remember last page + zoom per book
14
16
  # autoShare: true # false stops position hints
15
17
  # autoShareSection: true # include the outline section in the line
16
18
  # autoShareMinIntervalMs: 0 # optional: min ms between hints (0 = no time throttle)