dsh-document-reader 0.0.0-stage → 1.0.2
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 +21 -0
- package/README.md +84 -2
- package/client.js +3652 -0
- package/client.pdfjs.js +21278 -0
- package/client.vendor.js +41 -0
- package/cordis.patch.yml +10 -0
- package/icon.svg +11 -0
- package/index.js +1418 -0
- package/locale/en.json +41 -0
- package/locale/zh.json +41 -0
- package/package.json +50 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 wangjianghu
|
|
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.md
CHANGED
|
@@ -1,3 +1,85 @@
|
|
|
1
|
-
#
|
|
1
|
+
# dsh-document-reader
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A dedicated document & image reader panel for [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) (DSH). Open local files in a real reader surface instead of chat attachments — and let the assistant read along.
|
|
4
|
+
|
|
5
|
+
[English](#features) · [中文说明](#中文说明)
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **Formats**: PDF (continuous scroll, text-layer search, zoom/rotate/fit), DOCX (headers/footers/footnotes, virtual pages), EPUB (chapter rendering with scoped CSS, whole-book search), HTML (sanitized), Markdown, plain text (multi-encoding: UTF-8/GBK/Big5/Shift-JIS), images (zoom/rotate/fit-window), and Office decks & spreadsheets (`.pptx .xlsx .ppt .xls .doc` — converted to PDF through the LibreOffice engine bundled with DSH, cached by content hash).
|
|
10
|
+
- **Reading essentials**: outline navigation, in-document search with match highlighting, structured scroll-position restore per file, rename in place, recent files, dark/light theme tokens, English / Simplified / Traditional Chinese UI.
|
|
11
|
+
- **Editing**: Markdown and plain-text edit mode (Ctrl/Cmd+S), unsaved-draft recovery, conflict detection when the file changes on disk, external-change auto-reload.
|
|
12
|
+
- **Selection actions**: select text anywhere → floating bar for *quote to chat*, *copy*, *search in document*, *translate*.
|
|
13
|
+
- **Translation** (all three engines built in — pick one in ⚙ Settings): Bing (anonymous, via the translator service shipped with DSH), Google gtx (anonymous, custom endpoint supported), or **your configured DSH model** via `ctx.llm` (e.g. GLM). Result dialog shows source text + translation, retry, copy.
|
|
14
|
+
- **AI integration**: a `doc_reader` agent tool (read / outline / search any supported format), active-document outline injected into chat context (toggleable), a `/doc` slash command for fuzzy-opening recent documents, tool-result cards in chat with "open in reader".
|
|
15
|
+
- **Polish**: copy-path toolbar button, status-bar feedback, instant dark tooltips, global shortcut Cmd/Ctrl+Shift+O, per-view settings (font size, line height, PDF text layer, DOCX pagination, UI language).
|
|
16
|
+
|
|
17
|
+
Security posture: extension whitelist, symlink rejection, atomic writes, loopback + cross-site guards on all Host routes, sanitized HTML/EPUB rendering, size caps and timeouts everywhere.
|
|
18
|
+
|
|
19
|
+
## Install
|
|
20
|
+
|
|
21
|
+
Requires DSH with the plugin system (dsh ≥ 0.2.0).
|
|
22
|
+
|
|
23
|
+
**A. From a plugin market (Discover)** — add an index source that lists this package (any index that mirrors `dsh-plugin-catalog`), then search "document reader" and install `dsh-document-reader`.
|
|
24
|
+
|
|
25
|
+
**B. Direct install from npm**:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
dsh plugin --profile desktop add dsh-document-reader
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
**C. Direct install from GitHub**:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
dsh plugin --profile desktop add "git+https://github.com/wangjianghu/dsh-document-reader.git"
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Open the reader from the left sidebar (book icon) and paste an absolute local file path, or use the file browser.
|
|
38
|
+
|
|
39
|
+
## 中文说明
|
|
40
|
+
|
|
41
|
+
DSH 文档阅读器:在独立面板阅读本地 PDF、DOCX、EPUB、HTML、Markdown、文本、图片与 Office 演示稿/表格(经 DSH 自带 LibreOffice 引擎转 PDF,按内容缓存)。支持大纲导航、文内搜索、编辑保存、重命名、最近文件、滚动位置记忆;选中文字可引用到对话、复制、文内搜索、翻译——三引擎(必应 / Google / DSH 模型)全部内置,⚙ 设置中切换;并提供 `doc_reader` 对话工具、当前文档上下文注入与 `/doc` 命令,让助手直接读你的文档。
|
|
42
|
+
|
|
43
|
+
安装:插件 → 发现,添加收录本插件的索引源后搜索安装;或 `dsh plugin --profile desktop add dsh-document-reader`。打开方式:左侧栏书本图标,粘贴本地文件绝对路径回车。
|
|
44
|
+
|
|
45
|
+
## Repository layout
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
├── index.js # Host half: HTTP routes, extraction engine, tool/context/command services
|
|
49
|
+
├── client.js # Client half: reader panel, all views, selection bar, translate overlay
|
|
50
|
+
├── client.vendor.js # Lazy chunk: markdown-it + jszip + docx-preview
|
|
51
|
+
├── client.pdfjs.js # Lazy chunk: pdfjs-dist + worker
|
|
52
|
+
├── cordis.patch.yml # Loader rows (reader + translator service)
|
|
53
|
+
├── locale/ # Plugin-manager display metadata (en / zh)
|
|
54
|
+
├── tools/ # Regression suites (host / client / smoke) + vendor build
|
|
55
|
+
└── index.json # DSH plugin-market index (format 1), self-hosted
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Development
|
|
59
|
+
|
|
60
|
+
The reader is dual-half (Host services + Client slots). Iterate by linking the package directory:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
dsh plugin --profile desktop add "link:$(pwd)"
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Host-half changes need a plugin reload; client-half changes a page refresh.
|
|
67
|
+
|
|
68
|
+
### Tests · 测试
|
|
69
|
+
|
|
70
|
+
Three regression suites live in `tools/` (run in CI):
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
node tools/host-test.mjs # Host half
|
|
74
|
+
mkdir -p /tmp/vendor && cd /tmp/vendor && npm init -y && npm i jsdom@24 react@18 react-dom@18 jszip
|
|
75
|
+
node "$OLDPWD/tools/client-test.mjs" # client half, needs the vendor env above
|
|
76
|
+
node "$OLDPWD/tools/smoke-test.mjs" # end-to-end panel smoke
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
`tools/build-vendor.mjs` rebuilds the lazy client chunks (`client.vendor.js` / `client.pdfjs.js`).
|
|
80
|
+
|
|
81
|
+
## License & attribution
|
|
82
|
+
|
|
83
|
+
MIT — see [LICENSE](LICENSE). Bundled third-party libraries are listed in [THIRD-PARTY-NOTICES.md](THIRD-PARTY-NOTICES.md).
|
|
84
|
+
|
|
85
|
+
This project started as a reimplementation of the feature set of the VSCode extension `vscode-doc-reader` (publisher *DocReader*). No original code is included — every line in this repository was written from scratch for DSH (verified: zero verbatim overlap with the original distribution).
|