@whyshu/argent-engine 0.8.0-rc.13 → 0.8.0-rc.15

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 (74) hide show
  1. package/MANIFEST.json +71 -36
  2. package/engine/VERSION +1 -1
  3. package/engine/configs/mcp-tools.snapshot.json +8 -1
  4. package/engine/core/contracts/argent.contracts.json +2 -2
  5. package/engine/core/mcp/erp-server.mjs +10 -6
  6. package/engine/core/mcp/gateway.mjs +3 -3
  7. package/engine/core/mcp/server.mjs +245 -0
  8. package/engine/scripts/appointment-worker.mjs +456 -35
  9. package/engine/scripts/appointment_grab.py +1329 -284
  10. package/engine/scripts/appointment_rules.py +118 -0
  11. package/engine/scripts/argent-timers.mjs +227 -0
  12. package/engine/scripts/capability-packs.lock.json +323 -300
  13. package/engine/scripts/check-version-consistency.mjs +14 -1
  14. package/engine/scripts/collect-intel.mjs +108 -0
  15. package/engine/scripts/daily-report-timer-plist.sh +18 -4
  16. package/engine/scripts/daily-report-timers.sh +1 -1
  17. package/engine/scripts/daily-report.mjs +22 -0
  18. package/engine/scripts/engine-manifest.mjs +90 -0
  19. package/engine/scripts/flow-requirements.json +122 -99
  20. package/engine/scripts/full-exec-worker.mjs +251 -0
  21. package/engine/scripts/gen-preset-rows.mjs +1 -1
  22. package/engine/scripts/invoice_lip_runner.py +1 -0
  23. package/engine/scripts/invoice_runner.py +3 -1
  24. package/engine/scripts/lib/bootcheck-wiring.mjs +7 -5
  25. package/engine/scripts/lib/intel-card.mjs +43 -0
  26. package/engine/scripts/lib/invoice_names.py +23 -0
  27. package/engine/scripts/lib/ml-ads-core.mjs +100 -18
  28. package/engine/scripts/lib/ml-ads-rules.mjs +275 -0
  29. package/engine/scripts/lib/ml-bridge-auth.mjs +50 -0
  30. package/engine/scripts/lib/ml-category-core.mjs +120 -0
  31. package/engine/scripts/lib/ml-insight-core.mjs +621 -0
  32. package/engine/scripts/lib/ml-insight-facts.mjs +424 -0
  33. package/engine/scripts/lib/ml-items.mjs +40 -0
  34. package/engine/scripts/lib/ml-listing-core.mjs +342 -0
  35. package/engine/scripts/lib/ml-market-core.mjs +774 -0
  36. package/engine/scripts/lib/webdriver_ipc.py +61 -1
  37. package/engine/scripts/line_pack.py +196 -0
  38. package/engine/scripts/ml-ads-advice.mjs +140 -0
  39. package/engine/scripts/ml-ads.mjs +40 -0
  40. package/engine/scripts/ml-category-baseline.mjs +174 -0
  41. package/engine/scripts/ml-insight-diagnose.mjs +247 -0
  42. package/engine/scripts/ml-insight-run.sh +183 -0
  43. package/engine/scripts/ml-insight-timers.sh +224 -0
  44. package/engine/scripts/ml-listing-audit.mjs +170 -0
  45. package/engine/scripts/ml-market-matrix.mjs +84 -0
  46. package/engine/scripts/ml-market-snapshot.mjs +261 -0
  47. package/engine/scripts/ml-messages.mjs +145 -0
  48. package/engine/scripts/npm-publish-argent.mjs +14 -0
  49. package/engine/scripts/ops-codefix-pr.mjs +87 -0
  50. package/engine/scripts/ops-codefix-queue.mjs +30 -0
  51. package/engine/scripts/ops-digest.mjs +98 -0
  52. package/engine/scripts/ops-verify.mjs +67 -0
  53. package/engine/scripts/orchestrator.py +410 -20
  54. package/engine/scripts/orchestrator_br.py +146 -4
  55. package/engine/scripts/plugin-bootcheck.mjs +50 -1
  56. package/engine/scripts/publish-engine.mjs +111 -0
  57. package/engine/scripts/restart-dsh-with-tunnel.sh +129 -0
  58. package/engine/scripts/skuflow_invoice_runner.py +24 -3
  59. package/engine/scripts/vertical-lint.mjs +12 -1
  60. package/engine/scripts/wenyao_fill_template.py +52 -15
  61. package/engine/scripts/wenyao_run.py +2 -1
  62. package/engine/skills/ml-appointment-safety/SKILL.md +42 -0
  63. package/engine/skills/ml-full-appointment/SKILL.md +23 -0
  64. package/engine/skills/ml-invoice/SKILL.md +2 -2
  65. package/engine/skills/ml-invoice/references/template-fill-contract.md +1 -1
  66. package/engine/skills/ml-label-recovery/SKILL.md +43 -0
  67. package/engine/skills/ml-listing-audit/SKILL.md +66 -0
  68. package/engine/skills/ml-store-daily-report/scripts/generate.js +35 -0
  69. package/engine/skills/ml-store-insight/SKILL.md +81 -0
  70. package/engine/version.mjs +1 -1
  71. package/engine/verticals/README.md +7 -0
  72. package/engine/verticals/_engine-words.baseline.txt +27 -59
  73. package/engine/verticals/mercadolibre/manifest.json +132 -6
  74. package/package.json +1 -1
