weaver-work-cli 0.1.60 → 0.1.62

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. package/dist/chunks/{archive-4SQAVTIB.js → archive-S2VKZWQ3.js} +2 -2
  2. package/dist/chunks/{archive-oa-W2UEJ67L.js → archive-oa-HEDSIUUY.js} +2 -2
  3. package/dist/chunks/{asset-EGZEABBI.js → asset-HYH4W357.js} +2 -2
  4. package/dist/chunks/{asset-idle-EBUZBB6M.js → asset-idle-N7REBNGL.js} +2 -2
  5. package/dist/chunks/{attachment-content-I6WHKGR2.js → attachment-content-VYYA75FR.js} +3 -3
  6. package/dist/chunks/{blog-2YKMWOWI.js → blog-SLMZZICV.js} +2 -2
  7. package/dist/chunks/{caizhilian-5NM4X5HG.js → caizhilian-RV43KKBT.js} +4 -4
  8. package/dist/chunks/{calendar-H4QTJCUY.js → calendar-DMVZ4OLY.js} +2 -2
  9. package/dist/chunks/{chunk-VLL6JOB4.js → chunk-6XSSAUNW.js} +4 -4
  10. package/dist/chunks/{chunk-VQWPQTEY.js → chunk-BIA2NKUG.js} +4 -4
  11. package/dist/chunks/{chunk-VMCCRWFO.js → chunk-BQYX2UX5.js} +2 -2
  12. package/dist/chunks/{chunk-XF7S6FQW.js → chunk-DTCQFTHW.js} +1 -1
  13. package/dist/chunks/{chunk-CPG6NLN4.js → chunk-E5YD5JWR.js} +1 -1
  14. package/dist/chunks/{chunk-PH7N4UFT.js → chunk-EGANE35F.js} +1 -1
  15. package/dist/chunks/{chunk-Z4IPY5GV.js → chunk-H6YOMI3U.js} +2 -2
  16. package/dist/chunks/{chunk-HHH4K3YY.js → chunk-ILALC2N6.js} +1 -1
  17. package/dist/chunks/{chunk-WINR2Q6K.js → chunk-KXJA42EA.js} +86 -19
  18. package/dist/chunks/{chunk-CQ4OVCKG.js → chunk-KY3R42RS.js} +2 -2
  19. package/dist/chunks/{chunk-WVH5ESDA.js → chunk-NRYDJN4J.js} +1 -1
  20. package/dist/chunks/{chunk-TGM7BWEH.js → chunk-P6TXQK75.js} +2 -2
  21. package/dist/chunks/{chunk-6YWHRXEQ.js → chunk-QBDXJS2W.js} +119 -9
  22. package/dist/chunks/{chunk-2IGZUMNG.js → chunk-SHX7XBYR.js} +180 -18
  23. package/dist/chunks/{chunk-P7RXQDCA.js → chunk-T2KVJFWJ.js} +4 -4
  24. package/dist/chunks/{chunk-FMNCSYIG.js → chunk-TEZHIB6T.js} +2 -2
  25. package/dist/chunks/{chunk-HMIIVM2L.js → chunk-UBGWIXU3.js} +97 -45
  26. package/dist/chunks/{chunk-5N222HK6.js → chunk-UBRWONP4.js} +2 -2
  27. package/dist/chunks/{chunk-7U5YHCW7.js → chunk-UQFPF4EX.js} +2 -2
  28. package/dist/chunks/{chunk-4GG72JAT.js → chunk-V2LASYKO.js} +2 -2
  29. package/dist/chunks/{chunk-BDBTZVYA.js → chunk-VBFBMM7G.js} +55 -55
  30. package/dist/chunks/{chunk-YHSOCGKO.js → chunk-VNYOUAWV.js} +11 -11
  31. package/dist/chunks/{chunk-SFM3M2L3.js → chunk-WIWDVETN.js} +19 -3
  32. package/dist/chunks/{chunk-44KJ7WFA.js → chunk-XT77MP54.js} +2 -2
  33. package/dist/chunks/{chunk-JFKMPRZB.js → chunk-YI2YMW5N.js} +50 -3
  34. package/dist/chunks/{conflict-QMDLS2EW.js → conflict-GFJRS6I7.js} +2 -2
  35. package/dist/chunks/{contract-LLRKMLQQ.js → contract-U3ZGNRWB.js} +2 -2
  36. package/dist/chunks/{cowork-2RDFBZWB.js → cowork-EX7PKIDK.js} +2 -2
  37. package/dist/chunks/{create-flow-5ODJ7WJO.js → create-flow-EJZD434E.js} +6 -6
  38. package/dist/chunks/{data-LVDFIRNG.js → data-FOODGAMF.js} +278 -121
  39. package/dist/chunks/{ebuilder-form-7WA6X6ZI.js → ebuilder-form-I2EOKODG.js} +3 -3
  40. package/dist/chunks/{ehr-52GBKNJR.js → ehr-TE4RFNID.js} +2 -2
  41. package/dist/chunks/{entry-mode-73BJML22.js → entry-mode-ZOLSXEGX.js} +9 -5
  42. package/dist/chunks/{env-OHFS76HV.js → env-TID5NFR6.js} +2 -2
  43. package/dist/chunks/{esb-HJSXCEOM.js → esb-7L6MHYLB.js} +4 -4
  44. package/dist/chunks/{factory-FRTA2LP4.js → factory-OG7BPMH5.js} +1 -1
  45. package/dist/chunks/{fna-OBACRT3J.js → fna-6V2ENR3Y.js} +2 -2
  46. package/dist/chunks/{group-chat-KBFRPCR2.js → group-chat-5DKPWIHL.js} +3 -3
  47. package/dist/chunks/{host-TTSGY5NZ.js → host-3DLYA54R.js} +3 -3
  48. package/dist/chunks/{host-KJT3G5D2.js → host-GOJHHTPY.js} +3 -3
  49. package/dist/chunks/{host-KOWUMNAY.js → host-OGBHL75G.js} +3 -3
  50. package/dist/chunks/{host-MFXRA2MY.js → host-ONZC6AE7.js} +3 -3
  51. package/dist/chunks/{host-W4JCNRFS.js → host-TJ5VVHM7.js} +3 -3
  52. package/dist/chunks/{host-2BKMPWDH.js → host-VTPAWDZV.js} +3 -3
  53. package/dist/chunks/{hrm-AK3WGBMN.js → hrm-2N7NFQDZ.js} +3 -3
  54. package/dist/chunks/{im-JZSBPO4Z.js → im-XCH47ZBN.js} +3 -3
  55. package/dist/chunks/{invoice-6XDMPCWB.js → invoice-5KJ7T774.js} +198 -331
  56. package/dist/chunks/{jiuchuanhui-K4EQU6GK.js → jiuchuanhui-PL6DRPBM.js} +2 -2
  57. package/dist/chunks/{lazy-dispatch-GCA6HDOB.js → lazy-dispatch-UATEN7H7.js} +5 -5
  58. package/dist/chunks/{mail-IKVCQCVZ.js → mail-Q7Z4CQ4D.js} +2 -2
  59. package/dist/chunks/{meeting-ARHVWK7G.js → meeting-5E3BNARL.js} +13 -13
  60. package/dist/chunks/{minute-doc-547KSYKR.js → minute-doc-NXRE5C77.js} +4 -4
  61. package/dist/chunks/{okr-KV43FPPX.js → okr-3O3XNYOK.js} +2 -2
  62. package/dist/chunks/{operations-6NXJ7RTE.js → operations-EZWG72FH.js} +4 -4
  63. package/dist/chunks/performance-Y7CPNSOR.js +1295 -0
  64. package/dist/chunks/{plan-WOYR4WEG.js → plan-BLGPZF5M.js} +2 -2
  65. package/dist/chunks/{project-CQJKBUIL.js → project-6MZMLJMP.js} +2 -2
  66. package/dist/chunks/{reception-MPBU3JXC.js → reception-F2VT2X52.js} +2 -2
  67. package/dist/chunks/{recruit-stage-USTTRHOX.js → recruit-stage-4ETIBMIW.js} +2 -2
  68. package/dist/chunks/{registry-GURQG4ZV.js → registry-3FYSWV3U.js} +3 -3
  69. package/dist/chunks/{registry-SS5J2FZQ.js → registry-7RS74TCK.js} +4 -4
  70. package/dist/chunks/{registry-H5HQ5QNH.js → registry-I4DVPDMU.js} +11 -11
  71. package/dist/chunks/{room-recommend-3UBROMZE.js → room-recommend-GWCVKCXW.js} +4 -4
  72. package/dist/chunks/{schedule-FTUQML6O.js → schedule-6AN63MJQ.js} +4 -4
  73. package/dist/chunks/{smart-extract-APX2PNIN.js → smart-extract-SR4SJJKN.js} +3 -3
  74. package/dist/chunks/{workflow-WMPW3WSB.js → workflow-KF7FA2UQ.js} +7 -7
  75. package/dist/cmd/refs/index.js +124 -4
  76. package/dist/core/output.js +199 -26
  77. package/dist/core/refs.js +36 -0
  78. package/dist/index.js +38 -33
  79. package/dist/internal/e10/auth/xiaoe.js +25 -3
  80. package/dist/shortcuts/caizhilian/operations/files.js +86 -15
  81. package/dist/shortcuts/data/index.js +12 -2
  82. package/dist/shortcuts/data/manifest.js +4 -2
  83. package/dist/shortcuts/data/operations/attribution.js +229 -0
  84. package/dist/shortcuts/data/operations/ds.js +87 -90
  85. package/dist/shortcuts/data/operations/index.js +3 -1
  86. package/dist/shortcuts/index.js +5 -0
  87. package/dist/shortcuts/invoice/manifest.js +30 -62
  88. package/dist/shortcuts/invoice/operations/registry.js +2 -2
  89. package/dist/shortcuts/invoice/operations/reim-customer.js +111 -0
  90. package/dist/shortcuts/invoice/operations/shared.js +0 -204
  91. package/dist/shortcuts/meeting/operations/eb/create-flow.js +84 -16
  92. package/dist/shortcuts/meeting/operations/eb/entry-mode.js +61 -7
  93. package/dist/shortcuts/performance/continuation.js +74 -0
  94. package/dist/shortcuts/performance/errors.js +65 -0
  95. package/dist/shortcuts/performance/host.js +105 -0
  96. package/dist/shortcuts/performance/index.js +109 -0
  97. package/dist/shortcuts/performance/manifest.js +30 -0
  98. package/dist/shortcuts/performance/operations/hrm-resolve.js +114 -0
  99. package/dist/shortcuts/performance/operations/registry.js +44 -0
  100. package/dist/shortcuts/performance/operations/scheme-detail.js +70 -0
  101. package/dist/shortcuts/performance/operations/scheme-draft.js +116 -0
  102. package/dist/shortcuts/performance/operations/scheme-publish.js +158 -0
  103. package/dist/shortcuts/performance/operations/types.js +32 -0
  104. package/dist/shortcuts/performance/scheme-validate.js +307 -0
  105. package/dist/shortcuts/performance/shared.js +158 -0
  106. package/docs/agent-invoice.md +1 -1
  107. package/docs/agent-io-channel-design.md +67 -3
  108. package/docs/data.md +2 -1
  109. package/docs/invoice.md +0 -2
  110. package/package.json +1 -1
  111. package/scripts/xiaoe_env.py +6 -1
  112. package/skill-template/business-info.json +19 -0
  113. package/skill-template/domains/performance.md +18 -0
  114. package/skill-template/domains/yepiaotong.md +0 -1
  115. package/skills/weaver-e10-caizhilian/SKILL.md +1 -1
  116. package/skills/weaver-e10-data/references/datasource.md +2 -1
  117. package/skills/weaver-e10-meeting/SKILL.md +5 -3
  118. package/skills/weaver-e10-performance/SKILL.md +202 -0
  119. package/skills/weaver-e10-performance/agents/openai.yaml +74 -0
  120. package/skills/weaver-e10-performance/references/default-assembly.md +108 -0
  121. package/skills/weaver-e10-performance/references/entity-resolution.md +69 -0
  122. package/skills/weaver-e10-performance/references/enums-and-normalization.md +80 -0
  123. package/skills/weaver-e10-performance/references/examples.md +146 -0
  124. package/skills/weaver-e10-performance/references/extraction-guide.md +144 -0
  125. package/skills/weaver-e10-performance/references/scheme-edit-req-fields.md +185 -0
  126. package/skills/weaver-e10-performance/references/scheme-setting-page.md +62 -0
  127. package/skills/weaver-e10-performance/scripts/parse_appraisal_doc.py +483 -0
  128. package/skills/weaver-e10-shared/references/json-output-contract.md +5 -0
  129. package/skills/weaver-e10-yepiaotong/SKILL.md +16 -9
  130. package/skills/weaver-e10-yepiaotong/references/invoice-reim-relation.md +9 -7
  131. package/skills/weaver-e10-yepiaotong/references/invoice-reim.md +15 -11
  132. package/skills/weaver-e10-yepiaotong/references/reim-api-reference.md +29 -25
  133. package/skills/weaver-e10-yepiaotong/references/reim-customer-search.md +89 -0
  134. package/skills/weaver-e10-yepiaotong/references/reim-examples.md +35 -37
  135. package/skills/weaver-e10-yepiaotong/references/reim-form-fill-rules.md +66 -63
  136. package/skills/weaver-e10-yepiaotong/references/reim-workflow.md +50 -71
  137. package/skills/weaver-e10-yepiaotong/references/source-manifest.json +34 -95
  138. package/dist/shortcuts/invoice/operations/browse-field.js +0 -17
  139. package/skills/weaver-e10-yepiaotong/references/invoice-browse-field-data.md +0 -204
