#!/usr/bin/env node import { pathToFileURL } from 'node:url'; import { evaluateMemoryV2PhaseAReadiness } from '../memory-v2-phase-a-ready.mjs'; import { loadMemindEnvFiles } from './memind-runtime-profile.mjs'; function usage() { return [ 'Usage: node scripts/check-memory-v2-phase-a-ready.mjs [--json]', '', 'Validates local/admin env for Memory V2 Phase A canary rollout.', ].join('\n'); } function parseArgs(argv) { const args = { json: false }; for (let i = 2; i < argv.length; i += 1) { const arg = argv[i]; if (arg === '--json') args.json = true; else if (arg === '--help' || arg === '-h') { console.log(usage()); process.exit(0); } else { console.error(`Unknown argument: ${arg}`); console.error(usage()); process.exit(2); } } return args; } function printReport(report, { json = false } = {}) { if (json) { console.log(JSON.stringify(report, null, 2)); return; } console.log(`memory v2 phase-a readiness: ${report.ok ? 'ready' : 'blocked'}`); console.log(JSON.stringify(report.summary, null, 2)); for (const item of report.issues) { console.log(`- issue ${item.code}: ${item.message}`); } for (const item of report.warnings) { console.log(`- warning ${item.code}: ${item.message}`); } } async function main() { const args = parseArgs(process.argv); loadMemindEnvFiles(process.cwd()); const report = evaluateMemoryV2PhaseAReadiness(process.env); printReport(report, { json: args.json }); process.exit(report.ok ? 0 : 1); } if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) { void main(); }