@sma1lboy/rove 0.9.266 → 0.9.267

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 (214) hide show
  1. package/dist/cli/{chunk-e69s8s16.js → chunk-02htajas.js} +3 -3
  2. package/dist/cli/chunk-0bcs1v6n.js +2 -0
  3. package/dist/cli/{chunk-7wsxppwc.js → chunk-0fejmkz1.js} +1 -1
  4. package/dist/cli/{chunk-gskbzgc3.js → chunk-0g4wc808.js} +1 -1
  5. package/dist/cli/chunk-0t0ykzek.js +2 -0
  6. package/dist/cli/chunk-1b3pq6g6.js +2 -0
  7. package/dist/cli/{chunk-tz3eftty.js → chunk-1qvrn21x.js} +1 -1
  8. package/dist/cli/chunk-1z1tjqyy.js +3 -0
  9. package/dist/cli/{chunk-yk498qwr.js → chunk-1z2sze0v.js} +1 -1
  10. package/dist/cli/{chunk-3zsm2jbm.js → chunk-2a19815h.js} +2 -2
  11. package/dist/cli/chunk-2gc4kqrt.js +2 -0
  12. package/dist/cli/chunk-2geegpp7.js +2 -0
  13. package/dist/cli/chunk-2jzaabcy.js +11 -0
  14. package/dist/cli/{chunk-ag3txfg2.js → chunk-2r1fgng9.js} +1 -1
  15. package/dist/cli/{chunk-n3f5sdka.js → chunk-32j6y5d1.js} +1 -1
  16. package/dist/cli/{chunk-rbr6qapz.js → chunk-3gegmpff.js} +1 -1
  17. package/dist/cli/{chunk-8vkma6c4.js → chunk-3nf9zbm7.js} +1 -1
  18. package/dist/cli/{chunk-zprhxt1q.js → chunk-3qkhxem2.js} +1 -1
  19. package/dist/cli/chunk-3xrbb1yv.js +2 -0
  20. package/dist/cli/{chunk-31jxjkrq.js → chunk-48ynmrd8.js} +1 -1
  21. package/dist/cli/{chunk-b3pm5nvh.js → chunk-4bfwafzg.js} +1 -1
  22. package/dist/cli/{chunk-8saxdp88.js → chunk-4fa35dbn.js} +1 -1
  23. package/dist/cli/{chunk-ejd307we.js → chunk-4kdakncb.js} +1 -1
  24. package/dist/cli/{chunk-mr0z23fd.js → chunk-57qny54a.js} +1 -1
  25. package/dist/cli/chunk-5d3p4rqv.js +2 -0
  26. package/dist/cli/{chunk-hc6qpkpy.js → chunk-5m1ef9ez.js} +2 -2
  27. package/dist/cli/{chunk-wvaf3d9j.js → chunk-5r4d0h87.js} +1 -1
  28. package/dist/cli/chunk-5vetsh77.js +4 -0
  29. package/dist/cli/chunk-66zvkh5z.js +2 -0
  30. package/dist/cli/chunk-6xsc9crp.js +4 -0
  31. package/dist/cli/{chunk-7c4zdjr5.js → chunk-6z02cd58.js} +1 -1
  32. package/dist/cli/{chunk-ye4vt96f.js → chunk-7ag59vyh.js} +9 -7
  33. package/dist/cli/{chunk-hq3hd8qr.js → chunk-7maf6x1g.js} +1 -1
  34. package/dist/cli/{chunk-3342qzve.js → chunk-7mwvvj46.js} +1 -1
  35. package/dist/cli/{chunk-me656p3n.js → chunk-835qwnnq.js} +2 -2
  36. package/dist/cli/chunk-84m0d72d.js +2 -0
  37. package/dist/cli/chunk-85m74thf.js +31 -0
  38. package/dist/cli/{chunk-tdhk4dz8.js → chunk-8t7qbr1e.js} +1 -1
  39. package/dist/cli/{chunk-yztr951z.js → chunk-a0rz9g11.js} +1 -1
  40. package/dist/cli/{chunk-qpr14v8x.js → chunk-a4znycsh.js} +1 -1
  41. package/dist/cli/{chunk-kvwqh35r.js → chunk-a569ctz6.js} +1 -1
  42. package/dist/cli/{chunk-3x0ryj15.js → chunk-acqcph62.js} +1 -1
  43. package/dist/cli/chunk-ak0frbbw.js +3 -0
  44. package/dist/cli/chunk-ankt6yse.js +2 -0
  45. package/dist/cli/{chunk-80jqznbm.js → chunk-av482xxw.js} +1 -1
  46. package/dist/cli/chunk-awgsda64.js +2 -0
  47. package/dist/cli/chunk-axjcmamn.js +2 -0
  48. package/dist/cli/chunk-azpvsc5d.js +2 -0
  49. package/dist/cli/{chunk-zh0c8yzw.js → chunk-bejhca6z.js} +1 -1
  50. package/dist/cli/chunk-bm2baazf.js +2 -0
  51. package/dist/cli/{chunk-wqckm0k6.js → chunk-br8r72bf.js} +1 -1
  52. package/dist/cli/{chunk-sdya3r5j.js → chunk-bvsjep6w.js} +1 -1
  53. package/dist/cli/{chunk-1vtfzcca.js → chunk-c1dz3qg3.js} +1 -1
  54. package/dist/cli/{chunk-2gjrfqhs.js → chunk-c25vea1q.js} +1 -1
  55. package/dist/cli/{chunk-qwz9728j.js → chunk-cangy5wn.js} +1 -1
  56. package/dist/cli/chunk-dhcx1gna.js +3 -0
  57. package/dist/cli/chunk-e7h7w4n0.js +4 -0
  58. package/dist/cli/{chunk-sr4c9fve.js → chunk-eckrcmtz.js} +1 -1
  59. package/dist/cli/{chunk-7zyyvc3d.js → chunk-eqa843hf.js} +1 -1
  60. package/dist/cli/{chunk-n0rtj4z7.js → chunk-eqdbfgq5.js} +1 -1
  61. package/dist/cli/{chunk-cbc1h345.js → chunk-eyrt04mg.js} +1 -2
  62. package/dist/cli/{chunk-3126c9x9.js → chunk-f09ex46c.js} +1 -1
  63. package/dist/cli/{chunk-szjgjrar.js → chunk-f2bqrzsy.js} +1 -1
  64. package/dist/cli/chunk-f8gg8cqh.js +3 -0
  65. package/dist/cli/{chunk-wyn3zbh4.js → chunk-f8w52tsz.js} +2 -2
  66. package/dist/cli/{chunk-qs0526nj.js → chunk-fcnd49ce.js} +1 -1
  67. package/dist/cli/{chunk-ek6kywem.js → chunk-fcqtqpm1.js} +1 -1
  68. package/dist/cli/chunk-fjvefbnr.js +16 -0
  69. package/dist/cli/chunk-fvvb0072.js +3 -0
  70. package/dist/cli/{chunk-b4zqkdyq.js → chunk-ga412sby.js} +1 -1
  71. package/dist/cli/{chunk-5v02t4pz.js → chunk-gak4aag4.js} +25 -8
  72. package/dist/cli/{chunk-vxc90473.js → chunk-gg5f2ayw.js} +1 -1
  73. package/dist/cli/{chunk-30g1bgkg.js → chunk-ggnq2vvk.js} +1 -1
  74. package/dist/cli/{chunk-4018sjy3.js → chunk-ghkr7f4t.js} +1 -1
  75. package/dist/cli/{chunk-41x1hrqe.js → chunk-gq36nzg8.js} +1 -1
  76. package/dist/cli/{chunk-mh2s5ttr.js → chunk-gqh6atvp.js} +2 -2
  77. package/dist/cli/{chunk-y078swzq.js → chunk-gs6j7y6q.js} +1 -1
  78. package/dist/cli/chunk-gytx47yk.js +3 -0
  79. package/dist/cli/{chunk-1jz7ppsy.js → chunk-h6bbe9nd.js} +1 -1
  80. package/dist/cli/{chunk-9g2faw9a.js → chunk-h8t4xg1p.js} +1 -1
  81. package/dist/cli/{chunk-re15t5r1.js → chunk-heajz5tw.js} +1 -1
  82. package/dist/cli/{chunk-yadx0wc5.js → chunk-hf168gph.js} +1 -1
  83. package/dist/cli/{chunk-1ys1maw7.js → chunk-hsy5gebc.js} +1 -1
  84. package/dist/cli/{chunk-cajrtabt.js → chunk-hv79ys32.js} +1 -1
  85. package/dist/cli/{chunk-mb018hfg.js → chunk-hy0r635n.js} +3 -3
  86. package/dist/cli/{chunk-812et2xk.js → chunk-j1z9kgyd.js} +1 -1
  87. package/dist/cli/{chunk-w196jkg5.js → chunk-jj5f4n51.js} +1 -1
  88. package/dist/cli/{chunk-z80jjarw.js → chunk-jp8vfwqm.js} +1 -1
  89. package/dist/cli/chunk-kcd1w62f.js +2 -0
  90. package/dist/cli/{chunk-tshbjft4.js → chunk-ke19jzhg.js} +2 -2
  91. package/dist/cli/chunk-kq01awhv.js +3 -0
  92. package/dist/cli/{chunk-kmgheesn.js → chunk-krnacq08.js} +2 -2
  93. package/dist/cli/{chunk-t6hzyee7.js → chunk-kwyxwcr8.js} +1 -1
  94. package/dist/cli/chunk-kx7b5nht.js +11 -0
  95. package/dist/cli/{chunk-a42j8eek.js → chunk-mj7nfaaf.js} +1 -1
  96. package/dist/cli/{chunk-c47gag5r.js → chunk-mvnz68vh.js} +1 -1
  97. package/dist/cli/{chunk-j1fe3j54.js → chunk-mzk4p07t.js} +2 -2
  98. package/dist/cli/chunk-n1tfhd48.js +2 -0
  99. package/dist/cli/{chunk-rtkj4wdw.js → chunk-n1v59qgs.js} +2 -2
  100. package/dist/cli/{chunk-drt79f2t.js → chunk-n2j5sk0g.js} +1 -1
  101. package/dist/cli/chunk-npnbq79j.js +2 -0
  102. package/dist/cli/{chunk-5srsjs7r.js → chunk-nw4p86t1.js} +1 -1
  103. package/dist/cli/{chunk-dzmfexh8.js → chunk-p4fjynez.js} +1 -1
  104. package/dist/cli/{chunk-8sksdq95.js → chunk-p6jw0zcd.js} +1 -1
  105. package/dist/cli/{chunk-ve348rmz.js → chunk-p9t6ye6t.js} +2 -2
  106. package/dist/cli/{chunk-amc17enx.js → chunk-pv2334ak.js} +1 -1
  107. package/dist/cli/chunk-pxdnc5mz.js +91 -0
  108. package/dist/cli/{chunk-4rya4jmx.js → chunk-qeya7dv5.js} +2 -2
  109. package/dist/cli/{chunk-6a70wv2b.js → chunk-qgrg9a5n.js} +1 -1
  110. package/dist/cli/{chunk-4z01vg3t.js → chunk-qnpkhvrn.js} +1 -1
  111. package/dist/cli/{chunk-cgxgqc87.js → chunk-qykg15ks.js} +1 -1
  112. package/dist/cli/{chunk-625773dm.js → chunk-r0etc6vp.js} +1 -1
  113. package/dist/cli/chunk-r40aj7z6.js +2 -0
  114. package/dist/cli/{chunk-jrqtzp35.js → chunk-r67c54hn.js} +1 -1
  115. package/dist/cli/chunk-ra1m0gs4.js +3 -0
  116. package/dist/cli/{chunk-m6pp9gaf.js → chunk-rfp0ayra.js} +1 -1
  117. package/dist/cli/chunk-rn08whn3.js +20 -0
  118. package/dist/cli/chunk-s3cvbp3a.js +3 -0
  119. package/dist/cli/chunk-s4ghfrr9.js +2 -0
  120. package/dist/cli/chunk-s4nrmbqh.js +13 -0
  121. package/dist/cli/{chunk-p2vagan3.js → chunk-s7mzpdgb.js} +1 -1
  122. package/dist/cli/{chunk-tgfn5ykb.js → chunk-sfn4s219.js} +1 -1
  123. package/dist/cli/chunk-sq6zj3fb.js +5 -0
  124. package/dist/cli/{chunk-n9w0026r.js → chunk-tca0hx96.js} +1 -1
  125. package/dist/cli/{chunk-xh72jz7c.js → chunk-tst79jmx.js} +1 -1
  126. package/dist/cli/{chunk-mtw6nce9.js → chunk-twjt04z3.js} +1 -1
  127. package/dist/cli/{chunk-qga9xd2f.js → chunk-v8nvfyd4.js} +1 -1
  128. package/dist/cli/{chunk-m8shvh3j.js → chunk-v967kt9x.js} +1 -1
  129. package/dist/cli/{chunk-w78n33b8.js → chunk-vckr5yvb.js} +1 -1
  130. package/dist/cli/{chunk-67qa9eca.js → chunk-vd6z4v6p.js} +1 -1
  131. package/dist/cli/{chunk-gvmgabps.js → chunk-wa7jswp3.js} +1 -1
  132. package/dist/cli/{chunk-agt2sdaw.js → chunk-wd9n7cwz.js} +6 -6
  133. package/dist/cli/chunk-x4s60mnd.js +2 -0
  134. package/dist/cli/chunk-xex81qeb.js +2 -0
  135. package/dist/cli/{chunk-bwr6dygx.js → chunk-xfgqae9t.js} +1 -1
  136. package/dist/cli/chunk-xt543e2h.js +3 -0
  137. package/dist/cli/{chunk-z72f3d9m.js → chunk-xymn760d.js} +17 -17
  138. package/dist/cli/chunk-y1xnjx8x.js +4 -0
  139. package/dist/cli/chunk-y7a8h5xe.js +2 -0
  140. package/dist/cli/chunk-y8b2p44q.js +2 -0
  141. package/dist/cli/{chunk-yyjskza5.js → chunk-ycd28edp.js} +1 -1
  142. package/dist/cli/chunk-yfvt96ar.js +3 -0
  143. package/dist/cli/{chunk-rwmxpjrx.js → chunk-ykyertq9.js} +1 -1
  144. package/dist/cli/chunk-yssxs1fn.js +3 -0
  145. package/dist/cli/{chunk-z3zaa155.js → chunk-yzkhwn31.js} +1 -1
  146. package/dist/cli/{chunk-prqeddy7.js → chunk-z1nj22va.js} +1 -1
  147. package/dist/cli/chunk-z7d7gk7p.js +2 -0
  148. package/dist/cli/{chunk-0sm0wcx9.js → chunk-zg66t7k9.js} +1 -1
  149. package/dist/cli/chunk-zy2jdze4.js +3 -0
  150. package/dist/cli/index.js +8 -8
  151. package/dist/cli/pty-host-node.mjs +29 -7
  152. package/dist/cli/rove-run.js +1 -1
  153. package/dist/cli/rove.js +1 -1
  154. package/dist/completions/rove.bash +1 -1
  155. package/dist/completions/rove.fish +1 -1
  156. package/dist/completions/rove.zsh +1 -1
  157. package/dist/skills/rove/SKILL.md +25 -20
  158. package/dist/skills/rove/references/api-flags.md +3 -1
  159. package/dist/web/assets/index-BM0Pt6E-.js +111 -0
  160. package/dist/web/assets/index-DneB7YXQ.css +1 -0
  161. package/dist/web/index.html +2 -2
  162. package/dist/web-ui/assets/{harness-dYkQBfYz.js → harness-pEyVtWV4.js} +1 -1
  163. package/dist/web-ui/assets/index-Bsn8NuKa.css +1 -0
  164. package/dist/web-ui/assets/{index-ByMdqeTv.js → index-Dyg-qcgB.js} +2 -2
  165. package/dist/web-ui/index.html +2 -2
  166. package/package.json +3 -3
  167. package/dist/cli/chunk-09sfrqkr.js +0 -2
  168. package/dist/cli/chunk-1bmhygwd.js +0 -2
  169. package/dist/cli/chunk-1gawhhd0.js +0 -3
  170. package/dist/cli/chunk-1nrva2m2.js +0 -11
  171. package/dist/cli/chunk-1pg3247n.js +0 -16
  172. package/dist/cli/chunk-2gk96h3f.js +0 -2
  173. package/dist/cli/chunk-2vrx0pmv.js +0 -2
  174. package/dist/cli/chunk-4250pw6r.js +0 -3
  175. package/dist/cli/chunk-4b9f565d.js +0 -2
  176. package/dist/cli/chunk-4dsyczce.js +0 -2
  177. package/dist/cli/chunk-4gngf0mt.js +0 -70
  178. package/dist/cli/chunk-4sj2sqyt.js +0 -2
  179. package/dist/cli/chunk-56n0whme.js +0 -2
  180. package/dist/cli/chunk-696sqb6j.js +0 -2
  181. package/dist/cli/chunk-7nrzkqt5.js +0 -3
  182. package/dist/cli/chunk-aeswyjhk.js +0 -3
  183. package/dist/cli/chunk-b39sdtt0.js +0 -3
  184. package/dist/cli/chunk-b7xjhgts.js +0 -4
  185. package/dist/cli/chunk-bav3bh70.js +0 -4
  186. package/dist/cli/chunk-bc72rgkm.js +0 -2
  187. package/dist/cli/chunk-bnv1mm5h.js +0 -4
  188. package/dist/cli/chunk-chzn3px6.js +0 -31
  189. package/dist/cli/chunk-cqsc0wmp.js +0 -20
  190. package/dist/cli/chunk-g1px1rk6.js +0 -9
  191. package/dist/cli/chunk-kg8k1rar.js +0 -2
  192. package/dist/cli/chunk-m86qk3za.js +0 -2
  193. package/dist/cli/chunk-njvz867e.js +0 -2
  194. package/dist/cli/chunk-nyw4s1pv.js +0 -2
  195. package/dist/cli/chunk-pcqw7r50.js +0 -2
  196. package/dist/cli/chunk-qdvtz853.js +0 -3
  197. package/dist/cli/chunk-r4vfng2z.js +0 -2
  198. package/dist/cli/chunk-r6k3ve2g.js +0 -3
  199. package/dist/cli/chunk-s0gp5b9p.js +0 -10
  200. package/dist/cli/chunk-s27a0ckk.js +0 -3
  201. package/dist/cli/chunk-sgngkkp3.js +0 -2
  202. package/dist/cli/chunk-spee6wv8.js +0 -3
  203. package/dist/cli/chunk-swxq6yak.js +0 -2
  204. package/dist/cli/chunk-trhrdby1.js +0 -4
  205. package/dist/cli/chunk-tvbbnfp2.js +0 -2
  206. package/dist/cli/chunk-xgans9wf.js +0 -3
  207. package/dist/cli/chunk-xm7a6swz.js +0 -2
  208. package/dist/cli/chunk-y87f04kk.js +0 -2
  209. package/dist/cli/chunk-ywwm92e5.js +0 -2
  210. package/dist/cli/chunk-z5g3twhn.js +0 -2
  211. package/dist/cli/chunk-z99ynm4r.js +0 -3
  212. package/dist/web/assets/index-BsbDxm3K.js +0 -109
  213. package/dist/web/assets/index-DNv-oxrT.css +0 -1
  214. package/dist/web-ui/assets/index-nMJ42IGm.css +0 -1
