rovecode 0.3.3 → 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 (495) hide show
  1. package/CHANGELOG.md +527 -0
  2. package/README.md +46 -48
  3. package/bin/rovecode.js +24 -0
  4. package/dist/cli/app-j6gn14w3.js +2 -0
  5. package/dist/cli/ask-user-cwstt8fz.js +2 -0
  6. package/dist/cli/auth-login-9bbp9915.js +2 -0
  7. package/dist/cli/auth-m8p9grty.js +2 -0
  8. package/dist/cli/bench-16zqdms5.js +9 -0
  9. package/dist/cli/catalog-1xchffa4.js +2 -0
  10. package/dist/cli/cli-1n1zb64f.js +2 -0
  11. package/dist/cli/client-2t9gjkck.js +2 -0
  12. package/dist/cli/commands-exafvm2b.js +2 -0
  13. package/dist/cli/connect-6zde0kn3.js +2 -0
  14. package/dist/cli/context-cmd-5t43wgqt.js +2 -0
  15. package/dist/cli/context-report-kt01pw8y.js +2 -0
  16. package/dist/cli/count-remote-ap7x3vh6.js +2 -0
  17. package/dist/cli/design-ne5zszyh.js +2 -0
  18. package/dist/cli/dispatch-2r5myxye.js +2 -0
  19. package/dist/cli/doctor-ws4fh4tn.js +3 -0
  20. package/dist/cli/executor-bdrjn634.js +2 -0
  21. package/dist/cli/export-1mxb9g5p.js +2 -0
  22. package/dist/cli/files-g104xghh.js +2 -0
  23. package/dist/cli/gauntlet-07xrjpj7.js +2 -0
  24. package/dist/cli/gauntlet-runner-xvy64436.js +10 -0
  25. package/dist/cli/gauntlet-wave3-jm91yt5w.js +5 -0
  26. package/dist/cli/gauntlet-wave4-r13py7p1.js +14 -0
  27. package/dist/cli/hashline-znvrat11.js +2 -0
  28. package/dist/cli/http-xafw6fsh.js +143 -0
  29. package/dist/cli/index-1sgjm25y.js +2 -0
  30. package/dist/cli/init-g2m0tn4m.js +51 -0
  31. package/dist/cli/install-avaqjjqq.js +2 -0
  32. package/dist/cli/loop-mmpfft01.js +2 -0
  33. package/dist/cli/main-0904f6ps.js +5 -0
  34. package/dist/cli/main-0ab9fc26.js +9 -0
  35. package/dist/cli/main-0jys2ccn.js +3 -0
  36. package/dist/cli/main-0mtcdbs7.js +3 -0
  37. package/dist/cli/main-0z1w2zsg.js +3 -0
  38. package/dist/cli/main-1dchs7xv.js +18 -0
  39. package/dist/cli/main-1ereejm1.js +3 -0
  40. package/dist/cli/main-1k1kw6b5.js +3 -0
  41. package/dist/cli/main-27y4sm2k.js +38 -0
  42. package/dist/cli/main-2wwjex5j.js +58 -0
  43. package/dist/cli/main-2yeveeve.js +6 -0
  44. package/dist/cli/main-2yfck9b5.js +3 -0
  45. package/dist/cli/main-2zmzgkwh.js +3 -0
  46. package/dist/cli/main-351pz3z7.js +7 -0
  47. package/dist/cli/main-3gjqfh7a.js +6 -0
  48. package/dist/cli/main-3nf3kgve.js +3 -0
  49. package/dist/cli/main-3pjrb2hd.js +3 -0
  50. package/dist/cli/main-3rxcvgna.js +19 -0
  51. package/dist/cli/main-4b3jgy66.js +19 -0
  52. package/dist/cli/main-4wndhjdc.js +7 -0
  53. package/dist/cli/main-4xcmvxnk.js +3 -0
  54. package/dist/cli/main-5tbz0wbz.js +4 -0
  55. package/dist/cli/main-5ywnwthm.js +3 -0
  56. package/dist/cli/main-6b62vkz0.js +14 -0
  57. package/dist/cli/main-6dnk69vp.js +3 -0
  58. package/dist/cli/main-6genrmhs.js +136 -0
  59. package/dist/cli/main-73g7eff4.js +15 -0
  60. package/dist/cli/main-7c5thhjd.js +5 -0
  61. package/dist/cli/main-7rn6bqje.js +3 -0
  62. package/dist/cli/main-80haw7qk.js +4 -0
  63. package/dist/cli/main-875s60s2.js +4 -0
  64. package/dist/cli/main-8kjxbpw4.js +8 -0
  65. package/dist/cli/main-90ds1z4e.js +10 -0
  66. package/dist/cli/main-9etavkew.js +3 -0
  67. package/dist/cli/main-a9njrkk1.js +3 -0
  68. package/dist/cli/main-aecrjq2d.js +12 -0
  69. package/dist/cli/main-ck9asesq.js +9 -0
  70. package/dist/cli/main-cta9racd.js +4 -0
  71. package/dist/cli/main-ddv7j2ag.js +3 -0
  72. package/dist/cli/main-dfreez27.js +10 -0
  73. package/dist/cli/main-f7rw7des.js +3 -0
  74. package/dist/cli/main-ggcn7rd7.js +5 -0
  75. package/dist/cli/main-gzkmycnv.js +3 -0
  76. package/dist/cli/main-hq51jg8v.js +18 -0
  77. package/dist/cli/main-jft389w9.js +8 -0
  78. package/dist/cli/main-k1eqkg83.js +3 -0
  79. package/dist/cli/main-k2y8a2aw.js +9 -0
  80. package/dist/cli/main-kcpbykxz.js +4 -0
  81. package/dist/cli/main-kd488vje.js +22 -0
  82. package/dist/cli/main-kh32yvgk.js +5 -0
  83. package/dist/cli/main-kqxnqjnv.js +25 -0
  84. package/dist/cli/main-kyn0xnsg.js +3 -0
  85. package/dist/cli/main-m1kk6fp5.js +21 -0
  86. package/dist/cli/main-mv40pcr2.js +4 -0
  87. package/dist/cli/main-n0t3973w.js +3 -0
  88. package/dist/cli/main-nqveez48.js +4 -0
  89. package/dist/cli/main-pknhvrmj.js +3 -0
  90. package/dist/cli/main-pn1w7a7j.js +3 -0
  91. package/dist/cli/main-prxxs70n.js +4 -0
  92. package/dist/cli/main-q3vsesf9.js +3 -0
  93. package/dist/cli/main-qsevpgsv.js +3 -0
  94. package/dist/cli/main-rdgdw24b.js +25 -0
  95. package/dist/cli/main-rfth4tbm.js +16 -0
  96. package/dist/cli/main-rg0wn0xf.js +5 -0
  97. package/dist/cli/main-sdmxhtv8.js +4 -0
  98. package/dist/cli/main-skbp13js.js +18 -0
  99. package/dist/cli/main-t4xnd213.js +7 -0
  100. package/dist/cli/main-vqak588n.js +4 -0
  101. package/dist/cli/main-w2n1303f.js +9 -0
  102. package/dist/cli/main-wbrdspr2.js +5 -0
  103. package/dist/cli/main-wsrg79c1.js +7 -0
  104. package/dist/cli/main-x4r0fne4.js +5 -0
  105. package/dist/cli/main-xea2f3tn.js +6 -0
  106. package/dist/cli/main-xg704a3c.js +3 -0
  107. package/dist/cli/main-xvnrabfp.js +16 -0
  108. package/dist/cli/main-xy53xf0r.js +4 -0
  109. package/dist/cli/main-y1fqy60y.js +3 -0
  110. package/dist/cli/main-yn8cd281.js +34 -0
  111. package/dist/cli/main-yr0ksc0h.js +4 -0
  112. package/dist/cli/main-z2ex2vyf.js +4 -0
  113. package/dist/cli/main-z3aayzvq.js +3 -0
  114. package/dist/cli/main-zaqh35jg.js +3 -0
  115. package/dist/cli/main-zc2e8e46.js +4 -0
  116. package/dist/cli/main-zzrfw6cf.js +13 -0
  117. package/dist/cli/main.js +280 -0
  118. package/dist/cli/market-cmd-e14kmx9n.js +5 -0
  119. package/dist/cli/mcp-login-wq7ktdek.js +2 -0
  120. package/dist/cli/mcp-market-cmd-9mg3jecy.js +2 -0
  121. package/dist/cli/notify-b7qc0cjb.js +2 -0
  122. package/dist/cli/oauth-z8whcgfx.js +2 -0
  123. package/dist/cli/output-b3ewj3ps.js +16 -0
  124. package/dist/cli/profiles-6mr5he5e.js +2 -0
  125. package/dist/cli/provider-config-g7j42q8x.js +2 -0
  126. package/dist/cli/provider-jr1y8vvm.js +2 -0
  127. package/dist/cli/registry-s8yk86g0.js +2 -0
  128. package/dist/cli/registry-t6p8d4mn.js +2 -0
  129. package/dist/cli/repl-bajwe1mh.js +11 -0
  130. package/dist/cli/resume-rwn9nz7y.js +2 -0
  131. package/dist/cli/run-flags-nah7ndpt.js +2 -0
  132. package/dist/cli/runtime-n7gafzhb.js +2 -0
  133. package/dist/cli/sandbox-config-emdy18x4.js +2 -0
  134. package/dist/cli/server-b0nvs2bn.js +5 -0
  135. package/dist/cli/session-arg-y75wd4kj.js +2 -0
  136. package/dist/cli/session-j62evmjq.js +2 -0
  137. package/dist/cli/sessions-cmd-tsnwz0ns.js +7 -0
  138. package/dist/cli/settings-df10wfez.js +2 -0
  139. package/dist/cli/setup-jzvv72fg.js +2 -0
  140. package/dist/cli/sextant-smoke-37m81ke6.js +5 -0
  141. package/dist/cli/skills-cmd-gjxnxnhx.js +2 -0
  142. package/dist/cli/smoke-p7748apt.js +8 -0
  143. package/dist/cli/start-chat-s4st3mm0.js +12 -0
  144. package/dist/cli/stream-gmeyewds.js +2 -0
  145. package/dist/cli/task-gh0kkp3n.js +2 -0
  146. package/dist/cli/tasks-z1kfpe8e.js +2 -0
  147. package/dist/cli/thinking-0eqkrz6t.js +2 -0
  148. package/dist/cli/todo-5brcrt9m.js +2 -0
  149. package/dist/cli/tools-7pzm0vj9.js +2 -0
  150. package/dist/cli/tools-s635p6s8.js +2 -0
  151. package/dist/cli/trust-cmd-cjav8zgm.js +2 -0
  152. package/dist/cli/update-check-pt31bm2f.js +2 -0
  153. package/dist/cli/update-cmd-tk131s9t.js +2 -0
  154. package/dist/cli/voice-56nabd8d.js +2 -0
  155. package/dist/cli/webfetch-xd8q596m.js +2 -0
  156. package/dist/cli/websearch-5hkf98k1.js +2 -0
  157. package/dist/cli/workflow-cmd-cy3cvzjp.js +4 -0
  158. package/dist/cli/workspace-q10g5z3e.js +2 -0
  159. package/dist/lib/index.js +62 -0
  160. package/dist/lib/models-index.json +1 -0
  161. package/dist/lib/plugins.js +55 -0
  162. package/dist/lib/providers.js +17 -0
  163. package/dist/lib/public-api.js +20 -0
  164. package/dist/lib/sdk.js +360 -0
  165. package/package.json +84 -72
  166. package/bin/rovecode.ts +0 -21
  167. package/src/acp/server.ts +0 -374
  168. package/src/cli/auth-login.ts +0 -122
  169. package/src/cli/connect.ts +0 -244
  170. package/src/cli/context-cmd.ts +0 -199
  171. package/src/cli/dispatch.ts +0 -82
  172. package/src/cli/doctor.ts +0 -362
  173. package/src/cli/export.ts +0 -276
  174. package/src/cli/help.ts +0 -293
  175. package/src/cli/is-tui-invocation.ts +0 -8
  176. package/src/cli/main.ts +0 -583
  177. package/src/cli/market-cmd.ts +0 -658
  178. package/src/cli/mcp-login.ts +0 -141
  179. package/src/cli/mcp-market-cmd.ts +0 -302
  180. package/src/cli/output.ts +0 -382
  181. package/src/cli/repl.ts +0 -250
  182. package/src/cli/repomap-root.ts +0 -14
  183. package/src/cli/resume.ts +0 -57
  184. package/src/cli/run-flags.ts +0 -43
  185. package/src/cli/run-limits.ts +0 -78
  186. package/src/cli/runtime.ts +0 -931
  187. package/src/cli/session-arg.ts +0 -30
  188. package/src/cli/sessions-cmd.ts +0 -145
  189. package/src/cli/setup.ts +0 -153
  190. package/src/cli/skills-cmd.ts +0 -194
  191. package/src/cli/start-chat.ts +0 -65
  192. package/src/cli/trust-cmd.ts +0 -52
  193. package/src/coding/bash.ts +0 -148
  194. package/src/coding/checkpoints.ts +0 -327
  195. package/src/coding/diff.ts +0 -138
  196. package/src/coding/files.ts +0 -341
  197. package/src/coding/hashline.ts +0 -274
  198. package/src/coding/lsp-gate.ts +0 -254
  199. package/src/coding/lsp-servers.ts +0 -147
  200. package/src/coding/lsp.ts +0 -283
  201. package/src/coding/repomap-cache.ts +0 -99
  202. package/src/coding/repomap-files.ts +0 -192
  203. package/src/coding/repomap.ts +0 -481
  204. package/src/core/agents.ts +0 -255
  205. package/src/core/compaction.ts +0 -259
  206. package/src/core/config.ts +0 -289
  207. package/src/core/context-report.ts +0 -228
  208. package/src/core/context.ts +0 -60
  209. package/src/core/count-remote.ts +0 -107
  210. package/src/core/execpolicy-rules.ts +0 -196
  211. package/src/core/execpolicy.ts +0 -385
  212. package/src/core/executor.ts +0 -454
  213. package/src/core/guardrails.ts +0 -400
  214. package/src/core/hooks.ts +0 -411
  215. package/src/core/images.ts +0 -230
  216. package/src/core/intro.ts +0 -266
  217. package/src/core/loop.ts +0 -567
  218. package/src/core/modes.ts +0 -372
  219. package/src/core/orchestrator.ts +0 -245
  220. package/src/core/proc-group.ts +0 -48
  221. package/src/core/project-trust.ts +0 -98
  222. package/src/core/reflection.ts +0 -165
  223. package/src/core/sandbox-config.ts +0 -186
  224. package/src/core/session-id.ts +0 -24
  225. package/src/core/session-images.ts +0 -73
  226. package/src/core/session-ops.ts +0 -183
  227. package/src/core/session-text.ts +0 -29
  228. package/src/core/session.ts +0 -469
  229. package/src/core/settings.ts +0 -170
  230. package/src/core/tasks.ts +0 -646
  231. package/src/core/token-scale.ts +0 -108
  232. package/src/core/tools.ts +0 -309
  233. package/src/core/trust.ts +0 -104
  234. package/src/core/types.ts +0 -330
  235. package/src/core/update-check.ts +0 -171
  236. package/src/core/usage.ts +0 -204
  237. package/src/core/validate.ts +0 -121
  238. package/src/core/verify-gate.ts +0 -159
  239. package/src/core/verify.ts +0 -236
  240. package/src/core/voice.ts +0 -158
  241. package/src/core/win-job.ts +0 -183
  242. package/src/core/workspace.ts +0 -184
  243. package/src/design/audit.ts +0 -797
  244. package/src/design/direction.ts +0 -190
  245. package/src/design/rules.ts +0 -157
  246. package/src/eval/bench.ts +0 -150
  247. package/src/eval/gauntlet-runner.ts +0 -215
  248. package/src/eval/gauntlet-support.ts +0 -84
  249. package/src/eval/gauntlet-wave3.ts +0 -269
  250. package/src/eval/gauntlet-wave4.ts +0 -217
  251. package/src/eval/gauntlet.ts +0 -253
  252. package/src/index.ts +0 -17
  253. package/src/lanes/agy.ts +0 -95
  254. package/src/lanes/approval.ts +0 -24
  255. package/src/lanes/claude.ts +0 -129
  256. package/src/lanes/codex.ts +0 -127
  257. package/src/lanes/events.ts +0 -130
  258. package/src/lanes/job.ts +0 -142
  259. package/src/lanes/opencode.ts +0 -122
  260. package/src/lanes/process.ts +0 -184
  261. package/src/lanes/progress.ts +0 -183
  262. package/src/lanes/registry.ts +0 -178
  263. package/src/lanes/runner.ts +0 -124
  264. package/src/lanes/types.ts +0 -112
  265. package/src/market/catalogs/mcp-docs.json +0 -111
  266. package/src/market/catalogs/plugins.json +0 -111
  267. package/src/market/catalogs/skills.json +0 -478
  268. package/src/market/clone.ts +0 -72
  269. package/src/market/context-cost.ts +0 -121
  270. package/src/market/digest.ts +0 -106
  271. package/src/market/index.ts +0 -22
  272. package/src/market/install.ts +0 -578
  273. package/src/market/manifest.ts +0 -187
  274. package/src/market/prereq.ts +0 -145
  275. package/src/market/registry.ts +0 -363
  276. package/src/market/resolve.ts +0 -111
  277. package/src/market/types.ts +0 -236
  278. package/src/market/validate.ts +0 -227
  279. package/src/mcp/client.ts +0 -449
  280. package/src/mcp/config.ts +0 -252
  281. package/src/mcp/local-package.ts +0 -211
  282. package/src/mcp/market-catalog.ts +0 -84
  283. package/src/mcp/market-install.ts +0 -289
  284. package/src/mcp/market.ts +0 -362
  285. package/src/mcp/oauth.ts +0 -251
  286. package/src/mcp/prompts-resources.ts +0 -249
  287. package/src/mcp/shared.ts +0 -149
  288. package/src/mcp/status.ts +0 -67
  289. package/src/mcp/tools.ts +0 -275
  290. package/src/mcp/transport.ts +0 -122
  291. package/src/mcp/trust.ts +0 -25
  292. package/src/memory/blocks.ts +0 -278
  293. package/src/memory/recall.ts +0 -355
  294. package/src/memory/scope.ts +0 -182
  295. package/src/memory/store.ts +0 -105
  296. package/src/memory/tools.ts +0 -99
  297. package/src/plugins/cli.ts +0 -119
  298. package/src/plugins/discover.ts +0 -108
  299. package/src/plugins/index.ts +0 -50
  300. package/src/plugins/install.ts +0 -184
  301. package/src/plugins/load.ts +0 -124
  302. package/src/plugins/manifest.ts +0 -92
  303. package/src/plugins/state.ts +0 -83
  304. package/src/providers/auth.ts +0 -408
  305. package/src/providers/cache.ts +0 -223
  306. package/src/providers/catalog-local.ts +0 -160
  307. package/src/providers/catalog.ts +0 -421
  308. package/src/providers/middleware-context.ts +0 -86
  309. package/src/providers/middleware.ts +0 -373
  310. package/src/providers/model-list.ts +0 -23
  311. package/src/providers/oauth/common.ts +0 -105
  312. package/src/providers/oauth/device-code.ts +0 -107
  313. package/src/providers/oauth/github-copilot.ts +0 -146
  314. package/src/providers/oauth/loopback.ts +0 -158
  315. package/src/providers/oauth/openai.ts +0 -163
  316. package/src/providers/oauth/openrouter.ts +0 -89
  317. package/src/providers/oauth/pkce.ts +0 -45
  318. package/src/providers/oauth/registry.ts +0 -39
  319. package/src/providers/oauth/seam.ts +0 -89
  320. package/src/providers/profile-glm53.ts +0 -111
  321. package/src/providers/profile-sonnet5-persona.ts +0 -65
  322. package/src/providers/profile-sonnet5-voice.ts +0 -23
  323. package/src/providers/profiles.ts +0 -156
  324. package/src/providers/provider-config.ts +0 -311
  325. package/src/providers/registry.ts +0 -333
  326. package/src/providers/responses.ts +0 -209
  327. package/src/providers/retry.ts +0 -234
  328. package/src/providers/router.ts +0 -294
  329. package/src/providers/sse.ts +0 -26
  330. package/src/providers/stream-errors.ts +0 -117
  331. package/src/providers/stream.ts +0 -566
  332. package/src/providers/thinking.ts +0 -189
  333. package/src/providers/wire-messages.ts +0 -129
  334. package/src/providers/wire-responses.ts +0 -79
  335. package/src/providers/wire-select.ts +0 -53
  336. package/src/server/http.ts +0 -291
  337. package/src/server/openapi.ts +0 -246
  338. package/src/sextant/card-hits.ts +0 -102
  339. package/src/sextant/card-keys.ts +0 -55
  340. package/src/sextant/context-source.ts +0 -157
  341. package/src/sextant/crew-cards.ts +0 -350
  342. package/src/sextant/draw-agents.ts +0 -273
  343. package/src/sextant/draw-code.ts +0 -388
  344. package/src/sextant/draw-context.ts +0 -222
  345. package/src/sextant/draw-frame.ts +0 -164
  346. package/src/sextant/draw-market.ts +0 -573
  347. package/src/sextant/draw-messages.ts +0 -386
  348. package/src/sextant/draw-pet.ts +0 -230
  349. package/src/sextant/draw-plan.ts +0 -187
  350. package/src/sextant/draw-tabs.ts +0 -85
  351. package/src/sextant/draw-util.ts +0 -65
  352. package/src/sextant/draw-wizard.ts +0 -378
  353. package/src/sextant/engine.ts +0 -230
  354. package/src/sextant/frame-hits.ts +0 -25
  355. package/src/sextant/frame.ts +0 -101
  356. package/src/sextant/git-status.ts +0 -197
  357. package/src/sextant/grid.ts +0 -59
  358. package/src/sextant/input.ts +0 -119
  359. package/src/sextant/keys.ts +0 -521
  360. package/src/sextant/layout.ts +0 -86
  361. package/src/sextant/local-commands.ts +0 -169
  362. package/src/sextant/market-source.ts +0 -287
  363. package/src/sextant/mentions.ts +0 -200
  364. package/src/sextant/message-hits.ts +0 -26
  365. package/src/sextant/model.ts +0 -387
  366. package/src/sextant/overlays.ts +0 -456
  367. package/src/sextant/panel-hits.ts +0 -38
  368. package/src/sextant/pet.ts +0 -399
  369. package/src/sextant/screen.ts +0 -324
  370. package/src/sextant/scroll-hits.ts +0 -66
  371. package/src/sextant/scrollbar.ts +0 -82
  372. package/src/sextant/sextant-bridge.ts +0 -174
  373. package/src/sextant/sextant-cards.ts +0 -142
  374. package/src/sextant/sextant-diff-base.ts +0 -63
  375. package/src/sextant/sextant-files.ts +0 -154
  376. package/src/sextant/sextant-frame-loop.ts +0 -335
  377. package/src/sextant/sextant-renderer.ts +0 -574
  378. package/src/sextant/sextant-repo.ts +0 -140
  379. package/src/sextant/theme.ts +0 -66
  380. package/src/sextant/tool-rows.ts +0 -189
  381. package/src/sextant/types.ts +0 -493
  382. package/src/skills/index.ts +0 -387
  383. package/src/skills/pack.ts +0 -220
  384. package/src/skills/spec.ts +0 -162
  385. package/src/skills/tools.ts +0 -69
  386. package/src/skills/versioned.ts +0 -227
  387. package/src/telemetry/otel-export.ts +0 -122
  388. package/src/telemetry/otel-lanes.ts +0 -89
  389. package/src/telemetry/otel-logs.ts +0 -131
  390. package/src/telemetry/otel-metrics.ts +0 -136
  391. package/src/telemetry/otel.ts +0 -397
  392. package/src/telemetry/otlp.ts +0 -76
  393. package/src/tools/ask-user.ts +0 -156
  394. package/src/tools/bash-bg.ts +0 -94
  395. package/src/tools/bash-jobs.ts +0 -237
  396. package/src/tools/design.ts +0 -151
  397. package/src/tools/evalcell.ts +0 -338
  398. package/src/tools/html-text.ts +0 -139
  399. package/src/tools/provider.ts +0 -149
  400. package/src/tools/task.ts +0 -250
  401. package/src/tools/todo.ts +0 -320
  402. package/src/tools/webfetch.ts +0 -332
  403. package/src/tools/websearch.ts +0 -359
  404. package/src/tui/agents-cmd.ts +0 -41
  405. package/src/tui/app.ts +0 -749
  406. package/src/tui/attach.ts +0 -127
  407. package/src/tui/boot-notes.ts +0 -41
  408. package/src/tui/builtin-prompts.ts +0 -59
  409. package/src/tui/checkpoints-cmd.ts +0 -70
  410. package/src/tui/clipboard-image.ts +0 -81
  411. package/src/tui/clipboard.ts +0 -78
  412. package/src/tui/commands.ts +0 -283
  413. package/src/tui/config-view.ts +0 -53
  414. package/src/tui/context-cmds.ts +0 -282
  415. package/src/tui/cost.ts +0 -108
  416. package/src/tui/crash-guard.ts +0 -173
  417. package/src/tui/focus-terminal.ts +0 -34
  418. package/src/tui/git-cmds.ts +0 -273
  419. package/src/tui/git-plain.ts +0 -58
  420. package/src/tui/info-cmd.ts +0 -150
  421. package/src/tui/input-plain.ts +0 -76
  422. package/src/tui/mcp-cmd.ts +0 -128
  423. package/src/tui/memory-note.ts +0 -77
  424. package/src/tui/modes-cmd.ts +0 -45
  425. package/src/tui/notify-seq.ts +0 -100
  426. package/src/tui/notify.ts +0 -318
  427. package/src/tui/overlays.ts +0 -97
  428. package/src/tui/pi-renderer.ts +0 -428
  429. package/src/tui/providers-cmd.ts +0 -377
  430. package/src/tui/reasoning-view.ts +0 -56
  431. package/src/tui/renderer.ts +0 -128
  432. package/src/tui/replay-marker.ts +0 -29
  433. package/src/tui/session-cmd.ts +0 -148
  434. package/src/tui/session-manage.ts +0 -95
  435. package/src/tui/sextant-attach.ts +0 -102
  436. package/src/tui/sextant-io.ts +0 -202
  437. package/src/tui/sextant-smoke.ts +0 -110
  438. package/src/tui/shell-cmd.ts +0 -158
  439. package/src/tui/smoke.ts +0 -72
  440. package/src/tui/staged-terminal.ts +0 -50
  441. package/src/tui/startup.ts +0 -12
  442. package/src/tui/theme.ts +0 -59
  443. package/src/tui/todo-label.ts +0 -7
  444. package/src/tui/trust-card.ts +0 -107
  445. package/src/tui/tui-commands.ts +0 -87
  446. package/tsconfig.json +0 -30
  447. package/vendor/pi-tui/LICENSE +0 -21
  448. package/vendor/pi-tui/PATCHES.md +0 -12
  449. package/vendor/pi-tui/PROVENANCE.md +0 -12
  450. package/vendor/pi-tui/README.upstream.md +0 -854
  451. package/vendor/pi-tui/native/win32/prebuilds/win32-arm64/win32-console-mode.node +0 -0
  452. package/vendor/pi-tui/native/win32/prebuilds/win32-x64/win32-console-mode.node +0 -0
  453. package/vendor/pi-tui/src/alt-screen-search.ts +0 -158
  454. package/vendor/pi-tui/src/autocomplete.ts +0 -827
  455. package/vendor/pi-tui/src/components/alt-screen-flash.ts +0 -52
  456. package/vendor/pi-tui/src/components/box.ts +0 -138
  457. package/vendor/pi-tui/src/components/cancellable-loader.ts +0 -41
  458. package/vendor/pi-tui/src/components/editor.ts +0 -2364
  459. package/vendor/pi-tui/src/components/h-stack.ts +0 -45
  460. package/vendor/pi-tui/src/components/image.ts +0 -128
  461. package/vendor/pi-tui/src/components/input.ts +0 -448
  462. package/vendor/pi-tui/src/components/loader.ts +0 -93
  463. package/vendor/pi-tui/src/components/markdown.ts +0 -1016
  464. package/vendor/pi-tui/src/components/scroll-view.ts +0 -217
  465. package/vendor/pi-tui/src/components/select-list.ts +0 -230
  466. package/vendor/pi-tui/src/components/settings-list.ts +0 -277
  467. package/vendor/pi-tui/src/components/spacer.ts +0 -29
  468. package/vendor/pi-tui/src/components/stack.ts +0 -155
  469. package/vendor/pi-tui/src/components/text.ts +0 -108
  470. package/vendor/pi-tui/src/components/truncated-text.ts +0 -66
  471. package/vendor/pi-tui/src/components/v-stack.ts +0 -34
  472. package/vendor/pi-tui/src/editor-component.ts +0 -75
  473. package/vendor/pi-tui/src/fuzzy.ts +0 -138
  474. package/vendor/pi-tui/src/index.ts +0 -149
  475. package/vendor/pi-tui/src/keybindings.ts +0 -321
  476. package/vendor/pi-tui/src/keys.ts +0 -1402
  477. package/vendor/pi-tui/src/kill-ring.ts +0 -47
  478. package/vendor/pi-tui/src/latex.ts +0 -1381
  479. package/vendor/pi-tui/src/layout-node.ts +0 -52
  480. package/vendor/pi-tui/src/layout.ts +0 -411
  481. package/vendor/pi-tui/src/native-modifiers.ts +0 -60
  482. package/vendor/pi-tui/src/native-module-path.ts +0 -32
  483. package/vendor/pi-tui/src/stdin-buffer.ts +0 -445
  484. package/vendor/pi-tui/src/terminal-colors.ts +0 -74
  485. package/vendor/pi-tui/src/terminal-image.ts +0 -701
  486. package/vendor/pi-tui/src/terminal.ts +0 -554
  487. package/vendor/pi-tui/src/tui-alt-screen.ts +0 -1379
  488. package/vendor/pi-tui/src/tui-main-screen.ts +0 -655
  489. package/vendor/pi-tui/src/tui.ts +0 -1264
  490. package/vendor/pi-tui/src/undo-stack.ts +0 -29
  491. package/vendor/pi-tui/src/utils.ts +0 -1327
  492. package/vendor/pi-tui/src/word-navigation.ts +0 -118
  493. package/vendor/pi-tui/test/test-themes.ts +0 -39
  494. package/vendor/pi-tui/test/virtual-terminal.ts +0 -219
  495. /package/{src/providers → dist/cli}/models-index.json +0 -0
