@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.
Files changed (305) hide show
  1. package/MANIFEST.json +307 -0
  2. package/engine/VERSION +1 -0
  3. package/engine/agents/catalog.json +454 -0
  4. package/engine/configs/_aliases.proposed.json +651 -0
  5. package/engine/configs/_migration-plan.proposed.json +899 -0
  6. package/engine/configs/account.json +272 -0
  7. package/engine/configs/advanced.json +205 -0
  8. package/engine/configs/host.json +149 -0
  9. package/engine/configs/hr.json +27 -0
  10. package/engine/configs/notify.json +264 -0
  11. package/engine/core/cli/argent.mjs +277 -0
  12. package/engine/core/contracts/argent.contracts.json +1065 -0
  13. package/engine/core/contracts/verbs.schema.json +2539 -0
  14. package/engine/core/lib/argent-datadir.mjs +223 -0
  15. package/engine/core/lib/audit.mjs +187 -0
  16. package/engine/core/lib/claim.mjs +258 -0
  17. package/engine/core/lib/config-catalog.mjs +1172 -0
  18. package/engine/core/lib/doctor-customer.mjs +577 -0
  19. package/engine/core/lib/flow-list.mjs +138 -0
  20. package/engine/core/lib/flow-registry.mjs +48 -0
  21. package/engine/core/lib/init.mjs +247 -0
  22. package/engine/core/lib/ledger.mjs +124 -0
  23. package/engine/core/lib/license-activate.mjs +813 -0
  24. package/engine/core/lib/license-device.mjs +314 -0
  25. package/engine/core/lib/license-file.mjs +349 -0
  26. package/engine/core/lib/license-guard.mjs +123 -0
  27. package/engine/core/lib/license-ops.mjs +1645 -0
  28. package/engine/core/lib/license-verdict.mjs +133 -0
  29. package/engine/core/lib/license.mjs +577 -0
  30. package/engine/core/lib/notify/dedup.mjs +101 -0
  31. package/engine/core/lib/notify/feishu.mjs +38 -0
  32. package/engine/core/lib/notify/index.mjs +95 -0
  33. package/engine/core/lib/notify/verb.mjs +327 -0
  34. package/engine/core/lib/notify/webhook.mjs +135 -0
  35. package/engine/core/lib/notify/wecom.mjs +36 -0
  36. package/engine/core/lib/python.mjs +145 -0
  37. package/engine/core/lib/sop.mjs +116 -0
  38. package/engine/core/lib/versions.mjs +205 -0
  39. package/engine/core/mcp/client.mjs +67 -0
  40. package/engine/core/mcp/http.mjs +138 -0
  41. package/engine/core/mcp/server.mjs +702 -0
  42. package/engine/scripts/_engine_rules_probe.py +15 -0
  43. package/engine/scripts/analyze-full-day.py +568 -0
  44. package/engine/scripts/archive/feishu-bridge.js +246 -0
  45. package/engine/scripts/argent-agents.mjs +527 -0
  46. package/engine/scripts/argent-capabilities.mjs +776 -0
  47. package/engine/scripts/argent-catalog.mjs +186 -0
  48. package/engine/scripts/argent-datadir.py +62 -0
  49. package/engine/scripts/argent-doctor.mjs +624 -0
  50. package/engine/scripts/argent-env-write.mjs +302 -0
  51. package/engine/scripts/argent-schedule.mjs +620 -0
  52. package/engine/scripts/argent-setup-check.mjs +369 -0
  53. package/engine/scripts/argent-upgrade.mjs +1046 -0
  54. package/engine/scripts/base-bootstrap.sh +575 -0
  55. package/engine/scripts/billing-mode-daily.sh +12 -0
  56. package/engine/scripts/build-engine-package.mjs +123 -0
  57. package/engine/scripts/capability-packs.lock.json +484 -0
  58. package/engine/scripts/capability_pack.py +1242 -0
  59. package/engine/scripts/check-1.0-criteria.mjs +355 -0
  60. package/engine/scripts/check-agent-catalog.mjs +141 -0
  61. package/engine/scripts/check-billing-mode.sh +377 -0
  62. package/engine/scripts/check-child-sessions.mjs +83 -0
  63. package/engine/scripts/check-config-catalog.mjs +677 -0
  64. package/engine/scripts/check-docs-drift.mjs +522 -0
  65. package/engine/scripts/check-dsh-web-expose.sh +98 -0
  66. package/engine/scripts/check-judgment-drift.mjs +403 -0
  67. package/engine/scripts/check-license.mjs +199 -0
  68. package/engine/scripts/check-model-auth.py +443 -0
  69. package/engine/scripts/check-pack-closure.mjs +661 -0
  70. package/engine/scripts/check-portable-symbols.mjs +116 -0
  71. package/engine/scripts/check-preset-landing.mjs +124 -0
  72. package/engine/scripts/check-production-home.mjs +602 -0
  73. package/engine/scripts/check-role-mapping.mjs +461 -0
  74. package/engine/scripts/check-sample-redaction.mjs +320 -0
  75. package/engine/scripts/check-skill-classification.mjs +188 -0
  76. package/engine/scripts/check-sop-consistency.mjs +431 -0
  77. package/engine/scripts/check-test-env-safety.mjs +627 -0
  78. package/engine/scripts/check-version-consistency.mjs +452 -0
  79. package/engine/scripts/ci-run.sh +558 -0
  80. package/engine/scripts/config-explain.mjs +278 -0
  81. package/engine/scripts/configure-provider.rb +29 -0
  82. package/engine/scripts/customer-config-migrate.mjs +179 -0
  83. package/engine/scripts/customer-preflight.py +892 -0
  84. package/engine/scripts/customer-readiness.sh +134 -0
  85. package/engine/scripts/daily-report-inbox.py +242 -0
  86. package/engine/scripts/daily-report-reconcile.mjs +312 -0
  87. package/engine/scripts/daily-report.mjs +1310 -0
  88. package/engine/scripts/daily-report.sh +46 -0
  89. package/engine/scripts/data/lip-product-dict.json +306 -0
  90. package/engine/scripts/deliver-customer.mjs +932 -0
  91. package/engine/scripts/delivery-faces.txt +31 -0
  92. package/engine/scripts/desktop-trial.sh +146 -0
  93. package/engine/scripts/dev-window.sh +260 -0
  94. package/engine/scripts/drill-clean-machine.sh +315 -0
  95. package/engine/scripts/dsh-api-client.mjs +215 -0
  96. package/engine/scripts/dsh-backup-scope.sh +83 -0
  97. package/engine/scripts/dsh-offline-pack.mjs +77 -0
  98. package/engine/scripts/dsh-overlay-pin.sh +87 -0
  99. package/engine/scripts/dsh-plane.mjs +153 -0
  100. package/engine/scripts/dsh-portforward.py +223 -0
  101. package/engine/scripts/dsh-preflight.mjs +179 -0
  102. package/engine/scripts/dsh-release-watch-daily.sh +19 -0
  103. package/engine/scripts/dsh-release-watch.mjs +458 -0
  104. package/engine/scripts/dsh-remote-check.sh +99 -0
  105. package/engine/scripts/dsh-restart.sh +179 -0
  106. package/engine/scripts/dsh-restore.sh +111 -0
  107. package/engine/scripts/dsh-scope-rewire.mjs +803 -0
  108. package/engine/scripts/dsh-snapshot.mjs +116 -0
  109. package/engine/scripts/dsh-upgrade-readiness.mjs +165 -0
  110. package/engine/scripts/dsh-upgrade.mjs +612 -0
  111. package/engine/scripts/dsh-url.sh +86 -0
  112. package/engine/scripts/dsh-web-launch.mjs +155 -0
  113. package/engine/scripts/ensure-store-windows.py +509 -0
  114. package/engine/scripts/entitlements.py +458 -0
  115. package/engine/scripts/env_probe.py +411 -0
  116. package/engine/scripts/feishu-card.mjs +252 -0
  117. package/engine/scripts/fix-skill-frontmatter.py +209 -0
  118. package/engine/scripts/flow-auto-retry.py +454 -0
  119. package/engine/scripts/flow-requirements.json +720 -0
  120. package/engine/scripts/flow-scaffold.py +275 -0
  121. package/engine/scripts/flow-timers-plist.sh +86 -0
  122. package/engine/scripts/flow-timers.sh +182 -0
  123. package/engine/scripts/flow-trigger-wake.mjs +284 -0
  124. package/engine/scripts/flow-trigger.sh +571 -0
  125. package/engine/scripts/flow_billing.py +354 -0
  126. package/engine/scripts/flow_capability_stats.py +314 -0
  127. package/engine/scripts/flow_case.py +194 -0
  128. package/engine/scripts/flow_claim.py +497 -0
  129. package/engine/scripts/flow_config.py +1024 -0
  130. package/engine/scripts/flow_failure.py +588 -0
  131. package/engine/scripts/flow_learn.py +105 -0
  132. package/engine/scripts/flow_ledger.py +235 -0
  133. package/engine/scripts/flow_policy.py +238 -0
  134. package/engine/scripts/flow_preflight.py +339 -0
  135. package/engine/scripts/flow_registry.py +341 -0
  136. package/engine/scripts/flow_retry.py +304 -0
  137. package/engine/scripts/flow_return_to_ops.py +191 -0
  138. package/engine/scripts/flow_source.py +315 -0
  139. package/engine/scripts/flow_sources/__init__.py +53 -0
  140. package/engine/scripts/flow_sources/cases_json.py +106 -0
  141. package/engine/scripts/flow_sources/common.py +428 -0
  142. package/engine/scripts/flow_sources/feishu_base.py +273 -0
  143. package/engine/scripts/flow_stale.py +185 -0
  144. package/engine/scripts/flow_status_reconcile.py +344 -0
  145. package/engine/scripts/flow_triage.py +849 -0
  146. package/engine/scripts/flow_write_verify.py +496 -0
  147. package/engine/scripts/fulfillment.js +586 -0
  148. package/engine/scripts/gen-agent-bundles.mjs +276 -0
  149. package/engine/scripts/gen-preset-rows.mjs +259 -0
  150. package/engine/scripts/init-ml.sh +2275 -0
  151. package/engine/scripts/install-internal-role.sh +190 -0
  152. package/engine/scripts/install-license.mjs +641 -0
  153. package/engine/scripts/install-one-shot.mjs +665 -0
  154. package/engine/scripts/integration_contract.py +220 -0
  155. package/engine/scripts/integrations/wenyao/adapter.py +98 -0
  156. package/engine/scripts/integrations/xzh/adapter.py +75 -0
  157. package/engine/scripts/invoice-mapping.example.json +40 -0
  158. package/engine/scripts/invoice-table.sh +194 -0
  159. package/engine/scripts/invoice_carrier_notice.py +279 -0
  160. package/engine/scripts/invoice_fail_closeout.py +297 -0
  161. package/engine/scripts/invoice_lip_runner.py +1508 -0
  162. package/engine/scripts/invoice_lip_runner.py.bak-20260922-1710-freready +1090 -0
  163. package/engine/scripts/invoice_ready_audit.py +191 -0
  164. package/engine/scripts/invoice_runner.py +675 -0
  165. package/engine/scripts/invoice_stageb.py +516 -0
  166. package/engine/scripts/launchd/com.whyshu.argent-bridge.plist.example +42 -0
  167. package/engine/scripts/launchd/com.whyshu.fulfillment-poll.plist.example +29 -0
  168. package/engine/scripts/lease.py +377 -0
  169. package/engine/scripts/lib/agent-install.mjs +649 -0
  170. package/engine/scripts/lib/argent-datadir.mjs +16 -0
  171. package/engine/scripts/lib/argent_datadir.py +262 -0
  172. package/engine/scripts/lib/argent_filelock.py +507 -0
  173. package/engine/scripts/lib/bootcheck-wiring.mjs +510 -0
  174. package/engine/scripts/lib/cdp_ports.py +197 -0
  175. package/engine/scripts/lib/customer-env.mjs +102 -0
  176. package/engine/scripts/lib/daily-report-core.mjs +517 -0
  177. package/engine/scripts/lib/dep-declaration.mjs +81 -0
  178. package/engine/scripts/lib/deps-migrate.mjs +310 -0
  179. package/engine/scripts/lib/dsh-host-resolve.mjs +109 -0
  180. package/engine/scripts/lib/dsh-scope.mjs +500 -0
  181. package/engine/scripts/lib/dsh-snapshot-path.mjs +35 -0
  182. package/engine/scripts/lib/dsh-versions.mjs +96 -0
  183. package/engine/scripts/lib/dsh-web-probe.mjs +214 -0
  184. package/engine/scripts/lib/is-direct-run.mjs +61 -0
  185. package/engine/scripts/lib/patch-compose.mjs +241 -0
  186. package/engine/scripts/lib/patch-target.mjs +35 -0
  187. package/engine/scripts/lib/plugin-lifecycle.mjs +128 -0
  188. package/engine/scripts/lib/plugin-packages.mjs +332 -0
  189. package/engine/scripts/lib/preset-compat.mjs +127 -0
  190. package/engine/scripts/lib/preset-install.mjs +575 -0
  191. package/engine/scripts/lib/preset-mechanism.mjs +56 -0
  192. package/engine/scripts/lib/preset-sync.mjs +59 -0
  193. package/engine/scripts/lib/profile-retire.mjs +97 -0
  194. package/engine/scripts/lib/python-runtime.mjs +190 -0
  195. package/engine/scripts/lib/registry.mjs +72 -0
  196. package/engine/scripts/lib/repo-root.sh +56 -0
  197. package/engine/scripts/lib/schedule-mechanism.mjs +659 -0
  198. package/engine/scripts/lib/schedule-probe.mjs +835 -0
  199. package/engine/scripts/lib/scope-pointer.mjs +164 -0
  200. package/engine/scripts/lib/settings-panels.mjs +816 -0
  201. package/engine/scripts/lib/stdio_utf8.py +86 -0
  202. package/engine/scripts/lib/wake-auth.mjs +392 -0
  203. package/engine/scripts/lib/webdriver_ipc.py +264 -0
  204. package/engine/scripts/lib/zstd-frames.mjs +104 -0
  205. package/engine/scripts/license-e2e-drill.mjs +426 -0
  206. package/engine/scripts/license-gate.mjs +245 -0
  207. package/engine/scripts/lip_backlog.py +171 -0
  208. package/engine/scripts/lip_table.py +185 -0
  209. package/engine/scripts/local-usage.mjs +214 -0
  210. package/engine/scripts/migrate-providers.mjs +127 -0
  211. package/engine/scripts/migrate-skills.sh +65 -0
  212. package/engine/scripts/ml-oauth-setup.mjs +550 -0
  213. package/engine/scripts/ml-store-ids.json +26 -0
  214. package/engine/scripts/ml_artifact_attribution.py +333 -0
  215. package/engine/scripts/ml_capacity_probe.py +1158 -0
  216. package/engine/scripts/ml_hub_status.py +1556 -0
  217. package/engine/scripts/ml_schema_check.py +115 -0
  218. package/engine/scripts/ml_store_ids.py +139 -0
  219. package/engine/scripts/npm-publish-argent.mjs +499 -0
  220. package/engine/scripts/npm-publish-argent.sh +20 -0
  221. package/engine/scripts/orchestrator.py +13811 -0
  222. package/engine/scripts/pack-plugins.mjs +140 -0
  223. package/engine/scripts/patches/dsh-llm-deepseek--transport-diagnostics.patch +297 -0
  224. package/engine/scripts/patches/dsh-session--append-message-shape.patch +15 -0
  225. package/engine/scripts/patches/dsh-session--tool-result-block-017.patch +28 -0
  226. package/engine/scripts/patches/dsh-session-format-v0-to-v1--permission-preset-origin.patch +11 -0
  227. package/engine/scripts/patches/dsh-session-format-v3-to-v4--turn-outside-replace.patch +20 -0
  228. package/engine/scripts/patches/dsh-session-persistence-jsonl--worker-bundled-migrators.patch +39 -0
  229. package/engine/scripts/patches/dsh-tools--render-return-shape.patch +50 -0
  230. package/engine/scripts/patches/verify-bundled-migrators.mjs +79 -0
  231. package/engine/scripts/patches/verify-hardening.mjs +167 -0
  232. package/engine/scripts/patches/verify-session-migration.mjs +149 -0
  233. package/engine/scripts/patches/verify-transport-diagnostics.mjs +227 -0
  234. package/engine/scripts/plan-role-rename.mjs +125 -0
  235. package/engine/scripts/plugin-bootcheck.mjs +451 -0
  236. package/engine/scripts/plugin-composition.json +15 -0
  237. package/engine/scripts/poc-mcp-host.mjs +455 -0
  238. package/engine/scripts/poll-fulfillment.sh +293 -0
  239. package/engine/scripts/poll-invoice.sh +74 -0
  240. package/engine/scripts/profile-doctor.mjs +686 -0
  241. package/engine/scripts/provider-select.sh +70 -0
  242. package/engine/scripts/provider-switch.sh +146 -0
  243. package/engine/scripts/provider-sync-target.check.mjs +64 -0
  244. package/engine/scripts/python-runtime.sh +78 -0
  245. package/engine/scripts/query_runner.py +310 -0
  246. package/engine/scripts/release-argent.sh +574 -0
  247. package/engine/scripts/repair-unresolved-tools.mjs +178 -0
  248. package/engine/scripts/run-tests.sh +256 -0
  249. package/engine/scripts/self-sign-license.mjs +179 -0
  250. package/engine/scripts/session-health-scan.mjs +63 -0
  251. package/engine/scripts/session-repair-tool-result-content.mjs +181 -0
  252. package/engine/scripts/setup.sh +22 -0
  253. package/engine/scripts/skill-install.mjs +629 -0
  254. package/engine/scripts/sku_translate.py +148 -0
  255. package/engine/scripts/sync-plugins.sh +90 -0
  256. package/engine/scripts/sync-presets.sh +27 -0
  257. package/engine/scripts/sync-scripts.sh +445 -0
  258. package/engine/scripts/telemetry.py +873 -0
  259. package/engine/scripts/ui-copy-count.mjs +220 -0
  260. package/engine/scripts/usage-anchor.sh +136 -0
  261. package/engine/scripts/usage_report.py +531 -0
  262. package/engine/scripts/validate-preset-schema.mjs +208 -0
  263. package/engine/scripts/vertical-init.mjs +323 -0
  264. package/engine/scripts/vertical-lint.mjs +482 -0
  265. package/engine/scripts/wenyao-browser.sh +73 -0
  266. package/engine/scripts/wenyao-fixture-export.py +116 -0
  267. package/engine/scripts/wenyao-invoice-writeback.mjs +540 -0
  268. package/engine/scripts/wenyao-login.sh +34 -0
  269. package/engine/scripts/wenyao-template-map.json +292 -0
  270. package/engine/scripts/wenyao_attach.py +131 -0
  271. package/engine/scripts/wenyao_download_template.py +144 -0
  272. package/engine/scripts/wenyao_fill_template.py +568 -0
  273. package/engine/scripts/wenyao_login.py +145 -0
  274. package/engine/scripts/wenyao_portal.py +633 -0
  275. package/engine/scripts/wenyao_recon.py +230 -0
  276. package/engine/scripts/wenyao_run.py +503 -0
  277. package/engine/scripts/wenyao_shadow_diff.py +160 -0
  278. package/engine/scripts/wenyao_skill_contract.py +156 -0
  279. package/engine/scripts/wenyao_template_fetch.py +175 -0
  280. package/engine/scripts/win/dsh-web-autostart.ps1 +372 -0
  281. package/engine/scripts/ziniao-auth-probe.sh +268 -0
  282. package/engine/scripts/ziniao-keepalive.sh +216 -0
  283. package/engine/scripts/ziniao-post-upgrade-check.sh +120 -0
  284. package/engine/scripts/ziniao-windows.sh +153 -0
  285. package/engine/version.mjs +1 -0
  286. package/engine/verticals/README.md +103 -0
  287. package/engine/verticals/_engine-words.baseline.txt +237 -0
  288. package/engine/verticals/_engine-words.json +19 -0
  289. package/engine/verticals/mercadolibre/README.md +43 -0
  290. package/engine/verticals/mercadolibre/config.json +709 -0
  291. package/engine/verticals/mercadolibre/flows.json +706 -0
  292. package/engine/verticals/mercadolibre/manifest.json +538 -0
  293. package/engine/verticals/mercadolibre/migrate-machine-state.mjs +138 -0
  294. package/engine/verticals/mercadolibre/preflight.py +143 -0
  295. package/engine/verticals/mercadolibre/prompts/daily-report.failure.md +69 -0
  296. package/engine/verticals/mercadolibre/prompts/daily-report.md +47 -0
  297. package/engine/verticals/mercadolibre/prompts/daily-report.scheduled.md +79 -0
  298. package/engine/verticals/mercadolibre/prompts/full.failure.md +125 -0
  299. package/engine/verticals/mercadolibre/prompts/full.md +91 -0
  300. package/engine/verticals/mercadolibre/prompts/wenyao-invoice.failure.md +88 -0
  301. package/engine/verticals/mercadolibre/prompts/wenyao-invoice.md +64 -0
  302. package/engine/verticals/mercadolibre/prompts/xzh-invoice.failure.md +91 -0
  303. package/engine/verticals/mercadolibre/prompts/xzh-invoice.md +46 -0
  304. package/package.json +21 -4
  305. package/README.md +0 -3