@@ -459,6 +459,20 @@ async function main() {
459
459
  continue
460
460
  }
461
461
  console.log(` \x1b[32m✓\x1b[0m [PUB-J5] 回读一致(第 ${post.attempts} 次):${post.integrity}`)
462
+ // PUB-J5b:元数据可见 ≠ 包可下载。2026-11-16 实测 0.11.4 发布后 tarball 404 约 4 分钟,
463
+ // 客户端"更新插件"直接失败,而 PUB-J5 是绿的(它只读 dist.integrity)。这里必须实际取一次字节。
464
+ try {
465
+ const tarball = `https://registry.npmjs.org/${pack.name.replace('/', '%2f')}/-/${pack.name.split('/').pop()}-${pack.version}.tgz`
466
+ const r = await fetch(tarball, { method: 'GET' })
467
+ if (!r.ok) {
468
+ red('PUB-J5b', `${pack.name}@${pack.version}`, `tarball 尚不可下载(HTTP ${r.status}):${tarball} ⇒ 客户端会"更新失败",稍后重试或等分发完成`)
469
+ audit.push({ pkg: pack.name, version: pack.version, integrity: pack.integrity, action: 'published-tarball-missing' })
470
+ continue
471
+ }
472
+ console.log(' \x1b[32m✓\x1b[0m [PUB-J5b] tarball 可下载')
473
+ } catch (e) {
474
+ console.log(` \x1b[33m•\x1b[0m [PUB-J5b] tarball 探测失败(不阻断):${e?.message || e}`)
475
+ }
462
476
  plan.push({ pkg: pack.name, version: pack.version, integrity: pack.integrity, action: 'published' })
463
477
  audit.push({ pkg: pack.name, version: pack.version, integrity: pack.integrity, action: 'published' })
464
478
  }
