#!/usr/bin/env node
import"./suppress-stderr.mjs";import"./ensure-deps.mjs";import{readStdin as Y,getSessionId as Z,getSessionDBPath as $}from"./session-helpers.mjs";import{createSessionLoaders as w}from"./session-loaders.mjs";import{dirname as y}from"node:path";import{fileURLToPath as H}from"node:url";var K=y(H(import.meta.url)),{loadSessionDB:M,loadExtract:T}=w(K);try{let G=await Y(),A=JSON.parse(G),F=A.prompt??A.message??"",q=(F||"").trim(),J=q.startsWith("<task-notification>")||q.startsWith("<system-reminder>")||q.startsWith("<context_guidance>")||q.startsWith("<tool-result>");if(q.length>0&&!J){let{SessionDB:N}=await M(),{extractUserEvents:Q}=await T(),V=$(),z=new N({dbPath:V}),C=Z(A);z.ensureSession(C,process.env.PUKU_PROJECT_DIR||process.cwd()),z.insertEvent(C,{type:"user_prompt",category:"prompt",data:F,priority:1},"UserPromptSubmit");let W=Q(q);for(let X of W)z.insertEvent(C,X,"UserPromptSubmit");z.close()}}catch{}
