@dylanl1/dsh-plugin-pdf 0.1.2 → 0.1.3
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/NATIVE_V1.md +3 -1
- package/README.md +54 -114
- package/README.zh.md +61 -121
- package/SPEC.md +46 -51
- package/dist/THIRD_PARTY_NOTICES.md +1 -56
- package/dist/client.js +5045 -2779
- package/dist/embedding.js +34 -9
- package/dist/engines.js +49 -4
- package/dist/image-host.js +837 -505
- package/dist/index.js +6790 -4126
- package/dist/ocr-host.js +1036 -175
- package/dist/ocr.js +4 -1
- package/dist/translation.js +43 -14
- package/dist/types/adapters/host/dsh/agent-tools.d.ts +1 -1
- package/dist/types/adapters/host/dsh/document-status.d.ts +0 -1
- package/dist/types/adapters/host/dsh/form-guidance.d.ts +2 -2
- package/dist/types/adapters/host/dsh/image-backends.d.ts +19 -3
- package/dist/types/adapters/host/dsh/image-tools.d.ts +15 -0
- package/dist/types/adapters/host/dsh/image-transport.d.ts +8 -7
- package/dist/types/adapters/host/dsh/index.d.ts +3 -2
- package/dist/types/adapters/host/dsh/model-cache-identity.d.ts +26 -0
- package/dist/types/adapters/host/dsh/ocr-session-llm.d.ts +2 -3
- package/dist/types/adapters/host/dsh/ocr-tool.d.ts +4 -2
- package/dist/types/adapters/host/dsh/page-content.d.ts +27 -0
- package/dist/types/adapters/host/dsh/pdf-evidence-meta.d.ts +13 -148
- package/dist/types/adapters/host/dsh/retrieval-prefetch.d.ts +49 -0
- package/dist/types/adapters/host/dsh/retrieval.d.ts +132 -25
- package/dist/types/adapters/host/dsh/translation-model.d.ts +3 -5
- package/dist/types/adapters/host/ocr/local-backend.d.ts +4 -0
- package/dist/types/contracts/indexing.d.ts +156 -0
- package/dist/types/embedding/registry.d.ts +2 -1
- package/dist/types/embedding/types.d.ts +10 -2
- package/dist/types/entrypoints/image-understanding-host.d.ts +2 -8
- package/dist/types/host/image-understanding-plugin.d.ts +1 -1
- package/dist/types/modules/document/index.d.ts +7 -0
- package/dist/types/modules/document/page-content-error.d.ts +3 -0
- package/dist/types/modules/document/page-content-native.d.ts +10 -0
- package/dist/types/modules/document/page-content-ocr.d.ts +5 -0
- package/dist/types/modules/document/page-content-text.d.ts +12 -0
- package/dist/types/modules/document/page-content.d.ts +158 -0
- package/dist/types/modules/engines/cache-identity.d.ts +16 -0
- package/dist/types/modules/engines/catalog.d.ts +20 -0
- package/dist/types/modules/engines/directory.d.ts +1 -0
- package/dist/types/modules/engines/index.d.ts +3 -0
- package/dist/types/modules/engines/serialization.d.ts +3 -0
- package/dist/types/modules/engines/types.d.ts +13 -0
- package/dist/types/modules/evidence/agent-page-image.d.ts +9 -112
- package/dist/types/modules/evidence/agent-page-read.d.ts +36 -2
- package/dist/types/modules/evidence/image-capture.d.ts +1 -6
- package/dist/types/modules/evidence/index.d.ts +9 -136
- package/dist/types/modules/evidence/provenance.d.ts +8 -0
- package/dist/types/modules/evidence/reference-store.d.ts +91 -1
- package/dist/types/modules/evidence/status.d.ts +17 -0
- package/dist/types/modules/evidence/text-range.d.ts +28 -0
- package/dist/types/modules/evidence/text-target.d.ts +7 -1
- package/dist/types/modules/forms/index.d.ts +4 -4
- package/dist/types/modules/forms/inspection-references.d.ts +1 -1
- package/dist/types/modules/forms/validation.d.ts +4 -8
- package/dist/types/modules/image-understanding/service.d.ts +24 -42
- package/dist/types/modules/model-write/index.d.ts +1 -2
- package/dist/types/modules/ocr/service.d.ts +51 -3
- package/dist/types/modules/retrieval/cache.d.ts +44 -2
- package/dist/types/modules/retrieval/document-policy.d.ts +83 -0
- package/dist/types/modules/retrieval/index.d.ts +4 -1
- package/dist/types/modules/retrieval/page-content.d.ts +4 -0
- package/dist/types/modules/retrieval/paragraphs.d.ts +1 -12
- package/dist/types/modules/retrieval/shared-source.d.ts +25 -0
- package/dist/types/modules/retrieval/text.d.ts +19 -1
- package/dist/types/modules/retrieval/types.d.ts +83 -9
- package/dist/types/modules/retrieval/vector.d.ts +3 -0
- package/dist/types/modules/working-copy/index.d.ts +1 -1
- package/dist/types/modules/working-copy/ports.d.ts +11 -0
- package/dist/types/modules/working-copy/service.d.ts +13 -1
- package/dist/types/ocr/types.d.ts +2 -1
- package/dist/types/shared/contracts.d.ts +4 -0
- package/dist/types/shared/geometry/native-viewport.d.ts +0 -18
- package/dist/types/shared/geometry/text-target.d.ts +2 -6
- package/dist/types/shared/native.d.ts +2 -1
- package/dist/types/shared/passive-poll.d.ts +4 -0
- package/dist/types/translation/locales.d.ts +4 -3
- package/dist/types/translation/schema.d.ts +14 -0
- package/dist/types/translation/types.d.ts +12 -2
- package/docs/AI_READER_TOOLS.md +87 -210
- package/docs/ARCHITECTURE_V2.md +64 -18
- package/docs/ENGINE_EXTENSIONS.md +295 -25
- package/docs/RETRIEVAL_EXPERIMENT.md +169 -47
- package/docs/UX_TYPOGRAPHY.md +3 -3
- package/package.json +13 -13
- package/dist/types/adapters/host/dsh/image-auxiliary.d.ts +0 -20
package/NATIVE_V1.md
CHANGED
|
@@ -51,7 +51,9 @@ npm run check
|
|
|
51
51
|
|
|
52
52
|
保存与授权仍在 Host。helper 通过进程隔离避免在 Host V8 中直接运行 PDFium;本版没有新增操作系统级沙箱。
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
文字质量检测区分 PDFium 的换行断字标记(`U+0002` 且 `FPDFText_IsHyphen()` 为真)和真正的控制字符/Unicode 映射错误。合法断字不再触发警告或无必要的整页 OCR;真实映射错误仍报告。回归测试同时覆盖这两类字符,以及 Reader 与模型读取正常断字时均不启动 OCR。此修复不猜测缺失的符号字体映射,也不改变原生文字或定位偏移。
|
|
55
|
+
|
|
56
|
+
内置书签写入不经原生 helper:UI 与 `pdf_bookmark_edit` 共用目录操作领域和工作副本修订检查,撤销/重做及草稿恢复沿用原事务,最终由 pdf-lib 修改 `/Outlines`。重命名或移动保留既有目的地、外链和样式;显式修改目标页改为页面适合目的地。
|
|
55
57
|
|
|
56
58
|
## 性能假设和测量
|
|
57
59
|
|
package/README.md
CHANGED
|
@@ -2,152 +2,92 @@
|
|
|
2
2
|
|
|
3
3
|
English | [中文](README.zh.md)
|
|
4
4
|
|
|
5
|
-
Read
|
|
5
|
+
Read PDFs alongside your [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) conversation. Let the model find relevant passages, annotate them, navigate to the source, and return to your previous reading position.
|
|
6
6
|
|
|
7
|
-
I
|
|
7
|
+
I read papers and books in PDF form. The readers I tried lacked multi-step back navigation, while AI explanation and translation often required another subscription. I built this plugin for my own DSH workspace.
|
|
8
8
|
|
|
9
|
-
##
|
|
9
|
+
## Features
|
|
10
10
|
|
|
11
|
-
- **Read and
|
|
12
|
-
- **
|
|
13
|
-
- **
|
|
14
|
-
- **
|
|
15
|
-
- **
|
|
16
|
-
- **
|
|
17
|
-
- **Translate selections.** Get pronunciation, meanings, parts of speech and examples for words; meanings and examples for phrases; direct translations for sentences.
|
|
18
|
-
- **Ask in context.** Select several text passages or single-page image regions, attach a question to each, and send them together to the current conversation.
|
|
19
|
-
- **Capture and recognize.** Copy or download a page region, run OCR on a page or region, and use the configured image-understanding backend.
|
|
20
|
-
- **Let the model work with the PDF.** Read unread pages, find related passages, mark evidence, edit forms and bookmarks, and navigate an already visible Reader.
|
|
21
|
-
- **Extend AI engines.** Register OCR, image-understanding, translation and embedding implementations through plugin APIs; available engines appear in PDF settings.
|
|
22
|
-
- **Search by meaning (experimental).** Combine keyword matching with a local embedding model to find paraphrases and cross-language passages. Results remain original text references; incomplete indexing and image-only pages are reported explicitly. Embedding is off by default.
|
|
11
|
+
- **Read and navigate**: continuous scrolling, zoom, thumbnails, text search, and multi-step back history with selectable destinations.
|
|
12
|
+
- **Annotate and bookmark**: highlights, underlines, strikeouts, comments, draggable and resizable notes, and editing of the PDF's built-in bookmark tree.
|
|
13
|
+
- **Translate and explain**: word meanings, pronunciation and examples; phrase and sentence translations; questions attached to multiple text passages or image regions, sent together to the current conversation.
|
|
14
|
+
- **Agent control**: read, search, annotate, edit bookmarks and fill existing AcroForm fields in the same draft as the user.
|
|
15
|
+
- **Save and recover**: undo/redo, draft recovery, save/save as, and source-file conflict detection.
|
|
16
|
+
- **OCR and retrieval**: region capture, text recognition and experimental semantic search with your own embedding service. Indexes can include scanned-page text and image descriptions.
|
|
23
17
|
|
|
24
|
-
|
|
18
|
+

