#!/usr/bin/env node
import{a as g,b as p}from"./chunk-HI7TGUGZ.js";import{a as c}from"./chunk-JBABAK44.js";import{a as l,b as m}from"./chunk-GTNBSMZR.js";import"./chunk-KGOUQS5A.js";var D={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"]},F={unified:{short:"u",long:"unified",type:"boolean"},summary:{short:"s",long:"summary",type:"boolean"},ignoreCase:{short:"i",long:"ignore-case",type:"boolean"}},k={name:"ag-diff",async execute(f,e){if(m(f))return l(D);let s=c("ag-diff",f,F);if(!s.ok)return s.error;let h=s.result.flags.summary,y=s.result.flags.ignoreCase,d=s.result.positional;if(d.length<2)return{stdout:"",stderr:`ag-diff: missing operand
`,exitCode:2};let[t,o]=d,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}}y&&(r=r.toLowerCase(),i=i.toLowerCase());let C=g(t,o,r,i,"","",{context:3}),n=0,a=0;for(let w of C.hunks)for(let u of w.lines)u.startsWith("+")&&n++,u.startsWith("-")&&a++;if(h)return{stdout:`Summary: ${n} additions, ${a} deletions in ${o} compared to ${t}
`,stderr:"",exitCode:n+a>0?1:0};let $=p(t,o,r,i,"","",{context:3});return{stdout:`--- ag-diff summary ---
${t} -> ${o}
Additions: ${n}, Deletions: ${a}
-----------------------

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