dsh-plugin-office-markdown 1.2.1

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 dsh-plugin-office-markdown contributors
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.en.md ADDED
@@ -0,0 +1,156 @@
1
+ <h1 align="center">dsh-plugin-office-markdown</h1>
2
+
3
+ <p align="center">
4
+ Convert Office / PDF files to Markdown before DeepSeek Harness reads them —<br>
5
+ what enters the model context is a file path, not the raw contents of the document.
6
+ </p>
7
+
8
+ <p align="center">
9
+ <a href="README.md">中文</a> | <a href="README.en.md">English</a>
10
+ </p>
11
+
12
+ <p align="center">
13
+ <a href="https://github.com/Z8906/dsh-plugin-office-markdown/releases"><img alt="release" src="https://img.shields.io/github/v/release/Z8906/dsh-plugin-office-markdown?style=flat-square&label=release"></a>
14
+ <img alt="license" src="https://img.shields.io/badge/license-MIT-blue?style=flat-square">
15
+ <img alt="node" src="https://img.shields.io/badge/node-%E2%89%A518-brightgreen?style=flat-square">
16
+ <img alt="npm dependencies" src="https://img.shields.io/badge/npm%20deps-0-brightgreen?style=flat-square">
17
+ </p>
18
+
19
+ <p align="center">
20
+ <a href="#install">Install</a> |
21
+ <a href="#usage">Usage</a> |
22
+ <a href="#converters">Converters</a> |
23
+ <a href="#documentation">Docs</a> |
24
+ <a href="CHANGELOG.md">Changelog</a>
25
+ </p>
26
+
27
+ ---
28
+
29
+ Conversion happens **locally**: no network (except an optional first MarkItDown download), the source
30
+ file is never modified, no API budget is spent, and the plugin itself has **zero npm dependencies**.
31
+
32
+ ## Install
33
+
34
+ In DSH, open **Settings → Plugins → Install**, paste one line, press Enter, then **restart DSH**:
35
+
36
+ ```
37
+ github:Z8906/dsh-plugin-office-markdown
38
+ ```
39
+
40
+ To pin a version, append a tag: `github:Z8906/dsh-plugin-office-markdown#<tag>`, where `<tag>` looks like
41
+ `v1.2.1` (see [Releases](https://github.com/Z8906/dsh-plugin-office-markdown/releases)).
42
+ If the target machine has no git, use the `.tgz` from Releases and paste its absolute path into the
43
+ install box. All four install routes, the manual route and the upgrade steps are in the
44
+ **[installation docs](docs/installation.md)**.
45
+
46
+ > **Do not upgrade through "uninstall → reinstall".** When this plugin is really uninstalled it cleans up
47
+ > the Python packages it registered (see the [uninstall docs](docs/uninstall.md)), so that route leaves you
48
+ > with an updated plugin and no Python environment. Use `pnpm update`, or add the same git address again
49
+ > in the install box.
50
+
51
+ ## Usage
52
+
53
+ Nothing to memorise. Say "read and summarise this xlsx" — the skill registered by the plugin makes the
54
+ model convert first:
55
+
56
+ ```
57
+ read_office_as_markdown({ path: "report.xlsx" })
58
+ ```
59
+
60
+ The return value carries the path, size and line count of the resulting `.md`, plus a structure outline
61
+ (headings / sheets / slides with approximate line numbers), and hands back a reading strategy: read the
62
+ first 200 lines for structure, then grep within the same `.md`. **The artifact itself is never truncated** —
63
+ the model receives a complete Markdown file.
64
+
65
+ Other ways to call the tool: batch (`paths`, or point `path` at a directory), outline only
66
+ (`action: "outline"`, never triggers conversion), clean up stale artifacts of the same source
67
+ (`action: "clean"`, dry-run by default), inspect the current converter (`action: "status"`).
68
+ All parameters are in the **[usage docs](docs/usage.md)**.
69
+
70
+ ## Converters
71
+
72
+ Probed in order, first available wins. This table mirrors `lib/convert.js`:
73
+
74
+ | # | Converter | Fidelity | Requires |
75
+ | --- | --- | --- | --- |
76
+ | 1 | `uvx markitdown` (temporary run) | high | `uv` + network (first run) |
77
+ | 2 | local `markitdown` command | high | markitdown installed |
78
+ | 3 | `python -m markitdown` | high | Python + markitdown |
79
+ | 4 | built-in Python fallback (`lib/fallback.py`) | limited | any Python 3; optional libs improve it |
80
+ | 5 | built-in Node fallback (`lib/fallback-node.js`) | limited | nothing |
81
+
82
+ **Level 5 needs neither Python nor network**: it parses OOXML directly with Node's built-in `zlib`
83
+ (`.docx` / `.xlsx` / `.pptx` are just zip + xml). It supports `.docx` `.docm` `.xlsx` `.xlsm` `.pptx` `.pptm`;
84
+ `.pdf` and legacy binary formats (`.doc` `.xls` `.ppt`) need MarkItDown or level 4.
85
+
86
+ Every artifact records who produced it on its first line; on a cache hit the plugin reads the **real**
87
+ converter and fidelity back from that line instead of claiming "high fidelity" unconditionally:
88
+
89
+ ```
90
+ <!-- dsh-office-markdown converter=python-module fidelity=high at=<time> srcbytes=<bytes> srchash=<hash> -->
91
+ ```
92
+
93
+ For maximum fidelity, open **Settings → Office conversion** and click "configure MarkItDown environment".
94
+ **The install script never installs any Python package on its own** — you pick the interpreter on that page.
95
+ Details are in the **[converter docs](docs/converters.md)**.
96
+
97
+ ## Settings page
98
+
99
+ **Settings → Office conversion** shows the current converter, probes the local Python environments,
100
+ configures or uninstalls MarkItDown, displays the environment record the plugin adopted, and offers
101
+ "try converting one file" (which runs the real converter chain locally, bypassing the model and the cache).
102
+
103
+ The buttons call the plugin's own HTTP routes under `/office-markdown/api/*`; the route list is in the
104
+ [usage docs](docs/usage.md).
105
+
106
+ ## Uninstall
107
+
108
+ Uninstall it from **Settings → Plugins**. The plugin first confirms it was **really removed**
109
+ (not disabled, not closed, not restarted), then dispatches a detached watchdog process that
110
+ `pip uninstall`s the packages it registered.
111
+
112
+ **Disabling, closing or restarting never triggers cleanup, and never leaves a resident process behind.**
113
+ Cleanup is strictly limited to the plugin's own environment record: packages shipped with the DSH runtime,
114
+ packages other components depend on, and anything you installed yourself are left untouched.
115
+ Details are in the **[uninstall docs](docs/uninstall.md)**.
116
+
117
+ ## Requirements
118
+
119
+ - **Node ≥ 18**, built-in modules only (`fs` / `path` / `os` / `zlib` / `crypto` / `child_process` / `string_decoder`) —
120
+ **0 npm dependencies**, no `npm install`.
121
+ - **Python and MarkItDown are entirely optional**; with neither, the level-5 Node fallback is used.
122
+ - Imports nothing from the host except `@deepseek-ai/dsh-tools` (for `defineTool`).
123
+ - DeepSeek Harness only. A profile without `webServer` (CLI profiles) simply has no settings page;
124
+ the tool and the skill are unaffected.
125
+
126
+ ## Documentation
127
+
128
+ The detailed docs are currently Chinese-only.
129
+
130
+ | Doc | Contents |
131
+ | --- | --- |
132
+ | [Installation](docs/installation.md) | four routes, manual install, upgrade, verification |
133
+ | [Usage](docs/usage.md) | tool parameters, skill, `read` guard, settings page, HTTP routes |
134
+ | [Converters](docs/converters.md) | converter chain, fidelity, multiple Python environments |
135
+ | [Configuration](docs/configuration.md) | config keys and defaults (mirrors `DEFAULTS` in `lib/index.js`) |
136
+ | [Artifacts & files](docs/artifacts.md) | where the `.md` goes, which files the plugin leaves behind |
137
+ | [Uninstall](docs/uninstall.md) | enable / disable / uninstall and cleanup scope |
138
+ | [Troubleshooting](docs/troubleshooting.md) | common symptoms |
139
+ | [Development](docs/development.md) | package layout, local development, releasing |
140
+ | [Changelog](CHANGELOG.md) | what changed in each version |
141
+
142
+ ## About this documentation
143
+
144
+ The README, `docs/`, `CHANGELOG.md` and the release notes of this repository are **largely AI-generated**
145
+ (written by a coding agent running in DeepSeek Harness) and reviewed by the maintainer before publishing.
146
+
147
+ Config keys, HTTP routes, the converter chain and the file list were each **checked against the source**;
148
+ even so, the docs can lag behind the implementation or contain inaccuracies and omissions — **the code is
149
+ the reference**. Issues and corrections are welcome.
150
+
151
+ Numbers without a reproducible measurement behind them (for example "how many tokens does this save" or
152
+ "how much memory does it use") are deliberately **not** stated here.
153
+
154
+ ## License
155
+
156
+ [MIT](LICENSE) © 2026 dsh-plugin-office-markdown contributors
package/README.md ADDED
@@ -0,0 +1,144 @@
1
+ <h1 align="center">dsh-plugin-office-markdown</h1>
2
+
3
+ <p align="center">
4
+ 在 DeepSeek Harness 读取 Office / PDF 之前,先把它们转成 Markdown ——<br>
5
+ 进入模型上下文的是一个文件路径,而不是整份文件的原始内容。
6
+ </p>
7
+
8
+ <p align="center">
9
+ <a href="README.md">中文</a> | <a href="README.en.md">English</a>
10
+ </p>
11
+
12
+ <p align="center">
13
+ <a href="https://github.com/Z8906/dsh-plugin-office-markdown/releases"><img alt="release" src="https://img.shields.io/github/v/release/Z8906/dsh-plugin-office-markdown?style=flat-square&label=release"></a>
14
+ <img alt="license" src="https://img.shields.io/badge/license-MIT-blue?style=flat-square">
15
+ <img alt="node" src="https://img.shields.io/badge/node-%E2%89%A518-brightgreen?style=flat-square">
16
+ <img alt="npm dependencies" src="https://img.shields.io/badge/npm%20deps-0-brightgreen?style=flat-square">
17
+ </p>
18
+
19
+ <p align="center">
20
+ <a href="#安装">安装</a> |
21
+ <a href="#怎么用">使用</a> |
22
+ <a href="#转换器">转换器</a> |
23
+ <a href="#文档">文档</a> |
24
+ <a href="CHANGELOG.md">更新日志</a>
25
+ </p>
26
+
27
+ ---
28
+
29
+ 转换在**本机**完成,不联网(可选的 MarkItDown 首次下载除外)、不修改原文件、
30
+ 不消耗 API 额度,插件本身**没有任何 npm 依赖**。
31
+
32
+ ## 安装
33
+
34
+ 在 DSH 的 **设置 → 插件 → 安装** 里填一行,回车,然后**重启 DSH**:
35
+
36
+ ```
37
+ github:Z8906/dsh-plugin-office-markdown
38
+ ```
39
+
40
+ 想锁定版本就在末尾加 tag:`github:Z8906/dsh-plugin-office-markdown#<tag>`,
41
+ `<tag>` 形如 `v1.2.1`(见 [Releases](https://github.com/Z8906/dsh-plugin-office-markdown/releases))。
42
+ 目标机器没有 git 的话,可以用 Releases 里的 `.tgz`,在安装框里填它的绝对路径。
43
+ 四种安装方式、手工装法与升级步骤见 **[安装文档](docs/installation.md)**。
44
+
45
+ > **升级不要走「卸载 → 重新安装」。** 本插件在真正被卸载时会清理它自己登记过的 Python 包
46
+ > (见 [卸载文档](docs/uninstall.md)),那条路的结果是「插件更新了、Python 环境却没了」。
47
+ > 用 `pnpm update`,或者直接在安装框里再 add 一次同一个 git 地址。
48
+
49
+ ## 怎么用
50
+
51
+ 装好之后不需要记命令,直接说「读取并总结这个 xlsx」即可 —— 插件注册的技能会让模型先调用转换工具:
52
+
53
+ ```
54
+ read_office_as_markdown({ path: "报表.xlsx" })
55
+ ```
56
+
57
+ 返回值里有转换后 `.md` 的路径、体积、行数,以及一份结构索引(章节 / 工作表 / 幻灯片的标题与大致行号),
58
+ 并给出读取建议:先读前 200 行看结构,再用 grep 在同一个 `.md` 里定位。
59
+ **产物本身不会被裁剪** —— 交给模型的是一个完整的 Markdown 文件。
60
+
61
+ 工具的其他用法:批量(`paths`,或把目录交给 `path`)、只要结构索引(`action: "outline"`,
62
+ 不触发转换)、清理同一源文件的旧产物(`action: "clean"`,默认先干跑)、查看当前转换器
63
+ (`action: "status"`)。全部参数见 **[使用文档](docs/usage.md)**。
64
+
65
+ ## 转换器
66
+
67
+ 按顺序探测,第一个可用的胜出。下表对照 `lib/convert.js`:
68
+
69
+ | 顺序 | 转换器 | 保真度 | 需要 |
70
+ | --- | --- | --- | --- |
71
+ | 1 | `uvx markitdown`(临时运行) | 高 | `uv` + 网络(首次) |
72
+ | 2 | 本机 `markitdown` 命令 | 高 | 已安装 markitdown |
73
+ | 3 | `python -m markitdown` | 高 | Python + markitdown |
74
+ | 4 | 插件内置 Python 兜底(`lib/fallback.py`) | 有限 | 任意 Python 3,可选库能提升效果 |
75
+ | 5 | 插件内置 Node 兜底(`lib/fallback-node.js`) | 有限 | 无 |
76
+
77
+ **第 5 级不需要 Python、也不需要网络**:它用 Node 内置的 `zlib` 直接解析 OOXML
78
+ (`.docx` / `.xlsx` / `.pptx` 本身就是 zip + xml)。支持 `.docx` `.docm` `.xlsx` `.xlsm` `.pptx` `.pptm`;
79
+ `.pdf` 与旧版二进制格式(`.doc` `.xls` `.ppt`)需要 MarkItDown 或第 4 级。
80
+
81
+ 每份产物的第一行记录它是谁转的;命中缓存时插件从这一行读回**真实的**转换器与保真度,
82
+ 而不是无条件声称「高保真」:
83
+
84
+ ```
85
+ <!-- dsh-office-markdown converter=python-module fidelity=high at=<时间> srcbytes=<字节数> srchash=<哈希> -->
86
+ ```
87
+
88
+ 想要高保真:打开 **设置 → Office 转换**,点「一键配置 MarkItDown 环境」。
89
+ **安装脚本不会替你装任何 Python 包**,装到哪个解释器由你在页面上选。
90
+ 细节见 **[转换器文档](docs/converters.md)**。
91
+
92
+ ## 设置页
93
+
94
+ **设置 → Office 转换** 提供:当前转换器、本机 Python 环境探测、一键配置 / 卸载 MarkItDown、
95
+ 插件登记的环境记录、以及「试转一个文件」(不进模型、不走缓存,直接在本机跑一遍转换链看结果)。
96
+
97
+ 页面上的按钮走插件自己的 HTTP 路由 `/office-markdown/api/*`,路由清单见 [使用文档](docs/usage.md)。
98
+
99
+ ## 卸载
100
+
101
+ 在 **设置 → 插件** 里点卸载即可。插件会先确认自己**真的被移除**(而不是被禁用 / 关闭 / 重启),
102
+ 再派一个脱离宿主的看门狗进程,把它登记过的 Python 包 `pip uninstall` 掉。
103
+
104
+ **禁用、关闭、重启都不会触发清理,也不会留下任何常驻进程。**
105
+ 清理范围严格限定在插件自己的环境记录里:DSH 运行时自带的包、被其它组件依赖的包、
106
+ 以及你自己装的包,一个都不动。细节见 **[卸载文档](docs/uninstall.md)**。
107
+
108
+ ## 依赖与兼容
109
+
110
+ - **Node ≥ 18**,只用内置模块(`fs` / `path` / `os` / `zlib` / `crypto` / `child_process` / `string_decoder`),
111
+ **0 个 npm 依赖**,不需要 `npm install`。
112
+ - **Python 与 MarkItDown 全部可选**:两者都没有时走第 5 级 Node 兜底。
113
+ - 除宿主提供的 `@deepseek-ai/dsh-tools`(用于 `defineTool`)外,不 import 任何宿主包。
114
+ - 只支持 DeepSeek Harness。profile 没有 `webServer` 服务时(例如 CLI profile),
115
+ 设置页不会出现,工具与技能不受影响。
116
+
117
+ ## 文档
118
+
119
+ | 文档 | 内容 |
120
+ | --- | --- |
121
+ | [安装](docs/installation.md) | 四种安装方式、手工安装、升级、验证 |
122
+ | [使用](docs/usage.md) | 工具参数、技能、`read` 守卫、设置页、HTTP 路由 |
123
+ | [转换器](docs/converters.md) | 转换器链、保真度、多个 Python 环境 |
124
+ | [配置](docs/configuration.md) | 配置项与默认值(对照 `lib/index.js` 的 `DEFAULTS`) |
125
+ | [产物与文件](docs/artifacts.md) | `.md` 放在哪、插件会留下哪些文件 |
126
+ | [卸载](docs/uninstall.md) | 启用 / 禁用 / 卸载与清理范围 |
127
+ | [故障排查](docs/troubleshooting.md) | 常见现象与处理 |
128
+ | [开发](docs/development.md) | 包内文件、本地开发、发布 |
129
+ | [更新日志](CHANGELOG.md) | 每个版本改了什么 |
130
+
131
+ ## 关于本文档
132
+
133
+ 本仓库的 README、`docs/`、`CHANGELOG.md` 以及各版本的 Release 说明,**主要由 AI 生成**
134
+ (DeepSeek Harness 里的编码 agent 撰写),由维护者审阅后发布。
135
+
136
+ 其中配置项、HTTP 路由、转换器链、文件清单等内容都**逐项对照过源码**;但文档仍可能落后于实现,
137
+ 或存在表述不准、细节缺失之处,**请以代码为准**。发现问题欢迎提 issue。
138
+
139
+ 文档中**不写没有实测依据的数字**(例如「能省多少 token」「占用多少内存」)——
140
+ 这类断言缺少可复现的测量过程,因此不列出。
141
+
142
+ ## 许可证
143
+
144
+ [MIT](LICENSE) © 2026 dsh-plugin-office-markdown contributors
@@ -0,0 +1,35 @@
1
+ # dsh-plugin-office-markdown bundle patch: inserts one plugin row into the
2
+ # profile roster. Install by copying this package into the profile's
3
+ # node_modules and adding `dsh-plugin-office-markdown` to
4
+ # `dsh.profile.bundles` in the profile package.json (see README.md).
5
+ #
6
+ # The row references the package by name; `exports["."]` is the host half that
7
+ # registers the `read_office_as_markdown` tool plus its bundled skill.
8
+ #
9
+ # `config` below restates every owned key so later profile layers can override
10
+ # individual values while keeping this bundle first in the stack.
11
+ - insert:
12
+ - id: office-markdown
13
+ name: dsh-plugin-office-markdown
14
+ config:
15
+ enabled: true
16
+ tmpDir: ''
17
+ converter: auto
18
+ pythonPath: ''
19
+ pythonPrefer: auto
20
+ allowUvxDownload: true
21
+ uvxExtras: 'markitdown[all]'
22
+ fallbackEnabled: true
23
+ guardReadTool: true
24
+ probeTtlMs: 600000
25
+ timeoutMs: 300000
26
+ reuseFresh: true
27
+ pruneStaleArtifacts: false
28
+ maxPreviewChars: 4000
29
+ maxRowsPerSheet: 400
30
+ maxTableCols: 24
31
+ maxCellsPerSheet: 20000
32
+ registerSkill: true
33
+ registerSettings: true
34
+ autoAdoptEnv: true
35
+ removeEnvOnUninstall: true