|
|
25
19
|
|
|
26
|
-
|
|
20
|
+

|
|
27
21
|
|
|
28
|
-
|
|
29
|
-
- `pdf_open` — Open a PDF in the background and obtain its shared document reference.
|
|
30
|
-
- `pdf_close` — Release the model's document reference; Reader tabs keep their own references.
|
|
31
|
-
- `pdf_status` — Inspect revisions, unsaved changes, conflicts and available capabilities.
|
|
32
|
-
- `pdf_read_page` — Read a bounded text window from a specified page.
|
|
33
|
-
- `pdf_search` — Search for exact text and return source references.
|
|
34
|
-
- `pdf_find_related` — Find passages related to a question or concept and return source references.
|
|
35
|
-
- `pdf_locate` — Locate a quoted passage in the original page text.
|
|
36
|
-
- `pdf_context` — Read surrounding text for a position, quote or source reference.
|
|
37
|
-
- `pdf_render_page` — Return a page image or derived text from the configured image-understanding backend.
|
|
38
|
-
- `pdf_ocr_page` — Recognize text on a page using the selected OCR backend.
|
|
39
|
-
- `pdf_image_context` — Retrieve previously recorded image or OCR evidence after revalidation.
|
|
40
|
-
- `pdf_form_inspect_page` — Return a page image with numbered writable controls and their types/options.
|
|
41
|
-
- `pdf_fill_form` — Fill one inspected page atomically in the shared draft.
|
|
42
|
-
- `pdf_page_annotations` — List a page's annotations, comments and exact IDs.
|
|
43
|
-
- `pdf_annotate` — Add a highlight, underline, strikeout or page note; text ranges can span pages.
|
|
44
|
-
- `pdf_annotation_update` — Update text-mark colors or the text of a mark, note or comment reply.
|
|
45
|
-
- `pdf_annotation_delete` — Delete an editable annotation or comment reply by ID.
|
|
46
|
-
- `pdf_bookmarks` — Read the PDF's built-in bookmark tree and IDs.
|
|
47
|
-
- `pdf_outline_edit` — Add, rename, delete, reorder or reparent built-in bookmarks.
|
|
48
|
-
- `pdf_navigate` — Jump to a verified passage or page in a visible Reader, preserving back history.
|
|
49
|
-
- `pdf_save` — Request user approval and save the current draft over its source PDF.
|
|
50
|
-
- `ocr_recognize` — Transcribe a session-scoped image handle; provided by the bundled OCR plugin.
|
|
22
|
+
## Install
|
|
51
23
|
|
|
52
|
-
|
|
24
|
+
Validated with DSH `0.2.1-rc.5`; other supported versions are declared in [package.json](package.json).
|
|
53
25
|
|
|
54
|
-
|
|
26
|
+
**GUI**: open **Plugins → Add plugin**, enter `@dylanl1/dsh-plugin-pdf`, install, then click **Enable now**.
|
|
55
27
|
|
|
56
|
-
|
|
28
|
+
**CLI**: replace `<profile>` with your profile:
|
|
57
29
|
|
|
58
|
-
|
|
30
|
+
```sh
|
|
31
|
+
dsh plugin --profile <profile> add @dylanl1/dsh-plugin-pdf
|
|
32
|
+
```
|
|
59
33
|
|
|
60
|
-
|
|
34
|
+
For Desktop, install its bundled CLI through **Manage dsh Command…** in the app menu. Launch Desktop once, fully quit it, install with `--profile desktop`, then reopen it. A separately npm-installed CLI cannot manage Desktop's plugins.
|
|
61
35
|
|
|
62
|
-
|
|
36
|
+
Native components install automatically; no local compilation is needed. Supported platforms: macOS (Apple Silicon/Intel), Windows x64, and glibc Linux (x64/arm64).
|
|
63
37
|
|
|
64
|
-
|
|
38
|
+
Open a local PDF from DSH's file sidebar. AI features use your configured models or extension engines. Semantic retrieval requires a separately configured embedding service and is off by default. PDFs with an enabled active policy prepare their index in the background on open; OCR and image descriptions can be enabled independently and may call remote services and incur charges. See [SPEC](SPEC.md) for limits.
|
|
65
39
|
|
|
66
|
-
|
|
40
|
+
Settings save automatically. Select engines in **PDF settings**; each PDF independently enables OCR and image-description indexing under **Search → Current PDF index**. Update indexes when needed to reuse cached results; disabling semantic search takes effect immediately.
|
|
67
41
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
You can also use the CLI. Replace `<profile>` with the profile you actually use:
|
|
42
|
+
## Agent tools
|
|
71
43
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
44
|
+
- Documents: `pdf_current`, `pdf_open`, `pdf_close`, `pdf_info`, `pdf_status`.
|
|
45
|
+
- Reading: `pdf_page_read`, `pdf_page_render`.
|
|
46
|
+
- Search and evidence: `pdf_keyword_search`, `pdf_semantic_search`, `pdf_evidence_read`.
|
|
47
|
+
- Annotations: `pdf_annotation_list`, `pdf_annotation_create`, `pdf_annotation_update`, `pdf_annotation_delete`.
|
|
48
|
+
- Bookmarks: `pdf_bookmark_list`, `pdf_bookmark_edit`.
|
|
49
|
+
- Forms: `pdf_form_inspect`, `pdf_form_fill`.
|
|
50
|
+
- Navigation and saving: `pdf_page_jump`, `pdf_save`.
|
|
51
|
+
- Images: `ocr_recognize`, `image_understand`.
|
|
75
52
|
|
|
76
|
-
|
|
53
|
+
`pdf_open` opens documents in the background; navigation requires a visible Reader. Agent edits go straight into the draft; overwriting the source still requires user approval. See the [tool documentation](docs/AI_READER_TOOLS.md) for parameters and examples.
|
|
77
54
|
|
|
78
|
-
|
|
55
|
+
## Extend engines
|
|
79
56
|
|
|
80
|
-
|
|
57
|
+
OCR, image understanding, translation and embedding support third-party implementations. Build an independent DSH Host plugin, declare this package as a peer dependency, register your backend with the corresponding service through the public SDK, and install it in the same Host profile. It then appears in PDF settings.
|
|
81
58
|
|
|
82
|
-
|
|
59
|
+
Start with [`http-engines`](examples/http-engines) in [`examples/`](examples/README.md), an independent plugin providing HTTP OCR and image-understanding backends. See [engine extensions](docs/ENGINE_EXTENSIONS.md) for API and lifecycle contracts.
|
|
83
60
|
|
|
84
61
|
## Architecture
|
|
85
62
|
|
|
86
63
|
```mermaid
|
|
87
64
|
flowchart TB
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
65
|
+
Reader["Client · PDF Reader"] <--> RPC
|
|
66
|
+
Model["DSH conversation model"] -- "Tool calls" --> Features
|
|
67
|
+
subgraph Host
|
|
68
|
+
RPC["Authenticated RPC"] --> Features["PDF domain capabilities"]
|
|
69
|
+
Features --> Copy["Shared working copy · Drafts and undo"]
|
|
70
|
+
Features --> Search["Retrieval and evidence"]
|
|
71
|
+
Features --> Engines["Extensible AI engines"]
|
|
72
|
+
Search --> Copy
|
|
73
|
+
Search --> Engines
|
|
74
|
+
Copy --> PDF["PDFium · pdf-lib"]
|
|
75
|
+
Copy --> Storage["Files and draft storage"]
|
|
91
76
|
end
|
|
92
|
-
subgraph Host["Host · Authority"]
|
|
93
|
-
RPC["Authenticated RPC"]
|
|
94
|
-
Tools["Agent tools"]
|
|
95
|
-
Features["PDF and AI use cases"]
|
|
96
|
-
Copy["Shared working copy<br/>Drafts, revisions, undo, save"]
|
|
97
|
-
AI["Typed services<br/>OCR · Image understanding · Translation · Embedding"]
|
|
98
|
-
Retrieval["Text retrieval<br/>BM25 + embeddings · Rebuildable cache"]
|
|
99
|
-
Evidence["Existing evidence references<br/>Revalidate before marking or navigation"]
|
|
100
|
-
Catalog["Read-only engine catalog<br/>Change notifications"]
|
|
101
|
-
Config["Per-feature engine bindings<br/>Configuration and credential references"]
|
|
102
|
-
Backends["Default and contributor engines<br/>Same registration / Fiber-owned disposal"]
|
|
103
|
-
Native["PDF adapters<br/>pdf-lib · Native PDFium"]
|
|
104
|
-
Files["Files and draft storage"]
|
|
105
|
-
RPC --> Features
|
|
106
|
-
Tools --> Features
|
|
107
|
-
Features --> Copy
|
|
108
|
-
Features --> AI
|
|
109
|
-
Features --> Retrieval
|
|
110
|
-
Retrieval --> AI
|
|
111
|
-
Retrieval --> Evidence
|
|
112
|
-
Evidence --> Copy
|
|
113
|
-
Copy --> Native
|
|
114
|
-
Copy --> Files
|
|
115
|
-
AI --> Backends
|
|
116
|
-
AI --> Config
|
|
117
|
-
AI -. "Descriptor changes" .-> Catalog
|
|
118
|
-
Catalog --> RPC
|
|
119
|
-
RPC --> Config
|
|
120
|
-
end
|
|
121
|
-
Reader <--> RPC
|
|
122
|
-
Settings <--> RPC
|
|
123
|
-
Model["DSH conversation model"] <--> Tools
|
|
124
|
-
Backends --> Dependencies["DSH LLM · Local workers · Remote APIs"]
|
|
125
77
|
```
|
|
126
78
|
|
|
127
|
-
The
|
|
128
|
-
|
|
129
|
-
Host plugins can register OCR, image-understanding, translation and embedding engines. The settings catalog updates on registration and removal; unloaded selections remain visible. Requests capture their engine/configuration, and unloading cancels that engine's active work. Each service retains its typed API; the catalog is not another execution registry. Only retrieval's explicit `auto` mode may report a lexical fallback. See [engine extensions](docs/ENGINE_EXTENSIONS.md) for contributor contracts. Automatic character-map repair remains a separate local-only path, never routed to a selected remote OCR engine.
|
|
130
|
-
|
|
131
|
-
The `pdf_search` and `pdf_find_related` tools start with a document, query and options, then return `searchId` and `hasMore`. To continue, the model passes only that ID to the same tool; Host retains the query and progress. Related results are ranked only after the requested scope is fully indexed. See the [tool contracts](docs/AI_READER_TOOLS.md) for coverage and search-session lifetime rules.
|
|
132
|
-
|
|
133
|
-
Bookmark edits use the shared outline domain and the existing pdf-lib save transaction. The agent can obtain exact `outlineId` values with `pdf_bookmarks`, then submit an atomic draft edit through `pdf_outline_edit`. New outline-edit interactions still need real Desktop and external-reader acceptance testing.
|
|
134
|
-
|
|
135
|
-
See the [architecture](docs/ARCHITECTURE_V2.md), [AI reader tools](docs/AI_READER_TOOLS.md), and [specification](SPEC.md) for contracts and implementation status. Some advanced tool interactions still need real Desktop and model-based acceptance testing.
|
|
136
|
-
|
|
137
|
-
Form inspection returns a numbered page image and the writable controls on that page, including their types, options and positions. Each small translucent F label sits inside its control. The calling model matches those controls to the printed content; inspection does not make an additional model or OCR request.
|
|
79
|
+
The Reader and agent tools share Host business logic and a working copy within the same resource session; edits synchronize both ways. A native PDFium worker handles rendering and text extraction. See the [architecture](docs/ARCHITECTURE_V2.md).
|
|
138
80
|
|
|
139
81
|
## Development
|
|
140
82
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
Ordinary AcroForm fields can be filled in the Reader or by the model. Inspection puts small IDs inside controls on a base-page image without widget appearances or annotations; current draft values are available through `includeValues:true` metadata, not the deliberately blank-looking image. Each fill atomically updates one page of the shared undoable draft using a single inspection ID and label/value entries; the Host restores the page. Inspect multiple pages together, then fill independent pages in separate calls. Shared-field and declared-dependency conflicts require reinspection. The model can supply explicit conditional and exclusive-choice checks; the Host validates those supplied rules and field types without inferring business meaning. Inspection needs a vision-capable model; overwriting the PDF still requires approval. PDF scripts and actions are not executed; signed PDFs remain read-only and signatures are not verified. XFA and encrypted PDFs are not supported. Text search does not automatically index scanned pages, and a background `pdf_open` tool call does not open a Reader tab. See [SPEC.md](SPEC.md) for the remaining limits.
|
|
83
|
+
```sh
|
|
84
|
+
npm ci
|
|
85
|
+
npm run native:build
|
|
86
|
+
npm run build
|
|
87
|
+
```
|
|
148
88
|
|
|
149
|
-
|
|
89
|
+
Checks and tests: `npm run check`, `npm run test:web`, `npm run test:coverage:project`. See also [retrieval configuration and benchmarks](docs/RETRIEVAL_EXPERIMENT.md) and [packaging and releases](docs/RELEASING.md).
|
|
150
90
|
|
|
151
91
|
## License
|
|
152
92
|
|
|
153
|
-
[MIT](LICENSE).
|
|
93
|
+
[MIT](LICENSE). Published packages include the third-party licenses for their native components and dependencies.
|
package/README.zh.md
CHANGED
|
@@ -2,152 +2,92 @@
|
|
|
2
2
|
|
|
3
3
|
[English](README.md) | 中文
|
|
4
4
|
|
|
5
|
-
在 [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness)
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
##
|
|
10
|
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
|
|
18
|
-
-
|
|
19
|
-
|
|
20
|
-
-
|
|
21
|
-
- **扩展 AI 引擎。** 通过插件接口注册 OCR、图像理解、翻译和 embedding 实现,在 PDF 设置中选择可用引擎。
|
|
22
|
-
- **按含义寻找原文(实验功能)。** 结合关键词与本地 embedding,检索同义表达和跨语言段落。结果保留原文引用,索引尚未完成及图片页未覆盖都会明确报告;embedding 默认关闭。
|
|
23
|
-
|
|
24
|
-
## 提供给模型的工具
|
|
25
|
-
|
|
26
|
-
插件提供以下工具。图像与 OCR 的可用性取决于当前模型及所选后端,导航要求已有可见的阅读器。参数与限制详见[工具契约](docs/AI_READER_TOOLS.md)。
|
|
27
|
-
|
|
28
|
-
- `pdf_current`:获取当前会话中可见的 PDF 及页码提示。
|
|
29
|
-
- `pdf_open`:在后台打开 PDF,取得共享文档引用。
|
|
30
|
-
- `pdf_close`:释放模型持有的文档引用,阅读器标签保留各自的引用。
|
|
31
|
-
- `pdf_status`:查询修订、未保存修改、冲突及可用能力。
|
|
32
|
-
- `pdf_read_page`:读取指定页面的一段文字。
|
|
33
|
-
- `pdf_search`:搜索精确文本,返回原文引用。
|
|
34
|
-
- `pdf_find_related`:查找与问题或概念相关的段落,返回原文引用。
|
|
35
|
-
- `pdf_locate`:定位一段引文在原文中的范围。
|
|
36
|
-
- `pdf_context`:读取指定位置、引文或引用的周边上下文。
|
|
37
|
-
- `pdf_render_page`:获取页图,或由配置的图像理解后端返回文字结果。
|
|
38
|
-
- `pdf_ocr_page`:使用所选 OCR 后端识别整页文字。
|
|
39
|
-
- `pdf_image_context`:重新验证并取回之前记录的图像或 OCR 证据。
|
|
40
|
-
- `pdf_form_inspect_page`:返回填写框内带编号的页图,以及控件类型与选项。
|
|
41
|
-
- `pdf_fill_form`:依据检查结果,原子填写单页的共享草稿。
|
|
42
|
-
- `pdf_page_annotations`:读取指定页的标注、评论及精确 ID。
|
|
43
|
-
- `pdf_annotate`:新增高亮、下划线、删除线或便签,支持跨页原文范围。
|
|
44
|
-
- `pdf_annotation_update`:修改文字标记的颜色,或标注、便签和评论回复的文本。
|
|
45
|
-
- `pdf_annotation_delete`:按 ID 删除可编辑标注或评论回复。
|
|
46
|
-
- `pdf_bookmarks`:读取 PDF 内置书签树及 ID。
|
|
47
|
-
- `pdf_outline_edit`:新增、改名、删除、排序或调整内置书签层级。
|
|
48
|
-
- `pdf_navigate`:在可见阅读器中跳转到已验证的段落或页面,并保留回退历史。
|
|
49
|
-
- `pdf_save`:请求用户批准后,将当前草稿保存到原 PDF。
|
|
50
|
-
- `ocr_recognize`:识别当前会话的图像句柄,由 bundle 内的 OCR 子插件提供。
|
|
51
|
-
|
|
52
|
-
## 功能预览
|
|
53
|
-
|
|
54
|
-
模型可以直接在 PDF 草稿中高亮原文并添加批注:
|
|
55
|
-
|
|
56
|
-

