import{a as g}from"./chunk-HWKDQ44K.js";import{a as m,b as c}from"./chunk-74CEPOFO.js";import"./chunk-DXB73IDG.js";import*as f from"diff";var w={name:"ag-diff",summary:"agent-optimized file comparison with change summaries",usage:"ag-diff [OPTION]... FILE1 FILE2",options:["-u, --unified     output unified diff format (default)","-s, --summary     output only a summary of changes","-i, --ignore-case  ignore case differences","    --help        display this help and exit"]},D={unified:{short:"u",long:"unified",type:"boolean"},summary:{short:"s",long:"summary",type:"boolean"},ignoreCase:{short:"i",long:"ignore-case",type:"boolean"}},O={name:"ag-diff",async execute(d,e){if(c(d))return m(w);let s=g("ag-diff",d,D);if(!s.ok)return s.error;let p=s.result.flags.summary,h=s.result.flags.ignoreCase,u=s.result.positional;if(u.length<2)return{stdout:"",stderr:`ag-diff: missing operand
`,exitCode:2};let[t,o]=u,r,i;try{r=t==="-"?e.stdin:await e.fs.readFile(e.fs.resolvePath(e.cwd,t))}catch{return{stdout:"",stderr:`ag-diff: ${t}: No such file or directory
`,exitCode:2}}try{i=o==="-"?e.stdin:await e.fs.readFile(e.fs.resolvePath(e.cwd,o))}catch{return{stdout:"",stderr:`ag-diff: ${o}: No such file or directory
`,exitCode:2}}h&&(r=r.toLowerCase(),i=i.toLowerCase());let y=f.structuredPatch(t,o,r,i,"","",{context:3}),n=0,a=0;for(let $ of y.hunks)for(let l of $.lines)l.startsWith("+")&&n++,l.startsWith("-")&&a++;if(p)return{stdout:`Summary: ${n} additions, ${a} deletions in ${o} compared to ${t}
`,stderr:"",exitCode:n+a>0?1:0};let C=f.createTwoFilesPatch(t,o,r,i,"","",{context:3});return{stdout:`--- ag-diff summary ---
${t} -> ${o}
Additions: ${n}, Deletions: ${a}
-----------------------

${C}
`,stderr:"",exitCode:n+a>0?1:0}}};export{O as agDiffCommand};