@@ -0,0 +1,483 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+ """考核文档解析:doc / docx / xls / xlsx / pdf -> Markdown(保留标题层级与表格)。
4
+
5
+ 用法:
6
+ python3 parse_appraisal_doc.py <文件路径> [-o 输出.md]
7
+
8
+ 注意: 本脚本文件名刻意避开宿主内置 parse_document 工具名,调用方必须通过
9
+ shell 执行本脚本,不要改用宿主内置文档解析工具(无表格编号/标题层级输出)。
10
+
11
+ 依赖策略(自动降级):
12
+ docx: python-docx -> 无则用标准库 zipfile+XML 解析
13
+ xlsx: openpyxl -> 无则用标准库 zipfile+XML 解析
14
+ pdf : pdfplumber -> 无则尝试系统 pdftotext 命令(表格保真度下降)
15
+ doc : LibreOffice(soffice) 转 docx 后解析 -> 无则 macOS textutil 转 html 解析(标题层级可能丢失)
16
+ xls : xlrd -> 无则 LibreOffice(soffice) 转 xlsx 后解析
17
+
18
+ 输出约定:
19
+ - 标题按原文层级输出 #/##/###
20
+ - 表格输出为 Markdown 管道表并编号(表1、表2…),供后续引用
21
+ - pdf 每页前输出 "--- 第N页 ---" 分隔
22
+ """
23
+ import argparse
24
+ import os
25
+ import re
26
+ import subprocess
27
+ import sys
28
+ import unicodedata
29
+ import zipfile
30
+
31
+
32
+ def nfc(s):
33
+ """文本归一化:PDF/Word 提取常见两类问题——
34
+ 1) 组合字符序列 → NFC 合成;
35
+ 2) 康熙部首/CJK 部首(⼼U+2FBD 等)混入正文 → 需逐字符 NFKC 映射回统一汉字(⼼→心)。
36
+ 只对部首区段做 NFKC,避免全文 NFKC 破坏全角标点等合法字符。"""
37
+ s = unicodedata.normalize("NFC", s)
38
+ out = []
39
+ for ch in s:
40
+ cp = ord(ch)
41
+ if 0x2E80 <= cp <= 0x2FDF:
42
+ out.append(unicodedata.normalize("NFKC", ch))
43
+ else:
44
+ out.append(ch)
45
+ return "".join(out)
46
+
47
+
48
+ def out(s=""):
49
+ sys.stdout.write(s + "\n")
50
+
51
+
52
+ def md_table(rows):
53
+ """rows: [[c1,c2..], ...] -> markdown 表格文本"""
54
+ if not rows:
55
+ return ""
56
+ lines = []
57
+ lines.append("| " + " | ".join(c.replace("\n", " ").replace("|", "\\|") for c in rows[0]) + " |")
58
+ lines.append("|" + "---|" * len(rows[0]))
59
+ for r in rows[1:]:
60
+ lines.append("| " + " | ".join(c.replace("\n", " ").replace("|", "\\|") for c in r) + " |")
61
+ return "\n".join(lines)
62
+
63
+
64
+ # ---------------------------------------------------------------- docx
65
+ def parse_docx(path):
66
+ try:
67
+ import docx # python-docx
68
+ return _parse_docx_lib(path)
69
+ except ImportError:
70
+ return _parse_docx_stdlib(path)
71
+
72
+
73
+ def _heading_level(style_name):
74
+ if not style_name:
75
+ return 0
76
+ m = re.match(r"^(?:Heading|标题)\s*(\d)", style_name, re.IGNORECASE)
77
+ return int(m.group(1)) if m else 0
78
+
79
+
80
+ def _docx_style_names(z):
81
+ """解析 styles.xml 得到 styleId -> 样式名 映射。
82
+ 中文版 Word 的标题样式 styleId 常是数字(如 val="2" 即'标题 2'),
83
+ 必须经 styles.xml 换算成样式名再判断标题级别。"""
84
+ names = {}
85
+ try:
86
+ import xml.etree.ElementTree as ET
87
+ W = "{http://schemas.openxmlformats.org/wordprocessingml/2006/main}"
88
+ root = ET.fromstring(z.read("word/styles.xml"))
89
+ for st in root.findall(W + "style"):
90
+ sid = st.get(W + "styleId")
91
+ nm = st.find(W + "name")
92
+ if sid and nm is not None:
93
+ names[sid] = nm.get(W + "val", "")
94
+ except (KeyError, Exception):
95
+ pass
96
+ return names
97
+
98
+
99
+ def _parse_docx_lib(path):
100
+ import docx
101
+ d = docx.Document(path)
102
+ table_no = 0
103
+ parts = []
104
+ # 按 body 顺序遍历段落与表格
105
+ from docx.table import Table
106
+ from docx.text.paragraph import Paragraph
107
+ body = d.element.body
108
+ for child in body.iterchildren():
109
+ tag = child.tag.split("}")[-1]
110
+ if tag == "p":
111
+ p = Paragraph(child, d)
112
+ text = nfc(p.text.strip())
113
+ if not text:
114
+ continue
115
+ lvl = _heading_level(p.style.name if p.style is not None else "")
116
+ parts.append(("#" * lvl + " " + text) if lvl else text)
117
+ elif tag == "tbl":
118
+ t = Table(child, d)
119
+ table_no += 1
120
+ rows = []
121
+ for row in t.rows:
122
+ rows.append([nfc(c.text.strip()) for c in row.cells])
123
+ parts.append("**表%d**\n\n%s" % (table_no, md_table(rows)))
124
+ return "\n\n".join(parts)
125
+
126
+
127
+ def _parse_docx_stdlib(path):
128
+ import xml.etree.ElementTree as ET
129
+ W = "{http://schemas.openxmlformats.org/wordprocessingml/2006/main}"
130
+ with zipfile.ZipFile(path) as z:
131
+ style_names = _docx_style_names(z)
132
+ xml = z.read("word/document.xml")
133
+ root = ET.fromstring(xml)
134
+ body = root.find(W + "body")
135
+ table_no = 0
136
+ parts = []
137
+ for child in body:
138
+ tag = child.tag.split("}")[-1]
139
+ if tag == "p":
140
+ text = nfc("".join(t.text or "" for t in child.iter(W + "t")).strip())
141
+ if not text:
142
+ continue
143
+ style = child.find(W + "pPr/" + W + "pStyle")
144
+ lvl = 0
145
+ if style is not None:
146
+ # styleId 先经 styles.xml 换算样式名,无映射时按 "HeadingN" 直判
147
+ lvl = _heading_level(style_names.get(style.get(W + "val", "")) or style.get(W + "val", ""))
148
+ parts.append(("#" * lvl + " " + text) if lvl else text)
149
+ elif tag == "tbl":
150
+ table_no += 1
151
+ rows = []
152
+ for tr in child.findall(W + "tr"):
153
+ cells = []
154
+ for tc in tr.findall(W + "tc"):
155
+ cells.append(nfc("".join(t.text or "" for t in tc.iter(W + "t")).strip()))
156
+ rows.append(cells)
157
+ parts.append("**表%d**\n\n%s" % (table_no, md_table(rows)))
158
+ return "\n\n".join(parts)
159
+
160
+
161
+ # ---------------------------------------------------------------- xlsx
162
+ def parse_xlsx(path):
163
+ try:
164
+ import openpyxl
165
+ return _parse_xlsx_lib(path)
166
+ except ImportError:
167
+ return _parse_xlsx_stdlib(path)
168
+
169
+
170
+ def _parse_xlsx_lib(path):
171
+ import openpyxl
172
+ wb = openpyxl.load_workbook(path, data_only=True)
173
+ parts = []
174
+ for ws in wb.worksheets:
175
+ parts.append("## Sheet: %s" % ws.title)
176
+ rows = []
177
+ for row in ws.iter_rows(values_only=True):
178
+ cells = ["" if c is None else str(c).strip() for c in row]
179
+ # 去掉行尾空单元格
180
+ while cells and cells[-1] == "":
181
+ cells.pop()
182
+ if cells:
183
+ rows.append(cells)
184
+ if rows:
185
+ parts.append(md_table(rows))
186
+ else:
187
+ parts.append("(空 sheet)")
188
+ return "\n\n".join(parts)
189
+
190
+
191
+ def _col_index(ref):
192
+ """A1 -> 0, B5 -> 1"""
193
+ n = 0
194
+ for ch in ref:
195
+ if ch.isalpha():
196
+ n = n * 26 + (ord(ch.upper()) - 64)
197
+ else:
198
+ break
199
+ return n - 1
200
+
201
+
202
+ def _parse_xlsx_stdlib(path):
203
+ import xml.etree.ElementTree as ET
204
+ NS = "{http://schemas.openxmlformats.org/spreadsheetml/2006/main}"
205
+ RNS = "{http://schemas.openxmlformats.org/officeDocument/2006/relationships}"
206
+ with zipfile.ZipFile(path) as z:
207
+ shared = []
208
+ if "xl/sharedStrings.xml" in z.namelist():
209
+ sroot = ET.fromstring(z.read("xl/sharedStrings.xml"))
210
+ for si in sroot.findall(NS + "si"):
211
+ shared.append("".join(t.text or "" for t in si.iter(NS + "t")))
212
+ wb = ET.fromstring(z.read("xl/workbook.xml"))
213
+ rels = ET.fromstring(z.read("xl/_rels/workbook.xml.rels"))
214
+ rel_map = {r.get("Id"): r.get("Target") for r in rels}
215
+ parts = []
216
+ for sheet in wb.find(NS + "sheets"):
217
+ name = sheet.get("name")
218
+ rid = sheet.get(RNS + "id")
219
+ target = rel_map.get(rid, "")
220
+ if target.startswith("/"):
221
+ target = target[1:]
222
+ elif not target.startswith("xl/"):
223
+ target = "xl/" + target
224
+ if target not in z.namelist():
225
+ continue
226
+ parts.append("## Sheet: %s" % name)
227
+ sroot = ET.fromstring(z.read(target))
228
+ rows = []
229
+ for r in sroot.iter(NS + "row"):
230
+ cells_by_idx = {}
231
+ for c in r.findall(NS + "c"):
232
+ idx = _col_index(c.get("r", "A1"))
233
+ v = c.find(NS + "v")
234
+ txt = ""
235
+ if v is not None and v.text is not None:
236
+ if c.get("t") == "s":
237
+ txt = shared[int(v.text)]
238
+ else:
239
+ txt = v.text
240
+ elif c.get("t") == "inlineStr":
241
+ is_el = c.find(NS + "is")
242
+ if is_el is not None:
243
+ txt = "".join(t.text or "" for t in is_el.iter(NS + "t"))
244
+ cells_by_idx[idx] = (txt or "").strip()
245
+ if cells_by_idx:
246
+ width = max(cells_by_idx) + 1
247
+ rows.append([cells_by_idx.get(i, "") for i in range(width)])
248
+ if rows:
249
+ parts.append(md_table(rows))
250
+ else:
251
+ parts.append("(空 sheet)")
252
+ return "\n\n".join(parts)
253
+
254
+
255
+ # ---------------------------------------------------------------- pdf
256
+ def parse_pdf(path):
257
+ try:
258
+ import pdfplumber
259
+ except ImportError:
260
+ return _parse_pdf_pdftotext(path)
261
+ parts = []
262
+ with pdfplumber.open(path) as pdf:
263
+ for i, page in enumerate(pdf.pages, 1):
264
+ parts.append("--- 第%d页 ---" % i)
265
+ tables = [[nfc(str(c)) if c is not None else "" for c in r] for t in (page.extract_tables() or []) if t for r in t]
266
+ page_text = nfc(page.extract_text() or "")
267
+ lines = []
268
+ for ln in page_text.splitlines():
269
+ if not ln.strip() or ln.strip() not in tables:
270
+ lines.append(ln)
271
+ parts.append("\n".join(lines))
272
+ table_no = 0
273
+ for t in (page.extract_tables() or []):
274
+ if not t:
275
+ continue
276
+ table_no += 1
277
+ parts.append("**表%d(第%d页)**\n\n%s" % (
278
+ table_no, i, md_table([[nfc(str(c)) if c is not None else "" for c in r] for r in t])))
279
+ return "\n\n".join(parts)
280
+
281
+
282
+ def _parse_pdf_pdftotext(path):
283
+ try:
284
+ r = subprocess.run(["pdftotext", "-layout", path, "-"], capture_output=True, timeout=120)
285
+ if r.returncode != 0:
286
+ raise RuntimeError(r.stderr.decode("utf-8", "ignore"))
287
+ text = r.stdout.decode("utf-8", "ignore")
288
+ if not text.strip():
289
+ raise RuntimeError("empty text(可能是扫描件)")
290
+ return text + "\n\n(注:本 pdf 由 pdftotext 解析,表格结构可能失真,请人工核对指标表格)"
291
+ except FileNotFoundError:
292
+ raise RuntimeError("解析 pdf 需要安装 pdfplumber(pip3 install pdfplumber)或系统 pdftotext(poppler)")
293
+
294
+
295
+ # ---------------------------------------------------------------- doc / xls(旧版二进制格式)
296
+ import shutil
297
+ import tempfile
298
+
299
+
300
+ def _convert_via_soffice(path, target_ext):
301
+ """LibreOffice 无头转换 doc->docx / xls->xlsx;失败返回 None。"""
302
+ soffice = shutil.which("soffice") or shutil.which("libreoffice")
303
+ if not soffice:
304
+ return None
305
+ with tempfile.TemporaryDirectory() as td:
306
+ try:
307
+ r = subprocess.run(
308
+ [soffice, "--headless", "--convert-to", target_ext, "--outdir", td, path],
309
+ capture_output=True, timeout=180)
310
+ except (OSError, subprocess.TimeoutExpired):
311
+ return None
312
+ if r.returncode != 0:
313
+ return None
314
+ base = os.path.splitext(os.path.basename(path))[0] + "." + target_ext
315
+ converted = os.path.join(td, base)
316
+ if not os.path.isfile(converted):
317
+ return None
318
+ # 读出内容后立刻解析(临时目录随之销毁,不在用户目录留文件)
319
+ return parse_docx(converted) if target_ext == "docx" else parse_xlsx(converted)
320
+
321
+
322
+ def parse_doc(path):
323
+ # ① LibreOffice 转 docx(表格/标题保真最好)
324
+ content = _convert_via_soffice(path, "docx")
325
+ if content:
326
+ return content
327
+ # ② macOS 自带 textutil 转 html(表格保留,标题层级可能丢失)
328
+ if shutil.which("textutil"):
329
+ try:
330
+ r = subprocess.run(["textutil", "-convert", "html", "-stdout", path],
331
+ capture_output=True, timeout=120)
332
+ if r.returncode == 0 and r.stdout:
333
+ return _parse_html(r.stdout.decode("utf-8", "ignore"))
334
+ except (OSError, subprocess.TimeoutExpired):
335
+ pass
336
+ raise RuntimeError(
337
+ "解析 .doc 需要 LibreOffice(soffice)或 macOS textutil;"
338
+ "都没有时可先在 Word 里另存为 .docx 再试")
339
+
340
+
341
+ def _parse_html(html):
342
+ """stdlib HTMLParser:抽取 <h1-h6> 标题与 <table> 行为 Markdown。"""
343
+ from html.parser import HTMLParser
344
+
345
+ class P(HTMLParser):
346
+ def __init__(self):
347
+ super().__init__()
348
+ self.parts = []
349
+ self.table_no = 0
350
+ self.rows = None # 当前表格行集合
351
+ self.row = None # 当前行
352
+ self.cell = None # 当前单元格文本
353
+ self.heading = None # 当前标题 (level, buf)
354
+ self.para = None # 当前段落文本
355
+
356
+ def handle_starttag(self, tag, attrs):
357
+ if tag == "table":
358
+ self._flush_para()
359
+ self.rows = []
360
+ elif tag == "tr" and self.rows is not None:
361
+ self.row = []
362
+ elif tag in ("td", "th") and self.row is not None:
363
+ self.cell = []
364
+ elif tag in ("h1", "h2", "h3", "h4", "h5", "h6"):
365
+ self._flush_para()
366
+ self.heading = (int(tag[1]), [])
367
+ elif tag == "p":
368
+ self._flush_para()
369
+ self.para = []
370
+
371
+ def handle_endtag(self, tag):
372
+ if tag == "table" and self.rows is not None:
373
+ if self.rows:
374
+ self.table_no += 1
375
+ self.parts.append("**表%d**\n\n%s" % (self.table_no, md_table(self.rows)))
376
+ self.rows = None
377
+ elif tag == "tr" and self.row is not None:
378
+ if any(c.strip() for c in self.row):
379
+ self.rows.append([nfc(c.strip()) for c in self.row])
380
+ self.row = None
381
+ elif tag in ("td", "th") and self.cell is not None:
382
+ self.row.append("".join(self.cell))
383
+ self.cell = None
384
+ elif tag in ("h1", "h2", "h3", "h4", "h5", "h6") and self.heading:
385
+ lvl, buf = self.heading
386
+ text = nfc("".join(buf).strip())
387
+ if text:
388
+ self.parts.append("#" * lvl + " " + text)
389
+ self.heading = None
390
+ elif tag == "p":
391
+ self._flush_para()
392
+
393
+ def handle_data(self, data):
394
+ if self.cell is not None:
395
+ self.cell.append(data)
396
+ elif self.heading:
397
+ self.heading[1].append(data)
398
+ elif self.para is not None:
399
+ self.para.append(data)
400
+
401
+ def _flush_para(self):
402
+ if self.para is not None:
403
+ text = nfc("".join(self.para).strip())
404
+ if text:
405
+ self.parts.append(text)
406
+ self.para = None
407
+
408
+ p = P()
409
+ p.feed(html)
410
+ p.close()
411
+ p._flush_para()
412
+ return "\n\n".join(p.parts)
413
+
414
+
415
+ def parse_xls(path):
416
+ # ① xlrd(专支持旧版 .xls,若已安装)
417
+ try:
418
+ import xlrd # type: ignore
419
+ parts = []
420
+ book = xlrd.open_workbook(path)
421
+ for ws in book.sheets():
422
+ parts.append("## Sheet: %s" % ws.name)
423
+ rows = []
424
+ for ri in range(ws.nrows):
425
+ cells = [nfc(str(c.value).strip()) for c in ws.row(ri)]
426
+ while cells and cells[-1] == "":
427
+ cells.pop()
428
+ if cells:
429
+ rows.append(cells)
430
+ parts.append(md_table(rows) if rows else "(空 sheet)")
431
+ return "\n\n".join(parts)
432
+ except ImportError:
433
+ pass
434
+ # ② LibreOffice 转 xlsx 后按 xlsx 解析
435
+ content = _convert_via_soffice(path, "xlsx")
436
+ if content:
437
+ return content
438
+ raise RuntimeError(
439
+ "解析 .xls 需要安装 xlrd(pip3 install xlrd)或 LibreOffice(soffice);"
440
+ "都没有时可先在 Excel 里另存为 .xlsx 再试")
441
+
442
+
443
+ # ---------------------------------------------------------------- main
444
+ def main():
445
+ ap = argparse.ArgumentParser(description="考核文档解析为 Markdown")
446
+ ap.add_argument("file", help="doc / docx / xls / xlsx / pdf 文件路径")
447
+ ap.add_argument("-o", "--output", help="输出到文件(默认打印到标准输出)")
448
+ args = ap.parse_args()
449
+
450
+ if not os.path.isfile(args.file):
451
+ out("ERROR: 文件不存在: %s" % args.file)
452
+ sys.exit(2)
453
+ ext = os.path.splitext(args.file)[1].lower()
454
+ try:
455
+ if ext == ".docx":
456
+ content = parse_docx(args.file)
457
+ elif ext == ".doc":
458
+ content = parse_doc(args.file)
459
+ elif ext == ".xlsx":
460
+ content = parse_xlsx(args.file)
461
+ elif ext == ".xls":
462
+ content = parse_xls(args.file)
463
+ elif ext == ".pdf":
464
+ content = parse_pdf(args.file)
465
+ else:
466
+ raise RuntimeError("不支持的格式 %s(支持 doc/docx/xls/xlsx/pdf)" % ext)
467
+ except RuntimeError as e:
468
+ out("ERROR: %s" % e)
469
+ sys.exit(1)
470
+ except Exception as e: # noqa
471
+ out("ERROR: 解析失败: %s: %s" % (type(e).__name__, e))
472
+ sys.exit(1)
473
+
474
+ if args.output:
475
+ with open(args.output, "w", encoding="utf-8") as f:
476
+ f.write(content)
477
+ out("OK: 已写入 %s(%d 字符)" % (args.output, len(content)))
478
+ else:
479
+ out(content)
480
+
481
+
482
+ if __name__ == "__main__":
483
+ main()
@@ -119,6 +119,11 @@ Windows/PowerShell 下不要使用 `printf`、bash 反斜杠续行、`$HOME/...`
119
119
  - 列表结果只展示最相关的前 `10` 条;如果用户要求更多,分批展示并说明还可以继续读取。
