@qitqode/qitqode-android-arm64 0.1.20 → 0.1.21

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.
Files changed (79) hide show
  1. package/bundle/{chunk-xb031er5.js → chunk-0942095s.js} +1 -1
  2. package/bundle/{chunk-0x0a51w3.js → chunk-0czxqcg7.js} +1 -1
  3. package/bundle/{chunk-9a5nck3f.js → chunk-1b9ey3yh.js} +1 -1
  4. package/bundle/{chunk-gspdrdyq.js → chunk-21q96fet.js} +1 -1
  5. package/bundle/{chunk-wnjg8mmh.js → chunk-21t254fq.js} +1 -1
  6. package/bundle/{chunk-zfvk6zjj.js → chunk-2db8pn5k.js} +1 -1
  7. package/bundle/{chunk-r2waj5n2.js → chunk-3gxhdy0c.js} +1 -1
  8. package/bundle/{chunk-471yj527.js → chunk-3m0t96kb.js} +1 -1
  9. package/bundle/{chunk-dp3hqm2m.js → chunk-4tk4wppp.js} +1 -1
  10. package/bundle/{chunk-p77m937s.js → chunk-5k1eyz7y.js} +1 -1
  11. package/bundle/{chunk-c4mxtqyq.js → chunk-5rcnwm9j.js} +1 -1
  12. package/bundle/{chunk-k728fzrr.js → chunk-5yghd32r.js} +1 -1
  13. package/bundle/{chunk-q39h31te.js → chunk-651fyxmn.js} +3 -3
  14. package/bundle/{chunk-7myavy3p.js → chunk-6ba9fc92.js} +1 -1
  15. package/bundle/{chunk-w0fg8n1f.js → chunk-6dznrhs4.js} +1 -1
  16. package/bundle/{chunk-knwayz0m.js → chunk-6t70j1wg.js} +1 -1
  17. package/bundle/{chunk-3makpbng.js → chunk-767vf2ha.js} +1 -1
  18. package/bundle/{chunk-k6z419yx.js → chunk-76p9v2jf.js} +1 -1
  19. package/bundle/{chunk-1brsnwhv.js → chunk-7hxksr4h.js} +1 -1
  20. package/bundle/{chunk-2w154wad.js → chunk-7jefvta3.js} +1 -1
  21. package/bundle/{chunk-fegrrsfj.js → chunk-7skp0dmg.js} +1 -1
  22. package/bundle/{chunk-1qw3yh13.js → chunk-88ckmmdr.js} +3 -3
  23. package/bundle/{chunk-0pbpzty2.js → chunk-8fn883z8.js} +1 -1
  24. package/bundle/{chunk-c422awkv.js → chunk-9gfe4wtk.js} +1 -1
  25. package/bundle/{chunk-rdsae6k4.js → chunk-9hwsz356.js} +1 -1
  26. package/bundle/{chunk-3fzgbam3.js → chunk-9vvvyk10.js} +1 -1
  27. package/bundle/{chunk-n0y1ea17.js → chunk-atg7cn5r.js} +1 -1
  28. package/bundle/{chunk-qq48ffjc.js → chunk-b3721b7c.js} +1 -1
  29. package/bundle/{chunk-nt07vncv.js → chunk-b4r19v4g.js} +1 -1
  30. package/bundle/{chunk-b2ky15zx.js → chunk-bsg92mw7.js} +1 -1
  31. package/bundle/{chunk-skjge2wh.js → chunk-bzj7yxw6.js} +1 -1
  32. package/bundle/{chunk-1gj0m10e.js → chunk-c1dwcsax.js} +1 -1
  33. package/bundle/{chunk-ysxmk1z1.js → chunk-c4vfxy1e.js} +1 -1
  34. package/bundle/{chunk-v7yvnnmr.js → chunk-esjs9s9g.js} +1 -1
  35. package/bundle/chunk-f2q7cbah.js +2 -0
  36. package/bundle/{chunk-mpn5qm9j.js → chunk-fssswy6j.js} +1 -1
  37. package/bundle/{chunk-4pedvzse.js → chunk-ghtm9598.js} +1 -1
  38. package/bundle/{chunk-p41h8naw.js → chunk-gkz68a5s.js} +1 -1
  39. package/bundle/{chunk-gfm4vad7.js → chunk-gp6nvjb8.js} +153 -153
  40. package/bundle/{chunk-6tjghyx6.js → chunk-hkydp4m3.js} +1 -1
  41. package/bundle/{chunk-hjvje9xj.js → chunk-htdpkk8v.js} +1 -1
  42. package/bundle/{chunk-ghmctw8s.js → chunk-hvnhkrd3.js} +1 -1
  43. package/bundle/{chunk-fgqrcjsm.js → chunk-hvqgvsa5.js} +1 -1
  44. package/bundle/{chunk-dgbvsnqb.js → chunk-js7becx7.js} +1 -1
  45. package/bundle/{chunk-5549c7mb.js → chunk-jwgqpntf.js} +1 -1
  46. package/bundle/{chunk-7nas10jx.js → chunk-k44dj66f.js} +1 -1
  47. package/bundle/{chunk-9g4hz1st.js → chunk-kvs7qbga.js} +1 -1
  48. package/bundle/{chunk-1q2vhe78.js → chunk-m7q12naw.js} +1 -1
  49. package/bundle/{chunk-pskkmca2.js → chunk-mc1m6dxk.js} +1 -1
  50. package/bundle/{chunk-anse7bd0.js → chunk-myjbd0vk.js} +1 -1
  51. package/bundle/{chunk-b49rxw15.js → chunk-n499tbz0.js} +1 -1
  52. package/bundle/{chunk-y36ggefa.js → chunk-n5k2c708.js} +1 -1
  53. package/bundle/{chunk-zafrxr1q.js → chunk-n6fh34xx.js} +1 -1
  54. package/bundle/{chunk-6bq7rx7m.js → chunk-n7a4wpjj.js} +1 -1
  55. package/bundle/{chunk-vh8w0ea8.js → chunk-ns0hezdf.js} +1 -1
  56. package/bundle/{chunk-pn77fh9b.js → chunk-q2zk0z41.js} +1 -1
  57. package/bundle/{chunk-s2g5989e.js → chunk-qh76pgsk.js} +1 -1
  58. package/bundle/{chunk-tp7sfreh.js → chunk-qxtz0tfd.js} +1 -1
  59. package/bundle/{chunk-3gdqmave.js → chunk-qy1s81tv.js} +2 -2
  60. package/bundle/{chunk-28knamc9.js → chunk-r03jc8xm.js} +1 -1
  61. package/bundle/{chunk-wmqcz5rb.js → chunk-rkb592nb.js} +1 -1
  62. package/bundle/{chunk-w8rvjbgr.js → chunk-s811ht10.js} +1 -1
  63. package/bundle/{chunk-8k1q3g8s.js → chunk-sj8py6vk.js} +1 -1
  64. package/bundle/{chunk-dvn528qs.js → chunk-t6dymkmx.js} +1 -1
  65. package/bundle/{chunk-jc0wbpjq.js → chunk-th5z0zx7.js} +1 -1
  66. package/bundle/chunk-tnn7hm4v.js +2 -0
  67. package/bundle/{chunk-aej69zjj.js → chunk-v0jnnpsz.js} +1 -1
  68. package/bundle/{chunk-f57rqsby.js → chunk-vdt8dvqs.js} +1 -1
  69. package/bundle/{chunk-0fwz5r1k.js → chunk-w2f8sjc4.js} +1 -1
  70. package/bundle/{chunk-rmmrnx95.js → chunk-w5nwkb0s.js} +1 -1
  71. package/bundle/{chunk-ckhhm2m8.js → chunk-w9mdrb90.js} +1 -1
  72. package/bundle/{chunk-xbxgrwvy.js → chunk-y7hkykkj.js} +1 -1
  73. package/bundle/{chunk-ej3gmaba.js → chunk-yja3y138.js} +1 -1
  74. package/bundle/{chunk-k5vwx1nv.js → chunk-yt6cfsdh.js} +1 -1
  75. package/bundle/index.js +3 -3
  76. package/bundle/worker.js +1 -1
  77. package/package.json +1 -1
  78. package/bundle/chunk-7pqevqry.js +0 -2
  79. package/bundle/chunk-p4pc1zdd.js +0 -2
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{rh as hM,sh as DR,th as B_,uh as H_,vh as j_,wh as O_,xh as vX,yh as U_,zh as S_}from"./chunk-ckhhm2m8.js";import{Ah as sP,Fh as M0}from"./chunk-tp7sfreh.js";import{xi as vW}from"./chunk-prrrw8t8.js";import{$j as LY,$k as QB,Ak as QU,Bk as XU,Cj as e,Ck as VU,Dj as x1,Ek as _A,Fk as zj,Gk as o4,Hj as sJ,Hk as W_,Ik as P0,Jj as i5,Kj as vE,Lj as aD,Mj as _9,Mk as kO,Nj as yB,Nk as KU,Ok as zM,Pk as oX,Qj as M$,Qk as K2,Rj as p7,Rk as $Y,Sj as g0,Sk as n0,Tj as W2,Tk as Q$,Uj as m0,Vk as s0,Wj as qV,Wk as $C,Xj as I2,Xk as O0,Yj as cZ,Yk as $y,_k as C2,ak as SY,al as pX,bk as q6,bl as LW,ck as p4,cl as E2,dk as W1,dl as D1,ek as n1,el as b0,fk as b1,fl as B0,gk as K_,hk as AX,ik as IX,jk as G_,kk as WQ,lk as BQ,mk as SO,nk as jf,ok as Of,pk as zQ,qk as o1,rk as oZ,sk as dK,tk as _7,uk as _Q,vk as lO,wk as rO,xk as aO,yk as tO,zk as eO}from"./chunk-q39h31te.js";import{gl as GQ,hl as ew}from"./chunk-0x0a51w3.js";import{Al as P9,Cl as f9,Fl as w0,Gl as U1,Hl as wJ,Il as A6,Jl as A8,Ml as $w,Nl as V6,Pl as q0,Ql as u,Rl as kw,Sl as L2,Tl as dz,sl as H3,tl as Rj,vl as yw,wl as MB,xl as V2,yl as k2,zl as p1}from"./chunk-7myavy3p.js";import{$l as S0,Ul as wY,Vl as m8,Wl as m$,Xl as u1,_l as Yw}from"./chunk-fegrrsfj.js";import{Gn as W8,Hn as I8,Im as d8,cn as j$,dn as o0,en as w$,fn as G8,gn as hO,hm as gO,in as z0,kn as i2,ln as F7,nn as QQ,qn as FM,rn as DM,tn as pZ}from"./chunk-c4x99ayd.js";import{Qo as mZ}from"./chunk-0pbpzty2.js";import{ip as e9,jp as s4,kp as $7,mp as V8}from"./chunk-tq258v8s.js";import{rp as Z9}from"./chunk-jfy6bfvv.js";import{sp as H2}from"./chunk-aej69zjj.js";import{eq as T8,fq as wM,qq as A9,rq as UP}from"./chunk-t7v8wzr9.js";import{Tq as $M,Uq as uP}from"./chunk-er5q8nhp.js";import{mr as m7}from"./chunk-351wfvhp.js";import{qr as w1,vr as tw,wr as X7}from"./chunk-k5vwx1nv.js";import{Cr as B3,yr as N1,zr as W3}from"./chunk-ej3gmaba.js";import{Or as o2,Pr as VX,Vr as P$,Wr as w8}from"./chunk-3nc9wy1m.js";import{Ds as q2}from"./chunk-56cty7nr.js";import{Fs as Tj}from"./chunk-thbjhgw0.js";import{Gs as S1,Is as BX,Ns as ZH,Qs as lY,Rs as kX,Ws as lw,Zs as Z$,bt as FJ,ct as a0,dt as h0,mt as Y0}from"./chunk-v7yvnnmr.js";import{Bt as g8,Ct as V0,Gt as z2,nt as mY,pt as t8,rt as V7,vt as K7,yt as Z7}from"./chunk-b5x3zghc.js";import{Ht as av}from"./chunk-t1f7jeat.js";import{It as F}from"./chunk-tk6gjy9d.js";import{Jt as wX,Mt as Ez,Nt as gz,Pt as U6,_t as J_}from"./chunk-pkdk0ppc.js";import{Au as LP,Bu as SP,Cu as B2,fu as d_,hu as m,iu as IP,ju as F2,ku as A2,lu as cW,mu as NP,nu as X$,ou as W0,pu as H0,qu as q$,ru as x2,su as uW,tu as lW,uu as v2,vu as k1,wu as A0,xu as V$,yu as c_,zu as pW}from"./chunk-hrnx60em.js";import{Du as AP,Zu as M5}from"./chunk-bbznk59q.js";import{Iz as G3,Tz as hW}from"./chunk-01gtn79f.js";import{$H as V,$N as X_,AG as ey,AH as PB,AO as f0,BN as K0,FC as Y_,GE as p0,IJ as k8,KJ as rY,MO as XX,NE as H$,TF as MJ,UE as u0,ZF as ry,_N as Q_,aO as V_,bC as CX,bO as v7,cO as XO,dO as I_,eC as N2,eG as ay,fO as f7,hO as tY,iF as w2,iO as N_,jD as X0,jG as ty,oJ as y8,sO as n9,tO as $B,vD as h8,vO as L_,wH as _B,wO as Q3,yF as b}from"./chunk-meaa7wrs.js";import{fP as CK}from"./chunk-0ddhkapd.js";import{lP as a6,mP as D0,nP as R0,pP as d2,qP as i9,rP as s9}from"./chunk-fa03gsff.js";var DH=D0((Sc,IY)=>{function GH($){return Array.isArray($)?$:[$]}var sC=void 0,c3="",VH=" ",d3="\\",nC=/^\s+$/,rC=/(?:[^\\]|^)\\$/,aC=/^\\!/,tC=/^\\#/,eC=/\r?\n/g,$A=/^\.{0,2}\/|^\.{1,2}$/,ZA=/\/$/,p9="/",WH="node-ignore";if(typeof Symbol<"u")WH=Symbol.for("node-ignore");var BH=WH,o9=($,Z,J)=>{return Object.defineProperty($,Z,{value:J}),J},JA=/([0-z])-([0-z])/g,HH=()=>!1,YA=($)=>$.replace(JA,(Z,J,Y)=>J.charCodeAt(0)<=Y.charCodeAt(0)?Z:c3),QA=($)=>{let{length:Z}=$;return $.slice(0,Z-Z%2)},XA=[[/^\uFEFF/,()=>c3],[/((?:\\\\)*?)(\\?\s+)$/,($,Z,J)=>Z+(J.indexOf("\\")===0?VH:c3)],[/(\\+?)\s/g,($,Z)=>{let{length:J}=Z;return Z.slice(0,J-J%2)+VH}],[/[\\$.|*+(){^]/g,($)=>`\\${$}`],[/(?!\\)\?/g,()=>"[^/]"],[/^\//,()=>"^"],[/\//g,()=>"\\/"],[/^\^*\\\*\\\*\\\//,()=>"^(?:.*\\/)?"],[/^(?=[^^])/,function(){return!/\/(?!$)/.test(this)?"(?:^|\\/)":"^"}],[/\\\/\\\*\\\*(?=\\\/|$)/g,($,Z,J)=>Z+6<J.length?"(?:\\/[^\\/]+)*":"\\/.+"],[/(^|[^\\]+)(\\\*)+(?=.+)/g,($,Z,J)=>{let Y=J.replace(/\\\*/g,"[^\\/]*");return Z+Y}],[/\\\\\\(?=[$.|*+(){^])/g,()=>d3],[/\\\\/g,()=>d3],[/(\\)?\[([^\]/]*?)(\\*)($|\])/g,($,Z,J,Y,Q)=>Z===d3?`\\[${J}${QA(Y)}${Q}`:Q==="]"?Y.length%2===0?`[${YA(J)}${Y}]`:"[]":"[]"],[/(?:[^*])$/,($)=>/\/$/.test($)?`${$}$`:`${$}(?=$|\\/$)`]],VA=/(^|\\\/)?\\\*$/,LZ="regex",CY="checkRegex",KH="_",KA={[LZ]($,Z){return`${Z?`${Z}[^/]+`:"[^/]*"}(?=$|\\/$)`},[CY]($,Z){return`${Z?`${Z}[^/]*`:"[^/]*"}(?=$|\\/$)`}},GA=($)=>XA.reduce((Z,[J,Y])=>Z.replace(J,Y.bind($)),$),AY=($)=>typeof $==="string",WA=($)=>$&&AY($)&&!nC.test($)&&!rC.test($)&&$.indexOf("#")!==0,BA=($)=>$.split(eC).filter(Boolean);class jH{constructor($,Z,J,Y,Q,X){this.pattern=$,this.mark=Z,this.negative=Q,o9(this,"body",J),o9(this,"ignoreCase",Y),o9(this,"regexPrefix",X)}get regex(){let $=KH+LZ;if(this[$])return this[$];return this._make(LZ,$)}get checkRegex(){let $=KH+CY;if(this[$])return this[$];return this._make(CY,$)}_make($,Z){let J=this.regexPrefix.replace(VA,KA[$]),Y=this.ignoreCase?new RegExp(J,"i"):new RegExp(J);return o9(this,Z,Y)}}var HA=({pattern:$,mark:Z},J)=>{let Y=!1,Q=$;if(Q.indexOf("!")===0)Y=!0,Q=Q.substr(1);Q=Q.replace(aC,"!").replace(tC,"#");let X=GA(Q);return new jH($,Z,Q,J,Y,X)};class OH{constructor($){this._ignoreCase=$,this._rules=[]}_add($){if($&&$[BH]){this._rules=this._rules.concat($._rules._rules),this._added=!0;return}if(AY($))$={pattern:$};if(WA($.pattern)){let Z=HA($,this._ignoreCase);this._added=!0,this._rules.push(Z)}}add($){return this._added=!1,GH(AY($)?BA($):$).forEach(this._add,this),this._added}test($,Z,J){let Y=!1,Q=!1,X;this._rules.forEach((G)=>{let{negative:B}=G;if(Q===B&&Y!==Q||B&&!Y&&!Q&&!Z)return;if(!G[J].test($))return;Y=!B,Q=B,X=B?sC:G});let K={ignored:Y,unignored:Q};if(X)K.rule=X;return K}}var jA=($,Z)=>{throw new Z($)},E8=($,Z,J)=>{if(!AY($))return J(`path must be a string, but got \`${Z}\``,TypeError);if(!$)return J("path must not be empty",TypeError);if(E8.isNotRelative($))return J(`path should be a \`path.relative()\`d string, but got "${Z}"`,RangeError);return!0},UH=($)=>$A.test($);E8.isNotRelative=UH;E8.convert=($)=>$;class qH{constructor({ignorecase:$=!0,ignoreCase:Z=$,allowRelativePaths:J=!1}={}){o9(this,BH,!0),this._rules=new OH(Z),this._strictPathCheck=!J,this._initCache()}_initCache(){this._ignoreCache=Object.create(null),this._testCache=Object.create(null)}add($){if(this._rules.add($))this._initCache();return this}addPattern($){return this.add($)}_test($,Z,J,Y){let Q=$&&E8.convert($);return E8(Q,$,this._strictPathCheck?jA:HH),this._t(Q,Z,J,Y)}checkIgnore($){if(!ZA.test($))return this.test($);let Z=$.split(p9).filter(Boolean);if(Z.pop(),Z.length){let J=this._t(Z.join(p9)+p9,this._testCache,!0,Z);if(J.ignored)return J}return this._rules.test($,!1,CY)}_t($,Z,J,Y){if($ in Z)return Z[$];if(!Y)Y=$.split(p9).filter(Boolean);if(Y.pop(),!Y.length)return Z[$]=this._rules.test($,J,LZ);let Q=this._t(Y.join(p9)+p9,Z,J,Y);return Z[$]=Q.ignored?Q:this._rules.test($,J,LZ)}ignores($){return this._test($,this._ignoreCache,!1).ignored}createFilter(){return($)=>!this.ignores($)}filter($){return GH($).filter(this.createFilter())}test($){return this._test($,this._testCache,!0)}}var u3=($)=>new qH($),OA=($)=>E8($&&E8.convert($),$,HH),FH=()=>{let $=(J)=>/^\\\\\?\\/.test(J)||/["<>|\u0000-\u001F]+/u.test(J)?J:J.replace(/\\/g,"/");E8.convert=$;let Z=/^[a-z]:\//i;E8.isNotRelative=(J)=>Z.test(J)||UH(J)};if(typeof process<"u"&&process.platform==="win32")FH();IY.exports=u3;u3.default=u3;IY.exports.isPathValid=OA;o9(IY.exports,Symbol.for("setupWindows"),FH)});var RY=D0((vA)=>{vA.isInteger=($)=>{if(typeof $==="number")return Number.isInteger($);if(typeof $==="string"&&$.trim()!=="")return Number.isInteger(Number($));return!1};vA.find=($,Z)=>$.nodes.find((J)=>J.type===Z);vA.exceedsLimit=($,Z,J=1,Y)=>{if(Y===!1)return!1;if(!vA.isInteger($)||!vA.isInteger(Z))return!1;return(Number(Z)-Number($))/Number(J)>=Y};vA.escapeNode=($,Z=0,J)=>{let Y=$.nodes[Z];if(!Y)return;if(J&&Y.type===J||Y.type==="open"||Y.type==="close"){if(Y.escaped!==!0)Y.value="\\"+Y.value,Y.escaped=!0}};vA.encloseBrace=($)=>{if($.type!=="brace")return!1;if($.commas>>0+$.ranges>>0===0)return $.invalid=!0,!0;return!1};vA.isInvalidBrace=($)=>{if($.type!=="brace")return!1;if($.invalid===!0||$.dollar)return!0;if($.commas>>0+$.ranges>>0===0)return $.invalid=!0,!0;if($.open!==!0||$.close!==!0)return $.invalid=!0,!0;return!1};vA.isOpenOrClose=($)=>{if($.type==="open"||$.type==="close")return!0;return $.open===!0||$.close===!0};vA.reduce=($)=>$.reduce((Z,J)=>{if(J.type==="text")Z.push(J.value);if(J.type==="range")J.type="text";return Z},[]);vA.flatten=(...$)=>{let Z=[],J=(Y)=>{for(let Q=0;Q<Y.length;Q++){let X=Y[Q];if(Array.isArray(X)){J(X);continue}if(X!==void 0)Z.push(X)}return Z};return J($),Z}});var TY=D0((ic,NH)=>{var IH=RY();NH.exports=($,Z={})=>{let J=(Y,Q={})=>{let X=Z.escapeInvalid&&IH.isInvalidBrace(Q),K=Y.invalid===!0&&Z.escapeInvalid===!0,G="";if(Y.value){if((X||K)&&IH.isOpenOrClose(Y))return"\\"+Y.value;return Y.value}if(Y.value)return Y.value;if(Y.nodes)for(let B of Y.nodes)G+=J(B);return G};return J($)}});var SH=D0((sc,LH)=>{/*!
2
+ import{rh as hM,sh as DR,th as B_,uh as H_,vh as j_,wh as O_,xh as vX,yh as U_,zh as S_}from"./chunk-w9mdrb90.js";import{Ah as sP,Fh as M0}from"./chunk-qxtz0tfd.js";import{xi as vW}from"./chunk-prrrw8t8.js";import{$j as LY,$k as QB,Ak as QU,Bk as XU,Cj as e,Ck as VU,Dj as x1,Ek as _A,Fk as zj,Gk as o4,Hj as sJ,Hk as W_,Ik as P0,Jj as i5,Kj as vE,Lj as aD,Mj as _9,Mk as kO,Nj as yB,Nk as KU,Ok as zM,Pk as oX,Qj as M$,Qk as K2,Rj as p7,Rk as $Y,Sj as g0,Sk as n0,Tj as W2,Tk as Q$,Uj as m0,Vk as s0,Wj as qV,Wk as $C,Xj as I2,Xk as O0,Yj as cZ,Yk as $y,_k as C2,ak as SY,al as pX,bk as q6,bl as LW,ck as p4,cl as E2,dk as W1,dl as D1,ek as n1,el as b0,fk as b1,fl as B0,gk as K_,hk as AX,ik as IX,jk as G_,kk as WQ,lk as BQ,mk as SO,nk as jf,ok as Of,pk as zQ,qk as o1,rk as oZ,sk as dK,tk as _7,uk as _Q,vk as lO,wk as rO,xk as aO,yk as tO,zk as eO}from"./chunk-651fyxmn.js";import{gl as GQ,hl as ew}from"./chunk-0czxqcg7.js";import{Al as P9,Cl as f9,Fl as w0,Gl as U1,Hl as wJ,Il as A6,Jl as A8,Ml as $w,Nl as V6,Pl as q0,Ql as u,Rl as kw,Sl as L2,Tl as dz,sl as H3,tl as Rj,vl as yw,wl as MB,xl as V2,yl as k2,zl as p1}from"./chunk-6ba9fc92.js";import{$l as S0,Ul as wY,Vl as m8,Wl as m$,Xl as u1,_l as Yw}from"./chunk-7skp0dmg.js";import{Gn as W8,Hn as I8,Im as d8,cn as j$,dn as o0,en as w$,fn as G8,gn as hO,hm as gO,in as z0,kn as i2,ln as F7,nn as QQ,qn as FM,rn as DM,tn as pZ}from"./chunk-c4x99ayd.js";import{Qo as mZ}from"./chunk-8fn883z8.js";import{ip as e9,jp as s4,kp as $7,mp as V8}from"./chunk-tq258v8s.js";import{rp as Z9}from"./chunk-jfy6bfvv.js";import{sp as H2}from"./chunk-v0jnnpsz.js";import{eq as T8,fq as wM,qq as A9,rq as UP}from"./chunk-t7v8wzr9.js";import{Tq as $M,Uq as uP}from"./chunk-er5q8nhp.js";import{mr as m7}from"./chunk-351wfvhp.js";import{qr as w1,vr as tw,wr as X7}from"./chunk-yt6cfsdh.js";import{Cr as B3,yr as N1,zr as W3}from"./chunk-yja3y138.js";import{Or as o2,Pr as VX,Vr as P$,Wr as w8}from"./chunk-3nc9wy1m.js";import{Ds as q2}from"./chunk-56cty7nr.js";import{Fs as Tj}from"./chunk-thbjhgw0.js";import{Gs as S1,Is as BX,Ns as ZH,Qs as lY,Rs as kX,Ws as lw,Zs as Z$,bt as FJ,ct as a0,dt as h0,mt as Y0}from"./chunk-esjs9s9g.js";import{Bt as g8,Ct as V0,Gt as z2,nt as mY,pt as t8,rt as V7,vt as K7,yt as Z7}from"./chunk-b5x3zghc.js";import{Ht as av}from"./chunk-t1f7jeat.js";import{It as F}from"./chunk-tk6gjy9d.js";import{Jt as wX,Mt as Ez,Nt as gz,Pt as U6,_t as J_}from"./chunk-pkdk0ppc.js";import{Au as LP,Bu as SP,Cu as B2,fu as d_,hu as m,iu as IP,ju as F2,ku as A2,lu as cW,mu as NP,nu as X$,ou as W0,pu as H0,qu as q$,ru as x2,su as uW,tu as lW,uu as v2,vu as k1,wu as A0,xu as V$,yu as c_,zu as pW}from"./chunk-hrnx60em.js";import{Du as AP,Zu as M5}from"./chunk-bbznk59q.js";import{Iz as G3,Tz as hW}from"./chunk-01gtn79f.js";import{$H as V,$N as X_,AG as ey,AH as PB,AO as f0,BN as K0,FC as Y_,GE as p0,IJ as k8,KJ as rY,MO as XX,NE as H$,TF as MJ,UE as u0,ZF as ry,_N as Q_,aO as V_,bC as CX,bO as v7,cO as XO,dO as I_,eC as N2,eG as ay,fO as f7,hO as tY,iF as w2,iO as N_,jD as X0,jG as ty,oJ as y8,sO as n9,tO as $B,vD as h8,vO as L_,wH as _B,wO as Q3,yF as b}from"./chunk-meaa7wrs.js";import{fP as CK}from"./chunk-0ddhkapd.js";import{lP as a6,mP as D0,nP as R0,pP as d2,qP as i9,rP as s9}from"./chunk-fa03gsff.js";var DH=D0((Sc,IY)=>{function GH($){return Array.isArray($)?$:[$]}var sC=void 0,c3="",VH=" ",d3="\\",nC=/^\s+$/,rC=/(?:[^\\]|^)\\$/,aC=/^\\!/,tC=/^\\#/,eC=/\r?\n/g,$A=/^\.{0,2}\/|^\.{1,2}$/,ZA=/\/$/,p9="/",WH="node-ignore";if(typeof Symbol<"u")WH=Symbol.for("node-ignore");var BH=WH,o9=($,Z,J)=>{return Object.defineProperty($,Z,{value:J}),J},JA=/([0-z])-([0-z])/g,HH=()=>!1,YA=($)=>$.replace(JA,(Z,J,Y)=>J.charCodeAt(0)<=Y.charCodeAt(0)?Z:c3),QA=($)=>{let{length:Z}=$;return $.slice(0,Z-Z%2)},XA=[[/^\uFEFF/,()=>c3],[/((?:\\\\)*?)(\\?\s+)$/,($,Z,J)=>Z+(J.indexOf("\\")===0?VH:c3)],[/(\\+?)\s/g,($,Z)=>{let{length:J}=Z;return Z.slice(0,J-J%2)+VH}],[/[\\$.|*+(){^]/g,($)=>`\\${$}`],[/(?!\\)\?/g,()=>"[^/]"],[/^\//,()=>"^"],[/\//g,()=>"\\/"],[/^\^*\\\*\\\*\\\//,()=>"^(?:.*\\/)?"],[/^(?=[^^])/,function(){return!/\/(?!$)/.test(this)?"(?:^|\\/)":"^"}],[/\\\/\\\*\\\*(?=\\\/|$)/g,($,Z,J)=>Z+6<J.length?"(?:\\/[^\\/]+)*":"\\/.+"],[/(^|[^\\]+)(\\\*)+(?=.+)/g,($,Z,J)=>{let Y=J.replace(/\\\*/g,"[^\\/]*");return Z+Y}],[/\\\\\\(?=[$.|*+(){^])/g,()=>d3],[/\\\\/g,()=>d3],[/(\\)?\[([^\]/]*?)(\\*)($|\])/g,($,Z,J,Y,Q)=>Z===d3?`\\[${J}${QA(Y)}${Q}`:Q==="]"?Y.length%2===0?`[${YA(J)}${Y}]`:"[]":"[]"],[/(?:[^*])$/,($)=>/\/$/.test($)?`${$}$`:`${$}(?=$|\\/$)`]],VA=/(^|\\\/)?\\\*$/,LZ="regex",CY="checkRegex",KH="_",KA={[LZ]($,Z){return`${Z?`${Z}[^/]+`:"[^/]*"}(?=$|\\/$)`},[CY]($,Z){return`${Z?`${Z}[^/]*`:"[^/]*"}(?=$|\\/$)`}},GA=($)=>XA.reduce((Z,[J,Y])=>Z.replace(J,Y.bind($)),$),AY=($)=>typeof $==="string",WA=($)=>$&&AY($)&&!nC.test($)&&!rC.test($)&&$.indexOf("#")!==0,BA=($)=>$.split(eC).filter(Boolean);class jH{constructor($,Z,J,Y,Q,X){this.pattern=$,this.mark=Z,this.negative=Q,o9(this,"body",J),o9(this,"ignoreCase",Y),o9(this,"regexPrefix",X)}get regex(){let $=KH+LZ;if(this[$])return this[$];return this._make(LZ,$)}get checkRegex(){let $=KH+CY;if(this[$])return this[$];return this._make(CY,$)}_make($,Z){let J=this.regexPrefix.replace(VA,KA[$]),Y=this.ignoreCase?new RegExp(J,"i"):new RegExp(J);return o9(this,Z,Y)}}var HA=({pattern:$,mark:Z},J)=>{let Y=!1,Q=$;if(Q.indexOf("!")===0)Y=!0,Q=Q.substr(1);Q=Q.replace(aC,"!").replace(tC,"#");let X=GA(Q);return new jH($,Z,Q,J,Y,X)};class OH{constructor($){this._ignoreCase=$,this._rules=[]}_add($){if($&&$[BH]){this._rules=this._rules.concat($._rules._rules),this._added=!0;return}if(AY($))$={pattern:$};if(WA($.pattern)){let Z=HA($,this._ignoreCase);this._added=!0,this._rules.push(Z)}}add($){return this._added=!1,GH(AY($)?BA($):$).forEach(this._add,this),this._added}test($,Z,J){let Y=!1,Q=!1,X;this._rules.forEach((G)=>{let{negative:B}=G;if(Q===B&&Y!==Q||B&&!Y&&!Q&&!Z)return;if(!G[J].test($))return;Y=!B,Q=B,X=B?sC:G});let K={ignored:Y,unignored:Q};if(X)K.rule=X;return K}}var jA=($,Z)=>{throw new Z($)},E8=($,Z,J)=>{if(!AY($))return J(`path must be a string, but got \`${Z}\``,TypeError);if(!$)return J("path must not be empty",TypeError);if(E8.isNotRelative($))return J(`path should be a \`path.relative()\`d string, but got "${Z}"`,RangeError);return!0},UH=($)=>$A.test($);E8.isNotRelative=UH;E8.convert=($)=>$;class qH{constructor({ignorecase:$=!0,ignoreCase:Z=$,allowRelativePaths:J=!1}={}){o9(this,BH,!0),this._rules=new OH(Z),this._strictPathCheck=!J,this._initCache()}_initCache(){this._ignoreCache=Object.create(null),this._testCache=Object.create(null)}add($){if(this._rules.add($))this._initCache();return this}addPattern($){return this.add($)}_test($,Z,J,Y){let Q=$&&E8.convert($);return E8(Q,$,this._strictPathCheck?jA:HH),this._t(Q,Z,J,Y)}checkIgnore($){if(!ZA.test($))return this.test($);let Z=$.split(p9).filter(Boolean);if(Z.pop(),Z.length){let J=this._t(Z.join(p9)+p9,this._testCache,!0,Z);if(J.ignored)return J}return this._rules.test($,!1,CY)}_t($,Z,J,Y){if($ in Z)return Z[$];if(!Y)Y=$.split(p9).filter(Boolean);if(Y.pop(),!Y.length)return Z[$]=this._rules.test($,J,LZ);let Q=this._t(Y.join(p9)+p9,Z,J,Y);return Z[$]=Q.ignored?Q:this._rules.test($,J,LZ)}ignores($){return this._test($,this._ignoreCache,!1).ignored}createFilter(){return($)=>!this.ignores($)}filter($){return GH($).filter(this.createFilter())}test($){return this._test($,this._testCache,!0)}}var u3=($)=>new qH($),OA=($)=>E8($&&E8.convert($),$,HH),FH=()=>{let $=(J)=>/^\\\\\?\\/.test(J)||/["<>|\u0000-\u001F]+/u.test(J)?J:J.replace(/\\/g,"/");E8.convert=$;let Z=/^[a-z]:\//i;E8.isNotRelative=(J)=>Z.test(J)||UH(J)};if(typeof process<"u"&&process.platform==="win32")FH();IY.exports=u3;u3.default=u3;IY.exports.isPathValid=OA;o9(IY.exports,Symbol.for("setupWindows"),FH)});var RY=D0((vA)=>{vA.isInteger=($)=>{if(typeof $==="number")return Number.isInteger($);if(typeof $==="string"&&$.trim()!=="")return Number.isInteger(Number($));return!1};vA.find=($,Z)=>$.nodes.find((J)=>J.type===Z);vA.exceedsLimit=($,Z,J=1,Y)=>{if(Y===!1)return!1;if(!vA.isInteger($)||!vA.isInteger(Z))return!1;return(Number(Z)-Number($))/Number(J)>=Y};vA.escapeNode=($,Z=0,J)=>{let Y=$.nodes[Z];if(!Y)return;if(J&&Y.type===J||Y.type==="open"||Y.type==="close"){if(Y.escaped!==!0)Y.value="\\"+Y.value,Y.escaped=!0}};vA.encloseBrace=($)=>{if($.type!=="brace")return!1;if($.commas>>0+$.ranges>>0===0)return $.invalid=!0,!0;return!1};vA.isInvalidBrace=($)=>{if($.type!=="brace")return!1;if($.invalid===!0||$.dollar)return!0;if($.commas>>0+$.ranges>>0===0)return $.invalid=!0,!0;if($.open!==!0||$.close!==!0)return $.invalid=!0,!0;return!1};vA.isOpenOrClose=($)=>{if($.type==="open"||$.type==="close")return!0;return $.open===!0||$.close===!0};vA.reduce=($)=>$.reduce((Z,J)=>{if(J.type==="text")Z.push(J.value);if(J.type==="range")J.type="text";return Z},[]);vA.flatten=(...$)=>{let Z=[],J=(Y)=>{for(let Q=0;Q<Y.length;Q++){let X=Y[Q];if(Array.isArray(X)){J(X);continue}if(X!==void 0)Z.push(X)}return Z};return J($),Z}});var TY=D0((ic,NH)=>{var IH=RY();NH.exports=($,Z={})=>{let J=(Y,Q={})=>{let X=Z.escapeInvalid&&IH.isInvalidBrace(Q),K=Y.invalid===!0&&Z.escapeInvalid===!0,G="";if(Y.value){if((X||K)&&IH.isOpenOrClose(Y))return"\\"+Y.value;return Y.value}if(Y.value)return Y.value;if(Y.nodes)for(let B of Y.nodes)G+=J(B);return G};return J($)}});var SH=D0((sc,LH)=>{/*!
3
3
  * is-number <https://github.com/jonschlinkert/is-number>
4
4
  *
5
5
  * Copyright (c) 2014-present, Jon Schlinkert.
@@ -7531,7 +7531,7 @@ For full type signatures, all available fields, and more examples:
7531
7531
  - Cannot modify the permission system
7532
7532
  - Tool output truncated at 50KB / 2000 lines
7533
7533
  - Prefer small, composable extensions over monolithic ones
7534
- `}}}catch($){if($ instanceof ReferenceError)return Zz();throw $}}var pE=lE(),oE=Y0.create({service:"skill.builtin"}),Yz=V.fn("Skill.extractBuiltinBundle")(function*($){let Z=Jz.join(FJ.data,"builtin_skills",S1),J=Jz.join(Z,".extracted");return yield*GX({fsys:$,bundle:pE,root:Z,marker:J,markerContent:S1,skipIfPresent:!BX,onExtracted:(Y)=>oE.info("extracted builtin skills",{root:Y})})});var DJ=Y0.create({service:"skill"}),nE=[".claude",".agents",".codex",".opencode"],Qz="skills/**/SKILL.md",rE="{skill,skills}/**/SKILL.md",HX="**/SKILL.md",Xz=F.object({name:F.string(),description:F.string(),location:F.string(),content:F.string(),hidden:F.boolean().optional()}),aE=q2.create("SkillInvalidError",F.object({path:F.string(),message:F.string().optional(),issues:F.custom().optional()})),tE=q2.create("SkillNameMismatchError",F.object({path:F.string(),expected:F.string(),actual:F.string()})),eE=V.fnUntraced(function*($,Z,J){let Y=yield*V.tryPromise({try:()=>_9.parse(Z),catch:(X)=>X}).pipe(V.catch(V.fnUntraced(function*(X){let K=_9.FrontmatterError.isInstance(X)?X.data.message:`Failed to parse skill ${Z}`,{Session:G}=yield*V.promise(()=>import("./chunk-7pqevqry.js"));yield*J.publish(G.Event.Error,{error:new q2.Unknown({message:K}).toObject()}),DJ.error("failed to load skill",{skill:Z,err:X});return})));if(!Y)return;let Q=Xz.pick({name:!0,description:!0,hidden:!0}).safeParse(Y.data);if(!Q.success)return;if($.skills[Q.data.name])DJ.warn("duplicate skill name",{name:Q.data.name,existing:$.skills[Q.data.name].location,duplicate:Z});$.dirs.add(h7.dirname(Z)),$.skills[Q.data.name]={name:Q.data.name,description:Q.data.description,location:Z,content:Y.content,hidden:Q.data.hidden}}),z9=V.fnUntraced(function*($,Z,J,Y){let Q=yield*V.tryPromise({try:()=>g8.scan(J,{cwd:Z,absolute:!0,include:"file",symlink:!0,dot:Y?.dot}),catch:(X)=>X}).pipe(V.catch((X)=>{if(!Y?.scope)return V.die(X);return DJ.error(`failed to scan ${Y.scope} skills`,{dir:Z,error:X}),V.succeed([])}));for(let X of Q)$.matches.add(X),$.dirs.add(h7.dirname(X))}),$g=V.fnUntraced(function*($,Z,J,Y,Q){let X={matches:new Set,dirs:new Set};if(!h0.QITQODE_DISABLE_BUILTIN_SKILLS){let B=yield*Yz(J).pipe(V.catch(()=>V.succeed(void 0)));if(B&&(yield*J.isDir(B)))yield*z9(X,B,HX,{scope:"builtin"})}if(!h0.QITQODE_DISABLE_COMPOSE_SKILLS){let B=yield*eD(J).pipe(V.catch(()=>V.succeed(void 0)));if(B&&(yield*J.isDir(B)))yield*z9(X,B,HX,{scope:"compose"})}if(!h0.QITQODE_DISABLE_EXTERNAL_SKILLS){let B=nE.filter((W)=>{if(W===".claude"&&h0.QITQODE_DISABLE_CLAUDE_CODE_SKILLS)return!1;if(W===".codex"&&h0.QITQODE_DISABLE_CODEX_SKILLS)return!1;if(W===".opencode"&&h0.QITQODE_DISABLE_OPENCODE_SKILLS)return!1;return!0});for(let W of B){let O=h7.join(a0.Path.home,W);if(!(yield*J.isDir(O)))continue;yield*z9(X,O,Qz,{dot:!0,scope:"global"})}let H=yield*J.up({targets:B,start:Y,stop:Q}).pipe(V.catch(()=>V.succeed([])));for(let W of H)yield*z9(X,W,Qz,{dot:!0,scope:"project"})}let K=yield*$.directories();for(let B of K)yield*z9(X,B,rE);let G=yield*$.get();for(let B of G.skills?.paths??[]){let H=B.startsWith("~/")?h7.join(iE.homedir(),B.slice(2)):B,W=h7.isAbsolute(H)?H:h7.join(Y,H);if(!(yield*J.isDir(W))){DJ.warn("skill path not found",{path:W});continue}yield*z9(X,W,HX)}for(let B of G.skills?.urls??[]){let H=yield*Z.pull(B);for(let W of H)yield*z9(X,W,HX)}return{matches:Array.from(X.matches),dirs:Array.from(X.dirs)}}),Zg=V.fnUntraced(function*($,Z,J){yield*V.forEach(Z.matches,(Y)=>eE($,Y,J),{concurrency:16,discard:!0}),DJ.info("init",{count:Object.keys($.skills).length})});class jX extends X0.Service()("@qitqode/Skill"){}var Vz=b.effect(jX,V.gen(function*(){let $=yield*y6.Service,Z=yield*B0.Service,J=yield*e.Service,Y=yield*V0.Service,Q=yield*u.make(V.fn("Skill.discovery")(function*(O){return yield*$g(Z,$,Y,O.directory,O.worktree)})),X=yield*u.make(V.fn("Skill.state")(function*(O){let j={skills:{},dirs:new Set};return yield*Zg(j,yield*u.get(Q),J),j})),K=V.fn("Skill.get")(function*(O){return(yield*u.get(X)).skills[O]}),G=V.fn("Skill.all")(function*(){let O=yield*u.get(X);return Object.values(O.skills)}),B=V.fn("Skill.dirs")(function*(){return(yield*u.get(Q)).dirs}),H=V.fn("Skill.available")(function*(O){let j=yield*u.get(X),U=Object.values(j.skills).filter((q)=>!q.hidden);if(U=U.toSorted((q,z)=>q.name.localeCompare(z.name)),!O)return U;return U.filter((q)=>P0.evaluate("skill",q.name,O.permission).action!=="deny")}),W=V.fn("Skill.reload")(function*(){yield*u.invalidate(Q),yield*u.invalidate(X)});return jX.of({get:K,all:G,dirs:B,available:H,reload:W})})),Jg=Vz.pipe(b.provide(y6.defaultLayer),b.provide(B0.defaultLayer),b.provide(e.layer),b.provide(V0.defaultLayer));function Yg($,Z){if($.length===0)return"No skills are currently available.";if(Z.verbose)return["<available_skills>",...$.sort((J,Y)=>J.name.localeCompare(Y.name)).flatMap((J)=>[" <skill>",` <name>${J.name}</name>`,` <description>${J.description}</description>`,` <location>${sE(J.location).href}</location>`," </skill>"]),"</available_skills>"].join(`
7534
+ `}}}catch($){if($ instanceof ReferenceError)return Zz();throw $}}var pE=lE(),oE=Y0.create({service:"skill.builtin"}),Yz=V.fn("Skill.extractBuiltinBundle")(function*($){let Z=Jz.join(FJ.data,"builtin_skills",S1),J=Jz.join(Z,".extracted");return yield*GX({fsys:$,bundle:pE,root:Z,marker:J,markerContent:S1,skipIfPresent:!BX,onExtracted:(Y)=>oE.info("extracted builtin skills",{root:Y})})});var DJ=Y0.create({service:"skill"}),nE=[".claude",".agents",".codex",".opencode"],Qz="skills/**/SKILL.md",rE="{skill,skills}/**/SKILL.md",HX="**/SKILL.md",Xz=F.object({name:F.string(),description:F.string(),location:F.string(),content:F.string(),hidden:F.boolean().optional()}),aE=q2.create("SkillInvalidError",F.object({path:F.string(),message:F.string().optional(),issues:F.custom().optional()})),tE=q2.create("SkillNameMismatchError",F.object({path:F.string(),expected:F.string(),actual:F.string()})),eE=V.fnUntraced(function*($,Z,J){let Y=yield*V.tryPromise({try:()=>_9.parse(Z),catch:(X)=>X}).pipe(V.catch(V.fnUntraced(function*(X){let K=_9.FrontmatterError.isInstance(X)?X.data.message:`Failed to parse skill ${Z}`,{Session:G}=yield*V.promise(()=>import("./chunk-tnn7hm4v.js"));yield*J.publish(G.Event.Error,{error:new q2.Unknown({message:K}).toObject()}),DJ.error("failed to load skill",{skill:Z,err:X});return})));if(!Y)return;let Q=Xz.pick({name:!0,description:!0,hidden:!0}).safeParse(Y.data);if(!Q.success)return;if($.skills[Q.data.name])DJ.warn("duplicate skill name",{name:Q.data.name,existing:$.skills[Q.data.name].location,duplicate:Z});$.dirs.add(h7.dirname(Z)),$.skills[Q.data.name]={name:Q.data.name,description:Q.data.description,location:Z,content:Y.content,hidden:Q.data.hidden}}),z9=V.fnUntraced(function*($,Z,J,Y){let Q=yield*V.tryPromise({try:()=>g8.scan(J,{cwd:Z,absolute:!0,include:"file",symlink:!0,dot:Y?.dot}),catch:(X)=>X}).pipe(V.catch((X)=>{if(!Y?.scope)return V.die(X);return DJ.error(`failed to scan ${Y.scope} skills`,{dir:Z,error:X}),V.succeed([])}));for(let X of Q)$.matches.add(X),$.dirs.add(h7.dirname(X))}),$g=V.fnUntraced(function*($,Z,J,Y,Q){let X={matches:new Set,dirs:new Set};if(!h0.QITQODE_DISABLE_BUILTIN_SKILLS){let B=yield*Yz(J).pipe(V.catch(()=>V.succeed(void 0)));if(B&&(yield*J.isDir(B)))yield*z9(X,B,HX,{scope:"builtin"})}if(!h0.QITQODE_DISABLE_COMPOSE_SKILLS){let B=yield*eD(J).pipe(V.catch(()=>V.succeed(void 0)));if(B&&(yield*J.isDir(B)))yield*z9(X,B,HX,{scope:"compose"})}if(!h0.QITQODE_DISABLE_EXTERNAL_SKILLS){let B=nE.filter((W)=>{if(W===".claude"&&h0.QITQODE_DISABLE_CLAUDE_CODE_SKILLS)return!1;if(W===".codex"&&h0.QITQODE_DISABLE_CODEX_SKILLS)return!1;if(W===".opencode"&&h0.QITQODE_DISABLE_OPENCODE_SKILLS)return!1;return!0});for(let W of B){let O=h7.join(a0.Path.home,W);if(!(yield*J.isDir(O)))continue;yield*z9(X,O,Qz,{dot:!0,scope:"global"})}let H=yield*J.up({targets:B,start:Y,stop:Q}).pipe(V.catch(()=>V.succeed([])));for(let W of H)yield*z9(X,W,Qz,{dot:!0,scope:"project"})}let K=yield*$.directories();for(let B of K)yield*z9(X,B,rE);let G=yield*$.get();for(let B of G.skills?.paths??[]){let H=B.startsWith("~/")?h7.join(iE.homedir(),B.slice(2)):B,W=h7.isAbsolute(H)?H:h7.join(Y,H);if(!(yield*J.isDir(W))){DJ.warn("skill path not found",{path:W});continue}yield*z9(X,W,HX)}for(let B of G.skills?.urls??[]){let H=yield*Z.pull(B);for(let W of H)yield*z9(X,W,HX)}return{matches:Array.from(X.matches),dirs:Array.from(X.dirs)}}),Zg=V.fnUntraced(function*($,Z,J){yield*V.forEach(Z.matches,(Y)=>eE($,Y,J),{concurrency:16,discard:!0}),DJ.info("init",{count:Object.keys($.skills).length})});class jX extends X0.Service()("@qitqode/Skill"){}var Vz=b.effect(jX,V.gen(function*(){let $=yield*y6.Service,Z=yield*B0.Service,J=yield*e.Service,Y=yield*V0.Service,Q=yield*u.make(V.fn("Skill.discovery")(function*(O){return yield*$g(Z,$,Y,O.directory,O.worktree)})),X=yield*u.make(V.fn("Skill.state")(function*(O){let j={skills:{},dirs:new Set};return yield*Zg(j,yield*u.get(Q),J),j})),K=V.fn("Skill.get")(function*(O){return(yield*u.get(X)).skills[O]}),G=V.fn("Skill.all")(function*(){let O=yield*u.get(X);return Object.values(O.skills)}),B=V.fn("Skill.dirs")(function*(){return(yield*u.get(Q)).dirs}),H=V.fn("Skill.available")(function*(O){let j=yield*u.get(X),U=Object.values(j.skills).filter((q)=>!q.hidden);if(U=U.toSorted((q,z)=>q.name.localeCompare(z.name)),!O)return U;return U.filter((q)=>P0.evaluate("skill",q.name,O.permission).action!=="deny")}),W=V.fn("Skill.reload")(function*(){yield*u.invalidate(Q),yield*u.invalidate(X)});return jX.of({get:K,all:G,dirs:B,available:H,reload:W})})),Jg=Vz.pipe(b.provide(y6.defaultLayer),b.provide(B0.defaultLayer),b.provide(e.layer),b.provide(V0.defaultLayer));function Yg($,Z){if($.length===0)return"No skills are currently available.";if(Z.verbose)return["<available_skills>",...$.sort((J,Y)=>J.name.localeCompare(Y.name)).flatMap((J)=>[" <skill>",` <name>${J.name}</name>`,` <description>${J.description}</description>`,` <location>${sE(J.location).href}</location>`," </skill>"]),"</available_skills>"].join(`
7535
7535
  `);return["## Available Skills",...$.toSorted((J,Y)=>J.name.localeCompare(Y.name)).map((J)=>`- **${J.name}**: ${J.description}`)].join(`
7536
7536
  `)}var _W=i0("skill",V.gen(function*(){let $=(yield*M0.toolDescriptionEffect("skill"))??"",Z=yield*Y$.Service,J=yield*d$.Service;return{description:$,parameters:Kj,execute:(Y,Q)=>V.gen(function*(){let X=yield*Z.get(Y.name);if(!X){let O=(yield*Z.all()).map((j)=>j.name).join(", ");throw Error(`Skill "${Y.name}" not found. Available skills: ${O||"none"}`)}yield*Q.ask({permission:"skill",patterns:[Y.name],always:[Y.name],metadata:{}});let K=Kz.dirname(X.location),G=Qg(K).href,B=10,H=yield*J.files({cwd:K,follow:!1,hidden:!0,signal:Q.abort}).pipe(f7((W)=>!W.includes("SKILL.md")),v7((W)=>Kz.resolve(K,W)),tY(B),n9,V.map((W)=>[...W].map((O)=>`<file>${O}</file>`).join(`
7537
7537
  `)));return{title:`Loaded skill: ${X.name}`,output:[`<skill_content name="${X.name}">`,`# Skill: ${X.name}`,"",X.content.trim(),"",`Base directory for this skill: ${G}`,"Relative paths in this skill (e.g., scripts/, reference/) are relative to this base directory.","Note: file list is sampled.","","<skill_files>",H,"</skill_files>","</skill_content>"].join(`
@@ -8089,7 +8089,7 @@ If you repeat the same output again, the session will be terminated.
8089
8089
  `)})});function qy($){if(!$.lastFinished)return;let Z=[];for(let Q=$.msgs.length-1;Q>=0&&Z.length<KB;Q--){let X=$.msgs[Q];if(X.info.role!=="assistant"||!X.info.finish)continue;let K=oJ(X.parts);if(K===void 0)break;Z.push(K)}if(!(Z.length===KB&&Z.every((Q)=>Q===Z[0])))return;let Y=$.msgs.findLast((Q)=>Q.info.role==="user");if(!Y||Y.parts.some((Q)=>Q.type==="text"&&Q.text?.includes("repeating the same action")))return;Y.parts.push({id:m0.ascending(),messageID:Y.info.id,sessionID:$.sessionID,type:"text",synthetic:!0,text:["<system-reminder>",`Your last ${KB} steps have been identical \u2014 you appear to be`,"repeating the same action without making progress. Stop and reconsider:","the current approach is not working. Try a different strategy, use a","different tool, or if you are blocked, explain the blocker to the user","instead of repeating the same step again.","</system-reminder>"].join(`
8090
8090
  `)})}var GB=Y0.create({service:"auto-dream"}),WB=86400000,km=7,Em=30,zy=1e4,BB="Auto Dream",HB="Auto Distill",Fy=0,Dy=0,_y=["Run one automatic dream memory consolidation pass for the current project.","","Use the memory files as the working index and the raw qitqode trajectory database as the source of truth.","Use bash for read-only SQLite and filesystem inspection. Do not modify the database.","Consolidate only durable, verified information into project memory."].join(`
8091
8091
  `),Py=["Run one automatic distill pass for the current project.","","Review the past month of sessions and identify repeated manual workflows worth packaging.","Use the raw qitqode trajectory database as the source of truth and memory files to spot cross-session patterns.","Inventory existing skills, agents, and commands first so you reuse or extend instead of duplicating.","Use bash for read-only SQLite and filesystem inspection. Do not modify the database.","Produce a compact shortlist, then create only the high-confidence missing assets."].join(`
8092
- `);function My($){return V.gen(function*(){if(!$.enabled)return!1;let Z=$.intervalDays*WB,J=yield*V.sync(()=>w0.use((X)=>X.select({time_created:V2.time_created}).from(V2).where(z0(V2.title,$.title)).orderBy(I8(V2.time_created)).limit(1).get())),Y=Date.now(),Q=J?Y-J.time_created:1/0;if(!J){let X=yield*V.sync(()=>w0.use((K)=>K.select({time_created:V2.time_created}).from(V2).where(pZ(V2.parent_id)).orderBy(W8(V2.time_created)).limit(1).get()));if(!X||Y-X.time_created<Z)return GB.info(`auto-${$.label} skipped \u2014 project too young`,{projectAge:X?Math.round((Y-X.time_created)/WB)+"d":"empty",interval:$.intervalDays+"d"}),!1}if(Q<Z)return GB.info(`auto-${$.label} skipped \u2014 last run too recent`,{lastRunAgo:Math.round(Q/WB)+"d",interval:$.intervalDays+"d"}),!1;return GB.info(`auto-${$.label} triggering`,{lastRun:J?new Date(J.time_created).toISOString():"never",interval:$.intervalDays+"d"}),!0})}function yy($){let Z=$.dream?.auto!==!1;if(!Z)return V.succeed(!1);let J=Date.now();if(J-Fy<zy)return V.succeed(!1);Fy=J;let Y=$.dream?.interval_days??km;return My({enabled:Z,intervalDays:Y,title:BB,label:"dream"})}function wy($){let Z=$.distill?.auto!==!1;if(!Z)return V.succeed(!1);let J=Date.now();if(J-Dy<zy)return V.succeed(!1);Dy=J;let Y=$.distill?.interval_days??Em;return My({enabled:Z,intervalDays:Y,title:HB,label:"distill"})}var Cy=V.fnUntraced(function*($){let Z=yield*$.config.get(),J=yield*yy(Z).pipe(V.catch(()=>V.succeed(!1))),Y=yield*wy(Z).pipe(V.catch(()=>V.succeed(!1))),Q={providerID:$.lastUser.model.providerID,modelID:$.lastUser.model.modelID};if(!J&&!Y)return;let{AppRuntime:X}=yield*V.promise(()=>import("./chunk-zafrxr1q.js"));if(J)X.runPromise(E2.use((K)=>V.gen(function*(){let G=yield*K.create({title:BB});yield*(yield*$.promptServiceTag).prompt({sessionID:G.id,agent:"dream",model:Q,parts:[{type:"text",text:_y}]})}))).catch((K)=>$.log.error("auto-dream prompt failed",{error:String(K)}));if(Y)X.runPromise(E2.use((K)=>V.gen(function*(){let G=yield*K.create({title:HB});yield*(yield*$.promptServiceTag).prompt({sessionID:G.id,agent:"distill",model:Q,parts:[{type:"text",text:Py}]})}))).catch((K)=>$.log.error("auto-distill prompt failed",{error:String(K)}))});var hm=($)=>$.pipe(V.catchDefect((Z)=>Z instanceof M0.BackendAuthRejectedError?V.succeed(void 0):V.die(Z))),jB=($)=>hm(V.promise(()=>M0.resolvePrompt($))).pipe(V.map((Z)=>Z??"")),Ay=V.gen(function*(){let $=yield*jB("session/build-switch"),Z=yield*jB("session/max-steps"),J=yield*jB("session/compose");return{buildSwitch:$,maxSteps:Z,promptCompose:J}});var Iy=N1.create({service:"session.prompt"}),vm=Y0.create({service:"session.prompt"});function Ny($,Z,J,Y){return V.gen(function*(){let{bus:Q,status:X,sessions:K,agents:G,provider:B,processor:H,prune:W,checkpoint:O,compaction:j,config:U,plugin:q,permission:z,fsys:A,registry:D,scope:_,instruction:w,state:P,goal:N,taskGateState:L,taskRegistry:T,revert:h,summary:x,sys:v,llm:I,actorRegistry:S,inbox:E}=yield*rV,y=yield*Ay,R=y.buildSwitch,k=y.maxSteps,i=y.promptCompose,d=(G0,Q0,s)=>iM(B,Q,G0,Q0,s),c=(G0,Q0)=>nM(K,G0,Q0),o=VB(K),p=1024,J0=new class extends Set{add(G0){if(super.add(G0),this.size>1024){let Q0=this.values().next().value;if(Q0!==void 0)this.delete(Q0)}return this}},t=(G0)=>ZB({getOps:$,...G0}),f=tM({agents:G,provider:B,llm:I,sessions:K,elog:Iy}),a=eM({sessions:K,fsys:A,buildSwitch:R,promptCompose:i});return{runLoop:V.fn("SessionPrompt.run")(function*(G0,Q0,s){let j0=yield*u.context,r=Iy.with({sessionID:G0}),Z0,_0=0,C0=yield*K.get(G0),L0,$2,O2=Q0??"main",e2=lM({sessionID:G0,agentID:O2,task_id:s,plugin:q,bus:Q,prune:W,scope:_}),{cancellation:L$,agentMetrics:r$,publishAgentRequest:f$,schedulePrune:K$}=e2,e0=uM({sessionID:G0,agentID:O2,task_id:s,session:C0,cancellation:L$,plugin:q});return yield*V.gen(function*(){yield*e2.before;let C1=(y0,c0)=>eV(SM(y0,c0,O0.parts(c0.id))),G$=!1,v1=jy({sessionID:G0,bus:Q,appendSyntheticUserTurn:o,slog:r}),D$=Hy({sessionID:G0,sessions:K,bus:Q,appendSyntheticUserTurn:o,slog:r}),{autoContinueOutputLength:Z8,autoContinueInvalidOutput:VY,autoRetryStructuredOutput:J8,handleTextRepeat:y3,writeContentFilterError:KY,writeModelError:G2}=D$,l0=rM({sessionID:G0,agentID:Q0,agents:G,taskGateState:L,taskRegistry:T,appendSyntheticUserTurn:o,slog:r}),b2=aM({sessionID:G0,agentID:Q0,session:C0,goal:N,bus:Q,appendSyntheticUserTurn:o,slog:r});while(!0){if(!Q0||Q0==="main")yield*X.set(G0,{type:"busy"});yield*E.drain(G0,Q0??"main").pipe(V.ignore),yield*r.info("loop",{step:_0});let y0=yield*O0.filterCompactedEffect(G0,{contextFrom:C0.contextFrom,contextWatermark:C0.contextWatermark,agentID:Q0??"main"}),c0,d9,O1,G6,W$,u6=[];for(let t0=y0.length-1;t0>=0;t0--){let _$=y0[t0];if(!c0&&_$.info.role==="user")c0=_$.info,d9=_$;if(!O1&&_$.info.role==="assistant")O1=_$.info,G6=_$;if(!W$&&_$.info.role==="assistant"&&_$.info.finish)W$=_$.info;if(c0&&W$)break;if(!W$){let c9=_$.parts.filter((_8)=>_8.type==="subtask");u6.push(...c9)}}if(!c0)throw Error("No user message found in stream. This should never happen.");yield*Oy({sessionID:G0,msgs:y0,checkpoint:O,config:U});let w3=G6?.parts.some((t0)=>t0.type==="tool"&&!t0.metadata?.providerExecuted)??!1;if(O1?.finish==="length"&&!w3&&c0.id<O1.id&&(yield*Z8({lastUser:c0,assistant:O1})))continue;if(O1){let t0=a5({phase:"existing-assistant",lastUser:c0,assistant:O1,parts:G6?.parts??[]});if(t0.type==="filtered"){yield*KY({assistant:O1}),yield*r.info("exiting loop",{classification:t0.type});break}if(t0.type==="failed"){yield*G2({assistant:O1,reason:t0.reason}),yield*r.info("exiting loop",{classification:t0.type,reason:t0.reason});break}if(t0.type==="think-only"||t0.type==="invalid"){let _$=t0.type==="invalid"?t0.reason:"think-only";if(yield*VY({lastUser:c0,assistant:O1,reason:_$}))continue;yield*r.info("exiting loop",{classification:t0.type});break}if(t0.type==="final"&&t0.degraded)yield*r.warn("degraded final on abnormal finish",{finish:O1.finish});if(t0.type!=="continue"){if(yield*l0(c0))continue;if(yield*b2(c0))continue;yield*r.info("exiting loop",{classification:t0.type});break}}if(_0++,_0===1)yield*f({session:C0,modelID:c0.model.modelID,providerID:c0.model.providerID,history:y0}).pipe(V.ignore,V.forkIn(_));if(_0===1&&!C0.parentID)yield*Cy({config:U,lastUser:c0,promptServiceTag:Y,log:vm});let t$=yield*d(c0.model.providerID,c0.model.modelID,G0);$2=t$,L0=W$;let z$=u6.pop();if(z$?.type==="subtask"){yield*t({task:z$,model:t$,lastUser:c0,sessionID:G0,session:C0,msgs:y0});continue}let l6=d9;if(l6?.parts.some((t0)=>t0.type==="compaction")){let t0=l6.parts.find((_8)=>_8.type==="compaction"),_$=yield*K.messages({sessionID:G0,agentID:c0.agentID??"main"});if((yield*j.process({parentID:c0.id,messages:_$,sessionID:G0,auto:t0?.auto??!1,overflow:t0?.overflow,agentID:c0.agentID}))==="stop")break;continue}yield*Uy({sessionID:G0,msgs:y0,lastFinished:W$,model:t$,config:U}),qy({sessionID:G0,msgs:y0,lastFinished:W$});let z8=yield*G.get(c0.agent),MZ=z8?.native===!0&&z8?.hidden===!0;if(!G$&&!MZ&&W$&&W$.tokens){let t0=yield*$();yield*W.fireCheckpoints({sessionID:G0,model:t$,tokens:W$.tokens,promptOps:t0,agentID:c0.agentID}).pipe(V.ignore)}if(!G$&&W$&&W$.tokens){if(yield*dM({config:U,checkpoint:O,compaction:j,prune:W},{sessionID:G0,lastFinished:W$,lastUser:c0,model:t$,msgs:y0,isBoundedComputation:MZ})){G$=!0;continue}}if(G$=!1,!z8)throw yield*t5(G,Q,c0.agent,G0);let x8=z8.steps??1/0,I0=_0>=x8;y0=yield*a({messages:y0,agent:z8,session:C0});let r0=J3({sessionID:G0,parentID:c0.id,agentID:c0.agentID,agent:z8.name,variant:c0.model.variant,cwd:j0.directory,root:j0.worktree,modelID:t$.id,providerID:t$.providerID});yield*K.updateMessage(r0);let y2=yield*H.create({assistantMessage:r0,sessionID:G0,model:t$,agentMetrics:r$}),p6=yield*V.gen(function*(){let t0={value:Z0},_$=yield*RM({sessionID:G0,resolvedAgentID:O2,step:_0,task_id:s,lastUser:c0,lastFinished:W$,msgs:y0,agent:z8,session:C0,model:t$,handle:y2,structured:t0,resolveTools:Z,createStructuredOutputTool:J,summary:x,scope:_,plugin:q}),{tools:c9,format:_8,query:C3}=_$,{cancelledByPlugin:A3,withUserQueryPost:I3}=TM({sessionID:G0,agentID:O2,step:_0,lastUser:c0,msgs:y0,query:C3,handle:y2,plugin:q,sessions:K,cancellation:L$,trajectoryForStep:C1}),N3=V.fnUntraced(function*(u9){if(u9==="continue"&&(yield*Z8({lastUser:c0,assistant:y2.message})))return"continue";if(u9==="text-repeat"){if(yield*y3({lastUser:c0}))return"continue";return"break"}if(t0.value!==void 0)return Z0=t0.value,y2.message.structured=t0.value,y2.message.finish=y2.message.finish??"stop",yield*K.updateMessage(y2.message),"break";let m1=a5({phase:"after-process",lastUser:c0,assistant:y2.message,parts:O0.parts(y2.message.id),processResult:u9});if(m1.type==="filtered")return yield*KY({assistant:y2.message}),"break";if(m1.type==="failed")return yield*G2({assistant:y2.message,reason:m1.reason}),"break";if(m1.type!=="continue"&&!y2.message.error&&_8.type==="json_schema"){if(yield*J8({lastUser:c0,assistant:y2.message}))return"continue";return"break"}if((m1.type==="think-only"||m1.type==="invalid")&&_8.type!=="json_schema"){let L3=m1.type==="invalid"?m1.reason:"think-only";if(yield*VY({lastUser:c0,assistant:y2.message,reason:L3}))return"continue";return"break"}if(m1.type==="final"&&m1.degraded)yield*r.warn("degraded final on abnormal finish",{finish:y2.message.finish});if(u9==="stop")return"break";return}),yZ=yield*vM({sessionID:G0,lastUser:c0,agent:z8,session:C0,model:t$,msgs:y0,tools:c9,format:_8,handle:y2,isLastStep:I0,task_id:s,instructionsNotified:J0,maxStepsText:k,actorRegistry:S,bus:Q,config:U,instruction:w,llm:I,registry:D,status:X,sys:v,cancelledByPlugin:A3,withUserQueryPost:I3,slog:r});if(yZ.kind==="break")return"break";let GY=yield*N3(yZ.result);if(GY)return GY;if(yZ.result==="overflow")yield*cM({config:U,checkpoint:O,compaction:j,prune:W},{sessionID:G0,lastUser:c0,model:t$,msgs:y0,isBoundedComputation:MZ});return"continue"}).pipe(V.ensuring(w.clear(y2.message.id))),Q8=yield*v1.check({lastUser:c0,completedParts:O0.parts(y2.message.id)});if(Q8==="terminate")break;if(Q8==="recovered")continue;if(p6==="break"){if(yield*l0(c0))continue;if(yield*b2(c0))continue;break}continue}let f1=yield*$();if($2&&L0)yield*K$({model:$2,lastFinished:L0,promptOps:f1});let a$=yield*c(G0,Q0),c6=a$.info.role==="assistant"&&!!a$.info.error,Y8=yield*K.findMessage(G0,(y0)=>y0.info.role==="user",{agentID:"*"});return yield*f$(c6?"error":"completed",N2.isSome(Y8)?Y8.value.info.agent:a$.info.agent),a$}).pipe((C1)=>e5(G0,Q,C1),V.onExit(e0),V.orDie)}),lastAssistant:c}})}import Ly from"path";var fm=new TextEncoder,OB=new TextDecoder,mm=($)=>`
8092
+ `);function My($){return V.gen(function*(){if(!$.enabled)return!1;let Z=$.intervalDays*WB,J=yield*V.sync(()=>w0.use((X)=>X.select({time_created:V2.time_created}).from(V2).where(z0(V2.title,$.title)).orderBy(I8(V2.time_created)).limit(1).get())),Y=Date.now(),Q=J?Y-J.time_created:1/0;if(!J){let X=yield*V.sync(()=>w0.use((K)=>K.select({time_created:V2.time_created}).from(V2).where(pZ(V2.parent_id)).orderBy(W8(V2.time_created)).limit(1).get()));if(!X||Y-X.time_created<Z)return GB.info(`auto-${$.label} skipped \u2014 project too young`,{projectAge:X?Math.round((Y-X.time_created)/WB)+"d":"empty",interval:$.intervalDays+"d"}),!1}if(Q<Z)return GB.info(`auto-${$.label} skipped \u2014 last run too recent`,{lastRunAgo:Math.round(Q/WB)+"d",interval:$.intervalDays+"d"}),!1;return GB.info(`auto-${$.label} triggering`,{lastRun:J?new Date(J.time_created).toISOString():"never",interval:$.intervalDays+"d"}),!0})}function yy($){let Z=$.dream?.auto!==!1;if(!Z)return V.succeed(!1);let J=Date.now();if(J-Fy<zy)return V.succeed(!1);Fy=J;let Y=$.dream?.interval_days??km;return My({enabled:Z,intervalDays:Y,title:BB,label:"dream"})}function wy($){let Z=$.distill?.auto!==!1;if(!Z)return V.succeed(!1);let J=Date.now();if(J-Dy<zy)return V.succeed(!1);Dy=J;let Y=$.distill?.interval_days??Em;return My({enabled:Z,intervalDays:Y,title:HB,label:"distill"})}var Cy=V.fnUntraced(function*($){let Z=yield*$.config.get(),J=yield*yy(Z).pipe(V.catch(()=>V.succeed(!1))),Y=yield*wy(Z).pipe(V.catch(()=>V.succeed(!1))),Q={providerID:$.lastUser.model.providerID,modelID:$.lastUser.model.modelID};if(!J&&!Y)return;let{AppRuntime:X}=yield*V.promise(()=>import("./chunk-n6fh34xx.js"));if(J)X.runPromise(E2.use((K)=>V.gen(function*(){let G=yield*K.create({title:BB});yield*(yield*$.promptServiceTag).prompt({sessionID:G.id,agent:"dream",model:Q,parts:[{type:"text",text:_y}]})}))).catch((K)=>$.log.error("auto-dream prompt failed",{error:String(K)}));if(Y)X.runPromise(E2.use((K)=>V.gen(function*(){let G=yield*K.create({title:HB});yield*(yield*$.promptServiceTag).prompt({sessionID:G.id,agent:"distill",model:Q,parts:[{type:"text",text:Py}]})}))).catch((K)=>$.log.error("auto-distill prompt failed",{error:String(K)}))});var hm=($)=>$.pipe(V.catchDefect((Z)=>Z instanceof M0.BackendAuthRejectedError?V.succeed(void 0):V.die(Z))),jB=($)=>hm(V.promise(()=>M0.resolvePrompt($))).pipe(V.map((Z)=>Z??"")),Ay=V.gen(function*(){let $=yield*jB("session/build-switch"),Z=yield*jB("session/max-steps"),J=yield*jB("session/compose");return{buildSwitch:$,maxSteps:Z,promptCompose:J}});var Iy=N1.create({service:"session.prompt"}),vm=Y0.create({service:"session.prompt"});function Ny($,Z,J,Y){return V.gen(function*(){let{bus:Q,status:X,sessions:K,agents:G,provider:B,processor:H,prune:W,checkpoint:O,compaction:j,config:U,plugin:q,permission:z,fsys:A,registry:D,scope:_,instruction:w,state:P,goal:N,taskGateState:L,taskRegistry:T,revert:h,summary:x,sys:v,llm:I,actorRegistry:S,inbox:E}=yield*rV,y=yield*Ay,R=y.buildSwitch,k=y.maxSteps,i=y.promptCompose,d=(G0,Q0,s)=>iM(B,Q,G0,Q0,s),c=(G0,Q0)=>nM(K,G0,Q0),o=VB(K),p=1024,J0=new class extends Set{add(G0){if(super.add(G0),this.size>1024){let Q0=this.values().next().value;if(Q0!==void 0)this.delete(Q0)}return this}},t=(G0)=>ZB({getOps:$,...G0}),f=tM({agents:G,provider:B,llm:I,sessions:K,elog:Iy}),a=eM({sessions:K,fsys:A,buildSwitch:R,promptCompose:i});return{runLoop:V.fn("SessionPrompt.run")(function*(G0,Q0,s){let j0=yield*u.context,r=Iy.with({sessionID:G0}),Z0,_0=0,C0=yield*K.get(G0),L0,$2,O2=Q0??"main",e2=lM({sessionID:G0,agentID:O2,task_id:s,plugin:q,bus:Q,prune:W,scope:_}),{cancellation:L$,agentMetrics:r$,publishAgentRequest:f$,schedulePrune:K$}=e2,e0=uM({sessionID:G0,agentID:O2,task_id:s,session:C0,cancellation:L$,plugin:q});return yield*V.gen(function*(){yield*e2.before;let C1=(y0,c0)=>eV(SM(y0,c0,O0.parts(c0.id))),G$=!1,v1=jy({sessionID:G0,bus:Q,appendSyntheticUserTurn:o,slog:r}),D$=Hy({sessionID:G0,sessions:K,bus:Q,appendSyntheticUserTurn:o,slog:r}),{autoContinueOutputLength:Z8,autoContinueInvalidOutput:VY,autoRetryStructuredOutput:J8,handleTextRepeat:y3,writeContentFilterError:KY,writeModelError:G2}=D$,l0=rM({sessionID:G0,agentID:Q0,agents:G,taskGateState:L,taskRegistry:T,appendSyntheticUserTurn:o,slog:r}),b2=aM({sessionID:G0,agentID:Q0,session:C0,goal:N,bus:Q,appendSyntheticUserTurn:o,slog:r});while(!0){if(!Q0||Q0==="main")yield*X.set(G0,{type:"busy"});yield*E.drain(G0,Q0??"main").pipe(V.ignore),yield*r.info("loop",{step:_0});let y0=yield*O0.filterCompactedEffect(G0,{contextFrom:C0.contextFrom,contextWatermark:C0.contextWatermark,agentID:Q0??"main"}),c0,d9,O1,G6,W$,u6=[];for(let t0=y0.length-1;t0>=0;t0--){let _$=y0[t0];if(!c0&&_$.info.role==="user")c0=_$.info,d9=_$;if(!O1&&_$.info.role==="assistant")O1=_$.info,G6=_$;if(!W$&&_$.info.role==="assistant"&&_$.info.finish)W$=_$.info;if(c0&&W$)break;if(!W$){let c9=_$.parts.filter((_8)=>_8.type==="subtask");u6.push(...c9)}}if(!c0)throw Error("No user message found in stream. This should never happen.");yield*Oy({sessionID:G0,msgs:y0,checkpoint:O,config:U});let w3=G6?.parts.some((t0)=>t0.type==="tool"&&!t0.metadata?.providerExecuted)??!1;if(O1?.finish==="length"&&!w3&&c0.id<O1.id&&(yield*Z8({lastUser:c0,assistant:O1})))continue;if(O1){let t0=a5({phase:"existing-assistant",lastUser:c0,assistant:O1,parts:G6?.parts??[]});if(t0.type==="filtered"){yield*KY({assistant:O1}),yield*r.info("exiting loop",{classification:t0.type});break}if(t0.type==="failed"){yield*G2({assistant:O1,reason:t0.reason}),yield*r.info("exiting loop",{classification:t0.type,reason:t0.reason});break}if(t0.type==="think-only"||t0.type==="invalid"){let _$=t0.type==="invalid"?t0.reason:"think-only";if(yield*VY({lastUser:c0,assistant:O1,reason:_$}))continue;yield*r.info("exiting loop",{classification:t0.type});break}if(t0.type==="final"&&t0.degraded)yield*r.warn("degraded final on abnormal finish",{finish:O1.finish});if(t0.type!=="continue"){if(yield*l0(c0))continue;if(yield*b2(c0))continue;yield*r.info("exiting loop",{classification:t0.type});break}}if(_0++,_0===1)yield*f({session:C0,modelID:c0.model.modelID,providerID:c0.model.providerID,history:y0}).pipe(V.ignore,V.forkIn(_));if(_0===1&&!C0.parentID)yield*Cy({config:U,lastUser:c0,promptServiceTag:Y,log:vm});let t$=yield*d(c0.model.providerID,c0.model.modelID,G0);$2=t$,L0=W$;let z$=u6.pop();if(z$?.type==="subtask"){yield*t({task:z$,model:t$,lastUser:c0,sessionID:G0,session:C0,msgs:y0});continue}let l6=d9;if(l6?.parts.some((t0)=>t0.type==="compaction")){let t0=l6.parts.find((_8)=>_8.type==="compaction"),_$=yield*K.messages({sessionID:G0,agentID:c0.agentID??"main"});if((yield*j.process({parentID:c0.id,messages:_$,sessionID:G0,auto:t0?.auto??!1,overflow:t0?.overflow,agentID:c0.agentID}))==="stop")break;continue}yield*Uy({sessionID:G0,msgs:y0,lastFinished:W$,model:t$,config:U}),qy({sessionID:G0,msgs:y0,lastFinished:W$});let z8=yield*G.get(c0.agent),MZ=z8?.native===!0&&z8?.hidden===!0;if(!G$&&!MZ&&W$&&W$.tokens){let t0=yield*$();yield*W.fireCheckpoints({sessionID:G0,model:t$,tokens:W$.tokens,promptOps:t0,agentID:c0.agentID}).pipe(V.ignore)}if(!G$&&W$&&W$.tokens){if(yield*dM({config:U,checkpoint:O,compaction:j,prune:W},{sessionID:G0,lastFinished:W$,lastUser:c0,model:t$,msgs:y0,isBoundedComputation:MZ})){G$=!0;continue}}if(G$=!1,!z8)throw yield*t5(G,Q,c0.agent,G0);let x8=z8.steps??1/0,I0=_0>=x8;y0=yield*a({messages:y0,agent:z8,session:C0});let r0=J3({sessionID:G0,parentID:c0.id,agentID:c0.agentID,agent:z8.name,variant:c0.model.variant,cwd:j0.directory,root:j0.worktree,modelID:t$.id,providerID:t$.providerID});yield*K.updateMessage(r0);let y2=yield*H.create({assistantMessage:r0,sessionID:G0,model:t$,agentMetrics:r$}),p6=yield*V.gen(function*(){let t0={value:Z0},_$=yield*RM({sessionID:G0,resolvedAgentID:O2,step:_0,task_id:s,lastUser:c0,lastFinished:W$,msgs:y0,agent:z8,session:C0,model:t$,handle:y2,structured:t0,resolveTools:Z,createStructuredOutputTool:J,summary:x,scope:_,plugin:q}),{tools:c9,format:_8,query:C3}=_$,{cancelledByPlugin:A3,withUserQueryPost:I3}=TM({sessionID:G0,agentID:O2,step:_0,lastUser:c0,msgs:y0,query:C3,handle:y2,plugin:q,sessions:K,cancellation:L$,trajectoryForStep:C1}),N3=V.fnUntraced(function*(u9){if(u9==="continue"&&(yield*Z8({lastUser:c0,assistant:y2.message})))return"continue";if(u9==="text-repeat"){if(yield*y3({lastUser:c0}))return"continue";return"break"}if(t0.value!==void 0)return Z0=t0.value,y2.message.structured=t0.value,y2.message.finish=y2.message.finish??"stop",yield*K.updateMessage(y2.message),"break";let m1=a5({phase:"after-process",lastUser:c0,assistant:y2.message,parts:O0.parts(y2.message.id),processResult:u9});if(m1.type==="filtered")return yield*KY({assistant:y2.message}),"break";if(m1.type==="failed")return yield*G2({assistant:y2.message,reason:m1.reason}),"break";if(m1.type!=="continue"&&!y2.message.error&&_8.type==="json_schema"){if(yield*J8({lastUser:c0,assistant:y2.message}))return"continue";return"break"}if((m1.type==="think-only"||m1.type==="invalid")&&_8.type!=="json_schema"){let L3=m1.type==="invalid"?m1.reason:"think-only";if(yield*VY({lastUser:c0,assistant:y2.message,reason:L3}))return"continue";return"break"}if(m1.type==="final"&&m1.degraded)yield*r.warn("degraded final on abnormal finish",{finish:y2.message.finish});if(u9==="stop")return"break";return}),yZ=yield*vM({sessionID:G0,lastUser:c0,agent:z8,session:C0,model:t$,msgs:y0,tools:c9,format:_8,handle:y2,isLastStep:I0,task_id:s,instructionsNotified:J0,maxStepsText:k,actorRegistry:S,bus:Q,config:U,instruction:w,llm:I,registry:D,status:X,sys:v,cancelledByPlugin:A3,withUserQueryPost:I3,slog:r});if(yZ.kind==="break")return"break";let GY=yield*N3(yZ.result);if(GY)return GY;if(yZ.result==="overflow")yield*cM({config:U,checkpoint:O,compaction:j,prune:W},{sessionID:G0,lastUser:c0,model:t$,msgs:y0,isBoundedComputation:MZ});return"continue"}).pipe(V.ensuring(w.clear(y2.message.id))),Q8=yield*v1.check({lastUser:c0,completedParts:O0.parts(y2.message.id)});if(Q8==="terminate")break;if(Q8==="recovered")continue;if(p6==="break"){if(yield*l0(c0))continue;if(yield*b2(c0))continue;break}continue}let f1=yield*$();if($2&&L0)yield*K$({model:$2,lastFinished:L0,promptOps:f1});let a$=yield*c(G0,Q0),c6=a$.info.role==="assistant"&&!!a$.info.error,Y8=yield*K.findMessage(G0,(y0)=>y0.info.role==="user",{agentID:"*"});return yield*f$(c6?"error":"completed",N2.isSome(Y8)?Y8.value.info.agent:a$.info.agent),a$}).pipe((C1)=>e5(G0,Q,C1),V.onExit(e0),V.orDie)}),lastAssistant:c}})}import Ly from"path";var fm=new TextEncoder,OB=new TextDecoder,mm=($)=>`
8093
8093
 
8094
8094
  [... QitQode truncated ${$} bytes of shell output ...]
8095
8095
 
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{hp as a0}from"./chunk-w8xaw2dv.js";import{Ar as f0,Cr as l0}from"./chunk-ej3gmaba.js";import{As as o0}from"./chunk-r8ddb02d.js";import{Ds as T0}from"./chunk-56cty7nr.js";import{_s as C0,at as s,ct as H0,dt as r}from"./chunk-v7yvnnmr.js";import{Ct as f,Gt as S,nt as a,wt as n0}from"./chunk-b5x3zghc.js";import{It as p}from"./chunk-tk6gjy9d.js";import{Kt as P0}from"./chunk-pkdk0ppc.js";import{Iz as u0}from"./chunk-01gtn79f.js";import{$H as J,BN as w,IO as s0,JA as p0,OH as N0,TF as C,eC as L,jD as R0,yF as g}from"./chunk-meaa7wrs.js";import{lP as X0,nP as i0,pP as _2}from"./chunk-fa03gsff.js";function h0(Z,Q){let z,$=()=>z??=u0.make(g.provideMerge(Q,f0.layer),{memoMap:l0});return{runSync:(X)=>$().runSync(Z.use(X)),runPromiseExit:(X,Y)=>$().runPromiseExit(Z.use(X),Y),runPromise:(X,Y)=>$().runPromise(Z.use(X),Y),runFork:(X)=>$().runFork(Z.use(X)),runCallback:(X)=>$().runCallback(Z.use(X))}}var Y0={};i0(Y0,{which:()=>w2,sanitize:()=>t0,outdated:()=>K2,layer:()=>e0,install:()=>N2,defaultLayer:()=>Z2,add:()=>F2,Service:()=>z0,Npm:()=>Y0,InstallFailedError:()=>V0});var r0=X0(o0(),1),b0=X0(a0(),1);import k from"path";import I0 from"path";import A2 from"os";import{randomUUID as D2}from"crypto";var B0;((Q0)=>{class Z extends w.TaggedErrorClass()("LockTimeoutError",{key:w.String}){}Q0.LockTimeoutError=Z;class Q extends w.TaggedErrorClass()("LockCompromisedError",{detail:w.String}){}Q0.LockCompromisedError=Q;class z extends w.TaggedErrorClass()("ReleaseError",{detail:w.String,cause:w.optional(w.Defect)}){get message(){return this.detail}}class $ extends w.TaggedErrorClass()("NotAcquired",{}){}let X=60000,Y=300000,U=100,G=2000,W=Math.max(100,Math.floor(X/3)),I=C.exponential(U,1.7).pipe(C.either(C.spaced(G)),C.jittered,C.while((j)=>j.elapsed<Y)),H=w.fromJsonString(w.Struct({token:w.String,pid:w.Number,hostname:w.String,createdAt:w.String})),q=w.decodeUnknownSync(H),R=w.encodeSync(H);class N extends R0.Service()("EffectFlock"){}Q0.Service=N;function A(){return performance.timeOrigin+performance.now()}let O=(j)=>L.getOrElse(j.mtime,()=>new Date(0)).getTime(),K=(j)=>j.reason._tag==="NotFound"||j.reason._tag==="Unknown";Q0.layer=g.effect(N,J.gen(function*(){let j=yield*s.Service,_=yield*f.Service,V=I0.join(j.state,"locks"),B=A2.hostname(),M=new Set,m=(D)=>_.stat(D).pipe(J.catchIf(K,()=>J.void),J.orDie),l=(D)=>_.remove(D,{recursive:!0}).pipe(J.ignore),d=(D)=>_.makeDirectory(D,{mode:448}).pipe(J.as(!0),J.catchIf((T)=>T.reason._tag==="AlreadyExists",()=>J.succeed(!1)),J.orDie),M0=(D,T,E,P)=>_.writeFileString(D,T,{flag:"wx"}).pipe(J.catch(()=>J.gen(function*(){return yield*l(E),yield*new Q({detail:P})}))),w0=J.fnUntraced(function*(D){let T=yield*m(D);if(T&&A()-O(T)>X)yield*l(D);return!1}),Z0=J.fnUntraced(function*(D){if(M.has(D))return;yield*_.makeDirectory(D,{recursive:!0}).pipe(J.orDie),M.add(D)}),F=J.fnUntraced(function*(D,T,E){let P=A(),h=yield*m(T);if(h)return P-O(h)>X;let $0=yield*m(E);if($0)return P-O($0)>X;let q0=yield*m(D);if(!q0)return!1;return P-O(q0)>X}),b=(D,T)=>J.gen(function*(){let E=D2(),P=I0.join(D,"meta.json"),h=I0.join(D,"heartbeat");if(!(yield*d(D))){if(!(yield*F(D,h,P)))return yield*new $;let O0=D+".breaker";if(!(yield*_.makeDirectory(O0,{mode:448}).pipe(J.as(!0),J.catchIf((V2)=>V2.reason._tag==="AlreadyExists",()=>w0(O0)),J.catchIf(K,()=>J.succeed(!1)),J.orDie)))return yield*new $;if(!(yield*J.gen(function*(){if(!(yield*F(D,h,P)))return!1;return yield*l(D),yield*d(D)}).pipe(J.ensuring(l(O0)))))return yield*new $}yield*M0(h,"",D,"heartbeat already existed");let q0=R({token:E,pid:process.pid,hostname:B,createdAt:new Date().toISOString()});return yield*M0(P,q0,D,"meta.json already existed"),{token:E,metaPath:P,heartbeatPath:h,lockDir:D}}).pipe(J.withSpan("EffectFlock.tryAcquire",{attributes:{key:T}})),U0=(D,T)=>b(D,T).pipe(J.retry({while:(E)=>E._tag==="NotAcquired",schedule:I}),J.catchTag("NotAcquired",()=>J.fail(new Z({key:T})))),i=(D)=>J.gen(function*(){let T=yield*_.readFileString(D.metaPath).pipe(J.catch((P)=>{if(K(P))return J.die(new z({detail:"metadata missing"}));return J.die(P)}));if((yield*J.try({try:()=>q(T),catch:(P)=>new z({detail:"metadata invalid",cause:P})}).pipe(J.orDie)).token!==D.token)return yield*J.die(new z({detail:"token mismatch"}));yield*l(D.lockDir)}),k0=J.fn("EffectFlock.acquire")(function*(D,T){let E=T??V;yield*Z0(E);let P=I0.join(E,C0.fast(D)+".lock"),h=yield*J.acquireRelease(U0(P,D),($0)=>i($0));yield*_.utimes(h.heartbeatPath,new Date,new Date).pipe(J.ignore,J.repeat(C.spaced(W)),J.forkScoped)}),B2=p0.dual((D)=>J.isEffect(D[0]),(D,T,E)=>J.scoped(J.gen(function*(){return yield*k0(T,E),yield*D})));return N.of({acquire:k0,withLock:B2})})),Q0.defaultLayer=Q0.layer.pipe(g.provide(f.defaultLayer),g.provide(s.layer))})(B0||={});class V0 extends w.TaggedErrorClass()("NpmInstallFailedError",{add:w.Array(w.String).pipe(w.optional),dir:w.String,cause:w.optional(w.Defect)}){}class z0 extends R0.Service()("@qitqode/Npm"){}var c0=process.platform==="win32"?new Set(["<",">",":",'"',"|","?","*"]):void 0;function t0(Z){if(!c0)return Z;return Array.from(Z,(Q)=>c0.has(Q)||Q.charCodeAt(0)<32?"_":Q).join("")}var d0=(Z,Q)=>{let z;try{let $=typeof Bun<"u"?import.meta.resolve(Z,Q):import.meta.resolve(Q);z=L.some($)}catch{z=L.none()}return{directory:Q,entrypoint:z}},e0=g.effect(z0,J.gen(function*(){let Z=yield*f.Service,Q=yield*s.Service,z=yield*s0.FileSystem,$=yield*B0.Service,X=(H)=>k.join(Q.cache,"packages",t0(H)),Y=(H)=>J.gen(function*(){yield*$.acquire(`npm-install:${H.dir}`);let{Arborist:q}=yield*J.promise(()=>import("./chunk-h9ftcgs2.js").then((m)=>X0(m.default,1))),R=new q({path:H.dir,binLinks:!0,progress:!1,savePrefix:"",ignoreScripts:!0});return yield*J.tryPromise({try:()=>R.reify({add:H?.add||[],save:!0,saveType:"prod"}),catch:(N)=>new V0({cause:N,add:H?.add,dir:H.dir})})}).pipe(J.withSpan("Npm.reify",{attributes:H})),U=J.fn("Npm.outdated")(function*(H,q){let R=yield*J.tryPromise({try:()=>fetch(`https://registry.npmjs.org/${H}`),catch:()=>{return}}).pipe(J.orElseSucceed(()=>{return}));if(!R||!R.ok)return!1;let A=(yield*J.tryPromise({try:()=>R.json(),catch:()=>{return}}).pipe(J.orElseSucceed(()=>{return})))?.["dist-tags"]?.latest;if(!A)return!1;if(/[\s^~*xX<>|=]/.test(q))return!b0.default.satisfies(A,q);return b0.default.lt(q,A)}),G=J.fn("Npm.add")(function*(H){let q=X(H),R=(()=>{try{return r0.default(H).name??H}catch{return H}})();if(yield*Z.existsSafe(q))return d0(R,k.join(q,"node_modules",R));let A=(yield*Y({dir:q,add:[H]})).edgesOut.values().next().value?.to;if(!A)return yield*new V0({add:[H],dir:q});return d0(A.name,A.path)},J.scoped),W=J.fn("Npm.install")(function*(H,q){if(!(yield*Z.access(H,{writable:!0}).pipe(J.as(!0),J.orElseSucceed(()=>!1))))return;let N=q?.add.map((A)=>[A.name,A.version].filter(Boolean).join("@"))??[];if(yield*J.gen(function*(){if(!(yield*Z.existsSafe(k.join(H,"node_modules"))))return yield*Y({add:N,dir:H}),!0;return!1}).pipe(J.withSpan("Npm.checkNodeModules")))return;yield*J.gen(function*(){let A=yield*Z.readJson(k.join(H,"package.json")).pipe(J.orElseSucceed(()=>({}))),O=yield*Z.readJson(k.join(H,"package-lock.json")).pipe(J.orElseSucceed(()=>({}))),K=A,y=O,v=new Set([...Object.keys(K?.dependencies||{}),...Object.keys(K?.devDependencies||{}),...Object.keys(K?.peerDependencies||{}),...Object.keys(K?.optionalDependencies||{}),...(q?.add||[]).map((V)=>V.name)]),j=y?.packages?.[""]||{},_=new Set([...Object.keys(j?.dependencies||{}),...Object.keys(j?.devDependencies||{}),...Object.keys(j?.peerDependencies||{}),...Object.keys(j?.optionalDependencies||{})]);for(let V of v)if(!_.has(V)){yield*Y({dir:H,add:N});return}}).pipe(J.withSpan("Npm.checkDirty"));return},J.scoped),I=J.fn("Npm.which")(function*(H){let q=X(H),R=k.join(q,"node_modules",".bin"),N=J.fnUntraced(function*(){let A=yield*z.readDirectory(R).pipe(J.catch(()=>J.succeed([])));if(A.length===0)return L.none();if(A.length===1)return L.some(A[0]);let O=yield*Z.readJson(k.join(q,"node_modules",H,"package.json")).pipe(J.option);if(L.isSome(O)){let K=O.value;if(K?.bin){let y=H.startsWith("@")?H.split("/")[1]:H,v=K.bin;if(typeof v==="string")return L.some(y);let j=Object.keys(v);if(j.length===1)return L.some(j[0]);return v[y]?L.some(y):L.some(j[0])}}return L.some(A[0])});return yield*J.gen(function*(){let A=yield*N();if(L.isSome(A))return L.some(k.join(R,A.value));yield*z.remove(k.join(q,"package-lock.json")).pipe(J.orElseSucceed(()=>{})),yield*G(H);let O=yield*N();if(L.isNone(O))return L.none();return L.some(k.join(R,O.value))}).pipe(J.scoped,J.orElseSucceed(()=>L.none()))});return z0.of({add:G,install:W,outdated:U,which:I})})),Z2=e0.pipe(g.provide(B0.layer),g.provide(f.layer),g.provide(s.layer),g.provide(n0.layer)),{runPromise:A0}=h0(z0,Z2);async function N2(...Z){return A0((Q)=>Q.install(...Z))}async function F2(...Z){let Q=await A0((z)=>z.add(...Z));return{directory:Q.directory,entrypoint:L.getOrUndefined(Q.entrypoint)}}async function K2(...Z){return A0((Q)=>Q.outdated(...Z))}async function w2(...Z){let Q=await A0((z)=>z.which(...Z));return L.getOrUndefined(Q)}var Q2=X0(o0(),1),D0=X0(a0(),1);import u from"path";import{fileURLToPath as _0,pathToFileURL as n}from"url";var O2=["opencode-openai-codex-auth","opencode-copilot-auth"];function _Z(Z){return O2.some((Q)=>Z.includes(Q))}function z2(Z){try{return Q2.default(Z)}catch{}}function NZ(Z){let Q=z2(Z);if(Q?.type==="alias"&&!Q.name){let z=Q.subSpec;if(z?.name){let $=!z.rawSpec||z.rawSpec==="*"?"latest":z.rawSpec;return{pkg:z.name,version:$}}}if(!Q?.name)return{pkg:Z,version:""};if(Q.raw===Q.name)return{pkg:Q.name,version:"latest"};return{pkg:Q.name,version:Q.rawSpec}}var b2=["index.ts","index.tsx","index.js","index.mjs","index.cjs"];function X2(Z){if(J2(Z))return"file";return"npm"}function L2(Z,Q){if(Z.startsWith("file://"))return _0(Z);if(u.isAbsolute(Z))return Z;return u.resolve(Q,Z)}function Y2(Z){return u.isAbsolute(Z)||/^[A-Za-z]:[\\/]/.test(Z)}function T2(Z){if(typeof Z==="string")return Z;if(!a(Z))return;for(let Q of["import","default"]){let z=Z[Q];if(typeof z==="string")return z}return}function y2(Z){let Q=Z.json.main;if(typeof Q!=="string")return;let z=Q.trim();if(!z)return;return z}function H2(Z,Q,z,$){let X=L2(Q,$.dir),Y=S.resolve($.dir),U=S.resolve(X);if(!S.contains(Y,U))throw Error(`Plugin ${Z} resolved ${z} entry outside plugin directory`);return U}function $2(Z,Q,z,$){return n(H2(Z,Q,z,$)).href}function P2(Z,Q,z){let $=z.json.exports;if(a($)){let Y=T2($[`./${Q}`]);if(Y)return $2(Z,Y,Q,z)}if(Q!=="server")return;let X=y2(z);if(!X)return;return $2(Z,X,Q,z)}function S2(Z){if(Z.startsWith("file://"))return _0(Z);if(u.isAbsolute(Z))return Z}async function L0(Z){for(let Q of b2){let z=u.join(Z,Q);if(await S.exists(z))return z}}async function m2(Z){let Q=S2(Z);if(!Q)return;if(!(await S.statAsync(Q))?.isDirectory())return;return Q}async function E2(Z,Q,z,$){let X=X2(Z),Y=$??(X==="npm"?await o(Q):await o(Q).catch(()=>{return}));if(!Y)return Q;let U=P2(Z,z,Y);if(U)return U;let G=await m2(Q);if(z==="tui"){if(X==="file"&&G){let W=await L0(G);if(W)return n(W).href}if(X==="npm")return;if(G)return;return Q}if(G&&a(Y.json.exports)){if(X==="file"){let W=await L0(G);if(W)return n(W).href}return}return Q}function J2(Z){return Z.startsWith("file://")||Z.startsWith(".")||Y2(Z)}async function v2(Z){let Q=Z.startsWith("file://")?_0(Z):Z,z=u.isAbsolute(Q)||/^[A-Za-z]:[\\/]/.test(Q)?Q:u.resolve(Q);if(!(await S.statAsync(z))?.isDirectory()){if(Z.startsWith("file://"))return Z;return n(z).href}if(await S.exists(u.join(z,"package.json")))return n(z).href;let X=await L0(z);if(X)return n(X).href;throw Error(`Plugin directory ${z} is missing package.json or index file`)}async function FZ(Z,Q,z){if(!D0.default.valid(Q)||D0.default.major(Q)===0)return;let $=z??await o(Z).catch(()=>{return});if(!$)return;let X=$.json.engines;if(!a(X))return;let Y=X.qitqode??X.opencode;if(typeof Y!=="string")return;if(!D0.default.satisfies(Q,Y))throw Error(`Plugin requires qitqode ${Y} but running ${Q}`)}async function KZ(Z){if(J2(Z))return v2(Z);let Q=z2(Z),z=Q?.name&&Q.raw===Q.name?`${Q.name}@latest`:Z;return(await Y0.add(z)).directory}async function o(Z){let Q=Z.startsWith("file://")?_0(Z):Z,$=(await S.statAsync(Q))?.isDirectory()?Q:u.dirname(Q),X=u.join($,"package.json"),Y=await S.readJson(X);return{dir:$,pkg:X,json:Y}}async function wZ(Z,Q,z){let $=X2(Z),X=$==="npm"?await o(Q):await o(Q).catch(()=>{return}),Y=await E2(Z,Q,z,X);return{spec:Z,source:$,target:Q,pkg:X,entry:Y}}function OZ(Z,Q){let z=Q.json["oc-themes"];if(z===void 0)return[];if(!Array.isArray(z))throw TypeError(`Plugin ${Z} has invalid oc-themes field`);let $=z.map((X)=>{if(typeof X!=="string")throw TypeError(`Plugin ${Z} has invalid oc-themes entry`);let Y=X.trim();if(!Y)throw TypeError(`Plugin ${Z} has empty oc-themes entry`);if(Y.startsWith("file://")||Y2(Y))throw TypeError(`Plugin ${Z} oc-themes entry must be relative: ${X}`);return H2(Z,Y,"oc-themes",Q)});return Array.from(new Set($))}function bZ(Z,Q){if(Z===void 0)return;if(typeof Z!=="string")throw TypeError(`Plugin ${Q} has invalid id type ${typeof Z}`);let z=Z.trim();if(!z)throw TypeError(`Plugin ${Q} has an empty id`);return z}function LZ(Z,Q,z,$="strict"){let X=Z.default;if(!a(X)){if($==="detect")return;throw TypeError(`Plugin ${Q} must default export an object with ${z}()`)}if($==="detect"&&!("id"in X)&&!("server"in X)&&!("tui"in X))return;let Y="server"in X?X.server:void 0,U="tui"in X?X.tui:void 0;if(Y!==void 0&&typeof Y!=="function")throw TypeError(`Plugin ${Q} has invalid server export`);if(U!==void 0&&typeof U!=="function")throw TypeError(`Plugin ${Q} has invalid tui export`);if(Y!==void 0&&U!==void 0)throw TypeError(`Plugin ${Q} must default export either server() or tui(), not both`);if(z==="server"&&Y===void 0)throw TypeError(`Plugin ${Q} must default export an object with server()`);if(z==="tui"&&U===void 0)throw TypeError(`Plugin ${Q} must default export an object with tui()`);return X}async function TZ(Z,Q,z,$,X){if(Z==="file"){if($)return $;throw TypeError(`Path plugin ${Q} must export id`)}if($)return $;let Y=X??await o(z);if(typeof Y.json.name!=="string"||!Y.json.name.trim())throw TypeError(`Plugin package ${Y.pkg} is missing name`);return Y.json.name.trim()}var S0={};i0(S0,{readFile:()=>l2,files:()=>g2,fileInDirectory:()=>f2,directories:()=>k2,claudeCommandDirectories:()=>u2,ConfigPaths:()=>S0});import y0 from"path";var W2=T0.create("ConfigJsonError",p.object({path:p.string(),message:p.string().optional()})),mZ=T0.create("ConfigInvalidError",p.object({path:p.string(),issues:p.custom().optional(),message:p.string().optional()}));var g2=N0("ConfigPaths.projectFiles")(function*(Z,Q,z){return(yield*(yield*f.Service).up({targets:[`${Z}.jsonc`,`${Z}.json`],start:Q,stop:z})).toReversed()}),k2=N0("ConfigPaths.directories")(function*(Z,Q){let z=yield*f.Service;return P0([H0.Path.config,...!r.QITQODE_DISABLE_PROJECT_CONFIG?yield*z.up({targets:[".qitqode"],start:Z,stop:Q}):[],...yield*z.up({targets:[".qitqode"],start:H0.Path.home,stop:H0.Path.home}),...r.QITQODE_CONFIG_DIR?[r.QITQODE_CONFIG_DIR]:[]])}),u2=N0("ConfigPaths.claudeCommandDirectories")(function*(Z,Q){if(r.QITQODE_DISABLE_CLAUDE_CODE_COMMANDS)return[];let z=yield*f.Service;return P0([y0.join(H0.Path.home,".claude"),...!r.QITQODE_DISABLE_PROJECT_CONFIG?yield*z.up({targets:[".claude"],start:Z,stop:Q}):[]])});function f2(Z,Q){return[y0.join(Z,`${Q}.json`),y0.join(Z,`${Q}.jsonc`)]}async function l2(Z){return S.readText(Z).catch((Q)=>{if(Q.code==="ENOENT")return;throw new W2({path:Z},{cause:Q})})}function W0(Z,Q=!1){let z=Z.length,$=0,X="",Y=0,U=16,G=0,W=0,I=0,H=0,q=0;function R(j,_){let V=0,B=0;while(V<j||!_){let M=Z.charCodeAt($);if(M>=48&&M<=57)B=B*16+M-48;else if(M>=65&&M<=70)B=B*16+M-65+10;else if(M>=97&&M<=102)B=B*16+M-97+10;else break;$++,V++}if(V<j)B=-1;return B}function N(j){$=j,X="",Y=0,U=16,q=0}function A(){let j=$;if(Z.charCodeAt($)===48)$++;else{$++;while($<Z.length&&t(Z.charCodeAt($)))$++}if($<Z.length&&Z.charCodeAt($)===46)if($++,$<Z.length&&t(Z.charCodeAt($))){$++;while($<Z.length&&t(Z.charCodeAt($)))$++}else return q=3,Z.substring(j,$);let _=$;if($<Z.length&&(Z.charCodeAt($)===69||Z.charCodeAt($)===101)){if($++,$<Z.length&&Z.charCodeAt($)===43||Z.charCodeAt($)===45)$++;if($<Z.length&&t(Z.charCodeAt($))){$++;while($<Z.length&&t(Z.charCodeAt($)))$++;_=$}else q=3}return Z.substring(j,_)}function O(){let j="",_=$;while(!0){if($>=z){j+=Z.substring(_,$),q=2;break}let V=Z.charCodeAt($);if(V===34){j+=Z.substring(_,$),$++;break}if(V===92){if(j+=Z.substring(_,$),$++,$>=z){q=2;break}switch(Z.charCodeAt($++)){case 34:j+='"';break;case 92:j+="\\";break;case 47:j+="/";break;case 98:j+="\b";break;case 102:j+="\f";break;case 110:j+=`
2
+ import{hp as a0}from"./chunk-w8xaw2dv.js";import{Ar as f0,Cr as l0}from"./chunk-yja3y138.js";import{As as o0}from"./chunk-r8ddb02d.js";import{Ds as T0}from"./chunk-56cty7nr.js";import{_s as C0,at as s,ct as H0,dt as r}from"./chunk-esjs9s9g.js";import{Ct as f,Gt as S,nt as a,wt as n0}from"./chunk-b5x3zghc.js";import{It as p}from"./chunk-tk6gjy9d.js";import{Kt as P0}from"./chunk-pkdk0ppc.js";import{Iz as u0}from"./chunk-01gtn79f.js";import{$H as J,BN as w,IO as s0,JA as p0,OH as N0,TF as C,eC as L,jD as R0,yF as g}from"./chunk-meaa7wrs.js";import{lP as X0,nP as i0,pP as _2}from"./chunk-fa03gsff.js";function h0(Z,Q){let z,$=()=>z??=u0.make(g.provideMerge(Q,f0.layer),{memoMap:l0});return{runSync:(X)=>$().runSync(Z.use(X)),runPromiseExit:(X,Y)=>$().runPromiseExit(Z.use(X),Y),runPromise:(X,Y)=>$().runPromise(Z.use(X),Y),runFork:(X)=>$().runFork(Z.use(X)),runCallback:(X)=>$().runCallback(Z.use(X))}}var Y0={};i0(Y0,{which:()=>w2,sanitize:()=>t0,outdated:()=>K2,layer:()=>e0,install:()=>N2,defaultLayer:()=>Z2,add:()=>F2,Service:()=>z0,Npm:()=>Y0,InstallFailedError:()=>V0});var r0=X0(o0(),1),b0=X0(a0(),1);import k from"path";import I0 from"path";import A2 from"os";import{randomUUID as D2}from"crypto";var B0;((Q0)=>{class Z extends w.TaggedErrorClass()("LockTimeoutError",{key:w.String}){}Q0.LockTimeoutError=Z;class Q extends w.TaggedErrorClass()("LockCompromisedError",{detail:w.String}){}Q0.LockCompromisedError=Q;class z extends w.TaggedErrorClass()("ReleaseError",{detail:w.String,cause:w.optional(w.Defect)}){get message(){return this.detail}}class $ extends w.TaggedErrorClass()("NotAcquired",{}){}let X=60000,Y=300000,U=100,G=2000,W=Math.max(100,Math.floor(X/3)),I=C.exponential(U,1.7).pipe(C.either(C.spaced(G)),C.jittered,C.while((j)=>j.elapsed<Y)),H=w.fromJsonString(w.Struct({token:w.String,pid:w.Number,hostname:w.String,createdAt:w.String})),q=w.decodeUnknownSync(H),R=w.encodeSync(H);class N extends R0.Service()("EffectFlock"){}Q0.Service=N;function A(){return performance.timeOrigin+performance.now()}let O=(j)=>L.getOrElse(j.mtime,()=>new Date(0)).getTime(),K=(j)=>j.reason._tag==="NotFound"||j.reason._tag==="Unknown";Q0.layer=g.effect(N,J.gen(function*(){let j=yield*s.Service,_=yield*f.Service,V=I0.join(j.state,"locks"),B=A2.hostname(),M=new Set,m=(D)=>_.stat(D).pipe(J.catchIf(K,()=>J.void),J.orDie),l=(D)=>_.remove(D,{recursive:!0}).pipe(J.ignore),d=(D)=>_.makeDirectory(D,{mode:448}).pipe(J.as(!0),J.catchIf((T)=>T.reason._tag==="AlreadyExists",()=>J.succeed(!1)),J.orDie),M0=(D,T,E,P)=>_.writeFileString(D,T,{flag:"wx"}).pipe(J.catch(()=>J.gen(function*(){return yield*l(E),yield*new Q({detail:P})}))),w0=J.fnUntraced(function*(D){let T=yield*m(D);if(T&&A()-O(T)>X)yield*l(D);return!1}),Z0=J.fnUntraced(function*(D){if(M.has(D))return;yield*_.makeDirectory(D,{recursive:!0}).pipe(J.orDie),M.add(D)}),F=J.fnUntraced(function*(D,T,E){let P=A(),h=yield*m(T);if(h)return P-O(h)>X;let $0=yield*m(E);if($0)return P-O($0)>X;let q0=yield*m(D);if(!q0)return!1;return P-O(q0)>X}),b=(D,T)=>J.gen(function*(){let E=D2(),P=I0.join(D,"meta.json"),h=I0.join(D,"heartbeat");if(!(yield*d(D))){if(!(yield*F(D,h,P)))return yield*new $;let O0=D+".breaker";if(!(yield*_.makeDirectory(O0,{mode:448}).pipe(J.as(!0),J.catchIf((V2)=>V2.reason._tag==="AlreadyExists",()=>w0(O0)),J.catchIf(K,()=>J.succeed(!1)),J.orDie)))return yield*new $;if(!(yield*J.gen(function*(){if(!(yield*F(D,h,P)))return!1;return yield*l(D),yield*d(D)}).pipe(J.ensuring(l(O0)))))return yield*new $}yield*M0(h,"",D,"heartbeat already existed");let q0=R({token:E,pid:process.pid,hostname:B,createdAt:new Date().toISOString()});return yield*M0(P,q0,D,"meta.json already existed"),{token:E,metaPath:P,heartbeatPath:h,lockDir:D}}).pipe(J.withSpan("EffectFlock.tryAcquire",{attributes:{key:T}})),U0=(D,T)=>b(D,T).pipe(J.retry({while:(E)=>E._tag==="NotAcquired",schedule:I}),J.catchTag("NotAcquired",()=>J.fail(new Z({key:T})))),i=(D)=>J.gen(function*(){let T=yield*_.readFileString(D.metaPath).pipe(J.catch((P)=>{if(K(P))return J.die(new z({detail:"metadata missing"}));return J.die(P)}));if((yield*J.try({try:()=>q(T),catch:(P)=>new z({detail:"metadata invalid",cause:P})}).pipe(J.orDie)).token!==D.token)return yield*J.die(new z({detail:"token mismatch"}));yield*l(D.lockDir)}),k0=J.fn("EffectFlock.acquire")(function*(D,T){let E=T??V;yield*Z0(E);let P=I0.join(E,C0.fast(D)+".lock"),h=yield*J.acquireRelease(U0(P,D),($0)=>i($0));yield*_.utimes(h.heartbeatPath,new Date,new Date).pipe(J.ignore,J.repeat(C.spaced(W)),J.forkScoped)}),B2=p0.dual((D)=>J.isEffect(D[0]),(D,T,E)=>J.scoped(J.gen(function*(){return yield*k0(T,E),yield*D})));return N.of({acquire:k0,withLock:B2})})),Q0.defaultLayer=Q0.layer.pipe(g.provide(f.defaultLayer),g.provide(s.layer))})(B0||={});class V0 extends w.TaggedErrorClass()("NpmInstallFailedError",{add:w.Array(w.String).pipe(w.optional),dir:w.String,cause:w.optional(w.Defect)}){}class z0 extends R0.Service()("@qitqode/Npm"){}var c0=process.platform==="win32"?new Set(["<",">",":",'"',"|","?","*"]):void 0;function t0(Z){if(!c0)return Z;return Array.from(Z,(Q)=>c0.has(Q)||Q.charCodeAt(0)<32?"_":Q).join("")}var d0=(Z,Q)=>{let z;try{let $=typeof Bun<"u"?import.meta.resolve(Z,Q):import.meta.resolve(Q);z=L.some($)}catch{z=L.none()}return{directory:Q,entrypoint:z}},e0=g.effect(z0,J.gen(function*(){let Z=yield*f.Service,Q=yield*s.Service,z=yield*s0.FileSystem,$=yield*B0.Service,X=(H)=>k.join(Q.cache,"packages",t0(H)),Y=(H)=>J.gen(function*(){yield*$.acquire(`npm-install:${H.dir}`);let{Arborist:q}=yield*J.promise(()=>import("./chunk-h9ftcgs2.js").then((m)=>X0(m.default,1))),R=new q({path:H.dir,binLinks:!0,progress:!1,savePrefix:"",ignoreScripts:!0});return yield*J.tryPromise({try:()=>R.reify({add:H?.add||[],save:!0,saveType:"prod"}),catch:(N)=>new V0({cause:N,add:H?.add,dir:H.dir})})}).pipe(J.withSpan("Npm.reify",{attributes:H})),U=J.fn("Npm.outdated")(function*(H,q){let R=yield*J.tryPromise({try:()=>fetch(`https://registry.npmjs.org/${H}`),catch:()=>{return}}).pipe(J.orElseSucceed(()=>{return}));if(!R||!R.ok)return!1;let A=(yield*J.tryPromise({try:()=>R.json(),catch:()=>{return}}).pipe(J.orElseSucceed(()=>{return})))?.["dist-tags"]?.latest;if(!A)return!1;if(/[\s^~*xX<>|=]/.test(q))return!b0.default.satisfies(A,q);return b0.default.lt(q,A)}),G=J.fn("Npm.add")(function*(H){let q=X(H),R=(()=>{try{return r0.default(H).name??H}catch{return H}})();if(yield*Z.existsSafe(q))return d0(R,k.join(q,"node_modules",R));let A=(yield*Y({dir:q,add:[H]})).edgesOut.values().next().value?.to;if(!A)return yield*new V0({add:[H],dir:q});return d0(A.name,A.path)},J.scoped),W=J.fn("Npm.install")(function*(H,q){if(!(yield*Z.access(H,{writable:!0}).pipe(J.as(!0),J.orElseSucceed(()=>!1))))return;let N=q?.add.map((A)=>[A.name,A.version].filter(Boolean).join("@"))??[];if(yield*J.gen(function*(){if(!(yield*Z.existsSafe(k.join(H,"node_modules"))))return yield*Y({add:N,dir:H}),!0;return!1}).pipe(J.withSpan("Npm.checkNodeModules")))return;yield*J.gen(function*(){let A=yield*Z.readJson(k.join(H,"package.json")).pipe(J.orElseSucceed(()=>({}))),O=yield*Z.readJson(k.join(H,"package-lock.json")).pipe(J.orElseSucceed(()=>({}))),K=A,y=O,v=new Set([...Object.keys(K?.dependencies||{}),...Object.keys(K?.devDependencies||{}),...Object.keys(K?.peerDependencies||{}),...Object.keys(K?.optionalDependencies||{}),...(q?.add||[]).map((V)=>V.name)]),j=y?.packages?.[""]||{},_=new Set([...Object.keys(j?.dependencies||{}),...Object.keys(j?.devDependencies||{}),...Object.keys(j?.peerDependencies||{}),...Object.keys(j?.optionalDependencies||{})]);for(let V of v)if(!_.has(V)){yield*Y({dir:H,add:N});return}}).pipe(J.withSpan("Npm.checkDirty"));return},J.scoped),I=J.fn("Npm.which")(function*(H){let q=X(H),R=k.join(q,"node_modules",".bin"),N=J.fnUntraced(function*(){let A=yield*z.readDirectory(R).pipe(J.catch(()=>J.succeed([])));if(A.length===0)return L.none();if(A.length===1)return L.some(A[0]);let O=yield*Z.readJson(k.join(q,"node_modules",H,"package.json")).pipe(J.option);if(L.isSome(O)){let K=O.value;if(K?.bin){let y=H.startsWith("@")?H.split("/")[1]:H,v=K.bin;if(typeof v==="string")return L.some(y);let j=Object.keys(v);if(j.length===1)return L.some(j[0]);return v[y]?L.some(y):L.some(j[0])}}return L.some(A[0])});return yield*J.gen(function*(){let A=yield*N();if(L.isSome(A))return L.some(k.join(R,A.value));yield*z.remove(k.join(q,"package-lock.json")).pipe(J.orElseSucceed(()=>{})),yield*G(H);let O=yield*N();if(L.isNone(O))return L.none();return L.some(k.join(R,O.value))}).pipe(J.scoped,J.orElseSucceed(()=>L.none()))});return z0.of({add:G,install:W,outdated:U,which:I})})),Z2=e0.pipe(g.provide(B0.layer),g.provide(f.layer),g.provide(s.layer),g.provide(n0.layer)),{runPromise:A0}=h0(z0,Z2);async function N2(...Z){return A0((Q)=>Q.install(...Z))}async function F2(...Z){let Q=await A0((z)=>z.add(...Z));return{directory:Q.directory,entrypoint:L.getOrUndefined(Q.entrypoint)}}async function K2(...Z){return A0((Q)=>Q.outdated(...Z))}async function w2(...Z){let Q=await A0((z)=>z.which(...Z));return L.getOrUndefined(Q)}var Q2=X0(o0(),1),D0=X0(a0(),1);import u from"path";import{fileURLToPath as _0,pathToFileURL as n}from"url";var O2=["opencode-openai-codex-auth","opencode-copilot-auth"];function _Z(Z){return O2.some((Q)=>Z.includes(Q))}function z2(Z){try{return Q2.default(Z)}catch{}}function NZ(Z){let Q=z2(Z);if(Q?.type==="alias"&&!Q.name){let z=Q.subSpec;if(z?.name){let $=!z.rawSpec||z.rawSpec==="*"?"latest":z.rawSpec;return{pkg:z.name,version:$}}}if(!Q?.name)return{pkg:Z,version:""};if(Q.raw===Q.name)return{pkg:Q.name,version:"latest"};return{pkg:Q.name,version:Q.rawSpec}}var b2=["index.ts","index.tsx","index.js","index.mjs","index.cjs"];function X2(Z){if(J2(Z))return"file";return"npm"}function L2(Z,Q){if(Z.startsWith("file://"))return _0(Z);if(u.isAbsolute(Z))return Z;return u.resolve(Q,Z)}function Y2(Z){return u.isAbsolute(Z)||/^[A-Za-z]:[\\/]/.test(Z)}function T2(Z){if(typeof Z==="string")return Z;if(!a(Z))return;for(let Q of["import","default"]){let z=Z[Q];if(typeof z==="string")return z}return}function y2(Z){let Q=Z.json.main;if(typeof Q!=="string")return;let z=Q.trim();if(!z)return;return z}function H2(Z,Q,z,$){let X=L2(Q,$.dir),Y=S.resolve($.dir),U=S.resolve(X);if(!S.contains(Y,U))throw Error(`Plugin ${Z} resolved ${z} entry outside plugin directory`);return U}function $2(Z,Q,z,$){return n(H2(Z,Q,z,$)).href}function P2(Z,Q,z){let $=z.json.exports;if(a($)){let Y=T2($[`./${Q}`]);if(Y)return $2(Z,Y,Q,z)}if(Q!=="server")return;let X=y2(z);if(!X)return;return $2(Z,X,Q,z)}function S2(Z){if(Z.startsWith("file://"))return _0(Z);if(u.isAbsolute(Z))return Z}async function L0(Z){for(let Q of b2){let z=u.join(Z,Q);if(await S.exists(z))return z}}async function m2(Z){let Q=S2(Z);if(!Q)return;if(!(await S.statAsync(Q))?.isDirectory())return;return Q}async function E2(Z,Q,z,$){let X=X2(Z),Y=$??(X==="npm"?await o(Q):await o(Q).catch(()=>{return}));if(!Y)return Q;let U=P2(Z,z,Y);if(U)return U;let G=await m2(Q);if(z==="tui"){if(X==="file"&&G){let W=await L0(G);if(W)return n(W).href}if(X==="npm")return;if(G)return;return Q}if(G&&a(Y.json.exports)){if(X==="file"){let W=await L0(G);if(W)return n(W).href}return}return Q}function J2(Z){return Z.startsWith("file://")||Z.startsWith(".")||Y2(Z)}async function v2(Z){let Q=Z.startsWith("file://")?_0(Z):Z,z=u.isAbsolute(Q)||/^[A-Za-z]:[\\/]/.test(Q)?Q:u.resolve(Q);if(!(await S.statAsync(z))?.isDirectory()){if(Z.startsWith("file://"))return Z;return n(z).href}if(await S.exists(u.join(z,"package.json")))return n(z).href;let X=await L0(z);if(X)return n(X).href;throw Error(`Plugin directory ${z} is missing package.json or index file`)}async function FZ(Z,Q,z){if(!D0.default.valid(Q)||D0.default.major(Q)===0)return;let $=z??await o(Z).catch(()=>{return});if(!$)return;let X=$.json.engines;if(!a(X))return;let Y=X.qitqode??X.opencode;if(typeof Y!=="string")return;if(!D0.default.satisfies(Q,Y))throw Error(`Plugin requires qitqode ${Y} but running ${Q}`)}async function KZ(Z){if(J2(Z))return v2(Z);let Q=z2(Z),z=Q?.name&&Q.raw===Q.name?`${Q.name}@latest`:Z;return(await Y0.add(z)).directory}async function o(Z){let Q=Z.startsWith("file://")?_0(Z):Z,$=(await S.statAsync(Q))?.isDirectory()?Q:u.dirname(Q),X=u.join($,"package.json"),Y=await S.readJson(X);return{dir:$,pkg:X,json:Y}}async function wZ(Z,Q,z){let $=X2(Z),X=$==="npm"?await o(Q):await o(Q).catch(()=>{return}),Y=await E2(Z,Q,z,X);return{spec:Z,source:$,target:Q,pkg:X,entry:Y}}function OZ(Z,Q){let z=Q.json["oc-themes"];if(z===void 0)return[];if(!Array.isArray(z))throw TypeError(`Plugin ${Z} has invalid oc-themes field`);let $=z.map((X)=>{if(typeof X!=="string")throw TypeError(`Plugin ${Z} has invalid oc-themes entry`);let Y=X.trim();if(!Y)throw TypeError(`Plugin ${Z} has empty oc-themes entry`);if(Y.startsWith("file://")||Y2(Y))throw TypeError(`Plugin ${Z} oc-themes entry must be relative: ${X}`);return H2(Z,Y,"oc-themes",Q)});return Array.from(new Set($))}function bZ(Z,Q){if(Z===void 0)return;if(typeof Z!=="string")throw TypeError(`Plugin ${Q} has invalid id type ${typeof Z}`);let z=Z.trim();if(!z)throw TypeError(`Plugin ${Q} has an empty id`);return z}function LZ(Z,Q,z,$="strict"){let X=Z.default;if(!a(X)){if($==="detect")return;throw TypeError(`Plugin ${Q} must default export an object with ${z}()`)}if($==="detect"&&!("id"in X)&&!("server"in X)&&!("tui"in X))return;let Y="server"in X?X.server:void 0,U="tui"in X?X.tui:void 0;if(Y!==void 0&&typeof Y!=="function")throw TypeError(`Plugin ${Q} has invalid server export`);if(U!==void 0&&typeof U!=="function")throw TypeError(`Plugin ${Q} has invalid tui export`);if(Y!==void 0&&U!==void 0)throw TypeError(`Plugin ${Q} must default export either server() or tui(), not both`);if(z==="server"&&Y===void 0)throw TypeError(`Plugin ${Q} must default export an object with server()`);if(z==="tui"&&U===void 0)throw TypeError(`Plugin ${Q} must default export an object with tui()`);return X}async function TZ(Z,Q,z,$,X){if(Z==="file"){if($)return $;throw TypeError(`Path plugin ${Q} must export id`)}if($)return $;let Y=X??await o(z);if(typeof Y.json.name!=="string"||!Y.json.name.trim())throw TypeError(`Plugin package ${Y.pkg} is missing name`);return Y.json.name.trim()}var S0={};i0(S0,{readFile:()=>l2,files:()=>g2,fileInDirectory:()=>f2,directories:()=>k2,claudeCommandDirectories:()=>u2,ConfigPaths:()=>S0});import y0 from"path";var W2=T0.create("ConfigJsonError",p.object({path:p.string(),message:p.string().optional()})),mZ=T0.create("ConfigInvalidError",p.object({path:p.string(),issues:p.custom().optional(),message:p.string().optional()}));var g2=N0("ConfigPaths.projectFiles")(function*(Z,Q,z){return(yield*(yield*f.Service).up({targets:[`${Z}.jsonc`,`${Z}.json`],start:Q,stop:z})).toReversed()}),k2=N0("ConfigPaths.directories")(function*(Z,Q){let z=yield*f.Service;return P0([H0.Path.config,...!r.QITQODE_DISABLE_PROJECT_CONFIG?yield*z.up({targets:[".qitqode"],start:Z,stop:Q}):[],...yield*z.up({targets:[".qitqode"],start:H0.Path.home,stop:H0.Path.home}),...r.QITQODE_CONFIG_DIR?[r.QITQODE_CONFIG_DIR]:[]])}),u2=N0("ConfigPaths.claudeCommandDirectories")(function*(Z,Q){if(r.QITQODE_DISABLE_CLAUDE_CODE_COMMANDS)return[];let z=yield*f.Service;return P0([y0.join(H0.Path.home,".claude"),...!r.QITQODE_DISABLE_PROJECT_CONFIG?yield*z.up({targets:[".claude"],start:Z,stop:Q}):[]])});function f2(Z,Q){return[y0.join(Z,`${Q}.json`),y0.join(Z,`${Q}.jsonc`)]}async function l2(Z){return S.readText(Z).catch((Q)=>{if(Q.code==="ENOENT")return;throw new W2({path:Z},{cause:Q})})}function W0(Z,Q=!1){let z=Z.length,$=0,X="",Y=0,U=16,G=0,W=0,I=0,H=0,q=0;function R(j,_){let V=0,B=0;while(V<j||!_){let M=Z.charCodeAt($);if(M>=48&&M<=57)B=B*16+M-48;else if(M>=65&&M<=70)B=B*16+M-65+10;else if(M>=97&&M<=102)B=B*16+M-97+10;else break;$++,V++}if(V<j)B=-1;return B}function N(j){$=j,X="",Y=0,U=16,q=0}function A(){let j=$;if(Z.charCodeAt($)===48)$++;else{$++;while($<Z.length&&t(Z.charCodeAt($)))$++}if($<Z.length&&Z.charCodeAt($)===46)if($++,$<Z.length&&t(Z.charCodeAt($))){$++;while($<Z.length&&t(Z.charCodeAt($)))$++}else return q=3,Z.substring(j,$);let _=$;if($<Z.length&&(Z.charCodeAt($)===69||Z.charCodeAt($)===101)){if($++,$<Z.length&&Z.charCodeAt($)===43||Z.charCodeAt($)===45)$++;if($<Z.length&&t(Z.charCodeAt($))){$++;while($<Z.length&&t(Z.charCodeAt($)))$++;_=$}else q=3}return Z.substring(j,_)}function O(){let j="",_=$;while(!0){if($>=z){j+=Z.substring(_,$),q=2;break}let V=Z.charCodeAt($);if(V===34){j+=Z.substring(_,$),$++;break}if(V===92){if(j+=Z.substring(_,$),$++,$>=z){q=2;break}switch(Z.charCodeAt($++)){case 34:j+='"';break;case 92:j+="\\";break;case 47:j+="/";break;case 98:j+="\b";break;case 102:j+="\f";break;case 110:j+=`
3
3
  `;break;case 114:j+="\r";break;case 116:j+="\t";break;case 117:let M=R(4,!0);if(M>=0)j+=String.fromCharCode(M);else q=4;break;default:q=5}_=$;continue}if(V>=0&&V<=31)if(J0(V)){j+=Z.substring(_,$),q=2;break}else q=6;$++}return j}function K(){if(X="",q=0,Y=$,W=G,H=I,$>=z)return Y=z,U=17;let j=Z.charCodeAt($);if(m0(j)){do $++,X+=String.fromCharCode(j),j=Z.charCodeAt($);while(m0(j));return U=15}if(J0(j)){if($++,X+=String.fromCharCode(j),j===13&&Z.charCodeAt($)===10)$++,X+=`
4
4
  `;return G++,I=$,U=14}switch(j){case 123:return $++,U=1;case 125:return $++,U=2;case 91:return $++,U=3;case 93:return $++,U=4;case 58:return $++,U=6;case 44:return $++,U=5;case 34:return $++,X=O(),U=10;case 47:let _=$-1;if(Z.charCodeAt($+1)===47){$+=2;while($<z){if(J0(Z.charCodeAt($)))break;$++}return X=Z.substring(_,$),U=12}if(Z.charCodeAt($+1)===42){$+=2;let V=z-1,B=!1;while($<V){let M=Z.charCodeAt($);if(M===42&&Z.charCodeAt($+1)===47){$+=2,B=!0;break}if($++,J0(M)){if(M===13&&Z.charCodeAt($)===10)$++;G++,I=$}}if(!B)$++,q=1;return X=Z.substring(_,$),U=13}return X+=String.fromCharCode(j),$++,U=16;case 45:if(X+=String.fromCharCode(j),$++,$===z||!t(Z.charCodeAt($)))return U=16;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return X+=A(),U=11;default:while($<z&&y(j))$++,j=Z.charCodeAt($);if(Y!==$){switch(X=Z.substring(Y,$),X){case"true":return U=8;case"false":return U=9;case"null":return U=7}return U=16}return X+=String.fromCharCode(j),$++,U=16}}function y(j){if(m0(j)||J0(j))return!1;switch(j){case 125:case 93:case 123:case 91:case 34:case 58:case 44:case 47:return!1}return!0}function v(){let j;do j=K();while(j>=12&&j<=15);return j}return{setPosition:N,getPosition:()=>$,scan:Q?v:K,getToken:()=>U,getTokenValue:()=>X,getTokenOffset:()=>Y,getTokenLength:()=>$-Y,getTokenStartLine:()=>W,getTokenStartCharacter:()=>Y-H,getTokenError:()=>q}}function m0(Z){return Z===32||Z===9}function J0(Z){return Z===10||Z===13}function t(Z){return Z>=48&&Z<=57}var G2;(function(Z){Z[Z.lineFeed=10]="lineFeed",Z[Z.carriageReturn=13]="carriageReturn",Z[Z.space=32]="space",Z[Z._0=48]="_0",Z[Z._1=49]="_1",Z[Z._2=50]="_2",Z[Z._3=51]="_3",Z[Z._4=52]="_4",Z[Z._5=53]="_5",Z[Z._6=54]="_6",Z[Z._7=55]="_7",Z[Z._8=56]="_8",Z[Z._9=57]="_9",Z[Z.a=97]="a",Z[Z.b=98]="b",Z[Z.c=99]="c",Z[Z.d=100]="d",Z[Z.e=101]="e",Z[Z.f=102]="f",Z[Z.g=103]="g",Z[Z.h=104]="h",Z[Z.i=105]="i",Z[Z.j=106]="j",Z[Z.k=107]="k",Z[Z.l=108]="l",Z[Z.m=109]="m",Z[Z.n=110]="n",Z[Z.o=111]="o",Z[Z.p=112]="p",Z[Z.q=113]="q",Z[Z.r=114]="r",Z[Z.s=115]="s",Z[Z.t=116]="t",Z[Z.u=117]="u",Z[Z.v=118]="v",Z[Z.w=119]="w",Z[Z.x=120]="x",Z[Z.y=121]="y",Z[Z.z=122]="z",Z[Z.A=65]="A",Z[Z.B=66]="B",Z[Z.C=67]="C",Z[Z.D=68]="D",Z[Z.E=69]="E",Z[Z.F=70]="F",Z[Z.G=71]="G",Z[Z.H=72]="H",Z[Z.I=73]="I",Z[Z.J=74]="J",Z[Z.K=75]="K",Z[Z.L=76]="L",Z[Z.M=77]="M",Z[Z.N=78]="N",Z[Z.O=79]="O",Z[Z.P=80]="P",Z[Z.Q=81]="Q",Z[Z.R=82]="R",Z[Z.S=83]="S",Z[Z.T=84]="T",Z[Z.U=85]="U",Z[Z.V=86]="V",Z[Z.W=87]="W",Z[Z.X=88]="X",Z[Z.Y=89]="Y",Z[Z.Z=90]="Z",Z[Z.asterisk=42]="asterisk",Z[Z.backslash=92]="backslash",Z[Z.closeBrace=125]="closeBrace",Z[Z.closeBracket=93]="closeBracket",Z[Z.colon=58]="colon",Z[Z.comma=44]="comma",Z[Z.dot=46]="dot",Z[Z.doubleQuote=34]="doubleQuote",Z[Z.minus=45]="minus",Z[Z.openBrace=123]="openBrace",Z[Z.openBracket=91]="openBracket",Z[Z.plus=43]="plus",Z[Z.slash=47]="slash",Z[Z.formFeed=12]="formFeed",Z[Z.tab=9]="tab"})(G2||(G2={}));var x=Array(20).fill(0).map((Z,Q)=>{return" ".repeat(Q)});var E0={" ":{"\n":Array(200).fill(0).map((Z,Q)=>{return`
5
5
  `+" ".repeat(Q)}),"\r":Array(200).fill(0).map((Z,Q)=>{return"\r"+" ".repeat(Q)}),"\r\n":Array(200).fill(0).map((Z,Q)=>{return`\r
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Cd as y,Ed as T,Fd as t,Gd as O,Hd as l,Jd as v,Kd as Q,Ld as X,Md as J}from"./chunk-9g05wsae.js";import"./chunk-x1dfc7qd.js";import{Od as w}from"./chunk-wmmck56g.js";import{Sf as f}from"./chunk-ntmn6epc.js";import{Lg as Y,Mg as mt,Ng as pt,Og as st,Pg as et,Qg as ft,Rg as E,qh as q}from"./chunk-1qw3yh13.js";import{sh as Mt}from"./chunk-ckhhm2m8.js";import"./chunk-tp7sfreh.js";import"./chunk-q6x5bmc3.js";import"./chunk-n1m5qdf5.js";import"./chunk-zeh3mjgp.js";import"./chunk-prrrw8t8.js";import"./chunk-tz8qhbk9.js";import"./chunk-k19zvbzh.js";import{Cj as nt,Jj as L,fl as F}from"./chunk-q39h31te.js";import"./chunk-0x0a51w3.js";import{Pl as $}from"./chunk-7myavy3p.js";import"./chunk-fegrrsfj.js";import"./chunk-c4x99ayd.js";import"./chunk-w0fg8n1f.js";import{Lo as P,Mo as h}from"./chunk-0pbpzty2.js";import"./chunk-w8xaw2dv.js";import"./chunk-tq258v8s.js";import"./chunk-jc0wbpjq.js";import"./chunk-jfy6bfvv.js";import"./chunk-aej69zjj.js";import"./chunk-98nh88th.js";import"./chunk-t7v8wzr9.js";import"./chunk-er5q8nhp.js";import"./chunk-cqtkxwd8.js";import"./chunk-h6htvj2y.js";import"./chunk-2qy62cv4.js";import"./chunk-t2n6fmpy.js";import"./chunk-x1naayst.js";import"./chunk-ng85b73s.js";import"./chunk-351wfvhp.js";import"./chunk-hmm1m733.js";import"./chunk-k5vwx1nv.js";import"./chunk-ej3gmaba.js";import"./chunk-3nc9wy1m.js";import"./chunk-r8ddb02d.js";import"./chunk-dhvwrrqx.js";import"./chunk-56cty7nr.js";import"./chunk-thbjhgw0.js";import{Gs as g,ct as A}from"./chunk-v7yvnnmr.js";import{Gt as D}from"./chunk-b5x3zghc.js";import"./chunk-t1f7jeat.js";import"./chunk-tk6gjy9d.js";import"./chunk-pkdk0ppc.js";import"./chunk-hrnx60em.js";import"./chunk-bbznk59q.js";import"./chunk-01gtn79f.js";import{$H as a}from"./chunk-meaa7wrs.js";import"./chunk-0ddhkapd.js";import"./chunk-gvj8qg7x.js";import{lP as ut}from"./chunk-fa03gsff.js";import W from"path";function G(o){switch(o){case"authenticated":return"\u2713";case"expired":return"\u26A0";case"not_authenticated":return"\u2717"}}function H(o){switch(o){case"authenticated":return"authenticated";case"expired":return"expired";case"not_authenticated":return"not authenticated"}}function N(o){return typeof o==="object"&&o!==null&&"type"in o}function k(o){return N(o)&&o.type==="remote"}function B(o){return Object.entries(o.mcp??{}).filter((e)=>N(e[1]))}function U(o,e){let r=o.mcp_origins?.[e];if(!r)return"qitqode";let i=A.Path.home,m=r.source===i?"~":r.source.startsWith(i+W.sep)?"~"+r.source.slice(i.length):r.source;return`${r.type}:${m}`}function C(o){return B(o).filter((e)=>k(e[1])&&e[1].oauth!==!1)}async function I(){return q.runPromise(a.gen(function*(){let o=yield*F.Service,e=yield*E.Service,r=yield*o.get(),i=yield*e.status(),m=yield*a.all(Object.fromEntries(B(r).map(([p])=>[p,e.hasStoredTokens(p)])),{concurrency:"unbounded"});return{config:r,statuses:i,stored:m}}))}async function S(){return q.runPromise(a.gen(function*(){let o=yield*F.Service,e=yield*E.Service,r=yield*o.get(),i=yield*a.all(Object.fromEntries(C(r).map(([m])=>[m,e.getAuthStatus(m)])),{concurrency:"unbounded"});return{config:r,auth:i}}))}async function V(o,e=!1){let r=[W.join(o,"qitqode.json"),W.join(o,"qitqode.jsonc")];if(!e)r.push(W.join(o,".qitqode","qitqode.json"),W.join(o,".qitqode","qitqode.jsonc"));for(let i of r)if(await D.exists(i))return i;return r[0]}async function R(o,e,r){let i="{}";if(await D.exists(r))i=await D.readText(r);let m=P(i,["mcp",o],e,{formattingOptions:{tabSize:2,insertSpaces:!0}});return await D.write(r,h(i,m)),r}var tt=ut(Mt(),1);function yt(o){let e=tt.parse(o);if(!e.every((r)=>typeof r==="string"))throw Error("Shell operators are not supported; enter only the command and its arguments");if(e.length===0)throw Error("Command is required");return e}var ot=w({command:"add",describe:"add an MCP server",async handler(){await $.provide({directory:process.cwd(),async fn(){f.empty(),O("Add MCP server");let o=$.project,[e,r]=await Promise.all([V($.worktree),V(A.Path.config,!0)]),i=r;if(o.vcs==="git"){let c=await X({message:"Location",options:[{label:"Current project",value:e,hint:e},{label:"Global",value:r,hint:r}]});if(y(c))throw new f.CancelledError;i=c}let m=await J({message:"Enter MCP server name",validate:(c)=>c&&c.length>0?void 0:"Required"});if(y(m))throw new f.CancelledError;let p=await X({message:"Select MCP server type",options:[{label:"Local",value:"local",hint:"Run a local command"},{label:"Remote",value:"remote",hint:"Connect to a remote URL"}]});if(y(p))throw new f.CancelledError;if(p==="local"){let c=await J({message:"Enter command to run",placeholder:"e.g., qode x @modelcontextprotocol/server-filesystem",validate:(s)=>s&&s.length>0?void 0:"Required"});if(y(c))throw new f.CancelledError;let u;try{u=yt(c)}catch(s){t.error(s instanceof Error?s.message:"Invalid command"),l("MCP server was not added");return}await R(m,{type:"local",command:u},i),t.success(`MCP server "${m}" added to ${i}`),l("MCP server added successfully");return}if(p==="remote"){let c=await J({message:"Enter MCP server URL",placeholder:"e.g., https://example.com/mcp",validate:(s)=>{if(!s)return"Required";if(s.length===0)return"Required";return URL.canParse(s)?void 0:"Invalid URL"}});if(y(c))throw new f.CancelledError;let u=await T({message:"Does this server require OAuth authentication?",initialValue:!1});if(y(u))throw new f.CancelledError;let n;if(u){let s=await T({message:"Do you have a pre-registered client ID?",initialValue:!1});if(y(s))throw new f.CancelledError;if(s){let d=await J({message:"Enter client ID",validate:(j)=>j&&j.length>0?void 0:"Required"});if(y(d))throw new f.CancelledError;let M=await T({message:"Do you have a client secret?",initialValue:!1});if(y(M))throw new f.CancelledError;let _;if(M){let j=await v({message:"Enter client secret"});if(y(j))throw new f.CancelledError;_=j}n={type:"remote",url:c,oauth:{clientId:d,..._&&{clientSecret:_}}}}else n={type:"remote",url:c,oauth:{}}}else n={type:"remote",url:c,oauth:!1};await R(m,n,i),t.success(`MCP server "${m}" added to ${i}`)}l("MCP server added successfully")}})}});var it=w({command:"list",aliases:["ls"],describe:"list MCP servers and their status",async handler(){await $.provide({directory:process.cwd(),async fn(){f.empty(),O("MCP Servers");let{config:o,statuses:e,stored:r}=await I(),i=B(o);if(i.length===0){t.warn("No MCP servers configured"),l("Add servers with: qode mcp add");return}for(let[m,p]of i){let c=e[m],u=k(p)&&p.oauth!==!1,n=r[m],s,d,M="";if(!c)s="\u25CB",d="not initialized";else if(c.status==="connected"){if(s="\u2713",d="connected",u&&n)M=" (OAuth)"}else if(c.status==="disabled")s="\u25CB",d="disabled";else if(c.status==="pending")s="\u25CB",d="pending approval";else if(c.status==="needs_auth")s="\u26A0",d="needs authentication";else if(c.status==="needs_client_registration")s="\u2717",d="needs client registration",M=`
2
+ import{Cd as y,Ed as T,Fd as t,Gd as O,Hd as l,Jd as v,Kd as Q,Ld as X,Md as J}from"./chunk-9g05wsae.js";import"./chunk-x1dfc7qd.js";import{Od as w}from"./chunk-wmmck56g.js";import{Sf as f}from"./chunk-ntmn6epc.js";import{Lg as Y,Mg as mt,Ng as pt,Og as st,Pg as et,Qg as ft,Rg as E,qh as q}from"./chunk-88ckmmdr.js";import{sh as Mt}from"./chunk-w9mdrb90.js";import"./chunk-qxtz0tfd.js";import"./chunk-q6x5bmc3.js";import"./chunk-n1m5qdf5.js";import"./chunk-zeh3mjgp.js";import"./chunk-prrrw8t8.js";import"./chunk-tz8qhbk9.js";import"./chunk-k19zvbzh.js";import{Cj as nt,Jj as L,fl as F}from"./chunk-651fyxmn.js";import"./chunk-0czxqcg7.js";import{Pl as $}from"./chunk-6ba9fc92.js";import"./chunk-7skp0dmg.js";import"./chunk-c4x99ayd.js";import"./chunk-6dznrhs4.js";import{Lo as P,Mo as h}from"./chunk-8fn883z8.js";import"./chunk-w8xaw2dv.js";import"./chunk-tq258v8s.js";import"./chunk-th5z0zx7.js";import"./chunk-jfy6bfvv.js";import"./chunk-v0jnnpsz.js";import"./chunk-98nh88th.js";import"./chunk-t7v8wzr9.js";import"./chunk-er5q8nhp.js";import"./chunk-cqtkxwd8.js";import"./chunk-h6htvj2y.js";import"./chunk-2qy62cv4.js";import"./chunk-t2n6fmpy.js";import"./chunk-x1naayst.js";import"./chunk-ng85b73s.js";import"./chunk-351wfvhp.js";import"./chunk-hmm1m733.js";import"./chunk-yt6cfsdh.js";import"./chunk-yja3y138.js";import"./chunk-3nc9wy1m.js";import"./chunk-r8ddb02d.js";import"./chunk-dhvwrrqx.js";import"./chunk-56cty7nr.js";import"./chunk-thbjhgw0.js";import{Gs as g,ct as A}from"./chunk-esjs9s9g.js";import{Gt as D}from"./chunk-b5x3zghc.js";import"./chunk-t1f7jeat.js";import"./chunk-tk6gjy9d.js";import"./chunk-pkdk0ppc.js";import"./chunk-hrnx60em.js";import"./chunk-bbznk59q.js";import"./chunk-01gtn79f.js";import{$H as a}from"./chunk-meaa7wrs.js";import"./chunk-0ddhkapd.js";import"./chunk-gvj8qg7x.js";import{lP as ut}from"./chunk-fa03gsff.js";import W from"path";function G(o){switch(o){case"authenticated":return"\u2713";case"expired":return"\u26A0";case"not_authenticated":return"\u2717"}}function H(o){switch(o){case"authenticated":return"authenticated";case"expired":return"expired";case"not_authenticated":return"not authenticated"}}function N(o){return typeof o==="object"&&o!==null&&"type"in o}function k(o){return N(o)&&o.type==="remote"}function B(o){return Object.entries(o.mcp??{}).filter((e)=>N(e[1]))}function U(o,e){let r=o.mcp_origins?.[e];if(!r)return"qitqode";let i=A.Path.home,m=r.source===i?"~":r.source.startsWith(i+W.sep)?"~"+r.source.slice(i.length):r.source;return`${r.type}:${m}`}function C(o){return B(o).filter((e)=>k(e[1])&&e[1].oauth!==!1)}async function I(){return q.runPromise(a.gen(function*(){let o=yield*F.Service,e=yield*E.Service,r=yield*o.get(),i=yield*e.status(),m=yield*a.all(Object.fromEntries(B(r).map(([p])=>[p,e.hasStoredTokens(p)])),{concurrency:"unbounded"});return{config:r,statuses:i,stored:m}}))}async function S(){return q.runPromise(a.gen(function*(){let o=yield*F.Service,e=yield*E.Service,r=yield*o.get(),i=yield*a.all(Object.fromEntries(C(r).map(([m])=>[m,e.getAuthStatus(m)])),{concurrency:"unbounded"});return{config:r,auth:i}}))}async function V(o,e=!1){let r=[W.join(o,"qitqode.json"),W.join(o,"qitqode.jsonc")];if(!e)r.push(W.join(o,".qitqode","qitqode.json"),W.join(o,".qitqode","qitqode.jsonc"));for(let i of r)if(await D.exists(i))return i;return r[0]}async function R(o,e,r){let i="{}";if(await D.exists(r))i=await D.readText(r);let m=P(i,["mcp",o],e,{formattingOptions:{tabSize:2,insertSpaces:!0}});return await D.write(r,h(i,m)),r}var tt=ut(Mt(),1);function yt(o){let e=tt.parse(o);if(!e.every((r)=>typeof r==="string"))throw Error("Shell operators are not supported; enter only the command and its arguments");if(e.length===0)throw Error("Command is required");return e}var ot=w({command:"add",describe:"add an MCP server",async handler(){await $.provide({directory:process.cwd(),async fn(){f.empty(),O("Add MCP server");let o=$.project,[e,r]=await Promise.all([V($.worktree),V(A.Path.config,!0)]),i=r;if(o.vcs==="git"){let c=await X({message:"Location",options:[{label:"Current project",value:e,hint:e},{label:"Global",value:r,hint:r}]});if(y(c))throw new f.CancelledError;i=c}let m=await J({message:"Enter MCP server name",validate:(c)=>c&&c.length>0?void 0:"Required"});if(y(m))throw new f.CancelledError;let p=await X({message:"Select MCP server type",options:[{label:"Local",value:"local",hint:"Run a local command"},{label:"Remote",value:"remote",hint:"Connect to a remote URL"}]});if(y(p))throw new f.CancelledError;if(p==="local"){let c=await J({message:"Enter command to run",placeholder:"e.g., qode x @modelcontextprotocol/server-filesystem",validate:(s)=>s&&s.length>0?void 0:"Required"});if(y(c))throw new f.CancelledError;let u;try{u=yt(c)}catch(s){t.error(s instanceof Error?s.message:"Invalid command"),l("MCP server was not added");return}await R(m,{type:"local",command:u},i),t.success(`MCP server "${m}" added to ${i}`),l("MCP server added successfully");return}if(p==="remote"){let c=await J({message:"Enter MCP server URL",placeholder:"e.g., https://example.com/mcp",validate:(s)=>{if(!s)return"Required";if(s.length===0)return"Required";return URL.canParse(s)?void 0:"Invalid URL"}});if(y(c))throw new f.CancelledError;let u=await T({message:"Does this server require OAuth authentication?",initialValue:!1});if(y(u))throw new f.CancelledError;let n;if(u){let s=await T({message:"Do you have a pre-registered client ID?",initialValue:!1});if(y(s))throw new f.CancelledError;if(s){let d=await J({message:"Enter client ID",validate:(j)=>j&&j.length>0?void 0:"Required"});if(y(d))throw new f.CancelledError;let M=await T({message:"Do you have a client secret?",initialValue:!1});if(y(M))throw new f.CancelledError;let _;if(M){let j=await v({message:"Enter client secret"});if(y(j))throw new f.CancelledError;_=j}n={type:"remote",url:c,oauth:{clientId:d,..._&&{clientSecret:_}}}}else n={type:"remote",url:c,oauth:{}}}else n={type:"remote",url:c,oauth:!1};await R(m,n,i),t.success(`MCP server "${m}" added to ${i}`)}l("MCP server added successfully")}})}});var it=w({command:"list",aliases:["ls"],describe:"list MCP servers and their status",async handler(){await $.provide({directory:process.cwd(),async fn(){f.empty(),O("MCP Servers");let{config:o,statuses:e,stored:r}=await I(),i=B(o);if(i.length===0){t.warn("No MCP servers configured"),l("Add servers with: qode mcp add");return}for(let[m,p]of i){let c=e[m],u=k(p)&&p.oauth!==!1,n=r[m],s,d,M="";if(!c)s="\u25CB",d="not initialized";else if(c.status==="connected"){if(s="\u2713",d="connected",u&&n)M=" (OAuth)"}else if(c.status==="disabled")s="\u25CB",d="disabled";else if(c.status==="pending")s="\u25CB",d="pending approval";else if(c.status==="needs_auth")s="\u26A0",d="needs authentication";else if(c.status==="needs_client_registration")s="\u2717",d="needs client registration",M=`
3
3
  `+c.error;else s="\u2717",d="failed",M=`
4
4
  `+c.error;let _=p.type==="remote"?L.redactString(p.url):L.redactCommand(p.command).join(" ");t.info(`${s} ${m} ${f.Style.TEXT_DIM}${d} ${U(o,m)}${M}
5
5
  ${f.Style.TEXT_DIM}${_}`)}l(`${i.length} server(s)`)}})}});var dt=w({command:"auth [name]",describe:"authenticate with an OAuth-enabled MCP server",builder:(o)=>o.positional("name",{describe:"name of the MCP server",type:"string"}).command(ct),async handler(o){await $.provide({directory:process.cwd(),async fn(){f.empty(),O("MCP OAuth Authentication");let{config:e,auth:r}=await S(),i=e.mcp??{},m=C(e);if(m.length===0){t.warn("No OAuth-capable MCP servers configured"),t.info("Remote MCP servers support OAuth by default. Add a remote server in qitqode.json:"),t.info(`
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Tf as a,Uf as b}from"./chunk-c4mxtqyq.js";import"./chunk-v7yvnnmr.js";import"./chunk-b5x3zghc.js";import"./chunk-t1f7jeat.js";import"./chunk-tk6gjy9d.js";import"./chunk-pkdk0ppc.js";import"./chunk-hrnx60em.js";import"./chunk-bbznk59q.js";import"./chunk-01gtn79f.js";import"./chunk-meaa7wrs.js";import"./chunk-fa03gsff.js";export{a as start,b as Heap};
2
+ import{Tf as a,Uf as b}from"./chunk-5rcnwm9j.js";import"./chunk-esjs9s9g.js";import"./chunk-b5x3zghc.js";import"./chunk-t1f7jeat.js";import"./chunk-tk6gjy9d.js";import"./chunk-pkdk0ppc.js";import"./chunk-hrnx60em.js";import"./chunk-bbznk59q.js";import"./chunk-01gtn79f.js";import"./chunk-meaa7wrs.js";import"./chunk-fa03gsff.js";export{a as start,b as Heap};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{jg as a,kg as b,lg as c}from"./chunk-rmmrnx95.js";import"./chunk-q39h31te.js";import"./chunk-0x0a51w3.js";import"./chunk-7myavy3p.js";import"./chunk-fegrrsfj.js";import"./chunk-c4x99ayd.js";import"./chunk-w0fg8n1f.js";import"./chunk-0pbpzty2.js";import"./chunk-w8xaw2dv.js";import"./chunk-tq258v8s.js";import"./chunk-jc0wbpjq.js";import"./chunk-jfy6bfvv.js";import"./chunk-aej69zjj.js";import"./chunk-98nh88th.js";import"./chunk-t7v8wzr9.js";import"./chunk-er5q8nhp.js";import"./chunk-cqtkxwd8.js";import"./chunk-h6htvj2y.js";import"./chunk-2qy62cv4.js";import"./chunk-t2n6fmpy.js";import"./chunk-x1naayst.js";import"./chunk-ng85b73s.js";import"./chunk-k5vwx1nv.js";import"./chunk-ej3gmaba.js";import"./chunk-3nc9wy1m.js";import"./chunk-r8ddb02d.js";import"./chunk-dhvwrrqx.js";import"./chunk-56cty7nr.js";import"./chunk-thbjhgw0.js";import"./chunk-v7yvnnmr.js";import"./chunk-b5x3zghc.js";import"./chunk-t1f7jeat.js";import"./chunk-tk6gjy9d.js";import"./chunk-pkdk0ppc.js";import"./chunk-hrnx60em.js";import"./chunk-bbznk59q.js";import"./chunk-01gtn79f.js";import"./chunk-meaa7wrs.js";import"./chunk-gvj8qg7x.js";import"./chunk-fa03gsff.js";export{b as run,a as encodeDir,c as ClaudeImport};
2
+ import{jg as a,kg as b,lg as c}from"./chunk-w5nwkb0s.js";import"./chunk-651fyxmn.js";import"./chunk-0czxqcg7.js";import"./chunk-6ba9fc92.js";import"./chunk-7skp0dmg.js";import"./chunk-c4x99ayd.js";import"./chunk-6dznrhs4.js";import"./chunk-8fn883z8.js";import"./chunk-w8xaw2dv.js";import"./chunk-tq258v8s.js";import"./chunk-th5z0zx7.js";import"./chunk-jfy6bfvv.js";import"./chunk-v0jnnpsz.js";import"./chunk-98nh88th.js";import"./chunk-t7v8wzr9.js";import"./chunk-er5q8nhp.js";import"./chunk-cqtkxwd8.js";import"./chunk-h6htvj2y.js";import"./chunk-2qy62cv4.js";import"./chunk-t2n6fmpy.js";import"./chunk-x1naayst.js";import"./chunk-ng85b73s.js";import"./chunk-yt6cfsdh.js";import"./chunk-yja3y138.js";import"./chunk-3nc9wy1m.js";import"./chunk-r8ddb02d.js";import"./chunk-dhvwrrqx.js";import"./chunk-56cty7nr.js";import"./chunk-thbjhgw0.js";import"./chunk-esjs9s9g.js";import"./chunk-b5x3zghc.js";import"./chunk-t1f7jeat.js";import"./chunk-tk6gjy9d.js";import"./chunk-pkdk0ppc.js";import"./chunk-hrnx60em.js";import"./chunk-bbznk59q.js";import"./chunk-01gtn79f.js";import"./chunk-meaa7wrs.js";import"./chunk-gvj8qg7x.js";import"./chunk-fa03gsff.js";export{b as run,a as encodeDir,c as ClaudeImport};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Bd as b}from"./chunk-wmqcz5rb.js";import{Od as f}from"./chunk-wmmck56g.js";import{qh as S}from"./chunk-1qw3yh13.js";import"./chunk-ckhhm2m8.js";import"./chunk-tp7sfreh.js";import"./chunk-q6x5bmc3.js";import"./chunk-n1m5qdf5.js";import"./chunk-zeh3mjgp.js";import"./chunk-prrrw8t8.js";import"./chunk-tz8qhbk9.js";import"./chunk-k19zvbzh.js";import{el as v}from"./chunk-q39h31te.js";import"./chunk-0x0a51w3.js";import{Fl as R,Pl as k,xl as U}from"./chunk-7myavy3p.js";import"./chunk-fegrrsfj.js";import"./chunk-c4x99ayd.js";import"./chunk-w0fg8n1f.js";import"./chunk-0pbpzty2.js";import"./chunk-w8xaw2dv.js";import"./chunk-tq258v8s.js";import"./chunk-jc0wbpjq.js";import"./chunk-jfy6bfvv.js";import"./chunk-aej69zjj.js";import"./chunk-98nh88th.js";import"./chunk-t7v8wzr9.js";import"./chunk-er5q8nhp.js";import"./chunk-cqtkxwd8.js";import"./chunk-h6htvj2y.js";import"./chunk-2qy62cv4.js";import"./chunk-t2n6fmpy.js";import"./chunk-x1naayst.js";import"./chunk-ng85b73s.js";import"./chunk-351wfvhp.js";import"./chunk-hmm1m733.js";import"./chunk-k5vwx1nv.js";import"./chunk-ej3gmaba.js";import"./chunk-3nc9wy1m.js";import"./chunk-r8ddb02d.js";import"./chunk-dhvwrrqx.js";import"./chunk-56cty7nr.js";import"./chunk-thbjhgw0.js";import{Vs as Z}from"./chunk-v7yvnnmr.js";import"./chunk-b5x3zghc.js";import"./chunk-t1f7jeat.js";import"./chunk-tk6gjy9d.js";import"./chunk-pkdk0ppc.js";import"./chunk-hrnx60em.js";import"./chunk-bbznk59q.js";import"./chunk-01gtn79f.js";import"./chunk-meaa7wrs.js";import"./chunk-0ddhkapd.js";import"./chunk-gvj8qg7x.js";import"./chunk-fa03gsff.js";var i=f({command:"stats",describe:"show token usage and cost statistics",builder:(z)=>{return z.option("days",{describe:"show stats for the last N days (default: all time)",type:"number"}).option("tools",{describe:"number of tools to show (default: all)",type:"number"}).option("models",{describe:"show model statistics (default: hidden). Pass a number to show top N, otherwise shows all"}).option("project",{describe:"filter by project (default: all projects, empty string: current project)",type:"string"})},handler:async(z)=>{await b(process.cwd(),async()=>{let E=await y(z.days,z.project),_;if(z.models===!0)_=1/0;else if(typeof z.models==="number")_=z.models;u(E,z.tools,_)})}});async function w(){return k.project}async function p(){return R.use((E)=>E.select().from(U).all()).map((E)=>v.fromRow(E))}async function y(z,E){let _=await p(),L=86400000,J=(()=>{if(z===void 0)return 0;if(z===0){let V=new Date;return V.setHours(0,0,0,0),V.getTime()}return Date.now()-z*86400000})(),K=(()=>{if(z===void 0)return;if(z===0)return 1;return z})(),Y=J>0?_.filter((V)=>V.time.updated>=J):_;if(E!==void 0)if(E===""){let V=await w();Y=Y.filter((F)=>F.projectID===V.id)}else Y=Y.filter((V)=>V.projectID===E);let G={totalSessions:Y.length,totalMessages:0,totalCost:0,totalTokens:{input:0,output:0,reasoning:0,cache:{read:0,write:0}},toolUsage:{},modelUsage:{},dateRange:{earliest:Date.now(),latest:Date.now()},days:0,costPerDay:0,tokensPerSession:0,medianTokensPerSession:0};if(Y.length>1000)console.log(`Large dataset detected (${Y.length} sessions). This may take a while...`);if(Y.length===0)return G.days=K??0,G;let C=Date.now(),x=0,X=[],h=20;for(let V=0;V<Y.length;V+=h){let D=Y.slice(V,V+h).map(async(Q)=>{let W=await S.runPromise(v.Service.use((O)=>O.messages({sessionID:Q.id,agentID:"*"}))),N=0,H={input:0,output:0,reasoning:0,cache:{read:0,write:0}},j={},A={};for(let O of W){if(O.info.role==="assistant"){N+=O.info.cost||0;let B=`${O.info.providerID}/${O.info.modelID}`;if(!A[B])A[B]={messages:0,tokens:{input:0,output:0,cache:{read:0,write:0}},cost:0};if(A[B].messages++,A[B].cost+=O.info.cost||0,O.info.tokens)H.input+=O.info.tokens.input||0,H.output+=O.info.tokens.output||0,H.reasoning+=O.info.tokens.reasoning||0,H.cache.read+=O.info.tokens.cache?.read||0,H.cache.write+=O.info.tokens.cache?.write||0,A[B].tokens.input+=O.info.tokens.input||0,A[B].tokens.output+=(O.info.tokens.output||0)+(O.info.tokens.reasoning||0),A[B].tokens.cache.read+=O.info.tokens.cache?.read||0,A[B].tokens.cache.write+=O.info.tokens.cache?.write||0}for(let B of O.parts)if(B.type==="tool"&&B.tool)j[B.tool]=(j[B.tool]||0)+1}return{messageCount:W.length,sessionCost:N,sessionTokens:H,sessionTotalTokens:H.input+H.output+H.reasoning+H.cache.read+H.cache.write,sessionToolUsage:j,sessionModelUsage:A,earliestTime:J>0?Q.time.updated:Q.time.created,latestTime:Q.time.updated}}),M=await Promise.all(D);for(let Q of M){C=Math.min(C,Q.earliestTime),x=Math.max(x,Q.latestTime),X.push(Q.sessionTotalTokens),G.totalMessages+=Q.messageCount,G.totalCost+=Q.sessionCost,G.totalTokens.input+=Q.sessionTokens.input,G.totalTokens.output+=Q.sessionTokens.output,G.totalTokens.reasoning+=Q.sessionTokens.reasoning,G.totalTokens.cache.read+=Q.sessionTokens.cache.read,G.totalTokens.cache.write+=Q.sessionTokens.cache.write;for(let[W,N]of Object.entries(Q.sessionToolUsage))G.toolUsage[W]=(G.toolUsage[W]||0)+N;for(let[W,N]of Object.entries(Q.sessionModelUsage)){if(!G.modelUsage[W])G.modelUsage[W]={messages:0,tokens:{input:0,output:0,cache:{read:0,write:0}},cost:0};G.modelUsage[W].messages+=N.messages,G.modelUsage[W].tokens.input+=N.tokens.input,G.modelUsage[W].tokens.output+=N.tokens.output,G.modelUsage[W].tokens.cache.read+=N.tokens.cache.read,G.modelUsage[W].tokens.cache.write+=N.tokens.cache.write,G.modelUsage[W].cost+=N.cost}}}let $=Math.max(1,Math.ceil((x-C)/86400000)),q=K??$;G.dateRange={earliest:C,latest:x},G.days=q,G.costPerDay=G.totalCost/q;let I=G.totalTokens.input+G.totalTokens.output+G.totalTokens.reasoning+G.totalTokens.cache.read+G.totalTokens.cache.write;G.tokensPerSession=Y.length>0?I/Y.length:0,X.sort((V,F)=>V-F);let P=Math.floor(X.length/2);return G.medianTokensPerSession=X.length===0?0:X.length%2===0?(X[P-1]+X[P])/2:X[P],G}function u(z,E,_){function J(x,X){let $=55-x.length-X.length,q=Math.max(0,$);return`\u2502${x}${" ".repeat(q)}${X} \u2502`}console.log("\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510"),console.log("\u2502 OVERVIEW \u2502"),console.log("\u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524"),console.log(J("Sessions",z.totalSessions.toLocaleString())),console.log(J("Messages",z.totalMessages.toLocaleString())),console.log(J("Days",z.days.toString())),console.log("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518"),console.log(),console.log("\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510"),console.log("\u2502 COST & TOKENS \u2502"),console.log("\u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524");let K=isNaN(z.totalCost)?0:z.totalCost,Y=isNaN(z.costPerDay)?0:z.costPerDay,G=isNaN(z.tokensPerSession)?0:z.tokensPerSession;console.log(J("Total Cost",`$${K.toFixed(2)}`)),console.log(J("Avg Cost/Day",`$${Y.toFixed(2)}`)),console.log(J("Avg Tokens/Session",Z.number(Math.round(G))));let C=isNaN(z.medianTokensPerSession)?0:z.medianTokensPerSession;if(console.log(J("Median Tokens/Session",Z.number(Math.round(C)))),console.log(J("Input",Z.number(z.totalTokens.input))),console.log(J("Output",Z.number(z.totalTokens.output))),console.log(J("Cache Read",Z.number(z.totalTokens.cache.read))),console.log(J("Cache Write",Z.number(z.totalTokens.cache.write))),console.log("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518"),console.log(),_!==void 0&&Object.keys(z.modelUsage).length>0){let x=Object.entries(z.modelUsage).sort(([,h],[,$])=>$.messages-h.messages),X=_===1/0?x:x.slice(0,_);console.log("\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510"),console.log("\u2502 MODEL USAGE \u2502"),console.log("\u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524");for(let[h,$]of X)console.log(`\u2502 ${h.padEnd(54)} \u2502`),console.log(J(" Messages",$.messages.toLocaleString())),console.log(J(" Input Tokens",Z.number($.tokens.input))),console.log(J(" Output Tokens",Z.number($.tokens.output))),console.log(J(" Cache Read",Z.number($.tokens.cache.read))),console.log(J(" Cache Write",Z.number($.tokens.cache.write))),console.log(J(" Cost",`$${$.cost.toFixed(4)}`)),console.log("\u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524");process.stdout.write("\x1B[1A"),console.log("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518")}if(console.log(),Object.keys(z.toolUsage).length>0){let x=Object.entries(z.toolUsage).sort(([,q],[,I])=>I-q),X=E?x.slice(0,E):x;console.log("\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510"),console.log("\u2502 TOOL USAGE \u2502"),console.log("\u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524");let h=Math.max(...X.map(([,q])=>q)),$=Object.values(z.toolUsage).reduce((q,I)=>q+I,0);for(let[q,I]of X){let P=Math.max(1,Math.floor(I/h*20)),V="\u2588".repeat(P),F=(I/$*100).toFixed(1),D=18,W=` ${(q.length>18?q.substring(0,16)+"..":q).padEnd(18)} ${V.padEnd(20)} ${I.toString().padStart(3)} (${F.padStart(4)}%)`,N=Math.max(0,56-W.length-1);console.log(`\u2502${W}${" ".repeat(N)} \u2502`)}console.log("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518")}console.log()}export{u as displayStats,y as aggregateSessionStats,i as StatsCommand};
2
+ import{Bd as b}from"./chunk-rkb592nb.js";import{Od as f}from"./chunk-wmmck56g.js";import{qh as S}from"./chunk-88ckmmdr.js";import"./chunk-w9mdrb90.js";import"./chunk-qxtz0tfd.js";import"./chunk-q6x5bmc3.js";import"./chunk-n1m5qdf5.js";import"./chunk-zeh3mjgp.js";import"./chunk-prrrw8t8.js";import"./chunk-tz8qhbk9.js";import"./chunk-k19zvbzh.js";import{el as v}from"./chunk-651fyxmn.js";import"./chunk-0czxqcg7.js";import{Fl as R,Pl as k,xl as U}from"./chunk-6ba9fc92.js";import"./chunk-7skp0dmg.js";import"./chunk-c4x99ayd.js";import"./chunk-6dznrhs4.js";import"./chunk-8fn883z8.js";import"./chunk-w8xaw2dv.js";import"./chunk-tq258v8s.js";import"./chunk-th5z0zx7.js";import"./chunk-jfy6bfvv.js";import"./chunk-v0jnnpsz.js";import"./chunk-98nh88th.js";import"./chunk-t7v8wzr9.js";import"./chunk-er5q8nhp.js";import"./chunk-cqtkxwd8.js";import"./chunk-h6htvj2y.js";import"./chunk-2qy62cv4.js";import"./chunk-t2n6fmpy.js";import"./chunk-x1naayst.js";import"./chunk-ng85b73s.js";import"./chunk-351wfvhp.js";import"./chunk-hmm1m733.js";import"./chunk-yt6cfsdh.js";import"./chunk-yja3y138.js";import"./chunk-3nc9wy1m.js";import"./chunk-r8ddb02d.js";import"./chunk-dhvwrrqx.js";import"./chunk-56cty7nr.js";import"./chunk-thbjhgw0.js";import{Vs as Z}from"./chunk-esjs9s9g.js";import"./chunk-b5x3zghc.js";import"./chunk-t1f7jeat.js";import"./chunk-tk6gjy9d.js";import"./chunk-pkdk0ppc.js";import"./chunk-hrnx60em.js";import"./chunk-bbznk59q.js";import"./chunk-01gtn79f.js";import"./chunk-meaa7wrs.js";import"./chunk-0ddhkapd.js";import"./chunk-gvj8qg7x.js";import"./chunk-fa03gsff.js";var i=f({command:"stats",describe:"show token usage and cost statistics",builder:(z)=>{return z.option("days",{describe:"show stats for the last N days (default: all time)",type:"number"}).option("tools",{describe:"number of tools to show (default: all)",type:"number"}).option("models",{describe:"show model statistics (default: hidden). Pass a number to show top N, otherwise shows all"}).option("project",{describe:"filter by project (default: all projects, empty string: current project)",type:"string"})},handler:async(z)=>{await b(process.cwd(),async()=>{let E=await y(z.days,z.project),_;if(z.models===!0)_=1/0;else if(typeof z.models==="number")_=z.models;u(E,z.tools,_)})}});async function w(){return k.project}async function p(){return R.use((E)=>E.select().from(U).all()).map((E)=>v.fromRow(E))}async function y(z,E){let _=await p(),L=86400000,J=(()=>{if(z===void 0)return 0;if(z===0){let V=new Date;return V.setHours(0,0,0,0),V.getTime()}return Date.now()-z*86400000})(),K=(()=>{if(z===void 0)return;if(z===0)return 1;return z})(),Y=J>0?_.filter((V)=>V.time.updated>=J):_;if(E!==void 0)if(E===""){let V=await w();Y=Y.filter((F)=>F.projectID===V.id)}else Y=Y.filter((V)=>V.projectID===E);let G={totalSessions:Y.length,totalMessages:0,totalCost:0,totalTokens:{input:0,output:0,reasoning:0,cache:{read:0,write:0}},toolUsage:{},modelUsage:{},dateRange:{earliest:Date.now(),latest:Date.now()},days:0,costPerDay:0,tokensPerSession:0,medianTokensPerSession:0};if(Y.length>1000)console.log(`Large dataset detected (${Y.length} sessions). This may take a while...`);if(Y.length===0)return G.days=K??0,G;let C=Date.now(),x=0,X=[],h=20;for(let V=0;V<Y.length;V+=h){let D=Y.slice(V,V+h).map(async(Q)=>{let W=await S.runPromise(v.Service.use((O)=>O.messages({sessionID:Q.id,agentID:"*"}))),N=0,H={input:0,output:0,reasoning:0,cache:{read:0,write:0}},j={},A={};for(let O of W){if(O.info.role==="assistant"){N+=O.info.cost||0;let B=`${O.info.providerID}/${O.info.modelID}`;if(!A[B])A[B]={messages:0,tokens:{input:0,output:0,cache:{read:0,write:0}},cost:0};if(A[B].messages++,A[B].cost+=O.info.cost||0,O.info.tokens)H.input+=O.info.tokens.input||0,H.output+=O.info.tokens.output||0,H.reasoning+=O.info.tokens.reasoning||0,H.cache.read+=O.info.tokens.cache?.read||0,H.cache.write+=O.info.tokens.cache?.write||0,A[B].tokens.input+=O.info.tokens.input||0,A[B].tokens.output+=(O.info.tokens.output||0)+(O.info.tokens.reasoning||0),A[B].tokens.cache.read+=O.info.tokens.cache?.read||0,A[B].tokens.cache.write+=O.info.tokens.cache?.write||0}for(let B of O.parts)if(B.type==="tool"&&B.tool)j[B.tool]=(j[B.tool]||0)+1}return{messageCount:W.length,sessionCost:N,sessionTokens:H,sessionTotalTokens:H.input+H.output+H.reasoning+H.cache.read+H.cache.write,sessionToolUsage:j,sessionModelUsage:A,earliestTime:J>0?Q.time.updated:Q.time.created,latestTime:Q.time.updated}}),M=await Promise.all(D);for(let Q of M){C=Math.min(C,Q.earliestTime),x=Math.max(x,Q.latestTime),X.push(Q.sessionTotalTokens),G.totalMessages+=Q.messageCount,G.totalCost+=Q.sessionCost,G.totalTokens.input+=Q.sessionTokens.input,G.totalTokens.output+=Q.sessionTokens.output,G.totalTokens.reasoning+=Q.sessionTokens.reasoning,G.totalTokens.cache.read+=Q.sessionTokens.cache.read,G.totalTokens.cache.write+=Q.sessionTokens.cache.write;for(let[W,N]of Object.entries(Q.sessionToolUsage))G.toolUsage[W]=(G.toolUsage[W]||0)+N;for(let[W,N]of Object.entries(Q.sessionModelUsage)){if(!G.modelUsage[W])G.modelUsage[W]={messages:0,tokens:{input:0,output:0,cache:{read:0,write:0}},cost:0};G.modelUsage[W].messages+=N.messages,G.modelUsage[W].tokens.input+=N.tokens.input,G.modelUsage[W].tokens.output+=N.tokens.output,G.modelUsage[W].tokens.cache.read+=N.tokens.cache.read,G.modelUsage[W].tokens.cache.write+=N.tokens.cache.write,G.modelUsage[W].cost+=N.cost}}}let $=Math.max(1,Math.ceil((x-C)/86400000)),q=K??$;G.dateRange={earliest:C,latest:x},G.days=q,G.costPerDay=G.totalCost/q;let I=G.totalTokens.input+G.totalTokens.output+G.totalTokens.reasoning+G.totalTokens.cache.read+G.totalTokens.cache.write;G.tokensPerSession=Y.length>0?I/Y.length:0,X.sort((V,F)=>V-F);let P=Math.floor(X.length/2);return G.medianTokensPerSession=X.length===0?0:X.length%2===0?(X[P-1]+X[P])/2:X[P],G}function u(z,E,_){function J(x,X){let $=55-x.length-X.length,q=Math.max(0,$);return`\u2502${x}${" ".repeat(q)}${X} \u2502`}console.log("\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510"),console.log("\u2502 OVERVIEW \u2502"),console.log("\u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524"),console.log(J("Sessions",z.totalSessions.toLocaleString())),console.log(J("Messages",z.totalMessages.toLocaleString())),console.log(J("Days",z.days.toString())),console.log("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518"),console.log(),console.log("\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510"),console.log("\u2502 COST & TOKENS \u2502"),console.log("\u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524");let K=isNaN(z.totalCost)?0:z.totalCost,Y=isNaN(z.costPerDay)?0:z.costPerDay,G=isNaN(z.tokensPerSession)?0:z.tokensPerSession;console.log(J("Total Cost",`$${K.toFixed(2)}`)),console.log(J("Avg Cost/Day",`$${Y.toFixed(2)}`)),console.log(J("Avg Tokens/Session",Z.number(Math.round(G))));let C=isNaN(z.medianTokensPerSession)?0:z.medianTokensPerSession;if(console.log(J("Median Tokens/Session",Z.number(Math.round(C)))),console.log(J("Input",Z.number(z.totalTokens.input))),console.log(J("Output",Z.number(z.totalTokens.output))),console.log(J("Cache Read",Z.number(z.totalTokens.cache.read))),console.log(J("Cache Write",Z.number(z.totalTokens.cache.write))),console.log("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518"),console.log(),_!==void 0&&Object.keys(z.modelUsage).length>0){let x=Object.entries(z.modelUsage).sort(([,h],[,$])=>$.messages-h.messages),X=_===1/0?x:x.slice(0,_);console.log("\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510"),console.log("\u2502 MODEL USAGE \u2502"),console.log("\u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524");for(let[h,$]of X)console.log(`\u2502 ${h.padEnd(54)} \u2502`),console.log(J(" Messages",$.messages.toLocaleString())),console.log(J(" Input Tokens",Z.number($.tokens.input))),console.log(J(" Output Tokens",Z.number($.tokens.output))),console.log(J(" Cache Read",Z.number($.tokens.cache.read))),console.log(J(" Cache Write",Z.number($.tokens.cache.write))),console.log(J(" Cost",`$${$.cost.toFixed(4)}`)),console.log("\u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524");process.stdout.write("\x1B[1A"),console.log("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518")}if(console.log(),Object.keys(z.toolUsage).length>0){let x=Object.entries(z.toolUsage).sort(([,q],[,I])=>I-q),X=E?x.slice(0,E):x;console.log("\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510"),console.log("\u2502 TOOL USAGE \u2502"),console.log("\u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524");let h=Math.max(...X.map(([,q])=>q)),$=Object.values(z.toolUsage).reduce((q,I)=>q+I,0);for(let[q,I]of X){let P=Math.max(1,Math.floor(I/h*20)),V="\u2588".repeat(P),F=(I/$*100).toFixed(1),D=18,W=` ${(q.length>18?q.substring(0,16)+"..":q).padEnd(18)} ${V.padEnd(20)} ${I.toString().padStart(3)} (${F.padStart(4)}%)`,N=Math.max(0,56-W.length-1);console.log(`\u2502${W}${" ".repeat(N)} \u2502`)}console.log("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518")}console.log()}export{u as displayStats,y as aggregateSessionStats,i as StatsCommand};