import{copyFileSync as m,existsSync as c,lstatSync as p,mkdirSync as a,rmSync as l,symlinkSync as S,unlinkSync as L}from"node:fs";import{join as o}from"node:path";import{homedir as _}from"node:os";import{randomBytes as C}from"node:crypto";var b=["cli-config.json","config.json","auth.json","argv.json"];function B(r){return!(!r||typeof r!="string"||process.env.ZIBBY_CURSOR_USE_GLOBAL_MCP==="1"||process.env.ZIBBY_CURSOR_USE_GLOBAL_MCP==="true")}function O(r){let t=o(r||process.cwd(),".zibby","tmp");a(t,{recursive:!0});let y=`${process.pid}-${Date.now()}-${C(4).toString("hex")}`,n=o(t,`cursor-agent-home-${y}`),s=o(n,".cursor");a(s,{recursive:!0});let i=_(),u=o(i,".cursor");if(c(u))for(let e of b){let f=o(u,e);if(c(f))try{m(f,o(s,e))}catch{}}if(process.platform==="darwin"){let e=o(i,"Library");if(c(e))try{S(e,o(n,"Library"))}catch{}}return n}function k(r){if(!(!r||typeof r!="string"))try{let t=o(r,"Library");try{p(t).isSymbolicLink()&&L(t)}catch{}l(r,{recursive:!0,force:!0})}catch{}}export{b as CURSOR_HOME_DOT_FILES,O as createIsolatedCursorAgentHome,k as removeIsolatedCursorAgentHome,B as shouldUseIsolatedCursorMcpHome};
