@magic5644/graph-it-live 1.16.0 → 1.16.1
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/dist/graph-it.js +4 -4
- package/package.json +7 -1
package/dist/graph-it.js
CHANGED
|
@@ -46289,7 +46289,7 @@ ${b2}tip:${nE} Type ${PBt}/${nE} for follow-up actions.${ee}`,h)}catch(Te){if(Te
|
|
|
46289
46289
|
`)}else{let{run:N}=await Promise.resolve().then(()=>(YEe(),XEe)),z=await WO("explain",[u],o,d.preferredFormat,N);d.lastFile=u,d.lastSymbol=void 0,d.lastResult=z.rawData??z.output;let ee=z.output??"";process.stdout.write(ee.endsWith(`
|
|
46290
46290
|
`)?ee:`${ee}
|
|
46291
46291
|
`)}}catch(N){N instanceof qne||process.stderr.write(`Error: ${YPe(N)}
|
|
46292
|
-
`)}}var hv,Bse,Rnn,XPe,b2,PBt,nE,Udt,MEn,LEn,OEn,NBt,FEn,Mnn,znn=li(()=>{"use strict";hv=cc(require("node:path")),Bse=require("node:fs");MHt();Yae();h2();Im();jC();SJ();fKt();_Kt();SFt();gKt();TFt();AKt();Rnn="1.16.
|
|
46292
|
+
`)}}var hv,Bse,Rnn,XPe,b2,PBt,nE,Udt,MEn,LEn,OEn,NBt,FEn,Mnn,znn=li(()=>{"use strict";hv=cc(require("node:path")),Bse=require("node:fs");MHt();Yae();h2();Im();jC();SJ();fKt();_Kt();SFt();gKt();TFt();AKt();Rnn="1.16.1",XPe=!process.env.NO_COLOR&&process.stdout.isTTY,b2=XPe?"\x1B[2m":"",PBt=XPe?"\x1B[1m":"",nE=XPe?"\x1B[0m":"",Udt=XPe?"\x1B[38;5;33m":"",MEn=XPe?"\x1B[38;5;214m":"",LEn=XPe?"\x1B[38;5;117m":"",OEn=`Interactive mode unavailable (no TTY).
|
|
46293
46293
|
Use direct commands: graph-it --help
|
|
46294
46294
|
`,NBt={uiMode:"legacy"},FEn={uiMode:"ink"},Mnn={architecture:()=>Promise.resolve().then(()=>(FJe(),OJe)),summary:()=>Promise.resolve().then(()=>(Edt(),Tdt)),check:()=>Promise.resolve().then(()=>(Adt(),Cdt)),path:()=>Promise.resolve().then(()=>(Ddt(),Idt)),pathIn:()=>Promise.resolve().then(()=>(Pdt(),kdt)),checkDependencies:()=>Promise.resolve().then(()=>(WJe(),BJe)),cycles:()=>Promise.resolve().then(()=>(wdt(),Ndt)),trace:()=>Promise.resolve().then(()=>(KPe(),$Pe)),explain:()=>Promise.resolve().then(()=>(YEe(),XEe)),scan:()=>Promise.resolve().then(()=>(yBt(),gBt)),query:()=>Promise.resolve().then(()=>(Fdt(),Odt)),wiki:()=>Promise.resolve().then(()=>(jdt(),zdt))}});var jnn={};pv(jnn,{getCommandHelp:()=>I1n});function I1n(u){return C1n[u]??`Unknown command "${u}".
|
|
46295
46295
|
|
|
@@ -46667,15 +46667,15 @@ Run "npm run build:cli" first.`,Yp.GENERAL_ERROR);let T=qdt.platform(),N=await z
|
|
|
46667
46667
|
Add ${d} to your PATH if needed.`}function V1n(u,o){let d=Wse.dirname(o);S2.mkdirSync(d,{recursive:!0});let h=`@echo off
|
|
46668
46668
|
node "${u}" %*
|
|
46669
46669
|
`,m=o.endsWith(".cmd")?o:o+".cmd";return S2.writeFileSync(m,h,"utf-8"),`\u2713 graph-it installed to ${m}
|
|
46670
|
-
Ensure ${d} is in your PATH.`}var S2,Wse,qdt,trn,rrn=li(()=>{"use strict";S2=cc(require("node:fs")),Wse=cc(require("node:path")),qdt=cc(require("node:os")),trn=cc(require("node:readline"));_2()});var orn={};pv(orn,{run:()=>H1n});function U1n(u){let o=["install","--global",`${irn}@${u}`];try{(0,FBt.execFileSync)("npm",o,{stdio:"inherit"});return}catch(d){if(!(d?.code==="ENOENT"||d instanceof Error&&d.message.includes("spawnSync npm ENOENT")))throw d}(0,FBt.execFileSync)("npm.cmd",o,{stdio:"inherit"})}async function H1n(u,o,d){let h="1.16.
|
|
46670
|
+
Ensure ${d} is in your PATH.`}var S2,Wse,qdt,trn,rrn=li(()=>{"use strict";S2=cc(require("node:fs")),Wse=cc(require("node:path")),qdt=cc(require("node:os")),trn=cc(require("node:readline"));_2()});var orn={};pv(orn,{run:()=>H1n});function U1n(u){let o=["install","--global",`${irn}@${u}`];try{(0,FBt.execFileSync)("npm",o,{stdio:"inherit"});return}catch(d){if(!(d?.code==="ENOENT"||d instanceof Error&&d.message.includes("spawnSync npm ENOENT")))throw d}(0,FBt.execFileSync)("npm.cmd",o,{stdio:"inherit"})}async function H1n(u,o,d){let h="1.16.1";process.stdout.write(`Current version : v${h}
|
|
46671
46671
|
`),process.stdout.write(`Checking npm registry for ${irn}\u2026
|
|
46672
46672
|
`);let m;try{m=await uOt(1e4)}catch(T){let N=T instanceof Error?T.message:String(T);throw new Am(N,Yp.GENERAL_ERROR)}if(m===h)return`\u2713 Already up to date (v${h})`;process.stdout.write(`Latest version : v${m}
|
|
46673
46673
|
Installing update\u2026
|
|
46674
46674
|
`);try{U1n(m)}catch(T){let N=T instanceof Error?T.message:String(T);throw new Am(`npm install failed: ${N}`,Yp.GENERAL_ERROR)}return`\u2713 Updated graph-it-live to v${m}`}var FBt,irn,arn=li(()=>{"use strict";FBt=require("node:child_process");_2();pOt();irn="@magic5644/graph-it-live"});var frn={};pv(frn,{run:()=>X1n});function urn(u){return u.replaceAll("|",String.raw`\|`)}function J1n(u){let o=u.indexOf("--stats-dir");if(o>=0&&u[o+1])return u[o+1]}function $1n(){return{sessions:0,calls:0,jsonTokens:0,toonTokens:0,savings:0,truncations:0,llmCalls:0,llmTokensUsed:0}}function drn(u){let o={};for(let d of u){let h=o[d.source]??=$1n();h.sessions+=1,h.calls+=d.totals.calls,h.jsonTokens+=d.totals.jsonTokens,h.toonTokens+=d.totals.toonTokens,h.savings+=d.totals.savings,h.truncations+=d.totals.truncations,h.llmCalls+=d.llmUsage.calls,h.llmTokensUsed+=d.llmUsage.tokensUsed}return o}function prn(u){let o={};for(let d of u)for(let[h,m]of Object.entries(d.byTool)){o[h]??={calls:0,jsonTokens:0,toonTokens:0,savings:0,truncations:0};let T=o[h];T.calls+=m.calls,T.jsonTokens+=m.jsonTokens,T.toonTokens+=m.toonTokens,T.savings+=m.savings,T.truncations+=m.truncations}return o}function srn(u){let o=["| Tool | Calls | JSON tokens | TOON tokens | Delta |","|------|-------|-------------|-------------|-------|"],d=Object.keys(u).sort((h,m)=>h.localeCompare(m));for(let h of d){let m=u[h];o.push(`| ${urn(h)} | ${m.calls} | ${m.jsonTokens} | ${m.toonTokens} | ${m.savings} |`)}return o}function K1n(u){let o=["| Source | Sessions | Calls | JSON tokens | TOON tokens | Delta | LLM calls | LLM tokens (real) |","|--------|----------|-------|-------------|-------------|-------|-----------|-------------------|"],d=Object.keys(u).sort((h,m)=>h.localeCompare(m));for(let h of d){let m=u[h];m&&o.push(`| ${urn(h)} | ${m.sessions} | ${m.calls} | ${m.jsonTokens} | ${m.toonTokens} | ${m.savings} | ${m.llmCalls} | ${m.llmTokensUsed} |`)}return o}function q1n(u,o){let d=[`# ${crn}`,"",`All JSON/TOON token counts are ${BBt}.`,"","## Current session",""],h=u.totals.calls===0?["(no TOON-encoded responses recorded in this session)"]:[...srn(u.byTool),"",`Totals: ${u.totals.calls} calls, JSON ${u.totals.jsonTokens} tokens vs TOON ${u.totals.toonTokens} tokens (delta ${u.totals.savings}, ${BBt}).`],m=u.llmUsage.calls===0?["(no LLM calls recorded in this session)"]:[`LLM calls: ${u.llmUsage.calls}, tokens used: ${u.llmUsage.tokensUsed} (real, provider-reported).`],T=o.length===0?["(no persisted sessions found)"]:["### By source","",...K1n(drn(o)),"","### By tool","",...srn(prn(o))];return d.concat(h,"","## llmUsage (current session)","",m,"",lrn,"","## History (persisted sessions)","",T).join(`
|
|
46675
46675
|
`)}async function X1n(u,o,d){let h=J1n(u),m=_B.snapshot(),T=b2t(h);return d==="json"?JSON.stringify({description:crn,estimationNote:BBt,llmUsageNote:lrn,currentSession:m,history:{persistedSessions:T.length,bySource:drn(T),byTool:prn(T)}},null,2):q1n(m,T)}var crn,BBt,lrn,mrn=li(()=>{"use strict";utt();NTe();crn="TOON encoding size vs JSON equivalent",BBt="estimated (chars/4 heuristic)",lrn="llmUsage: real provider-reported tokens \u2014 reported separately, never summed into the estimated totals above."});var txn={};pv(txn,{commandWantsHelp:()=>brn,createRuntime:()=>GBt,findCommandStart:()=>vrn});module.exports=Irn(txn);var zBt=cc(require("node:path")),hrn=require("node:util");utt();NTe();_2();h2();var pP=cc(require("node:fs")),xT=cc(require("node:path"));var n9t=cc(require("node:fs")),VDe=cc(require("node:path")),r9t=require("node:worker_threads");jC();var Fne=Uh("AstWorkerHost"),qae=class{worker=null;nextId=1;pendingRequests=new Map;workerPath;extensionPath;isStopping=!1;isDisposed=!1;stopPromise=null;constructor(o,d){if(this.extensionPath=d,o)this.workerPath=o;else{let h=[VDe.join(__dirname,"astWorker.js"),VDe.join(__dirname,"../../../dist/astWorker.js"),VDe.join(__dirname,"../../../../dist/astWorker.js"),VDe.join(process.cwd(),"dist/astWorker.js")],m="";for(let T of h)if(n9t.existsSync(T)){m=T;break}this.workerPath=m||VDe.join(process.cwd(),"dist/astWorker.js")}}async start(){if(this.isDisposed)throw new Error("AstWorker has been stopped");if(this.worker||this.isStopping){Fne.warn("AstWorker already started");return}Fne.info(`Starting AstWorker from ${this.workerPath}`);try{this.worker=new r9t.Worker(this.workerPath,{workerData:{extensionPath:this.extensionPath}}),this.worker.on("message",o=>{this.handleResponse(o)}),this.worker.on("error",o=>{Fne.error("AstWorker error:",o);for(let[d,h]of this.pendingRequests)h.reject(new Error(`AstWorker crashed: ${o.message}`)),this.pendingRequests.delete(d)}),this.worker.on("exit",o=>{o!==0&&!this.isStopping&&Fne.error(`AstWorker exited with code ${o}`),this.worker=null,this.stopPromise||(this.isStopping=!1)}),Fne.info("AstWorker started successfully")}catch(o){let d=o instanceof Error?o.message:String(o);throw Fne.error(`Failed to start AstWorker: ${d}`),new Error(`Failed to start AstWorker: ${d}`,{cause:o})}}stop(){if(this.isDisposed=!0,this.stopPromise)return this.stopPromise;let o=this.worker;if(!o)return Promise.resolve();Fne.debug("Stopping AstWorker");for(let[d,h]of this.pendingRequests)h.reject(new Error("AstWorker stopped")),this.pendingRequests.delete(d);return this.isStopping=!0,this.stopPromise=o.terminate().then(()=>{}).finally(()=>{this.worker===o&&(this.worker=null),this.isStopping=!1,this.stopPromise=null,Fne.debug("AstWorker stopped")}),this.stopPromise}async analyzeFile(o,d){return await this.sendRequest({type:"analyzeFile",id:0,filePath:o,content:d})}async getInternalExportDependencyGraph(o,d){let m=await this.sendRequest({type:"getInternalExportDeps",id:0,filePath:o,content:d});return new Map(Object.entries(m).map(([T,N])=>[T,new Set(N)]))}async extractSignatures(o,d){return await this.sendRequest({type:"extractSignatures",id:0,filePath:o,content:d})}async extractInterfaceMembers(o,d){let m=await this.sendRequest({type:"extractInterfaceMembers",id:0,filePath:o,content:d});return new Map(Object.entries(m))}async extractTypeAliases(o,d){return await this.sendRequest({type:"extractTypeAliases",id:0,filePath:o,content:d})}async compareSignatures(o,d){return await this.sendRequest({type:"compareSignatures",id:0,oldSig:o,newSig:d})}async analyzeBreakingChanges(o,d,h){return await this.sendRequest({type:"analyzeBreakingChanges",id:0,filePath:o,oldContent:d,newContent:h})}async reset(){await this.sendRequest({type:"reset",id:0})}async getFileCount(){return await this.sendRequest({type:"getFileCount",id:0})}async sendRequest(o){if(this.isDisposed)throw new Error("AstWorker has been stopped");if(this.worker||await this.start(),this.isDisposed)throw new Error("AstWorker has been stopped");let d=this.nextId++,h={...o,id:d};return new Promise((m,T)=>{this.pendingRequests.set(d,{resolve:m,reject:T}),this.worker?.postMessage(h)})}handleResponse(o){let d=this.pendingRequests.get(o.id);if(!d){Fne.warn(`Received response for unknown request ${o.id}`);return}if(this.pendingRequests.delete(o.id),o.type==="success")d.resolve(o.result);else{let h=new Error(o.error);o.stack&&(h.stack=o.stack),d.reject(h)}}};var FTe=cc(require("node:fs/promises")),Ttt=cc(require("node:fs"));GC();jC();var Rin=Uh("FileReader"),Min=5*1024*1024,Lin=64*1024,Oin=3e4,W1=class{maxSize;chunkSize;timeout;constructor(o={}){this.maxSize=o.maxSize??Min,this.chunkSize=o.chunkSize??Lin,this.timeout=o.timeout??Oin}async getFileSize(o){try{let d=await FTe.stat(o);return{size:d.size,isLarge:d.size>this.maxSize,path:o}}catch(d){throw pg.fromError(d,o)}}async readFile(o,d){let h=d?.maxSize??this.maxSize,m=d?.timeout??this.timeout,T=d?.streaming??!1,N;try{N=await FTe.stat(o)}catch(pe){throw pg.fromError(pe,o)}if(N.size>h)throw new pg(`File too large: ${o} (${this.formatSize(N.size)} > ${this.formatSize(h)})`,"FILE_TOO_LARGE",{filePath:o});let z,ee=new Promise((pe,Te)=>{z=setTimeout(()=>{Te(new pg(`File read timed out after ${m}ms: ${o}`,"TIMEOUT",{filePath:o}))},m)});try{let pe;return T||N.size>1024*1024?(Rin.debug(`Streaming read for large file: ${o} (${this.formatSize(N.size)})`),pe=await Promise.race([this.readFileStreaming(o),ee])):pe=await Promise.race([FTe.readFile(o,"utf-8"),ee]),clearTimeout(z),pe}catch(pe){throw clearTimeout(z),pe instanceof pg?pe:pg.fromError(pe,o)}}async readFileStreaming(o){return new Promise((d,h)=>{let m=[],T=Ttt.createReadStream(o,{highWaterMark:this.chunkSize});T.on("data",N=>{m.push(Buffer.isBuffer(N)?N:Buffer.from(N))}),T.on("end",()=>{let N=Buffer.concat(m).toString("utf-8");d(N)}),T.on("error",N=>{h(pg.fromError(N,o))})})}async readFileIfExists(o){try{return await this.readFile(o)}catch(d){if(d instanceof pg&&d.code==="FILE_NOT_FOUND")return null;throw d}}async canRead(o){try{return await FTe.access(o,Ttt.constants.R_OK),!0}catch{return!1}}formatSize(o){return o<1024?`${o}B`:o<1024*1024?`${(o/1024).toFixed(1)}KB`:`${(o/(1024*1024)).toFixed(1)}MB`}};jC();function VC(u){let d=/^(.+\.(ts|tsx|js|jsx|mjs|cjs|py|pyi|rs|vue|svelte|gql|graphql)):(.+)$/i.exec(u);if(!d)return u;let h=d[1];return d[3]?(h.length>1&&h[1]===":"&&/^[a-zA-Z]:/.test(h),Uh("PathExtractor").warn(`Symbol ID detected where file path expected: ${u}. Extracting file path: ${h}`),h):u}var Xae=cc(require("node:fs/promises")),_f=cc(require("node:path"));UDe();Bne();GC();var oJ=class{pathAliases=new Map;tsConfigPromise;tsConfigPath;isConfigLoaded=!1;excludeNodeModules;workspaceRoot;directoryToPackageJson=new Map;directoryToTsConfig=new Map;tsConfigPathAliases=new Map;packageJsonImports=new Map;packageJsonLoadPromises=new Map;tsConfigLoadPromises=new Map;constructor(o,d=!0,h){this.excludeNodeModules=d,this.tsConfigPath=o,this.workspaceRoot=h??(o?_f.dirname(o):void 0)}updateConfig(o){this.excludeNodeModules=o}async ensureTsConfigLoaded(){this.isConfigLoaded||!this.tsConfigPath||(this.tsConfigPromise??=this.loadTsConfig(this.tsConfigPath),await this.tsConfigPromise,this.tsConfigPromise=void 0,this.isConfigLoaded=!0)}async loadTsConfig(o){try{let d=await Xae.readFile(o,"utf-8"),h=JSON.parse(d),m=h?.compilerOptions?.paths,T=h?.compilerOptions?.baseUrl||".";if(m)for(let[N,z]of Object.entries(m)){let ee=N.replace(/\/\*$/,""),pe=z[0]?.replace(/\/\*$/,"");if(pe){let Te=_f.dirname(o),Ke=_f.resolve(Te,T,pe);this.pathAliases.set(ee,ri(Ke))}}}catch{}}async tryTsConfigAliases(o,d){let h=this.resolveAlias(d);if(h)return this.resolveWithExtensions(h);let m=await this.resolveDynamicTsConfigAlias(o,d);return m?this.resolveWithExtensions(m):null}async tryPythonImports(o,d){if(!this.isPythonFile(o))return null;if(this.isPythonRelativeImport(d)){let h=await this.resolvePythonRelativeImport(o,d);if(h)return h}if(d.includes(".")&&!d.includes("/")){let h=await this.resolvePythonModule(o,d);if(h)return h}return null}async trySpecialModulePatterns(o,d){if(this.isSubpathImport(d))return this.resolveSubpathImport(o,d);let h=await this.resolveRustModule(o,d);return h||(this.isPackageJsonAliasCandidate(d)?this.resolveScopedPackage(o,d):null)}async tryRelativePath(o,d){if(!this.isRelativePath(d))return null;let h=_f.dirname(o),m=_f.resolve(h,d);if(this.isPythonFile(o)&&!this.hasFileExtension(d)){let T=await this.resolveWithExtensions(m);if(T)return T}return this.resolveWithExtensions(m)}keepWithinWorkspace(o){return!o||!this.workspaceRoot||!_f.isAbsolute(o)||ZF(o,this.workspaceRoot)?o:null}isWithinWorkspace(o){return this.keepWithinWorkspace(o)!==null}async resolve(o,d){await this.ensureTsConfigLoaded();let h=await this.tryTsConfigAliases(o,d);if(h)return this.keepWithinWorkspace(h);let m=await this.trySpecialModulePatterns(o,d);if(m)return this.keepWithinWorkspace(m);let T=await this.tryPythonImports(o,d);return T?this.keepWithinWorkspace(T):this.isNodeModule(d)?this.excludeNodeModules?null:d:this.keepWithinWorkspace(await this.tryRelativePath(o,d))}async resolveSubpathImport(o,d){let h=await this.resolvePackageJsonImport(o,d);return h?this.resolveWithExtensions(h):null}async resolveScopedPackage(o,d){let h=await this.resolvePackageJsonImport(o,d);if(h)return this.resolveWithExtensions(h);let m=await this.resolveWorkspacePackage(o,d);return m||(this.excludeNodeModules?null:d)}async resolveDynamicTsConfigAlias(o,d){if(!this.isPackageJsonAliasCandidate(d))return null;let h=await this.findNearestTsConfig(o);if(!h)return null;let m=await this.getTsConfigPathAliases(h);for(let[T,N]of m.entries())if(d===T||d.startsWith(T+"/")){let z=d.replace(T,N);return ri(z)}return null}async findNearestTsConfig(o){let d=_f.dirname(o);return this.directoryToTsConfig.has(d)?this.directoryToTsConfig.get(d)??null:await this.searchTsConfigUpward(d)}async searchTsConfigUpward(o){let d=[],h=o;for(;!this.shouldStopSearch(h);){d.push(h);let m=this.directoryToTsConfig.get(h);if(m!==void 0)return this.cacheTsConfigResultForDirs(d,m),m;let T=_f.join(h,"tsconfig.json");if(await this.fileExists(T))return this.cacheTsConfigResultForDirs(d,T),T;let z=_f.dirname(h);if(z===h)break;h=z}return this.cacheTsConfigResultForDirs(d,null),null}cacheTsConfigResultForDirs(o,d){for(let h of o)this.directoryToTsConfig.set(h,d)}async getTsConfigPathAliases(o){let d=this.tsConfigPathAliases.get(o);if(d!==void 0)return d;let h=this.tsConfigLoadPromises.get(o);if(h!==void 0)return h;let m=this.loadTsConfigPathAliases(o);this.tsConfigLoadPromises.set(o,m);try{let T=await m;return this.tsConfigPathAliases.set(o,T),T}finally{this.tsConfigLoadPromises.delete(o)}}async loadTsConfigPathAliases(o){let d=new Map,h=new Set;return await this.loadTsConfigPathAliasesRecursive(o,d,h),d}async loadTsConfigPathAliasesRecursive(o,d,h){let m=_f.resolve(o);if(!h.has(m)){h.add(m);try{let T=await Xae.readFile(o,"utf-8"),N=JSON.parse(T),z=_f.dirname(o);if(N.extends){let Te=_f.resolve(z,N.extends),Ke=Te.endsWith(".json")?Te:Te+".json",ce=await this.fileExists(Ke)?Ke:Te;await this.fileExists(ce)&&await this.loadTsConfigPathAliasesRecursive(ce,d,h)}let ee=N?.compilerOptions?.paths,pe=N?.compilerOptions?.baseUrl||".";if(ee)for(let[Te,Ke]of Object.entries(ee)){let ce=Te.replace(/\/\*$/,""),Bt=Ke[0]?.replace(/\/\*$/,"");if(Bt){let tt=_f.resolve(z,pe,Bt);d.set(ce,ri(tt))}}}catch{}}}resolveAlias(o){for(let[d,h]of this.pathAliases.entries())if(o===d||o.startsWith(d+"/"))return o.replace(d,h);return null}async resolveWithExtensions(o){let d=xtt;if(await this.fileExists(o))return ri(o);let h=await this.resolveEmittedExtension(o);if(h)return h;for(let m of d){let T=o+m;if(await this.fileExists(T))return ri(T)}for(let m of d){let T=_f.join(o,`index${m}`);if(await this.fileExists(T))return ri(T)}return null}async resolveEmittedExtension(o){let d={".js":[".ts",".tsx"],".jsx":[".tsx"],".mjs":[".mts"],".cjs":[".cts"]},h=_f.extname(o).toLowerCase(),m=d[h];if(!m)return null;let T=o.slice(0,-h.length);for(let N of m){let z=T+N;if(await this.fileExists(z))return ri(z)}return null}async fileExists(o){try{return(await Xae.stat(o)).isFile()}catch{return!1}}isRelativePath(o){return o.startsWith("./")||o.startsWith("../")}async resolveRustModule(o,d){if(!o.endsWith(".rs")||d.startsWith(".")||d.startsWith("@")||d.startsWith("#")||d.startsWith("/")||!/^\w+(?:::\w+)*$/u.test(d))return null;let m=_f.dirname(o),T=d.replaceAll("::",_f.sep),N=[_f.join(m,`${T}.rs`),_f.join(m,T,"mod.rs")];for(let z of N)if(await this.fileExists(z))return ri(z);return null}isNodeModule(o){return!o.startsWith(".")&&!o.startsWith("/")&&!o.startsWith("#")&&!o.startsWith("@")}isSubpathImport(o){return o.startsWith("#")}isPackageJsonAliasCandidate(o){return o.startsWith("@")}isPythonFile(o){return Ett.some(d=>o.endsWith(d))}hasFileExtension(o){let d=_f.basename(o);return d.includes(".")&&!d.startsWith(".")}isPythonRelativeImport(o){return(o.startsWith(".")||o.startsWith(".."))&&!o.includes("/")&&o!=="."&&o!==".."}async resolvePythonRelativeImport(o,d){let h=_f.dirname(o),m=0,T=d;for(;T.startsWith(".");)m++,T=T.substring(1);let N=h;for(let z=1;z<m;z++)N=_f.dirname(N);if(T){let z=_f.join(N,T+".py");if(await this.fileExists(z))return ri(z);let ee=_f.join(N,T,"__init__.py");if(await this.fileExists(ee))return ri(ee)}return null}async resolvePythonModule(o,d){let h=d.replaceAll(".","/"),m=_f.dirname(o),T=this.workspaceRoot||m,N=m;for(;;){let z=_f.resolve(N,h+".py");if(await this.fileExists(z))return ri(z);let ee=_f.resolve(N,h,"__init__.py");if(await this.fileExists(ee))return ri(ee);if(ri(N)===ri(T))break;let pe=_f.dirname(N);if(pe===N)break;N=pe}return null}async resolvePackageJsonImport(o,d){let h=await this.findNearestPackageJson(o);if(!h)return null;let m=await this.getPackageJsonImports(h),T=_f.dirname(h),N=m.get(d);if(N!==void 0)return ri(_f.resolve(T,N));for(let[z,ee]of m.entries())if(z.endsWith("/*")){let pe=z.slice(0,-2);if(d.startsWith(pe+"/")){let Te=d.slice(pe.length+1),Ke=ee.endsWith("/*")?ee.slice(0,-2):ee,ce=_f.resolve(T,Ke,Te);return ri(ce)}}return null}async findNearestPackageJson(o){let d=_f.dirname(o);return this.directoryToPackageJson.has(d)?this.directoryToPackageJson.get(d)??null:await this.searchPackageJsonUpward(d)}async searchPackageJsonUpward(o){let d=[],h=o;for(;!this.shouldStopSearch(h);){d.push(h);let m=this.directoryToPackageJson.get(h);if(m!==void 0)return this.cacheResultForDirs(d,m),m;let T=_f.join(h,"package.json");if(await this.fileExists(T))return this.cacheResultForDirs(d,T),T;let N=_f.dirname(h);if(N===h)break;h=N}return this.cacheResultForDirs(d,null),null}shouldStopSearch(o){return!!(this.workspaceRoot&&o===_f.dirname(this.workspaceRoot))}cacheResultForDirs(o,d){for(let h of o)this.directoryToPackageJson.set(h,d)}async getPackageJsonImports(o){let d=this.packageJsonImports.get(o);if(d!==void 0)return d;let h=this.packageJsonLoadPromises.get(o);if(h!==void 0)return h;let m=this.loadPackageJsonImports(o);this.packageJsonLoadPromises.set(o,m);try{let T=await m;return this.packageJsonImports.set(o,T),T}finally{this.packageJsonLoadPromises.delete(o)}}async loadPackageJsonImports(o){let d=new Map;try{let h=await Xae.readFile(o,"utf-8"),m=JSON.parse(h);this.parseImportsField(m?.imports,d),this.parseAliasesField(m?.aliases,d)}catch{}return d}parseImportsField(o,d){if(!(!o||typeof o!="object"))for(let[h,m]of Object.entries(o)){let T=this.resolveImportTarget(m);T&&d.set(h,T)}}resolveImportTarget(o){if(typeof o=="string")return o;if(typeof o=="object"&&o!==null){let d=o,h=d.default??d.import??d.require??d.node;if(typeof h=="string")return h}return null}parseAliasesField(o,d){if(!(!o||typeof o!="object"))for(let[h,m]of Object.entries(o))typeof m=="string"&&d.set(h,m)}async resolveWorkspacePackage(o,d){if(!d.startsWith("@"))return null;let m=/^@([^/]+)\/([^/]+)(\/.*)?$/.exec(d);if(!m)return null;let[,,T,N]=m,z=d.split("/").slice(0,2).join("/"),ee=await this.resolveFileDependency(o,z);if(ee)return this.resolvePackageEntry(ee,d,N);if(this.workspaceRoot){let pe=await this.findWorkspacePackageDir(T);if(pe)return this.resolvePackageEntry(pe,d,N)}return null}async resolveFileDependency(o,d){let m=_f.dirname(o);for(;!this.shouldStopSearch(m);){let T=_f.join(m,"package.json");if(await this.fileExists(T)){let z=await this.findFileDependencyInPackageJson(T,d);if(z)return z}let N=_f.dirname(m);if(N===m)break;m=N}return null}async findFileDependencyInPackageJson(o,d){try{let h=await Xae.readFile(o,"utf-8"),m=JSON.parse(h),T=_f.dirname(o),z={...m.dependencies,...m.devDependencies,...m.peerDependencies}[d];if(typeof z=="string"&&z.startsWith("file:")){let ee=z.slice(5),pe=_f.resolve(T,ee),Te=ri(pe),Ke=_f.join(pe,"package.json");if(await this.fileExists(Ke))return Te}}catch{}return null}async findWorkspacePackageDir(o){if(!this.workspaceRoot)return null;let d=["packages","libs","modules"];for(let h of d){let m=_f.join(this.workspaceRoot,h,o),T=_f.join(m,"package.json");if(await this.fileExists(T))return m}return null}async resolvePackageEntry(o,d,h){let m=_f.join(o,"package.json");try{let T=await Xae.readFile(m,"utf-8"),N=JSON.parse(T),z=d.split("/").slice(0,2).join("/"),ee=d.split("/").slice(1,2).join("/"),pe=N.name;if(pe!==z&&pe!==ee)return null;if(h){let Te=N.source?_f.dirname(N.source):"src",Ke=_f.join(o,Te,h);return this.resolveWithExtensions(Ke)}return this.findPackageEntryPoint(o,N)}catch{return null}}async findPackageEntryPoint(o,d){let h=d.main||d.module||"index",m=[_f.join(o,"src","index"),_f.join(o,h),_f.join(o,"index")];for(let T of m){let N=await this.resolveWithExtensions(T);if(N)return N}return null}};var $De=class u{fileReader;pathResolver;static STRIP_COMMENTS_RE=(()=>{let o=/'[^']*'|"[^"]*"/,d=/\/\/[^\n]*|\/\*[\s\S]*?\*\//;return new RegExp(`(${o.source})|(${d.source})`,"g")})();ignoreTypeImports;constructor(o,d){this.fileReader=new W1,this.pathResolver=new oJ(o),this.ignoreTypeImports=d??!1}patterns={importFrom:/import\s+(?:[^;'"]|'[^']*'|"[^"]*")*?\s+from\s+['"]([^'"]+)['"]/g,exportFrom:/export\s+(?:[^;'"]|'[^']*'|"[^"]*")*?\s+from\s+['"]([^'"]+)['"]/g,require:/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g,dynamicImport:/import\s*\(\s*['"]([^'"]+)['"]\s*\)/g,graphqlImport:/#import\s+['"]([^'"]+)['"]/g};parse(o,d){d&&(d.endsWith(".vue")||d.endsWith(".svelte"))&&(o=this.extractScript(o));let h=[],m=new Set;return d?.endsWith(".gql")||d?.endsWith(".graphql")?(this.extractImports(o,this.patterns.graphqlImport,"import",h,m),h):(o=this.stripComments(o),this.extractImports(o,this.patterns.importFrom,"import",h,m),this.extractImports(o,this.patterns.exportFrom,"export",h,m),this.extractImports(o,this.patterns.require,"require",h,m),this.extractImports(o,this.patterns.dynamicImport,"dynamic",h,m),h)}extractScript(o){let d=/<script[^>]*>([\s\S]*?)<\/script\s*[^>]*>/gi;return[...o.matchAll(d)].map(m=>m[1]).join(`
|
|
46676
46676
|
`)}stripComments(o){return u.STRIP_COMMENTS_RE.lastIndex=0,o.replaceAll(u.STRIP_COMMENTS_RE,(d,h,m)=>h||m.replaceAll(/[^\n]/g," "))}extractImports(o,d,h,m,T){let N;for(d.lastIndex=0;(N=d.exec(o))!==null;){let z=N[1];if(T.has(z))continue;if(this.ignoreTypeImports){let pe=N[0].trim();if(/^(import|export)\s+type\b/.test(pe))continue;let Te=pe.match(/^(import|export)\s+\{([\s\S]*?)\}\s+from\b/);if(Te){let Ke=Te[2].split(",").map(ce=>ce.trim()).filter(Boolean);if(Ke.length>0&&Ke.every(ce=>/^type\b/.test(ce)))continue}}T.add(z);let ee=this.getLineNumber(o,N.index);m.push({module:z,type:h,line:ee})}}getLineNumber(o,d){return o.substring(0,d).split(`
|
|
46677
|
-
`).length}async parseImports(o){let d=VC(o),h=await this.fileReader.readFile(d);return this.parse(h,d).map(T=>({path:"",type:T.type,line:T.line,module:T.module}))}async resolvePath(o,d){let h=VC(o);return this.pathResolver.resolve(h,d)}};Yae();var Qae=class{cache=new Map;maxSize;enableLRU;hits=0;misses=0;evictions=0;constructor(o={}){this.maxSize=o.maxSize??0,this.enableLRU=o.enableLRU??!0}get(o){let d=this.cache.get(o);if(d!==void 0)return this.hits++,this.enableLRU&&this.maxSize>0&&(this.cache.delete(o),this.cache.set(o,d)),d;this.misses++}set(o,d){this.cache.has(o)?this.cache.delete(o):this.maxSize>0&&this.cache.size>=this.maxSize&&this.evictOldest(),this.cache.set(o,d)}has(o){return this.cache.has(o)}clear(){this.cache.clear(),this.resetStats()}delete(o){return this.cache.delete(o)}get size(){return this.cache.size}getStats(){let o=this.hits+this.misses;return{hits:this.hits,misses:this.misses,evictions:this.evictions,size:this.cache.size,maxSize:this.maxSize,hitRate:o>0?this.hits/o:0}}resetStats(){this.hits=0,this.misses=0,this.evictions=0}keys(){return this.cache.keys()}entries(){return this.cache.entries()}evictOldest(){let o=this.cache.keys().next().value;o!==void 0&&(this.cache.delete(o),this.evictions++)}};jC();var $in=Uh("IndexerStatus"),KDe=class{_state="idle";_processed=0;_total=0;_currentFile;_startTime;_errorMessage;_cancelled=!1;_listeners=new Set;_lastNotifyTime=0;_notifyThrottleMs;constructor(o){this._notifyThrottleMs=o?.notifyThrottleMs??250}subscribe(o){return this._listeners.add(o),o(this.getSnapshot()),()=>this._listeners.delete(o)}getSnapshot(){let o=this._total>0?Math.round(this._processed/this._total*100):0,d;if(this._startTime&&this._processed>0&&this._total>0&&this._state==="indexing"){let m=(Date.now()-this._startTime)/this._processed,T=this._total-this._processed;d=Math.round(m*T)}return{state:this._state,processed:this._processed,total:this._total,currentFile:this._currentFile,percentage:o,startTime:this._startTime,estimatedTimeRemaining:d,errorMessage:this._errorMessage,cancelled:this._cancelled}}startCounting(){this._state="counting",this._processed=0,this._total=0,this._currentFile=void 0,this._startTime=Date.now(),this._errorMessage=void 0,this._cancelled=!1,this._notifyListeners(!0)}setTotal(o){this._total=o,this._notifyListeners(!0)}startIndexing(){this._state="indexing",this._startTime=Date.now(),this._notifyListeners(!0)}startValidating(){this._state="validating",this._notifyListeners(!0)}updateProgress(o,d){this._processed=o,this._currentFile=d,this._notifyListeners(!1)}complete(){this._state="complete",this._currentFile=void 0,this._notifyListeners(!0)}setError(o){this._state="error",this._errorMessage=o,this._currentFile=void 0,this._notifyListeners(!0)}setCancelled(){this._cancelled=!0,this._state="idle",this._currentFile=void 0,this._notifyListeners(!0)}reset(){this._state="idle",this._processed=0,this._total=0,this._currentFile=void 0,this._startTime=void 0,this._errorMessage=void 0,this._cancelled=!1,this._notifyListeners(!0)}isActive(){return this._state==="counting"||this._state==="indexing"||this._state==="validating"}isReady(){return this._state==="complete"}_notifyListeners(o){let d=Date.now();if(!o&&d-this._lastNotifyTime<this._notifyThrottleMs)return;this._lastNotifyTime=d;let h=this.getSnapshot();for(let m of this._listeners)try{m(h)}catch(T){$in.error("Listener error:",T)}}get state(){return this._state}get total(){return this._total}get processed(){return this._processed}};var HUt=cc(require("node:path"));var _v=cc(YLt());jC();function QLt(u){switch(u){case"FunctionDeclaration":case"ArrowFunction":case"MethodDeclaration":case"GetAccessor":case"SetAccessor":return"function";case"ClassDeclaration":return"class";case"InterfaceDeclaration":return"interface";case"TypeAliasDeclaration":return"type";case"VariableDeclaration":case"PropertyDeclaration":case"EnumDeclaration":return"variable";default:return"other"}}var jUt=Uh("SymbolAnalyzer"),ast=class{project;maxFiles;fileCount=0;fileReader;constructor(o,d={}){this.maxFiles=d.maxFiles??100,this.project=this.createProject(),this.fileReader=new W1}createProject(){return new _v.Project({skipAddingFilesFromTsConfig:!0,useInMemoryFileSystem:!0,compilerOptions:{target:99,module:99}})}maybeResetProject(){this.fileCount>=this.maxFiles&&(jUt.debug(`Resetting ts-morph project (${this.fileCount} files in memory)`),this.project=this.createProject(),this.fileCount=0)}getFileCount(){return this.fileCount}reset(){jUt.debug("Forcing ts-morph project reset"),this.project=this.createProject(),this.fileCount=0}analyzeFileContent(o,d){this.maybeResetProject();let h=this.getOrCreateSourceFile(o,d),m=[],T=[],N=this.extractExportedSymbols(h,o,m);return this.extractNonExportedSymbols(h,o,N,m),this.buildDependencies(h,T),{symbols:m,dependencies:T}}getOrCreateSourceFile(o,d){let h=this.project.getSourceFile(o);return h?h.replaceWithText(d):(h=this.project.createSourceFile(o,d),this.fileCount++),h}extractExportedSymbols(o,d,h){let m=o.getExportedDeclarations(),T=new Set(m.keys());for(let[N,z]of m){let ee=z[0];ee&&(this.addSymbol(h,N,ee.getKindName(),ee.getStartLineNumber(),d,!0),ee.getKindName()==="ClassDeclaration"&&_v.Node.isClassDeclaration(ee)&&this.extractClassMembers(ee,d,h))}return T}extractNonExportedSymbols(o,d,h,m){let T=o.getStatements();for(let N of T)_v.Node.isVariableStatement(N)?this.extractVariableDeclarations(N,d,h,m):this.extractOtherDeclarations(N,d,h,m)}extractVariableDeclarations(o,d,h,m){let T=o.getDeclarations();for(let N of T){let z=N.getName();h.has(z)||this.addSymbol(m,z,"VariableDeclaration",N.getStartLineNumber(),d,!1)}}extractOtherDeclarations(o,d,h,m){let T=this.getDeclarationInfo(o);!T||h.has(T.name)||(this.addSymbol(m,T.name,T.kind,o.getStartLineNumber(),d,!1),T.isClass&&_v.Node.isClassDeclaration(o)&&this.extractClassMembers(o,d,m))}getDeclarationInfo(o){if(_v.Node.isClassDeclaration(o)){let d=o.getName();if(d)return{name:d,kind:"ClassDeclaration",isClass:!0}}else if(_v.Node.isFunctionDeclaration(o)){let d=o.getName();if(d)return{name:d,kind:"FunctionDeclaration",isClass:!1}}else{if(_v.Node.isInterfaceDeclaration(o))return{name:o.getName(),kind:"InterfaceDeclaration",isClass:!1};if(_v.Node.isTypeAliasDeclaration(o))return{name:o.getName(),kind:"TypeAliasDeclaration",isClass:!1};if(_v.Node.isEnumDeclaration(o))return{name:o.getName(),kind:"EnumDeclaration",isClass:!1}}return null}addSymbol(o,d,h,m,T,N){o.push({name:d,kind:h,line:m,isExported:N,id:`${T}:${d}`,category:QLt(h)})}buildDependencies(o,d){let h=this.buildImportMap(o),m=this.findSymbolUsage(o,h);for(let[T,N]of Object.entries(m))for(let z of N)d.push({sourceSymbolId:T,targetSymbolId:z.symbolId,targetFilePath:z.filePath,isTypeOnly:z.isTypeOnly})}getInternalExportDependencyGraph(o,d){this.maybeResetProject();let m=this.getOrCreateSourceFile(o,d).getExportedDeclarations(),T=new Set(m.keys()),N=new Map;for(let[z,ee]of m){let pe=`${o}:${z}`,Te=this.getOrCreateDependencySet(N,pe);this.collectExportDependencies(ee,z,T,o,Te)}return N}getOrCreateDependencySet(o,d){let h=o.get(d);return h||(h=new Set,o.set(d,h)),h}collectExportDependencies(o,d,h,m,T){for(let N of o){let z=N.getDescendantsOfKind(_v.SyntaxKind.Identifier);for(let ee of z){let pe=ee.getText();this.isValidDependency(pe,d,h)&&T.add(`${m}:${pe}`)}}}isValidDependency(o,d,h){return h.has(o)&&o!==d}buildImportMap(o){let d=new Map,h=o.getImportDeclarations();for(let m of h){let T=m.getModuleSpecifierValue(),N=m.isTypeOnly(),z=m.getDefaultImport();if(z){let Te=z.getText();d.set(Te,{originalName:"default",modulePath:T,isType:N})}let ee=m.getNamedImports();for(let Te of ee){let Ke=Te.getNameNode().getText(),ce=Te.getAliasNode(),Bt=ce?ce.getText():Ke;d.set(Bt,{originalName:Ke,modulePath:T,isType:N||Te.isTypeOnly()})}let pe=m.getNamespaceImport();if(pe){let Te=pe.getText();d.set(Te,{originalName:"*",modulePath:T,isType:N})}}return d}extractIntraFileCalls(o,d){let h=[],m=d.getFilePath(),T=this.collectFunctionNames(d),N=o.getDescendantsOfKind(_v.SyntaxKind.CallExpression);for(let z of N)this.processCallExpression(z,T,m,h);return h}collectFunctionNames(o){let d=new Set;for(let h of o.getFunctions()){let m=h.getName();m&&d.add(m)}for(let h of o.getClasses())for(let m of h.getMethods()){let T=m.getName();T&&d.add(T)}return d}processCallExpression(o,d,h,m){if(!_v.Node.isCallExpression(o))return;let T=o.getExpression();if(_v.Node.isIdentifier(T)){this.addDirectFunctionCall(T,d,h,m);return}_v.Node.isPropertyAccessExpression(T)&&this.addPropertyAccessCall(T,d,h,m)}addDirectFunctionCall(o,d,h,m){let T=o.getText();d.has(T)&&m.push({symbolId:`${h}:${T}`,filePath:h,isTypeOnly:!1})}addPropertyAccessCall(o,d,h,m){if(_v.Node.isPropertyAccessExpression(o)){let T=o.getName();d.has(T)&&m.push({symbolId:`${h}:${T}`,filePath:h,isTypeOnly:!1})}}findSymbolUsage(o,d){let h={},m=o.getFilePath(),T=[...o.getFunctions(),...o.getClasses(),...o.getVariableDeclarations()];for(let ee of T){let pe=ee.getName();if(!pe)continue;let Te=`${m}:${pe}`,Ke=this.extractSymbolDependencies(ee,d),ce=this.extractIntraFileCalls(ee,o);Ke.push(...ce),h[Te]=Ke}let N=o.getStatements(),z=[];for(let ee of N){if(_v.Node.isFunctionDeclaration(ee)||_v.Node.isClassDeclaration(ee)||_v.Node.isVariableStatement(ee)||_v.Node.isInterfaceDeclaration(ee)||_v.Node.isTypeAliasDeclaration(ee)||_v.Node.isEnumDeclaration(ee)||_v.Node.isImportDeclaration(ee))continue;let pe=this.extractSymbolDependencies(ee,d);z.push(...pe)}if(z.length>0){let ee=`${m}:(file)`;h[ee]=z}return h}extractSymbolDependencies(o,d){let h=[];return this.extractStaticImportDependencies(o,d,h),this.extractDynamicImportDependencies(o,h),h}extractStaticImportDependencies(o,d,h){let m=o.getDescendantsOfKind(_v.SyntaxKind.Identifier);for(let T of m){let N=d.get(T.getText());if(!N)continue;let z=this.buildTargetSymbolId(N);h.some(ee=>ee.symbolId===z)||h.push({symbolId:z,filePath:N.modulePath,isTypeOnly:N.isType})}}extractDynamicImportDependencies(o,d){let h=o.getDescendantsOfKind(_v.SyntaxKind.CallExpression);for(let m of h){let T=this.extractDynamicImportPath(m);if(!T)continue;let N=`${T}:default`;d.some(z=>z.symbolId===N)||d.push({symbolId:N,filePath:T,isTypeOnly:!1})}}extractDynamicImportPath(o){if(!_v.Node.isCallExpression(o)||o.getExpression().getKind()!==_v.SyntaxKind.ImportKeyword)return null;let h=o.getArguments();if(h.length===0)return null;let m=h[0];return _v.Node.isStringLiteral(m)?m.getLiteralValue():null}buildTargetSymbolId(o){return o.originalName==="default"?`${o.modulePath}:default`:`${o.modulePath}:${o.originalName}`}extractClassMembers(o,d,h){let m=o.getName();if(!m)return;let T=`${d}:${m}`,N=o.getMembers();for(let z of N){let ee=z.getKindName();if(!_v.Node.isMethodDeclaration(z)&&!_v.Node.isPropertyDeclaration(z)&&!_v.Node.isGetAccessorDeclaration(z)&&!_v.Node.isSetAccessorDeclaration(z))continue;let pe=z.getName();if(!pe)continue;let Te=z.isStatic()??!1,Ke=`${m}.${pe}`,ce=Te?`Static${ee}`:ee;h.push({name:Ke,kind:ce,line:z.getStartLineNumber(),isExported:!1,id:`${d}:${Ke}`,parentSymbolId:T,category:QLt(ee)})}}getExportedSymbols(o,d){let h=this.project.getSourceFile(o);h?h.replaceWithText(d):h=this.project.createSourceFile(o,d);let m=[],T=h.getExportedDeclarations();for(let[N,z]of T){let ee=z[0];if(!ee)continue;let pe=ee.getKindName();m.push({name:N,kind:pe,line:ee.getStartLineNumber(),isExported:!0,id:`${o}:${N}`,category:QLt(pe)})}return m}filterRuntimeSymbols(o){let d=new Set(["InterfaceDeclaration","TypeAliasDeclaration","TypeParameter"]);return o.filter(h=>!d.has(h.kind))}async analyzeFile(o){let d=await this.fileReader.readFile(o),h=this.analyzeFileContent(o,d),m=new Map;for(let T of h.symbols)m.set(T.id,T);return m}async getSymbolDependencies(o){let d=await this.fileReader.readFile(o);return this.analyzeFileContent(o,d).dependencies}};var ZLt=cc(require("node:fs/promises")),pse=cc(require("node:path"));Im();Bne();GC();Jne();var sst=class u{parser=null;fileReader;rootDir;extensionPath;initPromise=null;constructor(o,d){this.fileReader=new W1,this.rootDir=o??process.cwd(),this.extensionPath=d}async ensureInitialized(){if(!this.parser)return this.initPromise!==null?this.initPromise:(this.initPromise=(async()=>{let o=this.extensionPath;if(!o)throw new Error("Extension path required for WASM parser initialization. Ensure CSharpParser is constructed with extensionPath parameter.");try{let d=hN.getInstance(),h=pse.default.join(o,"dist","wasm","tree-sitter.wasm");await d.init(h);let m=pse.default.join(o,"dist","wasm","tree-sitter-c_sharp.wasm");this.parser=await d.getParser("c_sharp",m)}catch(d){this.initPromise=null;let h=d instanceof Error?d.message:String(d);throw new Error(`Failed to initialize C# WASM parser: ${h}`,{cause:d})}})(),this.initPromise)}async parseImports(o){let d=VC(o),h;try{h=await this.fileReader.readFile(d)}catch(T){throw pg.fromError(T,d)}if(await this.ensureInitialized(),!this.parser)return[];let m=this.parser.parse(h);if(!m)return[];try{let T=[];return this.extractUsings(m.rootNode,d,T),T}finally{m.delete()}}extractUsings(o,d,h){if(o.type==="using_directive"){let m=o.children.find(T=>T.type==="identifier"||T.type==="qualified_name"||T.type==="member_access_expression");if(m){let T=m.text.trim();T&&h.push({path:ri(d),type:"import",line:m.startPosition.row+1,module:T})}}for(let m of o.children)this.extractUsings(m,d,h)}async resolvePath(o,d){if(this.isFrameworkNamespace(d))return null;let h=d.split(".");return h.length<2||h.some(u.isUnsafeSegment)?null:this.resolveNamespace(h)}async resolveNamespace(o){try{return await this.resolveViaSuffix(o)??await this.resolveViaLastSegment(o)}catch{return null}}static isUnsafeSegment(o){return o===""||o===".."||o.includes("/")}async resolveViaSuffix(o){for(let d=o.length-1;d>=1;d--){let h=pse.default.resolve(this.rootDir,o.slice(d).join(pse.default.sep));if(!this.isWithinRoot(h))continue;let m=await this.findFirstCsFile(h);if(m)return ri(m)}return null}async resolveViaLastSegment(o){let d=o.at(-1)??"";if(!d)return null;let h=await this.findDirectory(this.rootDir,d,3);if(!h||!this.isWithinRoot(h))return null;let m=await this.findFirstCsFile(h);return m?ri(m):null}isWithinRoot(o){return ZF(o,this.rootDir)}isFrameworkNamespace(o){return["System","Microsoft","Newtonsoft","NUnit","Xunit","MSTest","AutoMapper","FluentValidation","MediatR","Serilog"].some(h=>o===h||o.startsWith(h+"."))}async findFirstCsFile(o){try{let h=(await ZLt.default.readdir(o,{withFileTypes:!0})).filter(m=>m.isFile()&&m.name.endsWith(".cs")).sort((m,T)=>m.name.localeCompare(T.name));return h.length>0?pse.default.join(o,h[0].name):null}catch{return null}}async findDirectory(o,d,h){if(h<=0)return null;try{let T=(await ZLt.default.readdir(o,{withFileTypes:!0})).filter(u.isTraversableDir);for(let N of T){if(N.name===d)return pse.default.join(o,N.name);let z=await this.findDirectory(pse.default.join(o,N.name),d,h-1);if(z)return z}}catch{}return null}static isTraversableDir(o){return o.isDirectory()&&!o.name.startsWith(".")&&o.name!=="node_modules"}};var cst=cc(require("node:fs/promises")),bJ=cc(require("node:path"));Im();Bne();GC();Jne();var lst=class u{parser=null;fileReader;rootDir;extensionPath;initPromise=null;constructor(o,d){this.fileReader=new W1,this.rootDir=o??process.cwd(),this.extensionPath=d}async ensureInitialized(){if(!this.parser)return this.initPromise!==null?this.initPromise:(this.initPromise=(async()=>{let o=this.extensionPath;if(!o)throw new Error("Extension path required for WASM parser initialization. Ensure GoParser is constructed with extensionPath parameter.");try{let d=hN.getInstance(),h=bJ.default.join(o,"dist","wasm","tree-sitter.wasm");await d.init(h);let m=bJ.default.join(o,"dist","wasm","tree-sitter-go.wasm");this.parser=await d.getParser("go",m)}catch(d){this.initPromise=null;let h=d instanceof Error?d.message:String(d);throw new Error(`Failed to initialize Go WASM parser: ${h}`,{cause:d})}})(),this.initPromise)}async parseImports(o){let d=VC(o),h;try{h=await this.fileReader.readFile(d)}catch(T){throw pg.fromError(T,d)}if(await this.ensureInitialized(),!this.parser)return[];let m=this.parser.parse(h);if(!m)return[];try{let T=[];return this.extractImports(m.rootNode,d,T),T}finally{m.delete()}}extractImports(o,d,h){if(o.type==="import_spec"){let m=o.children.find(T=>T.type==="interpreted_string_literal"||T.type==="raw_string_literal");if(m){let T=m.text.replaceAll(/^["`]|["`]$/g,"").trim();T&&h.push({path:ri(d),type:"import",line:m.startPosition.row+1,module:T})}}for(let m of o.children)this.extractImports(m,d,h)}async resolvePath(o,d){if(this.isGoStdlibImport(d))return null;let h=d.split("/");return h.some(u.isUnsafePart)?null:this.resolveGoImport(VC(o),d,h)}async resolveGoImport(o,d,h){try{let m=await this.resolveViaGoMod(o,d)??await this.resolveViaLastSegment(h);return m?ri(m):null}catch{return null}}static isUnsafePart(o){return o===".."||o===""}async resolveViaGoMod(o,d){let h=await this.findGoModuleInfo(bJ.default.dirname(o));if(!h||!d.startsWith(h.moduleName+"/"))return null;let T=d.slice(h.moduleName.length+1).split("/");if(T.some(u.isUnsafePart))return null;let N=bJ.default.resolve(h.moduleDir,...T);return this.isWithinRoot(N)?this.findFirstGoFile(N):null}async resolveViaLastSegment(o){let d=o.at(-1)??"";if(!d)return null;let h=await this.findDirectory(this.rootDir,d,3);return!h||!this.isWithinRoot(h)?null:this.findFirstGoFile(h)}isWithinRoot(o){return ZF(o,this.rootDir)}isGoStdlibImport(o){return!(o.split("/")[0]??"").includes(".")}async findGoModuleInfo(o){let d=o,h=ri(this.rootDir);for(;;){let m=await this.readGoModuleName(bJ.default.join(d,"go.mod"));if(m)return{moduleDir:d,moduleName:m};let T=bJ.default.dirname(d);if(T===d||!ri(T).startsWith(h))break;d=T}return null}async readGoModuleName(o){try{let d=await cst.default.readFile(o,"utf-8"),h=/^module\s+(\S+)/mu.exec(d);return h?h[1]:null}catch{return null}}async findFirstGoFile(o){try{let h=(await cst.default.readdir(o,{withFileTypes:!0})).filter(m=>m.isFile()&&m.name.endsWith(".go")&&!m.name.endsWith("_test.go")).sort((m,T)=>m.name.localeCompare(T.name));return h.length>0?bJ.default.join(o,h[0].name):null}catch{return null}}async findDirectory(o,d,h){if(h<=0)return null;try{let T=(await cst.default.readdir(o,{withFileTypes:!0})).filter(u.isTraversableDir);for(let N of T){if(N.name===d)return bJ.default.join(o,N.name);let z=await this.findDirectory(bJ.default.join(o,N.name),d,h-1);if(z)return z}}catch{}return null}static isTraversableDir(o){return o.isDirectory()&&!o.name.startsWith(".")&&o.name!=="node_modules"}};var eOt=cc(require("node:fs/promises")),rEe=cc(require("node:path"));Im();Bne();GC();Jne();var ust=class{parser=null;fileReader;rootDir;extensionPath;initPromise=null;constructor(o,d){this.fileReader=new W1,this.rootDir=o??process.cwd(),this.extensionPath=d}async ensureInitialized(){if(!this.parser)return this.initPromise!==null?this.initPromise:(this.initPromise=(async()=>{let o=this.extensionPath;if(!o)throw new Error("Extension path required for WASM parser initialization. Ensure JavaParser is constructed with extensionPath parameter.");try{let d=hN.getInstance(),h=rEe.default.join(o,"dist","wasm","tree-sitter.wasm");await d.init(h);let m=rEe.default.join(o,"dist","wasm","tree-sitter-java.wasm");this.parser=await d.getParser("java",m)}catch(d){this.initPromise=null;let h=d instanceof Error?d.message:String(d);throw new Error(`Failed to initialize Java WASM parser: ${h}`,{cause:d})}})(),this.initPromise)}async parseImports(o){let d=VC(o),h;try{h=await this.fileReader.readFile(d)}catch(T){throw pg.fromError(T,d)}if(await this.ensureInitialized(),!this.parser)return[];let m=this.parser.parse(h);if(!m)return[];try{let T=[];return this.extractImports(m.rootNode,d,T),T}finally{m.delete()}}extractImports(o,d,h){if(o.type==="import_declaration"){let m=o.children.find(T=>T.type==="identifier"||T.type==="scoped_identifier");if(m){let T=m.text.trim();T&&h.push({path:ri(d),type:"import",line:m.startPosition.row+1,module:T})}}for(let m of o.children)this.extractImports(m,d,h)}async resolvePath(o,d){try{if(this.isJavaStdlibImport(d)||d.endsWith(".*"))return null;let h=d.split(".");if(h.some(ee=>ee===""||ee===".."||ee.includes("/")))return null;let m=h.at(-1)??"",T=h.join(rEe.default.sep)+".java",N=rEe.default.resolve(this.rootDir,T);if(this.isWithinRoot(N)&&await this.fileExists(N))return ri(N);let z=await this.findFile(this.rootDir,m+".java",4);return z?ri(z):null}catch{return null}}isWithinRoot(o){return ZF(o,this.rootDir)}isJavaStdlibImport(o){return["java.","javax.","sun.","com.sun.","org.w3c.","org.xml.","org.ietf.","org.omg.","jdk.","javafx."].some(h=>o.startsWith(h))}async findFile(o,d,h){if(h<=0)return null;try{let m=await eOt.default.readdir(o,{withFileTypes:!0});for(let T of m)if(T.isFile()&&T.name===d)return rEe.default.join(o,T.name);for(let T of m)if(T.isDirectory()&&!T.name.startsWith(".")&&T.name!=="node_modules"){let N=await this.findFile(rEe.default.join(o,T.name),d,h-1);if(N)return N}}catch{}return null}async fileExists(o){try{return await eOt.default.access(o),!0}catch{return!1}}};var tOt=cc(require("node:fs/promises")),PO=cc(require("node:path"));Im();GC();Jne();var dst=class{parser=null;fileReader;rootDir;extensionPath;initPromise=null;constructor(o,d){this.fileReader=new W1,this.rootDir=o||process.cwd(),this.extensionPath=d}async ensureInitialized(){this.parser||(this.initPromise??=(async()=>{let o=await this.resolveExtensionPath();if(!o)throw new Error("Extension path required for WASM parser initialization. Ensure PythonParser is constructed with extensionPath parameter.");try{let d=hN.getInstance(),h=PO.default.join(o,"dist","wasm","tree-sitter.wasm");await d.init(h);let m=PO.default.join(o,"dist","wasm","tree-sitter-python.wasm");this.parser=await d.getParser("python",m)}catch(d){this.initPromise=null;let h=d instanceof Error?d.message:String(d);throw new Error(`Failed to initialize Python WASM parser: ${h}`,{cause:d})}})(),await this.initPromise)}async resolveExtensionPath(){if(this.extensionPath)return this.extensionPath;let o=process.cwd(),d=PO.default.join(o,"dist","wasm","tree-sitter.wasm");try{return await tOt.default.access(d),o}catch{return}}async parseImports(o){try{await this.ensureInitialized();let d=VC(o),h=await this.fileReader.readFile(d),m=this.parser?.parse(h);if(!m)throw new Error(`Failed to parse Python file: ${d}`);let T=[],N=new Set;return this.traverseTree(m.rootNode,z=>{z.type==="import_statement"?this.extractImportStatement(z,T,N,h):z.type==="import_from_statement"&&this.extractImportFromStatement(z,T,N,h)}),T}catch(d){throw pg.fromError(d,o)}}async resolvePath(o,d){try{await this.ensureInitialized();let h=VC(o),m=PO.default.dirname(h);return d.startsWith(".")?await this.resolveRelativeImport(m,d):await this.resolveAbsoluteImport(m,d)}catch{return null}}extractImportStatement(o,d,h,m){let T=this.findChildrenByType(o,"dotted_name");for(let N of T){let z=this.getNodeText(N,m);z&&!h.has(z)&&(h.add(z),d.push({path:"",type:"import",line:N.startPosition.row+1,module:z}))}}extractImportFromStatement(o,d,h,m){let T=null,N=this.findChildByType(o,"relative_import");if(N)T=this.getNodeText(N,m);else{let z=this.findChildByType(o,"dotted_name");z&&(T=this.getNodeText(z,m))}T&&!h.has(T)&&(h.add(T),d.push({path:"",type:"import",line:o.startPosition.row+1,module:T}))}async resolveRelativeImport(o,d){let h=/^\.*/u.exec(d),m=h?h[0].length:0,T=d.slice(m).replaceAll(".","/"),N=o;for(let ee=1;ee<m;ee++)N=PO.default.dirname(N);let z=[PO.default.join(N,T+".py"),PO.default.join(N,T+".pyi"),PO.default.join(N,T,"__init__.py"),PO.default.join(N,T,"__init__.pyi")];for(let ee of z)if(await this.fileExists(ee))return ri(ee);return null}async resolveAbsoluteImport(o,d){let h=d.replaceAll(".","/"),m=ri(this.rootDir),T=new Set,N=async ee=>{let pe=ri(ee);if(T.has(pe))return null;T.add(pe);let Te=[PO.default.join(ee,h+".py"),PO.default.join(ee,h+".pyi"),PO.default.join(ee,h,"__init__.py"),PO.default.join(ee,h,"__init__.pyi")];for(let Ke of Te)if(await this.fileExists(Ke))return ri(Ke);return null},z=o;for(;;){let ee=await N(z);if(ee)return ee;let pe=PO.default.dirname(z);if(pe===z)break;if(ri(pe)===m){let Te=await N(pe);if(Te)return Te;break}z=pe}if(!T.has(m)){let ee=await N(this.rootDir);if(ee)return ee}return null}async fileExists(o){try{return await tOt.default.access(o),!0}catch{return!1}}traverseTree(o,d){d(o);for(let h of o.children)this.traverseTree(h,d)}findChildrenByType(o,d){let h=[];for(let m of o.children)m.type===d&&h.push(m);return h}findChildByType(o,d){for(let h of o.children)if(h.type===d)return h;return null}getNodeText(o,d){return d.slice(o.startIndex,o.endIndex)}};var VUt=cc(require("node:fs/promises")),pst=cc(require("node:path"));Im();GC();Jne();var fst=class{parser=null;fileReader;initPromise=null;extensionPath;constructor(o,d){this.extensionPath=d??o,this.fileReader=new W1}async ensureInitialized(){this.parser||(this.initPromise??=(async()=>{let o=await this.resolveExtensionPath();if(!o)throw new Error("Extension path required for WASM parser initialization. Ensure PythonSymbolAnalyzer is constructed with extensionPath parameter.");try{let d=hN.getInstance(),h=pst.default.join(o,"dist","wasm","tree-sitter.wasm");await d.init(h);let m=pst.default.join(o,"dist","wasm","tree-sitter-python.wasm");this.parser=await d.getParser("python",m)}catch(d){this.initPromise=null;let h=d instanceof Error?d.message:String(d);throw new Error(`Failed to initialize Python WASM parser for symbol analysis: ${h}`,{cause:d})}})(),await this.initPromise)}async resolveExtensionPath(){if(this.extensionPath)return this.extensionPath;let o=process.cwd(),d=pst.default.join(o,"dist","wasm","tree-sitter.wasm");try{return await VUt.default.access(d),o}catch{return}}async analyzeFile(o){try{await this.ensureInitialized();let d=await this.fileReader.readFile(o);return this.analyzeFileFromContent(o,d)}catch(d){throw pg.fromError(d,o)}}analyzeFileFromContent(o,d){if(!this.parser)throw new Error("Parser not initialized. Call ensureInitialized() before using analyzeFileFromContent().");let h=this.parser.parse(d);if(!h)throw new Error(`Failed to parse Python file: ${o}`);try{let m=new Map,T=ri(o);return this.extractSymbols(h.rootNode,T,d,m),m}finally{h.delete()}}analyzeFileContent(o,d){if(!this.parser)throw new Error("Parser not initialized. Call ensureInitialized() before using analyzeFileContent().");let h=this.parser.parse(d);if(!h)throw new Error(`Failed to parse Python file: ${o}`);try{let m=new Map,T=[],N=ri(o);this.extractSymbols(h.rootNode,N,d,m);let z=this.buildImportMap(h.rootNode,d);return this.extractDependencies(h.rootNode,N,d,T,m,void 0,z),{symbols:Array.from(m.values()),dependencies:T}}finally{h.delete()}}async getSymbolDependencies(o){try{await this.ensureInitialized();let d=await this.fileReader.readFile(o);return this.analyzeFileContent(o,d).dependencies}catch(d){throw pg.fromError(d,o)}}extractSymbols(o,d,h,m,T){this.tryExtractSymbolFromNode(o,d,h,m,T)||this.extractSymbolsFromChildren(o,d,h,m,T)}tryExtractSymbolFromNode(o,d,h,m,T){return o.type==="function_definition"?(this.handleFunctionDefinition(o,d,h,m,T),!0):o.type==="class_definition"?(this.handleClassDefinition(o,d,h,m,T),!0):o.type==="decorated_definition"?(this.handleDecoratedDefinition(o,d,h,m,T),!0):!1}handleFunctionDefinition(o,d,h,m,T){let N=o.childForFieldName("name");if(!N)return;let z=this.getNodeText(N,h),ee=`${d}:${z}`,pe=this.hasChild(o,"async");m.set(ee,{name:z,kind:pe?"AsyncFunction":"FunctionDeclaration",line:N.startPosition.row+1,isExported:this.isExported(o,h),id:ee,parentSymbolId:T,category:"function"}),this.extractSymbolsFromChildren(o,d,h,m,ee)}handleClassDefinition(o,d,h,m,T){let N=o.childForFieldName("name");if(!N)return;let z=this.getNodeText(N,h),ee=`${d}:${z}`;m.set(ee,{name:z,kind:"ClassDeclaration",line:N.startPosition.row+1,isExported:this.isExported(o,h),id:ee,parentSymbolId:T,category:"class"}),this.extractSymbolsFromChildren(o,d,h,m,ee)}handleDecoratedDefinition(o,d,h,m,T){for(let N of o.children)(N.type==="function_definition"||N.type==="class_definition")&&this.extractSymbols(N,d,h,m,T)}extractSymbolsFromChildren(o,d,h,m,T){for(let N of o.children)this.extractSymbols(N,d,h,m,T)}buildImportMap(o,d){let h=new Map;return this.traverseForImports(o,h,d),h}traverseForImports(o,d,h){o.type==="import_from_statement"?this.processFromImport(o,d,h):o.type==="import_statement"&&this.processImportStatement(o,d,h);for(let m of o.children)this.traverseForImports(m,d,h)}processFromImport(o,d,h){let m=o.childForFieldName("module_name");if(!m)return;let T=this.getNodeText(m,h);for(let N of o.children)this.processFromImportChild(N,d,h,T)}processFromImportChild(o,d,h,m){if(o.type==="aliased_import"){this.addAliasedFromImport(o,d,h,m);return}if(o.type==="dotted_name"||o.type==="identifier"){let T=this.getNodeText(o,h);if(T===m||o.parent?.type==="aliased_import")return;d.set(T,m)}}addAliasedFromImport(o,d,h,m){let T=o.childForFieldName("name");if(!T)return;let N=this.getNodeText(T,h),z=o.childForFieldName("alias"),ee=z?this.getNodeText(z,h):N;d.set(ee,m)}processImportStatement(o,d,h){for(let m of o.children)this.processImportStatementChild(m,d,h)}processImportStatementChild(o,d,h){if(o.type==="aliased_import"){let m=o.childForFieldName("name");if(!m)return;let T=this.getNodeText(m,h),N=o.childForFieldName("alias"),z=N?this.getNodeText(N,h):T;d.set(z,T);return}if(o.type==="dotted_name"||o.type==="identifier"){let m=this.getNodeText(o,h);m!=="import"&&d.set(m,m)}}extractDependencies(o,d,h,m,T,N,z){let ee=this.getScopeForNode(o,d,h,N);this.addCallDependencyIfAny(o,d,h,m,T,ee,z);for(let pe of o.children)this.extractDependencies(pe,d,h,m,T,ee,z)}getScopeForNode(o,d,h,m){if(o.type!=="function_definition"&&o.type!=="class_definition")return m;let T=o.childForFieldName("name");if(!T)return m;let N=this.getNodeText(T,h);return`${d}:${N}`}addCallDependencyIfAny(o,d,h,m,T,N,z){if(o.type!=="call")return;let ee=o.childForFieldName("function");if(!ee||!N)return;let pe=this.getCalledName(ee,h),Te=`${d}:${pe}`;if(T.has(Te)){m.push({sourceSymbolId:N,targetSymbolId:Te,targetFilePath:d,isTypeOnly:!1});return}if(z?.has(pe)){let Ke=z.get(pe);if(Ke===void 0)return;m.push({sourceSymbolId:N,targetSymbolId:`${Ke}:${pe}`,targetFilePath:Ke,isTypeOnly:!1})}}getCalledName(o,d){if(o.type!=="attribute")return this.getNodeText(o,d);let h=o.childForFieldName("attribute");return h?this.getNodeText(h,d):this.getNodeText(o,d)}isExported(o,d){let h=o.childForFieldName("name");return h?!this.getNodeText(h,d).startsWith("_"):!1}hasChild(o,d){for(let h of o.children)if(h.type===d)return!0;return!1}getNodeText(o,d){return d.slice(o.startIndex,o.endIndex)}};var nOt=cc(require("node:fs/promises")),$ne=cc(require("node:path"));Im();GC();Jne();var mst=class{parser=null;fileReader;rootDir;extensionPath;initPromise=null;constructor(o,d){this.fileReader=new W1,this.rootDir=o||process.cwd(),this.extensionPath=d}async ensureInitialized(){this.parser||(this.initPromise??=(async()=>{let o=await this.resolveExtensionPath();if(!o)throw new Error("Extension path required for WASM parser initialization. Ensure RustParser is constructed with extensionPath parameter.");try{let d=hN.getInstance(),h=$ne.default.join(o,"dist","wasm","tree-sitter.wasm");await d.init(h);let m=$ne.default.join(o,"dist","wasm","tree-sitter-rust.wasm");this.parser=await d.getParser("rust",m)}catch(d){this.initPromise=null;let h=d instanceof Error?d.message:String(d);throw new Error(`Failed to initialize Rust WASM parser: ${h}`,{cause:d})}})(),await this.initPromise)}async resolveExtensionPath(){if(this.extensionPath)return this.extensionPath;let o=process.cwd(),d=$ne.default.join(o,"dist","wasm","tree-sitter.wasm");try{return await nOt.default.access(d),o}catch{return}}async parseImports(o){try{await this.ensureInitialized();let d=VC(o),h=await this.fileReader.readFile(d),m=this.parser?.parse(h);if(!m)throw new Error(`Failed to parse Rust file: ${d}`);let T=[],N=new Set;return this.traverseTree(m.rootNode,z=>{z.type==="use_declaration"?this.extractUseDeclaration(z,T,N,h):z.type==="mod_item"?this.extractModItem(z,T,N,h,o):z.type==="extern_crate_declaration"&&this.extractExternCrate(z,T,N,h)}),T}catch(d){throw pg.fromError(d,o)}}async resolvePath(o,d){try{await this.ensureInitialized();let h=d.split("::")[0];if(new Set(["std","core","alloc","proc_macro","test","serde","tokio","async_std","futures","vm","rustpython_vm","rustpython","rustpython_parser","rustpython_compiler","num_traits","enum_dispatch","dashmap"]).has(h))return null;let T=VC(o),N=$ne.default.dirname(T);return d.startsWith("self::")||d.startsWith("super::")||d.startsWith("crate::")?await this.resolveRelativeModule(o,d):await this.resolveModDeclaration(N,d)}catch{return null}}extractUseDeclaration(o,d,h,m){let T=this.collectIdentifiers(o,m);for(let N of T){if(!N)continue;let z=N.split("::")[0];if(new Set(["std","core","alloc","proc_macro","test","serde","tokio","async_std","futures","vm","rustpython_vm","rustpython","rustpython_parser","rustpython_compiler","num_traits","enum_dispatch","dashmap"]).has(z))continue;let pe=N.toLowerCase();h.has(pe)||(h.add(pe),d.push({path:"",type:"import",line:o.startPosition.row+1,module:pe}))}}extractModItem(o,d,h,m,T){if(this.findChildByType(o,"declaration_list"))return;let z=this.findChildByType(o,"identifier");if(z){let ee=this.getNodeText(z,m);ee=ee.toLowerCase(),ee&&!h.has(ee)&&(h.add(ee),d.push({path:"",type:"import",line:o.startPosition.row+1,module:ee}))}}extractExternCrate(o,d,h,m){let T=this.findChildByType(o,"identifier");if(T){let N=this.getNodeText(T,m);if(!N||new Set(["std","core","alloc","proc_macro","test","serde","tokio","async_std","futures","vm","rustpython_vm","rustpython","rustpython_parser","rustpython_compiler","num_traits","enum_dispatch","dashmap"]).has(N))return;let ee=N.toLowerCase();h.has(ee)||(h.add(ee),d.push({path:"",type:"import",line:o.startPosition.row+1,module:ee}))}}collectIdentifiers(o,d){let h=[],m=this.findAllByType(o,"scoped_identifier");for(let N of m){let z=this.getNodeText(N,d);z&&h.push(z)}let T=this.findAllByType(o,"identifier");for(let N of T){let z=this.getNodeText(N,d);if(!z||z==="self"||z==="super"||z==="crate")continue;let ee=z.charAt(0);ee===ee.toUpperCase()&&ee!==ee.toLowerCase()||h.push(z)}return h}async resolveRelativeModule(o,d){let h=$ne.default.dirname(o);if(d.startsWith("crate::")){let m=d.slice(7).replaceAll("::","/");return await this.resolveModDeclaration(this.rootDir,m)}if(d.startsWith("super::")){let m=$ne.default.dirname(h),T=d.slice(7).replaceAll("::","/");return await this.resolveModDeclaration(m,T)}if(d.startsWith("self::")){let m=d.slice(6).replaceAll("::","/");return await this.resolveModDeclaration(h,m)}return null}async resolveModDeclaration(o,d){if(d!==d.toLowerCase())return null;let h=d.replaceAll("::","/");h=h.toLowerCase();let m=[$ne.default.join(o,h+".rs"),$ne.default.join(o,h,"mod.rs")];for(let T of m)if(await this.fileExists(T))return ri(T);return null}async fileExists(o){try{return await nOt.default.access(o),!0}catch{return!1}}traverseTree(o,d){d(o);for(let h of o.children)this.traverseTree(h,d)}findChildByType(o,d){for(let h of o.children)if(h.type===d)return h;return null}findAllByType(o,d){let h=[],m=T=>{T.type===d&&h.push(T);for(let N of T.children)m(N)};return m(o),h}getNodeText(o,d){return d.slice(o.startIndex,o.endIndex)}};var UUt=cc(require("node:fs/promises")),_st=cc(require("node:path"));Im();GC();Jne();var hst=class{parser=null;fileReader;initPromise=null;extensionPath;constructor(o,d){this.extensionPath=d??o,this.fileReader=new W1}async ensureInitialized(){this.parser||(this.initPromise??=(async()=>{let o=await this.resolveExtensionPath();if(!o)throw new Error("Extension path required for WASM parser initialization. Ensure RustSymbolAnalyzer is constructed with extensionPath parameter.");try{let d=hN.getInstance(),h=_st.default.join(o,"dist","wasm","tree-sitter.wasm");await d.init(h);let m=_st.default.join(o,"dist","wasm","tree-sitter-rust.wasm");this.parser=await d.getParser("rust",m)}catch(d){this.initPromise=null;let h=d instanceof Error?d.message:String(d);throw new Error(`Failed to initialize Rust WASM parser for symbol analysis: ${h}`,{cause:d})}})(),await this.initPromise)}async resolveExtensionPath(){if(this.extensionPath)return this.extensionPath;let o=process.cwd(),d=_st.default.join(o,"dist","wasm","tree-sitter.wasm");try{return await UUt.default.access(d),o}catch{return}}async analyzeFile(o){try{await this.ensureInitialized();let d=await this.fileReader.readFile(o);return this.analyzeFileFromContent(o,d)}catch(d){throw pg.fromError(d,o)}}analyzeFileFromContent(o,d){if(!this.parser)throw new Error("Parser not initialized. Call ensureInitialized() before using analyzeFileFromContent().");let h=this.parser.parse(d);if(!h)throw new Error(`Failed to parse Rust file: ${o}`);try{let m=new Map,T=ri(o);return this.extractSymbols(h.rootNode,T,d,m),m}finally{h.delete()}}analyzeFileContent(o,d){if(!this.parser)throw new Error("Parser not initialized. Call ensureInitialized() before using analyzeFileContent().");let h=this.parser.parse(d);if(!h)throw new Error(`Failed to parse Rust file: ${o}`);try{let m=new Map,T=[],N=ri(o);this.extractSymbols(h.rootNode,N,d,m);let z=this.buildImportMap(h.rootNode,d);return this.extractDependencies(h.rootNode,N,d,T,m,void 0,z),{symbols:Array.from(m.values()),dependencies:T}}finally{h.delete()}}async getSymbolDependencies(o){try{await this.ensureInitialized();let d=await this.fileReader.readFile(o);return this.analyzeFileContent(o,d).dependencies}catch(d){throw pg.fromError(d,o)}}extractSymbols(o,d,h,m,T){this.tryExtractSymbolFromNode(o,d,h,m,T)||this.extractSymbolsFromChildren(o,d,h,m,T)}tryExtractSymbolFromNode(o,d,h,m,T){return o.type==="function_item"?(this.handleFunctionItem(o,d,h,m,T),!0):o.type==="struct_item"?(this.handleStructItem(o,d,h,m,T),!0):o.type==="enum_item"?(this.handleEnumItem(o,d,h,m,T),!0):o.type==="trait_item"?(this.handleTraitItem(o,d,h,m,T),!0):o.type==="impl_item"?(this.handleImplItem(o,d,h,m,T),!0):!1}handleFunctionItem(o,d,h,m,T){let N=o.childForFieldName("name");if(!N)return;let z=this.getNodeText(N,h),ee=`${d}:${z}`,pe=this.hasModifier(o,"async"),Te=this.hasVisibilityModifier(o,"pub");m.set(ee,{name:z,kind:pe?"AsyncFunction":"FunctionDeclaration",line:N.startPosition.row+1,isExported:Te,id:ee,parentSymbolId:T,category:"function"}),this.extractSymbolsFromChildren(o,d,h,m,ee)}handleStructItem(o,d,h,m,T){let N=o.childForFieldName("name");if(!N)return;let z=this.getNodeText(N,h),ee=`${d}:${z}`,pe=this.hasVisibilityModifier(o,"pub");m.set(ee,{name:z,kind:"StructDeclaration",line:N.startPosition.row+1,isExported:pe,id:ee,parentSymbolId:T,category:"class"}),this.extractSymbolsFromChildren(o,d,h,m,ee)}handleEnumItem(o,d,h,m,T){let N=o.childForFieldName("name");if(!N)return;let z=this.getNodeText(N,h),ee=`${d}:${z}`,pe=this.hasVisibilityModifier(o,"pub");m.set(ee,{name:z,kind:"EnumDeclaration",line:N.startPosition.row+1,isExported:pe,id:ee,parentSymbolId:T,category:"type"}),this.extractSymbolsFromChildren(o,d,h,m,ee)}handleTraitItem(o,d,h,m,T){let N=o.childForFieldName("name");if(!N)return;let z=this.getNodeText(N,h),ee=`${d}:${z}`,pe=this.hasVisibilityModifier(o,"pub");m.set(ee,{name:z,kind:"InterfaceDeclaration",line:N.startPosition.row+1,isExported:pe,id:ee,parentSymbolId:T,category:"type"}),this.extractSymbolsFromChildren(o,d,h,m,ee)}handleImplItem(o,d,h,m,T){this.extractSymbolsFromChildren(o,d,h,m,T)}extractSymbolsFromChildren(o,d,h,m,T){for(let N of o.children)this.extractSymbols(N,d,h,m,T)}buildImportMap(o,d){let h=new Map,m=T=>{if(T.type==="use_declaration"&&this.extractUseDeclarationImports(T,d,h),T.type==="mod_item"){let N=T.childForFieldName("name");if(N){let z=this.getNodeText(N,d);h.set(z,z)}}for(let N of T.children)m(N)};return m(o),h}extractUseDeclarationImports(o,d,h){this.extractFromUseLists(o,d,h),this.extractFromScopedIdentifiers(o,d,h),this.extractFromUseAsClauses(o,d,h)}extractFromUseLists(o,d,h){let m=this.findAllByType(o,"use_list");for(let T of m){let N=this.findBaseModuleForUseList(T,d);this.extractIdentifiersFromUseList(T,N,d,h)}}findBaseModuleForUseList(o,d){let h=o.parent;for(;h;){if(h.type==="scoped_use_list"){let m=this.findScopedIdentifierInChildren(h,d);if(m)return m}h=h.parent}return""}findScopedIdentifierInChildren(o,d){for(let h of o.children)if(h.type==="scoped_identifier")return this.getNodeText(h,d);return""}extractIdentifiersFromUseList(o,d,h,m){for(let T of o.children)if(T.type==="identifier"){let N=this.getNodeText(T,h);m.set(N,d)}}extractFromScopedIdentifiers(o,d,h){let m=this.findAllByType(o,"scoped_identifier");for(let T of m){if(this.hasAncestorOfType(T,"use_list"))continue;let N=this.getNodeText(T,d),{localName:z,modulePath:ee}=this.splitModulePath(N);h.set(z,ee)}}splitModulePath(o){let d=o.split("::"),h=d.at(-1)??"",m=d.slice(0,-1).join("::");return{localName:h,modulePath:m}}extractFromUseAsClauses(o,d,h){let m=this.findAllByType(o,"use_as_clause");for(let T of m){let N=T.childForFieldName("path"),z=T.childForFieldName("alias");if(N&&z){let ee=this.getNodeText(N,d),pe=this.getNodeText(z,d);h.set(pe,ee)}}}extractDependencies(o,d,h,m,T,N,z){let ee=this.getScopeForNode(o,d,h,N);this.addCallDependencyIfAny(o,d,h,m,T,ee,z);for(let pe of o.children)this.extractDependencies(pe,d,h,m,T,ee,z)}getScopeForNode(o,d,h,m){if(o.type!=="function_item")return m;let T=o.childForFieldName("name");if(!T)return m;let N=this.getNodeText(T,h);return`${d}:${N}`}addCallDependencyIfAny(o,d,h,m,T,N,z){if(o.type!=="call_expression")return;let ee=o.childForFieldName("function");if(!ee||!N)return;let{moduleName:pe,symbolName:Te}=this.extractModuleAndSymbolName(ee,h),Ke=`${d}:${Te}`;if(T.has(Ke)){m.push({sourceSymbolId:N,targetSymbolId:Ke,targetFilePath:d,isTypeOnly:!1});return}if(pe&&z?.has(pe)){let ce=z.get(pe);if(ce===void 0)return;m.push({sourceSymbolId:N,targetSymbolId:`${ce}:${Te}`,targetFilePath:ce,isTypeOnly:!1});return}if(z?.has(Te)){let ce=z.get(Te);if(ce===void 0)return;m.push({sourceSymbolId:N,targetSymbolId:`${ce}:${Te}`,targetFilePath:ce,isTypeOnly:!1})}}extractModuleAndSymbolName(o,d){if(o.type==="field_expression"){let h=o.childForFieldName("field");if(h)return{moduleName:void 0,symbolName:this.getNodeText(h,d)}}if(o.type==="scoped_identifier"){let m=this.getNodeText(o,d).split("::");if(m.length>=2){let T=m.at(-1)??"";return{moduleName:m.slice(0,-1).join("::"),symbolName:T}}return{moduleName:void 0,symbolName:m[0]}}return{moduleName:void 0,symbolName:this.getNodeText(o,d)}}hasVisibilityModifier(o,d){if(o.childForFieldName("visibility_modifier"))return!0;for(let m of o.children)if(m.type==="visibility_modifier")return!0;return!1}hasAncestorOfType(o,d){let h=o.parent;for(;h;){if(h.type===d)return!0;h=h.parent}return!1}hasModifier(o,d){for(let h of o.children)if(h.type===d)return!0;return!1}findAllByType(o,d){let h=[],m=T=>{T.type===d&&h.push(T);for(let N of T.children)m(N)};return m(o),h}getNodeText(o,d){return d.slice(o.startIndex,o.endIndex)}};var Ske=class u{static typeScriptParsers=new Map;static typeScriptSymbolAnalyzers=new Map;static pythonParsers=new Map;static pythonSymbolAnalyzers=new Map;static rustParsers=new Map;static rustSymbolAnalyzers=new Map;static csharpParsers=new Map;static goParsers=new Map;static javaParsers=new Map;rootDir;extensionPath;ignoreTypeImports;constructor(o,d,h,m){this.rootDir=o,this.extensionPath=h,this.ignoreTypeImports=m}getAnalyzer(o){let d=VC(o);return u.getAnalyzer(d,this.rootDir,this.extensionPath,this.ignoreTypeImports)}getSymbolAnalyzer(o){let d=VC(o);return u.getSymbolAnalyzer(d,this.rootDir,this.extensionPath)}static detectLanguage(o){let d=VC(o);switch(HUt.default.extname(d).toLowerCase()){case".ts":case".tsx":case".js":case".jsx":case".mjs":case".cjs":case".vue":case".svelte":case".gql":case".graphql":return"typescript";case".py":case".pyi":return"python";case".rs":case".toml":return"rust";case".cs":case".csproj":return"csharp";case".go":return"go";case".java":return"java";default:return"unknown"}}static getAnalyzer(o,d,h,m){let T=VC(o);switch(this.detectLanguage(T)){case"typescript":{let z=this.buildCacheKey(d,m?"ignore-types":""),ee=this.typeScriptParsers.get(z);if(ee)return ee;let pe=new $De(d,m);return this.typeScriptParsers.set(z,pe),pe}case"python":{let z=this.buildCacheKey(d,h),ee=this.pythonParsers.get(z);if(ee)return ee;let pe=new dst(d,h);return this.pythonParsers.set(z,pe),pe}case"rust":{let z=this.buildCacheKey(d,h),ee=this.rustParsers.get(z);if(ee)return ee;let pe=new mst(d,h);return this.rustParsers.set(z,pe),pe}case"csharp":{let z=this.buildCacheKey(d,h),ee=this.csharpParsers.get(z);if(ee)return ee;let pe=new sst(d,h);return this.csharpParsers.set(z,pe),pe}case"go":{let z=this.buildCacheKey(d,h),ee=this.goParsers.get(z);if(ee)return ee;let pe=new lst(d,h);return this.goParsers.set(z,pe),pe}case"java":{let z=this.buildCacheKey(d,h),ee=this.javaParsers.get(z);if(ee)return ee;let pe=new ust(d,h);return this.javaParsers.set(z,pe),pe}default:throw new Error(`Unsupported language for file: ${o}`)}}static getSymbolAnalyzer(o,d,h){let m=VC(o);switch(this.detectLanguage(m)){case"typescript":{let N=this.buildCacheKey(d),z=this.typeScriptSymbolAnalyzers.get(N);if(z)return z;let ee=new ast(d);return this.typeScriptSymbolAnalyzers.set(N,ee),ee}case"python":{let N=this.buildCacheKey(d,h),z=this.pythonSymbolAnalyzers.get(N);if(z)return z;let ee=new fst(d,h);return this.pythonSymbolAnalyzers.set(N,ee),ee}case"rust":{let N=this.buildCacheKey(d,h),z=this.rustSymbolAnalyzers.get(N);if(z)return z;let ee=new hst(d,h);return this.rustSymbolAnalyzers.set(N,ee),ee}default:throw new Error(`Unsupported language for file: ${o}`)}}static isSupported(o){return this.detectLanguage(o)!=="unknown"}static reset(){this.typeScriptParsers.clear(),this.typeScriptSymbolAnalyzers.clear(),this.pythonParsers.clear(),this.pythonSymbolAnalyzers.clear(),this.rustParsers.clear(),this.rustSymbolAnalyzers.clear(),this.csharpParsers.clear(),this.goParsers.clear(),this.javaParsers.clear()}static releaseWorkspace(o){let d=`${o}\0`;for(let h of[this.typeScriptParsers,this.typeScriptSymbolAnalyzers,this.pythonParsers,this.pythonSymbolAnalyzers,this.rustParsers,this.rustSymbolAnalyzers,this.csharpParsers,this.goParsers,this.javaParsers])for(let m of h.keys())m.startsWith(d)&&h.delete(m)}static buildCacheKey(...o){return o.map(d=>d??"").join("\0")}};jC();GC();var JUt=Uh("ReferencingFilesFinder"),Tke=class{sourceFileCollector;getRootDir;getConcurrency;findReferenceInFile;constructor(o){this.sourceFileCollector=o.sourceFileCollector,this.getRootDir=o.getRootDir,this.getConcurrency=o.getConcurrency,this.findReferenceInFile=o.findReferenceInFile}async findReferencingFilesFallback(o){let d=ri(o),h=this.extractBasename(d);if(!h)return[];JUt.debug("findReferencingFilesFallback for",d,"basename:",h);let m=await this.sourceFileCollector.collectAllSourceFiles(this.getRootDir()),T=[],N=this.getConcurrency()??8;for(let z=0;z<m.length;z+=N){let ee=m.slice(z,z+N),pe=await Promise.all(ee.filter(Te=>ri(Te)!==d).map(Te=>this.findReferenceInFile(Te,d,h)));for(let Te of pe)Te&&T.push(Te)}return JUt.debug("findReferencingFilesFallback found",T.length,"referencing files"),T}extractBasename(o){return o.split(/[/\\]/).pop()?.replace(/\.[^/.]+$/,"")}};var KUt=cc(require("node:fs/promises"));GC();jC();var $Ut=Uh("ReverseIndex"),rOt=1,fse=class u{reverseMap=new Map;fileHashes=new Map;rootDir;constructor(o){this.rootDir=ri(o)}addDependencies(o,d,h){let m=ri(o);this.removeDependenciesFromSource(m);for(let T of d){let N=ri(T.path),z={sourcePath:m,type:T.type,line:T.line,module:T.module},ee=this.reverseMap.get(N);ee||(ee=new Map,this.reverseMap.set(N,ee)),ee.set(m,z)}h&&this.fileHashes.set(m,h)}removeDependenciesFromSource(o){let d=ri(o);for(let[,h]of this.reverseMap)h.delete(d);this.fileHashes.delete(d)}getReferencingFiles(o){let d=ri(o),h=this.reverseMap.get(d);return h?.size===0?(this.reverseMap.delete(d),[]):h?Array.from(h.values()).map(m=>({path:m.sourcePath,type:m.type,line:m.line,module:m.module})):[]}getCallerCount(o){let d=ri(o);return this.reverseMap.get(d)?.size??0}isFileStale(o,d){let h=ri(o),m=this.fileHashes.get(h);return m?m.mtime!==d.mtime||m.size!==d.size:!0}getFileHash(o){return this.fileHashes.get(ri(o))}updateFileHash(o,d){this.fileHashes.set(ri(o),d)}hasEntries(){return this.reverseMap.size>0}hasFile(o){return this.fileHashes.has(ri(o))}get indexedFileCount(){return this.fileHashes.size}get targetFileCount(){return this.reverseMap.size}clear(){this.reverseMap.clear(),this.fileHashes.clear()}getEmptyMapCount(){let o=0;for(let d of this.reverseMap.values())d.size===0&&o++;return o}cleanup(){let o=0,d=[];for(let[h,m]of this.reverseMap)m.size===0&&d.push(h);for(let h of d)this.reverseMap.delete(h),o++;return o}static async getFileHashFromDisk(o){try{let d=await KUt.stat(o);return{mtime:d.mtimeMs,size:d.size}}catch{return null}}serialize(){let o={};for(let[h,m]of this.reverseMap)m.size!==0&&(o[h]=Array.from(m.values()));let d={};for(let[h,m]of this.fileHashes)d[h]=m;return{version:rOt,timestamp:Date.now(),rootDir:this.rootDir,reverseMap:o,fileHashes:d}}static deserialize(o,d){let h=ri(d),m=ri(o.rootDir);if(o.version!==rOt)return $Ut.warn("Version mismatch:",o.version,"!==",rOt),null;if(m!==h)return $Ut.warn("Root dir mismatch:",o.rootDir,"!==",d),null;let T=new u(d);for(let[N,z]of Object.entries(o.fileHashes))T.fileHashes.set(ri(N),z);for(let[N,z]of Object.entries(o.reverseMap)){let ee=ri(N),pe=new Map;for(let Te of z){let Ke=ri(Te.sourcePath);pe.set(Ke,{...Te,sourcePath:Ke})}T.reverseMap.set(ee,pe)}return T}async validateIndex(o=.2,d,h){let m=[],T=[],N=h?[...new Set(h.map(ri))]:[...this.fileHashes.keys()];for(let Ke of N){let ce=await u.getFileHashFromDisk(Ke);if(!ce){T.push(Ke);continue}(!this.fileHashes.has(Ke)||this.isFileStale(Ke,ce))&&m.push(Ke)}let z=0;if(d)for(let Ke of d){let ce=ri(Ke);!this.fileHashes.has(ce)&&!m.includes(ce)&&(m.push(ce),z++)}let ee=(h?N.length:this.fileHashes.size)+z,pe=m.length+T.length,Te=ee>0?pe/ee:0;return{isValid:Te<=o,staleFiles:m,stalePercentage:Te,missingFiles:T}}getStats(){let o=0;for(let d of this.reverseMap.values())o+=d.size;return{indexedFiles:this.fileHashes.size,targetFiles:this.reverseMap.size,totalReferences:o}}};iOt();var Cke=class{constructor(o){this.rootDir=o}rootDir;reverseIndex=null;symbolReverseIndex=null;enable(o){let d=!1;if(this.reverseIndex??=new fse(this.rootDir),this.symbolReverseIndex??=new Eke(this.rootDir),o)try{let h=JSON.parse(o),m=fse.deserialize(h,this.rootDir);m&&(this.reverseIndex=m,d=!0)}catch{d=!1}return d}disable(){this.reverseIndex?.clear(),this.reverseIndex=null,this.symbolReverseIndex?.clear(),this.symbolReverseIndex=null}clear(){this.reverseIndex?.clear(),this.symbolReverseIndex?.clear()}isEnabled(){return this.reverseIndex!==null}hasEntries(){return this.reverseIndex?.hasEntries()??!1}ensure(){this.reverseIndex??=new fse(this.rootDir)}addDependencies(o,d,h){this.reverseIndex?.addDependencies(o,d,h)}removeDependenciesFromSource(o){this.reverseIndex?.removeDependenciesFromSource(o)}getReferencingFiles(o){return this.reverseIndex?this.reverseIndex.getReferencingFiles(o):[]}getCallerCount(o){return this.reverseIndex?this.reverseIndex.getCallerCount(o):0}getSerialized(){return this.reverseIndex?JSON.stringify(this.reverseIndex.serialize()):null}validate(o=.2,d,h){return this.reverseIndex?.validateIndex(o,d,h)??null}getStats(){return this.reverseIndex?.getStats()}addSymbolDependencies(o,d,h){this.symbolReverseIndex?.addDependencies(o,d,h)}removeSymbolDependenciesFromSource(o){this.symbolReverseIndex?.removeDependenciesFromSource(o)}getSymbolReferencingFiles(o){return this.symbolReverseIndex?.getCallerFiles(o)??[]}getSymbolStats(){return this.symbolReverseIndex?.getStats()}};Yae();Yae();GC();var Ake=class{constructor(o,d,h){this.dependencyCache=o;this.symbolCache=d;this.reverseIndexManager=h}dependencyCache;symbolCache;reverseIndexManager;clearAll(){this.dependencyCache.clear(),this.symbolCache.clear(),this.reverseIndexManager.clear()}invalidateFile(o){let d=ri(o),h=this.dependencyCache.has(d);return this.dependencyCache.delete(d),this.symbolCache.delete(d),this.reverseIndexManager.removeDependenciesFromSource(d),h}invalidateFiles(o){let d=0;for(let h of o)this.invalidateFile(h)&&d++;return d}handleFileDeleted(o){let d=ri(o);this.dependencyCache.delete(d),this.symbolCache.delete(d),this.reverseIndexManager.removeDependenciesFromSource(d)}};GC();jC();var mse=Uh("SpiderDependencyAnalyzer"),Ike=class{constructor(o,d,h,m){this.languageService=o;this.resolver=d;this.dependencyCache=h;this.reverseIndexManager=m}languageService;resolver;dependencyCache;reverseIndexManager;async analyze(o){let d=ri(o),h=this.dependencyCache.get(d);if(h)return mse.debug(`Returning ${h.length} cached dependencies for ${o}`),await this.updateReverseIndexIfEnabled(o,d,h),h;mse.debug(`Analyzing ${o}...`);try{let m=this.languageService.getAnalyzer(o),T=await m.parseImports(o);mse.debug(`Parsed ${T.length} imports from ${o}`);let N=[],z=new Set;for(let ee of T){let pe=await m.resolvePath(o,ee.module);if(!pe){mse.debug(`Failed to resolve module "${ee.module}" from ${o}`);continue}if(!this.resolver.isWithinWorkspace(pe)){mse.warn(`Skipping dependency outside workspace: ${ee.module}`);continue}let Te=ri(pe);z.has(Te)||(z.add(Te),N.push({path:Te,type:ee.type,line:ee.line,module:ee.module}))}return mse.debug(`Resolved ${N.length} dependencies for ${o}`),this.dependencyCache.set(d,N),await this.updateReverseIndexIfEnabled(o,d,N),N}catch(m){let T=pg.fromError(m,o);if(T.code==="FILE_TOO_LARGE"||T.code==="TIMEOUT")return mse.warn(`Skipping ${o}: ${T.toUserMessage()}`),[];throw mse.error("Analysis failed:",T.toUserMessage(),T.code),T}}async resolveModuleSpecifier(o,d){try{return await this.resolver.resolve(o,d)}catch{return null}}invalidateDependencyCache(o){this.dependencyCache.delete(ri(o))}async updateReverseIndexIfEnabled(o,d,h){if(!this.reverseIndexManager.isEnabled())return;let m=await fse.getFileHashFromDisk(o);m&&this.reverseIndexManager.addDependencies(d,h,m)}};GC();UDe();GC();function iEe(u){let d=ri(u).split("/");for(let h=0;h<d.length-1;h++)if(Ctt.includes(d[h]))return!0;return!1}jC();var _se=Uh("SpiderGraphCrawler"),Dke=class{constructor(o,d){this.dependencyAnalyzer=o;this.getConfig=d}dependencyAnalyzer;getConfig;async crawl(o,d){let h=new Set,m=[],T=new Set,N=new Set,z={},ee=d?.maxDepth??this.getConfig().maxDepth??3,pe=()=>{if(d?.signal?.aborted){let Ke=new Error("Crawl cancelled");throw Ke.name="AbortError",Ke}};_se.debug(`Starting crawl from: ${o}`);let Te=async(Ke,ce)=>{pe();let Bt=ri(Ke);if(ce>ee){_se.debug(`Skipping ${Ke}: max depth ${ee} reached`);return}if(N.has(Bt)){_se.debug(`Skipping ${Ke}: already visited`);return}N.add(Bt),h.add(Bt);try{let tt=await this.dependencyAnalyzer.analyze(Ke);pe(),_se.debug(`Found ${tt.length} dependencies for ${Ke}`);for(let st of tt){pe(),h.add(st.path);let sr=`${Bt}->${st.path}`;T.has(sr)||(T.add(sr),m.push({source:Bt,target:st.path}),_se.debug(`Added edge: ${Bt} -> ${st.path}`)),st.module.startsWith("@")&&st.module.includes("/")&&!st.module.startsWith("@/")&&(z[st.path]=st.module),iEe(st.path)?_se.debug(`Skipping ${st.path}: in ignored directory`):await Te(st.path,ce+1)}}catch(tt){if(tt instanceof Error&&tt.name==="AbortError")throw tt;_se.debug(`Failed to analyze ${Ke}: ${tt}`)}};return await Te(o,0),_se.debug(`Crawl completed: ${h.size} nodes, ${m.length} edges`),{nodes:Array.from(h),edges:m,nodeLabels:Object.keys(z).length>0?z:void 0}}async crawlFrom(o,d,h=10,m){let T=new Set,N=[],z=new Set,ee={},pe=new Set(Array.from(d).map(Ln=>ri(Ln))),Te=ri(o),Ke=new Set,ce=[],Bt=new Set,tt={},st=m?.batchSize??200,sr=()=>{if(m?.signal?.aborted){let Ln=new Error("Expansion cancelled");throw Ln.name="AbortError",Ln}},ur=(Ln,vn)=>vn>h?!0:Ln===Te?vn!==0&&z.has(Ln):z.has(Ln),jr=Ln=>{pe.has(Ln)||(T.add(Ln),Ke.add(Ln))},Oi=(Ln,vn)=>{let Fi=`${vn}->${Ln.path}`;Bt.has(Fi)||(Bt.add(Fi),N.push({source:vn,target:Ln.path}),ce.push({source:vn,target:Ln.path})),!z.has(Ln.path)&&!pe.has(Ln.path)&&(T.add(Ln.path),Ke.add(Ln.path)),Ln.module.startsWith("@")&&Ln.module.includes("/")&&!Ln.module.startsWith("@/")&&(ee[Ln.path]=Ln.module,tt[Ln.path]=Ln.module)},Yi=async()=>{if(!m?.onBatch){Ke.clear(),ce.length=0;return}if(Ke.size===0&&ce.length===0)return;let Ln={nodes:Array.from(Ke),edges:[...ce],nodeLabels:Object.keys(tt).length>0?{...tt}:void 0};Ke.clear(),ce.length=0;for(let vn of Object.keys(tt))delete tt[vn];await m.onBatch(Ln)},Ci=async(Ln,vn)=>{sr();let Fi=ri(Ln);if(!ur(Fi,vn)){z.add(Fi),jr(Fi);try{let ii=await this.dependencyAnalyzer.analyze(Ln);for(let _i of ii)Oi(_i,Fi),iEe(_i.path)||await Ci(_i.path,vn+1);Ke.size+ce.length>=st&&await Yi()}catch{}}};return await Ci(o,0),await Yi(),{nodes:Array.from(T),edges:N,nodeLabels:Object.keys(ee).length>0?ee:void 0}}};var kke=class{cancelled=!1;reset(){this.cancelled=!1}cancel(){this.cancelled=!0}isCancelled(){return this.cancelled}};jC();GC();function Pke(){return new Promise(u=>setTimeout(u,1))}var Nke=50;var oEe=Uh("SpiderIndexingService"),wke=class{constructor(o,d,h,m,T,N,z,ee,pe,Te){this.dependencyAnalyzer=o;this.dependencyCache=d;this.reverseIndexManager=h;this.sourceFileCollector=m;this.indexerStatus=T;this.workerManager=N;this.cancellation=z;this.getConfig=ee;this.yieldToEventLoop=pe;this.getSymbolGraph=Te}dependencyAnalyzer;dependencyCache;reverseIndexManager;sourceFileCollector;indexerStatus;workerManager;cancellation;getConfig;yieldToEventLoop;getSymbolGraph;cancel(){this.cancellation.cancel(),this.workerManager.cancel()}async disposeWorker(){await this.workerManager.dispose()}async analyzeFileForIndex(o,d){try{if(await this.dependencyAnalyzer.analyze(o),this.getSymbolGraph&&d<(this.getConfig().maxSymbolAnalyzerFiles??100))try{let h=await this.getSymbolGraph(o);h.dependencies.length>0&&this.reverseIndexManager.addSymbolDependencies(o,h.dependencies)}catch{}return!0}catch{return!1}}checkCancellation(o){if(this.cancellation.isCancelled())return this.indexerStatus.setCancelled(),{indexedFiles:o,duration:Date.now()-(this.indexerStatus.getSnapshot().startTime??Date.now()),cancelled:!0}}async buildFullIndex(o){this.reverseIndexManager.ensure(),this.cancellation.reset(),this.indexerStatus.startCounting();let d=await this.sourceFileCollector.collectAllSourceFiles(this.getConfig().rootDir),h=this.checkCancellation(0);if(h)return h;let m=d.length;this.indexerStatus.setTotal(m),await this.yieldToEventLoop(),this.indexerStatus.startIndexing();let T=0,N=Date.now();try{for(let pe of d){let Te=this.checkCancellation(T);if(Te)return Te;await this.analyzeFileForIndex(pe,T),T++,this.indexerStatus.updateProgress(T,pe),o?.(T,m,pe),Date.now()-N>=Nke&&(await this.yieldToEventLoop(),N=Date.now())}this.indexerStatus.complete();let z=this.indexerStatus.getSnapshot(),ee=Date.now()-(z.startTime??Date.now());return{indexedFiles:T,duration:ee,cancelled:!1}}catch(z){let ee=pg.fromError(z);throw this.indexerStatus.setError(ee.toUserMessage()),oEe.error("Indexing failed:",ee.toUserMessage(),ee.code),ee}}async buildFullIndexInWorker(o,d){this.cancellation.reset();let h=this.getConfig();return this.workerManager.buildFullIndexInWorker({workerPath:o,progressCallback:d,config:{rootDir:h.rootDir,excludeNodeModules:h.excludeNodeModules,tsConfigPath:h.tsConfigPath,progressInterval:h.indexingProgressInterval,extensionPath:h.extensionPath,ignoreTypeImports:h.ignoreTypeImports}})}async reindexStaleFiles(o,d){if(!this.reverseIndexManager.isEnabled())return 0;this.cancellation.reset(),oEe.info(`Re-indexing ${o.length} stale files`),this.indexerStatus.startCounting(),this.indexerStatus.setTotal(o.length),this.indexerStatus.startIndexing();let h=this.getConfig().indexingConcurrency??8,m=0;for(let T=0;T<o.length;T+=h){if(this.cancellation.isCancelled())return this.indexerStatus.setCancelled(),m;let N=o.slice(T,T+h);await Promise.all(N.map(async z=>{let ee=ri(z);oEe.debug(`Re-indexing stale file: ${z}`);try{this.reverseIndexManager.removeDependenciesFromSource(ee),this.dependencyCache.delete(ee),oEe.debug(`Deleted cache for ${z}, re-analyzing...`),await this.dependencyAnalyzer.analyze(z),oEe.debug(`Successfully re-analyzed ${z}`)}catch(pe){oEe.error(`Failed to re-index ${z}:`,pe),this.reverseIndexManager.removeDependenciesFromSource(ee)}})),m+=N.length,this.indexerStatus.updateProgress(m,N.at(-1)),d?.(m,o.length,N.at(-1)),await this.yieldToEventLoop()}return this.cancellation.isCancelled()?(this.indexerStatus.setCancelled(),m):(this.indexerStatus.complete(),oEe.info(`Completed re-indexing ${m} files`),m)}};GC();var Rke=class{constructor(o,d,h,m=()=>!0,T=()=>!1){this.reverseIndexManager=o;this.dependencyAnalyzer=d;this.fileReader=h;this.isIndexReady=m;this.isIndexingActive=T}reverseIndexManager;dependencyAnalyzer;fileReader;isIndexReady;isIndexingActive;fallbackFinder=null;_fallbackCache=new Map;_fallbackCacheVersion=0;_fallbackCacheEntryVersion=new Map;setFallbackFinder(o){this.fallbackFinder=o}clearFallbackCache(){this._fallbackCacheVersion++}async findReferencingFiles(o){let d=ri(o),h=this.reverseIndexManager.hasEntries();if(h&&this.isIndexReady())return this.reverseIndexManager.getReferencingFiles(d);let m=h?this.reverseIndexManager.getReferencingFiles(d):[];if(h&&!this.isIndexingActive()||!this.fallbackFinder)return m;let T=await this.getFallbackReferencingFiles(d);return m.length===0?T:T.length===0?m:this.mergeDependencies(m,T)}async findReferencingFilesWithFallback(o){this.clearFallbackCache();let d=ri(o),h=this.reverseIndexManager.hasEntries()?this.reverseIndexManager.getReferencingFiles(d):[],m=await this.getFallbackReferencingFiles(d);return this.mergeDependencies(h,m)}async getFallbackReferencingFiles(o){if(!this.fallbackFinder)return[];if(this._fallbackCacheEntryVersion.get(o)===this._fallbackCacheVersion){let m=this._fallbackCache.get(o);if(m!==void 0)return m}let h=await this.fallbackFinder.findReferencingFilesFallback(o);return this._fallbackCache.set(o,h),this._fallbackCacheEntryVersion.set(o,this._fallbackCacheVersion),h}mergeDependencies(o,d){let h=new Map;for(let m of[...o,...d]){let T=ri(m.path);h.has(T)||h.set(T,m)}return[...h.values()]}async findReferenceInFile(o,d,h){try{if(!(await this.fileReader.readFile(o)).includes(h))return null;this.dependencyAnalyzer.invalidateDependencyCache(o);let N=(await this.dependencyAnalyzer.analyze(o)).find(z=>ri(z.path)===d);return N?{path:ri(o),type:N.type,line:N.line,module:N.module}:null}catch{return null}}};var oOt=cc(require("node:path"));UDe();jC();Yae();GC();var hse=Uh("SpiderSymbolService"),Mke=class{constructor(o,d,h,m,T,N,z,ee){this.astWorkerHost=o;this.symbolCache=d;this.fileReader=h;this.resolver=m;this.symbolDependencyHelper=T;this.getConfig=N;this.findReferencingFiles=z;this.languageService=ee}astWorkerHost;symbolCache;fileReader;resolver;symbolDependencyHelper;getConfig;findReferencingFiles;languageService;async getSymbolGraph(o){if(!oOt.default.isAbsolute(o))try{let m=await this.resolveModuleSpecifier(this.getConfig().rootDir,o);m&&(o=m)}catch{}let d=ri(o),h=this.symbolCache.get(d);if(h)return h;try{let m=await this.fileReader.readFile(o),T=await this.astWorkerHost.analyzeFile(d,m),N=await Promise.all(T.dependencies.map(async ee=>{try{let Te=await this.languageService.getAnalyzer(d).resolvePath(d,ee.targetFilePath);if(Te)return{...ee,targetFilePath:ri(Te)}}catch{}return ee})),z={symbols:T.symbols,dependencies:N};return this.symbolCache.set(d,z),z}catch(m){let T=pg.fromError(m,o);if(hse.error("Symbol analysis failed:",T.toUserMessage()),T.isRecoverable())return{symbols:[],dependencies:[]};throw T}}async findUnusedSymbols(o){try{let d=ri(o),{symbols:h}=await this.getSymbolGraph(d),m=h.filter(Te=>Te.isExported);if(m.length===0)return[];let T=await this.findReferencingFiles(d),N=await this.collectUsedSymbolIds(T,d),z=await this.fileReader.readFile(d),ee=await this.astWorkerHost.getInternalExportDependencyGraph(d,z),pe=this.expandUsedSymbolsViaInternalGraph(N,ee);return m.filter(Te=>!pe.has(Te.id))}catch(d){let h=pg.fromError(d,o);return hse.error("Find unused symbols failed:",h.toUserMessage()),[]}}async getSymbolDependents(o,d){let h=await this.findReferencingFiles(o);return this.collectSymbolDependents(h,o,d)}async traceFunctionExecution(o,d,h=10){let m=`${o}:${d}`,T=[],N=new Set,z=!1,ee=async(pe,Te,Ke)=>{if(Ke>h){z=!0;return}let ce=`${pe}:${Te}`;if(!N.has(ce)){N.add(ce);try{let{symbols:Bt,dependencies:tt}=await this.getSymbolGraph(pe),st=Bt.find(ur=>ur.name===Te);if(!st)return;let sr=tt.filter(ur=>ur.sourceSymbolId===st.id);for(let ur of sr){let jr=null;try{jr=await this.resolver.resolve(pe,ur.targetFilePath)}catch{}let Oi=ur.targetSymbolId.split(":").pop()||"";T.push({depth:Ke,callerSymbolId:ce,calledSymbolId:ur.targetSymbolId,calledFilePath:ur.targetFilePath,resolvedFilePath:jr}),jr&&!iEe(jr)&&await ee(jr,Oi,Ke+1)}}catch(Bt){let tt=pg.fromError(Bt,pe);hse.error("Trace execution failed:",ce,tt.toUserMessage())}}};return await ee(o,d,1),{rootSymbol:{id:m,filePath:o,symbolName:d},callChain:T,visitedSymbols:Array.from(N),maxDepthReached:z}}async resolveModuleSpecifier(o,d){try{return await this.resolver.resolve(o,d)}catch{return null}}expandUsedSymbolsViaInternalGraph(o,d){let h=new Set(o),m=Array.from(h);for(;m.length>0;){let T=m.pop();if(T===void 0)continue;let N=d.get(T);if(N)for(let z of N)h.has(z)||(h.add(z),m.push(z))}return h}async collectUsedSymbolIds(o,d){let h=new Set;for(let m of o){let{dependencies:T}=await this.getSymbolGraph(m.path);for(let N of T)if(await this.symbolDependencyHelper.doesDependencyTargetFile(N,m.path,d)){let ee=this.symbolDependencyHelper.extractSymbolName(N.targetSymbolId);h.add(this.symbolDependencyHelper.buildUsedSymbolId(d,ee))}}return h}async collectSymbolDependents(o,d,h){let m=[],T=ri(d);for(let N of o){let{dependencies:z}=await this.getSymbolGraph(N.path);for(let ee of z)await this.symbolDependencyHelper.doesDependencyTargetFile(ee,N.path,T)&&this.symbolDependencyHelper.extractSymbolName(ee.targetSymbolId)===h&&m.push(ee)}return m}async verifyDependencyUsage(o,d){try{let h=ri(o),m=ri(d);if(iEe(m))return!0;if(this.isAstUnsupportedFile(h))return hse.debug(`Skipping symbol analysis for unsupported file type: ${h}`),!0;let{dependencies:T}=await this.getSymbolGraph(h);if(T.length===0)return!1;let N=m.split("/").pop()||"",z=T.filter(ee=>ee.targetFilePath===m||ee.targetFilePath.includes(N)||!ee.targetFilePath.startsWith("/"));for(let ee of z)if(await this.symbolDependencyHelper.doesDependencyTargetFile(ee,h,m))return!0;return!1}catch(h){let m=pg.fromError(h,o);return hse.warn("Usage verification failed, assuming used:",m.message),!0}}async verifyDependencyUsageBatch(o,d){try{let h=ri(o);if(this.isAstUnsupportedFile(h))return hse.debug(`Skipping symbol analysis for unsupported file type: ${h}`),this.markAllAsUsed(d);let{dependencies:m}=await this.getSymbolGraph(h);if(m.length===0)return this.markAllAsUnused(d);let T=await this.buildResolvedTargetsSet(m,h);return this.checkTargetsAgainstResolved(d,T)}catch(h){let m=pg.fromError(h,o);return hse.warn("Batch usage verification failed, assuming all used:",m.message),this.markAllAsUsed(d)}}markAllAsUsed(o){let d=new Map;for(let h of o)d.set(ri(h),!0);return d}markAllAsUnused(o){let d=new Map;for(let h of o)d.set(ri(h),!1);return d}async buildResolvedTargetsSet(o,d){let h=new Set;for(let m of o)try{let T=await this.symbolDependencyHelper.resolveTargetPath(m,d);T&&h.add(ri(T))}catch{}return h}checkTargetsAgainstResolved(o,d){let h=new Map;for(let m of o){let T=ri(m);if(iEe(T)){h.set(T,!0);continue}h.set(T,d.has(T))}return h}isAstUnsupportedFile(o){return o.endsWith(".gql")||o.endsWith(".graphql")||o.endsWith(".cs")||o.endsWith(".csproj")||o.endsWith(".go")||o.endsWith(".java")}async scanDeadCode(o,d){let{maxFiles:h=500,hasReverseIndex:m}=d;if(!m)throw new pg("Dead code scan requires the reverse index. Wait for indexing to complete or call rebuild_index first.","INDEX_NOT_READY");let T=this.getConfig(),z=await new TR({excludeNodeModules:T.excludeNodeModules??!0}).collectAllSourceFiles(o),ee=new Set(fUe),Te=z.filter(Bt=>{let tt=oOt.default.extname(Bt).toLowerCase();return ee.has(tt)}).slice(0,h),Ke=[],ce=0;for(let Bt of Te)try{let tt=await this.findUnusedSymbols(Bt);tt.length>0&&Ke.push({filePath:Bt,unusedSymbols:tt})}catch(tt){let st=pg.fromError(tt,Bt);hse.warn("scanDeadCode: skipping file due to error:",Bt,st.message),ce++}return{entries:Ke,scannedFiles:Te.length,skippedFiles:ce}}};var YUt=require("node:worker_threads"),QUt=cc(require("node:path")),gst=class{worker=null;statusCallbacks=new Set;currentState="idle";currentProgress=0;currentTotal=0;currentFile="";startTime=void 0;cancelled=!1;stopActiveRequest=null;workerTermination=null;workerPath;constructor(o){this.workerPath=o??QUt.join(__dirname,"indexerWorker.js")}subscribeToStatus(o){return this.statusCallbacks.add(o),o(this.getSnapshot()),()=>this.statusCallbacks.delete(o)}getSnapshot(){let o=this.currentTotal>0?Math.round(this.currentProgress/this.currentTotal*100):0;return{state:this.currentState,processed:this.currentProgress,total:this.currentTotal,currentFile:this.currentFile,percentage:o,startTime:this.startTime,cancelled:this.cancelled}}notifySubscribers(){let o=this.getSnapshot();for(let d of this.statusCallbacks)try{d(o)}catch{}}updateState(o,d=0,h=0,m=""){this.currentState=o,this.currentProgress=d,this.currentTotal=h,this.currentFile=m,this.notifySubscribers()}getPendingCount(){return this.worker||this.workerTermination?1:0}async startIndexing(o){if(this.worker||this.workerTermination)throw new Error("Indexing already in progress");this.cancelled=!1,this.startTime=Date.now(),this.updateState("counting");let d=o.timeoutMs??600*1e3;return new Promise((h,m)=>{let T=!1,N=pe=>{T||(T=!0,clearTimeout(ee),this.stopActiveRequest=null,h(pe))},z=pe=>{T||(T=!0,clearTimeout(ee),this.stopActiveRequest=null,m(pe))},ee=setTimeout(()=>{this.cancel(),this.updateState("error"),this.cleanupWorker().then(()=>{z(new Error(`Indexing timed out after ${Math.round(d/6e4)} minute(s)`))})},d);this.stopActiveRequest=()=>{this.cancelled=!0,this.updateState("complete",this.currentProgress,this.currentTotal),N({indexedFiles:this.currentProgress,duration:Date.now()-(this.startTime??Date.now()),cancelled:!0,data:[]})};try{this.worker=new YUt.Worker(this.workerPath,{workerData:o});let pe={indexedFiles:0,duration:0,cancelled:!1,data:[]};this.worker.on("message",Te=>{switch(Te.type){case"counting":this.updateState("counting");break;case"progress":Te.data&&this.updateState("indexing",Te.data.processed??0,Te.data.total??0,Te.data.currentFile??"");break;case"complete":Te.data&&(pe={indexedFiles:Te.data.processed??0,duration:Te.data.duration??0,cancelled:this.cancelled,data:Te.data.indexData??[]}),this.updateState("complete"),this.cleanupWorker().then(()=>N(pe));break;case"error":this.updateState("error"),this.cleanupWorker().then(()=>z(new Error(Te.error??"Unknown worker error")));break}}),this.worker.on("error",Te=>{this.updateState("error"),this.cleanupWorker().then(()=>z(Te))}),this.worker.on("exit",Te=>{Te!==0&&this.currentState!=="complete"&&this.currentState!=="error"&&(this.updateState("error"),this.cleanupWorker().then(()=>z(new Error(`Worker stopped with exit code ${Te}`))))}),this.worker.postMessage({type:"start"})}catch(pe){this.updateState("error"),this.cleanupWorker().then(()=>z(pe))}})}cancel(){if(this.cancelled=!0,this.worker)try{this.worker.postMessage({type:"cancel"})}catch{}}isIndexing(){return this.currentState==="indexing"||this.currentState==="counting"}cleanupWorker(){if(this.worker){let o=this.worker;this.worker=null,o.removeAllListeners(),o.on("error",()=>{});let d=o.terminate().then(()=>{},()=>{}).then(()=>{this.workerTermination===d&&(this.workerTermination=null)});return this.workerTermination=d,d}return this.workerTermination??Promise.resolve()}async dispose(){this.cancel(),this.stopActiveRequest?.(),await this.cleanupWorker(),this.statusCallbacks.clear()}};GC();var Lke=class{constructor(o,d,h){this.indexerStatus=o;this.reverseIndexManager=d;this.dependencyCache=h}indexerStatus;reverseIndexManager;dependencyCache;workerHost=null;async buildFullIndexInWorker(o){let{workerPath:d,config:h,progressCallback:m}=o;this.workerHost??=new gst(d),this.reverseIndexManager.ensure();let T=this.workerHost.subscribeToStatus(N=>{switch(N.state){case"counting":this.indexerStatus.startCounting();break;case"indexing":N.total>0&&(this.indexerStatus.setTotal(N.total),this.indexerStatus.startIndexing()),this.indexerStatus.updateProgress(N.processed,N.currentFile);break;case"complete":this.indexerStatus.complete();break;case"error":this.indexerStatus.setError(N.errorMessage??"Unknown error");break}m&&N.state==="indexing"&&m(N.processed,N.total,N.currentFile)});try{let N=await this.workerHost.startIndexing({rootDir:h.rootDir,excludeNodeModules:h.excludeNodeModules,tsConfigPath:h.tsConfigPath,extensionPath:h.extensionPath,ignoreTypeImports:h.ignoreTypeImports});return this.importWorkerResult(N),{indexedFiles:N.indexedFiles,duration:N.duration,cancelled:N.cancelled}}finally{T()}}cancel(){this.workerHost?.cancel()}async dispose(){let o=this.workerHost;this.workerHost=null,await o?.dispose()}importWorkerResult(o){for(let d of o.data){let h=ri(d.filePath);this.dependencyCache.set(h,d.dependencies),this.reverseIndexManager.addDependencies(h,d.dependencies,{mtime:d.mtime,size:d.size})}}};GC();jC();var Oke=Uh("SymbolDependencyHelper"),Fke=class{resolveFn;constructor(o){this.resolveFn=o.resolve}async doesDependencyTargetFile(o,d,h){let m=ri(o.targetFilePath),T=ri(h);if(Oke.debug(`Comparing: dep.targetFilePath='${m}' vs targetFilePath='${T}'`),m===T)return Oke.debug("\u2713 Direct match"),!0;Oke.debug(`Attempting fallback resolution for '${o.targetFilePath}' from '${d}'`);let N=await this.resolveFn(d,o.targetFilePath);if(N){let z=ri(N);Oke.debug(`Resolved to: '${z}'`);let ee=z===T;return Oke.debug(ee?"\u2713 Fallback match":"\u2717 No match after resolution"),ee}return Oke.debug("\u2717 Resolution failed, no match"),!1}extractSymbolName(o){return o.split(":").pop()||""}extractBasename(o){return o.split(/[/\\]/).pop()?.replace(/\.[^/.]+$/,"")}buildUsedSymbolId(o,d){return`${ri(o)}:${d}`}async resolveTargetPath(o,d){let h=ri(o.targetFilePath);if(h.startsWith("/")||/^[a-zA-Z]:\//.test(h))return h;try{let m=await this.resolveFn(d,o.targetFilePath);return m?ri(m):null}catch{return null}}};Im();var yst=class{activeIndexingOperations=new Set;disposed=!1;disposePromise=null;workerShutdownPromise=null;config;languageService;resolver;cache;symbolCache;fileReader;astWorkerHost;reverseIndexManager;indexerStatus;workerManager;cancellation;sourceFileCollector;referencingFilesFinder;symbolDependencyHelper;dependencyAnalyzer;referenceLookup;symbolService;graphCrawler;indexingService;cacheCoordinator;constructor(o){if("dependencyAnalyzer"in o){let d=o;this.config=d.config,this.languageService=d.languageService,this.resolver=d.resolver,this.cache=d.cache,this.symbolCache=d.symbolCache,this.fileReader=d.fileReader,this.astWorkerHost=d.astWorkerHost,this.reverseIndexManager=d.reverseIndexManager,this.indexerStatus=d.indexerStatus,this.workerManager=d.workerManager,this.cancellation=d.cancellation,this.sourceFileCollector=d.sourceFileCollector,this.referencingFilesFinder=d.referencingFilesFinder,this.symbolDependencyHelper=d.symbolDependencyHelper,this.dependencyAnalyzer=d.dependencyAnalyzer,this.referenceLookup=d.referenceLookup,this.symbolService=d.symbolService,this.graphCrawler=d.graphCrawler,this.indexingService=d.indexingService,this.cacheCoordinator=d.cacheCoordinator}else{let d=o;this.config={maxDepth:50,excludeNodeModules:!0,enableReverseIndex:!1,indexingConcurrency:4,maxCacheSize:500,maxSymbolCacheSize:200,maxSymbolAnalyzerFiles:100,...d},this.languageService=new Ske(d.rootDir,d.tsConfigPath,d.extensionPath),this.resolver=new oJ(d.tsConfigPath,this.config.excludeNodeModules,d.rootDir),this.cache=new Qae({maxSize:this.config.maxCacheSize,enableLRU:!0}),this.symbolCache=new Qae({maxSize:this.config.maxSymbolCacheSize,enableLRU:!0}),this.astWorkerHost=new qae(void 0,d.extensionPath),this.reverseIndexManager=new Cke(this.config.rootDir),this.fileReader=new W1,this.indexerStatus=new KDe,this.cancellation=new kke,this.workerManager=new Lke(this.indexerStatus,this.reverseIndexManager,this.cache),this.dependencyAnalyzer=new Ike(this.languageService,this.resolver,this.cache,this.reverseIndexManager),this.sourceFileCollector=new TR({excludeNodeModules:this.config.excludeNodeModules??!0,yieldIntervalMs:Nke,yieldCallback:()=>Pke(),isCancelled:()=>this.cancellation.isCancelled()}),this.referenceLookup=new Rke(this.reverseIndexManager,this.dependencyAnalyzer,this.fileReader,()=>this.indexerStatus.isReady(),()=>this.indexerStatus.isActive()),this.referencingFilesFinder=new Tke({sourceFileCollector:this.sourceFileCollector,getRootDir:()=>this.config.rootDir,getConcurrency:()=>this.config.indexingConcurrency,findReferenceInFile:(h,m,T)=>this.referenceLookup.findReferenceInFile(h,m,T)}),this.referenceLookup.setFallbackFinder(this.referencingFilesFinder),this.symbolDependencyHelper=new Fke({resolve:async(h,m)=>{try{return await this.resolver.resolve(h,m)}catch{return null}}}),this.symbolService=new Mke(this.astWorkerHost,this.symbolCache,this.fileReader,this.resolver,this.symbolDependencyHelper,()=>this.config,h=>this.findReferencingFiles(h),this.languageService),this.graphCrawler=new Dke(this.dependencyAnalyzer,()=>this.config),this.indexingService=new wke(this.dependencyAnalyzer,this.cache,this.reverseIndexManager,this.sourceFileCollector,this.indexerStatus,this.workerManager,this.cancellation,()=>this.config,()=>Pke(),h=>this.symbolService.getSymbolGraph(h)),this.cacheCoordinator=new Ake(this.cache,this.symbolCache,this.reverseIndexManager),d.enableReverseIndex&&this.enableReverseIndex()}}get workspaceRoot(){return this.config.rootDir}dispose(){return this.disposed=!0,this.disposePromise??=this.disposeResources(),this.disposePromise}async disposeResources(){let o;try{await this.beginShutdown()}catch(d){o=d}for(;this.activeIndexingOperations.size>0;)await Promise.allSettled([...this.activeIndexingOperations]);if(o!==void 0)throw o}beginShutdown(){return this.disposed=!0,this.cancelIndexing(),this.workerShutdownPromise??=this.stopWorkers(),this.workerShutdownPromise}async stopWorkers(){let d=(await Promise.allSettled([this.disposeWorker(),this.astWorkerHost.stop()])).find(h=>h.status==="rejected");if(d)throw d.reason}updateConfig(o){this.config.excludeNodeModules=o.excludeNodeModules??this.config.excludeNodeModules,this.config.maxDepth=o.maxDepth??this.config.maxDepth,o.excludeNodeModules!==void 0&&(this.resolver.updateConfig(o.excludeNodeModules),this.sourceFileCollector.updateOptions({excludeNodeModules:o.excludeNodeModules})),o.enableReverseIndex!==void 0&&(this.config.enableReverseIndex=o.enableReverseIndex,o.enableReverseIndex?this.reverseIndexManager.enable():this.reverseIndexManager.disable()),o.indexingConcurrency!==void 0&&(this.config.indexingConcurrency=o.indexingConcurrency),this.clearCache()}async analyze(o){return this.dependencyAnalyzer.analyze(o)}clearCache(){this.cacheCoordinator.clearAll(),this.referenceLookup.clearFallbackCache()}invalidateFile(o){return this.referenceLookup.clearFallbackCache(),this.cacheCoordinator.invalidateFile(o)}invalidateFiles(o){return this.referenceLookup.clearFallbackCache(),this.cacheCoordinator.invalidateFiles(o)}async reanalyzeFile(o){this.invalidateFile(o);try{return await this.analyze(o)}catch{return null}}handleFileDeleted(o){this.referenceLookup.clearFallbackCache(),this.cacheCoordinator.handleFileDeleted(o)}enableReverseIndex(o){let d=this.reverseIndexManager.enable(o);return this.config.enableReverseIndex=!0,d}disableReverseIndex(){this.config.enableReverseIndex=!1,this.reverseIndexManager.disable()}getSerializedReverseIndex(){return this.reverseIndexManager.getSerialized()}async validateReverseIndex(o=.2,d,h){return this.reverseIndexManager.validate(o,d,h)}getIndexStatus(){return this.indexerStatus.getSnapshot()}subscribeToIndexStatus(o){return this.indexerStatus.subscribe(o)}isReverseIndexEnabled(){return this.reverseIndexManager.isEnabled()}hasReverseIndex(){return this.reverseIndexManager.hasEntries()}getCallerCount(o){return this.reverseIndexManager.hasEntries()?this.reverseIndexManager.getCallerCount(o):0}cancelIndexing(){this.indexingService.cancel()}async buildFullIndex(o){return this.disposed?{indexedFiles:0,duration:0,cancelled:!0}:this.trackIndexingOperation(this.indexingService.buildFullIndex(o))}async buildFullIndexInWorker(o,d){return this.disposed?{indexedFiles:0,duration:0,cancelled:!0}:this.trackIndexingOperation(this.indexingService.buildFullIndexInWorker(o,d))}async disposeWorker(){await this.indexingService.disposeWorker()}async reindexStaleFiles(o,d){return this.disposed?0:this.trackIndexingOperation(this.indexingService.reindexStaleFiles(o,d))}trackIndexingOperation(o){return this.activeIndexingOperations.add(o),o.finally(()=>this.activeIndexingOperations.delete(o)).catch(()=>{}),o}async crawl(o,d){return this.graphCrawler.crawl(o,d)}async getReadOnlyDependencyGraph(o){let d=ri(o),h=new Set([d]),m=[],T={};try{let N=this.languageService.getAnalyzer(o),z=await N.parseImports(o),ee=new Set;for(let pe of z){let Te=await N.resolvePath(o,pe.module);if(!Te||!this.resolver.isWithinWorkspace(Te))continue;let Ke=ri(Te);ee.has(Ke)||(ee.add(Ke),h.add(Ke),m.push({source:d,target:Ke,...pe.line>0?{sourceLine:pe.line}:{}}),pe.module.startsWith("@")&&pe.module.includes("/")&&!pe.module.startsWith("@/")&&(T[Ke]=pe.module))}}catch{}return{nodes:[...h],edges:m,nodeLabels:Object.keys(T).length>0?T:void 0}}async crawlFrom(o,d,h=10,m){return this.graphCrawler.crawlFrom(o,d,h,m)}async findReferencingFiles(o){return this.referenceLookup.findReferencingFiles(o)}async findReferencingFilesWithFallback(o){return this.referenceLookup.findReferencingFilesWithFallback(o)}getSymbolReferencingFiles(o){if(!this.reverseIndexManager.hasEntries())return new Set;let d=this.reverseIndexManager.getSymbolReferencingFiles(o);return new Set(d)}async getSymbolGraph(o){return this.symbolService.getSymbolGraph(o)}async resolveModuleSpecifier(o,d){return this.dependencyAnalyzer.resolveModuleSpecifier(o,d)}async findUnusedSymbols(o){return this.symbolService.findUnusedSymbols(o)}async scanDeadCode(o,d){let h=o??this.config.rootDir;return this.symbolService.scanDeadCode(h,{maxFiles:d?.maxFiles,hasReverseIndex:this.hasReverseIndex()})}async verifyDependencyUsage(o,d){return this.symbolService.verifyDependencyUsage(o,d)}async verifyDependencyUsageBatch(o,d){return this.symbolService.verifyDependencyUsageBatch(o,d)}async getSymbolDependents(o,d){return this.symbolService.getSymbolDependents(o,d)}async traceFunctionExecution(o,d,h=10){return this.symbolService.traceFunctionExecution(o,d,h)}getCacheStats(){return{dependencyCache:this.cache.getStats(),symbolCache:this.symbolCache.getStats(),symbolAnalyzerFileCount:0,reverseIndexStats:this.reverseIndexManager.getStats()}}async getCacheStatsAsync(){let o=0;try{o=await this.astWorkerHost.getFileCount()}catch{}return{dependencyCache:this.cache.getStats(),symbolCache:this.symbolCache.getStats(),symbolAnalyzerFileCount:o,reverseIndexStats:this.reverseIndexManager.getStats()}}};var vst=class{rootDir;tsConfigPath;extensionPath;maxDepth=50;excludeNodeModules=!0;enableReverseIndex=!1;indexingConcurrency=4;maxCacheSize=500;maxSymbolCacheSize=200;maxSymbolAnalyzerFiles=100;indexingProgressInterval;ignoreTypeImports=!1;customCache;customSymbolCache;customLanguageService;customPathResolver;customAstWorkerHost;customReverseIndexManager;withRootDir(o){return this.rootDir=o,this}withTsConfigPath(o){return this.tsConfigPath=o,this}withExtensionPath(o){return this.extensionPath=o,this}withMaxDepth(o){return this.maxDepth=o,this}withExcludeNodeModules(o){return this.excludeNodeModules=o,this}withIgnoreTypeImports(o){return this.ignoreTypeImports=o,this}withReverseIndex(o){return this.enableReverseIndex=o,this}withIndexingConcurrency(o){return this.indexingConcurrency=o,this}withCacheConfig(o){return o.maxCacheSize!==void 0&&(this.maxCacheSize=o.maxCacheSize),o.maxSymbolCacheSize!==void 0&&(this.maxSymbolCacheSize=o.maxSymbolCacheSize),o.maxSymbolAnalyzerFiles!==void 0&&(this.maxSymbolAnalyzerFiles=o.maxSymbolAnalyzerFiles),this}withIndexingProgressInterval(o){return this.indexingProgressInterval=o,this}withConfig(o){return this.rootDir=o.rootDir,o.tsConfigPath!==void 0&&(this.tsConfigPath=o.tsConfigPath),o.extensionPath!==void 0&&(this.extensionPath=o.extensionPath),o.maxDepth!==void 0&&(this.maxDepth=o.maxDepth),o.excludeNodeModules!==void 0&&(this.excludeNodeModules=o.excludeNodeModules),o.ignoreTypeImports!==void 0&&(this.ignoreTypeImports=o.ignoreTypeImports),o.enableReverseIndex!==void 0&&(this.enableReverseIndex=o.enableReverseIndex),o.indexingConcurrency!==void 0&&(this.indexingConcurrency=o.indexingConcurrency),o.maxCacheSize!==void 0&&(this.maxCacheSize=o.maxCacheSize),o.maxSymbolCacheSize!==void 0&&(this.maxSymbolCacheSize=o.maxSymbolCacheSize),o.maxSymbolAnalyzerFiles!==void 0&&(this.maxSymbolAnalyzerFiles=o.maxSymbolAnalyzerFiles),o.indexingProgressInterval!==void 0&&(this.indexingProgressInterval=o.indexingProgressInterval),this}withCache(o){return this.customCache=o,this}withSymbolCache(o){return this.customSymbolCache=o,this}withLanguageService(o){return this.customLanguageService=o,this}withPathResolver(o){return this.customPathResolver=o,this}withAstWorkerHost(o){return this.customAstWorkerHost=o,this}withReverseIndexManager(o){return this.customReverseIndexManager=o,this}build(){this.validate();let o=this.initializeServices();return new yst(o)}initializeServices(){let o=this.buildConfig(),d=this.customLanguageService??new Ske(this.rootDir,this.tsConfigPath,this.extensionPath,this.ignoreTypeImports),h=this.customPathResolver??new oJ(this.tsConfigPath,this.excludeNodeModules,this.rootDir),m=this.customCache??new Qae({maxSize:this.maxCacheSize,enableLRU:!0}),T=this.customSymbolCache??new Qae({maxSize:this.maxSymbolCacheSize,enableLRU:!0}),N=this.customAstWorkerHost??new qae(void 0,this.extensionPath),z=this.customReverseIndexManager??new Cke(this.rootDir),ee=new W1,pe=new KDe,Te=new kke,Ke=new Lke(pe,z,m),ce=new Ike(d,h,m,z),Bt=new TR({excludeNodeModules:this.excludeNodeModules,yieldIntervalMs:Nke,yieldCallback:()=>Pke(),isCancelled:()=>Te.isCancelled()}),tt=new Rke(z,ce,ee,()=>pe.isReady(),()=>pe.isActive()),st=new Tke({sourceFileCollector:Bt,getRootDir:()=>this.rootDir,getConcurrency:()=>this.indexingConcurrency,findReferenceInFile:(Ci,Ln,vn)=>tt.findReferenceInFile(Ci,Ln,vn)});tt.setFallbackFinder(st);let sr=new Fke({resolve:async(Ci,Ln)=>{try{return await h.resolve(Ci,Ln)}catch{return null}}}),ur=new Mke(N,T,ee,h,sr,()=>o,Ci=>tt.findReferencingFiles(Ci),d),jr=new Dke(ce,()=>o),Oi=new wke(ce,m,z,Bt,pe,Ke,Te,()=>o,()=>Pke(),Ci=>ur.getSymbolGraph(Ci)),Yi=new Ake(m,T,z);return this.enableReverseIndex&&z.enable(),{config:o,languageService:d,resolver:h,cache:m,symbolCache:T,fileReader:ee,astWorkerHost:N,reverseIndexManager:z,indexerStatus:pe,workerManager:Ke,cancellation:Te,sourceFileCollector:Bt,referencingFilesFinder:st,symbolDependencyHelper:sr,dependencyAnalyzer:ce,referenceLookup:tt,symbolService:ur,graphCrawler:jr,indexingService:Oi,cacheCoordinator:Yi}}validate(){if(!this.rootDir)throw new Error("rootDir is required");if(this.maxDepth<0)throw new Error("maxDepth must be non-negative");if(this.indexingConcurrency<1)throw new Error("indexingConcurrency must be at least 1");if(this.maxCacheSize<0)throw new Error("maxCacheSize must be non-negative");if(this.maxSymbolCacheSize<0)throw new Error("maxSymbolCacheSize must be non-negative");if(this.maxSymbolAnalyzerFiles<0)throw new Error("maxSymbolAnalyzerFiles must be non-negative")}buildConfig(){return{rootDir:this.rootDir,tsConfigPath:this.tsConfigPath,extensionPath:this.extensionPath,maxDepth:this.maxDepth,excludeNodeModules:this.excludeNodeModules,ignoreTypeImports:this.ignoreTypeImports,enableReverseIndex:this.enableReverseIndex,indexingConcurrency:this.indexingConcurrency,maxCacheSize:this.maxCacheSize,maxSymbolCacheSize:this.maxSymbolCacheSize,maxSymbolAnalyzerFiles:this.maxSymbolAnalyzerFiles,indexingProgressInterval:this.indexingProgressInterval}}};gN();Im();jC();_2();var sOt=class{constructor(o,d="info",h=[]){this.source=o;this.entries=h;this.level=d}source;entries;level;setLevel(o){this.level=o}debug(o){this.record("debug",o)}info(o){this.record("info",o)}warn(o){this.record("warn",o)}error(o){this.record("error",o)}record(o,d){this.entries.length>=1e3&&this.entries.shift(),this.entries.push({level:o,source:this.source,message:d,timestamp:Date.now()})}getEntries(){return[...this.entries]}clear(){this.entries.length=0}},bst=class{sharedEntries=[];createLogger(o,d){return new sOt(o,d??"info",this.sharedEntries)}getCollectedEntries(){return[...this.sharedEntries]}clear(){this.sharedEntries.length=0}getErrorCount(){let o=0,d=0;for(let h of this.sharedEntries)h.level==="error"?o+=1:h.level==="warn"&&(d+=1);return{errors:o,warnings:d,total:this.sharedEntries.length}}};var ZUt=require("node:crypto"),JUe=cc(require("node:fs")),Kne=cc(require("node:path"));Im();Bne();function eHt(u,o){try{let d=lpn(u,o);if(!d)return;let h=upn(u,d);return h?(0,ZUt.createHash)("sha256").update(JSON.stringify([...h].sort(([m],[T])=>m.localeCompare(T)))).digest("hex"):void 0}catch{return}}function lpn(u,o){let d=new Set([ri(u)]);for(let h of o){let m=ri(Kne.dirname(h));for(;!d.has(m);){if(!ZF(m,u))return;d.add(m),m=ri(Kne.dirname(m))}}return d}function upn(u,o){let d=[...o].flatMap(T=>[Kne.join(T,"tsconfig.json"),Kne.join(T,"package.json")]),h=new Set,m=new Map;for(let T=d.shift();T;T=d.shift()){let N=ri(T);if(h.has(N))continue;h.add(N);let z=dpn(T,u);if(z===void 0)continue;m.set(N,z);let ee=ppn(T,z,u);if(ee===void 0)return;ee&&d.push(ee)}return m}function dpn(u,o){if(!(!ZF(u,o)||!JUe.existsSync(u)))return JUe.readFileSync(u,"utf-8")}function ppn(u,o,d){let h;try{h=JSON.parse(o)}catch{return null}if(typeof h?.extends!="string")return null;let m=Kne.resolve(Kne.dirname(u),h.extends);if(!ZF(m,d))return;let T=m.endsWith(".json")?m:`${m}.json`;return JUe.existsSync(T)?T:m}Stt({createLogger(u,o){return new pUe(u,o)}});Kae.setDefaultLevel(t9t("LOG_LEVEL"));var aEe=Uh("CliRuntime"),tHt="1.16.0",nHt=1,fpn=.2,rHt="meta.json",iHt="reverse-index.json",oHt="callgraph.db";function cOt(u,o){let d=xT.dirname(u),h=xT.join(d,`.${xT.basename(u)}.${process.pid}.tmp`);pP.writeFileSync(h,o),pP.renameSync(h,u)}function lOt(u){let o=xT.resolve(u),{root:d}=xT.parse(o);for(;o!==d;){if(pP.existsSync(xT.join(o,"package.json"))||pP.existsSync(xT.join(o,"tsconfig.json")))return o;o=xT.dirname(o)}return xT.resolve(u)}function mpn(u){let o=xT.join(u,"tsconfig.json");return pP.existsSync(o)?o:void 0}var Sst=class{workspaceRoot;stateDir;cacheDir;cacheEnabled;_initialized=!1;_indexReady=!1;_reverseIndexRestored=!1;_sourceFiles=null;_configFingerprint;errorCollectorBackend=null;constructor(o,d){this.workspaceRoot=xT.resolve(o),this.stateDir=xT.join(this.workspaceRoot,".graph-it"),this.cacheDir=xT.join(this.stateDir,"cache"),this.cacheEnabled=(d?.cache??!0)&&!process.env.GRAPH_IT_NO_CACHE}clearCache(){pP.rmSync(this.cacheDir,{recursive:!0,force:!0})}get initialized(){return this._initialized}enableErrorCollection(){this.errorCollectorBackend||(this.errorCollectorBackend=new bst,Stt(this.errorCollectorBackend))}disableErrorCollection(){if(!this.errorCollectorBackend)return[];let o=this.errorCollectorBackend.getCollectedEntries();return Stt({createLogger(d,h){return new pUe(d,h)}}),this.errorCollectorBackend=null,o}getCollectedErrors(){return this.errorCollectorBackend?.getCollectedEntries()??[]}clearCollectedErrors(){this.errorCollectorBackend?.clear()}async init(){if(this._initialized)return;pP.mkdirSync(this.stateDir,{recursive:!0});let o=mpn(this.workspaceRoot);Cc.parser=new $De,Cc.resolver=new oJ(o,!0,this.workspaceRoot);let d=xT.resolve(__dirname,"..");Cc.astWorkerHost=new qae(void 0,d),await Cc.astWorkerHost.start();let h=new vst().withRootDir(this.workspaceRoot).withMaxDepth(50).withExcludeNodeModules(!0).withReverseIndex(!0).withExtensionPath(d);o&&h.withTsConfigPath(o),Cc.spider=h.build(),this.cacheEnabled&&(this._configFingerprint=eHt(this.workspaceRoot,await this.collectSourceFiles())),Cc.config={rootDir:this.workspaceRoot,tsConfigPath:o,excludeNodeModules:!0,maxDepth:50,extensionPath:d,cacheDir:this.cacheEnabled&&this.isCacheMetaValid()?this.cacheDir:void 0},Cc.isReady=!0,this._initialized=!0,this.cacheEnabled&&(this._reverseIndexRestored=this.tryRestoreReverseIndex()),aEe.info("Runtime initialized for",this.workspaceRoot)}tryRestoreReverseIndex(){if(!this.isCacheMetaValid())return!1;try{let o=pP.readFileSync(xT.join(this.cacheDir,iHt),"utf-8"),d=Cc.spider?.enableReverseIndex(o)??!1;return d&&aEe.info("Restored reverse index from cache"),d}catch{return!1}}isCacheMetaValid(){try{let o=pP.readFileSync(xT.join(this.cacheDir,rHt),"utf-8"),d=JSON.parse(o);return d.schema===nHt&&d.cliVersion===tHt&&this._configFingerprint!==void 0&&d.configFingerprint===this._configFingerprint&&ri(d.workspaceRoot)===ri(this.workspaceRoot)}catch{return!1}}async ensureIndexed(o){if(!this._initialized||!Cc.spider)throw new Am("Runtime not initialized. Call init() first.",Yp.WORKSPACE_NOT_FOUND);if(this._indexReady){let z=Cc.warmupInfo;return{filesIndexed:z?.filesIndexed??0,filesFound:z?.filesFound??z?.filesIndexed??0,filesAnalyzed:z?.filesAnalyzed??0,fromCache:z?.fromCache??!1,durationMs:z?.durationMs??0}}let d=Cc.spider,h=Date.now(),m=o?.silent??!1,T="Indexing",N=d.subscribeToIndexStatus(z=>{!m&&z.state==="indexing"&&z.total>0&&process.stderr.write(`\r ${T}: ${z.processed}/${z.total} files...`)});try{let ee=await this.tryIncrementalIndex(d,{silent:m,onReindexStart:()=>{T="Re-indexing changed"}})??await this.runFullIndex(d,m),pe=Date.now()-h;return m||process.stderr.write(this.describeOutcome(ee)+`
|
|
46678
|
-
`),aEe.info(`${ee.fromCache?"Cache":"Index"}: ${ee.filesIndexed} files,`,`${ee.filesAnalyzed} analyzed in ${pe}ms`),this.saveState({lastScanTimestamp:new Date().toISOString(),filesIndexed:ee.filesIndexed,workspaceRoot:this.workspaceRoot}),Cc.warmupInfo={completed:!0,durationMs:pe,...ee},this._indexReady=!0,{...ee,durationMs:pe}}finally{N()}}describeOutcome(o){return o.fromCache?o.filesAnalyzed===0?`\r Loaded ${o.filesIndexed} files from cache (nothing changed)`:`\r Loaded ${o.filesIndexed} files from cache, re-indexed ${o.filesAnalyzed} changed`:`\r Indexed ${o.filesIndexed}/${o.filesFound} files`}async runFullIndex(o,d){o.clearCache(),d||process.stderr.write("\r Indexing workspace...");let h=await o.buildFullIndex();return{filesIndexed:o.getCacheStats().reverseIndexStats?.indexedFiles??h.indexedFiles,filesFound:h.indexedFiles,filesAnalyzed:h.indexedFiles,fromCache:!1}}async tryIncrementalIndex(o,d){if(!this._reverseIndexRestored)return null;let h=await this.collectSourceFiles(),m=await o.validateReverseIndex(fpn,h);if(!m?.isValid)return aEe.info("Cached index too stale, rebuilding from scratch"),null;for(let N of m.missingFiles)o.handleFileDeleted(N);m.staleFiles.length>0&&d.onReindexStart();let T=await o.reindexStaleFiles(m.staleFiles);return aEe.info(`Incremental index: ${T} changed, ${m.missingFiles.length} deleted`),{filesIndexed:o.getCacheStats().reverseIndexStats?.indexedFiles??h.length,filesFound:h.length,filesAnalyzed:T,fromCache:!0}}async collectSourceFiles(){return this._sourceFiles??=await new TR({excludeNodeModules:!0,yieldIntervalMs:30,isCancelled:()=>!1}).collectAllSourceFiles(this.workspaceRoot),this._sourceFiles}saveCache(){if(!(!this.cacheEnabled||!this._indexReady||this._configFingerprint===void 0))try{pP.mkdirSync(this.cacheDir,{recursive:!0});let o=Cc.spider?.getSerializedReverseIndex();o&&cOt(xT.join(this.cacheDir,iHt),o),Cc.callGraphIndexer?cOt(xT.join(this.cacheDir,oHt),Cc.callGraphIndexer.exportDb()):this.isCacheMetaValid()||pP.rmSync(xT.join(this.cacheDir,oHt),{force:!0});let d={schema:nHt,cliVersion:tHt,savedAt:new Date().toISOString(),workspaceRoot:this.workspaceRoot,configFingerprint:this._configFingerprint};cOt(xT.join(this.cacheDir,rHt),JSON.stringify(d,null,2))}catch(o){aEe.warn("Could not save cache:",o instanceof Error?o.message:String(o))}}async dispose(){this.saveCache(),Cc.astWorkerHost&&await Cc.astWorkerHost.stop(),Cc.spider&&await Cc.spider.dispose(),Cc.reset(),this._initialized=!1,this._indexReady=!1}saveState(o){try{pP.writeFileSync(xT.join(this.stateDir,"state.json"),JSON.stringify(o,null,2))}catch(d){aEe.warn("Could not save state:",d instanceof Error?d.message:String(d))}}loadState(){try{let o=pP.readFileSync(xT.join(this.stateDir,"state.json"),"utf-8");return JSON.parse(o)}catch{return null}}};pOt();var jBt="1.16.
|
|
46677
|
+
`).length}async parseImports(o){let d=VC(o),h=await this.fileReader.readFile(d);return this.parse(h,d).map(T=>({path:"",type:T.type,line:T.line,module:T.module}))}async resolvePath(o,d){let h=VC(o);return this.pathResolver.resolve(h,d)}};Yae();var Qae=class{cache=new Map;maxSize;enableLRU;hits=0;misses=0;evictions=0;constructor(o={}){this.maxSize=o.maxSize??0,this.enableLRU=o.enableLRU??!0}get(o){let d=this.cache.get(o);if(d!==void 0)return this.hits++,this.enableLRU&&this.maxSize>0&&(this.cache.delete(o),this.cache.set(o,d)),d;this.misses++}set(o,d){this.cache.has(o)?this.cache.delete(o):this.maxSize>0&&this.cache.size>=this.maxSize&&this.evictOldest(),this.cache.set(o,d)}has(o){return this.cache.has(o)}clear(){this.cache.clear(),this.resetStats()}delete(o){return this.cache.delete(o)}get size(){return this.cache.size}getStats(){let o=this.hits+this.misses;return{hits:this.hits,misses:this.misses,evictions:this.evictions,size:this.cache.size,maxSize:this.maxSize,hitRate:o>0?this.hits/o:0}}resetStats(){this.hits=0,this.misses=0,this.evictions=0}keys(){return this.cache.keys()}entries(){return this.cache.entries()}evictOldest(){let o=this.cache.keys().next().value;o!==void 0&&(this.cache.delete(o),this.evictions++)}};jC();var $in=Uh("IndexerStatus"),KDe=class{_state="idle";_processed=0;_total=0;_currentFile;_startTime;_errorMessage;_cancelled=!1;_listeners=new Set;_lastNotifyTime=0;_notifyThrottleMs;constructor(o){this._notifyThrottleMs=o?.notifyThrottleMs??250}subscribe(o){return this._listeners.add(o),o(this.getSnapshot()),()=>this._listeners.delete(o)}getSnapshot(){let o=this._total>0?Math.round(this._processed/this._total*100):0,d;if(this._startTime&&this._processed>0&&this._total>0&&this._state==="indexing"){let m=(Date.now()-this._startTime)/this._processed,T=this._total-this._processed;d=Math.round(m*T)}return{state:this._state,processed:this._processed,total:this._total,currentFile:this._currentFile,percentage:o,startTime:this._startTime,estimatedTimeRemaining:d,errorMessage:this._errorMessage,cancelled:this._cancelled}}startCounting(){this._state="counting",this._processed=0,this._total=0,this._currentFile=void 0,this._startTime=Date.now(),this._errorMessage=void 0,this._cancelled=!1,this._notifyListeners(!0)}setTotal(o){this._total=o,this._notifyListeners(!0)}startIndexing(){this._state="indexing",this._startTime=Date.now(),this._notifyListeners(!0)}startValidating(){this._state="validating",this._notifyListeners(!0)}updateProgress(o,d){this._processed=o,this._currentFile=d,this._notifyListeners(!1)}complete(){this._state="complete",this._currentFile=void 0,this._notifyListeners(!0)}setError(o){this._state="error",this._errorMessage=o,this._currentFile=void 0,this._notifyListeners(!0)}setCancelled(){this._cancelled=!0,this._state="idle",this._currentFile=void 0,this._notifyListeners(!0)}reset(){this._state="idle",this._processed=0,this._total=0,this._currentFile=void 0,this._startTime=void 0,this._errorMessage=void 0,this._cancelled=!1,this._notifyListeners(!0)}isActive(){return this._state==="counting"||this._state==="indexing"||this._state==="validating"}isReady(){return this._state==="complete"}_notifyListeners(o){let d=Date.now();if(!o&&d-this._lastNotifyTime<this._notifyThrottleMs)return;this._lastNotifyTime=d;let h=this.getSnapshot();for(let m of this._listeners)try{m(h)}catch(T){$in.error("Listener error:",T)}}get state(){return this._state}get total(){return this._total}get processed(){return this._processed}};var HUt=cc(require("node:path"));var _v=cc(YLt());jC();function QLt(u){switch(u){case"FunctionDeclaration":case"ArrowFunction":case"MethodDeclaration":case"GetAccessor":case"SetAccessor":return"function";case"ClassDeclaration":return"class";case"InterfaceDeclaration":return"interface";case"TypeAliasDeclaration":return"type";case"VariableDeclaration":case"PropertyDeclaration":case"EnumDeclaration":return"variable";default:return"other"}}var jUt=Uh("SymbolAnalyzer"),ast=class{project;maxFiles;fileCount=0;fileReader;constructor(o,d={}){this.maxFiles=d.maxFiles??100,this.project=this.createProject(),this.fileReader=new W1}createProject(){return new _v.Project({skipAddingFilesFromTsConfig:!0,useInMemoryFileSystem:!0,compilerOptions:{target:99,module:99}})}maybeResetProject(){this.fileCount>=this.maxFiles&&(jUt.debug(`Resetting ts-morph project (${this.fileCount} files in memory)`),this.project=this.createProject(),this.fileCount=0)}getFileCount(){return this.fileCount}reset(){jUt.debug("Forcing ts-morph project reset"),this.project=this.createProject(),this.fileCount=0}analyzeFileContent(o,d){this.maybeResetProject();let h=this.getOrCreateSourceFile(o,d),m=[],T=[],N=this.extractExportedSymbols(h,o,m);return this.extractNonExportedSymbols(h,o,N,m),this.buildDependencies(h,T),{symbols:m,dependencies:T}}getOrCreateSourceFile(o,d){let h=this.project.getSourceFile(o);return h?h.replaceWithText(d):(h=this.project.createSourceFile(o,d),this.fileCount++),h}extractExportedSymbols(o,d,h){let m=o.getExportedDeclarations(),T=new Set(m.keys());for(let[N,z]of m){let ee=z[0];ee&&(this.addSymbol(h,N,ee.getKindName(),ee.getStartLineNumber(),d,!0),ee.getKindName()==="ClassDeclaration"&&_v.Node.isClassDeclaration(ee)&&this.extractClassMembers(ee,d,h))}return T}extractNonExportedSymbols(o,d,h,m){let T=o.getStatements();for(let N of T)_v.Node.isVariableStatement(N)?this.extractVariableDeclarations(N,d,h,m):this.extractOtherDeclarations(N,d,h,m)}extractVariableDeclarations(o,d,h,m){let T=o.getDeclarations();for(let N of T){let z=N.getName();h.has(z)||this.addSymbol(m,z,"VariableDeclaration",N.getStartLineNumber(),d,!1)}}extractOtherDeclarations(o,d,h,m){let T=this.getDeclarationInfo(o);!T||h.has(T.name)||(this.addSymbol(m,T.name,T.kind,o.getStartLineNumber(),d,!1),T.isClass&&_v.Node.isClassDeclaration(o)&&this.extractClassMembers(o,d,m))}getDeclarationInfo(o){if(_v.Node.isClassDeclaration(o)){let d=o.getName();if(d)return{name:d,kind:"ClassDeclaration",isClass:!0}}else if(_v.Node.isFunctionDeclaration(o)){let d=o.getName();if(d)return{name:d,kind:"FunctionDeclaration",isClass:!1}}else{if(_v.Node.isInterfaceDeclaration(o))return{name:o.getName(),kind:"InterfaceDeclaration",isClass:!1};if(_v.Node.isTypeAliasDeclaration(o))return{name:o.getName(),kind:"TypeAliasDeclaration",isClass:!1};if(_v.Node.isEnumDeclaration(o))return{name:o.getName(),kind:"EnumDeclaration",isClass:!1}}return null}addSymbol(o,d,h,m,T,N){o.push({name:d,kind:h,line:m,isExported:N,id:`${T}:${d}`,category:QLt(h)})}buildDependencies(o,d){let h=this.buildImportMap(o),m=this.findSymbolUsage(o,h);for(let[T,N]of Object.entries(m))for(let z of N)d.push({sourceSymbolId:T,targetSymbolId:z.symbolId,targetFilePath:z.filePath,isTypeOnly:z.isTypeOnly})}getInternalExportDependencyGraph(o,d){this.maybeResetProject();let m=this.getOrCreateSourceFile(o,d).getExportedDeclarations(),T=new Set(m.keys()),N=new Map;for(let[z,ee]of m){let pe=`${o}:${z}`,Te=this.getOrCreateDependencySet(N,pe);this.collectExportDependencies(ee,z,T,o,Te)}return N}getOrCreateDependencySet(o,d){let h=o.get(d);return h||(h=new Set,o.set(d,h)),h}collectExportDependencies(o,d,h,m,T){for(let N of o){let z=N.getDescendantsOfKind(_v.SyntaxKind.Identifier);for(let ee of z){let pe=ee.getText();this.isValidDependency(pe,d,h)&&T.add(`${m}:${pe}`)}}}isValidDependency(o,d,h){return h.has(o)&&o!==d}buildImportMap(o){let d=new Map,h=o.getImportDeclarations();for(let m of h){let T=m.getModuleSpecifierValue(),N=m.isTypeOnly(),z=m.getDefaultImport();if(z){let Te=z.getText();d.set(Te,{originalName:"default",modulePath:T,isType:N})}let ee=m.getNamedImports();for(let Te of ee){let Ke=Te.getNameNode().getText(),ce=Te.getAliasNode(),Bt=ce?ce.getText():Ke;d.set(Bt,{originalName:Ke,modulePath:T,isType:N||Te.isTypeOnly()})}let pe=m.getNamespaceImport();if(pe){let Te=pe.getText();d.set(Te,{originalName:"*",modulePath:T,isType:N})}}return d}extractIntraFileCalls(o,d){let h=[],m=d.getFilePath(),T=this.collectFunctionNames(d),N=o.getDescendantsOfKind(_v.SyntaxKind.CallExpression);for(let z of N)this.processCallExpression(z,T,m,h);return h}collectFunctionNames(o){let d=new Set;for(let h of o.getFunctions()){let m=h.getName();m&&d.add(m)}for(let h of o.getClasses())for(let m of h.getMethods()){let T=m.getName();T&&d.add(T)}return d}processCallExpression(o,d,h,m){if(!_v.Node.isCallExpression(o))return;let T=o.getExpression();if(_v.Node.isIdentifier(T)){this.addDirectFunctionCall(T,d,h,m);return}_v.Node.isPropertyAccessExpression(T)&&this.addPropertyAccessCall(T,d,h,m)}addDirectFunctionCall(o,d,h,m){let T=o.getText();d.has(T)&&m.push({symbolId:`${h}:${T}`,filePath:h,isTypeOnly:!1})}addPropertyAccessCall(o,d,h,m){if(_v.Node.isPropertyAccessExpression(o)){let T=o.getName();d.has(T)&&m.push({symbolId:`${h}:${T}`,filePath:h,isTypeOnly:!1})}}findSymbolUsage(o,d){let h={},m=o.getFilePath(),T=[...o.getFunctions(),...o.getClasses(),...o.getVariableDeclarations()];for(let ee of T){let pe=ee.getName();if(!pe)continue;let Te=`${m}:${pe}`,Ke=this.extractSymbolDependencies(ee,d),ce=this.extractIntraFileCalls(ee,o);Ke.push(...ce),h[Te]=Ke}let N=o.getStatements(),z=[];for(let ee of N){if(_v.Node.isFunctionDeclaration(ee)||_v.Node.isClassDeclaration(ee)||_v.Node.isVariableStatement(ee)||_v.Node.isInterfaceDeclaration(ee)||_v.Node.isTypeAliasDeclaration(ee)||_v.Node.isEnumDeclaration(ee)||_v.Node.isImportDeclaration(ee))continue;let pe=this.extractSymbolDependencies(ee,d);z.push(...pe)}if(z.length>0){let ee=`${m}:(file)`;h[ee]=z}return h}extractSymbolDependencies(o,d){let h=[];return this.extractStaticImportDependencies(o,d,h),this.extractDynamicImportDependencies(o,h),h}extractStaticImportDependencies(o,d,h){let m=o.getDescendantsOfKind(_v.SyntaxKind.Identifier);for(let T of m){let N=d.get(T.getText());if(!N)continue;let z=this.buildTargetSymbolId(N);h.some(ee=>ee.symbolId===z)||h.push({symbolId:z,filePath:N.modulePath,isTypeOnly:N.isType})}}extractDynamicImportDependencies(o,d){let h=o.getDescendantsOfKind(_v.SyntaxKind.CallExpression);for(let m of h){let T=this.extractDynamicImportPath(m);if(!T)continue;let N=`${T}:default`;d.some(z=>z.symbolId===N)||d.push({symbolId:N,filePath:T,isTypeOnly:!1})}}extractDynamicImportPath(o){if(!_v.Node.isCallExpression(o)||o.getExpression().getKind()!==_v.SyntaxKind.ImportKeyword)return null;let h=o.getArguments();if(h.length===0)return null;let m=h[0];return _v.Node.isStringLiteral(m)?m.getLiteralValue():null}buildTargetSymbolId(o){return o.originalName==="default"?`${o.modulePath}:default`:`${o.modulePath}:${o.originalName}`}extractClassMembers(o,d,h){let m=o.getName();if(!m)return;let T=`${d}:${m}`,N=o.getMembers();for(let z of N){let ee=z.getKindName();if(!_v.Node.isMethodDeclaration(z)&&!_v.Node.isPropertyDeclaration(z)&&!_v.Node.isGetAccessorDeclaration(z)&&!_v.Node.isSetAccessorDeclaration(z))continue;let pe=z.getName();if(!pe)continue;let Te=z.isStatic()??!1,Ke=`${m}.${pe}`,ce=Te?`Static${ee}`:ee;h.push({name:Ke,kind:ce,line:z.getStartLineNumber(),isExported:!1,id:`${d}:${Ke}`,parentSymbolId:T,category:QLt(ee)})}}getExportedSymbols(o,d){let h=this.project.getSourceFile(o);h?h.replaceWithText(d):h=this.project.createSourceFile(o,d);let m=[],T=h.getExportedDeclarations();for(let[N,z]of T){let ee=z[0];if(!ee)continue;let pe=ee.getKindName();m.push({name:N,kind:pe,line:ee.getStartLineNumber(),isExported:!0,id:`${o}:${N}`,category:QLt(pe)})}return m}filterRuntimeSymbols(o){let d=new Set(["InterfaceDeclaration","TypeAliasDeclaration","TypeParameter"]);return o.filter(h=>!d.has(h.kind))}async analyzeFile(o){let d=await this.fileReader.readFile(o),h=this.analyzeFileContent(o,d),m=new Map;for(let T of h.symbols)m.set(T.id,T);return m}async getSymbolDependencies(o){let d=await this.fileReader.readFile(o);return this.analyzeFileContent(o,d).dependencies}};var ZLt=cc(require("node:fs/promises")),pse=cc(require("node:path"));Im();Bne();GC();Jne();var sst=class u{parser=null;fileReader;rootDir;extensionPath;initPromise=null;constructor(o,d){this.fileReader=new W1,this.rootDir=o??process.cwd(),this.extensionPath=d}async ensureInitialized(){if(!this.parser)return this.initPromise!==null?this.initPromise:(this.initPromise=(async()=>{let o=this.extensionPath;if(!o)throw new Error("Extension path required for WASM parser initialization. Ensure CSharpParser is constructed with extensionPath parameter.");try{let d=hN.getInstance(),h=pse.default.join(o,"dist","wasm","tree-sitter.wasm");await d.init(h);let m=pse.default.join(o,"dist","wasm","tree-sitter-c_sharp.wasm");this.parser=await d.getParser("c_sharp",m)}catch(d){this.initPromise=null;let h=d instanceof Error?d.message:String(d);throw new Error(`Failed to initialize C# WASM parser: ${h}`,{cause:d})}})(),this.initPromise)}async parseImports(o){let d=VC(o),h;try{h=await this.fileReader.readFile(d)}catch(T){throw pg.fromError(T,d)}if(await this.ensureInitialized(),!this.parser)return[];let m=this.parser.parse(h);if(!m)return[];try{let T=[];return this.extractUsings(m.rootNode,d,T),T}finally{m.delete()}}extractUsings(o,d,h){if(o.type==="using_directive"){let m=o.children.find(T=>T.type==="identifier"||T.type==="qualified_name"||T.type==="member_access_expression");if(m){let T=m.text.trim();T&&h.push({path:ri(d),type:"import",line:m.startPosition.row+1,module:T})}}for(let m of o.children)this.extractUsings(m,d,h)}async resolvePath(o,d){if(this.isFrameworkNamespace(d))return null;let h=d.split(".");return h.length<2||h.some(u.isUnsafeSegment)?null:this.resolveNamespace(h)}async resolveNamespace(o){try{return await this.resolveViaSuffix(o)??await this.resolveViaLastSegment(o)}catch{return null}}static isUnsafeSegment(o){return o===""||o===".."||o.includes("/")}async resolveViaSuffix(o){for(let d=o.length-1;d>=1;d--){let h=pse.default.resolve(this.rootDir,o.slice(d).join(pse.default.sep));if(!this.isWithinRoot(h))continue;let m=await this.findFirstCsFile(h);if(m)return ri(m)}return null}async resolveViaLastSegment(o){let d=o.at(-1)??"";if(!d)return null;let h=await this.findDirectory(this.rootDir,d,3);if(!h||!this.isWithinRoot(h))return null;let m=await this.findFirstCsFile(h);return m?ri(m):null}isWithinRoot(o){return ZF(o,this.rootDir)}isFrameworkNamespace(o){return["System","Microsoft","Newtonsoft","NUnit","Xunit","MSTest","AutoMapper","FluentValidation","MediatR","Serilog"].some(h=>o===h||o.startsWith(h+"."))}async findFirstCsFile(o){try{let h=(await ZLt.default.readdir(o,{withFileTypes:!0})).filter(m=>m.isFile()&&m.name.endsWith(".cs")).sort((m,T)=>m.name.localeCompare(T.name));return h.length>0?pse.default.join(o,h[0].name):null}catch{return null}}async findDirectory(o,d,h){if(h<=0)return null;try{let T=(await ZLt.default.readdir(o,{withFileTypes:!0})).filter(u.isTraversableDir);for(let N of T){if(N.name===d)return pse.default.join(o,N.name);let z=await this.findDirectory(pse.default.join(o,N.name),d,h-1);if(z)return z}}catch{}return null}static isTraversableDir(o){return o.isDirectory()&&!o.name.startsWith(".")&&o.name!=="node_modules"}};var cst=cc(require("node:fs/promises")),bJ=cc(require("node:path"));Im();Bne();GC();Jne();var lst=class u{parser=null;fileReader;rootDir;extensionPath;initPromise=null;constructor(o,d){this.fileReader=new W1,this.rootDir=o??process.cwd(),this.extensionPath=d}async ensureInitialized(){if(!this.parser)return this.initPromise!==null?this.initPromise:(this.initPromise=(async()=>{let o=this.extensionPath;if(!o)throw new Error("Extension path required for WASM parser initialization. Ensure GoParser is constructed with extensionPath parameter.");try{let d=hN.getInstance(),h=bJ.default.join(o,"dist","wasm","tree-sitter.wasm");await d.init(h);let m=bJ.default.join(o,"dist","wasm","tree-sitter-go.wasm");this.parser=await d.getParser("go",m)}catch(d){this.initPromise=null;let h=d instanceof Error?d.message:String(d);throw new Error(`Failed to initialize Go WASM parser: ${h}`,{cause:d})}})(),this.initPromise)}async parseImports(o){let d=VC(o),h;try{h=await this.fileReader.readFile(d)}catch(T){throw pg.fromError(T,d)}if(await this.ensureInitialized(),!this.parser)return[];let m=this.parser.parse(h);if(!m)return[];try{let T=[];return this.extractImports(m.rootNode,d,T),T}finally{m.delete()}}extractImports(o,d,h){if(o.type==="import_spec"){let m=o.children.find(T=>T.type==="interpreted_string_literal"||T.type==="raw_string_literal");if(m){let T=m.text.replaceAll(/^["`]|["`]$/g,"").trim();T&&h.push({path:ri(d),type:"import",line:m.startPosition.row+1,module:T})}}for(let m of o.children)this.extractImports(m,d,h)}async resolvePath(o,d){if(this.isGoStdlibImport(d))return null;let h=d.split("/");return h.some(u.isUnsafePart)?null:this.resolveGoImport(VC(o),d,h)}async resolveGoImport(o,d,h){try{let m=await this.resolveViaGoMod(o,d)??await this.resolveViaLastSegment(h);return m?ri(m):null}catch{return null}}static isUnsafePart(o){return o===".."||o===""}async resolveViaGoMod(o,d){let h=await this.findGoModuleInfo(bJ.default.dirname(o));if(!h||!d.startsWith(h.moduleName+"/"))return null;let T=d.slice(h.moduleName.length+1).split("/");if(T.some(u.isUnsafePart))return null;let N=bJ.default.resolve(h.moduleDir,...T);return this.isWithinRoot(N)?this.findFirstGoFile(N):null}async resolveViaLastSegment(o){let d=o.at(-1)??"";if(!d)return null;let h=await this.findDirectory(this.rootDir,d,3);return!h||!this.isWithinRoot(h)?null:this.findFirstGoFile(h)}isWithinRoot(o){return ZF(o,this.rootDir)}isGoStdlibImport(o){return!(o.split("/")[0]??"").includes(".")}async findGoModuleInfo(o){let d=o,h=ri(this.rootDir);for(;;){let m=await this.readGoModuleName(bJ.default.join(d,"go.mod"));if(m)return{moduleDir:d,moduleName:m};let T=bJ.default.dirname(d);if(T===d||!ri(T).startsWith(h))break;d=T}return null}async readGoModuleName(o){try{let d=await cst.default.readFile(o,"utf-8"),h=/^module\s+(\S+)/mu.exec(d);return h?h[1]:null}catch{return null}}async findFirstGoFile(o){try{let h=(await cst.default.readdir(o,{withFileTypes:!0})).filter(m=>m.isFile()&&m.name.endsWith(".go")&&!m.name.endsWith("_test.go")).sort((m,T)=>m.name.localeCompare(T.name));return h.length>0?bJ.default.join(o,h[0].name):null}catch{return null}}async findDirectory(o,d,h){if(h<=0)return null;try{let T=(await cst.default.readdir(o,{withFileTypes:!0})).filter(u.isTraversableDir);for(let N of T){if(N.name===d)return bJ.default.join(o,N.name);let z=await this.findDirectory(bJ.default.join(o,N.name),d,h-1);if(z)return z}}catch{}return null}static isTraversableDir(o){return o.isDirectory()&&!o.name.startsWith(".")&&o.name!=="node_modules"}};var eOt=cc(require("node:fs/promises")),rEe=cc(require("node:path"));Im();Bne();GC();Jne();var ust=class{parser=null;fileReader;rootDir;extensionPath;initPromise=null;constructor(o,d){this.fileReader=new W1,this.rootDir=o??process.cwd(),this.extensionPath=d}async ensureInitialized(){if(!this.parser)return this.initPromise!==null?this.initPromise:(this.initPromise=(async()=>{let o=this.extensionPath;if(!o)throw new Error("Extension path required for WASM parser initialization. Ensure JavaParser is constructed with extensionPath parameter.");try{let d=hN.getInstance(),h=rEe.default.join(o,"dist","wasm","tree-sitter.wasm");await d.init(h);let m=rEe.default.join(o,"dist","wasm","tree-sitter-java.wasm");this.parser=await d.getParser("java",m)}catch(d){this.initPromise=null;let h=d instanceof Error?d.message:String(d);throw new Error(`Failed to initialize Java WASM parser: ${h}`,{cause:d})}})(),this.initPromise)}async parseImports(o){let d=VC(o),h;try{h=await this.fileReader.readFile(d)}catch(T){throw pg.fromError(T,d)}if(await this.ensureInitialized(),!this.parser)return[];let m=this.parser.parse(h);if(!m)return[];try{let T=[];return this.extractImports(m.rootNode,d,T),T}finally{m.delete()}}extractImports(o,d,h){if(o.type==="import_declaration"){let m=o.children.find(T=>T.type==="identifier"||T.type==="scoped_identifier");if(m){let T=m.text.trim();T&&h.push({path:ri(d),type:"import",line:m.startPosition.row+1,module:T})}}for(let m of o.children)this.extractImports(m,d,h)}async resolvePath(o,d){try{if(this.isJavaStdlibImport(d)||d.endsWith(".*"))return null;let h=d.split(".");if(h.some(ee=>ee===""||ee===".."||ee.includes("/")))return null;let m=h.at(-1)??"",T=h.join(rEe.default.sep)+".java",N=rEe.default.resolve(this.rootDir,T);if(this.isWithinRoot(N)&&await this.fileExists(N))return ri(N);let z=await this.findFile(this.rootDir,m+".java",4);return z?ri(z):null}catch{return null}}isWithinRoot(o){return ZF(o,this.rootDir)}isJavaStdlibImport(o){return["java.","javax.","sun.","com.sun.","org.w3c.","org.xml.","org.ietf.","org.omg.","jdk.","javafx."].some(h=>o.startsWith(h))}async findFile(o,d,h){if(h<=0)return null;try{let m=await eOt.default.readdir(o,{withFileTypes:!0});for(let T of m)if(T.isFile()&&T.name===d)return rEe.default.join(o,T.name);for(let T of m)if(T.isDirectory()&&!T.name.startsWith(".")&&T.name!=="node_modules"){let N=await this.findFile(rEe.default.join(o,T.name),d,h-1);if(N)return N}}catch{}return null}async fileExists(o){try{return await eOt.default.access(o),!0}catch{return!1}}};var tOt=cc(require("node:fs/promises")),PO=cc(require("node:path"));Im();GC();Jne();var dst=class{parser=null;fileReader;rootDir;extensionPath;initPromise=null;constructor(o,d){this.fileReader=new W1,this.rootDir=o||process.cwd(),this.extensionPath=d}async ensureInitialized(){this.parser||(this.initPromise??=(async()=>{let o=await this.resolveExtensionPath();if(!o)throw new Error("Extension path required for WASM parser initialization. Ensure PythonParser is constructed with extensionPath parameter.");try{let d=hN.getInstance(),h=PO.default.join(o,"dist","wasm","tree-sitter.wasm");await d.init(h);let m=PO.default.join(o,"dist","wasm","tree-sitter-python.wasm");this.parser=await d.getParser("python",m)}catch(d){this.initPromise=null;let h=d instanceof Error?d.message:String(d);throw new Error(`Failed to initialize Python WASM parser: ${h}`,{cause:d})}})(),await this.initPromise)}async resolveExtensionPath(){if(this.extensionPath)return this.extensionPath;let o=process.cwd(),d=PO.default.join(o,"dist","wasm","tree-sitter.wasm");try{return await tOt.default.access(d),o}catch{return}}async parseImports(o){try{await this.ensureInitialized();let d=VC(o),h=await this.fileReader.readFile(d),m=this.parser?.parse(h);if(!m)throw new Error(`Failed to parse Python file: ${d}`);let T=[],N=new Set;return this.traverseTree(m.rootNode,z=>{z.type==="import_statement"?this.extractImportStatement(z,T,N,h):z.type==="import_from_statement"&&this.extractImportFromStatement(z,T,N,h)}),T}catch(d){throw pg.fromError(d,o)}}async resolvePath(o,d){try{await this.ensureInitialized();let h=VC(o),m=PO.default.dirname(h);return d.startsWith(".")?await this.resolveRelativeImport(m,d):await this.resolveAbsoluteImport(m,d)}catch{return null}}extractImportStatement(o,d,h,m){let T=this.findChildrenByType(o,"dotted_name");for(let N of T){let z=this.getNodeText(N,m);z&&!h.has(z)&&(h.add(z),d.push({path:"",type:"import",line:N.startPosition.row+1,module:z}))}}extractImportFromStatement(o,d,h,m){let T=null,N=this.findChildByType(o,"relative_import");if(N)T=this.getNodeText(N,m);else{let z=this.findChildByType(o,"dotted_name");z&&(T=this.getNodeText(z,m))}T&&!h.has(T)&&(h.add(T),d.push({path:"",type:"import",line:o.startPosition.row+1,module:T}))}async resolveRelativeImport(o,d){let h=/^\.*/u.exec(d),m=h?h[0].length:0,T=d.slice(m).replaceAll(".","/"),N=o;for(let ee=1;ee<m;ee++)N=PO.default.dirname(N);let z=[PO.default.join(N,T+".py"),PO.default.join(N,T+".pyi"),PO.default.join(N,T,"__init__.py"),PO.default.join(N,T,"__init__.pyi")];for(let ee of z)if(await this.fileExists(ee))return ri(ee);return null}async resolveAbsoluteImport(o,d){let h=d.replaceAll(".","/"),m=ri(this.rootDir),T=new Set,N=async ee=>{let pe=ri(ee);if(T.has(pe))return null;T.add(pe);let Te=[PO.default.join(ee,h+".py"),PO.default.join(ee,h+".pyi"),PO.default.join(ee,h,"__init__.py"),PO.default.join(ee,h,"__init__.pyi")];for(let Ke of Te)if(await this.fileExists(Ke))return ri(Ke);return null},z=o;for(;;){let ee=await N(z);if(ee)return ee;let pe=PO.default.dirname(z);if(pe===z)break;if(ri(pe)===m){let Te=await N(pe);if(Te)return Te;break}z=pe}if(!T.has(m)){let ee=await N(this.rootDir);if(ee)return ee}return null}async fileExists(o){try{return await tOt.default.access(o),!0}catch{return!1}}traverseTree(o,d){d(o);for(let h of o.children)this.traverseTree(h,d)}findChildrenByType(o,d){let h=[];for(let m of o.children)m.type===d&&h.push(m);return h}findChildByType(o,d){for(let h of o.children)if(h.type===d)return h;return null}getNodeText(o,d){return d.slice(o.startIndex,o.endIndex)}};var VUt=cc(require("node:fs/promises")),pst=cc(require("node:path"));Im();GC();Jne();var fst=class{parser=null;fileReader;initPromise=null;extensionPath;constructor(o,d){this.extensionPath=d??o,this.fileReader=new W1}async ensureInitialized(){this.parser||(this.initPromise??=(async()=>{let o=await this.resolveExtensionPath();if(!o)throw new Error("Extension path required for WASM parser initialization. Ensure PythonSymbolAnalyzer is constructed with extensionPath parameter.");try{let d=hN.getInstance(),h=pst.default.join(o,"dist","wasm","tree-sitter.wasm");await d.init(h);let m=pst.default.join(o,"dist","wasm","tree-sitter-python.wasm");this.parser=await d.getParser("python",m)}catch(d){this.initPromise=null;let h=d instanceof Error?d.message:String(d);throw new Error(`Failed to initialize Python WASM parser for symbol analysis: ${h}`,{cause:d})}})(),await this.initPromise)}async resolveExtensionPath(){if(this.extensionPath)return this.extensionPath;let o=process.cwd(),d=pst.default.join(o,"dist","wasm","tree-sitter.wasm");try{return await VUt.default.access(d),o}catch{return}}async analyzeFile(o){try{await this.ensureInitialized();let d=await this.fileReader.readFile(o);return this.analyzeFileFromContent(o,d)}catch(d){throw pg.fromError(d,o)}}analyzeFileFromContent(o,d){if(!this.parser)throw new Error("Parser not initialized. Call ensureInitialized() before using analyzeFileFromContent().");let h=this.parser.parse(d);if(!h)throw new Error(`Failed to parse Python file: ${o}`);try{let m=new Map,T=ri(o);return this.extractSymbols(h.rootNode,T,d,m),m}finally{h.delete()}}analyzeFileContent(o,d){if(!this.parser)throw new Error("Parser not initialized. Call ensureInitialized() before using analyzeFileContent().");let h=this.parser.parse(d);if(!h)throw new Error(`Failed to parse Python file: ${o}`);try{let m=new Map,T=[],N=ri(o);this.extractSymbols(h.rootNode,N,d,m);let z=this.buildImportMap(h.rootNode,d);return this.extractDependencies(h.rootNode,N,d,T,m,void 0,z),{symbols:Array.from(m.values()),dependencies:T}}finally{h.delete()}}async getSymbolDependencies(o){try{await this.ensureInitialized();let d=await this.fileReader.readFile(o);return this.analyzeFileContent(o,d).dependencies}catch(d){throw pg.fromError(d,o)}}extractSymbols(o,d,h,m,T){this.tryExtractSymbolFromNode(o,d,h,m,T)||this.extractSymbolsFromChildren(o,d,h,m,T)}tryExtractSymbolFromNode(o,d,h,m,T){return o.type==="function_definition"?(this.handleFunctionDefinition(o,d,h,m,T),!0):o.type==="class_definition"?(this.handleClassDefinition(o,d,h,m,T),!0):o.type==="decorated_definition"?(this.handleDecoratedDefinition(o,d,h,m,T),!0):!1}handleFunctionDefinition(o,d,h,m,T){let N=o.childForFieldName("name");if(!N)return;let z=this.getNodeText(N,h),ee=`${d}:${z}`,pe=this.hasChild(o,"async");m.set(ee,{name:z,kind:pe?"AsyncFunction":"FunctionDeclaration",line:N.startPosition.row+1,isExported:this.isExported(o,h),id:ee,parentSymbolId:T,category:"function"}),this.extractSymbolsFromChildren(o,d,h,m,ee)}handleClassDefinition(o,d,h,m,T){let N=o.childForFieldName("name");if(!N)return;let z=this.getNodeText(N,h),ee=`${d}:${z}`;m.set(ee,{name:z,kind:"ClassDeclaration",line:N.startPosition.row+1,isExported:this.isExported(o,h),id:ee,parentSymbolId:T,category:"class"}),this.extractSymbolsFromChildren(o,d,h,m,ee)}handleDecoratedDefinition(o,d,h,m,T){for(let N of o.children)(N.type==="function_definition"||N.type==="class_definition")&&this.extractSymbols(N,d,h,m,T)}extractSymbolsFromChildren(o,d,h,m,T){for(let N of o.children)this.extractSymbols(N,d,h,m,T)}buildImportMap(o,d){let h=new Map;return this.traverseForImports(o,h,d),h}traverseForImports(o,d,h){o.type==="import_from_statement"?this.processFromImport(o,d,h):o.type==="import_statement"&&this.processImportStatement(o,d,h);for(let m of o.children)this.traverseForImports(m,d,h)}processFromImport(o,d,h){let m=o.childForFieldName("module_name");if(!m)return;let T=this.getNodeText(m,h);for(let N of o.children)this.processFromImportChild(N,d,h,T)}processFromImportChild(o,d,h,m){if(o.type==="aliased_import"){this.addAliasedFromImport(o,d,h,m);return}if(o.type==="dotted_name"||o.type==="identifier"){let T=this.getNodeText(o,h);if(T===m||o.parent?.type==="aliased_import")return;d.set(T,m)}}addAliasedFromImport(o,d,h,m){let T=o.childForFieldName("name");if(!T)return;let N=this.getNodeText(T,h),z=o.childForFieldName("alias"),ee=z?this.getNodeText(z,h):N;d.set(ee,m)}processImportStatement(o,d,h){for(let m of o.children)this.processImportStatementChild(m,d,h)}processImportStatementChild(o,d,h){if(o.type==="aliased_import"){let m=o.childForFieldName("name");if(!m)return;let T=this.getNodeText(m,h),N=o.childForFieldName("alias"),z=N?this.getNodeText(N,h):T;d.set(z,T);return}if(o.type==="dotted_name"||o.type==="identifier"){let m=this.getNodeText(o,h);m!=="import"&&d.set(m,m)}}extractDependencies(o,d,h,m,T,N,z){let ee=this.getScopeForNode(o,d,h,N);this.addCallDependencyIfAny(o,d,h,m,T,ee,z);for(let pe of o.children)this.extractDependencies(pe,d,h,m,T,ee,z)}getScopeForNode(o,d,h,m){if(o.type!=="function_definition"&&o.type!=="class_definition")return m;let T=o.childForFieldName("name");if(!T)return m;let N=this.getNodeText(T,h);return`${d}:${N}`}addCallDependencyIfAny(o,d,h,m,T,N,z){if(o.type!=="call")return;let ee=o.childForFieldName("function");if(!ee||!N)return;let pe=this.getCalledName(ee,h),Te=`${d}:${pe}`;if(T.has(Te)){m.push({sourceSymbolId:N,targetSymbolId:Te,targetFilePath:d,isTypeOnly:!1});return}if(z?.has(pe)){let Ke=z.get(pe);if(Ke===void 0)return;m.push({sourceSymbolId:N,targetSymbolId:`${Ke}:${pe}`,targetFilePath:Ke,isTypeOnly:!1})}}getCalledName(o,d){if(o.type!=="attribute")return this.getNodeText(o,d);let h=o.childForFieldName("attribute");return h?this.getNodeText(h,d):this.getNodeText(o,d)}isExported(o,d){let h=o.childForFieldName("name");return h?!this.getNodeText(h,d).startsWith("_"):!1}hasChild(o,d){for(let h of o.children)if(h.type===d)return!0;return!1}getNodeText(o,d){return d.slice(o.startIndex,o.endIndex)}};var nOt=cc(require("node:fs/promises")),$ne=cc(require("node:path"));Im();GC();Jne();var mst=class{parser=null;fileReader;rootDir;extensionPath;initPromise=null;constructor(o,d){this.fileReader=new W1,this.rootDir=o||process.cwd(),this.extensionPath=d}async ensureInitialized(){this.parser||(this.initPromise??=(async()=>{let o=await this.resolveExtensionPath();if(!o)throw new Error("Extension path required for WASM parser initialization. Ensure RustParser is constructed with extensionPath parameter.");try{let d=hN.getInstance(),h=$ne.default.join(o,"dist","wasm","tree-sitter.wasm");await d.init(h);let m=$ne.default.join(o,"dist","wasm","tree-sitter-rust.wasm");this.parser=await d.getParser("rust",m)}catch(d){this.initPromise=null;let h=d instanceof Error?d.message:String(d);throw new Error(`Failed to initialize Rust WASM parser: ${h}`,{cause:d})}})(),await this.initPromise)}async resolveExtensionPath(){if(this.extensionPath)return this.extensionPath;let o=process.cwd(),d=$ne.default.join(o,"dist","wasm","tree-sitter.wasm");try{return await nOt.default.access(d),o}catch{return}}async parseImports(o){try{await this.ensureInitialized();let d=VC(o),h=await this.fileReader.readFile(d),m=this.parser?.parse(h);if(!m)throw new Error(`Failed to parse Rust file: ${d}`);let T=[],N=new Set;return this.traverseTree(m.rootNode,z=>{z.type==="use_declaration"?this.extractUseDeclaration(z,T,N,h):z.type==="mod_item"?this.extractModItem(z,T,N,h,o):z.type==="extern_crate_declaration"&&this.extractExternCrate(z,T,N,h)}),T}catch(d){throw pg.fromError(d,o)}}async resolvePath(o,d){try{await this.ensureInitialized();let h=d.split("::")[0];if(new Set(["std","core","alloc","proc_macro","test","serde","tokio","async_std","futures","vm","rustpython_vm","rustpython","rustpython_parser","rustpython_compiler","num_traits","enum_dispatch","dashmap"]).has(h))return null;let T=VC(o),N=$ne.default.dirname(T);return d.startsWith("self::")||d.startsWith("super::")||d.startsWith("crate::")?await this.resolveRelativeModule(o,d):await this.resolveModDeclaration(N,d)}catch{return null}}extractUseDeclaration(o,d,h,m){let T=this.collectIdentifiers(o,m);for(let N of T){if(!N)continue;let z=N.split("::")[0];if(new Set(["std","core","alloc","proc_macro","test","serde","tokio","async_std","futures","vm","rustpython_vm","rustpython","rustpython_parser","rustpython_compiler","num_traits","enum_dispatch","dashmap"]).has(z))continue;let pe=N.toLowerCase();h.has(pe)||(h.add(pe),d.push({path:"",type:"import",line:o.startPosition.row+1,module:pe}))}}extractModItem(o,d,h,m,T){if(this.findChildByType(o,"declaration_list"))return;let z=this.findChildByType(o,"identifier");if(z){let ee=this.getNodeText(z,m);ee=ee.toLowerCase(),ee&&!h.has(ee)&&(h.add(ee),d.push({path:"",type:"import",line:o.startPosition.row+1,module:ee}))}}extractExternCrate(o,d,h,m){let T=this.findChildByType(o,"identifier");if(T){let N=this.getNodeText(T,m);if(!N||new Set(["std","core","alloc","proc_macro","test","serde","tokio","async_std","futures","vm","rustpython_vm","rustpython","rustpython_parser","rustpython_compiler","num_traits","enum_dispatch","dashmap"]).has(N))return;let ee=N.toLowerCase();h.has(ee)||(h.add(ee),d.push({path:"",type:"import",line:o.startPosition.row+1,module:ee}))}}collectIdentifiers(o,d){let h=[],m=this.findAllByType(o,"scoped_identifier");for(let N of m){let z=this.getNodeText(N,d);z&&h.push(z)}let T=this.findAllByType(o,"identifier");for(let N of T){let z=this.getNodeText(N,d);if(!z||z==="self"||z==="super"||z==="crate")continue;let ee=z.charAt(0);ee===ee.toUpperCase()&&ee!==ee.toLowerCase()||h.push(z)}return h}async resolveRelativeModule(o,d){let h=$ne.default.dirname(o);if(d.startsWith("crate::")){let m=d.slice(7).replaceAll("::","/");return await this.resolveModDeclaration(this.rootDir,m)}if(d.startsWith("super::")){let m=$ne.default.dirname(h),T=d.slice(7).replaceAll("::","/");return await this.resolveModDeclaration(m,T)}if(d.startsWith("self::")){let m=d.slice(6).replaceAll("::","/");return await this.resolveModDeclaration(h,m)}return null}async resolveModDeclaration(o,d){if(d!==d.toLowerCase())return null;let h=d.replaceAll("::","/");h=h.toLowerCase();let m=[$ne.default.join(o,h+".rs"),$ne.default.join(o,h,"mod.rs")];for(let T of m)if(await this.fileExists(T))return ri(T);return null}async fileExists(o){try{return await nOt.default.access(o),!0}catch{return!1}}traverseTree(o,d){d(o);for(let h of o.children)this.traverseTree(h,d)}findChildByType(o,d){for(let h of o.children)if(h.type===d)return h;return null}findAllByType(o,d){let h=[],m=T=>{T.type===d&&h.push(T);for(let N of T.children)m(N)};return m(o),h}getNodeText(o,d){return d.slice(o.startIndex,o.endIndex)}};var UUt=cc(require("node:fs/promises")),_st=cc(require("node:path"));Im();GC();Jne();var hst=class{parser=null;fileReader;initPromise=null;extensionPath;constructor(o,d){this.extensionPath=d??o,this.fileReader=new W1}async ensureInitialized(){this.parser||(this.initPromise??=(async()=>{let o=await this.resolveExtensionPath();if(!o)throw new Error("Extension path required for WASM parser initialization. Ensure RustSymbolAnalyzer is constructed with extensionPath parameter.");try{let d=hN.getInstance(),h=_st.default.join(o,"dist","wasm","tree-sitter.wasm");await d.init(h);let m=_st.default.join(o,"dist","wasm","tree-sitter-rust.wasm");this.parser=await d.getParser("rust",m)}catch(d){this.initPromise=null;let h=d instanceof Error?d.message:String(d);throw new Error(`Failed to initialize Rust WASM parser for symbol analysis: ${h}`,{cause:d})}})(),await this.initPromise)}async resolveExtensionPath(){if(this.extensionPath)return this.extensionPath;let o=process.cwd(),d=_st.default.join(o,"dist","wasm","tree-sitter.wasm");try{return await UUt.default.access(d),o}catch{return}}async analyzeFile(o){try{await this.ensureInitialized();let d=await this.fileReader.readFile(o);return this.analyzeFileFromContent(o,d)}catch(d){throw pg.fromError(d,o)}}analyzeFileFromContent(o,d){if(!this.parser)throw new Error("Parser not initialized. Call ensureInitialized() before using analyzeFileFromContent().");let h=this.parser.parse(d);if(!h)throw new Error(`Failed to parse Rust file: ${o}`);try{let m=new Map,T=ri(o);return this.extractSymbols(h.rootNode,T,d,m),m}finally{h.delete()}}analyzeFileContent(o,d){if(!this.parser)throw new Error("Parser not initialized. Call ensureInitialized() before using analyzeFileContent().");let h=this.parser.parse(d);if(!h)throw new Error(`Failed to parse Rust file: ${o}`);try{let m=new Map,T=[],N=ri(o);this.extractSymbols(h.rootNode,N,d,m);let z=this.buildImportMap(h.rootNode,d);return this.extractDependencies(h.rootNode,N,d,T,m,void 0,z),{symbols:Array.from(m.values()),dependencies:T}}finally{h.delete()}}async getSymbolDependencies(o){try{await this.ensureInitialized();let d=await this.fileReader.readFile(o);return this.analyzeFileContent(o,d).dependencies}catch(d){throw pg.fromError(d,o)}}extractSymbols(o,d,h,m,T){this.tryExtractSymbolFromNode(o,d,h,m,T)||this.extractSymbolsFromChildren(o,d,h,m,T)}tryExtractSymbolFromNode(o,d,h,m,T){return o.type==="function_item"?(this.handleFunctionItem(o,d,h,m,T),!0):o.type==="struct_item"?(this.handleStructItem(o,d,h,m,T),!0):o.type==="enum_item"?(this.handleEnumItem(o,d,h,m,T),!0):o.type==="trait_item"?(this.handleTraitItem(o,d,h,m,T),!0):o.type==="impl_item"?(this.handleImplItem(o,d,h,m,T),!0):!1}handleFunctionItem(o,d,h,m,T){let N=o.childForFieldName("name");if(!N)return;let z=this.getNodeText(N,h),ee=`${d}:${z}`,pe=this.hasModifier(o,"async"),Te=this.hasVisibilityModifier(o,"pub");m.set(ee,{name:z,kind:pe?"AsyncFunction":"FunctionDeclaration",line:N.startPosition.row+1,isExported:Te,id:ee,parentSymbolId:T,category:"function"}),this.extractSymbolsFromChildren(o,d,h,m,ee)}handleStructItem(o,d,h,m,T){let N=o.childForFieldName("name");if(!N)return;let z=this.getNodeText(N,h),ee=`${d}:${z}`,pe=this.hasVisibilityModifier(o,"pub");m.set(ee,{name:z,kind:"StructDeclaration",line:N.startPosition.row+1,isExported:pe,id:ee,parentSymbolId:T,category:"class"}),this.extractSymbolsFromChildren(o,d,h,m,ee)}handleEnumItem(o,d,h,m,T){let N=o.childForFieldName("name");if(!N)return;let z=this.getNodeText(N,h),ee=`${d}:${z}`,pe=this.hasVisibilityModifier(o,"pub");m.set(ee,{name:z,kind:"EnumDeclaration",line:N.startPosition.row+1,isExported:pe,id:ee,parentSymbolId:T,category:"type"}),this.extractSymbolsFromChildren(o,d,h,m,ee)}handleTraitItem(o,d,h,m,T){let N=o.childForFieldName("name");if(!N)return;let z=this.getNodeText(N,h),ee=`${d}:${z}`,pe=this.hasVisibilityModifier(o,"pub");m.set(ee,{name:z,kind:"InterfaceDeclaration",line:N.startPosition.row+1,isExported:pe,id:ee,parentSymbolId:T,category:"type"}),this.extractSymbolsFromChildren(o,d,h,m,ee)}handleImplItem(o,d,h,m,T){this.extractSymbolsFromChildren(o,d,h,m,T)}extractSymbolsFromChildren(o,d,h,m,T){for(let N of o.children)this.extractSymbols(N,d,h,m,T)}buildImportMap(o,d){let h=new Map,m=T=>{if(T.type==="use_declaration"&&this.extractUseDeclarationImports(T,d,h),T.type==="mod_item"){let N=T.childForFieldName("name");if(N){let z=this.getNodeText(N,d);h.set(z,z)}}for(let N of T.children)m(N)};return m(o),h}extractUseDeclarationImports(o,d,h){this.extractFromUseLists(o,d,h),this.extractFromScopedIdentifiers(o,d,h),this.extractFromUseAsClauses(o,d,h)}extractFromUseLists(o,d,h){let m=this.findAllByType(o,"use_list");for(let T of m){let N=this.findBaseModuleForUseList(T,d);this.extractIdentifiersFromUseList(T,N,d,h)}}findBaseModuleForUseList(o,d){let h=o.parent;for(;h;){if(h.type==="scoped_use_list"){let m=this.findScopedIdentifierInChildren(h,d);if(m)return m}h=h.parent}return""}findScopedIdentifierInChildren(o,d){for(let h of o.children)if(h.type==="scoped_identifier")return this.getNodeText(h,d);return""}extractIdentifiersFromUseList(o,d,h,m){for(let T of o.children)if(T.type==="identifier"){let N=this.getNodeText(T,h);m.set(N,d)}}extractFromScopedIdentifiers(o,d,h){let m=this.findAllByType(o,"scoped_identifier");for(let T of m){if(this.hasAncestorOfType(T,"use_list"))continue;let N=this.getNodeText(T,d),{localName:z,modulePath:ee}=this.splitModulePath(N);h.set(z,ee)}}splitModulePath(o){let d=o.split("::"),h=d.at(-1)??"",m=d.slice(0,-1).join("::");return{localName:h,modulePath:m}}extractFromUseAsClauses(o,d,h){let m=this.findAllByType(o,"use_as_clause");for(let T of m){let N=T.childForFieldName("path"),z=T.childForFieldName("alias");if(N&&z){let ee=this.getNodeText(N,d),pe=this.getNodeText(z,d);h.set(pe,ee)}}}extractDependencies(o,d,h,m,T,N,z){let ee=this.getScopeForNode(o,d,h,N);this.addCallDependencyIfAny(o,d,h,m,T,ee,z);for(let pe of o.children)this.extractDependencies(pe,d,h,m,T,ee,z)}getScopeForNode(o,d,h,m){if(o.type!=="function_item")return m;let T=o.childForFieldName("name");if(!T)return m;let N=this.getNodeText(T,h);return`${d}:${N}`}addCallDependencyIfAny(o,d,h,m,T,N,z){if(o.type!=="call_expression")return;let ee=o.childForFieldName("function");if(!ee||!N)return;let{moduleName:pe,symbolName:Te}=this.extractModuleAndSymbolName(ee,h),Ke=`${d}:${Te}`;if(T.has(Ke)){m.push({sourceSymbolId:N,targetSymbolId:Ke,targetFilePath:d,isTypeOnly:!1});return}if(pe&&z?.has(pe)){let ce=z.get(pe);if(ce===void 0)return;m.push({sourceSymbolId:N,targetSymbolId:`${ce}:${Te}`,targetFilePath:ce,isTypeOnly:!1});return}if(z?.has(Te)){let ce=z.get(Te);if(ce===void 0)return;m.push({sourceSymbolId:N,targetSymbolId:`${ce}:${Te}`,targetFilePath:ce,isTypeOnly:!1})}}extractModuleAndSymbolName(o,d){if(o.type==="field_expression"){let h=o.childForFieldName("field");if(h)return{moduleName:void 0,symbolName:this.getNodeText(h,d)}}if(o.type==="scoped_identifier"){let m=this.getNodeText(o,d).split("::");if(m.length>=2){let T=m.at(-1)??"";return{moduleName:m.slice(0,-1).join("::"),symbolName:T}}return{moduleName:void 0,symbolName:m[0]}}return{moduleName:void 0,symbolName:this.getNodeText(o,d)}}hasVisibilityModifier(o,d){if(o.childForFieldName("visibility_modifier"))return!0;for(let m of o.children)if(m.type==="visibility_modifier")return!0;return!1}hasAncestorOfType(o,d){let h=o.parent;for(;h;){if(h.type===d)return!0;h=h.parent}return!1}hasModifier(o,d){for(let h of o.children)if(h.type===d)return!0;return!1}findAllByType(o,d){let h=[],m=T=>{T.type===d&&h.push(T);for(let N of T.children)m(N)};return m(o),h}getNodeText(o,d){return d.slice(o.startIndex,o.endIndex)}};var Ske=class u{static typeScriptParsers=new Map;static typeScriptSymbolAnalyzers=new Map;static pythonParsers=new Map;static pythonSymbolAnalyzers=new Map;static rustParsers=new Map;static rustSymbolAnalyzers=new Map;static csharpParsers=new Map;static goParsers=new Map;static javaParsers=new Map;rootDir;extensionPath;ignoreTypeImports;constructor(o,d,h,m){this.rootDir=o,this.extensionPath=h,this.ignoreTypeImports=m}getAnalyzer(o){let d=VC(o);return u.getAnalyzer(d,this.rootDir,this.extensionPath,this.ignoreTypeImports)}getSymbolAnalyzer(o){let d=VC(o);return u.getSymbolAnalyzer(d,this.rootDir,this.extensionPath)}static detectLanguage(o){let d=VC(o);switch(HUt.default.extname(d).toLowerCase()){case".ts":case".tsx":case".js":case".jsx":case".mjs":case".cjs":case".vue":case".svelte":case".gql":case".graphql":return"typescript";case".py":case".pyi":return"python";case".rs":case".toml":return"rust";case".cs":case".csproj":return"csharp";case".go":return"go";case".java":return"java";default:return"unknown"}}static getAnalyzer(o,d,h,m){let T=VC(o);switch(this.detectLanguage(T)){case"typescript":{let z=this.buildCacheKey(d,m?"ignore-types":""),ee=this.typeScriptParsers.get(z);if(ee)return ee;let pe=new $De(d,m);return this.typeScriptParsers.set(z,pe),pe}case"python":{let z=this.buildCacheKey(d,h),ee=this.pythonParsers.get(z);if(ee)return ee;let pe=new dst(d,h);return this.pythonParsers.set(z,pe),pe}case"rust":{let z=this.buildCacheKey(d,h),ee=this.rustParsers.get(z);if(ee)return ee;let pe=new mst(d,h);return this.rustParsers.set(z,pe),pe}case"csharp":{let z=this.buildCacheKey(d,h),ee=this.csharpParsers.get(z);if(ee)return ee;let pe=new sst(d,h);return this.csharpParsers.set(z,pe),pe}case"go":{let z=this.buildCacheKey(d,h),ee=this.goParsers.get(z);if(ee)return ee;let pe=new lst(d,h);return this.goParsers.set(z,pe),pe}case"java":{let z=this.buildCacheKey(d,h),ee=this.javaParsers.get(z);if(ee)return ee;let pe=new ust(d,h);return this.javaParsers.set(z,pe),pe}default:throw new Error(`Unsupported language for file: ${o}`)}}static getSymbolAnalyzer(o,d,h){let m=VC(o);switch(this.detectLanguage(m)){case"typescript":{let N=this.buildCacheKey(d),z=this.typeScriptSymbolAnalyzers.get(N);if(z)return z;let ee=new ast(d);return this.typeScriptSymbolAnalyzers.set(N,ee),ee}case"python":{let N=this.buildCacheKey(d,h),z=this.pythonSymbolAnalyzers.get(N);if(z)return z;let ee=new fst(d,h);return this.pythonSymbolAnalyzers.set(N,ee),ee}case"rust":{let N=this.buildCacheKey(d,h),z=this.rustSymbolAnalyzers.get(N);if(z)return z;let ee=new hst(d,h);return this.rustSymbolAnalyzers.set(N,ee),ee}default:throw new Error(`Unsupported language for file: ${o}`)}}static isSupported(o){return this.detectLanguage(o)!=="unknown"}static reset(){this.typeScriptParsers.clear(),this.typeScriptSymbolAnalyzers.clear(),this.pythonParsers.clear(),this.pythonSymbolAnalyzers.clear(),this.rustParsers.clear(),this.rustSymbolAnalyzers.clear(),this.csharpParsers.clear(),this.goParsers.clear(),this.javaParsers.clear()}static releaseWorkspace(o){let d=`${o}\0`;for(let h of[this.typeScriptParsers,this.typeScriptSymbolAnalyzers,this.pythonParsers,this.pythonSymbolAnalyzers,this.rustParsers,this.rustSymbolAnalyzers,this.csharpParsers,this.goParsers,this.javaParsers])for(let m of h.keys())m.startsWith(d)&&h.delete(m)}static buildCacheKey(...o){return o.map(d=>d??"").join("\0")}};jC();GC();var JUt=Uh("ReferencingFilesFinder"),Tke=class{sourceFileCollector;getRootDir;getConcurrency;findReferenceInFile;constructor(o){this.sourceFileCollector=o.sourceFileCollector,this.getRootDir=o.getRootDir,this.getConcurrency=o.getConcurrency,this.findReferenceInFile=o.findReferenceInFile}async findReferencingFilesFallback(o){let d=ri(o),h=this.extractBasename(d);if(!h)return[];JUt.debug("findReferencingFilesFallback for",d,"basename:",h);let m=await this.sourceFileCollector.collectAllSourceFiles(this.getRootDir()),T=[],N=this.getConcurrency()??8;for(let z=0;z<m.length;z+=N){let ee=m.slice(z,z+N),pe=await Promise.all(ee.filter(Te=>ri(Te)!==d).map(Te=>this.findReferenceInFile(Te,d,h)));for(let Te of pe)Te&&T.push(Te)}return JUt.debug("findReferencingFilesFallback found",T.length,"referencing files"),T}extractBasename(o){return o.split(/[/\\]/).pop()?.replace(/\.[^/.]+$/,"")}};var KUt=cc(require("node:fs/promises"));GC();jC();var $Ut=Uh("ReverseIndex"),rOt=1,fse=class u{reverseMap=new Map;fileHashes=new Map;rootDir;constructor(o){this.rootDir=ri(o)}addDependencies(o,d,h){let m=ri(o);this.removeDependenciesFromSource(m);for(let T of d){let N=ri(T.path),z={sourcePath:m,type:T.type,line:T.line,module:T.module},ee=this.reverseMap.get(N);ee||(ee=new Map,this.reverseMap.set(N,ee)),ee.set(m,z)}h&&this.fileHashes.set(m,h)}removeDependenciesFromSource(o){let d=ri(o);for(let[,h]of this.reverseMap)h.delete(d);this.fileHashes.delete(d)}getReferencingFiles(o){let d=ri(o),h=this.reverseMap.get(d);return h?.size===0?(this.reverseMap.delete(d),[]):h?Array.from(h.values()).map(m=>({path:m.sourcePath,type:m.type,line:m.line,module:m.module})):[]}getCallerCount(o){let d=ri(o);return this.reverseMap.get(d)?.size??0}isFileStale(o,d){let h=ri(o),m=this.fileHashes.get(h);return m?m.mtime!==d.mtime||m.size!==d.size:!0}getFileHash(o){return this.fileHashes.get(ri(o))}updateFileHash(o,d){this.fileHashes.set(ri(o),d)}hasEntries(){return this.reverseMap.size>0}hasFile(o){return this.fileHashes.has(ri(o))}get indexedFileCount(){return this.fileHashes.size}get targetFileCount(){return this.reverseMap.size}clear(){this.reverseMap.clear(),this.fileHashes.clear()}getEmptyMapCount(){let o=0;for(let d of this.reverseMap.values())d.size===0&&o++;return o}cleanup(){let o=0,d=[];for(let[h,m]of this.reverseMap)m.size===0&&d.push(h);for(let h of d)this.reverseMap.delete(h),o++;return o}static async getFileHashFromDisk(o){try{let d=await KUt.stat(o);return{mtime:d.mtimeMs,size:d.size}}catch{return null}}serialize(){let o={};for(let[h,m]of this.reverseMap)m.size!==0&&(o[h]=Array.from(m.values()));let d={};for(let[h,m]of this.fileHashes)d[h]=m;return{version:rOt,timestamp:Date.now(),rootDir:this.rootDir,reverseMap:o,fileHashes:d}}static deserialize(o,d){let h=ri(d),m=ri(o.rootDir);if(o.version!==rOt)return $Ut.warn("Version mismatch:",o.version,"!==",rOt),null;if(m!==h)return $Ut.warn("Root dir mismatch:",o.rootDir,"!==",d),null;let T=new u(d);for(let[N,z]of Object.entries(o.fileHashes))T.fileHashes.set(ri(N),z);for(let[N,z]of Object.entries(o.reverseMap)){let ee=ri(N),pe=new Map;for(let Te of z){let Ke=ri(Te.sourcePath);pe.set(Ke,{...Te,sourcePath:Ke})}T.reverseMap.set(ee,pe)}return T}async validateIndex(o=.2,d,h){let m=[],T=[],N=h?[...new Set(h.map(ri))]:[...this.fileHashes.keys()];for(let Ke of N){let ce=await u.getFileHashFromDisk(Ke);if(!ce){T.push(Ke);continue}(!this.fileHashes.has(Ke)||this.isFileStale(Ke,ce))&&m.push(Ke)}let z=0;if(d)for(let Ke of d){let ce=ri(Ke);!this.fileHashes.has(ce)&&!m.includes(ce)&&(m.push(ce),z++)}let ee=(h?N.length:this.fileHashes.size)+z,pe=m.length+T.length,Te=ee>0?pe/ee:0;return{isValid:Te<=o,staleFiles:m,stalePercentage:Te,missingFiles:T}}getStats(){let o=0;for(let d of this.reverseMap.values())o+=d.size;return{indexedFiles:this.fileHashes.size,targetFiles:this.reverseMap.size,totalReferences:o}}};iOt();var Cke=class{constructor(o){this.rootDir=o}rootDir;reverseIndex=null;symbolReverseIndex=null;enable(o){let d=!1;if(this.reverseIndex??=new fse(this.rootDir),this.symbolReverseIndex??=new Eke(this.rootDir),o)try{let h=JSON.parse(o),m=fse.deserialize(h,this.rootDir);m&&(this.reverseIndex=m,d=!0)}catch{d=!1}return d}disable(){this.reverseIndex?.clear(),this.reverseIndex=null,this.symbolReverseIndex?.clear(),this.symbolReverseIndex=null}clear(){this.reverseIndex?.clear(),this.symbolReverseIndex?.clear()}isEnabled(){return this.reverseIndex!==null}hasEntries(){return this.reverseIndex?.hasEntries()??!1}ensure(){this.reverseIndex??=new fse(this.rootDir)}addDependencies(o,d,h){this.reverseIndex?.addDependencies(o,d,h)}removeDependenciesFromSource(o){this.reverseIndex?.removeDependenciesFromSource(o)}getReferencingFiles(o){return this.reverseIndex?this.reverseIndex.getReferencingFiles(o):[]}getCallerCount(o){return this.reverseIndex?this.reverseIndex.getCallerCount(o):0}getSerialized(){return this.reverseIndex?JSON.stringify(this.reverseIndex.serialize()):null}validate(o=.2,d,h){return this.reverseIndex?.validateIndex(o,d,h)??null}getStats(){return this.reverseIndex?.getStats()}addSymbolDependencies(o,d,h){this.symbolReverseIndex?.addDependencies(o,d,h)}removeSymbolDependenciesFromSource(o){this.symbolReverseIndex?.removeDependenciesFromSource(o)}getSymbolReferencingFiles(o){return this.symbolReverseIndex?.getCallerFiles(o)??[]}getSymbolStats(){return this.symbolReverseIndex?.getStats()}};Yae();Yae();GC();var Ake=class{constructor(o,d,h){this.dependencyCache=o;this.symbolCache=d;this.reverseIndexManager=h}dependencyCache;symbolCache;reverseIndexManager;clearAll(){this.dependencyCache.clear(),this.symbolCache.clear(),this.reverseIndexManager.clear()}invalidateFile(o){let d=ri(o),h=this.dependencyCache.has(d);return this.dependencyCache.delete(d),this.symbolCache.delete(d),this.reverseIndexManager.removeDependenciesFromSource(d),h}invalidateFiles(o){let d=0;for(let h of o)this.invalidateFile(h)&&d++;return d}handleFileDeleted(o){let d=ri(o);this.dependencyCache.delete(d),this.symbolCache.delete(d),this.reverseIndexManager.removeDependenciesFromSource(d)}};GC();jC();var mse=Uh("SpiderDependencyAnalyzer"),Ike=class{constructor(o,d,h,m){this.languageService=o;this.resolver=d;this.dependencyCache=h;this.reverseIndexManager=m}languageService;resolver;dependencyCache;reverseIndexManager;async analyze(o){let d=ri(o),h=this.dependencyCache.get(d);if(h)return mse.debug(`Returning ${h.length} cached dependencies for ${o}`),await this.updateReverseIndexIfEnabled(o,d,h),h;mse.debug(`Analyzing ${o}...`);try{let m=this.languageService.getAnalyzer(o),T=await m.parseImports(o);mse.debug(`Parsed ${T.length} imports from ${o}`);let N=[],z=new Set;for(let ee of T){let pe=await m.resolvePath(o,ee.module);if(!pe){mse.debug(`Failed to resolve module "${ee.module}" from ${o}`);continue}if(!this.resolver.isWithinWorkspace(pe)){mse.warn(`Skipping dependency outside workspace: ${ee.module}`);continue}let Te=ri(pe);z.has(Te)||(z.add(Te),N.push({path:Te,type:ee.type,line:ee.line,module:ee.module}))}return mse.debug(`Resolved ${N.length} dependencies for ${o}`),this.dependencyCache.set(d,N),await this.updateReverseIndexIfEnabled(o,d,N),N}catch(m){let T=pg.fromError(m,o);if(T.code==="FILE_TOO_LARGE"||T.code==="TIMEOUT")return mse.warn(`Skipping ${o}: ${T.toUserMessage()}`),[];throw mse.error("Analysis failed:",T.toUserMessage(),T.code),T}}async resolveModuleSpecifier(o,d){try{return await this.resolver.resolve(o,d)}catch{return null}}invalidateDependencyCache(o){this.dependencyCache.delete(ri(o))}async updateReverseIndexIfEnabled(o,d,h){if(!this.reverseIndexManager.isEnabled())return;let m=await fse.getFileHashFromDisk(o);m&&this.reverseIndexManager.addDependencies(d,h,m)}};GC();UDe();GC();function iEe(u){let d=ri(u).split("/");for(let h=0;h<d.length-1;h++)if(Ctt.includes(d[h]))return!0;return!1}jC();var _se=Uh("SpiderGraphCrawler"),Dke=class{constructor(o,d){this.dependencyAnalyzer=o;this.getConfig=d}dependencyAnalyzer;getConfig;async crawl(o,d){let h=new Set,m=[],T=new Set,N=new Set,z={},ee=d?.maxDepth??this.getConfig().maxDepth??3,pe=()=>{if(d?.signal?.aborted){let Ke=new Error("Crawl cancelled");throw Ke.name="AbortError",Ke}};_se.debug(`Starting crawl from: ${o}`);let Te=async(Ke,ce)=>{pe();let Bt=ri(Ke);if(ce>ee){_se.debug(`Skipping ${Ke}: max depth ${ee} reached`);return}if(N.has(Bt)){_se.debug(`Skipping ${Ke}: already visited`);return}N.add(Bt),h.add(Bt);try{let tt=await this.dependencyAnalyzer.analyze(Ke);pe(),_se.debug(`Found ${tt.length} dependencies for ${Ke}`);for(let st of tt){pe(),h.add(st.path);let sr=`${Bt}->${st.path}`;T.has(sr)||(T.add(sr),m.push({source:Bt,target:st.path}),_se.debug(`Added edge: ${Bt} -> ${st.path}`)),st.module.startsWith("@")&&st.module.includes("/")&&!st.module.startsWith("@/")&&(z[st.path]=st.module),iEe(st.path)?_se.debug(`Skipping ${st.path}: in ignored directory`):await Te(st.path,ce+1)}}catch(tt){if(tt instanceof Error&&tt.name==="AbortError")throw tt;_se.debug(`Failed to analyze ${Ke}: ${tt}`)}};return await Te(o,0),_se.debug(`Crawl completed: ${h.size} nodes, ${m.length} edges`),{nodes:Array.from(h),edges:m,nodeLabels:Object.keys(z).length>0?z:void 0}}async crawlFrom(o,d,h=10,m){let T=new Set,N=[],z=new Set,ee={},pe=new Set(Array.from(d).map(Ln=>ri(Ln))),Te=ri(o),Ke=new Set,ce=[],Bt=new Set,tt={},st=m?.batchSize??200,sr=()=>{if(m?.signal?.aborted){let Ln=new Error("Expansion cancelled");throw Ln.name="AbortError",Ln}},ur=(Ln,vn)=>vn>h?!0:Ln===Te?vn!==0&&z.has(Ln):z.has(Ln),jr=Ln=>{pe.has(Ln)||(T.add(Ln),Ke.add(Ln))},Oi=(Ln,vn)=>{let Fi=`${vn}->${Ln.path}`;Bt.has(Fi)||(Bt.add(Fi),N.push({source:vn,target:Ln.path}),ce.push({source:vn,target:Ln.path})),!z.has(Ln.path)&&!pe.has(Ln.path)&&(T.add(Ln.path),Ke.add(Ln.path)),Ln.module.startsWith("@")&&Ln.module.includes("/")&&!Ln.module.startsWith("@/")&&(ee[Ln.path]=Ln.module,tt[Ln.path]=Ln.module)},Yi=async()=>{if(!m?.onBatch){Ke.clear(),ce.length=0;return}if(Ke.size===0&&ce.length===0)return;let Ln={nodes:Array.from(Ke),edges:[...ce],nodeLabels:Object.keys(tt).length>0?{...tt}:void 0};Ke.clear(),ce.length=0;for(let vn of Object.keys(tt))delete tt[vn];await m.onBatch(Ln)},Ci=async(Ln,vn)=>{sr();let Fi=ri(Ln);if(!ur(Fi,vn)){z.add(Fi),jr(Fi);try{let ii=await this.dependencyAnalyzer.analyze(Ln);for(let _i of ii)Oi(_i,Fi),iEe(_i.path)||await Ci(_i.path,vn+1);Ke.size+ce.length>=st&&await Yi()}catch{}}};return await Ci(o,0),await Yi(),{nodes:Array.from(T),edges:N,nodeLabels:Object.keys(ee).length>0?ee:void 0}}};var kke=class{cancelled=!1;reset(){this.cancelled=!1}cancel(){this.cancelled=!0}isCancelled(){return this.cancelled}};jC();GC();function Pke(){return new Promise(u=>setTimeout(u,1))}var Nke=50;var oEe=Uh("SpiderIndexingService"),wke=class{constructor(o,d,h,m,T,N,z,ee,pe,Te){this.dependencyAnalyzer=o;this.dependencyCache=d;this.reverseIndexManager=h;this.sourceFileCollector=m;this.indexerStatus=T;this.workerManager=N;this.cancellation=z;this.getConfig=ee;this.yieldToEventLoop=pe;this.getSymbolGraph=Te}dependencyAnalyzer;dependencyCache;reverseIndexManager;sourceFileCollector;indexerStatus;workerManager;cancellation;getConfig;yieldToEventLoop;getSymbolGraph;cancel(){this.cancellation.cancel(),this.workerManager.cancel()}async disposeWorker(){await this.workerManager.dispose()}async analyzeFileForIndex(o,d){try{if(await this.dependencyAnalyzer.analyze(o),this.getSymbolGraph&&d<(this.getConfig().maxSymbolAnalyzerFiles??100))try{let h=await this.getSymbolGraph(o);h.dependencies.length>0&&this.reverseIndexManager.addSymbolDependencies(o,h.dependencies)}catch{}return!0}catch{return!1}}checkCancellation(o){if(this.cancellation.isCancelled())return this.indexerStatus.setCancelled(),{indexedFiles:o,duration:Date.now()-(this.indexerStatus.getSnapshot().startTime??Date.now()),cancelled:!0}}async buildFullIndex(o){this.reverseIndexManager.ensure(),this.cancellation.reset(),this.indexerStatus.startCounting();let d=await this.sourceFileCollector.collectAllSourceFiles(this.getConfig().rootDir),h=this.checkCancellation(0);if(h)return h;let m=d.length;this.indexerStatus.setTotal(m),await this.yieldToEventLoop(),this.indexerStatus.startIndexing();let T=0,N=Date.now();try{for(let pe of d){let Te=this.checkCancellation(T);if(Te)return Te;await this.analyzeFileForIndex(pe,T),T++,this.indexerStatus.updateProgress(T,pe),o?.(T,m,pe),Date.now()-N>=Nke&&(await this.yieldToEventLoop(),N=Date.now())}this.indexerStatus.complete();let z=this.indexerStatus.getSnapshot(),ee=Date.now()-(z.startTime??Date.now());return{indexedFiles:T,duration:ee,cancelled:!1}}catch(z){let ee=pg.fromError(z);throw this.indexerStatus.setError(ee.toUserMessage()),oEe.error("Indexing failed:",ee.toUserMessage(),ee.code),ee}}async buildFullIndexInWorker(o,d){this.cancellation.reset();let h=this.getConfig();return this.workerManager.buildFullIndexInWorker({workerPath:o,progressCallback:d,config:{rootDir:h.rootDir,excludeNodeModules:h.excludeNodeModules,tsConfigPath:h.tsConfigPath,progressInterval:h.indexingProgressInterval,extensionPath:h.extensionPath,ignoreTypeImports:h.ignoreTypeImports}})}async reindexStaleFiles(o,d){if(!this.reverseIndexManager.isEnabled())return 0;this.cancellation.reset(),oEe.info(`Re-indexing ${o.length} stale files`),this.indexerStatus.startCounting(),this.indexerStatus.setTotal(o.length),this.indexerStatus.startIndexing();let h=this.getConfig().indexingConcurrency??8,m=0;for(let T=0;T<o.length;T+=h){if(this.cancellation.isCancelled())return this.indexerStatus.setCancelled(),m;let N=o.slice(T,T+h);await Promise.all(N.map(async z=>{let ee=ri(z);oEe.debug(`Re-indexing stale file: ${z}`);try{this.reverseIndexManager.removeDependenciesFromSource(ee),this.dependencyCache.delete(ee),oEe.debug(`Deleted cache for ${z}, re-analyzing...`),await this.dependencyAnalyzer.analyze(z),oEe.debug(`Successfully re-analyzed ${z}`)}catch(pe){oEe.error(`Failed to re-index ${z}:`,pe),this.reverseIndexManager.removeDependenciesFromSource(ee)}})),m+=N.length,this.indexerStatus.updateProgress(m,N.at(-1)),d?.(m,o.length,N.at(-1)),await this.yieldToEventLoop()}return this.cancellation.isCancelled()?(this.indexerStatus.setCancelled(),m):(this.indexerStatus.complete(),oEe.info(`Completed re-indexing ${m} files`),m)}};GC();var Rke=class{constructor(o,d,h,m=()=>!0,T=()=>!1){this.reverseIndexManager=o;this.dependencyAnalyzer=d;this.fileReader=h;this.isIndexReady=m;this.isIndexingActive=T}reverseIndexManager;dependencyAnalyzer;fileReader;isIndexReady;isIndexingActive;fallbackFinder=null;_fallbackCache=new Map;_fallbackCacheVersion=0;_fallbackCacheEntryVersion=new Map;setFallbackFinder(o){this.fallbackFinder=o}clearFallbackCache(){this._fallbackCacheVersion++}async findReferencingFiles(o){let d=ri(o),h=this.reverseIndexManager.hasEntries();if(h&&this.isIndexReady())return this.reverseIndexManager.getReferencingFiles(d);let m=h?this.reverseIndexManager.getReferencingFiles(d):[];if(h&&!this.isIndexingActive()||!this.fallbackFinder)return m;let T=await this.getFallbackReferencingFiles(d);return m.length===0?T:T.length===0?m:this.mergeDependencies(m,T)}async findReferencingFilesWithFallback(o){this.clearFallbackCache();let d=ri(o),h=this.reverseIndexManager.hasEntries()?this.reverseIndexManager.getReferencingFiles(d):[],m=await this.getFallbackReferencingFiles(d);return this.mergeDependencies(h,m)}async getFallbackReferencingFiles(o){if(!this.fallbackFinder)return[];if(this._fallbackCacheEntryVersion.get(o)===this._fallbackCacheVersion){let m=this._fallbackCache.get(o);if(m!==void 0)return m}let h=await this.fallbackFinder.findReferencingFilesFallback(o);return this._fallbackCache.set(o,h),this._fallbackCacheEntryVersion.set(o,this._fallbackCacheVersion),h}mergeDependencies(o,d){let h=new Map;for(let m of[...o,...d]){let T=ri(m.path);h.has(T)||h.set(T,m)}return[...h.values()]}async findReferenceInFile(o,d,h){try{if(!(await this.fileReader.readFile(o)).includes(h))return null;this.dependencyAnalyzer.invalidateDependencyCache(o);let N=(await this.dependencyAnalyzer.analyze(o)).find(z=>ri(z.path)===d);return N?{path:ri(o),type:N.type,line:N.line,module:N.module}:null}catch{return null}}};var oOt=cc(require("node:path"));UDe();jC();Yae();GC();var hse=Uh("SpiderSymbolService"),Mke=class{constructor(o,d,h,m,T,N,z,ee){this.astWorkerHost=o;this.symbolCache=d;this.fileReader=h;this.resolver=m;this.symbolDependencyHelper=T;this.getConfig=N;this.findReferencingFiles=z;this.languageService=ee}astWorkerHost;symbolCache;fileReader;resolver;symbolDependencyHelper;getConfig;findReferencingFiles;languageService;async getSymbolGraph(o){if(!oOt.default.isAbsolute(o))try{let m=await this.resolveModuleSpecifier(this.getConfig().rootDir,o);m&&(o=m)}catch{}let d=ri(o),h=this.symbolCache.get(d);if(h)return h;try{let m=await this.fileReader.readFile(o),T=await this.astWorkerHost.analyzeFile(d,m),N=await Promise.all(T.dependencies.map(async ee=>{try{let Te=await this.languageService.getAnalyzer(d).resolvePath(d,ee.targetFilePath);if(Te)return{...ee,targetFilePath:ri(Te)}}catch{}return ee})),z={symbols:T.symbols,dependencies:N};return this.symbolCache.set(d,z),z}catch(m){let T=pg.fromError(m,o);if(hse.error("Symbol analysis failed:",T.toUserMessage()),T.isRecoverable())return{symbols:[],dependencies:[]};throw T}}async findUnusedSymbols(o){try{let d=ri(o),{symbols:h}=await this.getSymbolGraph(d),m=h.filter(Te=>Te.isExported);if(m.length===0)return[];let T=await this.findReferencingFiles(d),N=await this.collectUsedSymbolIds(T,d),z=await this.fileReader.readFile(d),ee=await this.astWorkerHost.getInternalExportDependencyGraph(d,z),pe=this.expandUsedSymbolsViaInternalGraph(N,ee);return m.filter(Te=>!pe.has(Te.id))}catch(d){let h=pg.fromError(d,o);return hse.error("Find unused symbols failed:",h.toUserMessage()),[]}}async getSymbolDependents(o,d){let h=await this.findReferencingFiles(o);return this.collectSymbolDependents(h,o,d)}async traceFunctionExecution(o,d,h=10){let m=`${o}:${d}`,T=[],N=new Set,z=!1,ee=async(pe,Te,Ke)=>{if(Ke>h){z=!0;return}let ce=`${pe}:${Te}`;if(!N.has(ce)){N.add(ce);try{let{symbols:Bt,dependencies:tt}=await this.getSymbolGraph(pe),st=Bt.find(ur=>ur.name===Te);if(!st)return;let sr=tt.filter(ur=>ur.sourceSymbolId===st.id);for(let ur of sr){let jr=null;try{jr=await this.resolver.resolve(pe,ur.targetFilePath)}catch{}let Oi=ur.targetSymbolId.split(":").pop()||"";T.push({depth:Ke,callerSymbolId:ce,calledSymbolId:ur.targetSymbolId,calledFilePath:ur.targetFilePath,resolvedFilePath:jr}),jr&&!iEe(jr)&&await ee(jr,Oi,Ke+1)}}catch(Bt){let tt=pg.fromError(Bt,pe);hse.error("Trace execution failed:",ce,tt.toUserMessage())}}};return await ee(o,d,1),{rootSymbol:{id:m,filePath:o,symbolName:d},callChain:T,visitedSymbols:Array.from(N),maxDepthReached:z}}async resolveModuleSpecifier(o,d){try{return await this.resolver.resolve(o,d)}catch{return null}}expandUsedSymbolsViaInternalGraph(o,d){let h=new Set(o),m=Array.from(h);for(;m.length>0;){let T=m.pop();if(T===void 0)continue;let N=d.get(T);if(N)for(let z of N)h.has(z)||(h.add(z),m.push(z))}return h}async collectUsedSymbolIds(o,d){let h=new Set;for(let m of o){let{dependencies:T}=await this.getSymbolGraph(m.path);for(let N of T)if(await this.symbolDependencyHelper.doesDependencyTargetFile(N,m.path,d)){let ee=this.symbolDependencyHelper.extractSymbolName(N.targetSymbolId);h.add(this.symbolDependencyHelper.buildUsedSymbolId(d,ee))}}return h}async collectSymbolDependents(o,d,h){let m=[],T=ri(d);for(let N of o){let{dependencies:z}=await this.getSymbolGraph(N.path);for(let ee of z)await this.symbolDependencyHelper.doesDependencyTargetFile(ee,N.path,T)&&this.symbolDependencyHelper.extractSymbolName(ee.targetSymbolId)===h&&m.push(ee)}return m}async verifyDependencyUsage(o,d){try{let h=ri(o),m=ri(d);if(iEe(m))return!0;if(this.isAstUnsupportedFile(h))return hse.debug(`Skipping symbol analysis for unsupported file type: ${h}`),!0;let{dependencies:T}=await this.getSymbolGraph(h);if(T.length===0)return!1;let N=m.split("/").pop()||"",z=T.filter(ee=>ee.targetFilePath===m||ee.targetFilePath.includes(N)||!ee.targetFilePath.startsWith("/"));for(let ee of z)if(await this.symbolDependencyHelper.doesDependencyTargetFile(ee,h,m))return!0;return!1}catch(h){let m=pg.fromError(h,o);return hse.warn("Usage verification failed, assuming used:",m.message),!0}}async verifyDependencyUsageBatch(o,d){try{let h=ri(o);if(this.isAstUnsupportedFile(h))return hse.debug(`Skipping symbol analysis for unsupported file type: ${h}`),this.markAllAsUsed(d);let{dependencies:m}=await this.getSymbolGraph(h);if(m.length===0)return this.markAllAsUnused(d);let T=await this.buildResolvedTargetsSet(m,h);return this.checkTargetsAgainstResolved(d,T)}catch(h){let m=pg.fromError(h,o);return hse.warn("Batch usage verification failed, assuming all used:",m.message),this.markAllAsUsed(d)}}markAllAsUsed(o){let d=new Map;for(let h of o)d.set(ri(h),!0);return d}markAllAsUnused(o){let d=new Map;for(let h of o)d.set(ri(h),!1);return d}async buildResolvedTargetsSet(o,d){let h=new Set;for(let m of o)try{let T=await this.symbolDependencyHelper.resolveTargetPath(m,d);T&&h.add(ri(T))}catch{}return h}checkTargetsAgainstResolved(o,d){let h=new Map;for(let m of o){let T=ri(m);if(iEe(T)){h.set(T,!0);continue}h.set(T,d.has(T))}return h}isAstUnsupportedFile(o){return o.endsWith(".gql")||o.endsWith(".graphql")||o.endsWith(".cs")||o.endsWith(".csproj")||o.endsWith(".go")||o.endsWith(".java")}async scanDeadCode(o,d){let{maxFiles:h=500,hasReverseIndex:m}=d;if(!m)throw new pg("Dead code scan requires the reverse index. Wait for indexing to complete or call rebuild_index first.","INDEX_NOT_READY");let T=this.getConfig(),z=await new TR({excludeNodeModules:T.excludeNodeModules??!0}).collectAllSourceFiles(o),ee=new Set(fUe),Te=z.filter(Bt=>{let tt=oOt.default.extname(Bt).toLowerCase();return ee.has(tt)}).slice(0,h),Ke=[],ce=0;for(let Bt of Te)try{let tt=await this.findUnusedSymbols(Bt);tt.length>0&&Ke.push({filePath:Bt,unusedSymbols:tt})}catch(tt){let st=pg.fromError(tt,Bt);hse.warn("scanDeadCode: skipping file due to error:",Bt,st.message),ce++}return{entries:Ke,scannedFiles:Te.length,skippedFiles:ce}}};var YUt=require("node:worker_threads"),QUt=cc(require("node:path")),gst=class{worker=null;statusCallbacks=new Set;currentState="idle";currentProgress=0;currentTotal=0;currentFile="";startTime=void 0;cancelled=!1;stopActiveRequest=null;workerTermination=null;workerPath;constructor(o){this.workerPath=o??QUt.join(__dirname,"indexerWorker.js")}subscribeToStatus(o){return this.statusCallbacks.add(o),o(this.getSnapshot()),()=>this.statusCallbacks.delete(o)}getSnapshot(){let o=this.currentTotal>0?Math.round(this.currentProgress/this.currentTotal*100):0;return{state:this.currentState,processed:this.currentProgress,total:this.currentTotal,currentFile:this.currentFile,percentage:o,startTime:this.startTime,cancelled:this.cancelled}}notifySubscribers(){let o=this.getSnapshot();for(let d of this.statusCallbacks)try{d(o)}catch{}}updateState(o,d=0,h=0,m=""){this.currentState=o,this.currentProgress=d,this.currentTotal=h,this.currentFile=m,this.notifySubscribers()}getPendingCount(){return this.worker||this.workerTermination?1:0}async startIndexing(o){if(this.worker||this.workerTermination)throw new Error("Indexing already in progress");this.cancelled=!1,this.startTime=Date.now(),this.updateState("counting");let d=o.timeoutMs??600*1e3;return new Promise((h,m)=>{let T=!1,N=pe=>{T||(T=!0,clearTimeout(ee),this.stopActiveRequest=null,h(pe))},z=pe=>{T||(T=!0,clearTimeout(ee),this.stopActiveRequest=null,m(pe))},ee=setTimeout(()=>{this.cancel(),this.updateState("error"),this.cleanupWorker().then(()=>{z(new Error(`Indexing timed out after ${Math.round(d/6e4)} minute(s)`))})},d);this.stopActiveRequest=()=>{this.cancelled=!0,this.updateState("complete",this.currentProgress,this.currentTotal),N({indexedFiles:this.currentProgress,duration:Date.now()-(this.startTime??Date.now()),cancelled:!0,data:[]})};try{this.worker=new YUt.Worker(this.workerPath,{workerData:o});let pe={indexedFiles:0,duration:0,cancelled:!1,data:[]};this.worker.on("message",Te=>{switch(Te.type){case"counting":this.updateState("counting");break;case"progress":Te.data&&this.updateState("indexing",Te.data.processed??0,Te.data.total??0,Te.data.currentFile??"");break;case"complete":Te.data&&(pe={indexedFiles:Te.data.processed??0,duration:Te.data.duration??0,cancelled:this.cancelled,data:Te.data.indexData??[]}),this.updateState("complete"),this.cleanupWorker().then(()=>N(pe));break;case"error":this.updateState("error"),this.cleanupWorker().then(()=>z(new Error(Te.error??"Unknown worker error")));break}}),this.worker.on("error",Te=>{this.updateState("error"),this.cleanupWorker().then(()=>z(Te))}),this.worker.on("exit",Te=>{Te!==0&&this.currentState!=="complete"&&this.currentState!=="error"&&(this.updateState("error"),this.cleanupWorker().then(()=>z(new Error(`Worker stopped with exit code ${Te}`))))}),this.worker.postMessage({type:"start"})}catch(pe){this.updateState("error"),this.cleanupWorker().then(()=>z(pe))}})}cancel(){if(this.cancelled=!0,this.worker)try{this.worker.postMessage({type:"cancel"})}catch{}}isIndexing(){return this.currentState==="indexing"||this.currentState==="counting"}cleanupWorker(){if(this.worker){let o=this.worker;this.worker=null,o.removeAllListeners(),o.on("error",()=>{});let d=o.terminate().then(()=>{},()=>{}).then(()=>{this.workerTermination===d&&(this.workerTermination=null)});return this.workerTermination=d,d}return this.workerTermination??Promise.resolve()}async dispose(){this.cancel(),this.stopActiveRequest?.(),await this.cleanupWorker(),this.statusCallbacks.clear()}};GC();var Lke=class{constructor(o,d,h){this.indexerStatus=o;this.reverseIndexManager=d;this.dependencyCache=h}indexerStatus;reverseIndexManager;dependencyCache;workerHost=null;async buildFullIndexInWorker(o){let{workerPath:d,config:h,progressCallback:m}=o;this.workerHost??=new gst(d),this.reverseIndexManager.ensure();let T=this.workerHost.subscribeToStatus(N=>{switch(N.state){case"counting":this.indexerStatus.startCounting();break;case"indexing":N.total>0&&(this.indexerStatus.setTotal(N.total),this.indexerStatus.startIndexing()),this.indexerStatus.updateProgress(N.processed,N.currentFile);break;case"complete":this.indexerStatus.complete();break;case"error":this.indexerStatus.setError(N.errorMessage??"Unknown error");break}m&&N.state==="indexing"&&m(N.processed,N.total,N.currentFile)});try{let N=await this.workerHost.startIndexing({rootDir:h.rootDir,excludeNodeModules:h.excludeNodeModules,tsConfigPath:h.tsConfigPath,extensionPath:h.extensionPath,ignoreTypeImports:h.ignoreTypeImports});return this.importWorkerResult(N),{indexedFiles:N.indexedFiles,duration:N.duration,cancelled:N.cancelled}}finally{T()}}cancel(){this.workerHost?.cancel()}async dispose(){let o=this.workerHost;this.workerHost=null,await o?.dispose()}importWorkerResult(o){for(let d of o.data){let h=ri(d.filePath);this.dependencyCache.set(h,d.dependencies),this.reverseIndexManager.addDependencies(h,d.dependencies,{mtime:d.mtime,size:d.size})}}};GC();jC();var Oke=Uh("SymbolDependencyHelper"),Fke=class{resolveFn;constructor(o){this.resolveFn=o.resolve}async doesDependencyTargetFile(o,d,h){let m=ri(o.targetFilePath),T=ri(h);if(Oke.debug(`Comparing: dep.targetFilePath='${m}' vs targetFilePath='${T}'`),m===T)return Oke.debug("\u2713 Direct match"),!0;Oke.debug(`Attempting fallback resolution for '${o.targetFilePath}' from '${d}'`);let N=await this.resolveFn(d,o.targetFilePath);if(N){let z=ri(N);Oke.debug(`Resolved to: '${z}'`);let ee=z===T;return Oke.debug(ee?"\u2713 Fallback match":"\u2717 No match after resolution"),ee}return Oke.debug("\u2717 Resolution failed, no match"),!1}extractSymbolName(o){return o.split(":").pop()||""}extractBasename(o){return o.split(/[/\\]/).pop()?.replace(/\.[^/.]+$/,"")}buildUsedSymbolId(o,d){return`${ri(o)}:${d}`}async resolveTargetPath(o,d){let h=ri(o.targetFilePath);if(h.startsWith("/")||/^[a-zA-Z]:\//.test(h))return h;try{let m=await this.resolveFn(d,o.targetFilePath);return m?ri(m):null}catch{return null}}};Im();var yst=class{activeIndexingOperations=new Set;disposed=!1;disposePromise=null;workerShutdownPromise=null;config;languageService;resolver;cache;symbolCache;fileReader;astWorkerHost;reverseIndexManager;indexerStatus;workerManager;cancellation;sourceFileCollector;referencingFilesFinder;symbolDependencyHelper;dependencyAnalyzer;referenceLookup;symbolService;graphCrawler;indexingService;cacheCoordinator;constructor(o){if("dependencyAnalyzer"in o){let d=o;this.config=d.config,this.languageService=d.languageService,this.resolver=d.resolver,this.cache=d.cache,this.symbolCache=d.symbolCache,this.fileReader=d.fileReader,this.astWorkerHost=d.astWorkerHost,this.reverseIndexManager=d.reverseIndexManager,this.indexerStatus=d.indexerStatus,this.workerManager=d.workerManager,this.cancellation=d.cancellation,this.sourceFileCollector=d.sourceFileCollector,this.referencingFilesFinder=d.referencingFilesFinder,this.symbolDependencyHelper=d.symbolDependencyHelper,this.dependencyAnalyzer=d.dependencyAnalyzer,this.referenceLookup=d.referenceLookup,this.symbolService=d.symbolService,this.graphCrawler=d.graphCrawler,this.indexingService=d.indexingService,this.cacheCoordinator=d.cacheCoordinator}else{let d=o;this.config={maxDepth:50,excludeNodeModules:!0,enableReverseIndex:!1,indexingConcurrency:4,maxCacheSize:500,maxSymbolCacheSize:200,maxSymbolAnalyzerFiles:100,...d},this.languageService=new Ske(d.rootDir,d.tsConfigPath,d.extensionPath),this.resolver=new oJ(d.tsConfigPath,this.config.excludeNodeModules,d.rootDir),this.cache=new Qae({maxSize:this.config.maxCacheSize,enableLRU:!0}),this.symbolCache=new Qae({maxSize:this.config.maxSymbolCacheSize,enableLRU:!0}),this.astWorkerHost=new qae(void 0,d.extensionPath),this.reverseIndexManager=new Cke(this.config.rootDir),this.fileReader=new W1,this.indexerStatus=new KDe,this.cancellation=new kke,this.workerManager=new Lke(this.indexerStatus,this.reverseIndexManager,this.cache),this.dependencyAnalyzer=new Ike(this.languageService,this.resolver,this.cache,this.reverseIndexManager),this.sourceFileCollector=new TR({excludeNodeModules:this.config.excludeNodeModules??!0,yieldIntervalMs:Nke,yieldCallback:()=>Pke(),isCancelled:()=>this.cancellation.isCancelled()}),this.referenceLookup=new Rke(this.reverseIndexManager,this.dependencyAnalyzer,this.fileReader,()=>this.indexerStatus.isReady(),()=>this.indexerStatus.isActive()),this.referencingFilesFinder=new Tke({sourceFileCollector:this.sourceFileCollector,getRootDir:()=>this.config.rootDir,getConcurrency:()=>this.config.indexingConcurrency,findReferenceInFile:(h,m,T)=>this.referenceLookup.findReferenceInFile(h,m,T)}),this.referenceLookup.setFallbackFinder(this.referencingFilesFinder),this.symbolDependencyHelper=new Fke({resolve:async(h,m)=>{try{return await this.resolver.resolve(h,m)}catch{return null}}}),this.symbolService=new Mke(this.astWorkerHost,this.symbolCache,this.fileReader,this.resolver,this.symbolDependencyHelper,()=>this.config,h=>this.findReferencingFiles(h),this.languageService),this.graphCrawler=new Dke(this.dependencyAnalyzer,()=>this.config),this.indexingService=new wke(this.dependencyAnalyzer,this.cache,this.reverseIndexManager,this.sourceFileCollector,this.indexerStatus,this.workerManager,this.cancellation,()=>this.config,()=>Pke(),h=>this.symbolService.getSymbolGraph(h)),this.cacheCoordinator=new Ake(this.cache,this.symbolCache,this.reverseIndexManager),d.enableReverseIndex&&this.enableReverseIndex()}}get workspaceRoot(){return this.config.rootDir}dispose(){return this.disposed=!0,this.disposePromise??=this.disposeResources(),this.disposePromise}async disposeResources(){let o;try{await this.beginShutdown()}catch(d){o=d}for(;this.activeIndexingOperations.size>0;)await Promise.allSettled([...this.activeIndexingOperations]);if(o!==void 0)throw o}beginShutdown(){return this.disposed=!0,this.cancelIndexing(),this.workerShutdownPromise??=this.stopWorkers(),this.workerShutdownPromise}async stopWorkers(){let d=(await Promise.allSettled([this.disposeWorker(),this.astWorkerHost.stop()])).find(h=>h.status==="rejected");if(d)throw d.reason}updateConfig(o){this.config.excludeNodeModules=o.excludeNodeModules??this.config.excludeNodeModules,this.config.maxDepth=o.maxDepth??this.config.maxDepth,o.excludeNodeModules!==void 0&&(this.resolver.updateConfig(o.excludeNodeModules),this.sourceFileCollector.updateOptions({excludeNodeModules:o.excludeNodeModules})),o.enableReverseIndex!==void 0&&(this.config.enableReverseIndex=o.enableReverseIndex,o.enableReverseIndex?this.reverseIndexManager.enable():this.reverseIndexManager.disable()),o.indexingConcurrency!==void 0&&(this.config.indexingConcurrency=o.indexingConcurrency),this.clearCache()}async analyze(o){return this.dependencyAnalyzer.analyze(o)}clearCache(){this.cacheCoordinator.clearAll(),this.referenceLookup.clearFallbackCache()}invalidateFile(o){return this.referenceLookup.clearFallbackCache(),this.cacheCoordinator.invalidateFile(o)}invalidateFiles(o){return this.referenceLookup.clearFallbackCache(),this.cacheCoordinator.invalidateFiles(o)}async reanalyzeFile(o){this.invalidateFile(o);try{return await this.analyze(o)}catch{return null}}handleFileDeleted(o){this.referenceLookup.clearFallbackCache(),this.cacheCoordinator.handleFileDeleted(o)}enableReverseIndex(o){let d=this.reverseIndexManager.enable(o);return this.config.enableReverseIndex=!0,d}disableReverseIndex(){this.config.enableReverseIndex=!1,this.reverseIndexManager.disable()}getSerializedReverseIndex(){return this.reverseIndexManager.getSerialized()}async validateReverseIndex(o=.2,d,h){return this.reverseIndexManager.validate(o,d,h)}getIndexStatus(){return this.indexerStatus.getSnapshot()}subscribeToIndexStatus(o){return this.indexerStatus.subscribe(o)}isReverseIndexEnabled(){return this.reverseIndexManager.isEnabled()}hasReverseIndex(){return this.reverseIndexManager.hasEntries()}getCallerCount(o){return this.reverseIndexManager.hasEntries()?this.reverseIndexManager.getCallerCount(o):0}cancelIndexing(){this.indexingService.cancel()}async buildFullIndex(o){return this.disposed?{indexedFiles:0,duration:0,cancelled:!0}:this.trackIndexingOperation(this.indexingService.buildFullIndex(o))}async buildFullIndexInWorker(o,d){return this.disposed?{indexedFiles:0,duration:0,cancelled:!0}:this.trackIndexingOperation(this.indexingService.buildFullIndexInWorker(o,d))}async disposeWorker(){await this.indexingService.disposeWorker()}async reindexStaleFiles(o,d){return this.disposed?0:this.trackIndexingOperation(this.indexingService.reindexStaleFiles(o,d))}trackIndexingOperation(o){return this.activeIndexingOperations.add(o),o.finally(()=>this.activeIndexingOperations.delete(o)).catch(()=>{}),o}async crawl(o,d){return this.graphCrawler.crawl(o,d)}async getReadOnlyDependencyGraph(o){let d=ri(o),h=new Set([d]),m=[],T={};try{let N=this.languageService.getAnalyzer(o),z=await N.parseImports(o),ee=new Set;for(let pe of z){let Te=await N.resolvePath(o,pe.module);if(!Te||!this.resolver.isWithinWorkspace(Te))continue;let Ke=ri(Te);ee.has(Ke)||(ee.add(Ke),h.add(Ke),m.push({source:d,target:Ke,...pe.line>0?{sourceLine:pe.line}:{}}),pe.module.startsWith("@")&&pe.module.includes("/")&&!pe.module.startsWith("@/")&&(T[Ke]=pe.module))}}catch{}return{nodes:[...h],edges:m,nodeLabels:Object.keys(T).length>0?T:void 0}}async crawlFrom(o,d,h=10,m){return this.graphCrawler.crawlFrom(o,d,h,m)}async findReferencingFiles(o){return this.referenceLookup.findReferencingFiles(o)}async findReferencingFilesWithFallback(o){return this.referenceLookup.findReferencingFilesWithFallback(o)}getSymbolReferencingFiles(o){if(!this.reverseIndexManager.hasEntries())return new Set;let d=this.reverseIndexManager.getSymbolReferencingFiles(o);return new Set(d)}async getSymbolGraph(o){return this.symbolService.getSymbolGraph(o)}async resolveModuleSpecifier(o,d){return this.dependencyAnalyzer.resolveModuleSpecifier(o,d)}async findUnusedSymbols(o){return this.symbolService.findUnusedSymbols(o)}async scanDeadCode(o,d){let h=o??this.config.rootDir;return this.symbolService.scanDeadCode(h,{maxFiles:d?.maxFiles,hasReverseIndex:this.hasReverseIndex()})}async verifyDependencyUsage(o,d){return this.symbolService.verifyDependencyUsage(o,d)}async verifyDependencyUsageBatch(o,d){return this.symbolService.verifyDependencyUsageBatch(o,d)}async getSymbolDependents(o,d){return this.symbolService.getSymbolDependents(o,d)}async traceFunctionExecution(o,d,h=10){return this.symbolService.traceFunctionExecution(o,d,h)}getCacheStats(){return{dependencyCache:this.cache.getStats(),symbolCache:this.symbolCache.getStats(),symbolAnalyzerFileCount:0,reverseIndexStats:this.reverseIndexManager.getStats()}}async getCacheStatsAsync(){let o=0;try{o=await this.astWorkerHost.getFileCount()}catch{}return{dependencyCache:this.cache.getStats(),symbolCache:this.symbolCache.getStats(),symbolAnalyzerFileCount:o,reverseIndexStats:this.reverseIndexManager.getStats()}}};var vst=class{rootDir;tsConfigPath;extensionPath;maxDepth=50;excludeNodeModules=!0;enableReverseIndex=!1;indexingConcurrency=4;maxCacheSize=500;maxSymbolCacheSize=200;maxSymbolAnalyzerFiles=100;indexingProgressInterval;ignoreTypeImports=!1;customCache;customSymbolCache;customLanguageService;customPathResolver;customAstWorkerHost;customReverseIndexManager;withRootDir(o){return this.rootDir=o,this}withTsConfigPath(o){return this.tsConfigPath=o,this}withExtensionPath(o){return this.extensionPath=o,this}withMaxDepth(o){return this.maxDepth=o,this}withExcludeNodeModules(o){return this.excludeNodeModules=o,this}withIgnoreTypeImports(o){return this.ignoreTypeImports=o,this}withReverseIndex(o){return this.enableReverseIndex=o,this}withIndexingConcurrency(o){return this.indexingConcurrency=o,this}withCacheConfig(o){return o.maxCacheSize!==void 0&&(this.maxCacheSize=o.maxCacheSize),o.maxSymbolCacheSize!==void 0&&(this.maxSymbolCacheSize=o.maxSymbolCacheSize),o.maxSymbolAnalyzerFiles!==void 0&&(this.maxSymbolAnalyzerFiles=o.maxSymbolAnalyzerFiles),this}withIndexingProgressInterval(o){return this.indexingProgressInterval=o,this}withConfig(o){return this.rootDir=o.rootDir,o.tsConfigPath!==void 0&&(this.tsConfigPath=o.tsConfigPath),o.extensionPath!==void 0&&(this.extensionPath=o.extensionPath),o.maxDepth!==void 0&&(this.maxDepth=o.maxDepth),o.excludeNodeModules!==void 0&&(this.excludeNodeModules=o.excludeNodeModules),o.ignoreTypeImports!==void 0&&(this.ignoreTypeImports=o.ignoreTypeImports),o.enableReverseIndex!==void 0&&(this.enableReverseIndex=o.enableReverseIndex),o.indexingConcurrency!==void 0&&(this.indexingConcurrency=o.indexingConcurrency),o.maxCacheSize!==void 0&&(this.maxCacheSize=o.maxCacheSize),o.maxSymbolCacheSize!==void 0&&(this.maxSymbolCacheSize=o.maxSymbolCacheSize),o.maxSymbolAnalyzerFiles!==void 0&&(this.maxSymbolAnalyzerFiles=o.maxSymbolAnalyzerFiles),o.indexingProgressInterval!==void 0&&(this.indexingProgressInterval=o.indexingProgressInterval),this}withCache(o){return this.customCache=o,this}withSymbolCache(o){return this.customSymbolCache=o,this}withLanguageService(o){return this.customLanguageService=o,this}withPathResolver(o){return this.customPathResolver=o,this}withAstWorkerHost(o){return this.customAstWorkerHost=o,this}withReverseIndexManager(o){return this.customReverseIndexManager=o,this}build(){this.validate();let o=this.initializeServices();return new yst(o)}initializeServices(){let o=this.buildConfig(),d=this.customLanguageService??new Ske(this.rootDir,this.tsConfigPath,this.extensionPath,this.ignoreTypeImports),h=this.customPathResolver??new oJ(this.tsConfigPath,this.excludeNodeModules,this.rootDir),m=this.customCache??new Qae({maxSize:this.maxCacheSize,enableLRU:!0}),T=this.customSymbolCache??new Qae({maxSize:this.maxSymbolCacheSize,enableLRU:!0}),N=this.customAstWorkerHost??new qae(void 0,this.extensionPath),z=this.customReverseIndexManager??new Cke(this.rootDir),ee=new W1,pe=new KDe,Te=new kke,Ke=new Lke(pe,z,m),ce=new Ike(d,h,m,z),Bt=new TR({excludeNodeModules:this.excludeNodeModules,yieldIntervalMs:Nke,yieldCallback:()=>Pke(),isCancelled:()=>Te.isCancelled()}),tt=new Rke(z,ce,ee,()=>pe.isReady(),()=>pe.isActive()),st=new Tke({sourceFileCollector:Bt,getRootDir:()=>this.rootDir,getConcurrency:()=>this.indexingConcurrency,findReferenceInFile:(Ci,Ln,vn)=>tt.findReferenceInFile(Ci,Ln,vn)});tt.setFallbackFinder(st);let sr=new Fke({resolve:async(Ci,Ln)=>{try{return await h.resolve(Ci,Ln)}catch{return null}}}),ur=new Mke(N,T,ee,h,sr,()=>o,Ci=>tt.findReferencingFiles(Ci),d),jr=new Dke(ce,()=>o),Oi=new wke(ce,m,z,Bt,pe,Ke,Te,()=>o,()=>Pke(),Ci=>ur.getSymbolGraph(Ci)),Yi=new Ake(m,T,z);return this.enableReverseIndex&&z.enable(),{config:o,languageService:d,resolver:h,cache:m,symbolCache:T,fileReader:ee,astWorkerHost:N,reverseIndexManager:z,indexerStatus:pe,workerManager:Ke,cancellation:Te,sourceFileCollector:Bt,referencingFilesFinder:st,symbolDependencyHelper:sr,dependencyAnalyzer:ce,referenceLookup:tt,symbolService:ur,graphCrawler:jr,indexingService:Oi,cacheCoordinator:Yi}}validate(){if(!this.rootDir)throw new Error("rootDir is required");if(this.maxDepth<0)throw new Error("maxDepth must be non-negative");if(this.indexingConcurrency<1)throw new Error("indexingConcurrency must be at least 1");if(this.maxCacheSize<0)throw new Error("maxCacheSize must be non-negative");if(this.maxSymbolCacheSize<0)throw new Error("maxSymbolCacheSize must be non-negative");if(this.maxSymbolAnalyzerFiles<0)throw new Error("maxSymbolAnalyzerFiles must be non-negative")}buildConfig(){return{rootDir:this.rootDir,tsConfigPath:this.tsConfigPath,extensionPath:this.extensionPath,maxDepth:this.maxDepth,excludeNodeModules:this.excludeNodeModules,ignoreTypeImports:this.ignoreTypeImports,enableReverseIndex:this.enableReverseIndex,indexingConcurrency:this.indexingConcurrency,maxCacheSize:this.maxCacheSize,maxSymbolCacheSize:this.maxSymbolCacheSize,maxSymbolAnalyzerFiles:this.maxSymbolAnalyzerFiles,indexingProgressInterval:this.indexingProgressInterval}}};gN();Im();jC();_2();var sOt=class{constructor(o,d="info",h=[]){this.source=o;this.entries=h;this.level=d}source;entries;level;setLevel(o){this.level=o}debug(o){this.record("debug",o)}info(o){this.record("info",o)}warn(o){this.record("warn",o)}error(o){this.record("error",o)}record(o,d){this.entries.length>=1e3&&this.entries.shift(),this.entries.push({level:o,source:this.source,message:d,timestamp:Date.now()})}getEntries(){return[...this.entries]}clear(){this.entries.length=0}},bst=class{sharedEntries=[];createLogger(o,d){return new sOt(o,d??"info",this.sharedEntries)}getCollectedEntries(){return[...this.sharedEntries]}clear(){this.sharedEntries.length=0}getErrorCount(){let o=0,d=0;for(let h of this.sharedEntries)h.level==="error"?o+=1:h.level==="warn"&&(d+=1);return{errors:o,warnings:d,total:this.sharedEntries.length}}};var ZUt=require("node:crypto"),JUe=cc(require("node:fs")),Kne=cc(require("node:path"));Im();Bne();function eHt(u,o){try{let d=lpn(u,o);if(!d)return;let h=upn(u,d);return h?(0,ZUt.createHash)("sha256").update(JSON.stringify([...h].sort(([m],[T])=>m.localeCompare(T)))).digest("hex"):void 0}catch{return}}function lpn(u,o){let d=new Set([ri(u)]);for(let h of o){let m=ri(Kne.dirname(h));for(;!d.has(m);){if(!ZF(m,u))return;d.add(m),m=ri(Kne.dirname(m))}}return d}function upn(u,o){let d=[...o].flatMap(T=>[Kne.join(T,"tsconfig.json"),Kne.join(T,"package.json")]),h=new Set,m=new Map;for(let T=d.shift();T;T=d.shift()){let N=ri(T);if(h.has(N))continue;h.add(N);let z=dpn(T,u);if(z===void 0)continue;m.set(N,z);let ee=ppn(T,z,u);if(ee===void 0)return;ee&&d.push(ee)}return m}function dpn(u,o){if(!(!ZF(u,o)||!JUe.existsSync(u)))return JUe.readFileSync(u,"utf-8")}function ppn(u,o,d){let h;try{h=JSON.parse(o)}catch{return null}if(typeof h?.extends!="string")return null;let m=Kne.resolve(Kne.dirname(u),h.extends);if(!ZF(m,d))return;let T=m.endsWith(".json")?m:`${m}.json`;return JUe.existsSync(T)?T:m}Stt({createLogger(u,o){return new pUe(u,o)}});Kae.setDefaultLevel(t9t("LOG_LEVEL"));var aEe=Uh("CliRuntime"),tHt="1.16.1",nHt=1,fpn=.2,rHt="meta.json",iHt="reverse-index.json",oHt="callgraph.db";function cOt(u,o){let d=xT.dirname(u),h=xT.join(d,`.${xT.basename(u)}.${process.pid}.tmp`);pP.writeFileSync(h,o),pP.renameSync(h,u)}function lOt(u){let o=xT.resolve(u),{root:d}=xT.parse(o);for(;o!==d;){if(pP.existsSync(xT.join(o,"package.json"))||pP.existsSync(xT.join(o,"tsconfig.json")))return o;o=xT.dirname(o)}return xT.resolve(u)}function mpn(u){let o=xT.join(u,"tsconfig.json");return pP.existsSync(o)?o:void 0}var Sst=class{workspaceRoot;stateDir;cacheDir;cacheEnabled;_initialized=!1;_indexReady=!1;_reverseIndexRestored=!1;_sourceFiles=null;_configFingerprint;errorCollectorBackend=null;constructor(o,d){this.workspaceRoot=xT.resolve(o),this.stateDir=xT.join(this.workspaceRoot,".graph-it"),this.cacheDir=xT.join(this.stateDir,"cache"),this.cacheEnabled=(d?.cache??!0)&&!process.env.GRAPH_IT_NO_CACHE}clearCache(){pP.rmSync(this.cacheDir,{recursive:!0,force:!0})}get initialized(){return this._initialized}enableErrorCollection(){this.errorCollectorBackend||(this.errorCollectorBackend=new bst,Stt(this.errorCollectorBackend))}disableErrorCollection(){if(!this.errorCollectorBackend)return[];let o=this.errorCollectorBackend.getCollectedEntries();return Stt({createLogger(d,h){return new pUe(d,h)}}),this.errorCollectorBackend=null,o}getCollectedErrors(){return this.errorCollectorBackend?.getCollectedEntries()??[]}clearCollectedErrors(){this.errorCollectorBackend?.clear()}async init(){if(this._initialized)return;pP.mkdirSync(this.stateDir,{recursive:!0});let o=mpn(this.workspaceRoot);Cc.parser=new $De,Cc.resolver=new oJ(o,!0,this.workspaceRoot);let d=xT.resolve(__dirname,"..");Cc.astWorkerHost=new qae(void 0,d),await Cc.astWorkerHost.start();let h=new vst().withRootDir(this.workspaceRoot).withMaxDepth(50).withExcludeNodeModules(!0).withReverseIndex(!0).withExtensionPath(d);o&&h.withTsConfigPath(o),Cc.spider=h.build(),this.cacheEnabled&&(this._configFingerprint=eHt(this.workspaceRoot,await this.collectSourceFiles())),Cc.config={rootDir:this.workspaceRoot,tsConfigPath:o,excludeNodeModules:!0,maxDepth:50,extensionPath:d,cacheDir:this.cacheEnabled&&this.isCacheMetaValid()?this.cacheDir:void 0},Cc.isReady=!0,this._initialized=!0,this.cacheEnabled&&(this._reverseIndexRestored=this.tryRestoreReverseIndex()),aEe.info("Runtime initialized for",this.workspaceRoot)}tryRestoreReverseIndex(){if(!this.isCacheMetaValid())return!1;try{let o=pP.readFileSync(xT.join(this.cacheDir,iHt),"utf-8"),d=Cc.spider?.enableReverseIndex(o)??!1;return d&&aEe.info("Restored reverse index from cache"),d}catch{return!1}}isCacheMetaValid(){try{let o=pP.readFileSync(xT.join(this.cacheDir,rHt),"utf-8"),d=JSON.parse(o);return d.schema===nHt&&d.cliVersion===tHt&&this._configFingerprint!==void 0&&d.configFingerprint===this._configFingerprint&&ri(d.workspaceRoot)===ri(this.workspaceRoot)}catch{return!1}}async ensureIndexed(o){if(!this._initialized||!Cc.spider)throw new Am("Runtime not initialized. Call init() first.",Yp.WORKSPACE_NOT_FOUND);if(this._indexReady){let z=Cc.warmupInfo;return{filesIndexed:z?.filesIndexed??0,filesFound:z?.filesFound??z?.filesIndexed??0,filesAnalyzed:z?.filesAnalyzed??0,fromCache:z?.fromCache??!1,durationMs:z?.durationMs??0}}let d=Cc.spider,h=Date.now(),m=o?.silent??!1,T="Indexing",N=d.subscribeToIndexStatus(z=>{!m&&z.state==="indexing"&&z.total>0&&process.stderr.write(`\r ${T}: ${z.processed}/${z.total} files...`)});try{let ee=await this.tryIncrementalIndex(d,{silent:m,onReindexStart:()=>{T="Re-indexing changed"}})??await this.runFullIndex(d,m),pe=Date.now()-h;return m||process.stderr.write(this.describeOutcome(ee)+`
|
|
46678
|
+
`),aEe.info(`${ee.fromCache?"Cache":"Index"}: ${ee.filesIndexed} files,`,`${ee.filesAnalyzed} analyzed in ${pe}ms`),this.saveState({lastScanTimestamp:new Date().toISOString(),filesIndexed:ee.filesIndexed,workspaceRoot:this.workspaceRoot}),Cc.warmupInfo={completed:!0,durationMs:pe,...ee},this._indexReady=!0,{...ee,durationMs:pe}}finally{N()}}describeOutcome(o){return o.fromCache?o.filesAnalyzed===0?`\r Loaded ${o.filesIndexed} files from cache (nothing changed)`:`\r Loaded ${o.filesIndexed} files from cache, re-indexed ${o.filesAnalyzed} changed`:`\r Indexed ${o.filesIndexed}/${o.filesFound} files`}async runFullIndex(o,d){o.clearCache(),d||process.stderr.write("\r Indexing workspace...");let h=await o.buildFullIndex();return{filesIndexed:o.getCacheStats().reverseIndexStats?.indexedFiles??h.indexedFiles,filesFound:h.indexedFiles,filesAnalyzed:h.indexedFiles,fromCache:!1}}async tryIncrementalIndex(o,d){if(!this._reverseIndexRestored)return null;let h=await this.collectSourceFiles(),m=await o.validateReverseIndex(fpn,h);if(!m?.isValid)return aEe.info("Cached index too stale, rebuilding from scratch"),null;for(let N of m.missingFiles)o.handleFileDeleted(N);m.staleFiles.length>0&&d.onReindexStart();let T=await o.reindexStaleFiles(m.staleFiles);return aEe.info(`Incremental index: ${T} changed, ${m.missingFiles.length} deleted`),{filesIndexed:o.getCacheStats().reverseIndexStats?.indexedFiles??h.length,filesFound:h.length,filesAnalyzed:T,fromCache:!0}}async collectSourceFiles(){return this._sourceFiles??=await new TR({excludeNodeModules:!0,yieldIntervalMs:30,isCancelled:()=>!1}).collectAllSourceFiles(this.workspaceRoot),this._sourceFiles}saveCache(){if(!(!this.cacheEnabled||!this._indexReady||this._configFingerprint===void 0))try{pP.mkdirSync(this.cacheDir,{recursive:!0});let o=Cc.spider?.getSerializedReverseIndex();o&&cOt(xT.join(this.cacheDir,iHt),o),Cc.callGraphIndexer?cOt(xT.join(this.cacheDir,oHt),Cc.callGraphIndexer.exportDb()):this.isCacheMetaValid()||pP.rmSync(xT.join(this.cacheDir,oHt),{force:!0});let d={schema:nHt,cliVersion:tHt,savedAt:new Date().toISOString(),workspaceRoot:this.workspaceRoot,configFingerprint:this._configFingerprint};cOt(xT.join(this.cacheDir,rHt),JSON.stringify(d,null,2))}catch(o){aEe.warn("Could not save cache:",o instanceof Error?o.message:String(o))}}async dispose(){this.saveCache(),Cc.astWorkerHost&&await Cc.astWorkerHost.stop(),Cc.spider&&await Cc.spider.dispose(),Cc.reset(),this._initialized=!1,this._indexReady=!1}saveState(o){try{pP.writeFileSync(xT.join(this.stateDir,"state.json"),JSON.stringify(o,null,2))}catch(d){aEe.warn("Could not save state:",d instanceof Error?d.message:String(d))}}loadState(){try{let o=pP.readFileSync(xT.join(this.stateDir,"state.json"),"utf-8");return JSON.parse(o)}catch{return null}}};pOt();var jBt="1.16.1",WBt={workspace:{type:"string",short:"w"},format:{type:"string",short:"f"},help:{type:"boolean",short:"h"},version:{type:"boolean",short:"v"},reindex:{type:"boolean"},"no-cache":{type:"boolean"}};_B.setSource("cli");var Xdt,Ydt,_rn=!1;function grn(){if(!_rn){_rn=!0;try{JBt(_B.snapshot())}catch{}}}process.on("exit",()=>{grn()});for(let u of["SIGINT","SIGTERM"])process.on(u,()=>{grn(),Ydt??=u==="SIGINT"?130:143,process.exitCode=Ydt,Xdt&&Xdt.dispose().catch(()=>{})});var yrn=`
|
|
46679
46679
|
graph-it \u2014 Graph-It-Live standalone CLI
|
|
46680
46680
|
|
|
46681
46681
|
Usage: graph-it <command> [options]
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@magic5644/graph-it-live",
|
|
3
3
|
"displayName": "Graph-It-Live",
|
|
4
4
|
"description": "AI-first dependency graph & code intelligence for VS Code. Visualize file imports, symbol call hierarchies, and cross-file call graphs. Detect circular dependencies, dead code, and breaking changes. Built-in MCP Server with 27 tools for GitHub Copilot, Cursor, Claude, Windsurf, and Antigravity. Generate AI-friendly codemaps. TypeScript, JavaScript, C#, Go, Java, Python, Rust, Vue, Svelte, GraphQL.",
|
|
5
|
-
"version": "1.16.
|
|
5
|
+
"version": "1.16.1",
|
|
6
6
|
"publisher": "magic5644",
|
|
7
7
|
"author": {
|
|
8
8
|
"name": "magic56"
|
|
@@ -313,6 +313,12 @@
|
|
|
313
313
|
"group": "navigation@1",
|
|
314
314
|
"icon": "$(copy)"
|
|
315
315
|
},
|
|
316
|
+
{
|
|
317
|
+
"command": "graph-it-live.branchWatch.openSettings",
|
|
318
|
+
"when": "view == graph-it-live.branchWatchView",
|
|
319
|
+
"group": "navigation@2",
|
|
320
|
+
"icon": "$(settings-gear)"
|
|
321
|
+
},
|
|
316
322
|
{
|
|
317
323
|
"command": "graph-it-live.setWorkspace",
|
|
318
324
|
"when": "view == graph-it-live.graphView || view == graph-it-live.branchWatchView",
|