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.
- package/README.md +1 -1
- package/dist/chunks/{attachment-content-MU2LPI5P.js → attachment-content-MBYYSQIX.js} +3 -3
- package/dist/chunks/{chunk-ZKEUGS2U.js → chunk-7UOXOGFL.js} +4 -4
- package/dist/chunks/{chunk-72MI3MBX.js → chunk-ATEXBEPD.js} +55 -15
- package/dist/chunks/{chunk-3NV2ETZR.js → chunk-D3TDNRFE.js} +8 -8
- package/dist/chunks/{chunk-6GWU63YF.js → chunk-DZOC77ZD.js} +1 -1
- package/dist/chunks/{chunk-K3BT54CU.js → chunk-IRMA3GVP.js} +1 -1
- package/dist/chunks/{chunk-3X7VOSBA.js → chunk-KLZ3ULQQ.js} +1 -1
- package/dist/chunks/{chunk-YLCYX7LE.js → chunk-KMRT7NAT.js} +18 -5
- package/dist/chunks/{chunk-NBEWUR7L.js → chunk-LALWNK6M.js} +167 -44
- package/dist/chunks/{chunk-BRRW7CWA.js → chunk-LM2H7SZI.js} +26 -26
- package/dist/chunks/{chunk-KV5SOWMS.js → chunk-LTRLF6MM.js} +4 -4
- package/dist/chunks/{chunk-D2QRZUW4.js → chunk-RPRFIG6I.js} +35 -28
- package/dist/chunks/{chunk-GEOMANP7.js → chunk-RWFRZSIP.js} +2 -2
- package/dist/chunks/{chunk-EJVA5ZVB.js → chunk-ZRHKGQRQ.js} +2 -2
- package/dist/chunks/{conflict-6347A7YK.js → conflict-D2HYKBMH.js} +2 -2
- package/dist/chunks/{contract-N6P2HIIE.js → contract-MFOFMM2J.js} +4284 -254
- package/dist/chunks/{create-flow-7WG7LVX5.js → create-flow-7ZATJVTM.js} +6 -6
- package/dist/chunks/{data-QO7QWOIV.js → data-WK5CQXNF.js} +17 -32
- package/dist/chunks/{env-LHRKSLG6.js → env-5DO4YENS.js} +2 -2
- package/dist/chunks/{factory-2H7Z4RWJ.js → factory-3M7D7WJC.js} +1 -1
- package/dist/chunks/{fna-ZVB2IILI.js → fna-ECOYBQYL.js} +328 -5
- package/dist/chunks/{group-chat-EW6PNDDT.js → group-chat-B2HT5NEO.js} +3 -3
- package/dist/chunks/{im-3RCNL5GT.js → im-TN2JYVGJ.js} +2 -2
- package/dist/chunks/{invoice-FXWH5GPO.js → invoice-V7ZTITUO.js} +726 -206
- package/dist/chunks/{meeting-N2FQBHXI.js → meeting-HZOX3CBB.js} +10 -10
- package/dist/chunks/{msg-parse-4GSQ2WTO.js → msg-parse-FPFVPMYI.js} +5 -1
- package/dist/chunks/{reception-MYOKJULO.js → reception-QGPNTGHG.js} +98 -82
- package/dist/chunks/{recruit-stage-FKWS5UQF.js → recruit-stage-XCMVEQA2.js} +718 -131
- package/dist/chunks/{registry-BUTEDK3C.js → registry-E5RQJVWN.js} +2 -2
- package/dist/chunks/{registry-7VZ6YJUF.js → registry-KYPFFQIH.js} +1 -1
- package/dist/chunks/{registry-CKUVBS53.js → registry-SJHSBO5G.js} +10 -10
- package/dist/chunks/{room-recommend-MBCYENQ2.js → room-recommend-5AHR4YQV.js} +4 -4
- package/dist/chunks/{schedule-5IFMCXME.js → schedule-KZPJUPC2.js} +4 -4
- package/dist/chunks/smart-extract-IXHCZE4R.js +2846 -0
- package/dist/chunks/{workflow-2TRU2ZSP.js → workflow-UHKCZJMY.js} +1 -1
- package/dist/index.js +14 -9
- package/dist/shortcuts/contract/host.js +11 -0
- package/dist/shortcuts/contract/index.js +13 -0
- package/dist/shortcuts/contract/manifest.js +204 -0
- package/dist/shortcuts/contract/operations/card-action.js +585 -0
- package/dist/shortcuts/contract/operations/card-ebdf-list.js +315 -0
- package/dist/shortcuts/contract/operations/card-plan.js +327 -0
- package/dist/shortcuts/contract/operations/card-risk-report.js +565 -0
- package/dist/shortcuts/contract/operations/elements-build.js +714 -0
- package/dist/shortcuts/contract/operations/elements-spec.js +216 -0
- package/dist/shortcuts/contract/operations/first-screen.js +563 -0
- package/dist/shortcuts/contract/operations/flow.js +81 -25
- package/dist/shortcuts/contract/operations/modeltext.js +132 -0
- package/dist/shortcuts/contract/operations/op-resolver.js +22 -0
- package/dist/shortcuts/contract/operations/performance.js +58 -7
- package/dist/shortcuts/contract/operations/quote.js +410 -22
- package/dist/shortcuts/contract/operations/registry.js +22 -0
- package/dist/shortcuts/contract/operations/review.js +73 -58
- package/dist/shortcuts/contract/operations/save-recognize.js +151 -0
- package/dist/shortcuts/contract/operations/summary-validate.js +293 -0
- package/dist/shortcuts/contract/operations/summary.js +4 -2
- package/dist/shortcuts/contract/operations/upload.js +48 -7
- package/dist/shortcuts/contract/prewarm-cache.js +90 -0
- package/dist/shortcuts/contract/prewarm.js +88 -0
- package/dist/shortcuts/contract/upload-cache.js +49 -4
- package/dist/shortcuts/data/index.js +1 -6
- package/dist/shortcuts/data/manifest.js +2 -2
- package/dist/shortcuts/data/operations/index.js +1 -1
- package/dist/shortcuts/data/operations/query.js +23 -46
- package/dist/shortcuts/fna/host.js +4 -2
- package/dist/shortcuts/fna/manifest.js +14 -5
- package/dist/shortcuts/fna/operations/audit.js +334 -0
- package/dist/shortcuts/fna/operations/registry.js +2 -0
- package/dist/shortcuts/im/operations/at-mention.js +6 -3
- package/dist/shortcuts/im/operations/msg-parse.js +35 -5
- package/dist/shortcuts/im/operations/msg-sync.js +3 -1
- package/dist/shortcuts/im/operations/msg-write.js +57 -9
- package/dist/shortcuts/index.js +5 -0
- package/dist/shortcuts/invoice/index.js +0 -12
- package/dist/shortcuts/invoice/manifest.js +201 -50
- package/dist/shortcuts/invoice/operations/registry.js +4 -2
- package/dist/shortcuts/invoice/operations/reim-relation.js +438 -0
- package/dist/shortcuts/invoice/operations/shared.js +3 -19
- package/dist/shortcuts/invoice/operations/upload-and-validate.js +109 -73
- package/dist/shortcuts/meeting/operations/from-group-chat.js +16 -2
- package/dist/shortcuts/reception/constants.js +3 -7
- package/dist/shortcuts/reception/operations/leads.js +30 -6
- package/dist/shortcuts/reception/operations/panels.js +3 -2
- package/dist/shortcuts/recruit-stage/operations/interview-arrange.js +4 -2
- package/dist/shortcuts/recruit-stage/operations/jd-create.js +6 -2
- package/dist/shortcuts/recruit-stage/operations/list.js +217 -1
- package/dist/shortcuts/recruit-stage/operations/resume-import.js +144 -158
- package/dist/shortcuts/recruit-stage/operations/search.js +348 -0
- package/dist/shortcuts/recruit-stage/shared.js +5 -0
- package/dist/shortcuts/recruit-stage/tag-lookup.js +136 -0
- package/dist/shortcuts/smart-extract/constants.js +79 -0
- package/dist/shortcuts/smart-extract/continuation.js +71 -0
- package/dist/shortcuts/smart-extract/errors.js +68 -0
- package/dist/shortcuts/smart-extract/host.js +191 -0
- package/dist/shortcuts/smart-extract/index.js +105 -0
- package/dist/shortcuts/smart-extract/ledger.js +70 -0
- package/dist/shortcuts/smart-extract/manifest.js +35 -0
- package/dist/shortcuts/smart-extract/operations/attachment.js +212 -0
- package/dist/shortcuts/smart-extract/operations/batch.js +67 -0
- package/dist/shortcuts/smart-extract/operations/config.js +118 -0
- package/dist/shortcuts/smart-extract/operations/fill.js +489 -0
- package/dist/shortcuts/smart-extract/operations/preview.js +174 -0
- package/dist/shortcuts/smart-extract/operations/registry.js +34 -0
- package/dist/shortcuts/smart-extract/operations/save.js +355 -0
- package/dist/shortcuts/smart-extract/operations/shared.js +191 -0
- package/dist/shortcuts/smart-extract/operations/structure.js +401 -0
- package/dist/shortcuts/smart-extract/operations/target.js +167 -0
- package/dist/shortcuts/smart-extract/operations/types.js +22 -0
- package/dist/shortcuts/smart-extract/operations/validate.js +408 -0
- package/dist/shortcuts/workflow/operations/read.js +77 -15
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.collect.js +140 -24
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.core.js +42 -14
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.js +4 -6
- package/docs/SKILL.md +1 -1
- package/docs/_catalog.md +4 -1
- package/docs/agent-invoice.md +5 -7
- package/docs/data.md +5 -1
- package/docs/fna.md +24 -4
- package/docs/invoice.md +7 -5
- package/docs/smart-extract.md +156 -0
- package/package.json +1 -1
- package/skill-template/business-info.json +21 -1
- package/skill-template/domains/qiyecheng.md +6 -2
- package/skill-template/domains/smart-extract.md +16 -0
- package/skill-template/domains/yepiaotong.md +2 -2
- package/skills/weaver-e10-data/references/scene-and-misc.md +4 -3
- package/skills/weaver-e10-jinchengda/SKILL.md +159 -11
- package/skills/weaver-e10-jinchengda/references/contract-action-card.md +13 -8
- package/skills/weaver-e10-jinchengda/references/contract-action-engine.md +5 -4
- package/skills/weaver-e10-jinchengda/references/contract-clause-library-crud.md +44 -2
- package/skills/weaver-e10-jinchengda/references/contract-command-index.md +2 -2
- package/skills/weaver-e10-jinchengda/references/contract-element-save-record.md +220 -0
- package/skills/weaver-e10-jinchengda/references/contract-field-extract-new-customer.md +68 -33
- package/skills/weaver-e10-jinchengda/references/contract-field-extract-other-flows.md +26 -15
- package/skills/weaver-e10-jinchengda/references/contract-flow-launch.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-modeltext-library.md +128 -0
- package/skills/weaver-e10-jinchengda/references/contract-multi-file.md +90 -0
- package/skills/weaver-e10-jinchengda/references/contract-performance-query.md +96 -2
- package/skills/weaver-e10-jinchengda/references/contract-quote-to-contract.md +167 -5
- package/skills/weaver-e10-jinchengda/scripts/contract_first_screen.py +200 -0
- package/skills/weaver-e10-jinchengda/scripts/fill_contract_from_quote.py +572 -0
- package/skills/weaver-e10-jinchengda/scripts/fill_plan.py +997 -0
- package/skills/weaver-e10-jinchengda/scripts/quote_screen.py +560 -0
- package/skills/weaver-e10-jinchengda/scripts/triage_contract.py +894 -0
- package/skills/weaver-e10-jinchengda/scripts/validate_action_card.py +93 -0
- package/skills/weaver-e10-jinchengda/scripts/verify_docx_placeholders.py +118 -0
- package/skills/weaver-e10-qiyecheng/SKILL.md +58 -7
- package/skills/weaver-e10-qiyecheng/references/ai-check-audit.md +118 -0
- package/skills/weaver-e10-qiyecheng/references/budget.md +14 -0
- package/skills/weaver-e10-qiyecheng/references/catalog.md +42 -3
- package/skills/weaver-e10-qiyecheng/references/expense-center.md +8 -0
- package/skills/weaver-e10-qiyecheng/references/expense-chart.md +9 -0
- package/skills/weaver-e10-qiyecheng/references/invoice-writeoff.md +13 -0
- package/skills/weaver-e10-qiyecheng/references/loan-management.md +14 -0
- package/skills/weaver-e10-qiyecheng/references/self-hosted-mode.md +239 -0
- package/skills/weaver-e10-qiyecheng/references/source-manifest.json +153 -40
- package/skills/weaver-e10-reception-flow/SKILL.md +43 -6
- package/skills/weaver-e10-reception-flow/references/guide.md +1 -1
- package/skills/weaver-e10-recruit-stage/SKILL.md +62 -4
- package/skills/weaver-e10-recruit-stage/agents/openai.yaml +42 -8
- package/skills/weaver-e10-recruit-stage/references/env-ziyong.md +79 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-arrange-interview.md +11 -3
- package/skills/weaver-e10-recruit-stage/references/recruit-edit-interview-feedback.md +3 -2
- package/skills/weaver-e10-recruit-stage/references/recruit-interview-not-attended.md +153 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-jd-create.md +7 -4
- package/skills/weaver-e10-recruit-stage/references/recruit-match-candidates.md +1 -1
- package/skills/weaver-e10-recruit-stage/references/recruit-my-positions.md +66 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-output-links.md +156 -40
- package/skills/weaver-e10-recruit-stage/references/recruit-resume-import-batch.md +122 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-resume-import.md +36 -8
- package/skills/weaver-e10-recruit-stage/references/recruit-search-by-tag.md +157 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-utterance-glossary.md +35 -0
- package/skills/weaver-e10-smart-extract/SKILL.md +169 -0
- package/skills/weaver-e10-smart-extract/references/api-contract.md +71 -0
- package/skills/weaver-e10-smart-extract/references/result-format.md +102 -0
- package/skills/weaver-e10-smart-extract/references/troubleshooting.md +105 -0
- package/skills/weaver-e10-workflow/SKILL.md +2 -1
- package/skills/weaver-e10-workflow/references/todo-smart-convert.md +29 -6
- package/skills/weaver-e10-workflow/references/workflow-query.md +1 -1
- package/skills/weaver-e10-workflow/references/workflow-view.md +1 -1
- package/skills/weaver-e10-workflow/tools/todo-summary.cjs +162 -10
- package/skills/weaver-e10-yepiaotong/SKILL.md +53 -35
- package/skills/weaver-e10-yepiaotong/references/invoice-add.md +2 -0
- package/skills/weaver-e10-yepiaotong/references/invoice-file-upload.md +1 -1
- package/skills/weaver-e10-yepiaotong/references/invoice-import.md +19 -2
- package/skills/weaver-e10-yepiaotong/references/invoice-issuing-workflow.md +19 -32
- package/skills/weaver-e10-yepiaotong/references/invoice-ocr-preview.md +8 -2
- package/skills/weaver-e10-yepiaotong/references/invoice-reim-relation.md +407 -0
- package/skills/weaver-e10-yepiaotong/references/invoice-reim.md +18 -53
- package/skills/weaver-e10-yepiaotong/references/invoice-upload-and-validate.md +97 -39
- package/skills/weaver-e10-yepiaotong/references/reim-api-reference.md +96 -7
- package/skills/weaver-e10-yepiaotong/references/reim-examples.md +5 -38
- package/skills/weaver-e10-yepiaotong/references/reim-form-fill-rules.md +14 -14
- package/skills/weaver-e10-yepiaotong/references/reim-matching-rules.md +8 -4
- package/skills/weaver-e10-yepiaotong/references/reim-phone-subsidy-rules.md +139 -94
- package/skills/weaver-e10-yepiaotong/references/reim-workflow.md +131 -58
- package/skills/weaver-e10-yepiaotong/references/source-manifest.json +110 -43
- package/skills/weaver-e10-yimiaoban/SKILL.md +8 -6
- package/skills/weaver-e10-yimiaoban/references/msg-read.md +20 -0
- package/skills/weaver-e10-yimiaoban/references/msg-write.md +7 -0
- package/skills/weaver-e10-yimiaoban/references/source-manifest.json +18 -15
- package/dist/shortcuts/invoice/operations/validate-preview.js +0 -40
- package/skills/weaver-e10-jinchengda/scripts/plan_actions.py +0 -279
- package/skills/weaver-e10-jinchengda/scripts/render_action_card.py +0 -450
- package/skills/weaver-e10-jinchengda/scripts/render_risk_report.py +0 -358
- 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())
|