@@ -0,0 +1,538 @@
1
+ {
2
+ "id": "mercadolibre",
3
+ "version": "0.1.2",
4
+ "title": "美客多(MercadoLibre)业务线",
5
+ "_note": "P2a 落位:flows/prompts/暂停开关/日志/会话文件已命名空间化;角色/preset/技能仍是旧名(legacyNaming,P2b/P5 在有重启窗口时改名);能力与计费单位仍在 base(随重装窗口改 SKU id);适配器仍在 scripts/integrations(P4 端口化时搬)。",
6
+ "_versionNote": "0.1.1(2026-10-06):`requires.argent` 由 `>=0.2 <0.3` 抬到 `>=0.3 <0.4`(平台现役 VERSION=0.3.0)—— 修前「Argent 能力 → 概览」把这唯一的业务线标成 `⚠️ 版本不满足`,而它实际能跑(口径与事实相反)。同批 `version` +1(P0-5,见 docs/Argent-工作台口径审计-2026-10-06.md)。|0.1.2(2026-10-09):**平台抬到 0.4.0** ⇒ `requires.argent` 同步抬到 `>=0.4 <0.5`(不改则会重演 P0-5:兼容区间把现役平台挡在门外)。判据已固化为门禁 `node scripts/check-version-consistency.mjs`(**平台版本必须落在每条业务线声明的兼容区间内**),不再靠人记得复核。⚠️ `verifiedOn.argent` **刻意维持 `0.3.0`**:该字段记的是\"**真装真跑过**\",本批只抬版本号、内核无行为改动,未在 0.4.0 上跑过生产 ⇒ 落地后补登,⛔ 不预填。",
7
+ "requires": {
8
+ "argent": ">=0.4 <0.5",
9
+ "dsh": ">=0.1.5 <0.2"
10
+ },
11
+ "verifiedOn": {
12
+ "argent": [
13
+ "0.3.0"
14
+ ],
15
+ "dsh": [
16
+ "0.1.5-rc.1",
17
+ "0.1.7-rc.2"
18
+ ]
19
+ },
20
+ "ports": {
21
+ "source": "feishu-base",
22
+ "transport": "feishu",
23
+ "notify": "feishu-card",
24
+ "actor": "portal",
25
+ "identity": "env"
26
+ },
27
+ "_capabilitiesNote": "2026-10-09(变现分层落地):`daily-report` 由 `enterprise` 降为 **`pro`** —— 判据 = 「**只读 ⇒ Pro / 写操作 ⇒ 企业版**」:日报只走官方 API 只读查询 + 生成推送,⛔ 不写客户任何系统、⛔ 不动浏览器;`full`(箱唛等写操作)与 `invoice`(门户写操作)**保持 `enterprise`**。唯一真源仍是 `scripts/flow-requirements.json#capabilities.<id>.minPlan`(本文件是业务线侧的同批声明,`node scripts/vertical-lint.mjs` 校验两处不得漂移)。",
28
+ "capabilities": [
29
+ {
30
+ "id": "daily-report",
31
+ "minPlan": "pro"
32
+ },
33
+ {
34
+ "id": "full",
35
+ "minPlan": "enterprise"
36
+ },
37
+ {
38
+ "id": "invoice",
39
+ "minPlan": "enterprise"
40
+ }
41
+ ],
42
+ "roles": [
43
+ "argent-ml-fulfillment",
44
+ "argent-ml-invoice-wy",
45
+ "argent-ml-invoice-xzh",
46
+ "argent-ml-daily"
47
+ ],
48
+ "skills": [
49
+ "ml-fulfillment-sop",
50
+ "ml-invoice",
51
+ "ml-invoice-xzh",
52
+ "ml-store-daily-report",
53
+ "ml-config-guide"
54
+ ],
55
+ "flows": [
56
+ "mercadolibre.full",
57
+ "mercadolibre.wenyao-invoice",
58
+ "mercadolibre.xzh-invoice",
59
+ "mercadolibre.daily-report"
60
+ ],
61
+ "preflight": "preflight.py",
62
+ "legacyNaming": [
63
+ "roles",
64
+ "skills"
65
+ ],
66
+ "_settingsPanelNote": "能力包设置页契约(docs/能力包设置页契约.md):**一个能力一页**,按 `capabilities` 绑定 —— 装了就出现、没装不出现(判据在 host/仓库脚本,客户端零名单)。面板级档位见各面板的 `minPlan`(缺省由绑定能力的注册表 minPlan 派生,**不新建第二份档位表**)。字段值只读;env 字段在 `ARGENT_ENV_WRITER=1` 时走受控写入器(写前备份 + 写后读回 + 审计 JSONL,只落 ~/.dsh/argent/** 的约定 env 路径),其余字段只复用既有端点(/api/argent-state/config、/api/argent-state/ziniao-key)。",
67
+ "settingsPanels": [
68
+ {
69
+ "id": "mercadolibre.settings",
70
+ "title": "美客多业务线",
71
+ "order": 10,
72
+ "capabilities": [
73
+ "full",
74
+ "invoice",
75
+ "daily-report"
76
+ ],
77
+ "hint": "本页字段来自能力包自己的声明(verticals/mercadolibre/manifest.json);未安装美客多能力包时本页不出现。",
78
+ "fields": [
79
+ {
80
+ "key": "feishuAppId",
81
+ "label": "飞书应用 App ID",
82
+ "type": "text",
83
+ "placeholder": "cli_xxx",
84
+ "hint": "推送/对话用的自建应用;保存后立刻切换 lark-cli 身份。",
85
+ "bind": {
86
+ "read": {
87
+ "from": "config",
88
+ "key": "feishuAppId"
89
+ },
90
+ "write": {
91
+ "endpoint": "/api/argent-state/config",
92
+ "field": "feishuAppId"
93
+ }
94
+ }
95
+ },
96
+ {
97
+ "key": "feishuAppSecret",
98
+ "label": "飞书应用 App Secret",
99
+ "type": "password",
100
+ "placeholder": "仅保存在本机",
101
+ "hint": "留空 = 保持原值(不会清空)。",
102
+ "bind": {
103
+ "read": {
104
+ "from": "config",
105
+ "key": "feishuAppSecretConfigured"
106
+ },
107
+ "write": {
108
+ "endpoint": "/api/argent-state/config",
109
+ "field": "feishuAppSecret"
110
+ }
111
+ }
112
+ },
113
+ {
114
+ "key": "feishuChatId",
115
+ "label": "飞书推送群(可选)",
116
+ "type": "text",
117
+ "placeholder": "oc_xxx / ou_xxx",
118
+ "hint": "通用群(非日报专用):流程通知/告警的兜底落点;日报群另有 mlDailyChatId(在「美客多日报」页)。",
119
+ "bind": {
120
+ "read": {
121
+ "from": "config",
122
+ "key": "feishuChatId"
123
+ },
124
+ "write": {
125
+ "endpoint": "/api/argent-state/config",
126
+ "field": "feishuChatId"
127
+ }
128
+ }
129
+ },
130
+ {
131
+ "key": "feishuBaseUrl",
132
+ "label": "飞书表格 URL(Base)",
133
+ "type": "text",
134
+ "placeholder": "https://xxx.feishu.cn/base/XXX",
135
+ "hint": "已有 Base 时填写;留空则由一键体检自动代建。",
136
+ "bind": {
137
+ "read": {
138
+ "from": "config",
139
+ "key": "feishuBaseUrl"
140
+ },
141
+ "write": {
142
+ "endpoint": "/api/argent-state/config",
143
+ "field": "feishuBaseUrl"
144
+ }
145
+ }
146
+ },
147
+ {
148
+ "key": "ziniaoApiKey",
149
+ "label": "紫鸟 API Key",
150
+ "type": "password",
151
+ "placeholder": "open.ziniao.com 获取(用户应用管理)",
152
+ "hint": "写入 ziniao-cli 自身配置(--no-keychain),不入 config.json。",
153
+ "bind": {
154
+ "read": {
155
+ "from": "config",
156
+ "key": "ziniaoApiKeyMasked"
157
+ },
158
+ "write": {
159
+ "endpoint": "/api/argent-state/ziniao-key",
160
+ "field": "apiKey"
161
+ }
162
+ }
163
+ },
164
+ {
165
+ "key": "stores",
166
+ "label": "店铺映射(紫鸟实时读取)",
167
+ "type": "text",
168
+ "hint": "只读:由「一键体检 / 刷新店铺」从紫鸟写入 STORES_JSON 指向的文件。",
169
+ "bind": {
170
+ "read": {
171
+ "from": "json",
172
+ "pathFromEnv": "STORES_JSON",
173
+ "mode": "keys"
174
+ }
175
+ }
176
+ }
177
+ ],
178
+ "_note": "业务线级面板(**任一已装即显示**):只放跨能力共用的对外配置面 —— 飞书应用凭据(App ID/Secret/推送群)/ 客户飞书表 URL / 紫鸟 API Key / 店铺映射。各能力**专属**的字段在下面的能力面板里(FULL 货件 / 发票 / 美客多日报):2026-10-01 迁移,`mlDailyTime` 与 `mlDailyStoreCount` 已移入 mercadolibre.daily-report。2026-10-01 第二层(清理迁移期重复):这些字段的**唯一入口就是本页** —— skin 通用区(Argent 页「账号与密钥 / 美客多业务线」)里的同名输入框已删除(契约 §14);`feishuChatId` 原本只在 skin 里有入口,属**漏项**,本次补进本页声明(写入口 /api/argent-state/config 的 CONFIG_KEYS 白名单里本就有它)。"
179
+ },
180
+ {
181
+ "id": "mercadolibre.full",
182
+ "title": "FULL 货件",
183
+ "order": 20,
184
+ "capabilities": [
185
+ "full"
186
+ ],
187
+ "hint": "FULL(美客多货件)专属配置:货件表、通知模式、紫鸟店铺浏览器凭据。env 字段写入 ~/.dsh/argent/verticals/mercadolibre/env/ 下的约定文件(写前备份 + 写后读回 + 审计;写入器默认关闭)。",
188
+ "fields": [
189
+ {
190
+ "key": "fullTableId",
191
+ "label": "FULL 货件表 ID(Base table)",
192
+ "type": "text",
193
+ "env": "FULL_TABLE_ID",
194
+ "envFile": "fulfillment.env",
195
+ "scope": "vertical",
196
+ "placeholder": "tbl…",
197
+ "hint": "FULL 流程认领/回写的飞书表 id;改错 ⇒ 认领不到票。"
198
+ },
199
+ {
200
+ "key": "fullBaseToken",
201
+ "label": "FULL 表 Base Token",
202
+ "type": "password",
203
+ "env": "FULL_BASE_TOKEN",
204
+ "envFile": "fulfillment.env",
205
+ "scope": "vertical",
206
+ "hint": "该表的读写身份 token(只保存在本机)。"
207
+ },
208
+ {
209
+ "key": "fullNotifyMode",
210
+ "label": "FULL 通知模式",
211
+ "type": "select",
212
+ "env": "FULL_NOTIFY_MODE",
213
+ "envFile": "fulfillment.env",
214
+ "scope": "vertical",
215
+ "hint": "final=只发最终完成卡(默认)|facts=全静默、只记事实(排障)|feishu=旧行为(步骤消息+卡片全发)。",
216
+ "options": [
217
+ "final",
218
+ "facts",
219
+ "feishu"
220
+ ]
221
+ },
222
+ {
223
+ "key": "fullLarkProfile",
224
+ "label": "FULL 推送身份(lark-cli profile)",
225
+ "type": "text",
226
+ "env": "FULL_LARK_PROFILE",
227
+ "envFile": "fulfillment.env",
228
+ "scope": "vertical",
229
+ "hint": "发卡片用哪个 Bot 身份;客户机没有独立 Bot 时填主 Bot 的 profile。"
230
+ },
231
+ {
232
+ "key": "fullDoneChatId",
233
+ "label": "完成卡群 id",
234
+ "type": "text",
235
+ "env": "FULL_DONE_CHAT_ID",
236
+ "envFile": "fulfillment.env",
237
+ "scope": "vertical",
238
+ "placeholder": "oc_…"
239
+ },
240
+ {
241
+ "key": "fullDoneProfile",
242
+ "label": "完成卡推送身份",
243
+ "type": "text",
244
+ "env": "FULL_DONE_PROFILE",
245
+ "envFile": "fulfillment.env",
246
+ "scope": "vertical"
247
+ },
248
+ {
249
+ "key": "fullInternalChatId",
250
+ "label": "内部群 id(需人工裁定用)",
251
+ "type": "text",
252
+ "env": "FULL_INTERNAL_CHAT_ID",
253
+ "envFile": "fulfillment.env",
254
+ "scope": "vertical",
255
+ "placeholder": "oc_…"
256
+ },
257
+ {
258
+ "key": "ziniaoMode",
259
+ "label": "紫鸟接入模式",
260
+ "type": "select",
261
+ "env": "ZINIAO_MODE",
262
+ "envFile": "fulfillment.env",
263
+ "scope": "vertical",
264
+ "hint": "bridge=ziniao-cli(默认)|webdriver=常驻 WebDriver(推荐)|selenium=官方 Selenium 客户端。",
265
+ "options": [
266
+ "bridge",
267
+ "webdriver",
268
+ "selenium"
269
+ ]
270
+ },
271
+ {
272
+ "key": "ziniaoDl",
273
+ "label": "紫鸟下载目录",
274
+ "type": "text",
275
+ "env": "ZINIAO_DL",
276
+ "envFile": "fulfillment.env",
277
+ "scope": "vertical",
278
+ "hint": "标签/箱唛下载落点;留空则用 orchestrator 的缺省目录。"
279
+ },
280
+ {
281
+ "key": "ziniaoWdCompany",
282
+ "label": "紫鸟企业号(WebDriver)",
283
+ "type": "text",
284
+ "env": "ZINIAO_WD_COMPANY",
285
+ "envFile": "ziniao-webdriver.env",
286
+ "scope": "vertical",
287
+ "hint": "紫鸟客户端(常驻 WebDriver)登录凭据 —— FULL 用店铺浏览器取标签/箱唛。"
288
+ },
289
+ {
290
+ "key": "ziniaoWdUsername",
291
+ "label": "紫鸟登录账号",
292
+ "type": "text",
293
+ "env": "ZINIAO_WD_USERNAME",
294
+ "envFile": "ziniao-webdriver.env",
295
+ "scope": "vertical"
296
+ },
297
+ {
298
+ "key": "ziniaoWdPassword",
299
+ "label": "紫鸟登录密码",
300
+ "type": "password",
301
+ "env": "ZINIAO_WD_PASSWORD",
302
+ "envFile": "ziniao-webdriver.env",
303
+ "scope": "vertical"
304
+ },
305
+ {
306
+ "key": "ziniaoWdPort",
307
+ "label": "WebDriver 端口",
308
+ "type": "text",
309
+ "env": "ZINIAO_WD_PORT",
310
+ "envFile": "ziniao-webdriver.env",
311
+ "scope": "vertical",
312
+ "placeholder": "19515"
313
+ }
314
+ ]
315
+ },
316
+ {
317
+ "id": "mercadolibre.invoice",
318
+ "title": "发票(文鳐 / 鑫中航)",
319
+ "order": 30,
320
+ "capabilities": [
321
+ "invoice"
322
+ ],
323
+ "hint": "两条发票流程的门户凭据:文鳐(上海文鳐)走 env 文件,鑫中航走 config.json。门户是生产系统 ⇒ 改动后在客户机上跑一次 dry-run 验证。",
324
+ "fields": [
325
+ {
326
+ "key": "wenyaoUrl",
327
+ "label": "文鳐门户地址",
328
+ "type": "text",
329
+ "env": "WENYAO_URL",
330
+ "envFile": "wenyao.env",
331
+ "scope": "vertical",
332
+ "placeholder": "https://my.ffl-tech.com"
333
+ },
334
+ {
335
+ "key": "wenyaoPhone",
336
+ "label": "文鳐门户账号(手机号)",
337
+ "type": "text",
338
+ "env": "WENYAO_PHONE",
339
+ "envFile": "wenyao.env",
340
+ "scope": "vertical"
341
+ },
342
+ {
343
+ "key": "wenyaoPassword",
344
+ "label": "文鳐门户密码",
345
+ "type": "password",
346
+ "env": "WENYAO_PASSWORD",
347
+ "envFile": "wenyao.env",
348
+ "scope": "vertical"
349
+ },
350
+ {
351
+ "key": "xhInvoiceUser",
352
+ "label": "鑫中航门户账号",
353
+ "type": "text",
354
+ "hint": "写生产系统用;改动需在客户机验证。",
355
+ "bind": {
356
+ "read": {
357
+ "from": "config",
358
+ "key": "xhInvoiceUser"
359
+ },
360
+ "write": {
361
+ "endpoint": "/api/argent-state/config",
362
+ "field": "xhInvoiceUser"
363
+ }
364
+ }
365
+ },
366
+ {
367
+ "key": "xhInvoicePass",
368
+ "label": "鑫中航门户密码",
369
+ "type": "password",
370
+ "hint": "留空 = 保持原值(不会清空)。",
371
+ "bind": {
372
+ "read": {
373
+ "from": "config",
374
+ "key": "xhInvoicePass"
375
+ },
376
+ "write": {
377
+ "endpoint": "/api/argent-state/config",
378
+ "field": "xhInvoicePass"
379
+ }
380
+ }
381
+ }
382
+ ]
383
+ },
384
+ {
385
+ "id": "mercadolibre.daily-report",
386
+ "title": "美客多日报",
387
+ "order": 40,
388
+ "capabilities": [
389
+ "daily-report"
390
+ ],
391
+ "hint": "美客多日报(官方 API 采集 → 飞书群卡片):ML OAuth 应用凭据 + 推送参数。推送时间/TopN/补货参数是「单值调参 + 有默认 + 改完能当场验证」⇒ 也可以在会话里让角色改(角色会说清影响)。",
392
+ "fields": [
393
+ {
394
+ "key": "mlAppId",
395
+ "label": "ML 应用 App ID",
396
+ "type": "text",
397
+ "env": "ML_APP_ID",
398
+ "envFile": "daily-report.env",
399
+ "scope": "vertical",
400
+ "hint": "美客多开发者后台的应用 id(OAuth 授权用)。"
401
+ },
402
+ {
403
+ "key": "mlAppSecret",
404
+ "label": "ML 应用 Secret",
405
+ "type": "password",
406
+ "env": "ML_APP_SECRET",
407
+ "envFile": "daily-report.env",
408
+ "scope": "vertical",
409
+ "hint": "只保存在本机;留空 = 保持原值。"
410
+ },
411
+ {
412
+ "key": "mlDailyChatId",
413
+ "label": "日报推送群 id",
414
+ "type": "text",
415
+ "placeholder": "oc_…",
416
+ "hint": "形如 oc_…;留空则回落到 daily-report.env 的 ML_DAILY_CHAT_ID / 内置默认。",
417
+ "bind": {
418
+ "read": {
419
+ "from": "config",
420
+ "key": "mlDailyChatId"
421
+ },
422
+ "write": {
423
+ "endpoint": "/api/argent-state/config",
424
+ "field": "mlDailyChatId"
425
+ }
426
+ }
427
+ },
428
+ {
429
+ "key": "mlDailyTime",
430
+ "label": "日报推送时间(站点本地时间)",
431
+ "type": "text",
432
+ "placeholder": "08:00",
433
+ "hint": "按各店站点本地时间计算;错过或失败会在 +5 小时窗口内逐小时补试(幂等防重)。",
434
+ "bind": {
435
+ "read": {
436
+ "from": "config",
437
+ "key": "mlDailyTime"
438
+ },
439
+ "write": {
440
+ "endpoint": "/api/argent-state/config",
441
+ "field": "mlDailyTime"
442
+ }
443
+ }
444
+ },
445
+ {
446
+ "key": "mlDailyTopN",
447
+ "label": "畅销榜条数(1–20)",
448
+ "type": "text",
449
+ "bind": {
450
+ "read": {
451
+ "from": "config",
452
+ "key": "mlDailyTopN"
453
+ },
454
+ "write": {
455
+ "endpoint": "/api/argent-state/config",
456
+ "field": "mlDailyTopN"
457
+ }
458
+ }
459
+ },
460
+ {
461
+ "key": "mlRestockLeadDays",
462
+ "label": "补货预警提前天数(0–90)",
463
+ "type": "text",
464
+ "bind": {
465
+ "read": {
466
+ "from": "config",
467
+ "key": "mlRestockLeadDays"
468
+ },
469
+ "write": {
470
+ "endpoint": "/api/argent-state/config",
471
+ "field": "mlRestockLeadDays"
472
+ }
473
+ }
474
+ },
475
+ {
476
+ "key": "mlRestockBufferDays",
477
+ "label": "补货缓冲天数(0–90)",
478
+ "type": "text",
479
+ "bind": {
480
+ "read": {
481
+ "from": "config",
482
+ "key": "mlRestockBufferDays"
483
+ },
484
+ "write": {
485
+ "endpoint": "/api/argent-state/config",
486
+ "field": "mlRestockBufferDays"
487
+ }
488
+ }
489
+ },
490
+ {
491
+ "key": "mlDailyAlertChatId",
492
+ "label": "告警落点群 id",
493
+ "type": "text",
494
+ "placeholder": "oc_…",
495
+ "hint": "流程失败/需人工裁定/待放行汇总的卡片发到哪个群;改错 ⇒ 你收不到需要确认的提醒。",
496
+ "bind": {
497
+ "read": {
498
+ "from": "config",
499
+ "key": "mlDailyAlertChatId"
500
+ },
501
+ "write": {
502
+ "endpoint": "/api/argent-state/config",
503
+ "field": "mlDailyAlertChatId"
504
+ }
505
+ }
506
+ },
507
+ {
508
+ "key": "mlDailyAlertProfile",
509
+ "label": "告警推送身份",
510
+ "type": "text",
511
+ "hint": "须在该群里;内部群实测 ml-daily 不在群内 ⇒ 用主 Bot。",
512
+ "bind": {
513
+ "read": {
514
+ "from": "config",
515
+ "key": "mlDailyAlertProfile"
516
+ },
517
+ "write": {
518
+ "endpoint": "/api/argent-state/config",
519
+ "field": "mlDailyAlertProfile"
520
+ }
521
+ }
522
+ },
523
+ {
524
+ "key": "mlDailyStoreCount",
525
+ "label": "已授权店铺(ML OAuth)",
526
+ "type": "text",
527
+ "hint": "只读:0 表示还没逐店授权 —— 运行 node ml-oauth-setup.mjs(或 init-ml.sh --daily-report)。",
528
+ "bind": {
529
+ "read": {
530
+ "from": "config",
531
+ "key": "mlDailyStoreCount"
532
+ }
533
+ }
534
+ }
535
+ ]
536
+ }
537
+ ]
538
+ }
@@ -0,0 +1,138 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * migrate-machine-state —— 美客多线落位的**机器状态迁移**(P2a,2026-09-29)
4
+ *
5
+ * 位置说明:这是**该业务线专属**的运维工具(提到该线的 env 与开关名)⇒ 放在业务线目录内,
6
+ * 引擎目录(scripts/)不得出现业务词(门禁 vertical-lint 的「引擎不掺业务」)。
7
+ *
8
+ * 代码侧(flows/prompts 落位 + 命名空间化)在仓库里;机器侧还有三样东西要跟着搬,
9
+ * 否则会出现"注册表改了、机器上的旧文件还在"的静默故障:
10
+ *
11
+ * ① **env 文件**:`~/.dsh/argent/fulfillment.env` → `verticals/mercadolibre/env/`。
12
+ * 仓库里还有 ~10 个脚本按旧平铺路径 source 它 ⇒ **旧路径留软链 shim**(不 churn 生产脚本),
13
+ * shim 清单进"退休待办"。
14
+ * ② **暂停开关**:`PAUSE_POLL` 等 → `verticals/mercadolibre/PAUSE.<flow>`。
15
+ * ⚠️ 顺序要紧:**先建新开关再改注册表**,否则"改注册表那一刻流程被静默解停"
16
+ * (本机流程当前全部暂停,绝不能因为迁移而跑起来)。flow-trigger 迁移期两条都查。
17
+ * ③ **会话复用文件**:`flow-dispatch-<flow>.json` → `verticals/mercadolibre/`(角色会话不中断)。
18
+ *
19
+ * 默认 **dry-run**(只打印计划);`--apply` 才落盘。幂等:可反复跑。
20
+ *
21
+ * 用法:
22
+ * node verticals/mercadolibre/migrate-machine-state.mjs # 看计划
23
+ * node verticals/mercadolibre/migrate-machine-state.mjs --apply # 执行
24
+ */
25
+ import { copyFileSync, existsSync, mkdirSync, readdirSync, renameSync, symlinkSync, unlinkSync, readlinkSync } from 'node:fs'
26
+ import { homedir } from 'node:os'
27
+ import { basename, join } from 'node:path'
28
+ import { loadRegistryDoc } from '../../scripts/lib/registry.mjs' // 引擎侧加载器(唯一真源)
29
+
30
+ const APPLY = process.argv.includes('--apply')
31
+ const argOf = (n, d) => { const i = process.argv.indexOf(n); return i > -1 ? process.argv[i + 1] ?? d : d }
32
+ const DATA = argOf('--data-dir', process.env.ARGENT_DATA_DIR || join(homedir(), '.dsh', 'argent'))
33
+ const VERT = 'mercadolibre'
34
+ const VDIR = join(DATA, 'verticals', VERT)
35
+ const envDir = join(VDIR, 'env')
36
+ const logDir = join(VDIR, 'logs')
37
+
38
+ // 属于美客多线的 env(按内容判定:飞书表/ML API/文鳐门户/紫鸟;`whyshu.env` 是平台级,不动)
39
+ const ENV_FILES = ['fulfillment.env', 'daily-report.env', 'wenyao.env', 'ziniao-webdriver.env']
40
+
41
+ const plan = []
42
+ const todos = []
43
+ const note = (kind, msg) => plan.push({ kind, msg })
44
+
45
+ console.log(`\n【美客多线机器状态迁移】数据目录:${DATA}|模式:${APPLY ? 'APPLY(落盘)' : 'dry-run'}\n`)
46
+
47
+ // ── 0. 目录 ─────────────────────────────────────────────────────
48
+ for (const d of [envDir, logDir]) {
49
+ if (!existsSync(d)) {
50
+ note('mkdir', d.replace(DATA, '~/.dsh/argent'))
51
+ if (APPLY) mkdirSync(d, { recursive: true })
52
+ }
53
+ }
54
+
55
+ // ── 1. env 文件:搬到规范位置 + 旧路径留软链 ────────────────────
56
+ for (const name of ENV_FILES) {
57
+ const legacy = join(DATA, name)
58
+ const target = join(envDir, name)
59
+ const rel = `verticals/${VERT}/env/${name}`
60
+ if (existsSync(target)) {
61
+ if (!existsSync(legacy)) note('ok', `${name}: 已在规范位置(${rel})`)
62
+ else {
63
+ let isLink = false
64
+ try { isLink = readlinkSync(legacy) === target } catch { isLink = false }
65
+ if (isLink) note('ok', `${name}: 规范位置 + 旧路径软链 shim(退休待办)`)
66
+ else { note('warn', `${name}: 两处都有实体文件 ⇒ 人工确认哪份为准(**不动**)`); todos.push(`${name}: 两处重复,人工去重`) }
67
+ }
68
+ continue
69
+ }
70
+ if (!existsSync(legacy)) { note('skip', `${name}: 不存在(该线可能不用它)`); continue }
71
+ note('move+symlink', `${name} → ${rel}(旧路径留软链,退休待办)`)
72
+ todos.push(`退休 shim:~/.dsh/argent/${name}(脚本改读规范路径后删)`)
73
+ if (APPLY) {
74
+ renameSync(legacy, target)
75
+ symlinkSync(target, legacy)
76
+ }
77
+ }
78
+
79
+ // ── 2. 暂停开关:先建新的(绝不能因为迁移把流程解停)────────────
80
+ let doc
81
+ try {
82
+ doc = loadRegistryDoc()
83
+ } catch (e) {
84
+ console.error(`✗ 读注册表失败:${e.message}`)
85
+ process.exit(2)
86
+ }
87
+ const mlFlows = Object.entries(doc.flows || {}).filter(([, f]) => (f.trigger || {}).pauseSwitch?.startsWith?.(`verticals/${VERT}/`))
88
+ console.log(` 注册表里属于该线的流程:${mlFlows.length} 条`)
89
+ for (const [fid, f] of mlFlows) {
90
+ const t = f.trigger || {}
91
+ const newRel = String(t.pauseSwitch || '')
92
+ const oldRel = String(t.pauseSwitchLegacy || '')
93
+ if (!newRel) continue
94
+ const newPath = join(DATA, newRel)
95
+ const oldPath = oldRel ? join(DATA, oldRel) : ''
96
+ const local = fid.split('.').pop()
97
+ if (existsSync(newPath)) { note('ok', `暂停开关已在规范位置:${newRel}`); continue }
98
+ if (oldPath && existsSync(oldPath)) {
99
+ note('pause', `新建 ${newRel}(镜像旧开关 ${oldRel})`)
100
+ todos.push(`退休旧开关:~/.dsh/argent/${oldRel}(确认新开关生效后删)`)
101
+ if (APPLY) {
102
+ mkdirSync(join(newPath, '..'), { recursive: true })
103
+ copyFileSync(oldPath, newPath)
104
+ }
105
+ } else {
106
+ note('pause', `⚠️ ${fid}: 新旧开关都不存在 ⇒ 该流程**当前是未暂停状态**(本机应为全暂停,请确认)`)
107
+ todos.push(`${fid}: 确认是否应处于暂停(本机约定全暂停)`)
108
+ }
109
+ }
110
+ // 流程看门狗(全局开关)保持原样
111
+ if (existsSync(join(DATA, 'PAUSE_FLOW_WATCH'))) note('ok', 'PAUSE_FLOW_WATCH(流程看门狗,全局)保持原样')
112
+
113
+ // ── 3. 会话复用文件:搬进业务线(角色会话不中断)────────────────
114
+ for (const [fid] of mlFlows) {
115
+ const local = fid.split('.').pop()
116
+ const legacy = join(DATA, `flow-dispatch-${local}.json`)
117
+ const target = join(VDIR, `flow-dispatch-${local}.json`)
118
+ if (existsSync(target)) { note('ok', `会话文件已就位:verticals/${VERT}/${basename(target)}`); continue }
119
+ if (!existsSync(legacy)) { note('skip', `flow-dispatch-${local}.json: 不存在(该线还没唤醒过)`); continue }
120
+ note('move', `flow-dispatch-${local}.json → verticals/${VERT}/(保留角色会话)`)
121
+ if (APPLY) renameSync(legacy, target)
122
+ }
123
+
124
+ // ── 4. 汇总 ─────────────────────────────────────────────────────
125
+ console.log('\n计划:')
126
+ for (const p of plan) console.log(` [${p.kind}] ${p.msg}`)
127
+ if (todos.length) {
128
+ console.log('\n⏳ 退休待办(迁移期允许存在,改完调用点后清理):')
129
+ for (const t of todos) console.log(` · ${t}`)
130
+ }
131
+ if (!APPLY) console.log('\n(dry-run:未落盘;确认无误后加 --apply)')
132
+ else {
133
+ console.log('\n✅ 已落盘。建议验证:')
134
+ console.log(' python3 scripts/flow_registry.py --check')
135
+ console.log(' node scripts/vertical-lint.mjs')
136
+ console.log(' python3 scripts/flow_config.py --list # 路径应全部指向 verticals/mercadolibre/')
137
+ console.log(' bash scripts/flow-trigger.sh --flow full --dry-run # 应报"已暂停"')
138
+ }