@systemfsoftware/omp-claude-compat 1.6.0 → 1.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +0,0 @@
1
- import{$ as e,A as t,An as n,Ar as r,B as i,Br as a,Bt as o,Cr as s,D as c,Dr as l,Er as u,Et as d,F as f,Fn as p,Fr as ee,Ft as te,G as m,Gr as ne,H as re,Ht as ie,In as ae,Ir as h,It as g,J as oe,K as _,L as se,Lr as ce,Lt as le,M as ue,Mt as de,Nr as fe,Nt as v,O as pe,Or as me,Pn as he,Pr as y,Pt as ge,Q as b,Rr as x,Rt as _e,Sr as ve,St as ye,T as be,Tn as xe,Tt as Se,U as Ce,Ur as S,V as we,Vr as Te,Vt as Ee,W as C,Wr as w,X as T,Y as E,Yt as De,Z as Oe,Zt as D,a as ke,at as Ae,br as je,c as Me,cr as Ne,ct as Pe,et as O,fr as Fe,gr as Ie,hr as Le,i as Re,it as k,j as ze,jr as A,k as Be,kn as Ve,kr as j,l as He,lr as Ue,m as We,mr as Ge,nn as Ke,nt as qe,o as Je,on as Ye,ot as Xe,pr as Ze,q as M,qt as Qe,r as $e,rn as et,rt as tt,s as nt,st as rt,tn as it,tt as at,u as N,ur as ot,vr as st,wr as P,xt as ct,yr as lt,z as F,zt as ut}from"./dist-uv-To51R.js";import{homedir as dt}from"node:os";const ft={[Symbol.for(`@effect/matcher/Matcher`)]:{_input:w,_filters:w,_remaining:w,_result:w,_provided:w,_return:w},_tag:`ValueMatcher`,add(e){return this.value._tag===`Right`?this:e._tag===`When`&&e.guard(this.provided)===!0||e._tag===`Not`&&e.guard(this.provided)===!1?pt(this.provided,x(e.evaluate(this.provided))):this},pipe(){return a(this,arguments)}};function pt(e,t){let n=Object.create(ft);return n.provided=e,n.value=t,n}const mt=(e,t)=>({_tag:`When`,guard:e,evaluate:t}),ht=e=>{if(typeof e==`function`)return e;if(Array.isArray(e)){let t=e.map(ht),n=t.length;return e=>{if(!Array.isArray(e))return!1;for(let r=0;r<n;r++)if(t[r](e[r])===!1)return!1;return!0}}else if(typeof e==`object`&&e){let t=Object.entries(e).map(([e,t])=>[e,ht(t)]),n=t.length;return e=>{if(typeof e!=`object`||!e)return!1;for(let r=0;r<n;r++){let[n,i]=t[r];if(!(n in e)||i(e[n])===!1)return!1}return!0}}return t=>t===e},gt=e=>pt(e,h(e)),_t=(e,t)=>n=>n.add(mt(ht(e),t)),vt=(e=>(...t)=>{let n=t[t.length-1],r=t.slice(0,-1),i=r.length===1?t=>t!=null&&t[e]===r[0]:t=>t!=null&&r.includes(t[e]);return e=>e.add(mt(i,n))})(`_tag`),yt=e=>t=>{let n=bt(t);return fe(n)?n._tag===`Right`?n.right:e(n.left):t=>{let r=n(t);return r._tag===`Right`?r.right:e(r.left)}},bt=e=>{if(e._tag===`ValueMatcher`)return e.value;let t=e.cases.length;if(t===1){let t=e.cases[0];return e=>t._tag===`When`&&t.guard(e)===!0||t._tag===`Not`&&t.guard(e)===!1?x(t.evaluate(e)):h(e)}return n=>{for(let r=0;r<t;r++){let t=e.cases[r];if(t._tag===`When`&&t.guard(n)===!0||t._tag===`Not`&&t.guard(n)===!1)return x(t.evaluate(n))}return h(n)}},xt=`effect/Match/exhaustive: absurd`,St=e=>{let t=bt(e);if(fe(t)){if(t._tag===`Right`)return t.right;throw Error(xt)}return e=>{let n=t(e);if(n._tag===`Right`)return n.right;throw Error(xt)}},I=gt,L=_t,R=vt,Ct=yt,z=St,wt=Symbol.for(`@effect/platform/CommandExecutor`),Tt=Symbol.for(`@effect/platform/Process`),Et=je(),Dt=je(),Ot=st(`@effect/platform/CommandExecutor`),kt=e=>{let n=t=>f(o(e(t),e=>e.stdout)),r=(e,t)=>{let r=new TextDecoder(t);return ue(pe(n(e),Ze(e=>r.decode(e))))};return{[wt]:wt,start:e,exitCode:t=>De(de(e(t),e=>e.exitCode)),stream:n,string:(n,r=`utf-8`)=>{let i=new TextDecoder(r);return ne(e(n),de(e=>t(e.stdout,At)),o(e=>i.decode(e)),De)},lines:(e,t=`utf-8`)=>ne(r(e,t),ze,o(Ie)),streamLines:r}},At=se(new Uint8Array,(e,t)=>Le(t,e,(e,t)=>{let n=new Uint8Array(e.length+t.length);return n.set(e),n.set(t,e.length),n})),jt=Symbol.for(`@effect/platform/Command`),Mt=S(2,(e,t)=>{switch(e._tag){case`StandardCommand`:return B({...e,env:ot(e.env,Ue(Object.entries(t).filter(([e])=>e!==void 0)))});case`PipedCommand`:return Bt(Mt(e.left,t),Mt(e.right,t))}}),Nt=S(2,(e,t)=>Ht(e,c(Ge(new TextEncoder().encode(t))))),Pt=e=>Array.from(Ft(e)),Ft=e=>{switch(e._tag){case`StandardCommand`:return Ge(e);case`PipedCommand`:return Fe(Ft(e.left),Ft(e.right))}},It={[jt]:jt,pipe(){return a(this,arguments)},...Te},Lt={...It,_tag:`StandardCommand`,toJSON(){return{_id:`@effect/platform/Command`,_tag:this._tag,command:this.command,args:this.args,env:Object.fromEntries(this.env),cwd:this.cwd.toJSON(),shell:this.shell,gid:this.gid.toJSON(),uid:this.uid.toJSON()}}},B=e=>Object.assign(Object.create(Lt),e),Rt={...It,_tag:`PipedCommand`,toJSON(){return{_id:`@effect/platform/Command`,_tag:this._tag,left:this.left.toJSON(),right:this.right.toJSON()}}},V=e=>Object.assign(Object.create(Rt),e),zt=(e,...t)=>B({command:e,args:t,env:Ne(),cwd:r(),shell:!1,stdin:`pipe`,stdout:`pipe`,stderr:`pipe`,gid:r(),uid:r()}),Bt=S(2,(e,t)=>V({left:e,right:t})),Vt=S(2,(e,t)=>{switch(e._tag){case`StandardCommand`:return B({...e,stderr:t});case`PipedCommand`:return V({...e,right:Vt(e.right,t)})}}),Ht=S(2,(e,t)=>{switch(e._tag){case`StandardCommand`:return B({...e,stdin:t});case`PipedCommand`:return V({...e,left:Ht(e.left,t)})}}),Ut=S(2,(e,t)=>{switch(e._tag){case`StandardCommand`:return B({...e,stdout:t});case`PipedCommand`:return V({...e,right:Ut(e.right,t)})}}),Wt=S(2,(e,t)=>{switch(e._tag){case`StandardCommand`:return B({...e,cwd:A(t)});case`PipedCommand`:return Bt(Wt(e.left,t),Wt(e.right,t))}}),Gt=Mt,Kt=Nt,qt=Pt,Jt=zt,Yt=Vt,Xt=Ht,Zt=Ut,Qt=Wt,$t=Ot,en=Tt,tn=Et,nn=Dt,rn=kt,an=p([]);lt(`@systemfsoftware/omp-claude-compat/AsyncHookContextState`)();function on(e){let t=e.trim();t.length!==0&&Qe(ae(an,e=>e.length>=64?[...e.slice(1),t]:[...e,t]))}function sn(){return Qe(he(an,[]))}const cn=(e,t,n)=>te(e,t).pipe(de(e=>xe(e)),et(n.deadline),o(e=>P(e,n.onDeadline))),ln=_({code:Ce,stdout:m,stderr:m});var un=class extends M()(`Block`,{reason:m}){},H=class extends M()(`Allow`,{updatedInput:e(C({key:m,value:T}))}){},dn=class extends M()(`Warning`,{message:m}){};E(un,H,dn);var fn=class extends M()(`Blocked`,{reason:m}){},pn=class extends M()(`Continue`,{warning:e(m),updatedInput:e(C({key:m,value:T}))}){};E(fn,pn);const mn=_({decision:e(m),reason:e(m),hookSpecificOutput:e(_({permissionDecision:e(m),permissionDecisionReason:e(m),updatedInput:e(C({key:m,value:T})),additionalContext:e(m)}))}),hn=b(qe(m,mn,{strict:!0,decode:e=>Ee(Oe(at(mn))(e),e=>e.issue),encode:(e,t,n)=>rt(new tt(n,e,`Decode-only: hook stdout is never encoded`))})),gn=`PreToolUse.PostToolUse.PostToolUseFailure.PostToolBatch.UserPromptSubmit.UserPromptExpansion.SessionStart.SessionEnd.Stop.StopFailure.PreCompact.PostCompact.PermissionRequest.PermissionDenied.SubagentStart.SubagentStop.MessageDisplay.Notification.Setup.TaskCreated.TaskCompleted.TeammateIdle.InstructionsLoaded.ConfigChange.CwdChanged.FileChanged.WorktreeCreate.WorktreeRemove.Elicitation.ElicitationResult`.split(`.`),_n=[`PreToolUse`,`PostToolUse`,`PostToolUseFailure`,`UserPromptSubmit`,`SessionStart`,`SessionEnd`,`Stop`,`PreCompact`,`PostCompact`],vn={PermissionRequest:"OMP emits `tool_approval_requested`, but the event exists to allow or deny and OMP ignores the handler return. Express approval policy through OMP native approval configuration instead.",PermissionDenied:"OMP emits `tool_approval_resolved` with `approved: false`, which reports a manual decline by the user — the case Claude Code explicitly excludes, since this event fires only for auto-classifier denials.",SubagentStart:"OMP emits `agent_start`, but its payload carries no agent identity and it fires for the main agent turn loop too, so a bridge would fabricate subagent events that never happened.",SubagentStop:'OMP emits `agent_end` with the same identity gap, so a "subagent stopped" hook would fire on every main-agent turn end.',MessageDisplay:"The event exists to rewrite what Claude Code renders via `displayContent`; OMP `message_update` / `message_end` expose no equivalent control over rendering.",PostToolBatch:`OMP dispatches tool calls individually and exposes no end-of-batch signal.`,UserPromptExpansion:"OMP has no signal for a typed command expanding before it reaches the model; its `input` event fires after expansion would already have happened.",StopFailure:`OMP exposes no signal distinguishing a failed stop from an ordinary one.`,Notification:`Notifications are OMP-side UI; no extension event is emitted when one is raised.`,Setup:`OMP has no first-run setup lifecycle event.`,TaskCreated:`The OMP todo surface emits no per-task creation event to extensions.`,TaskCompleted:`The OMP todo surface emits no per-task completion event to extensions.`,TeammateIdle:`OMP has no teammate concept and emits no idle signal for one.`,InstructionsLoaded:`OMP loads instruction files without emitting an extension event.`,ConfigChange:`OMP does not notify extensions when its configuration changes.`,CwdChanged:`OMP exposes no working-directory change event.`,FileChanged:`OMP has no file-watch surface exposed to extensions.`,WorktreeCreate:`OMP emits no worktree lifecycle events.`,WorktreeRemove:`OMP emits no worktree lifecycle events.`,Elicitation:`MCP elicitation is not surfaced to OMP extensions.`,ElicitationResult:`MCP elicitation is not surfaced to OMP extensions.`},yn=[`PreToolUse`,`PostToolUse`,`PostToolUseFailure`,`PermissionRequest`,`PermissionDenied`],bn={PreCompact:"OMP `session_before_compact` does not say whether the compaction was manual or automatic, so a `trigger` matcher cannot be evaluated.",PostCompact:"OMP `session_compact` reports only whether an extension requested the compaction, not whether it was manual or automatic, so a `trigger` matcher cannot be evaluated.",SessionEnd:"OMP `session_shutdown` fires on process exit and carries no reason, so a `reason` matcher cannot be evaluated."},xn={SessionStart:{startup:{_tag:`Reachable`},compact:{_tag:`Reachable`},fork:{_tag:`Reachable`},resume:{_tag:`Partial`,reason:'covers a mid-session resume, which arrives as `session_switch` with `reason: "resume"`. A cold start under `--resume` never emits that signal — it reaches extensions through a bare `session_start` — so it presents as `startup` and a resume-scoped hook does not run there.'},clear:{_tag:`Unreachable`,reason:`OMP emits no signal when a session is cleared.`}}},Sn=E(_({type:we(`command`),command:m,args:e(F(m)),async:e(i),asyncRewake:e(i),shell:e(we(`bash`,`powershell`)),timeout:e(Ce),if:e(m),statusMessage:e(m),once:e(i)}),_({type:we(`http`,`mcp_tool`,`prompt`,`agent`)})),U=_({matcher:e(m),hooks:F(Sn)}),Cn=_({PreToolUse:O(F(U),{exact:!0,default:()=>[]}),PostToolUse:O(F(U),{exact:!0,default:()=>[]}),PostToolUseFailure:O(F(U),{exact:!0,default:()=>[]}),UserPromptSubmit:O(F(U),{exact:!0,default:()=>[]}),Stop:O(F(U),{exact:!0,default:()=>[]}),SessionStart:O(F(U),{exact:!0,default:()=>[]}),SessionEnd:O(F(U),{exact:!0,default:()=>[]}),PreCompact:O(F(U),{exact:!0,default:()=>[]}),PostCompact:O(F(U),{exact:!0,default:()=>[]})}),wn=_({hooks:Cn,disableAllHooks:e(i)}),W=_({event:m,reason:m}),Tn=_({unrecognized:F(W),notCarried:F(W),matcherNotEvaluable:F(W),matcherOutOfReach:F(W),shadowed:F(W),disabled:F(W)}),En=b(E(wn,qe(_({...Cn.fields,disableAllHooks:e(i),hooks:e(re)}),wn,{strict:!0,decode:({disableAllHooks:e,...t})=>Pe(e===void 0?{hooks:t}:{hooks:t,disableAllHooks:e}),encode:(e,t,n)=>rt(new tt(n,e,`Decode-only`))}))),Dn=_n,On=k(C({key:m,value:T})),kn=[],An=k(F(_({matcher:e(m),hooks:O(F(_({type:e(m)})),{exact:!0,default:()=>[]})})));function jn(e){return me(On(e),e=>j(On(e.hooks),{onNone:()=>({namespace:e,outer:e,isWrapped:!1}),onSome:t=>({namespace:t,outer:e,isWrapped:!0})}))}const G=e=>e.replaceAll(/[\p{Cc}\p{Cf}]/gu,`�`),Mn={unrecognized:[],notCarried:[],matcherNotEvaluable:[],matcherOutOfReach:[],shadowed:[],disabled:[]},Nn=gn,Pn=vn,Fn=bn,In=yn,Ln=xn,Rn=e=>P(An(e),()=>kn).flatMap(e=>e.matcher===void 0?[]:[e.matcher]),zn=e=>Rn(e).length>0,Bn=e=>I(e).pipe(R(`Reachable`,()=>r()),R(`Partial`,e=>A(e.reason)),R(`Unreachable`,e=>A(e.reason)),z);function Vn(e){return j(jn(e),{onNone:()=>Mn,onSome:({isWrapped:e,namespace:t,outer:n})=>{let r=[],i=[],a=[],o=[],s=[];for(let n of Object.keys(t)){if(!e&&n===`disableAllHooks`)continue;let s=Pn[n];if(s!==void 0){i.push({event:G(n),reason:s});continue}if(!Nn.includes(n)){r.push({event:G(n),reason:`not in this bridge's catalog (Claude Code hooks reference 2026-07-28)`});continue}let c=Fn[n];c!==void 0&&zn(t[n])&&a.push({event:G(n),reason:c});let l=Ln[n];l!==void 0&&o.push(...Rn(t[n]).flatMap(e=>{let t=l[e];return t===void 0?[]:j(Bn(t),{onNone:()=>[],onSome:t=>[{event:`${G(n)} (matcher "${G(e)}")`,reason:t}]})}))}if(e)for(let e of Object.keys(n))Nn.includes(e)&&s.push({event:G(e),reason:"ignored: this file wraps its hooks under `hooks`, so a group repeated at the top level is never read"});return{unrecognized:r,notCarried:i,matcherNotEvaluable:a,matcherOutOfReach:o,shadowed:s,disabled:[]}}})}function Hn(e){let t=e.find(e=>!e.managed&&e.settings.disableAllHooks===!0);if(t===void 0)return[];let n=`switched off by \`disableAllHooks\` in ${G(t.label)}`;return e.filter(e=>!e.managed).flatMap(e=>Dn.filter(t=>e.settings.hooks[t].length>0).map(e=>({event:e,reason:n})))}function Un(e){return j(jn(e),{onNone:()=>[],onSome:({namespace:e})=>{let t=new Set;for(let n of Dn){let r=P(An(e[n]),()=>kn);for(let e of r)for(let n of e.hooks)n.type!==void 0&&n.type!==`command`&&t.add(G(n.type))}return Array.from(t)}})}function Wn(e){let t={PreToolUse:[],PostToolUse:[],PostToolUseFailure:[],UserPromptSubmit:[],SessionStart:[],SessionEnd:[],Stop:[],PreCompact:[],PostCompact:[]};if(e.some(e=>e.managed&&e.settings.disableAllHooks===!0))return{hooks:t};let n=e.some(e=>!e.managed&&e.settings.disableAllHooks===!0);for(let r of e)if(!(n&&!r.managed))for(let e of Dn)t[e]=t[e].concat(Array.from(r.settings.hooks[e]));return{hooks:t}}function Gn(e){return I(e).pipe(R(`Merge`,({sources:e})=>Wn(e)),R(`Coverage`,({json:e})=>Vn(e)),R(`DisabledCoverage`,({sources:e})=>Hn(e)),R(`UnsupportedHookTypes`,({json:e})=>Un(e)),R(`MatcherUnreadable`,({event:e})=>Fn[e]!==void 0),R(`IfEvaluatingEvent`,({event:e})=>In.includes(e)),z)}function K(e,t){return Ae(t)(Gn(e))}const Kn=Symbol.for(`@systemfsoftware/omp-claude-compat/InterpretHookCommand`);var qn=class extends M()(`InterpretHookCommand`,{result:ln,event:m}){[Kn]=Kn};const Jn=Symbol.for(`@systemfsoftware/omp-claude-compat/HookVerdictError`);var Yn=class extends oe()(`HookVerdictError`,{raw:m}){[Jn]=Jn};const q=Symbol.for(`@systemfsoftware/omp-claude-compat/ExitKind`);var Xn=class extends M()(`ExitBlock`,{}){[q]=q},Zn=class extends M()(`ExitDecisionJson`,{}){[q]=q},Qn=class extends M()(`ExitNoDecision`,{}){[q]=q},$n=class extends M()(`ExitOther`,{}){[q]=q};E(Xn,Zn,Qn,$n);const er=e=>l(e=>e.startsWith(`{`))(e.trim()),tr=e=>I(er(e)).pipe(R(`Some`,()=>new Zn({})),R(`None`,()=>new Qn({})),z),nr={0:e=>tr(e.stdout),2:()=>new Xn({})},rr=e=>I(s(nr[e.code])).pipe(R(`Some`,t=>t.value(e)),R(`None`,()=>new $n({})),z),ir=e=>l(e=>e!==``)(e.trim()),ar=(e,t)=>I(ir(e)).pipe(R(`Some`,e=>e.value),R(`None`,()=>`Blocked by ${t} hook`),z),or={deny:(e,t)=>e.hookSpecificOutput?.permissionDecisionReason??`Blocked by ${t} hook`,block:(e,t)=>e.reason??`Blocked by ${t} hook`},sr=(e,t)=>I(s(e.hookSpecificOutput?.permissionDecision??e.decision).pipe(ve(e=>or[e]))).pipe(R(`Some`,n=>new un({reason:n.value(e,t)})),R(`None`,()=>new H({updatedInput:e.hookSpecificOutput?.updatedInput})),z),cr=e=>I(ir(e)).pipe(R(`Some`,e=>new dn({message:e.value})),R(`None`,()=>new H({})),z),lr=e=>I(rr(e.result)).pipe(R(`ExitBlock`,()=>x(new un({reason:ar(e.result.stderr,e.event)}))),R(`ExitNoDecision`,()=>x(new H({}))),R(`ExitDecisionJson`,()=>ce(hn(e.result.stdout),{onLeft:()=>h(new Yn({raw:e.result.stdout})),onRight:t=>x(sr(t,e.event))})),R(`ExitOther`,()=>x(cr(e.result.stderr))),z),ur=[`/`,`!`,`->`,`=>`,`$ `,`$ `,`$
2
- `,`$\r`,`$$ `,`$$ `,`$$
3
- `,`$$\r`],dr=e=>ur.some(t=>`${e.trimStart()} `.startsWith(t));var fr=class extends lt(`HookDispatcherExecutorDeps`)(){};const pr={UserPromptSubmit:30},mr=(e,t)=>(e??pr[t]??600)*1e3,hr=24e3,gr=(e,t,n)=>{let r=mr(e,t);return!n||r<=hr?{timeoutMs:r,capNote:``}:{timeoutMs:hr,capNote:` (capped from ${r}ms by the extension handler budget)`}},_r=v(`loadSettingsFile`)(function*(e){let t=yield*(yield*We).readFileString(e).pipe(Se(()=>D(``)));if(t===``)return null;let n=b(at(C({key:m,value:T})))(t);if(y(n))return null;let r=n.right,i=En(r);return y(i)?null:i.right}),vr=`/etc/claude-code/managed-settings.json`,yr=e=>[`${dt()}/.claude/settings.json`,`${e}/.claude/settings.json`,`${e}/.claude/settings.local.json`,vr],J=v(`loadSettings`)(function*(e){return yield*br(yr(e))}),br=v(`loadSettingsWithPaths`)(function*(e,t=vr){let n=[];for(let r of e){let e=yield*_r(r);e!==null&&n.push({settings:e,managed:r===t})}return n.length===0?null:K({_tag:`Merge`,sources:n},wn)}),Y=e=>e.filter((t,n)=>e.findIndex(e=>e.event===t.event)===n),xr=e=>[...e.unrecognized.map(e=>` ${e.event}: ${e.reason}`),...e.notCarried.map(e=>` ${e.event}: not carried by this bridge — ${e.reason}`),...e.matcherNotEvaluable.map(e=>` ${e.event}: hook skipped, matcher not evaluable — ${e.reason}`),...e.matcherOutOfReach.map(e=>` ${e.event}: ${e.reason}`),...e.shadowed.map(e=>` ${e.event}: ${e.reason}`),...e.disabled.map(e=>` ${e.event}: ${e.reason}`)],Sr=v(`collectSettingsGapsWithPaths`)(function*(e){let t=yield*We,n=[],r=[],i=[],a=[],o=[],s=[],c=[],l=[];for(let u of e){let e=yield*t.readFileString(u).pipe(Se(()=>D(``)));if(e===``)continue;let d=b(at(C({key:m,value:T})))(e);if(y(d)){l.push(u);continue}let f=K({_tag:`Coverage`,json:d.right},Tn);n.push(...f.unrecognized),r.push(...f.notCarried),i.push(...f.matcherNotEvaluable),a.push(...f.matcherOutOfReach),o.push(...f.shadowed),c.push(...K({_tag:`UnsupportedHookTypes`,json:d.right},F(m)));let p=En(d.right);y(p)?l.push(u):s.push({settings:p.right,managed:u===vr,label:u})}return{coverage:{unrecognized:Y(n),notCarried:Y(r),matcherNotEvaluable:Y(i),matcherOutOfReach:Y(a),shadowed:Y(o),disabled:Y(K({_tag:`DisabledCoverage`,sources:s},F(W)))},unsupportedHookTypes:Array.from(new Set(c)),malformedFiles:Array.from(new Set(l))}}),Cr=v(`collectSettingsGaps`)(function*(e){return yield*Sr(yr(e))}),wr={sh:[`sh`,`-c`],bash:[`bash`,`-c`],powershell:[`powershell`,`-Command`]},X=v(`runHookScript`)(function*(e,t,n,r,i=!0){let a=yield*$t,{timeoutMs:s,capNote:c}=gr(e.timeout,r,i),l=Er(t),[u,d]=wr[e.shell??`sh`],f=(e.args===void 0?Jt(u,d,e.command):Jt(e.command,...e.args)).pipe(Qt(n),Gt({OMP_PROJECT_DIR:n,CLAUDE_PROJECT_DIR:n}),Kt(l),Zt(`pipe`),Yt(`pipe`)),p=yield*fr;return yield*cn(De(Ye(e=>g(function*(){let t=yield*a.start(f);yield*ct(()=>_e(t.kill(`SIGKILL`)).pipe(Ke(2e3),le));let[n,r,i]=yield*e(ye([t.stdout.pipe(be(),Be),t.stderr.pipe(be(),Be),t.exitCode.pipe(o(Number),Se(()=>D(-1)))],{concurrency:`unbounded`}));return{code:i,stdout:n,stderr:r}}))).pipe(it(t=>ut(`hook ${e.command} failed`,t))),p,{deadline:s,onDeadline:()=>({code:-1,stdout:``,stderr:`timeout after ${s}ms${c}`})})}),Z={},Tr=C({key:m,value:T}),Q=k(Tr),Er=Xe(at(Tr)),Dr=(e,t,r)=>e.pipe(ie({onSuccess:e=>{let t=hn(e.stdout);if(ee(t)){let e=t.right.hookSpecificOutput?.additionalContext;e!==void 0&&on(e)}},onFailure:e=>{Ve(e)||t.ui.notify(`Background hook failed: ${r}: ${n(e).split(`
4
- `)[0]}`,`error`)}})),Or=v(`runHooksForEventUnbounded`)(function*(e,t,n,a,o){let s=a.cwd,c=P(Q(n.tool_input),()=>Z),l,d=n,f=K({_tag:`MatcherUnreadable`,event:o},i);for(let n of e)if(!(f&&n.matcher!==void 0)&&Je(t,n.matcher))for(let e of n.hooks){if(e.type!==`command`||e.if!==void 0&&(!K({_tag:`IfEvaluatingEvent`,event:o},i)||!nt(e.if,t,c,s)))continue;if(e.async===!0||e.asyncRewake===!0){yield*ge(Dr(X(e,d,s,o,!1),a,e.command));continue}let n=ce(lr(new qn({result:yield*X(e,d,s,o),event:o})),{onLeft:e=>I(e).pipe(R(`HookVerdictError`,e=>new dn({message:`Hook exited 0 but produced invalid JSON: ${e.raw.slice(0,200)}`})),z),onRight:e=>e}),f=I(n).pipe(R(`Block`,e=>new fn({reason:e.reason})),R(`Warning`,e=>new pn({warning:e.message})),R(`Allow`,e=>new pn({updatedInput:e.updatedInput})),z),p=I(f).pipe(R(`Blocked`,e=>A({block:!0,reason:e.reason})),R(`Continue`,e=>(e.warning!==void 0&&l===void 0&&(l=e.warning),e.updatedInput!==void 0&&(d={...d,...e.updatedInput}),r())),z);if(u(p))return p.value}return{...d===n?{}:{updatedInput:d},...l===void 0?{}:{warning:l}}}),$=v(`runHooksForEvent`)(function*(e,t,n,r,i){return yield*Or(e,t,n,r,i).pipe(Ke(26e3),d(`TimeoutException`,()=>D({})))}),kr=v(`runPreToolUseHooks`)(function*(e,t,n){let r=He(t.toolName),i=N(()=>n.sessionManager.getSessionId()),a=P(Q(t.input),()=>Z),o=Me(r,a),s=ke(t.toolName,a);if(s!==void 0&&s.length>0){let r={...i,tool_name:`Bash`,tool_input:{command:s},tool_call_id:t.toolCallId},a=yield*$(e.hooks.PreToolUse,`Bash`,r,n,`PreToolUse`);if(a.block===!0)return a.reason===void 0?{block:!0}:{block:!0,reason:a.reason}}let c=Re(r,o),l=c.length===0?[o]:c.map(e=>({...o,file_path:e})),u={};for(let a of l){let o={...i,tool_name:r,tool_input:a,tool_call_id:t.toolCallId},s=yield*$(e.hooks.PreToolUse,r,o,n,`PreToolUse`);if(s.block===!0)return s.reason===void 0?{block:!0}:{block:!0,reason:s.reason};u=s}let d=l.length===1?u.updatedInput?.tool_input:void 0;Object.assign(t.input,$e(a,d))}),Ar=v(`runPostToolUseHooks`)(function*(e,t,n){let r=He(t.toolName),i=N(()=>n.sessionManager.getSessionId()),a=Me(r,P(Q(t.input),()=>Z)),o=Re(r,a),s=o.length===0?[a]:o.map(e=>({...a,file_path:e})),c,l={};for(let a of s){let o={...i,tool_name:r,tool_input:a,tool_call_id:t.toolCallId,output:t.content,is_error:t.isError??!1},s=yield*$(e.hooks.PostToolUse,r,o,n,`PostToolUse`);if(s.block===!0)return s;c===void 0&&(c=s.warning),l=s}return c===void 0?l:{...l,warning:c}}),jr=k(F(_({text:e(m)}))),Mr=k(m),Nr=e=>j(jr(e),{onSome:e=>e.flatMap(e=>e.text===void 0?[]:[e.text]).join(`
5
- `),onNone:()=>P(Mr(e),()=>``)}),Pr=v(`runPostToolUseFailureHooks`)(function*(e,t,n){let r=He(t.toolName),i=Me(r,P(Q(t.input),()=>Z)),a={...N(()=>n.sessionManager.getSessionId()),tool_name:r,tool_input:i,tool_use_id:t.toolCallId,error:Nr(t.content)},o=yield*$(e.hooks.PostToolUseFailure,r,a,n,`PostToolUseFailure`);return o.block===!0?o.reason===void 0?{}:{warning:o.reason}:o}),Fr=v(`runToolResultHooks`)(function*(e,t,n){return t.isError===!0?yield*Pr(e,t,n):yield*Ar(e,t,n)}),Ir=v(`runPreCompactHooks`)(function*(e,t){let n={...N(()=>t.sessionManager.getSessionId())};return yield*$(e.hooks.PreCompact,``,n,t,`PreCompact`)}),Lr=v(`runUserPromptSubmitHooks`)(function*(e,t,n){let r=e.hooks.UserPromptSubmit,i=n.cwd,a=dr(t.text),o=I(a).pipe(L(!0,()=>[]),L(!1,()=>sn()),z),s=[],c={...N(()=>n.sessionManager.getSessionId()),prompt:t.text,source:t.source};for(let e of r)for(let t of e.hooks){if(t.type!==`command`||t.if!==void 0)continue;let e=yield*X(t,c,i,`UserPromptSubmit`),r=ce(lr(new qn({result:e,event:`UserPromptSubmit`})),{onLeft:()=>void 0,onRight:e=>I(e).pipe(R(`Block`,e=>e.reason),Ct(()=>void 0))});if(r!==void 0)return n.ui.notify(`Prompt blocked by UserPromptSubmit hook: ${r}`,`error`),{handled:!0};if(e.code!==0)continue;let a=e.stdout.trim();a.length>0&&s.push(a)}return I(a).pipe(L(!0,()=>void 0),L(!1,()=>{let e=[...o,...s].join(`
6
-
7
- `);if(e.length===0)return;let n={text:`${e}\n\n${t.text}`};return t.images!==void 0&&(n.images=t.images),n}),z)}),Rr=v(`runSessionStartHooks`)(function*(e,t,n){let r=e.hooks.SessionStart;if(r.length===0)return;let i=n.cwd,a={...N(()=>n.sessionManager.getSessionId()),reason:t};for(let e of r)if(!(e.matcher!==void 0&&!Je(t,e.matcher))){for(let t of e.hooks)if(t.type===`command`&&t.if===void 0){if(t.async===!0||t.asyncRewake===!0){yield*ge(Dr(X(t,a,i,`SessionStart`,!1),n,t.command));continue}yield*X(t,a,i,`SessionStart`)}}}),zr=v(`runSessionSwitchHooks`)(function*(e,t,n){(t===`resume`||t===`fork`)&&(yield*Rr(e,t,n))}),Br=v(`runLifecycleHooks`)(function*(e,t,n){if(e.length===0)return;let r=t.cwd,a={...N(()=>t.sessionManager.getSessionId())},o=K({_tag:`MatcherUnreadable`,event:n},i);for(let i of e)if(!(o&&i.matcher!==void 0))for(let e of i.hooks)e.type===`command`&&e.if===void 0&&(e.async===!0||e.asyncRewake===!0?yield*ge(Dr(X(e,a,r,n,!1),t,e.command)):yield*X(e,a,r,n))}),Vr=e=>g(function*(){return yield*I(e).pipe(R(`ToolCall`,({event:e,ctx:t})=>g(function*(){let n=yield*J(t.cwd);if(n)return yield*kr(n,e,t)})),R(`ToolResult`,({event:e,ctx:t})=>g(function*(){let n=yield*J(t.cwd);if(!n)return;let r=yield*Fr(n,e,t);if(r.block===!0)return{isError:!0,content:[{type:`text`,text:r.reason??`Blocked by PostToolUse hook`}]};if(r.warning!==void 0)return{content:[...e.content,{type:`text`,text:r.warning}],isError:e.isError}})),R(`Prompt`,({event:e,ctx:t})=>g(function*(){let n=yield*J(t.cwd);if(n)return yield*Lr(n,e,t)})),R(`SessionStart`,({reason:e,ctx:t})=>g(function*(){let n=yield*Cr(t.cwd),r=xr(n.coverage);r.length>0&&t.ui.notify(`Hook coverage — configured hooks this bridge will not run:\n${r.join(`
8
- `)}`,`warning`),n.unsupportedHookTypes.length>0&&t.ui.notify(`Skipping hook(s) this bridge cannot run yet: type ${n.unsupportedHookTypes.join(`, `)}`,`warning`),n.malformedFiles.length>0&&t.ui.notify(`Hooks are NOT running from malformed settings file(s): ${n.malformedFiles.join(`, `)}`,`error`);let i=yield*J(t.cwd);i&&(yield*Rr(i,e,t))})),R(`SessionCompact`,({ctx:e})=>g(function*(){let t=yield*J(e.cwd);t&&(yield*Rr(t,`compact`,e),yield*Br(t.hooks.PostCompact,e,`PostCompact`))})),R(`PreCompact`,({ctx:e})=>g(function*(){let t=yield*J(e.cwd);if(!t)return;let n=yield*Ir(t,e);if(n.block===!0)return e.ui.notify(`Compaction cancelled by a PreCompact hook: ${n.reason??`no reason given`}`,`warning`),{cancel:!0}})),R(`SessionSwitch`,({reason:e,ctx:t})=>g(function*(){let n=yield*J(t.cwd);n&&(yield*zr(n,e,t))})),R(`SessionShutdown`,({ctx:e})=>g(function*(){let t=yield*J(e.cwd);t&&(yield*Br(t.hooks.SessionEnd,e,`SessionEnd`))})),R(`SessionStop`,({ctx:e})=>g(function*(){let t=yield*J(e.cwd);t&&(yield*Br(t.hooks.Stop,e,`Stop`))})),z)});export{nn as a,qt as c,tn as i,Xt as l,Vr as n,en as o,$t as r,rn as s,fr as t};
@@ -1 +0,0 @@
1
- import{At as e,It as t,Kn as n,Ot as r,Pr as i,Tr as a,jn as o,rn as s}from"./dist-uv-To51R.js";import{n as c}from"./hook-dispatcher.executor-DiQf8RVY.js";const l=l=>{async function u(l){let u=await import(`./hook-runtime.state-B1tGHImx.js`).then(e=>e.default),d=t(function*(){let e=yield*r(c(l));if(i(e))throw e.left;return e.right}).pipe(s(28e3),e),f=await u.runPromise(d);if(n(f))throw o(f.cause);return a(f.value)}l.on(`tool_call`,(e,t)=>u({_tag:`ToolCall`,event:e,ctx:t})),l.on(`tool_result`,(e,t)=>u({_tag:`ToolResult`,event:e,ctx:t})),l.on(`input`,(e,t)=>u({_tag:`Prompt`,event:e,ctx:t})),l.on(`session_start`,(e,t)=>u({_tag:`SessionStart`,reason:`startup`,ctx:t})),l.on(`session_compact`,(e,t)=>u({_tag:`SessionCompact`,ctx:t})),l.on(`session_before_compact`,(e,t)=>u({_tag:`PreCompact`,ctx:t})),l.on(`session_switch`,(e,t)=>u({_tag:`SessionSwitch`,reason:e.reason,ctx:t})),l.on(`session_shutdown`,async(e,t)=>{let n=await import(`./hook-runtime.state-B1tGHImx.js`).then(e=>e.default);try{return await u({_tag:`SessionShutdown`,ctx:t})}finally{await n.dispose()}}),l.on(`session_stop`,(e,t)=>u({_tag:`SessionStop`,ctx:t}))};export{l as HookDispatcherTask};
@@ -1 +0,0 @@
1
- import{$n as e,$t as t,A as n,Ar as r,Br as i,Bt as a,C as o,Cn as s,Cr as c,Ct as l,Dn as u,Dt as d,E as f,En as p,F as ee,Gn as te,Gr as m,Gt as h,Hr as ne,I as re,It as ie,Jn as g,Jt as ae,Kt as oe,Ln as se,Lt as ce,Mn as le,Mt as _,N as ue,Nn as de,On as fe,P as pe,Pt as me,Qn as v,Qt as y,R as he,S as ge,Sn as _e,Ut as ve,Vr as ye,Wr as be,Wt as xe,Xn as Se,Xt as Ce,Yn as we,Yt as Te,Zn as b,Zt as x,_ as Ee,_n as De,_r as Oe,_t as S,an as ke,ar as C,b as Ae,bn as je,bt as w,cn as Me,d as Ne,dn as Pe,dr as Fe,dt as T,en as Ie,er as Le,f as Re,fn as ze,ft as Be,g as E,gn as Ve,gt as D,h as O,hn as k,ht as He,in as Ue,ir as We,jr as A,jt as j,kr as Ge,kt as Ke,ln as qe,lt as Je,m as M,mn as Ye,mt as Xe,n as Ze,nr as Qe,or as $e,p as et,pn as tt,pt as N,qn as nt,rr as rt,sn as it,sr as at,t as ot,tr as st,un as P,ut as ct,v as lt,vn as F,vt as ut,w as dt,wn as ft,wr as pt,wt as I,x as mt,xn as ht,xr as gt,y as _t,yn as vt,yt as L}from"./dist-uv-To51R.js";import{a as yt,c as bt,i as xt,l as R,o as z,r as St,s as Ct,t as wt}from"./hook-dispatcher.executor-DiQf8RVY.js";import{t as Tt}from"./inject-instructions.executor-kXP1_aBg.js";import*as Et from"node:os";import*as Dt from"node:crypto";import*as B from"node:path";import*as V from"node:fs";import*as H from"node:child_process";function U(e,t){return Qe(e.runtimeEffect,e=>at(n=>(n.setFiberRefs(e.fiberRefs),n.currentRuntimeFlags=e.runtimeFlags,We(t,e.context))))}const Ot={...se,[p]:p,pipe(){return i(this,arguments)},commit(){return this.runtimeEffect}},kt=(e,t)=>{t??=ze();let n=_e(le()),r,i=C(()=>{if(!r){let i=new de;r=k($e(fe(Pe(e,t),n),e=>{a.cachedRuntime=e}),{scope:n,scheduler:i}),i.flush()}return rt(r.await)}),a=Object.assign(Object.create(Ot),{memoMap:t,scope:n,runtimeEffect:i,cachedRuntime:void 0,runtime(){return a.cachedRuntime===void 0?F(a.runtimeEffect):Promise.resolve(a.cachedRuntime)},dispose(){return F(a.disposeEffect)},disposeEffect:C(()=>(a.runtimeEffect=Le(`ManagedRuntime disposed`),a.cachedRuntime=void 0,u(a.scope,st))),runFork(e,t){return a.cachedRuntime===void 0?k(U(a,e),t):Ye(a.cachedRuntime)(e,t)},runSyncExit(e){return a.cachedRuntime===void 0?ft(U(a,e)):s(a.cachedRuntime)(e)},runSync(e){return a.cachedRuntime===void 0?_e(U(a,e)):ht(a.cachedRuntime)(e)},runPromiseExit(e,t){return a.cachedRuntime===void 0?je(U(a,e),t):vt(a.cachedRuntime)(e,t)},runCallback(e,t){return a.cachedRuntime===void 0?Ve(tt)(U(a,e),t):Ve(a.cachedRuntime)(e,t)},runPromise(e,t){return a.cachedRuntime===void 0?F(U(a,e),t):De(a.cachedRuntime)(e,t)}});return a},W=(e,t,n)=>(...r)=>I(i=>{try{e(...r,(e,n)=>{i(e?j(t?t(e,r):e):x(n))})}catch(e){i(n?j(n(e,r)):d(e))}}),G=(e,t,n)=>f(At(e,t,n)),At=(e,t,n)=>N(()=>Nt(e(),t,Fe(void 0),n)),jt=(e,t,{encoding:n,endOnDone:r=!0}={},i=L)=>{let a=Mt(e,n),o=r?I(t=>{`closed`in e&&e.closed?t(L):(e.once(`finish`,()=>t(L)),e.end())}):L;return{awaitRead:()=>L,emit:a,error:e=>P(o,t(e)),done:e=>P(o,i)}},Mt=(e,t)=>n=>n.length===0?L:I(r=>{let i=n[Symbol.iterator](),a=i.next();function o(){let n=a;a=i.next();let s=e.write(n.value,t);a.done?r(L):s?o():e.once(`drain`,o)}o()}),Nt=(e,n,r,i)=>{if(!e.readable)return Xe;let a=it(!1);function o(){a.unsafeOpen()}function s(e){r.current=te(n(e)),a.unsafeOpen()}function c(){r.current=nt,a.unsafeOpen()}e.on(`readable`,o),e.on(`error`,s),e.on(`end`,c);let l=i?.chunkSize?Number(i.chunkSize):void 0;return ct(N(function t(){let n=e.read(l);if(n===null)return r.current?Be(r.current):(a.unsafeClose(),T(a.await,t));let i=[n];for(;;){if(n=e.read(l),n===null)return T(He(Oe(i)),t);i.push(n)}}),t(()=>{e.off(`readable`,o),e.off(`error`,s),e.off(`end`,c),i?.closeOnDone!==!1&&`closed`in e&&!e.closed&&e.destroy()}))},Pt=(e,t,n)=>he(Ft(e,t,n)),Ft=(e,n,r)=>T(qe(t(()=>e()),v()),([e,t])=>Je(It(e,t,n),jt(e,e=>Se(t,e),r,we(t,L)))),It=(n,r,i)=>y(()=>{function a(t){e(r,j(i(t)))}return n.on(`error`,a),Ke(g(r),t(()=>{n.removeListener(`error`,a)}))}),K=(e,t)=>(n,[r])=>{let i=`Unknown`;switch(n.code){case`ENOENT`:i=`NotFound`;break;case`EACCES`:i=`PermissionDenied`;break;case`EEXIST`:i=`AlreadyExists`;break;case`EISDIR`:i=`BadResource`;break;case`ENOTDIR`:i=`BadResource`;break;case`EBUSY`:i=`Busy`;break;case`ELOOP`:i=`BadResource`;break}return new o({reason:i,module:e,method:t,pathOrDescriptor:r,syscall:n.syscall,description:n.message,cause:n})},Lt=e=>typeof e==`string`?e:`pipe`,Rt=e=>typeof e==`string`?e:`pipe`,q=e=>e instanceof globalThis.Error?e:new globalThis.Error(String(e)),J=(e,t,n)=>{let r=bt(n).reduce((e,t)=>{let n=`${t.command} ${t.args.join(` `)}`;return e.length===0?n:`${e} | ${n}`},``);return K(`Command`,e)(t,[r])},zt={[z]:z,...ye,toJSON(){return{_id:`@effect/platform/CommandExecutor/Process`,pid:this.pid}}},Y=r=>i=>{switch(i._tag){case`StandardCommand`:{let o=_(v(),n=>I(r=>{let a=H.spawn(i.command,i.args,{stdio:[Lt(i.stdin),Rt(i.stdout),Rt(i.stderr)],cwd:pt(i.cwd,ne),shell:i.shell,env:{...process.env,...Object.fromEntries(i.env)},detached:process.platform!==`win32`});return a.on(`error`,e=>{r(j(J(`spawn`,e,i)))}),a.on(`exit`,(...t)=>{e(n,x(t))}),a.on(`spawn`,()=>{r(x([a,n]))}),t(()=>{a.kill(`SIGTERM`)})})),s=process.platform===`win32`?(e,t)=>I(t=>{H.exec(`taskkill /pid ${e.pid} /T /F`,e=>{t(e?j(J(`kill`,q(e),i)):L)})}):(e,t)=>ke({try:()=>process.kill(-e.pid,t),catch:e=>J(`kill`,q(e),i)}),c=(e,t)=>y(()=>e.kill(t)?L:j(J(`kill`,new globalThis.Error(`Failed to kill process`),i)));return m(Ge(i.cwd,{onNone:()=>L,onSome:e=>r.access(e)}),P(w(o,([e,t])=>_(b(t),n=>n?_(g(t),([t])=>t!==0&&t!==null?s(e,`SIGTERM`).pipe(ce):L):s(e,`SIGTERM`).pipe(oe(()=>c(e,`SIGTERM`)),P(g(t)),ce)))),a(([e,t])=>{let n=re;e.stdin!==null&&(n=Pt(()=>e.stdin,e=>J(`toWritable`,q(e),i)));let r=_(g(t),([e,t])=>e===null?j(J(`exitCode`,new globalThis.Error(`Process interrupted due to receipt of signal: ${t}`),i)):x(xt(e))),a=xe(b(t)),o=(n=`SIGTERM`)=>s(e,n).pipe(oe(()=>c(e,n)),P(l(g(t)))),u=yt(e.pid),d=G(()=>e.stderr,e=>J(`fromReadable(stderr)`,q(e),i)),f=G(()=>e.stdout,e=>J(`fromReadable(stdout)`,q(e),i));return typeof i.stdout!=`string`&&(f=ue(f,i.stdout)),Object.assign(Object.create(zt),{pid:u,exitCode:r,isRunning:a,kill:o,stdin:n,stderr:d,stdout:f})}),typeof i.stdin==`string`?be:Ie(e=>me(n(i.stdin,e.stdin))))}case`PipedCommand`:{let e=bt(i);if(e.length===1)return m(e[0],Y(r));let t=e[0],n=e.slice(1),o=n.slice(0,n.length-1),s=n[n.length-1];return m(R(s,o.reduce((e,t)=>m(R(t,e),Y(r),a(e=>e.stdout),ee),m(Y(r)(t),a(e=>e.stdout),ee))),Y(r))}}},Bt=D(St,m(M,a(e=>Ct(Y(e))))),X=e=>t=>new ge({module:`FileSystem`,method:e,cause:t}),Vt=(()=>{let e=W(V.access,K(`FileSystem`,`access`),X(`access`));return(t,n)=>{let r=V.constants.F_OK;return n?.readable&&(r|=V.constants.R_OK),n?.writable&&(r|=V.constants.W_OK),e(t,r)}})(),Ht=(()=>{let e=W(V.cp,K(`FileSystem`,`copy`),X(`copy`));return(t,n,r)=>e(t,n,{force:r?.overwrite??!1,preserveTimestamps:r?.preserveTimestamps??!1,recursive:!0})})(),Ut=(()=>{let e=W(V.copyFile,K(`FileSystem`,`copyFile`),X(`copyFile`));return(t,n)=>e(t,n)})(),Wt=(()=>{let e=W(V.chmod,K(`FileSystem`,`chmod`),X(`chmod`));return(t,n)=>e(t,n)})(),Gt=(()=>{let e=W(V.chown,K(`FileSystem`,`chown`),X(`chown`));return(t,n,r)=>e(t,n,r)})(),Kt=(()=>{let e=W(V.link,K(`FileSystem`,`link`),X(`link`));return(t,n)=>e(t,n)})(),qt=(()=>{let e=W(V.mkdir,K(`FileSystem`,`makeDirectory`),X(`makeDirectory`));return(t,n)=>e(t,{recursive:n?.recursive??!1,mode:n?.mode})})(),Z=e=>{let t=W(V.mkdtemp,K(`FileSystem`,e),X(e));return e=>y(()=>{let n=e?.prefix??``,r=typeof e?.directory==`string`?B.join(e.directory,`.`):Et.tmpdir();return t(n?B.join(r,n):r+`/`)})},Jt=Z(`makeTempDirectory`),Q=e=>{let t=W(V.rm,K(`FileSystem`,e),X(e));return(e,n)=>t(e,{recursive:n?.recursive??!1,force:n?.force??!1})},Yt=Q(`remove`),Xt=(()=>{let e=Z(`makeTempDirectoryScoped`),t=Q(`makeTempDirectoryScoped`);return n=>w(e(n),e=>h(t(e,{recursive:!0})))})(),Zt=e=>{let t=W(V.open,K(`FileSystem`,e),X(e)),n=W(V.close,K(`FileSystem`,e),X(e));return(e,r)=>m(w(t(e,r?.flag??`r`,r?.mode),e=>h(n(e))),a(e=>$t(et(e),r?.flag?.startsWith(`a`)??!1)))},Qt=Zt(`open`),$t=(()=>{let e=e=>W(V.read,K(`FileSystem`,e),X(e)),n=e(`read`),i=e(`readAlloc`),s=W(V.fstat,K(`FileSystem`,`stat`),X(`stat`)),c=W(V.ftruncate,K(`FileSystem`,`truncate`),X(`truncate`)),l=W(V.fsync,K(`FileSystem`,`sync`),X(`sync`)),u=e=>W(V.write,K(`FileSystem`,e),X(e)),d=u(`write`),f=u(`writeAll`);class p{fd;append;[O];semaphore=Me(1);position=0n;constructor(e,t){this.fd=e,this.append=t,this[O]=O}get stat(){return a(s(this.fd),ln)}get sync(){return l(this.fd)}seek(e,n){let r=E(e);return this.semaphore.withPermits(1)(t(()=>(n===`start`?this.position=r:n===`current`&&(this.position+=r),this.position)))}read(e){return this.semaphore.withPermits(1)(a(y(()=>n(this.fd,{buffer:e,position:this.position})),e=>{let t=E(e);return this.position+=t,t}))}readAlloc(e){let n=Number(e);return this.semaphore.withPermits(1)(_(t(()=>Buffer.allocUnsafeSlow(n)),e=>a(i(this.fd,{buffer:e,position:this.position}),t=>{if(t===0)return r();if(this.position+=BigInt(t),t===n)return A(e);let i=Buffer.allocUnsafeSlow(t);return e.copy(i,0,0,t),A(i)})))}truncate(e){return this.semaphore.withPermits(1)(a(c(this.fd,e?Number(e):void 0),()=>{if(!this.append){let t=BigInt(e??0);this.position>t&&(this.position=t)}}))}write(e){return this.semaphore.withPermits(1)(a(y(()=>d(this.fd,e,void 0,void 0,this.append?void 0:Number(this.position))),e=>{let t=E(e);return this.append||(this.position+=t),t}))}writeAllChunk(e){return _(y(()=>f(this.fd,e,void 0,void 0,this.append?void 0:Number(this.position))),t=>t===0?j(new o({module:`FileSystem`,method:`writeAll`,reason:`WriteZero`,pathOrDescriptor:this.fd,description:`write returned 0 bytes written`})):(this.append||(this.position+=BigInt(t)),t<e.length?this.writeAllChunk(e.subarray(t)):L))}writeAll(e){return this.semaphore.withPermits(1)(this.writeAllChunk(e))}}return(e,t)=>new p(e,t)})(),en=e=>{let n=Z(e),r=Zt(e),i=e=>t(()=>Dt.randomBytes(e).toString(`hex`));return e=>m(qe(n(e),i(6)),a(([t,n])=>B.join(t,n+(e?.suffix??``))),Ie(e=>Te(r(e,{flag:`w+`}))))},tn=en(`makeTempFile`),nn=(()=>{let e=en(`makeTempFileScoped`),t=Q(`makeTempFileScoped`);return n=>w(e(n),e=>h(t(B.dirname(e),{recursive:!0})))})(),rn=(e,t)=>Ue({try:()=>V.promises.readdir(e,t),catch:t=>K(`FileSystem`,`readDirectory`)(t,[e])}),an=e=>I((t,n)=>{try{V.readFile(e,{signal:n},(n,r)=>{t(n?j(K(`FileSystem`,`readFile`)(n,[e])):x(r))})}catch(e){t(j(X(`readFile`)(e)))}}),on=(()=>{let e=W(V.readlink,K(`FileSystem`,`readLink`),X(`readLink`));return t=>e(t)})(),sn=(()=>{let e=W(V.realpath,K(`FileSystem`,`realPath`),X(`realPath`));return t=>e(t)})(),cn=(()=>{let e=W(V.rename,K(`FileSystem`,`rename`),X(`rename`));return(t,n)=>e(t,n)})(),ln=e=>({type:e.isFile()?`File`:e.isDirectory()?`Directory`:e.isSymbolicLink()?`SymbolicLink`:e.isBlockDevice()?`BlockDevice`:e.isCharacterDevice()?`CharacterDevice`:e.isFIFO()?`FIFO`:e.isSocket()?`Socket`:`Unknown`,mtime:c(e.mtime),atime:c(e.atime),birthtime:c(e.birthtime),dev:e.dev,rdev:c(e.rdev),ino:c(e.ino),mode:e.mode,nlink:c(e.nlink),uid:c(e.uid),gid:c(e.gid),size:E(e.size),blksize:c(E(e.blksize)),blocks:c(e.blocks)}),$=(()=>{let e=W(V.stat,K(`FileSystem`,`stat`),X(`stat`));return t=>a(e(t),ln)})(),un=(()=>{let e=W(V.symlink,K(`FileSystem`,`symlink`),X(`symlink`));return(t,n)=>e(t,n)})(),dn=(()=>{let e=W(V.truncate,K(`FileSystem`,`truncate`),X(`truncate`));return(t,n)=>e(t,n===void 0?void 0:Number(n))})(),fn=(()=>{let e=W(V.utimes,K(`FileSystem`,`utime`),X(`utime`));return(t,n,r)=>e(t,n,r)})(),pn=(e,n)=>dt(r=>w(t(()=>{let t=V.watch(e,{recursive:n?.recursive},(e,t)=>{if(t)switch(e){case`rename`:r.fromEffect(ve($(t),{onSuccess:e=>x(lt({path:t})),onFailure:e=>e._tag===`SystemError`&&e.reason===`NotFound`?x(_t({path:t})):j(e)}));return;case`change`:r.single(Ae({path:t}));return}});return t.on(`error`,t=>{r.fail(new o({module:`FileSystem`,reason:`Unknown`,method:`watch`,pathOrDescriptor:e,cause:t}))}),t.on(`close`,()=>{r.end()}),t}),e=>t(()=>e.close()))),mn=(e,t,n)=>$(t).pipe(a(r=>e.pipe(gt(e=>e.register(t,r,n)),pt(()=>pn(t,n)))),pe),hn=(e,t,n)=>I((r,i)=>{try{V.writeFile(e,t,{signal:i,flag:n?.flag,mode:n?.mode},t=>{r(t?j(K(`FileSystem`,`writeFile`)(t,[e])):L)})}catch(e){r(j(X(`writeFile`)(e)))}}),gn=D(M,a(Ce(Ee),e=>mt({access:Vt,chmod:Wt,chown:Gt,copy:Ht,copyFile:Ut,link:Kt,makeDirectory:qt,makeTempDirectory:Jt,makeTempDirectoryScoped:Xt,makeTempFile:tn,makeTempFileScoped:nn,open:Qt,readDirectory:rn,readFile:an,readLink:on,realPath:sn,remove:Yt,rename:cn,stat:$,symlink:un,truncate:dn,utimes:fn,watch(t,n){return mn(e,t,n)},writeFile:hn}))),_n=Bt,vn=ut(wt,ae),yn=D(Tt,ie(function*(){return{fileSystem:yield*M,path:yield*Ne,tomlLoader:yield*ot}})),bn=_n.pipe(S(gn),S(Re)),xn=kt(vn.pipe(S(yn),S(Ze),S(bn)));export{vn as HookScopeLive,yn as InjectInstructionsDepsLive,xn as default};
@@ -1,3 +0,0 @@
1
- import{Fr as e,Nt as t,Ot as n,Pr as r,Tt as i,Zt as a,yr as o}from"./dist-uv-To51R.js";var s=class extends o(`InjectInstructionsExecutorDeps`)(){};const c=[`AGENTS.md`],l=t(`extractRefs`)(function*(t,r,i){let{fileSystem:a,path:o}=yield*s,c=[];for(let s of t.split(`
2
- `)){let t=s.trim().replace(/^[-*+]\s+/,``);if(!t.startsWith(`@`))continue;let l=t.slice(1).trim();if(!l||l.includes(` `)||o.isAbsolute(l))continue;let u=o.resolve(r,l);if(u.startsWith(i+`/`)||u===i){let t=yield*n(a.exists(u));if(e(t)&&t.right){c.push({sourcePath:r,resolvedPath:u});continue}}let d=o.resolve(i,l);(d.startsWith(i+`/`)||d===i)&&d!==u&&c.push({sourcePath:i,resolvedPath:d})}return c});function u(o){return t(`loadReferencedContent`)(function*(t){let{fileSystem:o,path:u,tomlLoader:d}=yield*s,f=[u.resolve(t,`CLAUDE.md`),u.resolve(t,`.claude`,`CLAUDE.md`)],p=[];for(let r of f){let i=yield*n(o.readFileString(r,`utf-8`));if(e(i)){let e=yield*l(i.right,u.dirname(r),t);p.push(...e)}}let m=new Set,h=[];for(let e of p)m.has(e.resolvedPath)||(m.add(e.resolvedPath),h.push(e));let g=(yield*d.load(t).pipe(i(()=>a(void 0))))?.no_inject_refs??c,_=[];for(let e of h){let i=e.resolvedPath.slice(t.length+1);if(g.includes(i))continue;let a=yield*n(o.readFileString(e.resolvedPath,`utf-8`));r(a)||_.push(`## ${i}\n${a.right}\n`)}return _.length===0?``:[`# Injected @-references from CLAUDE.md`,`The following files were @-imported by CLAUDE.md and contain project rules.`,``,..._].join(`
3
- `)})(o)}export{u as n,s as t};
@@ -1 +0,0 @@
1
- import{At as e,Bn as t,Hn as n,It as r,Kn as i,Mr as a,Ot as o,Rn as s,Rr as c,Un as l,Ur as u,Vn as d,Wn as f,jn as p,zn as m,zr as h}from"./dist-uv-To51R.js";import{n as g}from"./inject-instructions.executor-kXP1_aBg.js";const _=f,v=Symbol.for(`effect/Config`),y={_A:e=>e},b={...h,[v]:y,commit(){return s(this)}},x=u(2,(e,t)=>{let r=Object.create(b);return r._tag=n,r.name=t,r.config=e,r}),S=u(2,(e,n)=>{let r=Object.create(b);return r._tag=t,r.first=e,r.second=E(n.orElse),r.condition=n.if,r}),C=(e,t)=>{let n=Object.create(b);return n._tag=l,n.description=e,n.parse=t,n},w=e=>{let t=C(`a text property`,c);return e===void 0?t:x(t,e)},T=e=>{let t=Object.create(b);return t._tag=m,t.value=e,t.parse=()=>c(e),t},E=e=>{let t=Object.create(b);return t._tag=d,t.config=e,t},D=u(2,(e,t)=>S(e,{orElse:()=>T(t),if:_})),O=w,k=D,A=t=>{t.on(`before_agent_start`,async(t,n)=>{let s=await(await import(`./hook-runtime.state-B1tGHImx.js`).then(e=>e.default)).runPromise(r(function*(){return a(yield*o(g(yield*O(`CLAUDE_PROJECT_DIR`).pipe(k(process.cwd())))))}).pipe(e));if(i(s))throw p(s.cause);let c=s.value;if(c!==``)return{systemPrompt:[...t.systemPrompt,``,c]}})};export{A as InjectInstructionsTask};