#!/usr/bin/env node // validate-plan.mjs - PreToolUse hook on ExitPlanMode, wired in SKILL.md frontmatter. // // This is LAW 1's harness-level enforcement for plan-style curation (failure mode #3: a plan that // names skills but summarizes the dossier evidence away, so the user approves a forge they never // saw). Instructions ask; hooks enforce. The plan body must BE the engine's `plan render` artifact: // - the PASS-THROUGH FORGE PLAN marker (only the engine emits it) // - the "=== dossiers above: N ===" sentinel as the plan's LAST line // - at least N "### " card headers backing the sentinel's count // Anything else is denied with a reason the model can act on. A malformed stdin or a different // tool exits 0 silently - a broken hook must never block unrelated work. import { readFileSync } from 'node:fs' let input try { input = JSON.parse(readFileSync(0, 'utf8')) } catch { process.exit(0) } if (input.tool_name !== 'ExitPlanMode') process.exit(0) const plan = String(input.tool_input?.plan || '') const problems = [] if (!plan.includes('