The DSH plugin ecosystem is designed to extend agent capabilities through host plugins. General-purpose agents often get stuck when handling binary files such as Word or Excel, because the basic read tool cannot parse these formats. cnkids/dsh-office-toolkit is a host plugin that enables AI agents to read and write Word and Excel files. It runs cross-platform using pure JavaScript and does not require a local Office installation.
Basic Information¶
- Name: dsh-office-toolkit
- Maintainer: cnkids
- Category: Workflow
- License: MIT
- Core Value: Pure JS reading/writing for Word/Excel/CSV/PDF, no Office installation required.
Installation and Enablement¶
Install it using the officially provided command. After installation, you must restart dsh web (or reopen the desktop client) and create a new session for the tools to take effect.
dsh plugin --profile web add dsh-office-toolkit
Core Features¶
The plugin automatically registers 8 tools, providing agents with end-to-end capabilities from reading, querying, and editing to conversion.
- File Reading and Writing: Supports pure JS reading and writing for Word (.docx/.doc), Excel (.xlsx/.xls/.xlsb), PDF, and CSV. When reading PDFs, it uses local
pdftotextor macOS PDFKit if available; otherwise, it uses the bundled pdfjs. - In-File Excel Calculation: Uses the
office_querytool to perform filtering, grouping, summing, counting, deduplication, and sorting inside the file. It supports pivot tables and multi-sheet joins (join), allowing conclusions to be obtained without exporting the data. - Word Layout and Editing:
- Automated Handling: Supports Word automatic numbering, headers and footers, and table of contents.
- Template Filling: Uses
office_fill_docx_templateto fill templates such as contracts and notifications with the{{variable}}syntax. - Style Control: Supports formatting settings such as font, font size, line spacing, and alignment, as well as images and formulas.
- Format Conversion: Provides the
office_converttool, supporting conversions within Word file families and spreadsheet file families, as well as exporting to PDF.
Typical Usage¶
The following are examples of the main operations supported by the plugin.
Read Word
{ "path": "报告.docx" }
Read Excel (Limited Range)
{ "path": "销售.xlsx", "sheets": ["明细"], "range": "A1:F100" }
Write Markdown to Word
{ "path": "周报.docx", "markdown": "# 周报\n\n- 完成 A\n- 完成 B" }
Edit Excel (Set Values and Styles)
{ "path": "台账.xlsx", "ops": [ { "op": "set_value", "ref": "E1", "value": "合计", "style": { "bold": true } } ] }
Template Filling
{ "templatePath": "合同模板.docx", "outputPath": "合同-001.docx", "data": { "合同编号": "HT-001" } }
Format Conversion
{ "sourcePath": "旧表.xls", "outputPath": "新表.xlsx" }
Notes¶
- Environment Requirement: Node.js 20 or higher is required.
- DSH Version Compatibility: DSH 0.1.6-alpha.1 / 0.1.6-alpha.2 have a module resolution defect that may cause
.xlsxreading/writing failures (related to ExcelJS paths). Please upgrade to a fixed DSH version. - Permissions and Sandbox: Write operations are constrained by the DSH sandbox fence (including realpath validation), text sources are neutralized against formula injection, parsing uses linear scanning throughout (no ReDoS), and there is no network access (except for pdfjs).
- PDF Reading: Reading PDFs requires local installation of
pdftotextor macOS PDFKit.
Summary¶
dsh-office-toolkit addresses the pain points of DSH agents when handling office documents. Through 8 automatically registered tools, it creates a closed loop from static reading to dynamic editing, calculation, and conversion. Developers can issue configuration instructions to force agents to prioritize these tools over general-purpose text reading/writing interfaces.
- Catalog Page: SkillHub
- GitHub Repository: cnkids/dsh-office-toolkit