scip-query 0.7.0 → 0.7.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 (102) hide show
  1. package/README.md +88 -1007
  2. package/dist/augment-vue-worker.js +1 -1
  3. package/dist/chunk-2QNKEJ7R.js +2 -0
  4. package/dist/{chunk-JTXKS5GK.js → chunk-3X43EYFU.js} +2 -2
  5. package/dist/{chunk-JB4PUN5S.js → chunk-4GPWGSOE.js} +2 -2
  6. package/dist/{chunk-WODJHE6Z.js → chunk-4LKJMRT5.js} +2 -2
  7. package/dist/{chunk-2IYEIFPP.js → chunk-4T35WUCX.js} +2 -2
  8. package/dist/chunk-4VYIZV3S.js +62 -0
  9. package/dist/{chunk-7O4MJYIW.js → chunk-5RGK4YA5.js} +2 -2
  10. package/dist/{chunk-KJ3ZJIE5.js → chunk-5TB4N27G.js} +2 -2
  11. package/dist/{chunk-ROOHENEP.js → chunk-6QC7SCKV.js} +2 -2
  12. package/dist/{chunk-6H2XIIPY.js → chunk-6QH2L26C.js} +6 -6
  13. package/dist/{chunk-MDAYGS6T.js → chunk-6SR4UNWI.js} +2 -2
  14. package/dist/chunk-6XEWA6FX.js +2 -0
  15. package/dist/{chunk-3GNFUVFA.js → chunk-7WHNTKSD.js} +2 -2
  16. package/dist/{chunk-XO6R3X5J.js → chunk-D62LLANH.js} +2 -2
  17. package/dist/{chunk-OHEIZWIA.js → chunk-EDXML2HI.js} +2 -2
  18. package/dist/{chunk-23YIGCYF.js → chunk-EIGCLVKK.js} +5 -5
  19. package/dist/{chunk-ZNUPGRPR.js → chunk-EVXQF7DM.js} +2 -2
  20. package/dist/chunk-EZQOVY3C.js +2 -0
  21. package/dist/{chunk-563HLCDW.js → chunk-FU5WRWAN.js} +2 -2
  22. package/dist/{chunk-4STLJYHI.js → chunk-GIRI7FHW.js} +2 -2
  23. package/dist/{chunk-A2AVLALL.js → chunk-HTVLH3NL.js} +2 -2
  24. package/dist/{chunk-J6Z5YKGQ.js → chunk-IFGEPTH5.js} +2 -2
  25. package/dist/chunk-JDFWJ7VK.js +2 -0
  26. package/dist/{chunk-33SSUPCB.js → chunk-LLL7THVV.js} +2 -2
  27. package/dist/{chunk-72JOIFXL.js → chunk-LXJTDFOV.js} +2 -2
  28. package/dist/chunk-NBUINPSH.js +2 -0
  29. package/dist/{chunk-NSTZMBAB.js → chunk-OPWOX7NT.js} +2 -2
  30. package/dist/{chunk-TRNAQABL.js → chunk-OPZQIJZU.js} +2 -2
  31. package/dist/chunk-P3PVY6TX.js +2 -0
  32. package/dist/{chunk-3OUC276S.js → chunk-P7UMQ7R7.js} +2 -2
  33. package/dist/{chunk-VUBQBW7H.js → chunk-PEU24CSY.js} +2 -2
  34. package/dist/{chunk-GAQGJ52J.js → chunk-QBXTQODK.js} +2 -2
  35. package/dist/{chunk-LDV2B7ET.js → chunk-QP6FLI6D.js} +2 -2
  36. package/dist/{chunk-NYEMZHUC.js → chunk-QVPYMZUJ.js} +2 -2
  37. package/dist/{chunk-2JEFS2YJ.js → chunk-RFCR2BRD.js} +2 -2
  38. package/dist/chunk-S5VMVNFM.js +2 -0
  39. package/dist/{chunk-DFK54IRN.js → chunk-SDPP5KVQ.js} +2 -2
  40. package/dist/{chunk-ZXFTC5ET.js → chunk-SVSLAUSJ.js} +2 -2
  41. package/dist/{chunk-WPLKHAH7.js → chunk-TB2OYNRS.js} +2 -2
  42. package/dist/chunk-TGNL3ZKZ.js +2 -0
  43. package/dist/{chunk-7H4RJ4MC.js → chunk-UHMJYNTK.js} +2 -2
  44. package/dist/{chunk-QPRIYXH4.js → chunk-VMS5YTBS.js} +2 -2
  45. package/dist/{chunk-FD37DBTD.js → chunk-WJQFABZN.js} +2 -2
  46. package/dist/{chunk-KNA6Z7JB.js → chunk-X2JB54QF.js} +2 -2
  47. package/dist/{chunk-QWJBIBE6.js → chunk-XANDY7N5.js} +2 -2
  48. package/dist/{chunk-WJQY2LGT.js → chunk-XDXZP3BE.js} +2 -2
  49. package/dist/{chunk-ARBZM2NF.js → chunk-YH6TTQEI.js} +2 -2
  50. package/dist/cli.js +127 -126
  51. package/dist/index.d.ts +21 -28
  52. package/dist/index.js +1 -1
  53. package/dist/queries/affected.js +1 -1
  54. package/dist/queries/bottlenecks.js +1 -1
  55. package/dist/queries/by-kind.js +1 -1
  56. package/dist/queries/call-graph.js +1 -1
  57. package/dist/queries/change-surface.js +1 -1
  58. package/dist/queries/code.js +1 -1
  59. package/dist/queries/complexity-hotspots.d.ts +1 -1
  60. package/dist/queries/complexity-hotspots.js +1 -1
  61. package/dist/queries/complexity.js +1 -1
  62. package/dist/queries/convergence.js +1 -1
  63. package/dist/queries/coupling.js +1 -1
  64. package/dist/queries/dataflow.js +1 -1
  65. package/dist/queries/dead.js +1 -1
  66. package/dist/queries/deps.js +1 -1
  67. package/dist/queries/diff-impact.js +1 -1
  68. package/dist/queries/drift.js +1 -1
  69. package/dist/queries/extract-candidates.js +1 -1
  70. package/dist/queries/fan.js +1 -1
  71. package/dist/queries/health.js +1 -1
  72. package/dist/queries/hierarchy.js +1 -1
  73. package/dist/queries/hotspots.js +1 -1
  74. package/dist/queries/imports.js +1 -1
  75. package/dist/queries/index.js +1 -1
  76. package/dist/queries/isolated.js +1 -1
  77. package/dist/queries/members.js +1 -1
  78. package/dist/queries/methods.js +1 -1
  79. package/dist/queries/outline.js +1 -1
  80. package/dist/queries/passthrough-candidates.js +1 -1
  81. package/dist/queries/redundant-reexports.js +1 -1
  82. package/dist/queries/refs.js +1 -1
  83. package/dist/queries/similar-signatures.js +1 -1
  84. package/dist/queries/similar.js +1 -1
  85. package/dist/queries/slice.js +1 -1
  86. package/dist/queries/stale-abstractions.js +1 -1
  87. package/dist/queries/surface.js +1 -1
  88. package/dist/queries/symbols.js +1 -1
  89. package/dist/queries/system.js +1 -1
  90. package/dist/queries/trace.js +1 -1
  91. package/dist/queries/wrapper-candidates.js +1 -1
  92. package/dist/reindex-worker.js +1 -1
  93. package/dist/reindex.js +16 -16
  94. package/package.json +2 -1
  95. package/dist/chunk-7OX2O53H.js +0 -62
  96. package/dist/chunk-CKIO6SVS.js +0 -2
  97. package/dist/chunk-D6Z67MZL.js +0 -2
  98. package/dist/chunk-FOQQDXE7.js +0 -2
  99. package/dist/chunk-QAEDNTY7.js +0 -2
  100. package/dist/chunk-TGK5DFBJ.js +0 -2
  101. package/dist/chunk-V53J46BX.js +0 -2
  102. package/dist/chunk-YSZNAG4G.js +0 -2