120
120
  - 详情结果只展示与用户问题相关的字段。发票类详情通常优先展示 `fid`、号码/代码、购销方、金额、日期、查验/报销状态和附件摘要。
121
121
  - 大结果会由 CLI 暂存在用户级 state 目录,并返回 `refId`。后续操作用 `--input-ref <refId>` 和可选的 `--pick` / `--pick-as` 取所需数据;不要直接读取暂存文件,也不要用 `head` / `tail` 截取 JSON。
122
+ - **预览条数 ≠ 返回条数(最容易误判的一条)**:结果超过 stdout 预算(默认 24 KB)时,CLI 会先压字段(长文本截短、**条目不丢**),仍然装不下才裁到 50/20/10/5/2/1 条。发生裁条目时,信封顶部一定有 `previewTruncated: true`、`previewOmitted` 和带原始条数的 `largeOutputNotice`(形如 `data.items 共 92 条,仅显示 5 条`)。**看到 `previewOmitted` 就说明 `data.items.length` 只是预览长度**:不得据此断言「服务端只返回 N 条」「分页参数没生效」「只成功 N 人」,必须先用 `refs get <refId> data.items` 取全量再下结论。
123
+ - **`refs get` 取数组会自动分批,且每批是完整条目**:返回 `{ total, offset, returned, hasMore, nextOffset, data }`,按 `largeOutputNotice` 给的命令续读(如 `refs get <refId> data.items --offset 33 --limit 33`)直到 `hasMore:false`。**不要**用先取到的这一批的 `length` 当总数,`total` 才是。
124
+ - **预览中的长文本不是完整值**:`previewTruncatedFields` 按字段路径给出 `{ unit:"chars", total, shown }`。需要原文时用 `refs get <refId> <path> --char-offset 0 --char-limit <n>` 分段读取,按 `nextCharOffset` 续读到 `hasMore:false`;不得把预览前缀当成原始字段做比较、总结或写入。
125
+ - **有 `refId` 就不得重查业务接口**:全量、子字段和长文本都从本地 ref 取;只有 ref 过期/损坏且任务确实仍需要数据时,才能重新请求服务端。
126
+ - **暂存不会无界增长**:只有超过 stdout 预算的结果才默认落盘;默认 TTL 30 分钟、最多 50 个 ref/总计 200 MB。CLI 在后续命令中惰性清理,也可用 `refs prune --all` 手动清理。
122
127
  - 如果用户确实需要一个可交付文件,使用业务 operation 提供的下载/导出参数或用户指定的输出路径;不要把 CLI stdout 当成临时中转文件。