|
|
57
|
-
|
|
58
|
-
连续跳转后,可以从回退历史中直接选择之前的阅读位置:
|
|
59
|
-
|
|
60
|
-

|
|
61
|
-
|
|
62
|
-
另见[书签与目录](docs/screenshots/02-bookmarks-and-outline.png)、[便签与标注](docs/screenshots/03-notes-and-annotations.png)。
|
|
5
|
+
在 [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) 中一边对话,一边阅读 PDF。让模型查找相关原文、添加标注、跳转定位,再回到之前的阅读位置。
|
|
6
|
+
|
|
7
|
+
我常用 PDF 读论文和书。常用阅读器缺少多级回退,带 AI 解读和翻译的产品又常需额外订阅,于是借助 DSH 写了这个插件。
|
|
8
|
+
|
|
9
|
+
## 功能
|
|
10
|
+
|
|
11
|
+
- **阅读与导航**:连续滚动、缩放、缩略图、文字搜索,以及可选择历史位置的多级回退。
|
|
12
|
+
- **标注与书签**:高亮、下划线、删除线、批注、可拖动和调整尺寸的便签;编辑 PDF 内置书签及其层级。
|
|
13
|
+
- **翻译与解释**:单词释义、音标和例句;短语与句子翻译;收集多段文字或图像区域,分别提问后发送给当前会话。
|
|
14
|
+
- **模型操作**:读页、检索、标注、编辑书签和填写已有 AcroForm 表单,与用户共用草稿。
|
|
15
|
+
- **保存与恢复**:撤销/重做、草稿恢复、保存/另存为和源文件冲突检测。
|
|
16
|
+
- **OCR 与检索**:区域截图、文字识别,以及基于自配 embedding 模型的语义搜索(实验功能)。索引可加入扫描页文字和图像描述。
|
|
17
|
+
|
|
18
|
+

