#!/usr/bin/env node /** * WeChat routing / intent evidence for v1.49 cutover. * Runs WX-01..WX-13 gate suites + wechat-intent-router; optional live webhook smoke. */ import { spawnSync } from 'node:child_process'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; const root = path.join(path.dirname(fileURLToPath(import.meta.url)), '..'); const skip = process.env.GOOSE_V149_WECHAT_EVIDENCE_SKIP === '1'; const live = process.env.GOOSE_V149_WECHAT_LIVE_SMOKE === '1'; function runScript(script, args = [], label = script) { const result = spawnSync(process.execPath, [path.join(root, 'scripts', script), ...args], { cwd: root, encoding: 'utf8', env: process.env, }); if (result.status !== 0) { throw new Error(`${label} failed: ${result.stderr?.trim() || result.stdout?.trim()}`); } } async function main() { if (skip) { console.log('GOOSE_V149_WECHAT_EVIDENCE_OK: skipped'); return; } const gateArgs = live ? ['--live-only', '--live-scenario', 'poem-page'] : []; runScript('run-wechat-gate-evidence.mjs', gateArgs, 'wechat-gate-evidence'); const fs = await import('node:fs'); const bundlePath = path.join(root, 'wechat-mp.bundle.mjs'); const sourcePath = path.join(root, 'wechat-mp.mjs'); const bundleExists = fs.existsSync(bundlePath); const sourceExists = fs.existsSync(sourcePath); if (!bundleExists && !sourceExists) { throw new Error('wechat-mp.mjs missing'); } console.log('GOOSE_V149_WECHAT_EVIDENCE_OK:'); console.log(' gate=WX-01..WX-13 deterministic suites'); console.log(` live_smoke=${live ? 'poem-page' : 'not-run (set GOOSE_V149_WECHAT_LIVE_SMOKE=1)'}`); if (bundleExists) { console.log(` bundle=${bundlePath} (${fs.statSync(bundlePath).size} bytes)`); } else { console.log(` source=${sourcePath} (bundle not built; prod uses wechat-mp.bundle.mjs)`); } } main().catch((error) => { console.error(`GOOSE_V149_WECHAT_EVIDENCE_FAIL: ${error.message}`); process.exit(1); });