@@ -1,3 +0,0 @@
1
- // @bun
2
- import{deriveTitleFromPrompt}from"./chunk-cbc1h345.js";import{TaskDeletingError}from"./chunk-j1fe3j54.js";import{awaitEngineProcess,buildEngineSessionLaunch,deliverToHostedKey,enginePresence,ensureHostedEngine,ensureHostedSessionHost,findHostedEngineKey,hostedSessionFailureLine,hostedTaskKeys,killHostedSessions,listHostedSessions,openHostedSessionHost,pastePromptWhenEngineUp,trustEngineWorktree}from"./chunk-ve348rmz.js";import{engineLaunchArgv,protocolEntry}from"./chunk-a42j8eek.js";import{resolveLoginShell}from"./chunk-f5n0tgky.js";import{DEFAULT_TASK_VENDOR}from"./chunk-xy8be792.js";var MAX_SESSIONS_SCANNED=8;function titleFromMessages(messages){let firstUser=messages.find((m)=>m.role==="user");if(!firstUser)return"";let text=firstUser.blocks.filter((b)=>b.type==="text").map((b)=>b.text).join(" "),title=deriveTitleFromPrompt(text);return title.length>0?Buffer.from(title,"utf8").toString("utf8"):title}async function deriveTitleFromSession(worktree,vendor=DEFAULT_TASK_VENDOR){if(!worktree)return"";let{history}=protocolEntry(vendor),ids=await history.listSessionIdsForWorktree(worktree);for(let sessionId of ids.slice(0,MAX_SESSIONS_SCANNED)){let title=titleFromMessages(await history.readHistory(sessionId));if(title)return title}return""}async function deriveTitleFromSessionId(vendor,sessionId){if(!sessionId)return"";try{return titleFromMessages(await protocolEntry(vendor).history.readHistory(sessionId))}catch{return""}}async function getTask(link,taskId){let{task}=await link.request("task.get",{taskId});return task}async function ensureTaskWorktree(link,taskId){let task=await getTask(link,taskId);if(task.deletion)throw new TaskDeletingError(taskId);if(task.worktreePath)return{task,worktreePath:task.worktreePath};let{worktreePath}=await link.request("task.ensureWorktree",{taskId});if(!worktreePath)throw Error(`task ${taskId} has no worktree`);return{task,worktreePath}}async function ensureTaskSessionAdapter(link,taskId){let{task,worktreePath}=await ensureTaskWorktree(link,taskId),launch=taskEngineLaunch(task,worktreePath,{kind:"repo-init"}),host=await ensureHostedSessionHost();try{if(!(await ensureHostedEngine(host.rpc,worktreePath,launch)).alive)throw Error(`failed to start hosted engine session for ${taskId}`);if(launch.firstMessage){let engineBin=engineLaunchArgv({command:task.command,vendor:task.vendor,effort:task.modelEffort,model:task.model})[0];await pastePromptWhenEngineUp(host.rpc,launch.key,engineBin,launch.firstMessage,{initMarkerPath:launch.initMarkerPath,initTimeoutMs:launch.initTimeoutMs}).catch(()=>!1)}}finally{host.close()}return{session:launch.key,worktreePath}}async function startTaskSessionWithPromptAdapter(link,taskId,prompt){let{task,worktreePath}=await ensureTaskWorktree(link,taskId);await link.request("task.observeLanguage",{taskId,text:prompt}).catch(()=>{});let launch=taskEngineLaunch(task,worktreePath,{kind:"new-task",prompt}),host=await ensureHostedSessionHost();try{if(!(await ensureHostedEngine(host.rpc,worktreePath,launch)).alive)return{started:!1,error:"hosted session did not open"};let engineBin=engineLaunchArgv({command:task.command,vendor:task.vendor,effort:task.modelEffort,model:task.model})[0],wait={initMarkerPath:launch.initMarkerPath,initTimeoutMs:launch.initTimeoutMs};if(launch.firstMessage){if(await pastePromptWhenEngineUp(host.rpc,launch.key,engineBin,launch.firstMessage,wait)!==null)return{started:!0};return{started:!1,error:await startFailureReason(host.rpc,launch.key)}}if(await awaitEngineProcess(host.rpc,launch.key,engineBin,wait)!==null)return{started:!0};return{started:!1,error:await startFailureReason(host.rpc,launch.key)}}finally{host.close()}}async function startFailureReason(rpc,key){let tail=await hostedSessionFailureLine(rpc,key),base="engine process never started";return tail?`engine process never started; last session output: ${tail}`:"engine process never started"}function taskEngineLaunch(task,worktreePath,promptIntent){return trustEngineWorktree(task.vendor,worktreePath),buildEngineSessionLaunch({task:{id:task.id,kind:task.kind,vendor:task.vendor,repo:task.repo},worktreePath,shell:resolveLoginShell({fallback:"/bin/zsh"}),argv:engineLaunchArgv({command:task.command,vendor:task.vendor,effort:task.modelEffort,model:task.model}),promptIntent})}async function deliverPromptToLiveEngineAdapter(task,prompt){let host=await openHostedSessionHost();if(!host)return!1;try{let sessions=await listHostedSessions(host.rpc),engineArgv=engineLaunchArgv({command:task.command,vendor:task.vendor}),key=findHostedEngineKey(sessions,task.id,engineArgv[0]);if(!key)return!1;let presence=await enginePresence(sessions.find((s)=>s.key===key)?.pid,engineArgv);if(presence.kind!=="engine")return!1;return await deliverToHostedKey(host.rpc,key,prompt,{vendor:presence.vendor})!==null}catch{return!1}finally{host.close()}}function tabIdFromHostedKey(key){return key.split("::")[1]??"tab-1"}async function deliverPromptToLiveEngineDetailedAdapter(task,prompt){let host=await openHostedSessionHost();if(!host)return{outcome:"no-session"};try{let sessions=await listHostedSessions(host.rpc),engineArgv=engineLaunchArgv({command:task.command,vendor:task.vendor}),key=findHostedEngineKey(sessions,task.id,engineArgv[0]);if(!key)return{outcome:"no-session"};let presence=await enginePresence(sessions.find((s)=>s.key===key)?.pid,engineArgv);if(presence.kind!=="engine")return{outcome:"no-engine",tabId:tabIdFromHostedKey(key)};return await deliverToHostedKey(host.rpc,key,prompt,{vendor:presence.vendor})===null?{outcome:"no-session"}:{outcome:"delivered",tabId:tabIdFromHostedKey(key)}}catch{return{outcome:"no-session"}}finally{host.close()}}async function deliverPromptToLiveEngineTabDetailedAdapter(target,prompt){let host=await openHostedSessionHost();if(!host)return{outcome:"no-session"};try{let key=`${target.id}::${target.tabId}`,sessions;try{sessions=await listHostedSessions(host.rpc)}catch{return{outcome:"no-session"}}let session=sessions.find((candidate)=>candidate.alive&&candidate.key===key);if(!session)return{outcome:"no-session"};let engineArgv=engineLaunchArgv({command:target.command,vendor:target.vendor}),presence=await enginePresence(session.pid,engineArgv);if(presence.kind!=="engine")return{outcome:"no-engine",tabId:target.tabId};return await deliverToHostedKey(host.rpc,key,prompt,{vendor:presence.vendor})===null?{outcome:"no-session"}:{outcome:"delivered",tabId:target.tabId}}finally{host.close()}}async function tearDownTaskSessionAdapter(taskId){let host=await openHostedSessionHost();if(!host)return;try{await killHostedSessions(host.rpc,hostedTaskKeys(await listHostedSessions(host.rpc),taskId),{wait:!0})}catch{}finally{host.close()}}
3
- export{deriveTitleFromSession,deriveTitleFromSessionId,ensureTaskSessionAdapter,startTaskSessionWithPromptAdapter,deliverPromptToLiveEngineAdapter,deliverPromptToLiveEngineDetailedAdapter,deliverPromptToLiveEngineTabDetailedAdapter,tearDownTaskSessionAdapter};
@@ -1,3 +0,0 @@
1
- // @bun
2
- import{basename,dirname,join}from"path";var LEGACY_PRE_RENAME_RUNTIME_NAME="kobe";function preRenameStateDir(home){return join(home,`.${LEGACY_PRE_RENAME_RUNTIME_NAME}`)}function preRenameConfigDir(home){return join(home,".config",LEGACY_PRE_RENAME_RUNTIME_NAME)}function preRenameRuntimePaths(canonical){let name=basename(canonical);if(canonical.startsWith("\\\\.\\pipe\\rove-")&&canonical.endsWith("-pty"))return[canonical.replace("\\pipe\\rove-",`\\pipe\\${LEGACY_PRE_RENAME_RUNTIME_NAME}-`)];if(/^rove(?:-[a-f0-9]{8})?-(?:pty|daemon)(?:-\d+)?\.sock$/.test(name)||name==="rove.sock")return[join(dirname(canonical),name.replace(/^rove/,LEGACY_PRE_RENAME_RUNTIME_NAME))];if(["pty.sock","pty.pid","daemon.sock","daemon.pid"].includes(name)&&basename(dirname(canonical))===".rove")return[join(preRenameStateDir(dirname(dirname(canonical))),name)];return[]}
3
- export{preRenameStateDir,preRenameConfigDir,preRenameRuntimePaths};
@@ -1,4 +0,0 @@
1
- // @bun
2
- import{quoteShellArg,quoteShellArgv}from"./chunk-7kysxgbq.js";import{spawn,spawnSync}from"child_process";import{existsSync}from"fs";import{mkdir,readFile as readFileAsync,readdir as readdirAsync}from"fs/promises";var shQuote=quoteShellArg,shJoin=quoteShellArgv;function shToken(s){return/^[A-Za-z0-9_@%+=:,./-]+$/.test(s)?s:quoteShellArg(s)}function remoteShellCommand(command,cwd){return cwd?`cd ${shQuote(cwd)} && ${command}`:command}function remoteEnvPrefix(env){if(!env)return"";let pairs=Object.entries(env).filter(([key])=>/^[A-Za-z_][A-Za-z0-9_]*$/.test(key));if(pairs.length===0)return"";return`${pairs.map(([key,value])=>`${key}=${shQuote(value)}`).join(" ")} `}function sshConnectArgs(spec,opts={}){let argv=["ssh"];if(opts.tty)argv.push("-tt");if(opts.batch)argv.push("-o","BatchMode=yes");if(argv.push("-o","ControlMaster=auto","-o",`ControlPath=${spec.controlPath}`,"-o","ControlPersist=300"),argv.push("-o","StrictHostKeyChecking=accept-new"),spec.port)argv.push("-p",String(spec.port));if(spec.auth.kind==="key"&&spec.auth.keyPath)argv.push("-i",spec.auth.keyPath);return argv.push(`${spec.user}@${spec.host}`),argv}function spawnCollect(argv,opts={}){return new Promise((resolve)=>{let[cmd,...rest]=argv,stdout="",stderr="",settled=!1,finish=(exitCode)=>{if(settled)return;settled=!0,resolve({stdout,stderr,exitCode})},child;try{child=spawn(cmd??"",rest,{cwd:opts.cwd,env:opts.env,shell:!1,signal:opts.signal})}catch{finish(-1);return}child.stdout?.setEncoding("utf8"),child.stdout?.on("data",(d)=>{stdout+=d}),child.stderr?.setEncoding("utf8"),child.stderr?.on("data",(d)=>{stderr+=d}),child.on("error",()=>finish(-1)),child.on("close",(code)=>finish(code??-1))})}class LocalExecHost{isRemote=!1;run(argv,opts={}){return spawnCollect(argv,{cwd:opts.cwd,env:opts.env?{...process.env,...opts.env}:process.env,signal:opts.signal})}async exists(path){return existsSync(path)}async mkdirp(path){await mkdir(path,{recursive:!0})}async readFile(path){try{return await readFileAsync(path,"utf8")}catch{return null}}async readdir(path){try{return await readdirAsync(path)}catch{return[]}}wrapCommand(command){return command}ensureReady(){}}var defaultSpawner=(argv,env)=>{let[cmd,...rest]=argv,proc=spawnSync(cmd??"",rest,{env:env?{...process.env,...env}:process.env,encoding:"utf8",shell:!1});return{stdout:proc.stdout??"",stderr:proc.stderr??"",exitCode:proc.status??-1}},defaultAsyncSpawner=(argv,env,opts)=>spawnCollect(argv,{env:env?{...process.env,...env}:process.env,signal:opts?.signal});class RemoteExecHost{spec;spawn;isRemote=!0;masterUp=!1;spawnAsync;constructor(spec,spawn2=defaultSpawner,spawnAsync){this.spec=spec;this.spawn=spawn2;this.spawnAsync=spawnAsync??(this.spawn===defaultSpawner?defaultAsyncSpawner:async(argv,env)=>this.spawn(argv,env))}ensureReady(){if(this.masterUp)return;if(this.spawn([...sshConnectArgs(this.spec,{batch:!0}),"-O","check"]).exitCode===0){this.masterUp=!0;return}let base=[...sshConnectArgs(this.spec,{batch:this.spec.auth.kind!=="password"}),"-fN"];if(this.spec.auth.kind==="password"){let pw=this.spec.auth.getPassword();if(pw!=null){this.spawn(["sshpass","-e",...base],{SSHPASS:pw}),this.masterUp=!0;return}}this.spawn(base),this.masterUp=!0}async run(argv,opts={}){this.ensureReady();let remote=remoteShellCommand(`${remoteEnvPrefix(opts.env)}${shJoin(argv)}`,opts.cwd),result=await this.spawnAsync([...sshConnectArgs(this.spec,{batch:!0}),remote],void 0,{signal:opts.signal});if(result.exitCode===255)this.masterUp=!1;return result}async exists(path){return(await this.run(["test","-e",path])).exitCode===0}async mkdirp(path){await this.run(["mkdir","-p",path])}async readFile(path){let r=await this.run(["cat",path]);return r.exitCode===0?r.stdout:null}async readdir(path){let r=await this.run(["ls","-1A",path]);if(r.exitCode!==0)return[];return r.stdout.split(`
3
- `).filter((s)=>s.length>0)}wrapCommand(command,opts={}){let remote=remoteShellCommand(command,opts.cwd);return`${sshConnectArgs(this.spec,{tty:opts.tty}).map(shToken).join(" ")} ${shQuote(remote)}`}}
4
- export{shQuote,LocalExecHost,RemoteExecHost};
@@ -1,4 +0,0 @@
1
- // @bun
2
- import{canonPath,normalizeMainRepo,randomDirTaskSuffix,repoWorkingDir,samePrStatus,titleFromRepo}from"./chunk-zprhxt1q.js";import{GitWorktreeManager,defaultExecDeps,isDirtyOutput,parseDirtyPaths}from"./chunk-s0gp5b9p.js";import{readLastActiveTaskId,writeLastActiveTaskId}from"./chunk-1vtfzcca.js";import{PLACEHOLDER_TASK_TITLE,isPlaceholderDerivedBranch,sanitizeTaskTitle}from"./chunk-cbc1h345.js";import{CannotDeleteMainTaskError,DirtyWorktreeError,EmptyBranchDirtyWorktreeError,EmptyBranchError,GitCommandFailedError,IllegalTransitionError,InvalidWorktreeNameError,LandConflictError,MainCheckoutDirtyError,MissingRefError,TaskDeletingError,TaskNotFoundError,WorktreeNameTakenError,WorktreeRemoveFailedError,canonicalize,listWorktreeDirNames}from"./chunk-j1fe3j54.js";import{detectLanguage}from"./chunk-hpay0ax8.js";import{resolvePreferredVendor}from"./chunk-9g2faw9a.js";import{READ_ONLY_GIT_ENV}from"./chunk-6xppe9bj.js";import{errorMessage}from"./chunk-2brn8e1y.js";import{DEFAULT_TASK_VENDOR}from"./chunk-xy8be792.js";import{addSavedRepo,getSavedRepos,isGitRepo,removeSavedRepo,resolveRepoRoot}from"./chunk-m6pp9gaf.js";import{projectRejection,rejectionReason}from"./chunk-3342qzve.js";import{createStateCell}from"./chunk-cmp64q4j.js";import{pathIdentity,pathWithin,samePath}from"./chunk-pn5ygqn6.js";async function createTaskRow(deps,input){if(!input.repo)throw Error("createTask: repo is required");let repo=(await deps.mainTasks.ensureIfEligible(input.repo,input.projectIntent??"explicit"))?.repo??normalizeMainRepo(input.repo).repo,title=sanitizeTaskTitle(input.title??PLACEHOLDER_TASK_TITLE)||PLACEHOLDER_TASK_TITLE,worktreeName=input.worktreeName?.trim();if(worktreeName)await deps.claimWorktreeName(repo,worktreeName);return await deps.store.create({repo,title,branch:input.branch??"",worktreePath:"",status:"backlog",kind:"task",vendor:input.vendor??DEFAULT_TASK_VENDOR,...input.command?.trim()?{command:input.command.trim()}:{},...input.modelEffort?{modelEffort:input.modelEffort}:{},...input.model?.trim()?{model:input.model.trim()}:{},...input.tier?.trim()?{tier:input.tier.trim()}:{},...input.groupId?{groupId:input.groupId}:{},...input.dispatcher?{dispatcher:input.dispatcher}:{},...input.routine?{routine:input.routine}:{},...input.baseRef?.trim()?{baseRef:input.baseRef.trim()}:{},...worktreeName?{worktreeName}:{}})}async function openDirectoryTaskRow(deps,input){if(!input.dir)throw Error("openDirectoryTask: dir is required");let dir=canonPath(input.dir);return deps.store.create({repo:dir,title:input.scratch?"":`${titleFromRepo(dir)}-${randomDirTaskSuffix()}`,branch:"",worktreePath:dir,status:"backlog",kind:"dir",...input.scratch?{scratch:!0}:{},vendor:input.vendor??resolvePreferredVendor()})}async function adoptScratchRepoRow(deps,id,repo){let task=deps.store.get(id);if(!task||task.kind!=="dir"||task.scratch!==!0)return;let dir=canonPath(repo);await deps.store.update(id,{repo:dir,worktreePath:dir,scratch:!1,title:titleFromRepo(dir)})}function baseRepoCtx(repo,deps){let basePath=deps.remoteBasePath(repo);return{exec:deps.execForRepo(repo),dir:basePath??repo}}async function landGit(exec,dir,args,opts){let r=await exec.run(["git",...args],{cwd:dir,env:opts?.readOnly?READ_ONLY_GIT_ENV:void 0});return{stdout:r.stdout,stderr:r.stderr,exitCode:r.exitCode}}async function isDirty(exec,dir){return isDirtyOutput((await landGit(exec,dir,["status","--porcelain"],{readOnly:!0})).stdout)}async function landPreflight(task,deps=defaultExecDeps){let refuse=(pf,refusal)=>{let refused={...pf,refusal};return{...refused,message:landRefusalError(task,refused).message}},branch=task.branch.trim();if(!branch)throw Error(`landPreflight: task ${task.id} has no branch to land (never materialised)`);let{exec,dir}=baseRepoCtx(task.repo,deps),headOut=await landGit(exec,dir,["symbolic-ref","--short","HEAD"],{readOnly:!0}),landedOn=headOut.stdout.trim();if(headOut.exitCode!==0||!landedOn){let headCommit=await landGit(exec,dir,["rev-parse","--verify","--quiet","HEAD"],{readOnly:!0}),detached=headCommit.exitCode===0&&headCommit.stdout.trim().length>0;return refuse({branch,landedOn:"",baseDir:dir},detached?"DETACHED_HEAD":"UNREADABLE_BASE")}if(landedOn===branch)return refuse({branch,landedOn,baseDir:dir},"SAME_BRANCH");let baseDirty=await isDirty(exec,dir),aheadOut=await landGit(exec,dir,["rev-list","--count",`${landedOn}..${branch}`],{readOnly:!0});if(aheadOut.exitCode!==0){let baseHead=await landGit(exec,dir,["rev-parse","--verify","--quiet","HEAD"],{readOnly:!0});if(baseHead.exitCode!==0||!baseHead.stdout.trim())return refuse({branch,landedOn,baseDirty,baseDir:dir},"UNBORN_BASE");return refuse({branch,landedOn,baseDirty,baseDir:dir},baseDirty?"MAIN_CHECKOUT_DIRTY":"MISSING_REF")}let parsed=Number.parseInt(aheadOut.stdout.trim(),10),base={branch,landedOn,baseDirty,baseDir:dir,...Number.isFinite(parsed)?{ahead:parsed}:{}};if(baseDirty)return refuse(base,"MAIN_CHECKOUT_DIRTY");if(base.ahead!==0)return base;let worktreePath=task.worktreePath.trim();if(worktreePath){let manager=new GitWorktreeManager(deps),dirty=!1;try{dirty=await manager.isDirty(worktreePath)}catch{dirty=!1}if(dirty){let wtExec=deps.execForPath(worktreePath),files=parseDirtyPaths((await landGit(wtExec,worktreePath,["status","--porcelain"],{readOnly:!0})).stdout);return refuse({...base,dirtyFiles:files},"EMPTY_BRANCH_DIRTY_WORKTREE")}}return refuse(base,"EMPTY_BRANCH")}function landRefusalError(task,pf){switch(pf.refusal){case"DETACHED_HEAD":return Error(`landTask: base checkout at ${pf.baseDir} is in detached-HEAD state; check out a branch first`);case"UNREADABLE_BASE":return Error(`landTask: could not read HEAD of the base checkout at ${pf.baseDir} \u2014 is it still a git repo?`);case"UNBORN_BASE":return Error(`landTask: base checkout at ${pf.baseDir} is on '${pf.landedOn}' but has no commits yet, so there is nothing to merge '${pf.branch}' into; make the first commit there (or \`git merge --ff-only ${pf.branch}\`) and land again`);case"SAME_BRANCH":return Error(`landTask: base checkout is already on '${pf.branch}' \u2014 nothing to land onto`);case"MAIN_CHECKOUT_DIRTY":return new MainCheckoutDirtyError(task.repo,pf.baseDir);case"MISSING_REF":return new MissingRefError(pf.branch,pf.landedOn,pf.baseDir);case"EMPTY_BRANCH_DIRTY_WORKTREE":return new EmptyBranchDirtyWorktreeError(pf.branch,pf.landedOn,task.worktreePath.trim(),[...pf.dirtyFiles??[]]);case"EMPTY_BRANCH":return new EmptyBranchError(pf.branch,pf.landedOn)}}async function landTaskWithCleanup(task,opts,deps){if(task.kind==="main")throw Error("landTask: a main task has no branch to land");if(task.kind==="dir")throw Error("landTask: a directory task has no Rove-managed branch to land");let result=await landTask(task,{strategy:opts.strategy}),worktree=opts.removeWorktree===!1?void 0:await removeLandedWorktree(task,opts.callerCwd,deps),branchAnchor=null,branchKept,worktreeGone=!task.worktreePath.trim()||worktree?.removed===!0;if(opts.deleteBranch&&!worktreeGone)branchKept={reason:worktree?.reason??`worktree ${task.worktreePath} was kept, and still has the branch checked out`};else if(opts.deleteBranch){let outcome=await deps.worktrees.deleteBranch(task.repo,result.branch,{force:!0,onAnchor:(record)=>{branchAnchor=record}});if(!outcome.deleted)branchKept={reason:outcome.reason}}return{...result,...worktree?{worktree}:{},...branchAnchor?{branchAnchor}:{},...branchKept?{branchKept}:{}}}async function removeLandedWorktree(task,callerCwd,deps){let worktreePath=task.worktreePath.trim();if(!worktreePath)return{removed:!1,reason:"task has no worktree on disk (never materialised)"};let wt=canonicalize(worktreePath);if(samePath(wt,canonicalize(task.repo)))return{removed:!1,reason:"refusing to remove the base checkout"};if(callerCwd){if(pathWithin(wt,canonicalize(callerCwd))!==null)return{removed:!1,reason:`refusing to remove the caller's own worktree (${worktreePath}) \u2014 re-run from outside it`}}if(deps.tearDownSession)try{await deps.tearDownSession(task.id)}catch{}let residue;try{await deps.worktrees.remove(worktreePath,{onResidue:(r)=>{residue=r}})}catch(err){return{removed:!1,reason:errText(err)}}try{await deps.clearWorktreePath(task.id)}catch(err){return{removed:!0,reason:`worktree removed, but clearing the task's worktree path failed: ${errText(err)}`,...residue?{residue}:{}}}return{removed:!0,...residue?{residue}:{}}}function errText(err){return err instanceof Error?err.message:String(err)}async function conflictedFiles(exec,dir){return(await landGit(exec,dir,["diff","--name-only","--diff-filter=U"],{readOnly:!0})).stdout.split(`
3
- `).map((l)=>l.trim()).filter((l)=>l.length>0)}async function landTask(task,input={},deps=defaultExecDeps){let strategy=input.strategy??"merge",preflight=await landPreflight(task,deps);if(preflight.refusal)throw landRefusalError(task,{...preflight,refusal:preflight.refusal});let{branch,landedOn}=preflight,{exec,dir}=baseRepoCtx(task.repo,deps);if(strategy==="squash"){if((await landGit(exec,dir,["merge","--squash",branch])).exitCode!==0){let files=await conflictedFiles(exec,dir);throw await landGit(exec,dir,["merge","--abort"]).catch(()=>{}),await landGit(exec,dir,["reset","--hard","HEAD"]).catch(()=>{}),new LandConflictError(task.id,branch,files)}let commit=await landGit(exec,dir,["commit","--no-edit","-m",`Land ${branch} (squash)`]);if(commit.exitCode!==0){if((await landGit(exec,dir,["diff","--cached","--quiet"],{readOnly:!0})).exitCode===0)throw await landGit(exec,dir,["reset","--hard","HEAD"]).catch(()=>{}),Error(`landTask: '${branch}' has nothing to land onto '${landedOn}' (already merged or empty)`);throw new GitCommandFailedError(`commit (squash-landing '${branch}' onto '${landedOn}')`,commit.stderr,"the squashed merge is left STAGED in the base checkout \u2014 fix the cause and `git commit` it, or `git reset --hard HEAD` to discard")}}else{let before=(await landGit(exec,dir,["rev-parse","HEAD"],{readOnly:!0})).stdout.trim(),merge=await landGit(exec,dir,["merge","--no-ff","-m",`Land ${branch}`,branch]);if(merge.exitCode!==0){let files=await conflictedFiles(exec,dir);if(await landGit(exec,dir,["merge","--abort"]).catch(()=>{}),files.length===0)throw new GitCommandFailedError(`merge --no-ff (landing '${branch}' onto '${landedOn}')`,merge.stderr,"the merge was aborted, so the base checkout is unchanged");throw new LandConflictError(task.id,branch,files)}let after=(await landGit(exec,dir,["rev-parse","HEAD"],{readOnly:!0})).stdout.trim();if(before===after)throw Error(`landTask: '${branch}' has nothing to land onto '${landedOn}' (already merged or empty)`)}let shaOut=await landGit(exec,dir,["rev-parse","--short","HEAD"],{readOnly:!0});return{branch,strategy,landedOn,commit:shaOut.stdout.trim()}}class MainTaskCoordinator{store;forgetWorktree;locks=new Map;constructor(store,forgetWorktree){this.store=store;this.forgetWorktree=forgetWorktree}async ensure(repo){let task=await this.ensureIfEligible(repo,"explicit");if(task)return task;let{repo:normalizedRepo}=normalizeMainRepo(repo),rejected=projectRejection(normalizedRepo,isGitRepo,"explicit")??"notGitRepo";throw Error(`cannot add ${normalizedRepo} as a project: ${rejectionReason(rejected)}`)}async ensureIfEligible(repo,intent="derived"){let{repo:normalizedRepo,key}=normalizeMainRepo(repo),onThisRoot=(task)=>normalizeMainRepo(task.repo).key===key,existing=this.store.list().find((task)=>task.kind==="main"&&onThisRoot(task));if(existing)return existing;if(projectRejection(normalizedRepo,isGitRepo,intent))return null;let inflight=this.locks.get(key);if(inflight)return inflight;let promise=(async()=>{addSavedRepo(normalizedRepo,{intent:"explicit"});let adoptable=this.store.list().find((task)=>task.kind==="dir"&&task.scratch!==!0&&onThisRoot(task));if(adoptable)return await this.store.update(adoptable.id,this.mainShape(normalizedRepo));return await this.store.create({...this.mainShape(normalizedRepo),status:"backlog",vendor:resolvePreferredVendor(normalizedRepo)})})();this.locks.set(key,promise);try{return await promise}finally{this.locks.delete(key)}}mainShape(normalizedRepo){return{kind:"main",title:titleFromRepo(normalizedRepo),repo:normalizedRepo,branch:"",worktreePath:repoWorkingDir(normalizedRepo)}}async forget(repo){if(!repo)throw Error("forgetProject: repo is required");let key=normalizeMainRepo(repo).key;for(let saved of getSavedRepos())if(normalizeMainRepo(saved).key===key)removeSavedRepo(saved);for(let task of this.store.list()){if(task.kind!=="main")continue;if(normalizeMainRepo(task.repo).key!==key)continue;await this.store.remove(task.id),this.forgetWorktree(task.id)}}}function promotableDirTasks(deps){let claimed=new Set(deps.tasks.filter((task)=>task.kind==="main").map((task)=>pathIdentity(task.repo))),seen=new Set,out=[];for(let task of deps.tasks){if(task.kind!=="dir"||task.scratch===!0)continue;let path=task.repo,key=pathIdentity(path);if(!path||claimed.has(key)||seen.has(key))continue;if(!deps.isRepoRoot(path))continue;seen.add(key),out.push(task)}return out}class TaskDeletionCoordinator{store;worktrees;forgetTask;onSalvage;onResidue;onBranchKept;constructor(store,worktrees,forgetTask,onSalvage,onResidue,onBranchKept){this.store=store;this.worktrees=worktrees;this.forgetTask=forgetTask;this.onSalvage=onSalvage;this.onResidue=onResidue;this.onBranchKept=onBranchKept}async prepare(id,opts){let task=this.store.get(id);if(!task)return!1;if(task.kind==="main")throw new CannotDeleteMainTaskError;if(task.deletion?.phase==="queued"||task.deletion?.phase==="running")return!0;let force=opts?.force===!0;if(task.worktreePath&&!force&&task.kind!=="dir"){let dirty=[],ignored=[],probed=!0;try{dirty=await this.worktrees.dirtyPaths(task.worktreePath)}catch{probed=!1}if(probed&&dirty.length===0)ignored=await this.worktrees.ignoredWork(task.worktreePath);if(dirty.length>0||ignored==="unknown"||ignored.length>0)throw new DirtyWorktreeError(task.id,ignored,dirty)}return await this.store.update(task.id,{deletion:{phase:"queued",force,deleteBranch:opts?.deleteBranch===!0,requestedAt:new Date().toISOString()}}),!0}async begin(id){let task=this.store.get(id);if(!task||!task.deletion||task.deletion.phase==="error")return!1;if(task.deletion.phase!=="running")await this.store.update(task.id,{deletion:{...task.deletion,phase:"running"}});return!0}async finish(id){let task=this.store.get(id);if(!task?.deletion||task.deletion.phase!=="running")return;try{if(task.worktreePath&&task.kind!=="dir")await this.worktrees.remove(task.worktreePath,{force:task.deletion.force,deleteBranch:task.deletion.deleteBranch===!0,repo:task.repo,branch:task.branch,onSalvage:(record)=>{if(record)this.onSalvage?.(task.id,record)},onResidue:(residue)=>this.onResidue?.(task.id,residue),onBranchKept:(kept)=>this.onBranchKept?.(task.id,kept)})}catch(cause){let failure=new WorktreeRemoveFailedError(task.id,cause);throw await this.store.update(task.id,{deletion:{...task.deletion,phase:"error",error:errorMessage(failure)}}),failure}await this.store.remove(task.id),this.forgetTask(task.id)}async deleteNow(id,opts){if(!await this.prepare(id,opts))return;if(!await this.begin(id))return;await this.finish(id)}}var TYPE_PREFIXES=new Set(["feat","feature","fix","bugfix","hotfix","chore","docs","doc","refactor","test","tests","ci","build","perf","style","revert","release"]),BRAND_TOKENS=new Set(["rove"]);function inferBranchStyle(names){let typed=new Map,bare=0;for(let raw of new Set(names)){let name=raw.trim();if(!name||name==="HEAD")continue;let slash=name.indexOf("/");if(slash===-1){bare+=1;continue}let prefix=name.slice(0,slash);if(TYPE_PREFIXES.has(prefix))typed.set(prefix,(typed.get(prefix)??0)+1)}let typedTotal=0;for(let n of typed.values())typedTotal+=n;if(typedTotal===0||typedTotal<bare)return{kind:"bare"};let best="",bestN=0;for(let[prefix,n]of typed)if(n>bestN||n===bestN&&(best===""||prefix<best))best=prefix,bestN=n;return{kind:"typed",defaultPrefix:best}}function slugTokens(title){return title.toLowerCase().replace(/[^a-z0-9]+/g,"-").split("-").filter((t)=>t.length>0&&!BRAND_TOKENS.has(t))}function capSlug(tokens){let slug="";for(let token of tokens){let candidate=slug?`${slug}-${token}`:token;if(candidate.length>32)return slug||token.slice(0,32);slug=candidate}return slug}function identitySlug(taskId){return`task-${taskId.slice(-6).toLowerCase()}`}function deriveConventionBranch(title,style,taskId){let tokens=slugTokens(title);if(style.kind==="typed"){let first=tokens[0];return`${first!==void 0&&TYPE_PREFIXES.has(first)?tokens.shift():style.defaultPrefix}/${capSlug(tokens)||identitySlug(taskId)}`}return capSlug(tokens)||identitySlug(taskId)}function uniqueBranchName(base,taken,taskId){let dirs=new Set;for(let name of taken)for(let i=name.indexOf("/");i>0;i=name.indexOf("/",i+1))dirs.add(name.slice(0,i));let isFree=(name)=>!taken.has(name)&&!dirs.has(name),segments=base.split("/"),root=segments.slice(0,-1).some((_,i)=>taken.has(segments.slice(0,i+1).join("/")))?segments.join("-"):base;if(isFree(root))return root;for(let n=2;n<=99;n+=1){let candidate=`${root}-${n}`;if(isFree(candidate))return candidate}return`${root}-${taskId.slice(-6).toLowerCase()}`}class TaskEditor{store;worktrees;constructor(store,worktrees){this.store=store,this.worktrees=worktrees}requireTask(id){let task=this.store.get(id);if(!task)throw new TaskNotFoundError(String(id));return task}async setTitle(id,title){let trimmed=sanitizeTaskTitle(title);if(!trimmed)throw Error("setTitle: title is required (empty or whitespace-only rejected)");let task=this.requireTask(id);if(task.title===trimmed&&task.scratch!==!0)return;await this.store.update(task.id,{title:trimmed,...task.scratch===!0?{scratch:!1}:{}}),await this.followBranchToTitle(task,trimmed)}async followBranchToTitle(taskBefore,newTitle){if(taskBefore.kind==="main"||!taskBefore.worktreePath)return;if(!isPlaceholderDerivedBranch(taskBefore.branch,taskBefore.id))return;try{let names=await this.worktrees.listBranchNames(taskBefore.repo),base=deriveConventionBranch(newTitle,inferBranchStyle(names),taskBefore.id);if(base===taskBefore.branch)return;if(await this.worktrees.branchHasUpstream(taskBefore.worktreePath,taskBefore.branch))return;let taken=new Set(names.filter((n)=>n!==taskBefore.branch)),nextBranch=uniqueBranchName(base,taken,taskBefore.id);await this.setBranch(taskBefore.id,nextBranch)}catch(err){console.error(`[rove] follow-branch-to-title failed for ${taskBefore.id}:`,err)}}async setBranch(id,branch){let trimmed=branch.trim();if(!trimmed)throw Error("setBranch: branch is required (empty or whitespace-only rejected)");let task=this.requireTask(id);if(task.kind==="main")throw Error("setBranch: a main task tracks the repo's own branch; rename it with git directly");if(task.kind==="dir")throw Error("setBranch: a directory task tracks its own checkout; rename branches with git directly");if(task.branch===trimmed)return;if(task.worktreePath)await this.worktrees.renameBranch(task.worktreePath,task.branch,trimmed);await this.store.update(task.id,{branch:trimmed})}async observeLanguage(id,text){let observed=detectLanguage(text);if(!observed)return;let task=this.requireTask(id);if(task.observedLanguage===observed)return;await this.store.update(task.id,{observedLanguage:observed})}async setVendor(id,vendor,effort,model){let task=this.requireTask(id),switching=task.vendor!==vendor,effortArg=effort??(switching?"":void 0),modelArg=model??(switching?"":void 0),nextEffort=effortArg?.trim()?effortArg.trim():void 0,effortChanges=effortArg!==void 0&&task.modelEffort!==nextEffort,nextModel=modelArg?.trim()?modelArg.trim():void 0,modelChanges=modelArg!==void 0&&task.model!==nextModel;if(!switching&&!effortChanges&&!modelChanges)return;await this.store.update(task.id,{vendor,...effortArg!==void 0?{modelEffort:nextEffort}:{},...modelArg!==void 0?{model:nextModel}:{}})}async setCommand(id,command,vendor){let trimmed=command.trim();if(!trimmed)throw Error("setCommand: command is required (empty or whitespace-only rejected)");let task=this.requireTask(id),switching=vendor!==void 0&&task.vendor!==vendor;if(task.command===trimmed&&!switching)return;await this.store.update(task.id,{command:trimmed,...switching?{vendor,model:void 0,modelEffort:void 0}:{}})}async setPinned(id,pinned){let task=this.requireTask(id);if(task.kind==="main")return;let next=pinned??!task.pinned;if((task.pinned??!1)===next)return;await this.store.update(task.id,{pinned:next})}async setRequireReport(id,required){let task=this.requireTask(id);if((task.requireReport??!1)===required)return;await this.store.update(task.id,{requireReport:required||void 0})}async moveTask(id,delta){let task=this.requireTask(id);await this.store.move(task.id,delta,this.movePartition(task))}async moveTaskToTop(id){let task=this.requireTask(id);await this.store.moveToFront(task.id,this.movePartition(task))}movePartition(task){let isMain=task.kind==="main";return this.store.list().filter((t)=>isMain?(t.kind??"task")==="main":(t.kind??"task")!=="main"&&samePath(t.repo,task.repo)&&(t.pinned??!1)===(task.pinned??!1)).map((t)=>String(t.id))}async setStatus(id,status){let task=this.requireTask(id);if(task.status===status)return;if(task.status==="done"&&status==="error"||task.status==="error"&&status==="done")throw new IllegalTransitionError(task.status,status,task.id);await this.store.update(task.id,{status})}async setWorkerReport(id,report){let task=this.requireTask(id),next={...task.report,...report,at:new Date().toISOString()};await this.store.update(task.id,{report:next})}async setPRStatus(id,prStatus){let task=this.requireTask(id);if((task.prStatus?.lastError??null)===(prStatus?.lastError??null)&&samePrStatus(task.prStatus,prStatus??void 0))return;await this.store.update(task.id,{prStatus:prStatus??void 0})}async setQuotaResume(id,state){let task=this.requireTask(id);if((task.quotaResume?.resumeAt??null)===(state?.resumeAt??null))return;await this.store.update(task.id,{quotaResume:state??void 0})}async setLinkedWorkItem(id,item){let task=this.requireTask(id);if((task.linkedWorkItem?.url??null)===(item?.url??null))return;await this.store.update(task.id,{linkedWorkItem:item??void 0})}async setPrompt(id,prompt){if(prompt.trim().length===0)throw Error("setPrompt: prompt is required (empty or whitespace-only rejected)");let task=this.requireTask(id);if(task.prompt===prompt)return;await this.store.update(task.id,{prompt})}}import{basename}from"path";var ANIMAL_NAMES=["aardvark","addax","adder","agouti","albatross","alpaca","anaconda","anchovy","anglerfish","anole","anteater","antelope","ape","argali","armadillo","avocet","axolotl","baboon","badger","banteng","barracuda","basilisk","bass","bat","beagle","bear","beaver","bee","beetle","beluga","betta","bison","blackbird","blenny","bluebird","bluegill","boar","bobcat","bonito","bovid","buffalo","bullfrog","bunting","bushbuck","butterfly","buzzard","caiman","camel","canary","capybara","caracal","cardinal","caribou","carp","cassowary","caterpillar","catfish","chameleon","chamois","char","cheetah","chickadee","chimp","chinchilla","chipmunk","chough","cicada","civet","clam","clownfish","cobra","cockatoo","condor","coot","copperhead","coral","cormorant","cougar","coyote","crab","crane","crawfish","crayfish","cricket","crocodile","crow","cuckoo","curlew","cuttlefish","deer","dikdik","dingo","dolphin","donkey","dormouse","dotterel","dove","dragonfly","dromedary","duck","dugong","dunlin","eagle","echidna","eel","egret","eider","eland","elephant","elk","emu","ermine","falcon","fawn","ferret","finch","firefly","flamingo","flounder","fox","frog","gadwall","gannet","gaur","gazelle","gecko","gemsbok","gerbil","gharial","gibbon","gnu","goat","goby","godwit","goldfish","goose","gopher","goral","gorilla","goshawk","grackle","grasshopper","grayling","grebe","grouse","guanaco","guillemot","guineafowl","guppy","halibut","hammerhead","hamster","hare","harrier","hartebeest","hawk","hedgehog","heron","herring","hippo","hornbill","hornet","horse","hummingbird","hyena","ibex","ibis","iguana","impala","indri","jacana","jackal","jaguar","jay","jellyfish","jerboa","junco","kakapo","kangaroo","kestrel","killdeer","kingfisher","kinglet","kite","kiwi","koala","kookaburra","krait","krill","kudu","ladybug","lamprey","langur","lapwing","lark","lemming","lemur","leopard","limpet","lion","lionfish","lizard","llama","lobster","locust","loon","lorikeet","loris","lynx","macaque","macaw","mackerel","magpie","mallard","mamba","mammoth","manatee","mandrill","manta","mantis","marlin","marmoset","marmot","marten","meerkat","merganser","mink","minnow","mole","mongoose","monitor","monkey","moose","moth","mouflon","mouse","mudpuppy","mule","muntjac","musk","muskox","muskrat","mussel","mustang","narwhal","newt","nightingale","numbat","nuthatch","nyala","ocelot","octopus","okapi","opossum","orangutan","orca","oriole","oryx","osprey","ostrich","otter","owl","oyster","oystercatcher","paca","panda","pangolin","panther","parakeet","parrot","parrotfish","partridge","peafowl","pelican","penguin","perch","petrel","pheasant","pigeon","pika","pike","pintail","pipefish","platypus","plover","pollock","pony","porcupine","porpoise","possum","ptarmigan","puffin","puma","pupfish","python","quail","quetzal","quokka","quoll","rabbit","raccoon","rail","rat","rattler","raven","ray","redpoll","reindeer","remora","rhino","roadrunner","robin","rook","sable","sailfish","salamander","salmon","sandpiper","sardine","scallop","scaup","scorpion","seahorse","seal","serval","shark","shearwater","shrew","shrike","shrimp","siskin","sitatunga","skate","skink","skua","skunk","sloth","smelt","snail","snipe","solenodon","sparrow","spider","springbok","squid","squirrel","starfish","starling","stilt","stingray","stoat","stork","sunbird","sunfish","swallow","swan","swift","swordfish","tahr","takin","tamarin","tanager","tapir","tarantula","tarpon","tarsier","teal","tenrec","terrapin","tern","tetra","thrasher","thrush","tiger","toad","tortoise","toucan","treecreeper","treefrog","trout","tuatara","tuna","turkey","turtle","urchin","urial","vicuna","viper","vole","vulture","wagtail","wallaby","walleye","walrus","warbler","warthog","waterbuck","weasel","wildebeest","wolf","wolverine","wombat","woodcock","woodpecker","wrasse","wren","yak","zebra","zebu","zorilla"];class SlugAllocator{activeSlugs;random;pool;pendingByRepo=new Map;chain=Promise.resolve();constructor(activeSlugs,options={}){this.activeSlugs=activeSlugs;if(this.random=options.random??Math.random,this.pool=options.pool??ANIMAL_NAMES,this.pool.length===0)throw Error("SlugAllocator: animal pool cannot be empty")}async allocate(repo){let previous=this.chain,release;this.chain=new Promise((resolve)=>{release=resolve}),await previous;try{return await this.pickLocked(repo)}finally{release()}}async claim(repo,slug){let previous=this.chain,release;this.chain=new Promise((resolve)=>{release=resolve}),await previous;try{if((await this.occupiedSlugs(repo)).has(slug))throw new WorktreeNameTakenError(slug);return this.addPending(repo,slug),slug}finally{release()}}commit(repo,slug){this.deletePending(repo,slug)}cancel(repo,slug){this.deletePending(repo,slug)}async pickLocked(repo){let occupied=await this.occupiedSlugs(repo),candidates=this.pool.filter((n)=>!occupied.has(n));if(candidates.length>0){let pick=candidates[Math.floor(this.random()*candidates.length)];return this.addPending(repo,pick),pick}let base=this.pool[Math.floor(this.random()*this.pool.length)];for(let v=2;;v++){let candidate=`${base}-v${v}`;if(!occupied.has(candidate))return this.addPending(repo,candidate),candidate}}async occupiedSlugs(repo){let set=new Set(this.pendingByRepo.get(repo)??[]);for(let slug of this.activeSlugs(repo))if(slug)set.add(slug);for(let dir of await listWorktreeDirNames(repo))set.add(dir);return set}addPending(repo,slug){let pending=this.pendingByRepo.get(repo);if(!pending)pending=new Set,this.pendingByRepo.set(repo,pending);pending.add(slug)}deletePending(repo,slug){let pending=this.pendingByRepo.get(repo);if(!pending)return;if(pending.delete(slug),pending.size===0)this.pendingByRepo.delete(repo)}}var WORKTREE_NAME_RE=/^[A-Za-z0-9_][A-Za-z0-9._-]*$/;class WorktreeCoordinator{store;worktrees;canonPath;ensureProject;slugs;worktreeLocks=new Map;adoptLocks=new Map;reservedBranches=new Set;constructor(store,worktrees,canonPath2,ensureProject){this.store=store,this.worktrees=worktrees,this.canonPath=canonPath2,this.ensureProject=ensureProject,this.slugs=new SlugAllocator((repo)=>this.store.list().filter((t)=>samePath(t.repo,repo)&&t.kind!=="main").map((t)=>{return t.worktreePath.match(/([^/\\]+)[/\\]*$/)?.[1]??""}).filter((s)=>s.length>0))}async claimWorktreeName(repo,name){if(!WORKTREE_NAME_RE.test(name))throw new InvalidWorktreeNameError(name);return await this.slugs.claim(repo,name)}forget(id){this.worktreeLocks.delete(id)}async ensure(task){let inflight=this.worktreeLocks.get(task.id);if(inflight)return inflight;let work=this.createWorktree(task);this.worktreeLocks.set(task.id,work);try{return await work}finally{this.worktreeLocks.delete(task.id)}}async createWorktree(task){let slug=task.worktreeName||await this.slugs.allocate(task.repo),branch=task.branch||await this.deriveAutoBranch(task),baseRef=task.baseRef,info;try{info=await this.worktrees.createForTask({repo:task.repo,slug,branch,baseRef})}catch(err){throw this.slugs.cancel(task.repo,slug),err}finally{this.reservedBranches.delete(branch)}try{await this.store.update(task.id,{worktreePath:info.path,branch})}catch(err){throw await this.rollbackWorktree(info.path),this.slugs.cancel(task.repo,slug),err}return this.slugs.commit(task.repo,slug),info.path}async deriveAutoBranch(task){let names=await this.worktrees.listBranchNames(task.repo),base=deriveConventionBranch(task.title,inferBranchStyle(names),task.id),taken=new Set([...names,...this.reservedBranches]),branch=uniqueBranchName(base,taken,task.id);return this.reservedBranches.add(branch),branch}async rollbackWorktree(worktreePath){try{await this.worktrees.remove(worktreePath,{force:!0})}catch(err){console.error(`[rove] ensureWorktree rollback failed for ${worktreePath}:`,err)}}async discoverAdoptable(repo){let all=await this.worktrees.listAll(repo),linked=new Set(this.store.list().filter((t)=>t.worktreePath).map((t)=>this.canonPath(t.worktreePath)));return all.filter((wt)=>!linked.has(this.canonPath(wt.path)))}async adopt(input){let target=this.canonPath(input.worktreePath),inflight=this.adoptLocks.get(target);if(inflight)return inflight;let work=this.adoptLocked(input,target);this.adoptLocks.set(target,work);try{return await work}finally{this.adoptLocks.delete(target)}}async adoptLocked(input,target){let existing=this.store.list().find((t)=>t.worktreePath&&this.canonPath(t.worktreePath)===target);if(existing){if(input.ifExists==="return")return existing;throw Error(`adoptWorktree: ${input.worktreePath} is already adopted as a task`)}let match=(await this.worktrees.listAdoptablePaths(input.repo)).find((wt)=>this.canonPath(wt.path)===target);if(!match)throw Error(`adoptWorktree: ${input.worktreePath} is not an adoptable git worktree of ${input.repo} (unknown, detached, or the main checkout)`);let branch=input.branch?.trim()||match.branch,title=(input.title??basename(match.path)).trim()||PLACEHOLDER_TASK_TITLE;return await this.ensureProject(input.repo),this.store.create({repo:input.repo,title,branch,worktreePath:match.path,status:"backlog",kind:"task",vendor:input.vendor??DEFAULT_TASK_VENDOR})}}class Orchestrator{store;worktrees;worktreeCoordinator;editor;deletions;tasksAcc;activeTaskAcc;unsubscribeStore;mainTasks;tearDownSession;constructor(deps){this.store=deps.store,this.worktrees=deps.worktrees,this.tearDownSession=deps.tearDownSession,this.worktreeCoordinator=new WorktreeCoordinator(this.store,this.worktrees,canonPath,(repo)=>this.mainTasks.ensureIfEligible(repo)),this.mainTasks=new MainTaskCoordinator(this.store,(id)=>this.worktreeCoordinator.forget(id)),this.editor=new TaskEditor(this.store,this.worktrees),this.deletions=new TaskDeletionCoordinator(this.store,this.worktrees,(id)=>this.worktreeCoordinator.forget(id),deps.onSalvage,deps.onWorktreeResidue,deps.onBranchKept),this.tasksAcc=createStateCell(this.store.list());let persistedFocus=readLastActiveTaskId();this.activeTaskAcc=createStateCell(persistedFocus&&this.store.get(persistedFocus)?persistedFocus:null),this.unsubscribeStore=this.store.subscribe((snapshot)=>{this.tasksAcc.set(snapshot.slice())})}async init(){try{let promotable=promotableDirTasks({tasks:this.store.list(),isRepoRoot:(path)=>isGitRepo(path)&&samePath(resolveRepoRoot(path),path)});for(let task of promotable)await this.mainTasks.ensureIfEligible(task.repo,"explicit")}catch{}}activeTaskSignal(){return this.activeTaskAcc}async setActiveTask(id){let next=id===null?null:String(id);if(next&&this.store.get(next)?.deletion)throw new TaskDeletingError(next);if(this.activeTaskAcc.set(next),next&&this.store.get(next))writeLastActiveTaskId(next),this.store.touchRecency(next)}tasksSignal(){return this.tasksAcc}subscribeTasks(listener){return this.store.subscribe(listener)}dispose(){this.unsubscribeStore()}listTasks(){return this.store.list()}getTask(id){return this.store.get(id)}createTask=(input)=>createTaskRow({store:this.store,mainTasks:this.mainTasks,claimWorktreeName:(repo,name)=>this.worktreeCoordinator.claimWorktreeName(repo,name)},input);openDirectoryTask=(input)=>openDirectoryTaskRow({store:this.store},input);adoptScratchRepo=(id,repo)=>adoptScratchRepoRow({store:this.store},id,repo);async ensureMainTask(repo){return await this.mainTasks.ensure(repo)}async ensureWorktree(id){let task=this.requireTask(id);if(task.deletion)throw new TaskDeletingError(String(task.id));if(task.kind==="main")return repoWorkingDir(task.repo);if(task.kind==="dir")return task.worktreePath;if(task.worktreePath){if(await this.worktrees.pathExists(task.worktreePath))return task.worktreePath;return await this.worktrees.pruneWorktrees(task.repo),await this.store.update(task.id,{worktreePath:""}),this.worktreeCoordinator.ensure({...task,worktreePath:""})}return this.worktreeCoordinator.ensure(task)}async clearWorktreePath(id){let task=this.store.get(id);if(!task||!task.worktreePath)return;if(task.kind==="main"||task.kind==="dir")return;await this.store.update(task.id,{worktreePath:""}),this.worktreeCoordinator.forget(task.id)}setTitle=(id,title)=>this.editor.setTitle(id,title);setBranch=(id,branch)=>this.editor.setBranch(id,branch);observeLanguage=(id,text)=>this.editor.observeLanguage(id,text);setVendor=(id,vendor,effort,model)=>this.editor.setVendor(id,vendor,effort,model);setCommand=(id,command,vendor)=>this.editor.setCommand(id,command,vendor);setPinned=(id,pinned)=>this.editor.setPinned(id,pinned);setRequireReport=(id,required)=>this.editor.setRequireReport(id,required);moveTask=(id,delta)=>this.editor.moveTask(id,delta);moveTaskToTop=(id)=>this.editor.moveTaskToTop(id);setStatus=(id,status)=>this.editor.setStatus(id,status);setWorkerReport=(id,report)=>this.editor.setWorkerReport(id,report);setPRStatus=(id,prStatus)=>this.editor.setPRStatus(id,prStatus);setLinkedWorkItem=(id,item)=>this.editor.setLinkedWorkItem(id,item);setQuotaResume=(id,state)=>this.editor.setQuotaResume(id,state);setPrompt=(id,prompt)=>this.editor.setPrompt(id,prompt);async deleteTask(id,opts){await this.deletions.deleteNow(id,opts)}async prepareTaskDeletion(id,opts){return this.deletions.prepare(id,opts)}async beginTaskDeletion(id){return this.deletions.begin(id)}async finishTaskDeletion(id){return this.deletions.finish(id)}async landPreflight(id){let task=this.requireTask(id);if(task.kind==="main")throw Error("landTask: a main task has no branch to land");if(task.kind==="dir")throw Error("landTask: a directory task has no Rove-managed branch to land");if(task.deletion)throw new TaskDeletingError(String(task.id));return landPreflight(task)}async landTask(id,opts){let task=this.requireTask(id);if(task.deletion)throw new TaskDeletingError(String(task.id));return landTaskWithCleanup(task,opts??{},{worktrees:this.worktrees,clearWorktreePath:(tid)=>this.clearWorktreePath(tid),tearDownSession:this.tearDownSession})}async forgetProject(repo){await this.mainTasks.forget(repo)}async discoverAdoptableWorktrees(repo){if(!repo)throw Error("discoverAdoptableWorktrees: repo is required");return this.worktreeCoordinator.discoverAdoptable(repo)}async adoptWorktree(input){if(!input.repo)throw Error("adoptWorktree: repo is required");if(!input.worktreePath)throw Error("adoptWorktree: worktreePath is required");return this.worktreeCoordinator.adopt(input)}requireTask(id){let task=this.store.get(id);if(!task)throw new TaskNotFoundError(String(id));return task}}
4
- export{Orchestrator};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{ConnectTimeoutError,RoveDaemonClient,RpcTimeoutError}from"./chunk-kmgheesn.js";import"./chunk-szjgjrar.js";import"./chunk-gskbzgc3.js";import"./chunk-pn5ygqn6.js";import"./chunk-n0rtj4z7.js";import"./chunk-b39sdtt0.js";import"./chunk-nc46gddg.js";import"./chunk-91sykzqq.js";export{RpcTimeoutError,RoveDaemonClient,ConnectTimeoutError};
@@ -1,4 +0,0 @@
1
- // @bun
2
- import{logDaemonInfo}from"./chunk-rxqdw6s5.js";import{resolveRoveSpawn,testDaemonResponds}from"./chunk-tgfn5ykb.js";import{stopDaemonProcess}from"./chunk-qga9xd2f.js";import{spawnDetachedDaemon,windowsPowershellPath}from"./chunk-5v02t4pz.js";import{isProcessAlive,readPidFile}from"./chunk-wqckm0k6.js";import{RoveDaemonClient}from"./chunk-kmgheesn.js";import{defaultPtyHostLogPath,defaultPtyHostPidPath,defaultPtyHostSocketPath}from"./chunk-n0rtj4z7.js";import{spawn}from"child_process";import{existsSync}from"fs";import{rename,rm}from"fs/promises";import{basename,delimiter,dirname,join,resolve}from"path";import{fileURLToPath}from"url";var PTY_HOST_START_ARGS=["pty-host"],PTY_HOST_NODE_BUNDLE="pty-host-node.mjs",PTY_HOST_NODE_DEV_CACHE="../../.cache/pty-host-node.mjs",PTY_HOST_NODE_ENTRY="../daemon/pty-host-node-entry.ts";function resolveNodeBinary(env=process.env,exists=existsSync,platform=process.platform){let dirs=(env.PATH??env.Path??"").split(delimiter).filter((dir)=>dir.length>0),suffixes=platform==="win32"?(env.PATHEXT??".EXE;.CMD;.BAT").split(";").filter((ext)=>ext.length>0):[""];for(let dir of dirs)for(let suffix of suffixes){let candidate=join(dir,`node${suffix}`);if(exists(candidate))return candidate}return null}async function bundleWithBun(entry,outFile,io){let{build,rename:move,discard}=io??{build:(config)=>Bun.build(config),rename,discard:(path)=>rm(path,{force:!0})},staging=`${outFile}.${process.pid}.tmp`,built=await build({entrypoints:[entry],outdir:dirname(staging),target:"node",format:"esm",naming:basename(staging),external:["node-pty"]});if(!built.success)return await discard(staging).catch(()=>{}),built;return await move(staging,outFile),built}async function resolveNodePtyHostSpawn(deps={}){let platform=deps.platform??process.platform;if(platform!=="win32")return null;let here=deps.moduleDir??dirname(fileURLToPath(import.meta.url)),exists=deps.exists??existsSync,bundle=deps.bundle??bundleWithBun,node=resolveNodeBinary(deps.env??process.env,exists,platform);if(!node)throw Error("Rove: the Windows PTY host runs under node, but no node was found on PATH. "+"Install Node.js (https://nodejs.org) and restart Rove \u2014 engine and terminal sessions cannot start without it.");let packaged=resolve(here,PTY_HOST_NODE_BUNDLE);if(exists(packaged))return[node,packaged];let entry=resolve(here,PTY_HOST_NODE_ENTRY);if(!exists(entry))throw Error(`Rove: no Windows PTY host found (looked for ${packaged} and ${entry})`);let cache=resolve(here,PTY_HOST_NODE_DEV_CACHE),built=await bundle(entry,cache);if(!built.success)throw Error(`Rove: could not build the Windows PTY host \u2014 ${built.logs.map(String).join("; ")}`);return[node,cache]}var BUSY_PTY_HOST_GRACE_MS=15000,CHILD_PROBE_TIMEOUT_MS=5000;function childProbeCommand(deps={}){let env=deps.env??process.env;if((deps.platform??process.platform)!=="win32")return["ps","-A","-o","ppid="];return[windowsPowershellPath(env,deps.exists??existsSync),"-NoProfile","-NonInteractive","-Command","[Console]::OutputEncoding=[System.Text.Encoding]::UTF8; Get-CimInstance -ClassName Win32_Process -Property ParentProcessId | Select-Object -ExpandProperty ParentProcessId"]}function runChildProbe(command,timeoutMs){return new Promise((done,fail)=>{let proc=spawn(command[0]??"",command.slice(1),{stdio:["ignore","pipe","ignore"]}),out="",finish=(err)=>{clearTimeout(timer);try{proc.kill()}catch{}if(err)fail(err);else done(out)},timer=setTimeout(()=>finish(Error(`did not answer within ${timeoutMs}ms`)),timeoutMs);proc.stdout?.on("data",(chunk)=>{out+=String(chunk)}),proc.on("error",(err)=>finish(err)),proc.on("close",(code,signal)=>finish(code===0&&signal===null?null:Error(`exited with ${signal??`code ${code}`}`)))})}async function liveChildCount(pid,deps={}){let timeoutMs=deps.timeoutMs??CHILD_PROBE_TIMEOUT_MS,command=childProbeCommand(deps),run=deps.run??runChildProbe,text;try{text=await run(command,timeoutMs)}catch{return null}let rows=text.split(`
3
- `).map((row)=>row.trim()).filter((row)=>row.length>0);if(rows.length===0||rows.some((row)=>!/^\d+$/.test(row)))return null;return rows.filter((row)=>Number(row)===pid).length}async function ensurePtyHostReachable(){let socketPath=defaultPtyHostSocketPath();if(await testDaemonResponds(socketPath))return socketPath;let hostPid=await readPidFile(defaultPtyHostPidPath());if(hostPid!==null&&hostPid!==process.pid&&isProcessAlive(hostPid)){let deadline2=Date.now()+BUSY_PTY_HOST_GRACE_MS;while(Date.now()<deadline2){if(await new Promise((resolveTimer)=>setTimeout(resolveTimer,250)),await testDaemonResponds(socketPath))return socketPath;if(!isProcessAlive(hostPid))break}if(isProcessAlive(hostPid)){let sessions=await liveChildCount(hostPid);if(sessions===null)throw Error(`rove: the pty host (pid ${hostPid}) is not answering and Rove could not read this machine's process table, so it cannot tell whether the host still holds live sessions \u2014 refusing to restart it, which would kill every engine running in them. Inspect it with \`rove api pty-list\`, or kill ${hostPid} yourself once you have accepted losing those sessions.`);if(sessions>0)throw Error(`rove: the pty host (pid ${hostPid}) is not answering but still holds ${sessions} live session(s) \u2014 refusing to restart it, which would kill every engine running in them. Inspect it with \`rove api pty-list\`, or kill ${hostPid} yourself once you have accepted losing those sessions.`)}}await stopDaemonProcess(socketPath,defaultPtyHostPidPath()).catch(()=>{});let[command,...args]=await resolveNodePtyHostSpawn()??resolveRoveSpawn(PTY_HOST_START_ARGS);spawnDetachedDaemon(command??"",args,process.env,defaultPtyHostLogPath());let deadline=Date.now()+5000;while(Date.now()<deadline){if(await testDaemonResponds(socketPath))return socketPath;await new Promise((resolveTimer)=>setTimeout(resolveTimer,100))}throw Error(`rove: pty host did not start (or stayed wedged) at ${socketPath}; check ${defaultPtyHostLogPath()} or run \`rove doctor\``)}async function sweepPtyHostSessions(liveTaskIds,homeDir){let client=new RoveDaemonClient(defaultPtyHostSocketPath(homeDir));try{await client.connect();let{sessions}=await client.request("pty.list"),currentTasks;for(let session of sessions){if(!currentTasks){let ids=liveTaskIds();if(ids===null)return;currentTasks=new Set(ids)}if(currentTasks.has(session.key.split("::")[0]??session.key))continue;if(!session.generation){logDaemonInfo("pty-sweep",`skipped ${session.key}: host has no session generation; restart it when sessions can be interrupted`);continue}await client.request("pty.kill",{key:session.key,expectedGeneration:session.generation}),currentTasks=void 0}}catch{}finally{client.close()}}async function ptyHostHasLiveSessions(homeDir){let client=new RoveDaemonClient(defaultPtyHostSocketPath(homeDir));try{await client.connect();let result=await client.request("pty.list");if(!Array.isArray(result.sessions)||result.sessions.some((s)=>typeof s.alive!=="boolean"))return null;return result.sessions.some((s)=>s.alive)}catch(err){if(err instanceof Error&&"code"in err&&(err.code==="ENOENT"||err.code==="ECONNREFUSED")){let pid=await readPidFile(defaultPtyHostPidPath(homeDir));return pid!==null&&isProcessAlive(pid)?null:!1}return null}finally{client.close()}}
4
- export{resolveNodeBinary,bundleWithBun,resolveNodePtyHostSpawn,childProbeCommand,runChildProbe,liveChildCount,ensurePtyHostReachable,sweepPtyHostSessions,ptyHostHasLiveSessions};