@sma1lboy/rove 0.9.296-next.328 → 0.9.296-next.331
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-8pvh2fff.js → chunk-09tyy8gw.js} +3 -3
- package/dist/cli/{chunk-bdbm8jkd.js → chunk-0kbd6nzm.js} +1 -1
- package/dist/cli/{chunk-f1wh362h.js → chunk-0xk05694.js} +1 -1
- package/dist/cli/{chunk-awmb1vzd.js → chunk-1hydxa8k.js} +1 -1
- package/dist/cli/{chunk-e9gnt61v.js → chunk-2bgb2810.js} +1 -1
- package/dist/cli/{chunk-7kgksv06.js → chunk-2z2jwetd.js} +2 -2
- package/dist/cli/{chunk-6pfeq5mx.js → chunk-3193p75b.js} +1 -1
- package/dist/cli/{chunk-2t0wxzcc.js → chunk-352dhjkf.js} +1 -1
- package/dist/cli/{chunk-t6q1we78.js → chunk-38w60dmy.js} +1 -1
- package/dist/cli/{chunk-4eh8ts01.js → chunk-3pbbf6hf.js} +1 -1
- package/dist/cli/chunk-44h0mhsa.js +2 -0
- package/dist/cli/chunk-49zh8bgk.js +2 -0
- package/dist/cli/{chunk-ncn022hs.js → chunk-4hvacnnr.js} +1 -1
- package/dist/cli/{chunk-77xn441d.js → chunk-4n7s5h9s.js} +1 -1
- package/dist/cli/{chunk-7f02vk0v.js → chunk-4rebycv9.js} +1 -1
- package/dist/cli/{chunk-ceg2g6ce.js → chunk-4sfdr0qw.js} +2 -2
- package/dist/cli/{chunk-c0fd63tg.js → chunk-4vbk9z6n.js} +1 -1
- package/dist/cli/{chunk-fv2j6zvm.js → chunk-53eqkfas.js} +1 -1
- package/dist/cli/{chunk-yfwn3fj5.js → chunk-5c591htx.js} +1 -1
- package/dist/cli/chunk-5drk7d2z.js +2 -0
- package/dist/cli/{chunk-6zxjc0et.js → chunk-5g01tqn6.js} +5 -5
- package/dist/cli/{chunk-mezp33qp.js → chunk-5jd2z8n0.js} +1 -1
- package/dist/cli/{chunk-arqemcjt.js → chunk-5wjskd40.js} +1 -1
- package/dist/cli/{chunk-wgk3dkq9.js → chunk-66vj434n.js} +3 -3
- package/dist/cli/chunk-6br2a2ze.js +2 -0
- package/dist/cli/{chunk-x58p36jn.js → chunk-6cmqh134.js} +1 -1
- package/dist/cli/{chunk-nps8009r.js → chunk-6dk6zcqm.js} +1 -1
- package/dist/cli/{chunk-gagrapmj.js → chunk-6evkd8be.js} +1 -1
- package/dist/cli/{chunk-da2j4tx2.js → chunk-75b4cgbz.js} +1 -1
- package/dist/cli/chunk-7cptm3td.js +2 -0
- package/dist/cli/chunk-7fxadh60.js +2 -0
- package/dist/cli/{chunk-cj4t4q1r.js → chunk-7j7sdn4p.js} +1 -1
- package/dist/cli/{chunk-m781veb4.js → chunk-7m3txy05.js} +1 -1
- package/dist/cli/{chunk-s8hc0wfr.js → chunk-7wwdcw8e.js} +2 -2
- package/dist/cli/{chunk-r79nb3kg.js → chunk-8cw8zznb.js} +1 -1
- package/dist/cli/{chunk-ynzyrjks.js → chunk-8ejt1bqj.js} +1 -1
- package/dist/cli/chunk-8hcmyjjn.js +2 -0
- package/dist/cli/{chunk-6xzx53b7.js → chunk-8q0nr6v6.js} +1 -1
- package/dist/cli/{chunk-p84bhs57.js → chunk-8trtyc98.js} +1 -1
- package/dist/cli/{chunk-29b3pj9h.js → chunk-8wfz7gyp.js} +1 -1
- package/dist/cli/{chunk-4tah26ys.js → chunk-95tzjzgb.js} +1 -1
- package/dist/cli/{chunk-k9a2b00g.js → chunk-9bhf8tkd.js} +3 -3
- package/dist/cli/{chunk-mw6rdm3k.js → chunk-9gevsmy4.js} +1 -1
- package/dist/cli/{chunk-yfzfbqp5.js → chunk-9we0f035.js} +1 -1
- package/dist/cli/{chunk-qbxpecq4.js → chunk-9wre0m8x.js} +1 -1
- package/dist/cli/chunk-a1scaehn.js +2 -0
- package/dist/cli/chunk-a2z0b48q.js +2 -0
- package/dist/cli/{chunk-k0yjcgd8.js → chunk-apaw34c5.js} +1 -1
- package/dist/cli/{chunk-jxc240wh.js → chunk-avf521sy.js} +1 -1
- package/dist/cli/{chunk-vd36r76s.js → chunk-b53drx76.js} +1 -1
- package/dist/cli/{chunk-p525sfz5.js → chunk-bk2vb6jj.js} +1 -1
- package/dist/cli/{chunk-nr8pxs18.js → chunk-bkhbaqt1.js} +1 -1
- package/dist/cli/chunk-c5w5t1t8.js +2 -0
- package/dist/cli/{chunk-7dmcpc3d.js → chunk-c5xnhy0v.js} +1 -1
- package/dist/cli/{chunk-85hmnbh1.js → chunk-c70kbg4m.js} +1 -1
- package/dist/cli/{chunk-s00k8tn6.js → chunk-cqzkk7j0.js} +1 -1
- package/dist/cli/{chunk-f26k5yqw.js → chunk-d63mrw6g.js} +1 -1
- package/dist/cli/{chunk-ewdanfd9.js → chunk-dvpjthdf.js} +1 -1
- package/dist/cli/chunk-dxyy3ep8.js +2 -0
- package/dist/cli/chunk-dz562xtj.js +2 -0
- package/dist/cli/{chunk-g8wzy7mn.js → chunk-e3bqjaff.js} +1 -1
- package/dist/cli/{chunk-5frd2aze.js → chunk-eaav6ajz.js} +1 -1
- package/dist/cli/{chunk-k3n95g00.js → chunk-etac300d.js} +1 -1
- package/dist/cli/{chunk-fjw8qqpz.js → chunk-f5hhhn3x.js} +1 -1
- package/dist/cli/{chunk-xwbntnv8.js → chunk-fhejs7ph.js} +1 -1
- package/dist/cli/{chunk-zbnw68pg.js → chunk-fj8awvx3.js} +2 -2
- package/dist/cli/{chunk-aw0rz15f.js → chunk-fqm68m42.js} +1 -1
- package/dist/cli/{chunk-nd5bhfxv.js → chunk-g37q36fs.js} +1 -1
- package/dist/cli/{chunk-hkqcc1t4.js → chunk-g5jc6c2d.js} +1 -1
- package/dist/cli/{chunk-wevvztwk.js → chunk-gceeh3yr.js} +1 -1
- package/dist/cli/chunk-h57gekkj.js +2 -0
- package/dist/cli/{chunk-m45b6d19.js → chunk-h72tns53.js} +1 -1
- package/dist/cli/{chunk-8yce2acw.js → chunk-jhnpr3cj.js} +1 -1
- package/dist/cli/{chunk-vda9epmy.js → chunk-jjc3v2zc.js} +1 -1
- package/dist/cli/{chunk-w8da1czv.js → chunk-jt9n8k7z.js} +1 -1
- package/dist/cli/{chunk-a1bzaw1b.js → chunk-jyakk1ah.js} +2 -2
- package/dist/cli/{chunk-hg0eck4e.js → chunk-kdf7cq06.js} +7 -7
- package/dist/cli/chunk-kvj8s9ck.js +2 -0
- package/dist/cli/{chunk-tygdsqwk.js → chunk-m5s8vn56.js} +1 -1
- package/dist/cli/{chunk-xejbrtx2.js → chunk-m6kw77w3.js} +1 -1
- package/dist/cli/{chunk-ev45vka6.js → chunk-m9ssmhrc.js} +1 -1
- package/dist/cli/chunk-mdx18vtz.js +3 -0
- package/dist/cli/{chunk-bfvfche3.js → chunk-mf2p3p9k.js} +1 -1
- package/dist/cli/{chunk-kvf0qqye.js → chunk-msgr4fes.js} +1 -1
- package/dist/cli/{chunk-86ssev5h.js → chunk-mx2smec1.js} +1 -1
- package/dist/cli/{chunk-86fzfqvw.js → chunk-mz82b1jf.js} +1 -1
- package/dist/cli/{chunk-8xtc0gqb.js → chunk-n1nt3zx9.js} +1 -1
- package/dist/cli/chunk-n2hz851r.js +2 -0
- package/dist/cli/{chunk-pn3tpqam.js → chunk-nawvr7j5.js} +1 -1
- package/dist/cli/{chunk-s8d3d2c2.js → chunk-ne7bbq1z.js} +5 -5
- package/dist/cli/{chunk-tcq7zep6.js → chunk-nv64scpb.js} +1 -1
- package/dist/cli/{chunk-dkcgm1cx.js → chunk-p2h4we4w.js} +1 -1
- package/dist/cli/chunk-p8te8w0d.js +2 -0
- package/dist/cli/chunk-pcmd0ydw.js +2 -0
- package/dist/cli/chunk-pferbnyr.js +2 -0
- package/dist/cli/{chunk-kfak0axd.js → chunk-pywaz045.js} +1 -1
- package/dist/cli/{chunk-3qg5wjnq.js → chunk-q5ncrh80.js} +1 -1
- package/dist/cli/{chunk-zb50xk9t.js → chunk-qcces6e3.js} +1 -1
- package/dist/cli/{chunk-fcs8szn5.js → chunk-qcdznw50.js} +1 -1
- package/dist/cli/{chunk-1tmmkk54.js → chunk-qdatysve.js} +1 -1
- package/dist/cli/{chunk-zgcfzfq3.js → chunk-qg92cfsh.js} +1 -1
- package/dist/cli/{chunk-857zfv82.js → chunk-qgf01sm2.js} +1 -1
- package/dist/cli/chunk-qjr36jpm.js +2 -0
- package/dist/cli/chunk-qpncf5as.js +2 -0
- package/dist/cli/{chunk-vn6brdp7.js → chunk-qqc8mn6x.js} +1 -1
- package/dist/cli/{chunk-7p8pb8c5.js → chunk-r271mcer.js} +1 -1
- package/dist/cli/{chunk-qa3dghyt.js → chunk-r7khfa3k.js} +1 -1
- package/dist/cli/{chunk-b8dr13gm.js → chunk-rr0cjy1v.js} +1 -1
- package/dist/cli/{chunk-9y21c892.js → chunk-s9j0sbmf.js} +1 -1
- package/dist/cli/chunk-sj0h67ht.js +2 -0
- package/dist/cli/{chunk-dsq5eqd5.js → chunk-t1vbw2me.js} +1 -1
- package/dist/cli/{chunk-5wjs7phr.js → chunk-t74ptmvq.js} +1 -1
- package/dist/cli/{chunk-rgz4m509.js → chunk-t7thxgcc.js} +1 -1
- package/dist/cli/chunk-tjtgks9k.js +2 -0
- package/dist/cli/chunk-v8e5smwe.js +2 -0
- package/dist/cli/{chunk-102yytay.js → chunk-v9n5e14e.js} +1 -1
- package/dist/cli/{chunk-5m8v3c29.js → chunk-vyh3ddp0.js} +1 -1
- package/dist/cli/{chunk-88cap497.js → chunk-w56terew.js} +1 -1
- package/dist/cli/chunk-wf5q5wm0.js +2 -0
- package/dist/cli/{chunk-qdf11nnb.js → chunk-wg9agpvf.js} +4 -4
- package/dist/cli/chunk-x8nc6bc2.js +2 -0
- package/dist/cli/{chunk-b0szsxbc.js → chunk-xxz504p6.js} +1 -1
- package/dist/cli/{chunk-49zrnjq1.js → chunk-y0skz8j9.js} +1 -1
- package/dist/cli/{chunk-b6ds8yfb.js → chunk-y2pt0wa6.js} +1 -1
- package/dist/cli/{chunk-vfrxywtx.js → chunk-y8hjgmn0.js} +1 -1
- package/dist/cli/{chunk-6r74n1g2.js → chunk-ywwg5zxs.js} +1 -1
- package/dist/cli/{chunk-s5ymevzg.js → chunk-yzdpmamq.js} +1 -1
- package/dist/cli/{chunk-ym33391g.js → chunk-z3k0wg31.js} +1 -1
- package/dist/cli/{chunk-mg9rjc2f.js → chunk-z538fdny.js} +1 -1
- package/dist/cli/{chunk-md47as1y.js → chunk-zjxz2v8a.js} +1 -1
- package/dist/cli/index.js +7 -7
- package/dist/cli/rove-run.js +1 -1
- package/dist/cli/rove.js +1 -1
- package/dist/skills/rove/SKILL.md +77 -1
- package/dist/skills/rove/references/api-flags.md +1 -1
- package/dist/web/assets/{index-DXX0TiVw.js → index-BugGU1Rz.js} +36 -36
- package/dist/web/assets/index-DBXOSxIY.css +1 -0
- package/dist/web/assets/{term-mount-C5szHrI9.js → term-mount-DnP2B2rY.js} +1 -1
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
- package/dist/cli/chunk-0e0dd4gt.js +0 -2
- package/dist/cli/chunk-3qmb3hhp.js +0 -2
- package/dist/cli/chunk-44msqtz9.js +0 -2
- package/dist/cli/chunk-4cr4pb6t.js +0 -2
- package/dist/cli/chunk-4fsdtw4r.js +0 -2
- package/dist/cli/chunk-6mxck5m6.js +0 -2
- package/dist/cli/chunk-6xhvprnc.js +0 -2
- package/dist/cli/chunk-atn06ncf.js +0 -3
- package/dist/cli/chunk-b6xrkzhj.js +0 -2
- package/dist/cli/chunk-dtb0dqwh.js +0 -2
- package/dist/cli/chunk-fftmsc4z.js +0 -2
- package/dist/cli/chunk-gsqphkca.js +0 -2
- package/dist/cli/chunk-gw9kzc63.js +0 -2
- package/dist/cli/chunk-h8m26j04.js +0 -2
- package/dist/cli/chunk-hq76ge1j.js +0 -2
- package/dist/cli/chunk-k4c7aqtj.js +0 -2
- package/dist/cli/chunk-pne75syz.js +0 -2
- package/dist/cli/chunk-q6t3gcs1.js +0 -2
- package/dist/cli/chunk-qb7jzw8e.js +0 -2
- package/dist/cli/chunk-r92mwjet.js +0 -2
- package/dist/cli/chunk-s84z30t2.js +0 -2
- package/dist/cli/chunk-ta9w2w9k.js +0 -2
- package/dist/cli/chunk-ts3q3a8a.js +0 -2
- package/dist/cli/chunk-vddmgpdz.js +0 -2
- package/dist/cli/chunk-wcwzvssh.js +0 -2
- package/dist/cli/chunk-znbtn8b8.js +0 -2
- package/dist/web/assets/index-DcF7AQIK.css +0 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{logClient}from"./chunk-vfrxywtx.js";import{toTaskId}from"./chunk-xy8be792.js";import{coerceVendorId}from"./chunk-h2m7em1e.js";import{pathSyntax,samePath}from"./chunk-pn5ygqn6.js";import{DAEMON_MIGRATION_MARKER}from"./chunk-m5nd44st.js";import{LockfileError,acquire}from"./chunk-w8da1czv.js";import{defaultClientLogPath}from"./chunk-7kgksv06.js";var WORKSPACE_BACKEND_IDS=["git-worktree","borrowed","cow-clone","layerfs","remote"];function isWorkspaceBackendId(value){return typeof value==="string"&&WORKSPACE_BACKEND_IDS.includes(value)}var GIT_WORKTREE={fork:"committed",checkpoint:!0,cheapClone:!1,ownsBranch:!0,ownsDirectory:!0,interactive:!0},WORKSPACE_CAPABILITIES={"git-worktree":GIT_WORKTREE,borrowed:{fork:"committed",checkpoint:!1,cheapClone:!1,ownsBranch:!1,ownsDirectory:!1,interactive:!0},"cow-clone":{...GIT_WORKTREE,fork:"with-uncommitted",cheapClone:!0},layerfs:{...GIT_WORKTREE,cheapClone:!0,ownsBranch:!1,interactive:!1},remote:{fork:"committed",checkpoint:!1,cheapClone:!1,ownsBranch:!1,ownsDirectory:!0,interactive:!1}};function workspaceBackendId(task){if(task.workspace)return task.workspace.backend;return task.kind==="main"||task.kind==="dir"?"borrowed":"git-worktree"}function workspaceCapabilities(task){return WORKSPACE_CAPABILITIES[workspaceBackendId(task)]}function childrenOf(tasks,id){return tasks.filter((task)=>task.parentTaskId===id)}function workspaceOwnerId(task){return task.sharesWorkspaceOf??task.id}function isSharedChild(task){return task.sharesWorkspaceOf!==void 0}function lineageRootId(tasks,id){let byId=new Map(tasks.map((task)=>[task.id,task])),seen=new Set,current=id;for(;;){seen.add(current);let up=byId.get(current)?.parentTaskId;if(!up||seen.has(up)||!byId.has(up))return current;current=up}}function subtreeIds(tasks,id){let out=[],seen=new Set,visit=(current)=>{if(seen.has(current))return;seen.add(current);for(let child of childrenOf(tasks,current))visit(child.id);out.push(current)};return visit(id),out}function taskCwd(task){let root=task.worktreePath??"";if(!root||!task.cwdSubpath)return root;return pathSyntax(root).join(root,task.cwdSubpath)}function gitRepoOf(task){return task.gitRepo||task.repo}var MULTI_REPO_CAP=8,REPO_NAME_RE=/^[A-Za-z0-9_][A-Za-z0-9._-]*$/;function repoNameOf(repoPath){return pathSyntax(repoPath).basename(repoPath).replace(/[^A-Za-z0-9._-]/g,"-").replace(/^[.-]+/,"")||"repo"}function uniqueRepoName(name,taken){if(!taken.has(name))return name;for(let n=2;;n++)if(!taken.has(`${name}-${n}`))return`${name}-${n}`}function taskRepos(task,tasks){let extras=(task.sharesWorkspaceOf&&tasks?.find((t)=>t.id===task.sharesWorkspaceOf)||task).extraRepos??[],primaryRepo=gitRepoOf(task);return[{name:uniqueRepoName(repoNameOf(primaryRepo),new Set(extras.map((e)=>e.name))),repo:primaryRepo,branch:task.branch,worktreePath:task.worktreePath??"",...task.baseRef?{baseRef:task.baseRef}:{},...task.prStatus?{prStatus:task.prStatus}:{},primary:!0},...extras.map((e)=>({name:e.name,repo:e.repo,branch:e.branch,worktreePath:e.worktreePath,...e.baseRef?{baseRef:e.baseRef}:{},...e.prStatus?{prStatus:e.prStatus}:{},primary:!1}))]}function taskWorktreePaths(task,tasks){return taskRepos(task,tasks).map((r)=>r.worktreePath).filter((p)=>p.length>0)}function prRank(pr){if(pr.checkState==="failing")return 0;if(pr.checkState==="pending")return 1;return pr.lifecycle==="merged"?3:2}function rollupPr(task){let worst;for(let pr of[task.prStatus,...(task.extraRepos??[]).map((e)=>e.prStatus)])if(pr&&(!worst||prRank(pr)<prRank(worst)))worst=pr;return worst}function pickRepos(task,only){let all=taskRepos(task);if(!only)return all;let picked=all.filter((r)=>r.name===only);if(picked.length===0)throw Error(`UNKNOWN_REPO: no repo named '${only}' in this task (repos: ${all.map((r)=>r.name).join(", ")})`);return picked}import{existsSync}from"fs";import{copyFile,readFile}from"fs/promises";import{dirname,join}from"path";var AUTO_FIX_MAX=3,AT_REST={idle:!0,turn_complete:!0};function autoFixDecision(input){let{state,pr,engine}=input;if(!state||!pr)return{do:"skip"};if(pr.lifecycle!=="open"&&pr.lifecycle!=="ready_to_merge")return{do:"skip"};if(pr.checkState==="passing")return state.attempts>0||state.stopped||state.lastSha?{do:"reset"}:{do:"skip"};if(pr.checkState!=="failing"||!pr.headSha)return{do:"skip"};if(pr.headSha===state.lastSha)return{do:"skip"};if(state.stopped)return{do:"skip"};if(state.attempts>=3)return{do:"stop"};return AT_REST[engine??""]?{do:"fire"}:{do:"wait"}}function coerceAutoFix(value){if(!value||typeof value!=="object"||Array.isArray(value))return;let v=value,attempts=typeof v.attempts==="number"&&Number.isInteger(v.attempts)&&v.attempts>=0?v.attempts:0;return{attempts:Math.min(attempts,3),...typeof v.lastSha==="string"&&v.lastSha.length>0?{lastSha:v.lastSha}:{},...v.stopped===!0?{stopped:!0}:{}}}var SESSION_PR_CAP=20,GITHUB_PR_URL=/^https?:\/\/(?:www\.)?github\.com\/([\w.-]+)\/([\w.-]+)\/pull\/(\d+)(?:[/?#].*)?$/i;function canonicalPrUrl(input){let m=GITHUB_PR_URL.exec(input.trim());if(!m)return;let[,owner,repo,number]=m;return`https://github.com/${owner}/${repo}/pull/${Number(number)}`}var MAX_NOTES=20000;class TodoRefusedError extends Error{code;constructor(code,message){super(message);this.code=code;this.name="TodoRefusedError"}}function cleanText(raw){let text=raw.replace(/\s+/g," ").trim();if(text.length===0)throw new TodoRefusedError("TODO_EMPTY","a todo needs some text");if(text.length>500)throw new TodoRefusedError("TODO_TOO_LONG","a todo is at most 500 characters");return text}function nextId(todos){return`t${todos.reduce((max,todo)=>Math.max(max,Number(todo.id.slice(1))||0),0)+1}`}function applyTodoOps(todos,ops){let list=[...todos],find=(id)=>{let at=list.findIndex((todo)=>todo.id===id);if(at<0)throw new TodoRefusedError("TODO_NOT_FOUND",`no todo ${id}`);return at};for(let op of ops)if(op.op==="add"){if(list.length>=100)throw new TodoRefusedError("TODO_LIMIT","a task holds at most 100 todos");list.push({id:nextId(list),text:cleanText(op.text),done:!1})}else if(op.op==="check"){let at=find(op.id);list[at]={...list[at],done:op.done}}else if(op.op==="edit"){let at=find(op.id);list[at]={...list[at],text:cleanText(op.text)}}else list.splice(find(op.id),1);return list}function checkNotes(notes){if(notes.length>20000)throw new TodoRefusedError("NOTES_TOO_LONG","notes are at most 20000 characters");return notes}function coerceTodos(value){if(!Array.isArray(value))return;let out=[];for(let item of value.slice(0,100)){let v=item;if(typeof v?.id==="string"&&/^t\d+$/.test(v.id)&&typeof v.text==="string"&&v.text.trim().length>0)out.push({id:v.id,text:v.text.slice(0,500),done:v.done===!0})}return out.length>0?out:void 0}function todoCount(todos){if(!todos||todos.length===0)return null;return{done:todos.filter((todo)=>todo.done).length,total:todos.length}}function parseTodoOps(value){if(!Array.isArray(value))throw new TodoRefusedError("TODO_EMPTY","ops must be a list");return value.map((raw)=>{let v=raw,id=typeof v?.id==="string"?v.id:"",text=typeof v?.text==="string"?v.text:"";if(v?.op==="add")return{op:"add",text};if(v?.op==="edit")return{op:"edit",id,text};if(v?.op==="remove")return{op:"remove",id};if(v?.op==="check"&&typeof v.done==="boolean")return{op:"check",id,done:v.done};throw new TodoRefusedError("TODO_EMPTY","each op is add, check, edit or remove")})}function coerceTask(value){if(!value||typeof value!=="object")return null;let v=value;if(typeof v.id!=="string"||typeof v.title!=="string"||typeof v.repo!=="string"||typeof v.branch!=="string"||typeof v.worktreePath!=="string"||typeof v.status!=="string"||typeof v.createdAt!=="string"||typeof v.updatedAt!=="string")return null;if(!isTaskStatus(v.status))return null;let kind=v.kind==="main"?"main":v.kind==="dir"?"dir":"task",scratch=kind==="dir"&&v.scratch===!0,noProject=kind==="dir"&&v.noProject===!0,healedStatus=kind==="main"&&(v.status==="in_progress"||v.status==="done")?"backlog":v.status,deletion=coerceDeletion(v.deletion),quotaResume=coerceQuotaResume(v.quotaResume),scheduledStart=coerceScheduledStart(v.scheduledStart),linkedWorkItem=coerceLinkedWorkItem(v.linkedWorkItem),dispatcher=coerceDispatcher(v.dispatcher),lineage=coerceLineage(v,kind),routine=coerceRoutine(v.routine),extraRepos=coerceExtraRepos(v.extraRepos,v.repo),workspace=coerceWorkspace(v.workspace),sessionPrs=coerceSessionPrs(v.sessionPrs),todos=coerceTodos(v.todos),autoFixCi=coerceAutoFix(v.autoFixCi),report=coerceWorkerReport(v.report);return{id:toTaskId(v.id),title:v.title,repo:v.repo,branch:v.branch,worktreePath:v.worktreePath,status:healedStatus,pinned:typeof v.pinned==="boolean"?v.pinned:!1,...v.kept===!0?{kept:!0}:{},...typeof v.notes==="string"&&v.notes.length>0?{notes:v.notes.slice(0,MAX_NOTES)}:{},...todos?{todos}:{},...autoFixCi?{autoFixCi}:{},kind,...scratch?{scratch:!0}:{},...noProject?{noProject:!0}:{},...routine?{routine}:{},vendor:coerceVendorId(typeof v.vendor==="string"?v.vendor:void 0),...typeof v.command==="string"&&v.command.trim().length>0?{command:v.command}:{},prStatus:coercePRStatus(v.prStatus),...typeof v.modelEffort==="string"&&v.modelEffort.length>0?{modelEffort:v.modelEffort}:{},...typeof v.model==="string"&&v.model.length>0?{model:v.model}:{},...typeof v.tier==="string"&&v.tier.length>0?{tier:v.tier}:{},...typeof v.groupId==="string"&&v.groupId.length>0?{groupId:v.groupId}:{},...v.observedLanguage==="zh"||v.observedLanguage==="en"?{observedLanguage:v.observedLanguage}:{},...deletion?{deletion}:{},...quotaResume?{quotaResume}:{},...scheduledStart?{scheduledStart}:{},...linkedWorkItem?{linkedWorkItem}:{},...dispatcher?{dispatcher}:{},...lineage,...v.deleteBranchPending===!0?{deleteBranchPending:!0}:{},...typeof v.prompt==="string"&&v.prompt.length>0?{prompt:v.prompt}:{},...typeof v.baseRef==="string"&&v.baseRef.trim().length>0?{baseRef:v.baseRef}:{},...typeof v.worktreeName==="string"&&v.worktreeName.trim().length>0?{worktreeName:v.worktreeName}:{},...typeof v.gitRepo==="string"&&v.gitRepo.trim().length>0?{gitRepo:v.gitRepo}:{},...extraRepos?{extraRepos}:{},...workspace?{workspace}:{},...sessionPrs?{sessionPrs}:{},...report?{report}:{},...v.requireReport===!0?{requireReport:!0}:{},...v.worktreeOnly===!0?{worktreeOnly:!0}:{},...v.archived===!0?{archived:!0}:{},createdAt:v.createdAt,updatedAt:v.updatedAt}}function coerceWorkspace(value){if(!value||typeof value!=="object")return;let w=value;if(!isWorkspaceBackendId(w.backend))return;return{backend:w.backend,...typeof w.ref==="string"&&w.ref.length>0?{ref:w.ref}:{}}}function coerceExtraRepos(value,primary){if(!Array.isArray(value))return;let out=[];for(let entry of value){if(out.length>=MULTI_REPO_CAP-1)break;if(!entry||typeof entry!=="object")continue;let e=entry;if(typeof e.name!=="string"||!REPO_NAME_RE.test(e.name))continue;if(typeof e.repo!=="string"||!pathSyntax(e.repo).isAbsolute(e.repo))continue;let repo=e.repo;if(samePath(repo,primary)||out.some((o)=>o.name===e.name||samePath(o.repo,repo)))continue;out.push({name:e.name,repo,branch:typeof e.branch==="string"?e.branch:"",worktreePath:typeof e.worktreePath==="string"?e.worktreePath:"",...typeof e.baseRef==="string"&&e.baseRef.trim().length>0?{baseRef:e.baseRef}:{},...coercePRStatus(e.prStatus)?{prStatus:coercePRStatus(e.prStatus)}:{}})}return out.length>0?out:void 0}function coerceSessionPrs(value){if(!Array.isArray(value))return;let out=[];for(let entry of value){if(!entry||typeof entry!=="object")continue;let e=entry,url=typeof e.url==="string"?canonicalPrUrl(e.url):void 0;if(!url||typeof e.addedAt!=="string"||out.some((o)=>o.url===url))continue;let status=coercePRStatus(e.status);out.push({url,addedAt:e.addedAt,...status?{status}:{}})}return out.length>0?out.slice(-SESSION_PR_CAP):void 0}function coerceWorkerReport(value){if(!value||typeof value!=="object"||Array.isArray(value))return;let v=value;if(typeof v.at!=="string"||v.at.length===0)return;return{at:v.at,...typeof v.branch==="string"&&v.branch.length>0?{branch:v.branch}:{},...typeof v.pr==="number"&&Number.isFinite(v.pr)?{pr:v.pr}:{},...typeof v.summary==="string"&&v.summary.length>0?{summary:v.summary}:{}}}function coerceDispatcher(value){if(!value||typeof value!=="object"||Array.isArray(value))return;let v=value;if(typeof v.taskId!=="string"||v.taskId.length===0)return;if(typeof v.tabId!=="string"||v.tabId.length===0)return;return{taskId:v.taskId,tabId:v.tabId}}function coerceTaskRef(value,selfId){return typeof value==="string"&&value.length>0&&value!==selfId?value:void 0}function coerceCwdSubpath(value){if(typeof value!=="string"||value.length===0)return;if(/^[/\\]|^[a-z]:/i.test(value))return;return value.split(/[/\\]/).includes("..")?void 0:value}function coerceLineage(v,kind){let selfId=v.id,parentTaskId=coerceTaskRef(v.parentTaskId,selfId),sharesWorkspaceOf=kind==="main"?void 0:coerceTaskRef(v.sharesWorkspaceOf,selfId),cwdSubpath=coerceCwdSubpath(v.cwdSubpath),ptyAlias=coerceDispatcher(v.ptyAlias);return{...parentTaskId?{parentTaskId:toTaskId(parentTaskId)}:{},...sharesWorkspaceOf?{sharesWorkspaceOf:toTaskId(sharesWorkspaceOf)}:{},...cwdSubpath?{cwdSubpath}:{},...ptyAlias?{ptyAlias}:{}}}function coerceRoutine(value){if(!value||typeof value!=="object"||Array.isArray(value))return;let v=value;if(typeof v.automationId!=="string"||v.automationId.length===0)return;return{automationId:v.automationId}}function coerceQuotaResume(value){if(!value||typeof value!=="object"||Array.isArray(value))return;let v=value;if(typeof v.resumeAt!=="string"||v.resumeAt.length===0)return;if(typeof v.requestedAt!=="string"||v.requestedAt.length===0)return;return{resumeAt:v.resumeAt,requestedAt:v.requestedAt}}function coerceScheduledStart(value){if(!value||typeof value!=="object"||Array.isArray(value))return;let v=value;if(typeof v.at!=="string"||v.at.length===0)return;if(typeof v.prompt!=="string"||v.prompt.length===0)return;return{at:v.at,prompt:v.prompt}}function coerceLinkedWorkItem(value){if(!value||typeof value!=="object"||Array.isArray(value))return;let v=value;if(v.provider!=="github")return;if(v.type!=="issue"&&v.type!=="pr")return;if(typeof v.number!=="number"||!Number.isFinite(v.number))return;if(typeof v.title!=="string"||typeof v.url!=="string"||v.url.length===0)return;return{provider:v.provider,type:v.type,number:v.number,title:v.title,url:v.url}}function coerceDeletion(value){if(!value||typeof value!=="object"||Array.isArray(value))return;let v=value;if(v.phase!=="queued"&&v.phase!=="running"&&v.phase!=="error"||typeof v.force!=="boolean"||typeof v.requestedAt!=="string"||v.requestedAt.length===0||v.error!==void 0&&typeof v.error!=="string")return;return{phase:v.phase,force:v.force,...typeof v.deleteBranch==="boolean"?{deleteBranch:v.deleteBranch}:{},requestedAt:v.requestedAt,...typeof v.error==="string"?{error:v.error}:{}}}function coercePRStatus(value){if(!value||typeof value!=="object"||Array.isArray(value))return;let v=value;if(!isPRProviderId(v.provider)||!isPRLifecycleState(v.lifecycle)||!isPRCheckState(v.checkState))return;return{provider:v.provider,lifecycle:v.lifecycle,checkState:v.checkState,...typeof v.number==="number"&&Number.isFinite(v.number)?{number:v.number}:{},...typeof v.url==="string"?{url:v.url}:{},...typeof v.title==="string"?{title:v.title}:{},...typeof v.additions==="number"&&Number.isFinite(v.additions)?{additions:v.additions}:{},...typeof v.deletions==="number"&&Number.isFinite(v.deletions)?{deletions:v.deletions}:{},...typeof v.baseRef==="string"?{baseRef:v.baseRef}:{},...typeof v.reviewDecision==="string"?{reviewDecision:v.reviewDecision}:{},...typeof v.mergeable==="string"?{mergeable:v.mergeable}:{},...typeof v.headSha==="string"?{headSha:v.headSha}:{},...typeof v.lastCheckedAt==="string"?{lastCheckedAt:v.lastCheckedAt}:{},...typeof v.lastError==="string"?{lastError:v.lastError}:{}}}function isPRProviderId(v){return v==="github"||v==="gitlab"||v==="bitbucket"||v==="unknown"}function isPRLifecycleState(v){return v==="creating"||v==="open"||v==="ready_to_merge"||v==="merged"||v==="closed"||v==="unknown"}function isPRCheckState(v){return v==="none"||v==="pending"||v==="passing"||v==="failing"||v==="unknown"}function isTaskStatus(s){return s==="backlog"||s==="in_progress"||s==="in_review"||s==="done"||s==="canceled"||s==="error"}var sleep=(ms)=>new Promise((resolve)=>setTimeout(resolve,ms)),LOCK_RETRY_DELAY_MS=25,LOCK_MAX_WAIT_MS=5000;async function acquireWithRetry(lockPath){let deadline=Date.now()+LOCK_MAX_WAIT_MS;for(;;)try{return await acquire(lockPath)}catch(err){if(!(err instanceof LockfileError)||Date.now()>=deadline)throw err;await sleep(LOCK_RETRY_DELAY_MS)}}var CURRENT_VERSION=3;async function backupCorruptManifest(path,now=()=>new Date){let backupPath=`${path}.corrupt-${now().toISOString().replaceAll(":","-")}`;try{return await copyFile(path,backupPath),backupPath}catch{return null}}var SUPPORTED_VERSIONS=new Set([1,2,3]);function warnManifestRecovery(message,manifestPath){console.warn(message),logClient("tasks-index",message,manifestPath?defaultClientLogPath(dirname(dirname(manifestPath))):void 0)}async function recoverUnsupportedVersion(parsed,sourcePath){if(!parsed||typeof parsed!=="object"||Array.isArray(parsed))return!1;let version=parsed.version;if(version===void 0||SUPPORTED_VERSIONS.has(version))return!1;let backup=await backupCorruptManifest(sourcePath);return warnManifestRecovery(`[rove] tasks.json at ${sourcePath} has unsupported version=${String(version)}; recovering with empty index.${backup?` Original bytes backed up to ${backup}.`:" Backup copy failed; the stale file is left in place."}`,sourcePath),!0}function normalizeIndex(parsed,source){if(!parsed||typeof parsed!=="object"||Array.isArray(parsed))return warnManifestRecovery(`[rove] tasks.json at ${source} is not an object; recovering with empty index.`,source),{version:CURRENT_VERSION,tasks:[]};let obj=parsed,version=obj.version;if(version!==void 0&&!SUPPORTED_VERSIONS.has(version))return warnManifestRecovery(`[rove] tasks.json at ${source} has unsupported version=${String(version)}; recovering with empty index.`,source),{version:CURRENT_VERSION,tasks:[]};let rawTasks=Array.isArray(obj.tasks)?obj.tasks:[],tasks=[];for(let entry of rawTasks){let task=coerceTask(entry);if(task)tasks.push(task);else console.warn(`[rove] dropping malformed task entry from ${source}: ${JSON.stringify(entry)}`)}return{version:CURRENT_VERSION,tasks}}var TOMBSTONE_TTL_MS=2592000000;function readableLegacyIndexPath(canonicalPath,legacyPath){return existsSync(join(dirname(canonicalPath),DAEMON_MIGRATION_MARKER))?void 0:legacyPath}async function readDiskIndex(path,legacyPath){let raw,sourcePath=path;try{raw=await readFile(sourcePath,"utf8")}catch(err){if(err.code!=="ENOENT")throw err;let legacy=readableLegacyIndexPath(path,legacyPath);if(!legacy)return{tasks:[],removed:[]};sourcePath=legacy;try{raw=await readFile(sourcePath,"utf8")}catch(legacyErr){if(legacyErr.code==="ENOENT")return{tasks:[],removed:[]};throw legacyErr}}let parsed;try{parsed=JSON.parse(raw)}catch{return await backupCorruptManifest(sourcePath),{tasks:[],removed:[]}}if(await recoverUnsupportedVersion(parsed,sourcePath))return{tasks:[],removed:[]};return{tasks:normalizeIndex(parsed,sourcePath).tasks,removed:coerceTombstones(parsed)}}function coerceTombstones(parsed){if(!parsed||typeof parsed!=="object"||Array.isArray(parsed))return[];let raw=parsed.removed;if(!Array.isArray(raw))return[];let out=[];for(let entry of raw){if(!entry||typeof entry!=="object")continue;let v=entry;if(typeof v.id==="string"&&v.id.length>0&&typeof v.at==="string")out.push({id:v.id,at:v.at})}return out}function mergeTasksWithDisk(cacheTasks,diskTasks,dirty,removed,diskRemoved=[],now=Date.now()){let tombstones=new Map;for(let t of diskRemoved){let at=Date.parse(t.at);if(!Number.isFinite(at)||now-at>TOMBSTONE_TTL_MS)continue;tombstones.set(t.id,t.at)}for(let[id,at]of removed)tombstones.set(id,at);let diskById=new Map(diskTasks.map((t)=>[t.id,t])),result=[],included=new Set;for(let task of cacheTasks){if(tombstones.has(task.id))continue;if(dirty.has(task.id))result.push(task);else{let onDisk=diskById.get(task.id);if(onDisk===void 0)continue;result.push(onDisk)}included.add(task.id)}for(let task of diskTasks){if(included.has(task.id)||tombstones.has(task.id))continue;result.push(task),included.add(task.id)}return{tasks:result,removed:[...tombstones].map(([id,at])=>({id,at}))}}async function recoverIndexFromDisk(path,legacyPath){let raw,sourcePath=path;try{raw=await readFile(path,"utf8")}catch(err){if(err.code!=="ENOENT")throw err;let legacy=readableLegacyIndexPath(path,legacyPath),legacyRaw;if(legacy)try{legacyRaw=await readFile(legacy,"utf8"),sourcePath=legacy}catch(legacyErr){if(legacyErr.code!=="ENOENT")throw legacyErr}if(legacyRaw===void 0)return{version:CURRENT_VERSION,tasks:[]};raw=legacyRaw}let parsed;try{parsed=JSON.parse(raw)}catch(err){let backup=await backupCorruptManifest(sourcePath);return warnManifestRecovery(`[rove] tasks.json at ${sourcePath} is corrupted (${err.message}); recovering with empty index.${backup?` Original bytes backed up to ${backup}.`:" Backup copy failed; the stale file is left in place."}`,sourcePath),{version:CURRENT_VERSION,tasks:[]}}if(await recoverUnsupportedVersion(parsed,sourcePath))return{version:CURRENT_VERSION,tasks:[]};return normalizeIndex(parsed,sourcePath)}
|
|
2
|
+
import{logClient}from"./chunk-y8hjgmn0.js";import{toTaskId}from"./chunk-xy8be792.js";import{coerceVendorId}from"./chunk-h2m7em1e.js";import{pathSyntax,samePath}from"./chunk-pn5ygqn6.js";import{DAEMON_MIGRATION_MARKER}from"./chunk-m5nd44st.js";import{LockfileError,acquire}from"./chunk-jt9n8k7z.js";import{defaultClientLogPath}from"./chunk-2z2jwetd.js";var WORKSPACE_BACKEND_IDS=["git-worktree","borrowed","cow-clone","layerfs","remote"];function isWorkspaceBackendId(value){return typeof value==="string"&&WORKSPACE_BACKEND_IDS.includes(value)}var GIT_WORKTREE={fork:"committed",checkpoint:!0,cheapClone:!1,ownsBranch:!0,ownsDirectory:!0,interactive:!0},WORKSPACE_CAPABILITIES={"git-worktree":GIT_WORKTREE,borrowed:{fork:"committed",checkpoint:!1,cheapClone:!1,ownsBranch:!1,ownsDirectory:!1,interactive:!0},"cow-clone":{...GIT_WORKTREE,fork:"with-uncommitted",cheapClone:!0},layerfs:{...GIT_WORKTREE,cheapClone:!0,ownsBranch:!1,interactive:!1},remote:{fork:"committed",checkpoint:!1,cheapClone:!1,ownsBranch:!1,ownsDirectory:!0,interactive:!1}};function workspaceBackendId(task){if(task.workspace)return task.workspace.backend;return task.kind==="main"||task.kind==="dir"?"borrowed":"git-worktree"}function workspaceCapabilities(task){return WORKSPACE_CAPABILITIES[workspaceBackendId(task)]}function childrenOf(tasks,id){return tasks.filter((task)=>task.parentTaskId===id)}function workspaceOwnerId(task){return task.sharesWorkspaceOf??task.id}function isSharedChild(task){return task.sharesWorkspaceOf!==void 0}function lineageRootId(tasks,id){let byId=new Map(tasks.map((task)=>[task.id,task])),seen=new Set,current=id;for(;;){seen.add(current);let up=byId.get(current)?.parentTaskId;if(!up||seen.has(up)||!byId.has(up))return current;current=up}}function subtreeIds(tasks,id){let out=[],seen=new Set,visit=(current)=>{if(seen.has(current))return;seen.add(current);for(let child of childrenOf(tasks,current))visit(child.id);out.push(current)};return visit(id),out}function taskCwd(task){let root=task.worktreePath??"";if(!root||!task.cwdSubpath)return root;return pathSyntax(root).join(root,task.cwdSubpath)}function gitRepoOf(task){return task.gitRepo||task.repo}var MULTI_REPO_CAP=8,REPO_NAME_RE=/^[A-Za-z0-9_][A-Za-z0-9._-]*$/;function repoNameOf(repoPath){return pathSyntax(repoPath).basename(repoPath).replace(/[^A-Za-z0-9._-]/g,"-").replace(/^[.-]+/,"")||"repo"}function uniqueRepoName(name,taken){if(!taken.has(name))return name;for(let n=2;;n++)if(!taken.has(`${name}-${n}`))return`${name}-${n}`}function taskRepos(task,tasks){let extras=(task.sharesWorkspaceOf&&tasks?.find((t)=>t.id===task.sharesWorkspaceOf)||task).extraRepos??[],primaryRepo=gitRepoOf(task);return[{name:uniqueRepoName(repoNameOf(primaryRepo),new Set(extras.map((e)=>e.name))),repo:primaryRepo,branch:task.branch,worktreePath:task.worktreePath??"",...task.baseRef?{baseRef:task.baseRef}:{},...task.prStatus?{prStatus:task.prStatus}:{},primary:!0},...extras.map((e)=>({name:e.name,repo:e.repo,branch:e.branch,worktreePath:e.worktreePath,...e.baseRef?{baseRef:e.baseRef}:{},...e.prStatus?{prStatus:e.prStatus}:{},primary:!1}))]}function taskWorktreePaths(task,tasks){return taskRepos(task,tasks).map((r)=>r.worktreePath).filter((p)=>p.length>0)}function prRank(pr){if(pr.checkState==="failing")return 0;if(pr.checkState==="pending")return 1;return pr.lifecycle==="merged"?3:2}function rollupPr(task){let worst;for(let pr of[task.prStatus,...(task.extraRepos??[]).map((e)=>e.prStatus)])if(pr&&(!worst||prRank(pr)<prRank(worst)))worst=pr;return worst}function pickRepos(task,only){let all=taskRepos(task);if(!only)return all;let picked=all.filter((r)=>r.name===only);if(picked.length===0)throw Error(`UNKNOWN_REPO: no repo named '${only}' in this task (repos: ${all.map((r)=>r.name).join(", ")})`);return picked}import{existsSync}from"fs";import{copyFile,readFile}from"fs/promises";import{dirname,join}from"path";var AUTO_FIX_MAX=3,AT_REST={idle:!0,turn_complete:!0};function autoFixDecision(input){let{state,pr,engine}=input;if(!state||!pr)return{do:"skip"};if(pr.lifecycle!=="open"&&pr.lifecycle!=="ready_to_merge")return{do:"skip"};if(pr.checkState==="passing")return state.attempts>0||state.stopped||state.lastSha?{do:"reset"}:{do:"skip"};if(pr.checkState!=="failing"||!pr.headSha)return{do:"skip"};if(pr.headSha===state.lastSha)return{do:"skip"};if(state.stopped)return{do:"skip"};if(state.attempts>=3)return{do:"stop"};return AT_REST[engine??""]?{do:"fire"}:{do:"wait"}}function coerceAutoFix(value){if(!value||typeof value!=="object"||Array.isArray(value))return;let v=value,attempts=typeof v.attempts==="number"&&Number.isInteger(v.attempts)&&v.attempts>=0?v.attempts:0;return{attempts:Math.min(attempts,3),...typeof v.lastSha==="string"&&v.lastSha.length>0?{lastSha:v.lastSha}:{},...v.stopped===!0?{stopped:!0}:{}}}var SESSION_PR_CAP=20,GITHUB_PR_URL=/^https?:\/\/(?:www\.)?github\.com\/([\w.-]+)\/([\w.-]+)\/pull\/(\d+)(?:[/?#].*)?$/i;function canonicalPrUrl(input){let m=GITHUB_PR_URL.exec(input.trim());if(!m)return;let[,owner,repo,number]=m;return`https://github.com/${owner}/${repo}/pull/${Number(number)}`}var MAX_NOTES=20000;class TodoRefusedError extends Error{code;constructor(code,message){super(message);this.code=code;this.name="TodoRefusedError"}}function cleanText(raw){let text=raw.replace(/\s+/g," ").trim();if(text.length===0)throw new TodoRefusedError("TODO_EMPTY","a todo needs some text");if(text.length>500)throw new TodoRefusedError("TODO_TOO_LONG","a todo is at most 500 characters");return text}function nextId(todos){return`t${todos.reduce((max,todo)=>Math.max(max,Number(todo.id.slice(1))||0),0)+1}`}function applyTodoOps(todos,ops){let list=[...todos],find=(id)=>{let at=list.findIndex((todo)=>todo.id===id);if(at<0)throw new TodoRefusedError("TODO_NOT_FOUND",`no todo ${id}`);return at};for(let op of ops)if(op.op==="add"){if(list.length>=100)throw new TodoRefusedError("TODO_LIMIT","a task holds at most 100 todos");list.push({id:nextId(list),text:cleanText(op.text),done:!1})}else if(op.op==="check"){let at=find(op.id);list[at]={...list[at],done:op.done}}else if(op.op==="edit"){let at=find(op.id);list[at]={...list[at],text:cleanText(op.text)}}else list.splice(find(op.id),1);return list}function checkNotes(notes){if(notes.length>20000)throw new TodoRefusedError("NOTES_TOO_LONG","notes are at most 20000 characters");return notes}function coerceTodos(value){if(!Array.isArray(value))return;let out=[];for(let item of value.slice(0,100)){let v=item;if(typeof v?.id==="string"&&/^t\d+$/.test(v.id)&&typeof v.text==="string"&&v.text.trim().length>0)out.push({id:v.id,text:v.text.slice(0,500),done:v.done===!0})}return out.length>0?out:void 0}function todoCount(todos){if(!todos||todos.length===0)return null;return{done:todos.filter((todo)=>todo.done).length,total:todos.length}}function parseTodoOps(value){if(!Array.isArray(value))throw new TodoRefusedError("TODO_EMPTY","ops must be a list");return value.map((raw)=>{let v=raw,id=typeof v?.id==="string"?v.id:"",text=typeof v?.text==="string"?v.text:"";if(v?.op==="add")return{op:"add",text};if(v?.op==="edit")return{op:"edit",id,text};if(v?.op==="remove")return{op:"remove",id};if(v?.op==="check"&&typeof v.done==="boolean")return{op:"check",id,done:v.done};throw new TodoRefusedError("TODO_EMPTY","each op is add, check, edit or remove")})}function coerceTask(value){if(!value||typeof value!=="object")return null;let v=value;if(typeof v.id!=="string"||typeof v.title!=="string"||typeof v.repo!=="string"||typeof v.branch!=="string"||typeof v.worktreePath!=="string"||typeof v.status!=="string"||typeof v.createdAt!=="string"||typeof v.updatedAt!=="string")return null;if(!isTaskStatus(v.status))return null;let kind=v.kind==="main"?"main":v.kind==="dir"?"dir":"task",scratch=kind==="dir"&&v.scratch===!0,noProject=kind==="dir"&&v.noProject===!0,healedStatus=kind==="main"&&(v.status==="in_progress"||v.status==="done")?"backlog":v.status,deletion=coerceDeletion(v.deletion),quotaResume=coerceQuotaResume(v.quotaResume),scheduledStart=coerceScheduledStart(v.scheduledStart),linkedWorkItem=coerceLinkedWorkItem(v.linkedWorkItem),dispatcher=coerceDispatcher(v.dispatcher),lineage=coerceLineage(v,kind),routine=coerceRoutine(v.routine),extraRepos=coerceExtraRepos(v.extraRepos,v.repo),workspace=coerceWorkspace(v.workspace),sessionPrs=coerceSessionPrs(v.sessionPrs),todos=coerceTodos(v.todos),autoFixCi=coerceAutoFix(v.autoFixCi),report=coerceWorkerReport(v.report);return{id:toTaskId(v.id),title:v.title,repo:v.repo,branch:v.branch,worktreePath:v.worktreePath,status:healedStatus,pinned:typeof v.pinned==="boolean"?v.pinned:!1,...v.kept===!0?{kept:!0}:{},...typeof v.notes==="string"&&v.notes.length>0?{notes:v.notes.slice(0,MAX_NOTES)}:{},...todos?{todos}:{},...autoFixCi?{autoFixCi}:{},kind,...scratch?{scratch:!0}:{},...noProject?{noProject:!0}:{},...routine?{routine}:{},vendor:coerceVendorId(typeof v.vendor==="string"?v.vendor:void 0),...typeof v.command==="string"&&v.command.trim().length>0?{command:v.command}:{},prStatus:coercePRStatus(v.prStatus),...typeof v.modelEffort==="string"&&v.modelEffort.length>0?{modelEffort:v.modelEffort}:{},...typeof v.model==="string"&&v.model.length>0?{model:v.model}:{},...typeof v.tier==="string"&&v.tier.length>0?{tier:v.tier}:{},...typeof v.groupId==="string"&&v.groupId.length>0?{groupId:v.groupId}:{},...v.observedLanguage==="zh"||v.observedLanguage==="en"?{observedLanguage:v.observedLanguage}:{},...deletion?{deletion}:{},...quotaResume?{quotaResume}:{},...scheduledStart?{scheduledStart}:{},...linkedWorkItem?{linkedWorkItem}:{},...dispatcher?{dispatcher}:{},...lineage,...v.deleteBranchPending===!0?{deleteBranchPending:!0}:{},...typeof v.prompt==="string"&&v.prompt.length>0?{prompt:v.prompt}:{},...typeof v.baseRef==="string"&&v.baseRef.trim().length>0?{baseRef:v.baseRef}:{},...typeof v.worktreeName==="string"&&v.worktreeName.trim().length>0?{worktreeName:v.worktreeName}:{},...typeof v.gitRepo==="string"&&v.gitRepo.trim().length>0?{gitRepo:v.gitRepo}:{},...extraRepos?{extraRepos}:{},...workspace?{workspace}:{},...sessionPrs?{sessionPrs}:{},...report?{report}:{},...v.requireReport===!0?{requireReport:!0}:{},...v.worktreeOnly===!0?{worktreeOnly:!0}:{},...v.archived===!0?{archived:!0}:{},createdAt:v.createdAt,updatedAt:v.updatedAt}}function coerceWorkspace(value){if(!value||typeof value!=="object")return;let w=value;if(!isWorkspaceBackendId(w.backend))return;return{backend:w.backend,...typeof w.ref==="string"&&w.ref.length>0?{ref:w.ref}:{}}}function coerceExtraRepos(value,primary){if(!Array.isArray(value))return;let out=[];for(let entry of value){if(out.length>=MULTI_REPO_CAP-1)break;if(!entry||typeof entry!=="object")continue;let e=entry;if(typeof e.name!=="string"||!REPO_NAME_RE.test(e.name))continue;if(typeof e.repo!=="string"||!pathSyntax(e.repo).isAbsolute(e.repo))continue;let repo=e.repo;if(samePath(repo,primary)||out.some((o)=>o.name===e.name||samePath(o.repo,repo)))continue;out.push({name:e.name,repo,branch:typeof e.branch==="string"?e.branch:"",worktreePath:typeof e.worktreePath==="string"?e.worktreePath:"",...typeof e.baseRef==="string"&&e.baseRef.trim().length>0?{baseRef:e.baseRef}:{},...coercePRStatus(e.prStatus)?{prStatus:coercePRStatus(e.prStatus)}:{}})}return out.length>0?out:void 0}function coerceSessionPrs(value){if(!Array.isArray(value))return;let out=[];for(let entry of value){if(!entry||typeof entry!=="object")continue;let e=entry,url=typeof e.url==="string"?canonicalPrUrl(e.url):void 0;if(!url||typeof e.addedAt!=="string"||out.some((o)=>o.url===url))continue;let status=coercePRStatus(e.status);out.push({url,addedAt:e.addedAt,...status?{status}:{}})}return out.length>0?out.slice(-SESSION_PR_CAP):void 0}function coerceWorkerReport(value){if(!value||typeof value!=="object"||Array.isArray(value))return;let v=value;if(typeof v.at!=="string"||v.at.length===0)return;return{at:v.at,...typeof v.branch==="string"&&v.branch.length>0?{branch:v.branch}:{},...typeof v.pr==="number"&&Number.isFinite(v.pr)?{pr:v.pr}:{},...typeof v.summary==="string"&&v.summary.length>0?{summary:v.summary}:{}}}function coerceDispatcher(value){if(!value||typeof value!=="object"||Array.isArray(value))return;let v=value;if(typeof v.taskId!=="string"||v.taskId.length===0)return;if(typeof v.tabId!=="string"||v.tabId.length===0)return;return{taskId:v.taskId,tabId:v.tabId}}function coerceTaskRef(value,selfId){return typeof value==="string"&&value.length>0&&value!==selfId?value:void 0}function coerceCwdSubpath(value){if(typeof value!=="string"||value.length===0)return;if(/^[/\\]|^[a-z]:/i.test(value))return;return value.split(/[/\\]/).includes("..")?void 0:value}function coerceLineage(v,kind){let selfId=v.id,parentTaskId=coerceTaskRef(v.parentTaskId,selfId),sharesWorkspaceOf=kind==="main"?void 0:coerceTaskRef(v.sharesWorkspaceOf,selfId),cwdSubpath=coerceCwdSubpath(v.cwdSubpath),ptyAlias=coerceDispatcher(v.ptyAlias);return{...parentTaskId?{parentTaskId:toTaskId(parentTaskId)}:{},...sharesWorkspaceOf?{sharesWorkspaceOf:toTaskId(sharesWorkspaceOf)}:{},...cwdSubpath?{cwdSubpath}:{},...ptyAlias?{ptyAlias}:{}}}function coerceRoutine(value){if(!value||typeof value!=="object"||Array.isArray(value))return;let v=value;if(typeof v.automationId!=="string"||v.automationId.length===0)return;return{automationId:v.automationId}}function coerceQuotaResume(value){if(!value||typeof value!=="object"||Array.isArray(value))return;let v=value;if(typeof v.resumeAt!=="string"||v.resumeAt.length===0)return;if(typeof v.requestedAt!=="string"||v.requestedAt.length===0)return;return{resumeAt:v.resumeAt,requestedAt:v.requestedAt}}function coerceScheduledStart(value){if(!value||typeof value!=="object"||Array.isArray(value))return;let v=value;if(typeof v.at!=="string"||v.at.length===0)return;if(typeof v.prompt!=="string"||v.prompt.length===0)return;return{at:v.at,prompt:v.prompt}}function coerceLinkedWorkItem(value){if(!value||typeof value!=="object"||Array.isArray(value))return;let v=value;if(v.provider!=="github")return;if(v.type!=="issue"&&v.type!=="pr")return;if(typeof v.number!=="number"||!Number.isFinite(v.number))return;if(typeof v.title!=="string"||typeof v.url!=="string"||v.url.length===0)return;return{provider:v.provider,type:v.type,number:v.number,title:v.title,url:v.url}}function coerceDeletion(value){if(!value||typeof value!=="object"||Array.isArray(value))return;let v=value;if(v.phase!=="queued"&&v.phase!=="running"&&v.phase!=="error"||typeof v.force!=="boolean"||typeof v.requestedAt!=="string"||v.requestedAt.length===0||v.error!==void 0&&typeof v.error!=="string")return;return{phase:v.phase,force:v.force,...typeof v.deleteBranch==="boolean"?{deleteBranch:v.deleteBranch}:{},requestedAt:v.requestedAt,...typeof v.error==="string"?{error:v.error}:{}}}function coercePRStatus(value){if(!value||typeof value!=="object"||Array.isArray(value))return;let v=value;if(!isPRProviderId(v.provider)||!isPRLifecycleState(v.lifecycle)||!isPRCheckState(v.checkState))return;return{provider:v.provider,lifecycle:v.lifecycle,checkState:v.checkState,...typeof v.number==="number"&&Number.isFinite(v.number)?{number:v.number}:{},...typeof v.url==="string"?{url:v.url}:{},...typeof v.title==="string"?{title:v.title}:{},...typeof v.additions==="number"&&Number.isFinite(v.additions)?{additions:v.additions}:{},...typeof v.deletions==="number"&&Number.isFinite(v.deletions)?{deletions:v.deletions}:{},...typeof v.baseRef==="string"?{baseRef:v.baseRef}:{},...typeof v.reviewDecision==="string"?{reviewDecision:v.reviewDecision}:{},...typeof v.mergeable==="string"?{mergeable:v.mergeable}:{},...typeof v.headSha==="string"?{headSha:v.headSha}:{},...typeof v.lastCheckedAt==="string"?{lastCheckedAt:v.lastCheckedAt}:{},...typeof v.lastError==="string"?{lastError:v.lastError}:{}}}function isPRProviderId(v){return v==="github"||v==="gitlab"||v==="bitbucket"||v==="unknown"}function isPRLifecycleState(v){return v==="creating"||v==="open"||v==="ready_to_merge"||v==="merged"||v==="closed"||v==="unknown"}function isPRCheckState(v){return v==="none"||v==="pending"||v==="passing"||v==="failing"||v==="unknown"}function isTaskStatus(s){return s==="backlog"||s==="in_progress"||s==="in_review"||s==="done"||s==="canceled"||s==="error"}var sleep=(ms)=>new Promise((resolve)=>setTimeout(resolve,ms)),LOCK_RETRY_DELAY_MS=25,LOCK_MAX_WAIT_MS=5000;async function acquireWithRetry(lockPath){let deadline=Date.now()+LOCK_MAX_WAIT_MS;for(;;)try{return await acquire(lockPath)}catch(err){if(!(err instanceof LockfileError)||Date.now()>=deadline)throw err;await sleep(LOCK_RETRY_DELAY_MS)}}var CURRENT_VERSION=3;async function backupCorruptManifest(path,now=()=>new Date){let backupPath=`${path}.corrupt-${now().toISOString().replaceAll(":","-")}`;try{return await copyFile(path,backupPath),backupPath}catch{return null}}var SUPPORTED_VERSIONS=new Set([1,2,3]);function warnManifestRecovery(message,manifestPath){console.warn(message),logClient("tasks-index",message,manifestPath?defaultClientLogPath(dirname(dirname(manifestPath))):void 0)}async function recoverUnsupportedVersion(parsed,sourcePath){if(!parsed||typeof parsed!=="object"||Array.isArray(parsed))return!1;let version=parsed.version;if(version===void 0||SUPPORTED_VERSIONS.has(version))return!1;let backup=await backupCorruptManifest(sourcePath);return warnManifestRecovery(`[rove] tasks.json at ${sourcePath} has unsupported version=${String(version)}; recovering with empty index.${backup?` Original bytes backed up to ${backup}.`:" Backup copy failed; the stale file is left in place."}`,sourcePath),!0}function normalizeIndex(parsed,source){if(!parsed||typeof parsed!=="object"||Array.isArray(parsed))return warnManifestRecovery(`[rove] tasks.json at ${source} is not an object; recovering with empty index.`,source),{version:CURRENT_VERSION,tasks:[]};let obj=parsed,version=obj.version;if(version!==void 0&&!SUPPORTED_VERSIONS.has(version))return warnManifestRecovery(`[rove] tasks.json at ${source} has unsupported version=${String(version)}; recovering with empty index.`,source),{version:CURRENT_VERSION,tasks:[]};let rawTasks=Array.isArray(obj.tasks)?obj.tasks:[],tasks=[];for(let entry of rawTasks){let task=coerceTask(entry);if(task)tasks.push(task);else console.warn(`[rove] dropping malformed task entry from ${source}: ${JSON.stringify(entry)}`)}return{version:CURRENT_VERSION,tasks}}var TOMBSTONE_TTL_MS=2592000000;function readableLegacyIndexPath(canonicalPath,legacyPath){return existsSync(join(dirname(canonicalPath),DAEMON_MIGRATION_MARKER))?void 0:legacyPath}async function readDiskIndex(path,legacyPath){let raw,sourcePath=path;try{raw=await readFile(sourcePath,"utf8")}catch(err){if(err.code!=="ENOENT")throw err;let legacy=readableLegacyIndexPath(path,legacyPath);if(!legacy)return{tasks:[],removed:[]};sourcePath=legacy;try{raw=await readFile(sourcePath,"utf8")}catch(legacyErr){if(legacyErr.code==="ENOENT")return{tasks:[],removed:[]};throw legacyErr}}let parsed;try{parsed=JSON.parse(raw)}catch{return await backupCorruptManifest(sourcePath),{tasks:[],removed:[]}}if(await recoverUnsupportedVersion(parsed,sourcePath))return{tasks:[],removed:[]};return{tasks:normalizeIndex(parsed,sourcePath).tasks,removed:coerceTombstones(parsed)}}function coerceTombstones(parsed){if(!parsed||typeof parsed!=="object"||Array.isArray(parsed))return[];let raw=parsed.removed;if(!Array.isArray(raw))return[];let out=[];for(let entry of raw){if(!entry||typeof entry!=="object")continue;let v=entry;if(typeof v.id==="string"&&v.id.length>0&&typeof v.at==="string")out.push({id:v.id,at:v.at})}return out}function mergeTasksWithDisk(cacheTasks,diskTasks,dirty,removed,diskRemoved=[],now=Date.now()){let tombstones=new Map;for(let t of diskRemoved){let at=Date.parse(t.at);if(!Number.isFinite(at)||now-at>TOMBSTONE_TTL_MS)continue;tombstones.set(t.id,t.at)}for(let[id,at]of removed)tombstones.set(id,at);let diskById=new Map(diskTasks.map((t)=>[t.id,t])),result=[],included=new Set;for(let task of cacheTasks){if(tombstones.has(task.id))continue;if(dirty.has(task.id))result.push(task);else{let onDisk=diskById.get(task.id);if(onDisk===void 0)continue;result.push(onDisk)}included.add(task.id)}for(let task of diskTasks){if(included.has(task.id)||tombstones.has(task.id))continue;result.push(task),included.add(task.id)}return{tasks:result,removed:[...tombstones].map(([id,at])=>({id,at}))}}async function recoverIndexFromDisk(path,legacyPath){let raw,sourcePath=path;try{raw=await readFile(path,"utf8")}catch(err){if(err.code!=="ENOENT")throw err;let legacy=readableLegacyIndexPath(path,legacyPath),legacyRaw;if(legacy)try{legacyRaw=await readFile(legacy,"utf8"),sourcePath=legacy}catch(legacyErr){if(legacyErr.code!=="ENOENT")throw legacyErr}if(legacyRaw===void 0)return{version:CURRENT_VERSION,tasks:[]};raw=legacyRaw}let parsed;try{parsed=JSON.parse(raw)}catch(err){let backup=await backupCorruptManifest(sourcePath);return warnManifestRecovery(`[rove] tasks.json at ${sourcePath} is corrupted (${err.message}); recovering with empty index.${backup?` Original bytes backed up to ${backup}.`:" Backup copy failed; the stale file is left in place."}`,sourcePath),{version:CURRENT_VERSION,tasks:[]}}if(await recoverUnsupportedVersion(parsed,sourcePath))return{version:CURRENT_VERSION,tasks:[]};return normalizeIndex(parsed,sourcePath)}
|
|
3
3
|
export{WORKSPACE_CAPABILITIES,workspaceBackendId,workspaceCapabilities,AUTO_FIX_MAX,autoFixDecision,SESSION_PR_CAP,canonicalPrUrl,TodoRefusedError,applyTodoOps,checkNotes,todoCount,parseTodoOps,childrenOf,workspaceOwnerId,isSharedChild,lineageRootId,subtreeIds,taskCwd,gitRepoOf,MULTI_REPO_CAP,repoNameOf,uniqueRepoName,taskRepos,taskWorktreePaths,rollupPr,pickRepos,acquireWithRetry,readableLegacyIndexPath,readDiskIndex,mergeTasksWithDisk,recoverIndexFromDisk};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{machineTasks}from"./chunk-0xk05694.js";import"./chunk-bkhbaqt1.js";import{dedupeMachines,listMachines}from"./chunk-7m3txy05.js";import"./chunk-y0e28qha.js";import"./chunk-m6kw77w3.js";import"./chunk-6jcmdxza.js";import"./chunk-m9ssmhrc.js";import"./chunk-han0d078.js";import"./chunk-jz1kj4sf.js";import"./chunk-v8nbqjwc.js";import"./chunk-ws2q07kb.js";import"./chunk-g9ba25q5.js";import"./chunk-cqzkk7j0.js";import"./chunk-catrr0z3.js";import"./chunk-dvpjthdf.js";import"./chunk-tn9gtf18.js";import"./chunk-r7khfa3k.js";import"./chunk-sak1tphp.js";import"./chunk-y1xnjx8x.js";import"./chunk-zsfyj36g.js";import"./chunk-1feav1w3.js";import"./chunk-vpph4nqf.js";import"./chunk-cmp64q4j.js";import"./chunk-8cw8zznb.js";import"./chunk-z3k0wg31.js";import"./chunk-4hvacnnr.js";import"./chunk-w7zv47mp.js";import"./chunk-mz82b1jf.js";import"./chunk-jhnpr3cj.js";import"./chunk-w56terew.js";import"./chunk-8wfz7gyp.js";import"./chunk-96kvwzj8.js";import"./chunk-v9n5e14e.js";import"./chunk-40dgv828.js";import"./chunk-9gctbddn.js";import"./chunk-mg1cas61.js";import"./chunk-8trtyc98.js";import"./chunk-g5jc6c2d.js";import"./chunk-qdatysve.js";import"./chunk-7kysxgbq.js";import"./chunk-5c591htx.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-jt9n8k7z.js";import"./chunk-apaw34c5.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)tasks.push({...task,origin:{machineId:entry.alias,hostLabel}})}return{tasks}}export{mergeTaskList};
|