@jaxzhou/dsh-file-explorer 0.1.4 → 0.1.6
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/README.md +72 -17
- package/README.zh.md +58 -15
- package/lib/client.js +3920 -1183
- package/lib/client.js.map +1 -7
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -10,8 +10,9 @@ English | [中文](README.zh.md)
|
|
|
10
10
|
|
|
11
11
|
A **Files** tab for [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness),
|
|
12
12
|
beside **Chat** and **Trajectory**: the session workspace as a tree, and a preview
|
|
13
|
-
that adapts to what the file is — rendered Markdown, a
|
|
14
|
-
source, an image,
|
|
13
|
+
that adapts to what the file is — rendered Markdown with its diagrams, a page of
|
|
14
|
+
HTML, a JSON tree, highlighted source, an image, a PDF, or an unpacked Word, Excel
|
|
15
|
+
or PowerPoint document. Read-only, no configuration, nothing stored.
|
|
15
16
|
|
|
16
17
|
```sh
|
|
17
18
|
dsh plugin --profile web add @jaxzhou/dsh-file-explorer
|
|
@@ -21,13 +22,17 @@ dsh --profile web
|
|
|
21
22
|
## Demo
|
|
22
23
|
|
|
23
24
|
[](media/demo.mp4)
|
|
25
|
+
rendered Markdown document on the right](media/demo.gif)](media/demo.mp4)
|
|
26
26
|
|
|
27
27
|
*15 seconds — click for the full-quality MP4.* A primary-school maths workspace: a
|
|
28
28
|
lesson document rendered with its tables, the **Source** toggle showing the
|
|
29
|
-
Markdown behind it, a second document open beside it in its own tab, and
|
|
30
|
-
|
|
29
|
+
Markdown behind it, a second document open beside it in its own tab, and an export
|
|
30
|
+
of it to PDF.
|
|
31
|
+
|
|
32
|
+
**The recording is an older build than the list below.** It predates Mermaid
|
|
33
|
+
diagrams, the PDF and Office previews and the pane's **Download** control, and it
|
|
34
|
+
still shows an export handing the page to the browser's print dialog — which no
|
|
35
|
+
export does now.
|
|
31
36
|
|
|
32
37
|
## What you get
|
|
33
38
|
|
|
@@ -44,20 +49,41 @@ The right pane picks each tab's body from the file:
|
|
|
44
49
|
|
|
45
50
|
| Category | Preview |
|
|
46
51
|
|---|---|
|
|
47
|
-
| **Markdown** | Rendered GFM — headings, tables, task lists, quotes, math, footnotes, images referenced beside the file, highlighted code fences — with a **Source** toggle
|
|
48
|
-
| **HTML** | Drawn as a page in a sandboxed frame: the file's own CSS applies, and its scripts run in an opaque origin that cannot reach this application. With a **Source** toggle
|
|
52
|
+
| **Markdown** | Rendered GFM — headings, tables, task lists, quotes, math, footnotes, images referenced beside the file, highlighted code fences, and **Mermaid diagrams** — with a **Source** toggle and an **Export** menu |
|
|
53
|
+
| **HTML** | Drawn as a page in a sandboxed frame: the file's own CSS applies, and its scripts run in an opaque origin that cannot reach this application. With a **Source** toggle and an **Export** menu |
|
|
49
54
|
| **JSON** | A collapsible tree with per-value copy, and the same toggle |
|
|
50
55
|
| **Source code** | Syntax highlighting, line numbers, and a copy button for 24 grammars: TypeScript/JavaScript, shell, Python, Ruby, Go, Rust, Java, C, C++, C#, Kotlin, Swift, PHP, YAML, TOML, INI, HTML, CSS, SCSS, Less, SQL, XML, Lua, MDX |
|
|
51
56
|
| **Images** | PNG, JPEG, GIF, WebP, AVIF, BMP, ICO and SVG, drawn to the pane. An SVG goes through `<img>`, so its scripts never run |
|
|
52
|
-
| **
|
|
57
|
+
| **PDF** | Drawn by the browser's own PDF reader, from the file's bytes — so its text is real text |
|
|
58
|
+
| **Word, Excel, PowerPoint** | `.docx`, `.xlsx` and `.pptx` unpacked in the page: a document's headings, lists, tables, pictures and code; a workbook's sheets as a grid, with the dates it stores as numbers shown as dates; a deck's slides as an outline of their text and pictures |
|
|
59
|
+
| **Anything else** | Numbered plain text — an unmapped suffix (`.vue`, `.proto`, `.txt`) stays plain rather than guessing a wrong grammar. The legacy binary Office formats (`.doc`, `.xls`, `.ppt`) are not previewed: the pane says so and offers the download |
|
|
60
|
+
|
|
61
|
+
A **Mermaid** code fence (` ```mermaid `) is a diagram, not source, so the pane
|
|
62
|
+
draws it: flowcharts, sequence diagrams, state, class, ER, gantt, pie and the
|
|
63
|
+
rest of what Mermaid 11 understands. The drawing is a picture everywhere it
|
|
64
|
+
appears — the preview, the PDF page, and the Word document all carry the same
|
|
65
|
+
image — so what you see is what exports. A diagram Mermaid cannot parse keeps its
|
|
66
|
+
source, with the failure named above it.
|
|
53
67
|
|
|
54
68
|
Text previews wrap at their spaces and keep every word whole; an image reads its
|
|
55
|
-
complete bytes.
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
69
|
+
complete bytes.
|
|
70
|
+
|
|
71
|
+
Every preview carries **Download** in the pane's toolbar, which saves the file
|
|
72
|
+
itself — not a conversion of it, which is why it is the one control that works for
|
|
73
|
+
every kind of file, including the ones this pane will not draw. Every text body
|
|
74
|
+
carries **Copy**, which copies the file's own text — a rendered Markdown document
|
|
75
|
+
copies its Markdown source.
|
|
76
|
+
|
|
77
|
+
A rendered Markdown or HTML document also carries **Export**, which **downloads a
|
|
78
|
+
file directly** — no print dialog — in either of two formats:
|
|
79
|
+
|
|
80
|
+
| Format | What it is |
|
|
81
|
+
|---|---|
|
|
82
|
+
| **PDF** | A picture of the page, laid out as A4 and sliced to fit. The text in it is not selectable. That is deliberate: a text-mode PDF of a Chinese document would need a CJK font embedded in the plugin, which is megabytes for a preview tool |
|
|
83
|
+
| **Word** (`.docx`) | A real Word document: headings, lists, tables, code and images, with the text still text — editable, searchable, and rendered with Word's own fonts. Chinese included |
|
|
84
|
+
|
|
85
|
+
A document's own local assets come with it: the images a Markdown file references
|
|
86
|
+
beside it, and the images and stylesheets an HTML file links to.
|
|
61
87
|
|
|
62
88
|
## Requirements
|
|
63
89
|
|
|
@@ -119,6 +145,11 @@ restart the profile.
|
|
|
119
145
|
state lives in memory and is discarded with the session.
|
|
120
146
|
- **Inert Host half.** The package's Node side registers no service, tool, prompt
|
|
121
147
|
section, or event.
|
|
148
|
+
- **Diagrams are drawn in the page.** Mermaid is bundled into the plugin and runs
|
|
149
|
+
locally; drawing a diagram fetches nothing from anywhere.
|
|
150
|
+
- **Office documents are unpacked in the page.** A `.docx`, `.xlsx` or `.pptx` is
|
|
151
|
+
read here, by this plugin's own reader; nothing about it leaves the browser. A
|
|
152
|
+
PDF is handed to the browser's reader as a local blob URL.
|
|
122
153
|
- **HTML runs sandboxed.** A previewed page's scripts execute in an opaque origin,
|
|
123
154
|
which cannot read this application's DOM, storage, or session; an exported page
|
|
124
155
|
is printed with its scripts removed. An SVG draws through `<img>`, so its scripts
|
|
@@ -147,8 +178,32 @@ restart the profile.
|
|
|
147
178
|
the second loads directly, and the third is not fetched.
|
|
148
179
|
- **HTML previews do not resolve relative assets.** A page drawn from a Blob
|
|
149
180
|
document has no base to resolve its own `style.css` or images against, so only
|
|
150
|
-
absolute URLs load there
|
|
151
|
-
|
|
181
|
+
absolute URLs load there. **An export does resolve them** — the file it writes is
|
|
182
|
+
read from a copy that has been made to stand alone — so a document can export
|
|
183
|
+
with pictures it does not show in the preview.
|
|
184
|
+
- **An exported PDF's text is a picture.** Nothing in it can be selected or
|
|
185
|
+
searched — a *previewed* PDF is the browser's own reader, where it can. Export
|
|
186
|
+
Word instead when the text has to stay text.
|
|
187
|
+
- **A Mermaid diagram is a picture too.** It is drawn once, to a PNG, for the
|
|
188
|
+
preview and for both exports — so its labels are not selectable, and it is
|
|
189
|
+
always drawn on white, because a PDF page and a Word document are white and a
|
|
190
|
+
diagram drawn for a dark pane would be invisible on them. Drawing supports the
|
|
191
|
+
diagram types Mermaid 11 carries; a malformed one keeps its source and names
|
|
192
|
+
the failure above it.
|
|
193
|
+
- **An Office preview is content, not layout.** A `.docx` shows its headings,
|
|
194
|
+
text, lists, tables and pictures; a `.xlsx` shows its cells' values; a `.pptx`
|
|
195
|
+
shows each slide's text and pictures. What is *not* there is everything that
|
|
196
|
+
needs a layout engine and the fonts the file names: colours and themes, column
|
|
197
|
+
widths, page breaks, headers and footers, charts, SmartArt, and animations.
|
|
198
|
+
Formulas show the value the file cached, not a recalculation.
|
|
199
|
+
- **Only the OOXML formats are read.** `.doc`, `.xls` and `.ppt` are the older
|
|
200
|
+
binary container, which this pane does not parse — it says so and offers the
|
|
201
|
+
download instead.
|
|
202
|
+
- **Preview and download are bounded by one complete-file read**, 32 MiB by
|
|
203
|
+
default in the shipped Web composition. A file above it reports the refusal
|
|
204
|
+
rather than arriving cut.
|
|
205
|
+
- **Long documents are cut at 60 PDF pages**, and an image past 8 MiB is left out;
|
|
206
|
+
both are stated here because a silent cut reads as a complete export.
|
|
152
207
|
|
|
153
208
|
## Contributing
|
|
154
209
|
|
package/README.zh.md
CHANGED
|
@@ -10,8 +10,9 @@
|
|
|
10
10
|
|
|
11
11
|
为 [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) 增加一个
|
|
12
12
|
**文件** 标签,与 **对话**、**轨迹** 并列:左侧是会话工作区的目录树,右侧的预览
|
|
13
|
-
会按文件本身决定形态 —— 渲染后的 Markdown
|
|
14
|
-
|
|
13
|
+
会按文件本身决定形态 —— 渲染后的 Markdown(含图表)、HTML 页面、JSON 树、语法
|
|
14
|
+
高亮源码、图片、PDF,以及解包后的 Word / Excel / PowerPoint 文档。只读、无需配置、
|
|
15
|
+
不落任何数据。
|
|
15
16
|
|
|
16
17
|
```sh
|
|
17
18
|
dsh plugin --profile web add @jaxzhou/dsh-file-explorer
|
|
@@ -20,12 +21,14 @@ dsh --profile web
|
|
|
20
21
|
|
|
21
22
|
## 演示
|
|
22
23
|
|
|
23
|
-
[](media/demo.mp4)
|
|
24
|
+
[](media/demo.mp4)
|
|
25
25
|
|
|
26
26
|
*15 秒录屏 —— 点击可打开完整画质的 MP4。* 一个小数学工作区:渲染后的讲义文档
|
|
27
27
|
(含表格)、切到 **源码** 看它背后的 Markdown、在旁边用另一个标签打开第二份文档,
|
|
28
|
-
|
|
28
|
+
最后把它导出为 PDF。
|
|
29
|
+
|
|
30
|
+
**录屏来自比下面更早的版本。** 它早于 Mermaid 图表、PDF 与 Office 预览以及工具栏
|
|
31
|
+
上的 **下载**,其中那次导出仍然把页面交给浏览器的打印对话框 —— 现在的导出都不会。
|
|
29
32
|
|
|
30
33
|
## 能做什么
|
|
31
34
|
|
|
@@ -39,18 +42,37 @@ dsh --profile web
|
|
|
39
42
|
|
|
40
43
|
| 类别 | 预览 |
|
|
41
44
|
|---|---|
|
|
42
|
-
| **Markdown** | 直接渲染为 GFM ——
|
|
43
|
-
| **HTML** | 在沙箱 iframe 中当作页面绘制:文件自己的 CSS 生效,其脚本运行在不透明源(opaque origin)里,无法触达本应用。带 **源码** 切换与
|
|
45
|
+
| **Markdown** | 直接渲染为 GFM —— 标题、表格、任务列表、引用、公式、脚注、引用文件旁的图片、高亮的代码围栏、**Mermaid 图表** —— 并带 **源码** 切换与 **导出** 菜单 |
|
|
46
|
+
| **HTML** | 在沙箱 iframe 中当作页面绘制:文件自己的 CSS 生效,其脚本运行在不透明源(opaque origin)里,无法触达本应用。带 **源码** 切换与 **导出** 菜单 |
|
|
44
47
|
| **JSON** | 可折叠树,每个值可单独复制,同样带 **源码** 切换 |
|
|
45
48
|
| **源码** | 24 种语法的语法高亮、行号与复制按钮:TypeScript/JavaScript、shell、Python、Ruby、Go、Rust、Java、C、C++、C#、Kotlin、Swift、PHP、YAML、TOML、INI、HTML、CSS、SCSS、Less、SQL、XML、Lua、MDX |
|
|
46
49
|
| **图片** | PNG、JPEG、GIF、WebP、AVIF、BMP、ICO、SVG,自动适配窗格。SVG 经 `<img>` 绘制,其中的脚本不会执行 |
|
|
47
|
-
|
|
|
50
|
+
| **PDF** | 交由浏览器自带的 PDF 阅读器绘制,用的是文件自身的字节 —— 因此其中的文字是真文字 |
|
|
51
|
+
| **Word / Excel / PowerPoint** | `.docx`、`.xlsx`、`.pptx` 在页面内解包:文档的标题、列表、表格、图片与代码;工作簿按工作表显示为网格,并以日期显示它按数字存储的日期;演示文稿按幻灯片显示其文字与图片的提纲 |
|
|
52
|
+
| **其它** | 带行号的纯文本 —— 未映射的后缀(`.vue`、`.proto`、`.txt`)保持纯文本,而不是猜测一个错误的高亮。旧版二进制 Office 格式(`.doc`、`.xls`、`.ppt`)不做预览:窗格会说明原因并提供下载 |
|
|
53
|
+
|
|
54
|
+
**Mermaid** 代码围栏(` ```mermaid `)是图表而不是源码,窗格会把它画出来:
|
|
55
|
+
流程图、时序图、状态图、类图、ER 图、甘特图、饼图,以及 Mermaid 11 支持的其它
|
|
56
|
+
类型。它在出现的每一处都是图像 —— 预览、PDF 页面、Word 文档携带的是同一张图 ——
|
|
57
|
+
所见即所得。Mermaid 无法解析的图表会保留源码,并在其上方说明失败原因。
|
|
58
|
+
|
|
59
|
+
文本预览在空格处折行、保持单词完整;图片读取完整字节。
|
|
60
|
+
|
|
61
|
+
每一种预览的窗格工具栏里都有 **下载**,保存的是文件本身而不是它的某种转换 ——
|
|
62
|
+
因此这是唯一对**所有**文件类型都可用的控件,包括本窗格不绘制的那些。每一种文本预览
|
|
63
|
+
还有 **复制**,复制的是文件自身的文本——渲染态的 Markdown 复制的是它的 Markdown
|
|
64
|
+
源码。
|
|
65
|
+
|
|
66
|
+
渲染态的 Markdown 与 HTML 还带 **导出** 菜单,**直接下载文件**(不走打印对话框),
|
|
67
|
+
两种格式:
|
|
68
|
+
|
|
69
|
+
| 格式 | 说明 |
|
|
70
|
+
|---|---|
|
|
71
|
+
| **PDF** | 页面的图像:按 A4 排版并分页切分。其中的文字**不可选中**。这是刻意的:中文文档若用文本模式生成 PDF,就必须在插件里内嵌 CJK 字体——对一个预览工具来说是好几 MB |
|
|
72
|
+
| **Word**(`.docx`) | 真正的 Word 文档:标题、列表、表格、代码与图片都在,文字仍是文字——可编辑、可搜索,中文交给 Word 自己的字体渲染 |
|
|
48
73
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
Markdown 源码。渲染态的 Markdown 与 HTML 还带 **导出 PDF**:它把页面交给浏览器的
|
|
52
|
-
打印对话框,那里每个浏览器都提供「另存为 PDF」,而排版由浏览器自己的引擎完成
|
|
53
|
-
——文字仍是文字,不像基于 canvas 的 PDF 库那样把整页栅格化。
|
|
74
|
+
文档自带的本地资源会一起带上:Markdown 文件旁边引用的图片,以及 HTML 文件链接的
|
|
75
|
+
图片与样式表。
|
|
54
76
|
|
|
55
77
|
## 环境要求
|
|
56
78
|
|
|
@@ -106,6 +128,10 @@ profile。
|
|
|
106
128
|
Host 的文件系统决定。插件自身不持有文件权限、不做路径解析、不接触凭据。
|
|
107
129
|
- **不落数据**:不写磁盘、不写会话日志;视图状态保存在内存中,随会话一起释放。
|
|
108
130
|
- **Host 半边是空实现**:包的 Node 侧不注册任何服务、工具、提示词片段或事件。
|
|
131
|
+
- **图表在页面内绘制**:Mermaid 打包在插件里、在本地运行;绘制图表不会向任何地方
|
|
132
|
+
发起请求。
|
|
133
|
+
- **Office 文档在页面内解包**:`.docx`、`.xlsx`、`.pptx` 由本插件自己的读取器在本地
|
|
134
|
+
解析,内容不会离开浏览器。PDF 则以本地 blob URL 交给浏览器自带的阅读器。
|
|
109
135
|
- **HTML 在沙箱中运行**:预览页面的脚本执行于不透明源,无法读取本应用的 DOM、
|
|
110
136
|
存储或会话;导出时会先剥除脚本再打印。SVG 经 `<img>` 绘制,脚本完全不执行。
|
|
111
137
|
|
|
@@ -129,8 +155,25 @@ profile。
|
|
|
129
155
|
URL、绝对路径则交给渲染器自己的规则:第一个保持原样,第二个直接加载,第三个
|
|
130
156
|
不会去读。
|
|
131
157
|
- **HTML 预览不解析相对资源**:由 Blob 文档绘制出的页面没有可用来解析自身
|
|
132
|
-
`style.css` 或图片的 base
|
|
133
|
-
|
|
158
|
+
`style.css` 或图片的 base,所以预览里只有绝对 URL 能加载。**导出时会解析**——
|
|
159
|
+
写出的文件来自一份被补齐成自包含的副本——所以可能有「预览里看不到图,导出里
|
|
160
|
+
有图」的情况。
|
|
161
|
+
- **导出的 PDF 里文字是图像**,无法选中或搜索(**预览** PDF 用的是浏览器自带的
|
|
162
|
+
阅读器,文字可选)。需要文字可编辑时请导出 Word。
|
|
163
|
+
- **Mermaid 图表同样是图像**:它只绘制一次(PNG),供预览与两种导出共用 —— 因此
|
|
164
|
+
其中的标签不可选中,且始终以白底绘制:PDF 页面与 Word 文档都是白底,为深色窗格
|
|
165
|
+
绘制的图在它们上面会看不见。绘制范围是 Mermaid 11 支持的图表类型;语法错误的
|
|
166
|
+
图表会保留源码,并在上方说明失败原因。
|
|
167
|
+
- **Office 预览是内容,不是排版**:`.docx` 显示标题、正文、列表、表格与图片;
|
|
168
|
+
`.xlsx` 显示单元格的值;`.pptx` 显示每页的文字与图片。**没有**的是所有需要排版
|
|
169
|
+
引擎和文件所指定字体的东西:颜色与主题、列宽、分页、页眉页脚、图表、SmartArt、
|
|
170
|
+
动画。公式显示文件缓存的值,不做重算。
|
|
171
|
+
- **只读取 OOXML 格式**:`.doc`、`.xls`、`.ppt` 是更早的二进制容器,本窗格不解析
|
|
172
|
+
—— 会说明这一点并提供下载。
|
|
173
|
+
- **预览与下载都受同一次「完整读取」上限约束**:官方 Web 组合默认 32 MiB。超过上限
|
|
174
|
+
的文件会报告被拒绝,而不是被截断后送来。
|
|
175
|
+
- **超长文档会在 60 页 PDF 处截断**,单张超过 8 MiB 的图片会被跳过;写在这里是因为
|
|
176
|
+
静默截断会被误认为完整导出。
|
|
134
177
|
|
|
135
178
|
## 参与开发
|
|
136
179
|
|