## 问题 / Problem 真机三轮整理实测:Agent 全部写出 `报告/整理报告-<运行日期>.md`,而技能里只定义了 `报告/<YYYY-MM>.md`。 **原因不是模型不听话。** 测试范围跨了 2020-08 到 2024-09 共十几个月,`<YYYY-MM>` 在多月场景下无从填写——技能没给出这种情况的文件名,Agent 只能自己发明一个。 **后果不是难看,而是会攒垃圾。** `invoice-automation` 的定时任务每月重建的是 `报告/<上月 YYYY-MM>.md`;与按运行日期命名的手工报告永远不会互相覆盖,用户目录里会留下一堆内容重叠、无从分辨新旧的报告。 Three real-machine runs all produced `报告/整理报告-<run date>.md`, while the skills only define `报告/<YYYY-MM>.md`. The runs spanned 2020-08 through 2024-09, so `<YYYY-MM>` was unfillable and the agent improvised. Because the scheduled monthly job rebuilds `报告/<last month YYYY-MM>.md`, the two naming schemes never overwrite each other and the user's directory accumulates overlapping reports with no way to tell which is current. ## 改动 / Changes - `invoice-workflow` 第 7 步补一张表,把两种文件名钉死: | 本次覆盖 | 文件名 | 例 | | --- | --- | --- | | 恰好一个自然月 | `报告/<YYYY-MM>.md` | `报告/2024-08.md` | | 跨多个月 | `报告/<起始 YYYY-MM>_<结束 YYYY-MM>.md` | `报告/2020-08_2024-09.md` | 并写明月份按**开票日期**归属(与台账同口径)、同名直接覆盖(报告是从 `.index/ledger.json` 全量重建的派生产物,不像台账需要先备份)、以及**为什么不许用运行日期命名** - `invoice-ledger` 与 `references/月度报告模板.md` 同步该约定 - 目录布局示例与中英 USAGE 一并标注跨月形态 ## 为什么不在本 PR 里 bump 版本 / Why no version bump here `contentSource` 的 `ref` 必须 pin 到**已合并的 commit**,本 PR 合并前拿不到那个 SHA。先 bump 版本会让目录声称 1.0.1、却仍按指向 1.0.0 内容的 pin 去取文件——比不 bump 更糟。版本号、pin 与 changelog 留到后续 PR 一起改。 The `contentSource` ref must pin to an already-merged commit, which does not exist until this PR lands. Bumping the version now would advertise 1.0.1 while still serving 1.0.0 content. Version, pin and changelog follow in a second PR. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- ## 追加:台账四张表必须全建 / Also: all four ledger sheets must always exist 真机压测(只有 1 张发票)产出的 `台账.xlsx` **只有三张表**——Agent 判定「按销售方汇总」在单一销售方下冗余而略过: ``` 发票测试(23 张) → ['明细', '月度汇总', '按销售方汇总', '异常'] 发票压测(1 张) → ['明细', '月度汇总', '异常'] ← 少一张 ``` 技能写的是「四张表,顺序固定」,但没说「即使为空也必须存在」。台账是要被重复重建、被用户自己写公式引用、被下一次整理覆盖的产物;表的位置一旦随数据量浮动,「第 3 张是按销售方汇总」这类引用就会在下个月悄悄指错。已在 `invoice-ledger` 里把这条钉死。 A stress run with a single invoice produced only three sheets — the agent judged the per-seller summary redundant. The skill said "four sheets, fixed order" but never said "even when empty". Sheet positions that float with row count silently break user formulas and rebuilds; now pinned.
7.6 KiB
Invoice Organizer · Usage
Check three things before installing
1. A mailbox is connected. This is the only step that requires you: authorize an account (Gmail, Outlook or IMAP) in the DesireCore mail interface. Without one, the Agent can still parse files you drop into its work directory yourself, but the collection step is unavailable.
2. There is a work directory you can actually find. After installation the Agent automatically receives a default workspace, but that path is hard to locate in a file manager. On the first conversation it will suggest registering a visible directory (for example ~/Documents/invoices) and making it primary — just agree. Deliverables land there and appear in DesireCore's file workbench.
3. It does not verify invoice authenticity. No official verification channel is available to it. It performs format and arithmetic checks only (required fields present, amounts reconcile, the document is internally consistent) and hands you the State Taxation Administration's national VAT invoice verification platform so you can check the number yourself. If verification is what you need, this Agent is not the answer.
How to use it
Once installed, just say what you want in plain language:
- "Sort out August's invoices" — the full pipeline: intake, extraction, dedupe, archive, ledger, report
- "How much is this month's spend?" — summary only, no mailbox re-scan
- "Have I already recorded this invoice?" — an index lookup, answered immediately
- "Export August's invoices to Excel" — rebuilds the ledger from the index without re-parsing anything
- "From now on, post new invoices automatically" — sets up the mail rule and the scheduled job, after explaining exactly what will happen
Relative dates like "last month" are converted to explicit start and end dates and read back to you before any work starts — that one step avoids most year-boundary mistakes.
What you get
One new directory under your work directory:
发票/ (invoices)
├── 台账.xlsx (ledger; 台账.csv when the xlsx dependencies are unavailable)
├── 报告/2024-08.md (reports; invoices spanning months write 报告/2020-08_2024-09.md)
├── 归档/2024/08/20240815_<seller>_1959.98_24312000000000020002.pdf (archive, by year/month)
├── _inbox/ downloaded, not yet processed
├── _quarantine/ parse failures and non-invoices, each with a .reason.txt
└── .index/ dedupe index — do not edit by hand
The directory and file names are Chinese, matching the invoices themselves; the English glosses above
are only for reading this page. Look for 发票/ under your work directory.
The ledger has four sheets: line items, monthly summary, per-seller summary, and exceptions. Amounts follow RMB conventions (two decimal places always; a zero-amount invoice shows as ¥0.00 rather than being hidden), and invoice numbers and tax IDs are stored as text so Excel cannot turn them into 2.4312E+19.
Every monthly report opens with a one-line conclusion before any detail, and each entry under "needs your attention" carries a concrete action rather than just a description.
Documents it handles
- PDF: fully digital VAT e-invoices (the nationwide platform format used since 2023, both ordinary and special), legacy VAT electronic ordinary invoices, railway e-ticket reimbursement vouchers (both the old and new layouts), air transport e-ticket itineraries, taxi and ride-hailing receipts
- OFD: reads the structured invoice data carried inside the package. A 2020-style invoice ships a complete national-standard invoice XML in the package — those values are written by the issuing system rather than guessed from the layout, so that path gets full confidence. A 2024 fully-digital invoice carries only invoice tags, which cannot supply the invoice code or the per-line item breakdown; those are recovered from the layout text and confidence is lowered to match. When neither is present it falls back to layout text
- Scans and images: JPG, PNG, WebP, and scanned PDFs with no text layer, handed to the vision model with confidence lowered accordingly
None of this requires you to install anything. Only the .xlsx ledger may need Python with openpyxl and pandas; when they are missing it writes a UTF-8 BOM CSV instead (so non-Latin text opens correctly in Excel) and tells you it degraded.
About approvals (read this before expecting unattended runs)
Organizing invoices calls confirmation-gated tools constantly — reading the mailbox, downloading attachments, writing files — and under the default approval mode each call raises an approval card. Processing a few dozen invoices raises a lot of them in a row. That is by design, not a fault.
If you want genuinely unattended operation (a ledger built overnight on a schedule, new mail posted automatically), you need to switch this Agent's execution-approval mode to allow-all in its settings. The cost is that its file writes and mail calls stop asking each time. Note that the "always allow" button does not currently take effect for these tools — pressing it will not stop the cards.
What it will not do
- Never deletes, moves or forwards your mail. Mailbox cleanup stays with you
- No accounting entries, no tax filing, no input-tax-credit judgements
- No currency conversion. A foreign-currency settlement is still priced in RMB on the face of the invoice; the original amount and the rate used are copied verbatim into the notes, never converted and never totalled separately
- Never merges suspected duplicates on its own (numbers differing by one digit with every other field identical); they are listed for you to decide
- Never invents invoice fields. Whatever cannot be extracted is left empty, the original is quarantined, and the reason is stated
- Never claims to have found everything, only that within the stated range it found N candidate messages and successfully parsed M invoices
Known limits
- On IMAP accounts, mail rules only cover the inbox. If you are on IMAP and your invoice mail is auto-filed into another folder, the rule will not fire; in that case ask the Agent in conversation to scan that folder. Gmail and Outlook poll the whole mailbox and are not affected
- The local cached search matches keywords against the subject only. Mail whose subject never says "invoice" and only mentions it in the body ("You have a new electronic voucher") will not surface that way. On Gmail the Agent switches to Gmail's own server-side search, which does cover bodies; on Outlook and IMAP it has to pull the messages locally and scan them one by one, which is slower over a wide range. It states in its summary which of the two it used
- Outlook and IMAP have no server-side search, so messages must be pulled locally before filtering. Over a wide range that is noticeably slower than Gmail, where the native search syntax narrows the set in one call
- Password-protected PDFs cannot be opened. Some invoicing platforms send them with the password in the message body. For now you need to decrypt the file yourself and drop it into
_inbox/, and the next run will pick it up - Void detection relies on the text layer. A void stamp that exists only as an image may go undetected. Void invoices get their own column in the ledger — worth a glance
Privacy
Invoices carry company names, taxpayer IDs, bank accounts and travel details. All of it stays in your local work directory and ledger. This Agent has no outbound channel and never replies to or forwards mail on your behalf; when you want to send the ledger to someone, it hands the file back to you and you decide where it goes.