package/dist/reindex.js CHANGED
@@ -1,9 +1,9 @@
1
- import{a as m,e as w}from"./chunk-LWYIGRHR.js";import{a as Z}from"./chunk-TKDJQ2WD.js";import{a as Y,b as Q}from"./chunk-KJ6CW6EK.js";import"./chunk-NHDPYW7O.js";import"./chunk-NN3O7TPH.js";import{execFileSync as er}from"child_process";import{closeSync as nr,existsSync as q,mkdirSync as $e,mkdtempSync as tr,openSync as rr,readFileSync as ir,renameSync as K,rmSync as X,writeFileSync as Be}from"fs";import{basename as C,dirname as b,extname as or,join as f}from"path";import We from"better-sqlite3";import{execFileSync as He}from"child_process";import{existsSync as Je,readdirSync as ze,readFileSync as Ge}from"fs";import{extname as S,join as ee}from"path";function y(e){let n=new Set((e.extensions??Y).map(o=>o.toLowerCase()));if(n.size===0)return{scanned:0,inserted:0,existing:0};if(!Je(e.dbPath))throw new Error(`SCIP SQLite database not found at ${e.dbPath}`);let t=Z(e.projectRoot),r=qe(e.projectRoot,n).filter(o=>!t.isIgnored(o)),i=new We(e.dbPath);try{let o=Xe(i,r),s=i.prepare(`INSERT OR IGNORE INTO documents (language, relative_path, position_encoding, text)
1
+ import{a as f,e as L}from"./chunk-LWYIGRHR.js";import{a as Z}from"./chunk-TKDJQ2WD.js";import{a as Y,b as Q}from"./chunk-KJ6CW6EK.js";import"./chunk-NHDPYW7O.js";import"./chunk-NN3O7TPH.js";import{execFileSync as nr}from"child_process";import{closeSync as tr,existsSync as q,mkdirSync as $e,mkdtempSync as rr,openSync as ir,readFileSync as or,renameSync as K,rmSync as X,writeFileSync as Be}from"fs";import{basename as C,dirname as b,extname as sr,join as m}from"path";import We from"better-sqlite3";import{execFileSync as He}from"child_process";import{existsSync as Je,readdirSync as ze,readFileSync as Ge}from"fs";import{extname as S,join as ee}from"path";function y(e){let n=new Set((e.extensions??Y).map(o=>o.toLowerCase()));if(n.size===0)return{scanned:0,inserted:0,existing:0};if(!Je(e.dbPath))throw new Error(`SCIP SQLite database not found at ${e.dbPath}`);let t=Z(e.projectRoot),r=qe(e.projectRoot,n).filter(o=>!t.isIgnored(o)),i=new We(e.dbPath);try{let o=Xe(i,r),s=i.prepare(`INSERT OR IGNORE INTO documents (language, relative_path, position_encoding, text)
2
2
  VALUES (?, ?, NULL, ?)`),u=i.transaction(g=>{let l=0;for(let p of g){if(o.has(p))continue;let d=Ge(ee(e.projectRoot,p),"utf-8"),Ue=s.run(Ye(p),p,d);l+=Number(Ue.changes)}return l})(r),c={scanned:r.length,inserted:u,existing:r.length-u};return e.onStatus?.(`Augmented SQLite documents with ${u} auxiliary source file${u===1?"":"s"} (${c.existing} already present).`),c}finally{i.close()}}function qe(e,n){let t=Ke(e,n);if(t)return t;let r=[],i=o=>{let s=o?ee(e,o):e,a;try{a=ze(s,{withFileTypes:!0})}catch{return}for(let u of a){if(Q.has(u.name))continue;let c=o?`${o}/${u.name}`:u.name;if(u.isDirectory()){i(c);continue}n.has(S(u.name).toLowerCase())&&r.push(c)}};return i(""),r.sort()}function Ke(e,n){try{return He("git",["-C",e,"ls-files","-co","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:26214400,stdio:["ignore","pipe","ignore"]}).split(`
3
- `).filter(r=>r&&n.has(S(r).toLowerCase())).sort()}catch{return null}}function Xe(e,n){let t=new Set,r=500;for(let i=0;i<n.length;i+=r){let o=n.slice(i,i+r),s=e.prepare(`SELECT relative_path FROM documents WHERE relative_path IN (${o.map(()=>"?").join(",")})`).all(...o);for(let a of s)t.add(a.relative_path)}return t}function Ye(e){return S(e).toLowerCase()===".vue"?"vue":S(e).replace(/^\./,"").toLowerCase()||"source"}import{execFileSync as Qe}from"child_process";import{existsSync as Ze,readdirSync as te}from"fs";import{extname as re,join as ie}from"path";var en=new Set([".git",".hg",".svn",".idea",".vscode","node_modules","vendor","dist","build","target","bin","obj",".dart_tool",".gradle",".next",".venv","venv","__pycache__"]),nn=[{language:"typescript",files:["tsconfig.json","tsconfig.base.json"],extensions:[".ts",".tsx",".mts",".cts"]},{language:"rust",files:["Cargo.toml"],extensions:[".rs"]},{language:"go",files:["go.mod"],extensions:[".go"]},{language:"java",files:["pom.xml","build.gradle","build.gradle.kts"],extensions:[".java"]},{language:"kotlin",files:["build.gradle.kts"],extensions:[".kt",".kts"]},{language:"scala",files:["build.sbt"],extensions:[".scala"]},{language:"python",files:["pyproject.toml","setup.py","setup.cfg","Pipfile"],extensions:[".py",".pyi"]},{language:"ruby",files:["Gemfile"],extensions:[".rb"]},{language:"cpp",files:["compile_commands.json","CMakeLists.txt","Makefile"],extensions:[".cc",".cpp",".cxx",".hpp",".hh",".hxx"]},{language:"c",files:["compile_commands.json","CMakeLists.txt","Makefile"],extensions:[".c",".h"]},{language:"csharp",globs:["*.csproj","*.sln"],extensions:[".cs"]},{language:"vb",globs:["*.vbproj"],extensions:[".vb"]},{language:"dart",files:["pubspec.yaml"],extensions:[".dart"]},{language:"php",files:["composer.json"],extensions:[".php"]},{language:"javascript",files:["package.json"],extensions:[".js",".jsx",".mjs",".cjs"]}];function L(e){let n=[],t=tn(e),r=an(e);for(let i of nn){if(rn(e,i.files)){n.push(i.language);continue}if(on(t,i.globs)){n.push(i.language);continue}cn(r,i.extensions)&&n.push(i.language)}return n.includes("typescript")&&ne(n,"javascript"),n.includes("cpp")&&!r.has(".c")&&ne(n,"c"),n}function tn(e){try{return te(e)}catch{return[]}}function rn(e,n){return n?.length?n.some(t=>Ze(ie(e,t))):!1}function on(e,n){return n?.length?e.some(t=>n.some(r=>sn(t,r))):!1}function sn(e,n){if(n==="*")return!0;if(!n.includes("*"))return e===n;let[t,r]=n.split("*");return e.startsWith(t??"")&&e.endsWith(r??"")}function an(e){let n=un(e);if(n)return n;let t=new Set,r=[e];for(;r.length>0;){let i=r.pop();if(!i)continue;let o;try{o=te(i,{withFileTypes:!0})}catch{continue}for(let s of o){if(s.name.startsWith(".")&&!s.name.endsWith("proj")&&!s.name.endsWith("sln")&&s.isDirectory())continue;let a=ie(i,s.name);if(s.isDirectory()){en.has(s.name)||r.push(a);continue}let u=re(s.name).toLowerCase();u&&t.add(u)}}return t}function un(e){try{let n=Qe("git",["-C",e,"ls-files","-co","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:26214400,stdio:["ignore","pipe","ignore"]}),t=new Set;for(let r of n.split(`
4
- `)){if(!r)continue;let i=re(r).toLowerCase();i&&t.add(i)}return t}catch{return null}}function cn(e,n){return n?.length?n.some(t=>e.has(t)):!1}function ne(e,n){let t=e.indexOf(n);t!==-1&&e.splice(t,1)}import{existsSync as oe,readdirSync as ln}from"fs";import{join as O}from"path";var ae={typescript:{language:"typescript",indexerBinary:"scip-typescript",checkCommand:"npx scip-typescript --version",indexArgs:({outputPath:e,pnpmWorkspaces:n,indexerBinary:t})=>{let r=["index","--infer-tsconfig","--output",e,"--no-progress-bar"];return n&&r.splice(1,0,"--pnpm-workspaces"),{binary:t,args:r}},markerFiles:["tsconfig.json"],installMethods:[{label:"npm",prerequisite:"npm",binary:"npm",args:["install","-g","@sourcegraph/scip-typescript"]}],installUrl:"https://github.com/sourcegraph/scip-typescript",bundledNpmPackage:"@sourcegraph/scip-typescript"},javascript:{language:"javascript",indexerBinary:"scip-typescript",checkCommand:"npx scip-typescript --version",indexArgs:({outputPath:e,indexerBinary:n})=>({binary:n,args:["index","--infer-tsconfig","--output",e,"--no-progress-bar"]}),markerFiles:["package.json"],installMethods:[{label:"npm",prerequisite:"npm",binary:"npm",args:["install","-g","@sourcegraph/scip-typescript"]}],installUrl:"https://github.com/sourcegraph/scip-typescript",bundledNpmPackage:"@sourcegraph/scip-typescript"},java:{language:"java",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:["pom.xml","build.gradle"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},scala:{language:"scala",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:["build.sbt"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},kotlin:{language:"kotlin",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:["build.gradle.kts"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},rust:{language:"rust",indexerBinary:"rust-analyzer",checkCommand:"rust-analyzer --version",indexArgs:({outputPath:e})=>({binary:"rust-analyzer",args:["scip",".","--output",e]}),markerFiles:["Cargo.toml"],installMethods:[{label:"rustup",prerequisite:"rustup",binary:"rustup",args:["component","add","rust-analyzer"]}],installUrl:"https://github.com/rust-lang/rust-analyzer"},python:{language:"python",indexerBinary:"scip-python-plus",binaryAliases:["scip-python"],checkCommand:"scip-python-plus --version",indexArgs:({outputPath:e,indexerBinary:n})=>({binary:n,args:["index","--output",e,"--project-name","project"]}),markerFiles:["pyproject.toml","setup.py"],installMethods:[{label:"npm",prerequisite:"npm",binary:"npm",args:["install","-g","scip-python-plus"]}],installUrl:"https://github.com/PlunderStruck/scip-python",bundledNpmPackage:"scip-python-plus"},ruby:{language:"ruby",indexerBinary:"scip-ruby",checkCommand:"scip-ruby --version",indexArgs:({indexerBinary:e})=>({binary:e,args:["--dir","."]}),defaultOutputPath:"index.scip",markerFiles:["Gemfile"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-ruby/releases"},go:{language:"go",indexerBinary:"scip-go",checkCommand:"scip-go --version",indexArgs:({outputPath:e})=>({binary:"scip-go",args:["--output",e]}),markerFiles:["go.mod"],installMethods:[{label:"go install",prerequisite:"go",binary:"go",args:["install","github.com/sourcegraph/scip-go@latest"]}],installUrl:"https://github.com/sourcegraph/scip-go"},cpp:{language:"cpp",indexerBinary:"scip-clang",checkCommand:"scip-clang --version",indexArgs:({outputPath:e})=>({binary:"scip-clang",args:["--compdb-path","compile_commands.json","--index-output-path",e]}),markerFiles:["CMakeLists.txt","Makefile"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-clang/releases"},c:{language:"c",indexerBinary:"scip-clang",checkCommand:"scip-clang --version",indexArgs:({outputPath:e})=>({binary:"scip-clang",args:["--compdb-path","compile_commands.json","--index-output-path",e]}),markerFiles:["CMakeLists.txt","Makefile"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-clang/releases"},csharp:{language:"csharp",indexerBinary:"scip-dotnet",checkCommand:"scip-dotnet --version",indexArgs:({projectRoot:e,outputPath:n})=>({binary:"scip-dotnet",args:["index",se(e,[".sln",".csproj"])??e,"--output",n,"--working-directory",e]}),markerFiles:["*.csproj","*.sln"],installMethods:[{label:"dotnet",prerequisite:"dotnet",binary:"dotnet",args:["tool","install","--global","scip-dotnet"]}],installUrl:"https://github.com/sourcegraph/scip-dotnet/releases"},vb:{language:"vb",indexerBinary:"scip-dotnet",checkCommand:"scip-dotnet --version",indexArgs:({projectRoot:e,outputPath:n})=>({binary:"scip-dotnet",args:["index",se(e,[".sln",".vbproj"])??e,"--output",n,"--working-directory",e]}),markerFiles:["*.vbproj","*.sln"],installMethods:[{label:"dotnet",prerequisite:"dotnet",binary:"dotnet",args:["tool","install","--global","scip-dotnet"]}],installUrl:"https://github.com/sourcegraph/scip-dotnet/releases"},dart:{language:"dart",indexerBinary:"scip-dart",checkCommand:"scip-dart --version",indexArgs:({indexerBinary:e,outputPath:n})=>({binary:e,args:["--output",n]}),markerFiles:["pubspec.yaml"],installMethods:[{label:"dart pub",prerequisite:"dart",binary:"dart",args:["pub","global","activate","scip_dart"]}],installUrl:"https://github.com/Workiva/scip-dart/releases"},php:{language:"php",indexerBinary:"scip-php",projectLocalBinaries:["vendor/davidrjenni/scip-php/bin/scip-php","vendor/bin/scip-php"],checkCommand:"scip-php --version",indexArgs:({projectRoot:e,indexerBinary:n})=>{let t=O(e,"vendor","bin","scip-php"),r=O(e,"vendor","davidrjenni","scip-php","bin","scip-php");return{binary:"php",args:["-d","error_reporting=E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED",oe(r)?r:oe(t)?t:n]}},defaultOutputPath:"index.scip",markerFiles:["composer.json"],installMethods:[],installUrl:"https://github.com/davidrjenni/scip-php/releases"}};function D(e){return ae[e]}function se(e,n){let t;try{t=ln(e)}catch{return null}for(let r of t)if(n.some(i=>r.endsWith(i)))return O(e,r);return null}import{readFileSync as gn,writeFileSync as pn}from"fs";import{create as T}from"@bufbuild/protobuf";import{deserializeSCIP as dn,serializeSCIP as fn,DocumentSchema as mn,IndexSchema as hn,SymbolInformationSchema as bn}from"@c4312/scip";function ue(e){if(e.length===0)throw new Error("Cannot merge zero SCIP indexes");if(e.length===1)return e[0];let n=yn(e),t=xn(e.flatMap(i=>i.documents??[])),r=ce(e.flatMap(i=>i.externalSymbols??[]));return T(hn,{metadata:n,documents:t,externalSymbols:r})}function F(e,n){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let t=e.map(i=>dn(gn(i))),r=ue(t);return pn(n,Buffer.from(fn(r))),{documentCount:r.documents.length,externalSymbolCount:r.externalSymbols.length,inputCount:e.length}}function yn(e){let n=e[0]?.metadata;if(!n)return;let t=n.projectRoot;for(let r of e.slice(1)){let i=r.metadata?.projectRoot;if(t&&i&&i!==t)throw new Error(`Cannot merge SCIP indexes with different project roots: ${t} vs ${i}`)}return n}function xn(e){let n=new Map;for(let t of e){let r=n.get(t.relativePath);if(!r){n.set(t.relativePath,t);continue}n.set(t.relativePath,T(mn,{language:r.language||t.language,relativePath:r.relativePath||t.relativePath,occurrences:[...r.occurrences,...t.occurrences],symbols:ce([...r.symbols,...t.symbols]),text:vn(r.text,t.text),positionEncoding:r.positionEncoding||t.positionEncoding}))}return[...n.values()]}function ce(e){let n=new Map;for(let t of e){let r=n.get(t.symbol);if(!r){n.set(t.symbol,t);continue}n.set(t.symbol,T(bn,{symbol:r.symbol,documentation:Rn([...r.documentation,...t.documentation]),relationships:Sn([...r.relationships,...t.relationships]),kind:r.kind||t.kind,displayName:r.displayName||t.displayName,enclosingSymbol:r.enclosingSymbol||t.enclosingSymbol,signatureDocumentation:r.signatureDocumentation??t.signatureDocumentation}))}return[...n.values()]}function Sn(e){let n=new Set,t=[];for(let r of e){let i=[r.symbol,r.isReference?"1":"0",r.isImplementation?"1":"0",r.isTypeDefinition?"1":"0",r.isDefinition?"1":"0"].join("|");n.has(i)||(n.add(i),t.push(r))}return t}function vn(e,n){return e?n?e.length>=n.length?e:n:e:n}function Rn(e){return[...new Set(e)]}import{execFileSync as kn}from"child_process";import{createHash as In}from"crypto";import{readdirSync as Pn,readFileSync as Cn}from"fs";import{join as le}from"path";function wn(e){return(Ln(e)??On(e)).filter(n=>n&&!ge(n)).sort()}function v(e){return wn(e).map(n=>{let t=le(e,n);try{let r=Cn(t);return{path:n,size:r.byteLength,hash:In("sha256").update(r).digest("hex")}}catch{return{path:n,size:-1,hash:"unreadable"}}})}function Ln(e){try{return kn("git",["-C",e,"ls-files","-co","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:50*1024*1024,stdio:["ignore","pipe","ignore"]}).split(`
5
- `).filter(Boolean)}catch{return null}}function On(e){let n=[],t=[""];for(;t.length>0;){let r=t.pop(),i=r?le(e,r):e,o;try{o=Pn(i,{withFileTypes:!0})}catch{continue}for(let s of o){let a=r?`${r}/${s.name}`:s.name;if(s.isDirectory()){ge(a)||t.push(a);continue}n.push(a)}}return n}function ge(e){return e.split("/").some(t=>Dn.has(t))||e.endsWith(".db")||e.endsWith(".db-wal")||e.endsWith(".db-shm")||e.endsWith(".scip")}var Dn=new Set([".git","node_modules",".scipquery-cache",".stryker-tmp","dist","build","coverage",".next",".nuxt","target"]);import{readFileSync as Tn,writeFileSync as Fn}from"fs";import{create as pe}from"@bufbuild/protobuf";import{deserializeSCIP as En,DocumentSchema as Vn,IndexSchema as jn,serializeSCIP as Mn,SymbolRole as Nn}from"@c4312/scip";function de(e){let n;try{n=En(Tn(e))}catch{return{removedDefinitionOccurrences:0,touchedDocuments:0}}let t=An(n);return t.removedDefinitionOccurrences>0&&Fn(e,Buffer.from(Mn(t.index))),{removedDefinitionOccurrences:t.removedDefinitionOccurrences,touchedDocuments:t.touchedDocuments}}function An(e){let n=new Set;for(let o of e.documents)for(let s of o.symbols)s.symbol&&n.add(s.symbol);for(let o of e.externalSymbols)o.symbol&&n.add(o.symbol);let t=0,r=0,i=[];for(let o of e.documents){let s=o.occurrences.filter(a=>(a.symbolRoles&Nn.Definition)===0||n.has(a.symbol)?!0:(t+=1,!1));if(s.length===o.occurrences.length){i.push(o);continue}r+=1,i.push(pe(Vn,{language:o.language,relativePath:o.relativePath,occurrences:s,symbols:o.symbols,text:o.text,positionEncoding:o.positionEncoding}))}return{index:t===0?e:pe(jn,{metadata:e.metadata,documents:i,externalSymbols:e.externalSymbols}),removedDefinitionOccurrences:t,touchedDocuments:r}}import{execFile as _n}from"child_process";import{existsSync as R,renameSync as V,rmSync as j}from"fs";import{cpus as $n}from"os";import{join as fe}from"path";function Bn(e,n,t){if(!e.defaultOutputPath)return;let r=fe(n,e.defaultOutputPath);t!==r&&R(r)&&V(r,t)}function Un(e,n,t){if(!e.defaultOutputPath)return null;let r=fe(n,e.defaultOutputPath);if(r===t)return null;let i=`${t}.default-output-backup`;return j(i,{force:!0}),R(r)?(V(r,i),{defaultOutputPath:r,backupPath:i}):{defaultOutputPath:r,backupPath:null}}function Wn(e){e&&(j(e.defaultOutputPath,{force:!0}),e.backupPath&&R(e.backupPath)&&V(e.backupPath,e.defaultOutputPath))}function Hn(e,n){if(e<=1)return 1;let t=Number(process.env.SCIP_QUERY_INDEXER_CONCURRENCY??0),r=Number.isFinite(n)&&n&&n>0?n:Number.isFinite(t)&&t>0?t:Math.min(2,Math.max(1,$n().length-1));return Math.max(1,Math.min(e,Math.floor(r)))}async function me(e,n,t,r){let i=e.filter(c=>c.config.defaultOutputPath),o=e.filter(c=>!c.config.defaultOutputPath),s=[],a=Hn(o.length,r),u=await zn(o,a,c=>E(c,n,t));if(a>1){let c=new Map;for(let g of u.filter(l=>l.skipped)){let l=o.find(p=>p.language===g.language);l&&(t(`Retrying ${l.language} indexer serially after parallel failure...`),c.set(l.language,await E(l,n,t)))}s.push(...u.map(g=>c.get(g.language)??g))}else s.push(...u);for(let c of i)s.push(await E(c,n,t));return s.sort((c,g)=>e.findIndex(l=>l.language===c.language)-e.findIndex(l=>l.language===g.language))}async function E(e,n,t){t(`Indexing ${e.language} with ${e.resolvedBinary}...`),j(e.scipPath,{force:!0});let r=Un(e.config,n,e.scipPath);try{await Jn(e.binary,e.args,{cwd:n,env:e.env,maxBuffer:50*1024*1024}),Bn(e.config,n,e.scipPath)}catch(i){let o=i instanceof Error?i.message:String(i),s=`${e.resolvedBinary} indexer failed: ${o.split(`
6
- `)[0]}`;return t(`Skipping ${e.language}: ${s}`),{language:e.language,scipPath:e.scipPath,skipped:{language:e.language,reason:s}}}finally{Wn(r)}if(!R(e.scipPath)){let i=`${e.resolvedBinary} indexer completed but did not produce ${e.scipPath}`;return t(`Skipping ${e.language}: ${i}`),{language:e.language,scipPath:e.scipPath,skipped:{language:e.language,reason:i}}}return{language:e.language,scipPath:e.scipPath}}function Jn(e,n,t){return new Promise((r,i)=>{_n(e,[...n],t,o=>{o?i(o):r()})})}async function zn(e,n,t){if(e.length===0)return[];let r=new Array(e.length),i=0,o=Math.max(1,Math.min(e.length,n)),s=Array.from({length:o},async()=>{for(;i<e.length;){let a=i++;r[a]=await t(e[a])}});return await Promise.all(s),r}import{execFileSync as N}from"child_process";import{existsSync as M,readFileSync as Gn}from"fs";import{createRequire as qn}from"module";import{platform as Kn}from"os";import{dirname as he,join as k}from"path";var Xn=qn(import.meta.url);function A(e){return[e.indexerBinary,...e.binaryAliases??[]]}function I(e){let n=A(e);return n.length===1?n[0]:n.join(" or ")}function x(e){for(let n of A(e))if(m(n))return n;return Qn(e)}function _(e){return x(e)!==null||Yn(e)}function Yn(e){return be(e)!==null}function Qn(e){let n=be(e);if(!n)return null;let r=JSON.parse(Gn(n,"utf8")).bin;if(!r)return null;if(typeof r=="string")return k(he(n),r);for(let i of A(e)){let o=r[i];if(o)return k(he(n),o)}return null}function be(e){if(!e.bundledNpmPackage)return null;try{return Xn.resolve(`${e.bundledNpmPackage}/package.json`)}catch{return null}}function $(e,n){for(let t of e.projectLocalBinaries??[]){let r=k(n,t);if(M(r))return r}return null}function B(e,n=process.env,t=e.indexerBinary){if(e.indexerBinary!=="scip-dotnet"||ye(t,n))return n;let r=Zn(t,n);return r?{...n,DOTNET_ROOT:r}:n}function U(e,n){let t=e.installMethods,r=I(e);if(!t?.length)return n(`No auto-install method available for ${r}.`),e.installUrl&&n(`Install manually from: ${e.installUrl}`),!1;for(let i of t)if(m(i.prerequisite)){n(`Installing ${r} via ${i.label}...`);try{N(i.binary,i.args,{stdio:"inherit",timeout:3e5,env:process.env});let o=x(e);if(o){let s=o===e.indexerBinary?"":` (using ${o})`;return n(`Successfully installed ${r} via ${i.label}${s}`),!0}n(`${i.label} command completed but ${r} was not found on PATH`)}catch(o){let s=o instanceof Error?o.message:String(o);n(`${i.label} install failed: ${s}`)}}return n(`Could not auto-install ${r}.`),e.installUrl&&n(`Install manually from: ${e.installUrl}`),!1}function Zn(e,n){for(let t of et(n))if(ye(e,{...n,DOTNET_ROOT:t}))return t;return null}function et(e){let n=[],t=e.DOTNET_ROOT;if(t&&M(t)&&n.push(t),Kn()==="darwin"&&m("brew"))try{let r=N("brew",["--prefix","dotnet@9"],{stdio:"pipe",env:e}).toString().trim(),i=k(r,"libexec");M(i)&&!n.includes(i)&&n.push(i)}catch{}return n}function ye(e,n){try{return N(e,["--version"],{stdio:"pipe",env:n}),!0}catch{return!1}}import Vt from"better-sqlite3";import{existsSync as jt,readFileSync as Mt,writeFileSync as Nt}from"fs";import{dirname as At,join as _t,resolve as $t}from"path";import{readFileSync as nt,rmSync as tt,statSync as rt,mkdtempSync as it}from"fs";import{cpus as ot,tmpdir as st}from"os";import{join as W}from"path";import{Worker as at}from"worker_threads";function xe(e){return e.length>=8&&ve(e.length)>1}function Se(e){let n=ve(e.vueFiles.length),t=ct(e.vueFiles),r=gt(t,n),i=new URL("./augment-vue-worker.js",import.meta.url),o=it(W(st(),"scip-query-vue-workers-")),s=new SharedArrayBuffer(4),a=new Int32Array(s),u=ut(),c=Date.now();try{for(let l=0;l<r.length;l++)new at(i,{workerData:{projectRoot:e.projectRoot,dbPath:e.dbPath,tsconfig:e.tsconfig,tasks:r[l],resultPath:W(o,`${l}.json`),sharedBuffer:s}});for(;Atomics.load(a,0)<r.length;){if(Date.now()-c>u)throw new Error(`Vue reference workers timed out after ${(u/1e3).toFixed(0)}s`);Atomics.wait(a,0,Atomics.load(a,0),100)}let g=r.map((l,p)=>{let d=JSON.parse(nt(W(o,`${p}.json`),"utf-8"));if(!d.ok)throw new Error(`Vue reference worker failed: ${d.error}`);return d.result});return{occurrences:g.flatMap(l=>l.occurrences),skippedReferences:g.reduce((l,p)=>l+p.skippedReferences,0)}}finally{tt(o,{recursive:!0,force:!0})}}function ve(e){let n=Number(process.env.SCIP_QUERY_AUGMENT_VUE_WORKERS??0),t=Number.isFinite(n)&&n>0?n:Math.min(8,Math.max(1,ot().length-1));return Math.max(1,Math.min(e,t))}function ut(){let e=Number(process.env.SCIP_QUERY_AUGMENT_VUE_WORKER_TIMEOUT_MS??0);return Number.isFinite(e)&&e>0?e:3e5}function ct(e){let n=lt(),t=[];for(let r of e){let i=Re(r),o=Math.max(1,Math.ceil(i/n));for(let s=0;s<o;s++)t.push({fileName:r,startOffset:Math.floor(i*s/o),endOffset:s===o-1?Number.POSITIVE_INFINITY:Math.floor(i*(s+1)/o),countFileSkip:s===0})}return t}function lt(){return Number.POSITIVE_INFINITY}function gt(e,n){let t=Array.from({length:n},()=>({tasks:[],weight:0})),r=e.map(i=>({task:i,weight:pt(i)})).sort((i,o)=>o.weight-i.weight);for(let i of r){let o=t.reduce((s,a)=>a.weight<s.weight?a:s);o.tasks.push(i.task),o.weight+=i.weight}return t.map(i=>i.tasks).filter(i=>i.length>0)}function pt(e){return Number.isFinite(e.endOffset)?Math.max(1,e.endOffset-e.startOffset):Math.max(1,Re(e.fileName)-e.startOffset)}function Re(e){try{return rt(e).size}catch{return 1}}import{createRequire as dt}from"module";import{existsSync as ft,readFileSync as J}from"fs";import{dirname as ke,extname as mt,join as Ie,relative as ht,resolve as bt}from"path";import{pathToFileURL as yt}from"url";function xt(e){e.transaction(()=>{e.prepare(`
3
+ `).filter(r=>r&&n.has(S(r).toLowerCase())).sort()}catch{return null}}function Xe(e,n){let t=new Set,r=500;for(let i=0;i<n.length;i+=r){let o=n.slice(i,i+r),s=e.prepare(`SELECT relative_path FROM documents WHERE relative_path IN (${o.map(()=>"?").join(",")})`).all(...o);for(let a of s)t.add(a.relative_path)}return t}function Ye(e){return S(e).toLowerCase()===".vue"?"vue":S(e).replace(/^\./,"").toLowerCase()||"source"}import{execFileSync as Qe}from"child_process";import{existsSync as Ze,readdirSync as te}from"fs";import{extname as re,join as ie}from"path";var en=new Set([".git",".hg",".svn",".idea",".vscode","node_modules","vendor","dist","build","target","bin","obj",".dart_tool",".gradle",".next",".venv","venv","__pycache__"]),nn=[{language:"typescript",files:["tsconfig.json","tsconfig.base.json"],extensions:[".ts",".tsx",".mts",".cts"]},{language:"rust",files:["Cargo.toml"],extensions:[".rs"]},{language:"go",files:["go.mod"],extensions:[".go"]},{language:"java",files:["pom.xml","build.gradle","build.gradle.kts"],extensions:[".java"]},{language:"kotlin",files:["build.gradle.kts"],extensions:[".kt",".kts"]},{language:"scala",files:["build.sbt"],extensions:[".scala"]},{language:"python",files:["pyproject.toml","setup.py","setup.cfg","Pipfile"],extensions:[".py",".pyi"]},{language:"ruby",files:["Gemfile"],extensions:[".rb"]},{language:"cpp",files:["compile_commands.json","CMakeLists.txt","Makefile"],extensions:[".cc",".cpp",".cxx",".hpp",".hh",".hxx"]},{language:"c",files:["compile_commands.json","CMakeLists.txt","Makefile"],extensions:[".c",".h"]},{language:"csharp",globs:["*.csproj","*.sln"],extensions:[".cs"]},{language:"vb",globs:["*.vbproj"],extensions:[".vb"]},{language:"dart",files:["pubspec.yaml"],extensions:[".dart"]},{language:"php",files:["composer.json"],extensions:[".php"]},{language:"javascript",files:["package.json"],extensions:[".js",".jsx",".mjs",".cjs"]}];function w(e){let n=[],t=tn(e),r=an(e);for(let i of nn){if(rn(e,i.files)){n.push(i.language);continue}if(on(t,i.globs)){n.push(i.language);continue}cn(r,i.extensions)&&n.push(i.language)}return n.includes("typescript")&&ne(n,"javascript"),n.includes("cpp")&&!r.has(".c")&&ne(n,"c"),n}function tn(e){try{return te(e)}catch{return[]}}function rn(e,n){return n?.length?n.some(t=>Ze(ie(e,t))):!1}function on(e,n){return n?.length?e.some(t=>n.some(r=>sn(t,r))):!1}function sn(e,n){if(n==="*")return!0;if(!n.includes("*"))return e===n;let[t,r]=n.split("*");return e.startsWith(t??"")&&e.endsWith(r??"")}function an(e){let n=un(e);if(n)return n;let t=new Set,r=[e];for(;r.length>0;){let i=r.pop();if(!i)continue;let o;try{o=te(i,{withFileTypes:!0})}catch{continue}for(let s of o){if(s.name.startsWith(".")&&!s.name.endsWith("proj")&&!s.name.endsWith("sln")&&s.isDirectory())continue;let a=ie(i,s.name);if(s.isDirectory()){en.has(s.name)||r.push(a);continue}let u=re(s.name).toLowerCase();u&&t.add(u)}}return t}function un(e){try{let n=Qe("git",["-C",e,"ls-files","-co","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:26214400,stdio:["ignore","pipe","ignore"]}),t=new Set;for(let r of n.split(`
4
+ `)){if(!r)continue;let i=re(r).toLowerCase();i&&t.add(i)}return t}catch{return null}}function cn(e,n){return n?.length?n.some(t=>e.has(t)):!1}function ne(e,n){let t=e.indexOf(n);t!==-1&&e.splice(t,1)}import{existsSync as oe,readdirSync as ln}from"fs";import{join as O}from"path";var ae={typescript:{language:"typescript",indexerBinary:"scip-typescript",checkCommand:"npx scip-typescript --version",indexArgs:({outputPath:e,pnpmWorkspaces:n,indexerBinary:t})=>{let r=["index","--infer-tsconfig","--output",e,"--no-progress-bar"];return n&&r.splice(1,0,"--pnpm-workspaces"),{binary:t,args:r}},markerFiles:["tsconfig.json"],installMethods:[{label:"npm",prerequisite:"npm",binary:"npm",args:["install","-g","@sourcegraph/scip-typescript"]}],installUrl:"https://github.com/sourcegraph/scip-typescript",bundledNpmPackage:"@sourcegraph/scip-typescript"},javascript:{language:"javascript",indexerBinary:"scip-typescript",checkCommand:"npx scip-typescript --version",indexArgs:({outputPath:e,indexerBinary:n})=>({binary:n,args:["index","--infer-tsconfig","--output",e,"--no-progress-bar"]}),markerFiles:["package.json"],installMethods:[{label:"npm",prerequisite:"npm",binary:"npm",args:["install","-g","@sourcegraph/scip-typescript"]}],installUrl:"https://github.com/sourcegraph/scip-typescript",bundledNpmPackage:"@sourcegraph/scip-typescript"},java:{language:"java",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:["pom.xml","build.gradle"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},scala:{language:"scala",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:["build.sbt"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},kotlin:{language:"kotlin",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:["build.gradle.kts"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},rust:{language:"rust",indexerBinary:"rust-analyzer",checkCommand:"rust-analyzer --version",indexArgs:({outputPath:e})=>({binary:"rust-analyzer",args:["scip",".","--output",e]}),markerFiles:["Cargo.toml"],installMethods:[{label:"rustup",prerequisite:"rustup",binary:"rustup",args:["component","add","rust-analyzer"]}],installUrl:"https://github.com/rust-lang/rust-analyzer"},python:{language:"python",indexerBinary:"scip-python-plus",binaryAliases:["scip-python"],checkCommand:"scip-python-plus --version",indexArgs:({outputPath:e,indexerBinary:n})=>({binary:n,args:["index","--output",e,"--project-name","project"]}),markerFiles:["pyproject.toml","setup.py"],installMethods:[{label:"npm",prerequisite:"npm",binary:"npm",args:["install","-g","scip-python-plus"]}],installUrl:"https://github.com/PlunderStruck/scip-python",bundledNpmPackage:"scip-python-plus"},ruby:{language:"ruby",indexerBinary:"scip-ruby",checkCommand:"scip-ruby --version",indexArgs:({indexerBinary:e})=>({binary:e,args:["--dir","."]}),defaultOutputPath:"index.scip",markerFiles:["Gemfile"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-ruby/releases"},go:{language:"go",indexerBinary:"scip-go",checkCommand:"scip-go --version",indexArgs:({outputPath:e})=>({binary:"scip-go",args:["--output",e]}),markerFiles:["go.mod"],installMethods:[{label:"go install",prerequisite:"go",binary:"go",args:["install","github.com/sourcegraph/scip-go@latest"]}],installUrl:"https://github.com/sourcegraph/scip-go"},cpp:{language:"cpp",indexerBinary:"scip-clang",checkCommand:"scip-clang --version",indexArgs:({outputPath:e})=>({binary:"scip-clang",args:["--compdb-path","compile_commands.json","--index-output-path",e]}),markerFiles:["CMakeLists.txt","Makefile"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-clang/releases"},c:{language:"c",indexerBinary:"scip-clang",checkCommand:"scip-clang --version",indexArgs:({outputPath:e})=>({binary:"scip-clang",args:["--compdb-path","compile_commands.json","--index-output-path",e]}),markerFiles:["CMakeLists.txt","Makefile"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-clang/releases"},csharp:{language:"csharp",indexerBinary:"scip-dotnet",checkCommand:"scip-dotnet --version",indexArgs:({projectRoot:e,outputPath:n})=>({binary:"scip-dotnet",args:["index",se(e,[".sln",".csproj"])??e,"--output",n,"--working-directory",e]}),markerFiles:["*.csproj","*.sln"],installMethods:[{label:"dotnet",prerequisite:"dotnet",binary:"dotnet",args:["tool","install","--global","scip-dotnet"]}],installUrl:"https://github.com/sourcegraph/scip-dotnet/releases"},vb:{language:"vb",indexerBinary:"scip-dotnet",checkCommand:"scip-dotnet --version",indexArgs:({projectRoot:e,outputPath:n})=>({binary:"scip-dotnet",args:["index",se(e,[".sln",".vbproj"])??e,"--output",n,"--working-directory",e]}),markerFiles:["*.vbproj","*.sln"],installMethods:[{label:"dotnet",prerequisite:"dotnet",binary:"dotnet",args:["tool","install","--global","scip-dotnet"]}],installUrl:"https://github.com/sourcegraph/scip-dotnet/releases"},dart:{language:"dart",indexerBinary:"scip-dart",checkCommand:"scip-dart --version",indexArgs:({indexerBinary:e,outputPath:n})=>({binary:e,args:["--output",n]}),markerFiles:["pubspec.yaml"],installMethods:[{label:"dart pub",prerequisite:"dart",binary:"dart",args:["pub","global","activate","scip_dart"]}],installUrl:"https://github.com/Workiva/scip-dart/releases"},php:{language:"php",indexerBinary:"scip-php",projectLocalBinaries:["vendor/davidrjenni/scip-php/bin/scip-php","vendor/bin/scip-php"],checkCommand:"scip-php --version",indexArgs:({projectRoot:e,indexerBinary:n})=>{let t=O(e,"vendor","bin","scip-php"),r=O(e,"vendor","davidrjenni","scip-php","bin","scip-php");return{binary:"php",args:["-d","error_reporting=E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED",oe(r)?r:oe(t)?t:n]}},defaultOutputPath:"index.scip",markerFiles:["composer.json"],installMethods:[],installUrl:"https://github.com/davidrjenni/scip-php/releases"}};function D(e){return ae[e]}function se(e,n){let t;try{t=ln(e)}catch{return null}for(let r of t)if(n.some(i=>r.endsWith(i)))return O(e,r);return null}import{readFileSync as gn,writeFileSync as pn}from"fs";import{create as V}from"@bufbuild/protobuf";import{deserializeSCIP as dn,serializeSCIP as mn,DocumentSchema as fn,IndexSchema as hn,SymbolInformationSchema as bn}from"@c4312/scip";function ue(e){if(e.length===0)throw new Error("Cannot merge zero SCIP indexes");if(e.length===1)return e[0];let n=yn(e),t=xn(e.flatMap(i=>i.documents??[])),r=ce(e.flatMap(i=>i.externalSymbols??[]));return V(hn,{metadata:n,documents:t,externalSymbols:r})}function T(e,n){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let t=e.map(i=>dn(gn(i))),r=ue(t);return pn(n,Buffer.from(mn(r))),{documentCount:r.documents.length,externalSymbolCount:r.externalSymbols.length,inputCount:e.length}}function yn(e){let n=e[0]?.metadata;if(!n)return;let t=n.projectRoot;for(let r of e.slice(1)){let i=r.metadata?.projectRoot;if(t&&i&&i!==t)throw new Error(`Cannot merge SCIP indexes with different project roots: ${t} vs ${i}`)}return n}function xn(e){let n=new Map;for(let t of e){let r=n.get(t.relativePath);if(!r){n.set(t.relativePath,t);continue}n.set(t.relativePath,V(fn,{language:r.language||t.language,relativePath:r.relativePath||t.relativePath,occurrences:[...r.occurrences,...t.occurrences],symbols:ce([...r.symbols,...t.symbols]),text:Rn(r.text,t.text),positionEncoding:r.positionEncoding||t.positionEncoding}))}return[...n.values()]}function ce(e){let n=new Map;for(let t of e){let r=n.get(t.symbol);if(!r){n.set(t.symbol,t);continue}n.set(t.symbol,V(bn,{symbol:r.symbol,documentation:vn([...r.documentation,...t.documentation]),relationships:Sn([...r.relationships,...t.relationships]),kind:r.kind||t.kind,displayName:r.displayName||t.displayName,enclosingSymbol:r.enclosingSymbol||t.enclosingSymbol,signatureDocumentation:r.signatureDocumentation??t.signatureDocumentation}))}return[...n.values()]}function Sn(e){let n=new Set,t=[];for(let r of e){let i=[r.symbol,r.isReference?"1":"0",r.isImplementation?"1":"0",r.isTypeDefinition?"1":"0",r.isDefinition?"1":"0"].join("|");n.has(i)||(n.add(i),t.push(r))}return t}function Rn(e,n){return e?n?e.length>=n.length?e:n:e:n}function vn(e){return[...new Set(e)]}import{execFileSync as kn}from"child_process";import{createHash as In}from"crypto";import{readdirSync as Pn,readFileSync as Cn}from"fs";import{join as le}from"path";function Ln(e){return(wn(e)??On(e)).filter(n=>n&&!ge(n)).sort()}function R(e){return Ln(e).map(n=>{let t=le(e,n);try{let r=Cn(t);return{path:n,size:r.byteLength,hash:In("sha256").update(r).digest("hex")}}catch{return{path:n,size:-1,hash:"unreadable"}}})}function wn(e){try{return kn("git",["-C",e,"ls-files","-co","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:50*1024*1024,stdio:["ignore","pipe","ignore"]}).split(`
5
+ `).filter(Boolean)}catch{return null}}function On(e){let n=[],t=[""];for(;t.length>0;){let r=t.pop(),i=r?le(e,r):e,o;try{o=Pn(i,{withFileTypes:!0})}catch{continue}for(let s of o){let a=r?`${r}/${s.name}`:s.name;if(s.isDirectory()){ge(a)||t.push(a);continue}n.push(a)}}return n}function ge(e){return e.split("/").some(t=>Dn.has(t))||e.endsWith(".db")||e.endsWith(".db-wal")||e.endsWith(".db-shm")||e.endsWith(".scip")}var Dn=new Set([".git","node_modules",".scipquery-cache",".stryker-tmp","dist","build","coverage",".next",".nuxt","target"]);import{readFileSync as Vn,writeFileSync as Tn}from"fs";import{create as pe}from"@bufbuild/protobuf";import{deserializeSCIP as Fn,DocumentSchema as En,IndexSchema as jn,serializeSCIP as Mn,SymbolRole as Nn}from"@c4312/scip";function de(e){let n;try{n=Fn(Vn(e))}catch{return{removedDefinitionOccurrences:0,touchedDocuments:0}}let t=An(n);return t.removedDefinitionOccurrences>0&&Tn(e,Buffer.from(Mn(t.index))),{removedDefinitionOccurrences:t.removedDefinitionOccurrences,touchedDocuments:t.touchedDocuments}}function An(e){let n=new Set;for(let o of e.documents)for(let s of o.symbols)s.symbol&&n.add(s.symbol);for(let o of e.externalSymbols)o.symbol&&n.add(o.symbol);let t=0,r=0,i=[];for(let o of e.documents){let s=o.occurrences.filter(a=>(a.symbolRoles&Nn.Definition)===0||n.has(a.symbol)?!0:(t+=1,!1));if(s.length===o.occurrences.length){i.push(o);continue}r+=1,i.push(pe(En,{language:o.language,relativePath:o.relativePath,occurrences:s,symbols:o.symbols,text:o.text,positionEncoding:o.positionEncoding}))}return{index:t===0?e:pe(jn,{metadata:e.metadata,documents:i,externalSymbols:e.externalSymbols}),removedDefinitionOccurrences:t,touchedDocuments:r}}import{execFile as _n}from"child_process";import{existsSync as v,renameSync as E,rmSync as j}from"fs";import{cpus as $n}from"os";import{join as me}from"path";function Bn(e,n,t){if(!e.defaultOutputPath)return;let r=me(n,e.defaultOutputPath);t!==r&&v(r)&&E(r,t)}function Un(e,n,t){if(!e.defaultOutputPath)return null;let r=me(n,e.defaultOutputPath);if(r===t)return null;let i=`${t}.default-output-backup`;return j(i,{force:!0}),v(r)?(E(r,i),{defaultOutputPath:r,backupPath:i}):{defaultOutputPath:r,backupPath:null}}function Wn(e){e&&(j(e.defaultOutputPath,{force:!0}),e.backupPath&&v(e.backupPath)&&E(e.backupPath,e.defaultOutputPath))}function Hn(e,n){if(e<=1)return 1;let t=Number(process.env.SCIP_QUERY_INDEXER_CONCURRENCY??0),r=Number.isFinite(n)&&n&&n>0?n:Number.isFinite(t)&&t>0?t:Math.min(2,Math.max(1,$n().length-1));return Math.max(1,Math.min(e,Math.floor(r)))}async function fe(e,n,t,r){let i=e.filter(c=>c.config.defaultOutputPath),o=e.filter(c=>!c.config.defaultOutputPath),s=[],a=Hn(o.length,r),u=await zn(o,a,c=>F(c,n,t));if(a>1){let c=new Map;for(let g of u.filter(l=>l.skipped)){let l=o.find(p=>p.language===g.language);l&&(t(`Retrying ${l.language} indexer serially after parallel failure...`),c.set(l.language,await F(l,n,t)))}s.push(...u.map(g=>c.get(g.language)??g))}else s.push(...u);for(let c of i)s.push(await F(c,n,t));return s.sort((c,g)=>e.findIndex(l=>l.language===c.language)-e.findIndex(l=>l.language===g.language))}async function F(e,n,t){t(`Indexing ${e.language} with ${e.resolvedBinary}...`),j(e.scipPath,{force:!0});let r=Un(e.config,n,e.scipPath);try{await Jn(e.binary,e.args,{cwd:n,env:e.env,maxBuffer:50*1024*1024}),Bn(e.config,n,e.scipPath)}catch(i){let o=i instanceof Error?i.message:String(i),s=`${e.resolvedBinary} indexer failed: ${o.split(`
6
+ `)[0]}`;return t(`Skipping ${e.language}: ${s}`),{language:e.language,scipPath:e.scipPath,skipped:{language:e.language,reason:s}}}finally{Wn(r)}if(!v(e.scipPath)){let i=`${e.resolvedBinary} indexer completed but did not produce ${e.scipPath}`;return t(`Skipping ${e.language}: ${i}`),{language:e.language,scipPath:e.scipPath,skipped:{language:e.language,reason:i}}}return{language:e.language,scipPath:e.scipPath}}function Jn(e,n,t){return new Promise((r,i)=>{_n(e,[...n],t,o=>{o?i(o):r()})})}async function zn(e,n,t){if(e.length===0)return[];let r=new Array(e.length),i=0,o=Math.max(1,Math.min(e.length,n)),s=Array.from({length:o},async()=>{for(;i<e.length;){let a=i++;r[a]=await t(e[a])}});return await Promise.all(s),r}import{execFileSync as N}from"child_process";import{existsSync as M,readFileSync as Gn}from"fs";import{createRequire as qn}from"module";import{platform as Kn}from"os";import{dirname as he,join as k}from"path";var Xn=qn(import.meta.url);function A(e){return[e.indexerBinary,...e.binaryAliases??[]]}function I(e){let n=A(e);return n.length===1?n[0]:n.join(" or ")}function x(e){for(let n of A(e))if(f(n))return n;return Qn(e)}function _(e){return x(e)!==null||Yn(e)}function Yn(e){return be(e)!==null}function Qn(e){let n=be(e);if(!n)return null;let r=JSON.parse(Gn(n,"utf8")).bin;if(!r)return null;if(typeof r=="string")return k(he(n),r);for(let i of A(e)){let o=r[i];if(o)return k(he(n),o)}return null}function be(e){if(!e.bundledNpmPackage)return null;try{return Xn.resolve(`${e.bundledNpmPackage}/package.json`)}catch{return null}}function $(e,n){for(let t of e.projectLocalBinaries??[]){let r=k(n,t);if(M(r))return r}return null}function B(e,n=process.env,t=e.indexerBinary){if(e.indexerBinary!=="scip-dotnet"||ye(t,n))return n;let r=Zn(t,n);return r?{...n,DOTNET_ROOT:r}:n}function U(e,n){let t=e.installMethods,r=I(e);if(!t?.length)return n(`No auto-install method available for ${r}.`),e.installUrl&&n(`Install manually from: ${e.installUrl}`),!1;for(let i of t)if(f(i.prerequisite)){n(`Installing ${r} via ${i.label}...`);try{N(i.binary,i.args,{stdio:"inherit",timeout:3e5,env:process.env});let o=x(e);if(o){let s=o===e.indexerBinary?"":` (using ${o})`;return n(`Successfully installed ${r} via ${i.label}${s}`),!0}n(`${i.label} command completed but ${r} was not found on PATH`)}catch(o){let s=o instanceof Error?o.message:String(o);n(`${i.label} install failed: ${s}`)}}return n(`Could not auto-install ${r}.`),e.installUrl&&n(`Install manually from: ${e.installUrl}`),!1}function Zn(e,n){for(let t of et(n))if(ye(e,{...n,DOTNET_ROOT:t}))return t;return null}function et(e){let n=[],t=e.DOTNET_ROOT;if(t&&M(t)&&n.push(t),Kn()==="darwin"&&f("brew"))try{let r=N("brew",["--prefix","dotnet@9"],{stdio:"pipe",env:e}).toString().trim(),i=k(r,"libexec");M(i)&&!n.includes(i)&&n.push(i)}catch{}return n}function ye(e,n){try{return N(e,["--version"],{stdio:"pipe",env:n}),!0}catch{return!1}}import Et from"better-sqlite3";import{existsSync as jt,readFileSync as Mt,writeFileSync as Nt}from"fs";import{dirname as At,join as _t,resolve as $t}from"path";import{readFileSync as nt,rmSync as tt,statSync as rt,mkdtempSync as it}from"fs";import{cpus as ot,tmpdir as st}from"os";import{join as W}from"path";import{Worker as at}from"worker_threads";function xe(e){return e.length>=8&&Re(e.length)>1}function Se(e){let n=Re(e.vueFiles.length),t=ct(e.vueFiles),r=gt(t,n),i=new URL("./augment-vue-worker.js",import.meta.url),o=it(W(st(),"scip-query-vue-workers-")),s=new SharedArrayBuffer(4),a=new Int32Array(s),u=ut(),c=Date.now();try{for(let l=0;l<r.length;l++)new at(i,{workerData:{projectRoot:e.projectRoot,dbPath:e.dbPath,tsconfig:e.tsconfig,tasks:r[l],resultPath:W(o,`${l}.json`),sharedBuffer:s}});for(;Atomics.load(a,0)<r.length;){if(Date.now()-c>u)throw new Error(`Vue reference workers timed out after ${(u/1e3).toFixed(0)}s`);Atomics.wait(a,0,Atomics.load(a,0),100)}let g=r.map((l,p)=>{let d=JSON.parse(nt(W(o,`${p}.json`),"utf-8"));if(!d.ok)throw new Error(`Vue reference worker failed: ${d.error}`);return d.result});return{occurrences:g.flatMap(l=>l.occurrences),skippedReferences:g.reduce((l,p)=>l+p.skippedReferences,0)}}finally{tt(o,{recursive:!0,force:!0})}}function Re(e){let n=Number(process.env.SCIP_QUERY_AUGMENT_VUE_WORKERS??0),t=Number.isFinite(n)&&n>0?n:Math.min(8,Math.max(1,ot().length-1));return Math.max(1,Math.min(e,t))}function ut(){let e=Number(process.env.SCIP_QUERY_AUGMENT_VUE_WORKER_TIMEOUT_MS??0);return Number.isFinite(e)&&e>0?e:3e5}function ct(e){let n=lt(),t=[];for(let r of e){let i=ve(r),o=Math.max(1,Math.ceil(i/n));for(let s=0;s<o;s++)t.push({fileName:r,startOffset:Math.floor(i*s/o),endOffset:s===o-1?Number.POSITIVE_INFINITY:Math.floor(i*(s+1)/o),countFileSkip:s===0})}return t}function lt(){return Number.POSITIVE_INFINITY}function gt(e,n){let t=Array.from({length:n},()=>({tasks:[],weight:0})),r=e.map(i=>({task:i,weight:pt(i)})).sort((i,o)=>o.weight-i.weight);for(let i of r){let o=t.reduce((s,a)=>a.weight<s.weight?a:s);o.tasks.push(i.task),o.weight+=i.weight}return t.map(i=>i.tasks).filter(i=>i.length>0)}function pt(e){return Number.isFinite(e.endOffset)?Math.max(1,e.endOffset-e.startOffset):Math.max(1,ve(e.fileName)-e.startOffset)}function ve(e){try{return rt(e).size}catch{return 1}}import{createRequire as dt}from"module";import{existsSync as mt,readFileSync as J}from"fs";import{dirname as ke,extname as ft,join as Ie,relative as ht,resolve as bt}from"path";import{pathToFileURL as yt}from"url";function xt(e){e.transaction(()=>{e.prepare(`
7
7
  DELETE FROM mentions
8
8
  WHERE chunk_id IN (
9
9
  SELECT c.id
@@ -23,7 +23,7 @@ import{a as m,e as w}from"./chunk-LWYIGRHR.js";import{a as Z}from"./chunk-TKDJQ2
23
23
  FROM documents
24
24
  WHERE language = 'vue' OR relative_path LIKE '%.vue'
25
25
  ORDER BY relative_path
26
- `).all().map(r=>bt(n,r.relativePath))}function Ce(e,n){let{vueCore:t,ts:r,volarTs:i}=St(e),{parsed:o,vueOptions:s}=vt(t,r,n),a=ke(n),u=t.createVueLanguagePlugin(r,o.options,s,d=>d),c=Rt(t,r,u),g=kt(a,o),{languageServiceHost:l}=i.createLanguageServiceHost(r,r.sys,c,d=>d,g),p=r.createLanguageService(l);return{ts:r,language:c,languageService:p,fileNames:o.fileNames,configDir:a}}function St(e){let n=dt(yt(Ie(e,"package.json")).href);return{vueCore:H(n,"@vue/language-core",e),ts:H(n,"typescript",e),volarTs:H(n,"@volar/typescript",e)}}function vt(e,n,t){let r=n.readConfigFile(t,n.sys.readFile);if(r.error||!r.config)throw new Error(`Failed to read ${t}`);let o=e.createParsedCommandLine(n,n.sys,t).vueOptions;return typeof e.createGlobalTypesWriter=="function"&&(o.globalTypesPath=e.createGlobalTypesWriter(o,n.sys.writeFile)),{parsed:n.parseJsonConfigFileContent(r.config,n.sys,ke(t),void 0,t,void 0,e.getAllExtensions(o).map(s=>({extension:s.slice(1),isMixedContent:!0,scriptKind:n.ScriptKind.Deferred}))),vueOptions:o}}function Rt(e,n,t){let r={},i=e.createLanguage([t],new Map,o=>{if(!ft(o))return;let s=J(o,"utf-8");r.current?.scripts.set(o,n.ScriptSnapshot.fromString(s),t.getLanguageId(o)??Ot(o))});return r.current=i,i}function kt(e,n){return{getCurrentDirectory:()=>e,getCompilationSettings:()=>n.options,getScriptFileNames:()=>n.fileNames,getProjectReferences:()=>n.projectReferences,getProjectVersion:()=>"0"}}function H(e,n,t){try{return e(n)}catch(r){throw(typeof r=="object"&&r!==null&&"code"in r?r.code:null)==="MODULE_NOT_FOUND"?new Error(`Vue augmentation requires ${n} to be installed in ${t}. Install Vue/Volar dependencies for that project, then rerun augment-vue.`,{cause:r}):r}}function we(e,n,t){let r=It(e);return i=>{let o=h(n,i.fileName),s=t.get(i.fileName);if(!s)return null;let a=t.positionAt(s,i.textSpan.start),u=r.get(o);if(!u)return null;let c=u.containingByLine.get(a.line);return c!==void 0?c:Pt(u.starts,a.line,2)}}function It(e){let n=e.prepare(`
26
+ `).all().map(r=>bt(n,r.relativePath))}function Ce(e,n){let{vueCore:t,ts:r,volarTs:i}=St(e),{parsed:o,vueOptions:s}=Rt(t,r,n),a=ke(n),u=t.createVueLanguagePlugin(r,o.options,s,d=>d),c=vt(t,r,u),g=kt(a,o),{languageServiceHost:l}=i.createLanguageServiceHost(r,r.sys,c,d=>d,g),p=r.createLanguageService(l);return{ts:r,language:c,languageService:p,fileNames:o.fileNames,configDir:a}}function St(e){let n=dt(yt(Ie(e,"package.json")).href);return{vueCore:H(n,"@vue/language-core",e),ts:H(n,"typescript",e),volarTs:H(n,"@volar/typescript",e)}}function Rt(e,n,t){let r=n.readConfigFile(t,n.sys.readFile);if(r.error||!r.config)throw new Error(`Failed to read ${t}`);let o=e.createParsedCommandLine(n,n.sys,t).vueOptions;return typeof e.createGlobalTypesWriter=="function"&&(o.globalTypesPath=e.createGlobalTypesWriter(o,n.sys.writeFile)),{parsed:n.parseJsonConfigFileContent(r.config,n.sys,ke(t),void 0,t,void 0,e.getAllExtensions(o).map(s=>({extension:s.slice(1),isMixedContent:!0,scriptKind:n.ScriptKind.Deferred}))),vueOptions:o}}function vt(e,n,t){let r={},i=e.createLanguage([t],new Map,o=>{if(!mt(o))return;let s=J(o,"utf-8");r.current?.scripts.set(o,n.ScriptSnapshot.fromString(s),t.getLanguageId(o)??Ot(o))});return r.current=i,i}function kt(e,n){return{getCurrentDirectory:()=>e,getCompilationSettings:()=>n.options,getScriptFileNames:()=>n.fileNames,getProjectReferences:()=>n.projectReferences,getProjectVersion:()=>"0"}}function H(e,n,t){try{return e(n)}catch(r){throw(typeof r=="object"&&r!==null&&"code"in r?r.code:null)==="MODULE_NOT_FOUND"?new Error(`Vue augmentation requires ${n} to be installed in ${t}. Install Vue/Volar dependencies for that project, then rerun augment-vue.`,{cause:r}):r}}function Le(e,n,t){let r=It(e);return i=>{let o=h(n,i.fileName),s=t.get(i.fileName);if(!s)return null;let a=t.positionAt(s,i.textSpan.start),u=r.get(o);if(!u)return null;let c=u.containingByLine.get(a.line);return c!==void 0?c:Pt(u.starts,a.line,2)}}function It(e){let n=e.prepare(`
27
27
  SELECT
28
28
  d.relative_path AS relativePath,
29
29
  der.start_line AS startLine,
@@ -32,22 +32,22 @@ import{a as m,e as w}from"./chunk-LWYIGRHR.js";import{a as Z}from"./chunk-TKDJQ2
32
32
  FROM defn_enclosing_ranges der
33
33
  JOIN documents d ON d.id = der.document_id
34
34
  ORDER BY d.relative_path, (der.end_line - der.start_line) DESC
35
- `).all(),t=new Map;for(let r of n){let i=t.get(r.relativePath);i||(i={containingByLine:new Map,starts:[]},t.set(r.relativePath,i)),i.starts.push({line:r.startLine,symbolId:r.symbolId});for(let o=r.startLine;o<=r.endLine;o++)i.containingByLine.set(o,r.symbolId)}for(let r of t.values())r.starts.sort((i,o)=>i.line-o.line);return t}function Pt(e,n,t){let r=0,i=e.length-1;for(;r<=i;){let s=Math.floor((r+i)/2);e[s].line<n?r=s+1:i=s-1}let o=null;for(let s of[i,r]){let a=e[s];if(!a)continue;let u=Math.abs(a.line-n);u>t||(!o||u<o.distance)&&(o={distance:u,symbolId:a.symbolId})}return o?.symbolId??null}function Le(e,n,t){let r=Ft(n),i=e.prepare("SELECT id FROM global_symbols WHERE symbol = ?"),o=e.prepare(`
35
+ `).all(),t=new Map;for(let r of n){let i=t.get(r.relativePath);i||(i={containingByLine:new Map,starts:[]},t.set(r.relativePath,i)),i.starts.push({line:r.startLine,symbolId:r.symbolId});for(let o=r.startLine;o<=r.endLine;o++)i.containingByLine.set(o,r.symbolId)}for(let r of t.values())r.starts.sort((i,o)=>i.line-o.line);return t}function Pt(e,n,t){let r=0,i=e.length-1;for(;r<=i;){let s=Math.floor((r+i)/2);e[s].line<n?r=s+1:i=s-1}let o=null;for(let s of[i,r]){let a=e[s];if(!a)continue;let u=Math.abs(a.line-n);u>t||(!o||u<o.distance)&&(o={distance:u,symbolId:a.symbolId})}return o?.symbolId??null}function we(e,n,t){let r=Tt(n),i=e.prepare("SELECT id FROM global_symbols WHERE symbol = ?"),o=e.prepare(`
36
36
  INSERT OR IGNORE INTO global_symbols (symbol, display_name, kind, documentation)
37
37
  VALUES (?, ?, ?, ?)
38
- `),s=0,a=new Map;return e.transaction(()=>{for(let c of t){let g=h(n,c),l=Ne(r.name,r.version,g);o.run(l,"default",7,`Vue component|${g}`);let p=Et(i,r,n,c);p&&(s++,a.set(c,p))}})(),{get(c){return a.get(c)??null},syntheticSymbols:s}}function Oe(e,n,t,r,i){return e.transaction(()=>(xt(e),Ct(e,n,t,r),wt(e,i)))()}function Ct(e,n,t,r){let i=e.prepare("SELECT id FROM documents WHERE relative_path = ?"),o=e.prepare(`
38
+ `),s=0,a=new Map;return e.transaction(()=>{for(let c of t){let g=h(n,c),l=Ne(r.name,r.version,g);o.run(l,"default",7,`Vue component|${g}`);let p=Ft(i,r,n,c);p&&(s++,a.set(c,p))}})(),{get(c){return a.get(c)??null},syntheticSymbols:s}}function Oe(e,n,t,r,i){return e.transaction(()=>(xt(e),Ct(e,n,t,r),Lt(e,i)))()}function Ct(e,n,t,r){let i=e.prepare("SELECT id FROM documents WHERE relative_path = ?"),o=e.prepare(`
39
39
  INSERT INTO chunks (document_id, chunk_index, start_line, end_line, occurrences)
40
40
  VALUES (?, ?, ?, ?, X'00')
41
41
  `),s=e.prepare(`
42
42
  INSERT OR IGNORE INTO mentions (chunk_id, symbol_id, role)
43
43
  VALUES (?, ?, 1)
44
- `);for(let a of t){let u=r.get(a);if(!u)continue;let c=h(n,a),g=i.get(c);if(!g)continue;let l=o.run(g.id,-1,0,0);s.run(Number(l.lastInsertRowid),u)}}function De(e,n,t,r,i){if(e.fileName.endsWith(".vue")){let o=r.language.scripts.get(e.fileName),s=o?.generated?.languagePlugin.typescript?.getServiceScript(o.generated.root)?.code;if(o&&s){let a=r.language.maps.get(s,o);if(z(a,e.textSpan.start)!==null)return t.get(e.fileName)}return e.fileName.startsWith(i)?t.get(e.fileName):null}return n(e)}function Te(e){let n=new Set,t=[];for(let r of e){let i=Fe(r);n.has(i)||(n.add(i),t.push(r))}return t}function Fe(e){return[e.sourceFile,e.sourceLine,e.sourceStartChar,e.sourceEndChar,e.symbolId].join(":")}function wt(e,n){let t=Tt(e,[...new Set(n.map(u=>u.sourceFile))]),r=e.prepare(`
44
+ `);for(let a of t){let u=r.get(a);if(!u)continue;let c=h(n,a),g=i.get(c);if(!g)continue;let l=o.run(g.id,-1,0,0);s.run(Number(l.lastInsertRowid),u)}}function De(e,n,t,r,i){if(e.fileName.endsWith(".vue")){let o=r.language.scripts.get(e.fileName),s=o?.generated?.languagePlugin.typescript?.getServiceScript(o.generated.root)?.code;if(o&&s){let a=r.language.maps.get(s,o);if(z(a,e.textSpan.start)!==null)return t.get(e.fileName)}return e.fileName.startsWith(i)?t.get(e.fileName):null}return n(e)}function Ve(e){let n=new Set,t=[];for(let r of e){let i=Te(r);n.has(i)||(n.add(i),t.push(r))}return t}function Te(e){return[e.sourceFile,e.sourceLine,e.sourceStartChar,e.sourceEndChar,e.symbolId].join(":")}function Lt(e,n){let t=Vt(e,[...new Set(n.map(u=>u.sourceFile))]),r=e.prepare(`
45
45
  INSERT INTO chunks (document_id, chunk_index, start_line, end_line, occurrences)
46
46
  VALUES (?, ?, ?, ?, X'00')
47
47
  `),i=e.prepare(`
48
48
  INSERT OR IGNORE INTO mentions (chunk_id, symbol_id, role)
49
49
  VALUES (?, ?, 0)
50
- `),o=new Set,s=0,a=0;for(let u of n){let c=Fe(u);if(o.has(c))continue;o.add(c);let g=t.get(u.sourceFile);if(!g)continue;let l=r.run(g,a++,u.sourceLine,u.sourceLine),p=i.run(Number(l.lastInsertRowid),u.symbolId);s+=Number(p.changes)}return s}function*Ee(e){let n=/\b[A-Za-z_$][A-Za-z0-9_$]*\b/g,t=new Set(["script","setup","template","style","lang","scoped","true","false","null","undefined","const","let","var","import","from","export","return","if","else","for","while","function","class","type","interface","as","await","async"]),r;for(;r=n.exec(e);){let i=r[0];t.has(i)||(yield{text:i,start:r.index,end:r.index+i.length})}}function Ve(e,n){for(let[t]of e.toGeneratedLocation(n,r=>!!r.navigation))return t;return null}function z(e,n){let t=e;for(let[r]of t.toSourceLocation(n,i=>!!i.navigation))return r;return null}function Lt(e,n){let t=0,r=e.lineStarts.length-1;for(;t<=r;){let o=Math.floor((t+r)/2);e.lineStarts[o]<=n?t=o+1:r=o-1}let i=Math.max(0,r);return{line:i,character:n-e.lineStarts[i]}}function je(e,n){return h(e,n).startsWith("node_modules/")}function h(e,n){return ht(e,n).replaceAll("\\","/")}function Ot(e){switch(mt(e)){case".vue":return"vue";case".tsx":return"typescriptreact";case".ts":case".mts":case".cts":return"typescript";case".jsx":return"javascriptreact";case".js":case".mjs":case".cjs":return"javascript";case".json":return"json";default:return"typescript"}}function Me(){let e=new Map;return{get(n){if(e.has(n))return e.get(n)??null;try{let t=J(n,"utf-8"),r={text:t,lineStarts:Dt(t)};return e.set(n,r),r}catch{return e.set(n,null),null}},positionAt:Lt}}function Dt(e){let n=[0];for(let t=0;t<e.length;t++)e.charCodeAt(t)===10&&n.push(t+1);return n}function Tt(e,n){let t=new Map,r=500;for(let i=0;i<n.length;i+=r){let o=n.slice(i,i+r),s=e.prepare(`SELECT id, relative_path AS relativePath FROM documents WHERE relative_path IN (${o.map(()=>"?").join(",")})`).all(...o);for(let a of s)t.set(a.relativePath,a.id)}return t}function Ft(e){try{let n=JSON.parse(J(Ie(e,"package.json"),"utf-8"));return{name:n.name??"workspace",version:n.version??"0.0.0"}}catch{return{name:"workspace",version:"0.0.0"}}}function Et(e,n,t,r){let i=h(t,r),o=Ne(n.name,n.version,i);return e.get(o)?.id??null}function Ne(e,n,t){let r=t.split("/").map(i=>`\`${i.replaceAll("`","")}\``).join("/");return`scip-vue npm ${e} ${n} ${r}/default.`}function Bt(e){y({projectRoot:e.projectRoot,dbPath:e.dbPath});let n=$t(e.projectRoot,e.tsconfig);if(!jt(n))throw new Error(`Vue tsconfig not found at ${n}`);let t=new Vt(e.dbPath);try{let r=Pe(t,e.projectRoot),i=_t(At(e.dbPath),"augment-vue-meta.json"),o=Ae(t,e.projectRoot,e.tsconfig),s=Ut(i,o,e.onStatus);if(s)return s;let a=Wt({db:t,projectRoot:e.projectRoot,dbPath:e.dbPath,tsconfig:e.tsconfig,configPath:n,vueFiles:r,onStatus:e.onStatus});return zt(i,Ae(t,e.projectRoot,e.tsconfig),a),a}finally{t.close()}}function Ut(e,n,t){let r=Jt(e,n);return r&&t?.(`Vue references unchanged; reused ${r.resolvedReferences} cached resolved references.`),r}function Wt(e){let n=Le(e.db,e.projectRoot,e.vueFiles),t=Ht(e,n),r=Te(t.occurrences),i=Oe(e.db,e.projectRoot,e.vueFiles,n,r),o={vueFiles:e.vueFiles.length,resolvedReferences:r.length,insertedMentions:i,skippedReferences:t.skippedReferences,syntheticSymbols:n.syntheticSymbols};return e.onStatus?.(`Resolved ${o.resolvedReferences} Vue references with Volar; inserted ${o.insertedMentions} mentions.`),o}function Ht(e,n){if(xe(e.vueFiles))return Se({projectRoot:e.projectRoot,dbPath:e.dbPath,tsconfig:e.tsconfig,vueFiles:e.vueFiles});let t=Me(),r=Ce(e.projectRoot,e.configPath);return Gt({projectRoot:e.projectRoot,vueFiles:r.fileNames.filter(i=>i.endsWith(".vue")),context:r,symbolLookup:we(e.db,e.projectRoot,t),vueSymbolLookup:n,sourceReader:t})}function Jt(e,n){try{let t=JSON.parse(Mt(e,"utf-8"));return JSON.stringify(t.fingerprint)===JSON.stringify(n)?t.result:null}catch{return null}}function zt(e,n,t){Nt(e,JSON.stringify({updatedAt:new Date().toISOString(),fingerprint:n,result:t},null,2)+`
50
+ `),o=new Set,s=0,a=0;for(let u of n){let c=Te(u);if(o.has(c))continue;o.add(c);let g=t.get(u.sourceFile);if(!g)continue;let l=r.run(g,a++,u.sourceLine,u.sourceLine),p=i.run(Number(l.lastInsertRowid),u.symbolId);s+=Number(p.changes)}return s}function*Fe(e){let n=/\b[A-Za-z_$][A-Za-z0-9_$]*\b/g,t=new Set(["script","setup","template","style","lang","scoped","true","false","null","undefined","const","let","var","import","from","export","return","if","else","for","while","function","class","type","interface","as","await","async"]),r;for(;r=n.exec(e);){let i=r[0];t.has(i)||(yield{text:i,start:r.index,end:r.index+i.length})}}function Ee(e,n){for(let[t]of e.toGeneratedLocation(n,r=>!!r.navigation))return t;return null}function z(e,n){let t=e;for(let[r]of t.toSourceLocation(n,i=>!!i.navigation))return r;return null}function wt(e,n){let t=0,r=e.lineStarts.length-1;for(;t<=r;){let o=Math.floor((t+r)/2);e.lineStarts[o]<=n?t=o+1:r=o-1}let i=Math.max(0,r);return{line:i,character:n-e.lineStarts[i]}}function je(e,n){return h(e,n).startsWith("node_modules/")}function h(e,n){return ht(e,n).replaceAll("\\","/")}function Ot(e){switch(ft(e)){case".vue":return"vue";case".tsx":return"typescriptreact";case".ts":case".mts":case".cts":return"typescript";case".jsx":return"javascriptreact";case".js":case".mjs":case".cjs":return"javascript";case".json":return"json";default:return"typescript"}}function Me(){let e=new Map;return{get(n){if(e.has(n))return e.get(n)??null;try{let t=J(n,"utf-8"),r={text:t,lineStarts:Dt(t)};return e.set(n,r),r}catch{return e.set(n,null),null}},positionAt:wt}}function Dt(e){let n=[0];for(let t=0;t<e.length;t++)e.charCodeAt(t)===10&&n.push(t+1);return n}function Vt(e,n){let t=new Map,r=500;for(let i=0;i<n.length;i+=r){let o=n.slice(i,i+r),s=e.prepare(`SELECT id, relative_path AS relativePath FROM documents WHERE relative_path IN (${o.map(()=>"?").join(",")})`).all(...o);for(let a of s)t.set(a.relativePath,a.id)}return t}function Tt(e){try{let n=JSON.parse(J(Ie(e,"package.json"),"utf-8"));return{name:n.name??"workspace",version:n.version??"0.0.0"}}catch{return{name:"workspace",version:"0.0.0"}}}function Ft(e,n,t,r){let i=h(t,r),o=Ne(n.name,n.version,i);return e.get(o)?.id??null}function Ne(e,n,t){let r=t.split("/").map(i=>`\`${i.replaceAll("`","")}\``).join("/");return`scip-vue npm ${e} ${n} ${r}/default.`}function Bt(e){y({projectRoot:e.projectRoot,dbPath:e.dbPath});let n=$t(e.projectRoot,e.tsconfig);if(!jt(n))throw new Error(`Vue tsconfig not found at ${n}`);let t=new Et(e.dbPath);try{let r=Pe(t,e.projectRoot),i=_t(At(e.dbPath),"augment-vue-meta.json"),o=Ae(t,e.projectRoot,e.tsconfig),s=Ut(i,o,e.onStatus);if(s)return s;let a=Wt({db:t,projectRoot:e.projectRoot,dbPath:e.dbPath,tsconfig:e.tsconfig,configPath:n,vueFiles:r,onStatus:e.onStatus});return zt(i,Ae(t,e.projectRoot,e.tsconfig),a),a}finally{t.close()}}function Ut(e,n,t){let r=Jt(e,n);return r&&t?.(`Vue references unchanged; reused ${r.resolvedReferences} cached resolved references.`),r}function Wt(e){let n=we(e.db,e.projectRoot,e.vueFiles),t=Ht(e,n),r=Ve(t.occurrences),i=Oe(e.db,e.projectRoot,e.vueFiles,n,r),o={vueFiles:e.vueFiles.length,resolvedReferences:r.length,insertedMentions:i,skippedReferences:t.skippedReferences,syntheticSymbols:n.syntheticSymbols};return e.onStatus?.(`Resolved ${o.resolvedReferences} Vue references with Volar; inserted ${o.insertedMentions} mentions.`),o}function Ht(e,n){if(xe(e.vueFiles))return Se({projectRoot:e.projectRoot,dbPath:e.dbPath,tsconfig:e.tsconfig,vueFiles:e.vueFiles});let t=Gt({db:e.db,projectRoot:e.projectRoot,configPath:e.configPath,vueSymbolLookup:n});return qt({...t,vueFiles:t.context.fileNames.filter(r=>r.endsWith(".vue"))})}function Jt(e,n){try{let t=JSON.parse(Mt(e,"utf-8"));return JSON.stringify(t.fingerprint)===JSON.stringify(n)?t.result:null}catch{return null}}function zt(e,n,t){Nt(e,JSON.stringify({updatedAt:new Date().toISOString(),fingerprint:n,result:t},null,2)+`
51
51
  `)}function Ae(e,n,t){let r=e.prepare(`
52
52
  SELECT
53
53
  (SELECT COUNT(*) FROM documents) AS documents,
@@ -57,13 +57,13 @@ import{a as m,e as w}from"./chunk-LWYIGRHR.js";import{a as Z}from"./chunk-TKDJQ2
57
57
  (SELECT COUNT(*) FROM defn_enclosing_ranges) AS ranges,
58
58
  (SELECT MAX(id) FROM chunks) AS maxChunkId,
59
59
  (SELECT MAX(id) FROM global_symbols) AS maxSymbolId
60
- `).get();return{version:2,tsconfig:t,files:v(n),db:r}}function Gt(e){let n=[],t=0,r=e.tasks??e.vueFiles.map(i=>({fileName:i,startOffset:0,endOffset:Number.POSITIVE_INFINITY,countFileSkip:!0}));for(let i of r){let o=qt(e,i);n.push(...o.occurrences),t+=o.skippedReferences}return{occurrences:n,skippedReferences:t}}function qt(e,n){let t=e.context.language.scripts.get(n.fileName),r=t?.generated?.languagePlugin.typescript?.getServiceScript(t.generated.root)?.code;if(!t||!r)return{occurrences:[],skippedReferences:n.countFileSkip?1:0};let i=e.sourceReader.get(n.fileName);if(!i)return{occurrences:[],skippedReferences:n.countFileSkip?1:0};let o=e.context.language.maps.get(r,t),s=h(e.projectRoot,n.fileName),a=[...Ee(i.text)],u={tokens:a.filter(c=>c.start>=n.startOffset&&c.start<n.endOffset),tokenByStart:new Map(a.map(c=>[c.start,c])),tokenTextCounts:Yt(a),processedStarts:new Set};return Kt({...e,fileName:n.fileName,sourceInfo:i,sourceFile:s,map:o,tokenContext:u})}function Kt(e){let n=[],t=0;for(let r of e.tokenContext.tokens){if(e.tokenContext.processedStarts.has(r.start))continue;let i=Ve(e.map,r.start);if(i===null)continue;let s=(e.context.languageService.getDefinitionAtPosition(e.fileName,i+1)??[]).find(u=>!je(e.projectRoot,u.fileName));if(!s){t++;continue}let a=De(s,e.symbolLookup,e.vueSymbolLookup,e.context,e.projectRoot);if(a===null){t++;continue}_e(n,e.sourceReader,e.sourceInfo,e.sourceFile,r,a),e.tokenContext.processedStarts.add(r.start),Xt(n,e,r,i,a)}return{occurrences:n,skippedReferences:t}}function Xt(e,n,t,r,i){if(!((n.tokenContext.tokenTextCounts.get(t.text)??0)<=1))for(let o of Qt(n.context.languageService,n.fileName,r+1,n.map,t,n.tokenContext.tokenByStart)){if(n.tokenContext.processedStarts.has(o))continue;let s=n.tokenContext.tokenByStart.get(o);s&&(_e(e,n.sourceReader,n.sourceInfo,n.sourceFile,s,i),n.tokenContext.processedStarts.add(o))}}function _e(e,n,t,r,i,o){let s=n.positionAt(t,i.start);e.push({sourceFile:r,sourceLine:s.line,sourceStartChar:s.character,sourceEndChar:s.character+i.text.length,symbolId:o})}function Yt(e){let n=new Map;for(let t of e)n.set(t.text,(n.get(t.text)??0)+1);return n}function Qt(e,n,t,r,i,o){let s=e.getDocumentHighlights?.(n,t,[n])??[],a=[];for(let u of s)if(u.fileName===n)for(let c of u.highlightSpans){let g=Zt(r,c.textSpan.start,o,i.text);g!==null&&a.push(g)}return a}function Zt(e,n,t,r){let i=t.get(n);if(i?.text===r)return i.start;let o=z(e,n);if(o===null)return null;let s=t.get(o);return s?.text===r?s.start:null}async function Bi(e){let{projectRoot:n,maxHeapMb:t=8192,onStatus:r=console.log,skipAutoInstall:i=!1}=e,o=sr(e),s=Date.now();$e(b(o.outputScip),{recursive:!0}),$e(b(o.outputDb),{recursive:!0});let a=e.languages??L(n);if(a.length===0)throw new Error("No supported languages detected in this project. Looked for: tsconfig.json, Cargo.toml, go.mod, pyproject.toml, etc.");r(`Detected languages: ${a.join(", ")}`);let u=Rr(n,a,{pnpmWorkspaces:e.pnpmWorkspaces}),c=Sr(f(b(o.outputDb),"index.lock")),g=null;try{let l=ar({opts:e,paths:o,languages:a,fingerprint:u,start:s,onStatus:r});if(l)return l;pr(i,r);let p=ur(o);return g=p.runDir,await cr({opts:e,languages:a,projectRoot:n,paths:o,tempPaths:p,fingerprint:u,start:s,maxHeapMb:t,skipAutoInstall:i,onStatus:r})}finally{g&&X(g,{recursive:!0,force:!0}),c()}}function sr(e){let n=e.outputScip??f(e.projectRoot,"index.scip"),t=e.outputDb??f(e.projectRoot,"index.db");return{outputScip:n,outputDb:t,metaPath:f(b(t),"meta.json")}}function ar(e){if(e.opts.skipIfUnchanged===!1||!q(e.paths.outputScip)||!q(e.paths.outputDb)||!kr(e.paths.metaPath,e.fingerprint))return null;y({projectRoot:e.opts.projectRoot,dbPath:e.paths.outputDb,onStatus:e.onStatus});let n=Date.now()-e.start;return e.onStatus(`Index unchanged; reused existing SQLite index in ${(n/1e3).toFixed(1)}s`),{languages:e.languages,indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:n,reused:!0,skipped:[]}}function ur(e){let n=tr(f(b(e.outputDb),"reindex-"));return{runDir:n,tempOutputScip:f(n,C(e.outputScip)),tempOutputDb:f(n,C(e.outputDb)),tempMetaPath:f(n,C(e.metaPath))}}async function cr(e){let n={...process.env,NODE_OPTIONS:`--max-old-space-size=${e.maxHeapMb}`},{indexedOutputs:t,skippedLanguages:r}=await lr(e,n);gr(e,n,t,r);let i=Date.now()-e.start;return e.onStatus(`Done in ${(i/1e3).toFixed(1)}s`),{languages:t.map(o=>o.language),indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:i,reused:!1,skipped:r}}async function lr(e,n){let{preparedRuns:t,skippedLanguages:r}=dr({languages:e.languages,tempOutputScip:e.tempPaths.tempOutputScip,projectRoot:e.projectRoot,env:n,skipAutoInstall:e.skipAutoInstall,pnpmWorkspaces:e.opts.pnpmWorkspaces,onStatus:e.onStatus}),i=await me(t,e.projectRoot,e.onStatus,e.opts.indexerConcurrency),{indexedOutputs:o}=mr(i,r);return hr(o,r,e.languages,e.opts.allowPartial,e.onStatus),{indexedOutputs:o,skippedLanguages:r}}function gr(e,n,t,r){br(t,e.tempPaths.tempOutputScip,e.onStatus),yr(e.tempPaths.tempOutputScip,e.tempPaths.tempOutputDb,n,e.onStatus),y({projectRoot:e.projectRoot,dbPath:e.tempPaths.tempOutputDb,onStatus:e.onStatus}),Ir(e.tempPaths.tempMetaPath,{version:2,status:r.length===0?"complete":"partial",updatedAt:new Date().toISOString(),fingerprint:e.fingerprint,requestedLanguages:e.languages,indexedLanguages:t.map(i=>i.language),skipped:[...r]}),vr({tempOutputScip:e.tempPaths.tempOutputScip,tempOutputDb:e.tempPaths.tempOutputDb,tempMetaPath:e.tempPaths.tempMetaPath,outputScip:e.paths.outputScip,outputDb:e.paths.outputDb,metaPath:e.paths.metaPath})}function pr(e,n){if(!m("scip")){if(e)throw new Error(`The scip CLI is required but not found on PATH.
61
- Install from: https://github.com/sourcegraph/scip/releases`);if(n("scip CLI not found on PATH. Attempting auto-install..."),!w(n))throw new Error(`The scip CLI is required but could not be installed.
62
- Install manually from: https://github.com/sourcegraph/scip/releases`)}}function dr(e){let n=[],t=[],r=e.languages.map((i,o)=>({language:i,scipPath:e.languages.length>1?xr(e.tempOutputScip,i,o):e.tempOutputScip}));for(let{language:i,scipPath:o}of r){let s=fr({...e,language:i,scipPath:o});"skipped"in s?t.push(s.skipped):n.push(s.prepared)}return{preparedRuns:n,skippedLanguages:t}}function fr(e){let n=D(e.language),t=I(n),r=$(n,e.projectRoot);if(!r&&!_(n)){if(e.skipAutoInstall){let a=`${t} not found on PATH (auto-install disabled). ${n.installUrl??""}`.trim();return e.onStatus(`Skipping ${e.language}: ${a}`),{skipped:{language:e.language,reason:a}}}if(e.onStatus(`${t} not found. Attempting auto-install...`),!U(n,e.onStatus)){let a=`${t} could not be auto-installed. ${n.installUrl?`Install manually from ${n.installUrl}`:`Install ${t} and put it on PATH.`}`;return e.onStatus(`Skipping ${e.language}: ${a}`),{skipped:{language:e.language,reason:a}}}}let i=r??x(n);if(!i){let a=`${t} was not found after installation checks.`;return e.onStatus(`Skipping ${e.language}: ${a}`),{skipped:{language:e.language,reason:a}}}let{binary:o,args:s}=n.indexArgs({projectRoot:e.projectRoot,outputPath:e.scipPath,pnpmWorkspaces:e.pnpmWorkspaces,indexerBinary:i});return{prepared:{language:e.language,scipPath:e.scipPath,config:n,resolvedBinary:i,binary:o,args:s,env:B(n,e.env,i)}}}function mr(e,n){let t=[];for(let r of e)r.skipped?n.push(r.skipped):t.push({language:r.language,scipPath:r.scipPath});return{indexedOutputs:t}}function hr(e,n,t,r,i){if(e.length===0){let o=n.map(s=>` - ${s.language}: ${s.reason}`).join(`
60
+ `).get();return{version:2,tsconfig:t,files:R(n),db:r}}function Gt(e){let n=Me();return{projectRoot:e.projectRoot,context:Ce(e.projectRoot,e.configPath),symbolLookup:Le(e.db,e.projectRoot,n),vueSymbolLookup:e.vueSymbolLookup,sourceReader:n}}function qt(e){let n=[],t=0,r=e.tasks??e.vueFiles.map(i=>({fileName:i,startOffset:0,endOffset:Number.POSITIVE_INFINITY,countFileSkip:!0}));for(let i of r){let o=Kt(e,i);n.push(...o.occurrences),t+=o.skippedReferences}return{occurrences:n,skippedReferences:t}}function Kt(e,n){let t=e.context.language.scripts.get(n.fileName),r=t?.generated?.languagePlugin.typescript?.getServiceScript(t.generated.root)?.code;if(!t||!r)return{occurrences:[],skippedReferences:n.countFileSkip?1:0};let i=e.sourceReader.get(n.fileName);if(!i)return{occurrences:[],skippedReferences:n.countFileSkip?1:0};let o=e.context.language.maps.get(r,t),s=h(e.projectRoot,n.fileName),a=[...Fe(i.text)],u={tokens:a.filter(c=>c.start>=n.startOffset&&c.start<n.endOffset),tokenByStart:new Map(a.map(c=>[c.start,c])),tokenTextCounts:Qt(a),processedStarts:new Set};return Xt({...e,fileName:n.fileName,sourceInfo:i,sourceFile:s,map:o,tokenContext:u})}function Xt(e){let n=[],t=0;for(let r of e.tokenContext.tokens){if(e.tokenContext.processedStarts.has(r.start))continue;let i=Ee(e.map,r.start);if(i===null)continue;let s=(e.context.languageService.getDefinitionAtPosition(e.fileName,i+1)??[]).find(u=>!je(e.projectRoot,u.fileName));if(!s){t++;continue}let a=De(s,e.symbolLookup,e.vueSymbolLookup,e.context,e.projectRoot);if(a===null){t++;continue}_e(n,e.sourceReader,e.sourceInfo,e.sourceFile,r,a),e.tokenContext.processedStarts.add(r.start),Yt(n,e,r,i,a)}return{occurrences:n,skippedReferences:t}}function Yt(e,n,t,r,i){if(!((n.tokenContext.tokenTextCounts.get(t.text)??0)<=1))for(let o of Zt(n.context.languageService,n.fileName,r+1,n.map,t,n.tokenContext.tokenByStart)){if(n.tokenContext.processedStarts.has(o))continue;let s=n.tokenContext.tokenByStart.get(o);s&&(_e(e,n.sourceReader,n.sourceInfo,n.sourceFile,s,i),n.tokenContext.processedStarts.add(o))}}function _e(e,n,t,r,i,o){let s=n.positionAt(t,i.start);e.push({sourceFile:r,sourceLine:s.line,sourceStartChar:s.character,sourceEndChar:s.character+i.text.length,symbolId:o})}function Qt(e){let n=new Map;for(let t of e)n.set(t.text,(n.get(t.text)??0)+1);return n}function Zt(e,n,t,r,i,o){let s=e.getDocumentHighlights?.(n,t,[n])??[],a=[];for(let u of s)if(u.fileName===n)for(let c of u.highlightSpans){let g=er(r,c.textSpan.start,o,i.text);g!==null&&a.push(g)}return a}function er(e,n,t,r){let i=t.get(n);if(i?.text===r)return i.start;let o=z(e,n);if(o===null)return null;let s=t.get(o);return s?.text===r?s.start:null}async function Ui(e){let{projectRoot:n,maxHeapMb:t=8192,onStatus:r=console.log,skipAutoInstall:i=!1}=e,o=ar(e),s=Date.now();$e(b(o.outputScip),{recursive:!0}),$e(b(o.outputDb),{recursive:!0});let a=e.languages??w(n);if(a.length===0)throw new Error("No supported languages detected in this project. Looked for: tsconfig.json, Cargo.toml, go.mod, pyproject.toml, etc.");r(`Detected languages: ${a.join(", ")}`);let u=kr(n,a,{pnpmWorkspaces:e.pnpmWorkspaces}),c=Rr(m(b(o.outputDb),"index.lock")),g=null;try{let l=ur({opts:e,paths:o,languages:a,fingerprint:u,start:s,onStatus:r});if(l)return l;dr(i,r);let p=cr(o);return g=p.runDir,await lr({opts:e,languages:a,projectRoot:n,paths:o,tempPaths:p,fingerprint:u,start:s,maxHeapMb:t,skipAutoInstall:i,onStatus:r})}finally{g&&X(g,{recursive:!0,force:!0}),c()}}function ar(e){let n=e.outputScip??m(e.projectRoot,"index.scip"),t=e.outputDb??m(e.projectRoot,"index.db");return{outputScip:n,outputDb:t,metaPath:m(b(t),"meta.json")}}function ur(e){if(e.opts.skipIfUnchanged===!1||!q(e.paths.outputScip)||!q(e.paths.outputDb)||!Ir(e.paths.metaPath,e.fingerprint))return null;y({projectRoot:e.opts.projectRoot,dbPath:e.paths.outputDb,onStatus:e.onStatus});let n=Date.now()-e.start;return e.onStatus(`Index unchanged; reused existing SQLite index in ${(n/1e3).toFixed(1)}s`),{languages:e.languages,indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:n,reused:!0,skipped:[]}}function cr(e){let n=rr(m(b(e.outputDb),"reindex-"));return{runDir:n,tempOutputScip:m(n,C(e.outputScip)),tempOutputDb:m(n,C(e.outputDb)),tempMetaPath:m(n,C(e.metaPath))}}async function lr(e){let n={...process.env,NODE_OPTIONS:`--max-old-space-size=${e.maxHeapMb}`},{indexedOutputs:t,skippedLanguages:r}=await gr(e,n);pr(e,n,t,r);let i=Date.now()-e.start;return e.onStatus(`Done in ${(i/1e3).toFixed(1)}s`),{languages:t.map(o=>o.language),indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:i,reused:!1,skipped:r}}async function gr(e,n){let{preparedRuns:t,skippedLanguages:r}=mr({languages:e.languages,tempOutputScip:e.tempPaths.tempOutputScip,projectRoot:e.projectRoot,env:n,skipAutoInstall:e.skipAutoInstall,pnpmWorkspaces:e.opts.pnpmWorkspaces,onStatus:e.onStatus}),i=await fe(t,e.projectRoot,e.onStatus,e.opts.indexerConcurrency),{indexedOutputs:o}=hr(i,r);return br(o,r,e.languages,e.opts.allowPartial,e.onStatus),{indexedOutputs:o,skippedLanguages:r}}function pr(e,n,t,r){yr(t,e.tempPaths.tempOutputScip,e.onStatus),xr(e.tempPaths.tempOutputScip,e.tempPaths.tempOutputDb,n,e.onStatus),y({projectRoot:e.projectRoot,dbPath:e.tempPaths.tempOutputDb,onStatus:e.onStatus}),Pr(e.tempPaths.tempMetaPath,{version:2,status:r.length===0?"complete":"partial",updatedAt:new Date().toISOString(),fingerprint:e.fingerprint,requestedLanguages:e.languages,indexedLanguages:t.map(i=>i.language),skipped:[...r]}),vr({tempOutputScip:e.tempPaths.tempOutputScip,tempOutputDb:e.tempPaths.tempOutputDb,tempMetaPath:e.tempPaths.tempMetaPath,outputScip:e.paths.outputScip,outputDb:e.paths.outputDb,metaPath:e.paths.metaPath})}function dr(e,n){if(!f("scip")){if(e)throw new Error(`The scip CLI is required but not found on PATH.
61
+ Install from: https://github.com/sourcegraph/scip/releases`);if(n("scip CLI not found on PATH. Attempting auto-install..."),!L(n))throw new Error(`The scip CLI is required but could not be installed.
62
+ Install manually from: https://github.com/sourcegraph/scip/releases`)}}function mr(e){let n=[],t=[],r=e.languages.map((i,o)=>({language:i,scipPath:e.languages.length>1?Sr(e.tempOutputScip,i,o):e.tempOutputScip}));for(let{language:i,scipPath:o}of r){let s=fr({...e,language:i,scipPath:o});"skipped"in s?t.push(s.skipped):n.push(s.prepared)}return{preparedRuns:n,skippedLanguages:t}}function fr(e){let n=D(e.language),t=I(n),r=$(n,e.projectRoot);if(!r&&!_(n)){if(e.skipAutoInstall){let a=`${t} not found on PATH (auto-install disabled). ${n.installUrl??""}`.trim();return e.onStatus(`Skipping ${e.language}: ${a}`),{skipped:{language:e.language,reason:a}}}if(e.onStatus(`${t} not found. Attempting auto-install...`),!U(n,e.onStatus)){let a=`${t} could not be auto-installed. ${n.installUrl?`Install manually from ${n.installUrl}`:`Install ${t} and put it on PATH.`}`;return e.onStatus(`Skipping ${e.language}: ${a}`),{skipped:{language:e.language,reason:a}}}}let i=r??x(n);if(!i){let a=`${t} was not found after installation checks.`;return e.onStatus(`Skipping ${e.language}: ${a}`),{skipped:{language:e.language,reason:a}}}let{binary:o,args:s}=n.indexArgs({projectRoot:e.projectRoot,outputPath:e.scipPath,pnpmWorkspaces:e.pnpmWorkspaces,indexerBinary:i});return{prepared:{language:e.language,scipPath:e.scipPath,config:n,resolvedBinary:i,binary:o,args:s,env:B(n,e.env,i)}}}function hr(e,n){let t=[];for(let r of e)r.skipped?n.push(r.skipped):t.push({language:r.language,scipPath:r.scipPath});return{indexedOutputs:t}}function br(e,n,t,r,i){if(e.length===0){let o=n.map(s=>` - ${s.language}: ${s.reason}`).join(`
63
63
  `);throw new Error(`No language indexers ran successfully. Install at least one indexer for the languages in this project.
64
64
  `+o)}if(n.length!==0&&(i(`Indexed ${e.length} of ${t.length} languages; skipped ${n.map(o=>o.language).join(", ")}.`),!r))throw new Error(`Failed to index all required languages; preserving the previous index. Pass --allow-partial to intentionally write an incomplete index.
65
65
  `+n.map(o=>` - ${o.language}: ${o.reason}`).join(`
66
- `))}function br(e,n,t){e.length>1?(t(`Merging ${e.length} language indexes...`),F(e.map(r=>r.scipPath),n)):e[0].scipPath!==n&&K(e[0].scipPath,n)}function yr(e,n,t,r){if(r("Converting to SQLite..."),!q(e))throw new Error(`SCIP index not found at ${e} after indexing`);try{let i=de(e);i.removedDefinitionOccurrences>0&&r(`Sanitized ${i.removedDefinitionOccurrences} invalid definition occurrences across ${i.touchedDocuments} documents before SQLite conversion.`),er("scip",["expt-convert","--output",n,e],{env:t,stdio:"pipe",maxBuffer:50*1024*1024})}catch(i){let o=i instanceof Error?i.message:String(i);throw new Error(`Failed to convert SCIP index to SQLite: ${o}`,{cause:i})}}function xr(e,n,t){let r=or(e)||".scip",i=C(e,r);return f(b(e),`${i}.${t+1}.${n}${r}`)}function Sr(e){let n;try{n=rr(e,"wx")}catch(t){throw(typeof t=="object"&&t&&"code"in t?t.code:void 0)==="EEXIST"?new Error(`Another scip-query reindex is already running for ${b(e)}.`,{cause:t}):t}return Be(n,JSON.stringify({pid:process.pid,startedAt:new Date().toISOString()})+`
67
- `),()=>{try{nr(n)}finally{X(e,{force:!0})}}}function vr(e){G(e.tempOutputScip,e.outputScip),G(e.tempOutputDb,e.outputDb),G(e.tempMetaPath,e.metaPath)}function G(e,n){X(`${n}.tmp-replace`,{force:!0}),K(e,`${n}.tmp-replace`),K(`${n}.tmp-replace`,n)}function Rr(e,n,t){return{version:1,languages:[...n].sort(),pnpmWorkspaces:t.pnpmWorkspaces===!0,files:v(e)}}function kr(e,n){try{let t=JSON.parse(ir(e,"utf-8"));return t.version===2&&t.status==="complete"&&P(t.fingerprint)===P(n)&&P([...t.indexedLanguages??[]].sort())===P(n.languages)}catch{return!1}}function Ir(e,n){Be(e,`${JSON.stringify(n,null,2)}
68
- `)}function P(e){return JSON.stringify(e)}export{ae as INDEXER_CONFIGS,y as augmentAuxiliaryDocuments,Bt as augmentVueResolvedReferences,I as describeIndexerBinary,L as detectLanguages,D as getIndexerConfig,B as getIndexerExecutionEnv,m as isBinaryAvailable,_ as isIndexerInstalled,F as mergeScipFiles,ue as mergeScipIndexes,Bi as reindex,x as resolveIndexerBinary,$ as resolveProjectLocalIndexerBinary,U as tryInstallIndexer,w as tryInstallScipCli};
66
+ `))}function yr(e,n,t){e.length>1?(t(`Merging ${e.length} language indexes...`),T(e.map(r=>r.scipPath),n)):e[0].scipPath!==n&&K(e[0].scipPath,n)}function xr(e,n,t,r){if(r("Converting to SQLite..."),!q(e))throw new Error(`SCIP index not found at ${e} after indexing`);try{let i=de(e);i.removedDefinitionOccurrences>0&&r(`Sanitized ${i.removedDefinitionOccurrences} invalid definition occurrences across ${i.touchedDocuments} documents before SQLite conversion.`),nr("scip",["expt-convert","--output",n,e],{env:t,stdio:"pipe",maxBuffer:50*1024*1024})}catch(i){let o=i instanceof Error?i.message:String(i);throw new Error(`Failed to convert SCIP index to SQLite: ${o}`,{cause:i})}}function Sr(e,n,t){let r=sr(e)||".scip",i=C(e,r);return m(b(e),`${i}.${t+1}.${n}${r}`)}function Rr(e){let n;try{n=ir(e,"wx")}catch(t){throw(typeof t=="object"&&t&&"code"in t?t.code:void 0)==="EEXIST"?new Error(`Another scip-query reindex is already running for ${b(e)}.`,{cause:t}):t}return Be(n,JSON.stringify({pid:process.pid,startedAt:new Date().toISOString()})+`
67
+ `),()=>{try{tr(n)}finally{X(e,{force:!0})}}}function vr(e){G(e.tempOutputScip,e.outputScip),G(e.tempOutputDb,e.outputDb),G(e.tempMetaPath,e.metaPath)}function G(e,n){X(`${n}.tmp-replace`,{force:!0}),K(e,`${n}.tmp-replace`),K(`${n}.tmp-replace`,n)}function kr(e,n,t){return{version:1,languages:[...n].sort(),pnpmWorkspaces:t.pnpmWorkspaces===!0,files:R(e)}}function Ir(e,n){try{let t=JSON.parse(or(e,"utf-8"));return t.version===2&&t.status==="complete"&&P(t.fingerprint)===P(n)&&P([...t.indexedLanguages??[]].sort())===P(n.languages)}catch{return!1}}function Pr(e,n){Be(e,`${JSON.stringify(n,null,2)}
68
+ `)}function P(e){return JSON.stringify(e)}export{ae as INDEXER_CONFIGS,y as augmentAuxiliaryDocuments,Bt as augmentVueResolvedReferences,I as describeIndexerBinary,w as detectLanguages,D as getIndexerConfig,B as getIndexerExecutionEnv,f as isBinaryAvailable,_ as isIndexerInstalled,T as mergeScipFiles,ue as mergeScipIndexes,Ui as reindex,x as resolveIndexerBinary,$ as resolveProjectLocalIndexerBinary,U as tryInstallIndexer,L as tryInstallScipCli};
69
69
  //# sourceMappingURL=reindex.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scip-query",
3
- "version": "0.7.0",
3
+ "version": "0.7.2",
4
4
  "description": "Language-agnostic code intelligence CLI powered by SCIP indexes",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -216,6 +216,7 @@
216
216
  "typecheck": "tsc --noEmit",
217
217
  "lint": "eslint src tests tsup.config.ts",
218
218
  "calibrate": "node scripts/accuracy-calibration.mjs",
219
+ "docs:commands": "vite-node scripts/render-command-reference.ts",
219
220
  "prepublishOnly": "npm run build",
220
221
  "postinstall": "node dist/postinstall.js || true"
221
222
  },
