@whyshu/argent-engine 0.0.0-stage → 0.6.0
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/MANIFEST.json +307 -0
- package/engine/VERSION +1 -0
- package/engine/agents/catalog.json +454 -0
- package/engine/configs/_aliases.proposed.json +651 -0
- package/engine/configs/_migration-plan.proposed.json +899 -0
- package/engine/configs/account.json +272 -0
- package/engine/configs/advanced.json +205 -0
- package/engine/configs/host.json +149 -0
- package/engine/configs/hr.json +27 -0
- package/engine/configs/notify.json +264 -0
- package/engine/core/cli/argent.mjs +277 -0
- package/engine/core/contracts/argent.contracts.json +1065 -0
- package/engine/core/contracts/verbs.schema.json +2539 -0
- package/engine/core/lib/argent-datadir.mjs +223 -0
- package/engine/core/lib/audit.mjs +187 -0
- package/engine/core/lib/claim.mjs +258 -0
- package/engine/core/lib/config-catalog.mjs +1172 -0
- package/engine/core/lib/doctor-customer.mjs +577 -0
- package/engine/core/lib/flow-list.mjs +138 -0
- package/engine/core/lib/flow-registry.mjs +48 -0
- package/engine/core/lib/init.mjs +247 -0
- package/engine/core/lib/ledger.mjs +124 -0
- package/engine/core/lib/license-activate.mjs +813 -0
- package/engine/core/lib/license-device.mjs +314 -0
- package/engine/core/lib/license-file.mjs +349 -0
- package/engine/core/lib/license-guard.mjs +123 -0
- package/engine/core/lib/license-ops.mjs +1645 -0
- package/engine/core/lib/license-verdict.mjs +133 -0
- package/engine/core/lib/license.mjs +577 -0
- package/engine/core/lib/notify/dedup.mjs +101 -0
- package/engine/core/lib/notify/feishu.mjs +38 -0
- package/engine/core/lib/notify/index.mjs +95 -0
- package/engine/core/lib/notify/verb.mjs +327 -0
- package/engine/core/lib/notify/webhook.mjs +135 -0
- package/engine/core/lib/notify/wecom.mjs +36 -0
- package/engine/core/lib/python.mjs +145 -0
- package/engine/core/lib/sop.mjs +116 -0
- package/engine/core/lib/versions.mjs +205 -0
- package/engine/core/mcp/client.mjs +67 -0
- package/engine/core/mcp/http.mjs +138 -0
- package/engine/core/mcp/server.mjs +702 -0
- package/engine/scripts/_engine_rules_probe.py +15 -0
- package/engine/scripts/analyze-full-day.py +568 -0
- package/engine/scripts/archive/feishu-bridge.js +246 -0
- package/engine/scripts/argent-agents.mjs +527 -0
- package/engine/scripts/argent-capabilities.mjs +776 -0
- package/engine/scripts/argent-catalog.mjs +186 -0
- package/engine/scripts/argent-datadir.py +62 -0
- package/engine/scripts/argent-doctor.mjs +624 -0
- package/engine/scripts/argent-env-write.mjs +302 -0
- package/engine/scripts/argent-schedule.mjs +620 -0
- package/engine/scripts/argent-setup-check.mjs +369 -0
- package/engine/scripts/argent-upgrade.mjs +1046 -0
- package/engine/scripts/base-bootstrap.sh +575 -0
- package/engine/scripts/billing-mode-daily.sh +12 -0
- package/engine/scripts/build-engine-package.mjs +123 -0
- package/engine/scripts/capability-packs.lock.json +484 -0
- package/engine/scripts/capability_pack.py +1242 -0
- package/engine/scripts/check-1.0-criteria.mjs +355 -0
- package/engine/scripts/check-agent-catalog.mjs +141 -0
- package/engine/scripts/check-billing-mode.sh +377 -0
- package/engine/scripts/check-child-sessions.mjs +83 -0
- package/engine/scripts/check-config-catalog.mjs +677 -0
- package/engine/scripts/check-docs-drift.mjs +522 -0
- package/engine/scripts/check-dsh-web-expose.sh +98 -0
- package/engine/scripts/check-judgment-drift.mjs +403 -0
- package/engine/scripts/check-license.mjs +199 -0
- package/engine/scripts/check-model-auth.py +443 -0
- package/engine/scripts/check-pack-closure.mjs +661 -0
- package/engine/scripts/check-portable-symbols.mjs +116 -0
- package/engine/scripts/check-preset-landing.mjs +124 -0
- package/engine/scripts/check-production-home.mjs +602 -0
- package/engine/scripts/check-role-mapping.mjs +461 -0
- package/engine/scripts/check-sample-redaction.mjs +320 -0
- package/engine/scripts/check-skill-classification.mjs +188 -0
- package/engine/scripts/check-sop-consistency.mjs +431 -0
- package/engine/scripts/check-test-env-safety.mjs +627 -0
- package/engine/scripts/check-version-consistency.mjs +452 -0
- package/engine/scripts/ci-run.sh +558 -0
- package/engine/scripts/config-explain.mjs +278 -0
- package/engine/scripts/configure-provider.rb +29 -0
- package/engine/scripts/customer-config-migrate.mjs +179 -0
- package/engine/scripts/customer-preflight.py +892 -0
- package/engine/scripts/customer-readiness.sh +134 -0
- package/engine/scripts/daily-report-inbox.py +242 -0
- package/engine/scripts/daily-report-reconcile.mjs +312 -0
- package/engine/scripts/daily-report.mjs +1310 -0
- package/engine/scripts/daily-report.sh +46 -0
- package/engine/scripts/data/lip-product-dict.json +306 -0
- package/engine/scripts/deliver-customer.mjs +932 -0
- package/engine/scripts/delivery-faces.txt +31 -0
- package/engine/scripts/desktop-trial.sh +146 -0
- package/engine/scripts/dev-window.sh +260 -0
- package/engine/scripts/drill-clean-machine.sh +315 -0
- package/engine/scripts/dsh-api-client.mjs +215 -0
- package/engine/scripts/dsh-backup-scope.sh +83 -0
- package/engine/scripts/dsh-offline-pack.mjs +77 -0
- package/engine/scripts/dsh-overlay-pin.sh +87 -0
- package/engine/scripts/dsh-plane.mjs +153 -0
- package/engine/scripts/dsh-portforward.py +223 -0
- package/engine/scripts/dsh-preflight.mjs +179 -0
- package/engine/scripts/dsh-release-watch-daily.sh +19 -0
- package/engine/scripts/dsh-release-watch.mjs +458 -0
- package/engine/scripts/dsh-remote-check.sh +99 -0
- package/engine/scripts/dsh-restart.sh +179 -0
- package/engine/scripts/dsh-restore.sh +111 -0
- package/engine/scripts/dsh-scope-rewire.mjs +803 -0
- package/engine/scripts/dsh-snapshot.mjs +116 -0
- package/engine/scripts/dsh-upgrade-readiness.mjs +165 -0
- package/engine/scripts/dsh-upgrade.mjs +612 -0
- package/engine/scripts/dsh-url.sh +86 -0
- package/engine/scripts/dsh-web-launch.mjs +155 -0
- package/engine/scripts/ensure-store-windows.py +509 -0
- package/engine/scripts/entitlements.py +458 -0
- package/engine/scripts/env_probe.py +411 -0
- package/engine/scripts/feishu-card.mjs +252 -0
- package/engine/scripts/fix-skill-frontmatter.py +209 -0
- package/engine/scripts/flow-auto-retry.py +454 -0
- package/engine/scripts/flow-requirements.json +720 -0
- package/engine/scripts/flow-scaffold.py +275 -0
- package/engine/scripts/flow-timers-plist.sh +86 -0
- package/engine/scripts/flow-timers.sh +182 -0
- package/engine/scripts/flow-trigger-wake.mjs +284 -0
- package/engine/scripts/flow-trigger.sh +571 -0
- package/engine/scripts/flow_billing.py +354 -0
- package/engine/scripts/flow_capability_stats.py +314 -0
- package/engine/scripts/flow_case.py +194 -0
- package/engine/scripts/flow_claim.py +497 -0
- package/engine/scripts/flow_config.py +1024 -0
- package/engine/scripts/flow_failure.py +588 -0
- package/engine/scripts/flow_learn.py +105 -0
- package/engine/scripts/flow_ledger.py +235 -0
- package/engine/scripts/flow_policy.py +238 -0
- package/engine/scripts/flow_preflight.py +339 -0
- package/engine/scripts/flow_registry.py +341 -0
- package/engine/scripts/flow_retry.py +304 -0
- package/engine/scripts/flow_return_to_ops.py +191 -0
- package/engine/scripts/flow_source.py +315 -0
- package/engine/scripts/flow_sources/__init__.py +53 -0
- package/engine/scripts/flow_sources/cases_json.py +106 -0
- package/engine/scripts/flow_sources/common.py +428 -0
- package/engine/scripts/flow_sources/feishu_base.py +273 -0
- package/engine/scripts/flow_stale.py +185 -0
- package/engine/scripts/flow_status_reconcile.py +344 -0
- package/engine/scripts/flow_triage.py +849 -0
- package/engine/scripts/flow_write_verify.py +496 -0
- package/engine/scripts/fulfillment.js +586 -0
- package/engine/scripts/gen-agent-bundles.mjs +276 -0
- package/engine/scripts/gen-preset-rows.mjs +259 -0
- package/engine/scripts/init-ml.sh +2275 -0
- package/engine/scripts/install-internal-role.sh +190 -0
- package/engine/scripts/install-license.mjs +641 -0
- package/engine/scripts/install-one-shot.mjs +665 -0
- package/engine/scripts/integration_contract.py +220 -0
- package/engine/scripts/integrations/wenyao/adapter.py +98 -0
- package/engine/scripts/integrations/xzh/adapter.py +75 -0
- package/engine/scripts/invoice-mapping.example.json +40 -0
- package/engine/scripts/invoice-table.sh +194 -0
- package/engine/scripts/invoice_carrier_notice.py +279 -0
- package/engine/scripts/invoice_fail_closeout.py +297 -0
- package/engine/scripts/invoice_lip_runner.py +1508 -0
- package/engine/scripts/invoice_lip_runner.py.bak-20260922-1710-freready +1090 -0
- package/engine/scripts/invoice_ready_audit.py +191 -0
- package/engine/scripts/invoice_runner.py +675 -0
- package/engine/scripts/invoice_stageb.py +516 -0
- package/engine/scripts/launchd/com.whyshu.argent-bridge.plist.example +42 -0
- package/engine/scripts/launchd/com.whyshu.fulfillment-poll.plist.example +29 -0
- package/engine/scripts/lease.py +377 -0
- package/engine/scripts/lib/agent-install.mjs +649 -0
- package/engine/scripts/lib/argent-datadir.mjs +16 -0
- package/engine/scripts/lib/argent_datadir.py +262 -0
- package/engine/scripts/lib/argent_filelock.py +507 -0
- package/engine/scripts/lib/bootcheck-wiring.mjs +510 -0
- package/engine/scripts/lib/cdp_ports.py +197 -0
- package/engine/scripts/lib/customer-env.mjs +102 -0
- package/engine/scripts/lib/daily-report-core.mjs +517 -0
- package/engine/scripts/lib/dep-declaration.mjs +81 -0
- package/engine/scripts/lib/deps-migrate.mjs +310 -0
- package/engine/scripts/lib/dsh-host-resolve.mjs +109 -0
- package/engine/scripts/lib/dsh-scope.mjs +500 -0
- package/engine/scripts/lib/dsh-snapshot-path.mjs +35 -0
- package/engine/scripts/lib/dsh-versions.mjs +96 -0
- package/engine/scripts/lib/dsh-web-probe.mjs +214 -0
- package/engine/scripts/lib/is-direct-run.mjs +61 -0
- package/engine/scripts/lib/patch-compose.mjs +241 -0
- package/engine/scripts/lib/patch-target.mjs +35 -0
- package/engine/scripts/lib/plugin-lifecycle.mjs +128 -0
- package/engine/scripts/lib/plugin-packages.mjs +332 -0
- package/engine/scripts/lib/preset-compat.mjs +127 -0
- package/engine/scripts/lib/preset-install.mjs +575 -0
- package/engine/scripts/lib/preset-mechanism.mjs +56 -0
- package/engine/scripts/lib/preset-sync.mjs +59 -0
- package/engine/scripts/lib/profile-retire.mjs +97 -0
- package/engine/scripts/lib/python-runtime.mjs +190 -0
- package/engine/scripts/lib/registry.mjs +72 -0
- package/engine/scripts/lib/repo-root.sh +56 -0
- package/engine/scripts/lib/schedule-mechanism.mjs +659 -0
- package/engine/scripts/lib/schedule-probe.mjs +835 -0
- package/engine/scripts/lib/scope-pointer.mjs +164 -0
- package/engine/scripts/lib/settings-panels.mjs +816 -0
- package/engine/scripts/lib/stdio_utf8.py +86 -0
- package/engine/scripts/lib/wake-auth.mjs +392 -0
- package/engine/scripts/lib/webdriver_ipc.py +264 -0
- package/engine/scripts/lib/zstd-frames.mjs +104 -0
- package/engine/scripts/license-e2e-drill.mjs +426 -0
- package/engine/scripts/license-gate.mjs +245 -0
- package/engine/scripts/lip_backlog.py +171 -0
- package/engine/scripts/lip_table.py +185 -0
- package/engine/scripts/local-usage.mjs +214 -0
- package/engine/scripts/migrate-providers.mjs +127 -0
- package/engine/scripts/migrate-skills.sh +65 -0
- package/engine/scripts/ml-oauth-setup.mjs +550 -0
- package/engine/scripts/ml-store-ids.json +26 -0
- package/engine/scripts/ml_artifact_attribution.py +333 -0
- package/engine/scripts/ml_capacity_probe.py +1158 -0
- package/engine/scripts/ml_hub_status.py +1556 -0
- package/engine/scripts/ml_schema_check.py +115 -0
- package/engine/scripts/ml_store_ids.py +139 -0
- package/engine/scripts/npm-publish-argent.mjs +499 -0
- package/engine/scripts/npm-publish-argent.sh +20 -0
- package/engine/scripts/orchestrator.py +13811 -0
- package/engine/scripts/pack-plugins.mjs +140 -0
- package/engine/scripts/patches/dsh-llm-deepseek--transport-diagnostics.patch +297 -0
- package/engine/scripts/patches/dsh-session--append-message-shape.patch +15 -0
- package/engine/scripts/patches/dsh-session--tool-result-block-017.patch +28 -0
- package/engine/scripts/patches/dsh-session-format-v0-to-v1--permission-preset-origin.patch +11 -0
- package/engine/scripts/patches/dsh-session-format-v3-to-v4--turn-outside-replace.patch +20 -0
- package/engine/scripts/patches/dsh-session-persistence-jsonl--worker-bundled-migrators.patch +39 -0
- package/engine/scripts/patches/dsh-tools--render-return-shape.patch +50 -0
- package/engine/scripts/patches/verify-bundled-migrators.mjs +79 -0
- package/engine/scripts/patches/verify-hardening.mjs +167 -0
- package/engine/scripts/patches/verify-session-migration.mjs +149 -0
- package/engine/scripts/patches/verify-transport-diagnostics.mjs +227 -0
- package/engine/scripts/plan-role-rename.mjs +125 -0
- package/engine/scripts/plugin-bootcheck.mjs +451 -0
- package/engine/scripts/plugin-composition.json +15 -0
- package/engine/scripts/poc-mcp-host.mjs +455 -0
- package/engine/scripts/poll-fulfillment.sh +293 -0
- package/engine/scripts/poll-invoice.sh +74 -0
- package/engine/scripts/profile-doctor.mjs +686 -0
- package/engine/scripts/provider-select.sh +70 -0
- package/engine/scripts/provider-switch.sh +146 -0
- package/engine/scripts/provider-sync-target.check.mjs +64 -0
- package/engine/scripts/python-runtime.sh +78 -0
- package/engine/scripts/query_runner.py +310 -0
- package/engine/scripts/release-argent.sh +574 -0
- package/engine/scripts/repair-unresolved-tools.mjs +178 -0
- package/engine/scripts/run-tests.sh +256 -0
- package/engine/scripts/self-sign-license.mjs +179 -0
- package/engine/scripts/session-health-scan.mjs +63 -0
- package/engine/scripts/session-repair-tool-result-content.mjs +181 -0
- package/engine/scripts/setup.sh +22 -0
- package/engine/scripts/skill-install.mjs +629 -0
- package/engine/scripts/sku_translate.py +148 -0
- package/engine/scripts/sync-plugins.sh +90 -0
- package/engine/scripts/sync-presets.sh +27 -0
- package/engine/scripts/sync-scripts.sh +445 -0
- package/engine/scripts/telemetry.py +873 -0
- package/engine/scripts/ui-copy-count.mjs +220 -0
- package/engine/scripts/usage-anchor.sh +136 -0
- package/engine/scripts/usage_report.py +531 -0
- package/engine/scripts/validate-preset-schema.mjs +208 -0
- package/engine/scripts/vertical-init.mjs +323 -0
- package/engine/scripts/vertical-lint.mjs +482 -0
- package/engine/scripts/wenyao-browser.sh +73 -0
- package/engine/scripts/wenyao-fixture-export.py +116 -0
- package/engine/scripts/wenyao-invoice-writeback.mjs +540 -0
- package/engine/scripts/wenyao-login.sh +34 -0
- package/engine/scripts/wenyao-template-map.json +292 -0
- package/engine/scripts/wenyao_attach.py +131 -0
- package/engine/scripts/wenyao_download_template.py +144 -0
- package/engine/scripts/wenyao_fill_template.py +568 -0
- package/engine/scripts/wenyao_login.py +145 -0
- package/engine/scripts/wenyao_portal.py +633 -0
- package/engine/scripts/wenyao_recon.py +230 -0
- package/engine/scripts/wenyao_run.py +503 -0
- package/engine/scripts/wenyao_shadow_diff.py +160 -0
- package/engine/scripts/wenyao_skill_contract.py +156 -0
- package/engine/scripts/wenyao_template_fetch.py +175 -0
- package/engine/scripts/win/dsh-web-autostart.ps1 +372 -0
- package/engine/scripts/ziniao-auth-probe.sh +268 -0
- package/engine/scripts/ziniao-keepalive.sh +216 -0
- package/engine/scripts/ziniao-post-upgrade-check.sh +120 -0
- package/engine/scripts/ziniao-windows.sh +153 -0
- package/engine/version.mjs +1 -0
- package/engine/verticals/README.md +103 -0
- package/engine/verticals/_engine-words.baseline.txt +237 -0
- package/engine/verticals/_engine-words.json +19 -0
- package/engine/verticals/mercadolibre/README.md +43 -0
- package/engine/verticals/mercadolibre/config.json +709 -0
- package/engine/verticals/mercadolibre/flows.json +706 -0
- package/engine/verticals/mercadolibre/manifest.json +538 -0
- package/engine/verticals/mercadolibre/migrate-machine-state.mjs +138 -0
- package/engine/verticals/mercadolibre/preflight.py +143 -0
- package/engine/verticals/mercadolibre/prompts/daily-report.failure.md +69 -0
- package/engine/verticals/mercadolibre/prompts/daily-report.md +47 -0
- package/engine/verticals/mercadolibre/prompts/daily-report.scheduled.md +79 -0
- package/engine/verticals/mercadolibre/prompts/full.failure.md +125 -0
- package/engine/verticals/mercadolibre/prompts/full.md +91 -0
- package/engine/verticals/mercadolibre/prompts/wenyao-invoice.failure.md +88 -0
- package/engine/verticals/mercadolibre/prompts/wenyao-invoice.md +64 -0
- package/engine/verticals/mercadolibre/prompts/xzh-invoice.failure.md +91 -0
- package/engine/verticals/mercadolibre/prompts/xzh-invoice.md +46 -0
- package/package.json +21 -4
- package/README.md +0 -3
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""从填报映射真源生成技能里的「列契约」参考文档(避免手写漂移)。
|
|
3
|
+
|
|
4
|
+
用法:
|
|
5
|
+
python3 scripts/wenyao_skill_contract.py # 写到 skills/ml-invoice/references/template-fill-contract.md
|
|
6
|
+
python3 scripts/wenyao_skill_contract.py --stdout # 打到标准输出
|
|
7
|
+
python3 scripts/wenyao_skill_contract.py --check # 只校验磁盘文件与真源一致(CI/单测用),不一致 exit 1
|
|
8
|
+
|
|
9
|
+
真源:scripts/wenyao-template-map.json
|
|
10
|
+
目标:skills/ml-invoice/references/template-fill-contract.md
|
|
11
|
+
"""
|
|
12
|
+
import json
|
|
13
|
+
import pathlib
|
|
14
|
+
import sys
|
|
15
|
+
|
|
16
|
+
ROOT = pathlib.Path(__file__).resolve().parent.parent
|
|
17
|
+
MAP_PATH = ROOT / 'scripts' / 'wenyao-template-map.json'
|
|
18
|
+
sys.path.insert(0, str(ROOT / 'scripts'))
|
|
19
|
+
import ml_store_ids # noqa: E402 (店铺→卖家ID 的唯一真源)
|
|
20
|
+
OUT_PATH = ROOT / 'skills' / 'ml-invoice' / 'references' / 'template-fill-contract.md'
|
|
21
|
+
|
|
22
|
+
SRC_CN = {
|
|
23
|
+
'field': '飞书字段',
|
|
24
|
+
'calc': '计算',
|
|
25
|
+
'const': '常量',
|
|
26
|
+
'llm': 'LLM 翻译',
|
|
27
|
+
'image': '图片',
|
|
28
|
+
'storemap': '店铺映射',
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def detail_of(c: dict) -> str:
|
|
33
|
+
src = c['source']
|
|
34
|
+
if src == 'field':
|
|
35
|
+
return f"飞书 `{c['field']}`"
|
|
36
|
+
if src == 'calc':
|
|
37
|
+
return f"`{c['expr']}`"
|
|
38
|
+
if src == 'llm':
|
|
39
|
+
return f"LLM:{c.get('note') or c.get('prompt', '')}"
|
|
40
|
+
if src == 'storemap':
|
|
41
|
+
return '店铺 → 卖家ID'
|
|
42
|
+
if src == 'image':
|
|
43
|
+
return f"飞书 `{c.get('field', '产品图')}`(浮动图片,锚 `{c.get('anchor', 'AA8')}`)"
|
|
44
|
+
value = c.get('value', '')
|
|
45
|
+
shown = '(空)' if value == '' else f'`{value}`'
|
|
46
|
+
extra = f"({c['note']})" if c.get('note') else ''
|
|
47
|
+
if c.get('perRow'):
|
|
48
|
+
extra += '|**随行变化**(影子对比器按 `perRow` 放行,判据在填报器)'
|
|
49
|
+
return f"{shown}{extra}"
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def material_section() -> list:
|
|
53
|
+
"""材质英文三级解析 + 与 HS 的分界(2026-10-12 事故固化)。
|
|
54
|
+
|
|
55
|
+
⛔ 这里**不写填报器的脚本路径**(路径写在 `SKILL.md`,避免引擎面文件复述业务词):
|
|
56
|
+
真源只有一份判据(填报器的 `resolve_material_en()`),本节只描述**怎么传、怎么回写**。
|
|
57
|
+
"""
|
|
58
|
+
return [
|
|
59
|
+
'', '## 材质英文(`S` 列)三级解析 —— 与 HS 的分界', '',
|
|
60
|
+
'合同:`S` = `{材质},{材质英文}`。**材质英文走三级解析**(唯一实现 = 填报器的 '
|
|
61
|
+
'`resolve_material_en()`;脚本路径与入口见 `SKILL.md`「材质英文(`S` 列)三级解析」):', '',
|
|
62
|
+
'| 级 | 来源 | 命中后 | 写回字典? |', '|---|---|---|---|',
|
|
63
|
+
'| ① | per-SKU 字典 `<数据目录>/lip-sku-dict.json`(键 = `SKU`,**优先 `confirmed:true`** '
|
|
64
|
+
'的「材质英文」) | 直接用 | ⛔ 不写(答案已固化) |',
|
|
65
|
+
'| ② | 本映射的 `materialEn` 通用小词典 | 直接用 | ⛔ 不写 |',
|
|
66
|
+
'| ③ | 会话传入 `--material-en "<英文>"`(或行内 `材质英文`;**政策A:LLM 译出的可直接用**) '
|
|
67
|
+
'| 用它填 `S` 列 | ✅ 写回 |', '',
|
|
68
|
+
'写回形状(③ 定音时;落到 `<数据目录>/lip-sku-dict.json`):', '',
|
|
69
|
+
'```json',
|
|
70
|
+
'{"<SKU>": {"材质英文": "<英文>", "confirmed": false,',
|
|
71
|
+
' "来源": "LLM 译 <YYYY-MM-DD>(政策A:材质英文可直接用,HS 不动)", "备注": ""}}',
|
|
72
|
+
'```', '',
|
|
73
|
+
'- 写回**合并进已有条目**(⛔ 不丢 `品名英文`/`海关编码`);**原子写**(`tmp` + `os.replace`);'
|
|
74
|
+
'同 `SKU` 同值 ⇒ **幂等跳过**(不重写、不动 mtime);',
|
|
75
|
+
'- **⛔ 不覆盖 `confirmed:true`**;字典里已有 `confirmed:true` 条目但缺材质英文 ⇒ 只留痕、'
|
|
76
|
+
'**不写回**(不把已确认条目降级成 `confirmed:false`);',
|
|
77
|
+
'- **同名不同值 ⇒ 冲突交人**:保留字典值、**不写回**、阻断重跑(与 `flow_case` 的'
|
|
78
|
+
'「不覆盖 + 记冲突」同一口径);',
|
|
79
|
+
'- 审计:`<数据目录>/material-en/audit.jsonl`;阶段台账:编排器 P0 行打印的 `log=<路径>`'
|
|
80
|
+
'(`run-<货件号>-<时间>.jsonl`,目录名见 `SKILL.md`)。', '',
|
|
81
|
+
'**三级都没命中 ⇒ 阻断**(填报器不落盘、闸门 exit ≠ 0),文案指路:', '',
|
|
82
|
+
'```',
|
|
83
|
+
'材质「<中文材质>」未能在 SKU 字典 / 小词典命中 ⇒ 请翻译成英文后用 --material-en 重跑',
|
|
84
|
+
'(政策A:材质英文允许 LLM 译;HS 编码仍必须人工维护)',
|
|
85
|
+
'```', '',
|
|
86
|
+
'### ⛔ HS 编码(`Z` 列)不在这条链上', '',
|
|
87
|
+
'HS 编码由**运营/人工维护**:系统**不预填、不写候选、不自动确认**(红线,勿动)。'
|
|
88
|
+
'「不预填」那条**只管 HS** —— 把它套到材质英文上,就是 2026-10-12 两条票被误阻的成因。', '',
|
|
89
|
+
'另有一份**按中文品名**建的翻译缓存 `<数据目录>/lip-product-dict.json`(品名英文/材质英文/'
|
|
90
|
+
'HS 候选),与本节这份**按 SKU** 的字典是两回事:本填报链只读 `lip-sku-dict.json`'
|
|
91
|
+
'(HS 候选**不预填**进模板,见上一条红线)。',
|
|
92
|
+
]
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def render(m: dict) -> str:
|
|
97
|
+
L = ['# 填报列契约(由 `scripts/wenyao-template-map.json` 生成,勿手改)', '']
|
|
98
|
+
L += ['模板真源:**门户下载版**《跨境电商-下单模板.xlsx》(`getTemplateUrl`)。',
|
|
99
|
+
'运营版《上海文鳐发票模版.xlsx》仅作「每列怎么填」的说明,**列序不可照抄**(门户版多 `*是否投保`)。', '']
|
|
100
|
+
L.append(f"- sheet: `{m['sheet']}`|表头行: **{m['headerRow']}**|数据行: **{m['dataRow']}**|清底: `{m['clearRowsBelow']}`")
|
|
101
|
+
L.append(f"- 模板来源标记: `{m['templateSource']}`")
|
|
102
|
+
L += ['', '## 顶部块(第 2 行)', '', '| 字段 | 单元格 | 取值 | 说明 |', '|---|---|---|---|']
|
|
103
|
+
for k, v in m['topBlock'].items():
|
|
104
|
+
val = v.get('value', '')
|
|
105
|
+
shown = '`__TODAY__`(当前日期)' if val == '__TODAY__' else ('(空)' if val == '' else f'`{val}`')
|
|
106
|
+
L.append(f"| {k} | `{v['cell']}` | {shown} | {v.get('note', '')} |")
|
|
107
|
+
L += ['', f"## 明细列(第 8 行,A..{m['columns'][-1]['col']})", '',
|
|
108
|
+
'| 列 | 表头 | 来源 | 取值/表达式 |', '|---|---|---|---|']
|
|
109
|
+
for c in m['columns']:
|
|
110
|
+
L.append(f"| `{c['col']}` | {c['header']} | {SRC_CN.get(c['source'], c['source'])} | {detail_of(c)} |")
|
|
111
|
+
L += ['', '## 店铺 → 卖家ID 映射', '',
|
|
112
|
+
'真源:`scripts/ml-store-ids.json`(键=国家-店号;**主账号/子账号共用同一 ML ID**)。', '',
|
|
113
|
+
'| 店铺 | 卖家ID |', '|---|---|']
|
|
114
|
+
for k, v in ml_store_ids.load().items():
|
|
115
|
+
L.append(f"| {k} | `{v}` |")
|
|
116
|
+
if ml_store_ids.UNKNOWN_HINT:
|
|
117
|
+
L += ['', '未配置(解析将**响亮失败**、不会顶替):' + '、'.join(ml_store_ids.UNKNOWN_HINT)]
|
|
118
|
+
if m.get('materialEn'):
|
|
119
|
+
L += ['', '## 材质中英对照', '', '| 中文 | 英文 |', '|---|---|']
|
|
120
|
+
for k, v in m['materialEn'].items():
|
|
121
|
+
L.append(f"| {k} | {v} |")
|
|
122
|
+
L += material_section()
|
|
123
|
+
if m.get('knownDivergence'):
|
|
124
|
+
L += ['', '## 已知与运营版的差异', '']
|
|
125
|
+
for d in m['knownDivergence']:
|
|
126
|
+
L.append(f'- {d}')
|
|
127
|
+
L += ['', '## 硬约束', '',
|
|
128
|
+
'- **只写第 2、8 行**;第 5-6 行是门户自带示例(门户要求不删)⇒ 不动;表头/声明/校验/冻结窗格一律不动。',
|
|
129
|
+
'- **写值前先清空 `A2..H2`**(门户版预填 `CNYTN/USLGB/东莞集货仓/墨西哥` 不得沿用)。',
|
|
130
|
+
'- **港前仓 = `华南仓`**(覆盖模板自带的 `东莞集货仓`),G2 单元格校验**保留不动**。',
|
|
131
|
+
'- 方数用**精确值**,不做 Excel 式四舍五入。',
|
|
132
|
+
'- 产品图为**浮动图片**,需 Pillow。', '']
|
|
133
|
+
return '\n'.join(L)
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def main() -> int:
|
|
137
|
+
m = json.loads(MAP_PATH.read_text())
|
|
138
|
+
text = render(m)
|
|
139
|
+
if '--stdout' in sys.argv:
|
|
140
|
+
sys.stdout.write(text)
|
|
141
|
+
return 0
|
|
142
|
+
if '--check' in sys.argv:
|
|
143
|
+
cur = OUT_PATH.read_text() if OUT_PATH.exists() else ''
|
|
144
|
+
if cur != text:
|
|
145
|
+
print(f'❌ {OUT_PATH.relative_to(ROOT)} 与真源不一致,请跑 python3 scripts/wenyao_skill_contract.py')
|
|
146
|
+
return 1
|
|
147
|
+
print(f'✅ 技能列契约与真源一致({len(text.splitlines())} 行)')
|
|
148
|
+
return 0
|
|
149
|
+
OUT_PATH.parent.mkdir(parents=True, exist_ok=True)
|
|
150
|
+
OUT_PATH.write_text(text)
|
|
151
|
+
print(f'已写入 {OUT_PATH.relative_to(ROOT)}({len(text.splitlines())} 行)')
|
|
152
|
+
return 0
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
if __name__ == '__main__':
|
|
156
|
+
sys.exit(main())
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""wenyao_template_fetch.py — 取文鳐门户的「导入模版」(跨境电商-下单模板.xlsx) 并解析结构(2026-09-10)
|
|
3
|
+
|
|
4
|
+
为什么不用普通下载:本门户的模板下载是 **JS fetch → blob → 合成点击**,而本浏览器是 `open -na`
|
|
5
|
+
启动(非 Playwright 启动)⇒ Playwright 收不到 download 事件;即便用 CDP 设下载目录也不稳。
|
|
6
|
+
**最稳做法**:在页面里钩住 `URL.createObjectURL`,点完之后把 blob 以 base64 取回 Python 落盘
|
|
7
|
+
(完全绕开下载管线)。再兜底:CDP 网络捕获 + 目录轮询。
|
|
8
|
+
|
|
9
|
+
安全边界:只取**模板**;不选文件、不点「导入」、不点导出/取消订单;完事关闭弹窗。
|
|
10
|
+
|
|
11
|
+
用法:python3 scripts/wenyao_template_fetch.py [--out-dir DIR]
|
|
12
|
+
"""
|
|
13
|
+
import argparse
|
|
14
|
+
import base64
|
|
15
|
+
import json
|
|
16
|
+
import os
|
|
17
|
+
import sys
|
|
18
|
+
import time
|
|
19
|
+
from pathlib import Path
|
|
20
|
+
from playwright.sync_api import sync_playwright
|
|
21
|
+
|
|
22
|
+
HOME = Path.home()
|
|
23
|
+
# 数据目录:**唯一判据**在 `scripts/lib/argent_datadir.py`(三级链,与 JS 内核同语义)
|
|
24
|
+
sys.path.insert(0, str(Path(__file__).resolve().parent / 'lib'))
|
|
25
|
+
from argent_datadir import resolve_data_dir # noqa: E402 —— 勿在此复制判据
|
|
26
|
+
DATA = Path(resolve_data_dir()['dir'])
|
|
27
|
+
DEFAULT_OUT = DATA / "wenyao-downloads"
|
|
28
|
+
CDP = os.environ.get("WENYAO_CDP", "http://127.0.0.1:9333")
|
|
29
|
+
|
|
30
|
+
BLOB_HOOK = """() => {
|
|
31
|
+
if (window.__blobHook) return 'already';
|
|
32
|
+
const orig = URL.createObjectURL;
|
|
33
|
+
URL.createObjectURL = function (b) { try { window.__lastBlob = b; } catch (e) {} return orig.call(URL, b); };
|
|
34
|
+
window.__blobHook = true;
|
|
35
|
+
return 'hooked';
|
|
36
|
+
}"""
|
|
37
|
+
|
|
38
|
+
READ_BLOB = """async () => {
|
|
39
|
+
const b = window.__lastBlob;
|
|
40
|
+
if (!b) return null;
|
|
41
|
+
const buf = await b.arrayBuffer();
|
|
42
|
+
const bytes = new Uint8Array(buf);
|
|
43
|
+
let s = '';
|
|
44
|
+
for (let i = 0; i < bytes.length; i++) s += String.fromCharCode(bytes[i]);
|
|
45
|
+
return { b64: btoa(s), size: bytes.length, type: b.type || '' };
|
|
46
|
+
}"""
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def summarize_xlsx(path):
|
|
50
|
+
try:
|
|
51
|
+
import openpyxl
|
|
52
|
+
except Exception as e:
|
|
53
|
+
return {"err": f"openpyxl 不可用: {e}"}
|
|
54
|
+
try:
|
|
55
|
+
wb = openpyxl.load_workbook(path, data_only=True, read_only=True)
|
|
56
|
+
out = {"sheets": wb.sheetnames, "detail": {}}
|
|
57
|
+
for ws in wb.worksheets:
|
|
58
|
+
rows = []
|
|
59
|
+
for i, r in enumerate(ws.iter_rows(values_only=True)):
|
|
60
|
+
if i > 3:
|
|
61
|
+
break
|
|
62
|
+
rows.append([str(c)[:22] if c is not None else "" for c in r][:16])
|
|
63
|
+
out["detail"][ws.title] = {"dims": f"{ws.max_row}x{ws.max_column}", "head": rows}
|
|
64
|
+
return out
|
|
65
|
+
except Exception as e:
|
|
66
|
+
return {"err": str(e)[:200]}
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def main():
|
|
70
|
+
ap = argparse.ArgumentParser()
|
|
71
|
+
ap.add_argument("--out-dir", default=str(DEFAULT_OUT))
|
|
72
|
+
a = ap.parse_args()
|
|
73
|
+
out_dir = Path(a.out_dir)
|
|
74
|
+
out_dir.mkdir(parents=True, exist_ok=True)
|
|
75
|
+
os.chmod(out_dir, 0o700)
|
|
76
|
+
res = {}
|
|
77
|
+
with sync_playwright() as p:
|
|
78
|
+
browser = p.chromium.connect_over_cdp(CDP, timeout=8000)
|
|
79
|
+
pages = [pg for c in browser.contexts for pg in c.pages]
|
|
80
|
+
page = next((pg for pg in pages if "ffl-tech" in (pg.url or "")), pages[0])
|
|
81
|
+
try:
|
|
82
|
+
page.keyboard.press("Escape"); page.wait_for_timeout(500)
|
|
83
|
+
except Exception:
|
|
84
|
+
pass
|
|
85
|
+
# 网络捕获(兜底:若模板是服务端直链而非 blob)
|
|
86
|
+
net = []
|
|
87
|
+
try:
|
|
88
|
+
sess = page.context.new_cdp_session(page)
|
|
89
|
+
sess.send("Browser.setDownloadBehavior", {"behavior": "allow", "downloadPath": str(out_dir)})
|
|
90
|
+
sess.send("Network.enable")
|
|
91
|
+
sess.on("Network.responseReceived", lambda e: net.append({
|
|
92
|
+
"url": (e.get("response") or {}).get("url", "")[:200],
|
|
93
|
+
"mime": (e.get("response") or {}).get("mimeType", ""),
|
|
94
|
+
"cd": [h for h in (((e.get("response") or {}).get("headers") or {}).items()
|
|
95
|
+
if isinstance(((e.get("response") or {}).get("headers")), dict) else [])
|
|
96
|
+
if h[0].lower() == "content-disposition"][:1]
|
|
97
|
+
}) if any(k in ((e.get("response") or {}).get("url", "")).lower() for k in ("template", "xlsx", "excel", "download", "moban", "模板")) else None)
|
|
98
|
+
except Exception as e:
|
|
99
|
+
res["cdp_err"] = str(e)[:120]
|
|
100
|
+
# 打开弹窗
|
|
101
|
+
opened = False
|
|
102
|
+
for sel in ["button:has-text('导入订单')", "text=导入订单"]:
|
|
103
|
+
try:
|
|
104
|
+
el = page.query_selector(sel)
|
|
105
|
+
if el and el.is_visible():
|
|
106
|
+
el.click(); opened = True; break
|
|
107
|
+
except Exception:
|
|
108
|
+
continue
|
|
109
|
+
page.wait_for_timeout(2500)
|
|
110
|
+
res["dialog_opened"] = opened
|
|
111
|
+
res["hook"] = page.evaluate(BLOB_HOOK)
|
|
112
|
+
# 点真正的 xlsx 链接
|
|
113
|
+
clicked = None
|
|
114
|
+
for sel in ["button:has-text('跨境电商-下单模板.xlsx')", "text=跨境电商-下单模板.xlsx", "text=下载导入模版"]:
|
|
115
|
+
try:
|
|
116
|
+
el = page.query_selector(sel)
|
|
117
|
+
if el and el.is_visible():
|
|
118
|
+
el.click(); clicked = sel; break
|
|
119
|
+
except Exception:
|
|
120
|
+
continue
|
|
121
|
+
res["clicked"] = clicked
|
|
122
|
+
# 取 blob
|
|
123
|
+
got = None
|
|
124
|
+
for _ in range(20):
|
|
125
|
+
page.wait_for_timeout(1000)
|
|
126
|
+
got = page.evaluate(READ_BLOB)
|
|
127
|
+
if got and got.get("b64"):
|
|
128
|
+
break
|
|
129
|
+
saved = None
|
|
130
|
+
if got and got.get("b64"):
|
|
131
|
+
name = "跨境电商-下单模板.xlsx"
|
|
132
|
+
dest = out_dir / name
|
|
133
|
+
dest.write_bytes(base64.b64decode(got["b64"]))
|
|
134
|
+
os.chmod(dest, 0o600)
|
|
135
|
+
saved = dest
|
|
136
|
+
res["via"] = "blob-hook"
|
|
137
|
+
res["blob_type"] = got.get("type")
|
|
138
|
+
else:
|
|
139
|
+
# 兜底:目录轮询
|
|
140
|
+
for _ in range(15):
|
|
141
|
+
page.wait_for_timeout(1000)
|
|
142
|
+
files = [f for f in out_dir.iterdir() if f.is_file() and not f.name.endswith(".crdownload")]
|
|
143
|
+
if files:
|
|
144
|
+
saved = max(files, key=lambda f: f.stat().st_mtime)
|
|
145
|
+
res["via"] = "dir-poll"
|
|
146
|
+
break
|
|
147
|
+
if saved:
|
|
148
|
+
res["saved"] = {"path": str(saved), "bytes": saved.stat().st_size, "name": saved.name}
|
|
149
|
+
if saved.suffix.lower() in (".xlsx", ".xls", ".xlsm"):
|
|
150
|
+
res["structure"] = summarize_xlsx(saved)
|
|
151
|
+
if net:
|
|
152
|
+
res["network_hits"] = net[:5]
|
|
153
|
+
# 关闭弹窗(只关不提交)
|
|
154
|
+
closed = False
|
|
155
|
+
for sel in ["button:has-text('取消')", ".next-dialog-close", "text=取消"]:
|
|
156
|
+
try:
|
|
157
|
+
el = page.query_selector(sel)
|
|
158
|
+
if el and el.is_visible():
|
|
159
|
+
el.click(); closed = True; break
|
|
160
|
+
except Exception:
|
|
161
|
+
continue
|
|
162
|
+
if not closed:
|
|
163
|
+
try: page.keyboard.press("Escape")
|
|
164
|
+
except Exception: pass
|
|
165
|
+
res["dialog_closed"] = closed
|
|
166
|
+
try:
|
|
167
|
+
page.screenshot(path=str(DATA / "wenyao-probe" / "64-template-fetch.png"), full_page=True)
|
|
168
|
+
except Exception:
|
|
169
|
+
pass
|
|
170
|
+
print(json.dumps(res, ensure_ascii=False, indent=1))
|
|
171
|
+
return 0 if (res.get("saved")) else 1
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
if __name__ == "__main__":
|
|
175
|
+
raise SystemExit(main())
|