Introduction

DSH’s native read / write / edit tools are primarily oriented towards UTF-8 text, whereas office documents such as PDF, DOCX, XLSX, and PPTX are typically binary formats that text processing tools cannot directly overwrite.

The following introduces dsh-basic-office. It is a DSH office file plugin that provides a set of office_* tools for reading common office documents and generating common office files within DSH sessions.

What is it

dsh-basic-office is a set of office file read/write tools for DSH sessions.

The repository is located at:

https://github.com/pqkisvery666/dsh-basic-office

It is licensed under the MIT license and requires Node.js >=20.

It primarily addresses two things:

  1. Reading common binary documents such as PDF, DOCX, XLSX, and PPTX.
  2. Generating common office files such as DOCX, XLSX, PPTX, PDF, and CSV.

Core Features

Reading

The plugin provides the following reading tools:

  • office_read_pdf: Extracts PDF text, supporting page_start / page_end page ranges and max_chars truncation.
  • office_read_docx: Extracts Word .docx text, including headers, paragraphs, and table text.
  • office_read_xlsx: Reads .xlsx / .xls / .csv, returning tab-separated lines per sheet; supports sheet / range / max_rows.
  • office_read_pptx: Extracts text from each slide of PowerPoint .pptx, including table text.

Generation

The plugin provides the following generation tools:

  • office_write_docx: Generates Word documents, supporting headers, heading1-3 / quote / normal paragraph styles, and tables with header background colors.
  • office_write_xlsx: Generates Excel workbooks, supporting multiple sheets, string/number/boolean/empty cells, and automatic column width.
  • office_write_pptx: Generates PPT presentations, supporting 16:9 widescreen, titles/subtitles/bulleted lists/tables.
  • office_write_pdf: Generates PDF, supporting multiple pages, headers/paragraphs/bullets/tables; non-ASCII text uses Windows system fonts.
  • office_write_csv: Generates CSV, supporting optional headers, comma / tab / semicolon delimiters, and default UTF-8 BOM.

Installation and Usage

First, execute the following installation command. This command installs the plugin to the web profile:

dsh plugin --profile web add https://codeload.github.com/pqkisvery666/dsh-basic-office/tar.gz/refs/heads/main

After installation, restart the dsh web service for the new tools to take effect in the session.

Typical Usage

After installation and restart, you can describe tasks directly in the session, for example:

  • Read the first 10 pages of C:\path\报告.pdf
  • Generate data.xlsx and data.csv from this table
  • Generate a 周报.docx (with title and table) and a 5-page 汇报.pptx from the following content
  • Output this summary as 总结.pdf

Consistency with Native Behavior

dsh-basic-office adheres to the existing DSH session strategies for file read/write behavior:

  • Sandbox consistency: Generated files are constrained by session sandbox policies; boundary violations result in the same [sandbox: ...] rejection prompt as the native behavior.
  • Under workspace-write, only the workspace and system temporary directory can be written to.
  • Supports a one-time upgrade of sandbox_permissions + justification, requiring user approval.
  • Read-before-write protection: Unread existing files will not be overwritten directly.
  • Path resolution: Relative paths are resolved based on the session workspace.
  • Observed events: Both reading and generation emit fs/observed.

Runtime Environment and Dependencies

The runtime environment requires Node.js >=20.

It is licensed under the MIT license.

Dependencies include:

docx
jszip
mammoth
pdfkit
pptxgenjs
unpdf
xlsx

@deepseek-ai/dsh-tools is an optional peerDependency with version ^0.1.0-rc.0.

Notes and Limitations

Please be aware of the following limitations before use:

  • Scan-based PDFs (pure images without a text layer) cannot extract text.
  • Old binary .doc files are not supported; please save them as .docx first. .xls is supported.
  • When generating PDFs on non-Windows platforms, if there are no CJK system fonts, Chinese characters cannot be rendered.
  • PPTX reading does not include text within images or drawings.
  • The plugin runs within a dsh session and reads/writes files. It is recommended to check the source code and MIT license before installation.

Conclusion

The value of dsh-basic-office lies in filling the gap in DSH sessions’ ability to read and generate common office binary documents, while retaining DSH’s sandbox, observation, and path resolution mechanisms.

GitHub repository:

https://github.com/pqkisvery666/dsh-basic-office