@whyshu/argent-engine 0.0.0-stage → 0.6.1
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 +341 -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 +576 -0
- package/engine/scripts/billing-mode-daily.sh +13 -0
- package/engine/scripts/build-engine-package.mjs +126 -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 +378 -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/collect-evidence.mjs +42 -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 +135 -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 +47 -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 +261 -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/final-check.mjs +43 -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 +735 -0
- package/engine/scripts/flow-scaffold.py +275 -0
- package/engine/scripts/flow-timers-plist.sh +87 -0
- package/engine/scripts/flow-timers.sh +184 -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 +1025 -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 +2278 -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 +195 -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.sh +18 -0
- package/engine/scripts/lib/argent_datadir.py +285 -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 +295 -0
- package/engine/scripts/poll-invoice.sh +76 -0
- package/engine/scripts/profile-doctor.mjs +686 -0
- package/engine/scripts/provider-select.sh +71 -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/retire-inventory.mjs +40 -0
- package/engine/scripts/run-tests.sh +257 -0
- package/engine/scripts/s1-audit.mjs +85 -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 +137 -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 +74 -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 +35 -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 +217 -0
- package/engine/scripts/ziniao-post-upgrade-check.sh +121 -0
- package/engine/scripts/ziniao-windows.sh +154 -0
- package/engine/skills/README.md +86 -0
- package/engine/skills/argent-dev/SKILL.md +41 -0
- package/engine/skills/internal.json +37 -0
- package/engine/skills/lktop-pm/SKILL.md +35 -0
- package/engine/skills/lktopapp-dev/SKILL.md +34 -0
- package/engine/skills/ml-config-guide/SKILL.md +50 -0
- package/engine/skills/ml-fulfillment-sop/SKILL.md +178 -0
- package/engine/skills/ml-fulfillment-sop/references/andes-components.md +69 -0
- package/engine/skills/ml-fulfillment-sop/references/cdp-port-mapping.md +35 -0
- package/engine/skills/ml-fulfillment-sop/references/feishu-base-fulfillment-schema.md +136 -0
- package/engine/skills/ml-fulfillment-sop/references/multi-window-concurrency.md +69 -0
- package/engine/skills/ml-fulfillment-sop/references/pitfalls.md +77 -0
- package/engine/skills/ml-fulfillment-sop/references/selectors.md +243 -0
- package/engine/skills/ml-fulfillment-sop/scripts/fulfillment.js +586 -0
- package/engine/skills/ml-fulfillment-sop/scripts/poll-and-execute.sh +271 -0
- package/engine/skills/ml-fulfillment-sop/templates/report.md +55 -0
- package/engine/skills/ml-invoice/SKILL.md +506 -0
- package/engine/skills/ml-invoice/references/pitfalls.md +268 -0
- package/engine/skills/ml-invoice/references/portal-flow.md +360 -0
- package/engine/skills/ml-invoice/references/template-fill-contract.md +133 -0
- package/engine/skills/ml-invoice-xzh/SKILL.md +133 -0
- package/engine/skills/ml-invoice-xzh/references/pitfalls.md +230 -0
- package/engine/skills/ml-store-daily-report/SKILL.md +224 -0
- package/engine/skills/ml-store-daily-report/scripts/README.md +25 -0
- package/engine/skills/ml-store-daily-report/scripts/extract.js +691 -0
- package/engine/skills/ml-store-daily-report/scripts/generate.js +299 -0
- package/engine/skills/pet-dev/SKILL.md +42 -0
- package/engine/skills/whyshu-pm/SKILL.md +35 -0
- package/engine/skills/whyshu-web-dev/SKILL.md +50 -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 +738 -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 +22 -4
- package/requirements.txt +5 -0
- package/README.md +0 -3
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""ML 流程的**数据源字段缺口检查**(事实采集,不做判断)。
|
|
3
|
+
|
|
4
|
+
分诊层需要的"事实":**给定数据源的实际字段** vs **某流程声明的必需字段**。
|
|
5
|
+
判断(归谁/能不能跑/要不要人等)交给 SKILL 与角色 —— 本脚本只输出差异,机器可读。
|
|
6
|
+
|
|
7
|
+
用法:
|
|
8
|
+
python3 scripts/ml_schema_check.py --flow wenyao-invoice --table <表 id> --profile <身份>
|
|
9
|
+
python3 scripts/ml_schema_check.py --flow wenyao-invoice --fields-from-json /tmp/fields.json # 离线(测试/夹具)
|
|
10
|
+
退出码:0 = 字段齐备 ; 1 = 有缺口 ; 2 = 读不到源/参数错误(**区别于"有缺口"**)
|
|
11
|
+
"""
|
|
12
|
+
import argparse, json, subprocess, sys
|
|
13
|
+
from pathlib import Path
|
|
14
|
+
|
|
15
|
+
REQ = Path(__file__).resolve().with_name("flow-requirements.json")
|
|
16
|
+
|
|
17
|
+
try:
|
|
18
|
+
from flow_registry import consumer_doc as _registry_doc
|
|
19
|
+
except Exception: # noqa: BLE001 —— 半坏机器上退回单文件
|
|
20
|
+
def _registry_doc(path=None):
|
|
21
|
+
_p = pathlib.Path(path) if path else REQ
|
|
22
|
+
return json.loads(_p.read_text(encoding="utf-8"))
|
|
23
|
+
|
|
24
|
+
LARK = "lark-cli"
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def live_field_names(table: str, profile: str | None) -> list[str]:
|
|
28
|
+
"""用 lark-cli 读表的实际字段名(live schema)。"""
|
|
29
|
+
cmd = [LARK]
|
|
30
|
+
if profile:
|
|
31
|
+
cmd += ["--profile", profile]
|
|
32
|
+
cmd += ["base", "+field-list", "--table-id", table, "--format", "json"]
|
|
33
|
+
out = subprocess.run(cmd, capture_output=True, text=True, timeout=120)
|
|
34
|
+
if out.returncode != 0:
|
|
35
|
+
raise RuntimeError(f"lark-cli 失败({out.returncode}): {(out.stderr or out.stdout)[:300]}")
|
|
36
|
+
data = json.loads(out.stdout)
|
|
37
|
+
items = data.get("items") or data.get("data", {}).get("items") or []
|
|
38
|
+
return [str(i.get("field_name") or i.get("name") or "") for i in items if i]
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def main(argv=None) -> int:
|
|
42
|
+
ap = argparse.ArgumentParser(description="ML 流程数据源字段缺口检查")
|
|
43
|
+
ap.add_argument("--flow", required=True)
|
|
44
|
+
ap.add_argument("--table", default="")
|
|
45
|
+
ap.add_argument("--profile", default=None)
|
|
46
|
+
ap.add_argument("--fields-from-json", default=None, help="离线:直接给字段名数组(测试用)")
|
|
47
|
+
ap.add_argument("--json", action="store_true")
|
|
48
|
+
a = ap.parse_args(argv)
|
|
49
|
+
|
|
50
|
+
try:
|
|
51
|
+
flows = _registry_doc()["flows"]
|
|
52
|
+
except Exception as exc:
|
|
53
|
+
print(f"读取 flow-requirements.json 失败: {exc}", file=sys.stderr)
|
|
54
|
+
return 2
|
|
55
|
+
# P2a:旧 id 经**加载器的别名解析**(别再往引擎里写业务线名 —— vertical-lint 会拦)
|
|
56
|
+
try:
|
|
57
|
+
import flow_registry
|
|
58
|
+
_canon = flow_registry.resolve_flow_id(a.flow)
|
|
59
|
+
except Exception: # noqa: BLE001
|
|
60
|
+
_canon = a.flow
|
|
61
|
+
flow = flows.get(_canon)
|
|
62
|
+
if flow is None:
|
|
63
|
+
print(f"未知流程: {a.flow}(可选: {', '.join(flows)})", file=sys.stderr)
|
|
64
|
+
return 2
|
|
65
|
+
|
|
66
|
+
try:
|
|
67
|
+
if a.fields_from_json:
|
|
68
|
+
have = [str(x) for x in json.loads(Path(a.fields_from_json).read_text(encoding="utf-8"))]
|
|
69
|
+
else:
|
|
70
|
+
table = a.table or flow.get("source", {}).get("table", "")
|
|
71
|
+
if not table:
|
|
72
|
+
print("缺 --table(或流程未声明 source.table)", file=sys.stderr)
|
|
73
|
+
return 2
|
|
74
|
+
have = live_field_names(table, a.profile or flow.get("source", {}).get("identity"))
|
|
75
|
+
except Exception as exc:
|
|
76
|
+
print(f"读不到数据源: {exc}", file=sys.stderr)
|
|
77
|
+
return 2
|
|
78
|
+
|
|
79
|
+
# 字段要求按**当前变体**解析(FULL 的 legacy/lip 列名不同;见 flow_config.load_config)
|
|
80
|
+
try:
|
|
81
|
+
import flow_config as _fc
|
|
82
|
+
_cfg = _fc.load_config(a.flow, strict=False) # P2a:不要传 base 路径(会退化成单文件)
|
|
83
|
+
want = _cfg.get("required") or flow["required"]
|
|
84
|
+
except Exception:
|
|
85
|
+
want = flow["required"]
|
|
86
|
+
missing = [f for f in want if f["name"] not in have]
|
|
87
|
+
# 2026-09-15:同一源列在需求里出现多次(如「重量」对应模板 K/L 两行)时,缺口按名去重
|
|
88
|
+
_seen, _uniq = set(), []
|
|
89
|
+
for _m in missing:
|
|
90
|
+
if _m["name"] in _seen:
|
|
91
|
+
continue
|
|
92
|
+
_seen.add(_m["name"])
|
|
93
|
+
_uniq.append(_m)
|
|
94
|
+
missing = _uniq
|
|
95
|
+
extra_hint = [f for f in want if f["name"] in have]
|
|
96
|
+
result = {
|
|
97
|
+
"flow": a.flow, "role": flow.get("role"), "ok": not missing,
|
|
98
|
+
"have": len(have), "required": len(want),
|
|
99
|
+
"missing": missing, "satisfied": [f["name"] for f in extra_hint],
|
|
100
|
+
}
|
|
101
|
+
if a.json:
|
|
102
|
+
print(json.dumps(result, ensure_ascii=False, indent=2))
|
|
103
|
+
else:
|
|
104
|
+
print(f"流程 {a.flow}(责任角色 {flow.get('role')})|数据源字段 {len(have)} 个|要求 {len(want)} 个")
|
|
105
|
+
if missing:
|
|
106
|
+
print(f"\n❌ 缺 {len(missing)} 个字段(分诊层据此落卡并提示补录):")
|
|
107
|
+
for f in missing:
|
|
108
|
+
print(f" · {f['name']:<16} 用途: {f.get('why') or f.get('usedBy') or '-'}|应由: {f.get('owner','?')} 补")
|
|
109
|
+
else:
|
|
110
|
+
print("\n✅ 字段齐备,可分派给该流程角色")
|
|
111
|
+
return 0 if not missing else 1
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
if __name__ == "__main__":
|
|
115
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""ML(美客多)店铺 → 卖家 user_id 的**唯一解析入口**(真源:`scripts/ml-store-ids.json`)。
|
|
3
|
+
|
|
4
|
+
## 为什么要有这个文件(2026-09-19 真实事故)
|
|
5
|
+
同一个概念曾在三处各写一份、键格式还不同,其中鑫中航发票那条线因查不到映射**静默回退**成
|
|
6
|
+
**紫鸟 store_id**(浏览器店铺 ID,如 27494792824433),而不是 ML 卖家 ID(如 2475636269)——
|
|
7
|
+
6 张发票的 PO Number 全写错、无人发现。根因不是"少配一个文件",而是:
|
|
8
|
+
· 同一概念多处副本(改一处不改另一处);
|
|
9
|
+
· **查不到就用一个"看起来合理"的近似值顶上**(错误被静默吞掉)。
|
|
10
|
+
本模块一次性解决两条:单点真源 + 查不到**响亮失败**(返回空串,调用方必须据此停手,
|
|
11
|
+
绝不回退成另一个 ID 体系的值)。
|
|
12
|
+
|
|
13
|
+
用法:
|
|
14
|
+
from ml_store_ids import resolve, load, store_key
|
|
15
|
+
resolve("墨西哥-2店-子账号") # → '2475636269'
|
|
16
|
+
resolve("巴西-1店") # → ''(未配置 ⇒ 调用方必须停手并报出来)
|
|
17
|
+
"""
|
|
18
|
+
from __future__ import annotations
|
|
19
|
+
|
|
20
|
+
import json
|
|
21
|
+
import pathlib
|
|
22
|
+
import re
|
|
23
|
+
|
|
24
|
+
MAP_PATH = pathlib.Path(__file__).resolve().parent / "ml-store-ids.json"
|
|
25
|
+
|
|
26
|
+
_CACHE: dict | None = None
|
|
27
|
+
|
|
28
|
+
# 已知「有行但未配置」的店铺(写进文档,让"没配"是显式的而不是撞运气撞出来的)
|
|
29
|
+
UNKNOWN_HINT = ["巴西-1店"]
|
|
30
|
+
|
|
31
|
+
# 这些店铺**为什么**没有 ID —— 直接写进给运营看的错误信息里(2026-09-19 用户口径:
|
|
32
|
+
# 「巴西-1店当前是没有给到账号的,所以可以写明原因即可」)。
|
|
33
|
+
# 区分"运营还没给账号"(等对方)与"店铺名没认出来"(多半是写法变了/选错行),
|
|
34
|
+
# 因为两者的下一步动作完全不同 —— 混成一句话会让人去查错方向。
|
|
35
|
+
NO_ACCOUNT_YET = {
|
|
36
|
+
"巴西-1店": "该店铺尚未取得 ML 账号 ID(运营待提供)",
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def missing_reason(store_name) -> str:
|
|
41
|
+
"""解析不到 ID 时,给**人看**的原因(写进「发票错误信息」/日志)。
|
|
42
|
+
|
|
43
|
+
语气刻意是"陈述 + 下一步",不是"报错":这是一种已知的、可接受的等待态
|
|
44
|
+
(巴西店还没账号),不是系统故障。
|
|
45
|
+
"""
|
|
46
|
+
key = store_key(store_name)
|
|
47
|
+
if key in NO_ACCOUNT_YET:
|
|
48
|
+
return NO_ACCOUNT_YET[key]
|
|
49
|
+
if not key:
|
|
50
|
+
return f"店铺名「{store_name}」无法识别为『国家-店号』(多半是写法变了或选错了行)"
|
|
51
|
+
return f"真源 scripts/ml-store-ids.json 里没有「{key}」(新店?请运营提供 ML 账号 ID)"
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def load(path: pathlib.Path | None = None) -> dict:
|
|
55
|
+
"""读真源(`{_doc..., stores: {'<N>店': '<mlUserId>'}}`)。"""
|
|
56
|
+
global _CACHE
|
|
57
|
+
if path is not None:
|
|
58
|
+
return json.loads(pathlib.Path(path).read_text(encoding="utf-8")).get("stores") or {}
|
|
59
|
+
if _CACHE is None:
|
|
60
|
+
_CACHE = json.loads(MAP_PATH.read_text(encoding="utf-8")).get("stores") or {}
|
|
61
|
+
return _CACHE
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def parse_store_name(store_name):
|
|
65
|
+
r"""店铺名 → (国家, '<N>店');取不到国家返回 ''(历史短名如 '2店-子账号')。
|
|
66
|
+
|
|
67
|
+
拆开国家与本号是**刻意的**:2026-09-19 自测发现,若只用 `(\d+)店` 取键,
|
|
68
|
+
「**巴西**-1店」会命中「1店」并返回**墨西哥**-1店的 ML ID —— 跨国家静默串号,
|
|
69
|
+
与本次事故同一类错误(错得"看起来合理")。lip 表确有 5 行巴西店。
|
|
70
|
+
"""
|
|
71
|
+
s = store_name
|
|
72
|
+
if isinstance(s, list):
|
|
73
|
+
s = s[0] if s else ""
|
|
74
|
+
if isinstance(s, dict):
|
|
75
|
+
s = s.get("text") or s.get("name") or ""
|
|
76
|
+
if s is None:
|
|
77
|
+
return "", ""
|
|
78
|
+
text = str(s)
|
|
79
|
+
m = re.search(r"(\d+)\s*店", text)
|
|
80
|
+
key = f"{m.group(1)}店" if m else ""
|
|
81
|
+
c = re.search(r"(墨西哥|巴西|智利|哥伦比亚|阿根廷|秘鲁|乌拉圭)", text)
|
|
82
|
+
return (c.group(1) if c else ""), key
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def store_key(store_name) -> str:
|
|
86
|
+
"""店铺名 → 真源键 `<国家>-<N>店`;历史短名(无国家前缀,如 '2店-子账号')按墨西哥处理。
|
|
87
|
+
|
|
88
|
+
"无国家前缀按墨西哥"是**有据**的:短名只出现在 legacy 旧表与旧管线(那时只有墨西哥店),
|
|
89
|
+
lip 表自身的『店铺』值一律带国家前缀。带国家前缀但该国未配置(如巴西)⇒ 返回原样键,
|
|
90
|
+
查不到即失败(**不跨国家兜底**)。
|
|
91
|
+
"""
|
|
92
|
+
country, key = parse_store_name(store_name)
|
|
93
|
+
if not key:
|
|
94
|
+
return ""
|
|
95
|
+
if not country:
|
|
96
|
+
return f"墨西哥-{key}" # legacy 短名
|
|
97
|
+
return f"{country}-{key}"
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def resolve(store_name, ids: dict | None = None) -> str:
|
|
101
|
+
"""店铺名 → ML user_id;**未配置返回空串**(绝不回退成紫鸟 ID 之类的近似值)。
|
|
102
|
+
|
|
103
|
+
调用方契约:返回空串 = **停手并报出来**(写「发票错误信息」/跳过该行),
|
|
104
|
+
绝不许拿别的 ID 顶上 —— 2026-09-19 的 6 张错发票就是"顶上"顶出来的。
|
|
105
|
+
"""
|
|
106
|
+
table = ids if ids is not None else load()
|
|
107
|
+
k = store_key(store_name)
|
|
108
|
+
if k and k in table:
|
|
109
|
+
return str(table[k]).strip()
|
|
110
|
+
# 兜底:整名命中(历史映射里出现过完整名作键的写法)
|
|
111
|
+
s = str(store_name or "").strip()
|
|
112
|
+
return str(table.get(s, "")).strip() if s else ""
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def main(argv=None) -> int:
|
|
116
|
+
import argparse
|
|
117
|
+
ap = argparse.ArgumentParser(description="店铺 → ML 卖家 ID 解析(真源 scripts/ml-store-ids.json)")
|
|
118
|
+
ap.add_argument("store", nargs="?", help="店铺名(如 墨西哥-2店-子账号);省略则打印全表")
|
|
119
|
+
ap.add_argument("--json", action="store_true")
|
|
120
|
+
a = ap.parse_args(argv)
|
|
121
|
+
table = load()
|
|
122
|
+
if not a.store:
|
|
123
|
+
if a.json:
|
|
124
|
+
print(json.dumps(table, ensure_ascii=False, indent=2))
|
|
125
|
+
else:
|
|
126
|
+
print(f" 真源 {MAP_PATH}")
|
|
127
|
+
for k, v in table.items():
|
|
128
|
+
print(f" {k:6} → {v}")
|
|
129
|
+
return 0
|
|
130
|
+
v = resolve(a.store)
|
|
131
|
+
if a.json:
|
|
132
|
+
print(json.dumps({"store": a.store, "key": store_key(a.store), "mlUserId": v}, ensure_ascii=False))
|
|
133
|
+
else:
|
|
134
|
+
print(f" {a.store}(键 {store_key(a.store) or '—'})→ {v or '❌ 未配置(不得回退成其它 ID 体系的值)'}")
|
|
135
|
+
return 0 if v else 1
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
if __name__ == "__main__":
|
|
139
|
+
raise SystemExit(main())
|