In the plugin ecosystem of DSH (DeepSeek Harness), file-level read/write tools (such as openpyxl) cannot simulate real Office runtime behavior, such as performing formula recalculation or running VBA macros. dsh-office-com provides a COM channel to operate local Office instances directly, filling this gap.

Plugin Positioning

This is a Windows-native real Office automation plugin maintained by developer wly8691-jpg. It drives real Excel and Word instances through COM and supports VBA macros, pivot tables, and live formula recalculation. Its core features cover flagship accounting scenarios (journal entries, general ledger, and pivot tables) and provide complete process lifecycle management.

Core Features

29 low-level tools

The toolset is grouped into application management, read/write, formulas/macros, pivot tables, and Word operations.

  • Application discovery / launch: office_apps, office_launch
  • Excel read/write: excel_new (create and make visible/topmost), excel_open, excel_read_range, excel_write_range
  • Excel formulas / macros: excel_formula_set, excel_recalc (force recalculation and get live values), excel_vba_run (run existing macros)
  • Pivot tables: excel_pivot_create, excel_pivot_refresh
  • Word: word_open (read structure), word_edit (whole-document search and replace)
  • Accounting flagship (low-level): excel_journal_post (write journal entries + debit/credit balance check), excel_ledger_gen (journal → account ledger)

6 task-level tools

Task-level tools encapsulate a complete set of business steps into a single call, so the Agent does not have to manually orchestrate multiple COM steps.

  • office_generate_accounting_report: Generates a complete accounting report (journal + general ledger + pivot table + forced recalculation).
  • office_check_workbook: Read-only health check; checks evaluation errors, external links, protected sheets, and unsaved changes.
  • office_replace_document_terms: Batch-replaces terms (such as amounts or dates in contracts), counting first and then replacing all.
  • office_update_monthly_report: Updates a monthly report by period, replacing content rather than appending to it.
  • office_apply_template: Applies template appearance (fonts, borders, formatting) to the target workbook.
  • office_prepare_management_summary: Generates a management summary from data sheets, including dimension aggregation and comparison.

8 kb_* knowledge base classification tools

This family of tools forms the Office + KnowLP integration surface and is used to establish classification systems in unfamiliar environments.

  • kb_scan_root: Registers the directory tree and supports dual-criteria classification by extension + magic number.
  • kb_taxonomy_get / kb_taxonomy_set: Get or set the taxonomy, with built-in drift auditing.
  • kb_classify: Archives items according to taxonomy rules, supporting semantic seam (use_semantics=true).
  • kb_scheme_propose: Generates a shadow directory scheme (label chain) and only proposes the scheme without touching files.
  • kb_annotate: Writes annotations and can write them back to the original file.
  • kb_verify: Performs verification, checking that annotations are parseable and source-file fingerprints match.
  • kb_write_back_office: Writes custom document properties into Office files without touching cell content.

Execution Modes

All tools support three execution modes:

  • preview: Actually opens the file via COM to dry-run changes without committing them; used to confirm before making changes.
  • managed: Open → modify → validate → save → close; suitable for batch jobs.
  • attached: Operates on the currently running instance; does not actively close or automatically overwrite; suitable for scenarios where the user is editing.

Typical Usage

1. Write data → write a formula → recalculate and read the live value

// 写入数据
{ "tool": "excel_write_range", "range": "A1:C4",
  "value": [["科目","月份","金额"],["办公费","1月",100],["办公费","2月",150],["差旅费","1月",80]] }

// 设置公式
{ "tool": "excel_formula_set", "range": "D1", "formula": "=SUM(C2:C4)" }

// 强制重算后读回的是计算后的活值
{ "tool": "excel_recalc", "range": "D1" }
// → { "value": 330 }

2. Use preview mode to dry-run changes

// 第一步:预演修改,不落笔
{ "tool": "excel_write_range", "path": "C:/book.xlsx", "range": "A2:B2",
  "value": [["x","y"]], "mode": "preview" }
// → { "preview": true, "changed": false, "output": { "target": { "sheet": "Sheet1", "address": "$A$2:$B$2" }, "overwrite_non_empty": 2 } }

// 第二步:确认无误后执行
{ "tool": "excel_write_range", "path": "C:/book.xlsx", "range": "A2:B2", "value": [["x","y"]], "mode": "managed" }

Applicable Scenarios and Notes

  • Dependency environment: Real Office testing must run on the target machine and depends on the local OfficeMCP service.
  • Permission requirements: The plugin runs with the current DSH process permissions; before installing, review the source code and license (MIT).
  • Process management: The plugin can reclaim orphaned processes and manages the Excel process lifecycle using PID ownership and visibility checks.