rovecode 0.4.0-beta.2 → 0.4.0

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 (428) hide show
  1. package/README.md +67 -69
  2. package/THIRD_PARTY_NOTICES.md +0 -44
  3. package/bin/rovecode.ts +21 -0
  4. package/package.json +16 -37
  5. package/src/account/keys.ts +97 -0
  6. package/src/account/login.ts +158 -0
  7. package/src/account/provision.ts +47 -0
  8. package/src/account/store.ts +63 -0
  9. package/src/acp/server.ts +373 -0
  10. package/src/cli/account-cmd.ts +116 -0
  11. package/src/cli/connect.ts +244 -0
  12. package/src/cli/context-cmd.ts +199 -0
  13. package/src/cli/dispatch.ts +109 -0
  14. package/src/cli/doctor.ts +324 -0
  15. package/src/cli/export.ts +278 -0
  16. package/src/cli/help.ts +240 -0
  17. package/src/cli/is-tui-invocation.ts +8 -0
  18. package/src/cli/main.ts +599 -0
  19. package/src/cli/market-cmd.ts +658 -0
  20. package/src/cli/mcp-market-cmd.ts +299 -0
  21. package/src/cli/output.ts +382 -0
  22. package/src/cli/repl.ts +172 -0
  23. package/src/cli/resume.ts +32 -0
  24. package/src/cli/run-limits.ts +78 -0
  25. package/src/cli/runtime.ts +792 -0
  26. package/src/cli/setup.ts +187 -0
  27. package/src/cli/update-cmd.ts +78 -0
  28. package/src/cli/workflow-cmd.ts +100 -0
  29. package/src/coding/checkpoints.ts +270 -0
  30. package/src/coding/diff.ts +136 -0
  31. package/src/coding/files.ts +339 -0
  32. package/src/coding/hashline.ts +319 -0
  33. package/src/coding/lsp.ts +406 -0
  34. package/src/coding/repomap-cache.ts +99 -0
  35. package/src/coding/repomap-files.ts +110 -0
  36. package/src/coding/repomap.ts +392 -0
  37. package/src/core/compaction.ts +399 -0
  38. package/src/core/config.ts +289 -0
  39. package/src/core/context-report.ts +228 -0
  40. package/src/core/context.ts +60 -0
  41. package/src/core/count-remote.ts +107 -0
  42. package/src/core/execpolicy-rules.ts +196 -0
  43. package/src/core/execpolicy.ts +385 -0
  44. package/src/core/executor.ts +397 -0
  45. package/src/core/guardrails.ts +400 -0
  46. package/src/core/hooks.ts +398 -0
  47. package/src/core/images.ts +230 -0
  48. package/src/core/intro.ts +236 -0
  49. package/src/core/loop.ts +621 -0
  50. package/src/core/modes.ts +372 -0
  51. package/src/core/orchestrator.ts +207 -0
  52. package/src/core/reflection.ts +165 -0
  53. package/src/core/sandbox-config.ts +167 -0
  54. package/src/core/session-images.ts +73 -0
  55. package/src/core/session.ts +398 -0
  56. package/src/core/settings.ts +98 -0
  57. package/src/core/stuck-detector.ts +273 -0
  58. package/src/core/tasks.ts +374 -0
  59. package/src/core/token-scale.ts +108 -0
  60. package/src/core/tool-output-budget.ts +166 -0
  61. package/src/core/tools.ts +288 -0
  62. package/src/core/types.ts +330 -0
  63. package/src/core/update-check.ts +171 -0
  64. package/src/core/update.ts +158 -0
  65. package/src/core/usage.ts +204 -0
  66. package/src/core/validate.ts +121 -0
  67. package/src/core/verify-gate.ts +159 -0
  68. package/src/core/verify.ts +237 -0
  69. package/src/core/voice.ts +158 -0
  70. package/src/core/win-job.ts +183 -0
  71. package/src/design/audit.ts +797 -0
  72. package/src/design/direction.ts +190 -0
  73. package/src/design/rules.ts +157 -0
  74. package/src/eval/bench.ts +150 -0
  75. package/src/eval/gauntlet-runner.ts +218 -0
  76. package/src/eval/gauntlet.ts +226 -0
  77. package/src/eval/grader.ts +186 -0
  78. package/src/eval/record.ts +202 -0
  79. package/src/eval/redact.ts +141 -0
  80. package/src/eval/replay.ts +147 -0
  81. package/src/eval/trajectory.ts +373 -0
  82. package/src/index.ts +17 -0
  83. package/src/market/catalogs/mcp-docs.json +111 -0
  84. package/src/market/catalogs/plugins.json +111 -0
  85. package/src/market/catalogs/skills.json +478 -0
  86. package/src/market/clone.ts +72 -0
  87. package/src/market/context-cost.ts +121 -0
  88. package/src/market/digest.ts +106 -0
  89. package/src/market/index.ts +22 -0
  90. package/src/market/install.ts +578 -0
  91. package/src/market/manifest.ts +187 -0
  92. package/src/market/prereq.ts +145 -0
  93. package/src/market/registry.ts +363 -0
  94. package/src/market/resolve.ts +111 -0
  95. package/src/market/types.ts +236 -0
  96. package/src/market/validate.ts +227 -0
  97. package/src/mcp/client.ts +431 -0
  98. package/src/mcp/config.ts +239 -0
  99. package/src/mcp/local-package.ts +211 -0
  100. package/src/mcp/market-catalog.ts +84 -0
  101. package/src/mcp/market-install.ts +289 -0
  102. package/src/mcp/market.ts +0 -0
  103. package/src/mcp/tools.ts +131 -0
  104. package/src/mcp/trust.ts +49 -0
  105. package/src/memory/blocks.ts +175 -0
  106. package/src/memory/recall.ts +355 -0
  107. package/src/memory/store.ts +105 -0
  108. package/src/memory/tools.ts +99 -0
  109. package/src/plugins/cli.ts +123 -0
  110. package/src/plugins/discover.ts +108 -0
  111. package/src/plugins/index.ts +50 -0
  112. package/src/plugins/init.ts +140 -0
  113. package/src/plugins/install.ts +184 -0
  114. package/src/plugins/load.ts +149 -0
  115. package/src/plugins/manifest.ts +106 -0
  116. package/src/plugins/state.ts +83 -0
  117. package/src/providers/auth.ts +293 -0
  118. package/src/providers/cache.ts +223 -0
  119. package/src/providers/catalog-local.ts +160 -0
  120. package/src/providers/catalog.ts +408 -0
  121. package/src/providers/middleware-context.ts +86 -0
  122. package/src/providers/middleware.ts +373 -0
  123. package/src/providers/profile-glm53.ts +111 -0
  124. package/src/providers/profile-sonnet5-persona.ts +65 -0
  125. package/src/providers/profile-sonnet5-voice.ts +23 -0
  126. package/src/providers/profiles.ts +156 -0
  127. package/src/providers/provider-config.ts +311 -0
  128. package/src/providers/registry.ts +302 -0
  129. package/src/providers/response-validation.ts +80 -0
  130. package/src/providers/retry.ts +234 -0
  131. package/src/providers/router.ts +294 -0
  132. package/src/providers/sse.ts +26 -0
  133. package/src/providers/stream-errors.ts +117 -0
  134. package/src/providers/stream.ts +569 -0
  135. package/src/providers/thinking.ts +189 -0
  136. package/src/providers/wire-messages.ts +129 -0
  137. package/src/sdk/client.ts +225 -0
  138. package/src/sdk/index.ts +3 -0
  139. package/src/server/dashboard.ts +144 -0
  140. package/src/server/http.ts +343 -0
  141. package/src/server/openapi.ts +246 -0
  142. package/src/sextant/card-hits.ts +102 -0
  143. package/src/sextant/card-keys.ts +55 -0
  144. package/src/sextant/context-source.ts +157 -0
  145. package/src/sextant/draw-agents.ts +273 -0
  146. package/src/sextant/draw-code.ts +388 -0
  147. package/src/sextant/draw-context.ts +222 -0
  148. package/src/sextant/draw-frame.ts +164 -0
  149. package/src/sextant/draw-market.ts +573 -0
  150. package/src/sextant/draw-messages.ts +386 -0
  151. package/src/sextant/draw-pet.ts +230 -0
  152. package/src/sextant/draw-plan.ts +159 -0
  153. package/src/sextant/draw-tabs.ts +85 -0
  154. package/src/sextant/draw-util.ts +65 -0
  155. package/src/sextant/engine.ts +230 -0
  156. package/src/sextant/frame-hits.ts +25 -0
  157. package/src/sextant/frame.ts +101 -0
  158. package/src/sextant/git-status.ts +197 -0
  159. package/src/sextant/grid.ts +59 -0
  160. package/src/sextant/input.ts +119 -0
  161. package/src/sextant/keys.ts +488 -0
  162. package/src/sextant/layout.ts +86 -0
  163. package/src/sextant/local-commands.ts +156 -0
  164. package/src/sextant/market-source.ts +287 -0
  165. package/src/sextant/mentions.ts +141 -0
  166. package/src/sextant/message-hits.ts +26 -0
  167. package/src/sextant/model.ts +387 -0
  168. package/src/sextant/overlays.ts +451 -0
  169. package/src/sextant/panel-hits.ts +38 -0
  170. package/src/sextant/pet.ts +399 -0
  171. package/src/sextant/screen.ts +324 -0
  172. package/src/sextant/scroll-hits.ts +66 -0
  173. package/src/sextant/scrollbar.ts +82 -0
  174. package/src/sextant/selection.ts +123 -0
  175. package/src/sextant/sextant-bridge.ts +174 -0
  176. package/src/sextant/sextant-cards.ts +142 -0
  177. package/src/sextant/sextant-diff-base.ts +63 -0
  178. package/src/sextant/sextant-files.ts +154 -0
  179. package/src/sextant/sextant-frame-loop.ts +314 -0
  180. package/src/sextant/sextant-renderer.ts +478 -0
  181. package/src/sextant/sextant-repo.ts +131 -0
  182. package/src/sextant/theme.ts +66 -0
  183. package/src/sextant/tool-rows.ts +189 -0
  184. package/src/sextant/types.ts +473 -0
  185. package/src/skills/index.ts +306 -0
  186. package/src/skills/tools.ts +69 -0
  187. package/src/skills/versioned.ts +227 -0
  188. package/src/telemetry/otel.ts +353 -0
  189. package/src/telemetry/otlp.ts +68 -0
  190. package/src/tools/ask-user.ts +156 -0
  191. package/src/tools/design.ts +151 -0
  192. package/src/tools/evalcell.ts +338 -0
  193. package/src/tools/html-text.ts +139 -0
  194. package/src/tools/provider.ts +149 -0
  195. package/src/tools/task.ts +216 -0
  196. package/src/tools/todo.ts +320 -0
  197. package/src/tools/webfetch.ts +331 -0
  198. package/src/tui/app.ts +608 -0
  199. package/src/tui/attach.ts +127 -0
  200. package/src/tui/checkpoints-cmd.ts +70 -0
  201. package/src/tui/clipboard-image.ts +81 -0
  202. package/src/tui/commands.ts +277 -0
  203. package/src/tui/cost.ts +108 -0
  204. package/src/tui/info-cmd.ts +144 -0
  205. package/src/tui/mcp-cmd.ts +128 -0
  206. package/src/tui/modes-cmd.ts +45 -0
  207. package/src/tui/overlays.ts +97 -0
  208. package/src/tui/pi-renderer.ts +424 -0
  209. package/src/tui/providers-cmd.ts +366 -0
  210. package/src/tui/renderer.ts +101 -0
  211. package/src/tui/replay-marker.ts +29 -0
  212. package/src/tui/session-cmd.ts +146 -0
  213. package/src/tui/sextant-attach.ts +68 -0
  214. package/src/tui/sextant-io.ts +184 -0
  215. package/src/tui/sextant-smoke.ts +110 -0
  216. package/src/tui/smoke.ts +72 -0
  217. package/src/tui/theme.ts +59 -0
  218. package/src/tui/todo-label.ts +7 -0
  219. package/src/workflow/engine.ts +266 -0
  220. package/tsconfig.json +30 -0
  221. package/vendor/pi-tui/LICENSE +21 -0
  222. package/vendor/pi-tui/PATCHES.md +12 -0
  223. package/vendor/pi-tui/PROVENANCE.md +12 -0
  224. package/vendor/pi-tui/README.upstream.md +854 -0
  225. package/vendor/pi-tui/native/win32/prebuilds/win32-arm64/win32-console-mode.node +0 -0
  226. package/vendor/pi-tui/native/win32/prebuilds/win32-x64/win32-console-mode.node +0 -0
  227. package/vendor/pi-tui/src/alt-screen-search.ts +158 -0
  228. package/vendor/pi-tui/src/autocomplete.ts +827 -0
  229. package/vendor/pi-tui/src/components/alt-screen-flash.ts +52 -0
  230. package/vendor/pi-tui/src/components/box.ts +138 -0
  231. package/vendor/pi-tui/src/components/cancellable-loader.ts +41 -0
  232. package/vendor/pi-tui/src/components/editor.ts +2364 -0
  233. package/vendor/pi-tui/src/components/h-stack.ts +45 -0
  234. package/vendor/pi-tui/src/components/image.ts +128 -0
  235. package/vendor/pi-tui/src/components/input.ts +448 -0
  236. package/vendor/pi-tui/src/components/loader.ts +93 -0
  237. package/vendor/pi-tui/src/components/markdown.ts +1016 -0
  238. package/vendor/pi-tui/src/components/scroll-view.ts +217 -0
  239. package/vendor/pi-tui/src/components/select-list.ts +230 -0
  240. package/vendor/pi-tui/src/components/settings-list.ts +277 -0
  241. package/vendor/pi-tui/src/components/spacer.ts +29 -0
  242. package/vendor/pi-tui/src/components/stack.ts +155 -0
  243. package/vendor/pi-tui/src/components/text.ts +108 -0
  244. package/vendor/pi-tui/src/components/truncated-text.ts +66 -0
  245. package/vendor/pi-tui/src/components/v-stack.ts +34 -0
  246. package/vendor/pi-tui/src/editor-component.ts +75 -0
  247. package/vendor/pi-tui/src/fuzzy.ts +138 -0
  248. package/vendor/pi-tui/src/index.ts +149 -0
  249. package/vendor/pi-tui/src/keybindings.ts +321 -0
  250. package/vendor/pi-tui/src/keys.ts +1402 -0
  251. package/vendor/pi-tui/src/kill-ring.ts +47 -0
  252. package/vendor/pi-tui/src/latex.ts +1381 -0
  253. package/vendor/pi-tui/src/layout-node.ts +52 -0
  254. package/vendor/pi-tui/src/layout.ts +411 -0
  255. package/vendor/pi-tui/src/native-modifiers.ts +60 -0
  256. package/vendor/pi-tui/src/native-module-path.ts +32 -0
  257. package/vendor/pi-tui/src/stdin-buffer.ts +445 -0
  258. package/vendor/pi-tui/src/terminal-colors.ts +74 -0
  259. package/vendor/pi-tui/src/terminal-image.ts +701 -0
  260. package/vendor/pi-tui/src/terminal.ts +554 -0
  261. package/vendor/pi-tui/src/tui-alt-screen.ts +1379 -0
  262. package/vendor/pi-tui/src/tui-main-screen.ts +655 -0
  263. package/vendor/pi-tui/src/tui.ts +1264 -0
  264. package/vendor/pi-tui/src/undo-stack.ts +29 -0
  265. package/vendor/pi-tui/src/utils.ts +1327 -0
  266. package/vendor/pi-tui/src/word-navigation.ts +118 -0
  267. package/vendor/pi-tui/test/test-themes.ts +39 -0
  268. package/vendor/pi-tui/test/virtual-terminal.ts +219 -0
  269. package/CHANGELOG.md +0 -512
  270. package/bin/rovecode.js +0 -24
  271. package/dist/cli/app-dybnr56b.js +0 -2
  272. package/dist/cli/ask-user-p8hq4xgj.js +0 -2
  273. package/dist/cli/auth-login-ewpgw5sm.js +0 -2
  274. package/dist/cli/auth-m8p9grty.js +0 -2
  275. package/dist/cli/bench-xv3ypwev.js +0 -9
  276. package/dist/cli/catalog-737wb2s0.js +0 -2
  277. package/dist/cli/cli-arhg40m0.js +0 -2
  278. package/dist/cli/client-cf2pxx8q.js +0 -2
  279. package/dist/cli/commands-3p7e4xxs.js +0 -2
  280. package/dist/cli/connect-3q93d7cb.js +0 -2
  281. package/dist/cli/context-cmd-eqxmxhzq.js +0 -2
  282. package/dist/cli/context-report-hbw9zfes.js +0 -2
  283. package/dist/cli/count-remote-mby98cd0.js +0 -2
  284. package/dist/cli/design-122y0axd.js +0 -2
  285. package/dist/cli/dispatch-b4egzvvh.js +0 -2
  286. package/dist/cli/doctor-x4jkv72e.js +0 -3
  287. package/dist/cli/executor-ftvg6tsy.js +0 -2
  288. package/dist/cli/export-pdgdhkch.js +0 -2
  289. package/dist/cli/files-cez9a96p.js +0 -2
  290. package/dist/cli/gauntlet-r3xxaszc.js +0 -2
  291. package/dist/cli/gauntlet-runner-r515m7kk.js +0 -10
  292. package/dist/cli/gauntlet-wave3-bnkjk2v2.js +0 -5
  293. package/dist/cli/gauntlet-wave4-acs9s60q.js +0 -14
  294. package/dist/cli/hashline-ewg5hbe3.js +0 -2
  295. package/dist/cli/http-n0kehsk8.js +0 -5
  296. package/dist/cli/index-z5qt1s76.js +0 -2
  297. package/dist/cli/install-80mp63kx.js +0 -2
  298. package/dist/cli/loop-12twjcat.js +0 -2
  299. package/dist/cli/main-01pv9206.js +0 -4
  300. package/dist/cli/main-0jys2ccn.js +0 -3
  301. package/dist/cli/main-1ztz6fkj.js +0 -10
  302. package/dist/cli/main-23q7cmww.js +0 -9
  303. package/dist/cli/main-2rzbexn2.js +0 -3
  304. package/dist/cli/main-2wyax8k9.js +0 -9
  305. package/dist/cli/main-2yeveeve.js +0 -6
  306. package/dist/cli/main-2z3dek0b.js +0 -3
  307. package/dist/cli/main-2zgsknth.js +0 -3
  308. package/dist/cli/main-45ejth3a.js +0 -4
  309. package/dist/cli/main-45rn3trk.js +0 -22
  310. package/dist/cli/main-4p4e2w7x.js +0 -4
  311. package/dist/cli/main-4y0tnfpa.js +0 -16
  312. package/dist/cli/main-5py0rkmc.js +0 -4
  313. package/dist/cli/main-6dtqmbt6.js +0 -7
  314. package/dist/cli/main-6h9x282m.js +0 -4
  315. package/dist/cli/main-6vjeds42.js +0 -3
  316. package/dist/cli/main-78gq4bt9.js +0 -6
  317. package/dist/cli/main-7jd5vh3x.js +0 -4
  318. package/dist/cli/main-7kt6r53y.js +0 -4
  319. package/dist/cli/main-8c1tbazx.js +0 -58
  320. package/dist/cli/main-9a9rnh47.js +0 -19
  321. package/dist/cli/main-9ht36z12.js +0 -3
  322. package/dist/cli/main-a2yfvcy9.js +0 -7
  323. package/dist/cli/main-a3f51n0x.js +0 -5
  324. package/dist/cli/main-b8zq261k.js +0 -3
  325. package/dist/cli/main-bxtvnf6d.js +0 -13
  326. package/dist/cli/main-edxc3yzt.js +0 -4
  327. package/dist/cli/main-evgz4mp5.js +0 -21
  328. package/dist/cli/main-f33fc5je.js +0 -9
  329. package/dist/cli/main-fvnpq46y.js +0 -12
  330. package/dist/cli/main-gbbty4d4.js +0 -3
  331. package/dist/cli/main-gth53dnt.js +0 -25
  332. package/dist/cli/main-hqbz10aw.js +0 -9
  333. package/dist/cli/main-hrrvcfan.js +0 -38
  334. package/dist/cli/main-hzwtsb2m.js +0 -5
  335. package/dist/cli/main-j7ttv0sd.js +0 -34
  336. package/dist/cli/main-jak598k9.js +0 -5
  337. package/dist/cli/main-kba6zeyd.js +0 -6
  338. package/dist/cli/main-kwwsz6rq.js +0 -3
  339. package/dist/cli/main-m8vm17zq.js +0 -3
  340. package/dist/cli/main-mg4f96e1.js +0 -3
  341. package/dist/cli/main-mg9b20ac.js +0 -18
  342. package/dist/cli/main-mgb9ccnx.js +0 -3
  343. package/dist/cli/main-mjt2p7aj.js +0 -3
  344. package/dist/cli/main-n6qrdbmy.js +0 -3
  345. package/dist/cli/main-na7wse0x.js +0 -5
  346. package/dist/cli/main-nqveez48.js +0 -4
  347. package/dist/cli/main-ntqef02r.js +0 -10
  348. package/dist/cli/main-nvc3yjay.js +0 -136
  349. package/dist/cli/main-p0cfn6nr.js +0 -16
  350. package/dist/cli/main-qj2djy17.js +0 -19
  351. package/dist/cli/main-qsevpgsv.js +0 -3
  352. package/dist/cli/main-qvarybsp.js +0 -3
  353. package/dist/cli/main-rebtt91r.js +0 -5
  354. package/dist/cli/main-rpg7h8mb.js +0 -3
  355. package/dist/cli/main-rsy72qmw.js +0 -15
  356. package/dist/cli/main-rvetps99.js +0 -18
  357. package/dist/cli/main-s4bb0jav.js +0 -3
  358. package/dist/cli/main-s9v8k74e.js +0 -3
  359. package/dist/cli/main-tjvwmscs.js +0 -3
  360. package/dist/cli/main-tkgarpjj.js +0 -4
  361. package/dist/cli/main-v8y60bb2.js +0 -3
  362. package/dist/cli/main-vhrrq337.js +0 -3
  363. package/dist/cli/main-vp2dfb7s.js +0 -4
  364. package/dist/cli/main-vqbr22sz.js +0 -8
  365. package/dist/cli/main-vxnwe5xx.js +0 -18
  366. package/dist/cli/main-wgph00xf.js +0 -5
  367. package/dist/cli/main-wk2csfnj.js +0 -5
  368. package/dist/cli/main-wm997zjx.js +0 -3
  369. package/dist/cli/main-wpkyraxh.js +0 -3
  370. package/dist/cli/main-wqt32p5x.js +0 -4
  371. package/dist/cli/main-x9ct6y1a.js +0 -3
  372. package/dist/cli/main-xfekqh9m.js +0 -7
  373. package/dist/cli/main-xt9zc3n6.js +0 -7
  374. package/dist/cli/main-xx2z3zh5.js +0 -4
  375. package/dist/cli/main-y5c82rxr.js +0 -3
  376. package/dist/cli/main-yrjt2sqt.js +0 -14
  377. package/dist/cli/main-ys6zj3yr.js +0 -3
  378. package/dist/cli/main-ywbxshqc.js +0 -8
  379. package/dist/cli/main-z13755t8.js +0 -25
  380. package/dist/cli/main-zc7pyrbj.js +0 -4
  381. package/dist/cli/main.js +0 -279
  382. package/dist/cli/market-cmd-bm5xvn9f.js +0 -5
  383. package/dist/cli/mcp-login-bthtfpt7.js +0 -2
  384. package/dist/cli/mcp-market-cmd-mbeshfyd.js +0 -2
  385. package/dist/cli/notify-54v5z9dz.js +0 -2
  386. package/dist/cli/oauth-g5gme95c.js +0 -2
  387. package/dist/cli/output-satndjap.js +0 -16
  388. package/dist/cli/profiles-sfhpbq3m.js +0 -2
  389. package/dist/cli/provider-config-hv3xtdt4.js +0 -2
  390. package/dist/cli/provider-kwzq6g84.js +0 -2
  391. package/dist/cli/registry-fh0hdnyn.js +0 -2
  392. package/dist/cli/registry-y1y8e94r.js +0 -2
  393. package/dist/cli/repl-t4z03mqq.js +0 -11
  394. package/dist/cli/resume-fqt4chg8.js +0 -2
  395. package/dist/cli/run-flags-rysbag9t.js +0 -2
  396. package/dist/cli/runtime-j19fjbsa.js +0 -2
  397. package/dist/cli/sandbox-config-g4qxd7y5.js +0 -2
  398. package/dist/cli/server-r0b6bksk.js +0 -5
  399. package/dist/cli/session-arg-txmn5g4x.js +0 -2
  400. package/dist/cli/session-ed250d9j.js +0 -2
  401. package/dist/cli/sessions-cmd-adw7svfn.js +0 -7
  402. package/dist/cli/settings-y9rzcqx8.js +0 -2
  403. package/dist/cli/setup-jmbr11j0.js +0 -2
  404. package/dist/cli/sextant-smoke-tcth0vea.js +0 -5
  405. package/dist/cli/skills-cmd-zbdy99v6.js +0 -2
  406. package/dist/cli/smoke-1bg937kx.js +0 -8
  407. package/dist/cli/start-chat-p01cdks3.js +0 -12
  408. package/dist/cli/stream-4wmyaypz.js +0 -2
  409. package/dist/cli/task-eg4s093s.js +0 -2
  410. package/dist/cli/tasks-12v9rr9k.js +0 -2
  411. package/dist/cli/thinking-a5ngvqyh.js +0 -2
  412. package/dist/cli/todo-1wxpcecx.js +0 -2
  413. package/dist/cli/tools-2ftsya7w.js +0 -2
  414. package/dist/cli/tools-x1tj4fxm.js +0 -2
  415. package/dist/cli/trust-cmd-hccxehzb.js +0 -2
  416. package/dist/cli/update-check-ygt3vd7m.js +0 -2
  417. package/dist/cli/update-cmd-v23qhr8c.js +0 -2
  418. package/dist/cli/voice-g1gtck92.js +0 -2
  419. package/dist/cli/webfetch-0nnrjgb5.js +0 -2
  420. package/dist/cli/websearch-f0vr2p7d.js +0 -2
  421. package/dist/cli/workspace-9rq1w4ta.js +0 -2
  422. package/dist/lib/index.js +0 -62
  423. package/dist/lib/models-index.json +0 -1
  424. package/dist/lib/plugins.js +0 -6
  425. package/dist/lib/providers.js +0 -17
  426. package/dist/lib/public-api.js +0 -20
  427. package/dist/rovecode.exe +0 -4
  428. /package/{dist/cli → src/providers}/models-index.json +0 -0
