weaver-work-cli 0.1.49 → 0.1.52

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 (207) hide show
  1. package/README.md +1 -1
  2. package/dist/chunks/{attachment-content-MU2LPI5P.js → attachment-content-MBYYSQIX.js} +3 -3
  3. package/dist/chunks/{chunk-ZKEUGS2U.js → chunk-7UOXOGFL.js} +4 -4
  4. package/dist/chunks/{chunk-72MI3MBX.js → chunk-ATEXBEPD.js} +55 -15
  5. package/dist/chunks/{chunk-3NV2ETZR.js → chunk-D3TDNRFE.js} +8 -8
  6. package/dist/chunks/{chunk-6GWU63YF.js → chunk-DZOC77ZD.js} +1 -1
  7. package/dist/chunks/{chunk-K3BT54CU.js → chunk-IRMA3GVP.js} +1 -1
  8. package/dist/chunks/{chunk-3X7VOSBA.js → chunk-KLZ3ULQQ.js} +1 -1
  9. package/dist/chunks/{chunk-YLCYX7LE.js → chunk-KMRT7NAT.js} +18 -5
  10. package/dist/chunks/{chunk-NBEWUR7L.js → chunk-LALWNK6M.js} +167 -44
  11. package/dist/chunks/{chunk-BRRW7CWA.js → chunk-LM2H7SZI.js} +26 -26
  12. package/dist/chunks/{chunk-KV5SOWMS.js → chunk-LTRLF6MM.js} +4 -4
  13. package/dist/chunks/{chunk-D2QRZUW4.js → chunk-RPRFIG6I.js} +35 -28
  14. package/dist/chunks/{chunk-GEOMANP7.js → chunk-RWFRZSIP.js} +2 -2
  15. package/dist/chunks/{chunk-EJVA5ZVB.js → chunk-ZRHKGQRQ.js} +2 -2
  16. package/dist/chunks/{conflict-6347A7YK.js → conflict-D2HYKBMH.js} +2 -2
  17. package/dist/chunks/{contract-N6P2HIIE.js → contract-MFOFMM2J.js} +4284 -254
  18. package/dist/chunks/{create-flow-7WG7LVX5.js → create-flow-7ZATJVTM.js} +6 -6
  19. package/dist/chunks/{data-QO7QWOIV.js → data-WK5CQXNF.js} +17 -32
  20. package/dist/chunks/{env-LHRKSLG6.js → env-5DO4YENS.js} +2 -2
  21. package/dist/chunks/{factory-2H7Z4RWJ.js → factory-3M7D7WJC.js} +1 -1
  22. package/dist/chunks/{fna-ZVB2IILI.js → fna-ECOYBQYL.js} +328 -5
  23. package/dist/chunks/{group-chat-EW6PNDDT.js → group-chat-B2HT5NEO.js} +3 -3
  24. package/dist/chunks/{im-3RCNL5GT.js → im-TN2JYVGJ.js} +2 -2
  25. package/dist/chunks/{invoice-FXWH5GPO.js → invoice-V7ZTITUO.js} +726 -206
  26. package/dist/chunks/{meeting-N2FQBHXI.js → meeting-HZOX3CBB.js} +10 -10
  27. package/dist/chunks/{msg-parse-4GSQ2WTO.js → msg-parse-FPFVPMYI.js} +5 -1
  28. package/dist/chunks/{reception-MYOKJULO.js → reception-QGPNTGHG.js} +98 -82
  29. package/dist/chunks/{recruit-stage-FKWS5UQF.js → recruit-stage-XCMVEQA2.js} +718 -131
  30. package/dist/chunks/{registry-BUTEDK3C.js → registry-E5RQJVWN.js} +2 -2
  31. package/dist/chunks/{registry-7VZ6YJUF.js → registry-KYPFFQIH.js} +1 -1
  32. package/dist/chunks/{registry-CKUVBS53.js → registry-SJHSBO5G.js} +10 -10
  33. package/dist/chunks/{room-recommend-MBCYENQ2.js → room-recommend-5AHR4YQV.js} +4 -4
  34. package/dist/chunks/{schedule-5IFMCXME.js → schedule-KZPJUPC2.js} +4 -4
  35. package/dist/chunks/smart-extract-IXHCZE4R.js +2846 -0
  36. package/dist/chunks/{workflow-2TRU2ZSP.js → workflow-UHKCZJMY.js} +1 -1
  37. package/dist/index.js +14 -9
  38. package/dist/shortcuts/contract/host.js +11 -0
  39. package/dist/shortcuts/contract/index.js +13 -0
  40. package/dist/shortcuts/contract/manifest.js +204 -0
  41. package/dist/shortcuts/contract/operations/card-action.js +585 -0
  42. package/dist/shortcuts/contract/operations/card-ebdf-list.js +315 -0
  43. package/dist/shortcuts/contract/operations/card-plan.js +327 -0
  44. package/dist/shortcuts/contract/operations/card-risk-report.js +565 -0
  45. package/dist/shortcuts/contract/operations/elements-build.js +714 -0
  46. package/dist/shortcuts/contract/operations/elements-spec.js +216 -0
  47. package/dist/shortcuts/contract/operations/first-screen.js +563 -0
  48. package/dist/shortcuts/contract/operations/flow.js +81 -25
  49. package/dist/shortcuts/contract/operations/modeltext.js +132 -0
  50. package/dist/shortcuts/contract/operations/op-resolver.js +22 -0
  51. package/dist/shortcuts/contract/operations/performance.js +58 -7
  52. package/dist/shortcuts/contract/operations/quote.js +410 -22
  53. package/dist/shortcuts/contract/operations/registry.js +22 -0
  54. package/dist/shortcuts/contract/operations/review.js +73 -58
  55. package/dist/shortcuts/contract/operations/save-recognize.js +151 -0
  56. package/dist/shortcuts/contract/operations/summary-validate.js +293 -0
  57. package/dist/shortcuts/contract/operations/summary.js +4 -2
  58. package/dist/shortcuts/contract/operations/upload.js +48 -7
  59. package/dist/shortcuts/contract/prewarm-cache.js +90 -0
  60. package/dist/shortcuts/contract/prewarm.js +88 -0
  61. package/dist/shortcuts/contract/upload-cache.js +49 -4
  62. package/dist/shortcuts/data/index.js +1 -6
  63. package/dist/shortcuts/data/manifest.js +2 -2
  64. package/dist/shortcuts/data/operations/index.js +1 -1
  65. package/dist/shortcuts/data/operations/query.js +23 -46
  66. package/dist/shortcuts/fna/host.js +4 -2
  67. package/dist/shortcuts/fna/manifest.js +14 -5
  68. package/dist/shortcuts/fna/operations/audit.js +334 -0
  69. package/dist/shortcuts/fna/operations/registry.js +2 -0
  70. package/dist/shortcuts/im/operations/at-mention.js +6 -3
  71. package/dist/shortcuts/im/operations/msg-parse.js +35 -5
  72. package/dist/shortcuts/im/operations/msg-sync.js +3 -1
  73. package/dist/shortcuts/im/operations/msg-write.js +57 -9
  74. package/dist/shortcuts/index.js +5 -0
  75. package/dist/shortcuts/invoice/index.js +0 -12
  76. package/dist/shortcuts/invoice/manifest.js +201 -50
  77. package/dist/shortcuts/invoice/operations/registry.js +4 -2
  78. package/dist/shortcuts/invoice/operations/reim-relation.js +438 -0
  79. package/dist/shortcuts/invoice/operations/shared.js +3 -19
  80. package/dist/shortcuts/invoice/operations/upload-and-validate.js +109 -73
  81. package/dist/shortcuts/meeting/operations/from-group-chat.js +16 -2
  82. package/dist/shortcuts/reception/constants.js +3 -7
  83. package/dist/shortcuts/reception/operations/leads.js +30 -6
  84. package/dist/shortcuts/reception/operations/panels.js +3 -2
  85. package/dist/shortcuts/recruit-stage/operations/interview-arrange.js +4 -2
  86. package/dist/shortcuts/recruit-stage/operations/jd-create.js +6 -2
  87. package/dist/shortcuts/recruit-stage/operations/list.js +217 -1
  88. package/dist/shortcuts/recruit-stage/operations/resume-import.js +144 -158
  89. package/dist/shortcuts/recruit-stage/operations/search.js +348 -0
  90. package/dist/shortcuts/recruit-stage/shared.js +5 -0
  91. package/dist/shortcuts/recruit-stage/tag-lookup.js +136 -0
  92. package/dist/shortcuts/smart-extract/constants.js +79 -0
  93. package/dist/shortcuts/smart-extract/continuation.js +71 -0
  94. package/dist/shortcuts/smart-extract/errors.js +68 -0
  95. package/dist/shortcuts/smart-extract/host.js +191 -0
  96. package/dist/shortcuts/smart-extract/index.js +105 -0
  97. package/dist/shortcuts/smart-extract/ledger.js +70 -0
  98. package/dist/shortcuts/smart-extract/manifest.js +35 -0
  99. package/dist/shortcuts/smart-extract/operations/attachment.js +212 -0
  100. package/dist/shortcuts/smart-extract/operations/batch.js +67 -0
  101. package/dist/shortcuts/smart-extract/operations/config.js +118 -0
  102. package/dist/shortcuts/smart-extract/operations/fill.js +489 -0
  103. package/dist/shortcuts/smart-extract/operations/preview.js +174 -0
  104. package/dist/shortcuts/smart-extract/operations/registry.js +34 -0
  105. package/dist/shortcuts/smart-extract/operations/save.js +355 -0
  106. package/dist/shortcuts/smart-extract/operations/shared.js +191 -0
  107. package/dist/shortcuts/smart-extract/operations/structure.js +401 -0
  108. package/dist/shortcuts/smart-extract/operations/target.js +167 -0
  109. package/dist/shortcuts/smart-extract/operations/types.js +22 -0
  110. package/dist/shortcuts/smart-extract/operations/validate.js +408 -0
  111. package/dist/shortcuts/workflow/operations/read.js +77 -15
  112. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.collect.js +140 -24
  113. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.core.js +42 -14
  114. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.js +4 -6
  115. package/docs/SKILL.md +1 -1
  116. package/docs/_catalog.md +4 -1
  117. package/docs/agent-invoice.md +5 -7
  118. package/docs/data.md +5 -1
  119. package/docs/fna.md +24 -4
  120. package/docs/invoice.md +7 -5
  121. package/docs/smart-extract.md +156 -0
  122. package/package.json +1 -1
  123. package/skill-template/business-info.json +21 -1
  124. package/skill-template/domains/qiyecheng.md +6 -2
  125. package/skill-template/domains/smart-extract.md +16 -0
  126. package/skill-template/domains/yepiaotong.md +2 -2
  127. package/skills/weaver-e10-data/references/scene-and-misc.md +4 -3
  128. package/skills/weaver-e10-jinchengda/SKILL.md +159 -11
  129. package/skills/weaver-e10-jinchengda/references/contract-action-card.md +13 -8
  130. package/skills/weaver-e10-jinchengda/references/contract-action-engine.md +5 -4
  131. package/skills/weaver-e10-jinchengda/references/contract-clause-library-crud.md +44 -2
  132. package/skills/weaver-e10-jinchengda/references/contract-command-index.md +2 -2
  133. package/skills/weaver-e10-jinchengda/references/contract-element-save-record.md +220 -0
  134. package/skills/weaver-e10-jinchengda/references/contract-field-extract-new-customer.md +68 -33
  135. package/skills/weaver-e10-jinchengda/references/contract-field-extract-other-flows.md +26 -15
  136. package/skills/weaver-e10-jinchengda/references/contract-flow-launch.md +1 -1
  137. package/skills/weaver-e10-jinchengda/references/contract-modeltext-library.md +128 -0
  138. package/skills/weaver-e10-jinchengda/references/contract-multi-file.md +90 -0
  139. package/skills/weaver-e10-jinchengda/references/contract-performance-query.md +96 -2
  140. package/skills/weaver-e10-jinchengda/references/contract-quote-to-contract.md +167 -5
  141. package/skills/weaver-e10-jinchengda/scripts/contract_first_screen.py +200 -0
  142. package/skills/weaver-e10-jinchengda/scripts/fill_contract_from_quote.py +572 -0
  143. package/skills/weaver-e10-jinchengda/scripts/fill_plan.py +997 -0
  144. package/skills/weaver-e10-jinchengda/scripts/quote_screen.py +560 -0
  145. package/skills/weaver-e10-jinchengda/scripts/triage_contract.py +894 -0
  146. package/skills/weaver-e10-jinchengda/scripts/validate_action_card.py +93 -0
  147. package/skills/weaver-e10-jinchengda/scripts/verify_docx_placeholders.py +118 -0
  148. package/skills/weaver-e10-qiyecheng/SKILL.md +58 -7
  149. package/skills/weaver-e10-qiyecheng/references/ai-check-audit.md +118 -0
  150. package/skills/weaver-e10-qiyecheng/references/budget.md +14 -0
  151. package/skills/weaver-e10-qiyecheng/references/catalog.md +42 -3
  152. package/skills/weaver-e10-qiyecheng/references/expense-center.md +8 -0
  153. package/skills/weaver-e10-qiyecheng/references/expense-chart.md +9 -0
  154. package/skills/weaver-e10-qiyecheng/references/invoice-writeoff.md +13 -0
  155. package/skills/weaver-e10-qiyecheng/references/loan-management.md +14 -0
  156. package/skills/weaver-e10-qiyecheng/references/self-hosted-mode.md +239 -0
  157. package/skills/weaver-e10-qiyecheng/references/source-manifest.json +153 -40
  158. package/skills/weaver-e10-reception-flow/SKILL.md +43 -6
  159. package/skills/weaver-e10-reception-flow/references/guide.md +1 -1
  160. package/skills/weaver-e10-recruit-stage/SKILL.md +62 -4
  161. package/skills/weaver-e10-recruit-stage/agents/openai.yaml +42 -8
  162. package/skills/weaver-e10-recruit-stage/references/env-ziyong.md +79 -0
  163. package/skills/weaver-e10-recruit-stage/references/recruit-arrange-interview.md +11 -3
  164. package/skills/weaver-e10-recruit-stage/references/recruit-edit-interview-feedback.md +3 -2
  165. package/skills/weaver-e10-recruit-stage/references/recruit-interview-not-attended.md +153 -0
  166. package/skills/weaver-e10-recruit-stage/references/recruit-jd-create.md +7 -4
  167. package/skills/weaver-e10-recruit-stage/references/recruit-match-candidates.md +1 -1
  168. package/skills/weaver-e10-recruit-stage/references/recruit-my-positions.md +66 -0
  169. package/skills/weaver-e10-recruit-stage/references/recruit-output-links.md +156 -40
  170. package/skills/weaver-e10-recruit-stage/references/recruit-resume-import-batch.md +122 -0
  171. package/skills/weaver-e10-recruit-stage/references/recruit-resume-import.md +36 -8
  172. package/skills/weaver-e10-recruit-stage/references/recruit-search-by-tag.md +157 -0
  173. package/skills/weaver-e10-recruit-stage/references/recruit-utterance-glossary.md +35 -0
  174. package/skills/weaver-e10-smart-extract/SKILL.md +169 -0
  175. package/skills/weaver-e10-smart-extract/references/api-contract.md +71 -0
  176. package/skills/weaver-e10-smart-extract/references/result-format.md +102 -0
  177. package/skills/weaver-e10-smart-extract/references/troubleshooting.md +105 -0
  178. package/skills/weaver-e10-workflow/SKILL.md +2 -1
  179. package/skills/weaver-e10-workflow/references/todo-smart-convert.md +29 -6
  180. package/skills/weaver-e10-workflow/references/workflow-query.md +1 -1
  181. package/skills/weaver-e10-workflow/references/workflow-view.md +1 -1
  182. package/skills/weaver-e10-workflow/tools/todo-summary.cjs +162 -10
  183. package/skills/weaver-e10-yepiaotong/SKILL.md +53 -35
  184. package/skills/weaver-e10-yepiaotong/references/invoice-add.md +2 -0
  185. package/skills/weaver-e10-yepiaotong/references/invoice-file-upload.md +1 -1
  186. package/skills/weaver-e10-yepiaotong/references/invoice-import.md +19 -2
  187. package/skills/weaver-e10-yepiaotong/references/invoice-issuing-workflow.md +19 -32
  188. package/skills/weaver-e10-yepiaotong/references/invoice-ocr-preview.md +8 -2
  189. package/skills/weaver-e10-yepiaotong/references/invoice-reim-relation.md +407 -0
  190. package/skills/weaver-e10-yepiaotong/references/invoice-reim.md +18 -53
  191. package/skills/weaver-e10-yepiaotong/references/invoice-upload-and-validate.md +97 -39
  192. package/skills/weaver-e10-yepiaotong/references/reim-api-reference.md +96 -7
  193. package/skills/weaver-e10-yepiaotong/references/reim-examples.md +5 -38
  194. package/skills/weaver-e10-yepiaotong/references/reim-form-fill-rules.md +14 -14
  195. package/skills/weaver-e10-yepiaotong/references/reim-matching-rules.md +8 -4
  196. package/skills/weaver-e10-yepiaotong/references/reim-phone-subsidy-rules.md +139 -94
  197. package/skills/weaver-e10-yepiaotong/references/reim-workflow.md +131 -58
  198. package/skills/weaver-e10-yepiaotong/references/source-manifest.json +110 -43
  199. package/skills/weaver-e10-yimiaoban/SKILL.md +8 -6
  200. package/skills/weaver-e10-yimiaoban/references/msg-read.md +20 -0
  201. package/skills/weaver-e10-yimiaoban/references/msg-write.md +7 -0
  202. package/skills/weaver-e10-yimiaoban/references/source-manifest.json +18 -15
  203. package/dist/shortcuts/invoice/operations/validate-preview.js +0 -40
  204. package/skills/weaver-e10-jinchengda/scripts/plan_actions.py +0 -279
  205. package/skills/weaver-e10-jinchengda/scripts/render_action_card.py +0 -450
  206. package/skills/weaver-e10-jinchengda/scripts/render_risk_report.py +0 -358
  207. package/skills/weaver-e10-yepiaotong/references/invoice-validation-preview.md +0 -40
