rovecode 0.4.0-beta.2 → 0.4.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (189) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +13 -0
  3. package/dist/cli/app-j6gn14w3.js +2 -0
  4. package/dist/cli/{ask-user-p8hq4xgj.js → ask-user-cwstt8fz.js} +1 -1
  5. package/dist/cli/auth-login-9bbp9915.js +2 -0
  6. package/dist/cli/{bench-xv3ypwev.js → bench-16zqdms5.js} +1 -1
  7. package/dist/cli/catalog-1xchffa4.js +2 -0
  8. package/dist/cli/cli-1n1zb64f.js +2 -0
  9. package/dist/cli/client-2t9gjkck.js +2 -0
  10. package/dist/cli/{commands-3p7e4xxs.js → commands-exafvm2b.js} +1 -1
  11. package/dist/cli/connect-6zde0kn3.js +2 -0
  12. package/dist/cli/{context-cmd-eqxmxhzq.js → context-cmd-5t43wgqt.js} +1 -1
  13. package/dist/cli/context-report-kt01pw8y.js +2 -0
  14. package/dist/cli/{count-remote-mby98cd0.js → count-remote-ap7x3vh6.js} +1 -1
  15. package/dist/cli/{design-122y0axd.js → design-ne5zszyh.js} +1 -1
  16. package/dist/cli/dispatch-2r5myxye.js +2 -0
  17. package/dist/cli/doctor-ws4fh4tn.js +3 -0
  18. package/dist/cli/{executor-ftvg6tsy.js → executor-bdrjn634.js} +1 -1
  19. package/dist/cli/export-1mxb9g5p.js +2 -0
  20. package/dist/cli/{files-cez9a96p.js → files-g104xghh.js} +1 -1
  21. package/dist/cli/gauntlet-07xrjpj7.js +2 -0
  22. package/dist/cli/{gauntlet-runner-r515m7kk.js → gauntlet-runner-xvy64436.js} +1 -1
  23. package/dist/cli/{gauntlet-wave3-bnkjk2v2.js → gauntlet-wave3-jm91yt5w.js} +1 -1
  24. package/dist/cli/{gauntlet-wave4-acs9s60q.js → gauntlet-wave4-r13py7p1.js} +1 -1
  25. package/dist/cli/hashline-znvrat11.js +2 -0
  26. package/dist/cli/http-xafw6fsh.js +143 -0
  27. package/dist/cli/{index-z5qt1s76.js → index-1sgjm25y.js} +1 -1
  28. package/dist/cli/init-g2m0tn4m.js +51 -0
  29. package/dist/cli/install-avaqjjqq.js +2 -0
  30. package/dist/cli/loop-mmpfft01.js +2 -0
  31. package/dist/cli/{main-a3f51n0x.js → main-0904f6ps.js} +1 -1
  32. package/dist/cli/{main-f33fc5je.js → main-0ab9fc26.js} +2 -2
  33. package/dist/cli/{main-n6qrdbmy.js → main-0mtcdbs7.js} +2 -2
  34. package/dist/cli/main-0z1w2zsg.js +3 -0
  35. package/dist/cli/{main-rvetps99.js → main-1dchs7xv.js} +2 -2
  36. package/dist/cli/{main-rpg7h8mb.js → main-1ereejm1.js} +2 -2
  37. package/dist/cli/{main-6vjeds42.js → main-1k1kw6b5.js} +2 -2
  38. package/dist/cli/{main-hrrvcfan.js → main-27y4sm2k.js} +2 -2
  39. package/dist/cli/{main-8c1tbazx.js → main-2wwjex5j.js} +2 -2
  40. package/dist/cli/main-2yfck9b5.js +3 -0
  41. package/dist/cli/main-2zmzgkwh.js +3 -0
  42. package/dist/cli/{main-xt9zc3n6.js → main-351pz3z7.js} +1 -1
  43. package/dist/cli/{main-kba6zeyd.js → main-3gjqfh7a.js} +1 -1
  44. package/dist/cli/{main-s4bb0jav.js → main-3nf3kgve.js} +1 -1
  45. package/dist/cli/{main-2z3dek0b.js → main-3pjrb2hd.js} +1 -1
  46. package/dist/cli/{main-qj2djy17.js → main-3rxcvgna.js} +3 -3
  47. package/dist/cli/{main-9a9rnh47.js → main-4b3jgy66.js} +1 -1
  48. package/dist/cli/{main-6dtqmbt6.js → main-4wndhjdc.js} +1 -1
  49. package/dist/cli/{main-9ht36z12.js → main-4xcmvxnk.js} +2 -2
  50. package/dist/cli/{main-vp2dfb7s.js → main-5tbz0wbz.js} +2 -2
  51. package/dist/cli/{main-wpkyraxh.js → main-5ywnwthm.js} +2 -2
  52. package/dist/cli/{main-yrjt2sqt.js → main-6b62vkz0.js} +2 -2
  53. package/dist/cli/{main-2zgsknth.js → main-6dnk69vp.js} +1 -1
  54. package/dist/cli/{main-nvc3yjay.js → main-6genrmhs.js} +2 -2
  55. package/dist/cli/{main-rsy72qmw.js → main-73g7eff4.js} +2 -2
  56. package/dist/cli/{main-jak598k9.js → main-7c5thhjd.js} +1 -1
  57. package/dist/cli/{main-y5c82rxr.js → main-7rn6bqje.js} +1 -1
  58. package/dist/cli/{main-4p4e2w7x.js → main-80haw7qk.js} +2 -2
  59. package/dist/cli/{main-01pv9206.js → main-875s60s2.js} +2 -2
  60. package/dist/cli/{main-ywbxshqc.js → main-8kjxbpw4.js} +1 -1
  61. package/dist/cli/{main-1ztz6fkj.js → main-90ds1z4e.js} +1 -1
  62. package/dist/cli/{main-mjt2p7aj.js → main-9etavkew.js} +1 -1
  63. package/dist/cli/main-a9njrkk1.js +3 -0
  64. package/dist/cli/{main-fvnpq46y.js → main-aecrjq2d.js} +2 -2
  65. package/dist/cli/{main-23q7cmww.js → main-ck9asesq.js} +2 -2
  66. package/dist/cli/{main-wqt32p5x.js → main-cta9racd.js} +2 -2
  67. package/dist/cli/{main-wm997zjx.js → main-ddv7j2ag.js} +1 -1
  68. package/dist/cli/{main-ntqef02r.js → main-dfreez27.js} +1 -1
  69. package/dist/cli/{main-m8vm17zq.js → main-f7rw7des.js} +1 -1
  70. package/dist/cli/{main-rebtt91r.js → main-ggcn7rd7.js} +2 -2
  71. package/dist/cli/{main-gbbty4d4.js → main-gzkmycnv.js} +1 -1
  72. package/dist/cli/{main-vxnwe5xx.js → main-hq51jg8v.js} +2 -2
  73. package/dist/cli/{main-vqbr22sz.js → main-jft389w9.js} +2 -2
  74. package/dist/cli/{main-qvarybsp.js → main-k1eqkg83.js} +2 -2
  75. package/dist/cli/{main-2wyax8k9.js → main-k2y8a2aw.js} +2 -2
  76. package/dist/cli/main-kcpbykxz.js +4 -0
  77. package/dist/cli/{main-45rn3trk.js → main-kd488vje.js} +1 -1
  78. package/dist/cli/main-kh32yvgk.js +5 -0
  79. package/dist/cli/{main-z13755t8.js → main-kqxnqjnv.js} +4 -4
  80. package/dist/cli/{main-b8zq261k.js → main-kyn0xnsg.js} +2 -2
  81. package/dist/cli/{main-evgz4mp5.js → main-m1kk6fp5.js} +1 -1
  82. package/dist/cli/{main-5py0rkmc.js → main-mv40pcr2.js} +1 -1
  83. package/dist/cli/{main-vhrrq337.js → main-n0t3973w.js} +1 -1
  84. package/dist/cli/{main-s9v8k74e.js → main-pknhvrmj.js} +2 -2
  85. package/dist/cli/{main-kwwsz6rq.js → main-pn1w7a7j.js} +2 -2
  86. package/dist/cli/{main-6h9x282m.js → main-prxxs70n.js} +2 -2
  87. package/dist/cli/{main-2rzbexn2.js → main-q3vsesf9.js} +1 -1
  88. package/dist/cli/{main-gth53dnt.js → main-rdgdw24b.js} +7 -7
  89. package/dist/cli/{main-4y0tnfpa.js → main-rfth4tbm.js} +1 -1
  90. package/dist/cli/{main-wk2csfnj.js → main-rg0wn0xf.js} +2 -2
  91. package/dist/cli/{main-xx2z3zh5.js → main-sdmxhtv8.js} +1 -1
  92. package/dist/cli/{main-mg9b20ac.js → main-skbp13js.js} +1 -1
  93. package/dist/cli/{main-xfekqh9m.js → main-t4xnd213.js} +1 -1
  94. package/dist/cli/{main-7kt6r53y.js → main-vqak588n.js} +2 -2
  95. package/dist/cli/{main-hqbz10aw.js → main-w2n1303f.js} +1 -1
  96. package/dist/cli/{main-na7wse0x.js → main-wbrdspr2.js} +2 -2
  97. package/dist/cli/{main-a2yfvcy9.js → main-wsrg79c1.js} +2 -2
  98. package/dist/cli/{main-hzwtsb2m.js → main-x4r0fne4.js} +2 -2
  99. package/dist/cli/{main-78gq4bt9.js → main-xea2f3tn.js} +1 -1
  100. package/dist/cli/{main-v8y60bb2.js → main-xg704a3c.js} +1 -1
  101. package/dist/cli/{main-p0cfn6nr.js → main-xvnrabfp.js} +2 -2
  102. package/dist/cli/{main-45ejth3a.js → main-xy53xf0r.js} +2 -2
  103. package/dist/cli/{main-x9ct6y1a.js → main-y1fqy60y.js} +2 -2
  104. package/dist/cli/{main-j7ttv0sd.js → main-yn8cd281.js} +4 -4
  105. package/dist/cli/{main-zc7pyrbj.js → main-yr0ksc0h.js} +1 -1
  106. package/dist/cli/{main-tkgarpjj.js → main-z2ex2vyf.js} +2 -2
  107. package/dist/cli/{main-mgb9ccnx.js → main-z3aayzvq.js} +1 -1
  108. package/dist/cli/{main-tjvwmscs.js → main-zaqh35jg.js} +2 -2
  109. package/dist/cli/{main-edxc3yzt.js → main-zc2e8e46.js} +2 -2
  110. package/dist/cli/{main-bxtvnf6d.js → main-zzrfw6cf.js} +2 -2
  111. package/dist/cli/main.js +5 -4
  112. package/dist/cli/{market-cmd-bm5xvn9f.js → market-cmd-e14kmx9n.js} +2 -2
  113. package/dist/cli/{mcp-login-bthtfpt7.js → mcp-login-wq7ktdek.js} +1 -1
  114. package/dist/cli/mcp-market-cmd-9mg3jecy.js +2 -0
  115. package/dist/cli/{notify-54v5z9dz.js → notify-b7qc0cjb.js} +1 -1
  116. package/dist/cli/{oauth-g5gme95c.js → oauth-z8whcgfx.js} +1 -1
  117. package/dist/cli/{output-satndjap.js → output-b3ewj3ps.js} +1 -1
  118. package/dist/cli/{profiles-sfhpbq3m.js → profiles-6mr5he5e.js} +1 -1
  119. package/dist/cli/{provider-config-hv3xtdt4.js → provider-config-g7j42q8x.js} +1 -1
  120. package/dist/cli/provider-jr1y8vvm.js +2 -0
  121. package/dist/cli/registry-s8yk86g0.js +2 -0
  122. package/dist/cli/{registry-fh0hdnyn.js → registry-t6p8d4mn.js} +1 -1
  123. package/dist/cli/{repl-t4z03mqq.js → repl-bajwe1mh.js} +1 -1
  124. package/dist/cli/{resume-fqt4chg8.js → resume-rwn9nz7y.js} +1 -1
  125. package/dist/cli/run-flags-nah7ndpt.js +2 -0
  126. package/dist/cli/runtime-n7gafzhb.js +2 -0
  127. package/dist/cli/{sandbox-config-g4qxd7y5.js → sandbox-config-emdy18x4.js} +1 -1
  128. package/dist/cli/{server-r0b6bksk.js → server-b0nvs2bn.js} +1 -1
  129. package/dist/cli/session-arg-y75wd4kj.js +2 -0
  130. package/dist/cli/session-j62evmjq.js +2 -0
  131. package/dist/cli/{sessions-cmd-adw7svfn.js → sessions-cmd-tsnwz0ns.js} +1 -1
  132. package/dist/cli/{settings-y9rzcqx8.js → settings-df10wfez.js} +1 -1
  133. package/dist/cli/{setup-jmbr11j0.js → setup-jzvv72fg.js} +1 -1
  134. package/dist/cli/{sextant-smoke-tcth0vea.js → sextant-smoke-37m81ke6.js} +1 -1
  135. package/dist/cli/{skills-cmd-zbdy99v6.js → skills-cmd-gjxnxnhx.js} +1 -1
  136. package/dist/cli/smoke-p7748apt.js +8 -0
  137. package/dist/cli/{start-chat-p01cdks3.js → start-chat-s4st3mm0.js} +3 -3
  138. package/dist/cli/stream-gmeyewds.js +2 -0
  139. package/dist/cli/task-gh0kkp3n.js +2 -0
  140. package/dist/cli/tasks-z1kfpe8e.js +2 -0
  141. package/dist/cli/{thinking-a5ngvqyh.js → thinking-0eqkrz6t.js} +1 -1
  142. package/dist/cli/{todo-1wxpcecx.js → todo-5brcrt9m.js} +1 -1
  143. package/dist/cli/{tools-x1tj4fxm.js → tools-7pzm0vj9.js} +1 -1
  144. package/dist/cli/{tools-2ftsya7w.js → tools-s635p6s8.js} +1 -1
  145. package/dist/cli/trust-cmd-cjav8zgm.js +2 -0
  146. package/dist/cli/{update-check-ygt3vd7m.js → update-check-pt31bm2f.js} +1 -1
  147. package/dist/cli/{update-cmd-v23qhr8c.js → update-cmd-tk131s9t.js} +1 -1
  148. package/dist/cli/{voice-g1gtck92.js → voice-56nabd8d.js} +1 -1
  149. package/dist/cli/{webfetch-0nnrjgb5.js → webfetch-xd8q596m.js} +1 -1
  150. package/dist/cli/{websearch-f0vr2p7d.js → websearch-5hkf98k1.js} +1 -1
  151. package/dist/cli/workflow-cmd-cy3cvzjp.js +4 -0
  152. package/dist/cli/{workspace-9rq1w4ta.js → workspace-q10g5z3e.js} +1 -1
  153. package/dist/lib/index.js +44 -44
  154. package/dist/lib/plugins.js +54 -5
  155. package/dist/lib/public-api.js +15 -15
  156. package/dist/lib/sdk.js +360 -0
  157. package/package.json +3 -2
  158. package/dist/cli/app-dybnr56b.js +0 -2
  159. package/dist/cli/auth-login-ewpgw5sm.js +0 -2
  160. package/dist/cli/catalog-737wb2s0.js +0 -2
  161. package/dist/cli/cli-arhg40m0.js +0 -2
  162. package/dist/cli/client-cf2pxx8q.js +0 -2
  163. package/dist/cli/connect-3q93d7cb.js +0 -2
  164. package/dist/cli/context-report-hbw9zfes.js +0 -2
  165. package/dist/cli/dispatch-b4egzvvh.js +0 -2
  166. package/dist/cli/doctor-x4jkv72e.js +0 -3
  167. package/dist/cli/export-pdgdhkch.js +0 -2
  168. package/dist/cli/gauntlet-r3xxaszc.js +0 -2
  169. package/dist/cli/hashline-ewg5hbe3.js +0 -2
  170. package/dist/cli/http-n0kehsk8.js +0 -5
  171. package/dist/cli/install-80mp63kx.js +0 -2
  172. package/dist/cli/loop-12twjcat.js +0 -2
  173. package/dist/cli/main-7jd5vh3x.js +0 -4
  174. package/dist/cli/main-mg4f96e1.js +0 -3
  175. package/dist/cli/main-wgph00xf.js +0 -5
  176. package/dist/cli/main-ys6zj3yr.js +0 -3
  177. package/dist/cli/mcp-market-cmd-mbeshfyd.js +0 -2
  178. package/dist/cli/provider-kwzq6g84.js +0 -2
  179. package/dist/cli/registry-y1y8e94r.js +0 -2
  180. package/dist/cli/run-flags-rysbag9t.js +0 -2
  181. package/dist/cli/runtime-j19fjbsa.js +0 -2
  182. package/dist/cli/session-arg-txmn5g4x.js +0 -2
  183. package/dist/cli/session-ed250d9j.js +0 -2
  184. package/dist/cli/smoke-1bg937kx.js +0 -8
  185. package/dist/cli/stream-4wmyaypz.js +0 -2
  186. package/dist/cli/task-eg4s093s.js +0 -2
  187. package/dist/cli/tasks-12v9rr9k.js +0 -2
  188. package/dist/cli/trust-cmd-hccxehzb.js +0 -2
  189. package/dist/rovecode.exe +0 -4
@@ -2,4 +2,4 @@
2
2
  import{wn as X}from"./main-qsevpgsv.js";import{realpathSync as _,statSync as f}from"fs";import{basename as S,dirname as $,isAbsolute as P,join as Q,parse as g,relative as D,resolve as V,sep as N}from"path";function G(q){let x=V(q);try{return _.native(x)}catch{}let z=$(x);return z===x?x:Q(G(z),S(x))}function E(q,x){return V(P(x)?x:Q(q,x))}function K(q,x){let z=D(q,x);return z===""||!P(z)&&z!==".."&&!z.startsWith(`..${N}`)}function k(q,x){return!K(G(q),G(x))}function L(q){try{return f(q).isDirectory()}catch{return!1}}function I(q){let x=G(q);return Q(L(x)?x:$(x),"*")}function v(q,x,z){let F=z.filter((B)=>B.action===C&&B.effect==="allow"&&B.resource!=="*").map((B)=>B.resource);return`${q} is outside the workspace ${x}${F.length>0?` and its roots ${F.join(", ")}`:""} \u2014 allow once/always for this directory, or start rovecode with --add-dir <dir> to make it a workspace root`}function R(q,x){let z=`--add-dir "${x}": the directory name contains "*", a rule wildcard (no escape syntax) \u2014 its allow rule would match more than that directory`;if(q.includes("*"))return z;if(!L(q))return`--add-dir "${x}" is not a directory`;let F=G(q);if(F.includes("*"))return z;if(g(F).root===F)return`--add-dir "${x}" is a filesystem root \u2014 it would disable the workspace boundary \u2014 pass --yolo instead`;return}function m(q,x=[],z=process.cwd()){let F=G(q),B=[],H=[];for(let U of x){let Y=V(z,U),Z=R(Y,U);if(Z!==void 0)throw new O(Z);let M=G(Y);if(K(F,M)||B.some((J)=>K(J,M))){H.push(U);continue}for(let J of B)if(K(M,J))H.push(J);B.splice(0,B.length,...B.filter((J)=>!K(M,J)),M)}let W=H.length===0?[]:[`rovecode: --add-dir: ${H.length} value${H.length===1?"":"s"} dropped \u2014 already inside the workspace ${F} or another root: ${H.join(", ")}`];return{dirs:B,notes:W}}class T{cwd;dirs;notes;constructor(q,x={dirs:[],notes:[]}){this.cwd=G(q),this.dirs=x.dirs,this.notes=x.notes}rootOf(q){let x=G(q);return this.dirs.find((z)=>K(z,x))}rules(){return this.dirs.map((q)=>({action:C,resource:Q(q,"*"),effect:"allow"}))}acceptEditsRules(){return this.dirs.map((q)=>({action:"file.write",resource:Q(q,"*"),effect:"allow"}))}describe(){return this.dirs.map((q)=>`+${q}`).join(" ")}promptLine(){return this.dirs.length===0?"":`
3
3
 
4
4
  Additional workspace roots (name them by absolute path): ${this.dirs.join(", ")}`}checkpointNote(){return this.dirs.length===0?"":`roots: ${this.describe()} \u2014 checkpoints cover ${this.cwd} only; a change under an added root is not snapshotted and /restore does not undo it`}}var C="file.external",O;var j=X(()=>{O=class O extends Error{constructor(q){super(q);this.name="WorkspaceRootError"}}});
5
- export{C as sl,G as tl,E as ul,K as vl,k as wl,I as xl,v as yl,R as zl,O as Al,m as Bl,T as Cl,j as Dl};
5
+ export{C as Sl,G as Tl,E as Ul,K as Vl,k as Wl,I as Xl,v as Yl,R as Zl,O as _l,m as $l,T as am,j as bm};
@@ -1,9 +1,9 @@
1
1
  // @bun
