#!/usr/bin/env bun
// @bun
var Y=Object.defineProperty;var Z=(F)=>F;function $(F,H){this[F]=Z.bind(null,H)}var L=(F,H)=>{for(var I in H)Y(F,I,{get:H[I],enumerable:!0,configurable:!0,set:$.bind(H,I)})};var N=(F,H)=>()=>(F&&(H=F(F=0)),H);import{closeSync as V,fstatSync as _,openSync as w,readSync as z}from"fs";var q=[/\bshould i (go ahead|proceed|start|begin|continue|implement|build|kick)\b/i,/\b(want|do you want|would you like) me to (go ahead|proceed|start|begin|continue|implement|build|kick|do)\b/i,/\bshall i (proceed|start|begin|continue|implement|build|go)\b/i,/\bdoes (this|that|the plan|the approach|it) (look|sound) (right|good|ok|okay|fine)\b/i,/\b(looks?|sounds?) (right|good|fine) to you\b/i,/\blet me know (if|what|how|whether|once|when)\b/i,/\bbefore i (go|start|begin|implement|proceed|dive|write|send|build|continue|move|ship)\b/i,/\b(ready|good) to (proceed|implement|start|build|go)\b/i,/\b(things?|couple|two|a few)\b[^.?!]*\bto confirm\b/i,/\bto confirm[:?]/i,/\bif (this|that|it) looks (right|good|ok|okay)\b/i,/\bwaiting (for|on) your (approval|go-?ahead|sign-?off|ok|review|decision)\b/i,/\b(approve|green-?light|sign off on) (this|the plan|the approach|it)\b/i];function C(F){if(!F||!F.trim())return!1;return q.some((H)=>H.test(F))}function D(F){if(typeof F==="string")return F;if(Array.isArray(F))return F.filter((H)=>(H?.type==="text"||H?.type==="output_text")&&typeof H.text==="string").map((H)=>H.text).join(`
`).trim();return""}function G(F){let H=F.split(`
`);for(let I=H.length-1;I>=0;I--){let M=H[I].trim();if(!M)continue;let J;try{J=JSON.parse(M)}catch{continue}let K=J.message??J.payload??J;if((K.role??J.type)!=="assistant")continue;return D(K.content)}return""}function U(F){let H=F.split(/\n\s*\n/).map((I)=>I.trim()).filter(Boolean);return H.length?H[H.length-1]:""}function W(F){return C(U(G(F)))}var B="It looks like you ended your turn asking the user to approve a plan or decide how to "+"proceed \u2014 in prose. In this project, plans are reviewed on Beacon's /plan canvas, not in the "+"terminal. Present it through Beacon instead: call the `beacon_present_plan` MCP tool with your plan as markdown (embed a ```beacon block for any tables/endpoints/features). It opens /plan and BLOCKS until the user approves, discards, or leaves feedback, then returns their verdict. If this was NOT a plan (just a quick question), ignore this and continue.";function E(F,H=65536){let I=w(F,"r");try{let M=_(I).size,J=Math.max(0,M-H),K=M-J;if(K<=0)return"";let Q=Buffer.alloc(K);return z(I,Q,0,K,J),Q.toString("utf8")}finally{V(I)}}var X="";for await(let F of process.stdin)X+=F;try{let F=JSON.parse(X||"{}");if(F.stop_hook_active)process.exit(0);let H=F.transcript_path;if(typeof H!=="string"||!H)process.exit(0);let I="";try{I=E(H)}catch{process.exit(0)}if(W(I))process.stdout.write(JSON.stringify({decision:"block",reason:B}))}catch{}process.exit(0);
