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
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Db as XJ,Fb as h,Gb as w,Hb as f,Ib as c,ub as q,vb as JJ,wb as _,xb as d,yb as p}from"./main-tjvwmscs.js";import{Jb as DJ,Kb as KJ,Lb as gJ,Ob as EJ,Pb as UJ,Qb as PJ,Rb as u,Sb as g,Tb as CJ,Ub as uJ}from"./main-hzwtsb2m.js";import"./main-m8vm17zq.js";import{Zb as WJ,ac as k,cc as HJ,dc as fJ}from"./main-zc7pyrbj.js";import{ec as e,oc as AJ}from"./main-45ejth3a.js";import{pc as BJ,xc as kJ}from"./main-jak598k9.js";import"./main-7kt6r53y.js";import"./main-f33fc5je.js";import"./main-2zgsknth.js";import"./main-kwwsz6rq.js";import{Ng as YJ,Vg as xJ}from"./main-7jd5vh3x.js";import"./main-xt9zc3n6.js";import"./main-2rzbexn2.js";import"./main-y5c82rxr.js";import{$m as hJ,Lm as VJ,_m as o}from"./main-2yeveeve.js";import"./main-0jys2ccn.js";import"./main-nqveez48.js";import{xn as yJ}from"./main-qsevpgsv.js";hJ();p();c();p();c();AJ();var FJ=/^(?:https?:\/\/|git@|ssh:\/\/|git:\/\/)|\.git$/i,qJ=/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/i,TJ=/^(?:\.{1,2}[\\/]|[A-Za-z]:[\\/]|[\\/])/,MJ=(J)=>FJ.test(J),SJ=(J)=>TJ.test(J),LJ=(J)=>qJ.test(J)&&(J.startsWith("@")||J.includes("-"));function x(J,Z,X,$){return{id:Z,kind:J,title:Z,publisher:"unknown (you named this source)",description:$,source:"catalog",tags:[],env:[],install:X}}function t(J,Z){let X=J.trim();if(MJ(X)){if(Z==="mcp")return null;return Z==="skill"?x("skill",s(X),{kind:"skill",source:{git:X}},`a skill cloned from ${X}`):x("plugin",s(X),{kind:"plugin",source:X,git:!0},`a plugin cloned from ${X}`)}if(SJ(X)){if(Z!==void 0&&Z!=="plugin")return null;return x("plugin",X.split(/[\\/]/).filter(Boolean).pop()??"plugin",{kind:"plugin",source:X,git:!1},`a plugin copied from ${X}`)}if((Z===void 0||Z==="mcp")&&LJ(X)){let $={key:X,title:X,description:`an MCP server run with npx ${X}`,source:"registry",publisher:X.startsWith("@")?X.slice(1).split("/")[0]:"unknown",installs:[{kind:"stdio",runtime:"npx",command:"npx",args:["-y",X],env:[],pending:[]}]};return x("mcp",e(X),{kind:"mcp",entry:$},`an MCP server run with npx ${X}`)}return null}function s(J){return(J.replace(/\.git$/i,"").split(/[\\/]/).filter(Boolean).pop()??"item").toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/^[^a-z0-9]+/,"").slice(0,64)||"item"}async function j(J,Z={}){let X=JJ(J);if(X===null)return{ok:!1,error:`"${J.slice(0,60)}" is not something rovecode can install`};let{kind:$,id:V}=X;if($!==void 0){let E=await w($,V,Z);if(E.item)return{ok:!0,item:E.item};let D=t(V,$);if(D)return{ok:!0,item:D};return{ok:!1,error:`no ${$} called "${V}"${E.notes.length?` \u2014 ${E.notes[0]}`:""}`}}let B=[];for(let E of["mcp","skill","plugin"]){let D=await w(E,V,Z);if(D.item&&D.item.id===V)B.push(D.item)}if(B.length===1)return{ok:!0,item:B[0]};if(B.length>1)return{ok:!1,ambiguous:B,error:`"${V}" exists in ${B.length} kinds \u2014 say which: ${B.map(_).join(" \xB7 ")}`};let Q=t(V);if(Q)return{ok:!0,item:Q};let C=(await h(V,Z)).items.slice(0,5);if(C.length===0)return{ok:!1,error:`nothing in the market matches "${V}"`};return{ok:!1,ambiguous:C,error:`no item is called "${V}" \u2014 did you mean: ${C.map(_).join(" \xB7 ")}`}}uJ();kJ();fJ();gJ();xJ();c();p();var b=(J)=>typeof J==="object"&&J!==null&&!Array.isArray(J),OJ=/^[a-z0-9][a-z0-9._-]{0,63}$/,vJ={skill:new Set(["id","name","title","publisher","description","version","license","tags","repository","homepage","source","files","bytes","docs","env","status","planNote"]),plugin:new Set(["id","name","title","publisher","description","version","apiVersion","license","tags","repository","homepage","install","contributes","docs","env","status","planNote"])};function l(J){if(typeof J!=="string"||J==="")return!1;let Z=J.split("\\").join("/");return Z.startsWith("/")||/^[A-Za-z]:/.test(Z)||Z.split("/").includes("..")}function bJ(J,Z={}){if(Z.kind!==void 0)return Z.kind;if(b(J)&&(J.kind==="skill"||J.kind==="plugin"))return J.kind;let X=(Z.filename??"").toLowerCase();if(X.includes("skill"))return"skill";if(X.includes("plugin"))return"plugin";return}function ZJ(J,Z={}){let X=[],$=(D,S,G="error")=>X.push({path:D,message:S,severity:G});if(J.length>q.body)return{ok:!1,kind:Z.kind??"skill",accepted:0,dropped:0,findings:[{path:"",message:`the file is ${Math.round(J.length/1024)} KB; rovecode reads at most ${q.body/1024} KB`,severity:"error"}]};let V;try{V=JSON.parse(J)}catch(D){return{ok:!1,kind:Z.kind??"skill",accepted:0,dropped:0,findings:[{path:"",message:`not valid JSON: ${D instanceof Error?D.message:String(D)}`,severity:"error"}]}}let B=bJ(V,Z);if(B===void 0)return{ok:!1,kind:"skill",accepted:0,dropped:0,findings:[{path:"",message:'cannot tell whether this is a skill or a plugin catalog \u2014 pass --kind skill|plugin, or give the document a "kind" field',severity:"error"}]};if(!b(V))return{ok:!1,kind:B,accepted:0,dropped:0,findings:[{path:"",message:"the top level must be an object",severity:"error"}]};if(V.version===void 0)$("version","missing; rovecode assumes 1","warning");else if(V.version!==1)$("version",`is ${JSON.stringify(V.version)}; this rovecode reads version 1`);if(!Array.isArray(V.items))return $("items","missing or not an array \u2014 a catalog is { version, items: [...] }"),{ok:!1,kind:B,accepted:0,dropped:0,findings:X};let Q=V.items;if(Q.length===0)$("items","no rows: this catalog would show nothing","warning");if(Q.length>q.items)$("items",`${Q.length} rows; rovecode reads the first ${q.items} and ignores the rest`,"warning");let F=new Map,C=0,E=0;return Q.forEach((D,S)=>{let G=`items[${S}]`,A=X.length;if(!b(D)){$(G,"not an object"),E++;return}let O=typeof D.id==="string"?D.id:typeof D.name==="string"?D.name:void 0;if(O===void 0)$(`${G}.id`,"missing (a row needs an id, or a name to use as one)");else if(!OJ.test(O))$(`${G}.id`,`"${O}" is not a bare slug \u2014 lowercase letters, digits, dot, dash, underscore, at most 64`);else{let Y=F.get(O);if(Y!==void 0)$(`${G}.id`,`"${O}" is already used by items[${Y}]; ids are unique within a kind`);else F.set(O,S)}if(typeof D.description!=="string"||D.description.trim()==="")$(`${G}.description`,"missing (a row needs one line describing it)");else if(D.description.length>q.desc)$(`${G}.description`,`${D.description.length} characters; will be cut to ${q.desc}`,"warning");for(let Y of["title","publisher","version","license","repository","homepage"]){let H=D[Y];if(H!==void 0&&typeof H!=="string")$(`${G}.${Y}`,`must be a string, not ${Array.isArray(H)?"an array":typeof H}`,"warning");else if(typeof H==="string"&&H.length>q.str)$(`${G}.${Y}`,`${H.length} characters; will be cut to ${q.str}`,"warning")}if(D.publisher===void 0)$(`${G}.publisher`,'missing; the row will say "unknown"',"warning");if(D.tags!==void 0){if(!Array.isArray(D.tags))$(`${G}.tags`,"must be an array of strings","warning");else if(D.tags.length>q.list)$(`${G}.tags`,`${D.tags.length} tags; only the first ${q.list} are read`,"warning")}IJ(B,D,G,$),jJ(D.docs,`${G}.docs`,$);for(let Y of Object.keys(D))if(!vJ[B].has(Y))$(`${G}.${Y}`,"not a field rovecode reads \u2014 a typo, or something it will ignore","warning");let I=[],R=XJ(B,D,I),z=X.slice(A).some((Y)=>Y.severity==="error");if(R===null){if(E++,!z)$(G,`rovecode drops this row${I.length?`: ${I[I.length-1]}`:""} \u2014 the checks above did not explain why, which is a gap in this validator`)}else{if(z)$(G,"the row loads despite the errors above; treat them as the more careful reading","warning");C++}}),{ok:X.every((D)=>D.severity!=="error"),kind:B,accepted:C,dropped:E,findings:X}}function IJ(J,Z,X,$){if(J==="skill"){let B=b(Z.source)?Z.source:void 0,Q=Array.isArray(Z.files)?Z.files:void 0;if(B===void 0&&Q===void 0){$(`${X}.source`,"missing: a skill needs either source.git (a repository) or files (the text itself)");return}if(B!==void 0){if(typeof B.git!=="string"||!/^https?:\/\//.test(B.git))$(`${X}.source.git`,"must be an http(s) repository URL");if(l(B.subfolder))$(`${X}.source.subfolder`,`"${String(B.subfolder)}" climbs out of the clone`)}if(Q?.forEach((F,C)=>{let E=b(F)?F.path:void 0;if(typeof E!=="string"||E==="")$(`${X}.files[${C}].path`,"missing");else if(l(E))$(`${X}.files[${C}].path`,`"${E}" writes outside the skill's folder`);if(b(F)&&typeof F.text!=="string")$(`${X}.files[${C}].text`,"missing (the file's contents)")}),Q!==void 0&&Q.length>q.list)$(`${X}.files`,`${Q.length} files; only the first ${q.list} are read`,"warning");return}let V=b(Z.install)?Z.install:void 0;if(V===void 0){$(`${X}.install`,"missing: a plugin needs install.source (a repository URL or a folder)");return}if(typeof V.source!=="string"||V.source===""){$(`${X}.install.source`,"missing");return}if(V.git===!0&&!/^https?:\/\//.test(V.source))$(`${X}.install.source`,`"${V.source}" is marked git: true but is not an http(s) URL`);if(l(V.subfolder))$(`${X}.install.subfolder`,`"${String(V.subfolder)}" climbs out of the clone`);if(V.subfolder===void 0)$(`${X}.install.subfolder`,"absent: the plugin.json must then be at the repository root","warning")}function jJ(J,Z,X){if(J===void 0)return;if(!b(J)){X(Z,"must be an object","warning");return}if(typeof J.source!=="string"||!/^https?:\/\//.test(J.source))X(`${Z}.source`,"must be the http(s) URL the document was read from \u2014 the docs are dropped without it","warning");if(J.format!=="markdown")X(`${Z}.format`,'must be "markdown"; the docs are dropped otherwise',"warning");if(typeof J.body!=="string"||J.body.trim()==="")X(`${Z}.body`,"empty: the docs are dropped and the row keeps no documentation","warning");else if(Buffer.byteLength(J.body,"utf8")>q.docs)X(`${Z}.body`,`${Math.round(Buffer.byteLength(J.body,"utf8")/1024)} KB; will be cut to ${q.docs/1024} KB`,"warning");if(J.truncated===!0&&typeof J.bytes==="number"&&typeof J.body==="string"&&J.bytes<=Buffer.byteLength(J.body,"utf8"))X(`${Z}.bytes`,"marked truncated, but bytes is not larger than the body \u2014 bytes should be the size BEFORE truncation","warning")}function $J(J,Z){let X=J.findings.filter((B)=>B.severity==="error"),$=J.findings.filter((B)=>B.severity==="warning"),V=[`${Z}: ${J.kind} catalog \u2014 ${J.ok?"valid":"INVALID"}`];V.push(` ${J.accepted} row${J.accepted===1?"":"s"} would load, ${J.dropped} dropped, ${X.length} error${X.length===1?"":"s"}, ${$.length} warning${$.length===1?"":"s"}`);for(let B of[...X,...$])V.push(` ${B.severity==="error"?"error ":"warning"} ${B.path===""?"(file)":B.path}: ${B.message}`);if(J.ok&&$.length>0)V.push(" warnings do not stop a catalog loading; they are fields that will not survive as written");return V}import{readFileSync as mJ}from"fs";import{createInterface as wJ}from"readline";var n=["usage: rovecode market <command>"," search [query] [--kind mcp|skill|plugin] every source at once: the curated MCP shelf, the MCP registry,"," rovecode's skill and plugin catalogs (skills/plugins work offline)"," info <id> one item in full: publisher, version, what it installs, what it asks"," docs <id> the item's own documentation, as the catalog carries it"," install <id|kind:id|git-url|npm-package> [--project] [--as <name>] [--pick N] [--ref <branch|tag|commit>] [--yes] [--force]"," shows the plan, asks (masked) for keys by name, then writes"," --local / --no-local: an npx server installed ONCE (npm, ~25 MB, starts in 0.4 s not 2 s)"," or the npx line as it is; without either, a terminal asks and --yes keeps npx"," --dry-run shows the plan and stops; nothing is fetched or written"," remove <id|kind:id> [--project] undo an install of any kind"," list [--all] [--kind mcp|skill|plugin] what is installed here (--all: the whole market, with badges)"," update [id] [--all] [--yes] what is out of date; with an id or --all: plan, approve, reinstall"," --all --yes skips plugins (new code): name one, or pass --yes-plugins"," sources [probe] where rows come from right now; really asks the registry (--offline to skip)"," verify [id] re-hash what is installed and say what has changed since"," validate <path|url> [--kind skill|plugin] check a catalog you wrote before anyone trusts it: what would"," load, what would be dropped, and which fields will not survive","every command takes --json \xB7 --offline skips the network entirely","an id is a bare slug inside its kind (filesystem); say mcp:filesystem when two kinds share a name"],GJ=new Set(["--json","--offline"]),pJ=new Set(["--as","--pick","--kind","--ref"]),_J={search:new Set(["--kind"]),info:new Set,docs:new Set,install:new Set(["--project","--as","--pick","--ref","--yes","--force","--dry-run","--local","--no-local"]),remove:new Set(["--project","--yes"]),list:new Set(["--all","--kind"]),update:new Set(["--all","--yes","--yes-plugins","--dry-run"]),sources:new Set,verify:new Set,validate:new Set(["--kind"]),help:new Set},cJ=new Set([...GJ,...Object.values(_J).flatMap((J)=>[...J])]),lJ=/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u009f]/g,nJ=(J)=>J.replace(/\r\n?/g,`
2
+ import{a as DJ,b as KJ,c as gJ,f as EJ,g as UJ,h as PJ,i as u,j as g,k as CJ,l as uJ}from"./main-x4r0fne4.js";import"./main-f7rw7des.js";import{S as WJ,V as k,X as HJ,Y as fJ}from"./main-yr0ksc0h.js";import{Z as e,ha as AJ}from"./main-xy53xf0r.js";import{ia as BJ,qa as kJ}from"./main-7c5thhjd.js";import{Ac as f,Bc as c,nc as q,oc as JJ,pc as _,qc as d,rc as p,wc as XJ,yc as h,zc as w}from"./main-zaqh35jg.js";import"./main-vqak588n.js";import"./main-0ab9fc26.js";import"./main-6dnk69vp.js";import"./main-pn1w7a7j.js";import"./main-351pz3z7.js";import{Hh as YJ,Ph as xJ}from"./main-kcpbykxz.js";import"./main-q3vsesf9.js";import"./main-a9njrkk1.js";import"./main-7rn6bqje.js";import{$m as hJ,Lm as VJ,_m as o}from"./main-2yeveeve.js";import"./main-0jys2ccn.js";import"./main-nqveez48.js";import{xn as yJ}from"./main-qsevpgsv.js";hJ();p();c();p();c();AJ();var FJ=/^(?:https?:\/\/|git@|ssh:\/\/|git:\/\/)|\.git$/i,qJ=/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/i,TJ=/^(?:\.{1,2}[\\/]|[A-Za-z]:[\\/]|[\\/])/,MJ=(J)=>FJ.test(J),SJ=(J)=>TJ.test(J),LJ=(J)=>qJ.test(J)&&(J.startsWith("@")||J.includes("-"));function x(J,Z,X,$){return{id:Z,kind:J,title:Z,publisher:"unknown (you named this source)",description:$,source:"catalog",tags:[],env:[],install:X}}function t(J,Z){let X=J.trim();if(MJ(X)){if(Z==="mcp")return null;return Z==="skill"?x("skill",s(X),{kind:"skill",source:{git:X}},`a skill cloned from ${X}`):x("plugin",s(X),{kind:"plugin",source:X,git:!0},`a plugin cloned from ${X}`)}if(SJ(X)){if(Z!==void 0&&Z!=="plugin")return null;return x("plugin",X.split(/[\\/]/).filter(Boolean).pop()??"plugin",{kind:"plugin",source:X,git:!1},`a plugin copied from ${X}`)}if((Z===void 0||Z==="mcp")&&LJ(X)){let $={key:X,title:X,description:`an MCP server run with npx ${X}`,source:"registry",publisher:X.startsWith("@")?X.slice(1).split("/")[0]:"unknown",installs:[{kind:"stdio",runtime:"npx",command:"npx",args:["-y",X],env:[],pending:[]}]};return x("mcp",e(X),{kind:"mcp",entry:$},`an MCP server run with npx ${X}`)}return null}function s(J){return(J.replace(/\.git$/i,"").split(/[\\/]/).filter(Boolean).pop()??"item").toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/^[^a-z0-9]+/,"").slice(0,64)||"item"}async function j(J,Z={}){let X=JJ(J);if(X===null)return{ok:!1,error:`"${J.slice(0,60)}" is not something rovecode can install`};let{kind:$,id:V}=X;if($!==void 0){let E=await w($,V,Z);if(E.item)return{ok:!0,item:E.item};let D=t(V,$);if(D)return{ok:!0,item:D};return{ok:!1,error:`no ${$} called "${V}"${E.notes.length?` \u2014 ${E.notes[0]}`:""}`}}let B=[];for(let E of["mcp","skill","plugin"]){let D=await w(E,V,Z);if(D.item&&D.item.id===V)B.push(D.item)}if(B.length===1)return{ok:!0,item:B[0]};if(B.length>1)return{ok:!1,ambiguous:B,error:`"${V}" exists in ${B.length} kinds \u2014 say which: ${B.map(_).join(" \xB7 ")}`};let Q=t(V);if(Q)return{ok:!0,item:Q};let C=(await h(V,Z)).items.slice(0,5);if(C.length===0)return{ok:!1,error:`nothing in the market matches "${V}"`};return{ok:!1,ambiguous:C,error:`no item is called "${V}" \u2014 did you mean: ${C.map(_).join(" \xB7 ")}`}}uJ();kJ();fJ();gJ();xJ();c();p();var b=(J)=>typeof J==="object"&&J!==null&&!Array.isArray(J),OJ=/^[a-z0-9][a-z0-9._-]{0,63}$/,vJ={skill:new Set(["id","name","title","publisher","description","version","license","tags","repository","homepage","source","files","bytes","docs","env","status","planNote"]),plugin:new Set(["id","name","title","publisher","description","version","apiVersion","license","tags","repository","homepage","install","contributes","docs","env","status","planNote"])};function l(J){if(typeof J!=="string"||J==="")return!1;let Z=J.split("\\").join("/");return Z.startsWith("/")||/^[A-Za-z]:/.test(Z)||Z.split("/").includes("..")}function bJ(J,Z={}){if(Z.kind!==void 0)return Z.kind;if(b(J)&&(J.kind==="skill"||J.kind==="plugin"))return J.kind;let X=(Z.filename??"").toLowerCase();if(X.includes("skill"))return"skill";if(X.includes("plugin"))return"plugin";return}function ZJ(J,Z={}){let X=[],$=(D,S,G="error")=>X.push({path:D,message:S,severity:G});if(J.length>q.body)return{ok:!1,kind:Z.kind??"skill",accepted:0,dropped:0,findings:[{path:"",message:`the file is ${Math.round(J.length/1024)} KB; rovecode reads at most ${q.body/1024} KB`,severity:"error"}]};let V;try{V=JSON.parse(J)}catch(D){return{ok:!1,kind:Z.kind??"skill",accepted:0,dropped:0,findings:[{path:"",message:`not valid JSON: ${D instanceof Error?D.message:String(D)}`,severity:"error"}]}}let B=bJ(V,Z);if(B===void 0)return{ok:!1,kind:"skill",accepted:0,dropped:0,findings:[{path:"",message:'cannot tell whether this is a skill or a plugin catalog \u2014 pass --kind skill|plugin, or give the document a "kind" field',severity:"error"}]};if(!b(V))return{ok:!1,kind:B,accepted:0,dropped:0,findings:[{path:"",message:"the top level must be an object",severity:"error"}]};if(V.version===void 0)$("version","missing; rovecode assumes 1","warning");else if(V.version!==1)$("version",`is ${JSON.stringify(V.version)}; this rovecode reads version 1`);if(!Array.isArray(V.items))return $("items","missing or not an array \u2014 a catalog is { version, items: [...] }"),{ok:!1,kind:B,accepted:0,dropped:0,findings:X};let Q=V.items;if(Q.length===0)$("items","no rows: this catalog would show nothing","warning");if(Q.length>q.items)$("items",`${Q.length} rows; rovecode reads the first ${q.items} and ignores the rest`,"warning");let F=new Map,C=0,E=0;return Q.forEach((D,S)=>{let G=`items[${S}]`,A=X.length;if(!b(D)){$(G,"not an object"),E++;return}let O=typeof D.id==="string"?D.id:typeof D.name==="string"?D.name:void 0;if(O===void 0)$(`${G}.id`,"missing (a row needs an id, or a name to use as one)");else if(!OJ.test(O))$(`${G}.id`,`"${O}" is not a bare slug \u2014 lowercase letters, digits, dot, dash, underscore, at most 64`);else{let Y=F.get(O);if(Y!==void 0)$(`${G}.id`,`"${O}" is already used by items[${Y}]; ids are unique within a kind`);else F.set(O,S)}if(typeof D.description!=="string"||D.description.trim()==="")$(`${G}.description`,"missing (a row needs one line describing it)");else if(D.description.length>q.desc)$(`${G}.description`,`${D.description.length} characters; will be cut to ${q.desc}`,"warning");for(let Y of["title","publisher","version","license","repository","homepage"]){let H=D[Y];if(H!==void 0&&typeof H!=="string")$(`${G}.${Y}`,`must be a string, not ${Array.isArray(H)?"an array":typeof H}`,"warning");else if(typeof H==="string"&&H.length>q.str)$(`${G}.${Y}`,`${H.length} characters; will be cut to ${q.str}`,"warning")}if(D.publisher===void 0)$(`${G}.publisher`,'missing; the row will say "unknown"',"warning");if(D.tags!==void 0){if(!Array.isArray(D.tags))$(`${G}.tags`,"must be an array of strings","warning");else if(D.tags.length>q.list)$(`${G}.tags`,`${D.tags.length} tags; only the first ${q.list} are read`,"warning")}IJ(B,D,G,$),jJ(D.docs,`${G}.docs`,$);for(let Y of Object.keys(D))if(!vJ[B].has(Y))$(`${G}.${Y}`,"not a field rovecode reads \u2014 a typo, or something it will ignore","warning");let I=[],R=XJ(B,D,I),z=X.slice(A).some((Y)=>Y.severity==="error");if(R===null){if(E++,!z)$(G,`rovecode drops this row${I.length?`: ${I[I.length-1]}`:""} \u2014 the checks above did not explain why, which is a gap in this validator`)}else{if(z)$(G,"the row loads despite the errors above; treat them as the more careful reading","warning");C++}}),{ok:X.every((D)=>D.severity!=="error"),kind:B,accepted:C,dropped:E,findings:X}}function IJ(J,Z,X,$){if(J==="skill"){let B=b(Z.source)?Z.source:void 0,Q=Array.isArray(Z.files)?Z.files:void 0;if(B===void 0&&Q===void 0){$(`${X}.source`,"missing: a skill needs either source.git (a repository) or files (the text itself)");return}if(B!==void 0){if(typeof B.git!=="string"||!/^https?:\/\//.test(B.git))$(`${X}.source.git`,"must be an http(s) repository URL");if(l(B.subfolder))$(`${X}.source.subfolder`,`"${String(B.subfolder)}" climbs out of the clone`)}if(Q?.forEach((F,C)=>{let E=b(F)?F.path:void 0;if(typeof E!=="string"||E==="")$(`${X}.files[${C}].path`,"missing");else if(l(E))$(`${X}.files[${C}].path`,`"${E}" writes outside the skill's folder`);if(b(F)&&typeof F.text!=="string")$(`${X}.files[${C}].text`,"missing (the file's contents)")}),Q!==void 0&&Q.length>q.list)$(`${X}.files`,`${Q.length} files; only the first ${q.list} are read`,"warning");return}let V=b(Z.install)?Z.install:void 0;if(V===void 0){$(`${X}.install`,"missing: a plugin needs install.source (a repository URL or a folder)");return}if(typeof V.source!=="string"||V.source===""){$(`${X}.install.source`,"missing");return}if(V.git===!0&&!/^https?:\/\//.test(V.source))$(`${X}.install.source`,`"${V.source}" is marked git: true but is not an http(s) URL`);if(l(V.subfolder))$(`${X}.install.subfolder`,`"${String(V.subfolder)}" climbs out of the clone`);if(V.subfolder===void 0)$(`${X}.install.subfolder`,"absent: the plugin.json must then be at the repository root","warning")}function jJ(J,Z,X){if(J===void 0)return;if(!b(J)){X(Z,"must be an object","warning");return}if(typeof J.source!=="string"||!/^https?:\/\//.test(J.source))X(`${Z}.source`,"must be the http(s) URL the document was read from \u2014 the docs are dropped without it","warning");if(J.format!=="markdown")X(`${Z}.format`,'must be "markdown"; the docs are dropped otherwise',"warning");if(typeof J.body!=="string"||J.body.trim()==="")X(`${Z}.body`,"empty: the docs are dropped and the row keeps no documentation","warning");else if(Buffer.byteLength(J.body,"utf8")>q.docs)X(`${Z}.body`,`${Math.round(Buffer.byteLength(J.body,"utf8")/1024)} KB; will be cut to ${q.docs/1024} KB`,"warning");if(J.truncated===!0&&typeof J.bytes==="number"&&typeof J.body==="string"&&J.bytes<=Buffer.byteLength(J.body,"utf8"))X(`${Z}.bytes`,"marked truncated, but bytes is not larger than the body \u2014 bytes should be the size BEFORE truncation","warning")}function $J(J,Z){let X=J.findings.filter((B)=>B.severity==="error"),$=J.findings.filter((B)=>B.severity==="warning"),V=[`${Z}: ${J.kind} catalog \u2014 ${J.ok?"valid":"INVALID"}`];V.push(` ${J.accepted} row${J.accepted===1?"":"s"} would load, ${J.dropped} dropped, ${X.length} error${X.length===1?"":"s"}, ${$.length} warning${$.length===1?"":"s"}`);for(let B of[...X,...$])V.push(` ${B.severity==="error"?"error ":"warning"} ${B.path===""?"(file)":B.path}: ${B.message}`);if(J.ok&&$.length>0)V.push(" warnings do not stop a catalog loading; they are fields that will not survive as written");return V}import{readFileSync as mJ}from"fs";import{createInterface as wJ}from"readline";var n=["usage: rovecode market <command>"," search [query] [--kind mcp|skill|plugin] every source at once: the curated MCP shelf, the MCP registry,"," rovecode's skill and plugin catalogs (skills/plugins work offline)"," info <id> one item in full: publisher, version, what it installs, what it asks"," docs <id> the item's own documentation, as the catalog carries it"," install <id|kind:id|git-url|npm-package> [--project] [--as <name>] [--pick N] [--ref <branch|tag|commit>] [--yes] [--force]"," shows the plan, asks (masked) for keys by name, then writes"," --local / --no-local: an npx server installed ONCE (npm, ~25 MB, starts in 0.4 s not 2 s)"," or the npx line as it is; without either, a terminal asks and --yes keeps npx"," --dry-run shows the plan and stops; nothing is fetched or written"," remove <id|kind:id> [--project] undo an install of any kind"," list [--all] [--kind mcp|skill|plugin] what is installed here (--all: the whole market, with badges)"," update [id] [--all] [--yes] what is out of date; with an id or --all: plan, approve, reinstall"," --all --yes skips plugins (new code): name one, or pass --yes-plugins"," sources [probe] where rows come from right now; really asks the registry (--offline to skip)"," verify [id] re-hash what is installed and say what has changed since"," validate <path|url> [--kind skill|plugin] check a catalog you wrote before anyone trusts it: what would"," load, what would be dropped, and which fields will not survive","every command takes --json \xB7 --offline skips the network entirely","an id is a bare slug inside its kind (filesystem); say mcp:filesystem when two kinds share a name"],GJ=new Set(["--json","--offline"]),pJ=new Set(["--as","--pick","--kind","--ref"]),_J={search:new Set(["--kind"]),info:new Set,docs:new Set,install:new Set(["--project","--as","--pick","--ref","--yes","--force","--dry-run","--local","--no-local"]),remove:new Set(["--project","--yes"]),list:new Set(["--all","--kind"]),update:new Set(["--all","--yes","--yes-plugins","--dry-run"]),sources:new Set,verify:new Set,validate:new Set(["--kind"]),help:new Set},cJ=new Set([...GJ,...Object.values(_J).flatMap((J)=>[...J])]),lJ=/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u009f]/g,nJ=(J)=>J.replace(/\r\n?/g,`
3
3
  `).replace(lJ,""),NJ=(J)=>J<1024?`${J} B`:`${(J/1024).toFixed(1)} KB`,N=(J,Z)=>(J.out??console.log)(JSON.stringify(Z,null,2));function zJ(J){let Z=J.status?` [${J.status}]`:"";if(!J.installed)return Z;if(J.installed.updateAvailable)return`${Z} [installed ${J.installed.version??"?"} \xB7 update ${"available"}]`;if(J.installed.trusted===!1)return`${Z} [installed \xB7 NOT approved on this machine]`;return`${Z} [installed]`}function iJ(J,Z,X){let $=[`${J.title}${J.version?` ${J.version}`:""}${J.status?` [${J.status}]`:""}`,` id ${_(J)}`,` kind ${J.kind==="mcp"?"MCP server \u2014 rovecode launches it and the model gets its tools":J.kind==="skill"?"skill \u2014 instructions the model reads; files only, nothing runs":"plugin \u2014 a folder of code rovecode loads and runs"}`,` publisher ${J.publisher}`,` source ${J.source==="curated"?"curated list (built into rovecode)":J.source==="registry"?"MCP registry (registry.modelcontextprotocol.io)":"rovecode catalog (in the repository)"}`,` ${J.description}`];if(J.license)$.push(` licence ${J.license}`);if($.push(J.docs?` docs ${NJ(J.docs.bytes)} from ${J.docs.source}${J.docs.truncated?" (truncated)":""} \u2014 rovecode market docs ${_(J)}`:` docs none${J.repository?` \u2014 try ${J.repository}`:""}`),J.repository)$.push(` repo ${J.repository}`);if(J.homepage)$.push(` home ${J.homepage}`);if(J.tags.length)$.push(` tags ${J.tags.join(", ")}`);let{install:V}=J;if(V.kind==="mcp")for(let Q of V.entry.installs)$.push(Q.kind==="stdio"?` runs ${Q.command} ${Q.args.join(" ")}`:` connects ${Q.url}`);else if(V.kind==="plugin")$.push(` installs ${V.git?`git clone ${V.source}`:`copy of ${V.source}`}${V.subfolder?` (subfolder ${V.subfolder})`:""}`);else $.push(V.source?` installs git clone ${V.source.git}${V.source.subfolder?` (${V.source.subfolder})`:""}`:` installs ${(V.files??[]).length} file(s) from the catalog`);for(let Q of J.env)$.push(` needs ${Q.name}${Q.secret?" (secret, asked masked)":""}${Q.required?"":" (optional)"}${Q.description?` \u2014 ${Q.description}`:""}`);let B=u(J,Z,X);return $.push(B?` installed ${B.path} (${B.scope}${B.version?`, ${B.version}`:""}${B.trusted===!1?", NOT approved here":""})`:" installed no"),$}async function oJ(J,Z){let X={};for(let $ of J.asks){if(!Z.tty){Z.err(`${$.name} is not set \u2014 it will be written as \${${$.name}} and read from your environment`);continue}let V=`${$.name}${$.description?` (${$.description})`:""}: `,B=(await($.secret?Z.secret(V):Z.plain(V))).trim();if(B.length>0)X[$.name]=B}for(let $ of J.pending??[]){if(!Z.tty)continue;let V=(await Z.plain(`${$}: `)).trim();if(V.length>0)X[$]=V}return X}function dJ(J,Z){if(J.install.kind!=="mcp")return;if(Z.scope==="project")return;let X=J.install.entry.installs[Z.pick??0];return X===void 0?void 0:BJ(X)}function aJ(J){return[`${J.spec} would start through npx: ~2 s at every start, re-resolving the package (and asking the npm registry) each time.`,"Install it once instead? npm puts the package's code under ~/.rovecode/mcp \u2014 typically 20\u201330 MB and a few seconds, one time;","it then starts in ~0.4 s and needs no network to start. No keeps the npx line exactly as it is today."]}async function QJ(J,Z,X){let $=(E)=>{if(X.collect)X.collect(E);else N({out:X.out},E)},V=Z.local,B=dJ(J,Z);if(B!==void 0&&V===void 0&&!X.yes&&!X.json&&!X.dryRun&&X.tty){for(let D of aJ(B))X.out(D);let E=(await X.plain(`install ${B.spec} once? [y/N] `)).trim().toLowerCase();V=E==="y"||E==="yes"}let Q=EJ(J,V===void 0?Z:{...Z,local:V});if("error"in Q){if(X.err(Q.error),X.json)$({ok:!1,error:Q.error,id:_(J)});return 1}if(!X.json){for(let E of Q.preview)X.out(E);if(Q.replaces)X.out(` replaces ${Q.replaces}`);for(let E of Q.pending)X.out(` fill in ${E} \u2014 after the install, in ${Q.target}`)}if(X.dryRun){if(X.json)return $({dryRun:!0,item:J,target:Q.target,scope:Q.scope,preview:Q.preview,asks:Q.asks,pending:Q.pending,...Q.replaces?{replaces:Q.replaces}:{}}),0;return X.out(`nothing written \u2014 --dry-run. ${PJ(J.install)?"The source was not fetched, so this is the plan, not its contents.":"This is the whole plan."}`),0}if(!X.yes){if(X.json)return $({ok:!1,needsApproval:!0,item:J,target:Q.target,scope:Q.scope,preview:Q.preview,asks:Q.asks,pending:Q.pending,...Q.replaces?{replaces:Q.replaces}:{}}),X.err("nothing written: pass --yes to accept this plan, or --dry-run to read it"),1;if(!X.tty)return X.err("nothing written: rerun on a terminal, or pass --yes to accept this plan in a script"),1;let E=(await X.plain(`${X.verb} this? [y/N] `)).trim().toLowerCase();if(E!=="y"&&E!=="yes")return X.out("nothing written"),1}let F=await oJ(Q,{secret:X.secret,plain:X.plain,tty:X.tty&&!(Z.scope==="project"&&Q.asks.some((E)=>E.secret)),err:X.err}),C=await UJ(Q,F,V===void 0?Z:{...Z,local:V},X.run);if(!C.ok){if(X.err(C.error),X.json)$(C);return 1}if(X.json)return $(C),0;if(X.out(`${X.verb==="update"?"updated":"installed"} ${_(J)} \u2192 ${C.target}${C.trusted===!0?" (trusted as written)":""}`),C.package){if(X.out(` package ${C.package.name} ${C.package.version} \u2192 ${C.package.prefix}${C.package.integrity!==void 0?" (integrity recorded in installed.json)":""}`),C.package.missing)X.err(` record incomplete: ${C.package.missing.join("; ")}`)}if(C.trusted===!1)X.err("that file already held entries you have not approved, so it is NOT trusted yet \u2014 rovecode mcp trust");if(C.envNames.length)X.err(`set ${C.envNames.join(", ")} in your environment before the restart`);if(C.next)X.out(C.next);return 0}async function GX(J,Z={}){let X=new Map;try{return await rJ(J,{...Z,run:{...Z.run,cloneCache:X}})}catch($){return(Z.err??((V)=>console.error(V)))(`market: ${$ instanceof Error?$.message:String($)}`),1}finally{YJ(X)}}async function rJ(J,Z){let X=Z.out??console.log,$=Z.err??((z)=>console.error(z)),V=Z.cwd??process.cwd(),B=Z.home??VJ(),Q=J.includes("--json"),F=J.includes("--offline"),C=J.includes("--project")?"project":"user",E={...Z.registry,...F?{offline:!0}:{}},D=(z)=>{let Y=J.indexOf(z);return Y>=0?J[Y+1]:void 0},S=J.filter((z,Y)=>!z.startsWith("--")&&!(Y>0&&pJ.has(J[Y-1]))),G=(z)=>{if($(z),$(n.join(`
4
4
  `)),Q)N(Z,{ok:!1,error:z,usage:n});return 2},A=S[0];if(A===void 0)return G("market needs a command");let O=_J[A];if(O===void 0)return G(`unknown command "${A}"`);for(let z of J){if(!z.startsWith("--"))continue;if(GJ.has(z)||O.has(z))continue;return G(cJ.has(z)?`market ${A} does not take ${z}`:`unknown flag ${z}`)}if(A==="help")return X(n.join(`
5
- `)),0;let I=()=>{let z=D("--kind");if(z===void 0)return;return["mcp","skill","plugin"].includes(z)?z:G("--kind takes mcp, skill or plugin")};if(A==="search"){let z=I();if(z===2)return 2;let Y=S.slice(1).join(" "),H=await h(Y,E),K=z?H.items.filter((W)=>W.kind===z):H.items,P=g(K,V,B);if(Q)return N(Z,{items:P,sources:H.sources,notes:H.notes}),P.length===0?1:0;for(let W of H.notes)$(`market: ${W}`);if(P.length===0){let W=Object.entries(H.sources).filter(([,T])=>!T.ok);$(Y?`nothing matches "${Y}"`:"the market is empty");for(let[T,M]of W)if(!M.ok)$(` ${T}: ${M.reason}`);return 1}for(let W of P)X(`${d(W)}${zJ(W)}`);return 0}if(A==="sources"){let z=S.slice(1).join(" ")||"mcp",Y=F?await f(E):await h(z,E);if(Q)return N(Z,{sources:Y.sources,notes:Y.notes,count:Y.items.length,probe:F?null:z,offline:F}),Object.values(Y.sources).every((H)=>H.ok)?0:1;if(F)X("--offline: the registry was not asked");else X(`probed with "${z}"`);for(let[H,K]of Object.entries(Y.sources)){let P=!K.ok?`FAILED \u2014 ${K.reason}`:K.from==="live"?"answered just now":K.from==="cache"?`from the cache${K.ageMs?` (${Math.round(K.ageMs/1000)}s old)`:""}`:K.from==="skipped"?`not consulted \u2014 ${K.why}`:"built in / on disk";X(`${H.padEnd(14)} ${P}`)}return X(`${String(Y.items.length).padStart(14)} items visible right now`),Object.values(Y.sources).every((H)=>H.ok)?0:1}if(A==="verify"){let z=S[1],Y=[];for(let K of["user","project"])for(let P of WJ(K,V,B)){let W=`${P.kind}:${P.id}`;if(z!==void 0&&z!==W&&z!==P.id)continue;Y.push({id:W,result:P.kind==="mcp"?{state:"not-applicable",why:"an MCP entry is a line inside a shared mcp.json, not a folder of its own"}:DJ(P.digest,P.target)})}if(Q){if(N(Z,Y),Y.length===0)return z!==void 0?1:0;return Y.some((K)=>K.result.state==="changed"||K.result.state==="missing")?1:0}if(Y.length===0)return X(z!==void 0?`nothing recorded for "${z}"`:"nothing installed through the market yet"),z!==void 0?1:0;for(let K of Y)X(KJ(K.id,K.result));let H=Y.filter((K)=>K.result.state==="changed"||K.result.state==="missing").length;if(H>0)$(`${H} item${H===1?" is":"s are"} not what was installed \u2014 reinstall with \`market install <id> --force\`, or keep the edit`);return H>0?1:0}if(A==="list"){let z=J.includes("--all"),Y=I();if(Y===2)return 2;let H=await f(E),K=g(H.items,V,B).filter((W)=>(z||W.installed)&&(Y===void 0||W.kind===Y)),P=K.map((W)=>W.installed?{...W,origin:k(W,W.installed.scope,V,B)??null}:W);if(Q)return N(Z,P),0;if(K.length===0){let W=Y===void 0?"":`${Y==="mcp"?"MCP server":Y} `;return X(z?Y===void 0?"the market is empty":`the market has no ${W}items`:`${Y===void 0?"nothing ":`no ${W}`}installed here yet \u2014 \`rovecode market search${Y?` --kind ${Y}`:""}\` to look around`),0}for(let W of K)if(X(`${d(W)}${zJ(W)}`),W.installed)X(` from ${HJ(k(W,W.installed.scope,V,B))}`);return 0}if(A==="update"){let z=await f(E),Y=g(z.items,V,B).filter((U)=>U.installed),H=Y.filter((U)=>U.installed.updateAvailable===!0||U.version===void 0||U.installed.version===void 0),K=S[1],P=J.includes("--all");if(K===void 0&&!P){if(Q)return N(Z,H),0;if(H.length===0)return X("everything installed is at the catalog's version"),0;for(let U of H){let v=U.installed.version,L=U.version;X(v!==void 0&&L!==void 0?`${_(U)} ${v} \u2192 ${L}`:`${_(U)} version unknown (${v===void 0?"nothing on disk says one":"the catalog states none"}) \u2014 updating reinstalls it`)}return X("rovecode market update <id> \xB7 rovecode market update --all"),0}let W=P&&J.includes("--yes")&&!J.includes("--yes-plugins"),T=H;if(K!==void 0){let U=await j(K,E);if(!U.ok){if($(U.error),Q)N(Z,{ok:!1,error:U.error,candidates:U.ambiguous??[]});return U.ambiguous?2:1}let v=Y.find((L)=>L.id===U.item.id&&L.kind===U.item.kind);if(v===void 0){let L=`${_(U.item)} is not installed here \u2014 rovecode market install ${_(U.item)}`;if($(L),Q)N(Z,{ok:!1,error:L,id:_(U.item),installed:!1});return 1}T=[v]}let M=W?T.filter((U)=>U.kind==="plugin"):[];if(M.length)T=T.filter((U)=>U.kind!=="plugin");let y=[],a=(U)=>{if(Q)N(Z,{ok:U,results:y,skipped:M.map(_)})};if(T.length===0&&M.length===0){if(Q)a(!0);else X("everything installed is at the catalog's version");return 0}let RJ={out:X,err:$,json:Q,yes:J.includes("--yes"),tty:Z.tty??process.stdin.isTTY===!0,secret:Z.secret??o,plain:Z.plain??i,verb:"update",dryRun:J.includes("--dry-run"),run:{...Z.run,force:!0,...F?{offline:!0}:{}},...Q?{collect:(U)=>{y.push(U)}}:{}},m=0;if(M.length&&!Q)X(`${M.length} plugin${M.length>1?"s":""} skipped \u2014 a plugin update runs new code: ${M.map(_).join(", ")}`),X(" rovecode market update <id> --yes \xB7 or --yes-plugins to take them all");for(let U of T){let v=U.kind==="mcp"?k(U,U.installed.scope,V,B)?.package!==void 0:void 0,L={scope:U.installed.scope,cwd:V,home:B,...Z.prereqEnv!==void 0?{prereqEnv:Z.prereqEnv}:{},...v!==void 0?{local:v}:{}},r=await QJ(U,L,RJ);if(r!==0)m=r}return a(m===0),m}let R=S[1];if(["info","install","remove","docs"].includes(A)&&R===void 0)return G(`market ${A} needs a name`);if(A==="info"){let z=await j(R,E);if(z.ok&&z.item.source==="catalog"&&z.item.publisher.startsWith("unknown (")&&z.item.kind==="mcp"){if($(`"${R}" is not in the catalog or the registry \u2014 \`market install\` would treat it as an npm package, but there is nothing here to describe`),Q)N(Z,{error:"not found",id:R});return 1}if(!z.ok){if($(z.error),Q)N(Z,{error:z.error,candidates:z.ambiguous??[]});return z.ambiguous?2:1}if(Q)return N(Z,{...z.item,installed:u(z.item,V,B)}),0;for(let Y of iJ(z.item,V,B))X(Y);return 0}if(A==="docs"){let z=await j(R,E);if(z.ok&&z.item.source==="catalog"&&z.item.publisher.startsWith("unknown (")&&z.item.kind==="mcp"){if($(`"${R}" is not in the catalog or the registry \u2014 nothing here has documentation`),Q)N(Z,{error:"not found",id:R});return 1}if(!z.ok){if($(z.error),Q)N(Z,{error:z.error,candidates:z.ambiguous??[]});return z.ambiguous?2:1}let Y=z.item.docs;if(!Y||Y.body===void 0){let H=z.item.repository??z.item.homepage;if($(`${_(z.item)} carries no documentation in the catalog${H?` \u2014 the publisher's own is at ${H}`:""}`),Q)N(Z,{id:_(z.item),docs:null,...H?{repository:H}:{}});return 1}if(Q)return N(Z,{id:_(z.item),docs:Y}),0;if(X(nJ(Y.body)),Y.truncated)$(`\u2014 truncated: ${NJ(Y.bytes)} upstream, read the rest at ${Y.source}`);return 0}if(A==="validate"){if(R===void 0)return G("usage: rovecode market validate <path|url> [--kind skill|plugin]");let z=D("--kind");if(z!==void 0&&z!=="skill"&&z!=="plugin")return G("validate takes --kind skill or --kind plugin");let Y,H=/^https?:\/\//i.test(R),K=(W)=>{if($(W),Q)N(Z,{ok:!1,error:W,source:R});return 1};if(H){if(F)return G("--offline and a URL cannot both be meant \u2014 give a local path, or drop --offline");try{let W=await fetch(R,{headers:{"user-agent":"rovecode-market-validate"}});if(!W.ok)return K(`${R}: HTTP ${W.status}`);Y=await W.text()}catch(W){return K(`${R}: ${W instanceof Error?W.message:String(W)}`)}}else try{Y=mJ(R,"utf8")}catch(W){return K(`${R}: ${W instanceof Error?W.message:String(W)}`)}let P=ZJ(Y,{...z?{kind:z}:{},filename:R});if(Q)return N(Z,P),P.ok?0:1;for(let W of $J(P,R))X(W);return P.ok?0:1}if(A==="remove"){let z=await j(R,E);if(!z.ok){if($(z.error),Q)N(Z,{ok:!1,error:z.error,candidates:z.ambiguous??[]});return z.ambiguous?2:1}let Y=u(z.item,V,B,J.includes("--project")?"project":void 0);if(Y===void 0){let P=`${_(z.item)} is not installed here`;if($(P),Q)N(Z,{ok:!1,error:P,id:_(z.item),installed:!1});return 1}let H=Z.tty??process.stdin.isTTY===!0;if(!J.includes("--yes")){if(Q)return N(Z,{ok:!1,needsApproval:!0,id:_(z.item),path:Y.path,scope:Y.scope}),$("nothing removed: pass --yes to confirm"),1;if(!H)return $(`nothing removed: ${_(z.item)} lives at ${Y.path} \u2014 rerun on a terminal, or pass --yes`),1;X(`${_(z.item)} ${Y.path}${Y.scope==="project"?" (this repo)":""}`);let P=(await(Z.plain??i)("remove this? [y/N] ")).trim().toLowerCase();if(P!=="y"&&P!=="yes")return X("nothing removed"),1}let K=CJ(z.item,V,B,J.includes("--project")?"project":void 0);if(!K.ok){if($(K.error),Q)N(Z,{ok:!1,error:K.error,id:_(z.item)});return 1}if(Q)return N(Z,{ok:!0,removed:_(z.item),path:K.path}),0;return X(`removed ${_(z.item)} from ${K.path}`),0}if(A==="install"){let z=await j(R,E);if(!z.ok){if($(z.error),Q)N(Z,{error:z.error,candidates:z.ambiguous??[]});else for(let y of z.ambiguous??[])$(` ${_(y)} ${y.description}`);return z.ambiguous?2:1}let Y=D("--pick"),H=Y===void 0?void 0:Number(Y);if(H!==void 0&&!Number.isInteger(H))return G("--pick takes a number");let K=D("--as"),P=Z.model??await tJ(),W=D("--ref");if(W!==void 0&&W.trim()==="")return G("--ref needs a branch, tag or commit");let T=J.includes("--local")?!0:J.includes("--no-local")?!1:void 0,M={scope:C,cwd:V,home:B,...H!==void 0?{pick:H}:{},...K!==void 0?{as:K}:{},...W!==void 0?{ref:W}:{},...Z.prereqEnv!==void 0?{prereqEnv:Z.prereqEnv}:{},...P!==void 0?{model:P}:{},...T!==void 0?{local:T}:{}};return QJ(z.item,M,{out:X,err:$,json:Q,yes:J.includes("--yes"),tty:Z.tty??process.stdin.isTTY===!0,secret:Z.secret??o,plain:Z.plain??i,verb:"install",dryRun:J.includes("--dry-run"),run:{...Z.run,...J.includes("--force")?{force:!0}:{},...F?{offline:!0}:{}}})}return G(`unknown command "${A}"`)}async function tJ(){try{let{resolveProvider:J}=await import("./stream-4wmyaypz.js"),Z=J();if(!Z)return;let X=process.env.ROVECODE_MODEL??Z.defaultModel;return X?{provider:Z.id,model:X}:void 0}catch{return}}async function i(J){let Z=wJ({input:process.stdin,output:process.stderr});try{return await new Promise((X)=>Z.question(J,X))}finally{Z.close()}}export{nJ as safeForTerminal,iJ as infoLines,GX as cmdMarket,_J as SUBCOMMAND_FLAGS,n as MARKET_USAGE};
5
+ `)),0;let I=()=>{let z=D("--kind");if(z===void 0)return;return["mcp","skill","plugin"].includes(z)?z:G("--kind takes mcp, skill or plugin")};if(A==="search"){let z=I();if(z===2)return 2;let Y=S.slice(1).join(" "),H=await h(Y,E),K=z?H.items.filter((W)=>W.kind===z):H.items,P=g(K,V,B);if(Q)return N(Z,{items:P,sources:H.sources,notes:H.notes}),P.length===0?1:0;for(let W of H.notes)$(`market: ${W}`);if(P.length===0){let W=Object.entries(H.sources).filter(([,T])=>!T.ok);$(Y?`nothing matches "${Y}"`:"the market is empty");for(let[T,M]of W)if(!M.ok)$(` ${T}: ${M.reason}`);return 1}for(let W of P)X(`${d(W)}${zJ(W)}`);return 0}if(A==="sources"){let z=S.slice(1).join(" ")||"mcp",Y=F?await f(E):await h(z,E);if(Q)return N(Z,{sources:Y.sources,notes:Y.notes,count:Y.items.length,probe:F?null:z,offline:F}),Object.values(Y.sources).every((H)=>H.ok)?0:1;if(F)X("--offline: the registry was not asked");else X(`probed with "${z}"`);for(let[H,K]of Object.entries(Y.sources)){let P=!K.ok?`FAILED \u2014 ${K.reason}`:K.from==="live"?"answered just now":K.from==="cache"?`from the cache${K.ageMs?` (${Math.round(K.ageMs/1000)}s old)`:""}`:K.from==="skipped"?`not consulted \u2014 ${K.why}`:"built in / on disk";X(`${H.padEnd(14)} ${P}`)}return X(`${String(Y.items.length).padStart(14)} items visible right now`),Object.values(Y.sources).every((H)=>H.ok)?0:1}if(A==="verify"){let z=S[1],Y=[];for(let K of["user","project"])for(let P of WJ(K,V,B)){let W=`${P.kind}:${P.id}`;if(z!==void 0&&z!==W&&z!==P.id)continue;Y.push({id:W,result:P.kind==="mcp"?{state:"not-applicable",why:"an MCP entry is a line inside a shared mcp.json, not a folder of its own"}:DJ(P.digest,P.target)})}if(Q){if(N(Z,Y),Y.length===0)return z!==void 0?1:0;return Y.some((K)=>K.result.state==="changed"||K.result.state==="missing")?1:0}if(Y.length===0)return X(z!==void 0?`nothing recorded for "${z}"`:"nothing installed through the market yet"),z!==void 0?1:0;for(let K of Y)X(KJ(K.id,K.result));let H=Y.filter((K)=>K.result.state==="changed"||K.result.state==="missing").length;if(H>0)$(`${H} item${H===1?" is":"s are"} not what was installed \u2014 reinstall with \`market install <id> --force\`, or keep the edit`);return H>0?1:0}if(A==="list"){let z=J.includes("--all"),Y=I();if(Y===2)return 2;let H=await f(E),K=g(H.items,V,B).filter((W)=>(z||W.installed)&&(Y===void 0||W.kind===Y)),P=K.map((W)=>W.installed?{...W,origin:k(W,W.installed.scope,V,B)??null}:W);if(Q)return N(Z,P),0;if(K.length===0){let W=Y===void 0?"":`${Y==="mcp"?"MCP server":Y} `;return X(z?Y===void 0?"the market is empty":`the market has no ${W}items`:`${Y===void 0?"nothing ":`no ${W}`}installed here yet \u2014 \`rovecode market search${Y?` --kind ${Y}`:""}\` to look around`),0}for(let W of K)if(X(`${d(W)}${zJ(W)}`),W.installed)X(` from ${HJ(k(W,W.installed.scope,V,B))}`);return 0}if(A==="update"){let z=await f(E),Y=g(z.items,V,B).filter((U)=>U.installed),H=Y.filter((U)=>U.installed.updateAvailable===!0||U.version===void 0||U.installed.version===void 0),K=S[1],P=J.includes("--all");if(K===void 0&&!P){if(Q)return N(Z,H),0;if(H.length===0)return X("everything installed is at the catalog's version"),0;for(let U of H){let v=U.installed.version,L=U.version;X(v!==void 0&&L!==void 0?`${_(U)} ${v} \u2192 ${L}`:`${_(U)} version unknown (${v===void 0?"nothing on disk says one":"the catalog states none"}) \u2014 updating reinstalls it`)}return X("rovecode market update <id> \xB7 rovecode market update --all"),0}let W=P&&J.includes("--yes")&&!J.includes("--yes-plugins"),T=H;if(K!==void 0){let U=await j(K,E);if(!U.ok){if($(U.error),Q)N(Z,{ok:!1,error:U.error,candidates:U.ambiguous??[]});return U.ambiguous?2:1}let v=Y.find((L)=>L.id===U.item.id&&L.kind===U.item.kind);if(v===void 0){let L=`${_(U.item)} is not installed here \u2014 rovecode market install ${_(U.item)}`;if($(L),Q)N(Z,{ok:!1,error:L,id:_(U.item),installed:!1});return 1}T=[v]}let M=W?T.filter((U)=>U.kind==="plugin"):[];if(M.length)T=T.filter((U)=>U.kind!=="plugin");let y=[],a=(U)=>{if(Q)N(Z,{ok:U,results:y,skipped:M.map(_)})};if(T.length===0&&M.length===0){if(Q)a(!0);else X("everything installed is at the catalog's version");return 0}let RJ={out:X,err:$,json:Q,yes:J.includes("--yes"),tty:Z.tty??process.stdin.isTTY===!0,secret:Z.secret??o,plain:Z.plain??i,verb:"update",dryRun:J.includes("--dry-run"),run:{...Z.run,force:!0,...F?{offline:!0}:{}},...Q?{collect:(U)=>{y.push(U)}}:{}},m=0;if(M.length&&!Q)X(`${M.length} plugin${M.length>1?"s":""} skipped \u2014 a plugin update runs new code: ${M.map(_).join(", ")}`),X(" rovecode market update <id> --yes \xB7 or --yes-plugins to take them all");for(let U of T){let v=U.kind==="mcp"?k(U,U.installed.scope,V,B)?.package!==void 0:void 0,L={scope:U.installed.scope,cwd:V,home:B,...Z.prereqEnv!==void 0?{prereqEnv:Z.prereqEnv}:{},...v!==void 0?{local:v}:{}},r=await QJ(U,L,RJ);if(r!==0)m=r}return a(m===0),m}let R=S[1];if(["info","install","remove","docs"].includes(A)&&R===void 0)return G(`market ${A} needs a name`);if(A==="info"){let z=await j(R,E);if(z.ok&&z.item.source==="catalog"&&z.item.publisher.startsWith("unknown (")&&z.item.kind==="mcp"){if($(`"${R}" is not in the catalog or the registry \u2014 \`market install\` would treat it as an npm package, but there is nothing here to describe`),Q)N(Z,{error:"not found",id:R});return 1}if(!z.ok){if($(z.error),Q)N(Z,{error:z.error,candidates:z.ambiguous??[]});return z.ambiguous?2:1}if(Q)return N(Z,{...z.item,installed:u(z.item,V,B)}),0;for(let Y of iJ(z.item,V,B))X(Y);return 0}if(A==="docs"){let z=await j(R,E);if(z.ok&&z.item.source==="catalog"&&z.item.publisher.startsWith("unknown (")&&z.item.kind==="mcp"){if($(`"${R}" is not in the catalog or the registry \u2014 nothing here has documentation`),Q)N(Z,{error:"not found",id:R});return 1}if(!z.ok){if($(z.error),Q)N(Z,{error:z.error,candidates:z.ambiguous??[]});return z.ambiguous?2:1}let Y=z.item.docs;if(!Y||Y.body===void 0){let H=z.item.repository??z.item.homepage;if($(`${_(z.item)} carries no documentation in the catalog${H?` \u2014 the publisher's own is at ${H}`:""}`),Q)N(Z,{id:_(z.item),docs:null,...H?{repository:H}:{}});return 1}if(Q)return N(Z,{id:_(z.item),docs:Y}),0;if(X(nJ(Y.body)),Y.truncated)$(`\u2014 truncated: ${NJ(Y.bytes)} upstream, read the rest at ${Y.source}`);return 0}if(A==="validate"){if(R===void 0)return G("usage: rovecode market validate <path|url> [--kind skill|plugin]");let z=D("--kind");if(z!==void 0&&z!=="skill"&&z!=="plugin")return G("validate takes --kind skill or --kind plugin");let Y,H=/^https?:\/\//i.test(R),K=(W)=>{if($(W),Q)N(Z,{ok:!1,error:W,source:R});return 1};if(H){if(F)return G("--offline and a URL cannot both be meant \u2014 give a local path, or drop --offline");try{let W=await fetch(R,{headers:{"user-agent":"rovecode-market-validate"}});if(!W.ok)return K(`${R}: HTTP ${W.status}`);Y=await W.text()}catch(W){return K(`${R}: ${W instanceof Error?W.message:String(W)}`)}}else try{Y=mJ(R,"utf8")}catch(W){return K(`${R}: ${W instanceof Error?W.message:String(W)}`)}let P=ZJ(Y,{...z?{kind:z}:{},filename:R});if(Q)return N(Z,P),P.ok?0:1;for(let W of $J(P,R))X(W);return P.ok?0:1}if(A==="remove"){let z=await j(R,E);if(!z.ok){if($(z.error),Q)N(Z,{ok:!1,error:z.error,candidates:z.ambiguous??[]});return z.ambiguous?2:1}let Y=u(z.item,V,B,J.includes("--project")?"project":void 0);if(Y===void 0){let P=`${_(z.item)} is not installed here`;if($(P),Q)N(Z,{ok:!1,error:P,id:_(z.item),installed:!1});return 1}let H=Z.tty??process.stdin.isTTY===!0;if(!J.includes("--yes")){if(Q)return N(Z,{ok:!1,needsApproval:!0,id:_(z.item),path:Y.path,scope:Y.scope}),$("nothing removed: pass --yes to confirm"),1;if(!H)return $(`nothing removed: ${_(z.item)} lives at ${Y.path} \u2014 rerun on a terminal, or pass --yes`),1;X(`${_(z.item)} ${Y.path}${Y.scope==="project"?" (this repo)":""}`);let P=(await(Z.plain??i)("remove this? [y/N] ")).trim().toLowerCase();if(P!=="y"&&P!=="yes")return X("nothing removed"),1}let K=CJ(z.item,V,B,J.includes("--project")?"project":void 0);if(!K.ok){if($(K.error),Q)N(Z,{ok:!1,error:K.error,id:_(z.item)});return 1}if(Q)return N(Z,{ok:!0,removed:_(z.item),path:K.path}),0;return X(`removed ${_(z.item)} from ${K.path}`),0}if(A==="install"){let z=await j(R,E);if(!z.ok){if($(z.error),Q)N(Z,{error:z.error,candidates:z.ambiguous??[]});else for(let y of z.ambiguous??[])$(` ${_(y)} ${y.description}`);return z.ambiguous?2:1}let Y=D("--pick"),H=Y===void 0?void 0:Number(Y);if(H!==void 0&&!Number.isInteger(H))return G("--pick takes a number");let K=D("--as"),P=Z.model??await tJ(),W=D("--ref");if(W!==void 0&&W.trim()==="")return G("--ref needs a branch, tag or commit");let T=J.includes("--local")?!0:J.includes("--no-local")?!1:void 0,M={scope:C,cwd:V,home:B,...H!==void 0?{pick:H}:{},...K!==void 0?{as:K}:{},...W!==void 0?{ref:W}:{},...Z.prereqEnv!==void 0?{prereqEnv:Z.prereqEnv}:{},...P!==void 0?{model:P}:{},...T!==void 0?{local:T}:{}};return QJ(z.item,M,{out:X,err:$,json:Q,yes:J.includes("--yes"),tty:Z.tty??process.stdin.isTTY===!0,secret:Z.secret??o,plain:Z.plain??i,verb:"install",dryRun:J.includes("--dry-run"),run:{...Z.run,...J.includes("--force")?{force:!0}:{},...F?{offline:!0}:{}}})}return G(`unknown command "${A}"`)}async function tJ(){try{let{resolveProvider:J}=await import("./stream-gmeyewds.js"),Z=J();if(!Z)return;let X=process.env.ROVECODE_MODEL??Z.defaultModel;return X?{provider:Z.id,model:X}:void 0}catch{return}}async function i(J){let Z=wJ({input:process.stdin,output:process.stderr});try{return await new Promise((X)=>Z.question(J,X))}finally{Z.close()}}export{nJ as safeForTerminal,iJ as infoLines,GX as cmdMarket,_J as SUBCOMMAND_FLAGS,n as MARKET_USAGE};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Dc as F,Gc as G}from"./main-wpkyraxh.js";import{jd as x,ld as P}from"./main-n6qrdbmy.js";import{Ed as C}from"./main-kwwsz6rq.js";import{Ji as k}from"./main-s9v8k74e.js";import{$l as _,bm as v}from"./main-b8zq261k.js";import"./main-wk2csfnj.js";import{nm as A,pm as O,qm as X,um as T,vm as j}from"./main-y5c82rxr.js";import"./main-ys6zj3yr.js";import"./main-mjt2p7aj.js";import{$m as L,Lm as H,Nm as R}from"./main-2yeveeve.js";import"./main-0jys2ccn.js";import{dn as U,kn as N,mn as b}from"./main-nqveez48.js";import"./main-qsevpgsv.js";P();j();v();C();N();L();import{existsSync as y,readFileSync as S}from"fs";import{join as M}from"path";var w="usage: rovecode mcp login <name> \u2014 a url server from ~/.rovecode/mcp.json or a TRUSTED .rovecode/mcp.json / .mcp.json";function u(z){if(!y(z))return;let J;try{J=JSON.parse(S(z,"utf8"))}catch(q){throw Error(`${z}: invalid JSON (${X(q)}) \u2014 fix or remove it by hand; refusing to overwrite`)}if(!O(J))throw Error(`${z}: root is not an object \u2014 fix or remove it by hand; refusing to overwrite`)}async function f(z,J,q){if(z.length===0)return q.err(w),1;let K=A(J);try{u(K)}catch(B){return q.err(`error: ${X(B)}`),2}let V=q.home??H(),W=[],Q=T(J,W,{home:V,trusted:b(U(V))}).find((B)=>B.name===z);for(let B of W)q.err(`warning: ${B}`);if(!Q)return q.err(`error: no MCP server "${z}" in ${K}, .mcp.json (trusted files only \u2014 rovecode mcp trust) or ${M(V,"mcp.json")}`),1;if(Q.transport==="stdio"||Q.url===void 0)return q.err(`error: MCP server "${z}" is a stdio server \u2014 OAuth login applies to url servers only`),1;if(Q.enabled===!1)return q.err(`error: MCP server "${z}" is disabled (enabled: false) \u2014 enable it first`),1;let Y=q.signal??new AbortController().signal,Z={...k(),...q.oauth};q.out(`rovecode mcp login ${z} \u2014 ${Q.transport} ${Q.url}`);let $;try{$=await _(Q,{notify:(B)=>{for(let I of G(B))q.out(` ${I}`)},signal:Y},{...Z,...q.timeoutMs!==void 0?{timeoutMs:q.timeoutMs}:{}})}catch(B){if(Y.aborted)return q.err("login cancelled"),130;return q.err(`error: ${B instanceof Error?B.message:String(B)}`),1}let D=`stored OAuth token for MCP server "${z}" in ${R()} (${F($.expires,Z.now())})`,E=await l(Q,q.connectTimeoutMs);if(E===void 0)return q.out(`${D} \u2014 connected`),0;return q.out(D),q.err(`error: verification connect failed: ${E}`),1}async function l(z,J=1e4){let q=new x([z],{connectTimeoutMs:J});try{let K=await q.connect();return K.failed[0]?.error??(K.connected.includes(z.name)?void 0:"not connected")}finally{await q.close()}}async function p(z,J,q){let K=new AbortController,V=()=>K.abort();process.once("SIGINT",V);try{return await f(z[0]??"",J,{out:(W)=>q.out(W),err:(W)=>q.err(W),signal:K.signal,...q.home!==void 0?{home:q.home}:{}})}finally{process.removeListener("SIGINT",V)}}export{f as runMcpLogin,p as cmdMcpLogin,w as MCP_LOGIN_USAGE};
2
+ import{Hc as F,Kc as G}from"./main-5ywnwthm.js";import{id as _,kd as v}from"./main-kyn0xnsg.js";import{Pd as x,Rd as P}from"./main-0mtcdbs7.js";import{Wd as C}from"./main-pn1w7a7j.js";import"./main-rg0wn0xf.js";import"./main-0z1w2zsg.js";import{lj as k}from"./main-pknhvrmj.js";import"./main-9etavkew.js";import{Am as X,Em as T,Fm as j,xm as A,zm as O}from"./main-7rn6bqje.js";import{$m as L,Lm as H,Nm as R}from"./main-2yeveeve.js";import"./main-0jys2ccn.js";import{dn as U,kn as N,mn as b}from"./main-nqveez48.js";import"./main-qsevpgsv.js";P();j();v();C();N();L();import{existsSync as y,readFileSync as S}from"fs";import{join as M}from"path";var w="usage: rovecode mcp login <name> \u2014 a url server from ~/.rovecode/mcp.json or a TRUSTED .rovecode/mcp.json / .mcp.json";function u(z){if(!y(z))return;let J;try{J=JSON.parse(S(z,"utf8"))}catch(q){throw Error(`${z}: invalid JSON (${X(q)}) \u2014 fix or remove it by hand; refusing to overwrite`)}if(!O(J))throw Error(`${z}: root is not an object \u2014 fix or remove it by hand; refusing to overwrite`)}async function f(z,J,q){if(z.length===0)return q.err(w),1;let K=A(J);try{u(K)}catch(B){return q.err(`error: ${X(B)}`),2}let V=q.home??H(),W=[],Q=T(J,W,{home:V,trusted:b(U(V))}).find((B)=>B.name===z);for(let B of W)q.err(`warning: ${B}`);if(!Q)return q.err(`error: no MCP server "${z}" in ${K}, .mcp.json (trusted files only \u2014 rovecode mcp trust) or ${M(V,"mcp.json")}`),1;if(Q.transport==="stdio"||Q.url===void 0)return q.err(`error: MCP server "${z}" is a stdio server \u2014 OAuth login applies to url servers only`),1;if(Q.enabled===!1)return q.err(`error: MCP server "${z}" is disabled (enabled: false) \u2014 enable it first`),1;let Y=q.signal??new AbortController().signal,Z={...k(),...q.oauth};q.out(`rovecode mcp login ${z} \u2014 ${Q.transport} ${Q.url}`);let $;try{$=await _(Q,{notify:(B)=>{for(let I of G(B))q.out(` ${I}`)},signal:Y},{...Z,...q.timeoutMs!==void 0?{timeoutMs:q.timeoutMs}:{}})}catch(B){if(Y.aborted)return q.err("login cancelled"),130;return q.err(`error: ${B instanceof Error?B.message:String(B)}`),1}let D=`stored OAuth token for MCP server "${z}" in ${R()} (${F($.expires,Z.now())})`,E=await l(Q,q.connectTimeoutMs);if(E===void 0)return q.out(`${D} \u2014 connected`),0;return q.out(D),q.err(`error: verification connect failed: ${E}`),1}async function l(z,J=1e4){let q=new x([z],{connectTimeoutMs:J});try{let K=await q.connect();return K.failed[0]?.error??(K.connected.includes(z.name)?void 0:"not connected")}finally{await q.close()}}async function p(z,J,q){let K=new AbortController,V=()=>K.abort();process.once("SIGINT",V);try{return await f(z[0]??"",J,{out:(W)=>q.out(W),err:(W)=>q.err(W),signal:K.signal,...q.home!==void 0?{home:q.home}:{}})}finally{process.removeListener("SIGINT",V)}}export{f as runMcpLogin,p as cmdMcpLogin,w as MCP_LOGIN_USAGE};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{T as $q,W as Dq,Y as Kq}from"./main-yr0ksc0h.js";import{$ as zq,_ as L,aa as Bq,ba as Jq,ca as Qq,da as Xq,ea as v,fa as Yq,ga as Zq,ha as Uq}from"./main-xy53xf0r.js";import{ia as a,ka as s,la as r,oa as e,pa as qq,qa as Tq}from"./main-7c5thhjd.js";import{Cc as p,Dc as b,Ec as l,Fc as Eq}from"./main-vqak588n.js";import{Sd as R,Td as t,Ud as n,Vd as S,Wd as jq}from"./main-pn1w7a7j.js";import{Dm as o,Fm as Vq,ym as y}from"./main-7rn6bqje.js";import{$m as i,Lm as c,_m as d}from"./main-2yeveeve.js";import"./main-0jys2ccn.js";import"./main-nqveez48.js";import{xn as Hq}from"./main-qsevpgsv.js";i();i();Eq();Uq();Vq();jq();Tq();Kq();import{createInterface as Wq}from"readline";var f=["usage: rovecode mcp <command>"," search [query] the curated list, then the MCP registry's name matches (cached a day)"," info <name> everything about one server: publisher, version, what it runs or connects to, what it asks"," add <name> [--project] [--pick N] [--as <name>] [--yes] [--force] [--local | --no-local]"," install: shows the exact command/URL + source, asks (masked) for keys by name, then writes"," ~/.rovecode/mcp.json \u2014 or .rovecode/mcp.json with --project (keys stay out of it: ${NAME})"," --local: an npx server is installed ONCE (npm, ~25 MB under ~/.rovecode/mcp) and started with"," node in ~0.4 s instead of ~2 s; --no-local keeps npx; neither \u2192 a terminal asks, --yes keeps npx"," remove <name> [--project] delete the entry from that file"," list every configured server, by file (user \xB7 .mcp.json \xB7 project), with the project files' trust"," show --project each project file's servers \u2014 exact command/URL, env NAMES \u2014 and whether it is trusted here"," trust \xB7 untrust approve this repo's .rovecode/mcp.json and .mcp.json as they are now (any edit asks again);"," files you write through `add --project` are trusted as you approve them"," login <name> OAuth sign-in to a url server through the browser (port #76, mcp-login.ts): the token"," lands in credentials.json under mcp:<name>; only servers the runtime itself would load","restart rovecode after add/remove/trust \u2014 servers are read once per process (docs/mcp-market.md)"];function u(z,J){let Q=S(z);if(Q.length===0)return["no project MCP files here (.rovecode/mcp.json, .mcp.json)"];let B=new Proxy({},{get:()=>"set"}),q=[];for(let Z of Q){let G=R(J,Z);q.push(`${Z} \u2014 ${G==="trusted"?"trusted on this machine":"NOT trusted: nothing in it loads until `rovecode mcp trust`"}`);let U=[];for(let _ of o(Z,U,B))q.push(` ${v(_)}`);for(let _ of U)q.push(` ! ${_}`)}return q}async function Aq(z){process.stderr.write(z);let J=Wq({input:process.stdin});return new Promise((Q)=>{J.once("line",(B)=>{J.close(),Q(B.trim())}),J.once("close",()=>Q(""))})}function A(z,J){return z.includes(J)}function m(z,J){let Q=z.indexOf(J);return Q===-1?void 0:z[Q+1]}function Gq(z){let J=[];for(let Q=0;Q<z.length;Q++){let B=z[Q];if(B==="--pick"||B==="--as"){Q++;continue}if(!B.startsWith("--"))J.push(B)}return J}function _q(z){let J=z.source==="curated"?"curated ":"registry",Q=[z.title,z.version,z.status?`[${z.status}]`:void 0].filter((B)=>B!==void 0).join(" ");return`${z.key.padEnd(40)} ${J} ${Q}${z.description?`${Q?" \u2014 ":""}${z.description}`:""}`.trimEnd()}function xq(z){let J=[`${z.key}${z.title?` (${z.title})`:""}${z.version?` v${z.version}`:""}${z.status?` [${z.status}]`:""}`,` ${z.description}`,` source ${z.source==="curated"?"curated list":"MCP registry"}`,` publisher ${z.publisher??"unknown"}`];if(z.repository)J.push(` repo ${z.repository}`);if(z.homepage)J.push(` home ${z.homepage}`);if(z.installs.length===0)J.push(" install nothing rovecode can launch (no stdio package, no streamable-http remote)");if(z.installs.forEach((Q,B)=>{if(J.push(` install ${B} ${Q.kind==="stdio"?`runs ${l(Q)}`:`connects ${Q.url}`}`),Q.kind==="stdio"){for(let q of Q.env)J.push(` env ${q.name}${q.secret?" (secret)":""}${q.required?"":" optional"}${q.description?` \u2014 ${q.description}`:""}`);for(let q of Q.pending)J.push(` needs ${q}`)}else for(let q of Q.headers)J.push(` header ${q.name}${q.template?`: ${q.template}`:""}${q.secret?" (secret)":""}${q.required?"":" optional"}`)}),z.installs.length>1)J.push(` pick one with: rovecode mcp add ${z.key} --pick N`);return J}async function Nq(z,J){let Q={};for(let B of z.asks){let q=B.secret&&z.scope==="project";if(!J.tty||q){if(B.required)J.err(`${B.name} is not set \u2014 it will be written as \${${B.name}} and read from your environment at launch`);continue}let Z=`${B.name}${B.description?` (${B.description})`:""}${B.required?"":" [optional, enter to skip]"}: `;if(Q[B.name]=B.secret?await J.secret(Z):await J.plain(Z),B.required&&Q[B.name].length===0)J.err(`${B.name} is not set \u2014 it will be written as \${${B.name}} and read from your environment at launch`)}for(let B of z.pending){if(!J.tty)continue;let q=(await J.plain(`${B}: `)).trim();if(q.length>0)Q[B]=q}return Q}async function Rq(z,J={}){let Q=J.cwd??process.cwd(),B=J.home??c(),q=J.out??console.log,Z=J.err??console.error,G={home:B,...J.market},U=J.tty??process.stdin.isTTY===!0,_=J.secret??((X)=>d(X)),x=J.plain??Aq,[K,...j]=z,k={search:[],info:[],add:["--project","--pick","--as","--yes","--force","--local","--no-local"],remove:["--project"],list:[],show:["--project"],trust:["--yes","--project"],untrust:[],login:[],help:[]};if(K!==void 0&&K in k){let X=new Set(["--pick","--as"]),Y=!1;for(let D of j){if(Y){Y=!1;continue}if(D.startsWith("--")){if(!k[K].includes(D))return Z(`unknown flag ${D} for "rovecode mcp ${K}" \u2014 see: rovecode mcp help`),2;if(X.has(D))Y=!0}}}let E=Gq(j),W=A(j,"--project")?"project":"user";switch(K){case void 0:case"help":case"--help":case"-h":for(let X of f)q(X);return K===void 0?2:0;case"search":{let X=await p(E.join(" "),G);for(let Y of X.notes)Z(`note: ${Y}`);if(X.entries.length===0)return q(`nothing matches "${E.join(" ")}"`),0;for(let Y of X.entries)q(_q(Y));return q(`\u2192 rovecode mcp info <name> \xB7 rovecode mcp add <name>${X.fromCache?" (registry results from cache)":""}`),0}case"info":{if(!E[0])return Z("usage: rovecode mcp info <name>"),2;let X=await b(E[0],G);for(let Y of X.notes)Z(`note: ${Y}`);if(!X.entry)return 1;for(let Y of xq(X.entry))q(Y);return 0}case"add":{if(!E[0])return Z("usage: rovecode mcp add <name> [--project] [--pick N] [--as <name>] [--yes] [--force]"),2;let X=await b(E[0],G);for(let $ of X.notes)Z(`note: ${$}`);if(!X.entry)return 1;let Y=m(j,"--pick"),D=Y===void 0?void 0:Number(Y);if(D!==void 0&&(!Number.isInteger(D)||D<0))return Z(`--pick wants a whole number, not "${Y}"`),2;let V=m(j,"--as"),N={scope:W,cwd:Q,home:B,...D!==void 0?{pick:D}:{},...V!==void 0?{name:V}:{}},O=L(X.entry,N);if("error"in O)return Z(O.error),1;let I=A(j,"--local")?!0:A(j,"--no-local")?!1:void 0,C=a(O.install);if(C!==void 0&&I===void 0&&W==="user"&&!A(j,"--yes")&&U){q(`${C.spec} would start through npx: ~2 s at every start, re-resolving the package (and asking the npm registry) each time.`),q("Install it once instead? npm puts the package's code under ~/.rovecode/mcp \u2014 typically 20\u201330 MB and a few seconds, one time;"),q("it then starts in ~0.4 s and needs no network to start. No keeps the npx line exactly as it is today.");let $=(await x(`install ${C.spec} once? [y/N] `)).trim().toLowerCase();I=$==="y"||$==="yes"}let H=I===!0?L(X.entry,{...N,local:!0}):O;if("error"in H)return Z(H.error),1;for(let $ of Jq(H))q($);if(!A(j,"--yes")){if(!U)return Z("nothing written: no terminal to confirm on \u2014 re-run with --yes after reading the lines above"),1;let $=(await x("install this? [y/N] ")).toLowerCase();if($!=="y"&&$!=="yes")return q("nothing written"),1}let h=await Nq(H,{secret:_,plain:x,tty:U,err:Z});if(h===null)return q("nothing written"),1;let w,T;if(H.local){let $=await s(H.local.pkg,H.local.prefix,J.spawn?{spawn:J.spawn}:{});if(!$.ok)return Z($.error),q("nothing written"),1;w=r($.pkg,H.local.pkg.rest),T={name:$.pkg.name,version:$.pkg.version,prefix:H.local.prefix,bin:$.pkg.bin,missing:$.pkg.missing,...$.pkg.integrity!==void 0?{integrity:$.pkg.integrity}:{},...$.pkg.resolved!==void 0?{resolved:$.pkg.resolved}:{}}}let M,P=zq(H,h,w);try{M=Qq(H.file,H.name,P,{replace:A(j,"--force"),...W==="project"?{trustHome:B}:{}}).trusted}catch($){return Z($ instanceof Error?$.message:String($)),1}if(q(`added "${H.name}" \u2192 ${H.file}${M===!0?" (trusted on this machine as written)":""}`),T){if($q(Dq({kind:"mcp",id:X.entry.key,source:X.entry.source,...X.entry.version!==void 0?{version:X.entry.version}:{}},{scope:W,target:H.file,package:T,installedBy:"mcp add"}),{cwd:Q,home:B}),q(`installed ${T.name} ${T.version} once \u2192 ${H.local.prefix}${T.integrity!==void 0?" (integrity recorded in installed.json)":""}`),T.missing?.length)Z(`record incomplete: ${T.missing.join("; ")}`)}if(M===!1)q("NOT trusted yet: that file already held servers you have not approved \u2014 rovecode mcp show, then rovecode mcp trust");let F=Zq(H,P);if(F.length)q(`fill in before use: ${F.join(", ")} \u2014 edit the args in that file; until then this server is skipped`);let g=Bq(H,P);if(g.length)q(`set ${g.join(", ")} in your environment \u2014 the file only names them`);if(F.length===0)q("restart rovecode to connect (servers are read once per process)");return 0}case"remove":{if(!E[0])return Z("usage: rovecode mcp remove <name> [--project]"),2;let X=y(Q,B),Y=W==="project"?X.project:X.user;try{if(!Xq(Y,E[0],W==="project"?{trustHome:B}:{}))return Z(`${Y} has no server named "${E[0]}"${W==="user"?" (project entries: add --project)":""}`),1}catch(D){return Z(D instanceof Error?D.message:String(D)),1}return q(`removed "${E[0]}" from ${Y}`),0}case"list":{let X=[],Y=Yq(Q,B,X);for(let V of X)Z(V);if(Y.length===0)return q("no MCP servers configured \u2014 rovecode mcp search <query>"),0;for(let V of Y){let N=V.scope==="user"?"":R(B,V.file)==="trusted"?"":" (file not trusted \u2014 off; rovecode mcp trust)";q(`${V.scope.padEnd(8)} ${v(V.server)}${N}`)}let D=qq(Y.filter((V)=>e(V.server)).map((V)=>V.server.name));if(D!==void 0)q(D);return 0}case"show":{for(let X of u(Q,B))q(X);return 0}case"login":return(await import("./mcp-login-wq7ktdek.js")).cmdMcpLogin(E,Q,{out:q,err:Z,home:B});case"trust":{let X=S(Q);if(X.length===0)return q("no project MCP files here (.rovecode/mcp.json, .mcp.json) \u2014 nothing to trust"),1;for(let Y of u(Q,B))q(Y);if(!A(j,"--yes")){if(!U)return Z("nothing trusted: no terminal to confirm on \u2014 re-run with --yes after reading the lines above"),1;let Y=(await x("trust these files as they are now? [y/N] ")).toLowerCase();if(Y!=="y"&&Y!=="yes")return q("nothing trusted"),1}for(let Y of X){let D=t(B,Y);q(D.ok?`trusted ${Y} (${D.digest.slice(0,12)}\u2026)`:D.reason)}return q("restart rovecode to connect \u2014 an edit to either file asks again"),0}case"untrust":{let Y=[y(Q).harvest,y(Q).project].filter((D)=>n(B,D));return q(Y.length?`untrusted ${Y.join(", ")}`:"nothing was trusted here"),0}default:Z(`unknown mcp command "${K}"`);for(let X of f)Z(X);return 2}}export{u as showLines,xq as infoLines,Rq as cmdMcp,Nq as askPlan,f as MCP_USAGE};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{d as w}from"./main-z13755t8.js";import{A as c,B as v,x as l,y as p}from"./main-8c1tbazx.js";import"./main-rsy72qmw.js";import"./main-jak598k9.js";import{dd as x,ed as k}from"./main-hqbz10aw.js";import"./main-2z3dek0b.js";import"./main-xfekqh9m.js";import"./main-rvetps99.js";import"./main-kba6zeyd.js";import"./main-2rzbexn2.js";import"./main-ywbxshqc.js";import"./main-qj2djy17.js";import"./main-6dtqmbt6.js";import"./main-rebtt91r.js";import"./main-a3f51n0x.js";import"./main-5py0rkmc.js";import{Ll as b,Sl as h}from"./main-6h9x282m.js";import"./main-vhrrq337.js";import"./main-ys6zj3yr.js";import"./main-2yeveeve.js";import"./main-0jys2ccn.js";import"./main-nqveez48.js";import{un as M}from"./main-qsevpgsv.js";h();class _{inner;tracker;constructor(j,B){this.inner=j;this.tracker=B}start(j,B){this.inner.start((G)=>{let J=this.tracker.feed(G);if(J.length>0)j(J)},B)}stop(){this.inner.stop()}drainInput(j,B){return this.inner.drainInput(j,B)}write(j){this.inner.write(j)}get columns(){return this.inner.columns}get rows(){return this.inner.rows}get kittyProtocolActive(){return this.inner.kittyProtocolActive}moveBy(j){this.inner.moveBy(j)}hideCursor(){this.inner.hideCursor()}showCursor(){this.inner.showCursor()}clearLine(){this.inner.clearLine()}clearFromCursor(){this.inner.clearFromCursor()}clearScreen(){this.inner.clearScreen()}setTitle(j){this.inner.setTitle(j)}setProgress(j){this.inner.setProgress(j)}}var E="\x1B[?1004h",N="\x1B[?1004l";function z(j,B){let G=j.replace(/[\x00-\x1f\x7f-\x9f]/g,(J)=>/\s/.test(J)?" ":"").replace(/\s+/g," ").trim();if(B<=0)return"";return G.length>B?`${G.slice(0,B-1)}\u2026`:G}var Y=(j,B)=>(j[B]??"")!=="",g=(j)=>(j.TERM_PROGRAM??"").replace(/[\s_.-]/g,"").toLowerCase();function O(j){let B=g(j),G=j.TERM??"",J=B==="ghostty"||G==="xterm-ghostty"||Y(j,"GHOSTTY_RESOURCES_DIR"),$=B==="itermapp"||B==="iterm"||B==="iterm2"||Y(j,"ITERM_SESSION_ID"),L=B==="kitty"||G==="xterm-kitty"||Y(j,"KITTY_WINDOW_ID"),D=B==="warpterminal"||B==="warp",H=B==="wezterm"||Y(j,"WEZTERM_VERSION");return J||$||L||D||H?"osc9":"bell"}var C=(j)=>Y(j,"TMUX");function I(j,B,G){if(j==="bell")return"\x07";let J=j==="osc9"?`\x1B]9;${B}\x07`:`\x1B]777;notify;rovecode;${B}\x07`;return G?`\x1BPtmux;${J.replace(/\x1b/g,"\x1B\x1B")}\x1B\\`:J}function P(j,B){if(j==="approval")return`approval needed: ${z(B.tool??"",40)} ${z(B.argsPreview??"",40)}`.trimEnd();if(j==="question")return`question: ${z(B.question??"",60)}`;let G=z(B.lastText??"",120);return G?`run finished: ${G}`:"run finished"}var S=(j)=>!Array.isArray(j);function F(j){let B=j.trim();if(B.startsWith("[")){let J;try{J=JSON.parse(B)}catch($){return{error:`not a JSON array (${$ instanceof Error?$.message:String($)})`}}if(!Array.isArray(J)||J.length===0||!J.every(($)=>typeof $==="string"&&$.length>0))return{error:"a JSON array must hold one or more non-empty strings"};return J}let G=B.split(/\s+/).filter((J)=>J.length>0);return G.length===0?{error:"empty command"}:G}class q{focused=!0;feed(j){if(!j.includes("\x1B["))return j;return j.replace(/\x1b\[([IO])/g,(B,G)=>{return this.focused=G==="I",""})}}var i=["auto","bell","osc9","osc777"],s=["unfocused","always"],T=(j)=>(j??"").trim().toLowerCase();function a(j,B={}){let G=B.env??process.env,J=B.settings??b(j),$={...J.user,...J.project},L=[],D,H=T(G.ROVECODE_NOTIFY);if(H==="off")D=void 0;else if(i.includes(H))D=H;else{if(H!=="")L.push(`notify: unknown value "${H}" in ROVECODE_NOTIFY \u2014 off | auto | bell | osc9 | osc777; using the settings files`);D=$.bell===!1?void 0:$.notify??"auto"}let Q=D==="auto"?O(G):D,K=$.notify_when??"unfocused",Z=T(G.ROVECODE_NOTIFY_WHEN);if(s.includes(Z))K=Z;else if(Z!=="")L.push(`notify_when: unknown value "${Z}" in ROVECODE_NOTIFY_WHEN \u2014 unfocused | always; using ${K}`);let V,U,A=G.ROVECODE_NOTIFY_COMMAND;if(A!==void 0&&A.trim()!=="")V=A,U="ROVECODE_NOTIFY_COMMAND";else{if(J.project.notify_command!==void 0)V=J.project.notify_command,U=J.projectPath;else if(J.dropped.includes("notify_command"))L.push(`notify_command: set by ${J.projectPath}, a repository file this machine has not approved \u2014 ignored (rovecode trust show \xB7 rovecode trust; in the TUI: /trust); set it in ~/.rovecode/settings.json or ROVECODE_NOTIFY_COMMAND to use your own`);if(V===void 0&&J.user.notify_command!==void 0)V=J.user.notify_command,U="~/.rovecode/settings.json"}let R;if(V!==void 0){let X=F(V);if(S(X))L.push(`notify_command (${U}): ${X.error} \u2014 the hook is off`);else{let W=x(X),u=k().check(X).decision;if(W!==null)L.push(`notify_command (${U}): "${X.join(" ")}" is a dangerous command (${W}) \u2014 the hook is off`);else if(u==="forbidden")L.push(`notify_command (${U}): execpolicy forbids "${X.join(" ")}" \u2014 the hook is off`);else R=X}}return{...Q!==void 0?{method:Q}:{},when:K,...R!==void 0?{hook:R,hookSource:U}:{},tmux:C(G),notes:L}}var y=400;function o(j,B,G){if(j==="approval")return{type:"approval-requested",cwd:G,tool:B.tool??"","args-preview":B.argsPreview??""};if(j==="question")return{type:"question-requested",cwd:G,question:B.question??""};return{type:"agent-turn-complete",cwd:G,"last-assistant-message":B.lastText??null}}var d=(j,B)=>Bun.spawn(j,B);function r(j=d){return(B)=>{j(B,{stdio:["ignore","ignore","ignore"]}).unref()}}var f=(j)=>j instanceof Error?j.message:String(j);class m{config;cwd;write;focused;spawn;note;seqOff=!1;hookOff=!1;notesShown=!1;decset=!1;constructor(j){this.config=j.config,this.cwd=j.cwd??process.cwd(),this.write=j.write??(()=>{}),this.focused=j.focused??(()=>!0),this.spawn=j.spawn??r(),this.note=j.note??(()=>{})}active(){return this.config.method!==void 0||this.config.hook!==void 0}showNotes(){if(this.notesShown)return;this.notesShown=!0;for(let j of this.config.notes)this.note(j,"warn")}focusOn(){if(this.showNotes(),!this.active())return!1;return this.decset=!0,this.emit(E),!0}focusOff(){if(!this.decset)return;this.decset=!1,this.emit(N)}fire(j,B){if(this.showNotes(),!(this.config.when==="always"||!this.focused()))return;let{method:G,hook:J}=this.config;if(G!==void 0)this.emit(I(G,P(j,B),this.config.tmux));if(J!==void 0&&!this.hookOff)this.runHook(J,o(j,B,this.cwd))}emit(j){if(this.seqOff)return;try{this.write(j)}catch(B){this.seqOff=!0,this.note(`notify: the terminal write failed (${f(B)}) \u2014 terminal notifications are off for this session`,"warn")}}runHook(j,B){try{this.spawn([...j,JSON.stringify(B)])}catch(G){this.hookOff=!0,this.note(`notify_command: could not start ${j[0]} (${f(G)}) \u2014 the hook is off for this session`,"warn")}}}function n(j,B){let G=!1,J=!1,$=!1,L=0,D,H={start(Q,K){let Z=L,V=j.start(Q,K),U=()=>{if(Z===L&&!J)J=!0,$=B.focusOn()};if(V)return V.then(U);U()},stop(){if(L++,$)$=!1,B.focusOff();J=!1,j.stop()},askApproval(Q,K,Z){if(J)B.fire("approval",{tool:Q,argsPreview:K});return j.askApproval(Q,K,Z)},askQuestion(Q,K){if(J)B.fire("question",{question:Q.question});return j.askQuestion(Q,K)},setBusy(Q,K){if(j.setBusy(Q,K),Q){G=!0,D=void 0;return}let Z=G&&K===void 0;if(G=!1,Z&&J)B.fire("run_end",{...D!==void 0?{lastText:D}:{}})},beginAssistant(){let Q=j.beginAssistant(),K="";return{append(Z){if(Q.append(Z),K.length<y)K=(K+Z).slice(0,y)},done(){Q.done(),D=K}}}};return new Proxy(j,{get(Q,K){if(typeof K==="string"&&Object.hasOwn(H,K))return H[K];let Z=Reflect.get(Q,K,Q);return typeof Z==="function"?Z.bind(Q):Z}})}function Qj(j,B=process.env,G=process.stdout,J=process.stdin,$=process.cwd()){let L=G.isTTY===!0,D=L?new q:void 0,H=w(j,B,G,{stdin:J,...D?{focus:D}:{}});if(!H){let{PiTuiRenderer:K}=(v(),M(c)),{ProcessTerminal:Z}=(p(),M(l));H=new K({cwd:$,terminal:D?new _(new Z,D):new Z})}if(J.isTTY!==!0)J.on?.("end",()=>{try{process.exit(0)}catch{}});let Q=new m({config:a($,{env:B}),cwd:$,write:L?(K)=>{G.write(K)}:()=>{},focused:()=>D?.focused??!0,note:(K,Z)=>H.addSystemNote(K,Z)});return n(H,Q)}export{n as withNotifications,a as resolveNotifyConfig,o as payloadFor,Qj as interactiveRenderer,r as defaultSpawner,m as Notifier,s as NOTIFY_WHENS,i as NOTIFY_METHODS};
2
+ import{t as w}from"./main-kqxnqjnv.js";import{N as l,O as p,Q as c,R as v}from"./main-2wwjex5j.js";import"./main-7c5thhjd.js";import"./main-73g7eff4.js";import{Jd as x,Kd as k}from"./main-w2n1303f.js";import"./main-3pjrb2hd.js";import"./main-t4xnd213.js";import"./main-1dchs7xv.js";import"./main-0z1w2zsg.js";import"./main-3gjqfh7a.js";import"./main-q3vsesf9.js";import"./main-8kjxbpw4.js";import"./main-3rxcvgna.js";import"./main-4wndhjdc.js";import"./main-ggcn7rd7.js";import"./main-0904f6ps.js";import{fm as b,mm as h}from"./main-prxxs70n.js";import"./main-n0t3973w.js";import"./main-mv40pcr2.js";import"./main-2yeveeve.js";import"./main-0jys2ccn.js";import"./main-nqveez48.js";import{un as M}from"./main-qsevpgsv.js";h();class _{inner;tracker;constructor(j,B){this.inner=j;this.tracker=B}start(j,B){this.inner.start((G)=>{let J=this.tracker.feed(G);if(J.length>0)j(J)},B)}stop(){this.inner.stop()}drainInput(j,B){return this.inner.drainInput(j,B)}write(j){this.inner.write(j)}get columns(){return this.inner.columns}get rows(){return this.inner.rows}get kittyProtocolActive(){return this.inner.kittyProtocolActive}moveBy(j){this.inner.moveBy(j)}hideCursor(){this.inner.hideCursor()}showCursor(){this.inner.showCursor()}clearLine(){this.inner.clearLine()}clearFromCursor(){this.inner.clearFromCursor()}clearScreen(){this.inner.clearScreen()}setTitle(j){this.inner.setTitle(j)}setProgress(j){this.inner.setProgress(j)}}var E="\x1B[?1004h",N="\x1B[?1004l";function z(j,B){let G=j.replace(/[\x00-\x1f\x7f-\x9f]/g,(J)=>/\s/.test(J)?" ":"").replace(/\s+/g," ").trim();if(B<=0)return"";return G.length>B?`${G.slice(0,B-1)}\u2026`:G}var Y=(j,B)=>(j[B]??"")!=="",g=(j)=>(j.TERM_PROGRAM??"").replace(/[\s_.-]/g,"").toLowerCase();function O(j){let B=g(j),G=j.TERM??"",J=B==="ghostty"||G==="xterm-ghostty"||Y(j,"GHOSTTY_RESOURCES_DIR"),$=B==="itermapp"||B==="iterm"||B==="iterm2"||Y(j,"ITERM_SESSION_ID"),L=B==="kitty"||G==="xterm-kitty"||Y(j,"KITTY_WINDOW_ID"),D=B==="warpterminal"||B==="warp",H=B==="wezterm"||Y(j,"WEZTERM_VERSION");return J||$||L||D||H?"osc9":"bell"}var C=(j)=>Y(j,"TMUX");function I(j,B,G){if(j==="bell")return"\x07";let J=j==="osc9"?`\x1B]9;${B}\x07`:`\x1B]777;notify;rovecode;${B}\x07`;return G?`\x1BPtmux;${J.replace(/\x1b/g,"\x1B\x1B")}\x1B\\`:J}function P(j,B){if(j==="approval")return`approval needed: ${z(B.tool??"",40)} ${z(B.argsPreview??"",40)}`.trimEnd();if(j==="question")return`question: ${z(B.question??"",60)}`;let G=z(B.lastText??"",120);return G?`run finished: ${G}`:"run finished"}var S=(j)=>!Array.isArray(j);function F(j){let B=j.trim();if(B.startsWith("[")){let J;try{J=JSON.parse(B)}catch($){return{error:`not a JSON array (${$ instanceof Error?$.message:String($)})`}}if(!Array.isArray(J)||J.length===0||!J.every(($)=>typeof $==="string"&&$.length>0))return{error:"a JSON array must hold one or more non-empty strings"};return J}let G=B.split(/\s+/).filter((J)=>J.length>0);return G.length===0?{error:"empty command"}:G}class q{focused=!0;feed(j){if(!j.includes("\x1B["))return j;return j.replace(/\x1b\[([IO])/g,(B,G)=>{return this.focused=G==="I",""})}}var i=["auto","bell","osc9","osc777"],s=["unfocused","always"],T=(j)=>(j??"").trim().toLowerCase();function a(j,B={}){let G=B.env??process.env,J=B.settings??b(j),$={...J.user,...J.project},L=[],D,H=T(G.ROVECODE_NOTIFY);if(H==="off")D=void 0;else if(i.includes(H))D=H;else{if(H!=="")L.push(`notify: unknown value "${H}" in ROVECODE_NOTIFY \u2014 off | auto | bell | osc9 | osc777; using the settings files`);D=$.bell===!1?void 0:$.notify??"auto"}let Q=D==="auto"?O(G):D,K=$.notify_when??"unfocused",Z=T(G.ROVECODE_NOTIFY_WHEN);if(s.includes(Z))K=Z;else if(Z!=="")L.push(`notify_when: unknown value "${Z}" in ROVECODE_NOTIFY_WHEN \u2014 unfocused | always; using ${K}`);let V,U,A=G.ROVECODE_NOTIFY_COMMAND;if(A!==void 0&&A.trim()!=="")V=A,U="ROVECODE_NOTIFY_COMMAND";else{if(J.project.notify_command!==void 0)V=J.project.notify_command,U=J.projectPath;else if(J.dropped.includes("notify_command"))L.push(`notify_command: set by ${J.projectPath}, a repository file this machine has not approved \u2014 ignored (rovecode trust show \xB7 rovecode trust; in the TUI: /trust); set it in ~/.rovecode/settings.json or ROVECODE_NOTIFY_COMMAND to use your own`);if(V===void 0&&J.user.notify_command!==void 0)V=J.user.notify_command,U="~/.rovecode/settings.json"}let R;if(V!==void 0){let X=F(V);if(S(X))L.push(`notify_command (${U}): ${X.error} \u2014 the hook is off`);else{let W=x(X),u=k().check(X).decision;if(W!==null)L.push(`notify_command (${U}): "${X.join(" ")}" is a dangerous command (${W}) \u2014 the hook is off`);else if(u==="forbidden")L.push(`notify_command (${U}): execpolicy forbids "${X.join(" ")}" \u2014 the hook is off`);else R=X}}return{...Q!==void 0?{method:Q}:{},when:K,...R!==void 0?{hook:R,hookSource:U}:{},tmux:C(G),notes:L}}var y=400;function o(j,B,G){if(j==="approval")return{type:"approval-requested",cwd:G,tool:B.tool??"","args-preview":B.argsPreview??""};if(j==="question")return{type:"question-requested",cwd:G,question:B.question??""};return{type:"agent-turn-complete",cwd:G,"last-assistant-message":B.lastText??null}}var d=(j,B)=>Bun.spawn(j,B);function r(j=d){return(B)=>{j(B,{stdio:["ignore","ignore","ignore"]}).unref()}}var f=(j)=>j instanceof Error?j.message:String(j);class m{config;cwd;write;focused;spawn;note;seqOff=!1;hookOff=!1;notesShown=!1;decset=!1;constructor(j){this.config=j.config,this.cwd=j.cwd??process.cwd(),this.write=j.write??(()=>{}),this.focused=j.focused??(()=>!0),this.spawn=j.spawn??r(),this.note=j.note??(()=>{})}active(){return this.config.method!==void 0||this.config.hook!==void 0}showNotes(){if(this.notesShown)return;this.notesShown=!0;for(let j of this.config.notes)this.note(j,"warn")}focusOn(){if(this.showNotes(),!this.active())return!1;return this.decset=!0,this.emit(E),!0}focusOff(){if(!this.decset)return;this.decset=!1,this.emit(N)}fire(j,B){if(this.showNotes(),!(this.config.when==="always"||!this.focused()))return;let{method:G,hook:J}=this.config;if(G!==void 0)this.emit(I(G,P(j,B),this.config.tmux));if(J!==void 0&&!this.hookOff)this.runHook(J,o(j,B,this.cwd))}emit(j){if(this.seqOff)return;try{this.write(j)}catch(B){this.seqOff=!0,this.note(`notify: the terminal write failed (${f(B)}) \u2014 terminal notifications are off for this session`,"warn")}}runHook(j,B){try{this.spawn([...j,JSON.stringify(B)])}catch(G){this.hookOff=!0,this.note(`notify_command: could not start ${j[0]} (${f(G)}) \u2014 the hook is off for this session`,"warn")}}}function n(j,B){let G=!1,J=!1,$=!1,L=0,D,H={start(Q,K){let Z=L,V=j.start(Q,K),U=()=>{if(Z===L&&!J)J=!0,$=B.focusOn()};if(V)return V.then(U);U()},stop(){if(L++,$)$=!1,B.focusOff();J=!1,j.stop()},askApproval(Q,K,Z){if(J)B.fire("approval",{tool:Q,argsPreview:K});return j.askApproval(Q,K,Z)},askQuestion(Q,K){if(J)B.fire("question",{question:Q.question});return j.askQuestion(Q,K)},setBusy(Q,K){if(j.setBusy(Q,K),Q){G=!0,D=void 0;return}let Z=G&&K===void 0;if(G=!1,Z&&J)B.fire("run_end",{...D!==void 0?{lastText:D}:{}})},beginAssistant(){let Q=j.beginAssistant(),K="";return{append(Z){if(Q.append(Z),K.length<y)K=(K+Z).slice(0,y)},done(){Q.done(),D=K}}}};return new Proxy(j,{get(Q,K){if(typeof K==="string"&&Object.hasOwn(H,K))return H[K];let Z=Reflect.get(Q,K,Q);return typeof Z==="function"?Z.bind(Q):Z}})}function Qj(j,B=process.env,G=process.stdout,J=process.stdin,$=process.cwd()){let L=G.isTTY===!0,D=L?new q:void 0,H=w(j,B,G,{stdin:J,...D?{focus:D}:{}});if(!H){let{PiTuiRenderer:K}=(v(),M(c)),{ProcessTerminal:Z}=(p(),M(l));H=new K({cwd:$,terminal:D?new _(new Z,D):new Z})}if(J.isTTY!==!0)J.on?.("end",()=>{try{process.exit(0)}catch{}});let Q=new m({config:a($,{env:B}),cwd:$,write:L?(K)=>{G.write(K)}:()=>{},focused:()=>D?.focused??!0,note:(K,Z)=>H.addSystemNote(K,Z)});return n(H,Q)}export{n as withNotifications,a as resolveNotifyConfig,o as payloadFor,Qj as interactiveRenderer,r as defaultSpawner,m as Notifier,s as NOTIFY_WHENS,i as NOTIFY_METHODS};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{$l as i,Wl as d,Xl as e,Yl as f,Zl as g,_l as h,am as j,bm as k}from"./main-b8zq261k.js";import{hm as a,im as b,jm as c}from"./main-wk2csfnj.js";import"./main-y5c82rxr.js";import"./main-ys6zj3yr.js";import"./main-mjt2p7aj.js";import"./main-2yeveeve.js";import"./main-0jys2ccn.js";import"./main-nqveez48.js";import"./main-qsevpgsv.js";k();export{f as saveMcpOAuth,j as runtimeAuthProvider,i as runMcpLoginFlow,a as needsLoginText,d as mcpOAuthId,e as loadMcpOAuth,c as hasStaticAuthorization,g as McpRuntimeAuthProvider,b as McpNeedsLoginError,h as McpLoginAuthProvider};
2
+ import{dd as d,ed as e,fd as f,gd as g,hd as h,id as i,jd as j,kd as k}from"./main-kyn0xnsg.js";import{hh as a,ih as b,jh as c}from"./main-rg0wn0xf.js";import"./main-0z1w2zsg.js";import"./main-9etavkew.js";import"./main-7rn6bqje.js";import"./main-2yeveeve.js";import"./main-0jys2ccn.js";import"./main-nqveez48.js";import"./main-qsevpgsv.js";k();export{f as saveMcpOAuth,j as runtimeAuthProvider,i as runMcpLoginFlow,a as needsLoginText,d as mcpOAuthId,e as loadMcpOAuth,c as hasStaticAuthorization,g as McpRuntimeAuthProvider,b as McpNeedsLoginError,h as McpLoginAuthProvider};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Hh as T}from"./main-qvarybsp.js";import{wj as y,yj as A}from"./main-2rzbexn2.js";import{Bj as L,Ej as w}from"./main-v8y60bb2.js";import{Mk as O,Qk as _}from"./main-qj2djy17.js";import"./main-6dtqmbt6.js";import"./main-rebtt91r.js";import"./main-a3f51n0x.js";import"./main-5py0rkmc.js";import"./main-6h9x282m.js";import"./main-vhrrq337.js";import"./main-2yeveeve.js";import"./main-0jys2ccn.js";import"./main-nqveez48.js";import"./main-qsevpgsv.js";_();A();w();import{format as F}from"util";var S=["text","json","ndjson"],U="--output <mode>: text (default) | json | ndjson",M=(j)=>{return process.stderr.write(`error: ${j} \u2014 ${U}
2
+ import{Vh as T}from"./main-k1eqkg83.js";import{Wj as y,Yj as A}from"./main-q3vsesf9.js";import{$j as L,ck as w}from"./main-xg704a3c.js";import{kl as O,ol as _}from"./main-3rxcvgna.js";import"./main-4wndhjdc.js";import"./main-ggcn7rd7.js";import"./main-0904f6ps.js";import"./main-prxxs70n.js";import"./main-n0t3973w.js";import"./main-mv40pcr2.js";import"./main-2yeveeve.js";import"./main-0jys2ccn.js";import"./main-nqveez48.js";import"./main-qsevpgsv.js";_();A();w();import{format as F}from"util";var S=["text","json","ndjson"],U="--output <mode>: text (default) | json | ndjson",M=(j)=>{return process.stderr.write(`error: ${j} \u2014 ${U}
3
3
  `),process.exit(2)};function E(j){return S.includes(j)}function m(j,J=M){let K=j.slice(2),H;for(let R=0;R<K.length;R++){let Y=K[R];if(Y==="--output"){let $=K[++R];if($===void 0||$.startsWith("-"))return J("--output needs a value");H=$}else if(Y.startsWith("--output="))H=Y.slice(9)}if(H===void 0)return"text";return E(H)?H:J(`unknown --output mode "${H}"`)}function v(j,J){let K=j.cmd==="run"?[...j.rest]:[j.cmd,...j.rest],H=J.slice(2),R=(N)=>N.startsWith("-"),Y=H.findIndex((N,X)=>!R(N)&&!(X>0&&T.has(H[X-1])));if(Y===-1)return K;let $=j.cmd==="run"?Y+1:Y,z=[];H.forEach((N,X)=>{let W=H[X+1];if(!T.has(N)||X<Y||W===void 0||R(W))return;z.push(H.slice($,X+1).filter((D)=>!R(D)).length)});for(let N of z.reverse())K.splice(N,1);return K}async function l(j,J={}){if(j.isTTY===!0)return"";let K=J.firstByteMs??3000,H=J.maxChars??1e6;return new Promise((R)=>{let Y=[],$=!1,z=!1,N=()=>{if(z)return;z=!0,clearTimeout(X);let W=Buffer.concat(Y).toString("utf8");if(W.length>H)J.note?.(`stdin: ${W.length.toLocaleString("en-US")} characters piped in \u2014 kept the first ${H.toLocaleString("en-US")}`);R(W.slice(0,H))},X=setTimeout(()=>{if($||z)return;J.note?.(`stdin: not a terminal, but nothing arrived in ${K/1000} s \u2014 ignored (pipe your input, or pass --no-stdin)`);try{j.pause?.()}catch{}N()},K);j.on("data",(W)=>{$=!0,Y.push(Buffer.isBuffer(W)?W:Buffer.from(W))}),j.on("end",N),j.on("close",N),j.on("error",N);try{j.resume?.()}catch{N()}})}function c(j,J){let K=J.replace(/\r\n?/g,`
4
4
  `).replace(/\n+$/,"");if(K.length===0)return j;let H="```";while(K.includes(H))H+="`";return`${j.trim().length>0?j.trim():"Here is the input:"}
5
5
 
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{fj as a,gj as b,hj as c,ij as d,jj as e,kj as f,lj as g,mj as h,nj as i,oj as j,pj as k,qj as l,rj as m}from"./main-1ztz6fkj.js";import"./main-2yeveeve.js";import"./main-0jys2ccn.js";import"./main-qsevpgsv.js";export{i as wireProfileFor,m as profileWire,l as profilePromptSection,k as profileOverridePaths,j as profileHint,h as profileFor,c as SONNET_5_VOICE,b as SONNET_5_PERSONA,g as PROFILES,e as GLM_53_PROFILE,f as GLM_53_PLAIN_PROFILE,d as GLM_53_MODEL_RE,a as GLM_53_AGENT_CONTRACT};
2
+ import{Aj as h,Bj as i,Cj as j,Dj as k,Ej as l,Fj as m,tj as a,uj as b,vj as c,wj as d,xj as e,yj as f,zj as g}from"./main-90ds1z4e.js";import"./main-2yeveeve.js";import"./main-0jys2ccn.js";import"./main-qsevpgsv.js";export{i as wireProfileFor,m as profileWire,l as profilePromptSection,k as profileOverridePaths,j as profileHint,h as profileFor,c as SONNET_5_VOICE,b as SONNET_5_PERSONA,g as PROFILES,e as GLM_53_PROFILE,f as GLM_53_PLAIN_PROFILE,d as GLM_53_MODEL_RE,a as GLM_53_AGENT_CONTRACT};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{$i as k,Ri as a,Si as b,Ti as c,Ui as d,Vi as e,Wi as f,Xi as g,Yi as h,Zi as i,_i as j,aj as l,bj as m,cj as n,dj as o,ej as p}from"./main-xx2z3zh5.js";import"./main-2yeveeve.js";import"./main-0jys2ccn.js";import"./main-qsevpgsv.js";export{i as writeProvidersFile,g as validateSpec,b as userProvidersPath,j as resolveKey,h as readProvidersFile,d as providersPathFor,c as projectProvidersPath,o as pickDefault,n as parseSelector,l as isConfigured,f as inferProtocol,k as envCustomProvider,m as buildSnapshot,p as ProviderConfig,e as PROVIDER_ID_RE,a as BUILTIN_PROVIDERS};
2
+ import{$i as i,Ti as a,Ui as b,Vi as c,Wi as d,Xi as e,Yi as f,Zi as g,_i as h,aj as j,bj as k,cj as l,dj as m,ej as n,fj as o,gj as p}from"./main-sdmxhtv8.js";import"./main-2yeveeve.js";import"./main-0jys2ccn.js";import"./main-qsevpgsv.js";export{i as writeProvidersFile,g as validateSpec,b as userProvidersPath,j as resolveKey,h as readProvidersFile,d as providersPathFor,c as projectProvidersPath,o as pickDefault,n as parseSelector,l as isConfigured,f as inferProtocol,k as envCustomProvider,m as buildSnapshot,p as ProviderConfig,e as PROVIDER_ID_RE,a as BUILTIN_PROVIDERS};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{he as a,ie as b,je as c}from"./main-ck9asesq.js";import"./main-cta9racd.js";import"./main-k2y8a2aw.js";import"./main-875s60s2.js";import"./main-sdmxhtv8.js";import"./main-pknhvrmj.js";import"./main-1k1kw6b5.js";import"./main-90ds1z4e.js";import"./main-9etavkew.js";import"./main-q3vsesf9.js";import"./main-xg704a3c.js";import"./main-8kjxbpw4.js";import"./main-3rxcvgna.js";import"./main-4wndhjdc.js";import"./main-ggcn7rd7.js";import"./main-0904f6ps.js";import"./main-prxxs70n.js";import"./main-n0t3973w.js";import"./main-mv40pcr2.js";import"./main-2yeveeve.js";import"./main-0jys2ccn.js";import"./main-nqveez48.js";import"./main-qsevpgsv.js";export{b as providerListTool,c as providerEditTool,a as looksLikeSecret};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Bg as a,Cg as b,Dg as c,Eg as d,Fg as e,Gg as f,Hg as g,Ig as h,Jg as i,Kg as j}from"./main-cta9racd.js";import"./main-k2y8a2aw.js";import"./main-875s60s2.js";import"./main-sdmxhtv8.js";import"./main-pknhvrmj.js";import"./main-1k1kw6b5.js";import"./main-90ds1z4e.js";import"./main-9etavkew.js";import"./main-q3vsesf9.js";import"./main-xg704a3c.js";import"./main-8kjxbpw4.js";import"./main-3rxcvgna.js";import"./main-4wndhjdc.js";import"./main-ggcn7rd7.js";import"./main-0904f6ps.js";import"./main-prxxs70n.js";import"./main-n0t3973w.js";import"./main-mv40pcr2.js";import"./main-2yeveeve.js";import"./main-0jys2ccn.js";import"./main-nqveez48.js";import"./main-qsevpgsv.js";export{a as toWireConfig,e as scrubSecret,h as parseAddArgs,j as formatProviderList,i as formatProviderLine,b as defaultAdapterFactory,d as configErrorTurn,f as ProviderRegistry,c as CONFIG_ERROR_PREFIX,g as ADD_USAGE};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Ab as b,Bb as c,Cb as d,Db as e,Eb as f,Fb as g,Gb as h,Hb as i,Ib as j,zb as a}from"./main-tjvwmscs.js";import"./main-7kt6r53y.js";import"./main-y5c82rxr.js";import"./main-2yeveeve.js";import"./main-0jys2ccn.js";import"./main-nqveez48.js";import"./main-qsevpgsv.js";j();export{g as searchMarket,f as itemFromMcp,e as itemFromCatalog,h as findItem,d as capBytes,i as allItems,c as MCP_DOCS_FILE,b as CATALOG_FILES,a as CATALOG_DIR};
2
+ import{Ac as i,Bc as j,sc as a,tc as b,uc as c,vc as d,wc as e,xc as f,yc as g,zc as h}from"./main-zaqh35jg.js";import"./main-vqak588n.js";import"./main-7rn6bqje.js";import"./main-2yeveeve.js";import"./main-0jys2ccn.js";import"./main-nqveez48.js";import"./main-qsevpgsv.js";j();export{g as searchMarket,f as itemFromMcp,e as itemFromCatalog,h as findItem,d as capBytes,i as allItems,c as MCP_DOCS_FILE,b as CATALOG_FILES,a as CATALOG_DIR};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{$ as e,L as a,M as r,O as o,P as Vj,Q as n,R as f,T as R,U as L,V as b,_ as s,aa as t,da as P,ja as Yj}from"./main-hrrvcfan.js";import{Sa as q,Ua as Xj}from"./main-rsy72qmw.js";import{Sc as p,Tc as i}from"./main-nvc3yjay.js";import"./main-bxtvnf6d.js";import"./main-4p4e2w7x.js";import"./main-hqbz10aw.js";import"./main-n6qrdbmy.js";import"./main-evgz4mp5.js";import"./main-f33fc5je.js";import"./main-2zgsknth.js";import"./main-kwwsz6rq.js";import"./main-23q7cmww.js";import"./main-45rn3trk.js";import"./main-yrjt2sqt.js";import"./main-a2yfvcy9.js";import"./main-gth53dnt.js";import"./main-2z3dek0b.js";import{De as g}from"./main-9a9rnh47.js";import"./main-mg9b20ac.js";import"./main-p0cfn6nr.js";import"./main-xfekqh9m.js";import"./main-s4bb0jav.js";import"./main-wqt32p5x.js";import"./main-rvetps99.js";import{pg as u,sg as d,tg as Qj}from"./main-x9ct6y1a.js";import"./main-mg4f96e1.js";import"./main-wgph00xf.js";import"./main-7jd5vh3x.js";import{kh as l,lh as Wj}from"./main-4y0tnfpa.js";import"./main-xt9zc3n6.js";import"./main-ntqef02r.js";import"./main-mgb9ccnx.js";import"./main-kba6zeyd.js";import"./main-2wyax8k9.js";import"./main-01pv9206.js";import"./main-s9v8k74e.js";import"./main-6vjeds42.js";import"./main-xx2z3zh5.js";import"./main-1ztz6fkj.js";import"./main-2rzbexn2.js";import"./main-v8y60bb2.js";import{Tj as S,Wj as Fj}from"./main-ywbxshqc.js";import"./main-gbbty4d4.js";import{Jk as c,Qk as Hj}from"./main-qj2djy17.js";import"./main-6dtqmbt6.js";import"./main-rebtt91r.js";import{Al as x,Dl as Gj}from"./main-a3f51n0x.js";import"./main-5py0rkmc.js";import"./main-6h9x282m.js";import"./main-vhrrq337.js";import"./main-wk2csfnj.js";import"./main-y5c82rxr.js";import"./main-ys6zj3yr.js";import"./main-mjt2p7aj.js";import"./main-2yeveeve.js";import"./main-0jys2ccn.js";import"./main-nqveez48.js";import"./main-qsevpgsv.js";Hj();import Dj from"readline";Fj();Qj();Gj();Vj();function Kj(X,j){let z=(Y)=>Y.replace(/\n/g," \u23CE ");return{start(Y){},stop(){},setCommands(){},addUser(Y){j(Y)},addSystemNote(Y,K="info"){j(` ${K==="info"?"":`${K}: `}${Y}`)},beginAssistant(){return{append(){},done(){}}},toolStart(Y,K,J){j(`
2
+ import{Ea as a,Fa as r,Ha as o,Ia as Vj,Ja as n,Ka as f,Ma as R,Na as L,Oa as b,Ta as s,Ua as e,Va as t,Ya as P,cb as Yj}from"./main-27y4sm2k.js";import{Lb as q,Nb as Xj}from"./main-73g7eff4.js";import{bd as l,cd as Wj}from"./main-rfth4tbm.js";import{qd as p,rd as i}from"./main-6genrmhs.js";import"./main-zzrfw6cf.js";import"./main-0ab9fc26.js";import"./main-80haw7qk.js";import"./main-6dnk69vp.js";import"./main-w2n1303f.js";import"./main-0mtcdbs7.js";import"./main-pn1w7a7j.js";import"./main-m1kk6fp5.js";import"./main-wsrg79c1.js";import"./main-ck9asesq.js";import"./main-kd488vje.js";import"./main-6b62vkz0.js";import"./main-rdgdw24b.js";import"./main-3pjrb2hd.js";import"./main-351pz3z7.js";import"./main-dfreez27.js";import{tf as g}from"./main-4b3jgy66.js";import"./main-skbp13js.js";import"./main-xvnrabfp.js";import"./main-t4xnd213.js";import"./main-3nf3kgve.js";import"./main-cta9racd.js";import"./main-1dchs7xv.js";import"./main-rg0wn0xf.js";import{qh as u,th as d,uh as Qj}from"./main-y1fqy60y.js";import"./main-2yfck9b5.js";import"./main-kh32yvgk.js";import"./main-kcpbykxz.js";import"./main-z3aayzvq.js";import"./main-0z1w2zsg.js";import"./main-3gjqfh7a.js";import"./main-k2y8a2aw.js";import"./main-875s60s2.js";import"./main-sdmxhtv8.js";import"./main-pknhvrmj.js";import"./main-1k1kw6b5.js";import"./main-90ds1z4e.js";import"./main-9etavkew.js";import"./main-q3vsesf9.js";import"./main-xg704a3c.js";import{rk as S,uk as Fj}from"./main-8kjxbpw4.js";import"./main-gzkmycnv.js";import{hl as c,ol as Hj}from"./main-3rxcvgna.js";import"./main-4wndhjdc.js";import"./main-ggcn7rd7.js";import{_l as x,bm as Gj}from"./main-0904f6ps.js";import"./main-prxxs70n.js";import"./main-n0t3973w.js";import"./main-2zmzgkwh.js";import"./main-a9njrkk1.js";import"./main-7rn6bqje.js";import"./main-mv40pcr2.js";import"./main-2yeveeve.js";import"./main-0jys2ccn.js";import"./main-nqveez48.js";import"./main-qsevpgsv.js";Hj();import Dj from"readline";Fj();Qj();Gj();Vj();function Kj(X,j){let z=(Y)=>Y.replace(/\n/g," \u23CE ");return{start(Y){},stop(){},setCommands(){},addUser(Y){j(Y)},addSystemNote(Y,K="info"){j(` ${K==="info"?"":`${K}: `}${Y}`)},beginAssistant(){return{append(){},done(){}}},toolStart(Y,K,J){j(`
3
3
  \u2192 ${K} ${J}`)},toolUpdate(){},toolEnd(Y,K,J){j(` \u2190 ${K?"ok":"FAIL"} ${z(J)}`)},async askApproval(Y,K,J){if(j(`
4
4
  approval needed: ${Y} ${K}`),J)for(let G of J.split(`
5
5
  `))j(` ${G}`);let V=await X(" allow? [y]es / [n]o: ");return V==="y"||V==="yes"?"once":"deny"},async askQuestion(){return null},async pickOne(){return null},clearTranscript(){},prefillEditor(Y){j(` resubmit with: ${z(Y)}`)},setBusy(Y,K){},setStatus(Y){}}}async function k(X,j){let Y={renderer:Kj(X.ask,X.out??console.log),rt:X.rt,store:()=>X.rt.store,approve:()=>X.approve,yolo:()=>X.yolo,busy:X.busy??(()=>!1),setBusy(){},bindAbort:X.bindAbort??(()=>{})},K=j.trim();if(K==="/undo")await b(Y);else if(K==="/commit"||K.startsWith("/commit "))await L(Y,K.slice(7))}Wj();R();Xj();Yj();R();import{existsSync as Zj}from"fs";import{resolve as $j}from"path";var Bj=" allow? [y]es / [a]lways / [n]o: ",_=String.fromCharCode(10);async function E(X,j,z,Y,K=console.log){if(K(`${_} approval needed: ${j} ${z}`),Y)for(let V of Y.split(_))K(` ${V}`);let J=await X(Bj);return J==="a"?"always":J==="n"||J===""?"deny":"once"}function v(X,j){return{start(){},stop(){},setCommands(){},addUser(){},addSystemNote(z,Y="info"){j(` ${Y==="info"?"":`${Y}: `}${z}`)},beginAssistant(){return{append(){},done(){}}},toolStart(z,Y,K){j(`${_} \u2192 ${Y} ${K}`)},toolUpdate(){},toolEnd(z,Y,K){j(` \u2190 ${Y?"ok":"FAIL"} ${K.split(_).join(" \u23CE ")}`)},askApproval:(z,Y,K)=>E(X,z,Y,K,j),async askQuestion(){return null},async pickOne(){return null},clearTranscript(){},prefillEditor(){},setBusy(){},setStatus(){}}}async function h(X,j){let z=X.out??console.log,Y={renderer:v(X.ask,z),rt:X.rt,store:()=>X.rt.store,level:()=>X.yolo()?"auto":"ask",approve:()=>X.yolo()?void 0:(K)=>E(X.ask,K.tool,JSON.stringify(K.revisedArgs).slice(0,140),void 0,z),busy:()=>X.busy(),setBusy(){},bindAbort:(K)=>X.bindAbort(K)};await f(Y,j)}function m(X,j){let z=v(X.ask,X.out??console.log),Y={renderer:z,cwd:X.rt.cwd,store:()=>X.rt.store,modelRef:()=>X.modelRef()},K=q(j,{cwd:X.rt.cwd,roots:X.rt.roots.dirs,resolve:(J)=>Zj($j(X.rt.cwd,J))?J:null,attachImage:(J)=>P(Y,J)});for(let J of K.notes)z.addSystemNote(J,J.includes(": attached as an image (")?"info":"warn");if(K.attached.length>0)z.addSystemNote(`attached: ${K.attached.map((J)=>`${J.path} (${J.shown} lines${J.capped?", capped":""})`).join(" \xB7 ")}`);return K.text}function I(X,j,z){if(z?.aborted)return Promise.resolve("");return new Promise((Y)=>{let K=()=>{Y("")};z?.addEventListener("abort",K,{once:!0}),X.question(j,{signal:z},(J)=>{z?.removeEventListener("abort",K),Y(J.trim().toLowerCase())})})}function Uj(X,j=console.log){return(z,Y)=>new Promise((K)=>{let J=z.options??[],V=z.allowFreeText!==!1;j(`
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{f as J}from"./main-tkgarpjj.js";import"./main-rpg7h8mb.js";import"./main-evgz4mp5.js";import{kl as F,ml as K}from"./main-6dtqmbt6.js";import"./main-qsevpgsv.js";K();function L(k){let j=k.indexOf("--resume"),q=j!==-1?k[j+1]:void 0,y=q!==void 0&&!q.startsWith("-")?q:void 0;return{...y!==void 0?{id:y}:{},newest:y===void 0&&(j!==-1||k.includes("--continue"))}}var M="nothing to continue from \u2014 this is a new session";function P(k,j,q){let y=L(k);if(y.id!==void 0)return{id:J("--resume",j,y.id,q)};if(!y.newest)return{};let z=F(j);return z?{id:z.id}:{note:M}}function W(k,j,q){return P(k,j,q).id}export{W as resolveResume,P as resolveBoot,L as parseResume,M as NOTHING_TO_CONTINUE};
2
+ import{v as J}from"./main-z2ex2vyf.js";import"./main-1ereejm1.js";import"./main-m1kk6fp5.js";import{Kl as F,Ml as K}from"./main-4wndhjdc.js";import"./main-qsevpgsv.js";K();function L(k){let j=k.indexOf("--resume"),q=j!==-1?k[j+1]:void 0,y=q!==void 0&&!q.startsWith("-")?q:void 0;return{...y!==void 0?{id:y}:{},newest:y===void 0&&(j!==-1||k.includes("--continue"))}}var M="nothing to continue from \u2014 this is a new session";function P(k,j,q){let y=L(k);if(y.id!==void 0)return{id:J("--resume",j,y.id,q)};if(!y.newest)return{};let z=F(j);return z?{id:z.id}:{note:M}}function W(k,j,q){return P(k,j,q).id}export{W as resolveResume,P as resolveBoot,L as parseResume,M as NOTHING_TO_CONTINUE};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{vh as a,wh as b,xh as c}from"./main-5tbz0wbz.js";import"./main-0904f6ps.js";import"./main-qsevpgsv.js";export{c as parseAddDirs,b as ADD_DIR_USAGE,a as ADD_DIR_FLAG};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{od as a,pd as b,qd as c,rd as d}from"./main-6genrmhs.js";import"./main-zzrfw6cf.js";import"./main-0ab9fc26.js";import"./main-80haw7qk.js";import"./main-6dnk69vp.js";import"./main-w2n1303f.js";import"./main-0mtcdbs7.js";import"./main-pn1w7a7j.js";import"./main-m1kk6fp5.js";import"./main-wsrg79c1.js";import"./main-ck9asesq.js";import"./main-kd488vje.js";import"./main-6b62vkz0.js";import"./main-rdgdw24b.js";import"./main-3pjrb2hd.js";import"./main-351pz3z7.js";import"./main-dfreez27.js";import"./main-4b3jgy66.js";import"./main-skbp13js.js";import"./main-xvnrabfp.js";import"./main-t4xnd213.js";import"./main-3nf3kgve.js";import"./main-cta9racd.js";import"./main-1dchs7xv.js";import"./main-rg0wn0xf.js";import"./main-y1fqy60y.js";import"./main-2yfck9b5.js";import"./main-kh32yvgk.js";import"./main-kcpbykxz.js";import"./main-z3aayzvq.js";import"./main-0z1w2zsg.js";import"./main-3gjqfh7a.js";import"./main-k2y8a2aw.js";import"./main-875s60s2.js";import"./main-sdmxhtv8.js";import"./main-pknhvrmj.js";import"./main-1k1kw6b5.js";import"./main-90ds1z4e.js";import"./main-9etavkew.js";import"./main-q3vsesf9.js";import"./main-xg704a3c.js";import"./main-8kjxbpw4.js";import"./main-gzkmycnv.js";import"./main-3rxcvgna.js";import"./main-4wndhjdc.js";import"./main-ggcn7rd7.js";import"./main-0904f6ps.js";import"./main-prxxs70n.js";import"./main-n0t3973w.js";import"./main-2zmzgkwh.js";import"./main-a9njrkk1.js";import"./main-7rn6bqje.js";import"./main-mv40pcr2.js";import"./main-2yeveeve.js";import"./main-0jys2ccn.js";import"./main-nqveez48.js";import"./main-qsevpgsv.js";export{b as createRuntime,d as bootRuntime,c as NO_PROVIDER_HINT,a as MAX_OUTPUT_CAP};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{mg as a,ng as b,og as c,pg as d,qg as e,rg as f,sg as g,tg as h}from"./main-x9ct6y1a.js";import"./main-kba6zeyd.js";import"./main-2yeveeve.js";import"./main-0jys2ccn.js";import"./main-nqveez48.js";import"./main-qsevpgsv.js";h();export{f as unavailableRungError,e as loadSandboxConfig,g as describeSandbox,d as SandboxConfigError,c as SANDBOX_IMAGE_ENV,a as SANDBOX_FILE,b as SANDBOX_ENV};
2
+ import{nh as a,oh as b,ph as c,qh as d,rh as e,sh as f,th as g,uh as h}from"./main-y1fqy60y.js";import"./main-3gjqfh7a.js";import"./main-2yeveeve.js";import"./main-0jys2ccn.js";import"./main-nqveez48.js";import"./main-qsevpgsv.js";h();export{f as unavailableRungError,e as loadSandboxConfig,g as describeSandbox,d as SandboxConfigError,c as SANDBOX_IMAGE_ENV,a as SANDBOX_FILE,b as SANDBOX_ENV};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Tc as _}from"./main-nvc3yjay.js";import"./main-bxtvnf6d.js";import"./main-4p4e2w7x.js";import"./main-hqbz10aw.js";import"./main-n6qrdbmy.js";import"./main-evgz4mp5.js";import"./main-f33fc5je.js";import"./main-2zgsknth.js";import"./main-kwwsz6rq.js";import"./main-23q7cmww.js";import"./main-45rn3trk.js";import"./main-yrjt2sqt.js";import"./main-a2yfvcy9.js";import"./main-gth53dnt.js";import"./main-2z3dek0b.js";import"./main-9a9rnh47.js";import"./main-mg9b20ac.js";import"./main-p0cfn6nr.js";import"./main-xfekqh9m.js";import"./main-s4bb0jav.js";import"./main-wqt32p5x.js";import"./main-rvetps99.js";import{pg as T,tg as q}from"./main-x9ct6y1a.js";import"./main-mg4f96e1.js";import"./main-wgph00xf.js";import"./main-7jd5vh3x.js";import"./main-xt9zc3n6.js";import"./main-ntqef02r.js";import"./main-mgb9ccnx.js";import"./main-kba6zeyd.js";import"./main-2wyax8k9.js";import"./main-01pv9206.js";import"./main-s9v8k74e.js";import"./main-6vjeds42.js";import"./main-xx2z3zh5.js";import"./main-1ztz6fkj.js";import"./main-2rzbexn2.js";import"./main-v8y60bb2.js";import{Nj as W,Wj as k}from"./main-ywbxshqc.js";import"./main-gbbty4d4.js";import{Jk as N,Qk as C}from"./main-qj2djy17.js";import{Vk as h,Wk as w,bl as E}from"./main-6dtqmbt6.js";import"./main-rebtt91r.js";import"./main-a3f51n0x.js";import"./main-5py0rkmc.js";import"./main-6h9x282m.js";import"./main-vhrrq337.js";import"./main-wk2csfnj.js";import"./main-y5c82rxr.js";import"./main-ys6zj3yr.js";import"./main-mjt2p7aj.js";import"./main-2yeveeve.js";import"./main-0jys2ccn.js";import"./main-nqveez48.js";import"./main-qsevpgsv.js";k();C();import{AgentSideConnection as R,RequestError as $,PROTOCOL_VERSION as u,ndJsonStream as b}from"@zed-industries/agent-client-protocol";import{basename as d}from"path";import{Readable as l,Writable as c}from"stream";E();q();function L(y){let j=[],G=[],U;for(let Q of y)if(Q.type==="text")j.push(Q.text);else if(Q.type==="resource_link")j.push(`[resource: ${Q.uri}]`);else if(Q.type==="resource"&&"text"in Q.resource)j.push(`<context uri="${Q.resource.uri}">
2
+ import{rd as _}from"./main-6genrmhs.js";import"./main-zzrfw6cf.js";import"./main-0ab9fc26.js";import"./main-80haw7qk.js";import"./main-6dnk69vp.js";import"./main-w2n1303f.js";import"./main-0mtcdbs7.js";import"./main-pn1w7a7j.js";import"./main-m1kk6fp5.js";import"./main-wsrg79c1.js";import"./main-ck9asesq.js";import"./main-kd488vje.js";import"./main-6b62vkz0.js";import"./main-rdgdw24b.js";import"./main-3pjrb2hd.js";import"./main-351pz3z7.js";import"./main-dfreez27.js";import"./main-4b3jgy66.js";import"./main-skbp13js.js";import"./main-xvnrabfp.js";import"./main-t4xnd213.js";import"./main-3nf3kgve.js";import"./main-cta9racd.js";import"./main-1dchs7xv.js";import"./main-rg0wn0xf.js";import{qh as T,uh as q}from"./main-y1fqy60y.js";import"./main-2yfck9b5.js";import"./main-kh32yvgk.js";import"./main-kcpbykxz.js";import"./main-z3aayzvq.js";import"./main-0z1w2zsg.js";import"./main-3gjqfh7a.js";import"./main-k2y8a2aw.js";import"./main-875s60s2.js";import"./main-sdmxhtv8.js";import"./main-pknhvrmj.js";import"./main-1k1kw6b5.js";import"./main-90ds1z4e.js";import"./main-9etavkew.js";import"./main-q3vsesf9.js";import"./main-xg704a3c.js";import{lk as W,uk as k}from"./main-8kjxbpw4.js";import"./main-gzkmycnv.js";import{hl as N,ol as C}from"./main-3rxcvgna.js";import{Bl as E,tl as h,ul as w}from"./main-4wndhjdc.js";import"./main-ggcn7rd7.js";import"./main-0904f6ps.js";import"./main-prxxs70n.js";import"./main-n0t3973w.js";import"./main-2zmzgkwh.js";import"./main-a9njrkk1.js";import"./main-7rn6bqje.js";import"./main-mv40pcr2.js";import"./main-2yeveeve.js";import"./main-0jys2ccn.js";import"./main-nqveez48.js";import"./main-qsevpgsv.js";k();C();import{AgentSideConnection as R,RequestError as $,PROTOCOL_VERSION as u,ndJsonStream as b}from"@zed-industries/agent-client-protocol";import{basename as d}from"path";import{Readable as l,Writable as c}from"stream";E();q();function L(y){let j=[],G=[],U;for(let Q of y)if(Q.type==="text")j.push(Q.text);else if(Q.type==="resource_link")j.push(`[resource: ${Q.uri}]`);else if(Q.type==="resource"&&"text"in Q.resource)j.push(`<context uri="${Q.resource.uri}">
3
3
  ${Q.resource.text}
4
4
  </context>`);else if(Q.type==="image"){let Y=Q.uri&&!Q.uri.startsWith("data:")?d(Q.uri):void 0,z=h(Q.data,Q.mimeType,Y!==void 0?{name:Y}:{});if("error"in z)U??=z.error;else G.push(z)}else j.push(`[unsupported ${Q.type} content omitted]`);U??=w(G.length);let X=j.join(`
5
5
  `);return U===void 0?{goal:X,images:G}:{goal:X,images:G,error:U}}function jj(y){return L(y).goal}var m={read:"read",edit:"edit",write:"edit",bash:"execute",skill_view:"read",skills_list:"search",mcp_list:"search",mcp_call:"other",memory_edit:"other",web_fetch:"fetch"};function S(y){return m[y]??"other"}function f(y,j){if(j&&typeof j==="object"){let G=j,U=G.path??G.command??G.name??G.url;if(U!==void 0)return`${y}: ${String(U).slice(0,120)}`}return y}function A(y){if(y&&typeof y==="object"&&!Array.isArray(y))return y;return y===void 0?{}:{value:y}}function J(y){return[{type:"content",content:{type:"text",text:y}}]}function p(y){switch(y.type){case"message_update":return{sessionUpdate:"agent_message_chunk",content:{type:"text",text:y.delta}};case"tool_execution_start":return{sessionUpdate:"tool_call",toolCallId:y.callId,title:f(y.tool,y.args),kind:S(y.tool),status:"in_progress",rawInput:A(y.args)};case"tool_execution_update":return{sessionUpdate:"tool_call_update",toolCallId:y.callId,content:J(y.note)};case"tool_execution_end":return{sessionUpdate:"tool_call_update",toolCallId:y.callId,status:y.ok?"completed":"failed",content:J(y.output),rawOutput:{output:y.output}};case"tool_call_failed":return{sessionUpdate:"tool_call",toolCallId:y.callId,title:`tool call failed (${y.reason})`,kind:"other",status:"failed",content:J(y.detail)};default:return null}}class F{conn;opts;sessions=new Map;constructor(y,j={}){this.conn=y;this.opts=j}async initialize(y){return{protocolVersion:u,agentCapabilities:{loadSession:!1,promptCapabilities:{image:!0,audio:!1,embeddedContext:!0}},authMethods:[]}}async authenticate(y){return{}}async newSession(y){let j;try{j=await _({cwd:y.cwd,stream:this.opts.stream})}catch(U){if(U instanceof T)throw $.invalidParams({cwd:y.cwd,error:U.message});throw U}let G=j.noProviderReason();if(!j.stream||G!==null)throw $.authRequired({details:G??W("cli")});return this.sessions.set(j.sessionId,{rt:j,steering:j.steering,active:null,permSeq:0}),{sessionId:j.sessionId}}async prompt(y){let j=this.sessions.get(y.sessionId);if(!j)throw $.invalidParams({sessionId:y.sessionId,error:"unknown session"});if(j.active)throw $.invalidRequest({error:"a prompt is already running for this session"});let G=j.rt.stream,U=j.rt.noProviderReason();if(!G||U!==null)throw $.authRequired(U!==null?{details:U}:void 0);let{goal:X,images:Q,error:Y}=L(y.prompt);if(Y!==void 0)throw $.invalidParams({error:Y});let z={provider:j.rt.provider?.id??"mock",model:j.rt.defaultModel||"default"},O=j.rt.buildDef(z),x=j.rt.buildCfg(this.opts.yolo??!1,this.approvalFor(y.sessionId,j)),D=new AbortController;j.rt.tasks.bindRun(D.signal);let I={stream:G,registry:j.rt.registry,store:j.rt.store,tools:j.rt.registry.list().map((Z)=>Z.schema),guard:j.rt.guard,hooks:j.rt.hooks,cwd:j.rt.cwd,signal:D.signal};if(Q.length>0)j.rt.store.stageAttachments(Q);let K=N(O,X,{},x,I,j.steering),M=()=>{},P=new Promise((Z)=>{M=()=>Z(null)}),H={gen:K,cancelled:!1,abort:D,onCancel:P,fireCancel:M};j.active=H;let B=null;try{for await(let Z of K){if(H.cancelled)break;if(Z.type==="run_end"){B={status:Z.status,summary:Z.summary};break}let V=p(Z);if(V)await this.conn.sessionUpdate({sessionId:y.sessionId,update:V})}}finally{j.active=null}if(H.cancelled||B===null)return{stopReason:"cancelled"};switch(B.status){case"done":return{stopReason:"end_turn"};case"budget":return{stopReason:"max_turn_requests"};case"stopped":return{stopReason:"cancelled"};case"error":throw $.internalError({details:B.summary})}}async cancel(y){let j=this.sessions.get(y.sessionId)?.active;if(!j)return;j.cancelled=!0,j.abort.abort(),j.fireCancel(),await j.gen.return(void 0).then(()=>{return},()=>{return})}async shutdown(){let y=[];for(let j of this.sessions.values())if(j.rt.tasks.cancelAll(),j.rt.bashJobs.dispose(),y.push(j.rt.hooks.close()),j.rt.mcp)y.push(j.rt.mcp.close().catch(()=>{}));await Promise.all(y)}approvalFor(y,j){return async(G)=>{let U=`perm-${++j.permSeq}`,X;try{let Q=this.conn.requestPermission({sessionId:y,toolCall:{toolCallId:U,title:f(G.tool,G.revisedArgs),kind:S(G.tool),status:"pending",rawInput:A(G.revisedArgs)},options:[{optionId:"allow-once",name:"Allow once",kind:"allow_once"},{optionId:"allow-always",name:"Allow always",kind:"allow_always"},{optionId:"reject-once",name:"Deny",kind:"reject_once"}]});Q.then(()=>{return},()=>{return});let Y=j.active?await Promise.race([Q,j.active.onCancel]):await Q;if(Y===null)return"deny";X=Y.outcome}catch{return"deny"}if(X.outcome!=="selected")return"deny";if(X.optionId==="allow-once")return"once";if(X.optionId==="allow-always")return"always";return"deny"}}}function g(y,j={}){let G;return{conn:new R((X)=>G=new F(X,j),y),agent:G}}function yj(y={}){let j=b(c.toWeb(process.stdout),l.toWeb(process.stdin)),{agent:G}=g(j,y);return new Promise((U)=>{let X=()=>{G.shutdown().then(()=>U(),()=>U())};process.stdin.once("end",X),process.stdin.once("close",X)})}export{p as updateForEvent,f as titleFor,g as serveAcp,yj as runAcpStdio,jj as promptText,L as promptParts,S as kindFor,F as RovecodeAcpAgent};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{u as a,v as b}from"./main-z2ex2vyf.js";import"./main-1ereejm1.js";import"./main-m1kk6fp5.js";import"./main-4wndhjdc.js";import"./main-qsevpgsv.js";export{a as sessionIdArg,b as resolveSessionArg};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Gl as a,Hl as b,Il as c,Jl as d,Kl as e,Ll as f,Ml as g}from"./main-4wndhjdc.js";import"./main-qsevpgsv.js";g();export{c as scanSessions,e as newestSession,d as listSessions,b as entryShape,a as chainHash,f as SessionStore};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{lb as F,ob as U,pb as V,qb as W,rb as Y,sb as _,tb as k}from"./main-rpg7h8mb.js";import"./main-evgz4mp5.js";import{el as I,il as O,ml as P}from"./main-6dtqmbt6.js";import"./main-qsevpgsv.js";P();k();function y(z){let K=F(z),Q=O(K);return{rows:Q.sessions.map((M)=>({id:M.id,created:new Date(M.createdAt).toISOString(),updated:new Date(M.updatedAt).toISOString(),cwd:z,firstPrompt:M.preview,turns:M.turns,entries:M.entryCount,...M.title!==void 0?{title:M.title}:{}})),hollow:Q.hollow.length,root:K}}function S(z){return y(z).rows}function R(z,K){if(z===0)return;return`${z} empty session director${z===1?"y":"ies"} in ${K} \u2014 nothing was ever written to them`}function T(z,K){let{rows:Q,hollow:$,root:M}=z;if(K)return JSON.stringify(Q);let X=R($,M);if(Q.length===0)return[`no sessions in ${M} \u2014 a \`rovecode run\` or a TUI turn starts one`,...X?[X]:[]].join(`
2
+ import{ec as F,hc as U,ic as V,jc as W,kc as Y,lc as _,mc as k}from"./main-1ereejm1.js";import"./main-m1kk6fp5.js";import{El as I,Il as O,Ml as P}from"./main-4wndhjdc.js";import"./main-qsevpgsv.js";P();k();function y(z){let K=F(z),Q=O(K);return{rows:Q.sessions.map((M)=>({id:M.id,created:new Date(M.createdAt).toISOString(),updated:new Date(M.updatedAt).toISOString(),cwd:z,firstPrompt:M.preview,turns:M.turns,entries:M.entryCount,...M.title!==void 0?{title:M.title}:{}})),hollow:Q.hollow.length,root:K}}function S(z){return y(z).rows}function R(z,K){if(z===0)return;return`${z} empty session director${z===1?"y":"ies"} in ${K} \u2014 nothing was ever written to them`}function T(z,K){let{rows:Q,hollow:$,root:M}=z;if(K)return JSON.stringify(Q);let X=R($,M);if(Q.length===0)return[`no sessions in ${M} \u2014 a \`rovecode run\` or a TUI turn starts one`,...X?[X]:[]].join(`
3
3
  `);let B=[`sessions in ${M} (newest first; --json for the full rows):`,`${"id".padEnd(36)} ${"created".padEnd(24)} turns first prompt`];for(let x of Q)B.push(`${x.id.padEnd(36)} ${x.created.padEnd(24)} ${String(x.turns).padStart(5)} ${x.title??(x.firstPrompt||"(empty session)")}`);if(X)B.push(X);return B.join(`
4
4
  `)}function L(z){let K=z.entryId===""?"title":z.entryId.slice(0,8);return`${z.sessionId.slice(0,8)} ${new Date(z.timestamp).toISOString()} ${K.padEnd(8)} ${z.title!==void 0?`[${z.title}] `:""}${z.preview}`}var j="usage: rovecode sessions [--json] | rename <id|prefix> <title\u2026> | delete <id|prefix> [--yes] | fork <id|prefix> [--json] | search <terms\u2026> [--json]",q=new Set(["rename","delete","fork","search"]),h=(z)=>z.length>1&&z.startsWith("-");function p(z){let K=z.indexOf("sessions");return K===-1?[]:z.slice(K+1).filter((Q)=>!h(Q))}function v(z,K,Q={}){let $=Q.out??((J)=>console.log(J)),M=Q.err??((J)=>process.stderr.write(`${J}
5
5
  `)),X=(J)=>{return M(`error: ${J} \u2014 ${j}`),2},B=z.includes("--json"),x=p(z),C=x[0];if(C===void 0)return $(T(y(K),B)),0;if(!q.has(C))return X(`unknown sessions verb "${C}"`);let D=F(K);if(C==="search"){let J=x.slice(1).join(" ").trim();if(J==="")return X("search needs at least one term");let A=_(D,J,10);if(B)$(JSON.stringify(A));else $(A.length===0?`no matches for "${J}" in ${D}`:A.map(L).join(`
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Il as a,Jl as b,Kl as c,Ll as d,Ml as e,Nl as f,Ol as g,Pl as h,Ql as i,Rl as j,Sl as k}from"./main-6h9x282m.js";import"./main-vhrrq337.js";import"./main-2yeveeve.js";import"./main-0jys2ccn.js";import"./main-nqveez48.js";import"./main-qsevpgsv.js";k();export{f as settingsTrustNotes,b as settingsPath,g as saveSetting,h as resolvePermission,i as resolveEffort,c as readSettingsFile,d as loadSettingsScoped,e as loadSettings,j as autoUpdateEnabled,a as COMMAND_KEYS};
2
+ import{cm as a,dm as b,em as c,fm as d,gm as e,hm as f,im as g,jm as h,km as i,lm as j,mm as k}from"./main-prxxs70n.js";import"./main-n0t3973w.js";import"./main-2yeveeve.js";import"./main-0jys2ccn.js";import"./main-nqveez48.js";import"./main-qsevpgsv.js";k();export{f as settingsTrustNotes,b as settingsPath,g as saveSetting,h as resolvePermission,i as resolveEffort,c as readSettingsFile,d as loadSettingsScoped,e as loadSettings,j as autoUpdateEnabled,a as COMMAND_KEYS};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Jc as a,Kc as b,Lc as c,Mc as d}from"./main-9ht36z12.js";import"./main-xx2z3zh5.js";import"./main-ywbxshqc.js";import"./main-2yeveeve.js";import"./main-0jys2ccn.js";import"./main-qsevpgsv.js";export{d as runSetup,c as askLine,a as SETUP_PICKS,b as SETUP_DONE};
2
+ import{wa as a,xa as b,ya as c,za as d}from"./main-4xcmvxnk.js";import"./main-sdmxhtv8.js";import"./main-8kjxbpw4.js";import"./main-2yeveeve.js";import"./main-0jys2ccn.js";import"./main-qsevpgsv.js";export{d as runSetup,c as askLine,a as SETUP_PICKS,b as SETUP_DONE};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{a as v,b as y,c as C}from"./main-z13755t8.js";import{h as k}from"./main-j7ttv0sd.js";import"./main-vxnwe5xx.js";import"./main-8c1tbazx.js";import"./main-edxc3yzt.js";import"./main-na7wse0x.js";import"./main-hrrvcfan.js";import"./main-rsy72qmw.js";import"./main-rpg7h8mb.js";import"./main-zc7pyrbj.js";import"./main-45ejth3a.js";import"./main-jak598k9.js";import"./main-7kt6r53y.js";import"./main-9ht36z12.js";import"./main-nvc3yjay.js";import"./main-bxtvnf6d.js";import"./main-4p4e2w7x.js";import"./main-hqbz10aw.js";import"./main-n6qrdbmy.js";import"./main-evgz4mp5.js";import"./main-f33fc5je.js";import"./main-2zgsknth.js";import"./main-kwwsz6rq.js";import"./main-23q7cmww.js";import"./main-45rn3trk.js";import"./main-yrjt2sqt.js";import"./main-a2yfvcy9.js";import"./main-gth53dnt.js";import"./main-2z3dek0b.js";import"./main-9a9rnh47.js";import"./main-mg9b20ac.js";import"./main-p0cfn6nr.js";import"./main-xfekqh9m.js";import"./main-s4bb0jav.js";import"./main-wqt32p5x.js";import{$f as P,ag as g,lg as u}from"./main-rvetps99.js";import"./main-x9ct6y1a.js";import"./main-mg4f96e1.js";import"./main-wgph00xf.js";import"./main-7jd5vh3x.js";import"./main-fvnpq46y.js";import"./main-4y0tnfpa.js";import"./main-xt9zc3n6.js";import"./main-ntqef02r.js";import"./main-mgb9ccnx.js";import"./main-wm997zjx.js";import"./main-kba6zeyd.js";import{vi as q,wi as N,xi as H}from"./main-2wyax8k9.js";import"./main-01pv9206.js";import"./main-s9v8k74e.js";import"./main-6vjeds42.js";import"./main-xx2z3zh5.js";import"./main-1ztz6fkj.js";import"./main-2rzbexn2.js";import"./main-v8y60bb2.js";import"./main-ywbxshqc.js";import"./main-gbbty4d4.js";import"./main-qj2djy17.js";import"./main-6dtqmbt6.js";import"./main-rebtt91r.js";import"./main-a3f51n0x.js";import"./main-5py0rkmc.js";import"./main-6h9x282m.js";import"./main-vhrrq337.js";import"./main-wk2csfnj.js";import"./main-y5c82rxr.js";import"./main-ys6zj3yr.js";import"./main-mjt2p7aj.js";import"./main-2yeveeve.js";import"./main-0jys2ccn.js";import"./main-nqveez48.js";import"./main-qsevpgsv.js";u();import{mkdtempSync as F,rmSync as T}from"fs";import{tmpdir as x}from"os";import{join as j}from"path";y();var $=(J)=>new Promise((X)=>setTimeout(X,J)),B=[/needs your permission\s+write\b/,/needs your permission\s+edit\b/],A=["\x1B[?1049l","\x1B[?25h","\x1B[?1006l","\x1B[?2004l"];async function w(J={}){let X=F(j(x(),"rovecode-sextant-smoke-")),U=new C(J.cols??160,J.rows??44,{COLORTERM:"truecolor"}),Q=new v({io:U,cwd:X,pet:"rovecode"}),I=j(X,"smoke.txt"),S=`smoke-ok
2
+ import{q as v,r as y,s as C}from"./main-kqxnqjnv.js";import{x as k}from"./main-yn8cd281.js";import"./main-hq51jg8v.js";import"./main-2wwjex5j.js";import"./main-yr0ksc0h.js";import"./main-xy53xf0r.js";import"./main-7c5thhjd.js";import"./main-zc2e8e46.js";import"./main-4xcmvxnk.js";import"./main-wbrdspr2.js";import"./main-27y4sm2k.js";import"./main-73g7eff4.js";import"./main-1ereejm1.js";import"./main-vqak588n.js";import"./main-aecrjq2d.js";import"./main-rfth4tbm.js";import"./main-6genrmhs.js";import"./main-zzrfw6cf.js";import"./main-0ab9fc26.js";import"./main-80haw7qk.js";import"./main-6dnk69vp.js";import"./main-w2n1303f.js";import"./main-0mtcdbs7.js";import"./main-pn1w7a7j.js";import"./main-m1kk6fp5.js";import"./main-wsrg79c1.js";import"./main-ck9asesq.js";import"./main-kd488vje.js";import"./main-6b62vkz0.js";import"./main-rdgdw24b.js";import"./main-3pjrb2hd.js";import"./main-351pz3z7.js";import"./main-dfreez27.js";import"./main-4b3jgy66.js";import"./main-skbp13js.js";import"./main-xvnrabfp.js";import"./main-t4xnd213.js";import"./main-3nf3kgve.js";import"./main-cta9racd.js";import{Rg as P,Sg as g,bh as u}from"./main-1dchs7xv.js";import"./main-rg0wn0xf.js";import"./main-y1fqy60y.js";import"./main-2yfck9b5.js";import"./main-kh32yvgk.js";import"./main-kcpbykxz.js";import"./main-z3aayzvq.js";import"./main-0z1w2zsg.js";import"./main-ddv7j2ag.js";import"./main-3gjqfh7a.js";import{Ji as q,Ki as N,Li as H}from"./main-k2y8a2aw.js";import"./main-875s60s2.js";import"./main-sdmxhtv8.js";import"./main-pknhvrmj.js";import"./main-1k1kw6b5.js";import"./main-90ds1z4e.js";import"./main-9etavkew.js";import"./main-q3vsesf9.js";import"./main-xg704a3c.js";import"./main-8kjxbpw4.js";import"./main-gzkmycnv.js";import"./main-3rxcvgna.js";import"./main-4wndhjdc.js";import"./main-ggcn7rd7.js";import"./main-0904f6ps.js";import"./main-prxxs70n.js";import"./main-n0t3973w.js";import"./main-2zmzgkwh.js";import"./main-a9njrkk1.js";import"./main-7rn6bqje.js";import"./main-mv40pcr2.js";import"./main-2yeveeve.js";import"./main-0jys2ccn.js";import"./main-nqveez48.js";import"./main-qsevpgsv.js";u();import{mkdtempSync as F,rmSync as T}from"fs";import{tmpdir as x}from"os";import{join as j}from"path";y();var $=(J)=>new Promise((X)=>setTimeout(X,J)),B=[/needs your permission\s+write\b/,/needs your permission\s+edit\b/],A=["\x1B[?1049l","\x1B[?25h","\x1B[?1006l","\x1B[?2004l"];async function w(J={}){let X=F(j(x(),"rovecode-sextant-smoke-")),U=new C(J.cols??160,J.rows??44,{COLORTERM:"truecolor"}),Q=new v({io:U,cwd:X,pet:"rovecode"}),I=j(X,"smoke.txt"),S=`smoke-ok
3
3
  `,D=q({turns:[H([{id:"t1",tool:"write",args:{path:I,content:`smoke-ok
4
4
  `}}]),H([{id:"t2",tool:"edit",args:{path:I,edits:[{tag:g(`smoke-ok
5
5
  `),anchorLine:1,anchorHash:P("smoke-ok"),newLines:["smoke-edited"]}]}}]),N("Smoke OK \u2014 the sextant surface rendered a write, an anchored edit and this summary.")]}),K=[],L=k({renderer:Q,stream:D,cwd:X,permission:"ask",exitOnClose:!1,model:"scripted"});U.feed("hello rovecode\r");let b=Date.now()+(J.deadlineMs??15000),Y=[],G="",Z=!1;while(Date.now()<b){if(Q.tick(),G=Q.frameText(),Y.length===B.length&&G.includes("Smoke OK")&&!G.includes("needs your permission")){Z=!0;break}let z=B[Y.length];if(z!==void 0&&z.test(G)&&G.includes("allow"))Y.push(G),U.feed("\r");await $(25)}let M=["\u2500 files \u2500","\u2500 code \u2500","\u2500 messages \u2500","\u2500 plan \u2500","\u2500 usage \u2500","\u2500 rovecode \u2500"],O=(z)=>G.includes(z)||z==="\u2500 code \u2500"&&G.includes("\u2500 diff \u2500"),E=Date.now()+2000;while(Z&&Date.now()<E&&!M.every(O))await $(25),Q.tick(),G=Q.frameText();if(!Z)K.push(`final frame not reached (approval cards seen ${Y.length}/${B.length})`);if(!/~ edit\s+smoke\.txt/.test(G))K.push("no `~ edit smoke.txt` tool row in the messages panel");if(!/\+ write\s+smoke\.txt/.test(G))K.push("no `+ write smoke.txt` tool row in the messages panel");for(let z of M)if(!O(z))K.push(`panel ${z.trim()} missing at ${U.cols}\xD7${U.rows}`);let R=Q.active;U.feed("\x03"),await L;let V=U.output().slice(-400);for(let z of A)if(!V.includes(z))K.push(`the output tail lacks ${JSON.stringify(z)} \u2014 terminal not restored`);if(!R)K.push("the frame interval was not running before quit");if(Q.active)K.push("the frame interval survived quit");await Q.drain().catch(()=>{});for(let z=0;;z++)try{T(X,{recursive:!0,force:!0});break}catch(W){let _=W.code;if(_!=="EBUSY"&&_!=="EPERM"&&_!=="ENOTEMPTY"||z>=20)throw W;await $(25)}return{ok:K.length===0,reasons:K,cardFrame:Y[1]??Y[0]??"(no approval card rendered)",frame:G,tail:V}}async function n(){let J=await w();console.log("\u2500\u2500 sextant: approval card for the anchored edit (160x44) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"),console.log(J.cardFrame),console.log("\u2500\u2500 sextant: final frame (160x44) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"),console.log(J.frame),console.log("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"),console.log(J.ok?"smoke-tui --sextant: PASS (files \xB7 code \xB7 messages \xB7 plan \xB7 usage \xB7 rovecode + two approval cards through the full pipeline; terminal restored on quit)":`smoke-tui --sextant: FAIL \u2014 ${J.reasons.join("; ")}`),process.exit(J.ok?0:1)}export{w as sextantSmoke,n as runSextantSmoke};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Ne as c,Pe as n,Qe as v,Re as d}from"./main-mg9b20ac.js";import{mh as S,nh as k,oh as Uq,ph as H,qh as D,rh as T,uh as M,vh as _}from"./main-xt9zc3n6.js";import"./main-2yeveeve.js";import"./main-0jys2ccn.js";import"./main-qsevpgsv.js";_();Uq();import{existsSync as Pq,readFileSync as a,statSync as Nq,writeFileSync as Yq}from"fs";import{basename as Bq,join as F,resolve as R}from"path";_();import{copyFileSync as s,existsSync as u,lstatSync as e,mkdirSync as x,readdirSync as i,readFileSync as r,renameSync as X,rmSync as I,writeFileSync as qq}from"fs";import{basename as Jq,dirname as h,join as B,resolve as Qq}from"path";import{gunzipSync as Wq}from"zlib";var L=2000,K=67108864,b=2*K,Zq=new Set([".git","node_modules"]);class U extends Error{code;constructor(J,Q){super(J);this.code=Q}}function C(J){let Q=[],G=(q,Z)=>{for(let O of i(q,{withFileTypes:!0})){let $=Z===""?O.name:`${Z}/${O.name}`,W=e(B(q,O.name));if(W.isSymbolicLink())throw new U(`symlink refused: ${$}`,1);if(W.isDirectory()){if(!Zq.has(O.name))G(B(q,O.name),$)}else if(W.isFile()&&!D(O.name))Q.push($)}};return G(J,""),Q.sort()}async function g(J,Q){let G={};for(let q of C(J))G[`${Q}/${q}`]=r(B(J,q));return new Bun.Archive(G,{compress:"gzip"}).bytes()}function $q(J){if(J.length===0)return"archive is empty";if(J.length>L)return`archive has ${J.length} entries (max ${L})`;let Q=new Set;for(let q of J){let Z=JSON.stringify(q);if(q.includes("\\"))return`unsafe entry ${Z}: backslash`;if(q.startsWith("/"))return`unsafe entry ${Z}: absolute path`;if(/^[A-Za-z]:/.test(q))return`unsafe entry ${Z}: drive letter`;let O=q.split("/");if(O.some(($)=>$===""))return`unsafe entry ${Z}: empty path segment`;if(O.some(($)=>$===".."||$==="."))return`unsafe entry ${Z}: relative segment`;if(O.length<2)return`entry ${Z} is not inside a top-level directory`;Q.add(O[0])}if(Q.size!==1)return`archive must hold exactly one top-level directory (found ${[...Q].sort().join(", ")})`;let G=[...Q][0];if(!J.includes(`${G}/${H}`))return`top-level directory ${JSON.stringify(G)} has no ${H}`;return null}var Gq={"1":"hard link","2":"symlink","3":"character device","4":"block device","6":"fifo"};function Oq(J){let Q=J;if(J[0]===31&&J[1]===139)try{Q=Wq(J,{maxOutputLength:b})}catch(q){return q.code==="ERR_BUFFER_TOO_LARGE"?`archive inflates past ${b} bytes`:null}let G=(q,Z)=>new TextDecoder().decode(Q.subarray(q,q+Z)).replace(/\0[\s\S]*$/,"");if(G(257,5)!=="ustar")return null;for(let q=0;q+512<=Q.length&&Q[q]!==0;){let Z=parseInt(G(q+124,12).trim()||"0",8);if(!Number.isFinite(Z))return null;let O=Gq[String.fromCharCode(Q[q+156])];if(O!==void 0){let $=G(q+345,155);return`unsafe entry ${JSON.stringify($===""?G(q,100):`${$}/${G(q,100)}`)}: ${O} member`}q+=512+Math.ceil(Z/512)*512}return null}async function zq(J,Q){for(let[G,q]of J){let Z=B(Q,G);x(h(Z),{recursive:!0}),qq(Z,new Uint8Array(await q.arrayBuffer()))}}var w=()=>Math.random().toString(36).slice(2,10);function p(J){x(J,{recursive:!0});let Q=B(J,`.install-${w()}`);return x(Q),Q}function j(J){for(let Q=1;;Q++)try{I(J,{recursive:!0,force:!0});return}catch(G){if(Q>=5)throw G;Bun.sleepSync(40*Q)}}function y(J,Q,G={}){let q=Qq(J);if(!u(B(q,H)))throw new U(`${q} has no ${H}`,2);let Z=C(q),O=p(Q);try{let $=B(O,Jq(q)),W=G.copyFile??s;for(let P of Z){let z=B($,P);x(h(z),{recursive:!0}),W(B(q,P),z)}return f(O,Q,G)}catch($){throw j(O),$}}async function A(J,Q,G={}){if(J.length>K)throw new U(`archive is ${J.length} bytes (max ${K})`,2);let q;try{q=await new Bun.Archive(J).files()}catch(W){throw new U(`not a tar.gz archive: ${W instanceof Error?W.message:String(W)}`,2)}let Z=$q([...q.keys()])??Oq(J);if(Z!==null)throw new U(Z,2);let O=0;for(let W of q.values())O+=W.size;if(O>K)throw new U(`archive unpacks to ${O} bytes (max ${K})`,2);let $=p(Q);try{return await zq(q,$),f($,Q,G)}catch(W){throw j($),W}}function f(J,Q,G){let q=new M(Q,{projectDir:J,globalDir:null}).scan();if(q.invalid.length>0)throw new U(`staged skill is invalid: ${q.invalid.map((W)=>W.reason).join("; ")}`,2);if(q.skills.length!==1)throw new U(`expected exactly one skill, found ${q.skills.length}`,2);let Z=q.skills[0];if(!/^[^/\\]+$/.test(Z.name)||Z.name==="."||Z.name===".."||Z.name.startsWith("."))throw new U(`refusing skill name ${JSON.stringify(Z.name)}`,2);let O=B(Q,Z.name),$=q.warnings.map((W)=>W.reason);if(u(O)){if(!G.force)throw new U(`${O} already exists (use --force to replace it)`,1);let W=B(Q,`.old-${w()}`);X(O,W);try{G.onSwap?.(),X(Z.dir,O)}catch(P){throw I(O,{recursive:!0,force:!0}),X(W,O),P}j(W)}else X(Z.dir,O);return j(J),{name:Z.name,version:Z.version,path:O,warnings:$}}var Hq={out:(J)=>console.log(J),err:(J)=>console.error(J)},Kq="usage: rovecode skills list [--json] | rovecode skills validate <dir> | rovecode skills pack <dir> [--out <file>] [--force] | rovecode skills install <dir|file.tar.gz|http(s)-url> [--user] [--force]",E=60000,m=5,Vq=new Set([301,302,303,307,308]),Xq=/^([a-z][a-z0-9+.-]*):\/\//i;async function gq(J,Q,G={}){let q=G.io??Hq,Z=J[0]??"",O=J.slice(1),$=new Set(O.filter((N)=>N.startsWith("--"))),W=O.indexOf("--out"),P=W!==-1?O[W+1]:void 0,z=O.filter((N,Y)=>!N.startsWith("--")&&O[Y-1]!=="--out"),V=G.globalDir??T(Q,"global");try{if(Z==="list")return xq(Q,V,$.has("--json"),q);if(Z==="validate"&&z[0]!==void 0)return jq(R(Q,z[0]),q);if(Z==="pack"&&z[0]!==void 0)return await Mq(R(Q,z[0]),P!==void 0?R(Q,P):void 0,$.has("--force"),Q,q);if(Z==="install"&&z[0]!==void 0){let N=$.has("--user")?V:T(Q,"project");return await Rq(z[0],Q,N,$.has("--force"),G.fetch??((Y,l)=>fetch(Y,l)),G.resolve??c,q)}}catch(N){return q.err(`error: ${N instanceof Error?N.message:String(N)}`),N instanceof U?N.code:2}return q.err(Kq),1}function xq(J,Q,G,q){let Z=new M(J,{globalDir:Q}).scan(),O=new Map;for(let W of Z.warnings)O.set(W.path,[...O.get(W.path)??[],W.reason]);let $=Z.skills.map((W)=>({name:W.name,version:W.version,scope:W.scope,path:W.path,dir:W.dir,description:W.fullDescription,license:W.license,compatibility:W.compatibility,metadata:W.metadata,allowedTools:W.allowedTools,warnings:O.get(W.path)??[]}));if(G)return q.out(JSON.stringify({skills:$,invalid:Z.invalid},null,2)),0;if($.length===0&&Z.invalid.length===0)return q.out(`no skills installed (${T(J,"project")} or ${Q}) \u2014 rovecode skills install <dir|file.tar.gz|url>`),0;for(let W of $)q.out(`${W.name.padEnd(24)} ${(W.version||"-").padEnd(10)} ${W.scope.padEnd(8)} ${W.path}`);for(let W of $)for(let P of W.warnings)q.err(`warning: ${W.path}: ${P}`);for(let W of Z.invalid)q.err(`warning: ${W.path}: not loaded \u2014 ${W.reason}`);return 0}function t(J){let Q=F(J,H),G;try{G=a(Q,"utf8")}catch(Z){throw new U(`cannot read ${Q}: ${Z instanceof Error?Z.message:String(Z)}`,2)}let q=S(G);if(q===null)throw new U(`${Q}: missing or unterminated frontmatter block`,1);return k(q,Bq(J),"strict")}function o(J,Q,G){for(let q of J.errors)G.err(`${F(Q,H)}: ${q}`);for(let q of J.notes)G.out(`note: ${q}`);return J.errors.length===0}function jq(J,Q){let G=t(J);if(!o(G,J,Q))return 1;return Q.out(`ok: ${G.meta.name}${G.meta.version?` (v${G.meta.version})`:""} \u2014 ${F(J,H)}`),0}async function Mq(J,Q,G,q,Z){let O=t(J);if(!o(O,J,Z))return 1;let $=Q??F(q,`${O.meta.name}.tar.gz`);if(Pq($)&&!G)return Z.err(`error: ${$} already exists (use --force to overwrite)`),1;let W=await g(J,O.meta.name);return Yq($,W),Z.out(`packed ${O.meta.name} \u2192 ${$} (${W.length} bytes)`),0}async function Rq(J,Q,G,q,Z,O,$){let W=Xq.exec(J)?.[1]?.toLowerCase(),P;if(W!==void 0){if(W!=="http"&&W!=="https")throw new U(`only http(s) URLs can be installed (got ${W}:)`,1);P=await A(await Tq(J,Z,O),G,{force:q})}else{let z=R(Q,J),V;try{V=Nq(z).isDirectory()}catch{throw new U(`${z}: no such file or directory`,2)}P=V?y(z,G,{force:q}):await A(a(z),G,{force:q})}$.out(`installed ${P.name}${P.version?` (v${P.version})`:""} \u2192 ${P.path}`);for(let z of P.warnings)$.err(`warning: ${z}`);return 0}async function Tq(J,Q,G){let q=new AbortController,Z=setTimeout(()=>q.abort(),E);Z.ref?.();let O=($)=>new U(`download failed: ${q.signal.aborted?`timed out after ${E}ms`:$ instanceof Error?$.message:String($)}`,2);try{let $=new URL(J),W=0;for(;;){if($.protocol!=="http:"&&$.protocol!=="https:")throw new U(`only http(s) URLs can be installed (got ${$.protocol})`,1);let P;try{P=await v(n($.hostname,G),q.signal)}catch(Y){throw O(Y)}if(P!==null)throw new U(`refused ${$.href}: ${P}`,1);let z;try{z=await v(Q($.href,{signal:q.signal,redirect:"manual"}),q.signal)}catch(Y){throw O(Y)}if(Vq.has(z.status)){let Y=z.headers.get("location");if(await z.body?.cancel().catch(()=>{}),!Y)throw new U(`download failed: HTTP ${z.status} from ${$.href} without a Location header`,2);if(++W>m)throw new U(`download failed: too many redirects (more than ${m}) starting from ${J}`,2);try{$=new URL(Y,$)}catch{throw new U(`download failed: invalid redirect target ${Y}`,2)}continue}if(!z.ok)throw new U(`download failed: HTTP ${z.status} for ${$.href}`,2);let{bytes:V,truncated:N}=await d(z,K);if(N)throw new U(`download exceeds ${K} bytes`,2);return V}}finally{clearTimeout(Z)}}export{gq as cmdSkills,Kq as SKILLS_USAGE,m as MAX_REDIRECTS,E as INSTALL_TIMEOUT_MS};
2
+ import{$e as H,Ye as S,Ze as k,_e as Uq,af as D,bf as T,ef as M,ff as _}from"./main-351pz3z7.js";import{Df as c,Ff as n,Gf as v,Hf as d}from"./main-skbp13js.js";import"./main-2yeveeve.js";import"./main-0jys2ccn.js";import"./main-qsevpgsv.js";_();Uq();import{existsSync as Pq,readFileSync as a,statSync as Nq,writeFileSync as Yq}from"fs";import{basename as Bq,join as F,resolve as R}from"path";_();import{copyFileSync as s,existsSync as u,lstatSync as e,mkdirSync as x,readdirSync as i,readFileSync as r,renameSync as X,rmSync as I,writeFileSync as qq}from"fs";import{basename as Jq,dirname as h,join as B,resolve as Qq}from"path";import{gunzipSync as Wq}from"zlib";var L=2000,K=67108864,b=2*K,Zq=new Set([".git","node_modules"]);class U extends Error{code;constructor(J,Q){super(J);this.code=Q}}function C(J){let Q=[],G=(q,Z)=>{for(let O of i(q,{withFileTypes:!0})){let $=Z===""?O.name:`${Z}/${O.name}`,W=e(B(q,O.name));if(W.isSymbolicLink())throw new U(`symlink refused: ${$}`,1);if(W.isDirectory()){if(!Zq.has(O.name))G(B(q,O.name),$)}else if(W.isFile()&&!D(O.name))Q.push($)}};return G(J,""),Q.sort()}async function g(J,Q){let G={};for(let q of C(J))G[`${Q}/${q}`]=r(B(J,q));return new Bun.Archive(G,{compress:"gzip"}).bytes()}function $q(J){if(J.length===0)return"archive is empty";if(J.length>L)return`archive has ${J.length} entries (max ${L})`;let Q=new Set;for(let q of J){let Z=JSON.stringify(q);if(q.includes("\\"))return`unsafe entry ${Z}: backslash`;if(q.startsWith("/"))return`unsafe entry ${Z}: absolute path`;if(/^[A-Za-z]:/.test(q))return`unsafe entry ${Z}: drive letter`;let O=q.split("/");if(O.some(($)=>$===""))return`unsafe entry ${Z}: empty path segment`;if(O.some(($)=>$===".."||$==="."))return`unsafe entry ${Z}: relative segment`;if(O.length<2)return`entry ${Z} is not inside a top-level directory`;Q.add(O[0])}if(Q.size!==1)return`archive must hold exactly one top-level directory (found ${[...Q].sort().join(", ")})`;let G=[...Q][0];if(!J.includes(`${G}/${H}`))return`top-level directory ${JSON.stringify(G)} has no ${H}`;return null}var Gq={"1":"hard link","2":"symlink","3":"character device","4":"block device","6":"fifo"};function Oq(J){let Q=J;if(J[0]===31&&J[1]===139)try{Q=Wq(J,{maxOutputLength:b})}catch(q){return q.code==="ERR_BUFFER_TOO_LARGE"?`archive inflates past ${b} bytes`:null}let G=(q,Z)=>new TextDecoder().decode(Q.subarray(q,q+Z)).replace(/\0[\s\S]*$/,"");if(G(257,5)!=="ustar")return null;for(let q=0;q+512<=Q.length&&Q[q]!==0;){let Z=parseInt(G(q+124,12).trim()||"0",8);if(!Number.isFinite(Z))return null;let O=Gq[String.fromCharCode(Q[q+156])];if(O!==void 0){let $=G(q+345,155);return`unsafe entry ${JSON.stringify($===""?G(q,100):`${$}/${G(q,100)}`)}: ${O} member`}q+=512+Math.ceil(Z/512)*512}return null}async function zq(J,Q){for(let[G,q]of J){let Z=B(Q,G);x(h(Z),{recursive:!0}),qq(Z,new Uint8Array(await q.arrayBuffer()))}}var w=()=>Math.random().toString(36).slice(2,10);function p(J){x(J,{recursive:!0});let Q=B(J,`.install-${w()}`);return x(Q),Q}function j(J){for(let Q=1;;Q++)try{I(J,{recursive:!0,force:!0});return}catch(G){if(Q>=5)throw G;Bun.sleepSync(40*Q)}}function y(J,Q,G={}){let q=Qq(J);if(!u(B(q,H)))throw new U(`${q} has no ${H}`,2);let Z=C(q),O=p(Q);try{let $=B(O,Jq(q)),W=G.copyFile??s;for(let P of Z){let z=B($,P);x(h(z),{recursive:!0}),W(B(q,P),z)}return f(O,Q,G)}catch($){throw j(O),$}}async function A(J,Q,G={}){if(J.length>K)throw new U(`archive is ${J.length} bytes (max ${K})`,2);let q;try{q=await new Bun.Archive(J).files()}catch(W){throw new U(`not a tar.gz archive: ${W instanceof Error?W.message:String(W)}`,2)}let Z=$q([...q.keys()])??Oq(J);if(Z!==null)throw new U(Z,2);let O=0;for(let W of q.values())O+=W.size;if(O>K)throw new U(`archive unpacks to ${O} bytes (max ${K})`,2);let $=p(Q);try{return await zq(q,$),f($,Q,G)}catch(W){throw j($),W}}function f(J,Q,G){let q=new M(Q,{projectDir:J,globalDir:null}).scan();if(q.invalid.length>0)throw new U(`staged skill is invalid: ${q.invalid.map((W)=>W.reason).join("; ")}`,2);if(q.skills.length!==1)throw new U(`expected exactly one skill, found ${q.skills.length}`,2);let Z=q.skills[0];if(!/^[^/\\]+$/.test(Z.name)||Z.name==="."||Z.name===".."||Z.name.startsWith("."))throw new U(`refusing skill name ${JSON.stringify(Z.name)}`,2);let O=B(Q,Z.name),$=q.warnings.map((W)=>W.reason);if(u(O)){if(!G.force)throw new U(`${O} already exists (use --force to replace it)`,1);let W=B(Q,`.old-${w()}`);X(O,W);try{G.onSwap?.(),X(Z.dir,O)}catch(P){throw I(O,{recursive:!0,force:!0}),X(W,O),P}j(W)}else X(Z.dir,O);return j(J),{name:Z.name,version:Z.version,path:O,warnings:$}}var Hq={out:(J)=>console.log(J),err:(J)=>console.error(J)},Kq="usage: rovecode skills list [--json] | rovecode skills validate <dir> | rovecode skills pack <dir> [--out <file>] [--force] | rovecode skills install <dir|file.tar.gz|http(s)-url> [--user] [--force]",E=60000,m=5,Vq=new Set([301,302,303,307,308]),Xq=/^([a-z][a-z0-9+.-]*):\/\//i;async function gq(J,Q,G={}){let q=G.io??Hq,Z=J[0]??"",O=J.slice(1),$=new Set(O.filter((N)=>N.startsWith("--"))),W=O.indexOf("--out"),P=W!==-1?O[W+1]:void 0,z=O.filter((N,Y)=>!N.startsWith("--")&&O[Y-1]!=="--out"),V=G.globalDir??T(Q,"global");try{if(Z==="list")return xq(Q,V,$.has("--json"),q);if(Z==="validate"&&z[0]!==void 0)return jq(R(Q,z[0]),q);if(Z==="pack"&&z[0]!==void 0)return await Mq(R(Q,z[0]),P!==void 0?R(Q,P):void 0,$.has("--force"),Q,q);if(Z==="install"&&z[0]!==void 0){let N=$.has("--user")?V:T(Q,"project");return await Rq(z[0],Q,N,$.has("--force"),G.fetch??((Y,l)=>fetch(Y,l)),G.resolve??c,q)}}catch(N){return q.err(`error: ${N instanceof Error?N.message:String(N)}`),N instanceof U?N.code:2}return q.err(Kq),1}function xq(J,Q,G,q){let Z=new M(J,{globalDir:Q}).scan(),O=new Map;for(let W of Z.warnings)O.set(W.path,[...O.get(W.path)??[],W.reason]);let $=Z.skills.map((W)=>({name:W.name,version:W.version,scope:W.scope,path:W.path,dir:W.dir,description:W.fullDescription,license:W.license,compatibility:W.compatibility,metadata:W.metadata,allowedTools:W.allowedTools,warnings:O.get(W.path)??[]}));if(G)return q.out(JSON.stringify({skills:$,invalid:Z.invalid},null,2)),0;if($.length===0&&Z.invalid.length===0)return q.out(`no skills installed (${T(J,"project")} or ${Q}) \u2014 rovecode skills install <dir|file.tar.gz|url>`),0;for(let W of $)q.out(`${W.name.padEnd(24)} ${(W.version||"-").padEnd(10)} ${W.scope.padEnd(8)} ${W.path}`);for(let W of $)for(let P of W.warnings)q.err(`warning: ${W.path}: ${P}`);for(let W of Z.invalid)q.err(`warning: ${W.path}: not loaded \u2014 ${W.reason}`);return 0}function t(J){let Q=F(J,H),G;try{G=a(Q,"utf8")}catch(Z){throw new U(`cannot read ${Q}: ${Z instanceof Error?Z.message:String(Z)}`,2)}let q=S(G);if(q===null)throw new U(`${Q}: missing or unterminated frontmatter block`,1);return k(q,Bq(J),"strict")}function o(J,Q,G){for(let q of J.errors)G.err(`${F(Q,H)}: ${q}`);for(let q of J.notes)G.out(`note: ${q}`);return J.errors.length===0}function jq(J,Q){let G=t(J);if(!o(G,J,Q))return 1;return Q.out(`ok: ${G.meta.name}${G.meta.version?` (v${G.meta.version})`:""} \u2014 ${F(J,H)}`),0}async function Mq(J,Q,G,q,Z){let O=t(J);if(!o(O,J,Z))return 1;let $=Q??F(q,`${O.meta.name}.tar.gz`);if(Pq($)&&!G)return Z.err(`error: ${$} already exists (use --force to overwrite)`),1;let W=await g(J,O.meta.name);return Yq($,W),Z.out(`packed ${O.meta.name} \u2192 ${$} (${W.length} bytes)`),0}async function Rq(J,Q,G,q,Z,O,$){let W=Xq.exec(J)?.[1]?.toLowerCase(),P;if(W!==void 0){if(W!=="http"&&W!=="https")throw new U(`only http(s) URLs can be installed (got ${W}:)`,1);P=await A(await Tq(J,Z,O),G,{force:q})}else{let z=R(Q,J),V;try{V=Nq(z).isDirectory()}catch{throw new U(`${z}: no such file or directory`,2)}P=V?y(z,G,{force:q}):await A(a(z),G,{force:q})}$.out(`installed ${P.name}${P.version?` (v${P.version})`:""} \u2192 ${P.path}`);for(let z of P.warnings)$.err(`warning: ${z}`);return 0}async function Tq(J,Q,G){let q=new AbortController,Z=setTimeout(()=>q.abort(),E);Z.ref?.();let O=($)=>new U(`download failed: ${q.signal.aborted?`timed out after ${E}ms`:$ instanceof Error?$.message:String($)}`,2);try{let $=new URL(J),W=0;for(;;){if($.protocol!=="http:"&&$.protocol!=="https:")throw new U(`only http(s) URLs can be installed (got ${$.protocol})`,1);let P;try{P=await v(n($.hostname,G),q.signal)}catch(Y){throw O(Y)}if(P!==null)throw new U(`refused ${$.href}: ${P}`,1);let z;try{z=await v(Q($.href,{signal:q.signal,redirect:"manual"}),q.signal)}catch(Y){throw O(Y)}if(Vq.has(z.status)){let Y=z.headers.get("location");if(await z.body?.cancel().catch(()=>{}),!Y)throw new U(`download failed: HTTP ${z.status} from ${$.href} without a Location header`,2);if(++W>m)throw new U(`download failed: too many redirects (more than ${m}) starting from ${J}`,2);try{$=new URL(Y,$)}catch{throw new U(`download failed: invalid redirect target ${Y}`,2)}continue}if(!z.ok)throw new U(`download failed: HTTP ${z.status} for ${$.href}`,2);let{bytes:V,truncated:N}=await d(z,K);if(N)throw new U(`download exceeds ${K} bytes`,2);return V}}finally{clearTimeout(Z)}}export{gq as cmdSkills,Kq as SKILLS_USAGE,m as MAX_REDIRECTS,E as INSTALL_TIMEOUT_MS};
@@ -0,0 +1,8 @@
1
+ // @bun
2
+ import{x as $}from"./main-yn8cd281.js";import"./main-hq51jg8v.js";import{P as _,R as j}from"./main-2wwjex5j.js";import"./main-yr0ksc0h.js";import"./main-xy53xf0r.js";import"./main-7c5thhjd.js";import"./main-zc2e8e46.js";import"./main-4xcmvxnk.js";import"./main-wbrdspr2.js";import"./main-27y4sm2k.js";import"./main-73g7eff4.js";import"./main-1ereejm1.js";import"./main-vqak588n.js";import"./main-aecrjq2d.js";import"./main-rfth4tbm.js";import"./main-6genrmhs.js";import"./main-zzrfw6cf.js";import"./main-0ab9fc26.js";import"./main-80haw7qk.js";import"./main-6dnk69vp.js";import"./main-w2n1303f.js";import"./main-0mtcdbs7.js";import"./main-pn1w7a7j.js";import"./main-m1kk6fp5.js";import"./main-wsrg79c1.js";import"./main-ck9asesq.js";import"./main-kd488vje.js";import"./main-6b62vkz0.js";import"./main-rdgdw24b.js";import"./main-3pjrb2hd.js";import"./main-351pz3z7.js";import"./main-dfreez27.js";import"./main-4b3jgy66.js";import"./main-skbp13js.js";import"./main-xvnrabfp.js";import"./main-t4xnd213.js";import"./main-3nf3kgve.js";import"./main-cta9racd.js";import{Rg as Y,Sg as Z,bh as g}from"./main-1dchs7xv.js";import"./main-rg0wn0xf.js";import"./main-y1fqy60y.js";import"./main-2yfck9b5.js";import"./main-kh32yvgk.js";import"./main-kcpbykxz.js";import"./main-z3aayzvq.js";import"./main-0z1w2zsg.js";import"./main-ddv7j2ag.js";import"./main-3gjqfh7a.js";import{Ji as O,Ki as Q,Li as L}from"./main-k2y8a2aw.js";import"./main-875s60s2.js";import"./main-sdmxhtv8.js";import"./main-pknhvrmj.js";import"./main-1k1kw6b5.js";import"./main-90ds1z4e.js";import"./main-9etavkew.js";import"./main-q3vsesf9.js";import"./main-xg704a3c.js";import"./main-8kjxbpw4.js";import"./main-gzkmycnv.js";import"./main-3rxcvgna.js";import"./main-4wndhjdc.js";import"./main-ggcn7rd7.js";import"./main-0904f6ps.js";import"./main-prxxs70n.js";import"./main-n0t3973w.js";import"./main-2zmzgkwh.js";import"./main-a9njrkk1.js";import"./main-7rn6bqje.js";import"./main-mv40pcr2.js";import"./main-2yeveeve.js";import"./main-0jys2ccn.js";import"./main-nqveez48.js";import"./main-qsevpgsv.js";import W from"@xterm/headless";var X=W.Terminal;class K{xterm;inputHandler;resizeHandler;_columns;_rows;constructor(q=80,A=24){this._columns=q,this._rows=A,this.xterm=new X({cols:q,rows:A,disableStdin:!0,allowProposedApi:!0})}start(q,A){this.inputHandler=q,this.resizeHandler=A,this.xterm.write("\x1B[?2004h")}async drainInput(q,A){}stop(){this.xterm.write("\x1B[?2004l"),this.inputHandler=void 0,this.resizeHandler=void 0}write(q){this.xterm.write(q)}get columns(){return this._columns}get rows(){return this._rows}get kittyProtocolActive(){return!0}moveBy(q){if(q>0)this.xterm.write(`\x1B[${q}B`);else if(q<0)this.xterm.write(`\x1B[${-q}A`)}hideCursor(){this.xterm.write("\x1B[?25l")}showCursor(){this.xterm.write("\x1B[?25h")}clearLine(){this.xterm.write("\x1B[K")}clearFromCursor(){this.xterm.write("\x1B[J")}clearScreen(){this.xterm.write("\x1B[2J\x1B[H")}setTitle(q){this.xterm.write(`\x1B]0;${q}\x07`)}setProgress(q){}sendInput(q){if(this.inputHandler)this.inputHandler(q)}resize(q,A){if(this._columns=q,this._rows=A,this.xterm.resize(q,A),this.resizeHandler)this.resizeHandler()}async flush(){return new Promise((q)=>{this.xterm.write("",()=>q())})}async flushAndGetViewport(){return await this.flush(),this.getViewport()}getViewport(){let q=[],A=this.xterm.buffer.active;for(let B=0;B<this.xterm.rows;B++){let C=A.getLine(A.viewportY+B);if(C)q.push(C.translateToString(!0));else q.push("")}return q}getScrollBuffer(){let q=[],A=this.xterm.buffer.active;for(let B=0;B<A.length;B++){let C=A.getLine(B);if(C)q.push(C.translateToString(!0));else q.push("")}return q}clear(){this.xterm.clear()}reset(){this.xterm.reset()}getCursorPosition(){let q=this.xterm.buffer.active;return{x:q.cursorX,y:q.cursorY}}async waitForRender(){await new Promise((q)=>process.nextTick(q)),await new Promise((q)=>setTimeout(q,20)),await this.flush()}}j();g();import{mkdtempSync as y,rmSync as z}from"fs";import{tmpdir as I}from"os";import{join as N}from"path";async function u(){let q=y(N(I(),"rovecode-tui-smoke-")),A=new K(80,24),B=new _({terminal:A,cwd:q}),C=N(q,"smoke.txt"),R=`smoke-ok
3
+ `,H=O({turns:[L([{id:"t1",tool:"write",args:{path:C,content:`smoke-ok
4
+ `}}]),L([{id:"t2",tool:"edit",args:{path:C,edits:[{tag:Z(`smoke-ok
5
+ `),anchorLine:1,anchorHash:Y("smoke-ok"),newLines:["smoke-edited"]}]}}]),Q(`# Smoke OK
6
+
7
+ rendered **markdown**, a tool card, and the status line.`)]}),P=$({renderer:B,stream:H,cwd:q,permission:"ask",exitOnClose:!1,model:"scripted"});A.sendInput("hello rovecode"),A.sendInput("\r");let G=["+smoke-ok","-smoke-ok"],E=[],U=Date.now()+1e4,F=[],J=!1;while(Date.now()<U){F=await A.flushAndGetViewport();let D=F.join(`
8
+ `);if(D.includes("Smoke OK")&&D.includes("write")&&E.length===G.length){J=!0;break}let M=G[E.length];if(M!==void 0&&D.includes("allow once")&&D.includes(M))E.push(F),A.sendInput("\r");await new Promise((V)=>setTimeout(V,50))}A.sendInput("\x03"),await P,z(q,{recursive:!0,force:!0}),console.log("\u2500\u2500 approval overlay with diff card (edit) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500");for(let D of E[1]??["(diff card never rendered)"])console.log(D.trimEnd());console.log("\u2500\u2500 emulated 80x24 screen \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500");for(let D of F)console.log(D.trimEnd());console.log("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"),console.log(J?"smoke-tui: PASS (markdown + tool card + diff card rendered through full pipeline)":`smoke-tui: FAIL (diff cards seen: ${E.length}/${G.length})`),process.exit(J?0:1)}export{u as runTuiSmoke};