2
- import{th as G,vh as K}from"./main-xt9zc3n6.js";import{wn as J}from"./main-qsevpgsv.js";function H(b,A,q){let p=G(b,A,q);return`- ${b.name}${b.version?` (v${b.version})`:""}: ${b.description}${p==="stale"?" [stale]":""}`}function W(b,A=Date.now()){let q=b.list();if(q.length===0||q.length>Q)return"";return q.map((p)=>H(p,b.usage(p.name),A)).join(`
2
+ import{df as G,ff as K}from"./main-351pz3z7.js";import{wn as J}from"./main-qsevpgsv.js";function H(b,A,q){let p=G(b,A,q);return`- ${b.name}${b.version?` (v${b.version})`:""}: ${b.description}${p==="stale"?" [stale]":""}`}function W(b,A=Date.now()){let q=b.list();if(q.length===0||q.length>Q)return"";return q.map((p)=>H(p,b.usage(p.name),A)).join(`
3
3
  `)}function Y(b){return[{schema:{name:"skill_view",description:"Read one skill's full instructions. Use when a skill in the index matches the task.",args:{type:"object",properties:{name:{type:"string",description:"skill name from the index"}},required:["name"]}},kind:"read",sequential:!0,execute(p){let C=p,z=typeof C.name==="string"?C.name:"",j=b.get(z);if(!j)return Promise.resolve({ok:!1,output:`no skill named '${z}'`});let F=b.bumpUsage(j),B=`# ${j.name} (v${j.version})
4
4
 
5
5
  ${j.fullDescription}
6
6
 
7
7
  `;return Promise.resolve({ok:!0,output:B+j.body,data:F})}},{schema:{name:"skills_list",description:"List available skills (name, version, description, staleness). Use to discover skills when the system prompt has no skill index.",args:{type:"object",properties:{}}},kind:"read",execute(p,C){b.scan();let z=b.list();if(z.length===0)return Promise.resolve({ok:!0,output:"no skills installed"});let j=Date.now(),F=z.map((B)=>H(B,b.usage(B.name),j));return Promise.resolve({ok:!0,output:F.join(`
8
8
  `),data:{count:z.length}})}}]}var Q=50;var S=J(()=>{K()});
9
- export{Q as ud,W as vd,Y as wd,S as xd};
9
+ export{Q as vd,W as wd,Y as xd,S as yd};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{dm as b,em as U,hm as M,im as N,jm as C,km as w,lm as m,mm as R}from"./main-wk2csfnj.js";import{nm as S,pm as x,qm as V,um as P,vm as z}from"./main-y5c82rxr.js";import{vn as p,wn as _,xn as j}from"./main-qsevpgsv.js";function Y(){return L??=Promise.all([import("@modelcontextprotocol/sdk/client/index.js"),import("@modelcontextprotocol/sdk/client/stdio.js"),import("@modelcontextprotocol/sdk/client/streamableHttp.js"),import("@modelcontextprotocol/sdk/client/sse.js"),import("@modelcontextprotocol/sdk/client/auth.js"),import("@modelcontextprotocol/sdk/types.js")]).then(([q,D,F,H,I,J])=>{return K={Client:q.Client,StdioClientTransport:D.StdioClientTransport,getDefaultEnvironment:D.getDefaultEnvironment,StreamableHTTPClientTransport:F.StreamableHTTPClientTransport,StreamableHTTPError:F.StreamableHTTPError,SSEClientTransport:H.SSEClientTransport,SseError:H.SseError,UnauthorizedError:I.UnauthorizedError,ToolListChangedNotificationSchema:J.ToolListChangedNotificationSchema,PromptListChangedNotificationSchema:J.PromptListChangedNotificationSchema,ResourceListChangedNotificationSchema:J.ResourceListChangedNotificationSchema},K}),L}function E(q){let D=K;return D!==null&&q instanceof D.StreamableHTTPError&&(q.code===404||q.code===405)}function y(q){let D=K;if(D!==null&&(q instanceof D.StreamableHTTPError||q instanceof D.SseError))return q.code===401;return q instanceof Error&&/\(HTTP 401\)/.test(q.message)}function B(q,D){if(q instanceof N)return q.message;let F=K;if(F!==null&&q instanceof F.UnauthorizedError||y(q))return C(D)?"HTTP 401 \u2014 the configured Authorization header was rejected":M(D.name);let H=V(q);return F!==null&&q instanceof F.StreamableHTTPError&&typeof q.code==="number"&&q.code>0&&!H.includes(String(q.code))?`${H} (HTTP ${q.code})`:H}async function O(q,D,F){let H=await Y();if(D==="http"||D==="sse"){if(q.url===void 0)throw Error(`${D} server "${q.name}" has no url`);let I={...q.headers?{requestInit:{headers:q.headers}}:{},...F?{authProvider:F}:{}},J=new URL(q.url);return D==="http"?new H.StreamableHTTPClientTransport(J,I):new H.SSEClientTransport(J,I)}if(q.command===void 0)throw Error(`stdio server "${q.name}" has no command`);return new H.StdioClientTransport({command:q.command,args:q.args??[],env:{...H.getDefaultEnvironment(),...q.env??{}},stderr:"ignore"})}var L=null,K=null;var T=_(()=>{z();R()});var l={};p(l,{runnerTimeoutMessage:()=>k,mcpConfigPath:()=>S,loadMcpConfig:()=>P,isPackageRunner:()=>A,RUNNER_CONNECT_MS:()=>h,McpManager:()=>u});function A(q){if(q.transport!=="stdio"||q.command===void 0)return!1;let D=q.command.split(/[\\/]/).pop()??q.command;return f.has(D.toLowerCase())}function k(q,D){let F=`connect to MCP server "${q.name}" timed out after ${Math.round(D/1000)}s`;if(!A(q))return F;let H=(q.command??"the runner").split(/[\\/]/).pop();return`${F} \u2014 ${H} downloads the server's package on first use. Try again (the download is cached), or install it once so it starts without the network: rovecode mcp add ${q.name} --local --force`}class u{servers=new Map;toolCache=new Map;toolGen=new Map;listeners=new Set;ttl;connectTimeout;callTimeout;transportFactory;authProvider;constructor(q,D={}){this.ttl=D.toolTtlMs??60000,this.connectTimeout=D.connectTimeoutMs??1e4,this.callTimeout=D.callTimeoutMs??120000,this.transportFactory=D.transportFactory,this.authProvider=D.authProvider??d;for(let F of q)if(!this.servers.has(F.name))this.servers.set(F.name,{config:F,client:null,attempted:!1})}serverNames(){return[...this.servers.keys()]}connectedNames(){return[...this.servers.values()].filter((q)=>q.client!==null).map((q)=>q.config.name)}get ttlMs(){return this.ttl}get requestTimeoutMs(){return this.connectTimeout}clientOf(q){let D=this.servers.get(q);if(!D)throw Error(`unknown MCP server "${q}"`);if(!D.client)throw Error(`MCP server "${q}" is not connected${D.lastError?` (${D.lastError})`:""}`);return D.client}connection(q){let D=this.clientOf(q);return{client:D,caps:D.getServerCapabilities()??{}}}onListChanged(q){return this.listeners.add(q),()=>{this.listeners.delete(q)}}invalidate(q,D){if(D==="tools")this.toolCache.delete(q),this.toolGen.set(q,(this.toolGen.get(q)??0)+1);for(let F of this.listeners)try{F(q,D)}catch{}}async connect(){let q=[],D=[...this.servers.values()].filter((H)=>H.config.enabled!==!1&&H.client===null),F=[];for(let H of D){if(F.length>0&&H.connecting===void 0)await v();H.connecting??=this.open(H).finally(()=>{H.connecting=void 0}),F.push(H.connecting.catch((I)=>{q.push({name:H.config.name,error:B(I,H.config)})}))}return await Promise.all(F),{connected:this.connectedNames(),failed:q}}async open(q){let{config:D}=q;q.attempted=!0;try{let F=this.transportFactory?await this.transportFactory(D):void 0,H=F?"custom":D.transport,I=!1,J;try{J=await this.handshake(D,F??await O(D,D.transport,await this.authProvider(D)))}catch(X){if(F!==void 0||D.transport!=="http"||!E(X))throw X;J=await this.handshake(D,await O(D,"sse",await this.authProvider(D))),H="sse",I=!0}await this.armNotifications(D.name,J),q.client=J,q.wire=H,q.fellBack=I,delete q.lastError}catch(F){throw q.lastError=B(F,D),F}}async handshake(q,D){let F=new(await Y()).Client({name:"rovecode",version:"0.1.0"}),H=A(q)?Math.max(this.connectTimeout,h):this.connectTimeout;try{await w(F.connect(D,{timeout:H}),H+2000,k(q,H))}catch(I){throw await F.close().catch(()=>{}),I}return F}async armNotifications(q,D){let F=await Y();D.setNotificationHandler(F.ToolListChangedNotificationSchema,()=>this.invalidate(q,"tools")),D.setNotificationHandler(F.PromptListChangedNotificationSchema,()=>this.invalidate(q,"prompts")),D.setNotificationHandler(F.ResourceListChangedNotificationSchema,()=>this.invalidate(q,"resources"))}async fetchTools(q,D=!1,F){let H=this.clientOf(q),I=this.toolCache.get(q),J=Date.now();if(!D&&I&&J-I.at<this.ttl)return I.tools;let X=this.toolGen.get(q)??0,$=await m("tool",q,async(G)=>{let Q=U(F),Z;try{Z=await H.listTools(G===void 0?void 0:{cursor:G},{timeout:this.connectTimeout,signal:Q.signal})}finally{Q.dispose()}return{items:Z.tools.map((W)=>({name:W.name,description:typeof W.description==="string"?W.description:"",inputSchema:W.inputSchema})),nextCursor:Z.nextCursor}},F);if((this.toolGen.get(q)??0)===X)this.toolCache.set(q,{at:J,tools:$});return $}async listTools(q=!1,D){let F=[];for(let[H,I]of this.servers){if(I.client===null)continue;try{for(let J of await this.fetchTools(H,q,D))F.push({server:H,name:J.name,description:J.description})}catch{}}return F}async toolSchema(q,D,F){try{let H=(await this.fetchTools(q,!1,F)).find((I)=>I.name===D);if(!H)H=(await this.fetchTools(q,!0,F)).find((I)=>I.name===D);return H?.inputSchema}catch{return}}async callTool(q,D,F,H,I){let J=this.servers.get(q);if(!J){let Q=this.serverNames();return{ok:!1,output:`unknown MCP server "${q}". Known servers: ${Q.length>0?Q.join(", "):"(none configured)"}`}}let X=J.client;if(!X)return{ok:!1,output:`MCP server "${q}" is not connected${J.lastError?`: ${J.lastError}`:""}`};if(F!==void 0&&F!==null&&!x(F))return{ok:!1,output:`args for ${q}/${D} must be a JSON object (got ${Array.isArray(F)?"array":typeof F})`};let $;try{$=await this.fetchTools(q,!1,H)}catch(Q){return{ok:!1,output:`failed to list tools on "${q}": ${V(Q)}`}}if(!$.some((Q)=>Q.name===D)){try{$=await this.fetchTools(q,!0,H)}catch{}if(!$.some((Q)=>Q.name===D)){let Q=$.map((Z)=>Z.name).join(", ");return{ok:!1,output:`unknown tool "${D}" on server "${q}". Available: ${Q.length>0?Q:"(none)"}`}}}let G=U(H);try{let Q=await X.callTool({name:D,arguments:F??void 0},void 0,{signal:G.signal,timeout:this.callTimeout,resetTimeoutOnProgress:!0,onprogress:(W)=>I?.(typeof W.message==="string"&&W.message.length>0?W.message:`progress ${W.progress}${typeof W.total==="number"?`/${W.total}`:""}`)}),Z=b(Q.content,Q.structuredContent);if(Q.isError===!0)return{ok:!1,output:Z.length>0?Z:`tool "${D}" reported an error`};return{ok:!0,output:Z}}catch(Q){return{ok:!1,output:`mcp call ${q}/${D} failed: ${V(Q)}`}}finally{G.dispose()}}status(){return[...this.servers.values()].map((q)=>{let D={name:q.config.name,transport:q.config.transport,state:q.config.enabled===!1?"disabled":q.client?"connected":q.attempted&&!q.connecting?"failed":"pending"};if(q.wire!==void 0)D.wire=q.wire;if(q.fellBack)D.fellBack=!0;if(q.lastError!==void 0)D.error=q.lastError;let F=this.toolCache.get(q.config.name);if(F)D.tools=F.tools.length;return D})}async sync(q){let D=new Map(q.map((I)=>[I.name,I])),F=[],H=[];for(let[I,J]of[...this.servers]){if(D.has(I))continue;H.push(I),this.servers.delete(I);for(let X of["tools","prompts","resources"])this.invalidate(I,X);if(J.client)await J.client.close().catch(()=>{})}for(let[I,J]of D){if(this.servers.has(I))continue;this.servers.set(I,{config:J,client:null,attempted:!1}),F.push(I)}return{added:F,removed:H}}async close(){let q=[];for(let D of this.servers.values()){if(D.client)q.push(D.client.close().catch(()=>{})),D.client=null;D.attempted=!1,delete D.wire,delete D.fellBack;for(let F of["tools","prompts","resources"])this.invalidate(D.config.name,F)}await Promise.all(q)}}var v=()=>new Promise((q)=>setTimeout(q,0)),f,h=90000,d=async(q)=>(await import("./oauth-g5gme95c.js")).runtimeAuthProvider(q);var a=_(()=>{z();R();T();z();f=new Set(["npx","npx.cmd","uvx","uvx.exe","pipx","pipx.exe","bunx","bunx.exe"])});
3
- export{h as gd,A as hd,k as id,u as jd,l as kd,a as ld};
2
+ import{dh as b,eh as U,hh as M,ih as N,jh as C,kh as w,lh as m,mh as R}from"./main-rg0wn0xf.js";import{Am as V,Em as P,Fm as z,xm as S,zm as x}from"./main-7rn6bqje.js";import{vn as p,wn as _,xn as j}from"./main-qsevpgsv.js";function Y(){return L??=Promise.all([import("@modelcontextprotocol/sdk/client/index.js"),import("@modelcontextprotocol/sdk/client/stdio.js"),import("@modelcontextprotocol/sdk/client/streamableHttp.js"),import("@modelcontextprotocol/sdk/client/sse.js"),import("@modelcontextprotocol/sdk/client/auth.js"),import("@modelcontextprotocol/sdk/types.js")]).then(([q,D,F,H,I,J])=>{return K={Client:q.Client,StdioClientTransport:D.StdioClientTransport,getDefaultEnvironment:D.getDefaultEnvironment,StreamableHTTPClientTransport:F.StreamableHTTPClientTransport,StreamableHTTPError:F.StreamableHTTPError,SSEClientTransport:H.SSEClientTransport,SseError:H.SseError,UnauthorizedError:I.UnauthorizedError,ToolListChangedNotificationSchema:J.ToolListChangedNotificationSchema,PromptListChangedNotificationSchema:J.PromptListChangedNotificationSchema,ResourceListChangedNotificationSchema:J.ResourceListChangedNotificationSchema},K}),L}function E(q){let D=K;return D!==null&&q instanceof D.StreamableHTTPError&&(q.code===404||q.code===405)}function y(q){let D=K;if(D!==null&&(q instanceof D.StreamableHTTPError||q instanceof D.SseError))return q.code===401;return q instanceof Error&&/\(HTTP 401\)/.test(q.message)}function B(q,D){if(q instanceof N)return q.message;let F=K;if(F!==null&&q instanceof F.UnauthorizedError||y(q))return C(D)?"HTTP 401 \u2014 the configured Authorization header was rejected":M(D.name);let H=V(q);return F!==null&&q instanceof F.StreamableHTTPError&&typeof q.code==="number"&&q.code>0&&!H.includes(String(q.code))?`${H} (HTTP ${q.code})`:H}async function O(q,D,F){let H=await Y();if(D==="http"||D==="sse"){if(q.url===void 0)throw Error(`${D} server "${q.name}" has no url`);let I={...q.headers?{requestInit:{headers:q.headers}}:{},...F?{authProvider:F}:{}},J=new URL(q.url);return D==="http"?new H.StreamableHTTPClientTransport(J,I):new H.SSEClientTransport(J,I)}if(q.command===void 0)throw Error(`stdio server "${q.name}" has no command`);return new H.StdioClientTransport({command:q.command,args:q.args??[],env:{...H.getDefaultEnvironment(),...q.env??{}},stderr:"ignore"})}var L=null,K=null;var T=_(()=>{z();R()});var l={};p(l,{runnerTimeoutMessage:()=>k,mcpConfigPath:()=>S,loadMcpConfig:()=>P,isPackageRunner:()=>A,RUNNER_CONNECT_MS:()=>h,McpManager:()=>u});function A(q){if(q.transport!=="stdio"||q.command===void 0)return!1;let D=q.command.split(/[\\/]/).pop()??q.command;return f.has(D.toLowerCase())}function k(q,D){let F=`connect to MCP server "${q.name}" timed out after ${Math.round(D/1000)}s`;if(!A(q))return F;let H=(q.command??"the runner").split(/[\\/]/).pop();return`${F} \u2014 ${H} downloads the server's package on first use. Try again (the download is cached), or install it once so it starts without the network: rovecode mcp add ${q.name} --local --force`}class u{servers=new Map;toolCache=new Map;toolGen=new Map;listeners=new Set;ttl;connectTimeout;callTimeout;transportFactory;authProvider;constructor(q,D={}){this.ttl=D.toolTtlMs??60000,this.connectTimeout=D.connectTimeoutMs??1e4,this.callTimeout=D.callTimeoutMs??120000,this.transportFactory=D.transportFactory,this.authProvider=D.authProvider??d;for(let F of q)if(!this.servers.has(F.name))this.servers.set(F.name,{config:F,client:null,attempted:!1})}serverNames(){return[...this.servers.keys()]}connectedNames(){return[...this.servers.values()].filter((q)=>q.client!==null).map((q)=>q.config.name)}get ttlMs(){return this.ttl}get requestTimeoutMs(){return this.connectTimeout}clientOf(q){let D=this.servers.get(q);if(!D)throw Error(`unknown MCP server "${q}"`);if(!D.client)throw Error(`MCP server "${q}" is not connected${D.lastError?` (${D.lastError})`:""}`);return D.client}connection(q){let D=this.clientOf(q);return{client:D,caps:D.getServerCapabilities()??{}}}onListChanged(q){return this.listeners.add(q),()=>{this.listeners.delete(q)}}invalidate(q,D){if(D==="tools")this.toolCache.delete(q),this.toolGen.set(q,(this.toolGen.get(q)??0)+1);for(let F of this.listeners)try{F(q,D)}catch{}}async connect(){let q=[],D=[...this.servers.values()].filter((H)=>H.config.enabled!==!1&&H.client===null),F=[];for(let H of D){if(F.length>0&&H.connecting===void 0)await v();H.connecting??=this.open(H).finally(()=>{H.connecting=void 0}),F.push(H.connecting.catch((I)=>{q.push({name:H.config.name,error:B(I,H.config)})}))}return await Promise.all(F),{connected:this.connectedNames(),failed:q}}async open(q){let{config:D}=q;q.attempted=!0;try{let F=this.transportFactory?await this.transportFactory(D):void 0,H=F?"custom":D.transport,I=!1,J;try{J=await this.handshake(D,F??await O(D,D.transport,await this.authProvider(D)))}catch(X){if(F!==void 0||D.transport!=="http"||!E(X))throw X;J=await this.handshake(D,await O(D,"sse",await this.authProvider(D))),H="sse",I=!0}await this.armNotifications(D.name,J),q.client=J,q.wire=H,q.fellBack=I,delete q.lastError}catch(F){throw q.lastError=B(F,D),F}}async handshake(q,D){let F=new(await Y()).Client({name:"rovecode",version:"0.1.0"}),H=A(q)?Math.max(this.connectTimeout,h):this.connectTimeout;try{await w(F.connect(D,{timeout:H}),H+2000,k(q,H))}catch(I){throw await F.close().catch(()=>{}),I}return F}async armNotifications(q,D){let F=await Y();D.setNotificationHandler(F.ToolListChangedNotificationSchema,()=>this.invalidate(q,"tools")),D.setNotificationHandler(F.PromptListChangedNotificationSchema,()=>this.invalidate(q,"prompts")),D.setNotificationHandler(F.ResourceListChangedNotificationSchema,()=>this.invalidate(q,"resources"))}async fetchTools(q,D=!1,F){let H=this.clientOf(q),I=this.toolCache.get(q),J=Date.now();if(!D&&I&&J-I.at<this.ttl)return I.tools;let X=this.toolGen.get(q)??0,$=await m("tool",q,async(G)=>{let Q=U(F),Z;try{Z=await H.listTools(G===void 0?void 0:{cursor:G},{timeout:this.connectTimeout,signal:Q.signal})}finally{Q.dispose()}return{items:Z.tools.map((W)=>({name:W.name,description:typeof W.description==="string"?W.description:"",inputSchema:W.inputSchema})),nextCursor:Z.nextCursor}},F);if((this.toolGen.get(q)??0)===X)this.toolCache.set(q,{at:J,tools:$});return $}async listTools(q=!1,D){let F=[];for(let[H,I]of this.servers){if(I.client===null)continue;try{for(let J of await this.fetchTools(H,q,D))F.push({server:H,name:J.name,description:J.description})}catch{}}return F}async toolSchema(q,D,F){try{let H=(await this.fetchTools(q,!1,F)).find((I)=>I.name===D);if(!H)H=(await this.fetchTools(q,!0,F)).find((I)=>I.name===D);return H?.inputSchema}catch{return}}async callTool(q,D,F,H,I){let J=this.servers.get(q);if(!J){let Q=this.serverNames();return{ok:!1,output:`unknown MCP server "${q}". Known servers: ${Q.length>0?Q.join(", "):"(none configured)"}`}}let X=J.client;if(!X)return{ok:!1,output:`MCP server "${q}" is not connected${J.lastError?`: ${J.lastError}`:""}`};if(F!==void 0&&F!==null&&!x(F))return{ok:!1,output:`args for ${q}/${D} must be a JSON object (got ${Array.isArray(F)?"array":typeof F})`};let $;try{$=await this.fetchTools(q,!1,H)}catch(Q){return{ok:!1,output:`failed to list tools on "${q}": ${V(Q)}`}}if(!$.some((Q)=>Q.name===D)){try{$=await this.fetchTools(q,!0,H)}catch{}if(!$.some((Q)=>Q.name===D)){let Q=$.map((Z)=>Z.name).join(", ");return{ok:!1,output:`unknown tool "${D}" on server "${q}". Available: ${Q.length>0?Q:"(none)"}`}}}let G=U(H);try{let Q=await X.callTool({name:D,arguments:F??void 0},void 0,{signal:G.signal,timeout:this.callTimeout,resetTimeoutOnProgress:!0,onprogress:(W)=>I?.(typeof W.message==="string"&&W.message.length>0?W.message:`progress ${W.progress}${typeof W.total==="number"?`/${W.total}`:""}`)}),Z=b(Q.content,Q.structuredContent);if(Q.isError===!0)return{ok:!1,output:Z.length>0?Z:`tool "${D}" reported an error`};return{ok:!0,output:Z}}catch(Q){return{ok:!1,output:`mcp call ${q}/${D} failed: ${V(Q)}`}}finally{G.dispose()}}status(){return[...this.servers.values()].map((q)=>{let D={name:q.config.name,transport:q.config.transport,state:q.config.enabled===!1?"disabled":q.client?"connected":q.attempted&&!q.connecting?"failed":"pending"};if(q.wire!==void 0)D.wire=q.wire;if(q.fellBack)D.fellBack=!0;if(q.lastError!==void 0)D.error=q.lastError;let F=this.toolCache.get(q.config.name);if(F)D.tools=F.tools.length;return D})}async sync(q){let D=new Map(q.map((I)=>[I.name,I])),F=[],H=[];for(let[I,J]of[...this.servers]){if(D.has(I))continue;H.push(I),this.servers.delete(I);for(let X of["tools","prompts","resources"])this.invalidate(I,X);if(J.client)await J.client.close().catch(()=>{})}for(let[I,J]of D){if(this.servers.has(I))continue;this.servers.set(I,{config:J,client:null,attempted:!1}),F.push(I)}return{added:F,removed:H}}async close(){let q=[];for(let D of this.servers.values()){if(D.client)q.push(D.client.close().catch(()=>{})),D.client=null;D.attempted=!1,delete D.wire,delete D.fellBack;for(let F of["tools","prompts","resources"])this.invalidate(D.config.name,F)}await Promise.all(q)}}var v=()=>new Promise((q)=>setTimeout(q,0)),f,h=90000,d=async(q)=>(await import("./oauth-z8whcgfx.js")).runtimeAuthProvider(q);var a=_(()=>{z();R();T();z();f=new Set(["npx","npx.cmd","uvx","uvx.exe","pipx","pipx.exe","bunx","bunx.exe"])});
3
+ export{h as Md,A as Nd,k as Od,u as Pd,l as Qd,a as Rd};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ import{wn as e}from"./main-qsevpgsv.js";var t;var s=e(()=>{t={name:"rovecode",version:"0.4.0-beta.3",license:"AGPL-3.0-only",author:"9Code Labs",repository:{type:"git",url:"git+https://github.com/9Code-Labs/rovecode-community.git"},homepage:"https://github.com/9Code-Labs/rovecode-community#readme",description:"Rovecode: a coding agent for the terminal. Research-derived harness on Bun/TypeScript with evidence-based ports from open-source harnesses (sextant TUI, MCP, ACP, headless server, repo-map, shadow-git checkpoints, execpolicy, model routers). The npm tarball ships the minified bundle; this public repository is its AGPL source.",type:"module",module:"./dist/lib/index.js",exports:{".":"./dist/lib/index.js","./extensions":"./dist/lib/public-api.js","./plugins":"./dist/lib/plugins.js","./providers":"./dist/lib/providers.js","./sdk":"./dist/lib/sdk.js","./package.json":"./package.json"},bin:{rovecode:"bin/rovecode.js"},files:["bin","dist","README.md","CHANGELOG.md","LICENSE","THIRD_PARTY_NOTICES.md"],engines:{bun:">=1.3.14"},scripts:{build:"bun run scripts/build.ts","build:cli":`bun -e "require('node:fs').rmSync('dist/cli', { recursive: true, force: true })" && bun build --target=bun --splitting --sourcemap=external src/cli/main.ts --outdir dist/cli && bun -e "require('node:fs').copyFileSync('src/providers/models-index.json', 'dist/cli/models-index.json')" && bun run smoke:cli && bun run smoke:dist`,"build:npm":"bun run build:npm:cli && bun run build:npm:lib && bun run smoke:npm","build:npm:cli":`bun -e "require('node:fs').rmSync('dist/cli', { recursive: true, force: true })" && bun build --target=bun --minify --splitting --packages=external src/cli/main.ts --outdir dist/cli && bun -e "require('node:fs').copyFileSync('src/providers/models-index.json', 'dist/cli/models-index.json')"`,"build:npm:lib":`bun -e "require('node:fs').rmSync('dist/lib', { recursive: true, force: true })" && bun build --target=bun --minify --packages=external src/index.ts --outfile dist/lib/index.js && bun build --target=bun --minify --packages=external src/public-api.ts --outfile dist/lib/public-api.js && bun build --target=bun --minify --packages=external src/plugins/index.ts --outfile dist/lib/plugins.js && bun build --target=bun --minify --packages=external src/providers/stream.ts --outfile dist/lib/providers.js && bun build --target=bun --minify --packages=external src/sdk/index.ts --outfile dist/lib/sdk.js && bun -e "require('node:fs').copyFileSync('src/providers/models-index.json', 'dist/lib/models-index.json')"`,"smoke:npm":"bun dist/cli/main.js --version && bun dist/cli/main.js smoke-tui --sextant",prepack:"bun run build:npm","smoke:cli":"bun dist/cli/main.js --version","smoke:dist":"bun dist/cli/main.js smoke-tui --sextant",test:"bun test",gauntlet:"bun src/cli/main.ts gauntlet",typecheck:"tsc --noEmit",check:"node scripts/build-model-index.mjs --check && tsc --noEmit && bun test",smoke:"bun src/cli/main.ts smoke-tui --sextant","build:model-index":"node scripts/build-model-index.mjs","check:boundary":"node scripts/check-public-boundary.mjs","check:product-boundary":"node scripts/check-product-boundary.mjs","check:links":"node scripts/check-doc-links.mjs",ci:"bun run check:boundary && bun run check:product-boundary && bun run check:links && bun run typecheck && bun test && bun run build:cli","release:check":"bun run ci && bun run build:npm && npm pack --dry-run","release:stage":"bun run scripts/stage-release.ts","quality:offline":"bun run scripts/harness-quality.ts"},dependencies:{"@ast-grep/napi":"^0.45.3","@modelcontextprotocol/sdk":"^1.30.0","@zed-industries/agent-client-protocol":"^0.4.5",diff:"^9.0.0","get-east-asian-width":"1.6.0","gpt-tokenizer":"^4.0.0",marked:"18.0.11",tokenlens:"^1.3.1"},devDependencies:{"@opencode-ai/models":"^0.0.64","@types/bun":"latest","@xterm/headless":"6.0.0",typescript:"^5.9.3"},bugs:{url:"https://github.com/9Code-Labs/rovecode-community/issues"},publishConfig:{access:"public",provenance:!0,tag:"beta"}}});
3
+ export{s as Th,t as Uh};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{di as v,fi as u}from"./main-kba6zeyd.js";import{Dl as o,ul as p}from"./main-a3f51n0x.js";import{wn as F}from"./main-qsevpgsv.js";class h{opts;jobs=new Map;listeners=new Set;seq=0;unbind;constructor(z={}){this.opts=z;let Q=z.owner;if(Q){let V=()=>{this.killAll()};Q.addEventListener("abort",V,{once:!0}),this.unbind=()=>Q.removeEventListener("abort",V)}}subscribe(z){return this.listeners.add(z),()=>this.listeners.delete(z)}list(){return[...this.jobs.values()].map((z)=>({...z.info}))}status(z){let Q=this.jobs.get(z);return Q?{...Q.info}:void 0}get running(){let z=0;for(let Q of this.jobs.values())if(Q.info.status==="running")z++;return z}start(z,Q){if(this.running>=y)return{ok:!1,reason:`${y} background jobs already running (bash_list shows them; bash_kill frees a slot) \u2014 run this one in the foreground or wait`};let V=`b${++this.seq}`,Z=new AbortController,$={info:{id:V,command:z,status:"running",startedAt:Date.now(),dropped:0,drained:!1},buf:"",cursor:0,ac:Z,done:Promise.resolve()},q=new TextDecoder,J={onSpawn:(K)=>{$.info.pid=K},onChunk:(K,W)=>{this.append($,q.decode(W,{stream:!0}))}};return this.jobs.set(V,$),$.done=v().run(z,Q,Z.signal,J).then((K)=>{if($.info.status==="killed"){this.finish($);return}if($.info.status=K.code===0?"exited":"failed",$.info.exitCode=K.code,$.buf===""&&K.text!=="")this.append($,K.text);this.finish($)},(K)=>{$.info.status="failed",this.append($,`
2
+ import{ri as v,ti as u}from"./main-3gjqfh7a.js";import{Ul as p,bm as o}from"./main-0904f6ps.js";import{wn as F}from"./main-qsevpgsv.js";class h{opts;jobs=new Map;listeners=new Set;seq=0;unbind;constructor(z={}){this.opts=z;let Q=z.owner;if(Q){let V=()=>{this.killAll()};Q.addEventListener("abort",V,{once:!0}),this.unbind=()=>Q.removeEventListener("abort",V)}}subscribe(z){return this.listeners.add(z),()=>this.listeners.delete(z)}list(){return[...this.jobs.values()].map((z)=>({...z.info}))}status(z){let Q=this.jobs.get(z);return Q?{...Q.info}:void 0}get running(){let z=0;for(let Q of this.jobs.values())if(Q.info.status==="running")z++;return z}start(z,Q){if(this.running>=y)return{ok:!1,reason:`${y} background jobs already running (bash_list shows them; bash_kill frees a slot) \u2014 run this one in the foreground or wait`};let V=`b${++this.seq}`,Z=new AbortController,$={info:{id:V,command:z,status:"running",startedAt:Date.now(),dropped:0,drained:!1},buf:"",cursor:0,ac:Z,done:Promise.resolve()},q=new TextDecoder,J={onSpawn:(K)=>{$.info.pid=K},onChunk:(K,W)=>{this.append($,q.decode(W,{stream:!0}))}};return this.jobs.set(V,$),$.done=v().run(z,Q,Z.signal,J).then((K)=>{if($.info.status==="killed"){this.finish($);return}if($.info.status=K.code===0?"exited":"failed",$.info.exitCode=K.code,$.buf===""&&K.text!=="")this.append($,K.text);this.finish($)},(K)=>{$.info.status="failed",this.append($,`
3
3
  [job runner threw: ${K instanceof Error?K.message:String(K)}]`),this.finish($)}),{ok:!0,info:{...$.info}}}append(z,Q){if(Q==="")return;if(z.buf+=Q,z.buf.length>g){let V=z.buf.length-g;z.buf=z.buf.slice(V),z.info.dropped+=V,z.cursor=Math.max(0,z.cursor-V)}}finish(z){z.info.finishedAt=Date.now();let Q={...z.info};for(let Z of this.listeners)Z(Q);let V=z.info.status==="killed"?"killed":`exit=${z.info.exitCode}`;this.opts.notify?.push(`background job ${z.info.id} finished (${V}): ${m(z.info.command,60)} \u2014 bash_output ${z.info.id} reads what it printed`),this.reap()}read(z){let Q=this.jobs.get(z);if(!Q)return{ok:!1,reason:`no background job "${z}" in this session (bash_list shows them; a finished job is dropped after its output has been read)`};let V=Q.info.dropped,$=Q.buf.slice(Q.cursor).slice(0,x);Q.cursor+=$.length;let q=Q.cursor<Q.buf.length;if(!q&&Q.info.status!=="running")Q.info.drained=!0,this.reap();return{ok:!0,info:{...Q.info},text:$,more:q,lost:V}}kill(z){let Q=this.jobs.get(z);if(!Q)return{ok:!1,reason:`no background job "${z}" in this session`};if(Q.info.status!=="running")return{ok:!0,info:{...Q.info}};return Q.info.status="killed",Q.ac.abort(),{ok:!0,info:{...Q.info}}}killAll(){let z=0;for(let Q of this.jobs.values())if(Q.info.status==="running")this.kill(Q.info.id),z++;return z}async drain(){await Promise.allSettled([...this.jobs.values()].map((z)=>z.done))}dispose(){this.killAll(),this.unbind?.(),this.listeners.clear()}reap(){let z=[...this.jobs.values()].filter((Q)=>Q.info.status!=="running"&&Q.info.drained);if(z.length<=M)return;z.sort((Q,V)=>(Q.info.finishedAt??0)-(V.info.finishedAt??0));for(let Q of z.slice(0,z.length-M))this.jobs.delete(Q.info.id)}}function $z(z){k=z}function A(){return k!==null}function Wz(){return k}function _(z,Q){if(!k)return{ok:!1,reason:"background jobs are not available on this surface \u2014 run the command in the foreground (drop run_in_background)"};return k.start(z,Q)}var y=4,g=200000,x=1e4,M=8,m=(z,Q)=>z.length>Q?z.slice(0,Q-1)+"\u2026":z,k=null;var S=F(()=>{u()});function f(z){if(z===void 0||z===null)return;let Q=typeof z==="number"?z:Number(z);if(!Number.isFinite(Q)||Q<=0)return Error(`timeout_ms must be a positive number of milliseconds (got ${JSON.stringify(z)})`);if(Q>L)return Error(`timeout_ms ${Q} is longer than the ${L}ms cap \u2014 use run_in_background for work that takes longer`);return Math.floor(Q)}function E(z){let Q=d.find((V)=>V.test(z));return Q?`command refused by safety blocklist (matched ${Q.source}): this tool is not a sandbox; rephrase without destructive system commands`:null}var L=600000,l,d;var b=F(()=>{u();S();l={schema:{name:"bash",description:"Run a shell command in the workspace (cwd locked to the session cwd). One automatic retry on non-zero exit. "+"Destructive system commands are refused by a best-effort blocklist \u2014 this is NOT a sandbox. Output truncated to 10k chars. "+`\`timeout_ms\` gives up after that long and RETURNS what the command printed (max ${L}ms); the process tree is killed. `+"`run_in_background: true` returns a job id at once instead of waiting \u2014 for a dev server, a long build, a slow test run. "+"Read it later with bash_output (only NEW output per read), see them with bash_list, stop one with bash_kill; a finished job also posts one note here by itself.",args:{type:"object",properties:{command:{type:"string"},timeout_ms:{type:"number",description:`give up after this many ms and return the partial output (1..${L}); a timeout is never retried`},run_in_background:{type:"boolean",description:"start it as a background job and return its id immediately (bash_output reads it)"}},required:["command"]}},kind:"execute",sequential:!0,async execute(z,Q){let V=z,Z=String(V.command),$=E(Z);if($)return{ok:!1,output:$};if(V.run_in_background===!0){if(!A())return{ok:!1,output:"background jobs are not available on this surface \u2014 drop run_in_background to run it in the foreground"};let W=_(Z,Q.cwd);if(!W.ok)return{ok:!1,output:W.reason};return{ok:!0,output:`started background job ${W.info.id}: ${Z}
4
4
  It runs while you continue \u2014 do NOT poll in a loop. \`bash_output ${W.info.id}\` reads what is new; a note lands here when it finishes.`,data:W.info}}let q=f(V.timeout_ms);if(q instanceof Error)return{ok:!1,output:q.message};let J=async()=>{if(q===void 0){let G=await v().run(Z,Q.cwd,Q.signal);return{code:G.code,text:G.text,timedOut:!1}}let W=new AbortController,Y=()=>W.abort();Q.signal.addEventListener("abort",Y,{once:!0});let U,B=!1;try{U=setTimeout(()=>{B=!0,W.abort()},q);let G=await v().run(Z,Q.cwd,W.signal);return{code:G.code,text:G.text,timedOut:B}}finally{clearTimeout(U),Q.signal.removeEventListener("abort",Y)}},K=await J();if(K.code!==0&&!K.timedOut&&!Q.signal.aborted)K=await J();if(K.timedOut)return{ok:!1,output:`timed out after ${q}ms (process tree killed; what it printed follows)
5
5
  ${K.text}`};return{ok:K.code===0,output:`exit=${K.code}
@@ -15,4 +15,4 @@ ${V}`}function r(z,Q,V){let Z=N(z),$=Q.find((W)=>W.tag!==Z);if($)return{ok:!1,fa
15
15
  \u2026 and ${Y.length-H} more`:"");return Promise.resolve({ok:!1,output:`Edit applied but lint failed \u2014 file reverted to original. New lint errors:
16
16
  ${U}
17
17
  Fix these and retry the edit.`})}}return Promise.resolve({ok:!0,output:`applied ${V.edits.length} edit(s); new TAG ${q.newTag}`})}},Oz={schema:{name:"write",description:"Create or overwrite a file with content.",args:{type:"object",properties:{path:{type:"string"},content:{type:"string"}},required:["path","content"]}},kind:"write",sequential:!0,execute(z,Q){let V=z,Z=T(Q.cwd,V.path),$=n(Z);if(!R($))return Promise.resolve({ok:!1,output:P(`Write rejected: directory ${$} does not exist \u2014 create it first (bash: mkdir -p ${JSON.stringify($)}) or write into an existing directory.`,I)});return j(Z,V.content),Promise.resolve({ok:!0,output:`wrote ${Z} (${V.content.length} bytes, TAG ${N(V.content)})`})}}});
18
- export{h as Vf,$z as Wf,Wz as Xf,S as Yf,l as Zf,E as _f,X as $f,N as ag,s as bg,c as cg,r as dg,t as eg,I as fg,e as gg,vz as hg,Cz as ig,Lz as jg,Oz as kg,Vz as lg};
18
+ export{h as Lg,$z as Mg,Wz as Ng,S as Og,l as Pg,E as Qg,X as Rg,N as Sg,s as Tg,c as Ug,r as Vg,t as Wg,I as Xg,e as Yg,vz as Zg,Cz as _g,Lz as $g,Oz as ah,Vz as bh};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{od as v,qd as I,rd as E,td as j}from"./main-evgz4mp5.js";import{cl as O,dl as q,fl as A,jl as U,ll as C,ml as g}from"./main-6dtqmbt6.js";import{wn as H}from"./main-qsevpgsv.js";import{basename as R}from"path";function _(G){return G.trim().length>0&&G!=="."&&G!==".."&&!/[\\/]/.test(G)&&R(G)===G}function B(G){if(_(G))return;if(G.trim().length===0)return"session id is empty";return`session id ${JSON.stringify(G)} is not a plain directory name (no / or \\, not . or ..)`}var D=()=>{};import{randomUUID as k}from"crypto";import{copyFileSync as b,cpSync as x,existsSync as z,mkdirSync as T,readdirSync as f,rmSync as p,statSync as w}from"fs";import{join as Z}from"path";function JG(G){return Z(G,".rovecode","sessions")}function S(G,J){let L=G.find((V)=>V.id===J);return L?[L]:G.filter((V)=>V.id.startsWith(J))}function u(G,J){let L=J.slice(0,4).map((V)=>V.id.slice(0,8)).join(", ");return`"${G}" matches ${J.length} sessions: ${L}${J.length>4?", \u2026":""} \u2014 be more specific`}function LG(G,J){let L=J.trim();if(L==="")return{ok:!1,error:"a session id or prefix is required"};let V=B(L);if(V!==void 0)return{ok:!1,error:V};let W=S(U(G,{includeHollow:!0}),L);if(W.length===1)return{ok:!0,id:W[0].id,summary:W[0]};if(W.length>1)return{ok:!1,error:u(L,W)};return{ok:!1,error:`no session matching "${L}"`}}function y(G){let J=/^(.+) \(fork #(\d+)\)$/.exec(G);return J?`${J[1]} (fork #${Number(J[2])+1})`:`${G} (fork #1)`}function QG(G,J,L){new C(G,J).patchMeta({title:L})}function M(G){let J=0,L;try{L=f(G)}catch{return 0}for(let V of L){let W=Z(G,V);try{let $=w(W);J+=$.isDirectory()?M(W):$.size}catch{}}return J}function VG(G,J,L={}){let V=Z(G,J.id),W=Z(V,O),$=L.maxBytes??h,Y=z(W)?M(W):0;if(Y>$)throw Error(`session ${J.id.slice(0,8)} carries ${N(Y)} of attachments, over the fork limit of ${N($)} \u2014 nothing copied; \`rovecode export ${J.id.slice(0,8)}\` writes the transcript without them`);let P=k(),X=Z(G,P);T(X,{recursive:!0});for(let F of["entries.jsonl","meta.json"])if(z(Z(V,F)))b(Z(V,F),Z(X,F));if(z(W))x(W,Z(X,O),{recursive:!0});let Q=J.title??J.preview,K=y(Q===""?"(empty session)":Q);return new C(G,P).patchMeta({createdAt:Date.now(),title:K,forkedFrom:J.id}),{id:P,from:J.id,title:K}}function WG(G,J,L){let V=[];for(let W of[Z(J,L),v(G,L)]){if(!z(W))continue;p(W,{recursive:!0,force:!0}),V.push(W)}return{removed:V}}function ZG(G,J,L=10){let V=J.trim();if(V==="")return[];let W=U(G),$=new Map;for(let Q of W)if(Q.title!==void 0)$.set(Q.id,Q.title);let Y=V.toLowerCase(),P=[];for(let Q of W)if(Q.title!==void 0&&Q.title.toLowerCase().includes(Y))P.push({sessionId:Q.id,title:Q.title,entryId:"",timestamp:Q.updatedAt,preview:Q.preview});for(let Q of new E(G).search(V,L)){let K=$.get(Q.sessionId);P.push({sessionId:Q.sessionId,...K!==void 0?{title:K}:{},entryId:Q.entryId,timestamp:Q.timestamp,preview:Q.preview})}let X=new Set;return P.filter((Q)=>{let K=`${Q.sessionId.length}:${Q.sessionId}:${Q.entryId}`;if(X.has(K))return!1;return X.add(K),!0}).slice(0,L)}var h=268435456,N=(G)=>`${(G/1048576).toFixed(1)} MB`;var l=H(()=>{I();j();D();q();g();A()});
3
- export{B as jb,D as kb,JG as lb,S as mb,u as nb,LG as ob,QG as pb,VG as qb,WG as rb,ZG as sb,l as tb};
2
+ import{$d as I,Zd as v,ae as E,ce as j}from"./main-m1kk6fp5.js";import{Cl as O,Dl as q,Fl as A,Jl as U,Ll as C,Ml as g}from"./main-4wndhjdc.js";import{wn as H}from"./main-qsevpgsv.js";import{basename as R}from"path";function _(G){return G.trim().length>0&&G!=="."&&G!==".."&&!/[\\/]/.test(G)&&R(G)===G}function B(G){if(_(G))return;if(G.trim().length===0)return"session id is empty";return`session id ${JSON.stringify(G)} is not a plain directory name (no / or \\, not . or ..)`}var D=()=>{};import{randomUUID as k}from"crypto";import{copyFileSync as b,cpSync as x,existsSync as z,mkdirSync as T,readdirSync as f,rmSync as p,statSync as w}from"fs";import{join as Z}from"path";function JG(G){return Z(G,".rovecode","sessions")}function S(G,J){let L=G.find((V)=>V.id===J);return L?[L]:G.filter((V)=>V.id.startsWith(J))}function u(G,J){let L=J.slice(0,4).map((V)=>V.id.slice(0,8)).join(", ");return`"${G}" matches ${J.length} sessions: ${L}${J.length>4?", \u2026":""} \u2014 be more specific`}function LG(G,J){let L=J.trim();if(L==="")return{ok:!1,error:"a session id or prefix is required"};let V=B(L);if(V!==void 0)return{ok:!1,error:V};let W=S(U(G,{includeHollow:!0}),L);if(W.length===1)return{ok:!0,id:W[0].id,summary:W[0]};if(W.length>1)return{ok:!1,error:u(L,W)};return{ok:!1,error:`no session matching "${L}"`}}function y(G){let J=/^(.+) \(fork #(\d+)\)$/.exec(G);return J?`${J[1]} (fork #${Number(J[2])+1})`:`${G} (fork #1)`}function QG(G,J,L){new C(G,J).patchMeta({title:L})}function M(G){let J=0,L;try{L=f(G)}catch{return 0}for(let V of L){let W=Z(G,V);try{let $=w(W);J+=$.isDirectory()?M(W):$.size}catch{}}return J}function VG(G,J,L={}){let V=Z(G,J.id),W=Z(V,O),$=L.maxBytes??h,Y=z(W)?M(W):0;if(Y>$)throw Error(`session ${J.id.slice(0,8)} carries ${N(Y)} of attachments, over the fork limit of ${N($)} \u2014 nothing copied; \`rovecode export ${J.id.slice(0,8)}\` writes the transcript without them`);let P=k(),X=Z(G,P);T(X,{recursive:!0});for(let F of["entries.jsonl","meta.json"])if(z(Z(V,F)))b(Z(V,F),Z(X,F));if(z(W))x(W,Z(X,O),{recursive:!0});let Q=J.title??J.preview,K=y(Q===""?"(empty session)":Q);return new C(G,P).patchMeta({createdAt:Date.now(),title:K,forkedFrom:J.id}),{id:P,from:J.id,title:K}}function WG(G,J,L){let V=[];for(let W of[Z(J,L),v(G,L)]){if(!z(W))continue;p(W,{recursive:!0,force:!0}),V.push(W)}return{removed:V}}function ZG(G,J,L=10){let V=J.trim();if(V==="")return[];let W=U(G),$=new Map;for(let Q of W)if(Q.title!==void 0)$.set(Q.id,Q.title);let Y=V.toLowerCase(),P=[];for(let Q of W)if(Q.title!==void 0&&Q.title.toLowerCase().includes(Y))P.push({sessionId:Q.id,title:Q.title,entryId:"",timestamp:Q.updatedAt,preview:Q.preview});for(let Q of new E(G).search(V,L)){let K=$.get(Q.sessionId);P.push({sessionId:Q.sessionId,...K!==void 0?{title:K}:{},entryId:Q.entryId,timestamp:Q.timestamp,preview:Q.preview})}let X=new Set;return P.filter((Q)=>{let K=`${Q.sessionId.length}:${Q.sessionId}:${Q.entryId}`;if(X.has(K))return!1;return X.add(K),!0}).slice(0,L)}var h=268435456,N=(G)=>`${(G/1048576).toFixed(1)} MB`;var l=H(()=>{I();j();D();q();g();A()});
3
+ export{B as cc,D as dc,JG as ec,S as fc,u as gc,LG as hc,QG as ic,VG as jc,WG as kc,ZG as lc,l as mc};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{ij as x,nj as B}from"./main-1ztz6fkj.js";var C=(j)=>j??"auto",F="nothing \u2014 auto: the endpoint's own default stands";function H(j){switch(j){case"low":return 2048;case"medium":return 8192;case"high":return 24576;default:return null}}function U(j,z){if(j===void 0||j==="auto")return{};if(j==="off")return{thinking:{type:"disabled"}};if(z==="effort")return{output_config:{effort:j}};let J=H(j);return J===null?{}:{thinking:{type:"enabled",budget_tokens:J}}}function q(j,z){let J=U(j,z),W=j==="auto"?F:j==="off"?'thinking: { type: "disabled" } \u2014 an explicit off; Claude 5 reasons by default':`${JSON.stringify(J).slice(1,-1).replace(/"(\w+)":/g,"$1: ").replace(/,/g,", ")} (the ${z} shape \u2014 learned from the endpoint, kept per model)`;return{dialect:`anthropic/${z}`,fields:J,says:W}}var R=(j)=>JSON.stringify(j),K=(j)=>({fields:{},says:`nothing \u2014 ${j}`}),Q=(j,z="")=>({fields:{reasoning_effort:j},says:`reasoning_effort: ${R(j)}${z?` (${z})`:""}`}),$=(j,z)=>({fields:{thinking:{type:j?"enabled":"disabled"}},says:`thinking: { type: ${R(j?"enabled":"disabled")} } (${z} has an on/off switch, no levels)`}),V=(j)=>(z)=>j.test(z.model),M=[{id:"catalog: no reasoning mode",matches:(j)=>j.reasoning===!1,plan:(j,z)=>K(`the catalog lists ${z.model} without a reasoning mode, so no dial is sent`)},{id:"openrouter",matches:(j)=>j.provider==="openrouter",plan:(j)=>j==="off"?{fields:{reasoning:{enabled:!1}},says:"reasoning: { enabled: false } (OpenRouter's unified field; a model that always reasons ignores it)"}:{fields:{reasoning:{effort:j}},says:`reasoning: { effort: ${R(j)} } (OpenRouter's unified field, translated per upstream)`}},{id:"glm-5.3",matches:V(x),plan:(j,z)=>{if(j==="off")return K("GLM-5.3 cannot switch thinking off (Z.ai: thinking.type accepts enabled only); the endpoint default is max");let J=B(z);if(J===null)return Q(j,"ROVECODE_PROFILE=off: the plain word, not GLM's low | high | max");return Q(J.reasoningEffort(j),"GLM's words are low | high | max; medium rounds up")}},{id:"glm-5.x",matches:V(/(^|[/:])glm-5(\.\d+)?(?=[-:]|$)/i),plan:(j)=>j==="off"?{fields:{thinking:{type:"disabled"}},says:'thinking: { type: "disabled" } (best effort \u2014 GLM gen-5 endpoints may ignore it; measured ignored on kaesra dash)'}:Q(j==="low"?"low":j==="medium"?"high":"max","GLM gen-5 words are low | high | max; medium rounds up")},{id:"glm",matches:V(/(^|[/:])glm-(4\.[5-9]|4\.\d{2,})(?=[-:]|$)/i),plan:(j)=>$(j!=="off","GLM")},{id:"deepseek",matches:V(/deepseek/i),plan:(j,z)=>/reasoner|r1/i.test(z.model)?K(`${z.model} always thinks \u2014 no dial`):$(j!=="off","DeepSeek")},{id:"qwen",matches:V(/(^|[/:])(qwen|qwq)/i),plan:(j,z)=>{if(z.provider==="groq")return j==="off"?Q("none","Groq's Qwen words are none | default"):Q("default","Groq's Qwen words are none | default");if(j==="off")return{fields:{enable_thinking:!1},says:"enable_thinking: false (DashScope / most Qwen hosts; a vLLM host wants chat_template_kwargs instead and ignores this)"};let J=H(j);return{fields:{enable_thinking:!0,thinking_budget:J},says:`enable_thinking: true, thinking_budget: ${J} (DashScope's fields; a host without them ignores both)`}}},{id:"kimi",matches:V(/kimi|moonshot/i),plan:(j,z)=>/thinking/i.test(z.model)?K(`${z.model} always thinks \u2014 no dial`):/k2[.-]5|k2\.5/i.test(z.model)?$(j!=="off","Moonshot K2.5"):K(`${z.model} has no thinking mode (the -thinking variant does)`)},{id:"gemini",matches:V(/gemini/i),plan:(j,z)=>j!=="off"?Q(j,"Google's OpenAI-compatible layer maps low | medium | high to a thinking budget"):/flash/i.test(z.model)?{fields:{extra_body:{google:{thinking_config:{thinking_budget:0}}}},says:"extra_body.google.thinking_config.thinking_budget: 0 (Flash can switch thinking off; Pro cannot)"}:K(`${z.model} cannot switch thinking off (Gemini Pro keeps a minimum budget)`)},{id:"grok",matches:V(/grok/i),plan:(j,z)=>/non-reasoning/i.test(z.model)?K(`${z.model} has no reasoning mode`):/grok-3-mini/i.test(z.model)?j==="off"?K("grok-3-mini cannot switch reasoning off"):Q(j==="low"?"low":"high","xAI's words for grok-3-mini are low | high; medium rounds up"):j==="off"?Q("none","xAI's explicit off (grok-4.3 and later; retired grok-4 slugs are served by grok-4.3)"):Q(j,"xAI's words are none | low | medium | high")},{id:"gpt-oss",matches:V(/gpt-oss/i),plan:(j)=>j==="off"?K("gpt-oss cannot switch reasoning off (low is the floor)"):Q(j)},{id:"openai o-series",matches:V(/(^|[/:])o[134](-|$)/i),plan:(j,z)=>j==="off"?K(`${z.model} cannot switch reasoning off`):Q(j)},{id:"openai gpt-5",matches:V(/(^|[/:])gpt-5/i),plan:(j,z)=>j!=="off"?Q(j):/gpt-5\.[1-9]/i.test(z.model)?Q("none","gpt-5.1 and later: the explicit off"):Q("minimal","gpt-5 has no off; minimal is its floor")},{id:"openai gpt-4 class",matches:V(/(^|[/:])(gpt-4|gpt-3\.5|chatgpt)/i),plan:(j,z)=>K(`${z.model} has no reasoning mode and OpenAI rejects reasoning_effort for it`)},{id:"mistral",matches:V(/magistral|mistral|codestral|ministral|pixtral/i),plan:(j,z)=>/magistral/i.test(z.model)?K("Magistral always reasons \u2014 no dial"):K(`${z.model} has no reasoning mode`)},{id:"minimax",matches:V(/minimax/i),plan:(j,z)=>K(`${z.model} always reasons \u2014 no dial`)},{id:"openai-compatible default",matches:()=>!0,plan:(j)=>j==="off"?K("off sends nothing here: no common explicit disable on OpenAI-compatible endpoints; a model without a reasoning mode ignores the word anyway"):Q(j,"the OpenAI word; a model without a reasoning mode ignores it")}];function y(j){return M.find((z)=>z.matches(j)).id}function S(j,z,J={}){let W=C(j.effort);if(z==="anthropic")return q(W,J.shape??"effort");let X=M.find((Y)=>Y.matches(j));if(W==="auto")return{dialect:X.id,fields:{},says:F};return{dialect:X.id,...X.plan(W,j)}}function D(j,z,J={}){return["auto","off","low","medium","high"].map((W)=>({level:W,says:S({...j,effort:W},z,J).says}))}function A(j,z,J={}){return`${j.provider}/${j.model} receives: ${S(j,z,J).says}`}function E(j,z,J={}){let W=C(j.effort),X=z==="anthropic"?`anthropic (${J.shape??"effort"} shape)`:y(j),Y=[`${j.provider}/${j.model}${J.source?` (${J.source})`:""}`,` protocol ${z}`,` dialect ${X}${j.reasoning===!1?" \u2014 the catalog lists no reasoning mode":j.reasoning===!0?" \u2014 the catalog lists a reasoning mode":""}`,...J.catalog?[` prices ${J.catalog}`]:[],` effort ${W} (ROVECODE_EFFORT / --effort / /effort)`];for(let Z of D(j,z,J))Y.push(` ${Z.level===W?"*":" "} ${Z.level.padEnd(7)} ${Z.says}`);return Y}
3
- export{H as Ki,U as Li,y as Mi,S as Ni,D as Oi,A as Pi,E as Qi};
2
+ import{Bj as B,wj as x}from"./main-90ds1z4e.js";var C=(j)=>j??"auto",F="nothing \u2014 auto: the endpoint's own default stands";function H(j){switch(j){case"low":return 2048;case"medium":return 8192;case"high":return 24576;default:return null}}function U(j,z){if(j===void 0||j==="auto")return{};if(j==="off")return{thinking:{type:"disabled"}};if(z==="effort")return{output_config:{effort:j}};let J=H(j);return J===null?{}:{thinking:{type:"enabled",budget_tokens:J}}}function q(j,z){let J=U(j,z),W=j==="auto"?F:j==="off"?'thinking: { type: "disabled" } \u2014 an explicit off; Claude 5 reasons by default':`${JSON.stringify(J).slice(1,-1).replace(/"(\w+)":/g,"$1: ").replace(/,/g,", ")} (the ${z} shape \u2014 learned from the endpoint, kept per model)`;return{dialect:`anthropic/${z}`,fields:J,says:W}}var R=(j)=>JSON.stringify(j),K=(j)=>({fields:{},says:`nothing \u2014 ${j}`}),Q=(j,z="")=>({fields:{reasoning_effort:j},says:`reasoning_effort: ${R(j)}${z?` (${z})`:""}`}),$=(j,z)=>({fields:{thinking:{type:j?"enabled":"disabled"}},says:`thinking: { type: ${R(j?"enabled":"disabled")} } (${z} has an on/off switch, no levels)`}),V=(j)=>(z)=>j.test(z.model),M=[{id:"catalog: no reasoning mode",matches:(j)=>j.reasoning===!1,plan:(j,z)=>K(`the catalog lists ${z.model} without a reasoning mode, so no dial is sent`)},{id:"openrouter",matches:(j)=>j.provider==="openrouter",plan:(j)=>j==="off"?{fields:{reasoning:{enabled:!1}},says:"reasoning: { enabled: false } (OpenRouter's unified field; a model that always reasons ignores it)"}:{fields:{reasoning:{effort:j}},says:`reasoning: { effort: ${R(j)} } (OpenRouter's unified field, translated per upstream)`}},{id:"glm-5.3",matches:V(x),plan:(j,z)=>{if(j==="off")return K("GLM-5.3 cannot switch thinking off (Z.ai: thinking.type accepts enabled only); the endpoint default is max");let J=B(z);if(J===null)return Q(j,"ROVECODE_PROFILE=off: the plain word, not GLM's low | high | max");return Q(J.reasoningEffort(j),"GLM's words are low | high | max; medium rounds up")}},{id:"glm-5.x",matches:V(/(^|[/:])glm-5(\.\d+)?(?=[-:]|$)/i),plan:(j)=>j==="off"?{fields:{thinking:{type:"disabled"}},says:'thinking: { type: "disabled" } (best effort \u2014 GLM gen-5 endpoints may ignore it; measured ignored on kaesra dash)'}:Q(j==="low"?"low":j==="medium"?"high":"max","GLM gen-5 words are low | high | max; medium rounds up")},{id:"glm",matches:V(/(^|[/:])glm-(4\.[5-9]|4\.\d{2,})(?=[-:]|$)/i),plan:(j)=>$(j!=="off","GLM")},{id:"deepseek",matches:V(/deepseek/i),plan:(j,z)=>/reasoner|r1/i.test(z.model)?K(`${z.model} always thinks \u2014 no dial`):$(j!=="off","DeepSeek")},{id:"qwen",matches:V(/(^|[/:])(qwen|qwq)/i),plan:(j,z)=>{if(z.provider==="groq")return j==="off"?Q("none","Groq's Qwen words are none | default"):Q("default","Groq's Qwen words are none | default");if(j==="off")return{fields:{enable_thinking:!1},says:"enable_thinking: false (DashScope / most Qwen hosts; a vLLM host wants chat_template_kwargs instead and ignores this)"};let J=H(j);return{fields:{enable_thinking:!0,thinking_budget:J},says:`enable_thinking: true, thinking_budget: ${J} (DashScope's fields; a host without them ignores both)`}}},{id:"kimi",matches:V(/kimi|moonshot/i),plan:(j,z)=>/thinking/i.test(z.model)?K(`${z.model} always thinks \u2014 no dial`):/k2[.-]5|k2\.5/i.test(z.model)?$(j!=="off","Moonshot K2.5"):K(`${z.model} has no thinking mode (the -thinking variant does)`)},{id:"gemini",matches:V(/gemini/i),plan:(j,z)=>j!=="off"?Q(j,"Google's OpenAI-compatible layer maps low | medium | high to a thinking budget"):/flash/i.test(z.model)?{fields:{extra_body:{google:{thinking_config:{thinking_budget:0}}}},says:"extra_body.google.thinking_config.thinking_budget: 0 (Flash can switch thinking off; Pro cannot)"}:K(`${z.model} cannot switch thinking off (Gemini Pro keeps a minimum budget)`)},{id:"grok",matches:V(/grok/i),plan:(j,z)=>/non-reasoning/i.test(z.model)?K(`${z.model} has no reasoning mode`):/grok-3-mini/i.test(z.model)?j==="off"?K("grok-3-mini cannot switch reasoning off"):Q(j==="low"?"low":"high","xAI's words for grok-3-mini are low | high; medium rounds up"):j==="off"?Q("none","xAI's explicit off (grok-4.3 and later; retired grok-4 slugs are served by grok-4.3)"):Q(j,"xAI's words are none | low | medium | high")},{id:"gpt-oss",matches:V(/gpt-oss/i),plan:(j)=>j==="off"?K("gpt-oss cannot switch reasoning off (low is the floor)"):Q(j)},{id:"openai o-series",matches:V(/(^|[/:])o[134](-|$)/i),plan:(j,z)=>j==="off"?K(`${z.model} cannot switch reasoning off`):Q(j)},{id:"openai gpt-5",matches:V(/(^|[/:])gpt-5/i),plan:(j,z)=>j!=="off"?Q(j):/gpt-5\.[1-9]/i.test(z.model)?Q("none","gpt-5.1 and later: the explicit off"):Q("minimal","gpt-5 has no off; minimal is its floor")},{id:"openai gpt-4 class",matches:V(/(^|[/:])(gpt-4|gpt-3\.5|chatgpt)/i),plan:(j,z)=>K(`${z.model} has no reasoning mode and OpenAI rejects reasoning_effort for it`)},{id:"mistral",matches:V(/magistral|mistral|codestral|ministral|pixtral/i),plan:(j,z)=>/magistral/i.test(z.model)?K("Magistral always reasons \u2014 no dial"):K(`${z.model} has no reasoning mode`)},{id:"minimax",matches:V(/minimax/i),plan:(j,z)=>K(`${z.model} always reasons \u2014 no dial`)},{id:"openai-compatible default",matches:()=>!0,plan:(j)=>j==="off"?K("off sends nothing here: no common explicit disable on OpenAI-compatible endpoints; a model without a reasoning mode ignores the word anyway"):Q(j,"the OpenAI word; a model without a reasoning mode ignores it")}];function y(j){return M.find((z)=>z.matches(j)).id}function S(j,z,J={}){let W=C(j.effort);if(z==="anthropic")return q(W,J.shape??"effort");let X=M.find((Y)=>Y.matches(j));if(W==="auto")return{dialect:X.id,fields:{},says:F};return{dialect:X.id,...X.plan(W,j)}}function D(j,z,J={}){return["auto","off","low","medium","high"].map((W)=>({level:W,says:S({...j,effort:W},z,J).says}))}function A(j,z,J={}){return`${j.provider}/${j.model} receives: ${S(j,z,J).says}`}function E(j,z,J={}){let W=C(j.effort),X=z==="anthropic"?`anthropic (${J.shape??"effort"} shape)`:y(j),Y=[`${j.provider}/${j.model}${J.source?` (${J.source})`:""}`,` protocol ${z}`,` dialect ${X}${j.reasoning===!1?" \u2014 the catalog lists no reasoning mode":j.reasoning===!0?" \u2014 the catalog lists a reasoning mode":""}`,...J.catalog?[` prices ${J.catalog}`]:[],` effort ${W} (ROVECODE_EFFORT / --effort / /effort)`];for(let Z of D(j,z,J))Y.push(` ${Z.level===W?"*":" "} ${Z.level.padEnd(7)} ${Z.says}`);return Y}
3
+ export{H as mj,U as nj,y as oj,S as pj,D as qj,A as rj,E as sj};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Wa as g,ib as Rz}from"./main-rsy72qmw.js";import{jh as U,kh as jz,lh as az}from"./main-4y0tnfpa.js";import{Bh as $z,Dh as nz,zh as Zz}from"./main-ntqef02r.js";import{Xh as d,fi as Tz}from"./main-kba6zeyd.js";import{Cj as v,Ej as YJ}from"./main-v8y60bb2.js";import{Ok as M,Pk as Vz,Qk as n,rk as t,sk as xz,tk as e,vk as zz,wk as Jz,xk as dz}from"./main-qj2djy17.js";import{Rk as I,Tk as Hz,Uk as Fz,Wk as w,Yk as _,_k as Yz,bl as FJ,cl as r,dl as pz}from"./main-6dtqmbt6.js";import{wn as R}from"./main-qsevpgsv.js";function Pz(z){if(/[\r\n]/.test(z))return null;let J=z.trim();if(!Gz.test(J))return null;return J.slice(1).trim()}function h(z,J,V){let Z=z.add(J,V);if(!Z.ok)return{ok:!1,tone:"warn",text:`memory: not saved to ${A[J]} \u2014 ${Z.reason??"edit failed"}`};return{ok:!0,tone:"info",text:`memory: noted in ${A[J]} (${Z.current}/${Z.limit} chars, ${z.path(J)}) \u2014 in the prompt from the next run`}}function PJ(z,J){let V=Pz(J);if(V===null)return!1;z.renderer.addUser(J.trim());let Z=h(z.blocks(),"memory",V);return z.renderer.addSystemNote(Z.text,Z.tone),!0}function Dz(z,J){let V=z.overCap(J);return(z.edited(J)?`
2
+ import{Pb as g,bc as Rz}from"./main-73g7eff4.js";import{ad as U,bd as jz,cd as az}from"./main-rfth4tbm.js";import{jf as Zz,lf as $z,nf as nz}from"./main-dfreez27.js";import{ji as d,ti as Tz}from"./main-3gjqfh7a.js";import{ak as v,ck as YJ}from"./main-xg704a3c.js";import{Rk as t,Sk as xz,Tk as e,Vk as zz,Wk as Jz,Xk as dz,ml as M,nl as Vz,ol as n}from"./main-3rxcvgna.js";import{Bl as FJ,Cl as r,Dl as pz,pl as I,rl as Hz,sl as Fz,ul as w,wl as _,yl as Yz}from"./main-4wndhjdc.js";import{wn as R}from"./main-qsevpgsv.js";function Pz(z){if(/[\r\n]/.test(z))return null;let J=z.trim();if(!Gz.test(J))return null;return J.slice(1).trim()}function h(z,J,V){let Z=z.add(J,V);if(!Z.ok)return{ok:!1,tone:"warn",text:`memory: not saved to ${A[J]} \u2014 ${Z.reason??"edit failed"}`};return{ok:!0,tone:"info",text:`memory: noted in ${A[J]} (${Z.current}/${Z.limit} chars, ${z.path(J)}) \u2014 in the prompt from the next run`}}function PJ(z,J){let V=Pz(J);if(V===null)return!1;z.renderer.addUser(J.trim());let Z=h(z.blocks(),"memory",V);return z.renderer.addSystemNote(Z.text,Z.tone),!0}function Dz(z,J){let V=z.overCap(J);return(z.edited(J)?`
3
3
  (edited this run \u2014 in the prompt from the next run)`:"")+(z.isWithheld(J)?`
4
4
  (not in the prompt and not writable \u2014 it came with this repository; rovecode trust show)`:"")+(V?`
5
5
  (over the ${V.cap}-char cap \u2014 the prompt shows the first ${V.cap}; trim the file)`:"")}function DJ(z,J){let V=J.trim(),Z=V==="--user"||V.startsWith("--user "),$=Z?V.slice(6).trim():V;if($){let K=h(z,Z?"user":"memory",$);return{text:K.text,tone:K.tone}}return{text:(Z?["user"]:["memory","user"]).map((K)=>`# ${A[K]} \u2014 ${z.path(K)}
@@ -35,4 +35,4 @@ ${X.body.trim().split(`
35
35
  `)}`,"error");return}Q="done",V.addSystemNote(`committed ${k(X.body)||k(Y)}${P?` \xB7 message by ${P}`:""}`)}finally{z.bindAbort(null),V.setBusy(!1,Q),z.setBusy(!1)}}var gz=(z)=>new Date(z.createdAt).toLocaleTimeString(),x=(z)=>`${z.hash.slice(0,8)} (${z.label}, ${gz(z)})`,lz={M:"rewritten",D:"recreated",A:"removed (added since that checkpoint)","?":"removed (created after the checkpoint)"};async function kJ(z){let{renderer:J}=z;if(z.busy()){J.addSystemNote(a,"warn");return}let V=await z.rt.checkpointsFor(z.store().id);if(!V){J.addSystemNote("checkpoints unavailable (git missing or ROVECODE_NO_CHECKPOINTS=1) \u2014 nothing to undo","warn");return}let Z=V.list().at(-1);if(!Z){J.addSystemNote("no checkpoint to undo to \u2014 snapshots land after each mutating tool call (edit, write, bash)");return}let $=await V.position(),Q=$.at?$.previous:Z;if(!Q){J.addSystemNote(`nothing to undo \u2014 the workspace matches checkpoint ${x($.at)} and no older snapshot differs from it (/checkpoints lists them; /restore <ref> reaches any)`);return}let j=x(Q),K=await V.changedSince(Q.hash);if(K!==null&&K.length===0){J.addSystemNote(`nothing to undo \u2014 the workspace already matches the last checkpoint ${j}`);return}let W=$.at?`undo the agent's last change (checkpoint ${$.at.hash.slice(0,8)}, ${$.at.label}): restore ${j}`:`restore the workspace to checkpoint ${j}`,q=K===null?`${W}: every file goes back to that snapshot (the change list could not be computed)`:[`${W} \u2014 ${K.length} path${K.length===1?"":"s"}:`,...K.slice(0,40).map((H)=>` ${H.status} ${H.path} \u2014 ${lz[H.status]??H.status}`),...K.length>40?[` \u2026 ${K.length-40} more`]:[],"","the conversation is untouched; /restore <ref> conversation branches it too"].join(`
36
36
  `);if(await J.askApproval("undo",`restore checkpoint ${Q.hash.slice(0,8)} \xB7 files only`,q)==="deny"){J.addSystemNote("undo cancelled \u2014 nothing changed","warn");return}let Y=await V.restore(Q.hash,"files");if(!Y.ok){J.addSystemNote(`undo failed: ${Y.error}`,"error");return}let P=K===null?"the workspace":`${K.length} path${K.length===1?"":"s"}: ${K.slice(0,8).map((H)=>H.path).join(", ")}${K.length>8?", \u2026":""}`;J.addSystemNote(`undo: restored ${P} to checkpoint ${j} \u2014 files only; the conversation is untouched (snapshots keep history: /checkpoints)`)}dz();xz();n();nz();pz();az();import{randomUUID as Kz}from"crypto";import{existsSync as oz}from"fs";import{basename as sz,isAbsolute as cz,join as rz}from"path";function mz(z){if(z==="win32")return[["powershell","-NoProfile","-NonInteractive","-Command","[Console]::InputEncoding=[Text.Encoding]::UTF8; $t=[Console]::In.ReadToEnd(); Set-Clipboard -Value $t"]];return[["pbcopy"],["wl-copy"],["xclip","-selection","clipboard"],["xsel","--clipboard","--input"]]}var iz=async(z,J)=>{try{let V=Bun.spawn([...z],{stdin:"pipe",stdout:"ignore",stderr:"pipe"});V.stdin.write(J),await V.stdin.end();let Z=await V.exited;if(Z===0)return{ok:!0};let $=(await new Response(V.stderr).text()).trim().split(`
37
37
  `)[0]??"";return{ok:!1,detail:`exit ${Z}${$?`: ${$.slice(0,120)}`:""}`}}catch(V){return{ok:!1,detail:V instanceof Error?V.message:String(V)}}};async function s(z,J={}){let V=J.spawn??iz,Z=[];if(z.length===0)return{ok:!1,tried:Z,detail:"nothing to copy (empty text)"};let $;for(let Q of mz(J.platform??process.platform)){let j=Q[0];Z.push(j);let K;try{K=await V(Q,z)}catch(W){K={ok:!1,detail:W instanceof Error?W.message:String(W)}}if(K.ok)return{ok:!0,tool:j};$=K.detail}return{ok:!1,tried:Z,...$!==void 0?{detail:$}:{}}}o();var dJ=[{name:"compact",description:"Compact the context now: /compact [focus] \u2014 the automatic strategy set, marker persisted",group:"session"},{name:"clear",description:"Fresh session in place (transcript emptied; the previous session is kept \u2014 /resume <id>)",group:"session"},{name:"init",description:"Analyse the repo and write AGENTS.md (an existing one gets targeted improvements)",group:"files & history"},{name:"copy",description:"Copy the last assistant message to the clipboard: /copy [n] (n-th from the end)",group:"session"}],c=6,C="finish or interrupt the run first (Esc)";function tz(z){return z.map((J)=>J.kind==="image"&&J.path!==void 0&&cz(J.path)?{...J,path:`${r}/${sz(J.path)}`}:J)}async function ez(z,J,V={}){let Z=z.messages(),$=Z.length;if($<c)return{kind:"nothing",reason:`nothing to compact \u2014 ${$} message${$===1?"":"s"} on the active path (compaction needs at least ${c})`};let Q=(L)=>Vz(L.parts),j=(L)=>L.reduce((N,Bz)=>N+t(Q(Bz)),0),K={trigger:"speculative",tokenText:Q,summarize:V.summarize,native:V.native,model:V.model,signal:V.signal},W=zz(Z,J,K),q=W?await Jz(Z,W,J,K):null;if(!q)return{kind:"nothing",reason:`nothing to compact \u2014 ${J.compactionStrategy??e} found nothing droppable (${j(Z)} tokens)`};let B=j(Z),Y=j(q.history),P=z.stagedAttachments;z.stageAttachments([]);let H=Z.at(-1)?.id,X=null;try{for(let L of q.history){let N={...L,id:Kz(),parentId:X,parts:tz(L.parts)};z.append(N),X=N.id}if(X!==null)z.branch(X)}catch(L){if(H!==void 0)z.branch(H);throw L}finally{z.stageAttachments(P)}let F={type:"compaction",strategy:q.strategy,tokensBefore:B,tokensAfter:Y};z.appendEvent(F);let D=new Set(Z.map((L)=>L.id)),G=q.history.filter((L)=>D.has(L.id)).length;return{kind:"compacted",event:F,dropped:$-G,kept:G,...q.fallbackFrom?{fallbackFrom:q.fallbackFrom}:{}}}function Qz(z,J){let V=(Z)=>Z===1?"":"s";return`${z.dropped} message${V(z.dropped)} dropped, ${z.kept} kept \u2014 the earlier turns stay in the session file on the previous branch`+(z.fallbackFrom?` \xB7 ${z.fallbackFrom} could not run on this surface (no summarizer wired) \u2014 ${z.event.strategy} ran instead`:"")+(J?` \xB7 focus "${J}" not applied \u2014 the compaction strategies take no instructions`:"")}function nJ(z,J){return z.kind==="nothing"?[z.reason]:[E(z.event),Qz(z,J)]}async function zJ(z,J){if(z.busy()){z.renderer.addSystemNote(C,"warn");return}let V=z.store();z.state.busy=!0;let Z=new AbortController;z.bindAbort?.(Z);let $;try{$=await ez(V,z.buildCfg(),{model:z.modes.modelFor(),summarize:z.summarize,signal:Z.signal})}catch(j){$={kind:"nothing",reason:`compaction failed: ${j instanceof Error?j.message:String(j)} \u2014 the session is unchanged`}}finally{z.bindAbort?.(null),z.state.busy=!1}if($.kind==="nothing"){z.renderer.addSystemNote($.reason,$.reason.startsWith("compaction failed")?"error":"info"),z.pushStatus();return}let Q=$z(V.messages())??z.defaultMode;if(Q!==z.modes.mode)V.append(Zz({from:Q,to:z.modes.mode},V.messages().at(-1)?.id??null));z.replayHistory(),z.refreshUsage(),z.pushStatus(),z.renderer.addSystemNote(Qz($,J))}function JJ(z){if(z.busy()){z.renderer.addSystemNote(C,"warn");return}let J=z.store().id,V=z.modes.mode,Z=Kz();if(z.switchSession(Z,!1),z.modes.mode!==V){z.modes.toggle(V);let $=z.modes.modelFor();z.state.mode=V,z.state.model=$.model,z.state.provider=$.provider,z.pushStatus()}z.renderer.addSystemNote(`cleared \u2014 fresh session ${Z.slice(0,8)} in the same directory; session ${J.slice(0,8)} kept (/resume ${J.slice(0,8)})`)}async function VJ(z){if(z.busy()){z.renderer.addSystemNote(C,"warn");return}let J=jz("/init",z.cwd);if(J===void 0)return;z.renderer.addSystemNote(oz(rz(z.cwd,U))?`${U} exists \u2014 asking the agent for targeted improvements (edits go through the usual approval)`:`analysing the repository to write ${U} (the write goes through the usual approval)`),await z.submit(J)}async function ZJ(z,J,V={}){let Z=z.filter((j)=>j.role==="assistant").map((j)=>M(j.parts)).filter((j)=>j.trim()!=="");if(Z.length===0)return{text:"nothing to copy \u2014 no assistant message with text yet",tone:"warn"};let $=Z[Z.length-J];if($===void 0)return{text:`nothing to copy \u2014 only ${Z.length} assistant message${Z.length===1?"":"s"} with text (asked for number ${J} from the end)`,tone:"warn"};let Q=await s($,V);if(Q.ok)return{text:`copied ${J===1?"the last assistant message":`assistant message ${J} from the end`} (${$.length} chars) to the clipboard via ${Q.tool}`,tone:"info"};return{text:`clipboard unavailable \u2014 tried ${Q.tried.join(", ")||"nothing"}${Q.detail?` (${Q.detail})`:""}; the text stays in the transcript`,tone:"warn"}}async function $J(z,J){if(z.busy()){z.renderer.addSystemNote(C,"warn");return}let V=J===""?1:/^[1-9]\d*$/.test(J)?Number(J):NaN;if(Number.isNaN(V)){z.renderer.addSystemNote("usage: /copy [n] \u2014 copies the last assistant message; n counts back from the latest (2 = the one before)","warn");return}let Z=await ZJ(z.store().messages(),V,z.clipboard??{});z.renderer.addSystemNote(Z.text,Z.tone)}async function aJ(z,J,V){switch(J){case"compact":return zJ(z,V);case"clear":return JJ(z);case"init":return VJ(z);case"copy":return $J(z,V);default:return}}
38
- export{Pz as L,h as M,PJ as N,DJ as O,Lz as P,Iz as Q,OJ as R,MJ as S,m as T,bJ as U,kJ as V,E as W,SJ as X,o as Y,dJ as Z,ez as _,nJ as $,ZJ as aa,aJ as ba,JV as ca,VV as da,ZV as ea,$V as fa,jV as ga,KV as ha,QV as ia,GJ as ja};
38
+ export{Pz as Ea,h as Fa,PJ as Ga,DJ as Ha,Lz as Ia,Iz as Ja,OJ as Ka,MJ as La,m as Ma,bJ as Na,kJ as Oa,E as Pa,SJ as Qa,o as Ra,dJ as Sa,ez as Ta,nJ as Ua,ZJ as Va,aJ as Wa,JV as Xa,VV as Ya,ZV as Za,$V as _a,jV as $a,KV as ab,QV as bb,GJ as cb};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Ra as X3,Sa as G3,Ta as j3,Ua as p6}from"./main-rsy72qmw.js";import{dg as R$,lg as K3}from"./main-rvetps99.js";import{Jj as Y3,Wj as x6}from"./main-ywbxshqc.js";import{Dl as z3,ul as P$}from"./main-a3f51n0x.js";import{vn as w$,wn as T}from"./main-qsevpgsv.js";import{existsSync as N3,readFileSync as _3}from"fs";import{relative as H3}from"path";import{structuredPatch as B3}from"diff";function F3($){return`\u2026 +${$} more line${$===1?"":"s"}`}function M3($,J){return $.length>J?[...$.slice(0,J),F3($.length-J)]:$}function E3($,J){return P$($,J)}function D3($){let J=Math.min($.length,A3);for(let Z=0;Z<J;Z++)if($[Z]===0)return!0;return!1}function S3($){switch($.kind){case"tag-mismatch":return`stale read \u2014 file TAG is now ${$.actual}, the edit expects ${$.expected}`;case"hash-mismatch":return`stale anchor \u2014 line ${$.line} hash is ${$.actual}, the edit expects ${$.expected}; ${$.nearest}`;case"out-of-range":return`line ${$.line} out of range (file has ${$.lineCount} lines)`}}function P3($,J){if(!Array.isArray($.edits))return null;let Z=[];for(let Y of $.edits){let X=typeof Y==="object"&&Y!==null?Y:{};if(typeof X.tag!=="string"||typeof X.anchorHash!=="string"||typeof X.anchorLine!=="number")return null;if(!Array.isArray(X.newLines)||!X.newLines.every((G)=>typeof G==="string"))return null;Z.push({path:J,tag:X.tag,anchorLine:X.anchorLine,anchorHash:X.anchorHash,newLines:X.newLines})}return Z}function R3($,J){let Z=$.replace(/\r\n/g,`
2
+ import{Kb as X3,Lb as G3,Mb as j3,Nb as p6}from"./main-73g7eff4.js";import{Vg as R$,bh as K3}from"./main-1dchs7xv.js";import{hk as Y3,uk as x6}from"./main-8kjxbpw4.js";import{Ul as P$,bm as z3}from"./main-0904f6ps.js";import{vn as w$,wn as T}from"./main-qsevpgsv.js";import{existsSync as N3,readFileSync as _3}from"fs";import{relative as H3}from"path";import{structuredPatch as B3}from"diff";function F3($){return`\u2026 +${$} more line${$===1?"":"s"}`}function M3($,J){return $.length>J?[...$.slice(0,J),F3($.length-J)]:$}function E3($,J){return P$($,J)}function D3($){let J=Math.min($.length,A3);for(let Z=0;Z<J;Z++)if($[Z]===0)return!0;return!1}function S3($){switch($.kind){case"tag-mismatch":return`stale read \u2014 file TAG is now ${$.actual}, the edit expects ${$.expected}`;case"hash-mismatch":return`stale anchor \u2014 line ${$.line} hash is ${$.actual}, the edit expects ${$.expected}; ${$.nearest}`;case"out-of-range":return`line ${$.line} out of range (file has ${$.lineCount} lines)`}}function P3($,J){if(!Array.isArray($.edits))return null;let Z=[];for(let Y of $.edits){let X=typeof Y==="object"&&Y!==null?Y:{};if(typeof X.tag!=="string"||typeof X.anchorHash!=="string"||typeof X.anchorLine!=="number")return null;if(!Array.isArray(X.newLines)||!X.newLines.every((G)=>typeof G==="string"))return null;Z.push({path:J,tag:X.tag,anchorLine:X.anchorLine,anchorHash:X.anchorHash,newLines:X.newLines})}return Z}function R3($,J){let Z=$.replace(/\r\n/g,`
3
3
  `).split(`
4
4
  `),Y=Z[Z.length-1]==="";if(Y)Z.pop();let X=Z.map((G)=>J+G);if(!Y&&X.length>0)X.push("\");return X}function T3($,J,Z,Y){let X=Y.maxLines??q3;if(J===Z)return{text:"",truncated:!1,kind:"unchanged"};let G=[],j="modify";if(J===null){j="create";let Q=R3(Z,"+");if(Q.length>0)G.push(`@@ -0,0 +1,${Q.filter((z)=>z[0]==="+").length} @@`,...Q)}else{if(J.length+Z.length>V3)return $0("file too large to preview");let Q=B3($,$,J,Z,void 0,void 0,{context:Y.context??O3,stripTrailingCr:!0,maxEditLength:D$,timeout:S$});if(Q===void 0)return $0(`change too large to preview (over ${D$} edited lines or ${S$}ms)`);for(let z of Q.hunks)G.push(`@@ -${z.oldStart},${z.oldLines} +${z.newStart},${z.newLines} @@`,...z.lines);if(G.length===0)return{text:"no content changes (line endings only)",truncated:!1,kind:"unchanged"}}let U=[`--- ${J===null?"/dev/null":`a/${$}`}`,`+++ b/${$}`,...G];return{text:M3(U,X).join(`
5
5
  `),truncated:U.length>X,kind:j}}function a6($,J,Z,Y={}){try{let X=typeof J==="object"&&J!==null?J:{};if(typeof X.path!=="string"||X.path==="")return $0("missing path");let G=E3(Z,X.path),j=H3(Z,G).replace(/\\/g,"/")||X.path,U=null;if(N3(G)){let z=_3(G);if(D3(z))return $0("binary file");U=z.toString("utf8")}let Q;if($==="write"){if(typeof X.content!=="string")return $0("missing content");Q=X.content}else{if(U===null)return $0(`file not found: ${G}`);let z=P3(X,G);if(z===null)return $0("malformed edits");let K=R$(U,z,G);if(!K.ok)return $0(S3(K.failure));Q=K.content}if(Q.includes("\x00"))return $0("binary content");return T3(j,U,Q,Y)}catch(X){return $0(X instanceof Error?X.message:String(X))}}var q3=40,O3=3,A3=8000,D$=2000,S$=1000,V3=4000000,$0=($)=>({text:`diff unavailable: ${$}`,truncated:!1,kind:"unavailable"});var I3=T(()=>{z3();K3()});function k0($){X0=$}function P1($){return W3.get($)??$}function s0($,J){if((J&~C0&D.shift)!==0&&$>=65&&$<=90)return $+32;return $}function n0($){if($.includes("\x1B[200~"))return!1;if($.includes(":3u")||$.includes(":3~")||$.includes(":3A")||$.includes(":3B")||$.includes(":3C")||$.includes(":3D")||$.includes(":3H")||$.includes(":3F"))return!0;return!1}function d0($){if(!$)return"press";let J=parseInt($,10);if(J===2)return"repeat";if(J===3)return"release";return"press"}function k3($){let J=$.match(/^\x1b\[(\d+)(?::(\d*))?(?::(\d+))?(?:;(\d+))?(?::(\d+))?u$/);if(J){let G=parseInt(J[1],10),j=J[2]&&J[2].length>0?parseInt(J[2],10):void 0,U=J[3]?parseInt(J[3],10):void 0,Q=J[4]?parseInt(J[4],10):1,z=d0(J[5]);return l0=z,{codepoint:G,shiftedKey:j,baseLayoutKey:U,modifier:Q-1,eventType:z}}let Z=$.match(/^\x1b\[1;(\d+)(?::(\d+))?([ABCD])$/);if(Z){let G=parseInt(Z[1],10),j=d0(Z[2]),U={A:-1,B:-2,C:-3,D:-4};return l0=j,{codepoint:U[Z[3]],modifier:G-1,eventType:j}}let Y=$.match(/^\x1b\[(\d+)(?:;(\d+))?(?::(\d+))?~$/);if(Y){let G=parseInt(Y[1],10),j=Y[2]?parseInt(Y[2],10):1,U=d0(Y[3]),z={2:y.insert,3:y.delete,5:y.pageUp,6:y.pageDown,7:y.home,8:y.end}[G];if(z!==void 0)return l0=U,{codepoint:z,modifier:j-1,eventType:U}}let X=$.match(/^\x1b\[1;(\d+)(?::(\d+))?([HF])$/);if(X){let G=parseInt(X[1],10),j=d0(X[2]),U=X[3]==="H"?y.home:y.end;return l0=j,{codepoint:U,modifier:G-1,eventType:j}}return null}function R($,J,Z){let Y=k3($);if(!Y)return!1;let X=Y.modifier&~C0,G=Z&~C0;if(X!==G)return!1;let j=s0(P1(Y.codepoint),Y.modifier),U=s0(P1(J),Z);if(j===U)return!0;if(Y.baseLayoutKey!==void 0&&Y.baseLayoutKey===J){let Q=j,z=Q>=97&&Q<=122,K=S1.has(String.fromCharCode(Q));if(!z&&!K)return!0}return!1}function R1($){let J=$.match(/^\x1b\[27;(\d+);(\d+)~$/);if(!J)return null;let Z=parseInt(J[1],10);return{codepoint:parseInt(J[2],10),modifier:Z-1}}function n($,J,Z){let Y=R1($);if(!Y)return!1;return Y.codepoint===J&&Y.modifier===Z}function v3(){return Boolean(process.env.WT_SESSION)&&!process.env.SSH_CONNECTION&&!process.env.SSH_CLIENT&&!process.env.SSH_TTY}function T$($,J){if($==="\x7F")return J===0;if($!=="\b")return!1;return v3()?J===D.ctrl:J===0}function b3($){let J=$.toLowerCase(),Z=J.charCodeAt(0);if(Z>=97&&Z<=122||J==="["||J==="\\"||J==="]"||J==="_")return String.fromCharCode(Z&31);if(J==="-")return String.fromCharCode(31);return null}function I$($){return $>="0"&&$<="9"}function o0($,J,Z){if(Z===0)return!1;let Y=R1($);if(!Y||Y.modifier!==Z)return!1;return s0(Y.codepoint,Y.modifier)===s0(J,Z)}function y3($){let J=$.toLowerCase().split("+"),Z=J[J.length-1];if(!Z)return null;return{key:Z,ctrl:J.includes("ctrl"),shift:J.includes("shift"),alt:J.includes("alt"),super:J.includes("super")}}function d($,J){let Z=y3(J);if(!Z)return!1;let{key:Y,ctrl:X,shift:G,alt:j,super:U}=Z,Q=0;if(G)Q|=D.shift;if(j)Q|=D.alt;if(X)Q|=D.ctrl;if(U)Q|=D.super;switch(Y){case"escape":case"esc":if(Q!==0)return!1;return $==="\x1B"||R($,v.escape,0)||n($,v.escape,0);case"space":if(!X0){if(Q===D.ctrl&&$==="\x00")return!0;if(Q===D.alt&&$==="\x1B ")return!0}if(Q===0)return $===" "||R($,v.space,0)||n($,v.space,0);return R($,v.space,Q)||n($,v.space,Q);case"tab":if(Q===D.shift)return $==="\x1B[Z"||R($,v.tab,D.shift)||n($,v.tab,D.shift);if(Q===0)return $==="\t"||R($,v.tab,0);return R($,v.tab,Q)||n($,v.tab,Q);case"enter":case"return":if(Q===D.shift){if(R($,v.enter,D.shift)||R($,v.kpEnter,D.shift))return!0;if(n($,v.enter,D.shift))return!0;if(X0)return $==="\x1B\r"||$===`
@@ -55,4 +55,4 @@ import{Ra as X3,Sa as G3,Ta as j3,Ua as p6}from"./main-rsy72qmw.js";import{dg as
55
55
  \x1B[2K`);E.append(`\x1B[${F}A`)}if(E.append("\x1B[?2026l"),process.env.PI_TUI_DEBUG==="1"){Q0.mkdirSync("/tmp/tui",{recursive:!0});let V=E0.join("/tmp/tui",`render-${Date.now()}-${Math.random().toString(36).slice(2)}.log`),L=[`firstChanged: ${H}`,`viewportTop: ${j}`,`cursorRow: ${this.cursorRow}`,`height: ${J}`,`lineDiff: ${I}`,`hardwareCursorRow: ${U}`,`renderEnd: ${k}`,`finalCursorRow: ${f}`,`cursorPos: ${JSON.stringify(K)}`,`newLines.length: ${z.length}`,`previousLines.length: ${this.previousLines.length}`,"","=== newLines ===",JSON.stringify(z,null,2),"","=== previousLines ===",JSON.stringify(this.previousLines,null,2),"","=== buffer ===",`[${E.length} chars written in bounded chunks]`].join(`
56
56
  `);Q0.writeFileSync(V,L)}E.flush(),this.cursorRow=Math.max(0,z.length-1),this.hardwareCursorRow=f,this.maxLinesRendered=Math.max(this.maxLinesRendered,z.length),this.previousViewportTop=Math.max(G,f-J+1),this.positionHardwareCursor(K,z.length),this.previousLines=z,this.previousKittyImageIds=this.collectKittyImageIds(z),this.previousWidth=$,this.previousHeight=J}positionHardwareCursor($,J){if(!$||J<=0){this.terminal.hideCursor();return}let Z=Math.max(0,Math.min($.row,J-1)),Y=Math.max(0,$.col),X=Z-this.hardwareCursorRow,G="";if(X>0)G+=`\x1B[${X}B`;else if(X<0)G+=`\x1B[${-X}A`;if(G+=`\x1B[${Y+1}G`,G)this.terminal.write(G);if(this.hardwareCursorRow=Z,this.getShowHardwareCursor())this.terminal.showCursor();else this.terminal.hideCursor()}}});import{Marked as t4}from"marked";var B$=T(()=>{n$();Y8();Q8();L8();v8();b8();A1();l1();x8();_$();Z$();p8();u8();c1();m8();h8();X1();N0();z0();z$();C1();x$();r1();_0();Y0();r8();t8();g()});var B0=($,J)=>(Z)=>`\x1B[${$}m${Z}\x1B[${J}m`,W,x,c0,e8,$3;var q$=T(()=>{W={bold:B0("1","22"),dim:B0("2","22"),italic:B0("3","23"),underline:B0("4","24"),inverse:B0("7","27"),strike:B0("9","29"),fg:($)=>B0(`38;5;${$}`,"39"),bg:($)=>B0(`48;5;${$}`,"49")},x={accent:W.fg(75),accentDim:W.fg(67),ok:W.fg(114),warn:W.fg(215),err:W.fg(203),muted:W.dim,code:W.fg(180),link:W.fg(75)},c0={selectedPrefix:($)=>x.accent($),selectedText:($)=>W.bold($),description:($)=>W.dim($),scrollInfo:($)=>W.dim($),noMatch:($)=>W.dim($)},e8={borderColor:($)=>x.accentDim($),selectList:c0},$3={heading:($)=>W.bold(x.accent($)),link:($)=>x.link(W.underline($)),linkUrl:($)=>W.dim($),code:($)=>x.code($),codeBlock:($)=>x.code($),codeBlockBorder:($)=>W.dim($),quote:($)=>W.italic(W.dim($)),quoteBorder:($)=>W.dim($),hr:($)=>W.dim($),listBullet:($)=>x.accent($),bold:($)=>W.bold($),italic:($)=>W.italic($),strikethrough:($)=>W.strike($),underline:($)=>W.underline($)}});function D0($,J){let Z=m($,J-2,"\u2026");return` ${Z}${" ".repeat(Math.max(0,J-1-M(Z)))}`}class O${title;diff;list;rows;constructor($,J,Z,Y){this.title=$;this.diff=J;this.list=Z;this.rows=Y}handleInput($){this.list.handleInput($)}invalidate(){this.list.invalidate()}render($){let J=Math.max(4,this.rows()-12),Z=this.diff;if(Z.length>J){let Y=f6.exec(Z[Z.length-1]),X=Z.length-J+(Y?Number(Y[1])-1:0);Z=[...Z.slice(0,J),`\u2026 +${X} more line${X===1?"":"s"}`]}return[D0(x.warn(this.title),$),...Z.map((Y,X)=>D0(g6(Y,X),$))," ".repeat($),...this.list.render($)]}}function g6($,J){if(J===0&&$.startsWith("--- ")||J===1&&$.startsWith("+++ "))return W.dim($);let Z=$[0];return Z==="+"?x.ok($):Z==="-"?x.err($):Z===" "?$:W.dim($)}class F${question;list;optionCount;freeText;rows;busy;typing;input=new V0;constructor($,J,Z,Y,X,G){this.question=$;this.list=J;this.optionCount=Z;this.freeText=Y;this.rows=X;this.busy=G;this.typing=Z===0}get isTyping(){return this.typing}setTyping($){this.typing=$}handleInput($){if(this.typing)this.input.handleInput($);else this.list.handleInput($)}invalidate(){this.list.invalidate(),this.input.invalidate()}render($){let J=this.typing?1:this.optionCount+(this.freeText?1:0)+1,Z=Math.max(2,this.rows()-9-J),Y=a(this.question,$-2);if(Y.length>Z)Y=[...Y.slice(0,Z-1),W.dim(`\u2026 +${Y.length-Z+1} more lines`)];let X=this.busy()?"Esc stop the run":"Esc skip",G=this.typing?[D0(this.input.render($-2)[0]??"",$),D0(W.dim(this.optionCount>0?"Enter sends \xB7 Esc back to the options":`Enter sends \xB7 ${X}`),$)]:[...this.list.render($),D0(W.dim(`\u2191\u2193 choose \xB7 Enter answer \xB7 ${X}`),$)];return[D0(x.warn("question"),$),...Y.map((j)=>D0(j,$))," ".repeat($),...G]}}var f6,A$="\x00free-text",V$="\x00skip-question";var J3=T(()=>{B$();q$();f6=/^\u2026 \+(\d+) more line/});class M${inner;pending=[];visible=!1;discarded=!1;constructor($){this.inner=$}get columns(){return this.inner.columns}get rows(){return this.inner.rows}get kittyProtocolActive(){return this.inner.kittyProtocolActive}prepare($){this.pending=[],$()}reveal($,J){if(this.discarded||this.visible)return;let Z=this.pending;this.pending=[];let Y=String.fromCharCode(27);this.inner.write(`${Y}[?2026h`);try{J?.(),this.visible=!0,$();for(let X of Z)X()}finally{this.inner.write(`${Y}[?2026l`)}}emit($){if(this.discarded)return;if(this.visible)$();else this.pending.push($)}start($,J){if(this.visible)this.inner.start($,J)}stop(){if(this.discarded=!0,this.pending=[],this.visible)this.inner.stop()}drainInput($,J){return this.visible?this.inner.drainInput($,J):Promise.resolve()}write($){this.emit(()=>this.inner.write($))}moveBy($){this.emit(()=>this.inner.moveBy($))}hideCursor(){this.emit(()=>this.inner.hideCursor())}showCursor(){this.emit(()=>this.inner.showCursor())}clearLine(){this.emit(()=>this.inner.clearLine())}clearFromCursor(){this.emit(()=>this.inner.clearFromCursor())}clearScreen(){this.emit(()=>this.inner.clearScreen())}setTitle($){this.emit(()=>this.inner.setTitle($))}setProgress($){this.emit(()=>this.inner.setProgress($))}}var Z3=()=>{};var c6={};w$(c6,{PiTuiRenderer:()=>Q3});import{existsSync as u6}from"fs";import{join as m6}from"path";function D1($,J=h6){let Z=$.replace(/\s+/g," ").trim();return Z.length>J?`${Z.slice(0,J-1)}\u2026`:Z}class Q3{terminal;cwd;commands=[];tui=null;editor=null;statusLine=null;statusText="";loader=null;hooks=null;unsubscribeInput=null;toolCards=new Map;pendingPickers=new Set;constructor($){this.terminal=$?.terminal??new v0,this.cwd=$?.cwd??process.cwd()}ui(){if(!this.tui)throw Error("PiTuiRenderer: start() must be called first");return this.tui}requireEditor(){if(!this.editor)throw Error("PiTuiRenderer: start() must be called first");return this.editor}insertTranscript($){let J=this.tui,Z=this.loader??this.editor;if(!J||!Z)return;let Y=J.children.indexOf(Z);J.children.splice(Y<0?J.children.length:Y,0,$),J.requestRender()}start($,J){if(this.tui)return;this.hooks=$;let Z=J?.beforeReveal?new M$(this.terminal):void 0,Y=Z?new E$(Z):new h0(this.terminal);this.tui=Y,Y.addChild(new Z0(W.dim("rovecode"),1,0));let X=new B1(Y,e8);this.editor=X,X.onSubmit=(j)=>{let U=j.trim();if(!U)return;let Q=X3(U);if(Q.length===0){$.onSubmit(U);return}let z=G3(U,{cwd:this.cwd,mentions:Q,resolve:(K)=>u6(m6(this.cwd,K))?K.replace(/\\/g,"/"):null});for(let K of z.notes)this.addSystemNote(K,"warn");$.onSubmit(z.text)},X.setAutocompleteProvider(new b0(this.commands,this.cwd)),Y.addChild(X);let G=new m0(this.statusText,1,0);if(this.statusLine=G,Y.addChild(G),Y.setFocus(X),this.unsubscribeInput=Y.addInputListener((j)=>{if(d(j,r0.ctrl("c")))return $.onExit(),{consume:!0};if(this.loader&&!Y.hasOverlay()&&d(j,r0.escape))return this.loader.handleInput(j),{consume:!0};return}),J?.beforeFirstRender?.(),Z&&Y instanceof E$&&J?.beforeReveal)return Z.prepare(()=>Y.renderNow(!0)),J.beforeReveal().then(()=>{if(this.tui!==Y)return;Z.prepare(()=>Y.renderNow(!0)),Z.reveal(()=>Y.reveal(),J.onReveal)});J?.onReveal?.(),Y.start()}stop(){let $=this.tui;if(!$)return;if(this.loader)this.loader.stop(),this.loader=null;if(this.unsubscribeInput)this.unsubscribeInput(),this.unsubscribeInput=null;for(let J of this.pendingPickers)J();this.pendingPickers.clear(),$.stop(),this.tui=null,this.editor=null,this.statusLine=null,this.hooks=null,this.toolCards.clear()}setCommands($){if(this.commands=$.slice(),this.editor)this.editor.setAutocompleteProvider(new b0(this.commands,this.cwd))}addUser($){let{text:J,files:Z}=j3($);this.insertTranscript(new Z0(W.dim("> ")+J,1,0));for(let Y of Z)this.insertTranscript(new Z0(W.dim(` \u25A4 attached ${Y}`),1,0))}addSystemNote($,J="info"){let Z=J==="warn"?x.warn:J==="error"?x.err:x.muted;this.insertTranscript(new Z0(Z($),1,0))}beginAssistant(){let $=this.tui;if(!$)return{append:()=>{},done:()=>{}};let J=new M1("",1,1,$3);this.insertTranscript(J);let Z="";return{append:(Y)=>{Z+=Y,J.setText(Z),$.requestRender()},done:()=>{}}}toolStart($,J,Z){let Y=D1(`\u2192 ${J} ${Z}`),X=new Z0(W.dim(Y),1,0);this.toolCards.set($,{line:X,tool:J,base:Y}),this.insertTranscript(X)}toolUpdate($,J){let Z=this.toolCards.get($);if(!Z)return;Z.line.setText(W.dim(D1(`${Z.base} \xB7 ${J}`))),this.tui?.requestRender()}toolEnd($,J,Z,Y){let X=this.toolCards.get($);if(!X)return;this.toolCards.delete($);let G=J?x.ok:x.err,j=J?"ok":"FAIL";X.line.setText(G(D1(`\u2190 ${j} ${X.tool} (${Y}ms) ${Z}`))),this.tui?.requestRender()}pickWith($,J,Z){let Y=this.tui,X=this.editor;if(!Y||!X)return Promise.resolve(null);return new Promise((G)=>{let j=Y.showOverlay($,{width:Z,anchor:"center"}),U=!1,Q=(K)=>{if(U)return;if(U=!0,this.pendingPickers.delete(z),j.hide(),this.tui)Y.setFocus(X),Y.requestRender();G(K)},z=()=>Q(null);this.pendingPickers.add(z),J.onSelect=(K)=>Q(K.value),J.onCancel=()=>Q(null)})}pickOne($,J){if(!this.tui||$.length===0)return Promise.resolve(null);if(J)this.addSystemNote(J);let Z=new H0($.map((Y)=>({value:Y.value,label:Y.label,description:Y.description})),Math.min($.length,8),c0);return this.pickWith(Z,Z,64)}async askApproval($,J,Z){this.addSystemNote(`approval needed: ${$} ${J}`,"warn");let Y=[{value:"once",label:"allow once",description:"run this call only"},{value:"always",label:"always",description:"allow this tool for the session"},{value:"deny",label:"deny",description:"reject this call"}],X;if(Z){let G=new H0(Y,Y.length,c0),j=new O$(`approval needed: ${$}`,Z.split(`
57
57
  `),G,()=>this.terminal.rows);X=await this.pickWith(j,G,Math.max(40,Math.min(this.terminal.columns-4,100)))}else X=await this.pickOne(Y);return X==="once"||X==="always"?X:"deny"}askQuestion($,J){let Z=this.tui,Y=this.editor;if(!Z||!Y||J?.aborted)return Promise.resolve(null);if(Z.hasOverlay())return Promise.reject(Error("a question or approval overlay is already open"));let X=$.options??[],G=$.allowFreeText!==!1,j=X.map((z,K)=>({value:String(K),label:z}));if(G)j.push({value:A$,label:"type an answer\u2026"});j.push({value:V$,label:"skip this question"});let U=new H0(j,Math.max(1,j.length),c0),Q=new F$($.question,U,X.length,G,()=>this.terminal.rows,()=>this.loader!==null);return this.addSystemNote(`question: ${D1($.question)}`,"warn"),new Promise((z)=>{let K=Z.showOverlay(Q,{width:Math.max(40,Math.min(this.terminal.columns-4,100)),anchor:"center"}),N=!1,_=(q)=>{if(N)return;if(N=!0,this.pendingPickers.delete(B),J?.removeEventListener("abort",B),K.hide(),this.tui)Z.setFocus(Y),Z.requestRender();z(q)},B=()=>_(null);this.pendingPickers.add(B),J?.addEventListener("abort",B,{once:!0});let H=()=>{if(this.loader)this.hooks?.onInterrupt();else _(null)};U.onCancel=H,U.onSelect=(q)=>{if(q.value===V$){_(null);return}if(q.value===A$){Q.setTyping(!0),Z.requestRender();return}let A=Number(q.value);_({choice:A,label:X[A]})},Q.input.onEscape=()=>{if(X.length>0)Q.setTyping(!1),Z.requestRender();else H()},Q.input.onSubmit=(q)=>{let A=q.trim();if(A)_({text:A})}})}clearTranscript(){let $=this.tui,J=this.loader??this.editor;if(!$||!J)return;let Z=$.children.indexOf(J);if(Z>1)$.children.splice(1,Z-1);this.toolCards.clear(),$.requestRender()}prefillEditor($){let J=this.tui,Z=this.editor;if(!J||!Z)return;Z.setText($),J.setFocus(Z),J.requestRender()}setBusy($,J){let Z=this.tui;if(!Z){this.loader=null;return}if($){let Y=J??"thinking\u2026";if(this.loader){this.loader.setMessage(Y);return}let X=new z1(Z,(U)=>x.accent(U),(U)=>W.dim(U),Y);X.onAbort=()=>{this.hooks?.onInterrupt()},this.loader=X;let G=this.editor,j=G?Z.children.indexOf(G):-1;Z.children.splice(j<0?Z.children.length:j,0,X),X.start(),Z.requestRender()}else{let Y=this.loader;if(!Y)return;this.loader=null,Y.stop();let X=Z.children.indexOf(Y);if(X>=0)Z.children.splice(X,1);Z.requestRender()}}setStatus($){let J=Y3($.yolo),Z=$.mode?`${$.mode} \xB7 `:"";this.statusText=W.dim(`${Z}${$.provider}/${$.model} \xB7 ${J} \xB7 turns ${$.turns} \xB7 tokens ${$.tokensIn}/${$.tokensOut}${$.todos?` \xB7 ${$.todos}`:""}`);let Y=this.tui;if(!Y||!this.statusLine)return;let X=new m0(this.statusText,1,0),G=Y.children.indexOf(this.statusLine);if(G>=0)Y.children.splice(G,1,X);else Y.children.push(X);this.statusLine=X,Y.requestRender()}}var h6=120,E$;var l6=T(()=>{B$();J3();x6();p6();q$();Z3();E$=class E$ extends h0{holding=!0;requestRender($=!1){if(!this.holding)super.requestRender($)}reveal(){this.holding=!1,this.start()}}});
58
- export{F3 as s,a6 as t,I3 as u,t0 as v,W1 as w,N2 as x,x$ as y,Q3 as z,c6 as A,l6 as B};
58
+ export{F3 as I,a6 as J,I3 as K,t0 as L,W1 as M,N2 as N,x$ as O,Q3 as P,c6 as Q,l6 as R};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ import{Eh as C,Fh as G,Ph as K}from"./main-kcpbykxz.js";import{rm as D}from"./main-2zmzgkwh.js";import{wm as J}from"./main-a9njrkk1.js";import{$m as I,Lm as E}from"./main-2yeveeve.js";import{dn as B,kn as F}from"./main-nqveez48.js";I();G();F();J();F();G();K();async function x(z,A={}){let q=A.home??E(),k=C(z,{home:q,state:B(q)}),j=await D(k.plugins,{cwd:z,home:q,...A.timeoutMs!==void 0?{timeoutMs:A.timeoutMs}:{}});return{plugins:j.plugins,warnings:[...k.warnings,...j.warnings]}}function h(z){if(z.length===0)return null;let A=(k)=>z.filter((j)=>j.status===k).map((j)=>j.name),q=[];for(let k of["active","untrusted","disabled","broken"]){let j=A(k);if(j.length)q.push(`${j.length} ${k} (${j.join(", ")})`)}return`plugins: ${q.join(" \xB7 ")}`}
3
+ export{x as yh,h as zh};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ import{sm as H,wm as L}from"./main-a9njrkk1.js";import{Fm as k,zm as $}from"./main-7rn6bqje.js";import{Gm as x,Jm as D}from"./main-mv40pcr2.js";D();k();L();import{existsSync as P}from"fs";import{join as A}from"path";import{pathToFileURL as S}from"url";var M=5000;function U(b=process.env){let B=Number(b.ROVECODE_PLUGIN_TIMEOUT_MS);return Number.isFinite(B)&&B>=1?Math.floor(B):M}var G=["read","write","execute","spawn","memory","network","custom"],K=/^[a-z][a-z0-9_]{0,63}$/,R={read:"file.read",write:"file.write",execute:"shell.exec",spawn:"spawn",memory:"memory.write",network:"net.fetch"};function E(b,B,q){if(B===void 0)return b;let z=R[b.kind];if(z===void 0)return b;if(B.includes(z)||B.includes("*"))return b;return{...b,execute:async(J,Q)=>({ok:!1,output:`Permission denied: plugin '${q}' did not declare '${z}' \u2014 add it to the manifest's "permissions" and re-install, or remove this tool`})}}var V=Symbol("timed-out");async function h(b,B){let q,z=new Promise((J)=>{q=setTimeout(()=>J(V),B)});try{return await Promise.race([b,z])}finally{if(q!==void 0)clearTimeout(q)}}var y=(b)=>b instanceof Error?b.message:String(b);async function p(b,B){let q=[],z=[];for(let J of b)z.push(await N(J,B,q));return{plugins:z,warnings:q}}async function N(b,B,q){let z={...b,tools:[],hooks:null};if(b.status!=="active"||b.manifest===null)return z;let J=b.manifest,Q=`plugin ${b.name}`;if(!J.entry)return z;let v=A(b.dir,J.entry);if(!P(v))return q.push(`${Q}: entry ${J.entry} does not exist \u2014 no tools or hooks loaded`),z;let C=B.timeoutMs??U(),F;try{F=await h(import(S(v).href),C)}catch(W){return q.push(`${Q}: ${J.entry} failed to load \u2014 ${y(W)}`),z}if(F===V)return q.push(`${Q}: ${J.entry} load timed out after ${C}ms (top-level await?) \u2014 skipped`),z;let Y=$(F)?F.default:void 0;if(!$(Y))return q.push(`${Q}: ${J.entry} must \`export default { api: ${H}, tools?, hooks? }\` \u2014 skipped`),z;if(Y.api!==H)return q.push(`${Q}: ${J.entry} declares api ${String(Y.api)}; this rovecode speaks ${H} \u2014 skipped`),z;for(let W of Object.keys(Y))if(!["api","tools","hooks"].includes(W))q.push(`${Q}: ${J.entry} exports unknown member "${W}" \u2014 ignored`);if(Y.tools!==void 0){let W;try{let X=Y.tools;W=typeof X==="function"?await h(Promise.resolve(X({cwd:B.cwd,home:B.home,pluginDir:b.dir})),C):X}catch(X){q.push(`${Q}: tools() threw \u2014 ${y(X)}`),W=[]}if(W===V)q.push(`${Q}: tools() timed out after ${C}ms \u2014 no tools loaded`),W=[];if(!Array.isArray(W))q.push(`${Q}: "tools" must be an array (or a function returning one) \u2014 ignored`),W=[];let Z=new Set;for(let X of W){let j=f(X,Q,q);if(!j)continue;if(Z.has(j.schema.name)){q.push(`${Q}: tool "${j.schema.name}" declared twice \u2014 first kept`);continue}Z.add(j.schema.name),z.tools.push(E(j,J.permissions,Q))}}if(Y.hooks!==void 0)if(!$(Y.hooks))q.push(`${Q}: "hooks" must be an object of hook functions \u2014 ignored`);else{let W={};for(let[Z,X]of Object.entries(Y.hooks)){if(!x.includes(Z)){q.push(`${Q}: unknown hook "${Z}" ignored (known: ${x.join(", ")})`);continue}if(typeof X!=="function"){q.push(`${Q}: hook "${Z}" is not a function \u2014 ignored`);continue}W[Z]=X}if(Object.keys(W).length)z.hooks=W}return z}function f(b,B,q){if(!$(b)||!$(b.schema))return q.push(`${B}: a tool without a schema was dropped`),null;let z=b.schema,J=z.name;if(typeof J!=="string"||!K.test(J))return q.push(`${B}: tool name ${JSON.stringify(J)} must match ${K} \u2014 dropped`),null;if(typeof z.description!=="string"||!z.description.trim())return q.push(`${B}: tool "${J}" needs a description \u2014 dropped`),null;if(!$(z.args))return q.push(`${B}: tool "${J}" needs a JSON-Schema "args" object \u2014 dropped`),null;if(!G.includes(b.kind))return q.push(`${B}: tool "${J}" kind ${JSON.stringify(b.kind)} is not one of ${G.join("|")} \u2014 dropped (the kind is its permission class)`),null;if(typeof b.execute!=="function")return q.push(`${B}: tool "${J}" has no execute() \u2014 dropped`),null;return b}
3
+ export{M as qm,p as rm};
@@ -4,4 +4,4 @@ import{$m as c,Lm as I}from"./main-2yeveeve.js";import{wn as E}from"./main-qsevp
4
4
  ---`,3);if(Q===-1)return null;let Z=Q+1+J.slice(Q+1).indexOf(`
5
5
  `)+1,z=J.slice(4,Q),Y=J.slice(Z).replace(/^\r?\n/,""),$={},V=z.split(/\r?\n/);for(let G=0;G<V.length;G++){let W=V[G];if(/^\s/.test(W))continue;let U=W.indexOf(":");if(U===-1)continue;let j=W.slice(0,U).trim();if(!j)continue;let T=W.slice(U+1).trim(),q=/^([|>])([+-]?)$/.exec(T);if(q===null){$[j]=T.replace(/^["']|["']$/g,"");continue}let B=q[1]===">",X=[];while(G+1<V.length){let D=V[G+1];if(D.trim()!==""&&!/^\s/.test(D))break;X.push(D.replace(/^\s+/,"")),G++}while(X.length>0&&X[X.length-1]==="")X.pop();$[j]=B?X.join(" ").replace(/\s+/g," ").trim():X.join(`
6
6
  `)}return{fm:$,body:Y}}function t(J){let Q=J.replace(/\s+/g," ").trim();if(Q.length<=_)return Q;let Z=Q.slice(0,_-1),z=Z.lastIndexOf(" ");return`${(z>_/2?Z.slice(0,z):Z).replace(/[,;:.]$/,"")}\u2026`}function e(J,Q){let Z;try{Z=w(J,"utf8")}catch(W){return{invalid:{path:J,reason:`unreadable: ${W.message}`}}}let z=a(Z);if(!z)return{invalid:{path:J,reason:"missing frontmatter block"}};let Y=r(J),$=u(o(z.fm,Z),p(Y),"lenient");if($.errors.length>0)return{invalid:{path:J,reason:$.errors.join("; ")}};let V=$.meta.description,G=S(J);return{skill:{name:$.meta.name,description:t(V),fullDescription:V,version:$.meta.version||"0.0.0",path:J,dir:Y,body:z.body,scope:Q,mtimeMs:G.mtimeMs,size:G.size,...$.meta.license!==void 0?{license:$.meta.license}:{},...$.meta.compatibility!==void 0?{compatibility:$.meta.compatibility}:{},metadata:$.meta.metadata,allowedTools:$.meta.allowedTools},warnings:$.warnings}}function g(J){return J+".usage.json"}function v(J){let Q=g(J);if(!F(Q))return;try{let Z=JSON.parse(w(Q,"utf8"));return{viewCount:typeof Z.viewCount==="number"?Z.viewCount:0,lastViewedAt:typeof Z.lastViewedAt==="number"?Z.lastViewedAt:0}}catch{return}}function JJ(J,Q){let Z=g(J),z=Z+".tmp";l(z,JSON.stringify(Q,null,2)),d(z,Z)}function XJ(J,Q,Z){let z=Q&&Q.viewCount>0?Q.lastViewedAt:J.mtimeMs;return Z-z>n?"stale":"active"}class QJ{cwd;projectDir;globalDir;maxDepth;cache=new Map;manifest=new Map;constructor(J,Q={}){this.cwd=J;this.projectDir=A(J,Q.projectDir??K(".rovecode","skills")),this.globalDir=Q.globalDir===null?null:A(Q.globalDir??K(I(),"skills")),this.maxDepth=Q.maxDepth??3,this.walkProject=Q.walkProject!==!1,this.extraDirs=(Q.extraDirs??[]).map(({dir:Z,scope:z})=>[A(J,Z),z])}extraDirs;walkProject;dirs(){let J=this.walkProject?[[this.projectDir,"project"]]:[];if(this.globalDir&&F(this.globalDir))J.push([this.globalDir,"global"]);for(let[Q,Z]of this.extraDirs)if(F(Q))J.push([Q,Z]);return J}find(J,Q=J,Z=0){let z;try{z=m(Q,{withFileTypes:!0})}catch{return[]}if(z.some(($)=>$.isFile()&&$.name===N))return[K(Q,N)];let Y=[];for(let $ of z){let V=K(Q,$.name);if($.isFile()&&$.name===N)Y.push(V);else if($.isDirectory()&&Z<this.maxDepth&&!s[$.name]&&!$.name.startsWith("."))Y.push(...this.find(J,V,Z+1))}return Y}scan(){let J=new Map,Q=new Map;for(let[$,V]of this.dirs())for(let G of this.find($))try{let W=S(G);if(J.set(G,`${W.mtimeMs}:${W.size}`),!Q.has(G))Q.set(G,V)}catch{}let Z={added:[],removed:[],changed:[]};for(let[$,V]of J)if(!this.manifest.has($))Z.added.push($);else if(this.manifest.get($)!==V)Z.changed.push($);for(let $ of this.manifest.keys())if(!J.has($))Z.removed.push($);let z=[],Y=[];for(let $ of[...Z.added,...Z.changed]){let V=Q.get($)??($.startsWith(this.projectDir)?"project":"global"),G=e($,V);if("skill"in G){this.cache.set($,G.skill);for(let W of G.warnings)Y.push({path:$,reason:W})}else this.cache.delete($),z.push(G.invalid)}for(let $ of Z.removed)this.cache.delete($);return this.manifest=J,{skills:this.list(),invalid:z,warnings:Y,changes:Z}}list(){let J=new Map;for(let Q of this.cache.values()){let Z=J.get(Q.name);if(!Z||Z.scope==="global"&&Q.scope==="project")J.set(Q.name,Q)}return[...J.values()].sort((Q,Z)=>Q.name.localeCompare(Z.name))}get(J){return this.list().find((Q)=>Q.name===J)}usage(J){let Q=this.get(J);return Q?v(Q.path):void 0}bumpUsage(J,Q=Date.now()){let z={viewCount:(v(J.path)?.viewCount??0)+1,lastViewedAt:Q};return JJ(J.path,z),z}}var N="SKILL.md",i,qJ=(J)=>i.some((Q)=>J.endsWith(Q)),_=60,n=7776000000,s;var ZJ=E(()=>{c();x();i=[".usage.json",".versions.jsonl"],s={node_modules:!0,".git":!0}});
7
- export{b as mh,u as nh,x as oh,N as ph,qJ as qh,UJ as rh,a as sh,XJ as th,QJ as uh,ZJ as vh};
7
+ export{b as Ye,u as Ze,x as _e,N as $e,qJ as af,UJ as bf,a as cf,XJ as df,QJ as ef,ZJ as ff};
@@ -3,4 +3,4 @@ import{wn as w}from"./main-qsevpgsv.js";import{dlopen as a,FFIType as J,ptr as U
3
3
  stderr:
4
4
  ${Q}`:"")).slice(0,Xq)}function Zq(){if(K!==null)return K;if(process.platform!=="win32")return K="bash";let q="C:/Program Files/Git/bin/bash.exe";return K=Yq(q)?q:"bash",K}function c(q){return q.replace(/\u0000/g,"").trim().slice(0,200)}async function g(q,Q,z){let V={code:-1,stdout:"",stderr:`probe timed out after ${z}ms`},W,Y=new Promise(($)=>{W=setTimeout(()=>$(V),z)});try{let $=await Promise.race([q(Q,{signal:AbortSignal.timeout(z)}),Y]);return{r:$,timedOut:$===V}}finally{clearTimeout(W)}}async function d(q,Q=C,z=process.platform,V={}){let W=V.timeoutMs??Pq;switch(q){case"direct":return{rung:q,available:!0,detail:"always available \u2014 today's in-process bash (blocklist only, NOT a sandbox)"};case"wsl":{if(z!=="win32")return{rung:q,available:!1,detail:`wsl rung requires Windows wsl.exe (platform is ${z})`};let Y="wsl.exe --exec bash -c true",{r:$,timedOut:H}=await g(Q,["wsl.exe","--exec","bash","-c","true"],W);if(H)return{rung:q,available:!1,detail:`wsl trial (${Y}) timed out after ${W}ms \u2014 wrapper did not answer (a cold WSL utility-VM boot exceeds this cap); warm it with the same command and reconfigure`};return $.code===0?{rung:q,available:!0,detail:`wsl trial (${Y}) ok`}:{rung:q,available:!1,detail:`wsl trial (${Y}) exited ${$.code}: ${c($.stderr||$.stdout)||"no output"}`}}case"docker":{let Y=V.dockerImage??u,$=`docker run --rm ${Y} bash -c true`,{r:H,timedOut:Z}=await g(Q,["docker","run","--rm",Y,"bash","-c","true"],W);if(Z)return{rung:q,available:!1,detail:`docker trial (${$}) timed out after ${W}ms \u2014 daemon wedged or pulling the image; pre-pull it and retry`};return H.code===0?{rung:q,available:!0,detail:`docker trial (${$}) ok`}:{rung:q,available:!1,detail:`docker trial (${$}) exited ${H.code}: ${c(H.stderr||H.stdout)||"no output"}`}}}}function Cq(q=C,Q=process.platform,z={}){return Promise.all($q.map((V)=>d(V,q,Q,z)))}function l(q){return{rung:"direct",async run(Q,z,V,W){let Y=await q([Zq(),"-c",Q],{cwd:z,signal:V,...W?{observe:W}:{}});return{code:Y.code,text:_(Y.stdout,Y.stderr)}}}}function Gq(q){return{rung:"wsl",async run(Q,z,V,W){let Y=await q(["wsl.exe","--cd",z,"--exec","bash","-c",Q],{cwd:z,signal:V,...W?{observe:W}:{}});return{code:Y.code,text:_(Y.stdout,Y.stderr)}}}}function Bq(q,Q){return{rung:"docker",async run(z,V,W,Y){let $=["docker","run","--rm","-v",`${V}:/workspace`,"-w","/workspace",Q,"bash","-c",z],H=await q($,{cwd:V,signal:W,...Y?{observe:Y}:{}});return{code:H.code,text:_(H.stdout,H.stderr)}}}}async function Nq(q,Q={}){let z=Q.runner??C,V=await d(q,z,Q.platform??process.platform,{dockerImage:Q.dockerImage});if(!V.available)throw new A(q,V.detail);switch(q){case"direct":return l(z);case"wsl":return Gq(z);case"docker":return Bq(z,Q.dockerImage??u)}}async function Aq(q,Q){x=q;try{return L=await Nq(q,Q),O=null,L}catch(z){throw O=z instanceof A?z.detail:z instanceof Error?z.message:String(z),z}}function Sq(){if(L?.rung===x)return L;if(x==="direct")return L=l(C);throw new A(x,O??`configureExecutor('${x}') has not succeeded; the seam refuses to substitute another rung`)}function fq(){L=null,x="direct",O=null}var $q,Wq=500,Hq="[output truncated: process tree terminated on abort]",C=async(q,Q)=>{let z=Q.signal,{treeKill:V,grouped:W}=Jq(process.platform,z!==void 0);if((V||W)&&z?.aborted)return{code:143,stdout:"",stderr:"aborted before spawn"};let Y,$=null,H=!1,Z;try{let X=Bun.spawn([...q],{cwd:Q.cwd,signal:V||W?void 0:z,stdout:"pipe",stderr:"pipe",...W?T(process.platform):{}});Q.observe?.onSpawn?.(X.pid);let G=Q.observe,B=b(X.stdout,G?.onChunk?(P)=>G.onChunk("stdout",P):void 0),S=b(X.stderr,G?.onChunk?(P)=>G.onChunk("stderr",P):void 0),k=Promise.all([B.done,S.done,X.exited]).then(()=>"done"),v,p=new Promise((P)=>{v=()=>P("grace")});if(z){if(V){if($=I(),$&&!$.assign(X.pid))$=null}Y=()=>{let P=X.exitCode===null;if(H=V||W,V){if($?.terminate(),P)try{Bun.spawn(["taskkill","/T","/F","/PID",String(X.pid)],{stdout:"ignore",stderr:"ignore"})}catch{}}if(W){if(R(X.pid,"SIGTERM"),P)try{X.kill("SIGTERM")}catch{}}Z=setTimeout(v,Wq)},z.addEventListener("abort",Y,{once:!0}),k.then(()=>{if(Y)z.removeEventListener("abort",Y)},()=>{})}let j=await Promise.race([k,p]);if(j==="grace"&&W)R(X.pid,"SIGKILL");if(j==="grace")B.cancel(),S.cancel();let i=H||j==="grace"?143:await X.exited,f=S.text();if(j==="grace")f+=(f?`
5
5
  `:"")+Hq;let y={code:i,stdout:B.text(),stderr:f};if(V)y.treeKill=$?"job":"taskkill-only";return y}catch(X){return{code:-1,stdout:"",stderr:`spawn failed: ${X instanceof Error?X.message:String(X)}`}}finally{if(clearTimeout(Z),H)$?.terminate();else $?.release();if(Y)z?.removeEventListener("abort",Y)}},Xq=1e4,K=null,Pq=500,A,u="debian:stable-slim",L=null,x="direct",O=null;var xq=w(()=>{h();F();$q=["direct","wsl","docker"];A=class A extends Error{rung;detail;constructor(q,Q){super(`executor rung '${q}' is unavailable: ${Q}. `+"Refusing to fall back down the ladder \u2014 pick an available rung explicitly "+`(probeLadder() reports availability) or make '${q}' usable and retry.`);this.name="RungUnavailableError",this.rung=q,this.detail=Q}}});
6
- export{I as Nh,h as Oh,T as Ph,R as Qh,F as Rh,$q as Sh,Wq as Th,Hq as Uh,Jq as Vh,C as Wh,Xq as Xh,Pq as Yh,d as Zh,Cq as _h,A as $h,u as ai,Nq as bi,Aq as ci,Sq as di,fq as ei,xq as fi};
6
+ export{I as $h,h as ai,T as bi,R as ci,F as di,$q as ei,Wq as fi,Hq as gi,Jq as hi,C as ii,Xq as ji,Pq as ki,d as li,Cq as mi,A as ni,u as oi,Nq as pi,Aq as qi,Sq as ri,fq as si,xq as ti};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
2
  var N=8,O=80,P=2000,S="ask_user unavailable: no interactive user in this session (headless run/serve/acp) \u2014 proceed with your best judgment or stop",U="ask_user aborted",V="user declined to answer";function L(B){let j=B&&typeof B==="object"?B:{},C=typeof j.question==="string"?j.question.trim():"";if(C==="")return"question must be a non-empty string";if(C.length>2000)return`question too long (${C.length} chars, max 2000)`;let z;if(j.options!==void 0&&j.options!==null){if(!Array.isArray(j.options))return"options must be an array of strings";if(j.options.length>8)return`too many options (${j.options.length}, max 8)`;z=[];for(let G of j.options){if(typeof G!=="string"||G.trim()==="")return"every option must be a non-empty string";let I=G.trim();if(I.length>80)return`option too long (${I.length} chars, max 80): ${I.slice(0,40)}\u2026`;z.push(I)}if(z.length===0)z=void 0}if(j.allowFreeText!==void 0&&typeof j.allowFreeText!=="boolean")return"allowFreeText must be a boolean";let E=j.allowFreeText!==!1;if(!z&&!E)return"nothing to answer with: provide options or allow free text";return{question:C,...z?{options:z}:{},allowFreeText:E}}function M(B,j){let C=typeof B.text==="string"?B.text.trim():"";if(C!=="")return{ok:!0,output:`answer: ${C}`,data:{text:C}};let z=j.options??[];if(typeof B.choice==="number"&&Number.isInteger(B.choice)&&B.choice>=0&&B.choice<z.length){let E=z[B.choice];return{ok:!0,output:`answer: ${E}`,data:{choice:B.choice,label:E}}}return{ok:!1,output:"ask_user failed: the surface returned an unusable answer"}}function W(B){return{schema:{name:"ask_user",description:"Ask the user ONE clarifying question and wait for the answer. Use it when instructions are "+"ambiguous, a decision has real consequences, or you must pick between approaches \u2014 do not guess. "+`Give up to ${"8"} short options (\u2264${"80"} chars each); the user may also type a free-text answer unless allowFreeText is false. If you recommend an option, list it first and append `+'"(recommended)"; never add an "Other" option \u2014 the free-text entry covers it. The result is '+"`answer: <chosen option or typed text>`. A declined or aborted question, or a session with no interactive user (headless run/serve/acp), returns an error: then proceed with your best judgment or stop.",args:{type:"object",properties:{question:{type:"string",description:"the complete question \u2014 clear, specific, one decision"},options:{type:"array",items:{type:"string"},maxItems:8,description:`up to ${"8"} answer choices, \u2264${"80"} chars each (recommended one first)`},allowFreeText:{type:"boolean",description:"also accept a typed free-form answer (default true)"}},required:["question"]}},kind:"read",sequential:!0,async execute(j,C){let z=L(j);if(typeof z==="string")return{ok:!1,output:`ask_user failed: ${z}`};let E=B();if(!E)return{ok:!1,output:"ask_user unavailable: no interactive user in this session (headless run/serve/acp) \u2014 proceed with your best judgment or stop"};if(C.signal.aborted)return{ok:!1,output:"ask_user aborted"};let G,I=new Promise((H)=>{G=()=>H("aborted"),C.signal.addEventListener("abort",G,{once:!0})});try{let H=new Promise((K)=>K(E(z,C.signal))),J=await Promise.race([H.then((K)=>({answer:K})),I]);if(J==="aborted"||C.signal.aborted)return{ok:!1,output:"ask_user aborted"};if(J.answer===null)return{ok:!1,output:"user declined to answer"};return M(J.answer,z)}catch(H){return{ok:!1,output:`ask_user failed: ${H instanceof Error?H.message:String(H)}`}}finally{if(G)C.signal.removeEventListener("abort",G)}}}}
3
- export{N as Df,O as Ef,P as Ff,S as Gf,U as Hf,V as If,L as Jf,W as Kf};
3
+ export{N as tg,O as ug,P as vg,S as wg,U as xg,V as yg,L as zg,W as Ag};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
2
  import{wn as j}from"./main-qsevpgsv.js";var k,p=(c)=>typeof c==="string"&&k.includes(c),q=()=>({garbage:0,scratch:{}});var m=j(()=>{k=["claude","codex","opencode","agy"]});
3
- export{k as ue,p as ve,q as we,m as xe};
3
+ export{k as Ue,p as Ve,q as We,m as Xe};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{nl as c,rl as IQ}from"./main-rebtt91r.js";import{Jl as RJ,Ll as EJ,Sl as YQ}from"./main-6h9x282m.js";import{wn as f,xn as _Q}from"./main-qsevpgsv.js";function PJ(J,Q){let Z=J.trim(),z=Z.indexOf("/");if(z<=0)return{provider:Q,model:Z};return{provider:Z.slice(0,z),model:Z.slice(z+1)}}function sJ(J,Q){return J.split(",").map((Z)=>Z.trim()).filter(Boolean).map((Z)=>PJ(Z,Q))}function TQ(J,Q=process.env){let Z={};for(let z of t){let X=Q[tJ[z]];if(X&&X.trim().length>0){let G=sJ(X,J.provider);if(G.length>0)Z[z]=G}}return{...Z,default:Z.default??[J]}}function eJ(J){let Q=/^HTTP (\d{3})\b/.exec(J??"");if(Q){let Z=Number(Q[1]);return{status:Z,retryable:Z===429||Z>=500&&Z<600}}if((J??"").startsWith("config: "))return{retryable:!1};return{retryable:!0}}function jJ(J){return e.get(J)}function xQ(J){let Q=new Map;for(let G of t){let W=J.roles[G];if(!W)continue;let B=Array.isArray(W)?W:[W];if(B.length>0)Q.set(G,B)}let Z=Q.get("default");if(!Z)throw Error("router: roles.default must contain at least one ModelRef");let z=(G)=>Q.get(G)??Z,X=(G)=>{let W=null;for(let K of t){let V=Q.get(K);if(!V)continue;let Y=V.findIndex(($)=>JQ($,G));if(Y===0)return{key:K,chain:V,index:0};if(Y>0&&W===null)W={key:K,chain:V,index:Y}}if(W)return W;let B=J.looseFallback===!0?[G,...Z]:[G];return{key:QQ(G),chain:B,index:0}};return{chain:z,resolve(G,W){let K=z(G)[0];if(W!==void 0)return typeof W==="string"?PJ(W,K.provider):W;return K},wrap(G){let W=J.sticky??!0,B=new Map;return async function*(K,V,Y){let{key:$,chain:q,index:j}=X(K),P=W?Math.min(Math.max(j,B.get($)??0),q.length-1):j,N=null;for(let O=P;O<q.length;O++){let R=q[O],w=null,E=!1;try{for await(let S of G(R,V,Y))if(S.type==="turn")w=S.turn;else{if(S.type==="text_delta"||S.type==="reasoning_delta")E=!0;yield S}}catch(S){w=s(S instanceof Error?S.message:String(S))}let b=w??s("stream ended without a terminal turn"),T=Y?.signal?.aborted===!0;if(b.stopReason!=="error"||T||E||!eJ(b.error).retryable||q.length===1){e.set(b,R),yield{type:"turn",turn:b};return}N=b;let h=O+1<q.length?q[O+1]:null;if(W&&h!==null)B.set($,O+1);J.onNote?.({chain:$,from:R,to:h,reason:b.error??"error"})}if(W)B.delete($);let U=q.length-P,M=s(`model chain '${$}' exhausted (${U} candidate${U===1?"":"s"} failed); last: ${N?.error??"unknown error"}`);e.set(M,q[q.length-1]),yield{type:"turn",turn:M}}}}}var t,tJ,e,JQ=(J,Q)=>J.provider===Q.provider&&J.model===Q.model,QQ=(J)=>`${J.provider}/${J.model}`,ZQ=()=>({input:0,output:0}),s=(J)=>({parts:[],stopReason:"error",usage:ZQ(),error:J});var MJ=f(()=>{t=["default","smol","plan","commit","task"];tJ={default:"ROVECODE_MODEL_DEFAULT",smol:"ROVECODE_MODEL_SMOL",plan:"ROVECODE_MODEL_PLAN",commit:"ROVECODE_MODEL_COMMIT",task:"ROVECODE_MODEL_TASK"};e=new WeakMap});function k(J){return Math.ceil(J.length/4)}function DJ(J,Q){let Z=[...J].sort((Y,$)=>$.priority-Y.priority),z=Z.filter((Y)=>Y.name!=="history"),X=[],G=[...z],W=Z.find((Y)=>Y.name==="history"),B=W?.tokens??0;while(G.length>0&&G.reduce((Y,$)=>Y+$.tokens,0)+B>Q){let Y=G.pop();X.push(Y)}let K=G.reduce((Y,$)=>Y+$.tokens,0)+B,V=[...G];if(W)V.push(W);return{chunks:V,dropped:X,totalTokens:K,overBudget:K>Q}}function NJ(J,Q){if(J.reduce((W,B)=>W+B.tokens,0)<=Q*0.8)return{keep:J,summarize:[]};let z=Math.floor(Q/2),X=0,G=J.length;for(let W=J.length-1;W>=0;W--){if(X+=J[W].tokens,X>z){G=W+1;break}G=W}return{keep:J.slice(G),summarize:J.slice(0,G)}}var JJ=()=>{};import{randomUUID as CJ}from"crypto";function mQ(J){let Q=(J??"").trim().toLowerCase();if(Q==="")return;if(LJ.includes(Q))return Q;if(!_J.has(Q))_J.add(Q),console.error(`rovecode: unknown ROVECODE_COMPACTION "${(J??"").trim()}" \u2014 using ${QJ} (known: ${LJ.join(", ")})`);return}function SJ(J,Q,Z){if(Z)return"emergency";return J>Q.contextBudgetTokens*Q.compactionThreshold?"speculative":null}function UJ(J){if(!J||zQ.some((Z)=>Z.test(J)))return!1;let Q=/(?:^|last: )HTTP (\d{3})\b/.exec(J)?.[1];if(Q==="413")return!0;if(Q==="429"||Q?.startsWith("5"))return!1;return XQ.some((Z)=>Z.test(J))}function KQ(J,Q,Z){if(Z==="speculative")return J.contextBudgetTokens;return Math.max(1,Math.floor(Math.min(J.contextBudgetTokens,Q)/2))}function WQ(J,Q){if(J==="keep-window")return"keep-window";if(J==="provider-native"&&Q.native)return"provider-native";if(Q.summarize)return"head-summarize";return Q.trigger==="emergency"?"keep-window":null}function ZJ(J,Q,Z){let z=Q.compactionStrategy??QJ,X=WQ(z,Z);if(!X)return null;let G=($)=>k(Z.tokenText($)),W=J.reduce(($,q)=>$+G(q),0),B=KQ(Q,W,Z.trigger),K={strategy:X,tokensBefore:W,budgetTokens:B,...X!==z?{fallbackFrom:z}:{}};if(X==="provider-native")return{...K,keep:J,drop:[],summaryNeeded:!1};if(X==="keep-window"){let $=Z.trigger==="emergency"?0:Q.compactionKeepTurns??$Q;return{...K,...BQ(J,G,B,$),summaryNeeded:!1}}let V=NJ(J.map(($)=>({id:$.id,tokens:G($),text:Z.tokenText($)})),B),Y=new Set(V.keep.map(($)=>$.id));if(Y.size===0&&J.length>0){let $=J.length-1;while($>0&&J[$].role==="tool")$--;for(let q of J.slice($))Y.add(q.id)}return{...K,keep:J.filter(($)=>Y.has($.id)),drop:J.filter(($)=>!Y.has($.id)),summaryNeeded:!0}}function BQ(J,Q,Z,z){let X=Math.floor(Z/2),G=(Y)=>Y.reduce(($,q)=>$+Q(q),0),W=J.flatMap((Y,$)=>Y.role==="user"?[$]:[]),B=Math.max(0,W.length-1-Math.max(0,z)),K=W.length>0?W[B]:0;while(G(J.slice(K))>X&&B<W.length-1)K=W[++B];let V=W.at(-1);if(V!==void 0&&K===V&&G(J.slice(K))>X){let Y=V+1;while(Y<J.length&&Q(J[V])+G(J.slice(Y))>X){let $=OJ(J,Y+1);if($<=Y||$>=J.length)break;Y=$}return{keep:[J[V],...J.slice(Y)],drop:[...J.slice(0,V),...J.slice(V+1,Y)]}}if(W.length===0)while(G(J.slice(K))>X){let Y=OJ(J,K+1);if(Y<=K||Y>=J.length)break;K=Y}return{keep:J.slice(K),drop:J.slice(0,K)}}function OJ(J,Q){let Z=Q;while(Z<J.length&&J[Z].role==="tool")Z++;return Z}async function $J(J,Q,Z,z){let X=Q.fallbackFrom?{fallbackFrom:Q.fallbackFrom}:{};if(Q.strategy==="provider-native"){let B=null;if(z.native)try{B=await z.native(J,{model:z.model,budgetTokens:Q.budgetTokens,trigger:z.trigger,signal:z.signal})}catch{B=null}if(B)return{history:B,strategy:"provider-native",...X};let K=ZJ(J,{...Z,compactionStrategy:QJ},{...z,native:void 0});if(!K)return null;let V=await $J(J,K,Z,{...z,native:void 0});return V?{...V,fallbackFrom:"provider-native"}:null}if(Q.strategy==="keep-window"){if(Q.drop.length===0)return null;let B=Q.drop.reduce((V,Y)=>V+k(z.tokenText(Y)),0);return{history:[{id:CJ(),role:"system",parts:[{kind:"text",text:`[context compacted (keep-window): ${Q.drop.length} earlier messages, ~${B} tokens, removed from the working context]`}],parentId:Q.keep[0]?.id??null,createdAt:Date.now()},...Q.keep],strategy:"keep-window",...X}}if(!z.summarize)return null;let G=await z.summarize(Q.drop.map((B)=>z.tokenText(B)));return{history:[{id:CJ(),role:"system",parts:[{kind:"text",text:`Summary of earlier conversation:
2
+ import{Nl as c,Rl as IQ}from"./main-ggcn7rd7.js";import{dm as RJ,fm as EJ,mm as YQ}from"./main-prxxs70n.js";import{wn as f,xn as _Q}from"./main-qsevpgsv.js";function PJ(J,Q){let Z=J.trim(),z=Z.indexOf("/");if(z<=0)return{provider:Q,model:Z};return{provider:Z.slice(0,z),model:Z.slice(z+1)}}function sJ(J,Q){return J.split(",").map((Z)=>Z.trim()).filter(Boolean).map((Z)=>PJ(Z,Q))}function TQ(J,Q=process.env){let Z={};for(let z of t){let X=Q[tJ[z]];if(X&&X.trim().length>0){let G=sJ(X,J.provider);if(G.length>0)Z[z]=G}}return{...Z,default:Z.default??[J]}}function eJ(J){let Q=/^HTTP (\d{3})\b/.exec(J??"");if(Q){let Z=Number(Q[1]);return{status:Z,retryable:Z===429||Z>=500&&Z<600}}if((J??"").startsWith("config: "))return{retryable:!1};return{retryable:!0}}function jJ(J){return e.get(J)}function xQ(J){let Q=new Map;for(let G of t){let W=J.roles[G];if(!W)continue;let B=Array.isArray(W)?W:[W];if(B.length>0)Q.set(G,B)}let Z=Q.get("default");if(!Z)throw Error("router: roles.default must contain at least one ModelRef");let z=(G)=>Q.get(G)??Z,X=(G)=>{let W=null;for(let K of t){let V=Q.get(K);if(!V)continue;let Y=V.findIndex(($)=>JQ($,G));if(Y===0)return{key:K,chain:V,index:0};if(Y>0&&W===null)W={key:K,chain:V,index:Y}}if(W)return W;let B=J.looseFallback===!0?[G,...Z]:[G];return{key:QQ(G),chain:B,index:0}};return{chain:z,resolve(G,W){let K=z(G)[0];if(W!==void 0)return typeof W==="string"?PJ(W,K.provider):W;return K},wrap(G){let W=J.sticky??!0,B=new Map;return async function*(K,V,Y){let{key:$,chain:q,index:j}=X(K),P=W?Math.min(Math.max(j,B.get($)??0),q.length-1):j,N=null;for(let O=P;O<q.length;O++){let R=q[O],w=null,E=!1;try{for await(let S of G(R,V,Y))if(S.type==="turn")w=S.turn;else{if(S.type==="text_delta"||S.type==="reasoning_delta")E=!0;yield S}}catch(S){w=s(S instanceof Error?S.message:String(S))}let b=w??s("stream ended without a terminal turn"),T=Y?.signal?.aborted===!0;if(b.stopReason!=="error"||T||E||!eJ(b.error).retryable||q.length===1){e.set(b,R),yield{type:"turn",turn:b};return}N=b;let h=O+1<q.length?q[O+1]:null;if(W&&h!==null)B.set($,O+1);J.onNote?.({chain:$,from:R,to:h,reason:b.error??"error"})}if(W)B.delete($);let U=q.length-P,M=s(`model chain '${$}' exhausted (${U} candidate${U===1?"":"s"} failed); last: ${N?.error??"unknown error"}`);e.set(M,q[q.length-1]),yield{type:"turn",turn:M}}}}}var t,tJ,e,JQ=(J,Q)=>J.provider===Q.provider&&J.model===Q.model,QQ=(J)=>`${J.provider}/${J.model}`,ZQ=()=>({input:0,output:0}),s=(J)=>({parts:[],stopReason:"error",usage:ZQ(),error:J});var MJ=f(()=>{t=["default","smol","plan","commit","task"];tJ={default:"ROVECODE_MODEL_DEFAULT",smol:"ROVECODE_MODEL_SMOL",plan:"ROVECODE_MODEL_PLAN",commit:"ROVECODE_MODEL_COMMIT",task:"ROVECODE_MODEL_TASK"};e=new WeakMap});function k(J){return Math.ceil(J.length/4)}function DJ(J,Q){let Z=[...J].sort((Y,$)=>$.priority-Y.priority),z=Z.filter((Y)=>Y.name!=="history"),X=[],G=[...z],W=Z.find((Y)=>Y.name==="history"),B=W?.tokens??0;while(G.length>0&&G.reduce((Y,$)=>Y+$.tokens,0)+B>Q){let Y=G.pop();X.push(Y)}let K=G.reduce((Y,$)=>Y+$.tokens,0)+B,V=[...G];if(W)V.push(W);return{chunks:V,dropped:X,totalTokens:K,overBudget:K>Q}}function NJ(J,Q){if(J.reduce((W,B)=>W+B.tokens,0)<=Q*0.8)return{keep:J,summarize:[]};let z=Math.floor(Q/2),X=0,G=J.length;for(let W=J.length-1;W>=0;W--){if(X+=J[W].tokens,X>z){G=W+1;break}G=W}return{keep:J.slice(G),summarize:J.slice(0,G)}}var JJ=()=>{};import{randomUUID as CJ}from"crypto";function mQ(J){let Q=(J??"").trim().toLowerCase();if(Q==="")return;if(LJ.includes(Q))return Q;if(!_J.has(Q))_J.add(Q),console.error(`rovecode: unknown ROVECODE_COMPACTION "${(J??"").trim()}" \u2014 using ${QJ} (known: ${LJ.join(", ")})`);return}function SJ(J,Q,Z){if(Z)return"emergency";return J>Q.contextBudgetTokens*Q.compactionThreshold?"speculative":null}function UJ(J){if(!J||zQ.some((Z)=>Z.test(J)))return!1;let Q=/(?:^|last: )HTTP (\d{3})\b/.exec(J)?.[1];if(Q==="413")return!0;if(Q==="429"||Q?.startsWith("5"))return!1;return XQ.some((Z)=>Z.test(J))}function KQ(J,Q,Z){if(Z==="speculative")return J.contextBudgetTokens;return Math.max(1,Math.floor(Math.min(J.contextBudgetTokens,Q)/2))}function WQ(J,Q){if(J==="keep-window")return"keep-window";if(J==="provider-native"&&Q.native)return"provider-native";if(Q.summarize)return"head-summarize";return Q.trigger==="emergency"?"keep-window":null}function ZJ(J,Q,Z){let z=Q.compactionStrategy??QJ,X=WQ(z,Z);if(!X)return null;let G=($)=>k(Z.tokenText($)),W=J.reduce(($,q)=>$+G(q),0),B=KQ(Q,W,Z.trigger),K={strategy:X,tokensBefore:W,budgetTokens:B,...X!==z?{fallbackFrom:z}:{}};if(X==="provider-native")return{...K,keep:J,drop:[],summaryNeeded:!1};if(X==="keep-window"){let $=Z.trigger==="emergency"?0:Q.compactionKeepTurns??$Q;return{...K,...BQ(J,G,B,$),summaryNeeded:!1}}let V=NJ(J.map(($)=>({id:$.id,tokens:G($),text:Z.tokenText($)})),B),Y=new Set(V.keep.map(($)=>$.id));if(Y.size===0&&J.length>0){let $=J.length-1;while($>0&&J[$].role==="tool")$--;for(let q of J.slice($))Y.add(q.id)}return{...K,keep:J.filter(($)=>Y.has($.id)),drop:J.filter(($)=>!Y.has($.id)),summaryNeeded:!0}}function BQ(J,Q,Z,z){let X=Math.floor(Z/2),G=(Y)=>Y.reduce(($,q)=>$+Q(q),0),W=J.flatMap((Y,$)=>Y.role==="user"?[$]:[]),B=Math.max(0,W.length-1-Math.max(0,z)),K=W.length>0?W[B]:0;while(G(J.slice(K))>X&&B<W.length-1)K=W[++B];let V=W.at(-1);if(V!==void 0&&K===V&&G(J.slice(K))>X){let Y=V+1;while(Y<J.length&&Q(J[V])+G(J.slice(Y))>X){let $=OJ(J,Y+1);if($<=Y||$>=J.length)break;Y=$}return{keep:[J[V],...J.slice(Y)],drop:[...J.slice(0,V),...J.slice(V+1,Y)]}}if(W.length===0)while(G(J.slice(K))>X){let Y=OJ(J,K+1);if(Y<=K||Y>=J.length)break;K=Y}return{keep:J.slice(K),drop:J.slice(0,K)}}function OJ(J,Q){let Z=Q;while(Z<J.length&&J[Z].role==="tool")Z++;return Z}async function $J(J,Q,Z,z){let X=Q.fallbackFrom?{fallbackFrom:Q.fallbackFrom}:{};if(Q.strategy==="provider-native"){let B=null;if(z.native)try{B=await z.native(J,{model:z.model,budgetTokens:Q.budgetTokens,trigger:z.trigger,signal:z.signal})}catch{B=null}if(B)return{history:B,strategy:"provider-native",...X};let K=ZJ(J,{...Z,compactionStrategy:QJ},{...z,native:void 0});if(!K)return null;let V=await $J(J,K,Z,{...z,native:void 0});return V?{...V,fallbackFrom:"provider-native"}:null}if(Q.strategy==="keep-window"){if(Q.drop.length===0)return null;let B=Q.drop.reduce((V,Y)=>V+k(z.tokenText(Y)),0);return{history:[{id:CJ(),role:"system",parts:[{kind:"text",text:`[context compacted (keep-window): ${Q.drop.length} earlier messages, ~${B} tokens, removed from the working context]`}],parentId:Q.keep[0]?.id??null,createdAt:Date.now()},...Q.keep],strategy:"keep-window",...X}}if(!z.summarize)return null;let G=await z.summarize(Q.drop.map((B)=>z.tokenText(B)));return{history:[{id:CJ(),role:"system",parts:[{kind:"text",text:`Summary of earlier conversation:
3
3
  ${G}`}],parentId:J[0]?.id??null,createdAt:Date.now()},...Q.keep],strategy:"head-summarize",...X}}var LJ,QJ="head-summarize",$Q=2,_J,XQ,zQ;var IJ=f(()=>{JJ();LJ=["head-summarize","keep-window","provider-native"],_J=new Set;XQ=[/prompt is too long/i,/request_too_large/i,/input is too long for requested model/i,/exceeds the context window/i,/maximum context length/i,/context[_ ]length[_ ]exceeded/i,/input token count.*exceeds the maximum/i,/tokens in request more than max tokens allowed/i,/maximum prompt length is \d+/i,/reduce the length of the messages/i,/request entity too large/i,/model_context_window_exceeded/i,/too many tokens/i,/token limit exceeded/i,/exceeds the available context size/i,/greater than the context length/i],zQ=[/rate limit/i,/too many requests/i,/throttling/i,/service unavailable/i]});import{existsSync as GQ,mkdirSync as HQ,readFileSync as bJ,writeFileSync as qQ}from"fs";import{join as L}from"path";function MQ(J,Q){if(Q(L(J,"bun.lock"))||Q(L(J,"bun.lockb")))return{run:"bun run",from:"bun.lock"};if(Q(L(J,"pnpm-lock.yaml")))return{run:"pnpm run",from:"pnpm-lock.yaml"};if(Q(L(J,"yarn.lock")))return{run:"yarn",from:"yarn.lock"};if(Q(L(J,"package-lock.json")))return{run:"npm run",from:"package-lock.json"};return{run:"npm run",from:"no lockfile (npm assumed)"}}function wJ(J,Q={}){let Z=Q.exists??GQ,z=Q.read??(($)=>bJ($,"utf8")),X=EJ(J),G={...X.user,...X.project};if(G.verify===!1)return{source:"none",commands:[],reason:"settings.json verify: false \u2014 the gate is off by choice, nothing is inferred",refused:[]};if(G.verify!==void 0){let $=Array.isArray(G.verify)?G.verify:[G.verify],q=X.project.verify!==void 0?X.projectPath:RJ("user",J);return{source:"settings",commands:$,reason:`${q} verify`,refused:[]}}let W=[],B=[],K=[],V=L(J,"package.json");if(Z(V)){let $={},q=!0;try{let P=JSON.parse(z(V)).scripts;if(P!==void 0&&(typeof P!=="object"||P===null||Array.isArray(P)))K.push('package.json: "scripts" is not an object \u2014 nothing inferred from it'),q=!1;else if(P){for(let[N,U]of Object.entries(P))if(typeof U==="string")$[N]=U}}catch{K.push("package.json is not valid JSON \u2014 nothing inferred from it"),q=!1,$={}}if(q){let j=MQ(J,Z),P=(M)=>$[M].trim(),N=(M)=>`set \`"verify": "${j.run} ${M}"\` in .rovecode/settings.json`,U=(M,O,R,w)=>{if($[M]===void 0)return;let E=P(M);if(AJ.test(E)){K.push(`package.json script "${M}" runs \`${E}\`: a watch mode never exits, so it cannot gate a run`);return}if(!O.test(E)){K.push(`package.json script "${M}" runs \`${E}\`: not a ${R} this gate knows runs unattended and ends (${w}) \u2014 ${N(M)} to run it anyway`);return}W.push(`${j.run} ${M}`),B.push(`package.json script "${M}" (${j.from})`)};if(U("typecheck",PQ,"type-checker","tsc, vue-tsc, svelte-check"),U("lint",jQ,"linter","eslint, biome check, oxlint"),$.check!==void 0){let M=P("check"),O=FQ.exec(M),R=VQ.exec(M);if(O)K.push(`package.json script "check" runs \`${M}\`: it names \`${O[1]}\`, which a check must not do \u2014 ${N("check")} if that is really what you want the gate to run`);else if(AJ.test(M))K.push(`package.json script "check" runs \`${M}\`: a watch mode never exits, so it cannot gate a run`);else if(R)K.push(`package.json script "check" runs \`${M}\`: it runs the test suite (\`${R[1]}\`), which is minutes here rather than seconds; the thorough gate is configured, never inferred \u2014 ${N("check")} if that cost is right for this project`);else if(W.length>0)K.push(`package.json script "check" runs \`${M}\`: a faster script already covers it (${B.map((w)=>w.split(" (")[0]).join(", ")}) \u2014 ${N("check")} to run it instead`);else W.push(`${j.run} check`),B.push(`package.json script "check" (${j.from})`)}if($.test!==void 0){let M=P("test");K.push(`package.json script "test" runs \`${M}\`: a test suite is never inferred, only configured (the fast gate is a type-check; a suite can take minutes and may need services) \u2014 ${N("test")} if it is quick enough here`)}if(W.length===0&&K.length===0)K.push('package.json has no "typecheck", "lint", "check" or "test" script \u2014 name one, or set verify in .rovecode/settings.json')}}if(Z(L(J,"Cargo.toml")))W.push("cargo check"),B.push("Cargo.toml"),K.push("`cargo test` is not inferred: it runs the crate's tests, which may be slow or need services \u2014 set verify to run it");if(Z(L(J,"go.mod")))W.push("go vet ./..."),B.push("go.mod"),K.push("`go test ./...` is not inferred: it runs the module's tests \u2014 set verify to run it");let Y=L(J,"pyproject.toml");if(Z(Y)||Z(L(J,"ruff.toml"))){let $=Z(L(J,"ruff.toml")),q=$;if(!q&&Z(Y))try{q=/^\[tool\.ruff(\.|\])/m.test(z(Y))}catch{}if(q)W.push("ruff check ."),B.push($?"ruff.toml":"pyproject.toml [tool.ruff]");else K.push("pyproject.toml without a [tool.ruff] section: no linter is configured that this gate knows \u2014 set verify (for example `ruff check .` or `pytest -q`) to run one");K.push("`pytest` is not inferred: it runs the project's tests \u2014 set verify to run it")}if(Z(L(J,"Makefile"))||Z(L(J,"makefile")))K.push("a Makefile is here, but make targets are never inferred (a target can do anything) \u2014 set verify to `make check` or the target you mean");if(W.length>0)return{source:"inferred",commands:W,reason:`inferred from ${B.join(", ")}`,refused:K};if(K.length===0)return{source:"none",commands:[],reason:NQ,refused:[]};return{source:"none",commands:[],reason:DQ,refused:K}}function vJ(J){try{let Q=JSON.parse(bJ(L(J,kJ),"utf8"));if(Q===null||typeof Q!=="object"||Array.isArray(Q))return{};let Z={};for(let[z,X]of Object.entries(Q))if(X&&typeof X==="object"&&typeof X.ms==="number"&&typeof X.at==="string")Z[z]=X;return Z}catch{return{}}}function TJ(J,Q,Z,z=new Date){try{let X=vJ(J);X[Q]={ms:Math.max(0,Math.round(Z)),at:z.toISOString()},HQ(L(J,".rovecode"),{recursive:!0}),qQ(L(J,kJ),JSON.stringify(X,null,2)+`
4
4
  `)}catch{}}function CQ(J,Q){return vJ(J)[Q]?.ms}function LQ(J){let Q=Math.round(J/1000);if(Q<1)return"under a second";if(Q<120)return`${Q} s`;let Z=Math.floor(Q/60),z=Q%60;return z===0?`${Z} min`:`${Z} min ${z} s`}function iQ(J,Q){return Q.commands.map((Z)=>{let z=CQ(J,Z);return z===void 0?`${Z} (not run here yet)`:`${Z} (${LQ(z)} last time)`}).join(" && ")}var FQ,AJ,VQ,PQ,jQ,DQ="nothing configured and nothing fast and safe to infer \u2014 set verify in .rovecode/settings.json (a command, or a list) to turn the gate on",NQ="no package.json, Cargo.toml, go.mod or pyproject.toml here, so there is no compiler, linter or test runner to run; for a plain HTML/CSS/JS site that is the normal answer, and the gate stays off",dQ="runs after edits made with `edit` or `write`; a run that changed files only through `bash` is not counted, so it is not verified",kJ;var xJ=f(()=>{YQ();FQ=/\b(deploy|publish|release|push|migrate|drop|rm\s+-rf|docker|kubectl|terraform|curl|wget|ssh|scp|rsync)\b/i,AJ=/(^|\s)(--watch(=\S*)?|-w|--watchAll)(\s|$)|\bnodemon\b|\bvitest\s*$/,VQ=/\b(bun test|vitest|jest|mocha|node --test|playwright test|cypress run|ava|tap|uvu)\b/,PQ=/^(bunx |npx |pnpm exec |yarn )?(tsc|vue-tsc|svelte-check)(\s|$)/,jQ=/^(bunx |npx |pnpm exec |yarn )?(eslint|biome (check|lint)|oxlint)(\s|$)/;kJ=L(".rovecode","verify-timing.json")});function rQ(J,Q){try{if(Q.ran>0)TJ(J,Q.command,Q.ms)}catch{}}function yJ(J,Q=OQ){let Z=J.replace(/\r\n?/g,`
5
5
  `).split(`
@@ -9,11 +9,11 @@ ${B.slice(B.length-Q)}`;return B}async function sQ(J,Q,Z={}){let z=Z.exec??UQ,X=
9
9
  `+J.failure,"Fix what your changes broke and run the check yourself, or say plainly why it cannot be made to pass. This check runs once per run; your next reply ends it either way.","</verify-check>"].join(`
10
10
  `)}function gJ(J){let Q=J.refused&&J.refused.length>0?` \xB7 ${J.refused.length} check${J.refused.length===1?"":"s"} refused (${J.refused.join("; ")})`:"",Z="command"in J?J.command.length>60?`${J.command.slice(0,59)}\u2026`:J.command:"";switch(J.state){case"unconfigured":return`not verified: ${J.reason??"no check configured"}${Q}`;case"passed":return`check passed (${Z})${Q}`;case"timeout":return`check timed out after ${J.seconds}s (${Z})${Q}`;case"failed":return`check failed (${Z}): ${(J.failure.split(`
11
11
  `).filter((z)=>z.trim()!=="").at(-1)??"").slice(0,120)}${Q}`}}function mJ(J){if(J.ok)return`passed in ${(J.ms/1000).toFixed(1)}s`;if(J.timedOut)return`timed out after ${(J.ms/1000).toFixed(0)}s`;let Q=J.failure.split(`
12
- `).filter((Z)=>Z.trim()!=="").at(-1)??"";return`exit ${J.code}${Q?` \u2014 ${Q.slice(0,120)}`:""}`}var oQ=(J)=>{let Q=wJ(J);return{commands:Q.commands,refused:Q.refused,source:Q.source,reason:Q.reason}},fJ=120000,OQ=3000,SQ=40,XJ=20,UQ=async(J,Q,Z)=>{let{getExecutor:z}=await import("./executor-ftvg6tsy.js");return z().run(J,Q,Z)};var uJ=f(()=>{xJ()});import{randomUUID as v}from"crypto";class AQ{queue=[];push(J){this.queue.push(J)}drainAll(){let J=this.queue;return this.queue=[],J}drainOne(){return this.queue.shift()}get size(){return this.queue.length}}function RQ(J,Q){return{calls:J.filter((z)=>z.kind==="tool_call"),truncated:Q==="length"}}async function*KZ(J,Q,Z,z,X,G,W=0,B){let K=new AbortController,V=()=>K.abort();if(X.signal?.aborted)K.abort();else X.signal?.addEventListener("abort",V,{once:!0});let Y=X.hooks?.observer?.({cwd:X.cwd??process.cwd(),sessionId:X.store.id});try{for await(let $ of EQ(J,Q,Z,z,X,G,W,B,K)){if(Y)await Y.observe($);yield $}}finally{if(X.signal?.removeEventListener("abort",V),K.abort(),Y)await Y.close()}}async function*EQ(J,Q,Z,z,X,G,W,B,K){let V=v();yield{type:"run_start",runId:V,sessionId:X.store.id,goal:Q};let Y=J.model??{provider:"mock",model:"default"},$=[...X.store.messages()],q=$.length,j={id:v(),role:"user",parts:[{kind:"text",text:Q}],parentId:$.at(-1)?.id??null,createdAt:Date.now()};X.store.append(j),$.push(j);let P=[],N=(I)=>{P.push(I)},U=function*(){yield*P.splice(0,P.length)};X.guard?.onTurn();let M=null,O=0,R=X.clock??Date.now,w=R(),E=0,b=0,T=!1,h=-1,S;for(let I=1;I<=z.maxTurns;I++){if(K.signal.aborted){yield{type:"run_end",status:"stopped",summary:"run aborted"};return}if(z.maxSeconds!==void 0&&(R()-w)/1000>=z.maxSeconds){yield{type:"run_end",status:"budget",summary:`wall clock (${z.maxSeconds}s) reached after ${I-1} turn${I===2?"":"s"}`};return}if(z.maxCostUsd!==void 0&&E>=z.maxCostUsd){let H=b>0?`; ${b} turn${b===1?"":"s"} unpriced`:"";yield{type:"run_end",status:"budget",summary:`cost cap ($${z.maxCostUsd.toFixed(2)}) reached after ${I-1} turn${I===2?"":"s"} \u2014 $${E.toFixed(4)} spent${H}`};return}for(let H of G.drainAll()){let F={id:v(),role:"user",parts:[{kind:"text",text:H}],parentId:$.at(-1)?.id??null,createdAt:Date.now()};X.store.append(F),$.push(F),yield{type:"steer",text:H}}yield{type:"turn_start",turn:I};let KJ=$.reduce((H,F)=>H+k(p(F.parts)),0),d=SJ(KJ,z,M!==null),WJ=M;if(M=null,d){let H={trigger:d,tokenText:(D)=>p(D.parts),summarize:X.summarize,native:X.compactNative,model:Y,signal:K.signal},F=ZJ($,z,H),A=F?await $J($,F,z,H):null;if(A){$.length=0,$.push(...A.history);let D={type:"compaction",strategy:A.strategy,trigger:d,tokensBefore:KJ,tokensAfter:$.reduce((C,_)=>C+k(p(_.parts)),0)};X.store.appendEvent(D),yield D}else if(WJ!==null){yield{type:"run_end",status:"error",summary:WJ};return}}let BJ=typeof J.systemPrompt==="function"?J.systemPrompt(Z):J.systemPrompt,dJ=$.reduce((H,F)=>H+k(p(F.parts)),0),iJ=[{name:"system",text:BJ,priority:100,tokens:k(BJ)},...J.contextChunks??[],{name:"history",text:"",priority:50,tokens:dJ}],g=DJ(iJ,z.contextBudgetTokens);if(g.dropped.length>0){let H=g.dropped.reduce((F,A)=>F+A.tokens,0);yield{type:"compaction",strategy:"context-drop",tokensBefore:g.totalTokens+H,tokensAfter:g.totalTokens}}let YJ=g.chunks.filter((H)=>H.name!=="history"),aJ=YJ.length>0,nJ=YJ.map((H)=>H.text).join(`
12
+ `).filter((Z)=>Z.trim()!=="").at(-1)??"";return`exit ${J.code}${Q?` \u2014 ${Q.slice(0,120)}`:""}`}var oQ=(J)=>{let Q=wJ(J);return{commands:Q.commands,refused:Q.refused,source:Q.source,reason:Q.reason}},fJ=120000,OQ=3000,SQ=40,XJ=20,UQ=async(J,Q,Z)=>{let{getExecutor:z}=await import("./executor-bdrjn634.js");return z().run(J,Q,Z)};var uJ=f(()=>{xJ()});import{randomUUID as v}from"crypto";class AQ{queue=[];push(J){this.queue.push(J)}drainAll(){let J=this.queue;return this.queue=[],J}drainOne(){return this.queue.shift()}get size(){return this.queue.length}}function RQ(J,Q){return{calls:J.filter((z)=>z.kind==="tool_call"),truncated:Q==="length"}}async function*KZ(J,Q,Z,z,X,G,W=0,B){let K=new AbortController,V=()=>K.abort();if(X.signal?.aborted)K.abort();else X.signal?.addEventListener("abort",V,{once:!0});let Y=X.hooks?.observer?.({cwd:X.cwd??process.cwd(),sessionId:X.store.id});try{for await(let $ of EQ(J,Q,Z,z,X,G,W,B,K)){if(Y)await Y.observe($);yield $}}finally{if(X.signal?.removeEventListener("abort",V),K.abort(),Y)await Y.close()}}async function*EQ(J,Q,Z,z,X,G,W,B,K){let V=v();yield{type:"run_start",runId:V,sessionId:X.store.id,goal:Q};let Y=J.model??{provider:"mock",model:"default"},$=[...X.store.messages()],q=$.length,j={id:v(),role:"user",parts:[{kind:"text",text:Q}],parentId:$.at(-1)?.id??null,createdAt:Date.now()};X.store.append(j),$.push(j);let P=[],N=(I)=>{P.push(I)},U=function*(){yield*P.splice(0,P.length)};X.guard?.onTurn();let M=null,O=0,R=X.clock??Date.now,w=R(),E=0,b=0,T=!1,h=-1,S;for(let I=1;I<=z.maxTurns;I++){if(K.signal.aborted){yield{type:"run_end",status:"stopped",summary:"run aborted"};return}if(z.maxSeconds!==void 0&&(R()-w)/1000>=z.maxSeconds){yield{type:"run_end",status:"budget",summary:`wall clock (${z.maxSeconds}s) reached after ${I-1} turn${I===2?"":"s"}`};return}if(z.maxCostUsd!==void 0&&E>=z.maxCostUsd){let H=b>0?`; ${b} turn${b===1?"":"s"} unpriced`:"";yield{type:"run_end",status:"budget",summary:`cost cap ($${z.maxCostUsd.toFixed(2)}) reached after ${I-1} turn${I===2?"":"s"} \u2014 $${E.toFixed(4)} spent${H}`};return}for(let H of G.drainAll()){let F={id:v(),role:"user",parts:[{kind:"text",text:H}],parentId:$.at(-1)?.id??null,createdAt:Date.now()};X.store.append(F),$.push(F),yield{type:"steer",text:H}}yield{type:"turn_start",turn:I};let KJ=$.reduce((H,F)=>H+k(p(F.parts)),0),d=SJ(KJ,z,M!==null),WJ=M;if(M=null,d){let H={trigger:d,tokenText:(D)=>p(D.parts),summarize:X.summarize,native:X.compactNative,model:Y,signal:K.signal},F=ZJ($,z,H),A=F?await $J($,F,z,H):null;if(A){$.length=0,$.push(...A.history);let D={type:"compaction",strategy:A.strategy,trigger:d,tokensBefore:KJ,tokensAfter:$.reduce((C,_)=>C+k(p(_.parts)),0)};X.store.appendEvent(D),yield D}else if(WJ!==null){yield{type:"run_end",status:"error",summary:WJ};return}}let BJ=typeof J.systemPrompt==="function"?J.systemPrompt(Z):J.systemPrompt,dJ=$.reduce((H,F)=>H+k(p(F.parts)),0),iJ=[{name:"system",text:BJ,priority:100,tokens:k(BJ)},...J.contextChunks??[],{name:"history",text:"",priority:50,tokens:dJ}],g=DJ(iJ,z.contextBudgetTokens);if(g.dropped.length>0){let H=g.dropped.reduce((F,A)=>F+A.tokens,0);yield{type:"compaction",strategy:"context-drop",tokensBefore:g.totalTokens+H,tokensAfter:g.totalTokens}}let YJ=g.chunks.filter((H)=>H.name!=="history"),aJ=YJ.length>0,nJ=YJ.map((H)=>H.text).join(`
13
13
 
14
14
  `),i=v(),m,oJ={id:"sys",role:"system",parts:[{kind:"text",text:nJ}],parentId:null,createdAt:0};try{let H=X.planReminder?.($)??null,F=H===null?$:[...$,{id:`reminder-${I}`,role:"user",parts:[{kind:"text",text:H}],parentId:$.at(-1)?.id??null,createdAt:Date.now()}],A=kQ(X.stream,Y,aJ?[oJ,...F]:F,X.tools,K.signal,z.maxSeconds!==void 0?w+z.maxSeconds*1000:void 0),D="";for(;;){let C=await A.next();if(C.done){m=C.value;break}if(C.value.type==="text_delta")yield{type:"message_update",messageId:i,delta:C.value.text};else D+=C.value.text,yield{type:"reasoning_update",messageId:i,tokens:k(D)}}}catch(H){m={parts:[],stopReason:"error",usage:{input:0,output:0},error:H instanceof Error?H.message:String(H)}}yield*U();let{parts:x,stopReason:u,usage:y}=m,a=K.signal.aborted||u==="aborted",n={id:i,role:"assistant",parts:x,parentId:$.at(-1)?.id??null,createdAt:Date.now(),origin:m.origin??Y,usage:y};if(z.maxCostUsd!==void 0&&(y.input>0||y.output>0||(y.cacheRead??0)>0||(y.cacheWrite??0)>0)){let H=z.priceUsd?.(y,n.origin??Y);if(H===void 0)b++;else E+=H}if(!a||x.length>0)X.store.append(n),$.push(n);if(yield{type:"turn_end",turn:I,stopReason:a?"aborted":u},a){for(let H of x)if(H.kind==="tool_call")zJ(X.store,$,H.id,{ok:!1,output:c});yield{type:"run_end",status:"stopped",summary:"run aborted"};return}if(u==="error"){let H=m.error??"provider stream failed",F=cJ(x),A=F?`${F}
15
15
  error: ${H}`:`error: ${H}`;if(UJ(H)&&O===0&&I<z.maxTurns){O++,M=A;continue}yield{type:"run_end",status:"error",summary:A};return}let{calls:l,truncated:rJ}=RQ(x,u);if(rJ){for(let F of l)yield{type:"tool_call_failed",callId:F.id,reason:"truncated",detail:"response hit length limit; tool calls not executed"},zJ(X.store,$,F.id,{ok:!1,output:"response hit length limit; tool calls not executed"});continue}if(l.length===0){let H=B?B.drainAll():[];if(H.length>0){X.guard?.onTurn();for(let D of H){let C={id:v(),role:"user",parts:[{kind:"text",text:D}],parentId:$.at(-1)?.id??null,createdAt:Date.now()};X.store.append(C),$.push(C),yield{type:"steer",text:D}}continue}let F=bQ($.slice(q),z.todoState?.()??null,T);if(z.finishCheck!==!1&&!T&&(F.failed.length>0||F.unansweredAsk)){T=!0;let D=wQ(F),C={id:v(),role:"user",parts:[{kind:"text",text:D}],parentId:$.at(-1)?.id??null,createdAt:Date.now()};X.store.append(C),$.push(C),yield{type:"steer",text:D};continue}if(z.verify!==void 0&&F.writes>0){let D=z.verify,C=D.resolution?.refused&&D.resolution.refused.length>0?{refused:D.resolution.refused}:{};if(D.resolution===null||D.resolution.commands.length===0)F.verify={state:"unconfigured",...D.resolution?.reason?{reason:D.resolution.reason}:{},...C};else if(F.writes===h&&S!==void 0)F.verify=S;else{yield{type:"verify",command:D.resolution.commands.join(" && "),state:"running"};let _=await D.run(K.signal);if(K.signal.aborted){yield{type:"run_end",status:"stopped",summary:"run aborted"};return}h=F.writes;let r=_.ok?{state:"passed",command:_.command,ms:_.ms,...C}:_.timedOut?{state:"timeout",command:_.command,seconds:Math.round(D.timeoutMs/1000),...C}:{state:"failed",command:_.command,code:_.code,failure:_.failure,...C};if(S=r,yield{type:"verify",command:_.command,state:r.state,ms:_.ms,detail:mJ(_)},!_.ok&&!T){T=!0;let FJ=hJ(_,D.timeoutMs),VJ={id:v(),role:"user",parts:[{kind:"text",text:FJ}],parentId:$.at(-1)?.id??null,createdAt:Date.now()};X.store.append(VJ),$.push(VJ),yield{type:"steer",text:FJ};continue}F.verify=r}}let A=F.failed.length>0||F.unansweredAsk||(F.todosOpen??0)>0||F.nudged||F.verify!==void 0;yield{type:"run_end",status:"done",summary:cJ(x),...A?{outstanding:F}:{}};return}let GJ={sessionId:X.store.id,cwd:X.cwd??process.cwd(),signal:K.signal,runId:V,spawn:void 0,permissions:{effect:"allow"}},HJ=X.childRunner;if(HJ)GJ.spawn=async(H)=>{let F=await HJ(H.agent,H.goal,H.vars,W+1);return{agent:H.agent,ok:F.ok,summary:F.summary,usage:F.usage}};let qJ=new Map,o=!1;try{let H=X.registry.dispatchBatch(l,GJ,X.hooks,z.permissionRules,z.approval,N,z.parallelTools,X.guard),F=!1;H.then(()=>{F=!0},()=>{F=!0});while(!F&&!K.signal.aborted)if(await Promise.race([H,lJ(5)]),P.length>0)yield*U();if(!F&&K.signal.aborted)await Promise.race([H,lJ(250)]);if(F)qJ=await H,o=!0;if(P.length>0)yield*U()}finally{if(!o)K.abort();for(let H of l)zJ(X.store,$,H.id,qJ.get(H.id)??{ok:!1,output:o?"missing result":c})}if(K.signal.aborted){yield{type:"run_end",status:"stopped",summary:"run aborted"};return}}yield{type:"run_end",status:"budget",summary:`max turns (${z.maxTurns}) reached`}}function bQ(J,Q,Z){let z=new Map;for(let $ of J)if($.role==="tool"){for(let q of $.parts)if(q.kind==="tool_result")z.set(q.callId,{ok:q.ok,output:q.output})}let X=($,q)=>`${$.tool}: ${(q.split(`
16
16
  `)[0]??"").slice(0,160)}`,G=($)=>{let q=$.args,j=q?.path??q?.file_path;return typeof j==="string"?j:null},W=0,B=[],K=new Map;for(let $ of J){if($.role!=="assistant")continue;let q=$.parts.filter((j)=>j.kind==="tool_call");if(q.length===0)continue;B=q;for(let j of q){if(j.tool!=="edit"&&j.tool!=="write")continue;let P=z.get(j.id),N=G(j)??j.id;if(P?.ok===!0)W++,K.delete(N);else if(P&&!pJ(P.output))K.set(N,X(j,P.output))}}let V=[...K.values()],Y=!1;for(let $ of B){let q=z.get($.id);if(q===void 0||q.ok)continue;if($.tool==="ask_user"){Y=!0;continue}if(pJ(q.output))continue;let j=X($,q.output);if(!V.includes(j))V.push(j)}return{failed:V,unansweredAsk:Y,writes:W,...Q&&Q.total>0?{todosOpen:Q.open,todosTotal:Q.total}:{},nudged:Z}}function pJ(J){return J.startsWith("Permission denied")||J.includes("loop guard: blocked")||J.startsWith(c)}function wQ(J){let Q=["<finish-check>","You stopped, but this run is not in a finished state \u2014 this is a check by the harness, not a message from the user."];for(let Z of J.failed)Q.push(`- a tool call failed and nothing after it recovered from that: ${Z}`);if(J.unansweredAsk)Q.push("- your question to the user was not answered (there is no one to answer it in this run); decide with your best judgment instead of waiting");if((J.todosOpen??0)>0)Q.push(`- your own todo list still has ${J.todosOpen} of ${J.todosTotal} items open`);return Q.push("Either continue and finish the work now, or say plainly what is left undone and why it is not needed. This check runs once per run; your next reply ends it either way.","</finish-check>"),Q.join(`
17
17
  `)}function WZ(J){let Q=[];if(J.failed.length>0)Q.push(`${J.failed.length} failed tool call${J.failed.length===1?"":"s"} not recovered (${[...new Set(J.failed.map((Z)=>Z.split(":")[0]))].join(", ")})`);if(J.unansweredAsk)Q.push("its question to you went unanswered");if((J.todosOpen??0)>0)Q.push(`${J.todosOpen} of ${J.todosTotal} items still open`);if(J.verify!==void 0)Q.push(gJ(J.verify));return Q.length>0?Q.join(" \xB7 "):null}function BZ(J){return J.failed.length===0&&!J.unansweredAsk&&(J.todosOpen??0)===0&&J.verify?.state==="passed"?"info":"warn"}function zJ(J,Q,Z,z){let X={id:v(),role:"tool",parts:[{kind:"tool_result",callId:Z,ok:z.ok,output:z.output}],parentId:Q.at(-1)?.id??null,createdAt:Date.now()};J.append(X),Q.push(X)}async function*kQ(J,Q,Z,z,X,G){let W={parts:[],stopReason:"end_turn",usage:{input:0,output:0}};for await(let B of J(Q,Z,{tools:z,signal:X,...G!==void 0?{deadlineAt:G}:{}}))if(B.type==="text_delta"||B.type==="reasoning_delta")yield B;else if(B.type==="turn")W={parts:B.turn.parts,stopReason:B.turn.stopReason,usage:B.turn.usage,error:B.turn.error,origin:jJ(B.turn)};return W}function cJ(J){return J.filter((Q)=>Q.kind==="text").map((Q)=>Q.text).join("")}function p(J){return J.map((Q)=>Q.kind==="text"?Q.text:Q.kind==="tool_call"?`${Q.tool} ${JSON.stringify(Q.args)}`:Q.kind==="tool_result"?Q.output:"").join(`
18
18
  `)}var lJ=(J)=>new Promise((Q)=>setTimeout(Q,J));var vQ=f(()=>{IQ();MJ();JJ();IJ();uJ()});
19
- export{PJ as mk,TQ as nk,eJ as ok,xQ as pk,MJ as qk,k as rk,JJ as sk,QJ as tk,mQ as uk,ZJ as vk,$J as wk,IJ as xk,wJ as yk,dQ as zk,iQ as Ak,xJ as Bk,oQ as Ck,rQ as Dk,fJ as Ek,sQ as Fk,uJ as Gk,AQ as Hk,RQ as Ik,KZ as Jk,bQ as Kk,wQ as Lk,WZ as Mk,BZ as Nk,cJ as Ok,p as Pk,vQ as Qk};
19
+ export{PJ as Mk,TQ as Nk,eJ as Ok,xQ as Pk,MJ as Qk,k as Rk,JJ as Sk,QJ as Tk,mQ as Uk,ZJ as Vk,$J as Wk,IJ as Xk,wJ as Yk,dQ as Zk,iQ as _k,xJ as $k,oQ as al,rQ as bl,fJ as cl,sQ as dl,uJ as el,AQ as fl,RQ as gl,KZ as hl,bQ as il,wQ as jl,WZ as kl,BZ as ll,cJ as ml,p as nl,vQ as ol};
@@ -16,4 +16,4 @@ ${this.promptView("memory")}`);if(this.frozen.user&&!this.withheld.has("user"))q
16
16
  ${this.promptView("user")}`);return q.join(`
17
17
 
18
18
  `)}liveText(q){return this.live[q]}edited(q){return B(this.live[q])!==this.frozen[q]}cap(q){return this.caps[q]}overCap(q){if(this.live[q].length<=this.caps[q]&&!this.readCut[q])return null;return{chars:this.live[q].length,cap:this.caps[q],readCut:this.readCut[q]}}isWithheld(q){return this.withheld.has(q)}}
19
- export{A as ye,Y as ze,T as Ae,x as Be,s as Ce,i as De,k as Ee,a as Fe};
19
+ export{A as of,Y as pf,T as qf,x as rf,s as sf,i as tf,k as uf,a as vf};
@@ -4,4 +4,4 @@ import{wn as B}from"./main-qsevpgsv.js";import{readFileSync as D,statSync as v}f
4
4
  `).filter(Boolean),V=new Map,K;$.forEach((J,O)=>{let U;try{U=JSON.parse(J)}catch{Q.push({kind:"malformed-json",line:O,detail:`unparseable line ${O}`});return}if(!U||typeof U!=="object"){Q.push({kind:"unknown-shape",line:O,detail:"line is not an entry object"});return}if(typeof U.id!=="string"){Q.push({kind:"unknown-shape",line:O,detail:"entry line has no string id"});return}if(q.has(U.id))Q.push({kind:"duplicate-id",entryId:U.id,line:O,detail:"duplicate id"});q.add(U.id);let W=U.parentId!==null&&!q.has(U.parentId);if(W)Q.push({kind:"orphan-entry",entryId:U.id,line:O,detail:`parent ${U.parentId} missing`});let X=U.parentId===null?"":V.get(U.parentId)?.hash;if(X!==void 0&&U.prevHash!==X)Q.push({kind:"chain-broken",entryId:U.id,line:O,detail:`prevHash disagrees with parent ${U.parentId??"(root)"}`});if(!V.has(U.id))V.set(U.id,U);let z=R(U.entry);if(z===void 0)Q.push({kind:"unknown-shape",entryId:U.id,line:O,detail:"entry is neither a message nor an event"});if(U.entry=this.hydrateImages(U.entry),this.cache.push(U),!W&&z!==void 0)K=U});let Y=new Map(this.cache.map((J)=>[J.id,J]));for(let J of this.cache){let O=new Set,U=J;while(U&&U.parentId!==null){if(O.has(U.id)){Q.push({kind:"cycle",entryId:J.id,line:-1,detail:"ancestry cycle"});break}O.add(U.id),U=Y.get(U.parentId)}}if(K)this.leaf=K.id,this.prevHash=K.hash;if(Z!==void 0){let J=Y.get(Z);if(J)this.leaf=J.id,this.prevHash=J.hash}return Q}append(q){this.materialize();let Q=q.parentId,Z=Q!==void 0?Q:this.leaf,$=this.prevHash;if(Z!==this.leaf)$=Z===null?"":this.cache.find((Y)=>Y.id===Z)?.hash??this.prevHash;if(this.staged.length>0&&"role"in q&&q.role==="user")q.parts.push(...this.staged),this.staged=[];let V=this.sidecarImages(q),K={id:q.id,parentId:Z,createdAt:q.createdAt??Date.now(),prevHash:$,hash:"",entry:V};if(K.hash=a($,K),i(this.file,JSON.stringify(K)+`
5
5
  `),this.cache.push(V===q?K:{...K,entry:this.hydrateImages(V)}),this.leaf=K.id,this.prevHash=K.hash,this.leafPersisted)this.persistLeaf()}stageAttachments(q){this.staged=[...q]}get stagedAttachments(){return this.staged}sidecarImages(q){if(R(q)!=="message"||!("role"in q))return q;let Q=d(this.dir,q.parts);return Q===void 0?q:{...q,parts:Q}}hydrateImages(q){if(R(q)!=="message"||!("role"in q))return q;let Q=m(this.dir,q.parts);return Q===void 0?q:{...q,parts:Q}}appendEvent(q){this.materialize();let Q=this.leaf==="root"?null:this.leaf,Z={id:zq(),kind:"event",parentId:Q,createdAt:Date.now(),event:q},$={id:Z.id,parentId:Q,createdAt:Z.createdAt,prevHash:this.prevHash,hash:"",entry:Z};return $.hash=a(this.prevHash,$),i(this.file,JSON.stringify($)+`
6
6
  `),this.cache.push($),Z}path(){return this.wrappedPath().filter((q)=>R(q.entry)!==void 0).map((q)=>q.entry)}wrappedPath(){let q=new Map(this.cache.map((J)=>[J.id,J])),Q=[],Z=q.get(this.leaf),$=new Set;while(Z&&!$.has(Z.id))$.add(Z.id),Q.unshift(Z),Z=Z.parentId?q.get(Z.parentId):void 0;let V=new Set(Q.map((J)=>J.id)),K=new Map;for(let J of this.cache){if(V.has(J.id)||!r(J))continue;if(J.parentId!==null&&!V.has(J.parentId))continue;let O=K.get(J.parentId)??[];O.push(J),K.set(J.parentId,O)}if(K.size===0)return Q;let Y=[...K.get(null)??[]];for(let J of Q)Y.push(J,...K.get(J.id)??[]);return Y}turnPoints(){let q=new Map;for(let Z of this.cache)if(!r(Z))q.set(Z.parentId,(q.get(Z.parentId)??0)+1);let Q=[];for(let Z of this.wrappedPath()){let $=Z.entry;if(R($)!=="message"||!("role"in $)||$.role!=="user")continue;Q.push({entryId:Z.id,index:Q.length+1,text:g($),fullText:$.parts.filter((V)=>V.kind==="text").map((V)=>V.text).join(""),parentId:Z.parentId,branches:(q.get(Z.parentId)??1)-1})}return Q}branch(q){let Q=this.cache.find((Z)=>Z.id===q);if(!Q)return!1;return this.leaf=Q.id,this.prevHash=Q.hash,this.persistLeaf(),!0}persistLeaf(){this.materialize(),this.meta={...this.meta,leaf:this.leaf},this.writeMeta(this.meta),this.leafPersisted=!0}patchMeta(q){this.materialize();let Q={};try{let $=JSON.parse(j(G(this.dir,"meta.json"),"utf8"));if($&&typeof $==="object"&&!Array.isArray($))Q=$}catch{Q={...this.meta}}let Z={...Q,...q,id:this.id};this.writeMeta(Z),this.meta={...this.meta,...q,id:this.id}}writeMeta(q){let Q=G(this.dir,"meta.json"),Z=Q+".tmp";p(Z,JSON.stringify(q,null,2)),Cq(Z,Q)}messages(){return this.path().filter((q)=>("role"in q))}}var Hq=B(()=>{b();n()});
7
- export{Qq as Rk,Zq as Sk,S as Tk,Fq as Uk,kq as Vk,_q as Wk,u as Xk,Oq as Yk,gq as Zk,Mq as _k,Eq as $k,Tq as al,l as bl,L as cl,b as dl,o as el,n as fl,a as gl,R as hl,e as il,Lq as jl,dq as kl,jq as ll,Hq as ml};
7
+ export{Qq as pl,Zq as ql,S as rl,Fq as sl,kq as tl,_q as ul,u as vl,Oq as wl,gq as xl,Mq as yl,Eq as zl,Tq as Al,l as Bl,L as Cl,b as Dl,o as El,n as Fl,a as Gl,R as Hl,e as Il,Lq as Jl,dq as Kl,jq as Ll,Hq as Ml};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{Vi as T,Wi as y,aj as C}from"./main-xx2z3zh5.js";import{Mj as F,Nj as O,Wj as h}from"./main-ywbxshqc.js";import{$m as I,Um as D,_m as R}from"./main-2yeveeve.js";I();import{createInterface as _}from"readline";h();var A=[{key:"1",id:"anthropic",label:"anthropic \u2014 Claude models"},{key:"2",id:"openai",label:"openai"},{key:"3",id:"openrouter",label:"openrouter \u2014 many models behind one key"},{key:"4",id:"deepseek",label:"deepseek"},{key:"5",id:"groq",label:"groq"},{key:"6",id:"ollama",label:"ollama \u2014 local, no key needed",local:!0},{key:"7",id:"lmstudio",label:"lmstudio \u2014 local, no key needed",local:!0},{key:"8",label:"another OpenAI-compatible URL (a proxy, vLLM, \u2026)",url:"openai"},{key:"9",label:"another Anthropic-protocol URL",url:"anthropic"}],E='Done. Try: rovecode "explain this repo"';function K(G){return new Promise((q)=>{let J=_({input:process.stdin,output:process.stdout}),Y=!1;J.question(G,(H)=>{if(Y)return;Y=!0,J.close(),q(H.trim())}),J.once("close",()=>{if(!Y)Y=!0,q("")})})}async function v(G){let q=G.out??console.log,J=G.ask??K,Y=G.secret??((j)=>R(j)),H=G.save??D,W=G.registry,f=G.probe??((j,B)=>W.probe(j,B));if(!(G.tty??process.stdin.isTTY===!0))return q(O("cli")),q(" (rovecode setup needs a terminal \u2014 this stdin is a pipe)"),2;q("\u25C6 rovecode setup \u2014 let's connect a model. Two or three questions."),q("");for(let j of A)q(` ${j.key} ${j.label}`);q("");let Q;for(let j=0;j<3&&Q===void 0;j++){let B=(await J("Which one? [1-9, empty = cancel]: ")).trim();if(B.length===0)return q(`cancelled \u2014 nothing changed. ${F("rovecode setup")} whenever you like`),2;if(Q=A.find(($)=>$.key===B||$.id===B),Q===void 0)q(` "${B}" is not on the list \u2014 a number from 1 to 9, please.`)}if(Q===void 0)return 2;let z;if(Q.url!==void 0){if(z=(await J("Short name for it (letters, digits, - _ .): ")).trim().toLowerCase(),!T.test(z))return q(` "${z}" won't work as an id. ${F("rovecode setup, and pick a name like myproxy")}`),2;let j=(await J("Base URL (e.g. https://host/v1): ")).trim();if(!/^https?:\/\//.test(j))return q(` "${j}" is not an http(s) URL. ${F("rovecode setup")}`),2;let B=Q.url==="anthropic"?"anthropic":j.includes("anthropic.com")?y(j):"openai",$=(await J("Does it need an API key? [Y/n]: ")).trim().toLowerCase().startsWith("n"),V=W.add({id:z,baseUrl:j,protocol:B,...$?{noKey:!0}:{}},"user");if("error"in V)return q(` ${V.error}. ${F("rovecode setup")}`),2;q(`\u25C6 ${z} registered (${B} protocol, ${j}).`)}else{z=Q.id;let j=W.get(z);if(j===void 0)return q(` ${z} is missing from the built-in table \u2014 that is a bug. ${F("rovecode provider add "+z+" <baseUrl>")}`),2;if(Q.local===!0&&j.noKey!==!0){let B=W.add({id:z,baseUrl:j.baseUrl,protocol:j.protocol,noKey:!0,...j.defaultModel!==void 0?{defaultModel:j.defaultModel}:{}},"user");if("error"in B)return q(` ${B.error}. ${F("rovecode setup")}`),2;q(`\u25C6 ${z} marked as a local server (${j.baseUrl}, no key).`)}}let X=W.get(z),L=X.defaultModel,N=(await J(L!==void 0?`Model id [${L}]: `:"Model id (empty = choose later with rovecode model list): ")).trim(),Z=N.length>0?N:L,M=C(X);if(!M){let j=await Y(`${X.keyEnv} (hidden): `);if(j.trim().length===0)q(`\u25C6 no key stored \u2014 I can't call ${z} without one.`),q(` ${F(`rovecode auth set ${z}`)} (or set ${X.keyEnv} in your environment)`);else H(z,j.trim(),X.keyEnv),W.refresh(),M=!0,q(`\u25C6 key stored for ${z} (hidden; ~/.rovecode/credentials.json).`)}else q(`\u25C6 ${z} already has a key (${X.keySource==="stored"?"stored":`env ${X.keyEnv}`}).`);if(M&&Z!==void 0){q(`\u25C6 testing ${z}/${Z} \u2026`);let j=await f(z,Z);if(j.ok)q(` ${j.detail}`);else q(` that didn't work: ${j.detail}`),q(` ${F(`check the key and the URL, then rovecode provider test ${z} ${Z}`)}`)}if(Z!==void 0){let j=W.setDefault(`${z}/${Z}`,"user");if("error"in j)return q(` ${j.error}. ${F(`rovecode model use ${z}/<model>`)}`),2;q(`\u25C6 default \u2192 ${j.provider}/${j.model} (~/.rovecode/providers.json; running TUIs switch live).`)}else q(`\u25C6 ${z} is set up but has no model yet.`),q(` ${F(`rovecode model list ${z}, then rovecode model use ${z}/<model>`)}`);return q(""),q(E),q(" or open the cockpit: rovecode"),0}
3
- export{A as Jc,E as Kc,K as Lc,v as Mc};
2
+ import{Xi as T,Yi as y,cj as C}from"./main-sdmxhtv8.js";import{kk as F,lk as O,uk as h}from"./main-8kjxbpw4.js";import{$m as I,Um as D,_m as R}from"./main-2yeveeve.js";I();import{createInterface as _}from"readline";h();var A=[{key:"1",id:"anthropic",label:"anthropic \u2014 Claude models"},{key:"2",id:"openai",label:"openai"},{key:"3",id:"openrouter",label:"openrouter \u2014 many models behind one key"},{key:"4",id:"deepseek",label:"deepseek"},{key:"5",id:"groq",label:"groq"},{key:"6",id:"ollama",label:"ollama \u2014 local, no key needed",local:!0},{key:"7",id:"lmstudio",label:"lmstudio \u2014 local, no key needed",local:!0},{key:"8",label:"another OpenAI-compatible URL (a proxy, vLLM, \u2026)",url:"openai"},{key:"9",label:"another Anthropic-protocol URL",url:"anthropic"}],E='Done. Try: rovecode "explain this repo"';function K(G){return new Promise((q)=>{let J=_({input:process.stdin,output:process.stdout}),Y=!1;J.question(G,(H)=>{if(Y)return;Y=!0,J.close(),q(H.trim())}),J.once("close",()=>{if(!Y)Y=!0,q("")})})}async function v(G){let q=G.out??console.log,J=G.ask??K,Y=G.secret??((j)=>R(j)),H=G.save??D,W=G.registry,f=G.probe??((j,B)=>W.probe(j,B));if(!(G.tty??process.stdin.isTTY===!0))return q(O("cli")),q(" (rovecode setup needs a terminal \u2014 this stdin is a pipe)"),2;q("\u25C6 rovecode setup \u2014 let's connect a model. Two or three questions."),q("");for(let j of A)q(` ${j.key} ${j.label}`);q("");let Q;for(let j=0;j<3&&Q===void 0;j++){let B=(await J("Which one? [1-9, empty = cancel]: ")).trim();if(B.length===0)return q(`cancelled \u2014 nothing changed. ${F("rovecode setup")} whenever you like`),2;if(Q=A.find(($)=>$.key===B||$.id===B),Q===void 0)q(` "${B}" is not on the list \u2014 a number from 1 to 9, please.`)}if(Q===void 0)return 2;let z;if(Q.url!==void 0){if(z=(await J("Short name for it (letters, digits, - _ .): ")).trim().toLowerCase(),!T.test(z))return q(` "${z}" won't work as an id. ${F("rovecode setup, and pick a name like myproxy")}`),2;let j=(await J("Base URL (e.g. https://host/v1): ")).trim();if(!/^https?:\/\//.test(j))return q(` "${j}" is not an http(s) URL. ${F("rovecode setup")}`),2;let B=Q.url==="anthropic"?"anthropic":j.includes("anthropic.com")?y(j):"openai",$=(await J("Does it need an API key? [Y/n]: ")).trim().toLowerCase().startsWith("n"),V=W.add({id:z,baseUrl:j,protocol:B,...$?{noKey:!0}:{}},"user");if("error"in V)return q(` ${V.error}. ${F("rovecode setup")}`),2;q(`\u25C6 ${z} registered (${B} protocol, ${j}).`)}else{z=Q.id;let j=W.get(z);if(j===void 0)return q(` ${z} is missing from the built-in table \u2014 that is a bug. ${F("rovecode provider add "+z+" <baseUrl>")}`),2;if(Q.local===!0&&j.noKey!==!0){let B=W.add({id:z,baseUrl:j.baseUrl,protocol:j.protocol,noKey:!0,...j.defaultModel!==void 0?{defaultModel:j.defaultModel}:{}},"user");if("error"in B)return q(` ${B.error}. ${F("rovecode setup")}`),2;q(`\u25C6 ${z} marked as a local server (${j.baseUrl}, no key).`)}}let X=W.get(z),L=X.defaultModel,N=(await J(L!==void 0?`Model id [${L}]: `:"Model id (empty = choose later with rovecode model list): ")).trim(),Z=N.length>0?N:L,M=C(X);if(!M){let j=await Y(`${X.keyEnv} (hidden): `);if(j.trim().length===0)q(`\u25C6 no key stored \u2014 I can't call ${z} without one.`),q(` ${F(`rovecode auth set ${z}`)} (or set ${X.keyEnv} in your environment)`);else H(z,j.trim(),X.keyEnv),W.refresh(),M=!0,q(`\u25C6 key stored for ${z} (hidden; ~/.rovecode/credentials.json).`)}else q(`\u25C6 ${z} already has a key (${X.keySource==="stored"?"stored":`env ${X.keyEnv}`}).`);if(M&&Z!==void 0){q(`\u25C6 testing ${z}/${Z} \u2026`);let j=await f(z,Z);if(j.ok)q(` ${j.detail}`);else q(` that didn't work: ${j.detail}`),q(` ${F(`check the key and the URL, then rovecode provider test ${z} ${Z}`)}`)}if(Z!==void 0){let j=W.setDefault(`${z}/${Z}`,"user");if("error"in j)return q(` ${j.error}. ${F(`rovecode model use ${z}/<model>`)}`),2;q(`\u25C6 default \u2192 ${j.provider}/${j.model} (~/.rovecode/providers.json; running TUIs switch live).`)}else q(`\u25C6 ${z} is set up but has no model yet.`),q(` ${F(`rovecode model list ${z}, then rovecode model use ${z}/<model>`)}`);return q(""),q(E),q(" or open the cockpit: rovecode"),0}
3
+ export{A as wa,E as xa,K as ya,v as za};
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{Dl as Q,zl as N}from"./main-a3f51n0x.js";Q();import{resolve as V}from"path";var z="--add-dir",W="usage: rovecode [run] [--add-dir <dir>]\u2026 \u2014 an extra workspace root beside the cwd (repeatable; --add-dir=<dir> too)",X=(q)=>{return process.stderr.write(`error: ${q} \u2014 ${W}
2
+ import{Zl as N,bm as Q}from"./main-0904f6ps.js";Q();import{resolve as V}from"path";var z="--add-dir",W="usage: rovecode [run] [--add-dir <dir>]\u2026 \u2014 an extra workspace root beside the cwd (repeatable; --add-dir=<dir> too)",X=(q)=>{return process.stderr.write(`error: ${q} \u2014 ${W}
3
3
  `),process.exit(2)},Y=(q)=>q.length>1&&q.startsWith("-");function w(q,B=X,O=process.cwd()){let C=q.slice(2),H=[];for(let y=0;y<C.length;y++){let J=C[y],j;if(J===z){if(j=C[y+1],j===void 0||Y(j))return B(`${z} needs a value`);y++}else if(J.startsWith(`${z}=`))j=J.slice(z.length+1);else continue;if(j.trim().length===0)return B(`${z} needs a directory`);let K=V(O,j),M=N(K,j);if(M!==void 0)return B(M);if(!H.includes(K))H.push(K)}return H}
4
- export{z as ug,W as vg,w as wg};
4
+ export{z as vh,W as wh,w as xh};