Introduction¶
When you ask a model to “read an invoice” in DeepSeek Harness (DSH), the common result is: the code, amount, and tax amount look reasonable, but they have never been validated against accounting identities. Whether an invoice can be booked often depends on one simple relationship: amount + tax = tax-inclusive total. If the model merely transcribes numbers from OCR text, one-cent discrepancies, misaligned labels, or inconsistencies between figures and word amounts are hard to detect systematically in a conversation.
The community plugin yuehancn/dsh-tool-invoice (SkillHub category: Model Reasoning) targets this scenario: it registers three tools inside the Harness, extracts fields from invoice text or files, and adds validation checks plus ledger aggregation, turning “reading an invoice” from number guessing into an auditable step. The maintainer is yuehancn; the README states it was built and tested on dsh 0.2.0-rc.2 (preview), and the apply(ctx) plugin spec is stable — other dsh versions need to be verified by yourself. The license is MIT, and the current package version is 1.0.0.
What Is This¶
In one sentence: a self-built tool plugin for DSH that extracts key fields from texts such as VAT invoices and English receipts into structured data, while checking amount relationships, consistency between figures and word amounts, and whether tax rate tiers are reasonable.
Compared with “letting the model read images/PDFs directly,” this plugin emphasizes three capabilities that ordinary regular expressions struggle to cover (as summarized in the README):
- Validation, not transcription — each check reports the “expected value” alongside the “read value” and the difference.
- Values with evidence — each value carries the matched label (e.g., “Seller Name”) and the original sentence, facilitating manual review.
- Take a value only when it has a label — an isolated
¥1130.00is not guessed to be an amount, tax, or total; without a label it is reported as “unrecognized.”
When no PDF/image-to-text command is configured, as long as you already have text (e.g., from an OCR plugin or email body), invoice_extract is still directly usable.
Three Tools¶
invoice_status¶
Probes whether this plugin can read files itself (whether a text extraction command is configured) and lists all field names it can recognize. Suitable for confirming the environment and capability boundaries before starting a conversation.
invoice_extract(path | text)¶
Extracts fields from an invoice and performs validation checks. The argument can be a file path or existing text.
Recognizable fields include (excerpt; see the README table for the full list):
| Field | Meaning |
|---|---|
code / number |
Invoice code / invoice number |
date |
Issue date |
seller / buyer |
Seller / Buyer |
sellerTaxId / buyerTaxId |
Taxpayer ID numbers |
amount / tax / total |
Amount excluding tax / tax amount / tax-inclusive total (in figures) |
totalInWords |
Tax-inclusive total (in words) |
checkCode / remark |
Check code / remark |
Three types of checks in the response:
| Check | Meaning |
|---|---|
amount + tax == total |
Basic identity (tolerance configurable, default ±2 cents or ±0.5%) |
| Figures vs. word amount | Easily triggers alerts when scanned copies are tampered with or OCR errors occur |
| Reverse-calculated tax rate | Whether it falls into common tiers such as 0/1/3/5/6/9/13% |
There is also a faithful boolean: true when all checks pass and the number, date, and total all exist; in most scenarios you only need to watch this field.
invoice_ledger(paths, groupBy, outputName)¶
Aggregates multiple invoices into a ledger: totals, subtotals grouped by field, and flags for unvalidated rows, unreadable rows, and duplicate invoice numbers. Specifying outputName writes the ledger to JSON.
Installation and Activation¶
One-line installation (from the README; supports desktop and web profiles):
dsh plugin --profile desktop add github:yuehancn/dsh-tool-invoice
For the web version, replace --profile desktop with --profile web. After installation, restart dsh and the tools above become callable in the Harness.
Optional configuration is written to ~/.dsh/profiles/<profile>/cordis.patch.yml, for example:
- id: tool-invoice
config:
outputDir: C:/Users/you/Documents/invoice-output
textCommand: C:/poppler/Library/bin/pdftotext.exe
textArgs: ["-layout", "{input}", "{output}"]
toleranceCents: 2
| Config item | Default | Description |
|---|---|---|
outputDir |
invoice-output |
Directory for intermediate text, ledger JSON, and other artifacts |
timeoutMs |
600000 | Per-call timeout (10 minutes) |
textCommand |
empty | Leave empty to accept only text; invoice_extract(text=...) still works without it |
textArgs |
["-layout","{input}","{output}"] |
{input} / {output} placeholders |
tolerancePercent |
0.5 | Percentage tolerance for the identity check |
toleranceCents |
2 | Cent-level tolerance for the identity check |
status / extract / ledger |
true |
Individual tools can be disabled as needed |
The README notes: you can point textCommand at the CLI of plugins such as dsh-tool-ocr to form a “scanned copy → text → structured invoice” pipeline; the text extraction command is configured by the user themselves — the plugin does not download or install third-party binaries.
Typical Usage Approaches¶
- Call
invoice_statusto confirm whethertextCommandis configured and which fields are currently recognizable. - If you already have plain text from OCR or PDF extraction, call
invoice_extractwithtext; if you have a local file and a text-extraction command is configured, passpath. - Check the
faithfulflag and the three validation results in the response; when a check fails, manually re-verify against the original invoice using the difference and field evidence. - Before reimbursement or month-end closing, call
invoice_ledgerwith multiple paths to check for duplicate numbers and unvalidated rows; setoutputNameif you need to persist the ledger to disk.
The parser deliberately tolerates dirty text (folding fullwidth digits and punctuation, repairing OCR confusions within digit strings, handling multiple date formats, labels and values on separate lines in two-column layouts, red-ink negative amounts, Chinese word amounts, English Stripe-style receipts, etc.). Labels must appear at the start of a line to avoid misreading fragments of “Amount Excluding Tax” as the tax amount — the README calls this a design decision born from real-world pitfalls, with regression cases included.
Applicable Scenarios and Notes¶
Suitable for: situations in DSH conversations or workflows where invoice/receipt text needs to become reconcilable, aggregable data; where identity and figures-vs-words amount consistency checks are wanted; where batch ledgers are needed and duplicate invoice numbers must be detected.
Runtime and security (from the README’s security notes):
- Text extraction is invoked via
spawn(command, argsArray), not by concatenating shell strings. - It only reads and writes the inputs you specify and
outputDir; it uploads nothing and makes no network connections. - The plugin runs with the permissions of the current dsh process; before installing, review the GitHub source code and the MIT license yourself, and make sure the executable that
textCommandpoints to is trustworthy.
The README mentions the test suite has 288 assertions, run against the real @deepseek-ai/dsh-tools and subprocesses (no mocks); to run tests locally you need to copy dsh’s node_modules per the README and execute node _test/run-all.mjs; the e2e tests use a built-in stand-in extractor, requiring neither poppler nor network access.
The SkillHub directory page and the GitHub repository are community ecosystem information, with no official affiliation with DeepSeek / High-Flyer; metadata such as star counts is subject to what each site displays at the time.
Conclusion¶
dsh-tool-invoice converges invoice reading from “model guessing numbers” to “field extraction + validation + ledger”: most calls only need to look at faithful, while complex reimbursement scenarios can rely on the ledger to catch duplicates and anomalous rows. If you are already handling OCR output or email bodies in the Harness, you can first skip configuring textCommand to validate extraction and checks, then hook up the PDF/OCR pipeline as needed.
- Directory page: https://www.skillhub.cn/plugins/yuehancn/dsh-tool-invoice
- Source code with the full field table and configuration docs: https://github.com/yuehancn/dsh-tool-invoice