@sma1lboy/rove 0.9.273 → 0.9.276

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 (195) hide show
  1. package/dist/cli/chunk-0d7517kk.js +6 -0
  2. package/dist/cli/{chunk-55ajzrj6.js → chunk-0r1jf8m9.js} +1 -1
  3. package/dist/cli/{chunk-sap4tggv.js → chunk-1ca2j9w6.js} +2 -2
  4. package/dist/cli/chunk-1eef3z5v.js +3 -0
  5. package/dist/cli/{chunk-655kt3e1.js → chunk-1jjqk7sq.js} +1 -1
  6. package/dist/cli/chunk-1n03wzx4.js +3 -0
  7. package/dist/cli/{chunk-9trbc3kj.js → chunk-22rgewg0.js} +2 -2
  8. package/dist/cli/{chunk-jwedmkm8.js → chunk-283vd9h7.js} +1 -1
  9. package/dist/cli/chunk-2kqxz9a4.js +5 -0
  10. package/dist/cli/chunk-2xsxcdp6.js +3 -0
  11. package/dist/cli/{chunk-bj6sa371.js → chunk-372g44dg.js} +1 -1
  12. package/dist/cli/{chunk-4dxc29mm.js → chunk-387w0db1.js} +1 -1
  13. package/dist/cli/{chunk-bm0qe5gy.js → chunk-3xkhcfet.js} +2 -2
  14. package/dist/cli/{chunk-qvnr8c18.js → chunk-3y9xzbqh.js} +1 -1
  15. package/dist/cli/chunk-4117kgmx.js +2 -0
  16. package/dist/cli/chunk-4a05fgdh.js +2 -0
  17. package/dist/cli/chunk-4dt1gfb3.js +3 -0
  18. package/dist/cli/{chunk-ycd28edp.js → chunk-4xvmrg86.js} +3 -4
  19. package/dist/cli/{chunk-jbdg5ggt.js → chunk-511103e8.js} +1 -1
  20. package/dist/cli/chunk-59p3h5e9.js +2 -0
  21. package/dist/cli/{chunk-80t9z2b2.js → chunk-5e9y8aw5.js} +1 -1
  22. package/dist/cli/chunk-5nvg3ek8.js +3 -0
  23. package/dist/cli/chunk-5yfffvqe.js +2 -0
  24. package/dist/cli/{chunk-nyn1j7cf.js → chunk-63cwjceg.js} +1 -1
  25. package/dist/cli/{chunk-jwta8rp8.js → chunk-6mtfafaw.js} +1 -1
  26. package/dist/cli/{chunk-bmg5y8eh.js → chunk-6xga1a2d.js} +1 -1
  27. package/dist/cli/{chunk-wqvmvgaf.js → chunk-745pg3xm.js} +1 -1
  28. package/dist/cli/{chunk-adj65prq.js → chunk-81thm1eb.js} +4 -4
  29. package/dist/cli/chunk-82apkcrk.js +5 -0
  30. package/dist/cli/chunk-84pvn784.js +2 -0
  31. package/dist/cli/{chunk-1exwrmjd.js → chunk-883fyezq.js} +1 -1
  32. package/dist/cli/{chunk-63t3sh8c.js → chunk-8dd60adw.js} +1 -1
  33. package/dist/cli/{chunk-qfe1wf5c.js → chunk-91tcwxph.js} +1 -1
  34. package/dist/cli/{chunk-fkn6z4yq.js → chunk-9c3brkb3.js} +1 -1
  35. package/dist/cli/chunk-9gh8kgjs.js +2 -0
  36. package/dist/cli/{chunk-h8t4xg1p.js → chunk-9rj2fx6v.js} +1 -1
  37. package/dist/cli/{chunk-qsqde2kj.js → chunk-a4r45qdn.js} +1 -1
  38. package/dist/cli/{chunk-p6jw0zcd.js → chunk-agvtzads.js} +1 -1
  39. package/dist/cli/{chunk-gcg5h667.js → chunk-awh7np6x.js} +1 -1
  40. package/dist/cli/chunk-b035pej7.js +20 -0
  41. package/dist/cli/{chunk-ez438kn3.js → chunk-b95q6zhk.js} +1 -1
  42. package/dist/cli/chunk-brgfsm5v.js +2 -0
  43. package/dist/cli/chunk-bw98jn7g.js +18 -0
  44. package/dist/cli/{chunk-bexnp6g4.js → chunk-c63vgbkw.js} +1 -1
  45. package/dist/cli/{chunk-8sggyn8y.js → chunk-c6fy8xew.js} +1 -1
  46. package/dist/cli/chunk-c7mz2aq0.js +2 -0
  47. package/dist/cli/{chunk-ec7f3wcm.js → chunk-cbrt4s7m.js} +2 -2
  48. package/dist/cli/chunk-ccwe9n56.js +19 -0
  49. package/dist/cli/chunk-cfzg8q3e.js +4 -0
  50. package/dist/cli/{chunk-387ecqb8.js → chunk-d0hpes59.js} +1 -1
  51. package/dist/cli/{chunk-edrxs4cy.js → chunk-d7f022eb.js} +5 -5
  52. package/dist/cli/{chunk-fy4eyzbt.js → chunk-d7xbm9jp.js} +1 -1
  53. package/dist/cli/{chunk-3v9s3bcz.js → chunk-d9643dwf.js} +1 -1
  54. package/dist/cli/{chunk-x20bs6bs.js → chunk-dgx02565.js} +1 -1
  55. package/dist/cli/{chunk-ecrw211n.js → chunk-dt676ks9.js} +1 -1
  56. package/dist/cli/{chunk-vw34sdkk.js → chunk-e3cd4qd2.js} +2 -2
  57. package/dist/cli/chunk-e3t1zbv1.js +5 -0
  58. package/dist/cli/{chunk-0rrmz6k6.js → chunk-eege1x0a.js} +1 -1
  59. package/dist/cli/{chunk-t34kjg5y.js → chunk-ehm9abge.js} +4 -3
  60. package/dist/cli/{chunk-mmq6922s.js → chunk-eq7vey2j.js} +2 -2
  61. package/dist/cli/chunk-eyvw70yb.js +2 -0
  62. package/dist/cli/{chunk-jcrg7pjv.js → chunk-f76gzvq3.js} +1 -1
  63. package/dist/cli/{chunk-xkmdxcjg.js → chunk-fn7ffyam.js} +1 -1
  64. package/dist/cli/chunk-g4dtqbrj.js +2 -0
  65. package/dist/cli/chunk-g9ba25q5.js +3 -0
  66. package/dist/cli/{chunk-22d4fjjb.js → chunk-gafkp74h.js} +1 -1
  67. package/dist/cli/chunk-gctqthxq.js +97 -0
  68. package/dist/cli/{chunk-f6hgkc7g.js → chunk-gq57he03.js} +1 -1
  69. package/dist/cli/chunk-h2gznz46.js +2 -0
  70. package/dist/cli/{chunk-03rbg95q.js → chunk-h64rsbrx.js} +5 -5
  71. package/dist/cli/{chunk-5dd7trgf.js → chunk-h7vwn62z.js} +1 -1
  72. package/dist/cli/chunk-hcvp84b3.js +4 -0
  73. package/dist/cli/chunk-hhcmzs67.js +78 -0
  74. package/dist/cli/chunk-hmjg1qh3.js +2 -0
  75. package/dist/cli/{chunk-jd7p0y5x.js → chunk-j9b285x6.js} +1 -1
  76. package/dist/cli/{chunk-k5k2jpxk.js → chunk-jckx79gk.js} +3 -3
  77. package/dist/cli/{chunk-a4x8h7zv.js → chunk-je80r59s.js} +1 -1
  78. package/dist/cli/{chunk-1n7tcq6a.js → chunk-jfcn77n9.js} +1 -1
  79. package/dist/cli/chunk-jn10xeft.js +2 -0
  80. package/dist/cli/{chunk-g263457v.js → chunk-k1pwp155.js} +1 -1
  81. package/dist/cli/chunk-k235z3ct.js +2 -0
  82. package/dist/cli/{chunk-ms92andd.js → chunk-m2a19yt4.js} +1 -1
  83. package/dist/cli/{chunk-x7yxf5b5.js → chunk-m73x5nry.js} +3 -3
  84. package/dist/cli/chunk-ma21srvx.js +3 -0
  85. package/dist/cli/chunk-mdc7b01e.js +3 -0
  86. package/dist/cli/{chunk-kgs56yns.js → chunk-mkfc9a09.js} +1 -1
  87. package/dist/cli/{chunk-xgm43xm3.js → chunk-mq88bvj6.js} +1 -1
  88. package/dist/cli/chunk-mqfvzdpr.js +3 -0
  89. package/dist/cli/{chunk-98s0fhmv.js → chunk-mz1ffkqb.js} +3 -3
  90. package/dist/cli/{chunk-1rjq808h.js → chunk-n0rdn2fn.js} +1 -1
  91. package/dist/cli/{chunk-sza3tyhs.js → chunk-n6marmjn.js} +1 -1
  92. package/dist/cli/chunk-n8t4y0bj.js +10 -0
  93. package/dist/cli/chunk-nbpq1tkx.js +98 -0
  94. package/dist/cli/{chunk-x6xevrtz.js → chunk-ne6x6g2c.js} +1 -1
  95. package/dist/cli/{chunk-fexzfgd1.js → chunk-nr7e3e82.js} +1 -1
  96. package/dist/cli/chunk-ns35rdyk.js +3 -0
  97. package/dist/cli/chunk-pap7k3b4.js +3 -0
  98. package/dist/cli/chunk-pdq3ya2e.js +3 -0
  99. package/dist/cli/chunk-q8ffd1pc.js +3 -0
  100. package/dist/cli/{chunk-39sfhppm.js → chunk-qna1s1r4.js} +1 -1
  101. package/dist/cli/{chunk-tjj9bt7n.js → chunk-qqr4tfhk.js} +1 -1
  102. package/dist/cli/chunk-r7kmn4js.js +2 -0
  103. package/dist/cli/chunk-r7ntkd6y.js +15 -0
  104. package/dist/cli/{chunk-rtpa8hg3.js → chunk-rjfdzjhj.js} +1 -1
  105. package/dist/cli/chunk-syfs63r2.js +2 -0
  106. package/dist/cli/{chunk-4hnz77xf.js → chunk-syn0tfwy.js} +1 -1
  107. package/dist/cli/chunk-t4qr9sv4.js +4 -0
  108. package/dist/cli/{chunk-6jk2khme.js → chunk-t52gzaeb.js} +1 -1
  109. package/dist/cli/chunk-teh40faw.js +1 -1
  110. package/dist/cli/{chunk-gqh6atvp.js → chunk-tjhw09bz.js} +1 -1
  111. package/dist/cli/chunk-tq0h3vy6.js +3 -0
  112. package/dist/cli/{chunk-snqa07h6.js → chunk-tvdrvgen.js} +1 -1
  113. package/dist/cli/chunk-tz373e5w.js +3 -0
  114. package/dist/cli/chunk-v1r83m3n.js +3 -0
  115. package/dist/cli/chunk-vp171as9.js +65 -0
  116. package/dist/cli/chunk-vtcr71fs.js +8 -0
  117. package/dist/cli/{chunk-zaw71cf4.js → chunk-vz0f8e8q.js} +1 -1
  118. package/dist/cli/chunk-w77s2df8.js +3 -0
  119. package/dist/cli/chunk-w7v4jzwy.js +3 -0
  120. package/dist/cli/chunk-wvqn1t55.js +2 -0
  121. package/dist/cli/{chunk-r40aj7z6.js → chunk-x1ghdmp1.js} +1 -1
  122. package/dist/cli/{chunk-zxkjpfp5.js → chunk-x3n4y5sp.js} +1 -1
  123. package/dist/cli/{chunk-qnaxnx5w.js → chunk-xb3p11g0.js} +1 -1
  124. package/dist/cli/{chunk-yzkhwn31.js → chunk-xd93fm1k.js} +1 -1
  125. package/dist/cli/chunk-xn2f56tg.js +3 -0
  126. package/dist/cli/chunk-xv3217yv.js +2 -0
  127. package/dist/cli/chunk-yhytkwpv.js +2 -0
  128. package/dist/cli/{chunk-hfdk7j28.js → chunk-yk9b8zgn.js} +1 -1
  129. package/dist/cli/chunk-zat16a83.js +2 -0
  130. package/dist/cli/chunk-zcrs4sm2.js +3 -0
  131. package/dist/cli/{chunk-kx53jjee.js → chunk-zkp6nty3.js} +8 -6
  132. package/dist/cli/index.js +5 -5
  133. package/dist/cli/pty-host-node.mjs +258 -29
  134. package/dist/cli/rove-run.js +1 -1
  135. package/dist/cli/rove.js +1 -1
  136. package/dist/completions/rove.bash +2 -2
  137. package/dist/completions/rove.fish +2 -2
  138. package/dist/completions/rove.zsh +2 -2
  139. package/dist/skills/rove/SKILL.md +23 -9
  140. package/dist/skills/rove/references/api-flags.md +20 -11
  141. package/dist/web/assets/index-C5t3gibI.css +1 -0
  142. package/dist/web/assets/index-Djp7M6r8.js +122 -0
  143. package/dist/web/index.html +2 -2
  144. package/dist/web/sw.js +52 -0
  145. package/package.json +3 -3
  146. package/dist/cli/chunk-0ppkvphp.js +0 -2
  147. package/dist/cli/chunk-11wyec8z.js +0 -2
  148. package/dist/cli/chunk-15fp4p9v.js +0 -15
  149. package/dist/cli/chunk-1ffqacz9.js +0 -3
  150. package/dist/cli/chunk-1h1ejknz.js +0 -2
  151. package/dist/cli/chunk-4d50eg3p.js +0 -97
  152. package/dist/cli/chunk-5c4vr45n.js +0 -4
  153. package/dist/cli/chunk-5zsdjrgz.js +0 -4
  154. package/dist/cli/chunk-64f3ncxx.js +0 -2
  155. package/dist/cli/chunk-68wpp5y8.js +0 -20
  156. package/dist/cli/chunk-6d3espha.js +0 -10
  157. package/dist/cli/chunk-6h4qdckd.js +0 -3
  158. package/dist/cli/chunk-6jj82bej.js +0 -2
  159. package/dist/cli/chunk-783d1ba0.js +0 -3
  160. package/dist/cli/chunk-78v1q5mz.js +0 -2
  161. package/dist/cli/chunk-7z463zkx.js +0 -3
  162. package/dist/cli/chunk-8zw085pc.js +0 -3
  163. package/dist/cli/chunk-97m9nyw7.js +0 -2
  164. package/dist/cli/chunk-9bae7f3m.js +0 -4
  165. package/dist/cli/chunk-9eqh0yph.js +0 -2
  166. package/dist/cli/chunk-ajad94vy.js +0 -2
  167. package/dist/cli/chunk-b5c7p22a.js +0 -2
  168. package/dist/cli/chunk-b5pytfgm.js +0 -2
  169. package/dist/cli/chunk-b68dd36h.js +0 -3
  170. package/dist/cli/chunk-bbksmb5a.js +0 -3
  171. package/dist/cli/chunk-bp0en3f7.js +0 -2
  172. package/dist/cli/chunk-cyzp2btw.js +0 -63
  173. package/dist/cli/chunk-e01321zn.js +0 -5
  174. package/dist/cli/chunk-f5fk30x1.js +0 -2
  175. package/dist/cli/chunk-fvvb0072.js +0 -3
  176. package/dist/cli/chunk-g53yqr82.js +0 -78
  177. package/dist/cli/chunk-k67vbszb.js +0 -3
  178. package/dist/cli/chunk-k9zarq1x.js +0 -96
  179. package/dist/cli/chunk-m1n1rszx.js +0 -2
  180. package/dist/cli/chunk-n2ejvjrd.js +0 -3
  181. package/dist/cli/chunk-nf3kg9rz.js +0 -25
  182. package/dist/cli/chunk-q9zgj6kw.js +0 -3
  183. package/dist/cli/chunk-qd72kqg9.js +0 -20
  184. package/dist/cli/chunk-ra18rjj4.js +0 -20
  185. package/dist/cli/chunk-rkn2fby6.js +0 -3
  186. package/dist/cli/chunk-rzef6szc.js +0 -3
  187. package/dist/cli/chunk-sqxdfzdq.js +0 -5
  188. package/dist/cli/chunk-sz2xs0a2.js +0 -4
  189. package/dist/cli/chunk-vjp7drne.js +0 -2
  190. package/dist/cli/chunk-w2xdmnnf.js +0 -2
  191. package/dist/cli/chunk-xmqv1zx6.js +0 -2
  192. package/dist/cli/chunk-xn7bk4f9.js +0 -3
  193. package/dist/cli/chunk-zybjm7d5.js +0 -2
  194. package/dist/web/assets/index-Bc0LgdLr.js +0 -113
  195. package/dist/web/assets/index-sA2EEQJw.css +0 -1
