@sma1lboy/kobe 0.8.95 → 0.8.96

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/kobe.js CHANGED
@@ -282,8 +282,8 @@ ${z}`,Z);this.line=J,this.column=X,this.codeblock=z}}});function ML($,Z){let J=$
282
282
  `)){let U=H.trim();if(!U)continue;if(!TJ(U))continue;let K;try{K=JSON.parse(U)}catch{continue}if(!HR(K)||typeof K.type!=="string")continue;let N=typeof K.timestamp==="string"?K.timestamp:new Date().toISOString(),L=HR(K.data)?K.data:{};if(K.type==="session.start"){let M=typeof L.sessionId==="string"?L.sessionId:void 0;if(M)z=M;continue}if(K.type==="user.message"){let M=typeof L.content==="string"?L.content:"";if(!M)continue;if(!W)W=Buffer.from(M.slice(0,_J0),"utf8").toString("utf8");J.push({role:"user",blocks:[{type:"text",text:M}],timestamp:N,sessionId:z});continue}if(K.type==="assistant.message"){let M=[],V=typeof L.content==="string"?L.content:"";if(V)M.push({type:"text",text:V});let P=Array.isArray(L.toolRequests)?L.toolRequests:[];for(let _ of P){if(!HR(_))continue;let C=typeof _.id==="string"?_.id:typeof _.toolCallId==="string"?_.toolCallId:"tool",f=typeof _.name==="string"?_.name:typeof _.toolName==="string"?_.toolName:"tool";M.push({type:"tool_call",callId:C,name:f,input:_.arguments??{}})}if(M.length>0)J.push({role:"assistant",blocks:M,timestamp:N,sessionId:z});continue}if(K.type==="tool.execution_start"){let M=typeof L.toolCallId==="string"?L.toolCallId:void 0,V=typeof L.toolName==="string"?L.toolName:"tool";if(M)X.set(M,V);continue}if(K.type==="tool.execution_complete"){let M=typeof L.toolCallId==="string"?L.toolCallId:void 0;if(!M)continue;let V=X.get(M)??(typeof L.toolName==="string"?L.toolName:"tool"),P=L.result??(L.success===!1?{success:!1}:void 0);J.push({role:"assistant",blocks:[{type:"tool_result",callId:M,output:P,isError:L.success===!1}],timestamp:N,sessionId:z});continue}if(K.type==="session.shutdown")G=Ck(L)}return{messages:J,toolNameById:X,sessionId:z,usageMetrics:G,firstUserMessage:W}}function HR($){return typeof $==="object"&&$!==null&&!Array.isArray($)}var OY,jJ0,_J0=200;var Rk=a(()=>{AQ();xL();OY={copilotDir(){let $=process.env.COPILOT_HOME?.trim();if($)return $;return TQ.join(MJ0(),".copilot")},async readdir($){try{return await BJ0($)}catch{return[]}},async readFile($){return await DQ($)},stat:FJ0,async rm($){await KJ0($,{recursive:!0,force:!0})}};jJ0=yH({initial:LJ0,parseChunk:($,Z)=>VJ0($,Z)})});import{stat as DJ0}from"fs/promises";import{homedir as AJ0}from"os";import vL from"path";function PJ0($){let Z=[];for(let J of $.split(`
283
283
  `)){if(!J.trim())continue;try{let{sessionId:X,sessionDir:z,workDir:G}=JSON.parse(J);if(X&&z&&G)Z.push({sessionId:X,sessionDir:z,workDir:G})}catch{}}return Z}async function Tk($){let Z=await $.readFile(vL.join($.kimiDir(),"session_index.jsonl")).catch(()=>"");return PJ0(Z)}function Sk($){return vL.join($,"agents","main","wire.jsonl")}async function FR($,Z=KR){if(!$)return[];let J=[];for(let X of await Tk(Z)){if(X.workDir!==$)continue;let z=await Z.stat(Sk(X.sessionDir)).then((G)=>G.mtimeMs).catch(()=>null);if(z===null)continue;J.push({id:X.sessionId,mtimeMs:z})}return J.sort((X,z)=>X.mtimeMs-z.mtimeMs).map((X)=>X.id)}async function Ik($,Z=KR){return await Z.stat($).then((J)=>J.mtimeMs).catch(()=>0)}async function MR($,Z=KR){if(!$)return null;let J=(await Tk(Z)).find((z)=>z.sessionId===$);if(!J)return null;let X=Sk(J.sessionDir);return await Z.stat(X).then(()=>X).catch(()=>null)}var KR;var Ek=a(()=>{AQ();KR={kimiDir(){return process.env.KIMI_CODE_HOME?.trim()||vL.join(AJ0(),".kimi-code")},async readFile($){return await DQ($)},stat:DJ0}});import TJ0 from"path";var mL,wk,xk,fk,gk;var yk=a(()=>{WR();gL();Rk();Ek();mL={async listSessionIdsForWorktree(){return[]},async readHistory(){return[]},async transcriptPath(){return null},async latestTranscriptMtimeForWorktree(){return 0}},wk={async listSessionIdsForWorktree($){return[...await bH($)].sort((J,X)=>J.mtimeMs-X.mtimeMs).map((J)=>J.sessionId)},readHistory:($)=>Vk($),async transcriptPath($,Z){return(await bH(Z)).find((X)=>X.sessionId===$)?.path??null},latestTranscriptMtimeForWorktree:($)=>jk($)},xk={listSessionIdsForWorktree:($)=>Yk($),readHistory:($)=>Wk($),transcriptPath:async($)=>await QR($)??null,latestTranscriptMtimeForWorktree:($)=>Gk($)},fk={listSessionIdsForWorktree:($)=>Dk($),readHistory:($)=>Pk($),async transcriptPath($){let Z=await UR($);return Z?TJ0.join(Z,"events.jsonl"):null},latestTranscriptMtimeForWorktree:($)=>Ak($)},gk={listSessionIdsForWorktree:($)=>FR($),readHistory:mL.readHistory,transcriptPath:($)=>MR($),async latestTranscriptMtimeForWorktree($){let J=(await FR($)).at(-1);if(!J)return 0;let X=await MR(J);return X?await Ik(X):0}}});var hL,bk,kk;var uL=a(()=>{hL=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],bk=["\xB7","\u2722","\u2731","\u2736","\u273B","\u273D"],kk=[...bk,...[...bk].reverse()]});import{readFile as mk,stat as SJ0}from"fs/promises";class cL{supportsCompletionMarkers(){return!0}async latestCompletion($){return(await this.latestActivity($)).marker}async latestActivityInFile($){return null}}function hk($){return D$($).createTurnDetector()}function vk($,Z="claude",J=0){let X=null,z=0;for(let G of $.split(`
284
284
  `)){z++;let W=ck(G);if(!W)continue;let H=LR(W.message)?W.message:W;if(H.role!=="assistant")continue;if(!("content"in H))continue;let U=dk(W,J),K={id:`claude:${Z}:${U}:${z}`,timestampMs:U,source:"claude"};if(!X||K.timestampMs>=X.timestampMs)X=K}return X}function xJ0($){if($.type==="turn.completed")return!0;if($.type!=="event_msg")return!1;let Z=LR($.payload)?$.payload:void 0;return typeof Z?.type==="string"&&wJ0.has(Z.type)}function fJ0($,Z="codex"){let J=null,X=0;for(let z of $.split(`
285
- `)){X++;let G=ck(z);if(!G||!xJ0(G))continue;let W=dk(G,0),H={id:`codex:${Z}:${W}:${X}`,timestampMs:W,source:"codex"};if(!J||H.timestampMs>=J.timestampMs)J=H}return J}function ck($){let Z=$.trim();if(!Z)return null;try{let J=JSON.parse(Z);return LR(J)?J:null}catch{return null}}function dk($,Z){let J=typeof $.timestamp==="string"?Date.parse($.timestamp):Number.NaN;return Number.isFinite(J)?J:Z}function LR($){return typeof $==="object"&&$!==null&&!Array.isArray($)}var uk=($)=>SJ0($).then((Z)=>Z.mtimeMs,()=>0),IJ0,NR,EJ0,OR,mK,wJ0;var jR=a(()=>{WR();gL();C7();IJ0={listSessionFiles:($)=>bH($),readFile:($)=>mk($,"utf8"),statMtimeMs:uk};NR=class NR extends cL{deps;vendor="claude";cache=new Map;constructor($=IJ0){super();this.deps=$}async latestActivity($){let Z=await this.deps.listSessionFiles($),J=Z[0]?.mtimeMs??0,X=null,z=new Map;for(let G of Z.slice(0,4)){let W=this.cache.get(G.path),H;if(W&&G.mtimeMs>0&&W.mtimeMs===G.mtimeMs)H=W.marker;else{let U=await this.deps.readFile(G.path).catch(()=>"");H=vk(U,G.path,G.mtimeMs)}if(z.set(G.path,{mtimeMs:G.mtimeMs,marker:H}),H&&(!X||H.timestampMs>X.timestampMs))X=H}return this.cache=z,{marker:X,mtimeMs:J}}async latestActivityInFile($){let Z=await(this.deps.statMtimeMs??uk)($);if(Z===0)return null;let J=await this.deps.readFile($).catch(()=>"");return{marker:vk(J,$,Z),mtimeMs:Z}}};EJ0={findLatestRollout:($)=>zR($),readFile:($)=>mk($,"utf8")};OR=class OR extends cL{deps;vendor="codex";cache=null;constructor($=EJ0){super();this.deps=$}async latestActivity($){if(!$)return{marker:null,mtimeMs:0};let Z=await this.deps.findLatestRollout($);if(!Z)return{marker:null,mtimeMs:0};if(this.cache&&this.cache.path===Z.path&&Z.mtimeMs>0&&this.cache.mtimeMs===Z.mtimeMs)return{marker:this.cache.marker,mtimeMs:Z.mtimeMs};let J=await this.deps.readFile(Z.path).catch(()=>"");if(!J)return{marker:null,mtimeMs:Z.mtimeMs};let X=fJ0(J,Z.path);return this.cache={path:Z.path,mtimeMs:Z.mtimeMs,marker:X},{marker:X,mtimeMs:Z.mtimeMs}}};mK=class mK extends cL{vendor;constructor($){super();this.vendor=$}supportsCompletionMarkers(){return!1}async latestActivity(){return{marker:null,mtimeMs:0}}};wJ0=new Set(["task_complete","turn_complete","turn_aborted"])});function gJ0($){return{vendor:$,builtin:!1,displayName:$,defaultCommand:[$],history:mL,detectAccount:async()=>({binary:{found:!1,error:"custom engine: Rove has no account detector for it"},account:{kind:"none"}}),createHookAdapter:()=>new hK($),createTurnDetector:()=>new mK($)}}function D$($){return h7($)?VR[$]:gJ0($)}function lk($){return D$($).history.readHistory!==mL.readHistory}function _R($){let Z=D$($).terminalTitle?.statusPrefixes;return Z&&Z.length>0?Z:pk}function kH($,Z){let J=Z?_R(Z):pk;for(let X of[...J].sort((z,G)=>G.length-z.length)){if(!$.startsWith(X))continue;let z=$.slice(X.length).trimStart();if(z.length===0)return $;return z}return $}function dL($,Z){let J=D$($).terminalTitle,X=J?.workingPrefixes;if(J?.ownsStatus!==!0||!X||X.length===0)return null;let z=Z.trim();if(z.length===0)return null;return X.some((G)=>z.startsWith(G))?"working":"rest"}function nk(){return Object.values(VR).filter(($)=>$.quotaUsage).map(($)=>$.vendor)}var VR,pk;var C7=a(()=>{u7();SJ();Eb();kb();db();nb();ob();Bk();yk();CR();uL();jR();VR={claude:{vendor:"claude",builtin:!0,displayName:"Claude",defaultCommand:["claude"],history:wk,detectAccount:($)=>IH($),createHookAdapter:()=>new nP,createTurnDetector:()=>new NR,capabilities:Sb,identity:Ib,spinnerFrames:kk,terminalTitle:{ownsStatus:!0,statusPrefixes:["\u2733","\u2802","\u2810","\u25D0","\u25D1"],workingPrefixes:["\u2802","\u2810","\u25D0","\u25D1"]},quotaUsage:()=>cb()},codex:{vendor:"codex",builtin:!0,displayName:"Codex",defaultCommand:["codex"],effortLevels:["none","low","medium","high","xhigh"],history:xk,detectAccount:($)=>EH($),createHookAdapter:()=>new rP,createTurnDetector:()=>new OR,capabilities:lb,identity:pb,terminalTitle:{ownsStatus:!0,launchArgs:["-c",'tui.terminal_title=["activity","thread-title"]'],statusPrefixes:["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],workingPrefixes:["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"]},quotaUsage:()=>Uk()},copilot:{vendor:"copilot",builtin:!0,displayName:"Copilot",defaultCommand:["copilot"],history:fk,detectAccount:($)=>wH($),createHookAdapter:()=>new hK("copilot"),createTurnDetector:()=>new mK("copilot")},kimi:{vendor:"kimi",builtin:!0,displayName:"Kimi",defaultCommand:["kimi"],firstMessageDelivery:"paste",history:gk,detectAccount:($)=>SL($),createHookAdapter:()=>new hK("kimi"),createTurnDetector:()=>new mK("kimi")}};pk=[...new Set(Object.values(VR).flatMap(($)=>$.terminalTitle?.statusPrefixes??[]))]});function DR($){return D$($).createHookAdapter()}class hK{vendor;constructor($){this.vendor=$}supportsHooks(){return!1}globalSettingsPath(){return""}activityDetailFromPayload(){return}sessionFromPayload(){return}async installActivityHooks(){}async removeActivityHooks(){}supportsWorktreeSync(){return!1}async removeWorktreeSyncHook(){}async installWorktreeWatchHook(){}async removeWorktreeWatchHook(){}}var CR=a(()=>{C7()});function lL($){return yJ0.includes($)}function ik($){return bJ0.includes($)}var yJ0,bJ0;var AR=a(()=>{yJ0=["session-start","turn-start","turn-complete","turn-failed","turn-interrupted","awaiting-input","session-end","tool-pre","tool-post","tool-failed","pre-compact","post-compact","subagent-start","subagent-stop"];bJ0=["session-start","turn-start","turn-complete","turn-failed","turn-interrupted","awaiting-input","session-end"]});var zv={};g$(zv,{runHookSubcommand:()=>cJ0,readTextWithTimeout:()=>sk,parseWorktreeRemovePath:()=>Zv,parseWorktreeAddPath:()=>$v,ensureGlobalKobeHooks:()=>RR});import{homedir as kJ0}from"os";import{join as rk,resolve as PR}from"path";async function sk($,Z=vJ0){let J;try{return await Promise.race([$(),new Promise((X)=>{J=setTimeout(()=>X(""),Z)})])}finally{if(J!==void 0)clearTimeout(J)}}async function tk(){try{let $=await sk(()=>Bun.stdin.text());if(!$.trim())return{};let Z=JSON.parse($);return Z&&typeof Z==="object"&&!Array.isArray(Z)?Z:{}}catch{return{}}}function ok($,Z){for(let J=0;J<$.length;J++){if($[J]===Z)return $[J+1];if($[J].startsWith(`${Z}=`))return $[J].slice(Z.length+1)}return}function hJ0($){return!!$&&typeof $==="object"&&!Array.isArray($)}function ek($){let Z=[],J=/"([^"]*)"|'([^']*)'|(\S+)/g,X;while((X=J.exec($))!==null)Z.push(X[1]??X[2]??X[3]??"");return Z}function $v($){let Z=ek($),J=new Set(["-b","-B","--reason"]);for(let X=0;X+1<Z.length;X++){if(Z[X]!=="worktree"||Z[X+1]!=="add")continue;let z=X+2;while(z<Z.length){let G=Z[z];if(G==="&&"||G==="||"||G===";"||G==="|"||G===">"||G===">>")break;if(G.startsWith("-")){z+=J.has(G)?2:1;continue}return G}}return}function Zv($){let Z=ek($);for(let J=0;J+1<Z.length;J++){if(Z[J]!=="worktree"||Z[J+1]!=="remove")continue;let X=J+2;while(X<Z.length){let z=Z[X];if(z==="&&"||z==="||"||z===";"||z==="|"||z===">"||z===">>")break;if(z.startsWith("-")){X+=1;continue}return z}}return}async function uJ0(){let $=await tk(),Z=hJ0($.tool_input)?$.tool_input:{},J=typeof Z.command==="string"?Z.command:"";if(!J.includes("worktree"))return;let X=typeof $.cwd==="string"&&$.cwd?$.cwd:process.cwd(),z=$v(J),G=z?void 0:Zv(J);if(!z&&!G)return;let W=await BQ();if(!W)return;try{if(z)await W.request("worktree.reconcile",{cwd:X,worktreePath:PR(X,z)});else if(G)await W.request("worktree.archiveRemoved",{worktreePath:PR(X,G)})}finally{W.close()}}async function cJ0($){let[Z,...J]=$;if(Z==="setup"){await nJ0(J);return}if(Z===mJ0){try{await uJ0()}catch{}return}try{if(!Z||!lL(Z))return;let X=await tk(),z=ok(J,"--task-id"),G=typeof X.cwd==="string"&&X.cwd?X.cwd:process.cwd(),W=process.env.KOBE_TASK_ID,H=process.env.KOBE_TAB_ID,U=ok(J,"--engine"),K=Jv().filter((V)=>!U||V.vendor===U),N;for(let V of K)if(N=V.activityDetailFromPayload(Z,X),N)break;let L;for(let V of K)if(L=V.sessionFromPayload(X),L)break;let M=await BQ();if(!M)return;try{let V=z??W;await M.request("engine.reportEvent",{...V?{taskId:V}:{cwd:G},kind:Z,...U?{engine:U}:{},...H?{tabId:H}:{},...N?{detail:N}:{},...L?{sessionId:L.sessionId}:{},...L?.transcriptPath?{transcriptPath:L.transcriptPath}:{}})}finally{M.close()}}catch(X){if(process.env.KOBE_HOOK_DEBUG)console.error(`[rove hook] ${Z} failed:`,X instanceof Error?X.message:String(X))}}function dJ0(){return T8.map(($)=>DR($)).filter(($)=>$.supportsWorktreeSync())}function Jv(){return T8.map(($)=>DR($)).filter(($)=>$.supportsHooks())}function Xv(){return rk(kJ0(),".claude","settings.json")}function lJ0($){if(!$||$==="off")return;if($==="global")return Xv();if($.startsWith("repo:"))return rk(PR($.slice(5)),".claude","settings.json");return $}async function RR(){try{let $=pJ0();for(let Z of Jv()){let J=Z.globalSettingsPath();if(!J)continue;await Z.installActivityHooks(J,{toolEvents:$}),await Z.installWorktreeWatchHook(J)}await Qv()}catch{}}function pJ0(){try{for(let $ of j5().plugins){if(!$.enabled)continue;try{if(XZ($.root).manifest.events.some((Z)=>Z.on.startsWith("tool.")))return!0}catch{}}}catch{}return!1}async function Qv(){let $=dJ0();if($.length===0)return;let Z=l7(ak),J=new Set([Xv()]),X=lJ0(Z);if(X)J.add(X);for(let z of $)for(let G of J)await z.removeWorktreeSyncHook(G);if(Z!=="off")o3(ak,"off")}async function nJ0($){await Qv(),process.stdout.write(["rove hook setup is deprecated and now a no-op (cleanup only).","","The old external-worktree sync used a global WorktreeCreate hook, which is","a VCS provider hook \u2014 its presence broke `claude --worktree` / EnterWorktree","in every repo. Any hook Rove previously installed has been removed.","","Sync is now automatic: a `claude --worktree` (or any session) started in a","worktree under a repo Rove already tracks is adopted as a task on launch.","To adopt existing worktrees on demand, use the New Task dialog or `rove adopt`.",""].join(`
286
- `))}var vJ0=500,mJ0="worktree-created",ak="externalWorktreeSync";var TR=a(()=>{C2();jQ();RJ();CR();AR();b4();u7()});var pL;var Yv=a(()=>{pL={$schema:"https://json.schemastore.org/package.json",name:"@sma1lboy/rove",version:"0.8.95",description:"Rove \u2014 the terminal-native agent multiplexer",type:"module",packageManager:"bun@1.3.13",bin:{kobe:"dist/cli/kobe.js",rove:"dist/cli/rove.js"},files:["dist/cli","dist/web-ui","dist/skills","dist/*.wav","README.md","LICENSE"],publishConfig:{access:"public"},repository:{type:"git",url:"git+https://github.com/Sma1lboy/rove.git"},homepage:"https://github.com/Sma1lboy/rove#readme",bugs:{url:"https://github.com/Sma1lboy/rove/issues"},engines:{bun:">=1.3.11"},scripts:{dev:"ROVE_DEV=1 bun --conditions=browser ./src/cli/rove.ts","dev:kobe":"KOBE_DEV=1 bun --conditions=browser ./src/cli/kobe.ts","dev:mock":"KOBE_DEV=1 bun ./src/tui-react/mock/host.tsx","dev:mock-react":"KOBE_DEV=1 bun ./src/tui-react/mock/host.tsx","dev:mock-react-task-dialogs":"KOBE_DEV=1 bun ./src/tui-react/component/mock-dialogs-host.tsx","dev:mock-react-filetree":"KOBE_DEV=1 bun ./src/tui-react/panes/filetree/mock-host.tsx","dev:mock-react-sidebar":"KOBE_DEV=1 bun ./src/tui-react/panes/sidebar/mock-host.tsx","dev:mock-react-terminal":"KOBE_DEV=1 bun ./src/tui-react/panes/terminal/mock-host.tsx","dev:mock-react-dialogs":"KOBE_DEV=1 bun ./src/tui-react/mock/dialogs-host.tsx","dev:mock-react-workspace":"KOBE_DEV=1 bun ./src/tui-react/workspace/mock-host.tsx","dev:sandbox":"bun run scripts/dev-sandbox.ts run","dev:sandbox:reset":"bun run scripts/dev-sandbox.ts reset",build:"bun run scripts/build.ts","build:with-web":"bun run build",compile:"bun run scripts/compile.ts",typecheck:"tsc --noEmit","check-i18n":"bun run scripts/check-i18n.ts",test:"bun run test:fast && bun run test:socket","perf:golden":"bun scripts/perf-golden.ts","pty:soak":"bun scripts/pty-soak.ts","test:fast":"vitest run --passWithNoTests --minWorkers=1 --maxWorkers=8","test:socket":"KOBE_INCLUDE_SOCKET=1 vitest run test/daemon --pool forks --minWorkers=1 --maxWorkers=4 --passWithNoTests","test:socket:coverage":"KOBE_INCLUDE_SOCKET=1 KOBE_COVERAGE_DAEMON=1 vitest run test/daemon --coverage --pool forks --minWorkers=1 --maxWorkers=4 --passWithNoTests","test:behavior":"KOBE_INCLUDE_BEHAVIOR=1 vitest run test/behavior --pool forks --minWorkers=1 --maxWorkers=1 --retry=2 --passWithNoTests","test:render":"bun test test/render --coverage --coverage-reporter=text --coverage-reporter=lcov --coverage-dir=coverage-render",coverage:"vitest run --coverage --passWithNoTests",bench:"vitest bench --run",lint:"biome check .",knip:"knip-bun",postinstall:"bun run scripts/check-preview-deps.ts || true",prepublishOnly:"bun run typecheck && bun run build"},"//":"biome.json + bunfig.toml live at the monorepo root since they apply repo-wide; bun.lock also lives at root (workspace-shared).",dependencies:{"@ansi-tools/parser":"^1.0.15","@opentui/core":"0.4.3","@opentui/react":"0.4.3","@xterm/addon-serialize":"^0.14.0","@xterm/addon-unicode11":"^0.9.0","@xterm/headless":"^6.0.0","node-pty":"^1.1.0",react:"^19.2.8",ws:"^8.18.0"},devDependencies:{"@biomejs/biome":"1.9.4","@sma1lboy/kobe-daemon":"0.7.14","@tsconfig/bun":"1.0.10","@types/bun":"1.3.14","@types/node":"25.6.2","@types/react":"^19.2.0","@vitest/coverage-v8":"2.1.9",knip:"^6.14.2","kobe-web":"workspace:*","react-devtools-core":"^7.0.1",typescript:"5.8.2",vitest:"2.1.9"},trustedDependencies:[]}});var Wv={};g$(Wv,{repoSlug:()=>LY,releasePageUrl:()=>fR,recommendedGlobalInstallCommand:()=>ER,isNewerSemver:()=>SR,fetchReleaseSummaries:()=>cK,fetchReleaseNotesRange:()=>xR,fetchReleaseNotes:()=>wR,compareSemver:()=>B3,checkLatestVersion:()=>jY,breakingVersionsCrossed:()=>uK,UPDATE_SCRIPT_URL:()=>nL,UPDATE_COMMAND:()=>WZ,PACKAGE_NAME:()=>IR,CURRENT_VERSION:()=>A$,BREAKING_VERSIONS:()=>EJ});function LY(){let $=pL.repository?.url;if(!$)return null;let Z=$.match(/github\.com[:/]([^/]+)\/([^/.]+)/);if(!Z||!Z[1]||!Z[2])return null;return`${Z[1]}/${Z[2]}`}function ER(){return`npm install -g ${IR}@latest`}function uK($,Z,J=EJ){let[X,z]=B3($,Z)<=0?[$,Z]:[Z,$];return J.filter((G)=>B3(G,X)>0&&B3(G,z)<=0)}async function oJ0($){let Z=new AbortController,J=setTimeout(()=>Z.abort(),iL);try{let X=$.replace("/","%2F"),z=await fetch(`https://registry.npmjs.org/${X}/latest`,{signal:Z.signal,headers:{accept:"application/json"}});if(!z.ok)return null;let G=await z.json();if(typeof G.version!=="string")return null;return G.version}catch{return null}finally{clearTimeout(J)}}function SR($,Z){return B3($,Z)>0}function B3($,Z){let J=(G)=>G.split("-")[0]??G,X=J($).split(".").map((G)=>Number.parseInt(G,10)),z=J(Z).split(".").map((G)=>Number.parseInt(G,10));for(let G=0;G<3;G++){let W=X[G]??0,H=z[G]??0;if(Number.isNaN(W)||Number.isNaN(H))return 0;if(W>H)return 1;if(W<H)return-1}return 0}async function jY($={}){let Z=process.env.KOBE_FAKE_UPDATE;if(Z)return{current:A$,latest:Z,hasUpdate:SR(Z,A$)};if(WH()&&!$.force)return null;let J=await oJ0(IR);if(!J)return null;return{current:A$,latest:J,hasUpdate:SR(J,A$)}}function Gv($){if(typeof $!=="string")return null;return $.match(/^v(\d+\.\d+\.\d+)$/)?.[1]??null}async function wR($){let Z=LY();if(!Z)return null;let J=`v${$}`,X=new AbortController,z=setTimeout(()=>X.abort(),iL);try{let G=await fetch(`https://api.github.com/repos/${Z}/releases/tags/${J}`,{signal:X.signal,headers:{accept:"application/vnd.github+json","x-github-api-version":"2022-11-28"}});if(!G.ok)return null;let W=await G.json();if(typeof W.body!=="string"||typeof W.html_url!=="string")return null;return{body:W.body,url:W.html_url,version:$}}catch{return null}finally{clearTimeout(z)}}async function xR($){let Z=LY();if(!Z)return[];let J=$.limit??100,X=new AbortController,z=setTimeout(()=>X.abort(),iL);try{let G=await fetch(`https://api.github.com/repos/${Z}/releases?per_page=${J}`,{signal:X.signal,headers:{accept:"application/vnd.github+json","x-github-api-version":"2022-11-28"}});if(!G.ok)return[];let W=await G.json();if(!Array.isArray(W))return[];return W.map((H)=>{let U=Gv(H.tag_name);if(!U||typeof H.html_url!=="string"||typeof H.body!=="string")return null;if(B3(U,$.current)<=0)return null;if(B3(U,$.latest)>0)return null;return{version:U,url:H.html_url,body:H.body}}).filter((H)=>H!==null)}catch{return[]}finally{clearTimeout(z)}}async function cK($=12){let Z=LY();if(!Z)return[];let J=new AbortController,X=setTimeout(()=>J.abort(),iL);try{let z=await fetch(`https://api.github.com/repos/${Z}/releases?per_page=${$}`,{signal:J.signal,headers:{accept:"application/vnd.github+json","x-github-api-version":"2022-11-28"}});if(!z.ok)return[];let G=await z.json();if(!Array.isArray(G))return[];return G.map((W)=>{let H=Gv(W.tag_name);if(!H||typeof W.html_url!=="string")return null;return{version:H,url:W.html_url}}).filter((W)=>W!==null)}catch{return[]}finally{clearTimeout(X)}}function fR($){let Z=LY();if(!Z)return null;return`https://github.com/${Z}/releases/tag/v${$}`}var A$,IR,nL="https://raw.githubusercontent.com/Sma1lboy/rove/main/scripts/update.sh",WZ,EJ,iL=3000;var w8=a(()=>{Yv();L5();A$=pL.version,IR=pL.name;WZ=`curl -fsSL ${nL} | sh`;EJ=[]});var qv={};g$(qv,{stampResetGate:()=>oL,resetGateBlockers:()=>Hv,enforceResetGate:()=>yR,LAST_RUN_VERSION_KEY:()=>gR});function Hv($,Z=A$,J=EJ){if(typeof $!=="string"||$.length===0)return[];let[X,z]=B3($,Z)<=0?[$,Z]:[Z,$];return J.filter((G)=>B3(G,X)>0&&B3(G,z)<=0)}function yR(){let $=X$(),Z=_4()[gR],J=Hv(Z);if(J.length>0){let X=typeof Z==="string"?Z:"unknown";console.error([`${$} ${A$}: cannot start \u2014 version ${J.join(", ")} introduced breaking changes`,`(last run: ${X}). Your daemon/session state may be incompatible.`,"","Run:",` ${$} reset # stop daemon + PTY host + sessions (tasks kept)`,` ${$} reset --hard # additionally wipe the task index + UI state`,"","Then relaunch Rove. Worktrees are never touched."].join(`
285
+ `)){X++;let G=ck(z);if(!G||!xJ0(G))continue;let W=dk(G,0),H={id:`codex:${Z}:${W}:${X}`,timestampMs:W,source:"codex"};if(!J||H.timestampMs>=J.timestampMs)J=H}return J}function ck($){let Z=$.trim();if(!Z)return null;try{let J=JSON.parse(Z);return LR(J)?J:null}catch{return null}}function dk($,Z){let J=typeof $.timestamp==="string"?Date.parse($.timestamp):Number.NaN;return Number.isFinite(J)?J:Z}function LR($){return typeof $==="object"&&$!==null&&!Array.isArray($)}var uk=($)=>SJ0($).then((Z)=>Z.mtimeMs,()=>0),IJ0,NR,EJ0,OR,mK,wJ0;var jR=a(()=>{WR();gL();C7();IJ0={listSessionFiles:($)=>bH($),readFile:($)=>mk($,"utf8"),statMtimeMs:uk};NR=class NR extends cL{deps;vendor="claude";cache=new Map;constructor($=IJ0){super();this.deps=$}async latestActivity($){let Z=await this.deps.listSessionFiles($),J=Z[0]?.mtimeMs??0,X=null,z=new Map;for(let G of Z.slice(0,4)){let W=this.cache.get(G.path),H;if(W&&G.mtimeMs>0&&W.mtimeMs===G.mtimeMs)H=W.marker;else{let U=await this.deps.readFile(G.path).catch(()=>"");H=vk(U,G.path,G.mtimeMs)}if(z.set(G.path,{mtimeMs:G.mtimeMs,marker:H}),H&&(!X||H.timestampMs>X.timestampMs))X=H}return this.cache=z,{marker:X,mtimeMs:J}}async latestActivityInFile($){let Z=await(this.deps.statMtimeMs??uk)($);if(Z===0)return null;let J=await this.deps.readFile($).catch(()=>"");return{marker:vk(J,$,Z),mtimeMs:Z}}};EJ0={findLatestRollout:($)=>zR($),readFile:($)=>mk($,"utf8")};OR=class OR extends cL{deps;vendor="codex";cache=null;constructor($=EJ0){super();this.deps=$}async latestActivity($){if(!$)return{marker:null,mtimeMs:0};let Z=await this.deps.findLatestRollout($);if(!Z)return{marker:null,mtimeMs:0};if(this.cache&&this.cache.path===Z.path&&Z.mtimeMs>0&&this.cache.mtimeMs===Z.mtimeMs)return{marker:this.cache.marker,mtimeMs:Z.mtimeMs};let J=await this.deps.readFile(Z.path).catch(()=>"");if(!J)return{marker:null,mtimeMs:Z.mtimeMs};let X=fJ0(J,Z.path);return this.cache={path:Z.path,mtimeMs:Z.mtimeMs,marker:X},{marker:X,mtimeMs:Z.mtimeMs}}};mK=class mK extends cL{vendor;constructor($){super();this.vendor=$}supportsCompletionMarkers(){return!1}async latestActivity(){return{marker:null,mtimeMs:0}}};wJ0=new Set(["task_complete","turn_complete","turn_aborted"])});function gJ0($){return{vendor:$,builtin:!1,displayName:$,defaultCommand:[$],history:mL,detectAccount:async()=>({binary:{found:!1,error:"custom engine: Rove has no account detector for it"},account:{kind:"none"}}),createHookAdapter:()=>new hK($),createTurnDetector:()=>new mK($)}}function D$($){return h7($)?VR[$]:gJ0($)}function lk($){return D$($).history.readHistory!==mL.readHistory}function _R($){let Z=D$($).terminalTitle?.statusPrefixes;return Z&&Z.length>0?Z:pk}function kH($,Z){let J=Z?_R(Z):pk;for(let X of[...J].sort((z,G)=>G.length-z.length)){if(!$.startsWith(X))continue;let z=$.slice(X.length).trimStart();if(z.length===0)return $;return z}return $}function dL($,Z){let J=D$($).terminalTitle,X=J?.workingPrefixes;if(J?.ownsStatus!==!0||!X||X.length===0)return null;let z=Z.trim();if(z.length===0)return null;return X.some((G)=>z.startsWith(G))?"working":"rest"}function nk(){return Object.values(VR).filter(($)=>$.quotaUsage).map(($)=>$.vendor)}var VR,pk;var C7=a(()=>{u7();SJ();Eb();kb();db();nb();ob();Bk();yk();CR();uL();jR();VR={claude:{vendor:"claude",builtin:!0,displayName:"Claude",defaultCommand:["claude"],history:wk,detectAccount:($)=>IH($),createHookAdapter:()=>new nP,createTurnDetector:()=>new NR,capabilities:Sb,identity:Ib,spinnerFrames:kk,terminalTitle:{ownsStatus:!0,statusPrefixes:["\u2733","\u2802","\u2810","\u25D0","\u25D1"],workingPrefixes:["\u2802","\u2810","\u25D0","\u25D1"]},quotaUsage:()=>cb()},codex:{vendor:"codex",builtin:!0,displayName:"Codex",defaultCommand:["codex"],effortLevels:["none","low","medium","high","xhigh"],history:xk,detectAccount:($)=>EH($),createHookAdapter:()=>new rP,createTurnDetector:()=>new OR,capabilities:lb,identity:pb,terminalTitle:{ownsStatus:!0,launchArgs:["-c",'tui.terminal_title=["activity","thread-title"]'],statusPrefixes:["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],workingPrefixes:["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"]},quotaUsage:()=>Uk()},copilot:{vendor:"copilot",builtin:!0,displayName:"Copilot",defaultCommand:["copilot"],history:fk,detectAccount:($)=>wH($),createHookAdapter:()=>new hK("copilot"),createTurnDetector:()=>new mK("copilot")},kimi:{vendor:"kimi",builtin:!0,displayName:"Kimi",defaultCommand:["kimi"],firstMessageDelivery:"paste",processNames:["kimi-co"],history:gk,detectAccount:($)=>SL($),createHookAdapter:()=>new hK("kimi"),createTurnDetector:()=>new mK("kimi")}};pk=[...new Set(Object.values(VR).flatMap(($)=>$.terminalTitle?.statusPrefixes??[]))]});function DR($){return D$($).createHookAdapter()}class hK{vendor;constructor($){this.vendor=$}supportsHooks(){return!1}globalSettingsPath(){return""}activityDetailFromPayload(){return}sessionFromPayload(){return}async installActivityHooks(){}async removeActivityHooks(){}supportsWorktreeSync(){return!1}async removeWorktreeSyncHook(){}async installWorktreeWatchHook(){}async removeWorktreeWatchHook(){}}var CR=a(()=>{C7()});function lL($){return yJ0.includes($)}function ik($){return bJ0.includes($)}var yJ0,bJ0;var AR=a(()=>{yJ0=["session-start","turn-start","turn-complete","turn-failed","turn-interrupted","awaiting-input","session-end","tool-pre","tool-post","tool-failed","pre-compact","post-compact","subagent-start","subagent-stop"];bJ0=["session-start","turn-start","turn-complete","turn-failed","turn-interrupted","awaiting-input","session-end"]});var zv={};g$(zv,{runHookSubcommand:()=>cJ0,readTextWithTimeout:()=>sk,parseWorktreeRemovePath:()=>Zv,parseWorktreeAddPath:()=>$v,ensureGlobalKobeHooks:()=>RR});import{homedir as kJ0}from"os";import{join as rk,resolve as PR}from"path";async function sk($,Z=vJ0){let J;try{return await Promise.race([$(),new Promise((X)=>{J=setTimeout(()=>X(""),Z)})])}finally{if(J!==void 0)clearTimeout(J)}}async function tk(){try{let $=await sk(()=>Bun.stdin.text());if(!$.trim())return{};let Z=JSON.parse($);return Z&&typeof Z==="object"&&!Array.isArray(Z)?Z:{}}catch{return{}}}function ok($,Z){for(let J=0;J<$.length;J++){if($[J]===Z)return $[J+1];if($[J].startsWith(`${Z}=`))return $[J].slice(Z.length+1)}return}function hJ0($){return!!$&&typeof $==="object"&&!Array.isArray($)}function ek($){let Z=[],J=/"([^"]*)"|'([^']*)'|(\S+)/g,X;while((X=J.exec($))!==null)Z.push(X[1]??X[2]??X[3]??"");return Z}function $v($){let Z=ek($),J=new Set(["-b","-B","--reason"]);for(let X=0;X+1<Z.length;X++){if(Z[X]!=="worktree"||Z[X+1]!=="add")continue;let z=X+2;while(z<Z.length){let G=Z[z];if(G==="&&"||G==="||"||G===";"||G==="|"||G===">"||G===">>")break;if(G.startsWith("-")){z+=J.has(G)?2:1;continue}return G}}return}function Zv($){let Z=ek($);for(let J=0;J+1<Z.length;J++){if(Z[J]!=="worktree"||Z[J+1]!=="remove")continue;let X=J+2;while(X<Z.length){let z=Z[X];if(z==="&&"||z==="||"||z===";"||z==="|"||z===">"||z===">>")break;if(z.startsWith("-")){X+=1;continue}return z}}return}async function uJ0(){let $=await tk(),Z=hJ0($.tool_input)?$.tool_input:{},J=typeof Z.command==="string"?Z.command:"";if(!J.includes("worktree"))return;let X=typeof $.cwd==="string"&&$.cwd?$.cwd:process.cwd(),z=$v(J),G=z?void 0:Zv(J);if(!z&&!G)return;let W=await BQ();if(!W)return;try{if(z)await W.request("worktree.reconcile",{cwd:X,worktreePath:PR(X,z)});else if(G)await W.request("worktree.archiveRemoved",{worktreePath:PR(X,G)})}finally{W.close()}}async function cJ0($){let[Z,...J]=$;if(Z==="setup"){await nJ0(J);return}if(Z===mJ0){try{await uJ0()}catch{}return}try{if(!Z||!lL(Z))return;let X=await tk(),z=ok(J,"--task-id"),G=typeof X.cwd==="string"&&X.cwd?X.cwd:process.cwd(),W=process.env.KOBE_TASK_ID,H=process.env.KOBE_TAB_ID,U=ok(J,"--engine"),K=Jv().filter((V)=>!U||V.vendor===U),N;for(let V of K)if(N=V.activityDetailFromPayload(Z,X),N)break;let L;for(let V of K)if(L=V.sessionFromPayload(X),L)break;let M=await BQ();if(!M)return;try{let V=z??W;await M.request("engine.reportEvent",{...V?{taskId:V}:{cwd:G},kind:Z,...U?{engine:U}:{},...H?{tabId:H}:{},...N?{detail:N}:{},...L?{sessionId:L.sessionId}:{},...L?.transcriptPath?{transcriptPath:L.transcriptPath}:{}})}finally{M.close()}}catch(X){if(process.env.KOBE_HOOK_DEBUG)console.error(`[rove hook] ${Z} failed:`,X instanceof Error?X.message:String(X))}}function dJ0(){return T8.map(($)=>DR($)).filter(($)=>$.supportsWorktreeSync())}function Jv(){return T8.map(($)=>DR($)).filter(($)=>$.supportsHooks())}function Xv(){return rk(kJ0(),".claude","settings.json")}function lJ0($){if(!$||$==="off")return;if($==="global")return Xv();if($.startsWith("repo:"))return rk(PR($.slice(5)),".claude","settings.json");return $}async function RR(){try{let $=pJ0();for(let Z of Jv()){let J=Z.globalSettingsPath();if(!J)continue;await Z.installActivityHooks(J,{toolEvents:$}),await Z.installWorktreeWatchHook(J)}await Qv()}catch{}}function pJ0(){try{for(let $ of j5().plugins){if(!$.enabled)continue;try{if(XZ($.root).manifest.events.some((Z)=>Z.on.startsWith("tool.")))return!0}catch{}}}catch{}return!1}async function Qv(){let $=dJ0();if($.length===0)return;let Z=l7(ak),J=new Set([Xv()]),X=lJ0(Z);if(X)J.add(X);for(let z of $)for(let G of J)await z.removeWorktreeSyncHook(G);if(Z!=="off")o3(ak,"off")}async function nJ0($){await Qv(),process.stdout.write(["rove hook setup is deprecated and now a no-op (cleanup only).","","The old external-worktree sync used a global WorktreeCreate hook, which is","a VCS provider hook \u2014 its presence broke `claude --worktree` / EnterWorktree","in every repo. Any hook Rove previously installed has been removed.","","Sync is now automatic: a `claude --worktree` (or any session) started in a","worktree under a repo Rove already tracks is adopted as a task on launch.","To adopt existing worktrees on demand, use the New Task dialog or `rove adopt`.",""].join(`
286
+ `))}var vJ0=500,mJ0="worktree-created",ak="externalWorktreeSync";var TR=a(()=>{C2();jQ();RJ();CR();AR();b4();u7()});var pL;var Yv=a(()=>{pL={$schema:"https://json.schemastore.org/package.json",name:"@sma1lboy/rove",version:"0.8.96",description:"Rove \u2014 the terminal-native agent multiplexer",type:"module",packageManager:"bun@1.3.13",bin:{kobe:"dist/cli/kobe.js",rove:"dist/cli/rove.js"},files:["dist/cli","dist/web-ui","dist/skills","dist/*.wav","README.md","LICENSE"],publishConfig:{access:"public"},repository:{type:"git",url:"git+https://github.com/Sma1lboy/rove.git"},homepage:"https://github.com/Sma1lboy/rove#readme",bugs:{url:"https://github.com/Sma1lboy/rove/issues"},engines:{bun:">=1.3.11"},scripts:{dev:"ROVE_DEV=1 bun --conditions=browser ./src/cli/rove.ts","dev:kobe":"KOBE_DEV=1 bun --conditions=browser ./src/cli/kobe.ts","dev:mock":"KOBE_DEV=1 bun ./src/tui-react/mock/host.tsx","dev:mock-react":"KOBE_DEV=1 bun ./src/tui-react/mock/host.tsx","dev:mock-react-task-dialogs":"KOBE_DEV=1 bun ./src/tui-react/component/mock-dialogs-host.tsx","dev:mock-react-filetree":"KOBE_DEV=1 bun ./src/tui-react/panes/filetree/mock-host.tsx","dev:mock-react-sidebar":"KOBE_DEV=1 bun ./src/tui-react/panes/sidebar/mock-host.tsx","dev:mock-react-terminal":"KOBE_DEV=1 bun ./src/tui-react/panes/terminal/mock-host.tsx","dev:mock-react-dialogs":"KOBE_DEV=1 bun ./src/tui-react/mock/dialogs-host.tsx","dev:mock-react-workspace":"KOBE_DEV=1 bun ./src/tui-react/workspace/mock-host.tsx","dev:sandbox":"bun run scripts/dev-sandbox.ts run","dev:sandbox:reset":"bun run scripts/dev-sandbox.ts reset",build:"bun run scripts/build.ts","build:with-web":"bun run build",compile:"bun run scripts/compile.ts",typecheck:"tsc --noEmit","check-i18n":"bun run scripts/check-i18n.ts",test:"bun run test:fast && bun run test:socket","perf:golden":"bun scripts/perf-golden.ts","pty:soak":"bun scripts/pty-soak.ts","test:fast":"vitest run --passWithNoTests --minWorkers=1 --maxWorkers=8","test:socket":"KOBE_INCLUDE_SOCKET=1 vitest run test/daemon --pool forks --minWorkers=1 --maxWorkers=4 --passWithNoTests","test:socket:coverage":"KOBE_INCLUDE_SOCKET=1 KOBE_COVERAGE_DAEMON=1 vitest run test/daemon --coverage --pool forks --minWorkers=1 --maxWorkers=4 --passWithNoTests","test:behavior":"KOBE_INCLUDE_BEHAVIOR=1 vitest run test/behavior --pool forks --minWorkers=1 --maxWorkers=1 --retry=2 --passWithNoTests","test:render":"bun test test/render --coverage --coverage-reporter=text --coverage-reporter=lcov --coverage-dir=coverage-render",coverage:"vitest run --coverage --passWithNoTests",bench:"vitest bench --run",lint:"biome check .",knip:"knip-bun",postinstall:"bun run scripts/check-preview-deps.ts || true",prepublishOnly:"bun run typecheck && bun run build"},"//":"biome.json + bunfig.toml live at the monorepo root since they apply repo-wide; bun.lock also lives at root (workspace-shared).",dependencies:{"@ansi-tools/parser":"^1.0.15","@opentui/core":"0.4.3","@opentui/react":"0.4.3","@xterm/addon-serialize":"^0.14.0","@xterm/addon-unicode11":"^0.9.0","@xterm/headless":"^6.0.0","node-pty":"^1.1.0",react:"^19.2.8",ws:"^8.18.0"},devDependencies:{"@biomejs/biome":"1.9.4","@sma1lboy/kobe-daemon":"0.7.14","@tsconfig/bun":"1.0.10","@types/bun":"1.3.14","@types/node":"25.6.2","@types/react":"^19.2.0","@vitest/coverage-v8":"2.1.9",knip:"^6.14.2","kobe-web":"workspace:*","react-devtools-core":"^7.0.1",typescript:"5.8.2",vitest:"2.1.9"},trustedDependencies:[]}});var Wv={};g$(Wv,{repoSlug:()=>LY,releasePageUrl:()=>fR,recommendedGlobalInstallCommand:()=>ER,isNewerSemver:()=>SR,fetchReleaseSummaries:()=>cK,fetchReleaseNotesRange:()=>xR,fetchReleaseNotes:()=>wR,compareSemver:()=>B3,checkLatestVersion:()=>jY,breakingVersionsCrossed:()=>uK,UPDATE_SCRIPT_URL:()=>nL,UPDATE_COMMAND:()=>WZ,PACKAGE_NAME:()=>IR,CURRENT_VERSION:()=>A$,BREAKING_VERSIONS:()=>EJ});function LY(){let $=pL.repository?.url;if(!$)return null;let Z=$.match(/github\.com[:/]([^/]+)\/([^/.]+)/);if(!Z||!Z[1]||!Z[2])return null;return`${Z[1]}/${Z[2]}`}function ER(){return`npm install -g ${IR}@latest`}function uK($,Z,J=EJ){let[X,z]=B3($,Z)<=0?[$,Z]:[Z,$];return J.filter((G)=>B3(G,X)>0&&B3(G,z)<=0)}async function oJ0($){let Z=new AbortController,J=setTimeout(()=>Z.abort(),iL);try{let X=$.replace("/","%2F"),z=await fetch(`https://registry.npmjs.org/${X}/latest`,{signal:Z.signal,headers:{accept:"application/json"}});if(!z.ok)return null;let G=await z.json();if(typeof G.version!=="string")return null;return G.version}catch{return null}finally{clearTimeout(J)}}function SR($,Z){return B3($,Z)>0}function B3($,Z){let J=(G)=>G.split("-")[0]??G,X=J($).split(".").map((G)=>Number.parseInt(G,10)),z=J(Z).split(".").map((G)=>Number.parseInt(G,10));for(let G=0;G<3;G++){let W=X[G]??0,H=z[G]??0;if(Number.isNaN(W)||Number.isNaN(H))return 0;if(W>H)return 1;if(W<H)return-1}return 0}async function jY($={}){let Z=process.env.KOBE_FAKE_UPDATE;if(Z)return{current:A$,latest:Z,hasUpdate:SR(Z,A$)};if(WH()&&!$.force)return null;let J=await oJ0(IR);if(!J)return null;return{current:A$,latest:J,hasUpdate:SR(J,A$)}}function Gv($){if(typeof $!=="string")return null;return $.match(/^v(\d+\.\d+\.\d+)$/)?.[1]??null}async function wR($){let Z=LY();if(!Z)return null;let J=`v${$}`,X=new AbortController,z=setTimeout(()=>X.abort(),iL);try{let G=await fetch(`https://api.github.com/repos/${Z}/releases/tags/${J}`,{signal:X.signal,headers:{accept:"application/vnd.github+json","x-github-api-version":"2022-11-28"}});if(!G.ok)return null;let W=await G.json();if(typeof W.body!=="string"||typeof W.html_url!=="string")return null;return{body:W.body,url:W.html_url,version:$}}catch{return null}finally{clearTimeout(z)}}async function xR($){let Z=LY();if(!Z)return[];let J=$.limit??100,X=new AbortController,z=setTimeout(()=>X.abort(),iL);try{let G=await fetch(`https://api.github.com/repos/${Z}/releases?per_page=${J}`,{signal:X.signal,headers:{accept:"application/vnd.github+json","x-github-api-version":"2022-11-28"}});if(!G.ok)return[];let W=await G.json();if(!Array.isArray(W))return[];return W.map((H)=>{let U=Gv(H.tag_name);if(!U||typeof H.html_url!=="string"||typeof H.body!=="string")return null;if(B3(U,$.current)<=0)return null;if(B3(U,$.latest)>0)return null;return{version:U,url:H.html_url,body:H.body}}).filter((H)=>H!==null)}catch{return[]}finally{clearTimeout(z)}}async function cK($=12){let Z=LY();if(!Z)return[];let J=new AbortController,X=setTimeout(()=>J.abort(),iL);try{let z=await fetch(`https://api.github.com/repos/${Z}/releases?per_page=${$}`,{signal:J.signal,headers:{accept:"application/vnd.github+json","x-github-api-version":"2022-11-28"}});if(!z.ok)return[];let G=await z.json();if(!Array.isArray(G))return[];return G.map((W)=>{let H=Gv(W.tag_name);if(!H||typeof W.html_url!=="string")return null;return{version:H,url:W.html_url}}).filter((W)=>W!==null)}catch{return[]}finally{clearTimeout(X)}}function fR($){let Z=LY();if(!Z)return null;return`https://github.com/${Z}/releases/tag/v${$}`}var A$,IR,nL="https://raw.githubusercontent.com/Sma1lboy/rove/main/scripts/update.sh",WZ,EJ,iL=3000;var w8=a(()=>{Yv();L5();A$=pL.version,IR=pL.name;WZ=`curl -fsSL ${nL} | sh`;EJ=[]});var qv={};g$(qv,{stampResetGate:()=>oL,resetGateBlockers:()=>Hv,enforceResetGate:()=>yR,LAST_RUN_VERSION_KEY:()=>gR});function Hv($,Z=A$,J=EJ){if(typeof $!=="string"||$.length===0)return[];let[X,z]=B3($,Z)<=0?[$,Z]:[Z,$];return J.filter((G)=>B3(G,X)>0&&B3(G,z)<=0)}function yR(){let $=X$(),Z=_4()[gR],J=Hv(Z);if(J.length>0){let X=typeof Z==="string"?Z:"unknown";console.error([`${$} ${A$}: cannot start \u2014 version ${J.join(", ")} introduced breaking changes`,`(last run: ${X}). Your daemon/session state may be incompatible.`,"","Run:",` ${$} reset # stop daemon + PTY host + sessions (tasks kept)`,` ${$} reset --hard # additionally wipe the task index + UI state`,"","Then relaunch Rove. Worktrees are never touched."].join(`
287
287
  `)),process.exit(1)}if(Z!==A$)oL()}function oL(){try{n2({[gR]:A$})}catch{}}var gR="app.lastRunVersion";var aL=a(()=>{D2();w8();h4()});import{existsSync as Bv,readFileSync as aJ0}from"fs";import{homedir as rJ0}from"os";import{join as Kv,resolve as Uv}from"path";import{fileURLToPath as sJ0}from"url";function vR($=process.env){return`${X$($)} skill install`}function rL(){let $=sJ0(import.meta.url);return[Uv($,"../../../../../.agents/skills/kobe"),Uv($,"../../skills/rove")].find((J)=>Bv(Kv(J,"SKILL.md")))??null}function sL($={}){let Z=$.source!==void 0?$.source:rL(),J=$.agent===void 0?[]:typeof $.agent==="string"?[$.agent]:$.agent;return["skills","add",Z??eJ0,"--skill",p3,...$.global===!1?[]:["--global"],...J.flatMap((X)=>["--agent",X])]}function VY($={}){return`npx ${sL($).join(" ")}`}async function mR($,Z){return await Bun.spawn(["npx",...sL({...$===void 0?{}:{agent:$},global:Z})],{stdin:"inherit",stdout:"inherit",stderr:"inherit"}).exited}function tL($={}){let Z=$.home??rJ0(),J=$.cwd??process.cwd();return[Z,J].flatMap((X)=>tJ0.map((z)=>Kv(X,z)))}function $X0($){let Z=$.match(/(?:rove|kobe)-skill-version:\s*(\d+)/);return Z?Number.parseInt(Z[1],10):null}function dK($){let Z=tL($).find((z)=>Bv(z));if(!Z)return{installed:!1,installedVersion:null,currentVersion:bR,stale:!1};let J=null;try{J=$X0(aJ0(Z,"utf8"))}catch{J=null}let X=J===null||J<bR;return{installed:!0,installedVersion:J,currentVersion:bR,stale:X}}function ZX0(){return new Promise(($)=>{process.stdin.resume(),process.stdin.once("data",(Z)=>{process.stdin.pause(),$(String(Z))})})}async function Fv($={}){let Z=X$(),J=vR(),X=dK();if(!X.installed){if(l7(kR)==="1")return;o3(kR,"1"),process.stderr.write(`
288
288
  ${Z}: the Rove agent skill isn't installed \u2014 install it so your coding agent can drive Rove via \`${Z} api\`:
289
289
  ${J}
@@ -727,7 +727,7 @@ ${$.t("update.updateComplete")}
727
727
  ${$.t("update.updateFailed",{code:String(J)})}
728
728
  `),process.stdout.write($.t("update.pressAnyKey")),await Jq0(),process.exit(J)}var tI=a(()=>{w8()});import{spawn as Xq0}from"child_process";import{TextAttributes as gq}from"@opentui/core";function Qq0($){if(!$)return!1;let Z=process.platform,[J,X]=Z==="darwin"?["open",[$]]:Z==="win32"?["cmd",["/c","start","",$]]:["xdg-open",[$]];try{return Xq0(J,X,{stdio:"ignore",detached:!0}).unref(),!0}catch{return!1}}function eI($){return $.replace(/\r\n/g,`
729
729
  `).split(`
730
- `).map((Z)=>Z.trim()).filter(Boolean)}function Do($){let{theme:Z}=l0(),J=Z1(),X=E4(),[z,G]=dQ.useState(null),[W,H]=dQ.useState([]),[U,K]=dQ.useState(!0),[N,L]=dQ.useState("update"),[M,V]=dQ.useState(null),P=z?.latest??A$,_=W[0]?.url??fR(P),C=[{id:"update",key:"U",label:J("update.actions.updateNow"),detail:WZ},{id:"release",key:"R",label:J("update.actions.openRelease"),detail:_??J("update.releaseUrlUnavailable")},{id:"close",key:"Q",label:J("update.actions.close"),detail:J("update.actions.closeDetail")}];dQ.useEffect(()=>{f()},[]);async function f(){let x=await jY({force:!0});G(x);let b=x?.latest??A$,v=await xR({current:A$,latest:b});H(v),K(!1)}function E(x){let b=C.map((o)=>o.id),u=(b.indexOf(N)+x+b.length)%b.length;L(b[u]??"update")}function S(x=N){if(x==="close"){$.onClose();return}if(x==="release"){V(Qq0(_)?J("update.statusReleaseOpened"):J("update.statusReleaseError"));return}T()}async function T(){V(J("update.statusRunningUpdater")),await new Promise((x)=>setTimeout(x,30)),await $_({renderer:X,t:J,targetLabel:P,command:WZ})}return g1(()=>({bindings:[{key:"up",cmd:()=>E(-1)},{key:"down",cmd:()=>E(1)},{key:"k",cmd:()=>E(-1)},{key:"j",cmd:()=>E(1)},{key:"return",cmd:()=>S()},{key:"u",cmd:()=>S("update")},{key:"r",cmd:()=>S("release")},...a7(()=>S("close"))]})),R.jsxDEV("box",{flexDirection:"column",flexGrow:1,backgroundColor:Z.background,paddingTop:1,paddingLeft:2,paddingRight:2,children:[R.jsxDEV("box",{flexDirection:"row",justifyContent:"space-between",flexShrink:0,children:[R.jsxDEV("text",{fg:Z.text,attributes:gq.BOLD,wrapMode:"none",children:J("update.pageTitle")},void 0,!1,void 0,this),R.jsxDEV("text",{fg:Z.textMuted,wrapMode:"none",onMouseUp:()=>S("close"),children:"q / esc"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),R.jsxDEV("box",{flexDirection:"row",gap:2,flexShrink:0,paddingTop:1,children:[R.jsxDEV("text",{fg:Z.textMuted,wrapMode:"none",children:J("update.current")},void 0,!1,void 0,this),R.jsxDEV("text",{fg:Z.text,attributes:gq.BOLD,wrapMode:"none",children:["v",A$]},void 0,!0,void 0,this),R.jsxDEV("text",{fg:Z.textMuted,wrapMode:"none",children:J("update.latest")},void 0,!1,void 0,this),R.jsxDEV("text",{fg:z?.hasUpdate?Z.warning:Z.success,attributes:gq.BOLD,wrapMode:"none",children:["v",P]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),R.jsxDEV("box",{flexDirection:"column",flexShrink:0,paddingTop:1,gap:0,children:C.map((x)=>R.jsxDEV("box",{flexDirection:"row",gap:1,paddingLeft:1,paddingRight:1,backgroundColor:N===x.id?Z.primary:void 0,onMouseUp:()=>S(x.id),children:[R.jsxDEV("box",{width:4,flexShrink:0,children:R.jsxDEV("text",{fg:N===x.id?Z.selectedListItemText:Z.accent,attributes:gq.BOLD,wrapMode:"none",children:["[",x.key,"]"]},void 0,!0,void 0,this)},void 0,!1,void 0,this),R.jsxDEV("box",{width:14,flexShrink:0,children:R.jsxDEV("text",{fg:N===x.id?Z.selectedListItemText:Z.text,wrapMode:"none",children:x.label},void 0,!1,void 0,this)},void 0,!1,void 0,this),R.jsxDEV("text",{fg:N===x.id?Z.selectedListItemText:Z.textMuted,wrapMode:"word",children:x.detail},void 0,!1,void 0,this)]},x.id,!0,void 0,this))},void 0,!1,void 0,this),M?R.jsxDEV("text",{fg:Z.info,wrapMode:"word",children:M},void 0,!1,void 0,this):null,R.jsxDEV("box",{flexShrink:0,paddingTop:1,children:R.jsxDEV("text",{fg:Z.textMuted,attributes:gq.DIM,wrapMode:"none",children:J("update.changesSectionHeader",{from:A$,to:P})},void 0,!1,void 0,this)},void 0,!1,void 0,this),R.jsxDEV("scrollbox",{flexGrow:1,flexShrink:1,stickyScroll:!1,verticalScrollbarOptions:{trackOptions:{backgroundColor:Z.background,foregroundColor:Z.borderActive}},children:R.jsxDEV("box",{flexDirection:"column",paddingRight:1,paddingBottom:1,gap:0,children:[U?R.jsxDEV("text",{fg:Z.textMuted,children:J("update.loadingNotes")},void 0,!1,void 0,this):null,!U&&W.length===0?R.jsxDEV("text",{fg:Z.textMuted,wrapMode:"word",children:J("update.notesUnavailable")},void 0,!1,void 0,this):null,W.map((x)=>R.jsxDEV("box",{flexDirection:"column",paddingBottom:1,gap:0,children:[R.jsxDEV("text",{fg:Z.text,attributes:gq.BOLD,wrapMode:"none",children:["v",x.version]},void 0,!0,void 0,this),eI(x.body).map((b,v)=>R.jsxDEV("text",{fg:Z.textMuted,wrapMode:"word",children:b},`${v}:${b}`,!1,void 0,this))]},x.version,!0,void 0,this))]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var dQ;var $E=a(async()=>{w8();Q$();tI();r0();await e1([u4(),$$(),C4()]);dQ=H1(q1(),1)});import{TextAttributes as Ao}from"@opentui/core";function zq0($){if(!$)return[];let Z=[];for(let J of $.listTasks())if(J.repo&&!Z.includes(J.repo))Z.push(J.repo);return Z}function Yq0($,Z){let J=Date.parse($);if(!Number.isFinite(J))return"";let X=Math.round((Z-J)/60000);if(X<60)return`${Math.max(X,0)}m`;let z=Math.round(X/60);if(z<24)return`${z}h`;return`${Math.round(z/24)}d`}function Po($){let{theme:Z}=l0(),J=Z1(),X=zq0($.orchestrator),[z,G]=X6.useState(()=>{let u=$.focusRepo?X.indexOf($.focusRepo):-1;return u>=0?u:0}),W=X[z],[H,U]=X6.useState(null),[K,N]=X6.useState(null),[L,M]=X6.useState(0),[V,P]=X6.useState(!1),[_,C]=X6.useState(!1),[f,E]=X6.useState(null);X6.useEffect(()=>{let u=!1,o=$.orchestrator;if(!o||!W){U([]);return}return N(null),o.listWorkItems({repo:W,limit:30,...V?{assignee:"@me"}:{},...L>0?{refresh:!0}:{}}).then((m)=>{if(!u)U(m.items)}).catch((m)=>{if(u)return;N(m instanceof Error?m.message:String(m)),U([])}),()=>{u=!0}},[$.orchestrator,W,V,L]);let S=H??[],[T,x]=X6.useState(0);X6.useEffect(()=>{x((u)=>w4(u,S.length))},[S.length]);async function b(){let u=$.orchestrator,o=S[T];if(!u||!o||!W||_)return;C(!0),E(J("workItems.starting",{number:o.number}));try{let m=await u.startWorkItem({repo:W,number:o.number});if(m.started)$.onOpenTask?.(m.taskId);else E(J("workItems.startedNoEngine",{title:m.title}))}catch(m){E(m instanceof Error?m.message:String(m))}finally{C(!1)}}g1(()=>({enabled:$.focused!==!1,bindings:[...a7($.onClose),{key:"j",cmd:()=>x((u)=>w4(u+1,S.length))},{key:"down",cmd:()=>x((u)=>w4(u+1,S.length))},{key:"k",cmd:()=>x((u)=>w4(u-1,S.length))},{key:"up",cmd:()=>x((u)=>w4(u-1,S.length))},{key:"tab",cmd:()=>G((u)=>X.length?(u+1)%X.length:0)},{key:"a",cmd:()=>P((u)=>!u)},{key:"r",cmd:()=>M((u)=>u+1)},{key:"return",cmd:()=>void b()}]}));let v=Date.now();return R.jsxDEV("box",{flexDirection:"column",flexGrow:1,padding:1,children:[R.jsxDEV("box",{flexDirection:"row",justifyContent:"space-between",children:[R.jsxDEV("text",{attributes:Ao.BOLD,fg:Z.accent,children:J("workItems.title")},void 0,!1,void 0,this),R.jsxDEV("text",{fg:Z.textMuted,children:[W?U9(W,X):J("workItems.noRepo"),V?` ${J("workItems.assignedFilter")}`:""]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),K?R.jsxDEV("box",{flexDirection:"column",marginTop:1,children:R.jsxDEV("text",{fg:Z.error,children:K},void 0,!1,void 0,this)},void 0,!1,void 0,this):H===null?R.jsxDEV("text",{fg:Z.textMuted,children:J("common.loading")},void 0,!1,void 0,this):S.length===0?R.jsxDEV("text",{fg:Z.textMuted,children:J("workItems.empty")},void 0,!1,void 0,this):R.jsxDEV("box",{flexDirection:"column",marginTop:1,flexGrow:1,children:S.map((u,o)=>{let m=iJ(Z,{cursor:o===T,selected:!1});return R.jsxDEV("box",{flexDirection:"column",flexShrink:0,...m.backgroundColor?{backgroundColor:m.backgroundColor}:{},children:[R.jsxDEV("box",{flexDirection:"row",gap:0,children:[R.jsxDEV("text",{fg:m.markerColor,wrapMode:"none",children:m.marker},void 0,!1,void 0,this),R.jsxDEV("box",{flexDirection:"row",flexGrow:1,paddingLeft:1,paddingRight:1,gap:1,children:[R.jsxDEV("text",{fg:Z.textMuted,wrapMode:"none",children:`#${u.number}`},void 0,!1,void 0,this),R.jsxDEV("text",{fg:Z.text,attributes:o===T?Ao.BOLD:void 0,wrapMode:"none",flexGrow:1,children:u.title},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),R.jsxDEV("box",{flexDirection:"row",gap:0,children:[R.jsxDEV("text",{fg:m.markerColor,wrapMode:"none",children:m.marker},void 0,!1,void 0,this),R.jsxDEV("box",{flexDirection:"row",flexGrow:1,paddingLeft:2,paddingRight:1,gap:1,children:[R.jsxDEV("text",{fg:Z.textMuted,wrapMode:"none",flexGrow:1,children:[u.author,...u.labels.slice(0,2)].filter(Boolean).join(" \xB7 ")},void 0,!1,void 0,this),R.jsxDEV("text",{fg:Z.textMuted,wrapMode:"none",children:Yq0(u.updatedAt,v)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},`${u.number}`,!0,void 0,this)})},void 0,!1,void 0,this),f?R.jsxDEV("text",{fg:Z.textMuted,children:f},void 0,!1,void 0,this):null]},void 0,!0,void 0,this)}var X6;var Ro=a(async()=>{g8();L3();Q$();r0();await e1([$$(),C4()]);X6=H1(q1(),1)});import{TextAttributes as To}from"@opentui/core";function So($){return $.flatMap((Z)=>Z.worktrees)}function qq0($,Z){let J=(z)=>z.replace(/^\/private\//,"/").replace(/\/+$/,""),X=J(Z);return $.listTasks().find((z)=>z.worktreePath&&J(z.worktreePath)===X)?.id}function Io($){let{theme:Z}=l0(),J=n$(),X=Z1(),[z,G]=tJ.useState(null),[W,H]=tJ.useState(0),U=()=>H((u)=>u+1);tJ.useEffect(()=>{let u=!1,o=!1,m=$.orchestrator;if(!m){G([]);return}return m.listWorktrees({network:!1}).then((e)=>{if(!u&&!o)G(e)}).catch(()=>{}),m.listWorktrees().then((e)=>{if(o=!0,u)return;G(e);let t=new Set(So(e).map((Y0)=>Y0.path));N((Y0)=>Y0.filter((F0)=>t.has(F0)))}).catch(()=>{}),()=>{u=!0}},[$.orchestrator,W]);let[K,N]=tJ.useState([]),L=(z??[]).map((u)=>({...u,worktrees:u.worktrees.filter((o)=>!K.includes(o.path))})),M=So(L),[V,P]=tJ.useState(0);tJ.useEffect(()=>{P((u)=>w4(u,M.length))},[M.length]);let[_,C]=tJ.useState(null);async function f(u,o){let m=$.orchestrator;if(!m)return;N((e)=>[...e,u.path]);try{await m.removeWorktree(u.path,o),U()}catch(e){if(N((t)=>t.filter((Y0)=>Y0!==u.path)),!o&&e instanceof Error&&Gq0.test(e.message)){if(await N4.show(J,X("worktrees.delete.forceTitle"),X("worktrees.delete.forceBody",{branch:u.branch||u.path}),X("common.cancel"),X("worktrees.delete.button"))===!0)await f(u,!0);return}console.error(`[rove worktrees] ${X("worktrees.delete.failed",{error:String(e)})}`)}}async function E(u){if(!$.orchestrator||_||K.includes(u.path))return;if(await N4.show(J,X("worktrees.delete.confirmTitle"),X("worktrees.delete.confirmBody",{branch:u.branch||u.path}),X("common.cancel"),X("worktrees.delete.button"))!==!0)return;f(u,!1)}async function S(u){let o=$.orchestrator;if(!o||_)return;let m=qq0(o,u.path);if(!m){console.error(`[rove worktrees] ${X("worktrees.land.noTask")}`);return}if(await N4.show(J,X("worktrees.land.confirmTitle"),X("worktrees.land.confirmBody",{branch:u.branch||u.path}),X("common.cancel"),X("worktrees.land.button"))!==!0)return;C(u.path);try{let t=await o.landTask(m);console.error(`[rove worktrees] ${X("worktrees.land.done",{branch:t.branch,landedOn:t.landedOn,commit:t.commit})}`),U()}catch(t){let Y0=t instanceof Error?t.message:String(t);if(Wq0.test(Y0))console.error(`[rove worktrees] ${X("worktrees.land.conflict",{files:Y0})}`);else if(Hq0.test(Y0))console.error(`[rove worktrees] ${X("worktrees.land.dirtyBase")}`);else console.error(`[rove worktrees] ${X("worktrees.land.failed",{error:Y0})}`)}finally{C(null)}}g1(()=>({enabled:J.stack.length===0,bindings:[...a7($.onClose),{key:"up",cmd:()=>P((u)=>w4(u-1,M.length))},{key:"down",cmd:()=>P((u)=>w4(u+1,M.length))},{key:"d",cmd:()=>{let u=M[V];if(u)E(u)}},{key:"l",cmd:()=>{let u=M[V];if(u)S(u)}}]}));function T(u){if(u===!0)return R.jsxDEV("text",{fg:Z.success,children:[" ",X("worktrees.badge.remoteOn")]},void 0,!0,void 0,this);if(u===!1)return R.jsxDEV("text",{fg:Z.warning,children:[" ",X("worktrees.badge.remoteOff")]},void 0,!0,void 0,this);return R.jsxDEV("text",{fg:Z.textMuted,children:[" ",X("worktrees.badge.remoteUnknown")]},void 0,!0,void 0,this)}function x(u){if(u.verdictReason==="dirty"||u.verdictReason==="fresh")return null;let o=u.verdict==="merged"?Z.success:u.verdict==="stale"?Z.warning:Z.accent;return R.jsxDEV("text",{fg:o,children:[" ",X(`worktrees.verdict.${u.verdictReason}`)]},void 0,!0,void 0,this)}let b=z===null,v=0;return R.jsxDEV("scrollbox",{flexGrow:1,backgroundColor:Z.background,paddingTop:1,paddingLeft:2,paddingRight:2,paddingBottom:1,verticalScrollbarOptions:{trackOptions:{foregroundColor:"transparent"}},children:[R.jsxDEV("box",{flexDirection:"row",justifyContent:"space-between",children:R.jsxDEV("text",{attributes:To.BOLD,fg:Z.text,children:X("worktrees.title")},void 0,!1,void 0,this)},void 0,!1,void 0,this),b?R.jsxDEV("text",{fg:Z.textMuted,children:X("worktrees.loading")},void 0,!1,void 0,this):L.length===0?R.jsxDEV("text",{fg:Z.textMuted,children:X("worktrees.noProjects")},void 0,!1,void 0,this):L.map((u)=>{let o=v;return v+=u.worktrees.length,R.jsxDEV("box",{gap:0,paddingTop:1,children:[R.jsxDEV("text",{fg:Z.textMuted,wrapMode:"none",children:u.repo},void 0,!1,void 0,this),u.worktrees.length===0?R.jsxDEV("text",{fg:Z.textMuted,wrapMode:"none",children:X("worktrees.noWorktrees")},void 0,!1,void 0,this):u.worktrees.map((m,e)=>{let t=o+e,Y0=t===V;return R.jsxDEV("box",{gap:0,onMouseUp:()=>P(t),children:[R.jsxDEV("box",{flexDirection:"row",children:[R.jsxDEV("text",{fg:Y0?Z.primary:Z.text,attributes:Y0?To.BOLD:void 0,wrapMode:"none",children:[Y0?"\u25B8 ":" ",m.branch||X("worktrees.row.detached")]},void 0,!0,void 0,this),m.kobeManaged?R.jsxDEV("text",{fg:Z.textMuted,children:[" ",X("worktrees.badge.kobeManaged")]},void 0,!0,void 0,this):null,m.dirty?R.jsxDEV("text",{fg:Z.warning,children:[" ",X("worktrees.badge.dirty")]},void 0,!0,void 0,this):null,T(m.branchOnRemote),x(m),_===m.path?R.jsxDEV("text",{fg:Z.textMuted,children:" \u2026"},void 0,!1,void 0,this):null]},void 0,!0,void 0,this),R.jsxDEV("box",{flexDirection:"row",justifyContent:"space-between",paddingLeft:2,children:[R.jsxDEV("text",{fg:Z.textMuted,wrapMode:"none",children:m.path},void 0,!1,void 0,this),m.createdAtMs>0?R.jsxDEV("text",{fg:Z.textMuted,wrapMode:"none",children:X("worktrees.row.created",{age:rY(m.createdAtMs)})},void 0,!1,void 0,this):null]},void 0,!0,void 0,this)]},m.path,!0,void 0,this)})]},u.repo,!0,void 0,this)})]},void 0,!0,void 0,this)}var tJ,Gq0,Wq0,Hq0;var Eo=a(async()=>{g8();sV();Q$();r0();await e1([$$(),C4(),V5(),FZ()]);tJ=H1(q1(),1);Gq0=/refusing to remove dirty worktree/,Wq0=/LAND_CONFLICT/,Hq0=/MAIN_CHECKOUT_DIRTY/});function wo($){let[Z,J]=vF.useState(!1),[X,z]=vF.useState(!1),[G,W]=vF.useState(!1),[H,U]=vF.useState("terminal"),K=(N)=>{U(N),$.setFocused(bi(N))};return{nav:H,setNav:U,goToNav:K,settingsOpen:Z,openSettings:()=>J(!0),closeSettings:()=>J(!1),worktreesOpen:X,openWorktrees:()=>z(!0),closeWorktrees:()=>z(!1),updateOpen:G,openUpdate:()=>W(!0),closeUpdate:()=>W(!1),kanbanOpen:H==="kanban",openKanban:()=>K("kanban"),closeKanban:()=>K("terminal"),automationsOpen:H==="automations",openAutomations:()=>K("automations"),closeAutomations:()=>K("terminal"),workItemsOpen:H==="issues",openWorkItems:()=>K("issues"),closeWorkItems:()=>K("terminal")}}function xo($){if($.worktreesOpen)return R.jsxDEV(Io,{orchestrator:$.orchestrator,onClose:$.closeWorktrees},void 0,!1,void 0,this);if($.updateOpen)return R.jsxDEV(Do,{onClose:$.closeUpdate},void 0,!1,void 0,this);return null}function fo($){let Z=$.orchestrator;if($.automationsOpen)return R.jsxDEV(ei,{orchestrator:Z,focused:$.contentFocused,...$.selectedTask?{focusRepo:$.selectedTask.repo}:{},onClose:$.closeAutomations,onOpenTask:(J)=>{$.closeAutomations(),$.activateTask(J)}},void 0,!1,void 0,this);if($.workItemsOpen)return R.jsxDEV(Po,{orchestrator:Z,focused:$.contentFocused,onClose:$.closeWorkItems,...$.selectedTask?{focusRepo:$.selectedTask.repo}:{},onOpenTask:(J)=>{$.closeWorkItems(),$.activateTask(J)}},void 0,!1,void 0,this);if($.kanbanOpen)return R.jsxDEV(_o,{orchestrator:Z,focused:$.contentFocused,onClose:$.closeKanban,onStartChat:$.startIssueChat,engineStates:$.engineStates,focusTask:$.selectedTask?{id:$.selectedTask.id,repo:$.selectedTask.repo}:void 0,onOpenTask:(J)=>{$.closeKanban(),$.activateTask(J)}},void 0,!1,void 0,this);return null}var vF;var go=a(async()=>{bI();r0();await e1([$o(),Co(),$E(),Ro(),Eo()]);vF=H1(q1(),1)});function yo($){let Z=$.scheduleTimeout??((U,K)=>{let N=setTimeout(U,K);return()=>clearTimeout(N)}),J=!1,X=null,z=()=>{J=!0,X?.(),X=Z(()=>{J=!1,X=null},700)},G=()=>{J=!1,X?.(),X=null},W=(U)=>{let K=$.getFlatIds();if(K.length===0)return;let N=$.getCursor(),L=N<0?0:N,M=Math.min(K.length-1,Math.max(0,L+U));$.setCursor(M)},H=(U)=>{let K=$.getFlatIds();if(K.length===0)return;$.setCursor(Math.min(K.length-1,Math.max(0,U)))};return{moveDown(){G(),W(1)},moveUp(){G(),W(-1)},selectCurrent(){G();let U=$.getFlatIds(),K=$.getCursor();if(K<0||K>=U.length)return;let N=U[K];if(N!==void 0)$.onSelect(N)},pressG(){if(J)G(),H(0);else z()},pressShiftG(){G(),H($.getFlatIds().length-1)},isChordArmed(){return J},disarmChord(){G()}}}function ko($,Z){if(!Z)return[...$];return[{kind:"recent",id:Z_,task:Z,depth:1},...$]}function yq($,Z){return`${$}${ZE}${Z}`}function lQ($){let Z=$.indexOf(ZE);if(Z<0)return{taskId:$,tabId:null};return{taskId:$.slice(0,Z),tabId:$.slice(Z+ZE.length)}}function vo($){let{tasks:Z,tabsByTask:J}=$,X=new Map;for(let H of Z){let U=oY(H.repo),K=X.get(U)??{repo:H.repo,tasks:[]};if(H.kind==="main")K.repo=H.repo,K.tasks.unshift(H);else K.tasks.push(H);X.set(U,K)}let z=[],G=new Set;for(let H of Z){if(H.kind!=="main")continue;let U=oY(H.repo);if(!G.has(U))G.add(U),z.push(U)}for(let H of X.keys())if(!G.has(H))G.add(H),z.push(H);let W=[];for(let H of z){let U=X.get(H);if(!U)continue;W.push({kind:"project",id:H,repo:U.repo,label:OZ(U.repo),depth:0});for(let K of U.tasks)Uq0(W,K,J)}return W}function Uq0($,Z,J){$.push({kind:"worktree",id:Z.id,task:Z,depth:1});for(let X of J.get(Z.id)??[])$.push({kind:"tab",id:yq(Z.id,X.id),task:Z,tab:X,depth:2})}function JE($){let Z=[];for(let J of $)if(J.kind!=="project")Z.push(J.id);return Z}function bo($){return oY($.repo)}function Bq0($){if($.kind==="project")return $.label;if($.kind==="tab")return $.tab.label;return`${$.task.title} ${$.task.branch??""} ${OZ($.task.repo)}`}function mo($,Z){let J=Z.trim();if(J==="")return[...$];let X=new Set,z=new Set;for(let W of $){if(!lI(J,Bq0(W)))continue;if(X.add(W.id),z.add(W.id),W.kind==="project")continue;if(W.kind==="tab")z.add(W.task.id);let H=bo(W.task);if(H!==null)z.add(H)}let G=[];for(let W of $){if(W.kind==="project"){if(z.has(W.id))G.push(W);continue}let H=bo(W.task),U=H!==null&&X.has(H);if(W.kind==="worktree"){if(U||z.has(W.id))G.push(W);continue}if(U||X.has(W.task.id)||z.has(W.id))G.push(W)}return G}function ho($,Z){for(let J of $){if(J.kind!=="main")continue;if(oY(J.repo)===Z)return String(J.id)}return null}function uo($){if($.tabActivity!==void 0)return $.tabActivity;if(!$.active||$.reportedTabCount>0)return;return $.taskActivity}var ZE="::",Z_="~recent";var mF=a(()=>{L3()});function lo($){let Z=$.maxWidth??Kq0,J=Math.max(1,...$.lines.map((W)=>em(W.text))),X=Math.min(Z-4,J),z=X+4,G=$.lines.length+2;return{innerWidth:X,boxWidth:z,boxHeight:G,left:Math.max(0,Math.min($.hoverX+2,$.screenWidth-z-1)),top:Math.max(0,Math.min($.hoverY+1,$.screenHeight-G-1))}}var co=2750,Kq0=72;var po=a(()=>{L3()});function no($,Z){return qZ($,Z)}var XE=()=>{};import{TextAttributes as Fq0}from"@opentui/core";function io($){let{theme:Z}=l0();if($.entries.length===0)return null;let J=lo({hoverX:$.x,hoverY:$.y,screenWidth:$.dims.width,screenHeight:$.dims.height,lines:$.entries.map((X)=>({text:X.label}))});return R.jsxDEV("box",{position:"absolute",zIndex:Mq0,left:J.left,top:J.top,width:J.boxWidth,flexDirection:"column",border:!0,borderColor:Z.focusAccent,backgroundColor:Z.backgroundElement,paddingLeft:1,paddingRight:1,children:$.entries.map((X,z)=>{let G=z===$.cursor;return R.jsxDEV("box",{flexShrink:0,backgroundColor:G?Z.focusAccent:void 0,onMouseUp:()=>$.onPick(X.id),children:R.jsxDEV("text",{fg:G?Z.backgroundElement:X.danger?Z.error:Z.text,attributes:G?Fq0.BOLD:void 0,wrapMode:"none",flexGrow:1,children:no(X.label,J.innerWidth)},void 0,!1,void 0,this)},X.id,!1,void 0,this)})},void 0,!1,void 0,this)}var Mq0;var oo=a(async()=>{po();XE();r0();await $$();Mq0=co+10});import{MouseButton as Nq0,TextAttributes as Q6}from"@opentui/core";function ao($){let{theme:Z,transparentBackground:J}=l0(),X=J?Z.border:Z.borderSubtle;return R.jsxDEV("box",{flexDirection:"column",flexShrink:0,children:[$.topPad?R.jsxDEV("box",{flexShrink:0,children:R.jsxDEV("text",{wrapMode:"none",children:" "},void 0,!1,void 0,this)},void 0,!1,void 0,this):null,R.jsxDEV("box",{flexDirection:"row",flexShrink:0,gap:1,paddingLeft:1,paddingRight:1,onMouseUp:$.onPress||$.onContextMenu?(z)=>{if(z.button===Nq0.RIGHT&&$.onContextMenu){$.onContextMenu(z.x,z.y);return}$.onPress?.()}:void 0,children:[$.prefix?R.jsxDEV("text",{fg:Z.textMuted,wrapMode:"none",flexShrink:0,children:$.prefix},void 0,!1,void 0,this):null,R.jsxDEV("text",{fg:Z.textMuted,attributes:Q6.BOLD,wrapMode:"none",flexShrink:0,children:$.label},void 0,!1,void 0,this),R.jsxDEV("text",{fg:X,wrapMode:"none",flexBasis:0,flexGrow:1,flexShrink:1,children:"\u2500".repeat(240)},void 0,!1,void 0,this),$.suffix?R.jsxDEV("text",{fg:Z.info,attributes:Q6.BOLD,wrapMode:"none",flexShrink:0,children:$.suffix},void 0,!1,void 0,this):null]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function ro($){let{theme:Z}=l0(),J=Z1();return R.jsxDEV("box",{flexDirection:"row",gap:0,flexShrink:0,paddingBottom:1,paddingLeft:1,children:[R.jsxDEV("text",{fg:Z.info,wrapMode:"none",children:"/"},void 0,!1,void 0,this),R.jsxDEV("text",{fg:Z.text,wrapMode:"none",children:$.query},void 0,!1,void 0,this),R.jsxDEV("text",{fg:Z.info,attributes:Q6.BLINK,wrapMode:"none",children:"\u2588"},void 0,!1,void 0,this),$.query.length===0?R.jsxDEV("text",{fg:Z.textMuted,wrapMode:"none",children:[" ",J("tasks.search.placeholder")]},void 0,!0,void 0,this):R.jsxDEV("text",{fg:Z.textMuted,wrapMode:"none",children:[" ",$.matchCount,"/",$.totalCount]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function so($){let{theme:Z}=l0();return R.jsxDEV("box",{flexDirection:"row",justifyContent:"space-between",gap:1,flexShrink:0,paddingLeft:1,paddingRight:1,children:R.jsxDEV("box",{flexDirection:"row",gap:1,children:[R.jsxDEV("text",{fg:$.focused?Z.focusAccent:Z.textMuted,attributes:Q6.BOLD,wrapMode:"none",children:"ROVE"},void 0,!1,void 0,this),$.status?R.jsxDEV("text",{fg:$.status.emphasize?Z.warning:Z.textMuted,attributes:$.status.emphasize?Q6.BOLD:Q6.DIM,wrapMode:"none",onMouseUp:()=>$.onStatusClick?.(),children:$.status.label},void 0,!1,void 0,this):null]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function to($){let{theme:Z,transparentBackground:J}=l0(),X=Z1(),z=X9("task.new");if(!$.onAddTask)return null;return R.jsxDEV("box",{flexShrink:0,paddingTop:1,paddingBottom:1,paddingLeft:1,paddingRight:1,children:R.jsxDEV("box",{flexDirection:"row",flexShrink:0,gap:1,paddingLeft:1,paddingRight:1,backgroundColor:J?void 0:Z.backgroundElement,onMouseUp:()=>$.onAddTask?.(),children:[R.jsxDEV("text",{fg:Z.primary,attributes:Q6.BOLD,wrapMode:"none",flexShrink:0,children:"+"},void 0,!1,void 0,this),R.jsxDEV("text",{fg:Z.text,attributes:Q6.BOLD,wrapMode:"none",flexGrow:1,children:X("tasks.menu.newTask")},void 0,!1,void 0,this),z?R.jsxDEV("text",{fg:Z.textMuted,attributes:Q6.DIM,wrapMode:"none",flexShrink:0,children:z},void 0,!1,void 0,this):null]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function eo($){let{theme:Z}=l0(),J=Z1();return R.jsxDEV("box",{flexDirection:"column",flexShrink:0,paddingBottom:1,children:yi.map((X)=>{let z=$.nav===X.nav;return R.jsxDEV("box",{flexDirection:"row",flexShrink:0,paddingLeft:1,paddingRight:1,backgroundColor:z?Z.focusAccent:void 0,onMouseUp:(G)=>{G.stopPropagation(),$.setNav(X.nav)},children:R.jsxDEV("text",{fg:z?Z.backgroundElement:Z.textMuted,attributes:z?Q6.BOLD:void 0,wrapMode:"none",flexGrow:1,children:J(X.labelKey)},void 0,!1,void 0,this)},X.nav,!1,void 0,this)})},void 0,!1,void 0,this)}function $a($){let{theme:Z}=l0(),J=Z1();return R.jsxDEV("box",{flexDirection:"row",gap:1,flexShrink:0,paddingBottom:1,paddingLeft:1,paddingRight:1,children:lH.map((X)=>{let z=$.view===X.view;return R.jsxDEV("box",{flexShrink:0,paddingLeft:1,paddingRight:1,backgroundColor:z?Z.focusAccent:void 0,onMouseUp:()=>$.setView(X.view),children:R.jsxDEV("text",{fg:z?Z.backgroundElement:Z.textMuted,attributes:z?Q6.BOLD:void 0,wrapMode:"none",children:J(Jh(X.view))},void 0,!1,void 0,this)},X.view,!1,void 0,this)})},void 0,!1,void 0,this)}function Za($){let{theme:Z}=l0();return R.jsxDEV("box",{flexShrink:0,paddingLeft:1,paddingRight:1,paddingTop:1,children:R.jsxDEV("text",{fg:Z.accent,attributes:Q6.BOLD,wrapMode:"none",onMouseUp:(J)=>{J.stopPropagation(),$.onZenClick?.()},children:"\u262F ZEN"},void 0,!1,void 0,this)},void 0,!1,void 0,this)}var QE=a(async()=>{mj();bI();gJ();Q$();r0();await $$()});function J_($){let Z=new Map,J=$.equals??((z,G)=>z===G);function X(z){let G=Z.get(z);if(!G){let W=$.initial;G={read:()=>W,write:(H)=>{if(!J(W,H))W=H},inFlight:!1,nextAllowedAt:0},Z.set(z,G)}return G}return{read(z){if(!z)return $.initial;return X(z).read()},poll(z){if(!z)return;let G=X(z);vy(G,$,(W)=>$.run(z,W),(W)=>G.write(W))},reset(){Z.clear()}}}var hF=a(()=>{CH();CH()});import{stat as Oq0}from"fs/promises";import{join as Lq0}from"path";async function Cq0($){try{let Z=await Oq0(Lq0($,".git","HEAD"));return`${Z.mtimeMs}:${Z.size}`}catch{return null}}async function Dq0($,Z,J=t6){let X=await Cq0($);if(X!==null){let U=Ja.get($);if(U&&U.fingerprint===X)return U.value}let z="",G=!1,W=await J("git",["symbolic-ref","--short","HEAD"],{cwd:$,env:a2(),signal:Z}),H=W.status===0?W.stdout.trim():"";if(H&&H!=="HEAD")z=H,G=!0;else if((await J("git",["rev-parse","--verify","HEAD"],{cwd:$,env:a2(),signal:Z})).status===0)z="(detached)",G=!0;if(G&&X!==null)Ja.set($,{fingerprint:X,value:z});return z}function zE($){return Xa.read($)}function YE($){Xa.poll($)}var jq0=2000,Vq0=30000,_q0=1500,Ja,Xa;var GE=a(()=>{wJ();hF();Ja=new Map;Xa=J_({initial:"",timeoutMs:jq0,slowRetryMs:Vq0,minIntervalMs:_q0,run:($,Z)=>Dq0($,Z)})});function Aq0($){switch($){case"rate_limited":return{text:S$("tasks.activity.rateLimited"),tone:"warning"};case"permission_needed":return{text:S$("tasks.activity.permissionNeeded"),tone:"warning"};case"error":return{text:S$("tasks.activity.error"),tone:"error"};default:return null}}function WE($){switch($.prStatus?.checkState){case"passing":return{glyph:"\u2713",tone:"success"};case"failing":return{glyph:"\u2717",tone:"error"};case"pending":return{glyph:"\u2022",tone:"warning"};default:return null}}function Rq0(){return S$("tasks.subtitle.noTracking")}function Tq0(){return S$("tasks.subtitle.materializing")}function Sq0($){return $?S$("tasks.subtitle.deleteFailed"):S$("tasks.subtitle.deleting")}function Ya($){if($.kind==="main")return!1;return $.vendor!==void 0&&!h7($.vendor)}function Ga($,Z){if($?.state!=="turn_complete"||!Z)return!1;if(!$.at||!Z.mtimeMs)return!1;return Z.mtimeMs>$.at+Iq0}function Eq0($){let{task:Z}=$,J=$.activity?.state,X=J!==void 0,z=Ya(Z)&&!X,G=$.job!==void 0,W=Z.deletion?.phase==="queued"||Z.deletion?.phase==="running",H=J==="running"||Ga($.activity,$.transcript);return W||G||!z&&H}function HE($){let{task:Z}=$,J=Z.kind==="main",X=J?$.mainBranch??"":Z.branch,z=$.activity?.state,G=z!==void 0,H=Ga($.activity,$.transcript)?null:wq0(z,$.completionSeen===!0),U=Aq0(z),K=Ya(Z)&&!G,N=$.job!==void 0,L=Z.deletion?.phase==="queued"||Z.deletion?.phase==="running",M=Z.deletion?.phase==="error",V=Eq0({task:Z,activity:$.activity,job:$.job,transcript:$.transcript}),P=D$(Z.vendor??M4).spinnerFrames??hL,_=P[$.spinnerFrame%P.length]??P[0],C=M?"error":L||N?"primary":K?"textMuted":U?.tone??(V?"primary":H?.tone??"textMuted"),f=K?Rq0():"\u2014",E=V?$.lifecycle?.subagents??0:0,S=E>0&&X.length>0?`\u25C7${E} ${X}`:X,T=L||M?$.truncateBranch(Sq0(M),$.subtitleBudget):N?$.truncateBranch(Tq0(),$.subtitleBudget):U?$.truncateBranch(U.text,$.subtitleBudget):S.length>0?$.truncateBranch(S,$.subtitleBudget):$.truncateBranch(f,$.subtitleBudget),x=M?"\u2715":K?Pq0:H?.glyph??"\u25CB";return{isMain:J,titleText:J?OZ(Z.repo):Z.title,subtitleText:T,loading:V,stateGlyph:V?_:x,tone:C,spinnerFrames:P,materializing:N}}function qE($,Z){if(!$.loading)return $;let J=$.spinnerFrames,X=J[Z()%J.length]??J[0]??"\u280B";if(X===$.stateGlyph)return $;return{...$,stateGlyph:X}}function wq0($,Z){switch($){case"rate_limited":return{glyph:"\u25F7",tone:"warning"};case"permission_needed":return{glyph:"?",tone:"warning"};case"error":return{glyph:"\u2715",tone:"error"};case"turn_complete":return Z?null:{glyph:"\u25CF",tone:"primary"};default:return null}}var Qa=100,za=600,Pq0="\xB7",Iq0=2000;var X_=a(()=>{C7();uL();gY();d7();u7();L3()});function xq0(){z_=(z_+1)%za;for(let $ of Q_)try{$()}catch{}}function Y_(){return z_}function G_($){if(Q_.add($),bq===null)bq=setInterval(xq0,Qa),bq.unref?.();return()=>{if(Q_.delete($),Q_.size===0&&bq!==null)clearInterval(bq),bq=null,z_=0}}var Q_,z_=0,bq=null;var UE=a(()=>{X_();Q_=new Set});function Ha($){return Wa.read($)}function qa($){Wa.poll($)}var fq0=4000,gq0=60000,yq0=1500,bq0,Wa;var Ua=a(()=>{wJ();hF();cH();hF();bq0={added:0,deleted:0},Wa=J_({initial:bq0,equals:aK,timeoutMs:fq0,slowRetryMs:gq0,minIntervalMs:yq0,run:async($,Z)=>{let J=await t6("git",["status","--porcelain=v1"],{cwd:$,env:a2(),signal:Z});if(J.status!==0)throw Error("git status failed");return uH(J.stdout)}})});function BE($,Z){return Z===void 0?$:`${$}\x00${Z}`}function kq0($){if(typeof $!=="object"||$===null||Array.isArray($))return{};let Z={};for(let[J,X]of Object.entries($))if(typeof X==="number"&&Number.isFinite(X))Z[J]=X;return Z}function vq0($,Z,J,X=200){let z=$[Z];if(z!==void 0&&z>=J)return $;let G={...$,[Z]:J},W=Object.keys(G);if(W.length<=X)return G;let H={};for(let U of W.sort((K,N)=>G[N]-G[K]).slice(0,X))H[U]=G[U];return H}function Ba($,Z,J){if(!$||J===void 0)return!1;let X=$.get("completionSeen");if(typeof X!=="object"||X===null||Array.isArray(X))return!1;let z=X[Z];return typeof z==="number"&&z>=J}function Ka($,Z,J){let X=kq0($.get("completionSeen")),z=vq0(X,Z,J);if(z!==X)$.set("completionSeen",z)}import{TextAttributes as mq0}from"@opentui/core";function Fa($){return kq.useSyncExternalStore($?G_:hq0,$?Y_:uq0)}function Ma($,Z){let J=XT($.worktreeChanges,Z.worktreePath),X=J!==null;return kq.useEffect(()=>{if($.branchTick,X||Z.archived)return;qa(Z.worktreePath)},[X,Z.archived,Z.worktreePath,$.branchTick]),J??Ha(Z.worktreePath)}function Na($){let{theme:Z}=l0();if($.changes.added<=0&&$.changes.deleted<=0)return null;return R.jsxDEV("box",{flexDirection:"row",gap:1,flexShrink:0,children:[$.changes.added>0?R.jsxDEV("text",{fg:Z.success,wrapMode:"none",flexShrink:0,children:["+",$.changes.added]},void 0,!0,void 0,this):null,$.changes.deleted>0?R.jsxDEV("text",{fg:Z.error,wrapMode:"none",flexShrink:0,children:["\u2212",$.changes.deleted]},void 0,!0,void 0,this):null]},void 0,!0,void 0,this)}function Oa($,Z,J,X,z=!1){let G=BE($,X);if(Z==="turn_complete"){if(J)KE.add(G)}else KE.delete(G);return KE.has(G)||z}function La($){return $?.state==="turn_complete"?$.at:void 0}function ja($,Z,J,X){let z=bQ(),G=BE($,Z),W=Ba(z,G,J);return kq.useEffect(()=>{if(!z||!X||J===void 0||W)return;Ka(z,G,J)},[z,G,J,X,W]),W}function FE($){let{theme:Z}=l0(),J=$u($.flatIndex);if(J===null)return null;return R.jsxDEV("text",{fg:$.dim?Z.textMuted:Z.accent,attributes:mq0.DIM,wrapMode:"none",flexShrink:0,children:J},void 0,!1,void 0,this)}var kq,hq0=()=>()=>{},uq0=()=>0,KE;var Va=a(async()=>{fS();UE();GE();fT();XE();X_();gJ();cH();Ua();M3();Q$();r0();await $$();kq=H1(q1(),1);KE=new Set});import{MouseButton as cq0}from"@opentui/core";function ME($){let{theme:Z}=l0(),J=$.shared,X=iJ(Z,{cursor:J.cursorIndex===$.flatIndex,selected:J.activeRowId===$.rowId});return R.jsxDEV("box",{ref:(z)=>{if(!z)return;return J.rowEls.set($.flatIndex,z),()=>{if(J.rowEls.get($.flatIndex)===z)J.rowEls.delete($.flatIndex)}},width:"100%",flexDirection:"row",gap:0,backgroundColor:X.backgroundColor,onMouseUp:(z)=>{if(z.stopPropagation(),z.button===cq0.RIGHT&&J.onContextMenu){J.onContextMenu($.flatIndex,$.rowId,z.x,z.y);return}J.onPress($.flatIndex,$.rowId)},children:[R.jsxDEV("text",{fg:X.markerColor,wrapMode:"none",children:X.marker},void 0,!1,void 0,this),R.jsxDEV("text",{wrapMode:"none",flexShrink:0,children:" ".repeat($.depth*dq0)},void 0,!1,void 0,this),$.children]},void 0,!0,void 0,this)}function Ca($){let{theme:Z}=l0(),J=$.shared,X=$.task,z=J.cursorIndex===$.flatIndex,G=Ma(J,X),W=WE(X),H=X.kind==="main";_a.useEffect(()=>{if(J.branchTick,H)YE(X.repo)},[H,X.repo,J.branchTick]);let U=(H?zE(X.repo):X.branch)||X.branch||X.title;return R.jsxDEV(ME,{rowId:$.rowId,flatIndex:$.flatIndex,depth:1,shared:J,children:R.jsxDEV("box",{flexDirection:"row",flexGrow:1,paddingRight:1,gap:1,children:[R.jsxDEV("text",{fg:Z.text,wrapMode:"none",flexBasis:0,flexGrow:1,flexShrink:1,children:U},void 0,!1,void 0,this),X.pinned===!0?R.jsxDEV("text",{fg:Z.warning,wrapMode:"none",flexShrink:0,children:"\u25B4"},void 0,!1,void 0,this):null,W?R.jsxDEV("text",{fg:qj(Z,W.tone),wrapMode:"none",flexShrink:0,children:W.glyph},void 0,!1,void 0,this):null,R.jsxDEV(Na,{changes:G},void 0,!1,void 0,this),R.jsxDEV(FE,{flatIndex:$.flatIndex,dim:!z},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function Da($){let{theme:Z}=l0(),J=$.shared,X=J.cursorIndex===$.flatIndex,z=$.tab.engine===!0,G=z?J.engineTabState?.get($.task.id):void 0,W=z?uo({tabActivity:G?.get($.tab.id),reportedTabCount:G?.size??0,taskActivity:J.engineState?.get($.task.id),active:$.tab.active===!0}):void 0,H=W!==void 0,U=J.selectedTaskId===$.task.id&&$.tab.active===!0,K=ja($.task.id,$.tab.id,H?La(W):void 0,U),N=H?Oa($.task.id,W?.state,U,$.tab.id,K):!1,L=HE({task:$.task,activity:W,lifecycle:H?J.engineLifecycle?.get($.task.id):void 0,job:H?J.taskJobs?.get($.task.id):void 0,spinnerFrame:0,subtitleBudget:0,truncateBranch:BT,completionSeen:N}),M=Fa(H&&L.loading),V=qE(L,()=>M),P="\u25CC",_=z?H?V.stateGlyph:"\u25CC":"\xB7";return R.jsxDEV(ME,{rowId:$.rowId,flatIndex:$.flatIndex,depth:2,shared:$.shared,children:[R.jsxDEV("text",{fg:H?qj(Z,V.tone):Z.textMuted,wrapMode:"none",width:2,flexShrink:0,children:`${_} `},void 0,!1,void 0,this),R.jsxDEV("box",{flexDirection:"row",flexGrow:1,paddingRight:1,gap:1,children:[R.jsxDEV("text",{fg:Z.textMuted,wrapMode:"none",flexBasis:0,flexGrow:1,flexShrink:1,children:$.tab.label},void 0,!1,void 0,this),R.jsxDEV(FE,{flatIndex:$.flatIndex,dim:!X},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Aa($){let{theme:Z}=l0(),J=Z1();return R.jsxDEV(ME,{rowId:$.rowId,flatIndex:$.flatIndex,depth:1,shared:$.shared,children:[R.jsxDEV("text",{fg:Z.accent,wrapMode:"none",width:2,flexShrink:0,children:"\u21A9 "},void 0,!1,void 0,this),R.jsxDEV("text",{fg:Z.text,wrapMode:"none",flexShrink:1,children:J("tasks.recentJump",{title:$.task.title})},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var _a,dq0=1;var Pa=a(async()=>{GE();X_();mF();gJ();Q$();r0();await e1([$$(),Va()]);_a=H1(q1(),1)});function Ra($){let{theme:Z}=l0(),J=Z1();return R.jsxDEV("scrollbox",{ref:$.setScrollRef,flexGrow:1,minHeight:0,stickyScroll:!1,verticalScrollbarOptions:{visible:!1},children:R.jsxDEV("box",{flexShrink:0,gap:0,children:[$.rows.map((X,z)=>{if(X.kind==="project")return R.jsxDEV(ao,{label:X.label,suffix:$.movingProjectId===X.id?J("tasks.moveChip"):void 0,topPad:z>0,onContextMenu:$.onProjectContextMenu?(G,W)=>$.onProjectContextMenu?.(X.id,G,W):void 0},X.id,!1,void 0,this);if(X.kind==="recent")return R.jsxDEV(Aa,{rowId:X.id,flatIndex:$.flatIndexOf.get(X.id)??-1,task:X.task,shared:$.shared},X.id,!1,void 0,this);if(X.kind==="worktree")return R.jsxDEV(Ca,{rowId:X.id,flatIndex:$.flatIndexOf.get(X.id)??-1,task:X.task,shared:$.shared},X.id,!1,void 0,this);return R.jsxDEV(Da,{rowId:X.id,flatIndex:$.flatIndexOf.get(X.id)??-1,task:X.task,tab:X.tab,shared:$.shared},X.id,!1,void 0,this)}),$.rows.length===0?R.jsxDEV("box",{paddingTop:1,paddingLeft:1,children:R.jsxDEV("text",{fg:Z.textMuted,children:J(Qh({searching:$.searching,projectFilter:!1,view:$.view}))},void 0,!1,void 0,this)},void 0,!1,void 0,this):null]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}var Ta=a(async()=>{gJ();Q$();r0();await e1([$$(),QE(),Pa()])});function Sa($){return[{action:"rename",labelKey:"tasks.menu.rename"},{action:"pin",labelKey:$?"tasks.menu.unpin":"tasks.menu.pin"},{action:"localMerge",labelKey:"tasks.menu.localMerge"},{action:"archive",labelKey:"tasks.menu.archive"},{action:"delete",labelKey:"tasks.menu.delete",danger:!0}]}function Ia($,Z={}){if($.kind==="project")return[{action:"newTask",labelKey:"tasks.menu.newTask"}];if($.kind==="worktree")return[{action:"open",labelKey:"tasks.menu.open"},...Sa($.task.pinned===!0)];let J=[{action:"open",labelKey:"tasks.menu.openTab"}];if((Z.tabCount??0)>1)J.push({action:"closeTab",labelKey:"tasks.menu.closeTab"});return[...J,...Sa($.task.pinned===!0)]}function Ea($){let Z=Z1(),{tree:J,activateRow:X,setCursorIndex:z,actions:G}=$,[W,H]=z6.useState(null),[U,K]=z6.useState(0),N=z6.useCallback((E,S,T,x)=>{let b=Ia(E,S);H({row:E,actions:b.map((v)=>v.action),entries:b.map((v)=>({id:v.action,label:Z(v.labelKey),danger:v.danger})),x:T,y:x}),K(0)},[Z]),L=z6.useCallback((E,S,T,x)=>{let b=J.rows.find((v)=>v.id===S);if(!b||b.kind==="project"||b.kind==="recent")return;z(E),N(b,{tabCount:J.tabCount(b.task.id)},T,x)},[J.rows,J.tabCount,N,z]),M=z6.useCallback((E,S,T)=>{let x=J.rows.find((b)=>b.kind==="project"&&b.id===E);if(!x)return;N(x,{},S,T)},[J.rows,N]),V=z6.useCallback(()=>H(null),[]),P=z6.useCallback((E)=>{let S=W?.entries.length??0;if(S===0)return;K((T)=>(T+E+S)%S)},[W]),_=z6.useCallback((E)=>{if(!W||E===void 0)return;let S=W.row;if(H(null),S.kind==="project"){if(E==="newTask")$.onAddTask?.();return}let T=S.task.id;switch(E){case"open":X(S.id);break;case"closeTab":if(S.kind==="tab")$.onCloseTab?.(T,S.tab.id);break;case"rename":G.onRenameRequest?.(T);break;case"pin":G.onPinRequest?.(T);break;case"localMerge":G.onLocalMergeRequest?.(T);break;case"archive":G.onArchiveRequest?.(T);break;case"delete":G.onDeleteRequest?.(T);break;default:break}},[W,X,G,$.onAddTask,$.onCloseTab]),C=z6.useCallback(()=>_(W?.actions[U]),[_,W,U]),f=z6.useCallback((E)=>_(W?.actions.find((S)=>S===E)),[_,W]);return{open:W!==null,entries:W?.entries??[],cursor:U,x:W?.x??0,y:W?.y??0,close:V,moveCursor:P,pickCurrent:C,pick:f,openForRow:L,openForProject:M}}var z6;var wa=a(()=>{Q$();z6=H1(q1(),1)});function xa($){let[Z,J]=pQ.useState(!1),[X,z]=pQ.useState(""),G=w1($.focused),W=$.onActiveChange,H=pQ.useCallback(()=>{z(""),J(!0),W?.(!0)},[W]),U=pQ.useCallback(()=>{J(!1),z(""),W?.(!1)},[W]),K=E4();return pQ.useEffect(()=>{if(!Z||!K)return;let N=(L)=>{if(!G.current||bY())return;z((M)=>zh(M,L)??M)};return K.keyInput.on("keypress",N),()=>{K.keyInput.off("keypress",N)}},[Z,K]),{active:Z,query:X,enter:H,exit:U}}var pQ;var fa=a(async()=>{gJ();W2();await e1([u4(),C4()]);pQ=H1(q1(),1)});function ga($){return $.split("::").slice(0,2).join("::")}function W_($,Z=Date.now()){NE.set(ga($),Z)}function ya($,Z=Date.now()){let J=ga($),X=NE.get(J);if(X===void 0)return!1;if(Z-X>15000)return NE.delete(J),!1;return!0}var NE;var H_=a(()=>{NE=new Map});import{basename as ba}from"path";function pq0($){return ba($).replace(/\.(exe|js|mjs|cjs)$/,"")}function nq0($){for(let Z of $.trim().split(/\s+/).slice(0,4)){if(/^[A-Za-z_][A-Za-z0-9_]*=/.test(Z))continue;let J=pq0(Z);if(lq0.has(J))continue;return WQ.find((X)=>D$(X).defaultCommand[0]===J)??null}return null}function LZ($){let Z=[];for(let J of $.split(`
730
+ `).map((Z)=>Z.trim()).filter(Boolean)}function Do($){let{theme:Z}=l0(),J=Z1(),X=E4(),[z,G]=dQ.useState(null),[W,H]=dQ.useState([]),[U,K]=dQ.useState(!0),[N,L]=dQ.useState("update"),[M,V]=dQ.useState(null),P=z?.latest??A$,_=W[0]?.url??fR(P),C=[{id:"update",key:"U",label:J("update.actions.updateNow"),detail:WZ},{id:"release",key:"R",label:J("update.actions.openRelease"),detail:_??J("update.releaseUrlUnavailable")},{id:"close",key:"Q",label:J("update.actions.close"),detail:J("update.actions.closeDetail")}];dQ.useEffect(()=>{f()},[]);async function f(){let x=await jY({force:!0});G(x);let b=x?.latest??A$,v=await xR({current:A$,latest:b});H(v),K(!1)}function E(x){let b=C.map((o)=>o.id),u=(b.indexOf(N)+x+b.length)%b.length;L(b[u]??"update")}function S(x=N){if(x==="close"){$.onClose();return}if(x==="release"){V(Qq0(_)?J("update.statusReleaseOpened"):J("update.statusReleaseError"));return}T()}async function T(){V(J("update.statusRunningUpdater")),await new Promise((x)=>setTimeout(x,30)),await $_({renderer:X,t:J,targetLabel:P,command:WZ})}return g1(()=>({bindings:[{key:"up",cmd:()=>E(-1)},{key:"down",cmd:()=>E(1)},{key:"k",cmd:()=>E(-1)},{key:"j",cmd:()=>E(1)},{key:"return",cmd:()=>S()},{key:"u",cmd:()=>S("update")},{key:"r",cmd:()=>S("release")},...a7(()=>S("close"))]})),R.jsxDEV("box",{flexDirection:"column",flexGrow:1,backgroundColor:Z.background,paddingTop:1,paddingLeft:2,paddingRight:2,children:[R.jsxDEV("box",{flexDirection:"row",justifyContent:"space-between",flexShrink:0,children:[R.jsxDEV("text",{fg:Z.text,attributes:gq.BOLD,wrapMode:"none",children:J("update.pageTitle")},void 0,!1,void 0,this),R.jsxDEV("text",{fg:Z.textMuted,wrapMode:"none",onMouseUp:()=>S("close"),children:"q / esc"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),R.jsxDEV("box",{flexDirection:"row",gap:2,flexShrink:0,paddingTop:1,children:[R.jsxDEV("text",{fg:Z.textMuted,wrapMode:"none",children:J("update.current")},void 0,!1,void 0,this),R.jsxDEV("text",{fg:Z.text,attributes:gq.BOLD,wrapMode:"none",children:["v",A$]},void 0,!0,void 0,this),R.jsxDEV("text",{fg:Z.textMuted,wrapMode:"none",children:J("update.latest")},void 0,!1,void 0,this),R.jsxDEV("text",{fg:z?.hasUpdate?Z.warning:Z.success,attributes:gq.BOLD,wrapMode:"none",children:["v",P]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),R.jsxDEV("box",{flexDirection:"column",flexShrink:0,paddingTop:1,gap:0,children:C.map((x)=>R.jsxDEV("box",{flexDirection:"row",gap:1,paddingLeft:1,paddingRight:1,backgroundColor:N===x.id?Z.primary:void 0,onMouseUp:()=>S(x.id),children:[R.jsxDEV("box",{width:4,flexShrink:0,children:R.jsxDEV("text",{fg:N===x.id?Z.selectedListItemText:Z.accent,attributes:gq.BOLD,wrapMode:"none",children:["[",x.key,"]"]},void 0,!0,void 0,this)},void 0,!1,void 0,this),R.jsxDEV("box",{width:14,flexShrink:0,children:R.jsxDEV("text",{fg:N===x.id?Z.selectedListItemText:Z.text,wrapMode:"none",children:x.label},void 0,!1,void 0,this)},void 0,!1,void 0,this),R.jsxDEV("text",{fg:N===x.id?Z.selectedListItemText:Z.textMuted,wrapMode:"word",children:x.detail},void 0,!1,void 0,this)]},x.id,!0,void 0,this))},void 0,!1,void 0,this),M?R.jsxDEV("text",{fg:Z.info,wrapMode:"word",children:M},void 0,!1,void 0,this):null,R.jsxDEV("box",{flexShrink:0,paddingTop:1,children:R.jsxDEV("text",{fg:Z.textMuted,attributes:gq.DIM,wrapMode:"none",children:J("update.changesSectionHeader",{from:A$,to:P})},void 0,!1,void 0,this)},void 0,!1,void 0,this),R.jsxDEV("scrollbox",{flexGrow:1,flexShrink:1,stickyScroll:!1,verticalScrollbarOptions:{trackOptions:{backgroundColor:Z.background,foregroundColor:Z.borderActive}},children:R.jsxDEV("box",{flexDirection:"column",paddingRight:1,paddingBottom:1,gap:0,children:[U?R.jsxDEV("text",{fg:Z.textMuted,children:J("update.loadingNotes")},void 0,!1,void 0,this):null,!U&&W.length===0?R.jsxDEV("text",{fg:Z.textMuted,wrapMode:"word",children:J("update.notesUnavailable")},void 0,!1,void 0,this):null,W.map((x)=>R.jsxDEV("box",{flexDirection:"column",paddingBottom:1,gap:0,children:[R.jsxDEV("text",{fg:Z.text,attributes:gq.BOLD,wrapMode:"none",children:["v",x.version]},void 0,!0,void 0,this),eI(x.body).map((b,v)=>R.jsxDEV("text",{fg:Z.textMuted,wrapMode:"word",children:b},`${v}:${b}`,!1,void 0,this))]},x.version,!0,void 0,this))]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var dQ;var $E=a(async()=>{w8();Q$();tI();r0();await e1([u4(),$$(),C4()]);dQ=H1(q1(),1)});import{TextAttributes as Ao}from"@opentui/core";function zq0($){if(!$)return[];let Z=[];for(let J of $.listTasks())if(J.repo&&!Z.includes(J.repo))Z.push(J.repo);return Z}function Yq0($,Z){let J=Date.parse($);if(!Number.isFinite(J))return"";let X=Math.round((Z-J)/60000);if(X<60)return`${Math.max(X,0)}m`;let z=Math.round(X/60);if(z<24)return`${z}h`;return`${Math.round(z/24)}d`}function Po($){let{theme:Z}=l0(),J=Z1(),X=zq0($.orchestrator),[z,G]=X6.useState(()=>{let u=$.focusRepo?X.indexOf($.focusRepo):-1;return u>=0?u:0}),W=X[z],[H,U]=X6.useState(null),[K,N]=X6.useState(null),[L,M]=X6.useState(0),[V,P]=X6.useState(!1),[_,C]=X6.useState(!1),[f,E]=X6.useState(null);X6.useEffect(()=>{let u=!1,o=$.orchestrator;if(!o||!W){U([]);return}return N(null),o.listWorkItems({repo:W,limit:30,...V?{assignee:"@me"}:{},...L>0?{refresh:!0}:{}}).then((m)=>{if(!u)U(m.items)}).catch((m)=>{if(u)return;N(m instanceof Error?m.message:String(m)),U([])}),()=>{u=!0}},[$.orchestrator,W,V,L]);let S=H??[],[T,x]=X6.useState(0);X6.useEffect(()=>{x((u)=>w4(u,S.length))},[S.length]);async function b(){let u=$.orchestrator,o=S[T];if(!u||!o||!W||_)return;C(!0),E(J("workItems.starting",{number:o.number}));try{let m=await u.startWorkItem({repo:W,number:o.number});if(m.started)$.onOpenTask?.(m.taskId);else E(J("workItems.startedNoEngine",{title:m.title}))}catch(m){E(m instanceof Error?m.message:String(m))}finally{C(!1)}}g1(()=>({enabled:$.focused!==!1,bindings:[...a7($.onClose),{key:"j",cmd:()=>x((u)=>w4(u+1,S.length))},{key:"down",cmd:()=>x((u)=>w4(u+1,S.length))},{key:"k",cmd:()=>x((u)=>w4(u-1,S.length))},{key:"up",cmd:()=>x((u)=>w4(u-1,S.length))},{key:"tab",cmd:()=>G((u)=>X.length?(u+1)%X.length:0)},{key:"a",cmd:()=>P((u)=>!u)},{key:"r",cmd:()=>M((u)=>u+1)},{key:"return",cmd:()=>void b()}]}));let v=Date.now();return R.jsxDEV("box",{flexDirection:"column",flexGrow:1,padding:1,children:[R.jsxDEV("box",{flexDirection:"row",justifyContent:"space-between",children:[R.jsxDEV("text",{attributes:Ao.BOLD,fg:Z.accent,children:J("workItems.title")},void 0,!1,void 0,this),R.jsxDEV("text",{fg:Z.textMuted,children:[W?U9(W,X):J("workItems.noRepo"),V?` ${J("workItems.assignedFilter")}`:""]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),K?R.jsxDEV("box",{flexDirection:"column",marginTop:1,children:R.jsxDEV("text",{fg:Z.error,children:K},void 0,!1,void 0,this)},void 0,!1,void 0,this):H===null?R.jsxDEV("text",{fg:Z.textMuted,children:J("common.loading")},void 0,!1,void 0,this):S.length===0?R.jsxDEV("text",{fg:Z.textMuted,children:J("workItems.empty")},void 0,!1,void 0,this):R.jsxDEV("box",{flexDirection:"column",marginTop:1,flexGrow:1,children:S.map((u,o)=>{let m=iJ(Z,{cursor:o===T,selected:!1});return R.jsxDEV("box",{flexDirection:"column",flexShrink:0,...m.backgroundColor?{backgroundColor:m.backgroundColor}:{},children:[R.jsxDEV("box",{flexDirection:"row",gap:0,children:[R.jsxDEV("text",{fg:m.markerColor,wrapMode:"none",children:m.marker},void 0,!1,void 0,this),R.jsxDEV("box",{flexDirection:"row",flexGrow:1,paddingLeft:1,paddingRight:1,gap:1,children:[R.jsxDEV("text",{fg:Z.textMuted,wrapMode:"none",children:`#${u.number}`},void 0,!1,void 0,this),R.jsxDEV("text",{fg:Z.text,attributes:o===T?Ao.BOLD:void 0,wrapMode:"none",flexGrow:1,children:u.title},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),R.jsxDEV("box",{flexDirection:"row",gap:0,children:[R.jsxDEV("text",{fg:m.markerColor,wrapMode:"none",children:m.marker},void 0,!1,void 0,this),R.jsxDEV("box",{flexDirection:"row",flexGrow:1,paddingLeft:2,paddingRight:1,gap:1,children:[R.jsxDEV("text",{fg:Z.textMuted,wrapMode:"none",flexGrow:1,children:[u.author,...u.labels.slice(0,2)].filter(Boolean).join(" \xB7 ")},void 0,!1,void 0,this),R.jsxDEV("text",{fg:Z.textMuted,wrapMode:"none",children:Yq0(u.updatedAt,v)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},`${u.number}`,!0,void 0,this)})},void 0,!1,void 0,this),f?R.jsxDEV("text",{fg:Z.textMuted,children:f},void 0,!1,void 0,this):null]},void 0,!0,void 0,this)}var X6;var Ro=a(async()=>{g8();L3();Q$();r0();await e1([$$(),C4()]);X6=H1(q1(),1)});import{TextAttributes as To}from"@opentui/core";function So($){return $.flatMap((Z)=>Z.worktrees)}function qq0($,Z){let J=(z)=>z.replace(/^\/private\//,"/").replace(/\/+$/,""),X=J(Z);return $.listTasks().find((z)=>z.worktreePath&&J(z.worktreePath)===X)?.id}function Io($){let{theme:Z}=l0(),J=n$(),X=Z1(),[z,G]=tJ.useState(null),[W,H]=tJ.useState(0),U=()=>H((u)=>u+1);tJ.useEffect(()=>{let u=!1,o=!1,m=$.orchestrator;if(!m){G([]);return}return m.listWorktrees({network:!1}).then((e)=>{if(!u&&!o)G(e)}).catch(()=>{}),m.listWorktrees().then((e)=>{if(o=!0,u)return;G(e);let t=new Set(So(e).map((Y0)=>Y0.path));N((Y0)=>Y0.filter((F0)=>t.has(F0)))}).catch(()=>{}),()=>{u=!0}},[$.orchestrator,W]);let[K,N]=tJ.useState([]),L=(z??[]).map((u)=>({...u,worktrees:u.worktrees.filter((o)=>!K.includes(o.path))})),M=So(L),[V,P]=tJ.useState(0);tJ.useEffect(()=>{P((u)=>w4(u,M.length))},[M.length]);let[_,C]=tJ.useState(null);async function f(u,o){let m=$.orchestrator;if(!m)return;N((e)=>[...e,u.path]);try{await m.removeWorktree(u.path,o),U()}catch(e){if(N((t)=>t.filter((Y0)=>Y0!==u.path)),!o&&e instanceof Error&&Gq0.test(e.message)){if(await N4.show(J,X("worktrees.delete.forceTitle"),X("worktrees.delete.forceBody",{branch:u.branch||u.path}),X("common.cancel"),X("worktrees.delete.button"))===!0)await f(u,!0);return}console.error(`[rove worktrees] ${X("worktrees.delete.failed",{error:String(e)})}`)}}async function E(u){if(!$.orchestrator||_||K.includes(u.path))return;if(await N4.show(J,X("worktrees.delete.confirmTitle"),X("worktrees.delete.confirmBody",{branch:u.branch||u.path}),X("common.cancel"),X("worktrees.delete.button"))!==!0)return;f(u,!1)}async function S(u){let o=$.orchestrator;if(!o||_)return;let m=qq0(o,u.path);if(!m){console.error(`[rove worktrees] ${X("worktrees.land.noTask")}`);return}if(await N4.show(J,X("worktrees.land.confirmTitle"),X("worktrees.land.confirmBody",{branch:u.branch||u.path}),X("common.cancel"),X("worktrees.land.button"))!==!0)return;C(u.path);try{let t=await o.landTask(m);console.error(`[rove worktrees] ${X("worktrees.land.done",{branch:t.branch,landedOn:t.landedOn,commit:t.commit})}`),U()}catch(t){let Y0=t instanceof Error?t.message:String(t);if(Wq0.test(Y0))console.error(`[rove worktrees] ${X("worktrees.land.conflict",{files:Y0})}`);else if(Hq0.test(Y0))console.error(`[rove worktrees] ${X("worktrees.land.dirtyBase")}`);else console.error(`[rove worktrees] ${X("worktrees.land.failed",{error:Y0})}`)}finally{C(null)}}g1(()=>({enabled:J.stack.length===0,bindings:[...a7($.onClose),{key:"up",cmd:()=>P((u)=>w4(u-1,M.length))},{key:"down",cmd:()=>P((u)=>w4(u+1,M.length))},{key:"d",cmd:()=>{let u=M[V];if(u)E(u)}},{key:"l",cmd:()=>{let u=M[V];if(u)S(u)}}]}));function T(u){if(u===!0)return R.jsxDEV("text",{fg:Z.success,children:[" ",X("worktrees.badge.remoteOn")]},void 0,!0,void 0,this);if(u===!1)return R.jsxDEV("text",{fg:Z.warning,children:[" ",X("worktrees.badge.remoteOff")]},void 0,!0,void 0,this);return R.jsxDEV("text",{fg:Z.textMuted,children:[" ",X("worktrees.badge.remoteUnknown")]},void 0,!0,void 0,this)}function x(u){if(u.verdictReason==="dirty"||u.verdictReason==="fresh")return null;let o=u.verdict==="merged"?Z.success:u.verdict==="stale"?Z.warning:Z.accent;return R.jsxDEV("text",{fg:o,children:[" ",X(`worktrees.verdict.${u.verdictReason}`)]},void 0,!0,void 0,this)}let b=z===null,v=0;return R.jsxDEV("scrollbox",{flexGrow:1,backgroundColor:Z.background,paddingTop:1,paddingLeft:2,paddingRight:2,paddingBottom:1,verticalScrollbarOptions:{trackOptions:{foregroundColor:"transparent"}},children:[R.jsxDEV("box",{flexDirection:"row",justifyContent:"space-between",children:R.jsxDEV("text",{attributes:To.BOLD,fg:Z.text,children:X("worktrees.title")},void 0,!1,void 0,this)},void 0,!1,void 0,this),b?R.jsxDEV("text",{fg:Z.textMuted,children:X("worktrees.loading")},void 0,!1,void 0,this):L.length===0?R.jsxDEV("text",{fg:Z.textMuted,children:X("worktrees.noProjects")},void 0,!1,void 0,this):L.map((u)=>{let o=v;return v+=u.worktrees.length,R.jsxDEV("box",{gap:0,paddingTop:1,children:[R.jsxDEV("text",{fg:Z.textMuted,wrapMode:"none",children:u.repo},void 0,!1,void 0,this),u.worktrees.length===0?R.jsxDEV("text",{fg:Z.textMuted,wrapMode:"none",children:X("worktrees.noWorktrees")},void 0,!1,void 0,this):u.worktrees.map((m,e)=>{let t=o+e,Y0=t===V;return R.jsxDEV("box",{gap:0,onMouseUp:()=>P(t),children:[R.jsxDEV("box",{flexDirection:"row",children:[R.jsxDEV("text",{fg:Y0?Z.primary:Z.text,attributes:Y0?To.BOLD:void 0,wrapMode:"none",children:[Y0?"\u25B8 ":" ",m.branch||X("worktrees.row.detached")]},void 0,!0,void 0,this),m.kobeManaged?R.jsxDEV("text",{fg:Z.textMuted,children:[" ",X("worktrees.badge.kobeManaged")]},void 0,!0,void 0,this):null,m.dirty?R.jsxDEV("text",{fg:Z.warning,children:[" ",X("worktrees.badge.dirty")]},void 0,!0,void 0,this):null,T(m.branchOnRemote),x(m),_===m.path?R.jsxDEV("text",{fg:Z.textMuted,children:" \u2026"},void 0,!1,void 0,this):null]},void 0,!0,void 0,this),R.jsxDEV("box",{flexDirection:"row",justifyContent:"space-between",paddingLeft:2,children:[R.jsxDEV("text",{fg:Z.textMuted,wrapMode:"none",children:m.path},void 0,!1,void 0,this),m.createdAtMs>0?R.jsxDEV("text",{fg:Z.textMuted,wrapMode:"none",children:X("worktrees.row.created",{age:rY(m.createdAtMs)})},void 0,!1,void 0,this):null]},void 0,!0,void 0,this)]},m.path,!0,void 0,this)})]},u.repo,!0,void 0,this)})]},void 0,!0,void 0,this)}var tJ,Gq0,Wq0,Hq0;var Eo=a(async()=>{g8();sV();Q$();r0();await e1([$$(),C4(),V5(),FZ()]);tJ=H1(q1(),1);Gq0=/refusing to remove dirty worktree/,Wq0=/LAND_CONFLICT/,Hq0=/MAIN_CHECKOUT_DIRTY/});function wo($){let[Z,J]=vF.useState(!1),[X,z]=vF.useState(!1),[G,W]=vF.useState(!1),[H,U]=vF.useState("terminal"),K=(N)=>{U(N),$.setFocused(bi(N))};return{nav:H,setNav:U,goToNav:K,settingsOpen:Z,openSettings:()=>J(!0),closeSettings:()=>J(!1),worktreesOpen:X,openWorktrees:()=>z(!0),closeWorktrees:()=>z(!1),updateOpen:G,openUpdate:()=>W(!0),closeUpdate:()=>W(!1),kanbanOpen:H==="kanban",openKanban:()=>K("kanban"),closeKanban:()=>K("terminal"),automationsOpen:H==="automations",openAutomations:()=>K("automations"),closeAutomations:()=>K("terminal"),workItemsOpen:H==="issues",openWorkItems:()=>K("issues"),closeWorkItems:()=>K("terminal")}}function xo($){if($.worktreesOpen)return R.jsxDEV(Io,{orchestrator:$.orchestrator,onClose:$.closeWorktrees},void 0,!1,void 0,this);if($.updateOpen)return R.jsxDEV(Do,{onClose:$.closeUpdate},void 0,!1,void 0,this);return null}function fo($){let Z=$.orchestrator;if($.automationsOpen)return R.jsxDEV(ei,{orchestrator:Z,focused:$.contentFocused,...$.selectedTask?{focusRepo:$.selectedTask.repo}:{},onClose:$.closeAutomations,onOpenTask:(J)=>{$.closeAutomations(),$.activateTask(J)}},void 0,!1,void 0,this);if($.workItemsOpen)return R.jsxDEV(Po,{orchestrator:Z,focused:$.contentFocused,onClose:$.closeWorkItems,...$.selectedTask?{focusRepo:$.selectedTask.repo}:{},onOpenTask:(J)=>{$.closeWorkItems(),$.activateTask(J)}},void 0,!1,void 0,this);if($.kanbanOpen)return R.jsxDEV(_o,{orchestrator:Z,focused:$.contentFocused,onClose:$.closeKanban,onStartChat:$.startIssueChat,engineStates:$.engineStates,focusTask:$.selectedTask?{id:$.selectedTask.id,repo:$.selectedTask.repo}:void 0,onOpenTask:(J)=>{$.closeKanban(),$.activateTask(J)}},void 0,!1,void 0,this);return null}var vF;var go=a(async()=>{bI();r0();await e1([$o(),Co(),$E(),Ro(),Eo()]);vF=H1(q1(),1)});function yo($){let Z=$.scheduleTimeout??((U,K)=>{let N=setTimeout(U,K);return()=>clearTimeout(N)}),J=!1,X=null,z=()=>{J=!0,X?.(),X=Z(()=>{J=!1,X=null},700)},G=()=>{J=!1,X?.(),X=null},W=(U)=>{let K=$.getFlatIds();if(K.length===0)return;let N=$.getCursor(),L=N<0?0:N,M=Math.min(K.length-1,Math.max(0,L+U));$.setCursor(M)},H=(U)=>{let K=$.getFlatIds();if(K.length===0)return;$.setCursor(Math.min(K.length-1,Math.max(0,U)))};return{moveDown(){G(),W(1)},moveUp(){G(),W(-1)},selectCurrent(){G();let U=$.getFlatIds(),K=$.getCursor();if(K<0||K>=U.length)return;let N=U[K];if(N!==void 0)$.onSelect(N)},pressG(){if(J)G(),H(0);else z()},pressShiftG(){G(),H($.getFlatIds().length-1)},isChordArmed(){return J},disarmChord(){G()}}}function ko($,Z){if(!Z)return[...$];return[{kind:"recent",id:Z_,task:Z,depth:1},...$]}function yq($,Z){return`${$}${ZE}${Z}`}function lQ($){let Z=$.indexOf(ZE);if(Z<0)return{taskId:$,tabId:null};return{taskId:$.slice(0,Z),tabId:$.slice(Z+ZE.length)}}function vo($){let{tasks:Z,tabsByTask:J}=$,X=new Map;for(let H of Z){let U=oY(H.repo),K=X.get(U)??{repo:H.repo,tasks:[]};if(H.kind==="main")K.repo=H.repo,K.tasks.unshift(H);else K.tasks.push(H);X.set(U,K)}let z=[],G=new Set;for(let H of Z){if(H.kind!=="main")continue;let U=oY(H.repo);if(!G.has(U))G.add(U),z.push(U)}for(let H of X.keys())if(!G.has(H))G.add(H),z.push(H);let W=[];for(let H of z){let U=X.get(H);if(!U)continue;W.push({kind:"project",id:H,repo:U.repo,label:OZ(U.repo),depth:0});for(let K of U.tasks)Uq0(W,K,J)}return W}function Uq0($,Z,J){$.push({kind:"worktree",id:Z.id,task:Z,depth:1});for(let X of J.get(Z.id)??[])$.push({kind:"tab",id:yq(Z.id,X.id),task:Z,tab:X,depth:2})}function JE($){let Z=[];for(let J of $)if(J.kind!=="project")Z.push(J.id);return Z}function bo($){return oY($.repo)}function Bq0($){if($.kind==="project")return $.label;if($.kind==="tab")return $.tab.label;return`${$.task.title} ${$.task.branch??""} ${OZ($.task.repo)}`}function mo($,Z){let J=Z.trim();if(J==="")return[...$];let X=new Set,z=new Set;for(let W of $){if(!lI(J,Bq0(W)))continue;if(X.add(W.id),z.add(W.id),W.kind==="project")continue;if(W.kind==="tab")z.add(W.task.id);let H=bo(W.task);if(H!==null)z.add(H)}let G=[];for(let W of $){if(W.kind==="project"){if(z.has(W.id))G.push(W);continue}let H=bo(W.task),U=H!==null&&X.has(H);if(W.kind==="worktree"){if(U||z.has(W.id))G.push(W);continue}if(U||X.has(W.task.id)||z.has(W.id))G.push(W)}return G}function ho($,Z){for(let J of $){if(J.kind!=="main")continue;if(oY(J.repo)===Z)return String(J.id)}return null}function uo($){if($.tabActivity!==void 0)return $.tabActivity;if(!$.active||$.reportedTabCount>0)return;return $.taskActivity}var ZE="::",Z_="~recent";var mF=a(()=>{L3()});function lo($){let Z=$.maxWidth??Kq0,J=Math.max(1,...$.lines.map((W)=>em(W.text))),X=Math.min(Z-4,J),z=X+4,G=$.lines.length+2;return{innerWidth:X,boxWidth:z,boxHeight:G,left:Math.max(0,Math.min($.hoverX+2,$.screenWidth-z-1)),top:Math.max(0,Math.min($.hoverY+1,$.screenHeight-G-1))}}var co=2750,Kq0=72;var po=a(()=>{L3()});function no($,Z){return qZ($,Z)}var XE=()=>{};import{TextAttributes as Fq0}from"@opentui/core";function io($){let{theme:Z}=l0();if($.entries.length===0)return null;let J=lo({hoverX:$.x,hoverY:$.y,screenWidth:$.dims.width,screenHeight:$.dims.height,lines:$.entries.map((X)=>({text:X.label}))});return R.jsxDEV("box",{position:"absolute",zIndex:Mq0,left:J.left,top:J.top,width:J.boxWidth,flexDirection:"column",border:!0,borderColor:Z.focusAccent,backgroundColor:Z.backgroundElement,paddingLeft:1,paddingRight:1,children:$.entries.map((X,z)=>{let G=z===$.cursor;return R.jsxDEV("box",{flexShrink:0,backgroundColor:G?Z.focusAccent:void 0,onMouseUp:()=>$.onPick(X.id),children:R.jsxDEV("text",{fg:G?Z.backgroundElement:X.danger?Z.error:Z.text,attributes:G?Fq0.BOLD:void 0,wrapMode:"none",flexGrow:1,children:no(X.label,J.innerWidth)},void 0,!1,void 0,this)},X.id,!1,void 0,this)})},void 0,!1,void 0,this)}var Mq0;var oo=a(async()=>{po();XE();r0();await $$();Mq0=co+10});import{MouseButton as Nq0,TextAttributes as Q6}from"@opentui/core";function ao($){let{theme:Z,transparentBackground:J}=l0(),X=J?Z.border:Z.borderSubtle;return R.jsxDEV("box",{flexDirection:"column",flexShrink:0,children:[$.topPad?R.jsxDEV("box",{flexShrink:0,children:R.jsxDEV("text",{wrapMode:"none",children:" "},void 0,!1,void 0,this)},void 0,!1,void 0,this):null,R.jsxDEV("box",{flexDirection:"row",flexShrink:0,gap:1,paddingLeft:1,paddingRight:1,onMouseUp:$.onPress||$.onContextMenu?(z)=>{if(z.button===Nq0.RIGHT&&$.onContextMenu){$.onContextMenu(z.x,z.y);return}$.onPress?.()}:void 0,children:[$.prefix?R.jsxDEV("text",{fg:Z.textMuted,wrapMode:"none",flexShrink:0,children:$.prefix},void 0,!1,void 0,this):null,R.jsxDEV("text",{fg:Z.textMuted,attributes:Q6.BOLD,wrapMode:"none",flexShrink:0,children:$.label},void 0,!1,void 0,this),R.jsxDEV("text",{fg:X,wrapMode:"none",flexBasis:0,flexGrow:1,flexShrink:1,children:"\u2500".repeat(240)},void 0,!1,void 0,this),$.suffix?R.jsxDEV("text",{fg:Z.info,attributes:Q6.BOLD,wrapMode:"none",flexShrink:0,children:$.suffix},void 0,!1,void 0,this):null]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function ro($){let{theme:Z}=l0(),J=Z1();return R.jsxDEV("box",{flexDirection:"row",gap:0,flexShrink:0,paddingBottom:1,paddingLeft:1,children:[R.jsxDEV("text",{fg:Z.info,wrapMode:"none",children:"/"},void 0,!1,void 0,this),R.jsxDEV("text",{fg:Z.text,wrapMode:"none",children:$.query},void 0,!1,void 0,this),R.jsxDEV("text",{fg:Z.info,attributes:Q6.BLINK,wrapMode:"none",children:"\u2588"},void 0,!1,void 0,this),$.query.length===0?R.jsxDEV("text",{fg:Z.textMuted,wrapMode:"none",children:[" ",J("tasks.search.placeholder")]},void 0,!0,void 0,this):R.jsxDEV("text",{fg:Z.textMuted,wrapMode:"none",children:[" ",$.matchCount,"/",$.totalCount]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function so($){let{theme:Z}=l0();return R.jsxDEV("box",{flexDirection:"row",justifyContent:"space-between",gap:1,flexShrink:0,paddingLeft:1,paddingRight:1,children:R.jsxDEV("box",{flexDirection:"row",gap:1,children:[R.jsxDEV("text",{fg:$.focused?Z.focusAccent:Z.textMuted,attributes:Q6.BOLD,wrapMode:"none",children:"ROVE"},void 0,!1,void 0,this),$.status?R.jsxDEV("text",{fg:$.status.emphasize?Z.warning:Z.textMuted,attributes:$.status.emphasize?Q6.BOLD:Q6.DIM,wrapMode:"none",onMouseUp:()=>$.onStatusClick?.(),children:$.status.label},void 0,!1,void 0,this):null]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function to($){let{theme:Z,transparentBackground:J}=l0(),X=Z1(),z=X9("task.new");if(!$.onAddTask)return null;return R.jsxDEV("box",{flexShrink:0,paddingTop:1,paddingBottom:1,paddingLeft:1,paddingRight:1,children:R.jsxDEV("box",{flexDirection:"row",flexShrink:0,gap:1,paddingLeft:1,paddingRight:1,backgroundColor:J?void 0:Z.backgroundElement,onMouseUp:()=>$.onAddTask?.(),children:[R.jsxDEV("text",{fg:Z.primary,attributes:Q6.BOLD,wrapMode:"none",flexShrink:0,children:"+"},void 0,!1,void 0,this),R.jsxDEV("text",{fg:Z.text,attributes:Q6.BOLD,wrapMode:"none",flexGrow:1,children:X("tasks.menu.newTask")},void 0,!1,void 0,this),z?R.jsxDEV("text",{fg:Z.textMuted,attributes:Q6.DIM,wrapMode:"none",flexShrink:0,children:z},void 0,!1,void 0,this):null]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function eo($){let{theme:Z}=l0(),J=Z1();return R.jsxDEV("box",{flexDirection:"column",flexShrink:0,paddingBottom:1,children:yi.map((X)=>{let z=$.nav===X.nav;return R.jsxDEV("box",{flexDirection:"row",flexShrink:0,paddingLeft:1,paddingRight:1,backgroundColor:z?Z.focusAccent:void 0,onMouseUp:(G)=>{G.stopPropagation(),$.setNav(X.nav)},children:R.jsxDEV("text",{fg:z?Z.backgroundElement:Z.textMuted,attributes:z?Q6.BOLD:void 0,wrapMode:"none",flexGrow:1,children:J(X.labelKey)},void 0,!1,void 0,this)},X.nav,!1,void 0,this)})},void 0,!1,void 0,this)}function $a($){let{theme:Z}=l0(),J=Z1();return R.jsxDEV("box",{flexDirection:"row",gap:1,flexShrink:0,paddingBottom:1,paddingLeft:1,paddingRight:1,children:lH.map((X)=>{let z=$.view===X.view;return R.jsxDEV("box",{flexShrink:0,paddingLeft:1,paddingRight:1,backgroundColor:z?Z.focusAccent:void 0,onMouseUp:()=>$.setView(X.view),children:R.jsxDEV("text",{fg:z?Z.backgroundElement:Z.textMuted,attributes:z?Q6.BOLD:void 0,wrapMode:"none",children:J(Jh(X.view))},void 0,!1,void 0,this)},X.view,!1,void 0,this)})},void 0,!1,void 0,this)}function Za($){let{theme:Z}=l0();return R.jsxDEV("box",{flexShrink:0,paddingLeft:1,paddingRight:1,paddingTop:1,children:R.jsxDEV("text",{fg:Z.accent,attributes:Q6.BOLD,wrapMode:"none",onMouseUp:(J)=>{J.stopPropagation(),$.onZenClick?.()},children:"\u262F ZEN"},void 0,!1,void 0,this)},void 0,!1,void 0,this)}var QE=a(async()=>{mj();bI();gJ();Q$();r0();await $$()});function J_($){let Z=new Map,J=$.equals??((z,G)=>z===G);function X(z){let G=Z.get(z);if(!G){let W=$.initial;G={read:()=>W,write:(H)=>{if(!J(W,H))W=H},inFlight:!1,nextAllowedAt:0},Z.set(z,G)}return G}return{read(z){if(!z)return $.initial;return X(z).read()},poll(z){if(!z)return;let G=X(z);vy(G,$,(W)=>$.run(z,W),(W)=>G.write(W))},reset(){Z.clear()}}}var hF=a(()=>{CH();CH()});import{stat as Oq0}from"fs/promises";import{join as Lq0}from"path";async function Cq0($){try{let Z=await Oq0(Lq0($,".git","HEAD"));return`${Z.mtimeMs}:${Z.size}`}catch{return null}}async function Dq0($,Z,J=t6){let X=await Cq0($);if(X!==null){let U=Ja.get($);if(U&&U.fingerprint===X)return U.value}let z="",G=!1,W=await J("git",["symbolic-ref","--short","HEAD"],{cwd:$,env:a2(),signal:Z}),H=W.status===0?W.stdout.trim():"";if(H&&H!=="HEAD")z=H,G=!0;else if((await J("git",["rev-parse","--verify","HEAD"],{cwd:$,env:a2(),signal:Z})).status===0)z="(detached)",G=!0;if(G&&X!==null)Ja.set($,{fingerprint:X,value:z});return z}function zE($){return Xa.read($)}function YE($){Xa.poll($)}var jq0=2000,Vq0=30000,_q0=1500,Ja,Xa;var GE=a(()=>{wJ();hF();Ja=new Map;Xa=J_({initial:"",timeoutMs:jq0,slowRetryMs:Vq0,minIntervalMs:_q0,run:($,Z)=>Dq0($,Z)})});function Aq0($){switch($){case"rate_limited":return{text:S$("tasks.activity.rateLimited"),tone:"warning"};case"permission_needed":return{text:S$("tasks.activity.permissionNeeded"),tone:"warning"};case"error":return{text:S$("tasks.activity.error"),tone:"error"};default:return null}}function WE($){switch($.prStatus?.checkState){case"passing":return{glyph:"\u2713",tone:"success"};case"failing":return{glyph:"\u2717",tone:"error"};case"pending":return{glyph:"\u2022",tone:"warning"};default:return null}}function Rq0(){return S$("tasks.subtitle.noTracking")}function Tq0(){return S$("tasks.subtitle.materializing")}function Sq0($){return $?S$("tasks.subtitle.deleteFailed"):S$("tasks.subtitle.deleting")}function Ya($){if($.kind==="main")return!1;return $.vendor!==void 0&&!h7($.vendor)}function Ga($,Z){if($?.state!=="turn_complete"||!Z)return!1;if(!$.at||!Z.mtimeMs)return!1;return Z.mtimeMs>$.at+Iq0}function Eq0($){let{task:Z}=$,J=$.activity?.state,X=J!==void 0,z=Ya(Z)&&!X,G=$.job!==void 0,W=Z.deletion?.phase==="queued"||Z.deletion?.phase==="running",H=J==="running"||Ga($.activity,$.transcript);return W||G||!z&&H}function HE($){let{task:Z}=$,J=Z.kind==="main",X=J?$.mainBranch??"":Z.branch,z=$.activity?.state,G=z!==void 0,H=Ga($.activity,$.transcript)?null:wq0(z,$.completionSeen===!0),U=Aq0(z),K=Ya(Z)&&!G,N=$.job!==void 0,L=Z.deletion?.phase==="queued"||Z.deletion?.phase==="running",M=Z.deletion?.phase==="error",V=Eq0({task:Z,activity:$.activity,job:$.job,transcript:$.transcript}),P=D$(Z.vendor??M4).spinnerFrames??hL,_=P[$.spinnerFrame%P.length]??P[0],C=M?"error":L||N?"primary":K?"textMuted":U?.tone??(V?"primary":H?.tone??"textMuted"),f=K?Rq0():"\u2014",E=V?$.lifecycle?.subagents??0:0,S=E>0&&X.length>0?`\u25C7${E} ${X}`:X,T=L||M?$.truncateBranch(Sq0(M),$.subtitleBudget):N?$.truncateBranch(Tq0(),$.subtitleBudget):U?$.truncateBranch(U.text,$.subtitleBudget):S.length>0?$.truncateBranch(S,$.subtitleBudget):$.truncateBranch(f,$.subtitleBudget),x=M?"\u2715":K?Pq0:H?.glyph??"\u25CB";return{isMain:J,titleText:J?OZ(Z.repo):Z.title,subtitleText:T,loading:V,stateGlyph:V?_:x,tone:C,spinnerFrames:P,materializing:N}}function qE($,Z){if(!$.loading)return $;let J=$.spinnerFrames,X=J[Z()%J.length]??J[0]??"\u280B";if(X===$.stateGlyph)return $;return{...$,stateGlyph:X}}function wq0($,Z){switch($){case"rate_limited":return{glyph:"\u25F7",tone:"warning"};case"permission_needed":return{glyph:"?",tone:"warning"};case"error":return{glyph:"\u2715",tone:"error"};case"turn_complete":return Z?null:{glyph:"\u25CF",tone:"primary"};default:return null}}var Qa=100,za=600,Pq0="\xB7",Iq0=2000;var X_=a(()=>{C7();uL();gY();d7();u7();L3()});function xq0(){z_=(z_+1)%za;for(let $ of Q_)try{$()}catch{}}function Y_(){return z_}function G_($){if(Q_.add($),bq===null)bq=setInterval(xq0,Qa),bq.unref?.();return()=>{if(Q_.delete($),Q_.size===0&&bq!==null)clearInterval(bq),bq=null,z_=0}}var Q_,z_=0,bq=null;var UE=a(()=>{X_();Q_=new Set});function Ha($){return Wa.read($)}function qa($){Wa.poll($)}var fq0=4000,gq0=60000,yq0=1500,bq0,Wa;var Ua=a(()=>{wJ();hF();cH();hF();bq0={added:0,deleted:0},Wa=J_({initial:bq0,equals:aK,timeoutMs:fq0,slowRetryMs:gq0,minIntervalMs:yq0,run:async($,Z)=>{let J=await t6("git",["status","--porcelain=v1"],{cwd:$,env:a2(),signal:Z});if(J.status!==0)throw Error("git status failed");return uH(J.stdout)}})});function BE($,Z){return Z===void 0?$:`${$}\x00${Z}`}function kq0($){if(typeof $!=="object"||$===null||Array.isArray($))return{};let Z={};for(let[J,X]of Object.entries($))if(typeof X==="number"&&Number.isFinite(X))Z[J]=X;return Z}function vq0($,Z,J,X=200){let z=$[Z];if(z!==void 0&&z>=J)return $;let G={...$,[Z]:J},W=Object.keys(G);if(W.length<=X)return G;let H={};for(let U of W.sort((K,N)=>G[N]-G[K]).slice(0,X))H[U]=G[U];return H}function Ba($,Z,J){if(!$||J===void 0)return!1;let X=$.get("completionSeen");if(typeof X!=="object"||X===null||Array.isArray(X))return!1;let z=X[Z];return typeof z==="number"&&z>=J}function Ka($,Z,J){let X=kq0($.get("completionSeen")),z=vq0(X,Z,J);if(z!==X)$.set("completionSeen",z)}import{TextAttributes as mq0}from"@opentui/core";function Fa($){return kq.useSyncExternalStore($?G_:hq0,$?Y_:uq0)}function Ma($,Z){let J=XT($.worktreeChanges,Z.worktreePath),X=J!==null;return kq.useEffect(()=>{if($.branchTick,X||Z.archived)return;qa(Z.worktreePath)},[X,Z.archived,Z.worktreePath,$.branchTick]),J??Ha(Z.worktreePath)}function Na($){let{theme:Z}=l0();if($.changes.added<=0&&$.changes.deleted<=0)return null;return R.jsxDEV("box",{flexDirection:"row",gap:1,flexShrink:0,children:[$.changes.added>0?R.jsxDEV("text",{fg:Z.success,wrapMode:"none",flexShrink:0,children:["+",$.changes.added]},void 0,!0,void 0,this):null,$.changes.deleted>0?R.jsxDEV("text",{fg:Z.error,wrapMode:"none",flexShrink:0,children:["\u2212",$.changes.deleted]},void 0,!0,void 0,this):null]},void 0,!0,void 0,this)}function Oa($,Z,J,X,z=!1){let G=BE($,X);if(Z==="turn_complete"){if(J)KE.add(G)}else KE.delete(G);return KE.has(G)||z}function La($){return $?.state==="turn_complete"?$.at:void 0}function ja($,Z,J,X){let z=bQ(),G=BE($,Z),W=Ba(z,G,J);return kq.useEffect(()=>{if(!z||!X||J===void 0||W)return;Ka(z,G,J)},[z,G,J,X,W]),W}function FE($){let{theme:Z}=l0(),J=$u($.flatIndex);if(J===null)return null;return R.jsxDEV("text",{fg:$.dim?Z.textMuted:Z.accent,attributes:mq0.DIM,wrapMode:"none",flexShrink:0,children:J},void 0,!1,void 0,this)}var kq,hq0=()=>()=>{},uq0=()=>0,KE;var Va=a(async()=>{fS();UE();GE();fT();XE();X_();gJ();cH();Ua();M3();Q$();r0();await $$();kq=H1(q1(),1);KE=new Set});import{MouseButton as cq0}from"@opentui/core";function ME($){let{theme:Z}=l0(),J=$.shared,X=iJ(Z,{cursor:J.cursorIndex===$.flatIndex,selected:J.activeRowId===$.rowId});return R.jsxDEV("box",{ref:(z)=>{if(!z)return;return J.rowEls.set($.flatIndex,z),()=>{if(J.rowEls.get($.flatIndex)===z)J.rowEls.delete($.flatIndex)}},width:"100%",flexDirection:"row",gap:0,backgroundColor:X.backgroundColor,onMouseUp:(z)=>{if(z.stopPropagation(),z.button===cq0.RIGHT&&J.onContextMenu){J.onContextMenu($.flatIndex,$.rowId,z.x,z.y);return}J.onPress($.flatIndex,$.rowId)},children:[R.jsxDEV("text",{fg:X.markerColor,wrapMode:"none",children:X.marker},void 0,!1,void 0,this),R.jsxDEV("text",{wrapMode:"none",flexShrink:0,children:" ".repeat($.depth*dq0)},void 0,!1,void 0,this),$.children]},void 0,!0,void 0,this)}function Ca($){let{theme:Z}=l0(),J=$.shared,X=$.task,z=J.cursorIndex===$.flatIndex,G=Ma(J,X),W=WE(X),H=X.kind==="main";_a.useEffect(()=>{if(J.branchTick,H)YE(X.repo)},[H,X.repo,J.branchTick]);let U=(H?zE(X.repo):X.branch)||X.branch||X.title;return R.jsxDEV(ME,{rowId:$.rowId,flatIndex:$.flatIndex,depth:1,shared:J,children:R.jsxDEV("box",{flexDirection:"row",flexGrow:1,paddingRight:1,gap:1,children:[R.jsxDEV("text",{fg:Z.text,wrapMode:"none",flexBasis:0,flexGrow:1,flexShrink:1,children:U},void 0,!1,void 0,this),X.pinned===!0?R.jsxDEV("text",{fg:Z.warning,wrapMode:"none",flexShrink:0,children:"\u25B4"},void 0,!1,void 0,this):null,W?R.jsxDEV("text",{fg:qj(Z,W.tone),wrapMode:"none",flexShrink:0,children:W.glyph},void 0,!1,void 0,this):null,R.jsxDEV(Na,{changes:G},void 0,!1,void 0,this),R.jsxDEV(FE,{flatIndex:$.flatIndex,dim:!z},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function Da($){let{theme:Z}=l0(),J=$.shared,X=J.cursorIndex===$.flatIndex,z=$.tab.engine===!0,G=z?J.engineTabState?.get($.task.id):void 0,W=z?uo({tabActivity:G?.get($.tab.id),reportedTabCount:G?.size??0,taskActivity:J.engineState?.get($.task.id),active:$.tab.active===!0}):void 0,H=W!==void 0,U=J.selectedTaskId===$.task.id&&$.tab.active===!0,K=ja($.task.id,$.tab.id,H?La(W):void 0,U),N=H?Oa($.task.id,W?.state,U,$.tab.id,K):!1,L=HE({task:$.task,activity:W,lifecycle:H?J.engineLifecycle?.get($.task.id):void 0,job:H?J.taskJobs?.get($.task.id):void 0,spinnerFrame:0,subtitleBudget:0,truncateBranch:BT,completionSeen:N}),M=Fa(H&&L.loading),V=qE(L,()=>M),P="\u25CC",_=z?H?V.stateGlyph:"\u25CC":"\xB7";return R.jsxDEV(ME,{rowId:$.rowId,flatIndex:$.flatIndex,depth:2,shared:$.shared,children:[R.jsxDEV("text",{fg:H?qj(Z,V.tone):Z.textMuted,wrapMode:"none",width:2,flexShrink:0,children:`${_} `},void 0,!1,void 0,this),R.jsxDEV("box",{flexDirection:"row",flexGrow:1,paddingRight:1,gap:1,children:[R.jsxDEV("text",{fg:Z.textMuted,wrapMode:"none",flexBasis:0,flexGrow:1,flexShrink:1,children:$.tab.label},void 0,!1,void 0,this),R.jsxDEV(FE,{flatIndex:$.flatIndex,dim:!X},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Aa($){let{theme:Z}=l0(),J=Z1();return R.jsxDEV(ME,{rowId:$.rowId,flatIndex:$.flatIndex,depth:1,shared:$.shared,children:[R.jsxDEV("text",{fg:Z.accent,wrapMode:"none",width:2,flexShrink:0,children:"\u21A9 "},void 0,!1,void 0,this),R.jsxDEV("text",{fg:Z.text,wrapMode:"none",flexShrink:1,children:J("tasks.recentJump",{title:$.task.title})},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var _a,dq0=1;var Pa=a(async()=>{GE();X_();mF();gJ();Q$();r0();await e1([$$(),Va()]);_a=H1(q1(),1)});function Ra($){let{theme:Z}=l0(),J=Z1();return R.jsxDEV("scrollbox",{ref:$.setScrollRef,flexGrow:1,minHeight:0,stickyScroll:!1,verticalScrollbarOptions:{visible:!1},children:R.jsxDEV("box",{flexShrink:0,gap:0,children:[$.rows.map((X,z)=>{if(X.kind==="project")return R.jsxDEV(ao,{label:X.label,suffix:$.movingProjectId===X.id?J("tasks.moveChip"):void 0,topPad:z>0,onContextMenu:$.onProjectContextMenu?(G,W)=>$.onProjectContextMenu?.(X.id,G,W):void 0},X.id,!1,void 0,this);if(X.kind==="recent")return R.jsxDEV(Aa,{rowId:X.id,flatIndex:$.flatIndexOf.get(X.id)??-1,task:X.task,shared:$.shared},X.id,!1,void 0,this);if(X.kind==="worktree")return R.jsxDEV(Ca,{rowId:X.id,flatIndex:$.flatIndexOf.get(X.id)??-1,task:X.task,shared:$.shared},X.id,!1,void 0,this);return R.jsxDEV(Da,{rowId:X.id,flatIndex:$.flatIndexOf.get(X.id)??-1,task:X.task,tab:X.tab,shared:$.shared},X.id,!1,void 0,this)}),$.rows.length===0?R.jsxDEV("box",{paddingTop:1,paddingLeft:1,children:R.jsxDEV("text",{fg:Z.textMuted,children:J(Qh({searching:$.searching,projectFilter:!1,view:$.view}))},void 0,!1,void 0,this)},void 0,!1,void 0,this):null]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}var Ta=a(async()=>{gJ();Q$();r0();await e1([$$(),QE(),Pa()])});function Sa($){return[{action:"rename",labelKey:"tasks.menu.rename"},{action:"pin",labelKey:$?"tasks.menu.unpin":"tasks.menu.pin"},{action:"localMerge",labelKey:"tasks.menu.localMerge"},{action:"archive",labelKey:"tasks.menu.archive"},{action:"delete",labelKey:"tasks.menu.delete",danger:!0}]}function Ia($,Z={}){if($.kind==="project")return[{action:"newTask",labelKey:"tasks.menu.newTask"}];if($.kind==="worktree")return[{action:"open",labelKey:"tasks.menu.open"},...Sa($.task.pinned===!0)];let J=[{action:"open",labelKey:"tasks.menu.openTab"}];if((Z.tabCount??0)>1)J.push({action:"closeTab",labelKey:"tasks.menu.closeTab"});return[...J,...Sa($.task.pinned===!0)]}function Ea($){let Z=Z1(),{tree:J,activateRow:X,setCursorIndex:z,actions:G}=$,[W,H]=z6.useState(null),[U,K]=z6.useState(0),N=z6.useCallback((E,S,T,x)=>{let b=Ia(E,S);H({row:E,actions:b.map((v)=>v.action),entries:b.map((v)=>({id:v.action,label:Z(v.labelKey),danger:v.danger})),x:T,y:x}),K(0)},[Z]),L=z6.useCallback((E,S,T,x)=>{let b=J.rows.find((v)=>v.id===S);if(!b||b.kind==="project"||b.kind==="recent")return;z(E),N(b,{tabCount:J.tabCount(b.task.id)},T,x)},[J.rows,J.tabCount,N,z]),M=z6.useCallback((E,S,T)=>{let x=J.rows.find((b)=>b.kind==="project"&&b.id===E);if(!x)return;N(x,{},S,T)},[J.rows,N]),V=z6.useCallback(()=>H(null),[]),P=z6.useCallback((E)=>{let S=W?.entries.length??0;if(S===0)return;K((T)=>(T+E+S)%S)},[W]),_=z6.useCallback((E)=>{if(!W||E===void 0)return;let S=W.row;if(H(null),S.kind==="project"){if(E==="newTask")$.onAddTask?.();return}let T=S.task.id;switch(E){case"open":X(S.id);break;case"closeTab":if(S.kind==="tab")$.onCloseTab?.(T,S.tab.id);break;case"rename":G.onRenameRequest?.(T);break;case"pin":G.onPinRequest?.(T);break;case"localMerge":G.onLocalMergeRequest?.(T);break;case"archive":G.onArchiveRequest?.(T);break;case"delete":G.onDeleteRequest?.(T);break;default:break}},[W,X,G,$.onAddTask,$.onCloseTab]),C=z6.useCallback(()=>_(W?.actions[U]),[_,W,U]),f=z6.useCallback((E)=>_(W?.actions.find((S)=>S===E)),[_,W]);return{open:W!==null,entries:W?.entries??[],cursor:U,x:W?.x??0,y:W?.y??0,close:V,moveCursor:P,pickCurrent:C,pick:f,openForRow:L,openForProject:M}}var z6;var wa=a(()=>{Q$();z6=H1(q1(),1)});function xa($){let[Z,J]=pQ.useState(!1),[X,z]=pQ.useState(""),G=w1($.focused),W=$.onActiveChange,H=pQ.useCallback(()=>{z(""),J(!0),W?.(!0)},[W]),U=pQ.useCallback(()=>{J(!1),z(""),W?.(!1)},[W]),K=E4();return pQ.useEffect(()=>{if(!Z||!K)return;let N=(L)=>{if(!G.current||bY())return;z((M)=>zh(M,L)??M)};return K.keyInput.on("keypress",N),()=>{K.keyInput.off("keypress",N)}},[Z,K]),{active:Z,query:X,enter:H,exit:U}}var pQ;var fa=a(async()=>{gJ();W2();await e1([u4(),C4()]);pQ=H1(q1(),1)});function ga($){return $.split("::").slice(0,2).join("::")}function W_($,Z=Date.now()){NE.set(ga($),Z)}function ya($,Z=Date.now()){let J=ga($),X=NE.get(J);if(X===void 0)return!1;if(Z-X>15000)return NE.delete(J),!1;return!0}var NE;var H_=a(()=>{NE=new Map});import{basename as ba}from"path";function pq0($){return ba($).replace(/\.(exe|js|mjs|cjs)$/,"")}function nq0($){for(let Z of $.trim().split(/\s+/).slice(0,4)){if(/^[A-Za-z_][A-Za-z0-9_]*=/.test(Z))continue;let J=pq0(Z);if(lq0.has(J))continue;return WQ.find((X)=>{let z=D$(X);return z.defaultCommand[0]===J||z.processNames?.includes(J)===!0})??null}return null}function LZ($){let Z=[];for(let J of $.split(`
731
731
  `)){let X=/^\s*(\d+)\s+(\d+)\s+(\S.*)$/.exec(J);if(X)Z.push({pid:Number(X[1]),ppid:Number(X[2]),args:X[3]})}return Z}function ka($){let Z=new Map;for(let J of $){let X=Z.get(J.ppid);if(X)X.push(J);else Z.set(J.ppid,[J])}return Z}function tY($,Z){let J=ka($),X=[...J.get(Z)??[]];while(X.length>0){let z=X.shift();if(!z)break;let G=nq0(z.args);if(G)return{vendor:G,argv:z.args,pid:z.pid};X.push(...J.get(z.pid)??[])}return null}function q_($,Z,J){if(tY($,Z))return!0;if(!J)return!1;let X=ka($),z=[...X.get(Z)??[]];while(z.length>0){let G=z.shift();if(!G)break;let W=G.args.trim().split(/\s+/)[0]??"";if(ba(W)===J)return!0;z.push(...X.get(G.pid)??[])}return!1}var lq0,jZ=async()=>{let $=Bun.spawn(["ps","-A","-o","pid=,ppid=,args="],{stdout:"pipe",stderr:"ignore"});return await new Response($.stdout).text()};var vq=a(()=>{u7();C7();lq0=new Set(["node","bun","npx","deno","sh","zsh","bash","env","script"])});function iq0($={}){let Z=$.entries??(()=>X4().entries()),J=$.snapshot??jZ,X=new Map,z=new Set,G=new Set,W=!1,H=()=>{for(let N of G)N()},U={async probe(){if(W)return;let N=new Map,L=new Set;for(let[V,P]of Z()){L.add(V);let _=P.shellPid??null;if(_!==null)N.set(V,_)}let M=!1;for(let V of[...X.keys()]){if(L.has(V)&&N.has(V))continue;X.delete(V),M=!0}for(let V of[...z]){if(L.has(V)&&N.has(V))continue;z.delete(V)}if(N.size>0){let V;try{V=LZ(await J())}catch{if(M)H();return}if(W)return;for(let[P,_]of N){let C=tY(V,_)?.vendor??null;if(z.add(P),(X.get(P)??null)===C)continue;if(C)X.set(P,C);else X.delete(P);M=!0}}if(M)H()},get(N){return X.get(N)??null},resolve(N){let L=X.get(N);if(L)return L;return z.has(N)?null:void 0},subscribe(N){return G.add(N),()=>{G.delete(N)}},dispose(){W=!0,G.clear(),X.clear(),z.clear(),clearInterval(K)}},K=setInterval(()=>{U.probe()},$.intervalMs??2000);return K.unref?.(),U}function eY(){if(!OE)OE=iq0();return OE}var OE=null;var U_=a(()=>{vq();x8()});function oq0($,Z){let J=/^tab-(\d+)$/.exec($);return J?Number(J[1]):Z}function B_($,Z){let J=new Set($.tabs.map((U)=>U.id)),X=[];for(let U of Z){if(J.has(U))continue;J.add(U),X.push(U)}if(X.length===0)return $;let z=$.nextOrdinal,G=X.map((U)=>({kind:"engine",id:U,title:null,ordinal:oq0(U,z++),spawned:!0}));G.sort((U,K)=>U.ordinal-K.ordinal);let W=[...$.tabs,...G],H=W.reduce((U,K)=>Math.max(U,K.ordinal),0);return{tabs:W,activeId:$.activeId,nextOrdinal:Math.max($.nextOrdinal,H+1)}}function va($,Z,J){if(J.length===0)return!1;if(fn(Z,J),!yn())return!1;let z=$.store[P7(Z)],G=$8.get(Z)??(z&&Array.isArray(z.tabs)?z:null),W={tabs:[],activeId:J[0],nextOrdinal:1},H=B_(G??W,J);if(G&&H===G)return!1;return $8.set(Z,H),$.set(P7(Z),H),!0}var ma=a(()=>{O3()});function ha($,Z){let J=new Map;for(let X of $){if(X.alive===!1)continue;let{taskId:z,tabId:G}=lQ(X.key);if(!G)continue;let W=G.split("::")[0];if(Z.has(yq(z,W)))continue;let H=J.get(z)??[];if(H.some((U)=>U.id===W))continue;H.push({id:W,label:`\u26A0 ${X.title?.trim()||W}`,active:H.length===0,engine:!0}),J.set(z,H)}return J}var ua=a(()=>{mF()});function rq0(){return process.env.BUN_TEST!=="1"&&process.env.VITEST!=="true"}function da($=rq0()){let[Z,J]=K_.useState(ca);return K_.useEffect(()=>{if(!$)return;let X=!1,z=async()=>{try{let W=await eK(),{sessions:H=[]}=await W.request("pty.list",{});if(!X)J(H)}catch{if(!X)J(ca)}};z();let G=setInterval(()=>void z(),aq0);return()=>{X=!0,clearInterval(G)}},[$]),Z}var K_,aq0=2000,ca;var la=a(()=>{$F();K_=H1(q1(),1),ca=[]});function pa($){let{tasks:Z,kv:J,selectedTaskId:X,selectedTabId:z}=$,G=$.query??"",W=G.trim()!=="",H=eY(),[U,K]=E2.useState(0);E2.useEffect(()=>H.subscribe(()=>K((b)=>b+1)),[H]);let N=da(),L=E2.useMemo(()=>{let b=new Map;for(let v of Z){let u=jI(J,v.id);if(!u)continue;let o=v.vendor??M4;b.set(v.id,u.tabs.map((m)=>{let e=H.resolve(b8(v.id,m)),t=e===void 0?m.liveVendor:e;return{id:m.id,label:nY(m,o,t),active:m.id===u.activeId,engine:m.kind==="engine"||(t??null)!==null}}))}return b},[Z,J,H,U]),M=E2.useMemo(()=>{let b=new Set;for(let[o,m]of L)for(let e of m)b.add(yq(o,e.id));let v=new Map,u=N.filter((o)=>!ya(o.key));for(let[o,m]of ha(u,b))if(Z.some((e)=>e.id===o))v.set(o,m);return v},[L,N,Z]);E2.useEffect(()=>{if(!J)return;for(let[b,v]of M)va(J,b,v.map((u)=>u.id))},[M,J]);let V=E2.useMemo(()=>{if(M.size===0)return L;let b=new Map(L);for(let[v,u]of M){let o=b.get(v);b.set(v,o?[...o,...u.map((m)=>({...m,active:!1}))]:u)}return b},[L,M]),P=$.recentTask??null,{rows:_,totalCount:C}=E2.useMemo(()=>{let b=vo({tasks:Z,tabsByTask:V}),v=JE(b).length;return{rows:W?mo(b,G):ko(b,P),totalCount:v}},[Z,V,W,G,P]),f=E2.useMemo(()=>JE(_),[_]),E=E2.useMemo(()=>{if(X===null)return null;if(z!==null)return yq(X,z);return X},[X,z]),S=E2.useCallback((b)=>V.get(b)?.length??0,[V]),T=E2.useCallback((b)=>ho(Z,b),[Z]),x=E2.useCallback((b)=>{let v=Z.find((u)=>u.id===b);if(!v||v.kind==="dir")return null;return oY(v.repo)},[Z]);return{rows:_,flatIds:f,totalCount:C,tabCount:S,activeRowId:E,projectIdOfTask:x,mainTaskIdOfProject:T}}var E2;var na=a(()=>{d7();L3();mF();H_();U_();UI();U7();ma();O3();ua();la();E2=H1(q1(),1)});function ia($){let{theme:Z}=l0(),J=bQ(),X=$.focused??!0,z=E5(),[G,W]=c4.useState("active"),H=c4.useMemo(()=>oi($.tasks,G),[$.tasks,G]),U=G==="archived"||$.tasks.some((G0)=>G0.archived===!0),[K,N]=c4.useState(0);c4.useEffect(()=>{let G0=setInterval(()=>N((s)=>s+1),Zh);return()=>clearInterval(G0)},[]);let L=xa({focused:X,onActiveChange:$.onSearchActiveChange}),M=pa({tasks:H,kv:J,selectedTaskId:$.selectedId,selectedTabId:$.selectedTabId??null,query:L.active?L.query:"",recentTask:$.recentTask??null}),V=c4.useMemo(()=>{let G0=new Map;return M.flatIds.forEach((s,r)=>G0.set(s,r)),G0},[M.flatIds]),[P,_]=c4.useState(-1),C=c4.useRef(P),f=c4.useCallback((G0)=>{C.current=G0,_(G0)},[]),E=w1(M.flatIds),S=c4.useRef(null),T=c4.useRef(null),x=$.moveMode===!0;c4.useEffect(()=>{let G0=M.flatIds;if(x){let C0=T.current,Q0=C0===null?-1:G0.indexOf(C0);if(Q0>=0){if(Q0!==C.current)f(Q0);return}}let s=M.activeRowId,r=s!==S.current;S.current=s;let J0=s===null?-1:G0.indexOf(s);if(r&&J0>=0){if(J0!==C.current)f(J0);return}if(C.current>=G0.length)f(Math.max(0,G0.length-1));else if(C.current<0&&G0.length>0)f(J0>=0?J0:0)},[M.flatIds,M.activeRowId,x,f]),c4.useEffect(()=>{T.current=M.flatIds[C.current]??null}),c4.useEffect(()=>{if(L.query,!L.active)return;f(0)},[L.active,L.query,f]);let b=w1($.recentTask??null),v=c4.useCallback((G0)=>{let s=G0===Z_?b.current:null,{taskId:r,tabId:J0}=s?{taskId:s.id,tabId:null}:lQ(G0);if($.onSelect(r),J0===null){$.onActivate?.(r);return}$.onSelectTab?.(r,J0),$.onActivate?.(r)},[$.onSelect,$.onActivate,$.onSelectTab]),u=w1(v),o=c4.useRef(null);if(o.current===null)o.current=yo({getCursor:()=>C.current,setCursor:f,getFlatIds:()=>E.current,onSelect:(G0)=>u.current(G0)});let m=o.current,e=c4.useMemo(()=>{let G0=M.flatIds[P];if(G0===void 0)return null;return M.projectIdOfTask(lQ(G0).taskId)},[M.flatIds,M.projectIdOfTask,P]),t=c4.useCallback((G0)=>{let s=E.current[C.current];if(s===void 0)return;let r=M.projectIdOfTask(lQ(s).taskId);if(r===null)return;let J0=M.mainTaskIdOfProject(r);if(J0===null)return;$.onMoveRequest?.(J0,G0)},[M.projectIdOfTask,M.mainTaskIdOfProject,$.onMoveRequest]),Y0=Ea({tree:M,activateRow:v,setCursorIndex:f,onAddTask:$.onAddTask,onCloseTab:$.onCloseTab,actions:$}),F0=cV("sidebar");g1(()=>({enabled:X&&!L.active&&!Y0.open,bindings:G5({"sidebar.nav":(G0,s)=>{F0();let r=(s??0)%2===0;if(x){t(r?1:-1);return}if(r)m.moveDown();else m.moveUp()},"sidebar.select":()=>{if(F0(),x){$.onMoveModeExit?.();return}m.selectCurrent()},"sidebar.goto":(G0,s)=>{if(x)return;if((s??0)%2===1)m.pressShiftG();else m.pressG()},"sidebar.tree.open":()=>{if(x)return;m.selectCurrent()},"sidebar.search.enter":()=>{if(x)return;L.enter()},"sidebar.delete":()=>{if(x)return;K0($.onDeleteRequest)},"sidebar.archive":()=>{if(x)return;K0($.onArchiveRequest)},"sidebar.rename":()=>{if(x)return;K0($.onRenameRequest)},"sidebar.localMerge":()=>K0($.onLocalMergeRequest),"sidebar.pin":()=>{if(x)return;K0($.onPinRequest)}})})),g1(()=>({enabled:X&&x,bindings:[{key:"escape",cmd:()=>$.onMoveModeExit?.()}]})),g1(()=>({enabled:X,bindings:G5({"sidebar.view":(G0,s)=>{if(!U)return;let r=Xh(G,(s??0)%2===0?-1:1);if(r)W(r)}})})),g1(()=>({enabled:X&&L.active,bindings:G5({"sidebar.search.nav":(G0,s)=>{if((s??0)%2===0)m.moveDown();else m.moveUp()},"sidebar.search.submit":()=>{m.selectCurrent(),L.exit()},"sidebar.search.cancel":()=>L.exit()})})),g1(()=>({enabled:X&&Y0.open,bindings:G5({"sidebar.nav":(G0,s)=>Y0.moveCursor((s??0)%2===0?1:-1),"sidebar.select":()=>Y0.pickCurrent()})})),g1(()=>({enabled:X&&Y0.open,bindings:[{key:"escape",cmd:()=>Y0.close()}]}));function K0(G0){let s=E.current[C.current];if(s===void 0||!G0)return;if(s===Z_)return;G0(lQ(s).taskId)}g1(()=>({enabled:!0,bindings:G5({"tasks.jump":(G0,s)=>{let r=E.current[s??0];if(r===void 0)return;f(s??0),u.current(r)}})}));let M0=c4.useRef(null),H0=c4.useRef(null);if(H0.current===null)H0.current=new Map;let k=H0.current;c4.useEffect(()=>{let G0=M0.current;if(!G0||P<0||G0.viewport.height<=0)return;let s=k.get(P);if(s)G0.scrollChildIntoView(s.id)},[P,k]);let l=c4.useRef(null),d=$.width??RY;c4.useEffect(()=>{let G0=l.current;if(!G0)return;G0.width=d,G0.flexShrink=1,G0.minHeight=0},[d]);let n={cursorIndex:P,activeRowId:M.activeRowId,selectedTaskId:$.selectedId,rowEls:k,onPress:(G0,s)=>{Y0.close(),f(G0),v(s)},onContextMenu:Y0.openForRow,branchTick:K,engineState:$.engineState,engineTabState:$.engineTabState,engineLifecycle:$.engineLifecycle,taskJobs:$.taskJobs,worktreeChanges:$.worktreeChanges};return R.jsxDEV("box",{ref:l,flexGrow:1,minHeight:0,flexDirection:"column",backgroundColor:Z.backgroundPanel,paddingTop:1,paddingBottom:1,children:[R.jsxDEV(so,{focused:X,status:$.headerStatus??null,onStatusClick:$.onHeaderStatusClick},void 0,!1,void 0,this),R.jsxDEV(to,{onAddTask:$.onAddTask},void 0,!1,void 0,this),L.active?R.jsxDEV(ro,{query:L.query,matchCount:M.flatIds.length,totalCount:M.totalCount},void 0,!1,void 0,this):null,U?R.jsxDEV($a,{view:G,setView:W},void 0,!1,void 0,this):null,R.jsxDEV(eo,{nav:$.nav??"terminal",setNav:(G0)=>$.onNavChange?.(G0)},void 0,!1,void 0,this),R.jsxDEV(Ra,{rows:M.rows,flatIndexOf:V,view:G,searching:L.active&&L.query.trim().length>0,shared:n,onProjectContextMenu:Y0.openForProject,movingProjectId:x?e:null,setScrollRef:(G0)=>{M0.current=G0}},void 0,!1,void 0,this),$.zenActive?R.jsxDEV(Za,{onZenClick:$.onZenClick},void 0,!1,void 0,this):null,Y0.open?R.jsxDEV(io,{entries:Y0.entries,cursor:Y0.cursor,x:Y0.x,y:Y0.y,dims:{width:d,height:z.height},onPick:Y0.pick},void 0,!1,void 0,this):null,z.height<0?R.jsxDEV("text",{children:""},void 0,!1,void 0,this):null]},void 0,!0,void 0,this)}var c4;var oa=a(async()=>{L3();mF();gJ();MZ();M3();W2();wa();na();r0();await e1([u4(),xF(),$$(),C4(),oo(),QE(),Ta(),fa()]);c4=H1(q1(),1)});class LE{ptyIdentity=null;coordinate=null;update($,Z){if($!==this.ptyIdentity)this.ptyIdentity=$,this.coordinate=null;if($===null)return this.coordinate=null,null;if(Z)this.coordinate={x:Z.x,y:Z.y};return this.coordinate}current(){return this.coordinate}}var jE,VE;var aa=a(()=>{jE=class jE extends LE{};VE=class VE extends LE{}});import{RGBA as sq0}from"@opentui/core";function ra($){if(!$)return;return sq0.fromInts($[0],$[1],$[2])}function tq0($){return{__isChunk:!0,text:$.text,...$.fg?{fg:ra($.fg)}:{},...$.bg?{bg:ra($.bg)}:{},...$.attributes!==void 0?{attributes:$.attributes}:{}}}function sa($){let Z=[];for(let J=0;J<$.length;J++){if(J>0)Z.push({__isChunk:!0,text:`
732
732
  `});let X=$[J];if(!X)continue;for(let z of X)Z.push(tq0(z))}return Z}var ta=()=>{};function ea($){let Z=$.toLowerCase();return Z.includes("enoent")||Z.includes("not found")}function uF($,Z,J=$.attributes??0){return{text:Z,...$.fg?{fg:$.fg}:{},...$.bg?{bg:$.bg}:{},...J!==0?{attributes:J}:{}}}function eq0($){let Z=0;for(let J of $)Z+=fJ(J.codePointAt(0))||1;return Z}function $U0($,Z){let J=[],X=0,z=!1;for(let G of $){if(z){J.push(G);continue}let W=Array.from(G.text),H=X,U=-1;for(let K=0;K<W.length;K++){let N=fJ(W[K].codePointAt(0))||1;if(Z>=H&&Z<H+N){U=K;break}H+=N}if(U>=0){let K=W.slice(0,U).join(""),N=W.slice(U+1).join("");if(K)J.push(uF(G,K));if(J.push(uF(G,W[U]||" ",(G.attributes??0)|Y4.INVERSE)),N)J.push(uF(G,N));z=!0}else J.push(G),X+=eq0(W)}if(!z){if(Z>X)J.push({text:" ".repeat(Z-X)});J.push({text:" ",attributes:Y4.INVERSE})}return J}function $r($,Z){if(!Z)return $;return $.map((J,X)=>X===Z.y?$U0(J,Z.x):J)}function Zr($,Z,J,X){if(Z<=0)return $;let z=Z-1;return $.map((G)=>{let W=0;for(let H=0;H<G.length;H++){let U=G[H],K=Array.from(U.text);for(let N=0;N<K.length;N++){let L=K[N],M=fJ(L.codePointAt(0))||1;if(W+M<=z){W+=M;continue}let V=U.attributes??0;if(V===0)return G;let P=U.fg??J,_=U.bg??X,C=(V&Y4.INVERSE)!==0?{text:L,fg:_,bg:P}:{text:L,fg:P,bg:_},f=K.slice(0,N).join(""),E=K.slice(N+1).join(""),S=G.slice(0,H);if(f)S.push(uF(U,f));if(S.push(C),E)S.push(uF(U,E));return[...S,...G.slice(H+1)]}}return G})}var Jr=a(()=>{sH()});function Xr($){let{anchor:Z,head:J}=$;return J.row<Z.row||J.row===Z.row&&J.col<Z.col?{start:J,end:Z}:{start:Z,end:J}}function Qr($,Z,J){let{start:X,end:z}=Xr($);if(Z<X.row||Z>z.row)return null;let G=Z===X.row?X.col:0,W=Z===z.row?z.col+1:J;return G<W?[G,W]:null}function ZU0($){let Z="";for(let J of $)Z+=J.text;return Z}function zr($){let Z=0;for(let J of $)Z+=fJ(J.codePointAt(0));return Z}function Yr($,Z,J){let X="",z="",G="",W=0,H="before";for(let U of $){let K=fJ(U.codePointAt(0));if(K===0){if(H==="selected")z+=U;else if(H==="after")G+=U;else X+=U;continue}let N=W+K;if(N<=Z)X+=U,H="before";else if(W>=J)G+=U,H="after";else z+=U,H="selected";W=N}return{before:X,selected:z,after:G}}function Gr($,Z){let{start:J,end:X}=Xr(Z),z=[];for(let G=Math.max(0,J.row);G<=Math.min($.length-1,X.row);G++){let W=ZU0($[G]??[]),H=Qr(Z,G,Math.max(zr(W),1));z.push(H?Yr(W,H[0],H[1]).selected.trimEnd():"")}return z.join(`
733
733
  `)}function JU0($,Z,J){let X=[],z=0;for(let G of $){let W=z,H=W+zr(G.text);if(z=H,H<=Z||W>=J){X.push(G);continue}let{before:U,selected:K,after:N}=Yr(G.text,Z-W,J-W);if(U)X.push({...G,text:U});if(X.push({...G,text:K,attributes:(G.attributes??0)|Y4.INVERSE}),N)X.push({...G,text:N})}if(z<J)X.push({text:" ".repeat(J-Math.max(z,Z)),attributes:Y4.INVERSE});return X}function Wr($,Z,J,X){if(!Z)return $;return $.map((z,G)=>{let W=Qr(Z,J+G,X);return W?JU0(z,W[0],W[1]):z})}var _E=a(()=>{sH()});function CE($,Z,J){let X=Math.max(1,Z),z=Math.max(0,$-Math.max(0,J));return{start:Math.max(0,z-X),end:z}}function DE($,Z,J,X){let z=Math.max(0,$-Math.max(1,Z)),G=Math.min(z,Math.max(0,J.fallbackOffset));if(!J.anchor||!X||J.anchor.epoch!==X.epoch)return G;let W=J.anchor.topLine-X.startLine;if(W<=0)return z;return Math.min(z,Math.max(0,$-(W+Math.max(1,Z))))}function Hr($,Z,J,X,z){let G=DE(Z,J,$,z),W=Math.max(0,Z-Math.max(1,J)),H=Math.min(W,Math.max(0,G-X));if(H===0)return F_;let U=CE(Z,J,H),K=z?{epoch:z.epoch,topLine:z.startLine+U.start}:null;return{fallbackOffset:H,anchor:K}}function AE($,Z,J){if(!$||Z!==0)return null;if($.y<J.start||$.y>=J.end)return null;return{x:$.x,y:$.y-J.start}}var F_;var qr=a(()=>{F_={fallbackOffset:0,anchor:null}});import{decodePasteBytes as XU0}from"@opentui/core";function Ur($){let Z=$.pageSize??Hu,J=w1($),X=w1(Z),z=M_.useMemo(()=>{let W=[];W.push(...G5({"terminal.scroll-up":()=>J.current.scroll(-X.current),"terminal.scroll-down":()=>J.current.scroll(X.current),"terminal.reset":()=>J.current.reset()}));let H=(U)=>{let K=hT(U);if(K!=null)J.current.write(K)};for(let U of qu)W.push({key:U,cmd:H,passthrough:!0});return W},[]);g1(()=>({enabled:J.current.focused,bindings:z}));let G=E4();M_.useEffect(()=>{if(!G)return;let W=(U)=>{if(!J.current.focused||U.defaultPrevented||bY())return;let K=hT(U);if(K==null)return;J.current.write(K),U.preventDefault()},H=(U)=>{if(U.defaultPrevented||bY())return;let K=XU0(U.bytes);if(K.length===0)return;if(!J.current.focused&&(!J.current.unfocusedAttachmentTarget||!xq(K)))return;J.current.paste(K),U.preventDefault()};return G.keyInput.on("keypress",W),G.keyInput.on("paste",H),()=>{G.keyInput.off("keypress",W),G.keyInput.off("paste",H)}},[G])}var M_;var Br=a(async()=>{fq();uT();MZ();W2();await e1([u4(),C4()]);M_=H1(q1(),1)});function Kr(){let[$,Z]=eJ.useState(null),[J,X]=eJ.useState(4),[z,G]=eJ.useState(null),W=E5(),[H,U]=eJ.useState(0),K=eJ.useCallback(()=>{U((N)=>N+1&255)},[]);return eJ.useEffect(()=>{if(!$)return;if($.width<=0||$.height<=0)return;let N=Math.max(20,$.width),L=Math.max(4,$.height);X(L),G((M)=>M&&M.cols===N&&M.rows===L?M:{cols:N,rows:L})},[$,W,H]),{bodyEl:$,setBodyEl:Z,bodyRows:J,bodyGeometry:z,bumpGeomTick:K,dims:W,geomTick:H}}var eJ;var Fr=a(async()=>{await u4();eJ=H1(q1(),1)});function Mr($){let[Z,J]=Z8.useState(null),[X,z]=Z8.useState(null),[G,W]=Z8.useState([]),H=Z8.useRef(null),[U,K]=Z8.useState(null),[N,L]=Z8.useState(!1),M=w1($.command),V=w1($.initialInput),P=w1($.bodyGeometry),_=w1($.registry),C=w1($.onExit),f=w1($.onFreshPty),E=w1($.cwd),S=w1($.taskId),T=$.bodyGeometry!==null,x=$.cwd,b=$.taskId;Z8.useEffect(()=>{if(!x||!b||!T){J(null),W([]),H.current=null,K(null),z(null);return}let o=P.current;if(!o)return;let m;try{m=_.current.acquire(b,x,{...o,command:M.current,initialInput:V.current})}catch(e){let t=N1(e);z(t),J(null),W([]),H.current=null,K(null);return}z(null),W([]),H.current=null,K(null),L(m.killed),J(m),f.current()},[x,b,T]),Z8.useEffect(()=>{let o=Z?Z.killed:!1;if(L(o),!Z)return;if(o){C.current?.({deadOnAttach:Z.deadOnAttach===!0});return}let m=Z.onExit(()=>{L(!0),C.current?.({deadOnAttach:Z.deadOnAttach===!0})}),e=Z.onData((t,Y0,F0)=>{H.current=F0,W(t),K(Y0)});try{let t=Z.capture();if(H.current=Z.captureWindow(),t.length>0)W(t);K(Z.captureCursor())}catch{}return()=>{m(),e()}},[Z]);let v=Z8.useCallback((o,m,e,t)=>{try{let Y0={...e,command:M.current,initialInput:V.current},F0=t?_.current.resetIfCurrent(m,t,o,Y0):_.current.reset(m,o,Y0);if(!F0)return;J(F0),W([]),H.current=null,K(null),f.current()}catch(Y0){let F0=N1(Y0);z(F0),J(null),W([]),H.current=null,K(null)}},[]),u=Z8.useRef(!1);return Z8.useEffect(()=>{if($.resetToken,!u.current){u.current=!0;return}let o=E.current,m=S.current,e=P.current;if(o&&m&&e)v(o,m,e)},[$.resetToken,v]),{pty:Z,snapshot:G,snapshotWindow:H.current,cursor:U,exited:N,acquireError:X,forceReacquire:v}}var Z8;var Nr=a(()=>{W2();Z8=H1(q1(),1)});import{spawnSync as QU0}from"child_process";function Or($,Z){if($==="darwin")return"pbcopy";if($==="linux"){for(let J of zU0)if(Z(J.binary))return J.command}return null}var zU0,Lr=($)=>{try{let Z=process.platform==="win32"?"where":"which";return QU0(Z,[$],{encoding:"utf8"}).status===0}catch{return!1}};var jr=a(()=>{zU0=[{binary:"wl-copy",command:"wl-copy"},{binary:"xclip",command:"xclip -selection clipboard -in"},{binary:"xsel",command:"xsel --clipboard --input"}]});function YU0(){if(PE===void 0)PE=Or(process.platform,Lr);return PE}function Vr($,Z){let J=YU0();if(J)try{let X=Bun.spawn(["sh","-c",J],{stdin:"pipe",stdout:"ignore",stderr:"ignore"});X.stdin.write($),X.stdin.end()}catch{}try{Z($)}catch{}}var PE;var _r=a(()=>{jr()});function Cr($){let[Z,J]=$G.useState(null),[X,z]=$G.useState(null),G=$G.useRef(!1),W=E4(),H=$G.useMemo(()=>{if(!Z||!X)return null;if(Z.row===X.row&&Z.col===X.col)return null;return{anchor:Z,head:X}},[Z,X]);return{selection:H,cellFromEvent:(M)=>{let{bodyEl:V,bodyGeometry:P,bodyRows:_,visibleRangeStart:C}=$;if(!V||!P)return null;let f=Math.min(P.cols-1,Math.max(0,(M.x??0)-V.screenX)),E=Math.min(_-1,Math.max(0,(M.y??0)-V.screenY));return{row:C+E,col:f}},beginSelection:(M)=>{G.current=!0,J(M),z(M)},updateSelectionHead:(M)=>{if(!G.current)return;z(M)},isDragging:()=>G.current,endDragging:()=>{G.current=!1},clearSelection:()=>{J(null),z(null)},copySelection:()=>{if(!H)return;let M=Gr($.snapshot,H);if(M.trim().length>0)Vr(M,(V)=>W?.copyToClipboardOSC52(V))}}}var $G;var Dr=a(async()=>{_r();_E();await u4();$G=H1(q1(),1)});import{StyledText as GU0}from"@opentui/core";function RE($){let{theme:Z}=l0(),J=Z1(),X=$.registry??X4(),[z,G]=_5.useState(!1),W=$.focused??z,[H,U]=_5.useState(F_),{bodyEl:K,setBodyEl:N,bodyRows:L,bodyGeometry:M,bumpGeomTick:V,dims:P,geomTick:_}=Kr(),{pty:C,snapshot:f,snapshotWindow:E,cursor:S,exited:T,acquireError:x,forceReacquire:b}=Mr({cwd:$.cwd,taskId:$.taskId,command:$.command,initialInput:$.initialInput,resetToken:$.resetToken,onExit:$.onExit,registry:X,bodyGeometry:M,onFreshPty:()=>U(F_)}),v=DE(f.length,L,H,E),u=(u0)=>{U((L0)=>Hr(L0,f.length,L,u0,E))},o=_5.useMemo(()=>CE(f.length,L,v),[f.length,L,v]),m=_5.useMemo(()=>f.slice(o.start,o.end),[f,o]),e=_5.useMemo(()=>AE(S,v,o),[S,v,o]),[t]=_5.useState(()=>new jE),Y0=t.update(C,S),F0=_5.useMemo(()=>AE(Y0,v,o),[Y0,v,o]),K0=Cr({bodyEl:K,bodyGeometry:M,bodyRows:L,visibleRangeStart:o.start,snapshot:f}),M0=_5.useMemo(()=>{let u0=Wr(m,K0.selection,o.start,M?.cols??80),L0=W&&!K0.selection?e:null;return $r(u0,L0)},[m,K0.selection,o.start,M,W,e]),H0=_5.useMemo(()=>{let u0=Z.text.toInts(),L0=Z.background.toInts(),d0=Zr(M0,M?.cols??80,[u0[0],u0[1],u0[2]],[L0[0],L0[1],L0[2]]);return new GU0(sa(d0))},[M0,M,Z]),[k,l]=_5.useState(null);_5.useEffect(()=>{if(k&&!k.isDestroyed)k.content=H0},[k,H0]);let d=n$(),n=($.imeAnchorActive??!0)&&d.stack.length===0,G0=$.imeAnchorActive===!0&&d.stack.length===0,s=w1($.taskId),r=w1($.cwd),J0=_5.useRef(!0);_5.useLayoutEffect(()=>{return J0.current=!0,()=>{J0.current=!1}},[]),Ur({focused:W,unfocusedAttachmentTarget:G0,write:(u0)=>{if(!C||C.killed)return;C.write(u0),$.onUserInput?.(u0)},paste:(u0)=>{if(!C||C.killed)return;C.paste(u0)},scroll:u,reset:()=>{if(!C)return;let u0=C,L0=$.cwd,d0=$.taskId,G1=M;if(!L0||!d0||!G1)return;N4.show(d,J("terminal.reset.title"),J("terminal.reset.body"),"cancel").then((D1)=>{if(D1!==!0||!J0.current)return;if(s.current!==d0||r.current!==L0)return;b(L0,d0,G1,u0)})}});let Q0=E4(),w0=_5.useRef(Symbol("terminal-ime-anchor")).current,[v0]=_5.useState(()=>new VE),P0=_5.useRef(null);return _5.useEffect(()=>{if(!C||!M)return;let{cols:u0,rows:L0}=M,d0=P0.current;if(d0?.pty===C&&d0.cols===u0&&d0.rows===L0)return;P0.current={pty:C,cols:u0,rows:L0};try{C.resize(u0,L0)}catch{}},[C,M]),_5.useEffect(()=>{if(!Q0)return;if(!n){if(v0.update(null,null),Kq.release(w0))Q0.setCursorPosition(0,0,!1);return}let u0=null;if(K&&F0&&K.width>0)u0={x:K.screenX+F0.x,y:K.screenY+F0.y};let L0=v0.update(C,u0);if(L0){Kq.claim(w0,L0),Q0.setCursorPosition(L0.x,L0.y,!1);return}Kq.claim(w0,{x:0,y:0}),Q0.setCursorPosition(0,0,!1)},[Q0,n,K,F0,P,_,w0,v0,C]),_5.useEffect(()=>{return()=>{try{if(Kq.release(w0))Q0?.setCursorPosition(0,0,!1)}catch{}}},[Q0,w0]),R.jsxDEV("box",{flexDirection:"column",flexGrow:1,overflow:"hidden",backgroundColor:Z.background,onMouseDown:(u0)=>{if(u0.button!==0)return;if(!W)$.onRequestFocus?.();let L0=K0.cellFromEvent(u0);if(!L0)return;K0.beginSelection(L0)},onMouseDrag:(u0)=>{let L0=K0.cellFromEvent(u0);if(L0)K0.updateSelectionHead(L0)},onMouseUp:()=>{if(G(!0),!K0.isDragging())return;if(K0.endDragging(),K0.selection)K0.copySelection();else K0.clearSelection()},onMouseScroll:(u0)=>{let L0=u0.scroll;if(!L0||L0.direction!=="up"&&L0.direction!=="down")return;if(C&&!C.killed&&K){let G1=Math.max(1,u0.x-K.screenX+1),D1=Math.max(1,u0.y-K.screenY+1);if(C.wheel(L0.direction,G1,D1))return}let d0=Math.max(1,L0.delta||1);u(L0.direction==="up"?-d0:d0)},children:[T?R.jsxDEV("box",{flexDirection:"row",flexShrink:0,paddingLeft:1,paddingRight:1,children:R.jsxDEV("text",{fg:Z.error,wrapMode:"none",children:J("terminal.exited")},void 0,!1,void 0,this)},void 0,!1,void 0,this):null,v>0?R.jsxDEV("box",{position:"absolute",zIndex:10,left:0,right:0,bottom:0,flexDirection:"row",paddingLeft:1,paddingRight:1,backgroundColor:Z.backgroundPanel,children:R.jsxDEV("text",{fg:Z.warning,wrapMode:"none",children:J("terminal.scrolledBack",{lines:v})},void 0,!1,void 0,this)},void 0,!1,void 0,this):null,R.jsxDEV("box",{ref:(u0)=>N(u0),onSizeChange:V,flexGrow:1,overflow:"hidden",children:C?R.jsxDEV("text",{fg:Z.text,wrapMode:"none",ref:(u0)=>l(u0)},void 0,!1,void 0,this):R.jsxDEV("box",{paddingLeft:1,paddingTop:1,flexDirection:"column",gap:0,children:x?R.jsxDEV(R.Fragment,{children:[R.jsxDEV("text",{fg:Z.error,wrapMode:"word",children:ea(x)?J("terminal.unavailable.shellMissing"):J("terminal.unavailable.spawnFailed")},void 0,!1,void 0,this),R.jsxDEV("text",{fg:Z.textMuted,wrapMode:"word",children:x},void 0,!1,void 0,this)]},void 0,!0,void 0,this):R.jsxDEV("text",{fg:Z.textMuted,children:J("terminal.noTask")},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var _5;var Ar=a(async()=>{GI();aa();x8();ta();Jr();_E();qr();Q$();W2();Nr();r0();await e1([u4(),$$(),V5(),FZ(),Br(),Fr(),Dr()]);_5=H1(q1(),1)});function TE($=X4().get.bind(X4())){let Z=new Map,J=new Set,X=()=>{for(let z of J)z()};return{reconcile(z){let G=new Set(z),W=!1;for(let[H,U]of Z){if((G.has(H)?$(H):null)===U.pty)continue;U.unsub(),Z.delete(H),W=!0}for(let H of G){if(Z.has(H))continue;let U=$(H);if(!U)continue;let K={pty:U,unsub:()=>{},title:void 0};K.unsub=U.onTitleChange((N)=>{if(K.title===N)return;K.title=N,X()}),Z.set(H,K),W=!0}return W},get(z){return Z.get(z)?.title},subscribe(z){return J.add(z),()=>{J.delete(z)}},dispose(){for(let z of Z.values())z.unsub();Z.clear(),J.clear()}}}function Pr($){let Z=K9.useRef(null);if(Z.current===null)Z.current=TE();let J=Z.current,[X,z]=K9.useState(new Map),G=w1($),W=K9.useCallback(()=>{let H=G.current;J.reconcile(H.values());let U=eY();z((K)=>{let N=new Map;for(let[L,M]of H){let V=J.get(M);if(V===void 0)continue;N.set(L,kH(V,U.resolve(M)))}if(N.size===K.size&&[...N].every(([L,M])=>K.get(L)===M))return K;return N})},[J]);return K9.useEffect(()=>{let H=setInterval(W,WU0);return()=>clearInterval(H)},[W]),K9.useEffect(()=>{W()},[$,W]),K9.useEffect(()=>{let H=!0,U=!1,K=J.subscribe(()=>{if(U)return;U=!0,queueMicrotask(()=>{if(U=!1,H)W()})});return()=>{H=!1,K()}},[J,W]),K9.useEffect(()=>()=>J.dispose(),[J]),X}var K9,WU0=2000;var SE=a(()=>{C7();x8();U_();W2();K9=H1(q1(),1)});import{TextAttributes as Rr}from"@opentui/core";function ZG($,Z){if(!Z)return;for(let J of r7(Z.root))if(J.id!=="leaf-1")X4().release(N3($,J.id))}function Sr($){let{theme:Z,transparentBackground:J}=l0(),X=J?Z.border:Z.borderSubtle,z=Z1(),G=I2(),W=$.splitTree??Tr,[H,U]=mq.useState(W.activeLeafId);mq.useEffect(()=>{U(($.splitTree??Tr).activeLeafId)},[$.splitTree]);let K=()=>({...W,activeLeafId:H}),N=(o)=>{if(o===W)return;$.onSplitChange(Mq(o))},L=RF(W),M=bj(G.get(GF))==="box"&&L,V=Mq(W)!==null;function P(o){let m=K(),e=AV(m,o);if(e===null)return!1;if(e!==m)N(e),X4().release(N3($.tabKey,o));return!0}function _(o){if(P(o))return;ZG($.tabKey,W),$.onSplitChange(null),$.onExit?.()}let C=()=>X4().get(N3($.tabKey,H))?.size??null;g1(()=>({enabled:$.focused,bindings:G5({"workspace.split.right":()=>N(AF(K(),"row",[u5()],C())),"workspace.split.down":()=>N(AF(K(),"column",[u5()],C())),"workspace.split.focus-next":()=>U(ep(K(),1).activeLeafId)})}));let f=n$();g1(()=>({enabled:$.focused&&L,bindings:G5({"workspace.split.close":()=>P(H),"workspace.split.rename":()=>{let o=H;p5.show(f,x.get(o)??"",{dialogTitle:z("terminal.split.renameTitle"),fieldLabel:z("terminal.split.renameField"),submitLabel:z("terminal.tab.renameSubmit"),allowEmpty:!0}).then((m)=>{if(m===void 0)return;N(PV(K(),o,m))})}})}));let E=(o)=>$.focused&&H===o,S=mq.useMemo(()=>{let o=new Map;for(let m of r7(W.root))o.set(m.id,N3($.tabKey,m.id));return o},[$.tabKey,W]),T=Pr(S),x=HI(r7(W.root),$.command,$.engineTitle,T),b=(o,m)=>o?{border:[o],borderColor:m}:{border:!1},v=(o,m)=>{let e=()=>U(o.id),t=H===o.id,Y0=E(o.id),F0=R.jsxDEV(R.Fragment,{children:[R.jsxDEV(RE,{cwd:$.cwd,taskId:N3($.tabKey,o.id),command:o.content??$.command,initialInput:o.content===null?$.initialInput:void 0,onUserInput:o.content===null?$.onUserInput:void 0,onExit:()=>_(o.id),resetToken:o.id==="leaf-1"?$.resetToken:void 0,focused:Y0,imeAnchorActive:t,onRequestFocus:()=>{$.onRequestFocus?.(),e()}},void 0,!1,void 0,this),L?R.jsxDEV("box",{position:"absolute",right:0,top:0,zIndex:10,backgroundColor:Z.backgroundElement,children:R.jsxDEV("text",{fg:Y0?Z.focusAccent:Z.textMuted,attributes:Y0?Rr.BOLD:Rr.DIM,wrapMode:"none",children:` ${x.get(o.id)??""} `},void 0,!1,void 0,this)},void 0,!1,void 0,this):null]},void 0,!0,void 0,this);if(M)return R.jsxDEV("box",{flexGrow:1,flexShrink:1,flexBasis:0,border:!0,borderColor:Y0?Z.focusAccent:X,onMouseUp:e,children:F0},o.id,!1,void 0,this);return m?R.jsxDEV("box",{flexGrow:1,flexShrink:1,flexBasis:0,border:[m],borderColor:Y0?Z.focusAccent:X,onMouseUp:e,children:F0},o.id,!1,void 0,this):R.jsxDEV("box",{flexGrow:1,flexShrink:1,flexBasis:0,border:!1,onMouseUp:e,children:F0},o.id,!1,void 0,this)},u=(o,m,e)=>o.kind==="leaf"?v(o,e):R.jsxDEV("box",{flexDirection:o.orientation,flexGrow:1,flexShrink:1,flexBasis:0,...b(M?void 0:e,X),children:o.children.map((t,Y0)=>u(t,t.kind==="leaf"?t.id:`${m}.${Y0}`,Y0>0?o.orientation==="row"?"left":"top":void 0))},m,!1,void 0,this);if(V)return R.jsxDEV("box",{flexDirection:"column",flexGrow:1,overflow:"hidden",children:u(W.root,"root")},void 0,!1,void 0,this);return R.jsxDEV(RE,{cwd:$.cwd,taskId:$.tabKey,command:$.command,initialInput:$.initialInput,onUserInput:$.onUserInput,onExit:$.onExit,resetToken:$.resetToken,focused:$.focused,imeAnchorActive:!0,onRequestFocus:$.onRequestFocus},void 0,!1,void 0,this)}var mq,Tr;var cF=a(async()=>{WF();r3();x8();U7();MZ();M3();Q$();SE();r0();await e1([cJ(),$$(),C4(),Ar(),V5()]);mq=H1(q1(),1),Tr=DV(null)});function N_($,Z,J){let X=Z?b8($,Z):e2($,J);if(ZG(X,Z?.splitTree??null),Z?.kind==="engine"&&Z.ptyTask)return;W_(X);let z=X4(),G=z.get(X);if(z.release(X),!G)HU0(X)}function HU0($){let Z=Rh();if(!Z)return;Z.then((J)=>J.request("pty.kill",{key:$})).catch(()=>{})}function qU0($,Z){let J=$8.get(Z);if(J)return J;let X=$.store[P7(Z)];return X&&Array.isArray(X.tabs)?X:null}function Ir($,Z,J){if(En(Z,J),!xn())return!0;let z=qU0($,Z);if(!z)return!1;let G=z.tabs.find((U)=>U.id===J),{state:W,closedId:H}=Vq(z,J);if(!H)return!1;return $8.set(Z,W),$.set(P7(Z),W),N_(Z,G,H),!0}var IE=a(async()=>{$F();x8();H_();U7();O3();await cF()});function wr($){let{theme:Z}=l0(),J=I2(),X=hQ(),z=Z1(),G=Er.useCallback((H,U)=>{if(!Ir(J,H,U))X.notify({kind:"error",taskId:H,tabId:U,title:z("terminal.tab.cannotCloseLast")})},[J,X,z]),W={width:$.width,nav:$.nav,onNavChange:$.onNavChange,tasks:$.tasks,selectedId:$.selectedId,onSelect:$.onSelect,onActivate:$.onActivate,engineState:$.engineState,engineTabState:$.engineTabState,engineLifecycle:$.engineLifecycle,taskJobs:$.taskJobs,worktreeChanges:$.worktreeChanges,transcriptActivity:$.transcriptActivity,focused:$.focused,onDeleteRequest:$.onDeleteRequest,onArchiveRequest:$.onArchiveRequest,onRenameRequest:$.onRenameRequest,onPinRequest:$.onPinRequest,onLocalMergeRequest:$.onLocalMergeRequest,moveMode:$.moveMode,onMoveRequest:$.onMoveRequest,onMoveModeExit:$.onMoveModeExit,onSearchActiveChange:$.onSearchActiveChange,onAddTask:$.onAddTask,headerStatus:$.headerStatus,onHeaderStatusClick:$.onHeaderStatusClick,zenActive:$.zenActive,onZenClick:$.onZenClick};return R.jsxDEV("box",{width:$.width,flexShrink:0,flexDirection:"column",backgroundColor:Z.backgroundPanel,onMouseUp:$.onFocusRequest,children:[R.jsxDEV(ia,{...W,selectedTabId:$.selectedTabId,onSelectTab:$.onSelectTab,onCloseTab:G,recentTask:$.recentTask??null},void 0,!1,void 0,this),R.jsxDEV("box",{flexShrink:0,paddingLeft:1,paddingBottom:0,children:R.jsxDEV(dV,{pane:"sidebar"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var Er;var xr=a(async()=>{M3();Uq();Q$();r0();await e1([xF(),$$(),oa(),IE()]);Er=H1(q1(),1)});import{basename as UU0}from"path";async function fr($){let Z=new m5($);try{await Z.connect()}catch(J){throw Z.close(),J}return{rpc:Z,close:()=>Z.close()}}async function JG(){try{return await fr(p2())}catch{return null}}async function dF(){return fr(await Kj())}async function XG($){try{let{sessions:Z}=await $.request("pty.list",{});return Z??[]}catch{return[]}}function O_($,Z){return($.split("::")[0]??$)===Z}function hq($,Z){return $.filter((J)=>O_(J.key,Z)).map((J)=>J.key)}async function uq($,Z){for(let J of Z)await $.request("pty.kill",{key:J}).catch(()=>{})}function BU0($,Z){for(let J of $)for(let X of J.split(/\s+/)){let z=X.replace(/^['"]+|['"]+$/g,"");if(z&&UU0(z)===Z)return!0}return!1}function L_($,Z,J){let X=$.filter((G)=>G.alive&&O_(G.key,Z)),z=X.find((G)=>G.key===`${Z}::tab-1`);if(z)return z.key;if(J){let G=X.find((W)=>BU0(W.command,J));if(G)return G.key}return null}async function j_($,Z,J){await $.request("pty.write",{key:Z,data:`\x1B[200~${J}\x1B[201~`}),await new Promise((X)=>setTimeout(X,KU0)),await $.request("pty.write",{key:Z,data:"\r"})}async function V_($,Z,J){if(!(await $.request("pty.peek",{key:Z})).alive)return!1;return await j_($,Z,J),!0}async function EE($,Z,J){let X=await $.request("pty.open",{key:J.key,cwd:Z,command:J.command});return await $.request("pty.detach",{key:J.key}).catch(()=>{}),X}async function lF($,Z,J,X,z={}){let G=z.sleep??((U)=>new Promise((K)=>setTimeout(K,U))),W=z.snapshot??jZ,H=Date.now()+(z.timeoutMs??FU0);while(Date.now()<H){let{sessions:U=[]}=await $.request("pty.list",{}),K=U.find((N)=>N.key===Z);if(!K?.alive)return!1;if(K.pid){let N=!1;try{N=q_(LZ(await W()),K.pid,J)}catch{N=!1}if(N)return await G(z.settleMs??NU0),await j_($,Z,X),!0}await G(z.intervalMs??MU0)}return!1}var KU0=150,FU0=20000,MU0=500,NU0=1500;var __=a(()=>{a6();sK();c7();vq()});function gr($,Z){return $.find((J)=>J.id!==Z&&!J.archived)}async function yr($,Z,J){let X=await JG();if(!X)return;try{await uq(X.rpc,hq(await XG(X.rpc),$))}catch(z){Z.error(`${J} kill hosted session failed:`,z)}finally{X.close()}}function br($,Z){let J=$.activeTaskSignal;if(typeof J!=="function")return!0;return J.call($)()===Z}async function OU0($){let Z=$.tasks.find((z)=>z.id===$.taskId);if(!Z)return null;let J=!Z.archived;try{await $.orch.setArchived($.taskId,J)}catch(z){return $.logger.error(`${$.logPrefix} archive failed:`,z),null}if(!J)return{archived:J};let X=gr($.tasks,$.taskId);if($.updateActiveTask&&br($.orch,$.taskId))await $.orch.setActiveTask(X?.id??null).catch(()=>{});return await yr($.taskId,$.logger,$.logPrefix),{archived:J,nextTask:X}}async function LU0($){let Z=gr($.tasks,$.taskId);if($.updateActiveTask&&$.orch&&br($.orch,$.taskId))await $.orch.setActiveTask(Z?.id??null).catch(()=>{});return await yr($.taskId,$.logger,$.logPrefix),{nextTask:Z}}async function kr($,Z){if(!$.orch)return;let J=$.tasks().find((z)=>z.id===Z);if(!J)return;if(!J.archived){if(!await $.confirm({title:`Archive "${J.title}"?`,body:"Moves it to Archives and stops its running session. The worktree, branch, and chat history stay \u2014 unarchive to bring it back.",cancelLabel:"cancel",confirmLabel:"archive"}))return}if(!await OU0({orch:$.orch,tasks:$.tasks(),taskId:Z,logger:$.logger,logPrefix:$.logPrefix,updateActiveTask:$.updateActiveTask}))return;await $.reload?.()}async function vr($,Z){if(!$.orch)return;let J=$.tasks().find((W)=>W.id===Z);if(!J)return;if(J.kind==="main"){if(!await $.confirm({title:`Remove project "${J.title}"?`,body:"Forgets it from the projects list. The repo, its branches, worktrees, and any tasks under it stay on disk \u2014 re-add it with `rove add`.",cancelLabel:"cancel",confirmLabel:"remove"}))return;try{await $.orch.forgetProject(J.repo)}catch(H){$.logger.error(`${$.logPrefix} forget project failed:`,H),$.notifyError?.(`Couldn't remove: ${N1(H)}`);return}await $.reload?.();return}if(!await $.confirm({title:`Delete "${J.title}"?`,body:J.kind==="dir"?"Removes the task entry. The directory itself stays on disk. Its hosted sessions are stopped.":"Removes the task entry and its worktree. Its hosted sessions are stopped.",cancelLabel:"cancel",confirmLabel:"delete"}))return;let z=!1;try{await $.orch.deleteTask(Z),z=!0}catch(W){if(N1(W).includes(LP)){if(await $.confirm({title:`"${J.title}" has uncommitted changes`,body:"Its worktree has uncommitted or untracked work that will be permanently deleted. Force delete anyway?",cancelLabel:"cancel",confirmLabel:"force delete"}))try{await $.orch.deleteTask(Z,{force:!0}),z=!0}catch(K){$.logger.error(`${$.logPrefix} force delete failed:`,K),$.notifyError?.(`Couldn't delete: ${N1(K)}`)}}else $.logger.error(`${$.logPrefix} delete failed:`,W),$.notifyError?.(`Couldn't delete: ${N1(W)}`)}if(!z)return;let{nextTask:G}=await LU0({orch:$.orch,tasks:$.tasks(),taskId:Z,logger:$.logger,logPrefix:$.logPrefix,updateActiveTask:$.updateActiveTask});await $.reload?.(),$.onTaskDeleted?.(Z,G)}async function mr($,Z){let J=$.tasks().find((z)=>z.id===Z);if(!J)return;let X=await $.promptText(J.title);if(!X||!$.orch)return;try{await $.orch.setTitle(Z,X)}catch(z){$.logger.error(`${$.logPrefix} task.rename failed:`,z),$.notifyError?.(`Couldn't rename task: ${N1(z)}`);return}await $.reload?.()}async function hr($,Z){let J=$.tasks().find((G)=>G.id===Z);if(!J||!$.orch)return;let X=await GZ(),z=qH(X,J.vendor??M4);try{await $.orch.setVendor(Z,z)}catch(G){$.logger.error(`${$.logPrefix} task.setVendor failed:`,G),$.notifyError?.(`Couldn't switch engine: ${N1(G)}`);return}$.notifyInfo?.(`Engine \u2192 ${Z7(z)} (applies on reopen)`),await $.reload?.()}var ur=a(()=>{SJ();__();d5();NQ();d7();u7()});async function cr($){let Z=t9(),J=$.cursorRepo()??Z[0]??process.cwd(),X=$.lastVendor(J)??M4,z=await GZ();if(z.length===0)$.notifyInfo?.("No engine CLI detected \u2014 install claude or codex, or add one in Settings \u2192 Engines");let G=$.orch,W=await $.promptNewTask(J,Z,{defaultVendor:X,availableVendors:z,discoverAdoptable:G?(U)=>G.discoverAdoptableWorktrees(U):void 0});if(!W)return;if($.rememberVendor(W.repo,W.vendor),UY(W.repo),$.onRepoSaved?.(),!G){$.logger.error(`${$.logPrefix} no daemon; cannot create task`);return}$.notifyInfo?.("Creating task\u2026");let H;if(W.mode==="adopt"){let U=W.adopt.length,K=0,N;for(let L of W.adopt)try{H=(await G.adoptWorktree({repo:W.repo,worktreePath:L.worktreePath,branch:L.branch,vendor:W.vendor})).id,K++}catch(M){if(N===void 0)N=N1(M);$.logger.error(`${$.logPrefix} adoptWorktree failed for ${L.worktreePath}:`,M)}if(K===0){$.notifyError?.(S$("newTask.adopt.summaryNone",{error:N??""}));return}if(K<U)$.notifyInfo?.(S$("newTask.adopt.summaryPartial",{done:K,total:U}));else $.notifyInfo?.(S$("newTask.adopt.summaryAll",{count:K}))}else try{H=(await G.createTask({repo:W.repo,baseRef:W.baseRef,vendor:W.vendor})).id}catch(U){$.logger.error(`${$.logPrefix} task.create failed:`,U),$.notifyError?.(`Couldn't create task: ${N1(U)}`);return}if(await $.reload?.(),H)$.selectTask?.(H),await $.enterTask?.(H)}var dr=a(()=>{SJ();b4();gY();d7()});import{TextAttributes as jU0}from"@opentui/core";function VU0($){let Z=n$(),{theme:J}=l0(),X=Z1(),z=H7(),[G,W]=cq.useState($.currentBranch),[H,U]=cq.useState(0),K=cq.useMemo(()=>tj($.repo),[$.repo]),N=cq.useMemo(()=>ej(K,G),[K,G]),L=G9(N,H);function M(_){if(N.length===0)return;U((C)=>w4(C+_,N.length))}function V(_){let C=_.trim();if(!C)return;$.onSubmit(C),Z.clear()}let P=L.items.map((_,C)=>({key:`${L.start+C}:${_}`,body:_,accent:G.trim()===_}));return g1(()=>({bindings:[{key:"up",cmd:()=>M(-1)},{key:"down",cmd:()=>M(1)}]})),R.jsxDEV("box",{paddingLeft:z,paddingRight:z,gap:1,children:[R.jsxDEV("box",{flexDirection:"row",justifyContent:"space-between",children:[R.jsxDEV("text",{attributes:jU0.BOLD,fg:J.text,children:X("tasks.reBranch.title")},void 0,!1,void 0,this),R.jsxDEV("text",{fg:J.textMuted,onMouseUp:()=>$.onCancel(),children:"esc"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),R.jsxDEV("box",{gap:0,children:[R.jsxDEV("text",{fg:J.accent,children:X("tasks.reBranch.fieldLabel")},void 0,!1,void 0,this),R.jsxDEV("input",{value:G,placeholder:$.currentBranch,focused:!0,onInput:(_)=>{W(l5(_)),U(0)},onSubmit:()=>V($V(G,N,H))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),N.length===0?R.jsxDEV("box",{gap:0,paddingBottom:1,children:R.jsxDEV("text",{fg:J.textMuted,wrapMode:"none",children:K.length===0?X("tasks.reBranch.hintNoBranches"):X("tasks.reBranch.hintNoMatch")},void 0,!1,void 0,this)},void 0,!1,void 0,this):R.jsxDEV(B9,{window:L,cursor:H,rows:P,onPick:(_)=>V(N[_]??G),paddingBottom:1},void 0,!1,void 0,this),R.jsxDEV("box",{paddingBottom:1,children:R.jsxDEV("text",{fg:J.textMuted,children:X("tasks.reBranch.footer")},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function _U0($,Z){return S2($,(J)=>R.jsxDEV(VU0,{currentBranch:Z.currentBranch,repo:Z.repo,onSubmit:(X)=>J(X),onCancel:()=>J(void 0)},void 0,!1,void 0,this))}var cq,lr;var pr=a(async()=>{g8();kQ();Q$();r0();await e1([$$(),C4(),V5(),aJ()]);cq=H1(q1(),1);lr={show:_U0}});function nr({vm:$}){let{theme:Z}=l0(),J=Z1(),X=$.adoptVisible.map((z)=>{let G=[z.dirty?"dirty":"",z.kobeManaged?"":"external"].filter(Boolean).join(",");return{key:z.path,body:`${$.adoptSelected.has(z.path)?"[x] ":"[ ] "}${z.branch}${G?` (${G})`:""}`,accent:$.adoptSelected.has(z.path)}});return R.jsxDEV(R.Fragment,{children:[R.jsxDEV("box",{gap:0,children:[R.jsxDEV("text",{...Z6(Z,$.field,"adoptFilter"),children:J("newTask.field.adoptFilter")},void 0,!1,void 0,this),R.jsxDEV("input",{value:$.adoptFilter,placeholder:J("newTask.placeholder.adoptFilter"),focused:$.field==="adoptFilter",onMouseUp:()=>$.setField("adoptFilter"),onInput:(z)=>$.setAdoptFilterText(z),onSubmit:()=>$.toggleAdoptCursor()},void 0,!1,void 0,this)]},void 0,!0,void 0,this),R.jsxDEV("box",{paddingLeft:2,children:R.jsxDEV("text",{fg:Z.textMuted,wrapMode:"none",children:J("newTask.adopt.repoLine",{path:$.expandedRepo||J("newTask.adopt.repoNone")})},void 0,!1,void 0,this)},void 0,!1,void 0,this),$.adoptLoading?R.jsxDEV("box",{paddingLeft:2,children:R.jsxDEV("text",{fg:Z.textMuted,wrapMode:"none",children:J("newTask.hint.scanningWorktrees")},void 0,!1,void 0,this)},void 0,!1,void 0,this):null,!$.adoptLoading&&$.adoptList.length===0?R.jsxDEV("box",{paddingLeft:2,children:R.jsxDEV("text",{fg:Z.textMuted,wrapMode:"none",children:$.adoptDiscoveredCount===0?J("newTask.adopt.noUnlinked"):J("newTask.adopt.noMatch")},void 0,!1,void 0,this)},void 0,!1,void 0,this):null,$.adoptList.length>0?R.jsxDEV(B9,{window:$.adoptWindow,cursor:$.adoptCursor,rows:X,onPick:$.pickAdoptAt,footer:R.jsxDEV("text",{fg:Z.textMuted,wrapMode:"none",children:$.adoptSelected.size>0?J("newTask.adopt.hintSelected",{count:$.adoptSelected.size}):J("newTask.adopt.hintDefault")},void 0,!1,void 0,this)},void 0,!1,void 0,this):null]},void 0,!0,void 0,this)}var ir=a(async()=>{Q$();r0();await e1([$$(),aJ()])});function or({vm:$}){let{theme:Z}=l0(),J=Z1(),X=$.cloneParentWindow.items.map((z,G)=>({key:`${$.cloneParentWindow.start+G}:${z}`,body:`${z}/`}));return R.jsxDEV(R.Fragment,{children:[R.jsxDEV("box",{gap:0,children:[R.jsxDEV("text",{...Z6(Z,$.field,"cloneUrl"),children:J("newTask.field.gitUrl")},void 0,!1,void 0,this),R.jsxDEV("input",{value:$.cloneUrl,placeholder:"https://github.com/user/repo.git",focused:$.field==="cloneUrl",onMouseUp:()=>$.setField("cloneUrl"),onInput:(z)=>$.setCloneUrlText(z),onSubmit:()=>{if(!$.cloneUrl.trim())return;$.setField("cloneParent")}},void 0,!1,void 0,this)]},void 0,!0,void 0,this),R.jsxDEV("box",{gap:0,children:[R.jsxDEV("text",{...Z6(Z,$.field,"cloneParent"),children:J("newTask.field.parentDir")},void 0,!1,void 0,this),R.jsxDEV("input",{value:$.cloneParent,placeholder:"~/",focused:$.field==="cloneParent",onMouseUp:()=>$.setField("cloneParent"),onInput:(z)=>$.setCloneParentText(z),onSubmit:()=>$.onCloneParentSubmit()},void 0,!1,void 0,this)]},void 0,!0,void 0,this),$.field==="cloneParent"?R.jsxDEV("box",{paddingLeft:2,children:R.jsxDEV("text",{fg:Z.textMuted,wrapMode:"none",children:J("newTask.hint.remembered")},void 0,!1,void 0,this)},void 0,!1,void 0,this):null,$.field==="cloneParent"&&$.cloneParentFiltered.length>0&&!$.cloneParentPicked?R.jsxDEV(B9,{window:$.cloneParentWindow,cursor:$.cloneParentCursor,rows:X,onPick:$.selectCloneParentAt},void 0,!1,void 0,this):null,R.jsxDEV("box",{gap:0,children:[R.jsxDEV("text",{...Z6(Z,$.field,"cloneFolder"),children:J("newTask.field.folderName")},void 0,!1,void 0,this),R.jsxDEV("input",{value:$.cloneFolder,placeholder:J("newTask.placeholder.folderName"),focused:$.field==="cloneFolder",onMouseUp:()=>$.setField("cloneFolder"),onInput:(z)=>$.setCloneFolderText(z),onSubmit:()=>$.setField("cloneBaseRef")},void 0,!1,void 0,this)]},void 0,!0,void 0,this),R.jsxDEV("box",{gap:0,children:[R.jsxDEV("text",{...Z6(Z,$.field,"cloneBaseRef"),children:J("newTask.field.baseBranch")},void 0,!1,void 0,this),R.jsxDEV("input",{value:$.cloneBaseRef,placeholder:f8,focused:$.field==="cloneBaseRef",onMouseUp:()=>$.setField("cloneBaseRef"),onInput:(z)=>$.setCloneBaseRefText(z),onSubmit:()=>void $.commitClone()},void 0,!1,void 0,this)]},void 0,!0,void 0,this),$.cloneInFlight?R.jsxDEV("box",{gap:0,paddingLeft:2,children:R.jsxDEV("text",{fg:Z.textMuted,wrapMode:"none",children:$.cloneProgress||J("newTask.clone.progressFallback")},void 0,!1,void 0,this)},void 0,!1,void 0,this):null]},void 0,!0,void 0,this)}var ar=a(async()=>{kQ();Q$();r0();await e1([$$(),aJ()])});function rr({vm:$}){let{theme:Z}=l0(),J=Z1(),X=$.activeWindow.items.map((G,W)=>{let H=$.mode==="saved"&&G===$.defaultRepo,U=$.mode==="browse"?"/":"",K=H?` ${J("newTask.hint.currentDir")}`:"";return{key:`${$.activeWindow.start+W}:${G}`,body:`${G}${U}${K}`,accent:$.mode==="saved"&&$.repo.trim()===G}}),z=$.branchWindow.items.map((G,W)=>({key:`${$.branchWindow.start+W}:${G}`,body:G,accent:$.baseRef.trim()===G}));return R.jsxDEV(R.Fragment,{children:[R.jsxDEV("box",{gap:0,children:[R.jsxDEV("text",{...Z6(Z,$.field,"repo"),children:J("newTask.field.repo")},void 0,!1,void 0,this),R.jsxDEV("input",{value:$.repo,placeholder:$.defaultRepo,focused:$.field==="repo",onMouseUp:()=>$.setField("repo"),onInput:(G)=>$.setRepoText(G),onSubmit:()=>$.onRepoSubmit()},void 0,!1,void 0,this)]},void 0,!0,void 0,this),$.field==="repo"&&$.activeList.length>0&&!$.repoPicked?R.jsxDEV(B9,{window:$.activeWindow,cursor:$.repoCursor,rows:X,onPick:$.selectRepoAt},void 0,!1,void 0,this):null,R.jsxDEV("box",{gap:0,children:[R.jsxDEV("text",{...Z6(Z,$.field,"baseRef"),children:J("newTask.field.fromBranch")},void 0,!1,void 0,this),R.jsxDEV("input",{value:$.baseRef,placeholder:f8,focused:$.field==="baseRef",onMouseUp:()=>$.setField("baseRef"),onInput:(G)=>$.setBaseRefText(G),onSubmit:()=>$.onBaseRefSubmit()},void 0,!1,void 0,this)]},void 0,!0,void 0,this),$.field==="baseRef"&&$.branchFiltered.length===0&&$.submitError==null?R.jsxDEV("box",{gap:0,paddingLeft:2,paddingBottom:1,children:R.jsxDEV("text",{fg:Z.textMuted,wrapMode:"none",children:$.branches.length===0?J("newTask.hint.noBranchesFound"):J("newTask.hint.noMatchBranch")},void 0,!1,void 0,this)},void 0,!1,void 0,this):null,$.field==="baseRef"&&$.branchFiltered.length>0?R.jsxDEV(B9,{window:$.branchWindow,cursor:$.branchCursor,rows:z,onPick:$.pickBranchAt,paddingBottom:1},void 0,!1,void 0,this):null]},void 0,!0,void 0,this)}var sr=a(async()=>{kQ();Q$();r0();await e1([$$(),aJ()])});function wE($){return $&&$.length>0?$:T8}function tr($,Z){let J=Z??"claude";return $.includes(J)?J:$[0]??"claude"}function er($,Z){let J=new Set($);if(J.has(Z))J.delete(Z);else J.add(Z);return J}function $s($,Z){if(Z.length===0)return $;return Z.every((X)=>$.has(X))?new Set:new Set(Z)}var xE=a(()=>{u7()});function Zs($){let[Z,J]=k8.useState(""),[X,z]=k8.useState(0),[G,W]=k8.useState(new Set),[H,U]=k8.useState(void 0),[K,N]=k8.useState(!1),L=k8.useMemo(()=>ql(H??[],Z),[H,Z]),M=G9(L.map((m)=>m.path),X),V=L.slice(M.start,M.start+M.items.length),P=(H??[]).length,{active:_,expandedRepo:C,discoverAdoptable:f}=$;k8.useEffect(()=>{if(!_)return;let m=!1;return N(!0),(async()=>{let e=[];try{e=f?await f(C):[]}catch{e=[]}if(m)return;U(e),N(!1)})(),()=>{m=!0}},[_,C,f]),k8.useEffect(()=>{z((m)=>w4(m,L.length))},[L]);let E=k8.useRef(void 0);k8.useEffect(()=>{if(E.current!==void 0&&E.current!==C)W(new Set),z(0);E.current=C},[C]);function S(m){J(l5(m))}function T(m){W((e)=>er(e,m))}function x(){let m=L[X];if(m)T(m.path)}function b(m){let e=L[m];if(!e)return;z(m),T(e.path)}function v(){W((m)=>$s(m,L.map((e)=>e.path)))}function u(m){if(L.length===0)return;z((e)=>w4(e+m,L.length))}function o(){if(L.length===0){$.setSubmitError(S$("newTask.error.noAdoptable"));return}let m=G.size>0?L.filter((e)=>G.has(e.path)):L.slice(X,X+1);if(m.length===0)return;$.onSubmit({mode:"adopt",repo:C,vendor:$.vendor,adopt:m.map((e)=>({worktreePath:e.path,branch:e.branch}))}),$.clearDialog()}return{adoptFilter:Z,adoptLoading:K,adoptDiscoveredCount:P,adoptList:L,adoptWindow:M,adoptVisible:V,adoptCursor:X,adoptSelected:G,setAdoptFilterText:S,toggleAdoptCursor:x,pickAdoptAt:b,adoptSelectAll:v,moveAdoptCursor:u,commitAdopt:o}}var k8;var Js=a(()=>{g8();Q$();xE();k8=H1(q1(),1)});import{spawn as CU0}from"child_process";import*as QG from"fs";import*as pF from"path";function Xs($){let Z=$.trim().replace(/\/+$/,"");if(!Z)return"";let J=Z.lastIndexOf("/"),X=Z.lastIndexOf(":"),z=Math.max(J,X);return(z>=0?Z.slice(z+1):Z).replace(/\.git$/i,"")}function Qs($){let Z=$.trim();if(!Z)return S$("newTask.error.gitUrlRequired");let J=Z.includes("://"),X=Z.includes("@")&&Z.includes(":"),z=Z.includes("/");if(!J&&!X&&!z)return S$("newTask.error.gitUrlInvalid",{url:Z});return null}function fE($,Z){let J=Z.trim();if(!J)return S$("newTask.error.folderRequired");if(J.includes("/")||J.includes("\\"))return S$("newTask.error.folderHasSeparator");let X=$.trim();if(!X)return S$("newTask.error.parentRequired");let z=NZ(X),G;try{G=QG.statSync(z)}catch{return S$("newTask.error.parentNotFound",{path:z})}if(!G.isDirectory())return S$("newTask.error.parentNotDir",{path:z});let W=pF.join(z,J);if(QG.existsSync(W))return S$("newTask.error.targetExists",{path:W});return null}function zs($,Z){return pF.join(NZ($.trim()),Z.trim())}function Ys($,Z){let J=Z.trim();if(!J)return Z;let X=NZ($.trim());if(!X)return Z;try{if(!QG.statSync(X).isDirectory())return Z}catch{return Z}if(!QG.existsSync(pF.join(X,J)))return J;for(let z=2;z<1000;z++){let G=`${J}-${z}`;if(!QG.existsSync(pF.join(X,G)))return G}return J}function Gs($,Z,J){return new Promise((X)=>{let z="";try{let G=CU0("git",["clone","--progress",$,Z],{stdio:["ignore","ignore","pipe"],env:{...process.env,GIT_TERMINAL_PROMPT:"0",GIT_ASKPASS:""}});G.stderr?.setEncoding("utf-8"),G.stderr?.on("data",(W)=>{if(z+=W,J){let H=W.split(/[\r\n]+/).filter((K)=>K.trim().length>0),U=H[H.length-1];if(U)J(U)}}),G.on("error",(W)=>{X({ok:!1,error:W.message})}),G.on("close",(W)=>{if(W===0){X({ok:!0,path:Z});return}let H=z.split(/[\r\n]+/).filter((U)=>U.trim().length>0).pop()??`git clone exited with ${W}`;X({ok:!1,error:H})})}catch(G){X({ok:!1,error:N1(G)})}})}var Ws=a(()=>{gY();pY()});function C_($){let Z=gE.useMemo(()=>ap($),[$]),J=gE.useMemo(()=>sp(rp(Z.base),Z.filter),[Z]);return{split:Z,filtered:J}}var gE;var yE=a(()=>{pY();gE=H1(q1(),1)});function Hs($){let[Z,J]=Y6.useState(""),[X,z]=Y6.useState($.defaultCloneParent?.trim()?$.defaultCloneParent:"~/"),[G,W]=Y6.useState(""),[H,U]=Y6.useState(!1),[K,N]=Y6.useState(f8),[L,M]=Y6.useState(!1),[V,P]=Y6.useState(""),[_,C]=Y6.useState(0),[f,E]=Y6.useState(!1),{split:S,filtered:T}=C_(X),x=G9(T,_);Y6.useEffect(()=>{if(H)return;W(Ys(X,Xs(Z)))},[Z,X,H]);function b(F0){J(l5(F0))}function v(F0){E(!1),z(l5(F0)),C(0)}function u(F0){U(!0),W(l5(F0))}function o(F0){N(l5(F0))}function m(){let F0=T[_];if(F0)z(Fq(X,S.base,F0)),C(0),E(!0);$.setField("cloneFolder")}function e(F0){let K0=T[F0];if(!K0)return;z(Fq(X,S.base,K0)),C(F0),E(!0),$.setField("cloneFolder")}function t(F0){if(T.length===0)return;C((K0)=>w4(K0+F0,T.length))}async function Y0(){if(L)return;let F0=Qs(Z);if(F0){$.setSubmitError(F0),$.setField("cloneUrl");return}let K0=fE(X,G);if(K0){$.setSubmitError(K0);let l=G.trim(),n=!(!l||l.includes("/")||l.includes("\\"))&&fE(X,"__kobe_probe__")!=null;$.setField(n?"cloneParent":"cloneFolder");return}let M0=zs(X,G);M(!0),P(S$("newTask.clone.progressInto",{target:M0}));let H0=await Gs(Z.trim(),M0,(l)=>P(l));if(M(!1),!H0.ok){$.setSubmitError(S$("newTask.error.cloneFailed",{error:H0.error})),$.setField("cloneUrl");return}let k=K.trim()||f8;$.onSubmit({repo:H0.path,baseRef:k,vendor:$.vendor,cloned:{parentDir:NZ(X.trim())}}),$.clearDialog()}return{cloneUrl:Z,cloneParent:X,cloneFolder:G,cloneBaseRef:K,cloneInFlight:L,cloneProgress:V,cloneParentFiltered:T,cloneParentWindow:x,cloneParentCursor:_,cloneParentPicked:f,setCloneUrlText:b,setCloneParentText:v,setCloneFolderText:u,setCloneBaseRefText:o,onCloneParentSubmit:m,selectCloneParentAt:e,moveParentCursor:t,commitClone:Y0}}var Y6;var qs=a(()=>{Ws();g8();kQ();pY();Q$();yE();Y6=H1(q1(),1)});function Us($){let Z=n$(),[J,X]=R7.useState("existing"),z=wE($.availableVendors),[G,W]=R7.useState(()=>tr(wE($.availableVendors),$.defaultVendor)),[H,U]=R7.useState("tabs"),[K,N]=R7.useState($.defaultRepo),[L,M]=R7.useState(()=>Wq(NZ($.defaultRepo.trim()))??f8),[V,P]=R7.useState(!1),[_,C]=R7.useState(0),[f,E]=R7.useState(!1),[S,T]=R7.useState(0),[x,b]=R7.useState(null),v=R7.useMemo(()=>Ul($.defaultRepo,$.savedRepos),[$.defaultRepo,$.savedRepos]),u=Hl(K,v),{split:o,filtered:m}=C_(K),e=R7.useMemo(()=>Bl(v,K),[v,K]),t=u==="browse"?m:e,Y0=G9(t,_),F0=NZ(K.trim()),K0=R7.useMemo(()=>tj(F0),[F0]),M0=R7.useMemo(()=>ej(K0,L),[K0,L]),H0=G9(M0,S),k=Hs({defaultCloneParent:$.defaultCloneParent,vendor:G,onSubmit:$.onSubmit,clearDialog:()=>Z.clear(),setField:U,setSubmitError:b}),l=Zs({active:J==="adopt",expandedRepo:F0,vendor:G,discoverAdoptable:$.discoverAdoptable,onSubmit:$.onSubmit,clearDialog:()=>Z.clear(),setSubmitError:b});R7.useEffect(()=>{if(!F0||V)return;let L0=Wq(F0);if(L0)M(L0)},[F0,V]),R7.useEffect(()=>{b(null)},[K,k.cloneUrl,k.cloneParent,k.cloneFolder,l.adoptFilter]);function d(L0){E(!1),N(l5(L0)),C(0),T(0)}function n(L0){P(!0),M(l5(L0)),T(0)}function G0(){let L0=F0;if(!L0)return;let d0=Wl(L0);if(d0){b(d0),U("repo");return}let G1=L.trim()||f8;$.onSubmit({repo:L0,baseRef:G1,vendor:G}),Z.clear()}function s(){if(J==="clone"){k.commitClone();return}if(J==="adopt"){l.commitAdopt();return}G0()}function r(L0){if(k.cloneInFlight||L0===J)return;X(L0),U(cS(L0)),b(null)}function J0(L0){if(k.cloneInFlight)return;let d0=L0===1?mS(J):hS(J);if(d0===J)return;X(d0),b(null),U("tabs")}function C0(L0){W((d0)=>L0===1?qH(z,d0):tf(z,d0))}function Q0(){if(!K.trim()&&u==="saved"){let d0=t[0];if(d0){N(d0),U("baseRef");return}}if(u==="browse"){let d0=m[_];if(d0)N(Fq(K,o.base,d0)),C(0),E(!0);U("baseRef");return}let L0=t[_];if(L0)N(L0);U("baseRef")}function w0(L0){let d0=t[L0];if(!d0)return;if(u==="browse")N(Fq(K,o.base,d0)),E(!0);else N(d0);C(L0),U("baseRef")}function v0(L0){let d0=M0[L0];if(!d0)return;M(d0),P(!0),T(L0),U("confirm")}function P0(){M($V(L,M0,S)),P(!0),G0()}function u0(L0){if(k.cloneInFlight)return;if(J==="existing"&&H==="repo"&&t.length>0){C((d0)=>w4(d0+L0,t.length));return}if(J==="existing"&&H==="baseRef"&&M0.length>0){T((d0)=>w4(d0+L0,M0.length));return}if(J==="clone"&&H==="cloneParent"){k.moveParentCursor(L0);return}if(J==="adopt")l.moveAdoptCursor(L0)}return g1(()=>({bindings:[{key:"tab",cmd:()=>U((L0)=>uS(L0,J))},{key:"ctrl+]",cmd:()=>r(mS(J))},{key:"ctrl+[",cmd:()=>r(hS(J))},{key:"ctrl+e",cmd:()=>C0(1)},{key:"up",cmd:()=>u0(-1)},{key:"down",cmd:()=>u0(1)},...H==="tabs"||H==="engine"?[{key:"left",cmd:()=>H==="tabs"?J0(-1):C0(-1)},{key:"right",cmd:()=>H==="tabs"?J0(1):C0(1)},{key:"return",cmd:()=>U((L0)=>uS(L0,J))}]:[],...J==="adopt"?[{key:"ctrl+a",cmd:l.adoptSelectAll}]:[]]})),g1(()=>({enabled:H==="confirm"&&!k.cloneInFlight,bindings:[{key:"return",cmd:()=>s()}]})),{...k,...l,defaultRepo:$.defaultRepo,tab:J,vendors:z,vendor:G,setVendor:W,field:H,setField:U,repo:K,mode:u,activeList:t,activeWindow:Y0,repoCursor:_,repoPicked:f,expandedRepo:F0,baseRef:L,branches:K0,branchFiltered:M0,branchWindow:H0,branchCursor:S,submitError:x,setRepoText:d,setBaseRefText:n,onRepoSubmit:Q0,selectRepoAt:w0,pickBranchAt:v0,onBaseRefSubmit:P0,switchToTab:r,commit:s,commitExisting:G0}}var R7;var Bs=a(async()=>{u7();g8();kQ();pY();xE();Js();qs();yE();await e1([C4(),V5()]);R7=H1(q1(),1)});import{TextAttributes as nF}from"@opentui/core";function Ks($){let{theme:Z}=l0(),J=Z1(),X=H7(),z=Us($),G={existing:J("newTask.tabs.existing"),clone:J("newTask.tabs.clone"),adopt:J("newTask.tabs.adopt")},W=z.field==="tabs",H=(U,K)=>U?K?nF.BOLD|nF.UNDERLINE:nF.BOLD:void 0;return R.jsxDEV("box",{paddingLeft:X,paddingRight:X,gap:0,children:[R.jsxDEV("box",{flexDirection:"row",children:R.jsxDEV("text",{attributes:nF.BOLD,fg:Z.text,children:J("newTask.title")},void 0,!1,void 0,this)},void 0,!1,void 0,this),R.jsxDEV("box",{gap:1,paddingTop:1,paddingBottom:1,children:[R.jsxDEV("box",{flexDirection:"row",gap:2,children:DU0.map((U)=>{let K=z.tab===U;return R.jsxDEV("text",{fg:K?Z.primary:Z.textMuted,attributes:H(K,W),onMouseUp:()=>z.switchToTab(U),children:K?`\u25B8 ${G[U]}`:` ${G[U]}`},U,!1,void 0,this)})},void 0,!1,void 0,this),R.jsxDEV("box",{gap:0,children:[R.jsxDEV("text",{...Z6(Z,z.field,"engine"),children:J("newTask.field.engine")},void 0,!1,void 0,this),R.jsxDEV(Iq,{choices:z.vendors,selected:z.vendor,onPick:(U)=>{z.setVendor(U),z.setField("engine")},children:[R.jsxDEV("box",{flexGrow:1},void 0,!1,void 0,this),R.jsxDEV("text",{fg:Z.textMuted,children:J("newTask.hint.engineCycle")},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.tab==="existing"?R.jsxDEV(rr,{vm:z},void 0,!1,void 0,this):null,z.tab==="clone"?R.jsxDEV(or,{vm:z},void 0,!1,void 0,this):null,z.tab==="adopt"?R.jsxDEV(nr,{vm:z},void 0,!1,void 0,this):null,z.submitError?R.jsxDEV("text",{fg:Z.error,wrapMode:"word",children:["\u203B ",z.submitError]},void 0,!0,void 0,this):null]},void 0,!0,void 0,this),R.jsxDEV("box",{flexDirection:"row",justifyContent:"flex-end",alignItems:"center",paddingTop:1,paddingBottom:1,children:R.jsxDEV("text",{fg:z.field==="confirm"?Z.primary:Z.text,attributes:z.field==="confirm"?nF.BOLD:void 0,onMouseUp:()=>z.commit(),children:z.cloneInFlight?J("newTask.button.cloning"):z.field==="confirm"?J("newTask.button.createFocused"):J("newTask.button.create")},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var DU0;var Fs=a(async()=>{Q$();r0();await e1([$$(),V5(),aJ(),ir(),ar(),sr(),Bs()]);DU0=["existing","clone","adopt"]});function AU0($,Z,J,X){return S2($,(z)=>R.jsxDEV(Ks,{defaultRepo:Z,savedRepos:J,defaultCloneParent:X?.defaultCloneParent,defaultVendor:X?.defaultVendor,availableVendors:X?.availableVendors,discoverAdoptable:X?.discoverAdoptable,onSubmit:(G)=>z(G),onCancel:()=>z(void 0)},void 0,!1,void 0,this),{size:"medium"})}var Ms;var Ns=a(async()=>{g8();r0();await e1([V5(),Fs()]);Ms={show:AU0}});function PU0($){return{confirm:async(Z)=>await N4.show($,Z.title,Z.body,Z.cancelLabel,Z.confirmLabel)===!0,promptText:(Z,J)=>p5.show($,Z,J),promptNewTask:(Z,J,X)=>Ms.show($,Z,J,X)}}function bE($){return(Z,J)=>{if($.selectedId()!==Z)return;let X=$.tasks();$.setSelectedId(J?.id??(X.find((z)=>!z.archived)??X[0])?.id??null)}}function Os($){return{orch:$.orch,tasks:()=>$.tasks(),...PU0($.dialog),...RU0,logger:console,logPrefix:$.logPrefix,notifyError:$.notifyError,notifyInfo:$.notifyInfo,updateActiveTask:!0,onTaskDeleted:bE($),cursorRepo:()=>{let Z=$.tasks();return(Z.find((J)=>J.id===$.selectedId())??Z[0])?.repo},selectTask:(Z)=>$.setSelectedId(Z),enterTask:(Z)=>$.enterTask(Z)}}var RU0;var Ls=a(async()=>{AJ();await e1([Ns(),cJ(),FZ()]);RU0={lastVendor:($)=>ZZ($),rememberVendor:($,Z)=>DJ($,Z)}});function js($){let{orchestrator:Z,tasks:J,dialog:X,notifyError:z}=$,G={...Os({orch:Z,tasks:J,dialog:X,notifyError:z,notifyInfo:$.notifyInfo,selectedId:$.selectedId,setSelectedId:$.setSelectedId,logPrefix:"[rove workspace]",enterTask:$.activateTask}),onTaskDeleted:(()=>{let K=bE({tasks:J,selectedId:$.selectedId,setSelectedId:$.setSelectedId});return(N,L)=>{$.forgetTaskTabs(N),K(N,L)}})()};async function W(K){let N=J().find((L)=>L.id===K);if(!N)return;await Z.setPinned(K,!N.pinned).catch((L)=>{z(`Couldn't pin: ${N1(L)}`)})}async function H(K,N){await Z.moveTask(K,N).catch((L)=>{z(`Couldn't move: ${N1(L)}`)})}async function U(K){let N=J().find((M)=>M.id===K);if(!N||N.kind==="main")return;let L=await lr.show(X,{currentBranch:N.branch,repo:N.repo});if(!L)return;await Z.setBranch(K,L).catch((M)=>{z(`Couldn't rename branch: ${N1(M)}`)})}return{createTask:()=>cr(G),archiveTask:(K)=>kr(G,K),deleteTask:(K)=>vr(G,K),renameTask:(K)=>mr(G,K),renameBranch:U,cycleVendor:(K)=>hr(G,K),togglePin:W,moveTask:H}}var Vs=a(async()=>{ur();dr();await e1([pr(),Ls()])});import{spawn as TU0}from"child_process";import{existsSync as SU0}from"fs";import{basename as IU0,delimiter as EU0,isAbsolute as wU0,join as xU0}from"path";function kE($,Z,J){if(wU0($))return J($);let X=Z.PATH??"";for(let z of X.split(EU0)){if(!z)continue;if(J(xU0(z,$)))return!0}return!1}function yU0($){let Z=IU0($);if(Z==="code")return"VS Code";if(Z==="cursor")return"Cursor";if(Z==="windsurf")return"Windsurf";if(Z==="zed")return"Zed";return Z||$}function _s($={}){let Z=$.env??process.env,J=$.platform??process.platform,X=$.exists??SU0,z=C$("OPEN_EDITOR",Z)?.trim();if(z)return{id:"env",label:yU0(z),command:z,args:[]};for(let G of fU0)if(kE(G.command,Z,X))return{id:G.id,label:G.label,command:G.command,args:[]};if(J==="darwin"&&kE("open",Z,X)){for(let G of gU0)if(G.paths.some((W)=>X(W)))return{id:G.id,label:G.label,command:"open",args:["-a",G.appName]};return{id:"mac-open",label:"Finder",command:"open",args:[]}}if(J==="linux"&&kE("xdg-open",Z,X))return{id:"xdg-open",label:"Open",command:"xdg-open",args:[]};return null}function bU0($,Z){return[Z.command,[...Z.args,$]]}function Cs($,Z,J={}){if(!$)return!1;let X=J.spawn??TU0,[z,G]=bU0($,Z);try{let W=X(z,G,{detached:!0,stdio:"ignore"});if(W.pid===void 0)return!1;return W.unref(),!0}catch{return!1}}var fU0,gU0;var Ds=a(()=>{fU0=[{id:"code",label:"VS Code",command:"code"},{id:"cursor",label:"Cursor",command:"cursor"},{id:"windsurf",label:"Windsurf",command:"windsurf"},{id:"zed",label:"Zed",command:"zed"}],gU0=[{id:"vscode.app",label:"VS Code",appName:"Visual Studio Code",paths:["/Applications/Visual Studio Code.app"]},{id:"cursor.app",label:"Cursor",appName:"Cursor",paths:["/Applications/Cursor.app","/System/Applications/Cursor.app"]},{id:"windsurf.app",label:"Windsurf",appName:"Windsurf",paths:["/Applications/Windsurf.app"]},{id:"zed.app",label:"Zed",appName:"Zed",paths:["/Applications/Zed.app"]}]});import{existsSync as As}from"fs";async function Ps($,Z){let J=Z.taskPath;if(!J||!As(J))try{J=await Z.ensureWorktree($)}catch(z){let G=z instanceof Error?z.message:String(z);Z.notifyError(`Couldn't create worktree: ${G}`);return}if(!J||!As(J))return;let X=_s();if(!X){Z.notifyError(Z.noEditorMessage);return}if(!Cs(J,X))Z.notifyError(Z.openFailedMessage(X.label))}var Rs=a(()=>{Ds()});function Es($){return $.kind==="running"?Ss:kU0}function ws(){iF=null;let $=Date.now(),Z=null,J=Number.POSITIVE_INFINITY;for(let[X,z]of $X.get()){let G=z.at+Es(z);if(G<=$)Z??=new Map($X.get()),Z.delete(X);else if(G<J)J=G}if(Z)$X.set(Z);if(J<Number.POSITIVE_INFINITY)iF=setTimeout(ws,J-$+20)}function Ts($,Z){let J=new Map($X.get());if(J.set($,{kind:Z,at:Date.now()}),$X.set(J),iF)clearTimeout(iF);iF=setTimeout(ws,Ss+20)}function xs($){if(!$X.get().has($))return;let Z=new Map($X.get());Z.delete($),$X.set(Z)}function fs($,Z){if(Z==="\r"||Z.endsWith("\r"))Ts($,"running");else if(Z==="\x1B")Ts($,"interrupted")}function gs($,Z,J=Date.now()){if(Z.size===0)return $;let X=null;for(let[z,G]of Z){if(J-G.at>Es(G))continue;let W=$.get(z);if(W&&W.at>=G.at)continue;if(G.kind==="running"){if(W?.state==="running")continue;X??=new Map($),X.set(z,{state:"running",at:G.at})}else if(W!==void 0)X??=new Map($),X.delete(z)}return X??$}function ys($,Z){if(Z.size===0)return[];let J=[];for(let[X,z]of Z){let G=$.get(X);if(G&&G.at>=z.at)J.push(X)}return J}var Ss=5000,kU0=1800000,$X,iF=null,Is;var vE=a(()=>{$Z();$X=r$(new Map),Is=$X});import{randomUUID as vU0}from"crypto";function mU0($){let Z=$.body.replace(/\\/g,"\\\\").replace(/"/g,"\\\"").replace(/\r/g,"\\r").replace(/\n/g,"\\n"),J=$.startLine!==void 0&&$.startLine!==$.line?`Lines: ${$.startLine}-${$.line}`:`Line: ${$.line}`;return[`File: ${$.filePath}`,J,`User comment: "${Z}"`].join(`