@@ -0,0 +1,4 @@
1
+ // @bun
2
+ import{nm as A,om as C,pm as K}from"./main-n0t3973w.js";import{$m as R,Lm as Z}from"./main-2yeveeve.js";import{on as G,sn as Y,tn as H}from"./main-nqveez48.js";import{wn as b}from"./main-qsevpgsv.js";import{mkdirSync as M,readFileSync as T,writeFileSync as N}from"fs";import{dirname as F,join as x}from"path";function X(J,q){return J==="user"?x(Z(),z):x(q,".rovecode",z)}function E(J){if(typeof J!=="object"||J===null||Array.isArray(J))return{};let q=J,B={};if(typeof q.permission==="string"&&D.includes(q.permission))B.permission=q.permission;if(typeof q.effort==="string"&&A.includes(q.effort))B.effort=q.effort;if(typeof q.bell==="boolean")B.bell=q.bell;if(typeof q.autoUpdate==="boolean")B.autoUpdate=q.autoUpdate;if(typeof q.notify==="string"&&["auto","bell","osc9","osc777"].includes(q.notify))B.notify=q.notify;if(q.notify_when==="unfocused"||q.notify_when==="always")B.notify_when=q.notify_when;if(typeof q.notify_command==="string"&&q.notify_command.trim()!==""&&q.notify_command.length<=2000)B.notify_command=q.notify_command;if(q.verify===!1)B.verify=!1;else if(typeof q.verify==="string"&&q.verify.trim()!==""&&q.verify.length<=500)B.verify=q.verify.trim();else if(Array.isArray(q.verify)){let Q=q.verify.filter((U)=>typeof U==="string"&&U.trim()!==""&&U.length<=500).map((U)=>U.trim()).slice(0,8);if(Q.length>0)B.verify=Q}if(typeof q.lsp==="string"&&q.lsp.trim()!==""&&q.lsp.length<=2000)B.lsp=q.lsp;return B}function V(J){try{return E(JSON.parse(T(J,"utf8")))}catch{return{}}}function g(J){return V(J)}function I(J){return j.filter((q)=>J[q]!==void 0&&!(q==="verify"&&J.verify===!1))}function L(J,q=Z()){let B=X("project",J),Q=V(B),U=I(Q);if(U.length===0||G(q,B))return{user:V(X("user",J)),project:Q,projectPath:B,dropped:[]};let W={...Q};for(let _ of U)delete W[_];return{user:V(X("user",J)),project:W,projectPath:B,dropped:U}}function $(J){let q=L(J);return{...q.user,...q.project}}function S(J,q=Z()){let B=L(J,q);if(B.dropped.length===0)return[];let Q=B.dropped.join(", ");return[Y(B.projectPath,`its ${Q} key${B.dropped.length===1?" is":"s are"} ignored (a repo file would decide what we run)`)]}function u(J,q,B,Q){let U=X(B,Q),W={...V(U),[J]:q};return M(F(U),{recursive:!0}),N(U,JSON.stringify(W,null,2)+`
3
+ `),U}function l(J,q,B){if(q!==void 0)return q;let Q=(B.ROVECODE_PERMISSION??"").trim().toLowerCase();if(D.includes(Q))return Q;if(B.ROVECODE_YOLO==="1")return"auto";if(B.ROVECODE_ACCEPT_EDITS==="1")return"accept-edits";return $(J).permission??"ask"}function p(J,q,B={}){if(q!==void 0)return q;let Q=C(B.ROVECODE_EFFORT);if(Q!==void 0)return Q;return $(J).effort??"auto"}function v(J,q={}){if(q.ROVECODE_AUTO_UPDATE==="1")return!0;return $(J).autoUpdate===!0}var j,z="settings.json",D;var O=b(()=>{R();H();K();j=["verify","lsp","notify_command"];D=["ask","accept-edits","auto"]});
4
+ export{j as cm,X as dm,g as em,L as fm,$ as gm,S as hm,u as im,l as jm,p as km,v as lm,O as mm};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ import{wn as $,xn as y}from"./main-qsevpgsv.js";import{breakdownTokens as E}from"tokenlens/helpers";function F(){if(V===null)V=y("gpt-tokenizer/encoding/o200k_base");return V}function m(j){if(j.length===0)return 0;return F().countTokens(j)}function A(j){if(j.length===0)return 0;return V===null?null:V.countTokens(j)}function K(j){return typeof j==="number"&&Number.isFinite(j)&&j>0?j:0}function Y(j){return typeof j==="object"&&j!==null&&!Array.isArray(j)}function Z(j){if(!Y(j))return 0;for(let q of["prompt_tokens_details","input_tokens_details"]){let B=j[q];if(Y(B))return K(B.cached_tokens)}return 0}function N(j){let q=E(j),B=K(q.cacheReads)||Z(j),D=K(q.cacheWrites),G=K(q.input);if(Y(j)&&(typeof j.prompt_tokens==="number"||Z(j)>0&&j.cache_read_input_tokens===void 0))G=Math.max(0,G-B);return{input:G,output:K(q.output),cacheRead:B,cacheWrite:D}}function C(j,q){let B=q.promptBase+q.promptAbove,D=B>0?q.promptAbove/B:0,G=q.above??q.base,H=(P)=>D<=0?[[P,q.base]]:D>=1?[[P,G]]:[[P*(1-D),q.base],[P*D,G]],Q=0;for(let[P,X]of[...H(j.input).map(([J,U])=>[J,U.inputPerMTok]),...H(j.cacheRead).map(([J,U])=>[J,U.cacheReadPerMTok]),...H(j.cacheWrite).map(([J,U])=>[J,U.cacheWritePerMTok]),[j.output,q.request.outputPerMTok]]){let J=K(P);if(J===0)continue;if(typeof X!=="number"||!Number.isFinite(X))return;Q+=J/1e6*X}return Q}function I(j,q){let B=[[j.input,q.inputPerMTok],[j.output,q.outputPerMTok],[j.cacheRead,q.cacheReadPerMTok],[j.cacheWrite,q.cacheWritePerMTok]],D=0;for(let[G,H]of B){let Q=K(G);if(Q===0)continue;if(typeof H!=="number"||!Number.isFinite(H))return;D+=Q/1e6*H}return D}function S(j,q){if(!Number.isFinite(q)||q<=0)return{fraction:1,nearLimit:!0};let B=K(j)/q;return{fraction:B,nearLimit:B>=L}}var V=null,L=0.8;var O=()=>{};
3
+ export{m as Sj,A as Tj,N as Uj,C as Vj,I as Wj,S as Xj,O as Yj};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ var{defineProperty:e,getOwnPropertyNames:g,getOwnPropertyDescriptor:h}=Object,i=Object.prototype.hasOwnProperty;function j(a){return this[a]}var m=(a)=>{var b=(f??=new WeakMap).get(a),c;if(b)return b;if(b=e({},"__esModule",{value:!0}),a&&typeof a==="object"||typeof a==="function"){for(var d of g(a))if(!i.call(b,d))e(b,d,{get:j.bind(a,d),enumerable:!(c=h(a,d))||c.enumerable})}return f.set(a,b),b},f;var k=(a)=>a;function l(a,b){this[a]=k.bind(null,b)}var n=(a,b)=>{for(var c in b)e(a,c,{get:b[c],enumerable:!0,configurable:!0,set:l.bind(b,c)})};var o=(a,b)=>()=>(a&&(b=a(a=0)),b);var p=import.meta.require;
3
+ export{m as un,n as vn,o as wn,p as xn};
@@ -0,0 +1,25 @@
1
+ // @bun
2
+ import{Ue as t,Ve as n,We as VZ,Xe as Uz}from"./main-3pjrb2hd.js";import{hf as Tz,if as jz,nf as NZ}from"./main-dfreez27.js";import{$h as tz,ai as rZ,bi as zZ,ci as ZZ,di as oZ,fi as Nz,ti as W0}from"./main-3gjqfh7a.js";import{Kk as Sz,Lk as OZ}from"./main-gzkmycnv.js";import{fl as Iz,hl as Lz,ol as UZ}from"./main-3rxcvgna.js";import{Ll as Rz,Ml as CZ}from"./main-4wndhjdc.js";import{wn as T}from"./main-qsevpgsv.js";import{randomUUID as _z}from"crypto";import{cpSync as qz,mkdirSync as PZ,mkdtempSync as qZ,rmSync as Mz}from"fs";import{tmpdir as MZ}from"os";import{join as m}from"path";function Jz(z,Z){if((z.spawns??"subtasks")==="none")return{ok:!1,reason:`agent '${z.name}' spawn policy is 'none'`};if(Z.depth>=Z.maxDepth)return{ok:!1,reason:`depth cap ${Z.maxDepth} reached (current ${Z.depth})`};return{ok:!0}}function l(z,Z,$){let Q=Bun.spawnSync(["git",...z],{cwd:Z,stdin:$===void 0?"ignore":new Blob([$]),stdout:"pipe",stderr:"pipe"});return{code:Q.exitCode??-1,out:Q.stdout.toString()}}async function r(z,Z){if(Z.prefer==="none")return{dir:z,kind:"none",diff:async()=>"",cleanup:async()=>{}};let $=_z().slice(0,8);if(Z.prefer==="worktree"){let V=m(z,".rovecode","worktrees",$);if(l(["worktree","add","--detach",V],z).code===0)return{dir:V,kind:"worktree",diff:async()=>{return l(["add","-A","-N"],V),l(["diff","HEAD"],V).out},cleanup:async()=>{l(["worktree","remove","--force",V],z)}}}let Q=qZ(m(MZ(),"rovecode-iso-"));try{PZ(m(Q,"baseline")),qz(z,m(Q,"baseline"),{recursive:!0}),qz(z,m(Q,"work"),{recursive:!0})}catch{return Mz(Q,{recursive:!0,force:!0}),{dir:z,kind:"none",diff:async()=>"",cleanup:async()=>{}}}return{dir:m(Q,"work"),kind:"copy",diff:async()=>{let V=l(["diff","--no-index","baseline","work"],Q);return V.code<=1?V.out.replace(/^([-+]{3} [ab]\/)(baseline|work)\//gm,"$1").replace(/^(diff --git a\/)(?:baseline|work)\/(\S+ b\/)(?:baseline|work)\/(\S+)/gm,"$1$2$3"):""},cleanup:async()=>{Mz(Q,{recursive:!0,force:!0})}}}async function Dz(z,Z,$=0,Q){let V=(K)=>({agent:Z.agent,ok:!1,summary:K,usage:{input:0,output:0}}),W=z.defs.get(Z.agent);if(!W)return V(`unknown agent '${Z.agent}'`);let Y=Jz(W,{depth:$,maxDepth:o,parentSessionId:""});if(!Y.ok)return V(Y.reason??"spawn refused");let J=Z.isolated?await r(z.rootDir,{prefer:"worktree"}):await r(z.rootDir,{prefer:"none"});try{let K=new Rz(z.sessionsDir,_z()),X=new Iz,B=z.registryFactory(W,J.dir,{depth:$,steering:X,signal:Q,dir:J.dir,...Z.parentTools?{parentTools:Z.parentTools}:{}}),P=Tz(W.mode??"act",z.baseConfig.permissionRules),j={...z.baseConfig,permissionRules:IZ(P,J.dir,J.kind!=="none")},F=B.list().map((C)=>C.schema),I=W.model&&z.toolPrompt?z.toolPrompt(W.model,F):"",O=[W.mode==="plan"?jz():"",I?`# Tool calling
3
+ ${I}`:""].filter((C)=>C!==""),S=O.length>0?{...W,systemPrompt:(C)=>[typeof W.systemPrompt==="function"?W.systemPrompt(C):W.systemPrompt,...O].join(`
4
+
5
+ `)}:W,M;for await(let C of Lz(S,Z.goal,Z.vars??{},j,{stream:z.stream,registry:B,store:K,guard:new Sz,tools:F,cwd:J.dir,signal:Q,hooks:z.hooks},X,$+1))if(C.type==="run_end")M={status:C.status,summary:C.summary};let E=0,w=0;for(let C of K.messages())if(C.usage)E+=C.usage.input,w+=C.usage.output;let R=J.kind==="none"?void 0:await J.diff(),N=M?.status==="done",_=RZ(K),D=N?_||"(no output)":`${M?.summary??"child run ended without run_end"}${_?`
6
+ last output: ${_}`:""}`,L=N&&R?Kz(R,z.rootDir):void 0;if(L===!1)D+=`
7
+ patch-apply-failed`;return{agent:Z.agent,ok:N,summary:D.slice(0,4000),usage:{input:E,output:w},patch:R,...L!==void 0?{applied:L}:{}}}finally{await J.cleanup()}}function RZ(z){let Z=[...z.messages()].reverse().find(($)=>$.role==="assistant");return Z?Z.parts.filter(($)=>$.kind==="text").map(($)=>$.text).join(""):""}function Kz(z,Z){if(!z.trim())return!0;return l(["-c","core.autocrlf=false","apply","--whitespace=nowarn","-"],Z,z).code===0}function IZ(z,Z,$=!1){let Q=[{action:"*",resource:"*",effect:"deny"}];for(let V of z)if(V.effect==="prompt")Q.push({...V,effect:"deny"});else if($&&Z&&V.effect==="allow"&&LZ(V))Q.push({...V,resource:m(Z,V.resource)});else Q.push({...V});return Q}function LZ(z){if(z.resource==="*"||z.resource.includes(" "))return!1;return z.action.startsWith("file.")||z.resource.includes("/")}var o=3;var Gz=T(()=>{NZ();OZ();CZ();UZ()});function f(z){let Z=z.trim();if(!Z.startsWith("{"))return null;try{let $=JSON.parse(Z);return k($)?$:null}catch{return null}}function U(z,Z=160){let $=(z??"").split(`
8
+ `).map((Q)=>Q.trim()).find((Q)=>Q!=="")??"";return $.length>Z?$.slice(0,Z-1)+"\u2026":$}function Xz(z){if(typeof z==="string")return z;return g(z).map((Z)=>k(Z)&&Z.type==="text"?H(Z.text)??"":"").filter(Boolean).join(`
9
+ `)}function A(z,Z){let $=G(z);if(!$)return;let Q=q($.input_tokens)??q($.prompt_tokens)??q($.input),V=q($.output_tokens)??q($.completion_tokens)??q($.output);if(Q===void 0&&V===void 0)return;let W=G($.cache),Y=q($.cache_read_input_tokens)??q($.cached_input_tokens)??q(W?.read),J=q($.cache_creation_input_tokens)??q(W?.write),K=G(Z)??$,X=q(K.total_cost_usd)??q(K.cost_usd)??q(K.cost),B={input:Q??0,output:V??0};if(Y!==void 0)B.cacheRead=Y;if(J!==void 0)B.cacheWrite=J;if(X!==void 0)B.costUsd=X;return B}function e(z,Z){if(!z)return{...Z};let $={input:z.input+Z.input,output:z.output+Z.output},Q=(z.cacheRead??0)+(Z.cacheRead??0),V=(z.cacheWrite??0)+(Z.cacheWrite??0);if(z.cacheRead!==void 0||Z.cacheRead!==void 0)$.cacheRead=Q;if(z.cacheWrite!==void 0||Z.cacheWrite!==void 0)$.cacheWrite=V;if(z.costUsd!==void 0||Z.costUsd!==void 0)$.costUsd=(z.costUsd??0)+(Z.costUsd??0);return $}function yz(z){switch(z.kind){case"log":return U(z.text,200);case"edit":return`${z.op} ${z.path}${z.wrote===!0?" (ok)":""}`;case"bash":{let Z=z.exitCode!==void 0?` \u2192 exit ${z.exitCode}`:"",$=z.output?` \xB7 ${U(z.output,80)}`:"";return`$ ${U(z.command,100)}${Z}${$}`}case"tool":return`tool ${z.name}${z.detail?`: ${z.detail}`:""}`;case"ask":return`ask: ${U(z.text,160)}`;case"progress":return`progress: ${U(z.text,160)}`;case"done":return`done: ${U(z.summary,160)||"(no output)"}`;case"fail":return`fail: ${U(z.error,160)||"(no reason)"}`;case"usage":{let Z=z.usage.costUsd!==void 0?` \xB7 $${z.usage.costUsd.toFixed(4)}`:"";return`usage: ${z.usage.input} in \xB7 ${z.usage.output} out${Z}`}}}function Bz(z){let Z=z.toLowerCase();if(/^(bash|shell|command|run_command|run_shell_command|execute)$/.test(Z))return"bash";if(/^(write|write_file|create_file|notebookedit)$/.test(Z))return"write";if(/^(edit|multiedit|edit_file|replace|str_replace|patch|apply_patch)$/.test(Z))return"edit";return"other"}function Fz(z){return H(z?.file_path)??H(z?.filePath)??H(z?.path)??H(z?.file)??"?"}function d(z,Z,$,Q,V={}){let W=V.callId!==void 0&&V.callId!==""?{callId:V.callId}:{},Y=Fz(Z);switch(Bz(z)){case"bash":{let J={kind:"bash",command:H(Z?.command)??H(Z?.cmd)??"?",...W};if($!==void 0)J.output=$;if(Q!==void 0)J.exitCode=Q;return J}case"write":return{kind:"edit",path:Y,op:"write",...W,...V.wrote?{wrote:!0}:{}};case"edit":return{kind:"edit",path:Y,op:"edit",...W,...V.wrote?{wrote:!0}:{}};default:return{kind:"tool",name:z,...W,...$?{detail:U($,120)}:{}}}}var k=(z)=>typeof z==="object"&&z!==null&&!Array.isArray(z),H=(z)=>typeof z==="string"?z:void 0,q=(z)=>typeof z==="number"&&Number.isFinite(z)?z:void 0,G=(z)=>k(z)?z:void 0,g=(z)=>Array.isArray(z)?z:[];var h=()=>{};function kz(z,Z,$){let Q=Az(Z),V=[...Z.bare===!1?[]:["--bare"],"-p",z,"--output-format","stream-json","--verbose","--permission-mode","acceptEdits"];if(Q.length>0)V.push("--allowedTools",Q.join(","));if(Z.model)V.push("--model",Z.model);if($)V.push("--resume",$);return{bin:"claude",args:V,cwd:Z.cwd}}function jZ(z,Z){let $=[];for(let Q of g(G(z.message)?.content)){if(!k(Q))continue;if(Q.type==="text"){let V=(H(Q.text)??"").trim();if(V)Z.lastText=V,$.push({kind:"log",text:V})}else if(Q.type==="tool_use"){let V=H(Q.name)??"tool",W=H(Q.id),Y=G(Q.input);if(W)Cz(Z)[W]={name:V,path:Fz(Y)};$.push(d(V,Y,void 0,void 0,W?{callId:W}:{}))}}return $}function _Z(z,Z){let $=[];for(let Q of g(G(z.message)?.content)){if(!k(Q)||Q.type!=="tool_result")continue;let V=H(Q.tool_use_id)??"",W=Cz(Z)[V],Y=W?.name??"tool";delete Cz(Z)[V];let J=U(Xz(Q.content),120),K=Q.is_error===!0,X=Bz(Y);if(!K&&W!==void 0&&(X==="edit"||X==="write")&&W.path!=="?"){$.push({kind:"edit",path:W.path,op:X==="write"?"write":"edit",wrote:!0,...V?{callId:V}:{}});continue}$.push({kind:"log",text:`${Y} ${K?"error":"result"}${J?`: ${J}`:""}`})}return $}var SZ,Az=(z)=>[...z.allowlist??SZ],TZ=(z)=>z.bare!==!1?"bare":z.oauthToken===!0?"oauth token":"cli login",Cz=(z)=>z.scratch.tools??={},Ez;var wz=T(()=>{h();SZ=["Read","Edit","Write"];Ez={id:"claude",interruptFirst:!0,command:(z,Z)=>kz(z.goal,Z,Z.resume),resume:(z,Z,$)=>kz(Z,$,z),permissionSummary:(z)=>`permission-mode acceptEdits \xB7 allow: ${Az(z).join(",")||"none"} \xB7 ${TZ(z)} \xB7 worktree`,parse(z,Z){let $=f(z),Q=$?H($.type):void 0;if(!$||!Q)return Z.garbage++,[];let V=H($.session_id);if(V)Z.sessionId=V;switch(Q){case"system":{let W=H($.subtype)??"?";if(W==="hook_started"||W==="hook_response")return[{kind:"log",text:`hook ${H($.hook_name)??"?"} ${W==="hook_started"?"started":H($.outcome)??"responded"}`}];if(W!=="init")return[{kind:"log",text:`system ${W}`}];return[{kind:"log",text:`init \xB7 model ${H($.model)??"?"} \xB7 ${g($.tools).length} tools${V?` \xB7 session ${V}`:""}`}]}case"assistant":if($.is_api_error_message===!0)return[{kind:"log",text:`api error: ${U(Xz(G($.message)?.content),160)||H($.error)||"?"}${H($.error)?` (${H($.error)})`:""}`}];return jZ($,Z);case"user":return _Z($,Z);case"result":{let W=[],Y=A($.usage,$);if(Y)W.push({kind:"usage",usage:Y});let J=H($.result)??"",K=Z.sessionId?{sessionId:Z.sessionId}:{};if($.is_error===!0)W.push({kind:"fail",error:J||`result ${H($.subtype)??"error"}`,...K});else W.push({kind:"done",summary:J||Z.lastText||"",...K});return W}default:return[]}}}});import{tmpdir as DZ}from"os";import{join as yZ}from"path";function kZ(z){if(z.lastMessageFile)return z.lastMessageFile;let Z=0;for(let $ of z.cwd)Z=Z*31+$.charCodeAt(0)>>>0;return yZ(DZ(),`rovecode-codex-last-${Z.toString(16)}.md`)}function xz(z,Z,$){let Q=["-a","never","exec"];if($)Q.push("resume",$);if(Q.push("--json","--sandbox",Z.sandbox??gz,"-C",Z.cwd,"-o",kZ(Z),"--skip-git-repo-check"),Z.model)Q.push("-m",Z.model);return Q.push(z),{bin:"codex",args:Q,cwd:Z.cwd}}function EZ(z,Z,$){let Q=H(Z.type)??"",V=z==="item.completed";switch(Q){case"agent_message":{let W=(H(Z.text)??"").trim();if(!V||!W)return[];return $.lastText=W,[{kind:"log",text:W}]}case"reasoning":{let W=(H(Z.text)??"").trim();return V&&W?[{kind:"log",text:`thinking: ${U(W,160)}`}]:[]}case"command_execution":{let W=H(Z.command)??"?",Y=H(Z.id),J=Y!==void 0?{callId:Y}:{};if(z==="item.started")return[{kind:"bash",command:W,...J}];if(!V)return[];let K={kind:"bash",command:W,...J},X=q(Z.exit_code);if(X!==void 0)K.exitCode=X;let B=U(H(Z.aggregated_output),120);if(B)K.output=B;return[K]}case"file_change":{if(!V)return[];let W=H(Z.id);return g(Z.changes).filter(k).map((Y)=>({kind:"edit",path:H(Y.path)??"?",op:AZ[H(Y.kind)??""]??"edit",wrote:!0,...W!==void 0?{callId:W}:{}}))}case"todo_list":{let W=g(Z.items).filter(k),Y=W.filter((K)=>K.completed===!0).length,J=W.find((K)=>K.completed!==!0);return[{kind:"progress",text:`plan ${Y}/${W.length}${J?` \xB7 ${U(H(J.text),100)}`:" \xB7 complete"}`}]}case"mcp_tool_call":return V?[{kind:"log",text:`mcp ${H(Z.server)??"?"}.${H(Z.tool)??"?"} ${H(Z.status)??"completed"}`}]:[];case"web_search":return V?[{kind:"log",text:`search: ${U(H(Z.query),120)}`}]:[];default:return[]}}var gz="workspace-write",AZ,fz;var hz=T(()=>{h();AZ={add:"write",create:"write",update:"edit",modify:"edit",delete:"delete",remove:"delete"};fz={id:"codex",interruptFirst:!1,command:(z,Z)=>xz(z.goal,Z,Z.resume),resume:(z,Z,$)=>xz(Z,$,z),permissionSummary:(z)=>`sandbox ${z.sandbox??gz} \xB7 approval never \xB7 worktree`,parse(z,Z){let $=f(z),Q=$?H($.type):void 0;if(!$||!Q)return Z.garbage++,[];let V=()=>Z.sessionId?{sessionId:Z.sessionId}:{};switch(Q){case"thread.started":{let W=H($.thread_id);if(W)Z.sessionId=W;return[{kind:"log",text:`thread ${W??"?"}`}]}case"item.started":case"item.updated":case"item.completed":{let W=G($.item);return W?EZ(Q,W,Z):[]}case"turn.completed":{let W=[],Y=A($.usage);if(Y)W.push({kind:"usage",usage:Y});return W.push({kind:"done",summary:Z.lastText??"",...V()}),W}case"turn.failed":return[{kind:"fail",error:H(G($.error)?.message)??H($.error)??"turn failed",...V()}];case"error":return[{kind:"fail",error:H($.message)??H(G($.error)?.message)??"error",...V()}];default:return[]}}}});function bz(z,Z,$){let Q=["run",z,"--format","json","--dir",Z.cwd];if($)Q.push("-s",$);if(Z.attach)Q.push("--attach",Z.attach);if(Z.model)Q.push("-m",Z.model);return{bin:"opencode",args:Q,cwd:Z.cwd}}function vz(z,Z){let $=H(z.sessionID)??H(z.sessionId);if($)Z.sessionId=$;let Q=H(z.type);switch(Q){case"text":case"reasoning":{let V=(H(z.text)??"").trim(),W=G(z.time);if(!V||W&&W.end===void 0)return[];let Y=H(z.id)??V;if(mz(Z)[Y]===V)return[];if(mz(Z)[Y]=V,Q==="reasoning")return[{kind:"log",text:`thinking: ${U(V,160)}`}];return Z.lastText=V,[{kind:"log",text:V}]}case"tool":{let V=G(z.state),W=H(V?.status),Y=H(z.tool)??"tool";if(W==="error")return[{kind:"log",text:`tool ${Y} error: ${U(H(V?.error)??H(V?.output),120)}`}];if(W!=="completed")return[];let J=q(G(V?.metadata)?.exit),K=H(z.callID)??H(z.id);return[d(Y,G(V?.input),U(H(V?.output),120)||void 0,J,{wrote:!0,...K!==void 0?{callId:K}:{}})]}case"step-finish":case"step_finish":{let V=A(z.tokens,z),W=V?[{kind:"usage",usage:V}]:[],Y=H(z.reason);if(Y==="stop")W.push({kind:"done",summary:Z.lastText??"",...s(Z)});else if(Y==="error"||Y==="length"||Y==="content-filter")W.push({kind:"fail",error:`step finished: ${Y}`,...s(Z)});return W}default:return[]}}var wZ,mz=(z)=>z.scratch.parts??={},s=(z)=>z.sessionId?{sessionId:z.sessionId}:{},uz;var cz=T(()=>{h();wZ=new Set(["step_start","step-start","text","reasoning","tool_use","tool","step_finish","step-finish"]);uz={id:"opencode",interruptFirst:!0,command:(z,Z)=>bz(z.goal,Z,Z.resume),resume:(z,Z,$)=>bz(Z,$,z),permissionSummary:(z)=>`permissions per opencode config (asks surface as lane events)${z.attach?` \xB7 attach ${z.attach}`:""} \xB7 worktree`,parse(z,Z){let $=f(z),Q=$?H($.type):void 0;if(!$||!Q)return Z.garbage++,[];let V=G($.properties)??$,W=H(V.sessionID)??H(V.sessionId)??H(G(V.info)?.sessionID);if(W)Z.sessionId=W;if(wZ.has(Q)){let Y=G($.part);return Y?vz(Y,Z):[]}if(Q.startsWith("message.part.")){let Y=G(V.part)??G($.part);return Y?vz(Y,Z):[]}if(Q.startsWith("permission."))return[{kind:"ask",text:H(V.title)??H(G(V.permission)?.title)??H(V.type)??"permission"}];switch(Q){case"message.updated":{let Y=G(V.info),J=A(Y?.tokens,Y);return J&&H(Y?.role)!=="user"?[{kind:"usage",usage:J}]:[]}case"session.idle":return[{kind:"done",summary:Z.lastText??"",...s(Z)}];case"session.error":case"error":{let Y=G(V.error)??G($.error);return[{kind:"fail",error:H(G(Y?.data)?.message)??H(Y?.message)??H(V.message)??H(Y?.name)??"error",...s(Z)}]}default:return[]}}}});function lz(z,Z,$){let Q=["-p",z,"--output-format","stream-json","--print-timeout",gZ(Z.timeoutMs)];if(Z.allowAll===!0)Q.push("--dangerously-skip-permissions");if(Z.model)Q.push("--model",Z.model);if($)Q.push("--conversation",$);return{bin:"agy",args:Q,cwd:Z.cwd}}function dz(z,Z,$){let Q=(H(z.scratch.text)??"")+Z,V=[],W=(Y)=>{let J=Y.trim();if(J)z.lastText=J,V.push({kind:"log",text:J})};for(let Y=Q.indexOf(`
10
+ `);Y>=0;Y=Q.indexOf(`
11
+ `))W(Q.slice(0,Y)),Q=Q.slice(Y+1);if($)W(Q),Q="";return z.scratch.text=Q,V}function fZ(z,Z){let $=H(z.text_delta)??H(G(z.step)?.text_delta);if($!==void 0)return dz(Z,$,!1);let Q=G(z.step)??z,V=G(Q.tool)??G(Q.tool_call),W=H(V?.name)??H(Q.tool_name)??H(Q.name),Y=H(z.step_type)??H(Q.step_type)??"";if(!W||!/tool/.test(Y)&&!V)return[];let J=G(V?.args)??G(V?.input)??G(Q.tool_input)??G(Q.args)??G(Q.input),K=H(V?.output)??H(Q.tool_output)??H(Q.output);return[d(W,J,K?U(K,120):void 0)]}var xZ,gZ=(z)=>`${Math.max(1,Math.ceil(z/60000))}m`,nz;var az=T(()=>{h();xZ="agy reported SUCCESS but the lane's worktree has no changes \u2014 a tool that needed approval was probably soft-denied (agy exits 0); "+"re-run with an explicit allow-all (--dangerously-skip-permissions) or grant it in ~/.gemini/antigravity-cli/settings.json permissions.allow";nz={id:"agy",interruptFirst:!1,emptyDiffNote:xZ,command:(z,Z)=>lz(z.goal,Z,Z.resume),resume:(z,Z,$)=>lz(Z,$,z),permissionSummary:(z)=>z.allowAll===!0?"--dangerously-skip-permissions (every tool auto-approved) \xB7 worktree":"soft-deny (tools needing approval are refused, exit 0 \u2014 diff is cross-checked) \xB7 worktree",parse(z,Z){let $=f(z),Q=$?H($.type):void 0;if(!$||!Q)return Z.garbage++,[];let V=H($.conversation_id)??H($.session_id)??H($.conversationId);if(V)Z.sessionId=V;let W=()=>Z.sessionId?{sessionId:Z.sessionId}:{};switch(Q){case"init":return[{kind:"log",text:`init \xB7 model ${H($.model)??"?"}${Z.sessionId?` \xB7 conversation ${Z.sessionId}`:""}`}];case"step_update":return fZ($,Z);case"result":{let Y=dz(Z,"",!0),J=A($.usage??$.stats??G($.metadata)?.usage,$);if(J)Y.push({kind:"usage",usage:J});let K=H($.status)??"?",X=(H($.response)??"").trim();if(K==="SUCCESS")Y.push({kind:"done",summary:X||Z.lastText||"",...W()});else Y.push({kind:"fail",error:X||(H($.error)??H($.message)??`result ${K}`),...W()});return Y}case"error":return[{kind:"fail",error:H($.message)??H(G($.error)?.message)??"error",...W()}];default:return[]}}}});import{existsSync as pz}from"fs";import{delimiter as hZ,join as bZ}from"path";function oz(z){let Z=new Set;for(let $ of(z??"").split(",")){let Q=$.trim().toLowerCase();if(n(Q))Z.add(Q)}return Z}function nZ(z,Z,$){if(z.includes("/")||z.includes("\\"))return pz(z);if(Z==="")return!0;let Q=process.platform==="win32"?($.PATHEXT??".COM;.EXE;.BAT;.CMD").split(";").map((V)=>V.trim()).filter(Boolean):[""];for(let V of Z.split(hZ)){if(V==="")continue;for(let W of Q)if(pz(bZ(V,z+W)))return!0}return!1}function Oz(z,Z=process.env,$=dZ){let Q=cZ(Z);if(!Q.has(z)){let W=Q.size?[...Q].join(","):"none";return`external lane '${z}' is not in ${iz} (currently allowed: ${W}) \u2014 add it, or unset ${iz} to allow all of ${t.join(",")}`}let V=lZ(z,Z);if(!$(V,Z))return`external lane '${z}' needs the '${V}' CLI, which is not on PATH \u2014 install it, or start a different lane (${t.filter((W)=>W!==z).join(", ")})`;return null}function ez(z,Z=process.env,$={}){return`${c(z,Z,$)} \u2014 started; it works in its own worktree and its diff comes back as a patch`}function aZ(z=process.env){let Z=Number(v("LANE_TIMEOUT_MS",z)??"");return Number.isInteger(Z)&&Z>=1000?Z:uZ}function Zz(z,Z,$=process.env,Q={}){let V={cwd:Z,timeoutMs:aZ($)},W=(v(vZ(z),$)??"").trim();if(W)V.model=W;if(z==="claude"){let Y=v("LANE_CLAUDE_ALLOW",$);if(Y!==void 0)V.allowlist=Y.split(",").map((K)=>K.trim()).filter(Boolean);let J=v("LANE_CLAUDE_BARE",$);if(V.bare=J==="1"?!0:J==="0"?!1:($.ANTHROPIC_API_KEY??"")!=="",($[mZ]??"")!=="")V.oauthToken=!0}if(z==="codex"){let Y=v("LANE_CODEX_SANDBOX",$);V.sandbox=Y==="read-only"?"read-only":"workspace-write"}if(z==="agy"&&oz(v("LANES_ALLOW_ALL",$)).has("agy"))V.allowAll=!0;return{...V,...Q,cwd:Z}}function c(z,Z=process.env,$={}){return`spawn ${z} lane \xB7 ${zz[z].permissionSummary(Zz(z,"<worktree>",Z,$))}`}function Z1(z,Z=process.env){if(!k(z)||z.action!=="start"||!n(z.agent))return null;return c(z.agent,Z)}var zz,u=(z)=>`ROVECODE_${z}`,v=(z,Z=process.env)=>Z[u(z)],iz,o0,e0,s0,mZ="CLAUDE_CODE_OAUTH_TOKEN",vZ=(z)=>`LANE_${z.toUpperCase()}_MODEL`,t0,z1,uZ=900000,cZ=(z=process.env)=>{let Z=v("LANES_ALLOW",z);return Z===void 0?new Set(t):oz(Z)},lZ=(z,Z=process.env)=>zz[z].command({goal:"probe"},Zz(z,".",Z)).bin,rz,dZ=(z,Z)=>{let $=Z.PATH??Z.Path??"",Q=`${process.platform}|${z}|${$}`,V=rz.get(Q);if(V!==void 0)return V;let W=nZ(z,$,Z);return rz.set(Q,W),W};var $z=T(()=>{h();Uz();wz();hz();cz();az();zz={claude:Ez,codex:fz,opencode:uz,agy:nz},iz=u("LANES_ALLOW"),o0=u("LANES_ALLOW_ALL"),e0=u("LANE_CLAUDE_ALLOW"),s0=u("LANE_CLAUDE_BARE"),t0=u("LANE_CODEX_SANDBOX"),z1=u("LANE_TIMEOUT_MS");rz=new Map});class Vz{calls=new Set;anonymousCalls=0;files=new Set;filesTotal=0;usage;add(z){switch(z.kind){case"edit":if(this.countCall(z.callId),z.wrote===!0&&!this.files.has(z.path)){if(this.filesTotal+=1,this.files.size<Qz)this.files.add(z.path)}return;case"bash":case"tool":this.countCall(z.callId);return;case"usage":this.usage=e(this.usage,z.usage);return;default:return}}countCall(z){if(z===void 0||z==="")this.anonymousCalls+=1;else this.calls.add(z)}snapshot(){return{toolCalls:this.calls.size+this.anonymousCalls,filesWritten:[...this.files].sort(),filesWrittenTotal:this.filesTotal,...this.usage?{usage:{...this.usage}}:{}}}withFiles(z){let Z=[...new Set(z)].sort();return{...this.snapshot(),filesWritten:Z.slice(0,Qz),filesWrittenTotal:Z.length}}}function Wz(z){let Z=new Set;for(let $ of z.split(/\r?\n/)){if(!$.startsWith("diff --git "))continue;let Q=$.slice(11),V=pZ(Q);if(V===null)continue;let[W,Y]=V,J=Y==="/dev/null"?W:Y;if(J!==""&&J!=="/dev/null")Z.add(J)}return[...Z].sort()}function pZ(z){if(z.startsWith('"')){let $=iZ(z);if($===-1)return null;let Q=sz(z.slice(0,$+1)),V=z.slice($+1).trimStart(),W=V.startsWith('"')?sz(V):V;return[a(Q),a(W)]}let Z=z.indexOf(" b/");if(Z===-1){let $=z.indexOf(" ");return $===-1?null:[a(z.slice(0,$)),a(z.slice($+1))]}return[a(z.slice(0,Z)),a(z.slice(Z+1))]}var Qz=100,iZ=(z)=>{for(let Z=1;Z<z.length;Z++){if(z[Z]==="\\"){Z++;continue}if(z[Z]==='"')return Z}return-1},sz=(z)=>{return(z.startsWith('"')?z.slice(1,z.lastIndexOf('"')):z).replace(/\\(.)/g,"$1")},a=(z)=>/^[ab]\//.test(z)?z.slice(2):z;var Yz=T(()=>{h()});function Z0(z,Z){let $={};for(let[Q,V]of Object.entries(z)){if(V===void 0)continue;let W=Q.toUpperCase();if(!z0.includes(W)&&(sZ.includes(W)||W.startsWith(tZ)))continue;$[Q]=V}return{...$,...Z??{}}}async function*$0(z){let Z=new TextDecoder,$="",Q=!1;try{for(;;){let V=await z.read();if(V.done)break;$+=Z.decode(V.value,{stream:!0});for(let W=$.indexOf(`
12
+ `);W>=0;W=$.indexOf(`
13
+ `)){let Y=$.slice(0,W);if($=$.slice(W+1),Q){Q=!1;continue}if(Y.endsWith("\r"))Y=Y.slice(0,-1);yield Y.length>Hz?Y.slice(0,Hz):Y}if($.length>Hz)yield $.slice(0,Hz),$="",Q=!0}if($+=Z.decode(),$&&!Q)yield $}catch{}}function V0(z={}){let Z=z.platform??process.platform,$=z.spawn??Q0,Q=z.kill,V=z.createJob??tz,W=Z==="win32";return(Y)=>{let J=$([Y.bin,...Y.args],{cwd:Y.cwd,env:Z0(process.env,Y.env),stdin:Y.stdin!==void 0?new Blob([Y.stdin]):"ignore",stdout:"pipe",stderr:"pipe",...zZ(Z)}),K=W?V():null;if(K&&!K.assign(J.pid))K=null;let X=!1,B=null,P="";(async()=>{let F=J.stderr.getReader(),I=new TextDecoder;for(let O=await F.read();!O.done;O=await F.read())P=(P+I.decode(O.value,{stream:!0})).slice(-eZ)})().catch(()=>{});let j=J.exited.then((F)=>X?143:F).finally(()=>{if(X)K?.terminate();else K?.release()});return{pid:J.pid,exited:j,lines:()=>$0(B=J.stdout.getReader()),interrupt(){if(W||J.exitCode!==null)return!1;try{return J.kill("SIGINT"),!0}catch{return!1}},kill(){if(X)return;if(X=!0,W){if(K?.terminate(),J.exitCode===null)try{$(["taskkill","/T","/F","/PID",String(J.pid)],{stdout:"ignore",stderr:"ignore"})}catch{}}else{ZZ(J.pid,"SIGTERM",Q);try{J.kill("SIGTERM")}catch{}}},abandon(){B?.cancel().catch(()=>{})},stderrTail:()=>P.trim()}}}var Hz=1048576,eZ=2000,sZ,tZ="CLAUDE_CODE_",z0,Q0=(z,Z)=>Bun.spawn(z,Z),$Z;var QZ=T(()=>{oZ();rZ();sZ=["CLAUDECODE"],z0=["CLAUDE_CODE_OAUTH_TOKEN","CLAUDE_CODE_USE_BEDROCK","CLAUDE_CODE_USE_VERTEX","CLAUDE_CODE_USE_FOUNDRY","CLAUDE_CODE_SIMPLE","CLAUDE_CODE_SAFE_MODE","CLAUDE_CODE_MAX_OUTPUT_TOKENS","CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC"];$Z=V0()});class WZ{cap;lines=[];constructor(z){this.cap=z}push(z){if(this.lines.push(z),this.lines.length>this.cap)this.lines.splice(0,this.lines.length-this.cap)}tail(z=this.cap){return this.lines.slice(-z)}get length(){return this.lines.length}}async function YZ(z,Z,$,Q={}){if(Q.signal?.aborted)return{status:"cancelled",summary:"",error:"cancelled",exitCode:null,log:[],garbage:0,progress:new Vz().snapshot()};let V=$.resume&&z.resume?z.resume($.resume,Z.goal,$):z.command(Z,$),W=new WZ(Y0),Y=new Vz,J=VZ(),K;try{K=(Q.spawn??$Z)(V)}catch(N){return{status:"failed",summary:"",error:`spawn failed: ${V.bin}: ${J0(N)}`,exitCode:null,log:[],garbage:0,progress:Y.snapshot()}}let X,B,P,j=!1,F=!1,I=!1,O=new Set,S=(N,_)=>{let D=setTimeout(()=>{O.delete(D),N()},_);O.add(D)},M=(N)=>{Q.steps?.push(N)},E=()=>{M("kill"),K.kill(),S(()=>{M("abandon"),K.abandon()},Nz)},w=()=>{if(I)return;if(I=!0,z.interruptFirst&&K.interrupt())M("interrupt"),S(E,Q.graceMs??H0);else E()},R=()=>{F=!0,w()};try{Q.signal?.addEventListener("abort",R,{once:!0}),S(()=>{j=!0,w()},Math.max(0,$.timeoutMs));for await(let b of K.lines()){let x=b.trimEnd();if(!x)continue;let i;try{i=z.parse(x,J)}catch{J.garbage++;continue}for(let y of i){if(W.push(yz(y)),Y.add(y),y.kind==="done")X=y;else if(y.kind==="fail")B=y;else if(y.kind==="usage")P=e(P,y.usage);Q.onEvent?.(y,W.tail(3),Y.snapshot())}}let N,_=await Promise.race([K.exited,new Promise((b)=>{N=setTimeout(()=>b(null),Nz)})]);clearTimeout(N);let D=X?.sessionId??B?.sessionId??J.sessionId,L={exitCode:_,log:W.tail(),garbage:J.garbage,progress:Y.snapshot(),...P?{usage:P}:{},...D?{sessionId:D}:{}};if(F)return{...L,status:"cancelled",summary:"",error:"cancelled"};if(j)return{...L,status:"failed",summary:"",error:`timed out after ${$.timeoutMs}ms`};if(B)return{...L,status:"failed",summary:"",error:B.error};if(X)return{...L,status:"done",summary:X.summary||J.lastText||""};let C=K.stderrTail();if(_!==0)return{...L,status:"failed",summary:"",error:`${V.bin} exited with code ${_??"?"} without a result${C?`: ${C.slice(-300)}`:""}`};return{...L,status:"failed",summary:"",error:`${V.bin} exited 0 without a result event${C?`: ${C.slice(-300)}`:""}`}}finally{Q.signal?.removeEventListener("abort",R);for(let N of O)clearTimeout(N)}}var Y0=200,H0=3000,J0=(z)=>z instanceof Error?z.message:String(z);var HZ=T(()=>{W0();h();Yz();QZ();Uz()});function G0(z){return{filesWritten:z.slice(0,Qz),filesWrittenTotal:z.length}}async function GZ(z,Z,$,Q,V,W){let Y=zz[Z],J=z.env??process.env,K=c(Z,J),X=(F)=>({agent:Z,ok:!1,usage:{input:0,output:0},permissions:K,summary:F}),B=await(z.isolate??r)(Q,{prefer:"worktree"}),P,j;try{if(B.kind==="none")return X("isolation unavailable \u2014 an external lane never runs in the parent tree");if(V.aborted)return X("cancelled before the lane started");let F=Zz(Z,B.dir,J,z.timeoutMs!==void 0?{timeoutMs:z.timeoutMs}:{}),I=0,O,S=!1,M,E=(x)=>{I=Date.now(),O=void 0,W(x.join(`
14
+ `),M)},w=z.silentMs??K0;j=setTimeout(()=>{if(!S)W(`no output from ${Z} after ${JZ(w)} \u2014 still waiting (lane timeout ${JZ(F.timeoutMs)})`)},w);let R=await YZ(Y,{goal:$},F,{spawn:z.spawn,signal:V,graceMs:z.graceMs,onEvent:(x,i,y)=>{S=!0,M=y;let Pz=Date.now()-I;if(Pz>=KZ){E(i);return}if(O=i,P===void 0)P=setTimeout(()=>{if(P=void 0,O)E(O)},KZ-Pz)}}),N=await B.diff(),_=R.usage??{input:0,output:0},D={...R.progress,...G0(Wz(N))},L={agent:Z,usage:_,permissions:K,patch:N,exitCode:R.exitCode,...R.sessionId?{sessionId:R.sessionId}:{},...F.model?{model:F.model}:{}};if(R.status!=="done"){let x=R.log.slice(-3).join(`
15
+ `);return{...L,progress:{...D,applied:!1},ok:!1,summary:`${R.error??R.status}${x?`
16
+ last output: ${x}`:""}`}}let C=R.summary||"(no output)";if(N.trim()===""&&Y.emptyDiffNote)C+=`
17
+ note: ${Y.emptyDiffNote}`;if(B.kind==="copy")C+=`
18
+ [isolation: copy \u2014 ${Q} is not a git repo]`;let b=(z.apply??Kz)(N,Q);if(!b)C+=`
19
+ patch-apply-failed`;return{...L,applied:b,progress:{...D,applied:b},ok:!0,summary:C.slice(0,4000)}}finally{clearTimeout(P),clearTimeout(j),await B.cleanup()}}var K0=30000,JZ=(z)=>z>=1000?`${Math.round(z/1000)}s`:`${z}ms`,KZ=250;var XZ=T(()=>{Gz();$z();Yz();HZ();$z();Uz()});function B0(z=process.env){let Z=Number(z.ROVECODE_TASKS_MAX??"");return Number.isInteger(Z)&&Z>=1?Z:X0}function p(z,Z=200){let $=(z??"").split(`
20
+ `).find((Q)=>Q.trim()!=="")?.trim()??"";return $.length>Z?$.slice(0,Z-1)+"\u2026":$||"(no output)"}function FZ(z){let Z=`task ${z.id} (${z.label})`;if(z.status==="done")return`${Z} finished: ${p(z.summary)} \u2014 call task_status result ${z.id} for details`;if(z.status==="failed")return`${Z} failed: ${p(z.error)} \u2014 call task_status result ${z.id} for details`;return`${Z} cancelled`}function T1(z,Z=Date.now()){if(z.length===0)return"(no background tasks)";let $=z.slice(-50).map((Q)=>{let V=Q.finishedAt??Z,W=Q.startedAt!==void 0?` ${Math.max(0,Math.round((V-Q.startedAt)/1000))}s`:"",Y=Q.status==="failed"?` \u2014 ${p(Q.error,80)}`:Q.status==="done"?` \u2014 ${p(Q.summary,80)}`:"";return`${Q.id.padEnd(4)} ${Q.status.padEnd(9)}${W.padEnd(6)} ${Q.label}${Y}`});return(z.length>50?`(showing 50 of ${z.length})
21
+ `:"")+$.join(`
22
+ `)}function U0(z,Z){let $=(z??"").replace(/\s+/g," ").trim();return $.length>Z?$.slice(0,Z-1)+"\u2026":$}function N0(z,Z=z){let $=new Set(z.map((J)=>J.id)),Q=new Map;for(let J of Z)for(let K of J.files??[])Q.set(K,[...Q.get(K)??[],J.id]);let V=[...Q].filter(([,J])=>J.length>1&&J.some((K)=>$.has(K))).map(([J,K])=>({path:J,tasks:K})).sort((J,K)=>J.path.localeCompare(K.path)),W=(J)=>z.reduce((K,X)=>K+(X.status===J?1:0),0),Y=z.find((J)=>J.batchLabel!==void 0)?.batchLabel;return{batch:z[0]?.batch??"",...Y!==void 0?{label:Y}:{},tasks:z,done:W("done"),failed:W("failed"),cancelled:W("cancelled"),collisions:V}}function P0(z){let Z=[];if(z.failed>0)Z.push(`${z.failed} FAILED`);if(z.cancelled>0)Z.push(`${z.cancelled} cancelled`);if(z.done>0)Z.push(`${z.done} done`);let $=z.tasks.length,V=[`batch ${z.batch}${z.label!==void 0?` (${z.label})`:""}: ${$} agent${$===1?"":"s"} \u2014 ${Z.join(", ")}`];for(let W of z.collisions)V.push(`COLLISION: ${W.path} \u2014 ${O0(W.tasks)} both changed this file`);for(let W of z.tasks){let Y=W.startedAt!==void 0&&W.finishedAt!==void 0?` ${Math.max(0,Math.round((W.finishedAt-W.startedAt)/1000))}s`:"",J=W.status==="failed"?"FAILED":W.status,K=W.files!==void 0&&W.files.length>0?` [${W.files.length} file${W.files.length===1?"":"s"}]`:"",X=W.status==="done"?p(W.summary,80):W.status==="failed"?p(W.error,80):"";V.push(` ${W.id} ${W.agent}${Y} ${J}${K}${X!==""?` \u2014 ${X}`:""}`)}return V.push("call task_status result <id> for any of them"),V.join(`
23
+ `)}class q0{opts;maxConcurrent;maxDepth;tasks=new Map;queue=[];listeners=new Set;run;sink=null;runSignal=null;batch=null;running=0;seq=0;runSeq=0;constructor(z){this.opts=z;this.maxConcurrent=Math.max(1,Math.floor(z.maxConcurrent??B0())),this.maxDepth=Math.min(z.maxDepth??o,o),this.run=z.run??Dz}get lanes(){return this.opts.lanes??{}}attach(z){this.sink=z}bindRun(z,Z){this.runSignal=z;let $=U0(Z?.label,C0);this.batch={id:Z?.id?.trim()||`r${++this.runSeq}`,...$!==""?{label:$}:{}}}start(z,Z={}){let $=this.opts.deps();if(!$)return{ok:!1,reason:"no provider configured"};let Q=n(z.agent)?z.agent:null,V=Q?Oz(Q,this.lanes.env):null;if(V)return{ok:!1,reason:V};let W=Q?{name:Q,systemPrompt:"",tools:[]}:$.defs.get(z.agent);if(!W)return{ok:!1,reason:`unknown agent '${z.agent}'`};let Y=Z.owner??this.runSignal??void 0;if(Y?.aborted)return{ok:!1,reason:"parent run aborted"};let J=(Z.parentDepth??0)+1,K=Jz(W,{depth:J,maxDepth:this.maxDepth,parentSessionId:Z.caller??""});if(!K.ok)return{ok:!1,reason:K.reason??"spawn refused"};let X=$.baseConfig.permissionRules.some((M)=>M.effect==="prompt")?"gated":"open",B=`t${++this.seq}`,P=()=>{},j=new Promise((M)=>{P=M}),F=z.goal.replace(/\s+/g," ").trim(),I=Z.caller!==void 0?this.tasks.get(Z.caller)?.info:void 0,O=I?.batch!==void 0?{id:I.batch,...I.batchLabel!==void 0?{label:I.batchLabel}:{}}:this.batch,S={info:{id:B,label:(Z.label??"").trim()||(F.length>40?F.slice(0,39)+"\u2026":F||"(no goal)"),agent:z.agent,goal:F.length>200?F.slice(0,199)+"\u2026":F,isolated:Q!==null||z.isolated===!0,depth:J,status:"queued",createdAt:Date.now(),...Z.caller!==void 0?{parent:Z.caller}:{},...Q?{kind:"external",permissions:c(Q,this.lanes.env)}:{},...O?{batch:O.id,...O.label!==void 0?{batchLabel:O.label}:{}}:{}},req:Z.parentTools?{...z,parentTools:Z.parentTools}:z,deps:$,...Q?{lane:Q}:{},...Z.parentDir!==void 0?{parentDir:Z.parentDir}:{},ac:new AbortController,notify:Z.notify,done:j,resolveDone:P,settled:!1,reported:!1};if(Y){let M=()=>{this.cancel(B)};Y.addEventListener("abort",M,{once:!0}),S.unbind=()=>Y.removeEventListener("abort",M)}return this.tasks.set(B,S),this.queue.push(B),this.emit(S),this.pump(),{ok:!0,id:B,childPolicy:X}}status(z){let Z=this.tasks.get(z);return Z?{...Z.info}:void 0}list(){return[...this.tasks.values()].map((z)=>({...z.info}))}counts(){let z={queued:0,running:0,done:0,failed:0,cancelled:0};for(let Z of this.tasks.values())z[Z.info.status]++;return z}async result(z,Z={}){let $=this.tasks.get(z);if(!$)return;if($.settled)return{...$.info};if($.info.status==="queued"&&Z.caller!==void 0&&this.tasks.get(Z.caller)?.info.status==="running")this.dequeue(z),this.launch($);return await M0($.done,Z.timeoutMs,Z.signal),{...$.info}}cancel(z){let Z=this.tasks.get(z);if(!Z)return;if(BZ(Z.info.status))return{...Z.info};if(Z.info.status==="queued")this.dequeue(z),Z.info.status="cancelled",Z.info.error="cancelled",this.settle(Z);else Z.info.status="cancelled",Z.info.error="cancelled",Z.ac.abort();return{...Z.info}}cancelAll(){let z=0;for(let Z of this.tasks.values())if(!BZ(Z.info.status))this.cancel(Z.info.id),z++;return z}async drain(z){let Z=Date.now()+z;while(this.running>0||this.queue.length>0){if(Date.now()>=Z)return!1;await new Promise(($)=>setTimeout($,10))}return!0}subscribe(z){return this.listeners.add(z),()=>{this.listeners.delete(z)}}dequeue(z){let Z=this.queue.indexOf(z);if(Z>=0)this.queue.splice(Z,1)}pump(){while(this.running<this.maxConcurrent&&this.queue.length>0){let z=this.tasks.get(this.queue.shift());if(z&&z.info.status==="queued")this.launch(z)}}launch(z){if(z.info.status="running",z.info.startedAt=Date.now(),this.running++,this.emit(z),z.lane)(z.notify??this.sink)?.push(`task ${z.info.id} (${z.info.label}): ${ez(z.lane,this.lanes.env)}`);let Z={...z.deps,registryFactory:(Q,V,W)=>z.deps.registryFactory(Q,V,W?{...W,taskId:z.info.id}:void 0)};(z.lane?GZ(this.lanes,z.lane,z.req.goal,z.parentDir??z.deps.rootDir,z.ac.signal,(Q,V)=>this.progress(z,Q,V)):this.run(Z,z.req,z.info.depth,z.ac.signal)).then((Q)=>this.finish(z,Q),(Q)=>this.finish(z,void 0,Q)).finally(()=>{this.running--,this.pump()})}progress(z,Z,$){if(z.info.status!=="running")return;if(z.info.summary=Z,$){if(z.info.progress=$,$.usage)z.info.usage=$.usage}this.emit(z)}finish(z,Z,$){let Q=z.info;if(Z&&"permissions"in Z){if(Z.sessionId)Q.laneSession=Z.sessionId;if(Q.laneExit=Z.exitCode,Z.model)Q.laneModel=Z.model;if(Z.progress)Q.progress=Z.progress}if(Q.status==="cancelled"){if(Z)Q.usage=Z.usage}else if(Z===void 0)Q.status="failed",Q.error=`child runner threw: ${$ instanceof Error?$.message:String($)}`;else if(!Z.ok)Q.status="failed",Q.error=Z.summary,Q.usage=Z.usage;else if(Q.status="done",Q.summary=Z.summary,Q.usage=Z.usage,Z.patch!==void 0){Q.patchLines=Z.patch.trim()===""?0:Z.patch.split(`
24
+ `).length;let V=Q.progress?.applied??Z.applied??!0,W=Q.progress?.filesWritten??Wz(Z.patch);if(V&&W.length>0)Q.files=W}this.settle(z)}settle(z){z.settled=!0,z.unbind?.(),z.info.finishedAt=Date.now();let Z=this.noteFor(z);if(Z!==null)(z.notify??this.sink)?.push(Z);z.resolveDone(),this.emit(z)}noteFor(z){let Z=z.info.batch;if(Z===void 0)return z.reported=!0,FZ(z.info);let $=z.notify??this.sink,Q=[...this.tasks.values()].filter((Y)=>Y.info.batch===Z&&(Y.notify??this.sink)===$);if(Q.some((Y)=>!Y.settled))return null;let V=Q.filter((Y)=>!Y.reported);for(let Y of V)Y.reported=!0;let W=N0(V.map((Y)=>({...Y.info})),Q.map((Y)=>({...Y.info})));if(W.tasks.length<=1&&W.collisions.length===0)return FZ(z.info);return P0(W)}emit(z){for(let Z of this.listeners)try{Z({...z.info})}catch{}}}function M0(z,Z,$){return new Promise((Q)=>{let V,W=!1,Y=()=>{if(W)return;if(W=!0,V!==void 0)clearTimeout(V);$?.removeEventListener("abort",Y),Q()};if($?.aborted){Y();return}if(Z!==void 0)V=setTimeout(Y,Math.max(0,Z));$?.addEventListener("abort",Y,{once:!0}),z.then(Y,Y)})}var X0=3,F0,BZ=(z)=>F0.has(z),C0=60,O0=(z)=>z.length<=1?z[0]??"":`${z.slice(0,-1).join(", ")} and ${z[z.length-1]}`;var R0=T(()=>{Gz();XZ();Yz();$z();F0=new Set(["done","failed","cancelled"])});
25
+ export{k as Fe,h as Ge,iz as He,Z1 as Ie,$z as Je,X0 as Ke,B0 as Le,BZ as Me,FZ as Ne,T1 as Oe,C0 as Pe,N0 as Qe,P0 as Re,q0 as Se,R0 as Te};
@@ -0,0 +1,16 @@
1
+ // @bun
2
+ import{wn as K}from"./main-qsevpgsv.js";import{existsSync as Q}from"fs";import{join as V}from"path";function W(z){let F=Q(V(z,q));return`${F?`${q} already exists in this project. Analyse the repository, read the current ${q}, and propose TARGETED improvements to it: fix what is stale or wrong, add what a future agent session would need and cannot infer quickly, remove nothing that is still true. Apply the changes with the edit tool (small anchored edits, never a wholesale rewrite) and finish with a short list of what changed and why.`:`Analyse this repository and write an ${q} file at the project root: the instructional context a future agent session reads first.`}
3
+
4
+ Analysis:
5
+ 1. List the top-level files and directories for an overview. Read the README (README.md or similar) first if there is one.
6
+ 2. Read the files that matter most, up to about ten, letting each discovery guide the next: build/package manifests (package.json, pyproject.toml, Cargo.toml, go.mod, Makefile, \u2026), the main entry points, existing agent or contributor guides (AGENTS.md, CLAUDE.md, CONTRIBUTING.md), CI config.
7
+ 3. Decide whether this is a code project or something else (documentation, notes, data).
8
+
9
+ ${q} content \u2014 concise, factual, only what you verified in the files:
10
+ - Project overview: purpose, main technologies, architecture in a few sentences.
11
+ - Build, run and test: the exact commands, inferred from the manifests and scripts you read; mark anything you could not confirm with a TODO instead of guessing.
12
+ - Conventions: code style, testing practice, layout rules, review or contribution rules the files reveal.
13
+ - For a non-code directory: what it holds, the key files and how the contents are meant to be used.
14
+
15
+ ${F?`Edit ${q} in place; do not create a second file.`:"Write the complete file with the write tool as well-formatted Markdown; do not touch other files."} Keep it under about 150 lines.`}function $(z,F){let D=/^\/(\S+)(?:\s+([\s\S]*))?$/.exec(z.trim());if(!D)return;let H=Object.hasOwn(J,D[1].toLowerCase())?J[D[1].toLowerCase()]:void 0;return H?H(F,(D[2]??"").trim()):void 0}var q="AGENTS.md",J;var X=K(()=>{J={init:(z)=>W(z)}});
16
+ export{q as ad,$ as bd,X as cd};
@@ -0,0 +1,5 @@
1
+ // @bun
2
+ import{Fm as D,zm as Z}from"./main-7rn6bqje.js";import{wn as $}from"./main-qsevpgsv.js";function K(q,y="mcp output"){if(q.length<=V)return q;return`${q.slice(0,V)}
3
+ [${y} truncated: showing ${V} of ${q.length} chars]`}function E(q,y){let z=[];if(Array.isArray(q))for(let B of q){if(!Z(B))continue;if(B.type==="text"&&typeof B.text==="string")z.push(B.text);else if(typeof B.type==="string")z.push(`[${B.type} content]`)}if(z.length===0&&y!==void 0)try{z.push(JSON.stringify(y))}catch{}return K(z.join(`
4
+ `))}function R(q){let y=new AbortController;if(q===void 0)return{signal:y.signal,dispose:()=>{}};if(q.aborted)return y.abort(q.reason),{signal:y.signal,dispose:()=>{}};let z=()=>y.abort(q.reason);return q.addEventListener("abort",z,{once:!0}),{signal:y.signal,dispose:()=>q.removeEventListener("abort",z)}}async function G(q,y){let z=R(q);try{return await y(z.signal)}finally{z.dispose()}}function I(q){return typeof q==="object"&&q!==null&&q.code===-32601}function W(q){return`needs login \u2014 run \`rovecode mcp login ${q}\``}function k(q){return q.headers!==void 0&&Object.keys(q.headers).some((y)=>y.toLowerCase()==="authorization")}async function L(q,y,z){let B,H=new Promise((J,F)=>{B=setTimeout(()=>F(Error(z)),y)});try{return await Promise.race([q,H])}finally{if(B!==void 0)clearTimeout(B)}}async function O(q,y,z,B){let H=[],J=new Set,F,N=0;do{if(B?.aborted)throw Error(`${q} listing on "${y}" aborted`);let Q=await z(F);if(N+=1,H.push(...Q.items),F=typeof Q.nextCursor==="string"?Q.nextCursor:void 0,F!==void 0){if(J.has(F))throw Error(`${q} listing on "${y}" stopped: server repeated pagination cursor ${JSON.stringify(F)} (partial: ${H.length} ${q}s in ${N} pages)`);if(J.add(F),N>=Y)throw Error(`${q} listing on "${y}" stopped after ${Y} pages without a final page (partial: ${H.length} ${q}s)`)}}while(F!==void 0);return H}var Y=50,V=1e4,b;var j=$(()=>{D();b=class b extends Error{constructor(q){super(W(q));this.name="McpNeedsLoginError"}}});
5
+ export{K as ch,E as dh,R as eh,G as fh,I as gh,W as hh,b as ih,k as jh,L as kh,O as lh,j as mh};
@@ -0,0 +1,4 @@
1
+ // @bun
2
+ import{$m as _,Lm as D,Nm as V,Om as K,Ym as N}from"./main-2yeveeve.js";_();import{mkdirSync as R,readFileSync as U,statSync as k,writeFileSync as g}from"fs";import{dirname as S,join as j}from"path";var E=[{id:"kaesra",baseUrl:"https://api.example.invalid/v1",protocol:"openai",keyEnv:"KAESRA_API_KEY",defaultModel:"zai-org/glm-5.3-flash"},{id:"openai",baseUrl:"https://api.openai.com/v1",protocol:"openai",keyEnv:"OPENAI_API_KEY"},{id:"anthropic",baseUrl:"https://api.anthropic.com/v1",protocol:"anthropic",keyEnv:"ANTHROPIC_API_KEY",defaultModel:"claude-opus-5"},{id:"deepseek",baseUrl:"https://api.deepseek.com/v1",protocol:"openai",keyEnv:"DEEPSEEK_API_KEY"},{id:"groq",baseUrl:"https://api.groq.com/openai/v1",protocol:"openai",keyEnv:"GROQ_API_KEY"},{id:"openrouter",baseUrl:"https://openrouter.ai/api/v1",protocol:"openai",keyEnv:"OPENROUTER_API_KEY"},{id:"ollama",baseUrl:"http://127.0.0.1:11434/v1",protocol:"openai",keyEnv:"OLLAMA_API_KEY"},{id:"lmstudio",baseUrl:"http://127.0.0.1:1234/v1",protocol:"openai",keyEnv:"LMSTUDIO_API_KEY"},{id:"together",baseUrl:"https://api.together.xyz/v1",protocol:"openai",keyEnv:"TOGETHER_API_KEY"},{id:"mistral",baseUrl:"https://api.mistral.ai/v1",protocol:"openai",keyEnv:"MISTRAL_API_KEY"},{id:"cerebras",baseUrl:"https://api.cerebras.ai/v1",protocol:"openai",keyEnv:"CEREBRAS_API_KEY"},{id:"fireworks",baseUrl:"https://api.fireworks.ai/inference/v1",protocol:"openai",keyEnv:"FIREWORKS_API_KEY"},{id:"perplexity",baseUrl:"https://api.perplexity.ai",protocol:"openai",keyEnv:"PERPLEXITY_API_KEY"},{id:"xai",baseUrl:"https://api.x.ai/v1",protocol:"openai",keyEnv:"XAI_API_KEY"},{id:"moondream",baseUrl:"https://api.moondream.ai/v1",protocol:"openai",keyEnv:"MOONDREAM_API_KEY"},{id:"vllm",baseUrl:"http://127.0.0.1:8000/v1",protocol:"openai",keyEnv:"VLLM_API_KEY"}];function T(){return j(D(),"providers.json")}function O(q){return j(q,".rovecode","providers.json")}function t(q,G){return q==="project"?O(G):T()}var b=/^[a-z0-9][a-z0-9_.-]{0,39}$/,f=/^[A-Z_][A-Z0-9_]*$/;function x(q){return q.includes("anthropic.com")?"anthropic":"openai"}function u(q,G){if(!b.test(q))return{error:`provider id "${q}" must be a lowercase slug (a-z 0-9 _ . -), at most 40 chars`};if(typeof G!=="object"||G===null||Array.isArray(G))return{error:`provider "${q}": entry must be an object`};let z=G,W=typeof z.baseUrl==="string"?z.baseUrl.trim().replace(/\/+$/,""):"";if(!/^https?:\/\/[^\s/]+/.test(W))return{error:`provider "${q}": baseUrl must be an http(s) URL`};let X=z.protocol===void 0?x(W):z.protocol;if(X!=="openai"&&X!=="anthropic")return{error:`provider "${q}": protocol must be "openai" or "anthropic"`};let J={id:q,baseUrl:W,protocol:X};if(z.keyEnv!==void 0){if(typeof z.keyEnv!=="string"||!f.test(z.keyEnv))return{error:`provider "${q}": keyEnv must be an ENV_VAR_NAME`};J.keyEnv=z.keyEnv}if(z.defaultModel!==void 0){if(typeof z.defaultModel!=="string"||z.defaultModel.trim().length===0)return{error:`provider "${q}": defaultModel must be a non-empty string`};J.defaultModel=z.defaultModel.trim()}if(z.models!==void 0){if(!Array.isArray(z.models)||!z.models.every((Q)=>typeof Q==="string"&&Q.trim().length>0))return{error:`provider "${q}": models must be a list of model ids`};J.models=z.models.map((Q)=>Q.trim())}if(z.headers!==void 0){let Q=z.headers;if(typeof Q!=="object"||Q===null||Array.isArray(Q)||!Object.values(Q).every((Y)=>typeof Y==="string"))return{error:`provider "${q}": headers must be an object of strings`};J.headers={...Q}}if(z.noKey!==void 0){if(typeof z.noKey!=="boolean")return{error:`provider "${q}": noKey must be true or false`};if(z.noKey)J.noKey=!0}return{spec:J}}function y(q){let G;try{G=U(q,"utf8")}catch{return{data:{},warnings:[]}}let z;try{z=JSON.parse(G)}catch{return{data:{},warnings:[`${q}: invalid JSON \u2014 ignored`]}}if(typeof z!=="object"||z===null||Array.isArray(z))return{data:{},warnings:[`${q}: expected an object \u2014 ignored`]};let W=z,X={},J=[];if(W.default!==void 0)if(typeof W.default==="string"&&W.default.trim().length>0)X.default=W.default.trim();else J.push(`${q}: "default" must be "provider/model" \u2014 ignored`);if(W.providers!==void 0){let Q=W.providers;if(typeof Q!=="object"||Q===null||Array.isArray(Q))J.push(`${q}: "providers" must be an object \u2014 ignored`);else{X.providers={};for(let[Y,H]of Object.entries(Q)){let $=u(Y,H);if("error"in $){J.push(`${q}: ${$.error} \u2014 ignored`);continue}let{id:L,...Z}=$.spec;X.providers[Y]=Z}}}return{data:X,warnings:J}}function d(q,G){R(S(q),{recursive:!0}),g(q,JSON.stringify(G,null,2)+`
3
+ `)}function P(q,G,z,W){let X=q.keyEnv??N(q.id),J=W[q.id]?.key;if(J!==void 0&&J.trim().length>0)return{...q,keyEnv:X,scope:G,apiKey:J,keySource:"stored"};let Q=z[X];if(Q!==void 0&&Q.trim().length>0)return{...q,keyEnv:X,scope:G,apiKey:Q,keySource:"env"};return{...q,keyEnv:X,scope:G,apiKey:null,keySource:"none"}}function m(q){let G=q.ROVECODE_BASE_URL,z=q.ROVECODE_API_KEY??q.OPENAI_API_KEY;if(!G||!z)return null;return{id:"custom",baseUrl:G,protocol:x(G),keyEnv:"ROVECODE_API_KEY",scope:"env",apiKey:z,keySource:"inline",...q.ROVECODE_MODEL?{defaultModel:q.ROVECODE_MODEL}:{}}}function w(q){return q.apiKey!==null||q.noKey===!0}function h(q,G=process.env){let z=[],W=[],X=new Map;for(let Z of E)X.set(Z.id,{spec:Z,scope:"builtin"}),W.push(Z.id);let J,Q,Y=(Z,A)=>{let{data:M,warnings:F}=y(Z);z.push(...F);for(let[B,I]of Object.entries(M.providers??{})){let C=X.get(B);if(X.set(B,{spec:{...C?.spec??{},...I,id:B},scope:A}),C===void 0)W.push(B)}if(M.default!==void 0)J=M.default,Q=A};Y(T(),"user"),Y(O(q),"project");let H=K(),$=W.map((Z)=>{let A=X.get(Z);return P(A.spec,A.scope,G,H)}),L=m(G);if(L)$.push(L);return{providers:$,...J!==void 0?{defaultSelector:J,defaultScope:Q}:{},warnings:z}}function l(q){let G=q.trim(),z=G.indexOf("/");if(z<=0)return{provider:G};let W=G.slice(z+1).trim();return W.length>0?{provider:G.slice(0,z),model:W}:{provider:G.slice(0,z)}}function o(q){let G=q.providers.find((J)=>J.scope==="env");if(G)return{provider:G,model:G.defaultModel,via:"env-pair"};if(q.defaultSelector!==void 0){let J=l(q.defaultSelector),Q=q.providers.find((Y)=>Y.id===J.provider);if(Q&&w(Q))return{provider:Q,model:J.model??Q.defaultModel,via:"default"}}let z=q.providers.find((J)=>J.keySource==="stored");if(z)return{provider:z,model:z.defaultModel,via:"stored"};let W=q.providers.find((J)=>J.keySource==="env");if(W)return{provider:W,model:W.defaultModel,via:"env-key"};let X=q.providers.find((J)=>J.noKey===!0);if(X)return{provider:X,model:X.defaultModel,via:"no-key"};return null}class v{cwd;env;throttleMs;snap=null;stamp="";checkedAt=-1/0;listeners=new Set;constructor(q,G=process.env,z=250){this.cwd=q;this.env=G;this.throttleMs=z}sourcePaths(){return[T(),O(this.cwd),V()]}stampNow(){return this.sourcePaths().map((q)=>{try{let G=k(q);return`${G.mtimeMs}:${G.size}`}catch{return"-"}}).join("|")}snapshot(){let q=Date.now();if(this.snap!==null&&q-this.checkedAt<this.throttleMs)return this.snap;this.checkedAt=q;let G=this.stampNow();if(this.snap===null||G!==this.stamp){let z=this.snap===null;if(this.stamp=G,this.snap=h(this.cwd,this.env),!z)for(let W of this.listeners)W(this.snap)}return this.snap}invalidate(){this.checkedAt=-1/0,this.stamp=""}onChange(q){return this.listeners.add(q),()=>{this.listeners.delete(q)}}}
4
+ export{E as Ti,T as Ui,O as Vi,t as Wi,b as Xi,x as Yi,u as Zi,y as _i,d as $i,P as aj,m as bj,w as cj,h as dj,l as ej,o as fj,v as gj};
@@ -0,0 +1,18 @@
1
+ // @bun
2
+ import{lookup as o}from"dns/promises";var p=new Set(["script","style","noscript","template","title"]),d=new Set(["head","svg","iframe","object","canvas","audio","video","select"]),c=new Set(["head","meta","link","base","basefont","bgsound","noframes","title","style","script","noscript","template"]),l=new Set(["address","article","aside","blockquote","body","caption","center","dd","details","dialog","div","dl","dt","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hr","html","legend","main","menu","nav","ol","p","pre","section","summary","table","tbody","tfoot","thead","tr","ul"]),m=new Set(["p","h1","h2","h3","h4","h5","h6","blockquote","pre","ul","ol","table","figure"]),i={amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:" ",shy:"",copy:"\xA9",reg:"\xAE",trade:"\u2122",hellip:"\u2026",mdash:"\u2014",ndash:"\u2013",lsquo:"\u2018",rsquo:"\u2019",ldquo:"\u201C",rdquo:"\u201D",laquo:"\xAB",raquo:"\xBB",bull:"\u2022",middot:"\xB7",deg:"\xB0",times:"\xD7",divide:"\xF7",plusmn:"\xB1",euro:"\u20AC",pound:"\xA3",yen:"\xA5",cent:"\xA2",sect:"\xA7",para:"\xB6",larr:"\u2190",rarr:"\u2192",uarr:"\u2191",darr:"\u2193",harr:"\u2194",frac12:"\xBD",frac14:"\xBC",frac34:"\xBE",sup2:"\xB2",sup3:"\xB3",micro:"\xB5",iexcl:"\xA1",iquest:"\xBF"};function y(J){return J.replace(/&(#[xX][0-9a-fA-F]+|#\d+|[a-zA-Z][a-zA-Z0-9]*);/g,(Q,z)=>{if(z[0]==="#"){let $=z[1]==="x"||z[1]==="X"?parseInt(z.slice(2),16):parseInt(z.slice(1),10);return $>0&&$<=1114111&&($<55296||$>57343)?String.fromCodePoint($):Q}return i[z]??Q})}function n(J,Q){let z=new RegExp(`(?:^|\\s)${Q}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s"'>]+))`,"i").exec(J);return z?y(z[1]??z[2]??z[3]??"").trim():void 0}function r(J,Q){try{return new URL(J,Q).href}catch{return J}}function g(J,Q){let z=[],$=0,Z=0,G=!1,q=null,F=/<!--[\s\S]*?(?:-->|$)|<!\[CDATA\[[\s\S]*?(?:\]\]>|$)|<[!?][^<>]*>|<\/?([a-zA-Z][^\s/>]*)((?:[\s/](?:[^>"']|"[^"]*(?:"|$)|'[^']*(?:'|$))*)?)(?:>|$)/g,W=0,V=(K)=>{if($>0||K==="")return;let N=y(K);if(Z===0){N=N.replace(/\s+/g," ");let O=z.length>0?z[z.length-1]:`
3
+ `;if(O.endsWith(`
4
+ `)||O.endsWith("- "))N=N.trimStart()}if(N)z.push(N)},j;while((j=F.exec(J))!==null){V(J.slice(W,j.index)),W=F.lastIndex;let K=j[1]?.toLowerCase();if(!K)continue;let N=j[0].startsWith("</");if(p.has(K)){if(N)continue;let X=J.slice(W).search(new RegExp(`</${K}\\s*>`,"i"));W=X<0?J.length:W+X,F.lastIndex=W;continue}if(G&&!N&&!c.has(K))G=!1,$=0;if(K==="head")G=!N;if(d.has(K)){$=N?Math.max(0,$-1):$+1;continue}if($>0)continue;if(K==="a"){if(!N){let X=n(j[2]??"","href")??"";q={href:X===""||X.startsWith("#")?"":r(X,Q),start:z.length}}else if(q){let X=z.slice(q.start).join("").trim(),w=q.href;if(w&&X&&X!==w&&!/^(javascript|data|mailto|tel):/i.test(w))z.push(` (${w})`);q=null}continue}if(K==="br"){z.push(`
5
+ `);continue}if(K==="li"){if(!N)z.push(`
6
+ - `);continue}let O=z.length>0?z[z.length-1]:`
7
+ `;if(K==="td"||K==="th"){if(!N&&!O.endsWith(`
8
+ `))z.push(" ");continue}if(K==="pre")Z=Math.max(0,Z+(N?-1:1));if(l.has(K)){let X=m.has(K)?`
9
+
10
+ `:`
11
+ `;if(!O.endsWith(X))z.push(X)}}return V(J.slice(W)),z.join("").replace(/(?<=^|[^ \t])[ \t]+\n/g,`
12
+ `).replace(/\n{3,}/g,`
13
+
14
+ `).trim()}var H=524288,f=50000,k=250000,S=5,b=30000,a="Mozilla/5.0 (compatible; rovecode/0.2 web_fetch)",s="text/html, application/xhtml+xml, application/json;q=0.9, text/*;q=0.8, application/xml;q=0.7, */*;q=0.1";function t(J){return Number.isFinite(J)&&J>0?Math.min(Math.floor(J),k):f}function e(){let J=Number(process.env.ROVECODE_WEBFETCH_TIMEOUT_MS??"");return Number.isFinite(J)&&J>0?Math.floor(J):b}function I(J){let Q=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/.exec(J);if(!Q)return null;let z=0;for(let $=1;$<=4;$++){let Z=Number(Q[$]);if(Z>255)return null;z=z<<8|Z}return z>>>0}function zz(J){let Q=J.includes("%")?J.slice(0,J.indexOf("%")):J;if(!/^[0-9a-fA-F:.]+$/.test(Q)||!Q.includes(":"))return null;let z=Q.split("::");if(z.length>2)return null;let $=(F)=>{if(F==="")return[];let W=[];for(let V of F.split(":"))if(V.includes(".")){let j=I(V);if(j===null)return null;W.push(j>>>16,j&65535)}else if(/^[0-9a-fA-F]{1,4}$/.test(V))W.push(parseInt(V,16));else return null;return W},Z=$(z[0]),G=z.length===2?$(z[1]):[];if(!Z||!G)return null;let q=8-Z.length-G.length;if(z.length===2?q<1:q!==0)return null;return[...Z,...Array(q).fill(0),...G]}var Jz=[["0.0.0.0",8],["10.0.0.0",8],["100.64.0.0",10],["127.0.0.0",8],["169.254.0.0",16],["172.16.0.0",12],["192.0.0.0",24],["192.0.2.0",24],["192.168.0.0",16],["198.18.0.0",15],["198.51.100.0",24],["203.0.113.0",24],["224.0.0.0",4],["240.0.0.0",4]].map(([J,Q])=>[I(J),Q]);function _(J){return Jz.some(([Q,z])=>J>>>32-z===Q>>>32-z)}function v(J){let Q=I(J);if(Q!==null)return _(Q);let z=zz(J);if(!z)return!0;let[$,Z,G,q,F,W,V,j]=z;if($===0&&Z===0&&G===0&&q===0&&F===0&&W===65535)return _((V<<16|j)>>>0);if(($&57344)!==8192)return!0;if($===8194)return _((Z<<16|G)>>>0);return $===8193&&Z===3512}var Qz=async(J)=>(await o(J,{all:!0})).map((Q)=>Q.address);function C(J){let Q=J.toLowerCase();if(Q.startsWith("[")&&Q.endsWith("]"))Q=Q.slice(1,-1);return Q.endsWith(".")?Q.slice(0,-1):Q}async function Zz(J,Q){let z=C(J),$="a private, loopback, link-local or reserved address";if(z==="")return"empty host";if(z==="localhost"||z.endsWith(".localhost"))return`${z} is a loopback name`;if(I(z)!==null||z.includes(":"))return v(z)?`${z} is a private, loopback, link-local or reserved address`:null;let Z;try{Z=await Q(z)}catch(q){return`could not resolve ${z}: ${q instanceof Error?q.message:String(q)}`}if(Z.length===0)return`could not resolve ${z}`;let G=Z.find(v);return G===void 0?null:`${z} resolves to ${G}, a private, loopback, link-local or reserved address`}var $z=new Set([301,302,303,307,308]);function qz(J){return J===""||J.startsWith("text/")||J==="application/json"||J==="application/xml"||J==="application/xhtml+xml"||J==="application/javascript"||J==="application/ecmascript"||J.endsWith("+json")||J.endsWith("+xml")}function Gz(J,Q){if(J==="text/html"||J==="application/xhtml+xml")return!0;return J===""&&/^\s*<(!doctype\s+html|html|head|body)[\s>]/i.test(Q.slice(0,1024))}function Vz(J,Q){if(Q.aborted)return Promise.reject(Error("aborted"));return new Promise((z,$)=>{let Z=()=>$(Error("aborted"));Q.addEventListener("abort",Z,{once:!0}),J.then(z,$).finally(()=>Q.removeEventListener("abort",Z))})}async function Wz(J,Q){if(!J.body)return{bytes:new Uint8Array(0),truncated:!1};let z=J.body.getReader(),$=[],Z=0,G=!1;try{for(;;){let{done:W,value:V}=await z.read();if(W)break;if(V.length===0)continue;if(Z>=Q){G=!0;break}let j=Q-Z;if(V.length>j){$.push(V.subarray(0,j)),Z=Q,G=!0;break}$.push(V),Z+=V.length}}finally{await z.cancel().catch(()=>{})}let q=new Uint8Array(Z),F=0;for(let W of $)q.set(W,F),F+=W.length;return{bytes:q,truncated:G}}function Kz(J,Q,z){let $=/charset=["']?([\w.:-]+)/i.exec(Q)?.[1],Z;try{Z=new TextDecoder($??"utf-8")}catch{Z=new TextDecoder}let G=Z.decode(J);return z?G.replace(/\uFFFD$/,""):G}function Nz(J={}){let Q=J.fetch??((Z,G)=>fetch(Z,G)),z=J.resolve??Qz;async function $(Z,G){if(typeof Z.url!=="string"||Z.url.trim()==="")return{ok:!1,output:"web_fetch: url is required"};let q;try{q=new URL(Z.url.trim())}catch{return{ok:!1,output:`web_fetch: invalid URL: ${Z.url}`}}let F=t(Z.maxChars),W=process.env.ROVECODE_WEBFETCH_ALLOW_PRIVATE==="1";if(G.signal.aborted)return{ok:!1,output:"web_fetch: aborted"};let V=new AbortController,j=e(),K=!1,N=setTimeout(()=>{K=!0,V.abort()},j);N.ref?.();let O=()=>V.abort();G.signal.addEventListener("abort",O,{once:!0});let X=(w)=>{if(V.signal.aborted)return{ok:!1,output:K?`web_fetch: timed out after ${j}ms`:"web_fetch: aborted"};return{ok:!1,output:`web_fetch: request failed: ${w instanceof Error?w.message:String(w)}`}};try{let w=0,R=C(q.hostname);for(;;){if(q.protocol!=="http:"&&q.protocol!=="https:")return{ok:!1,output:`web_fetch: unsupported URL scheme ${q.protocol} (http/https only)`};if(!W){let Y;try{Y=await Vz(Zz(q.hostname,z),V.signal)}catch(h){return X(h)}if(Y!==null)return{ok:!1,output:`web_fetch: refused ${q.href}: ${Y} (set ROVECODE_WEBFETCH_ALLOW_PRIVATE=1 for local dev servers)`}}let x=C(q.hostname);if(x!==R)return{ok:!1,output:`web_fetch: redirected to ${q.href}; fetch it directly (a redirect from ${R} to ${x} needs its own net.fetch permission)`};let L;try{L=await Q(q.href,{method:"GET",redirect:"manual",signal:V.signal,headers:{"User-Agent":a,Accept:s}})}catch(Y){return X(Y)}if($z.has(L.status)){let Y=L.headers.get("location");if(await L.body?.cancel().catch(()=>{}),!Y)return{ok:!1,output:`web_fetch: HTTP ${L.status} redirect from ${q.href} without a Location header`};if(++w>S)return{ok:!1,output:`web_fetch: too many redirects (more than ${S}) starting from ${Z.url}`};try{q=new URL(Y,q)}catch{return{ok:!1,output:`web_fetch: invalid redirect target ${Y}`}}continue}let E=L.headers.get("content-type")??"",D=(E.split(";")[0]??"").trim().toLowerCase();if(!qz(D))return await L.body?.cancel().catch(()=>{}),{ok:!1,output:`web_fetch: unsupported content-type: ${D} (only text/*, JSON, XML and XHTML are fetched)`};let B;try{B=await Wz(L,H)}catch(Y){return X(Y)}let P=Kz(B.bytes,E,B.truncated),M=Gz(D,P)?g(P,q.href):P,U=[];if(B.truncated){let Y=Number(L.headers.get("content-length"));U.push(`(Body truncated at ${H} bytes${Number.isFinite(Y)&&Y>0?` of ${Y}`:""}.)`)}let T=M.length,A=T>F;if(A)M=M.slice(0,F).replace(/[\uD800-\uDBFF]$/,""),U.push(`(Text truncated: showing first ${F} of ${T} characters.)`);let u=[`${q.href} (HTTP ${L.status}, ${D||"no content-type"}, ${B.bytes.length} bytes${w>0?`, ${w} redirect${w===1?"":"s"}`:""})`,M,...U.length>0?[U.join(`
15
+ `)]:[]].filter((Y)=>Y!=="").join(`
16
+
17
+ `);return{ok:L.status<400,output:u,data:{url:q.href,status:L.status,contentType:D,bytes:B.bytes.length,redirects:w,truncated:B.truncated||A}}}}finally{clearTimeout(N),G.signal.removeEventListener("abort",O)}}return{schema:{name:"web_fetch",description:`Fetch a public http(s) URL with GET and return its content as readable text. HTML is reduced to text (scripts/styles dropped, headings/paragraphs/lists kept, links as "text (href)"); JSON, XML and plain text pass through unchanged. Follows at most ${S} redirects, and only within the same host: a redirect to another host stops with that URL \u2014 fetch it directly. Only text/*, JSON, XML and XHTML responses are accepted. The body is read up to ${H} bytes and the text is capped at maxChars (default ${f}, cap ${k}); both truncations leave a marker. Times out after ${b/1000}s. Private, loopback, link-local and unresolvable hosts are refused. Output starts with a header line: final URL, HTTP status, content-type, bytes read.`,args:{type:"object",properties:{url:{type:"string",description:"absolute http:// or https:// URL to fetch"},maxChars:{type:"integer",description:`max characters of text returned (default ${f}, cap ${k})`}},required:["url"]}},kind:"network",sequential:!1,execute:(Z,G)=>$(Z??{},G)}}var wz=Nz();
18
+ export{H as wf,f as xf,k as yf,S as zf,b as Af,t as Bf,v as Cf,Qz as Df,C as Ef,Zz as Ff,Vz as Gf,Wz as Hf,Nz as If,wz as Jf};
@@ -0,0 +1,7 @@
1
+ // @bun
2
+ import{wn as M}from"./main-qsevpgsv.js";import{mkdirSync as X,readFileSync as l,renameSync as N,writeFileSync as w}from"fs";import{basename as C,join as y}from"path";function v(z){return f.includes(z)}function c(z){return u.includes(z)}function U(z){let q;try{q=JSON.stringify(z)??String(z)}catch{q=String(z)}return q.length>40?q.slice(0,40).replace(/[\uD800-\uDBFF]$/,"")+"\u2026":q}function L(z){let q=(J)=>({ok:!1,error:J});if(!Array.isArray(z))return q("`todos` must be an array of {id, content, status, priority?}");if(z.length>Y)return q(`too many todos: ${z.length} (max ${Y})`);let Q=[],K=new Set,$=[];for(let J=0;J<z.length;J++){let k=z[J],Z=`todos[${J}]`;if(!k||typeof k!=="object"||Array.isArray(k))return q(`${Z} must be an object {id, content, status, priority?}`);let b=k;if(typeof b.id!=="string"||b.id.trim().length===0)return q(`${Z}.id must be a non-empty string`);let B=b.id.trim();if(B.length>W)return q(`${Z}.id exceeds ${W} chars`);if(K.has(B))return q(`duplicate id "${B}" at ${Z} \u2014 ids must be unique`);if(K.add(B),typeof b.content!=="string"||b.content.trim().length===0)return q(`${Z} ("${B}"): content must be a non-empty string`);let H=b.content.trim();if(H.length>j)return q(`${Z} ("${B}"): content exceeds ${j} chars`);if(!v(b.status))return q(`${Z} ("${B}"): status must be one of ${f.join(", ")} (got ${U(b.status)})`);let V={id:B,content:H,status:b.status};if(b.priority!==void 0&&b.priority!==null){if(!c(b.priority))return q(`${Z} ("${B}"): priority must be one of ${u.join(", ")} (got ${U(b.priority)})`);V.priority=b.priority}if(V.status==="in_progress")$.push(B);Q.push(V)}if($.length>1)return q(`only one todo may be in_progress at a time (found ${$.length}: ${$.join(", ")})`);return{ok:!0,items:Q}}function A(z){let q=y(z,G),Q="treating the list as empty; the next todo_write replaces it",K;try{K=l(q,"utf8")}catch(Z){if(Z?.code==="ENOENT")return{items:[]};return{items:[],note:`${G} could not be read (${Z instanceof Error?Z.message:String(Z)}) \u2014 ${"treating the list as empty; the next todo_write replaces it"}`}}let $;try{$=JSON.parse(K)}catch{return{items:[],note:`${G} is not valid JSON \u2014 ${"treating the list as empty; the next todo_write replaces it"}`}}let J=$&&typeof $==="object"&&!Array.isArray($)?$:null;if(!J||J.version!==p||!Array.isArray(J.items))return{items:[],note:`${G} has an unexpected shape (expected {version: ${p}, items: [...]}) \u2014 ${"treating the list as empty; the next todo_write replaces it"}`};let k=L(J.items);if(!k.ok)return{items:[],note:`${G} failed validation (${k.error}) \u2014 ${"treating the list as empty; the next todo_write replaces it"}`};return{items:k.items}}function E(z,q){X(z,{recursive:!0});let Q=y(z,G),K=Q+".tmp";w(K,JSON.stringify({version:p,items:q},null,2)+`
3
+ `),N(K,Q)}function F(z,q){if(!q||q==="."||q===".."||/[\\/]/.test(q)||C(q)!==q)return null;return y(z,q)}function h(z){let q={total:z.length,pending:0,inProgress:0,completed:0};for(let Q of z)if(Q.status==="completed")q.completed++;else if(Q.status==="in_progress")q.inProgress++;else q.pending++;return q}function x(z){let q=z.replace(/\s+/g," ").trim();return q.length>P?q.slice(0,P).replace(/[\uD800-\uDBFF]$/,"")+"\u2026":q}function g(z){if(z.length===0)return"todos: (empty)";let q=h(z),Q=[`todos: ${q.total} total \xB7 ${q.completed} completed \xB7 ${q.inProgress} in progress \xB7 ${q.pending} pending`];for(let K of z.slice(0,Y))Q.push(`${R[K.status]} ${x(K.id)}: ${x(K.content)}${K.priority?` (${K.priority})`:""}`);if(z.length>Y)Q.push(`(+${z.length-Y} more not shown)`);return Q.join(`
4
+ `)}function O(z){let q=h(z);if(q.total===0||q.completed===q.total)return null;return["<plan-reminder>","Your own todo list for this task, still open \u2014 not a message from the user.",g(z),q.inProgress===0?"Nothing is in progress. Mark the next item in_progress with todo_write before you start it.":"Mark the in_progress item completed with todo_write the moment it is done, then start the next one.","Rewrite the list if the plan changed. Never mention this reminder in your reply.","</plan-reminder>"].join(`
5
+ `)}function n(z){if(z.length===0)return"";let q=h(z);return`todos ${q.completed}/${q.total}`}function _(z){return{schema:{name:"todo_write",description:D,args:{type:"object",properties:{todos:{type:"array",description:"the complete, updated todo list (replaces the current one)",maxItems:Y,items:I}},required:["todos"]}},kind:"memory",sequential:!0,execute(q,Q){let K=F(z,Q.sessionId);if(!K)return Promise.resolve({ok:!1,output:`todo_write failed: invalid session id ${U(Q.sessionId)}`});let J=L((q&&typeof q==="object"?q:{}).todos);if(!J.ok)return Promise.resolve({ok:!1,output:`todo_write failed: ${J.error}; the list was not changed`});try{E(K,J.items)}catch(Z){return Promise.resolve({ok:!1,output:`todo_write failed: could not write ${G}: ${Z instanceof Error?Z.message:String(Z)}`})}let k=J.items.length===0?"Cleared todo list.":g(J.items);return Promise.resolve({ok:!0,output:k,data:{items:J.items}})}}}function S(z){return{schema:{name:"todo_read",description:m,args:{type:"object",properties:{}}},kind:"read",sequential:!1,execute(q,Q){let K=F(z,Q.sessionId);if(!K)return Promise.resolve({ok:!1,output:`todo_read failed: invalid session id ${U(Q.sessionId)}`});let{items:$,note:J}=A(K);if($.length===0){let k=J?`${J}
6
+ `:"";return Promise.resolve({ok:!0,output:`${k}No todos for this session yet \u2014 use todo_write to create a list.`,data:{items:$,...J?{note:J}:{}}})}return Promise.resolve({ok:!0,output:g($),data:{items:$}})}}}function r(z){return[_(z),S(z)]}var f,u,Y=50,W=64,j=500,G="todos.json",p=1,P=200,R,D,m="Read this session's todo list as last written by todo_write: ids, content, status, priority. Use it to get the current ids before updating the list, or to check what remains. Empty until todo_write creates a list.",I;var a=M(()=>{f=["pending","in_progress","completed"],u=["high","medium","low"];R={pending:"[ ]",in_progress:"[>]",completed:"[x]"};D="Create or update this session's structured todo list (your plan). REPLACES the whole list: send every item "+`you want kept \u2014 items {id, content, status, priority?}; at most ${Y} items, ids unique and non-empty `+`(\u2264${W} chars), content non-empty (\u2264${j} chars). Statuses: pending | in_progress (exactly ONE at a time) | completed. Priority: high | medium | low (optional). An invalid list is rejected whole and nothing changes; an empty list clears the todos. Use proactively when: the task needs 3+ distinct steps; the work is non-trivial and benefits from planning; the user gives multiple tasks or asks for a todo list; new instructions arrive (capture them as todos); you start a step (mark it in_progress first) or finish one (mark it `+"completed only once the work, including verification, is actually done \u2014 never on intent; add follow-ups "+"discovered on the way). Skip it for a single straightforward task, a purely informational request, or when "+"tracking adds no value. Update in real time \u2014 don't batch completions. When in doubt, use it.",I={type:"object",properties:{id:{type:"string",description:`stable short id, unique within the list (e.g. "t1"); \u2264${W} chars`},content:{type:"string",description:`brief, specific, actionable description of the task; \u2264${j} chars`},status:{type:"string",enum:[...f],description:"pending | in_progress (exactly one at a time) | completed"},priority:{type:"string",enum:[...u],description:"optional priority"}},required:["id","content","status"]}});
7
+ export{f as cg,u as dg,Y as eg,W as fg,j as gg,G as hg,L as ig,A as jg,E as kg,h as lg,g as mg,O as ng,n as og,_ as pg,S as qg,r as rg,a as sg};
@@ -0,0 +1,4 @@
1
+ // @bun
2
+ import{Am as H,Fm as C,zm as h}from"./main-7rn6bqje.js";import{$m as X,Lm as z}from"./main-2yeveeve.js";import{wn as G}from"./main-qsevpgsv.js";var k=(e,...i)=>["-y",e,...i],P;var K=G(()=>{P=[{key:"filesystem",title:"Filesystem",source:"curated",publisher:"modelcontextprotocol (Anthropic)",description:"Read, write, search and move files under the directories you name.",repository:"https://github.com/modelcontextprotocol/servers",installs:[{kind:"stdio",runtime:"npx",command:"npx",args:k("@modelcontextprotocol/server-filesystem"),env:[],pending:["<directory the server may touch>"]}]},{key:"memory",title:"Memory",source:"curated",publisher:"modelcontextprotocol (Anthropic)",description:"A knowledge graph the model can remember across sessions with (entities, relations, observations).",repository:"https://github.com/modelcontextprotocol/servers",installs:[{kind:"stdio",runtime:"npx",command:"npx",args:k("@modelcontextprotocol/server-memory"),env:[],pending:[]}]},{key:"sequential-thinking",title:"Sequential Thinking",source:"curated",publisher:"modelcontextprotocol (Anthropic)",description:"A scratchpad tool for step-by-step reasoning with revisions and branches.",repository:"https://github.com/modelcontextprotocol/servers",installs:[{kind:"stdio",runtime:"npx",command:"npx",args:k("@modelcontextprotocol/server-sequential-thinking"),env:[],pending:[]}]},{key:"everything",title:"Everything (test server)",source:"curated",publisher:"modelcontextprotocol (Anthropic)",description:"Exercises every MCP feature \u2014 prompts, resources, sampling, progress. For testing a client, not for work.",repository:"https://github.com/modelcontextprotocol/servers",installs:[{kind:"stdio",runtime:"npx",command:"npx",args:k("@modelcontextprotocol/server-everything"),env:[],pending:[]}]},{key:"fetch",title:"Fetch",source:"curated",publisher:"modelcontextprotocol (Anthropic)",description:"Fetch a URL and hand the page back as markdown (Python; needs uv).",repository:"https://github.com/modelcontextprotocol/servers",installs:[{kind:"stdio",runtime:"uvx",command:"uvx",args:["mcp-server-fetch"],env:[],pending:[]}]},{key:"git",title:"Git",source:"curated",publisher:"modelcontextprotocol (Anthropic)",description:"Read and search git repositories: log, diff, show, status (Python; needs uv).",repository:"https://github.com/modelcontextprotocol/servers",installs:[{kind:"stdio",runtime:"uvx",command:"uvx",args:["mcp-server-git"],env:[],pending:[]}]},{key:"time",title:"Time",source:"curated",publisher:"modelcontextprotocol (Anthropic)",description:"Current time and timezone conversion (Python; needs uv).",repository:"https://github.com/modelcontextprotocol/servers",installs:[{kind:"stdio",runtime:"uvx",command:"uvx",args:["mcp-server-time"],env:[],pending:[]}]},{key:"github",title:"GitHub",source:"curated",publisher:"GitHub",description:"Issues, pull requests, code search and Actions on GitHub \u2014 remote with a personal access token, or the official image via docker.",repository:"https://github.com/github/github-mcp-server",installs:[{kind:"http",url:"https://api.githubcopilot.com/mcp/",headers:[{name:"Authorization",template:"Bearer {GITHUB_PAT}",required:!0,secret:!0,description:"a GitHub personal access token"}]},{kind:"stdio",runtime:"docker",command:"docker",args:["run","-i","--rm","-e","GITHUB_PERSONAL_ACCESS_TOKEN","ghcr.io/github/github-mcp-server"],env:[{name:"GITHUB_PERSONAL_ACCESS_TOKEN",required:!0,secret:!0,description:"a GitHub personal access token"}],pending:[]}]},{key:"playwright",title:"Playwright",source:"curated",publisher:"Microsoft",description:"Drive a real browser through accessibility snapshots: navigate, click, type, screenshot.",repository:"https://github.com/microsoft/playwright-mcp",installs:[{kind:"stdio",runtime:"npx",command:"npx",args:k("@playwright/mcp@latest"),env:[],pending:[]}]},{key:"context7",title:"Context7",source:"curated",publisher:"Upstash",description:"Up-to-date library documentation and code examples for the versions you actually use.",repository:"https://github.com/upstash/context7",installs:[{kind:"http",url:"https://mcp.context7.com/mcp",headers:[{name:"CONTEXT7_API_KEY",required:!1,secret:!0,description:"optional API key for higher limits"}]},{kind:"stdio",runtime:"npx",command:"npx",args:k("@upstash/context7-mcp"),env:[{name:"CONTEXT7_API_KEY",required:!1,secret:!0,description:"optional API key for higher limits"}],pending:[]}]},{key:"brave-search",title:"Brave Search",source:"curated",publisher:"Brave",description:"Web, news, image and local search through the Brave Search API.",repository:"https://github.com/brave/brave-search-mcp-server",installs:[{kind:"stdio",runtime:"npx",command:"npx",args:k("@brave/brave-search-mcp-server"),env:[{name:"BRAVE_API_KEY",required:!0,secret:!0,description:"Brave Search API key"}],pending:[]}]},{key:"firecrawl",title:"Firecrawl",source:"curated",publisher:"Firecrawl (Mendable)",description:"Scrape, crawl and extract structured data from websites.",repository:"https://github.com/mendableai/firecrawl-mcp-server",installs:[{kind:"stdio",runtime:"npx",command:"npx",args:k("firecrawl-mcp"),env:[{name:"FIRECRAWL_API_KEY",required:!0,secret:!0,description:"Firecrawl API key"}],pending:[]}]},{key:"tavily",title:"Tavily",source:"curated",publisher:"Tavily",description:"Search and extract built for agents: web search, page extraction, site crawl.",repository:"https://github.com/tavily-ai/tavily-mcp",installs:[{kind:"stdio",runtime:"npx",command:"npx",args:k("tavily-mcp"),env:[{name:"TAVILY_API_KEY",required:!0,secret:!0,description:"Tavily API key"}],pending:[]}]},{key:"exa",title:"Exa",source:"curated",publisher:"Exa",description:"Neural web search and page contents for AI; the remote works without a key at a low rate.",repository:"https://github.com/exa-labs/exa-mcp-server",installs:[{kind:"http",url:"https://mcp.exa.ai/mcp",headers:[]}]},{key:"deepwiki",title:"DeepWiki",source:"curated",publisher:"Cognition (Devin)",description:"Ask questions about any public GitHub repository, answered from its generated wiki. No key.",homepage:"https://docs.devin.ai/work-with-devin/deepwiki-mcp",installs:[{kind:"http",url:"https://mcp.deepwiki.com/mcp",headers:[]}]},{key:"cloudflare-docs",title:"Cloudflare Docs",source:"curated",publisher:"Cloudflare",description:"Search Cloudflare's developer documentation. No key.",repository:"https://github.com/cloudflare/mcp-server-cloudflare",installs:[{kind:"http",url:"https://docs.mcp.cloudflare.com/mcp",headers:[]}]}]});import{existsSync as J,mkdirSync as Z,readFileSync as $,writeFileSync as D}from"fs";import{dirname as Q,join as U}from"path";function l(e,i=y.str){if(typeof e!=="string"||e.length===0)return;let t=e.replace(/[\u0000-\u001f\u007f]/g," ");return t.length>i?t.slice(0,i-1)+"\u2026":t}function g(e,i=y.list){return Array.isArray(e)?e.slice(0,i):[]}function B(e){let i=l(e,2000);if(i===void 0)return;try{let t=new URL(i);return t.protocol==="http:"||t.protocol==="https:"?i:void 0}catch{return}}function w(e){if(!h(e))return;let i=l(e.name,128);if(i===void 0||!M.test(i))return;let t=l(e.value)??l(e.default),o={name:i,required:e.isRequired===!0,secret:e.isSecret===!0},r=l(e.description,y.desc);if(r!==void 0)o.description=r;if(t!==void 0&&!Y.test(t))o.default=t;return Y.lastIndex=0,o}function ee(e){if(!h(e))return;let i=l(e.name,64);if(i===void 0||!j.test(i))return;let t={name:i,required:e.isRequired===!0,secret:e.isSecret===!0},o=l(e.value)??l(e.default);if(o!==void 0)t.template=o;let r=l(e.description,y.desc);if(r!==void 0)t.description=r;return t}function N(e){return e.startsWith("<")&&e.endsWith(">")?e:`<${e}>`}function E(e,i){let t=[];for(let o of e){if(!h(o))continue;let r=l(o.value)??l(o.default),c=l(o.name,128),s=l(o.valueHint,64)??c??"<argument>";if(o.type==="named"){if(c===void 0)continue;if(r!==void 0)t.push(c,r);else if(o.isRequired===!0)i.push(`${c} ${N(l(o.valueHint,64)??"value")}`)}else if(r!==void 0)t.push(r);else if(o.isRequired===!0)i.push(N(s))}return t}function te(e,i){if(!h(e))return;let t=l(e.registryType,32),o=l(e.identifier,200),r=l(e.version,64);if(t===void 0||o===void 0)return;let c=h(e.transport)?l(e.transport.type,32):"stdio";if(c!==void 0&&c!=="stdio")return;let s=l(e.runtimeHint,64);if(s!==void 0&&!R.test(s)){i.push(`${o}: runtime hint "${s}" refused (not a bare command name)`);return}let p=[],n=E(g(e.runtimeArguments),p),b=E(g(e.packageArguments),p),u=g(e.environmentVariables).map(w).filter((x)=>x!==void 0),m=r!==void 0&&r!=="latest",d,a,v;switch(t){case"npm":d=s??"npx",v=d==="npx"?"npx":"other",a=[...d==="npx"&&!n.includes("-y")?["-y"]:[],...n,m?`${o}@${r}`:o,...b];break;case"pypi":d=s??"uvx",v=d==="uvx"?"uvx":"other",a=[...n,m?`${o}==${r}`:o,...b];break;case"oci":d=s??"docker",v=d==="docker"?"docker":"other",a=["run","-i","--rm",...u.flatMap((x)=>["-e",x.name]),...n,m?`${o}:${r}`:o,...b];break;default:i.push(`${o}: package type "${t}" is not something rovecode can launch`);return}return{kind:"stdio",runtime:v,command:d,args:a,env:u,pending:p}}function ie(e,i=[]){if(!h(e))return;let t=l(e.type,32),o=B(e.url);if(t!=="streamable-http"&&t!=="http"){i.push(`${o??"a remote"}: ${t==="sse"?"sse remote (legacy transport) is not something rovecode can connect to":`remote type "${t??"?"}" is not something rovecode can connect to`}`);return}if(o===void 0)return;return{kind:"http",url:o,headers:g(e.headers).map(ee).filter((r)=>r!==void 0)}}function oe(e){let i=e.split("/")[0]??e;if(i.startsWith("io.github."))return`github.com/${i.slice(10)}`;return i.split(".").reverse().join(".")}function O(e,i){if(!h(e)||!h(e.server))return;let t=e.server,o=l(t.name,200);if(o===void 0||!/^[a-z0-9][a-z0-9.-]*\/[A-Za-z0-9._-]+$/.test(o))return;let r=h(e._meta)?e._meta["io.modelcontextprotocol.registry/official"]:void 0,c=h(r)?l(r.status,32):void 0;if(c==="deleted")return;let s=[];for(let d of g(t.packages,y.packages)){let a=te(d,i);if(a)s.push(a)}for(let d of g(t.remotes,y.packages)){let a=ie(d,i);if(a)s.push(a)}let p={key:o,description:l(t.description,y.desc)??"",source:"registry",publisher:oe(o),installs:s},n=l(t.title,120),b=l(t.version,64),u=B(t.websiteUrl),m=h(t.repository)?B(t.repository.url):void 0;if(n!==void 0)p.title=n;if(b!==void 0)p.version=b;if(c!==void 0&&c!=="active")p.status=c;if(m!==void 0)p.repository=m;if(u!==void 0)p.homepage=u;return p}function re(e){if(!h(e)||!h(e.metadata))return;let i=e.metadata.nextCursor;return typeof i==="string"&&i.length>0&&i.length<=y.str?i:void 0}function pe(e,i){if(!h(e))return i.push("registry: response is not an object"),[];let t=new Set,o=[];for(let r of g(e.servers,y.servers)){let c=O(r,i);if(c&&!t.has(c.key))t.add(c.key),o.push(c)}return o}function _(e){return U(e,"cache","mcp-market.json")}function le(e){let i=_(e);if(!J(i))return{version:1,queries:{}};try{let t=JSON.parse($(i,"utf8"));if(h(t)&&t.version===1&&h(t.queries))return t}catch{}return{version:1,queries:{}}}function se(e,i){let t=Object.entries(i.queries).sort((o,r)=>r[1].at-o[1].at).slice(0,S);try{Z(Q(_(e)),{recursive:!0}),D(_(e),JSON.stringify({version:1,queries:Object.fromEntries(t)})+`
3
+ `)}catch{}}async function F(e,i){let t=i.fetch??fetch,o=i.registryUrl??process.env.ROVECODE_MCP_REGISTRY??T,r=await t(`${o}${e}`,{headers:{accept:"application/json"},signal:AbortSignal.timeout(L)});if(!r.ok)throw Error(`registry answered ${r.status}`);let c=await r.text();if(c.length>y.body)throw Error(`registry response too large (${c.length} bytes)`);return JSON.parse(c)}async function V(e,i,t,o){let r=t.home??z(),c=(t.now??Date.now)(),s=le(r),p=s.queries[e];if(p&&c-p.at<I)return{entries:p.entries,fromCache:!0};if(t.offline){if(p)o.push("offline: showing cached registry results");return{entries:p?.entries??[],fromCache:p!==void 0}}try{let n=await i();return s.queries[e]={at:c,entries:n},se(r,s),{entries:n,fromCache:!1}}catch(n){return o.push(`registry unreachable (${H(n)})${p?" \u2014 showing cached results":""}`),{entries:p?.entries??[],fromCache:p!==void 0}}}async function ye(e,i={}){let t=[],o=e.trim().toLowerCase(),r=i.catalog??P,c=o.split(/\s+/).filter(Boolean),s=r.filter((u)=>c.every((m)=>`${u.key} ${u.title??""} ${u.description}`.toLowerCase().includes(m)));if(o.length<2)return{entries:s,notes:t,fromCache:!1};let{entries:p,fromCache:n}=await V(`search:${o}`,async()=>{let u=[],m=[],d=new Set,a=new Set,v;for(let x=0;x<ce;x++){let W=`/servers?search=${encodeURIComponent(o)}&version=latest&limit=50${v?`&cursor=${encodeURIComponent(v)}`:""}`,q=await F(W,i);for(let A of pe(q,u)){if(d.has(A.key))continue;d.add(A.key),m.push(A)}if(m.length>=y.servers)break;let f=re(q);if(f===void 0||a.has(f))break;a.add(f),v=f}return m.slice(0,y.servers)},i,t),b=new Set(s.flatMap((u)=>[u.key,...u.repository?[u.repository]:[]]));return{entries:[...s,...p.filter((u)=>!b.has(u.key)&&!(u.repository&&b.has(u.repository)))],notes:t,fromCache:n}}async function ke(e,i={}){let t=[],o=e.trim(),c=(i.catalog??P).find((n)=>n.key===o);if(c)return{entry:c,notes:t};if(!o.includes("/"))return t.push(`"${o}" is not a curated name and not a registry name (those look like io.github.owner/repo) \u2014 try: rovecode mcp search ${o}`),{notes:t};let{entries:s}=await V(`info:${o}`,async()=>{let n=await F(`/servers/${encodeURIComponent(o)}/versions/latest`,i),b=O(n,t);return b?[b]:[]},i,t),p=s[0];if(!p&&t.length===0)t.push(`"${o}" is not in the registry`);return p?{entry:p,notes:t}:{notes:t}}function ve(e){return e.kind==="stdio"?[e.command,...e.args].join(" "):e.url}var T="https://registry.modelcontextprotocol.io/v0",I=86400000,S=40,L=20000,y,M,j,R,Y,ce=5;var ue=G(()=>{X();C();K();y={body:2097152,servers:100,str:300,desc:500,list:32,packages:8},M=/^[A-Za-z_][A-Za-z0-9_]*$/,j=/^[A-Za-z0-9-]{1,64}$/,R=/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/,Y=/\{([A-Za-z_][A-Za-z0-9_-]*)\}/g});
4
+ export{ye as Cc,ke as Dc,ve as Ec,ue as Fc};
@@ -0,0 +1,9 @@
1
+ // @bun
2
+ var _=new Set([..."{}*?[]\\~^#$`()<>"]);function K(j){let Z=R(j);if(Z===null)return null;let J=[],z=[],$=!1,Q=()=>{let X=z[0];if(X===void 0||/^[A-Za-z_][A-Za-z0-9_]*\+?=/.test(X))return!1;return J.push(z),z=[],!0};for(let X of Z)if(X.kind==="word"){if(X.quotedHead&&z.length===0)return null;z.push(X.text)}else if(X.op===`
3
+ `){if(z.length>0){if(!Q())return null;$=!1}}else if(X.op===";"){if(z.length===0||!Q())return null;$=!1}else{if(z.length===0||!Q())return null;$=!0}if($&&z.length===0)return null;if(z.length>0&&!Q())return null;return J}function R(j){let Z=[],J=0,z=j.length;while(J<z){let $=j[J];if($===void 0)break;if($===" "||$==="\t"||$==="\r"){J++;continue}if($===`
4
+ `){Z.push({kind:"op",op:`
5
+ `}),J++;continue}if($==="&"){if(j[J+1]!=="&")return null;Z.push({kind:"op",op:"&&"}),J+=2;continue}if($==="|"){if(j[J+1]==="|"){Z.push({kind:"op",op:"||"}),J+=2;continue}if(j[J+1]==="&")return null;Z.push({kind:"op",op:"|"}),J++;continue}if($===";"){if(j[J+1]===";")return null;Z.push({kind:"op",op:";"}),J++;continue}let Q="",X=0,G=!1;while(J<z){let W=j[J];if(W===void 0)break;if(` \r
6
+ &|;`.includes(W))break;if(W==="'"){let B=j.indexOf("'",J+1);if(B===-1)return null;if(Q+=j.slice(J+1,B),X===0)G=!0;X++,J=B+1;continue}if(W==='"'){let B=w(j,J);if(B===null)return null;if(Q+=B.text,X===0)G=!0;X++,J=B.next;continue}let Y="";while(J<z){let B=j[J];if(B===void 0||` \r
7
+ &|;'"`.includes(B))break;if(_.has(B))return null;Y+=B,J++}if(Y.startsWith("="))return null;if(X===0&&Y==="!")return null;Q+=Y,X++}if(X>1&&Q.length===0)return null;Z.push({kind:"word",text:Q,quotedHead:G})}return Z}function w(j,Z){let J=Z+1,z="";while(J<j.length){let $=j[J];if($===void 0)return null;if($==='"')return{text:z,next:J+1};if($==="$"||$==="`")return null;if($==="\\"){let Q=j[J+1];if(Q===void 0||Q==="$"||Q==="`"||Q==='"'||Q==="\\"||Q===`
8
+ `)return null;z+=$+Q,J+=2;continue}z+=$,J++}return null}var N=[{pattern:["ls"],match:[["ls"],"ls -la ."]},{pattern:["pwd"],match:[["pwd"]]},{pattern:["cat"],match:["cat file.txt"]},{pattern:["head"],match:["head -n 5 CHANGELOG.md"],notMatch:[["hea","-n","1"]]},{pattern:["tail"]},{pattern:["wc"]},{pattern:["echo"]},{pattern:["which"],match:["which python3"]},{pattern:["printenv"],notMatch:[["print","-0"]]},{pattern:["grep"]},{pattern:["cd"]},{pattern:["git",["status","log","diff","show","branch"]],match:["git status",["git","log","--oneline"]],notMatch:["git stash"]},{pattern:["git","branch",["-D","-d","-m","-M","-f","--delete","--force","--move"]],decision:"prompt",justification:"deletes or rewrites branches; confirm the target",match:["git branch -D feature",["git","branch","--delete","old"]],notMatch:["git branch","git branch --list","git branch -a"]},{pattern:["git","push"],decision:"prompt",justification:"pushes publish state; confirm the remote and branch",match:["git push","git push --force-with-lease"]},{pattern:["git","push",["--force","-f"]],decision:"forbidden",justification:"history-rewriting push; use --force-with-lease after user sign-off",match:["git push --force",["git","push","-f","origin","main"]],notMatch:["git push","git push --force-with-lease"]},{pattern:["git","reset","--hard"],decision:"forbidden",justification:"destructive operation",match:[["git","reset","--hard"]],notMatch:[["git","reset","--keep"],"git reset --merge"]}];var D={allow:0,prompt:1,forbidden:2};function L(j){let Z="allow";for(let J of j)if(D[J]>D[Z])Z=J;return Z}function A(j,Z){if(Z.length<j.tokens.length)return null;for(let J=0;J<j.tokens.length;J++){let z=j.tokens[J],$=Z[J];if(z===void 0||$===void 0)return null;if(typeof z==="string"?z!==$:!z.includes($))return null}return Z.slice(0,j.tokens.length)}function V(j,Z){let J=Z[0];if(J===void 0)return[];let z=(X,G)=>(j.get(X)??[]).flatMap((W)=>{let Y=A(W,G);return Y?[{kind:"rule",decision:W.decision,matchedPrefix:Y,justification:W.justification}]:[]}),$=z(J,Z);if($.length>0)return $;if(!q(J))return[];let Q=I(J);return Q!==null&&Q!==J?z(Q,[Q,...Z.slice(1)]):[]}function M(j){if(j.justification!==void 0&&j.justification.trim()==="")throw Error("prefix_rule: justification cannot be empty");let[Z,...J]=j.pattern;if(Z===void 0)throw Error("prefix_rule: pattern cannot be empty");for(let Q of j.pattern)if(typeof Q!=="string"&&Q.length===0)throw Error("prefix_rule: pattern alternatives cannot be empty");let z=typeof Z==="string"?[Z]:[...Z],$=new Map;for(let Q of z){if(Q.length===0)throw Error("prefix_rule: pattern tokens must be non-empty strings");let X=$.get(Q)??[];X.push({tokens:[Q,...J],decision:j.decision??"allow",justification:j.justification}),$.set(Q,X)}return $}class P{rulesByProgram=new Map;constructor(j){let Z=j.map(M);for(let J of Z)for(let[z,$]of J){let Q=this.rulesByProgram.get(z)??[];Q.push(...$),this.rulesByProgram.set(z,Q)}j.forEach((J,z)=>{let $=Z[z];for(let Q of J.notMatch??[]){let X=v(Q);if(V($,X).length>0)throw Error(`prefix_rule not_match example matched its rule: ${H(X)}`)}for(let Q of J.match??[]){let X=v(Q);if(V($,X).length===0)throw Error(`prefix_rule match example did not match its rule: ${H(X)}`)}})}check(j){let Z=V(this.rulesByProgram,j);if(Z.length===0)Z=[y(j)];return Z=[...Z,...E(j)],{decision:L(Z.map((J)=>J.decision)),matchedRules:Z}}checkMany(j){let Z=j.flatMap((J)=>this.check(J).matchedRules);if(Z.length===0)return this.check([]);return{decision:L(Z.map((J)=>J.decision)),matchedRules:Z}}checkScript(j){let Z=K(j);return Z!==null&&Z.length>0?this.checkMany(Z):this.check(["bash","-c",j])}}function I(j){if(!j.includes("/")&&!j.includes("\\"))return null;let Z=j.split(/[/\\]/).pop()??"";if(Z==="")return null;let J=Z.toLowerCase();for(let z of[".exe",".cmd",".bat",".com"])if(J.endsWith(z))return J.slice(0,-z.length);return Z}function q(j){return j.startsWith("/")||j.startsWith("\\\\")||/^[A-Za-z]:[/\\]/.test(j)}function y(j){let Z=O(j);return{kind:"heuristics",decision:"prompt",command:[...j],justification:Z==="forced-rm"?"rm -f style commands are not permitted. Use a safer approach":Z==="other"?"blocked by policy":void 0}}var C=new Set(["diff","show","log"]),k=new Set(["-D","-d","-m","-M","-f","--delete","--force","--move"]);function E(j){let Z=j[0],J=Z===void 0?null:I(Z)??Z,z=j[1];if(J!=="git"||z===void 0)return[];if(z==="branch"){for(let $ of j.slice(2)){if($==="--")break;if(k.has($))return[{kind:"heuristics",decision:"prompt",command:[...j],justification:"deletes or rewrites branches; confirm the target"}]}return[]}if(!C.has(z))return[];for(let $ of j.slice(2)){if($==="--")break;if($==="--output"||$.startsWith("--output="))return[{kind:"heuristics",decision:"prompt",command:[...j],justification:"--output writes the result to a file; confirm the destination"}]}return[]}var g=8;function O(j,Z=0){if(Z>g)return"other";let J=j[0]===void 0?null:I(j[0])??j[0];if(J==="rm"&&S(j.slice(1)))return"forced-rm";if(J==="sudo")return O(j.slice(1),Z+1);if(J==="env"){let z=1;while(z<j.length){let $=j[z];if($===void 0)break;if($==="--"){z++;break}if($==="-i"||$==="--ignore-environment"||/^[^-=][^=]*=/.test($)){z++;continue}break}return O(j.slice(z),Z+1)}if(J==="trap"){let z=j[1]==="--"?2:1,$=j[z];if($===void 0||$.startsWith("-"))return null;return U($,Z+1)}if((J==="bash"||J==="sh"||J==="zsh")&&j.length===3&&(j[1]==="-c"||j[1]==="-lc")&&j[2]!==void 0)return U(j[2],Z+1);return null}function U(j,Z){let J=K(j);if(J===null)return null;for(let z of J){let $=O(z,Z);if($!==null)return $}return null}function S(j){for(let Z of j){if(Z==="--")return!1;if(Z==="--force"||Z.startsWith("-")&&!Z.startsWith("--")&&Z.includes("f"))return!0}return!1}var b=null;function T(){return b??=new P(N)}function f(j,Z=T()){let J=Z.checkScript(j);if(J.decision==="forbidden"){let z=F(J,"forbidden");return{effect:"deny",reason:z?.justification!==void 0?`\`${j}\` rejected: ${z.justification}`:z!==null?`\`${j}\` rejected: policy forbids commands starting with \`${H(z.matchedPrefix)}\``:`\`${j}\` rejected: blocked by policy`}}if(J.decision==="prompt"){let z=F(J,"prompt"),$=J.matchedRules.find((X)=>X.kind==="heuristics"&&X.justification!==void 0);return{effect:"prompt",reason:z!==null?z.justification!==void 0?`\`${j}\` requires approval: ${z.justification}`:`\`${j}\` requires approval by policy`:$?.justification}}return{effect:"allow"}}function F(j,Z){let J=null;for(let z of j.matchedRules){if(z.kind!=="rule"||z.decision!==Z)continue;if(J===null||z.matchedPrefix.length>J.matchedPrefix.length)J=z}return J}function H(j){return j.map((Z)=>/^[A-Za-z0-9@%_+=:,./-]+$/.test(Z)?Z:`'${Z.replace(/'/g,"'\\''")}'`).join(" ")}function v(j){if(typeof j!=="string")return[...j];let Z=K(j),J=Z?.[0];if(Z===null||Z.length!==1||J===void 0)throw Error(`prefix_rule example is not a single plain command: ${j}`);return J}function l(j,Z={}){let J=Z.policy??T(),z=new Set(Z.tools??["bash"]);return async($)=>{let Q=$.revisedArgs??$.args,X=z.has($.tool)&&typeof Q==="object"&&Q!==null&&typeof Q.command==="string"?String(Q.command):null;if(X===null)return j?j($):"deny";let G=f(X,J);if(G.effect==="allow")return"once";if(G.effect==="deny")return"deny";if(!j)return"deny";return j(G.reason!==void 0?{...$,reason:G.reason}:$)}}
9
+ export{O as Jd,T as Kd,l as Ld};
@@ -0,0 +1,5 @@
1
+ // @bun
2
+ import{Xi as O,Yi as S,cj as b}from"./main-sdmxhtv8.js";import{kk as X,uk as _}from"./main-8kjxbpw4.js";import{$m as m,Um as h,_m as A}from"./main-2yeveeve.js";m();_();var w=3,D="usage: rovecode connect [<id> [<baseUrl>]] [--model <id>] [--key | --key-stdin | --key-env NAME | --no-key] [--protocol openai|anthropic] [--project] [--no-test]";function y(j){let z=[],q,M,P,Z="auto",Q="user",R=!0,Y=[];for(let V=0;V<j.length;V++){let B=j[V],W=()=>{let H=j[V+1];if(H===void 0||H.startsWith("-"))return;return V++,H};switch(B){case"--model":{let H=W();if(H===void 0)return{error:`--model needs a value \u2014 ${D}`};q=H;break}case"--key-env":{let H=W();if(H===void 0)return{error:`--key-env needs a value \u2014 ${D}`};P=H,Y.push(B);break}case"--protocol":{let H=W();if(H!=="openai"&&H!=="anthropic")return{error:`--protocol takes openai or anthropic \u2014 ${D}`};M=H;break}case"--key":Z="prompt",Y.push(B);break;case"--key-stdin":Z="stdin",Y.push(B);break;case"--no-key":Z="none",Y.push(B);break;case"--project":Q="project";break;case"--no-test":R=!1;break;default:if(B.startsWith("-"))return{error:`unknown flag ${B} \u2014 ${D}`};z.push(B)}}if(Y.length>1)return{error:`${Y.join(" and ")} contradict each other \u2014 pick one`};if(z.length===0)return{error:`connect needs a provider id \u2014 ${D}`};if(z.length>2)return{error:`unexpected argument "${z[2]}" \u2014 ${D}`};let $=z[0].toLowerCase();if(!O.test($))return{error:`"${$}" won't work as an id (letters, digits, - _ .)`};let L=z[1];if(L!==void 0&&!/^https?:\/\//.test(L))return{error:`"${L}" is not an http(s) URL \u2014 ${D}`};if(L===void 0&&M!==void 0)return{error:"--protocol only applies when you give a base URL"};return{id:$,...L!==void 0?{baseUrl:L}:{},...q!==void 0?{model:q}:{},...M!==void 0?{protocol:M}:{},...P!==void 0?{keyEnv:P}:{},key:Z,scope:Q,test:R}}async function x(){let j=[];for await(let z of process.stdin)j.push(z);return Buffer.concat(j).toString("utf8")}async function C(j,z){let q=z.out??console.log,M=z.secret??((J)=>A(J)),P=z.stdin??x,Z=z.save??h,Q=z.registry,R=z.probe??((J,f)=>Q.probe(J,f)),Y=z.tty??process.stdin.isTTY===!0,$=z.where==="tui",L=Q.get(j.id),V=j.key==="none"||j.keyEnv!==void 0;if(j.baseUrl!==void 0||V){let J=j.baseUrl??L?.baseUrl;if(J===void 0)return q(`\u25C6 I don't know a provider called "${j.id}".`),q(` known: ${Q.ids().join(" ")}`),q(` ${X(`rovecode connect ${j.id} <baseUrl>`)} to register your own endpoint`),2;let f=j.protocol??L?.protocol??S(J),G=j.model??L?.defaultModel,T={id:j.id,baseUrl:J,protocol:f,...j.keyEnv!==void 0?{keyEnv:j.keyEnv}:L?.keyEnv!==void 0&&j.baseUrl===void 0?{keyEnv:L.keyEnv}:{},...G!==void 0?{defaultModel:G}:{},...j.key==="none"?{noKey:!0}:{}},K=Q.add(T,j.scope);if("error"in K)return q(`\u25C6 ${K.error}`),q(` ${X("rovecode connect")} for the step-by-step version`),2;q(`\u25C6 ${K.id} registered (${K.protocol} protocol, ${K.baseUrl}${j.key==="none"?", no key":""}).`)}else if(L===void 0)return q(`\u25C6 I don't know a provider called "${j.id}".`),q(` known: ${Q.ids().join(" ")}`),q(` ${X(`rovecode connect ${j.id} <baseUrl>`)} to register your own endpoint`),2;let B=Q.get(j.id);if(B===void 0)return q(`\u25C6 ${j.id} did not survive registration \u2014 that is a bug.`),2;let W=b(B);if(!W||j.key==="prompt"||j.key==="stdin")if(j.key==="stdin"){let J=(await P()).split(`
3
+ `)[0].trim();if(J.length===0)return q("\u25C6 nothing came in on stdin \u2014 no key stored."),q(` ${X(`echo $KEY | rovecode connect ${j.id} --key-stdin`)}`),2;Z(j.id,J,B.keyEnv),q(`\u25C6 key stored for ${j.id} (hidden; ~/.rovecode/credentials.json).`),W=!0}else if(j.key==="prompt"||j.key==="auto"&&Y){let J=(await M(`${B.keyEnv} (hidden): `)).trim();if(J.length===0)return q(`\u25C6 no key stored \u2014 I can't call ${j.id} without one.`),q(` ${X(`rovecode auth set ${j.id}`)} (or set ${B.keyEnv} in your environment)`),2;Z(j.id,J,B.keyEnv),q(`\u25C6 key stored for ${j.id} (hidden; ~/.rovecode/credentials.json).`),W=!0}else if(z.deferKey!==void 0)return z.deferKey(B),w;else return q(`\u25C6 ${j.id} has no key, and there is no terminal to ask on.`),q(` ${X(`set ${B.keyEnv}, or pipe it: echo $KEY | rovecode connect ${j.id} --key-stdin`)}`),2;else q(B.noKey===!0?`\u25C6 ${j.id} needs no key (local server).`:`\u25C6 ${j.id} already has a key (${B.keySource==="stored"?"stored":`env ${B.keyEnv}`}).`);Q.refresh();let H=j.model??Q.get(j.id)?.defaultModel;if(H===void 0)return q(`\u25C6 ${j.id} is connected but has no model yet.`),q(` ${X($?`/models ${j.id}, then /model ${j.id}/<model> --save`:`rovecode model list ${j.id}, then rovecode model use ${j.id}/<model>`)}`),0;let F=!0;if(j.test){q(`\u25C6 testing ${j.id}/${H} \u2026`);let J=await R(j.id,H);F=J.ok,q(` ${J.detail}`)}let I=Q.setDefault(`${j.id}/${H}`,j.scope);if("error"in I)return q(`\u25C6 ${I.error}`),q(` ${X(`rovecode model use ${j.id}/<model>`)}`),2;if(q(`\u25C6 default \u2192 ${I.provider}/${I.model} (${$?"this session switched too":"running TUIs switch live"}).`),!F)return q(` ${X(`check the key and the URL, then ${$?"/provider":"rovecode provider"} test ${j.id} ${H}`)}`),1;return q(""),q(z.done??`Done. Try: rovecode "explain this repo"
4
+ or open the cockpit: rovecode`),0}
5
+ export{w as Aa,D as Ba,y as Ca,C as Da};
@@ -0,0 +1,7 @@
1
+ // @bun
2
+ import{He as X,Je as E,Me as U,Oe as P,Te as M}from"./main-rdgdw24b.js";import{Ue as V,Xe as b}from"./main-3pjrb2hd.js";M();b();E();var y=60000,D=600000,R="You will be notified in this conversation when it finishes \u2014 do NOT poll or sleep: "+"continue other non-overlapping work or end your turn. Use `task_status result` to wait for it when you need its output.",W="In a one-shot run (`rovecode run`) background tasks do not outlive the run: collect what you need with `task_status result` before ending your turn.",Q=(j)=>({ok:!1,output:`Error: ${j}`}),G=(j,B)=>Q(`${j} ${B} requires a string \`id\` (see \`task_status list\`)`);function x(j,B){let C=j.startedAt!==void 0?Math.max(0,Math.round(((j.finishedAt??B)-j.startedAt)/1000)):0,K=j.usage?`, tokens ${j.usage.input}in/${j.usage.output}out`:"";return`task ${j.id} (${j.label}) ${j.status} \u2014 agent ${j.agent}, ${j.isolated?"isolated, ":""}${C}s${K}`}function S(j,B){let C=x(j,B);if(j.status==="done"){let K=j.patchLines!==void 0?`
3
+ [isolated: ${j.patchLines===0?"no file changes":`patch of ${j.patchLines} lines merged back`}]`:"",Y=j.kind==="external"?`
4
+ [external ${j.agent} lane \u2014 permissions: ${j.permissions??"(unknown)"}${j.laneExit!==void 0?`; exit ${j.laneExit}`:""}${j.laneModel?`; model ${j.laneModel}`:""}]`:"";return{ok:!0,output:`${C}${Y}${K}
5
+ ${j.summary??"(no output)"}`,data:j}}if(j.status==="failed")return{ok:!1,output:`${C}
6
+ ${j.error??"unknown error"}`,data:j};if(j.status==="cancelled")return{ok:!1,output:C,data:j};return{ok:!0,output:`${C}. ${R}`,data:j}}function g(j){if(j===void 0||j===null)return y;let B=typeof j==="number"?j:typeof j==="string"&&j.trim()!==""?Number(j):NaN;if(!Number.isFinite(B))return{error:`task_status result: \`timeout_ms\` must be a number of milliseconds (got ${JSON.stringify(j)??String(j)})`};return Math.min(D,Math.max(0,Math.floor(B)))}function h(j,B={}){let C=B.defaultAgent??"main",K=(B.agents??[]).filter((q)=>q.name!==C),Y=(q)=>q.length>120?q.slice(0,119)+"\u2026":q,H=K.length>0?`Custom agent definitions (.rovecode/agents/<name>.md \u2014 own system prompt, model, mode and tool allow-list): ${K.map((q)=>`${q.name} \u2014 ${Y(q.description)}`).join("; ")}. `:"";return{schema:{name:"task",description:"Run subagents as background tasks. `start` launches a child agent session on `goal` and returns at once with a task id; the child works while you continue, and a note lands in this conversation when it finishes (do not poll). Read its state or output with the `task_status` tool (status/result/list "+"\u2014 never prompts); `cancel` aborts a task. Children see only `goal` (write it self-contained). "+`At most ${j.maxConcurrent} run concurrently; extra starts queue FIFO \u2014 so for independent parts of a `+"wider request, issue their starts together in one turn and they run side by side while you keep the dependent steps. `isolated` runs the child in a git worktree copy and merges its file changes back as a patch on success. "+`\`agent\` may also name an EXTERNAL agentic-CLI lane \u2014 ${V.join(" | ")} \u2014 which runs \`goal\` in that CLI `+`instead of in one of our agents. A lane always works in its own worktree, its diff merges back like any isolated child, and it runs with the flags stated on the approval card. Lanes are OFF unless ${X} lists the id. Policy: under gated rules each \`start\` needs approval and the child runs read-only (prompt-gated actions are denied for children) unless allow rules cover them; under yolo it inherits allow-all. `+H+W,args:{type:"object",properties:{action:{type:"string",enum:["start","cancel"]},goal:{type:"string",description:"start: the child's task, self-contained (it has no access to this conversation)"},agent:{type:"string",description:`start: agent definition to run (default "${C}"${K.length>0?`; custom: ${K.map((q)=>q.name).join(", ")}`:""}), or an external CLI lane: ${V.join(" | ")} (needs ${X})`},isolated:{type:"boolean",description:"start: run in an isolated worktree copy; file changes merge back as a patch when the task finishes ok"},label:{type:"string",description:"start: short label (3-5 words) shown in task lists and completion notes"},id:{type:"string",description:"cancel: task id (e.g. t1)"}},required:["action"]}},kind:"spawn",sequential:!0,async execute(q){let z=q??{},J=typeof z.id==="string"?z.id.trim():"";switch(z.action){case"start":{if(typeof z.goal!=="string"||z.goal.trim()==="")return Q("task start requires a non-empty string `goal`");let F=typeof z.agent==="string"&&z.agent.trim()!==""?z.agent.trim():C,Z=j.start({agent:F,goal:z.goal,isolated:z.isolated===!0,background:!0},{label:typeof z.label==="string"?z.label:void 0,parentDepth:B.parentDepth??0,notify:B.notify,caller:B.caller,owner:B.owner,...B.parentTools?{parentTools:B.parentTools()}:{},...B.parentDir!==void 0?{parentDir:B.parentDir}:{}});if(!Z.ok)return Q(`task refused: ${Z.reason}`);let $=j.status(Z.id),f=$.status==="running"?"running":`queued (${j.counts().running} running, bound ${j.maxConcurrent})`,I=$.kind==="external"?`External ${$.agent} lane \u2014 permissions: ${$.permissions??"(unknown)"}; its worktree patch merges back when it finishes ok.`:Z.childPolicy==="gated"?"Policy: gated \u2014 the child runs read-only (prompt-gated actions are DENIED for children) unless allow rules cover them.":"Policy: the child inherits your allow rules.";return{ok:!0,output:`task ${$.id} (${$.label}) started: ${f}. ${I} ${R}`,data:$}}case"cancel":{if(J==="")return G("task","cancel");let F=j.status(J);if(!F)return Q(`unknown task '${J}'`);if(U(F.status))return{ok:!0,output:`task ${J} already ${F.status}`,data:F};let Z=j.cancel(J);return{ok:!0,output:`task ${Z.id} (${Z.label}) cancelled`,data:Z}}default:return Q(`task requires action start|cancel (got ${JSON.stringify(z.action??null)}); status|result|list live on task_status`)}}}}function L(j,B={}){return{schema:{name:"task_status",description:"Read background tasks started with `task` (never prompts, never mutates). `status` shows one task's state; `result` waits (bounded by `timeout_ms`, default 60s) for a task to finish and returns the "+"child's final output \u2014 call it when you need the output, otherwise wait for the completion note; "+"`list` shows every task. "+W,args:{type:"object",properties:{action:{type:"string",enum:["status","result","list"]},id:{type:"string",description:"status/result: task id (e.g. t1)"},timeout_ms:{type:"integer",description:`result: max wait in ms (default ${y}, max ${D}); 0 = report the current state at once`}},required:["action"]}},kind:"read",sequential:!0,async execute(C,K){let Y=C??{},H=Date.now(),q=typeof Y.id==="string"?Y.id.trim():"";switch(Y.action){case"status":{if(q==="")return G("task_status","status");let z=j.status(q);return z?{ok:!0,output:x(z,H),data:z}:Q(`unknown task '${q}'`)}case"result":{if(q==="")return G("task_status","result");if(!j.status(q))return Q(`unknown task '${q}'`);let z=g(Y.timeout_ms);if(typeof z!=="number")return Q(z.error);let J=await j.result(q,{timeoutMs:z,signal:K.signal,caller:B.caller});if(!J)return Q(`unknown task '${q}'`);if(!U(J.status)&&K.signal.aborted)return Q(`wait for task ${q} aborted`);if(!U(J.status))return{ok:!0,output:`${x(J,Date.now())} \u2014 still running after ${Math.round(z/1000)}s. ${R}`,data:J};return S(J,Date.now())}case"list":return{ok:!0,output:P(j.list(),H),data:j.counts()};default:return Q(`task_status requires action status|result|list (got ${JSON.stringify(Y.action??null)}); start|cancel live on task`)}}}}
7
+ export{y as de,D as ee,h as fe,L as ge};
@@ -0,0 +1,5 @@
1
+ // @bun
2
+ import{m as Hz,n as Wz,o as g,p as kz}from"./main-f7rw7des.js";import{T as O,U as T,W as b,Y as gz}from"./main-yr0ksc0h.js";import{$ as Yz,_ as y,aa as Zz,ba as $z,ca as Gz,da as Kz,ga as Vz,ha as Lz}from"./main-xy53xf0r.js";import{ka as Qz,la as Uz,qa as Iz}from"./main-7c5thhjd.js";import{vd as x,yd as Bz}from"./main-0ab9fc26.js";import{Hd as m,Id as Cz}from"./main-6dnk69vp.js";import{Sd as Jz,Wd as xz}from"./main-pn1w7a7j.js";import{Eh as i,Fh as Pz,Gh as s,Jh as t,Kh as e,Lh as zz,Ph as jz}from"./main-kcpbykxz.js";import{Sj as j,Yj as _z}from"./main-q3vsesf9.js";import{Dm as u,Fm as Fz,ym as S}from"./main-7rn6bqje.js";import{wn as R}from"./main-qsevpgsv.js";function Dz(z){return/allow.*sha1.*in.?want|not our ref|unadvertised object|Server does not allow request for unadvertised object/i.test(z)}async function f(z,J,Q,U){if(U===void 0||U.trim()===""){let V=await z(["git","clone","--depth","1","--quiet","--",J,"."],Q);return V.code===0?{ok:!0,resolvedBy:"default"}:{ok:!1,error:`git clone failed (exit ${V.code})${D(V.stderr)?`: ${D(V.stderr)}`:""}`}}if((await z(["git","clone","--depth","1","--quiet","--branch",U,"--",J,"."],Q)).code===0)return{ok:!0,resolvedBy:"branch"};let Y=await z(["git","init","--quiet"],Q);if(Y.code!==0)return{ok:!1,error:`git init failed (exit ${Y.code})${D(Y.stderr)?`: ${D(Y.stderr)}`:""}`};let $=await z(["git","fetch","--depth","1","--quiet","--",J,U],Q);if($.code!==0){if(Dz($.stderr))return{ok:!1,error:`${J} will not serve the single commit ${U} (the server has uploadpack.allowReachableSHA1InWant off) \u2014 give a branch or tag instead, or ask the host to enable it`};return{ok:!1,error:`"${U}" is not a branch or tag there, and fetching it as a commit failed (exit ${$.code})${D($.stderr)?`: ${D($.stderr)}`:""}`}}let G=await z(["git","checkout","--quiet","FETCH_HEAD"],Q);if(G.code!==0)return{ok:!1,error:`fetched ${U} but could not check it out (exit ${G.code})${D(G.stderr)?`: ${D(G.stderr)}`:""}`};return{ok:!0,resolvedBy:"commit"}}var D=(z)=>z.trim().split(`
3
+ `).at(-1)?.trim()??"";var h=()=>{};function d(z,J={}){let Q=z.install;if(Q.kind==="mcp")return{perTurn:0,tokenizer:"o200k_base",unknown:"an MCP server's tools are only known once it connects, so its context cost cannot be measured before you install it"};if(Q.kind==="skill"){let U=z.docs?.body,Z={perTurn:j(Mz(z)),tokenizer:"o200k_base"};if(J.model!==void 0)Z.scale=m(J.model);if(U!==void 0)Z.whenUsed=j(U);else Z.unknown="the SKILL.md is not carried in the catalog, so only the index line can be measured here";let Y=J.installedSkills;if(Y!==void 0&&Y+1>x)Z.overIndexLimit=!0;return Z}return{perTurn:0,tokenizer:"o200k_base",unknown:"a plugin's context cost cannot be measured from the catalog: its tools need the code loaded to read, and its commands and skills are files that are only fetched when you install it"}}function a(z){if(z===void 0)return[];let J=[];if(z.perTurn>0||z.whenUsed!==void 0){let Q=z.scale?.measured===!0?z.scale.scale:1,U=`~${c(Math.round(z.perTurn*Q))} tokens every turn`,Z=z.whenUsed!==void 0?`, ~${c(Math.round(z.whenUsed*Q))} more when the model opens it`:"";if(J.push(`${U}${Z}`),z.scale===void 0)J.push("counted with o200k_base, which is not every model's tokenizer \u2014 unscaled here because no model was named");else if(!z.scale.measured)J.push(`counted with o200k_base \u2014 ${z.scale.note}`);else if(Q===1)J.push(`counted with o200k_base \u2014 ${z.scale.note}`);else J.push(`o200k_base scaled ${Q}\xD7 for this model \u2014 ${z.scale.note}`)}if(z.overIndexLimit)J.push(`past ${x} skills the index leaves the prompt entirely and the model lists skills with a tool instead \u2014 this changes the cost of every skill you have, not just this one`);if(z.unknown!==void 0)J.push(z.unknown);return J}var Mz=(z)=>`- ${z.id}${z.version?` (v${z.version})`:""}: ${z.description}`,c=(z)=>z>=1000?`${(z/1000).toFixed(1)}k`:String(z);var p=R(()=>{Cz();_z();Bz()});import{createHash as Nz}from"crypto";import{existsSync as Rz,readdirSync as qz,readFileSync as r,statSync as l}from"fs";import{join as n,relative as Oz,sep as Tz}from"path";function bz(z){let J=[],Q=[z];while(Q.length>0){let U=Q.pop(),Z;try{Z=qz(U)}catch{continue}for(let Y of Z){if(Y===".git")continue;let $=n(U,Y),G;try{G=l($)}catch{continue}if(G.isDirectory()){Q.push($);continue}if(G.isFile())J.push(Oz(z,$).split(Tz).join("/"))}}return J.sort()}function q(z){if(!Rz(z))return;let J=Nz("sha256"),Q=0;try{if(l(z).isFile())J.update(r(z)),Q=1;else for(let U of bz(z))J.update(U),J.update("\x00"),J.update(r(n(z,U))),J.update("\x00"),Q+=1}catch{return}return{algo:"sha256",value:J.digest("hex"),files:Q}}function VJ(z,J){if(J===void 0)return{state:"not-applicable",why:"this kind of install has no folder of its own to hash"};let Q=q(J);if(z===void 0)return Q===void 0?{state:"unrecorded"}:{state:"unrecorded",now:Q};if(Q===void 0)return{state:"missing",recorded:z};return Q.value===z.value?{state:"unchanged",digest:Q}:{state:"changed",recorded:z,now:Q}}function HJ(z,J){switch(J.state){case"unchanged":return`${z} unchanged (${J.digest.files} file${J.digest.files===1?"":"s"})`;case"changed":return`${z} CHANGED since install \u2014 recorded ${J.recorded.value.slice(0,12)} (${J.recorded.files} files), now ${J.now.value.slice(0,12)} (${J.now.files} files)`;case"missing":return`${z} gone from disk, but a record remains`;case"unrecorded":return`${z} no digest recorded \u2014 installed before rovecode kept one, or by hand`;case"not-applicable":return`${z} ${J.why}`}}var o=()=>{};import{cpSync as vz,existsSync as E,lstatSync as Sz,mkdirSync as k,mkdtempSync as v,readdirSync as uz,readFileSync as F,renameSync as Xz,rmSync as C,writeFileSync as yz}from"fs";import{tmpdir as wz}from"os";import{dirname as N,join as X,sep as Az,resolve as M}from"path";function hz(z){return fz.test(z)&&z!=="."&&z!==".."}function cz(z,J){if(J.local===!0&&z.install.kind==="mcp"){let U=["npm","node"].map((Z)=>g(Hz(Z,J.prereqEnv))).filter((Z)=>Z!==void 0);return U.length===0?[]:[` requires ${U.join(" \xB7 ")}`]}let Q=g(Wz(z,J.prereqEnv));return Q===void 0?[]:[` requires ${Q}`]}function dz(z,J){let Q=0;for(let U of[X(J,"skills"),X(z,".rovecode","skills")]){if(!E(U))continue;try{for(let Z of uz(U))if(E(X(U,Z,"SKILL.md")))Q+=1}catch{}}return Q}function az(z,J){let Q=dz(J.cwd,J.home),U=d(z,{installedSkills:Q,...J.model?{model:J.model}:{}}),Z=a(U);return Z.length===0?[]:Z.map((Y,$)=>$===0?` context ${Y}`:` ${Y}`)}function pz(z,J,Q){let U=[...cz(J,Q),...az(J,Q)];if(U.length===0)return z;let Z=z.findIndex(($)=>/^ {2}(runs|connects) {3,}/.test($)),Y=Z>=0?Z:z.findIndex(($)=>/^ {2}source {3,}/.test($));return Y<0?[...z,...U]:[...z.slice(0,Y+1),...U,...z.slice(Y+1)]}function Ez(z,J){let Q=J.scope==="project"?X(J.cwd,".rovecode","skills"):X(J.home,"skills"),U=X(Q,z);if(!M(U).startsWith(M(Q)+Az))throw Error(`"${z}" is not a usable skill name`);return U}function rz(z){let J=z.status;if(J===void 0||J==="")return[];return[` ! ${J==="archived"?"archived on GitHub \u2014 the publisher has stopped maintaining it":J==="deprecated"?"marked deprecated by its publisher":`marked "${J}" by its publisher`}. It still installs; nothing here is blocked.`]}function I(z,J,Q){return[...rz(J),...pz(z,J,Q)]}function FJ(z,J){let{install:Q}=z;if(J.ref!==void 0&&z.install.kind==="plugin")return{error:"--ref is not wired for plugins yet \u2014 it would be accepted and ignored, which is worse than not having it"};if(J.ref!==void 0&&z.install.kind==="mcp")return{error:"--ref applies to something that is cloned; an MCP entry is a config line, and its package version belongs in the entry itself"};if(J.as!==void 0&&!hz(J.as))return{error:`"${J.as}" is not a usable name \u2014 letters, digits, dot, dash and underscore only, and it must not be a path`};if(Q.kind==="mcp"){let G=y(Q.entry,{scope:J.scope,cwd:J.cwd,home:J.home,...J.pick!==void 0?{pick:J.pick}:{},...J.as!==void 0?{name:J.as}:{},...J.local!==void 0?{local:J.local}:{}});if("error"in G)return G;let V={item:z,target:G.file,scope:J.scope,preview:[...I($z(G,J.scope==="project"?"env":"prompt").filter((H)=>!mz.test(H)),z,J),...z.planNote??[]],asks:G.asks.map((H)=>({...H})),pending:[...G.pending]};if(tz(J.cwd,J.home,J.scope).includes(G.name))V.replaces=`${G.name} in ${G.file}`;return V}let U=J.as??z.id;if(Q.kind==="plugin"){if(J.as!==void 0)return{error:"--as does not apply to a plugin: it installs under the name in its own manifest"};let G=X(t(J.scope,J.cwd,J.home),z.id),V=[`${z.title}${z.version?` ${z.version}`:""}`," kind plugin \u2014 a folder of CODE that rovecode loads and RUNS in this process",` source ${Q.git?`git clone --depth 1 ${Q.source}`:`copy of the folder ${Q.source}`}${Q.subfolder?` (subfolder ${Q.subfolder})`:""}`,` publisher ${z.publisher}`,...z.license?[` licence ${z.license}`]:[],...z.repository?[` repo ${z.repository}`]:[],` writes ${G}${Q.git?" (the folder is named by the plugin's manifest; this is the expected name)":""}`,J.scope==="project"?" trust installed into this repo \u2014 approving here records this exact content as trusted on this machine":" trust user scope (~/.rovecode/plugins): loaded in every project you open"," a plugin can add tools, hooks, commands, skills and MCP servers. Install one only from a publisher you trust.",...z.planNote??[]];return{item:z,target:G,scope:J.scope,preview:I(V,z,J),asks:z.env.map((K)=>({...K})),pending:[],...E(G)?{replaces:G}:{}}}let Z=Ez(U,J),Y=Q.files??[];if(Q.source===void 0&&!Y.some((G)=>G.path.replace(/\\/g,"/").toLowerCase()==="skill.md"))return{error:`${z.id} carries no SKILL.md \u2014 a skill is a folder with a SKILL.md, and rovecode would never see this one`};let $=[`${z.title}${z.version?` ${z.version}`:""}`," kind skill \u2014 instructions the model reads. Files only: nothing here is executed on install.",Q.source?` source git clone --depth 1 ${Q.source.git}${Q.source.subfolder?` (subfolder ${Q.source.subfolder})`:""}`:` source ${Y.length} file${Y.length===1?"":"s"} from rovecode's catalog`,` publisher ${z.publisher}`,...z.license?[` licence ${z.license}`]:[],...z.repository?[` repo ${z.repository}`]:[],` writes ${Z}`,...Y.slice(0,8).map((G)=>` ${G.path}`),...Y.length>8?[` \u2026 and ${Y.length-8} more`]:[],...z.planNote??[]];return{item:z,target:Z,scope:J.scope,preview:I($,z,J),asks:z.env.map((G)=>({...G})),pending:[],...E(Z)?{replaces:Z}:{}}}async function PJ(z,J,Q,U={}){let{item:Z}=z,{install:Y}=Z;try{if(Y.kind==="mcp"){let K=y(Y.entry,{scope:Q.scope,cwd:Q.cwd,home:Q.home,...Q.pick!==void 0?{pick:Q.pick}:{},...Q.as!==void 0?{name:Q.as}:{},...Q.local!==void 0?{local:Q.local}:{}});if("error"in K)return{ok:!1,error:K.error};let H,W;if(K.local){if(U.offline===!0)return{ok:!1,error:`--offline: installing ${K.local.pkg.spec} once means npm fetching it now; drop --local to write the npx line, which fetches at launch instead`};let A=await Qz(K.local.pkg,K.local.prefix,U.spawn?{spawn:U.spawn}:{});if(!A.ok)return{ok:!1,error:A.error};H=Uz(A.pkg,K.local.pkg.rest),W={name:A.pkg.name,version:A.pkg.version,prefix:K.local.prefix,bin:A.pkg.bin,...A.pkg.integrity!==void 0?{integrity:A.pkg.integrity}:{},...A.pkg.missing.length>0?{missing:A.pkg.missing}:{}}}let _=Yz(K,J,H),P=Gz(K.file,K.name,_,{...U.force===!0?{replace:!0}:{},...Q.scope==="project"?{trustHome:Q.home}:{}});O(b(Z,{scope:Q.scope,target:K.file,...W?{package:{...W,missing:W.missing??[]}}:{}}),{cwd:Q.cwd,home:Q.home,stillInstalled:L(Q.cwd,Q.home)});let B=Vz(K,_);return{ok:!0,item:Z,target:K.file,scope:Q.scope,envNames:Zz(K,_),...P.trusted!==void 0?{trusted:P.trusted}:{},...W?{package:W}:{},...B.length?{fillIn:B}:{},next:B.length?`fill in before use: ${B.join(", ")} \u2014 edit the args in ${K.file}; until then this server is skipped`:"restart rovecode to connect \u2014 MCP servers are read once per process (a session that installs from /market connects it on the spot)"}}if(U.offline===!0&&nz(Y))return{ok:!1,error:`--offline: ${Z.id} would have to be fetched (${oz(Y)}) and nothing local can stand in for it`};if(Y.kind==="plugin"){let K=await e(Y.source,{cwd:Q.cwd,home:Q.home,scope:Q.scope,...U.force===!0?{force:!0}:{},...U.spawn?{spawn:U.spawn}:{},...Y.subfolder!==void 0?{subfolder:Y.subfolder}:{},...U.cloneCache!==void 0?{cloneCache:U.cloneCache}:{}});if(!K.ok)return{ok:!1,error:K.error};return O(b(Z,{scope:Q.scope,target:K.dir,...(()=>{let H=q(K.dir);return H?{digest:H}:{}})(),...Y.git?{git:{source:Y.source}}:{}}),{cwd:Q.cwd,home:Q.home,stillInstalled:L(Q.cwd,Q.home)}),{ok:!0,item:Z,target:K.dir,scope:Q.scope,envNames:Z.env.filter((H)=>H.required).map((H)=>H.name),...Q.scope==="project"?{trusted:!0}:{},next:"restart rovecode \u2014 plugins are loaded once at startup"}}let $=z.target;if(E($)&&U.force!==!0)return{ok:!1,error:`${$} already exists (use --force to replace)`};let G,V;if(Y.source){let K=await sz(Y.source,$,U,Q.ref);if(!K.ok)return{ok:!1,error:K.error};G=K.sha,V=K.resolvedBy}else{k(N($),{recursive:!0});let K=v(X(N($),`.rovecode-skill-${Z.id}-`));try{for(let H of Y.files??[]){let W=X(K,H.path);if(!M(W).startsWith(M(K)+Az))return{ok:!1,error:`${H.path} escapes the skill's folder`};k(N(W),{recursive:!0}),yz(W,H.text)}if(E($))C($,{recursive:!0,force:!0});Xz(K,$)}finally{C(K,{recursive:!0,force:!0})}}return O(b(Z,{scope:Q.scope,target:$,...(()=>{let K=q($);return K?{digest:K}:{}})(),...Y.source?{git:{source:Y.source.git,...G!==void 0?{sha:G}:{},...Q.ref!==void 0?{ref:Q.ref}:{},...V!==void 0?{resolvedBy:V}:{}}}:{}}),{cwd:Q.cwd,home:Q.home,stillInstalled:L(Q.cwd,Q.home)}),{ok:!0,item:Z,target:$,scope:Q.scope,envNames:[],next:"restart rovecode \u2014 skills are indexed at startup"}}catch($){return{ok:!1,error:$ instanceof Error?$.message:String($)}}}function L(z,J){return(Q)=>w({kind:Q.kind,id:Q.id},z,J,Q.scope)!==void 0}function lz(z){try{let J=F(X(z,".git","HEAD"),"utf8").trim(),Q=/^ref:\s*(.+)$/.exec(J)?.[1];if(Q===void 0)return/^[0-9a-f]{40}$/i.test(J)?J:void 0;let U=X(z,".git",...Q.split("/"));if(E(U)){let Y=F(U,"utf8").trim();return/^[0-9a-f]{40}$/i.test(Y)?Y:void 0}let Z=X(z,".git","packed-refs");if(!E(Z))return;for(let Y of F(Z,"utf8").split(`
4
+ `)){let $=/^([0-9a-f]{40})\s+(.+)$/i.exec(Y.trim());if($&&$[2]===Q)return $[1]}return}catch{return}}function nz(z){if(z.kind==="plugin")return z.git;if(z.kind==="skill")return z.source!==void 0;return!1}function oz(z){if(z.kind==="plugin")return z.source;if(z.kind==="skill")return z.source?.git??"its catalog files";return"an mcp.json entry"}function iz(z){try{return Sz(z).isSymbolicLink()}catch{return!0}}async function sz(z,J,Q,U){let Z,Y=Q.spawn??(async(K,H)=>{let W=Bun.spawn(K,{cwd:H,stdout:"ignore",stderr:"pipe",stdin:"ignore"});return{code:await W.exited,stderr:await new Response(W.stderr).text()}}),$=Q.copy??((K,H,W)=>vz(K,H,{recursive:!0,filter:W})),G=s(z.git,U),V=null;try{let K=Q.cloneCache?.get(G),H;if(K!==void 0)H=K;else{V=v(X(wz(),"rovecode-skill-"));let A=await f(Y,z.git,V,U);if(!A.ok)return{ok:!1,error:A.error};Z=A.resolvedBy,H=V}let W=z.subfolder?X(H,z.subfolder):H;if(!M(W).startsWith(M(H)))return{ok:!1,error:"subfolder escapes the clone"};if(!E(X(W,"SKILL.md")))return{ok:!1,error:`no SKILL.md in ${z.subfolder??"the repository root"} \u2014 a skill is a folder with a SKILL.md`};k(N(J),{recursive:!0});let _=v(X(N(J),".rovecode-clone-"));try{if($(W,_,(A)=>!/(?:^|[\\/])\.git(?:[\\/]|$)/.test(A)&&!iz(A)),E(J))C(J,{recursive:!0,force:!0});Xz(_,J)}finally{C(_,{recursive:!0,force:!0})}let B=(await Y(["git","rev-parse","HEAD"],H).catch(()=>({code:1,stderr:""}))).code===0?lz(H):void 0;if(V!==null&&Q.cloneCache!==void 0)Q.cloneCache.set(G,V),V=null;return{ok:!0,...B!==void 0?{sha:B}:{},...Z!==void 0?{resolvedBy:Z}:{}}}finally{if(V!==null)C(V,{recursive:!0,force:!0})}}function tz(z,J,Q){let U=S(z,J),Z=Q==="project"?U.project:U.user;if(Z===void 0||!E(Z))return[];let Y=new Proxy({},{get:()=>"set"});return u(Z,[],Y).map(($)=>$.name)}function w(z,J,Q,U){let Z=U?[U]:["project","user"];if(z.kind==="mcp"){let Y=S(J,Q),$={project:Y.project,user:Y.user};for(let G of Z){let V=$[G];if(V===void 0||!E(V))continue;let K=new Proxy({},{get:()=>"set"});if(u(V,[],K).find((W)=>W.name===z.id)){let W={path:V,scope:G};if(G==="project")W.trusted=Jz(Q,V)==="trusted";return W}}return}if(z.kind==="plugin"){let Y=i(J,{home:Q}).plugins.find((V)=>V.name===z.id&&(U===void 0||V.scope===U));if(!Y)return;let $={path:Y.dir,scope:Y.scope},G=Y.manifest?.version;if(G!==void 0){if($.version=G,z.version!==void 0&&z.version!==G)$.updateAvailable=!0}if(Y.scope==="project")$.trusted=Y.status!=="untrusted";return $}for(let Y of Z){let $=Ez(z.id,{scope:Y,cwd:J,home:Q});if(!E(X($,"SKILL.md")))continue;let G={path:$,scope:Y},V=ez(X($,"SKILL.md"));if(V!==void 0){if(G.version=V,z.version!==void 0&&z.version!==V)G.updateAvailable=!0}return G}return}function ez(z){try{let J=F(z,"utf8").slice(0,2000);return/^version:\s*(.+)$/m.exec(J)?.[1]?.trim().slice(0,64)}catch{return}}function jJ(z,J,Q){return z.map((U)=>{let Z=w(U,J,Q);return Z?{...U,installed:Z}:{...U}})}function xJ(z,J,Q,U){let Z=w(z,J,Q,U);if(Z===void 0)return{ok:!1,error:`${z.kind} "${z.id}" is not installed here${U?` in ${U} scope`:""}`};if(z.kind==="mcp"){let Y=Kz(Z.path,z.id,{trustHome:Q});if(Y)T(z.kind,z.id,Z.scope,{cwd:J,home:Q});return Y?{ok:!0,path:Z.path}:{ok:!1,error:`no server "${z.id}" in ${Z.path}`}}if(z.kind==="plugin"){let Y=zz(z.id,{cwd:J,home:Q,scope:Z.scope});if(Y.ok)T(z.kind,z.id,Z.scope,{cwd:J,home:Q});return Y.ok?{ok:!0,path:Y.dir}:{ok:!1,error:Y.error}}return C(Z.path,{recursive:!0,force:!0}),T(z.kind,z.id,Z.scope,{cwd:J,home:Q}),{ok:!0,path:Z.path}}var fz,mz;var zJ=R(()=>{Lz();Fz();xz();jz();Pz();kz();Iz();gz();h();p();o();fz=/^[a-z0-9][a-z0-9._-]{0,63}$/i;mz=/^ {2}needs {6}/});
5
+ export{VJ as a,HJ as b,o as c,hz as d,Ez as e,FJ as f,PJ as g,nz as h,w as i,jJ as j,xJ as k,zJ as l};
@@ -0,0 +1,6 @@
1
+ // @bun
2
+ import{pn as Z,tn as $}from"./main-nqveez48.js";$();import{existsSync as z,mkdirSync as D,mkdtempSync as G,readdirSync as H,rmSync as P,writeFileSync as U}from"fs";import{tmpdir as V}from"os";import{dirname as W,join as Y}from"path";var X="rovecode-gauntlet-";function _(){return G(Y(V(),X))}function A(B){try{return new Set(H(B).map((J)=>Y(B,J)))}catch{return new Set}}var x=(B)=>P(B,{recursive:!0,force:!0});function E(B,J={}){let K=Math.max(1,J.attempts??3),q=J.rm??x,C="";for(let M=0;M<K;M++){try{q(B)}catch(Q){C=Q instanceof Error?Q.message:String(Q)}if(!z(B))return null;if(M+1<K)Bun.sleepSync(J.pauseMs??100)}return`gauntlet root not removed after ${K} attempt${K===1?"":"s"} (busy?): ${B}${C?` \u2014 ${C}`:""}`}async function F(B,J){let K={};for(let q of Object.keys(B))K[q]=process.env[q];for(let[q,C]of Object.entries(B))if(C===void 0)delete process.env[q];else process.env[q]=C;try{return await J()}finally{for(let[q,C]of Object.entries(K))if(C===void 0)delete process.env[q];else process.env[q]=C}}function R(B){return{ROVECODE_HOME:B,ROVECODE_NO_REPOMAP:"1",ROVECODE_NO_CHECKPOINTS:"1",ROVECODE_NO_HOOKS:void 0}}function j(B,J,K){let q=Y(B,".rovecode","hooks.ts");D(W(q),{recursive:!0}),U(q,`export default { version: 1, hooks: {
3
+ ${K}
4
+ } };
5
+ `);let C=Z(J,q);if(!C.ok)throw Error(`gauntlet: could not trust ${q}: ${C.reason}`);return q}
6
+ export{_ as Dk,A as Ek,E as Fk,F as Gk,R as Hk,j as Ik};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ import{an as M,bn as K}from"./main-0jys2ccn.js";import{wn as V}from"./main-qsevpgsv.js";var U,x,j,A;var G=V(()=>{U={context:1e6,toolCall:!0,image:!0,cost:{input:1.25,output:2.5,cacheRead:0.2},source:"docs.x.ai May-15-2026 retirement: served by grok-4.3, billed at grok-4.3 rates (under 200k context)",checked:"2026-09-04 (fetched)"},x={xai:{"grok-4.6":{thresholdTokens:200000,mode:"per-request",above:{input:4,output:12,cacheRead:1},source:"docs.x.ai/developers/pricing \u2014 over 200k prompt tokens the whole request bills at the high rate",checked:"2026-09-05 (fetched)"},"grok-4.3":{thresholdTokens:200000,mode:"per-request",above:{input:2.5,output:5,cacheRead:0.4},source:"docs.x.ai/developers/pricing \u2014 over 200k prompt tokens the whole request bills at the high rate",checked:"2026-09-05 (fetched)"}},openai:{"gpt-5.4":{thresholdTokens:272000,mode:"per-request",above:{input:5,output:22.5,cacheRead:0.5},source:"developers.openai.com/api/docs/models/gpt-5.4 \u2014 >272K input tokens: 2x input, 1.5x output for the full session",checked:"2026-09-05 (fetched)"},"gpt-5.5":{thresholdTokens:272000,mode:"per-request",above:{input:10,output:45,cacheRead:1},source:"developers.openai.com/api/docs/models/gpt-5.5 \u2014 >272K input tokens: 2x input, 1.5x output for the full session",checked:"2026-09-05 (fetched)"}},google:{"gemini-3.1-pro-preview":{thresholdTokens:200000,mode:"per-request",above:{input:4,output:18},source:'ai.google.dev/gemini-api/docs/pricing \u2014 "$4.00, prompts > 200k tokens" / "$18.00, prompts > 200k"',checked:"2026-09-05 (fetched)"},"gemini-2.5-pro":{thresholdTokens:200000,mode:"per-request",above:{input:2.5,output:15},source:'ai.google.dev/gemini-api/docs/pricing \u2014 "$2.50, prompts > 200k tokens" / "$15.00, prompts > 200k"',checked:"2026-09-05 (fetched)"}}},j={google:{"gemini-3.8-flash":"promotional pricing through 2026-12-31: ai.google.dev/gemini-api/docs/pricing says it doubles to $1.50 in / $7.50 out starting 2027-01-01 (checked 2026-09-05)"},mistral:{"mistral-medium-latest":"mistral.ai/pricing/api publishes only `-latest` aliases and NO maximum output for any model \u2014 the catalog's maxOutput equalling the context window is filler, not a vendor figure (checked 2026-09-05)","mistral-medium-2604":"this dated id is not on mistral.ai/pricing/api, which lists only `-latest` aliases; the price matches mistral-medium-latest but the id itself is unverified (checked 2026-09-05)"},groq:{"llama-3.3-70b-versatile":`Groq does not publish a price for this model \u2014 its docs table says "Contact Sales" and there is no public pricing page; the catalog's figure is models.dev's, not the vendor's (checked 2026-09-05)`},anthropic:{"claude-mythos-5-1":"invite-only access (platform.claude.com/docs/en/models/mythos-5-1/overview); outside the Batches 300k beta, which covers Opus 5/4.8/4.7/4.6 and Sonnet 5/4.6 only (checked 2026-09-05)","claude-fable-5-1":"outside the Batches 300k beta, which covers Opus 5/4.8/4.7/4.6 and Sonnet 5/4.6 only (checked 2026-09-05)","claude-opus-5":"thinking tokens bill as OUTPUT and count inside max_tokens; from Opus 4.5 / Sonnet 4.6 / Fable 5.x earlier thinking blocks are preserved and bill as INPUT on the next turn (platform.claude.com/docs, checked 2026-09-05)"}},A={deepseek:{"deepseek-v4-flash":{context:1e6,output:384000,reasoning:!0,toolCall:!0,override:!0,cost:{input:0.44,output:1.32,cacheRead:0.014},source:"api-docs.deepseek.com/quick_start/pricing (peak rate \u2014 off-peak is half, we do not model time-of-day; models.dev carries ~1/3 of these)",checked:"2026-09-05 (fetched)"},"deepseek-v4-pro":{context:1e6,output:384000,reasoning:!0,toolCall:!0,override:!0,cost:{input:1.32,output:3.96,cacheRead:0.044},source:"api-docs.deepseek.com/quick_start/pricing (peak rate \u2014 off-peak is half, we do not model time-of-day; models.dev carries ~1/3 of these)",checked:"2026-09-05 (fetched)"},"deepseek-v4-flash-vision-exp":{context:1e6,output:384000,reasoning:!0,toolCall:!0,image:!0,override:!0,cost:{input:0.44,output:1.32,cacheRead:0.014},source:"api-docs.deepseek.com/quick_start/pricing (peak rate \u2014 off-peak is half, we do not model time-of-day; models.dev carries ~1/3 of these)",checked:"2026-09-05 (fetched)"},"deepseek-chat":{context:128000,output:8000,reasoning:!0,toolCall:!0,cost:{input:0.28,output:0.42,cacheRead:0.028},source:"api-docs.deepseek.com pricing (V3.2 era)",checked:"2026-09-05 (unverified: the alias is not on the pricing page, which lists deepseek-v4-* only)"},"deepseek-reasoner":{context:128000,output:64000,reasoning:!0,toolCall:!0,cost:{input:0.28,output:0.42,cacheRead:0.028},source:"api-docs.deepseek.com pricing (V3.2 era)",checked:"2026-09-05 (unverified: not on the pricing page; DeepSeek now exposes thinking as a MODE of the v4 models, not a separate id)"}},openai:{"gpt-6-astra":{context:1050000,output:128000,reasoning:!0,toolCall:!0,image:!0,cost:{input:10,output:50,cacheRead:1},source:"developers.openai.com/api/docs/pricing",checked:"2026-09-05 (fetched)"}},xai:{"grok-4":{...U,reasoning:!0},"grok-4-0709":{...U,reasoning:!0},"grok-4-fast":{...U,reasoning:!0},"grok-4-fast-reasoning":{...U,reasoning:!0},"grok-4-fast-non-reasoning":{...U,reasoning:!1},"grok-4-1-fast-reasoning":{...U,reasoning:!0},"grok-4-1-fast-non-reasoning":{...U,reasoning:!1},"grok-3":{...U,reasoning:!1}}}});import{readFileSync as T,writeFileSync as g,mkdirSync as C,statSync as _}from"fs";import{join as S}from"path";function F(z,q){let B=x[z.toLowerCase()];if(!B)return;let Q=Object.keys(B).find((J)=>J.toLowerCase()===q.toLowerCase());return Q===void 0?void 0:B[Q]}function L(z,q){let B=j[z.toLowerCase()];if(!B)return;let Q=Object.keys(B).find((J)=>J.toLowerCase()===q.toLowerCase());return Q===void 0?void 0:B[Q]}function s(z,q){let B={...z.pricing??{}},Q=Number.isFinite(q)&&q>0?Math.floor(q):0,J=z.tier;if(!J||Q<=J.thresholdTokens)return{mode:J?J.mode:"flat",tierApplied:!1,...J?{thresholdTokens:J.thresholdTokens}:{},promptBase:Q,promptAbove:0,base:B,...J?{above:P(J)}:{},request:B};let W=P(J);return J.mode==="per-request"?{mode:"per-request",tierApplied:!0,thresholdTokens:J.thresholdTokens,promptBase:0,promptAbove:Q,base:B,above:W,request:W}:{mode:"marginal",tierApplied:!0,thresholdTokens:J.thresholdTokens,promptBase:J.thresholdTokens,promptAbove:Q-J.thresholdTokens,base:B,above:W,request:W}}function P(z){return{inputPerMTok:z.above.input,outputPerMTok:z.above.output,...z.above.cacheRead!==void 0?{cacheReadPerMTok:z.above.cacheRead}:{},...z.above.cacheWrite!==void 0?{cacheWritePerMTok:z.above.cacheWrite}:{}}}function m(z){let q=z.pricing;if(!q||q.inputPerMTok===void 0&&q.outputPerMTok===void 0)return[];let B=(J)=>J===void 0?"\u2014":`$${J}`,Q=[`${B(q.inputPerMTok)} in / ${B(q.outputPerMTok)} out per 1M${q.cacheReadPerMTok!==void 0?` \xB7 cache read ${B(q.cacheReadPerMTok)}`:""}${q.cacheWritePerMTok!==void 0?` \xB7 cache write ${B(q.cacheWritePerMTok)}`:""}`];if(z.tier){let J=z.tier;Q.push(J.mode==="per-request"?`over ${J.thresholdTokens.toLocaleString("en-US")} prompt tokens the WHOLE request bills at ${B(J.above.input)} in / ${B(J.above.output)} out`:`tokens past ${J.thresholdTokens.toLocaleString("en-US")} bill at ${B(J.above.input)} in / ${B(J.above.output)} out`)}if(z.priceNote)Q.push(z.priceNote);return Q}function D(z,q){return{id:z,name:z,description:`${q.source} \u2014 checked ${q.checked}`,attachment:!1,reasoning:q.reasoning,tool_call:q.toolCall,release_date:q.checked,modalities:{input:q.image?["text","image"]:["text"],output:["text"]},limit:{context:q.context,...q.output!==void 0?{output:q.output}:{}},cost:{input:q.cost.input,output:q.cost.output,...q.cost.cacheRead!==void 0?{cache_read:q.cost.cacheRead}:{},...q.cost.cacheWrite!==void 0?{cache_write:q.cost.cacheWrite}:{}}}}function O(z){if(typeof z!=="object"||z===null||Array.isArray(z))return!1;for(let q of Object.values(z)){if(typeof q!=="object"||q===null||Array.isArray(q))return!1;let B=q.models;if(typeof B!=="object"||B===null||Array.isArray(B))return!1}return!0}function X(z,q){if(q in z)return q;let B=q.toLowerCase();for(let Y of Object.keys(z))if(Y.toLowerCase()===B)return Y;let Q=q.indexOf("/");if(Q===-1)return;let J=q.slice(Q+1);if(J in z)return J;let W=J.toLowerCase();for(let Y of Object.keys(z))if(Y.toLowerCase()===W)return Y;return}function y(z,q,B){let Q={provider:z,model:q};if(B.limit?.context!==void 0)Q.contextWindow=B.limit.context;if(B.limit?.output!==void 0)Q.maxOutput=B.limit.output;let J=B.cost;if(J){let W={};if(J.input!==void 0)W.inputPerMTok=J.input;if(J.output!==void 0)W.outputPerMTok=J.output;if(J.cache_read!==void 0)W.cacheReadPerMTok=J.cache_read;if(J.cache_write!==void 0)W.cacheWritePerMTok=J.cache_write;if(Object.keys(W).length>0)Q.pricing=W}if(B.tool_call!==void 0)Q.supportsTools=B.tool_call;if(B.reasoning!==void 0)Q.supportsReasoning=B.reasoning;return Q}class N{fetchFn;cacheDir;local;liveProviders=null;triedDiskCache=!1;constructor(z={}){this.fetchFn=z.fetchFn??null,this.cacheDir=z.cacheDir,this.local=z.local??A}lookup(z,q){let B=this.resolve(z,q);if(!B)return;let Q=y(B.as,B.key,B.model);if(Q.source=B.local?"local":"models.dev",B.local)Q.sourceNote=`${B.local.source}, checked ${B.local.checked}`;let J=F(z,q)??F(z,B.key);if(J)Q.tier=J;let W=L(z,q)??L(z,B.key);if(W)Q.priceNote=W;return Q}supportsImages(z,q){let Q=this.resolve(z,q)?.model.modalities?.input;return Array.isArray(Q)?Q.includes("image"):void 0}supportsReasoning(z,q){let B=this.resolve(z,q);return typeof B?.model.reasoning==="boolean"?B.model.reasoning:void 0}resolve(z,q){this.loadDiskCacheOnce();let B=[],Q=E[z];if(Q)B.push({key:Q,as:z,model:q});let J=q.indexOf("/");if(J>0){let W=R[q.slice(0,J).toLowerCase()];if(W&&W!==Q)B.push({key:W,as:W,model:q.slice(J+1)})}for(let W of B){let Y=this.findIn(W.key,W.model);if(Y)return{as:W.as,...Y}}return}findIn(z,q){let B=this.local[z];if(B){let Z=X(B,q),$=Z===void 0?void 0:B[Z];if(Z!==void 0&&$?.override===!0)return{key:Z,model:D(Z,$),local:$}}let Q=this.liveProviders?.[z];if(Q){let Z=X(Q.models,q);if(Z!==void 0){let $=Q.models[Z];if($)return{key:Z,model:$}}}let J=u()[z];if(J){let Z=X(J.models,q);if(Z!==void 0){let $=J.models[Z];if($)return{key:Z,model:$}}}let W=this.local[z];if(!W)return;let Y=X(W,q);if(Y===void 0)return;let H=W[Y];return{key:Y,model:D(Y,H),local:H}}async refresh(){if(!this.fetchFn)return!1;try{let z=await this.fetchFn(k);if(!z.ok)return!1;let q=await z.json();if(!O(q))return!1;return this.liveProviders=q,this.triedDiskCache=!0,this.writeDiskCache(q),!0}catch{return!1}}loadDiskCacheOnce(){if(this.triedDiskCache)return;if(this.triedDiskCache=!0,!this.fetchFn||!this.cacheDir)return;try{let z=S(this.cacheDir,w);if(Date.now()-_(z).mtimeMs>h)return;let B=JSON.parse(T(z,"utf8"));if(O(B))this.liveProviders=B}catch{}}writeDiskCache(z){if(!this.cacheDir)return;try{C(this.cacheDir,{recursive:!0}),g(S(this.cacheDir,w),JSON.stringify(z))}catch{}}}function r(z,q){return(q??(b??=new N)).supportsImages(z.provider,z.model)}function n(z,q){return(q??(b??=new N)).supportsReasoning(z.provider,z.model)}var u=()=>K.providers,h=86400000,w="models.json",k="https://models.dev/api.json",E,R,b=null;var c=V(()=>{M();G();E={openai:"openai",anthropic:"anthropic",deepseek:"deepseek",groq:"groq",openrouter:"openrouter",lmstudio:"lmstudio",together:"togetherai",mistral:"mistral",cerebras:"cerebras",fireworks:"fireworks-ai",perplexity:"perplexity",xai:"xai",google:"google",gemini:"google",zai:"zai",moonshot:"moonshotai",moonshotai:"moonshotai",alibaba:"alibaba",dashscope:"alibaba",minimax:"minimax"},R={"zai-org":"zai","deepseek-ai":"deepseek",moonshotai:"moonshotai"}});
3
+ export{s as Zj,m as _j,N as $j,r as ak,n as bk,c as ck};
@@ -0,0 +1,16 @@
1
+ // @bun
2
+ import{Ul as i,bm as Wq}from"./main-0904f6ps.js";import{wn as t}from"./main-qsevpgsv.js";import{readdirSync as qq,statSync as x}from"fs";import{readdir as zq,stat as g}from"fs/promises";import{join as T,extname as A}from"path";import{execFile as Hq,spawnSync as Jq}from"child_process";import{Lang as P}from"@ast-grep/napi";function y(q){try{let H=Jq("git",["-C",q,"ls-files","-z","--cached","--others","--exclude-standard"],{timeout:5000,maxBuffer:67108864,encoding:"utf8",windowsHide:!0});if(H.error||H.status!==0||typeof H.stdout!=="string")return null;return H.stdout.split("\x00").filter((Z)=>Z.length>0)}catch{return null}}function Qq(q){return new Promise((H)=>{try{Hq("git",["-C",q,"ls-files","-z","--cached","--others","--exclude-standard"],{timeout:5000,maxBuffer:67108864,encoding:"utf8",windowsHide:!0},(Z,O)=>{H(Z||typeof O!=="string"?null:O.split("\x00").filter((j)=>j.length>0))})}catch{H(null)}})}function Vq(q){try{let H=x(q);return H.isFile()&&H.size<=F}catch{return!1}}function Pq(q,H,Z=d){let O=[],j=y(q);if(j){if(H)H.viaGit=!0;let Y=j.filter((J)=>D[A(J).toLowerCase()]!==void 0).filter((J)=>!J.split("/").slice(0,-1).some((z)=>h.has(z)||z.startsWith("."))).sort();for(let J of Y){if(O.length>Z)break;let z=T(q,J);if(Vq(z))O.push(z)}}else{let Y=(J)=>{let z;try{z=qq(J)}catch{return}for(let Q of z.sort()){if(O.length>Z)return;let $=T(J,Q),K;try{K=x($)}catch{continue}if(K.isDirectory()){if(!h.has(Q)&&!Q.startsWith("."))Y($)}else if(D[A(Q).toLowerCase()]!==void 0&&K.size<=F)O.push($)}};Y(q)}if(O.length>Z){if(H)H.capped=!0;O.pop()}return O}async function _(q){try{let H=await g(q);return H.isFile()&&H.size<=F}catch{return!1}}async function bq(q,H,Z=d,O){O?.throwIfAborted();let j=[],Y=await Qq(q);if(O?.throwIfAborted(),Y){if(H)H.viaGit=!0;let J=Y.filter((z)=>D[A(z).toLowerCase()]!==void 0).filter((z)=>!z.split("/").slice(0,-1).some((Q)=>h.has(Q)||Q.startsWith("."))).sort();for(let z of J){if(j.length>Z)break;let Q=T(q,z);if(await _(Q))j.push(Q);O?.throwIfAborted()}}else{let J=async(z)=>{O?.throwIfAborted();let Q;try{Q=await zq(z,{withFileTypes:!0})}catch{return}for(let $ of Q.sort((K,V)=>K.name<V.name?-1:K.name>V.name?1:0)){if(O?.throwIfAborted(),j.length>Z)return;let K=$.name,V=T(z,K),B=$.isDirectory(),M=$.isFile();if($.isSymbolicLink())try{let w=await g(V);B=w.isDirectory(),M=w.isFile()}catch{continue}if(B){if(!h.has(K)&&!K.startsWith("."))await J(V)}else if(M&&D[A(K).toLowerCase()]!==void 0){if(await _(V))j.push(V)}}};await J(q)}if(j.length>Z){if(H)H.capped=!0;j.pop()}return j}var D,h,d=2000,F=262144;var u=t(()=>{D={".ts":P.TypeScript,".mts":P.TypeScript,".cts":P.TypeScript,".tsx":P.Tsx,".js":P.JavaScript,".mjs":P.JavaScript,".cjs":P.JavaScript,".jsx":P.JavaScript},h=new Set(["node_modules",".git",".rovecode","dist","build","out","coverage",".cache"])});Wq();u();import{readdirSync as o,statSync as k,lstatSync as Zq,existsSync as S}from"fs";import{readFile as $q,stat as Oq}from"fs/promises";import{join as E,basename as a}from"path";import{spawnSync as Kq}from"child_process";var m=100,c=100,p=200,I=1000,s=1e4,l=2000,Uq=1048576,jq=8192;function C(q,H){return Number.isFinite(q)&&q>0?Math.min(Math.floor(q),I):H}function f(q,H){if(!H)return q;return i(q,H)}function r(q,H=s){let Z=y(q);if(Z){let J=Z.slice(0,H+1),z=J.length>H;if(z)J.pop();return{rel:J,viaGit:!0,capped:z}}let O=[],j=!1,Y=(J,z)=>{let Q;try{Q=o(J)}catch{return}for(let $ of Q.sort()){if(j)return;if($.startsWith(".")||$==="node_modules")continue;let K=E(J,$),V;try{V=Zq(K)}catch{continue}if(V.isSymbolicLink())continue;if(V.isDirectory())Y(K,`${z}${$}/`);else if(V.isFile()){if(O.length>=H){j=!0;return}O.push(z+$)}}};return Y(q,""),{rel:O,viaGit:!1,capped:j}}function n(q){let H=new Bun.Glob(q);if(!q.includes("/"))return(Z)=>H.match(a(Z));return(Z)=>H.match(Z)}var e=(q)=>`(File enumeration capped at ${q} files; results may be incomplete.)`,L=(q,H)=>q?["",e(H)]:[];function Xq(q){return q.subarray(0,jq).includes(0)}function Yq(q){return q.length>l?q.slice(0,l).replace(/[\uD800-\uDBFF]$/,"")+"...":q}function vq(q,H){try{let Z=Kq("git",["-C",q,"check-ignore","--stdin","-z"],{input:H.join("\x00"),timeout:5000,maxBuffer:16777216,encoding:"utf8",windowsHide:!0});if(Z.error||typeof Z.stdout!=="string")return null;if(Z.status!==0&&Z.status!==1)return null;return new Set(Z.stdout.split("\x00").filter((O)=>O.length>0))}catch{return null}}function Bq(q=s){let H={schema:{name:"glob",description:'Find files by glob pattern (e.g. "**/*.ts", "src/**/*.test.ts"; a pattern without "/" matches file names at any depth). Honors .gitignore in git repos; skips dotfiles and node_modules elsewhere. Returns absolute paths, most recently modified first, at most maxFiles (default 100, cap 1000) with a truncation note when more matched.',args:{type:"object",properties:{pattern:{type:"string",description:"glob pattern to match files against"},path:{type:"string",description:"directory to search (default: session cwd)"},maxFiles:{type:"integer",description:`max paths returned (default ${m}, cap ${I})`}},required:["pattern"]}},kind:"read",sequential:!1,execute(j,Y){let J=j,z=f(Y.cwd,J.path);if(!S(z))return Promise.resolve({ok:!1,output:`directory not found: ${z}`});if(!k(z).isDirectory())return Promise.resolve({ok:!1,output:`glob path must be a directory: ${z}`});let Q=C(J.maxFiles,m),$;try{$=n(J.pattern)}catch(X){return Promise.resolve({ok:!1,output:`invalid glob pattern: ${X instanceof Error?X.message:String(X)}`})}let K=r(z,q),V=[];for(let X of K.rel){if(!$(X))continue;let U=E(z,X);try{V.push({abs:U,mtimeMs:k(U).mtimeMs})}catch{}}let B=Date.now(),M=86400000;V.sort((X,U)=>{let G=B-X.mtimeMs<M,W=B-U.mtimeMs<M;if(G&&W)return U.mtimeMs-X.mtimeMs;if(G)return-1;if(W)return 1;return X.abs.localeCompare(U.abs)});let w=V.length>Q,v=w?V.slice(0,Q):V,N=[];if(v.length===0)N.push("No files found");else if(N.push(...v.map((X)=>X.abs)),w)N.push("",`(Results are truncated: showing first ${Q} results. Consider using a more specific path or pattern.)`);return N.push(...L(K.capped,q)),Promise.resolve({ok:!0,output:N.join(`
3
+ `),data:{count:v.length,truncated:w}})}},Z={schema:{name:"grep",description:'Search file contents with a JS regular expression (e.g. "log.*Error", "function\\s+\\w+"). Optional glob filters files ("*.ts", "src/**/*.tsx"). Honors .gitignore in git repos; skips dotfiles/node_modules elsewhere, plus binary files and files over 1MB. Output is `path:line: text` matches, at most maxMatches (default 100, cap 1000), each line capped at 2000 chars, with truncation notes.',args:{type:"object",properties:{pattern:{type:"string",description:"regex to search for in file contents"},path:{type:"string",description:"directory (or single file) to search (default: session cwd)"},glob:{type:"string",description:'file filter glob, e.g. "*.ts" (names at any depth) or "src/**/*.ts"'},maxMatches:{type:"integer",description:`max matches returned (default ${c}, cap ${I})`}},required:["pattern"]}},kind:"read",sequential:!1,async execute(j,Y){let J=j,z;try{z=new RegExp(J.pattern)}catch(U){return{ok:!1,output:`invalid regex: ${U instanceof Error?U.message:String(U)}`}}let Q=f(Y.cwd,J.path);if(!S(Q))return{ok:!1,output:`path not found: ${Q}`};let $=C(J.maxMatches,c),K=null;if(J.glob)try{K=n(J.glob)}catch(U){return{ok:!1,output:`invalid glob filter: ${U instanceof Error?U.message:String(U)}`}}if(Y.signal.aborted)return{ok:!1,output:"grep aborted"};let V=k(Q).isFile(),B=V?{rel:[a(Q)],viaGit:!1,capped:!1}:r(Q,q),M=V?E(Q,".."):Q,w=B.rel.filter((U)=>K?K(U):!0).sort(),v=[],N=!1;q:for(let U of w){if(Y.signal.aborted)return{ok:!1,output:"grep aborted"};let G=V?Q:E(M,U),W;try{if((await Oq(G)).size>Uq)continue;W=await $q(G)}catch{continue}if(Xq(W))continue;let R=W.toString("utf8").split(/\r?\n/);for(let b=0;b<R.length;b++){if(!z.test(R[b]))continue;if(v.length>=$){N=!0;break q}v.push({abs:G,line:b+1,text:Yq(R[b])})}}if(v.length===0)return{ok:!0,output:["No matches found",...L(B.capped,q)].join(`
4
+ `),data:{matches:0,truncated:!1}};let X=[`Found ${v.length} matches${N?" (more matches available)":""}`];if(X.push(...v.map((U)=>`${U.abs}:${U.line}: ${U.text}`)),N)X.push("","(Results truncated. Consider using a more specific path or pattern.)");return X.push(...L(B.capped,q)),{ok:!0,output:X.join(`
5
+ `),data:{matches:v.length,truncated:N}}}},O={schema:{name:"ls",description:"List a directory (non-recursive). Directories first as `[DIR] name`, files as `name (N bytes)`, alphabetical. Gitignored entries are hidden and counted in git repos; dotfiles and node_modules are hidden elsewhere. At most maxEntries rows (default 200, cap 1000) with a truncation note.",args:{type:"object",properties:{path:{type:"string",description:"directory to list (default: session cwd)"},maxEntries:{type:"integer",description:`max entries returned (default ${p}, cap ${I})`}}}},kind:"read",sequential:!1,execute(j,Y){let J=j,z=f(Y.cwd,J.path);if(!S(z))return Promise.resolve({ok:!1,output:`directory not found: ${z}`});if(!k(z).isDirectory())return Promise.resolve({ok:!1,output:`Path is not a directory: ${z}`});let Q=C(J.maxEntries,p),$=o(z).filter((W)=>W!==".git"),K=vq(z,$),V,B;if(K)V=$.filter((W)=>!K.has(W)),B=$.length-V.length;else V=$.filter((W)=>!W.startsWith(".")&&W!=="node_modules"),B=$.length-V.length;if(V.length===0){let W=B>0?`
6
+
7
+ (${B} ignored)`:"";return Promise.resolve({ok:!0,output:`Directory ${z} is empty.${W}`,data:{entries:0,truncated:!1}})}let M=V.length>q,w=M?V.sort((W,R)=>W.localeCompare(R)).slice(0,q):V,v=[];for(let W of w)try{let R=k(E(z,W));v.push({name:W,isDir:R.isDirectory(),size:R.isDirectory()?0:R.size})}catch{}v.sort((W,R)=>{if(W.isDir&&!R.isDir)return-1;if(!W.isDir&&R.isDir)return 1;return W.name.localeCompare(R.name)});let N=v.length>Q,X=N?v.slice(0,Q):v,U=X.map((W)=>W.isDir?`[DIR] ${W.name}`:`${W.name} (${W.size} bytes)`).join(`
8
+ `),G=`Directory listing for ${z}:
9
+ ${U}`;if(N)G+=`
10
+
11
+ (Results truncated: showing first ${Q} of ${v.length} entries.)`;if(B>0)G+=`
12
+
13
+ (${B} ignored)`;if(M)G+=`
14
+
15
+ ${e(q)}`;return Promise.resolve({ok:!0,output:G,data:{entries:X.length,truncated:N}})}};return{globTool:H,grepTool:Z,lsTool:O}}var{globTool:Fq,grepTool:yq,lsTool:Sq}=Bq();
16
+ export{D as Kf,d as Lf,F as Mf,Pq as Nf,bq as Of,u as Pf,m as Qf,c as Rf,p as Sf,I as Tf,s as Uf,l as Vf,Uq as Wf,C as Xf,r as Yf,e as Zf,Bq as _f,Fq as $f,yq as ag,Sq as bg};
@@ -0,0 +1,4 @@
1
+ // @bun
2
+ import{ia as C,ja as F,ma as P,na as T,qa as v}from"./main-7c5thhjd.js";import{Ec as D,Fc as g}from"./main-vqak588n.js";import{Sd as b,Td as j,Wd as u}from"./main-pn1w7a7j.js";import{Bm as A,Cm as H,Dm as V,Fm as k,ym as W,zm as N}from"./main-7rn6bqje.js";import{wn as S}from"./main-qsevpgsv.js";import{chmodSync as d,existsSync as O,mkdirSync as w,readFileSync as y,writeFileSync as c}from"fs";import{dirname as m}from"path";function h(B){let J=(B.split("/").pop()??B).toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/^[^a-z0-9]+/,"").slice(0,64);return J.length>0?J:"server"}function x(B){return B.toUpperCase().replace(/[^A-Z0-9_]/g,"_").replace(/^[0-9]/,"_$&")}function s(B,G){if(B.installs.length===0)return{error:`${B.key} lists nothing rovecode can launch or connect to (no stdio package, no streamable-http remote)`};let J=G.pick??0,K=B.installs[J];if(!K)return{error:`${B.key} has ${B.installs.length} install form(s); --pick ${J} is out of range`};let U=G.name??(B.source==="curated"?B.key:h(B.key));if(!f.test(U))return{error:`"${U}" is not a usable server name (lowercase letters, digits, . _ -)`};let Z=W(G.cwd,G.home),X=G.scope==="project"?Z.project:Z.user,Q;if(G.local===!0){if(G.scope==="project")return{error:`${B.key}: install-once writes this machine's absolute path (node <home>/mcp/\u2026), and a project file is shared with every clone \u2014 install it in user scope (drop --project) or keep the npx line`};let Y=C(K);if(Y===void 0)return{error:`${B.key} cannot be installed once: its launch line is not a plain \`npx <package>\` (${D(K)}) \u2014 drop --local to write it as it is`};Q={pkg:Y,prefix:F(G.home)}}let $=[],q={};if(K.kind==="stdio")for(let Y of K.env){if(Y.default!==void 0)continue;if(Y.secret||Y.required)$.push(Y)}else for(let Y of K.headers){let I=[...(Y.template??"").matchAll(M)].map((z)=>z[1]);if(Y.template!==void 0&&I.length===0)continue;for(let z of I.length?I:[x(Y.name)]){q[z]=Y.name;let _={name:z,required:Y.required,secret:Y.secret};if(Y.description)_.description=Y.description;$.push(_)}}return{entry:B,install:K,scope:G.scope,file:X,name:U,asks:$,pending:K.kind==="stdio"?K.pending:[],headerVars:q,...Q?{local:Q}:{}}}function R(B,G){let J=/^(.*?)\s*(<[^<>]*>)\s*$/.exec(B),K=G!==void 0&&G.length>0;if(!J)return[K?G:B];return[...J[1].length>0?J[1].split(/\s+/):[],K?G:J[2]]}function a(B,G,J){let K=(X)=>{let Q=G[X.name];if(Q!==void 0&&Q.length>0&&!(X.secret&&B.scope==="project"))return Q;if(Q===void 0||Q.length===0){if(!X.required&&!(Q!==void 0&&X.secret))return}return`\${${X.name}}`},{install:U}=B;if(U.kind==="stdio"){let X={};for(let q of U.env){if(q.default!==void 0){X[q.name]=q.default;continue}let Y=K(q);if(Y!==void 0)X[q.name]=Y}let Q=U.pending.flatMap((q)=>R(q,G[q])),$=J??{command:U.command,args:U.args};return{command:$.command,args:[...$.args,...Q],...Object.keys(X).length?{env:X}:{}}}let Z={};for(let X of U.headers){if(X.template!==void 0&&!M.test(X.template)){Z[X.name]=X.template,M.lastIndex=0;continue}M.lastIndex=0;let Q=Object.entries(B.headerVars).filter(([,Y])=>Y===X.name).map(([Y])=>Y),$=X.template??`{${Q[0]??x(X.name)}}`,q=!0;for(let Y of Q){let I=B.asks.find((_)=>_.name===Y),z=K(I);if(z===void 0){q=!1;break}$=$.split(`{${Y}}`).join(z)}if(q)Z[X.name]=$}return{type:"http",url:U.url,...Object.keys(Z).length?{headers:Z}:{}}}function e(B,G){let J=JSON.stringify(G);return B.asks.filter((K)=>J.includes(`\${${K.name}}`)).map((K)=>K.name)}function BB(B,G="prompt"){let{entry:J,install:K}=B,U=(Q)=>G==="env"?"(${NAME} \u2014 from your environment)":Q?"(asked, masked, never shown)":"(asked)",Z=[`${J.title??J.key}${J.version?` ${J.version}`:""}${J.status?` [${J.status}]`:""}`,` source ${J.source==="curated"?"curated list (built into rovecode)":"MCP registry (registry.modelcontextprotocol.io)"}`,` publisher ${J.publisher??"unknown"}`];if(J.repository)Z.push(` repo ${J.repository}`);if(B.local)Z.push(` runs ${P(B.local.pkg,B.local.prefix)}`,...T(B.local.pkg,B.local.prefix));else Z.push(K.kind==="stdio"?` runs ${D(K)}`:` connects ${K.url}`);let X=K.kind==="stdio"?K.env:[];for(let Q of X){let $=Q.default!==void 0?`= ${Q.default}`:B.asks.includes(Q)?U(Q.secret).replace("NAME",Q.name):"(optional, left unset)";Z.push(` env ${Q.name} ${$}${Q.required?"":" optional"}`)}if(K.kind==="http")for(let Q of K.headers){let $=Object.entries(B.headerVars).filter(([,q])=>q===Q.name).map(([q])=>q);Z.push(` header ${Q.name}: ${$.length?`${Q.template??`{${$[0]}}`} \u2190 ${$.join(", ")} ${U(Q.secret).replace("NAME",$[0])}`:Q.template??""}${Q.required?"":" optional"}`)}for(let Q of B.pending)Z.push(` needs ${Q} \u2014 ${G==="env"?"written as the placeholder; fill it in and the server connects":"asked here; unanswered it is written as the placeholder"}`);return Z.push(` writes ${B.file} as "${B.name}"${G==="prompt"&&B.scope==="project"&&B.asks.some((Q)=>Q.secret)?" (secrets stay out of this file: ${NAME} is read from your environment)":""}`),Z}function E(B){if(!O(B))return{json:{},servers:{}};let G=JSON.parse(y(B,"utf8"));if(!N(G))throw Error(`${B}: root is not an object`);let J=N(G.mcpServers)?G.mcpServers:{};return{json:G,servers:J}}function L(B,G,J){if(w(m(B),{recursive:!0}),c(B,JSON.stringify({...G.json,mcpServers:G.servers},null,2)+`
3
+ `,{mode:384}),J&&process.platform!=="win32")d(B,384)}function GB(B,G,J,K={}){let U=[],Z=A(G,J,B,U,new Proxy({},{get:()=>"set"}),{allowPlaceholders:!0});if(!Z)throw Error(U.join("; ")||`${G}: not a valid server entry`);let X=E(B);if(X.servers[G]!==void 0&&!K.replace)throw Error(`${B} already has a server named "${G}" \u2014 remove it first, or add --force`);let Q=K.trustHome!==void 0&&(!O(B)||Object.keys(X.servers).filter((q)=>q!==G).length===0||b(K.trustHome,B)==="trusted");X.servers[G]=J;let $=JSON.stringify(J).includes("env")||JSON.stringify(J).includes("headers");if(L(B,X,$),K.trustHome===void 0)return Z;if(Q)j(K.trustHome,B);return{...Z,trusted:Q}}function JB(B,G,J={}){if(!O(B))return!1;let K=J.trustHome!==void 0&&b(J.trustHome,B)==="trusted",U=E(B);if(U.servers[G]===void 0)return!1;if(delete U.servers[G],L(B,U,!1),K)j(J.trustHome,B);return!0}function KB(B){let G=B.transport==="stdio"?[B.command,...B.args??[]].join(" "):B.url??"",J=B.env&&Object.keys(B.env).length?` env ${Object.keys(B.env).join(", ")}`:"",K=B.headers&&Object.keys(B.headers).length?` headers ${Object.keys(B.headers).join(", ")}`:"",U=H(B),Z=U.length?` (fill in ${U.join(", ")})`:"";return`${B.name.padEnd(24)} ${B.transport.padEnd(5)} ${G}${J}${K}${Z}${B.enabled===!1?" (disabled)":""}`}function QB(B,G,J=[]){let K=W(B,G),U=new Proxy({},{get:()=>"set"}),Z=[];for(let[X,Q]of[["user",K.user],["harvest",K.harvest],["project",K.project]])for(let $ of V(Q,J,U,{allowPlaceholders:!0}))Z.push({scope:X,file:Q,server:$});return Z}function UB(B,G){let J=Array.isArray(G.args)?G.args:[];return B.pending.filter((K)=>R(K).some((U)=>/^<.*>$/.test(U)&&J.includes(U)))}var f,M;var o=S(()=>{k();g();u();v();f=/^[a-z0-9][a-z0-9._-]{0,63}$/,M=/\{([A-Za-z_][A-Za-z0-9_-]*)\}/g});
4
+ export{h as Z,s as _,a as $,e as aa,BB as ba,GB as ca,JB as da,KB as ea,QB as fa,UB as ga,o as ha};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ import{ei as k,ni as X,oi as y,ti as R}from"./main-3gjqfh7a.js";import{$m as T,Lm as L}from"./main-2yeveeve.js";import{on as U,sn as B,tn as h}from"./main-nqveez48.js";import{wn as F}from"./main-qsevpgsv.js";import{readFileSync as p}from"fs";import{join as v}from"path";function m(q){return q.replace(/\s*[\r\n]+\s*/g," ").trim()}function A(q){return k.includes(q)}function H(q,z){let Q=typeof q==="string"?q.trim().toLowerCase():"";if(A(Q))return Q;let J=typeof q==="string"?q:JSON.stringify(q);return $(`sandbox rung ${JSON.stringify(String(J).slice(0,60))} from ${z} is not a rung \u2014 use one of ${k.join(", ")} (bubblewrap is not a rung on this harness); ${Y}`)}function D(q,z){if(typeof q==="string"&&q.trim()!=="")return q.trim();return $(`sandbox dockerImage from ${z} must be a non-empty string (e.g. "${y}"); ${Y}`)}function $(q){throw new V(q)}function O(q){let z=v(q,".rovecode","sandbox.json"),Q;try{Q=p(z,"utf8")}catch(P){if(P.code==="ENOENT")return null;return $(`sandbox config ${z} cannot be read (${P instanceof Error?P.message:String(P)}) \u2014 ${Y}`)}let J;try{J=JSON.parse(Q)}catch(P){return $(`sandbox config ${z} is not valid JSON (${P instanceof Error?P.message:String(P)}) \u2014 fix or delete it; ${Y}`)}if(!J||typeof J!=="object"||Array.isArray(J))return $(`sandbox config ${z} must be a JSON object like {"rung":"wsl"} or {"rung":"docker","dockerImage":"${y}"}; ${Y}`);let W=J;return{rung:W.rung,dockerImage:W.dockerImage,path:z}}function u(q,z=process.env,Q={}){let J=O(q),W;if(J!==null){if(!(Q.trusted??((C)=>U(Q.home??L(),C)))(J.path))W=B(J.path,"its sandbox rung and docker image are ignored (a repo file would choose the executor every bash command runs in)"),J=null}let P=z[K]?.trim()??"",G=z[S]?.trim()??"",j="direct",M="default";if(P!=="")j=H(P,K),M="env";else if(J&&J.rung!==void 0)j=H(J.rung,J.path),M="file";let Z;if(G!=="")Z=G;else if(J&&J.dockerImage!==void 0)Z=D(J.dockerImage,J.path);else if(j==="docker")Z=y;return{rung:j,source:M,...Z!==void 0?{dockerImage:Z}:{},...W!==void 0?{note:W}:{}}}function t(q,z){let Q=z instanceof X?z.detail:z instanceof Error?z.message:String(z);return new V(`sandbox rung "${q.rung}" (from ${x(q)}) unavailable: ${Q} \u2014 ${Y}`,{cause:z})}function x(q){return q.source==="env"?K:q.source==="file"?b:"default"}function i(q){let z=q.rung==="docker"?` ${q.dockerImage??y}`:"";return`${q.rung}${z} (${x(q)})`}var b=".rovecode/sandbox.json",K="ROVECODE_SANDBOX",S="ROVECODE_SANDBOX_IMAGE",Y,V;var _=F(()=>{T();R();h();Y=`fix ${b} or ${K} (default: direct)`;V=class V extends Error{constructor(q,z){super(m(q),z);this.name="SandboxConfigError"}}});
3
+ export{b as nh,K as oh,S as ph,V as qh,u as rh,t as sh,i as th,_ as uh};