Introduction

The plugin ecosystem of DeepSeek Harness (DSH) aims to extend tool capabilities. Processing invoices (especially Chinese e-invoices) usually involves manual entry or complex Excel operations. Currently, there is no ready-made solution for this vertical area. dsh-invoice-tools is a native DSH tool designed to parse invoice PDFs (prioritizing XML attachments, with text-layer regex as a fallback) and generate expense reports.

Installation and Prerequisites

This plugin depends on an adjacent dsh-src checkout (link: dependency). Before installing the plugin, make sure the official DeepSeek Harness source code has been checked out and built.

# 1. 先检出并构建 dsh-src
git clone https://github.com/deepseek-ai/deepseek-harness.git dsh-src
cd dsh-src
pnpm install && pnpm run build

# 2. 安装本插件
dsh plugin add

Core Features

The plugin provides two main tools: invoice_parse and invoice_summary.

invoice_parse

Used for parsing a single invoice or a batch of invoices.
* XML first: Reads the structured XML embedded in the PDF.
* Text-layer fallback: If no XML is present, uses regular expressions to match invoice numbers and amounts.
* Reconciliation check: Automatically validates 价税合计 == 金额 + 税额.
* Confidence labeling: Marks parse quality (high/medium/low) based on the source.

invoice_summary

Used for aggregating settlements and generating expense reports.
* Categorization: Maps invoices to categories based on the categories parameter (e.g., travel, office).
* Duplicate detection: Detects duplicate invoice numbers and amounts.
* Output: Generates a Markdown or xlsx file.

Usage Examples

Parse a single invoice

invoice_parse path='invoices/电子发票_2024.pdf'

Parse a directory

invoice_parse path='invoices/'

Generate an expense report (Markdown by default)

invoice_summary

Generate an expense report with specified categories

invoice_summary out='both' categories='{"发票号码123...":"差旅","文件B.pdf":"办公"}'

Generate an xlsx expense report

invoice_summary files='["invoices/A.pdf","invoices/B.pdf"]' out='md'
# xlsx 文件将以 base64 文本形式落盘

Technical Details and Limitations

  • Dependencies: The plugin depends on an adjacent dsh-src checkout (link: dependency).
  • File limits: Single-file read limit is 16MB; recursive directory scan depth limit is 3.
  • Scanned-file handling: Pure scanned files (images/PDFs without a text layer) return an explicit “skip reason” and do not interrupt batch processing.
  • xlsx export: Because the DSH filesystem service provides only a text channel, xlsx output is written as base64 text to a .b64 file. Decoding is as follows:
    base64 -d 报销单-20260823.xlsx.b64 > 报销单-20260823.xlsx
  • Privacy: No verification APIs are called and no data is uploaded; processing is local only.

Applicable Scenarios

Suitable for DSH users who need automated invoice processing. Input must be standard Chinese e-invoice PDFs or images. It does not rely on OCR and uses purely structured parsing.