前言¶
DSH 的理念是「一切皆插件」,插件是扩展 agent 能力的主要方式。对于需要在 dsh 中让 agent 创建、读取、查询和编辑 .docx、.xlsx、.pptx 的任务,dsh-office-tool 提供了一条现成的工具链。
它是一个 DeepSeek Harness(DSH / dsh)插件,GitHub 仓库为 rong-coder/dsh-office-tool,许可证为 MIT。它通过 OfficeCLI 二进制驱动 Office 文档能力,并在 dsh web sidebar 中提供文档预览;预览部分依赖 dsh-better-sidebar。
这是什么¶
dsh-office-tool 为 dsh agent 提供创建、读取、查询和编辑 .docx、.xlsx、.pptx 的完整 Office 文档能力。
它的核心特点是:
- 使用 OfficeCLI 二进制执行 Office 文档操作。
- 向模型暴露一组结构化工具。
- 在 dsh web sidebar 中提供文档预览。
- 无需 Microsoft Office,依赖 OfficeCLI 内置高保真 HTML 引擎渲染预览。
- 可在无 Web UI 的 profile 中启用工具,仅预览路由依赖 Web server。
核心功能¶
Office 文档操作¶
插件提供 9 个模型工具,覆盖创建、读取、查询、修改、添加、删除、查看、批量操作和原始命令透传:
office_create(file, type?, force?)
office_get(file, path?, depth?)
office_query(file, selector, limit?)
office_set(file, path, props, find?, replace?)
office_add(file, parent, type, props?, after?/before?/index?/from?)
office_remove(file, path, shift?)
office_view(file, mode, page?, cols?, maxLines?)
office_batch(file, commands[], bestEffort?)
office_cli(argv)
这些工具的作用如下:
office_create:创建空白文档。office_get:读取元素及子元素。office_query:按选择器查询。office_set:修改元素属性。office_add:添加或克隆元素。office_remove:删除元素。office_view:查看text、outline、annotated、stats、issues、html、screenshot等模式。office_batch:执行批量操作。office_cli:透传 OfficeCLI 原始命令,例如:
merge
dump
import
validate
raw
raw-set
move
swap
refresh
help
load_skill
结构化响应¶
工具使用结构化 --json 响应。失败时,会暴露 OfficeCLI 错误码,便于模型或调用方继续处理。
Web sidebar 预览¶
预览功能依赖同一 profile 中安装的 dsh-better-sidebar。
启用后,dsh web sidebar 中可以提供:
docx/xlsx/pptx文件查看器。- 运行
officecli watch的「Office 预览」tab。
实时预览只在 OfficeCLI 修改文档时刷新;其他工具修改的文件不会自动推送。
无 Web UI 时也可用¶
dsh-office-tool 可在无 Web UI 的 profile 中启用工具。
预览路由只在 host 存在 ctx.webServer 时注册;headless 下仅工具可用。
安装与启用¶
先确认安装前提:
- 已安装
dsh,并配置可用 profile。 - 启用预览需要 web profile。
- 需要 OfficeCLI 二进制。
$DSH_OFFICECLI可覆盖默认officecli。- 预览功能需要同一 profile 安装
dsh-better-sidebar。
先安装预览依赖,再安装本插件:
dsh plugin --profile web add dsh-better-sidebar
dsh plugin --profile web add dsh-office-tool
如果从本地仓库安装,先克隆并安装依赖:
git clone https://github.com/rong-coder/dsh-office-tool.git
cd dsh-office-tool && pnpm install
dsh plugin --profile web add ./dsh-office-tool
配置¶
插件支持通过 profile 的 cordis.patch.yml 配置这些项:
command
timeoutMs
maxOutputBytes
preview.allowOutsideWorkspace
watch.enabled
watch.idleSeconds
配置示例:
- id: office-tool
config:
command: 'C:\path\to\officecli.exe'
timeoutMs: 60000
maxOutputBytes: 16777216
- id: office-tool-preview
config:
preview:
allowOutsideWorkspace: false
watch:
enabled: true
idleSeconds: 300
command 可以写二进制名或绝对路径;$DSH_OFFICECLI 会覆盖默认 officecli。
典型用法¶
创建空白文档:
office_create(file, type?, force?)
读取元素及子元素:
office_get(file, path?, depth?)
按选择器查询:
office_query(file, selector, limit?)
修改元素属性:
office_set(file, path, props, find?, replace?)
添加或克隆元素:
office_add(file, parent, type, props?, after?/before?/index?/from?)
删除元素:
office_remove(file, path, shift?)
查看文档内容:
office_view(file, mode, page?, cols?, maxLines?)
批量执行操作:
office_batch(file, commands[], bestEffort?)
透传 OfficeCLI 原始命令:
office_cli(argv)
适用场景与注意¶
dsh-office-tool 适合这些场景:
- 希望 dsh agent 直接处理
.docx、.xlsx、.pptx。 - 希望在 dsh web sidebar 中预览 Office 文档。
- 希望在无 Web UI 的 profile 中调用 Office 文档工具。
- 希望使用 OfficeCLI raw passthrough 命令处理更复杂的文档操作。
安装前需要注意:
- 插件以当前 dsh 进程权限运行,安装前应检查源码与许可证。
- 工具中的相对文件路径按
dsh启动时的 host cwd 解析。 office_view的screenshot模式需要 host 安装 headless 浏览器。- 含公式的 HTML 会从 CDN 加载 KaTeX;无网络时公式退化为等宽文本。
dsh-better-sidebar在package.json的peerDependenciesMeta中标记为 optional。- 预览路由只在 host 存在
ctx.webServer时注册;headless 下仅工具可用。
结尾¶
dsh-office-tool 的价值在于:把 Office 文档能力封装成 dsh agent 可直接调用的工具,并保留 web sidebar 预览入口。社区目录是独立站点,与 DeepSeek / 幻方无官方从属关系;如需在目录中查找,可按插件名 dsh-office-tool 搜索。可核实的仓库地址是:
https://github.com/rong-coder/dsh-office-tool