@sma1lboy/rove 0.9.304 → 0.9.305-next.430
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.
- package/dist/cli/{chunk-kyddm7xe.js → chunk-06vsvvtr.js} +1 -1
- package/dist/cli/{chunk-jkxn32nk.js → chunk-0s7j1xps.js} +1 -1
- package/dist/cli/{chunk-vk2xz0s4.js → chunk-19n8y9xp.js} +3 -3
- package/dist/cli/{chunk-qnkq7d8z.js → chunk-1bertmzz.js} +3 -3
- package/dist/cli/{chunk-gb2ahsfx.js → chunk-1et3gskx.js} +1 -1
- package/dist/cli/chunk-29e7x3qx.js +2 -0
- package/dist/cli/{chunk-sd6eae1h.js → chunk-2agspgfq.js} +1 -1
- package/dist/cli/{chunk-ga0kvz6j.js → chunk-2gpr5dm4.js} +1 -1
- package/dist/cli/{chunk-d4w91a02.js → chunk-2nddryb2.js} +1 -1
- package/dist/cli/{chunk-q6qmv2jq.js → chunk-37g0yabr.js} +1 -1
- package/dist/cli/{chunk-d3d06a4w.js → chunk-3da0g8md.js} +2 -2
- package/dist/cli/{chunk-mb2tfr2c.js → chunk-3jh1cfdj.js} +1 -1
- package/dist/cli/{chunk-j1rw5jdt.js → chunk-3t3fp5h4.js} +1 -1
- package/dist/cli/{chunk-tr9n297x.js → chunk-4nzf8w3e.js} +2 -2
- package/dist/cli/{chunk-am3vaamq.js → chunk-59ff10tt.js} +1 -1
- package/dist/cli/{chunk-hmfqyvet.js → chunk-5dv7pw3w.js} +2 -2
- package/dist/cli/{chunk-cmbd3s71.js → chunk-6azsw0ry.js} +5 -5
- package/dist/cli/{chunk-vpm8dfyg.js → chunk-6cggsxpr.js} +1 -1
- package/dist/cli/{chunk-p9an6jcq.js → chunk-6jxe4f13.js} +1 -1
- package/dist/cli/{chunk-b7bbnx1x.js → chunk-6wzb9c2x.js} +1 -1
- package/dist/cli/chunk-750rk2xz.js +16 -0
- package/dist/cli/chunk-7dah6dc9.js +2 -0
- package/dist/cli/{chunk-tzf7b25k.js → chunk-7ezpcrkf.js} +1 -1
- package/dist/cli/chunk-7gk8g1ae.js +2 -0
- package/dist/cli/{chunk-22syh28c.js → chunk-7yhekmvy.js} +1 -1
- package/dist/cli/{chunk-mdypt84n.js → chunk-8ag7qs90.js} +1 -1
- package/dist/cli/chunk-8nbvsger.js +2 -0
- package/dist/cli/{chunk-cb3krnqn.js → chunk-8wejvvsz.js} +1 -1
- package/dist/cli/{chunk-akygcre8.js → chunk-9892j1n1.js} +1 -1
- package/dist/cli/{chunk-wh147k4t.js → chunk-9b42t2wf.js} +1 -1
- package/dist/cli/{chunk-ammf7919.js → chunk-9tke0g8m.js} +1 -1
- package/dist/cli/chunk-a5pd9fk3.js +2 -0
- package/dist/cli/{chunk-x4gqyhhv.js → chunk-a6s52zm5.js} +1 -1
- package/dist/cli/{chunk-d4eav2xt.js → chunk-a8j2x5pf.js} +1 -1
- package/dist/cli/chunk-aejb41e3.js +2 -0
- package/dist/cli/{chunk-jx0sfc90.js → chunk-am70fwd0.js} +1 -1
- package/dist/cli/{chunk-gr9555d9.js → chunk-b7rxn7c9.js} +1 -1
- package/dist/cli/chunk-cs7m5f61.js +2 -0
- package/dist/cli/{chunk-s00wwj3a.js → chunk-cvcp1aye.js} +1 -1
- package/dist/cli/{chunk-76433s6v.js → chunk-d35ctfpd.js} +1 -1
- package/dist/cli/chunk-dab3kttb.js +2 -0
- package/dist/cli/{chunk-7w43ktng.js → chunk-ejs6dnxf.js} +1 -1
- package/dist/cli/{chunk-yebkeqj2.js → chunk-er4mc36m.js} +1 -1
- package/dist/cli/{chunk-sqcntdty.js → chunk-etz8f2ny.js} +1 -1
- package/dist/cli/{chunk-g770enx5.js → chunk-fmhnw1nz.js} +2 -2
- package/dist/cli/{chunk-689sfk7h.js → chunk-g70rcpsp.js} +1 -1
- package/dist/cli/{chunk-px91psgc.js → chunk-ga448pv8.js} +1 -1
- package/dist/cli/{chunk-5gw9f1zb.js → chunk-gafj4yp3.js} +4 -4
- package/dist/cli/{chunk-gdjaf50p.js → chunk-ggjg0h5c.js} +1 -1
- package/dist/cli/{chunk-wjz55sc3.js → chunk-gvs8sbp2.js} +1 -1
- package/dist/cli/{chunk-zc7e78mv.js → chunk-gz0x179r.js} +1 -1
- package/dist/cli/chunk-h2xantkm.js +2 -0
- package/dist/cli/{chunk-ytx7x3j8.js → chunk-hct98wxq.js} +1 -1
- package/dist/cli/{chunk-qjr63j9v.js → chunk-kvwneanp.js} +1 -1
- package/dist/cli/chunk-m5ddrj6q.js +2 -0
- package/dist/cli/{chunk-m6ekn4q8.js → chunk-mavyyarb.js} +1 -1
- package/dist/cli/{chunk-6y1jamqn.js → chunk-me70fpec.js} +1 -1
- package/dist/cli/{chunk-ykm19q7h.js → chunk-n15p38e5.js} +1 -1
- package/dist/cli/{chunk-2v2t1a03.js → chunk-nhsem71y.js} +1 -1
- package/dist/cli/{chunk-e04yypye.js → chunk-nyr8zxgd.js} +3 -3
- package/dist/cli/{chunk-q8b6gnc5.js → chunk-p4rhkv3k.js} +1 -1
- package/dist/cli/{chunk-x3c6f2sf.js → chunk-pf3nzz87.js} +1 -1
- package/dist/cli/{chunk-jb63kaer.js → chunk-qaznc1bg.js} +1 -1
- package/dist/cli/{chunk-633beahm.js → chunk-qwqa75g1.js} +1 -1
- package/dist/cli/{chunk-2h58p581.js → chunk-r8xt34nn.js} +1 -1
- package/dist/cli/chunk-ragdpajw.js +6 -0
- package/dist/cli/{chunk-bp3edwby.js → chunk-rnmj5c45.js} +1 -1
- package/dist/cli/{chunk-ahnv378z.js → chunk-s129kc10.js} +1 -1
- package/dist/cli/chunk-s2eezz0a.js +3 -0
- package/dist/cli/{chunk-sfskhmzp.js → chunk-s6wqbs6y.js} +1 -1
- package/dist/cli/{chunk-rz5sspn8.js → chunk-sffdpzfv.js} +1 -1
- package/dist/cli/{chunk-7zawz6sa.js → chunk-sggsdk9s.js} +11 -7
- package/dist/cli/{chunk-16sb3y82.js → chunk-t4reqv8m.js} +1 -1
- package/dist/cli/{chunk-q6q4aram.js → chunk-t7qj639x.js} +1 -1
- package/dist/cli/{chunk-emj5p5k7.js → chunk-t8gt3kq8.js} +1 -1
- package/dist/cli/{chunk-486j02v4.js → chunk-vat1vjkk.js} +1 -1
- package/dist/cli/{chunk-gd8gc37t.js → chunk-vd9670dy.js} +1 -1
- package/dist/cli/chunk-vjejmwzj.js +2 -0
- package/dist/cli/{chunk-rajwag3e.js → chunk-weah9492.js} +1 -1
- package/dist/cli/{chunk-mwbs7818.js → chunk-x5ybfyja.js} +1 -1
- package/dist/cli/{chunk-zpdvfb01.js → chunk-xj3034s1.js} +1 -1
- package/dist/cli/chunk-yk3we30f.js +2 -0
- package/dist/cli/chunk-yzz6vx5j.js +2 -0
- package/dist/cli/{chunk-7d22h7qg.js → chunk-z1fpd4k2.js} +1 -1
- package/dist/cli/{chunk-r9yx4k0q.js → chunk-zc67sqet.js} +1 -1
- package/dist/cli/{chunk-nmfcvtxk.js → chunk-zp4efbtb.js} +1 -1
- package/dist/cli/{chunk-2pc4wpm4.js → chunk-zqftyn6w.js} +1 -1
- package/dist/cli/{chunk-bznee97z.js → chunk-zze1pw22.js} +1 -1
- package/dist/cli/index.js +3 -3
- package/dist/cli/rove.js +3 -3
- package/dist/completions/rove.bash +1 -1
- package/dist/completions/rove.fish +1 -1
- package/dist/completions/rove.zsh +1 -1
- package/dist/web/assets/{index-D9TLg2oV.js → index-7xgjby6F.js} +3 -3
- package/dist/web/assets/{term-mount-Cn86hde_.js → term-mount-OMVJnrk8.js} +1 -1
- package/dist/web/index.html +1 -1
- package/package.json +1 -1
- package/dist/cli/chunk-0qxqk8cr.js +0 -2
- package/dist/cli/chunk-0r64dqy3.js +0 -3
- package/dist/cli/chunk-1fw86kg2.js +0 -2
- package/dist/cli/chunk-1w2dx91w.js +0 -2
- package/dist/cli/chunk-2ze5ss4k.js +0 -2
- package/dist/cli/chunk-46zqt24x.js +0 -2
- package/dist/cli/chunk-8647s43m.js +0 -2
- package/dist/cli/chunk-96jqrzcp.js +0 -2
- package/dist/cli/chunk-czyyrxmf.js +0 -2
- package/dist/cli/chunk-d9e1vx7y.js +0 -15
- package/dist/cli/chunk-fg7kv30n.js +0 -2
- package/dist/cli/chunk-gpmpv5gw.js +0 -2
- package/dist/cli/chunk-pe92nt86.js +0 -4
- package/dist/cli/chunk-scb1g3zf.js +0 -2
- package/dist/cli/chunk-vy5ja578.js +0 -2
- package/dist/cli/chunk-xrg2tc6p.js +0 -2
- package/dist/cli/chunk-zshgx9fp.js +0 -6
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{interactiveEngineCommand,listPresetIds}from"./chunk-
|
|
2
|
+
import{interactiveEngineCommand,listPresetIds}from"./chunk-gz0x179r.js";import{resolveSessionShell}from"./chunk-tn9gtf18.js";import{engineEntry}from"./chunk-5dv7pw3w.js";import{installedEngineIds}from"./chunk-2bapg0v2.js";import{spawn,spawnSync}from"child_process";import{statSync}from"fs";import path from"path";function whichOnPath(bin){let bunWhich=globalThis.Bun?.which;if(bunWhich)return bunWhich(bin);let out=spawnSync(process.platform==="win32"?"where":"which",[bin],{encoding:"utf8"});if(out.status!==0)return null;return out.stdout.split(`
|
|
3
3
|
`).map((l)=>l.trim()).find(Boolean)??null}var LOGIN_PROBE_MS=5000,MARK="__rove_which__";function whichInLoginShell(bin){return new Promise((resolve)=>{let out="",child;try{let quoted=`'${bin.replaceAll("'","'\\''")}'`;child=spawn(resolveSessionShell(),["-ilc",`printf '\\n${MARK}%s\\n' "$(command -v ${quoted})"`],{stdio:["ignore","pipe","ignore"],detached:!0})}catch{return resolve(null)}let timer=setTimeout(()=>child.kill("SIGKILL"),LOGIN_PROBE_MS);child.stdout?.on("data",(b)=>{out+=b.toString()}),child.on("error",()=>{clearTimeout(timer),resolve(null)}),child.on("close",()=>{clearTimeout(timer);let line=out.split(`
|
|
4
4
|
`).find((l)=>l.startsWith(MARK));resolve(line?.slice(MARK.length).trim()||null)})})}var defaultDeps={which:(bin)=>whichOnPath(bin)??(process.platform==="win32"?null:whichInLoginShell(bin)),command:(vendor)=>interactiveEngineCommand(vendor)};async function probeLaunchBinary(argv,which){let bin=argv[0]?.trim();if(!bin)return{found:!1,error:"no launch command"};if(bin.includes(path.sep)||bin.startsWith(".")){try{if(statSync(bin).isFile())return{found:!0,path:bin}}catch{}return{found:!1,error:`not found at ${bin}`}}let found=await which(bin);return found?{found:!0,path:found}:{found:!1,error:"not found on PATH"}}async function detectEngineStatus(vendor,over={}){let deps={...defaultDeps,...over},detector=engineEntry(vendor).detectAccount;if(!detector)return{vendor,binary:await probeLaunchBinary(deps.command(vendor),deps.which),account:null};let status=await detector(deps.accountDeps),binary=status.binary.found?status.binary:await probeLaunchBinary(deps.command(vendor),deps.which);return{vendor,binary,account:status.account,accountError:status.accountError}}function detectEngineStatuses(vendors,over={}){return Promise.all(vendors.map((v)=>detectEngineStatus(v,over)))}function describeAccount(account){if(account===null)return"login not detectable";switch(account.kind){case"oauth":return"email"in account?`logged in (${account.email}${account.organization?`, ${account.organization}`:""})`:"logged in";case"chatgpt":return`logged in (${account.email}${account.plan?`, ${account.plan}`:""})`;case"apikey":return"API key";case"token":return`token (${account.source})`;default:return"no account"}}function engineUsable(status){return status.binary.found&&status.account?.kind!=="none"}async function probeableEngineIds(){return[...new Set([...listPresetIds(),...await installedEngineIds()])]}function summarizeEngines(statuses){let usable=[],signedOut=[];for(let status of statuses)if(engineUsable(status))usable.push(status.vendor);else if(status.binary.found)signedOut.push(status.vendor);return{usable,signedOut}}import{spawn as spawn2}from"child_process";import path2 from"path";var VERSION_PROBE_MS=3000,MAX_OUTPUT=4096;function parseVersionOutput(output){return/\b\d+(?:\.\d+)+(?:-[0-9A-Za-z.]+)?\b/.exec(output)?.[0]??null}var runVersionCommand=(bin,args)=>new Promise((resolve)=>{let out="",child;try{child=spawn2(bin,[...args],{stdio:["ignore","pipe","ignore"]})}catch{return resolve(null)}let timer=setTimeout(()=>child.kill("SIGKILL"),VERSION_PROBE_MS);child.stdout?.on("data",(b)=>{if(out.length<MAX_OUTPUT)out+=b.toString()}),child.on("error",()=>{clearTimeout(timer),resolve(null)}),child.on("close",(code)=>{clearTimeout(timer),resolve(code===0?out:null)})});async function readEngineVersion(vendor,binary,run=runVersionCommand){if(!binary.found)return null;let entry=engineEntry(vendor),own=entry.defaultCommand[0];if(!entry.versionArgs||!own)return null;if(path2.basename(binary.path)!==path2.basename(own))return null;let output=await run(binary.path,entry.versionArgs).catch(()=>null);return output===null?null:parseVersionOutput(output)}function withEngineVersions(statuses,run=runVersionCommand){return Promise.all(statuses.map(async(status)=>{let version=await readEngineVersion(status.vendor,status.binary,run);return version?{...status,version}:status}))}
|
|
5
5
|
export{detectEngineStatus,detectEngineStatuses,describeAccount,probeableEngineIds,summarizeEngines,readEngineVersion,withEngineVersions};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var TOP_LEVEL_SUBCOMMANDS=["completions","add","remove","adopt","export","repo","api","daemon","machine","weixin","doctor","config","reset","theme","skill","plugin","feedback","update"],SUBCOMMAND_VERBS={daemon:["status","start","stop","restart","relay","autostart"],machine:["add","doctor","update","remove","list","tunnel","inbound","primary"],plugin:["install","link","list","search","outdated","update","enable","disable","unlink","uninstall","config-dir","log","action","pane"],repo:["show","set","unset"],skill:["install","status","print"],theme:["list","add","remove"],weixin:["login","logout","status","allow","deny","send","agent"]};
|
|
2
|
+
var TOP_LEVEL_SUBCOMMANDS=["completions","add","remove","adopt","export","repo","api","daemon","machine","weixin","doctor","config","reset","theme","skill","plugin","feedback","update"],SUBCOMMAND_VERBS={daemon:["status","start","stop","restart","relay","autostart"],machine:["add","doctor","update","remove","list","tunnel","inbound","primary","mcp"],plugin:["install","link","list","search","outdated","update","enable","disable","unlink","uninstall","config-dir","log","action","pane"],repo:["show","set","unset"],skill:["install","status","print"],theme:["list","add","remove"],weixin:["login","logout","status","allow","deny","send","agent"]};
|
|
3
3
|
export{TOP_LEVEL_SUBCOMMANDS,SUBCOMMAND_VERBS};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{BREAKING_VERSIONS,CURRENT_VERSION,PACKAGE_NAME,UPDATE_COMMAND,UPDATE_SCRIPT_URL,ZH_NOTES_ASSET,breakingVersionsCrossed,channelOf,checkLatestVersion,compareSemver,fetchReleaseNotes,fetchReleaseNotesRange,fetchReleaseSummaries,isNewerSemver,owningNpmPrefix,recommendedGlobalInstallCommand,releasePageUrl,repoSlug,updateCommandFor}from"./chunk-
|
|
2
|
+
import{BREAKING_VERSIONS,CURRENT_VERSION,PACKAGE_NAME,UPDATE_COMMAND,UPDATE_SCRIPT_URL,ZH_NOTES_ASSET,breakingVersionsCrossed,channelOf,checkLatestVersion,compareSemver,fetchReleaseNotes,fetchReleaseNotesRange,fetchReleaseSummaries,isNewerSemver,owningNpmPrefix,recommendedGlobalInstallCommand,releasePageUrl,repoSlug,updateCommandFor}from"./chunk-s2eezz0a.js";import"./chunk-8143k3t6.js";import"./chunk-zt7wfnva.js";import"./chunk-g6wb8p4p.js";import"./chunk-nc46gddg.js";import"./chunk-91sykzqq.js";export{updateCommandFor,repoSlug,releasePageUrl,recommendedGlobalInstallCommand,owningNpmPrefix,isNewerSemver,fetchReleaseSummaries,fetchReleaseNotesRange,fetchReleaseNotes,compareSemver,checkLatestVersion,channelOf,breakingVersionsCrossed,ZH_NOTES_ASSET,UPDATE_SCRIPT_URL,UPDATE_COMMAND,PACKAGE_NAME,CURRENT_VERSION,BREAKING_VERSIONS};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{SSH_SHELL_IS_CMD,SSH_SHELL_PROBE,isWindowsPath,windowsRshScript,windowsRxScript}from"./chunk-cw9h73h5.js";import{getMachine,machineSshArgs}from"./chunk-37g0yabr.js";import{runAsync}from"./chunk-nw48bskt.js";import{quoteShellArg,quoteShellArgv}from"./chunk-7kysxgbq.js";import{pathWithin}from"./chunk-pn5ygqn6.js";import{homeDir}from"./chunk-8143k3t6.js";import{spawnSync}from"child_process";import{createHash}from"crypto";function forwardedServerName(name,machine){return`${name}-${machine}`.replace(/[^A-Za-z0-9_-]/g,"_")}function forwardPort(machine,host,port){return 20000+createHash("sha256").update(`${machine}\x00${host}:${port}`).digest().readUInt32BE(0)%40000}function forwardedMcp(machine,servers){return servers.flatMap((entry)=>{let url;try{url=new URL(entry.url)}catch{return[]}if(url.protocol!=="http:"&&url.protocol!=="https:")return[];let port=Number(url.port)||(url.protocol==="https:"?443:80),host=url.hostname,local=forwardPort(machine,host,port),here=new URL(url);return here.hostname="127.0.0.1",here.port=String(local),[{server:forwardedServerName(entry.name,machine),url:here.toString(),target:{host,port},port:local}]})}function machineMcp(machine){return forwardedMcp(machine,getMachine(machine)?.mcp??[])}function ensureMcpForwards(machine,forwards){let config=getMachine(machine);if(!config||forwards.length===0)return config?[]:[...forwards];let base=machineSshArgs(machine,config),flags=base.slice(1,-1),target=base.at(-1)??machine,ssh=(args,timeout)=>spawnSync(base[0]??"ssh",[...flags,...args,target],{stdio:"ignore",timeout}).status===0;if(!(ssh(["-O","check"],5000)||spawnSync(base[0]??"ssh",[...base.slice(1),"exit"],{stdio:"ignore",timeout:30000}).status===0))return[...forwards];return forwards.filter((fwd)=>!ssh(["-O","forward","-L",`127.0.0.1:${fwd.port}:${fwd.target.host}:${fwd.target.port}`],1e4))}import{chmodSync,existsSync as existsSync2,mkdirSync,readFileSync as readFileSync2,rmSync,rmdirSync,writeFileSync}from"fs";import{basename,dirname,join as join2}from"path";import{spawnSync as spawnSync2}from"child_process";import{existsSync,readFileSync}from"fs";import{join}from"path";function normalizeRemoteUrl(url){let u=url.trim();return u=u.replace(/^[a-z+]+:\/\//i,""),u=u.replace(/^[^@/]+@/,""),u=u.replace(/^([^/:]+):(?!\d+\/)/,"$1/"),u=u.replace(/^([^/:]+):\d+\//,"$1/"),u=u.replace(/\/+$/,"").replace(/\.git$/i,""),u=u.replace(/^ssh\.github\.com\//i,"github.com/"),u.toLowerCase()}function git(cwd,args){let res=spawnSync2("git",["-C",cwd,...args],{encoding:"utf8",timeout:5000,windowsHide:!0});return res.status===0?res.stdout.trim():null}var REMOTE_WORKSPACE_FILE=".rove-remote.json";function readLink(path){try{return JSON.parse(readFileSync(join(path,REMOTE_WORKSPACE_FILE),"utf8"))}catch{return}}function linkedRepoId(path){let id=readLink(path)?.repoId;return typeof id==="string"&&id?id:void 0}function linkedWorkspace(path){let link=readLink(path);return typeof link?.machine==="string"&&typeof link.path==="string"?{machine:link.machine,path:link.path}:void 0}function computeRepoId(path){let linked=linkedRepoId(path);if(linked)return linked;let origin=git(path,["remote","get-url","origin"]);if(origin)return normalizeRemoteUrl(origin);let root=git(path,["rev-list","--max-parents=0","HEAD"])?.split(`
|
|
3
|
+
`).filter(Boolean).sort()[0];return root?`root:${root}`:void 0}var memo=new Map,NO_ID_TTL_MS=30000;function repoIdOf(path,now=Date.now()){if(!path)return;let hit=memo.get(path);if(hit&&(hit.id!==void 0||now-hit.at<NO_ID_TTL_MS))return hit.id;if(!existsSync(path))return;let id=computeRepoId(path);return memo.set(path,{id,at:now}),id}function remoteWorkspacesRoot(home=homeDir()){return join2(home,".rove","remote-workspaces")}function remoteWorkspaceDir(machine,taskId,name,home=homeDir()){return join2(remoteWorkspacesRoot(home),taskId,machine,basename(name.replaceAll("\\","/"))||"workspace")}function readRemoteWorkspace(dir){try{let raw=JSON.parse(readFileSync2(join2(dir,REMOTE_WORKSPACE_FILE),"utf8"));if(typeof raw.machine!=="string"||typeof raw.taskId!=="string"||typeof raw.path!=="string")return null;return{machine:raw.machine,taskId:raw.taskId,path:raw.path,...typeof raw.branch==="string"?{branch:raw.branch}:{},...typeof raw.repoId==="string"?{repoId:raw.repoId}:{}}}catch{return null}}var isRemoteWorkspace=(dir)=>existsSync2(join2(dir,REMOTE_WORKSPACE_FILE)),remoteBinDir=(dir)=>join2(dir,"bin"),rxPath=(dir)=>join2(remoteBinDir(dir),"rx"),SED_QUOTE=`sed "s/'/'\\\\\\\\''/g"`;function rxScript(sshArgv,path){return["#!/bin/sh","# Rove: run one command in this task's workspace on another machine.",`dir=${quoteShellArg(path)}`,`d=$(printf '%s' "$dir" | ${SED_QUOTE})`,`c=$(printf '%s' "$1" | ${SED_QUOTE})`,`exec ${quoteShellArgv(sshArgv)} "cd '$d' && exec \\"\\\${SHELL:-sh}\\" -lc '$c'"`,""].join(`
|
|
4
|
+
`)}function rshScript(sshArgv,path){let[ssh="ssh",...rest]=sshArgv;return["#!/bin/sh","# Rove: open a shell in this task's workspace on another machine.",`dir=${quoteShellArg(path)}`,`d=$(printf '%s' "$dir" | ${SED_QUOTE})`,`exec ${quoteShellArgv([ssh,"-t",...rest])} "cd '$d' && exec \\"\\\${SHELL:-sh}\\" -l"`,""].join(`
|
|
5
|
+
`)}var rshPath=(dir)=>join2(remoteBinDir(dir),"rsh");function remoteShellInput(dir){return existsSync2(rshPath(dir))?` exec ${quoteShellArg(rshPath(dir))}\r`:""}function linkedWorktree(dir){let ws=dir?readRemoteWorkspace(dir):null;return ws?{machine:ws.machine,taskId:ws.taskId}:void 0}function remoteNotes(ws){return["# This project lives on another machine","",`The project is not in this directory. It is on ${`the machine "${ws.machine}"${ws.system?` (${ws.system})`:""}`}, at \`${ws.path}\`. This directory only links to it.`,"","- Run every command as `rx '<command>'`. It runs in the project root there and passes stdin, output and the exit code through: `rx 'git status'`, `rx 'cat > src/a.ts' <<'EOF'`.","- Each `rx` call starts in the project root; a `cd` does not carry over to the next call.","- Read, search and edit the project's files through commands there. File tools that work on local paths only see this directory.","- git, tests and builds all run there. Nothing of the project is on this machine.",...whereThingsRun(ws,"- Run `rove` without `rx`: Rove and your task are on this machine, so `rove api \u2026` reaches this Rove and takes this machine's paths."),""].join(`
|
|
6
|
+
`)}function whereThingsRun(ws,roveLine){let forwarded=ws.mcp??[];return["","## Which machine runs what","",roveLine,`- Your MCP tools${forwarded.length>0?" not listed below":""}, a browser among them, run on this machine, so \`localhost\` in them is this machine, not the project's.`,forwarded.length>0?`- These MCP servers are ${ws.machine}'s, forwarded here: ${forwarded.map((s)=>`\`${s}\``).join(", ")}. A page served on ${ws.machine} (a dev server you started there) opens in its browser at ${ws.machine}'s own \`localhost\` address; use them for that.`:`- A page served on ${ws.machine} is not at this machine's \`localhost\`. To open it in ${ws.machine}'s own browser, the owner can forward that machine's browser MCP server: \`rove machine mcp ${ws.machine} <name> <url>\`; it shows up in new sessions as \`<name>-${ws.machine}\`.`]}function projectInstructions(text){return text.trim()?`
|
|
7
|
+
# The project's own instructions
|
|
8
|
+
|
|
9
|
+
${text.trim()}
|
|
10
|
+
`:""}var MARK="@@rove-workspace@@";async function createRemoteLink(input,home=homeDir()){let{ws}=input,dir=remoteWorkspaceDir(ws.machine,ws.taskId,input.repo,home);if(mkdirSync(remoteBinDir(dir),{recursive:!0}),writeFileSync(join2(dir,REMOTE_WORKSPACE_FILE),`${JSON.stringify(ws,null,2)}
|
|
11
|
+
`),isWindowsPath(ws.path)){let shell=await runAsync(input.sshArgv[0]??"ssh",[...input.sshArgv.slice(1),SSH_SHELL_PROBE],{timeoutMs:30000});writeFileSync(rxPath(dir),windowsRxScript(input.sshArgv,ws.path,SSH_SHELL_IS_CMD.test(shell.stdout))),writeFileSync(rshPath(dir),windowsRshScript(input.sshArgv,ws.path))}else writeFileSync(rxPath(dir),rxScript(input.sshArgv,ws.path)),writeFileSync(rshPath(dir),rshScript(input.sshArgv,ws.path));chmodSync(rxPath(dir),493),chmodSync(rshPath(dir),493);let probe=await runAsync(rxPath(dir),[`uname -sm; echo ${MARK}; cat AGENTS.md 2>/dev/null || cat CLAUDE.md 2>/dev/null`],{timeoutMs:30000});if(!probe.ok&&!probe.stdout.includes(MARK))throw removeRemoteLink(dir,home),Error(`${ws.machine} did not answer at ${ws.path}: ${(probe.stderr||"ssh failed").trim()}`);let[system="",...rest]=probe.stdout.split(`
|
|
12
|
+
${MARK}
|
|
13
|
+
`),note={...ws,system:system.trim(),...input.mcp?.length?{mcp:input.mcp}:{}},project=projectInstructions(rest.join(`
|
|
14
|
+
${MARK}
|
|
15
|
+
`));writeFileSync(join2(dir,"AGENTS.md"),remoteNotes(note)+project);for(let notes of input.engineNotes)writeFileSync(join2(dir,notes.file),notes.text(note)+project);return dir}function removeRemoteLink(dir,home=homeDir()){if(!pathWithin(remoteWorkspacesRoot(home),dir)||!isRemoteWorkspace(dir))return;rmSync(dir,{recursive:!0,force:!0});for(let parent of[dirname(dir),dirname(dirname(dir))])try{rmdirSync(parent)}catch{}}
|
|
16
|
+
export{forwardedMcp,machineMcp,ensureMcpForwards,normalizeRemoteUrl,linkedWorkspace,repoIdOf,readRemoteWorkspace,isRemoteWorkspace,remoteBinDir,rxPath,remoteShellInput,linkedWorktree,whereThingsRun,createRemoteLink,removeRemoteLink};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{NoopHookAdapter,activityHookAdapters,createEngineHookAdapter}from"./chunk-5dv7pw3w.js";import"./chunk-2bapg0v2.js";import"./chunk-750rk2xz.js";import"./chunk-w7zv47mp.js";import"./chunk-cw9h73h5.js";import"./chunk-37g0yabr.js";import"./chunk-nw48bskt.js";import"./chunk-k7tdg6kb.js";import"./chunk-1pmzr8kr.js";import"./chunk-e5jxbd98.js";import"./chunk-84q9hv7m.js";import"./chunk-96kvwzj8.js";import"./chunk-07665jz6.js";import"./chunk-40dgv828.js";import"./chunk-9gctbddn.js";import"./chunk-mg1cas61.js";import"./chunk-yvg46jh9.js";import"./chunk-xasg8z9e.js";import"./chunk-j152pk57.js";import"./chunk-c4dfktv2.js";import"./chunk-bdmbevk8.js";import"./chunk-7kysxgbq.js";import"./chunk-g755p68b.js";import"./chunk-tcmzq86w.js";import"./chunk-y8hjgmn0.js";import"./chunk-xy8be792.js";import"./chunk-h2m7em1e.js";import"./chunk-pn5ygqn6.js";import"./chunk-7ghwdjdc.js";import"./chunk-m5nd44st.js";import"./chunk-rxb0hw1e.js";import"./chunk-tw25g9g5.js";import"./chunk-yt15y085.js";import"./chunk-2z2jwetd.js";import"./chunk-8143k3t6.js";import"./chunk-zt7wfnva.js";import"./chunk-g6wb8p4p.js";import"./chunk-nc46gddg.js";import"./chunk-91sykzqq.js";export{createEngineHookAdapter,activityHookAdapters,NoopHookAdapter};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{canonPath,normalizeMainRepo,randomDirTaskSuffix,repoWorkingDir,samePrStatus,titleFromRepo}from"./chunk-nmfcvtxk.js";import{isUnlistedCheckout}from"./chunk-n8z4nb8v.js";import{CLONEFILEAT_PERL,GitWorktreeManager,defaultExecDeps,git,headCommit,isDirtyOutput,parseDirtyPaths}from"./chunk-a5ehejp6.js";import{readLastActiveTaskId,writeLastActiveTaskId}from"./chunk-ak0ezn5t.js";import{LAUNCH_PREFIX_FILE}from"./chunk-4dt1gfb3.js";import{PLACEHOLDER_TASK_TITLE,isPlaceholderDerivedBranch,sanitizeTaskTitle}from"./chunk-2xsxcdp6.js";import{DirtyWorktreeError,EmptyBranchDirtyWorktreeError,EmptyBranchError,ExtraRepoNotGitError,ForkUnsupportedError,GitCommandFailedError,IllegalTransitionError,InvalidWorktreeNameError,LandConflictError,MainCheckoutDirtyError,MissingRefError,MoveRefusedError,NotAGitRepoError,NotALinkedRepoError,REMOTE_PARENT_UNSUPPORTED_CODE,RemoteExtraUnsupportedError,RemoteParentUnsupportedError,ReparentRefusedError,RepoDuplicateError,TaskDeletingError,TaskNotFoundError,TooManyReposError,WorktreeNameTakenError,WorktreeRemoveFailedError,canonicalize,listWorktreeDirNames,worktreePathFor}from"./chunk-79wejcs5.js";import{forwardVerb,requireMachine}from"./chunk-r9yx4k0q.js";import{resolvePreferredVendor}from"./chunk-2x6s7z8w.js";import{READ_ONLY_GIT_ENV}from"./chunk-6xppe9bj.js";import{readRemoteWorkspace,removeRemoteLink}from"./chunk-d9e1vx7y.js";import{detectLanguage}from"./chunk-133c884f.js";import{addSavedRepo,getPersistedString,isGitRepo,isRemoteRepoKey,removeSavedRepo,resolveMainRepoRoot,resolveRepoRoot,storedRepos}from"./chunk-07665jz6.js";import{errorMessage}from"./chunk-9gctbddn.js";import{projectRejection,rejectionReason}from"./chunk-mg1cas61.js";import{createStateCell}from"./chunk-cmp64q4j.js";import{MULTI_REPO_CAP,SESSION_PR_CAP,WORKSPACE_CAPABILITIES,applyTodoOps,checkNotes,childrenOf,deletionTargets,gitRepoOf,lineageRootId,pickRepos,repoNameOf,subtreeIds,taskCwd,taskRepos,taskWorktreePaths,uniqueRepoName,workspaceBackendId,workspaceCapabilities}from"./chunk-tcmzq86w.js";import{DEFAULT_TASK_VENDOR,toTaskId}from"./chunk-xy8be792.js";import{pathWithin,samePath}from"./chunk-pn5ygqn6.js";class WorkspaceCheckpoints{store;worktrees;workspaces;requireTask;constructor(store,worktrees,workspaces,requireTask){this.store=store;this.worktrees=worktrees;this.workspaces=workspaces;this.requireTask=requireTask}workspaceOwner(id){let task=this.requireTask(id);return(task.sharesWorkspaceOf?this.store.get(task.sharesWorkspaceOf):void 0)??task}checkpointScope(id){let owner=this.workspaceOwner(id),sharers=this.store.list().filter((t)=>t.sharesWorkspaceOf===owner.id&&!t.deletion);return{ownerId:String(owner.id),sharerIds:[String(owner.id),...sharers.map((t)=>String(t.id))]}}canCheckpoint(id){if(!this.store.get(id))return!1;let owner=this.workspaceOwner(id);return workspaceCapabilities(owner).checkpoint&&!owner.deletion&&owner.worktreePath!==""}async target(id){let owner=this.workspaceOwner(id),own=this.canCheckpoint(id)?this.workspaces.get(workspaceBackendId(owner)).checkpoints:void 0,dir=owner.worktreePath;if(!this.canCheckpoint(id)||!await this.worktrees.pathExists(own?dir:`${dir}/.git`))throw Error(`NOT_CHECKPOINTABLE: ${owner.kind==="task"?"the task has no workspace on disk":`a ${owner.kind} task works in your own checkout`}`);let ownerId=String(owner.id);return{ownerId,dir,via:own??{take:(d,opts)=>this.worktrees.takeCheckpoint(d,ownerId,opts),list:(d)=>this.worktrees.listCheckpoints(d,ownerId),rewind:(d,n)=>this.worktrees.rewindToCheckpoint(d,ownerId,n)}}}async takeCheckpoint(id,opts){let{dir,via}=await this.target(id);return via.take(dir,opts)}async listCheckpoints(id){let{dir,via}=await this.target(id);return via.list(dir)}async rewindToCheckpoint(id,n){let{dir,via}=await this.target(id);return via.rewind(dir,n)}async exportBranch(id){let owner=this.workspaceOwner(id),backend=this.workspaces.get(workspaceBackendId(owner));if(!backend.exportBranch||!owner.worktreePath)throw Error("EXPORT_UNSUPPORTED: the task's branch is already in its repo (or it has no workspace yet)");return backend.exportBranch({path:owner.worktreePath,repo:gitRepoOf(owner),branch:owner.branch})}}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()}`}function planExtraRepos(primary,inputs){if(inputs.length===0)return[];if(1+inputs.length>MULTI_REPO_CAP)throw new TooManyReposError(1+inputs.length,MULTI_REPO_CAP);if(isRemoteRepoKey(primary))throw new RemoteExtraUnsupportedError(primary);let seen=new Set([canonPath(primary)]),names=new Set([repoNameOf(primary)]);return inputs.map((input)=>{if(isRemoteRepoKey(input.repo))throw new RemoteExtraUnsupportedError(input.repo);let{repo}=normalizeMainRepo(input.repo);if(!isGitRepo(repo))throw new ExtraRepoNotGitError(input.repo);if(seen.has(canonPath(repo)))throw new RepoDuplicateError(repo);seen.add(canonPath(repo));let name=uniqueRepoName(repoNameOf(repo),names);names.add(name);let baseRef=input.baseRef?.trim();return{name,repo,branch:"",worktreePath:"",...baseRef?{baseRef}:{}}})}async function rollbackWorktree(backend,created){try{await backend.dispose({path:created.path,...created.fresh},created.fresh?{force:!0,deleteBranch:!0}:{force:!0})}catch(err){console.error(`[rove] ensureWorktree rollback failed for ${created.path}:`,err)}}async function extrasToMaterialise(worktrees,extras){let missing=[];for(let extra of extras??[])if(!extra.worktreePath||!await worktrees.pathExists(extra.worktreePath))missing.push(extra);return missing}function scaleProgress(onProgress,step,total){return onProgress&&((percent)=>onProgress(Math.floor((step+percent/100)/total*100)))}async function materialiseExtras(opts){let{worktrees,backend,slugs,task}=opts,callerNamed=task.branch!=="",created=[],picked=[],done=new Map,missing=await extrasToMaterialise(worktrees,task.extraRepos);try{for(let[index,extra]of missing.entries()){if(extra.worktreePath)await worktrees.pruneWorktrees(extra.repo);let names=await worktrees.listBranchNames(extra.repo),branch=extra.branch||(callerNamed||!names.includes(opts.branch)?opts.branch:uniqueBranchName(opts.branch,new Set(names),task.id)),slug=await slugs.allocate(extra.repo);picked.push({repo:extra.repo,slug});let info=await backend.materialize({repo:extra.repo,slug,branch,baseRef:extra.baseRef,onProgress:opts.progressFor(index)});created.push({path:info.path,...names.includes(branch)?{}:{fresh:{repo:extra.repo,branch}}}),done.set(extra.name,{...extra,branch,worktreePath:info.path})}}catch(err){for(let wt of created.reverse())await rollbackWorktree(backend,wt);for(let{repo,slug}of picked)slugs.cancel(repo,slug);throw err}return{extraRepos:(task.extraRepos??[]).map((e)=>done.get(e.name)??e),created,slugs:picked}}function nestingParent(store,id){let parent=store.get(id);if(!parent)throw new TaskNotFoundError(id);if(parent.deletion)throw new TaskDeletingError(String(parent.id));if(isRemoteRepoKey(parent.repo))throw new RemoteParentUnsupportedError(String(parent.id));return toTaskId(lineageRootId(store.list(),parent.id))}async function createTaskRow(deps,input){if(!input.repo)throw Error("createTask: repo is required");let extraRepos=planExtraRepos(normalizeMainRepo(input.repo).repo,input.extraRepos??[]),parentTaskId=input.parentTaskId?nestingParent(deps.store,input.parentTaskId):void 0,repo=deps.projects.ensureIfEligible(input.repo,input.projectIntent??"explicit")??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}:{},...parentTaskId?{parentTaskId}:{},...input.worktreeOnly?{worktreeOnly:!0}:{},...input.cwdSubpath?{cwdSubpath:input.cwdSubpath}:{},...input.routine?{routine:input.routine}:{},...input.baseRef?.trim()?{baseRef:input.baseRef.trim()}:{},...extraRepos.length>0?{extraRepos}:{},...input.workspace?{workspace:input.workspace}:{},...worktreeName?{worktreeName}:{}})}async function openDirectoryTaskRow(deps,input){if(!input.dir)throw Error("openDirectoryTask: dir is required");let remote=isRemoteRepoKey(input.dir),dir=remote?input.dir:canonPath(input.dir),title=(input.title?sanitizeTaskTitle(input.title):"")||(input.scratch?"":`${titleFromRepo(dir)}-${randomDirTaskSuffix()}`);return deps.store.create({repo:dir,title,branch:"",worktreePath:remote?repoWorkingDir(dir):dir,status:"backlog",kind:"dir",...input.scratch?{scratch:!0}:{},...input.noProject?{noProject:!0}:{},...input.routine?{routine:input.routine}:{},...input.workspace?{workspace:input.workspace}:{},...input.modelEffort?{modelEffort:input.modelEffort}:{},...input.model?.trim()?{model:input.model.trim()}:{},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)})}class BorrowedBackend{id="borrowed";capabilities=WORKSPACE_CAPABILITIES.borrowed;async materialize(spec){return{backend:this.id,path:spec.path??repoWorkingDir(spec.repo)}}async dispose(){}}import{execFile}from"child_process";import{promises as fs,statSync}from"fs";import path from"path";import{promisify}from"util";var run=promisify(execFile),CP_CHUNK=200;function cloneFlags(){if(process.platform==="darwin")return["-c","-R","-P"];if(process.platform==="linux")return["--reflink=always","-a"];return null}var cpClone=async(entries,to)=>{let flags=cloneFlags();if(!flags)throw new ForkUnsupportedError(`copy-on-write clones are not supported on ${process.platform}`);for(let i=0;i<entries.length;i+=CP_CHUNK)try{await run("cp",[...flags,...entries.slice(i,i+CP_CHUNK),`${to}${path.sep}`])}catch(err){let detail=err.stderr?.trim()||String(err);throw Error(`cloning the worktree failed: ${detail}`)}},probeCache=new Map;async function cloneOneFile(source,target){if(process.platform==="darwin")await run("/usr/bin/perl",["-e",CLONEFILEAT_PERL,source,target]);else if(process.platform==="linux")await run("cp",["--reflink=always",source,target]);else throw Error(`no clone primitive on ${process.platform}`)}var volumeProbe=(from,toDir)=>{let key=`${statSync(from).dev}:${statSync(toDir).dev}`,known=probeCache.get(key);if(!known)known=(async()=>{let probe=path.join(toDir,`.rove-clone-probe-${process.pid}`);try{return await cloneOneFile(path.join(from,".git"),probe),!0}catch{return!1}finally{await fs.rm(probe,{force:!0})}})(),probeCache.set(key,known);return known};async function git2(cwd,args){let{stdout}=await run("git",[...args],{cwd,maxBuffer:67108864});return stdout.trim()}class CowCloneBackend{plain;id="cow-clone";capabilities=WORKSPACE_CAPABILITIES["cow-clone"];probe;cloneEntries;constructor(plain,deps={}){this.plain=plain;this.probe=deps.probe??volumeProbe,this.cloneEntries=deps.cloneEntries??cpClone}async materialize(spec){let parent=spec.forkFrom;if(!parent)return{...await this.plain.materialize(spec),backend:this.id};if(isRemoteRepoKey(spec.repo))throw new ForkUnsupportedError("a remote project's worktree cannot be cloned");let target=worktreePathFor(spec.repo,spec.slug),root=path.dirname(target);if(await fs.mkdir(root,{recursive:!0}),!await this.probe(parent,root))throw new ForkUnsupportedError(`${parent} and ${root} are not on one volume that can clone files (APFS, btrfs, XFS with reflink); the fork would have to copy the whole tree`);let head=await git2(parent,["rev-parse","HEAD"]);await git2(spec.repo,["worktree","add","--no-checkout","-b",spec.branch,target,head]);try{let entries=(await fs.readdir(parent)).filter((name)=>name!==".git").map((name)=>path.join(parent,name));await this.cloneEntries(entries,target),await this.carryIndex(parent,target)}catch(err){throw await this.discard(spec.repo,target,spec.branch),err}return{backend:this.id,path:target}}async carryIndex(parent,target){let indexOf=(dir)=>git2(dir,["rev-parse","--path-format=absolute","--git-path","index"]);try{await fs.copyFile(await indexOf(parent),await indexOf(target)),await git2(target,["update-index","-q","--refresh"])}catch{await git2(target,["reset","-q"])}}async discard(repo,target,branch){await git2(repo,["worktree","remove","--force",target]).catch(()=>{}),await fs.rm(target,{recursive:!0,force:!0}),await git2(repo,["worktree","prune"]).catch(()=>{}),await git2(repo,["branch","-D",branch]).catch(()=>{})}dispose(target,opts){return this.plain.dispose(target,opts)}}class GitWorktreeBackend{worktrees;id="git-worktree";capabilities=WORKSPACE_CAPABILITIES["git-worktree"];constructor(worktrees){this.worktrees=worktrees}async materialize(spec){let info=await this.worktrees.createForTask({repo:spec.repo,slug:spec.slug,branch:spec.branch,baseRef:spec.baseRef,onProgress:spec.onProgress});return{backend:this.id,path:info.path}}async dispose(target,opts){await this.worktrees.remove(target.path,{...opts,repo:target.repo,branch:target.branch})}}import{execFile as execFile2}from"child_process";import{createHash}from"crypto";import{promises as fs2,readFileSync}from"fs";import os from"os";import path2 from"path";import{promisify as promisify2}from"util";var LAYERFS_CONFIG_KEY="experimental.layerfs",STATE_FILE=".rove-layerfs.json",SANDBOX_USER="501:20",SANDBOX_HOME="/tmp/rove-home",KILL_TAGGED=`for p in /proc/[0-9]*; do tr '\\0' '\\n' < $p/environ 2>/dev/null | grep -qx "$1" && kill -KILL \${p#/proc/}; done; true`,KILL_UNDER='for p in /proc/[0-9]*; do case $(readlink $p/cwd) in "$1"|"$1"/*) kill -KILL ${p#/proc/};; esac; done; sleep 0.2',execRun=async(file,args)=>{try{let{stdout}=await promisify2(execFile2)(file,[...args],{maxBuffer:67108864});return stdout}catch(err){let e=err;throw Error((e.stderr?.trim()||e.stdout?.trim()||e.message).slice(0,2000))}};function parseLayerfsEnv(text){let env={};for(let line of text.split(`
|
|
2
|
+
import{canonPath,normalizeMainRepo,randomDirTaskSuffix,repoWorkingDir,samePrStatus,titleFromRepo}from"./chunk-zp4efbtb.js";import{isUnlistedCheckout}from"./chunk-n8z4nb8v.js";import{CLONEFILEAT_PERL,GitWorktreeManager,defaultExecDeps,git,headCommit,isDirtyOutput,parseDirtyPaths}from"./chunk-a5ehejp6.js";import{readLastActiveTaskId,writeLastActiveTaskId}from"./chunk-ak0ezn5t.js";import{LAUNCH_PREFIX_FILE}from"./chunk-4dt1gfb3.js";import{PLACEHOLDER_TASK_TITLE,isPlaceholderDerivedBranch,sanitizeTaskTitle}from"./chunk-2xsxcdp6.js";import{DirtyWorktreeError,EmptyBranchDirtyWorktreeError,EmptyBranchError,ExtraRepoNotGitError,ForkUnsupportedError,GitCommandFailedError,IllegalTransitionError,InvalidWorktreeNameError,LandConflictError,MainCheckoutDirtyError,MissingRefError,MoveRefusedError,NotAGitRepoError,NotALinkedRepoError,REMOTE_PARENT_UNSUPPORTED_CODE,RemoteExtraUnsupportedError,RemoteParentUnsupportedError,ReparentRefusedError,RepoDuplicateError,TaskDeletingError,TaskNotFoundError,TooManyReposError,WorktreeNameTakenError,WorktreeRemoveFailedError,canonicalize,listWorktreeDirNames,worktreePathFor}from"./chunk-79wejcs5.js";import{forwardVerb,requireMachine}from"./chunk-zc67sqet.js";import{resolvePreferredVendor}from"./chunk-2x6s7z8w.js";import{READ_ONLY_GIT_ENV}from"./chunk-6xppe9bj.js";import{detectLanguage}from"./chunk-133c884f.js";import{readRemoteWorkspace,removeRemoteLink}from"./chunk-750rk2xz.js";import{addSavedRepo,getPersistedString,isGitRepo,isRemoteRepoKey,removeSavedRepo,resolveMainRepoRoot,resolveRepoRoot,storedRepos}from"./chunk-07665jz6.js";import{errorMessage}from"./chunk-9gctbddn.js";import{projectRejection,rejectionReason}from"./chunk-mg1cas61.js";import{createStateCell}from"./chunk-cmp64q4j.js";import{MULTI_REPO_CAP,SESSION_PR_CAP,WORKSPACE_CAPABILITIES,applyTodoOps,checkNotes,childrenOf,deletionTargets,gitRepoOf,lineageRootId,pickRepos,repoNameOf,subtreeIds,taskCwd,taskRepos,taskWorktreePaths,uniqueRepoName,workspaceBackendId,workspaceCapabilities}from"./chunk-tcmzq86w.js";import{DEFAULT_TASK_VENDOR,toTaskId}from"./chunk-xy8be792.js";import{pathWithin,samePath}from"./chunk-pn5ygqn6.js";class WorkspaceCheckpoints{store;worktrees;workspaces;requireTask;constructor(store,worktrees,workspaces,requireTask){this.store=store;this.worktrees=worktrees;this.workspaces=workspaces;this.requireTask=requireTask}workspaceOwner(id){let task=this.requireTask(id);return(task.sharesWorkspaceOf?this.store.get(task.sharesWorkspaceOf):void 0)??task}checkpointScope(id){let owner=this.workspaceOwner(id),sharers=this.store.list().filter((t)=>t.sharesWorkspaceOf===owner.id&&!t.deletion);return{ownerId:String(owner.id),sharerIds:[String(owner.id),...sharers.map((t)=>String(t.id))]}}canCheckpoint(id){if(!this.store.get(id))return!1;let owner=this.workspaceOwner(id);return workspaceCapabilities(owner).checkpoint&&!owner.deletion&&owner.worktreePath!==""}async target(id){let owner=this.workspaceOwner(id),own=this.canCheckpoint(id)?this.workspaces.get(workspaceBackendId(owner)).checkpoints:void 0,dir=owner.worktreePath;if(!this.canCheckpoint(id)||!await this.worktrees.pathExists(own?dir:`${dir}/.git`))throw Error(`NOT_CHECKPOINTABLE: ${owner.kind==="task"?"the task has no workspace on disk":`a ${owner.kind} task works in your own checkout`}`);let ownerId=String(owner.id);return{ownerId,dir,via:own??{take:(d,opts)=>this.worktrees.takeCheckpoint(d,ownerId,opts),list:(d)=>this.worktrees.listCheckpoints(d,ownerId),rewind:(d,n)=>this.worktrees.rewindToCheckpoint(d,ownerId,n)}}}async takeCheckpoint(id,opts){let{dir,via}=await this.target(id);return via.take(dir,opts)}async listCheckpoints(id){let{dir,via}=await this.target(id);return via.list(dir)}async rewindToCheckpoint(id,n){let{dir,via}=await this.target(id);return via.rewind(dir,n)}async exportBranch(id){let owner=this.workspaceOwner(id),backend=this.workspaces.get(workspaceBackendId(owner));if(!backend.exportBranch||!owner.worktreePath)throw Error("EXPORT_UNSUPPORTED: the task's branch is already in its repo (or it has no workspace yet)");return backend.exportBranch({path:owner.worktreePath,repo:gitRepoOf(owner),branch:owner.branch})}}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()}`}function planExtraRepos(primary,inputs){if(inputs.length===0)return[];if(1+inputs.length>MULTI_REPO_CAP)throw new TooManyReposError(1+inputs.length,MULTI_REPO_CAP);if(isRemoteRepoKey(primary))throw new RemoteExtraUnsupportedError(primary);let seen=new Set([canonPath(primary)]),names=new Set([repoNameOf(primary)]);return inputs.map((input)=>{if(isRemoteRepoKey(input.repo))throw new RemoteExtraUnsupportedError(input.repo);let{repo}=normalizeMainRepo(input.repo);if(!isGitRepo(repo))throw new ExtraRepoNotGitError(input.repo);if(seen.has(canonPath(repo)))throw new RepoDuplicateError(repo);seen.add(canonPath(repo));let name=uniqueRepoName(repoNameOf(repo),names);names.add(name);let baseRef=input.baseRef?.trim();return{name,repo,branch:"",worktreePath:"",...baseRef?{baseRef}:{}}})}async function rollbackWorktree(backend,created){try{await backend.dispose({path:created.path,...created.fresh},created.fresh?{force:!0,deleteBranch:!0}:{force:!0})}catch(err){console.error(`[rove] ensureWorktree rollback failed for ${created.path}:`,err)}}async function extrasToMaterialise(worktrees,extras){let missing=[];for(let extra of extras??[])if(!extra.worktreePath||!await worktrees.pathExists(extra.worktreePath))missing.push(extra);return missing}function scaleProgress(onProgress,step,total){return onProgress&&((percent)=>onProgress(Math.floor((step+percent/100)/total*100)))}async function materialiseExtras(opts){let{worktrees,backend,slugs,task}=opts,callerNamed=task.branch!=="",created=[],picked=[],done=new Map,missing=await extrasToMaterialise(worktrees,task.extraRepos);try{for(let[index,extra]of missing.entries()){if(extra.worktreePath)await worktrees.pruneWorktrees(extra.repo);let names=await worktrees.listBranchNames(extra.repo),branch=extra.branch||(callerNamed||!names.includes(opts.branch)?opts.branch:uniqueBranchName(opts.branch,new Set(names),task.id)),slug=await slugs.allocate(extra.repo);picked.push({repo:extra.repo,slug});let info=await backend.materialize({repo:extra.repo,slug,branch,baseRef:extra.baseRef,onProgress:opts.progressFor(index)});created.push({path:info.path,...names.includes(branch)?{}:{fresh:{repo:extra.repo,branch}}}),done.set(extra.name,{...extra,branch,worktreePath:info.path})}}catch(err){for(let wt of created.reverse())await rollbackWorktree(backend,wt);for(let{repo,slug}of picked)slugs.cancel(repo,slug);throw err}return{extraRepos:(task.extraRepos??[]).map((e)=>done.get(e.name)??e),created,slugs:picked}}function nestingParent(store,id){let parent=store.get(id);if(!parent)throw new TaskNotFoundError(id);if(parent.deletion)throw new TaskDeletingError(String(parent.id));if(isRemoteRepoKey(parent.repo))throw new RemoteParentUnsupportedError(String(parent.id));return toTaskId(lineageRootId(store.list(),parent.id))}async function createTaskRow(deps,input){if(!input.repo)throw Error("createTask: repo is required");let extraRepos=planExtraRepos(normalizeMainRepo(input.repo).repo,input.extraRepos??[]),parentTaskId=input.parentTaskId?nestingParent(deps.store,input.parentTaskId):void 0,repo=deps.projects.ensureIfEligible(input.repo,input.projectIntent??"explicit")??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}:{},...parentTaskId?{parentTaskId}:{},...input.worktreeOnly?{worktreeOnly:!0}:{},...input.cwdSubpath?{cwdSubpath:input.cwdSubpath}:{},...input.routine?{routine:input.routine}:{},...input.baseRef?.trim()?{baseRef:input.baseRef.trim()}:{},...extraRepos.length>0?{extraRepos}:{},...input.workspace?{workspace:input.workspace}:{},...worktreeName?{worktreeName}:{}})}async function openDirectoryTaskRow(deps,input){if(!input.dir)throw Error("openDirectoryTask: dir is required");let remote=isRemoteRepoKey(input.dir),dir=remote?input.dir:canonPath(input.dir),title=(input.title?sanitizeTaskTitle(input.title):"")||(input.scratch?"":`${titleFromRepo(dir)}-${randomDirTaskSuffix()}`);return deps.store.create({repo:dir,title,branch:"",worktreePath:remote?repoWorkingDir(dir):dir,status:"backlog",kind:"dir",...input.scratch?{scratch:!0}:{},...input.noProject?{noProject:!0}:{},...input.routine?{routine:input.routine}:{},...input.workspace?{workspace:input.workspace}:{},...input.modelEffort?{modelEffort:input.modelEffort}:{},...input.model?.trim()?{model:input.model.trim()}:{},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)})}class BorrowedBackend{id="borrowed";capabilities=WORKSPACE_CAPABILITIES.borrowed;async materialize(spec){return{backend:this.id,path:spec.path??repoWorkingDir(spec.repo)}}async dispose(){}}import{execFile}from"child_process";import{promises as fs,statSync}from"fs";import path from"path";import{promisify}from"util";var run=promisify(execFile),CP_CHUNK=200;function cloneFlags(){if(process.platform==="darwin")return["-c","-R","-P"];if(process.platform==="linux")return["--reflink=always","-a"];return null}var cpClone=async(entries,to)=>{let flags=cloneFlags();if(!flags)throw new ForkUnsupportedError(`copy-on-write clones are not supported on ${process.platform}`);for(let i=0;i<entries.length;i+=CP_CHUNK)try{await run("cp",[...flags,...entries.slice(i,i+CP_CHUNK),`${to}${path.sep}`])}catch(err){let detail=err.stderr?.trim()||String(err);throw Error(`cloning the worktree failed: ${detail}`)}},probeCache=new Map;async function cloneOneFile(source,target){if(process.platform==="darwin")await run("/usr/bin/perl",["-e",CLONEFILEAT_PERL,source,target]);else if(process.platform==="linux")await run("cp",["--reflink=always",source,target]);else throw Error(`no clone primitive on ${process.platform}`)}var volumeProbe=(from,toDir)=>{let key=`${statSync(from).dev}:${statSync(toDir).dev}`,known=probeCache.get(key);if(!known)known=(async()=>{let probe=path.join(toDir,`.rove-clone-probe-${process.pid}`);try{return await cloneOneFile(path.join(from,".git"),probe),!0}catch{return!1}finally{await fs.rm(probe,{force:!0})}})(),probeCache.set(key,known);return known};async function git2(cwd,args){let{stdout}=await run("git",[...args],{cwd,maxBuffer:67108864});return stdout.trim()}class CowCloneBackend{plain;id="cow-clone";capabilities=WORKSPACE_CAPABILITIES["cow-clone"];probe;cloneEntries;constructor(plain,deps={}){this.plain=plain;this.probe=deps.probe??volumeProbe,this.cloneEntries=deps.cloneEntries??cpClone}async materialize(spec){let parent=spec.forkFrom;if(!parent)return{...await this.plain.materialize(spec),backend:this.id};if(isRemoteRepoKey(spec.repo))throw new ForkUnsupportedError("a remote project's worktree cannot be cloned");let target=worktreePathFor(spec.repo,spec.slug),root=path.dirname(target);if(await fs.mkdir(root,{recursive:!0}),!await this.probe(parent,root))throw new ForkUnsupportedError(`${parent} and ${root} are not on one volume that can clone files (APFS, btrfs, XFS with reflink); the fork would have to copy the whole tree`);let head=await git2(parent,["rev-parse","HEAD"]);await git2(spec.repo,["worktree","add","--no-checkout","-b",spec.branch,target,head]);try{let entries=(await fs.readdir(parent)).filter((name)=>name!==".git").map((name)=>path.join(parent,name));await this.cloneEntries(entries,target),await this.carryIndex(parent,target)}catch(err){throw await this.discard(spec.repo,target,spec.branch),err}return{backend:this.id,path:target}}async carryIndex(parent,target){let indexOf=(dir)=>git2(dir,["rev-parse","--path-format=absolute","--git-path","index"]);try{await fs.copyFile(await indexOf(parent),await indexOf(target)),await git2(target,["update-index","-q","--refresh"])}catch{await git2(target,["reset","-q"])}}async discard(repo,target,branch){await git2(repo,["worktree","remove","--force",target]).catch(()=>{}),await fs.rm(target,{recursive:!0,force:!0}),await git2(repo,["worktree","prune"]).catch(()=>{}),await git2(repo,["branch","-D",branch]).catch(()=>{})}dispose(target,opts){return this.plain.dispose(target,opts)}}class GitWorktreeBackend{worktrees;id="git-worktree";capabilities=WORKSPACE_CAPABILITIES["git-worktree"];constructor(worktrees){this.worktrees=worktrees}async materialize(spec){let info=await this.worktrees.createForTask({repo:spec.repo,slug:spec.slug,branch:spec.branch,baseRef:spec.baseRef,onProgress:spec.onProgress});return{backend:this.id,path:info.path}}async dispose(target,opts){await this.worktrees.remove(target.path,{...opts,repo:target.repo,branch:target.branch})}}import{execFile as execFile2}from"child_process";import{createHash}from"crypto";import{promises as fs2,readFileSync}from"fs";import os from"os";import path2 from"path";import{promisify as promisify2}from"util";var LAYERFS_CONFIG_KEY="experimental.layerfs",STATE_FILE=".rove-layerfs.json",SANDBOX_USER="501:20",SANDBOX_HOME="/tmp/rove-home",KILL_TAGGED=`for p in /proc/[0-9]*; do tr '\\0' '\\n' < $p/environ 2>/dev/null | grep -qx "$1" && kill -KILL \${p#/proc/}; done; true`,KILL_UNDER='for p in /proc/[0-9]*; do case $(readlink $p/cwd) in "$1"|"$1"/*) kill -KILL ${p#/proc/};; esac; done; sleep 0.2',execRun=async(file,args)=>{try{let{stdout}=await promisify2(execFile2)(file,[...args],{maxBuffer:67108864});return stdout}catch(err){let e=err;throw Error((e.stderr?.trim()||e.stdout?.trim()||e.message).slice(0,2000))}};function parseLayerfsEnv(text){let env={};for(let line of text.split(`
|
|
3
3
|
`)){let m=/^\s*(?:export\s+)?([A-Z_][A-Z0-9_]*)=(.*)$/.exec(line);if(m)env[m[1]]=m[2].trim().replace(/^(["'])(.*)\1$/,"$2")}return env}class LayerfsBackend{id="layerfs";capabilities=WORKSPACE_CAPABILITIES.layerfs;run;configPath;platform;rootChecked=!1;constructor(deps={}){this.run=deps.run??execRun,this.configPath=deps.configPath??(()=>getPersistedString(LAYERFS_CONFIG_KEY)),this.platform=deps.platform??process.platform}async preflight(){this.env(),await this.requireRoot()}env(){if(this.platform!=="linux")throw unavailable(`it runs on Linux Runners only, not ${this.platform}`);let file=this.configPath();if(!file)throw unavailable(`set ${LAYERFS_CONFIG_KEY} in state.json to a LayerFS env file`);let env;try{env=parseLayerfsEnv(readFileSync(file,"utf8"))}catch(err){throw unavailable(`cannot read ${file}: ${err.message}`)}for(let key of["LAYERFS_CLI","LAYERFS_NODE","LAYERFS_HOME","LAYERFS_STORE_PATH","LAYERFS_IMAGE"])if(!env[key])throw unavailable(`${file} does not set ${key}`);return env}async requireRoot(){if(this.rootChecked)return;try{await this.run("sudo",["-n","true"])}catch{throw Error("LAYERFS_NEEDS_ROOT: LayerFS Store calls run as root, and `sudo -n` cannot (configure passwordless sudo for this user)")}this.rootChecked=!0}async lfs(project,...args){let env=this.env();await this.requireRoot();let pass=Object.entries(env).filter(([k])=>k!=="LAYERFS_CLI"&&k!=="LAYERFS_NODE").map(([k,v])=>`${k}=${v}`),out=await this.run("sudo",["-n","env",...pass,`LAYERFS_PROJECT=${project}`,env.LAYERFS_NODE,env.LAYERFS_CLI,...args]);return JSON.parse(out)}docker(...args){return this.run("docker",args)}inSandbox(s,dir,...argv){return this.docker("exec","-u",SANDBOX_USER,"-w",dir,"-e",`HOME=${SANDBOX_HOME}`,s.container,...argv)}async ensureProject(repo){let project=`rove-${createHash("sha1").update(repo).digest("hex").slice(0,12)}`;try{await this.lfs(project,"project","list_branches","--page-size","1")}catch{await this.lfs(project,"init",project,repo,"--timeout","1800000")}return project}async materialize(spec){if(spec.forkFrom||spec.path)throw unavailable("a layerfs task cannot be forked or borrow a directory");this.env();let dir=worktreePathFor(spec.repo,spec.slug),project=await this.ensureProject(spec.repo),branch=`${spec.slug}-${Date.now().toString(36)}`;await this.lfs(project,"branch","fork",branch);let{sandbox}=await this.lfs(project,"sandbox","create"),s={project,sandbox,ws:"",container:"",branch,gitBase:"",checkpoints:[]};try{s.container=await this.containerOf(project,sandbox),await this.mount(s,dir),await this.inSandbox(s,dir,"git","checkout","-q","-b",spec.branch,...spec.baseRef?[spec.baseRef]:[]),s.gitBase=(await this.inSandbox(s,dir,"git","rev-parse","HEAD")).trim();let reap=["docker","exec","-u",SANDBOX_USER,s.container,"sh","-c",KILL_TAGGED,"sh","ROVE_LAUNCH={launch}"];await fs2.writeFile(path2.join(dir,LAUNCH_PREFIX_FILE),JSON.stringify({prefix:this.launchPrefix(s,dir),reap})),await this.save(dir,s)}catch(err){throw await this.teardown(s,dir,!0).catch(()=>{}),err}return{backend:this.id,path:dir,ref:`${project}:${branch}`}}launchPrefix(s,dir){let env=["-e",`HOME=${SANDBOX_HOME}`,"-e","ROVE_LAUNCH={launch}","-e","TERM","-e","COLUMNS","-e","LINES"];return["docker","exec","-it","-u",SANDBOX_USER,"-w",dir,...env,s.container]}async containerOf(project,sandbox){let id=(await this.docker("ps","-q","--filter",`label=layerfs.project=${project}`,"--filter",`label=layerfs.sandbox=${sandbox}`)).trim();if(!id||id.includes(`
|
|
4
4
|
`))throw Error(`no single container for LayerFS sandbox ${project}/${sandbox}`);return id}async mount(s,dir){s.ws=(await this.lfs(s.project,"workspace","mount",s.sandbox,s.branch)).ws,await fs2.mkdir(dir,{recursive:!0}),await this.bind(s,dir)}async bind(s,dir){let mountPath=s.ws.slice(s.ws.indexOf(":")+1),script=`mkdir -p "$1" ${SANDBOX_HOME} && chown ${SANDBOX_USER} ${SANDBOX_HOME} && mount --bind "$2" "$1"`;await this.docker("exec","-u","0",s.container,"sh","-c",script,"sh",dir,mountPath)}async unbind(s,dir){try{await this.docker("exec","-u","0",s.container,"umount",dir)}catch(err){if(!/busy/i.test(err.message))throw err;throw Error(`WORKSPACE_BUSY: a process still runs in ${dir} inside the sandbox; close the task's terminals first`)}}async unmount(s,dir,discard){await this.unbind(s,dir);try{await this.lfs(s.project,"workspace","unmount",s.ws,...discard?["--discard"]:[])}catch(err){if(await this.bind(s,dir),!/"code":"Dirty"/.test(err.message))throw err;throw Error(`WORKSPACE_DIRTY: LayerFS has uncommitted changes in ${dir}; checkpoint first, or force`)}}async teardown(s,dir,discard){if(s.ws){if(s.container)await this.docker("exec","-u",SANDBOX_USER,s.container,"sh","-c",KILL_UNDER,"sh",dir);await this.unmount(s,dir,discard)}await this.lfs(s.project,"sandbox","close",s.sandbox),await fs2.rm(path2.join(dir,STATE_FILE),{force:!0}),await fs2.rm(path2.join(dir,LAUNCH_PREFIX_FILE),{force:!0}),await fs2.rmdir(dir).catch(()=>{})}async dispose(target,opts){let s=await this.load(target.path).catch(()=>{return});if(!s){await fs2.rm(path2.join(target.path,LAUNCH_PREFIX_FILE),{force:!0}),await fs2.rmdir(target.path).catch(()=>{});return}await this.teardown(s,target.path,opts.force===!0)}async dirtyPaths(dir){let s=await this.load(dir).catch(()=>{return});if(!s?.ws)return[];let{items}=await this.lfs(s.project,"sandbox","list_workspaces",s.sandbox);return items.find((w)=>`${s.sandbox}:${w.path}`===s.ws)?.changed?["(changes since the last checkpoint, inside the LayerFS sandbox)"]:[]}checkpoints={take:(dir,opts)=>this.take(dir,opts?.tabId),list:async(dir)=>(await this.load(dir)).checkpoints,rewind:async(dir,n)=>{let target=(await this.load(dir)).checkpoints.find((c)=>c.n===n);if(!target)throw Error(`CHECKPOINT_NOT_FOUND: checkpoint ${n} does not exist`);let undo=(await this.take(dir)).checkpoint,after=await this.load(dir),fork=`${after.branch.replace(/-r[0-9a-z]+$/,"")}-r${Date.now().toString(36)}`;return await this.lfs(after.project,"branch","fork",fork,target.commit),await this.unmount(after,dir,!0),after.branch=fork,await this.mount(after,dir),await this.save(dir,after),{target,undo,uncaptured:[]}}};async take(dir,tabId){let s=await this.load(dir),latest=s.checkpoints.at(-1),reply=await this.lfs(s.project,"workspace","commit",s.ws,"-m","rove checkpoint",...latest?[]:["--force"]);if(latest&&reply.kind==="UpToDate")return{created:!1,checkpoint:latest};let checkpoint={n:(latest?.n??0)+1,ref:`layerfs:${s.project}:${s.branch}`,commit:reply.head,tree:reply.commit?.root??reply.root??reply.head,at:new Date().toISOString(),...tabId?{tabId}:{}};return s.checkpoints.push(checkpoint),await this.save(dir,s),{created:!0,checkpoint,uncaptured:[]}}async exportBranch(target){let s=await this.load(target.path),inner=`/tmp/rove-export-${process.pid}.bundle`;await this.inSandbox(s,target.path,"git","bundle","create","-q",inner,target.branch,`^${s.gitBase}`);let local=path2.join(os.tmpdir(),`rove-layerfs-${process.pid}-${Date.now()}.bundle`);try{await this.docker("cp",`${s.container}:${inner}`,local),await this.run("git",["-C",target.repo,"fetch","-q",local,`${target.branch}:refs/heads/${target.branch}`]);let commit=(await this.run("git",["-C",target.repo,"rev-parse",target.branch])).trim();return{branch:target.branch,commit}}finally{await fs2.rm(local,{force:!0})}}async load(dir){return JSON.parse(await fs2.readFile(path2.join(dir,STATE_FILE),"utf8"))}save(dir,s){return fs2.writeFile(path2.join(dir,STATE_FILE),`${JSON.stringify(s,null,2)}
|
|
5
5
|
`)}}function unavailable(why){return Error(`LAYERFS_UNAVAILABLE: the layerfs workspace backend is unavailable: ${why}`)}class RemoteBackend{id="remote";capabilities=WORKSPACE_CAPABILITIES.remote;async materialize(){throw Error("a remote workspace is created by `rove api add --workspace-on <machine>`")}async dispose(target,opts){let ws=readRemoteWorkspace(target.path);if(ws){let gone=await forwardVerb(requireMachine(ws.machine),"delete",{"task-id":ws.taskId,wait:!0,...opts.force?{force:!0}:{}});if(!gone.ok&&gone.error.code!=="TASK_NOT_FOUND"&&!opts.force)throw Error(gone.error.message)}removeRemoteLink(target.path)}async dirtyPaths(){return[]}}class WorkspaceRegistry{backends=new Map;constructor(backends){for(let backend of backends)this.backends.set(backend.id,backend)}get(id){let backend=this.backends.get(id);if(!backend)throw Error(`workspace backend '${id}' is not available in this build`);return backend}}function createWorkspaceRegistry(worktrees,cowClone){let plain=new GitWorktreeBackend(worktrees);return new WorkspaceRegistry([plain,new BorrowedBackend,new CowCloneBackend(plain,cowClone),new LayerfsBackend,new RemoteBackend])}async function createOrForkTask(deps,input){if(input.workspace)await deps.workspaces.get(input.workspace.backend).preflight?.();let createRow=(row)=>createTaskRow(deps,row),{forkFrom}=input;return forkFrom?forkTaskRow({...deps,createRow},{...input,forkFrom}):createRow(input)}async function forkTaskRow(deps,input){let parent=deps.store.get(input.forkFrom);if(!parent)throw new TaskNotFoundError(input.forkFrom);if(parent.deletion)throw new TaskDeletingError(String(parent.id));if(!workspaceCapabilities(parent).ownsDirectory)throw new ForkUnsupportedError("a directory task has no Rove-created worktree to clone");if(isRemoteRepoKey(parent.repo))throw new ForkUnsupportedError("a remote project's worktree cannot be cloned");if(parent.extraRepos?.length)throw new ForkUnsupportedError("a multi-repo task cannot be forked: only its primary repo would be cloned");let parentPath=await deps.ensureWorktree(parent.id),baseRef=headCommit(parentPath),child=await deps.createRow({...input,repo:gitRepoOf(parent),title:input.title??`${parent.title} (fork)`,baseRef,workspace:{backend:"cow-clone",ref:String(parent.id)},...parent.cwdSubpath?{cwdSubpath:parent.cwdSubpath}:{}});if(parent.gitRepo)await deps.store.update(child.id,{repo:parent.repo,gitRepo:parent.gitRepo});try{await deps.cloneInto(child,parentPath)}catch(err){throw await discard(deps,child).catch((cleanup)=>console.error(`[rove] fork rollback failed for ${child.id}:`,cleanup)),await deps.store.remove(child.id),err}return deps.store.get(child.id)??child}async function discard(deps,child){let row=deps.store.get(child.id);if(!row?.worktreePath)return;await deps.workspaces.get(workspaceBackendId(row)).dispose({path:row.worktreePath,repo:gitRepoOf(row),branch:row.branch},{force:!0,deleteBranch:!0})}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(gitRepoOf(task),deps),headOut=await landGit(exec,dir,["symbolic-ref","--short","HEAD"],{readOnly:!0}),landedOn=headOut.stdout.trim();if(headOut.exitCode!==0||!landedOn){let headCommit2=await landGit(exec,dir,["rev-parse","--verify","--quiet","HEAD"],{readOnly:!0}),detached=headCommit2.exitCode===0&&headCommit2.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(gitRepoOf(task),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)}}function assertOwnsBranch(task){if(workspaceCapabilities(task).ownsBranch)return;throw Error("landTask: a directory task has no Rove-managed branch to land")}async function landTaskWithCleanup(task,opts,deps){assertOwnsBranch(task);let result=await landTask(task,{strategy:opts.strategy});return finishLanded(task,result,opts,deps)}async function finishLanded(task,result,opts,deps){let 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(gitRepoOf(task),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(gitRepoOf(task))))return{removed:!1,reason:"refusing to remove the base checkout"};if(deps.sharesWorktree?.(task))return{removed:!1,reason:`kept ${worktreePath}: other tasks still run in this directory`};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(`
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{machineTasks}from"./chunk-zc67sqet.js";import"./chunk-ejs6dnxf.js";import"./chunk-a6s52zm5.js";import"./chunk-y0e28qha.js";import"./chunk-t7qj639x.js";import"./chunk-gz0x179r.js";import"./chunk-jz1kj4sf.js";import"./chunk-v8nbqjwc.js";import"./chunk-ws2q07kb.js";import"./chunk-g9ba25q5.js";import"./chunk-133c884f.js";import"./chunk-catrr0z3.js";import"./chunk-xjrkvksc.js";import"./chunk-tn9gtf18.js";import"./chunk-ahbw1f8n.js";import"./chunk-sak1tphp.js";import"./chunk-y1xnjx8x.js";import"./chunk-sffdpzfv.js";import"./chunk-5dv7pw3w.js";import"./chunk-2bapg0v2.js";import"./chunk-750rk2xz.js";import"./chunk-w7zv47mp.js";import"./chunk-cw9h73h5.js";import{dedupeMachines,listMachines}from"./chunk-37g0yabr.js";import"./chunk-nw48bskt.js";import"./chunk-k7tdg6kb.js";import"./chunk-1pmzr8kr.js";import"./chunk-e5jxbd98.js";import"./chunk-84q9hv7m.js";import"./chunk-96kvwzj8.js";import"./chunk-07665jz6.js";import"./chunk-40dgv828.js";import"./chunk-zsfyj36g.js";import"./chunk-1feav1w3.js";import"./chunk-9gctbddn.js";import"./chunk-mg1cas61.js";import"./chunk-yvg46jh9.js";import"./chunk-xasg8z9e.js";import"./chunk-8xdhw922.js";import"./chunk-cmp64q4j.js";import"./chunk-j152pk57.js";import"./chunk-c4dfktv2.js";import"./chunk-bdmbevk8.js";import"./chunk-7kysxgbq.js";import"./chunk-g755p68b.js";import"./chunk-tcmzq86w.js";import"./chunk-y8hjgmn0.js";import"./chunk-xy8be792.js";import"./chunk-h2m7em1e.js";import"./chunk-pn5ygqn6.js";import"./chunk-7ghwdjdc.js";import"./chunk-m5nd44st.js";import"./chunk-rxb0hw1e.js";import"./chunk-tw25g9g5.js";import"./chunk-yt15y085.js";import"./chunk-2z2jwetd.js";import"./chunk-8143k3t6.js";import"./chunk-zt7wfnva.js";import"./chunk-g6wb8p4p.js";import"./chunk-nc46gddg.js";import"./chunk-1mp632fj.js";import"./chunk-91sykzqq.js";async function mergeTaskList(local){let machines=dedupeMachines(listMachines());if(machines.length===0)return local;let tasks=(local.tasks??[]).map((task)=>({...task,origin:{machineId:"local",hostLabel:"local"}}));for(let entry of machines){let remote=await machineTasks(entry);if(!remote)continue;let hostLabel=entry.alias;for(let task of remote){let kind=task.kind==="main"?"dir":task.kind;tasks.push({...task,kind,origin:{machineId:entry.alias,hostLabel}})}}return{tasks}}export{mergeTaskList};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{stampResetGate}from"./chunk-
|
|
2
|
+
import{stampResetGate}from"./chunk-ggjg0h5c.js";import{stopLegacyTmux}from"./chunk-gkdfct7t.js";import"./chunk-s2eezz0a.js";import{clearFrozenSessions}from"./chunk-y0skz8j9.js";import"./chunk-mqfvzdpr.js";import{stopDaemonProcess}from"./chunk-1pmzr8kr.js";import"./chunk-84q9hv7m.js";import"./chunk-96kvwzj8.js";import{errorMessage}from"./chunk-9gctbddn.js";import"./chunk-xasg8z9e.js";import"./chunk-y8hjgmn0.js";import"./chunk-pn5ygqn6.js";import"./chunk-rxb0hw1e.js";import"./chunk-tw25g9g5.js";import"./chunk-yt15y085.js";import{defaultDaemonPidPath,defaultDaemonSocketPath,defaultPtyFreezeDir,defaultPtyHostPidPath,defaultPtyHostSocketPath}from"./chunk-2z2jwetd.js";import{kvStatePath,legacyRoveKvStatePath,legacyRoveStateDir,roveStateDir}from"./chunk-8143k3t6.js";import{ROVE_PRODUCT_NAME}from"./chunk-zt7wfnva.js";import"./chunk-g6wb8p4p.js";import"./chunk-nc46gddg.js";import"./chunk-91sykzqq.js";import{readFileSync}from"fs";import{unlink}from"fs/promises";import{join}from"path";import{createInterface}from"readline";var CLI_NAME=ROVE_PRODUCT_NAME;function printUsage(out){out.write([`Usage: ${CLI_NAME} reset [--hard] [--yes]`,"","Recover a wedged install: stop the daemon, Hosted PTY host, and any pre-v0.8 tmux sessions.","This ends background terminal and engine sessions; the next launch starts fresh.","Never touches your git worktrees.","","Options:"," --hard Also DELETE the task index and the whole settings file"," (saved projects, custom engines, theme, language, onboarding)"," -y, --yes Skip the interactive confirmation. REQUIRED without a terminal;"," a non-interactive run without it exits 2 and changes nothing."," -h, --help Print this help",""].join(`
|
|
3
3
|
`))}function taskCount(path){try{let parsed=JSON.parse(readFileSync(path,"utf8"));return Array.isArray(parsed.tasks)?parsed.tasks.length:null}catch{return null}}function stateSummary(path){let parsed;try{parsed=JSON.parse(readFileSync(path,"utf8"))}catch{return[]}let count=(key)=>Array.isArray(parsed[key])?parsed[key].length:0,lines=[` saved projects: ${count("savedRepos")}`,` custom engines: ${count("customEngineIds")} (their launch commands live here and nowhere else)`],present=[["activeTheme","theme"],["defaultVendor","default engine"],["locale","language"],["onboarded","onboarding (the wizard runs again)"]].filter(([key])=>parsed[key]!==void 0).map(([,label])=>label);if(present.length>0)lines.push(` also set: ${present.join(", ")}`);return lines.push(` ${Object.keys(parsed).length} setting(s) in total`),lines}async function confirmTty(prompt){let readline=createInterface({input:process.stdin,output:process.stdout});try{let answer=await new Promise((resolve)=>readline.question(prompt,resolve));return/^y(es)?$/i.test(answer.trim())}finally{readline.close()}}async function removeStateFile(path,label){try{await unlink(path),console.log(` removed ${label} (${path})`)}catch(err){if(err.code==="ENOENT")console.log(` ${label}: already absent`);else throw Error(`failed to remove ${label} (${path}): ${errorMessage(err)}`)}}async function runResetSubcommand(argv){if(argv.some((arg)=>arg==="--help"||arg==="-h"||arg==="help")){printUsage(process.stdout);return}let known=new Set(["--hard","--yes","-y"]),unknown=argv.find((arg)=>!known.has(arg));if(unknown!==void 0)process.stderr.write(`${CLI_NAME} reset: unknown argument "${unknown}"
|
|
4
4
|
|
|
5
5
|
`),printUsage(process.stderr),process.exit(2);let hard=argv.includes("--hard"),yes=argv.includes("--yes")||argv.includes("-y"),daemonSocket=defaultDaemonSocketPath(),tasksPath=join(roveStateDir(),"tasks.json"),legacyTasksPath=join(legacyRoveStateDir(),"tasks.json"),statePath=kvStatePath(),legacyStatePath=legacyRoveKvStatePath();if(console.log(`${CLI_NAME} reset will:`),console.log(" \u2022 stop the Rove daemon (graceful \u2192 SIGTERM \u2192 SIGKILL)"),console.log(` \u2022 remove its socket + pidfile (${daemonSocket})`),console.log(" \u2022 stop the standalone Hosted PTY host and all background terminal/engine sessions"),console.log(" \u2022 stop any pre-v0.8 tmux sessions after SIGTERM-ing their pane process groups"),hard){let count=taskCount(tasksPath)??taskCount(legacyTasksPath);console.log(` \u2022 DELETE the task index${count===null?"":` (${count} task(s))`} \u2014 ${tasksPath}`),console.log(` \u2022 DELETE the whole settings file \u2014 ${statePath}`);for(let line of stateSummary(statePath))console.log(line);console.log(" \u2022 DELETE the pre-Rove task/UI indexes too, so migration cannot restore reset state")}if(console.log(" \u2022 NOT touch your git worktrees under ~/.rove/worktrees/ or existing repo-local roots"),!hard)console.log(" (your task list, settings & worktrees are kept \u2014 add --hard to also delete the task index and settings file)");if(!yes){if(!process.stdin.isTTY){console.log(`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{formatBytes}from"./chunk-my20q579.js";import{hookConfigIssues}from"./chunk-
|
|
2
|
+
import{formatBytes}from"./chunk-my20q579.js";import{hookConfigIssues}from"./chunk-qwqa75g1.js";import{inspectLegacyTmux,legacyTmuxDoctorLines}from"./chunk-gkdfct7t.js";import"./chunk-3da0g8md.js";import"./chunk-ga448pv8.js";import"./chunk-a4hsqj1b.js";import"./chunk-xzk96zfj.js";import"./chunk-rmnm3f9n.js";import{skillOverview}from"./chunk-cvcp1aye.js";import{applyFixes,daemonRestartFix,defaultFixRuntime,engineTabsManualFix,humanOnlyFix,killOrphansManualFix,noEngineFix,reinstallManualFix,resetManualFix,skillInstallFix,spawnHelperFix}from"./chunk-7z2bmv13.js";import"./chunk-cpgnm1xr.js";import"./chunk-r3s2t9af.js";import"./chunk-6xr1prk6.js";import{describeAccount,detectEngineStatuses,probeableEngineIds,summarizeEngines,withEngineVersions}from"./chunk-6cggsxpr.js";import"./chunk-q8ffd1pc.js";import"./chunk-je7egpqh.js";import"./chunk-2bgmby1d.js";import"./chunk-5mhvjytn.js";import"./chunk-d1vv8xk6.js";import"./chunk-psxhek7n.js";import"./chunk-mdx18vtz.js";import"./chunk-y0e28qha.js";import"./chunk-eaav6ajz.js";import"./chunk-dmzg9zdc.js";import"./chunk-kg9kmwt9.js";import{CURRENT_VERSION,package_default}from"./chunk-s2eezz0a.js";import{resolveNodeBinary}from"./chunk-0x62tvdk.js";import"./chunk-y0skz8j9.js";import"./chunk-mqfvzdpr.js";import{formatDaemonInfo}from"./chunk-rxqdw6s5.js";import"./chunk-gz0x179r.js";import"./chunk-v8nbqjwc.js";import"./chunk-ws2q07kb.js";import"./chunk-g9ba25q5.js";import"./chunk-tn9gtf18.js";import"./chunk-sffdpzfv.js";import"./chunk-5dv7pw3w.js";import"./chunk-2bapg0v2.js";import"./chunk-750rk2xz.js";import"./chunk-w7zv47mp.js";import"./chunk-cw9h73h5.js";import"./chunk-37g0yabr.js";import"./chunk-nw48bskt.js";import{isStaleInstallError,resolveRoveSpawn}from"./chunk-k7tdg6kb.js";import"./chunk-1pmzr8kr.js";import"./chunk-e5jxbd98.js";import{RoveDaemonClient,isForeignDaemonHome}from"./chunk-84q9hv7m.js";import"./chunk-96kvwzj8.js";import"./chunk-etfh8f4z.js";import"./chunk-07665jz6.js";import"./chunk-40dgv828.js";import"./chunk-zsfyj36g.js";import"./chunk-9gctbddn.js";import"./chunk-mg1cas61.js";import"./chunk-yvg46jh9.js";import"./chunk-xasg8z9e.js";import{t}from"./chunk-8xdhw922.js";import"./chunk-cmp64q4j.js";import"./chunk-j152pk57.js";import"./chunk-c4dfktv2.js";import"./chunk-bdmbevk8.js";import"./chunk-7kysxgbq.js";import"./chunk-g755p68b.js";import{readableLegacyIndexPath}from"./chunk-tcmzq86w.js";import"./chunk-y8hjgmn0.js";import"./chunk-xy8be792.js";import"./chunk-h2m7em1e.js";import"./chunk-pn5ygqn6.js";import"./chunk-7ghwdjdc.js";import"./chunk-m5nd44st.js";import"./chunk-rxb0hw1e.js";import{readPidFile}from"./chunk-tw25g9g5.js";import"./chunk-yt15y085.js";import{defaultDaemonLogPath,defaultDaemonPidPath,defaultDaemonSocketPath,defaultPtyHostLogPath,defaultPtyHostPidPath,defaultPtyHostSocketPath}from"./chunk-2z2jwetd.js";import{homeDir,kvStatePath,roveStateDir}from"./chunk-8143k3t6.js";import{ROVE_PRODUCT_NAME}from"./chunk-zt7wfnva.js";import{preRenameStateDir}from"./chunk-g6wb8p4p.js";import"./chunk-nc46gddg.js";import"./chunk-1mp632fj.js";import{__require}from"./chunk-91sykzqq.js";import{existsSync,readFileSync as readFileSync2,statSync as statSync2}from"fs";import{join as join2}from"path";var MIN_BUN_VERSION=package_default.engines.bun.match(/\d+\.\d+\.\d+/)?.[0]??"0.0.0";function parseBunVersion(raw){return raw.trim().match(/^v?(\d+\.\d+\.\d+)/)?.[1]??null}function isBunAtLeast(raw,minimum=MIN_BUN_VERSION){let found=parseBunVersion(raw),floor=parseBunVersion(minimum);if(!found||!floor)return!0;let a=found.split(".").map(Number),b=floor.split(".").map(Number);for(let i=0;i<3;i++){let av=a[i]??0,bv=b[i]??0;if(av!==bv)return av>bv}return!0}function classifyHookChannel(input){let total=0,hooked=0;for(let tabs of Object.values(input.tabs))for(let entry of Object.values(tabs))if(total++,entry.source==="hook")hooked++;if(total===0)return{kind:"no-tabs"};if(hooked===0)return{kind:"down",totalTabs:total};return{kind:"live",hookTabs:hooked,totalTabs:total}}function hookChannelDoctorLines(verdict,input,cliName){let configLines=(input.configIssues??[]).flatMap((issue)=>[` \u26A0 hook install skipped: ${issue.file}`,` ${issue.reason} \u2014 fix the file, then relaunch Rove`]);if(verdict.kind==="no-tabs")return["hooks: \u2014 no engine tabs yet (nothing to check)",...configLines];if(verdict.kind==="live")return[`hooks: \u2713 engine hook channel live (${verdict.hookTabs}/${verdict.totalTabs} tab(s) hook-sourced)`,...configLines];let out=[`hooks: \u2717 NO hook events reaching the daemon (0/${verdict.totalTabs} tab(s) hook-sourced)`," badges fall back to a ~10s poll, so activity looks seconds late",` daemon socket: ${input.socketPath}`,...configLines];return out.push(' \u2192 compare with an engine tab\'s own path: `ps eww -p <engine-pid> | tr " " "\\n" | grep DAEMON_SOCKET_PATH`',` \u2192 restart the engine tabs (they may hold a stale socket path), or run \`${cliName} daemon restart\``,` \u2192 debug one hook directly: \`ROVE_HOOK_DEBUG=1 echo '{}' | ${cliName} hook turn-start --engine claude\``),out}import{readdirSync,statSync}from"fs";import{createRequire}from"module";import{dirname,join}from"path";function installedSpawnHelpers(){let pkg;try{pkg=dirname(createRequire(import.meta.url).resolve("node-pty/package.json"))}catch{return[]}let prebuilds=join(pkg,"prebuilds"),arches;try{arches=readdirSync(prebuilds).filter((name)=>name.startsWith("darwin-"))}catch{return[]}let helpers=[];for(let arch of arches){let path=join(prebuilds,arch,"spawn-helper");try{helpers.push({path,executable:(statSync(path).mode&64)!==0})}catch{}}return helpers}function spawnHelperDoctorLines(helpers){let broken=helpers.filter((helper)=>!helper.executable).map((helper)=>helper.path);if(helpers.length===0)return{lines:["node-pty: ? no darwin spawn-helper found next to node-pty"],broken};if(broken.length===0)return{lines:[`node-pty: \u2713 spawn-helper executable (${helpers.length} arch)`],broken};return{lines:["node-pty: \u2717 spawn-helper is not executable \u2014 every node-pty PTY spawn fails",...broken.map((path)=>` ${path}`),` \u2192 chmod 755 ${broken.join(" ")}`],broken}}import{appendFileSync,readFileSync}from"fs";var PTY_MARKER="ROVE_TERMINAL_PTY=1",run=async(argv)=>{try{let proc=Bun.spawn([...argv],{stdin:"ignore",stdout:"pipe",stderr:"ignore"}),[stdout,code]=await Promise.all([new Response(proc.stdout).text().catch(()=>""),proc.exited]);return{code,stdout}}catch{return{code:127,stdout:""}}};function parsePsRows(output){let rows=[];for(let line of output.split(`
|
|
3
3
|
`)){let parts=line.trim().split(/\s+/);if(parts.length<6)continue;let[pid,ppid,pgid]=[parts[0],parts[1],parts[2]].map((value)=>Number.parseInt(value??"",10)),rssKb=Number.parseInt(parts[4]??"",10);if(!Number.isFinite(pid)||!Number.isFinite(ppid)||!Number.isFinite(pgid)||!Number.isFinite(rssKb))continue;rows.push({pid,ppid,pgid,etime:parts[3]??"",rssKb,command:parts.slice(5).join(" ")})}return rows}function pidAlive(pid,rows){return rows.some((row)=>row.pid===pid)}function orphanCandidates(rows,selfPgid,liveSessionPids){return rows.filter((row)=>row.ppid===1&&row.pgid!==selfPgid&&!liveSessionPids.has(row.pgid)&&!pidAlive(row.pgid,rows))}async function markedPids(pids,deps={}){let runProbe=deps.run??run,readEnviron=deps.readEnviron??((pid)=>readFileSync(`/proc/${pid}/environ`,"utf8")),marked=new Set;if(pids.length===0)return{marked,failed:null};if((deps.platform??process.platform)==="linux"){let refused=null;for(let pid of pids)try{if(readEnviron(pid).split("\x00").includes(PTY_MARKER))marked.add(pid)}catch(err){let code=err.code;if(code!=="ENOENT"&&code!=="ESRCH")refused??=`/proc/${pid}/environ: ${code??"unreadable"}`}return{marked,failed:refused}}let result=await runProbe(["ps","eww","-o","pid=,command=","-p",pids.join(",")]);if(result.code!==0)return{marked,failed:`ps eww exited ${result.code}`};let marker=new RegExp(`(^|\\s)${PTY_MARKER}(\\s|$)`);for(let line of result.stdout.split(`
|
|
4
4
|
`)){let pid=Number.parseInt(line.trim().split(/\s+/)[0]??"",10);if(Number.isFinite(pid)&&marker.test(line))marked.add(pid)}return{marked,failed:null}}async function ownPgid(runProbe){let result=await runProbe(["ps","-o","pgid=","-p",String(process.pid)]),pgid=Number.parseInt(result.stdout.trim(),10);return Number.isFinite(pgid)?pgid:-1}async function collectOrphans(liveSessionPids,deps={}){let runProbe=deps.run??run;if((deps.platform??process.platform)==="win32")return{orphans:[],error:null};let ps=await runProbe(["ps","-A","-o","pid=,ppid=,pgid=,etime=,rss=,command="]);if(ps.code!==0)return{orphans:[],error:`could not read the process table \u2014 ps exited ${ps.code}`};let rows=parsePsRows(ps.stdout),candidates=orphanCandidates(rows,await ownPgid(runProbe),liveSessionPids),{marked,failed}=await markedPids(candidates.map((row)=>row.pid),deps);if(failed)return{orphans:[],error:`could not read process environments \u2014 ${failed}`};return{orphans:candidates.filter((row)=>marked.has(row.pid)),error:null}}function formatMb(rssKb){return`${(rssKb/1024).toFixed(0)} MB`}function orphanDoctorLines(orphans,error,cliName,killing=!1){if(error)return[`orphans: \u2717 ${error}`];if(orphans.length===0)return["orphans: \u2713 none \u2014 no processes left behind by a dead PTY session"];let totalMb=orphans.reduce((sum,row)=>sum+row.rssKb,0)/1024,lines=[`orphans: \u26A0 ${orphans.length} process(es) outlived the PTY session that spawned them (${totalMb.toFixed(0)} MB RSS)`," each is reparented to init, carries Rove's PTY marker, and its process"," group leader is gone \u2014 no live task owns them"];for(let row of[...orphans].sort((a,b)=>b.rssKb-a.rssKb))lines.push(` pid ${row.pid} (group ${row.pgid}) up ${row.etime}, ${formatMb(row.rssKb)}: ${row.command.slice(0,90)}`);if(!killing)lines.push(` \u2192 \`${cliName} doctor --kill-orphans\` ends those process groups (SIGTERM, then SIGKILL)`," read the list first: something you backgrounded from a Rove terminal and then"," closed the tab on looks exactly like a leak, and doctor cannot tell them apart");return lines}var GROUP_EXIT_GRACE_MS=2000,GROUP_POLL_MS=100;function logOrphanKill(pgid,signal,logPath=defaultDaemonLogPath()){try{appendFileSync(logPath,formatDaemonInfo("doctor-kill-orphans",`${signal} process group ${pgid}`))}catch{}}function groupAlive(pgid){try{return process.kill(-pgid,0),!0}catch(err){return err.code!=="ESRCH"}}async function killOrphanGroups(orphans){let groups=[...new Set(orphans.map((row)=>row.pgid))];for(let pgid of groups)try{process.kill(-pgid,"SIGTERM"),logOrphanKill(pgid,"SIGTERM")}catch{}let deadline=Date.now()+GROUP_EXIT_GRACE_MS,survivors=groups.filter(groupAlive);while(survivors.length>0&&Date.now()<deadline)await new Promise((resolve)=>setTimeout(resolve,GROUP_POLL_MS)),survivors=survivors.filter(groupAlive);for(let pgid of survivors)try{process.kill(-pgid,"SIGKILL"),logOrphanKill(pgid,"SIGKILL")}catch{}return await new Promise((resolve)=>setTimeout(resolve,GROUP_POLL_MS)),{groups,survivors:survivors.filter(groupAlive)}}function multiplexerLabel(env){if(env.TMUX)return"tmux";if(env.ZELLIJ)return"zellij";if(env.STY)return"screen";return"no"}function terminalEnvLines(env){let show=(v)=>v&&v.length>0?v:"(unset)",program=env.TERM_PROGRAM?`${env.TERM_PROGRAM}${env.TERM_PROGRAM_VERSION?` v${env.TERM_PROGRAM_VERSION}`:""}`:"(unset)";return[`terminal: TERM=${show(env.TERM)} TERM_PROGRAM=${program} COLORTERM=${show(env.COLORTERM)}`,` running inside a multiplexer: ${multiplexerLabel(env)}`]}function parseKittyProbeReply(data){let kitty=data.match(/\x1b\[\?(\d+)u/);if(kitty?.[1]!==void 0)return{kind:"supported",flags:Number.parseInt(kitty[1],10)};if(/\x1b\[\?[\d;]*c/.test(data))return{kind:"unsupported"};return null}function kittyProbeLine(result){switch(result.kind){case"supported":return` kitty keyboard protocol: \u2713 answered (flags=${result.flags})`;case"unsupported":return[" kitty keyboard protocol: \u2717 not supported \u2014 legacy key path"," (ctrl+h/ctrl+j arrive as C0 backspace/linefeed bytes; the"," split chords ctrl+\\ and ctrl+= cannot be encoded at all)"].join(`
|
|
5
5
|
`);case"no-response":return" kitty keyboard protocol: ? no reply (terminal ignored both the kitty query and DA1)";case"skipped":return` kitty keyboard protocol: skipped (${result.reason})`}}async function probeKittyKeyboard(timeoutMs=300){let stdin=process.stdin;if(!stdin.isTTY||!process.stdout.isTTY)return{kind:"skipped",reason:"not an interactive terminal"};let wasRaw=stdin.isRaw===!0,buffer="";return await new Promise((resolve)=>{let done=!1,finish=(result)=>{if(done)return;if(done=!0,clearTimeout(timer),stdin.off("data",onData),stdin.pause(),!wasRaw)stdin.setRawMode(!1);resolve(result)},onData=(chunk)=>{buffer+=chunk.toString("latin1");let decided=parseKittyProbeReply(buffer);if(decided)finish(decided)},timer=setTimeout(()=>finish({kind:"no-response"}),timeoutMs);stdin.setRawMode(!0),stdin.resume(),stdin.on("data",onData),process.stdout.write("\x1B[?u\x1B[c")})}async function terminalDoctorLines(){return[...terminalEnvLines(process.env),kittyProbeLine(await probeKittyKeyboard())]}async function probeGit(){try{let proc=Bun.spawn(["git","--version"],{stdin:"ignore",stdout:"pipe",stderr:"ignore"}),text=(await new Response(proc.stdout).text()).trim();if(await proc.exited===0&&text)return{line:`git: \u2713 ${text}`,found:!0}}catch{}return{line:"git: \u2717 not found on PATH",found:!1}}function binaryLabel(binary){return binary.found?`\u2713 ${binary.path}`:`\u2717 ${binary.error}`}async function probeEngines(){let statuses=await withEngineVersions(await detectEngineStatuses(await probeableEngineIds())),lines=["engines:"];for(let status of statuses){let account=describeAccount(status.account),name=`${status.vendor.padEnd(7)} `,version=status.version?` (${status.version})`:"";if(lines.push(` ${name}${binaryLabel(status.binary)}${version}${status.binary.found?` \u2014 ${account}`:""}`),status.accountError)lines.push(` \u26A0 ${status.accountError}`)}let{usable,signedOut}=summarizeEngines(statuses);return{lines,anyUsable:usable.length>0,signedOut}}var CLI_NAME=ROVE_PRODUCT_NAME;function isProcessAlive(pid){try{return process.kill(pid,0),!0}catch(err){return err.code==="EPERM"}}async function requestIfReachable(socketPath,name){let client=new RoveDaemonClient(socketPath);try{return await client.request(name,{})}catch{return null}finally{client.close()}}function fmtDuration(ms){let seconds=Math.floor(ms/1000);if(seconds<60)return`${seconds}s`;let minutes=Math.floor(seconds/60);if(minutes<60)return`${minutes}m ${seconds%60}s`;return`${Math.floor(minutes/60)}h ${minutes%60}m`}function describeFile(path){try{let stat=statSync2(path);return`present (${formatBytes(stat.size)}, modified ${stat.mtime.toISOString()})`}catch{return"absent"}}function taskCount(path){try{let parsed=JSON.parse(readFileSync2(path,"utf8"));return Array.isArray(parsed.tasks)?parsed.tasks.length:null}catch{return null}}function tailFile(path,count){try{return readFileSync2(path,"utf8").split(`
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{DAEMON_UNREACHABLE_MESSAGE,argvToParams,booleanFlagsOf,callVerb,errorBody,errorEnvelope,executeVerb,isDaemonUnreachable,paramsToFlags,repeatableFlagsOf,runVerb,successEnvelope,toApiError}from"./chunk-am70fwd0.js";import"./chunk-gafj4yp3.js";import"./chunk-t4reqv8m.js";import"./chunk-8hfkcjxm.js";import"./chunk-h9z9x14k.js";import"./chunk-j2k6f128.js";import"./chunk-38hnq4aq.js";import"./chunk-rset5pt8.js";import"./chunk-17e2tgyg.js";import"./chunk-2xsxcdp6.js";import"./chunk-79wejcs5.js";import"./chunk-6cggsxpr.js";import"./chunk-q8ffd1pc.js";import"./chunk-je7egpqh.js";import"./chunk-2bgmby1d.js";import"./chunk-5mhvjytn.js";import"./chunk-d1vv8xk6.js";import"./chunk-psxhek7n.js";import"./chunk-pf3nzz87.js";import"./chunk-xj3034s1.js";import"./chunk-mdx18vtz.js";import"./chunk-p4rhkv3k.js";import"./chunk-zc67sqet.js";import"./chunk-ejs6dnxf.js";import"./chunk-a6s52zm5.js";import"./chunk-y0e28qha.js";import"./chunk-qkehg2c1.js";import"./chunk-2x6s7z8w.js";import"./chunk-t7j8g9f6.js";import"./chunk-dmzg9zdc.js";import"./chunk-kg9kmwt9.js";import"./chunk-6xppe9bj.js";import"./chunk-s2eezz0a.js";import"./chunk-06vsvvtr.js";import"./chunk-zze1pw22.js";import"./chunk-0x62tvdk.js";import"./chunk-y0skz8j9.js";import"./chunk-mqfvzdpr.js";import"./chunk-4whghfgg.js";import"./chunk-rxqdw6s5.js";import"./chunk-xe3zr5b9.js";import"./chunk-gzn14mwk.js";import"./chunk-t7qj639x.js";import"./chunk-gz0x179r.js";import"./chunk-jz1kj4sf.js";import"./chunk-v8nbqjwc.js";import"./chunk-ws2q07kb.js";import"./chunk-g9ba25q5.js";import"./chunk-133c884f.js";import"./chunk-catrr0z3.js";import"./chunk-xjrkvksc.js";import"./chunk-tn9gtf18.js";import"./chunk-ahbw1f8n.js";import"./chunk-sak1tphp.js";import"./chunk-y1xnjx8x.js";import"./chunk-sffdpzfv.js";import"./chunk-5dv7pw3w.js";import"./chunk-2bapg0v2.js";import"./chunk-750rk2xz.js";import"./chunk-w7zv47mp.js";import"./chunk-cw9h73h5.js";import"./chunk-37g0yabr.js";import"./chunk-nw48bskt.js";import"./chunk-k7tdg6kb.js";import"./chunk-1pmzr8kr.js";import"./chunk-e5jxbd98.js";import"./chunk-84q9hv7m.js";import"./chunk-96kvwzj8.js";import"./chunk-etfh8f4z.js";import"./chunk-07665jz6.js";import"./chunk-40dgv828.js";import"./chunk-zsfyj36g.js";import"./chunk-1feav1w3.js";import"./chunk-9gctbddn.js";import"./chunk-mg1cas61.js";import"./chunk-yvg46jh9.js";import"./chunk-xasg8z9e.js";import"./chunk-8xdhw922.js";import"./chunk-cmp64q4j.js";import"./chunk-j152pk57.js";import"./chunk-c4dfktv2.js";import"./chunk-bdmbevk8.js";import"./chunk-7kysxgbq.js";import"./chunk-g755p68b.js";import"./chunk-tcmzq86w.js";import"./chunk-y8hjgmn0.js";import"./chunk-xy8be792.js";import"./chunk-h2m7em1e.js";import"./chunk-pn5ygqn6.js";import"./chunk-7ghwdjdc.js";import"./chunk-m5nd44st.js";import"./chunk-rxb0hw1e.js";import"./chunk-tw25g9g5.js";import"./chunk-yt15y085.js";import"./chunk-2z2jwetd.js";import"./chunk-8143k3t6.js";import"./chunk-zt7wfnva.js";import"./chunk-g6wb8p4p.js";import"./chunk-nc46gddg.js";import"./chunk-1mp632fj.js";import"./chunk-91sykzqq.js";export{toApiError,successEnvelope,runVerb,repeatableFlagsOf,paramsToFlags,isDaemonUnreachable,executeVerb,errorEnvelope,errorBody,callVerb,booleanFlagsOf,argvToParams,DAEMON_UNREACHABLE_MESSAGE};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{MachineFeed,decodeMachines}from"./chunk-
|
|
2
|
+
import{MachineFeed,decodeMachines}from"./chunk-2gpr5dm4.js";import"./chunk-b7rxn7c9.js";import"./chunk-n15p38e5.js";import"./chunk-6xr1prk6.js";import"./chunk-mdx18vtz.js";import"./chunk-ejs6dnxf.js";import"./chunk-a6s52zm5.js";import"./chunk-55ajzrj6.js";import"./chunk-t7j8g9f6.js";import"./chunk-dmzg9zdc.js";import"./chunk-6xppe9bj.js";import"./chunk-s2eezz0a.js";import"./chunk-y1xnjx8x.js";import"./chunk-cw9h73h5.js";import"./chunk-37g0yabr.js";import"./chunk-k7tdg6kb.js";import"./chunk-1pmzr8kr.js";import"./chunk-e5jxbd98.js";import"./chunk-84q9hv7m.js";import"./chunk-96kvwzj8.js";import"./chunk-40dgv828.js";import"./chunk-xasg8z9e.js";import"./chunk-cmp64q4j.js";import"./chunk-7kysxgbq.js";import"./chunk-y8hjgmn0.js";import"./chunk-xy8be792.js";import"./chunk-pn5ygqn6.js";import"./chunk-rxb0hw1e.js";import"./chunk-tw25g9g5.js";import"./chunk-yt15y085.js";import"./chunk-2z2jwetd.js";import"./chunk-8143k3t6.js";import"./chunk-zt7wfnva.js";import"./chunk-g6wb8p4p.js";import"./chunk-nc46gddg.js";import"./chunk-91sykzqq.js";export{decodeMachines,MachineFeed};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{ensureForwards,startTunnel}from"./chunk-
|
|
2
|
+
import{ensureForwards,startTunnel}from"./chunk-ejs6dnxf.js";import"./chunk-a6s52zm5.js";import"./chunk-y1xnjx8x.js";import"./chunk-cw9h73h5.js";import"./chunk-37g0yabr.js";import"./chunk-84q9hv7m.js";import"./chunk-96kvwzj8.js";import"./chunk-xasg8z9e.js";import"./chunk-7kysxgbq.js";import"./chunk-y8hjgmn0.js";import"./chunk-pn5ygqn6.js";import"./chunk-rxb0hw1e.js";import"./chunk-tw25g9g5.js";import"./chunk-yt15y085.js";import"./chunk-2z2jwetd.js";import"./chunk-8143k3t6.js";import"./chunk-zt7wfnva.js";import"./chunk-g6wb8p4p.js";import"./chunk-nc46gddg.js";import"./chunk-91sykzqq.js";export{startTunnel,ensureForwards};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{bundledSkillDir,installSkill,installedSkillDiffersFromBundled,skillOverview,skillTargets}from"./chunk-
|
|
2
|
+
import{bundledSkillDir,installSkill,installedSkillDiffersFromBundled,skillOverview,skillTargets}from"./chunk-cvcp1aye.js";import{SUBCOMMAND_VERBS}from"./chunk-6jxe4f13.js";import"./chunk-5dv7pw3w.js";import"./chunk-2bapg0v2.js";import"./chunk-750rk2xz.js";import"./chunk-w7zv47mp.js";import"./chunk-cw9h73h5.js";import"./chunk-37g0yabr.js";import"./chunk-nw48bskt.js";import"./chunk-k7tdg6kb.js";import"./chunk-1pmzr8kr.js";import"./chunk-e5jxbd98.js";import"./chunk-84q9hv7m.js";import"./chunk-96kvwzj8.js";import"./chunk-07665jz6.js";import"./chunk-40dgv828.js";import"./chunk-9gctbddn.js";import"./chunk-mg1cas61.js";import"./chunk-yvg46jh9.js";import"./chunk-xasg8z9e.js";import"./chunk-j152pk57.js";import"./chunk-c4dfktv2.js";import"./chunk-bdmbevk8.js";import"./chunk-7kysxgbq.js";import"./chunk-g755p68b.js";import"./chunk-tcmzq86w.js";import"./chunk-y8hjgmn0.js";import"./chunk-xy8be792.js";import"./chunk-h2m7em1e.js";import"./chunk-pn5ygqn6.js";import"./chunk-7ghwdjdc.js";import"./chunk-m5nd44st.js";import"./chunk-rxb0hw1e.js";import"./chunk-tw25g9g5.js";import"./chunk-yt15y085.js";import"./chunk-2z2jwetd.js";import"./chunk-8143k3t6.js";import{ROVE_PRODUCT_NAME}from"./chunk-zt7wfnva.js";import"./chunk-g6wb8p4p.js";import"./chunk-nc46gddg.js";import"./chunk-91sykzqq.js";import{readFileSync}from"fs";import{join}from"path";var CLI_NAME=ROVE_PRODUCT_NAME,SKILL_VERBS=SUBCOMMAND_VERBS.skill;function skillUsage(){return[`usage: ${CLI_NAME} skill <verb>`,"","verbs:"," install [--agent ENGINE]\u2026 Copy the Rove agent skill into every engine set up on this machine"," status Show which engines have the skill, and whether it is current",` print Print the bundled SKILL.md (also: \`${CLI_NAME} --skill\`)`,"",`The skill teaches a coding agent how to drive \`${CLI_NAME} api\`. Installs are`,"user-level. --agent takes a Rove engine id (claude, codex, \u2026) and may repeat.","Installed copies refresh themselves when Rove upgrades."].join(`
|
|
3
3
|
`)}function fail(message){process.stderr.write(`${CLI_NAME} skill: ${message}
|
|
4
4
|
`),process.exit(2)}function parseAgents(rest){let agents=[];for(let i=0;i<rest.length;i++){let arg=rest[i];if(arg==="--agent"){let v=rest[i+1];if(!v||v.startsWith("--"))fail("--agent requires a value");agents.push(v),i++}else if(arg.startsWith("--agent="))agents.push(arg.slice(8));else fail(`unknown flag "${arg}"
|
|
5
5
|
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{__require}from"./chunk-91sykzqq.js";var welcomeWrite=Promise.resolve();function trackWelcomeWrite(write){welcomeWrite=write}async function launchTui(){let{startTui}=await import("./chunk-
|
|
2
|
+
import{__require}from"./chunk-91sykzqq.js";var welcomeWrite=Promise.resolve();function trackWelcomeWrite(write){welcomeWrite=write}async function launchTui(){let{startTui}=await import("./chunk-29e7x3qx.js");await startTui(),await welcomeWrite;let{runPendingWelcomeInstalls}=await import("./chunk-3t3fp5h4.js");runPendingWelcomeInstalls()}
|
|
3
3
|
export{trackWelcomeWrite,launchTui};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Orchestrator}from"./chunk-7ezpcrkf.js";import"./chunk-zp4efbtb.js";import"./chunk-n8z4nb8v.js";import"./chunk-a5ehejp6.js";import"./chunk-ak0ezn5t.js";import"./chunk-4dt1gfb3.js";import"./chunk-xmwp6je4.js";import{PLACEHOLDER_TASK_TITLE}from"./chunk-2xsxcdp6.js";import"./chunk-79wejcs5.js";import"./chunk-zc67sqet.js";import"./chunk-ejs6dnxf.js";import"./chunk-a6s52zm5.js";import"./chunk-y0e28qha.js";import"./chunk-2x6s7z8w.js";import"./chunk-t7j8g9f6.js";import"./chunk-dmzg9zdc.js";import"./chunk-6xppe9bj.js";import"./chunk-mqfvzdpr.js";import"./chunk-t7qj639x.js";import"./chunk-gz0x179r.js";import"./chunk-jz1kj4sf.js";import"./chunk-v8nbqjwc.js";import"./chunk-ws2q07kb.js";import"./chunk-g9ba25q5.js";import"./chunk-133c884f.js";import"./chunk-catrr0z3.js";import"./chunk-xjrkvksc.js";import"./chunk-tn9gtf18.js";import"./chunk-ahbw1f8n.js";import"./chunk-sak1tphp.js";import"./chunk-y1xnjx8x.js";import"./chunk-sffdpzfv.js";import"./chunk-5dv7pw3w.js";import"./chunk-2bapg0v2.js";import"./chunk-750rk2xz.js";import"./chunk-w7zv47mp.js";import"./chunk-cw9h73h5.js";import"./chunk-37g0yabr.js";import"./chunk-nw48bskt.js";import"./chunk-k7tdg6kb.js";import"./chunk-1pmzr8kr.js";import"./chunk-e5jxbd98.js";import"./chunk-84q9hv7m.js";import"./chunk-96kvwzj8.js";import"./chunk-07665jz6.js";import"./chunk-40dgv828.js";import"./chunk-zsfyj36g.js";import"./chunk-1feav1w3.js";import"./chunk-9gctbddn.js";import"./chunk-mg1cas61.js";import"./chunk-yvg46jh9.js";import"./chunk-xasg8z9e.js";import"./chunk-8xdhw922.js";import"./chunk-cmp64q4j.js";import"./chunk-j152pk57.js";import"./chunk-c4dfktv2.js";import"./chunk-bdmbevk8.js";import"./chunk-7kysxgbq.js";import"./chunk-g755p68b.js";import"./chunk-tcmzq86w.js";import"./chunk-y8hjgmn0.js";import"./chunk-xy8be792.js";import"./chunk-h2m7em1e.js";import"./chunk-pn5ygqn6.js";import"./chunk-7ghwdjdc.js";import"./chunk-m5nd44st.js";import"./chunk-rxb0hw1e.js";import"./chunk-tw25g9g5.js";import"./chunk-yt15y085.js";import"./chunk-2z2jwetd.js";import"./chunk-8143k3t6.js";import"./chunk-zt7wfnva.js";import"./chunk-g6wb8p4p.js";import"./chunk-nc46gddg.js";import"./chunk-1mp632fj.js";import"./chunk-91sykzqq.js";export{PLACEHOLDER_TASK_TITLE,Orchestrator};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{shQuote}from"./chunk-y1xnjx8x.js";import{WINDOWS_LOCATE_ROVE,WINDOWS_ROVE_MISSING,WINDOWS_SCRIPTS_DISABLED,WINDOWS_SSHD_BANNER,WINDOWS_SSHD_STEPS,isWindowsMachine,isWindowsPath,windowsNoRoveMessage,windowsRoveCommand}from"./chunk-cw9h73h5.js";import{machineSocketDir,machineSshArgs,sshTargetOf}from"./chunk-37g0yabr.js";import{PRE_RENAME_VERSION_KEY}from"./chunk-g6wb8p4p.js";import{spawn}from"child_process";import{mkdirSync}from"fs";import{posix}from"path";var PATTERNS=[["host-key-changed",/REMOTE HOST IDENTIFICATION HAS CHANGED|Host key for .* has changed/i],["host-key-unverified",/Host key verification failed|No .*host key is known for/i],["auth-denied",/Permission denied \(|Too many authentication failures|no matching host key type/i],["unresolved",/Could not resolve hostname|Name or service not known|nodename nor servname/i],["refused",/Connection refused/i],["timeout",/timed out|Operation timed out|No route to host|Network is unreachable/i]];function classifySshFailure(stderr){for(let[kind,pattern]of PATTERNS)if(pattern.test(stderr))return kind;return"unknown"}function sshFailureRemedy(kind,target,windows=!1){if(windows&&(kind==="refused"||kind==="timeout"))return[`${target} (Windows) ${kind==="refused"?"refused the connection: its OpenSSH Server is not running":"did not answer on the ssh port: its OpenSSH Server is off, or the firewall drops it"}.`,"In an elevated PowerShell there:",...WINDOWS_SSHD_STEPS.map((step)=>` ${step}`)].join(`
|
|
3
3
|
`);if(windows&&kind==="auth-denied")return`${target} (Windows) rejected every key ssh offered. For an Administrators account, OpenSSH for Windows reads only %ProgramData%\\ssh\\administrators_authorized_keys; ~\\.ssh\\authorized_keys is ignored.`;switch(kind){case"unresolved":return`${target} does not resolve to an address. Check the name, or the Host block in ~/.ssh/config; on a tailnet, check \`tailscale status\`.`;case"refused":return`${target} refused the connection: nothing listens for ssh there. Enable Remote Login / start sshd on it (Windows: \`Start-Service sshd\`, elevated), or pass the right --port.`;case"timeout":return`${target} did not answer. Is it awake and on this network (or VPN / tailnet)?`;case"host-key-changed":return`${target}'s host key CHANGED since you last connected. That is either a reinstall or someone in the middle. If you reinstalled it, remove the old key with \`ssh-keygen -R <host>\` and retry; otherwise stop here.`;case"host-key-unverified":return`${target}'s host key is not trusted yet. Run \`rove machine add\` in a terminal to confirm its fingerprint, or connect once with \`ssh ${target}\`.`;case"auth-denied":return`${target} rejected every key ssh offered. Load your key into ssh-agent, pass --identity <key>, or install a key there with \`ssh-copy-id ${target}\`.`;case"unknown":return`ssh to ${target} failed. Run \`ssh ${target} true\` to see why.`}}async function runOnMachine(alias,config,command,opts={}){try{mkdirSync(machineSocketDir(alias,opts.home),{recursive:!0,mode:448})}catch{}let base=machineSshArgs(alias,config,{home:opts.home,mux:opts.sshFlags===void 0}),argv=[base[0]??"ssh",...opts.sshFlags??[],...base.slice(1),command];return await new Promise((resolve)=>{let stdout="",stderr="",settled=!1,done=(exitCode)=>{if(settled)return;settled=!0,clearTimeout(timer),resolve({stdout,stderr,exitCode})},child=spawn(argv[0]??"ssh",argv.slice(1),{stdio:["ignore","pipe","pipe"]}),timer=setTimeout(()=>{child.kill("SIGKILL"),stderr+=`
|
|
4
4
|
timed out`,done(-1)},opts.timeoutMs??30000);child.stdout?.on("data",(c)=>{stdout+=c.toString()}),child.stderr?.on("data",(c)=>{stderr+=c.toString()}),child.on("error",()=>done(-1)),child.on("close",(code)=>done(code??-1))})}function unansweringDaemonPid(stdout){let match=/\(stale pidfile pid=(\d+)\)/.exec(stdout);return match?Number(match[1]):null}async function discoverMachine(alias,config,opts={}){let found=await probe(alias,config,config.roveBin,opts);if(found.ok||found.code!=="NO_ROVE")return found;let locate=found.windows?WINDOWS_LOCATE_ROVE:LOCATE_ROVE_SCRIPT,located=parseLocatedRove((await runOnMachine(alias,config,locate,opts)).stdout);if(!located||located===config.roveBin)return found;let retry=await probe(alias,config,located,opts);return retry.ok?{...retry,roveBin:located}:retry}function learnedFrom(found){return{sockets:{daemon:found.status.socketPath,pty:found.status.ptySocketPath},...found.roveBin?{roveBin:found.roveBin}:{},...found.status.relayPreamble?{relayPreamble:!0}:{}}}function remoteRove(roveBin,args){if(roveBin&&isWindowsPath(roveBin))return windowsRoveCommand(roveBin,args);return[roveCommand(roveBin),...args].join(" ")}function roveCommand(roveBin){if(!roveBin)return"rove";return`PATH=${shQuote(posix.dirname(roveBin))}:"$PATH" ${shQuote(roveBin)}`}var LOCATE_ROVE_SCRIPT=[`p=$("\${SHELL:-sh}" -lc 'command -v rove' 2>/dev/null)`,'if [ -n "$p" ] && [ -x "$p" ]; then echo "ROVE_BIN=$p"; exit 0; fi','for p in "$HOME/.bun/bin/rove" "$HOME/.npm-global/bin/rove" "$HOME/.local/bin/rove" /opt/homebrew/bin/rove /usr/local/bin/rove "$HOME"/.nvm/versions/node/*/bin/rove; do',' if [ -x "$p" ]; then echo "ROVE_BIN=$p"; exit 0; fi',"done","exit 1"].join(`
|
|
5
5
|
`);function parseLocatedRove(stdout){return/^ROVE_BIN=((?:\/|[A-Za-z]:\\)\S.*)$/m.exec(stdout)?.[1]?.trim()??null}var ROVE_MISSING=/(?:^|\W)rove:? (?:command not found|not found)|command not found:? rove|\/rove:? No such file or directory|no such file or directory: \S*\/rove\b/i;async function probe(alias,config,roveBin,opts){let status=remoteRove(roveBin,["daemon","status","--json"]),first=await runOnMachine(alias,config,status,opts),parsed=parseStatusJson(first.stdout);if(parsed)return withNoise(windowsReady(alias,parsed),first.stdout);let combined=`${first.stdout}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{__require}from"./chunk-91sykzqq.js";var CHANNEL_LOADERS={weixin:async()=>(await import("./chunk-
|
|
2
|
+
import{__require}from"./chunk-91sykzqq.js";var CHANNEL_LOADERS={weixin:async()=>(await import("./chunk-2nddryb2.js")).default};async function runChannelCli(id,argv){let load=CHANNEL_LOADERS[id];if(!load)throw Error(`no chat channel "${id}"`);await(await load()).runCli(argv)}async function startChatChannels(ctx){let started=[];for(let[id,load]of Object.entries(CHANNEL_LOADERS))try{let channel=(await load()).createChannel();await channel.start(ctx),started.push(channel)}catch(err){ctx.log("channel",`${id} did not start: ${err instanceof Error?err.message:String(err)}`)}return started}
|
|
3
3
|
export{runChannelCli,startChatChannels};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{INBOUND_CLASSES,INBOUND_KEY,deniedClasses,inboundClassOf,inboundRefusal,setInbound}from"./chunk-d35ctfpd.js";import"./chunk-gafj4yp3.js";import"./chunk-t4reqv8m.js";import"./chunk-8hfkcjxm.js";import"./chunk-h9z9x14k.js";import"./chunk-j2k6f128.js";import"./chunk-38hnq4aq.js";import"./chunk-rset5pt8.js";import"./chunk-17e2tgyg.js";import"./chunk-2xsxcdp6.js";import"./chunk-79wejcs5.js";import"./chunk-6cggsxpr.js";import"./chunk-q8ffd1pc.js";import"./chunk-je7egpqh.js";import"./chunk-2bgmby1d.js";import"./chunk-5mhvjytn.js";import"./chunk-d1vv8xk6.js";import"./chunk-psxhek7n.js";import"./chunk-pf3nzz87.js";import"./chunk-xj3034s1.js";import"./chunk-mdx18vtz.js";import"./chunk-p4rhkv3k.js";import"./chunk-zc67sqet.js";import"./chunk-ejs6dnxf.js";import"./chunk-a6s52zm5.js";import"./chunk-y0e28qha.js";import"./chunk-qkehg2c1.js";import"./chunk-2x6s7z8w.js";import"./chunk-t7j8g9f6.js";import"./chunk-dmzg9zdc.js";import"./chunk-kg9kmwt9.js";import"./chunk-6xppe9bj.js";import"./chunk-s2eezz0a.js";import"./chunk-06vsvvtr.js";import"./chunk-zze1pw22.js";import"./chunk-0x62tvdk.js";import"./chunk-y0skz8j9.js";import"./chunk-mqfvzdpr.js";import"./chunk-4whghfgg.js";import"./chunk-rxqdw6s5.js";import"./chunk-xe3zr5b9.js";import"./chunk-gzn14mwk.js";import"./chunk-t7qj639x.js";import"./chunk-gz0x179r.js";import"./chunk-jz1kj4sf.js";import"./chunk-v8nbqjwc.js";import"./chunk-ws2q07kb.js";import"./chunk-g9ba25q5.js";import"./chunk-133c884f.js";import"./chunk-catrr0z3.js";import"./chunk-xjrkvksc.js";import"./chunk-tn9gtf18.js";import"./chunk-ahbw1f8n.js";import"./chunk-sak1tphp.js";import"./chunk-y1xnjx8x.js";import"./chunk-sffdpzfv.js";import"./chunk-5dv7pw3w.js";import"./chunk-2bapg0v2.js";import"./chunk-750rk2xz.js";import"./chunk-w7zv47mp.js";import"./chunk-cw9h73h5.js";import"./chunk-37g0yabr.js";import"./chunk-nw48bskt.js";import"./chunk-k7tdg6kb.js";import"./chunk-1pmzr8kr.js";import"./chunk-e5jxbd98.js";import"./chunk-84q9hv7m.js";import"./chunk-96kvwzj8.js";import"./chunk-etfh8f4z.js";import"./chunk-07665jz6.js";import"./chunk-40dgv828.js";import"./chunk-zsfyj36g.js";import"./chunk-1feav1w3.js";import"./chunk-9gctbddn.js";import"./chunk-mg1cas61.js";import"./chunk-yvg46jh9.js";import"./chunk-xasg8z9e.js";import"./chunk-8xdhw922.js";import"./chunk-cmp64q4j.js";import"./chunk-j152pk57.js";import"./chunk-c4dfktv2.js";import"./chunk-bdmbevk8.js";import"./chunk-7kysxgbq.js";import"./chunk-g755p68b.js";import"./chunk-tcmzq86w.js";import"./chunk-y8hjgmn0.js";import"./chunk-xy8be792.js";import"./chunk-h2m7em1e.js";import"./chunk-pn5ygqn6.js";import"./chunk-7ghwdjdc.js";import"./chunk-m5nd44st.js";import"./chunk-rxb0hw1e.js";import"./chunk-tw25g9g5.js";import"./chunk-yt15y085.js";import"./chunk-2z2jwetd.js";import"./chunk-8143k3t6.js";import"./chunk-zt7wfnva.js";import"./chunk-g6wb8p4p.js";import"./chunk-nc46gddg.js";import"./chunk-1mp632fj.js";import"./chunk-91sykzqq.js";export{setInbound,inboundRefusal,inboundClassOf,deniedClasses,INBOUND_KEY,INBOUND_CLASSES};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{REPEAT_SEP,VerbArgs,defaultApiRuntime,findVerb,parseFlags,unknownVerbError,validateAgainstSpec}from"./chunk-
|
|
2
|
+
import{REPEAT_SEP,VerbArgs,defaultApiRuntime,findVerb,parseFlags,unknownVerbError,validateAgainstSpec}from"./chunk-gafj4yp3.js";import{ensurePluginEnginesLoaded}from"./chunk-8hfkcjxm.js";import{REPO_HAS_NO_COMMITS_CODE,REPO_HAS_NO_COMMITS_HINT}from"./chunk-79wejcs5.js";import{ApiError,cliCaller,requireVerbInstalled,splitDaemonCode}from"./chunk-jz1kj4sf.js";import{ROVE_API_VERSION}from"./chunk-96kvwzj8.js";import{errorMessage}from"./chunk-9gctbddn.js";var DAEMON_UNREACHABLE_MESSAGE="the rove daemon is not answering (restarting or stopped); nothing was changed, try again in a moment";function isDaemonUnreachable(err){if(!err||typeof err!=="object"||!("code"in err))return!1;if(err.code==="DAEMON_UNREACHABLE")return!0;return"syscall"in err&&err.syscall==="connect"&&(err.code==="ENOENT"||err.code==="ECONNREFUSED")}function toApiError(err){if(err instanceof ApiError)return err;if(isDaemonUnreachable(err))return new ApiError(DAEMON_UNREACHABLE_MESSAGE,"DAEMON_UNREACHABLE");let message=errorMessage(err);if(/task not found/i.test(message))return new ApiError(message,"TASK_NOT_FOUND",{hint:"that task id does not exist (deleted or mistyped) \u2014 list live tasks and retry with a real id",nextCommandArgs:["api","list"]});if(/unknown daemon request:/i.test(message))return versionSkewError(message);let coded=splitDaemonCode(message);if(coded?.code===REPO_HAS_NO_COMMITS_CODE)return new ApiError(coded.rest,coded.code,{hint:REPO_HAS_NO_COMMITS_HINT});if(coded)return new ApiError(coded.rest,coded.code);return new ApiError(message,"RPC_ERROR")}function versionSkewError(message){return new ApiError(message,"DAEMON_VERSION_SKEW",{hint:"the running daemon is a different build than this CLI, so it does not serve this verb \u2014 restart the daemon to pick up this build, then retry (if the verb is gone for good, `rove api schema` lists what this daemon actually serves)",nextCommandArgs:["daemon","restart"]})}function errorBody(err){return{message:err.message,code:err.code,...err.data}}function successEnvelope(result){return{apiVersion:ROVE_API_VERSION,ok:!0,result}}function errorEnvelope(err){return{apiVersion:ROVE_API_VERSION,ok:!1,error:errorBody(toApiError(err))}}function flagText(name,spec,value){let type=spec?.type;if(typeof value==="string")return value;if(spec?.repeatable&&Array.isArray(value)&&value.every((item)=>typeof item==="string"))return value.join(REPEAT_SEP);if(typeof value==="boolean"&&(type==="bool"||type===void 0))return String(value);if(typeof value==="number"&&(type==="int"||type==="uint"||type===void 0))return String(value);if(Array.isArray(value)&&(type==="csv"||type===void 0)){if(!value.every((item)=>typeof item==="string"&&!item.includes(",")))throw new ApiError(`param ${name} must be a list of strings without ","`,"BAD_FLAG");return value.join(",")}throw new ApiError(`param ${name} does not fit its ${type} flag`,"BAD_FLAG")}function paramsToFlags(verb,params){let flags=new Map;for(let[name,value]of Object.entries(params))flags.set(name,flagText(name,verb.flags.find((f)=>f.name===name),value));return flags}function booleanFlagsOf(verb){return new Set(verb.flags.filter((f)=>f.type==="bool").map((f)=>f.name))}function repeatableFlagsOf(verb){return new Set(verb.flags.filter((f)=>f.repeatable).map((f)=>f.name))}async function callVerb(verb,flags,deps){requireVerbInstalled(verb);let caller=deps.caller??cliCaller();try{return await verb.handler({args:new VerbArgs(verb,flags,caller),caller,client:deps.client,runtime:deps.runtime??defaultApiRuntime})}catch(err){throw toApiError(err)}}async function runVerb(verbName,input,deps){ensurePluginEnginesLoaded();let verb=findVerb(verbName);if(!verb)throw unknownVerbError(verbName);if(verb.cliOnly&&!(deps.caller??cliCaller()).cli)throw new ApiError(`"${verbName}" streams over stdout/stdin, so only \`rove api\` can run it`,"CLI_ONLY_VERB",{hint:"run it as a CLI command on the machine whose daemon you are talking to"});let flags="argv"in input?parseFlags(input.argv,booleanFlagsOf(verb),repeatableFlagsOf(verb)).flags:paramsToFlags(verb,input.params);return validateAgainstSpec(verb,flags),callVerb(verb,flags,deps)}async function executeVerb(verbName,input,deps){try{return successEnvelope(await runVerb(verbName,input,deps))}catch(err){return errorEnvelope(err)}}function argvToParams(verbName,argv){let verb=findVerb(verbName);if(!verb)throw unknownVerbError(verbName);let{flags}=parseFlags(argv,booleanFlagsOf(verb),repeatableFlagsOf(verb));return Object.fromEntries(flags)}
|
|
3
3
|
export{DAEMON_UNREACHABLE_MESSAGE,isDaemonUnreachable,toApiError,errorBody,successEnvelope,errorEnvelope,paramsToFlags,booleanFlagsOf,repeatableFlagsOf,callVerb,runVerb,executeVerb,argvToParams};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{RemoteOrchestrator}from"./chunk-
|
|
2
|
+
import{RemoteOrchestrator}from"./chunk-n15p38e5.js";import{startTunnel}from"./chunk-ejs6dnxf.js";import{discoverMachine,learnedFrom}from"./chunk-a6s52zm5.js";import{dedupeMachines,duplicateAliasOf,listMachines,readMachines,setMachineIdentity,updateMachine}from"./chunk-37g0yabr.js";import{RoveDaemonClient}from"./chunk-84q9hv7m.js";import{loadStateFile}from"./chunk-xasg8z9e.js";import{createStateCell}from"./chunk-cmp64q4j.js";import{logClient,logClientError}from"./chunk-y8hjgmn0.js";function discoverReason(failure){switch(failure.code){case"SSH_FAILED":return!failure.ssh||failure.ssh==="unknown"?"ssh-failed":failure.ssh;case"NO_ROVE":return"no-rove";case"NO_DAEMON":return"no-daemon";default:return"bad-status"}}var NO_LIVE={activity:new Map,changes:new Map,tokens:new Map},PEER_CHANNELS=["task.snapshot","engine-state","worktree.changes","task.tokens"];class MachineHub{slots=new Map;machinesAcc=createStateCell([],"machines.status");tasksAcc=createStateCell([],"machines.tasks");liveAcc=createStateCell(NO_LIVE,"machines.live");disposed=!1;machinesSignal(){return this.machinesAcc}tasksSignal(){return this.tasksAcc}liveSignal(){return this.liveAcc}remoteTaskIds(){let ids=new Set;for(let slot of this.slots.values())for(let task of slot.tasks)ids.add(String(task.id));return ids}sync(entries=dedupeMachines(listMachines())){if(this.disposed)return;let wanted=new Map(entries.map((entry)=>[entry.alias,entry])),fresh=[];for(let[alias,slot]of this.slots){let next=wanted.get(alias);if(next&&sameAddress(slot.entry,next))slot.entry=next;else this.drop(alias)}for(let entry of entries){if(this.slots.has(entry.alias))continue;this.slots.set(entry.alias,{entry,tasks:[]}),fresh.push(entry)}if(fresh.length===0&&wanted.size===this.slots.size&&this.machinesAcc.get().length===wanted.size)return;let known=new Map(this.machinesAcc.get().map((row)=>[row.alias,row]));this.machinesAcc.set([...this.slots.values()].map((slot)=>known.get(slot.entry.alias)??{alias:slot.entry.alias,hostLabel:slot.entry.alias,state:"connecting"})),this.republishTasks(),this.republishLive();for(let entry of fresh)this.connect(entry)}drop(alias){let slot=this.slots.get(alias);if(!slot)return;this.slots.delete(alias),slot.unsubscribe?.(),slot.orchestrator?.dispose(),slot.tunnel?.stop()}async connect(entry){let slot=this.slots.get(entry.alias);if(!slot||this.disposed)return;let found=await discoverMachine(entry.alias,entry);if(this.disposed||this.slots.get(entry.alias)!==slot)return;let sockets=found.ok?{daemon:found.status.socketPath,pty:found.status.ptySocketPath}:entry.sockets,failed=found.ok?{}:{error:found.message,reason:discoverReason(found)};if(!sockets){this.setStatus(entry.alias,{state:"offline",...failed});return}if(!found.ok)this.setStatus(entry.alias,failed);let learned=found.ok?learnedFrom(found):{};if(found.ok)updateMachine(entry.alias,learned);let tunnel=startTunnel({alias:entry.alias,config:{...entry,...learned,sockets},remoteDaemonSocket:sockets.daemon,remotePtySocket:sockets.pty});if(slot.tunnel=tunnel,tunnel.state()==="unsupported"){this.setStatus(entry.alias,{state:"unsupported",error:"SSH unix-socket forwarding is not available on Windows",reason:"no-forwarding"});return}if(tunnel.onState((state)=>{if(this.slots.get(entry.alias)!==slot)return;if(state==="online")this.openOrchestrator(entry,tunnel);else if(state==="offline"){let known=this.machinesAcc.get().find((row)=>row.alias===entry.alias)?.reason;this.setStatus(entry.alias,{state:"offline",reason:known??"lost"}),this.republishTasks()}}),tunnel.state()==="online")await this.openOrchestrator(entry,tunnel)}async openOrchestrator(entry,tunnel){let slot=this.slots.get(entry.alias);if(!slot||this.disposed||slot.orchestrator)return;let client=new RoveDaemonClient(tunnel.daemonSocketPath),orchestrator=new RemoteOrchestrator(client,{role:"gui",channels:PEER_CHANNELS,expectForeignHome:!0,onPeerIdentity:(peer)=>this.onPeerIdentity(entry.alias,peer)});slot.orchestrator=orchestrator;try{if(await orchestrator.init(),this.slots.get(entry.alias)!==slot)return}catch(err){let message=err instanceof Error?err.message:String(err);this.setStatus(entry.alias,{state:classifyHandshakeFailure(message),error:message,reason:"handshake"}),logClientError("machines",err);return}let stopTasks=orchestrator.tasksSignal().subscribe(()=>{slot.tasks=orchestrator.tasksSignal().get(),this.republishTasks()}),stopConnection=orchestrator.connectionStateSignal().subscribe(()=>{let connected=orchestrator.connectionStateSignal().get()==="online";if(this.slots.get(entry.alias)!==slot)return;this.setStatus(entry.alias,connected?{state:"online",error:void 0,reason:void 0}:{state:"offline",reason:"lost"}),this.republishTasks()}),live=[orchestrator.engineStateSignal(),orchestrator.worktreeChangesSignal(),orchestrator.rowTokensSignal()].map((signal)=>signal.subscribe(()=>this.republishLive()));slot.unsubscribe=()=>{stopTasks(),stopConnection();for(let stop of live)stop()},slot.tasks=orchestrator.tasksSignal().get(),this.setStatus(entry.alias,{state:"online",version:orchestrator.daemonVersionSignal().get()??void 0,error:void 0,reason:void 0}),this.republishTasks(),this.republishLive(),logClient("machines",`${entry.alias} online (${slot.tasks.length} tasks)`)}republishLive(){let activity=new Map,changes=new Map,tokens=new Map;for(let slot of this.slots.values()){let o=slot.orchestrator;if(!o)continue;for(let[id,state]of o.engineStateSignal().get())activity.set(id,state);for(let[path,change]of o.worktreeChangesSignal().get()??[])changes.set(path,change);for(let[id,chips]of o.rowTokensSignal().get())tokens.set(id,chips)}this.liveAcc.set({activity,changes,tokens})}onPeerIdentity(alias,peer){if(!peer.hostname&&!peer.homeDir)return;let identity={hostname:peer.hostname,homeDir:peer.homeDir,daemonPid:peer.daemonPid};setMachineIdentity(alias,identity);let duplicate=duplicateAliasOf(readMachines(loadStateFile()),alias,identity);this.setStatus(alias,{hostname:peer.hostname||void 0,version:peer.roveVersion||void 0,...duplicate?{duplicateOf:duplicate}:{}})}setStatus(alias,patch){let next=this.machinesAcc.get().map((row)=>row.alias===alias?{...row,...patch}:row);this.machinesAcc.set(next)}republishTasks(){let merged=[];for(let slot of this.slots.values()){let status=this.machinesAcc.get().find((row)=>row.alias===slot.entry.alias);if(status?.duplicateOf)continue;let hostLabel=status?.hostLabel||slot.entry.alias,stale=status?.state!=="online";for(let task of slot.tasks)merged.push(stampOrigin(task,slot.entry.alias,hostLabel,stale))}this.tasksAcc.set(merged)}dispose(){this.disposed=!0;for(let alias of[...this.slots.keys()])this.drop(alias)}}function classifyHandshakeFailure(message){return/protocol v\d/i.test(message)?"mismatch":"offline"}function sameAddress(a,b){return a.host===b.host&&a.user===b.user&&a.port===b.port&&JSON.stringify(a.auth)===JSON.stringify(b.auth)}function stampOrigin(task,machineId,hostLabel,stale=!1){return{...task,origin:{machineId,hostLabel,...stale?{stale:!0}:{}}}}
|
|
3
3
|
export{MachineHub,stampOrigin};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{ensureGlobalRoveHooks,readStdinText,readTextWithTimeout,runHookSubcommand}from"./chunk-nhsem71y.js";import"./chunk-17e2tgyg.js";import"./chunk-2bgmby1d.js";import"./chunk-psxhek7n.js";import"./chunk-ws2q07kb.js";import"./chunk-5dv7pw3w.js";import"./chunk-2bapg0v2.js";import"./chunk-750rk2xz.js";import"./chunk-w7zv47mp.js";import"./chunk-cw9h73h5.js";import"./chunk-37g0yabr.js";import"./chunk-nw48bskt.js";import"./chunk-k7tdg6kb.js";import"./chunk-1pmzr8kr.js";import"./chunk-e5jxbd98.js";import"./chunk-84q9hv7m.js";import"./chunk-96kvwzj8.js";import"./chunk-07665jz6.js";import"./chunk-40dgv828.js";import"./chunk-zsfyj36g.js";import"./chunk-9gctbddn.js";import"./chunk-mg1cas61.js";import"./chunk-yvg46jh9.js";import"./chunk-xasg8z9e.js";import"./chunk-j152pk57.js";import"./chunk-c4dfktv2.js";import"./chunk-bdmbevk8.js";import"./chunk-7kysxgbq.js";import"./chunk-g755p68b.js";import"./chunk-tcmzq86w.js";import"./chunk-y8hjgmn0.js";import"./chunk-xy8be792.js";import"./chunk-h2m7em1e.js";import"./chunk-pn5ygqn6.js";import"./chunk-7ghwdjdc.js";import"./chunk-m5nd44st.js";import"./chunk-rxb0hw1e.js";import"./chunk-tw25g9g5.js";import"./chunk-yt15y085.js";import"./chunk-2z2jwetd.js";import"./chunk-8143k3t6.js";import"./chunk-zt7wfnva.js";import"./chunk-g6wb8p4p.js";import"./chunk-nc46gddg.js";import"./chunk-91sykzqq.js";export{runHookSubcommand,readTextWithTimeout,readStdinText,ensureGlobalRoveHooks};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{engineEntry,identifiableEngineIds}from"./chunk-
|
|
2
|
+
import{engineEntry,identifiableEngineIds}from"./chunk-5dv7pw3w.js";import{existsSync,mkdirSync,readFileSync,readdirSync,writeFileSync}from"fs";import{join,resolve}from"path";import{fileURLToPath}from"url";var ROVE_SKILL_VERSION=134,SKILL_NAME="rove";function bundledSkillDir(){let here=fileURLToPath(import.meta.url);return[resolve(here,"../../../../../.agents/skills/rove"),resolve(here,"../../skills/rove")].find((dir)=>existsSync(join(dir,"SKILL.md")))??null}function parseSkillVersion(content){let m=content.match(/rove-skill-version:\s*(\d+)/);return m?Number.parseInt(m[1],10):null}function readSkillCopy(dir){let text;try{text=readFileSync(join(dir,"SKILL.md"),"utf8")}catch{return{state:"not-installed",version:null}}let version=parseSkillVersion(text);return{state:version!==null&&version>=ROVE_SKILL_VERSION?"installed":"outdated",version}}function engineSkillDir(vendor){let base=engineEntry(vendor).skillsDir?.();return base?join(base,SKILL_NAME):null}function skillTargets(vendors=identifiableEngineIds()){let seen=new Set,out=[];for(let vendor of vendors){let dir=engineSkillDir(vendor);if(!dir||seen.has(dir))continue;seen.add(dir),out.push({vendor,displayName:engineEntry(vendor).displayName,dir,...readSkillCopy(dir)})}return out}function missingSkillNames(installed){return skillTargets(installed).filter((t)=>t.state==="not-installed").map((t)=>t.displayName)}function skillOverview(targets=skillTargets()){return{targets,installed:targets.some((t)=>t.state!=="not-installed"),outdated:targets.filter((t)=>t.state==="outdated")}}function copyTree(src,dest){mkdirSync(dest,{recursive:!0});for(let entry of readdirSync(src,{withFileTypes:!0})){let from=join(src,entry.name),to=join(dest,entry.name);if(entry.isDirectory())copyTree(from,to);else writeFileSync(to,readFileSync(from))}}function installSkill(targets,source=bundledSkillDir()){if(!source)throw Error("this Rove build ships no bundled skill");return targets.map((target)=>{try{return copyTree(source,target.dir),{target,error:null}}catch(error){return{target,error:error instanceof Error?error.message:String(error)}}})}function refreshOutdatedSkills(source=bundledSkillDir()){let outdated=skillOverview().outdated;if(outdated.length===0||!source)return[];return installSkill(outdated,source)}function installSkillErrors(source=bundledSkillDir()){try{let failed=installSkill(skillTargets().filter((t)=>t.state!=="installed"),source).filter((r)=>r.error);return failed.length===0?null:failed.map((r)=>`${r.target.displayName}: ${r.error}`).join("; ")}catch(error){return error instanceof Error?error.message:String(error)}}function installedSkillDiffersFromBundled(dir){let bundled=bundledSkillDir();if(!bundled)return!1;try{return readFileSync(join(bundled,"SKILL.md"),"utf8")!==readFileSync(join(dir,"SKILL.md"),"utf8")}catch{return!1}}
|
|
3
3
|
export{bundledSkillDir,readSkillCopy,engineSkillDir,skillTargets,missingSkillNames,skillOverview,installSkill,refreshOutdatedSkills,installSkillErrors,installedSkillDiffersFromBundled};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{findVerb}from"./chunk-
|
|
2
|
+
import{findVerb}from"./chunk-gafj4yp3.js";import{VERB_GROUP_IDS}from"./chunk-jz1kj4sf.js";import{loadStateFile,updateStateFile}from"./chunk-xasg8z9e.js";var INBOUND_KEY="machineInbound",INBOUND_CLASSES=[...VERB_GROUP_IDS,"land","credentials"],LAND_VERBS=new Set(["land","publish"]),CREDENTIAL_VERBS={"github-login":!0,"github-logout":!0,"github-sync":!0,"github-apply":!0};function inboundClassOf(verb){if(LAND_VERBS.has(verb))return"land";if(Object.hasOwn(CREDENTIAL_VERBS,verb))return"credentials";return findVerb(verb)?.group??null}function deniedClasses(state=loadStateFile()){let raw=state[INBOUND_KEY],deny=raw&&typeof raw==="object"?raw.deny:void 0;return Array.isArray(deny)?deny.filter((c)=>typeof c==="string"):[]}function inboundRefusal(verb,state){let cls=inboundClassOf(verb);return cls&&deniedClasses(state).includes(cls)?cls:null}function setInbound(cls,allow){let next=[];return updateStateFile((state)=>{let current=new Set(deniedClasses(state));if(allow)current.delete(cls);else current.add(cls);return next=[...current].sort(),state[INBOUND_KEY]={deny:next},!0}),next}
|
|
3
3
|
export{INBOUND_KEY,INBOUND_CLASSES,inboundClassOf,deniedClasses,inboundRefusal,setInbound};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{MachineHub}from"./chunk-b7rxn7c9.js";import"./chunk-n15p38e5.js";import"./chunk-6xr1prk6.js";import{upgradeMachine}from"./chunk-xj3034s1.js";import"./chunk-mdx18vtz.js";import{preferredReleaseChannel}from"./chunk-p4rhkv3k.js";import{machineDaemonSocket}from"./chunk-zc67sqet.js";import"./chunk-ejs6dnxf.js";import"./chunk-a6s52zm5.js";import"./chunk-y0e28qha.js";import"./chunk-55ajzrj6.js";import"./chunk-t7j8g9f6.js";import"./chunk-dmzg9zdc.js";import"./chunk-6xppe9bj.js";import{CURRENT_VERSION,checkLatestVersion,isNewerSemver}from"./chunk-s2eezz0a.js";import{logDaemonInfo}from"./chunk-rxqdw6s5.js";import"./chunk-t7qj639x.js";import"./chunk-gz0x179r.js";import"./chunk-jz1kj4sf.js";import"./chunk-v8nbqjwc.js";import"./chunk-ws2q07kb.js";import"./chunk-g9ba25q5.js";import"./chunk-133c884f.js";import"./chunk-catrr0z3.js";import"./chunk-xjrkvksc.js";import"./chunk-tn9gtf18.js";import"./chunk-ahbw1f8n.js";import"./chunk-sak1tphp.js";import"./chunk-y1xnjx8x.js";import"./chunk-sffdpzfv.js";import"./chunk-5dv7pw3w.js";import"./chunk-2bapg0v2.js";import"./chunk-750rk2xz.js";import"./chunk-w7zv47mp.js";import{isWindowsMachine}from"./chunk-cw9h73h5.js";import{listMachines}from"./chunk-37g0yabr.js";import"./chunk-nw48bskt.js";import"./chunk-k7tdg6kb.js";import"./chunk-1pmzr8kr.js";import"./chunk-e5jxbd98.js";import{RoveDaemonClient}from"./chunk-84q9hv7m.js";import"./chunk-96kvwzj8.js";import"./chunk-07665jz6.js";import"./chunk-40dgv828.js";import"./chunk-zsfyj36g.js";import"./chunk-1feav1w3.js";import"./chunk-9gctbddn.js";import"./chunk-mg1cas61.js";import"./chunk-yvg46jh9.js";import{loadStateFile}from"./chunk-xasg8z9e.js";import"./chunk-8xdhw922.js";import"./chunk-cmp64q4j.js";import"./chunk-j152pk57.js";import"./chunk-c4dfktv2.js";import"./chunk-bdmbevk8.js";import"./chunk-7kysxgbq.js";import"./chunk-g755p68b.js";import"./chunk-tcmzq86w.js";import"./chunk-y8hjgmn0.js";import"./chunk-xy8be792.js";import"./chunk-h2m7em1e.js";import"./chunk-pn5ygqn6.js";import"./chunk-7ghwdjdc.js";import"./chunk-m5nd44st.js";import"./chunk-rxb0hw1e.js";import"./chunk-tw25g9g5.js";import"./chunk-yt15y085.js";import"./chunk-2z2jwetd.js";import"./chunk-8143k3t6.js";import"./chunk-zt7wfnva.js";import"./chunk-g6wb8p4p.js";import"./chunk-nc46gddg.js";import"./chunk-1mp632fj.js";import"./chunk-91sykzqq.js";var MACHINES_AUTO_UPDATE_KEY="machines.autoUpdate",DEFAULTS={hubVersion:CURRENT_VERSION,enabled:()=>loadStateFile()[MACHINES_AUTO_UPDATE_KEY]!==!1,head:async()=>(await checkLatestVersion({force:!0,channel:preferredReleaseChannel()}))?.latest??null,entryOf:(alias)=>listMachines().find((m)=>m.alias===alias),busy:async(entry)=>{let socketPath=await machineDaemonSocket(entry);if(!socketPath)return!0;let client=new RoveDaemonClient(socketPath);try{return((await client.request("daemon.status")).invoking??0)>0}catch{return!0}finally{client.close()}},upgrade:upgradeMachine,log:(line)=>logDaemonInfo("machines",line),retryMs:60000};function startMachineAutoUpdate(machines,overrides={}){let deps={...DEFAULTS,...overrides},tried=new Set,running=new Set,retry=null,attempt=async(alias,version)=>{let key=`${alias}@${version}`,entry=deps.entryOf(alias);if(!entry||isWindowsMachine(entry))return void tried.add(key);let head=await deps.head();if(!head||!isNewerSemver(head,version))return void tried.add(key);if(await deps.busy(entry)){retry??=setTimeout(()=>{retry=null,look()},deps.retryMs);return}tried.add(key);let done=await deps.upgrade(entry);deps.log(done.changed?`${alias} updated: ${done.from??"?"} \u2192 ${done.to??"?"}`:`${alias} had nothing newer to install`)},look=()=>{if(!deps.enabled())return;for(let row of machines.get()){if(row.state!=="online"||!row.version||row.duplicateOf)continue;if(!isNewerSemver(deps.hubVersion,row.version))continue;if(tried.has(`${row.alias}@${row.version}`)||running.has(row.alias))continue;running.add(row.alias),attempt(row.alias,row.version).catch((err)=>deps.log(`${row.alias} auto-update failed: ${err instanceof Error?err.message:err}`)).finally(()=>running.delete(row.alias))}},stop=machines.subscribe(look);return look(),()=>{if(stop(),retry)clearTimeout(retry)}}var PUBLISH_DEBOUNCE_MS=50;function startDaemonMachineHub(bus){let hub=new MachineHub,timer=null,publish=()=>{timer=null;let live=hub.liveSignal().get(),payload={machines:hub.machinesSignal().get(),tasks:hub.tasksSignal().get().map((task)=>({...task,kind:task.kind??"task",pinned:task.pinned??!1})),live:{activity:Object.fromEntries(live.activity),changes:Object.fromEntries(live.changes),tokens:Object.fromEntries(live.tokens)}};bus.publish("machines",payload)},schedule=()=>{timer??=setTimeout(publish,PUBLISH_DEBOUNCE_MS)},stops=[hub.machinesSignal(),hub.tasksSignal(),hub.liveSignal()].map((signal)=>signal.subscribe(schedule)),lastRegistry=null,offState=bus.onPublish((event)=>{if(event.channel!=="state")return;let state=event.payload.state,text=JSON.stringify(state.machines??null);if(text===lastRegistry)return;lastRegistry=text,hub.sync()});hub.sync(),publish();let stopAutoUpdate=startMachineAutoUpdate(hub.machinesSignal());return()=>{stopAutoUpdate(),offState();for(let stop of stops)stop();if(timer)clearTimeout(timer);hub.dispose(),bus.publish("machines",{machines:[],tasks:[],live:{activity:{},changes:{},tokens:{}}})}}export{startDaemonMachineHub};
|