pando-ai 0.1.1 → 0.1.2

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.
Files changed (150) hide show
  1. package/dist/cli.js +216 -352
  2. package/dist/watcher-process.js +546 -686
  3. package/dist/workers/chunk-LGZQCDFH.mjs +522 -0
  4. package/dist/workers/{chunk-HQDE7M4W.mjs → chunk-ODST7O2H.mjs} +4 -4
  5. package/dist/workers/indexer-worker.mjs +1 -1
  6. package/dist/workers/snapshot-worker.mjs +3 -3
  7. package/dist/workers/sqlite-writer-worker.mjs +16 -63
  8. package/package.json +10 -6
  9. package/resources/tools/pando-tools.json +832 -429
  10. package/tools/clojure-editor/lib/pando-clojure-editor-standalone.jar +0 -0
  11. package/tools/clojure-indexer/lib/pando-clojure-indexer-standalone.jar +0 -0
  12. package/tools/csharp-indexer/CSharpIndexer.csproj +12 -0
  13. package/tools/csharp-indexer/bin/Release/net10.0/CSharpIndexer +0 -0
  14. package/tools/csharp-indexer/bin/Release/net10.0/CSharpIndexer.deps.json +383 -0
  15. package/tools/csharp-indexer/bin/Release/net10.0/CSharpIndexer.dll +0 -0
  16. package/tools/csharp-indexer/bin/Release/net10.0/CSharpIndexer.pdb +0 -0
  17. package/tools/csharp-indexer/bin/Release/net10.0/CSharpIndexer.runtimeconfig.json +13 -0
  18. package/tools/csharp-indexer/bin/Release/net10.0/Humanizer.dll +0 -0
  19. package/tools/csharp-indexer/bin/Release/net10.0/Microsoft.CodeAnalysis.CSharp.Workspaces.dll +0 -0
  20. package/tools/csharp-indexer/bin/Release/net10.0/Microsoft.CodeAnalysis.CSharp.dll +0 -0
  21. package/tools/csharp-indexer/bin/Release/net10.0/Microsoft.CodeAnalysis.Workspaces.dll +0 -0
  22. package/tools/csharp-indexer/bin/Release/net10.0/Microsoft.CodeAnalysis.dll +0 -0
  23. package/tools/csharp-indexer/bin/Release/net10.0/System.Composition.AttributedModel.dll +0 -0
  24. package/tools/csharp-indexer/bin/Release/net10.0/System.Composition.Convention.dll +0 -0
  25. package/tools/csharp-indexer/bin/Release/net10.0/System.Composition.Hosting.dll +0 -0
  26. package/tools/csharp-indexer/bin/Release/net10.0/System.Composition.Runtime.dll +0 -0
  27. package/tools/csharp-indexer/bin/Release/net10.0/System.Composition.TypedParts.dll +0 -0
  28. package/tools/csharp-indexer/bin/Release/net10.0/cs/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  29. package/tools/csharp-indexer/bin/Release/net10.0/cs/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  30. package/tools/csharp-indexer/bin/Release/net10.0/cs/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  31. package/tools/csharp-indexer/bin/Release/net10.0/cs/Microsoft.CodeAnalysis.resources.dll +0 -0
  32. package/tools/csharp-indexer/bin/Release/net10.0/de/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  33. package/tools/csharp-indexer/bin/Release/net10.0/de/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  34. package/tools/csharp-indexer/bin/Release/net10.0/de/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  35. package/tools/csharp-indexer/bin/Release/net10.0/de/Microsoft.CodeAnalysis.resources.dll +0 -0
  36. package/tools/csharp-indexer/bin/Release/net10.0/es/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  37. package/tools/csharp-indexer/bin/Release/net10.0/es/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  38. package/tools/csharp-indexer/bin/Release/net10.0/es/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  39. package/tools/csharp-indexer/bin/Release/net10.0/es/Microsoft.CodeAnalysis.resources.dll +0 -0
  40. package/tools/csharp-indexer/bin/Release/net10.0/fr/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  41. package/tools/csharp-indexer/bin/Release/net10.0/fr/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  42. package/tools/csharp-indexer/bin/Release/net10.0/fr/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  43. package/tools/csharp-indexer/bin/Release/net10.0/fr/Microsoft.CodeAnalysis.resources.dll +0 -0
  44. package/tools/csharp-indexer/bin/Release/net10.0/it/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  45. package/tools/csharp-indexer/bin/Release/net10.0/it/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  46. package/tools/csharp-indexer/bin/Release/net10.0/it/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  47. package/tools/csharp-indexer/bin/Release/net10.0/it/Microsoft.CodeAnalysis.resources.dll +0 -0
  48. package/tools/csharp-indexer/bin/Release/net10.0/ja/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  49. package/tools/csharp-indexer/bin/Release/net10.0/ja/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  50. package/tools/csharp-indexer/bin/Release/net10.0/ja/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  51. package/tools/csharp-indexer/bin/Release/net10.0/ja/Microsoft.CodeAnalysis.resources.dll +0 -0
  52. package/tools/csharp-indexer/bin/Release/net10.0/ko/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  53. package/tools/csharp-indexer/bin/Release/net10.0/ko/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  54. package/tools/csharp-indexer/bin/Release/net10.0/ko/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  55. package/tools/csharp-indexer/bin/Release/net10.0/ko/Microsoft.CodeAnalysis.resources.dll +0 -0
  56. package/tools/csharp-indexer/bin/Release/net10.0/pl/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  57. package/tools/csharp-indexer/bin/Release/net10.0/pl/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  58. package/tools/csharp-indexer/bin/Release/net10.0/pl/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  59. package/tools/csharp-indexer/bin/Release/net10.0/pl/Microsoft.CodeAnalysis.resources.dll +0 -0
  60. package/tools/csharp-indexer/bin/Release/net10.0/pt-BR/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  61. package/tools/csharp-indexer/bin/Release/net10.0/pt-BR/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  62. package/tools/csharp-indexer/bin/Release/net10.0/pt-BR/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  63. package/tools/csharp-indexer/bin/Release/net10.0/pt-BR/Microsoft.CodeAnalysis.resources.dll +0 -0
  64. package/tools/csharp-indexer/bin/Release/net10.0/ru/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  65. package/tools/csharp-indexer/bin/Release/net10.0/ru/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  66. package/tools/csharp-indexer/bin/Release/net10.0/ru/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  67. package/tools/csharp-indexer/bin/Release/net10.0/ru/Microsoft.CodeAnalysis.resources.dll +0 -0
  68. package/tools/csharp-indexer/bin/Release/net10.0/tr/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  69. package/tools/csharp-indexer/bin/Release/net10.0/tr/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  70. package/tools/csharp-indexer/bin/Release/net10.0/tr/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  71. package/tools/csharp-indexer/bin/Release/net10.0/tr/Microsoft.CodeAnalysis.resources.dll +0 -0
  72. package/tools/csharp-indexer/bin/Release/net10.0/zh-Hans/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  73. package/tools/csharp-indexer/bin/Release/net10.0/zh-Hans/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  74. package/tools/csharp-indexer/bin/Release/net10.0/zh-Hans/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  75. package/tools/csharp-indexer/bin/Release/net10.0/zh-Hans/Microsoft.CodeAnalysis.resources.dll +0 -0
  76. package/tools/csharp-indexer/bin/Release/net10.0/zh-Hant/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  77. package/tools/csharp-indexer/bin/Release/net10.0/zh-Hant/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  78. package/tools/csharp-indexer/bin/Release/net10.0/zh-Hant/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  79. package/tools/csharp-indexer/bin/Release/net10.0/zh-Hant/Microsoft.CodeAnalysis.resources.dll +0 -0
  80. package/tools/csharp-indexer/bin/Release/net8.0/CSharpIndexer +0 -0
  81. package/tools/csharp-indexer/bin/Release/net8.0/CSharpIndexer.deps.json +400 -0
  82. package/tools/csharp-indexer/bin/Release/net8.0/CSharpIndexer.dll +0 -0
  83. package/tools/csharp-indexer/bin/Release/net8.0/CSharpIndexer.pdb +0 -0
  84. package/tools/csharp-indexer/bin/Release/net8.0/CSharpIndexer.runtimeconfig.json +13 -0
  85. package/tools/csharp-indexer/bin/Release/net8.0/Humanizer.dll +0 -0
  86. package/tools/csharp-indexer/bin/Release/net8.0/Microsoft.CodeAnalysis.CSharp.Workspaces.dll +0 -0
  87. package/tools/csharp-indexer/bin/Release/net8.0/Microsoft.CodeAnalysis.CSharp.dll +0 -0
  88. package/tools/csharp-indexer/bin/Release/net8.0/Microsoft.CodeAnalysis.Workspaces.dll +0 -0
  89. package/tools/csharp-indexer/bin/Release/net8.0/Microsoft.CodeAnalysis.dll +0 -0
  90. package/tools/csharp-indexer/bin/Release/net8.0/System.Composition.AttributedModel.dll +0 -0
  91. package/tools/csharp-indexer/bin/Release/net8.0/System.Composition.Convention.dll +0 -0
  92. package/tools/csharp-indexer/bin/Release/net8.0/System.Composition.Hosting.dll +0 -0
  93. package/tools/csharp-indexer/bin/Release/net8.0/System.Composition.Runtime.dll +0 -0
  94. package/tools/csharp-indexer/bin/Release/net8.0/System.Composition.TypedParts.dll +0 -0
  95. package/tools/csharp-indexer/bin/Release/net8.0/System.IO.Pipelines.dll +0 -0
  96. package/tools/csharp-indexer/bin/Release/net8.0/cs/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  97. package/tools/csharp-indexer/bin/Release/net8.0/cs/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  98. package/tools/csharp-indexer/bin/Release/net8.0/cs/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  99. package/tools/csharp-indexer/bin/Release/net8.0/cs/Microsoft.CodeAnalysis.resources.dll +0 -0
  100. package/tools/csharp-indexer/bin/Release/net8.0/de/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  101. package/tools/csharp-indexer/bin/Release/net8.0/de/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  102. package/tools/csharp-indexer/bin/Release/net8.0/de/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  103. package/tools/csharp-indexer/bin/Release/net8.0/de/Microsoft.CodeAnalysis.resources.dll +0 -0
  104. package/tools/csharp-indexer/bin/Release/net8.0/es/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  105. package/tools/csharp-indexer/bin/Release/net8.0/es/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  106. package/tools/csharp-indexer/bin/Release/net8.0/es/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  107. package/tools/csharp-indexer/bin/Release/net8.0/es/Microsoft.CodeAnalysis.resources.dll +0 -0
  108. package/tools/csharp-indexer/bin/Release/net8.0/fr/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  109. package/tools/csharp-indexer/bin/Release/net8.0/fr/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  110. package/tools/csharp-indexer/bin/Release/net8.0/fr/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  111. package/tools/csharp-indexer/bin/Release/net8.0/fr/Microsoft.CodeAnalysis.resources.dll +0 -0
  112. package/tools/csharp-indexer/bin/Release/net8.0/it/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  113. package/tools/csharp-indexer/bin/Release/net8.0/it/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  114. package/tools/csharp-indexer/bin/Release/net8.0/it/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  115. package/tools/csharp-indexer/bin/Release/net8.0/it/Microsoft.CodeAnalysis.resources.dll +0 -0
  116. package/tools/csharp-indexer/bin/Release/net8.0/ja/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  117. package/tools/csharp-indexer/bin/Release/net8.0/ja/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  118. package/tools/csharp-indexer/bin/Release/net8.0/ja/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  119. package/tools/csharp-indexer/bin/Release/net8.0/ja/Microsoft.CodeAnalysis.resources.dll +0 -0
  120. package/tools/csharp-indexer/bin/Release/net8.0/ko/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  121. package/tools/csharp-indexer/bin/Release/net8.0/ko/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  122. package/tools/csharp-indexer/bin/Release/net8.0/ko/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  123. package/tools/csharp-indexer/bin/Release/net8.0/ko/Microsoft.CodeAnalysis.resources.dll +0 -0
  124. package/tools/csharp-indexer/bin/Release/net8.0/pl/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  125. package/tools/csharp-indexer/bin/Release/net8.0/pl/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  126. package/tools/csharp-indexer/bin/Release/net8.0/pl/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  127. package/tools/csharp-indexer/bin/Release/net8.0/pl/Microsoft.CodeAnalysis.resources.dll +0 -0
  128. package/tools/csharp-indexer/bin/Release/net8.0/pt-BR/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  129. package/tools/csharp-indexer/bin/Release/net8.0/pt-BR/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  130. package/tools/csharp-indexer/bin/Release/net8.0/pt-BR/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  131. package/tools/csharp-indexer/bin/Release/net8.0/pt-BR/Microsoft.CodeAnalysis.resources.dll +0 -0
  132. package/tools/csharp-indexer/bin/Release/net8.0/ru/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  133. package/tools/csharp-indexer/bin/Release/net8.0/ru/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  134. package/tools/csharp-indexer/bin/Release/net8.0/ru/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  135. package/tools/csharp-indexer/bin/Release/net8.0/ru/Microsoft.CodeAnalysis.resources.dll +0 -0
  136. package/tools/csharp-indexer/bin/Release/net8.0/tr/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  137. package/tools/csharp-indexer/bin/Release/net8.0/tr/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  138. package/tools/csharp-indexer/bin/Release/net8.0/tr/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  139. package/tools/csharp-indexer/bin/Release/net8.0/tr/Microsoft.CodeAnalysis.resources.dll +0 -0
  140. package/tools/csharp-indexer/bin/Release/net8.0/zh-Hans/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  141. package/tools/csharp-indexer/bin/Release/net8.0/zh-Hans/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  142. package/tools/csharp-indexer/bin/Release/net8.0/zh-Hans/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  143. package/tools/csharp-indexer/bin/Release/net8.0/zh-Hans/Microsoft.CodeAnalysis.resources.dll +0 -0
  144. package/tools/csharp-indexer/bin/Release/net8.0/zh-Hant/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  145. package/tools/csharp-indexer/bin/Release/net8.0/zh-Hant/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  146. package/tools/csharp-indexer/bin/Release/net8.0/zh-Hant/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  147. package/tools/csharp-indexer/bin/Release/net8.0/zh-Hant/Microsoft.CodeAnalysis.resources.dll +0 -0
  148. package/tools/csharp-indexer/bin/pando-csharp-indexer +32 -0
  149. package/tools/csharp-indexer/bin/pando-csharp-indexer.cmd +17 -0
  150. package/dist/workers/chunk-62Z76NNE.mjs +0 -522