@@ -1,62 +0,0 @@
1
- import{a as h,k as S}from"./chunk-5TT47UMX.js";import{a as y}from"./chunk-NHDPYW7O.js";import{a as x}from"./chunk-NN3O7TPH.js";var F={"/":"namespace","#":"type",".":"term","[":"type-param",":":"meta","!":"macro"};function u(e){if(e.startsWith("local "))return{kind:"local",id:e.slice(6),raw:e};let t=e.split(" ");if(t.length<4)return{scheme:t[0]??"",manager:t[1]??"",packageName:t[2]??"",version:"",descriptors:[],raw:e};let n=t[0],r=t[1],i=e.slice(n.length+1+r.length+1),s;if(i.startsWith("`")){let l=i.indexOf("`",1);l===-1?(s=i.slice(1),i=""):(s=i.slice(1,l),i=i.slice(l+2))}else{let l=i.indexOf(" ");l===-1?(s=i,i=""):(s=i.slice(0,l),i=i.slice(l+1))}let o,a=i.indexOf(" ");a===-1?(o=i,i=""):(o=i.slice(0,a),i=i.slice(a+1));let c=C(i);return{scheme:n,manager:r,packageName:s,version:o,descriptors:c,raw:e}}function m(e){let t=u(e);if("kind"in t)return null;for(let n=t.descriptors.length-2;n>=0;n--){let r=t.descriptors[n];if(r?.suffix==="type")return r.name}return null}function C(e){let t=[],n=0;for(;n<e.length;){if(e[n]==="["){let s=e.indexOf("]",n+1);if(s===-1){t.push({name:e.slice(n+1),suffix:"type-param"});break}t.push({name:e.slice(n+1,s),suffix:"type-param"}),n=s+1;continue}if(e[n]==="("&&(t.length===0||n===0||D(e[n-1]))){let s=e.indexOf(")",n+1);if(s!==-1&&e[s+1]!=="."){t.push({name:e.slice(n+1,s),suffix:"parameter"}),n=s+1;continue}}let r;if(e[n]==="`"){let s=e.indexOf("`",n+1);if(s===-1){r=e.slice(n+1),t.push({name:r,suffix:"term"});break}r=e.slice(n+1,s),n=s+1}else{let s=n;for(;n<e.length&&!D(e[n]);)n++;r=e.slice(s,n)}if(n>=e.length){r&&t.push({name:r,suffix:"term"});break}let i=e[n];if(i==="("){let s=e.indexOf(")",n+1);s!==-1&&e[s+1]==="."?(t.push({name:r,suffix:"method"}),n=s+2):s!==-1?(t.push({name:r,suffix:"method"}),n=s+1):(t.push({name:r,suffix:"term"}),n++)}else{let s=F[i];s&&t.push({name:r,suffix:s}),n+=1}}return t}function D(e){return e==="/"||e==="#"||e==="."||e==="("||e==="["||e===":"||e==="!"}function _(e){let t=u(e);if("kind"in t&&t.kind==="local")return`local:${t.id}`;let n=t;if(n.descriptors.length===0)return n.raw;let r=[];for(let i of n.descriptors){let s=w(i);s&&r.push(s)}return r.join(":")}function w(e){let t=e.suffix==="namespace"?A(e.name):e.name;return t?e.suffix==="method"?`${t}()`:t:""}function A(e){return e.replace(/\.(ts|tsx|js|jsx|mjs|cjs)$/,"").replace(/\.(py|pyi)$/,"").replace(/\.(rs)$/,"").replace(/\.(java|scala|kt|kts)$/,"").replace(/\.(rb)$/,"").replace(/\.(go)$/,"").replace(/\.(cs|vb)$/,"").replace(/\.(dart)$/,"").replace(/\.(php)$/,"").replace(/\.(c|cc|cpp|cxx|h|hpp)$/,"")}function L(e){let t=u(e);if("kind"in t&&t.kind==="local")return t.id;let n=t;return n.descriptors.length===0?"":n.descriptors[n.descriptors.length-1].name}function f(e){let t=u(e);if("kind"in t&&t.kind==="local")return null;let n=t;return n.descriptors[n.descriptors.length-1]?.suffix??null}function ne(e){return e.endsWith("().")||f(e)==="method"}function I(e){let t=f(e);return t==="method"||t==="term"}function te(e){return f(e)==="namespace"}var T=/^rust-analyzer\b.*[\s/]impl#\[[^\]]+\]\[[^\]]+\]/;function ie(e){return T.test(e)}var Q=new Set(["test","tests","_tests"]);function re(e){let t=u(e);if("kind"in t)return!1;for(let n=0;n<t.descriptors.length-1;n+=1){let r=t.descriptors[n];if(r?.suffix==="namespace"&&r.name&&Q.has(r.name))return!0}return!1}function se(e,t){let n=u(e),r=u(t);if("kind"in n||"kind"in r)return!1;let i=n.descriptors,s=r.descriptors;if(s.length!==i.length+1)return!1;for(let o=0;o<i.length;o++){let a=i[o],c=s[o];if(a.name!==c.name||a.suffix!==c.suffix)return!1}return!0}function oe(e,t){let n=u(e),r=u(t);if("kind"in n||"kind"in r)return!1;let i=n.descriptors,s=r.descriptors;if(s.length<=i.length)return!1;for(let o=0;o<i.length;o++){let a=i[o],c=s[o];if(a.name!==c.name||a.suffix!==c.suffix)return!1}return!0}function le(e,t){return e.all(`SELECT gs.id, gs.symbol, der.document_id, der.start_line, der.end_line, d.relative_path, gs.display_name, gs.documentation
2
- FROM global_symbols gs
3
- JOIN defn_enclosing_ranges der ON gs.id = der.symbol_id
4
- JOIN documents d ON der.document_id = d.id
5
- WHERE ${t.where}
6
- ${e.pathExclusionsFor("d")}
7
- ${M(t.orderBy)}
8
- ${k(t.limit)}`,...t.params??[])}function ce(e,t){return e.all(`SELECT
9
- gs.id,
10
- gs.symbol,
11
- c.document_id,
12
- MIN(c.start_line) AS start_line,
13
- MAX(c.end_line) AS end_line,
14
- d.relative_path,
15
- gs.display_name,
16
- gs.documentation
17
- FROM global_symbols gs
18
- JOIN mentions m ON m.symbol_id = gs.id
19
- JOIN chunks c ON m.chunk_id = c.id
20
- JOIN documents d ON c.document_id = d.id
21
- WHERE m.role = 1
22
- AND ${t.where}
23
- ${e.pathExclusionsFor("d")}
24
- GROUP BY gs.id, gs.symbol, c.document_id, d.relative_path, gs.display_name, gs.documentation
25
- ${M(t.orderBy)}
26
- ${k(t.limit)}`,...t.params??[])}function M(e){return e?`ORDER BY ${e}`:""}function k(e){return typeof e=="number"?`LIMIT ${e}`:""}function N(e){return!e||!e.trim()?null:e.replace(/^```\w*\s*/,"").replace(/\s*```$/,"").replace(/^\(method\)\s*/,"").replace(/^\(property\)\s*/,"").replace(/^\(function\)\s*/,"").replace(/^\(class\)\s*/,"").replace(/^\(interface\)\s*/,"").replace(/^\(enum\)\s*/,"").replace(/^\(type alias\)\s*/,"").replace(/^\(const\)\s*/,"").replace(/^\(var\)\s*/,"").trim()||null}function O(e){if(!e)return null;let t=R(e);if(t)return t.replace(/\n/g," ");let n=e.indexOf("|");if(n===-1)return e.replace(/\n/g," ");let r=e.slice(n+1);return(R(r)??r).replace(/\n/g," ")}function R(e){return/^```(?:\w+)?\s*\n?([\s\S]*?)\n?```/.exec(e.trimStart())?.[1]?.trim()||null}function P(e){if(m(e.symbol)!==null)return!1;let n=(e.documentation??"").replace(/^```\w*\s*/,"").replace(/\s*```$/,"").trim();return/^(?:var|let|const|function|class|interface|type|enum)\b/.test(n)}function $(e,t,n={}){let r=new Map;for(let s of t)e.length>0&&!P(s)||r.set(s.id,s);for(let s of e)r.set(s.id,s);let i=[...r.values()];return n.sort?i.sort((s,o)=>s.start_line-o.start_line||s.end_line-o.end_line||s.symbol.localeCompare(o.symbol)):i}var E=y("file-definitions");function Se(e,t){E.invalidate(e,t)}function b(e,t){return E.get(e,t,()=>{let n=$(B(e,t),j(e,t),{sort:!0});return H(e,t,n.map(J))})}function B(e,t){return e.all(`SELECT
27
- gs.id,
28
- gs.symbol,
29
- der.document_id,
30
- der.start_line,
31
- der.end_line,
32
- d.relative_path,
33
- gs.display_name,
34
- gs.kind,
35
- gs.documentation,
36
- gs.enclosing_symbol
37
- FROM global_symbols gs
38
- JOIN defn_enclosing_ranges der ON gs.id = der.symbol_id
39
- JOIN documents d ON der.document_id = d.id
40
- WHERE d.relative_path = ?
41
- ${e.symbolNoiseFor("gs")}
42
- ORDER BY der.start_line, der.end_line`,t)}function j(e,t){return e.all(`SELECT
43
- gs.id,
44
- gs.symbol,
45
- c.document_id,
46
- MIN(c.start_line) AS start_line,
47
- MAX(c.end_line) AS end_line,
48
- d.relative_path,
49
- gs.display_name,
50
- gs.kind,
51
- gs.documentation,
52
- gs.enclosing_symbol
53
- FROM global_symbols gs
54
- JOIN mentions m ON m.symbol_id = gs.id
55
- JOIN chunks c ON m.chunk_id = c.id
56
- JOIN documents d ON c.document_id = d.id
57
- WHERE d.relative_path = ?
58
- AND m.role = 1
59
- ${e.symbolNoiseFor("gs")}
60
- GROUP BY gs.id, gs.symbol, c.document_id, d.relative_path
61
- ORDER BY start_line, end_line`,t)}function J(e){return{symbolId:e.id,symbol:e.symbol,documentId:e.document_id,startLine:e.start_line,endLine:e.end_line,relativePath:e.relative_path,leaf:L(e.symbol),parentTypeName:m(e.symbol),isFunctionLike:I(e.symbol),isTypeLike:f(e.symbol)==="type",kind:e.kind??null,documentation:e.documentation??null,enclosingSymbol:e.enclosing_symbol??null}}function De(e,t={}){return W(e,t.scope)}function W(e,t){return x(e,{scope:t,includeIgnored:!1}).flatMap(n=>b(e,n)).filter(n=>!e.isIgnored(n.relativePath))}function _e(e,t,n={}){if(t.length===0)return[];let r=t.flatMap(i=>b(e,i)).filter(i=>!e.isIgnored(i.relativePath));return n.onlyDocumented&&(r=r.filter(i=>i.documentation!==null&&i.documentation!=="")),n.sort&&(r=r.sort((i,s)=>i.relativePath.localeCompare(s.relativePath)||i.startLine-s.startLine||i.endLine-s.endLine)),r.map(i=>({startLine:i.startLine,endLine:i.endLine,symbol:i.symbol,shortName:_(i.symbol),signature:N(O(i.documentation)),relativePath:i.relativePath,enclosingSymbol:i.enclosingSymbol}))}function Le(e,t){let n=null;for(let r of e)r.startLine>t||r.endLine<t||(!n||r.endLine-r.startLine<n.endLine-n.startLine)&&(n=r);return n}function Ie(e,t){let n=b(e,t.relative_path).find(r=>r.symbolId===t.id);return n?{symbolId:n.symbolId,symbol:n.symbol,documentId:n.documentId,startLine:n.startLine,endLine:n.endLine,relativePath:n.relativePath}:{symbolId:t.id,symbol:t.symbol,documentId:t.document_id,startLine:t.start_line,endLine:t.end_line,relativePath:t.relative_path}}function H(e,t,n){let r=h(e,t),i=S(e,t);return i?G(n,i,r):r?z(n,r):n}function z(e,t){let n=t.split(/\r?\n/),r=Y(e,n),i=U(e,r),s=Z(i,n);return X(e,s)}function Y(e,t){let n=e.some(i=>g(i.symbol))?V(t):null,r=new Map;for(let i of e)r.set(i.symbolId,K(t,n,i));return r}function U(e,t){return e.filter(n=>g(n.symbol)).map(n=>({definition:n,startLine:t.get(n.symbolId)??n.startLine})).sort((n,r)=>n.startLine-r.startLine||n.definition.startLine-r.definition.startLine||n.definition.symbol.localeCompare(r.definition.symbol))}function Z(e,t){let n=new Map;for(let r=0;r<e.length;r+=1){let i=e[r],s=e[r+1],o=s?Math.max(i.startLine,s.startLine-1):t.length-1;n.set(i.definition.symbolId,{startLine:i.startLine,endLine:q(t,i.definition,i.startLine,o)})}return n}function X(e,t){return e.map(n=>{let r=t.get(n.symbolId);return r?{...n,startLine:r.startLine,endLine:r.endLine}:n})}function G(e,t,n=null){let r=new Map;for(let i of t){let s=r.get(i.name);s?s.push(i):r.set(i.name,[i])}return e.map(i=>{if(!g(i.symbol)||!i.leaf)return v(i,n);let s=r.get(i.leaf);if(!s||s.length===0)return v(i,n);let o=s[0],a=Math.abs(o.startLine-i.startLine);for(let c=1;c<s.length;c+=1){let l=s[c],d=Math.abs(l.startLine-i.startLine);d<a&&(o=l,a=d)}return{...i,startLine:o.startLine,endLine:o.endLine}})}function v(e,t){if(!t||!e.leaf||f(e.symbol)!=="term"||m(e.symbol)!==null)return e;let n=e.leaf.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),r=new RegExp(`\\b(?:export\\s+)?(?:const|let|var)\\s+${n}\\b`),s=t.split(/\r?\n/).findIndex(o=>r.test(o));return s>=0?{...e,startLine:s,endLine:s}:e}function K(e,t,n){if(!g(n.symbol))return n.startLine;let r=Math.max(0,Math.min(n.startLine,e.length-1));if(!t)return r;let i=t.get(n.leaf);if(!i||i.length===0)return r;let s=null;for(let o of i){let a=Math.abs(o-n.startLine);(!s||a<s.distance)&&(s={line:o,distance:a})}return s?.line??r}function V(e){let t=/\b(?:function|def|fn)\s+([A-Za-z_$][\w$]*)/g,n=/\b([A-Za-z_$][\w$]*)\s*[:=]\s*(?:async\s*)?(?:function\b|\()/g,r=/^\s*(?:(?:export|public|private|protected|static|readonly|async|abstract|get|set)\s+)*([A-Za-z_$][\w$]*)\s*(?:<[^(]*>)?\s*\(/,i=/\b([A-Za-z_$][\w$]*)\s*\(/g,s=new Map,o=(a,c)=>{let l=s.get(a);if(!l){s.set(a,[c]);return}l[l.length-1]!==c&&l.push(c)};for(let a=0;a<e.length;a+=1){let c=e[a]??"";for(let d of c.matchAll(t))d[1]&&o(d[1],a);for(let d of c.matchAll(n))d[1]&&o(d[1],a);let l=c.match(r);l?.[1]&&o(l[1],a);for(let d of c.matchAll(i))d[1]&&o(d[1],a)}return s}function q(e,t,n,r){let i=Math.max(n,Math.min(e.length-1,r)),s=Math.max(n,Math.min(i,t.endLine)),o=0,a=0,c=!1;for(let l=n;l<=i;l+=1){let d=ee(e[l]??"");for(let p of d)p==="{"?(o+=1,c=!0):p==="}"?o=Math.max(0,o-1):p==="("?a+=1:p===")"&&(a=Math.max(0,a-1));if(c&&o===0||!c&&a===0&&l>=s)return l}return s}function ee(e){let t="",n=null,r=!1;for(let i=0;i<e.length;i+=1){let s=e[i],o=e[i+1];if(!n&&s==="/"&&o==="/"){t+=" ".repeat(e.length-i);break}if(n){if(r){r=!1,t+=" ";continue}if(s==="\\"){r=!0,t+=" ";continue}s===n&&(n=null),t+=" ";continue}if(s==='"'||s==="'"||s==="`"){n=s,t+=" ";continue}t+=s}return t}function g(e){return e.includes("().")}function Re(e){let t=u(e);if("kind"in t)return[];let n=[];for(let r=t.descriptors.length-2;r>=0;r-=1){let i=t.descriptors[r];i?.suffix==="type"&&i.name&&n.push(i.name)}return n}export{u as a,m as b,_ as c,L as d,f as e,ne as f,I as g,te as h,ie as i,re as j,se as k,oe as l,le as m,ce as n,N as o,O as p,$ as q,Se as r,b as s,De as t,W as u,_e as v,Le as w,Ie as x,Re as y};
62
- //# sourceMappingURL=chunk-7OX2O53H.js.map
@@ -1,2 +0,0 @@
1
- import{b as r}from"./chunk-DFK54IRN.js";import{v as e}from"./chunk-7OX2O53H.js";function l(t,s){let o=r(t,s);return e(t,o).map(({relativePath:n,...a})=>a)}export{l as a};
2
- //# sourceMappingURL=chunk-CKIO6SVS.js.map
@@ -1,2 +0,0 @@
1
- import{c as ae}from"./chunk-MX6F756F.js";import{a as K,b as C}from"./chunk-QAEDNTY7.js";import{d as A,e as j,f as O,g as B,h as H}from"./chunk-NKJKI6SE.js";import{b as N}from"./chunk-IODTPF5H.js";import{b as re,d as te}from"./chunk-ARBZM2NF.js";import{c as Y,d as Q,e as X,f as Z,h as v,l as ee,m as ne}from"./chunk-JB4PUN5S.js";import{a as R}from"./chunk-7O4MJYIW.js";import{b as T,d as w,e as M}from"./chunk-RCJEFQOK.js";import{v as L,w as _}from"./chunk-BOVNTAKQ.js";import{c as U,f as G,g as W,h as $,i as V,j as q,r as z,s as J,y as h}from"./chunk-7OX2O53H.js";import{b as I,c as F,h as k,i as E}from"./chunk-5TT47UMX.js";import{a as y}from"./chunk-NN3O7TPH.js";function ie(e){let n=new Map,r=t=>{let a=n.get(t);if(a)return a;let s=K(e,t);return a={ranges:s.map(i=>({startLine:i.startLine,endLine:i.endLine})),containers:new Set(s.map(i=>i.containerName).filter(i=>!!i))},n.set(t,a),a};return(t,a,s,i)=>{let l=r(t);for(let c of l.ranges)if(a>=c.startLine&&a<=c.endLine)return!0;if(i&&l.containers.has(i))return!0;for(let c of h(s))if(l.containers.has(c))return!0;return!1}}function oe(e){N(e),te(e),ee(e)}var Re=[{kind:"symbol-evidence",clearDatabase:oe},{kind:"semantic-provider",clearDatabase:R},{kind:"identifier-index",clearDatabase:Y,clearFile:Q},{kind:"language-parser",clearDatabase:w,clearFile:M},{kind:"source-stripper",clearDatabase:L,clearFile:_},{kind:"ast-tree",clearDatabase:k,clearFile:E},{kind:"source-text",clearDatabase:I,clearFile:F},{kind:"definition-catalog",clearFile:z}],se=["symbol-evidence","identifier-index","language-parser","source-stripper","ast-tree","source-text"],ce=["identifier-index","language-parser","source-stripper","ast-tree","source-text"];function le(e,n){let r=new Set(n.kinds);for(let t of Re)r.has(t.kind)&&(n.scope.kind==="database"?t.clearDatabase?.(e):t.clearFile?.(e,Ce(n.scope.relativePath)))}function en(e,n={}){le(e,{scope:{kind:"database"},kinds:n.semanticProvider===!0?[...se,"semantic-provider"]:se})}function D(e,n,r={}){le(e,{scope:{kind:"file",relativePath:n},kinds:r.definitions===!0?[...ce,"definition-catalog"]:ce})}function Ce(e){return e.replace(/\\/g,"/")}function de(e,n){return n.isIgnoredPath(e.relativePath)?m("ignored-file"):$(e.symbol)?m("module-like-symbol"):ue(e.symbol)?!e.isFunctionLike&&e.enclosingSymbol&&ue(e.enclosingSymbol)?m("nested-non-callable-value"):!n.includeTests&&!x(e.relativePath)?m("test-file"):!n.includeTests&&n.isExcludedRegion(e.relativePath,e.startLine,e.symbol,e.parentTypeName)?m("excluded-file-region"):V(e.symbol)?m("rust-trait-impl-member"):q(e.symbol)?m("rust-test-module"):!n.includeMembers&&!xe(e)?m("member"):e.endLine-e.startLine+1<n.minLoc?m("below-min-loc"):{accepted:!0}:m("non-value-symbol")}function x(e){return[...new Set([...B,...H])].every(r=>!De(e,r))}function m(e){return{accepted:!1,rejectionReason:e}}function De(e,n){return new RegExp(`^${n.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/%/g,".*").replace(/_/g,".")}$`).test(e)}function ue(e){return W(e)||e.endsWith("().")||e.endsWith(".")}function xe(e){return G(e.symbol)||h(e.symbol).length===0}function me(){return new Map}function fe(e,n,r){let t=new Map;for(let a of X(e,r))e.isIgnored(a.relative_path)||n.has(a.relative_path)||S(t,a.symbol_id,a.relative_path,a.ref_count,"scip-mention");return t}function pe(e,n,r){let t=new Set;for(let a of Z(e,n))e.isIgnored(a.relative_path)||r.has(a.relative_path)||t.add(a.symbol_id);return t}function P(e,n){let r=e.get(n);if(!r)return!1;for(let t of r.values())if(t.occurrences>0)return!0;return!1}function ge(e){return e?.occurrences??0}function S(e,n,r,t,a="source-fallback"){if(t<=0)return;let s=ye(e,n,r);s.occurrences+=t,s.sources.add(a)}function be(e,n,r,t,a){if(t<=0)return;let s=ye(e,n,r);s.occurrences=Math.max(t,s.occurrences),s.sources.add(a)}function ye(e,n,r){let t=e.get(n);t||(t=new Map,e.set(n,t));let a=t.get(r);return a||(a={occurrences:0,sources:new Set},t.set(r,a)),a}function Dn(e,n={}){let{scope:r,minLoc:t=1,includeTests:a=!1,skipBarrels:s=!1,includeMembers:i=!1,deadCodeOnly:l=!1,scanLimit:c,semantic:d=!0}=n,o=ae(Pe(e,{scope:r,minLoc:t,includeTests:a,includeMembers:i}),c),u=s?new Set(A(e)):new Set,p=l?me():fe(e,u,o.map(f=>f.symbolId)),g=l?pe(e,o.map(f=>f.symbolId),u):new Set,b=l?o.filter(f=>!g.has(f.symbolId)):o;l?ke(e,b,p,u):_e(e,b,p,u);let Se=l?b.filter(f=>!P(p,f.symbolId)):o;Ne(e,Se,p,{includeTests:a,inactiveBarrelPaths:u,includeSemantic:!l&&d});let ve=l?b.filter(f=>!P(p,f.symbolId)):o;return Le(e,Ie(ve,p))}function Pe(e,n){let r=ie(e),t=[];for(let a of y(e,{scope:n.scope}))try{for(let s of J(e,a))de(s,{minLoc:n.minLoc,includeTests:n.includeTests,includeMembers:n.includeMembers,isIgnoredPath:l=>e.isIgnored(l),isExcludedRegion:r}).accepted&&t.push(s)}finally{D(e,a,{definitions:!0})}return t}function Ie(e,n){return e.map(r=>Fe(r,n)).filter(r=>r.cross_file_refs===0).sort((r,t)=>t.loc-r.loc||r.relative_path.localeCompare(t.relative_path)||r.start_line-t.start_line)}function Fe(e,n){let r=n.get(e.symbolId)??new Map,t=ge(r.get(e.relativePath)),a=0;for(let[s,i]of r)s!==e.relativePath&&(a+=i.occurrences);return{relative_path:e.relativePath,start_line:e.startLine,end_line:e.endLine,loc:e.endLine-e.startLine+1,symbol:e.symbol,same_file_refs:t,cross_file_refs:a}}function Le(e,n){let r=[],t=0,a=0,s=0;for(let i of n){if(e.isIgnored(i.relative_path)||j(e,i.relative_path)||O(e,i.symbol,i.relative_path))continue;let l=i.same_file_refs===0?"dead-code":"file-internal";l==="dead-code"?t++:a++,s+=i.loc,r.push({relativePath:i.relative_path,startLine:i.start_line,endLine:i.end_line,loc:i.loc,symbol:i.symbol,shortName:U(i.symbol),sameFileRefs:i.same_file_refs,kind:l})}return{symbols:r,totalCount:r.length,deadCodeCount:t,fileInternalCount:a,totalLoc:s}}function _e(e,n,r,t){if(n.length===0)return;let a=new C(e),s=new Set(n.map(c=>c.symbolId)),i=new Set(n.map(c=>c.leaf).filter(Boolean)),l=new Set(a.sourceFiles());for(let c of y(e))l.add(c);a.scanSourceReferences({paths:l,includeVueSfc:!0,includeCrossLanguageDispatchNames:!0,includeRustAttributeNames:!0,identifierResolution:"permissive",candidateNames:i,skipPath:c=>t.has(c)},c=>{s.has(c.target.symbolId)&&(we(e,c)||S(r,c.target.symbolId,c.sourceFile,Me(c),"source-fallback"))})}function ke(e,n,r,t){if(n.length===0)return;let a=new C(e),s=Ee(n),i=new Set(a.sourceFiles());for(let o of y(e))i.add(o);let l=new Set(s.keys()),c=new Map,d=o=>{let u=c.get(o);return u||(u=ne(e,o),c.set(o,u)),u};a.scanSourceReferences({paths:i,includeVueSfc:!0,includeCrossLanguageDispatchNames:!0,includeRustAttributeNames:!0,identifierResolution:"permissive",candidateNames:l,skipPath:o=>t.has(o),resolveTargets:({sourceFile:o,name:u,kind:p})=>{let g=s.get(u);return g?Te(o,u,g,d(o),{permissive:p!=="cross-language-dispatch"}):[]},afterPath:o=>{c.delete(o),D(e,o)}},o=>{let u=o.kind==="identifier"&&o.sourceFile===o.target.relativePath?Math.max(0,o.occurrences-1):o.occurrences;o.kind==="identifier"&&he(e,{sourceFile:o.sourceFile,name:o.name,target:o.target,occurrences:u})||S(r,o.target.symbolId,o.sourceFile,u,"source-fallback")})}function Ee(e){let n=new Map;for(let r of e){if(!r.leaf)continue;let t=n.get(r.leaf)??[];t.push(r),n.set(r.leaf,t)}return n}function Te(e,n,r,t,a){let s=r.filter(c=>c.relativePath===e);if(s.length>0)return s;let i=t.get(n);if(i)for(let c of i){let d=r.filter(o=>v(c,o.relativePath));if(d.length>0)return d}let l=new Set;for(let c of t.values())for(let d of c)l.add(d);for(let c of l){let d=r.filter(o=>v(c,o.relativePath));if(d.length>0&&d.length===r.length)return d}return a.permissive?[...r]:[]}function we(e,n){return n.kind==="cross-language-dispatch"&&n.target.relativePath===n.sourceFile?!0:n.kind==="identifier"&&he(e,n)}function Me(e){return e.kind==="identifier"&&e.target.relativePath===e.sourceFile?Math.max(0,e.occurrences-1):e.occurrences}function he(e,n){return n.occurrences>1?!1:T(e,n.sourceFile).some(r=>r.used||r.sourcePath!==n.target.relativePath?!1:r.importedName===n.name||r.localName===n.name)}function Ne(e,n,r,t){for(let a of n){let s=re(e,a,{semantic:t.includeSemantic!==!1});if(s.length!==0)for(let i of s){let l=i.file;l===a.relativePath||e.isIgnored(l)||t.inactiveBarrelPaths.has(l)||!t.includeTests&&!x(l)||be(r,a.symbolId,l,1,"caller-map")}}}export{en as a,Dn as b};
2
- //# sourceMappingURL=chunk-D6Z67MZL.js.map
@@ -1,2 +0,0 @@
1
- import{d as m}from"./chunk-MX6F756F.js";import{a as g,b}from"./chunk-ARBZM2NF.js";import{r as y}from"./chunk-JB4PUN5S.js";import{a as c}from"./chunk-ZNUPGRPR.js";import{c as t}from"./chunk-7OX2O53H.js";function R(l,n,r={}){let o=c(l,n);if(!o)return null;let a=[{file:o.relativePath,line:o.startLine}],i=y(l,o,{semantic:r.semantic}).map(e=>({file:e.file,line:e.line,enclosingSymbol:e.enclosingSymbol??"(top-level)",enclosingShort:e.enclosingSymbol?t(e.enclosingSymbol):"(top-level)"})),{producers:f,consumers:s}=S(l,o,i,{semantic:r.semantic!==!1});return{symbol:o.symbol,shortName:t(o.symbol),relativePath:o.relativePath,definitionSites:a.filter(e=>!l.isIgnored(e.file)),usageSites:i,producers:f.filter(e=>!l.isIgnored(e.file)).map(e=>({symbol:e.symbol,shortName:t(e.symbol),file:e.file})),consumers:s.filter(e=>!l.isIgnored(e.file)).map(e=>({symbol:e.symbol,shortName:e.symbol===e.file?"(top-level)":t(e.symbol),file:e.file}))}}function S(l,n,r,o){let a=m(g(l,n,{limit:30,semantic:o.semantic}).map(s=>({symbol:s.symbol,file:s.file}))),i=m(b(l,n,{limit:30,semantic:o.semantic})),f=i.length>0?i:m(r.map(s=>({symbol:s.enclosingSymbol==="(top-level)"?s.file:s.enclosingSymbol,file:s.file})));return{producers:a,consumers:f}}export{R as a};
2
- //# sourceMappingURL=chunk-FOQQDXE7.js.map
@@ -1,2 +0,0 @@
1
- import{a as C,e as P}from"./chunk-NKJKI6SE.js";import{a as v}from"./chunk-IODTPF5H.js";import{c as Y}from"./chunk-ARBZM2NF.js";import{a as K,g as W,i as z,j as B,k as $,n as L,o as J,p as X}from"./chunk-JB4PUN5S.js";import{d as U}from"./chunk-7O4MJYIW.js";import{c as F}from"./chunk-KJ6CW6EK.js";import{f as T,g as H,i as V,j as O,s as j,t as G,u as q}from"./chunk-7OX2O53H.js";import{d as R,e as p,f as I,g as A,j as S,l as M,n as x,o as N}from"./chunk-5TT47UMX.js";import{a as _}from"./chunk-NN3O7TPH.js";var h=new WeakMap;function Ke(e,t){let i=p(t);return i==="rust"?pe(e,t):i==="typescript"||i==="tsx"||i==="javascript"?fe(e,t):[]}var ue=new Set(["describe","it","test","fdescribe","fit","xdescribe","xit","beforeEach","afterEach","beforeAll","afterAll","before","after","suite","bench","benchmark"]);function fe(e,t){let i=S(e,t);if(!i)return[];let o=h.get(i);if(o)return o;let r=/(^|\/)(pages|app)\/.+\.(tsx?|jsx?)$/.test(t)||/(^|\/)(layout|page|loading|error|not-found|head|template|default)\.(tsx?|jsx?)$/.test(t),n=/(^|\/)src\/(pages|views|routes)\/.+\.(tsx?|jsx?|vue)$/.test(t),s=!1,c=i.rootNode;for(let l of c.namedChildren){if(l.type!=="expression_statement")continue;let u=l.namedChild(0);if(!u||u.type!=="call_expression")continue;let f=u.namedChild(0);if(!f)continue;let d=f.type==="member_expression"?f.namedChild(f.namedChildCount-1)?.text:f.text;if(d&&ue.has(d)){s=!0;break}}let a=[];s&&a.push({startLine:0,endLine:c.endPosition.row,reason:"TS/JS test file (describe/it/test at top level)"}),(r||n)&&a.push({startLine:0,endLine:c.endPosition.row,reason:r?"Next.js / Remix route file":"Vite/Vue route component"});for(let l of c.namedChildren){let u=null,f=null;if(l.type==="function_declaration")u=l.namedChild(0)?.text??null,f=l;else if(l.type==="export_statement"){let d=l.namedChild(0);d?.type==="function_declaration"&&(u=d.namedChild(0)?.text??null,f=d)}else if(l.type==="lexical_declaration"){let d=l.namedChild(0);if(d?.type==="variable_declarator"){let b=d.namedChild(0)?.text,m=d.namedChild(1);b&&(m?.type==="arrow_function"||m?.type==="function_expression")&&(u=b,f=d)}}u&&/^use[A-Z]/.test(u)&&f&&a.push({startLine:f.startPosition.row,endLine:f.endPosition.row,reason:"React custom hook (use*)"})}return a.push(...ee(i,new Set(["function_declaration","method_definition","class_declaration","interface_declaration","type_alias_declaration","enum_declaration","variable_declarator","export_statement"]),new Set(["comment"]))),h.set(i,a),a}var de=/scip-query[\s:-]*ignore[\s:-]*(?:dead(?:-code)?|stale)?/i;function me(e){return de.test(e)}function ee(e,t,i){let o=[],r=n=>{if(t.has(n.type)&&n.parent){let c=n.parent.children,a=-1;for(let l=0;l<c.length;l+=1)if(c[l].startIndex===n.startIndex&&c[l].type===n.type){a=l;break}if(a>0)for(let l=a-1;l>=0;l-=1){let u=c[l];if(i.has(u.type)){if(me(u.text)){o.push({startLine:n.startPosition.row,endLine:n.endPosition.row,reason:"scip-query suppression comment"});break}continue}if(!(u.type==="attribute_item"||u.type==="inner_attribute_item"))break}}for(let s of n.namedChildren)r(s)};return r(e.rootNode),o}function pe(e,t){let i=S(e,t);if(!i)return[];let o=h.get(i);if(o)return o;let r=[],n=be(i);return n?(h.set(i,n),n):(te(i.rootNode,r,!1,!1),r.push(...ee(i,new Set(["function_item","function_signature_item","struct_item","enum_item","union_item","impl_item","mod_item","static_item","const_item"]),new Set(["line_comment","block_comment"]))),r.push(...Re(i.rootNode)),h.set(i,r),r)}function be(e){return xe(e.rootNode)?[{startLine:0,endLine:e.rootNode.endPosition.row,reason:"generated file (@generated header)"}]:null}function te(e,t,i,o){let r=i,n=o;e.type==="trait_item"&&t.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:"trait declaration body (dynamic dispatch)"}),e.type==="impl_item"&&e.childForFieldName("trait")&&(n=!0,t.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:"trait impl block (dynamic dispatch)"})),e.type==="function_item"||e.type==="function_signature_item"?ye(e,t,i,o):o&&_e(e)?t.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:"trait impl associated item (dynamic dispatch)"}):e.type==="struct_item"||e.type==="enum_item"||e.type==="union_item"?ge(e,t,i):e.type==="mod_item"&&w(e).some(s=>/#\[\s*cfg\s*\(\s*test\s*\)/.test(s))&&(r=!0);for(let s of e.namedChildren)te(s,t,r,n)}function ye(e,t,i,o){let r=w(e),n=null;o?n="trait impl method (dynamic dispatch)":i&&(n="inside #[cfg(test)] mod");for(let s of r){let c=Se(s);if(c){n=c;break}if(ne(s)){n="#[allow(dead_code)]";break}}n&&t.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:n})}function ge(e,t,i){let o=w(e),r=e.namedChildren.find(n=>n.type==="type_identifier")?.text;o.some(he)&&t.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:"#[derive(<reflective>)] \u2014 fields accessed via macro/reflection",containerName:r}),o.some(ne)&&t.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:"#[allow(dead_code)]",containerName:r}),i&&t.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:"inside #[cfg(test)] mod",containerName:r})}function w(e){let t=e.parent;if(!t)return[];let i=t.children,o=-1;for(let n=0;n<i.length;n+=1)if(i[n].startIndex===e.startIndex&&i[n].type===e.type){o=n;break}if(o<=0)return[];let r=[];for(let n=o-1;n>=0;n-=1){let s=i[n];if(s.type==="attribute_item"||s.type==="inner_attribute_item")r.push(s.text);else{if(s.type==="line_comment"||s.type==="block_comment")continue;break}}return r}function Se(e){return/#\[\s*tauri::command\b/.test(e)?"#[tauri::command]":/#\[\s*command\b/.test(e)?"#[command]":/#\[\s*test\b/.test(e)?"#[test]":/#\[\s*bench\b/.test(e)?"#[bench]":/#\[\s*tokio::test\b/.test(e)?"#[tokio::test]":/#\[\s*async_std::test\b/.test(e)?"#[async_std::test]":/#\[\s*wasm_bindgen\b/.test(e)?"#[wasm_bindgen]":/#\[\s*no_mangle\b/.test(e)?"#[no_mangle]":/#\[\s*napi\b/.test(e)?"#[napi]":/#\[\s*pyfunction\b/.test(e)?"#[pyfunction]":/#\[\s*pymethod\b/.test(e)?"#[pymethod]":/#\[\s*pyo3\b/.test(e)?"#[pyo3]":/#\[\s*cfg\s*\(\s*test\s*\)/.test(e)?"#[cfg(test)]":/#\[\s*doc\s*\(\s*hidden\s*\)/.test(e)?"#[doc(hidden)]":null}function he(e){return/#\[\s*derive\s*\(/.test(e)?/\bSerialize\b/.test(e)||/\bDeserialize\b/.test(e)||/\bFromRow\b/.test(e)||/\bDeriveEntityModel\b/.test(e)||/\bIntoSchema\b/.test(e)||/\bToSchema\b/.test(e)||/\bDeriveValueType\b/.test(e)||/\bsqlx::FromRow\b/.test(e)||/\bError\b/.test(e)||/\bthiserror::Error\b/.test(e):!1}function ne(e){return/#\[\s*allow\s*\(\s*dead_code\s*\)/.test(e)}function _e(e){return e.type==="const_item"||e.type==="type_item"||e.type==="static_item"||e.type==="associated_type"}function Re(e){let t=ke(e);if(t.size===0)return[];let i=[];for(let o of e.descendantsOfType("mod_item")){let r=o.childForFieldName("name")?.text;r&&t.has(r)&&i.push({startLine:o.startPosition.row,endLine:o.endPosition.row,reason:'serde `with = "..."` module \u2014 body invoked via reflection',containerName:r})}return i}function xe(e){for(let t=0;t<Math.min(e.namedChildCount,12);t+=1){let i=e.namedChild(t);if(!i||i.type!=="line_comment"&&i.type!=="block_comment")break;if(/@generated\b/.test(i.text)||/This file is .*generated\b/i.test(i.text)||/Code generated by/i.test(i.text)||/Generated by:\s*https?:\/\/openapi-generator/i.test(i.text)||/openapi-generator/i.test(i.text)&&/Generated by/i.test(i.text))return!0}return!1}var Ce=[{key:"default",re:/\bdefault\s*=\s*"([^"]+)"/g},{key:"with",re:/\bwith\s*=\s*"([^"]+)"/g},{key:"serialize_with",re:/\bserialize_with\s*=\s*"([^"]+)"/g},{key:"deserialize_with",re:/\bdeserialize_with\s*=\s*"([^"]+)"/g},{key:"skip_serializing_if",re:/\bskip_serializing_if\s*=\s*"([^"]+)"/g},{key:"getter",re:/\bgetter\s*=\s*"([^"]+)"/g},{key:"rename_all_with",re:/\brename_all_with\s*=\s*"([^"]+)"/g},{key:"schema_with",re:/\bschema_with\s*=\s*"([^"]+)"/g}],ie=/^#!?\[\s*serde\s*\(/,Le=/^#!?\[\s*schemars\s*\(/,we=/^#!?\[\s*validate\s*\(/,Z=/\bwith\s*=\s*"([^"]+)"/g;function g(e,t){return x(e,t,Ee,()=>new Set,(i,o,r)=>{if(o==="rust"){for(let n of i.rootNode.descendantsOfType("attribute_item"))Q(n.text,r);for(let n of i.rootNode.descendantsOfType("inner_attribute_item"))Q(n.text,r)}})??new Set}var Ee=new WeakMap;function Q(e,t){let i=ie.test(e),o=Le.test(e),r=we.test(e);if(!(!i&&!o&&!r))for(let{re:n}of Ce){n.lastIndex=0;let s;for(;(s=n.exec(e))!==null;){let c=s[1],a=c.split("::").pop()??c;a==="is_none"&&/\bOption\b/.test(c)||a==="is_empty"&&/\b(String|Vec|HashMap|BTreeMap|HashSet|BTreeSet)\b/.test(c)||a&&t.add(a)}}}function ke(e){let t=new Set;for(let i of e.descendantsOfType("attribute_item")){if(!ie.test(i.text))continue;Z.lastIndex=0;let o;for(;(o=Z.exec(i.text))!==null;){let r=o[1],n=r.split("::").pop()??r;n&&t.add(n)}}return t}var De=new Set(["invoke","invokeTauriCommand","listen","once","emit","subscribe","dispatch","sendCommand","callRust"]);function re(e,t){return x(e,t,Ie,()=>new Set,(i,o,r)=>{if(!(o!=="typescript"&&o!=="tsx"&&o!=="javascript"))for(let n of i.rootNode.descendantsOfType("call_expression")){let s=n.namedChild(0);if(!s)continue;let c=N(s);if(!c||!De.has(c))continue;let a=n.namedChildren.find(f=>f.type==="arguments");if(!a)continue;let l=a.namedChild(0);if(!l||l.type!=="string")continue;let u=l.namedChildren.find(f=>f.type==="string_fragment");u&&r.add(u.text)}})??new Set}var Ie=new WeakMap;function oe(e,t,i={}){let o=new Map;if(t&&t.length===0)return o;let r=_(e,{includeIgnored:!1}),n=$(e),s=t??G(e),c=new Set(s.map(a=>a.symbolId));return Ae(e,o,r,n,c),Me(e,o,s,c),Pe(e,o,r,n,c),i.semantic!==!1&&He(o,U(e,Te(s))),o}function Ae(e,t,i,o,r){for(let n of i){if(!p(n))continue;let s=M(e,n);if(s)for(let c of s){let a=z(n,o.get(c.calleeLeaf)??[]);if(!a||a.length===0)continue;let l=B(e,n,a,c.memberAccess);l&&r.has(l.symbolId)&&l.file!==n&&E(t,l.symbolId,n)}}}function Me(e,t,i,o){let r=ve(i);for(let n of Ne(e,o))e.isIgnored(n.relative_path)||Fe(n,r.get(n.symbol_id))||E(t,n.symbol_id,n.relative_path)}function Ne(e,t){return W(e,t?[...t]:void 0)}function ve(e){let t=new Map;for(let i of e)t.set(i.symbolId,{docId:i.documentId,startLine:i.startLine,endLine:i.endLine});return t}function Fe(e,t){return!!t&&t.docId===e.document_id&&e.chunk_start>=t.startLine&&e.chunk_end<=t.endLine}function Pe(e,t,i,o,r){for(let n of i){if(p(n)!=="rust")continue;let s=g(e,n);if(s.size!==0)for(let c of s){let a=o.get(c);if(a)for(let l of a)r.has(l.symbolId)&&l.file!==n&&E(t,l.symbolId,n)}}}function E(e,t,i){let o=e.get(t);o||(o=new Set,e.set(t,o)),o.add(i)}function Te(e){return e.filter(t=>"relativePath"in t&&"symbol"in t&&"leaf"in t)}function He(e,t){for(let[i,o]of t){let r=e.get(i);r||(r=new Set,e.set(i,r));for(let n of o)r.add(n)}}var se=new WeakMap;function ae(e,t,i,o){let r=p(t);if(!r)return null;let n=S(e,t);if(!n)return null;let s=se.get(n);return s||(s=Ve(n,r),se.set(n,s)),s.get(`${i}:${o}`)??null}function Ve(e,t){let i=A(t),o=new Map,r=n=>{if(i.has(n.type)){let s=n.namedChildren.find(a=>a.type==="parameters"||a.type==="formal_parameters"),c=0;if(s)for(let a of s.namedChildren)a.type==="comment"||a.type==="line_comment"||a.type==="block_comment"||(c+=1);o.set(`${n.startPosition.row}:${n.endPosition.row}`,{paramCount:c})}for(let s of n.children)r(s)};return r(e.rootNode),o}function le(e,t,i){let o=t.identifierResolution==="strict"?L:J;for(let r of t.paths){let n=p(r);if(!(!n&&!(t.includeVueSfc&&I(r)))&&!e.isIgnored(r)&&!t.skipPath?.(r))try{let s=(a,l,u,f)=>{if(t.candidateNames&&!t.candidateNames.has(a))return;let d=t.resolveTargets?t.resolveTargets({sourceFile:r,name:a,kind:l,defaultTargets:f}):f();for(let b of d)i({sourceFile:r,name:a,target:b,occurrences:u,kind:l})},c=K(e,r);for(let[a,l]of c)s(a,"identifier",l.length,()=>o(e,r,a));if(t.includeCrossLanguageDispatchNames)for(let a of re(e,r))s(a,"cross-language-dispatch",1,()=>L(e,r,a));if(t.includeRustAttributeNames&&n==="rust")for(let a of g(e,r))s(a,"rust-attribute",1,()=>o(e,r,a))}finally{t.afterPath?.(r)}}}var ce=class{constructor(t){this.db=t}db;scopedDefinitions(t){return q(this.db,t)}definitionsForFile(t){return j(this.db,t)}productionCallableDefinitions(t={}){let{scope:i,minLoc:o=1,maxLoc:r=Number.POSITIVE_INFINITY,excludeSymbol:n,excludeEntrySurfaces:s=!1,excludeTypesFiles:c=!1,requireFunctionLikeSymbol:a=!1,requireCallableSymbol:l=!1,excludeRustTraitImplMembers:u=!1,includeSuppressed:f=!1,sortByLocDesc:d=!1}=t,b=[];for(let m of this.scopedDefinitions(i)){let y=m.relativePath;if(this.db.isIgnored(y)||s&&P(this.db,y)||!Oe(m,{requireFunctionLikeSymbol:a,requireCallableSymbol:l})||n!==void 0&&m.symbol===n)continue;let D=k(m);D<o||D>r||c&&je(y)||u&&V(m.symbol)||C(y)!=="test"&&(O(m.symbol)||!f&&R(this.db,y,m.startLine)||b.push(m))}return d?b.sort((m,y)=>k(y)-k(m)):b}calleeMap(t,i={}){return Y(this.db,t,i)}crossFileCallerMap(t,i={}){return oe(this.db,t,i)}sourceFallbackCallerFiles(t){return X(this.db,t)}callerFileMap(t,i={}){let o=this.crossFileCallerMap(t,{semantic:i.semantic});return i.sourceFallback===!1?o:Ge(o,this.sourceFallbackCallerFiles(t))}frameworkReferencedSymbolIds(t){let i=new Map;for(let r of t){if(!r.leaf)continue;let n=i.get(r.leaf)??[];n.push(r.symbolId),i.set(r.leaf,n)}let o=new Set;for(let r of _(this.db,{includeIgnored:!1}))if(p(r)==="rust")for(let n of g(this.db,r))for(let s of i.get(n)??[])o.add(s);return o}symbolsWithNonSelfCallees(t,i={}){if(t.length===0)return new Set;let o=new Map(t.map(n=>[n.symbolId,n.symbol])),r=this.calleeMap(t,i);return new Set([...r.entries()].filter(([n,s])=>{let c=o.get(n);return s.some(a=>a.symbol!==c)}).map(([n])=>n))}fileDependencyGraph(t){return v(this.db,t)}fileKind(t){return C(t)}hasSuppressionComment(t){return R(this.db,t.relativePath,t.startLine)}sourceFiles(){return F(this.db)}scanSourceReferences(t,i){le(this.db,t,i)}callableSignature(t){return ae(this.db,t.relativePath,t.startLine,t.endLine)}};function Oe(e,t){return t.requireCallableSymbol?T(e.symbol):t.requireFunctionLikeSymbol?H(e.symbol):e.isFunctionLike}function k(e){return e.endLine-e.startLine+1}function je(e){return(e.split("/").pop()??"").includes("types")}function Ge(e,t){let i=new Map;for(let[o,r]of e)i.set(o,new Set(r));for(let[o,r]of t){let n=i.get(o)??new Set;for(let s of r)n.add(s);i.set(o,n)}return i}export{Ke as a,ce as b};
2
- //# sourceMappingURL=chunk-QAEDNTY7.js.map
@@ -1,2 +0,0 @@
1
- import{d as i}from"./chunk-MX6F756F.js";import{a,b as m}from"./chunk-ARBZM2NF.js";import{a as r}from"./chunk-ZNUPGRPR.js";import{c as s}from"./chunk-7OX2O53H.js";function h(t,n,c={}){let e=r(t,n);if(!e)return null;let o=c.semantic!==!1,y=m(t,e,{limit:50,semantic:o}),b=i(a(t,e,{limit:50,additive:!0,callableOnly:!0,semantic:o}));return{symbol:e.symbol,shortName:s(e.symbol),callers:y.map(l=>({symbol:l.symbol,shortName:s(l.symbol),file:l.file})),callees:b.map(l=>({symbol:l.symbol,shortName:s(l.symbol),file:l.file}))}}export{h as a};
2
- //# sourceMappingURL=chunk-TGK5DFBJ.js.map
@@ -1,2 +0,0 @@
1
- import{b as a}from"./chunk-QAEDNTY7.js";import{a as i}from"./chunk-ZNUPGRPR.js";import{c as s,e as o,k as m}from"./chunk-7OX2O53H.js";function L(t,l){let r=i(t,l);return r?new a(t).definitionsForFile(r.relativePath).filter(e=>e.symbol!==r.symbol).filter(e=>m(r.symbol,e.symbol)).sort((e,n)=>e.startLine-n.startLine||e.endLine-n.endLine).map(e=>({symbol:e.symbol,shortName:s(e.symbol),startLine:e.startLine,endLine:e.endLine,kind:o(e.symbol)??"unknown"})):[]}export{L as a};
2
- //# sourceMappingURL=chunk-V53J46BX.js.map
@@ -1,2 +0,0 @@
1
- import{c as f}from"./chunk-MX6F756F.js";import{b}from"./chunk-QAEDNTY7.js";import{a as c,b as u}from"./chunk-ARBZM2NF.js";import{c as l}from"./chunk-7OX2O53H.js";function w(o,e={}){let{limit:r=20,scope:s,minFanIn:i=2,minFanOut:n=2,scanLimit:a}=e,p=new b(o);return f(p.productionCallableDefinitions({scope:s,requireCallableSymbol:!0,includeSuppressed:!0,sortByLocDesc:typeof a=="number"&&a>0}),a).map(t=>y(o,t,e.semantic!==!1)).filter(t=>t.fanIn>=i&&t.fanOut>=n).sort((t,m)=>m.score-t.score||m.fanIn-t.fanIn).slice(0,r)}function y(o,e,r){let s=new Set(u(o,e,{limit:500,semantic:r}).map(n=>n.file)).size,i=new Set(c(o,e,{limit:500,semantic:r}).filter(n=>n.file!==e.relativePath).map(n=>`${n.symbol}|${n.file}`)).size;return{symbol:e.symbol,shortName:l(e.symbol),fanIn:s,fanOut:i,score:s*i,definedIn:e.relativePath}}export{w as a};
2
- //# sourceMappingURL=chunk-YSZNAG4G.js.map