123
128
  - 如果为了调试必须引用原始 envelope,只截取必要字段:`ok`、`operation`、`meta`、`warnings`、`error` 或 `data` 的相关子树。
124
129
 
@@ -5,7 +5,7 @@ display_name_en: Weaver Invoice
5
5
  description: "泛微 E10 业票通发票管理:查询票夹、OCR 识别、上传查验、附件、流程发票字段、仅上传/录入时先问是否登记再采集相关客户/项目/事前申请(报销意图不问登记)、报销填单、查询待开票合同并创建开票申请草稿。"
6
6
  description_zh: "泛微 E10 业票通发票管理。支持查询个人/企业票夹、查看详情、OCR 识别、上传查验(上传、识别、查验一步到位)、下载附件、流程表单发票字段数据,通过 prepare/apply 确认链处理导入、新增、编辑、删除;仅上传 / 录入发票且无报销意图时,识别查验完后同一批先问要不要登记,同意后再采集关联信息(话费 / 油费从最近的报销单找出事前申请登记,找不到给出发起链接;差旅 / 打车只采相关项目和事前申请,客户按项目带出;其他采相关客户、相关项目、事前申请);报销意图下不问登记,只读已有登记自动带出;报销填单由本技能准备发票、事前申请、工作流等数据,报销单创建/修改调用 weaver-e10-workflow 的发起/修改能力;AI 开票先用 weaver-e10-workflow 查出当前用户有权限看的合同审批流程,补齐是否开票、合同号、客户名称和开票金额后列出待开票合同,用户选定并确认后,按销售方调用 weaver-e10-workflow 创建开票申请草稿(不提交)。"
