import{a as g}from"./chunk-HWKDQ44K.js";import{a as h}from"./chunk-3THT3N7L.js";import{a as p,b as m}from"./chunk-74CEPOFO.js";var y={name:"ag-hover",summary:"get information about a symbol at a specific position",usage:"ag-hover <file> <line> <character>",options:["    --help        display this help and exit"]},w={name:"ag-hover",async execute(d,e){if(m(d))return p(y);let i=g("ag-hover",d,Object.create(null));if(!i.ok)return i.error;let{positional:s}=i.result,a=s[0],c=parseInt(s[1],10),l=parseInt(s[2],10);if(!a||Number.isNaN(c)||Number.isNaN(l))return{stdout:"",stderr:`ag-hover: missing or invalid arguments
Usage: ag-hover <file> <line> <character>
`,exitCode:2};let u=e.fs.resolvePath(e.cwd,a);if(!await e.fs.exists(u))return{stdout:"",stderr:`ag-hover: ${a}: No such file or directory
`,exitCode:2};try{let v=(await e.fs.readFile(u,"utf8")).split(/\r?\n/)[c-1]||"",b=/[\w$!]+/g,t,r;for(;(r=b.exec(v))!==null;)if(l-1>=r.index&&l-1<r.index+r[0].length){t=r[0];break}if(!t)return{stdout:`No symbol found at position.
`,stderr:"",exitCode:0};if(!e.bash)return{stdout:"",stderr:`ag-hover: no bash host available
`,exitCode:1};let o=e.bash.semanticEngine.findDefinition(t);if(o){let n=`--- Hover Info for '${t}' ---
`;return n+=`Type: ${o.type}
`,n+=`Scope: ${o.scope}
`,n+=`Defined in: ${o.path||"current script"} at line ${o.line}
`,{stdout:n,stderr:"",exitCode:0}}return{stdout:`No semantic info found for '${t}'.
`,stderr:"",exitCode:0}}catch(f){return{stdout:"",stderr:`ag-hover: error: ${h(f.message)}
`,exitCode:1}}}};export{w as a};