@@ -1,522 +0,0 @@
1
- import{c as Pn,d as ee,e as q,f as te,g as xt}from"./chunk-HQDE7M4W.mjs";import{a as wn,b as le}from"./chunk-AYCBSZ56.mjs";var Y,ce=le(()=>{"use strict";Y={getAbbrev(t,e="ts"){return t},getKindFromAbbrev(t,e="ts"){return t}}});import{Node as O}from"ts-morph";function xe(t){let e=t.getKindName?.()||"Unknown",n=Et(t,e);return{kind:n.kind,semanticKind:n.semanticKind,rawKind:e,rawKindSource:Pt.TS_MORPH}}function Rt(t){let e=t.getKindName?.()||"Unknown";return{kind:Et(t,e).kind,rawKind:e,rawKindSource:Pt.TS_MORPH}}function Pe(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):""}`)}var Pt,Et,Ee=le(()=>{"use strict";Pt={TS_MORPH:"ts-morph",PYTHON_AST:"python-ast",CLANG:"clang",ROSLYN:"roslyn",JAVA_AST:"java-ast",CLI:"cli",UNKNOWN:"unknown"},Et=(t,e)=>O.isFunctionDeclaration(t)||O.isFunctionExpression(t)||O.isArrowFunction(t)?{kind:"Function",semanticKind:"function"}:O.isGetAccessorDeclaration(t)||O.isSetAccessorDeclaration(t)?{kind:"Method",semanticKind:"property"}:O.isMethodDeclaration(t)||O.isMethodSignature(t)||O.isConstructorDeclaration(t)?{kind:"Method",semanticKind:"method"}:O.isClassDeclaration(t)||O.isClassExpression(t)?{kind:"Class",semanticKind:"class"}:O.isInterfaceDeclaration(t)?{kind:"Interface",semanticKind:"interface"}:O.isEnumDeclaration(t)?{kind:"Enum",semanticKind:"enum"}:O.isEnumMember(t)?{kind:"EnumMember",semanticKind:"enum"}:O.isTypeAliasDeclaration(t)?{kind:"TypeAlias",semanticKind:"type"}:O.isModuleDeclaration(t)?{kind:"Namespace",semanticKind:"namespace"}:O.isPropertyDeclaration(t)||O.isPropertySignature(t)?{kind:"Field",semanticKind:"property"}:O.isVariableDeclaration(t)?{kind:"Variable",semanticKind:"variable"}:{kind:e,semanticKind:null}});var Xe=le(()=>{"use strict";ce();Ee();te()});function En(){return new Date().toISOString()}function Re(t,e,n){let r=`[${En()}] [${t.toUpperCase()}] ${e}`;if(!n)return r;try{return r+" "+JSON.stringify(n)}catch{return r}}var Rn,_t=le(()=>{"use strict";Rn={debug:(t,e)=>{try{process.stderr.write(Re("debug",t,e)+`
2
- `)}catch{}},info:(t,e)=>{try{process.stderr.write(Re("info",t,e)+`
3
- `)}catch{}},warn:(t,e)=>{try{process.stderr.write(Re("warn",t,e)+`
4
- `)}catch{}},error:(t,e)=>{try{process.stderr.write(Re("error",t,e)+`
5
- `)}catch{}}}});import{Node as ki}from"ts-morph";var At=le(()=>{"use strict";Ue();Xe();_t();te()});import*as kn from"xxhash-wasm";var In,Dn,zi,Ue=le(()=>{"use strict";At();In="__pando_xxhash_instance__",Dn=globalThis,zi=Dn[In]??null});ce();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}`:"",a=t.targetNodeId??"",o=`${e}:REF:${n}:${r}|${i}${s}|${a}`;return xt(o)}function St(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}te();function me(t,e,n){let r=new Date().toISOString();return{payload:{lang:t,fileRel:e,preDeleted:!1,exportRows:[],nodeRows:[],referenceRows:[],importRows:[],importBindingRows:[],fileRow:[e,n?.mtime??null,n?.size??null,"failed",r],fts:null},fileSize:n?.size,mtime:n?.mtime}}function he(t){let{lang:e,fileRel:n,content:r,meta:i,preDeleted:s,parsed:a,resolveNodeId:o,exportKind:d}=t,h=[];for(let u of a.nodes??[]){let C=u.rawKind??u.kind,x=u.rawKindSource??"cli",_=u.containerRawKind??u.containerKind??null,j=u.containerRawKindSource??(_?"cli":null),$=u.scopeChain??null,g=Array.isArray($)?JSON.stringify($):typeof $=="string"?$:null,y=`${n}#${u.start}-${u.end}:${Y.getAbbrev(u.kind,e)}`,v=(e==="c"||e==="cpp"||e==="java"||e==="clojure")&&u.name?`${y}:${u.name}`:y,S=u.metadata&&Object.keys(u.metadata).length?JSON.stringify(u.metadata):null;h.push([v,u.name,u.kind,C,x,u.semanticKind??null,u.start,u.end,typeof u.isExported=="number"?u.isExported:0,u.containerKind??null,_,j,typeof u.paramCount=="number"?u.paramCount:null,u.qualifiedName??null,g,u.symbolKey??null,S])}let p=[],m=new Set;for(let u of St(a)){if(!u.name||m.has(u.name))continue;m.add(u.name);let C=u.nodeId??(o?o(u.name):null);p.push([n,u.name,C??null,u.isReexport?1:0,u.reexportFrom??null,u.reexportName??null,u.exportKind??d??"cli",u.targetSymbolKey??null])}let b=[],w=new Map,N=new Map;for(let u of h){let C=u[0]!=null?String(u[0]):null,x=u[13]!=null?String(u[13]):null,_=u[15]!=null?String(u[15]):null;C&&(x&&!w.has(x)&&w.set(x,C),_&&!N.has(_)&&N.set(_,C))}if(ee()&&e==="clojure"&&(a.references??[]).length>0){let u=Array.from(w.keys()).slice(0,10),C=Array.from(N.keys()).slice(0,10),x=(a.references??[]).slice(0,10).map(j=>j.containerQualifiedName),_={file:n,nodeCount:h.length,refCount:(a.references??[]).length,nodeQualifiedNames:u,nodeSymbolKeys:C,refContainers:x,qualifiedNameMapSize:w.size,symbolKeyMapSize:N.size};try{console.error("[CliPayload][CLOJURE-DEBUG] source_node_id lookup context",_)}catch{}}for(let u of a.references??[]){let C=u.targetNodeId??(o&&u.refName?o(u.refName):null),x=u.targetFile??(C?n:null),_=u.sourceNodeId??(u.containerQualifiedName?w.get(u.containerQualifiedName)??null:null)??(u.containerQualifiedName?N.get(u.containerQualifiedName)??null:null),j=we({sourceFile:n,sourceStart:u.sourceStart,sourceEnd:u.sourceEnd,refKind:u.refKind,refName:u.refName,targetFile:x??null,targetStart:u.targetStart??null,targetEnd:u.targetEnd??null,targetNodeId:C??u.targetNodeId??null}),$=u.metadata&&Object.keys(u.metadata).length?JSON.stringify(u.metadata):null;b.push([j,n,_,u.refName??null,u.refKind,u.sourceStart,u.sourceEnd,C??u.targetNodeId??null,x??null,C||u.targetNodeId||u.targetFile?"resolved":"unresolved",u.receiverName??null,typeof u.arity=="number"?u.arity:null,u.containerQualifiedName??null,u.targetSymbolKey??null,u.confidence??null,$])}if(ee()&&e==="clojure"&&b.length>0){let u=b.reduce((x,_)=>x+(_?.[2]!=null?1:0),0),C=b.reduce((x,_)=>x+(_?.[12]!=null?1:0),0);try{console.error("[CliPayload] clojure source-node summary",{file:n,refs:b.length,sourceNodeCount:u,containerCount:C,sample:b.slice(0,5).map(x=>({sourceNodeId:x[2]==null?null:String(x[2]),refName:x[3],refKind:x[4],containerQualifiedName:x[12]}))})}catch{}}let E=[];for(let u of a.imports??[])E.push([n,u.module??null,u.isTypeOnly??0]);let I=[];for(let u of a.importBindings??[])I.push([n,u.module??null,u.kind,u.localName,u.importedName,u.isTypeOnly??0]);let R=new Date().toISOString(),c=[n,i?.mtime??null,i?.size??null,"completed",R];return{payload:{lang:e,fileRel:n,preDeleted:!!s,exportRows:p,nodeRows:h,referenceRows:b,importRows:E,importBindingRows:I,fileRow:c,fts:typeof r=="string"?{blobOid:n,content:r}:null},fileSize:i?.size,mtime:i?.mtime}}var ye=["ts","js","python","c","cpp","csharp","dart","java","clojure"];function Je(t){return typeof t=="string"&&ye.includes(t)}Pn();te();function vt(){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(Je);if(n.length>0)return Nt(n)}return[...ye]}function Nt(t){let e=new Set;for(let n of t)Je(n)&&e.add(n);return ye.filter(n=>e.has(n))}function Ct(t){let e=new Set(Nt(t)),n={};for(let r of ye){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 Ye from"path";import Jn from"fs";import{Project as Wn,Node as W}from"ts-morph";import{Node as f,SyntaxKind as ue}from"ts-morph";import*as J from"typescript";import{SyntaxKind as be}from"ts-morph";var We={LINE_COMMENT:{kind:9001,name:"LineComment",triviaKind:be.SingleLineCommentTrivia},BLOCK_COMMENT:{kind:9002,name:"BlockComment",triviaKind:be.MultiLineCommentTrivia},JSDOC_COMMENT:{kind:9003,name:"JSDocComment",triviaKind:be.MultiLineCommentTrivia}};function wt(t,e){return t===be.SingleLineCommentTrivia?We.LINE_COMMENT:t===be.MultiLineCommentTrivia&&e.startsWith("/**")?We.JSDOC_COMMENT:We.BLOCK_COMMENT}Ue();Xe();import{Node as K,SyntaxKind as l,Scope as Ve}from"ts-morph";var Gi=new Set([l.ArrayLiteralExpression,l.ArrayType,l.ArrowFunction,l.AsExpression,l.AssertClause,l.AssertEntry,l.AwaitExpression,l.BigIntLiteral,l.BinaryExpression,l.BindingElement,l.Block,l.CallExpression,l.CallSignature,l.CaseClause,l.CatchClause,l.ClassDeclaration,l.ClassExpression,l.ClassStaticBlockDeclaration,l.ComputedPropertyName,l.ConditionalExpression,l.ConditionalType,l.ConstructSignature,l.Constructor,l.ConstructorType,l.Decorator,l.DefaultClause,l.DoStatement,l.ElementAccessExpression,l.EnumDeclaration,l.EnumMember,l.ExportAssignment,l.ExportDeclaration,l.ExportSpecifier,l.ExpressionStatement,l.ExpressionWithTypeArguments,l.FalseKeyword,l.ForInStatement,l.ForOfStatement,l.ForStatement,l.FunctionDeclaration,l.FunctionExpression,l.FunctionType,l.GetAccessor,l.Identifier,l.IfStatement,l.ImportAttribute,l.ImportAttributes,l.ImportClause,l.ImportDeclaration,l.ImportEqualsDeclaration,l.ImportSpecifier,l.ImportType,l.IndexSignature,l.IndexedAccessType,l.InferType,l.InterfaceDeclaration,l.IntersectionType,l.JsxAttribute,l.JsxClosingElement,l.JsxClosingFragment,l.JsxElement,l.JsxExpression,l.JsxFragment,l.JsxOpeningElement,l.JsxOpeningFragment,l.JsxSelfClosingElement,l.JsxSpreadAttribute,l.JsxText,l.LiteralType,l.MappedType,l.MetaProperty,l.MethodDeclaration,l.MethodSignature,l.ModuleDeclaration,l.NamedExports,l.NamedImports,l.NamedTupleMember,l.NamespaceExport,l.NamespaceExportDeclaration,l.NamespaceImport,l.NewExpression,l.NoSubstitutionTemplateLiteral,l.NonNullExpression,l.NullKeyword,l.NumericLiteral,l.ObjectLiteralExpression,l.OptionalType,l.Parameter,l.ParenthesizedType,l.PostfixUnaryExpression,l.PrefixUnaryExpression,l.PrivateIdentifier,l.PropertyAccessExpression,l.PropertyAssignment,l.PropertyDeclaration,l.PropertySignature,l.QualifiedName,l.RegularExpressionLiteral,l.RestType,l.ReturnStatement,l.SatisfiesExpression,l.SetAccessor,l.ShorthandPropertyAssignment,l.SourceFile,l.SpreadAssignment,l.SpreadElement,l.StringLiteral,l.SwitchStatement,l.TaggedTemplateExpression,l.TemplateExpression,l.TemplateLiteralType,l.ThisType,l.ThrowStatement,l.TrueKeyword,l.TryStatement,l.TupleType,l.TypeAliasDeclaration,l.TypeLiteral,l.TypeOfExpression,l.TypeOperator,l.TypeParameter,l.TypePredicate,l.TypeQuery,l.TypeReference,l.UnionType,l.VariableDeclaration,l.VariableStatement,l.WhileStatement,l.YieldExpression]);function Kn(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 Fn(t){try{if(!K.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 Mn(t){try{let e=new Set;if(K.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(K.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 Tt(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 Ln(t){try{if(typeof t.getScope!="function")return null;let e=t.getScope();return e===Ve.Private||e===Ve.Protected||e===Ve.Public?e:null}catch{return null}}function kt(t){let e={kind:t.getKindName()},n=Kn(t);if(n.length&&(e.decorators=n),T(e,"flags",()=>t.getFlags()),(K.isFunctionDeclaration(t)||K.isMethodDeclaration(t)||K.isFunctionExpression(t))&&(T(e,"isAsync",()=>t.isAsync()),T(e,"isGenerator",()=>t.isGenerator()),T(e,"parameterCount",()=>t.getParameters().length),T(e,"returnType",()=>Tt(t)),K.isFunctionDeclaration(t)&&T(e,"isExported",()=>t.isExported())),K.isClassDeclaration(t)){T(e,"isAbstract",()=>t.isAbstract()),T(e,"isExported",()=>t.isExported());let i=Mn(t);i.length&&(e.extends=i);let s=Fn(t);s.length&&(e.implements=s)}if(K.isVariableDeclaration(t)&&(T(e,"declarationKind",()=>t.getVariableStatement()?.getDeclarationKind()),T(e,"hasInitializer",()=>t.hasInitializer()),T(e,"type",()=>t.getTypeNode()?.getText())),(K.isPropertyDeclaration(t)||K.isPropertySignature(t)||K.isParameterDeclaration(t))&&(T(e,"isStatic",()=>t.isStatic?.()),T(e,"isReadonly",()=>t.isReadonly?.()),T(e,"isOptional",()=>t.hasQuestionToken?.()),T(e,"scope",()=>t.getScope?.())),(K.isMethodDeclaration(t)||K.isMethodSignature(t)||K.isGetAccessorDeclaration(t)||K.isSetAccessorDeclaration(t))&&(T(e,"isStatic",()=>t.isStatic?.()),T(e,"isAbstract",()=>t.isAbstract?.()),T(e,"isAsync",()=>t.isAsync?.()),T(e,"returnType",()=>Tt(t)),T(e,"scope",()=>t.getScope?.())),K.isCallExpression(t)){let i=t.getExpression();if(K.isPropertyAccessExpression(i)){e.propertyName=i.getName();let s=i.getExpression();K.isIdentifier(s)&&(e.objectName=s.getText())}else K.isIdentifier(i)&&(e.functionName=i.getText());e.argumentCount=t.getArguments().length,e.callExpression=i.getText()}let r=Ln(t);return r&&(e.visibility=r),e.isReadonly||T(e,"isReadonly",()=>t.isReadonly?.()),K.isImportDeclaration(t)&&(T(e,"moduleSpecifier",()=>t.getModuleSpecifier()?.getLiteralText()),T(e,"isTypeOnly",()=>t.isTypeOnly()),T(e,"namedImports",()=>t.getNamedImports()?.map(i=>i.getName()).join(", ")),T(e,"defaultImport",()=>t.getDefaultImport()?.getText())),Object.keys(e).forEach(i=>{e[i]===void 0&&delete e[i]}),e}function T(t,e,n){try{let r=n();r!=null&&(t[e]=r)}catch{}}Ee();function On(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 jn(t){if(t.length<2)return t;let e=new Map;for(let n of t){let r=On(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 _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 Qe(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 $n(t){try{if(f.isFunctionDeclaration(t)||f.isMethodDeclaration(t)||f.isConstructorDeclaration(t)||f.isFunctionExpression(t)||f.isArrowFunction(t)){let e=t.getParameters?.();if(Array.isArray(e))return e.length}}catch{}return null}function Bn(t){try{return f.isIdentifier(t)?t.getSymbol():f.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 zn(t,e,n){if(!f.isImportDeclaration(t))return;let i={moduleSpecifier:t.getModuleSpecifierValue(),isTypeOnly:t.isTypeOnly(),namedImports:[]};try{let s=t.getDefaultImport();if(s){let a=s.getText();i.defaultImport=a,n(a,s)}}catch{}try{let s=t.getNamespaceImport();if(s){let a=s.getText();i.namespaceImport=a,n(a,s)}}catch{}try{t.getNamedImports().forEach(s=>{try{let a=s.getName(),o=s.getAliasNode(),d=o?o.getText():void 0;a&&(i.namedImports.push({name:a,alias:d||void 0}),n(d||a,s.getNameNode()))}catch{}})}catch{}e.push(i)}function qn(t,e){if(f.isExportDeclaration(t)){let n=t.getModuleSpecifierValue();if(n){if(t.getNamedExports().length>0)try{t.getNamedExports().forEach(r=>{try{let i=r.getName(),s=r.getAliasNode(),a=s?s.getText():void 0;e.push({kind:"reexport",moduleSpecifier:n,name:i||void 0,alias:a||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(),a=s?s.getText():i;e.push({kind:"alias",local:i,exported:a})}catch{}})}catch{}return}if(f.isExportAssignment(t))try{let n=t.getExpression();if(n&&f.isIdentifier(n)){let r=n.getText();e.push({kind:"alias",local:r,exported:"default"})}}catch{}}function Hn(t,e,n,r){if(!Ae(t,ue.ExportKeyword))return;let i=Ae(t,ue.DefaultKeyword);if(f.isVariableStatement(t)){try{let s=t.getDeclarationList().getDeclarations();for(let a of s){let o=_e(a)??a.getName?.()??null;if(o){n(o,a);let d=r(a);d&&e.push({kind:"local",name:o,isDefault:i,nodeId:d})}}}catch{}return}if(f.isFunctionDeclaration(t)||f.isClassDeclaration(t)||f.isInterfaceDeclaration(t)||f.isEnumDeclaration(t)||f.isTypeAliasDeclaration(t)||f.isModuleDeclaration(t)){let s=_e(t)||(i?"default":null),a=r(t);a&&e.push({kind:"local",name:s??"default",isDefault:i,nodeId:a})}}function It(t,e,n,r){let i=[],s=[],a=[],o=new Set,d=new Map,h=[],p=[],m=[{node:t,id:null,kind:"module",rawKind:"SourceFile",rawKindSource:"ts-morph",name:null,isExported:!1}],b=c=>{if(!c)return null;try{return e(c)}catch{return null}},w=(c,P)=>{if(c&&(o.has(c)||o.add(c),P&&!d.has(c))){let u=b(P);u&&d.set(c,u)}},N=c=>f.isFunctionDeclaration(c)||f.isFunctionExpression(c)||f.isArrowFunction(c)||f.isClassDeclaration(c)||f.isClassExpression(c)||f.isInterfaceDeclaration(c)||f.isEnumDeclaration(c)||f.isEnumMember(c)||f.isTypeAliasDeclaration(c)||f.isModuleDeclaration(c)||f.isMethodDeclaration(c)||f.isMethodSignature(c)||f.isPropertyDeclaration(c)||f.isPropertySignature(c)||f.isGetAccessorDeclaration(c)||f.isSetAccessorDeclaration(c)||f.isConstructorDeclaration(c)||f.isVariableDeclaration(c)||f.isReturnStatement(c)||f.isIfStatement(c)||f.isForStatement(c)||f.isForInStatement(c)||f.isForOfStatement(c)||f.isWhileStatement(c)||f.isDoStatement(c)||f.isSwitchStatement(c)||f.isCaseClause(c)||f.isDefaultClause(c)||f.isTryStatement(c)||f.isCatchClause(c)||f.isThrowStatement(c)||f.isExpressionStatement(c)||f.isBlock(c),E=c=>f.isSourceFile(c)||f.isFunctionDeclaration(c)||f.isFunctionExpression(c)||f.isArrowFunction(c)||f.isMethodDeclaration(c)||f.isConstructorDeclaration(c)||f.isClassDeclaration(c)||f.isClassExpression(c)||f.isModuleDeclaration(c),I=c=>{let P=_e(c);if(P)return P;if(f.isConstructorDeclaration(c))return"constructor";if(f.isArrowFunction(c)||f.isFunctionExpression(c)){let u=c.getParent();try{if(f.isVariableDeclaration(u))return u.getName();if(f.isPropertyAssignment(u)||f.isPropertyDeclaration(u)||f.isPropertySignature(u))return u.getName?.()??null;if(f.isShorthandPropertyAssignment(u))return u.getNameNode()?.getText()??null;if(f.isExportAssignment(u))return"default"}catch{}}if(f.isEnumMember(c))try{return c.getName()}catch{return null}if(f.isVariableDeclaration(c))try{return c.getName()}catch{return null}return null},R=c=>{let P=m[m.length-1],u=P?.id??null,C=P?.kind??"module",x=P?.name??null;if(f.isImportDeclaration(c))zn(c,h,w);else if(f.isImportEqualsDeclaration(c))try{let g=c.getModuleReference();if(g&&f.isExternalModuleReference(g)){let y=g.getExpression(),v;if(y&&f.isStringLiteral(y))v=y.getLiteralText();else if(y){let S=y.getText();v=typeof S=="string"?S.replace(/^['"]|['"]$/g,""):void 0}if(v){let M=c.getNameNode()?.getText(),B={moduleSpecifier:v,isTypeOnly:!1,namedImports:[]};M&&(B.defaultImport=M,w(M,c)),h.push(B)}}}catch{}(f.isExportDeclaration(c)||f.isExportAssignment(c))&&qn(c,p),Hn(c,p,w,b);let _=N(c),j=I(c);if(_){let g=e(c);s.push({nodeId:g,node:c});let y=Ae(c,ue.ExportKeyword)||P?.isExported||!1,v=c.getNameNode?.()?.getText?.()??null,S=j??_e(c)??v;j?w(j,c):S&&w(S,c);let M=Qe(c),B=$n(c),D={...kt(c)};if(u&&(D.containerId=u),C&&(D.containerKind=C),x&&(D.containerName=x),f.isModuleDeclaration(c))try{let L=c.getNameNode?.();if(L){let z=Qe(L);Number.isFinite(z.start)&&Number.isFinite(z.end)&&(D.moduleNameStart=z.start,D.moduleNameEnd=z.end)}}catch{}let k=Object.keys(D).length?D:null,F=xe(c);Pe(F,{source:"ts-node-collector",file:t.getFilePath(),name:S??null}),i.push({nodeId:g,nodeName:S??null,containerId:u,containerKind:C,containerRawKind:P?.rawKind??null,containerRawKindSource:P?.rawKindSource??null,containerName:x,isExported:y,kind:F.kind,rawKind:F.rawKind,rawKindSource:F.rawKindSource,semanticKind:F.semanticKind??null,start:M.start,end:M.end,paramCount:B,metadata:k})}if(f.isCallExpression(c)||f.isNewExpression(c)){let g=c.getExpression(),y=null,v,S;try{if(S=Bn(g),f.isIdentifier(g))y=g.getText();else if(f.isPropertyAccessExpression(g)){y=g.getName();let D=g.getExpression();f.isIdentifier(D)&&(v=D.getText())}}catch{}let M="";try{M=g.getText()}catch{}let B=Qe(c);if(a.push({name:y,kind:f.isNewExpression(c)?"new":"call",containerId:u,containerKind:C,containerName:x,expression:M,objectName:v,symbol:S,start:B.start,end:B.end}),f.isCallExpression(c))try{if(f.isIdentifier(g)&&g.getText()==="require"){let k=c.getArguments()[0],F;if(k&&(f.isStringLiteral(k)||f.isNoSubstitutionTemplateLiteral(k)))try{F=k.getLiteralText()}catch{let L=k.getText();F=typeof L=="string"?L.replace(/^['"]|['"]$/g,""):void 0}if(F){let L={moduleSpecifier:F,isTypeOnly:!1,namedImports:[]},z=c.getParent();if(z&&f.isVariableDeclaration(z)){let Z=z.getNameNode();try{if(f.isIdentifier(Z)){let Q=Z.getText();Q&&(L.defaultImport=Q,w(Q,z))}}catch{}}h.push(L)}}else if(g?.getKind?.()===ue.ImportKeyword){let k=c.getArguments()[0],F;if(k&&(f.isStringLiteral(k)||f.isNoSubstitutionTemplateLiteral(k)))try{F=k.getLiteralText()}catch{let L=k.getText();F=typeof L=="string"?L.replace(/^['"]|['"]$/g,""):void 0}F&&h.push({moduleSpecifier:F,isTypeOnly:!1,namedImports:[]})}}catch{}}if(f.isCallExpression(c)){let g=c.getExpression();try{if(f.isIdentifier(g)&&g.getText()==="require"){let y=c.getParent();if(!(y&&f.isExternalModuleReference(y))){let S=c.getArguments()[0],M;if(S&&(f.isStringLiteral(S)||f.isNoSubstitutionTemplateLiteral(S)))try{M=S.getLiteralText()}catch{M=S.getText().replace(/^['"]|['"]$/g,"")}if(M){let B={moduleSpecifier:M,isTypeOnly:!1,namedImports:[]};if(y&&f.isVariableDeclaration(y)){let D=y.getNameNode();try{if(f.isIdentifier(D)){let k=D.getText();k&&(B.defaultImport=k,w(k,y))}}catch{}}h.push(B)}}}else if(g?.getKind?.()===ue.ImportKeyword){let v=c.getArguments()[0],S;if(v&&(f.isStringLiteral(v)||f.isNoSubstitutionTemplateLiteral(v)))try{S=v.getLiteralText()}catch{S=v.getText().replace(/^['"]|['"]$/g,"")}S&&h.push({moduleSpecifier:S,isTypeOnly:!1,namedImports:[]})}}catch{}}let $=!1;if(E(c)){let g=b(c)??e(c),y=Rt(c);m.push({node:c,id:g,kind:y.kind,rawKind:y.rawKind,rawKindSource:y.rawKindSource,name:j??x,isExported:Ae(c,ue.ExportKeyword)||P?.isExported||!1}),$=!0}c.forEachChild(R),$&&m.pop()};if(t.forEachChild(R),r?.includeComments===!0||process.env.AST_INDEX_COMMENTS==="1")try{let c=t.getFullText(),P=J.createScanner(J.ScriptTarget.Latest,!1,J.LanguageVariant.Standard,c),u=new Set;for(let C=P.scan();C!==J.SyntaxKind.EndOfFileToken;C=P.scan()){if(C!==J.SyntaxKind.SingleLineCommentTrivia&&C!==J.SyntaxKind.MultiLineCommentTrivia)continue;let x=P.getTokenPos(),_=P.getTextPos(),j=`${x}-${_}`;if(u.has(j)||(u.add(j),n.has(j)))continue;n.add(j);let $=c.substring(x,_),g=wt(C,$),v=e({getKindName:()=>g.name,getKind:()=>g.kind,getPos:()=>x,getEnd:()=>_,getStart:()=>x,getFullStart:()=>x,getText:()=>$,getSourceFile:()=>t,getParent:()=>t,__isComment:!0,__commentPosition:"standalone",__attachedTo:null},"COM");i.push({nodeId:v,nodeName:$.substring(0,100),containerId:null,containerKind:"module",containerRawKind:"SourceFile",containerRawKindSource:"ts-morph",containerName:null,isExported:!1,kind:g.name,rawKind:g.name,rawKindSource:"ts-morph",semanticKind:null,start:x,end:_,paramCount:null,metadata:null})}}catch{}return{nodes:i,symbolCandidateNodes:s,references:a,declaredNames:o,localDeclarations:d,imports:h,exports:jn(p)}}ce();function Dt(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}}Ee();var Xn=100;function Un(t,e,n,r){let{start:i,end:s}=Dt(e),a=xe(e);Pe(a,{source:"ts-node-id",file:t,kind:a.kind});let o=r||Y.getAbbrev(a.kind,n);return`${t}#${i}-${s}:${o}`}function Vn(t,e){return Ye.relative(t,e).replace(/\\/g,"/")}function Kt(t,e){if(!t)return null;let n=t;try{let p=t.getAliasedSymbol();p&&(n=p)}catch{}let r=[];try{r=n.getDeclarations()??[]}catch{r=[]}if(!r.length)return null;let s=r.slice().sort((p,m)=>{let b=p.getSourceFile().getFilePath(),w=m.getSourceFile().getFilePath();if(b!==w)return b.localeCompare(w);let N=p.getStart(!1),E=m.getStart(!1);return N!==E?N-E:p.getEnd()-m.getEnd()})[0],a=Vn(e,s.getSourceFile().getFilePath()),o=s.getStart(!1),d=s.getEnd(),h="";try{h=n.getEscapedName()}catch{try{h=n.getName()}catch{h=""}}return`${a}#${o}-${d}:${h}`}function Qn(t){try{return W.isVariableDeclaration(t)||W.isEnumMember(t)?t.getNameNode().getSymbol()??t.getSymbol():t.getSymbol()}catch{return}}function Gn(t,e){let n=t.getDescendantAtPos(e);if(!n)return;let r=n;if(!W.isCallExpression(r)&&!W.isNewExpression(r)&&(r=n.getFirstAncestor(s=>W.isCallExpression(s)||W.isNewExpression(s))??void 0),!r||!W.isCallExpression(r)&&!W.isNewExpression(r))return;let i=r.getExpression();try{return W.isIdentifier(i)?i.getSymbol():W.isPropertyAccessExpression(i)?i.getNameNode().getSymbol()??i.getSymbol():i.getSymbol()}catch{return}}async function Yn(t){let{sf:e,fileRel:n,content:r,preDeleted:i,meta:s,projectRoot:a,lang:o}=t,h=It(e,(g,y)=>Un(n,g,o,y),new Set,{includeComments:!1}),p=new Map;for(let{nodeId:g,node:y}of h.symbolCandidateNodes){let v=Kt(Qn(y),a);v&&(p.has(g)||p.set(g,v))}let m=[],b=new Map,w=h.exports.filter(g=>g.kind!=="reexport"),N=h.exports.filter(g=>g.kind==="reexport");for(let g of w)if(g.kind==="local"){let y=g.isDefault?"default":g.name;if(!y||b.has(y))continue;let v=g.nodeId;m.push([n,y,v,0,null,null,g.isDefault?"default":"named"]),b.set(y,v)}else if(g.kind==="alias"){let y=g.exported;if(!y||b.has(y))continue;m.push([n,y,null,0,null,g.local,"alias"]),b.set(y,"alias")}for(let g of N){let y=g.moduleSpecifier;if(!y)continue;let v=y;if(g.isNamespace){let S=g.alias||"*";if(b.has(S))continue;m.push([n,S,null,1,v,g.name||S,"reexport_star"]),b.set(S,"reexport")}else{let S=g.alias||g.name;if(!S||b.has(S))continue;m.push([n,S,null,1,v,g.name||S,"reexport_named"]),b.set(S,"reexport")}}let E=[],I=typeof r=="string"?r:null;if(I==null)try{let g=e.getFullText();I=typeof g=="string"?g:null}catch{I=null}for(let g of h.nodes){let{nodeId:y,nodeName:v,containerKind:S,containerRawKind:M,containerRawKindSource:B,isExported:D,kind:k,rawKind:F,rawKindSource:L,semanticKind:z,start:Z,end:Q,paramCount:qe,metadata:G}=g,He=G&&Object.keys(G).length?JSON.stringify(G):null,Cn=p.get(y)??null;E.push([y,v??null,k,F??k,L??null,z??null,Z,Q,D?1:0,S??"module",M??S??"module",B??null,qe,null,null,Cn,He])}let R=[];for(let g of h.references){let{name:y,kind:v,containerId:S,containerName:M,expression:B,objectName:D,start:k,end:F}=g,L=null,z=null,Z=Kt(g.symbol??Gn(e,k),a),Q=y?h.localDeclarations.get(y):void 0;Q&&(L=Q,z=n,Z||(Z=p.get(Q)??null));let qe=we({sourceFile:n,sourceStart:k,sourceEnd:F,refKind:v,refName:y,targetFile:z,targetNodeId:L}),G={};B&&(G.expression=B),D&&(G.objectName=D),M&&(G.containerName=M);let He=Object.keys(G).length?JSON.stringify(G):null;R.push([qe,n,S,y,v,k,F,L,z,L?"resolved":"unresolved",D??null,null,null,Z,He])}let c=[],P=[];for(let g of h.imports){let y=g.moduleSpecifier??null;c.push([n,y,g.isTypeOnly?1:0]),g.defaultImport&&P.push([n,y,"default",g.defaultImport,"default",g.isTypeOnly?1:0]),g.namespaceImport&&P.push([n,y,"namespace",g.namespaceImport,"*",g.isTypeOnly?1:0]);for(let v of g.namedImports){let S=v.alias||v.name;P.push([n,y,"named",S,v.name,g.isTypeOnly?1:0])}}let u=Ye.join(a,n),C=s?.size,x=s?.mtime;if(C===void 0||x===void 0)try{let g=Jn.statSync(u);C=g.size,x=Math.floor(g.mtimeMs)}catch{}let _=new Date().toISOString(),j=[n,x??null,C??null,"completed",_],$=null;if(typeof I=="string")$={blobOid:n,content:I};else try{let g=e.getFullText?.();typeof g=="string"&&($={blobOid:n,content:g})}catch(g){console.log(`[TypescriptIndexer] Failed to compute FTS payload for ${n}:`,g?.message??g)}return{payload:{lang:o,fileRel:n,preDeleted:i,exportRows:m,nodeRows:E,referenceRows:R,importRows:c,importBindingRows:P,fileRow:j,fts:$},fileSize:C,mtime:x}}var Ge=class{constructor(e,n){this.project=null;this.filesProcessed=0;this.projectRoot=e,this.lang=n}getProject(){return this.project||(this.project=new Wn({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 r=this.getProject().createSourceFile(Ye.join(this.projectRoot,e.relPath),e.content,{overwrite:!0}),i=await Yn({sf:r,fileRel:e.relPath,content:e.content,preDeleted:!!e.preDeleted,meta:e.meta,projectRoot:this.projectRoot,lang:e.lang});return this.filesProcessed++,this.filesProcessed>=Xn&&(this.disposeProject(),this.filesProcessed=0),{payload:i.payload,fileSize:i.fileSize,mtime:i.mtime}}};function Zn(t){return t==="ts"?[".ts",".tsx",".mts",".cts"]:t==="js"?[".js",".jsx",".mjs",".cjs"]:[]}function Ze(t){return{id:t,extensions:Zn(t),indexingMode:"worker",createIndexer:e=>new Ge(e,t)}}import Te from"fs";import ne from"path";import{spawn as rr,spawnSync as jt}from"child_process";import er 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()}};ce();var et=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 a=er.statSync(e.absPath);n=Math.floor(a.mtimeMs),r=a.size}catch{}let i=this.cache.get(e.absPath,{mtime:n,size:r});if(i)return he({lang:this.lang,fileRel:e.relPath,content:e.content,meta:{mtime:n,size:r},preDeleted:e.preDeleted,parsed:i,resolveNodeId:Ft(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(a){try{console.log(`[CliContract:${this.lang}] parse threw for ${e.relPath}: ${a?.message||String(a)}`)}catch{}return me(this.lang,e.relPath,{mtime:n,size:r})}return!s||s.error?me(this.lang,e.relPath,{mtime:n,size:r}):(this.cache.set(e.absPath,{mtime:n,size:r},s),he({lang:this.lang,fileRel:e.relPath,content:e.content,meta:{mtime:n,size:r},preDeleted:e.preDeleted,parsed:s,resolveNodeId:Ft(e.relPath,s,this.lang),exportKind:this.exportKind??"cli"}))}};function Ft(t,e,n){let r=new Map;for(let i of e.nodes??[]){if(!i.name||i.containerKind||r.has(i.name))continue;let s=`${t}#${i.start}-${i.end}:${Y.getAbbrev(i.kind,n)}`;r.set(i.name,s)}return i=>r.get(i)??null}function X(t){return{id:t.id,extensions:t.extensions,indexingMode:"worker",createIndexer:e=>new et(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 tr from"fs";import tt from"path";var Mt=null;function nr(t){for(let e of t)if(tr.existsSync(e))return e;return null}function U(t){let e=Mt?.toolsRoot??process.env.PANDO_TOOLS_ROOT,n=Mt?.runtimeRoot??process.env.PANDO_RUNTIME_ROOT,r=[e?tt.join(e,t):null,n?tt.join(n,"tools",t):null,tt.resolve(process.cwd(),"tools",t)].filter(i=>!!i);return nr(r)}function H(...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=rr(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=>{H(`[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&&H("[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},a=Date.now(),o={op:e,id:i};return typeof n?.path=="string"&&(o.path=n.path),typeof n?.nodePath=="string"&&(o.nodePath=n.nodePath),typeof n?.content_b64=="string"&&(o.contentBytes=n.content_b64.length),new Promise((d,h)=>{let p=setTimeout(()=>{this.pending.delete(i),H("[PythonCliAdapter] worker timeout",{op:e,id:i,timeoutMs:r,pending:this.pending.size,interpreter:this.interpreter,...o}),h(new Error(`python worker timeout (${e})`))},r);this.pending.set(i,{resolve:d,reject:h,timeout:p,summary:o}),this.pending.size%200===0&&H("[PythonCliAdapter] worker pending",{op:e,pending:this.pending.size,interpreter:this.interpreter});try{this.sendMessage(s)}catch(m){clearTimeout(p),this.pending.delete(i),h(m)}})}async request(e,n,r=1e4){await this.ready;let i=Date.now(),s=await this.requestRaw(e,n,r),a=Date.now()-i;return a>2e3&&H("[PythonCliAdapter] worker slow",{op:e,ms:a,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}},ir=`
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
- `,sr=`
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 $t(t){let e=ne.resolve(t,"tools/python-indexer/pando_python_worker.py");if(Te.existsSync(e))return e;let n=U("python-indexer/pando_python_worker.py");if(n)return n;let r=ne.resolve(__dirname,"../../../../../tools/python-indexer/pando_python_worker.py");return Te.existsSync(r)?r:null}var fe=new Map;function pe(t){try{return Te.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 ar(t){let e=pe(ne.join(t,"pyproject.toml"));if(e){let o=e.match(/requires-python\s*=\s*"([^"]+)"/i),d=Se(o?.[1]??null);if(d)return d}let n=pe(ne.join(t,"setup.cfg"));if(n){let o=n.match(/python_requires\s*=\s*([\w\d\.<>~=\s]+)/i),d=Se(o?.[1]??null);if(d)return d}let r=pe(ne.join(t,"setup.py"));if(r){let o=r.match(/python_requires\s*=\s*['\"]([^'\"]+)['\"]/i),d=Se(o?.[1]??null);if(d)return d}let i=pe(ne.join(t,"tox.ini"));if(i){let o=i.match(/envlist\s*=\s*([^\n]+)/i);if(o&&o[1]){let d=o[1].split(/[,\s]+/).filter(Boolean);for(let h of d){let p=h.match(/py(\d)(\d)/i);if(p)return{major:Number(p[1]),minor:Number(p[2])}}}}let s=pe(ne.join(t,".python-version"));if(s){let o=Se(s.trim());if(o)return o}let a=pe(ne.join(t,"runtime.txt"));if(a){let o=a.match(/python-(\d+\.\d+)/i),d=Se(o?.[1]??null);if(d)return d}return null}function Ie(t){return ar(t)?.major===2?["python2","python","python3"]:["python3","python","python2"]}async function or(t,e,n){let r=$t(t);if(!r)return null;let i=Ie(t);for(let s of i){let a=`${s}::${r}`,o=fe.get(a);if(!o)try{o=new ke(s,r),fe.set(a,o)}catch{continue}try{let d=await o.parse({path:e,content:n,encoding:"utf-8"});if(d)return d}catch{H("[PythonCliAdapter] worker parse error",{file:e,interpreter:s}),fe.delete(a)}}return null}async function lr(t,e,n,r){let i=$t(t);if(!i)return null;let s=Ie(t);for(let a of s){let o=`${a}::${i}`,d=fe.get(o);if(!d)try{d=new ke(a,i),fe.set(o,d)}catch{continue}try{let h=await d.resolve({path:e,nodePath:r,content:n,encoding:"utf-8"});if(h)return h}catch{H("[PythonCliAdapter] worker resolve error",{file:e,interpreter:a,nodePath:r}),fe.delete(o)}}return null}function Lt(t,e){let n=jt(t,["-c",ir,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 Ot(t,e,n){let r=jt(t,["-c",sr,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 cr(t){let e=Date.now(),n=!1,r=null;try{r=await or(t.projectRoot,t.absPath,t.content),n=!!r}catch{}if(!r){let a=Ie(t.projectRoot),o=null;for(let d of a)if(r=Lt(d,t.absPath),r){o=d;break}if(!r&&a.length>1){for(let d of a.slice().reverse())if(r=Lt(d,t.absPath),r){o=d;break}}if(!r){H(`[PythonCliAdapter] parse failed for ${t.relPath} (interpreters tried: ${a.join(", ")})`);let d=Date.now()-e;return d>2e3&&H("[PythonCliAdapter] parse slow (failed)",{file:t.relPath,ms:d}),null}o&&H(`[PythonCliAdapter] parse ok for ${t.relPath} via ${o}`)}let i=[];for(let a of r.references||[]){let o={};a.expression&&(o.expression=a.expression),a.objectName&&(o.objectName=a.objectName),a.containerName&&(o.containerName=a.containerName),a.containerKind&&(o.containerKind=a.containerKind),i.push({sourceStart:a.start,sourceEnd:a.end,refKind:a.kind,refName:a.name,receiverName:a.receiverName??a.objectName??null,arity:typeof a.arity=="number"?a.arity:null,containerQualifiedName:a.containerQualifiedName??null,targetSymbolKey:a.targetSymbolKey??null,metadata:Object.keys(o).length?o:null})}let s=Date.now()-e;return s>2e3&&H("[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 Bt(){return X({id:"python",extensions:[".py",".pyw",".pyi"],exportKind:"named",parse:({absPath:t,relPath:e,projectRoot:n,content:r})=>cr({absPath:t,relPath:e,projectRoot:n,content:r}),resolve:async({absPath:t,nodePath:e,projectRoot:n})=>{try{let i=Te.readFileSync(t,"utf8"),s=await lr(n,t,i,e);if(s)return s}catch{}let r=Ie(n);for(let i of r){let s=Ot(i,t,e);if(s)return s}for(let i of r.slice().reverse()){let s=Ot(i,t,e);if(s)return s}return null}})}import zt from"fs";import qt from"path";import{spawn as ur,spawnSync as js}from"child_process";var dr=256e3,pr=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 nt=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=ur(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.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 a={id:r,...e};this.pending.set(r,{resolve:i,reject:s});try{this.proc.stdin.write(`${JSON.stringify(a)}
511
- `)}catch(o){if(this.pending.delete(r),n>0){try{this.handleExit(o)}catch{}return this.request(e,n-1).then(i,s)}s(o)}})}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}},rt=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<pr;){let r=this.queue[0];if(e.length>0&&n+r.input.size>dr)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],a=r[i]??null,o=Date.now()-s.startedAt;o>2e3&&re(`[${new Date().toISOString()}] [CSharpCliAdapter] parse slow`,{file:s.input.file,ms:o,path:"custom",ok:!!a}),a||re(`[${new Date().toISOString()}] [CSharpCliAdapter] parse failed`,{file:s.input.file,ms:o,path:"custom"}),s.resolve(a)}}catch(r){for(let i of e)i.reject(r)}}}},Ht=new Map,Jt=new Map;function fr(t){let e=process.platform==="win32"?".cmd":"",n=U(`csharp-indexer/bin/pando-csharp-indexer${e}`);if(n)return n;if(t){let i=qt.resolve(t,"tools/csharp-indexer/bin/pando-csharp-indexer"+e);if(zt.existsSync(i))return i}let r=qt.resolve(__dirname,"../../../../../tools/csharp-indexer/bin/pando-csharp-indexer"+e);return zt.existsSync(r)?r:null}function Wt(t){let e=process.env.PANDO_CSHARP_INDEXER_CMD||fr(t);if(!e)return null;let n=Ht.get(e);n||(n=new nt(e),Ht.set(e,n));let r=Jt.get(e);return r||(r=new rt(n),Jt.set(e,r)),{client:n,batcher:r}}async function gr(t,e,n){let r=Wt(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 mr(t,e,n){let r=await gr(t,e,n);return r||null}function Xt(){return X({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 mr(t,e,i)},resolve:({absPath:t,nodePath:e,projectRoot:n})=>{let r=Date.now(),i=Wt(n);return i?i.client.resolve({file:t,root:n,lang:"csharp",nodePath:e}).then(s=>{let a=Date.now()-r;return a>2e3&&re(`[${new Date().toISOString()}] [CSharpCliAdapter] resolve slow`,{file:t,ms:a}),s||re(`[${new Date().toISOString()}] [CSharpCliAdapter] resolve failed`,{file:t,ms:a,nodePath:e}),s}).catch(s=>{let a=Date.now()-r;return re(`[${new Date().toISOString()}] [CSharpCliAdapter] resolve error`,{file:t,ms:a,nodePath:e,error:s?.message||s}),null}):null}})}import{spawnSync as Nr}from"child_process";import Cr from"path";import V from"fs";import A from"path";var De=new Map,hr=["include","src","lib","libs","third_party","third-party","deps","vendor"];function Vt(t){let e=[],n="",r=null,i=!1;for(let s=0;s<t.length;s+=1){let a=t[s];if(i){n+=a,i=!1;continue}if(a==="\\"){i=!0;continue}if(r){a===r?r=null:n+=a;continue}if(a==='"'||a==="'"){r=a;continue}if(a===" "||a===`
512
- `||a===" "||a==="\r"){n&&(e.push(n),n="");continue}n+=a}return n&&e.push(n),e}function yr(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++"))&&A.isAbsolute(i)||n.push(i))}}return n}function Qt(t,e){return A.isAbsolute(t)?A.resolve(t):e?A.resolve(e,t):A.resolve(t)}function br(t){try{let e=V.readFileSync(t,"utf8"),n=JSON.parse(e),r=new Map;for(let i of n){let s=i.directory?A.resolve(i.directory):void 0,a=i.file?Qt(i.file,s):null;if(!a)continue;let o=s??A.dirname(a),d=Array.isArray(i.arguments)?i.arguments:i.command?Vt(i.command):[];if(d.length===0)continue;let h=yr(d.slice(1),a);r.set(a,{args:h,cwd:o})}return r}catch{return null}}function xr(t){try{let e=V.readFileSync(t,"utf8");return Vt(e.replace(/\r/g,`
513
- `))}catch{return null}}function Gt(t){let e=A.join(t,"compile_commands.json");if(V.existsSync(e))return e;let n=["build","out","build-debug","build-release","cmake-build-debug","cmake-build-release"];for(let o of n){let d=A.join(t,o,"compile_commands.json");if(V.existsSync(d))return d}let r=n.map(o=>A.join(t,o)).filter(o=>V.existsSync(o));r.push(t);let i=10,s=new Set,a=(o,d)=>{if(d>i)return null;let h=A.resolve(o);if(s.has(h))return null;s.add(h);try{let p=V.readdirSync(o,{withFileTypes:!0});for(let m of p)if(m.isFile()&&m.name==="compile_commands.json")return A.join(o,m.name);for(let m of p){if(!m.isDirectory()||m.name==="node_modules"||m.name.startsWith("."))continue;let b=a(A.join(o,m.name),d+1);if(b)return b}}catch{}return null};for(let o of r){let d=a(o,0);if(d)return d}return null}function Sr(t,e){let n=A.resolve(t),r=A.resolve(e);for(;;){let i=Gt(n);if(i)return i;if(n===r)break;let s=A.dirname(n);if(s===n)break;n=s}return null}function Yt(t){let e=A.join(t,"compile_flags.txt");if(V.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=A.join(t,r,"compile_flags.txt");if(V.existsSync(i))return i}return null}function vr(t,e){let n=A.resolve(t),r=A.resolve(e);for(;;){let i=Yt(n);if(i)return i;if(n===r)break;let s=A.dirname(n);if(s===n)break;n=s}return null}function Ke(t){if(t)try{return V.statSync(t).mtimeMs}catch{return}}function Ut(t,e){let n=e?`${A.resolve(t)}::${A.resolve(e)}`:A.resolve(t),r=De.get(n);if(r){let m=Ke(r.commandsPath);if(r.commandsPath&&m&&r.commandsMtime&&m!==r.commandsMtime)De.delete(n);else if(r.flagsPath){let b=Ke(r.flagsPath);b&&r.flagsMtime&&b!==r.flagsMtime&&De.delete(n)}else return r}let i=e?Sr(e,t):Gt(t),s=i?br(i)??void 0:void 0,a=Ke(i),o=s?null:e?vr(e,t):Yt(t),d=o?xr(o)??void 0:void 0,h=Ke(o),p={commands:s,flags:d,commandsPath:i,commandsMtime:a,flagsPath:o,flagsMtime:h};return De.set(n,p),p}function it(t,e,n){let r=A.dirname(e),i=Ut(t);!i.commands&&!i.flags&&(i=Ut(t,r));let s=Qt(e);if(i.commands){let a=i.commands.get(s);if(a)return{args:a.args,cwd:a.cwd,source:"compile_commands"}}return i.flags?{args:i.flags,cwd:t,source:"compile_flags"}:st(t,n)}function st(t,e){let n=["-std="+(e==="cpp"?"c++20":"c17")];n.push("-I",t);for(let r of hr){let i=A.join(t,r);V.existsSync(i)&&n.push("-I",i)}return n.push("-ferror-limit=0"),{args:n,cwd:t,source:"fallback"}}function tn(t){let e=[0];for(let n=0;n<t.length;n+=1)t.charCodeAt(n)===10&&e.push(n+1);return e}function Zt(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 ge(t){return t?Cr.resolve(t):null}function en(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=en(e,n,r.line);if((r.col??1)-1>s)return null;if(i?.line){let d=en(e,n,i.line);if((i.col??r.col??1)-1>d)return null}let a=Zt(e,r.line,r.col),o=Zt(e,i?.line??r.line,i?.col??r.col);return{start:a,end:Math.max(o,a)}}function Le(t){let e=t.range?.begin?.file||t.loc?.file||t.range?.end?.file||null;if(e)return ge(e);let n=t.range?.begin?.includedFrom?.file||t.range?.end?.includedFrom?.file||null;return ge(n)}function wr(t){let e=t.access;return typeof e=="string"?e:null}function Pr(t,e){let n={};e.containerName&&(n.containerName=e.containerName);let r=wr(t);r&&(n.visibility=r);let i=t.storageClass;i&&(n.storageClass=i);let s=t.isInline;typeof s=="boolean"&&(n.isInline=s);let a=t.isConstexpr;typeof a=="boolean"&&(n.isConstexpr=a);let o=t.isVirtual;typeof o=="boolean"&&(n.isVirtual=o);let d=t.isStatic;typeof d=="boolean"&&(n.isStatic=d);let h=t.type;return typeof h=="string"&&(n.type=h),n}function at(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 Er(t,e,n,r){let i=[],s=ge(e),a=(o,d)=>{let h=Le(o),m=h&&(!s||h===s)?at(o.kind,o.tagUsed,d.containerKind):null,b=o.name;if(m&&b){m.kind==="Method"&&typeof b=="string"&&b.startsWith("operator")&&(m={kind:"Operator",semanticKind:"method"});let N=ie(o,n,r);if(N){let E=Pr(o,d);(m.kind==="Template"||m.kind==="TemplateParameter")&&(E.isTemplate=!0),m.kind==="Operator"&&(E.isOperator=!0),i.push({name:b,kind:m.kind,rawKind:o.kind??null,rawKindSource:"clang",semanticKind:m.semanticKind??null,start:N.start,end:N.end,isExported:d.containerKind?0:1,containerKind:d.containerKind??null,containerRawKind:d.containerRawKind??null,containerRawKindSource:d.containerRawKind?"clang":null,paramCount:null,metadata:Object.keys(E).length?E:null})}}let w=d;if(o.kind==="RecordDecl"&&o.name){let N=at(o.kind,o.tagUsed,d.containerKind);N&&(w={containerKind:N.kind,containerName:o.name,containerRawKind:o.kind??null})}o.kind==="EnumDecl"&&o.name&&(w={containerKind:"Enum",containerName:o.name,containerRawKind:o.kind??null}),o.kind==="NamespaceDecl"&&o.name&&(w={containerKind:"Namespace",containerName:o.name,containerRawKind:o.kind??null});for(let N of o.inner??[])a(N,w)};return a(t,{}),{nodes:i}}function ot(t,e,n){let r=Nr(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 nn(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 Rr(t,e){let n=[],r=ge(e),i=s=>{let a=Le(s);if(a&&(!r||a===r)&&s.kind==="InclusionDirective"){let h=s.spelling||s.includeName||null||s.file||s.filename||s.includedFile||s.headerName||null;h&&n.push({module:String(h),isTypeOnly:0})}for(let d of s.inner??[])i(d)};return i(t),{imports:n}}function Me(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 Me(e)}if(t.kind==="CallExpr"||t.kind==="CXXMemberCallExpr"){for(let e of t.inner??[])if(e.kind==="MemberExpr")return Me(e)}return null}function _r(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 Ar(t){if(t.kind!=="CallExpr")return null;let e=t.inner?.[0];return e&&e.kind==="MemberExpr"?Me(e):null}function Fe(t,e){return t.containerQualifiedName?`${t.containerQualifiedName}::${e}`:e}function Tr(t,e,n,r){let i=[],s=ge(e),a=r.length,o=(p,m,b)=>{let w=Le(p),N=w&&(!s||w===s);if(N&&(p.kind==="CallExpr"||p.kind==="CXXConstructExpr"||p.kind==="CXXNewExpr")){let R=ie(p,n,a);if(R){let c=ve(p),P=p.kind==="CallExpr"?"call":"new",u=r.slice(R.start,R.end),C=Ar(p),x=_r(p);i.push({sourceStart:R.start,sourceEnd:R.end,refKind:P,refName:c,receiverName:C??void 0,arity:typeof x=="number"?x:void 0,containerQualifiedName:m.containerQualifiedName??void 0,metadata:u?{expression:u,containerName:m.containerName,containerKind:m.containerKind}:null})}}if(N&&p.kind==="TypeRef"){let R=ie(p,n,a);if(R){let c=ve(p);i.push({sourceStart:R.start,sourceEnd:R.end,refKind:"type",refName:c,containerQualifiedName:m.containerQualifiedName??void 0,metadata:{containerName:m.containerName,containerKind:m.containerKind}})}}if(N&&(p.kind==="DeclRefExpr"||p.kind==="MemberExpr")&&!(b.includes("CallExpr")||b.includes("CXXConstructExpr")||b.includes("CXXNewExpr"))){let c=ie(p,n,a);if(c){let P=ve(p),u=p.kind==="MemberExpr"?Me(p):void 0;i.push({sourceStart:c.start,sourceEnd:c.end,refKind:"reference",refName:P,receiverName:u??void 0,containerQualifiedName:m.containerQualifiedName??void 0,metadata:{containerName:m.containerName,containerKind:m.containerKind}})}}if(N&&(p.kind==="MacroExpansion"||p.kind==="MacroInstantiation")){let R=ie(p,n,a);if(R){let c=ve(p);i.push({sourceStart:R.start,sourceEnd:R.end,refKind:"macro",refName:c,containerQualifiedName:m.containerQualifiedName??void 0,metadata:{containerName:m.containerName,containerKind:m.containerKind}})}}let E=m;if(p.kind==="RecordDecl"&&p.name){let R=at(p.kind,p.tagUsed,m.containerKind);R&&(E={containerKind:R.kind,containerName:p.name,containerQualifiedName:Fe(m,p.name)})}p.kind==="EnumDecl"&&p.name&&(E={containerKind:"Enum",containerName:p.name,containerQualifiedName:Fe(m,p.name)}),p.kind==="NamespaceDecl"&&p.name&&(E={containerKind:"Namespace",containerName:p.name,containerQualifiedName:Fe(m,p.name)}),(p.kind==="FunctionDecl"||p.kind==="CXXMethodDecl"||p.kind==="CXXConstructorDecl"||p.kind==="CXXDestructorDecl")&&p.name&&(E={...E,containerQualifiedName:Fe(m,p.name)});let I=b.slice();p.kind&&I.push(p.kind);for(let R of p.inner??[])o(R,E,I)};o(t,{},[]);let d=new Set,h=[];for(let p of i){let m=`${p.sourceStart}:${p.sourceEnd}:${p.refKind}:${p.refName??""}:${p.targetNodeId??""}:${p.targetFile??""}`;d.has(m)||(d.add(m),h.push(p))}return{references:h}}function kr(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("-"),a=Number(i),o=Number(s);return!Number.isFinite(a)||!Number.isFinite(o)||o<a?null:{start:a,end:o}}function Ir(t,e,n,r,i){let s=kr(n);if(!s)return null;let a=nn(t),o=it(i,e,t),d=[...o.args,"-Xclang","-ast-dump=json","-Xclang","-detailed-preprocessing-record","-fsyntax-only","-fno-color-diagnostics","-fno-diagnostics-color",...o.source==="fallback"?["-x",t==="cpp"?"c++":"c"]:[],e],h=ot(a,d,o.cwd);if(!h||h.kind!=="TranslationUnitDecl")return null;let p=tn(r),m=r.length,b=ge(e),w=null,N=I=>{if(w)return;let R=Le(I),P=R&&(!b||R===b)?ie(I,p,m):null;if(P&&P.start===s.start&&P.end===s.end){let u=null,C=null;for(let x of I.inner??[])if(x.kind==="CompoundStmt"){let _=ie(x,p,m);if(_){u=_.start,C=_.end;break}}w={start:P.start,end:P.end,bodyStart:u,bodyEnd:C};return}for(let u of I.inner??[])N(u)};if(N(h),!w)return null;let E=w;return{start:E.start,end:E.end,bodyStart:E.bodyStart??null,bodyEnd:E.bodyEnd??null,text:r.slice(E.start,E.end)}}function lt(t){return X({id:t,extensions:[],parse:({absPath:e,relPath:n,content:r,projectRoot:i})=>{let s=nn(t),a=it(i,e,t),o=N=>[...N.args,"-Xclang","-ast-dump=json","-Xclang","-detailed-preprocessing-record","-fsyntax-only","-fno-color-diagnostics","-fno-diagnostics-color",...N.source==="fallback"?["-x",t==="cpp"?"c++":"c"]:[],e],d=ot(s,o(a),a.cwd);if(!d&&a.source!=="fallback"){let N=st(i,t);d=ot(s,o(N),N.cwd)}if(!d||d.kind!=="TranslationUnitDecl")return null;let h=tn(r??""),p=(r??"").length,{nodes:m}=Er(d,e,h,p),{imports:b}=Rr(d,e),{references:w}=Tr(d,e,h,r??"");return{nodes:m,imports:b,importBindings:[],references:w}},resolve:({absPath:e,nodePath:n,projectRoot:r})=>{try{let i=wn("fs").readFileSync(e,"utf8");return Ir(t,e,n,i,r)}catch{return null}}})}import ct from"fs";import ut from"path";import{spawn as Dr,spawnSync as ta}from"child_process";var Kr=256e3,Fr=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 dt=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("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.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 a={id:r,...e};this.pending.set(r,{resolve:i,reject:s});try{this.proc.stdin.write(`${JSON.stringify(a)}
516
- `)}catch(o){if(this.pending.delete(r),n>0){try{this.handleExit(o)}catch{}return this.request(e,n-1).then(i,s)}s(o)}})}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}},pt=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],a=r[i]??null,o=Date.now()-s.startedAt;o>2e3&&se(`[${new Date().toISOString()}] [DartCliAdapter] parse slow`,{file:s.input.file,ms:o,ok:!!a}),a||se(`[${new Date().toISOString()}] [DartCliAdapter] parse failed`,{file:s.input.file,ms:o}),s.resolve(a)}}catch(r){for(let i of e)i.reject(r)}}}},rn=new Map,sn=new Map;function Mr(t){let e=process.platform==="win32"?".cmd":"",n=U(`dart-indexer/bin/pando-dart-indexer${e}`);if(n)return n;if(t){let s=ut.resolve(t,"tools/dart-indexer/bin/pando-dart-indexer"+e);if(ct.existsSync(s))return s}let r=process.env.PANDO_EXTENSION_ROOT;if(r){let s=ut.resolve(r,"tools/dart-indexer/bin/pando-dart-indexer"+e);if(ct.existsSync(s))return s}let i=ut.resolve(process.cwd(),"tools/dart-indexer/bin/pando-dart-indexer"+e);return ct.existsSync(i)?i:null}function an(t){let e=process.env.PANDO_DART_INDEXER_CMD||Mr(t);if(!e)return null;let n=rn.get(e);n||(n=new dt(e),rn.set(e,n));let r=sn.get(e);return r||(r=new pt(n),sn.set(e,r)),{client:n,batcher:r}}async function Lr(t,e,n){let r=an(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 on(){return X({id:"dart",extensions:[".dart"],parse:async({absPath:t,projectRoot:e,content:n,meta:r})=>{let i=r?.size??Buffer.byteLength(n,"utf8");return Lr(t,e,i)},resolve:({absPath:t,nodePath:e,projectRoot:n})=>{let r=Date.now(),i=an(n);return i?i.client.resolve({file:t,root:n,lang:"dart",nodePath:e}).then(s=>{let a=Date.now()-r;return a>2e3&&se(`[${new Date().toISOString()}] [DartCliAdapter] resolve slow`,{file:t,ms:a}),s||se(`[${new Date().toISOString()}] [DartCliAdapter] resolve failed`,{file:t,ms:a,nodePath:e}),s}).catch(s=>{let a=Date.now()-r;return se(`[${new Date().toISOString()}] [DartCliAdapter] resolve error`,{file:t,ms:a,nodePath:e,error:s?.message||s}),null}):null},exportKind:"dart"})}import ft from"fs";import Ne from"path";import{spawn as Or,spawnSync as la}from"child_process";var jr=256e3,$r=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 gt=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=Or(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.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 a={id:r,...e},o=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:o});try{this.proc.stdin.write(`${JSON.stringify(a)}
519
- `)}catch(d){if(clearTimeout(o),this.pending.delete(r),n>0){try{this.handleExit(d)}catch{}return this.request(e,n-1).then(i,s)}s(d)}})}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}},mt=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<$r;){let r=this.queue[0];if(e.length>0&&n+r.input.size>jr)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],a=r[i]??null,o=Date.now()-s.startedAt;o>2e3&&oe(`[${new Date().toISOString()}] [JavaCliAdapter] parse slow`,{file:s.input.file,ms:o,path:"custom",ok:!!a}),a||oe(`[${new Date().toISOString()}] [JavaCliAdapter] parse failed`,{file:s.input.file,ms:o,path:"custom"}),s.resolve(a)}}catch(r){for(let i of e)i.reject(r)}}}},ln=new Map,cn=new Map;function Br(){return typeof __dirname=="string"?__dirname:process.cwd()}var ae,zr;function qr(t){if(ae!==void 0&&zr===t)return ae;let e=process.platform==="win32"?".cmd":"",n="tools/java-indexer/bin/pando-java-indexer"+e,r=U(`java-indexer/bin/pando-java-indexer${e}`);if(r)return ae=r,r;if(t){let s=Ne.resolve(t,n);if(ft.existsSync(s))return ae=s,s}let i=Br();for(let s=0;s<8;s++){let a=Ne.join(i,n);if(ft.existsSync(a))return ae=a,a;let o=Ne.dirname(i);if(o===i)break;i=o}i=process.cwd();for(let s=0;s<8;s++){let a=Ne.join(i,n);if(ft.existsSync(a))return ae=a,a;let o=Ne.dirname(i);if(o===i)break;i=o}return ae=null,null}function un(t){let e=process.env.PANDO_JAVA_INDEXER_CMD||qr(t);if(!e)return null;let n=ln.get(e);n||(n=new gt(e),ln.set(e,n));let r=cn.get(e);return r||(r=new mt(n),cn.set(e,r)),{client:n,batcher:r}}async function Hr(t,e,n){let r=un(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 Jr(t,e,n){let r=await Hr(t,e,n);return r||null}function dn(){return X({id:"java",extensions:[".java"],exportKind:"named",parse:({absPath:t,projectRoot:e,content:n,meta:r})=>{let i=r?.size??Buffer.byteLength(n,"utf8");return Jr(t,e,i)},resolve:({absPath:t,nodePath:e,projectRoot:n})=>{let r=Date.now(),i=un(n);return i?i.client.resolve({file:t,root:n,lang:"java",nodePath:e}).then(s=>{let a=Date.now()-r;return a>2e3&&oe(`[${new Date().toISOString()}] [JavaCliAdapter] resolve slow`,{file:t,ms:a}),s||oe(`[${new Date().toISOString()}] [JavaCliAdapter] resolve failed`,{file:t,ms:a,nodePath:e}),s}).catch(s=>{let a=Date.now()-r;return oe(`[${new Date().toISOString()}] [JavaCliAdapter] resolve error`,{file:t,ms:a,nodePath:e,error:s?.message||s}),null}):null}})}te();ce();import Qr from"fs";te();te();te();import{spawn as Wr}from"child_process";import ht from"fs";import yt from"path";function pn(t,e){let n=process.platform==="win32"?".cmd":"",r=t==="clojure-editor"?"pando-clojure-editor":"pando-clojure-indexer",i=U(`${t}/bin/${r}${n}`);if(i)return i;if(e){let o=yt.resolve(e,`tools/${t}/bin/${r}${n}`);if(ht.existsSync(o))return o}let s=process.env.PANDO_EXTENSION_ROOT;if(s){let o=yt.resolve(s,`tools/${t}/bin/${r}${n}`);if(ht.existsSync(o))return o}let a=yt.resolve(process.cwd(),`tools/${t}/bin/${r}${n}`);return ht.existsSync(a)?a:null}var mn=3e4,Xr=Math.max(mn,Number(process.env.PANDO_CLOJURE_CHANGE_SIGNATURE_TIMEOUT_MS||`${5*60*1e3}`)),fn="__PANDO_CLOJURE_INDEX__";function Ur(...t){if(!ee())return;let e=t.map(n=>{if(typeof n=="string")return n;try{return JSON.stringify(n)}catch{return String(n)}}).join(" ");q("ClojureIndexer",e)}function Ce(t,e){ee()&&q("ClojureIndex",t,e)}var Oe=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=Wr(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(fn)){let i=r.slice(fn.length);try{let s=JSON.parse(i);Ce(s.event||"jvm.trace",s)}catch(s){q("ClojureIndexer","stderr trace parse failed",{error:s?.message||String(s),line:r})}continue}Ur(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??mn,a=Date.now();return new Promise((o,d)=>{let h={id:r,...e},p=setTimeout(()=>{this.pending.delete(r),d(new Error(`clojure indexer request timed out after ${s}ms`))},s);this.pending.set(r,{resolve:m=>{Ce("node.client.request.complete",{projectRoot:this.projectRoot,id:r,op:e.op,durationMs:Date.now()-a}),o(m)},reject:d,timer:p});try{Ce("node.client.request.start",{projectRoot:this.projectRoot,id:r,op:e.op}),this.proc.stdin.write(`${JSON.stringify(h)}
522
- `)}catch(m){if(clearTimeout(p),this.pending.delete(r),i>0){try{this.handleExit(m)}catch{}return this.request(e,{retry:i-1,timeoutMs:s}).then(o,d)}d(m)}})}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:Xr});return"result"in n&&n.result||null}},gn=new Map;function hn(t){return process.env.PANDO_CLOJURE_INDEXER_CMD||pn("clojure-indexer",t)}function yn(t){let e=hn(t);return e?new Oe(e,t):null}function bn(t){let e=hn(t);if(!e)return null;let n=`${e}::${t}`,r=gn.get(n);return r||(r=new Oe(e,t),gn.set(n,r)),r}var Vr=Math.max(1,Number(process.env.PANDO_CLOJURE_ANALYZER_POOL_SIZE||"3"));function je(t,e){q("ClojureIndex",t,e)}function $e(t,e){q("IndexTiming",t,e)}var Be=class{constructor(e,n=Vr){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=yn(e);if(!s)break;this.clients.push(s),this.idleClients.push(s)}if(!this.clients.length)throw new Error("clojure indexer command unavailable");je("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((a,o)=>a+Math.max(0,o.size||0),0),i=Date.now(),s=Math.max(0,i-n.enqueuedAt);je("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 a=await this.parseFiles(e,n.files,n.batchId,r);$e("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}),je("node.pool-batch.complete",{batchId:n.batchId,batchKey:n.batchKey,fileCount:n.files.length,batchBytes:r,durationMs:Date.now()-i,successCount:Array.from(a.values()).filter(o=>!("error"in o)).length,errorCount:Array.from(a.values()).filter(o=>"error"in o).length}),n.resolve(a)}catch(a){let o=a instanceof Error?a:new Error(String(a));je("node.pool-batch.error",{batchId:n.batchId,batchKey:n.batchKey,fileCount:n.files.length,batchBytes:r,durationMs:Date.now()-i,error:o.message}),n.reject(o)}}async parseFiles(e,n,r,i){let s=Date.now();try{let a=await e.parseBatch(n.map(d=>({file:d.absPath,root:this.projectRoot,lang:d.lang})),{batchId:r,batchBytes:i});$e("clojure-parse-batch.complete",{projectRoot:this.projectRoot,batchId:r,fileCount:n.length,batchBytes:i,durationMs:Date.now()-s,split:!1});let o=new Map;for(let d=0;d<n.length;d+=1){let h=n[d],p=a[d]??null;p?o.set(h.fileKey,p):(q("IndexingAudit","clojure analysis returned no result",{projectRoot:this.projectRoot,batchId:r,file:h.absPath}),o.set(h.fileKey,{error:`clojure analysis returned no result for ${h.absPath}`}))}return o}catch(a){if(n.length>1){let h=Date.now(),p=Math.ceil(n.length/2),m=n.slice(0,p),b=n.slice(p),w=await this.parseFiles(e,m,r,m.reduce((E,I)=>E+Math.max(0,I.size||0),0)),N=await this.parseFiles(e,b,r,b.reduce((E,I)=>E+Math.max(0,I.size||0),0));return $e("clojure-parse-batch.split",{projectRoot:this.projectRoot,batchId:r,fileCount:n.length,batchBytes:i,durationMs:Date.now()-h,leftCount:m.length,rightCount:b.length,error:a instanceof Error?a.message:String(a)}),new Map([...w,...N])}let o=a instanceof Error?a:new Error(String(a));$e("clojure-parse-batch.error",{projectRoot:this.projectRoot,batchId:r,fileCount:n.length,batchBytes:i,durationMs:Date.now()-s,error:o.message});let d=new Map;for(let h of n)q("IndexingAudit","clojure analysis request failed",{projectRoot:this.projectRoot,batchId:r,file:h.absPath,error:o.message}),d.set(h.fileKey,{error:o.message});return d}}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 Gr(t,e){if(typeof e?.size=="number"&&typeof e?.mtime=="number")return{size:e.size,mtime:e.mtime};try{let n=Qr.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 Yr(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}:${Y.getAbbrev(r.kind,"clojure")}:${r.name}`;n.set(r.name,i)}return r=>n.get(r)??null}function Zr(t){let e=t?.error;return typeof e=="string"&&e.trim().length>0?e.trim():null}var ze=class{constructor(e){this.projectRoot=e;this.cache=new de;this.pool=new Be(e)}prepare(e){let n=Gr(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 a=i.get(s.fileKey)??{error:`missing clojure analysis result for ${s.relPath}`};"error"in a||this.cache.set(s.absPath,s.meta??{},a),n.set(s.fileKey,a)}return n}buildProcessedFile(e,n,r){let i=Zr(r);return i?(q("IndexingAudit","clojure batch analysis failed",{projectRoot:this.projectRoot,relPath:e.relPath,error:i}),me("clojure",e.relPath,n.meta)):he({lang:"clojure",fileRel:e.relPath,content:e.content,meta:n.meta,preDeleted:e.preDeleted,parsed:r,resolveNodeId:Yr(e.relPath,r),exportKind:"cli"})}async flush(){await this.pool.flush()}async close(){await this.pool.close()}};function ei(...t){let e=t.map(n=>{if(typeof n=="string")return n;try{return JSON.stringify(n)}catch{return String(n)}}).join(" ");q("ClojureCliAdapter",e)}function xn(){return{id:"clojure",extensions:[".clj",".cljc",".cljs"],indexingMode:"batch",createBatchIndexer:t=>new ze(t),resolveSpan:(t,e,n)=>{let r=bn(t);return r?r.resolve({file:e,root:t,lang:"clojure",nodePath:n}).catch(i=>(ei(`[${new Date().toISOString()}] [ClojureCliAdapter] resolve error`,{file:e,nodePath:n,error:i?.message||i}),null)):null}}}function qa(t){return t.indexingMode==="worker"&&typeof t.createIndexer=="function"}var bt={ts:Ze("ts"),js:Ze("js"),python:Bt(),c:{...lt("c"),extensions:[".c",".h",".i",".inc"]},cpp:{...lt("cpp"),extensions:[".cc",".cpp",".cxx",".c++",".cp",".ccm",".cppm",".cxxm",".ixx",".hpp",".hh",".hxx",".h++",".ii",".inl",".ipp",".tcc",".tpp",".txx"]},csharp:Xt(),dart:on(),java:dn(),clojure:xn()},Sn=new Map;for(let t of Object.values(bt))for(let e of t.extensions)Sn.set(e,t.id);function ti(){return Ct(vt())}function Ha(t){let e=t.toLowerCase().match(/\.[a-z0-9+]+$/);return e?Sn.get(e[0])??null:null}function Ja(t){return bt[t]}function Wa(t){let e=t??ti(),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(bt))if(n.has(i.id))for(let s of i.extensions)r.add(s);return r}import ni from"fs";import vn from"path";import{promises as ri}from"fs";import Ya from"ignore";function Nn(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 a=s.startsWith("!"),o=a?s.slice(1):s;if(!o)return s;if((o.endsWith("/")?o.slice(0,-1):o).includes("/")){let m=o.startsWith("/")?o.slice(1):o,b=r?`${r}${m}`:m;return a?`!${b}`:b}let p=r?`${r}**/${o}`:o;return a?`!${p}`:p})}function Za(t,e){let n=vn.join(t,".gitignore");try{let r=ni.readFileSync(n,"utf8");return Nn(r,e)}catch{return[]}}async function eo(t,e){let n=vn.join(t,".gitignore");try{let r=await ri.readFile(n,"utf8");return Nn(r,e)}catch{return[]}}function ii(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 no(t,e){if(t?.aborted)throw ii(t.reason,e)}export{Rn as a,_t as b,me as c,qa as d,ti as e,Ha as f,Ja as g,Wa as h,no as i,Za as j,eo as k};