@@ -1,5 +0,0 @@
1
- // @bun
2
- import{wn as X}from"./main-qsevpgsv.js";import{realpathSync as _,statSync as f}from"fs";import{basename as S,dirname as $,isAbsolute as P,join as Q,parse as g,relative as D,resolve as V,sep as N}from"path";function G(q){let x=V(q);try{return _.native(x)}catch{}let z=$(x);return z===x?x:Q(G(z),S(x))}function E(q,x){return V(P(x)?x:Q(q,x))}function K(q,x){let z=D(q,x);return z===""||!P(z)&&z!==".."&&!z.startsWith(`..${N}`)}function k(q,x){return!K(G(q),G(x))}function L(q){try{return f(q).isDirectory()}catch{return!1}}function I(q){let x=G(q);return Q(L(x)?x:$(x),"*")}function v(q,x,z){let F=z.filter((B)=>B.action===C&&B.effect==="allow"&&B.resource!=="*").map((B)=>B.resource);return`${q} is outside the workspace ${x}${F.length>0?` and its roots ${F.join(", ")}`:""} \u2014 allow once/always for this directory, or start rovecode with --add-dir <dir> to make it a workspace root`}function R(q,x){let z=`--add-dir "${x}": the directory name contains "*", a rule wildcard (no escape syntax) \u2014 its allow rule would match more than that directory`;if(q.includes("*"))return z;if(!L(q))return`--add-dir "${x}" is not a directory`;let F=G(q);if(F.includes("*"))return z;if(g(F).root===F)return`--add-dir "${x}" is a filesystem root \u2014 it would disable the workspace boundary \u2014 pass --yolo instead`;return}function m(q,x=[],z=process.cwd()){let F=G(q),B=[],H=[];for(let U of x){let Y=V(z,U),Z=R(Y,U);if(Z!==void 0)throw new O(Z);let M=G(Y);if(K(F,M)||B.some((J)=>K(J,M))){H.push(U);continue}for(let J of B)if(K(M,J))H.push(J);B.splice(0,B.length,...B.filter((J)=>!K(M,J)),M)}let W=H.length===0?[]:[`rovecode: --add-dir: ${H.length} value${H.length===1?"":"s"} dropped \u2014 already inside the workspace ${F} or another root: ${H.join(", ")}`];return{dirs:B,notes:W}}class T{cwd;dirs;notes;constructor(q,x={dirs:[],notes:[]}){this.cwd=G(q),this.dirs=x.dirs,this.notes=x.notes}rootOf(q){let x=G(q);return this.dirs.find((z)=>K(z,x))}rules(){return this.dirs.map((q)=>({action:C,resource:Q(q,"*"),effect:"allow"}))}acceptEditsRules(){return this.dirs.map((q)=>({action:"file.write",resource:Q(q,"*"),effect:"allow"}))}describe(){return this.dirs.map((q)=>`+${q}`).join(" ")}promptLine(){return this.dirs.length===0?"":`
3
-
4
- Additional workspace roots (name them by absolute path): ${this.dirs.join(", ")}`}checkpointNote(){return this.dirs.length===0?"":`roots: ${this.describe()} \u2014 checkpoints cover ${this.cwd} only; a change under an added root is not snapshotted and /restore does not undo it`}}var C="file.external",O;var j=X(()=>{O=class O extends Error{constructor(q){super(q);this.name="WorkspaceRootError"}}});
5
- export{C as sl,G as tl,E as ul,K as vl,k as wl,I as xl,v as yl,R as zl,O as Al,m as Bl,T as Cl,j as Dl};
@@ -1,3 +0,0 @@
1
- // @bun
2
- import{im as V,jm as C,mm as h}from"./main-wk2csfnj.js";import{wm as E,xm as b}from"./main-ys6zj3yr.js";import{Cm as I,Dm as k,Fm as R,Gm as u,Im as N,Jm as g,ym as F,zm as T}from"./main-mjt2p7aj.js";import{$m as l,Qm as P,Rm as S,Sm as _}from"./main-2yeveeve.js";import{wn as w}from"./main-qsevpgsv.js";import{auth as W,extractWWWAuthenticateParams as f}from"@modelcontextprotocol/sdk/client/auth.js";import{OAuthError as p}from"@modelcontextprotocol/sdk/server/auth/errors.js";import{LATEST_PROTOCOL_VERSION as d}from"@modelcontextprotocol/sdk/types.js";function x(q){return`mcp:${q}`}function a(q,H){let J=S(x(q));if(H===void 0||!P(J)||J.url!==H)return;return J}function O(q,H){_(x(q),H)}function m(q,H){return typeof q.expires_in==="number"&&Number.isFinite(q.expires_in)?H+Math.max(0,q.expires_in)*1000:Number.MAX_SAFE_INTEGER}function L(q,H){let J=q.oauth?.clientId;return J?{client_id:J}:H}function y(q){let H={client_id:q.client_id};if(typeof q.client_secret==="string")H.client_secret=q.client_secret;if(typeof q.client_id_issued_at==="number")H.client_id_issued_at=q.client_id_issued_at;if(typeof q.client_secret_expires_at==="number")H.client_secret_expires_at=q.client_secret_expires_at;return H}function M(q,H){return{client_name:"rovecode",redirect_uris:[q],grant_types:["authorization_code","refresh_token"],response_types:["code"],token_endpoint_auth_method:"none",...H?{scope:H}:{}}}function c(q){let H=q.discovery;return H!==void 0&&typeof H.authorizationServerUrl==="string"?H:void 0}class v{config;record;now;refreshes=0;constructor(q,H,J=Date.now){this.config=q;this.record=H;this.now=J}get redirectUrl(){return U}get clientMetadata(){return M(U,this.config.oauth?.scope)}clientInformation(){let q=L(this.config,this.record.clientInformation);if(!q)throw new V(this.config.name);return q}saveClientInformation(){throw new V(this.config.name)}discoveryState(){return c(this.record)}saveDiscoveryState(q){this.persist({...this.record,discovery:q})}tokens(){let{access:q,refresh:H,expires:J}=this.record;if(q.length===0)return;let Q={access_token:q,token_type:"Bearer"};if(H.length>0&&this.refreshes===0)Q.refresh_token=H;if(J<Number.MAX_SAFE_INTEGER)Q.expires_in=Math.max(0,Math.floor((J-this.now())/1000));return Q}saveTokens(q){this.refreshes+=1,this.persist({...this.record,access:q.access_token,refresh:q.refresh_token??this.record.refresh,expires:m(q,this.now())})}redirectToAuthorization(){throw new V(this.config.name)}saveCodeVerifier(){}codeVerifier(){throw new V(this.config.name)}invalidateCredentials(q){let H={...this.record};if(q==="all"||q==="tokens")H.access="",H.refresh="",H.expires=0;if(q==="all"||q==="client")delete H.clientInformation;if(q==="all"||q==="discovery")delete H.discovery;this.persist(H)}persist(q){this.record=q,O(this.config.name,q)}}class A{config;callbackUrl;nonce;io;now;registered;verifier;discovery;stored;constructor(q,H,J,Q,j){this.config=q;this.callbackUrl=H;this.nonce=J;this.io=Q;this.now=j}get redirectUrl(){return this.callbackUrl}get clientMetadata(){return M(this.callbackUrl,this.config.oauth?.scope)}state(){return this.nonce}clientInformation(){return L(this.config,this.registered)}saveClientInformation(q){this.registered=y(q)}discoveryState(){return this.discovery}saveDiscoveryState(q){this.discovery=q}tokens(){return}saveTokens(q){let H=this.clientInformation(),J={type:"mcp-oauth",url:this.config.url??"",access:q.access_token,refresh:q.refresh_token??"",expires:m(q,this.now()),...H?{clientInformation:y(H)}:{},...this.discovery?{discovery:this.discovery}:{}};O(this.config.name,J),this.stored=J}redirectToAuthorization(q){this.io.notify({type:"auth_url",url:q.toString(),callbackUrl:this.callbackUrl})}saveCodeVerifier(q){this.verifier=q}codeVerifier(){if(this.verifier===void 0)throw Error("no PKCE verifier for this login");return this.verifier}}function D(q,H){if(H instanceof V||H instanceof Error&&H.message===F)return H;if(H instanceof p)return Error(`${q} failed (${H.name}: ${H.errorCode})`);let J=H instanceof Error?`${H.constructor.name}: ${H.message.slice(0,200)}`:String(H).slice(0,200);return Error(`${q} failed (${J})`)}async function Xq(q,H,J){let Q=q.name;if(q.transport==="stdio"||q.url===void 0)throw Error(`MCP server "${Q}" is a stdio server \u2014 OAuth login applies to url servers only`);if(H.signal.aborted)throw T();let j=q.url,X=`MCP server "${Q}"`,G=N(),$,Y={},z=R({nonce:G,signal:H.signal,what:X,retryHint:`Run rovecode mcp login ${Q} again.`,exchange:"token exchange",requireStateParam:!0,...J.timeoutMs!==void 0?{timeoutMs:J.timeoutMs}:{},onCode:async(Z)=>{if(!$)throw Error(`${X} token exchange failed (callback before the authorization request)`);if(await W($,{serverUrl:j,authorizationCode:Z,resourceMetadataUrl:Y.resourceMetadataUrl,scope:Y.scope,fetchFn:J.fetch}).catch((K)=>{throw D(`${X} token exchange`,K)})!=="AUTHORIZED"||!$.stored)throw Error(`${X} token exchange failed (no tokens were issued)`);return $.stored}});try{let Z;try{Z=await I(J,j,{method:"POST",headers:{"content-type":"application/json",accept:"application/json, text/event-stream"},body:s},H.signal)}catch(K){throw K instanceof Error&&K.message===F?K:Error(`${X} probe failed (${K instanceof Error?K.message.slice(0,200):String(K).slice(0,200)})`)}if(await Z.body?.cancel().catch(()=>{}),Z.status!==401)throw Error(`server does not require OAuth (HTTP ${Z.status})`);Y=f(Z),$=new A(q,z.callbackUrl,G,H,J.now);let B=await W($,{serverUrl:j,resourceMetadataUrl:Y.resourceMetadataUrl,scope:Y.scope,fetchFn:J.fetch}).catch((K)=>{throw D(`${X} authorization`,K)});if(B!=="REDIRECT")throw Error(`${X} authorization failed (expected a browser redirect, got ${B})`);return await z.result}finally{z.stop()}}function Zq(q){if(q.transport==="stdio"||q.url===void 0)return;if(C(q))return;let H=a(q.name,q.url);return H?new v(q,H):void 0}var U="http://127.0.0.1/callback/needs-login",s;var i=w(()=>{l();k();u();g();h();E();s=JSON.stringify({jsonrpc:"2.0",id:0,method:"initialize",params:{protocolVersion:d,capabilities:{},clientInfo:{name:"rovecode",version:b.version}}})});
3
- export{x as Wl,a as Xl,O as Yl,v as Zl,A as _l,Xq as $l,Zq as am,i as bm};
@@ -1,13 +0,0 @@
1
- // @bun
2
- import{Ml as b,Sl as e}from"./main-6h9x282m.js";e();import{existsSync as k}from"fs";import{extname as HH,isAbsolute as JH,join as v,resolve as D}from"path";import{readFileSync as o}from"fs";import{extname as s}from"path";import{pathToFileURL as T}from"url";var L="ROVECODE_LSP",M=["typescript-language-server","--stdio"],S=[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"],i=new Map(S.map((J)=>[J,M])),WH=`${S.join(",")}=${M.join(" ")}`,p={".ts":"typescript",".mts":"typescript",".cts":"typescript",".tsx":"typescriptreact",".js":"javascript",".mjs":"javascript",".cjs":"javascript",".jsx":"javascriptreact",".py":"python",".pyi":"python",".go":"go",".rs":"rust",".rb":"ruby",".java":"java",".kt":"kotlin",".c":"c",".h":"c",".cpp":"cpp",".cc":"cpp",".cxx":"cpp",".hpp":"cpp",".hh":"cpp",".cs":"csharp",".php":"php",".swift":"swift",".scala":"scala",".lua":"lua",".pl":"perl",".r":"r",".dart":"dart",".ex":"elixir",".exs":"elixir",".erl":"erlang",".fs":"fsharp",".clj":"clojure",".hs":"haskell",".sh":"shellscript",".bash":"shellscript",".ps1":"powershell",".sql":"sql",".html":"html",".htm":"html",".css":"css",".scss":"scss",".less":"less",".json":"json",".yaml":"yaml",".yml":"yaml",".xml":"xml",".md":"markdown",".tex":"latex",".vue":"vue",".toml":"toml"};function _(J){let H=J.toLowerCase(),Q=H.startsWith(".")?H.slice(1):H;return p[H]??(Q===""?"plaintext":Q)}function l(J){let H=J.trim().toLowerCase().replace(/^\./,"");return/^[a-z0-9_+-]+$/.test(H)?`.${H}`:null}function n(J){let H=[],Q="",$=!1,W=!1;for(let B of J){if(B==='"'){$=!$,W=!0;continue}if(!$&&/\s/.test(B)){if(W)H.push(Q);Q="",W=!1;continue}Q+=B,W=!0}if($)return null;if(W)H.push(Q);return H}function F(J){let H={table:new Map,off:!1,problems:[]},Q=J.trim();if(Q==="")return H;if(Q.toLowerCase()==="off")return H.off=!0,H;for(let $ of Q.split(";")){let W=$.trim();if(W==="")continue;let B=W.indexOf("=");if(B<0){H.problems.push(`entry "${W}" has no "=" (ext[,ext]=argv, ext=off, or the bare value off)`);continue}let C=[];for(let Z of W.slice(0,B).split(",")){let z=l(Z);if(z===null){H.problems.push(`entry "${W}": "${Z.trim()}" is not a file extension (letters, digits, _ + -)`);continue}if(H.table.has(z)||C.includes(z)){H.problems.push(`entry "${W}": ${z} is listed twice`);continue}C.push(z)}let K=W.slice(B+1).trim(),Y=null;if(K.toLowerCase()!=="off"){let Z=n(K);if(Z===null){H.problems.push(`entry "${W}": unbalanced double quote in the argv`);continue}if(Z.length===0){H.problems.push(`entry "${W}": empty argv (ext=argv, or ext=off to disable)`);continue}Y=Z}for(let Z of C)H.table.set(Z,Y)}return H}function P(J){let{problems:H}=F(J);return H.length===0?null:H.join("; ")}function N(J={}){let H=(J.env??process.env).ROVECODE_LSP;if(H!==void 0)return{value:H,source:"env"};if(J.settings!==void 0)return{value:J.settings,source:"settings"};return{value:"",source:"default"}}function A(J={}){let H=F(N(J).value);if(H.off)return new Map;let Q=new Map;for(let[$,W]of i)Q.set($,[...W]);for(let[$,W]of H.table)if(W===null)Q.delete($);else Q.set($,W);return Q}function t(J){let H=Buffer.from(JSON.stringify(J),"utf8");return Buffer.concat([Buffer.from(`Content-Length: ${H.byteLength}\r
3
- \r
4
- `,"latin1"),H])}class E{buf=Buffer.alloc(0);push(J){this.buf=Buffer.concat([this.buf,Buffer.from(J)]);let H=[];for(;;){let Q=this.buf.indexOf(`\r
5
- \r
6
- `);if(Q<0)return H;let $=this.buf.subarray(0,Q).toString("latin1"),W=Number(/Content-Length:\s*(\d+)/i.exec($)?.[1]),B=Q+4;if(!Number.isFinite(W)||W<0){this.buf=this.buf.subarray(B);continue}if(this.buf.byteLength<B+W)return H;let C=this.buf.subarray(B,B+W).toString("utf8");this.buf=this.buf.subarray(B+W);try{H.push(JSON.parse(C))}catch{}}}}class R{opts;proc=null;parser=new E;nextId=1;pending=new Map;versions=new Map;diags=new Map;gen=new Map;pubVer=new Map;waiters=new Map;stateVal="idle";initPromise=null;constructor(J){this.opts={cmd:J.cmd,root:J.root,initTimeoutMs:J.initTimeoutMs??8000,settleMs:Math.min(J.settleMs??1500,2000),debounceMs:J.debounceMs??150}}get state(){return this.stateVal}get exited(){return this.proc?.exited??null}async touch(J){if(this.stateVal==="dead")return[];if(this.initPromise??=this.start().catch((Y)=>{throw this.becomeDead(),Y}),await this.initPromise,this.stateVal!=="ready")return[];let H=T(J).href,Q=o(J,"utf8"),$=this.gen.get(H)??0,W=this.versions.get(H),B=W===void 0?0:W+1;if(this.versions.set(H,B),W===void 0){let Y=_(s(J));this.notify("textDocument/didOpen",{textDocument:{uri:H,languageId:Y,version:B,text:Q}})}else this.notify("textDocument/didChange",{textDocument:{uri:H,version:B},contentChanges:[{text:Q}]});let C=Date.now()+this.opts.settleMs;if(!await this.waitPublish(H,$,C,B))return[];let K=this.gen.get(H)??0;while(Date.now()+this.opts.debounceMs<=C){if(!await this.waitPublish(H,K,Math.min(C,Date.now()+this.opts.debounceMs),B))break;K=this.gen.get(H)??0}return this.diags.get(H)??[]}kill(){this.becomeDead()}async start(){this.stateVal="starting",this.proc=Bun.spawn(this.opts.cmd,{cwd:this.opts.root,stdin:"pipe",stdout:"pipe",stderr:"ignore"}),this.proc.unref(),this.pump(),this.proc.exited.then(()=>this.becomeDead());let J=await this.request("initialize",{processId:process.pid,rootUri:T(this.opts.root).href,capabilities:{textDocument:{synchronization:{didOpen:!0,didChange:!0},publishDiagnostics:{versionSupport:!1}}},workspaceFolders:null},this.opts.initTimeoutMs);if(J.error)throw Error(`lsp initialize failed: ${J.error.message}`);this.notify("initialized",{}),this.stateVal="ready"}async pump(){let J=this.proc;if(!J)return;try{for await(let H of J.stdout)for(let Q of this.parser.push(H))try{this.dispatch(Q)}catch{}}catch{}}dispatch(J){if(!J||typeof J!=="object")return;let H=J;if(typeof H.id==="number"&&H.method===void 0){let Q=this.pending.get(H.id);if(Q)this.pending.delete(H.id),Q(H);return}if(H.method==="textDocument/publishDiagnostics"){let Q=H.params;if(!Q||typeof Q!=="object"||typeof Q.uri!=="string")return;if(this.diags.set(Q.uri,Array.isArray(Q.diagnostics)?Q.diagnostics:[]),typeof Q.version==="number")this.pubVer.set(Q.uri,Q.version);else this.pubVer.delete(Q.uri);this.gen.set(Q.uri,(this.gen.get(Q.uri)??0)+1);for(let $ of[...this.waiters.get(Q.uri)??[]])$();return}if(typeof H.id==="number")this.send({jsonrpc:"2.0",id:H.id,result:null})}request(J,H,Q){let $=this.nextId++;return this.send({jsonrpc:"2.0",id:$,method:J,params:H}),new Promise((W,B)=>{let C=setTimeout(()=>{this.pending.delete($),B(Error(`lsp request ${J} timed out after ${Q}ms`))},Q);this.pending.set($,(K)=>{clearTimeout(C),W(K)})})}notify(J,H){this.send({jsonrpc:"2.0",method:J,params:H})}send(J){let H=this.proc?.stdin;if(!H||this.stateVal==="dead")return;try{H.write(t(J)),H.flush()}catch{this.becomeDead()}}waitPublish(J,H,Q,$){let W=()=>{if((this.gen.get(J)??0)<=H)return!1;let B=this.pubVer.get(J);return B===void 0||B===$};if(W())return Promise.resolve(!0);if(this.stateVal==="dead"||Q<=Date.now())return Promise.resolve(!1);return new Promise((B)=>{let C=this.waiters.get(J)??new Set;this.waiters.set(J,C);let K=()=>{clearTimeout(Z),C.delete(Y),B(W())},Y=()=>{if(W()||this.stateVal==="dead")K()},Z=setTimeout(K,Q-Date.now());C.add(Y)})}becomeDead(){if(this.stateVal==="dead")return;this.stateVal="dead";for(let[J,H]of[...this.pending])this.pending.delete(J),H({jsonrpc:"2.0",id:J,error:{code:-1,message:"lsp server dead"}});for(let J of this.waiters.values())for(let H of[...J])H();try{this.proc?.kill()}catch{}try{this.proc?.ref()}catch{}}}var G=20;function m(J,H,Q="typescript-language-server"){let $=H.filter((C)=>C.severity===1);if($.length===0)return"";let W=$.slice(0,G).map((C)=>`ERROR [${C.range.start.line+1}:${C.range.start.character+1}] ${C.message}`),B=$.length>G?`
7
- ... and ${$.length-G} more`:"";return`
8
-
9
- lsp-gate (${Q}): ${$.length} error(s) in ${J} \u2014 fix before proceeding:
10
- ${W.join(`
11
- `)}${B}`}var c=M.join("\x00");function h(J){try{let H=b(J).lsp;return typeof H==="string"?H:void 0}catch{return}}function f(J){let H=J.split(/[\\/]/).pop()??"",$=(H.replace(/\.[^.]+$/,"")||H).replace(/[^A-Za-z0-9._-]/g,"");return $===""?"lsp":$}function g(J,H,Q){let $=J[0];if($===void 0||$==="")return null;let W=/[\\/]/.test($)?k(D(H,$))?D(H,$):null:Q($);return W===null?null:[W,...J.slice(1)]}function u(J,H){return H.servers??A({env:H.env??process.env,settings:H.settingsValue??h(J)})}function w(J={}){let H=J.root??process.cwd(),Q=Math.min(J.hardDeadlineMs??2000,2000),$=J.which??((Z)=>Bun.which(Z)),W={...J.settleMs!==void 0?{settleMs:J.settleMs}:{},...J.initTimeoutMs!==void 0?{initTimeoutMs:J.initTimeoutMs}:{},...J.debounceMs!==void 0?{debounceMs:J.debounceMs}:{}},B,C=new Map,K=null,Y=(Z)=>{let z=Z.join("\x00"),O=z===c,I=O&&J.serverName!==void 0?J.serverName:f(Z[0]??""),j=C.get(z);if(j===void 0){let q=O&&J.cmd!==void 0?J.cmd:g(O&&J.serverName!==void 0?[J.serverName,...Z.slice(1)]:Z,H,$);if(j=q===null?null:new R({cmd:q,root:H,...W}),C.set(z,j),j!==null)K=j}return{client:j,label:I}};return{get client(){return K},clients(){return[...C.values()].filter((Z)=>Z!==null)},async note(Z){B??=u(H,J);let z=B.get(HH(Z).toLowerCase());if(z===void 0)return"";let{client:O,label:I}=Y(z);if(O===null||O.state==="dead")return"";let j=O,q=await new Promise((U)=>{let V=setTimeout(()=>U(null),Q);j.touch(Z).then((d)=>{clearTimeout(V),U(d)},()=>{clearTimeout(V),U(null)})});return q===null?"":m(Z,q,I)},dispose(){for(let Z of C.values())Z?.kill()}}}function y(J,H=(W)=>Bun.which(W),Q="typescript-language-server",$={}){let W=[];if($.servers===void 0){let K=N({env:$.env??process.env,settings:$.settingsValue??h(J)}),Y=P(K.value);if(Y!==null)W.push(`lsp: the \`lsp\` table (${K.source==="env"?L:".rovecode/settings.json lsp"}) has a problem \u2014 ${Y}; that entry is ignored, the rest of the table applies`)}let B=u(J,$),C=new Map;for(let[K,Y]of B){let Z=Y.join("\x00"),z=C.get(Z);if(z)z.exts.push(K);else C.set(Z,{argv:Y,exts:[K]})}for(let[K,{argv:Y,exts:Z}]of C){if(K===c){if(!k(v(J,"tsconfig.json")))continue;if(H(Q)!==null)continue;W.push(`lsp: ${Q} is not on PATH \u2014 edits and writes are NOT type-checked, and the model gets no diagnostics after them (npm i -g typescript-language-server typescript)`);continue}if(g(Y,J,H)!==null)continue;let z=Y[0]??"",O=/[\\/]/.test(z)?`is not at ${D(J,z)}`:"is not on PATH";W.push(`lsp: ${z} (${Z.sort().join(", ")}) ${O} \u2014 edits to those files are NOT checked (the \`lsp\` setting names it; fix the path or install it)`)}return W}function a(J,H=($)=>Bun.which($),Q="typescript-language-server"){let $=y(J,H,Q);return $.length===0?null:$.map((W,B)=>B===0?W:` ${W.replace(/^lsp: /,"")}`).join(`
12
- `)}var QH=4,X=new Map;function x(J,H,Q){let $=D(H??process.cwd()),W=X.get($);if(W!==void 0)X.delete($);else if(W=w({...Q,root:$}),X.size>=QH)for(let[B,C]of X){X.delete(B),C.dispose();break}return X.set($,W),W.note(J)}function r(J,H=x){if(J.kind!=="write")return J;return{...J,async execute(Q,$){let W=await J.execute(Q,$),B=Q.path;if(!W.ok||typeof B!=="string")return W;let C=JH(B)?B:v($.cwd,B);if(!k(C))return W;let K=await H(C);return K===""?W:{...W,output:W.output+K}}}}
13
- export{a as Uc,x as Vc,r as Wc};
@@ -1,4 +0,0 @@
1
- // @bun
2
- import{Il as D,Jl as E,Kl as K,Sl as j}from"./main-6h9x282m.js";import{om as L,tm as M,vm as b}from"./main-y5c82rxr.js";import{nn as V,pn as Y,qn as A,tn as _}from"./main-nqveez48.js";b();j();_();import{existsSync as W,readFileSync as N}from"fs";import{join as I}from"path";var X=(z,H=100)=>{let q=typeof z==="string"?z:JSON.stringify(z);return q.length>H?`${q.slice(0,H-1)}\u2026`:q};function g(z,H){let q=[],Q=E("project",z);if(W(Q)){let G=K(Q),J=D.filter((U)=>G[U]!==void 0&&!(U==="verify"&&G.verify===!1)).map((U)=>`${U}: ${X(G[U])}`);if(J.length>0)q.push({file:Q,kind:"settings",status:V(H,Q),carries:J})}for(let G of["hooks.ts","hooks.js"]){let J=I(z,".rovecode",G);if(W(J))q.push({file:J,kind:"hooks",status:V(H,J),carries:[`code imported in-process at boot (${P(J)} lines) \u2014 read it before approving`]})}let Z=I(z,".rovecode","sandbox.json");if(W(Z)){let G=[];try{let J=JSON.parse(N(Z,"utf8"));if(J&&typeof J==="object"){if(J.rung!==void 0)G.push(`rung: ${X(J.rung)}`);if(J.dockerImage!==void 0)G.push(`dockerImage: ${X(J.dockerImage)}`)}if(G.length===0)G.push("no rung or image \u2014 nothing gated")}catch{G.push("not valid JSON \u2014 a boot refuses it either way")}q.push({file:Z,kind:"sandbox",status:V(H,Z),carries:G})}let $=I(z,".rovecode","memory","MEMORY.md");if(W($)){let G=V(H,$);if(G!=="trusted")q.push({file:$,kind:"memory",status:G,carries:[`${P($)} lines of text placed in front of the model in every run \u2014 read it before approving`]})}let O=L(z);for(let G of[O.harvest,O.project]){if(!W(G))continue;let J=[],B=M(G,J,process.env,{allowPlaceholders:!0}).map((R)=>`${R.name}: ${R.transport==="stdio"?X([R.command,...R.args??[]].filter(Boolean).join(" ")):X(R.url??"")}`);for(let R of J)B.push(`! ${R}`);if(B.length===0)B.push("no servers");q.push({file:G,kind:"mcp",status:V(H,G),carries:B})}return q}function P(z){try{return N(z,"utf8").split(`
3
- `).length}catch{return 0}}var C={settings:"settings \u2014 commands this repo asks us to run",hooks:"hooks \u2014 code this repo asks us to import",sandbox:"sandbox \u2014 the executor this repo asks us to use",mcp:"MCP servers this repo asks us to start",memory:"memory \u2014 text this repo asks us to put in the prompt"};function x(z){if(z.length===0)return["no gated project files here (.rovecode/settings.json with verify/lsp/notify_command, hooks.ts, sandbox.json, mcp.json, .mcp.json) \u2014 nothing to trust"];let H=[];for(let q of z){H.push(`${q.status==="trusted"?"\u2713 trusted ":"\xB7 UNTRUSTED"} ${q.file} (${C[q.kind]})`);for(let Q of q.carries)H.push(` ${Q}`)}return H}function y(z,H){return H.map((q)=>{let Q=Y(z,q.file);return Q.ok?`trusted ${q.file} (${Q.digest.slice(0,12)}\u2026)`:Q.reason})}function S(z,H){let q=H.filter((Q)=>A(z,Q.file));return q.length?q.map((Q)=>`untrusted ${Q.file}`):["nothing was trusted here"]}function f(z){return z.filter((H)=>H.status!=="trusted")}
4
- export{g as C,x as D,y as E,S as F,f as G};
@@ -1,21 +0,0 @@
1
- // @bun
2
- import{wn as D}from"./main-qsevpgsv.js";import{execFile as R}from"child_process";import{appendFileSync as u,existsSync as P,mkdirSync as U,readFileSync as S,realpathSync as W,rmSync as L,writeFileSync as x}from"fs";import{join as M,resolve as j}from"path";function ZB(B){return B.findLast((J)=>J.role==="user")?.id}function C(B,J,q=B.find(($)=>!$.startsWith("-"))??"",Z={}){let $={...process.env};for(let N of["GIT_DIR","GIT_WORK_TREE","GIT_INDEX_FILE","GIT_OBJECT_DIRECTORY","GIT_COMMON_DIR"])delete $[N];return Object.assign($,Z),new Promise((N,z)=>{R("git",B,{cwd:J,env:$,windowsHide:!0,maxBuffer:16777216},(K,Q,Y)=>{if(K)z(Error(`git ${q} failed: ${Y.trim()||K.message}`));else N(Q.trim())})})}function T(B){let J=B;try{J=(W.native??W)(B)}catch{}return process.platform==="win32"?J.toLowerCase():J}function I(B,J,q){let Z=J.replace(/[^A-Za-z0-9._-]/g,"_"),$=/^\.*$/.test(Z)?Z.replace(/\./g,"_")||"_":Z;return M(q??M(B,".rovecode","checkpoints"),$)}class A{workspace;gitDir;sidecar;log=[];constructor(B,J,q){this.workspace=B;this.gitDir=J;this.sidecar=q}git(...B){return C(["--git-dir",this.gitDir,"--work-tree",this.workspace,...B],this.workspace,B[0])}static async init(B){let J=j(B.workspace),q=I(J,B.sessionId,B.shadowRoot),Z=M(q,".git");U(q,{recursive:!0});let $=new A(J,Z,M(q,"checkpoints.jsonl"));if(!P(M(Z,"HEAD"))){await C(["init"],q);for(let[N,z]of[["core.worktree",J],["commit.gpgSign","false"],["core.autocrlf","false"],["user.name","Rovecode Checkpoint"],["user.email","checkpoint@rovecode.local"]])await $.git("config",N,z)}else{let N=await $.git("config","core.worktree").catch(()=>"");if(T(j(N))!==T(J))throw Error(`checkpoints: shadow repo belongs to ${N}, not ${J}`)}return U(M(Z,"info"),{recursive:!0}),x(M(Z,"info","exclude"),w.join(`
3
- `)+`
4
- `),$.loadSidecar(),$}loadSidecar(){if(!P(this.sidecar))return;for(let B of S(this.sidecar,"utf8").split(`
5
- `)){if(!B.trim())continue;try{let J=JSON.parse(B);if(typeof J.hash==="string"&&typeof J.label==="string")this.log.push(J)}catch{}}}async snapshot(B,J){await this.git("add",".","--ignore-errors"),await this.git("commit","--allow-empty","--no-verify","-m",`rovecode-checkpoint: ${B}`);let Z={hash:await this.git("rev-parse","HEAD"),label:B,createdAt:Date.now(),...J!==void 0?{entryId:J}:{}};return u(this.sidecar,JSON.stringify(Z)+`
6
- `),this.log.push(Z),Z}list(){return[...this.log]}async position(){let B={at:null,previous:null};if(this.log.length===0)return B;let J=M(this.gitDir,"rovecode-undo-index"),q=["--git-dir",this.gitDir,"--work-tree",this.workspace];try{L(J,{force:!0}),await C([...q,"add",".","--ignore-errors"],this.workspace,"add",{GIT_INDEX_FILE:J});let Z=await C([...q,"write-tree"],this.workspace,"write-tree",{GIT_INDEX_FILE:J}),$=[];for(let K=0;K<this.log.length;K+=200)$.push(...(await this.git("rev-parse",...this.log.slice(K,K+200).map((Q)=>`${Q.hash}^{tree}`))).split(`
7
- `).map((Q)=>Q.trim()));let N=$.lastIndexOf(Z);if(N<0)return B;let z=this.log[N];for(let K of(await this.git("rev-list",z.hash)).split(`
8
- `).slice(1)){let Q=this.log.findLastIndex((Y)=>Y.hash===K.trim());if(Q>=0&&$[Q]!==Z)return{at:z,previous:this.log[Q]}}return{at:z,previous:null}}catch{return B}finally{L(J,{force:!0})}}async changedSince(B){try{let J=[];for(let q of(await this.git("diff","--name-status",B)).split(`
9
- `)){let Z=/^([A-Z])\S*\t(.+)$/.exec(q.trim());if(Z)J.push({status:Z[1],path:Z[2].split("\t").at(-1)})}for(let q of(await this.git("ls-files","--others","--exclude-standard")).split(`
10
- `))if(q.trim())J.push({status:"?",path:q.trim()});return J}catch{return null}}async restore(B,J){let q=this.log.filter(($)=>$.hash===B||$.hash.startsWith(B)),Z=q.at(-1);if(!Z||B.length<4)return{ok:!1,error:`no checkpoint matches ${B}`};if(new Set(q.map(($)=>$.hash)).size>1)return{ok:!1,error:`ambiguous checkpoint prefix ${B}`};if(J!=="files"&&Z.entryId===void 0)return{ok:!1,error:`checkpoint ${Z.hash.slice(0,8)} has no session entryId`};if(J!=="conversation")try{await this.git("reset","--hard",Z.hash),await this.git("clean","-fd")}catch($){return{ok:!1,error:$ instanceof Error?$.message:String($)}}return{ok:!0,mode:J,checkpoint:Z,...J!=="files"&&Z.entryId!==void 0?{entryId:Z.entryId}:{}}}}var JB,w;var y=D(()=>{JB=new Set(["write","execute"]);w=[".git/",".rovecode/","node_modules/","dist/","build/","out/",".next/","__pycache__/",".venv/","venv/",".DS_Store","*.mp4","*.m4v","*.mov","*.avi","*.mkv","*.webm","*.wmv","*.flv","*.mpg","*.mpeg","*.mp3","*.m4a","*.wav","*.flac","*.ogg","*.aac","*.wma","*.png","*.jpg","*.jpeg","*.gif","*.bmp","*.ico","*.webp","*.tif","*.tiff","*.heic","*.avif","*.psd","*.zip","*.tar","*.gz","*.tgz","*.bz2","*.xz","*.7z","*.rar","*.iso","*.dmg","*.exe","*.dll","*.so","*.dylib","*.node","*.wasm","*.o","*.a","*.class","*.jar","*.pyc","*.sqlite","*.sqlite3","*.db","*.mdb","*.log"]});import{readdirSync as g,readFileSync as k,statSync as h}from"fs";import{join as l}from"path";function _(B){return B.toLowerCase().split(/[^\p{L}\p{N}]+/u).filter((J)=>J.length>0)}function n(B){let J;try{J=JSON.parse(B)}catch{return null}if(!J||typeof J!=="object")return null;let q=J;if(typeof q.id!=="string")return null;let Z=q.entry;if(!Z||typeof Z!=="object"||!("role"in Z))return null;let $=Z.parts;if(!Array.isArray($))return null;let N=[];for(let K of $)if(K&&typeof K==="object"&&K.kind==="text"&&typeof K.text==="string")N.push(K.text);let z=N.join(" ").trim();if(!z)return null;return{entryId:q.id,text:z,timestamp:typeof q.createdAt==="number"?q.createdAt:0}}function a(B){return B.split(`
11
- `).map((J)=>o.test(J)?"[BLOCKED]":J).join(`
12
- `)}function f(B){let J=B.charCodeAt(0);if(J>=56320&&J<=57343)B=B.slice(1);let q=B.charCodeAt(B.length-1);if(q>=55296&&q<=56319)B=B.slice(0,-1);return B}function r(B,J){let q=B.replace(/\s+/g," ").trim(),Z=q.toLowerCase(),$=-1;for(let K of J){let Q=Z.indexOf(K);if(Q!==-1&&($===-1||Q<$))$=Q}let N=$===-1?0:Math.max(0,$-p),z=f(q.slice(N,N+v));return(N>0?"\u2026":"")+z+(N+v<q.length?"\u2026":"")}class E{root;docs=new Map;postings=new Map;files=new Map;constructor(B){this.root=B}refresh(){let B={scanned:0,indexed:0,removed:0},J=[];try{J=g(this.root)}catch{}let q=new Set;for(let Z of J){let $=l(this.root,Z,"entries.jsonl"),N;try{let K=h($);N={mtimeMs:K.mtimeMs,size:K.size}}catch{continue}q.add(Z),B.scanned++;let z=this.files.get(Z);if(z&&z.mtimeMs===N.mtimeMs&&z.size===N.size)continue;this.dropSession(Z),this.indexFile(Z,$,N),B.indexed++}for(let Z of[...this.files.keys()])if(!q.has(Z))this.dropSession(Z),B.removed++;return B}dropSession(B){let J=this.files.get(B);if(!J)return;for(let q of J.docKeys){let Z=this.docs.get(q);if(Z)for(let $ of Z.tokens.keys()){let N=this.postings.get($);if(N){if(N.delete(q),N.size===0)this.postings.delete($)}}this.docs.delete(q)}this.files.delete(B)}indexFile(B,J,q){let Z=[],$="";try{$=k(J,"utf8")}catch{}for(let N of $.split(`
13
- `)){if(!N.trim())continue;let z=n(N);if(!z)continue;let K=`${B.length}:${B}:${z.entryId}`;if(this.docs.has(K))continue;let Q=new Map;for(let Y of _(z.text))Q.set(Y,(Q.get(Y)??0)+1);if(Q.size===0)continue;this.docs.set(K,{sessionId:B,entryId:z.entryId,text:z.text,timestamp:z.timestamp,tokens:Q}),Z.push(K);for(let[Y,G]of Q){let V=this.postings.get(Y);if(!V)V=new Map,this.postings.set(Y,V);V.set(K,G)}}this.files.set(B,{mtimeMs:q.mtimeMs,size:q.size,docKeys:Z})}search(B,J,q){this.refresh();let Z=[...new Set(_(B.slice(0,F)))];if(Z.length===0)return[];let $=null;for(let z of Z){let K=new Map,Q=this.postings.get(z);if(Q)for(let[G,V]of Q)K.set(G,{ex:V,part:0});if(z.length>=d)for(let[G,V]of this.postings){if(G===z||!G.includes(z))continue;for(let[H,X]of V){let O=K.get(H)??{ex:0,part:0};O.part+=X,K.set(H,O)}}let Y=new Map;for(let[G,V]of K){let H=$===null?{exact:0,weighted:0}:$.get(G);if(H===void 0)continue;Y.set(G,{exact:H.exact+(V.ex>0?1:0),weighted:H.weighted+c*V.ex+i*V.part})}if($=Y,$.size===0)return[]}return[...$??new Map].flatMap(([z,K])=>{let Q=this.docs.get(z);return Q&&Q.sessionId!==q?[{key:z,cand:K,doc:Q}]:[]}).sort((z,K)=>K.cand.exact-z.cand.exact||K.cand.weighted-z.cand.weighted||K.doc.timestamp-z.doc.timestamp||(z.key<K.key?-1:1)).slice(0,Math.max(0,J)).map(({doc:z})=>({sessionId:z.sessionId,entryId:z.entryId,preview:a(r(z.text,Z)),timestamp:z.timestamp}))}}function zB(B,J={}){let q=new E(B),Z=Math.max(1,J.maxResults??m);return{schema:{name:"recall",description:"Search past session transcripts (cross-session recall). Full-text over prior conversation "+"message text \u2014 no LLM. Terms are ANDed; exact word matches rank above partial (substring) "+`matches. Returns up to ${Z} hits: sessionId, entryId, timestamp, and a short preview. Use for questions about past conversations: 'what did we decide about X', 'where did we leave Y'.`,args:{type:"object",properties:{query:{type:"string",description:"words to find in past sessions"},limit:{type:"integer",description:`max hits (default ${Math.min(b,Z)}, max ${Z})`}},required:["query"]}},kind:"read",sequential:!1,async execute($,N){let z=$&&typeof $==="object"?$:{},K={query:z.query,limit:z.limit};if(typeof K.query!=="string"||K.query.trim().length===0)return{ok:!1,output:"recall failed: query must be a non-empty string"};let Q=K.query.trim(),Y=Q.length>F?f(Q.slice(0,F))+"\u2026":Q,G=Math.min(b,Z);if(typeof K.limit==="number"&&Number.isFinite(K.limit))G=Math.trunc(K.limit);G=Math.max(1,Math.min(G,Z));let V=q.search(K.query,G,N.sessionId);if(V.length===0)return{ok:!0,output:`recall: no matches for "${Y}" \u2014 terms are ANDed; try fewer or broader terms`,data:{hits:V}};let H=V.map((O)=>`- [${O.sessionId}] entry ${O.entryId} @ ${O.timestamp>0?new Date(O.timestamp).toISOString():"unknown time"}
14
- ${O.preview}`),X=`recall: ${V.length} hit(s) for "${Y}"
15
- `+H.join(`
16
- `);if(J.summarize)try{let O=await J.summarize(K.query,V);if(O)X+=`
17
-
18
- summary: ${O}`}catch(O){X+=`
19
-
20
- (summarize step failed: ${O instanceof Error?O.message:String(O)}; hits above are unaffected)`}return{ok:!0,output:X,data:{hits:V}}}}}var m=10,b=5,v=120,p=40,d=3,F=512,c=2,i=1,o;var t=D(()=>{o=/(?:ignore previous|disregard above|system prompt)/i});
21
- export{JB as md,ZB as nd,I as od,A as pd,y as qd,E as rd,zB as sd,t as td};
@@ -1,9 +0,0 @@
1
- // @bun
2
- import{th as G,vh as K}from"./main-xt9zc3n6.js";import{wn as J}from"./main-qsevpgsv.js";function H(b,A,q){let p=G(b,A,q);return`- ${b.name}${b.version?` (v${b.version})`:""}: ${b.description}${p==="stale"?" [stale]":""}`}function W(b,A=Date.now()){let q=b.list();if(q.length===0||q.length>Q)return"";return q.map((p)=>H(p,b.usage(p.name),A)).join(`
3
- `)}function Y(b){return[{schema:{name:"skill_view",description:"Read one skill's full instructions. Use when a skill in the index matches the task.",args:{type:"object",properties:{name:{type:"string",description:"skill name from the index"}},required:["name"]}},kind:"read",sequential:!0,execute(p){let C=p,z=typeof C.name==="string"?C.name:"",j=b.get(z);if(!j)return Promise.resolve({ok:!1,output:`no skill named '${z}'`});let F=b.bumpUsage(j),B=`# ${j.name} (v${j.version})
4
-
5
- ${j.fullDescription}
6
-
7
- `;return Promise.resolve({ok:!0,output:B+j.body,data:F})}},{schema:{name:"skills_list",description:"List available skills (name, version, description, staleness). Use to discover skills when the system prompt has no skill index.",args:{type:"object",properties:{}}},kind:"read",execute(p,C){b.scan();let z=b.list();if(z.length===0)return Promise.resolve({ok:!0,output:"no skills installed"});let j=Date.now(),F=z.map((B)=>H(B,b.usage(B.name),j));return Promise.resolve({ok:!0,output:F.join(`
8
- `),data:{count:z.length}})}}]}var Q=50;var S=J(()=>{K()});
9
- export{Q as ud,W as vd,Y as wd,S as xd};
@@ -1,12 +0,0 @@
1
- // @bun
2
- import{kh as D,lh as k}from"./main-4y0tnfpa.js";import{sh as A,vh as C}from"./main-xt9zc3n6.js";import{Ah as N,Dh as E,xh as F,yh as I,zh as L}from"./main-ntqef02r.js";import{$m as R,Lm as j}from"./main-2yeveeve.js";import{wn as H}from"./main-qsevpgsv.js";function O(z,J,K,V,Z){if(K.busy){V.addSystemNote("finish or interrupt the run first (Esc)","warn");return}if(!z.toggle(J)){V.addSystemNote(`already in ${J} mode`);return}let $=z.modelFor();K.mode=z.mode,K.model=$.model,K.provider=$.provider,V.addSystemNote(J==="plan"?"plan mode: read-only tools \u2014 writes/shell/spawn denied by policy":"act mode: full toolset restored"),Z()}function s(z,J,K){if(J.permissionRules=F(z.mode,J.permissionRules),z.mode!=="plan")return;delete J.verify;let V=K.systemPrompt;K.systemPrompt=(Z)=>(typeof V==="function"?V(Z):V)+`
3
-
4
- `+I()}function d(z,J){let K=z.consumeSwitchNotice();if(K)J.append(L(K,J.messages().at(-1)?.id??null))}function c(z,J){let K=N(z);return K?`mode \u2192 ${K.to}`:J}var P=H(()=>{E()});import{readdirSync as S,readFileSync as v,statSync as b}from"fs";import{join as U,resolve as T}from"path";function M(z,J){return z.length>J?z.slice(0,J-1)+"\u2026":z}function g(z){let J=z.charCodeAt(0)===65279?z.slice(1):z,K={},V=J;if(J.startsWith("---")){if(!J.endsWith(`
5
- `))J+=`
6
- `;let $=A(J);if(!$)return{error:"unterminated frontmatter (no closing ---)"};K=$.fm,V=$.body}if(V=V.trim(),V==="")return{error:"empty command body (nothing to send)"};let Z=($)=>{let G=K[$]?.trim();return G?G:void 0},Y=Z("mode");if(Y!==void 0&&Y!=="plan"&&Y!=="act")return{error:`mode must be "plan" or "act" (got "${M(Y,40)}")`};return{description:Z("description"),model:Z("model"),mode:Y,body:V}}function l(z){let J=z.replace(/\$\$/g,""),K=[...new Set(J.match(/\$[1-9]/g)??[])].sort();if(J.includes("$ARGUMENTS"))K.push("$ARGUMENTS");return K}function x(z,J={}){let K=[],V=new Set(J.reserved??[]),Z=U(J.home??j(),"commands"),Y=U(z,".rovecode","commands"),$=(q)=>(J.extraDirs??[]).filter((Q)=>Q.scope===q).map((Q)=>[q,Q.dir]),G=T(Z)===T(Y)?[["project",Y],...$("user"),...$("project")]:[["user",Z],...$("user"),["project",Y],...$("project")],B=new Map;for(let[q,Q]of G)for(let W of i(Q,q,K)){if(V.has(W.name)){K.push(`/${W.name} is a built-in command \u2014 built-in kept (${W.path})`);continue}let X=B.get(W.name);if(X?.scope===q){K.push(`${W.path}: /${W.name} already defined by ${X.path} \u2014 first kept`);continue}B.set(W.name,W)}return{commands:[...B.values()].sort((q,Q)=>q.name.localeCompare(Q.name)),warnings:K}}function p(z){try{return b(z).isFile()}catch{return!0}}function i(z,J,K){let V;try{V=S(z,{withFileTypes:!0}).filter((Y)=>/\.md$/i.test(Y.name)&&(Y.isFile()||Y.isSymbolicLink()&&p(U(z,Y.name)))).map((Y)=>Y.name).sort()}catch{return[]}let Z=[];for(let Y of V){let $=U(z,Y),G=Y.slice(0,-3).toLowerCase();if(!y.test(G)){K.push(`${$}: skipped \u2014 command name "${G}" must match [a-z0-9_-]+`);continue}let B;try{B=v($,"utf8")}catch(Q){K.push(`${$}: skipped \u2014 unreadable (${Q instanceof Error?Q.message:String(Q)})`);continue}let q=g(B);if("error"in q){K.push(`${$}: skipped \u2014 ${q.error}`);continue}Z.push({name:G,description:M(q.description??`custom command (${Y})`,u),model:q.model,mode:q.mode,body:q.body,hints:l(q.body),path:$,scope:J})}return Z}function _(z,J){let K=J.trim(),V=(K.match(f)??[]).map(($)=>$.replace(h,"")),Z=!1,Y=z.body.replace(w,($,G)=>{if(G==="$")return"$";return Z=!0,G==="ARGUMENTS"?K:V[Number(G)-1]??""});return Z||K===""?Y:`${Y}
7
-
8
- ${K}`}function Yz(z,J,K={}){let V=D(z,J);if(V!==void 0)return V;let Z=/^\/(\S+)(?:\s+([\s\S]*))?$/.exec(z.trim());if(!Z)return z;let Y=x(J,K).commands.find(($)=>$.name===Z[1].toLowerCase());return Y?_(Y,Z[2]??""):z}function Zz(z){return z.map((J)=>({name:J.name,description:J.description}))}function $z(z){if(z.length===0)return"";return`
9
- custom:
10
- `+z.map((J)=>`/${J.name}${J.hints.length>0?" "+J.hints.join(" "):""} \u2014 ${J.description} (${J.scope})`).join(`
11
- `)}function qz(z,J,K,V){let Z=J.find((Y)=>Y.name===K);if(!Z)return!1;return n(z,Z,V),!0}async function n(z,J,K){if(z.state.busy){z.renderer.addSystemNote("finish or interrupt the run first (Esc)","warn");return}if(J.mode!==void 0&&J.mode!==z.modes.mode)O(z.modes,J.mode,z.state,z.renderer,z.pushStatus);let V=z.modes.modelFor().model,Z=J.model!==void 0&&J.model!==V;if(Z)z.modes.setModel({model:J.model}),z.state.model=z.modes.modelFor().model,z.renderer.addSystemNote(`model \u2192 ${J.model} for /${J.name} (restored after the run)`),z.pushStatus();try{await z.submit(_(J,K))}finally{if(Z&&z.modes.modelFor().model===J.model)z.modes.setModel({model:V}),z.state.model=V,z.pushStatus()}}var y,f,h,w,u=200;var m=H(()=>{R();C();P();k();y=/^[a-z0-9_-]+$/,f=/(?:"[^"]*"|'[^']*'|[^\s"']+)/g,h=/^["']|["']$/g,w=/\$(\$|ARGUMENTS|[1-9])/g});
12
- export{O as Wg,s as Xg,d as Yg,c as Zg,P as _g,g as $g,l as ah,x as bh,_ as ch,Yz as dh,Zz as eh,$z as fh,qz as gh,n as hh,m as ih};
@@ -1,3 +0,0 @@
1
- // @bun
2
- import{wn as N}from"./main-qsevpgsv.js";import{createHash as P}from"crypto";function Y(z,B=new Set){if(z===null)return"null";switch(typeof z){case"boolean":return z?"true":"false";case"number":return Number.isFinite(z)?JSON.stringify(z):String(z);case"string":return JSON.stringify(z);case"object":break;default:return JSON.stringify(String(z))}let K=z;if(B.has(K))return'"[circular]"';B.add(K);try{if(Array.isArray(K))return`[${K.map((Q)=>Y(Q,B)).join(",")}]`;let M=K;return`{${Object.keys(M).sort().map((Q)=>`${JSON.stringify(Q)}:${Y(M[Q],B)}`).join(",")}}`}finally{B.delete(K)}}function $(z){if(typeof z==="object"&&z!==null&&!Array.isArray(z))return z;return{}}function G(z){return P("sha256").update(Buffer.from(z,"utf16le")).digest("hex")}function y(z,B){return`${z}\x00${G(Y($(B)))}`}function W(z,B){if(z==="mcp_call"){let K=$(B).tool;if(typeof K==="string"&&K.length>0)return K}return z}function C(z){let B=z;try{let K=JSON.parse(z);if(K!==null)B=Y(K)}catch{}return G(B)}function F(z){if(z.startsWith("Error"))return!0;let B=z.slice(0,500).toLowerCase();return B.includes('"error"')||B.includes('"failed"')}function E(z){let B=z%100;if(B>=11&&B<=13)return`${z}th`;switch(z%10){case 1:return`${z}st`;case 2:return`${z}nd`;case 3:return`${z}rd`;default:return`${z}th`}}function Z(z,B){if(z===void 0||!Number.isFinite(z))return B;let K=Math.trunc(z);return K>=1?K:B}class O{opts;streak=null;callIndex=0;constructor(z){let B=S;this.opts={warningsEnabled:typeof z?.warningsEnabled==="boolean"?z.warningsEnabled:B.warningsEnabled,hardStop:typeof z?.hardStop==="boolean"?z.hardStop:B.hardStop,warnAfterRepeats:Z(z?.warnAfterRepeats,B.warnAfterRepeats),stubAfterRepeats:Z(z?.stubAfterRepeats,B.stubAfterRepeats),dedupMinChars:Z(z?.dedupMinChars,B.dedupMinChars),argsPreviewChars:Z(z?.argsPreviewChars,B.argsPreviewChars),repeatableTools:new Set(z?.repeatableTools??B.repeatableTools),repeatableSuffixes:[...z?.repeatableSuffixes??B.repeatableSuffixes]}}get trackedSignatures(){return this.streak?1:0}checkCall(z,B){this.callIndex+=1;let K=y(z,B);if(this.streak!==null&&this.streak.sig===K)this.streak.count+=1,this.streak.lastCallIndex=this.callIndex;else this.streak={sig:K,count:1,resultHash:null,firstCallIndex:this.callIndex,lastCallIndex:this.callIndex};if(this.isRepeatable(W(z,B)))return{action:"allow"};let M=this.streak.count;if(this.opts.hardStop&&M>this.opts.stubAfterRepeats)return{action:"stub",note:`[rovecode loop guard: blocked ${z} \u2014 this is the ${E(M)} consecutive call with identical arguments. Stop repeating it unchanged; change arguments or strategy, use a different tool, or proceed with what you already have.]`};if(this.opts.warningsEnabled&&M>this.opts.warnAfterRepeats)return{action:"warn",note:`[rovecode loop guard: this is the ${E(M)} consecutive call to ${z} `+"with identical arguments. This looks like a loop \u2014 change arguments, use a "+"different tool, or proceed with what you have.]"};return{action:"allow"}}checkResult(z,B,K,M){let X=y(z,B),Q=C(K);if(this.streak===null||this.streak.sig!==X){let q=Math.max(1,this.callIndex);return this.streak={sig:X,count:1,resultHash:Q,firstCallIndex:q,lastCallIndex:q},{output:K,deduped:!1}}let V=this.streak;if(V.resultHash===null)return V.resultHash=Q,{output:K,deduped:!1};if(V.resultHash!==Q)return V.count=1,V.resultHash=Q,V.firstCallIndex=V.lastCallIndex,{output:K,deduped:!1};if(V.count<2||K.length<this.opts.dedupMinChars||M===!1||F(K))return{output:K,deduped:!1};return{output:this.buildDedupStub(z,B,K.length,V.firstCallIndex),deduped:!0}}onTurn(){this.reset()}reset(){this.streak=null,this.callIndex=0}isRepeatable(z){if(this.opts.repeatableTools.has(z))return!0;return this.opts.repeatableSuffixes.some((B)=>z.endsWith(B))}buildDedupStub(z,B,K,M){let X=Y($(B));if(X.length>this.opts.argsPreviewChars)X=X.slice(0,this.opts.argsPreviewChars)+"\u2026";return`[rovecode note: this result is byte-identical to the ${z} result of call #${M} earlier this turn (original ${K} chars). Refer to that result; it has not changed. Args: ${X}]`}}var S;var R=N(()=>{S={warningsEnabled:!0,hardStop:!0,warnAfterRepeats:2,stubAfterRepeats:5,dedupMinChars:512,argsPreviewChars:120,repeatableTools:["process"],repeatableSuffixes:["_get_result","_poll"]}});
3
- export{S as jk,O as kk,R as lk};
@@ -1,25 +0,0 @@
1
- // @bun
2
- import{ue as t,ve as n,we as VZ,xe as Uz}from"./main-2z3dek0b.js";import{Dh as NZ,xh as Tz,yh as jz}from"./main-ntqef02r.js";import{Nh as tz,Oh as rZ,Ph as zZ,Qh as ZZ,Rh as oZ,Th as Nz,fi as W0}from"./main-kba6zeyd.js";import{kk as Sz,lk as OZ}from"./main-gbbty4d4.js";import{Hk as Iz,Jk as Lz,Qk as UZ}from"./main-qj2djy17.js";import{ll as Rz,ml as CZ}from"./main-6dtqmbt6.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 pz=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 az}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 az(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(az(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 pZ(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:pZ($)},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();pz();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=aZ(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 aZ(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[p(Q),p(W)]}let Z=z.indexOf(" b/");if(Z===-1){let $=z.indexOf(" ");return $===-1?null:[p(z.slice(0,$)),p(z.slice($+1))]}return[p(z.slice(0,Z)),p(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")},p=(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 a(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: ${a(z.summary)} \u2014 call task_status result ${z.id} for details`;if(z.status==="failed")return`${Z} failed: ${a(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 ${a(Q.error,80)}`:Q.status==="done"?` \u2014 ${a(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"?a(W.summary,80):W.status==="failed"?a(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(),...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};
@@ -1,9 +0,0 @@
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 dd,T as ed,l as fd};
@@ -1,38 +0,0 @@
1
- // @bun
2
- import{Wa as g,ib as Rz}from"./main-rsy72qmw.js";import{jh as U,kh as jz,lh as az}from"./main-4y0tnfpa.js";import{Bh as $z,Dh as nz,zh as Zz}from"./main-ntqef02r.js";import{Xh as d,fi as Tz}from"./main-kba6zeyd.js";import{Cj as v,Ej as YJ}from"./main-v8y60bb2.js";import{Ok as M,Pk as Vz,Qk as n,rk as t,sk as xz,tk as e,vk as zz,wk as Jz,xk as dz}from"./main-qj2djy17.js";import{Rk as I,Tk as Hz,Uk as Fz,Wk as w,Yk as _,_k as Yz,bl as FJ,cl as r,dl as pz}from"./main-6dtqmbt6.js";import{wn as R}from"./main-qsevpgsv.js";function Pz(z){if(/[\r\n]/.test(z))return null;let J=z.trim();if(!Gz.test(J))return null;return J.slice(1).trim()}function h(z,J,V){let Z=z.add(J,V);if(!Z.ok)return{ok:!1,tone:"warn",text:`memory: not saved to ${A[J]} \u2014 ${Z.reason??"edit failed"}`};return{ok:!0,tone:"info",text:`memory: noted in ${A[J]} (${Z.current}/${Z.limit} chars, ${z.path(J)}) \u2014 in the prompt from the next run`}}function PJ(z,J){let V=Pz(J);if(V===null)return!1;z.renderer.addUser(J.trim());let Z=h(z.blocks(),"memory",V);return z.renderer.addSystemNote(Z.text,Z.tone),!0}function Dz(z,J){let V=z.overCap(J);return(z.edited(J)?`
3
- (edited this run \u2014 in the prompt from the next run)`:"")+(z.isWithheld(J)?`
4
- (not in the prompt and not writable \u2014 it came with this repository; rovecode trust show)`:"")+(V?`
5
- (over the ${V.cap}-char cap \u2014 the prompt shows the first ${V.cap}; trim the file)`:"")}function DJ(z,J){let V=J.trim(),Z=V==="--user"||V.startsWith("--user "),$=Z?V.slice(6).trim():V;if($){let K=h(z,Z?"user":"memory",$);return{text:K.text,tone:K.tone}}return{text:(Z?["user"]:["memory","user"]).map((K)=>`# ${A[K]} \u2014 ${z.path(K)}
6
- ${z.liveText(K)||"(empty)"}${Dz(z,K)}`).join(`
7
-
8
- `),tone:"info"}}var Gz,A;var Lz=R(()=>{Gz=/^#[\p{L}\p{N}]/u;A={memory:"MEMORY",user:"USER"}});import{randomUUID as l}from"crypto";function Iz(z){let J=g(z);return J.kind==="shell"&&J.cmd?J.cmd:null}function _z(z,J){return!J&&z.detail==="user denied"?{...z,detail:b}:z}async function OJ(z,J){let V=Iz(J);if(V===null)return;let{renderer:Z}=z;if(z.busy()){Z.addSystemNote("finish or interrupt the run first (Esc) \u2014 `!cmd` runs only while the agent is idle","warn");return}Z.addUser(J.trim());let $=new AbortController;z.setBusy(!0),z.bindAbort($),Z.setBusy(!0,`running ${u(V)}\u2026`);let Q={kind:"tool_call",id:`shell-${l().slice(0,8)}`,tool:"bash",args:{command:V}},j=!1,K=!1,W=z.approve(),q=z.rt.buildCfg(z.level(),W===void 0?void 0:async(H)=>{return j=!0,W(H)}),B={sessionId:z.store().id,cwd:z.rt.cwd,signal:$.signal,permissions:{effect:"allow"}},Y=(H)=>{let X=H.type==="tool_call_failed"?_z(H,j):H;if(Z.onEvent?.(X),X.type==="tool_execution_start")Z.toolStart(X.callId,X.tool,JSON.stringify(X.args).slice(0,120));else if(X.type==="tool_execution_update")Z.toolUpdate(X.callId,X.note);else if(X.type==="tool_execution_end")K=!0,Z.toolEnd(X.callId,X.ok,X.output.slice(0,160).replace(/\n/g," \u23CE "),X.durationMs);else if(X.type==="tool_call_failed")Z.toolEnd(X.callId,!1,`${X.reason}: ${X.detail}`.slice(0,160),0)},P={ok:!1,output:""};try{if(P=await z.rt.registry.dispatch(Q,B,z.rt.hooks,q.permissionRules,q.approval,Y,void 0),K){let H=z.store(),X=H.stagedAttachments;if(H.stageAttachments([]),H.append(Az(V,P,H.messages().at(-1)?.id??null)),H.stageAttachments(X),!Z.onEvent)Z.addSystemNote(yz(P.output),P.ok?"info":"warn")}else{let H=$.signal.aborted?"was interrupted before it ran":j?"was denied at the approval card":"was refused before any approval prompt (a permission rule, exec policy or a hook)";Z.addSystemNote(`\`${u(V)}\` ${H} \u2014 nothing ran, nothing recorded`,"warn")}}finally{z.bindAbort(null),Z.setBusy(!1,K&&P.ok?"done":"error"),z.setBusy(!1)}}function Az(z,J,V){let Z=/^exit=(-?\d+)\r?\n?/.exec(J.output),$=Z?Z[1]:"?",Q=(Z?J.output.slice(Z[0].length):J.output).replace(/\r?\n$/,""),j=[Oz,`$ ${z}`,Mz,`${Uz} exit="${$}">`,...Q?[Q]:[],Cz].join(`
9
- `);return{id:l(),role:"user",parts:[{kind:"text",text:j}],parentId:V,createdAt:Date.now()}}function kz(z){let J=bz.exec(z);return J?{cmd:J[1],exit:J[2],output:J[3]??""}:null}function yz(z){let J=z.replace(/\r\n/g,`
10
- `).replace(/\n$/,"").split(`
11
- `),V=J.slice(0,Nz),Z=J.length-V.length;return V.join(`
12
- `)+(Z>0?`
13
- \u2026 ${Z} more line${Z===1?"":"s"} (the session record keeps the full output)`:"")}function MJ(z,J){let V=kz(J);if(!V)return!1;let Z=`shell-replay-${++Sz}`;return z.addUser(`!${V.cmd}`),z.toolStart(Z,"bash",JSON.stringify({command:V.cmd}).slice(0,120)),z.toolEnd(Z,V.exit==="0",[`exit=${V.exit}`,...V.output?[V.output]:[]].join(`
14
- `).slice(0,160).replace(/\n/g," \u23CE "),0),!0}var Nz=40,Oz="<user_shell_command>",Mz="</user_shell_command>",Uz="<user_shell_output",Cz="</user_shell_output>",u=(z)=>{let J=z.replace(/\s+/g," ").trim();return J.length>40?J.slice(0,39)+"\u2026":J},b="refused by a permission rule, exec policy or an approval hook (no approval prompt)",bz,Sz=0;var m=R(()=>{Rz();bz=/^<user_shell_command>\n\$ ([\s\S]*?)\n<\/user_shell_command>\n<user_shell_output exit="(-?\d+|\?)">\n(?:([\s\S]*?)\n)?<\/user_shell_output>$/});function E(z){return`compacted (${z.strategy}): ${z.tokensBefore} \u2192 ${z.tokensAfter} tokens`}function SJ(z){let J=z.event;if(!J||typeof J!=="object")return null;return J.type==="compaction"?E(J):null}var o=()=>{};import{spawnSync as jJ}from"child_process";function qJ(z){let J=z?.trim()??"";if(J.length<16||!/^[A-Za-z0-9+/=\r\n]+$/.test(J))return null;try{return new Uint8Array(Buffer.from(J.replace(/\s+/g,""),"base64"))}catch{return null}}function HJ(z){let J=/\u00ABdata PNGf([0-9A-Fa-f]+)\u00BB/.exec(z??"");if(!J||J[1].length<32||J[1].length%2!==0)return null;return new Uint8Array(Buffer.from(J[1],"hex"))}function Xz(z=XJ,J=process.platform){if(J==="win32")return qJ(z("powershell",["-NoProfile","-NonInteractive","-STA","-Command",WJ]));if(J==="darwin")return HJ(z("osascript",["-e","the clipboard as \xABclass PNGf\xBB"]));for(let[V,Z]of[["wl-paste",["-t","image/png"]],["xclip",["-selection","clipboard","-t","image/png","-o"]]]){let $=z(V,Z,"latin1");if($!==null&&$.length>8)return new Uint8Array(Buffer.from($,"latin1"))}return null}function Wz(z=new Date){let J=(V)=>String(V).padStart(2,"0");return`clipboard-${J(z.getHours())}${J(z.getMinutes())}${J(z.getSeconds())}.png`}var KJ=5000,QJ=67108864,XJ=(z,J,V="utf8")=>{try{let Z=jJ(z,J,{encoding:V,timeout:KJ,maxBuffer:QJ,windowsHide:!0,stdio:["ignore","pipe","ignore"]});if(Z.error||Z.status!==0||Z.signal)return null;return Z.stdout}catch{return null}},WJ;var qz=R(()=>{WJ=["Add-Type -AssemblyName System.Windows.Forms,System.Drawing","$i = [System.Windows.Forms.Clipboard]::GetImage()","if ($i -eq $null) { exit 3 }","$ms = New-Object System.IO.MemoryStream","$i.Save($ms, [System.Drawing.Imaging.ImageFormat]::Png)","[Console]::Out.Write([Convert]::ToBase64String($ms.ToArray()))"].join("; ")});import{resolve as BJ}from"path";function VV(z,J){let{renderer:V}=z,Z=z.store(),$=Z.stagedAttachments;if(J===""){V.addSystemNote($.length===0?"no images attached \u2014 /attach <path>":`attached (${$.length}/${I}):
15
- ${$.map((B,Y)=>`${Y+1}. ${_(B)}`).join(`
16
- `)}`);return}if(J==="clear"){Z.stageAttachments([]),V.addSystemNote($.length===0?"no images attached":`attachments cleared (${f($.length)} removed)`);return}let Q=J.replace(/^(["'])(.*)\1$/,"$2"),j=Fz(BJ(z.cwd,Q));if("error"in j){V.addSystemNote(j.error,"error");return}let K=w($.length+1);if(K!==void 0){V.addSystemNote(K,"error");return}Z.stageAttachments([...$,j]),V.addSystemNote(`attached ${_(j)} (${$.length+1}/${I}) \u2014 type your message and press Enter to send it`);let W=z.modelRef(),q=v(W);if(q===!1)V.addSystemNote(`model ${W.provider}/${W.model} has no image input \u2014 it will be sent as a text placeholder`,"warn");else if(q===void 0)V.addSystemNote(`unknown model ${W.provider}/${W.model}; image sent as-is (provider may reject)`)}function $V(z,J=()=>Xz(),V=Wz()){let{renderer:Z}=z,$=J();if($===null){Z.addSystemNote("no image on the clipboard \u2014 copy a screenshot or picture first, or /attach <path>");return}let Q=Hz($,{name:V});if("error"in Q){Z.addSystemNote(Q.error,"error");return}let j=z.store(),K=j.stagedAttachments,W=w(K.length+1);if(W!==void 0){Z.addSystemNote(W,"error");return}j.stageAttachments([...K,Q]),Z.addSystemNote(`attached ${_(Q)} from the clipboard (${K.length+1}/${I}) \u2014 type your message and press Enter to send it`);let q=z.modelRef();if(v(q)===!1)Z.addSystemNote(`model ${q.provider}/${q.model} has no image input \u2014 it will be sent as a text placeholder`,"warn")}function jV(z,J){let V=J.filter((Z)=>Z.kind==="image").map(Yz).join(" ");return z&&V?`${z}
17
- ${V}`:z||V}function KV(z){let J=z.stagedAttachments.length;return J===0?"":` \u2014 ${f(J)} attached to your queued message`}function QV(z,J){if(J.length===0)return;z.store().stageAttachments(J),z.renderer.addSystemNote(`${f(J.length)} still attached \u2014 carried over to this session, rides on your next message`)}var JV,f=(z)=>`${z} image${z===1?"":"s"}`,ZV;var GJ=R(()=>{FJ();qz();YJ();JV={name:"attach",description:"Attach an image to your next message (text required): /attach <path> \xB7 /attach = list \xB7 /attach clear \xB7 or drag an image file onto the terminal"};ZV={name:"paste",description:"attach the image on the clipboard (\u2303v)"}});Tz();n();m();import{randomUUID as T}from"crypto";var a="finish or interrupt the run first (Esc) \u2014 /commit and /undo run only while the agent is idle",i="(diff truncated at the 10k output cap for the model)",p="a commit message cannot start with -; quote it or begin with a word \u2014 git would read a dash-led message as a flag, so nothing was committed",Ez="You write git commit messages. Reply with the commit message only: a first line `type(scope): summary` in the imperative mood, at most 72 characters, type one of feat, fix, refactor, docs, test, chore, perf, build, ci, style; then, only when the change needs it, one blank line and a short body. No quotes, no code fences, no commentary.";function wz(z){return/^[A-Za-z0-9_./:=@%+,-]+$/.test(z)?z:`'${z.replace(/'/g,"'\\''")}'`}function vz(z){return["git",...z.map(wz)].join(" ")}async function O(z,J,V,Z){let $=vz(J),Q={kind:"tool_call",id:`git-${T().slice(0,8)}`,tool:"bash",args:{command:$}},j=!1,K=!1,W=z.approve(),q=z.rt.buildCfg(z.yolo(),W===void 0?void 0:async(D)=>{return j=!0,await z.renderer.askApproval(D.tool,JSON.stringify(D.revisedArgs).slice(0,140),Z)==="deny"?"deny":"once"}),B={sessionId:z.store().id,cwd:z.rt.cwd,signal:V,permissions:{effect:"allow"}},{renderer:Y}=z,P=(D)=>{let G=D.type==="tool_call_failed"&&!j&&D.detail==="user denied"?{...D,detail:b}:D;if(Y.onEvent?.(G),G.type==="tool_execution_start")Y.toolStart(G.callId,G.tool,JSON.stringify(G.args).slice(0,120));else if(G.type==="tool_execution_update")Y.toolUpdate(G.callId,G.note);else if(G.type==="tool_execution_end")K=!0,Y.toolEnd(G.callId,G.ok,G.output.slice(0,160).replace(/\n/g," \u23CE "),G.durationMs);else if(G.type==="tool_call_failed")Y.toolEnd(G.callId,!1,`${G.reason}: ${G.detail}`.slice(0,160),0)},H=await z.rt.registry.dispatch(Q,B,z.rt.hooks,q.permissionRules,q.approval,P,void 0),X=/^exit=(-?\d+)\r?\n?/.exec(H.output),F=X?H.output.slice(X[0].length):H.output;return{executed:K,asked:j,exit:X?Number(X[1]):-1,body:F.replace(/\r\n/g,`
18
- `),capped:F.length>=d,command:$}}var k=(z)=>z.trim().split(`
19
- `)[0]??"",y=(z,J)=>J.aborted?"was interrupted before it ran":z.asked?"was denied at the approval card":"was refused before any approval prompt (exec policy, a permission rule or a hook)";function S(z,J){let V=z.body.split(`
20
- `).map(($)=>$.trim()).find(($)=>$!==""&&$!=="stderr:")??"no output",Z=/not a git repository|--no-index/.test(z.body);return`${z.command.split(" ").slice(0,2).join(" ")} failed (exit ${z.exit}): ${V}${Z?` \u2014 ${J} is not inside a git repository`:""}`}function fz(z){let J=z.replace(/\r\n/g,`
21
- `).trim(),V=/^```[^\n]*\n([\s\S]*?)\n?```$/.exec(J);if(V)J=V[1].trim();if(J=J.replace(/^commit message:\s*/i,""),J.startsWith('"')&&J.endsWith('"')||J.startsWith("'")&&J.endsWith("'"))J=J.slice(1,-1).trim();return J.split(`
22
- `).map((Z)=>Z.trimEnd()).join(`
23
- `).replace(/\n{3,}/g,`
24
-
25
- `).trim()}async function hz(z,J,V,Z){let $=z.rt.stream;if(!$)return{error:"no provider configured \u2014 nothing can draft a message"};let Q=Date.now(),j={id:T(),role:"system",parts:[{kind:"text",text:Ez}],parentId:null,createdAt:Q},K={id:T(),role:"user",parts:[{kind:"text",text:`Write the commit message for this diff:
26
-
27
- ${J}`}],parentId:j.id,createdAt:Q},W=null;try{for await(let B of $(V,[j,K],{signal:Z}))if(B.type==="turn")W=B.turn}catch(B){return{error:`commit model failed: ${B instanceof Error?B.message:String(B)}`}}if(Z.aborted)return{error:"interrupted while drafting the message"};if(!W)return{error:"commit model returned no turn"};if(W.stopReason==="error")return{error:`commit model failed: ${W.error??"error"}`};let q=fz(M(W.parts));return q?{text:q}:{error:"the commit model returned an empty message"}}function uz(z){let J=[];for(let V of z.matchAll(/^diff --git a\/(.+?) b\/(.+)$/gm))J.push(V[2]);return J}async function bJ(z,J=""){let{renderer:V}=z;if(z.busy()){V.addSystemNote(a,"warn");return}let Z=J.replace(/\r\n/g,`
28
- `).trim();if(Z.startsWith("-")){V.addSystemNote(p,"warn");return}let $=new AbortController;z.setBusy(!0),z.bindAbort($),V.setBusy(!0,"collecting the diff\u2026");let Q="error";try{let j=await O(z,["diff","--cached"],$.signal);if(!j.executed){V.addSystemNote(`\`${j.command}\` ${y(j,$.signal)} \u2014 nothing committed`,"warn");return}if(j.exit!==0){V.addSystemNote(S(j,z.rt.cwd),"error");return}let K="staged",W=j.body,q=j.capped;if(!W.trim()){let F=await O(z,["diff"],$.signal);if(!F.executed){V.addSystemNote(`\`${F.command}\` ${y(F,$.signal)} \u2014 nothing committed`,"warn");return}if(F.exit!==0){V.addSystemNote(S(F,z.rt.cwd),"error");return}if(!F.body.trim()){V.addSystemNote("nothing to commit \u2014 the index and the tracked working tree are clean (untracked files need `git add` first)"),Q="done";return}K="working",W=F.body,q=F.capped,V.addSystemNote("nothing staged \u2014 committing the working-tree changes to tracked files instead (`git commit -a`)")}let B=uz(W);if(q){let F=await O(z,K==="working"?["diff","--name-only"]:["diff","--cached","--name-only"],$.signal);if(F.executed&&F.exit===0)B=F.body.split(`
29
- `).map((D)=>D.trim()).filter((D)=>D!=="")}let Y=Z,P="";if(!Y){let F=z.rt.router.resolve("commit");V.setBusy(!0,`drafting the commit message (${F.model})\u2026`);let D=await hz(z,q?`${W}
30
- \u2026 ${i}`:W,F,$.signal);if("error"in D){V.addSystemNote(`${D.error} \u2014 pass the message yourself: /commit <message>`,"error");return}if(Y=D.text,P=`${F.provider}/${F.model}`,Y.startsWith("-")){V.addSystemNote(`the drafted message starts with - (${k(Y)}); ${p}`,"error");return}}V.setBusy(!0,"committing\u2026");let H=[`commit message${P?` (drafted by ${P}${Z?"":" \u2014 deny to edit it in the prompt"})`:""}:`,...Y.split(`
31
- `).map((F)=>` ${F}`),"",K==="working"?"scope: working-tree changes to tracked files (git commit -a)":"scope: the staged changes",`files (${B.length}): ${B.slice(0,12).join(", ")}${B.length>12?", \u2026":""}`,...q?[i]:[]].join(`
32
- `),X=await O(z,K==="working"?["commit","-a","-m",Y]:["commit","-m",Y],$.signal,H);if(!X.executed){if(V.addSystemNote(`commit ${y(X,$.signal)} \u2014 nothing committed`,"warn"),X.asked&&!$.signal.aborted)V.prefillEditor(`/commit ${Y}`),V.addSystemNote("the message is in the prompt \u2014 edit it and press Enter to commit");return}if(X.exit!==0){V.addSystemNote(`${S(X,z.rt.cwd)}
33
- ${X.body.trim().split(`
34
- `).slice(-8).join(`
35
- `)}`,"error");return}Q="done",V.addSystemNote(`committed ${k(X.body)||k(Y)}${P?` \xB7 message by ${P}`:""}`)}finally{z.bindAbort(null),V.setBusy(!1,Q),z.setBusy(!1)}}var gz=(z)=>new Date(z.createdAt).toLocaleTimeString(),x=(z)=>`${z.hash.slice(0,8)} (${z.label}, ${gz(z)})`,lz={M:"rewritten",D:"recreated",A:"removed (added since that checkpoint)","?":"removed (created after the checkpoint)"};async function kJ(z){let{renderer:J}=z;if(z.busy()){J.addSystemNote(a,"warn");return}let V=await z.rt.checkpointsFor(z.store().id);if(!V){J.addSystemNote("checkpoints unavailable (git missing or ROVECODE_NO_CHECKPOINTS=1) \u2014 nothing to undo","warn");return}let Z=V.list().at(-1);if(!Z){J.addSystemNote("no checkpoint to undo to \u2014 snapshots land after each mutating tool call (edit, write, bash)");return}let $=await V.position(),Q=$.at?$.previous:Z;if(!Q){J.addSystemNote(`nothing to undo \u2014 the workspace matches checkpoint ${x($.at)} and no older snapshot differs from it (/checkpoints lists them; /restore <ref> reaches any)`);return}let j=x(Q),K=await V.changedSince(Q.hash);if(K!==null&&K.length===0){J.addSystemNote(`nothing to undo \u2014 the workspace already matches the last checkpoint ${j}`);return}let W=$.at?`undo the agent's last change (checkpoint ${$.at.hash.slice(0,8)}, ${$.at.label}): restore ${j}`:`restore the workspace to checkpoint ${j}`,q=K===null?`${W}: every file goes back to that snapshot (the change list could not be computed)`:[`${W} \u2014 ${K.length} path${K.length===1?"":"s"}:`,...K.slice(0,40).map((H)=>` ${H.status} ${H.path} \u2014 ${lz[H.status]??H.status}`),...K.length>40?[` \u2026 ${K.length-40} more`]:[],"","the conversation is untouched; /restore <ref> conversation branches it too"].join(`
36
- `);if(await J.askApproval("undo",`restore checkpoint ${Q.hash.slice(0,8)} \xB7 files only`,q)==="deny"){J.addSystemNote("undo cancelled \u2014 nothing changed","warn");return}let Y=await V.restore(Q.hash,"files");if(!Y.ok){J.addSystemNote(`undo failed: ${Y.error}`,"error");return}let P=K===null?"the workspace":`${K.length} path${K.length===1?"":"s"}: ${K.slice(0,8).map((H)=>H.path).join(", ")}${K.length>8?", \u2026":""}`;J.addSystemNote(`undo: restored ${P} to checkpoint ${j} \u2014 files only; the conversation is untouched (snapshots keep history: /checkpoints)`)}dz();xz();n();nz();pz();az();import{randomUUID as Kz}from"crypto";import{existsSync as oz}from"fs";import{basename as sz,isAbsolute as cz,join as rz}from"path";function mz(z){if(z==="win32")return[["powershell","-NoProfile","-NonInteractive","-Command","[Console]::InputEncoding=[Text.Encoding]::UTF8; $t=[Console]::In.ReadToEnd(); Set-Clipboard -Value $t"]];return[["pbcopy"],["wl-copy"],["xclip","-selection","clipboard"],["xsel","--clipboard","--input"]]}var iz=async(z,J)=>{try{let V=Bun.spawn([...z],{stdin:"pipe",stdout:"ignore",stderr:"pipe"});V.stdin.write(J),await V.stdin.end();let Z=await V.exited;if(Z===0)return{ok:!0};let $=(await new Response(V.stderr).text()).trim().split(`
37
- `)[0]??"";return{ok:!1,detail:`exit ${Z}${$?`: ${$.slice(0,120)}`:""}`}}catch(V){return{ok:!1,detail:V instanceof Error?V.message:String(V)}}};async function s(z,J={}){let V=J.spawn??iz,Z=[];if(z.length===0)return{ok:!1,tried:Z,detail:"nothing to copy (empty text)"};let $;for(let Q of mz(J.platform??process.platform)){let j=Q[0];Z.push(j);let K;try{K=await V(Q,z)}catch(W){K={ok:!1,detail:W instanceof Error?W.message:String(W)}}if(K.ok)return{ok:!0,tool:j};$=K.detail}return{ok:!1,tried:Z,...$!==void 0?{detail:$}:{}}}o();var dJ=[{name:"compact",description:"Compact the context now: /compact [focus] \u2014 the automatic strategy set, marker persisted",group:"session"},{name:"clear",description:"Fresh session in place (transcript emptied; the previous session is kept \u2014 /resume <id>)",group:"session"},{name:"init",description:"Analyse the repo and write AGENTS.md (an existing one gets targeted improvements)",group:"files & history"},{name:"copy",description:"Copy the last assistant message to the clipboard: /copy [n] (n-th from the end)",group:"session"}],c=6,C="finish or interrupt the run first (Esc)";function tz(z){return z.map((J)=>J.kind==="image"&&J.path!==void 0&&cz(J.path)?{...J,path:`${r}/${sz(J.path)}`}:J)}async function ez(z,J,V={}){let Z=z.messages(),$=Z.length;if($<c)return{kind:"nothing",reason:`nothing to compact \u2014 ${$} message${$===1?"":"s"} on the active path (compaction needs at least ${c})`};let Q=(L)=>Vz(L.parts),j=(L)=>L.reduce((N,Bz)=>N+t(Q(Bz)),0),K={trigger:"speculative",tokenText:Q,summarize:V.summarize,native:V.native,model:V.model,signal:V.signal},W=zz(Z,J,K),q=W?await Jz(Z,W,J,K):null;if(!q)return{kind:"nothing",reason:`nothing to compact \u2014 ${J.compactionStrategy??e} found nothing droppable (${j(Z)} tokens)`};let B=j(Z),Y=j(q.history),P=z.stagedAttachments;z.stageAttachments([]);let H=Z.at(-1)?.id,X=null;try{for(let L of q.history){let N={...L,id:Kz(),parentId:X,parts:tz(L.parts)};z.append(N),X=N.id}if(X!==null)z.branch(X)}catch(L){if(H!==void 0)z.branch(H);throw L}finally{z.stageAttachments(P)}let F={type:"compaction",strategy:q.strategy,tokensBefore:B,tokensAfter:Y};z.appendEvent(F);let D=new Set(Z.map((L)=>L.id)),G=q.history.filter((L)=>D.has(L.id)).length;return{kind:"compacted",event:F,dropped:$-G,kept:G,...q.fallbackFrom?{fallbackFrom:q.fallbackFrom}:{}}}function Qz(z,J){let V=(Z)=>Z===1?"":"s";return`${z.dropped} message${V(z.dropped)} dropped, ${z.kept} kept \u2014 the earlier turns stay in the session file on the previous branch`+(z.fallbackFrom?` \xB7 ${z.fallbackFrom} could not run on this surface (no summarizer wired) \u2014 ${z.event.strategy} ran instead`:"")+(J?` \xB7 focus "${J}" not applied \u2014 the compaction strategies take no instructions`:"")}function nJ(z,J){return z.kind==="nothing"?[z.reason]:[E(z.event),Qz(z,J)]}async function zJ(z,J){if(z.busy()){z.renderer.addSystemNote(C,"warn");return}let V=z.store();z.state.busy=!0;let Z=new AbortController;z.bindAbort?.(Z);let $;try{$=await ez(V,z.buildCfg(),{model:z.modes.modelFor(),summarize:z.summarize,signal:Z.signal})}catch(j){$={kind:"nothing",reason:`compaction failed: ${j instanceof Error?j.message:String(j)} \u2014 the session is unchanged`}}finally{z.bindAbort?.(null),z.state.busy=!1}if($.kind==="nothing"){z.renderer.addSystemNote($.reason,$.reason.startsWith("compaction failed")?"error":"info"),z.pushStatus();return}let Q=$z(V.messages())??z.defaultMode;if(Q!==z.modes.mode)V.append(Zz({from:Q,to:z.modes.mode},V.messages().at(-1)?.id??null));z.replayHistory(),z.refreshUsage(),z.pushStatus(),z.renderer.addSystemNote(Qz($,J))}function JJ(z){if(z.busy()){z.renderer.addSystemNote(C,"warn");return}let J=z.store().id,V=z.modes.mode,Z=Kz();if(z.switchSession(Z,!1),z.modes.mode!==V){z.modes.toggle(V);let $=z.modes.modelFor();z.state.mode=V,z.state.model=$.model,z.state.provider=$.provider,z.pushStatus()}z.renderer.addSystemNote(`cleared \u2014 fresh session ${Z.slice(0,8)} in the same directory; session ${J.slice(0,8)} kept (/resume ${J.slice(0,8)})`)}async function VJ(z){if(z.busy()){z.renderer.addSystemNote(C,"warn");return}let J=jz("/init",z.cwd);if(J===void 0)return;z.renderer.addSystemNote(oz(rz(z.cwd,U))?`${U} exists \u2014 asking the agent for targeted improvements (edits go through the usual approval)`:`analysing the repository to write ${U} (the write goes through the usual approval)`),await z.submit(J)}async function ZJ(z,J,V={}){let Z=z.filter((j)=>j.role==="assistant").map((j)=>M(j.parts)).filter((j)=>j.trim()!=="");if(Z.length===0)return{text:"nothing to copy \u2014 no assistant message with text yet",tone:"warn"};let $=Z[Z.length-J];if($===void 0)return{text:`nothing to copy \u2014 only ${Z.length} assistant message${Z.length===1?"":"s"} with text (asked for number ${J} from the end)`,tone:"warn"};let Q=await s($,V);if(Q.ok)return{text:`copied ${J===1?"the last assistant message":`assistant message ${J} from the end`} (${$.length} chars) to the clipboard via ${Q.tool}`,tone:"info"};return{text:`clipboard unavailable \u2014 tried ${Q.tried.join(", ")||"nothing"}${Q.detail?` (${Q.detail})`:""}; the text stays in the transcript`,tone:"warn"}}async function $J(z,J){if(z.busy()){z.renderer.addSystemNote(C,"warn");return}let V=J===""?1:/^[1-9]\d*$/.test(J)?Number(J):NaN;if(Number.isNaN(V)){z.renderer.addSystemNote("usage: /copy [n] \u2014 copies the last assistant message; n counts back from the latest (2 = the one before)","warn");return}let Z=await ZJ(z.store().messages(),V,z.clipboard??{});z.renderer.addSystemNote(Z.text,Z.tone)}async function aJ(z,J,V){switch(J){case"compact":return zJ(z,V);case"clear":return JJ(z);case"init":return VJ(z);case"copy":return $J(z,V);default:return}}
38
- export{Pz as L,h as M,PJ as N,DJ as O,Lz as P,Iz as Q,OJ as R,MJ as S,m as T,bJ as U,kJ as V,E as W,SJ as X,o as Y,dJ as Z,ez as _,nJ as $,ZJ as aa,aJ as ba,JV as ca,VV as da,ZV as ea,$V as fa,jV as ga,KV as ha,QV as ia,GJ as ja};
@@ -1,5 +0,0 @@
1
- // @bun
2
- import{Vb as Hz,Wb as Wz,Xb as g,Yb as kz}from"./main-m8vm17zq.js";import{$b as T,_b as O,bc as b,dc as gz}from"./main-zc7pyrbj.js";import{fc as y,gc as Yz,hc as Zz,ic as $z,jc as Gz,kc as Kz,nc as Vz,oc as Lz}from"./main-45ejth3a.js";import{rc as Qz,sc as Uz,xc as Iz}from"./main-jak598k9.js";import{ud as x,xd as Bz}from"./main-f33fc5je.js";import{yd as m,zd as Cz}from"./main-2zgsknth.js";import{Ad as Jz,Ed as xz}from"./main-kwwsz6rq.js";import{Kg as i,Lg as Pz,Mg as s,Pg as t,Qg as e,Rg as zz,Vg as jz}from"./main-7jd5vh3x.js";import{sj as j,yj as _z}from"./main-2rzbexn2.js";import{om as S,tm as u,vm as Fz}from"./main-y5c82rxr.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 Jb,HJ as Kb,o as Lb,hz as Mb,Ez as Nb,FJ as Ob,PJ as Pb,nz as Qb,w as Rb,jJ as Sb,xJ as Tb,zJ as Ub};