@systemfsoftware/omp-claude-compat 1.2.2 → 1.2.3
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.
- package/dist/CommandExecutor-WpnYtse1.js +1 -0
- package/dist/dist-DbemdM50.js +19 -0
- package/dist/{esm-DxC3o46t.js → esm-CeQhljd9.js} +17 -17
- package/dist/hook-dispatcher.executor-Dz36w3eT.js +6 -0
- package/dist/index.js +1 -1
- package/dist/inject-instructions.executor-DD0xz4GH.js +3 -0
- package/dist/runtime-CC04dRZJ.js +1 -0
- package/package.json +4 -4
- package/dist/CommandExecutor-B_nJZc9B.js +0 -1
- package/dist/dist-DQtXO3Ic.js +0 -18
- package/dist/hook-dispatcher.executor-ZArVQNkp.js +0 -3
- package/dist/inject-instructions.executor-CcZyWYa6.js +0 -3
- package/dist/runtime-D3PIHvF6.js +0 -1
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{$ as e,$t as t,A as n,B as r,Bn as i,C as a,D as o,Dt as s,E as c,Fn as l,G as u,H as d,In as f,J as ee,K as p,L as m,Lt as te,Mn as ne,Mt as re,Nn as h,O as g,Ot as _,P as v,Pn as ie,Qt as ae,R as y,Rn as oe,S as b,T as x,U as S,Ut as se,W as C,b as w,bt as T,et as ce,it as le,j as E,jn as ue,k as de,kn as D,kt as fe,r as pe,s as me,tt as he,w as O,xt as ge,y as k,z as A,zn as j,zt as M}from"./esm-CeQhljd9.js";import{f as _e,l as N,o as ve,p as ye,s as be,t as xe,u as Se}from"./CommandExecutor-WpnYtse1.js";import{a as Ce,c as P,i as F,l as I,m as L,o as R,r as we,s as Te,u as z}from"./dist-DbemdM50.js";import{homedir as Ee}from"node:os";const B=[];function De(e){let t=e.trim();t.length!==0&&(B.length>=64&&B.shift(),B.push(t))}function Oe(){return B.splice(0,B.length)}o({code:O,stdout:c,stderr:c});var V=class extends g()(`Block`,{reason:c}){},H=class extends g()(`Allow`,{updatedInput:m(x({key:c,value:E}))}){},U=class extends g()(`Warning`,{message:c}){};n(V,H,U);var W=class extends g()(`Blocked`,{reason:c}){},G=class extends g()(`Continue`,{warning:m(c),updatedInput:m(x({key:c,value:E}))}){};n(W,G);const ke=n(o({type:b(`command`),command:c,args:m(k(c)),async:m(w),asyncRewake:m(w),shell:m(b(`bash`,`powershell`)),timeout:m(O),if:m(c),statusMessage:m(c),once:m(w)}),o({type:b(`http`,`mcp_tool`,`prompt`,`agent`)})),K=o({matcher:m(c),hooks:k(ke)}),q=o({PreToolUse:y(k(K),{exact:!0,default:()=>[]}),PostToolUse:y(k(K),{exact:!0,default:()=>[]}),UserPromptSubmit:y(k(K),{exact:!0,default:()=>[]}),Stop:y(k(K),{exact:!0,default:()=>[]}),SessionStart:y(k(K),{exact:!0,default:()=>[]}),SessionEnd:y(k(K),{exact:!0,default:()=>[]})}),Ae=o({hooks:q,disableAllHooks:m(w)}),je=v(n(Ae,r(o({...q.fields,disableAllHooks:m(w),hooks:m(a)}),Ae,{strict:!0,decode:({disableAllHooks:e,...t})=>le(e===void 0?{hooks:t}:{hooks:t,disableAllHooks:e}),encode:(e,t,n)=>he(new ee(n,e,`Decode-only`))}))),J=[`PreToolUse`,`PostToolUse`,`UserPromptSubmit`,`SessionStart`,`SessionEnd`,`Stop`],Me=e(x({key:c,value:E})),Ne=e(k(o({hooks:y(k(o({type:m(c)})),{exact:!0,default:()=>[]})})));function Pe(e){return ne(Me(e),e=>h(Me(e.hooks),{onNone:()=>({namespace:e,isWrapped:!1}),onSome:e=>({namespace:e,isWrapped:!0})}))}function Fe(e){return h(Pe(e),{onNone:()=>[],onSome:({isWrapped:e,namespace:t})=>{let n=e?J:[...J,`disableAllHooks`];return Object.keys(t).filter(e=>!n.includes(e))}})}function Ie(e){return h(Pe(e),{onNone:()=>[],onSome:({namespace:e})=>{let t=new Set;for(let n of J){let r=D(Ne(e[n]),()=>[]);for(let e of r)for(let n of e.hooks)n.type!==void 0&&n.type!==`command`&&t.add(n.type)}return Array.from(t)}})}function Le(e){let t={PreToolUse:[],PostToolUse:[],UserPromptSubmit:[],SessionStart:[],SessionEnd:[],Stop:[]};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 J)t[e]=t[e].concat(Array.from(r.settings.hooks[e]));return{hooks:t}}const Re=v(A(o({decision:m(c),reason:m(c),hookSpecificOutput:m(o({permissionDecision:m(c),permissionDecisionReason:m(c),updatedInput:m(x({key:c,value:E}))}))})));var ze=class extends de()(`HookVerdictError`,{raw:c}){},Be=class extends g()(`ExitBlock`,{}){},Ve=class extends g()(`ExitDecisionJson`,{}){},He=class extends g()(`ExitNoDecision`,{}){},Ue=class extends g()(`ExitOther`,{}){};n(Be,Ve,He,Ue);const We=e=>u(e.trim()).pipe(p(e=>e.startsWith(`{`),()=>new Ve({})),S(()=>new He({}))),Ge=e=>u(e.code).pipe(p(2,()=>new Be({})),p(0,()=>We(e.stdout)),S(()=>new Ue({}))),Ke=(e,t)=>u(e.trim()).pipe(p(``,()=>`Blocked by ${t} hook`),S(e=>e)),qe=(e,t)=>u(e.hookSpecificOutput?.permissionDecision??e.decision).pipe(p(`deny`,()=>new V({reason:e.hookSpecificOutput?.permissionDecisionReason??`Blocked by ${t} hook`})),p(`block`,()=>new V({reason:e.reason??`Blocked by ${t} hook`})),S(()=>new H({updatedInput:e.hookSpecificOutput?.updatedInput}))),Je=e=>u(e.trim()).pipe(p(``,()=>new H({})),S(e=>new U({message:e}))),Ye=(e,t)=>u(Ge(e)).pipe(C(`ExitBlock`,()=>i(new V({reason:Ke(e.stderr,t)}))),C(`ExitNoDecision`,()=>i(new H({}))),C(`ExitDecisionJson`,()=>j(Re(e.stdout),{onLeft:()=>oe(new ze({raw:e.stdout})),onRight:e=>i(qe(e,t))})),C(`ExitOther`,()=>i(Je(e.stderr))),d),Xe=s(`loadSettingsFile`)(function*(e){let t=yield*(yield*L).readFileString(e).pipe(T(()=>M(``)));if(t===``)return null;let n=v(A(x({key:c,value:E})))(t);if(f(n))return null;let r=n.right,i=je(r);return f(i)?null:i.right}),Ze=`/etc/claude-code/managed-settings.json`,Qe=e=>[`${Ee()}/.claude/settings.json`,`${e}/.claude/settings.json`,`${e}/.claude/settings.local.json`,Ze],$e=s(`loadSettings`)(function*(e){return yield*et(Qe(e))}),et=s(`loadSettingsWithPaths`)(function*(e,t=Ze){let n=[];for(let r of e){let e=yield*Xe(r);e!==null&&n.push({settings:e,managed:r===t})}return n.length===0?null:Le(n)}),tt=s(`collectSettingsGapsWithPaths`)(function*(e){let t=yield*L,n=[],r=[],i=[];for(let a of e){let e=yield*t.readFileString(a).pipe(T(()=>M(``)));if(e===``)continue;let o=v(A(x({key:c,value:E})))(e);if(f(o)){i.push(a);continue}n.push(...Fe(o.right)),r.push(...Ie(o.right)),f(je(o.right))&&i.push(a)}return{unknownEvents:Array.from(new Set(n)),unsupportedHookTypes:Array.from(new Set(r)),malformedFiles:Array.from(new Set(i))}}),nt=s(`collectSettingsGaps`)(function*(e){return yield*tt(Qe(e))}),rt={UserPromptSubmit:30},it={sh:[`sh`,`-c`],bash:[`bash`,`-c`],powershell:[`powershell`,`-Command`]},Y=s(`runHookScript`)(function*(e,t,n,r){let i=yield*xe,a=(e.timeout??rt[r]??600)*1e3,o=ot(t),[s,c]=it[e.shell??`sh`],l=(e.args===void 0?N(s,c,e.command):N(e.command,...e.args)).pipe(ye(n),ve({OMP_PROJECT_DIR:n,CLAUDE_PROJECT_DIR:n}),be(o),_e(`pipe`),Se(`pipe`));return yield*te(fe(function*(){let e=yield*i.start(l),t=yield*e.stdout.pipe(pe(),me),n=yield*e.stderr.pipe(pe(),me),r=yield*e.exitCode;return{code:typeof r==`number`?r:Number(r),stdout:t,stderr:n}})).pipe(se(a),ge(`TimeoutException`,()=>M({code:-1,stdout:``,stderr:`timeout after ${a}ms`})))}),X={},at=x({key:c,value:E}),Z=e(at),ot=ce(A(at)),Q=(e,n,r)=>e.pipe(re({onSuccess:e=>De(e.stdout),onFailure:e=>{ae(e)||n.ui.notify(`Background hook failed: ${r}: ${t(e).split(`
|
|
2
|
+
`)[0]}`,`error`)}})),$=s(`runHooksForEvent`)(function*(e,t,n,r,i){let a=r.cwd,o=D(Z(n.tool_input),()=>X),s,c=n;for(let n of e)if(R(t,n.matcher))for(let e of n.hooks){if(e.type!==`command`||e.if!==void 0&&!Te(e.if,t,o,a))continue;if(e.async===!0||e.asyncRewake===!0){yield*_(Q(Y(e,c,a,i),r,e.command));continue}let n=u(u(j(Ye(yield*Y(e,c,a,i),i),{onLeft:e=>u(e).pipe(C(`HookVerdictError`,e=>new U({message:`Hook exited 0 but produced invalid JSON: ${e.raw.slice(0,200)}`})),d),onRight:e=>e})).pipe(C(`Block`,e=>new W({reason:e.reason})),C(`Warning`,e=>new G({warning:e.message})),C(`Allow`,e=>new G({updatedInput:e.updatedInput})),d)).pipe(C(`Blocked`,e=>l({block:!0,reason:e.reason})),C(`Continue`,e=>(e.warning!==void 0&&s===void 0&&(s=e.warning),e.updatedInput!==void 0&&(c={...c,...e.updatedInput}),ie())),d);if(ue(n))return n.value}return{...c===n?{}:{updatedInput:c},...s===void 0?{}:{warning:s}}}),st=s(`runPreToolUseHooks`)(function*(e,t,n){let r=I(t.toolName),i=z(()=>n.sessionManager.getSessionId()),a=D(Z(t.input),()=>X),o=P(r,a),s=Ce(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=F(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,we(a,d))}),ct=s(`runPostToolUseHooks`)(function*(e,t,n){let r=I(t.toolName),i=z(()=>n.sessionManager.getSessionId()),a=P(r,D(Z(t.input),()=>X)),o=F(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}}),lt=s(`runUserPromptSubmitHooks`)(function*(e,t,n){let r=e.hooks.UserPromptSubmit,i=n.cwd,a=Oe().join(`
|
|
3
|
+
|
|
4
|
+
`),o={...z(()=>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*Y(t,o,i,`UserPromptSubmit`),r=j(Ye(e,`UserPromptSubmit`),{onLeft:()=>void 0,onRight:e=>u(e).pipe(C(`Block`,e=>e.reason),S(()=>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 s=e.stdout.trim();s.length>0&&(a+=(a.length>0?`
|
|
5
|
+
|
|
6
|
+
`:``)+s)}if(a.length===0)return;let s={text:`${a}\n\n${t.text}`};return t.images!==void 0&&(s.images=t.images),s}),ut=s(`runSessionStartHooks`)(function*(e,t,n){let r=e.hooks.SessionStart;if(r.length===0)return;let i=n.cwd,a={...z(()=>n.sessionManager.getSessionId()),reason:t};for(let e of r)if(!(e.matcher!==void 0&&!R(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*_(Q(Y(t,a,i,`SessionStart`),n,t.command));continue}yield*Y(t,a,i,`SessionStart`)}}}),dt=s(`runLifecycleHooks`)(function*(e,t,n){if(e.length===0)return;let r=t.cwd,i={...z(()=>t.sessionManager.getSessionId())};for(let a of e)for(let e of a.hooks)e.type===`command`&&e.if===void 0&&(e.async===!0||e.asyncRewake===!0?yield*_(Q(Y(e,i,r,n),t,e.command)):yield*Y(e,i,r,n))});export{nt as collectSettingsGaps,$e as loadSettings,dt as runLifecycleHooks,ct as runPostToolUseHooks,st as runPreToolUseHooks,ut as runSessionStartHooks,lt as runUserPromptSubmitHooks};
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=(e,t)=>{e(e=>{e.setTimeout(()=>{t()},0)});let n=()=>{t().then(({default:e})=>e.dispose())};process.on(`SIGINT`,n),process.on(`SIGTERM`,n)},t=e=>{let t=async e=>{let[t,n]=await Promise.all([import(`./runtime-
|
|
1
|
+
const e=(e,t)=>{e(e=>{e.setTimeout(()=>{t()},0)});let n=()=>{t().then(({default:e})=>e.dispose())};process.on(`SIGINT`,n),process.on(`SIGTERM`,n)},t=e=>{let t=async e=>{let[t,n]=await Promise.all([import(`./runtime-CC04dRZJ.js`).then(e=>e.default),import(`./esm-CeQhljd9.js`)]),{Cause:r,Effect:i,Exit:a}=n,o=e.pipe(i.exit),s=await t.runPromise(o);if(a.isFailure(s))throw r.squash(s.cause);return s.value};e.on(`tool_call`,async(e,n)=>{let{loadSettings:r,runPreToolUseHooks:i}=await import(`./hook-dispatcher.executor-Dz36w3eT.js`),{Effect:a}=await import(`./esm-CeQhljd9.js`);return t(a.gen(function*(){let t=yield*r(n.cwd);if(t)return yield*i(t,e,n)}))}),e.on(`tool_result`,async(e,n)=>{let{loadSettings:r,runPostToolUseHooks:i}=await import(`./hook-dispatcher.executor-Dz36w3eT.js`),{Effect:a}=await import(`./esm-CeQhljd9.js`);return t(a.gen(function*(){let t=yield*r(n.cwd);if(!t)return;let a=yield*i(t,e,n);if(a.block===!0)return{isError:!0,content:[{type:`text`,text:a.reason??`Blocked by PostToolUse hook`}]};if(a.warning!==void 0)return{content:[...e.content,{type:`text`,text:a.warning}],isError:e.isError}}))}),e.on(`input`,async(e,n)=>{let{loadSettings:r,runUserPromptSubmitHooks:i}=await import(`./hook-dispatcher.executor-Dz36w3eT.js`),{Effect:a}=await import(`./esm-CeQhljd9.js`);return t(a.gen(function*(){let t=yield*r(n.cwd);if(t)return yield*i(t,e,n)}))}),e.on(`session_start`,async(e,n)=>{let{collectSettingsGaps:r,loadSettings:i,runSessionStartHooks:a}=await import(`./hook-dispatcher.executor-Dz36w3eT.js`),{Effect:o}=await import(`./esm-CeQhljd9.js`);return t(o.gen(function*(){let e=yield*r(n.cwd);e.unknownEvents.length>0&&n.ui.notify(`Ignoring unsupported hook event(s) in settings.json: ${e.unknownEvents.join(`, `)}`,`warning`),e.unsupportedHookTypes.length>0&&n.ui.notify(`Skipping hook(s) this bridge cannot run yet: type ${e.unsupportedHookTypes.join(`, `)}`,`warning`),e.malformedFiles.length>0&&n.ui.notify(`Hooks are NOT running from malformed settings file(s): ${e.malformedFiles.join(`, `)}`,`error`);let t=yield*i(n.cwd);t&&(yield*a(t,`start`,n))}))}),e.on(`session_compact`,async(e,n)=>{let{loadSettings:r,runSessionStartHooks:i}=await import(`./hook-dispatcher.executor-Dz36w3eT.js`),{Effect:a}=await import(`./esm-CeQhljd9.js`);return t(a.gen(function*(){let e=yield*r(n.cwd);e&&(yield*i(e,`compact`,n))}))}),e.on(`agent_start`,async(e,n)=>{let{loadSettings:r,runSessionStartHooks:i}=await import(`./hook-dispatcher.executor-Dz36w3eT.js`),{Effect:a}=await import(`./esm-CeQhljd9.js`);return t(a.gen(function*(){let e=yield*r(n.cwd);e&&(yield*i(e,`resume`,n))}))}),e.on(`session_shutdown`,async(e,n)=>{let{loadSettings:r,runLifecycleHooks:i}=await import(`./hook-dispatcher.executor-Dz36w3eT.js`),{Effect:a}=await import(`./esm-CeQhljd9.js`);return t(a.gen(function*(){let e=yield*r(n.cwd);e&&(yield*i(e.hooks.SessionEnd,n,`SessionEnd`))}))}),e.on(`session_stop`,async(e,n)=>{let{loadSettings:r,runLifecycleHooks:i}=await import(`./hook-dispatcher.executor-Dz36w3eT.js`),{Effect:a}=await import(`./esm-CeQhljd9.js`);return t(a.gen(function*(){let e=yield*r(n.cwd);e&&(yield*i(e.hooks.Stop,n,`Stop`))}))})},n=e=>{e.on(`before_agent_start`,async(e,t)=>{let n=await import(`./runtime-CC04dRZJ.js`).then(e=>e.default),{loadReferencedContent:r}=await import(`./inject-instructions.executor-DD0xz4GH.js`),{Cause:i,Config:a,Effect:o,Exit:s}=await import(`./esm-CeQhljd9.js`),c=await n.runPromise(o.gen(function*(){let e=yield*a.string(`CLAUDE_PROJECT_DIR`).pipe(a.withDefault(process.cwd()));return yield*r(e)}).pipe(o.exit));if(s.isFailure(c))throw i.squash(c.cause);let l=c.value;if(l!==``)return{systemPrompt:[...e.systemPrompt,``,l]}})};function r(r){t(r),n(r),e(e=>r.on(`session_start`,(t,n)=>e(n)),()=>import(`./runtime-CC04dRZJ.js`))}export{r as default};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{Ct as e,D as t,Dt as n,E as r,Fn as i,G as a,H as o,In as s,Ln as c,O as l,On as u,Pn as d,W as f,bt as p,jn as m,y as h,zt as g}from"./esm-CeQhljd9.js";import{d as _,m as v,t as y}from"./dist-DbemdM50.js";const b=[`AGENTS.md`];var x=class extends l()(`Inject`,{}){},S=class extends l()(`Skip`,{matched:r}){};t({relativePath:r,skipList:h(r)});const C=e=>u(e.skipList.find(t=>t===e.relativePath)),w=e=>a(C(e)).pipe(f(`None`,()=>new x),f(`Some`,e=>new S({matched:e.value})),o),T=n(`extractRefs`)(function*(t,n,r){let i=yield*v,a=yield*_,o=[];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(` `)||a.isAbsolute(l))continue;let u=a.resolve(n,l);if(u.startsWith(r+`/`)||u===r){let t=yield*e(i.exists(u));if(c(t)&&t.right){o.push({sourcePath:n,resolvedPath:u});continue}}let d=a.resolve(r,l);(d.startsWith(r+`/`)||d===r)&&d!==u&&o.push({sourcePath:r,resolvedPath:d})}return o}),E=n(`loadReferencedContent`)(function*(t){let n=yield*v,r=yield*_,l=yield*y,u=[r.resolve(t,`CLAUDE.md`),r.resolve(t,`.claude`,`CLAUDE.md`)],h=[];for(let i of u){let a=yield*e(n.readFileString(i,`utf-8`));if(c(a)){let e=yield*T(a.right,r.dirname(i),t);h.push(...e)}}let x=new Set,S=[];for(let e of h)x.has(e.resolvedPath)||(x.add(e.resolvedPath),S.push(e));let C=(yield*l.load(t).pipe(p(()=>g(void 0))))?.no_inject_refs??b,E=[];for(let r of S){let c=r.resolvedPath.slice(t.length+1);if(m(a(w({relativePath:c,skipList:C})).pipe(f(`Skip`,e=>i(e.matched)),f(`Inject`,()=>d()),o)))continue;let l=yield*e(n.readFileString(r.resolvedPath,`utf-8`));s(l)||E.push(`## ${c}\n${l.right}\n`)}return E.length===0?``:[`# Injected @-references from CLAUDE.md`,`The following files were @-imported by CLAUDE.md and contain project rules.`,``,...E].join(`
|
|
3
|
+
`)});export{E as loadReferencedContent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{At as e,Bt as t,Cn as n,Dn as r,Et as i,Fn as a,Ft as o,Gt as s,Hn as c,Ht as l,It as u,Jt as d,Kt as f,Lt as p,Nn as ee,Nt as te,On as m,Ot as ne,Pn as re,Pt as ie,Rt as ae,St as oe,Tt as h,Un as se,Vt as g,Xt as _,Yt as v,_ as ce,_n as le,at as ue,c as de,cn as y,ct as fe,d as pe,dn as b,dt as me,f as he,fn as ge,ft as x,gt as S,ht as C,i as _e,identity as ve,jt as w,kn as T,ln as ye,lt as E,m as be,on as xe,ot as Se,p as D,pipe as O,pn as Ce,pt as k,q as we,qt as Te,sn as Ee,st as A,t as De,un as Oe,ut as ke,vt as Ae,wt as je,yt as j,zt as M}from"./esm-CeQhljd9.js";import{a as Me,c as N,d as P,i as F,n as Ne,r as Pe,t as Fe}from"./CommandExecutor-WpnYtse1.js";import{C as I,S as Ie,_ as Le,b as Re,f as ze,g as L,h as R,m as z,n as Be,p as Ve,v as He,x as Ue,y as We}from"./dist-DbemdM50.js";import*as Ge from"node:os";import*as Ke from"node:crypto";import*as B from"node:path";import*as V from"node:fs";import*as H from"node:child_process";const U=(e,t,n)=>(...r)=>j(i=>{try{e(...r,(e,n)=>{i(e?h(t?t(e,r):e):M(n))})}catch(e){i(n?h(n(e,r)):oe(e))}}),W=(e,t,n)=>_e(qe(e,t,n)),qe=(e,t,n)=>E(()=>Xe(e(),t,le(void 0),n)),Je=(e,t,{encoding:n,endOnDone:r=!0}={},i=C)=>{let a=Ye(e,n),o=r?j(t=>{`closed`in e&&e.closed?t(C):(e.once(`finish`,()=>t(C)),e.end())}):C;return{awaitRead:()=>C,emit:a,error:e=>_(o,t(e)),done:e=>_(o,i)}},Ye=(e,t)=>n=>n.length===0?C:j(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(C):s?o():e.once(`drain`,o)}o()}),Xe=(e,t,r,i)=>{if(!e.readable)return ke;let a=Te(!1);function o(){a.unsafeOpen()}function s(e){r.current=xe(t(e)),a.unsafeOpen()}function c(){r.current=Ee,a.unsafeOpen()}e.on(`readable`,o),e.on(`error`,s),e.on(`end`,c);let l=i?.chunkSize?Number(i.chunkSize):void 0;return Se(E(function t(){let i=e.read(l);if(i===null)return r.current?fe(r.current):(a.unsafeClose(),A(a.await,t));let o=[i];for(;;){if(i=e.read(l),i===null)return A(me(n(o)),t);o.push(i)}}),g(()=>{e.off(`readable`,o),e.off(`error`,s),e.off(`end`,c),i?.closeOnDone!==!1&&`closed`in e&&!e.closed&&e.destroy()}))},Ze=(e,t,n)=>ce(Qe(e,t,n)),Qe=(e,t,n)=>A(v(g(()=>e()),ge()),([e,r])=>ue($e(e,r,t),Je(e,e=>Oe(r,e),n,ye(r,C)))),$e=(e,n,r)=>t(()=>{function t(e){Ce(n,h(r(e)))}return e.on(`error`,t),je(y(n),g(()=>{e.removeListener(`error`,t)}))}),G=(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 I({reason:i,module:e,method:t,pathOrDescriptor:r,syscall:n.syscall,description:n.message,cause:n})},et=e=>typeof e==`string`?e:`pipe`,K=e=>typeof e==`string`?e:`pipe`,q=e=>e instanceof globalThis.Error?e:new globalThis.Error(String(e)),J=(e,t,n)=>{let r=N(n).reduce((e,t)=>{let n=`${t.command} ${t.args.join(` `)}`;return e.length===0?n:`${e} | ${n}`},``);return G(`Command`,e)(t,[r])},tt={[F]:F,...c,toJSON(){return{_id:`@effect/platform/CommandExecutor/Process`,pid:this.pid}}},Y=n=>r=>{switch(r._tag){case`StandardCommand`:{let a=i(ge(),e=>j(t=>{let n=H.spawn(r.command,r.args,{stdio:[et(r.stdin),K(r.stdout),K(r.stderr)],cwd:T(r.cwd,se),shell:r.shell,env:{...process.env,...Object.fromEntries(r.env)},detached:process.platform!==`win32`});return n.on(`error`,e=>{t(h(J(`spawn`,e,r)))}),n.on(`exit`,(...t)=>{Ce(e,M(t))}),n.on(`spawn`,()=>{t(M([n,e]))}),g(()=>{n.kill(`SIGTERM`)})})),o=process.platform===`win32`?(e,t)=>j(t=>{H.exec(`taskkill /pid ${e.pid} /T /F`,e=>{t(e?h(J(`kill`,q(e),r)):C)})}):(e,t)=>f({try:()=>process.kill(-e.pid,t),catch:e=>J(`kill`,q(e),r)}),s=(e,n)=>t(()=>e.kill(n)?C:h(J(`kill`,new globalThis.Error(`Failed to kill process`),r)));return O(ee(r.cwd,{onNone:()=>C,onSome:e=>n.access(e)}),_(S(a,([t,n])=>i(b(n),r=>r?i(y(n),([n])=>n!==0&&n!==null?o(t,`SIGTERM`).pipe(e):C):o(t,`SIGTERM`).pipe(u(()=>s(t,`SIGTERM`)),_(y(n)),e)))),w(([e,t])=>{let n=be;e.stdin!==null&&(n=Ze(()=>e.stdin,e=>J(`toWritable`,q(e),r)));let a=i(y(t),([e,t])=>e===null?h(J(`exitCode`,new globalThis.Error(`Process interrupted due to receipt of signal: ${t}`),r)):M(Ne(e))),c=ie(b(t)),l=(n=`SIGTERM`)=>o(e,n).pipe(u(()=>s(e,n)),_(Ae(y(t)))),d=Pe(e.pid),f=W(()=>e.stderr,e=>J(`fromReadable(stderr)`,q(e),r)),p=W(()=>e.stdout,e=>J(`fromReadable(stdout)`,q(e),r));return typeof r.stdout!=`string`&&(p=pe(p,r.stdout)),Object.assign(Object.create(tt),{pid:d,exitCode:a,isRunning:c,kill:l,stdin:n,stderr:f,stdout:p})}),typeof r.stdin==`string`?ve:l(e=>ne(de(r.stdin,e.stdin))))}case`PipedCommand`:{let e=N(r);if(e.length===1)return O(e[0],Y(n));let t=e[0],i=e.slice(1),a=i.slice(0,i.length-1),o=i[i.length-1];return O(P(o,a.reduce((e,t)=>O(P(t,e),Y(n),w(e=>e.stdout),D),O(Y(n)(t),w(e=>e.stdout),D))),Y(n))}}},nt=x(Fe,O(z,w(e=>Me(Y(e))))),X=e=>t=>new Ie({module:`FileSystem`,method:e,cause:t}),rt=(()=>{let e=U(V.access,G(`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)}})(),it=(()=>{let e=U(V.cp,G(`FileSystem`,`copy`),X(`copy`));return(t,n,r)=>e(t,n,{force:r?.overwrite??!1,preserveTimestamps:r?.preserveTimestamps??!1,recursive:!0})})(),at=(()=>{let e=U(V.copyFile,G(`FileSystem`,`copyFile`),X(`copyFile`));return(t,n)=>e(t,n)})(),ot=(()=>{let e=U(V.chmod,G(`FileSystem`,`chmod`),X(`chmod`));return(t,n)=>e(t,n)})(),st=(()=>{let e=U(V.chown,G(`FileSystem`,`chown`),X(`chown`));return(t,n,r)=>e(t,n,r)})(),ct=(()=>{let e=U(V.link,G(`FileSystem`,`link`),X(`link`));return(t,n)=>e(t,n)})(),lt=(()=>{let e=U(V.mkdir,G(`FileSystem`,`makeDirectory`),X(`makeDirectory`));return(t,n)=>e(t,{recursive:n?.recursive??!1,mode:n?.mode})})(),Z=e=>{let n=U(V.mkdtemp,G(`FileSystem`,e),X(e));return e=>t(()=>{let t=e?.prefix??``,r=typeof e?.directory==`string`?B.join(e.directory,`.`):Ge.tmpdir();return n(t?B.join(r,t):r+`/`)})},ut=Z(`makeTempDirectory`),Q=e=>{let t=U(V.rm,G(`FileSystem`,e),X(e));return(e,n)=>t(e,{recursive:n?.recursive??!1,force:n?.force??!1})},dt=Q(`remove`),ft=(()=>{let e=Z(`makeTempDirectoryScoped`),t=Q(`makeTempDirectoryScoped`);return n=>S(e(n),e=>o(t(e,{recursive:!0})))})(),pt=e=>{let t=U(V.open,G(`FileSystem`,e),X(e)),n=U(V.close,G(`FileSystem`,e),X(e));return(e,r)=>O(S(t(e,r?.flag??`r`,r?.mode),e=>o(n(e))),w(e=>ht(Ve(e),r?.flag?.startsWith(`a`)??!1)))},mt=pt(`open`),ht=(()=>{let e=e=>U(V.read,G(`FileSystem`,e),X(e)),n=e(`read`),r=e(`readAlloc`),o=U(V.fstat,G(`FileSystem`,`stat`),X(`stat`)),s=U(V.ftruncate,G(`FileSystem`,`truncate`),X(`truncate`)),c=U(V.fsync,G(`FileSystem`,`sync`),X(`sync`)),l=e=>U(V.write,G(`FileSystem`,e),X(e)),u=l(`write`),f=l(`writeAll`);class p{fd;append;[R];semaphore=d(1);position=0n;constructor(e,t){this.fd=e,this.append=t,this[R]=R}get stat(){return w(o(this.fd),wt)}get sync(){return c(this.fd)}seek(e,t){let n=L(e);return this.semaphore.withPermits(1)(g(()=>(t===`start`?this.position=n:t===`current`&&(this.position+=n),this.position)))}read(e){return this.semaphore.withPermits(1)(w(t(()=>n(this.fd,{buffer:e,position:this.position})),e=>{let t=L(e);return this.position+=t,t}))}readAlloc(e){let t=Number(e);return this.semaphore.withPermits(1)(i(g(()=>Buffer.allocUnsafeSlow(t)),e=>w(r(this.fd,{buffer:e,position:this.position}),n=>{if(n===0)return re();if(this.position+=BigInt(n),n===t)return a(e);let r=Buffer.allocUnsafeSlow(n);return e.copy(r,0,0,n),a(r)})))}truncate(e){return this.semaphore.withPermits(1)(w(s(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)(w(t(()=>u(this.fd,e,void 0,void 0,this.append?void 0:Number(this.position))),e=>{let t=L(e);return this.append||(this.position+=t),t}))}writeAllChunk(e){return i(t(()=>f(this.fd,e,void 0,void 0,this.append?void 0:Number(this.position))),t=>t===0?h(new I({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)):C))}writeAll(e){return this.semaphore.withPermits(1)(this.writeAllChunk(e))}}return(e,t)=>new p(e,t)})(),gt=e=>{let t=Z(e),n=pt(e),r=e=>g(()=>Ke.randomBytes(e).toString(`hex`));return e=>O(v(t(e),r(6)),w(([t,n])=>B.join(t,n+(e?.suffix??``))),l(e=>p(n(e,{flag:`w+`}))))},_t=gt(`makeTempFile`),vt=(()=>{let e=gt(`makeTempFileScoped`),t=Q(`makeTempFileScoped`);return n=>S(e(n),e=>o(t(B.dirname(e),{recursive:!0})))})(),yt=(e,t)=>s({try:()=>V.promises.readdir(e,t),catch:t=>G(`FileSystem`,`readDirectory`)(t,[e])}),bt=e=>j((t,n)=>{try{V.readFile(e,{signal:n},(n,r)=>{t(n?h(G(`FileSystem`,`readFile`)(n,[e])):M(r))})}catch(e){t(h(X(`readFile`)(e)))}}),xt=(()=>{let e=U(V.readlink,G(`FileSystem`,`readLink`),X(`readLink`));return t=>e(t)})(),St=(()=>{let e=U(V.realpath,G(`FileSystem`,`realPath`),X(`realPath`));return t=>e(t)})(),Ct=(()=>{let e=U(V.rename,G(`FileSystem`,`rename`),X(`rename`));return(t,n)=>e(t,n)})(),wt=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:m(e.mtime),atime:m(e.atime),birthtime:m(e.birthtime),dev:e.dev,rdev:m(e.rdev),ino:m(e.ino),mode:e.mode,nlink:m(e.nlink),uid:m(e.uid),gid:m(e.gid),size:L(e.size),blksize:m(L(e.blksize)),blocks:m(e.blocks)}),$=(()=>{let e=U(V.stat,G(`FileSystem`,`stat`),X(`stat`));return t=>w(e(t),wt)})(),Tt=(()=>{let e=U(V.symlink,G(`FileSystem`,`symlink`),X(`symlink`));return(t,n)=>e(t,n)})(),Et=(()=>{let e=U(V.truncate,G(`FileSystem`,`truncate`),X(`truncate`));return(t,n)=>e(t,n===void 0?void 0:Number(n))})(),Dt=(()=>{let e=U(V.utimes,G(`FileSystem`,`utime`),X(`utime`));return(t,n,r)=>e(t,n,r)})(),Ot=(e,t)=>De(n=>S(g(()=>{let r=V.watch(e,{recursive:t?.recursive},(e,t)=>{if(t)switch(e){case`rename`:n.fromEffect(te($(t),{onSuccess:e=>M(He({path:t})),onFailure:e=>e._tag===`SystemError`&&e.reason===`NotFound`?M(We({path:t})):h(e)}));return;case`change`:n.single(Re({path:t}));return}});return r.on(`error`,t=>{n.fail(new I({module:`FileSystem`,reason:`Unknown`,method:`watch`,pathOrDescriptor:e,cause:t}))}),r.on(`close`,()=>{n.end()}),r}),e=>g(()=>e.close()))),kt=(e,t,n)=>$(t).pipe(w(i=>e.pipe(r(e=>e.register(t,i,n)),T(()=>Ot(t,n)))),he),At=(e,t,n)=>j((r,i)=>{try{V.writeFile(e,t,{signal:i,flag:n?.flag,mode:n?.mode},t=>{r(t?h(G(`FileSystem`,`writeFile`)(t,[e])):C)})}catch(e){r(h(X(`writeFile`)(e)))}}),jt=x(z,w(ae(Le),e=>Ue({access:rt,chmod:ot,chown:st,copy:it,copyFile:at,link:ct,makeDirectory:lt,makeTempDirectory:ut,makeTempDirectoryScoped:ft,makeTempFile:_t,makeTempFileScoped:vt,open:mt,readDirectory:yt,readFile:bt,readLink:xt,realPath:St,remove:dt,rename:Ct,stat:$,symlink:Tt,truncate:Et,utimes:Dt,watch(t,n){return kt(e,t,n)},writeFile:At}))),Mt=nt.pipe(k(jt),k(ze)),Nt=we(Be.pipe(k(Mt)));export{Nt as default};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@systemfsoftware/omp-claude-compat",
|
|
3
3
|
"license": "MIT",
|
|
4
|
-
"version": "1.2.
|
|
4
|
+
"version": "1.2.3",
|
|
5
5
|
"author": "Ryan Lee <drdgvhbh@gmail.com>",
|
|
6
6
|
"description": "OMP Claude Code compatibility: dispatch .claude/settings.json hooks + inject CLAUDE.md @-references",
|
|
7
7
|
"type": "module",
|
|
@@ -31,10 +31,10 @@
|
|
|
31
31
|
"typescript": "^7",
|
|
32
32
|
"vitest": "^4",
|
|
33
33
|
"@systemfsoftware/effect-gherkin-spec": "^0.4.0",
|
|
34
|
-
"@systemfsoftware/effect-memfs": "^1.0.
|
|
34
|
+
"@systemfsoftware/effect-memfs": "^1.0.8",
|
|
35
35
|
"@systemfsoftware/omp-utils": "^0.0.0",
|
|
36
|
-
"@systemfsoftware/
|
|
37
|
-
"@systemfsoftware/
|
|
36
|
+
"@systemfsoftware/tsconfig": "^1.2.6",
|
|
37
|
+
"@systemfsoftware/oxlint-config": "^0.1.0"
|
|
38
38
|
},
|
|
39
39
|
"omp": {
|
|
40
40
|
"extensions": [
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{An as e,Cn as t,Nn as n,Sn as r,a as i,an as a,c as o,cn as s,dn as c,fn as l,gn as u,h as d,in as f,jn as p,kt as m,l as h,ln as g,mn as _,o as v,on as y,p as b,pipe as x,u as S,un as C,wt as w,yt as T}from"./esm-DxC3o46t.js";const E=Symbol.for(`@effect/platform/CommandExecutor`),D=Symbol.for(`@effect/platform/Process`),O=u(),k=u(),A=_(`@effect/platform/CommandExecutor`),j=e=>{let t=t=>b(w(e(t),e=>e.stdout)),n=(e,n)=>{let r=new TextDecoder(n);return S(v(t(e),g(e=>r.decode(e))))};return{[E]:E,start:e,exitCode:t=>m(T(e(t),e=>e.exitCode)),stream:t,string:(t,n=`utf-8`)=>{let r=new TextDecoder(n);return x(e(t),T(e=>o(e.stdout,M)),w(e=>r.decode(e)),m)},lines:(e,t=`utf-8`)=>x(n(e,t),h,w(l)),streamLines:n}},M=d(new Uint8Array,(e,t)=>c(t,e,(e,t)=>{let n=new Uint8Array(e.length+t.length);return n.set(e),n.set(t,e.length),n})),N=Symbol.for(`@effect/platform/Command`),P=n(2,(e,t)=>{switch(e._tag){case`StandardCommand`:return z({...e,env:y(e.env,a(Object.entries(t).filter(([e])=>e!==void 0)))});case`PipedCommand`:return U(P(e.left,t),P(e.right,t))}}),F=n(2,(e,t)=>G(e,i(C(new TextEncoder().encode(t))))),I=e=>Array.from(L(e)),L=e=>{switch(e._tag){case`StandardCommand`:return C(e);case`PipedCommand`:return s(L(e.left),L(e.right))}},R={[N]:N,pipe(){return e(this,arguments)},...p},ee={...R,_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()}}},z=e=>Object.assign(Object.create(ee),e),B={...R,_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(B),e),H=(e,...t)=>z({command:e,args:t,env:f(),cwd:r(),shell:!1,stdin:`pipe`,stdout:`pipe`,stderr:`pipe`,gid:r(),uid:r()}),U=n(2,(e,t)=>V({left:e,right:t})),W=n(2,(e,t)=>{switch(e._tag){case`StandardCommand`:return z({...e,stderr:t});case`PipedCommand`:return V({...e,right:W(e.right,t)})}}),G=n(2,(e,t)=>{switch(e._tag){case`StandardCommand`:return z({...e,stdin:t});case`PipedCommand`:return V({...e,left:G(e.left,t)})}}),K=n(2,(e,t)=>{switch(e._tag){case`StandardCommand`:return z({...e,stdout:t});case`PipedCommand`:return V({...e,right:K(e.right,t)})}}),q=n(2,(e,n)=>{switch(e._tag){case`StandardCommand`:return z({...e,cwd:t(n)});case`PipedCommand`:return U(q(e.left,n),q(e.right,n))}}),J=P,Y=F,X=I,Z=H,Q=W,$=G,te=K,ne=q,re=A,ie=D,ae=O,oe=k,se=j;export{se as a,X as c,$ as d,te as f,ie as i,Z as l,ae as n,J as o,ne as p,oe as r,Y as s,re as t,Q as u};
|
package/dist/dist-DQtXO3Ic.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import{C as e,G as t,Gt as n,It as r,J as i,Jt as a,K as o,Kt as s,L as c,M as l,O as u,P as d,Pt as ee,R as te,Rt as ne,S as re,St as ie,T as f,Ut as p,Wt as ae,X as oe,Y as se,Yt as ce,Z as le,at as ue,bn as de,bt as fe,et as m,g as pe,gn as me,hn as h,i as he,identity as g,it as ge,j as _e,jt as _,k as ve,mn as ye,mt as be,n as xe,p as Se,pipe as v,pt as Ce,q as we,qt as Te,rt as Ee,st as De,un as Oe,ut as ke,v as Ae,vt as y,w as je,wt as b,x,xn as Me,y as Ne,yt as S}from"./esm-DxC3o46t.js";const C=Symbol.for(`@effect/platform/Error`),w=re(`Clipboard`,`Command`,`FileSystem`,`KeyValueStore`,`Path`,`Stream`,`Terminal`);var T=class extends u(`@effect/platform/Error/BadArgument`)(`BadArgument`,{module:w,method:f,description:d(f),cause:d(x)}){[C]=C;get message(){return`${this.module}.${this.method}${this.description?`: ${this.description}`:``}`}};const Pe=re(`AlreadyExists`,`BadResource`,`Busy`,`InvalidData`,`NotFound`,`PermissionDenied`,`TimedOut`,`UnexpectedEof`,`Unknown`,`WouldBlock`,`WriteZero`);var Fe=class extends u(`@effect/platform/Error/SystemError`)(`SystemError`,{reason:Pe,module:w,method:f,description:d(f),syscall:d(f),pathOrDescriptor:d(ve(f,e)),cause:d(x)}){[C]=C;get message(){return`${this.reason}: ${this.module}.${this.method}${this.pathOrDescriptor===void 0?``:` (${this.pathOrDescriptor})`}${this.description?`: ${this.description}`:``}`}};const Ie=ye(`@effect/platform/FileSystem`),E=e=>typeof e==`bigint`?e:BigInt(e),D=BigInt(1024);D*D*D*D*D;const Le=e=>Ie.of({...e,exists:t=>v(e.access(t),ke(!0),be(`SystemError`,e=>e.reason===`NotFound`?_(!1):y(e))),readFileString:(t,n)=>r(e.readFile(t),{try:e=>new TextDecoder(n).decode(e),catch:e=>new T({module:`FileSystem`,method:`readFileString`,description:`invalid encoding`,cause:e})}),stream:(t,n)=>v(e.open(t,{flag:`r`}),n?.offset?ee(e=>e.seek(n.offset,`start`)):g,b(e=>Re(e,n)),Se),sink:(t,n)=>v(e.open(t,{flag:`w`,...n}),b(e=>pe(t=>e.writeAll(t))),Ae),writeFileString:(t,n,r)=>S(ne({try:()=>new TextEncoder().encode(n),catch:e=>new T({module:`FileSystem`,method:`writeFileString`,description:`could not encode string`,cause:e})}),n=>e.writeFile(t,n,r))}),Re=(e,{bufferSize:t=16,bytesToRead:n,chunkSize:r=E(64*1024)}={})=>{let i=n===void 0?void 0:E(n),a=E(r);function o(t){if(i!==void 0&&i<=t)return Ee;let n=i!==void 0&&i-t<a?i-t:a;return m(e.readAlloc(n),Me({onNone:()=>Ee,onSome:e=>m(ge(Oe(e)),n=>o(t+BigInt(e.length)))}))}return xe(he(o(BigInt(0))),{capacity:t})},ze=E,Be=Ie,Ve=Le,He=Symbol.for(`@effect/platform/FileSystem/File`),Ue=me(),We=p(`Create`),Ge=p(`Update`),Ke=p(`Remove`);var qe=class extends h(`@effect/platform/FileSystem/WatchBackend`)(){};const Je=Symbol.for(`@effect/platform/Path`),O=ye(`@effect/platform/Path`);function Ye(e,t){let n=``,r=0,i=-1,a=0,o;for(let s=0;s<=e.length;++s){if(s<e.length)o=e.charCodeAt(s);else if(o===47)break;else o=47;if(o===47){if(i!==s-1&&a!==1)if(i!==s-1&&a===2){if(n.length<2||r!==2||n.charCodeAt(n.length-1)!==46||n.charCodeAt(n.length-2)!==46){if(n.length>2){let e=n.lastIndexOf(`/`);if(e!==n.length-1){e===-1?(n=``,r=0):(n=n.slice(0,e),r=n.length-1-n.lastIndexOf(`/`)),i=s,a=0;continue}}else if(n.length===2||n.length===1){n=``,r=0,i=s,a=0;continue}}t&&(n.length>0?n+=`/..`:n=`..`,r=2)}else n.length>0?n+=`/`+e.slice(i+1,s):n=e.slice(i+1,s),r=s-i-1;i=s,a=0}else o===46&&a!==-1?++a:a=-1}return n}function Xe(e,t){let n=t.dir||t.root,r=t.base||(t.name||``)+(t.ext||``);return n?n===t.root?n+r:n+e+r:r}function Ze(e){if(e.protocol!==`file:`)return y(new T({module:`Path`,method:`fromFileUrl`,description:`URL must be of scheme file`}));if(e.hostname!==``)return y(new T({module:`Path`,method:`fromFileUrl`,description:`Invalid file URL host`}));let t=e.pathname;for(let e=0;e<t.length;e++)if(t[e]===`%`){let n=t.codePointAt(e+2)|32;if(t[e+1]===`2`&&n===102)return y(new T({module:`Path`,method:`fromFileUrl`,description:`must not include encoded / characters`}))}return _(decodeURIComponent(t))}const Qe=function(){let e=``,t=!1,n;for(let r=arguments.length-1;r>=-1&&!t;r--){let i;if(r>=0)i=arguments[r];else{let e=globalThis.process;n===void 0&&`process`in globalThis&&typeof e==`object`&&e&&typeof e.cwd==`function`&&(n=e.cwd()),i=n}i.length!==0&&(e=i+`/`+e,t=i.charCodeAt(0)===47)}return e=Ye(e,!t),t?e.length>0?`/`+e:`/`:e.length>0?e:`.`};function $e(e){let t=new URL(`file://`),n=Qe(e);return e.charCodeAt(e.length-1)===47&&n[n.length-1]!==`/`&&(n+=`/`),t.pathname=at(n),_(t)}const et=/%/g,tt=/\\/g,nt=/\n/g,rt=/\r/g,it=/\t/g;function at(e){return e.includes(`%`)&&(e=e.replace(et,`%25`)),e.includes(`\\`)&&(e=e.replace(tt,`%5C`)),e.includes(`
|
|
2
|
-
`)&&(e=e.replace(nt,`%0A`)),e.includes(`\r`)&&(e=e.replace(rt,`%0D`)),e.includes(` `)&&(e=e.replace(it,`%09`)),e}const k=O.of({[Je]:Je,resolve:Qe,normalize(e){if(e.length===0)return`.`;let t=e.charCodeAt(0)===47,n=e.charCodeAt(e.length-1)===47;return e=Ye(e,!t),e.length===0&&!t&&(e=`.`),e.length>0&&n&&(e+=`/`),t?`/`+e:e},isAbsolute(e){return e.length>0&&e.charCodeAt(0)===47},join(){if(arguments.length===0)return`.`;let e;for(let t=0;t<arguments.length;++t){let n=arguments[t];n.length>0&&(e===void 0?e=n:e+=`/`+n)}return e===void 0?`.`:k.normalize(e)},relative(e,t){if(e===t||(e=k.resolve(e),t=k.resolve(t),e===t))return``;let n=1;for(;n<e.length&&e.charCodeAt(n)===47;++n);let r=e.length,i=r-n,a=1;for(;a<t.length&&t.charCodeAt(a)===47;++a);let o=t.length-a,s=i<o?i:o,c=-1,l=0;for(;l<=s;++l){if(l===s){if(o>s){if(t.charCodeAt(a+l)===47)return t.slice(a+l+1);if(l===0)return t.slice(a+l)}else i>s&&(e.charCodeAt(n+l)===47?c=l:l===0&&(c=0));break}let r=e.charCodeAt(n+l);if(r!==t.charCodeAt(a+l))break;r===47&&(c=l)}let u=``;for(l=n+c+1;l<=r;++l)(l===r||e.charCodeAt(l)===47)&&(u.length===0?u+=`..`:u+=`/..`);return u.length>0?u+t.slice(a+c):(a+=c,t.charCodeAt(a)===47&&++a,t.slice(a))},dirname(e){if(e.length===0)return`.`;let t=e.charCodeAt(0),n=t===47,r=-1,i=!0;for(let n=e.length-1;n>=1;--n)if(t=e.charCodeAt(n),t===47){if(!i){r=n;break}}else i=!1;return r===-1?n?`/`:`.`:n&&r===1?`//`:e.slice(0,r)},basename(e,t){let n=0,r=-1,i=!0,a;if(t!==void 0&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return``;let o=t.length-1,s=-1;for(a=e.length-1;a>=0;--a){let c=e.charCodeAt(a);if(c===47){if(!i){n=a+1;break}}else s===-1&&(i=!1,s=a+1),o>=0&&(c===t.charCodeAt(o)?--o===-1&&(r=a):(o=-1,r=s))}return n===r?r=s:r===-1&&(r=e.length),e.slice(n,r)}else{for(a=e.length-1;a>=0;--a)if(e.charCodeAt(a)===47){if(!i){n=a+1;break}}else r===-1&&(i=!1,r=a+1);return r===-1?``:e.slice(n,r)}},extname(e){let t=-1,n=0,r=-1,i=!0,a=0;for(let o=e.length-1;o>=0;--o){let s=e.charCodeAt(o);if(s===47){if(!i){n=o+1;break}continue}r===-1&&(i=!1,r=o+1),s===46?t===-1?t=o:a!==1&&(a=1):t!==-1&&(a=-1)}return t===-1||r===-1||a===0||a===1&&t===r-1&&t===n+1?``:e.slice(t,r)},format:function(e){if(typeof e!=`object`||!e)throw TypeError(`The "pathObject" argument must be of type Object. Received type `+typeof e);return Xe(`/`,e)},parse(e){let t={root:``,dir:``,base:``,ext:``,name:``};if(e.length===0)return t;let n=e.charCodeAt(0),r=n===47,i;r?(t.root=`/`,i=1):i=0;let a=-1,o=0,s=-1,c=!0,l=e.length-1,u=0;for(;l>=i;--l){if(n=e.charCodeAt(l),n===47){if(!c){o=l+1;break}continue}s===-1&&(c=!1,s=l+1),n===46?a===-1?a=l:u!==1&&(u=1):a!==-1&&(u=-1)}return a===-1||s===-1||u===0||u===1&&a===s-1&&a===o+1?s!==-1&&(o===0&&r?t.base=t.name=e.slice(1,s):t.base=t.name=e.slice(o,s)):(o===0&&r?(t.name=e.slice(1,a),t.base=e.slice(1,s)):(t.name=e.slice(o,a),t.base=e.slice(o,s)),t.ext=e.slice(a,s)),o>0?t.dir=e.slice(0,o-1):r&&(t.dir=`/`),t},sep:`/`,fromFileUrl:Ze,toFileUrl:$e,toNamespacedPath:g}),ot=De(O,k),A=O,st=ot,ct={arrays:`merge`,sets:`merge`,maps:`merge`};function j(e,t,n){return M(e,t,new Set,n??ct)}function M(e,t,n,r){let i={},a=new Set([...I(e),...I(t)]);for(let o of a){if(o===`__proto__`)continue;let a=e[o];if(!Object.hasOwn(t,o)){i[o]=a;continue}let s=t[o];if(F(a)&&F(s)&&!n.has(a)&&!n.has(s)){n.add(a),n.add(s),i[o]=lt(a,s,n,r);continue}i[o]=s}return i}function lt(e,t,n,r){if(N(e)&&N(t))return M(e,t,n,r);if(P(e)&&P(t)){if(Array.isArray(e)&&Array.isArray(t))return r.arrays===`merge`?e.concat(t):t;if(e instanceof Map&&t instanceof Map){if(r.maps===`merge`){let n=new Map(e);for(let[e,r]of t)n.set(e,r);return n}return t}if(e instanceof Set&&t instanceof Set){if(r.sets===`merge`){let n=new Set(e);for(let e of t)n.add(e);return n}return t}}return t}function N(e){return Object.getPrototypeOf(e)===Object.prototype}function P(e){return typeof e[Symbol.iterator]==`function`}function F(e){return typeof e==`object`&&!!e}function I(e){let t=Object.keys(e),n=Object.getOwnPropertySymbols(e);if(n.length===0)return t;for(let r of n)Object.prototype.propertyIsEnumerable.call(e,r)&&t.push(r);return t}function ut(e){return e%4==0&&e%100!=0||e%400==0}var dt=class{#e=/[ \t]/;#t=0;#n;constructor(e){this.#n=e}get position(){return this.#t}get source(){return this.#n}char(e=0){return this.#n[this.#t+e]??``}slice(e,t){return this.#n.slice(this.#t+e,this.#t+t)}next(e=1){this.#t+=e}skipWhitespaces(){for(;this.#e.test(this.char())&&!this.eof();)this.next();if(!this.isCurrentCharEOL()&&/\s/.test(this.char())){let e=`\\u`+this.char().charCodeAt(0).toString(16),t=this.#t;throw SyntaxError(`Cannot parse the TOML: It contains invalid whitespace at position '${t}': \`${e}\``)}}nextUntilChar(e={skipComments:!0}){for(;!this.eof();){let t=this.char();if(this.#e.test(t)||this.isCurrentCharEOL())this.next();else if(e.skipComments&&this.char()===`#`)for(;!this.isCurrentCharEOL()&&!this.eof();)this.next();else break}}eof(){return this.#t>=this.#n.length}isCurrentCharEOL(){return this.char()===`
|
|
3
|
-
`||this.startsWith(`\r
|
|
4
|
-
`)}startsWith(e){return this.#n.startsWith(e,this.#t)}match(e){if(!e.sticky)throw Error(`RegExp ${e} does not have a sticky 'y' flag`);return e.lastIndex=this.#t,this.#n.match(e)}};function L(e){return{ok:!0,body:e}}function R(){return{ok:!1}}function z(e,t={__proto__:null}){return e.reduceRight((e,t)=>({[t]:e}),t)}function B(e){return typeof e==`object`&&!!e}function V(e,t){let n=t[0];if(!n)throw Error(`Cannot parse the TOML: key length is not a positive number`);return e[n]}function ft(e,t){let{keys:n,type:r,value:i}=t,a=V(e,n);if(a===void 0)return Object.assign(e,z(n,i));if(Array.isArray(a))return H(a.at(-1),{type:r,keys:n.slice(1),value:i}),e;if(B(a))return H(a,{type:r,keys:n.slice(1),value:i}),e;throw Error(`Unexpected assign`)}function pt(e,t){let{type:n,keys:r,value:i}=t,a=V(e,r);if(a===void 0)return Object.assign(e,z(r,[i]));if(Array.isArray(a))return t.keys.length===1?a.push(i):H(a.at(-1),{type:t.type,keys:t.keys.slice(1),value:t.value}),e;if(B(a))return H(a,{type:n,keys:r.slice(1),value:i}),e;throw Error(`Unexpected assign`)}function H(e,t){switch(t.type){case`Block`:return j(e,t.value);case`Table`:return ft(e,t);case`TableArray`:return pt(e,t)}}function U(e){return t=>{for(let n of e){let e=n(t);if(e.ok)return e}return R()}}function mt(e,t){let n=K(t);return r=>{let i=[],a=e(r);if(!a.ok)return L(i);for(i.push(a.body);!r.eof()&&n(r).ok;){let n=e(r);if(!n.ok)throw SyntaxError(`Invalid token after "${t}"`);i.push(n.body)}return L(i)}}function ht(e,t){let n=K(t);return r=>{let i=e(r);if(!i.ok)return R();let a=[i.body];for(;!r.eof()&&n(r).ok;){let n=e(r);if(!n.ok)throw SyntaxError(`Invalid token after "${t}"`);a.push(n.body)}return L(a)}}function gt(e,t,n){let r=K(t);return i=>{let a=i.position,o=e(i);if(!o.ok)return R();if(!r(i).ok)throw SyntaxError(`key/value pair doesn't have "${t}"`);let s=n(i);if(!s.ok){let e=i.source.indexOf(`
|
|
5
|
-
`,i.position),t=e>0?e:i.source.length,n=i.source.slice(a,t);throw SyntaxError(`Cannot parse value on line '${n}'`)}return L(z(o.body,s.body))}}function _t(e){return t=>{let n=e(t);if(!n.ok)return R();let r={__proto__:null};for(let e of n.body)typeof e==`object`&&e&&(r=j(r,e));return L(r)}}function W(e){return t=>{let n=[];for(;!t.eof();){let r=e(t);if(!r.ok)break;n.push(r.body),t.nextUntilChar()}return n.length===0?R():L(n)}}function G(e,t,n){let r=K(e),i=K(n);return a=>{if(!r(a).ok)return R();let o=t(a);if(!o.ok)throw SyntaxError(`Invalid token after "${e}"`);if(!i(a).ok)throw SyntaxError(`Not closed by "${n}" after started with "${e}"`);return L(o.body)}}function K(e){return t=>(t.skipWhitespaces(),t.startsWith(e)?(t.next(e.length),t.skipWhitespaces(),L(void 0)):R())}const vt=/[A-Za-z0-9_-]+/y;function yt(e){e.skipWhitespaces();let t=e.match(vt)?.[0];return t?(e.next(t.length),L(t)):R()}function bt(e){if(e.char()!==`\\`)return R();switch(e.next(),e.char()){case`b`:return e.next(),L(`\b`);case`t`:return e.next(),L(` `);case`n`:return e.next(),L(`
|
|
6
|
-
`);case`f`:return e.next(),L(`\f`);case`r`:return e.next(),L(`\r`);case`u`:case`U`:{let t=e.char()===`u`?4:6,n=parseInt(`0x`+e.slice(1,1+t),16),r=String.fromCodePoint(n);return e.next(t+1),L(r)}case`"`:return e.next(),L(`"`);case`\\`:return e.next(),L(`\\`);default:throw SyntaxError(`Invalid escape sequence: \\${e.char()}`)}}function xt(e){if(e.skipWhitespaces(),e.char()!==`"`)return R();e.next();let t=[];for(;e.char()!==`"`&&!e.eof();){if(e.char()===`
|
|
7
|
-
`)throw SyntaxError(`Single-line string cannot contain EOL`);let n=bt(e);n.ok?t.push(n.body):(t.push(e.char()),e.next())}if(e.eof())throw SyntaxError(`Single-line string is not closed:\n${t.join(``)}`);return e.next(),L(t.join(``))}function St(e){if(e.skipWhitespaces(),e.char()!==`'`)return R();e.next();let t=[];for(;e.char()!==`'`&&!e.eof();){if(e.char()===`
|
|
8
|
-
`)throw SyntaxError(`Single-line string cannot contain EOL`);t.push(e.char()),e.next()}if(e.eof())throw SyntaxError(`Single-line string is not closed:\n${t.join(``)}`);return e.next(),L(t.join(``))}function Ct(e){if(e.skipWhitespaces(),!e.startsWith(`"""`))return R();e.next(3),e.char()===`
|
|
9
|
-
`?e.next():e.startsWith(`\r
|
|
10
|
-
`)&&e.next(2);let t=[];for(;!e.startsWith(`"""`)&&!e.eof();){if(e.startsWith(`\\
|
|
11
|
-
`)){e.next(),e.nextUntilChar({skipComments:!1});continue}else if(e.startsWith(`\\\r
|
|
12
|
-
`)){e.next(),e.nextUntilChar({skipComments:!1});continue}let n=bt(e);n.ok?t.push(n.body):(t.push(e.char()),e.next())}if(e.eof())throw SyntaxError(`Multi-line string is not closed:\n${t.join(``)}`);return e.char(3)===`"`&&(t.push(`"`),e.next()),e.next(3),L(t.join(``))}function wt(e){if(e.skipWhitespaces(),!e.startsWith(`'''`))return R();e.next(3),e.char()===`
|
|
13
|
-
`?e.next():e.startsWith(`\r
|
|
14
|
-
`)&&e.next(2);let t=[];for(;!e.startsWith(`'''`)&&!e.eof();)t.push(e.char()),e.next();if(e.eof())throw SyntaxError(`Multi-line string is not closed:\n${t.join(``)}`);return e.char(3)===`'`&&(t.push(`'`),e.next()),e.next(3),L(t.join(``))}const Tt=/(?:true|false)\b/y;function Et(e){e.skipWhitespaces();let t=e.match(Tt);if(!t)return R();let n=t[0];return e.next(n.length),L(n===`true`)}const Dt=new Map([[`inf`,1/0],[`+inf`,1/0],[`-inf`,-1/0]]),Ot=/[+-]?inf\b/y;function kt(e){e.skipWhitespaces();let t=e.match(Ot);if(!t)return R();let n=t[0];return e.next(n.length),L(Dt.get(n))}const At=/[+-]?nan\b/y;function jt(e){e.skipWhitespaces();let t=e.match(At);if(!t)return R();let n=t[0];return e.next(n.length),L(NaN)}const q=ht(U([yt,xt,St]),`.`),Mt=/0b[01]+(?:_[01]+)*\b/y;function Nt(e){e.skipWhitespaces();let t=e.match(Mt)?.[0];if(!t)return R();e.next(t.length);let n=t.slice(2).replaceAll(`_`,``),r=parseInt(n,2);return isNaN(r)?R():L(r)}const Pt=/0o[0-7]+(?:_[0-7]+)*\b/y;function Ft(e){e.skipWhitespaces();let t=e.match(Pt)?.[0];if(!t)return R();e.next(t.length);let n=t.slice(2).replaceAll(`_`,``),r=parseInt(n,8);return isNaN(r)?R():L(r)}const It=/0x[0-9a-f]+(?:_[0-9a-f]+)*\b/iy;function Lt(e){e.skipWhitespaces();let t=e.match(It)?.[0];if(!t)return R();e.next(t.length);let n=t.slice(2).replaceAll(`_`,``),r=parseInt(n,16);return isNaN(r)?R():L(r)}const Rt=/[+-]?(?:0|[1-9][0-9]*(?:_[0-9]+)*)\b/y;function zt(e){e.skipWhitespaces();let t=e.match(Rt)?.[0];if(!t)return R();e.next(t.length);let n=t.replaceAll(`_`,``);return L(parseInt(n,10))}const Bt=/[+-]?(?:0|[1-9][0-9]*(?:_[0-9]+)*)(?:\.[0-9]+(?:_[0-9]+)*)?(?:e[+-]?[0-9]+(?:_[0-9]+)*)?\b/iy;function Vt(e){e.skipWhitespaces();let t=e.match(Bt)?.[0];if(!t)return R();e.next(t.length);let n=t.replaceAll(`_`,``),r=parseFloat(n);return isNaN(r)?R():L(r)}const Ht=/(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})(?:[ 0-9TZ.:+-]+)?\b/y;function Ut(e){e.skipWhitespaces();let t=e.match(Ht);if(!t)return R();let n=t[0];e.next(n.length);let r=t.groups;if(r.month==`02`){let e=parseInt(r.day);if(e>29)throw SyntaxError(`Invalid date string "${t}"`);let n=parseInt(r.year);if(e>28&&!ut(n))throw SyntaxError(`Invalid date string "${t}"`)}let i=new Date(n.trim());if(isNaN(i.getTime()))throw SyntaxError(`Invalid date string "${t}"`);return L(i)}const Wt=/(\d{2}):(\d{2}):(\d{2})(?:\.[0-9]+)?\b/y;function Gt(e){e.skipWhitespaces();let t=e.match(Wt)?.[0];return t?(e.next(t.length),L(t)):R()}function Kt(e){if(e.skipWhitespaces(),e.char()!==`[`)return R();e.next();let t=[];for(;!e.eof();){e.nextUntilChar();let n=Jt(e);if(!n.ok||(t.push(n.body),e.skipWhitespaces(),e.char()!==`,`))break;e.next()}if(e.nextUntilChar(),e.char()!==`]`)throw SyntaxError(`Array is not closed`);return e.next(),L(t)}function qt(e){if(e.nextUntilChar(),e.char(1)===`}`)return e.next(2),L({__proto__:null});let t=G(`{`,mt(J,`,`),`}`)(e);if(!t.ok)return R();let n={__proto__:null};for(let e of t.body)n=j(n,e);return L(n)}const Jt=U([Ct,wt,xt,St,Et,kt,jt,Ut,Gt,Nt,Ft,Lt,Vt,zt,Kt,qt]),J=gt(q,`=`,Jt);function Y(e){e.nextUntilChar();let t=_t(W(J))(e);return t.ok?L({type:`Block`,value:t.body}):R()}const Yt=G(`[`,q,`]`);function Xt(e){e.nextUntilChar();let t=Yt(e);if(!t.ok)return R();e.nextUntilChar();let n=Y(e);return L({type:`Table`,keys:t.body,value:n.ok?n.body.value:{__proto__:null}})}const Zt=G(`[[`,q,`]]`);function Qt(e){e.nextUntilChar();let t=Zt(e);if(!t.ok)return R();e.nextUntilChar();let n=Y(e);return L({type:`TableArray`,keys:t.body,value:n.ok?n.body.value:{__proto__:null}})}function $t(e){let t=W(U([Y,Qt,Xt]))(e);return t.ok?L(t.body.reduce(H,{__proto__:null})):L({__proto__:null})}function X(e,t){let n=e.source.slice(0,e.position).split(`
|
|
15
|
-
`);return`Parse error on line ${n.length}, column ${n.at(-1)?.length??0}: ${t}`}function en(e){return t=>{let n=new dt(t);try{let t=e(n);if(t.ok&&n.eof())return t.body;let r=`Unexpected character: "${n.char()}"`;throw SyntaxError(X(n,r))}catch(e){throw e instanceof Error?SyntaxError(X(n,e.message)):SyntaxError(X(n,`Invalid error type caught`))}}}function tn(e){return en($t)(e)}const nn={ctx_execute:!0,ctx_batch_execute:!0};function rn(e,t){return nn[e]?e!==`ctx_execute`||t.language===`shell`:!1}function an(e,t){if(rn(e,t)){if(e===`ctx_execute`)return typeof t.code==`string`?t.code:void 0;if(Array.isArray(t.commands))return t.commands.map(e=>typeof e==`object`&&e?e.command:``).filter(e=>typeof e==`string`).join(`
|
|
16
|
-
`)}}const on=new Map;function sn(e,t){if(!t||t.length===0)return!0;let n=t.split(`|`).map(e=>e.trim()).filter(Boolean).join(`|`);if(n.length===0)return!0;let r=on.get(n);if(r!==void 0)return r.test(e);let i=RegExp(`^(?:${n})$`);return on.set(n,i),i.test(e)}function cn(e){return{session_id:e(),agent_id:null}}const Z=je({key:f,value:Ne(f)}).pipe(_e(`TomlConfig`)),ln=c(f,te(Z),{strict:!0,decode:e=>we({try:()=>tn(e),catch:e=>new o(e,`TOML parse error`)}).pipe(le(e=>se(Z)(e))),encode:(e,n,r)=>oe(new t(r,e,`TomlConfigFromText is decode-only`))}),Q=i(Z)({});var $=class extends h(`TomlLoader`)(){};const un=ue($,ie(function*(){let e=yield*n(Te()),t=yield*Be,r=yield*A;return $.of({load:fe(`TomlLoader.load`)(function*(n){let i=a(yield*ae(e),n);if(de(i))return i.value;let o=r.join(n,`systemfsoftware.toml`);if(!(yield*t.exists(o)))return yield*s(e,e=>(ce(e,n,Q),e)),Q;let c=yield*t.readFileString(o).pipe(S(l(ln)),Ce(()=>_(Q)));return yield*s(e,e=>(ce(e,n,c),e)),c})})})),dn={Write:!0,Edit:!0,Read:!0,MultiEdit:!0,Update:!0,Create:!0},fn={Edit:!0,MultiEdit:!0,Update:!0};function pn(e){return Array.isArray(e)&&e.length>0&&e.every(e=>typeof e==`object`&&!!e&&(`new_text`in e||`old_text`in e))}function mn(e,t){let n=t;if(dn[e]===!0&&`path`in n&&!(`file_path`in n)){let{path:e,...t}=n;n={file_path:e,...t}}if(fn[e]===!0&&`edits`in n&&pn(n.edits)&&!(`new_string`in n)){let e=n.edits.map(e=>({old_string:typeof e.old_text==`string`?e.old_text:``,new_string:typeof e.new_text==`string`?e.new_text:``}));n={...n,edits:e,old_string:e.map(e=>e.old_string).join(`
|
|
17
|
-
`),new_string:e.map(e=>e.new_string).join(`
|
|
18
|
-
`)}}return n}function hn(e){return e.length===0?e:e.charAt(0).toUpperCase()+e.slice(1)}export{Ge as _,mn as a,Fe as b,A as c,Be as d,He as f,Ke as g,We as h,sn as i,st as l,qe as m,un as n,hn as o,ze as p,an as r,cn as s,$ as t,Ue as u,Ve as v,T as y};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{A as e,B as t,C as n,Cn as r,D as i,Dn as a,E as o,En as s,F as c,Ft as l,H as u,I as d,N as f,O as ee,On as p,P as m,S as h,Sn as g,St as _,T as v,U as y,V as b,b as x,bn as te,bt as S,jt as C,k as w,kn as T,kt as E,mt as ne,pt as re,r as D,s as O,w as k,wn as A,xt as j,y as M,z as N}from"./esm-DxC3o46t.js";import{f as ie,l as ae,o as oe,p as se,s as ce,t as le,u as ue}from"./CommandExecutor-B_nJZc9B.js";import{a as P,d as de,i as F,o as I,r as fe,s as L}from"./dist-DQtXO3Ic.js";import{homedir as R}from"node:os";o({code:n,stdout:v,stderr:v});var z=class extends i()(`Block`,{reason:v}){},B=class extends i()(`Allow`,{updatedInput:m(k({key:v,value:e}))}){},V=class extends i()(`Warning`,{message:v}){};w(z,B,V);var H=class extends i()(`Blocked`,{reason:v}){},U=class extends i()(`Continue`,{warning:m(v),updatedInput:m(k({key:v,value:e}))}){};w(H,U);const pe=o({type:h(`command`),command:v,async:m(x),timeout:m(n)}),W=o({matcher:m(v),hooks:M(pe)}),G=o({PreToolUse:c(M(W),{exact:!0,default:()=>[]}),PostToolUse:c(M(W),{exact:!0,default:()=>[]}),UserPromptSubmit:c(M(W),{exact:!0,default:()=>[]}),Stop:c(M(W),{exact:!0,default:()=>[]}),SessionStart:c(M(W),{exact:!0,default:()=>[]}),SessionEnd:c(M(W),{exact:!0,default:()=>[]})}),me=f(w(o({hooks:G,disableAllHooks:m(x)}),o({...G.fields,disableAllHooks:m(x)})));function he(e){return a(me(e),e=>{if(`hooks`in e)return e;let{disableAllHooks:t,...n}=e;return{hooks:n,disableAllHooks:t}})}const ge=[`PreToolUse`,`PostToolUse`,`UserPromptSubmit`,`SessionStart`,`SessionEnd`,`Stop`];function _e(e){let t={hooks:{PreToolUse:[],PostToolUse:[],UserPromptSubmit:[],SessionStart:[],SessionEnd:[],Stop:[]}};for(let n of e){for(let e of ge)t.hooks[e]=(t.hooks[e]??[]).concat(Array.from(n.hooks[e]));n.disableAllHooks!==void 0&&(t.disableAllHooks=n.disableAllHooks)}return t}function K(e){return e.disableAllHooks===!0}const ve=f(d(o({decision:m(v),reason:m(v),hookSpecificOutput:m(o({permissionDecision:m(v),permissionDecisionReason:m(v),updatedInput:m(k({key:v,value:e}))}))})));var ye=class extends ee()(`HookVerdictError`,{raw:v}){},q=class extends i()(`ExitBlock`,{}){},J=class extends i()(`ExitDecisionJson`,{}){},Y=class extends i()(`ExitNoDecision`,{}){},X=class extends i()(`ExitOther`,{}){};w(q,J,Y,X);const be=e=>u(e.trim()).pipe(y(e=>e.startsWith(`{`),()=>new J({})),t(()=>new Y({}))),xe=e=>u(e.code).pipe(y(2,()=>new q({})),y(0,()=>be(e.stdout)),t(()=>new X({}))),Se=(e,n)=>u(e.trim()).pipe(y(``,()=>`Blocked by ${n} hook`),t(e=>e)),Ce=(e,n)=>u(e.hookSpecificOutput?.permissionDecision??e.decision).pipe(y(`deny`,()=>new z({reason:e.hookSpecificOutput?.permissionDecisionReason??`Blocked by ${n} hook`})),y(`block`,()=>new z({reason:e.reason??`Blocked by ${n} hook`})),t(()=>new B({updatedInput:e.hookSpecificOutput?.updatedInput}))),we=e=>u(e.trim()).pipe(y(``,()=>new B({})),t(e=>new V({message:e}))),Te=(e,t)=>u(xe(e)).pipe(b(`ExitBlock`,()=>T(new z({reason:Se(e.stderr,t)}))),b(`ExitNoDecision`,()=>T(new B({}))),b(`ExitDecisionJson`,()=>p(ve(e.stdout),{onLeft:()=>s(new ye({raw:e.stdout})),onRight:e=>T(Ce(e,t))})),b(`ExitOther`,()=>T(we(e.stderr))),N);function Ee(e,t){let n=e.replace(/"\$OMP_PROJECT_DIR"|'\$OMP_PROJECT_DIR'/g,JSON.stringify(t)).replace(/"\$\{OMP_PROJECT_DIR\}"|'\$\{OMP_PROJECT_DIR\}'/g,JSON.stringify(t)).replace(/"\$CLAUDE_PROJECT_DIR"|'\$CLAUDE_PROJECT_DIR'/g,JSON.stringify(t)).replace(/"\$\{CLAUDE_PROJECT_DIR\}"|'\$\{CLAUDE_PROJECT_DIR\}'/g,JSON.stringify(t)).replace(/\$OMP_PROJECT_DIR|\$\{OMP_PROJECT_DIR\}/g,JSON.stringify(t)).replace(/\$CLAUDE_PROJECT_DIR|\$\{CLAUDE_PROJECT_DIR\}/g,JSON.stringify(t)).trim();return{cmd:`sh`,args:[`-c`,n.startsWith(`"`)&&n.endsWith(`"`)?n.slice(1,-1):n]}}const De=S(`loadSettingsFile`)(function*(t){let n=yield*(yield*de).readFileString(t).pipe(re(()=>C(``)));if(n===``)return null;let r=f(d(k({key:v,value:e})))(n);if(A(r))return null;let i=r.right,a=he(i);return A(a)?null:a.right}),Oe=S(`loadSettings`)(function*(e){let t=[`${R()}/.claude/settings.json`,`${e}/.claude/settings.json`,`${e}/.claude/settings.local.json`,`/etc/claude-code/managed-settings.json`];return yield*ke(t)}),ke=S(`loadSettingsWithPaths`)(function*(e){let t=[];for(let n of e){let e=yield*De(n);e!==null&&t.push(e)}return t.length===0?null:_e(t)}),Z=S(`runHookScript`)(function*(e,t,n,r){let i=yield*le,{cmd:a,args:o}=Ee(e,n),s=JSON.stringify(t),c=ae(a,...o).pipe(se(n),oe({OMP_PROJECT_DIR:n,CLAUDE_PROJECT_DIR:n}),ce(s),ie(`pipe`),ue(`pipe`));return yield*E(_(function*(){let e=yield*i.start(c),t=yield*e.stdout.pipe(D(),O),n=yield*e.stderr.pipe(D(),O),r=yield*e.exitCode;return{code:typeof r==`number`?r:Number(r),stdout:t,stderr:n}})).pipe(l(r),ne(`TimeoutException`,()=>C({code:-1,stdout:``,stderr:`timeout after ${r}ms`})))}),Q=S(`runHooksForEvent`)(function*(e,t,n,i,a){let o=i.cwd,s,c=!1,l=n;for(let n of e)if(F(t,n.matcher))for(let e of n.hooks){let t=(e.timeout??10)*1e3;if(e.async){yield*j(Z(e.command,l,o,t));continue}let n=u(u(p(Te(yield*Z(e.command,l,o,t),a),{onLeft:e=>u(e).pipe(b(`HookVerdictError`,e=>new V({message:`Hook exited 0 but produced invalid JSON: ${e.raw.slice(0,200)}`})),N),onRight:e=>e})).pipe(b(`Block`,e=>new H({reason:e.reason})),b(`Warning`,e=>new U({warning:e.message})),b(`Allow`,e=>new U({updatedInput:e.updatedInput})),N)).pipe(b(`Blocked`,e=>r({block:!0,reason:e.reason})),b(`Continue`,e=>(e.warning!==void 0&&s===void 0&&(s=e.warning),e.updatedInput!==void 0&&(l={...l,...e.updatedInput},c=!0),g())),N);if(te(n))return n.value}return{...c?{updatedInput:l}:{},...s===void 0?{}:{warning:s}}}),Ae=S(`runPreToolUseHooks`)(function*(e,t,n){if(K(e))return;let r=I(t.toolName),i=L(()=>n.sessionManager.getSessionId()),a={...i,tool_name:r,tool_input:P(r,t.input),tool_call_id:t.toolCallId},o=fe(t.toolName,t.input);if(o!==void 0&&o.length>0){let r={...i,tool_name:`Bash`,tool_input:{command:o},tool_call_id:t.toolCallId},a=yield*Q(e.hooks.PreToolUse,`Bash`,r,n,`PreToolUse`);if(a.block)return a.reason===void 0?{block:!0}:{block:!0,reason:a.reason}}let s=yield*Q(e.hooks.PreToolUse,r,a,n,`PreToolUse`);if(s.block)return s.reason===void 0?{block:!0}:{block:!0,reason:s.reason};if(s.updatedInput&&typeof s.updatedInput==`object`&&`tool_input`in s.updatedInput&&s.updatedInput.tool_input&&typeof s.updatedInput.tool_input==`object`){let e=s.updatedInput.tool_input;for(let[n,r]of Object.entries(e))t.input[n]=r}}),$=S(`runPostToolUseHooks`)(function*(e,t,n){let r=I(t.toolName);if(K(e))return;let i={...L(()=>n.sessionManager.getSessionId()),tool_name:r,tool_input:P(r,t.input),tool_call_id:t.toolCallId,output:t.content,is_error:t.isError??!1};return yield*Q(e.hooks.PostToolUse,r,i,n,`PostToolUse`)}),je=S(`runUserPromptSubmitHooks`)(function*(e,t,n){let r=e.hooks.UserPromptSubmit;if(K(e)||r.length===0)return;let i=n.cwd,a=``,o={...L(()=>n.sessionManager.getSessionId()),prompt:t.text,source:t.source};for(let e of r)for(let t of e.hooks){let e=yield*Z(t.command,o,i,(t.timeout??10)*1e3);if(e.code!==0)continue;let n=e.stdout.trim();n.length>0&&(a+=(a.length>0?`
|
|
2
|
-
|
|
3
|
-
`:``)+n)}if(a.length===0)return;let s={text:`${a}\n\n${t.text}`};return t.images!==void 0&&(s.images=t.images),s}),Me=S(`runSessionStartHooks`)(function*(e,t,n){if(K(e))return;let r=e.hooks.SessionStart;if(r.length===0)return;let i=n.cwd,a={...L(()=>n.sessionManager.getSessionId()),reason:t};for(let e of r)if(!(e.matcher&&!F(t,e.matcher)))for(let t of e.hooks){let e=(t.timeout??10)*1e3;if(t.async){yield*j(Z(t.command,a,i,e));continue}yield*Z(t.command,a,i,e)}}),Ne=S(`runLifecycleHooks`)(function*(e,t){if(e.length===0)return;let n=t.cwd,r={...L(()=>t.sessionManager.getSessionId())};for(let t of e)for(let e of t.hooks){let t=(e.timeout??10)*1e3;e.async?yield*j(Z(e.command,r,n,t)):yield*Z(e.command,r,n,t)}});export{Oe as loadSettings,Ne as runLifecycleHooks,$ as runPostToolUseHooks,Ae as runPreToolUseHooks,Me as runSessionStartHooks,je as runUserPromptSubmitHooks};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{Cn as e,D as t,E as n,H as r,Sn as i,T as a,Tn as o,V as s,bn as c,bt as l,gt as u,jt as d,pt as f,vn as p,wn as m,y as h,z as g}from"./esm-DxC3o46t.js";import{c as _,d as v,t as y}from"./dist-DQtXO3Ic.js";const b=[`AGENTS.md`];var x=class extends t()(`Inject`,{}){},S=class extends t()(`Skip`,{matched:a}){};n({relativePath:a,skipList:h(a)});const C=e=>p(e.skipList.find(t=>t===e.relativePath)),w=e=>r(C(e)).pipe(s(`None`,()=>new x),s(`Some`,e=>new S({matched:e.value})),g),T=l(`extractRefs`)(function*(e,t,n){let r=yield*v,i=yield*_,a=[];for(let s of e.split(`
|
|
2
|
-
`)){let e=s.trim().replace(/^[-*+]\s+/,``);if(!e.startsWith(`@`))continue;let c=e.slice(1).trim();if(!c||c.includes(` `)||i.isAbsolute(c))continue;let l=i.resolve(t,c);if(l.startsWith(n+`/`)||l===n){let e=yield*u(r.exists(l));if(o(e)&&e.right){a.push({sourcePath:t,resolvedPath:l});continue}}let d=i.resolve(n,c);(d.startsWith(n+`/`)||d===n)&&d!==l&&a.push({sourcePath:n,resolvedPath:d})}return a}),E=l(`loadReferencedContent`)(function*(t){let n=yield*v,a=yield*_,l=yield*y,p=[a.resolve(t,`CLAUDE.md`),a.resolve(t,`.claude`,`CLAUDE.md`)],h=[];for(let e of p){let r=yield*u(n.readFileString(e,`utf-8`));if(o(r)){let n=yield*T(r.right,a.dirname(e),t);h.push(...n)}}let x=new Set,S=[];for(let e of h)x.has(e.resolvedPath)||(x.add(e.resolvedPath),S.push(e));let C=(yield*l.load(t).pipe(f(()=>d(void 0))))?.no_inject_refs??b,E=[];for(let a of S){let o=a.resolvedPath.slice(t.length+1);if(c(r(w({relativePath:o,skipList:C})).pipe(s(`Skip`,t=>e(t.matched)),s(`Inject`,()=>i()),g)))continue;let l=yield*u(n.readFileString(a.resolvedPath,`utf-8`));m(l)||E.push(`## ${o}\n${l.right}\n`)}return E.length===0?``:[`# Injected @-references from CLAUDE.md`,`The following files were @-imported by CLAUDE.md and contain project rules.`,``,...E].join(`
|
|
3
|
-
`)});export{E as loadReferencedContent};
|
package/dist/runtime-D3PIHvF6.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{$ as e,$t as t,At as n,Bt as r,Cn as i,Ct as a,Dt as o,Et as s,Ht as c,Lt as l,Mn as u,Mt as d,Nt as f,Ot as p,Pt as m,Q as ee,Qt as h,Rt as te,Sn as ne,Tt as re,Vt as g,W as ie,Xt as ae,Zt as oe,_ as se,_n as ce,_t as le,at as ue,c as de,ct as _,d as fe,dt as pe,en as me,et as v,f as he,ft as y,ht as ge,i as _e,identity as ve,it as ye,jn as be,jt as b,kt as xe,lt as x,m as Se,nn as S,nt as C,ot as w,p as T,pipe as E,pn as Ce,rn as D,rt as we,sn as Te,t as Ee,tn as O,tt as De,vn as k,vt as A,wt as j,xn as Oe,xt as ke,yn as Ae,yt as M,zt as je}from"./esm-DxC3o46t.js";import{a as Me,c as N,d as P,i as F,n as Ne,r as Pe,t as Fe}from"./CommandExecutor-B_nJZc9B.js";import{_ as Ie,b as I,d as L,f as R,g as Le,h as Re,l as ze,m as Be,n as Ve,p as z,u as He,v as Ue,y as We}from"./dist-DQtXO3Ic.js";import*as Ge from"node:os";import*as Ke from"node:crypto";import*as B from"node:path";import*as V from"node:fs";import*as H from"node:child_process";const U=(e,t,n)=>(...r)=>y(i=>{try{e(...r,(e,n)=>{i(e?A(t?t(e,r):e):b(n))})}catch(e){i(n?A(n(e,r)):ge(e))}}),W=(e,t,n)=>_e(qe(e,t,n)),qe=(e,t,n)=>C(()=>Xe(e(),t,Te(void 0),n)),Je=(e,t,{encoding:n,endOnDone:r=!0}={},i=_)=>{let a=Ye(e,n),o=r?y(t=>{`closed`in e&&e.closed?t(_):(e.once(`finish`,()=>t(_)),e.end())}):_;return{awaitRead:()=>_,emit:a,error:e=>c(o,t(e)),done:e=>c(o,i)}},Ye=(e,t)=>n=>n.length===0?_:y(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(_):s?o():e.once(`drain`,o)}o()}),Xe=(t,n,r,i)=>{if(!t.readable)return we;let a=je(!1);function o(){a.unsafeOpen()}function s(e){r.current=ae(n(e)),a.unsafeOpen()}function c(){r.current=oe,a.unsafeOpen()}t.on(`readable`,o),t.on(`error`,s),t.on(`end`,c);let l=i?.chunkSize?Number(i.chunkSize):void 0;return e(C(function e(){let n=t.read(l);if(n===null)return r.current?De(r.current):(a.unsafeClose(),v(a.await,e));let i=[n];for(;;){if(n=t.read(l),n===null)return v(ye(Ce(i)),e);i.push(n)}}),f(()=>{t.off(`readable`,o),t.off(`error`,s),t.off(`end`,c),i?.closeOnDone!==!1&&`closed`in t&&!t.closed&&t.destroy()}))},Ze=(e,t,n)=>se(Qe(e,t,n)),Qe=(e,n,r)=>v(g(f(()=>e()),S()),([e,i])=>ee($e(e,i,n),Je(e,e=>me(i,e),r,t(i,_)))),$e=(e,t,n)=>d(()=>{function r(e){D(t,A(n(e)))}return e.on(`error`,r),le(h(t),f(()=>{e.removeListener(`error`,r)}))}),G=(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 I({reason:i,module:e,method:t,pathOrDescriptor:r,syscall:n.syscall,description:n.message,cause:n})},et=e=>typeof e==`string`?e:`pipe`,K=e=>typeof e==`string`?e:`pipe`,q=e=>e instanceof globalThis.Error?e:new globalThis.Error(String(e)),J=(e,t,n)=>{let r=N(n).reduce((e,t)=>{let n=`${t.command} ${t.args.join(` `)}`;return e.length===0?n:`${e} | ${n}`},``);return G(`Command`,e)(t,[r])},tt={[F]:F,...be,toJSON(){return{_id:`@effect/platform/CommandExecutor/Process`,pid:this.pid}}},Y=e=>t=>{switch(t._tag){case`StandardCommand`:{let n=M(S(),e=>y(n=>{let r=H.spawn(t.command,t.args,{stdio:[et(t.stdin),K(t.stdout),K(t.stderr)],cwd:Ae(t.cwd,u),shell:t.shell,env:{...process.env,...Object.fromEntries(t.env)},detached:process.platform!==`win32`});return r.on(`error`,e=>{n(A(J(`spawn`,e,t)))}),r.on(`exit`,(...t)=>{D(e,b(t))}),r.on(`spawn`,()=>{n(b([r,e]))}),f(()=>{r.kill(`SIGTERM`)})})),r=process.platform===`win32`?(e,n)=>y(n=>{H.exec(`taskkill /pid ${e.pid} /T /F`,e=>{n(e?A(J(`kill`,q(e),t)):_)})}):(e,n)=>te({try:()=>process.kill(-e.pid,n),catch:e=>J(`kill`,q(e),t)}),i=(e,n)=>d(()=>e.kill(n)?_:A(J(`kill`,new globalThis.Error(`Failed to kill process`),t)));return E(Oe(t.cwd,{onNone:()=>_,onSome:t=>e.access(t)}),c(x(n,([e,t])=>M(O(t),n=>n?M(h(t),([t])=>t!==0&&t!==null?r(e,`SIGTERM`).pipe(a):_):r(e,`SIGTERM`).pipe(p(()=>i(e,`SIGTERM`)),c(h(t)),a)))),j(([e,n])=>{let a=Se;e.stdin!==null&&(a=Ze(()=>e.stdin,e=>J(`toWritable`,q(e),t)));let o=M(h(n),([e,n])=>e===null?A(J(`exitCode`,new globalThis.Error(`Process interrupted due to receipt of signal: ${n}`),t)):b(Ne(e))),l=s(O(n)),u=(t=`SIGTERM`)=>r(e,t).pipe(p(()=>i(e,t)),c(pe(h(n)))),d=Pe(e.pid),f=W(()=>e.stderr,e=>J(`fromReadable(stderr)`,q(e),t)),m=W(()=>e.stdout,e=>J(`fromReadable(stdout)`,q(e),t));return typeof t.stdout!=`string`&&(m=fe(m,t.stdout)),Object.assign(Object.create(tt),{pid:d,exitCode:o,isRunning:l,kill:u,stdin:a,stderr:f,stdout:m})}),typeof t.stdin==`string`?ve:m(e=>ke(de(t.stdin,e.stdin))))}case`PipedCommand`:{let n=N(t);if(n.length===1)return E(n[0],Y(e));let r=n[0],i=n.slice(1),a=i.slice(0,i.length-1),o=i[i.length-1];return E(P(o,a.reduce((t,n)=>E(P(n,t),Y(e),j(e=>e.stdout),T),E(Y(e)(r),j(e=>e.stdout),T))),Y(e))}}},nt=ue(Fe,E(L,j(e=>Me(Y(e))))),X=e=>t=>new We({module:`FileSystem`,method:e,cause:t}),rt=(()=>{let e=U(V.access,G(`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)}})(),it=(()=>{let e=U(V.cp,G(`FileSystem`,`copy`),X(`copy`));return(t,n,r)=>e(t,n,{force:r?.overwrite??!1,preserveTimestamps:r?.preserveTimestamps??!1,recursive:!0})})(),at=(()=>{let e=U(V.copyFile,G(`FileSystem`,`copyFile`),X(`copyFile`));return(t,n)=>e(t,n)})(),ot=(()=>{let e=U(V.chmod,G(`FileSystem`,`chmod`),X(`chmod`));return(t,n)=>e(t,n)})(),st=(()=>{let e=U(V.chown,G(`FileSystem`,`chown`),X(`chown`));return(t,n,r)=>e(t,n,r)})(),ct=(()=>{let e=U(V.link,G(`FileSystem`,`link`),X(`link`));return(t,n)=>e(t,n)})(),lt=(()=>{let e=U(V.mkdir,G(`FileSystem`,`makeDirectory`),X(`makeDirectory`));return(t,n)=>e(t,{recursive:n?.recursive??!1,mode:n?.mode})})(),Z=e=>{let t=U(V.mkdtemp,G(`FileSystem`,e),X(e));return e=>d(()=>{let n=e?.prefix??``,r=typeof e?.directory==`string`?B.join(e.directory,`.`):Ge.tmpdir();return t(n?B.join(r,n):r+`/`)})},ut=Z(`makeTempDirectory`),Q=e=>{let t=U(V.rm,G(`FileSystem`,e),X(e));return(e,n)=>t(e,{recursive:n?.recursive??!1,force:n?.force??!1})},dt=Q(`remove`),ft=(()=>{let e=Z(`makeTempDirectoryScoped`),t=Q(`makeTempDirectoryScoped`);return n=>x(e(n),e=>o(t(e,{recursive:!0})))})(),pt=e=>{let t=U(V.open,G(`FileSystem`,e),X(e)),n=U(V.close,G(`FileSystem`,e),X(e));return(e,r)=>E(x(t(e,r?.flag??`r`,r?.mode),e=>o(n(e))),j(e=>ht(He(e),r?.flag?.startsWith(`a`)??!1)))},mt=pt(`open`),ht=(()=>{let e=e=>U(V.read,G(`FileSystem`,e),X(e)),t=e(`read`),n=e(`readAlloc`),a=U(V.fstat,G(`FileSystem`,`stat`),X(`stat`)),o=U(V.ftruncate,G(`FileSystem`,`truncate`),X(`truncate`)),s=U(V.fsync,G(`FileSystem`,`sync`),X(`sync`)),c=e=>U(V.write,G(`FileSystem`,e),X(e)),l=c(`write`),u=c(`writeAll`);class p{fd;append;[R];semaphore=r(1);position=0n;constructor(e,t){this.fd=e,this.append=t,this[R]=R}get stat(){return j(a(this.fd),wt)}get sync(){return s(this.fd)}seek(e,t){let n=z(e);return this.semaphore.withPermits(1)(f(()=>(t===`start`?this.position=n:t===`current`&&(this.position+=n),this.position)))}read(e){return this.semaphore.withPermits(1)(j(d(()=>t(this.fd,{buffer:e,position:this.position})),e=>{let t=z(e);return this.position+=t,t}))}readAlloc(e){let t=Number(e);return this.semaphore.withPermits(1)(M(f(()=>Buffer.allocUnsafeSlow(t)),e=>j(n(this.fd,{buffer:e,position:this.position}),n=>{if(n===0)return ne();if(this.position+=BigInt(n),n===t)return i(e);let r=Buffer.allocUnsafeSlow(n);return e.copy(r,0,0,n),i(r)})))}truncate(e){return this.semaphore.withPermits(1)(j(o(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)(j(d(()=>l(this.fd,e,void 0,void 0,this.append?void 0:Number(this.position))),e=>{let t=z(e);return this.append||(this.position+=t),t}))}writeAllChunk(e){return M(d(()=>u(this.fd,e,void 0,void 0,this.append?void 0:Number(this.position))),t=>t===0?A(new I({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)):_))}writeAll(e){return this.semaphore.withPermits(1)(this.writeAllChunk(e))}}return(e,t)=>new p(e,t)})(),gt=e=>{let t=Z(e),n=pt(e),r=e=>f(()=>Ke.randomBytes(e).toString(`hex`));return e=>E(g(t(e),r(6)),j(([t,n])=>B.join(t,n+(e?.suffix??``))),m(e=>xe(n(e,{flag:`w+`}))))},_t=gt(`makeTempFile`),vt=(()=>{let e=gt(`makeTempFileScoped`),t=Q(`makeTempFileScoped`);return n=>x(e(n),e=>o(t(B.dirname(e),{recursive:!0})))})(),yt=(e,t)=>l({try:()=>V.promises.readdir(e,t),catch:t=>G(`FileSystem`,`readDirectory`)(t,[e])}),bt=e=>y((t,n)=>{try{V.readFile(e,{signal:n},(n,r)=>{t(n?A(G(`FileSystem`,`readFile`)(n,[e])):b(r))})}catch(e){t(A(X(`readFile`)(e)))}}),xt=(()=>{let e=U(V.readlink,G(`FileSystem`,`readLink`),X(`readLink`));return t=>e(t)})(),St=(()=>{let e=U(V.realpath,G(`FileSystem`,`realPath`),X(`realPath`));return t=>e(t)})(),Ct=(()=>{let e=U(V.rename,G(`FileSystem`,`rename`),X(`rename`));return(t,n)=>e(t,n)})(),wt=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:k(e.mtime),atime:k(e.atime),birthtime:k(e.birthtime),dev:e.dev,rdev:k(e.rdev),ino:k(e.ino),mode:e.mode,nlink:k(e.nlink),uid:k(e.uid),gid:k(e.gid),size:z(e.size),blksize:k(z(e.blksize)),blocks:k(e.blocks)}),$=(()=>{let e=U(V.stat,G(`FileSystem`,`stat`),X(`stat`));return t=>j(e(t),wt)})(),Tt=(()=>{let e=U(V.symlink,G(`FileSystem`,`symlink`),X(`symlink`));return(t,n)=>e(t,n)})(),Et=(()=>{let e=U(V.truncate,G(`FileSystem`,`truncate`),X(`truncate`));return(t,n)=>e(t,n===void 0?void 0:Number(n))})(),Dt=(()=>{let e=U(V.utimes,G(`FileSystem`,`utime`),X(`utime`));return(t,n,r)=>e(t,n,r)})(),Ot=(e,t)=>Ee(n=>x(f(()=>{let r=V.watch(e,{recursive:t?.recursive},(e,t)=>{if(t)switch(e){case`rename`:n.fromEffect(re($(t),{onSuccess:e=>b(Re({path:t})),onFailure:e=>e._tag===`SystemError`&&e.reason===`NotFound`?b(Le({path:t})):A(e)}));return;case`change`:n.single(Ie({path:t}));return}});return r.on(`error`,t=>{n.fail(new I({module:`FileSystem`,reason:`Unknown`,method:`watch`,pathOrDescriptor:e,cause:t}))}),r.on(`close`,()=>{n.end()}),r}),e=>f(()=>e.close()))),kt=(e,t,n)=>$(t).pipe(j(r=>e.pipe(ce(e=>e.register(t,r,n)),Ae(()=>Ot(t,n)))),he),At=(e,t,n)=>y((r,i)=>{try{V.writeFile(e,t,{signal:i,flag:n?.flag,mode:n?.mode},t=>{r(t?A(G(`FileSystem`,`writeFile`)(t,[e])):_)})}catch(e){r(A(X(`writeFile`)(e)))}}),jt=ue(L,j(n(Be),e=>Ue({access:rt,chmod:ot,chown:st,copy:it,copyFile:at,link:ct,makeDirectory:lt,makeTempDirectory:ut,makeTempDirectoryScoped:ft,makeTempFile:_t,makeTempFileScoped:vt,open:mt,readDirectory:yt,readFile:bt,readLink:xt,realPath:St,remove:dt,rename:Ct,stat:$,symlink:Tt,truncate:Et,utimes:Dt,watch(t,n){return kt(e,t,n)},writeFile:At}))),Mt=nt.pipe(w(jt),w(ze)),Nt=ie(Ve.pipe(w(Mt)));export{Nt as default};
|