7
7
  description_en: "Weaver E10 Yepiaotong invoice skill for folder queries, detail lookup, OCR recognition, one-step upload with recognition and validation, attachment downloads, workflow invoice field data, asking once after upload or entry (not during reimbursement) whether to record association info and only then collecting it so reimbursement can prefill them (phone and fuel invoices get their pre-approval found from recent reimbursements; travel and ride invoices only record the project and pre-approval), reimbursement data preparation (forms are created and edited via weaver-e10-workflow), and AI invoicing that lists the user's contracts pending invoicing and, after confirmation, drafts the invoice-application workflow via weaver-e10-workflow."
8
- version: 1.0.19
8
+ version: 1.0.20
9
9
  author: 泛微网络科技股份有限公司
10
10
  agent_created: true
11
11
  requires:
@@ -32,6 +32,16 @@ cliHelp: "weaver-work-cli invoice --help"
32
32
 
33
33
  # 泛微E10业票通发票管理
34
34
 
35
+ **普通 / 差旅 / 外出 / 交通报销客户与承担主体**:统一用 `invoice.reim.customer.search`(只传用户客户名称 `keywords`),客户多条必须让用户选,承担主体取同一选定客户返回值;与用户本轮输入不同,建单前提示「承担主体填写不一致,最终会被客户带出值覆盖」。本规则优先于当前用户、默认值、历史及合同联动,完整契约见 [reim-customer-search.md](references/reim-customer-search.md)。相关项目仍用 `invoice.reim.field.search`;话费 / 油费补贴不变。
36
+
37
+ **报销沟通口径**:合同号按内部规则处理,不主动向用户补充免填、按项目自动带出或来源说明;用户主动询问时再回答,命令返回的 `finalMarkdown` 保持原样。承担主体受客户联动覆盖,**无法保留用户输入的不一致值**;只告知这一限制并继续,不询问是否确认、不提供改用用户输入值的选项,也不承诺通过后续修改保留该值。
38
+
39
+ ## 报销客户 / 项目硬约束
40
+
41
+ - 识别到出差、差旅、外出或滴滴 / 打车 / 网约车等交通报销意图,相关客户必须经查询确定,并在 `data.main` 显式写入非空客户值。没有具体客户不得建单,不能用默认「泛微上海」顶替或等联动补值;项目仍可不填。
42
+ - 客户只用 `invoice.reim.customer.search`,只传 `keywords`。项目只用 `invoice.reim.field.search`,必须同时传 `workflowId="100003460000000060"`、`fieldId="100003720000006720"`、`keywords`;`fieldId` 只从 [字段对照表](references/reim-customer-search.md#相关客户--相关项目查询硬约束) 复制,禁止用客户字段 `100003720000000687`。
43
+ - 非空项目即使来自历史或登记,也必须独立查询、独立校验。返回的项目名称与客户名称完全一致时,判定为 `fieldId` 错误,停止写入并按字段对照表更正参数重查;客户 / 项目即使同名也不能共用查询结果,ID 相同不证明正确。重查仍无法区分时保持停止,完整恢复规则见上述文档。
44
+
35
45
  ## 执行预算(最小动作集,避免冗余读取与重复调用)
36
46
 
37
47
  本文件在技能加载时已整体注入上下文,**不要再用 Read 读本 SKILL.md**;仅需核对 `version` / `agent_created` 时读前 15 行,且**修改本包内文件不必先确认 `agent_created`**(此处已声明 `true`)。
@@ -102,11 +112,11 @@ cliHelp: "weaver-work-cli invoice --help"
102
112
  | 准备/确认手工新增发票 | `invoice run invoice.add.prepare/apply` | `[invoice-add.md](references/invoice-add.md)` |
103
113
  | 准备/确认编辑发票 | `invoice run invoice.update.prepare/apply` | `[invoice-update.md](references/invoice-update.md)` |
104
114
  | 准备/确认删除发票 | `invoice run invoice.delete.prepare/apply` | `[invoice-delete.md](references/invoice-delete.md)` |
105
- | 生成流程表单发票浏览按钮 JSON | `invoice run invoice.browse-field.data` | `[invoice-browse-field-data.md](references/invoice-browse-field-data.md)` |
106
115
  | 报销自动填单(发票、事前申请、工作流、客户 / 项目) | `invoice run invoice.reim.`* | `[invoice-reim.md](references/invoice-reim.md)` |
107
116
  | 报销单创建 / 修改 | `workflow run workflow.createForm/createRequest`、`workflow.editLoad/editPrepare/editApply`(`weaver-e10-workflow` 技能) | `[reim-workflow.md](references/reim-workflow.md)` Step 3~6;命令契约见 `[workflow-create.md](../weaver-e10-workflow/references/workflow-create.md)` |
108
117
  | 报销完整工作流编排、行为准则 | AI 内部 | `[reim-workflow.md](references/reim-workflow.md)` |
109
- | 相关客户 / 相关项目模糊搜索(报销填单) | `invoice run invoice.reim.field.search` | `[reim-form-fill-rules.md](references/reim-form-fill-rules.md)`「相关客户模糊搜索」 |
118
+ | 普通 / 差旅报销:查相关客户及承担主体 | `invoice run invoice.reim.customer.search`(只传 `keywords`) | [reim-customer-search.md](references/reim-customer-search.md) |
119
+ | 相关项目模糊搜索(报销填单) | `invoice run invoice.reim.field.search` | [reim-form-fill-rules.md](references/reim-form-fill-rules.md)「相关项目模糊搜索」 |
110
120
  | 上传发票登记前按名称搜相关客户 / 项目(取 `id`、名称,不需要报销表单) | `invoice run invoice.reim.relation.search` | `[invoice-reim-relation.md](references/invoice-reim-relation.md)`「客户、项目名称消歧」 |
111
121
  | **上传 / 录入发票后登记相关客户 / 项目 / 事前申请(仅非报销意图;先问要不要登记,同意后再采集)** | `invoice run invoice.reim.relation.save` | `[invoice-reim-relation.md](references/invoice-reim-relation.md)`「一、上传时登记」 |
112
122
  | **上传话费 / 油费发票后自动找事前申请并登记(先征得同意)** | `workflow run workflow.search/detail`(`weaver-e10-workflow`)+ `invoice run invoice.reim.relation.save` | `[invoice-reim-relation.md](references/invoice-reim-relation.md)`「三、话费 / 油费」 |
@@ -141,12 +151,11 @@ cliHelp: "weaver-work-cli invoice --help"
141
151
  - 用户给了客户 / 项目名称时,用 `invoice.reim.relation.search`(`target` 传 `customer` / `project`,`keywords` 用用户原话,可以是模糊名称)搜出 `id` 和名称,不需要报销表单 -> `invoice.reim.relation.save` 一次登记整批 `fid`。这个接口失败**不重试、不打断**,最多一句话说明。
142
152
  - 编辑发票:`invoice.update.prepare` -> 用户确认 -> `invoice.update.apply`
143
153
  - 删除发票:`invoice.delete.prepare` -> 用户确认 -> `invoice.delete.apply`
144
- - 流程发票字段:已有 `fid` 或详情时,用 `invoice.browse-field.data` 生成浏览按钮对象;不要运行旧源码脚本或直接调接口。
145
- - 报销填单(完整工作流见 `[reim-workflow.md](references/reim-workflow.md)`):先用 `invoice.reim.candidates.list`(按日期批量)/`invoice.list`/`invoice.get`/`invoice.reim.file-ocr.preview` 获取发票(日期筛选默认 `consumption_tm_begin` / `consumption_tm_end`;**出差报销先找出差流程**:`invoice.reim.requests.list` 传 `requestname="出差"`,用 `workflow.summary`(`weaver-e10-workflow`,只读)读「起始日期」「结束日期」,按起始日期前 1 天 ~ 结束日期后 1 天用 `invoice.reim.candidates.list` 查票,期间 `available` 的发票全部列入并全部绑这条出差流程,多条出差流程对不上时先问用户;找不到出差流程才按城市筛(出发城市没说默认上海),见 `[reim-workflow.md](references/reim-workflow.md)`「按出差流程查票」「出差 / 城市意图查票」)-> 展示汇总并确认 -> 并行 `invoice.reim.relation.list`(读上传时登记的相关客户、相关项目、事前申请:**登记了的直接用,不再问客户 / 项目,也不再选事前申请**,见 `[invoice-reim-relation.md](references/invoice-reim-relation.md)`)和 `invoice.reim.requests.list`(用户没指定日期时不传 `cusCreateDateStart` / `cusCreateDateEnd`,CLI 默认查最近 7 天、查不到放宽到 1 个月),没登记事前申请的发票只按开票日期和事前申请发起日期关联(只比日期不比钟点,发起日与开票日同一天算对上,默认绑定),**多条事前申请确认不了是哪条时(一张发票时间上落在多条、没有开票日期、用户点名的对上多条),必须一次问清用户,选定前不往下走、不替用户选** -> `invoice.reim.workflow.resolve` 得到报销工作流 -> **Read `[workflow-create.md](../weaver-e10-workflow/references/workflow-create.md)` 全文**(没读完不往下走,传参格式照它)-> 并行 `workflow.createForm`(`weaver-e10-workflow`,传 `{workFlowName}({workFlowId})`,**不传 `userQuestion`**,也不用 `workflow.createRequestDirect`)、`invoice.browse-field.data`(只传发票)-> 按规则组装 `data`(**`requestName` 与「报销事由」必传**,按 form-fill-rules 的标题/事由公式生成,禁止留用表单默认标题或留空;发票与事前申请只按时间关联,见 `[reim-matching-rules.md](references/reim-matching-rules.md)`,填单规则见 `[reim-form-fill-rules.md](references/reim-form-fill-rules.md)`;明细每行只写「相关发票」和(可选的)「相关流程」;工作流是「总部费用报销」时,用本次 `createForm` 的 `historyRequestData` 在项目确认后带出合同号,**不要询问合同号**;相关客户和相关项目上传时登记过就直接用,只登记了项目时客户按项目从 `historyRequestData` 同一项目最近一条带出;**差旅 / 外出没登记项目时,沿用 `historyRequestData` 里最近一张有项目的历史报销单的项目和客户**(不问,建单后告诉用户沿用了哪张),历史里也没有才问;需要填写时同一次让用户一起输入,未确认不建单,见 `[reim-workflow.md](references/reim-workflow.md)` Step 4.4、Step 4.5)-> 直接 `workflow.createRequest` 存草稿(`action` 固定 `"draft"`,**不问用户「存草稿 / 提交审批」**,草稿由用户在 E10 核对后自己提交;话费 / 油费补贴不走本链,见下条)-> 原样粘贴 `finalMarkdown` -> **必须做 Step 5.3**:查客户 / 项目是否被联动冲空(已确认值直接写回,不要先建空草稿再问)。创建成功后修改只能用 `workflow.editLoad` -> `workflow.editPrepare` -> 用户确认 -> `workflow.editApply`。
154
+ - 报销填单(完整工作流见 [reim-workflow.md](references/reim-workflow.md)):取发票(出差优先按出差流程起止日期前后各一天查票)→ 展示汇总并确认范围 → 并行读上传登记和事前申请(普通匹配只比开票日期与申请日期,多候选必须问清;按出差流程查的票直接绑该流程)→ `invoice.reim.workflow.resolve` → 完整读 `workflow-create.md` → `workflow.createForm`(只传 `workflow`,不传 `userQuestion`) → 按 [reim-form-fill-rules.md](references/reim-form-fill-rules.md) 组装 `data`。客户来源仍用本轮、登记、项目或历史,但**都须 `invoice.reim.customer.search` 取客户与承担主体,多客户必须让用户选**;项目仍用 `invoice.reim.field.search`。承担主体按同一客户返回值,若与用户输入不同先告知不一致及最终会被客户带出值覆盖。客户 / 项目需要采集时一次问齐;合同号按已确认项目从历史带出,不问合同号。必传标题和报销事由,明细每行只写相关发票及已绑定的相关流程,差旅每行必须有相关流程。直接 `workflow.createRequest`(`action:"draft"`)→ 原样展示 `finalMarkdown` → **必须做 Step 5.3** 检查并修复客户 / 项目及客户承担主体。成功后只用 `workflow.edit*` 修改,不重复建单。
146
155
  - **话费 / 油费补贴报销**(如「帮我报销上月的话费补贴」「帮我发起本月我的话费补贴报销」「报一下油费补贴」):**不走上面的「最近一周查票 → 确认 → 按日期匹配事前申请」**,完整规则见 `[reim-phone-subsidy-rules.md](references/reim-phone-subsidy-rules.md)`。① `invoice.list --view summary` **必须传 `date_begin` / `date_end`,仅查北京时间今天及前 29 天(最近 30 天,含首尾)开票的未报销发票**,按 `content` 关键词(话费 `电信服务` / `通讯` / `通信`,油费 `汽油` / `柴油`)筛选,逐张核对 `date`,超期、未来日期或缺失 / 无效日期的不报;未挂单的合规发票全部列入、不让用户挑,**票夹(台账)里已有的不查验**;票夹没有就提醒用户上传,**上传的发票必须查验**,用 `invoice.upload-and-validate` 上传并查验后再判断能不能报,**查验返回「单张发票每天最多查验5次」(6022)视为查验通过,继续报销**。② 事前申请**先用上传时登记的**(第 1 步返回后用发票 `fid` 调 `invoice.reim.relation.list`),没登记再用 `workflow.search`(`category="mine"`,话费 `流程(100003460000002556)`、油费 `流程(100003460000001017)`,和第 1 步同时发起,草稿状态从它读)兜底找固定事前申请,都**不问用户**;**提交了就能用,不等审批通过**(只有草稿时请用户先提交);都没有就按固定模板给出发起链接:话费 `{baseUrl}/sp/workflow/flowpage/create/100003460000002556?workflowId=100003460000002556&isCreate=1`,油费 `{baseUrl}/sp/workflow/flowpage/create/100003460000001017?workflowId=100003460000001017&isCreate=1`(`{baseUrl}` 取本轮 CLI 返回链接里 `/sp/` 前面的部分,本轮没有链接时才用 `workflow.pageOpen` 取)。定下事前申请的 `requestId` 后,**必须**再调 `workflow.detail`(入参 `{"requestId":"<列表里的 requestId>"}`)从详情字段补读「月补贴额度 / 月补额度 / 月补贴额」(列表结果没有该字段;读不到不传 `monthlyAllowance`)。③ **不拦金额**,也**不走表单填单**(不调 `invoice.reim.workflow.resolve`、`workflow.createForm`、`workflow.createRequest`):直接调用 `invoice.reim.subsidy.submit`(高风险写入,用户发起报销即视为同意提交,不再确认),传 `processTitle`(如 `龚为明10月话费报销`)、`reason`(固定写 `话费报销` / `油费报销`,不带月份)、`relatedProcessId`(事前申请 `requestId`)、`invoices`(最近 30 天内合规发票的 `{fid,total,date}`,`total` 是价税合计,`date` 是开票日期,直接抄 `invoice.list`;CLI 提交前再次校验全部日期,缺失 / 无效 / 超出范围时拒绝请求)和 `monthlyAllowance`(`workflow.detail` 读到的「月补贴额度」,读不到不传),CLI 给每行明细算 `reimbursedAmount`(所有行加起来不超过月补贴额度:没超过每行报发票 `total`,超过时最后一行报「月补贴额度 − 前面明细行累加的金额」,额度用完后剩下的发票不进明细、留在票夹,下次仍须满足最近 30 天限制),调 `aiCreateWf` 创建并提交报销流程。相关客户 / 项目不问用户:不传时客户默认泛微上海 `100504500000311504`、项目为空;用户自己说了名称才用 `invoice.reim.field.search` 换成 ID 传 `customerId` / `projectId`。④ 成功后原样展示 CLI 生成的 `finalMarkdown`,**包含「已报销成功,流程已提交。」、关键数据汇总和流程链接**;汇总包括报销事由、实际报销金额、已使用发票张数及票面合计、开票日期、月补贴额度(有值时),以及超额和整张未纳入发票的说明(有则展示),按完整回执展示,不另行补查或编造汇总;返回 `partial/write_uncertain` 时禁止重发,只读回查一次。
147
156
  - 报销单创建/修改依赖同级的 `weaver-e10-workflow` 技能(`../weaver-e10-workflow/`),调用前先读它的 `SKILL.md` 和对应契约文件(见本文件开头的 workflow 契约规则);该技能不存在时停止并告知用户需要安装,不要改用其他方式创建报销单。
148
- - **⚠️ 报销单不询问合同号。** 默认 `20260999`。用户本轮自己说了才用用户的;否则按已确认的相关项目,从 `historyRequestData` 里该项目最近一条带出。对不上或项目「不填」则用默认。带出的合同号不是 `20260999` 时,创建阶段承担主体不传。**相关客户和相关项目同一次让用户一起输入**,确认后再写入 `data`,禁止空着先建草稿,也不要拆成两轮。名称先 `invoice.reim.field.search`。口径见 `[reim-form-fill-rules.md](references/reim-form-fill-rules.md)`「总部费用报销历史参考」。
149
- - **⚠️ 明细每行只写「相关发票」**:有绑定的事前申请时再写「相关流程」(差旅 / 外出每行必须有)。费用日期、金额、币种、费用类型(科目)、费用说明 / 摘要、费用明细、相关凭证、明细相关客户 / 项目、附件数等其余明细列**创建时一律不传**,由「相关发票」联动带出:表单默认值、用户口述、科目匹配规则、兜底科目都不写进去,也不要用消费内容、起止点自己生成费用说明。不做凭证配对,`invoice.browse-field.data` 只传发票。建单后仍空只告知联动没带出,不补写,也不让用户选科目、挂行程单;只有用户明确要求改某行科目时才按 `[reim-expense-subject-rules.md](references/reim-expense-subject-rules.md)` 走修改链。见 `[reim-form-fill-rules.md](references/reim-form-fill-rules.md)`「费用明细字段规则」。
157
+ - **⚠️ 报销单不询问合同号。** 默认 `20260999`;用户本轮给了用用户的,否则按已确认项目从历史最近一条带出。**承担主体始终取选定客户的返回值,不因非默认合同号省略或改用合同承担人。** 相关客户、项目需要采集时同一次问齐;客户用 `invoice.reim.customer.search`,项目用 `invoice.reim.field.search`。详见 [reim-form-fill-rules.md](references/reim-form-fill-rules.md) 与 [reim-customer-search.md](references/reim-customer-search.md)。
158
+ - **⚠️ 明细每行只写「相关发票」**:有绑定的事前申请时再写「相关流程」(差旅 / 外出每行必须有)。费用日期、金额、币种、费用类型(科目)、费用说明 / 摘要、费用明细、相关凭证、明细相关客户 / 项目、附件数等其余明细列**创建时一律不传**,由「相关发票」联动带出:表单默认值、用户口述、科目匹配规则、兜底科目都不写进去,也不要用消费内容、起止点自己生成费用说明。不做凭证配对,直接用已选发票的 `[{id,name}]` 引用,不为填字段额外查询详情或转换对象。建单后仍空只告知联动没带出,不补写,也不让用户选科目、挂行程单;只有用户明确要求改某行科目时才按 `[reim-expense-subject-rules.md](references/reim-expense-subject-rules.md)` 走修改链。见 `[reim-form-fill-rules.md](references/reim-form-fill-rules.md)`「费用明细字段规则」。
150
159
  - **⚠️ 主表「事前申请流程」不允许赋值**:创建报销单时不写入 `data.main`,保留空值。匹配到的事前申请只写到明细每行「相关流程」(`{requestname}({requestid})`)。见 `[reim-form-fill-rules.md](references/reim-form-fill-rules.md)`「主表字段规则」。
151
160
  - **AI 开票**:`workflow.search`(`weaver-e10-workflow`,固定传 `category="all"`、`workflow=["老客户增值服务合同审批流程","新客户购买合同审批流程","常规二次销售服务合同审批流程"]`、`pageSize=10`;用户点名了客户、公司、地名、合同号或标题关键词时再追加 `requestName`,按流程标题 like 模糊搜索,如 `"鄂尔多斯"`,没点名不传,翻页原样带上,不要把「合同」「开票」当作 `requestName`)-> 把返回的 `data.cards` 原样作为 `cards` 传给 `invoice.issuing.contracts.list`,拿到 `invoiced`、`contractNo`、`customerName`、`invoiceAmount`、`sellerName` -> 只列 `invoiced=false` 的合同,问用户给哪份开票(不替用户选,金额以 CLI 为准不自己累加)-> `invoice.issuing.contract.detail` 取客户 `{id, name}` 和「合同正文及附件」每个文件的 `docId`、`name` -> `sellerName` 含「亘岩」用 `契约锁合同收款发票开具及快递申请(100003460000001852)`,其他用 `合同收款发票开具及快递申请(100003460000000214)` -> **必须先问用户「预计收款时间」**(`yyyy-MM-dd`,不猜、不留空,用户没给就不往下走),连同日期向用户确认一次 -> **Read `[workflow-create.md](../weaver-e10-workflow/references/workflow-create.md)` 全文**(没读完不往下走,传参格式照它)-> `workflow.createForm`(不传 `userQuestion`)-> `workflow.createRequest`(`action` 固定 `"draft"`,**不提交**),`data.main` 只填合同审批流程 `{id,name}`、合同客户 `{id,name}`、合同文本 `{id,name}`(`id` 用 `docId`,`name` 用文件名;多个文件传数组,不要传 `contractDocIds` 逗号串或纯数字 id)、预计收款时间,契约锁流程再填合同号 `contractNo`(另一张表的合同号是浏览按钮字段,写不进去,靠联动带出)-> 原样粘贴 `finalMarkdown`。创建成功后修改只走 `workflow.editLoad/editPrepare/editApply`,禁止重复创建。详见 `[invoice-issuing-workflow.md](references/invoice-issuing-workflow.md)`。
152
161
  - 合同流程查询与开票申请草稿依赖同级 `weaver-e10-workflow` 技能,调用前先读它的 `SKILL.md` 和对应契约文件(见本文件开头的 workflow 契约规则);该技能不存在时停止并告知用户需要安装,不要用其他方式创建开票申请。
@@ -220,7 +229,6 @@ weaver-work-cli invoice schema
220
229
  weaver-work-cli --json invoice run invoice.list --input-json '{"page_size":10,"start_pos":0}'
221
230
  weaver-work-cli --json invoice run invoice.get --input-json '{"fid":"12345"}'
222
231
  weaver-work-cli --json invoice run invoice.upload-and-validate --input-json '{"file":"./invoice.pdf"}'
223
- weaver-work-cli --json invoice run invoice.browse-field.data --input-json '{"fid":"12345"}'
224
232
  weaver-work-cli --json invoice run invoice.reim.requests.list --input-json '{"pageNo":1,"pageSize":100}'
225
233
  ```
226
234
 
@@ -231,7 +239,6 @@ weaver-work-cli invoice schema
231
239
  weaver-work-cli --json invoice run invoice.list --input-json '{"page_size":10,"start_pos":0}'
232
240
  weaver-work-cli --json invoice run invoice.get --input-json '{"fid":"12345"}'
233
241
  weaver-work-cli --json invoice run invoice.upload-and-validate --input-json '{"file":"./invoice.pdf"}'
234
- weaver-work-cli --json invoice run invoice.browse-field.data --input-json '{"fid":"12345"}'
235
242
  weaver-work-cli --json invoice run invoice.reim.requests.list --input-json '{"pageNo":1,"pageSize":100}'
236
243
  ```
237
244