Local Invoice Review
Use this skill when a user wants to batch-process local invoices, receipts, or simple billing documents. Keep source files on the local machine. Return the output directory, counts, warnings, and review statuses.
Invocation
Use the fixed entry point:
.\scripts\run.ps1 -InputDir .\data\input -OutputDir .\data\output -Offline
When the user asks to re-check only newly added or changed files, add
-OnlyChanged. The previous records.json is read from the output directory
unless -PreviousOutputDir is supplied. This is an incremental re-audit, not a
comparison of two business periods.
The entry point starts or reuses the local model server, processes the batch,
and emits one JSON response on stdout. Human-readable diagnostics go to stderr.
Add -IncludeReport only when the user explicitly asks for a report, summary
page, Markdown report, or HTML report. Without it, return structured JSON/CSV
outputs but do not generate human-readable report pages.
Natural requests such as “给我一份审核报告”“生成 HTML 报告”“把结果整理成
报告” count as an explicit request. Requests such as “帮我检查一下”“把发票
整理出来”“哪些有问题” do not request a report page by themselves.
首轮回复规范(WorkBuddy)
当用户第一次提出“帮我看一下这几张发票”“检查一下这些发票”等批量审核请求,且没有明确要求报告时,
调用
scripts\run.ps1,但不要加 -IncludeReport。调用完成后不要把原始 JSON 全部贴给用户,
必须按以下顺序回复:
- 先用
summary_zh展示总处理数量和四种状态数量,状态顺序固定为:规则校验通过、待人工确认、已阻断、处理失败。 - 再按
preview.展示展示问题发票。展示顺序固定为“已阻断”“待人工确认”;只有preview.总数.处理失败大于 0 时才增加“处理失败”。不要逐条展开“规则校验通过”发票。 - 每个问题分类只允许展示
preview.每类最多展示条(默认 10 条),只能使用preview.展示中的数据,不能自行从records.json扩展首轮消息。若preview.是否还有未展示对应分类为true,在该分类表格后说明还有未展示记录。 - 问题说明使用预览项中的中文
问题字段;不要向用户展示英文状态码、warning code 或完整结构化 JSON。 - 使用
artifacts.invoices_csv.path和artifacts.line_items_csv.path明确告诉用户: 完整发票表格和完整商品明细表已经生成到哪里。必要时同时提到artifacts.records_json.path,说明它保存完整记录与证据;同时告知artifacts.review_queue_csv.path、artifacts.blocked_queue_csv.path和artifacts.retry_queue_csv.path是后续动作清单。 - 在报告问题之前,首轮必须单独询问:
需要我按状态将原始发票复制到不同文件夹吗? - 首轮最后再单独询问:
是否需要我生成完整审核报告?
首轮回复使用下面的结构(数量和行内容替换为实际结果;没有记录的分类写“无”):
本次共处理 X 张发票。
| 状态 | 数量 |
|---|---:|
| 规则校验通过 | X |
| 待人工确认 | X |
| 已阻断 | X |
| 处理失败 | X |
## 已阻断
| 文件 | 销售方 | 发票号码 | 价税合计 | 问题 |
|---|---|---|---:|---|
## 待人工确认
| 文件 | 销售方 | 发票号码 | 价税合计 | 问题 |
|---|---|---|---:|---|
完整发票表格:`<artifacts.invoices_csv.path>`
完整商品明细表:`<artifacts.line_items_csv.path>`
待人工复核清单:`<artifacts.review_queue_csv.path>`
规则阻断清单:`<artifacts.blocked_queue_csv.path>`
处理失败重试清单:`<artifacts.retry_queue_csv.path>`
需要我按状态将原始发票复制到不同文件夹吗?
是否需要我生成完整审核报告?
只有用户明确同意按状态分类(例如“需要”“按状态分类”“帮我整理文件夹”)时,才调用:
.\scripts\run.ps1 -InputDir .\data\input -OutputDir .\data\output -Offline -OrganizeStatus
该调用读取已有 records.json,不重新执行 OCR;它会把原始文件复制到
按状态分类\规则校验通过、按状态分类\待人工确认、按状态分类\已阻断、
按状态分类\处理失败,绝不移动或删除原件。回复时使用
artifacts.status_folders.path、artifacts.status_classification_csv.path 和
artifacts.status_classification_json.path 告知目标目录和分类清单路径。
用户未确认时不得自行执行文件复制。
只有用户明确答复需要报告,或提出“给我报告”“生成 HTML 报告”等请求时,才再次调用
scripts\run.ps1 -IncludeReport。报告只展示管理摘要、风险分类、重点异常和处理建议,
不重复展开全部发票;回复中同时返回 artifacts.report_md.path 或
artifacts.report_html.path,以及完整发票表格和商品明细表路径。
Safety Rules
- Never upload invoice files or OCR text to a remote service.
- Never invent invoice numbers, dates, vendors, currency, totals, or tax values.
- Preserve the source value and add a warning when a field is ambiguous.
- Treat money fields as high risk. Export only records that pass validation or
are explicitly marked
needs_review. - Do not pay vendors, send emails, or write to an ERP/accounting system.
- Keep logs free of full invoice contents and personal identifiers.
Result Contract
Return:
records.json: one structured record per source file;invoices.csv: one row per invoice;line_items.csv: extracted line items;handoff.json: complete handoff groups for human review, rule blocks, and failed-file retries;review_queue.csv: complete pending-human-review checklist;blocked_queue.csv: complete rule-block checklist;retry_queue.csv: complete failed-file retry checklist;- when status classification is requested,
按状态分类/contains copied originals, andstatus_classification.csv/status_classification.jsonrecord the copy result; report.md: a concise text review report, only when requested;report.html: a local browser-readable management dashboard, only when requested;summary: processed, approved, needs-review, blocked, and failed counts.summary_zh: Chinese labels for the summary shown to users.preview: a bounded Chinese first-response summary for blocked, needs-review, and failed records (at most 10 per category by default).artifacts: paths for the complete records, invoice table, line-item table, summary data, and optional report files. Use these paths in the user-facing reply.report_generated: whether the optional human-readable report was generated.文件分类: classification result when the user explicitly requested status folders, otherwisenull.audit: audit version and the exact validation scope used for this run.
Machine-readable status and warning code values remain stable English
identifiers. User-facing outputs also include Chinese status_label, warning
label, Chinese warning messages, and Chinese CSV/report headings.
When replying to the user, prefer summary_zh and the Chinese labels; expose
the English codes only when the user asks for technical diagnostics.
The handoff lists preserve the issue type, suggested handler, required materials, next step, and whether the Skill can automatically handle the issue. The Skill does not approve expenses, release holds, contact suppliers, write to ERP, or pay vendors. Cross-batch comparison is intentionally left to the host Agent using the generated CSV files.
audit.校验详情 explicitly records which checks ran. The current Skill performs
local OCR, extraction, deterministic field/amount/duplicate/confidence checks;
external invoice authenticity or signature verification and ERP/procurement/
receipt matching are recorded as not executed.
The CSV/JSON files are the complete row-level audit data. The optional Markdown report is a text summary; the HTML report is a local visual dashboard. Both are management summaries and must not repeat every invoice row.
Review Semantics
needs_review: extracted but requires human confirmation;approved: rules passed; this does not mean financial approval or permission to pay;blocked: required information is missing or a serious consistency check failed;failed: the file could not be processed.
The current MVP intentionally uses local text/sidecar extraction in tests and a pluggable OCR boundary. A real OpenVINO model adapter must keep the same result schema and evidence contract.
Scan to join WeChat group