@@ -0,0 +1,87 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * 运维代码修复 → 分支 + PR(问述内部;P3)。
4
+ * ⛔ 只开 PR,不合并、不发布、不碰客户机。
5
+ * 用法:
6
+ * node scripts/ops-codefix-pr.mjs --incident <incidentId> --title "fix: ..." [--repo <path>] [--body-file <path>] [--dry-run]
7
+ * 前置(由 agent 完成):在 dsh/ops-fix-<incident> 分支上改代码并跑通测试。
8
+ * 守卫:当前分支必须 dsh/ops-fix-*、不能是 main/master、必须有未提交改动(或已提交但未推送)。
9
+ */
10
+ import { execFileSync } from 'node:child_process'
11
+ import { existsSync, readFileSync } from 'node:fs'
12
+ import { homedir } from 'node:os'
13
+ import { join, resolve } from 'node:path'
14
+
15
+ const args = process.argv.slice(2)
16
+ const opt = (name, dft = '') => {
17
+ const i = args.indexOf(`--${name}`)
18
+ return i >= 0 ? String(args[i + 1] || '') : dft
19
+ }
20
+ const flag = (name) => args.includes(`--${name}`)
21
+ const incidentId = opt('incident')
22
+ const title = opt('title') || `fix(ops): incident ${incidentId}`
23
+ const repo = resolve(opt('repo', join(homedir(), 'Code', 'argent-dsh')))
24
+ const bodyFile = opt('body-file')
25
+ const dry = flag('dry-run')
26
+ if (!incidentId) { console.error('缺少 --incident'); process.exit(2) }
27
+
28
+ function git(cmd, argv) {
29
+ return execFileSync('git', [cmd, ...argv], { cwd: repo, encoding: 'utf8' }).trim()
30
+ }
31
+ function sh(cmd, argv) {
32
+ return execFileSync(cmd, argv, { cwd: repo, encoding: 'utf8' }).trim()
33
+ }
34
+ function opsToken() {
35
+ if (process.env.OPS_TOKEN) return process.env.OPS_TOKEN
36
+ try {
37
+ const p = join(homedir(), '.dsh', 'argent', 'ops-token.env')
38
+ const m = readFileSync(p, 'utf8').match(/^OPS_TOKEN=(.+)$/m)
39
+ return m ? m[1].trim() : ''
40
+ } catch { return '' }
41
+ }
42
+ async function incidentContext() {
43
+ const tk = opsToken()
44
+ if (!tk) return null
45
+ try {
46
+ const res = await fetch(`https://whyshu.com/api/ops/v1/internal/incidents?status=all&limit=500`, { headers: { 'x-ops-token': tk }, signal: AbortSignal.timeout(10000) })
47
+ const j = await res.json()
48
+ return (j?.data?.incidents || []).find((x) => String(x._id) === String(incidentId)) || null
49
+ } catch { return null }
50
+ }
51
+
52
+ const branch = git('rev-parse', ['--abbrev-ref', 'HEAD'])
53
+ const guardErrors = []
54
+ if (!/^dsh\/ops-fix-/.test(branch)) guardErrors.push(`分支必须以 dsh/ops-fix- 开头(当前 ${branch})`)
55
+ if (['main', 'master'].includes(branch)) guardErrors.push('禁止在 main/master 上直接提交')
56
+ const dirty = git('status', ['--porcelain'])
57
+ if (guardErrors.length) { console.error(`守卫未通过:\n- ${guardErrors.join('\n- ')}`); process.exit(3) }
58
+
59
+ const inc = await incidentContext()
60
+ const body = [
61
+ `## 运维 incident`,
62
+ `- incidentId: \`${incidentId}\``,
63
+ inc ? `- 规则: \`${inc.rule}\` / 级别: \`${inc.level}\` / 机器: \`${inc.machineId}\` / 店铺: \`${inc.store || '-'}\`` : '- (未取到 incident 上下文)',
64
+ inc && inc.detail ? `- detail: \n\`\`\`json\n${JSON.stringify(inc.detail, null, 2).slice(0, 3000)}\n\`\`\`` : '',
65
+ '',
66
+ bodyFile && existsSync(bodyFile) ? readFileSync(bodyFile, 'utf8') : '## 修复说明\n(agent 在此补充根因/改法/测试)',
67
+ '',
68
+ '> 本 PR 由运维自动化流程生成,**必须人工 review 后再合并**;未经审查不得发布。',
69
+ ].filter(Boolean).join('\n')
70
+
71
+ if (dry) {
72
+ console.log(JSON.stringify({ ok: true, dry: true, repo, branch, title, dirty: Boolean(dirty), incident: inc ? { id: incidentId, rule: inc.rule } : null, bodyPreview: body.slice(0, 400) }, null, 2))
73
+ process.exit(0)
74
+ }
75
+
76
+ // 提交(若有未提交改动)
77
+ if (dirty) {
78
+ git('add', ['-A'])
79
+ git('commit', ['-m', `${title}\n\nIncident: ${incidentId}`])
80
+ } else {
81
+ // 允许已提交未推送:检查 ahead
82
+ const ahead = git('rev-list', ['--count', `origin/main..${branch}`])
83
+ if (Number(ahead) <= 0) { console.error('守卫未通过:分支没有改动(工作树干净且无领先提交)'); process.exit(3) }
84
+ }
85
+ git('push', ['-u', 'origin', branch])
86
+ const prUrl = sh('gh', ['pr', 'create', '--base', 'main', '--head', branch, '--title', title, '--body', body])
87
+ console.log(JSON.stringify({ ok: true, pr: prUrl, branch, incidentId }, null, 2))
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * 代码修复候选队列(问述内部):把需要代码修复的 incident 汇总为 JSON,供开发机 agent 处理。
4
+ * 需要代码修复的规则(窗口/任务数/卡死等基础设施问题由 L1/L2 自愈,不在此列):
5
+ * duplicate_shipment_task / version_drift / 以及 OpsIncident.detail 中出现 needsCodeFix=true 的;
6
+ * 输出:{ at, items:[{incidentId, tenantId, machineId, store, rule, level, count, lastSeenAt, detail}] }
7
+ */
8
+ import { readFileSync } from 'node:fs'
9
+ import { homedir } from 'node:os'
10
+ import { join } from 'node:path'
11
+
12
+ const BASE = process.env.OPS_BASE || 'https://whyshu.com'
13
+ const CODE_RULES = new Set(['duplicate_shipment_task', 'version_drift'])
14
+ function opsToken() {
15
+ if (process.env.OPS_TOKEN) return process.env.OPS_TOKEN
16
+ try {
17
+ const raw = readFileSync(join(homedir(), '.dsh', 'argent', 'ops-token.env'), 'utf8')
18
+ const m = raw.match(/^OPS_TOKEN=(.+)$/m)
19
+ return m ? m[1].trim() : ''
20
+ } catch { return '' }
21
+ }
22
+ async function get(path) {
23
+ const res = await fetch(`${BASE}${path}`, { headers: { 'x-ops-token': opsToken() }, signal: AbortSignal.timeout(15000) })
24
+ const json = await res.json().catch(() => ({}))
25
+ if (!res.ok) throw new Error(json?.error?.message || `HTTP ${res.status}`)
26
+ return json.data ?? json
27
+ }
28
+ const data = await get('/api/ops/v1/internal/incidents?status=open&limit=200')
29
+ const items = (data.incidents || []).filter((x) => CODE_RULES.has(x.rule) || x.detail?.needsCodeFix === true)
30
+ console.log(JSON.stringify({ at: new Date().toISOString(), count: items.length, items }, null, 2))
@@ -0,0 +1,98 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * 运维日报(问述内部):拉取运维层 overview/incidents,输出 Markdown。
4
+ * 用法:node scripts/ops-digest.mjs [--json]
5
+ * 凭据:OPS_TOKEN 环境变量 或 ~/.dsh/argent/ops-token.env(600,仅本机)
6
+ * 设计:docs/Argent-运维层-客户机健康与自愈-设计与操作方案.md §8
7
+ */
8
+ import { readFileSync, mkdirSync, writeFileSync } from 'node:fs'
9
+ import { homedir } from 'node:os'
10
+ import { join } from 'node:path'
11
+
12
+ const BASE = process.env.OPS_BASE || 'https://whyshu.com'
13
+ const RULE_LABEL = {
14
+ task_tab_mismatch: '任务数 > 预约标签页', store_over_concurrency: '同店超并发',
15
+ task_stalled: '任务卡死', window_missing: '窗口缺失/不可用',
16
+ noise_tab_present: '噪音标签', duplicate_shipment_task: '同货件重复任务',
17
+ machine_offline: '客户机离线', version_drift: '版本落后',
18
+ platform_no_slot: '平台无号(黑五常态)',
19
+ }
20
+
21
+ function opsToken() {
22
+ if (process.env.OPS_TOKEN) return process.env.OPS_TOKEN
23
+ try {
24
+ const raw = readFileSync(join(homedir(), '.dsh', 'argent', 'ops-token.env'), 'utf8')
25
+ const m = raw.match(/^OPS_TOKEN=(.+)$/m)
26
+ return m ? m[1].trim() : ''
27
+ } catch { return '' }
28
+ }
29
+
30
+ async function get(path) {
31
+ const token = opsToken()
32
+ if (!token) throw new Error('缺少 OPS_TOKEN(~/.dsh/argent/ops-token.env)')
33
+ const res = await fetch(`${BASE}${path}`, { headers: { 'x-ops-token': token }, signal: AbortSignal.timeout(15000) })
34
+ const json = await res.json().catch(() => ({}))
35
+ if (!res.ok) throw new Error(json?.error?.message || `HTTP ${res.status}`)
36
+ return json.data ?? json
37
+ }
38
+
39
+ const jsonMode = process.argv.includes('--json')
40
+ const [overview, incs, logsResp] = await Promise.all([
41
+ get('/api/ops/v1/internal/overview'),
42
+ get('/api/ops/v1/internal/incidents?status=open&limit=200'),
43
+ get('/api/ops/v1/internal/remediation-logs?limit=50').catch(() => ({ logs: [] })),
44
+ ])
45
+ const machines = overview.machines || []
46
+ const incidents = incs.incidents || []
47
+ const logs = (logsResp && logsResp.logs) || []
48
+ const dayAgo = Date.now() - 24 * 3600 * 1000
49
+ const recentLogs = logs.filter((x) => x.createdAt && new Date(x.createdAt).getTime() >= dayAgo)
50
+ const logCount = {}
51
+ for (const x of recentLogs) logCount[x.action] = (logCount[x.action] || 0) + 1
52
+ const now = new Date()
53
+ const online = machines.filter((m) => m.online).length
54
+
55
+ if (jsonMode) {
56
+ console.log(JSON.stringify({ at: now.toISOString(), overview, incidents }, null, 2))
57
+ process.exit(0)
58
+ }
59
+
60
+ const lines = []
61
+ lines.push(`# 运维日报 ${now.toLocaleString('zh-CN', { hour12: false })}`)
62
+ lines.push('')
63
+ lines.push(`## 概览`)
64
+ lines.push(`- 客户机:${online}/${machines.length} 在线`)
65
+ lines.push(`- 未闭环 incident:${incidents.length}(critical ${incidents.filter((x) => x.level === 'critical').length} / warning ${incidents.filter((x) => x.level === 'warning').length})`)
66
+ for (const m of machines) {
67
+ const stores = m.storeDetail || []
68
+ const mismatch = stores.filter((s) => (s.claimed || 0) > (s.appointmentTabs || 0)).length
69
+ lines.push(`- ${m.tenantId} / ${m.machineId}:${m.online ? '在线' : `离线 ${m.offlineFor ?? '?'} 分钟`},插件 ${m.pluginVersion || '-'} / 引擎 ${m.engineVersion || '-'},店铺 ${stores.length}${mismatch ? `,**${mismatch} 个店铺任务数>标签页数**` : ''}`)
70
+ }
71
+ lines.push('')
72
+ lines.push(`## 最近 24h 自愈审计`)
73
+ lines.push(recentLogs.length ? Object.entries(logCount).map(([k, n]) => `- ${k} ×${n}`).join('\n') : '- 无')
74
+ lines.push('')
75
+ lines.push(`## 未闭环 incident`)
76
+ if (!incidents.length) lines.push('- 无')
77
+ else {
78
+ for (const x of incidents.slice(0, 30)) {
79
+ lines.push(`- [${x.level}] ${x.tenantId} / ${x.machineId} / ${x.store || '-'}:${RULE_LABEL[x.rule] || x.rule} ×${x.count ?? 1}(${new Date(x.lastSeenAt).toLocaleString('zh-CN', { hour12: false })})`)
80
+ }
81
+ if (incidents.length > 30) lines.push(`- … 其余 ${incidents.length - 30} 条`)
82
+ }
83
+ const md = lines.join('\n') + '\n'
84
+ // 写入运维层(看板展示最新日报;--no-push 可跳过)
85
+ if (!process.argv.includes('--no-push')) {
86
+ try {
87
+ const res = await fetch(`${BASE}/api/ops/v1/internal/digest`, {
88
+ method: 'POST',
89
+ headers: { 'content-type': 'application/json', 'x-ops-token': opsToken() },
90
+ body: JSON.stringify({ markdown: md, summary: { machines: machines.length, online, incidents: incidents.length, at: now.toISOString() } }),
91
+ signal: AbortSignal.timeout(10000),
92
+ })
93
+ if (!res.ok) console.error('日报写入运维层失败:', res.status)
94
+ } catch (e) { console.error('日报写入运维层失败:', e.message) }
95
+ }
96
+ const dir = join(homedir(), '.dsh', 'argent', 'ops-digests')
97
+ try { mkdirSync(dir, { recursive: true }); writeFileSync(join(dir, `${now.toISOString().slice(0, 10)}.md`), md) } catch { /* noop */ }
98
+ console.log(md)
@@ -0,0 +1,67 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * 运维层验收脚本(问述内部):心跳新鲜度 / 版本 / 任务数 vs 标签页 / incident。
4
+ * 用法:node scripts/ops-verify.mjs [--min-version 0.12.5] [--max-heartbeat-age 180]
5
+ * 退出码:0 全部通过;1 有失败项(输出逐项结果)。
6
+ */
7
+ import { readFileSync } from 'node:fs'
8
+ import { homedir } from 'node:os'
9
+ import { join } from 'node:path'
10
+
11
+ const BASE = process.env.OPS_BASE || 'https://whyshu.com'
12
+ const args = process.argv.slice(2)
13
+ const opt = (n, d) => { const i = args.indexOf(`--${n}`); return i >= 0 ? args[i + 1] : d }
14
+ const MIN_VERSION = opt('min-version', '')
15
+ const ONLY_MACHINE = opt('machine', '')
16
+ const MAX_AGE = Number(opt('max-heartbeat-age', '180'))
17
+
18
+ function token() {
19
+ if (process.env.OPS_TOKEN) return process.env.OPS_TOKEN
20
+ try {
21
+ const raw = readFileSync(join(homedir(), '.dsh', 'argent', 'ops-token.env'), 'utf8')
22
+ const m = raw.match(/^OPS_TOKEN=(.+)$/m)
23
+ return m ? m[1].trim() : ''
24
+ } catch { return '' }
25
+ }
26
+ async function get(path) {
27
+ const res = await fetch(`${BASE}${path}`, { headers: { 'x-ops-token': token() }, signal: AbortSignal.timeout(15000) })
28
+ const j = await res.json().catch(() => ({}))
29
+ if (!res.ok) throw new Error(j?.error?.message || `HTTP ${res.status}`)
30
+ return j.data ?? j
31
+ }
32
+ const cmp = (a, b) => {
33
+ const pa = String(a || '').split('.').map(Number), pb = String(b || '').split('.').map(Number)
34
+ for (let i = 0; i < Math.max(pa.length, pb.length); i += 1) {
35
+ const x = pa[i] || 0, y = pb[i] || 0
36
+ if (x !== y) return x > y ? 1 : -1
37
+ }
38
+ return 0
39
+ }
40
+
41
+ const checks = []
42
+ const ok = (name, cond, detail = '') => checks.push({ name, ok: Boolean(cond), detail })
43
+ try {
44
+ const [overview, incs] = await Promise.all([get('/api/ops/v1/internal/overview'), get('/api/ops/v1/internal/incidents?status=open&limit=200')])
45
+ const allMachines = overview.machines || []
46
+ const machines = ONLY_MACHINE ? allMachines.filter((m) => String(m.machineId) === ONLY_MACHINE) : allMachines
47
+ ok('存在客户机心跳', machines.length > 0, `machines=${machines.length}`)
48
+ for (const m of machines) {
49
+ const ageMin = m.at ? Math.round((Date.now() - new Date(m.at).getTime()) / 60000) : null
50
+ ok(`心跳新鲜:${m.machineId}`, ageMin != null && ageMin <= MAX_AGE, `age=${ageMin}min`)
51
+ if (MIN_VERSION) ok(`插件版本:${m.machineId} >= ${MIN_VERSION}`, cmp(m.pluginVersion, MIN_VERSION) >= 0, `plugin=${m.pluginVersion}`)
52
+ for (const s of m.storeDetail || []) {
53
+ if (Number(s.claimed) > Number(s.appointmentTabs)) ok(`任务数<=标签页:${s.store}`, false, `claimed=${s.claimed} tabs=${s.appointmentTabs}`)
54
+ else ok(`任务数<=标签页:${s.store}`, true, `claimed=${s.claimed} tabs=${s.appointmentTabs}`)
55
+ ok(`窗口可连:${s.store}`, Boolean(s.cdpPort) || Number(s.claimed) === 0, `port=${s.cdpPort || 0}`)
56
+ }
57
+ }
58
+ const critical = (incs.incidents || []).filter((x) => x.level === 'critical')
59
+ ok('无 critical incident', critical.length === 0, critical.map((x) => `${x.rule}@${x.machineId}/${x.store || '-'}`).join('; '))
60
+ } catch (e) {
61
+ ok('拉取运维数据', false, e.message)
62
+ }
63
+
64
+ const failed = checks.filter((c) => !c.ok)
65
+ for (const c of checks) console.log(`${c.ok ? '✅' : '❌'} ${c.name}${c.detail ? `(${c.detail})` : ''}`)
66
+ console.log(`\n${failed.length ? `❌ ${failed.length} 项未通过` : '✅ 全部通过'}`)
67
+ process.exit(failed.length ? 1 : 0)