import{zr as e}from"./dist-CQ_iP-zI.mjs";import{cpSync as t,existsSync as n,lstatSync as r,mkdirSync as i,realpathSync as a,rmSync as o}from"node:fs";import{dirname as s,isAbsolute as c,relative as l,resolve as u,sep as d}from"node:path";function f(e,t){let n;try{n=a(t)}catch{n=u(t)}let i;try{i=r(e)}catch(e){if(e.code!==`ENOENT`)throw e}if(i?.isSymbolicLink())throw Error(`Refusing to write through a symbolic link at ${e}. Remove the symlink and re-run project setup.`);let o=s(e);for(;o.length>1&&o!==d;){let t;try{t=a(o)}catch(e){if(e.code===`ENOENT`){o=s(o);continue}throw e}let r=l(n,t);if(r===``||!r.startsWith(`..`)&&!c(r))return;throw Error(`Refusing to write at ${e}: ancestor ${o} resolves to ${t}, which is outside the project directory ${n}. A symbolic link in the path likely escapes the project. Remove the symlink and re-run project setup.`)}}function p(r,a){let c=r.projectSkillPath?.(a);if(!c)return{editorId:r.id,label:r.label,action:`skipped-unsupported`,path:``};try{let l=e(`project`,{checkDesktop:!0}),u=s(c);f(u,a);let d=n(c)?`overwritten`:`written`;return o(u,{recursive:!0,force:!0}),i(s(u),{recursive:!0}),t(l,u,{recursive:!0}),{editorId:r.id,label:r.label,action:d,path:c}}catch(e){return{editorId:r.id,label:r.label,action:`failed`,path:c,error:e instanceof Error?e.message:String(e)}}}export{p as n,f as t};
//# sourceMappingURL=write-project-skill-1--7yQee.mjs.map