@wispbit/local 1.0.34 → 1.0.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli-bundle.js +1 -1
- package/package.json +1 -1
package/cli-bundle.js
CHANGED
|
@@ -54,7 +54,7 @@ globstar while`,e,b,r,f,d),this.matchOne(e.slice(b),r.slice(f),i))return this.de
|
|
|
54
54
|
`);let l=o.map((u,p)=>`L${n+p+1} ${u}`);return c+=l.join(`
|
|
55
55
|
`),a<s.length&&(c+=`
|
|
56
56
|
[Lines ${a+1}-${s.length} omitted]`),c}catch(i){let s=i instanceof Error?i.message:String(i);throw new Error(`Failed to read file ${t}: ${s}`)}}async function k0(t,e,r=[]){let{target_file:i}=t,s=t.offset?parseInt(t.offset?.toString(),10):void 0,n=t.limit?parseInt(t.limit?.toString(),10):void 0,a=i.startsWith("/")?i.slice(1):i;if(Ts(a,r))return{error:`File not found or not accessible: ${i}. Please provide the correct path.`};let o=yo(e,a);if(!o)return{error:`Invalid file path: '${i}'`};if(!await po(o))return{error:`File not found or not accessible: ${i}. Please provide the correct path. It could also have been deleted as part of the PR.`};try{if(s!==void 0&&(Number.isNaN(Number(s))||s<0))return{error:`Invalid offset: ${s}. Offset must be a non-negative number starting from 0.`};if(n!==void 0&&(Number.isNaN(Number(n))||n<1))return{error:`Invalid limit: ${n}. Limit must be a positive number.`};let c=s??1,u=Math.min(n??200,500),p=c+u-1,b=PO(o,c,p),f=await Ps(o);return{content:b,sha:f}}catch(c){let l=c.message||String(c);return{error:go(`Error reading file: ${l}`,e)}}}async function IO(t,e,r,i="."){let s=["--no-config","--line-number","--color=never","--max-columns=300","--max-filesize=1M","--max-count=50","-i"];r&&s.push("-g",r),s.push(e),s.push(i);try{let n=await new Promise((c,l)=>{let u=$O(t,s,{cwd:i,shell:!1,stdio:["ignore","pipe","pipe"],env:{LANG:"C",RIPGREP_CONFIG_PATH:""}}),p="",b="";u.stdout?.on("data",d=>{p+=d.toString()}),u.stderr?.on("data",d=>{b+=d.toString()});let f=setTimeout(()=>{u.kill("SIGTERM"),l(new Error("rg search operation timed out"))},3e4);u.on("close",d=>{clearTimeout(f),d===1&&!b?c({stdout:"",stderr:""}):d===0||d===1&&!b?c({stdout:p,stderr:b}):l(new Error(`ripgrep exited with code ${d}: ${b}`))}),u.on("error",d=>{clearTimeout(f),l(d)})});if(!n.stdout.trim())return[];let a=n.stdout.trim().split(`
|
|
57
|
-
`),o=[];for(let c of a){let l=c.match(/^([^:]+):(\d+):(.*)$/);if(l){let[,u,p,b]=l,f=u;f=Bt.relative(i,u);let d=Bt.join(i,f);try{if($i.existsSync(d)){let m=await Ps(d);o.push({file:f,line_number:parseInt(p,10),content:b,sha:m})}}catch{}}}return o}catch(n){let a=n;if(a.code===1&&!a.stderr)return[];throw a.signal==="SIGTERM"?new Error("rg search operation timed out"):n}}async function j0(t,e,r=[],i=P0()){let{pattern:s,include:n}=t,a=t.path?.startsWith("/")?t.path.slice(1):t.path;try{if(!await I0(i))throw new Error(`ripgrep is not found or not executable: ${i}`);let c=null;if(a){let p=yo(e,a);if(!p)return{error:`Invalid path: '${a}'. Please provide the correct path.`};if(!await po(p))return{error:`Path not found or not accessible: ${a}. Please provide the correct path.`};let b=await $i.promises.stat(p);if(b.isFile())c=D0(p),a=D0(a);else if(b.isDirectory())c=p;else return{error:`Path is neither a file nor a directory: ${a}`}}return{matches:(await IO(i,s,n,c||e)).filter(p=>{let b=a?M0(a,p.file):p.file;return!Ts(b,r)}).slice(0,50).map(p=>({...p,file:a?M0(a,p.file):p.file}))}}catch(o){let c=typeof o=="object"&&o!==null&&"message"in o&&typeof o.message=="string"?o.message:String(o);return{error:go(c,e)}}}async function B0(t,e,r=[]){let i=t.pattern,s=t.path;s&&i.startsWith(s)&&(i=i.replace(s,"")),i=i.startsWith("/")?i.slice(1):i;let n;if(s){if(s=s.startsWith("/")?s.slice(1):s,s!=="."&&Ts(s,r))return{files:[]};let a=yo(e,s);if(!a)return{error:`Path not found or not accessible: '${s}'. Please provide the correct path.`};n=a}else n=e;if(!await po(n))return{error:`Directory not found or not accessible: ${s||"."}. Please provide the correct path.`};try{if(!(await $i.promises.stat(n)).isDirectory())return{error:`Not a directory: ${s||"."}. Please provide the correct path.`}}catch{return{error:`Directory not found or not accessible: ${s||"."}. Please provide the correct path.`}}try{return{files:(await FO(i,s,e)).filter(c=>!Ts(c,r)).slice(0,50)}}catch(a){let o=typeof a=="object"&&a!==null&&"message"in a&&typeof a.message=="string"?a.message:String(a);return{error:go(o,e)}}}async function FO(t,e,r){try{let i;if(e){let a=e.startsWith("/")?e.slice(1):e,o=yo(r,a);if(!o)throw new Error(`Invalid directory path: potential directory traversal detected in '${a}'`);i=o}else i=r;let s=await Jt(t,{cwd:i,nodir:!0,ignore:["node_modules/**",".git/**","**/__pycache__/**"],absolute:!1}),n=[];for(let a of s)try{let o=Bt.join(i,a),c=await $i.promises.stat(o);c.isFile()&&n.push({path:e?Bt.join(e,a):a,mtime:c.mtime})}catch{}return n.sort((a,o)=>o.mtime.getTime()-a.mtime.getTime()),n.map(a=>a.path)}catch(i){let s=i instanceof Error?i.message:String(i);throw new Error(go(`Glob search failed: ${s}`,r))}}function U0(t){return{...t,range:{start:{line:t.range.start.line-1,column:t.range.start.column-1},end:{line:t.range.end.line-1,column:t.range.end.column-1}}}}function El(t){return{...t,range:{start:{line:t.range.start.line+1,column:t.range.start.column+1},end:{line:t.range.end.line+1,column:t.range.end.column+1}}}}var bo=class{environment;language;constructor(e,r){this.environment=e,this.language=r}async findMatches(e,r){if(e.length===0)return[];let{rule:i,constraints:s}=r,n=this.getBatchSize(),a=[];for(let o=0;o<e.length;o+=n){let c=e.slice(o,o+n),l=await this.processBatch(c,i,s);a.push(...l)}return a}getBatchSize(){let e=parseInt(process.env.UV_THREADPOOL_SIZE||"4",10);return Math.max(2,Math.floor(e/2))}async processBatch(e,r,i){let s=e.map(async c=>{let l=q0.resolve(this.environment.getWorkspaceRoot(),c),u=await G0(l,"utf-8"),b=(await(0,vo.parseAsync)(this.language,u)).root().findAll({rule:r,language:this.language,constraints:i});if(b.length===0)return[];let f=await Ps(l);return b.map(d=>({filePath:c,sgNode:d,sha:f}))}),a=(await Promise.all(s)).flat(),o=[];for(let{filePath:c,sgNode:l,sha:u}of a){let p=l.range(),b={file:{path:c,sha:u},text:l.text(),range:{start:{line:p.start.line,column:p.start.column},end:{line:p.end.line,column:p.end.column}},language:this.language};o.push(El(b))}return o}extractSymbol(e){let r=e.kind();if(r==="call_expression"){let i=e.field("function");if(i)return this.extractSymbol(i)}else if(r==="member_expression"){let i=e.field("property");if(i)return i.text()}else if(r==="identifier")return e.text()}async expandMatch(e){let r=new Set(["method_definition","function_declaration","function_expression","arrow_function","class_declaration","export_statement","lexical_declaration"]),i=q0.resolve(this.environment.getWorkspaceRoot(),e.file.path),[s,n]=await Promise.all([G0(i,"utf-8"),Ps(i)]),a=(0,vo.parse)(this.language,s).root(),o=U0(e),c=this.findNodeAtPosition(a,o.range.start.line,o.range.start.column);if(!c)return null;let l=c;for(;l;){let u=l.kind(),p=typeof u=="string"?u:String(u);if(r.has(p)){let b=l.range(),f={file:{path:e.file.path,sha:n},text:l.text(),range:{start:{line:b.start.line,column:b.start.column},end:{line:b.end.line,column:b.end.column}},language:this.language};return El(f)}l=l.parent()}return null}findNodeAtPosition(e,r,i){let s=e.range(),n=r>s.start.line||r===s.start.line&&i>=s.start.column,a=r<s.end.line||r===s.end.line&&i<=s.end.column;if(!n||!a)return null;let o=e.children();for(let c of o){let l=this.findNodeAtPosition(c,r,i);if(l)return l}return e}};var Ti=class extends Error{constructor(e,r){super(`${e} is not supported: ${r}`),this.name="LanguageBackendNotSupportedError"}},Pi=class{astProvider;intelligenceProvider;language;constructor(e,r){this.language=r,this.astProvider=new bo(e,r)}async findMatches(e,r){if(!this.astProvider)throw new Ti("findMatches","no AST provider configured for this language");return await this.astProvider.findMatches(e,r)}async findDefinitions(e){if(!this.intelligenceProvider)throw new Ti("findDefinitions","no intelligence provider configured for this language");return await this.intelligenceProvider.findDefinitions(e)}async findReferences(e){if(!this.intelligenceProvider)throw new Ti("findReferences","no intelligence provider configured for this language");return await this.intelligenceProvider.findReferences(e)}async expandMatch(e){if(!this.astProvider)throw new Ti("expandMatch","no AST provider configured for this language");return await this.astProvider.expandMatch(e)}};var wo=class{environment;eventEmitter;constructor(e,r){this.environment=e,this.eventEmitter=r}async execute(e,r,i){let s=Date.now(),n=i.filePaths.filter(p=>T0(p)===r),c=(await new Pi(this.environment,r).findMatches(n,e)).map(p=>{if(NO.isAbsolute(p.file.path))throw new Error(`Match provider returned absolute path: ${p.file.path}. All file paths must be relative to workspace root.`);return{...p,language:r}}),l=i.previousMatches&&i.previousMatches.length>0?this.filterMatchesByRanges(c,i.previousMatches,r):c;l=this.deduplicateMatches(l);let u=Date.now()-s;return{matches:l,totalMatches:l.length,executionTime:u}}filterMatchesByRanges(e,r,i){let s=[];for(let n of e){let a=r.find(c=>this.isMatchInRange(n,c));if(!a)continue;let o=[...a.evidence||[],{file:a.file,text:a.text,range:a.range,language:a.language}];s.push({...n,evidence:o})}return s}isMatchInRange(e,r){if(e.file.path!==r.file.path)return!1;let i=e.range.start,s=e.range.end,n=r.range.start,a=r.range.end,o=i.line>n.line||i.line===n.line&&i.column>=n.column,c=s.line<a.line||s.line===a.line&&s.column<=a.column;return o&&c}deduplicateMatches(e){if(e.length<=1)return e;let r=[];for(let i of e)e.some(n=>i===n?!1:this.isMatchInRange(i,n))||r.push(i);return r}};var z0=We(lo(),1);import DO from"path";var xo=class{maxDepth=1;environment;eventEmitter;constructor(e,r){this.environment=e,this.eventEmitter=r||new nt}async execute(e,r,i={}){let s=Date.now(),n=new Pi(this.environment,r),a=await this.followDefinitions(e,n,this.maxDepth,i.where,r),o=Date.now()-s,c=a.map(l=>{let{depth:u,sourceMatch:p,...b}=l,f=p?[{file:p.file,text:p.text,range:p.range,language:p.language},...p.evidence||[]]:[];return{...b,source:f}});return{definitions:c,totalDefinitions:c.length,executionTime:o}}async followDefinitions(e,r,i,s,n){let a=[],o=new Set;for(let c of e)await this.followDefinitionsRecursive(c,r,0,i,s,a,o,c,n);return a}async followDefinitionsRecursive(e,r,i,s,n,a,o,c,l){if(i>=s)return;let u=`${e.file.path}:${e.range.start.line}:${e.range.start.column}`;if(o.has(u))return;o.add(u);let p=await r.findDefinitions(e);for(let b of p){let d={...await r.expandMatch(b)??b,language:l,depth:i,sourceMatch:c||e};n&&!this.matchesDefinitionFilter(d,n)||(a.push(d),i+1<s&&await this.followDefinitionsRecursive(b,r,i+1,s,n,a,o,c||e,l))}}matchesDefinitionFilter(e,r){return r.all?r.all.every(i=>this.matchesDefinitionFilter(e,i)):r.any?r.any.some(i=>this.matchesDefinitionFilter(e,i)):r.not?!this.matchesDefinitionFilter(e,r.not):!(r.file&&!this.matchesFileSpec(e.file.path,r.file)||r.function?.name)}matchesNameSpec(e,r){return r.equals?e===r.equals:r.anyOf?r.anyOf.includes(e):r.regex?new RegExp(r.regex).test(e):!0}matchesFileSpec(e,r){let i=DO.relative(this.environment.getWorkspaceRoot(),e);return r.path?i===r.path:r.glob?(0,z0.default)().add(r.glob).ignores(i):r.regex?new RegExp(r.regex).test(i):!0}};import{existsSync as MO}from"fs";import{dirname as kO,join as Eo}from"path";import{fileURLToPath as jO}from"url";var BO=jO(import.meta.url),_o=kO(BO);function W0(){let t=process.platform,e=process.arch,r;if(t==="linux"&&e==="x64")r="x64-linux";else if(t==="linux"&&e==="arm64")r="arm64-linux";else if(t==="darwin"&&e==="x64")r="x64-darwin";else if(t==="darwin"&&e==="arm64")r="arm64-darwin";else if(t==="win32"&&e==="x64")r="x64-win32";else throw new Error(`Unsupported platform: ${t}-${e}. Supported platforms: x64-linux, arm64-linux, x64-darwin, arm64-darwin, x64-win32`);let i=t==="win32"?"rg.exe":"rg",s=[Eo(_o,"powerlint/dist/vendor/ripgrep",r,i),Eo(_o,"../../dist/vendor/ripgrep",r,i),Eo(_o,"../vendor/ripgrep",r,i),Eo(_o,"./
|
|
57
|
+
`),o=[];for(let c of a){let l=c.match(/^([^:]+):(\d+):(.*)$/);if(l){let[,u,p,b]=l,f=u;f=Bt.relative(i,u);let d=Bt.join(i,f);try{if($i.existsSync(d)){let m=await Ps(d);o.push({file:f,line_number:parseInt(p,10),content:b,sha:m})}}catch{}}}return o}catch(n){let a=n;if(a.code===1&&!a.stderr)return[];throw a.signal==="SIGTERM"?new Error("rg search operation timed out"):n}}async function j0(t,e,r=[],i=P0()){let{pattern:s,include:n}=t,a=t.path?.startsWith("/")?t.path.slice(1):t.path;try{if(!await I0(i))throw new Error(`ripgrep is not found or not executable: ${i}`);let c=null;if(a){let p=yo(e,a);if(!p)return{error:`Invalid path: '${a}'. Please provide the correct path.`};if(!await po(p))return{error:`Path not found or not accessible: ${a}. Please provide the correct path.`};let b=await $i.promises.stat(p);if(b.isFile())c=D0(p),a=D0(a);else if(b.isDirectory())c=p;else return{error:`Path is neither a file nor a directory: ${a}`}}return{matches:(await IO(i,s,n,c||e)).filter(p=>{let b=a?M0(a,p.file):p.file;return!Ts(b,r)}).slice(0,50).map(p=>({...p,file:a?M0(a,p.file):p.file}))}}catch(o){let c=typeof o=="object"&&o!==null&&"message"in o&&typeof o.message=="string"?o.message:String(o);return{error:go(c,e)}}}async function B0(t,e,r=[]){let i=t.pattern,s=t.path;s&&i.startsWith(s)&&(i=i.replace(s,"")),i=i.startsWith("/")?i.slice(1):i;let n;if(s){if(s=s.startsWith("/")?s.slice(1):s,s!=="."&&Ts(s,r))return{files:[]};let a=yo(e,s);if(!a)return{error:`Path not found or not accessible: '${s}'. Please provide the correct path.`};n=a}else n=e;if(!await po(n))return{error:`Directory not found or not accessible: ${s||"."}. Please provide the correct path.`};try{if(!(await $i.promises.stat(n)).isDirectory())return{error:`Not a directory: ${s||"."}. Please provide the correct path.`}}catch{return{error:`Directory not found or not accessible: ${s||"."}. Please provide the correct path.`}}try{return{files:(await FO(i,s,e)).filter(c=>!Ts(c,r)).slice(0,50)}}catch(a){let o=typeof a=="object"&&a!==null&&"message"in a&&typeof a.message=="string"?a.message:String(a);return{error:go(o,e)}}}async function FO(t,e,r){try{let i;if(e){let a=e.startsWith("/")?e.slice(1):e,o=yo(r,a);if(!o)throw new Error(`Invalid directory path: potential directory traversal detected in '${a}'`);i=o}else i=r;let s=await Jt(t,{cwd:i,nodir:!0,ignore:["node_modules/**",".git/**","**/__pycache__/**"],absolute:!1}),n=[];for(let a of s)try{let o=Bt.join(i,a),c=await $i.promises.stat(o);c.isFile()&&n.push({path:e?Bt.join(e,a):a,mtime:c.mtime})}catch{}return n.sort((a,o)=>o.mtime.getTime()-a.mtime.getTime()),n.map(a=>a.path)}catch(i){let s=i instanceof Error?i.message:String(i);throw new Error(go(`Glob search failed: ${s}`,r))}}function U0(t){return{...t,range:{start:{line:t.range.start.line-1,column:t.range.start.column-1},end:{line:t.range.end.line-1,column:t.range.end.column-1}}}}function El(t){return{...t,range:{start:{line:t.range.start.line+1,column:t.range.start.column+1},end:{line:t.range.end.line+1,column:t.range.end.column+1}}}}var bo=class{environment;language;constructor(e,r){this.environment=e,this.language=r}async findMatches(e,r){if(e.length===0)return[];let{rule:i,constraints:s}=r,n=this.getBatchSize(),a=[];for(let o=0;o<e.length;o+=n){let c=e.slice(o,o+n),l=await this.processBatch(c,i,s);a.push(...l)}return a}getBatchSize(){let e=parseInt(process.env.UV_THREADPOOL_SIZE||"4",10);return Math.max(2,Math.floor(e/2))}async processBatch(e,r,i){let s=e.map(async c=>{let l=q0.resolve(this.environment.getWorkspaceRoot(),c),u=await G0(l,"utf-8"),b=(await(0,vo.parseAsync)(this.language,u)).root().findAll({rule:r,language:this.language,constraints:i});if(b.length===0)return[];let f=await Ps(l);return b.map(d=>({filePath:c,sgNode:d,sha:f}))}),a=(await Promise.all(s)).flat(),o=[];for(let{filePath:c,sgNode:l,sha:u}of a){let p=l.range(),b={file:{path:c,sha:u},text:l.text(),range:{start:{line:p.start.line,column:p.start.column},end:{line:p.end.line,column:p.end.column}},language:this.language};o.push(El(b))}return o}extractSymbol(e){let r=e.kind();if(r==="call_expression"){let i=e.field("function");if(i)return this.extractSymbol(i)}else if(r==="member_expression"){let i=e.field("property");if(i)return i.text()}else if(r==="identifier")return e.text()}async expandMatch(e){let r=new Set(["method_definition","function_declaration","function_expression","arrow_function","class_declaration","export_statement","lexical_declaration"]),i=q0.resolve(this.environment.getWorkspaceRoot(),e.file.path),[s,n]=await Promise.all([G0(i,"utf-8"),Ps(i)]),a=(0,vo.parse)(this.language,s).root(),o=U0(e),c=this.findNodeAtPosition(a,o.range.start.line,o.range.start.column);if(!c)return null;let l=c;for(;l;){let u=l.kind(),p=typeof u=="string"?u:String(u);if(r.has(p)){let b=l.range(),f={file:{path:e.file.path,sha:n},text:l.text(),range:{start:{line:b.start.line,column:b.start.column},end:{line:b.end.line,column:b.end.column}},language:this.language};return El(f)}l=l.parent()}return null}findNodeAtPosition(e,r,i){let s=e.range(),n=r>s.start.line||r===s.start.line&&i>=s.start.column,a=r<s.end.line||r===s.end.line&&i<=s.end.column;if(!n||!a)return null;let o=e.children();for(let c of o){let l=this.findNodeAtPosition(c,r,i);if(l)return l}return e}};var Ti=class extends Error{constructor(e,r){super(`${e} is not supported: ${r}`),this.name="LanguageBackendNotSupportedError"}},Pi=class{astProvider;intelligenceProvider;language;constructor(e,r){this.language=r,this.astProvider=new bo(e,r)}async findMatches(e,r){if(!this.astProvider)throw new Ti("findMatches","no AST provider configured for this language");return await this.astProvider.findMatches(e,r)}async findDefinitions(e){if(!this.intelligenceProvider)throw new Ti("findDefinitions","no intelligence provider configured for this language");return await this.intelligenceProvider.findDefinitions(e)}async findReferences(e){if(!this.intelligenceProvider)throw new Ti("findReferences","no intelligence provider configured for this language");return await this.intelligenceProvider.findReferences(e)}async expandMatch(e){if(!this.astProvider)throw new Ti("expandMatch","no AST provider configured for this language");return await this.astProvider.expandMatch(e)}};var wo=class{environment;eventEmitter;constructor(e,r){this.environment=e,this.eventEmitter=r}async execute(e,r,i){let s=Date.now(),n=i.filePaths.filter(p=>T0(p)===r),c=(await new Pi(this.environment,r).findMatches(n,e)).map(p=>{if(NO.isAbsolute(p.file.path))throw new Error(`Match provider returned absolute path: ${p.file.path}. All file paths must be relative to workspace root.`);return{...p,language:r}}),l=i.previousMatches&&i.previousMatches.length>0?this.filterMatchesByRanges(c,i.previousMatches,r):c;l=this.deduplicateMatches(l);let u=Date.now()-s;return{matches:l,totalMatches:l.length,executionTime:u}}filterMatchesByRanges(e,r,i){let s=[];for(let n of e){let a=r.find(c=>this.isMatchInRange(n,c));if(!a)continue;let o=[...a.evidence||[],{file:a.file,text:a.text,range:a.range,language:a.language}];s.push({...n,evidence:o})}return s}isMatchInRange(e,r){if(e.file.path!==r.file.path)return!1;let i=e.range.start,s=e.range.end,n=r.range.start,a=r.range.end,o=i.line>n.line||i.line===n.line&&i.column>=n.column,c=s.line<a.line||s.line===a.line&&s.column<=a.column;return o&&c}deduplicateMatches(e){if(e.length<=1)return e;let r=[];for(let i of e)e.some(n=>i===n?!1:this.isMatchInRange(i,n))||r.push(i);return r}};var z0=We(lo(),1);import DO from"path";var xo=class{maxDepth=1;environment;eventEmitter;constructor(e,r){this.environment=e,this.eventEmitter=r||new nt}async execute(e,r,i={}){let s=Date.now(),n=new Pi(this.environment,r),a=await this.followDefinitions(e,n,this.maxDepth,i.where,r),o=Date.now()-s,c=a.map(l=>{let{depth:u,sourceMatch:p,...b}=l,f=p?[{file:p.file,text:p.text,range:p.range,language:p.language},...p.evidence||[]]:[];return{...b,source:f}});return{definitions:c,totalDefinitions:c.length,executionTime:o}}async followDefinitions(e,r,i,s,n){let a=[],o=new Set;for(let c of e)await this.followDefinitionsRecursive(c,r,0,i,s,a,o,c,n);return a}async followDefinitionsRecursive(e,r,i,s,n,a,o,c,l){if(i>=s)return;let u=`${e.file.path}:${e.range.start.line}:${e.range.start.column}`;if(o.has(u))return;o.add(u);let p=await r.findDefinitions(e);for(let b of p){let d={...await r.expandMatch(b)??b,language:l,depth:i,sourceMatch:c||e};n&&!this.matchesDefinitionFilter(d,n)||(a.push(d),i+1<s&&await this.followDefinitionsRecursive(b,r,i+1,s,n,a,o,c||e,l))}}matchesDefinitionFilter(e,r){return r.all?r.all.every(i=>this.matchesDefinitionFilter(e,i)):r.any?r.any.some(i=>this.matchesDefinitionFilter(e,i)):r.not?!this.matchesDefinitionFilter(e,r.not):!(r.file&&!this.matchesFileSpec(e.file.path,r.file)||r.function?.name)}matchesNameSpec(e,r){return r.equals?e===r.equals:r.anyOf?r.anyOf.includes(e):r.regex?new RegExp(r.regex).test(e):!0}matchesFileSpec(e,r){let i=DO.relative(this.environment.getWorkspaceRoot(),e);return r.path?i===r.path:r.glob?(0,z0.default)().add(r.glob).ignores(i):r.regex?new RegExp(r.regex).test(i):!0}};import{existsSync as MO}from"fs";import{dirname as kO,join as Eo}from"path";import{fileURLToPath as jO}from"url";var BO=jO(import.meta.url),_o=kO(BO);function W0(){let t=process.platform,e=process.arch,r;if(t==="linux"&&e==="x64")r="x64-linux";else if(t==="linux"&&e==="arm64")r="arm64-linux";else if(t==="darwin"&&e==="x64")r="x64-darwin";else if(t==="darwin"&&e==="arm64")r="arm64-darwin";else if(t==="win32"&&e==="x64")r="x64-win32";else throw new Error(`Unsupported platform: ${t}-${e}. Supported platforms: x64-linux, arm64-linux, x64-darwin, arm64-darwin, x64-win32`);let i=t==="win32"?"rg.exe":"rg",s=[Eo(_o,"powerlint/dist/vendor/ripgrep",r,i),Eo(_o,"../../dist/vendor/ripgrep",r,i),Eo(_o,"../vendor/ripgrep",r,i),Eo(_o,"./vendor/ripgrep",r,i)];for(let n of s)if(MO(n))return n;throw new Error(`Bundled ripgrep binary not found for platform ${r}. Tried paths:
|
|
58
58
|
${s.join(`
|
|
59
59
|
`)}`)}import{readFile as UO}from"fs/promises";import GO from"path";async function _l(t,e,r,i=!1){let s=GO.resolve(t,e),a=(await UO(s,"utf-8")).split(`
|
|
60
60
|
`),{start:o,end:c}=r,l=o.line-1,u=c.line-1;if(o.line===c.line){let b=a[l]||"";return i?b.substring(o.column-1,c.column-1):b}let p=[];for(let b=l;b<=u&&b<a.length;b++){let f=a[b];b===l?p.push(i?f.substring(o.column-1):f):b===u?p.push(i?f.substring(0,c.column-1):f):p.push(f)}return p.join(`
|