|
|
19
|
+
|
|
20
|
+

|
|
63
21
|
|
|
64
22
|
## 安装
|
|
65
23
|
|
|
66
|
-
已验证 DSH `0.2.1-rc.
|
|
24
|
+
已验证 DSH `0.2.1-rc.5`,其他支持版本见 [package.json](package.json)。
|
|
67
25
|
|
|
68
|
-
|
|
26
|
+
**GUI**:打开 **插件 → 添加插件**,输入 `@dylanl1/dsh-plugin-pdf`,安装后点击 **立即启用**。
|
|
69
27
|
|
|
70
|
-
|
|
28
|
+
**CLI**:将 `<profile>` 替换为所用 profile:
|
|
71
29
|
|
|
72
30
|
```sh
|
|
73
31
|
dsh plugin --profile <profile> add @dylanl1/dsh-plugin-pdf
|
|
74
32
|
```
|
|
75
33
|
|
|
76
|
-
Desktop
|
|
77
|
-
|
|
78
|
-
如果此前安装过 `@local/dsh-pdf`,切换前先把未保存修改写入 PDF,并备份旧插件存储。启用新包前停用旧 bundle,不要同时启用两者。即使 `pdf-*` patch 行 ID 保持不变,旧包的设置、草稿和阅读位置仍需单独核对迁移情况。
|
|
34
|
+
Desktop 用户需通过应用菜单的 **管理 dsh 命令…** 安装自带 CLI。先启动一次 Desktop,再完全退出,以 `--profile desktop` 安装后重新打开;单独通过 npm 安装的 CLI 不能管理桌面版插件。
|
|
79
35
|
|
|
80
|
-
|
|
36
|
+
安装包自动匹配原生组件,无需本地编译。支持 macOS(Apple Silicon/Intel)、Windows x64 和 Linux glibc(x64/arm64)。
|
|
81
37
|
|
|
82
|
-
|
|
38
|
+
安装后从 DSH 文件栏打开本地 PDF。AI 功能使用已配置的模型或扩展引擎;语义检索需单独配置 embedding 服务,默认关闭。文档的生效策略启用后,打开时会后台建立索引;OCR 与图像描述可分别开启,可能调用远程服务并产生费用。更多限制见 [SPEC](SPEC.md)。
|
|
83
39
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
```mermaid
|
|
87
|
-
flowchart TB
|
|
88
|
-
subgraph Client["Client · 展示与交互"]
|
|
89
|
-
Reader["PDF 阅读器"]
|
|
90
|
-
Settings["PDF 设置<br/>动态引擎列表与配置"]
|
|
91
|
-
end
|
|
92
|
-
subgraph Host["Host · 业务与状态权威"]
|
|
93
|
-
RPC["鉴权 RPC"]
|
|
94
|
-
Tools["模型工具"]
|
|
95
|
-
Features["PDF 与 AI 功能用例"]
|
|
96
|
-
Copy["共享工作副本<br/>草稿、修订、撤销、保存"]
|
|
97
|
-
AI["类型化服务<br/>OCR · 图像理解 · 翻译 · Embedding"]
|
|
98
|
-
Retrieval["文字检索<br/>BM25 + 向量 · 可重建缓存"]
|
|
99
|
-
Evidence["既有证据引用<br/>标注与跳转前重新验证"]
|
|
100
|
-
Catalog["只读目录聚合<br/>引擎变化通知"]
|
|
101
|
-
Config["各功能的引擎绑定<br/>配置与凭据引用"]
|
|
102
|
-
Backends["默认与第三方引擎<br/>同一注册接口 · Fiber 生命周期"]
|
|
103
|
-
Native["PDF 适配层<br/>pdf-lib · 原生 PDFium"]
|
|
104
|
-
Files["文件与草稿存储"]
|
|
105
|
-
RPC --> Features
|
|
106
|
-
Tools --> Features
|
|
107
|
-
Features --> Copy
|
|
108
|
-
Features --> AI
|
|
109
|
-
Features --> Retrieval
|
|
110
|
-
Retrieval --> AI
|
|
111
|
-
Retrieval --> Evidence
|
|
112
|
-
Evidence --> Copy
|
|
113
|
-
Copy --> Native
|
|
114
|
-
Copy --> Files
|
|
115
|
-
AI --> Backends
|
|
116
|
-
AI --> Config
|
|
117
|
-
AI -. "描述与目录变化" .-> Catalog
|
|
118
|
-
Catalog --> RPC
|
|
119
|
-
RPC --> Config
|
|
120
|
-
end
|
|
121
|
-
Reader <--> RPC
|
|
122
|
-
Settings <--> RPC
|
|
123
|
-
Model["DSH 会话模型"] <--> Tools
|
|
124
|
-
Backends --> Dependencies["DSH LLM · 本地进程 · 远程 API"]
|
|
125
|
-
```
|
|
40
|
+
设置自动保存。引擎统一在 **PDF 设置**中选择;每份 PDF 在**搜索 → 当前 PDF 索引**中独立开启文字识别索引和视觉描述索引。由你决定何时更新,已有结果会尽量复用,关闭语义检索则立即生效。
|
|
126
41
|
|
|
127
|
-
|
|
42
|
+
## 模型工具
|
|
128
43
|
|
|
129
|
-
|
|
44
|
+
- 文档:`pdf_current`、`pdf_open`、`pdf_close`、`pdf_info`、`pdf_status`。
|
|
45
|
+
- 阅读:`pdf_page_read`、`pdf_page_render`。
|
|
46
|
+
- 检索与证据:`pdf_keyword_search`、`pdf_semantic_search`、`pdf_evidence_read`。
|
|
47
|
+
- 标注:`pdf_annotation_list`、`pdf_annotation_create`、`pdf_annotation_update`、`pdf_annotation_delete`。
|
|
48
|
+
- 书签:`pdf_bookmark_list`、`pdf_bookmark_edit`。
|
|
49
|
+
- 表单:`pdf_form_inspect`、`pdf_form_fill`。
|
|
50
|
+
- 导航与保存:`pdf_page_jump`、`pdf_save`。
|
|
51
|
+
- 图像:`ocr_recognize`、`image_understand`。
|
|
130
52
|
|
|
131
|
-
`
|
|
53
|
+
`pdf_open` 只在后台打开文档;跳转需要阅读器已显示。模型编辑直接写入草稿,覆盖保存原文件仍需用户确认。参数和示例见[工具文档](docs/AI_READER_TOOLS.md)。
|
|
132
54
|
|
|
133
|
-
|
|
55
|
+
## 扩展引擎
|
|
134
56
|
|
|
135
|
-
|
|
57
|
+
OCR、图像理解、翻译和 embedding 均支持第三方实现。将扩展写成独立的 DSH Host 插件,在 `peerDependencies` 中声明本包,通过公开 SDK 向对应服务注册后端,并安装到相同 Host profile,即可在 PDF 设置中选择。
|
|
136
58
|
|
|
137
|
-
|
|
59
|
+
参考 [`examples/`](examples/README.md) 中的 [`http-engines`](examples/http-engines):一个提供 HTTP OCR 和图像理解后端的独立插件。接口与生命周期约定见[引擎扩展](docs/ENGINE_EXTENSIONS.md)。
|
|
138
60
|
|
|
139
|
-
##
|
|
61
|
+
## 架构
|
|
140
62
|
|
|
141
|
-
|
|
63
|
+
```mermaid
|
|
64
|
+
flowchart TB
|
|
65
|
+
Reader["Client · PDF 阅读器"] <--> RPC
|
|
66
|
+
Model["DSH 会话模型"] -- "工具调用" --> Features
|
|
67
|
+
subgraph Host
|
|
68
|
+
RPC["鉴权 RPC"] --> Features["PDF 领域能力"]
|
|
69
|
+
Features --> Copy["共享工作副本 · 草稿与撤销"]
|
|
70
|
+
Features --> Search["检索与证据"]
|
|
71
|
+
Features --> Engines["可扩展 AI 引擎"]
|
|
72
|
+
Search --> Copy
|
|
73
|
+
Search --> Engines
|
|
74
|
+
Copy --> PDF["PDFium · pdf-lib"]
|
|
75
|
+
Copy --> Storage["文件与草稿存储"]
|
|
76
|
+
end
|
|
77
|
+
```
|
|
142
78
|
|
|
143
|
-
|
|
79
|
+
阅读器与模型工具共用 Host 业务能力和同一资源会话内的工作副本,修改双向同步。原生 PDFium worker 负责渲染和文字提取。详见[架构文档](docs/ARCHITECTURE_V2.md)。
|
|
144
80
|
|
|
145
|
-
|
|
81
|
+
## 开发
|
|
146
82
|
|
|
147
|
-
|
|
83
|
+
```sh
|
|
84
|
+
npm ci
|
|
85
|
+
npm run native:build
|
|
86
|
+
npm run build
|
|
87
|
+
```
|
|
148
88
|
|
|
149
|
-
|
|
89
|
+
检查与测试:`npm run check`、`npm run test:web`、`npm run test:coverage:project`。另见[语义检索配置与基准测试](docs/RETRIEVAL_EXPERIMENT.md)、[打包与发布](docs/RELEASING.md)。
|
|
150
90
|
|
|
151
91
|
## 许可证
|
|
152
92
|
|
|
153
|
-
[MIT](LICENSE)
|
|
93
|
+
[MIT](LICENSE)。发布包附带所用原生组件及依赖的第三方许可证。
|