@@ -1,9 +1,11 @@
1
1
  // @bun
2
- import{smallIgnoredPaths}from"./chunk-xmwp6je4.js";import{DIRTY_WORKTREE_CODE,canonicalize,describeDirtyWorktreeWork,isRoveManagedPath,isUnderManagedWorktreesRoot,managedWorktreeRootForPath,remoteManagedRootForPath,remoteWorktreePathFor,requireAbsolute,worktreePathFor}from"./chunk-mmq6922s.js";import{readFirstNonEmptyRepoFile}from"./chunk-catrr0z3.js";import{execHostForRepo,execHostForWorktreePath}from"./chunk-895yqjjz.js";import{parsePorcelainRows}from"./chunk-dmzg9zdc.js";import{READ_ONLY_GIT_ENV}from"./chunk-6xppe9bj.js";import{getRemoteRepoConfig}from"./chunk-rfp0ayra.js";import{loadStateFile}from"./chunk-32j6y5d1.js";import path4 from"path";function parseDirtyPaths(stdout){return parsePorcelainRows(stdout).filter((row)=>(row.x+row.y).trim().length>0).map((row)=>row.path).filter((p)=>p.length>0)}function isDirtyOutput(stdout){return parseDirtyPaths(stdout).length>0}var METER_RE=/(\d{1,3})% \(\d+\/\d+\)/g;function checkoutProgressReader(onPercent){let tail="",last=-1;return(chunk)=>{let text=tail+chunk,end=Math.max(text.lastIndexOf("\r"),text.lastIndexOf(`
3
- `));if(end<0){tail=text;return}tail=text.slice(end+1);let percent=-1;for(let match of text.slice(0,end).matchAll(METER_RE))percent=Number(match[1]);if(percent<0||percent>100||percent===last)return;last=percent,onPercent(percent)}}import fs from"fs/promises";import path from"path";var WORKTREE_CLONE_IGNORED_KEY="worktree.cloneIgnored",DEFAULT_CLONE_DIRS=["node_modules",".venv","target",".build"];function isCloneIgnoredEnabled(){return loadStateFile()[WORKTREE_CLONE_IGNORED_KEY]!==!1}function parseCloneDirs(text){return text.split(/\r?\n/).map((line)=>line.replace(/#.*$/,"").trim()).filter((e)=>e.length>0&&e!=="."&&e!==".."&&!/[/\\]/.test(e)&&!e.startsWith("-"))}function resolveCloneDirs(worktreePath){let file=readFirstNonEmptyRepoFile(worktreePath,"clone-dirs");return file===void 0?DEFAULT_CLONE_DIRS:parseCloneDirs(file)}var CLONEFILEAT_PERL='my $r = syscall(462, -2, $ARGV[0], -2, $ARGV[1], 0); if ($r != 0) { print STDERR "clonefileat: $!\\n"; exit 1 }';function defaultCloneDeps(exec){return{platform:process.platform,statDev:async(p)=>(await fs.stat(p)).dev,isApfs:async(p)=>{let r=await exec.run(["/bin/df","-T","apfs",p]);return r.exitCode===0&&r.stdout.trim().split(`
4
- `).length>1},clone:async(source,target)=>{let r=await exec.run(["/usr/bin/perl","-e",CLONEFILEAT_PERL,source,target]);if(r.exitCode!==0)throw Error(r.stderr.trim()||`perl exited ${r.exitCode}`)},log:(message)=>console.error(`[rove] ${message}`)}}async function discoverIgnoredDirs(exec,repo,names){let r=await exec.run(["git","ls-files","--others","--ignored","--exclude-standard","--directory","-z"],{cwd:repo,env:READ_ONLY_GIT_ENV});if(r.exitCode!==0)return[];return r.stdout.split("\x00").filter((entry)=>entry.endsWith("/")).map((entry)=>entry.slice(0,-1)).filter((rel)=>names.has(path.posix.basename(rel)))}async function isRealDirectory(p){try{return(await fs.lstat(p)).isDirectory()}catch{return!1}}async function exists(p){try{return await fs.lstat(p),!0}catch{return!1}}function cloneDirNames(exec,worktreePath,deps){if(exec.isRemote||deps.platform!=="darwin"||!isCloneIgnoredEnabled())return[];return resolveCloneDirs(worktreePath)}function regenerableDirNames(exec,worktreePath,deps){return cloneDirNames(exec,worktreePath,deps).filter((name)=>DEFAULT_CLONE_DIRS.includes(name))}async function cloneIgnoredDirs(exec,repo,worktreePath,deps=defaultCloneDeps(exec)){try{let names=new Set(cloneDirNames(exec,worktreePath,deps));if(names.size===0)return[];let apfsByDev=new Map,todo=[];for(let rel of await discoverIgnoredDirs(exec,repo,names)){let source=path.join(repo,rel),target=path.join(worktreePath,rel),targetParent=path.dirname(target);if(!await isRealDirectory(source)||await exists(target)||!await isRealDirectory(targetParent))continue;let dev=await deps.statDev(source);if(dev!==await deps.statDev(targetParent))continue;let apfs=apfsByDev.get(dev);if(apfs===void 0)apfs=await deps.isApfs(source),apfsByDev.set(dev,apfs);if(apfs)todo.push({rel,source,target})}return(await Promise.all(todo.map(async({rel,source,target})=>{try{return await deps.clone(source,target),rel}catch(err){return deps.log(`clone of ignored dir ${rel} into ${worktreePath} failed: ${err instanceof Error?err.message:err}`),null}}))).filter((rel)=>rel!==null)}catch(err){return deps.log(`cloning ignored dirs into ${worktreePath} failed: ${err instanceof Error?err.message:err}`),[]}}var defaultExecDeps={execForRepo:execHostForRepo,execForPath:execHostForWorktreePath,remoteBasePath(repoKey){return getRemoteRepoConfig(repoKey)?.basePath??null}};import{spawnSync}from"child_process";class GitCommandError extends Error{args;cwd;exitCode;stdout;stderr;constructor(args,cwd,result){super(`git ${args.join(" ")} (cwd=${cwd}) exited with code ${result.exitCode}: ${result.stderr.trim()||result.stdout.trim()}`);this.name="GitCommandError",this.args=args,this.cwd=cwd,this.exitCode=result.exitCode,this.stdout=result.stdout,this.stderr=result.stderr}}function git(args,opts){if(!opts.cwd)throw Error("git(): cwd is required; refusing to inherit from process.cwd()");let env={...process.env,...opts.env,...opts.readOnly?READ_ONLY_GIT_ENV:{}},proc=spawnSync("git",[...args],{cwd:opts.cwd,env,encoding:"utf8",shell:!1}),result={stdout:proc.stdout??"",stderr:proc.stderr??"",exitCode:proc.status??-1};if(result.exitCode!==0&&!opts.allowFail)throw new GitCommandError(args,opts.cwd,result);return result}async function gitlinkPaths(git2,tree){let out=await git2(["ls-tree","-r",tree]);if(out.exitCode!==0)return[];return out.stdout.split(`
5
- `).filter((line)=>line.startsWith("160000 ")).map((line)=>line.slice(line.indexOf("\t")+1)).filter((p)=>p.length>0)}function branchRefSlug(branch){return(branch??"").replace(/[\u0000-\u0020\u007f~^:?*[\\/]+/g,"-").replace(/@\{/g,"-").replace(/\.{2,}/g,"-").replace(/^[-.]+|[-.]+$/g,"")||"detached"}function salvageRef(branch,now){let stamp=now.toISOString().replace(/[-:]/g,"").replace(/\.\d+Z$/,"Z");return`refs/rove/salvage/${branchRefSlug(branch)}-${stamp}`}async function createSalvageRef(git2,preferred,commit){for(let attempt=1;attempt<=50;attempt++){let ref=attempt===1?preferred:`${preferred}-${attempt}`;if((await git2(["update-ref",ref,commit,""])).exitCode===0)return ref}return null}async function salvageWorktree(deps,exec,worktreePath,now=new Date){let git2=(args)=>deps.runGit(exec,args,{cwd:worktreePath,allowFail:!0});try{let status=await git2(["status","--porcelain"]);if(status.exitCode!==0)return null;let probe=await smallIgnoredPaths(exec,worktreePath),ignored=probe==="unknown"?[]:probe;if(status.stdout.trim().length===0&&ignored.length===0)return null;let indexPath=(await git2(["rev-parse","--git-path","rove-salvage-index"])).stdout.trim();if(!indexPath)return null;let withIndex=(args)=>deps.runGit(exec,args,{cwd:worktreePath,allowFail:!0,env:{GIT_INDEX_FILE:indexPath}}),head=(await git2(["rev-parse","HEAD"])).stdout.trim(),branch=(await git2(["rev-parse","--abbrev-ref","HEAD"])).stdout.trim();try{if(head&&(await withIndex(["read-tree",head])).exitCode!==0)return null;if((await withIndex(["add","-A"])).exitCode!==0)return null;if(ignored.length>0)await withIndex(["add","-f","--",...ignored]);let tree=(await withIndex(["write-tree"])).stdout.trim();if(!tree)return null;let message=`rove salvage: force-removed worktree ${worktreePath}`,commit=(await withIndex(head?["commit-tree",tree,"-p",head,"-m",message]:["commit-tree",tree,"-m",message])).stdout.trim();if(!commit)return null;let ref=await createSalvageRef(git2,salvageRef(branch&&branch!=="HEAD"?branch:null,now),commit);if(!ref)return null;return{ref,commit,uncaptured:await gitlinkPaths(git2,tree)}}finally{await exec.run(["rm","-f",indexPath],{cwd:worktreePath}).catch(()=>{return})}}catch{return null}}async function anchorBranchTip(deps,exec,repo,branch,now=new Date){if(!branch||branch==="HEAD")return null;let git2=(args)=>deps.runGit(exec,args,{cwd:repo,allowFail:!0});try{let tipOut=await git2(["rev-parse","--verify",`refs/heads/${branch}`]),tip=tipOut.stdout.trim();if(tipOut.exitCode!==0||!tip)return null;let holders=await git2(["for-each-ref","--contains",tip,"--format=%(refname)"]);if(holders.exitCode===0){if(holders.stdout.split(`
2
+ import{smallIgnoredPaths}from"./chunk-xmwp6je4.js";import{DIRTY_WORKTREE_CODE,canonicalize,describeDirtyWorktreeWork,isRoveManagedPath,isUnderManagedWorktreesRoot,managedWorktreeRootForPath,remoteManagedRootForPath,remoteWorktreePathFor,requireAbsolute,worktreePathFor}from"./chunk-eq7vey2j.js";import{readFirstNonEmptyRepoFile}from"./chunk-catrr0z3.js";import{execHostForRepo,execHostForWorktreePath}from"./chunk-895yqjjz.js";import{getRemoteRepoConfig}from"./chunk-rfp0ayra.js";import{parsePorcelainRows}from"./chunk-dmzg9zdc.js";import{READ_ONLY_GIT_ENV}from"./chunk-6xppe9bj.js";import{loadStateFile}from"./chunk-32j6y5d1.js";import path4 from"path";function parseDirtyPaths(stdout){return parsePorcelainRows(stdout).filter((row)=>(row.x+row.y).trim().length>0).map((row)=>row.path).filter((p)=>p.length>0)}function isDirtyOutput(stdout){return parseDirtyPaths(stdout).length>0}var METER_RE=/(\d{1,3})% \(\d+\/\d+\)/g;function checkoutProgressReader(onPercent){let tail="",last=-1;return(chunk)=>{let text=tail+chunk,end=Math.max(text.lastIndexOf("\r"),text.lastIndexOf(`
3
+ `));if(end<0){tail=text;return}tail=text.slice(end+1);let percent=-1;for(let match of text.slice(0,end).matchAll(METER_RE))percent=Number(match[1]);if(percent<0||percent>100||percent===last)return;last=percent,onPercent(percent)}}class CheckpointError extends Error{code;constructor(code,reason){super(`${code}: ${reason}`);this.code=code;this.name="CheckpointError"}}function checkpointRef(taskId,n){return`refs/rove/checkpoints/${taskId}/${n}`}var FALLBACK_IDENTITY={GIT_AUTHOR_NAME:"Rove",GIT_AUTHOR_EMAIL:"rove@localhost",GIT_COMMITTER_NAME:"Rove",GIT_COMMITTER_EMAIL:"rove@localhost"};function parseSubject(subject){let parts=subject.trim().split(/\s+/).slice(3),at=parts.pop()??"";return parts[0]?{at,tabId:parts[0]}:{at}}async function listCheckpoints(deps,exec,cwd,taskId){let prefix=`refs/rove/checkpoints/${taskId}/`,out=await deps.runGit(exec,["for-each-ref","--format=%(refname)%09%(objectname)%09%(tree)%09%(subject)",prefix],{cwd,allowFail:!0,readOnly:!0});if(out.exitCode!==0)return[];let records=[];for(let line of out.stdout.split(`
4
+ `)){let[ref,commit,tree,subject=""]=line.split("\t"),n=Number(ref?.slice(prefix.length));if(!ref||!commit||!tree||!Number.isInteger(n))continue;records.push({n,ref,commit,tree,...parseSubject(subject)})}return records.sort((a,b)=>a.n-b.n)}async function gitlinkPaths(exec,deps,cwd,tree){let out=await deps.runGit(exec,["ls-tree","-r",tree],{cwd,allowFail:!0,readOnly:!0});if(out.exitCode!==0)return[];return out.stdout.split(`
5
+ `).filter((line)=>line.startsWith("160000 ")).map((line)=>line.slice(line.indexOf("\t")+1)).filter((p)=>p.length>0)}async function withTempIndex(deps,exec,cwd,body){let name=`rove-ckpt-index-${process.pid}-${Math.random().toString(36).slice(2,8)}`,indexPath=(await deps.runGit(exec,["rev-parse","--git-path",name],{cwd,allowFail:!0,readOnly:!0})).stdout.trim();if(!indexPath)throw new CheckpointError("CHECKPOINT_FAILED",`${cwd} is not a git work tree`);try{return await body((args,extraEnv)=>deps.runGit(exec,args,{cwd,allowFail:!0,env:{GIT_INDEX_FILE:indexPath,...extraEnv}}),indexPath)}finally{await exec.run(["rm","-f",indexPath],{cwd}).catch(()=>{return})}}async function snapshotTree(deps,exec,cwd,head){let tree=await withTempIndex(deps,exec,cwd,async(gitIdx,indexPath)=>{let real=(await deps.runGit(exec,["rev-parse","--git-path","index"],{cwd,allowFail:!0,readOnly:!0})).stdout.trim();if(!(real!==""&&(await exec.run(["cp","-p",real,indexPath],{cwd}).catch(()=>{return}))?.exitCode===0)&&head&&(await gitIdx(["read-tree",head])).exitCode!==0)throw new CheckpointError("CHECKPOINT_FAILED","read-tree failed");if((await gitIdx(["add","-A"])).exitCode!==0)throw new CheckpointError("CHECKPOINT_FAILED","git add -A failed");let written=(await gitIdx(["write-tree"])).stdout.trim();if(!written)throw new CheckpointError("CHECKPOINT_FAILED","write-tree failed");return written});return{tree,uncaptured:await gitlinkPaths(exec,deps,cwd,tree)}}async function headCommit(deps,exec,cwd){let out=await deps.runGit(exec,["rev-parse","--verify","-q","HEAD"],{cwd,allowFail:!0,readOnly:!0});return out.exitCode===0?out.stdout.trim():""}async function takeCheckpoint(deps,exec,worktreePath,taskId,opts={}){let head=await headCommit(deps,exec,worktreePath),{tree,uncaptured}=await snapshotTree(deps,exec,worktreePath,head),existing=await listCheckpoints(deps,exec,worktreePath,taskId),latest=existing[existing.length-1];if(latest&&latest.tree===tree)return{created:!1,checkpoint:latest};let at=(opts.now??new Date).toISOString(),hasIdentity=(await deps.runGit(exec,["var","GIT_COMMITTER_IDENT"],{cwd:worktreePath,allowFail:!0,readOnly:!0})).exitCode===0;for(let n=(latest?.n??0)+1,attempt=0;attempt<5;n++,attempt++){let message=["rove checkpoint",n,opts.tabId,at].filter((p)=>p!==void 0&&p!=="").join(" "),commitArgs=head?["commit-tree",tree,"-p",head,"-m",message]:["commit-tree",tree,"-m",message],commit=await deps.runGit(exec,commitArgs,{cwd:worktreePath,allowFail:!0,...hasIdentity?{}:{env:FALLBACK_IDENTITY}}),sha=commit.stdout.trim();if(commit.exitCode!==0||!sha)throw new CheckpointError("CHECKPOINT_FAILED",`commit-tree failed: ${commit.stderr.trim()}`);let ref=checkpointRef(taskId,n);if((await deps.runGit(exec,["update-ref",ref,sha,""],{cwd:worktreePath,allowFail:!0})).exitCode===0)return await pruneCheckpoints(deps,exec,worktreePath,taskId).catch(()=>{return}),{created:!0,checkpoint:{n,ref,commit:sha,tree,at,...opts.tabId?{tabId:opts.tabId}:{}},uncaptured}}throw new CheckpointError("CHECKPOINT_FAILED",`could not allocate a checkpoint number for ${taskId}`)}async function deleteRefs(deps,exec,cwd,refs){for(let ref of refs)await deps.runGit(exec,["update-ref","-d",ref],{cwd,allowFail:!0})}async function pruneCheckpoints(deps,exec,cwd,taskId,keep=100){let all=await listCheckpoints(deps,exec,cwd,taskId),doomed=all.slice(0,Math.max(0,all.length-keep));return await deleteRefs(deps,exec,cwd,doomed.map((c)=>c.ref)),doomed.length}async function deleteTaskCheckpoints(deps,exec,cwd,taskId){let all=await listCheckpoints(deps,exec,cwd,taskId);return await deleteRefs(deps,exec,cwd,all.map((c)=>c.ref)),all.length}async function moveTaskCheckpoints(deps,exec,cwd,fromId,toId){let moved=0;for(let c of await listCheckpoints(deps,exec,cwd,fromId)){if((await deps.runGit(exec,["update-ref",checkpointRef(toId,c.n),c.commit,""],{cwd,allowFail:!0})).exitCode!==0)continue;await deleteRefs(deps,exec,cwd,[c.ref]),moved++}return moved}async function rewindTo(deps,exec,worktreePath,taskId,n,opts={}){let target=(await listCheckpoints(deps,exec,worktreePath,taskId)).find((c)=>c.n===n);if(!target)throw new CheckpointError("CHECKPOINT_NOT_FOUND",`task ${taskId} has no checkpoint ${n}`);let taken=await takeCheckpoint(deps,exec,worktreePath,taskId,{now:opts.now}),undo=taken.checkpoint,uncaptured=taken.created?taken.uncaptured:[];await withTempIndex(deps,exec,worktreePath,async(gitIdx)=>{if((await gitIdx(["read-tree",undo.tree])).exitCode!==0)throw new CheckpointError("CHECKPOINT_FAILED","read-tree (current) failed");let res=await gitIdx(["read-tree","--reset","-u",target.tree]);if(res.exitCode!==0)throw new CheckpointError("CHECKPOINT_FAILED",`read-tree failed: ${res.stderr.trim()}`)});let head=await headCommit(deps,exec,worktreePath);return await deps.runGit(exec,head?["reset","-q"]:["read-tree","--empty"],{cwd:worktreePath,allowFail:!0}),{target,undo,uncaptured}}import fs from"fs/promises";import path from"path";var WORKTREE_CLONE_IGNORED_KEY="worktree.cloneIgnored",DEFAULT_CLONE_DIRS=["node_modules",".venv","target",".build"];function isCloneIgnoredEnabled(){return loadStateFile()[WORKTREE_CLONE_IGNORED_KEY]!==!1}function parseCloneDirs(text){return text.split(/\r?\n/).map((line)=>line.replace(/#.*$/,"").trim()).filter((e)=>e.length>0&&e!=="."&&e!==".."&&!/[/\\]/.test(e)&&!e.startsWith("-"))}function resolveCloneDirs(worktreePath){let file=readFirstNonEmptyRepoFile(worktreePath,"clone-dirs");return file===void 0?DEFAULT_CLONE_DIRS:parseCloneDirs(file)}var CLONEFILEAT_PERL='my $r = syscall(462, -2, $ARGV[0], -2, $ARGV[1], 0); if ($r != 0) { print STDERR "clonefileat: $!\\n"; exit 1 }';function defaultCloneDeps(exec){return{platform:process.platform,statDev:async(p)=>(await fs.stat(p)).dev,isApfs:async(p)=>{let r=await exec.run(["/bin/df","-T","apfs",p]);return r.exitCode===0&&r.stdout.trim().split(`
6
+ `).length>1},clone:async(source,target)=>{let r=await exec.run(["/usr/bin/perl","-e",CLONEFILEAT_PERL,source,target]);if(r.exitCode!==0)throw Error(r.stderr.trim()||`perl exited ${r.exitCode}`)},log:(message)=>console.error(`[rove] ${message}`)}}async function discoverIgnoredDirs(exec,repo,names){let r=await exec.run(["git","ls-files","--others","--ignored","--exclude-standard","--directory","-z"],{cwd:repo,env:READ_ONLY_GIT_ENV});if(r.exitCode!==0)return[];return r.stdout.split("\x00").filter((entry)=>entry.endsWith("/")).map((entry)=>entry.slice(0,-1)).filter((rel)=>names.has(path.posix.basename(rel)))}async function isRealDirectory(p){try{return(await fs.lstat(p)).isDirectory()}catch{return!1}}async function exists(p){try{return await fs.lstat(p),!0}catch{return!1}}function cloneDirNames(exec,worktreePath,deps){if(exec.isRemote||deps.platform!=="darwin"||!isCloneIgnoredEnabled())return[];return resolveCloneDirs(worktreePath)}function regenerableDirNames(exec,worktreePath,deps){return cloneDirNames(exec,worktreePath,deps).filter((name)=>DEFAULT_CLONE_DIRS.includes(name))}async function cloneIgnoredDirs(exec,repo,worktreePath,deps=defaultCloneDeps(exec)){try{let names=new Set(cloneDirNames(exec,worktreePath,deps));if(names.size===0)return[];let apfsByDev=new Map,todo=[];for(let rel of await discoverIgnoredDirs(exec,repo,names)){let source=path.join(repo,rel),target=path.join(worktreePath,rel),targetParent=path.dirname(target);if(!await isRealDirectory(source)||await exists(target)||!await isRealDirectory(targetParent))continue;let dev=await deps.statDev(source);if(dev!==await deps.statDev(targetParent))continue;let apfs=apfsByDev.get(dev);if(apfs===void 0)apfs=await deps.isApfs(source),apfsByDev.set(dev,apfs);if(apfs)todo.push({rel,source,target})}return(await Promise.all(todo.map(async({rel,source,target})=>{try{return await deps.clone(source,target),rel}catch(err){return deps.log(`clone of ignored dir ${rel} into ${worktreePath} failed: ${err instanceof Error?err.message:err}`),null}}))).filter((rel)=>rel!==null)}catch(err){return deps.log(`cloning ignored dirs into ${worktreePath} failed: ${err instanceof Error?err.message:err}`),[]}}var defaultExecDeps={execForRepo:execHostForRepo,execForPath:execHostForWorktreePath,remoteBasePath(repoKey){return getRemoteRepoConfig(repoKey)?.basePath??null}};import{spawnSync}from"child_process";class GitCommandError extends Error{args;cwd;exitCode;stdout;stderr;constructor(args,cwd,result){super(`git ${args.join(" ")} (cwd=${cwd}) exited with code ${result.exitCode}: ${result.stderr.trim()||result.stdout.trim()}`);this.name="GitCommandError",this.args=args,this.cwd=cwd,this.exitCode=result.exitCode,this.stdout=result.stdout,this.stderr=result.stderr}}function git(args,opts){if(!opts.cwd)throw Error("git(): cwd is required; refusing to inherit from process.cwd()");let env={...process.env,...opts.env,...opts.readOnly?READ_ONLY_GIT_ENV:{}},proc=spawnSync("git",[...args],{cwd:opts.cwd,env,encoding:"utf8",shell:!1}),result={stdout:proc.stdout??"",stderr:proc.stderr??"",exitCode:proc.status??-1};if(result.exitCode!==0&&!opts.allowFail)throw new GitCommandError(args,opts.cwd,result);return result}async function gitlinkPaths2(git2,tree){let out=await git2(["ls-tree","-r",tree]);if(out.exitCode!==0)return[];return out.stdout.split(`
7
+ `).filter((line)=>line.startsWith("160000 ")).map((line)=>line.slice(line.indexOf("\t")+1)).filter((p)=>p.length>0)}function branchRefSlug(branch){return(branch??"").replace(/[\u0000-\u0020\u007f~^:?*[\\/]+/g,"-").replace(/@\{/g,"-").replace(/\.{2,}/g,"-").replace(/^[-.]+|[-.]+$/g,"")||"detached"}function salvageRef(branch,now){let stamp=now.toISOString().replace(/[-:]/g,"").replace(/\.\d+Z$/,"Z");return`refs/rove/salvage/${branchRefSlug(branch)}-${stamp}`}async function createSalvageRef(git2,preferred,commit){for(let attempt=1;attempt<=50;attempt++){let ref=attempt===1?preferred:`${preferred}-${attempt}`;if((await git2(["update-ref",ref,commit,""])).exitCode===0)return ref}return null}async function salvageWorktree(deps,exec,worktreePath,now=new Date){let git2=(args)=>deps.runGit(exec,args,{cwd:worktreePath,allowFail:!0});try{let status=await git2(["status","--porcelain"]);if(status.exitCode!==0)return null;let probe=await smallIgnoredPaths(exec,worktreePath),ignored=probe==="unknown"?[]:probe;if(status.stdout.trim().length===0&&ignored.length===0)return null;let indexPath=(await git2(["rev-parse","--git-path","rove-salvage-index"])).stdout.trim();if(!indexPath)return null;let withIndex=(args)=>deps.runGit(exec,args,{cwd:worktreePath,allowFail:!0,env:{GIT_INDEX_FILE:indexPath}}),head=(await git2(["rev-parse","HEAD"])).stdout.trim(),branch=(await git2(["rev-parse","--abbrev-ref","HEAD"])).stdout.trim();try{if(head&&(await withIndex(["read-tree",head])).exitCode!==0)return null;if((await withIndex(["add","-A"])).exitCode!==0)return null;if(ignored.length>0)await withIndex(["add","-f","--",...ignored]);let tree=(await withIndex(["write-tree"])).stdout.trim();if(!tree)return null;let message=`rove salvage: force-removed worktree ${worktreePath}`,commit=(await withIndex(head?["commit-tree",tree,"-p",head,"-m",message]:["commit-tree",tree,"-m",message])).stdout.trim();if(!commit)return null;let ref=await createSalvageRef(git2,salvageRef(branch&&branch!=="HEAD"?branch:null,now),commit);if(!ref)return null;return{ref,commit,uncaptured:await gitlinkPaths2(git2,tree)}}finally{await exec.run(["rm","-f",indexPath],{cwd:worktreePath}).catch(()=>{return})}}catch{return null}}async function anchorBranchTip(deps,exec,repo,branch,now=new Date){if(!branch||branch==="HEAD")return null;let git2=(args)=>deps.runGit(exec,args,{cwd:repo,allowFail:!0});try{let tipOut=await git2(["rev-parse","--verify",`refs/heads/${branch}`]),tip=tipOut.stdout.trim();if(tipOut.exitCode!==0||!tip)return null;let holders=await git2(["for-each-ref","--contains",tip,"--format=%(refname)"]);if(holders.exitCode===0){if(holders.stdout.split(`
6
8
  `).map((l)=>l.trim()).filter((l)=>l.length>0&&l!==`refs/heads/${branch}`).length>0)return null}let ref=salvageRef(branch,now);if((await git2(["update-ref",ref,tip])).exitCode!==0)return null;return{ref,commit:tip,uncaptured:[]}}catch{return null}}async function branchExists(deps,ctx,branch){return(await deps.runGit(ctx.exec,["show-ref","--verify","--quiet",`refs/heads/${branch}`],{cwd:ctx.dir,allowFail:!0,readOnly:!0})).exitCode===0}async function deleteBranchIn(deps,exec,repo,branch,force){if(!branch||branch==="HEAD")return{deleted:!1,reason:"no branch to delete"};let out=await deps.runGit(exec,["branch",force?"-D":"-d",branch],{cwd:repo,allowFail:!0});if(out.exitCode===0)return{deleted:!0};if(!await branchExists(deps,{exec,dir:repo,remote:exec.isRemote},branch))return{deleted:!0};return{deleted:!1,reason:out.stderr.trim()||out.stdout.trim()||`git branch exited ${out.exitCode}`}}async function deleteBranchAnchored(deps,exec,repo,branch,opts){if(opts.force)opts.onAnchor?.(await anchorBranchTip(deps,exec,repo,branch));return await deleteBranchIn(deps,exec,repo,branch,opts.force)}async function branchHasUpstream(deps,worktreePath,branch){return(await deps.runGit(deps.execAt(worktreePath),["for-each-ref","--format=%(upstream)",`refs/heads/${branch}`],{cwd:worktreePath,readOnly:!0})).stdout.trim().length>0}async function hasLocalBranch(deps,worktreePath,branch){return(await deps.runGit(deps.execAt(worktreePath),["show-ref","--verify","--quiet",`refs/heads/${branch}`],{cwd:worktreePath,allowFail:!0,readOnly:!0})).exitCode===0}async function renameBranch(deps,worktreePath,from,to){let exec=deps.execAt(worktreePath);if(from===to)return;let repo=await deps.findRepoFor(exec,worktreePath);if(!repo)throw Error(`renameBranch(): ${worktreePath} is not a git worktree`);let out=await deps.runGit(exec,["branch","-m",from,to],{cwd:repo,allowFail:!0});if(out.exitCode===0)return;let ctx={exec,dir:repo,remote:exec.isRemote};if(!await branchExists(deps,ctx,from)&&await branchExists(deps,ctx,to))return;throw new GitCommandError(["branch","-m",from,to],repo,out)}import fs2 from"fs";import path2 from"path";async function mapWithLimit(items,limit,fn){let results=Array(items.length),next=0,worker=async()=>{for(;;){let i=next++;if(i>=items.length)return;results[i]=await fn(items[i])}},width=Math.max(1,Math.min(limit,items.length));return await Promise.all(Array.from({length:width},worker)),results}var PROBE_CONCURRENCY=6;function parseWorktreeListPorcelain(out){let records=[],current=null;for(let rawLine of out.split(`
7
9
  `)){let line=rawLine.replace(/\r$/,"");if(line===""){if(current)records.push(current);current=null;continue}if(!current)current={};if(line.startsWith("worktree "))current.path=line.slice(9);else if(line.startsWith("HEAD "))current.head=line.slice(5);else if(line.startsWith("branch ")){let ref=line.slice(7);current.branch=ref.startsWith("refs/heads/")?ref.slice(11):ref}else if(line==="detached")current.detached=!0;else if(line==="bare")current.bare=!0}if(current)records.push(current);return records}async function lastActivityMs(deps,ctx,worktreePath){try{let stdout=await deps.runGitStdoutAt(ctx,worktreePath,["log","-1","--format=%ct"]),secs=Number.parseInt(stdout.trim(),10);if(Number.isFinite(secs)&&secs>0)return secs*1000}catch{}if(!ctx.exec.isRemote)try{return fs2.statSync(worktreePath).mtimeMs}catch{}return 0}async function listBranchNames(deps,repo){let ctx=deps.ctxFor(repo);requireAbsolute("repo",ctx.dir);let stdout;try{stdout=await deps.runGitStdout(ctx,["for-each-ref","--format=%(refname)","refs/heads","refs/remotes/origin"])}catch{return[]}let names=new Set;for(let line of stdout.split(`
8
- `)){let name=line.trim().replace(/^refs\/(?:heads|remotes\/origin)\//,"");if(name&&name!=="HEAD")names.add(name)}return[...names]}async function listManaged(deps,repo){let ctx=deps.ctxFor(repo);requireAbsolute("repo",ctx.dir);let all=parseWorktreeListPorcelain(await deps.runGitStdout(ctx,["worktree","list","--porcelain"])),kept=[];for(let entry of all){if(!entry.path)continue;let callerRoot=ctx.remote?remoteManagedRootForPath(ctx.dir,entry.path):managedWorktreeRootForPath(repo,entry.path);if(!callerRoot)continue;if(!entry.branch||entry.detached)continue;let rel=path2.relative(canonicalize(callerRoot),canonicalize(entry.path));kept.push({callerPath:path2.join(callerRoot,rel),probePath:entry.path,branch:entry.branch,head:entry.head??""})}return mapWithLimit(kept,PROBE_CONCURRENCY,async(e)=>({path:e.callerPath,branch:e.branch,head:e.head,dirty:await deps.isDirty(e.probePath).catch(()=>null)}))}async function listAllAdoptable(deps,repo){let ctx=deps.ctxFor(repo),adoptable=await adoptablePaths(deps,ctx),infos=await mapWithLimit(adoptable,PROBE_CONCURRENCY,async(entry)=>{let[dirty,activityMs]=await Promise.all([deps.isDirty(entry.path).catch(()=>null),lastActivityMs(deps,ctx,entry.path)]);return{path:entry.path,branch:entry.branch,head:entry.head,dirty,roveManaged:ctx.remote?remoteManagedRootForPath(ctx.dir,entry.path)!==null:isRoveManagedPath(repo,entry.path),lastActivityMs:activityMs}});return infos.sort((a,b)=>b.lastActivityMs-a.lastActivityMs),infos}async function adoptablePaths(deps,ctx){requireAbsolute("repo",ctx.dir);let all=parseWorktreeListPorcelain(await deps.runGitStdout(ctx,["worktree","list","--porcelain"])),canon=(p)=>ctx.remote?p:canonicalize(p),canonRepo=canon(ctx.dir),canonMain=all.find((entry)=>entry.path)?.path,canonMainPath=canonMain?canon(canonMain):null,kept=[];for(let entry of all){if(!entry.path)continue;if(entry.bare)continue;if(!entry.branch||entry.detached)continue;let canonEntry=canon(entry.path);if(canonMainPath!==null&&canonEntry===canonMainPath)continue;if(canonEntry===canonRepo)continue;kept.push({path:entry.path,branch:entry.branch,head:entry.head??""})}return kept}async function unreadableWorktreeNames(deps,ctx){if(ctx.remote)return[];requireAbsolute("repo",ctx.dir);let adminRoot;try{let common=(await deps.runGitStdout(ctx,["rev-parse","--git-common-dir"])).trim();if(!common)return[];adminRoot=path2.join(path2.resolve(ctx.dir,common),"worktrees")}catch{return[]}let names;try{names=fs2.readdirSync(adminRoot,{withFileTypes:!0}).filter((entry)=>entry.isDirectory()).map((entry)=>entry.name)}catch{return[]}if(names.length===0)return[];let listed;try{listed=await deps.runGitStdout(ctx,["worktree","list","--porcelain"])}catch{return[]}let reported=new Set(parseWorktreeListPorcelain(listed).filter((entry)=>entry.path).map((entry)=>canonicalize(entry.path))),missing=[];for(let name of names){let gitdir;try{gitdir=fs2.readFileSync(path2.join(adminRoot,name,"gitdir"),"utf8").trim()}catch{missing.push(name);continue}if(gitdir&&!reported.has(canonicalize(path2.dirname(gitdir))))missing.push(name)}return missing}import path3 from"path";async function isRegisteredWorktree(deps,exec,repo,worktreePath){let out=await deps.runGit(exec,["worktree","list","--porcelain"],{cwd:repo,allowFail:!0,readOnly:!0});if(out.exitCode!==0)return!1;let same=(a,b)=>exec.isRemote?a===b:canonicalize(a)===canonicalize(b);return parseWorktreeListPorcelain(out.stdout).some((e)=>e.path!==void 0&&same(e.path,worktreePath))}async function deregisteredWorktreeResidue(exec,worktreePath){let pointer=(await exec.readFile(`${worktreePath}/.git`))?.trim().match(/^gitdir:\s*(.+)$/)?.[1]?.trim();if(!pointer)return!1;let marker="/worktrees/",at=pointer.lastIndexOf(marker);if(at<0)return!1;return await exec.exists(pointer.slice(0,at))}function dirtyRefusal(worktreePath,ignored,dirty=[]){return`${DIRTY_WORKTREE_CODE}: ${worktreePath} has ${describeDirtyWorktreeWork(ignored,dirty)} \u2014 forcing the removal salvages it to a ref first`}async function removeWorktree(deps,worktreePath,opts){requireAbsolute("path",worktreePath);let exec=deps.execForPath(worktreePath),force=opts?.force===!0;if(!await exec.exists(worktreePath)){let goneRepo=opts?.repo??await deps.findRepoFor(exec,path3.dirname(worktreePath));if(goneRepo){if(await deps.runGit(exec,["worktree","prune"],{cwd:goneRepo,allowFail:!0}),opts?.deleteBranch===!0&&opts.branch){let outcome=await deleteBranchAnchored(deps.branchDeps(),exec,goneRepo,opts.branch,{force});if(!outcome.deleted)opts.onBranchKept?.({branch:opts.branch,reason:outcome.reason})}}return}let repo=await deps.findRepoFor(exec,worktreePath);if(repo===null||!await isRegisteredWorktree(deps,exec,repo,worktreePath)){if(await deregisteredWorktreeResidue(exec,worktreePath)){opts?.onResidue?.({path:worktreePath,reason:"a previous removal deregistered the worktree"});return}if(repo){opts?.onResidue?.({path:worktreePath,reason:"a previous removal deregistered the worktree"});return}if(!force)throw Error(`remove(): ${worktreePath} is not a git worktree`);if(!isUnderManagedWorktreesRoot(worktreePath,opts?.repo))throw Error(`remove(): ${worktreePath} has no reachable git repo and is not under a Rove worktrees root; refusing to delete it`);if(opts?.onSalvage?.(null),await exec.run(["rm","-rf",worktreePath]),await exec.exists(worktreePath))opts?.onResidue?.({path:worktreePath,reason:"the directory could not be deleted"});return}let branch=opts?.deleteBranch?await deps.currentBranch(worktreePath).catch(()=>null)??opts.branch??null:null;if(force){let salvaged=await salvageWorktree({runGit:(e,a,o)=>deps.runGit(e,a,o)},exec,worktreePath);opts?.onSalvage?.(salvaged)}else{let dirty=await deps.dirtyPaths(worktreePath);if(dirty.length>0)throw Error(dirtyRefusal(worktreePath,[],dirty));let ignored=await deps.ignoredWork(worktreePath);if(ignored==="unknown"||ignored.length>0)throw Error(dirtyRefusal(worktreePath,ignored))}let args=force?["worktree","remove","--force",worktreePath]:["worktree","remove",worktreePath],result=await deps.runGit(exec,args,{cwd:repo,allowFail:!0});if(result.exitCode!==0){if(await isRegisteredWorktree(deps,exec,repo,worktreePath))throw new GitCommandError(args,repo,result);opts?.onResidue?.({path:worktreePath,reason:result.stderr.trim()||result.stdout.trim()||"unknown"})}if(await deps.runGit(exec,["worktree","prune"],{cwd:repo,allowFail:!0}),branch){let outcome=await deleteBranchAnchored(deps.branchDeps(),exec,repo,branch,{force});if(!outcome.deleted)opts?.onBranchKept?.({branch,reason:outcome.reason})}}class GitWorktreeManager{execDeps;cloneDeps;constructor(execDeps=defaultExecDeps,cloneDeps=defaultCloneDeps){this.execDeps=execDeps;this.cloneDeps=cloneDeps}ctxFor(repoKey){let basePath=this.execDeps.remoteBasePath(repoKey);return basePath?{exec:this.execDeps.execForRepo(repoKey),dir:basePath,remote:!0}:{exec:this.execDeps.execForRepo(repoKey),dir:repoKey,remote:!1}}async runGit(exec,args,opts){if(!opts.cwd)throw Error("runGit(): cwd is required; refusing to inherit from process.cwd()");let env=opts.readOnly?{...opts.env,...READ_ONLY_GIT_ENV}:opts.env,r=await exec.run(["git",...args],{cwd:opts.cwd,env,onStderr:opts.onStderr}),result={stdout:r.stdout,stderr:r.stderr,exitCode:r.exitCode};if(result.exitCode!==0&&!opts.allowFail)throw new GitCommandError(args,opts.cwd,result);return result}async create(repo,branch,worktreePath,baseRef,onProgress){let ctx=this.ctxFor(repo);if(requireAbsolute("repo",ctx.dir),requireAbsolute("path",worktreePath),!branch)throw Error("create(): branch must be a non-empty string");if(await ctx.exec.exists(worktreePath)){let existing=await this.tryDescribe(ctx,worktreePath);if(existing){if(existing.branch!==branch)throw Error(`worktree at ${worktreePath} is on branch '${existing.branch}', refusing to hijack to '${branch}'`);return existing}throw Error(`create(): ${worktreePath} exists but is not a registered git worktree`)}await ctx.exec.mkdirp(path4.dirname(worktreePath));let args=await branchExists(this.branchDeps(),ctx,branch)?["worktree","add",worktreePath,branch]:baseRef?["worktree","add","-b",branch,worktreePath,baseRef]:["worktree","add","-b",branch,worktreePath];await this.runGit(ctx.exec,args,{cwd:ctx.dir,...onProgress?{onStderr:checkoutProgressReader(onProgress)}:{}});let info=await this.tryDescribe(ctx,worktreePath);if(!info)throw Error(`create(): git reported success but ${worktreePath} is not a worktree`);if(info.branch!==branch)throw Error(`create(): post-condition failed \u2014 expected branch '${branch}' at ${worktreePath}, got '${info.branch}'`);return info}async createForTask(args){let basePath=this.execDeps.remoteBasePath(args.repo),target=basePath?remoteWorktreePathFor(basePath,args.slug):worktreePathFor(args.repo,args.slug),ctx=this.ctxFor(args.repo),skipClone=ctx.remote||await ctx.exec.exists(target),info=await this.create(args.repo,args.branch,target,args.baseRef,args.onProgress);if(!skipClone)await cloneIgnoredDirs(ctx.exec,args.repo,info.path,this.cloneDeps(ctx.exec));return info}async remove(worktreePath,opts){await removeWorktree({runGit:(exec,args,runOpts)=>this.runGit(exec,args,runOpts),execForPath:(p)=>this.execDeps.execForPath(p),findRepoFor:(exec,p)=>this.findRepoFor(exec,p),currentBranch:(p)=>this.currentBranch(p),dirtyPaths:(p)=>this.dirtyPaths(p),ignoredWork:(p)=>this.ignoredWork(p),branchDeps:()=>this.branchDeps()},worktreePath,opts)}async deleteBranch(repo,branch,opts){let ctx=this.ctxFor(repo);return requireAbsolute("repo",ctx.dir),await deleteBranchAnchored(this.branchDeps(),ctx.exec,ctx.dir,branch,{force:opts?.force===!0,onAnchor:opts?.onAnchor})}execAt(worktreePath){return requireAbsolute("path",worktreePath),this.execDeps.execForPath(worktreePath)}branchDeps(){return{runGit:(exec,args,opts)=>this.runGit(exec,args,opts),execAt:(worktreePath)=>this.execAt(worktreePath),findRepoFor:(exec,worktreePath)=>this.findRepoFor(exec,worktreePath)}}listDeps(){return{ctxFor:(repoKey)=>this.ctxFor(repoKey),runGitStdout:async(ctx,args)=>(await this.runGit(ctx.exec,args,{cwd:ctx.dir,readOnly:!0})).stdout,runGitStdoutAt:async(ctx,cwd,args)=>(await this.runGit(ctx.exec,args,{cwd,readOnly:!0})).stdout,isDirty:(worktreePath)=>this.isDirty(worktreePath)}}list(repo){return listManaged(this.listDeps(),repo)}listAll(repo){return listAllAdoptable(this.listDeps(),repo)}listAdoptablePaths(repo){return adoptablePaths(this.listDeps(),this.ctxFor(repo))}listUnreadableWorktrees(repo){return unreadableWorktreeNames(this.listDeps(),this.ctxFor(repo))}listBranchNames(repo){return listBranchNames(this.listDeps(),repo)}async pathExists(worktreePath){return this.execAt(worktreePath).exists(worktreePath)}async pruneWorktrees(repo){let ctx=this.ctxFor(repo);requireAbsolute("repo",ctx.dir),await this.runGit(ctx.exec,["worktree","prune"],{cwd:ctx.dir,allowFail:!0})}async isDirty(worktreePath){return(await this.dirtyPaths(worktreePath)).length>0}async dirtyPaths(worktreePath){let out=await this.runGit(this.execAt(worktreePath),["status","--porcelain"],{cwd:worktreePath,readOnly:!0});return parseDirtyPaths(out.stdout)}async ignoredWork(worktreePath){let exec=this.execAt(worktreePath);return smallIgnoredPaths(exec,worktreePath,regenerableDirNames(exec,worktreePath,this.cloneDeps(exec)))}async currentBranch(worktreePath){let name=(await this.runGit(this.execAt(worktreePath),["rev-parse","--abbrev-ref","HEAD"],{cwd:worktreePath,readOnly:!0})).stdout.trim();if(!name||name==="HEAD")throw Error(`currentBranch(): ${worktreePath} is in detached-HEAD state`);return name}branchHasUpstream(worktreePath,branch){return branchHasUpstream(this.branchDeps(),worktreePath,branch)}hasLocalBranch(worktreePath,branch){return hasLocalBranch(this.branchDeps(),worktreePath,branch)}renameBranch(worktreePath,from,to){return renameBranch(this.branchDeps(),worktreePath,from,to)}async tryDescribe(ctx,worktreePath){let out=await this.runGit(ctx.exec,["worktree","list","--porcelain"],{cwd:ctx.dir,readOnly:!0}),entries=parseWorktreeListPorcelain(out.stdout),norm=(p)=>ctx.remote?p:canonicalize(p),target=norm(worktreePath),match=entries.find((e)=>e.path&&norm(e.path)===target);if(!match||!match.path||!match.branch||match.detached)return null;return{path:worktreePath,branch:match.branch,head:match.head??"",dirty:await this.isDirty(match.path)}}async findRepoFor(exec,worktreePath){try{let out=await this.runGit(exec,["rev-parse","--git-common-dir"],{cwd:worktreePath,allowFail:!0,readOnly:!0});if(out.exitCode!==0)return null;let gitDir=out.stdout.trim();if(!gitDir)return null;let absolute=path4.isAbsolute(gitDir)?gitDir:path4.resolve(worktreePath,gitDir);return path4.basename(absolute)===".git"?path4.dirname(absolute):absolute}catch(err){if(err instanceof GitCommandError)return null;throw err}}}
9
- export{parseDirtyPaths,isDirtyOutput,defaultExecDeps,git,GitWorktreeManager};
10
+ `)){let name=line.trim().replace(/^refs\/(?:heads|remotes\/origin)\//,"");if(name&&name!=="HEAD")names.add(name)}return[...names]}async function listManaged(deps,repo){let ctx=deps.ctxFor(repo);requireAbsolute("repo",ctx.dir);let all=parseWorktreeListPorcelain(await deps.runGitStdout(ctx,["worktree","list","--porcelain"])),kept=[];for(let entry of all){if(!entry.path)continue;let callerRoot=ctx.remote?remoteManagedRootForPath(ctx.dir,entry.path):managedWorktreeRootForPath(repo,entry.path);if(!callerRoot)continue;if(!entry.branch||entry.detached)continue;let rel=path2.relative(canonicalize(callerRoot),canonicalize(entry.path));kept.push({callerPath:path2.join(callerRoot,rel),probePath:entry.path,branch:entry.branch,head:entry.head??""})}return mapWithLimit(kept,PROBE_CONCURRENCY,async(e)=>({path:e.callerPath,branch:e.branch,head:e.head,dirty:await deps.isDirty(e.probePath).catch(()=>null)}))}async function listAllAdoptable(deps,repo){let ctx=deps.ctxFor(repo),adoptable=await adoptablePaths(deps,ctx),infos=await mapWithLimit(adoptable,PROBE_CONCURRENCY,async(entry)=>{let[dirty,activityMs]=await Promise.all([deps.isDirty(entry.path).catch(()=>null),lastActivityMs(deps,ctx,entry.path)]);return{path:entry.path,branch:entry.branch,head:entry.head,dirty,roveManaged:ctx.remote?remoteManagedRootForPath(ctx.dir,entry.path)!==null:isRoveManagedPath(repo,entry.path),lastActivityMs:activityMs}});return infos.sort((a,b)=>b.lastActivityMs-a.lastActivityMs),infos}async function adoptablePaths(deps,ctx){requireAbsolute("repo",ctx.dir);let all=parseWorktreeListPorcelain(await deps.runGitStdout(ctx,["worktree","list","--porcelain"])),canon=(p)=>ctx.remote?p:canonicalize(p),canonRepo=canon(ctx.dir),canonMain=all.find((entry)=>entry.path)?.path,canonMainPath=canonMain?canon(canonMain):null,kept=[];for(let entry of all){if(!entry.path)continue;if(entry.bare)continue;if(!entry.branch||entry.detached)continue;let canonEntry=canon(entry.path);if(canonMainPath!==null&&canonEntry===canonMainPath)continue;if(canonEntry===canonRepo)continue;kept.push({path:entry.path,branch:entry.branch,head:entry.head??""})}return kept}async function unreadableWorktreeNames(deps,ctx){if(ctx.remote)return[];requireAbsolute("repo",ctx.dir);let adminRoot;try{let common=(await deps.runGitStdout(ctx,["rev-parse","--git-common-dir"])).trim();if(!common)return[];adminRoot=path2.join(path2.resolve(ctx.dir,common),"worktrees")}catch{return[]}let names;try{names=fs2.readdirSync(adminRoot,{withFileTypes:!0}).filter((entry)=>entry.isDirectory()).map((entry)=>entry.name)}catch{return[]}if(names.length===0)return[];let listed;try{listed=await deps.runGitStdout(ctx,["worktree","list","--porcelain"])}catch{return[]}let reported=new Set(parseWorktreeListPorcelain(listed).filter((entry)=>entry.path).map((entry)=>canonicalize(entry.path))),missing=[];for(let name of names){let gitdir;try{gitdir=fs2.readFileSync(path2.join(adminRoot,name,"gitdir"),"utf8").trim()}catch{missing.push(name);continue}if(gitdir&&!reported.has(canonicalize(path2.dirname(gitdir))))missing.push(name)}return missing}import path3 from"path";async function isRegisteredWorktree(deps,exec,repo,worktreePath){let out=await deps.runGit(exec,["worktree","list","--porcelain"],{cwd:repo,allowFail:!0,readOnly:!0});if(out.exitCode!==0)return!1;let same=(a,b)=>exec.isRemote?a===b:canonicalize(a)===canonicalize(b);return parseWorktreeListPorcelain(out.stdout).some((e)=>e.path!==void 0&&same(e.path,worktreePath))}async function deregisteredWorktreeResidue(exec,worktreePath){let pointer=(await exec.readFile(`${worktreePath}/.git`))?.trim().match(/^gitdir:\s*(.+)$/)?.[1]?.trim();if(!pointer)return!1;let marker="/worktrees/",at=pointer.lastIndexOf(marker);if(at<0)return!1;return await exec.exists(pointer.slice(0,at))}function dirtyRefusal(worktreePath,ignored,dirty=[]){return`${DIRTY_WORKTREE_CODE}: ${worktreePath} has ${describeDirtyWorktreeWork(ignored,dirty)} \u2014 forcing the removal salvages it to a ref first`}async function removeWorktree(deps,worktreePath,opts){requireAbsolute("path",worktreePath);let exec=deps.execForPath(worktreePath),force=opts?.force===!0;if(!await exec.exists(worktreePath)){let goneRepo=opts?.repo??await deps.findRepoFor(exec,path3.dirname(worktreePath));if(goneRepo){if(await deps.runGit(exec,["worktree","prune"],{cwd:goneRepo,allowFail:!0}),opts?.deleteBranch===!0&&opts.branch){let outcome=await deleteBranchAnchored(deps.branchDeps(),exec,goneRepo,opts.branch,{force});if(!outcome.deleted)opts.onBranchKept?.({branch:opts.branch,reason:outcome.reason})}}return}let repo=await deps.findRepoFor(exec,worktreePath);if(repo===null||!await isRegisteredWorktree(deps,exec,repo,worktreePath)){if(await deregisteredWorktreeResidue(exec,worktreePath)){opts?.onResidue?.({path:worktreePath,reason:"a previous removal deregistered the worktree"});return}if(repo){opts?.onResidue?.({path:worktreePath,reason:"a previous removal deregistered the worktree"});return}if(!force)throw Error(`remove(): ${worktreePath} is not a git worktree`);if(!isUnderManagedWorktreesRoot(worktreePath,opts?.repo))throw Error(`remove(): ${worktreePath} has no reachable git repo and is not under a Rove worktrees root; refusing to delete it`);if(opts?.onSalvage?.(null),await exec.run(["rm","-rf",worktreePath]),await exec.exists(worktreePath))opts?.onResidue?.({path:worktreePath,reason:"the directory could not be deleted"});return}let branch=opts?.deleteBranch?await deps.currentBranch(worktreePath).catch(()=>null)??opts.branch??null:null;if(force){let salvaged=await salvageWorktree({runGit:(e,a,o)=>deps.runGit(e,a,o)},exec,worktreePath);opts?.onSalvage?.(salvaged)}else{let dirty=await deps.dirtyPaths(worktreePath);if(dirty.length>0)throw Error(dirtyRefusal(worktreePath,[],dirty));let ignored=await deps.ignoredWork(worktreePath);if(ignored==="unknown"||ignored.length>0)throw Error(dirtyRefusal(worktreePath,ignored))}let args=force?["worktree","remove","--force",worktreePath]:["worktree","remove",worktreePath],result=await deps.runGit(exec,args,{cwd:repo,allowFail:!0});if(result.exitCode!==0){if(await isRegisteredWorktree(deps,exec,repo,worktreePath))throw new GitCommandError(args,repo,result);opts?.onResidue?.({path:worktreePath,reason:result.stderr.trim()||result.stdout.trim()||"unknown"})}if(await deps.runGit(exec,["worktree","prune"],{cwd:repo,allowFail:!0}),branch){let outcome=await deleteBranchAnchored(deps.branchDeps(),exec,repo,branch,{force});if(!outcome.deleted)opts?.onBranchKept?.({branch,reason:outcome.reason})}}class GitWorktreeManager{execDeps;cloneDeps;constructor(execDeps=defaultExecDeps,cloneDeps=defaultCloneDeps){this.execDeps=execDeps;this.cloneDeps=cloneDeps}ctxFor(repoKey){let basePath=this.execDeps.remoteBasePath(repoKey);return basePath?{exec:this.execDeps.execForRepo(repoKey),dir:basePath,remote:!0}:{exec:this.execDeps.execForRepo(repoKey),dir:repoKey,remote:!1}}async runGit(exec,args,opts){if(!opts.cwd)throw Error("runGit(): cwd is required; refusing to inherit from process.cwd()");let env=opts.readOnly?{...opts.env,...READ_ONLY_GIT_ENV}:opts.env,r=await exec.run(["git",...args],{cwd:opts.cwd,env,onStderr:opts.onStderr}),result={stdout:r.stdout,stderr:r.stderr,exitCode:r.exitCode};if(result.exitCode!==0&&!opts.allowFail)throw new GitCommandError(args,opts.cwd,result);return result}async create(repo,branch,worktreePath,baseRef,onProgress){let ctx=this.ctxFor(repo);if(requireAbsolute("repo",ctx.dir),requireAbsolute("path",worktreePath),!branch)throw Error("create(): branch must be a non-empty string");if(await ctx.exec.exists(worktreePath)){let existing=await this.tryDescribe(ctx,worktreePath);if(existing){if(existing.branch!==branch)throw Error(`worktree at ${worktreePath} is on branch '${existing.branch}', refusing to hijack to '${branch}'`);return existing}throw Error(`create(): ${worktreePath} exists but is not a registered git worktree`)}await ctx.exec.mkdirp(path4.dirname(worktreePath));let args=await branchExists(this.branchDeps(),ctx,branch)?["worktree","add",worktreePath,branch]:baseRef?["worktree","add","-b",branch,worktreePath,baseRef]:["worktree","add","-b",branch,worktreePath];await this.runGit(ctx.exec,args,{cwd:ctx.dir,...onProgress?{onStderr:checkoutProgressReader(onProgress)}:{}});let info=await this.tryDescribe(ctx,worktreePath);if(!info)throw Error(`create(): git reported success but ${worktreePath} is not a worktree`);if(info.branch!==branch)throw Error(`create(): post-condition failed \u2014 expected branch '${branch}' at ${worktreePath}, got '${info.branch}'`);return info}async createForTask(args){let basePath=this.execDeps.remoteBasePath(args.repo),target=basePath?remoteWorktreePathFor(basePath,args.slug):worktreePathFor(args.repo,args.slug),ctx=this.ctxFor(args.repo),skipClone=ctx.remote||await ctx.exec.exists(target),info=await this.create(args.repo,args.branch,target,args.baseRef,args.onProgress);if(!skipClone)await cloneIgnoredDirs(ctx.exec,args.repo,info.path,this.cloneDeps(ctx.exec));return info}async remove(worktreePath,opts){await removeWorktree({runGit:(exec,args,runOpts)=>this.runGit(exec,args,runOpts),execForPath:(p)=>this.execDeps.execForPath(p),findRepoFor:(exec,p)=>this.findRepoFor(exec,p),currentBranch:(p)=>this.currentBranch(p),dirtyPaths:(p)=>this.dirtyPaths(p),ignoredWork:(p)=>this.ignoredWork(p),branchDeps:()=>this.branchDeps()},worktreePath,opts)}async deleteBranch(repo,branch,opts){let ctx=this.ctxFor(repo);return requireAbsolute("repo",ctx.dir),await deleteBranchAnchored(this.branchDeps(),ctx.exec,ctx.dir,branch,{force:opts?.force===!0,onAnchor:opts?.onAnchor})}execAt(worktreePath){return requireAbsolute("path",worktreePath),this.execDeps.execForPath(worktreePath)}branchDeps(){return{runGit:(exec,args,opts)=>this.runGit(exec,args,opts),execAt:(worktreePath)=>this.execAt(worktreePath),findRepoFor:(exec,worktreePath)=>this.findRepoFor(exec,worktreePath)}}listDeps(){return{ctxFor:(repoKey)=>this.ctxFor(repoKey),runGitStdout:async(ctx,args)=>(await this.runGit(ctx.exec,args,{cwd:ctx.dir,readOnly:!0})).stdout,runGitStdoutAt:async(ctx,cwd,args)=>(await this.runGit(ctx.exec,args,{cwd,readOnly:!0})).stdout,isDirty:(worktreePath)=>this.isDirty(worktreePath)}}list(repo){return listManaged(this.listDeps(),repo)}listAll(repo){return listAllAdoptable(this.listDeps(),repo)}listAdoptablePaths(repo){return adoptablePaths(this.listDeps(),this.ctxFor(repo))}listUnreadableWorktrees(repo){return unreadableWorktreeNames(this.listDeps(),this.ctxFor(repo))}listBranchNames(repo){return listBranchNames(this.listDeps(),repo)}async pathExists(worktreePath){return this.execAt(worktreePath).exists(worktreePath)}async pruneWorktrees(repo){let ctx=this.ctxFor(repo);requireAbsolute("repo",ctx.dir),await this.runGit(ctx.exec,["worktree","prune"],{cwd:ctx.dir,allowFail:!0})}async isDirty(worktreePath){return(await this.dirtyPaths(worktreePath)).length>0}async dirtyPaths(worktreePath){let out=await this.runGit(this.execAt(worktreePath),["status","--porcelain"],{cwd:worktreePath,readOnly:!0});return parseDirtyPaths(out.stdout)}async ignoredWork(worktreePath){let exec=this.execAt(worktreePath);return smallIgnoredPaths(exec,worktreePath,regenerableDirNames(exec,worktreePath,this.cloneDeps(exec)))}checkpointDeps(){return{runGit:(exec,args,opts)=>this.runGit(exec,args,opts)}}takeCheckpoint(worktreePath,taskId,opts){return takeCheckpoint(this.checkpointDeps(),this.execAt(worktreePath),worktreePath,taskId,opts)}listCheckpoints(worktreePath,taskId){return listCheckpoints(this.checkpointDeps(),this.execAt(worktreePath),worktreePath,taskId)}rewindToCheckpoint(worktreePath,taskId,n){return rewindTo(this.checkpointDeps(),this.execAt(worktreePath),worktreePath,taskId,n)}async deleteTaskCheckpoints(repo,taskId){let ctx=this.ctxFor(repo);return requireAbsolute("repo",ctx.dir),deleteTaskCheckpoints(this.checkpointDeps(),ctx.exec,ctx.dir,taskId)}async moveTaskCheckpoints(repo,fromId,toId){let ctx=this.ctxFor(repo);return requireAbsolute("repo",ctx.dir),moveTaskCheckpoints(this.checkpointDeps(),ctx.exec,ctx.dir,fromId,toId)}async currentBranch(worktreePath){let name=(await this.runGit(this.execAt(worktreePath),["rev-parse","--abbrev-ref","HEAD"],{cwd:worktreePath,readOnly:!0})).stdout.trim();if(!name||name==="HEAD")throw Error(`currentBranch(): ${worktreePath} is in detached-HEAD state`);return name}branchHasUpstream(worktreePath,branch){return branchHasUpstream(this.branchDeps(),worktreePath,branch)}hasLocalBranch(worktreePath,branch){return hasLocalBranch(this.branchDeps(),worktreePath,branch)}renameBranch(worktreePath,from,to){return renameBranch(this.branchDeps(),worktreePath,from,to)}async tryDescribe(ctx,worktreePath){let out=await this.runGit(ctx.exec,["worktree","list","--porcelain"],{cwd:ctx.dir,readOnly:!0}),entries=parseWorktreeListPorcelain(out.stdout),norm=(p)=>ctx.remote?p:canonicalize(p),target=norm(worktreePath),match=entries.find((e)=>e.path&&norm(e.path)===target);if(!match||!match.path||!match.branch||match.detached)return null;return{path:worktreePath,branch:match.branch,head:match.head??"",dirty:await this.isDirty(match.path)}}async findRepoFor(exec,worktreePath){try{let out=await this.runGit(exec,["rev-parse","--git-common-dir"],{cwd:worktreePath,allowFail:!0,readOnly:!0});if(out.exitCode!==0)return null;let gitDir=out.stdout.trim();if(!gitDir)return null;let absolute=path4.isAbsolute(gitDir)?gitDir:path4.resolve(worktreePath,gitDir);return path4.basename(absolute)===".git"?path4.dirname(absolute):absolute}catch(err){if(err instanceof GitCommandError)return null;throw err}}}
11
+ export{CLONEFILEAT_PERL,git,parseDirtyPaths,isDirtyOutput,defaultExecDeps,GitWorktreeManager};
package/dist/cli/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env bun
2
2
  // @bun
3
- import{matchPathGlob}from"./chunk-kg11c1py.js";import{failureHint}from"./chunk-6jk2khme.js";import{switchFlag}from"./chunk-zsfyj36g.js";import{expandTilde}from"./chunk-2r1fgng9.js";import{connectIfRunning}from"./chunk-387ecqb8.js";import"./chunk-kgs56yns.js";import"./chunk-4hnz77xf.js";import{errorMessage}from"./chunk-2brn8e1y.js";import{BUILTIN_VENDORS,coerceVendorId,isBuiltinVendor}from"./chunk-h2m7em1e.js";import{CURRENT_VERSION}from"./chunk-qsqde2kj.js";import{rejectionReason}from"./chunk-7mwvvj46.js";import"./chunk-z1nj22va.js";import"./chunk-br8r72bf.js";import{ROVE_PRODUCT_NAME}from"./chunk-zt7wfnva.js";import"./chunk-yt15y085.js";import"./chunk-bj6sa371.js";import"./chunk-1ffqacz9.js";import"./chunk-cmp64q4j.js";import"./chunk-sza3tyhs.js";import"./chunk-96kvwzj8.js";import"./chunk-0g4wc808.js";import{pathSyntax}from"./chunk-pn5ygqn6.js";import"./chunk-eqdbfgq5.js";import"./chunk-f8gg8cqh.js";import"./chunk-nc46gddg.js";import{__require}from"./chunk-91sykzqq.js";import{resolve as resolve2}from"path";function debugEnabled(env){return env.ROVE_DEBUG==="1"||env.ROVE_DEBUG==="1"}function failureSubject(cliName,argv){let verb=argv[2];return verb&&!verb.startsWith("-")&&!verb.includes("/")?`${cliName} ${verb}`:cliName}function summarizeCliGitError(message,cwd){if(!/not a git repository/i.test(message))return null;return`${cwd} is not a git repository \u2014 run this inside one, or pass a repo path.`}function formatCliFailure(err,opts){let subject=failureSubject(opts.cliName,opts.argv);if(debugEnabled(opts.env))return`${subject}: ${String(err instanceof Error?err.stack??err:err)}
3
+ import{matchPathGlob}from"./chunk-kg11c1py.js";import{failureHint}from"./chunk-t52gzaeb.js";import{CURRENT_VERSION}from"./chunk-a4r45qdn.js";import{switchFlag}from"./chunk-zsfyj36g.js";import{expandTilde}from"./chunk-2r1fgng9.js";import{connectIfRunning}from"./chunk-d0hpes59.js";import"./chunk-mkfc9a09.js";import"./chunk-syn0tfwy.js";import{errorMessage}from"./chunk-2brn8e1y.js";import{rejectionReason}from"./chunk-7mwvvj46.js";import"./chunk-372g44dg.js";import"./chunk-1eef3z5v.js";import"./chunk-cmp64q4j.js";import"./chunk-n6marmjn.js";import"./chunk-96kvwzj8.js";import{BUILTIN_VENDORS,coerceVendorId,isBuiltinVendor}from"./chunk-h2m7em1e.js";import"./chunk-z1nj22va.js";import"./chunk-br8r72bf.js";import{ROVE_PRODUCT_NAME}from"./chunk-zt7wfnva.js";import"./chunk-yt15y085.js";import"./chunk-0g4wc808.js";import{pathSyntax}from"./chunk-pn5ygqn6.js";import"./chunk-eqdbfgq5.js";import"./chunk-f8gg8cqh.js";import"./chunk-nc46gddg.js";import{__require}from"./chunk-91sykzqq.js";import{resolve as resolve2}from"path";function debugEnabled(env){return env.ROVE_DEBUG==="1"||env.ROVE_DEBUG==="1"}function failureSubject(cliName,argv){let verb=argv[2];return verb&&!verb.startsWith("-")&&!verb.includes("/")?`${cliName} ${verb}`:cliName}function summarizeCliGitError(message,cwd){if(!/not a git repository/i.test(message))return null;return`${cwd} is not a git repository \u2014 run this inside one, or pass a repo path.`}function formatCliFailure(err,opts){let subject=failureSubject(opts.cliName,opts.argv);if(debugEnabled(opts.env))return`${subject}: ${String(err instanceof Error?err.stack??err:err)}
4
4
  ${failureHint(err,opts.cliName)}`;let raw=errorMessage(err),git=summarizeCliGitError(raw,opts.cwd);return`${subject}: ${git??`${raw}
5
- ${failureHint(err,opts.cliName)}`}`}var DYNAMIC_COMMANDS=new Map([["completions",async(args)=>{let{runCompletionsSubcommand}=await import("./chunk-x7yxf5b5.js");await runCompletionsSubcommand(args)}],["export",async(args)=>{let{runExportSubcommand}=await import("./chunk-ecrw211n.js");await runExportSubcommand(args)}],["repo",async(args)=>{let{runRepoSubcommand}=await import("./chunk-gqh6atvp.js");await runRepoSubcommand(args)}],["api",async(args)=>{let{runApiSubcommand}=await import("./chunk-ajad94vy.js");await runApiSubcommand(args)}],["update",async(args)=>{let{runUpdateSubcommand}=await import("./chunk-bm0qe5gy.js");await runUpdateSubcommand(args)}],["theme",async(args)=>{let{runThemeSubcommand}=await import("./chunk-ycd28edp.js");await runThemeSubcommand(args)}],["feedback",async(args)=>{let{runFeedbackSubcommand}=await import("./chunk-wqvmvgaf.js");await runFeedbackSubcommand(args)}],["daemon",async(args)=>{let{runDaemonSubcommand}=await import("./chunk-adj65prq.js");await runDaemonSubcommand(args)}],["machine",async(args)=>{let{runMachineSubcommand}=await import("./chunk-98s0fhmv.js");await runMachineSubcommand(args)}],["weixin",async(args)=>{let{runChannelCli}=await import("./chunk-qnaxnx5w.js");await runChannelCli("weixin",args)}],["doctor",async(args)=>{let{runDoctorSubcommand}=await import("./chunk-sap4tggv.js");await runDoctorSubcommand(args)}],["config",async(args)=>{let{runConfigSubcommand}=await import("./chunk-bexnp6g4.js");await runConfigSubcommand(args)}],["reset",async(args)=>{let{runResetSubcommand}=await import("./chunk-f6hgkc7g.js");await runResetSubcommand(args)}],["pty-host",async(args)=>{let{runPtyHostSubcommand}=await import("./chunk-5c4vr45n.js");await runPtyHostSubcommand(args)}],["skill",async(args)=>{let{runSkillSubcommand}=await import("./chunk-nf3kg9rz.js");await runSkillSubcommand(args)}],["plugin",async(args)=>{let{runPluginSubcommand}=await import("./chunk-k5k2jpxk.js");await runPluginSubcommand(args)}],["hook",async(args)=>{let{runHookSubcommand}=await import("./chunk-vjp7drne.js");await runHookSubcommand(args)}]]);import{statSync}from"fs";import{resolve}from"path";async function openLocalOrchestrator(){let{TaskIndexStore}=await import("./chunk-22d4fjjb.js"),{GitWorktreeManager}=await import("./chunk-qfe1wf5c.js"),{Orchestrator}=await import("./chunk-6jj82bej.js"),store=new TaskIndexStore;return await store.load(),new Orchestrator({store,worktrees:new GitWorktreeManager})}async function withDaemonOrLocal(bridge){let client=await connectIfRunning();if(client)try{return await bridge.daemon(client)}finally{client.close()}let orch=await openLocalOrchestrator();return bridge.local(orch)}function isPathLikeArg(arg){return arg==="."||arg===".."||arg.startsWith("./")||arg.startsWith("../")||arg.startsWith(".\\")||arg.startsWith("..\\")||pathSyntax(arg).isAbsolute(arg)||arg.startsWith("/")||arg==="~"||arg.startsWith("~/")||arg.startsWith("~\\")}async function projectRootFor(dir){let{isGitRepo,resolveRepoRoot}=await import("./chunk-hv79ys32.js"),{projectRejection}=await import("./chunk-qnpkhvrn.js"),top=resolveRepoRoot(dir);if(top!==dir)return null;return projectRejection(top,isGitRepo,"explicit")?null:top}async function runOpenDirectory(arg){let dir=resolve(process.cwd(),expandTilde(arg)),isDir=!1;try{isDir=statSync(dir).isDirectory()}catch{isDir=!1}if(!isDir)process.stderr.write(`${ROVE_PRODUCT_NAME}: "${arg}" is not a directory (resolved to ${dir}).
6
- `),process.exit(1);let projectRoot=await projectRootFor(dir);await withDaemonOrLocal({daemon:async(client)=>{let taskId;if(projectRoot)taskId=(await client.request("task.ensureMain",{repo:projectRoot})).task.id;else taskId=(await client.request("task.openDir",{dir})).taskId;await client.request("task.setActive",{taskId})},local:async(orch)=>{let task=projectRoot?await orch.ensureMainTask(projectRoot):await orch.openDirectoryTask({dir}),{writeLastActiveTaskId}=await import("./chunk-y8b2p44q.js");writeLastActiveTaskId(String(task.id))}});let{publishRoveTerminalTitle}=await import("./chunk-g8wrdp7n.js");publishRoveTerminalTitle();let{launchTui}=await import("./chunk-80t9z2b2.js");await launchTui()}function topLevelUsage(cliName=ROVE_PRODUCT_NAME){return[`${cliName} ${CURRENT_VERSION}`,"",`Usage: ${cliName} [command] [options]`,"","Run with no command to launch PureTUI.",`Run \`${cliName} .\` (or \`${cliName} <path>\`) to open a directory as a standalone task.`,"","Commands:"," completions <shell> Generate shell completion script (bash/zsh/fish)"," add [path] Save a repo path for the new-task picker"," remove [path] Forget a saved project (inverse of add; non-destructive)"," adopt [glob] Import existing git worktrees as tasks"," export [--csv|--json] Print the task list (json/csv/table; daemon-free)"," repo <verb> Per-repo init script + first prompt (show|set|unset)",` api <verb> Scriptable RPC surface for agents (see \`${cliName} api --help\`)`," daemon <verb> Manage the daemon (start|stop|status|restart)"," machine <verb> Other computers running Rove (add|doctor|remove|list)"," weixin <verb> Talk to Rove from WeChat (login|logout|status|allow|deny|send|agent)"," doctor [--report|--fix] Diagnose daemon/PTY/engines/git; --fix walks the remedies",` config [--path] Open ${cliName}'s config file (state.json) in your editor`," reset [--hard] Stop runtimes; optionally wipe task/UI state"," theme <verb> Manage user themes (list|add|remove)",` skill <verb> Install the ${cliName} agent skill (install|status|command|print)`," plugin <verb> Install and run plugins (install|link|list|action|\u2026)"," feedback Send feedback to GitHub Discussions",` update [version|channel|list] Self-update ${cliName}, switch channel, or list versions`,"","Options:"," -v, --version Print version"," -h, --help Print this help"," --skill Print the agent skill file and exit"," --web [bridge flags] Serve the browser client on 127.0.0.1 and print its link"].join(`
5
+ ${failureHint(err,opts.cliName)}`}`}var DYNAMIC_COMMANDS=new Map([["completions",async(args)=>{let{runCompletionsSubcommand}=await import("./chunk-m73x5nry.js");await runCompletionsSubcommand(args)}],["export",async(args)=>{let{runExportSubcommand}=await import("./chunk-dt676ks9.js");await runExportSubcommand(args)}],["repo",async(args)=>{let{runRepoSubcommand}=await import("./chunk-tjhw09bz.js");await runRepoSubcommand(args)}],["api",async(args)=>{let{runApiSubcommand}=await import("./chunk-brgfsm5v.js");await runApiSubcommand(args)}],["update",async(args)=>{let{runUpdateSubcommand}=await import("./chunk-3xkhcfet.js");await runUpdateSubcommand(args)}],["theme",async(args)=>{let{runThemeSubcommand}=await import("./chunk-4xvmrg86.js");await runThemeSubcommand(args)}],["feedback",async(args)=>{let{runFeedbackSubcommand}=await import("./chunk-745pg3xm.js");await runFeedbackSubcommand(args)}],["daemon",async(args)=>{let{runDaemonSubcommand}=await import("./chunk-81thm1eb.js");await runDaemonSubcommand(args)}],["machine",async(args)=>{let{runMachineSubcommand}=await import("./chunk-mz1ffkqb.js");await runMachineSubcommand(args)}],["weixin",async(args)=>{let{runChannelCli}=await import("./chunk-xb3p11g0.js");await runChannelCli("weixin",args)}],["doctor",async(args)=>{let{runDoctorSubcommand}=await import("./chunk-1ca2j9w6.js");await runDoctorSubcommand(args)}],["config",async(args)=>{let{runConfigSubcommand}=await import("./chunk-c63vgbkw.js");await runConfigSubcommand(args)}],["reset",async(args)=>{let{runResetSubcommand}=await import("./chunk-gq57he03.js");await runResetSubcommand(args)}],["pty-host",async(args)=>{let{runPtyHostSubcommand}=await import("./chunk-t4qr9sv4.js");await runPtyHostSubcommand(args)}],["skill",async(args)=>{let{runSkillSubcommand}=await import("./chunk-ccwe9n56.js");await runSkillSubcommand(args)}],["plugin",async(args)=>{let{runPluginSubcommand}=await import("./chunk-jckx79gk.js");await runPluginSubcommand(args)}],["hook",async(args)=>{let{runHookSubcommand}=await import("./chunk-xv3217yv.js");await runHookSubcommand(args)}]]);import{statSync}from"fs";import{resolve}from"path";async function openLocalOrchestrator(){let{TaskIndexStore}=await import("./chunk-gafkp74h.js"),{GitWorktreeManager}=await import("./chunk-91tcwxph.js"),{Orchestrator}=await import("./chunk-syfs63r2.js"),store=new TaskIndexStore;return await store.load(),new Orchestrator({store,worktrees:new GitWorktreeManager})}async function withDaemonOrLocal(bridge){let client=await connectIfRunning();if(client)try{return await bridge.daemon(client)}finally{client.close()}let orch=await openLocalOrchestrator();return bridge.local(orch)}function isPathLikeArg(arg){return arg==="."||arg===".."||arg.startsWith("./")||arg.startsWith("../")||arg.startsWith(".\\")||arg.startsWith("..\\")||pathSyntax(arg).isAbsolute(arg)||arg.startsWith("/")||arg==="~"||arg.startsWith("~/")||arg.startsWith("~\\")}async function projectRootFor(dir){let{isGitRepo,resolveRepoRoot}=await import("./chunk-hv79ys32.js"),{projectRejection}=await import("./chunk-qnpkhvrn.js"),top=resolveRepoRoot(dir);if(top!==dir)return null;return projectRejection(top,isGitRepo,"explicit")?null:top}async function runOpenDirectory(arg){let dir=resolve(process.cwd(),expandTilde(arg)),isDir=!1;try{isDir=statSync(dir).isDirectory()}catch{isDir=!1}if(!isDir)process.stderr.write(`${ROVE_PRODUCT_NAME}: "${arg}" is not a directory (resolved to ${dir}).
6
+ `),process.exit(1);let projectRoot=await projectRootFor(dir);await withDaemonOrLocal({daemon:async(client)=>{let taskId;if(projectRoot)taskId=(await client.request("task.ensureMain",{repo:projectRoot})).task.id;else taskId=(await client.request("task.openDir",{dir})).taskId;await client.request("task.setActive",{taskId})},local:async(orch)=>{let task=projectRoot?await orch.ensureMainTask(projectRoot):await orch.openDirectoryTask({dir}),{writeLastActiveTaskId}=await import("./chunk-y8b2p44q.js");writeLastActiveTaskId(String(task.id))}});let{publishRoveTerminalTitle}=await import("./chunk-g8wrdp7n.js");publishRoveTerminalTitle();let{launchTui}=await import("./chunk-5e9y8aw5.js");await launchTui()}function topLevelUsage(cliName=ROVE_PRODUCT_NAME){return[`${cliName} ${CURRENT_VERSION}`,"",`Usage: ${cliName} [command] [options]`,"","Run with no command to launch PureTUI.",`Run \`${cliName} .\` (or \`${cliName} <path>\`) to open a directory as a standalone task.`,"","Commands:"," completions <shell> Generate shell completion script (bash/zsh/fish)"," add [path] Save a repo path for the new-task picker"," remove [path] Forget a saved project (inverse of add; non-destructive)"," adopt [glob] Import existing git worktrees as tasks"," export [--csv|--json] Print the task list (json/csv/table; daemon-free)"," repo <verb> Per-repo init script + first prompt (show|set|unset)",` api <verb> Scriptable RPC surface for agents (see \`${cliName} api --help\`)`," daemon <verb> Manage the daemon (start|stop|status|restart)"," machine <verb> Other computers running Rove (add|doctor|remove|list)"," weixin <verb> Talk to Rove from WeChat (login|logout|status|allow|deny|send|agent)"," doctor [--report|--fix] Diagnose daemon/PTY/engines/git; --fix walks the remedies",` config [--path] Open ${cliName}'s config file (state.json) in your editor`," reset [--hard] Stop runtimes; optionally wipe task/UI state"," theme <verb> Manage user themes (list|add|remove)",` skill <verb> Install the ${cliName} agent skill (install|status|command|print)`," plugin <verb> Install and run plugins (install|link|list|action|\u2026)"," feedback Send feedback to GitHub Discussions",` update [version|channel|list] Self-update ${cliName}, switch channel, or list versions`,"","Options:"," -v, --version Print version"," -h, --help Print this help"," --skill Print the agent skill file and exit"," --web [bridge flags] Serve the browser client on 127.0.0.1 and print its link"].join(`
7
7
  `)}var CLI_NAME=ROVE_PRODUCT_NAME,ADD_USAGE=[`Usage: ${CLI_NAME} add [path]`,` ${CLI_NAME} add --remote --host <host> --user <user> --path <basePath> [--port N] [--key [path] | --password]`,"","Save a repo for the new-task picker. With --remote, register an SSH-backed","project whose worktrees live on <host>; engine launch over SSH is pending.",""].join(`
8
- `);async function runAddSubcommand(rest){let arg=rest[0];if(arg==="--help"||arg==="-h"||arg==="help"){process.stdout.write(ADD_USAGE);return}if(arg==="--remote"){let{runAddRemote}=await import("./chunk-gcg5h667.js");await runAddRemote(rest.slice(1));return}if(arg?.startsWith("-"))process.stderr.write(`${CLI_NAME} add: unknown flag "${arg}"
8
+ `);async function runAddSubcommand(rest){let arg=rest[0];if(arg==="--help"||arg==="-h"||arg==="help"){process.stdout.write(ADD_USAGE);return}if(arg==="--remote"){let{runAddRemote}=await import("./chunk-awh7np6x.js");await runAddRemote(rest.slice(1));return}if(arg?.startsWith("-"))process.stderr.write(`${CLI_NAME} add: unknown flag "${arg}"
9
9
 
10
10
  ${ADD_USAGE}`),process.exit(2);let target=resolve2(process.cwd(),expandTilde(arg&&arg.length>0?arg:".")),{addSavedRepo}=await import("./chunk-hv79ys32.js"),result=addSavedRepo(target);if(result.rejected)process.stderr.write(`${CLI_NAME} add: "${arg&&arg.length>0?arg:"."}" cannot be a project \u2014 ${rejectionReason(result.rejected)} (resolved to ${result.path}).
11
11
  `),process.exit(1);if(result.added)console.log(`added ${result.path} (${result.total} saved repo${result.total===1?"":"s"} total)`);else console.log(`already saved: ${result.path}`);await ensureProjectMainTask(result.path),await adoptAllWorktrees(result.path)}async function ensureProjectMainTask(repo){try{await withDaemonOrLocal({daemon:(client)=>client.request("task.ensureMain",{repo}),local:(orch)=>orch.ensureMainTask(repo)})}catch(err){console.error(`(skipped project main-task setup: ${errorMessage(err)}). Run ${CLI_NAME} doctor, then retry ${CLI_NAME} add.`)}}var PURGE_FLAG="--purge-credentials",REMOVE_USAGE=[`Usage: ${CLI_NAME} remove [path] [--purge-credentials]`,"","Forget a saved project (drop it from the new-task picker). Non-destructive:","the repo's files, worktrees, branches and tasks all stay on disk. A remote","(ssh://) project also has its stored connection config dropped.",""," path defaults to the current directory. Pass an exact saved entry (e.g. a"," remote `ssh://user@host` key) to remove it verbatim. Run with no match to"," print the current saved projects.",""," --purge-credentials also delete the remote project's SSH password from"," the OS keychain. Off by default: forgetting a project"," should not silently destroy a stored secret.",""].join(`
@@ -26,4 +26,4 @@ ${ADOPT_USAGE}
26
26
  pass a path glob to adopt, e.g. ${CLI_NAME} adopt '${repo}/*' --yes`);return}let matched=worktrees.filter(isMatch);if(matched.length===0){console.log(`
27
27
  no worktrees match glob ${JSON.stringify(glob)}`);return}if(!yes){console.log(`
28
28
  ${matched.length} worktree(s) match \u2014 re-run with --yes to adopt them`);return}await adoptWorktreesInto(orch,repo,matched,vendor),console.log(`done \u2014 adopted ${matched.length} worktree(s)`)}function printTopLevelUsage(out){out.write(`${topLevelUsage()}
29
- `)}var COMMANDS=new Map([["add",runAddSubcommand],["remove",runRemoveSubcommand],["adopt",runAdoptSubcommand],...DYNAMIC_COMMANDS]);async function main(){let[,,...rawArgs]=process.argv,[subcommand,...rest]=rawArgs;if(subcommand==="--version"||subcommand==="-v"||subcommand==="version"){let{CURRENT_VERSION:CURRENT_VERSION2}=await import("./chunk-zxkjpfp5.js");console.log(`${CLI_NAME} ${CURRENT_VERSION2}`);return}if(subcommand==="--help"||subcommand==="-h"||subcommand==="help"){printTopLevelUsage(process.stdout);return}if(subcommand==="--skill"){let{runSkillSubcommand}=await import("./chunk-nf3kg9rz.js");await runSkillSubcommand(["print"]);return}if(subcommand==="--web"){let{runWebSubcommand}=await import("./chunk-63t3sh8c.js");await runWebSubcommand(rest);return}let handler=subcommand!==void 0?COMMANDS.get(subcommand):void 0;if(handler){await handler(rest);return}if(subcommand!==void 0&&isPathLikeArg(subcommand)){await runOpenDirectory(subcommand);return}if(subcommand!==void 0)console.error(`${CLI_NAME}: unknown command '${subcommand}'`),printTopLevelUsage(process.stderr),process.exit(2);let{publishRoveTerminalTitle}=await import("./chunk-g8wrdp7n.js");publishRoveTerminalTitle();let{launchTui}=await import("./chunk-80t9z2b2.js");await launchTui()}main().catch((err)=>{console.error(formatCliFailure(err,{cliName:CLI_NAME,argv:process.argv,cwd:process.cwd(),env:process.env})),process.exit(1)});
29
+ `)}var COMMANDS=new Map([["add",runAddSubcommand],["remove",runRemoveSubcommand],["adopt",runAdoptSubcommand],...DYNAMIC_COMMANDS]);async function main(){let[,,...rawArgs]=process.argv,[subcommand,...rest]=rawArgs;if(subcommand==="--version"||subcommand==="-v"||subcommand==="version"){let{CURRENT_VERSION:CURRENT_VERSION2}=await import("./chunk-x3n4y5sp.js");console.log(`${CLI_NAME} ${CURRENT_VERSION2}`);return}if(subcommand==="--help"||subcommand==="-h"||subcommand==="help"){printTopLevelUsage(process.stdout);return}if(subcommand==="--skill"){let{runSkillSubcommand}=await import("./chunk-ccwe9n56.js");await runSkillSubcommand(["print"]);return}if(subcommand==="--web"){let{runWebSubcommand}=await import("./chunk-8dd60adw.js");await runWebSubcommand(rest);return}let handler=subcommand!==void 0?COMMANDS.get(subcommand):void 0;if(handler){await handler(rest);return}if(subcommand!==void 0&&isPathLikeArg(subcommand)){await runOpenDirectory(subcommand);return}if(subcommand!==void 0)console.error(`${CLI_NAME}: unknown command '${subcommand}'`),printTopLevelUsage(process.stderr),process.exit(2);let{publishRoveTerminalTitle}=await import("./chunk-g8wrdp7n.js");publishRoveTerminalTitle();let{launchTui}=await import("./chunk-5e9y8aw5.js");await launchTui()}main().catch((err)=>{console.error(formatCliFailure(err,{cliName:CLI_NAME,argv:process.argv,cwd:process.cwd(),env:process.env})),process.exit(1)});