pando-ai 0.1.1 → 0.1.3
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/cli.js +216 -352
- package/dist/watcher-process.js +546 -686
- package/dist/workers/chunk-LGZQCDFH.mjs +522 -0
- package/dist/workers/{chunk-HQDE7M4W.mjs → chunk-ODST7O2H.mjs} +4 -4
- package/dist/workers/indexer-worker.mjs +1 -1
- package/dist/workers/snapshot-worker.mjs +3 -3
- package/dist/workers/sqlite-writer-worker.mjs +16 -63
- package/package.json +10 -6
- package/resources/tools/pando-tools.json +832 -429
- package/tools/clojure-editor/lib/pando-clojure-editor-standalone.jar +0 -0
- package/tools/clojure-indexer/lib/pando-clojure-indexer-standalone.jar +0 -0
- package/tools/csharp-indexer/CSharpIndexer.csproj +12 -0
- package/tools/csharp-indexer/bin/Release/net10.0/CSharpIndexer +0 -0
- package/tools/csharp-indexer/bin/Release/net10.0/CSharpIndexer.deps.json +383 -0
- package/tools/csharp-indexer/bin/Release/net10.0/CSharpIndexer.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net10.0/CSharpIndexer.pdb +0 -0
- package/tools/csharp-indexer/bin/Release/net10.0/CSharpIndexer.runtimeconfig.json +13 -0
- package/tools/csharp-indexer/bin/Release/net10.0/Humanizer.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net10.0/Microsoft.CodeAnalysis.CSharp.Workspaces.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net10.0/Microsoft.CodeAnalysis.CSharp.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net10.0/Microsoft.CodeAnalysis.Workspaces.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net10.0/Microsoft.CodeAnalysis.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net10.0/System.Composition.AttributedModel.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net10.0/System.Composition.Convention.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net10.0/System.Composition.Hosting.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net10.0/System.Composition.Runtime.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net10.0/System.Composition.TypedParts.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net10.0/cs/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net10.0/cs/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net10.0/cs/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net10.0/cs/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net10.0/de/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net10.0/de/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net10.0/de/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net10.0/de/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net10.0/es/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net10.0/es/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net10.0/es/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net10.0/es/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net10.0/fr/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net10.0/fr/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net10.0/fr/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net10.0/fr/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net10.0/it/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net10.0/it/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net10.0/it/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net10.0/it/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net10.0/ja/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net10.0/ja/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net10.0/ja/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net10.0/ja/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net10.0/ko/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net10.0/ko/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net10.0/ko/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net10.0/ko/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net10.0/pl/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net10.0/pl/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net10.0/pl/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net10.0/pl/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net10.0/pt-BR/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net10.0/pt-BR/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net10.0/pt-BR/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net10.0/pt-BR/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net10.0/ru/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net10.0/ru/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net10.0/ru/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net10.0/ru/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net10.0/tr/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net10.0/tr/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net10.0/tr/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net10.0/tr/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net10.0/zh-Hans/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net10.0/zh-Hans/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net10.0/zh-Hans/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net10.0/zh-Hans/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net10.0/zh-Hant/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net10.0/zh-Hant/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net10.0/zh-Hant/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net10.0/zh-Hant/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/CSharpIndexer +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/CSharpIndexer.deps.json +400 -0
- package/tools/csharp-indexer/bin/Release/net8.0/CSharpIndexer.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/CSharpIndexer.pdb +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/CSharpIndexer.runtimeconfig.json +13 -0
- package/tools/csharp-indexer/bin/Release/net8.0/Humanizer.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/Microsoft.CodeAnalysis.CSharp.Workspaces.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/Microsoft.CodeAnalysis.CSharp.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/Microsoft.CodeAnalysis.Workspaces.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/Microsoft.CodeAnalysis.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/System.Composition.AttributedModel.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/System.Composition.Convention.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/System.Composition.Hosting.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/System.Composition.Runtime.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/System.Composition.TypedParts.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/System.IO.Pipelines.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/cs/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/cs/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/cs/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/cs/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/de/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/de/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/de/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/de/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/es/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/es/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/es/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/es/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/fr/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/fr/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/fr/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/fr/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/it/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/it/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/it/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/it/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/ja/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/ja/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/ja/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/ja/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/ko/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/ko/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/ko/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/ko/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/pl/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/pl/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/pl/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/pl/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/pt-BR/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/pt-BR/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/pt-BR/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/pt-BR/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/ru/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/ru/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/ru/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/ru/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/tr/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/tr/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/tr/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/tr/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/zh-Hans/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/zh-Hans/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/zh-Hans/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/zh-Hans/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/zh-Hant/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/zh-Hant/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/zh-Hant/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
- package/tools/csharp-indexer/bin/Release/net8.0/zh-Hant/Microsoft.CodeAnalysis.resources.dll +0 -0
- package/tools/csharp-indexer/bin/pando-csharp-indexer +32 -0
- package/tools/csharp-indexer/bin/pando-csharp-indexer.cmd +17 -0
- package/dist/workers/chunk-62Z76NNE.mjs +0 -522
|
@@ -0,0 +1,522 @@
|
|
|
1
|
+
import{c as xn,d as te,e as X,f as gt}from"./chunk-ODST7O2H.mjs";import{a as bn}from"./chunk-AYCBSZ56.mjs";var ee={getAbbrev(t,e="ts"){return t},getKindFromAbbrev(t,e="ts"){return t}};function we(t){let e=`${t.sourceFile}#${t.sourceStart}-${t.sourceEnd}`,n=t.refKind??"",r=t.refName??"",i=t.targetFile??"",s=t.targetStart!=null&&t.targetEnd!=null?`#${t.targetStart}-${t.targetEnd}`:"",o=t.targetNodeId??"",l=`${e}:REF:${n}:${r}|${i}${s}|${o}`;return gt(l)}function ht(t){let e=[],n=new Set,r=i=>{!i?.name||n.has(i.name)||(n.add(i.name),e.push(i))};for(let i of t.exports??[])r(i);for(let i of t.explicitExports??[])r({name:i});for(let i of t.modulePublic??[])r({name:i});return e}function he(t,e,n){let r=new Date().toISOString();return{payload:{lang:t,fileRel:e,preDeleted:!1,exportRows:[],nodeRows:[],referenceRows:[],symbolMentionRows:[],importRows:[],importBindingRows:[],fileRow:[e,n?.mtime??null,n?.size??null,"failed",r],fts:null},fileSize:n?.size,mtime:n?.mtime}}function ye(t){let{lang:e,fileRel:n,content:r,meta:i,preDeleted:s,parsed:o,resolveNodeId:l,exportKind:u}=t,m=[];for(let a of o.nodes??[]){let h=a.rawKind??a.kind,b=a.rawKindSource??"cli",E=a.containerRawKind??a.containerKind??null,F=a.containerRawKindSource??(E?"cli":null),g=a.scopeChain??null,S=Array.isArray(g)?JSON.stringify(g):typeof g=="string"?g:null,P=`${n}#${a.start}-${a.end}:${ee.getAbbrev(a.kind,e)}`,A=(e==="c"||e==="cpp"||e==="java"||e==="clojure")&&a.name?`${P}:${a.name}`:P,N=a.metadata&&Object.keys(a.metadata).length?JSON.stringify(a.metadata):null;m.push([A,a.name,a.kind,h,b,a.semanticKind??null,a.start,a.end,typeof a.isExported=="number"?a.isExported:0,a.containerKind??null,E,F,typeof a.paramCount=="number"?a.paramCount:null,a.qualifiedName??null,S,a.symbolKey??null,N])}let d=[],f=new Set;for(let a of ht(o)){if(!a.name||f.has(a.name))continue;f.add(a.name);let h=a.nodeId??(l?l(a.name):null);d.push([n,a.name,h??null,a.isReexport?1:0,a.reexportFrom??null,a.reexportName??null,a.exportKind??u??"cli",a.targetSymbolKey??null])}let y=[],_=[],x=new Map,v=new Map;for(let a of m){let h=a[0]!=null?String(a[0]):null,b=a[13]!=null?String(a[13]):null,E=a[15]!=null?String(a[15]):null;h&&(b&&!x.has(b)&&x.set(b,h),E&&!v.has(E)&&v.set(E,h))}if(te()&&e==="clojure"&&(o.references??[]).length>0){let a=Array.from(x.keys()).slice(0,10),h=Array.from(v.keys()).slice(0,10),b=(o.references??[]).slice(0,10).map(F=>F.containerQualifiedName),E={file:n,nodeCount:m.length,refCount:(o.references??[]).length,nodeQualifiedNames:a,nodeSymbolKeys:h,refContainers:b,qualifiedNameMapSize:x.size,symbolKeyMapSize:v.size};try{console.error("[CliPayload][CLOJURE-DEBUG] source_node_id lookup context",E)}catch{}}for(let a of o.references??[]){let h=a.targetNodeId??(l&&a.refName?l(a.refName):null),b=a.targetFile??(h?n:null),E=a.sourceNodeId??(a.containerQualifiedName?x.get(a.containerQualifiedName)??null:null)??(a.containerQualifiedName?v.get(a.containerQualifiedName)??null:null),F=we({sourceFile:n,sourceStart:a.sourceStart,sourceEnd:a.sourceEnd,refKind:a.refKind,refName:a.refName,targetFile:b??null,targetStart:a.targetStart??null,targetEnd:a.targetEnd??null,targetNodeId:h??a.targetNodeId??null}),g=a.metadata&&Object.keys(a.metadata).length?JSON.stringify(a.metadata):null;y.push([F,n,E,a.refName??null,a.refKind,a.sourceStart,a.sourceEnd,h??a.targetNodeId??null,b??null,h||a.targetNodeId||a.targetFile?"resolved":"unresolved",a.receiverName??null,typeof a.arity=="number"?a.arity:null,a.containerQualifiedName??null,a.targetSymbolKey??null,a.confidence??null,g])}for(let a of o.symbolMentions??[]){let h=typeof a?.name=="string"?a.name.trim():"";if(!h)continue;let b=typeof a?.mentionKind=="string"&&a.mentionKind.trim().length>0?a.mentionKind.trim():"reference",E=typeof a?.count=="number"&&Number.isFinite(a.count)&&a.count>0?Math.floor(a.count):1;_.push([h,b,a.targetSymbolKey??null,a.containerQualifiedName??null,E])}if(te()&&e==="clojure"&&y.length>0){let a=y.reduce((b,E)=>b+(E?.[2]!=null?1:0),0),h=y.reduce((b,E)=>b+(E?.[12]!=null?1:0),0);try{console.error("[CliPayload] clojure source-node summary",{file:n,refs:y.length,sourceNodeCount:a,containerCount:h,sample:y.slice(0,5).map(b=>({sourceNodeId:b[2]==null?null:String(b[2]),refName:b[3],refKind:b[4],containerQualifiedName:b[12]}))})}catch{}}let K=[];for(let a of o.imports??[])K.push([n,a.module??null,a.isTypeOnly??0]);let C=[];for(let a of o.importBindings??[])C.push([n,a.module??null,a.kind,a.localName,a.importedName,a.isTypeOnly??0]);let z=new Date().toISOString(),$=[n,i?.mtime??null,i?.size??null,"completed",z];return{payload:{lang:e,fileRel:n,preDeleted:!!s,exportRows:d,nodeRows:m,referenceRows:y,symbolMentionRows:_,importRows:K,importBindingRows:C,fileRow:$,fts:typeof r=="string"?{blobOid:n,content:r}:null},fileSize:i?.size,mtime:i?.mtime}}var be=["ts","js","python","c","cpp","csharp","dart","java","clojure"];function He(t){return typeof t=="string"&&be.includes(t)}xn();function yt(){let t=process.env.PANDO_ENABLED_LANGUAGES;if(t&&t.trim().length>0){let n=t.split(",").map(r=>r.trim()).filter(r=>r.length>0).filter(He);if(n.length>0)return bt(n)}return[...be]}function bt(t){let e=new Set;for(let n of t)He(n)&&e.add(n);return be.filter(n=>e.has(n))}function xt(t){let e=new Set(bt(t)),n={};for(let r of be){if(e.has(r)){n[r]={enabled:!0,source:"embedded"};continue}n[r]={enabled:!1,source:"none",reason:"disabled by language support config"}}return{byLanguage:n}}import Ue from"path";import $n from"fs";import{Project as Bn,Node as Q}from"ts-morph";import{Node as p,SyntaxKind as ue}from"ts-morph";import*as V from"typescript";import{SyntaxKind as xe}from"ts-morph";var Je={LINE_COMMENT:{kind:9001,name:"LineComment",triviaKind:xe.SingleLineCommentTrivia},BLOCK_COMMENT:{kind:9002,name:"BlockComment",triviaKind:xe.MultiLineCommentTrivia},JSDOC_COMMENT:{kind:9003,name:"JSDocComment",triviaKind:xe.MultiLineCommentTrivia}};function St(t,e){return t===xe.SingleLineCommentTrivia?Je.LINE_COMMENT:t===xe.MultiLineCommentTrivia&&e.startsWith("/**")?Je.JSDOC_COMMENT:Je.BLOCK_COMMENT}import{Node as O,SyntaxKind as c,Scope as We}from"ts-morph";import*as En from"xxhash-wasm";import{Node as Pi}from"ts-morph";import{Node as B}from"ts-morph";var vt={TS_MORPH:"ts-morph",PYTHON_AST:"python-ast",CLANG:"clang",ROSLYN:"roslyn",JAVA_AST:"java-ast",CLI:"cli",UNKNOWN:"unknown"},Nt=(t,e)=>B.isFunctionDeclaration(t)||B.isFunctionExpression(t)||B.isArrowFunction(t)?{kind:"Function",semanticKind:"function"}:B.isGetAccessorDeclaration(t)||B.isSetAccessorDeclaration(t)?{kind:"Method",semanticKind:"property"}:B.isMethodDeclaration(t)||B.isMethodSignature(t)||B.isConstructorDeclaration(t)?{kind:"Method",semanticKind:"method"}:B.isClassDeclaration(t)||B.isClassExpression(t)?{kind:"Class",semanticKind:"class"}:B.isInterfaceDeclaration(t)?{kind:"Interface",semanticKind:"interface"}:B.isEnumDeclaration(t)?{kind:"Enum",semanticKind:"enum"}:B.isEnumMember(t)?{kind:"EnumMember",semanticKind:"enum"}:B.isTypeAliasDeclaration(t)?{kind:"TypeAlias",semanticKind:"type"}:B.isModuleDeclaration(t)?{kind:"Namespace",semanticKind:"namespace"}:B.isPropertyDeclaration(t)||B.isPropertySignature(t)?{kind:"Field",semanticKind:"property"}:B.isVariableDeclaration(t)?{kind:"Variable",semanticKind:"variable"}:{kind:e,semanticKind:null};function Ct(t){try{let e=t.getKindName?.();if(typeof e=="string"&&e.trim())return e}catch{}return"Unknown"}function ce(t){let e=Ct(t),n=Nt(t,e);return{kind:n.kind,semanticKind:n.semanticKind,rawKind:e,rawKindSource:vt.TS_MORPH}}function wt(t){let e=Ct(t);return{kind:Nt(t,e).kind,rawKind:e,rawKindSource:vt.TS_MORPH}}function Ee(t,e){if(!t.kind||!t.kind.trim())throw new Error(`Invalid normalized kind: missing kind ${e?JSON.stringify(e):""}`);if(!t.rawKind||!t.rawKind.trim())throw new Error(`Invalid normalized kind: missing rawKind ${e?JSON.stringify(e):""}`);if(!t.rawKindSource||!String(t.rawKindSource).trim())throw new Error(`Invalid normalized kind: missing rawKindSource ${e?JSON.stringify(e):""}`)}function Sn(){return new Date().toISOString()}function Pe(t,e,n){let r=`[${Sn()}] [${t.toUpperCase()}] ${e}`;if(!n)return r;try{return r+" "+JSON.stringify(n)}catch{return r}}var vn={debug:(t,e)=>{try{process.stderr.write(Pe("debug",t,e)+`
|
|
2
|
+
`)}catch{}},info:(t,e)=>{try{process.stderr.write(Pe("info",t,e)+`
|
|
3
|
+
`)}catch{}},warn:(t,e)=>{try{process.stderr.write(Pe("warn",t,e)+`
|
|
4
|
+
`)}catch{}},error:(t,e)=>{try{process.stderr.write(Pe("error",t,e)+`
|
|
5
|
+
`)}catch{}}};var Pn="__pando_xxhash_instance__",Rn=globalThis,ji=Rn[Pn]??null;var Ui=new Set([c.ArrayLiteralExpression,c.ArrayType,c.ArrowFunction,c.AsExpression,c.AssertClause,c.AssertEntry,c.AwaitExpression,c.BigIntLiteral,c.BinaryExpression,c.BindingElement,c.Block,c.CallExpression,c.CallSignature,c.CaseClause,c.CatchClause,c.ClassDeclaration,c.ClassExpression,c.ClassStaticBlockDeclaration,c.ComputedPropertyName,c.ConditionalExpression,c.ConditionalType,c.ConstructSignature,c.Constructor,c.ConstructorType,c.Decorator,c.DefaultClause,c.DoStatement,c.ElementAccessExpression,c.EnumDeclaration,c.EnumMember,c.ExportAssignment,c.ExportDeclaration,c.ExportSpecifier,c.ExpressionStatement,c.ExpressionWithTypeArguments,c.FalseKeyword,c.ForInStatement,c.ForOfStatement,c.ForStatement,c.FunctionDeclaration,c.FunctionExpression,c.FunctionType,c.GetAccessor,c.Identifier,c.IfStatement,c.ImportAttribute,c.ImportAttributes,c.ImportClause,c.ImportDeclaration,c.ImportEqualsDeclaration,c.ImportSpecifier,c.ImportType,c.IndexSignature,c.IndexedAccessType,c.InferType,c.InterfaceDeclaration,c.IntersectionType,c.JsxAttribute,c.JsxClosingElement,c.JsxClosingFragment,c.JsxElement,c.JsxExpression,c.JsxFragment,c.JsxOpeningElement,c.JsxOpeningFragment,c.JsxSelfClosingElement,c.JsxSpreadAttribute,c.JsxText,c.LiteralType,c.MappedType,c.MetaProperty,c.MethodDeclaration,c.MethodSignature,c.ModuleDeclaration,c.NamedExports,c.NamedImports,c.NamedTupleMember,c.NamespaceExport,c.NamespaceExportDeclaration,c.NamespaceImport,c.NewExpression,c.NoSubstitutionTemplateLiteral,c.NonNullExpression,c.NullKeyword,c.NumericLiteral,c.ObjectLiteralExpression,c.OptionalType,c.Parameter,c.ParenthesizedType,c.PostfixUnaryExpression,c.PrefixUnaryExpression,c.PrivateIdentifier,c.PropertyAccessExpression,c.PropertyAssignment,c.PropertyDeclaration,c.PropertySignature,c.QualifiedName,c.RegularExpressionLiteral,c.RestType,c.ReturnStatement,c.SatisfiesExpression,c.SetAccessor,c.ShorthandPropertyAssignment,c.SourceFile,c.SpreadAssignment,c.SpreadElement,c.StringLiteral,c.SwitchStatement,c.TaggedTemplateExpression,c.TemplateExpression,c.TemplateLiteralType,c.ThisType,c.ThrowStatement,c.TrueKeyword,c.TryStatement,c.TupleType,c.TypeAliasDeclaration,c.TypeLiteral,c.TypeOfExpression,c.TypeOperator,c.TypeParameter,c.TypePredicate,c.TypeQuery,c.TypeReference,c.UnionType,c.VariableDeclaration,c.VariableStatement,c.WhileStatement,c.YieldExpression]);function _n(t){try{let e=t.getDecorators;if(typeof e!="function")return[];let n=new Set;for(let r of e.call(t)){let i;try{i=r.getName?.()}catch{i=void 0}if(!i)try{i=r.getExpression?.()?.getText?.()}catch{i=void 0}if(i){let s=String(i).trim();s&&n.add(s)}}return Array.from(n)}catch{return[]}}function An(t){try{if(!O.isClassDeclaration(t))return[];let e=t.getImplements();if(!e||e.length===0)return[];let n=new Set;for(let r of e)try{let i=r.getExpression(),s=i?i.getText():r.getText();s&&n.add(s.trim())}catch{}return Array.from(n)}catch{return[]}}function Tn(t){try{let e=new Set;if(O.isClassDeclaration(t)){let n=t.getExtends();if(n)try{let r=n.getExpression(),i=r?r.getText():n.getText();i&&e.add(i.trim())}catch{}}else if(O.isInterfaceDeclaration(t)){let n=t.getExtends();for(let r of n)try{let i=r.getText();i&&e.add(i.trim())}catch{}}return Array.from(e)}catch{return[]}}function Et(t){try{if("getReturnTypeNode"in t&&typeof t.getReturnTypeNode=="function"){let e=t.getReturnTypeNode();if(e)return e.getText()}if("getReturnType"in t&&typeof t.getReturnType=="function"){let e=t.getReturnType();if(e&&typeof e.getText=="function"){let n=e.getText();if(n)return String(n)}}return null}catch{return null}}function In(t){try{if(typeof t.getScope!="function")return null;let e=t.getScope();return e===We.Private||e===We.Protected||e===We.Public?e:null}catch{return null}}function Pt(t){let e={kind:t.getKindName()},n=_n(t);if(n.length&&(e.decorators=n),k(e,"flags",()=>t.getFlags()),(O.isFunctionDeclaration(t)||O.isMethodDeclaration(t)||O.isFunctionExpression(t))&&(k(e,"isAsync",()=>t.isAsync()),k(e,"isGenerator",()=>t.isGenerator()),k(e,"parameterCount",()=>t.getParameters().length),k(e,"returnType",()=>Et(t)),O.isFunctionDeclaration(t)&&k(e,"isExported",()=>t.isExported())),O.isClassDeclaration(t)){k(e,"isAbstract",()=>t.isAbstract()),k(e,"isExported",()=>t.isExported());let i=Tn(t);i.length&&(e.extends=i);let s=An(t);s.length&&(e.implements=s)}if(O.isVariableDeclaration(t)&&(k(e,"declarationKind",()=>t.getVariableStatement()?.getDeclarationKind()),k(e,"hasInitializer",()=>t.hasInitializer()),k(e,"type",()=>t.getTypeNode()?.getText())),(O.isPropertyDeclaration(t)||O.isPropertySignature(t)||O.isParameterDeclaration(t))&&(k(e,"isStatic",()=>t.isStatic?.()),k(e,"isReadonly",()=>t.isReadonly?.()),k(e,"isOptional",()=>t.hasQuestionToken?.()),k(e,"scope",()=>t.getScope?.())),(O.isMethodDeclaration(t)||O.isMethodSignature(t)||O.isGetAccessorDeclaration(t)||O.isSetAccessorDeclaration(t))&&(k(e,"isStatic",()=>t.isStatic?.()),k(e,"isAbstract",()=>t.isAbstract?.()),k(e,"isAsync",()=>t.isAsync?.()),k(e,"returnType",()=>Et(t)),k(e,"scope",()=>t.getScope?.())),O.isCallExpression(t)){let i=t.getExpression();if(O.isPropertyAccessExpression(i)){e.propertyName=i.getName();let s=i.getExpression();O.isIdentifier(s)&&(e.objectName=s.getText())}else O.isIdentifier(i)&&(e.functionName=i.getText());e.argumentCount=t.getArguments().length,e.callExpression=i.getText()}let r=In(t);return r&&(e.visibility=r),e.isReadonly||k(e,"isReadonly",()=>t.isReadonly?.()),O.isImportDeclaration(t)&&(k(e,"moduleSpecifier",()=>t.getModuleSpecifier()?.getLiteralText()),k(e,"isTypeOnly",()=>t.isTypeOnly()),k(e,"namedImports",()=>t.getNamedImports()?.map(i=>i.getName()).join(", ")),k(e,"defaultImport",()=>t.getDefaultImport()?.getText())),Object.keys(e).forEach(i=>{e[i]===void 0&&delete e[i]}),e}function k(t,e,n){try{let r=n();r!=null&&(t[e]=r)}catch{}}function kn(t){if(t.kind==="local"){let r=t.isDefault?"default":t.name;return r?{name:r,priority:t.isDefault?4:3}:null}if(t.kind==="alias")return t.exported?{name:t.exported,priority:2}:null;let e=t.isNamespace??!1,n=t.alias||t.name||(e?"*":null);return n?{name:n,priority:e?0:1}:null}function Dn(t){if(t.length<2)return t;let e=new Map;for(let n of t){let r=kn(n);if(!r)continue;let i=e.get(r.name);(!i||r.priority>i.priority)&&e.set(r.name,{record:n,priority:r.priority})}return Array.from(e.values()).map(n=>n.record)}function Kn(t){if(typeof t=="boolean")return t;let e=process.env.PANDO_INDEX_ALL_NODES??process.env.AST_INDEX_ALL_NODES;return e?e==="1"||e.toLowerCase()==="true":!1}function _e(t){try{if(t&&typeof t.getName=="function"){let e=t.getName();if(typeof e=="string"&&e.length>0)return e}}catch{}return null}function Re(t){let e;try{let r=t.getStart?.(!1);typeof r=="number"&&Number.isFinite(r)&&(e=r)}catch{}if(e===void 0)try{let r=t.getStart?.();typeof r=="number"&&Number.isFinite(r)&&(e=r)}catch{}if(e===void 0)try{let r=t.getFullStart?.();typeof r=="number"&&Number.isFinite(r)&&(e=r)}catch{}e===void 0&&(e=0);let n;try{let r=t.getEnd?.();typeof r=="number"&&Number.isFinite(r)&&(n=r)}catch{}if(n===void 0)try{let r=t.getStart?.();typeof r=="number"&&Number.isFinite(r)&&(n=r)}catch{}return n===void 0&&(n=e),n<e&&(n=e),{start:e,end:n}}function Fn(t){try{if(p.isFunctionDeclaration(t)||p.isMethodDeclaration(t)||p.isConstructorDeclaration(t)||p.isFunctionExpression(t)||p.isArrowFunction(t)){let e=t.getParameters?.();if(Array.isArray(e))return e.length}}catch{}return null}function Mn(t){try{return p.isIdentifier(t)?t.getSymbol():p.isPropertyAccessExpression(t)?t.getNameNode().getSymbol()??t.getSymbol():t.getSymbol?.()}catch{return}}function Ae(t,e){try{return typeof t?.hasModifier=="function"&&t.hasModifier(e)}catch{return!1}}function Rt(t){try{return t.getModuleSpecifierValue?.()??null}catch{try{return t.getModuleSpecifier?.()?.getLiteralText?.()??null}catch{return null}}}function On(t,e,n){if(!p.isImportDeclaration(t))return;let i={moduleSpecifier:Rt(t),isTypeOnly:t.isTypeOnly(),namedImports:[]};try{let s=t.getDefaultImport();if(s){let o=s.getText();i.defaultImport=o,n(o,s)}}catch{}try{let s=t.getNamespaceImport();if(s){let o=s.getText();i.namespaceImport=o,n(o,s)}}catch{}try{t.getNamedImports().forEach(s=>{try{let o=s.getName(),l=s.getAliasNode(),u=l?l.getText():void 0;o&&(i.namedImports.push({name:o,alias:u||void 0}),n(u||o,s.getNameNode()))}catch{}})}catch{}e.push(i)}function Ln(t,e){if(p.isExportDeclaration(t)){let n=Rt(t);if(n){if(t.getNamedExports().length>0)try{t.getNamedExports().forEach(r=>{try{let i=r.getName(),s=r.getAliasNode(),o=s?s.getText():void 0;e.push({kind:"reexport",moduleSpecifier:n,name:i||void 0,alias:o||void 0,isNamespace:!1})}catch{}})}catch{}else if(t.isNamespaceExport())try{let i=t.getNamespaceExport()?.getName();e.push({kind:"reexport",moduleSpecifier:n,name:i||"*",alias:i||void 0,isNamespace:!0})}catch{e.push({kind:"reexport",moduleSpecifier:n,name:"*",isNamespace:!0})}else e.push({kind:"reexport",moduleSpecifier:n,name:"*",isNamespace:!0});return}try{t.getNamedExports().forEach(r=>{try{let i=r.getName();if(!i)return;let s=r.getAliasNode(),o=s?s.getText():i;e.push({kind:"alias",local:i,exported:o})}catch{}})}catch{}return}if(p.isExportAssignment(t))try{let n=t.getExpression();if(n&&p.isIdentifier(n)){let r=n.getText();e.push({kind:"alias",local:r,exported:"default"})}}catch{}}function jn(t,e,n,r){if(!Ae(t,ue.ExportKeyword))return;let i=Ae(t,ue.DefaultKeyword);if(p.isVariableStatement(t)){try{let s=t.getDeclarationList().getDeclarations();for(let o of s){let l=_e(o)??o.getName?.()??null;if(l){n(l,o);let u=r(o);u&&e.push({kind:"local",name:l,isDefault:i,nodeId:u})}}}catch{}return}if(p.isFunctionDeclaration(t)||p.isClassDeclaration(t)||p.isInterfaceDeclaration(t)||p.isEnumDeclaration(t)||p.isTypeAliasDeclaration(t)||p.isModuleDeclaration(t)){let s=_e(t)||(i?"default":null),o=r(t);o&&e.push({kind:"local",name:s??"default",isDefault:i,nodeId:o})}}function _t(t,e,n,r){let i=[],s=[],o=[],l=new Set,u=new Map,m=[],d=[],f=Kn(r?.indexAllNodes),y=[{node:t,id:null,kind:"module",rawKind:"SourceFile",rawKindSource:"ts-morph",name:null,isExported:!1}],_=a=>{if(!a)return null;try{return e(a)}catch{return null}},x=(a,h)=>{if(a&&(l.has(a)||l.add(a),h&&!u.has(a))){let b=_(h);b&&u.set(a,b)}},v=a=>p.isFunctionDeclaration(a)||p.isFunctionExpression(a)||p.isArrowFunction(a)||p.isClassDeclaration(a)||p.isClassExpression(a)||p.isInterfaceDeclaration(a)||p.isEnumDeclaration(a)||p.isEnumMember(a)||p.isTypeAliasDeclaration(a)||p.isModuleDeclaration(a)||p.isMethodDeclaration(a)||p.isMethodSignature(a)||p.isPropertyDeclaration(a)||p.isPropertySignature(a)||p.isGetAccessorDeclaration(a)||p.isSetAccessorDeclaration(a)||p.isConstructorDeclaration(a)||p.isVariableDeclaration(a),K=a=>p.isReturnStatement(a)||p.isIfStatement(a)||p.isForStatement(a)||p.isForInStatement(a)||p.isForOfStatement(a)||p.isWhileStatement(a)||p.isDoStatement(a)||p.isSwitchStatement(a)||p.isCaseClause(a)||p.isDefaultClause(a)||p.isTryStatement(a)||p.isCatchClause(a)||p.isThrowStatement(a)||p.isExpressionStatement(a)||p.isBlock(a),C=a=>v(a)||f&&K(a),z=a=>p.isSourceFile(a)||p.isFunctionDeclaration(a)||p.isFunctionExpression(a)||p.isArrowFunction(a)||p.isMethodDeclaration(a)||p.isConstructorDeclaration(a)||p.isClassDeclaration(a)||p.isClassExpression(a)||p.isModuleDeclaration(a),$=a=>{let h=_e(a);if(h)return h;if(p.isConstructorDeclaration(a))return"constructor";if(p.isArrowFunction(a)||p.isFunctionExpression(a)){let b=a.getParent();try{if(p.isVariableDeclaration(b))return b.getName();if(p.isPropertyAssignment(b)||p.isPropertyDeclaration(b)||p.isPropertySignature(b))return b.getName?.()??null;if(p.isShorthandPropertyAssignment(b))return b.getNameNode()?.getText()??null;if(p.isExportAssignment(b))return"default"}catch{}}if(p.isEnumMember(a))try{return a.getName()}catch{return null}if(p.isVariableDeclaration(a))try{return a.getName()}catch{return null}return null};if(f){let a=Re(t),h=ce(t);i.push({nodeId:e(t),nodeName:t.getBaseName?.()??null,containerId:null,containerKind:"module",containerRawKind:"SourceFile",containerRawKindSource:"ts-morph",containerName:null,isExported:!1,kind:h.kind,rawKind:h.rawKind,rawKindSource:h.rawKindSource,semanticKind:h.semanticKind??null,start:a.start,end:a.end,paramCount:null,metadata:null})}let H=a=>{let h=y[y.length-1],b=h?.id??null,E=h?.kind??"module",F=h?.name??null;if(p.isImportDeclaration(a))On(a,m,x);else if(p.isImportEqualsDeclaration(a))try{let N=a.getModuleReference();if(N&&p.isExternalModuleReference(N)){let w=N.getExpression(),M;if(w&&p.isStringLiteral(w))M=w.getLiteralText();else if(w){let R=w.getText();M=typeof R=="string"?R.replace(/^['"]|['"]$/g,""):void 0}if(M){let L=a.getNameNode()?.getText(),q={moduleSpecifier:M,isTypeOnly:!1,namedImports:[]};L&&(q.defaultImport=L,x(L,a)),m.push(q)}}}catch{}(p.isExportDeclaration(a)||p.isExportAssignment(a))&&Ln(a,d),jn(a,d,x,_);let g=C(a),S=f||g,P=g?$(a):null;if(S){let N=e(a);g&&s.push({nodeId:N,node:a});let w=Ae(a,ue.ExportKeyword)||h?.isExported||!1,M=g?a.getNameNode?.()?.getText?.()??null:null,R=P??(g?_e(a)??M:null);P?x(P,a):R&&x(R,a);let L=Re(a),q=Fn(a),J=f&&g?(()=>{let D={...Pt(a)};if(b&&(D.containerId=b),E&&(D.containerKind=E),F&&(D.containerName=F),p.isModuleDeclaration(a))try{let W=a.getNameNode?.();if(W){let j=Re(W);Number.isFinite(j.start)&&Number.isFinite(j.end)&&(D.moduleNameStart=j.start,D.moduleNameEnd=j.end)}}catch{}return Object.keys(D).length?D:null})():null,T=ce(a);Ee(T,{source:"ts-node-collector",file:t.getFilePath(),name:R??null}),i.push({nodeId:N,nodeName:R??null,containerId:b,containerKind:E,containerRawKind:h?.rawKind??null,containerRawKindSource:h?.rawKindSource??null,containerName:F,isExported:w,kind:T.kind,rawKind:T.rawKind,rawKindSource:T.rawKindSource,semanticKind:T.semanticKind??null,start:L.start,end:L.end,paramCount:q,metadata:J})}if(p.isCallExpression(a)||p.isNewExpression(a)){let N=a.getExpression(),w=null,M,R;try{if(R=Mn(N),p.isIdentifier(N))w=N.getText();else if(p.isPropertyAccessExpression(N)){w=N.getName();let J=N.getExpression();p.isIdentifier(J)&&(M=J.getText())}}catch{}let L="";try{L=N.getText()}catch{}let q=Re(a);if(o.push({name:w,kind:p.isNewExpression(a)?"new":"call",containerId:b,containerKind:E,containerName:F,expression:L,objectName:M,symbol:R,start:q.start,end:q.end}),p.isCallExpression(a))try{if(p.isIdentifier(N)&&N.getText()==="require"){let T=a.getArguments()[0],D;if(T&&(p.isStringLiteral(T)||p.isNoSubstitutionTemplateLiteral(T)))try{D=T.getLiteralText()}catch{let W=T.getText();D=typeof W=="string"?W.replace(/^['"]|['"]$/g,""):void 0}if(D){let W={moduleSpecifier:D,isTypeOnly:!1,namedImports:[]},j=a.getParent();if(j&&p.isVariableDeclaration(j)){let le=j.getNameNode();try{if(p.isIdentifier(le)){let ge=le.getText();ge&&(W.defaultImport=ge,x(ge,j))}}catch{}}m.push(W)}}else if(N?.getKind?.()===ue.ImportKeyword){let T=a.getArguments()[0],D;if(T&&(p.isStringLiteral(T)||p.isNoSubstitutionTemplateLiteral(T)))try{D=T.getLiteralText()}catch{let W=T.getText();D=typeof W=="string"?W.replace(/^['"]|['"]$/g,""):void 0}D&&m.push({moduleSpecifier:D,isTypeOnly:!1,namedImports:[]})}}catch{}}if(p.isCallExpression(a)){let N=a.getExpression();try{if(p.isIdentifier(N)&&N.getText()==="require"){let w=a.getParent();if(!(w&&p.isExternalModuleReference(w))){let R=a.getArguments()[0],L;if(R&&(p.isStringLiteral(R)||p.isNoSubstitutionTemplateLiteral(R)))try{L=R.getLiteralText()}catch{L=R.getText().replace(/^['"]|['"]$/g,"")}if(L){let q={moduleSpecifier:L,isTypeOnly:!1,namedImports:[]};if(w&&p.isVariableDeclaration(w)){let J=w.getNameNode();try{if(p.isIdentifier(J)){let T=J.getText();T&&(q.defaultImport=T,x(T,w))}}catch{}}m.push(q)}}}else if(N?.getKind?.()===ue.ImportKeyword){let M=a.getArguments()[0],R;if(M&&(p.isStringLiteral(M)||p.isNoSubstitutionTemplateLiteral(M)))try{R=M.getLiteralText()}catch{R=M.getText().replace(/^['"]|['"]$/g,"")}R&&m.push({moduleSpecifier:R,isTypeOnly:!1,namedImports:[]})}}catch{}}let A=!1;if(z(a)){let N=_(a)??e(a),w=wt(a);y.push({node:a,id:N,kind:w.kind,rawKind:w.rawKind,rawKindSource:w.rawKindSource,name:P??F,isExported:Ae(a,ue.ExportKeyword)||h?.isExported||!1}),A=!0}a.forEachChild(H),A&&y.pop()};if(t.forEachChild(H),r?.includeComments===!0||process.env.AST_INDEX_COMMENTS==="1")try{let a=t.getFullText(),h=V.createScanner(V.ScriptTarget.Latest,!1,V.LanguageVariant.Standard,a),b=new Set;for(let E=h.scan();E!==V.SyntaxKind.EndOfFileToken;E=h.scan()){if(E!==V.SyntaxKind.SingleLineCommentTrivia&&E!==V.SyntaxKind.MultiLineCommentTrivia)continue;let F=h.getTokenPos(),g=h.getTextPos(),S=`${F}-${g}`;if(b.has(S)||(b.add(S),n.has(S)))continue;n.add(S);let P=a.substring(F,g),A=St(E,P),w=e({getKindName:()=>A.name,getKind:()=>A.kind,getPos:()=>F,getEnd:()=>g,getStart:()=>F,getFullStart:()=>F,getText:()=>P,getSourceFile:()=>t,getParent:()=>t,__isComment:!0,__commentPosition:"standalone",__attachedTo:null},"COM");i.push({nodeId:w,nodeName:P.substring(0,100),containerId:null,containerKind:"module",containerRawKind:"SourceFile",containerRawKindSource:"ts-morph",containerName:null,isExported:!1,kind:A.name,rawKind:A.name,rawKindSource:"ts-morph",semanticKind:null,start:F,end:g,paramCount:null,metadata:null})}}catch{}return{nodes:i,symbolCandidateNodes:s,references:o,declaredNames:l,localDeclarations:u,imports:m,exports:Dn(d)}}function At(t){let e;try{let r=t.getStart?.(!1);typeof r=="number"&&Number.isFinite(r)&&(e=r)}catch{}if(e===void 0)try{let r=t.getStart?.();typeof r=="number"&&Number.isFinite(r)&&(e=r)}catch{}if(e===void 0)try{let r=t.getFullStart?.();typeof r=="number"&&Number.isFinite(r)&&(e=r)}catch{}e===void 0&&(e=0);let n;try{let r=t.getEnd?.();typeof r=="number"&&Number.isFinite(r)&&(n=r)}catch{}if(n===void 0)try{let r=t.getStart?.();typeof r=="number"&&Number.isFinite(r)&&(n=r)}catch{}return n===void 0&&(n=e),n<e&&(n=e),{start:e,end:n}}var zn=100;function qn(t,e,n,r){let{start:i,end:s}=At(e),o=ce(e);Ee(o,{source:"ts-node-id",file:t,kind:o.kind});let l=r||ee.getAbbrev(o.kind,n);return`${t}#${i}-${s}:${l}`}function Hn(t,e){return Ue.relative(t,e).replace(/\\/g,"/")}function Tt(t,e){if(!t)return null;let n=t;try{let d=t.getAliasedSymbol();d&&(n=d)}catch{}let r=[];try{r=n.getDeclarations()??[]}catch{r=[]}if(!r.length)return null;let s=r.slice().sort((d,f)=>{let y=d.getSourceFile().getFilePath(),_=f.getSourceFile().getFilePath();if(y!==_)return y.localeCompare(_);let x=d.getStart(!1),v=f.getStart(!1);return x!==v?x-v:d.getEnd()-f.getEnd()})[0],o=Hn(e,s.getSourceFile().getFilePath()),l=s.getStart(!1),u=s.getEnd(),m="";try{m=n.getEscapedName()}catch{try{m=n.getName()}catch{m=""}}return`${o}#${l}-${u}:${m}`}function Jn(t){try{return Q.isVariableDeclaration(t)||Q.isEnumMember(t)?t.getNameNode().getSymbol()??t.getSymbol():t.getSymbol()}catch{return}}function Wn(t,e){let n=t.getDescendantAtPos(e);if(!n)return;let r=n;if(!Q.isCallExpression(r)&&!Q.isNewExpression(r)&&(r=n.getFirstAncestor(s=>Q.isCallExpression(s)||Q.isNewExpression(s))??void 0),!r||!Q.isCallExpression(r)&&!Q.isNewExpression(r))return;let i=r.getExpression();try{return Q.isIdentifier(i)?i.getSymbol():Q.isPropertyAccessExpression(i)?i.getNameNode().getSymbol()??i.getSymbol():i.getSymbol()}catch{return}}async function Xn(t){let{sf:e,fileRel:n,content:r,preDeleted:i,meta:s,projectRoot:o,lang:l}=t,m=_t(e,(g,S)=>qn(n,g,l,S),new Set,{includeComments:!1,indexAllNodes:t.indexAllNodes}),d=new Map;for(let{nodeId:g,node:S}of m.symbolCandidateNodes){let P=Tt(Jn(S),o);P&&(d.has(g)||d.set(g,P))}let f=[],y=new Map,_=m.exports.filter(g=>g.kind!=="reexport"),x=m.exports.filter(g=>g.kind==="reexport");for(let g of _)if(g.kind==="local"){let S=g.isDefault?"default":g.name;if(!S||y.has(S))continue;let P=g.nodeId;f.push([n,S,P,0,null,null,g.isDefault?"default":"named"]),y.set(S,P)}else if(g.kind==="alias"){let S=g.exported;if(!S||y.has(S))continue;f.push([n,S,null,0,null,g.local,"alias"]),y.set(S,"alias")}for(let g of x){let S=g.moduleSpecifier;if(!S)continue;let P=S;if(g.isNamespace){let A=g.alias||"*";if(y.has(A))continue;f.push([n,A,null,1,P,g.name||A,"reexport_star"]),y.set(A,"reexport")}else{let A=g.alias||g.name;if(!A||y.has(A))continue;f.push([n,A,null,1,P,g.name||A,"reexport_named"]),y.set(A,"reexport")}}let v=[],K=typeof r=="string"?r:null;if(K==null)try{let g=e.getFullText();K=typeof g=="string"?g:null}catch{K=null}for(let g of m.nodes){let{nodeId:S,nodeName:P,containerKind:A,containerRawKind:N,containerRawKindSource:w,isExported:M,kind:R,rawKind:L,rawKindSource:q,semanticKind:J,start:T,end:D,paramCount:W,metadata:j}=g,le=j&&Object.keys(j).length?JSON.stringify(j):null,ge=d.get(S)??null;v.push([S,P??null,R,L??R,q??null,J??null,T,D,M?1:0,A??"module",N??A??"module",w??null,W,null,null,ge,le])}let C=[];for(let g of m.references){let{name:S,kind:P,containerId:A,containerName:N,expression:w,objectName:M,start:R,end:L}=g,q=null,J=null,T=Tt(g.symbol??Wn(e,R),o),D=S?m.localDeclarations.get(S):void 0;D&&(q=D,J=n,T||(T=d.get(D)??null));let W=we({sourceFile:n,sourceStart:R,sourceEnd:L,refKind:P,refName:S,targetFile:J,targetNodeId:q}),j={};w&&(j.expression=w),M&&(j.objectName=M),N&&(j.containerName=N);let le=Object.keys(j).length?JSON.stringify(j):null;C.push([W,n,A,S,P,R,L,q,J,q?"resolved":"unresolved",M??null,null,null,T,le])}let z=[],$=[];for(let g of m.imports){let S=g.moduleSpecifier??null;z.push([n,S,g.isTypeOnly?1:0]),g.defaultImport&&$.push([n,S,"default",g.defaultImport,"default",g.isTypeOnly?1:0]),g.namespaceImport&&$.push([n,S,"namespace",g.namespaceImport,"*",g.isTypeOnly?1:0]);for(let P of g.namedImports){let A=P.alias||P.name;$.push([n,S,"named",A,P.name,g.isTypeOnly?1:0])}}let H=Ue.join(o,n),a=s?.size,h=s?.mtime;if(a===void 0||h===void 0)try{let g=$n.statSync(H);a=g.size,h=Math.floor(g.mtimeMs)}catch{}let b=new Date().toISOString(),E=[n,h??null,a??null,"completed",b],F=null;if(typeof K=="string")F={blobOid:n,content:K};else try{let g=e.getFullText?.();typeof g=="string"&&(F={blobOid:n,content:g})}catch(g){console.log(`[TypescriptIndexer] Failed to compute FTS payload for ${n}:`,g?.message??g)}return{payload:{lang:l,fileRel:n,preDeleted:i,exportRows:f,nodeRows:v,referenceRows:C,importRows:z,importBindingRows:$,fileRow:E,fts:F},fileSize:a,mtime:h}}var Xe=class{constructor(e,n){this.project=null;this.filesProcessed=0;this.projectRoot=e,this.lang=n}getProject(){return this.project||(this.project=new Bn({useInMemoryFileSystem:!0,skipAddingFilesFromTsConfig:!0})),this.project}disposeProject(){if(this.project){try{let e=this.project.getLanguageService().compilerObject;typeof e?.dispose=="function"&&e.dispose()}catch{}this.project=null}}async process(e){let n=this.getProject(),r;try{let i=n.createSourceFile(Ue.join(this.projectRoot,e.relPath),e.content,{overwrite:!0});r=await Xn({sf:i,fileRel:e.relPath,content:e.content,preDeleted:!!e.preDeleted,meta:e.meta,projectRoot:this.projectRoot,lang:e.lang,indexAllNodes:e.indexAllNodes})}catch(i){this.disposeProject(),this.filesProcessed=0;let s=i?.message||String(i);throw new Error(`TypeScript parser failed for ${e.relPath}: ${s}`)}return this.filesProcessed++,this.filesProcessed>=zn&&(this.disposeProject(),this.filesProcessed=0),{payload:r.payload,fileSize:r.fileSize,mtime:r.mtime}}};function Un(t){return t==="ts"?[".ts",".tsx",".mts",".cts"]:t==="js"?[".js",".jsx",".mjs",".cjs"]:[]}function Ve(t){return{id:t,extensions:Un(t),indexingMode:"worker",createIndexer:e=>new Xe(e,t)}}import Ie from"fs";import ne from"path";import{spawn as Yn,spawnSync as Kt}from"child_process";import Vn from"fs";var de=class{constructor(e=5e3){this.maxEntries=e;this.cache=new Map}get(e,n){let r=this.cache.get(e);if(!r)return null;let i=n?.mtime??null,s=n?.size??null;return i!=null&&s!=null&&r.mtime===i&&r.size===s?r.result:null}set(e,n,r){let i=n?.mtime??null,s=n?.size??null;this.cache.set(e,{mtime:i,size:s,result:r}),this.cache.size>this.maxEntries&&this.cache.clear()}};var Qe=class{constructor(e,n,r,i){this.projectRoot=e;this.lang=n;this.parse=r;this.exportKind=i;this.cache=new de}async process(e){let n=e.meta?.mtime,r=e.meta?.size;if(n==null||r==null)try{let o=Vn.statSync(e.absPath);n=Math.floor(o.mtimeMs),r=o.size}catch{}let i=this.cache.get(e.absPath,{mtime:n,size:r});if(i)return ye({lang:this.lang,fileRel:e.relPath,content:e.content,meta:{mtime:n,size:r},preDeleted:e.preDeleted,parsed:i,resolveNodeId:It(e.relPath,i,this.lang),exportKind:this.exportKind??"cli"});let s=null;try{s=await this.parse({absPath:e.absPath,relPath:e.relPath,content:e.content,meta:{mtime:n,size:r},projectRoot:this.projectRoot,lang:this.lang})}catch(o){try{console.log(`[CliContract:${this.lang}] parse threw for ${e.relPath}: ${o?.message||String(o)}`)}catch{}return he(this.lang,e.relPath,{mtime:n,size:r})}return!s||s.error?he(this.lang,e.relPath,{mtime:n,size:r}):(this.cache.set(e.absPath,{mtime:n,size:r},s),ye({lang:this.lang,fileRel:e.relPath,content:e.content,meta:{mtime:n,size:r},preDeleted:e.preDeleted,parsed:s,resolveNodeId:It(e.relPath,s,this.lang),exportKind:this.exportKind??"cli"}))}};function It(t,e,n){let r=new Map;for(let i of e.nodes??[]){if(!i.name||r.has(i.name))continue;let s=`${t}#${i.start}-${i.end}:${ee.getAbbrev(i.kind,n)}`;r.set(i.name,s)}return i=>r.get(i)??null}function G(t){return{id:t.id,extensions:t.extensions,indexingMode:"worker",createIndexer:e=>new Qe(e,t.id,t.parse,t.exportKind),resolveSpan:t.resolve?async(e,n,r)=>t.resolve({projectRoot:e,absPath:n,nodePath:r,lang:t.id}):void 0}}import Qn from"fs";import Te from"path";var Ge=null;function Gn(t){for(let e of t)if(Qn.existsSync(e))return e;return null}function Y(t){let e=Ge?.toolsRoot??process.env.PANDO_TOOLS_ROOT,n=Ge?.runtimeRoot??process.env.PANDO_RUNTIME_ROOT,r=Ge?.resourcesRoot??process.env.PANDO_RESOURCES_ROOT,i=[e?Te.join(e,t):null,n?Te.join(n,"tools",t):null,r?Te.join(r,"tools",t):null,Te.resolve(process.cwd(),"tools",t)].filter(s=>!!s);return Gn(i)}function U(...t){try{let e=t.map(n=>{if(typeof n=="string")return n;try{return JSON.stringify(n)}catch{return String(n)}}).join(" ");process.stderr.write(e+`
|
|
6
|
+
`)}catch{}}var ke=class{constructor(e,n){this.interpreter=e;this.scriptPath=n;this.buffer=Buffer.alloc(0);this.pending=new Map;this.seq=1;this.closed=!1;if(this.proc=Yn(this.interpreter,["-u",this.scriptPath],{stdio:["pipe","pipe","pipe"]}),!this.proc.stdout||!this.proc.stderr||!this.proc.stdin)throw new Error("python worker stdio unavailable");this.proc.stdout.on("data",r=>this.onData(r)),this.proc.stderr.on("data",r=>{U(`[PythonWorker] ${r.toString("utf8").trim()}`)}),this.proc.stdin.on("error",r=>this.handleError(r)),this.proc.on("error",r=>this.handleError(r)),this.proc.on("exit",r=>this.handleError(new Error(`python worker exited with code ${r}`))),this.ready=this.ping()}handleError(e){if(!this.closed){this.closed=!0;for(let[,n]of this.pending)n.timeout&&clearTimeout(n.timeout),n.summary&&U("[PythonCliAdapter] worker error",{interpreter:this.interpreter,error:e.message,...n.summary}),n.reject(e);this.pending.clear()}}onData(e){for(this.buffer=Buffer.concat([this.buffer,e]);this.buffer.length>=4;){let n=this.buffer.readUInt32BE(0);if(this.buffer.length<4+n)return;let r=this.buffer.slice(4,4+n);this.buffer=this.buffer.slice(4+n);let i=null;try{i=JSON.parse(r.toString("utf8"))}catch{continue}let s=this.pending.get(i.id);s&&(this.pending.delete(i.id),s.timeout&&clearTimeout(s.timeout),i.ok?s.resolve(i):s.reject(new Error(i.error||"python worker error")))}}sendMessage(e){if(this.closed)throw new Error("python worker is closed");let n=Buffer.from(JSON.stringify(e),"utf8"),r=Buffer.alloc(4);r.writeUInt32BE(n.length,0),this.proc.stdin.write(r),this.proc.stdin.write(n)}async requestRaw(e,n,r=1e4){let i=this.seq++,s={id:i,op:e,...n},o=Date.now(),l={op:e,id:i};return typeof n?.path=="string"&&(l.path=n.path),typeof n?.nodePath=="string"&&(l.nodePath=n.nodePath),typeof n?.content_b64=="string"&&(l.contentBytes=n.content_b64.length),new Promise((u,m)=>{let d=setTimeout(()=>{this.pending.delete(i),U("[PythonCliAdapter] worker timeout",{op:e,id:i,timeoutMs:r,pending:this.pending.size,interpreter:this.interpreter,...l}),m(new Error(`python worker timeout (${e})`))},r);this.pending.set(i,{resolve:u,reject:m,timeout:d,summary:l}),this.pending.size%200===0&&U("[PythonCliAdapter] worker pending",{op:e,pending:this.pending.size,interpreter:this.interpreter});try{this.sendMessage(s)}catch(f){clearTimeout(d),this.pending.delete(i),m(f)}})}async request(e,n,r=1e4){await this.ready;let i=Date.now(),s=await this.requestRaw(e,n,r),o=Date.now()-i;return o>2e3&&U("[PythonCliAdapter] worker slow",{op:e,ms:o,pending:this.pending.size,interpreter:this.interpreter,path:n?.path}),s}async ping(){await this.requestRaw("ping",{},5e3)}async parse(e){let n=Buffer.from(e.content,"utf8").toString("base64"),r=await this.request("parse",{path:e.path,content_b64:n,encoding:e.encoding});return r.nodes?r:null}async resolve(e){let n=Buffer.from(e.content,"utf8").toString("base64"),r=await this.request("resolve",{path:e.path,nodePath:e.nodePath,content_b64:n,encoding:e.encoding});return typeof r.start=="number"&&typeof r.end=="number"?r:null}},Zn=`
|
|
7
|
+
import ast, json, sys, os
|
|
8
|
+
|
|
9
|
+
path = sys.argv[1]
|
|
10
|
+
with open(path, 'r', encoding='utf-8', errors='ignore') as f:
|
|
11
|
+
src = f.read()
|
|
12
|
+
|
|
13
|
+
# line start offsets
|
|
14
|
+
line_starts = [0]
|
|
15
|
+
for line in src.splitlines(True):
|
|
16
|
+
line_starts.append(line_starts[-1] + len(line))
|
|
17
|
+
|
|
18
|
+
def offset(lineno, col):
|
|
19
|
+
if lineno is None:
|
|
20
|
+
return 0
|
|
21
|
+
if lineno < 1:
|
|
22
|
+
lineno = 1
|
|
23
|
+
if lineno >= len(line_starts):
|
|
24
|
+
return line_starts[-1]
|
|
25
|
+
return line_starts[lineno - 1] + (col or 0)
|
|
26
|
+
|
|
27
|
+
def node_span(n):
|
|
28
|
+
start = offset(getattr(n, 'lineno', None), getattr(n, 'col_offset', 0))
|
|
29
|
+
end = offset(getattr(n, 'end_lineno', getattr(n, 'lineno', None)), getattr(n, 'end_col_offset', 0))
|
|
30
|
+
if end < start:
|
|
31
|
+
end = start
|
|
32
|
+
return start, end
|
|
33
|
+
|
|
34
|
+
nodes = []
|
|
35
|
+
imports = []
|
|
36
|
+
bindings = []
|
|
37
|
+
references = []
|
|
38
|
+
class_names = set()
|
|
39
|
+
module_public = set()
|
|
40
|
+
all_exports = None
|
|
41
|
+
|
|
42
|
+
module_name = os.path.splitext(os.path.basename(path))[0] if path else "__main__"
|
|
43
|
+
scope_stack = [module_name]
|
|
44
|
+
nodes.append({
|
|
45
|
+
'name': module_name,
|
|
46
|
+
'kind': 'Namespace',
|
|
47
|
+
'rawKind': 'Module',
|
|
48
|
+
'rawKindSource': 'python-ast',
|
|
49
|
+
'semanticKind': 'namespace',
|
|
50
|
+
'start': 0,
|
|
51
|
+
'end': len(src),
|
|
52
|
+
'isExported': 1,
|
|
53
|
+
'containerKind': None,
|
|
54
|
+
'containerRawKind': None,
|
|
55
|
+
'containerRawKindSource': None,
|
|
56
|
+
'paramCount': None,
|
|
57
|
+
'qualifiedName': module_name,
|
|
58
|
+
'scopeChain': [module_name],
|
|
59
|
+
'metadata': { 'path': path },
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
def decorator_names(node_list):
|
|
63
|
+
out = []
|
|
64
|
+
for d in node_list or []:
|
|
65
|
+
try:
|
|
66
|
+
if isinstance(d, ast.Name):
|
|
67
|
+
out.append(d.id)
|
|
68
|
+
elif isinstance(d, ast.Attribute):
|
|
69
|
+
out.append(d.attr)
|
|
70
|
+
elif hasattr(ast, 'Call') and isinstance(d, ast.Call):
|
|
71
|
+
if isinstance(d.func, ast.Name):
|
|
72
|
+
out.append(d.func.id)
|
|
73
|
+
elif isinstance(d.func, ast.Attribute):
|
|
74
|
+
out.append(d.func.attr)
|
|
75
|
+
except Exception:
|
|
76
|
+
pass
|
|
77
|
+
return out
|
|
78
|
+
|
|
79
|
+
def annotation_text(n):
|
|
80
|
+
try:
|
|
81
|
+
return ast.get_source_segment(src, n)
|
|
82
|
+
except Exception:
|
|
83
|
+
return None
|
|
84
|
+
|
|
85
|
+
def raw_kind(n):
|
|
86
|
+
try:
|
|
87
|
+
return n.__class__.__name__
|
|
88
|
+
except Exception:
|
|
89
|
+
return None
|
|
90
|
+
|
|
91
|
+
def base_name(txt):
|
|
92
|
+
try:
|
|
93
|
+
return txt.split('.')[-1]
|
|
94
|
+
except Exception:
|
|
95
|
+
return txt
|
|
96
|
+
|
|
97
|
+
ENUM_BASES = set(['Enum', 'IntEnum', 'StrEnum', 'Flag', 'IntFlag'])
|
|
98
|
+
META_BASES = set(['type', 'ABCMeta', 'EnumMeta'])
|
|
99
|
+
|
|
100
|
+
def is_enum_base(txt):
|
|
101
|
+
if not txt:
|
|
102
|
+
return False
|
|
103
|
+
name = base_name(txt)
|
|
104
|
+
return name in ENUM_BASES
|
|
105
|
+
|
|
106
|
+
def is_metaclass_base(txt):
|
|
107
|
+
if not txt:
|
|
108
|
+
return False
|
|
109
|
+
name = base_name(txt)
|
|
110
|
+
return name in META_BASES
|
|
111
|
+
|
|
112
|
+
class Visitor(ast.NodeVisitor):
|
|
113
|
+
def __init__(self):
|
|
114
|
+
self.class_name = None
|
|
115
|
+
self.class_is_enum = False
|
|
116
|
+
self.class_stack = []
|
|
117
|
+
self.func_name = None
|
|
118
|
+
self.func_stack = []
|
|
119
|
+
self.scope_stack = list(scope_stack)
|
|
120
|
+
|
|
121
|
+
def visit_ClassDef(self, n):
|
|
122
|
+
start, end = node_span(n)
|
|
123
|
+
name = n.name
|
|
124
|
+
class_names.add(name)
|
|
125
|
+
deco = decorator_names(getattr(n, 'decorator_list', None))
|
|
126
|
+
bases = []
|
|
127
|
+
is_enum = False
|
|
128
|
+
is_meta = False
|
|
129
|
+
meta_value = None
|
|
130
|
+
try:
|
|
131
|
+
for kw in getattr(n, 'keywords', []) or []:
|
|
132
|
+
if getattr(kw, 'arg', None) == 'metaclass':
|
|
133
|
+
meta_value = annotation_text(kw.value)
|
|
134
|
+
except Exception:
|
|
135
|
+
meta_value = None
|
|
136
|
+
try:
|
|
137
|
+
for b in getattr(n, 'bases', []) or []:
|
|
138
|
+
txt = annotation_text(b)
|
|
139
|
+
if txt:
|
|
140
|
+
bases.append(txt)
|
|
141
|
+
if is_enum_base(txt):
|
|
142
|
+
is_enum = True
|
|
143
|
+
if is_metaclass_base(txt):
|
|
144
|
+
is_meta = True
|
|
145
|
+
except Exception:
|
|
146
|
+
pass
|
|
147
|
+
is_exported = 0 if name.startswith('_') else 1
|
|
148
|
+
if is_exported:
|
|
149
|
+
module_public.add(name)
|
|
150
|
+
metadata = {
|
|
151
|
+
'decorators': deco,
|
|
152
|
+
'extends': bases if bases else None,
|
|
153
|
+
'visibility': 'private' if name.startswith('_') else 'public'
|
|
154
|
+
}
|
|
155
|
+
if meta_value:
|
|
156
|
+
metadata['metaclass'] = meta_value
|
|
157
|
+
if is_meta:
|
|
158
|
+
metadata['isMetaclass'] = True
|
|
159
|
+
if is_enum:
|
|
160
|
+
metadata['isEnum'] = True
|
|
161
|
+
scope_chain = self.scope_stack + [name]
|
|
162
|
+
nodes.append({
|
|
163
|
+
'name': name,
|
|
164
|
+
'kind': 'Enum' if is_enum else 'Class',
|
|
165
|
+
'rawKind': raw_kind(n),
|
|
166
|
+
'rawKindSource': 'python-ast',
|
|
167
|
+
'semanticKind': 'enum' if is_enum else 'class',
|
|
168
|
+
'start': start,
|
|
169
|
+
'end': end,
|
|
170
|
+
'isExported': is_exported,
|
|
171
|
+
'containerKind': None,
|
|
172
|
+
'containerRawKind': None,
|
|
173
|
+
'containerRawKindSource': None,
|
|
174
|
+
'paramCount': None,
|
|
175
|
+
'qualifiedName': '.'.join(scope_chain),
|
|
176
|
+
'scopeChain': scope_chain,
|
|
177
|
+
'metadata': metadata,
|
|
178
|
+
})
|
|
179
|
+
prev = self.class_name
|
|
180
|
+
prev_enum = self.class_is_enum
|
|
181
|
+
self.class_stack.append({ 'name': name, 'is_enum': is_enum })
|
|
182
|
+
self.class_name = name
|
|
183
|
+
self.class_is_enum = is_enum
|
|
184
|
+
self.scope_stack.append(name)
|
|
185
|
+
self.generic_visit(n)
|
|
186
|
+
self.scope_stack.pop()
|
|
187
|
+
self.class_stack.pop()
|
|
188
|
+
self.class_name = prev
|
|
189
|
+
self.class_is_enum = prev_enum
|
|
190
|
+
|
|
191
|
+
def visit_FunctionDef(self, n):
|
|
192
|
+
start, end = node_span(n)
|
|
193
|
+
name = n.name
|
|
194
|
+
param_count = len(getattr(n, 'args', {}).args) if hasattr(n, 'args') else None
|
|
195
|
+
is_async = isinstance(n, ast.AsyncFunctionDef)
|
|
196
|
+
deco = decorator_names(getattr(n, 'decorator_list', None))
|
|
197
|
+
ret = annotation_text(getattr(n, 'returns', None)) if hasattr(n, 'returns') else None
|
|
198
|
+
is_static = 'staticmethod' in deco
|
|
199
|
+
is_abstract = 'abstractmethod' in deco
|
|
200
|
+
is_readonly = 'property' in deco
|
|
201
|
+
visibility = 'private' if name.startswith('_') else 'public'
|
|
202
|
+
scope_chain = self.scope_stack + [name]
|
|
203
|
+
if self.class_name:
|
|
204
|
+
sem_kind = 'property' if is_readonly else 'method'
|
|
205
|
+
nodes.append({
|
|
206
|
+
'name': name,
|
|
207
|
+
'kind': 'Method',
|
|
208
|
+
'rawKind': raw_kind(n),
|
|
209
|
+
'rawKindSource': 'python-ast',
|
|
210
|
+
'semanticKind': sem_kind,
|
|
211
|
+
'start': start,
|
|
212
|
+
'end': end,
|
|
213
|
+
'isExported': 0,
|
|
214
|
+
'containerKind': 'Class',
|
|
215
|
+
'containerRawKind': 'ClassDef',
|
|
216
|
+
'containerRawKindSource': 'python-ast',
|
|
217
|
+
'paramCount': param_count,
|
|
218
|
+
'qualifiedName': '.'.join(scope_chain),
|
|
219
|
+
'scopeChain': scope_chain,
|
|
220
|
+
'metadata': { 'isAsync': is_async, 'containerName': self.class_name, 'decorators': deco, 'returnType': ret, 'isStatic': is_static, 'isAbstract': is_abstract, 'isReadonly': is_readonly, 'visibility': visibility },
|
|
221
|
+
})
|
|
222
|
+
else:
|
|
223
|
+
is_exported = 0 if name.startswith('_') else 1
|
|
224
|
+
if is_exported:
|
|
225
|
+
module_public.add(name)
|
|
226
|
+
nodes.append({
|
|
227
|
+
'name': name,
|
|
228
|
+
'kind': 'Function',
|
|
229
|
+
'rawKind': raw_kind(n),
|
|
230
|
+
'rawKindSource': 'python-ast',
|
|
231
|
+
'semanticKind': 'function',
|
|
232
|
+
'start': start,
|
|
233
|
+
'end': end,
|
|
234
|
+
'isExported': is_exported,
|
|
235
|
+
'containerKind': None,
|
|
236
|
+
'containerRawKind': None,
|
|
237
|
+
'containerRawKindSource': None,
|
|
238
|
+
'paramCount': param_count,
|
|
239
|
+
'qualifiedName': '.'.join(scope_chain),
|
|
240
|
+
'scopeChain': scope_chain,
|
|
241
|
+
'metadata': { 'isAsync': is_async, 'decorators': deco, 'returnType': ret, 'isAbstract': is_abstract, 'visibility': visibility },
|
|
242
|
+
})
|
|
243
|
+
prev = self.func_name
|
|
244
|
+
self.func_name = name
|
|
245
|
+
self.func_stack.append(name)
|
|
246
|
+
self.scope_stack.append(name)
|
|
247
|
+
self.generic_visit(n)
|
|
248
|
+
self.scope_stack.pop()
|
|
249
|
+
self.func_stack.pop()
|
|
250
|
+
self.func_name = prev
|
|
251
|
+
|
|
252
|
+
def visit_AsyncFunctionDef(self, n):
|
|
253
|
+
self.visit_FunctionDef(n)
|
|
254
|
+
|
|
255
|
+
def visit_Import(self, n):
|
|
256
|
+
for alias in n.names:
|
|
257
|
+
module = alias.name
|
|
258
|
+
imports.append({ 'module': module, 'isTypeOnly': 0 })
|
|
259
|
+
local = alias.asname or alias.name
|
|
260
|
+
if local and not local.startswith('_'):
|
|
261
|
+
module_public.add(local)
|
|
262
|
+
bindings.append({
|
|
263
|
+
'module': module,
|
|
264
|
+
'localName': local,
|
|
265
|
+
'importedName': alias.name,
|
|
266
|
+
'kind': 'named',
|
|
267
|
+
'isTypeOnly': 0,
|
|
268
|
+
})
|
|
269
|
+
|
|
270
|
+
def visit_ImportFrom(self, n):
|
|
271
|
+
module = n.module
|
|
272
|
+
imports.append({ 'module': module, 'isTypeOnly': 0 })
|
|
273
|
+
for alias in n.names:
|
|
274
|
+
if alias.name == '*':
|
|
275
|
+
bindings.append({
|
|
276
|
+
'module': module,
|
|
277
|
+
'localName': alias.asname or '*',
|
|
278
|
+
'importedName': '*',
|
|
279
|
+
'kind': 'namespace',
|
|
280
|
+
'isTypeOnly': 0,
|
|
281
|
+
})
|
|
282
|
+
else:
|
|
283
|
+
bindings.append({
|
|
284
|
+
'module': module,
|
|
285
|
+
'localName': alias.asname or alias.name,
|
|
286
|
+
'importedName': alias.name,
|
|
287
|
+
'kind': 'named',
|
|
288
|
+
'isTypeOnly': 0,
|
|
289
|
+
})
|
|
290
|
+
local_name = alias.asname or alias.name
|
|
291
|
+
if local_name and not local_name.startswith('_'):
|
|
292
|
+
module_public.add(local_name)
|
|
293
|
+
|
|
294
|
+
def visit_Assign(self, n):
|
|
295
|
+
# module-level or class-level names
|
|
296
|
+
global all_exports
|
|
297
|
+
targets = getattr(n, 'targets', [])
|
|
298
|
+
for t in targets:
|
|
299
|
+
if isinstance(t, ast.Name):
|
|
300
|
+
start, end = node_span(t)
|
|
301
|
+
name = t.id
|
|
302
|
+
is_exported = 0 if name.startswith('_') else 1
|
|
303
|
+
scope_chain = self.scope_stack + [name]
|
|
304
|
+
if self.class_name:
|
|
305
|
+
if self.class_is_enum:
|
|
306
|
+
nodes.append({
|
|
307
|
+
'name': name,
|
|
308
|
+
'kind': 'EnumMember',
|
|
309
|
+
'rawKind': raw_kind(t),
|
|
310
|
+
'rawKindSource': 'python-ast',
|
|
311
|
+
'semanticKind': 'enum',
|
|
312
|
+
'start': start,
|
|
313
|
+
'end': end,
|
|
314
|
+
'isExported': 0,
|
|
315
|
+
'containerKind': 'Enum',
|
|
316
|
+
'containerRawKind': 'ClassDef',
|
|
317
|
+
'containerRawKindSource': 'python-ast',
|
|
318
|
+
'paramCount': None,
|
|
319
|
+
'qualifiedName': '.'.join(scope_chain),
|
|
320
|
+
'scopeChain': scope_chain,
|
|
321
|
+
'metadata': { 'containerName': self.class_name, 'visibility': 'private' if name.startswith('_') else 'public' },
|
|
322
|
+
})
|
|
323
|
+
continue
|
|
324
|
+
nodes.append({
|
|
325
|
+
'name': name,
|
|
326
|
+
'kind': 'Field',
|
|
327
|
+
'rawKind': raw_kind(t),
|
|
328
|
+
'rawKindSource': 'python-ast',
|
|
329
|
+
'semanticKind': 'field',
|
|
330
|
+
'start': start,
|
|
331
|
+
'end': end,
|
|
332
|
+
'isExported': 0,
|
|
333
|
+
'containerKind': 'Class',
|
|
334
|
+
'containerRawKind': 'ClassDef',
|
|
335
|
+
'containerRawKindSource': 'python-ast',
|
|
336
|
+
'paramCount': None,
|
|
337
|
+
'qualifiedName': '.'.join(scope_chain),
|
|
338
|
+
'scopeChain': scope_chain,
|
|
339
|
+
'metadata': { 'containerName': self.class_name, 'visibility': 'private' if name.startswith('_') else 'public' },
|
|
340
|
+
})
|
|
341
|
+
else:
|
|
342
|
+
if is_exported:
|
|
343
|
+
module_public.add(name)
|
|
344
|
+
nodes.append({
|
|
345
|
+
'name': name,
|
|
346
|
+
'kind': 'Variable',
|
|
347
|
+
'rawKind': raw_kind(t),
|
|
348
|
+
'rawKindSource': 'python-ast',
|
|
349
|
+
'semanticKind': 'variable',
|
|
350
|
+
'start': start,
|
|
351
|
+
'end': end,
|
|
352
|
+
'isExported': is_exported,
|
|
353
|
+
'containerKind': None,
|
|
354
|
+
'containerRawKind': None,
|
|
355
|
+
'containerRawKindSource': None,
|
|
356
|
+
'paramCount': None,
|
|
357
|
+
'qualifiedName': '.'.join(scope_chain),
|
|
358
|
+
'scopeChain': scope_chain,
|
|
359
|
+
'metadata': { 'visibility': 'private' if name.startswith('_') else 'public' },
|
|
360
|
+
})
|
|
361
|
+
if (not self.class_name) and name == '__all__':
|
|
362
|
+
try:
|
|
363
|
+
if isinstance(n.value, (ast.List, ast.Tuple)):
|
|
364
|
+
all_list = []
|
|
365
|
+
for elt in n.value.elts:
|
|
366
|
+
if isinstance(elt, ast.Str):
|
|
367
|
+
all_list.append(elt.s)
|
|
368
|
+
elif hasattr(ast, 'Constant') and isinstance(elt, ast.Constant) and isinstance(elt.value, str):
|
|
369
|
+
all_list.append(elt.value)
|
|
370
|
+
if all_list:
|
|
371
|
+
all_exports = all_list
|
|
372
|
+
except Exception:
|
|
373
|
+
pass
|
|
374
|
+
self.generic_visit(n)
|
|
375
|
+
|
|
376
|
+
def visit_Call(self, n):
|
|
377
|
+
try:
|
|
378
|
+
func = n.func
|
|
379
|
+
call_name = None
|
|
380
|
+
object_name = None
|
|
381
|
+
expr_text = None
|
|
382
|
+
if isinstance(func, ast.Name):
|
|
383
|
+
call_name = func.id
|
|
384
|
+
elif isinstance(func, ast.Attribute):
|
|
385
|
+
call_name = func.attr
|
|
386
|
+
if isinstance(func.value, ast.Name):
|
|
387
|
+
object_name = func.value.id
|
|
388
|
+
try:
|
|
389
|
+
expr_text = ast.get_source_segment(src, func)
|
|
390
|
+
except Exception:
|
|
391
|
+
expr_text = None
|
|
392
|
+
start, end = node_span(n)
|
|
393
|
+
kind = 'new' if call_name in class_names else 'call'
|
|
394
|
+
container_name = self.class_name or self.func_name
|
|
395
|
+
container_kind = 'Class' if self.class_name else ('Function' if self.func_name else None)
|
|
396
|
+
try:
|
|
397
|
+
arity = len(getattr(n, 'args', []) or []) + len(getattr(n, 'keywords', []) or [])
|
|
398
|
+
except Exception:
|
|
399
|
+
arity = 0
|
|
400
|
+
container_qualified_name = '.'.join(self.scope_stack) if self.scope_stack else None
|
|
401
|
+
references.append({
|
|
402
|
+
'name': call_name,
|
|
403
|
+
'kind': kind,
|
|
404
|
+
'start': start,
|
|
405
|
+
'end': end,
|
|
406
|
+
'expression': expr_text,
|
|
407
|
+
'objectName': object_name,
|
|
408
|
+
'containerName': container_name,
|
|
409
|
+
'containerKind': container_kind,
|
|
410
|
+
'receiverName': object_name,
|
|
411
|
+
'arity': arity,
|
|
412
|
+
'containerQualifiedName': container_qualified_name,
|
|
413
|
+
})
|
|
414
|
+
except Exception:
|
|
415
|
+
pass
|
|
416
|
+
self.generic_visit(n)
|
|
417
|
+
|
|
418
|
+
try:
|
|
419
|
+
tree = ast.parse(src, filename=path)
|
|
420
|
+
Visitor().visit(tree)
|
|
421
|
+
out = { 'nodes': nodes, 'imports': imports, 'importBindings': bindings, 'references': references, 'modulePublic': sorted(list(module_public)), 'explicitExports': all_exports }
|
|
422
|
+
print(json.dumps(out))
|
|
423
|
+
except Exception as e:
|
|
424
|
+
print(json.dumps({ 'error': str(e) }))
|
|
425
|
+
sys.exit(2)
|
|
426
|
+
`,er=`
|
|
427
|
+
import ast, json, sys
|
|
428
|
+
|
|
429
|
+
path = sys.argv[1]
|
|
430
|
+
node_path = sys.argv[2]
|
|
431
|
+
with open(path, 'r', encoding='utf-8', errors='ignore') as f:
|
|
432
|
+
src = f.read()
|
|
433
|
+
|
|
434
|
+
# line start offsets
|
|
435
|
+
line_starts = [0]
|
|
436
|
+
for line in src.splitlines(True):
|
|
437
|
+
line_starts.append(line_starts[-1] + len(line))
|
|
438
|
+
|
|
439
|
+
def offset(lineno, col):
|
|
440
|
+
if lineno is None:
|
|
441
|
+
return 0
|
|
442
|
+
if lineno < 1:
|
|
443
|
+
lineno = 1
|
|
444
|
+
if lineno >= len(line_starts):
|
|
445
|
+
return line_starts[-1]
|
|
446
|
+
return line_starts[lineno - 1] + (col or 0)
|
|
447
|
+
|
|
448
|
+
def node_span(n):
|
|
449
|
+
start = offset(getattr(n, 'lineno', None), getattr(n, 'col_offset', 0))
|
|
450
|
+
end = offset(getattr(n, 'end_lineno', getattr(n, 'lineno', None)), getattr(n, 'end_col_offset', 0))
|
|
451
|
+
if end < start:
|
|
452
|
+
end = start
|
|
453
|
+
return start, end
|
|
454
|
+
|
|
455
|
+
def parse_range(node_path):
|
|
456
|
+
clean = node_path
|
|
457
|
+
if clean.startswith('SyntaxError:') or clean.startswith('CompileError:'):
|
|
458
|
+
clean = clean.split(':', 1)[1]
|
|
459
|
+
if '#' in clean:
|
|
460
|
+
clean = clean.split('#', 1)[1]
|
|
461
|
+
if ':' in clean:
|
|
462
|
+
clean = clean.rsplit(':', 1)[0]
|
|
463
|
+
if '-' not in clean:
|
|
464
|
+
return None
|
|
465
|
+
parts = clean.split('-', 1)
|
|
466
|
+
try:
|
|
467
|
+
return int(parts[0]), int(parts[1])
|
|
468
|
+
except Exception:
|
|
469
|
+
return None
|
|
470
|
+
|
|
471
|
+
target = parse_range(node_path)
|
|
472
|
+
if target is None:
|
|
473
|
+
print(json.dumps({ 'error': 'invalid nodePath' }))
|
|
474
|
+
sys.exit(2)
|
|
475
|
+
|
|
476
|
+
target_start, target_end = target
|
|
477
|
+
resolved = None
|
|
478
|
+
|
|
479
|
+
try:
|
|
480
|
+
tree = ast.parse(src, filename=path)
|
|
481
|
+
for n in ast.walk(tree):
|
|
482
|
+
s, e = node_span(n)
|
|
483
|
+
if s == target_start and e == target_end:
|
|
484
|
+
body_start = None
|
|
485
|
+
body_end = None
|
|
486
|
+
if hasattr(n, 'body') and isinstance(n.body, list) and len(n.body) > 0:
|
|
487
|
+
try:
|
|
488
|
+
bs, _ = node_span(n.body[0])
|
|
489
|
+
_, be = node_span(n.body[-1])
|
|
490
|
+
body_start = bs
|
|
491
|
+
body_end = be
|
|
492
|
+
except Exception:
|
|
493
|
+
body_start = None
|
|
494
|
+
body_end = None
|
|
495
|
+
try:
|
|
496
|
+
text = src[s:e]
|
|
497
|
+
except Exception:
|
|
498
|
+
text = None
|
|
499
|
+
resolved = { 'start': s, 'end': e, 'bodyStart': body_start, 'bodyEnd': body_end, 'text': text }
|
|
500
|
+
break
|
|
501
|
+
if not resolved:
|
|
502
|
+
print(json.dumps({ 'error': 'node not found' }))
|
|
503
|
+
sys.exit(2)
|
|
504
|
+
print(json.dumps(resolved))
|
|
505
|
+
except Exception as e:
|
|
506
|
+
print(json.dumps({ 'error': str(e) }))
|
|
507
|
+
sys.exit(2)
|
|
508
|
+
`;function Ft(t){let e=ne.resolve(t,"tools/python-indexer/pando_python_worker.py");if(Ie.existsSync(e))return e;let n=Y("python-indexer/pando_python_worker.py");if(n)return n;let r=ne.resolve(__dirname,"../../../../../tools/python-indexer/pando_python_worker.py");return Ie.existsSync(r)?r:null}var fe=new Map;function pe(t){try{return Ie.readFileSync(t,"utf8")}catch{return null}}function Se(t){if(!t)return null;let e=t.match(/(\d+)\.(\d+)/);return e?{major:Number(e[1]),minor:Number(e[2])}:null}function tr(t){let e=pe(ne.join(t,"pyproject.toml"));if(e){let l=e.match(/requires-python\s*=\s*"([^"]+)"/i),u=Se(l?.[1]??null);if(u)return u}let n=pe(ne.join(t,"setup.cfg"));if(n){let l=n.match(/python_requires\s*=\s*([\w\d\.<>~=\s]+)/i),u=Se(l?.[1]??null);if(u)return u}let r=pe(ne.join(t,"setup.py"));if(r){let l=r.match(/python_requires\s*=\s*['\"]([^'\"]+)['\"]/i),u=Se(l?.[1]??null);if(u)return u}let i=pe(ne.join(t,"tox.ini"));if(i){let l=i.match(/envlist\s*=\s*([^\n]+)/i);if(l&&l[1]){let u=l[1].split(/[,\s]+/).filter(Boolean);for(let m of u){let d=m.match(/py(\d)(\d)/i);if(d)return{major:Number(d[1]),minor:Number(d[2])}}}}let s=pe(ne.join(t,".python-version"));if(s){let l=Se(s.trim());if(l)return l}let o=pe(ne.join(t,"runtime.txt"));if(o){let l=o.match(/python-(\d+\.\d+)/i),u=Se(l?.[1]??null);if(u)return u}return null}function De(t){return tr(t)?.major===2?["python2","python","python3"]:["python3","python","python2"]}async function nr(t,e,n){let r=Ft(t);if(!r)return null;let i=De(t);for(let s of i){let o=`${s}::${r}`,l=fe.get(o);if(!l)try{l=new ke(s,r),fe.set(o,l)}catch{continue}try{let u=await l.parse({path:e,content:n,encoding:"utf-8"});if(u)return u}catch{U("[PythonCliAdapter] worker parse error",{file:e,interpreter:s}),fe.delete(o)}}return null}async function rr(t,e,n,r){let i=Ft(t);if(!i)return null;let s=De(t);for(let o of s){let l=`${o}::${i}`,u=fe.get(l);if(!u)try{u=new ke(o,i),fe.set(l,u)}catch{continue}try{let m=await u.resolve({path:e,nodePath:r,content:n,encoding:"utf-8"});if(m)return m}catch{U("[PythonCliAdapter] worker resolve error",{file:e,interpreter:o,nodePath:r}),fe.delete(l)}}return null}function kt(t,e){let n=Kt(t,["-c",Zn,e],{encoding:"utf8"});if(n.error||typeof n.stdout!="string")return null;try{let r=JSON.parse(n.stdout.trim()||"{}");return r&&r.error?null:r}catch{return null}}function Dt(t,e,n){let r=Kt(t,["-c",er,e,n],{encoding:"utf8"});if(r.error||typeof r.stdout!="string")return null;try{let i=JSON.parse(r.stdout.trim()||"{}");return i&&i.error||typeof i.start!="number"||typeof i.end!="number"?null:i}catch{return null}}async function ir(t){let e=Date.now(),n=!1,r=null;try{r=await nr(t.projectRoot,t.absPath,t.content),n=!!r}catch{}if(!r){let o=De(t.projectRoot),l=null;for(let u of o)if(r=kt(u,t.absPath),r){l=u;break}if(!r&&o.length>1){for(let u of o.slice().reverse())if(r=kt(u,t.absPath),r){l=u;break}}if(!r){U(`[PythonCliAdapter] parse failed for ${t.relPath} (interpreters tried: ${o.join(", ")})`);let u=Date.now()-e;return u>2e3&&U("[PythonCliAdapter] parse slow (failed)",{file:t.relPath,ms:u}),null}l&&U(`[PythonCliAdapter] parse ok for ${t.relPath} via ${l}`)}let i=[];for(let o of r.references||[]){let l={};o.expression&&(l.expression=o.expression),o.objectName&&(l.objectName=o.objectName),o.containerName&&(l.containerName=o.containerName),o.containerKind&&(l.containerKind=o.containerKind),i.push({sourceStart:o.start,sourceEnd:o.end,refKind:o.kind,refName:o.name,receiverName:o.receiverName??o.objectName??null,arity:typeof o.arity=="number"?o.arity:null,containerQualifiedName:o.containerQualifiedName??null,targetSymbolKey:o.targetSymbolKey??null,metadata:Object.keys(l).length?l:null})}let s=Date.now()-e;return s>2e3&&U("[PythonCliAdapter] parse slow",{file:t.relPath,ms:s,usedWorker:n}),{nodes:r.nodes,imports:r.imports,importBindings:r.importBindings,references:i,modulePublic:r.modulePublic??void 0,explicitExports:r.explicitExports??void 0}}function Mt(){return G({id:"python",extensions:[".py",".pyw",".pyi"],exportKind:"named",parse:({absPath:t,relPath:e,projectRoot:n,content:r})=>ir({absPath:t,relPath:e,projectRoot:n,content:r}),resolve:async({absPath:t,nodePath:e,projectRoot:n})=>{try{let i=Ie.readFileSync(t,"utf8"),s=await rr(n,t,i,e);if(s)return s}catch{}let r=De(n);for(let i of r){let s=Dt(i,t,e);if(s)return s}for(let i of r.slice().reverse()){let s=Dt(i,t,e);if(s)return s}return null}})}import Ot from"fs";import Lt from"path";import{spawn as sr,spawnSync as Ms}from"child_process";var ar=256e3,or=32;function re(...t){try{let e=t.map(n=>{if(typeof n=="string")return n;try{return JSON.stringify(n)}catch{return String(n)}}).join(" ");process.stderr.write(e+`
|
|
509
|
+
`)}catch{}}var Ye=class{constructor(e){this.cmd=e;this.proc=null;this.buffer="";this.pending=new Map;this.seq=1;this.closed=!1;this.ensureProcess()}ensureProcess(){if(!(this.proc&&!this.closed)){if(this.closed=!1,this.proc=sr(this.cmd,["--server"],{stdio:["pipe","pipe","pipe"]}),!this.proc.stdout||!this.proc.stderr||!this.proc.stdin)throw this.closed=!0,new Error("csharp indexer stdio unavailable");this.proc.stdout.on("data",e=>this.onData(e)),this.proc.stderr.on("data",e=>{re(`[CSharpIndexer] ${e.toString("utf8").trim()}`)}),this.proc.stdin.on("error",e=>this.handleExit(e)),this.proc.on("error",e=>this.handleExit(e)),this.proc.on("exit",e=>this.handleExit(new Error(`csharp indexer exited with code ${e}`)))}}handleExit(e){if(!this.closed){this.closed=!0;for(let[,n]of this.pending)n.reject(e);this.pending.clear()}}onData(e){for(this.buffer+=e.toString("utf8");;){let n=this.buffer.indexOf(`
|
|
510
|
+
`);if(n<0)break;let r=this.buffer.slice(0,n).trim();if(this.buffer=this.buffer.slice(n+1),!r)continue;let i=null;try{i=JSON.parse(r)}catch{continue}let s=this.pending.get(i.id);s&&(this.pending.delete(i.id),i.ok?s.resolve(i):s.reject(new Error(i.error||"csharp server error")))}}async request(e,n=1){this.ensureProcess();let r=this.seq++;return new Promise((i,s)=>{let o={id:r,...e};this.pending.set(r,{resolve:i,reject:s});try{this.proc.stdin.write(`${JSON.stringify(o)}
|
|
511
|
+
`)}catch(l){if(this.pending.delete(r),n>0){try{this.handleExit(l)}catch{}return this.request(e,n-1).then(i,s)}s(l)}})}async parseBatch(e){let n=await this.request({op:"parse",files:e});return"results"in n?n.results.map(r=>r.ok&&r.result?r.result:null):"result"in n?[n.result]:e.map(()=>null)}async resolve(e){let n=await this.request({op:"resolve",...e});return"result"in n&&n.result&&typeof n.result.start=="number"?n.result:null}async resolveReferences(e){let n=await this.request({op:"resolve-references",...e});return"result"in n&&n.result?n.result:null}},Ze=class{constructor(e){this.client=e;this.queue=[];this.scheduled=!1}enqueue(e){return new Promise((n,r)=>{this.queue.push({input:e,resolve:n,reject:r,startedAt:Date.now()}),this.scheduled||(this.scheduled=!0,setImmediate(()=>this.flush()))})}async flush(){for(this.scheduled=!1;this.queue.length;){let e=[],n=0;for(;this.queue.length&&e.length<or;){let r=this.queue[0];if(e.length>0&&n+r.input.size>ar)break;e.push(this.queue.shift()),n+=r.input.size}try{let r=await this.client.parseBatch(e.map(i=>({file:i.input.file,root:i.input.root,lang:i.input.lang})));for(let i=0;i<e.length;i+=1){let s=e[i],o=r[i]??null,l=Date.now()-s.startedAt;l>2e3&&re(`[${new Date().toISOString()}] [CSharpCliAdapter] parse slow`,{file:s.input.file,ms:l,path:"custom",ok:!!o}),o||re(`[${new Date().toISOString()}] [CSharpCliAdapter] parse failed`,{file:s.input.file,ms:l,path:"custom"}),s.resolve(o)}}catch(r){for(let i of e)i.reject(r)}}}},jt=new Map,$t=new Map;function lr(t){let e=process.platform==="win32"?".cmd":"",n=Y(`csharp-indexer/bin/pando-csharp-indexer${e}`);if(n)return n;if(t){let i=Lt.resolve(t,"tools/csharp-indexer/bin/pando-csharp-indexer"+e);if(Ot.existsSync(i))return i}let r=Lt.resolve(__dirname,"../../../../../tools/csharp-indexer/bin/pando-csharp-indexer"+e);return Ot.existsSync(r)?r:null}function Bt(t){let e=process.env.PANDO_CSHARP_INDEXER_CMD||lr(t);if(!e)return null;let n=jt.get(e);n||(n=new Ye(e),jt.set(e,n));let r=$t.get(e);return r||(r=new Ze(n),$t.set(e,r)),{client:n,batcher:r}}async function cr(t,e,n){let r=Bt(e);if(!r)return null;try{return await r.batcher.enqueue({file:t,root:e,lang:"csharp",size:n})}catch(i){return re(`[${new Date().toISOString()}] [CSharpCliAdapter] parse error`,{file:t,error:i?.message||i,path:"custom"}),null}}async function ur(t,e,n){let r=await cr(t,e,n);return r||null}function zt(){return G({id:"csharp",extensions:[".cs",".csx",".cshtml",".razor"],parse:({absPath:t,projectRoot:e,content:n,meta:r})=>{let i=r?.size??Buffer.byteLength(n,"utf8");return ur(t,e,i)},resolve:({absPath:t,nodePath:e,projectRoot:n})=>{let r=Date.now(),i=Bt(n);return i?i.client.resolve({file:t,root:n,lang:"csharp",nodePath:e}).then(s=>{let o=Date.now()-r;return o>2e3&&re(`[${new Date().toISOString()}] [CSharpCliAdapter] resolve slow`,{file:t,ms:o}),s||re(`[${new Date().toISOString()}] [CSharpCliAdapter] resolve failed`,{file:t,ms:o,nodePath:e}),s}).catch(s=>{let o=Date.now()-r;return re(`[${new Date().toISOString()}] [CSharpCliAdapter] resolve error`,{file:t,ms:o,nodePath:e,error:s?.message||s}),null}):null}})}import{spawnSync as yr}from"child_process";import br from"path";import Z from"fs";import I from"path";var Ke=new Map,dr=["include","src","lib","libs","third_party","third-party","deps","vendor"];function Ht(t){let e=[],n="",r=null,i=!1;for(let s=0;s<t.length;s+=1){let o=t[s];if(i){n+=o,i=!1;continue}if(o==="\\"){i=!0;continue}if(r){o===r?r=null:n+=o;continue}if(o==='"'||o==="'"){r=o;continue}if(o===" "||o===`
|
|
512
|
+
`||o===" "||o==="\r"){n&&(e.push(n),n="");continue}n+=o}return n&&e.push(n),e}function pr(t,e){let n=[];for(let r=0;r<t.length;r+=1){let i=t[r];if(i!=="-c"){if(i==="-o"){r+=1;continue}i!==e&&((i.endsWith(".c")||i.endsWith(".cc")||i.endsWith(".cpp")||i.endsWith(".cxx")||i.endsWith(".c++"))&&I.isAbsolute(i)||n.push(i))}}return n}function Jt(t,e){return I.isAbsolute(t)?I.resolve(t):e?I.resolve(e,t):I.resolve(t)}function fr(t){try{let e=Z.readFileSync(t,"utf8"),n=JSON.parse(e),r=new Map;for(let i of n){let s=i.directory?I.resolve(i.directory):void 0,o=i.file?Jt(i.file,s):null;if(!o)continue;let l=s??I.dirname(o),u=Array.isArray(i.arguments)?i.arguments:i.command?Ht(i.command):[];if(u.length===0)continue;let m=pr(u.slice(1),o);r.set(o,{args:m,cwd:l})}return r}catch{return null}}function mr(t){try{let e=Z.readFileSync(t,"utf8");return Ht(e.replace(/\r/g,`
|
|
513
|
+
`))}catch{return null}}function Wt(t){let e=I.join(t,"compile_commands.json");if(Z.existsSync(e))return e;let n=["build","out","build-debug","build-release","cmake-build-debug","cmake-build-release"];for(let l of n){let u=I.join(t,l,"compile_commands.json");if(Z.existsSync(u))return u}let r=n.map(l=>I.join(t,l)).filter(l=>Z.existsSync(l));r.push(t);let i=10,s=new Set,o=(l,u)=>{if(u>i)return null;let m=I.resolve(l);if(s.has(m))return null;s.add(m);try{let d=Z.readdirSync(l,{withFileTypes:!0});for(let f of d)if(f.isFile()&&f.name==="compile_commands.json")return I.join(l,f.name);for(let f of d){if(!f.isDirectory()||f.name==="node_modules"||f.name.startsWith("."))continue;let y=o(I.join(l,f.name),u+1);if(y)return y}}catch{}return null};for(let l of r){let u=o(l,0);if(u)return u}return null}function gr(t,e){let n=I.resolve(t),r=I.resolve(e);for(;;){let i=Wt(n);if(i)return i;if(n===r)break;let s=I.dirname(n);if(s===n)break;n=s}return null}function Xt(t){let e=I.join(t,"compile_flags.txt");if(Z.existsSync(e))return e;let n=["build","out","build-debug","build-release","cmake-build-debug","cmake-build-release"];for(let r of n){let i=I.join(t,r,"compile_flags.txt");if(Z.existsSync(i))return i}return null}function hr(t,e){let n=I.resolve(t),r=I.resolve(e);for(;;){let i=Xt(n);if(i)return i;if(n===r)break;let s=I.dirname(n);if(s===n)break;n=s}return null}function Fe(t){if(t)try{return Z.statSync(t).mtimeMs}catch{return}}function qt(t,e){let n=e?`${I.resolve(t)}::${I.resolve(e)}`:I.resolve(t),r=Ke.get(n);if(r){let f=Fe(r.commandsPath);if(r.commandsPath&&f&&r.commandsMtime&&f!==r.commandsMtime)Ke.delete(n);else if(r.flagsPath){let y=Fe(r.flagsPath);y&&r.flagsMtime&&y!==r.flagsMtime&&Ke.delete(n)}else return r}let i=e?gr(e,t):Wt(t),s=i?fr(i)??void 0:void 0,o=Fe(i),l=s?null:e?hr(e,t):Xt(t),u=l?mr(l)??void 0:void 0,m=Fe(l),d={commands:s,flags:u,commandsPath:i,commandsMtime:o,flagsPath:l,flagsMtime:m};return Ke.set(n,d),d}function et(t,e,n){let r=I.dirname(e),i=qt(t);!i.commands&&!i.flags&&(i=qt(t,r));let s=Jt(e);if(i.commands){let o=i.commands.get(s);if(o)return{args:o.args,cwd:o.cwd,source:"compile_commands"}}return i.flags?{args:i.flags,cwd:t,source:"compile_flags"}:tt(t,n)}function tt(t,e){let n=["-std="+(e==="cpp"?"c++20":"c17")];n.push("-I",t);for(let r of dr){let i=I.join(t,r);Z.existsSync(i)&&n.push("-I",i)}return n.push("-ferror-limit=0"),{args:n,cwd:t,source:"fallback"}}function Qt(t){let e=[0];for(let n=0;n<t.length;n+=1)t.charCodeAt(n)===10&&e.push(n+1);return e}function Ut(t,e,n){if(!e||e<1)return 0;let r=Math.min(e-1,t.length-1),i=t[r]??0,s=Math.max((n??1)-1,0);return i+s}function me(t){return t?br.resolve(t):null}function Vt(t,e,n){let r=Math.max(0,Math.min(n-1,t.length-1)),i=t[r]??0,s=r+1<t.length?t[r+1]:e;return Math.max(0,s-i)}function ie(t,e,n){let r=t.range?.begin??t.loc,i=t.range?.end??t.loc;if(!r?.line||r.line<1||r.line>e.length||r.col==null||r.col<1||i?.line&&(i.line<1||i.line>e.length)||i?.col!=null&&i.col<1)return null;let s=Vt(e,n,r.line);if((r.col??1)-1>s)return null;if(i?.line){let u=Vt(e,n,i.line);if((i.col??r.col??1)-1>u)return null}let o=Ut(e,r.line,r.col),l=Ut(e,i?.line??r.line,i?.col??r.col);return{start:o,end:Math.max(l,o)}}function Le(t){let e=t.range?.begin?.file||t.loc?.file||t.range?.end?.file||null;if(e)return me(e);let n=t.range?.begin?.includedFrom?.file||t.range?.end?.includedFrom?.file||null;return me(n)}function xr(t){let e=t.access;return typeof e=="string"?e:null}function Sr(t,e){let n={};e.containerName&&(n.containerName=e.containerName);let r=xr(t);r&&(n.visibility=r);let i=t.storageClass;i&&(n.storageClass=i);let s=t.isInline;typeof s=="boolean"&&(n.isInline=s);let o=t.isConstexpr;typeof o=="boolean"&&(n.isConstexpr=o);let l=t.isVirtual;typeof l=="boolean"&&(n.isVirtual=l);let u=t.isStatic;typeof u=="boolean"&&(n.isStatic=u);let m=t.type;return typeof m=="string"&&(n.type=m),n}function nt(t,e,n){switch(t){case"FunctionDecl":return{kind:"Function",semanticKind:"function"};case"CXXMethodDecl":case"CXXConstructorDecl":case"CXXDestructorDecl":case"CXXConversionDecl":return{kind:"Method",semanticKind:"method"};case"FunctionTemplateDecl":case"ClassTemplateDecl":case"TypeAliasTemplateDecl":return{kind:"Template",semanticKind:"template"};case"ConceptDecl":return{kind:"Concept",semanticKind:"type"};case"TemplateTypeParmDecl":case"NonTypeTemplateParmDecl":case"TemplateTemplateParmDecl":return{kind:"TemplateParameter",semanticKind:"template"};case"NamespaceDecl":return{kind:"Namespace",semanticKind:"namespace"};case"NamespaceAliasDecl":return{kind:"NamespaceAlias",semanticKind:"namespace"};case"RecordDecl":return e==="struct"?{kind:"Struct",semanticKind:"struct"}:e==="union"?{kind:"Union",semanticKind:"union"}:{kind:"Class",semanticKind:"class"};case"EnumDecl":return{kind:"Enum",semanticKind:"enum"};case"EnumConstantDecl":return{kind:"EnumMember",semanticKind:"enum"};case"FieldDecl":return{kind:"Field",semanticKind:"field"};case"VarDecl":return{kind:n?"Field":"Variable",semanticKind:n?"field":"variable"};case"TypedefDecl":case"TypeAliasDecl":case"UsingDecl":case"UsingDirectiveDecl":case"UsingEnumDecl":return{kind:"TypeAlias",semanticKind:"type"};case"ParmVarDecl":return{kind:"Param",semanticKind:"variable"};case"MacroDefinition":return{kind:"Macro",semanticKind:"macro"};default:return null}}function vr(t,e,n,r){let i=[],s=me(e),o=(l,u)=>{let m=Le(l),f=m&&(!s||m===s)?nt(l.kind,l.tagUsed,u.containerKind):null,y=l.name;if(f&&y){f.kind==="Method"&&typeof y=="string"&&y.startsWith("operator")&&(f={kind:"Operator",semanticKind:"method"});let x=ie(l,n,r);if(x){let v=Sr(l,u);(f.kind==="Template"||f.kind==="TemplateParameter")&&(v.isTemplate=!0),f.kind==="Operator"&&(v.isOperator=!0),i.push({name:y,kind:f.kind,rawKind:l.kind??null,rawKindSource:"clang",semanticKind:f.semanticKind??null,start:x.start,end:x.end,isExported:u.containerKind?0:1,containerKind:u.containerKind??null,containerRawKind:u.containerRawKind??null,containerRawKindSource:u.containerRawKind?"clang":null,paramCount:null,metadata:Object.keys(v).length?v:null})}}let _=u;if(l.kind==="RecordDecl"&&l.name){let x=nt(l.kind,l.tagUsed,u.containerKind);x&&(_={containerKind:x.kind,containerName:l.name,containerRawKind:l.kind??null})}l.kind==="EnumDecl"&&l.name&&(_={containerKind:"Enum",containerName:l.name,containerRawKind:l.kind??null}),l.kind==="NamespaceDecl"&&l.name&&(_={containerKind:"Namespace",containerName:l.name,containerRawKind:l.kind??null});for(let x of l.inner??[])o(x,_)};return o(t,{}),{nodes:i}}function rt(t,e,n){let r=yr(t,e,{encoding:"utf8",cwd:n});if(r.error)return null;let i=(r.stdout||"").trim();if(!i)return null;try{return JSON.parse(i)}catch{return null}}function Gt(t){let e=`PANDO_${t.toUpperCase()}_INDEXER_CMD`;return process.env[e]||(t==="cpp"?"clang++":"clang")}function ve(t){let e=t?.referencedDecl?.name||t.name;if(e)return e;for(let n of t.inner??[]){let r=ve(n);if(r)return r}return null}function Nr(t,e){let n=[],r=me(e),i=s=>{let o=Le(s);if(o&&(!r||o===r)&&s.kind==="InclusionDirective"){let m=s.spelling||s.includeName||null||s.file||s.filename||s.includedFile||s.headerName||null;m&&n.push({module:String(m),isTypeOnly:0})}for(let u of s.inner??[])i(u)};return i(t),{imports:n}}function Oe(t){if(t.kind==="MemberExpr"||t.kind==="ImplicitCastExpr")for(let e of t.inner??[]){if(e.kind==="DeclRefExpr"||e.kind==="MemberExpr")return e?.referencedDecl?.name||e.name||null;if(e.kind==="CXXThisExpr")return null;if(e.kind==="ImplicitCastExpr")return Oe(e)}if(t.kind==="CallExpr"||t.kind==="CXXMemberCallExpr"){for(let e of t.inner??[])if(e.kind==="MemberExpr")return Oe(e)}return null}function Cr(t){return!t.inner||t.inner.length===0?null:t.kind==="CallExpr"?Math.max(0,t.inner.length-1):t.kind==="CXXConstructExpr"||t.kind==="CXXNewExpr"?t.inner.length:null}function wr(t){if(t.kind!=="CallExpr")return null;let e=t.inner?.[0];return e&&e.kind==="MemberExpr"?Oe(e):null}function Me(t,e){return t.containerQualifiedName?`${t.containerQualifiedName}::${e}`:e}function Er(t,e,n,r){let i=[],s=me(e),o=r.length,l=(d,f,y)=>{let _=Le(d),x=_&&(!s||_===s);if(x&&(d.kind==="CallExpr"||d.kind==="CXXConstructExpr"||d.kind==="CXXNewExpr")){let C=ie(d,n,o);if(C){let z=ve(d),$=d.kind==="CallExpr"?"call":"new",H=r.slice(C.start,C.end),a=wr(d),h=Cr(d);i.push({sourceStart:C.start,sourceEnd:C.end,refKind:$,refName:z,receiverName:a??void 0,arity:typeof h=="number"?h:void 0,containerQualifiedName:f.containerQualifiedName??void 0,metadata:H?{expression:H,containerName:f.containerName,containerKind:f.containerKind}:null})}}if(x&&d.kind==="TypeRef"){let C=ie(d,n,o);if(C){let z=ve(d);i.push({sourceStart:C.start,sourceEnd:C.end,refKind:"type",refName:z,containerQualifiedName:f.containerQualifiedName??void 0,metadata:{containerName:f.containerName,containerKind:f.containerKind}})}}if(x&&(d.kind==="DeclRefExpr"||d.kind==="MemberExpr")&&!(y.includes("CallExpr")||y.includes("CXXConstructExpr")||y.includes("CXXNewExpr"))){let z=ie(d,n,o);if(z){let $=ve(d),H=d.kind==="MemberExpr"?Oe(d):void 0;i.push({sourceStart:z.start,sourceEnd:z.end,refKind:"reference",refName:$,receiverName:H??void 0,containerQualifiedName:f.containerQualifiedName??void 0,metadata:{containerName:f.containerName,containerKind:f.containerKind}})}}if(x&&(d.kind==="MacroExpansion"||d.kind==="MacroInstantiation")){let C=ie(d,n,o);if(C){let z=ve(d);i.push({sourceStart:C.start,sourceEnd:C.end,refKind:"macro",refName:z,containerQualifiedName:f.containerQualifiedName??void 0,metadata:{containerName:f.containerName,containerKind:f.containerKind}})}}let v=f;if(d.kind==="RecordDecl"&&d.name){let C=nt(d.kind,d.tagUsed,f.containerKind);C&&(v={containerKind:C.kind,containerName:d.name,containerQualifiedName:Me(f,d.name)})}d.kind==="EnumDecl"&&d.name&&(v={containerKind:"Enum",containerName:d.name,containerQualifiedName:Me(f,d.name)}),d.kind==="NamespaceDecl"&&d.name&&(v={containerKind:"Namespace",containerName:d.name,containerQualifiedName:Me(f,d.name)}),(d.kind==="FunctionDecl"||d.kind==="CXXMethodDecl"||d.kind==="CXXConstructorDecl"||d.kind==="CXXDestructorDecl")&&d.name&&(v={...v,containerQualifiedName:Me(f,d.name)});let K=y.slice();d.kind&&K.push(d.kind);for(let C of d.inner??[])l(C,v,K)};l(t,{},[]);let u=new Set,m=[];for(let d of i){let f=`${d.sourceStart}:${d.sourceEnd}:${d.refKind}:${d.refName??""}:${d.targetNodeId??""}:${d.targetFile??""}`;u.has(f)||(u.add(f),m.push(d))}return{references:m}}function Pr(t){if(!t)return null;let e=t;(e.startsWith("SyntaxError:")||e.startsWith("CompileError:"))&&(e=e.substring(e.indexOf(":")+1)),e.includes("#")&&(e=e.split("#")[1]);let n=e.lastIndexOf(":"),r=n>=0?e.slice(0,n):e,[i,s]=r.split("-"),o=Number(i),l=Number(s);return!Number.isFinite(o)||!Number.isFinite(l)||l<o?null:{start:o,end:l}}function Rr(t,e,n,r,i){let s=Pr(n);if(!s)return null;let o=Gt(t),l=et(i,e,t),u=[...l.args,"-Xclang","-ast-dump=json","-Xclang","-detailed-preprocessing-record","-fsyntax-only","-fno-color-diagnostics","-fno-diagnostics-color",...l.source==="fallback"?["-x",t==="cpp"?"c++":"c"]:[],e],m=rt(o,u,l.cwd);if(!m||m.kind!=="TranslationUnitDecl")return null;let d=Qt(r),f=r.length,y=me(e),_=null,x=K=>{if(_)return;let C=Le(K),$=C&&(!y||C===y)?ie(K,d,f):null;if($&&$.start===s.start&&$.end===s.end){let H=null,a=null;for(let h of K.inner??[])if(h.kind==="CompoundStmt"){let b=ie(h,d,f);if(b){H=b.start,a=b.end;break}}_={start:$.start,end:$.end,bodyStart:H,bodyEnd:a};return}for(let H of K.inner??[])x(H)};if(x(m),!_)return null;let v=_;return{start:v.start,end:v.end,bodyStart:v.bodyStart??null,bodyEnd:v.bodyEnd??null,text:r.slice(v.start,v.end)}}function it(t){return G({id:t,extensions:[],parse:({absPath:e,relPath:n,content:r,projectRoot:i})=>{let s=Gt(t),o=et(i,e,t),l=x=>[...x.args,"-Xclang","-ast-dump=json","-Xclang","-detailed-preprocessing-record","-fsyntax-only","-fno-color-diagnostics","-fno-diagnostics-color",...x.source==="fallback"?["-x",t==="cpp"?"c++":"c"]:[],e],u=rt(s,l(o),o.cwd);if(!u&&o.source!=="fallback"){let x=tt(i,t);u=rt(s,l(x),x.cwd)}if(!u||u.kind!=="TranslationUnitDecl")return null;let m=Qt(r??""),d=(r??"").length,{nodes:f}=vr(u,e,m,d),{imports:y}=Nr(u,e),{references:_}=Er(u,e,m,r??"");return{nodes:f,imports:y,importBindings:[],references:_}},resolve:({absPath:e,nodePath:n,projectRoot:r})=>{try{let i=bn("fs").readFileSync(e,"utf8");return Rr(t,e,n,i,r)}catch{return null}}})}import st from"fs";import at from"path";import{spawn as _r,spawnSync as Ys}from"child_process";var Ar=256e3,Tr=32;function se(...t){try{let e=t.map(n=>{if(typeof n=="string")return n;try{return JSON.stringify(n)}catch{return String(n)}}).join(" ");process.stderr.write(e+`
|
|
514
|
+
`)}catch{}}var ot=class{constructor(e){this.cmd=e;this.proc=null;this.buffer="";this.pending=new Map;this.seq=1;this.closed=!1;this.ensureProcess()}ensureProcess(){if(!(this.proc&&!this.closed)){if(this.closed=!1,this.proc=_r(this.cmd,["--server"],{stdio:["pipe","pipe","pipe"]}),!this.proc.stdout||!this.proc.stderr||!this.proc.stdin)throw this.closed=!0,new Error("dart indexer stdio unavailable");this.proc.stdout.on("data",e=>this.onData(e)),this.proc.stderr.on("data",e=>{se(`[DartIndexer] ${e.toString("utf8").trim()}`)}),this.proc.stdin.on("error",e=>this.handleExit(e)),this.proc.on("error",e=>this.handleExit(e)),this.proc.on("exit",e=>this.handleExit(new Error(`dart indexer exited with code ${e}`)))}}handleExit(e){if(!this.closed){this.closed=!0;for(let[,n]of this.pending)n.reject(e);this.pending.clear()}}onData(e){for(this.buffer+=e.toString("utf8");;){let n=this.buffer.indexOf(`
|
|
515
|
+
`);if(n<0)break;let r=this.buffer.slice(0,n).trim();if(this.buffer=this.buffer.slice(n+1),!r)continue;let i=null;try{i=JSON.parse(r)}catch{continue}let s=this.pending.get(i.id);s&&(this.pending.delete(i.id),i.ok?s.resolve(i):s.reject(new Error(i.error||"dart server error")))}}async request(e,n=1){this.ensureProcess();let r=this.seq++;return new Promise((i,s)=>{let o={id:r,...e};this.pending.set(r,{resolve:i,reject:s});try{this.proc.stdin.write(`${JSON.stringify(o)}
|
|
516
|
+
`)}catch(l){if(this.pending.delete(r),n>0){try{this.handleExit(l)}catch{}return this.request(e,n-1).then(i,s)}s(l)}})}async parseBatch(e){let n=await this.request({op:"parse",files:e});return"results"in n&&Array.isArray(n.results)?n.results.map(r=>r.ok&&r.result?r.result:null):"result"in n&&n.result?[n.result]:e.map(()=>null)}async resolve(e){let n=await this.request({op:"resolve",...e});return"result"in n&&n.result&&typeof n.result.start=="number"?n.result:null}},lt=class{constructor(e){this.client=e;this.queue=[];this.scheduled=!1}enqueue(e){return new Promise((n,r)=>{this.queue.push({input:e,resolve:n,reject:r,startedAt:Date.now()}),this.scheduled||(this.scheduled=!0,setImmediate(()=>this.flush()))})}async flush(){for(this.scheduled=!1;this.queue.length;){let e=[],n=0;for(;this.queue.length&&e.length<Tr;){let r=this.queue[0];if(e.length>0&&n+r.input.size>Ar)break;e.push(this.queue.shift()),n+=r.input.size}try{let r=await this.client.parseBatch(e.map(i=>({file:i.input.file,root:i.input.root,lang:i.input.lang})));for(let i=0;i<e.length;i+=1){let s=e[i],o=r[i]??null,l=Date.now()-s.startedAt;l>2e3&&se(`[${new Date().toISOString()}] [DartCliAdapter] parse slow`,{file:s.input.file,ms:l,ok:!!o}),o||se(`[${new Date().toISOString()}] [DartCliAdapter] parse failed`,{file:s.input.file,ms:l}),s.resolve(o)}}catch(r){for(let i of e)i.reject(r)}}}},Yt=new Map,Zt=new Map;function Ir(t){let e=process.platform==="win32"?".cmd":"",n=Y(`dart-indexer/bin/pando-dart-indexer${e}`);if(n)return n;if(t){let s=at.resolve(t,"tools/dart-indexer/bin/pando-dart-indexer"+e);if(st.existsSync(s))return s}let r=process.env.PANDO_EXTENSION_ROOT;if(r){let s=at.resolve(r,"tools/dart-indexer/bin/pando-dart-indexer"+e);if(st.existsSync(s))return s}let i=at.resolve(process.cwd(),"tools/dart-indexer/bin/pando-dart-indexer"+e);return st.existsSync(i)?i:null}function en(t){let e=process.env.PANDO_DART_INDEXER_CMD||Ir(t);if(!e)return null;let n=Yt.get(e);n||(n=new ot(e),Yt.set(e,n));let r=Zt.get(e);return r||(r=new lt(n),Zt.set(e,r)),{client:n,batcher:r}}async function kr(t,e,n){let r=en(e);if(!r)return null;try{return await r.batcher.enqueue({file:t,root:e,lang:"dart",size:n})}catch(i){return se(`[${new Date().toISOString()}] [DartCliAdapter] parse error`,{file:t,error:i?.message||i}),null}}function tn(){return G({id:"dart",extensions:[".dart"],parse:async({absPath:t,projectRoot:e,content:n,meta:r})=>{let i=r?.size??Buffer.byteLength(n,"utf8");return kr(t,e,i)},resolve:({absPath:t,nodePath:e,projectRoot:n})=>{let r=Date.now(),i=en(n);return i?i.client.resolve({file:t,root:n,lang:"dart",nodePath:e}).then(s=>{let o=Date.now()-r;return o>2e3&&se(`[${new Date().toISOString()}] [DartCliAdapter] resolve slow`,{file:t,ms:o}),s||se(`[${new Date().toISOString()}] [DartCliAdapter] resolve failed`,{file:t,ms:o,nodePath:e}),s}).catch(s=>{let o=Date.now()-r;return se(`[${new Date().toISOString()}] [DartCliAdapter] resolve error`,{file:t,ms:o,nodePath:e,error:s?.message||s}),null}):null},exportKind:"dart"})}import ct from"fs";import Ne from"path";import{spawn as Dr,spawnSync as sa}from"child_process";var Kr=256e3,Fr=32;function oe(...t){try{let e=t.map(n=>{if(typeof n=="string")return n;try{return JSON.stringify(n)}catch{return String(n)}}).join(" ");process.stderr.write(e+`
|
|
517
|
+
`)}catch{}}var ut=class{constructor(e){this.cmd=e;this.proc=null;this.buffer="";this.pending=new Map;this.seq=1;this.closed=!1;this.ensureProcess()}ensureProcess(){if(!(this.proc&&!this.closed)){if(this.closed=!1,this.proc=Dr(this.cmd,["--server"],{stdio:["pipe","pipe","pipe"]}),!this.proc.stdout||!this.proc.stderr||!this.proc.stdin)throw this.closed=!0,new Error("java indexer stdio unavailable");this.proc.stdout.on("data",e=>this.onData(e)),this.proc.stderr.on("data",e=>{oe(`[JavaCliAdapter] ${e.toString("utf8").trim()}`)}),this.proc.stdin.on("error",e=>this.handleExit(e)),this.proc.on("error",e=>this.handleExit(e)),this.proc.on("exit",e=>this.handleExit(new Error(`java indexer exited with code ${e}`)))}}handleExit(e){if(!this.closed){this.closed=!0;for(let[,n]of this.pending)clearTimeout(n.timer),n.reject(e);this.pending.clear()}}onData(e){for(this.buffer+=e.toString("utf8");;){let n=this.buffer.indexOf(`
|
|
518
|
+
`);if(n<0)break;let r=this.buffer.slice(0,n).trim();if(this.buffer=this.buffer.slice(n+1),!r)continue;let i=null;try{i=JSON.parse(r)}catch{continue}let s=this.pending.get(i.id);s&&(clearTimeout(s.timer),this.pending.delete(i.id),i.ok?s.resolve(i):s.reject(new Error(i.error||"java server error")))}}async request(e,n=1){this.ensureProcess();let r=this.seq++;return new Promise((i,s)=>{let o={id:r,...e},l=setTimeout(()=>{this.pending.delete(r),s(new Error("java indexer request timed out after 30s"))},3e4);this.pending.set(r,{resolve:i,reject:s,timer:l});try{this.proc.stdin.write(`${JSON.stringify(o)}
|
|
519
|
+
`)}catch(u){if(clearTimeout(l),this.pending.delete(r),n>0){try{this.handleExit(u)}catch{}return this.request(e,n-1).then(i,s)}s(u)}})}async parseBatch(e){let n=await this.request({op:"parse",files:e});return"results"in n?n.results.map(r=>r.ok&&r.result?r.result:null):"result"in n?[n.result]:e.map(()=>null)}async resolve(e){let n=await this.request({op:"resolve",...e});return"result"in n&&n.result&&typeof n.result.start=="number"?n.result:null}},dt=class{constructor(e){this.client=e;this.queue=[];this.scheduled=!1}enqueue(e){return new Promise((n,r)=>{this.queue.push({input:e,resolve:n,reject:r,startedAt:Date.now()}),this.scheduled||(this.scheduled=!0,setImmediate(()=>this.flush()))})}async flush(){for(this.scheduled=!1;this.queue.length;){let e=[],n=0;for(;this.queue.length&&e.length<Fr;){let r=this.queue[0];if(e.length>0&&n+r.input.size>Kr)break;e.push(this.queue.shift()),n+=r.input.size}try{let r=await this.client.parseBatch(e.map(i=>({file:i.input.file,root:i.input.root,lang:i.input.lang})));for(let i=0;i<e.length;i+=1){let s=e[i],o=r[i]??null,l=Date.now()-s.startedAt;l>2e3&&oe(`[${new Date().toISOString()}] [JavaCliAdapter] parse slow`,{file:s.input.file,ms:l,path:"custom",ok:!!o}),o||oe(`[${new Date().toISOString()}] [JavaCliAdapter] parse failed`,{file:s.input.file,ms:l,path:"custom"}),s.resolve(o)}}catch(r){for(let i of e)i.reject(r)}}}},nn=new Map,rn=new Map;function Mr(){return typeof __dirname=="string"?__dirname:process.cwd()}var ae,Or;function Lr(t){if(ae!==void 0&&Or===t)return ae;let e=process.platform==="win32"?".cmd":"",n="tools/java-indexer/bin/pando-java-indexer"+e,r=Y(`java-indexer/bin/pando-java-indexer${e}`);if(r)return ae=r,r;if(t){let s=Ne.resolve(t,n);if(ct.existsSync(s))return ae=s,s}let i=Mr();for(let s=0;s<8;s++){let o=Ne.join(i,n);if(ct.existsSync(o))return ae=o,o;let l=Ne.dirname(i);if(l===i)break;i=l}i=process.cwd();for(let s=0;s<8;s++){let o=Ne.join(i,n);if(ct.existsSync(o))return ae=o,o;let l=Ne.dirname(i);if(l===i)break;i=l}return ae=null,null}function sn(t){let e=process.env.PANDO_JAVA_INDEXER_CMD||Lr(t);if(!e)return null;let n=nn.get(e);n||(n=new ut(e),nn.set(e,n));let r=rn.get(e);return r||(r=new dt(n),rn.set(e,r)),{client:n,batcher:r}}async function jr(t,e,n){let r=sn(e);if(!r)return null;try{return await r.batcher.enqueue({file:t,root:e,lang:"java",size:n})}catch(i){return oe(`[${new Date().toISOString()}] [JavaCliAdapter] parse error`,{file:t,error:i?.message||i,path:"custom"}),null}}async function $r(t,e,n){let r=await jr(t,e,n);return r||null}function an(){return G({id:"java",extensions:[".java"],exportKind:"named",parse:({absPath:t,projectRoot:e,content:n,meta:r})=>{let i=r?.size??Buffer.byteLength(n,"utf8");return $r(t,e,i)},resolve:({absPath:t,nodePath:e,projectRoot:n})=>{let r=Date.now(),i=sn(n);return i?i.client.resolve({file:t,root:n,lang:"java",nodePath:e}).then(s=>{let o=Date.now()-r;return o>2e3&&oe(`[${new Date().toISOString()}] [JavaCliAdapter] resolve slow`,{file:t,ms:o}),s||oe(`[${new Date().toISOString()}] [JavaCliAdapter] resolve failed`,{file:t,ms:o,nodePath:e}),s}).catch(s=>{let o=Date.now()-r;return oe(`[${new Date().toISOString()}] [JavaCliAdapter] resolve error`,{file:t,ms:o,nodePath:e,error:s?.message||s}),null}):null}})}import Jr from"fs";import{spawn as Br}from"child_process";import pt from"fs";import ft from"path";function on(t,e){let n=process.platform==="win32"?".cmd":"",r=t==="clojure-editor"?"pando-clojure-editor":"pando-clojure-indexer",i=Y(`${t}/bin/${r}${n}`);if(i)return i;if(e){let l=ft.resolve(e,`tools/${t}/bin/${r}${n}`);if(pt.existsSync(l))return l}let s=process.env.PANDO_EXTENSION_ROOT;if(s){let l=ft.resolve(s,`tools/${t}/bin/${r}${n}`);if(pt.existsSync(l))return l}let o=ft.resolve(process.cwd(),`tools/${t}/bin/${r}${n}`);return pt.existsSync(o)?o:null}var un=3e4,zr=Math.max(un,Number(process.env.PANDO_CLOJURE_CHANGE_SIGNATURE_TIMEOUT_MS||`${300*1e3}`)),ln="__PANDO_CLOJURE_INDEX__";function qr(...t){if(!te())return;let e=t.map(n=>{if(typeof n=="string")return n;try{return JSON.stringify(n)}catch{return String(n)}}).join(" ");X("ClojureIndexer",e)}function Ce(t,e){te()&&X("ClojureIndex",t,e)}var je=class{constructor(e,n){this.cmd=e;this.projectRoot=n;this.proc=null;this.buffer="";this.stderrBuffer="";this.pending=new Map;this.seq=1;this.closed=!1;this.ensureProcess()}ensureProcess(){if(!(this.proc&&!this.closed)){if(this.closed=!1,Ce("node.server.spawn",{projectRoot:this.projectRoot,cmd:this.cmd}),this.proc=Br(this.cmd,["--server"],{cwd:this.projectRoot,stdio:["pipe","pipe","pipe"],env:{...process.env,PANDO_PROJECT_ROOT:this.projectRoot}}),!this.proc.stdout||!this.proc.stderr||!this.proc.stdin)throw this.closed=!0,new Error("clojure indexer stdio unavailable");this.proc.stdout.on("data",e=>this.onData(e)),this.proc.stderr.on("data",e=>this.onStderr(e)),this.proc.on("error",e=>this.handleExit(e)),this.proc.on("exit",e=>this.handleExit(new Error(`clojure indexer exited with code ${e}`)))}}handleExit(e){if(!this.closed){Ce("node.server.exit",{projectRoot:this.projectRoot,error:e?.message||String(e),pendingRequestCount:this.pending.size}),this.closed=!0;for(let[,n]of this.pending)clearTimeout(n.timer),n.reject(e);this.pending.clear(),this.proc=null}}onData(e){for(this.buffer+=e.toString("utf8");;){let n=this.buffer.indexOf(`
|
|
520
|
+
`);if(n<0)break;let r=this.buffer.slice(0,n).trim();if(this.buffer=this.buffer.slice(n+1),!r)continue;let i=null;try{i=JSON.parse(r)}catch{continue}let s=this.pending.get(i.id);s&&(clearTimeout(s.timer),this.pending.delete(i.id),i.ok?s.resolve(i):s.reject(new Error(i.error||"clojure server error")))}}onStderr(e){for(this.stderrBuffer+=e.toString("utf8");;){let n=this.stderrBuffer.indexOf(`
|
|
521
|
+
`);if(n<0)break;let r=this.stderrBuffer.slice(0,n).trim();if(this.stderrBuffer=this.stderrBuffer.slice(n+1),!!r){if(r.startsWith(ln)){let i=r.slice(ln.length);try{let s=JSON.parse(i);Ce(s.event||"jvm.trace",s)}catch(s){X("ClojureIndexer","stderr trace parse failed",{error:s?.message||String(s),line:r})}continue}qr(r)}}}close(){if(this.closed)return;this.closed=!0;for(let[,n]of this.pending)clearTimeout(n.timer),n.reject(new Error("clojure indexer client closed"));this.pending.clear();let e=this.proc;if(this.proc=null,!!e){try{e.stdin?.end()}catch{}try{e.kill()}catch{}}}async request(e,n){this.ensureProcess();let r=this.seq++,i=n?.retry??1,s=n?.timeoutMs??un,o=Date.now();return new Promise((l,u)=>{let m={id:r,...e},d=setTimeout(()=>{this.pending.delete(r),u(new Error(`clojure indexer request timed out after ${s}ms`))},s);this.pending.set(r,{resolve:f=>{Ce("node.client.request.complete",{projectRoot:this.projectRoot,id:r,op:e.op,durationMs:Date.now()-o}),l(f)},reject:u,timer:d});try{Ce("node.client.request.start",{projectRoot:this.projectRoot,id:r,op:e.op}),this.proc.stdin.write(`${JSON.stringify(m)}
|
|
522
|
+
`)}catch(f){if(clearTimeout(d),this.pending.delete(r),i>0){try{this.handleExit(f)}catch{}return this.request(e,{retry:i-1,timeoutMs:s}).then(l,u)}u(f)}})}async parseBatch(e,n){let r=await this.request({op:"parse",files:e,traceBatchId:n?.batchId,traceBatchBytes:n?.batchBytes});return"results"in r?r.results.map(i=>i.ok&&i.result?i.result:null):[]}async resolve(e){let n=await this.request({op:"resolve",...e});if("result"in n){let r=n.result;if(r&&typeof r.start=="number"&&typeof r.end=="number")return r}return null}async changeSignature(e){let n=await this.request({op:"change-signature",...e},{timeoutMs:zr});return"result"in n&&n.result||null}},cn=new Map;function dn(t){return process.env.PANDO_CLOJURE_INDEXER_CMD||on("clojure-indexer",t)}function pn(t){let e=dn(t);return e?new je(e,t):null}function fn(t){let e=dn(t);if(!e)return null;let n=`${e}::${t}`,r=cn.get(n);return r||(r=new je(e,t),cn.set(n,r)),r}var Hr=Math.max(1,Number(process.env.PANDO_CLOJURE_ANALYZER_POOL_SIZE||"3"));function $e(t,e){X("ClojureIndex",t,e)}function Be(t,e){X("IndexTiming",t,e)}var ze=class{constructor(e,n=Hr){this.projectRoot=e;this.clients=[];this.idleClients=[];this.queue=[];this.inFlight=new Set;this.drainWaiters=[];this.batchSeq=1;this.closed=!1;let r=Math.max(1,n);for(let i=0;i<r;i+=1){let s=pn(e);if(!s)break;this.clients.push(s),this.idleClients.push(s)}if(!this.clients.length)throw new Error("clojure indexer command unavailable");$e("node.pool.init",{projectRoot:e,configuredPoolSize:r,actualClientCount:this.clients.length})}submit(e,n){return this.closed?Promise.reject(new Error("clojure analyzer pool is closed")):new Promise((r,i)=>{this.queue.push({batchId:this.batchSeq++,batchKey:e,files:n,enqueuedAt:Date.now(),resolve:r,reject:i}),this.pump()})}async flush(){for(;this.queue.length||this.inFlight.size;)await new Promise(e=>this.drainWaiters.push(e))}async close(){if(!this.closed){await this.flush(),this.closed=!0;for(let e of this.clients)try{e.close()}catch{}this.clients.length=0,this.idleClients.length=0}}pump(){for(;!this.closed&&this.queue.length&&this.idleClients.length;){let e=this.queue.shift(),n=this.idleClients.shift(),r=this.runJob(n,e).finally(()=>{this.inFlight.delete(r),this.closed||this.idleClients.push(n),this.pump(),this.notifyIfIdle()});this.inFlight.add(r)}this.notifyIfIdle()}async runJob(e,n){let r=n.files.reduce((o,l)=>o+Math.max(0,l.size||0),0),i=Date.now(),s=Math.max(0,i-n.enqueuedAt);$e("node.pool-batch.start",{batchId:n.batchId,batchKey:n.batchKey,fileCount:n.files.length,batchBytes:r,queueWaitMs:s,queuedBatchCount:this.queue.length,inFlightCount:this.inFlight.size});try{let o=await this.parseFiles(e,n.files,n.batchId,r);Be("clojure-pool.job.complete",{projectRoot:this.projectRoot,batchId:n.batchId,batchKey:n.batchKey,fileCount:n.files.length,batchBytes:r,queueWaitMs:s,durationMs:Date.now()-i}),$e("node.pool-batch.complete",{batchId:n.batchId,batchKey:n.batchKey,fileCount:n.files.length,batchBytes:r,durationMs:Date.now()-i,successCount:Array.from(o.values()).filter(l=>!("error"in l)).length,errorCount:Array.from(o.values()).filter(l=>"error"in l).length}),n.resolve(o)}catch(o){let l=o instanceof Error?o:new Error(String(o));$e("node.pool-batch.error",{batchId:n.batchId,batchKey:n.batchKey,fileCount:n.files.length,batchBytes:r,durationMs:Date.now()-i,error:l.message}),n.reject(l)}}async parseFiles(e,n,r,i){let s=Date.now();try{let o=await e.parseBatch(n.map(u=>({file:u.absPath,root:this.projectRoot,lang:u.lang})),{batchId:r,batchBytes:i});Be("clojure-parse-batch.complete",{projectRoot:this.projectRoot,batchId:r,fileCount:n.length,batchBytes:i,durationMs:Date.now()-s,split:!1});let l=new Map;for(let u=0;u<n.length;u+=1){let m=n[u],d=o[u]??null;d?l.set(m.fileKey,d):(X("IndexingAudit","clojure analysis returned no result",{projectRoot:this.projectRoot,batchId:r,file:m.absPath}),l.set(m.fileKey,{error:`clojure analysis returned no result for ${m.absPath}`}))}return l}catch(o){if(n.length>1){let m=Date.now(),d=Math.ceil(n.length/2),f=n.slice(0,d),y=n.slice(d),_=await this.parseFiles(e,f,r,f.reduce((v,K)=>v+Math.max(0,K.size||0),0)),x=await this.parseFiles(e,y,r,y.reduce((v,K)=>v+Math.max(0,K.size||0),0));return Be("clojure-parse-batch.split",{projectRoot:this.projectRoot,batchId:r,fileCount:n.length,batchBytes:i,durationMs:Date.now()-m,leftCount:f.length,rightCount:y.length,error:o instanceof Error?o.message:String(o)}),new Map([..._,...x])}let l=o instanceof Error?o:new Error(String(o));Be("clojure-parse-batch.error",{projectRoot:this.projectRoot,batchId:r,fileCount:n.length,batchBytes:i,durationMs:Date.now()-s,error:l.message});let u=new Map;for(let m of n)X("IndexingAudit","clojure analysis request failed",{projectRoot:this.projectRoot,batchId:r,file:m.absPath,error:l.message}),u.set(m.fileKey,{error:l.message});return u}}notifyIfIdle(){if(this.queue.length||this.inFlight.size)return;let e=this.drainWaiters.splice(0,this.drainWaiters.length);for(let n of e)try{n()}catch{}}};function Wr(t,e){if(typeof e?.size=="number"&&typeof e?.mtime=="number")return{size:e.size,mtime:e.mtime};try{let n=Jr.statSync(t);return{size:typeof e?.size=="number"?e.size:n.size,mtime:typeof e?.mtime=="number"?e.mtime:Math.floor(n.mtimeMs)}}catch{return{size:e?.size,mtime:e?.mtime}}}function Xr(t,e){let n=new Map;for(let r of e.nodes??[]){if(!r.name||r.containerKind||n.has(r.name))continue;let i=`${t}#${r.start}-${r.end}:${ee.getAbbrev(r.kind,"clojure")}:${r.name}`;n.set(r.name,i)}return r=>n.get(r)??null}function Ur(t){let e=t?.error;return typeof e=="string"&&e.trim().length>0?e.trim():null}var qe=class{constructor(e){this.projectRoot=e;this.cache=new de;this.pool=new ze(e)}prepare(e){let n=Wr(e.absPath,e.meta),r=this.cache.get(e.absPath,n);return{fileKey:e.relPath,absPath:e.absPath,relPath:e.relPath,meta:n,preDeleted:e.preDeleted,lang:e.lang,cachedParsed:r??void 0}}batchKey(e){return`${this.projectRoot}::clojure`}async analyzeBatch(e){let n=new Map,r=e.filter(s=>!s.cachedParsed);for(let s of e)s.cachedParsed&&n.set(s.fileKey,s.cachedParsed);if(!r.length)return n;let i=await this.pool.submit(this.batchKey(r[0]),r.map(s=>({fileKey:s.fileKey,absPath:s.absPath,lang:s.lang,size:s.meta?.size??0})));for(let s of r){let o=i.get(s.fileKey)??{error:`missing clojure analysis result for ${s.relPath}`};"error"in o||this.cache.set(s.absPath,s.meta??{},o),n.set(s.fileKey,o)}return n}buildProcessedFile(e,n,r){let i=Ur(r);return i?(X("IndexingAudit","clojure batch analysis failed",{projectRoot:this.projectRoot,relPath:e.relPath,error:i}),he("clojure",e.relPath,n.meta)):ye({lang:"clojure",fileRel:e.relPath,content:e.content,meta:n.meta,preDeleted:e.preDeleted,parsed:r,resolveNodeId:Xr(e.relPath,r),exportKind:"cli"})}async flush(){await this.pool.flush()}async close(){await this.pool.close()}};function Vr(...t){let e=t.map(n=>{if(typeof n=="string")return n;try{return JSON.stringify(n)}catch{return String(n)}}).join(" ");X("ClojureCliAdapter",e)}function mn(){return{id:"clojure",extensions:[".clj",".cljc",".cljs"],indexingMode:"batch",createBatchIndexer:t=>new qe(t),resolveSpan:(t,e,n)=>{let r=fn(t);return r?r.resolve({file:e,root:t,lang:"clojure",nodePath:n}).catch(i=>(Vr(`[${new Date().toISOString()}] [ClojureCliAdapter] resolve error`,{file:e,nodePath:n,error:i?.message||i}),null)):null}}}function $a(t){return t.indexingMode==="worker"&&typeof t.createIndexer=="function"}var mt={ts:Ve("ts"),js:Ve("js"),python:Mt(),c:{...it("c"),extensions:[".c",".h",".i",".inc"]},cpp:{...it("cpp"),extensions:[".cc",".cpp",".cxx",".c++",".cp",".ccm",".cppm",".cxxm",".ixx",".hpp",".hh",".hxx",".h++",".ii",".inl",".ipp",".tcc",".tpp",".txx"]},csharp:zt(),dart:tn(),java:an(),clojure:mn()},gn=new Map;for(let t of Object.values(mt))for(let e of t.extensions)gn.set(e,t.id);function Qr(){return xt(yt())}function Ba(t){let e=t.toLowerCase().match(/\.[a-z0-9+]+$/);return e?gn.get(e[0])??null:null}function za(t){return mt[t]}function qa(t){let e=t??Qr(),n=new Set;for(let[i,s]of Object.entries(e.byLanguage))s.enabled&&n.add(i);let r=new Set;for(let i of Object.values(mt))if(n.has(i.id))for(let s of i.extensions)r.add(s);return r}import Gr from"fs";import hn from"path";import{promises as Yr}from"fs";import Va from"ignore";function yn(t,e){let n=t.split(/\r?\n/).map(s=>s.trim()).filter(Boolean);if(!n.length)return[];let r=e?`${e}/`:"";return n.map(s=>s.startsWith("\\#")||s.startsWith("\\!")?s.slice(1):s).filter(s=>!s.startsWith("#")).map(s=>{let o=s.startsWith("!"),l=o?s.slice(1):s;if(!l)return s;if((l.endsWith("/")?l.slice(0,-1):l).includes("/")){if(!r&&l.startsWith("/"))return o?`!${l}`:l;let f=l.startsWith("/")?l.slice(1):l,y=r?`${r}${f}`:f;return o?`!${y}`:y}let d=r?`${r}**/${l}`:l;return o?`!${d}`:d})}function Qa(t,e){let n=hn.join(t,".gitignore");try{let r=Gr.readFileSync(n,"utf8");return yn(r,e)}catch{return[]}}async function Ga(t,e){let n=hn.join(t,".gitignore");try{let r=await Yr.readFile(n,"utf8");return yn(r,e)}catch{return[]}}function Zr(t,e="Operation cancelled"){let n=typeof t=="string"&&t.trim()?t.trim():t instanceof Error&&t.message.trim()?t.message.trim():e,r=new Error(n);return r.name="AbortError",r.code="ABORT_ERR",r}function Za(t,e){if(t?.aborted)throw Zr(t.reason,e)}export{vn as a,he as b,$a as c,Qr as d,Ba as e,za as f,qa as g,Za as h,Qa as i,Ga as j};
|