@@ -0,0 +1,200 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+ """今承达合同首屏编排入口(跨平台唯一入口,取代原 contract_first_screen.cmd)。
4
+
5
+ 设计原则(2026-11-12 用户指定):
6
+ 技能内所有可执行入口统一用 Python,不再维护 .cmd / .sh 两套包装脚本。
7
+ 任何平台(Windows / Linux / macOS,含各类服务器与容器场景)都用同一条命令:
8
+ python3 contract_first_screen.py "<合同绝对路径>" "<输出目录>"
9
+ 子进程一律走 sys.executable,不依赖 PATH 解析,也不需要 Windows 的 PATHEXT 补全。
10
+
11
+ 两阶段:
12
+ 阶段1:只给 file 与 out_dir
13
+ → 抽正文 + 定 flowKey + 出 ai_fill.json 骨架
14
+ 阶段2:追加 --ai-fill(或旧写法 --elements / --summary-data)
15
+ → 复用 triage.json,上传 / 发起 / 存识别记录 / 渲染摘要与卡片
16
+
17
+ 用法(Windows 与 Linux 一致,仅解释器名可能不同):
18
+ 阶段1: python3 contract_first_screen.py "/data/c/合同.docx" "/tmp/out"
19
+ 阶段2: python3 contract_first_screen.py "/data/c/合同.docx" "/tmp/out" \
20
+ --ai-fill "/tmp/out/ai_fill.json" --print-card
21
+
22
+ 退出码:0 成功;1 正文抽取失败;2 参数错误;3 卡片/摘要均未产出
23
+ """
24
+ import argparse
25
+ import io
26
+ import json
27
+ import os
28
+ import shutil
29
+ import subprocess
30
+ import sys
31
+
32
+
33
+ def _force_utf8_console():
34
+ """Windows 控制台默认 GBK,中文路径/输出会乱码;有 reconfigure 就切 UTF-8。"""
35
+ for stream in (sys.stdout, sys.stderr):
36
+ try:
37
+ stream.reconfigure(encoding="utf-8", errors="replace")
38
+ except Exception:
39
+ pass
40
+
41
+
42
+ def _build_parser():
43
+ ap = argparse.ArgumentParser(
44
+ prog="contract_first_screen.py",
45
+ description="今承达合同首屏:抽正文/定类型/出骨架,阶段2 上传并发起并渲染卡片",
46
+ )
47
+ # 位置参数与 --file/--out-dir 两种写法都支持,兼容原 .cmd 调用习惯
48
+ ap.add_argument("pos", nargs="*", help="位置参数:<合同文件> <输出目录>")
49
+ ap.add_argument("--file", dest="file_opt", default="", help="主合同文件绝对路径")
50
+ ap.add_argument("--files", nargs="*", default=[],
51
+ help="多文件写法:第一个为主合同,其余为随附文件(协议/补充协议/清单)")
52
+ ap.add_argument("--attach", nargs="*", default=[],
53
+ help="随附文件绝对路径列表;与 --files 的后续文件等价")
54
+ ap.add_argument("--out-dir", dest="out_opt", default="", help="产物目录")
55
+ ap.add_argument("--elements", default="", help="兼容旧写法:要素 JSON")
56
+ ap.add_argument("--summary-data", default="", help="兼容旧写法:摘要 JSON")
57
+ ap.add_argument("--ai-fill", default="", help="阶段2:ai_fill.json(elements + summary 合一)")
58
+ ap.add_argument("--flow", default="", help="指定 flowKey,默认取 triage 判定结果")
59
+ ap.add_argument("--company-name", default="", help="对方主体全称,用于资信卡")
60
+ ap.add_argument("--counterparty", action="store_true", help="是否存在可查的对方主体")
61
+ ap.add_argument("--skip-upload", action="store_true", help="跳过预审上传")
62
+ ap.add_argument("--cli", default="", help="weaver-work-cli 可执行文件路径")
63
+ ap.add_argument("--print-card", action="store_true", help="把成品卡片打到 stdout")
64
+ return ap
65
+
66
+
67
+ def main():
68
+ _force_utf8_console()
69
+ args = _build_parser().parse_args()
70
+
71
+ pos = list(args.pos or [])
72
+ out_dir = (args.out_opt or (pos[1] if len(pos) > 1 else "")).strip()
73
+ # 多文件:--files 优先,其次 --file + --attach,最后退回位置参数
74
+ if args.files:
75
+ all_files = [x for x in args.files if x]
76
+ elif args.file_opt:
77
+ all_files = [args.file_opt] + [x for x in (args.attach or []) if x]
78
+ else:
79
+ # 位置参数写法同样要带上 --attach,否则随附文件被静默丢弃
80
+ all_files = ([pos[0]] if pos else []) + [x for x in (args.attach or []) if x]
81
+ all_files = [os.path.abspath(x) for x in all_files]
82
+ attach_files = all_files[1:]
83
+ contract = all_files[0] if all_files else ""
84
+ if not contract or not out_dir:
85
+ sys.stderr.write(
86
+ "用法: contract_first_screen.py <合同文件> <输出目录> "
87
+ "[--ai-fill ai_fill.json] [--print-card]\n"
88
+ )
89
+ return 2
90
+ contract = os.path.abspath(contract)
91
+ out_dir = os.path.abspath(out_dir)
92
+ if not os.path.isfile(contract):
93
+ sys.stderr.write("合同文件不存在:%s\n" % contract)
94
+ return 2
95
+ for a in attach_files:
96
+ if not os.path.isfile(a):
97
+ sys.stderr.write("随附文件不存在:%s\n" % a)
98
+ return 2
99
+
100
+ scripts = os.path.dirname(os.path.abspath(__file__))
101
+ triage_py = os.path.join(scripts, "triage_contract.py")
102
+ # 阶段2 已改走 CLI operation(contract.firstscreen.run),不再依赖 first_screen.py
103
+ if not os.path.isfile(triage_py):
104
+ sys.stderr.write("缺少依赖脚本:%s\n" % triage_py)
105
+ return 3
106
+
107
+ try:
108
+ os.makedirs(out_dir, exist_ok=True)
109
+ except Exception as e:
110
+ sys.stderr.write("无法创建输出目录 %s:%s\n" % (out_dir, e))
111
+ return 2
112
+
113
+ ai_fill = os.path.abspath(args.ai_fill) if args.ai_fill else ""
114
+ elements = os.path.abspath(args.elements) if args.elements else ""
115
+ summary = os.path.abspath(args.summary_data) if args.summary_data else ""
116
+ stage2 = bool(ai_fill or summary or elements)
117
+
118
+ triage_json = os.path.join(out_dir, "triage.json")
119
+ reuse = bool(stage2 and os.path.isfile(triage_json))
120
+
121
+ # ── 阶段1/阶段2 共用的正文抽取与指纹判定
122
+ if reuse:
123
+ print("[1/2] triage: REUSE existing triage.json (skip re-extract)")
124
+ else:
125
+ print("[1/2] triage: extract text + fingerprint flowKey + emit element skeleton")
126
+ cmd = [sys.executable, triage_py, "--file", contract, "--out-dir", out_dir]
127
+ if attach_files:
128
+ cmd += ["--attach"] + attach_files
129
+ if elements:
130
+ cmd += ["--elements", elements]
131
+ if summary:
132
+ cmd += ["--summary-data", summary]
133
+ if ai_fill:
134
+ cmd += ["--ai-fill", ai_fill]
135
+ if reuse:
136
+ cmd += ["--reuse"]
137
+ rc = subprocess.call(cmd)
138
+ if rc != 0:
139
+ sys.stderr.write("[FAIL] triage_contract.py exited %d\n" % rc)
140
+ return 1 if rc == 1 else rc
141
+
142
+ if not stage2:
143
+ print("")
144
+ print("[STAGE 1 DONE]")
145
+ print(" Text : %s" % os.path.join(out_dir, "contract_text.txt"))
146
+ print(" Sections : %s (区段视图, 仅辅助定位; 取值以 Text 全文为准)"
147
+ % os.path.join(out_dir, "contract_sections.txt"))
148
+ print(" AiFill : %s (elements + summary 填空板)"
149
+ % os.path.join(out_dir, "ai_fill.json"))
150
+ print(" Skeleton : %s (required rows + 口径, no values)"
151
+ % os.path.join(out_dir, "summary_skeleton.json"))
152
+ print(" Triage : %s (flowKey / counterparty / hints)"
153
+ % os.path.join(out_dir, "triage.json"))
154
+ print("")
155
+ if attach_files:
156
+ print("FILES: 主文件 1 份 + 随附 %d 份(%s)" % (
157
+ len(attach_files), "、".join(os.path.basename(x) for x in attach_files)))
158
+ print("NEXT: 只填 %s 一个文件(elements + summary),然后一条命令进阶段2:"
159
+ % os.path.join(out_dir, "ai_fill.json"))
160
+ _attach_hint = "".join(' --attach "%s"' % a for a in attach_files)
161
+ print(' python3 contract_first_screen.py "%s" "%s" --ai-fill "%s"%s --print-card'
162
+ % (contract, out_dir, os.path.join(out_dir, "ai_fill.json"), _attach_hint))
163
+ print(" 兼容旧写法: --elements elements.json --summary-data summary_data.json")
164
+ return 0
165
+
166
+ # ── 阶段2:改走 CLI operation(进程内串行,无子进程)
167
+ print("[2/2] firstscreen.run: upload/launch, then record/summary, then card")
168
+ cli = args.cli or shutil.which("weaver-work-cli") or "weaver-work-cli"
169
+ payload = {
170
+ "file": contract,
171
+ "outDir": out_dir,
172
+ "triage": triage_json,
173
+ }
174
+ if attach_files:
175
+ payload["attach"] = attach_files
176
+ if ai_fill:
177
+ payload["aiFill"] = ai_fill
178
+ if args.flow:
179
+ payload["flow"] = args.flow
180
+ if args.company_name:
181
+ payload["companyName"] = args.company_name
182
+ if args.counterparty:
183
+ payload["counterparty"] = True
184
+ if args.skip_upload:
185
+ payload["skipUpload"] = True
186
+ if args.print_card:
187
+ payload["printCard"] = True
188
+ args_file = os.path.join(out_dir, "firstscreen_args.json")
189
+ with io.open(args_file, "w", encoding="utf-8") as f:
190
+ f.write(json.dumps(payload, ensure_ascii=False))
191
+ rc2 = subprocess.call([cli, "--json", "contract", "run",
192
+ "contract.firstscreen.run", "--input", args_file])
193
+ if rc2 != 0:
194
+ print("[WARN] firstscreen.run exit=%d,结果见 %s"
195
+ % (rc2, os.path.join(out_dir, "first_screen_result.json")))
196
+ return rc2
197
+
198
+
199
+ if __name__ == "__main__":
200
+ sys.exit(main())