diff --git a/scripts/approved_plan_continuity_gate.mjs b/scripts/approved_plan_continuity_gate.mjs new file mode 100755 index 0000000..4b0af65 --- /dev/null +++ b/scripts/approved_plan_continuity_gate.mjs @@ -0,0 +1,67 @@ +#!/usr/bin/env node +import fs from 'node:fs'; + +function parseArgs(argv) { + let inputPath = null; + let compact = false; + + for (let i = 0; i < argv.length; i += 1) { + const arg = argv[i]; + + if (arg === '--input') { + inputPath = argv[i + 1] ?? null; + i += 1; + continue; + } + + if (arg.startsWith('--input=')) { + inputPath = arg.slice('--input='.length); + continue; + } + + if (arg === '--compact') { + compact = true; + continue; + } + } + + return { inputPath, compact }; +} + +function readInput(inputPath) { + if (!inputPath) { + return { + ok: false, + error: 'missing_required_input', + }; + } + + try { + const raw = fs.readFileSync(inputPath, 'utf8'); + return { + ok: true, + bytes: Buffer.byteLength(raw, 'utf8'), + preview: raw.slice(0, 0), + }; + } catch (error) { + return { + ok: false, + error: error instanceof Error ? error.message : String(error), + }; + } +} + +const { inputPath, compact } = parseArgs(process.argv.slice(2)); +const input = readInput(inputPath); + +const response = { + ok: true, + status: 'placeholder', + gate: 'approved_plan_continuity', + compact, + inputPath, + input, + verdict: 'not_implemented', +}; + +process.stdout.write(`${JSON.stringify(response)}\n`);