scip-query 0.6.4 → 0.6.5

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 (196) hide show
  1. package/README.md +31 -29
  2. package/dist/augment-vue-worker.js +2 -0
  3. package/dist/chunk-2ZGHRI2A.js +5 -0
  4. package/dist/chunk-32R4VYYA.js +2 -0
  5. package/dist/chunk-3UB2DPLP.js +2 -0
  6. package/dist/chunk-4X7C236P.js +84 -0
  7. package/dist/chunk-5LQ6CVX3.js +2 -0
  8. package/dist/chunk-5YYMKE3G.js +70 -0
  9. package/dist/chunk-7LSCW7NF.js +6 -0
  10. package/dist/chunk-7X7FLQC5.js +2 -0
  11. package/dist/chunk-A5UNS4DR.js +4 -0
  12. package/dist/chunk-BNCTPTVX.js +2 -0
  13. package/dist/{chunk-CGAO6FHN.js → chunk-C5BFS23M.js} +2 -2
  14. package/dist/{chunk-OOMAS234.js → chunk-DRLWW74T.js} +2 -2
  15. package/dist/chunk-EB5IVUNU.js +2 -0
  16. package/dist/{chunk-ZE3BTHTS.js → chunk-ERRUE5G4.js} +4 -4
  17. package/dist/chunk-F4KR22Z2.js +2 -0
  18. package/dist/chunk-FG6A6ZUP.js +2 -0
  19. package/dist/chunk-FHSD5RKF.js +19 -0
  20. package/dist/chunk-FVVEIGP3.js +5 -0
  21. package/dist/chunk-GBDZY73J.js +2 -0
  22. package/dist/{chunk-4TYGGOLO.js → chunk-H4DXD2FB.js} +1 -1
  23. package/dist/chunk-HUASU3AD.js +71 -0
  24. package/dist/chunk-IJWIYZO5.js +2 -0
  25. package/dist/chunk-K6H3XJQW.js +7 -0
  26. package/dist/{chunk-KYT47WU2.js → chunk-KAM4C6ZD.js} +1 -1
  27. package/dist/{chunk-IDCWMWWP.js → chunk-KTCODJNQ.js} +3 -3
  28. package/dist/chunk-LJ2YWNQF.js +2 -0
  29. package/dist/chunk-LT2CPEQ4.js +2 -0
  30. package/dist/chunk-M5QTG55L.js +2 -0
  31. package/dist/chunk-MKFH7QJG.js +7 -0
  32. package/dist/chunk-MO32JMOD.js +12 -0
  33. package/dist/chunk-MO65UK5V.js +6 -0
  34. package/dist/chunk-MTK3JAJT.js +2 -0
  35. package/dist/{chunk-6UJ5PXER.js → chunk-MXWC53GJ.js} +4 -4
  36. package/dist/{chunk-IVT2U2BV.js → chunk-OQZF2DQJ.js} +3 -3
  37. package/dist/chunk-PBFMZKXE.js +6 -0
  38. package/dist/{chunk-LAXFZ3UW.js → chunk-PFMGJ4BR.js} +4 -4
  39. package/dist/{chunk-QID23O53.js → chunk-PK4U6NWP.js} +2 -2
  40. package/dist/{chunk-GALIM3IE.js → chunk-Q2ALKKSE.js} +4 -4
  41. package/dist/chunk-QFCK6WV2.js +39 -0
  42. package/dist/chunk-QFZE73XF.js +84 -0
  43. package/dist/chunk-QRYEOK3M.js +2 -0
  44. package/dist/{chunk-LORWXBOO.js → chunk-RKTDEIHF.js} +1 -1
  45. package/dist/chunk-ROWAEEOD.js +2 -0
  46. package/dist/chunk-RT5PV5JQ.js +7 -0
  47. package/dist/chunk-TLRA5TR6.js +2 -0
  48. package/dist/chunk-U5MVUPOO.js +2 -0
  49. package/dist/chunk-URUVLDM7.js +29 -0
  50. package/dist/chunk-WHGCGENP.js +16 -0
  51. package/dist/chunk-WIIZF5FP.js +2 -0
  52. package/dist/chunk-WNMAH3P7.js +2 -0
  53. package/dist/chunk-XV3XUZ3X.js +11 -0
  54. package/dist/chunk-YDKWDTAW.js +2 -0
  55. package/dist/{chunk-5OVBASGY.js → chunk-YDNCX5PF.js} +2 -2
  56. package/dist/chunk-YU25IHJX.js +90 -0
  57. package/dist/{chunk-AW3QJT4O.js → chunk-Z5CTXSWT.js} +3 -3
  58. package/dist/chunk-ZFCQQ4B5.js +2 -0
  59. package/dist/chunk-ZHHMG4UC.js +114 -0
  60. package/dist/cli.js +487 -388
  61. package/dist/{db-DKhNQ75l.d.ts → db-BZPa7dzJ.d.ts} +19 -9
  62. package/dist/index.d.ts +221 -13
  63. package/dist/index.js +45 -31
  64. package/dist/postinstall.js +1 -1
  65. package/dist/queries/affected.d.ts +1 -1
  66. package/dist/queries/affected.js +1 -1
  67. package/dist/queries/bottlenecks.d.ts +1 -1
  68. package/dist/queries/bottlenecks.js +1 -1
  69. package/dist/queries/by-kind.d.ts +1 -1
  70. package/dist/queries/by-kind.js +1 -1
  71. package/dist/queries/call-graph.d.ts +1 -1
  72. package/dist/queries/call-graph.js +1 -1
  73. package/dist/queries/change-surface.d.ts +1 -1
  74. package/dist/queries/change-surface.js +1 -1
  75. package/dist/queries/code.d.ts +1 -1
  76. package/dist/queries/code.js +1 -1
  77. package/dist/queries/complexity-hotspots.d.ts +1 -1
  78. package/dist/queries/complexity-hotspots.js +1 -1
  79. package/dist/queries/complexity.d.ts +1 -1
  80. package/dist/queries/complexity.js +1 -1
  81. package/dist/queries/convergence.d.ts +1 -1
  82. package/dist/queries/convergence.js +1 -1
  83. package/dist/queries/coupling.d.ts +1 -1
  84. package/dist/queries/coupling.js +1 -1
  85. package/dist/queries/cycles.d.ts +1 -1
  86. package/dist/queries/cycles.js +1 -1
  87. package/dist/queries/dataflow.d.ts +1 -1
  88. package/dist/queries/dataflow.js +1 -1
  89. package/dist/queries/dead.d.ts +1 -1
  90. package/dist/queries/dead.js +1 -1
  91. package/dist/queries/deep-chains.d.ts +1 -1
  92. package/dist/queries/deep-chains.js +1 -1
  93. package/dist/queries/deps.d.ts +1 -1
  94. package/dist/queries/deps.js +1 -1
  95. package/dist/queries/diff-impact.d.ts +1 -1
  96. package/dist/queries/diff-impact.js +1 -1
  97. package/dist/queries/drift-policy.d.ts +6 -0
  98. package/dist/queries/drift-policy.js +2 -0
  99. package/dist/queries/drift.d.ts +1 -1
  100. package/dist/queries/drift.js +1 -1
  101. package/dist/queries/extract-candidates.d.ts +1 -1
  102. package/dist/queries/extract-candidates.js +1 -1
  103. package/dist/queries/fan.d.ts +1 -1
  104. package/dist/queries/fan.js +1 -1
  105. package/dist/queries/files.d.ts +1 -1
  106. package/dist/queries/files.js +1 -1
  107. package/dist/queries/health.d.ts +1 -1
  108. package/dist/queries/health.js +1 -1
  109. package/dist/queries/hierarchy.d.ts +1 -1
  110. package/dist/queries/hierarchy.js +1 -1
  111. package/dist/queries/hotspots.d.ts +1 -1
  112. package/dist/queries/hotspots.js +1 -1
  113. package/dist/queries/imports.d.ts +1 -1
  114. package/dist/queries/imports.js +1 -1
  115. package/dist/queries/index.d.ts +1 -1
  116. package/dist/queries/index.js +1 -1
  117. package/dist/queries/isolated.d.ts +1 -1
  118. package/dist/queries/isolated.js +1 -1
  119. package/dist/queries/members.d.ts +1 -1
  120. package/dist/queries/members.js +1 -1
  121. package/dist/queries/methods.d.ts +1 -1
  122. package/dist/queries/methods.js +1 -1
  123. package/dist/queries/outline.d.ts +1 -1
  124. package/dist/queries/outline.js +1 -1
  125. package/dist/queries/passthrough-candidates.d.ts +1 -1
  126. package/dist/queries/passthrough-candidates.js +1 -1
  127. package/dist/queries/redundant-reexports.d.ts +1 -1
  128. package/dist/queries/redundant-reexports.js +1 -1
  129. package/dist/queries/refs.d.ts +1 -1
  130. package/dist/queries/refs.js +1 -1
  131. package/dist/queries/similar-chains.d.ts +1 -1
  132. package/dist/queries/similar-chains.js +1 -1
  133. package/dist/queries/similar-files.d.ts +1 -1
  134. package/dist/queries/similar-files.js +1 -1
  135. package/dist/queries/similar-signatures.d.ts +1 -1
  136. package/dist/queries/similar-signatures.js +1 -1
  137. package/dist/queries/similar.d.ts +1 -1
  138. package/dist/queries/similar.js +1 -1
  139. package/dist/queries/slice.d.ts +1 -1
  140. package/dist/queries/slice.js +1 -1
  141. package/dist/queries/stale-abstractions.d.ts +1 -1
  142. package/dist/queries/stale-abstractions.js +1 -1
  143. package/dist/queries/stats.d.ts +1 -1
  144. package/dist/queries/stats.js +1 -1
  145. package/dist/queries/surface.d.ts +1 -1
  146. package/dist/queries/surface.js +1 -1
  147. package/dist/queries/symbols.d.ts +1 -1
  148. package/dist/queries/symbols.js +1 -1
  149. package/dist/queries/system.d.ts +1 -1
  150. package/dist/queries/system.js +1 -1
  151. package/dist/queries/trace.d.ts +1 -1
  152. package/dist/queries/trace.js +1 -1
  153. package/dist/queries/wrapper-candidates.d.ts +1 -1
  154. package/dist/queries/wrapper-candidates.js +1 -1
  155. package/dist/reindex-worker.js +10 -63
  156. package/package.json +4 -2
  157. package/dist/chunk-2DQK2IDZ.js +0 -19
  158. package/dist/chunk-4HCKXL7T.js +0 -6
  159. package/dist/chunk-4Q2D5BMS.js +0 -2
  160. package/dist/chunk-5IM4IQ6N.js +0 -2
  161. package/dist/chunk-5NSYCQWM.js +0 -6
  162. package/dist/chunk-6QKHOBC6.js +0 -2
  163. package/dist/chunk-6U5UHIRD.js +0 -5
  164. package/dist/chunk-AQFXC7CF.js +0 -2
  165. package/dist/chunk-BSONDC3H.js +0 -7
  166. package/dist/chunk-ECT6SOBO.js +0 -2
  167. package/dist/chunk-FFE3RZ65.js +0 -2
  168. package/dist/chunk-FT4WPAEX.js +0 -65
  169. package/dist/chunk-G6HYVVRV.js +0 -2
  170. package/dist/chunk-GVVKLMXG.js +0 -10
  171. package/dist/chunk-HVM6SQPQ.js +0 -2
  172. package/dist/chunk-IJO2HZFL.js +0 -2
  173. package/dist/chunk-INPQVQ6O.js +0 -12
  174. package/dist/chunk-JSBWVSES.js +0 -39
  175. package/dist/chunk-MFVPKCS5.js +0 -2
  176. package/dist/chunk-MWCN46ZX.js +0 -89
  177. package/dist/chunk-N3Z2SJCR.js +0 -2
  178. package/dist/chunk-NKU7Z242.js +0 -8
  179. package/dist/chunk-P6IUCZA3.js +0 -24
  180. package/dist/chunk-PM3GTZ4I.js +0 -2
  181. package/dist/chunk-QL5MJOVA.js +0 -84
  182. package/dist/chunk-QWFK4QOQ.js +0 -2
  183. package/dist/chunk-RBYC6PHE.js +0 -2
  184. package/dist/chunk-TS7E5XBZ.js +0 -29
  185. package/dist/chunk-TUC6IWTY.js +0 -2
  186. package/dist/chunk-USMVRM6F.js +0 -2
  187. package/dist/chunk-VTZPTRKS.js +0 -7
  188. package/dist/chunk-WUYKGQSK.js +0 -2
  189. package/dist/chunk-X7LOLGYY.js +0 -2
  190. package/dist/chunk-XGOEZVMA.js +0 -7
  191. package/dist/chunk-Y6NOLG4X.js +0 -70
  192. package/dist/chunk-YVQ7CIKO.js +0 -6
  193. package/dist/chunk-ZIFKQQW2.js +0 -4
  194. package/dist/chunk-ZOR6FW74.js +0 -2
  195. package/dist/chunk-ZPZLVFJQ.js +0 -41
  196. package/dist/chunk-ZZ3F6P3X.js +0 -2
@@ -1,66 +1,13 @@
1
- import{d as R}from"./chunk-4TYGGOLO.js";import{execFileSync as ae}from"child_process";import{existsSync as le,renameSync as ce,rmSync as un}from"fs";import{basename as pn,dirname as gn,extname as dn,join as C}from"path";import De from"better-sqlite3";import{existsSync as Ee,readdirSync as we,readFileSync as _e}from"fs";import{extname as D,join as U}from"path";import ve from"ignore";import{readFileSync as Se,existsSync as P}from"fs";import{dirname as k,isAbsolute as N,join as j,relative as Ie,resolve as Ce}from"path";function M(e){let n=ve(),r=!1,t=Pe(e);for(let i of t)try{let s=Se(i,"utf-8");n.add(s),r=!0}catch{}return r||n.add(ke),{isIgnored:i=>B(n,e,i),filter:i=>i.filter(s=>!B(n,e,s))}}function Pe(e){let n=[],r=j(e,".gitignore");P(r)&&n.push(r);let t=k(e),i=0;for(;t!==k(t)&&i<5;){let s=j(t,".gitignore");if(P(s)&&n.push(s),P(j(t,".git")))break;t=k(t),i++}return n}var ke=`
2
- # Dependencies
3
- node_modules/
4
- vendor/
5
- .bundle/
6
-
7
- # Build output
8
- dist/
9
- build/
10
- out/
11
- target/
12
- bin/
13
- obj/
14
-
15
- # Python
16
- __pycache__/
17
- *.pyc
18
- *.pyo
19
- .venv/
20
- venv/
21
- .env/
22
- env/
23
- *.egg-info/
24
-
25
- # Rust
26
- target/
27
-
28
- # Java / Kotlin / Scala
29
- *.class
30
- .gradle/
31
- .mvn/
32
-
33
- # C# / .NET
34
- bin/
35
- obj/
36
- packages/
37
-
38
- # Go
39
- vendor/
40
-
41
- # Dart
42
- .dart_tool/
43
- build/
44
-
45
- # PHP
46
- vendor/
47
-
48
- # IDE / OS
49
- .idea/
50
- .vscode/
51
- *.swp
52
- *.swo
53
- .DS_Store
54
- Thumbs.db
55
-
56
- # Type definitions (often noise in queries)
57
- *.d.ts
58
- `;function B(e,n,r){let t=je(n,r);if(!t)return!1;try{return e.ignores(t)}catch{return!1}}function je(e,n){if(!n||n===".")return null;if(!N(n)&&!n.startsWith(".."))return n.replaceAll("\\","/");let r=N(n)?n:Ce(e,n),t=Ie(e,r).replaceAll("\\","/");return!t||t==="."||t.startsWith("..")?null:t}import{readdirSync as Cn}from"fs";import{extname as kn,join as jn}from"path";function F(e){let n=new WeakMap,r=t=>{let i=n.get(t);return i||(i=new Map,n.set(t,i)),i};return{get(t,i,s){let a=r(t);if(a.has(i))return a.get(i);let l=s();return a.set(i,l),l},invalidate(t,i){n.get(t)?.delete(i)},invalidateAll(t){n.delete(t)},size(t){return n.get(t)?.size??0}}}var O=[".vue"],T=new Set(["node_modules",".git","target","dist","build",".next",".nuxt",".cache",".turbo","out","coverage",".scipquery-cache","__pycache__",".venv","venv",".idea",".vscode"]);var En=F("source-files");function V(e){let n=new Set((e.extensions??O).map(s=>s.toLowerCase()));if(n.size===0)return{scanned:0,inserted:0,existing:0};if(!Ee(e.dbPath))throw new Error(`SCIP SQLite database not found at ${e.dbPath}`);let r=M(e.projectRoot),t=Le(e.projectRoot,n).filter(s=>!r.isIgnored(s)),i=new De(e.dbPath);try{let s=t.length===0?new Set:new Set(i.prepare(`SELECT relative_path FROM documents WHERE relative_path IN (${t.map(()=>"?").join(",")})`).all(...t).map(f=>f.relative_path)),a=i.prepare(`INSERT OR IGNORE INTO documents (language, relative_path, position_encoding, text)
59
- VALUES (?, ?, NULL, ?)`),c=i.transaction(f=>{let p=0;for(let u of f){if(s.has(u))continue;let v=_e(U(e.projectRoot,u),"utf-8"),o=a.run($e(u),u,v);p+=Number(o.changes)}return p})(t),h={scanned:t.length,inserted:c,existing:t.length-c};return e.onStatus?.(`Augmented SQLite documents with ${c} auxiliary source file${c===1?"":"s"} (${h.existing} already present).`),h}finally{i.close()}}function Le(e,n){let r=[],t=i=>{let s=i?U(e,i):e,a=[];try{a=we(s,{withFileTypes:!0})}catch{return}for(let l of a){if(T.has(l.name))continue;let c=i?`${i}/${l.name}`:l.name;if(l.isDirectory()){t(c);continue}n.has(D(l.name).toLowerCase())&&r.push(c)}};return t(""),r.sort()}function $e(e){return D(e).toLowerCase()===".vue"?"vue":D(e).replace(/^\./,"").toLowerCase()||"source"}import{existsSync as Ae,readdirSync as G}from"fs";import{extname as Re,join as q}from"path";var Ne=new Set([".git",".hg",".svn",".idea",".vscode","node_modules","vendor","dist","build","target","bin","obj",".dart_tool",".gradle",".next",".venv","venv","__pycache__"]),Be=[{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 z(e){let n=[],r=Me(e),t=Ue(e);for(let i of Be){if(Fe(e,i.files)){n.push(i.language);continue}if(Oe(r,i.globs)){n.push(i.language);continue}Ve(t,i.extensions)&&n.push(i.language)}return n.includes("typescript")&&W(n,"javascript"),n.includes("cpp")&&!t.has(".c")&&W(n,"c"),n}function Me(e){try{return G(e)}catch{return[]}}function Fe(e,n){return n?.length?n.some(r=>Ae(q(e,r))):!1}function Oe(e,n){return n?.length?e.some(r=>n.some(t=>Te(r,t))):!1}function Te(e,n){if(n==="*")return!0;if(!n.includes("*"))return e===n;let[r,t]=n.split("*");return e.startsWith(r??"")&&e.endsWith(t??"")}function Ue(e){let n=new Set,r=[e];for(;r.length>0;){let t=r.pop();if(!t)continue;let i;try{i=G(t,{withFileTypes:!0})}catch{continue}for(let s of i){if(s.name.startsWith(".")&&!s.name.endsWith("proj")&&!s.name.endsWith("sln")&&s.isDirectory())continue;let a=q(t,s.name);if(s.isDirectory()){Ne.has(s.name)||r.push(a);continue}let l=Re(s.name).toLowerCase();l&&n.add(l)}}return n}function Ve(e,n){return n?.length?n.some(r=>e.has(r)):!1}function W(e,n){let r=e.indexOf(n);r!==-1&&e.splice(r,1)}import{existsSync as K,readdirSync as We}from"fs";import{join as E}from"path";var Ge={typescript:{language:"typescript",indexerBinary:"scip-typescript",checkCommand:"npx scip-typescript --version",indexArgs:({outputPath:e,pnpmWorkspaces:n})=>{let r=["scip-typescript","index","--infer-tsconfig","--output",e,"--no-progress-bar"];return n&&r.splice(2,0,"--pnpm-workspaces"),{binary:"npx",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})=>({binary:"npx",args:["scip-typescript","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",binaryAliases:["scip-python-plus"],checkCommand:"npx scip-python --version",indexArgs:({outputPath:e})=>({binary:"npx",args:["scip-python","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",H(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",H(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 r=E(e,"vendor","bin","scip-php"),t=E(e,"vendor","davidrjenni","scip-php","bin","scip-php");return{binary:"php",args:["-d","error_reporting=E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED",K(t)?t:K(r)?r:n]}},defaultOutputPath:"index.scip",markerFiles:["composer.json"],installMethods:[],installUrl:"https://github.com/davidrjenni/scip-php/releases"}};function X(e){return Ge[e]}function H(e,n){let r;try{r=We(e)}catch{return null}for(let t of r)if(n.some(i=>t.endsWith(i)))return E(e,t);return null}import{readFileSync as qe,writeFileSync as ze}from"fs";import{create as w}from"@bufbuild/protobuf";import{deserializeSCIP as Ke,serializeSCIP as He,DocumentSchema as Xe,IndexSchema as Je,SymbolInformationSchema as Qe}from"@c4312/scip";function Ye(e){if(e.length===0)throw new Error("Cannot merge zero SCIP indexes");if(e.length===1)return e[0];let n=Ze(e),r=en(e.flatMap(i=>i.documents??[])),t=Q(e.flatMap(i=>i.externalSymbols??[]));return w(Je,{metadata:n,documents:r,externalSymbols:t})}function J(e,n){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let r=e.map(i=>Ke(qe(i))),t=Ye(r);return ze(n,Buffer.from(He(t))),{documentCount:t.documents.length,externalSymbolCount:t.externalSymbols.length,inputCount:e.length}}function Ze(e){let n=e[0]?.metadata;if(!n)return;let r=n.projectRoot;for(let t of e.slice(1)){let i=t.metadata?.projectRoot;if(r&&i&&i!==r)throw new Error(`Cannot merge SCIP indexes with different project roots: ${r} vs ${i}`)}return n}function en(e){let n=new Map;for(let r of e){let t=n.get(r.relativePath);if(!t){n.set(r.relativePath,r);continue}n.set(r.relativePath,w(Xe,{language:t.language||r.language,relativePath:t.relativePath||r.relativePath,occurrences:[...t.occurrences,...r.occurrences],symbols:Q([...t.symbols,...r.symbols]),text:tn(t.text,r.text),positionEncoding:t.positionEncoding||r.positionEncoding}))}return[...n.values()]}function Q(e){let n=new Map;for(let r of e){let t=n.get(r.symbol);if(!t){n.set(r.symbol,r);continue}n.set(r.symbol,w(Qe,{symbol:t.symbol,documentation:rn([...t.documentation,...r.documentation]),relationships:nn([...t.relationships,...r.relationships]),kind:t.kind||r.kind,displayName:t.displayName||r.displayName,enclosingSymbol:t.enclosingSymbol||r.enclosingSymbol,signatureDocumentation:t.signatureDocumentation??r.signatureDocumentation}))}return[...n.values()]}function nn(e){let n=new Set,r=[];for(let t of e){let i=[t.symbol,t.isReference?"1":"0",t.isImplementation?"1":"0",t.isTypeDefinition?"1":"0",t.isDefinition?"1":"0"].join("|");n.has(i)||(n.add(i),r.push(t))}return r}function tn(e,n){return e?n?e.length>=n.length?e:n:e:n}function rn(e){return[...new Set(e)]}import{execFileSync as S}from"child_process";import{existsSync as _}from"fs";import{createRequire as sn}from"module";import{platform as Y}from"os";import{join as Z}from"path";var on=sn(import.meta.url),an=Y()==="win32";function b(e){let n=an?"where":"which";try{return S(n,[e],{stdio:"pipe"}),!0}catch{return!1}}function ee(e){return[e.indexerBinary,...e.binaryAliases??[]]}function L(e){let n=ee(e);return n.length===1?n[0]:n.join(" or ")}function I(e){for(let n of ee(e))if(b(n))return n;return te(e)?e.indexerBinary:null}function ne(e){return I(e)!==null||te(e)}function te(e){if(!e.bundledNpmPackage)return!1;try{return on.resolve(`${e.bundledNpmPackage}/package.json`),!0}catch{return!1}}function re(e,n){for(let r of e.projectLocalBinaries??[]){let t=Z(n,r);if(_(t))return t}return null}function ie(e,n=process.env,r=e.indexerBinary){if(e.indexerBinary!=="scip-dotnet"||oe(r,n))return n;let t=ln(r,n);return t?{...n,DOTNET_ROOT:t}:n}function se(e,n){let r=e.installMethods,t=L(e);if(!r?.length)return n(`No auto-install method available for ${t}.`),e.installUrl&&n(`Install manually from: ${e.installUrl}`),!1;for(let i of r)if(b(i.prerequisite)){n(`Installing ${t} via ${i.label}...`);try{S(i.binary,i.args,{stdio:"inherit",timeout:3e5,env:process.env});let s=I(e);if(s){let a=s===e.indexerBinary?"":` (using ${s})`;return n(`Successfully installed ${t} via ${i.label}${a}`),!0}n(`${i.label} command completed but ${t} was not found on PATH`)}catch(s){let a=s instanceof Error?s.message:String(s);n(`${i.label} install failed: ${a}`)}}return n(`Could not auto-install ${t}.`),e.installUrl&&n(`Install manually from: ${e.installUrl}`),!1}function ln(e,n){for(let r of cn(n))if(oe(e,{...n,DOTNET_ROOT:r}))return r;return null}function cn(e){let n=[],r=e.DOTNET_ROOT;if(r&&_(r)&&n.push(r),Y()==="darwin"&&b("brew"))try{let t=S("brew",["--prefix","dotnet@9"],{stdio:"pipe",env:e}).toString().trim(),i=Z(t,"libexec");_(i)&&!n.includes(i)&&n.push(i)}catch{}return n}function oe(e,n){try{return S(e,["--version"],{stdio:"pipe",env:n}),!0}catch{return!1}}async function ue(e){let{projectRoot:n,maxHeapMb:r=8192,onStatus:t=console.log,skipAutoInstall:i=!1}=e,s=e.outputScip??C(n,"index.scip"),a=e.outputDb??C(n,"index.db"),l=Date.now(),c=e.languages??z(n);if(c.length===0)throw new Error("No supported languages detected in this project. Looked for: tsconfig.json, Cargo.toml, go.mod, pyproject.toml, etc.");if(t(`Detected languages: ${c.join(", ")}`),!b("scip")){if(i)throw new Error(`The scip CLI is required but not found on PATH.
60
- Install from: https://github.com/sourcegraph/scip/releases`);if(t("scip CLI not found on PATH. Attempting auto-install..."),!R(t))throw new Error(`The scip CLI is required but could not be installed.
61
- Install manually from: https://github.com/sourcegraph/scip/releases`)}let h={...process.env,NODE_OPTIONS:`--max-old-space-size=${r}`},f=c.map((o,m)=>({language:o,scipPath:c.length>1?fn(s,o,m):s})),p=[],u=[];for(let{language:o,scipPath:m}of f){let d=X(o),x=L(d),$=re(d,n);if(!$&&!ne(d)){if(i){let g=`${x} not found on PATH (auto-install disabled). ${d.installUrl??""}`.trim();t(`Skipping ${o}: ${g}`),u.push({language:o,reason:g});continue}if(t(`${x} not found. Attempting auto-install...`),!se(d,t)){let g=`${x} could not be auto-installed. ${d.installUrl?`Install manually from ${d.installUrl}`:`Install ${x} and put it on PATH.`}`;t(`Skipping ${o}: ${g}`),u.push({language:o,reason:g});continue}}let y=$??I(d);if(!y){let g=`${x} was not found after installation checks.`;t(`Skipping ${o}: ${g}`),u.push({language:o,reason:g});continue}t(`Indexing ${o} with ${y}...`);let he=ie(d,h,y),{binary:xe,args:ye}=d.indexArgs({projectRoot:n,outputPath:m,pnpmWorkspaces:e.pnpmWorkspaces,indexerBinary:y});try{ae(xe,ye,{cwd:n,env:he,stdio:"pipe",maxBuffer:50*1024*1024})}catch(g){let be=g instanceof Error?g.message:String(g),A=`${y} indexer failed: ${be.split(`
62
- `)[0]}`;t(`Skipping ${o}: ${A}`),u.push({language:o,reason:A});continue}mn(d,n,m),p.push({language:o,scipPath:m})}if(p.length===0){let o=u.map(m=>` - ${m.language}: ${m.reason}`).join(`
1
+ import{a as k,b as $}from"./chunk-HUASU3AD.js";import{d as E}from"./chunk-H4DXD2FB.js";import{execFile as Ke,execFileSync as Ve}from"child_process";import{closeSync as Ye,existsSync as m,mkdirSync as ee,mkdtempSync as Ze,openSync as en,readFileSync as nn,renameSync as f,rmSync as h,writeFileSync as ne}from"fs";import{cpus as tn}from"os";import{basename as I,dirname as d,extname as rn,join as c}from"path";import{execFileSync as ue}from"child_process";import{existsSync as le,readdirSync as M}from"fs";import{extname as N,join as F}from"path";var ce=new Set([".git",".hg",".svn",".idea",".vscode","node_modules","vendor","dist","build","target","bin","obj",".dart_tool",".gradle",".next",".venv","venv","__pycache__"]),pe=[{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 A(e){let n=[],t=ge(e),r=he(e);for(let a of pe){if(de(e,a.files)){n.push(a.language);continue}if(me(t,a.globs)){n.push(a.language);continue}ye(r,a.extensions)&&n.push(a.language)}return n.includes("typescript")&&B(n,"javascript"),n.includes("cpp")&&!r.has(".c")&&B(n,"c"),n}function ge(e){try{return M(e)}catch{return[]}}function de(e,n){return n?.length?n.some(t=>le(F(e,t))):!1}function me(e,n){return n?.length?e.some(t=>n.some(r=>fe(t,r))):!1}function fe(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 he(e){let n=xe(e);if(n)return n;let t=new Set,r=[e];for(;r.length>0;){let a=r.pop();if(!a)continue;let i;try{i=M(a,{withFileTypes:!0})}catch{continue}for(let s of i){if(s.name.startsWith(".")&&!s.name.endsWith("proj")&&!s.name.endsWith("sln")&&s.isDirectory())continue;let o=F(a,s.name);if(s.isDirectory()){ce.has(s.name)||r.push(o);continue}let g=N(s.name).toLowerCase();g&&t.add(g)}}return t}function xe(e){try{let n=ue("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(`
2
+ `)){if(!r)continue;let a=N(r).toLowerCase();a&&t.add(a)}return t}catch{return null}}function ye(e,n){return n?.length?n.some(t=>e.has(t)):!1}function B(e,n){let t=e.indexOf(n);t!==-1&&e.splice(t,1)}import{existsSync as _,readdirSync as be}from"fs";import{join as R}from"path";var Se={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",T(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",T(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=R(e,"vendor","bin","scip-php"),r=R(e,"vendor","davidrjenni","scip-php","bin","scip-php");return{binary:"php",args:["-d","error_reporting=E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED",_(r)?r:_(t)?t:n]}},defaultOutputPath:"index.scip",markerFiles:["composer.json"],installMethods:[],installUrl:"https://github.com/davidrjenni/scip-php/releases"}};function U(e){return Se[e]}function T(e,n){let t;try{t=be(e)}catch{return null}for(let r of t)if(n.some(a=>r.endsWith(a)))return R(e,r);return null}import{readFileSync as Pe,writeFileSync as ve}from"fs";import{create as D}from"@bufbuild/protobuf";import{deserializeSCIP as Ie,serializeSCIP as ke,DocumentSchema as Re,IndexSchema as De,SymbolInformationSchema as Ce}from"@c4312/scip";function Oe(e){if(e.length===0)throw new Error("Cannot merge zero SCIP indexes");if(e.length===1)return e[0];let n=je(e),t=Le(e.flatMap(a=>a.documents??[])),r=q(e.flatMap(a=>a.externalSymbols??[]));return D(De,{metadata:n,documents:t,externalSymbols:r})}function W(e,n){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let t=e.map(a=>Ie(Pe(a))),r=Oe(t);return ve(n,Buffer.from(ke(r))),{documentCount:r.documents.length,externalSymbolCount:r.externalSymbols.length,inputCount:e.length}}function je(e){let n=e[0]?.metadata;if(!n)return;let t=n.projectRoot;for(let r of e.slice(1)){let a=r.metadata?.projectRoot;if(t&&a&&a!==t)throw new Error(`Cannot merge SCIP indexes with different project roots: ${t} vs ${a}`)}return n}function Le(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,D(Re,{language:r.language||t.language,relativePath:r.relativePath||t.relativePath,occurrences:[...r.occurrences,...t.occurrences],symbols:q([...r.symbols,...t.symbols]),text:Ee(r.text,t.text),positionEncoding:r.positionEncoding||t.positionEncoding}))}return[...n.values()]}function q(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,D(Ce,{symbol:r.symbol,documentation:$e([...r.documentation,...t.documentation]),relationships:we([...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 we(e){let n=new Set,t=[];for(let r of e){let a=[r.symbol,r.isReference?"1":"0",r.isImplementation?"1":"0",r.isTypeDefinition?"1":"0",r.isDefinition?"1":"0"].join("|");n.has(a)||(n.add(a),t.push(r))}return t}function Ee(e,n){return e?n?e.length>=n.length?e:n:e:n}function $e(e){return[...new Set(e)]}import{readFileSync as Be,writeFileSync as Me}from"fs";import{create as z}from"@bufbuild/protobuf";import{deserializeSCIP as Ne,DocumentSchema as Fe,IndexSchema as Ae,serializeSCIP as _e,SymbolRole as Te}from"@c4312/scip";function J(e){let n;try{n=Ne(Be(e))}catch{return{removedDefinitionOccurrences:0,touchedDocuments:0}}let t=Ue(n);return t.removedDefinitionOccurrences>0&&Me(e,Buffer.from(_e(t.index))),{removedDefinitionOccurrences:t.removedDefinitionOccurrences,touchedDocuments:t.touchedDocuments}}function Ue(e){let n=new Set;for(let i of e.documents)for(let s of i.symbols)s.symbol&&n.add(s.symbol);for(let i of e.externalSymbols)i.symbol&&n.add(i.symbol);let t=0,r=0,a=[];for(let i of e.documents){let s=i.occurrences.filter(o=>(o.symbolRoles&Te.Definition)===0||n.has(o.symbol)?!0:(t+=1,!1));if(s.length===i.occurrences.length){a.push(i);continue}r+=1,a.push(z(Fe,{language:i.language,relativePath:i.relativePath,occurrences:s,symbols:i.symbols,text:i.text,positionEncoding:i.positionEncoding}))}return{index:t===0?e:z(Ae,{metadata:e.metadata,documents:a,externalSymbols:e.externalSymbols}),removedDefinitionOccurrences:t,touchedDocuments:r}}import{execFileSync as S}from"child_process";import{existsSync as C,readFileSync as We}from"fs";import{createRequire as qe}from"module";import{platform as H}from"os";import{dirname as G,join as b}from"path";var ze=qe(import.meta.url),Je=H()==="win32";function x(e){let n=Je?"where":"which";try{return S(n,[e],{stdio:"pipe"}),!0}catch{return!1}}function O(e){return[e.indexerBinary,...e.binaryAliases??[]]}function j(e){let n=O(e);return n.length===1?n[0]:n.join(" or ")}function P(e){for(let n of O(e))if(x(n))return n;return He(e)}function X(e){return P(e)!==null||Ge(e)}function Ge(e){return Q(e)!==null}function He(e){let n=Q(e);if(!n)return null;let r=JSON.parse(We(n,"utf8")).bin;if(!r)return null;if(typeof r=="string")return b(G(n),r);for(let a of O(e)){let i=r[a];if(i)return b(G(n),i)}return null}function Q(e){if(!e.bundledNpmPackage)return null;try{return ze.resolve(`${e.bundledNpmPackage}/package.json`)}catch{return null}}function K(e,n){for(let t of e.projectLocalBinaries??[]){let r=b(n,t);if(C(r))return r}return null}function V(e,n=process.env,t=e.indexerBinary){if(e.indexerBinary!=="scip-dotnet"||Z(t,n))return n;let r=Xe(t,n);return r?{...n,DOTNET_ROOT:r}:n}function Y(e,n){let t=e.installMethods,r=j(e);if(!t?.length)return n(`No auto-install method available for ${r}.`),e.installUrl&&n(`Install manually from: ${e.installUrl}`),!1;for(let a of t)if(x(a.prerequisite)){n(`Installing ${r} via ${a.label}...`);try{S(a.binary,a.args,{stdio:"inherit",timeout:3e5,env:process.env});let i=P(e);if(i){let s=i===e.indexerBinary?"":` (using ${i})`;return n(`Successfully installed ${r} via ${a.label}${s}`),!0}n(`${a.label} command completed but ${r} was not found on PATH`)}catch(i){let s=i instanceof Error?i.message:String(i);n(`${a.label} install failed: ${s}`)}}return n(`Could not auto-install ${r}.`),e.installUrl&&n(`Install manually from: ${e.installUrl}`),!1}function Xe(e,n){for(let t of Qe(n))if(Z(e,{...n,DOTNET_ROOT:t}))return t;return null}function Qe(e){let n=[],t=e.DOTNET_ROOT;if(t&&C(t)&&n.push(t),H()==="darwin"&&x("brew"))try{let r=S("brew",["--prefix","dotnet@9"],{stdio:"pipe",env:e}).toString().trim(),a=b(r,"libexec");C(a)&&!n.includes(a)&&n.push(a)}catch{}return n}function Z(e,n){try{return S(e,["--version"],{stdio:"pipe",env:n}),!0}catch{return!1}}async function te(e){let{projectRoot:n,maxHeapMb:t=8192,onStatus:r=console.log,skipAutoInstall:a=!1}=e,i=an(e),s=Date.now();ee(d(i.outputScip),{recursive:!0}),ee(d(i.outputDb),{recursive:!0});let o=e.languages??A(n);if(o.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: ${o.join(", ")}`);let g=On(n,o,{pnpmWorkspaces:e.pnpmWorkspaces}),u=vn(c(d(i.outputDb),"index.lock")),p=null;try{let l=sn({opts:e,paths:i,languages:o,fingerprint:g,start:s,onStatus:r});if(l)return l;pn(a,r);let y=on(i);return p=y.runDir,await un({opts:e,languages:o,projectRoot:n,paths:i,tempPaths:y,fingerprint:g,start:s,maxHeapMb:t,skipAutoInstall:a,onStatus:r})}finally{p&&h(p,{recursive:!0,force:!0}),u()}}function an(e){let n=e.outputScip??c(e.projectRoot,"index.scip"),t=e.outputDb??c(e.projectRoot,"index.db");return{outputScip:n,outputDb:t,metaPath:c(d(t),"meta.json")}}function sn(e){if(e.opts.skipIfUnchanged===!1||!m(e.paths.outputScip)||!m(e.paths.outputDb)||!jn(e.paths.metaPath,e.fingerprint))return null;k({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 on(e){let n=Ze(c(d(e.outputDb),"reindex-"));return{runDir:n,tempOutputScip:c(n,I(e.outputScip)),tempOutputDb:c(n,I(e.outputDb)),tempMetaPath:c(n,I(e.metaPath))}}async function un(e){let n={...process.env,NODE_OPTIONS:`--max-old-space-size=${e.maxHeapMb}`},{indexedOutputs:t,skippedLanguages:r}=await ln(e,n);cn(e,n,t,r);let a=Date.now()-e.start;return e.onStatus(`Done in ${(a/1e3).toFixed(1)}s`),{languages:t.map(i=>i.language),indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:a,reused:!1,skipped:r}}async function ln(e,n){let{preparedRuns:t,skippedLanguages:r}=gn({languages:e.languages,tempOutputScip:e.tempPaths.tempOutputScip,projectRoot:e.projectRoot,env:n,skipAutoInstall:e.skipAutoInstall,pnpmWorkspaces:e.opts.pnpmWorkspaces,onStatus:e.onStatus}),a=await Rn(t,e.projectRoot,e.onStatus,e.opts.indexerConcurrency),{indexedOutputs:i}=mn(a,r);return fn(i,r,e.languages,e.opts.allowPartial,e.onStatus),{indexedOutputs:i,skippedLanguages:r}}function cn(e,n,t,r){hn(t,e.tempPaths.tempOutputScip,e.onStatus),xn(e.tempPaths.tempOutputScip,e.tempPaths.tempOutputDb,n,e.onStatus),k({projectRoot:e.projectRoot,dbPath:e.tempPaths.tempOutputDb,onStatus:e.onStatus}),Ln(e.tempPaths.tempMetaPath,{version:2,status:r.length===0?"complete":"partial",updatedAt:new Date().toISOString(),fingerprint:e.fingerprint,requestedLanguages:e.languages,indexedLanguages:t.map(a=>a.language),skipped:[...r]}),In({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 pn(e,n){if(!x("scip")){if(e)throw new Error(`The scip CLI is required but not found on PATH.
3
+ Install from: https://github.com/sourcegraph/scip/releases`);if(n("scip CLI not found on PATH. Attempting auto-install..."),!E(n))throw new Error(`The scip CLI is required but could not be installed.
4
+ Install manually from: https://github.com/sourcegraph/scip/releases`)}}function gn(e){let n=[],t=[],r=e.languages.map((a,i)=>({language:a,scipPath:e.languages.length>1?Pn(e.tempOutputScip,a,i):e.tempOutputScip}));for(let{language:a,scipPath:i}of r){let s=dn({...e,language:a,scipPath:i});"skipped"in s?t.push(s.skipped):n.push(s.prepared)}return{preparedRuns:n,skippedLanguages:t}}function dn(e){let n=U(e.language),t=j(n),r=K(n,e.projectRoot);if(!r&&!X(n)){if(e.skipAutoInstall){let o=`${t} not found on PATH (auto-install disabled). ${n.installUrl??""}`.trim();return e.onStatus(`Skipping ${e.language}: ${o}`),{skipped:{language:e.language,reason:o}}}if(e.onStatus(`${t} not found. Attempting auto-install...`),!Y(n,e.onStatus)){let o=`${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}: ${o}`),{skipped:{language:e.language,reason:o}}}}let a=r??P(n);if(!a){let o=`${t} was not found after installation checks.`;return e.onStatus(`Skipping ${e.language}: ${o}`),{skipped:{language:e.language,reason:o}}}let{binary:i,args:s}=n.indexArgs({projectRoot:e.projectRoot,outputPath:e.scipPath,pnpmWorkspaces:e.pnpmWorkspaces,indexerBinary:a});return{prepared:{language:e.language,scipPath:e.scipPath,config:n,resolvedBinary:a,binary:i,args:s,env:V(n,e.env,a)}}}function mn(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 fn(e,n,t,r,a){if(e.length===0){let i=n.map(s=>` - ${s.language}: ${s.reason}`).join(`
63
5
  `);throw new Error(`No language indexers ran successfully. Install at least one indexer for the languages in this project.
64
- `+o)}if(u.length>0&&t(`Indexed ${p.length} of ${c.length} languages; skipped ${u.map(o=>o.language).join(", ")}.`),c.length>1&&(p.length>1?(t(`Merging ${p.length} language indexes...`),J(p.map(o=>o.scipPath),s)):p[0].scipPath!==s&&ce(p[0].scipPath,s)),t("Converting to SQLite..."),!le(s))throw new Error(`SCIP index not found at ${s} after indexing`);try{ae("scip",["expt-convert","--output",a,s],{env:h,stdio:"pipe",maxBuffer:50*1024*1024})}catch(o){let m=o instanceof Error?o.message:String(o);throw new Error(`Failed to convert SCIP index to SQLite: ${m}`,{cause:o})}finally{for(let{scipPath:o}of f)o!==s&&un(o,{force:!0})}V({projectRoot:n,dbPath:a,onStatus:t});let v=Date.now()-l;return t(`Done in ${(v/1e3).toFixed(1)}s`),{languages:p.map(o=>o.language),indexPath:s,dbPath:a,durationMs:v,skipped:u}}function mn(e,n,r){if(!e.defaultOutputPath)return;let t=C(n,e.defaultOutputPath);r!==t&&le(t)&&ce(t,r)}function fn(e,n,r){let t=dn(e)||".scip",i=pn(e,t);return C(gn(e),`${i}.${r+1}.${n}${t}`)}var de=process.env.SCIP_REINDEX_PROJECT_ROOT,me=process.env.SCIP_REINDEX_OUTPUT_SCIP,fe=process.env.SCIP_REINDEX_OUTPUT_DB,pe=process.env.SCIP_REINDEX_LANGUAGES,hn=process.env.SCIP_REINDEX_PNPM_WORKSPACES==="1";(!de||!me||!fe)&&(console.error("reindex-worker: missing required env vars"),process.exit(1));var ge=pe?pe.split(",").filter(Boolean):void 0;ue({projectRoot:de,outputScip:me,outputDb:fe,languages:ge?.length?ge:void 0,pnpmWorkspaces:hn,onStatus:e=>process.stderr.write(`[reindex] ${e}
6
+ `+i)}if(n.length!==0&&(a(`Indexed ${e.length} of ${t.length} languages; skipped ${n.map(i=>i.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.
7
+ `+n.map(i=>` - ${i.language}: ${i.reason}`).join(`
8
+ `))}function hn(e,n,t){e.length>1?(t(`Merging ${e.length} language indexes...`),W(e.map(r=>r.scipPath),n)):e[0].scipPath!==n&&f(e[0].scipPath,n)}function xn(e,n,t,r){if(r("Converting to SQLite..."),!m(e))throw new Error(`SCIP index not found at ${e} after indexing`);try{let a=J(e);a.removedDefinitionOccurrences>0&&r(`Sanitized ${a.removedDefinitionOccurrences} invalid definition occurrences across ${a.touchedDocuments} documents before SQLite conversion.`),Ve("scip",["expt-convert","--output",n,e],{env:t,stdio:"pipe",maxBuffer:50*1024*1024})}catch(a){let i=a instanceof Error?a.message:String(a);throw new Error(`Failed to convert SCIP index to SQLite: ${i}`,{cause:a})}}function yn(e,n,t){if(!e.defaultOutputPath)return;let r=c(n,e.defaultOutputPath);t!==r&&m(r)&&f(r,t)}function bn(e,n,t){if(!e.defaultOutputPath)return null;let r=c(n,e.defaultOutputPath);if(r===t)return null;let a=`${t}.default-output-backup`;return h(a,{force:!0}),m(r)?(f(r,a),{defaultOutputPath:r,backupPath:a}):{defaultOutputPath:r,backupPath:null}}function Sn(e){e&&(h(e.defaultOutputPath,{force:!0}),e.backupPath&&m(e.backupPath)&&f(e.backupPath,e.defaultOutputPath))}function Pn(e,n,t){let r=rn(e)||".scip",a=I(e,r);return c(d(e),`${a}.${t+1}.${n}${r}`)}function vn(e){let n;try{n=en(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 ${d(e)}.`,{cause:t}):t}return ne(n,JSON.stringify({pid:process.pid,startedAt:new Date().toISOString()})+`
9
+ `),()=>{try{Ye(n)}finally{h(e,{force:!0})}}}function In(e){L(e.tempOutputScip,e.outputScip),L(e.tempOutputDb,e.outputDb),L(e.tempMetaPath,e.metaPath)}function L(e,n){h(`${n}.tmp-replace`,{force:!0}),f(e,`${n}.tmp-replace`),f(`${n}.tmp-replace`,n)}function kn(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,tn().length-1));return Math.max(1,Math.min(e,Math.floor(r)))}async function Rn(e,n,t,r){let a=e.filter(u=>u.config.defaultOutputPath),i=e.filter(u=>!u.config.defaultOutputPath),s=[],o=kn(i.length,r),g=await Cn(i,o,u=>w(u,n,t));if(o>1){let u=new Map;for(let p of g.filter(l=>l.skipped)){let l=i.find(y=>y.language===p.language);l&&(t(`Retrying ${l.language} indexer serially after parallel failure...`),u.set(l.language,await w(l,n,t)))}s.push(...g.map(p=>u.get(p.language)??p))}else s.push(...g);for(let u of a)s.push(await w(u,n,t));return s.sort((u,p)=>e.findIndex(l=>l.language===u.language)-e.findIndex(l=>l.language===p.language))}async function w(e,n,t){t(`Indexing ${e.language} with ${e.resolvedBinary}...`),h(e.scipPath,{force:!0});let r=bn(e.config,n,e.scipPath);try{await Dn(e.binary,e.args,{cwd:n,env:e.env,maxBuffer:50*1024*1024}),yn(e.config,n,e.scipPath)}catch(a){let i=a instanceof Error?a.message:String(a),s=`${e.resolvedBinary} indexer failed: ${i.split(`
10
+ `)[0]}`;return t(`Skipping ${e.language}: ${s}`),{language:e.language,scipPath:e.scipPath,skipped:{language:e.language,reason:s}}}finally{Sn(r)}if(!m(e.scipPath)){let a=`${e.resolvedBinary} indexer completed but did not produce ${e.scipPath}`;return t(`Skipping ${e.language}: ${a}`),{language:e.language,scipPath:e.scipPath,skipped:{language:e.language,reason:a}}}return{language:e.language,scipPath:e.scipPath}}function Dn(e,n,t){return new Promise((r,a)=>{Ke(e,[...n],t,i=>{i?a(i):r()})})}async function Cn(e,n,t){if(e.length===0)return[];let r=new Array(e.length),a=0,i=Math.max(1,Math.min(e.length,n)),s=Array.from({length:i},async()=>{for(;a<e.length;){let o=a++;r[o]=await t(e[o])}});return await Promise.all(s),r}function On(e,n,t){return{version:1,languages:[...n].sort(),pnpmWorkspaces:t.pnpmWorkspaces===!0,files:$(e)}}function jn(e,n){try{let t=JSON.parse(nn(e,"utf-8"));return t.version===2&&t.status==="complete"&&v(t.fingerprint)===v(n)&&v([...t.indexedLanguages??[]].sort())===v(n.languages)}catch{return!1}}function Ln(e,n){ne(e,`${JSON.stringify(n,null,2)}
11
+ `)}function v(e){return JSON.stringify(e)}var ie=process.env.SCIP_REINDEX_PROJECT_ROOT,se=process.env.SCIP_REINDEX_OUTPUT_SCIP,oe=process.env.SCIP_REINDEX_OUTPUT_DB,re=process.env.SCIP_REINDEX_LANGUAGES,wn=process.env.SCIP_REINDEX_PNPM_WORKSPACES==="1";(!ie||!se||!oe)&&(console.error("reindex-worker: missing required env vars"),process.exit(1));var ae=re?re.split(",").filter(Boolean):void 0;te({projectRoot:ie,outputScip:se,outputDb:oe,languages:ae?.length?ae:void 0,pnpmWorkspaces:wn,onStatus:e=>process.stderr.write(`[reindex] ${e}
65
12
  `)}).then(()=>{process.exit(0)}).catch(e=>{console.error(`reindex-worker error: ${e}`),process.exit(1)});
66
13
  //# sourceMappingURL=reindex-worker.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scip-query",
3
- "version": "0.6.4",
3
+ "version": "0.6.5",
4
4
  "description": "Language-agnostic code intelligence CLI powered by SCIP indexes",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -35,6 +35,7 @@
35
35
  "test:watch": "vitest",
36
36
  "typecheck": "tsc --noEmit",
37
37
  "lint": "eslint src/",
38
+ "calibrate": "node scripts/accuracy-calibration.mjs",
38
39
  "prepublishOnly": "npm run build",
39
40
  "postinstall": "node dist/postinstall.js || true"
40
41
  },
@@ -64,7 +65,8 @@
64
65
  "@c4312/scip": "^0.1.0",
65
66
  "better-sqlite3": "^12.9.0",
66
67
  "commander": "^13.1.0",
67
- "ignore": "^7.0.3"
68
+ "ignore": "^7.0.3",
69
+ "ts-morph": "^28.0.0"
68
70
  },
69
71
  "//optionalDependencies": "Native parsers and bundled SCIP indexers go in optionalDependencies so a failed install (missing build tools, restricted registry, incompatible platform) downgrades scip-query gracefully — the affected language falls back to regex parsing or asks the user to install its indexer manually — instead of blocking npm install.",
70
72
  "optionalDependencies": {
@@ -1,19 +0,0 @@
1
- import{b as v}from"./chunk-ZZ3F6P3X.js";import{a as $}from"./chunk-QID23O53.js";import{b as y,f as S,g as I}from"./chunk-FT4WPAEX.js";import{e as k}from"./chunk-NKU7Z242.js";import{f as _}from"./chunk-QL5MJOVA.js";import g from"path";function J(t,r){let{scope:s}=r??{},l=I(t,s),n=O(t,s),c=[];for(let[e,a]of l){if(m(e))continue;let u=n.get(e)??new Set;for(let o of a)if(!m(o)&&!u.has(o)){if(E(o)||R(t,e,o))continue;c.push({file:e,kind:"unused-import",description:`Depends on ${o} but references none of its symbols`,dep:o})}}let i=D(l);for(let[e,a]of l){if(m(e))continue;let u=h(e);for(let o of a){if(m(o))continue;let f=h(o);if(u===f)continue;i.get(`${u}->${f}`)==="violation"&&c.push({file:e,kind:"layer-violation",description:`Imports from ${f}/ (${o}) \u2014 may cross architectural boundary`,dep:o,detail:`${u}/ should not depend on ${f}/`})}}let p=new Map;for(let e of l.keys()){let a=g.dirname(e);p.has(a)||p.set(a,[]),p.get(a).push(e)}for(let[e,a]of p){let u=a.filter(f=>!m(f));if(u.length<5)continue;let o=new Map;for(let f of u)for(let d of l.get(f)??[])m(d)||o.set(d,(o.get(d)??0)+1);for(let f of u)for(let d of l.get(f)??[])m(d)||(o.get(d)??0)===1&&g.dirname(d)!==e&&g.dirname(d)!==g.dirname(e)&&c.push({file:f,kind:"pattern-deviation",description:`Only file in ${e}/ that depends on ${d}`,dep:d})}return{results:c,unusedImports:c.filter(e=>e.kind==="unused-import").length,layerViolations:c.filter(e=>e.kind==="layer-violation").length,patternDeviations:c.filter(e=>e.kind==="pattern-deviation").length}}function O(t,r){let s=r?`AND d1.relative_path LIKE '%${r}%'`:"",l=t.all(`SELECT DISTINCT d1.relative_path AS from_file, d2.relative_path AS to_file
2
- FROM mentions m
3
- JOIN chunks c ON m.chunk_id = c.id
4
- JOIN documents d1 ON c.document_id = d1.id
5
- JOIN global_symbols gs ON m.symbol_id = gs.id
6
- JOIN (
7
- SELECT m2.symbol_id, c2.document_id
8
- FROM mentions m2
9
- JOIN chunks c2 ON m2.chunk_id = c2.id
10
- WHERE m2.role = 1
11
- GROUP BY m2.symbol_id
12
- ) sym_def ON sym_def.symbol_id = gs.id
13
- JOIN documents d2 ON sym_def.document_id = d2.id
14
- WHERE d1.id != d2.id
15
- AND m.role != 1
16
- ${t.pathExclusionsFor("d1","d2")}
17
- ${s}`),n=new Map;for(let i of l)t.isIgnored(i.from_file)||t.isIgnored(i.to_file)||(n.has(i.from_file)||n.set(i.from_file,new Set),n.get(i.from_file).add(i.to_file));let c=t.all(`SELECT relative_path FROM documents
18
- WHERE 1 = 1 ${t.pathExclusionsFor("documents")}`);for(let i of c){if(t.isIgnored(i.relative_path)||!_(i.relative_path))continue;let p=S(t,i.relative_path),e=n.get(i.relative_path);for(let a of p.keys()){let u=v(t,i.relative_path,a);for(let o of u)o.relativePath!==i.relative_path&&(t.isIgnored(o.relativePath)||(e||(e=new Set,n.set(i.relative_path,e)),e.add(o.relativePath)))}if(_(i.relative_path)==="rust"){let a=y(t,i.relative_path);for(let u of a){let o=v(t,i.relative_path,u);for(let f of o)f.relativePath!==i.relative_path&&(t.isIgnored(f.relativePath)||(e||(e=new Set,n.set(i.relative_path,e)),e.add(f.relativePath)))}}}return n}function D(t){let r=new Map,s=new Set;for(let[n,c]of t){if(m(n))continue;let i=h(n);s.add(i);for(let p of c){if(m(p))continue;let e=h(p);if(i===e)continue;s.add(e);let a=`${i}->${e}`;r.set(a,(r.get(a)??0)+1)}}let l=new Map;for(let[n,c]of r)l.set(n,c<=2?"violation":"ok");return l}function h(t){let s=t.replace(/\\/g,"/").split("/").filter(Boolean);return s.length<=1?"(root)":s.length>=3&&["src","lib","app","server","client"].includes(s[0])?`${s[0]}/${s[1]}`:s[0]}function E(t){return t.includes("types")||t.endsWith(".d.ts")}function R(t,r,s){let l=k(t,r).filter(n=>n.sourcePath===s);return l.length===0?!1:l.every(n=>n.kind==="side-effect"||n.kind==="namespace"&&n.usedMembers.length===0&&!n.used)}function m(t){let r=$(t);return!!(r==="entry"||r==="barrel"||r==="test"||r==="worker"||N(g.basename(t)))}function N(t){return!!(t==="index.ts"||t==="index.js"||t==="cli.ts"||t==="main.ts"||t==="main.rs"||t.includes("worker.")||t.includes("postinstall.")||t==="health.ts"||t==="health.js")}export{J as a};
19
- //# sourceMappingURL=chunk-2DQK2IDZ.js.map
@@ -1,6 +0,0 @@
1
- import{a as c}from"./chunk-MWCN46ZX.js";import{existsSync as m}from"fs";import{basename as p,isAbsolute as f,join as g}from"path";function S(e,r){let t=u(e,r,{allowMultiple:!1})[0]?.relativePath;return t||v(e,r)}function M(e,r){return u(e,r,{allowMultiple:!0}).map(t=>t.relativePath)}function v(e,r){if(!r)return null;let t=r.replace(/\\/g,"/").replace(/^\.\//,""),a=f(t)&&t.startsWith(e.config.projectRoot)?t.slice(e.config.projectRoot.length).replace(/^\/+/,""):t,n=g(e.config.projectRoot,a);return m(n)?a:null}function u(e,r,t){let a=h(r);if(!a)return[];let i=e.all(`SELECT relative_path
2
- FROM documents
3
- WHERE 1 = 1
4
- ${e.pathExclusionsFor("documents")}
5
- ORDER BY relative_path`).filter(o=>!e.isIgnored(o.relative_path)).map(o=>({relativePath:o.relative_path,score:d(o.relative_path,a)})).filter(o=>o.score>0).sort((o,l)=>l.score-o.score||o.relativePath.localeCompare(l.relativePath));if(i.length===0){let o=c(e,r);return!o||e.isIgnored(o.relativePath)?[]:[{relativePath:o.relativePath,score:700}]}let s=i.filter(o=>o.score>=800);return s.length>0?t.allowMultiple?s:[s[0]]:t.allowMultiple?i:[i[0]]}function d(e,r){let t=h(e),a=p(t),n=p(r),i=0;return t===r&&(i+=1200),t.endsWith(`/${r}`)&&(i+=1100),a===n&&(i+=900),t.startsWith(`${r}/`)&&(i+=850),t.includes(r)&&(i+=250),i}function h(e){return e.trim().replace(/\\/g,"/").replace(/^\.\//,"").replace(/^\/+/,"").replace(/\/+$/,"")}export{S as a,M as b};
6
- //# sourceMappingURL=chunk-4HCKXL7T.js.map
@@ -1,2 +0,0 @@
1
- import{a as p,b as d}from"./chunk-QID23O53.js";import{g as B}from"./chunk-FT4WPAEX.js";function w(s,e={}){let{scope:r,maxDepth:c=10}=e,n=B(s,r),i=[],l=new Set,a=new Set,f=[];function g(t,o){if(o>c)return;if(a.has(t)){let h=f.indexOf(t);if(h!==-1){let u=f.slice(h).concat(t),m=u.indexOf(u.reduce(($,x)=>$<x?$:x)),y=[...u.slice(m,-1),...u.slice(0,m),u[m]],S=y.join(" -> ");b.has(S)||(b.add(S),i.push({path:y,kind:R(y)}))}return}if(l.has(t))return;l.add(t),a.add(t),f.push(t);let k=n.get(t);if(k)for(let h of k)g(h,o+1);f.pop(),a.delete(t)}let b=new Set;for(let t of n.keys())l.has(t)||g(t,0);return i.sort((t,o)=>t.kind!==o.kind?t.kind==="real"?-1:1:t.path.length-o.path.length),i}function R(s){for(let c of s){let n=p(c);if(n==="test"||n==="barrel"||n==="entry")return"module-hierarchy"}if(s.length!==3)return"real";let[e,r]=s;return!e||!r?"real":d(e)||d(r)||C(e,r)||C(r,e)||D(e,r)||D(r,e)||p(e)==="entry"||p(r)==="entry"?"module-hierarchy":"real"}function C(s,e){if(!/\.rs$/.test(s)||!/\.rs$/.test(e))return!1;let r=e.replace(/\.rs$/,"/");return s.startsWith(r)?!s.slice(r.length).includes("/"):!1}function D(s,e){if(!/\.rs$/.test(s)||!/\.rs$/.test(e))return!1;let r=s.replace(/\.rs$/,""),c=e.replace(/\.rs$/,"");if(r===c+"_tests"||r===c+"/tests")return!0;let n=s.split("/"),i=e.split("/");if(n.length===i.length&&n.includes("tests")&&i.includes("src")){let l=n[n.length-1],a=i[i.length-1];if(l&&l===a)return!0}return!1}export{w as a};
2
- //# sourceMappingURL=chunk-4Q2D5BMS.js.map
@@ -1,2 +0,0 @@
1
- var d={"/":"namespace","#":"type",".":"term","[":"type-param",":":"meta","!":"macro"};function l(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 s=t[0],i=t[1],r=e.slice(s.length+1+i.length+1),n;if(r.startsWith("`")){let f=r.indexOf("`",1);f===-1?(n=r.slice(1),r=""):(n=r.slice(1,f),r=r.slice(f+2))}else{let f=r.indexOf(" ");f===-1?(n=r,r=""):(n=r.slice(0,f),r=r.slice(f+1))}let c,o=r.indexOf(" ");o===-1?(c=r,r=""):(c=r.slice(0,o),r=r.slice(o+1));let a=m(r);return{scheme:s,manager:i,packageName:n,version:c,descriptors:a,raw:e}}function m(e){let t=[],s=0;for(;s<e.length;){if(e[s]==="["){let n=e.indexOf("]",s+1);if(n===-1){t.push({name:e.slice(s+1),suffix:"type-param"});break}t.push({name:e.slice(s+1,n),suffix:"type-param"}),s=n+1;continue}if(e[s]==="("&&(t.length===0||s===0||u(e[s-1]))){let n=e.indexOf(")",s+1);if(n!==-1&&e[n+1]!=="."){t.push({name:e.slice(s+1,n),suffix:"parameter"}),s=n+1;continue}}let i;if(e[s]==="`"){let n=e.indexOf("`",s+1);if(n===-1){i=e.slice(s+1),t.push({name:i,suffix:"term"});break}i=e.slice(s+1,n),s=n+1}else{let n=s;for(;s<e.length&&!u(e[s]);)s++;i=e.slice(n,s)}if(s>=e.length){i&&t.push({name:i,suffix:"term"});break}let r=e[s];if(r==="("){let n=e.indexOf(")",s+1);n!==-1&&e[n+1]==="."?(t.push({name:i,suffix:"method"}),s=n+2):n!==-1?(t.push({name:i,suffix:"method"}),s=n+1):(t.push({name:i,suffix:"term"}),s++)}else{let n=d[r];n&&t.push({name:i,suffix:n}),s+=1}}return t}function u(e){return e==="/"||e==="#"||e==="."||e==="("||e==="["||e===":"||e==="!"}function x(e){let t=l(e);if("kind"in t&&t.kind==="local")return`local:${t.id}`;let s=t;if(s.descriptors.length===0)return s.raw;let i=[];for(let r of s.descriptors){let n=r.name;r.suffix==="namespace"&&(n=n.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)$/,"")),n&&(r.suffix==="method"?i.push(`${n}()`):i.push(n))}return i.join(":")}function S(e){let t=l(e);if("kind"in t&&t.kind==="local")return t.id;let s=t;return s.descriptors.length===0?"":s.descriptors[s.descriptors.length-1].name}function p(e){let t=l(e);if("kind"in t&&t.kind==="local")return null;let s=t;return s.descriptors[s.descriptors.length-1]?.suffix??null}function b(e){return e.endsWith("().")||p(e)==="method"}function y(e){let t=p(e);return t==="method"||t==="term"}function k(e){return p(e)==="namespace"}var h=/^rust-analyzer\b.*[\s/]impl#\[[^\]]+\]\[[^\]]+\]/;function D(e){return h.test(e)}var g=new Set(["test","tests","_tests"]);function $(e){let t=l(e);if("kind"in t)return!1;for(let s=0;s<t.descriptors.length-1;s+=1){let i=t.descriptors[s];if(i?.suffix==="namespace"&&i.name&&g.has(i.name))return!0}return!1}function T(e,t){let s=l(e),i=l(t);if("kind"in s||"kind"in i)return!1;let r=s.descriptors,n=i.descriptors;if(n.length!==r.length+1)return!1;for(let c=0;c<r.length;c++){let o=r[c],a=n[c];if(o.name!==a.name||o.suffix!==a.suffix)return!1}return!0}function M(e,t){let s=l(e),i=l(t);if("kind"in s||"kind"in i)return!1;let r=s.descriptors,n=i.descriptors;if(n.length<=r.length)return!1;for(let c=0;c<r.length;c++){let o=r[c],a=n[c];if(o.name!==a.name||o.suffix!==a.suffix)return!1}return!0}export{l as a,x as b,S as c,p as d,b as e,y as f,k as g,D as h,$ as i,T as j,M as k};
2
- //# sourceMappingURL=chunk-5IM4IQ6N.js.map
@@ -1,6 +0,0 @@
1
- import{a as w,b as h,d as R,e as N}from"./chunk-LORWXBOO.js";import{a as P}from"./chunk-QID23O53.js";import{h as T,k as j}from"./chunk-FT4WPAEX.js";import{a as A}from"./chunk-MWCN46ZX.js";import{d as D,e as L,l as z,q as $,r as B}from"./chunk-QL5MJOVA.js";import{b,c as q,f as F,i as x}from"./chunk-5IM4IQ6N.js";function ae(i,e,r={}){let{minSimilarity:s=.4,limit:l=20}=r,o=U(i,e);if(!o)return[];if(!F(o.symbol))return[];let n=K(i,o,s);return n.length>0?n.slice(0,l):G(i,e,{minSimilarity:s,limit:l})}function K(i,e,r){let s=E(i,{minCallees:3,excludeSymbol:e.symbol}),l=R([e,...s].map(n=>n.callees)),o=[];for(let n of s){if(n.callees.size<3)continue;let t=I(e,n,l,{minSimilarity:r,requireSignificantShared:1,requireSharedCount:0});t&&o.push(t)}return o.sort((n,t)=>t.similarity-n.similarity),o}function I(i,e,r,s){let{similarity:l,significantShared:o}=N(i.callees,e.callees,r);if(l<s.minSimilarity)return null;let n=w(i.callees,e.callees).size;if(o.length<s.requireSignificantShared&&n<s.requireSharedCount)return null;let t=o.length>0?o:[...w(i.callees,e.callees)];return{symbolA:i.symbol,shortNameA:b(i.symbol),fileA:i.file,symbolB:e.symbol,shortNameB:b(e.symbol),fileB:e.file,similarity:l,sharedCallees:t.map(b),uniqueToA:[...h(i.callees,e.callees)].map(b),uniqueToB:[...h(e.callees,i.callees)].map(b)}}function me(i,e={}){let{minSimilarity:r=.5,limit:s=20,scope:l,minCallees:o=4,crossFileOnly:n=!1}=e,t=E(i,{minCallees:o,scope:l}),c=R(t.map(a=>a.callees)),u=new Map;for(let a of t)for(let m of a.callees)u.set(m,(u.get(m)??0)+1);let f=Math.max(8,Math.ceil(Math.sqrt(t.length))),S=new Map;for(let a=0;a<t.length;a+=1)for(let m of t[a].callees){if((u.get(m)??0)>f)continue;let g=S.get(m);g||(g=[],S.set(m,g)),g.push(a)}let C=[],v=new Set;e:for(let a=0;a<t.length;a+=1){let m=t[a],g=new Set;for(let k of m.callees){let y=S.get(k);if(y)for(let p of y)p>a&&g.add(p)}for(let k of g){let y=`${a}|${k}`;if(v.has(y))continue;v.add(y);let p=t[k];if(n&&m.file===p.file)continue;if(m.paramCount>=0&&p.paramCount>=0){let _=Math.abs(m.paramCount-p.paramCount),W=Math.max(2,Math.ceil(Math.max(m.paramCount,p.paramCount)*.5));if(_>W)continue}let M=I(m,p,c,{minSimilarity:r,requireSignificantShared:2,requireSharedCount:4});if(M&&(C.push(M),C.length>s*5))break e}}return C.sort((a,m)=>m.similarity-a.similarity),C.slice(0,s)}function U(i,e){let r=A(i,e);if(!r)return null;let s=T(i,r);return{symbol:r.symbol,file:r.relativePath,callees:new Set(s.map(l=>l.symbol)),paramCount:z(i,r.relativePath,r.startLine,r.endLine)?.paramCount??-1}}function E(i,e){let{minCallees:r,scope:s,excludeSymbol:l}=e,o=B(i,s).filter(t=>!i.isIgnored(t.relativePath)).filter(t=>t.isFunctionLike).filter(t=>l===void 0||t.symbol!==l).filter(t=>t.endLine-t.startLine+1>=5).filter(t=>P(t.relativePath)!=="test").filter(t=>!x(t.symbol)).filter(t=>!L(i,t.relativePath,t.startLine)),n=j(i,o);return o.map(t=>({symbol:t.symbol,file:t.relativePath,callees:new Set((n.get(t.symbolId)??[]).map(c=>c.symbol)),paramCount:z(i,t.relativePath,t.startLine,t.endLine)?.paramCount??-1})).filter(t=>t.callees.size>=r)}function G(i,e,r){let s=H(i,e);if(!s||s.tokens.size<3)return[];let l=r.minSimilarity>=.5?r.minSimilarity:.3,o=[];for(let n of Q(i)){if(n.symbol===s.symbol||n.tokens.size<3)continue;let t=w(s.tokens,n.tokens);if(t.size<2)continue;let c=new Set([...s.tokens,...n.tokens]),u=c.size>0?t.size/c.size:0;u<l||o.push({symbolA:s.symbol,shortNameA:b(s.symbol),fileA:s.file,symbolB:n.symbol,shortNameB:b(n.symbol),fileB:n.file,similarity:u,sharedCallees:[...t].sort(),uniqueToA:[...h(s.tokens,n.tokens)].sort(),uniqueToB:[...h(n.tokens,s.tokens)].sort()})}return o.sort((n,t)=>t.similarity-n.similarity||n.shortNameB.localeCompare(t.shortNameB)),o.slice(0,r.limit)}function H(i,e){let r=A(i,e);if(!r||!F(r.symbol))return null;let s=J(i,r);return s?{symbol:r.symbol,file:r.relativePath,tokens:s}:null}function J(i,e){let r=q(e.symbol),s=O(i,e.relativePath,e.startLine,e.endLine,r),l=Z(s,r);return l.size>0?l:null}function Q(i){return $(i).filter(e=>e.isFunctionLike).filter(e=>P(e.relativePath)!=="test").filter(e=>!x(e.symbol)).map(e=>({symbol:e.symbol,file:e.relativePath,tokens:Z(O(i,e.relativePath,e.startLine,e.endLine,e.leaf),e.leaf)})).filter(e=>e.tokens.size>0)}function O(i,e,r,s,l){let o=D(i,e);if(!o)return"";let n=o.split(`
2
- `);if(s>=r&&s-r<=12)return n.slice(r,s+1).join(`
3
- `);let t=[new RegExp(`\\bdef\\s+${d(l)}\\b`),new RegExp(`\\bfun\\s+${d(l)}\\b`),new RegExp(`\\bfn\\s+${d(l)}\\b`),new RegExp(`\\bfunction\\s+${d(l)}\\b`),new RegExp(`\\b${d(l)}\\s*\\(`)],c=n.findIndex(u=>t.some(f=>f.test(u)));if(c>=0){let u=c;for(let f=c+1;f<n.length&&f<=c+8;f++){let S=n[f]??"";if(f>c&&X(S)||(u=f,S.trim()===""&&f>c+1))break}return n.slice(c,u+1).join(`
4
- `)}return n.slice(r,Math.min(n.length,r+8)).join(`
5
- `)}function Z(i,e){if(!i)return new Set;let r=new Set(["public","private","protected","final","static","class","def","fun","fn","function","return","string","bool","boolean","void","unit","self","this","new","const","let","var","end","pub"]),s=V(e),o=i.replace(/["'`]/g," ").replace(/\b\d+\b/g," NUM ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[^A-Za-z0-9_]+/g," ").replace(/_/g," ").toLowerCase().split(/\s+/).map(n=>n.trim()).filter(n=>n.length>1).filter(n=>!r.has(n)).filter(n=>!s.has(n));return new Set(o)}function V(i){return new Set(i.replace(/([a-z0-9])([A-Z])/g,"$1 $2").split(/[^A-Za-z0-9_]+|_/).map(e=>e.toLowerCase()).filter(e=>e.length>1))}function X(i){return/^\s*(?:def|fun|fn|function|class|trait|module|object|enum|interface|public|private|protected)\b/.test(i)}function d(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}export{ae as a,me as b};
6
- //# sourceMappingURL=chunk-5NSYCQWM.js.map
@@ -1,2 +0,0 @@
1
- import{a as m}from"./chunk-MWCN46ZX.js";import{p as l}from"./chunk-QL5MJOVA.js";import{c as r,e as a}from"./chunk-5IM4IQ6N.js";import{basename as p}from"path";function M(t,c){let o=m(t,c);if(!o)return[];let s=r(o.symbol),i=l(t,o.relativePath).filter(e=>a(e.symbol)),n=i.filter(e=>e.parentTypeName===s||e.symbol.includes(s));return(n.length>0?n:f(p(o.relativePath))===s?i.filter(e=>e.symbol.includes("<invalid-global-code>")):[]).map(e=>({startLine:e.startLine,endLine:e.endLine,name:r(e.symbol)}))}function f(t){return t.replace(/\.[^.]+$/,"")}export{M as a};
2
- //# sourceMappingURL=chunk-6QKHOBC6.js.map
@@ -1,5 +0,0 @@
1
- import{d as T}from"./chunk-ZZ3F6P3X.js";import{m as I}from"./chunk-FT4WPAEX.js";import{d as k}from"./chunk-NKU7Z242.js";import{a as M,d as y,e as D,f as P,h as w,j as A,r as C}from"./chunk-QL5MJOVA.js";import{a as x,b as F,c as b}from"./chunk-5IM4IQ6N.js";function ie(t,s){let{scope:n,minLoc:r=3,maxLoc:i=80,limit:o=30,includeLowConfidence:c=!1}=s??{},a=E(t,n),l=C(t,n).filter(e=>e.isTypeLike&&L(e)>=r).filter(e=>L(e)<=i).filter(e=>!t.isIgnored(e.relativePath)).filter(e=>!$(e.symbol)).filter(e=>!D(t,e.relativePath,e.startLine)),f=I(t,l),u=T(t,l),g=q(f,u),d=new Map;for(let e of l){let m=d.get(e.relativePath);m||(m=new Map,d.set(e.relativePath,m));let p=b(e.symbol);p&&m.set(p,e)}return l.map(e=>{let p=[...g.get(e.symbolId)??new Set].filter(v=>v!==e.relativePath&&!t.isIgnored(v)),{realConsumers:h,barrelConsumers:S}=O(t,e.relativePath,e.symbol,p),R=U(t,e,g,d);return{definition:e,realConsumers:h,barrelConsumers:S,transitivelyReachable:R}}).filter(e=>!e.transitivelyReachable).filter(e=>e.realConsumers.length<=1).filter(e=>!(e.realConsumers.length===0&&e.barrelConsumers>0)).filter(e=>N(e.definition,e.realConsumers.length,a)).map(e=>{let m=G(t,e.definition.relativePath,e.definition.startLine),p=_(e.definition.relativePath)?!0:H(t,e.definition),{confidence:h,reason:S}=K(e.realConsumers.length,m,p);return{symbol:e.definition.symbol,shortName:F(e.definition.symbol),file:e.definition.relativePath,startLine:e.definition.startLine,endLine:e.definition.endLine,loc:L(e.definition),consumers:e.realConsumers.length,barrelConsumers:e.barrelConsumers,kind:m,definerUsesType:p,confidence:h,reason:S}}).filter(e=>c||e.confidence!=="low").sort((e,m)=>{let p={high:0,medium:1,low:2};return p[e.confidence]-p[m.confidence]||m.loc-e.loc||e.file.localeCompare(m.file)||e.startLine-m.startLine}).slice(0,o)}function E(t,s){return new Set(C(t,s).filter(n=>n.isFunctionLike).map(n=>n.relativePath))}function $(t){let s=x(t);if("kind"in s)return!1;let n=s.descriptors;if(n.length<2)return!1;let r=n[n.length-1],i=n[n.length-2];return r?.suffix==="type"&&i?.suffix==="type"}function _(t){let n=(t.split("/").pop()??"").replace(/\.[^.]+$/,"");return!!(n==="types"||n==="models"||n==="schema"||n==="common"||n==="protocol"||n==="proto"||n==="dto"||n==="mod"||/(^|\/)types(\/|\.)/.test(t)||/(^|\/)models?(\/|\.)/.test(t)||/(^|\/)proto(?:col)?(\/|\.)/.test(t)||/(^|\/)schema(\/|\.)/.test(t))}function N(t,s,n){return!(_(t.relativePath)&&s>0||s===0&&n.has(t.relativePath))}function O(t,s,n,r){let i=[],o=0,c=b(n);for(let a of r)z(t,a,s,c)||B(t,a,c)?o++:i.push(a);return{realConsumers:i,barrelConsumers:o}}function U(t,s,n,r){let i=A(t,s.relativePath),o=b(s.symbol);if(!o)return!1;let c=i.get(o);if(!c||c.size===0)return!1;let a=r.get(s.relativePath);if(!a)return!1;for(let l of c){let f=a.get(l);if(!f)continue;let u=n.get(f.symbolId);if(u){for(let g of u)if(g!==s.relativePath&&!t.isIgnored(g))return!0}}return!1}var j=M("stale-abs-file-usage");function B(t,s,n){if(!n)return!1;let r=P(s);if(!r)return!1;let i=j.get(t,s,()=>W(t,s,r));return i.importedLeaves.has(n)&&!i.usedLeaves.has(n)}function W(t,s,n){let r=new Set,i=new Set,o=w(t,s);if(!o)return{importedLeaves:r,usedLeaves:i};let c=n==="rust"?new Set(["use_declaration"]):n==="python"?new Set(["import_statement","import_from_statement"]):new Set(["import_statement"]),a=(l,f)=>{let u=f||c.has(l.type);(l.type==="identifier"||l.type==="type_identifier"||l.type==="property_identifier"||l.type==="field_identifier")&&(u?r.add(l.text):i.add(l.text));for(let g of l.children)a(g,u)};return a(o.rootNode,!1),{importedLeaves:r,usedLeaves:i}}function z(t,s,n,r){if(!r)return!1;let i=y(t,s);if(!i)return!1;let o=k(t,s);if(o.length===0)return!1;let c=r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),a=new RegExp(`\\b${c}\\b`),l=i.split(`
2
- `),f=0;for(let u=0;u<l.length;u++){if(!a.test(l[u]??""))continue;if(f++,!o.find(d=>d.startLine<=u&&u<=d.endLine))return!1}return f>0}function G(t,s,n){let r=y(t,s);if(!r)return"other";let i=r.split(`
3
- `),o=Math.max(0,n-2),c=Math.min(i.length-1,n+2);for(let a=o;a<=c;a++){let f=(i[a]??"").replace(/^\s*\/\/.*$/g,"");if(/\b(?:export\s+)?(?:abstract\s+)?class\s+\w/.test(f))return"class";if(/\b(?:export\s+)?interface\s+\w/.test(f))return"interface";if(/\b(?:export\s+)?type\s+\w/.test(f))return"type";if(/\b(?:export\s+)?(?:const\s+)?enum\s+\w/.test(f))return"enum"}return"other"}function H(t,s){let n=y(t,s.relativePath);if(!n)return!1;let r=b(s.symbol);if(!r)return!1;let i=r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),o=new RegExp(`\\b${i}\\b`),c=n.split(`
4
- `);for(let a=0;a<c.length;a++)if(!(a>=s.startLine&&a<=s.endLine)&&o.test(c[a]??""))return!0;return!1}function K(t,s,n){return t===0?{confidence:"high",reason:"unused \u2014 no consumers and defining file has no real usage"}:t===1&&s==="class"?{confidence:"low",reason:"1 consumer + class kind \u2014 likely 1:1 encapsulation, not over-abstraction"}:t===1&&!n?{confidence:"high",reason:"1 consumer + defining file never uses it \u2014 type belongs with its consumer"}:{confidence:"medium",reason:"1 consumer \u2014 single-use abstraction"}}function L(t){return t.endLine-t.startLine+1}function q(...t){let s=new Map;for(let n of t)for(let[r,i]of n){let o=s.get(r);o||(o=new Set,s.set(r,o));for(let c of i)o.add(c)}return s}export{ie as a};
5
- //# sourceMappingURL=chunk-6U5UHIRD.js.map
@@ -1,2 +0,0 @@
1
- import{a as C}from"./chunk-QID23O53.js";import{k as b,m as f}from"./chunk-FT4WPAEX.js";import{r as u}from"./chunk-QL5MJOVA.js";import{b as n,e as c,i as y}from"./chunk-5IM4IQ6N.js";function R(o,r){let{scope:s,minLoc:t=10,limit:M=30}=r??{},{definitions:d,callerMap:S,calleeMap:L}=g(o,s);return d.map(e=>{let a=e.endLine-e.startLine+1,i=S.get(e.symbolId)?.size??0,p=L.get(e.symbolId)??[],h=p.filter(l=>l.file!==e.relativePath),m=new Set(h.map(l=>`${l.symbol}|${l.file}`)).size,x=new Set(p.map(l=>`${l.symbol}|${l.file}`)).size;return{symbol:e.symbol,shortName:n(e.symbol),file:e.relativePath,startLine:e.startLine,endLine:e.endLine,loc:a,fanIn:i,fanOut:m,calleeCount:x,score:Math.round(a/50*(i/5)*Math.max(m/5,1)*100)/100}}).filter(e=>e.loc>=t).sort((e,a)=>a.score-e.score||a.loc-e.loc).slice(0,M)}function g(o,r){let s=u(o,r).filter(t=>c(t.symbol)&&!o.isIgnored(t.relativePath)).filter(t=>C(t.relativePath)!=="test").filter(t=>!y(t.symbol));return{definitions:s,callerMap:f(o,s),calleeMap:b(o,s)}}export{R as a};
2
- //# sourceMappingURL=chunk-AQFXC7CF.js.map
@@ -1,7 +0,0 @@
1
- import{c as m}from"./chunk-ZZ3F6P3X.js";import{j as g}from"./chunk-FT4WPAEX.js";import{a as R}from"./chunk-MWCN46ZX.js";import{d as h}from"./chunk-QL5MJOVA.js";import{f as u}from"./chunk-5IM4IQ6N.js";function $(t,a){let e=R(t,a);if(!e)return[];let i=!u(e.symbol)&&!t.isIgnored(e.relativePath)?[{relativePath:e.relativePath,line:e.startLine}]:[],r=m(t,e),l=(r.length>0?r:g(t,e)).filter(n=>!t.isIgnored(n.file)).map(n=>({relativePath:n.file,line:n.line})),c=S(t,e),o=new Set,f=[];for(let n of[...i,...l,...c]){let p=`${n.relativePath}:${n.line}`;o.has(p)||(o.add(p),f.push(n))}return f}function S(t,a){if(!a.relativePath.endsWith(".rb"))return[];let e=d(a.symbol);if(e.length===0)return[];let s=t.all(`SELECT relative_path
2
- FROM documents
3
- WHERE relative_path LIKE '%.rb'
4
- ${t.pathExclusionsFor("documents")}
5
- ORDER BY relative_path`),i=[];for(let r of s){if(t.isIgnored(r.relative_path))continue;let l=h(t,r.relative_path);if(!l)continue;let c=l.split(`
6
- `);for(let o=0;o<c.length;o++){let f=c[o]??"";e.some(n=>new RegExp(`@${n}\\b|\\b${n}:`).test(f))&&i.push({relativePath:r.relative_path,line:o})}}return i}function d(t){let e=(t.split(":").pop()??t).replace(/([a-z0-9])([A-Z])/g,"$1_$2").replace(/[^A-Za-z0-9_]+/g,"_").toLowerCase().replace(/^_+|_+$/g,""),s=e.split("_").filter(Boolean),i=new Set;return e&&i.add(e),s.length>=1&&i.add(s[s.length-1]),s.length>=2&&i.add(s.slice(-2).join("_")),[...i]}export{$ as a};
7
- //# sourceMappingURL=chunk-BSONDC3H.js.map
@@ -1,2 +0,0 @@
1
- import{h as f}from"./chunk-FT4WPAEX.js";import{a as m}from"./chunk-MWCN46ZX.js";import{b as r}from"./chunk-5IM4IQ6N.js";function w(i,g,p){let s=m(i,g),n=m(i,p);if(!s||!n)return null;let c=new Set(f(i,s).map(e=>e.symbol)),h=new Set(f(i,n).map(e=>e.symbol)),a=[];for(let e of c)h.has(e)&&a.push(e);let o=[];for(let e of c)h.has(e)||o.push(e);let l=[];for(let e of h)c.has(e)||l.push(e);let u=new Set([...c,...h]),d=u.size>0?a.length/u.size:0,t;u.size===0?t="Neither function calls other tracked symbols. There is no callee-pattern evidence for consolidation; inspect the source bodies directly.":a.length===0?t="These functions do not share any callees. They are not a callee-based consolidation candidate.":o.length===0&&l.length===0?t="These functions have identical tracked callee sets. They are a strong structural match, but identical callees do not prove interchangeable semantics; inspect signatures, control flow, and return values before consolidating.":o.length===0?t="A's tracked callees are a subset of B's. B may subsume part of A's structure, but verify signatures, guards, and non-call logic before replacing A with B.":l.length===0?t="B's tracked callees are a subset of A's. A may subsume part of B's structure, but verify signatures, guards, and non-call logic before replacing B with A.":o.length<=2&&l.length<=2?t=`Create a shared function with the ${a.length} common callees. Pass the ${o.length+l.length} divergent callees as parameters or strategy callbacks.`:t=`Extract the ${a.length} shared callees into a common helper. Each function calls the helper plus its own unique logic (${o.length} callees in A, ${l.length} in B).`;let y=s.endLine-s.startLine+1,b=n.endLine-n.startLine+1;return{symbolA:{symbol:s.symbol,shortName:r(s.symbol),file:s.relativePath,loc:y},symbolB:{symbol:n.symbol,shortName:r(n.symbol),file:n.relativePath,loc:b},similarity:d,sharedCallees:a.map(r),uniqueToA:o.map(r),uniqueToB:l.map(r),consolidationStrategy:t}}export{w as a};
2
- //# sourceMappingURL=chunk-ECT6SOBO.js.map
@@ -1,2 +0,0 @@
1
- import{d,q as b}from"./chunk-QL5MJOVA.js";import{b as g}from"./chunk-5IM4IQ6N.js";function I(n,e={}){let{scope:i,minLoc:u=1,limit:l}=e,p=new Map;for(let t of b(n,{scope:i})){if(!t.isFunctionLike||n.isIgnored(t.relativePath))continue;let s=t.endLine-t.startLine+1;if(s<u)continue;let f=x(n,t);if(!f)continue;let a={symbol:t.symbol,shortName:g(t.symbol),file:t.relativePath,startLine:t.startLine,endLine:t.endLine,loc:s},r=p.get(f);r?r.push(a):p.set(f,[a])}let c=[];for(let[t,s]of p)s.length<2||c.push({signature:t,functions:s});return c.sort((t,s)=>{let f=s.functions.length-t.functions.length;if(f!==0)return f;let a=t.functions.reduce((o,m)=>o+m.loc,0);return s.functions.reduce((o,m)=>o+m.loc,0)-a}),l?c.slice(0,l):c}function x(n,e){let i=S(e.documentation),u=i?L(i):null;return u||D($(n,e.relativePath,e.startLine,e.endLine,e.leaf),e.leaf)}function S(n){if(!n||!n.includes("|"))return null;let e=n.slice(n.indexOf("|")+1).replace(/\n/g," ").trim();return e.length>0?e:null}function $(n,e,i,u,l){let p=d(n,e);if(!p)return null;let c=p.split(/\r?\n/),t=v(c,i,u,l);for(let s of t){let f=Math.min(c.length-1,Math.max(s,s+4)),a="";for(let r=s;r<=f;r+=1){let o=c[r]?.trim();if(o&&(a=a?`${a} ${o}`:o,y(a)))return a}if(a&&a.includes("("))return a}return null}function y(n){let e=n.replace(/\s+/g," ").trim();return!e.includes("(")||w(e)>0?!1:/[;{]$/.test(e)||/\)\s*(?::\s*[^={]+)?\s*(?:=>|=|throws\b|where\b|$)/i.test(e)||/\)\s*As\s+.+$/i.test(e)}function L(n){if(!n||!n.trim())return null;let e=n.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(),i=e.indexOf("(");return i===-1||(e=e.slice(i),e=e.replace(/\s+/g,"").toLowerCase(),e.length<3)?null:e}function D(n,e){if(!n||!n.trim())return null;let i=n.replace(/\s+/g," ").trim(),u=i.indexOf("(");if(u===-1)return null;let l=i.slice(0,u),c=new RegExp(`\\b${h(e)}\\b`,"i").exec(l);c&&typeof c.index=="number"&&(l=l.slice(0,c.index)),l=l.replace(/\b(public|private|protected|internal|final|static|abstract|sealed|virtual|override|async|suspend|inline|constexpr|consteval|constinit|const|pub|fn|function|def|sub|friend|shared|readonly|new|open|partial|export)\b/gi," ").replace(/\s+/g," ").trim();let t=i.slice(u).replace(/\s*\{[\s\S]*$/,"").replace(/\s*=>[\s\S]*$/,"").replace(/\)\s*=\s*[\s\S]*$/,")").replace(/\s+throws\s+[^={]+$/i,"").replace(/\s+where\s+.+$/i,"").replace(/\s+/g," ").trim();if(!t.startsWith("("))return null;let s=`${l?`${l} `:""}${t}`.replace(/\s+/g,"").toLowerCase();return s.length>=3?s:null}function v(n,e,i,u){let l=h(u),p=new RegExp(`\\b${l}\\b\\s*\\(`,"i"),c=new RegExp(`\\bdef\\s+${l}\\b`,"i"),t=[],s=new Set,f=Math.max(0,Math.min(e,n.length-1)),a=Math.max(f,Math.min(n.length-1,Math.max(i,e+4)));for(let r=f;r<=a;r+=1){let o=n[r]??"";(p.test(o)||c.test(o))&&!s.has(r)&&(s.add(r),t.push(r))}for(let r=0;r<n.length;r+=1){let o=n[r]??"";(p.test(o)||c.test(o))&&!s.has(r)&&(s.add(r),t.push(r))}return t}function w(n){let e=0;for(let i of n)i==="("&&(e+=1),i===")"&&(e-=1);return e}function h(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}export{I as a};
2
- //# sourceMappingURL=chunk-FFE3RZ65.js.map
@@ -1,65 +0,0 @@
1
- import{a as T,b as H,c as $,e as J}from"./chunk-NKU7Z242.js";import{c as P}from"./chunk-MWCN46ZX.js";import{a as I,b as N,d as A,f as E,h as L,i as k,k as C,m as v,p as O,q as D,t as F}from"./chunk-QL5MJOVA.js";import{c as R}from"./chunk-5IM4IQ6N.js";var x=new WeakMap;function xe(n,o){let i=E(o);return i==="rust"?ne(n,o):i==="typescript"||i==="tsx"||i==="javascript"?Q(n,o):[]}var X=new Set(["describe","it","test","fdescribe","fit","xdescribe","xit","beforeEach","afterEach","beforeAll","afterAll","before","after","suite","bench","benchmark"]);function Q(n,o){let i=L(n,o);if(!i)return[];let l=x.get(i);if(l)return l;let a=/(^|\/)(pages|app)\/.+\.(tsx?|jsx?)$/.test(o)||/(^|\/)(layout|page|loading|error|not-found|head|template|default)\.(tsx?|jsx?)$/.test(o),r=/(^|\/)src\/(pages|views|routes)\/.+\.(tsx?|jsx?|vue)$/.test(o),d=!1,t=i.rootNode;for(let s of t.namedChildren){if(s.type!=="expression_statement")continue;let f=s.namedChild(0);if(!f||f.type!=="call_expression")continue;let e=f.namedChild(0);if(!e)continue;let u=e.type==="member_expression"?e.namedChild(e.namedChildCount-1)?.text:e.text;if(u&&X.has(u)){d=!0;break}}let c=[];d&&c.push({startLine:0,endLine:t.endPosition.row,reason:"TS/JS test file (describe/it/test at top level)"}),(a||r)&&c.push({startLine:0,endLine:t.endPosition.row,reason:a?"Next.js / Remix route file":"Vite/Vue route component"});for(let s of t.namedChildren){let f=null,e=null;if(s.type==="function_declaration")f=s.namedChild(0)?.text??null,e=s;else if(s.type==="export_statement"){let u=s.namedChild(0);u?.type==="function_declaration"&&(f=u.namedChild(0)?.text??null,e=u)}else if(s.type==="lexical_declaration"){let u=s.namedChild(0);if(u?.type==="variable_declarator"){let p=u.namedChild(0)?.text,m=u.namedChild(1);p&&(m?.type==="arrow_function"||m?.type==="function_expression")&&(f=p,e=u)}}f&&/^use[A-Z]/.test(f)&&e&&c.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:"React custom hook (use*)"})}return c.push(...z(i,new Set(["function_declaration","method_definition","class_declaration","interface_declaration","type_alias_declaration","enum_declaration","variable_declarator","export_statement"]),new Set(["comment"]))),x.set(i,c),c}var ee=/scip-query[\s:-]*ignore[\s:-]*(?:dead(?:-code)?|stale)?/i;function te(n){return ee.test(n)}function z(n,o,i){let l=[],a=r=>{if(o.has(r.type)&&r.parent){let t=r.parent.children,c=-1;for(let s=0;s<t.length;s+=1)if(t[s].startIndex===r.startIndex&&t[s].type===r.type){c=s;break}if(c>0)for(let s=c-1;s>=0;s-=1){let f=t[s];if(i.has(f.type)){if(te(f.text)){l.push({startLine:r.startPosition.row,endLine:r.endPosition.row,reason:"scip-query suppression comment"});break}continue}if(!(f.type==="attribute_item"||f.type==="inner_attribute_item"))break}}for(let d of r.namedChildren)a(d)};return a(n.rootNode),l}function ne(n,o){let i=L(n,o);if(!i)return[];let l=x.get(i);if(l)return l;let a=[];if(ie(i.rootNode)){let e={startLine:0,endLine:i.rootNode.endPosition.row,reason:"generated file (@generated header)"};return x.set(i,[e]),[e]}let r=e=>{let u=e.parent;if(!u)return[];let p=u.children,m=-1;for(let g=0;g<p.length;g+=1)if(p[g].startIndex===e.startIndex&&p[g].type===e.type){m=g;break}if(m<=0)return[];let b=[];for(let g=m-1;g>=0;g-=1){let _=p[g];if(_.type==="attribute_item"||_.type==="inner_attribute_item")b.push(_.text);else{if(_.type==="line_comment"||_.type==="block_comment")continue;break}}return b},d=e=>/#\[\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,t=e=>/#\[\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,c=e=>/#\[\s*allow\s*\(\s*dead_code\s*\)/.test(e),s=(e,u,p,m)=>{let b=u,g=p,_=m;if(e.type==="trait_item"&&(_=!0,a.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:"trait declaration body (dynamic dispatch)"})),e.type==="impl_item"&&e.childForFieldName("trait")&&(g=!0,a.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:"trait impl block (dynamic dispatch)"})),e.type==="function_item"||e.type==="function_signature_item"){let y=r(e),h=null;p?h="trait impl method (dynamic dispatch)":u&&(h="inside #[cfg(test)] mod");for(let S of y){let w=d(S);if(w){h=w;break}if(c(S)){h="#[allow(dead_code)]";break}}h&&a.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:h})}else if(p&&(e.type==="const_item"||e.type==="type_item"||e.type==="static_item"||e.type==="associated_type"))a.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:"trait impl associated item (dynamic dispatch)"});else if(e.type==="struct_item"||e.type==="enum_item"||e.type==="union_item"){let y=r(e),h=y.some(t),S=y.some(c),w=e.namedChildren.find(Z=>Z.type==="type_identifier")?.text;h&&a.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:"#[derive(<reflective>)] \u2014 fields accessed via macro/reflection",containerName:w}),S&&a.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:"#[allow(dead_code)]",containerName:w}),u&&a.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:"inside #[cfg(test)] mod",containerName:w})}else e.type==="mod_item"&&r(e).some(h=>/#\[\s*cfg\s*\(\s*test\s*\)/.test(h))&&(b=!0);for(let y of e.namedChildren)s(y,b,g,_)};s(i.rootNode,!1,!1,!1),a.push(...z(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"])));let f=ce(i.rootNode);if(f.size>0)for(let e of i.rootNode.descendantsOfType("mod_item")){let u=e.childForFieldName("name")?.text;u&&f.has(u)&&a.push({startLine:e.startPosition.row,endLine:e.endPosition.row,reason:'serde `with = "..."` module \u2014 body invoked via reflection',containerName:u})}return x.set(i,a),a}function ie(n){for(let o=0;o<Math.min(n.namedChildCount,12);o+=1){let i=n.namedChild(o);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 se=[{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}],j=/^#!?\[\s*serde\s*\(/,oe=/^#!?\[\s*schemars\s*\(/,re=/^#!?\[\s*validate\s*\(/,W=/\bwith\s*=\s*"([^"]+)"/g;function G(n,o){return C(n,o,ae,()=>new Set,(i,l,a)=>{if(l==="rust"){for(let r of i.rootNode.descendantsOfType("attribute_item"))B(r.text,a);for(let r of i.rootNode.descendantsOfType("inner_attribute_item"))B(r.text,a)}})??new Set}var ae=new WeakMap;function B(n,o){let i=j.test(n),l=oe.test(n),a=re.test(n);if(!(!i&&!l&&!a))for(let{re:r}of se){r.lastIndex=0;let d;for(;(d=r.exec(n))!==null;){let t=d[1],c=t.split("::").pop()??t;c==="is_none"&&/\bOption\b/.test(t)||c==="is_empty"&&/\b(String|Vec|HashMap|BTreeMap|HashSet|BTreeSet)\b/.test(t)||c&&o.add(c)}}}function ce(n){let o=new Set;for(let i of n.descendantsOfType("attribute_item")){if(!j.test(i.text))continue;W.lastIndex=0;let l;for(;(l=W.exec(i.text))!==null;){let a=l[1],r=a.split("::").pop()??a;r&&o.add(r)}}return o}var le=new Set(["invoke","invokeTauriCommand","listen","once","emit","subscribe","dispatch","sendCommand","callRust"]);function Re(n,o){return C(n,o,de,()=>new Set,(i,l,a)=>{if(!(l!=="typescript"&&l!=="tsx"&&l!=="javascript"))for(let r of i.rootNode.descendantsOfType("call_expression")){let d=r.namedChild(0);if(!d)continue;let t=v(d);if(!t||!le.has(t))continue;let c=r.namedChildren.find(e=>e.type==="arguments");if(!c)continue;let s=c.namedChild(0);if(!s||s.type!=="string")continue;let f=s.namedChildren.find(e=>e.type==="string_fragment");f&&a.add(f.text)}})??new Set}var de=new WeakMap;function Y(n,o,i,l={}){if(!i)return[];let a=A(n,o);if(!a)return[];if(a.indexOf(i)===-1)return[];if(E(o))return(M(n,o).get(i)??[]).filter(f=>!V(f,l));let r=H(n,o,a),d=new RegExp(`\\b${$(i)}\\b`),t=[];for(let c=0;c<r.length;c++)V(c,l)||d.test(r[c]??"")&&t.push(c);return t}function V(n,o){return typeof o.excludeStartLine=="number"&&typeof o.excludeEndLine=="number"&&n>=o.excludeStartLine&&n<=o.excludeEndLine}var ue=I("file-identifiers");function ve(n,o){return ue.get(n,o,()=>new Set(M(n,o).keys()))}var fe=I("file-ident-lines");function M(n,o){return fe.get(n,o,()=>pe(n,o))}var me=I("file-idents-by-line");function U(n,o){return me.get(n,o,()=>{let i=M(n,o),l=0;for(let r of i.values()){let d=r[r.length-1];d!==void 0&&d>l&&(l=d)}let a=new Array(l+1);for(let r=0;r<=l;r+=1)a[r]=new Set;for(let[r,d]of i)for(let t of d)a[t].add(r);return a})}function pe(n,o){let i=new Map,l=(t,c)=>{let s=i.get(t);if(!s){i.set(t,[c]);return}s[s.length-1]!==c&&s.push(c)};if(E(o)){let t=L(n,o);if(t){let c=E(o),s=c==="rust"?new Set(["identifier","type_identifier","field_identifier"]):c==="python"?new Set(["identifier"]):new Set(["identifier","property_identifier","type_identifier"]),f=new Set(["rust","python"]),e=/\{([^{}]*)\}/g,u=/\b([A-Za-z_][\w]*)\b/g,p=m=>{if(s.has(m.type)&&l(m.text,m.startPosition.row),c&&f.has(c)&&m.type==="string_content"){let b=m.startPosition.row;for(let g of m.text.matchAll(e)){let _=g[1]??"";for(let y of _.matchAll(u))y[1]&&l(y[1],b)}}for(let b of m.children)p(b)};return p(t.rootNode),i}}let a=A(n,o);if(!a)return i;let r=T(a).split(/\r?\n/),d=/\b([A-Za-z_$][\w$]*)\b/g;for(let t=0;t<r.length;t+=1){let c=r[t]??"";for(let s of c.matchAll(d))s[1]&&l(s[1],t)}return i}var be=I("file-dep-graph");function Be(n,o){return be.get(n,o??"",()=>{let i=o?`AND d1.relative_path LIKE '%${o}%'`:"",l=n.all(`SELECT DISTINCT
2
- d1.relative_path AS from_file,
3
- d2.relative_path AS to_file
4
- FROM mentions m
5
- JOIN chunks c ON m.chunk_id = c.id
6
- JOIN documents d1 ON c.document_id = d1.id
7
- JOIN global_symbols gs ON m.symbol_id = gs.id
8
- JOIN (
9
- SELECT m2.symbol_id, c2.document_id
10
- FROM mentions m2
11
- JOIN chunks c2 ON m2.chunk_id = c2.id
12
- WHERE m2.role = 1
13
- GROUP BY m2.symbol_id
14
- ) sym_def ON sym_def.symbol_id = gs.id
15
- JOIN documents d2 ON sym_def.document_id = d2.id
16
- WHERE d1.id != d2.id
17
- AND m.role != 1
18
- ${n.pathExclusionsFor("d1","d2")}
19
- ${i}`),a=new Map,r=new Set(n.all(`SELECT relative_path
20
- FROM documents
21
- WHERE 1 = 1
22
- ${n.pathExclusionsFor("documents")}
23
- ORDER BY relative_path`).map(t=>t.relative_path).filter(t=>!n.isIgnored(t))),d=(t,c)=>{t!==c&&(n.isIgnored(t)||n.isIgnored(c)||r.has(c)&&(a.has(t)||a.set(t,new Set),a.get(t).add(c)))};for(let t of l)d(t.from_file,t.to_file);for(let t of r)if(!(o&&!t.includes(o)))for(let c of J(n,t))c.sourcePath&&d(t,c.sourcePath);return a})}function ze(n,o,i={}){let a=K(n,[o]).get(o.symbolId)??[];return typeof i.limit=="number"?a.slice(0,i.limit):a}function je(n,o,i={}){let a=ye(n).get(o.symbolId)??[];return typeof i.limit=="number"?a.slice(0,i.limit):a}var ge=N("caller-rows");function ye(n){return ge.get(n,()=>{let o=D(n),i=K(n,o),l=new Map;for(let d of o)l.set(d.symbol,d.symbolId);let a=new Map,r=new Map;for(let d of o){let t=i.get(d.symbolId);if(!(!t||t.length===0))for(let c of t){let s=l.get(c.symbol);if(s===void 0||s===d.symbolId)continue;let f=a.get(s);f||(f=[],a.set(s,f),r.set(s,new Set));let e=`${d.symbol}|${d.relativePath}`;r.get(s).has(e)||(r.get(s).add(e),f.push({symbol:d.symbol,file:d.relativePath}))}}return a})}function Ge(n,o){let i=he(n,o);return i?Se(n,_e(n,i.match,i.identifier)):[]}function _e(n,o,i){let l=n.all(`SELECT DISTINCT d.relative_path, c.start_line, c.end_line
24
- FROM mentions m
25
- JOIN chunks c ON m.chunk_id = c.id
26
- JOIN documents d ON c.document_id = d.id
27
- WHERE m.symbol_id = ?
28
- AND m.role != 1
29
- ${n.pathExclusionsFor("d")}
30
- ORDER BY d.relative_path, c.start_line`,o.symbolId),a=new Map;for(let d of l){if(n.isIgnored(d.relative_path))continue;let t=a.get(d.relative_path);t||(t=[],a.set(d.relative_path,t)),t.push({start_line:d.start_line,end_line:d.end_line})}let r=new Map;for(let[d,t]of a){let c=d===o.relativePath?{excludeStartLine:o.startLine,excludeEndLine:o.endLine}:{},s=i?Y(n,d,i,c):[],f=[];for(let e of t){let u=s.filter(m=>m>=e.start_line&&m<=e.end_line),p=u.length>0?u:[e.start_line];for(let m of p)f.push(m)}r.set(d,f)}return r}function he(n,o){let i=P(n,o);return i?{match:i,identifier:R(i.symbol)||null}:null}function Se(n,o){let i=[],l=new Set;for(let[a,r]of o){let d=O(n,a);for(let t of r){let c=F(d,t),s=`${a}|${t}|${c?.symbol??""}`;l.has(s)||(l.add(s),i.push({file:a,line:t,enclosingSymbol:c?.symbol??null}))}}return i}function K(n,o,i={}){if(o.length===0)return new Map;let l=i.additive??!1,a=[],r=[];for(let s of o)E(s.relativePath)&&k(n,s.relativePath)!==null?a.push(s):r.push(s);let d=new Map,t=s=>{for(let[f,e]of s){let u=d.get(f);u||(u=[],d.set(f,u));let p=new Set(u.map(m=>`${m.symbol}|${m.chunkId}`));for(let m of e){let b=`${m.symbol}|${m.chunkId}`;p.has(b)||(p.add(b),u.push(m))}}};a.length>0&&t(Ee(n,a));let c=l?o:r;return c.length>0&&t(Ie(n,c)),d}function Ee(n,o){let i=new Map,l=new Map;for(let r of o){let d=l.get(r.relativePath);d?d.push(r):l.set(r.relativePath,[r]),i.set(r.symbolId,[])}let a=q(n);for(let[r,d]of l){let t=k(n,r);if(!t)continue;let c=[...d].sort((s,f)=>{let e=s.endLine-s.startLine,u=f.endLine-f.startLine;return e-u});for(let s of t){let f=null;for(let b of c)if(s.line>=b.startLine&&s.line<=b.endLine){f=b;break}if(!f)continue;let e=a.get(s.calleeLeaf);if(!e||e.length===0)continue;let u=null,p=e.find(b=>b.file===r);if(p?u=p:e.length===1&&(u=e[0]),!u||u.symbol===f.symbol)continue;i.get(f.symbolId).push({symbol:u.symbol,file:u.file,chunkId:s.line})}}return i}var we=N("global-leaf-index");function q(n){return we.get(n,()=>{let o=n.all(`SELECT gs.id, gs.symbol,
31
- COALESCE(der_doc.relative_path, mention_doc.relative_path) AS relative_path
32
- FROM global_symbols gs
33
- LEFT JOIN defn_enclosing_ranges der ON der.symbol_id = gs.id
34
- LEFT JOIN documents der_doc ON der_doc.id = der.document_id
35
- LEFT JOIN (
36
- SELECT m.symbol_id, MIN(d.relative_path) AS relative_path
37
- FROM mentions m
38
- JOIN chunks c ON m.chunk_id = c.id
39
- JOIN documents d ON c.document_id = d.id
40
- WHERE m.role = 1
41
- GROUP BY m.symbol_id
42
- ) mention_doc ON mention_doc.symbol_id = gs.id
43
- WHERE 1 = 1
44
- ${n.symbolNoiseFor("gs")}`),i=new Map;for(let l of o){if(!l.relative_path||n.isIgnored(l.relative_path))continue;let a=R(l.symbol);if(!a)continue;let r=i.get(a);r||(r=[],i.set(a,r)),r.some(d=>d.symbolId===l.id)||r.push({symbol:l.symbol,symbolId:l.id,file:l.relative_path})}return i})}function Ie(n,o){if(o.length===0)return new Map;let i=n.all(`SELECT c.document_id, c.id AS chunk_id, c.start_line, c.end_line, m.symbol_id
45
- FROM mentions m
46
- JOIN chunks c ON m.chunk_id = c.id
47
- WHERE m.role != 1`),l=new Map;for(let s of i)l.has(s.document_id)||l.set(s.document_id,[]),l.get(s.document_id).push(s);let a=new Map(n.all("SELECT id, relative_path FROM documents").map(s=>[s.id,s.relative_path])),r=new Map,d=n.all(`SELECT gs.id AS symbol_id, gs.symbol,
48
- COALESCE(der.document_id, def_chunk.document_id) AS document_id
49
- FROM global_symbols gs
50
- LEFT JOIN defn_enclosing_ranges der ON der.symbol_id = gs.id
51
- LEFT JOIN (
52
- SELECT m.symbol_id, MIN(c.document_id) AS document_id
53
- FROM mentions m
54
- JOIN chunks c ON m.chunk_id = c.id
55
- WHERE m.role = 1
56
- GROUP BY m.symbol_id
57
- ) def_chunk ON def_chunk.symbol_id = gs.id`);for(let s of d)r.has(s.symbol_id)||r.set(s.symbol_id,{symbol:s.symbol,file:s.document_id!==null?a.get(s.document_id)??"":""});let t=new Map,c=a;for(let s of o){let f=l.get(s.documentId)??[],e=new Set,u=[],p=null,m=()=>{if(p)return p;let b=c.get(s.documentId)??"",g=new Set;if(b){let _=U(n,b),y=Math.max(0,s.startLine),h=Math.min(_.length-1,s.endLine);for(let S=y;S<=h;S+=1)for(let w of _[S])g.add(w)}return p=g,g};for(let b of f){if(b.symbol_id===s.symbolId)continue;let g=r.get(b.symbol_id);if(!g)continue;if(!(b.start_line>=s.startLine&&b.end_line<=s.endLine)){if(!(b.start_line<=s.endLine&&b.end_line>=s.startLine))continue;let S=R(g.symbol);if(!S||!m().has(S))continue}let y=`${g.symbol}|${b.chunk_id}`;e.has(y)||(e.add(y),u.push({...g,chunkId:b.chunk_id}))}t.set(s.symbolId,u)}return t}function Ve(n,o){let i=new Map,l=n.all(`SELECT relative_path FROM documents
58
- WHERE 1 = 1 ${n.pathExclusionsFor("documents")}`),a=q(n);for(let t of l){if(!E(t.relative_path)||n.isIgnored(t.relative_path))continue;let c=k(n,t.relative_path);if(c)for(let s of c){let f=a.get(s.calleeLeaf);if(!f||f.length===0)continue;let u=f.find(m=>m.file===t.relative_path)??(f.length===1?f[0]:null);if(!u||u.file===t.relative_path)continue;let p=i.get(u.symbolId);p||(p=new Set,i.set(u.symbolId,p)),p.add(t.relative_path)}}let r=n.all(`SELECT DISTINCT m.symbol_id, d.relative_path, c.document_id,
59
- c.start_line AS chunk_start, c.end_line AS chunk_end
60
- FROM mentions m
61
- JOIN chunks c ON m.chunk_id = c.id
62
- JOIN documents d ON c.document_id = d.id
63
- WHERE m.role != 1
64
- ${n.pathExclusionsFor("d")}`),d=new Map;if(o)for(let t of o)d.set(t.symbolId,{docId:t.documentId,startLine:t.startLine,endLine:t.endLine});for(let t of r){if(n.isIgnored(t.relative_path))continue;let c=d.get(t.symbol_id);if(c&&c.docId===t.document_id&&t.chunk_start>=c.startLine&&t.chunk_end<=c.endLine)continue;let s=i.get(t.symbol_id);s||(s=new Set,i.set(t.symbol_id,s)),s.add(t.relative_path)}for(let t of l){if(n.isIgnored(t.relative_path)||E(t.relative_path)!=="rust")continue;let c=G(n,t.relative_path);if(c.size!==0)for(let s of c){let f=a.get(s);if(f)for(let e of f){if(e.file===t.relative_path)continue;let u=i.get(e.symbolId);u||(u=new Set,i.set(e.symbolId,u)),u.add(t.relative_path)}}}return i}export{xe as a,G as b,Re as c,Y as d,ve as e,M as f,Be as g,ze as h,je as i,Ge as j,K as k,q as l,Ve as m};
65
- //# sourceMappingURL=chunk-FT4WPAEX.js.map
@@ -1,2 +0,0 @@
1
- import{a as x}from"./chunk-QID23O53.js";import{k}from"./chunk-FT4WPAEX.js";import{e as w,r as v}from"./chunk-QL5MJOVA.js";import{b,f as C,i as L}from"./chunk-5IM4IQ6N.js";function A(i,F={}){let{scope:I,minLoc:P=10,minCallees:z=6,limit:D=20}=F,y=v(i,I).filter(e=>!i.isIgnored(e.relativePath)).filter(e=>h(e)>=P&&C(e.symbol)).filter(e=>!(e.relativePath.split("/").pop()??"").includes("types")).filter(e=>x(e.relativePath)!=="test").filter(e=>!L(e.symbol)).filter(e=>!w(i,e.relativePath,e.startLine)).sort((e,r)=>h(r)-h(e)),E=k(i,y),d=[];for(let e of y){let r=E.get(e.symbolId)??[],c=new Set(r.map(t=>t.symbol));if(c.size<z)continue;let l=new Map;for(let t of c)l.set(t,new Set);let a=new Map;for(let t of r)a.has(t.chunkId)||a.set(t.chunkId,new Set),a.get(t.chunkId).add(t.symbol);for(let t of a.values()){let s=[...t];for(let o=0;o<s.length;o++)for(let n=o+1;n<s.length;n++)l.get(s[o]).add(s[n]),l.get(s[n]).add(s[o])}let f=new Set,m=[];for(let t of c){if(f.has(t))continue;let s=new Set,o=[t];for(;o.length>0;){let n=o.pop();if(!f.has(n)){f.add(n),s.add(n);for(let u of l.get(n)??[])f.has(u)||o.push(u)}}m.push(s)}if(m.length<2)continue;let S=m.filter(t=>t.size>=3).map(t=>{let s=new Set;for(let p of m)if(p!==t)for(let g of p)s.add(g);let o=0;for(let p of t)for(let g of l.get(p)??[])s.has(g)&&o++;let n=t.size*s.size,u=n>0?1-o/n:1;return{callees:[...t].map(b),isolation:u}}).filter(t=>t.isolation>.5).sort((t,s)=>s.isolation-t.isolation);S.length>0&&d.push({symbol:e.symbol,shortName:b(e.symbol),relativePath:e.relativePath,startLine:e.startLine,endLine:e.endLine,loc:h(e),totalCallees:c.size,clusters:S})}return d.sort((e,r)=>r.clusters.length-e.clusters.length||r.loc-e.loc),d.slice(0,D)}function h(i){return i.endLine-i.startLine+1}export{A as a};
2
- //# sourceMappingURL=chunk-G6HYVVRV.js.map
@@ -1,10 +0,0 @@
1
- import{a as u}from"./chunk-4HCKXL7T.js";import{p as c}from"./chunk-QL5MJOVA.js";import{b as a}from"./chunk-5IM4IQ6N.js";function _(t,d){let s=u(t,d);if(!s)return null;let n=t.get(`SELECT id, relative_path FROM documents
2
- WHERE relative_path = ?
3
- ${t.pathExclusionsFor("documents")}
4
- LIMIT 1`,s);if(!n||t.isIgnored(n.relative_path))return null;let f=c(t,n.relative_path).sort((e,i)=>e.startLine-i.startLine||e.endLine-i.endLine),m=[],l=0;for(let e of f){let o=t.get(`SELECT COUNT(DISTINCT c.document_id) AS consumer_count
5
- FROM mentions m
6
- JOIN chunks c ON m.chunk_id = c.id
7
- WHERE m.symbol_id = ?
8
- AND m.role != 1
9
- AND c.document_id != ?`,e.symbolId,n.id)?.consumer_count??0,r;o>10?r="high":o>0?r="medium":r="low",l+=o,m.push({symbol:e.symbol,shortName:a(e.symbol),startLine:e.startLine,endLine:e.endLine,externalConsumers:o,riskLevel:r})}return{file:n.relative_path,symbols:m,totalExternalConsumers:l}}export{_ as a};
10
- //# sourceMappingURL=chunk-GVVKLMXG.js.map
@@ -1,2 +0,0 @@
1
- import{g as M}from"./chunk-FT4WPAEX.js";function H(o,c={}){let{minSimilarity:e=.5,limit:n=15,scope:r,minChainLength:g=3,maxChainLength:s=8}=c,l=M(o,r),t=R(l,g,s);if(t.length===0)return[];let h=new Map,u=new Map;for(let i of t){let a=new Set;for(let f of i)a.has(f)||(h.set(f,(h.get(f)??0)+1),a.add(f));for(let f=Math.max(0,i.length-2);f<i.length;f++)u.set(i[f],(u.get(i[f])??0)+1)}let P=t.length*.9,q=t.length*.8,x=new Set;for(let[i,a]of h)a>P&&x.add(i);for(let[i,a]of u)a>q&&x.add(i);let E=["index.ts","index.js","cli.ts","main.ts","health.ts","health.js"];for(let i of h.keys()){let a=i.split("/").pop()??"";E.includes(a)&&x.add(i)}let p=[];for(let i of t){let a=i.filter(f=>!x.has(f));a.length>=2&&p.push({original:i,filtered:a})}if(p.length<2)return[];let b=[];for(let i=0;i<p.length;i++){for(let a=i+1;a<p.length;a++){let f=p[i],m=p[a],F=new Set(f.filtered),S=!1;for(let d of m.filtered)if(F.has(d)){S=!0;break}if(!S)continue;let{distance:C,ops:A}=T(f.filtered,m.filtered),j=Math.max(f.filtered.length,m.filtered.length);if(j===0)continue;let B=1-C/j;if(B<e||C===0)continue;let w=A.filter(d=>d.type==="substitute").map(d=>({index:d.indexA,nodeA:f.filtered[d.indexA],nodeB:m.filtered[d.indexB]}));if(w.length===0||A.filter(d=>d.type==="match").length<2)continue;let N=v(f.original,m.original),O=z(f.original,m.original);b.push({chainA:f.original,chainB:m.original,similarity:B,editDistance:C,divergencePoints:w,commonPrefix:N,commonSuffix:O})}if(b.length>n*10)break}b.sort((i,a)=>Math.abs(a.similarity-i.similarity)>.01?a.similarity-i.similarity:i.divergencePoints.length-a.divergencePoints.length);let y=[];for(let i of b)if(y.some(f=>k(i.chainA,f.chainA)&&k(i.chainB,f.chainB))||y.push(i),y.length>=n)break;return y}function R(o,c,e){let n=[];for(let g of o.keys()){if(n.length>=500)break;D(o,g,[g],new Set([g]),c,e,n,500)}return n}function D(o,c,e,n,r,g,s,l){if(s.length>=l)return;if(e.length>=g){e.length>=r&&s.push([...e]);return}let t=o.get(c);if(!t||t.size===0){e.length>=r&&s.push([...e]);return}let h=!1;for(let u of t)if(!n.has(u)&&(n.add(u),e.push(u),D(o,u,e,n,r,g,s,l),e.pop(),n.delete(u),h=!0,s.length>=l))return;!h&&e.length>=r&&s.push([...e])}function T(o,c){let e=o.length,n=c.length,r=Array.from({length:e+1},()=>Array(n+1).fill(0));for(let t=0;t<=e;t++)r[t][0]=t;for(let t=0;t<=n;t++)r[0][t]=t;for(let t=1;t<=e;t++)for(let h=1;h<=n;h++)o[t-1]===c[h-1]?r[t][h]=r[t-1][h-1]:r[t][h]=1+Math.min(r[t-1][h],r[t][h-1],r[t-1][h-1]);let g=[],s=e,l=n;for(;s>0||l>0;)s>0&&l>0&&o[s-1]===c[l-1]?(g.unshift({type:"match",indexA:s-1,indexB:l-1}),s--,l--):s>0&&l>0&&r[s][l]===r[s-1][l-1]+1?(g.unshift({type:"substitute",indexA:s-1,indexB:l-1}),s--,l--):l>0&&r[s][l]===r[s][l-1]+1?(g.unshift({type:"insert",indexA:s,indexB:l-1}),l--):(g.unshift({type:"delete",indexA:s-1,indexB:l}),s--);return{distance:r[e][n],ops:g}}function v(o,c){let e=[];for(let n=0;n<Math.min(o.length,c.length)&&o[n]===c[n];n++)e.push(o[n]);return e}function z(o,c){let e=[],n=o.length-1,r=c.length-1;for(;n>=0&&r>=0&&o[n]===c[r];)e.unshift(o[n]),n--,r--;return e}function k(o,c){if(o.length>c.length)return!1;let e=c.join("\u2192"),n=o.join("\u2192");return e.includes(n)}export{H as a};
2
- //# sourceMappingURL=chunk-HVM6SQPQ.js.map
@@ -1,2 +0,0 @@
1
- import{a as n}from"./chunk-MWCN46ZX.js";import{p as l}from"./chunk-QL5MJOVA.js";import{b as m,d as o,j as i}from"./chunk-5IM4IQ6N.js";function f(r,a){let t=n(r,a);return t?l(r,t.relativePath).filter(e=>e.symbol!==t.symbol).filter(e=>i(t.symbol,e.symbol)).sort((e,s)=>e.startLine-s.startLine||e.endLine-s.endLine).map(e=>({symbol:e.symbol,shortName:m(e.symbol),startLine:e.startLine,endLine:e.endLine,kind:o(e.symbol)??"unknown"})):[]}export{f as a};
2
- //# sourceMappingURL=chunk-IJO2HZFL.js.map
@@ -1,12 +0,0 @@
1
- import{a as y,b as A}from"./chunk-ZZ3F6P3X.js";import{d as C,e as B,f as $,g as W,h as H}from"./chunk-QID23O53.js";import{c as M}from"./chunk-IDCWMWWP.js";import{a as w,b as D,c as O,f as k}from"./chunk-FT4WPAEX.js";import{f as T,g as I,q as x,v as N}from"./chunk-QL5MJOVA.js";import{b as L,f as R,g as E,h as P,i as F}from"./chunk-5IM4IQ6N.js";function se(t,a={}){let{scope:p,minLoc:c=1,includeTests:o=!1,skipBarrels:m=!1,includeMembers:s=!1}=a,n=m?new Set(C(t)):new Set,i=t.all(`SELECT
2
- m.symbol_id,
3
- d.relative_path,
4
- COUNT(*) AS ref_count
5
- FROM mentions m
6
- JOIN chunks c ON m.chunk_id = c.id
7
- JOIN documents d ON c.document_id = d.id
8
- WHERE m.role != 1
9
- ${t.pathExclusionsFor("d")}
10
- GROUP BY m.symbol_id, d.relative_path`),f=new Map;for(let e of i){if(t.isIgnored(e.relative_path)||n.has(e.relative_path))continue;let r=f.get(e.symbol_id);r||(r=new Map,f.set(e.symbol_id,r)),r.set(e.relative_path,e.ref_count)}V(t,f,n);let u=G(t),g=x(t,{scope:p}).filter(e=>!t.isIgnored(e.relativePath)).filter(e=>!E(e.symbol)).filter(e=>b(e.symbol)).filter(e=>e.isFunctionLike||!e.enclosingSymbol||!b(e.enclosingSymbol)).filter(e=>o||Y(e.relativePath)).filter(e=>o||!u(e.relativePath,e.startLine,e.symbol,e.parentTypeName)).filter(e=>!P(e.symbol)).filter(e=>!F(e.symbol)).filter(e=>s||b(e.symbol)).filter(e=>e.endLine-e.startLine+1>=c).map(e=>{let r=f.get(e.symbolId)??new Map,U=r.get(e.relativePath)??0,v=0;for(let[j,J]of r)j!==e.relativePath&&(v+=J);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:U,cross_file_refs:v}}).filter(e=>e.cross_file_refs===0).sort((e,r)=>r.loc-e.loc||e.relative_path.localeCompare(r.relative_path)||e.start_line-r.start_line),l=0,d=0,_=0,S=g.filter(e=>!t.isIgnored(e.relative_path)).filter(e=>!B(t,e.relative_path)).filter(e=>!$(t,e.symbol,e.relative_path)).map(e=>{let r=e.same_file_refs===0?"dead-code":"file-internal";return r==="dead-code"?l++:d++,_+=e.loc,{relativePath:e.relative_path,startLine:e.start_line,endLine:e.end_line,loc:e.loc,symbol:e.symbol,shortName:L(e.symbol),sameFileRefs:e.same_file_refs,kind:r}});return{symbols:S,totalCount:S.length,deadCodeCount:l,fileInternalCount:d,totalLoc:_}}function V(t,a,p){let c=t.all(`SELECT relative_path FROM documents
11
- WHERE 1 = 1 ${t.pathExclusionsFor("documents")}`),o=new Set(c.map(n=>n.relative_path)),m=new Set(M(t));for(let n of o)m.add(n);let s=(n,i,f)=>{if(f<=0)return;let u=a.get(n);u||(u=new Map,a.set(n,u)),u.set(i,(u.get(i)??0)+f)};for(let n of m){if(!T(n)&&!I(n)||t.isIgnored(n)||p.has(n))continue;let i=k(t,n);for(let[h,g]of i){let l=A(t,n,h);if(l.length!==0)for(let d of l){let _=d.relativePath===n?Math.max(0,g.length-1):g.length;s(d.symbolId,n,_)}}let f=O(t,n);for(let h of f){let g=y(t,n,h);for(let l of g)l.relativePath!==n&&s(l.symbolId,n,1)}let u=D(t,n);for(let h of u){let g=y(t,n,h);for(let l of g)s(l.symbolId,n,1)}}}function G(t){let a=new Map,p=c=>{let o=a.get(c);if(o)return o;let m=w(t,c);return o={ranges:m.map(s=>({startLine:s.startLine,endLine:s.endLine})),containers:new Set(m.map(s=>s.containerName).filter(s=>!!s))},a.set(c,o),o};return(c,o,m,s)=>{let n=p(c);for(let i of n.ranges)if(o>=i.startLine&&o<=i.endLine)return!0;if(s&&n.containers.has(s))return!0;for(let i of N(m))if(n.containers.has(i))return!0;return!1}}function Y(t){return[...new Set([...W,...H])].every(p=>!q(t,p))}function q(t,a){return new RegExp(`^${a.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/%/g,".*").replace(/_/g,".")}$`).test(t)}function b(t){return R(t)||t.endsWith("().")||t.endsWith(".")}export{se as a};
12
- //# sourceMappingURL=chunk-INPQVQ6O.js.map
@@ -1,39 +0,0 @@
1
- import{a as h}from"./chunk-4HCKXL7T.js";import{e as p}from"./chunk-NKU7Z242.js";import{a as _}from"./chunk-MWCN46ZX.js";import{b as d,c,g as f}from"./chunk-5IM4IQ6N.js";function v(e,i){return b(e,i)?.map(t=>({symbol:t.symbol,shortName:t.shortName,fromFile:t.fromFile}))??[]}function F(e,i){let a=e.all(`SELECT DISTINCT gs.symbol, d.relative_path AS importer
2
- FROM mentions m
3
- JOIN chunks c ON m.chunk_id = c.id
4
- JOIN documents d ON c.document_id = d.id
5
- JOIN global_symbols gs ON m.symbol_id = gs.id
6
- WHERE gs.symbol LIKE ?
7
- AND m.role = 2
8
- ORDER BY d.relative_path`,`%${i}%`).filter(s=>!e.isIgnored(s.importer)).map(s=>({symbol:s.symbol,shortName:d(s.symbol),fromFile:s.importer}));if(a.length>0)return a;let o=_(e,i),r=o?.relativePath??null,m=o?c(o.symbol):i.replace(/\(\)$/,""),u=o?f(o.symbol):!1,y=e.all(`SELECT relative_path
9
- FROM documents
10
- WHERE 1 = 1
11
- ${e.pathExclusionsFor("documents")}
12
- ORDER BY relative_path`),l=new Set;for(let s of y)if(!e.isIgnored(s.relative_path)){for(let n of p(e,s.relative_path))if(n.sourcePath&&!(r&&g(n.sourcePath)!==g(r))){if(n.kind==="side-effect"){l.add(s.relative_path);continue}if(r&&E(s.relative_path)){l.add(s.relative_path);continue}if(u){l.add(s.relative_path);continue}if(n.kind==="named"&&n.importedName===m){l.add(s.relative_path);continue}n.kind==="namespace"&&n.usedMembers.includes(m)&&l.add(s.relative_path)}}return[...l].sort().map(s=>({symbol:o?.symbol??m,shortName:o?d(o.symbol):m,fromFile:s}))}function D(e,i){return b(e,i)?.filter(t=>!t.used).map(t=>({symbol:t.symbol,shortName:t.shortName,importedIn:t.importer}))??[]}function b(e,i){let t=h(e,i);if(!t)return null;let o=e.all(`SELECT DISTINCT
13
- gs.symbol,
14
- def_d.relative_path AS from_file,
15
- imp_d.relative_path AS importer,
16
- EXISTS (
17
- SELECT 1
18
- FROM mentions ref_m
19
- JOIN chunks ref_c ON ref_m.chunk_id = ref_c.id
20
- WHERE ref_m.symbol_id = gs.id
21
- AND ref_m.role != 1
22
- AND ref_c.document_id = imp_d.id
23
- ) AS used
24
- FROM mentions m
25
- JOIN chunks c ON m.chunk_id = c.id
26
- JOIN documents imp_d ON c.document_id = imp_d.id
27
- JOIN global_symbols gs ON m.symbol_id = gs.id
28
- LEFT JOIN (
29
- SELECT m2.symbol_id, c2.document_id
30
- FROM mentions m2
31
- JOIN chunks c2 ON m2.chunk_id = c2.id
32
- WHERE m2.role = 1
33
- GROUP BY m2.symbol_id
34
- ) sym_def ON sym_def.symbol_id = gs.id
35
- LEFT JOIN documents def_d ON sym_def.document_id = def_d.id
36
- WHERE imp_d.relative_path = ?
37
- AND m.role = 2
38
- ORDER BY def_d.relative_path, gs.symbol`,t).filter(r=>!e.isIgnored(r.importer));return o.length>0?o.map(r=>({symbol:r.symbol,shortName:d(r.symbol),fromFile:r.from_file??"(external)",importer:r.importer,used:r.used!==0})):p(e,t).map(r=>{let m=I(r.importedName,r.localName,r.kind),u=r.kind==="side-effect"?!0:r.used;return{symbol:m,shortName:m,fromFile:r.sourcePath??"(external)",importer:t,used:u}})}function I(e,i,t){return t==="namespace"&&e==="*"&&i?`* as ${i}`:t==="default"&&i?`default as ${i}`:t==="side-effect"?"(side effect import)":i&&i!==e?`${e} as ${i}`:e}function g(e){return e.replace(/\\/g,"/")}function E(e){return/\.(?:c|h|cc|cpp|cxx|hpp|hh|hxx)$/i.test(e)}export{v as a,F as b,D as c};
39
- //# sourceMappingURL=chunk-JSBWVSES.js.map
@@ -1,2 +0,0 @@
1
- import{b as e}from"./chunk-4HCKXL7T.js";import{s as o}from"./chunk-QL5MJOVA.js";function l(t,r){let s=e(t,r);return o(t,s).map(({relativePath:a,...m})=>m)}export{l as a};
2
- //# sourceMappingURL=chunk-MFVPKCS5.js.map