scip-query 0.6.2 → 0.6.4

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 (93) hide show
  1. package/dist/{chunk-FPDWFGBQ.js → chunk-2DQK2IDZ.js} +2 -2
  2. package/dist/{chunk-NFOSOUH6.js → chunk-4HCKXL7T.js} +2 -2
  3. package/dist/{chunk-435YC4OF.js → chunk-4Q2D5BMS.js} +2 -2
  4. package/dist/{chunk-4LBOHXT7.js → chunk-5NSYCQWM.js} +2 -2
  5. package/dist/{chunk-67UXTIFZ.js → chunk-5OVBASGY.js} +2 -2
  6. package/dist/{chunk-MQ5FKM2F.js → chunk-6QKHOBC6.js} +2 -2
  7. package/dist/{chunk-5V76WMMZ.js → chunk-6U5UHIRD.js} +2 -2
  8. package/dist/{chunk-3QJ2NOYG.js → chunk-6UJ5PXER.js} +2 -2
  9. package/dist/{chunk-S65VVU3R.js → chunk-AQFXC7CF.js} +2 -2
  10. package/dist/{chunk-5W22HCSF.js → chunk-AW3QJT4O.js} +2 -2
  11. package/dist/{chunk-7DKDFRXQ.js → chunk-BSONDC3H.js} +2 -2
  12. package/dist/{chunk-2HEJQBMS.js → chunk-CGAO6FHN.js} +2 -2
  13. package/dist/{chunk-5VU2RVKI.js → chunk-ECT6SOBO.js} +2 -2
  14. package/dist/{chunk-TXADWK4I.js → chunk-FFE3RZ65.js} +2 -2
  15. package/dist/{chunk-3FG3VLK3.js → chunk-FT4WPAEX.js} +2 -2
  16. package/dist/{chunk-G2SX5EHW.js → chunk-G6HYVVRV.js} +2 -2
  17. package/dist/{chunk-AZTWY4OT.js → chunk-GALIM3IE.js} +2 -2
  18. package/dist/{chunk-PU7P5NPE.js → chunk-GVVKLMXG.js} +2 -2
  19. package/dist/{chunk-AVLUWGXG.js → chunk-HVM6SQPQ.js} +2 -2
  20. package/dist/{chunk-F6F2QUIH.js → chunk-IDCWMWWP.js} +2 -2
  21. package/dist/{chunk-CHW7433E.js → chunk-IJO2HZFL.js} +2 -2
  22. package/dist/{chunk-CW5K3KIF.js → chunk-INPQVQ6O.js} +2 -2
  23. package/dist/{chunk-GK6VXKLY.js → chunk-IVT2U2BV.js} +2 -2
  24. package/dist/{chunk-3J463LOK.js → chunk-JSBWVSES.js} +2 -2
  25. package/dist/{chunk-T26XHATT.js → chunk-LAXFZ3UW.js} +2 -2
  26. package/dist/chunk-MFVPKCS5.js +2 -0
  27. package/dist/{chunk-7NEBSLI3.js → chunk-MWCN46ZX.js} +2 -2
  28. package/dist/{chunk-6XP3KWHC.js → chunk-NKU7Z242.js} +2 -2
  29. package/dist/{chunk-NLWXQMKR.js → chunk-OOMAS234.js} +2 -2
  30. package/dist/{chunk-6ALIV5SZ.js → chunk-PM3GTZ4I.js} +2 -2
  31. package/dist/{chunk-AEMTUHQ7.js → chunk-QID23O53.js} +2 -2
  32. package/dist/{chunk-SPMLGXCE.js → chunk-QL5MJOVA.js} +8 -8
  33. package/dist/{chunk-OU2D2T4A.js → chunk-QWFK4QOQ.js} +2 -2
  34. package/dist/{chunk-TWYHFB5K.js → chunk-RBYC6PHE.js} +2 -2
  35. package/dist/{chunk-HS65NNKP.js → chunk-TS7E5XBZ.js} +2 -2
  36. package/dist/{chunk-FJV7QT4G.js → chunk-TUC6IWTY.js} +2 -2
  37. package/dist/{chunk-AZQ3ENHU.js → chunk-USMVRM6F.js} +2 -2
  38. package/dist/{chunk-YRUHPGC3.js → chunk-VTZPTRKS.js} +2 -2
  39. package/dist/{chunk-ZJM2HD2Z.js → chunk-WUYKGQSK.js} +2 -2
  40. package/dist/{chunk-26LSAIEP.js → chunk-X7LOLGYY.js} +2 -2
  41. package/dist/{chunk-5NRGSXZQ.js → chunk-XGOEZVMA.js} +2 -2
  42. package/dist/{chunk-ORD3HEWI.js → chunk-Y6NOLG4X.js} +2 -2
  43. package/dist/{chunk-RC2PKZSS.js → chunk-YVQ7CIKO.js} +2 -2
  44. package/dist/{chunk-LKCPNPHH.js → chunk-ZE3BTHTS.js} +2 -2
  45. package/dist/{chunk-HS5LX75F.js → chunk-ZIFKQQW2.js} +2 -2
  46. package/dist/{chunk-3T53QAUS.js → chunk-ZOR6FW74.js} +2 -2
  47. package/dist/{chunk-6CTMG3IF.js → chunk-ZPZLVFJQ.js} +2 -2
  48. package/dist/{chunk-QSTMORTI.js → chunk-ZZ3F6P3X.js} +2 -2
  49. package/dist/cli.js +74 -74
  50. package/dist/index.js +1 -1
  51. package/dist/queries/affected.js +1 -1
  52. package/dist/queries/bottlenecks.js +1 -1
  53. package/dist/queries/by-kind.js +1 -1
  54. package/dist/queries/call-graph.js +1 -1
  55. package/dist/queries/change-surface.js +1 -1
  56. package/dist/queries/code.js +1 -1
  57. package/dist/queries/complexity-hotspots.js +1 -1
  58. package/dist/queries/complexity.js +1 -1
  59. package/dist/queries/convergence.js +1 -1
  60. package/dist/queries/coupling.js +1 -1
  61. package/dist/queries/cycles.js +1 -1
  62. package/dist/queries/dataflow.js +1 -1
  63. package/dist/queries/dead.js +1 -1
  64. package/dist/queries/deep-chains.js +1 -1
  65. package/dist/queries/deps.js +1 -1
  66. package/dist/queries/drift.js +1 -1
  67. package/dist/queries/extract-candidates.js +1 -1
  68. package/dist/queries/fan.js +1 -1
  69. package/dist/queries/health.js +1 -1
  70. package/dist/queries/hierarchy.js +1 -1
  71. package/dist/queries/hotspots.js +1 -1
  72. package/dist/queries/imports.js +1 -1
  73. package/dist/queries/index.js +1 -1
  74. package/dist/queries/isolated.js +1 -1
  75. package/dist/queries/members.js +1 -1
  76. package/dist/queries/methods.js +1 -1
  77. package/dist/queries/outline.js +1 -1
  78. package/dist/queries/passthrough-candidates.js +1 -1
  79. package/dist/queries/redundant-reexports.js +1 -1
  80. package/dist/queries/refs.js +1 -1
  81. package/dist/queries/similar-chains.js +1 -1
  82. package/dist/queries/similar-files.js +1 -1
  83. package/dist/queries/similar-signatures.js +1 -1
  84. package/dist/queries/similar.js +1 -1
  85. package/dist/queries/slice.js +1 -1
  86. package/dist/queries/stale-abstractions.js +1 -1
  87. package/dist/queries/surface.js +1 -1
  88. package/dist/queries/symbols.js +1 -1
  89. package/dist/queries/system.js +1 -1
  90. package/dist/queries/trace.js +1 -1
  91. package/dist/queries/wrapper-candidates.js +1 -1
  92. package/package.json +1 -1
  93. package/dist/chunk-ZORIMKQO.js +0 -2
package/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import{program as v}from"commander";import{createRequire as yd}from"module";import{existsSync as hn,realpathSync as pr}from"fs";import{join as bd}from"path";import{fileURLToPath as Sd}from"url";import br from"better-sqlite3";import{statSync as os}from"fs";var Lt=class{db;config;pathFilter;constructor(n,t){this.config=n,this.pathFilter=t??null,this.db=new br(n.dbPath,{readonly:!0}),this.db.pragma("busy_timeout = 5000")}isIgnored(n){return this.pathFilter?.isIgnored(n)??!1}get localSymbolPredicate(){return`(
2
+ import{program as v}from"commander";import{createRequire as bd}from"module";import{existsSync as hn,realpathSync as fr}from"fs";import{join as Sd}from"path";import{fileURLToPath as _d}from"url";import Sr from"better-sqlite3";import{statSync as os}from"fs";var Lt=class{db;config;pathFilter;constructor(n,t){this.config=n,this.pathFilter=t??null,this.db=new Sr(n.dbPath,{readonly:!0}),this.db.pragma("busy_timeout = 5000")}isIgnored(n){return this.pathFilter?.isIgnored(n)??!1}get localSymbolPredicate(){return`(
3
3
  EXISTS (
4
4
  SELECT 1
5
5
  FROM defn_enclosing_ranges local_der
@@ -17,7 +17,7 @@ import{program as v}from"commander";import{createRequire as yd}from"module";impo
17
17
  ${this.pathExclusionsFor("local_d").trimStart()}
18
18
  )
19
19
  )`}get pathExclusions(){return this.pathExclusionsFor("d")}get symbolNoise(){return this.symbolNoiseFor("gs")}pathExclusionsFor(...n){return n.flatMap(t=>[`AND ${t}.relative_path NOT LIKE 'node_modules/%'`,`AND ${t}.relative_path NOT LIKE '.git/%'`]).join(`
20
- `)}symbolNoiseFor(n){return`AND ${n}.symbol NOT LIKE '%().(%' AND ${n}.symbol NOT LIKE '%typeLiteral%'`}all(n,...t){return this.db.prepare(n).all(...t)}get(n,...t){return this.db.prepare(n).get(...t)}sizeBytes(){try{return os(this.config.dbPath).size}catch{return 0}}lastModified(){try{return os(this.config.dbPath).mtime}catch{return null}}close(){this.db.close()}};import Sr from"ignore";import{readFileSync as _r,existsSync as Sn}from"fs";import{dirname as _n,isAbsolute as rs,join as xn,relative as xr,resolve as Ir}from"path";function Ue(e){let n=Sr(),t=!1,s=Nr(e);for(let i of s)try{let o=_r(i,"utf-8");n.add(o),t=!0}catch{}return t||n.add(vr),{isIgnored:i=>as(n,e,i),filter:i=>i.filter(o=>!as(n,e,o))}}function Nr(e){let n=[],t=xn(e,".gitignore");Sn(t)&&n.push(t);let s=_n(e),i=0;for(;s!==_n(s)&&i<5;){let o=xn(s,".gitignore");if(Sn(o)&&n.push(o),Sn(xn(s,".git")))break;s=_n(s),i++}return n}var vr=`
20
+ `)}symbolNoiseFor(n){return`AND ${n}.symbol NOT LIKE '%().(%' AND ${n}.symbol NOT LIKE '%typeLiteral%'`}all(n,...t){return this.db.prepare(n).all(...t)}get(n,...t){return this.db.prepare(n).get(...t)}sizeBytes(){try{return os(this.config.dbPath).size}catch{return 0}}lastModified(){try{return os(this.config.dbPath).mtime}catch{return null}}close(){this.db.close()}};import _r from"ignore";import{readFileSync as xr,existsSync as Sn}from"fs";import{dirname as _n,isAbsolute as rs,join as xn,relative as Ir,resolve as Nr}from"path";function Ue(e){let n=_r(),t=!1,s=vr(e);for(let i of s)try{let o=xr(i,"utf-8");n.add(o),t=!0}catch{}return t||n.add(Cr),{isIgnored:i=>as(n,e,i),filter:i=>i.filter(o=>!as(n,e,o))}}function vr(e){let n=[],t=xn(e,".gitignore");Sn(t)&&n.push(t);let s=_n(e),i=0;for(;s!==_n(s)&&i<5;){let o=xn(s,".gitignore");if(Sn(o)&&n.push(o),Sn(xn(s,".git")))break;s=_n(s),i++}return n}var Cr=`
21
21
  # Dependencies
22
22
  node_modules/
23
23
  vendor/
@@ -74,15 +74,15 @@ Thumbs.db
74
74
 
75
75
  # Type definitions (often noise in queries)
76
76
  *.d.ts
77
- `;function as(e,n,t){let s=Cr(n,t);if(!s)return!1;try{return e.ignores(s)}catch{return!1}}function Cr(e,n){if(!n||n===".")return null;if(!rs(n)&&!n.startsWith(".."))return n.replaceAll("\\","/");let t=rs(n)?n:Ir(e,n),s=xr(e,t).replaceAll("\\","/");return!s||s==="."||s.startsWith("..")?null:s}import{readFileSync as Er,writeFileSync as Rr,existsSync as cs,mkdirSync as Lr}from"fs";import{join as Fe,resolve as ls}from"path";import{createHash as wr}from"crypto";import{homedir as Dr}from"os";var us=".scipquery.json",kr={enabled:!1,debounceMs:3e4,cooldownMs:6e4,ignore:[]};function Te(e){let n=Fe(e,us);if(!cs(n))return{};try{let t=Er(n,"utf-8");return JSON.parse(t)}catch{return{}}}function ms(e){return{...kr,...e.watch}}function Or(e,n){let t=process.env.SCIP_QUERY_CACHE_DIR;if(t)return In(t);if(n?.dbPath)return In(ls(e,n.dbPath));let i=process.env.XDG_CACHE_HOME||Fe(Dr(),".cache"),o=wr("sha256").update(ls(e)).digest("hex").slice(0,12),a=Fe(i,"scip-query","projects",o);return In(a)}function Ae(e,n){let t=Or(e,n);return{cacheDir:t,dbPath:Fe(t,"index.db"),indexPath:Fe(t,"index.scip"),metaPath:Fe(t,"meta.json")}}function ds(e,n){let t=Fe(e,us);return cs(t)||Rr(t,JSON.stringify({languages:n,watch:{enabled:!1,debounceMs:3e4,cooldownMs:6e4}},null,2)+`
78
- `),t}function In(e){return Lr(e,{recursive:!0}),e}import{execFileSync as js}from"child_process";import{existsSync as Bs,renameSync as Ws,rmSync as Ja}from"fs";import{basename as Ua,dirname as qa,extname as za,join as At}from"path";import{execFileSync as Dt}from"child_process";import{platform as kt,arch as $r}from"os";var ps=kt()==="win32",fs="v0.7.0";function wt(e){let n=ps?"where":"which";try{return Dt(n,[e],{stdio:"pipe"}),!0}catch{return!1}}function Nn(){try{return Dt(ps?"where":"which",["scip"],{stdio:"pipe"}),!0}catch{return!1}}function Pr(){let e=kt(),n=$r(),t,s,i;switch(e){case"darwin":t="darwin",i="tar.gz";break;case"linux":t="linux",i="tar.gz";break;case"win32":t="windows",i="zip";break;default:return null}switch(n){case"arm64":s="arm64";break;case"x64":s="amd64";break;default:return null}let o=`scip-${t}-${s}.${i}`;return{url:`https://github.com/sourcegraph/scip/releases/download/${fs}/${o}`,filename:o}}function vn(){let e=Pr();console.log("\nThe `scip` CLI is required but not found on PATH.\n"),kt()==="darwin"?(console.log("Install via Homebrew:"),console.log(` brew install sourcegraph/scip/scip
77
+ `;function as(e,n,t){let s=Er(n,t);if(!s)return!1;try{return e.ignores(s)}catch{return!1}}function Er(e,n){if(!n||n===".")return null;if(!rs(n)&&!n.startsWith(".."))return n.replaceAll("\\","/");let t=rs(n)?n:Nr(e,n),s=Ir(e,t).replaceAll("\\","/");return!s||s==="."||s.startsWith("..")?null:s}import{readFileSync as Rr,writeFileSync as Lr,existsSync as cs,mkdirSync as wr}from"fs";import{join as Fe,resolve as ls}from"path";import{createHash as Dr}from"crypto";import{homedir as kr}from"os";var us=".scipquery.json",Or={enabled:!1,debounceMs:3e4,cooldownMs:6e4,ignore:[]};function Te(e){let n=Fe(e,us);if(!cs(n))return{};try{let t=Rr(n,"utf-8");return JSON.parse(t)}catch{return{}}}function ms(e){return{...Or,...e.watch}}function $r(e,n){let t=process.env.SCIP_QUERY_CACHE_DIR;if(t)return In(t);if(n?.dbPath)return In(ls(e,n.dbPath));let i=process.env.XDG_CACHE_HOME||Fe(kr(),".cache"),o=Dr("sha256").update(ls(e)).digest("hex").slice(0,12),a=Fe(i,"scip-query","projects",o);return In(a)}function Ae(e,n){let t=$r(e,n);return{cacheDir:t,dbPath:Fe(t,"index.db"),indexPath:Fe(t,"index.scip"),metaPath:Fe(t,"meta.json")}}function ds(e,n){let t=Fe(e,us);return cs(t)||Lr(t,JSON.stringify({languages:n,watch:{enabled:!1,debounceMs:3e4,cooldownMs:6e4}},null,2)+`
78
+ `),t}function In(e){return wr(e,{recursive:!0}),e}import{execFileSync as js}from"child_process";import{existsSync as Bs,renameSync as Ws,rmSync as Ua}from"fs";import{basename as qa,dirname as za,extname as Va,join as At}from"path";import{execFileSync as Dt}from"child_process";import{platform as kt,arch as Pr}from"os";var ps=kt()==="win32",fs="v0.7.0";function wt(e){let n=ps?"where":"which";try{return Dt(n,[e],{stdio:"pipe"}),!0}catch{return!1}}function Nn(){try{return Dt(ps?"where":"which",["scip"],{stdio:"pipe"}),!0}catch{return!1}}function Mr(){let e=kt(),n=Pr(),t,s,i;switch(e){case"darwin":t="darwin",i="tar.gz";break;case"linux":t="linux",i="tar.gz";break;case"win32":t="windows",i="zip";break;default:return null}switch(n){case"arm64":s="arm64";break;case"x64":s="amd64";break;default:return null}let o=`scip-${t}-${s}.${i}`;return{url:`https://github.com/sourcegraph/scip/releases/download/${fs}/${o}`,filename:o}}function vn(){let e=Mr();console.log("\nThe `scip` CLI is required but not found on PATH.\n"),kt()==="darwin"?(console.log("Install via Homebrew:"),console.log(` brew install sourcegraph/scip/scip
79
79
  `),console.log("Or download manually:")):console.log("Download from:"),console.log(e?` ${e.url}
80
80
  `:` https://github.com/sourcegraph/scip/releases/tag/${fs}
81
- `),console.log("After installing, ensure `scip` is on your PATH and run `scip-query reindex`.")}function gs(e){if(kt()==="darwin"&&wt("brew")){e("Installing scip CLI via Homebrew...");try{if(Dt("brew",["install","sourcegraph/scip/scip"],{stdio:"inherit",timeout:3e5,env:process.env}),wt("scip"))return e("Successfully installed scip CLI via Homebrew"),!0}catch(n){let t=n instanceof Error?n.message:String(n);e(`Homebrew install failed: ${t}`)}}if(wt("go")){e("Installing scip CLI via go install...");try{if(Dt("go",["install","github.com/sourcegraph/scip/cmd/scip@latest"],{stdio:"inherit",timeout:3e5,env:process.env}),wt("scip"))return e("Successfully installed scip CLI via go install"),!0}catch(n){let t=n instanceof Error?n.message:String(n);e(`go install failed: ${t}`)}}return e("Could not auto-install scip CLI."),e("Install manually from: https://github.com/sourcegraph/scip/releases"),!1}import Br from"better-sqlite3";import{existsSync as Wr,readdirSync as Hr,readFileSync as Jr}from"fs";import{extname as En,join as bs}from"path";import{readdirSync as Mr}from"fs";import{extname as hs,join as Fr}from"path";function W(e){let n=new WeakMap,t=s=>{let i=n.get(s);return i||(i=new Map,n.set(s,i)),i};return{get(s,i,o){let a=t(s);if(a.has(i))return a.get(i);let r=o();return a.set(i,r),r},invalidate(s,i){n.get(s)?.delete(i)},invalidateAll(s){n.delete(s)},size(s){return n.get(s)?.size??0}}}function je(e){let n=new WeakMap;return{get(t,s){let i=n.get(t);if(i)return i.value;let o=s();return n.set(t,{value:o}),o},invalidate(t){n.delete(t)},has(t){return n.has(t)}}}function Ot(e){let n=new WeakMap,t=s=>{let i=n.get(s);return i||(i=new Map,n.set(s,i)),i};return{get(s,i,o,a){let r=t(s),l=r.get(i);if(l&&l.source===o)return l.value;let c=a();return r.set(i,{source:o,value:c}),c},invalidate(s,i){n.get(s)?.delete(i)},invalidateAll(s){n.delete(s)}}}var Tr=[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs",".vue",".rs",".py",".pyi",".java",".kt",".kts",".scala",".sc",".rb",".c",".h",".cc",".cpp",".cxx",".hpp",".hh",".hxx",".cs",".vb",".php",".dart"],ys=[".vue"],Cn=new Set(["node_modules",".git","target","dist","build",".next",".nuxt",".cache",".turbo","out","coverage",".scipquery-cache","__pycache__",".venv","venv",".idea",".vscode"]);function Re(e,n={}){let t=n.includeIndexed??!0,s=n.includeAuxiliary??!0,i=n.extensions?new Set(n.extensions.map(a=>a.toLowerCase())):new Set(Tr.map(a=>a.toLowerCase())),o=`${t?"1":"0"}|${s?"1":"0"}|${[...i].sort().join(",")}`;return Ar.get(e,o,()=>{let a=new Set;if(t){let r=e.all(`SELECT relative_path
81
+ `),console.log("After installing, ensure `scip` is on your PATH and run `scip-query reindex`.")}function gs(e){if(kt()==="darwin"&&wt("brew")){e("Installing scip CLI via Homebrew...");try{if(Dt("brew",["install","sourcegraph/scip/scip"],{stdio:"inherit",timeout:3e5,env:process.env}),wt("scip"))return e("Successfully installed scip CLI via Homebrew"),!0}catch(n){let t=n instanceof Error?n.message:String(n);e(`Homebrew install failed: ${t}`)}}if(wt("go")){e("Installing scip CLI via go install...");try{if(Dt("go",["install","github.com/sourcegraph/scip/cmd/scip@latest"],{stdio:"inherit",timeout:3e5,env:process.env}),wt("scip"))return e("Successfully installed scip CLI via go install"),!0}catch(n){let t=n instanceof Error?n.message:String(n);e(`go install failed: ${t}`)}}return e("Could not auto-install scip CLI."),e("Install manually from: https://github.com/sourcegraph/scip/releases"),!1}import Wr from"better-sqlite3";import{existsSync as Hr,readdirSync as Jr,readFileSync as Ur}from"fs";import{extname as En,join as bs}from"path";import{readdirSync as Fr}from"fs";import{extname as hs,join as Tr}from"path";function W(e){let n=new WeakMap,t=s=>{let i=n.get(s);return i||(i=new Map,n.set(s,i)),i};return{get(s,i,o){let a=t(s);if(a.has(i))return a.get(i);let r=o();return a.set(i,r),r},invalidate(s,i){n.get(s)?.delete(i)},invalidateAll(s){n.delete(s)},size(s){return n.get(s)?.size??0}}}function je(e){let n=new WeakMap;return{get(t,s){let i=n.get(t);if(i)return i.value;let o=s();return n.set(t,{value:o}),o},invalidate(t){n.delete(t)},has(t){return n.has(t)}}}function Ot(e){let n=new WeakMap,t=s=>{let i=n.get(s);return i||(i=new Map,n.set(s,i)),i};return{get(s,i,o,a){let r=t(s),l=r.get(i);if(l&&l.source===o)return l.value;let c=a();return r.set(i,{source:o,value:c}),c},invalidate(s,i){n.get(s)?.delete(i)},invalidateAll(s){n.delete(s)}}}var Ar=[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs",".vue",".rs",".py",".pyi",".java",".kt",".kts",".scala",".sc",".rb",".c",".h",".cc",".cpp",".cxx",".hpp",".hh",".hxx",".cs",".vb",".php",".dart"],ys=[".vue"],Cn=new Set(["node_modules",".git","target","dist","build",".next",".nuxt",".cache",".turbo","out","coverage",".scipquery-cache","__pycache__",".venv","venv",".idea",".vscode"]);function Re(e,n={}){let t=n.includeIndexed??!0,s=n.includeAuxiliary??!0,i=n.extensions?new Set(n.extensions.map(a=>a.toLowerCase())):new Set(Ar.map(a=>a.toLowerCase())),o=`${t?"1":"0"}|${s?"1":"0"}|${[...i].sort().join(",")}`;return jr.get(e,o,()=>{let a=new Set;if(t){let r=e.all(`SELECT relative_path
82
82
  FROM documents
83
83
  WHERE 1 = 1
84
- ${e.pathExclusionsFor("documents")}`);for(let l of r)e.isIgnored(l.relative_path)||i.has(hs(l.relative_path).toLowerCase())&&a.add(l.relative_path)}if(s)for(let r of jr(e.config.projectRoot,i))e.isIgnored(r)||a.add(r);return[...a].sort()})}var Ar=W("source-files");function jr(e,n){let t=new Set,s=i=>{let o=i?Fr(e,i):e,a=[];try{a=Mr(o,{withFileTypes:!0})}catch{return}for(let r of a)if(!Cn.has(r.name)){if(r.isDirectory()){s(i?`${i}/${r.name}`:r.name);continue}n.has(hs(r.name).toLowerCase())&&t.add(i?`${i}/${r.name}`:r.name)}};return s(""),t}function Be(e){let n=new Set((e.extensions??ys).map(o=>o.toLowerCase()));if(n.size===0)return{scanned:0,inserted:0,existing:0};if(!Wr(e.dbPath))throw new Error(`SCIP SQLite database not found at ${e.dbPath}`);let t=Ue(e.projectRoot),s=Ur(e.projectRoot,n).filter(o=>!t.isIgnored(o)),i=new Br(e.dbPath);try{let o=s.length===0?new Set:new Set(i.prepare(`SELECT relative_path FROM documents WHERE relative_path IN (${s.map(()=>"?").join(",")})`).all(...s).map(m=>m.relative_path)),a=i.prepare(`INSERT OR IGNORE INTO documents (language, relative_path, position_encoding, text)
85
- VALUES (?, ?, NULL, ?)`),l=i.transaction(m=>{let u=0;for(let d of m){if(o.has(d))continue;let g=Jr(bs(e.projectRoot,d),"utf-8"),p=a.run(qr(d),d,g);u+=Number(p.changes)}return u})(s),c={scanned:s.length,inserted:l,existing:s.length-l};return e.onStatus?.(`Augmented SQLite documents with ${l} auxiliary source file${l===1?"":"s"} (${c.existing} already present).`),c}finally{i.close()}}function Ur(e,n){let t=[],s=i=>{let o=i?bs(e,i):e,a=[];try{a=Hr(o,{withFileTypes:!0})}catch{return}for(let r of a){if(Cn.has(r.name))continue;let l=i?`${i}/${r.name}`:r.name;if(r.isDirectory()){s(l);continue}n.has(En(r.name).toLowerCase())&&t.push(l)}};return s(""),t.sort()}function qr(e){return En(e).toLowerCase()===".vue"?"vue":En(e).replace(/^\./,"").toLowerCase()||"source"}import{existsSync as zr,readdirSync as _s}from"fs";import{extname as Vr,join as xs}from"path";var Gr=new Set([".git",".hg",".svn",".idea",".vscode","node_modules","vendor","dist","build","target","bin","obj",".dart_tool",".gradle",".next",".venv","venv","__pycache__"]),Yr=[{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 qe(e){let n=[],t=Kr(e),s=ea(e);for(let i of Yr){if(Qr(e,i.files)){n.push(i.language);continue}if(Xr(t,i.globs)){n.push(i.language);continue}ta(s,i.extensions)&&n.push(i.language)}return n.includes("typescript")&&Ss(n,"javascript"),n.includes("cpp")&&!s.has(".c")&&Ss(n,"c"),n}function Kr(e){try{return _s(e)}catch{return[]}}function Qr(e,n){return n?.length?n.some(t=>zr(xs(e,t))):!1}function Xr(e,n){return n?.length?e.some(t=>n.some(s=>Zr(t,s))):!1}function Zr(e,n){if(n==="*")return!0;if(!n.includes("*"))return e===n;let[t,s]=n.split("*");return e.startsWith(t??"")&&e.endsWith(s??"")}function ea(e){let n=new Set,t=[e];for(;t.length>0;){let s=t.pop();if(!s)continue;let i;try{i=_s(s,{withFileTypes:!0})}catch{continue}for(let o of i){if(o.name.startsWith(".")&&!o.name.endsWith("proj")&&!o.name.endsWith("sln")&&o.isDirectory())continue;let a=xs(s,o.name);if(o.isDirectory()){Gr.has(o.name)||t.push(a);continue}let r=Vr(o.name).toLowerCase();r&&n.add(r)}}return n}function ta(e,n){return n?.length?n.some(t=>e.has(t)):!1}function Ss(e,n){let t=e.indexOf(n);t!==-1&&e.splice(t,1)}import{existsSync as Is,readdirSync as na}from"fs";import{join as Rn}from"path";var sa={typescript:{language:"typescript",indexerBinary:"scip-typescript",checkCommand:"npx scip-typescript --version",indexArgs:({outputPath:e,pnpmWorkspaces:n})=>{let t=["scip-typescript","index","--infer-tsconfig","--output",e,"--no-progress-bar"];return n&&t.splice(2,0,"--pnpm-workspaces"),{binary:"npx",args:t}},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",Ns(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",Ns(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=Rn(e,"vendor","bin","scip-php"),s=Rn(e,"vendor","davidrjenni","scip-php","bin","scip-php");return{binary:"php",args:["-d","error_reporting=E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED",Is(s)?s:Is(t)?t:n]}},defaultOutputPath:"index.scip",markerFiles:["composer.json"],installMethods:[],installUrl:"https://github.com/davidrjenni/scip-php/releases"}};function $t(e){return sa[e]}function Ns(e,n){let t;try{t=na(e)}catch{return null}for(let s of t)if(n.some(i=>s.endsWith(i)))return Rn(e,s);return null}import{readFileSync as ia,writeFileSync as oa}from"fs";import{create as Ln}from"@bufbuild/protobuf";import{deserializeSCIP as ra,serializeSCIP as aa,DocumentSchema as la,IndexSchema as ca,SymbolInformationSchema as ua}from"@c4312/scip";function ma(e){if(e.length===0)throw new Error("Cannot merge zero SCIP indexes");if(e.length===1)return e[0];let n=da(e),t=pa(e.flatMap(i=>i.documents??[])),s=Cs(e.flatMap(i=>i.externalSymbols??[]));return Ln(ca,{metadata:n,documents:t,externalSymbols:s})}function vs(e,n){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let t=e.map(i=>ra(ia(i))),s=ma(t);return oa(n,Buffer.from(aa(s))),{documentCount:s.documents.length,externalSymbolCount:s.externalSymbols.length,inputCount:e.length}}function da(e){let n=e[0]?.metadata;if(!n)return;let t=n.projectRoot;for(let s of e.slice(1)){let i=s.metadata?.projectRoot;if(t&&i&&i!==t)throw new Error(`Cannot merge SCIP indexes with different project roots: ${t} vs ${i}`)}return n}function pa(e){let n=new Map;for(let t of e){let s=n.get(t.relativePath);if(!s){n.set(t.relativePath,t);continue}n.set(t.relativePath,Ln(la,{language:s.language||t.language,relativePath:s.relativePath||t.relativePath,occurrences:[...s.occurrences,...t.occurrences],symbols:Cs([...s.symbols,...t.symbols]),text:ga(s.text,t.text),positionEncoding:s.positionEncoding||t.positionEncoding}))}return[...n.values()]}function Cs(e){let n=new Map;for(let t of e){let s=n.get(t.symbol);if(!s){n.set(t.symbol,t);continue}n.set(t.symbol,Ln(ua,{symbol:s.symbol,documentation:ha([...s.documentation,...t.documentation]),relationships:fa([...s.relationships,...t.relationships]),kind:s.kind||t.kind,displayName:s.displayName||t.displayName,enclosingSymbol:s.enclosingSymbol||t.enclosingSymbol,signatureDocumentation:s.signatureDocumentation??t.signatureDocumentation}))}return[...n.values()]}function fa(e){let n=new Set,t=[];for(let s of e){let i=[s.symbol,s.isReference?"1":"0",s.isImplementation?"1":"0",s.isTypeDefinition?"1":"0",s.isDefinition?"1":"0"].join("|");n.has(i)||(n.add(i),t.push(s))}return t}function ga(e,n){return e?n?e.length>=n.length?e:n:e:n}function ha(e){return[...new Set(e)]}import{execFileSync as Pt}from"child_process";import{existsSync as wn}from"fs";import{createRequire as ya}from"module";import{platform as Es}from"os";import{join as Rs}from"path";var ba=ya(import.meta.url),Sa=Es()==="win32";function lt(e){let n=Sa?"where":"which";try{return Pt(n,[e],{stdio:"pipe"}),!0}catch{return!1}}function Ls(e){return[e.indexerBinary,...e.binaryAliases??[]]}function Mt(e){let n=Ls(e);return n.length===1?n[0]:n.join(" or ")}function ze(e){for(let n of Ls(e))if(lt(n))return n;return Ds(e)?e.indexerBinary:null}function ws(e){return ze(e)!==null||Ds(e)}function Ds(e){if(!e.bundledNpmPackage)return!1;try{return ba.resolve(`${e.bundledNpmPackage}/package.json`),!0}catch{return!1}}function Dn(e,n){for(let t of e.projectLocalBinaries??[]){let s=Rs(n,t);if(wn(s))return s}return null}function _a(e,n){return Dn(e,n)??ze(e)}function ks(e,n=process.env,t=e.indexerBinary){if(e.indexerBinary!=="scip-dotnet"||kn(t,n))return n;let s=Ps(t,n);return s?{...n,DOTNET_ROOT:s}:n}function Os(e,n){let t=Mt(e),s=n?_a(e,n):ze(e);if(!s)return{language:e.language,binaryLabel:t,installed:!1,runnable:!1,resolvedBinary:null,installUrl:e.installUrl};if(e.indexerBinary!=="scip-dotnet")return{language:e.language,binaryLabel:t,installed:!0,runnable:!0,resolvedBinary:s};let i=xa(s);return{language:e.language,binaryLabel:t,installed:!0,runnable:i.runnable,resolvedBinary:s,installUrl:e.installUrl,note:i.note}}function $s(e,n){let t=e.installMethods,s=Mt(e);if(!t?.length)return n(`No auto-install method available for ${s}.`),e.installUrl&&n(`Install manually from: ${e.installUrl}`),!1;for(let i of t)if(lt(i.prerequisite)){n(`Installing ${s} via ${i.label}...`);try{Pt(i.binary,i.args,{stdio:"inherit",timeout:3e5,env:process.env});let o=ze(e);if(o){let a=o===e.indexerBinary?"":` (using ${o})`;return n(`Successfully installed ${s} via ${i.label}${a}`),!0}n(`${i.label} command completed but ${s} was not found on PATH`)}catch(o){let a=o instanceof Error?o.message:String(o);n(`${i.label} install failed: ${a}`)}}return n(`Could not auto-install ${s}.`),e.installUrl&&n(`Install manually from: ${e.installUrl}`),!1}function xa(e){if(kn(e,process.env))return{runnable:!0};let n=Ps(e,process.env);if(n)return{runnable:!0,note:`using .NET 9 runtime from ${n}`};let t=Ms(process.env);return{runnable:!1,note:t.length>0?`.NET 9 runtime still unavailable after checking ${t.join(", ")}`:"binary is present, but scip-dotnet still needs a .NET 9 runtime"}}function Ps(e,n){for(let t of Ms(n))if(kn(e,{...n,DOTNET_ROOT:t}))return t;return null}function Ms(e){let n=[],t=e.DOTNET_ROOT;if(t&&wn(t)&&n.push(t),Es()==="darwin"&&lt("brew"))try{let s=Pt("brew",["--prefix","dotnet@9"],{stdio:"pipe",env:e}).toString().trim(),i=Rs(s,"libexec");wn(i)&&!n.includes(i)&&n.push(i)}catch{}return n}function kn(e,n){try{return Pt(e,["--version"],{stdio:"pipe",env:n}),!0}catch{return!1}}import Ia from"better-sqlite3";import{createRequire as Na}from"module";import{existsSync as Fs,readFileSync as Ft}from"fs";import{dirname as va,extname as Ca,join as Ts,relative as Ea,resolve as Ra}from"path";import{pathToFileURL as La}from"url";function On(e){Be({projectRoot:e.projectRoot,dbPath:e.dbPath});let n=Ra(e.projectRoot,e.tsconfig);if(!Fs(n))throw new Error(`Vue tsconfig not found at ${n}`);let t=Da(e.projectRoot,n),s=t.fileNames.filter(o=>o.endsWith(".vue")),i=new Ia(e.dbPath);try{wa(i);let o=ka(i,e.projectRoot),a=Oa(i,e.projectRoot,s),r=[],l=0;for(let m of s){let u=t.language.scripts.get(m),d=u?.generated?.languagePlugin.typescript?.getServiceScript(u.generated.root)?.code;if(!u||!d){l++;continue}let g=t.language.maps.get(d,u),p=Ft(m,"utf-8");for(let f of Ma(p)){let y=Fa(g,f.start);if(y===null)continue;let b=(t.languageService.getDefinitionAtPosition(m,y+1)??[]).find(x=>!Aa(e.projectRoot,x.fileName));if(!b){l++;continue}let _=$a(b,o,a,t,e.projectRoot);if(_===null){l++;continue}let S=As(p,f.start);r.push({sourceFile:Tt(e.projectRoot,m),sourceLine:S.line,sourceStartChar:S.character,sourceEndChar:S.character+f.text.length,symbolId:_})}}let c=Pa(i,r);return e.onStatus?.(`Resolved ${r.length} Vue references with Volar; inserted ${c} mentions.`),{vueFiles:s.length,resolvedReferences:r.length,insertedMentions:c,skippedReferences:l,syntheticSymbols:a.syntheticSymbols}}finally{i.close()}}function wa(e){e.transaction(()=>{e.prepare(`
84
+ ${e.pathExclusionsFor("documents")}`);for(let l of r)e.isIgnored(l.relative_path)||i.has(hs(l.relative_path).toLowerCase())&&a.add(l.relative_path)}if(s)for(let r of Br(e.config.projectRoot,i))e.isIgnored(r)||a.add(r);return[...a].sort()})}var jr=W("source-files");function Br(e,n){let t=new Set,s=i=>{let o=i?Tr(e,i):e,a=[];try{a=Fr(o,{withFileTypes:!0})}catch{return}for(let r of a)if(!Cn.has(r.name)){if(r.isDirectory()){s(i?`${i}/${r.name}`:r.name);continue}n.has(hs(r.name).toLowerCase())&&t.add(i?`${i}/${r.name}`:r.name)}};return s(""),t}function Be(e){let n=new Set((e.extensions??ys).map(o=>o.toLowerCase()));if(n.size===0)return{scanned:0,inserted:0,existing:0};if(!Hr(e.dbPath))throw new Error(`SCIP SQLite database not found at ${e.dbPath}`);let t=Ue(e.projectRoot),s=qr(e.projectRoot,n).filter(o=>!t.isIgnored(o)),i=new Wr(e.dbPath);try{let o=s.length===0?new Set:new Set(i.prepare(`SELECT relative_path FROM documents WHERE relative_path IN (${s.map(()=>"?").join(",")})`).all(...s).map(m=>m.relative_path)),a=i.prepare(`INSERT OR IGNORE INTO documents (language, relative_path, position_encoding, text)
85
+ VALUES (?, ?, NULL, ?)`),l=i.transaction(m=>{let u=0;for(let d of m){if(o.has(d))continue;let g=Ur(bs(e.projectRoot,d),"utf-8"),p=a.run(zr(d),d,g);u+=Number(p.changes)}return u})(s),c={scanned:s.length,inserted:l,existing:s.length-l};return e.onStatus?.(`Augmented SQLite documents with ${l} auxiliary source file${l===1?"":"s"} (${c.existing} already present).`),c}finally{i.close()}}function qr(e,n){let t=[],s=i=>{let o=i?bs(e,i):e,a=[];try{a=Jr(o,{withFileTypes:!0})}catch{return}for(let r of a){if(Cn.has(r.name))continue;let l=i?`${i}/${r.name}`:r.name;if(r.isDirectory()){s(l);continue}n.has(En(r.name).toLowerCase())&&t.push(l)}};return s(""),t.sort()}function zr(e){return En(e).toLowerCase()===".vue"?"vue":En(e).replace(/^\./,"").toLowerCase()||"source"}import{existsSync as Vr,readdirSync as _s}from"fs";import{extname as Gr,join as xs}from"path";var Yr=new Set([".git",".hg",".svn",".idea",".vscode","node_modules","vendor","dist","build","target","bin","obj",".dart_tool",".gradle",".next",".venv","venv","__pycache__"]),Kr=[{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 qe(e){let n=[],t=Qr(e),s=ta(e);for(let i of Kr){if(Xr(e,i.files)){n.push(i.language);continue}if(Zr(t,i.globs)){n.push(i.language);continue}na(s,i.extensions)&&n.push(i.language)}return n.includes("typescript")&&Ss(n,"javascript"),n.includes("cpp")&&!s.has(".c")&&Ss(n,"c"),n}function Qr(e){try{return _s(e)}catch{return[]}}function Xr(e,n){return n?.length?n.some(t=>Vr(xs(e,t))):!1}function Zr(e,n){return n?.length?e.some(t=>n.some(s=>ea(t,s))):!1}function ea(e,n){if(n==="*")return!0;if(!n.includes("*"))return e===n;let[t,s]=n.split("*");return e.startsWith(t??"")&&e.endsWith(s??"")}function ta(e){let n=new Set,t=[e];for(;t.length>0;){let s=t.pop();if(!s)continue;let i;try{i=_s(s,{withFileTypes:!0})}catch{continue}for(let o of i){if(o.name.startsWith(".")&&!o.name.endsWith("proj")&&!o.name.endsWith("sln")&&o.isDirectory())continue;let a=xs(s,o.name);if(o.isDirectory()){Yr.has(o.name)||t.push(a);continue}let r=Gr(o.name).toLowerCase();r&&n.add(r)}}return n}function na(e,n){return n?.length?n.some(t=>e.has(t)):!1}function Ss(e,n){let t=e.indexOf(n);t!==-1&&e.splice(t,1)}import{existsSync as Is,readdirSync as sa}from"fs";import{join as Rn}from"path";var ia={typescript:{language:"typescript",indexerBinary:"scip-typescript",checkCommand:"npx scip-typescript --version",indexArgs:({outputPath:e,pnpmWorkspaces:n})=>{let t=["scip-typescript","index","--infer-tsconfig","--output",e,"--no-progress-bar"];return n&&t.splice(2,0,"--pnpm-workspaces"),{binary:"npx",args:t}},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",Ns(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",Ns(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=Rn(e,"vendor","bin","scip-php"),s=Rn(e,"vendor","davidrjenni","scip-php","bin","scip-php");return{binary:"php",args:["-d","error_reporting=E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED",Is(s)?s:Is(t)?t:n]}},defaultOutputPath:"index.scip",markerFiles:["composer.json"],installMethods:[],installUrl:"https://github.com/davidrjenni/scip-php/releases"}};function $t(e){return ia[e]}function Ns(e,n){let t;try{t=sa(e)}catch{return null}for(let s of t)if(n.some(i=>s.endsWith(i)))return Rn(e,s);return null}import{readFileSync as oa,writeFileSync as ra}from"fs";import{create as Ln}from"@bufbuild/protobuf";import{deserializeSCIP as aa,serializeSCIP as la,DocumentSchema as ca,IndexSchema as ua,SymbolInformationSchema as ma}from"@c4312/scip";function da(e){if(e.length===0)throw new Error("Cannot merge zero SCIP indexes");if(e.length===1)return e[0];let n=pa(e),t=fa(e.flatMap(i=>i.documents??[])),s=Cs(e.flatMap(i=>i.externalSymbols??[]));return Ln(ua,{metadata:n,documents:t,externalSymbols:s})}function vs(e,n){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let t=e.map(i=>aa(oa(i))),s=da(t);return ra(n,Buffer.from(la(s))),{documentCount:s.documents.length,externalSymbolCount:s.externalSymbols.length,inputCount:e.length}}function pa(e){let n=e[0]?.metadata;if(!n)return;let t=n.projectRoot;for(let s of e.slice(1)){let i=s.metadata?.projectRoot;if(t&&i&&i!==t)throw new Error(`Cannot merge SCIP indexes with different project roots: ${t} vs ${i}`)}return n}function fa(e){let n=new Map;for(let t of e){let s=n.get(t.relativePath);if(!s){n.set(t.relativePath,t);continue}n.set(t.relativePath,Ln(ca,{language:s.language||t.language,relativePath:s.relativePath||t.relativePath,occurrences:[...s.occurrences,...t.occurrences],symbols:Cs([...s.symbols,...t.symbols]),text:ha(s.text,t.text),positionEncoding:s.positionEncoding||t.positionEncoding}))}return[...n.values()]}function Cs(e){let n=new Map;for(let t of e){let s=n.get(t.symbol);if(!s){n.set(t.symbol,t);continue}n.set(t.symbol,Ln(ma,{symbol:s.symbol,documentation:ya([...s.documentation,...t.documentation]),relationships:ga([...s.relationships,...t.relationships]),kind:s.kind||t.kind,displayName:s.displayName||t.displayName,enclosingSymbol:s.enclosingSymbol||t.enclosingSymbol,signatureDocumentation:s.signatureDocumentation??t.signatureDocumentation}))}return[...n.values()]}function ga(e){let n=new Set,t=[];for(let s of e){let i=[s.symbol,s.isReference?"1":"0",s.isImplementation?"1":"0",s.isTypeDefinition?"1":"0",s.isDefinition?"1":"0"].join("|");n.has(i)||(n.add(i),t.push(s))}return t}function ha(e,n){return e?n?e.length>=n.length?e:n:e:n}function ya(e){return[...new Set(e)]}import{execFileSync as Pt}from"child_process";import{existsSync as wn}from"fs";import{createRequire as ba}from"module";import{platform as Es}from"os";import{join as Rs}from"path";var Sa=ba(import.meta.url),_a=Es()==="win32";function lt(e){let n=_a?"where":"which";try{return Pt(n,[e],{stdio:"pipe"}),!0}catch{return!1}}function Ls(e){return[e.indexerBinary,...e.binaryAliases??[]]}function Mt(e){let n=Ls(e);return n.length===1?n[0]:n.join(" or ")}function ze(e){for(let n of Ls(e))if(lt(n))return n;return Ds(e)?e.indexerBinary:null}function ws(e){return ze(e)!==null||Ds(e)}function Ds(e){if(!e.bundledNpmPackage)return!1;try{return Sa.resolve(`${e.bundledNpmPackage}/package.json`),!0}catch{return!1}}function Dn(e,n){for(let t of e.projectLocalBinaries??[]){let s=Rs(n,t);if(wn(s))return s}return null}function xa(e,n){return Dn(e,n)??ze(e)}function ks(e,n=process.env,t=e.indexerBinary){if(e.indexerBinary!=="scip-dotnet"||kn(t,n))return n;let s=Ps(t,n);return s?{...n,DOTNET_ROOT:s}:n}function Os(e,n){let t=Mt(e),s=n?xa(e,n):ze(e);if(!s)return{language:e.language,binaryLabel:t,installed:!1,runnable:!1,resolvedBinary:null,installUrl:e.installUrl};if(e.indexerBinary!=="scip-dotnet")return{language:e.language,binaryLabel:t,installed:!0,runnable:!0,resolvedBinary:s};let i=Ia(s);return{language:e.language,binaryLabel:t,installed:!0,runnable:i.runnable,resolvedBinary:s,installUrl:e.installUrl,note:i.note}}function $s(e,n){let t=e.installMethods,s=Mt(e);if(!t?.length)return n(`No auto-install method available for ${s}.`),e.installUrl&&n(`Install manually from: ${e.installUrl}`),!1;for(let i of t)if(lt(i.prerequisite)){n(`Installing ${s} via ${i.label}...`);try{Pt(i.binary,i.args,{stdio:"inherit",timeout:3e5,env:process.env});let o=ze(e);if(o){let a=o===e.indexerBinary?"":` (using ${o})`;return n(`Successfully installed ${s} via ${i.label}${a}`),!0}n(`${i.label} command completed but ${s} was not found on PATH`)}catch(o){let a=o instanceof Error?o.message:String(o);n(`${i.label} install failed: ${a}`)}}return n(`Could not auto-install ${s}.`),e.installUrl&&n(`Install manually from: ${e.installUrl}`),!1}function Ia(e){if(kn(e,process.env))return{runnable:!0};let n=Ps(e,process.env);if(n)return{runnable:!0,note:`using .NET 9 runtime from ${n}`};let t=Ms(process.env);return{runnable:!1,note:t.length>0?`.NET 9 runtime still unavailable after checking ${t.join(", ")}`:"binary is present, but scip-dotnet still needs a .NET 9 runtime"}}function Ps(e,n){for(let t of Ms(n))if(kn(e,{...n,DOTNET_ROOT:t}))return t;return null}function Ms(e){let n=[],t=e.DOTNET_ROOT;if(t&&wn(t)&&n.push(t),Es()==="darwin"&&lt("brew"))try{let s=Pt("brew",["--prefix","dotnet@9"],{stdio:"pipe",env:e}).toString().trim(),i=Rs(s,"libexec");wn(i)&&!n.includes(i)&&n.push(i)}catch{}return n}function kn(e,n){try{return Pt(e,["--version"],{stdio:"pipe",env:n}),!0}catch{return!1}}import Na from"better-sqlite3";import{createRequire as va}from"module";import{existsSync as Fs,readFileSync as Ft}from"fs";import{dirname as Ca,extname as Ea,join as Ts,relative as Ra,resolve as La}from"path";import{pathToFileURL as wa}from"url";function On(e){Be({projectRoot:e.projectRoot,dbPath:e.dbPath});let n=La(e.projectRoot,e.tsconfig);if(!Fs(n))throw new Error(`Vue tsconfig not found at ${n}`);let t=ka(e.projectRoot,n),s=t.fileNames.filter(o=>o.endsWith(".vue")),i=new Na(e.dbPath);try{Da(i);let o=Oa(i,e.projectRoot),a=$a(i,e.projectRoot,s),r=[],l=0;for(let m of s){let u=t.language.scripts.get(m),d=u?.generated?.languagePlugin.typescript?.getServiceScript(u.generated.root)?.code;if(!u||!d){l++;continue}let g=t.language.maps.get(d,u),p=Ft(m,"utf-8");for(let f of Fa(p)){let y=Ta(g,f.start);if(y===null)continue;let b=(t.languageService.getDefinitionAtPosition(m,y+1)??[]).find(x=>!ja(e.projectRoot,x.fileName));if(!b){l++;continue}let _=Pa(b,o,a,t,e.projectRoot);if(_===null){l++;continue}let S=As(p,f.start);r.push({sourceFile:Tt(e.projectRoot,m),sourceLine:S.line,sourceStartChar:S.character,sourceEndChar:S.character+f.text.length,symbolId:_})}}let c=Ma(i,r);return e.onStatus?.(`Resolved ${r.length} Vue references with Volar; inserted ${c} mentions.`),{vueFiles:s.length,resolvedReferences:r.length,insertedMentions:c,skippedReferences:l,syntheticSymbols:a.syntheticSymbols}}finally{i.close()}}function Da(e){e.transaction(()=>{e.prepare(`
86
86
  DELETE FROM mentions
87
87
  WHERE chunk_id IN (
88
88
  SELECT c.id
@@ -97,7 +97,7 @@ Thumbs.db
97
97
  FROM documents
98
98
  WHERE language = 'vue' OR relative_path LIKE '%.vue'
99
99
  )
100
- `).run()})()}function Da(e,n){let t=Na(La(Ts(e,"package.json")).href),s=t("typescript"),i=t("@vue/language-core"),o=t("@volar/typescript"),a=s.readConfigFile(n,s.sys.readFile);if(a.error||!a.config)throw new Error(`Failed to read ${n}`);let l=i.createParsedCommandLine(s,s.sys,n).vueOptions;typeof i.createGlobalTypesWriter=="function"&&(l.globalTypesPath=i.createGlobalTypesWriter(l,s.sys.writeFile));let c=i.getAllExtensions(l).map(h=>({extension:h.slice(1),isMixedContent:!0,scriptKind:s.ScriptKind.Deferred})),m=va(n),u=s.parseJsonConfigFileContent(a.config,s.sys,m,void 0,n,void 0,c),d=i.createVueLanguagePlugin(s,u.options,l,h=>h),g;g=i.createLanguage([d],new Map,h=>{if(!Fs(h))return;let b=Ft(h,"utf-8");g.scripts.set(h,s.ScriptSnapshot.fromString(b),d.getLanguageId(h)??ja(h))});let p={getCurrentDirectory:()=>m,getCompilationSettings:()=>u.options,getScriptFileNames:()=>u.fileNames,getProjectReferences:()=>u.projectReferences,getProjectVersion:()=>"0"},{languageServiceHost:f}=o.createLanguageServiceHost(s,s.sys,g,h=>h,p),y=s.createLanguageService(f);return{ts:s,language:g,languageService:y,fileNames:u.fileNames,configDir:m}}function ka(e,n){let t=e.prepare(`
100
+ `).run()})()}function ka(e,n){let t=va(wa(Ts(e,"package.json")).href),s=t("typescript"),i=t("@vue/language-core"),o=t("@volar/typescript"),a=s.readConfigFile(n,s.sys.readFile);if(a.error||!a.config)throw new Error(`Failed to read ${n}`);let l=i.createParsedCommandLine(s,s.sys,n).vueOptions;typeof i.createGlobalTypesWriter=="function"&&(l.globalTypesPath=i.createGlobalTypesWriter(l,s.sys.writeFile));let c=i.getAllExtensions(l).map(h=>({extension:h.slice(1),isMixedContent:!0,scriptKind:s.ScriptKind.Deferred})),m=Ca(n),u=s.parseJsonConfigFileContent(a.config,s.sys,m,void 0,n,void 0,c),d=i.createVueLanguagePlugin(s,u.options,l,h=>h),g;g=i.createLanguage([d],new Map,h=>{if(!Fs(h))return;let b=Ft(h,"utf-8");g.scripts.set(h,s.ScriptSnapshot.fromString(b),d.getLanguageId(h)??Ba(h))});let p={getCurrentDirectory:()=>m,getCompilationSettings:()=>u.options,getScriptFileNames:()=>u.fileNames,getProjectReferences:()=>u.projectReferences,getProjectVersion:()=>"0"},{languageServiceHost:f}=o.createLanguageServiceHost(s,s.sys,g,h=>h,p),y=s.createLanguageService(f);return{ts:s,language:g,languageService:y,fileNames:u.fileNames,configDir:m}}function Oa(e,n){let t=e.prepare(`
101
101
  SELECT der.symbol_id AS symbolId
102
102
  FROM defn_enclosing_ranges der
103
103
  JOIN documents d ON d.id = der.document_id
@@ -114,7 +114,7 @@ Thumbs.db
114
114
  AND der.start_line BETWEEN ? AND ?
115
115
  ORDER BY ABS(der.start_line - ?) ASC
116
116
  LIMIT 1
117
- `);return i=>{let o=Tt(n,i.fileName),a=Ba(i.fileName);if(!a)return null;let r=As(a,i.textSpan.start),l=t.get(o,r.line,r.line);return l?l.symbolId:s.get(o,Math.max(0,r.line-2),r.line+2,r.line)?.symbolId??null}}function Oa(e,n,t){let s=Wa(n),i=e.prepare("SELECT id FROM global_symbols WHERE symbol = ?"),o=e.prepare(`
117
+ `);return i=>{let o=Tt(n,i.fileName),a=Wa(i.fileName);if(!a)return null;let r=As(a,i.textSpan.start),l=t.get(o,r.line,r.line);return l?l.symbolId:s.get(o,Math.max(0,r.line-2),r.line+2,r.line)?.symbolId??null}}function $a(e,n,t){let s=Ha(n),i=e.prepare("SELECT id FROM global_symbols WHERE symbol = ?"),o=e.prepare(`
118
118
  INSERT OR IGNORE INTO global_symbols (symbol, display_name, kind, documentation)
119
119
  VALUES (?, ?, ?, ?)
120
120
  `),a=e.prepare("SELECT id FROM documents WHERE relative_path = ?"),r=e.prepare(`
@@ -123,22 +123,22 @@ Thumbs.db
123
123
  `),l=e.prepare(`
124
124
  INSERT OR IGNORE INTO mentions (chunk_id, symbol_id, role)
125
125
  VALUES (?, ?, 1)
126
- `),c=0,m=new Map;return e.transaction(()=>{for(let d of t){let g=Tt(n,d),p=Ha(s.name,s.version,g);o.run(p,"default",7,`Vue component|${g}`);let f=i.get(p);if(!f)continue;c++,m.set(d,f.id);let y=a.get(g);if(!y)continue;let h=r.run(y.id,-1,0,0);l.run(Number(h.lastInsertRowid),f.id)}})(),{get(d){return m.get(d)??null},syntheticSymbols:c}}function $a(e,n,t,s,i){if(e.fileName.endsWith(".vue")){let o=s.language.scripts.get(e.fileName),a=o?.generated?.languagePlugin.typescript?.getServiceScript(o.generated.root)?.code;if(o&&a){let r=s.language.maps.get(a,o);if(Ta(r,e.textSpan.start)!==null)return t.get(e.fileName)}return e.fileName.startsWith(i)?t.get(e.fileName):null}return n(e)}function Pa(e,n){let t=e.prepare("SELECT id FROM documents WHERE relative_path = ?"),s=e.prepare(`
126
+ `),c=0,m=new Map;return e.transaction(()=>{for(let d of t){let g=Tt(n,d),p=Ja(s.name,s.version,g);o.run(p,"default",7,`Vue component|${g}`);let f=i.get(p);if(!f)continue;c++,m.set(d,f.id);let y=a.get(g);if(!y)continue;let h=r.run(y.id,-1,0,0);l.run(Number(h.lastInsertRowid),f.id)}})(),{get(d){return m.get(d)??null},syntheticSymbols:c}}function Pa(e,n,t,s,i){if(e.fileName.endsWith(".vue")){let o=s.language.scripts.get(e.fileName),a=o?.generated?.languagePlugin.typescript?.getServiceScript(o.generated.root)?.code;if(o&&a){let r=s.language.maps.get(a,o);if(Aa(r,e.textSpan.start)!==null)return t.get(e.fileName)}return e.fileName.startsWith(i)?t.get(e.fileName):null}return n(e)}function Ma(e,n){let t=e.prepare("SELECT id FROM documents WHERE relative_path = ?"),s=e.prepare(`
127
127
  INSERT INTO chunks (document_id, chunk_index, start_line, end_line, occurrences)
128
128
  VALUES (?, ?, ?, ?, X'00')
129
129
  `),i=e.prepare(`
130
130
  INSERT OR IGNORE INTO mentions (chunk_id, symbol_id, role)
131
131
  VALUES (?, ?, 0)
132
- `),o=new Set;return e.transaction(()=>{let r=0,l=0;for(let c of n){let m=`${c.sourceFile}:${c.sourceLine}:${c.sourceStartChar}:${c.symbolId}`;if(o.has(m))continue;o.add(m);let u=t.get(c.sourceFile);if(!u)continue;let d=s.run(u.id,l++,c.sourceLine,c.sourceLine),g=i.run(Number(d.lastInsertRowid),c.symbolId);r+=Number(g.changes)}return r})()}function*Ma(e){let n=/\b[A-Za-z_$][A-Za-z0-9_$]*\b/g,t=new Set(["script","setup","template","style","lang","scoped","true","false","null","undefined","const","let","var","import","from","export","return","if","else","for","while","function","class","type","interface","as","await","async"]),s;for(;s=n.exec(e);){let i=s[0];t.has(i)||(yield{text:i,start:s.index,end:s.index+i.length})}}function Fa(e,n){for(let[t]of e.toGeneratedLocation(n,s=>!!s.navigation))return t;return null}function Ta(e,n){let t=e;for(let[s]of t.toSourceLocation(n,i=>!!i.navigation))return s;return null}function As(e,n){let t=0,s=0;for(let i=0;i<n;i++)e.charCodeAt(i)===10&&(t++,s=i+1);return{line:t,character:n-s}}function Aa(e,n){return Tt(e,n).startsWith("node_modules/")}function Tt(e,n){return Ea(e,n).replaceAll("\\","/")}function ja(e){switch(Ca(e)){case".vue":return"vue";case".tsx":return"typescriptreact";case".ts":case".mts":case".cts":return"typescript";case".jsx":return"javascriptreact";case".js":case".mjs":case".cjs":return"javascript";case".json":return"json";default:return"typescript"}}function Ba(e){try{return Ft(e,"utf-8")}catch{return null}}function Wa(e){try{let n=JSON.parse(Ft(Ts(e,"package.json"),"utf-8"));return{name:n.name??"workspace",version:n.version??"0.0.0"}}catch{return{name:"workspace",version:"0.0.0"}}}function Ha(e,n,t){let s=t.split("/").map(i=>`\`${i.replaceAll("`","")}\``).join("/");return`scip-vue npm ${e} ${n} ${s}/default.`}async function Hs(e){let{projectRoot:n,maxHeapMb:t=8192,onStatus:s=console.log,skipAutoInstall:i=!1}=e,o=e.outputScip??At(n,"index.scip"),a=e.outputDb??At(n,"index.db"),r=Date.now(),l=e.languages??qe(n);if(l.length===0)throw new Error("No supported languages detected in this project. Looked for: tsconfig.json, Cargo.toml, go.mod, pyproject.toml, etc.");if(s(`Detected languages: ${l.join(", ")}`),!lt("scip")){if(i)throw new Error(`The scip CLI is required but not found on PATH.
132
+ `),o=new Set;return e.transaction(()=>{let r=0,l=0;for(let c of n){let m=`${c.sourceFile}:${c.sourceLine}:${c.sourceStartChar}:${c.symbolId}`;if(o.has(m))continue;o.add(m);let u=t.get(c.sourceFile);if(!u)continue;let d=s.run(u.id,l++,c.sourceLine,c.sourceLine),g=i.run(Number(d.lastInsertRowid),c.symbolId);r+=Number(g.changes)}return r})()}function*Fa(e){let n=/\b[A-Za-z_$][A-Za-z0-9_$]*\b/g,t=new Set(["script","setup","template","style","lang","scoped","true","false","null","undefined","const","let","var","import","from","export","return","if","else","for","while","function","class","type","interface","as","await","async"]),s;for(;s=n.exec(e);){let i=s[0];t.has(i)||(yield{text:i,start:s.index,end:s.index+i.length})}}function Ta(e,n){for(let[t]of e.toGeneratedLocation(n,s=>!!s.navigation))return t;return null}function Aa(e,n){let t=e;for(let[s]of t.toSourceLocation(n,i=>!!i.navigation))return s;return null}function As(e,n){let t=0,s=0;for(let i=0;i<n;i++)e.charCodeAt(i)===10&&(t++,s=i+1);return{line:t,character:n-s}}function ja(e,n){return Tt(e,n).startsWith("node_modules/")}function Tt(e,n){return Ra(e,n).replaceAll("\\","/")}function Ba(e){switch(Ea(e)){case".vue":return"vue";case".tsx":return"typescriptreact";case".ts":case".mts":case".cts":return"typescript";case".jsx":return"javascriptreact";case".js":case".mjs":case".cjs":return"javascript";case".json":return"json";default:return"typescript"}}function Wa(e){try{return Ft(e,"utf-8")}catch{return null}}function Ha(e){try{let n=JSON.parse(Ft(Ts(e,"package.json"),"utf-8"));return{name:n.name??"workspace",version:n.version??"0.0.0"}}catch{return{name:"workspace",version:"0.0.0"}}}function Ja(e,n,t){let s=t.split("/").map(i=>`\`${i.replaceAll("`","")}\``).join("/");return`scip-vue npm ${e} ${n} ${s}/default.`}async function Hs(e){let{projectRoot:n,maxHeapMb:t=8192,onStatus:s=console.log,skipAutoInstall:i=!1}=e,o=e.outputScip??At(n,"index.scip"),a=e.outputDb??At(n,"index.db"),r=Date.now(),l=e.languages??qe(n);if(l.length===0)throw new Error("No supported languages detected in this project. Looked for: tsconfig.json, Cargo.toml, go.mod, pyproject.toml, etc.");if(s(`Detected languages: ${l.join(", ")}`),!lt("scip")){if(i)throw new Error(`The scip CLI is required but not found on PATH.
133
133
  Install from: https://github.com/sourcegraph/scip/releases`);if(s("scip CLI not found on PATH. Attempting auto-install..."),!gs(s))throw new Error(`The scip CLI is required but could not be installed.
134
- Install manually from: https://github.com/sourcegraph/scip/releases`)}let c={...process.env,NODE_OPTIONS:`--max-old-space-size=${t}`},m=l.map((p,f)=>({language:p,scipPath:l.length>1?Ga(o,p,f):o})),u=[],d=[];for(let{language:p,scipPath:f}of m){let y=$t(p),h=Mt(y),b=Dn(y,n);if(!b&&!ws(y)){if(i){let w=`${h} not found on PATH (auto-install disabled). ${y.installUrl??""}`.trim();s(`Skipping ${p}: ${w}`),d.push({language:p,reason:w});continue}if(s(`${h} not found. Attempting auto-install...`),!$s(y,s)){let w=`${h} could not be auto-installed. ${y.installUrl?`Install manually from ${y.installUrl}`:`Install ${h} and put it on PATH.`}`;s(`Skipping ${p}: ${w}`),d.push({language:p,reason:w});continue}}let _=b??ze(y);if(!_){let w=`${h} was not found after installation checks.`;s(`Skipping ${p}: ${w}`),d.push({language:p,reason:w});continue}s(`Indexing ${p} with ${_}...`);let S=ks(y,c,_),{binary:x,args:L}=y.indexArgs({projectRoot:n,outputPath:f,pnpmWorkspaces:e.pnpmWorkspaces,indexerBinary:_});try{js(x,L,{cwd:n,env:S,stdio:"pipe",maxBuffer:50*1024*1024})}catch(w){let $=w instanceof Error?w.message:String(w),q=`${_} indexer failed: ${$.split(`
135
- `)[0]}`;s(`Skipping ${p}: ${q}`),d.push({language:p,reason:q});continue}Va(y,n,f),u.push({language:p,scipPath:f})}if(u.length===0){let p=d.map(f=>` - ${f.language}: ${f.reason}`).join(`
134
+ Install manually from: https://github.com/sourcegraph/scip/releases`)}let c={...process.env,NODE_OPTIONS:`--max-old-space-size=${t}`},m=l.map((p,f)=>({language:p,scipPath:l.length>1?Ya(o,p,f):o})),u=[],d=[];for(let{language:p,scipPath:f}of m){let y=$t(p),h=Mt(y),b=Dn(y,n);if(!b&&!ws(y)){if(i){let w=`${h} not found on PATH (auto-install disabled). ${y.installUrl??""}`.trim();s(`Skipping ${p}: ${w}`),d.push({language:p,reason:w});continue}if(s(`${h} not found. Attempting auto-install...`),!$s(y,s)){let w=`${h} could not be auto-installed. ${y.installUrl?`Install manually from ${y.installUrl}`:`Install ${h} and put it on PATH.`}`;s(`Skipping ${p}: ${w}`),d.push({language:p,reason:w});continue}}let _=b??ze(y);if(!_){let w=`${h} was not found after installation checks.`;s(`Skipping ${p}: ${w}`),d.push({language:p,reason:w});continue}s(`Indexing ${p} with ${_}...`);let S=ks(y,c,_),{binary:x,args:L}=y.indexArgs({projectRoot:n,outputPath:f,pnpmWorkspaces:e.pnpmWorkspaces,indexerBinary:_});try{js(x,L,{cwd:n,env:S,stdio:"pipe",maxBuffer:50*1024*1024})}catch(w){let $=w instanceof Error?w.message:String(w),q=`${_} indexer failed: ${$.split(`
135
+ `)[0]}`;s(`Skipping ${p}: ${q}`),d.push({language:p,reason:q});continue}Ga(y,n,f),u.push({language:p,scipPath:f})}if(u.length===0){let p=d.map(f=>` - ${f.language}: ${f.reason}`).join(`
136
136
  `);throw new Error(`No language indexers ran successfully. Install at least one indexer for the languages in this project.
137
- `+p)}if(d.length>0&&s(`Indexed ${u.length} of ${l.length} languages; skipped ${d.map(p=>p.language).join(", ")}.`),l.length>1&&(u.length>1?(s(`Merging ${u.length} language indexes...`),vs(u.map(p=>p.scipPath),o)):u[0].scipPath!==o&&Ws(u[0].scipPath,o)),s("Converting to SQLite..."),!Bs(o))throw new Error(`SCIP index not found at ${o} after indexing`);try{js("scip",["expt-convert","--output",a,o],{env:c,stdio:"pipe",maxBuffer:50*1024*1024})}catch(p){let f=p instanceof Error?p.message:String(p);throw new Error(`Failed to convert SCIP index to SQLite: ${f}`,{cause:p})}finally{for(let{scipPath:p}of m)p!==o&&Ja(p,{force:!0})}Be({projectRoot:n,dbPath:a,onStatus:s});let g=Date.now()-r;return s(`Done in ${(g/1e3).toFixed(1)}s`),{languages:u.map(p=>p.language),indexPath:o,dbPath:a,durationMs:g,skipped:d}}function Va(e,n,t){if(!e.defaultOutputPath)return;let s=At(n,e.defaultOutputPath);t!==s&&Bs(s)&&Ws(s,t)}function Ga(e,n,t){let s=za(e)||".scip",i=Ua(e,s);return At(qa(e),`${i}.${t+1}.${n}${s}`)}import{watch as Ya}from"fs";import{existsSync as Js,renameSync as Us}from"fs";import{join as Ka,relative as Qa}from"path";import{fork as Xa}from"child_process";import Za from"ignore";var jt=class{projectRoot;watchConfig;indexPaths;languages;pnpmWorkspaces;onStatus;onReindexComplete;onError;status={state:"idle"};debounceTimer=null;cooldownTimer=null;dirty=!1;changedFiles=0;reindexInFlight=!1;lastReindexEnd=0;fsWatchers=[];gitignoreFilter;extraIgnore;stopped=!1;constructor(n){this.projectRoot=n.projectRoot,this.watchConfig=ms(n.config),this.indexPaths=Ae(n.projectRoot,n.config),this.languages=n.languages,this.pnpmWorkspaces=n.config.indexer?.typescript?.pnpmWorkspaces??!1,this.onStatus=n.onStatus??(()=>{}),this.onReindexComplete=n.onReindexComplete??(()=>{}),this.onError=n.onError??(t=>console.error(t.message)),this.gitignoreFilter=Ue(n.projectRoot),this.extraIgnore=Za(),this.watchConfig.ignore.length>0&&this.extraIgnore.add(this.watchConfig.ignore)}start(){this.stopped=!1,this.setStatus({state:"idle"});try{let n=Ya(this.projectRoot,{recursive:!0},(t,s)=>{s&&!this.stopped&&this.handleFileChange(s)});this.fsWatchers.push(n)}catch{this.onError(new Error("Failed to start file watcher. On Linux, you may need to increase inotify limits: sysctl -w fs.inotify.max_user_watches=524288"))}}stop(){this.stopped=!0;for(let n of this.fsWatchers)n.close();this.fsWatchers=[],this.debounceTimer&&clearTimeout(this.debounceTimer),this.cooldownTimer&&clearTimeout(this.cooldownTimer),this.setStatus({state:"idle"})}handleFileChange(n){let t=Qa(this.projectRoot,Ka(this.projectRoot,n));if(this.gitignoreFilter.isIgnored(t)||this.extraIgnore.ignores(t)||n.endsWith("index.db")||n.endsWith("index.scip")||n.endsWith("index.db.tmp")||n.endsWith(".scipquery.json"))return;if(this.changedFiles++,this.reindexInFlight){this.dirty=!0,this.setStatus({state:"indexing",startedAt:this.status.startedAt});return}if(this.status.state==="cooldown"){this.dirty=!0,this.setStatus({state:"cooldown",until:this.status.until,dirty:!0});return}this.debounceTimer&&clearTimeout(this.debounceTimer);let s=Date.now()+this.watchConfig.debounceMs;this.setStatus({state:"waiting",changedFiles:this.changedFiles,reindexAt:s}),this.debounceTimer=setTimeout(()=>{this.debounceTimer=null,this.triggerReindex()},this.watchConfig.debounceMs)}triggerReindex(){if(this.reindexInFlight||this.stopped)return;let n=Date.now()-this.lastReindexEnd;if(this.lastReindexEnd>0&&n<this.watchConfig.cooldownMs){let s=this.watchConfig.cooldownMs-n;this.dirty=!0;let i=Date.now()+s;this.setStatus({state:"cooldown",until:i,dirty:!0}),this.cooldownTimer=setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped&&(this.dirty=!1,this.triggerReindex())},s);return}this.reindexInFlight=!0,this.dirty=!1,this.changedFiles=0;let t=Date.now();this.setStatus({state:"indexing",startedAt:t}),this.runReindex().then(s=>{if(this.reindexInFlight=!1,this.lastReindexEnd=Date.now(),this.onReindexComplete(s),this.dirty&&!this.stopped){let i=Date.now()+this.watchConfig.cooldownMs;this.setStatus({state:"cooldown",until:i,dirty:!0}),this.cooldownTimer=setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped?(this.dirty=!1,this.triggerReindex()):this.setStatus({state:"idle"})},this.watchConfig.cooldownMs)}else this.setStatus({state:"idle"})}).catch(s=>{this.reindexInFlight=!1,this.lastReindexEnd=Date.now(),this.onError(s instanceof Error?s:new Error(String(s))),this.setStatus({state:"idle"})})}runReindex(){return new Promise((n,t)=>{let s=Date.now(),i=this.indexPaths.dbPath+".tmp",o=el(this.indexPaths.indexPath),a=Xa(new URL("./reindex-worker.js",import.meta.url).pathname,[],{env:{...process.env,SCIP_REINDEX_PROJECT_ROOT:this.projectRoot,SCIP_REINDEX_OUTPUT_SCIP:o,SCIP_REINDEX_OUTPUT_DB:i,SCIP_REINDEX_LANGUAGES:this.languages?.join(",")??"",SCIP_REINDEX_PNPM_WORKSPACES:this.pnpmWorkspaces?"1":""},stdio:"pipe"});a.on("exit",r=>{if(r===0)try{Js(i)&&Us(i,this.indexPaths.dbPath),Js(o)&&Us(o,this.indexPaths.indexPath),n(Date.now()-s)}catch(l){t(new Error(`Atomic swap failed: ${l}`))}else t(new Error(`Reindex worker exited with code ${r}`))}),a.on("error",t)})}setStatus(n){this.status=n,this.onStatus(n)}};function el(e){return e.endsWith(".scip")?e.slice(0,-5)+".tmp.scip":e+".tmp.scip"}function Bt(e){let n=e.get("SELECT COUNT(*) as c FROM documents").c,t=e.get("SELECT COUNT(*) as c FROM global_symbols").c,s=e.get("SELECT COUNT(*) as c FROM mentions WHERE role = 1").c,i=e.get("SELECT COUNT(*) as c FROM mentions WHERE role != 1").c;return{documents:n,symbols:t,definitions:s,references:i,indexSizeBytes:e.sizeBytes(),lastBuilt:e.lastModified()}}function tl(e){return/[*?]/.test(e)?e.replace(/\*\*/g,"%").replace(/\*/g,"%").replace(/\?/g,"_"):`%${e}%`}function qs(e,n){let t=tl(n);return e.all(`SELECT relative_path FROM documents
137
+ `+p)}if(d.length>0&&s(`Indexed ${u.length} of ${l.length} languages; skipped ${d.map(p=>p.language).join(", ")}.`),l.length>1&&(u.length>1?(s(`Merging ${u.length} language indexes...`),vs(u.map(p=>p.scipPath),o)):u[0].scipPath!==o&&Ws(u[0].scipPath,o)),s("Converting to SQLite..."),!Bs(o))throw new Error(`SCIP index not found at ${o} after indexing`);try{js("scip",["expt-convert","--output",a,o],{env:c,stdio:"pipe",maxBuffer:50*1024*1024})}catch(p){let f=p instanceof Error?p.message:String(p);throw new Error(`Failed to convert SCIP index to SQLite: ${f}`,{cause:p})}finally{for(let{scipPath:p}of m)p!==o&&Ua(p,{force:!0})}Be({projectRoot:n,dbPath:a,onStatus:s});let g=Date.now()-r;return s(`Done in ${(g/1e3).toFixed(1)}s`),{languages:u.map(p=>p.language),indexPath:o,dbPath:a,durationMs:g,skipped:d}}function Ga(e,n,t){if(!e.defaultOutputPath)return;let s=At(n,e.defaultOutputPath);t!==s&&Bs(s)&&Ws(s,t)}function Ya(e,n,t){let s=Va(e)||".scip",i=qa(e,s);return At(za(e),`${i}.${t+1}.${n}${s}`)}import{watch as Ka}from"fs";import{existsSync as Js,renameSync as Us}from"fs";import{join as Qa,relative as Xa}from"path";import{fork as Za}from"child_process";import el from"ignore";var jt=class{projectRoot;watchConfig;indexPaths;languages;pnpmWorkspaces;onStatus;onReindexComplete;onError;status={state:"idle"};debounceTimer=null;cooldownTimer=null;dirty=!1;changedFiles=0;reindexInFlight=!1;lastReindexEnd=0;fsWatchers=[];gitignoreFilter;extraIgnore;stopped=!1;constructor(n){this.projectRoot=n.projectRoot,this.watchConfig=ms(n.config),this.indexPaths=Ae(n.projectRoot,n.config),this.languages=n.languages,this.pnpmWorkspaces=n.config.indexer?.typescript?.pnpmWorkspaces??!1,this.onStatus=n.onStatus??(()=>{}),this.onReindexComplete=n.onReindexComplete??(()=>{}),this.onError=n.onError??(t=>console.error(t.message)),this.gitignoreFilter=Ue(n.projectRoot),this.extraIgnore=el(),this.watchConfig.ignore.length>0&&this.extraIgnore.add(this.watchConfig.ignore)}start(){this.stopped=!1,this.setStatus({state:"idle"});try{let n=Ka(this.projectRoot,{recursive:!0},(t,s)=>{s&&!this.stopped&&this.handleFileChange(s)});this.fsWatchers.push(n)}catch{this.onError(new Error("Failed to start file watcher. On Linux, you may need to increase inotify limits: sysctl -w fs.inotify.max_user_watches=524288"))}}stop(){this.stopped=!0;for(let n of this.fsWatchers)n.close();this.fsWatchers=[],this.debounceTimer&&clearTimeout(this.debounceTimer),this.cooldownTimer&&clearTimeout(this.cooldownTimer),this.setStatus({state:"idle"})}handleFileChange(n){let t=Xa(this.projectRoot,Qa(this.projectRoot,n));if(this.gitignoreFilter.isIgnored(t)||this.extraIgnore.ignores(t)||n.endsWith("index.db")||n.endsWith("index.scip")||n.endsWith("index.db.tmp")||n.endsWith(".scipquery.json"))return;if(this.changedFiles++,this.reindexInFlight){this.dirty=!0,this.setStatus({state:"indexing",startedAt:this.status.startedAt});return}if(this.status.state==="cooldown"){this.dirty=!0,this.setStatus({state:"cooldown",until:this.status.until,dirty:!0});return}this.debounceTimer&&clearTimeout(this.debounceTimer);let s=Date.now()+this.watchConfig.debounceMs;this.setStatus({state:"waiting",changedFiles:this.changedFiles,reindexAt:s}),this.debounceTimer=setTimeout(()=>{this.debounceTimer=null,this.triggerReindex()},this.watchConfig.debounceMs)}triggerReindex(){if(this.reindexInFlight||this.stopped)return;let n=Date.now()-this.lastReindexEnd;if(this.lastReindexEnd>0&&n<this.watchConfig.cooldownMs){let s=this.watchConfig.cooldownMs-n;this.dirty=!0;let i=Date.now()+s;this.setStatus({state:"cooldown",until:i,dirty:!0}),this.cooldownTimer=setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped&&(this.dirty=!1,this.triggerReindex())},s);return}this.reindexInFlight=!0,this.dirty=!1,this.changedFiles=0;let t=Date.now();this.setStatus({state:"indexing",startedAt:t}),this.runReindex().then(s=>{if(this.reindexInFlight=!1,this.lastReindexEnd=Date.now(),this.onReindexComplete(s),this.dirty&&!this.stopped){let i=Date.now()+this.watchConfig.cooldownMs;this.setStatus({state:"cooldown",until:i,dirty:!0}),this.cooldownTimer=setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped?(this.dirty=!1,this.triggerReindex()):this.setStatus({state:"idle"})},this.watchConfig.cooldownMs)}else this.setStatus({state:"idle"})}).catch(s=>{this.reindexInFlight=!1,this.lastReindexEnd=Date.now(),this.onError(s instanceof Error?s:new Error(String(s))),this.setStatus({state:"idle"})})}runReindex(){return new Promise((n,t)=>{let s=Date.now(),i=this.indexPaths.dbPath+".tmp",o=tl(this.indexPaths.indexPath),a=Za(new URL("./reindex-worker.js",import.meta.url).pathname,[],{env:{...process.env,SCIP_REINDEX_PROJECT_ROOT:this.projectRoot,SCIP_REINDEX_OUTPUT_SCIP:o,SCIP_REINDEX_OUTPUT_DB:i,SCIP_REINDEX_LANGUAGES:this.languages?.join(",")??"",SCIP_REINDEX_PNPM_WORKSPACES:this.pnpmWorkspaces?"1":""},stdio:"pipe"});a.on("exit",r=>{if(r===0)try{Js(i)&&Us(i,this.indexPaths.dbPath),Js(o)&&Us(o,this.indexPaths.indexPath),n(Date.now()-s)}catch(l){t(new Error(`Atomic swap failed: ${l}`))}else t(new Error(`Reindex worker exited with code ${r}`))}),a.on("error",t)})}setStatus(n){this.status=n,this.onStatus(n)}};function tl(e){return e.endsWith(".scip")?e.slice(0,-5)+".tmp.scip":e+".tmp.scip"}function Bt(e){let n=e.get("SELECT COUNT(*) as c FROM documents").c,t=e.get("SELECT COUNT(*) as c FROM global_symbols").c,s=e.get("SELECT COUNT(*) as c FROM mentions WHERE role = 1").c,i=e.get("SELECT COUNT(*) as c FROM mentions WHERE role != 1").c;return{documents:n,symbols:t,definitions:s,references:i,indexSizeBytes:e.sizeBytes(),lastBuilt:e.lastModified()}}function nl(e){return/[*?]/.test(e)?e.replace(/\*\*/g,"%").replace(/\*/g,"%").replace(/\?/g,"_"):`%${e}%`}function qs(e,n){let t=nl(n);return e.all(`SELECT relative_path FROM documents
138
138
  WHERE relative_path LIKE ?
139
- ORDER BY relative_path`,t).filter(i=>!e.isIgnored(i.relative_path)).map(i=>({relativePath:i.relative_path}))}import{extname as Ks}from"path";import{createRequire as al}from"module";import{existsSync as nl,readFileSync as sl}from"fs";import{join as il}from"path";var ol=W("source-text");function M(e,n){let t=n.replace(/\\/g,"/");return ol.get(e,t,()=>{let s=il(e.config.projectRoot,t);return nl(s)?sl(s,"utf-8"):""})}var rl=/scip-query[\s:-]*ignore[\s:-]*(?:dead(?:-code)?|stale|wrapper|passthrough|drift)?/i;function pe(e,n,t){if(t<=0)return!1;let s=M(e,n);if(!s)return!1;let i=s.split(`
140
- `);for(let o=t-1;o>=0&&o>=t-5;o-=1){let a=(i[o]??"").trim();if(a!==""){if(rl.test(a))return!0;if(!a.startsWith("//")&&!a.startsWith("*")&&!a.startsWith("/*")&&!a.startsWith("@")&&!a.startsWith("#"))return!1}}return!1}var X=al(import.meta.url),Wt=null,zs=!1;function Qs(){if(zs)return null;if(Wt)return Wt;try{return Wt=X("tree-sitter"),Wt}catch{return zs=!0,null}}var ll={".rs":"rust",".ts":"typescript",".mts":"typescript",".cts":"typescript",".tsx":"tsx",".js":"javascript",".jsx":"javascript",".mjs":"javascript",".cjs":"javascript",".py":"python",".pyi":"python",".java":"java",".kt":"kotlin",".kts":"kotlin",".scala":"scala",".sc":"scala",".rb":"ruby",".c":"c",".h":"c",".cc":"cpp",".cpp":"cpp",".cxx":"cpp",".hpp":"cpp",".hh":"cpp",".hxx":"cpp",".cs":"csharp",".php":"php",".vb":"vb"},Vs=new Map,$n=new Set;function Xs(e){if($n.has(e))return null;let n=Vs.get(e);if(n)return n;let t;try{switch(e){case"rust":t=X("tree-sitter-rust");break;case"typescript":t=X("tree-sitter-typescript").typescript;break;case"tsx":t=X("tree-sitter-typescript").tsx;break;case"javascript":t=X("tree-sitter-javascript");break;case"python":t=X("tree-sitter-python");break;case"java":t=X("tree-sitter-java");break;case"kotlin":t=X("tree-sitter-kotlin");break;case"scala":t=X("tree-sitter-scala");break;case"ruby":t=X("tree-sitter-ruby");break;case"c":t=X("tree-sitter-c");break;case"cpp":t=X("tree-sitter-cpp");break;case"csharp":t=X("tree-sitter-c-sharp");break;case"php":t=X("tree-sitter-php").php;break;case"vb":{let s=X("tree-sitter-vb-dotnet");t=s.language??s;break}}}catch{return $n.add(e),null}return Vs.set(e,t),t}var Gs=new Map;function Zs(e){let n=Gs.get(e);if(n)return n;let t=Xs(e);if(!t)return null;let s=Qs();if(!s)return null;let i=new s;try{i.setLanguage(t)}catch{return $n.add(e),null}return Gs.set(e,i),i}function P(e){return ll[Ks(e).toLowerCase()]??null}function mt(e){return Ks(e).toLowerCase()===".vue"}var ei=Ot("ast-trees");function O(e,n){if(mt(n))return cl(e,n);let t=P(n);if(!t)return null;let s=M(e,n);return s?ei.get(e,n,s,()=>{let i=Zs(t);return i?i.parse(s):null}):null}function cl(e,n){let t=M(e,n);return t?ei.get(e,n,t,()=>{let s=ul(t);if(!s)return null;let i=Zs(s.language);if(!i)return null;let o=`
141
- `.repeat(s.startLine)+s.body;return i.parse(o)}):null}function ul(e){let n=[],t=/<script\b([^>]*)>([\s\S]*?)<\/script>/g;for(let l of e.matchAll(t))typeof l.index=="number"&&n.push({tagOpen:l[1]??"",body:l[2]??"",openIdx:l.index+(l[0].length-(l[2]?.length??0)-9)});if(n.length===0)return null;let s=n.find(l=>/\bsetup\b/.test(l.tagOpen))??n[0],o=s.tagOpen.match(/\blang\s*=\s*["']?([\w-]+)/)?.[1]?.toLowerCase(),a=o==="ts"||o==="typescript"?"typescript":o==="tsx"?"tsx":"javascript",r=ml(e,s.openIdx);return{body:s.body,startLine:r,language:a}}function ml(e,n){let t=0;for(let s=0;s<n&&s<e.length;s++)e.charCodeAt(s)===10&&t++;return t}var ct=new Map;function dl(e,n){let t=`${e}::${n}`;if(ct.has(t))return ct.get(t)??null;let s=Xs(e);if(!s)return ct.set(t,null),null;let i=Qs();if(!i)return ct.set(t,null),null;let o=null;try{o=new i.Query(s,n)}catch{o=null}return ct.set(t,o),o}var pl={rust:`
139
+ ORDER BY relative_path`,t).filter(i=>!e.isIgnored(i.relative_path)).map(i=>({relativePath:i.relative_path}))}import{extname as Ks}from"path";import{createRequire as ll}from"module";import{existsSync as sl,readFileSync as il}from"fs";import{join as ol}from"path";var rl=W("source-text");function M(e,n){let t=n.replace(/\\/g,"/");return rl.get(e,t,()=>{let s=ol(e.config.projectRoot,t);return sl(s)?il(s,"utf-8"):""})}var al=/scip-query[\s:-]*ignore[\s:-]*(?:dead(?:-code)?|stale|wrapper|passthrough|drift)?/i;function pe(e,n,t){if(t<=0)return!1;let s=M(e,n);if(!s)return!1;let i=s.split(`
140
+ `);for(let o=t-1;o>=0&&o>=t-5;o-=1){let a=(i[o]??"").trim();if(a!==""){if(al.test(a))return!0;if(!a.startsWith("//")&&!a.startsWith("*")&&!a.startsWith("/*")&&!a.startsWith("@")&&!a.startsWith("#"))return!1}}return!1}var X=ll(import.meta.url),Wt=null,zs=!1;function Qs(){if(zs)return null;if(Wt)return Wt;try{return Wt=X("tree-sitter"),Wt}catch{return zs=!0,null}}var cl={".rs":"rust",".ts":"typescript",".mts":"typescript",".cts":"typescript",".tsx":"tsx",".js":"javascript",".jsx":"javascript",".mjs":"javascript",".cjs":"javascript",".py":"python",".pyi":"python",".java":"java",".kt":"kotlin",".kts":"kotlin",".scala":"scala",".sc":"scala",".rb":"ruby",".c":"c",".h":"c",".cc":"cpp",".cpp":"cpp",".cxx":"cpp",".hpp":"cpp",".hh":"cpp",".hxx":"cpp",".cs":"csharp",".php":"php",".vb":"vb"},Vs=new Map,$n=new Set;function Xs(e){if($n.has(e))return null;let n=Vs.get(e);if(n)return n;let t;try{switch(e){case"rust":t=X("tree-sitter-rust");break;case"typescript":t=X("tree-sitter-typescript").typescript;break;case"tsx":t=X("tree-sitter-typescript").tsx;break;case"javascript":t=X("tree-sitter-javascript");break;case"python":t=X("tree-sitter-python");break;case"java":t=X("tree-sitter-java");break;case"kotlin":t=X("tree-sitter-kotlin");break;case"scala":t=X("tree-sitter-scala");break;case"ruby":t=X("tree-sitter-ruby");break;case"c":t=X("tree-sitter-c");break;case"cpp":t=X("tree-sitter-cpp");break;case"csharp":t=X("tree-sitter-c-sharp");break;case"php":t=X("tree-sitter-php").php;break;case"vb":{let s=X("tree-sitter-vb-dotnet");t=s.language??s;break}}}catch{return $n.add(e),null}return Vs.set(e,t),t}var Gs=new Map;function Zs(e){let n=Gs.get(e);if(n)return n;let t=Xs(e);if(!t)return null;let s=Qs();if(!s)return null;let i=new s;try{i.setLanguage(t)}catch{return $n.add(e),null}return Gs.set(e,i),i}function P(e){return cl[Ks(e).toLowerCase()]??null}function mt(e){return Ks(e).toLowerCase()===".vue"}var ei=Ot("ast-trees");function O(e,n){if(mt(n))return ul(e,n);let t=P(n);if(!t)return null;let s=M(e,n);return s?ei.get(e,n,s,()=>{let i=Zs(t);if(!i)return null;try{return ti(i,s)}catch{return null}}):null}function ul(e,n){let t=M(e,n);return t?ei.get(e,n,t,()=>{let s=ml(t);if(!s)return null;let i=Zs(s.language);if(!i)return null;let o=`
141
+ `.repeat(s.startLine)+s.body;try{return ti(i,o)}catch{return null}}):null}function ti(e,n){return e.parse(s=>s>=n.length?null:n.slice(s,Math.min(n.length,s+16384)))}function ml(e){let n=[],t=/<script\b([^>]*)>([\s\S]*?)<\/script>/g;for(let l of e.matchAll(t))typeof l.index=="number"&&n.push({tagOpen:l[1]??"",body:l[2]??"",openIdx:l.index+(l[0].length-(l[2]?.length??0)-9)});if(n.length===0)return null;let s=n.find(l=>/\bsetup\b/.test(l.tagOpen))??n[0],o=s.tagOpen.match(/\blang\s*=\s*["']?([\w-]+)/)?.[1]?.toLowerCase(),a=o==="ts"||o==="typescript"?"typescript":o==="tsx"?"tsx":"javascript",r=dl(e,s.openIdx);return{body:s.body,startLine:r,language:a}}function dl(e,n){let t=0;for(let s=0;s<n&&s<e.length;s++)e.charCodeAt(s)===10&&t++;return t}var ct=new Map;function pl(e,n){let t=`${e}::${n}`;if(ct.has(t))return ct.get(t)??null;let s=Xs(e);if(!s)return ct.set(t,null),null;let i=Qs();if(!i)return ct.set(t,null),null;let o=null;try{o=new i.Query(s,n)}catch{o=null}return ct.set(t,o),o}var fl={rust:`
142
142
  (function_item name: (identifier) @name) @def
143
143
  (function_signature_item name: (identifier) @name) @def
144
144
  `,typescript:`
@@ -164,7 +164,7 @@ Install manually from: https://github.com/sourcegraph/scip/releases`)}let c={...
164
164
  (variable_declarator name: (identifier) @name value: (function_expression)) @def
165
165
  `,python:`
166
166
  (function_definition name: (identifier) @name) @def
167
- `},fl=new WeakMap;function ti(e,n){return si(e,n,fl,pl,t=>{let s=[];for(let i of t){let o=null,a=null;for(let r of i.captures)r.name==="name"?o=r.node.text:r.name==="def"&&(a={startLine:r.node.startPosition.row,endLine:r.node.endPosition.row});o&&a&&s.push({name:o,startLine:a.startLine,endLine:a.endLine})}return s})}var gl={rust:`
167
+ `},gl=new WeakMap;function ni(e,n){return ii(e,n,gl,fl,t=>{let s=[];for(let i of t){let o=null,a=null;for(let r of i.captures)r.name==="name"?o=r.node.text:r.name==="def"&&(a={startLine:r.node.startPosition.row,endLine:r.node.endPosition.row});o&&a&&s.push({name:o,startLine:a.startLine,endLine:a.endLine})}return s})}var hl={rust:`
168
168
  (call_expression function: (_) @target) @call
169
169
  (macro_invocation macro: (_) @target) @call
170
170
  `,typescript:`
@@ -178,7 +178,7 @@ Install manually from: https://github.com/sourcegraph/scip/releases`)}let c={...
178
178
  (new_expression constructor: (_) @target) @call
179
179
  `,python:`
180
180
  (call function: (_) @target) @call
181
- `},hl=new WeakMap;function Ht(e,n){return si(e,n,hl,gl,t=>{let s=[];for(let i of t){let o=null,a=null;for(let l of i.captures)l.name==="target"?o=l.node:l.name==="call"&&(a=l.node);if(!o||!a)continue;let r=ut(o);r&&s.push({calleeLeaf:r,line:a.startPosition.row})}return s})}function ni(e,n){return Jt(e,n,yl,()=>new Map,(t,s,i)=>{let o=(l,c)=>{if(l===c)return;let m=i.get(l);m||(m=new Set,i.set(l,m)),m.add(c)},a=s==="python"?new Set(["identifier"]):new Set(["type_identifier"]),r=(l,c)=>{let m=u=>{a.has(u.type)&&u.text!==c&&o(u.text,c);for(let d of u.children)m(d)};for(let u of l.children)m(u)};if(s==="rust")for(let l of t.rootNode.descendantsOfType(["struct_item","enum_item","union_item","type_item"])){let c=l.namedChildren.find(u=>u.type==="type_identifier")?.text;if(!c)continue;let m=l.namedChildren.find(u=>u.type==="field_declaration_list"||u.type==="enum_variant_list"||u.type==="ordered_field_declaration_list");m&&r(m,c),l.type==="type_item"&&r(l,c)}else if(s==="python")for(let l of t.rootNode.descendantsOfType("class_definition")){let c=l.namedChildren.find(u=>u.type==="identifier")?.text;if(!c)continue;let m=l.namedChildren.find(u=>u.type==="block");if(m)for(let u of m.descendantsOfType("type"))for(let d of u.descendantsOfType("identifier"))d.text!==c&&o(d.text,c)}else for(let l of t.rootNode.descendantsOfType(["interface_declaration","type_alias_declaration","class_declaration"])){let c=l.namedChildren.find(m=>m.type==="type_identifier")?.text;c&&r(l,c)}})??new Map}function Jt(e,n,t,s,i){let o=P(n);if(!o)return null;let a=O(e,n);if(!a)return null;let r=t.get(a);if(r)return r;let l=s();return i(a,o,l),t.set(a,l),l}function si(e,n,t,s,i){let o=P(n);if(!o)return null;let a=s[o];if(!a)return null;let r=O(e,n);if(!r)return null;let l=t.get(r);if(l)return l;let c=dl(o,a);if(!c)return null;let m=i(c.matches(r.rootNode));return t.set(r,m),m}var yl=new WeakMap,Ys=new WeakMap;function Pn(e,n,t,s){let i=P(n);if(!i)return null;let o=O(e,n);if(!o)return null;let a=Ys.get(o);return a||(a=bl(o,i),Ys.set(o,a)),a.get(`${t}:${s}`)??null}function bl(e,n){let t=n==="rust"?new Set(["function_item","function_signature_item"]):n==="python"?new Set(["function_definition"]):new Set(["function_declaration","method_definition","arrow_function","function_expression"]),s=new Map,i=o=>{if(t.has(o.type)){let a=o.namedChildren.find(l=>l.type==="parameters"||l.type==="formal_parameters"),r=0;if(a)for(let l of a.namedChildren)l.type==="comment"||l.type==="line_comment"||l.type==="block_comment"||(r+=1);s.set(`${o.startPosition.row}:${o.endPosition.row}`,{paramCount:r})}for(let a of o.children)i(a)};return i(e.rootNode),s}function ut(e){switch(e.type){case"identifier":case"type_identifier":case"property_identifier":case"shorthand_property_identifier":return e.text;case"field_expression":case"member_expression":case"attribute":{let n=e.namedChild(e.namedChildCount-1);return n?ut(n):null}case"scoped_identifier":{let n=e.childForFieldName("name")??e.namedChild(e.namedChildCount-1);return n?ut(n):null}case"super":case"self":case"this":return null;default:return null}}var Sl={"/":"namespace","#":"type",".":"term","[":"type-param",":":"meta","!":"macro"};function V(e){if(e.startsWith("local "))return{kind:"local",id:e.slice(6),raw:e};let n=e.split(" ");if(n.length<4)return{scheme:n[0]??"",manager:n[1]??"",packageName:n[2]??"",version:"",descriptors:[],raw:e};let t=n[0],s=n[1],i=e.slice(t.length+1+s.length+1),o;if(i.startsWith("`")){let c=i.indexOf("`",1);c===-1?(o=i.slice(1),i=""):(o=i.slice(1,c),i=i.slice(c+2))}else{let c=i.indexOf(" ");c===-1?(o=i,i=""):(o=i.slice(0,c),i=i.slice(c+1))}let a,r=i.indexOf(" ");r===-1?(a=i,i=""):(a=i.slice(0,r),i=i.slice(r+1));let l=_l(i);return{scheme:t,manager:s,packageName:o,version:a,descriptors:l,raw:e}}function _l(e){let n=[],t=0;for(;t<e.length;){if(e[t]==="["){let o=e.indexOf("]",t+1);if(o===-1){n.push({name:e.slice(t+1),suffix:"type-param"});break}n.push({name:e.slice(t+1,o),suffix:"type-param"}),t=o+1;continue}if(e[t]==="("&&(n.length===0||t===0||ii(e[t-1]))){let o=e.indexOf(")",t+1);if(o!==-1&&e[o+1]!=="."){n.push({name:e.slice(t+1,o),suffix:"parameter"}),t=o+1;continue}}let s;if(e[t]==="`"){let o=e.indexOf("`",t+1);if(o===-1){s=e.slice(t+1),n.push({name:s,suffix:"term"});break}s=e.slice(t+1,o),t=o+1}else{let o=t;for(;t<e.length&&!ii(e[t]);)t++;s=e.slice(o,t)}if(t>=e.length){s&&n.push({name:s,suffix:"term"});break}let i=e[t];if(i==="("){let o=e.indexOf(")",t+1);o!==-1&&e[o+1]==="."?(n.push({name:s,suffix:"method"}),t=o+2):o!==-1?(n.push({name:s,suffix:"method"}),t=o+1):(n.push({name:s,suffix:"term"}),t++)}else{let o=Sl[i];o&&n.push({name:s,suffix:o}),t+=1}}return n}function ii(e){return e==="/"||e==="#"||e==="."||e==="("||e==="["||e===":"||e==="!"}function I(e){let n=V(e);if("kind"in n&&n.kind==="local")return`local:${n.id}`;let t=n;if(t.descriptors.length===0)return t.raw;let s=[];for(let i of t.descriptors){let o=i.name;i.suffix==="namespace"&&(o=o.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)$/,"")),o&&(i.suffix==="method"?s.push(`${o}()`):s.push(o))}return s.join(":")}function F(e){let n=V(e);if("kind"in n&&n.kind==="local")return n.id;let t=n;return t.descriptors.length===0?"":t.descriptors[t.descriptors.length-1].name}function ie(e){let n=V(e);if("kind"in n&&n.kind==="local")return null;let t=n;return t.descriptors[t.descriptors.length-1]?.suffix??null}function Ve(e){return e.endsWith("().")||ie(e)==="method"}function j(e){let n=ie(e);return n==="method"||n==="term"}function Ge(e){return ie(e)==="namespace"}var xl=/^rust-analyzer\b.*[\s/]impl#\[[^\]]+\]\[[^\]]+\]/;function Ye(e){return xl.test(e)}var Il=new Set(["test","tests","_tests"]);function G(e){let n=V(e);if("kind"in n)return!1;for(let t=0;t<n.descriptors.length-1;t+=1){let s=n.descriptors[t];if(s?.suffix==="namespace"&&s.name&&Il.has(s.name))return!0}return!1}function oi(e,n){let t=V(e),s=V(n);if("kind"in t||"kind"in s)return!1;let i=t.descriptors,o=s.descriptors;if(o.length!==i.length+1)return!1;for(let a=0;a<i.length;a++){let r=i[a],l=o[a];if(r.name!==l.name||r.suffix!==l.suffix)return!1}return!0}function ri(e,n){let t=V(e),s=V(n);if("kind"in t||"kind"in s)return!1;let i=t.descriptors,o=s.descriptors;if(o.length<=i.length)return!1;for(let a=0;a<i.length;a++){let r=i[a],l=o[a];if(r.name!==l.name||r.suffix!==l.suffix)return!1}return!0}function dt(e){return!e||!e.trim()?null:e.replace(/^```\w*\s*/,"").replace(/\s*```$/,"").replace(/^\(method\)\s*/,"").replace(/^\(property\)\s*/,"").replace(/^\(function\)\s*/,"").replace(/^\(class\)\s*/,"").replace(/^\(interface\)\s*/,"").replace(/^\(enum\)\s*/,"").replace(/^\(type alias\)\s*/,"").replace(/^\(const\)\s*/,"").replace(/^\(var\)\s*/,"").trim()||null}function pt(e){if(!e)return null;let n=e.indexOf("|");return n===-1?e.replace(/\n/g," "):e.slice(n+1).replace(/\n/g," ")}var Nl=W("file-definitions");function A(e,n){return Nl.get(e,n,()=>{let t=e.all(`SELECT
181
+ `},yl=new WeakMap;function Ht(e,n){return ii(e,n,yl,hl,t=>{let s=[];for(let i of t){let o=null,a=null;for(let l of i.captures)l.name==="target"?o=l.node:l.name==="call"&&(a=l.node);if(!o||!a)continue;let r=ut(o);r&&s.push({calleeLeaf:r,line:a.startPosition.row})}return s})}function si(e,n){return Jt(e,n,bl,()=>new Map,(t,s,i)=>{let o=(l,c)=>{if(l===c)return;let m=i.get(l);m||(m=new Set,i.set(l,m)),m.add(c)},a=s==="python"?new Set(["identifier"]):new Set(["type_identifier"]),r=(l,c)=>{let m=u=>{a.has(u.type)&&u.text!==c&&o(u.text,c);for(let d of u.children)m(d)};for(let u of l.children)m(u)};if(s==="rust")for(let l of t.rootNode.descendantsOfType(["struct_item","enum_item","union_item","type_item"])){let c=l.namedChildren.find(u=>u.type==="type_identifier")?.text;if(!c)continue;let m=l.namedChildren.find(u=>u.type==="field_declaration_list"||u.type==="enum_variant_list"||u.type==="ordered_field_declaration_list");m&&r(m,c),l.type==="type_item"&&r(l,c)}else if(s==="python")for(let l of t.rootNode.descendantsOfType("class_definition")){let c=l.namedChildren.find(u=>u.type==="identifier")?.text;if(!c)continue;let m=l.namedChildren.find(u=>u.type==="block");if(m)for(let u of m.descendantsOfType("type"))for(let d of u.descendantsOfType("identifier"))d.text!==c&&o(d.text,c)}else for(let l of t.rootNode.descendantsOfType(["interface_declaration","type_alias_declaration","class_declaration"])){let c=l.namedChildren.find(m=>m.type==="type_identifier")?.text;c&&r(l,c)}})??new Map}function Jt(e,n,t,s,i){let o=P(n);if(!o)return null;let a=O(e,n);if(!a)return null;let r=t.get(a);if(r)return r;let l=s();return i(a,o,l),t.set(a,l),l}function ii(e,n,t,s,i){let o=P(n);if(!o)return null;let a=s[o];if(!a)return null;let r=O(e,n);if(!r)return null;let l=t.get(r);if(l)return l;let c=pl(o,a);if(!c)return null;let m=i(c.matches(r.rootNode));return t.set(r,m),m}var bl=new WeakMap,Ys=new WeakMap;function Pn(e,n,t,s){let i=P(n);if(!i)return null;let o=O(e,n);if(!o)return null;let a=Ys.get(o);return a||(a=Sl(o,i),Ys.set(o,a)),a.get(`${t}:${s}`)??null}function Sl(e,n){let t=n==="rust"?new Set(["function_item","function_signature_item"]):n==="python"?new Set(["function_definition"]):new Set(["function_declaration","method_definition","arrow_function","function_expression"]),s=new Map,i=o=>{if(t.has(o.type)){let a=o.namedChildren.find(l=>l.type==="parameters"||l.type==="formal_parameters"),r=0;if(a)for(let l of a.namedChildren)l.type==="comment"||l.type==="line_comment"||l.type==="block_comment"||(r+=1);s.set(`${o.startPosition.row}:${o.endPosition.row}`,{paramCount:r})}for(let a of o.children)i(a)};return i(e.rootNode),s}function ut(e){switch(e.type){case"identifier":case"type_identifier":case"property_identifier":case"shorthand_property_identifier":return e.text;case"field_expression":case"member_expression":case"attribute":{let n=e.namedChild(e.namedChildCount-1);return n?ut(n):null}case"scoped_identifier":{let n=e.childForFieldName("name")??e.namedChild(e.namedChildCount-1);return n?ut(n):null}case"super":case"self":case"this":return null;default:return null}}var _l={"/":"namespace","#":"type",".":"term","[":"type-param",":":"meta","!":"macro"};function V(e){if(e.startsWith("local "))return{kind:"local",id:e.slice(6),raw:e};let n=e.split(" ");if(n.length<4)return{scheme:n[0]??"",manager:n[1]??"",packageName:n[2]??"",version:"",descriptors:[],raw:e};let t=n[0],s=n[1],i=e.slice(t.length+1+s.length+1),o;if(i.startsWith("`")){let c=i.indexOf("`",1);c===-1?(o=i.slice(1),i=""):(o=i.slice(1,c),i=i.slice(c+2))}else{let c=i.indexOf(" ");c===-1?(o=i,i=""):(o=i.slice(0,c),i=i.slice(c+1))}let a,r=i.indexOf(" ");r===-1?(a=i,i=""):(a=i.slice(0,r),i=i.slice(r+1));let l=xl(i);return{scheme:t,manager:s,packageName:o,version:a,descriptors:l,raw:e}}function xl(e){let n=[],t=0;for(;t<e.length;){if(e[t]==="["){let o=e.indexOf("]",t+1);if(o===-1){n.push({name:e.slice(t+1),suffix:"type-param"});break}n.push({name:e.slice(t+1,o),suffix:"type-param"}),t=o+1;continue}if(e[t]==="("&&(n.length===0||t===0||oi(e[t-1]))){let o=e.indexOf(")",t+1);if(o!==-1&&e[o+1]!=="."){n.push({name:e.slice(t+1,o),suffix:"parameter"}),t=o+1;continue}}let s;if(e[t]==="`"){let o=e.indexOf("`",t+1);if(o===-1){s=e.slice(t+1),n.push({name:s,suffix:"term"});break}s=e.slice(t+1,o),t=o+1}else{let o=t;for(;t<e.length&&!oi(e[t]);)t++;s=e.slice(o,t)}if(t>=e.length){s&&n.push({name:s,suffix:"term"});break}let i=e[t];if(i==="("){let o=e.indexOf(")",t+1);o!==-1&&e[o+1]==="."?(n.push({name:s,suffix:"method"}),t=o+2):o!==-1?(n.push({name:s,suffix:"method"}),t=o+1):(n.push({name:s,suffix:"term"}),t++)}else{let o=_l[i];o&&n.push({name:s,suffix:o}),t+=1}}return n}function oi(e){return e==="/"||e==="#"||e==="."||e==="("||e==="["||e===":"||e==="!"}function I(e){let n=V(e);if("kind"in n&&n.kind==="local")return`local:${n.id}`;let t=n;if(t.descriptors.length===0)return t.raw;let s=[];for(let i of t.descriptors){let o=i.name;i.suffix==="namespace"&&(o=o.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)$/,"")),o&&(i.suffix==="method"?s.push(`${o}()`):s.push(o))}return s.join(":")}function F(e){let n=V(e);if("kind"in n&&n.kind==="local")return n.id;let t=n;return t.descriptors.length===0?"":t.descriptors[t.descriptors.length-1].name}function ie(e){let n=V(e);if("kind"in n&&n.kind==="local")return null;let t=n;return t.descriptors[t.descriptors.length-1]?.suffix??null}function Ve(e){return e.endsWith("().")||ie(e)==="method"}function j(e){let n=ie(e);return n==="method"||n==="term"}function Ge(e){return ie(e)==="namespace"}var Il=/^rust-analyzer\b.*[\s/]impl#\[[^\]]+\]\[[^\]]+\]/;function Ye(e){return Il.test(e)}var Nl=new Set(["test","tests","_tests"]);function G(e){let n=V(e);if("kind"in n)return!1;for(let t=0;t<n.descriptors.length-1;t+=1){let s=n.descriptors[t];if(s?.suffix==="namespace"&&s.name&&Nl.has(s.name))return!0}return!1}function ri(e,n){let t=V(e),s=V(n);if("kind"in t||"kind"in s)return!1;let i=t.descriptors,o=s.descriptors;if(o.length!==i.length+1)return!1;for(let a=0;a<i.length;a++){let r=i[a],l=o[a];if(r.name!==l.name||r.suffix!==l.suffix)return!1}return!0}function ai(e,n){let t=V(e),s=V(n);if("kind"in t||"kind"in s)return!1;let i=t.descriptors,o=s.descriptors;if(o.length<=i.length)return!1;for(let a=0;a<i.length;a++){let r=i[a],l=o[a];if(r.name!==l.name||r.suffix!==l.suffix)return!1}return!0}function dt(e){return!e||!e.trim()?null:e.replace(/^```\w*\s*/,"").replace(/\s*```$/,"").replace(/^\(method\)\s*/,"").replace(/^\(property\)\s*/,"").replace(/^\(function\)\s*/,"").replace(/^\(class\)\s*/,"").replace(/^\(interface\)\s*/,"").replace(/^\(enum\)\s*/,"").replace(/^\(type alias\)\s*/,"").replace(/^\(const\)\s*/,"").replace(/^\(var\)\s*/,"").trim()||null}function pt(e){if(!e)return null;let n=e.indexOf("|");return n===-1?e.replace(/\n/g," "):e.slice(n+1).replace(/\n/g," ")}var vl=W("file-definitions");function A(e,n){return vl.get(e,n,()=>{let t=e.all(`SELECT
182
182
  gs.id,
183
183
  gs.symbol,
184
184
  der.document_id,
@@ -213,12 +213,12 @@ Install manually from: https://github.com/sourcegraph/scip/releases`)}let c={...
213
213
  AND m.role = 1
214
214
  ${e.symbolNoiseFor("gs")}
215
215
  GROUP BY gs.id, gs.symbol, c.document_id, d.relative_path
216
- ORDER BY start_line, end_line`,n);return vl(e,n,(t.length>0?t:s).map(i=>({symbolId:i.id,symbol:i.symbol,documentId:i.document_id,startLine:i.start_line,endLine:i.end_line,relativePath:i.relative_path,leaf:F(i.symbol),parentTypeName:Dl(i.symbol),isFunctionLike:j(i.symbol),isTypeLike:ie(i.symbol)==="type",kind:i.kind??null,documentation:i.documentation??null,enclosingSymbol:i.enclosing_symbol??null})))})}function Z(e,n={}){return Y(e,n.scope)}function Y(e,n){let t=n?`AND relative_path LIKE '%${n}%'`:"";return e.all(`SELECT relative_path
216
+ ORDER BY start_line, end_line`,n);return Cl(e,n,(t.length>0?t:s).map(i=>({symbolId:i.id,symbol:i.symbol,documentId:i.document_id,startLine:i.start_line,endLine:i.end_line,relativePath:i.relative_path,leaf:F(i.symbol),parentTypeName:kl(i.symbol),isFunctionLike:j(i.symbol),isTypeLike:ie(i.symbol)==="type",kind:i.kind??null,documentation:i.documentation??null,enclosingSymbol:i.enclosing_symbol??null})))})}function Z(e,n={}){return Y(e,n.scope)}function Y(e,n){let t=n?`AND relative_path LIKE '%${n}%'`:"";return e.all(`SELECT relative_path
217
217
  FROM documents
218
218
  WHERE 1 = 1
219
219
  ${e.pathExclusionsFor("documents")}
220
220
  ${t}
221
- ORDER BY relative_path`).flatMap(s=>A(e,s.relative_path)).filter(s=>!e.isIgnored(s.relativePath))}function Ke(e,n,t={}){if(n.length===0)return[];let s=n.flatMap(i=>A(e,i)).filter(i=>!e.isIgnored(i.relativePath));return t.onlyDocumented&&(s=s.filter(i=>i.documentation!==null&&i.documentation!=="")),t.sort&&(s=s.sort((i,o)=>i.relativePath.localeCompare(o.relativePath)||i.startLine-o.startLine||i.endLine-o.endLine)),s.map(i=>({startLine:i.startLine,endLine:i.endLine,symbol:i.symbol,shortName:I(i.symbol),signature:dt(pt(i.documentation)),relativePath:i.relativePath,enclosingSymbol:i.enclosingSymbol}))}function fe(e,n){let t=null;for(let s of e)s.startLine>n||s.endLine<n||(!t||s.endLine-s.startLine<t.endLine-t.startLine)&&(t=s);return t}function Qe(e,n){let t=A(e,n.relative_path).find(s=>s.symbolId===n.id);return t?{symbolId:t.symbolId,symbol:t.symbol,documentId:t.documentId,startLine:t.startLine,endLine:t.endLine,relativePath:t.relativePath}:{symbolId:n.id,symbol:n.symbol,documentId:n.document_id,startLine:n.start_line,endLine:n.end_line,relativePath:n.relative_path}}function vl(e,n,t){let s=ti(e,n);if(s)return Cl(t,s);let i=M(e,n);if(!i)return t;let o=i.split(/\r?\n/),a=t.some(m=>Ut(m.symbol))?Rl(o):null,r=new Map;for(let m of t)r.set(m.symbolId,El(o,a,m));let l=new Map,c=t.filter(m=>Ut(m.symbol)).map(m=>({definition:m,startLine:r.get(m.symbolId)??m.startLine})).sort((m,u)=>m.startLine-u.startLine||m.definition.startLine-u.definition.startLine||m.definition.symbol.localeCompare(u.definition.symbol));for(let m=0;m<c.length;m+=1){let u=c[m],d=c[m+1],g=d?Math.max(u.startLine,d.startLine-1):o.length-1;l.set(u.definition.symbolId,{startLine:u.startLine,endLine:Ll(o,u.definition,u.startLine,g)})}return t.map(m=>{let u=l.get(m.symbolId);return u?{...m,startLine:u.startLine,endLine:u.endLine}:m})}function Cl(e,n){let t=new Map;for(let s of n){let i=t.get(s.name);i?i.push(s):t.set(s.name,[s])}return e.map(s=>{if(!Ut(s.symbol)||!s.leaf)return s;let i=t.get(s.leaf);if(!i||i.length===0)return s;let o=i[0],a=Math.abs(o.startLine-s.startLine);for(let r=1;r<i.length;r+=1){let l=i[r],c=Math.abs(l.startLine-s.startLine);c<a&&(o=l,a=c)}return{...s,startLine:o.startLine,endLine:o.endLine}})}function El(e,n,t){if(!Ut(t.symbol))return t.startLine;let s=Math.max(0,Math.min(t.startLine,e.length-1));if(!n)return s;let i=n.get(t.leaf);if(!i||i.length===0)return s;let o=null;for(let a of i){let r=Math.abs(a-t.startLine);(!o||r<o.distance)&&(o={line:a,distance:r})}return o?.line??s}function Rl(e){let n=/\b(?:function|def|fn)\s+([A-Za-z_$][\w$]*)/g,t=/\b([A-Za-z_$][\w$]*)\s*[:=]\s*(?:async\s*)?(?:function\b|\()/g,s=/^\s*(?:(?:export|public|private|protected|static|readonly|async|abstract|get|set)\s+)*([A-Za-z_$][\w$]*)\s*(?:<[^(]*>)?\s*\(/,i=/\b([A-Za-z_$][\w$]*)\s*\(/g,o=new Map,a=(r,l)=>{let c=o.get(r);if(!c){o.set(r,[l]);return}c[c.length-1]!==l&&c.push(l)};for(let r=0;r<e.length;r+=1){let l=e[r]??"";for(let m of l.matchAll(n))m[1]&&a(m[1],r);for(let m of l.matchAll(t))m[1]&&a(m[1],r);let c=l.match(s);c?.[1]&&a(c[1],r);for(let m of l.matchAll(i))m[1]&&a(m[1],r)}return o}function Ll(e,n,t,s){let i=Math.max(t,Math.min(e.length-1,s)),o=Math.max(t,Math.min(i,n.endLine)),a=0,r=0,l=!1;for(let c=t;c<=i;c+=1){let m=wl(e[c]??"");for(let u of m)u==="{"?(a+=1,l=!0):u==="}"?a=Math.max(0,a-1):u==="("?r+=1:u===")"&&(r=Math.max(0,r-1));if(l&&a===0||!l&&r===0&&c>=o)return c}return o}function wl(e){let n="",t=null,s=!1;for(let i=0;i<e.length;i+=1){let o=e[i],a=e[i+1];if(!t&&o==="/"&&a==="/"){n+=" ".repeat(e.length-i);break}if(t){if(s){s=!1,n+=" ";continue}if(o==="\\"){s=!0,n+=" ";continue}o===t&&(t=null),n+=" ";continue}if(o==='"'||o==="'"||o==="`"){t=o,n+=" ";continue}n+=o}return n}function Ut(e){return e.includes("().")}function Dl(e){let n=V(e);if("kind"in n)return null;for(let t=n.descriptors.length-2;t>=0;t--){let s=n.descriptors[t];if(s?.suffix==="type")return s.name}return null}function ai(e){let n=V(e);if("kind"in n)return[];let t=[];for(let s=n.descriptors.length-2;s>=0;s-=1){let i=n.descriptors[s];i?.suffix==="type"&&i.name&&t.push(i.name)}return t}import{existsSync as Fl}from"fs";import{basename as ci,isAbsolute as Tl,join as Al}from"path";function k(e,n){let t=Xe(e,n.trim());if(t)return t;let s=n.match(/^(.+):(\d+)-(\d+)$/);if(s){let[,c,m,u]=s,d=Math.max(0,parseInt(m,10)-1),g=Math.max(d,parseInt(u,10)-1),p=e.get(`SELECT gs.id, gs.symbol, der.document_id, der.start_line, der.end_line, d.relative_path
221
+ ORDER BY relative_path`).flatMap(s=>A(e,s.relative_path)).filter(s=>!e.isIgnored(s.relativePath))}function Ke(e,n,t={}){if(n.length===0)return[];let s=n.flatMap(i=>A(e,i)).filter(i=>!e.isIgnored(i.relativePath));return t.onlyDocumented&&(s=s.filter(i=>i.documentation!==null&&i.documentation!=="")),t.sort&&(s=s.sort((i,o)=>i.relativePath.localeCompare(o.relativePath)||i.startLine-o.startLine||i.endLine-o.endLine)),s.map(i=>({startLine:i.startLine,endLine:i.endLine,symbol:i.symbol,shortName:I(i.symbol),signature:dt(pt(i.documentation)),relativePath:i.relativePath,enclosingSymbol:i.enclosingSymbol}))}function fe(e,n){let t=null;for(let s of e)s.startLine>n||s.endLine<n||(!t||s.endLine-s.startLine<t.endLine-t.startLine)&&(t=s);return t}function Qe(e,n){let t=A(e,n.relative_path).find(s=>s.symbolId===n.id);return t?{symbolId:t.symbolId,symbol:t.symbol,documentId:t.documentId,startLine:t.startLine,endLine:t.endLine,relativePath:t.relativePath}:{symbolId:n.id,symbol:n.symbol,documentId:n.document_id,startLine:n.start_line,endLine:n.end_line,relativePath:n.relative_path}}function Cl(e,n,t){let s=ni(e,n);if(s)return El(t,s);let i=M(e,n);if(!i)return t;let o=i.split(/\r?\n/),a=t.some(m=>Ut(m.symbol))?Ll(o):null,r=new Map;for(let m of t)r.set(m.symbolId,Rl(o,a,m));let l=new Map,c=t.filter(m=>Ut(m.symbol)).map(m=>({definition:m,startLine:r.get(m.symbolId)??m.startLine})).sort((m,u)=>m.startLine-u.startLine||m.definition.startLine-u.definition.startLine||m.definition.symbol.localeCompare(u.definition.symbol));for(let m=0;m<c.length;m+=1){let u=c[m],d=c[m+1],g=d?Math.max(u.startLine,d.startLine-1):o.length-1;l.set(u.definition.symbolId,{startLine:u.startLine,endLine:wl(o,u.definition,u.startLine,g)})}return t.map(m=>{let u=l.get(m.symbolId);return u?{...m,startLine:u.startLine,endLine:u.endLine}:m})}function El(e,n){let t=new Map;for(let s of n){let i=t.get(s.name);i?i.push(s):t.set(s.name,[s])}return e.map(s=>{if(!Ut(s.symbol)||!s.leaf)return s;let i=t.get(s.leaf);if(!i||i.length===0)return s;let o=i[0],a=Math.abs(o.startLine-s.startLine);for(let r=1;r<i.length;r+=1){let l=i[r],c=Math.abs(l.startLine-s.startLine);c<a&&(o=l,a=c)}return{...s,startLine:o.startLine,endLine:o.endLine}})}function Rl(e,n,t){if(!Ut(t.symbol))return t.startLine;let s=Math.max(0,Math.min(t.startLine,e.length-1));if(!n)return s;let i=n.get(t.leaf);if(!i||i.length===0)return s;let o=null;for(let a of i){let r=Math.abs(a-t.startLine);(!o||r<o.distance)&&(o={line:a,distance:r})}return o?.line??s}function Ll(e){let n=/\b(?:function|def|fn)\s+([A-Za-z_$][\w$]*)/g,t=/\b([A-Za-z_$][\w$]*)\s*[:=]\s*(?:async\s*)?(?:function\b|\()/g,s=/^\s*(?:(?:export|public|private|protected|static|readonly|async|abstract|get|set)\s+)*([A-Za-z_$][\w$]*)\s*(?:<[^(]*>)?\s*\(/,i=/\b([A-Za-z_$][\w$]*)\s*\(/g,o=new Map,a=(r,l)=>{let c=o.get(r);if(!c){o.set(r,[l]);return}c[c.length-1]!==l&&c.push(l)};for(let r=0;r<e.length;r+=1){let l=e[r]??"";for(let m of l.matchAll(n))m[1]&&a(m[1],r);for(let m of l.matchAll(t))m[1]&&a(m[1],r);let c=l.match(s);c?.[1]&&a(c[1],r);for(let m of l.matchAll(i))m[1]&&a(m[1],r)}return o}function wl(e,n,t,s){let i=Math.max(t,Math.min(e.length-1,s)),o=Math.max(t,Math.min(i,n.endLine)),a=0,r=0,l=!1;for(let c=t;c<=i;c+=1){let m=Dl(e[c]??"");for(let u of m)u==="{"?(a+=1,l=!0):u==="}"?a=Math.max(0,a-1):u==="("?r+=1:u===")"&&(r=Math.max(0,r-1));if(l&&a===0||!l&&r===0&&c>=o)return c}return o}function Dl(e){let n="",t=null,s=!1;for(let i=0;i<e.length;i+=1){let o=e[i],a=e[i+1];if(!t&&o==="/"&&a==="/"){n+=" ".repeat(e.length-i);break}if(t){if(s){s=!1,n+=" ";continue}if(o==="\\"){s=!0,n+=" ";continue}o===t&&(t=null),n+=" ";continue}if(o==='"'||o==="'"||o==="`"){t=o,n+=" ";continue}n+=o}return n}function Ut(e){return e.includes("().")}function kl(e){let n=V(e);if("kind"in n)return null;for(let t=n.descriptors.length-2;t>=0;t--){let s=n.descriptors[t];if(s?.suffix==="type")return s.name}return null}function li(e){let n=V(e);if("kind"in n)return[];let t=[];for(let s=n.descriptors.length-2;s>=0;s-=1){let i=n.descriptors[s];i?.suffix==="type"&&i.name&&t.push(i.name)}return t}import{existsSync as Tl}from"fs";import{basename as ui,isAbsolute as Al,join as jl}from"path";function k(e,n){let t=Xe(e,n.trim());if(t)return t;let s=n.match(/^(.+):(\d+)-(\d+)$/);if(s){let[,c,m,u]=s,d=Math.max(0,parseInt(m,10)-1),g=Math.max(d,parseInt(u,10)-1),p=e.get(`SELECT gs.id, gs.symbol, der.document_id, der.start_line, der.end_line, d.relative_path
222
222
  FROM global_symbols gs
223
223
  JOIN defn_enclosing_ranges der ON gs.id = der.symbol_id
224
224
  JOIN documents d ON der.document_id = d.id
@@ -237,7 +237,7 @@ Install manually from: https://github.com/sourcegraph/scip/releases`)}let c={...
237
237
  ${e.pathExclusionsFor("d")}
238
238
  GROUP BY gs.id, gs.symbol, c.document_id, d.relative_path
239
239
  ORDER BY (MAX(c.end_line) - MIN(c.start_line)) ASC
240
- LIMIT 1`,`%${c}%`,d,g)),p&&!e.isIgnored(p.relative_path))return Qe(e,p)}let i=li(n),o=Pl(n),a=Ol(e,o),r=Ml(a,n,i);if(r&&!e.isIgnored(r.relative_path))return Qe(e,r);let l=null;for(let c of a){if(e.isIgnored(c.relative_path))continue;let m=$l(c,n,i,o);m<=0||(!l||m>l.score)&&(l={row:c,score:m})}return l?Qe(e,l.row):null}function Xe(e,n){let s=e.get(`SELECT gs.id, gs.symbol, der.document_id, der.start_line, der.end_line, d.relative_path
240
+ LIMIT 1`,`%${c}%`,d,g)),p&&!e.isIgnored(p.relative_path))return Qe(e,p)}let i=ci(n),o=Ml(n),a=$l(e,o),r=Fl(a,n,i);if(r&&!e.isIgnored(r.relative_path))return Qe(e,r);let l=null;for(let c of a){if(e.isIgnored(c.relative_path))continue;let m=Pl(c,n,i,o);m<=0||(!l||m>l.score)&&(l={row:c,score:m})}return l?Qe(e,l.row):null}function Xe(e,n){let s=e.get(`SELECT gs.id, gs.symbol, der.document_id, der.start_line, der.end_line, d.relative_path
241
241
  FROM global_symbols gs
242
242
  JOIN defn_enclosing_ranges der ON gs.id = der.symbol_id
243
243
  JOIN documents d ON der.document_id = d.id
@@ -260,7 +260,7 @@ Install manually from: https://github.com/sourcegraph/scip/releases`)}let c={...
260
260
  ${e.pathExclusionsFor("d")}
261
261
  GROUP BY gs.id, gs.symbol, c.document_id, d.relative_path
262
262
  ORDER BY d.relative_path, start_line
263
- LIMIT 1`,n);return!s||e.isIgnored(s.relative_path)?null:Qe(e,s)}function qt(e,n){if("symbol"in n&&"relativePath"in n)return n;let t=kl(e,n.symbolId)[0];return t?Qe(e,t):null}function kl(e,n){let t=e.all(`SELECT gs.id, gs.symbol, der.document_id, der.start_line, der.end_line, d.relative_path, gs.display_name
263
+ LIMIT 1`,n);return!s||e.isIgnored(s.relative_path)?null:Qe(e,s)}function qt(e,n){if("symbol"in n&&"relativePath"in n)return n;let t=Ol(e,n.symbolId)[0];return t?Qe(e,t):null}function Ol(e,n){let t=e.all(`SELECT gs.id, gs.symbol, der.document_id, der.start_line, der.end_line, d.relative_path, gs.display_name
264
264
  FROM global_symbols gs
265
265
  JOIN defn_enclosing_ranges der ON gs.id = der.symbol_id
266
266
  JOIN documents d ON der.document_id = d.id
@@ -281,7 +281,7 @@ Install manually from: https://github.com/sourcegraph/scip/releases`)}let c={...
281
281
  AND m.role = 1
282
282
  ${e.pathExclusionsFor("d")}
283
283
  GROUP BY gs.id, gs.symbol, c.document_id, d.relative_path, gs.display_name
284
- ORDER BY start_line, end_line`,n)}function Ol(e,n){let t=n.map(()=>"(gs.symbol LIKE ? OR d.relative_path LIKE ? OR COALESCE(gs.display_name, '') LIKE ?)"),s=n.flatMap(o=>{let a=`%${o}%`;return[a,a,a]}),i=e.all(`SELECT gs.id, gs.symbol, der.document_id, der.start_line, der.end_line, d.relative_path, gs.display_name
284
+ ORDER BY start_line, end_line`,n)}function $l(e,n){let t=n.map(()=>"(gs.symbol LIKE ? OR d.relative_path LIKE ? OR COALESCE(gs.display_name, '') LIKE ?)"),s=n.flatMap(o=>{let a=`%${o}%`;return[a,a,a]}),i=e.all(`SELECT gs.id, gs.symbol, der.document_id, der.start_line, der.end_line, d.relative_path, gs.display_name
285
285
  FROM global_symbols gs
286
286
  JOIN defn_enclosing_ranges der ON gs.id = der.symbol_id
287
287
  JOIN documents d ON der.document_id = d.id
@@ -305,17 +305,17 @@ Install manually from: https://github.com/sourcegraph/scip/releases`)}let c={...
305
305
  AND `)}
306
306
  ${e.pathExclusionsFor("d")}
307
307
  GROUP BY gs.id, gs.symbol, c.document_id, d.relative_path, gs.display_name
308
- LIMIT 200`,...s)}function $l(e,n,t,s){let i=n.trim(),o=t,a=o.replace(/\(\)$/,""),r=n.toLowerCase(),l=t.toLowerCase(),c=l.replace(/\(\)$/,""),m=e.symbol,u=I(e.symbol),d=F(e.symbol),g=e.display_name??"",p=e.symbol.toLowerCase(),f=u.toLowerCase(),y=d.toLowerCase(),h=g.toLowerCase(),b=e.relative_path.toLowerCase(),_=/[/:.]/.test(t),S=0;return(m===i||m===o)&&(S+=1150),(u===i||u===o)&&(S+=1100),g===a&&(S+=980),d===a&&(S+=960),(`${d}()`===i||`${d}()`===o)&&(S+=955),(p===r||p===l)&&(S+=1e3),(f===r||f===l)&&(S+=950),(b===r||b===l)&&(S+=925),(b.endsWith(`/${l}`)||b.endsWith(`/${r}`))&&(S+=875),h===c&&(S+=850),y===c&&(S+=825),(`${y}()`===r||`${y}()`===l)&&(S+=820),(f.endsWith(`:${l}`)||f.endsWith(`:${c}`)||f.endsWith(`:${c}()`))&&(S+=800),p.includes(l)&&(S+=120),f.includes(l)&&(S+=140),b.includes(l)&&(S+=140),h.includes(l)&&(S+=110),s.every(x=>{let L=x.toLowerCase();return p.includes(L)||f.includes(L)||b.includes(L)||h.includes(L)})&&(S+=100+s.length*15),j(e.symbol)&&y===c&&(S+=60),!_&&Ge(e.symbol)&&(S-=160),S-=Math.min(50,Math.max(0,e.end_line-e.start_line)),S}function li(e){return e.trim().replace(/\(\)$/,"").replace(/\(.*$/,"")}function Pl(e){let n=li(e),t=n.split(/[^A-Za-z0-9_]+/).map(s=>s.trim()).filter(s=>s.length>0);return t.length>0?[...new Set(t)]:[n]}function Ml(e,n,t){let s=n.trim(),i=e.filter(o=>{let a=I(o.symbol),r=(o.display_name??"").trim();return o.symbol===s||a===s||a===t||r===s||r===t||`${r}()`===s||o.relative_path===s});return i.length===0?null:(i.sort((o,a)=>o.end_line-o.start_line-(a.end_line-a.start_line)||o.relative_path.localeCompare(a.relative_path)||o.symbol.localeCompare(a.symbol)),i[0]??null)}function ee(e,n){let t=ui(e,n,{allowMultiple:!1})[0]?.relativePath;return t||jl(e,n)}function Le(e,n){return ui(e,n,{allowMultiple:!0}).map(t=>t.relativePath)}function jl(e,n){if(!n)return null;let t=n.replace(/\\/g,"/").replace(/^\.\//,""),s=Tl(t)&&t.startsWith(e.config.projectRoot)?t.slice(e.config.projectRoot.length).replace(/^\/+/,""):t,i=Al(e.config.projectRoot,s);return Fl(i)?s:null}function ui(e,n,t){let s=mi(n);if(!s)return[];let o=e.all(`SELECT relative_path
308
+ LIMIT 200`,...s)}function Pl(e,n,t,s){let i=n.trim(),o=t,a=o.replace(/\(\)$/,""),r=n.toLowerCase(),l=t.toLowerCase(),c=l.replace(/\(\)$/,""),m=e.symbol,u=I(e.symbol),d=F(e.symbol),g=e.display_name??"",p=e.symbol.toLowerCase(),f=u.toLowerCase(),y=d.toLowerCase(),h=g.toLowerCase(),b=e.relative_path.toLowerCase(),_=/[/:.]/.test(t),S=0;return(m===i||m===o)&&(S+=1150),(u===i||u===o)&&(S+=1100),g===a&&(S+=980),d===a&&(S+=960),(`${d}()`===i||`${d}()`===o)&&(S+=955),(p===r||p===l)&&(S+=1e3),(f===r||f===l)&&(S+=950),(b===r||b===l)&&(S+=925),(b.endsWith(`/${l}`)||b.endsWith(`/${r}`))&&(S+=875),h===c&&(S+=850),y===c&&(S+=825),(`${y}()`===r||`${y}()`===l)&&(S+=820),(f.endsWith(`:${l}`)||f.endsWith(`:${c}`)||f.endsWith(`:${c}()`))&&(S+=800),p.includes(l)&&(S+=120),f.includes(l)&&(S+=140),b.includes(l)&&(S+=140),h.includes(l)&&(S+=110),s.every(x=>{let L=x.toLowerCase();return p.includes(L)||f.includes(L)||b.includes(L)||h.includes(L)})&&(S+=100+s.length*15),j(e.symbol)&&y===c&&(S+=60),!_&&Ge(e.symbol)&&(S-=160),S-=Math.min(50,Math.max(0,e.end_line-e.start_line)),S}function ci(e){return e.trim().replace(/\(\)$/,"").replace(/\(.*$/,"")}function Ml(e){let n=ci(e),t=n.split(/[^A-Za-z0-9_]+/).map(s=>s.trim()).filter(s=>s.length>0);return t.length>0?[...new Set(t)]:[n]}function Fl(e,n,t){let s=n.trim(),i=e.filter(o=>{let a=I(o.symbol),r=(o.display_name??"").trim();return o.symbol===s||a===s||a===t||r===s||r===t||`${r}()`===s||o.relative_path===s});return i.length===0?null:(i.sort((o,a)=>o.end_line-o.start_line-(a.end_line-a.start_line)||o.relative_path.localeCompare(a.relative_path)||o.symbol.localeCompare(a.symbol)),i[0]??null)}function ee(e,n){let t=mi(e,n,{allowMultiple:!1})[0]?.relativePath;return t||Bl(e,n)}function Le(e,n){return mi(e,n,{allowMultiple:!0}).map(t=>t.relativePath)}function Bl(e,n){if(!n)return null;let t=n.replace(/\\/g,"/").replace(/^\.\//,""),s=Al(t)&&t.startsWith(e.config.projectRoot)?t.slice(e.config.projectRoot.length).replace(/^\/+/,""):t,i=jl(e.config.projectRoot,s);return Tl(i)?s:null}function mi(e,n,t){let s=di(n);if(!s)return[];let o=e.all(`SELECT relative_path
309
309
  FROM documents
310
310
  WHERE 1 = 1
311
311
  ${e.pathExclusionsFor("documents")}
312
- ORDER BY relative_path`).filter(r=>!e.isIgnored(r.relative_path)).map(r=>({relativePath:r.relative_path,score:Bl(r.relative_path,s)})).filter(r=>r.score>0).sort((r,l)=>l.score-r.score||r.relativePath.localeCompare(l.relativePath));if(o.length===0){let r=k(e,n);return!r||e.isIgnored(r.relativePath)?[]:[{relativePath:r.relativePath,score:700}]}let a=o.filter(r=>r.score>=800);return a.length>0?t.allowMultiple?a:[a[0]]:t.allowMultiple?o:[o[0]]}function Bl(e,n){let t=mi(e),s=ci(t),i=ci(n),o=0;return t===n&&(o+=1200),t.endsWith(`/${n}`)&&(o+=1100),s===i&&(o+=900),t.startsWith(`${n}/`)&&(o+=850),t.includes(n)&&(o+=250),o}function mi(e){return e.trim().replace(/\\/g,"/").replace(/^\.\//,"").replace(/^\/+/,"").replace(/\/+$/,"")}function di(e,n){let t=Le(e,n);return Ke(e,t).map(({relativePath:s,...i})=>i)}import{basename as Wl}from"path";function pi(e,n){let t=k(e,n);if(!t)return[];let s=F(t.symbol),i=A(e,t.relativePath).filter(r=>Ve(r.symbol)),o=i.filter(r=>r.parentTypeName===s||r.symbol.includes(s));return(o.length>0?o:Hl(Wl(t.relativePath))===s?i.filter(r=>r.symbol.includes("<invalid-global-code>")):[]).map(r=>({startLine:r.startLine,endLine:r.endLine,name:F(r.symbol)}))}function Hl(e){return e.replace(/\.[^.]+$/,"")}var ft=new WeakMap;function hi(e,n){let t=P(n);return t==="rust"?Vl(e,n):t==="typescript"||t==="tsx"||t==="javascript"?Ul(e,n):[]}var Jl=new Set(["describe","it","test","fdescribe","fit","xdescribe","xit","beforeEach","afterEach","beforeAll","afterAll","before","after","suite","bench","benchmark"]);function Ul(e,n){let t=O(e,n);if(!t)return[];let s=ft.get(t);if(s)return s;let i=/(^|\/)(pages|app)\/.+\.(tsx?|jsx?)$/.test(n)||/(^|\/)(layout|page|loading|error|not-found|head|template|default)\.(tsx?|jsx?)$/.test(n),o=/(^|\/)src\/(pages|views|routes)\/.+\.(tsx?|jsx?|vue)$/.test(n),a=!1,r=t.rootNode;for(let c of r.namedChildren){if(c.type!=="expression_statement")continue;let m=c.namedChild(0);if(!m||m.type!=="call_expression")continue;let u=m.namedChild(0);if(!u)continue;let d=u.type==="member_expression"?u.namedChild(u.namedChildCount-1)?.text:u.text;if(d&&Jl.has(d)){a=!0;break}}let l=[];a&&l.push({startLine:0,endLine:r.endPosition.row,reason:"TS/JS test file (describe/it/test at top level)"}),(i||o)&&l.push({startLine:0,endLine:r.endPosition.row,reason:i?"Next.js / Remix route file":"Vite/Vue route component"});for(let c of r.namedChildren){let m=null,u=null;if(c.type==="function_declaration")m=c.namedChild(0)?.text??null,u=c;else if(c.type==="export_statement"){let d=c.namedChild(0);d?.type==="function_declaration"&&(m=d.namedChild(0)?.text??null,u=d)}else if(c.type==="lexical_declaration"){let d=c.namedChild(0);if(d?.type==="variable_declarator"){let g=d.namedChild(0)?.text,p=d.namedChild(1);g&&(p?.type==="arrow_function"||p?.type==="function_expression")&&(m=g,u=d)}}m&&/^use[A-Z]/.test(m)&&u&&l.push({startLine:u.startPosition.row,endLine:u.endPosition.row,reason:"React custom hook (use*)"})}return l.push(...yi(t,new Set(["function_declaration","method_definition","class_declaration","interface_declaration","type_alias_declaration","enum_declaration","variable_declarator","export_statement"]),new Set(["comment"]))),ft.set(t,l),l}var ql=/scip-query[\s:-]*ignore[\s:-]*(?:dead(?:-code)?|stale)?/i;function zl(e){return ql.test(e)}function yi(e,n,t){let s=[],i=o=>{if(n.has(o.type)&&o.parent){let r=o.parent.children,l=-1;for(let c=0;c<r.length;c+=1)if(r[c].startIndex===o.startIndex&&r[c].type===o.type){l=c;break}if(l>0)for(let c=l-1;c>=0;c-=1){let m=r[c];if(t.has(m.type)){if(zl(m.text)){s.push({startLine:o.startPosition.row,endLine:o.endPosition.row,reason:"scip-query suppression comment"});break}continue}if(!(m.type==="attribute_item"||m.type==="inner_attribute_item"))break}}for(let a of o.namedChildren)i(a)};return i(e.rootNode),s}function Vl(e,n){let t=O(e,n);if(!t)return[];let s=ft.get(t);if(s)return s;let i=[];if(Gl(t.rootNode)){let u={startLine:0,endLine:t.rootNode.endPosition.row,reason:"generated file (@generated header)"};return ft.set(t,[u]),[u]}let o=u=>{let d=u.parent;if(!d)return[];let g=d.children,p=-1;for(let y=0;y<g.length;y+=1)if(g[y].startIndex===u.startIndex&&g[y].type===u.type){p=y;break}if(p<=0)return[];let f=[];for(let y=p-1;y>=0;y-=1){let h=g[y];if(h.type==="attribute_item"||h.type==="inner_attribute_item")f.push(h.text);else{if(h.type==="line_comment"||h.type==="block_comment")continue;break}}return f},a=u=>/#\[\s*tauri::command\b/.test(u)?"#[tauri::command]":/#\[\s*command\b/.test(u)?"#[command]":/#\[\s*test\b/.test(u)?"#[test]":/#\[\s*bench\b/.test(u)?"#[bench]":/#\[\s*tokio::test\b/.test(u)?"#[tokio::test]":/#\[\s*async_std::test\b/.test(u)?"#[async_std::test]":/#\[\s*wasm_bindgen\b/.test(u)?"#[wasm_bindgen]":/#\[\s*no_mangle\b/.test(u)?"#[no_mangle]":/#\[\s*napi\b/.test(u)?"#[napi]":/#\[\s*pyfunction\b/.test(u)?"#[pyfunction]":/#\[\s*pymethod\b/.test(u)?"#[pymethod]":/#\[\s*pyo3\b/.test(u)?"#[pyo3]":/#\[\s*cfg\s*\(\s*test\s*\)/.test(u)?"#[cfg(test)]":/#\[\s*doc\s*\(\s*hidden\s*\)/.test(u)?"#[doc(hidden)]":null,r=u=>/#\[\s*derive\s*\(/.test(u)?/\bSerialize\b/.test(u)||/\bDeserialize\b/.test(u)||/\bFromRow\b/.test(u)||/\bDeriveEntityModel\b/.test(u)||/\bIntoSchema\b/.test(u)||/\bToSchema\b/.test(u)||/\bDeriveValueType\b/.test(u)||/\bsqlx::FromRow\b/.test(u)||/\bError\b/.test(u)||/\bthiserror::Error\b/.test(u):!1,l=u=>/#\[\s*allow\s*\(\s*dead_code\s*\)/.test(u),c=(u,d,g,p)=>{let f=d,y=g,h=p;if(u.type==="trait_item"&&(h=!0,i.push({startLine:u.startPosition.row,endLine:u.endPosition.row,reason:"trait declaration body (dynamic dispatch)"})),u.type==="impl_item"&&u.childForFieldName("trait")&&(y=!0,i.push({startLine:u.startPosition.row,endLine:u.endPosition.row,reason:"trait impl block (dynamic dispatch)"})),u.type==="function_item"||u.type==="function_signature_item"){let b=o(u),_=null;g?_="trait impl method (dynamic dispatch)":d&&(_="inside #[cfg(test)] mod");for(let S of b){let x=a(S);if(x){_=x;break}if(l(S)){_="#[allow(dead_code)]";break}}_&&i.push({startLine:u.startPosition.row,endLine:u.endPosition.row,reason:_})}else if(g&&(u.type==="const_item"||u.type==="type_item"||u.type==="static_item"||u.type==="associated_type"))i.push({startLine:u.startPosition.row,endLine:u.endPosition.row,reason:"trait impl associated item (dynamic dispatch)"});else if(u.type==="struct_item"||u.type==="enum_item"||u.type==="union_item"){let b=o(u),_=b.some(r),S=b.some(l),x=u.namedChildren.find(L=>L.type==="type_identifier")?.text;_&&i.push({startLine:u.startPosition.row,endLine:u.endPosition.row,reason:"#[derive(<reflective>)] \u2014 fields accessed via macro/reflection",containerName:x}),S&&i.push({startLine:u.startPosition.row,endLine:u.endPosition.row,reason:"#[allow(dead_code)]",containerName:x}),d&&i.push({startLine:u.startPosition.row,endLine:u.endPosition.row,reason:"inside #[cfg(test)] mod",containerName:x})}else u.type==="mod_item"&&o(u).some(_=>/#\[\s*cfg\s*\(\s*test\s*\)/.test(_))&&(f=!0);for(let b of u.namedChildren)c(b,f,y,h)};c(t.rootNode,!1,!1,!1),i.push(...yi(t,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 m=Zl(t.rootNode);if(m.size>0)for(let u of t.rootNode.descendantsOfType("mod_item")){let d=u.childForFieldName("name")?.text;d&&m.has(d)&&i.push({startLine:u.startPosition.row,endLine:u.endPosition.row,reason:'serde `with = "..."` module \u2014 body invoked via reflection',containerName:d})}return ft.set(t,i),i}function Gl(e){for(let n=0;n<Math.min(e.namedChildCount,12);n+=1){let t=e.namedChild(n);if(!t||t.type!=="line_comment"&&t.type!=="block_comment")break;if(/@generated\b/.test(t.text)||/This file is .*generated\b/i.test(t.text)||/Code generated by/i.test(t.text)||/Generated by:\s*https?:\/\/openapi-generator/i.test(t.text)||/openapi-generator/i.test(t.text)&&/Generated by/i.test(t.text))return!0}return!1}var Yl=[{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}],bi=/^#!?\[\s*serde\s*\(/,Kl=/^#!?\[\s*schemars\s*\(/,Ql=/^#!?\[\s*validate\s*\(/,fi=/\bwith\s*=\s*"([^"]+)"/g;function we(e,n){return Jt(e,n,Xl,()=>new Set,(t,s,i)=>{if(s==="rust"){for(let o of t.rootNode.descendantsOfType("attribute_item"))gi(o.text,i);for(let o of t.rootNode.descendantsOfType("inner_attribute_item"))gi(o.text,i)}})??new Set}var Xl=new WeakMap;function gi(e,n){let t=bi.test(e),s=Kl.test(e),i=Ql.test(e);if(!(!t&&!s&&!i))for(let{re:o}of Yl){o.lastIndex=0;let a;for(;(a=o.exec(e))!==null;){let r=a[1],l=r.split("::").pop()??r;l==="is_none"&&/\bOption\b/.test(r)||l==="is_empty"&&/\b(String|Vec|HashMap|BTreeMap|HashSet|BTreeSet)\b/.test(r)||l&&n.add(l)}}}function Zl(e){let n=new Set;for(let t of e.descendantsOfType("attribute_item")){if(!bi.test(t.text))continue;fi.lastIndex=0;let s;for(;(s=fi.exec(t.text))!==null;){let i=s[1],o=i.split("::").pop()??i;o&&n.add(o)}}return n}var ec=new Set(["invoke","invokeTauriCommand","listen","once","emit","subscribe","dispatch","sendCommand","callRust"]);function Si(e,n){return Jt(e,n,tc,()=>new Set,(t,s,i)=>{if(!(s!=="typescript"&&s!=="tsx"&&s!=="javascript"))for(let o of t.rootNode.descendantsOfType("call_expression")){let a=o.namedChild(0);if(!a)continue;let r=ut(a);if(!r||!ec.has(r))continue;let l=o.namedChildren.find(u=>u.type==="arguments");if(!l)continue;let c=l.namedChild(0);if(!c||c.type!=="string")continue;let m=c.namedChildren.find(u=>u.type==="string_fragment");m&&i.add(m.text)}})??new Set}var tc=new WeakMap;function zt(e){return e.replace(/'''[\s\S]*?'''/g,De).replace(/"""[\s\S]*?"""/g,De).replace(/#.*$/gm,De).replace(/\/\/.*$/gm,De).replace(/\/\*[\s\S]*?\*\//g,De).replace(/`(?:\\[\s\S]|[^`])*`/g,De).replace(/'(?:\\.|[^'\\\r\n])*'/g,De).replace(/"(?:\\.|[^"\\\r\n])*"/g,De)}function De(e){return e.replace(/[^\r\n]/g," ")}var nc=Ot("stripped-lines");function xi(e,n,t){return nc.get(e,n,t,()=>zt(t).split(`
313
- `))}var _i=null,Mn="";function sc(e){return _i===e||(_i=e,Mn=zt(e)),Mn}function z(e,n,t){let s=sc(e);return`${s.slice(0,n)}${" ".repeat(t-n)}${s.slice(t)}`}function te(e,n){return new RegExp(`\\b${Vt(n)}\\b`,"m").test(e)}function Ze(e,n){let t=new Set,s=new RegExp(`\\b${Vt(n)}\\s*\\.\\s*([A-Za-z_$][\\w$]*)`,"g");for(let i of e.matchAll(s)){let o=i[1];o&&t.add(o)}return[...t]}function Vt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Gt(e,n,t,s={}){if(!t)return[];let i=M(e,n);if(!i)return[];if(i.indexOf(t)===-1)return[];if(P(n))return(xe(e,n).get(t)??[]).filter(m=>!Ii(m,s));let o=xi(e,n,i),a=new RegExp(`\\b${Vt(t)}\\b`),r=[];for(let l=0;l<o.length;l++)Ii(l,s)||a.test(o[l]??"")&&r.push(l);return r}function Ii(e,n){return typeof n.excludeStartLine=="number"&&typeof n.excludeEndLine=="number"&&e>=n.excludeStartLine&&e<=n.excludeEndLine}var ic=W("file-identifiers");function Ni(e,n){return ic.get(e,n,()=>new Set(xe(e,n).keys()))}var oc=W("file-ident-lines");function xe(e,n){return oc.get(e,n,()=>ac(e,n))}var rc=W("file-idents-by-line");function vi(e,n){return rc.get(e,n,()=>{let t=xe(e,n),s=0;for(let o of t.values()){let a=o[o.length-1];a!==void 0&&a>s&&(s=a)}let i=new Array(s+1);for(let o=0;o<=s;o+=1)i[o]=new Set;for(let[o,a]of t)for(let r of a)i[r].add(o);return i})}function ac(e,n){let t=new Map,s=(r,l)=>{let c=t.get(r);if(!c){t.set(r,[l]);return}c[c.length-1]!==l&&c.push(l)};if(P(n)){let r=O(e,n);if(r){let l=P(n),c=l==="rust"?new Set(["identifier","type_identifier","field_identifier"]):l==="python"?new Set(["identifier"]):new Set(["identifier","property_identifier","type_identifier"]),m=new Set(["rust","python"]),u=/\{([^{}]*)\}/g,d=/\b([A-Za-z_][\w]*)\b/g,g=p=>{if(c.has(p.type)&&s(p.text,p.startPosition.row),l&&m.has(l)&&p.type==="string_content"){let f=p.startPosition.row;for(let y of p.text.matchAll(u)){let h=y[1]??"";for(let b of h.matchAll(d))b[1]&&s(b[1],f)}}for(let f of p.children)g(f)};return g(r.rootNode),t}}let i=M(e,n);if(!i)return t;let o=zt(i).split(/\r?\n/),a=/\b([A-Za-z_$][\w$]*)\b/g;for(let r=0;r<o.length;r+=1){let l=o[r]??"";for(let c of l.matchAll(a))c[1]&&s(c[1],r)}return t}import{existsSync as zi,readFileSync as Vi}from"fs";import{join as Gi}from"path";import{existsSync as et}from"fs";import{basename as lc,dirname as ke,extname as Ie,join as ue,relative as We,resolve as re}from"path";var cc=je("indexed-paths"),Yt=[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs",".vue"],Fn=[".py",".pyi"],me=[".java",".scala",".kt",".kts"],Tn=[".rs"],An=[".rb"],Ci=[".c",".h",".cc",".cpp",".cxx",".hpp",".hh",".hxx"],tt=[".cs",".vb"],jn=[".dart"],gt=[".php"],uc=[Yt,Fn,me,Tn,An,Ci,tt,jn,gt];function Oe(e,n){return n.includes(Ie(e).toLowerCase())}function mc(e){return Oe(e,Fn)}function dc(e){return Oe(e,me)}function pc(e){return Oe(e,Tn)}function fc(e){return Oe(e,An)}function gc(e){return Oe(e,Ci)}function hc(e){return Oe(e,tt)}function Ei(e){return Ie(e).toLowerCase()===".vb"}function yc(e){return Oe(e,jn)}function bc(e){return Oe(e,gt)}function Bn(e){let n=Ie(e).toLowerCase();for(let t of uc)if(t.includes(n))return t;return Yt}function Sc(e){return dc(e)||hc(e)||bc(e)}function He(e,n,t){return mc(n)?nt(e,n,t):pc(n)?Ne(e,n,t):fc(n)?Kt(e,n,t):gc(n)?Qt(e,n,t):Sc(n)?H(e,t.replace(/\\/g,"."),Bn(n)):yc(n)?Xt(e,n,t):_c(e,n,t)}function _c(e,n,t){if(!t.startsWith(".")&&!t.startsWith("/"))return null;let s=ke(ue(e.config.projectRoot,n)),i=re(s,t),o=Je(e);for(let a of Cc(i)){let r=ae(We(e.config.projectRoot,a));if(o.has(r)||et(a))return r}return ae(We(e.config.projectRoot,i))}function nt(e,n,t){let s=Je(e),i;if(t.startsWith(".")){let o=t.match(/^(\.+)(.*)$/);if(!o)return null;let a=o[1].length,r=o[2].replace(/^\./,""),l=ke(ue(e.config.projectRoot,n));for(let c=1;c<a;c++)l=ke(l);i=r?re(l,r.replace(/\./g,"/")):l}else i=re(e.config.projectRoot,t.replace(/\./g,"/"));for(let o of xc(i)){let a=ae(We(e.config.projectRoot,o));if(s.has(a)||et(o))return a}return null}function Ne(e,n,t){if(!t)return null;let s=t.replace(/\s+as\s+.+$/,"").trim();if(!s.startsWith("crate::")&&!s.startsWith("self::")&&!s.startsWith("super::"))return null;let i=ke(ue(e.config.projectRoot,n)),o;s.startsWith("crate::")?o=re(e.config.projectRoot,"src",s.slice(7).replace(/::/g,"/")):s.startsWith("self::")?o=re(i,s.slice(6).replace(/::/g,"/")):o=re(ke(i),s.slice(7).replace(/::/g,"/"));for(let a of Ic(o)){let r=ae(We(e.config.projectRoot,a));if(Je(e).has(r)||et(a))return r}return null}function Kt(e,n,t){let s=ke(ue(e.config.projectRoot,n)),i=re(s,t);for(let o of Nc(i)){let a=ae(We(e.config.projectRoot,o));if(Je(e).has(a)||et(o))return a}return null}function Qt(e,n,t){let s=Je(e),i=ke(ue(e.config.projectRoot,n)),o=[re(i,t),re(e.config.projectRoot,t),re(e.config.projectRoot,"include",t),re(e.config.projectRoot,"src",t)];for(let a of o){let r=ae(We(e.config.projectRoot,a));if(s.has(r)||et(a))return r}return null}function H(e,n,t){let s=Je(e),i=n.replace(/\\/g,".").replace(/::/g,".").replace(/^global::/,""),o=i.replace(/\./g,"/"),a=i.split(".").pop()??i;for(let l of t){let c=`${o}${l}`,m=[...s].find(u=>u.endsWith(c));if(m)return m}for(let l of t){let c=[...s].find(m=>lc(m)===`${a}${l}`);if(c)return c}let r=[...s].filter(l=>t.includes(Ie(l).toLowerCase())).filter(l=>l.includes(`/${o}/`)||l.includes(`/${a}/`)).sort((l,c)=>l.localeCompare(c));return r.length===1?r[0]:null}function Xt(e,n,t){let s=Je(e);if(t.startsWith("package:")){let a=t.slice(8),r=a.indexOf("/");if(r<0)return null;let l=a.slice(r+1),c=ae(l.startsWith("lib/")?l:`lib/${l}`);return s.has(c)?c:null}let i=ke(ue(e.config.projectRoot,n)),o=re(i,t);for(let a of vc(o)){let r=ae(We(e.config.projectRoot,a));if(s.has(r)||et(a))return r}return null}function xc(e){let n=Ie(e);return Fn.includes(n)?[e]:[`${e}.py`,`${e}.pyi`,ue(e,"__init__.py"),ue(e,"__init__.pyi")]}function Ic(e){let n=Ie(e);return Tn.includes(n)?[e]:[`${e}.rs`,ue(e,"mod.rs")]}function Nc(e){let n=Ie(e);return An.includes(n)?[e]:[`${e}.rb`,ue(e,"index.rb")]}function vc(e){let n=Ie(e);return jn.includes(n)?[e]:[`${e}.dart`,e]}function Cc(e){let n=Ie(e),t=new Set;if(n){t.add(e);for(let s of Yt)t.add(e.slice(0,-n.length)+s)}else for(let s of Yt)t.add(`${e}${s}`),t.add(ue(e,`index${s}`));return[...t]}function Je(e){return cc.get(e,()=>new Set(e.all(`SELECT relative_path
312
+ ORDER BY relative_path`).filter(r=>!e.isIgnored(r.relative_path)).map(r=>({relativePath:r.relative_path,score:Wl(r.relative_path,s)})).filter(r=>r.score>0).sort((r,l)=>l.score-r.score||r.relativePath.localeCompare(l.relativePath));if(o.length===0){let r=k(e,n);return!r||e.isIgnored(r.relativePath)?[]:[{relativePath:r.relativePath,score:700}]}let a=o.filter(r=>r.score>=800);return a.length>0?t.allowMultiple?a:[a[0]]:t.allowMultiple?o:[o[0]]}function Wl(e,n){let t=di(e),s=ui(t),i=ui(n),o=0;return t===n&&(o+=1200),t.endsWith(`/${n}`)&&(o+=1100),s===i&&(o+=900),t.startsWith(`${n}/`)&&(o+=850),t.includes(n)&&(o+=250),o}function di(e){return e.trim().replace(/\\/g,"/").replace(/^\.\//,"").replace(/^\/+/,"").replace(/\/+$/,"")}function pi(e,n){let t=Le(e,n);return Ke(e,t).map(({relativePath:s,...i})=>i)}import{basename as Hl}from"path";function fi(e,n){let t=k(e,n);if(!t)return[];let s=F(t.symbol),i=A(e,t.relativePath).filter(r=>Ve(r.symbol)),o=i.filter(r=>r.parentTypeName===s||r.symbol.includes(s));return(o.length>0?o:Jl(Hl(t.relativePath))===s?i.filter(r=>r.symbol.includes("<invalid-global-code>")):[]).map(r=>({startLine:r.startLine,endLine:r.endLine,name:F(r.symbol)}))}function Jl(e){return e.replace(/\.[^.]+$/,"")}var ft=new WeakMap;function yi(e,n){let t=P(n);return t==="rust"?Gl(e,n):t==="typescript"||t==="tsx"||t==="javascript"?ql(e,n):[]}var Ul=new Set(["describe","it","test","fdescribe","fit","xdescribe","xit","beforeEach","afterEach","beforeAll","afterAll","before","after","suite","bench","benchmark"]);function ql(e,n){let t=O(e,n);if(!t)return[];let s=ft.get(t);if(s)return s;let i=/(^|\/)(pages|app)\/.+\.(tsx?|jsx?)$/.test(n)||/(^|\/)(layout|page|loading|error|not-found|head|template|default)\.(tsx?|jsx?)$/.test(n),o=/(^|\/)src\/(pages|views|routes)\/.+\.(tsx?|jsx?|vue)$/.test(n),a=!1,r=t.rootNode;for(let c of r.namedChildren){if(c.type!=="expression_statement")continue;let m=c.namedChild(0);if(!m||m.type!=="call_expression")continue;let u=m.namedChild(0);if(!u)continue;let d=u.type==="member_expression"?u.namedChild(u.namedChildCount-1)?.text:u.text;if(d&&Ul.has(d)){a=!0;break}}let l=[];a&&l.push({startLine:0,endLine:r.endPosition.row,reason:"TS/JS test file (describe/it/test at top level)"}),(i||o)&&l.push({startLine:0,endLine:r.endPosition.row,reason:i?"Next.js / Remix route file":"Vite/Vue route component"});for(let c of r.namedChildren){let m=null,u=null;if(c.type==="function_declaration")m=c.namedChild(0)?.text??null,u=c;else if(c.type==="export_statement"){let d=c.namedChild(0);d?.type==="function_declaration"&&(m=d.namedChild(0)?.text??null,u=d)}else if(c.type==="lexical_declaration"){let d=c.namedChild(0);if(d?.type==="variable_declarator"){let g=d.namedChild(0)?.text,p=d.namedChild(1);g&&(p?.type==="arrow_function"||p?.type==="function_expression")&&(m=g,u=d)}}m&&/^use[A-Z]/.test(m)&&u&&l.push({startLine:u.startPosition.row,endLine:u.endPosition.row,reason:"React custom hook (use*)"})}return l.push(...bi(t,new Set(["function_declaration","method_definition","class_declaration","interface_declaration","type_alias_declaration","enum_declaration","variable_declarator","export_statement"]),new Set(["comment"]))),ft.set(t,l),l}var zl=/scip-query[\s:-]*ignore[\s:-]*(?:dead(?:-code)?|stale)?/i;function Vl(e){return zl.test(e)}function bi(e,n,t){let s=[],i=o=>{if(n.has(o.type)&&o.parent){let r=o.parent.children,l=-1;for(let c=0;c<r.length;c+=1)if(r[c].startIndex===o.startIndex&&r[c].type===o.type){l=c;break}if(l>0)for(let c=l-1;c>=0;c-=1){let m=r[c];if(t.has(m.type)){if(Vl(m.text)){s.push({startLine:o.startPosition.row,endLine:o.endPosition.row,reason:"scip-query suppression comment"});break}continue}if(!(m.type==="attribute_item"||m.type==="inner_attribute_item"))break}}for(let a of o.namedChildren)i(a)};return i(e.rootNode),s}function Gl(e,n){let t=O(e,n);if(!t)return[];let s=ft.get(t);if(s)return s;let i=[];if(Yl(t.rootNode)){let u={startLine:0,endLine:t.rootNode.endPosition.row,reason:"generated file (@generated header)"};return ft.set(t,[u]),[u]}let o=u=>{let d=u.parent;if(!d)return[];let g=d.children,p=-1;for(let y=0;y<g.length;y+=1)if(g[y].startIndex===u.startIndex&&g[y].type===u.type){p=y;break}if(p<=0)return[];let f=[];for(let y=p-1;y>=0;y-=1){let h=g[y];if(h.type==="attribute_item"||h.type==="inner_attribute_item")f.push(h.text);else{if(h.type==="line_comment"||h.type==="block_comment")continue;break}}return f},a=u=>/#\[\s*tauri::command\b/.test(u)?"#[tauri::command]":/#\[\s*command\b/.test(u)?"#[command]":/#\[\s*test\b/.test(u)?"#[test]":/#\[\s*bench\b/.test(u)?"#[bench]":/#\[\s*tokio::test\b/.test(u)?"#[tokio::test]":/#\[\s*async_std::test\b/.test(u)?"#[async_std::test]":/#\[\s*wasm_bindgen\b/.test(u)?"#[wasm_bindgen]":/#\[\s*no_mangle\b/.test(u)?"#[no_mangle]":/#\[\s*napi\b/.test(u)?"#[napi]":/#\[\s*pyfunction\b/.test(u)?"#[pyfunction]":/#\[\s*pymethod\b/.test(u)?"#[pymethod]":/#\[\s*pyo3\b/.test(u)?"#[pyo3]":/#\[\s*cfg\s*\(\s*test\s*\)/.test(u)?"#[cfg(test)]":/#\[\s*doc\s*\(\s*hidden\s*\)/.test(u)?"#[doc(hidden)]":null,r=u=>/#\[\s*derive\s*\(/.test(u)?/\bSerialize\b/.test(u)||/\bDeserialize\b/.test(u)||/\bFromRow\b/.test(u)||/\bDeriveEntityModel\b/.test(u)||/\bIntoSchema\b/.test(u)||/\bToSchema\b/.test(u)||/\bDeriveValueType\b/.test(u)||/\bsqlx::FromRow\b/.test(u)||/\bError\b/.test(u)||/\bthiserror::Error\b/.test(u):!1,l=u=>/#\[\s*allow\s*\(\s*dead_code\s*\)/.test(u),c=(u,d,g,p)=>{let f=d,y=g,h=p;if(u.type==="trait_item"&&(h=!0,i.push({startLine:u.startPosition.row,endLine:u.endPosition.row,reason:"trait declaration body (dynamic dispatch)"})),u.type==="impl_item"&&u.childForFieldName("trait")&&(y=!0,i.push({startLine:u.startPosition.row,endLine:u.endPosition.row,reason:"trait impl block (dynamic dispatch)"})),u.type==="function_item"||u.type==="function_signature_item"){let b=o(u),_=null;g?_="trait impl method (dynamic dispatch)":d&&(_="inside #[cfg(test)] mod");for(let S of b){let x=a(S);if(x){_=x;break}if(l(S)){_="#[allow(dead_code)]";break}}_&&i.push({startLine:u.startPosition.row,endLine:u.endPosition.row,reason:_})}else if(g&&(u.type==="const_item"||u.type==="type_item"||u.type==="static_item"||u.type==="associated_type"))i.push({startLine:u.startPosition.row,endLine:u.endPosition.row,reason:"trait impl associated item (dynamic dispatch)"});else if(u.type==="struct_item"||u.type==="enum_item"||u.type==="union_item"){let b=o(u),_=b.some(r),S=b.some(l),x=u.namedChildren.find(L=>L.type==="type_identifier")?.text;_&&i.push({startLine:u.startPosition.row,endLine:u.endPosition.row,reason:"#[derive(<reflective>)] \u2014 fields accessed via macro/reflection",containerName:x}),S&&i.push({startLine:u.startPosition.row,endLine:u.endPosition.row,reason:"#[allow(dead_code)]",containerName:x}),d&&i.push({startLine:u.startPosition.row,endLine:u.endPosition.row,reason:"inside #[cfg(test)] mod",containerName:x})}else u.type==="mod_item"&&o(u).some(_=>/#\[\s*cfg\s*\(\s*test\s*\)/.test(_))&&(f=!0);for(let b of u.namedChildren)c(b,f,y,h)};c(t.rootNode,!1,!1,!1),i.push(...bi(t,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 m=ec(t.rootNode);if(m.size>0)for(let u of t.rootNode.descendantsOfType("mod_item")){let d=u.childForFieldName("name")?.text;d&&m.has(d)&&i.push({startLine:u.startPosition.row,endLine:u.endPosition.row,reason:'serde `with = "..."` module \u2014 body invoked via reflection',containerName:d})}return ft.set(t,i),i}function Yl(e){for(let n=0;n<Math.min(e.namedChildCount,12);n+=1){let t=e.namedChild(n);if(!t||t.type!=="line_comment"&&t.type!=="block_comment")break;if(/@generated\b/.test(t.text)||/This file is .*generated\b/i.test(t.text)||/Code generated by/i.test(t.text)||/Generated by:\s*https?:\/\/openapi-generator/i.test(t.text)||/openapi-generator/i.test(t.text)&&/Generated by/i.test(t.text))return!0}return!1}var Kl=[{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}],Si=/^#!?\[\s*serde\s*\(/,Ql=/^#!?\[\s*schemars\s*\(/,Xl=/^#!?\[\s*validate\s*\(/,gi=/\bwith\s*=\s*"([^"]+)"/g;function we(e,n){return Jt(e,n,Zl,()=>new Set,(t,s,i)=>{if(s==="rust"){for(let o of t.rootNode.descendantsOfType("attribute_item"))hi(o.text,i);for(let o of t.rootNode.descendantsOfType("inner_attribute_item"))hi(o.text,i)}})??new Set}var Zl=new WeakMap;function hi(e,n){let t=Si.test(e),s=Ql.test(e),i=Xl.test(e);if(!(!t&&!s&&!i))for(let{re:o}of Kl){o.lastIndex=0;let a;for(;(a=o.exec(e))!==null;){let r=a[1],l=r.split("::").pop()??r;l==="is_none"&&/\bOption\b/.test(r)||l==="is_empty"&&/\b(String|Vec|HashMap|BTreeMap|HashSet|BTreeSet)\b/.test(r)||l&&n.add(l)}}}function ec(e){let n=new Set;for(let t of e.descendantsOfType("attribute_item")){if(!Si.test(t.text))continue;gi.lastIndex=0;let s;for(;(s=gi.exec(t.text))!==null;){let i=s[1],o=i.split("::").pop()??i;o&&n.add(o)}}return n}var tc=new Set(["invoke","invokeTauriCommand","listen","once","emit","subscribe","dispatch","sendCommand","callRust"]);function _i(e,n){return Jt(e,n,nc,()=>new Set,(t,s,i)=>{if(!(s!=="typescript"&&s!=="tsx"&&s!=="javascript"))for(let o of t.rootNode.descendantsOfType("call_expression")){let a=o.namedChild(0);if(!a)continue;let r=ut(a);if(!r||!tc.has(r))continue;let l=o.namedChildren.find(u=>u.type==="arguments");if(!l)continue;let c=l.namedChild(0);if(!c||c.type!=="string")continue;let m=c.namedChildren.find(u=>u.type==="string_fragment");m&&i.add(m.text)}})??new Set}var nc=new WeakMap;function zt(e){return e.replace(/'''[\s\S]*?'''/g,De).replace(/"""[\s\S]*?"""/g,De).replace(/#.*$/gm,De).replace(/\/\/.*$/gm,De).replace(/\/\*[\s\S]*?\*\//g,De).replace(/`(?:\\[\s\S]|[^`])*`/g,De).replace(/'(?:\\.|[^'\\\r\n])*'/g,De).replace(/"(?:\\.|[^"\\\r\n])*"/g,De)}function De(e){return e.replace(/[^\r\n]/g," ")}var sc=Ot("stripped-lines");function Ii(e,n,t){return sc.get(e,n,t,()=>zt(t).split(`
313
+ `))}var xi=null,Mn="";function ic(e){return xi===e||(xi=e,Mn=zt(e)),Mn}function z(e,n,t){let s=ic(e);return`${s.slice(0,n)}${" ".repeat(t-n)}${s.slice(t)}`}function te(e,n){return new RegExp(`\\b${Vt(n)}\\b`,"m").test(e)}function Ze(e,n){let t=new Set,s=new RegExp(`\\b${Vt(n)}\\s*\\.\\s*([A-Za-z_$][\\w$]*)`,"g");for(let i of e.matchAll(s)){let o=i[1];o&&t.add(o)}return[...t]}function Vt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Gt(e,n,t,s={}){if(!t)return[];let i=M(e,n);if(!i)return[];if(i.indexOf(t)===-1)return[];if(P(n))return(xe(e,n).get(t)??[]).filter(m=>!Ni(m,s));let o=Ii(e,n,i),a=new RegExp(`\\b${Vt(t)}\\b`),r=[];for(let l=0;l<o.length;l++)Ni(l,s)||a.test(o[l]??"")&&r.push(l);return r}function Ni(e,n){return typeof n.excludeStartLine=="number"&&typeof n.excludeEndLine=="number"&&e>=n.excludeStartLine&&e<=n.excludeEndLine}var oc=W("file-identifiers");function vi(e,n){return oc.get(e,n,()=>new Set(xe(e,n).keys()))}var rc=W("file-ident-lines");function xe(e,n){return rc.get(e,n,()=>lc(e,n))}var ac=W("file-idents-by-line");function Ci(e,n){return ac.get(e,n,()=>{let t=xe(e,n),s=0;for(let o of t.values()){let a=o[o.length-1];a!==void 0&&a>s&&(s=a)}let i=new Array(s+1);for(let o=0;o<=s;o+=1)i[o]=new Set;for(let[o,a]of t)for(let r of a)i[r].add(o);return i})}function lc(e,n){let t=new Map,s=(r,l)=>{let c=t.get(r);if(!c){t.set(r,[l]);return}c[c.length-1]!==l&&c.push(l)};if(P(n)){let r=O(e,n);if(r){let l=P(n),c=l==="rust"?new Set(["identifier","type_identifier","field_identifier"]):l==="python"?new Set(["identifier"]):new Set(["identifier","property_identifier","type_identifier"]),m=new Set(["rust","python"]),u=/\{([^{}]*)\}/g,d=/\b([A-Za-z_][\w]*)\b/g,g=p=>{if(c.has(p.type)&&s(p.text,p.startPosition.row),l&&m.has(l)&&p.type==="string_content"){let f=p.startPosition.row;for(let y of p.text.matchAll(u)){let h=y[1]??"";for(let b of h.matchAll(d))b[1]&&s(b[1],f)}}for(let f of p.children)g(f)};return g(r.rootNode),t}}let i=M(e,n);if(!i)return t;let o=zt(i).split(/\r?\n/),a=/\b([A-Za-z_$][\w$]*)\b/g;for(let r=0;r<o.length;r+=1){let l=o[r]??"";for(let c of l.matchAll(a))c[1]&&s(c[1],r)}return t}import{existsSync as Vi,readFileSync as Gi}from"fs";import{join as Yi}from"path";import{existsSync as et}from"fs";import{basename as cc,dirname as ke,extname as Ie,join as ue,relative as We,resolve as re}from"path";var uc=je("indexed-paths"),Yt=[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs",".vue"],Fn=[".py",".pyi"],me=[".java",".scala",".kt",".kts"],Tn=[".rs"],An=[".rb"],Ei=[".c",".h",".cc",".cpp",".cxx",".hpp",".hh",".hxx"],tt=[".cs",".vb"],jn=[".dart"],gt=[".php"],mc=[Yt,Fn,me,Tn,An,Ei,tt,jn,gt];function Oe(e,n){return n.includes(Ie(e).toLowerCase())}function dc(e){return Oe(e,Fn)}function pc(e){return Oe(e,me)}function fc(e){return Oe(e,Tn)}function gc(e){return Oe(e,An)}function hc(e){return Oe(e,Ei)}function yc(e){return Oe(e,tt)}function Ri(e){return Ie(e).toLowerCase()===".vb"}function bc(e){return Oe(e,jn)}function Sc(e){return Oe(e,gt)}function Bn(e){let n=Ie(e).toLowerCase();for(let t of mc)if(t.includes(n))return t;return Yt}function _c(e){return pc(e)||yc(e)||Sc(e)}function He(e,n,t){return dc(n)?nt(e,n,t):fc(n)?Ne(e,n,t):gc(n)?Kt(e,n,t):hc(n)?Qt(e,n,t):_c(n)?H(e,t.replace(/\\/g,"."),Bn(n)):bc(n)?Xt(e,n,t):xc(e,n,t)}function xc(e,n,t){if(!t.startsWith(".")&&!t.startsWith("/"))return null;let s=ke(ue(e.config.projectRoot,n)),i=re(s,t),o=Je(e);for(let a of Ec(i)){let r=ae(We(e.config.projectRoot,a));if(o.has(r)||et(a))return r}return ae(We(e.config.projectRoot,i))}function nt(e,n,t){let s=Je(e),i;if(t.startsWith(".")){let o=t.match(/^(\.+)(.*)$/);if(!o)return null;let a=o[1].length,r=o[2].replace(/^\./,""),l=ke(ue(e.config.projectRoot,n));for(let c=1;c<a;c++)l=ke(l);i=r?re(l,r.replace(/\./g,"/")):l}else i=re(e.config.projectRoot,t.replace(/\./g,"/"));for(let o of Ic(i)){let a=ae(We(e.config.projectRoot,o));if(s.has(a)||et(o))return a}return null}function Ne(e,n,t){if(!t)return null;let s=t.replace(/\s+as\s+.+$/,"").trim();if(!s.startsWith("crate::")&&!s.startsWith("self::")&&!s.startsWith("super::"))return null;let i=ke(ue(e.config.projectRoot,n)),o;s.startsWith("crate::")?o=re(e.config.projectRoot,"src",s.slice(7).replace(/::/g,"/")):s.startsWith("self::")?o=re(i,s.slice(6).replace(/::/g,"/")):o=re(ke(i),s.slice(7).replace(/::/g,"/"));for(let a of Nc(o)){let r=ae(We(e.config.projectRoot,a));if(Je(e).has(r)||et(a))return r}return null}function Kt(e,n,t){let s=ke(ue(e.config.projectRoot,n)),i=re(s,t);for(let o of vc(i)){let a=ae(We(e.config.projectRoot,o));if(Je(e).has(a)||et(o))return a}return null}function Qt(e,n,t){let s=Je(e),i=ke(ue(e.config.projectRoot,n)),o=[re(i,t),re(e.config.projectRoot,t),re(e.config.projectRoot,"include",t),re(e.config.projectRoot,"src",t)];for(let a of o){let r=ae(We(e.config.projectRoot,a));if(s.has(r)||et(a))return r}return null}function H(e,n,t){let s=Je(e),i=n.replace(/\\/g,".").replace(/::/g,".").replace(/^global::/,""),o=i.replace(/\./g,"/"),a=i.split(".").pop()??i;for(let l of t){let c=`${o}${l}`,m=[...s].find(u=>u.endsWith(c));if(m)return m}for(let l of t){let c=[...s].find(m=>cc(m)===`${a}${l}`);if(c)return c}let r=[...s].filter(l=>t.includes(Ie(l).toLowerCase())).filter(l=>l.includes(`/${o}/`)||l.includes(`/${a}/`)).sort((l,c)=>l.localeCompare(c));return r.length===1?r[0]:null}function Xt(e,n,t){let s=Je(e);if(t.startsWith("package:")){let a=t.slice(8),r=a.indexOf("/");if(r<0)return null;let l=a.slice(r+1),c=ae(l.startsWith("lib/")?l:`lib/${l}`);return s.has(c)?c:null}let i=ke(ue(e.config.projectRoot,n)),o=re(i,t);for(let a of Cc(o)){let r=ae(We(e.config.projectRoot,a));if(s.has(r)||et(a))return r}return null}function Ic(e){let n=Ie(e);return Fn.includes(n)?[e]:[`${e}.py`,`${e}.pyi`,ue(e,"__init__.py"),ue(e,"__init__.pyi")]}function Nc(e){let n=Ie(e);return Tn.includes(n)?[e]:[`${e}.rs`,ue(e,"mod.rs")]}function vc(e){let n=Ie(e);return An.includes(n)?[e]:[`${e}.rb`,ue(e,"index.rb")]}function Cc(e){let n=Ie(e);return jn.includes(n)?[e]:[`${e}.dart`,e]}function Ec(e){let n=Ie(e),t=new Set;if(n){t.add(e);for(let s of Yt)t.add(e.slice(0,-n.length)+s)}else for(let s of Yt)t.add(`${e}${s}`),t.add(ue(e,`index${s}`));return[...t]}function Je(e){return uc.get(e,()=>new Set(e.all(`SELECT relative_path
314
314
  FROM documents
315
315
  WHERE 1 = 1
316
- ${e.pathExclusionsFor("documents")}`).map(n=>ae(n.relative_path)).filter(n=>!e.isIgnored(n))))}function ae(e){return e.replace(/\\/g,"/")}function oe(e){let n=[],t=0,s=0;for(let i=0;i<e.length;i++){let o=e[i];(o==="{"||o==="["||o==="(")&&t++,(o==="}"||o==="]"||o===")")&&t--,o===","&&t===0&&(n.push(e.slice(s,i)),s=i+1)}return n.push(e.slice(s)),n}function le(e,n){for(let t of e.namedChildren)if(t.type===n)return t;return null}function J(e,n){let t=new Set,s=new Set(["identifier","type_identifier","property_identifier","shorthand_property_identifier","field_identifier"]),i=(o,a)=>{let r=a||n.has(o.type);!r&&s.has(o.type)&&t.add(o.text);for(let l of o.children)i(l,r)};return i(e.rootNode,!1),t}function ge(e,n,t,s,i,o,a){return{importedName:i,localName:o,sourcePath:a??H(e,s,Bn(n)),kind:"named",used:te(t,o),usedMembers:[]}}function Li(e,n,t){let s=O(e,n);return s?Ec(e,n,s):wc(t).flatMap(i=>Dc(e,n,i.clause,i.specifier,i.start,i.end,t))}function Ec(e,n,t){let s=J(t,new Set(["import_statement"]));if(mt(n))for(let o of Ac(e,n))s.add(o);let i=[];for(let o of t.rootNode.descendantsOfType("import_statement")){let a=Rc(o);if(!a)continue;let r=He(e,n,a),l=le(o,"import_clause");if(!l){i.push({importedName:"*",localName:null,sourcePath:r,kind:"side-effect",used:!0,usedMembers:[]});continue}for(let c of l.namedChildren)switch(c.type){case"identifier":{let m=c.text;i.push({importedName:"default",localName:m,sourcePath:r,kind:"default",used:s.has(m),usedMembers:[]});break}case"namespace_import":{let u=le(c,"identifier")?.text??"";if(!u)break;let d=Lc(t,u);i.push({importedName:"*",localName:u,sourcePath:r,kind:"namespace",used:d.length>0||s.has(u),usedMembers:d});break}case"named_imports":{for(let m of c.namedChildren){if(m.type!=="import_specifier")continue;let u=m.namedChild(0),d=m.namedChild(1);if(!u)continue;let g=u.text,p=d?.text??g;i.push({importedName:g,localName:p,sourcePath:r,kind:"named",used:s.has(p),usedMembers:[]})}break}}}return i}function Rc(e){let n=le(e,"string");if(!n)return null;let t=le(n,"string_fragment");return t?t.text:null}function Lc(e,n){let t=new Set;for(let s of e.rootNode.descendantsOfType("member_expression")){let i=s.namedChild(0),o=s.namedChild(1);!i||!o||i.type!=="identifier"||i.text!==n||(o.type==="property_identifier"||o.type==="identifier")&&t.add(o.text)}return[...t]}function wc(e){let n=[],t=/^[ \t]*import\s+([\s\S]*?)\s+from\s+['"]([^'"]+)['"]\s*;?/gm;for(let i of e.matchAll(t)){let o=i[0],a=i[1],r=i[2];!o||!r||typeof i.index!="number"||n.push({clause:a,specifier:r,start:i.index,end:i.index+o.length})}let s=/^[ \t]*import\s+['"]([^'"]+)['"]\s*;?/gm;for(let i of e.matchAll(s)){let o=i[0],a=i[1];!o||!a||typeof i.index!="number"||n.push({clause:null,specifier:a,start:i.index,end:i.index+o.length})}return n.sort((i,o)=>i.start-o.start)}function Dc(e,n,t,s,i,o,a){let r=He(e,n,s),l=z(a,i,o);return t?kc(t).map(m=>({...m,sourcePath:r})).map(m=>{if(m.kind==="namespace"){let u=Ze(l,m.localName);return{...m,used:u.length>0||te(l,m.localName),usedMembers:u}}return m.kind==="side-effect"?{...m,used:!0,usedMembers:[]}:{...m,used:m.localName?te(l,m.localName):!1,usedMembers:[]}}):[{importedName:"*",localName:null,sourcePath:r,kind:"side-effect",used:!0,usedMembers:[]}]}function kc(e){let n=e.trim().replace(/^type\s+/,""),[t,s]=Oc(n),i=[];return t&&i.push(...Ri(t)),s&&i.push(...Ri(s)),i}function Ri(e){let n=e.trim();if(!n)return[];if(n.startsWith("{")){let t=n.slice(1,-1).trim();return t?oe(t).map(s=>{let i=s.trim().replace(/^type\s+/,""),[o,a]=i.split(/\s+as\s+/);return{importedName:o.trim(),localName:(a??o).trim(),kind:"named"}}):[]}return n.startsWith("* as ")?[{importedName:"*",localName:n.slice(5).trim(),kind:"namespace"}]:[{importedName:"default",localName:n,kind:"default"}]}function Oc(e){let n=0;for(let t=0;t<e.length;t++){let s=e[t];if(s==="{"&&n++,s==="}"&&n--,s===","&&n===0)return[e.slice(0,t).trim(),e.slice(t+1).trim()]}return[e.trim(),null]}function wi(e,n){let t=O(e,n);if(t)return Pc(e,n,t);let s=M(e,n);if(!s)return[];let i=[],o=/^[ \t]*export\s+(?:type\s+)?\{([\s\S]*?)\}\s+from\s+['"]([^'"]+)['"]\s*;?/gm;for(let l of s.matchAll(o)){if(typeof l.index!="number")continue;let c=l[1]??"",m=l[2]??"",u=oe(c).map(p=>$c(p.trim())).filter(p=>!!p),d=st(s,l.index),g=st(s,l.index+l[0].length-1);i.push({kind:"named",sourcePath:He(e,n,m),names:u,startLine:d,endLine:g})}let a=/^[ \t]*export\s+\*\s+as\s+(\w+)\s+from\s+['"]([^'"]+)['"]\s*;?/gm;for(let l of s.matchAll(a)){if(typeof l.index!="number")continue;let c=l[2]??"",m=st(s,l.index),u=st(s,l.index+l[0].length-1);i.push({kind:"star-as",sourcePath:He(e,n,c),names:[],startLine:m,endLine:u})}let r=/^[ \t]*export\s+\*\s+from\s+['"]([^'"]+)['"]\s*;?/gm;for(let l of s.matchAll(r)){if(typeof l.index!="number")continue;let c=l[1]??"",m=st(s,l.index),u=st(s,l.index+l[0].length-1);i.push({kind:"star",sourcePath:He(e,n,c),names:[],startLine:m,endLine:u})}return i}function $c(e){if(!e)return null;let n=e.replace(/^type\s+/,"").trim();if(!n)return null;let t=n.match(/^(\w+)\s+as\s+(\w+)$/);if(t)return t[2]??null;let s=n.match(/^(\w+)$/);return s?s[1]??null:null}function st(e,n){let t=0;for(let s=0;s<n&&s<e.length;s++)e.charCodeAt(s)===10&&t++;return t}function Pc(e,n,t){let s=[];for(let i of t.rootNode.descendantsOfType("export_statement")){let o=Mc(e,n,i);if(o===void 0)continue;let a=i.startPosition.row,r=i.endPosition.row,l=Fc(i,o,a,r);s.push(l)}return s}function Mc(e,n,t){let s=le(t,"string");if(!s)return;let i=le(s,"string_fragment");if(i)return He(e,n,i.text)}function Fc(e,n,t,s){let i=le(e,"export_clause");if(i){let a=[];for(let r of i.namedChildren){if(r.type!=="export_specifier")continue;let l=r.namedChild(0),c=r.namedChild(1);l&&a.push((c??l).text)}return{kind:"named",sourcePath:n,names:a,startLine:t,endLine:s}}return le(e,"namespace_export")?{kind:"star-as",sourcePath:n,names:[],startLine:t,endLine:s}:{kind:"star",sourcePath:n,names:[],startLine:t,endLine:s}}var Tc=W("vue-non-script-identifiers");function Ac(e,n){return Tc.get(e,n,()=>{let t=new Set,s=M(e,n);if(!s)return t;let o=s.replace(/<script\b[^>]*>[\s\S]*?<\/script>/g,a=>a.replace(/[^\r\n]/g," ")).replace(/<!--[\s\S]*?-->/g,a=>a.replace(/[^\r\n]/g," ")).replace(/\/\*[\s\S]*?\*\//g,a=>a.replace(/[^\r\n]/g," "));for(let a of o.matchAll(/[A-Za-z_$][\w$]*/g))t.add(a[0]);return t})}import{basename as Di}from"path";function ki(e,n,t){let s=O(e,n);if(s)return jc(e,n,s);let i=[];for(let o of t.matchAll(/^[ \t]*#include\s+[<"]([^">]+)[">]\s*$/gm)){let a=o[1]?.trim(),r=o[0];if(!a||!r||typeof o.index!="number")continue;let l=z(t,o.index,o.index+r.length),c=Di(a).replace(/\.[^.]+$/,"");i.push({importedName:a,localName:c,sourcePath:Qt(e,n,a),kind:"named",used:te(l,c),usedMembers:[]})}return i}function jc(e,n,t){let s=J(t,new Set(["preproc_include"])),i=[];for(let o of t.rootNode.descendantsOfType("preproc_include")){let a=null;for(let l of o.namedChildren){if(l.type==="system_lib_string"){a=l.text.replace(/^<|>$/g,"");break}if(l.type==="string_literal"){a=l.namedChildren.find(m=>m.type==="string_content")?.text??l.text.replace(/^"|"$/g,"");break}}if(!a)continue;let r=Di(a).replace(/\.[^.]+$/,"");i.push({importedName:a,localName:r,sourcePath:Qt(e,n,a),kind:"named",used:s.has(r),usedMembers:[]})}return i}function Oi(e,n,t){let s=[];for(let i of t.matchAll(/^[ \t]*import\s+['"]([^'"]+)['"](?:\s+as\s+([A-Za-z_]\w*))?[\s\S]*?;$/gm)){let o=i[1]?.trim(),a=i[2]?.trim()??null,r=i[0];if(!o||!r||typeof i.index!="number")continue;let l=z(t,i.index,i.index+r.length);s.push({importedName:o,localName:a,sourcePath:Xt(e,n,o),kind:a?"namespace":"side-effect",used:a?te(l,a):!0,usedMembers:a?Ze(l,a):[]})}return s}function $i(e,n,t){let s=[];for(let i of t.matchAll(/^[ \t]*export\s+['"]([^'"]+)['"][\s\S]*?;$/gm)){let o=i[1]?.trim();o&&s.push({specifier:o,sourcePath:Xt(e,n,o)})}return s}function Pi(e,n,t){let s=O(e,n),i=P(n);if(s&&i==="csharp")return Wc(e,n,s);if(s&&i==="vb")return Bc(e,n,s);let o=[],a=Ei(n)?/^[ \t]*Imports\s+(.+?)\s*$/gm:/^[ \t]*using\s+(.+?)\s*;$/gm;for(let r of t.matchAll(a)){let l=r[1]?.trim(),c=r[0];if(!l||!c||typeof r.index!="number")continue;let m=z(t,r.index,r.index+c.length),[u,d]=l.split(/\s*=\s*/),g=!!d,p=(g?d:u)?.trim()??l,f=p.split(".").pop()??p,y=g?u?.trim()??f:f;o.push(ge(e,n,m,p,f,y,H(e,p,tt)))}return o}function Bc(e,n,t){let s=J(t,new Set(["imports_statement"])),i=[];for(let o of t.rootNode.descendantsOfType("imports_statement")){let a=o.namedChildren.filter(d=>d.type==="namespace_name");if(a.length===0)continue;let r=a[a.length-1],l=a.length>1?a[0]:null,c=r.text,m=c.split(".").pop()??c,u=l?.text??m;i.push({importedName:m,localName:u,sourcePath:H(e,c,tt),kind:l?"namespace":"named",used:s.has(u),usedMembers:[]})}return i}function Wc(e,n,t){let s=J(t,new Set(["using_directive"])),i=[];for(let o of t.rootNode.descendantsOfType("using_directive")){let a=o.namedChildren;if(a.length===0)continue;let r=null,l=null;if(a.length>=2&&a[0].type==="identifier"&&(a[1].type==="qualified_name"||a[1].type==="identifier")?(r=a[0],l=a[1]):l=a[a.length-1],!l)continue;let c=l.text,m=c.split(".").pop()??c,u=r?.text??m;i.push({importedName:m,localName:u,sourcePath:H(e,c,tt),kind:r?"namespace":"named",used:s.has(u),usedMembers:[]})}return i}function Mi(e,n,t){let s=O(e,n),i=P(n);if(s&&i==="java")return Hc(e,n,s);if(s&&i==="kotlin")return Jc(e,n,s);if(s&&i==="scala")return Uc(e,n,s);let o=[];for(let a of t.matchAll(/^[ \t]*import\s+(?:static\s+)?(.+?)\s*;?$/gm)){let r=a[1]?.trim(),l=a[0];if(!r||!l||typeof a.index!="number")continue;let c=z(t,a.index,a.index+l.length);o.push(...qc(e,n,r,c))}return o}function Hc(e,n,t){let s=J(t,new Set(["import_declaration"])),i=[];for(let o of t.rootNode.descendantsOfType("import_declaration")){let a=o.children.some(u=>u.type==="asterisk"),l=o.namedChildren.find(u=>u.type==="scoped_identifier")??o.namedChildren.find(u=>u.type==="identifier");if(!l)continue;let c=l.text;if(a){i.push({importedName:"*",localName:null,sourcePath:H(e,c,me),kind:"namespace",used:!0,usedMembers:[]});continue}let m=c.split(".").pop()??c;i.push({importedName:m,localName:m,sourcePath:H(e,c,me),kind:"named",used:s.has(m),usedMembers:[]})}return i}function Jc(e,n,t){let s=J(t,new Set(["import_header","import_list"])),i=[];for(let o of t.rootNode.descendantsOfType("import_header")){let a=o.namedChildren.find(g=>g.type==="identifier");if(!a)continue;let r=o.namedChildren.some(g=>g.type==="wildcard_import"),l=o.namedChildren.find(g=>g.type==="import_alias");if(r){i.push({importedName:"*",localName:null,sourcePath:H(e,a.text,me),kind:"namespace",used:!0,usedMembers:[]});continue}let c=a.text,m=c.split(".").pop()??c,d=l?.namedChild(0)?.text??m;i.push({importedName:m,localName:d,sourcePath:H(e,c,me),kind:"named",used:s.has(d),usedMembers:[]})}return i}function Uc(e,n,t){let s=J(t,new Set(["import_declaration"])),i=[];for(let o of t.rootNode.descendantsOfType("import_declaration")){let a=o.namedChildren.find(u=>u.type==="namespace_selectors"||u.type==="namespace_wildcard"),r=o.namedChildren.filter(u=>u!==a&&(u.type==="identifier"||u.type==="stable_identifier")),l=r.map(u=>u.text).join(".");if(!l)continue;if(a?.type==="namespace_wildcard"){i.push({importedName:"*",localName:null,sourcePath:H(e,l,me),kind:"namespace",used:!0,usedMembers:[]});continue}if(a?.type==="namespace_selectors"){for(let u of a.namedChildren)if(u.type==="arrow_renamed_identifier"){let[d,g]=u.namedChildren;if(!d)continue;let p=d.text,f=g?.text??p;if(p==="_")continue;i.push({importedName:p,localName:f,sourcePath:H(e,`${l}.${p}`,me),kind:"named",used:s.has(f),usedMembers:[]})}else if(u.type==="identifier"){let d=u.text;i.push({importedName:d,localName:d,sourcePath:H(e,`${l}.${d}`,me),kind:"named",used:s.has(d),usedMembers:[]})}continue}let c=r[r.length-1]?.text??l,m=r.slice(0,-1).map(u=>u.text).join(".")||l;i.push({importedName:c,localName:c,sourcePath:H(e,m&&r.length>1?`${m}.${c}`:l,me),kind:"named",used:s.has(c),usedMembers:[]})}return i}function qc(e,n,t,s){if(t.includes("{")&&t.includes("}")){let i=t.slice(0,t.indexOf("{")).replace(/\.$/,"").trim(),o=t.slice(t.indexOf("{")+1,t.lastIndexOf("}")).trim();return oe(o).flatMap(a=>{let r=a.trim();if(!r)return[];let[l,c]=r.includes("=>")?r.split(/\s*=>\s*/):r.split(/\s+as\s+/),m=l?.trim();if(!m||m==="_")return[];let u=(c??m.split(".").pop()??m).trim(),d=m==="_"?i:`${i}.${m}`.replace(/\.\./g,".");return[ge(e,n,s,d,m,u)]})}return[ge(e,n,s,t,t.split(".").pop()??t,t.split(".").pop()??t)]}function Ti(e,n,t){let s=O(e,n);if(s)return zc(e,n,s);let i=[];for(let o of t.matchAll(/^[ \t]*use\s+(.+?)\s*;$/gm)){let a=o[1]?.trim(),r=o[0];if(!a||!r||typeof o.index!="number")continue;let l=z(t,o.index,o.index+r.length);for(let c of oe(a)){let m=c.trim();if(!m)continue;let[u,d]=m.split(/\s+as\s+/i),g=u?.trim()??m,p=g.split("\\").pop()??g,f=(d??p).trim();i.push(ge(e,n,l,g,p,f,H(e,g.replace(/\\/g,"."),gt)))}}return i}function zc(e,n,t){let s=J(t,new Set(["namespace_use_declaration"])),i=[],o=(a,r,l)=>{i.push({importedName:r,localName:l,sourcePath:H(e,a.replace(/\\/g,"."),gt),kind:"named",used:s.has(l),usedMembers:[]})};for(let a of t.rootNode.descendantsOfType("namespace_use_declaration")){let r=a.namedChildren.find(l=>l.type==="namespace_use_group");if(r){let l=a.namedChildren.find(c=>c.type==="namespace_name")?.text??"";for(let c of r.namedChildren){if(c.type!=="namespace_use_clause")continue;let{importedName:m,localName:u,qualified:d}=Fi(c,l);m&&o(d,m,u)}continue}for(let l of a.namedChildren){if(l.type!=="namespace_use_clause")continue;let{importedName:c,localName:m,qualified:u}=Fi(l,"");c&&o(u,c,m)}}return i}function Fi(e,n){let t=e.namedChildren.find(c=>c.type==="qualified_name"),s=e.namedChildren.filter(c=>c.type==="name"),i="";t?i=t.text:s.length>=1&&(i=s[0].text);let o=t&&s.length>0?s[s.length-1]:null,a=i.split("\\").pop()??i,r=o?.text??a,l=n?`${n}\\${i}`:i;return{importedName:a,localName:r,qualified:l}}function Bi(e,n,t){let s=O(e,n);return s?Vc(e,n,s):Yc(t).flatMap(i=>Qc(e,n,i,t))}function Vc(e,n,t){let s=J(t,new Set(["import_statement","import_from_statement"])),i=[];for(let o of t.rootNode.descendantsOfType("import_statement"))for(let a of o.namedChildren){let r=Ai(a);if(!r)continue;let l=nt(e,n,r.qualifiedName);i.push({importedName:r.qualifiedName,localName:r.localName,sourcePath:l,kind:"namespace",used:s.has(r.localName),usedMembers:[]})}for(let o of t.rootNode.descendantsOfType("import_from_statement")){let a=o.namedChild(0);if(!a)continue;let r=Gc(a);if(r===null)continue;let l=nt(e,n,r);for(let c=1;c<o.namedChildCount;c+=1){let m=o.namedChild(c);if(m.type==="wildcard_import"){i.push({importedName:"*",localName:null,sourcePath:l,kind:"side-effect",used:!0,usedMembers:[]});continue}let u=Ai(m);u&&i.push({importedName:u.qualifiedName,localName:u.localName,sourcePath:l,kind:"named",used:s.has(u.localName),usedMembers:[]})}}return i}function Ai(e){if(e.type==="aliased_import"){let n=e.namedChild(0),t=e.namedChild(1);return!n||!t?null:{qualifiedName:n.text,localName:t.text}}if(e.type==="dotted_name"){let n=e.text;return{qualifiedName:n,localName:n.split(".")[0]??n}}return e.type==="identifier"?{qualifiedName:e.text,localName:e.text}:null}function Gc(e){if(e.type==="dotted_name")return e.text;if(e.type==="relative_import"){let n=le(e,"import_prefix")?.text??"",t=le(e,"dotted_name")?.text??"";return`${n}${t}`}return null}function Yc(e){let n=e.split(`
317
- `),t=[],s=0;for(let i=0;i<n.length;i++){let o=n[i],a=o.trimStart(),r=s;if(s+=o.length+1,!a.startsWith("import ")&&!a.startsWith("from "))continue;let l=o,c=r+o.length,m=ji(o);for(;i+1<n.length&&(m>0||l.trimEnd().endsWith("\\"));){i++;let d=n[i];l+=`
318
- ${d}`,c+=1+d.length,m+=ji(d),s+=d.length+1}let u=Kc(l);u&&t.push({...u,start:r,end:c})}return t}function Kc(e){let n=e.replace(/\\\s*\n/g," ").trim();if(n.startsWith("import "))return{kind:"import",module:null,clause:n.slice(7).trim()};let t=n.match(/^from\s+([.\w]+)\s+import\s+([\s\S]+)$/);if(!t)return null;let s=t[2].trim();return s.startsWith("(")&&s.endsWith(")")&&(s=s.slice(1,-1).trim()),{kind:"from",module:t[1],clause:s}}function Qc(e,n,t,s){let i=z(s,t.start,t.end),o=t.clause.replace(/\n/g," ").trim();if(t.kind==="import")return oe(o).flatMap(l=>{let c=l.trim().replace(/,$/,"");if(!c)return[];let[m,u]=c.split(/\s+as\s+/),d=m.trim(),g=(u??d.split(".")[0]??d).trim(),p=nt(e,n,d),f=Ze(i,g);return[{importedName:d,localName:g,sourcePath:p,kind:"namespace",used:te(i,g)||f.length>0,usedMembers:f}]});let a=t.module?nt(e,n,t.module):null,r=[];for(let l of oe(o)){let c=l.trim().replace(/,$/,"");if(!c)continue;if(c==="*"){r.push({importedName:"*",localName:null,sourcePath:a,kind:"side-effect",used:!0,usedMembers:[]});continue}let[m,u]=c.split(/\s+as\s+/),d=(u??m).trim();r.push({importedName:m.trim(),localName:d,sourcePath:a,kind:"named",used:te(i,d),usedMembers:[]})}return r}function ji(e){let n=0;for(let t of e)t==="("&&n++,t===")"&&n--;return n}import{basename as Xc}from"path";function Wi(e,n,t){let s=O(e,n);if(s)return Zc(e,n,s);let i=[];for(let o of t.matchAll(/^[ \t]*(require_relative|require)\s+["']([^"']+)["']\s*$/gm)){let a=o[1],r=o[2],l=o[0];if(!a||!r||!l||typeof o.index!="number")continue;let c=z(t,o.index,o.index+l.length),m=a==="require_relative"?Kt(e,n,r):null;if(m){let u=Hi(r);i.push({importedName:u,localName:u,sourcePath:m,kind:"named",used:te(c,u),usedMembers:[]});continue}i.push({importedName:r,localName:null,sourcePath:m,kind:"side-effect",used:!0,usedMembers:[]})}return i}function Zc(e,n,t){let s=J(t,new Set([])),i=[],o=new Set(["require","require_relative","load"]);for(let a of t.rootNode.descendantsOfType("call")){let r=a.namedChild(0);if(!r||r.type!=="identifier"||!o.has(r.text))continue;let c=a.namedChildren.find(g=>g.type==="argument_list")?.namedChild(0);if(!c||c.type!=="string")continue;let u=c.namedChildren.find(g=>g.type==="string_content")?.text;if(!u)continue;let d=r.text==="require_relative"?Kt(e,n,u):null;if(d){let g=Hi(u);i.push({importedName:g,localName:g,sourcePath:d,kind:"named",used:s.has(g),usedMembers:[]})}else i.push({importedName:u,localName:null,sourcePath:d,kind:"side-effect",used:!0,usedMembers:[]})}return i}function Hi(e){return Xc(e).replace(/\.[^.]+$/,"").split("_").filter(Boolean).map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join("")}function Ji(e,n,t){let s=O(e,n);if(s)return eu(e,n,s);let i=[];for(let o of t.matchAll(/^[ \t]*use\s+(.+?)\s*;$/gm)){let a=o[1]?.trim(),r=o[0];if(!a||!r||typeof o.index!="number")continue;let l=z(t,o.index,o.index+r.length);i.push(...tu(e,n,a,l))}return i}function eu(e,n,t){let s=J(t,new Set(["use_declaration"])),i=[];for(let o of t.rootNode.descendantsOfType("use_declaration")){let a=o.namedChild(0);if(a)for(let r of ht(a,"")){if(!r.importedName||r.importedName==="*")continue;let l=Ne(e,n,r.qualifiedName)??Ne(e,n,r.qualifiedName.split("::").slice(0,-1).join("::"));i.push({importedName:r.importedName,localName:r.localName,sourcePath:l,kind:"named",used:s.has(r.localName),usedMembers:[]})}}return i}function ht(e,n){switch(e.type){case"identifier":case"super":case"self":case"crate":{let t=e.text;return[{qualifiedName:Zt(n,t),importedName:t,localName:t}]}case"scoped_identifier":{let t=e.text,s=t.split("::").pop()??t;return[{qualifiedName:Zt(n,t),importedName:s,localName:s}]}case"scoped_use_list":{let t=e.namedChild(0),s=e.namedChild(1);if(!t||!s)return[];let i=Zt(n,t.text),o=[];for(let a of s.namedChildren)o.push(...ht(a,i));return o}case"use_list":{let t=[];for(let s of e.namedChildren)t.push(...ht(s,n));return t}case"use_as_clause":{let t=e.namedChild(0),s=e.namedChild(1);if(!t||!s)return[];let i=ht(t,n),o=s.text;return i.map(a=>({...a,localName:o}))}case"use_wildcard":{let t=e.namedChild(0),s=t?t.text:"";return[{qualifiedName:Zt(n,`${s}::*`),importedName:"*",localName:"*"}]}default:return[]}}function Zt(e,n){return e?n?`${e}::${n}`:e:n}function tu(e,n,t,s){let i=t.trim();if(i.includes("{")&&i.includes("}")){let m=i.slice(0,i.indexOf("{")).replace(/::$/,"").trim(),u=i.slice(i.indexOf("{")+1,i.lastIndexOf("}")).trim();return oe(u).flatMap(d=>{let g=d.trim();if(!g||g==="self")return[];let[p,f]=g.split(/\s+as\s+/),y=p?.trim();if(!y)return[];let h=(f??y.split("::").pop()??y).trim(),b=`${m}::${y}`.replace(/::::/g,"::");return[ge(e,n,s,b,y.split("::").pop()??y,h,Ne(e,n,m))]})}let[o,a]=i.split(/\s+as\s+/),r=o?.trim()??i,l=(a??r.split("::").pop()??r).trim(),c=Ne(e,n,r)??Ne(e,n,r.split("::").slice(0,-1).join("::"));return[ge(e,n,s,r,r.split("::").pop()??r,l,c)]}function Ui(e,n,t){let s=O(e,n);if(s)return nu(e,n,s);let i=[];for(let o of t.matchAll(/^[ \t]*pub\s+use\s+(.+?)\s*;$/gm)){let a=o[1]?.trim();a&&i.push(...iu(e,n,a))}return i}function nu(e,n,t){let s=[];for(let i of t.rootNode.descendantsOfType("use_declaration")){if(!su(i))continue;let o=i.namedChildren.find(a=>a.type!=="visibility_modifier");if(o)for(let a of ht(o,""))a.importedName&&s.push(Wn(e,n,a.qualifiedName))}return s}function su(e){for(let n of e.children)if(n.type==="visibility_modifier"&&n.text.startsWith("pub"))return!0;return!1}function iu(e,n,t){let s=t.trim();if(s.includes("{")&&s.includes("}")){let i=s.slice(0,s.indexOf("{")).replace(/::$/,"").trim(),o=s.slice(s.indexOf("{")+1,s.lastIndexOf("}")).trim();return oe(o).flatMap(a=>{let r=a.trim();if(!r||r==="self")return[];let[l]=r.split(/\s+as\s+/),c=`${i}::${l?.trim()??r}`.replace(/::::/g,"::");return[Wn(e,n,c)]})}return[Wn(e,n,s)]}function Wn(e,n,t){return{specifier:t,sourcePath:Ne(e,n,t)??Ne(e,n,t.split("::").slice(0,-1).join("::"))}}function qi(e,n){let t=n.toLowerCase();for(let s of e)for(let i of s.extensions)if(t.endsWith(i))return s;return null}var ou={language:"javascript",extensions:[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs",".vue"],parseImports:Li},ru={language:"python",extensions:[".py",".pyi"],parseImports:Bi},au={language:"jvm",extensions:[".java",".scala",".kt",".kts"],parseImports:Mi},lu={language:"rust",extensions:[".rs"],parseImports:Ji,parseExports:Ui},cu={language:"ruby",extensions:[".rb"],parseImports:Wi},uu={language:"c/cpp",extensions:[".c",".h",".cc",".cpp",".cxx",".hpp",".hh",".hxx"],parseImports:ki},mu={language:"dotnet",extensions:[".cs",".vb"],parseImports:Pi},du={language:"dart",extensions:[".dart"],parseImports:Oi,parseExports:$i},pu={language:"php",extensions:[".php"],parseImports:Ti},fu=[ou,ru,au,lu,cu,uu,mu,du,pu];function Hn(e){return qi(fu,e)}function Yi(e,n){return wi(e,n)}var gu=W("source-imports"),hu=W("source-exports");function de(e,n){let t=ae(n);return gu.get(e,t,()=>{let s=Hn(t);if(!s)return[];let i=Gi(e.config.projectRoot,t);if(!zi(i))return[];let o=Vi(i,"utf-8");return s.parseImports(e,t,o)})}function Jn(e,n){let t=ae(n);return hu.get(e,t,()=>{let s=Hn(t);if(!s?.parseExports)return[];let i=Gi(e.config.projectRoot,t);if(!zi(i))return[];let o=Vi(i,"utf-8");return s.parseExports(e,t,o)})}var yu=W("file-dep-graph");function K(e,n){return yu.get(e,n??"",()=>{let t=n?`AND d1.relative_path LIKE '%${n}%'`:"",s=e.all(`SELECT DISTINCT
316
+ ${e.pathExclusionsFor("documents")}`).map(n=>ae(n.relative_path)).filter(n=>!e.isIgnored(n))))}function ae(e){return e.replace(/\\/g,"/")}function oe(e){let n=[],t=0,s=0;for(let i=0;i<e.length;i++){let o=e[i];(o==="{"||o==="["||o==="(")&&t++,(o==="}"||o==="]"||o===")")&&t--,o===","&&t===0&&(n.push(e.slice(s,i)),s=i+1)}return n.push(e.slice(s)),n}function le(e,n){for(let t of e.namedChildren)if(t.type===n)return t;return null}function J(e,n){let t=new Set,s=new Set(["identifier","type_identifier","property_identifier","shorthand_property_identifier","field_identifier"]),i=(o,a)=>{let r=a||n.has(o.type);!r&&s.has(o.type)&&t.add(o.text);for(let l of o.children)i(l,r)};return i(e.rootNode,!1),t}function ge(e,n,t,s,i,o,a){return{importedName:i,localName:o,sourcePath:a??H(e,s,Bn(n)),kind:"named",used:te(t,o),usedMembers:[]}}function wi(e,n,t){let s=O(e,n);return s?Rc(e,n,s):Dc(t).flatMap(i=>kc(e,n,i.clause,i.specifier,i.start,i.end,t))}function Rc(e,n,t){let s=J(t,new Set(["import_statement"]));if(mt(n))for(let o of jc(e,n))s.add(o);let i=[];for(let o of t.rootNode.descendantsOfType("import_statement")){let a=Lc(o);if(!a)continue;let r=He(e,n,a),l=le(o,"import_clause");if(!l){i.push({importedName:"*",localName:null,sourcePath:r,kind:"side-effect",used:!0,usedMembers:[]});continue}for(let c of l.namedChildren)switch(c.type){case"identifier":{let m=c.text;i.push({importedName:"default",localName:m,sourcePath:r,kind:"default",used:s.has(m),usedMembers:[]});break}case"namespace_import":{let u=le(c,"identifier")?.text??"";if(!u)break;let d=wc(t,u);i.push({importedName:"*",localName:u,sourcePath:r,kind:"namespace",used:d.length>0||s.has(u),usedMembers:d});break}case"named_imports":{for(let m of c.namedChildren){if(m.type!=="import_specifier")continue;let u=m.namedChild(0),d=m.namedChild(1);if(!u)continue;let g=u.text,p=d?.text??g;i.push({importedName:g,localName:p,sourcePath:r,kind:"named",used:s.has(p),usedMembers:[]})}break}}}return i}function Lc(e){let n=le(e,"string");if(!n)return null;let t=le(n,"string_fragment");return t?t.text:null}function wc(e,n){let t=new Set;for(let s of e.rootNode.descendantsOfType("member_expression")){let i=s.namedChild(0),o=s.namedChild(1);!i||!o||i.type!=="identifier"||i.text!==n||(o.type==="property_identifier"||o.type==="identifier")&&t.add(o.text)}return[...t]}function Dc(e){let n=[],t=/^[ \t]*import\s+([\s\S]*?)\s+from\s+['"]([^'"]+)['"]\s*;?/gm;for(let i of e.matchAll(t)){let o=i[0],a=i[1],r=i[2];!o||!r||typeof i.index!="number"||n.push({clause:a,specifier:r,start:i.index,end:i.index+o.length})}let s=/^[ \t]*import\s+['"]([^'"]+)['"]\s*;?/gm;for(let i of e.matchAll(s)){let o=i[0],a=i[1];!o||!a||typeof i.index!="number"||n.push({clause:null,specifier:a,start:i.index,end:i.index+o.length})}return n.sort((i,o)=>i.start-o.start)}function kc(e,n,t,s,i,o,a){let r=He(e,n,s),l=z(a,i,o);return t?Oc(t).map(m=>({...m,sourcePath:r})).map(m=>{if(m.kind==="namespace"){let u=Ze(l,m.localName);return{...m,used:u.length>0||te(l,m.localName),usedMembers:u}}return m.kind==="side-effect"?{...m,used:!0,usedMembers:[]}:{...m,used:m.localName?te(l,m.localName):!1,usedMembers:[]}}):[{importedName:"*",localName:null,sourcePath:r,kind:"side-effect",used:!0,usedMembers:[]}]}function Oc(e){let n=e.trim().replace(/^type\s+/,""),[t,s]=$c(n),i=[];return t&&i.push(...Li(t)),s&&i.push(...Li(s)),i}function Li(e){let n=e.trim();if(!n)return[];if(n.startsWith("{")){let t=n.slice(1,-1).trim();return t?oe(t).map(s=>{let i=s.trim().replace(/^type\s+/,""),[o,a]=i.split(/\s+as\s+/);return{importedName:o.trim(),localName:(a??o).trim(),kind:"named"}}):[]}return n.startsWith("* as ")?[{importedName:"*",localName:n.slice(5).trim(),kind:"namespace"}]:[{importedName:"default",localName:n,kind:"default"}]}function $c(e){let n=0;for(let t=0;t<e.length;t++){let s=e[t];if(s==="{"&&n++,s==="}"&&n--,s===","&&n===0)return[e.slice(0,t).trim(),e.slice(t+1).trim()]}return[e.trim(),null]}function Di(e,n){let t=O(e,n);if(t)return Mc(e,n,t);let s=M(e,n);if(!s)return[];let i=[],o=/^[ \t]*export\s+(?:type\s+)?\{([\s\S]*?)\}\s+from\s+['"]([^'"]+)['"]\s*;?/gm;for(let l of s.matchAll(o)){if(typeof l.index!="number")continue;let c=l[1]??"",m=l[2]??"",u=oe(c).map(p=>Pc(p.trim())).filter(p=>!!p),d=st(s,l.index),g=st(s,l.index+l[0].length-1);i.push({kind:"named",sourcePath:He(e,n,m),names:u,startLine:d,endLine:g})}let a=/^[ \t]*export\s+\*\s+as\s+(\w+)\s+from\s+['"]([^'"]+)['"]\s*;?/gm;for(let l of s.matchAll(a)){if(typeof l.index!="number")continue;let c=l[2]??"",m=st(s,l.index),u=st(s,l.index+l[0].length-1);i.push({kind:"star-as",sourcePath:He(e,n,c),names:[],startLine:m,endLine:u})}let r=/^[ \t]*export\s+\*\s+from\s+['"]([^'"]+)['"]\s*;?/gm;for(let l of s.matchAll(r)){if(typeof l.index!="number")continue;let c=l[1]??"",m=st(s,l.index),u=st(s,l.index+l[0].length-1);i.push({kind:"star",sourcePath:He(e,n,c),names:[],startLine:m,endLine:u})}return i}function Pc(e){if(!e)return null;let n=e.replace(/^type\s+/,"").trim();if(!n)return null;let t=n.match(/^(\w+)\s+as\s+(\w+)$/);if(t)return t[2]??null;let s=n.match(/^(\w+)$/);return s?s[1]??null:null}function st(e,n){let t=0;for(let s=0;s<n&&s<e.length;s++)e.charCodeAt(s)===10&&t++;return t}function Mc(e,n,t){let s=[];for(let i of t.rootNode.descendantsOfType("export_statement")){let o=Fc(e,n,i);if(o===void 0)continue;let a=i.startPosition.row,r=i.endPosition.row,l=Tc(i,o,a,r);s.push(l)}return s}function Fc(e,n,t){let s=le(t,"string");if(!s)return;let i=le(s,"string_fragment");if(i)return He(e,n,i.text)}function Tc(e,n,t,s){let i=le(e,"export_clause");if(i){let a=[];for(let r of i.namedChildren){if(r.type!=="export_specifier")continue;let l=r.namedChild(0),c=r.namedChild(1);l&&a.push((c??l).text)}return{kind:"named",sourcePath:n,names:a,startLine:t,endLine:s}}return le(e,"namespace_export")?{kind:"star-as",sourcePath:n,names:[],startLine:t,endLine:s}:{kind:"star",sourcePath:n,names:[],startLine:t,endLine:s}}var Ac=W("vue-non-script-identifiers");function jc(e,n){return Ac.get(e,n,()=>{let t=new Set,s=M(e,n);if(!s)return t;let o=s.replace(/<script\b[^>]*>[\s\S]*?<\/script>/g,a=>a.replace(/[^\r\n]/g," ")).replace(/<!--[\s\S]*?-->/g,a=>a.replace(/[^\r\n]/g," ")).replace(/\/\*[\s\S]*?\*\//g,a=>a.replace(/[^\r\n]/g," "));for(let a of o.matchAll(/[A-Za-z_$][\w$]*/g))t.add(a[0]);return t})}import{basename as ki}from"path";function Oi(e,n,t){let s=O(e,n);if(s)return Bc(e,n,s);let i=[];for(let o of t.matchAll(/^[ \t]*#include\s+[<"]([^">]+)[">]\s*$/gm)){let a=o[1]?.trim(),r=o[0];if(!a||!r||typeof o.index!="number")continue;let l=z(t,o.index,o.index+r.length),c=ki(a).replace(/\.[^.]+$/,"");i.push({importedName:a,localName:c,sourcePath:Qt(e,n,a),kind:"named",used:te(l,c),usedMembers:[]})}return i}function Bc(e,n,t){let s=J(t,new Set(["preproc_include"])),i=[];for(let o of t.rootNode.descendantsOfType("preproc_include")){let a=null;for(let l of o.namedChildren){if(l.type==="system_lib_string"){a=l.text.replace(/^<|>$/g,"");break}if(l.type==="string_literal"){a=l.namedChildren.find(m=>m.type==="string_content")?.text??l.text.replace(/^"|"$/g,"");break}}if(!a)continue;let r=ki(a).replace(/\.[^.]+$/,"");i.push({importedName:a,localName:r,sourcePath:Qt(e,n,a),kind:"named",used:s.has(r),usedMembers:[]})}return i}function $i(e,n,t){let s=[];for(let i of t.matchAll(/^[ \t]*import\s+['"]([^'"]+)['"](?:\s+as\s+([A-Za-z_]\w*))?[\s\S]*?;$/gm)){let o=i[1]?.trim(),a=i[2]?.trim()??null,r=i[0];if(!o||!r||typeof i.index!="number")continue;let l=z(t,i.index,i.index+r.length);s.push({importedName:o,localName:a,sourcePath:Xt(e,n,o),kind:a?"namespace":"side-effect",used:a?te(l,a):!0,usedMembers:a?Ze(l,a):[]})}return s}function Pi(e,n,t){let s=[];for(let i of t.matchAll(/^[ \t]*export\s+['"]([^'"]+)['"][\s\S]*?;$/gm)){let o=i[1]?.trim();o&&s.push({specifier:o,sourcePath:Xt(e,n,o)})}return s}function Mi(e,n,t){let s=O(e,n),i=P(n);if(s&&i==="csharp")return Hc(e,n,s);if(s&&i==="vb")return Wc(e,n,s);let o=[],a=Ri(n)?/^[ \t]*Imports\s+(.+?)\s*$/gm:/^[ \t]*using\s+(.+?)\s*;$/gm;for(let r of t.matchAll(a)){let l=r[1]?.trim(),c=r[0];if(!l||!c||typeof r.index!="number")continue;let m=z(t,r.index,r.index+c.length),[u,d]=l.split(/\s*=\s*/),g=!!d,p=(g?d:u)?.trim()??l,f=p.split(".").pop()??p,y=g?u?.trim()??f:f;o.push(ge(e,n,m,p,f,y,H(e,p,tt)))}return o}function Wc(e,n,t){let s=J(t,new Set(["imports_statement"])),i=[];for(let o of t.rootNode.descendantsOfType("imports_statement")){let a=o.namedChildren.filter(d=>d.type==="namespace_name");if(a.length===0)continue;let r=a[a.length-1],l=a.length>1?a[0]:null,c=r.text,m=c.split(".").pop()??c,u=l?.text??m;i.push({importedName:m,localName:u,sourcePath:H(e,c,tt),kind:l?"namespace":"named",used:s.has(u),usedMembers:[]})}return i}function Hc(e,n,t){let s=J(t,new Set(["using_directive"])),i=[];for(let o of t.rootNode.descendantsOfType("using_directive")){let a=o.namedChildren;if(a.length===0)continue;let r=null,l=null;if(a.length>=2&&a[0].type==="identifier"&&(a[1].type==="qualified_name"||a[1].type==="identifier")?(r=a[0],l=a[1]):l=a[a.length-1],!l)continue;let c=l.text,m=c.split(".").pop()??c,u=r?.text??m;i.push({importedName:m,localName:u,sourcePath:H(e,c,tt),kind:r?"namespace":"named",used:s.has(u),usedMembers:[]})}return i}function Fi(e,n,t){let s=O(e,n),i=P(n);if(s&&i==="java")return Jc(e,n,s);if(s&&i==="kotlin")return Uc(e,n,s);if(s&&i==="scala")return qc(e,n,s);let o=[];for(let a of t.matchAll(/^[ \t]*import\s+(?:static\s+)?(.+?)\s*;?$/gm)){let r=a[1]?.trim(),l=a[0];if(!r||!l||typeof a.index!="number")continue;let c=z(t,a.index,a.index+l.length);o.push(...zc(e,n,r,c))}return o}function Jc(e,n,t){let s=J(t,new Set(["import_declaration"])),i=[];for(let o of t.rootNode.descendantsOfType("import_declaration")){let a=o.children.some(u=>u.type==="asterisk"),l=o.namedChildren.find(u=>u.type==="scoped_identifier")??o.namedChildren.find(u=>u.type==="identifier");if(!l)continue;let c=l.text;if(a){i.push({importedName:"*",localName:null,sourcePath:H(e,c,me),kind:"namespace",used:!0,usedMembers:[]});continue}let m=c.split(".").pop()??c;i.push({importedName:m,localName:m,sourcePath:H(e,c,me),kind:"named",used:s.has(m),usedMembers:[]})}return i}function Uc(e,n,t){let s=J(t,new Set(["import_header","import_list"])),i=[];for(let o of t.rootNode.descendantsOfType("import_header")){let a=o.namedChildren.find(g=>g.type==="identifier");if(!a)continue;let r=o.namedChildren.some(g=>g.type==="wildcard_import"),l=o.namedChildren.find(g=>g.type==="import_alias");if(r){i.push({importedName:"*",localName:null,sourcePath:H(e,a.text,me),kind:"namespace",used:!0,usedMembers:[]});continue}let c=a.text,m=c.split(".").pop()??c,d=l?.namedChild(0)?.text??m;i.push({importedName:m,localName:d,sourcePath:H(e,c,me),kind:"named",used:s.has(d),usedMembers:[]})}return i}function qc(e,n,t){let s=J(t,new Set(["import_declaration"])),i=[];for(let o of t.rootNode.descendantsOfType("import_declaration")){let a=o.namedChildren.find(u=>u.type==="namespace_selectors"||u.type==="namespace_wildcard"),r=o.namedChildren.filter(u=>u!==a&&(u.type==="identifier"||u.type==="stable_identifier")),l=r.map(u=>u.text).join(".");if(!l)continue;if(a?.type==="namespace_wildcard"){i.push({importedName:"*",localName:null,sourcePath:H(e,l,me),kind:"namespace",used:!0,usedMembers:[]});continue}if(a?.type==="namespace_selectors"){for(let u of a.namedChildren)if(u.type==="arrow_renamed_identifier"){let[d,g]=u.namedChildren;if(!d)continue;let p=d.text,f=g?.text??p;if(p==="_")continue;i.push({importedName:p,localName:f,sourcePath:H(e,`${l}.${p}`,me),kind:"named",used:s.has(f),usedMembers:[]})}else if(u.type==="identifier"){let d=u.text;i.push({importedName:d,localName:d,sourcePath:H(e,`${l}.${d}`,me),kind:"named",used:s.has(d),usedMembers:[]})}continue}let c=r[r.length-1]?.text??l,m=r.slice(0,-1).map(u=>u.text).join(".")||l;i.push({importedName:c,localName:c,sourcePath:H(e,m&&r.length>1?`${m}.${c}`:l,me),kind:"named",used:s.has(c),usedMembers:[]})}return i}function zc(e,n,t,s){if(t.includes("{")&&t.includes("}")){let i=t.slice(0,t.indexOf("{")).replace(/\.$/,"").trim(),o=t.slice(t.indexOf("{")+1,t.lastIndexOf("}")).trim();return oe(o).flatMap(a=>{let r=a.trim();if(!r)return[];let[l,c]=r.includes("=>")?r.split(/\s*=>\s*/):r.split(/\s+as\s+/),m=l?.trim();if(!m||m==="_")return[];let u=(c??m.split(".").pop()??m).trim(),d=m==="_"?i:`${i}.${m}`.replace(/\.\./g,".");return[ge(e,n,s,d,m,u)]})}return[ge(e,n,s,t,t.split(".").pop()??t,t.split(".").pop()??t)]}function Ai(e,n,t){let s=O(e,n);if(s)return Vc(e,n,s);let i=[];for(let o of t.matchAll(/^[ \t]*use\s+(.+?)\s*;$/gm)){let a=o[1]?.trim(),r=o[0];if(!a||!r||typeof o.index!="number")continue;let l=z(t,o.index,o.index+r.length);for(let c of oe(a)){let m=c.trim();if(!m)continue;let[u,d]=m.split(/\s+as\s+/i),g=u?.trim()??m,p=g.split("\\").pop()??g,f=(d??p).trim();i.push(ge(e,n,l,g,p,f,H(e,g.replace(/\\/g,"."),gt)))}}return i}function Vc(e,n,t){let s=J(t,new Set(["namespace_use_declaration"])),i=[],o=(a,r,l)=>{i.push({importedName:r,localName:l,sourcePath:H(e,a.replace(/\\/g,"."),gt),kind:"named",used:s.has(l),usedMembers:[]})};for(let a of t.rootNode.descendantsOfType("namespace_use_declaration")){let r=a.namedChildren.find(l=>l.type==="namespace_use_group");if(r){let l=a.namedChildren.find(c=>c.type==="namespace_name")?.text??"";for(let c of r.namedChildren){if(c.type!=="namespace_use_clause")continue;let{importedName:m,localName:u,qualified:d}=Ti(c,l);m&&o(d,m,u)}continue}for(let l of a.namedChildren){if(l.type!=="namespace_use_clause")continue;let{importedName:c,localName:m,qualified:u}=Ti(l,"");c&&o(u,c,m)}}return i}function Ti(e,n){let t=e.namedChildren.find(c=>c.type==="qualified_name"),s=e.namedChildren.filter(c=>c.type==="name"),i="";t?i=t.text:s.length>=1&&(i=s[0].text);let o=t&&s.length>0?s[s.length-1]:null,a=i.split("\\").pop()??i,r=o?.text??a,l=n?`${n}\\${i}`:i;return{importedName:a,localName:r,qualified:l}}function Wi(e,n,t){let s=O(e,n);return s?Gc(e,n,s):Kc(t).flatMap(i=>Xc(e,n,i,t))}function Gc(e,n,t){let s=J(t,new Set(["import_statement","import_from_statement"])),i=[];for(let o of t.rootNode.descendantsOfType("import_statement"))for(let a of o.namedChildren){let r=ji(a);if(!r)continue;let l=nt(e,n,r.qualifiedName);i.push({importedName:r.qualifiedName,localName:r.localName,sourcePath:l,kind:"namespace",used:s.has(r.localName),usedMembers:[]})}for(let o of t.rootNode.descendantsOfType("import_from_statement")){let a=o.namedChild(0);if(!a)continue;let r=Yc(a);if(r===null)continue;let l=nt(e,n,r);for(let c=1;c<o.namedChildCount;c+=1){let m=o.namedChild(c);if(m.type==="wildcard_import"){i.push({importedName:"*",localName:null,sourcePath:l,kind:"side-effect",used:!0,usedMembers:[]});continue}let u=ji(m);u&&i.push({importedName:u.qualifiedName,localName:u.localName,sourcePath:l,kind:"named",used:s.has(u.localName),usedMembers:[]})}}return i}function ji(e){if(e.type==="aliased_import"){let n=e.namedChild(0),t=e.namedChild(1);return!n||!t?null:{qualifiedName:n.text,localName:t.text}}if(e.type==="dotted_name"){let n=e.text;return{qualifiedName:n,localName:n.split(".")[0]??n}}return e.type==="identifier"?{qualifiedName:e.text,localName:e.text}:null}function Yc(e){if(e.type==="dotted_name")return e.text;if(e.type==="relative_import"){let n=le(e,"import_prefix")?.text??"",t=le(e,"dotted_name")?.text??"";return`${n}${t}`}return null}function Kc(e){let n=e.split(`
317
+ `),t=[],s=0;for(let i=0;i<n.length;i++){let o=n[i],a=o.trimStart(),r=s;if(s+=o.length+1,!a.startsWith("import ")&&!a.startsWith("from "))continue;let l=o,c=r+o.length,m=Bi(o);for(;i+1<n.length&&(m>0||l.trimEnd().endsWith("\\"));){i++;let d=n[i];l+=`
318
+ ${d}`,c+=1+d.length,m+=Bi(d),s+=d.length+1}let u=Qc(l);u&&t.push({...u,start:r,end:c})}return t}function Qc(e){let n=e.replace(/\\\s*\n/g," ").trim();if(n.startsWith("import "))return{kind:"import",module:null,clause:n.slice(7).trim()};let t=n.match(/^from\s+([.\w]+)\s+import\s+([\s\S]+)$/);if(!t)return null;let s=t[2].trim();return s.startsWith("(")&&s.endsWith(")")&&(s=s.slice(1,-1).trim()),{kind:"from",module:t[1],clause:s}}function Xc(e,n,t,s){let i=z(s,t.start,t.end),o=t.clause.replace(/\n/g," ").trim();if(t.kind==="import")return oe(o).flatMap(l=>{let c=l.trim().replace(/,$/,"");if(!c)return[];let[m,u]=c.split(/\s+as\s+/),d=m.trim(),g=(u??d.split(".")[0]??d).trim(),p=nt(e,n,d),f=Ze(i,g);return[{importedName:d,localName:g,sourcePath:p,kind:"namespace",used:te(i,g)||f.length>0,usedMembers:f}]});let a=t.module?nt(e,n,t.module):null,r=[];for(let l of oe(o)){let c=l.trim().replace(/,$/,"");if(!c)continue;if(c==="*"){r.push({importedName:"*",localName:null,sourcePath:a,kind:"side-effect",used:!0,usedMembers:[]});continue}let[m,u]=c.split(/\s+as\s+/),d=(u??m).trim();r.push({importedName:m.trim(),localName:d,sourcePath:a,kind:"named",used:te(i,d),usedMembers:[]})}return r}function Bi(e){let n=0;for(let t of e)t==="("&&n++,t===")"&&n--;return n}import{basename as Zc}from"path";function Hi(e,n,t){let s=O(e,n);if(s)return eu(e,n,s);let i=[];for(let o of t.matchAll(/^[ \t]*(require_relative|require)\s+["']([^"']+)["']\s*$/gm)){let a=o[1],r=o[2],l=o[0];if(!a||!r||!l||typeof o.index!="number")continue;let c=z(t,o.index,o.index+l.length),m=a==="require_relative"?Kt(e,n,r):null;if(m){let u=Ji(r);i.push({importedName:u,localName:u,sourcePath:m,kind:"named",used:te(c,u),usedMembers:[]});continue}i.push({importedName:r,localName:null,sourcePath:m,kind:"side-effect",used:!0,usedMembers:[]})}return i}function eu(e,n,t){let s=J(t,new Set([])),i=[],o=new Set(["require","require_relative","load"]);for(let a of t.rootNode.descendantsOfType("call")){let r=a.namedChild(0);if(!r||r.type!=="identifier"||!o.has(r.text))continue;let c=a.namedChildren.find(g=>g.type==="argument_list")?.namedChild(0);if(!c||c.type!=="string")continue;let u=c.namedChildren.find(g=>g.type==="string_content")?.text;if(!u)continue;let d=r.text==="require_relative"?Kt(e,n,u):null;if(d){let g=Ji(u);i.push({importedName:g,localName:g,sourcePath:d,kind:"named",used:s.has(g),usedMembers:[]})}else i.push({importedName:u,localName:null,sourcePath:d,kind:"side-effect",used:!0,usedMembers:[]})}return i}function Ji(e){return Zc(e).replace(/\.[^.]+$/,"").split("_").filter(Boolean).map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join("")}function Ui(e,n,t){let s=O(e,n);if(s)return tu(e,n,s);let i=[];for(let o of t.matchAll(/^[ \t]*use\s+(.+?)\s*;$/gm)){let a=o[1]?.trim(),r=o[0];if(!a||!r||typeof o.index!="number")continue;let l=z(t,o.index,o.index+r.length);i.push(...nu(e,n,a,l))}return i}function tu(e,n,t){let s=J(t,new Set(["use_declaration"])),i=[];for(let o of t.rootNode.descendantsOfType("use_declaration")){let a=o.namedChild(0);if(a)for(let r of ht(a,"")){if(!r.importedName||r.importedName==="*")continue;let l=Ne(e,n,r.qualifiedName)??Ne(e,n,r.qualifiedName.split("::").slice(0,-1).join("::"));i.push({importedName:r.importedName,localName:r.localName,sourcePath:l,kind:"named",used:s.has(r.localName),usedMembers:[]})}}return i}function ht(e,n){switch(e.type){case"identifier":case"super":case"self":case"crate":{let t=e.text;return[{qualifiedName:Zt(n,t),importedName:t,localName:t}]}case"scoped_identifier":{let t=e.text,s=t.split("::").pop()??t;return[{qualifiedName:Zt(n,t),importedName:s,localName:s}]}case"scoped_use_list":{let t=e.namedChild(0),s=e.namedChild(1);if(!t||!s)return[];let i=Zt(n,t.text),o=[];for(let a of s.namedChildren)o.push(...ht(a,i));return o}case"use_list":{let t=[];for(let s of e.namedChildren)t.push(...ht(s,n));return t}case"use_as_clause":{let t=e.namedChild(0),s=e.namedChild(1);if(!t||!s)return[];let i=ht(t,n),o=s.text;return i.map(a=>({...a,localName:o}))}case"use_wildcard":{let t=e.namedChild(0),s=t?t.text:"";return[{qualifiedName:Zt(n,`${s}::*`),importedName:"*",localName:"*"}]}default:return[]}}function Zt(e,n){return e?n?`${e}::${n}`:e:n}function nu(e,n,t,s){let i=t.trim();if(i.includes("{")&&i.includes("}")){let m=i.slice(0,i.indexOf("{")).replace(/::$/,"").trim(),u=i.slice(i.indexOf("{")+1,i.lastIndexOf("}")).trim();return oe(u).flatMap(d=>{let g=d.trim();if(!g||g==="self")return[];let[p,f]=g.split(/\s+as\s+/),y=p?.trim();if(!y)return[];let h=(f??y.split("::").pop()??y).trim(),b=`${m}::${y}`.replace(/::::/g,"::");return[ge(e,n,s,b,y.split("::").pop()??y,h,Ne(e,n,m))]})}let[o,a]=i.split(/\s+as\s+/),r=o?.trim()??i,l=(a??r.split("::").pop()??r).trim(),c=Ne(e,n,r)??Ne(e,n,r.split("::").slice(0,-1).join("::"));return[ge(e,n,s,r,r.split("::").pop()??r,l,c)]}function qi(e,n,t){let s=O(e,n);if(s)return su(e,n,s);let i=[];for(let o of t.matchAll(/^[ \t]*pub\s+use\s+(.+?)\s*;$/gm)){let a=o[1]?.trim();a&&i.push(...ou(e,n,a))}return i}function su(e,n,t){let s=[];for(let i of t.rootNode.descendantsOfType("use_declaration")){if(!iu(i))continue;let o=i.namedChildren.find(a=>a.type!=="visibility_modifier");if(o)for(let a of ht(o,""))a.importedName&&s.push(Wn(e,n,a.qualifiedName))}return s}function iu(e){for(let n of e.children)if(n.type==="visibility_modifier"&&n.text.startsWith("pub"))return!0;return!1}function ou(e,n,t){let s=t.trim();if(s.includes("{")&&s.includes("}")){let i=s.slice(0,s.indexOf("{")).replace(/::$/,"").trim(),o=s.slice(s.indexOf("{")+1,s.lastIndexOf("}")).trim();return oe(o).flatMap(a=>{let r=a.trim();if(!r||r==="self")return[];let[l]=r.split(/\s+as\s+/),c=`${i}::${l?.trim()??r}`.replace(/::::/g,"::");return[Wn(e,n,c)]})}return[Wn(e,n,s)]}function Wn(e,n,t){return{specifier:t,sourcePath:Ne(e,n,t)??Ne(e,n,t.split("::").slice(0,-1).join("::"))}}function zi(e,n){let t=n.toLowerCase();for(let s of e)for(let i of s.extensions)if(t.endsWith(i))return s;return null}var ru={language:"javascript",extensions:[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs",".vue"],parseImports:wi},au={language:"python",extensions:[".py",".pyi"],parseImports:Wi},lu={language:"jvm",extensions:[".java",".scala",".kt",".kts"],parseImports:Fi},cu={language:"rust",extensions:[".rs"],parseImports:Ui,parseExports:qi},uu={language:"ruby",extensions:[".rb"],parseImports:Hi},mu={language:"c/cpp",extensions:[".c",".h",".cc",".cpp",".cxx",".hpp",".hh",".hxx"],parseImports:Oi},du={language:"dotnet",extensions:[".cs",".vb"],parseImports:Mi},pu={language:"dart",extensions:[".dart"],parseImports:$i,parseExports:Pi},fu={language:"php",extensions:[".php"],parseImports:Ai},gu=[ru,au,lu,cu,uu,mu,du,pu,fu];function Hn(e){return zi(gu,e)}function Ki(e,n){return Di(e,n)}var hu=W("source-imports"),yu=W("source-exports");function de(e,n){let t=ae(n);return hu.get(e,t,()=>{let s=Hn(t);if(!s)return[];let i=Yi(e.config.projectRoot,t);if(!Vi(i))return[];let o=Gi(i,"utf-8");return s.parseImports(e,t,o)})}function Jn(e,n){let t=ae(n);return yu.get(e,t,()=>{let s=Hn(t);if(!s?.parseExports)return[];let i=Yi(e.config.projectRoot,t);if(!Vi(i))return[];let o=Gi(i,"utf-8");return s.parseExports(e,t,o)})}var bu=W("file-dep-graph");function K(e,n){return bu.get(e,n??"",()=>{let t=n?`AND d1.relative_path LIKE '%${n}%'`:"",s=e.all(`SELECT DISTINCT
319
319
  d1.relative_path AS from_file,
320
320
  d2.relative_path AS to_file
321
321
  FROM mentions m
@@ -337,14 +337,14 @@ ${d}`,c+=1+d.length,m+=ji(d),s+=d.length+1}let u=Kc(l);u&&t.push({...u,start:r,e
337
337
  FROM documents
338
338
  WHERE 1 = 1
339
339
  ${e.pathExclusionsFor("documents")}
340
- ORDER BY relative_path`).map(r=>r.relative_path).filter(r=>!e.isIgnored(r))),a=(r,l)=>{r!==l&&(e.isIgnored(r)||e.isIgnored(l)||o.has(l)&&(i.has(r)||i.set(r,new Set),i.get(r).add(l)))};for(let r of s)a(r.from_file,r.to_file);for(let r of o)if(!(n&&!r.includes(n)))for(let l of de(e,r))l.sourcePath&&a(r,l.sourcePath);return i})}function ne(e,n,t={}){let i=se(e,[n]).get(n.symbolId)??[];return typeof t.limit=="number"?i.slice(0,t.limit):i}function he(e,n,t={}){let i=Su(e).get(n.symbolId)??[];return typeof t.limit=="number"?i.slice(0,t.limit):i}var bu=je("caller-rows");function Su(e){return bu.get(e,()=>{let n=Z(e),t=se(e,n),s=new Map;for(let a of n)s.set(a.symbol,a.symbolId);let i=new Map,o=new Map;for(let a of n){let r=t.get(a.symbolId);if(!(!r||r.length===0))for(let l of r){let c=s.get(l.symbol);if(c===void 0||c===a.symbolId)continue;let m=i.get(c);m||(m=[],i.set(c,m),o.set(c,new Set));let u=`${a.symbol}|${a.relativePath}`;o.get(c).has(u)||(o.get(c).add(u),m.push({symbol:a.symbol,file:a.relativePath}))}}return i})}function $e(e,n){let t=xu(e,n);return t?Iu(e,_u(e,t.match,t.identifier)):[]}function _u(e,n,t){let s=e.all(`SELECT DISTINCT d.relative_path, c.start_line, c.end_line
340
+ ORDER BY relative_path`).map(r=>r.relative_path).filter(r=>!e.isIgnored(r))),a=(r,l)=>{r!==l&&(e.isIgnored(r)||e.isIgnored(l)||o.has(l)&&(i.has(r)||i.set(r,new Set),i.get(r).add(l)))};for(let r of s)a(r.from_file,r.to_file);for(let r of o)if(!(n&&!r.includes(n)))for(let l of de(e,r))l.sourcePath&&a(r,l.sourcePath);return i})}function ne(e,n,t={}){let i=se(e,[n]).get(n.symbolId)??[];return typeof t.limit=="number"?i.slice(0,t.limit):i}function he(e,n,t={}){let i=_u(e).get(n.symbolId)??[];return typeof t.limit=="number"?i.slice(0,t.limit):i}var Su=je("caller-rows");function _u(e){return Su.get(e,()=>{let n=Z(e),t=se(e,n),s=new Map;for(let a of n)s.set(a.symbol,a.symbolId);let i=new Map,o=new Map;for(let a of n){let r=t.get(a.symbolId);if(!(!r||r.length===0))for(let l of r){let c=s.get(l.symbol);if(c===void 0||c===a.symbolId)continue;let m=i.get(c);m||(m=[],i.set(c,m),o.set(c,new Set));let u=`${a.symbol}|${a.relativePath}`;o.get(c).has(u)||(o.get(c).add(u),m.push({symbol:a.symbol,file:a.relativePath}))}}return i})}function $e(e,n){let t=Iu(e,n);return t?Nu(e,xu(e,t.match,t.identifier)):[]}function xu(e,n,t){let s=e.all(`SELECT DISTINCT d.relative_path, c.start_line, c.end_line
341
341
  FROM mentions m
342
342
  JOIN chunks c ON m.chunk_id = c.id
343
343
  JOIN documents d ON c.document_id = d.id
344
344
  WHERE m.symbol_id = ?
345
345
  AND m.role != 1
346
346
  ${e.pathExclusionsFor("d")}
347
- ORDER BY d.relative_path, c.start_line`,n.symbolId),i=new Map;for(let a of s){if(e.isIgnored(a.relative_path))continue;let r=i.get(a.relative_path);r||(r=[],i.set(a.relative_path,r)),r.push({start_line:a.start_line,end_line:a.end_line})}let o=new Map;for(let[a,r]of i){let l=a===n.relativePath?{excludeStartLine:n.startLine,excludeEndLine:n.endLine}:{},c=t?Gt(e,a,t,l):[],m=[];for(let u of r){let d=c.filter(p=>p>=u.start_line&&p<=u.end_line),g=d.length>0?d:[u.start_line];for(let p of g)m.push(p)}o.set(a,m)}return o}function xu(e,n){let t=qt(e,n);return t?{match:t,identifier:F(t.symbol)||null}:null}function Iu(e,n){let t=[],s=new Set;for(let[i,o]of n){let a=A(e,i);for(let r of o){let l=fe(a,r),c=`${i}|${r}|${l?.symbol??""}`;s.has(c)||(s.add(c),t.push({file:i,line:r,enclosingSymbol:l?.symbol??null}))}}return t}function se(e,n,t={}){if(n.length===0)return new Map;let s=t.additive??!1,i=[],o=[];for(let c of n)P(c.relativePath)&&Ht(e,c.relativePath)!==null?i.push(c):o.push(c);let a=new Map,r=c=>{for(let[m,u]of c){let d=a.get(m);d||(d=[],a.set(m,d));let g=new Set(d.map(p=>`${p.symbol}|${p.chunkId}`));for(let p of u){let f=`${p.symbol}|${p.chunkId}`;g.has(f)||(g.add(f),d.push(p))}}};i.length>0&&r(Nu(e,i));let l=s?n:o;return l.length>0&&r(Cu(e,l)),a}function Nu(e,n){let t=new Map,s=new Map;for(let o of n){let a=s.get(o.relativePath);a?a.push(o):s.set(o.relativePath,[o]),t.set(o.symbolId,[])}let i=yt(e);for(let[o,a]of s){let r=Ht(e,o);if(!r)continue;let l=[...a].sort((c,m)=>{let u=c.endLine-c.startLine,d=m.endLine-m.startLine;return u-d});for(let c of r){let m=null;for(let f of l)if(c.line>=f.startLine&&c.line<=f.endLine){m=f;break}if(!m)continue;let u=i.get(c.calleeLeaf);if(!u||u.length===0)continue;let d=null,g=u.find(f=>f.file===o);if(g?d=g:u.length===1&&(d=u[0]),!d||d.symbol===m.symbol)continue;t.get(m.symbolId).push({symbol:d.symbol,file:d.file,chunkId:c.line})}}return t}var vu=je("global-leaf-index");function yt(e){return vu.get(e,()=>{let n=e.all(`SELECT gs.id, gs.symbol,
347
+ ORDER BY d.relative_path, c.start_line`,n.symbolId),i=new Map;for(let a of s){if(e.isIgnored(a.relative_path))continue;let r=i.get(a.relative_path);r||(r=[],i.set(a.relative_path,r)),r.push({start_line:a.start_line,end_line:a.end_line})}let o=new Map;for(let[a,r]of i){let l=a===n.relativePath?{excludeStartLine:n.startLine,excludeEndLine:n.endLine}:{},c=t?Gt(e,a,t,l):[],m=[];for(let u of r){let d=c.filter(p=>p>=u.start_line&&p<=u.end_line),g=d.length>0?d:[u.start_line];for(let p of g)m.push(p)}o.set(a,m)}return o}function Iu(e,n){let t=qt(e,n);return t?{match:t,identifier:F(t.symbol)||null}:null}function Nu(e,n){let t=[],s=new Set;for(let[i,o]of n){let a=A(e,i);for(let r of o){let l=fe(a,r),c=`${i}|${r}|${l?.symbol??""}`;s.has(c)||(s.add(c),t.push({file:i,line:r,enclosingSymbol:l?.symbol??null}))}}return t}function se(e,n,t={}){if(n.length===0)return new Map;let s=t.additive??!1,i=[],o=[];for(let c of n)P(c.relativePath)&&Ht(e,c.relativePath)!==null?i.push(c):o.push(c);let a=new Map,r=c=>{for(let[m,u]of c){let d=a.get(m);d||(d=[],a.set(m,d));let g=new Set(d.map(p=>`${p.symbol}|${p.chunkId}`));for(let p of u){let f=`${p.symbol}|${p.chunkId}`;g.has(f)||(g.add(f),d.push(p))}}};i.length>0&&r(vu(e,i));let l=s?n:o;return l.length>0&&r(Eu(e,l)),a}function vu(e,n){let t=new Map,s=new Map;for(let o of n){let a=s.get(o.relativePath);a?a.push(o):s.set(o.relativePath,[o]),t.set(o.symbolId,[])}let i=yt(e);for(let[o,a]of s){let r=Ht(e,o);if(!r)continue;let l=[...a].sort((c,m)=>{let u=c.endLine-c.startLine,d=m.endLine-m.startLine;return u-d});for(let c of r){let m=null;for(let f of l)if(c.line>=f.startLine&&c.line<=f.endLine){m=f;break}if(!m)continue;let u=i.get(c.calleeLeaf);if(!u||u.length===0)continue;let d=null,g=u.find(f=>f.file===o);if(g?d=g:u.length===1&&(d=u[0]),!d||d.symbol===m.symbol)continue;t.get(m.symbolId).push({symbol:d.symbol,file:d.file,chunkId:c.line})}}return t}var Cu=je("global-leaf-index");function yt(e){return Cu.get(e,()=>{let n=e.all(`SELECT gs.id, gs.symbol,
348
348
  COALESCE(der_doc.relative_path, mention_doc.relative_path) AS relative_path
349
349
  FROM global_symbols gs
350
350
  LEFT JOIN defn_enclosing_ranges der ON der.symbol_id = gs.id
@@ -358,7 +358,7 @@ ${d}`,c+=1+d.length,m+=ji(d),s+=d.length+1}let u=Kc(l);u&&t.push({...u,start:r,e
358
358
  GROUP BY m.symbol_id
359
359
  ) mention_doc ON mention_doc.symbol_id = gs.id
360
360
  WHERE 1 = 1
361
- ${e.symbolNoiseFor("gs")}`),t=new Map;for(let s of n){if(!s.relative_path||e.isIgnored(s.relative_path))continue;let i=F(s.symbol);if(!i)continue;let o=t.get(i);o||(o=[],t.set(i,o)),o.some(a=>a.symbolId===s.id)||o.push({symbol:s.symbol,symbolId:s.id,file:s.relative_path})}return t})}function Cu(e,n){if(n.length===0)return new Map;let t=e.all(`SELECT c.document_id, c.id AS chunk_id, c.start_line, c.end_line, m.symbol_id
361
+ ${e.symbolNoiseFor("gs")}`),t=new Map;for(let s of n){if(!s.relative_path||e.isIgnored(s.relative_path))continue;let i=F(s.symbol);if(!i)continue;let o=t.get(i);o||(o=[],t.set(i,o)),o.some(a=>a.symbolId===s.id)||o.push({symbol:s.symbol,symbolId:s.id,file:s.relative_path})}return t})}function Eu(e,n){if(n.length===0)return new Map;let t=e.all(`SELECT c.document_id, c.id AS chunk_id, c.start_line, c.end_line, m.symbol_id
362
362
  FROM mentions m
363
363
  JOIN chunks c ON m.chunk_id = c.id
364
364
  WHERE m.role != 1`),s=new Map;for(let c of t)s.has(c.document_id)||s.set(c.document_id,[]),s.get(c.document_id).push(c);let i=new Map(e.all("SELECT id, relative_path FROM documents").map(c=>[c.id,c.relative_path])),o=new Map,a=e.all(`SELECT gs.id AS symbol_id, gs.symbol,
@@ -371,21 +371,21 @@ ${d}`,c+=1+d.length,m+=ji(d),s+=d.length+1}let u=Kc(l);u&&t.push({...u,start:r,e
371
371
  JOIN chunks c ON m.chunk_id = c.id
372
372
  WHERE m.role = 1
373
373
  GROUP BY m.symbol_id
374
- ) def_chunk ON def_chunk.symbol_id = gs.id`);for(let c of a)o.has(c.symbol_id)||o.set(c.symbol_id,{symbol:c.symbol,file:c.document_id!==null?i.get(c.document_id)??"":""});let r=new Map,l=i;for(let c of n){let m=s.get(c.documentId)??[],u=new Set,d=[],g=null,p=()=>{if(g)return g;let f=l.get(c.documentId)??"",y=new Set;if(f){let h=vi(e,f),b=Math.max(0,c.startLine),_=Math.min(h.length-1,c.endLine);for(let S=b;S<=_;S+=1)for(let x of h[S])y.add(x)}return g=y,y};for(let f of m){if(f.symbol_id===c.symbolId)continue;let y=o.get(f.symbol_id);if(!y)continue;if(!(f.start_line>=c.startLine&&f.end_line<=c.endLine)){if(!(f.start_line<=c.endLine&&f.end_line>=c.startLine))continue;let S=F(y.symbol);if(!S||!p().has(S))continue}let b=`${y.symbol}|${f.chunk_id}`;u.has(b)||(u.add(b),d.push({...y,chunkId:f.chunk_id}))}r.set(c.symbolId,d)}return r}function ye(e,n){let t=new Map,s=e.all(`SELECT relative_path FROM documents
374
+ ) def_chunk ON def_chunk.symbol_id = gs.id`);for(let c of a)o.has(c.symbol_id)||o.set(c.symbol_id,{symbol:c.symbol,file:c.document_id!==null?i.get(c.document_id)??"":""});let r=new Map,l=i;for(let c of n){let m=s.get(c.documentId)??[],u=new Set,d=[],g=null,p=()=>{if(g)return g;let f=l.get(c.documentId)??"",y=new Set;if(f){let h=Ci(e,f),b=Math.max(0,c.startLine),_=Math.min(h.length-1,c.endLine);for(let S=b;S<=_;S+=1)for(let x of h[S])y.add(x)}return g=y,y};for(let f of m){if(f.symbol_id===c.symbolId)continue;let y=o.get(f.symbol_id);if(!y)continue;if(!(f.start_line>=c.startLine&&f.end_line<=c.endLine)){if(!(f.start_line<=c.endLine&&f.end_line>=c.startLine))continue;let S=F(y.symbol);if(!S||!p().has(S))continue}let b=`${y.symbol}|${f.chunk_id}`;u.has(b)||(u.add(b),d.push({...y,chunkId:f.chunk_id}))}r.set(c.symbolId,d)}return r}function ye(e,n){let t=new Map,s=e.all(`SELECT relative_path FROM documents
375
375
  WHERE 1 = 1 ${e.pathExclusionsFor("documents")}`),i=yt(e);for(let r of s){if(!P(r.relative_path)||e.isIgnored(r.relative_path))continue;let l=Ht(e,r.relative_path);if(l)for(let c of l){let m=i.get(c.calleeLeaf);if(!m||m.length===0)continue;let d=m.find(p=>p.file===r.relative_path)??(m.length===1?m[0]:null);if(!d||d.file===r.relative_path)continue;let g=t.get(d.symbolId);g||(g=new Set,t.set(d.symbolId,g)),g.add(r.relative_path)}}let o=e.all(`SELECT DISTINCT m.symbol_id, d.relative_path, c.document_id,
376
376
  c.start_line AS chunk_start, c.end_line AS chunk_end
377
377
  FROM mentions m
378
378
  JOIN chunks c ON m.chunk_id = c.id
379
379
  JOIN documents d ON c.document_id = d.id
380
380
  WHERE m.role != 1
381
- ${e.pathExclusionsFor("d")}`),a=new Map;if(n)for(let r of n)a.set(r.symbolId,{docId:r.documentId,startLine:r.startLine,endLine:r.endLine});for(let r of o){if(e.isIgnored(r.relative_path))continue;let l=a.get(r.symbol_id);if(l&&l.docId===r.document_id&&r.chunk_start>=l.startLine&&r.chunk_end<=l.endLine)continue;let c=t.get(r.symbol_id);c||(c=new Set,t.set(r.symbol_id,c)),c.add(r.relative_path)}for(let r of s){if(e.isIgnored(r.relative_path)||P(r.relative_path)!=="rust")continue;let l=we(e,r.relative_path);if(l.size!==0)for(let c of l){let m=i.get(c);if(m)for(let u of m){if(u.file===r.relative_path)continue;let d=t.get(u.symbolId);d||(d=new Set,t.set(u.symbolId,d)),d.add(r.relative_path)}}}return t}function it(e,n,t){let s=yt(e).get(t);if(!s||s.length===0)return[];if(s.length===1)return[bt(s[0])];let i=s.filter(l=>l.file===n);if(i.length>0)return i.map(bt);let o=Eu(e,n),a=o.get(t);if(a)for(let l of a){let c=s.filter(m=>Ki(l,m.file));if(c.length>0)return c.map(bt)}let r=new Set;for(let l of o.values())for(let c of l)r.add(c);for(let l of r){let c=s.filter(m=>Ki(l,m.file));if(c.length>0&&c.length===s.length)return c.map(bt)}return[]}function St(e,n,t){let s=it(e,n,t);if(s.length>0)return s;let i=yt(e).get(t);return!i||i.length===0?[]:i.map(bt)}function Pe(e,n){let t=qt(e,n);if(!t)return[];let s=F(t.symbol);if(!s)return[];let i=new Map;for(let o of Re(e)){let a=M(e,o);if(!a||a.indexOf(s)===-1||o!==t.relativePath&&!it(e,o,s).some(c=>c.symbolId===t.symbolId))continue;let r=Gt(e,o,s,o===t.relativePath?{excludeStartLine:t.startLine,excludeEndLine:t.endLine}:{});r.length>0&&i.set(o,r)}return Ru(e,i)}function ot(e,n){let t=new Map;for(let o of n){if(!o.leaf)continue;let a=t.get(o.leaf)??[];a.push(o),t.set(o.leaf,a)}if(t.size===0)return new Map;let s=new Set(n.map(o=>o.symbolId)),i=new Map;for(let o of Re(e)){let a=Ni(e,o);if(a.size!==0){for(let r of a)if(t.has(r))for(let l of it(e,o,r)){if(!s.has(l.symbolId)||o===l.relativePath)continue;let c=i.get(l.symbolId);c||(c=new Set,i.set(l.symbolId,c)),c.add(o)}}}return i}function Eu(e,n){let t=new Map;for(let s of de(e,n)){if(!s.sourcePath)continue;let i=s.localName??s.importedName;if(i){let o=t.get(i);o||(o=new Set,t.set(i,o)),o.add(s.sourcePath)}if(s.kind==="namespace")for(let o of s.usedMembers){let a=t.get(o);a||(a=new Set,t.set(o,a)),a.add(s.sourcePath)}}return t}function Ki(e,n){let t=s=>s.replace(/\\/g,"/").replace(/^\.\//,"");return t(e)===t(n)}function bt(e){return{symbolId:e.symbolId,symbol:e.symbol,relativePath:e.file}}function Ru(e,n){let t=[],s=new Set;for(let[i,o]of n){let a=A(e,i);for(let r of o){let l=fe(a,r),c=`${i}|${r}|${l?.symbol??""}`;s.has(c)||(s.add(c),t.push({file:i,line:r,enclosingSymbol:l?.symbol??null}))}}return t}function Qi(e,n){let t=k(e,n);if(!t)return[];let i=!j(t.symbol)&&!e.isIgnored(t.relativePath)?[{relativePath:t.relativePath,line:t.startLine}]:[],o=Pe(e,t),a=(o.length>0?o:$e(e,t)).filter(m=>!e.isIgnored(m.file)).map(m=>({relativePath:m.file,line:m.line})),r=Lu(e,t),l=new Set,c=[];for(let m of[...i,...a,...r]){let u=`${m.relativePath}:${m.line}`;l.has(u)||(l.add(u),c.push(m))}return c}function Lu(e,n){if(!n.relativePath.endsWith(".rb"))return[];let t=wu(n.symbol);if(t.length===0)return[];let s=e.all(`SELECT relative_path
381
+ ${e.pathExclusionsFor("d")}`),a=new Map;if(n)for(let r of n)a.set(r.symbolId,{docId:r.documentId,startLine:r.startLine,endLine:r.endLine});for(let r of o){if(e.isIgnored(r.relative_path))continue;let l=a.get(r.symbol_id);if(l&&l.docId===r.document_id&&r.chunk_start>=l.startLine&&r.chunk_end<=l.endLine)continue;let c=t.get(r.symbol_id);c||(c=new Set,t.set(r.symbol_id,c)),c.add(r.relative_path)}for(let r of s){if(e.isIgnored(r.relative_path)||P(r.relative_path)!=="rust")continue;let l=we(e,r.relative_path);if(l.size!==0)for(let c of l){let m=i.get(c);if(m)for(let u of m){if(u.file===r.relative_path)continue;let d=t.get(u.symbolId);d||(d=new Set,t.set(u.symbolId,d)),d.add(r.relative_path)}}}return t}function it(e,n,t){let s=yt(e).get(t);if(!s||s.length===0)return[];if(s.length===1)return[bt(s[0])];let i=s.filter(l=>l.file===n);if(i.length>0)return i.map(bt);let o=Ru(e,n),a=o.get(t);if(a)for(let l of a){let c=s.filter(m=>Qi(l,m.file));if(c.length>0)return c.map(bt)}let r=new Set;for(let l of o.values())for(let c of l)r.add(c);for(let l of r){let c=s.filter(m=>Qi(l,m.file));if(c.length>0&&c.length===s.length)return c.map(bt)}return[]}function St(e,n,t){let s=it(e,n,t);if(s.length>0)return s;let i=yt(e).get(t);return!i||i.length===0?[]:i.map(bt)}function Pe(e,n){let t=qt(e,n);if(!t)return[];let s=F(t.symbol);if(!s)return[];let i=new Map;for(let o of Re(e)){let a=M(e,o);if(!a||a.indexOf(s)===-1||o!==t.relativePath&&!it(e,o,s).some(c=>c.symbolId===t.symbolId))continue;let r=Gt(e,o,s,o===t.relativePath?{excludeStartLine:t.startLine,excludeEndLine:t.endLine}:{});r.length>0&&i.set(o,r)}return Lu(e,i)}function ot(e,n){let t=new Map;for(let o of n){if(!o.leaf)continue;let a=t.get(o.leaf)??[];a.push(o),t.set(o.leaf,a)}if(t.size===0)return new Map;let s=new Set(n.map(o=>o.symbolId)),i=new Map;for(let o of Re(e)){let a=vi(e,o);if(a.size!==0){for(let r of a)if(t.has(r))for(let l of it(e,o,r)){if(!s.has(l.symbolId)||o===l.relativePath)continue;let c=i.get(l.symbolId);c||(c=new Set,i.set(l.symbolId,c)),c.add(o)}}}return i}function Ru(e,n){let t=new Map;for(let s of de(e,n)){if(!s.sourcePath)continue;let i=s.localName??s.importedName;if(i){let o=t.get(i);o||(o=new Set,t.set(i,o)),o.add(s.sourcePath)}if(s.kind==="namespace")for(let o of s.usedMembers){let a=t.get(o);a||(a=new Set,t.set(o,a)),a.add(s.sourcePath)}}return t}function Qi(e,n){let t=s=>s.replace(/\\/g,"/").replace(/^\.\//,"");return t(e)===t(n)}function bt(e){return{symbolId:e.symbolId,symbol:e.symbol,relativePath:e.file}}function Lu(e,n){let t=[],s=new Set;for(let[i,o]of n){let a=A(e,i);for(let r of o){let l=fe(a,r),c=`${i}|${r}|${l?.symbol??""}`;s.has(c)||(s.add(c),t.push({file:i,line:r,enclosingSymbol:l?.symbol??null}))}}return t}function Xi(e,n){let t=k(e,n);if(!t)return[];let i=!j(t.symbol)&&!e.isIgnored(t.relativePath)?[{relativePath:t.relativePath,line:t.startLine}]:[],o=Pe(e,t),a=(o.length>0?o:$e(e,t)).filter(m=>!e.isIgnored(m.file)).map(m=>({relativePath:m.file,line:m.line})),r=wu(e,t),l=new Set,c=[];for(let m of[...i,...a,...r]){let u=`${m.relativePath}:${m.line}`;l.has(u)||(l.add(u),c.push(m))}return c}function wu(e,n){if(!n.relativePath.endsWith(".rb"))return[];let t=Du(n.symbol);if(t.length===0)return[];let s=e.all(`SELECT relative_path
382
382
  FROM documents
383
383
  WHERE relative_path LIKE '%.rb'
384
384
  ${e.pathExclusionsFor("documents")}
385
385
  ORDER BY relative_path`),i=[];for(let o of s){if(e.isIgnored(o.relative_path))continue;let a=M(e,o.relative_path);if(!a)continue;let r=a.split(`
386
- `);for(let l=0;l<r.length;l++){let c=r[l]??"";t.some(m=>new RegExp(`@${m}\\b|\\b${m}:`).test(c))&&i.push({relativePath:o.relative_path,line:l})}}return i}function wu(e){let t=(e.split(":").pop()??e).replace(/([a-z0-9])([A-Z])/g,"$1_$2").replace(/[^A-Za-z0-9_]+/g,"_").toLowerCase().replace(/^_+|_+$/g,""),s=t.split("_").filter(Boolean),i=new Set;return t&&i.add(t),s.length>=1&&i.add(s[s.length-1]),s.length>=2&&i.add(s.slice(-2).join("_")),[...i]}function Xi(e,n){let t=k(e,n);if(!t)return{definitions:[],referencedBy:[]};let s=e.get("SELECT display_name, documentation FROM global_symbols WHERE id = ?",t.symbolId),i=pt(s?.documentation??null),o=e.isIgnored(t.relativePath)?[]:[{relativePath:t.relativePath,startLine:t.startLine,endLine:t.endLine,signature:ku(i,s?.display_name??null,t.symbol),source:Du(e,t.relativePath,t.startLine,t.endLine)}],a=Pe(e,t),l=(a.length>0?a:$e(e,t)).filter(c=>!e.isIgnored(c.file)).map(c=>({relativePath:c.file,line:c.line,enclosingSymbol:c.enclosingSymbol,enclosingShort:c.enclosingSymbol?I(c.enclosingSymbol):"(top-level)"}));return{definitions:o,referencedBy:l}}function Du(e,n,t,s){let i=M(e,n);if(!i)return null;let a=i.split(`
386
+ `);for(let l=0;l<r.length;l++){let c=r[l]??"";t.some(m=>new RegExp(`@${m}\\b|\\b${m}:`).test(c))&&i.push({relativePath:o.relative_path,line:l})}}return i}function Du(e){let t=(e.split(":").pop()??e).replace(/([a-z0-9])([A-Z])/g,"$1_$2").replace(/[^A-Za-z0-9_]+/g,"_").toLowerCase().replace(/^_+|_+$/g,""),s=t.split("_").filter(Boolean),i=new Set;return t&&i.add(t),s.length>=1&&i.add(s[s.length-1]),s.length>=2&&i.add(s.slice(-2).join("_")),[...i]}function Zi(e,n){let t=k(e,n);if(!t)return{definitions:[],referencedBy:[]};let s=e.get("SELECT display_name, documentation FROM global_symbols WHERE id = ?",t.symbolId),i=pt(s?.documentation??null),o=e.isIgnored(t.relativePath)?[]:[{relativePath:t.relativePath,startLine:t.startLine,endLine:t.endLine,signature:Ou(i,s?.display_name??null,t.symbol),source:ku(e,t.relativePath,t.startLine,t.endLine)}],a=Pe(e,t),l=(a.length>0?a:$e(e,t)).filter(c=>!e.isIgnored(c.file)).map(c=>({relativePath:c.file,line:c.line,enclosingSymbol:c.enclosingSymbol,enclosingShort:c.enclosingSymbol?I(c.enclosingSymbol):"(top-level)"}));return{definitions:o,referencedBy:l}}function ku(e,n,t,s){let i=M(e,n);if(!i)return null;let a=i.split(`
387
387
  `).slice(t,s+1).join(`
388
- `).trimEnd();return a.length>0?a:null}function ku(e,n,t){let s=dt(e);if(s&&!Ou(s))return s;let i=(n??"").trim();return i?j(t)&&!i.endsWith("()")?`${i}()`:i:I(t)}function Ou(e){return e.startsWith("undefined")||e.includes("|")||e.includes("```")}function Zi(e,n){let t=ee(e,n);return t?e.all(`SELECT DISTINCT d2.relative_path
388
+ `).trimEnd();return a.length>0?a:null}function Ou(e,n,t){let s=dt(e);if(s&&!$u(s))return s;let i=(n??"").trim();return i?j(t)&&!i.endsWith("()")?`${i}()`:i:I(t)}function $u(e){return e.startsWith("undefined")||e.includes("|")||e.includes("```")}function eo(e,n){let t=ee(e,n);return t?e.all(`SELECT DISTINCT d2.relative_path
389
389
  FROM mentions m
390
390
  JOIN chunks c ON m.chunk_id = c.id
391
391
  JOIN documents d1 ON c.document_id = d1.id
@@ -401,7 +401,7 @@ ${d}`,c+=1+d.length,m+=ji(d),s+=d.length+1}let u=Kc(l);u&&t.push({...u,start:r,e
401
401
  WHERE d1.relative_path = ?
402
402
  AND d2.relative_path <> d1.relative_path
403
403
  AND ${e.localSymbolPredicate}
404
- ORDER BY d2.relative_path`,t).filter(i=>!e.isIgnored(i.relative_path)).map(i=>({relativePath:i.relative_path})):[]}function eo(e,n){let t=ee(e,n);return t?e.all(`SELECT DISTINCT d1.relative_path
404
+ ORDER BY d2.relative_path`,t).filter(i=>!e.isIgnored(i.relative_path)).map(i=>({relativePath:i.relative_path})):[]}function to(e,n){let t=ee(e,n);return t?e.all(`SELECT DISTINCT d1.relative_path
405
405
  FROM mentions m
406
406
  JOIN chunks c ON m.chunk_id = c.id
407
407
  JOIN documents d1 ON c.document_id = d1.id
@@ -416,7 +416,7 @@ ${d}`,c+=1+d.length,m+=ji(d),s+=d.length+1}let u=Kc(l);u&&t.push({...u,start:r,e
416
416
  JOIN documents d2 ON sym_def.document_id = d2.id
417
417
  WHERE d2.relative_path = ?
418
418
  AND d1.relative_path != ?
419
- ORDER BY d1.relative_path`,t,t).filter(i=>!e.isIgnored(i.relative_path)).map(i=>({relativePath:i.relative_path})):[]}function to(e,n){let t=Le(e,n);if(t.length===0)return{files:[],symbols:[],dependsOn:[],dependedOnBy:[]};let s=t.map(()=>"?").join(", "),o=e.all(`SELECT relative_path FROM documents
419
+ ORDER BY d1.relative_path`,t,t).filter(i=>!e.isIgnored(i.relative_path)).map(i=>({relativePath:i.relative_path})):[]}function no(e,n){let t=Le(e,n);if(t.length===0)return{files:[],symbols:[],dependsOn:[],dependedOnBy:[]};let s=t.map(()=>"?").join(", "),o=e.all(`SELECT relative_path FROM documents
420
420
  WHERE relative_path IN (${s})
421
421
  ORDER BY relative_path`,...t).map(u=>u.relative_path).filter(u=>!e.isIgnored(u)),a=Ke(e,o,{onlyDocumented:!0,sort:!0}).map(({relativePath:u,...d})=>d),l=e.all(`SELECT DISTINCT d2.relative_path
422
422
  FROM mentions m
@@ -449,7 +449,7 @@ ${d}`,c+=1+d.length,m+=ji(d),s+=d.length+1}let u=Kc(l);u&&t.push({...u,start:r,e
449
449
  JOIN documents d2 ON sym_def.document_id = d2.id
450
450
  WHERE d2.relative_path IN (${s})
451
451
  AND d1.relative_path NOT IN (${s})
452
- ORDER BY d1.relative_path`,...t,...t).map(u=>u.relative_path).filter(u=>!e.isIgnored(u));return{files:o,symbols:a,dependsOn:l,dependedOnBy:m}}function no(e,n){let t=Le(e,n);if(t.length===0)return[];let s=t.map(()=>"?").join(", "),i=e.all(`SELECT DISTINCT d1.relative_path, gs.symbol
452
+ ORDER BY d1.relative_path`,...t,...t).map(u=>u.relative_path).filter(u=>!e.isIgnored(u));return{files:o,symbols:a,dependsOn:l,dependedOnBy:m}}function so(e,n){let t=Le(e,n);if(t.length===0)return[];let s=t.map(()=>"?").join(", "),i=e.all(`SELECT DISTINCT d1.relative_path, gs.symbol
453
453
  FROM mentions m
454
454
  JOIN chunks c ON m.chunk_id = c.id
455
455
  JOIN documents d1 ON c.document_id = d1.id
@@ -476,7 +476,7 @@ ${d}`,c+=1+d.length,m+=ji(d),s+=d.length+1}let u=Kc(l);u&&t.push({...u,start:r,e
476
476
  AND m.role != 1
477
477
  AND ${e.localSymbolPredicate}
478
478
  ${e.pathExclusionsFor("d1")}
479
- ORDER BY d1.relative_path`,...t,...t,...t),o=t.flatMap(r=>A(e,r).filter(l=>Ve(l.symbol)).map(l=>({relative_path:r,symbol:l.symbol}))),a=new Set;return[...i,...o].filter(r=>!e.isIgnored(r.relative_path)).filter(r=>{let l=`${r.relative_path}|${r.symbol}`;return a.has(l)?!1:(a.add(l),!0)}).map(r=>({consumer:r.relative_path,symbol:r.symbol,shortName:I(r.symbol)}))}function U(e){let n=_t(e);return Pu(n)?"test":Mu(n)?"worker":Fu(n)?"entry":Tu(n)?"barrel":"source"}function en(e){return U(e)==="barrel"}function io(e){return $u.get(e,()=>{let n=K(e),t=Re(e).filter(o=>{let a=U(o);return a==="entry"||a==="worker"}),s=new Set,i=new Set;for(;t.length>0;){let o=t.shift();if(!s.has(o)){s.add(o),U(o)==="barrel"&&i.add(o);for(let a of n.get(o)??[])s.has(a)||t.push(a)}}return i})}var $u=je("live-barrels");function Un(e,n){return io(e).has(_t(n))}function oo(e){let n=io(e);return Re(e).filter(t=>en(t)&&!n.has(t))}function ve(e,n){let t=U(n);return t==="entry"||t==="worker"||Un(e,n)}function rt(e,n,t){let s=e.config.entryRoots;if(!s)return!1;let i=_t(t);return!!(s.files?.some(o=>_t(o)===i)||s.pathPrefixes?.some(o=>i.startsWith(_t(o)))||s.qualifiedVars?.some(o=>Au(n,o))||s.symbolPatterns?.some(o=>{try{return new RegExp(o).test(n)}catch{return!1}}))}var ro=["%/__tests__/%","%.test.%","%.spec.%","%/test/%","%/tests/%","%_test.%","%_spec.%","%/test_%.%","%/spec_%.%"],ao=["%/test-utils/%"];function Pu(e){return!!(/\.(?:test|spec)\.[a-z0-9]+$/i.test(e)||/(?:^|\/)(?:_)?test_[^/]+$/i.test(e)||/(?:^|\/)spec_[^/]+$/i.test(e)||/(?:^|\/)[^/]+_test\.[a-z0-9]+$/i.test(e)||/(?:^|\/)[^/]+_tests\.rs$/i.test(e)||/(?:^|\/)tests\.rs$/i.test(e)||/(?:^|\/)[^/]+_spec\.[a-z0-9]+$/i.test(e)||/(?:^|\/)__tests__\//i.test(e)||/(?:^|\/)test\//i.test(e)||/(?:^|\/)tests\//i.test(e)||/(?:^|\/)__fixtures__\//i.test(e)||/(?:^|\/)__mocks__\//i.test(e)||/(?:^|\/)test-support\//i.test(e)||/(?:^|\/)test-utils\//i.test(e)||/(?:^|\/)testing\//i.test(e))}function Mu(e){return/(?:^|\/)[^/]*worker\.(?:ts|tsx|js|mjs|cjs|rs|py|go)$/.test(e)}function Fu(e){let n=e.split("/"),t=n[n.length-1]??e;return t==="cli.ts"||t==="cli.js"||t==="postinstall.ts"||t==="postinstall.js"||t==="main.ts"||t==="main.js"||t==="main.rs"||t==="main.go"||t==="main.py"||t==="build.rs"||t==="lib.rs"||/\bsrc\/bin\/[^/]+\.rs$/.test(e)||/(?:^|\/)examples\/[^/]+\.rs$/.test(e)||/(?:^|\/)tests\/[^/]+\.rs$/.test(e)||/(?:^|\/)benches\/[^/]+\.rs$/.test(e)?!0:t==="index.ts"||t==="index.js"?n.length<=2:!1}function Tu(e){return e==="index.ts"||e==="index.js"||e.endsWith("/index.ts")||e.endsWith("/index.js")||e.endsWith("/mod.rs")||e.endsWith("/__init__.py")}function _t(e){return e.replace(/\\/g,"/")}function Au(e,n){let t=n.lastIndexOf("/");if(t<0)return!1;let s=n.slice(0,t),i=n.slice(t+1);return e.includes(so(s)+"/")&&e.includes(so(i)+".")}function so(e){return/^[A-Za-z0-9_$+-]+$/.test(e)?e:"`"+e.replace(/`/g,"``")+"`"}function tn(e,n={}){let{scope:t,minLoc:s=1,includeTests:i=!1,skipBarrels:o=!1,includeMembers:a=!1}=n,r=o?new Set(oo(e)):new Set,l=e.all(`SELECT
479
+ ORDER BY d1.relative_path`,...t,...t,...t),o=t.flatMap(r=>A(e,r).filter(l=>Ve(l.symbol)).map(l=>({relative_path:r,symbol:l.symbol}))),a=new Set;return[...i,...o].filter(r=>!e.isIgnored(r.relative_path)).filter(r=>{let l=`${r.relative_path}|${r.symbol}`;return a.has(l)?!1:(a.add(l),!0)}).map(r=>({consumer:r.relative_path,symbol:r.symbol,shortName:I(r.symbol)}))}function U(e){let n=_t(e);return Mu(n)?"test":Fu(n)?"worker":Tu(n)?"entry":Au(n)?"barrel":"source"}function en(e){return U(e)==="barrel"}function oo(e){return Pu.get(e,()=>{let n=K(e),t=Re(e).filter(o=>{let a=U(o);return a==="entry"||a==="worker"}),s=new Set,i=new Set;for(;t.length>0;){let o=t.shift();if(!s.has(o)){s.add(o),U(o)==="barrel"&&i.add(o);for(let a of n.get(o)??[])s.has(a)||t.push(a)}}return i})}var Pu=je("live-barrels");function Un(e,n){return oo(e).has(_t(n))}function ro(e){let n=oo(e);return Re(e).filter(t=>en(t)&&!n.has(t))}function ve(e,n){let t=U(n);return t==="entry"||t==="worker"||Un(e,n)}function rt(e,n,t){let s=e.config.entryRoots;if(!s)return!1;let i=_t(t);return!!(s.files?.some(o=>_t(o)===i)||s.pathPrefixes?.some(o=>i.startsWith(_t(o)))||s.qualifiedVars?.some(o=>ju(n,o))||s.symbolPatterns?.some(o=>{try{return new RegExp(o).test(n)}catch{return!1}}))}var ao=["%/__tests__/%","%.test.%","%.spec.%","%/test/%","%/tests/%","%_test.%","%_spec.%","%/test_%.%","%/spec_%.%"],lo=["%/test-utils/%"];function Mu(e){return!!(/\.(?:test|spec)\.[a-z0-9]+$/i.test(e)||/(?:^|\/)(?:_)?test_[^/]+$/i.test(e)||/(?:^|\/)spec_[^/]+$/i.test(e)||/(?:^|\/)[^/]+_test\.[a-z0-9]+$/i.test(e)||/(?:^|\/)[^/]+_tests\.rs$/i.test(e)||/(?:^|\/)tests\.rs$/i.test(e)||/(?:^|\/)[^/]+_spec\.[a-z0-9]+$/i.test(e)||/(?:^|\/)__tests__\//i.test(e)||/(?:^|\/)test\//i.test(e)||/(?:^|\/)tests\//i.test(e)||/(?:^|\/)__fixtures__\//i.test(e)||/(?:^|\/)__mocks__\//i.test(e)||/(?:^|\/)test-support\//i.test(e)||/(?:^|\/)test-utils\//i.test(e)||/(?:^|\/)testing\//i.test(e))}function Fu(e){return/(?:^|\/)[^/]*worker\.(?:ts|tsx|js|mjs|cjs|rs|py|go)$/.test(e)}function Tu(e){let n=e.split("/"),t=n[n.length-1]??e;return t==="cli.ts"||t==="cli.js"||t==="postinstall.ts"||t==="postinstall.js"||t==="main.ts"||t==="main.js"||t==="main.rs"||t==="main.go"||t==="main.py"||t==="build.rs"||t==="lib.rs"||/\bsrc\/bin\/[^/]+\.rs$/.test(e)||/(?:^|\/)examples\/[^/]+\.rs$/.test(e)||/(?:^|\/)tests\/[^/]+\.rs$/.test(e)||/(?:^|\/)benches\/[^/]+\.rs$/.test(e)?!0:t==="index.ts"||t==="index.js"?n.length<=2:!1}function Au(e){return e==="index.ts"||e==="index.js"||e.endsWith("/index.ts")||e.endsWith("/index.js")||e.endsWith("/mod.rs")||e.endsWith("/__init__.py")}function _t(e){return e.replace(/\\/g,"/")}function ju(e,n){let t=n.lastIndexOf("/");if(t<0)return!1;let s=n.slice(0,t),i=n.slice(t+1);return e.includes(io(s)+"/")&&e.includes(io(i)+".")}function io(e){return/^[A-Za-z0-9_$+-]+$/.test(e)?e:"`"+e.replace(/`/g,"``")+"`"}function tn(e,n={}){let{scope:t,minLoc:s=1,includeTests:i=!1,skipBarrels:o=!1,includeMembers:a=!1}=n,r=o?new Set(ro(e)):new Set,l=e.all(`SELECT
480
480
  m.symbol_id,
481
481
  d.relative_path,
482
482
  COUNT(*) AS ref_count
@@ -485,8 +485,8 @@ ${d}`,c+=1+d.length,m+=ji(d),s+=d.length+1}let u=Kc(l);u&&t.push({...u,start:r,e
485
485
  JOIN documents d ON c.document_id = d.id
486
486
  WHERE m.role != 1
487
487
  ${e.pathExclusionsFor("d")}
488
- GROUP BY m.symbol_id, d.relative_path`),c=new Map;for(let h of l){if(e.isIgnored(h.relative_path)||r.has(h.relative_path))continue;let b=c.get(h.symbol_id);b||(b=new Map,c.set(h.symbol_id,b)),b.set(h.relative_path,h.ref_count)}ju(e,c,r);let m=Bu(e),d=Z(e,{scope:t}).filter(h=>!e.isIgnored(h.relativePath)).filter(h=>!Ge(h.symbol)).filter(h=>qn(h.symbol)).filter(h=>h.isFunctionLike||!h.enclosingSymbol||!qn(h.enclosingSymbol)).filter(h=>i||Wu(h.relativePath)).filter(h=>i||!m(h.relativePath,h.startLine,h.symbol,h.parentTypeName)).filter(h=>!Ye(h.symbol)).filter(h=>!G(h.symbol)).filter(h=>a||qn(h.symbol)).filter(h=>h.endLine-h.startLine+1>=s).map(h=>{let b=c.get(h.symbolId)??new Map,_=b.get(h.relativePath)??0,S=0;for(let[x,L]of b)x!==h.relativePath&&(S+=L);return{relative_path:h.relativePath,start_line:h.startLine,end_line:h.endLine,loc:h.endLine-h.startLine+1,symbol:h.symbol,same_file_refs:_,cross_file_refs:S}}).filter(h=>h.cross_file_refs===0).sort((h,b)=>b.loc-h.loc||h.relative_path.localeCompare(b.relative_path)||h.start_line-b.start_line),g=0,p=0,f=0,y=d.filter(h=>!e.isIgnored(h.relative_path)).filter(h=>!ve(e,h.relative_path)).filter(h=>!rt(e,h.symbol,h.relative_path)).map(h=>{let b=h.same_file_refs===0?"dead-code":"file-internal";return b==="dead-code"?g++:p++,f+=h.loc,{relativePath:h.relative_path,startLine:h.start_line,endLine:h.end_line,loc:h.loc,symbol:h.symbol,shortName:I(h.symbol),sameFileRefs:h.same_file_refs,kind:b}});return{symbols:y,totalCount:y.length,deadCodeCount:g,fileInternalCount:p,totalLoc:f}}function ju(e,n,t){let s=e.all(`SELECT relative_path FROM documents
489
- WHERE 1 = 1 ${e.pathExclusionsFor("documents")}`),i=new Set(s.map(r=>r.relative_path)),o=new Set(Re(e));for(let r of i)o.add(r);let a=(r,l,c)=>{if(c<=0)return;let m=n.get(r);m||(m=new Map,n.set(r,m)),m.set(l,(m.get(l)??0)+c)};for(let r of o){if(!P(r)&&!mt(r)||e.isIgnored(r)||t.has(r))continue;let l=xe(e,r);for(let[u,d]of l){let g=St(e,r,u);if(g.length!==0)for(let p of g){let f=p.relativePath===r?Math.max(0,d.length-1):d.length;a(p.symbolId,r,f)}}let c=Si(e,r);for(let u of c){let d=it(e,r,u);for(let g of d)g.relativePath!==r&&a(g.symbolId,r,1)}let m=we(e,r);for(let u of m){let d=it(e,r,u);for(let g of d)a(g.symbolId,r,1)}}}function Bu(e){let n=new Map,t=s=>{let i=n.get(s);if(i)return i;let o=hi(e,s);return i={ranges:o.map(a=>({startLine:a.startLine,endLine:a.endLine})),containers:new Set(o.map(a=>a.containerName).filter(a=>!!a))},n.set(s,i),i};return(s,i,o,a)=>{let r=t(s);for(let l of r.ranges)if(i>=l.startLine&&i<=l.endLine)return!0;if(a&&r.containers.has(a))return!0;for(let l of ai(o))if(r.containers.has(l))return!0;return!1}}function Wu(e){return[...new Set([...ro,...ao])].every(t=>!Hu(e,t))}function Hu(e,n){return new RegExp(`^${n.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/%/g,".*").replace(/_/g,".")}$`).test(e)}function qn(e){return j(e)||e.endsWith("().")||e.endsWith(".")}function lo(e,n={}){let{limit:t=30,scope:s}=n,i=s?`AND def_d.relative_path LIKE '%${s}%'`:"",a=e.all(`SELECT
488
+ GROUP BY m.symbol_id, d.relative_path`),c=new Map;for(let h of l){if(e.isIgnored(h.relative_path)||r.has(h.relative_path))continue;let b=c.get(h.symbol_id);b||(b=new Map,c.set(h.symbol_id,b)),b.set(h.relative_path,h.ref_count)}Bu(e,c,r);let m=Wu(e),d=Z(e,{scope:t}).filter(h=>!e.isIgnored(h.relativePath)).filter(h=>!Ge(h.symbol)).filter(h=>qn(h.symbol)).filter(h=>h.isFunctionLike||!h.enclosingSymbol||!qn(h.enclosingSymbol)).filter(h=>i||Hu(h.relativePath)).filter(h=>i||!m(h.relativePath,h.startLine,h.symbol,h.parentTypeName)).filter(h=>!Ye(h.symbol)).filter(h=>!G(h.symbol)).filter(h=>a||qn(h.symbol)).filter(h=>h.endLine-h.startLine+1>=s).map(h=>{let b=c.get(h.symbolId)??new Map,_=b.get(h.relativePath)??0,S=0;for(let[x,L]of b)x!==h.relativePath&&(S+=L);return{relative_path:h.relativePath,start_line:h.startLine,end_line:h.endLine,loc:h.endLine-h.startLine+1,symbol:h.symbol,same_file_refs:_,cross_file_refs:S}}).filter(h=>h.cross_file_refs===0).sort((h,b)=>b.loc-h.loc||h.relative_path.localeCompare(b.relative_path)||h.start_line-b.start_line),g=0,p=0,f=0,y=d.filter(h=>!e.isIgnored(h.relative_path)).filter(h=>!ve(e,h.relative_path)).filter(h=>!rt(e,h.symbol,h.relative_path)).map(h=>{let b=h.same_file_refs===0?"dead-code":"file-internal";return b==="dead-code"?g++:p++,f+=h.loc,{relativePath:h.relative_path,startLine:h.start_line,endLine:h.end_line,loc:h.loc,symbol:h.symbol,shortName:I(h.symbol),sameFileRefs:h.same_file_refs,kind:b}});return{symbols:y,totalCount:y.length,deadCodeCount:g,fileInternalCount:p,totalLoc:f}}function Bu(e,n,t){let s=e.all(`SELECT relative_path FROM documents
489
+ WHERE 1 = 1 ${e.pathExclusionsFor("documents")}`),i=new Set(s.map(r=>r.relative_path)),o=new Set(Re(e));for(let r of i)o.add(r);let a=(r,l,c)=>{if(c<=0)return;let m=n.get(r);m||(m=new Map,n.set(r,m)),m.set(l,(m.get(l)??0)+c)};for(let r of o){if(!P(r)&&!mt(r)||e.isIgnored(r)||t.has(r))continue;let l=xe(e,r);for(let[u,d]of l){let g=St(e,r,u);if(g.length!==0)for(let p of g){let f=p.relativePath===r?Math.max(0,d.length-1):d.length;a(p.symbolId,r,f)}}let c=_i(e,r);for(let u of c){let d=it(e,r,u);for(let g of d)g.relativePath!==r&&a(g.symbolId,r,1)}let m=we(e,r);for(let u of m){let d=it(e,r,u);for(let g of d)a(g.symbolId,r,1)}}}function Wu(e){let n=new Map,t=s=>{let i=n.get(s);if(i)return i;let o=yi(e,s);return i={ranges:o.map(a=>({startLine:a.startLine,endLine:a.endLine})),containers:new Set(o.map(a=>a.containerName).filter(a=>!!a))},n.set(s,i),i};return(s,i,o,a)=>{let r=t(s);for(let l of r.ranges)if(i>=l.startLine&&i<=l.endLine)return!0;if(a&&r.containers.has(a))return!0;for(let l of li(o))if(r.containers.has(l))return!0;return!1}}function Hu(e){return[...new Set([...ao,...lo])].every(t=>!Ju(e,t))}function Ju(e,n){return new RegExp(`^${n.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/%/g,".*").replace(/_/g,".")}$`).test(e)}function qn(e){return j(e)||e.endsWith("().")||e.endsWith(".")}function co(e,n={}){let{limit:t=30,scope:s}=n,i=s?`AND def_d.relative_path LIKE '%${s}%'`:"",a=e.all(`SELECT
490
490
  gs.symbol,
491
491
  COUNT(*) AS ref_count,
492
492
  COUNT(DISTINCT ref_d.id) AS file_count,
@@ -509,7 +509,7 @@ ${d}`,c+=1+d.length,m+=ji(d),s+=d.length+1}let u=Kc(l);u&&t.push({...u,start:r,e
509
509
  ${i}
510
510
  GROUP BY gs.id
511
511
  ORDER BY ref_count DESC
512
- LIMIT ?`,t).filter(r=>!e.isIgnored(r.defined_in)).map(r=>({symbol:r.symbol,shortName:I(r.symbol),refCount:r.ref_count,fileCount:r.file_count,definedIn:r.defined_in}));return a.length>0?a:Ju(e,s,t)}function Ju(e,n,t){return Z(e,{scope:n}).filter(s=>!e.isIgnored(s.relativePath)).map(s=>Uu(e,s)).filter(s=>s.refCount>0).sort((s,i)=>i.refCount-s.refCount||i.fileCount-s.fileCount).slice(0,t)}function Uu(e,n){let t=he(e,n,{limit:500});return{symbol:n.symbol,shortName:I(n.symbol),refCount:t.length,fileCount:new Set(t.map(s=>s.file)).size,definedIn:n.relativePath}}function uo(e,n){return fo(e,n)?.map(t=>({symbol:t.symbol,shortName:t.shortName,fromFile:t.fromFile}))??[]}function mo(e,n){let s=e.all(`SELECT DISTINCT gs.symbol, d.relative_path AS importer
512
+ LIMIT ?`,t).filter(r=>!e.isIgnored(r.defined_in)).map(r=>({symbol:r.symbol,shortName:I(r.symbol),refCount:r.ref_count,fileCount:r.file_count,definedIn:r.defined_in}));return a.length>0?a:Uu(e,s,t)}function Uu(e,n,t){return Z(e,{scope:n}).filter(s=>!e.isIgnored(s.relativePath)).map(s=>qu(e,s)).filter(s=>s.refCount>0).sort((s,i)=>i.refCount-s.refCount||i.fileCount-s.fileCount).slice(0,t)}function qu(e,n){let t=he(e,n,{limit:500});return{symbol:n.symbol,shortName:I(n.symbol),refCount:t.length,fileCount:new Set(t.map(s=>s.file)).size,definedIn:n.relativePath}}function mo(e,n){return go(e,n)?.map(t=>({symbol:t.symbol,shortName:t.shortName,fromFile:t.fromFile}))??[]}function po(e,n){let s=e.all(`SELECT DISTINCT gs.symbol, d.relative_path AS importer
513
513
  FROM mentions m
514
514
  JOIN chunks c ON m.chunk_id = c.id
515
515
  JOIN documents d ON c.document_id = d.id
@@ -520,7 +520,7 @@ ${d}`,c+=1+d.length,m+=ji(d),s+=d.length+1}let u=Kc(l);u&&t.push({...u,start:r,e
520
520
  FROM documents
521
521
  WHERE 1 = 1
522
522
  ${e.pathExclusionsFor("documents")}
523
- ORDER BY relative_path`),c=new Set;for(let m of l)if(!e.isIgnored(m.relative_path)){for(let u of de(e,m.relative_path))if(u.sourcePath&&!(o&&co(u.sourcePath)!==co(o))){if(u.kind==="side-effect"){c.add(m.relative_path);continue}if(o&&zu(m.relative_path)){c.add(m.relative_path);continue}if(r){c.add(m.relative_path);continue}if(u.kind==="named"&&u.importedName===a){c.add(m.relative_path);continue}u.kind==="namespace"&&u.usedMembers.includes(a)&&c.add(m.relative_path)}}return[...c].sort().map(m=>({symbol:i?.symbol??a,shortName:i?I(i.symbol):a,fromFile:m}))}function po(e,n){return fo(e,n)?.filter(t=>!t.used).map(t=>({symbol:t.symbol,shortName:t.shortName,importedIn:t.importer}))??[]}function fo(e,n){let t=ee(e,n);if(!t)return null;let i=e.all(`SELECT DISTINCT
523
+ ORDER BY relative_path`),c=new Set;for(let m of l)if(!e.isIgnored(m.relative_path)){for(let u of de(e,m.relative_path))if(u.sourcePath&&!(o&&uo(u.sourcePath)!==uo(o))){if(u.kind==="side-effect"){c.add(m.relative_path);continue}if(o&&Vu(m.relative_path)){c.add(m.relative_path);continue}if(r){c.add(m.relative_path);continue}if(u.kind==="named"&&u.importedName===a){c.add(m.relative_path);continue}u.kind==="namespace"&&u.usedMembers.includes(a)&&c.add(m.relative_path)}}return[...c].sort().map(m=>({symbol:i?.symbol??a,shortName:i?I(i.symbol):a,fromFile:m}))}function fo(e,n){return go(e,n)?.filter(t=>!t.used).map(t=>({symbol:t.symbol,shortName:t.shortName,importedIn:t.importer}))??[]}function go(e,n){let t=ee(e,n);if(!t)return null;let i=e.all(`SELECT DISTINCT
524
524
  gs.symbol,
525
525
  def_d.relative_path AS from_file,
526
526
  imp_d.relative_path AS importer,
@@ -546,11 +546,11 @@ ${d}`,c+=1+d.length,m+=ji(d),s+=d.length+1}let u=Kc(l);u&&t.push({...u,start:r,e
546
546
  LEFT JOIN documents def_d ON sym_def.document_id = def_d.id
547
547
  WHERE imp_d.relative_path = ?
548
548
  AND m.role = 2
549
- ORDER BY def_d.relative_path, gs.symbol`,t).filter(o=>!e.isIgnored(o.importer));return i.length>0?i.map(o=>({symbol:o.symbol,shortName:I(o.symbol),fromFile:o.from_file??"(external)",importer:o.importer,used:o.used!==0})):de(e,t).map(o=>{let a=qu(o.importedName,o.localName,o.kind),r=o.kind==="side-effect"?!0:o.used;return{symbol:a,shortName:a,fromFile:o.sourcePath??"(external)",importer:t,used:r}})}function qu(e,n,t){return t==="namespace"&&e==="*"&&n?`* as ${n}`:t==="default"&&n?`default as ${n}`:t==="side-effect"?"(side effect import)":n&&n!==e?`${e} as ${n}`:e}function co(e){return e.replace(/\\/g,"/")}function zu(e){return/\.(?:c|h|cc|cpp|cxx|hpp|hh|hxx)$/i.test(e)}function go(e,n){let t=Le(e,n),s=Ke(e,t,{sort:!0});if(s.length===0)return[];let i=s.map(r=>({symbol:r.symbol,shortName:r.shortName,startLine:r.startLine,endLine:r.endLine,children:[]})),o=new Map;for(let r of i)o.set(r.symbol,r);let a=[];for(let r=0;r<s.length;r++){let l=s[r],c=i[r];if(l.enclosingSymbol&&o.has(l.enclosingSymbol)){o.get(l.enclosingSymbol).children.push(c);continue}let m=null,u=1/0;for(let d of i)if(d!==c&&d.startLine<=c.startLine&&d.endLine>=c.endLine){if(d.startLine===c.startLine&&d.endLine===c.endLine&&!ri(d.symbol,c.symbol))continue;let p=d.endLine-d.startLine;p<u&&(u=p,m=d)}m?m.children.push(c):a.push(c)}return a}function ho(e,n){let t=k(e,n);return t?A(e,t.relativePath).filter(s=>s.symbol!==t.symbol).filter(s=>oi(t.symbol,s.symbol)).sort((s,i)=>s.startLine-i.startLine||s.endLine-i.endLine).map(s=>({symbol:s.symbol,shortName:I(s.symbol),startLine:s.startLine,endLine:s.endLine,kind:ie(s.symbol)??"unknown"})):[]}function yo(e,n){let t=k(e,n);if(!t)return[];let s=e.get(`SELECT COUNT(DISTINCT c.document_id) AS file_count
549
+ ORDER BY def_d.relative_path, gs.symbol`,t).filter(o=>!e.isIgnored(o.importer));return i.length>0?i.map(o=>({symbol:o.symbol,shortName:I(o.symbol),fromFile:o.from_file??"(external)",importer:o.importer,used:o.used!==0})):de(e,t).map(o=>{let a=zu(o.importedName,o.localName,o.kind),r=o.kind==="side-effect"?!0:o.used;return{symbol:a,shortName:a,fromFile:o.sourcePath??"(external)",importer:t,used:r}})}function zu(e,n,t){return t==="namespace"&&e==="*"&&n?`* as ${n}`:t==="default"&&n?`default as ${n}`:t==="side-effect"?"(side effect import)":n&&n!==e?`${e} as ${n}`:e}function uo(e){return e.replace(/\\/g,"/")}function Vu(e){return/\.(?:c|h|cc|cpp|cxx|hpp|hh|hxx)$/i.test(e)}function ho(e,n){let t=Le(e,n),s=Ke(e,t,{sort:!0});if(s.length===0)return[];let i=s.map(r=>({symbol:r.symbol,shortName:r.shortName,startLine:r.startLine,endLine:r.endLine,children:[]})),o=new Map;for(let r of i)o.set(r.symbol,r);let a=[];for(let r=0;r<s.length;r++){let l=s[r],c=i[r];if(l.enclosingSymbol&&o.has(l.enclosingSymbol)){o.get(l.enclosingSymbol).children.push(c);continue}let m=null,u=1/0;for(let d of i)if(d!==c&&d.startLine<=c.startLine&&d.endLine>=c.endLine){if(d.startLine===c.startLine&&d.endLine===c.endLine&&!ai(d.symbol,c.symbol))continue;let p=d.endLine-d.startLine;p<u&&(u=p,m=d)}m?m.children.push(c):a.push(c)}return a}function yo(e,n){let t=k(e,n);return t?A(e,t.relativePath).filter(s=>s.symbol!==t.symbol).filter(s=>ri(t.symbol,s.symbol)).sort((s,i)=>s.startLine-i.startLine||s.endLine-i.endLine).map(s=>({symbol:s.symbol,shortName:I(s.symbol),startLine:s.startLine,endLine:s.endLine,kind:ie(s.symbol)??"unknown"})):[]}function bo(e,n){let t=k(e,n);if(!t)return[];let s=e.get(`SELECT COUNT(DISTINCT c.document_id) AS file_count
550
550
  FROM mentions m
551
551
  JOIN chunks c ON m.chunk_id = c.id
552
552
  WHERE m.symbol_id = ?
553
- AND m.role != 1`,t.symbolId);return[{name:I(t.symbol),count:s?.file_count??0}]}function bo(e,n){let t=ee(e,n);if(!t)return[];let i=e.all(`SELECT d.relative_path, COUNT(DISTINCT gs.id) AS symbol_count
553
+ AND m.role != 1`,t.symbolId);return[{name:I(t.symbol),count:s?.file_count??0}]}function So(e,n){let t=ee(e,n);if(!t)return[];let i=e.all(`SELECT d.relative_path, COUNT(DISTINCT gs.id) AS symbol_count
554
554
  FROM mentions m
555
555
  JOIN chunks c ON m.chunk_id = c.id
556
556
  JOIN documents d ON c.document_id = d.id
@@ -567,7 +567,7 @@ ${d}`,c+=1+d.length,m+=ji(d),s+=d.length+1}let u=Kc(l);u&&t.push({...u,start:r,e
567
567
  AND m.role != 1
568
568
  AND def_d.id != d.id
569
569
  GROUP BY d.id
570
- ORDER BY symbol_count DESC`,t).filter(r=>!e.isIgnored(r.relative_path)).map(r=>({name:r.relative_path,count:r.symbol_count}));if(i.length>0)return i;let a=K(e).get(t);return!a||a.size===0?[]:[{name:t,count:a.size}]}function So(e,n={}){return Vu(e,n).map(t=>({name:I(t.symbol),count:t.file_count}))}function Vu(e,n){let{limit:t=30,scope:s}=n,i=s?`AND def_d.relative_path LIKE '%${s}%'`:"";return e.all(`SELECT gs.symbol, COUNT(DISTINCT c.document_id) AS file_count
570
+ ORDER BY symbol_count DESC`,t).filter(r=>!e.isIgnored(r.relative_path)).map(r=>({name:r.relative_path,count:r.symbol_count}));if(i.length>0)return i;let a=K(e).get(t);return!a||a.size===0?[]:[{name:t,count:a.size}]}function _o(e,n={}){return Gu(e,n).map(t=>({name:I(t.symbol),count:t.file_count}))}function Gu(e,n){let{limit:t=30,scope:s}=n,i=s?`AND def_d.relative_path LIKE '%${s}%'`:"";return e.all(`SELECT gs.symbol, COUNT(DISTINCT c.document_id) AS file_count
571
571
  FROM mentions m
572
572
  JOIN chunks c ON m.chunk_id = c.id
573
573
  JOIN global_symbols gs ON m.symbol_id = gs.id
@@ -586,7 +586,7 @@ ${d}`,c+=1+d.length,m+=ji(d),s+=d.length+1}let u=Kc(l);u&&t.push({...u,start:r,e
586
586
  GROUP BY gs.id
587
587
  HAVING file_count > 1
588
588
  ORDER BY file_count DESC
589
- LIMIT ?`,t)}function _o(e,n={}){let{limit:t=30,scope:s}=n,i=s?`AND d.relative_path LIKE '%${s}%'`:"";return e.all(`SELECT d.relative_path, COUNT(DISTINCT gs.id) AS symbol_count
589
+ LIMIT ?`,t)}function xo(e,n={}){let{limit:t=30,scope:s}=n,i=s?`AND d.relative_path LIKE '%${s}%'`:"";return e.all(`SELECT d.relative_path, COUNT(DISTINCT gs.id) AS symbol_count
590
590
  FROM mentions m
591
591
  JOIN chunks c ON m.chunk_id = c.id
592
592
  JOIN documents d ON c.document_id = d.id
@@ -606,7 +606,7 @@ ${d}`,c+=1+d.length,m+=ji(d),s+=d.length+1}let u=Kc(l);u&&t.push({...u,start:r,e
606
606
  ${i}
607
607
  GROUP BY d.id
608
608
  ORDER BY symbol_count DESC
609
- LIMIT ?`,t).filter(a=>!e.isIgnored(a.relative_path)).map(a=>({name:a.relative_path,count:a.symbol_count}))}function xo(e,n,t){let s=ee(e,n)??n,i=ee(e,t)??t,o=e.get(`SELECT COUNT(DISTINCT gs.id) AS shared
609
+ LIMIT ?`,t).filter(a=>!e.isIgnored(a.relative_path)).map(a=>({name:a.relative_path,count:a.symbol_count}))}function Io(e,n,t){let s=ee(e,n)??n,i=ee(e,t)??t,o=e.get(`SELECT COUNT(DISTINCT gs.id) AS shared
610
610
  FROM global_symbols gs
611
611
  WHERE (
612
612
  -- Defined in file1, referenced in file2
@@ -638,7 +638,7 @@ ${d}`,c+=1+d.length,m+=ji(d),s+=d.length+1}let u=Kc(l);u&&t.push({...u,start:r,e
638
638
  JOIN documents d ON c.document_id = d.id
639
639
  WHERE m.symbol_id = gs.id AND m.role != 1 AND d.relative_path = ?
640
640
  )
641
- )`,s,i,i,s);return{file1:s,file2:i,sharedSymbols:o?.shared??0}}function Io(e,n={}){let{limit:t=20,scope:s}=n,i=s?`AND d1.relative_path LIKE '%${s}%' AND d2.relative_path LIKE '%${s}%'`:"";return e.all(`SELECT
641
+ )`,s,i,i,s);return{file1:s,file2:i,sharedSymbols:o?.shared??0}}function No(e,n={}){let{limit:t=20,scope:s}=n,i=s?`AND d1.relative_path LIKE '%${s}%' AND d2.relative_path LIKE '%${s}%'`:"";return e.all(`SELECT
642
642
  def_d.relative_path AS file1,
643
643
  ref_d.relative_path AS file2,
644
644
  COUNT(DISTINCT gs.id) AS shared
@@ -660,7 +660,7 @@ ${d}`,c+=1+d.length,m+=ji(d),s+=d.length+1}let u=Kc(l);u&&t.push({...u,start:r,e
660
660
  ${i}
661
661
  GROUP BY def_d.id, ref_d.id
662
662
  ORDER BY shared DESC
663
- LIMIT ?`,t).filter(a=>!e.isIgnored(a.file1)&&!e.isIgnored(a.file2)).map(a=>({file1:a.file1,file2:a.file2,sharedSymbols:a.shared}))}function nn(e,n={}){let{scope:t,maxDepth:s=10}=n,i=K(e,t),o=[],a=new Set,r=new Set,l=[];function c(u,d){if(d>s)return;if(r.has(u)){let p=l.indexOf(u);if(p!==-1){let f=l.slice(p).concat(u),y=f.indexOf(f.reduce((_,S)=>_<S?_:S)),h=[...f.slice(y,-1),...f.slice(0,y),f[y]],b=h.join(" -> ");m.has(b)||(m.add(b),o.push({path:h,kind:Gu(h)}))}return}if(a.has(u))return;a.add(u),r.add(u),l.push(u);let g=i.get(u);if(g)for(let p of g)c(p,d+1);l.pop(),r.delete(u)}let m=new Set;for(let u of i.keys())a.has(u)||c(u,0);return o.sort((u,d)=>u.kind!==d.kind?u.kind==="real"?-1:1:u.path.length-d.path.length),o}function Gu(e){for(let s of e){let i=U(s);if(i==="test"||i==="barrel"||i==="entry")return"module-hierarchy"}if(e.length!==3)return"real";let[n,t]=e;return!n||!t?"real":en(n)||en(t)||No(n,t)||No(t,n)||vo(n,t)||vo(t,n)||U(n)==="entry"||U(t)==="entry"?"module-hierarchy":"real"}function No(e,n){if(!/\.rs$/.test(e)||!/\.rs$/.test(n))return!1;let t=n.replace(/\.rs$/,"/");return e.startsWith(t)?!e.slice(t.length).includes("/"):!1}function vo(e,n){if(!/\.rs$/.test(e)||!/\.rs$/.test(n))return!1;let t=e.replace(/\.rs$/,""),s=n.replace(/\.rs$/,"");if(t===s+"_tests"||t===s+"/tests")return!0;let i=e.split("/"),o=n.split("/");if(i.length===o.length&&i.includes("tests")&&o.includes("src")){let a=i[i.length-1],r=o[o.length-1];if(a&&a===r)return!0}return!1}function Co(e,n={}){let{limit:t=20,scope:s,minFanIn:i=2,minFanOut:o=2}=n,a=s?`AND def_d.relative_path LIKE '%${s}%'`:"",l=e.all(`SELECT * FROM (
663
+ LIMIT ?`,t).filter(a=>!e.isIgnored(a.file1)&&!e.isIgnored(a.file2)).map(a=>({file1:a.file1,file2:a.file2,sharedSymbols:a.shared}))}function nn(e,n={}){let{scope:t,maxDepth:s=10}=n,i=K(e,t),o=[],a=new Set,r=new Set,l=[];function c(u,d){if(d>s)return;if(r.has(u)){let p=l.indexOf(u);if(p!==-1){let f=l.slice(p).concat(u),y=f.indexOf(f.reduce((_,S)=>_<S?_:S)),h=[...f.slice(y,-1),...f.slice(0,y),f[y]],b=h.join(" -> ");m.has(b)||(m.add(b),o.push({path:h,kind:Yu(h)}))}return}if(a.has(u))return;a.add(u),r.add(u),l.push(u);let g=i.get(u);if(g)for(let p of g)c(p,d+1);l.pop(),r.delete(u)}let m=new Set;for(let u of i.keys())a.has(u)||c(u,0);return o.sort((u,d)=>u.kind!==d.kind?u.kind==="real"?-1:1:u.path.length-d.path.length),o}function Yu(e){for(let s of e){let i=U(s);if(i==="test"||i==="barrel"||i==="entry")return"module-hierarchy"}if(e.length!==3)return"real";let[n,t]=e;return!n||!t?"real":en(n)||en(t)||vo(n,t)||vo(t,n)||Co(n,t)||Co(t,n)||U(n)==="entry"||U(t)==="entry"?"module-hierarchy":"real"}function vo(e,n){if(!/\.rs$/.test(e)||!/\.rs$/.test(n))return!1;let t=n.replace(/\.rs$/,"/");return e.startsWith(t)?!e.slice(t.length).includes("/"):!1}function Co(e,n){if(!/\.rs$/.test(e)||!/\.rs$/.test(n))return!1;let t=e.replace(/\.rs$/,""),s=n.replace(/\.rs$/,"");if(t===s+"_tests"||t===s+"/tests")return!0;let i=e.split("/"),o=n.split("/");if(i.length===o.length&&i.includes("tests")&&o.includes("src")){let a=i[i.length-1],r=o[o.length-1];if(a&&a===r)return!0}return!1}function Eo(e,n={}){let{limit:t=20,scope:s,minFanIn:i=2,minFanOut:o=2}=n,a=s?`AND def_d.relative_path LIKE '%${s}%'`:"",l=e.all(`SELECT * FROM (
664
664
  SELECT
665
665
  gs.symbol,
666
666
  def_d.relative_path AS defined_in,
@@ -699,12 +699,12 @@ ${d}`,c+=1+d.length,m+=ji(d),s+=d.length+1}let u=Kc(l);u&&t.push({...u,start:r,e
699
699
  ${a}
700
700
  ) WHERE fan_in >= ? AND fan_out >= ?
701
701
  ORDER BY (fan_in * fan_out) DESC
702
- LIMIT ?`,i,o,t).filter(c=>!e.isIgnored(c.defined_in)).map(c=>({symbol:c.symbol,shortName:I(c.symbol),fanIn:c.fan_in,fanOut:c.fan_out,score:c.fan_in*c.fan_out,definedIn:c.defined_in}));return l.length>0?l:Yu(e,s,{minFanIn:i,minFanOut:o,limit:t})}function Yu(e,n,t){let{minFanIn:s,minFanOut:i,limit:o}=t;return Z(e,{scope:n}).filter(r=>!e.isIgnored(r.relativePath)).map(r=>Ku(e,r)).filter(r=>r.fanIn>=s&&r.fanOut>=i).sort((r,l)=>l.score-r.score||l.fanIn-r.fanIn).slice(0,o)}function Ku(e,n){let t=new Set(he(e,n,{limit:500}).map(i=>i.file)).size,s=new Set(ne(e,n,{limit:500}).filter(i=>i.file!==n.relativePath).map(i=>`${i.symbol}|${i.file}`)).size;return{symbol:n.symbol,shortName:I(n.symbol),fanIn:t,fanOut:s,score:t*s,definedIn:n.relativePath}}function sn(e,n={}){let{scope:t,minLoc:s=3}=n,o=Y(e,t).filter(p=>!e.isIgnored(p.relativePath)).filter(p=>!ve(e,p.relativePath)).filter(p=>p.isFunctionLike).filter(p=>!Ye(p.symbol)).filter(p=>!G(p.symbol)).filter(p=>p.endLine-p.startLine+1>=s),a=ye(e,o),r=ot(e,o),l=new Set([...a.keys(),...r.keys()]),c=new Map;for(let p of o){let f=F(p.symbol);if(!f)continue;let y=c.get(f)??[];y.push(p.symbolId),c.set(f,y)}let m=e.all(`SELECT relative_path FROM documents WHERE 1 = 1 ${e.pathExclusionsFor("documents")}`);for(let p of m){if(e.isIgnored(p.relative_path)||P(p.relative_path)!=="rust")continue;let f=we(e,p.relative_path);for(let y of f){let h=c.get(y);if(h)for(let b of h)l.add(b)}}let u=new Map(o.map(p=>[p.symbolId,p.symbol])),d=se(e,o,{additive:!0}),g=new Set([...d.entries()].filter(([p,f])=>{let y=u.get(p);return f.some(h=>h.symbol!==y)}).map(([p])=>p));return o.filter(p=>!l.has(p.symbolId)).filter(p=>!g.has(p.symbolId)).sort((p,f)=>f.endLine-f.startLine-(p.endLine-p.startLine)||p.relativePath.localeCompare(f.relativePath)||p.startLine-f.startLine).map(p=>({symbol:p.symbol,shortName:I(p.symbol),relativePath:p.relativePath,startLine:p.startLine,endLine:p.endLine,loc:p.endLine-p.startLine+1}))}var Vn={0:"UnspecifiedKind",1:"AbstractMethod",2:"Accessor",3:"Array",4:"Assertion",5:"AssociatedType",6:"Attribute",7:"Axiom",8:"Boolean",9:"Class",10:"Constant",11:"Constructor",12:"Contract",13:"DataFamily",14:"DefinitionMacro",15:"Delegate",16:"Enum",17:"EnumMember",18:"Error",19:"Event",20:"Fact",21:"Field",22:"File",23:"Function",24:"Getter",25:"Grammar",26:"Instance",27:"Interface",28:"Key",29:"Lang",30:"Lemma",31:"Library",32:"Macro",33:"Method",34:"MethodAlias",35:"MethodReceiver",36:"MethodSpecification",37:"Message",38:"Modifier",39:"Module",40:"Namespace",41:"Null",42:"Number",43:"Object",44:"Operator",45:"Package",46:"PackageObject",47:"Parameter",48:"ParameterLabel",49:"Pattern",50:"Predicate",51:"Property",52:"Protocol",53:"ProtocolMethod",54:"PureVirtualMethod",55:"Quasiquoter",56:"SelfParameter",57:"Setter",58:"Signature",59:"SingletonClass",60:"SingletonMethod",61:"StaticDataMember",62:"StaticEvent",63:"StaticField",64:"StaticMethod",65:"StaticProperty",66:"StaticVariable",67:"String",68:"Struct",69:"Subscript",70:"Tactic",71:"Theorem",72:"ThisParameter",73:"Trait",74:"TraitMethod",75:"Type",76:"TypeAlias",77:"TypeClass",78:"TypeClassMethod",79:"TypeFamily",80:"TypeParameter",81:"Union",82:"Value",83:"Variable"},zn=new Map;for(let[e,n]of Object.entries(Vn))zn.set(n.toLowerCase(),Number(e));function Qu(e){let n=parseInt(e,10);if(!isNaN(n))return n;let t=e.toLowerCase(),s=zn.get(t);if(s!==void 0)return s;for(let[i,o]of zn)if(i.includes(t))return o;return null}function Eo(e,n,t={}){let{scope:s,limit:i=100}=t,o=Qu(n);return o===null?[]:Lo(e,s).map(r=>({row:r,resolvedKind:wo(r)})).filter(r=>r.resolvedKind===o).slice(0,i).map(({row:r,resolvedKind:l})=>({symbol:r.symbol,shortName:I(r.symbol),kind:l,kindName:Vn[l]??"Unknown",relativePath:r.relative_path,startLine:r.start_line,endLine:r.end_line}))}function Ro(e,n={}){let t=new Map;for(let s of Lo(e,n.scope)){let i=wo(s);i===null||i===0||t.set(i,(t.get(i)??0)+1)}return[...t.entries()].sort((s,i)=>i[1]-s[1]||s[0]-i[0]).map(([s,i])=>({kind:s,kindName:Vn[s]??"Unknown",count:i}))}function Lo(e,n){return Z(e,{scope:n}).map(Xu)}function Xu(e){return{symbol:e.symbol,kind:e.kind,documentation:e.documentation,enclosing_symbol:e.enclosingSymbol,relative_path:e.relativePath,start_line:e.startLine,end_line:e.endLine}}function wo(e){return e.kind!==null&&e.kind!==0?Zu(e.kind,e.symbol,e.documentation):em(e.symbol,e.documentation,e.enclosing_symbol)}function Zu(e,n,t){let s=(t??"").toLowerCase();if(ie(n)==="type"){if(s.includes("type "))return 76;if(s.includes("interface "))return 27;if(s.includes("struct "))return 68;if(s.includes("trait "))return 73;if(s.includes("class "))return 9}return e}function em(e,n,t){let s=V(e);if("kind"in s)return null;let i=s.descriptors,o=i[i.length-2]??null,a=ie(e),r=(n??"").toLowerCase();return a==="type"?r.includes("type ")?76:r.includes("interface ")?27:r.includes("struct ")?68:r.includes("trait ")?73:(r.includes("class "),9):a==="method"?o?.suffix==="type"?33:23:a==="namespace"?39:a!=="term"?null:r.includes("async def ")||r.includes("def ")?23:(t?ie(t):o?.suffix??null)==="type"?21:83}function Do(e,n={}){let{limit:t=10,scope:s,minDepth:i=3}=n,o=K(e,s),a=new Map,r=[],l=new Map,c=new Map,m=new Set,u=[],d=0;for(let x of o.keys()){if(l.has(x))continue;let L=[],w=(o.get(x)??new Set).values();for(l.set(x,d),c.set(x,d),d+=1,u.push(x),m.add(x),L.push({node:x,iter:w,pendingChild:null});L.length>0;){let $=L[L.length-1];if($.pendingChild!==null){let T=$.pendingChild;$.pendingChild=null,c.set($.node,Math.min(c.get($.node),c.get(T)))}let q=$.iter.next();if(q.done){if(c.get($.node)===l.get($.node)){let T=[];for(;;){let _e=u.pop();if(m.delete(_e),T.push(_e),a.set(_e,r.length),_e===$.node)break}r.push(T)}L.pop();continue}let B=q.value;if(l.has(B))m.has(B)&&c.set($.node,Math.min(c.get($.node),l.get(B)));else{l.set(B,d),c.set(B,d),d+=1,u.push(B),m.add(B);let T=(o.get(B)??new Set).values();$.pendingChild=B,L.push({node:B,iter:T,pendingChild:null})}}}let g=new Map,p=new Array(r.length);for(let x=0;x<r.length;x++)p[x]=r[x].length,g.set(x,new Set);for(let[x,L]of o){let w=a.get(x);for(let $ of L){let q=a.get($);q!==w&&g.get(w).add(q)}}let f=new Array(r.length),y=new Array(r.length);for(let x=0;x<r.length;x++){let L=[],w=0;for(let $ of g.get(x)){let q=y[$];q>w&&(w=q,L=f[$])}f[x]=[x,...L],y[x]=p[x]+w}function h(x){return f[x]}let b=r.map(x=>[...x].sort()),_=new Set,S=[];for(let x=0;x<r.length;x++){let L=h(x),w=[];for(let q of L)w.push(...b[q]);if(w.length<i)continue;let $=w.join(" ");_.has($)||(_.add($),S.push({chain:w,depth:w.length}))}return S.sort((x,L)=>L.depth-x.depth),S.slice(0,t)}function ko(e,n){let t=k(e,n);if(!t)return[];let s=e.get(`SELECT symbol, enclosing_symbol FROM global_symbols
703
- WHERE id = ? LIMIT 1`,t.symbolId);if(!s)return[];let i=[{symbol:s.symbol,shortName:I(s.symbol),depth:0}],o=s.enclosing_symbol,a=1,r=new Set([s.symbol]);for(;o&&!r.has(o)&&a<20;){r.add(o);let u=e.get("SELECT symbol, enclosing_symbol FROM global_symbols WHERE symbol = ?",o);if(!u)break;i.push({symbol:u.symbol,shortName:I(u.symbol),depth:a}),o=u.enclosing_symbol,a++}if(i.length>1)return i;let l=V(s.symbol);if("kind"in l)return i;let c=l.descriptors;if(c.length<=1)return i;let m=[i[0]];for(let u=c.length-2,d=1;u>=0;u--,d++){let p=c.slice(0,u+1).map(f=>f.suffix==="method"?`${f.name}()`:f.name.replace(/\.(ts|tsx|js|jsx|mjs|cjs|py|pyi|rs|java|scala|kt|kts|rb|go|cs|vb|dart|php|c|cc|cpp|cxx|h|hpp)$/,"")).join(":");m.push({symbol:p,shortName:p,depth:d})}return m}function Oo(e,n){let t=k(e,n);if(!t)return null;let s=he(e,t,{limit:50}),i=tm(ne(e,t,{limit:50}));return{symbol:t.symbol,shortName:I(t.symbol),callers:s.map(o=>({symbol:o.symbol,shortName:I(o.symbol),file:o.file})),callees:i.map(o=>({symbol:o.symbol,shortName:I(o.symbol),file:o.file}))}}function tm(e){let n=new Set,t=[];for(let s of e){let i=`${s.symbol}|${s.file}`;n.has(i)||(n.add(i),t.push(s))}return t}function xt(e,n){let t=new Set;for(let s of e)n.has(s)&&t.add(s);return t}function It(e,n){let t=new Set;for(let s of e)n.has(s)||t.add(s);return t}function $o(e,n){if(e.size===0&&n.size===0)return 0;let t=0;for(let i of e)n.has(i)&&(t+=1);let s=e.size+n.size-t;return s===0?0:t/s}function Gn(e){let n=e.length;if(n===0)return new Map;let t=new Map;for(let i of e)for(let o of i)t.set(o,(t.get(o)??0)+1);let s=new Map;for(let[i,o]of t)s.set(i,Math.log(n/o));return s}function nm(e){let n=[...e.values()].sort((s,i)=>s-i);if(n.length===0)return 0;let t=Math.floor(n.length/2);return n.length%2===0?(n[t-1]+n[t])/2:n[t]}function Po(e,n,t){let s=xt(e,n);if(s.size===0)return{similarity:0,significantShared:[],trivialShared:[]};let i=0,o=0,a=0,r=new Set([...e,...n]);for(let g of r){let p=t.get(g)??0,f=e.has(g)?p:0,y=n.has(g)?p:0;i+=f*y,o+=f*f,a+=y*y}let l=Math.sqrt(o)*Math.sqrt(a),c=l>0?i/l:0,m=nm(t),u=[],d=[];for(let g of s)(t.get(g)??0)>=m?u.push(g):d.push(g);return u.sort((g,p)=>(t.get(p)??0)-(t.get(g)??0)),{similarity:c,significantShared:u,trivialShared:d}}function Mo(e,n,t={}){let{minSimilarity:s=.4,limit:i=20}=t,o=im(e,n);if(!o)return[];if(!j(o.symbol))return[];let a=sm(e,o,s);return a.length>0?a.slice(0,i):om(e,n,{minSimilarity:s,limit:i})}function sm(e,n,t){let s=To(e,{minCallees:3,excludeSymbol:n.symbol}),i=Gn([n,...s].map(a=>a.callees)),o=[];for(let a of s){if(a.callees.size<3)continue;let r=Fo(n,a,i,{minSimilarity:t,requireSignificantShared:1,requireSharedCount:0});r&&o.push(r)}return o.sort((a,r)=>r.similarity-a.similarity),o}function Fo(e,n,t,s){let{similarity:i,significantShared:o}=Po(e.callees,n.callees,t);if(i<s.minSimilarity)return null;let a=xt(e.callees,n.callees).size;if(o.length<s.requireSignificantShared&&a<s.requireSharedCount)return null;let r=o.length>0?o:[...xt(e.callees,n.callees)];return{symbolA:e.symbol,shortNameA:I(e.symbol),fileA:e.file,symbolB:n.symbol,shortNameB:I(n.symbol),fileB:n.file,similarity:i,sharedCallees:r.map(I),uniqueToA:[...It(e.callees,n.callees)].map(I),uniqueToB:[...It(n.callees,e.callees)].map(I)}}function on(e,n={}){let{minSimilarity:t=.5,limit:s=20,scope:i,minCallees:o=4,crossFileOnly:a=!1}=n,r=To(e,{minCallees:o,scope:i}),l=Gn(r.map(p=>p.callees)),c=new Map;for(let p of r)for(let f of p.callees)c.set(f,(c.get(f)??0)+1);let m=Math.max(8,Math.ceil(Math.sqrt(r.length))),u=new Map;for(let p=0;p<r.length;p+=1)for(let f of r[p].callees){if((c.get(f)??0)>m)continue;let y=u.get(f);y||(y=[],u.set(f,y)),y.push(p)}let d=[],g=new Set;e:for(let p=0;p<r.length;p+=1){let f=r[p],y=new Set;for(let h of f.callees){let b=u.get(h);if(b)for(let _ of b)_>p&&y.add(_)}for(let h of y){let b=`${p}|${h}`;if(g.has(b))continue;g.add(b);let _=r[h];if(a&&f.file===_.file)continue;if(f.paramCount>=0&&_.paramCount>=0){let x=Math.abs(f.paramCount-_.paramCount),L=Math.max(2,Math.ceil(Math.max(f.paramCount,_.paramCount)*.5));if(x>L)continue}let S=Fo(f,_,l,{minSimilarity:t,requireSignificantShared:2,requireSharedCount:4});if(S&&(d.push(S),d.length>s*5))break e}}return d.sort((p,f)=>f.similarity-p.similarity),d.slice(0,s)}function im(e,n){let t=k(e,n);if(!t)return null;let s=ne(e,t);return{symbol:t.symbol,file:t.relativePath,callees:new Set(s.map(i=>i.symbol)),paramCount:Pn(e,t.relativePath,t.startLine,t.endLine)?.paramCount??-1}}function To(e,n){let{minCallees:t,scope:s,excludeSymbol:i}=n,o=Y(e,s).filter(r=>!e.isIgnored(r.relativePath)).filter(r=>r.isFunctionLike).filter(r=>i===void 0||r.symbol!==i).filter(r=>r.endLine-r.startLine+1>=5).filter(r=>U(r.relativePath)!=="test").filter(r=>!G(r.symbol)).filter(r=>!pe(e,r.relativePath,r.startLine)),a=se(e,o);return o.map(r=>({symbol:r.symbol,file:r.relativePath,callees:new Set((a.get(r.symbolId)??[]).map(l=>l.symbol)),paramCount:Pn(e,r.relativePath,r.startLine,r.endLine)?.paramCount??-1})).filter(r=>r.callees.size>=t)}function om(e,n,t){let s=rm(e,n);if(!s||s.tokens.size<3)return[];let i=t.minSimilarity>=.5?t.minSimilarity:.3,o=[];for(let a of lm(e)){if(a.symbol===s.symbol||a.tokens.size<3)continue;let r=xt(s.tokens,a.tokens);if(r.size<2)continue;let l=new Set([...s.tokens,...a.tokens]),c=l.size>0?r.size/l.size:0;c<i||o.push({symbolA:s.symbol,shortNameA:I(s.symbol),fileA:s.file,symbolB:a.symbol,shortNameB:I(a.symbol),fileB:a.file,similarity:c,sharedCallees:[...r].sort(),uniqueToA:[...It(s.tokens,a.tokens)].sort(),uniqueToB:[...It(a.tokens,s.tokens)].sort()})}return o.sort((a,r)=>r.similarity-a.similarity||a.shortNameB.localeCompare(r.shortNameB)),o.slice(0,t.limit)}function rm(e,n){let t=k(e,n);if(!t||!j(t.symbol))return null;let s=am(e,t);return s?{symbol:t.symbol,file:t.relativePath,tokens:s}:null}function am(e,n){let t=F(n.symbol),s=Ao(e,n.relativePath,n.startLine,n.endLine,t),i=jo(s,t);return i.size>0?i:null}function lm(e){return Z(e).filter(n=>n.isFunctionLike).filter(n=>U(n.relativePath)!=="test").filter(n=>!G(n.symbol)).map(n=>({symbol:n.symbol,file:n.relativePath,tokens:jo(Ao(e,n.relativePath,n.startLine,n.endLine,n.leaf),n.leaf)})).filter(n=>n.tokens.size>0)}function Ao(e,n,t,s,i){let o=M(e,n);if(!o)return"";let a=o.split(`
702
+ LIMIT ?`,i,o,t).filter(c=>!e.isIgnored(c.defined_in)).map(c=>({symbol:c.symbol,shortName:I(c.symbol),fanIn:c.fan_in,fanOut:c.fan_out,score:c.fan_in*c.fan_out,definedIn:c.defined_in}));return l.length>0?l:Ku(e,s,{minFanIn:i,minFanOut:o,limit:t})}function Ku(e,n,t){let{minFanIn:s,minFanOut:i,limit:o}=t;return Z(e,{scope:n}).filter(r=>!e.isIgnored(r.relativePath)).map(r=>Qu(e,r)).filter(r=>r.fanIn>=s&&r.fanOut>=i).sort((r,l)=>l.score-r.score||l.fanIn-r.fanIn).slice(0,o)}function Qu(e,n){let t=new Set(he(e,n,{limit:500}).map(i=>i.file)).size,s=new Set(ne(e,n,{limit:500}).filter(i=>i.file!==n.relativePath).map(i=>`${i.symbol}|${i.file}`)).size;return{symbol:n.symbol,shortName:I(n.symbol),fanIn:t,fanOut:s,score:t*s,definedIn:n.relativePath}}function sn(e,n={}){let{scope:t,minLoc:s=3}=n,o=Y(e,t).filter(p=>!e.isIgnored(p.relativePath)).filter(p=>!ve(e,p.relativePath)).filter(p=>p.isFunctionLike).filter(p=>!Ye(p.symbol)).filter(p=>!G(p.symbol)).filter(p=>p.endLine-p.startLine+1>=s),a=ye(e,o),r=ot(e,o),l=new Set([...a.keys(),...r.keys()]),c=new Map;for(let p of o){let f=F(p.symbol);if(!f)continue;let y=c.get(f)??[];y.push(p.symbolId),c.set(f,y)}let m=e.all(`SELECT relative_path FROM documents WHERE 1 = 1 ${e.pathExclusionsFor("documents")}`);for(let p of m){if(e.isIgnored(p.relative_path)||P(p.relative_path)!=="rust")continue;let f=we(e,p.relative_path);for(let y of f){let h=c.get(y);if(h)for(let b of h)l.add(b)}}let u=new Map(o.map(p=>[p.symbolId,p.symbol])),d=se(e,o,{additive:!0}),g=new Set([...d.entries()].filter(([p,f])=>{let y=u.get(p);return f.some(h=>h.symbol!==y)}).map(([p])=>p));return o.filter(p=>!l.has(p.symbolId)).filter(p=>!g.has(p.symbolId)).sort((p,f)=>f.endLine-f.startLine-(p.endLine-p.startLine)||p.relativePath.localeCompare(f.relativePath)||p.startLine-f.startLine).map(p=>({symbol:p.symbol,shortName:I(p.symbol),relativePath:p.relativePath,startLine:p.startLine,endLine:p.endLine,loc:p.endLine-p.startLine+1}))}var Vn={0:"UnspecifiedKind",1:"AbstractMethod",2:"Accessor",3:"Array",4:"Assertion",5:"AssociatedType",6:"Attribute",7:"Axiom",8:"Boolean",9:"Class",10:"Constant",11:"Constructor",12:"Contract",13:"DataFamily",14:"DefinitionMacro",15:"Delegate",16:"Enum",17:"EnumMember",18:"Error",19:"Event",20:"Fact",21:"Field",22:"File",23:"Function",24:"Getter",25:"Grammar",26:"Instance",27:"Interface",28:"Key",29:"Lang",30:"Lemma",31:"Library",32:"Macro",33:"Method",34:"MethodAlias",35:"MethodReceiver",36:"MethodSpecification",37:"Message",38:"Modifier",39:"Module",40:"Namespace",41:"Null",42:"Number",43:"Object",44:"Operator",45:"Package",46:"PackageObject",47:"Parameter",48:"ParameterLabel",49:"Pattern",50:"Predicate",51:"Property",52:"Protocol",53:"ProtocolMethod",54:"PureVirtualMethod",55:"Quasiquoter",56:"SelfParameter",57:"Setter",58:"Signature",59:"SingletonClass",60:"SingletonMethod",61:"StaticDataMember",62:"StaticEvent",63:"StaticField",64:"StaticMethod",65:"StaticProperty",66:"StaticVariable",67:"String",68:"Struct",69:"Subscript",70:"Tactic",71:"Theorem",72:"ThisParameter",73:"Trait",74:"TraitMethod",75:"Type",76:"TypeAlias",77:"TypeClass",78:"TypeClassMethod",79:"TypeFamily",80:"TypeParameter",81:"Union",82:"Value",83:"Variable"},zn=new Map;for(let[e,n]of Object.entries(Vn))zn.set(n.toLowerCase(),Number(e));function Xu(e){let n=parseInt(e,10);if(!isNaN(n))return n;let t=e.toLowerCase(),s=zn.get(t);if(s!==void 0)return s;for(let[i,o]of zn)if(i.includes(t))return o;return null}function Ro(e,n,t={}){let{scope:s,limit:i=100}=t,o=Xu(n);return o===null?[]:wo(e,s).map(r=>({row:r,resolvedKind:Do(r)})).filter(r=>r.resolvedKind===o).slice(0,i).map(({row:r,resolvedKind:l})=>({symbol:r.symbol,shortName:I(r.symbol),kind:l,kindName:Vn[l]??"Unknown",relativePath:r.relative_path,startLine:r.start_line,endLine:r.end_line}))}function Lo(e,n={}){let t=new Map;for(let s of wo(e,n.scope)){let i=Do(s);i===null||i===0||t.set(i,(t.get(i)??0)+1)}return[...t.entries()].sort((s,i)=>i[1]-s[1]||s[0]-i[0]).map(([s,i])=>({kind:s,kindName:Vn[s]??"Unknown",count:i}))}function wo(e,n){return Z(e,{scope:n}).map(Zu)}function Zu(e){return{symbol:e.symbol,kind:e.kind,documentation:e.documentation,enclosing_symbol:e.enclosingSymbol,relative_path:e.relativePath,start_line:e.startLine,end_line:e.endLine}}function Do(e){return e.kind!==null&&e.kind!==0?em(e.kind,e.symbol,e.documentation):tm(e.symbol,e.documentation,e.enclosing_symbol)}function em(e,n,t){let s=(t??"").toLowerCase();if(ie(n)==="type"){if(s.includes("type "))return 76;if(s.includes("interface "))return 27;if(s.includes("struct "))return 68;if(s.includes("trait "))return 73;if(s.includes("class "))return 9}return e}function tm(e,n,t){let s=V(e);if("kind"in s)return null;let i=s.descriptors,o=i[i.length-2]??null,a=ie(e),r=(n??"").toLowerCase();return a==="type"?r.includes("type ")?76:r.includes("interface ")?27:r.includes("struct ")?68:r.includes("trait ")?73:(r.includes("class "),9):a==="method"?o?.suffix==="type"?33:23:a==="namespace"?39:a!=="term"?null:r.includes("async def ")||r.includes("def ")?23:(t?ie(t):o?.suffix??null)==="type"?21:83}function ko(e,n={}){let{limit:t=10,scope:s,minDepth:i=3}=n,o=K(e,s),a=new Map,r=[],l=new Map,c=new Map,m=new Set,u=[],d=0;for(let x of o.keys()){if(l.has(x))continue;let L=[],w=(o.get(x)??new Set).values();for(l.set(x,d),c.set(x,d),d+=1,u.push(x),m.add(x),L.push({node:x,iter:w,pendingChild:null});L.length>0;){let $=L[L.length-1];if($.pendingChild!==null){let T=$.pendingChild;$.pendingChild=null,c.set($.node,Math.min(c.get($.node),c.get(T)))}let q=$.iter.next();if(q.done){if(c.get($.node)===l.get($.node)){let T=[];for(;;){let _e=u.pop();if(m.delete(_e),T.push(_e),a.set(_e,r.length),_e===$.node)break}r.push(T)}L.pop();continue}let B=q.value;if(l.has(B))m.has(B)&&c.set($.node,Math.min(c.get($.node),l.get(B)));else{l.set(B,d),c.set(B,d),d+=1,u.push(B),m.add(B);let T=(o.get(B)??new Set).values();$.pendingChild=B,L.push({node:B,iter:T,pendingChild:null})}}}let g=new Map,p=new Array(r.length);for(let x=0;x<r.length;x++)p[x]=r[x].length,g.set(x,new Set);for(let[x,L]of o){let w=a.get(x);for(let $ of L){let q=a.get($);q!==w&&g.get(w).add(q)}}let f=new Array(r.length),y=new Array(r.length);for(let x=0;x<r.length;x++){let L=[],w=0;for(let $ of g.get(x)){let q=y[$];q>w&&(w=q,L=f[$])}f[x]=[x,...L],y[x]=p[x]+w}function h(x){return f[x]}let b=r.map(x=>[...x].sort()),_=new Set,S=[];for(let x=0;x<r.length;x++){let L=h(x),w=[];for(let q of L)w.push(...b[q]);if(w.length<i)continue;let $=w.join(" ");_.has($)||(_.add($),S.push({chain:w,depth:w.length}))}return S.sort((x,L)=>L.depth-x.depth),S.slice(0,t)}function Oo(e,n){let t=k(e,n);if(!t)return[];let s=e.get(`SELECT symbol, enclosing_symbol FROM global_symbols
703
+ WHERE id = ? LIMIT 1`,t.symbolId);if(!s)return[];let i=[{symbol:s.symbol,shortName:I(s.symbol),depth:0}],o=s.enclosing_symbol,a=1,r=new Set([s.symbol]);for(;o&&!r.has(o)&&a<20;){r.add(o);let u=e.get("SELECT symbol, enclosing_symbol FROM global_symbols WHERE symbol = ?",o);if(!u)break;i.push({symbol:u.symbol,shortName:I(u.symbol),depth:a}),o=u.enclosing_symbol,a++}if(i.length>1)return i;let l=V(s.symbol);if("kind"in l)return i;let c=l.descriptors;if(c.length<=1)return i;let m=[i[0]];for(let u=c.length-2,d=1;u>=0;u--,d++){let p=c.slice(0,u+1).map(f=>f.suffix==="method"?`${f.name}()`:f.name.replace(/\.(ts|tsx|js|jsx|mjs|cjs|py|pyi|rs|java|scala|kt|kts|rb|go|cs|vb|dart|php|c|cc|cpp|cxx|h|hpp)$/,"")).join(":");m.push({symbol:p,shortName:p,depth:d})}return m}function $o(e,n){let t=k(e,n);if(!t)return null;let s=he(e,t,{limit:50}),i=nm(ne(e,t,{limit:50}));return{symbol:t.symbol,shortName:I(t.symbol),callers:s.map(o=>({symbol:o.symbol,shortName:I(o.symbol),file:o.file})),callees:i.map(o=>({symbol:o.symbol,shortName:I(o.symbol),file:o.file}))}}function nm(e){let n=new Set,t=[];for(let s of e){let i=`${s.symbol}|${s.file}`;n.has(i)||(n.add(i),t.push(s))}return t}function xt(e,n){let t=new Set;for(let s of e)n.has(s)&&t.add(s);return t}function It(e,n){let t=new Set;for(let s of e)n.has(s)||t.add(s);return t}function Po(e,n){if(e.size===0&&n.size===0)return 0;let t=0;for(let i of e)n.has(i)&&(t+=1);let s=e.size+n.size-t;return s===0?0:t/s}function Gn(e){let n=e.length;if(n===0)return new Map;let t=new Map;for(let i of e)for(let o of i)t.set(o,(t.get(o)??0)+1);let s=new Map;for(let[i,o]of t)s.set(i,Math.log(n/o));return s}function sm(e){let n=[...e.values()].sort((s,i)=>s-i);if(n.length===0)return 0;let t=Math.floor(n.length/2);return n.length%2===0?(n[t-1]+n[t])/2:n[t]}function Mo(e,n,t){let s=xt(e,n);if(s.size===0)return{similarity:0,significantShared:[],trivialShared:[]};let i=0,o=0,a=0,r=new Set([...e,...n]);for(let g of r){let p=t.get(g)??0,f=e.has(g)?p:0,y=n.has(g)?p:0;i+=f*y,o+=f*f,a+=y*y}let l=Math.sqrt(o)*Math.sqrt(a),c=l>0?i/l:0,m=sm(t),u=[],d=[];for(let g of s)(t.get(g)??0)>=m?u.push(g):d.push(g);return u.sort((g,p)=>(t.get(p)??0)-(t.get(g)??0)),{similarity:c,significantShared:u,trivialShared:d}}function Fo(e,n,t={}){let{minSimilarity:s=.4,limit:i=20}=t,o=om(e,n);if(!o)return[];if(!j(o.symbol))return[];let a=im(e,o,s);return a.length>0?a.slice(0,i):rm(e,n,{minSimilarity:s,limit:i})}function im(e,n,t){let s=Ao(e,{minCallees:3,excludeSymbol:n.symbol}),i=Gn([n,...s].map(a=>a.callees)),o=[];for(let a of s){if(a.callees.size<3)continue;let r=To(n,a,i,{minSimilarity:t,requireSignificantShared:1,requireSharedCount:0});r&&o.push(r)}return o.sort((a,r)=>r.similarity-a.similarity),o}function To(e,n,t,s){let{similarity:i,significantShared:o}=Mo(e.callees,n.callees,t);if(i<s.minSimilarity)return null;let a=xt(e.callees,n.callees).size;if(o.length<s.requireSignificantShared&&a<s.requireSharedCount)return null;let r=o.length>0?o:[...xt(e.callees,n.callees)];return{symbolA:e.symbol,shortNameA:I(e.symbol),fileA:e.file,symbolB:n.symbol,shortNameB:I(n.symbol),fileB:n.file,similarity:i,sharedCallees:r.map(I),uniqueToA:[...It(e.callees,n.callees)].map(I),uniqueToB:[...It(n.callees,e.callees)].map(I)}}function on(e,n={}){let{minSimilarity:t=.5,limit:s=20,scope:i,minCallees:o=4,crossFileOnly:a=!1}=n,r=Ao(e,{minCallees:o,scope:i}),l=Gn(r.map(p=>p.callees)),c=new Map;for(let p of r)for(let f of p.callees)c.set(f,(c.get(f)??0)+1);let m=Math.max(8,Math.ceil(Math.sqrt(r.length))),u=new Map;for(let p=0;p<r.length;p+=1)for(let f of r[p].callees){if((c.get(f)??0)>m)continue;let y=u.get(f);y||(y=[],u.set(f,y)),y.push(p)}let d=[],g=new Set;e:for(let p=0;p<r.length;p+=1){let f=r[p],y=new Set;for(let h of f.callees){let b=u.get(h);if(b)for(let _ of b)_>p&&y.add(_)}for(let h of y){let b=`${p}|${h}`;if(g.has(b))continue;g.add(b);let _=r[h];if(a&&f.file===_.file)continue;if(f.paramCount>=0&&_.paramCount>=0){let x=Math.abs(f.paramCount-_.paramCount),L=Math.max(2,Math.ceil(Math.max(f.paramCount,_.paramCount)*.5));if(x>L)continue}let S=To(f,_,l,{minSimilarity:t,requireSignificantShared:2,requireSharedCount:4});if(S&&(d.push(S),d.length>s*5))break e}}return d.sort((p,f)=>f.similarity-p.similarity),d.slice(0,s)}function om(e,n){let t=k(e,n);if(!t)return null;let s=ne(e,t);return{symbol:t.symbol,file:t.relativePath,callees:new Set(s.map(i=>i.symbol)),paramCount:Pn(e,t.relativePath,t.startLine,t.endLine)?.paramCount??-1}}function Ao(e,n){let{minCallees:t,scope:s,excludeSymbol:i}=n,o=Y(e,s).filter(r=>!e.isIgnored(r.relativePath)).filter(r=>r.isFunctionLike).filter(r=>i===void 0||r.symbol!==i).filter(r=>r.endLine-r.startLine+1>=5).filter(r=>U(r.relativePath)!=="test").filter(r=>!G(r.symbol)).filter(r=>!pe(e,r.relativePath,r.startLine)),a=se(e,o);return o.map(r=>({symbol:r.symbol,file:r.relativePath,callees:new Set((a.get(r.symbolId)??[]).map(l=>l.symbol)),paramCount:Pn(e,r.relativePath,r.startLine,r.endLine)?.paramCount??-1})).filter(r=>r.callees.size>=t)}function rm(e,n,t){let s=am(e,n);if(!s||s.tokens.size<3)return[];let i=t.minSimilarity>=.5?t.minSimilarity:.3,o=[];for(let a of cm(e)){if(a.symbol===s.symbol||a.tokens.size<3)continue;let r=xt(s.tokens,a.tokens);if(r.size<2)continue;let l=new Set([...s.tokens,...a.tokens]),c=l.size>0?r.size/l.size:0;c<i||o.push({symbolA:s.symbol,shortNameA:I(s.symbol),fileA:s.file,symbolB:a.symbol,shortNameB:I(a.symbol),fileB:a.file,similarity:c,sharedCallees:[...r].sort(),uniqueToA:[...It(s.tokens,a.tokens)].sort(),uniqueToB:[...It(a.tokens,s.tokens)].sort()})}return o.sort((a,r)=>r.similarity-a.similarity||a.shortNameB.localeCompare(r.shortNameB)),o.slice(0,t.limit)}function am(e,n){let t=k(e,n);if(!t||!j(t.symbol))return null;let s=lm(e,t);return s?{symbol:t.symbol,file:t.relativePath,tokens:s}:null}function lm(e,n){let t=F(n.symbol),s=jo(e,n.relativePath,n.startLine,n.endLine,t),i=Bo(s,t);return i.size>0?i:null}function cm(e){return Z(e).filter(n=>n.isFunctionLike).filter(n=>U(n.relativePath)!=="test").filter(n=>!G(n.symbol)).map(n=>({symbol:n.symbol,file:n.relativePath,tokens:Bo(jo(e,n.relativePath,n.startLine,n.endLine,n.leaf),n.leaf)})).filter(n=>n.tokens.size>0)}function jo(e,n,t,s,i){let o=M(e,n);if(!o)return"";let a=o.split(`
704
704
  `);if(s>=t&&s-t<=12)return a.slice(t,s+1).join(`
705
- `);let r=[new RegExp(`\\bdef\\s+${Nt(i)}\\b`),new RegExp(`\\bfun\\s+${Nt(i)}\\b`),new RegExp(`\\bfn\\s+${Nt(i)}\\b`),new RegExp(`\\bfunction\\s+${Nt(i)}\\b`),new RegExp(`\\b${Nt(i)}\\s*\\(`)],l=a.findIndex(c=>r.some(m=>m.test(c)));if(l>=0){let c=l;for(let m=l+1;m<a.length&&m<=l+8;m++){let u=a[m]??"";if(m>l&&um(u)||(c=m,u.trim()===""&&m>l+1))break}return a.slice(l,c+1).join(`
705
+ `);let r=[new RegExp(`\\bdef\\s+${Nt(i)}\\b`),new RegExp(`\\bfun\\s+${Nt(i)}\\b`),new RegExp(`\\bfn\\s+${Nt(i)}\\b`),new RegExp(`\\bfunction\\s+${Nt(i)}\\b`),new RegExp(`\\b${Nt(i)}\\s*\\(`)],l=a.findIndex(c=>r.some(m=>m.test(c)));if(l>=0){let c=l;for(let m=l+1;m<a.length&&m<=l+8;m++){let u=a[m]??"";if(m>l&&mm(u)||(c=m,u.trim()===""&&m>l+1))break}return a.slice(l,c+1).join(`
706
706
  `)}return a.slice(t,Math.min(a.length,t+8)).join(`
707
- `)}function jo(e,n){if(!e)return new Set;let t=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=cm(n),o=e.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(a=>a.trim()).filter(a=>a.length>1).filter(a=>!t.has(a)).filter(a=>!s.has(a));return new Set(o)}function cm(e){return new Set(e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").split(/[^A-Za-z0-9_]+|_/).map(n=>n.toLowerCase()).filter(n=>n.length>1))}function um(e){return/^\s*(?:def|fun|fn|function|class|trait|module|object|enum|interface|public|private|protected)\b/.test(e)}function Nt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Wo(e,n={}){let{minSimilarity:t=.5,limit:s=20,scope:i,filePattern:o}=n,a=n.minDeps??(o?1:3),r=mm(e,{scope:i,minDeps:a}),l=[];if(o){let c=r.find(m=>m.file.includes(o));if(!c)return[];for(let m of r){if(m.file===c.file)continue;let u=Bo(c,m,t);u&&l.push(u)}}else for(let c=0;c<r.length;c++){for(let m=c+1;m<r.length;m++){let u=Bo(r[c],r[m],t);u&&l.push(u)}if(l.length>s*5)break}return l.sort((c,m)=>m.similarity-c.similarity),l.slice(0,s)}function mm(e,n){let{scope:t,minDeps:s}=n,i=K(e,t),o=dm(i),a=[];for(let[r,l]of i)l.size>=s&&a.push({file:r,deps:new Set([...l].filter(c=>!o.has(c)))});return a}function dm(e){let n=new Set,t=e.size;if(t===0)return n;let s=new Map;for(let i of e.values())for(let o of i)s.set(o,(s.get(o)??0)+1);for(let[i,o]of s)o>=5&&o/t>.3&&n.add(i);return n}function Bo(e,n,t){let s=new Set;for(let r of e.deps)n.deps.has(r)&&s.add(r);if(s.size<3||e.deps.size<4||n.deps.size<4)return null;let i=$o(e.deps,n.deps);if(i<t)return null;let o=[];for(let r of e.deps)n.deps.has(r)||o.push(r);let a=[];for(let r of n.deps)e.deps.has(r)||a.push(r);return{fileA:e.file,fileB:n.file,similarity:i,sharedDeps:[...s],uniqueToA:o,uniqueToB:a}}function Jo(e,n={}){let{minSimilarity:t=.5,limit:s=15,scope:i,minChainLength:o=3,maxChainLength:a=8}=n,r=K(e,i),l=pm(r,o,a);if(l.length===0)return[];let c=new Map,m=new Map;for(let b of l){let _=new Set;for(let S of b)_.has(S)||(c.set(S,(c.get(S)??0)+1),_.add(S));for(let S=Math.max(0,b.length-2);S<b.length;S++)m.set(b[S],(m.get(b[S])??0)+1)}let u=l.length*.9,d=l.length*.8,g=new Set;for(let[b,_]of c)_>u&&g.add(b);for(let[b,_]of m)_>d&&g.add(b);let p=["index.ts","index.js","cli.ts","main.ts","health.ts","health.js"];for(let b of c.keys()){let _=b.split("/").pop()??"";p.includes(_)&&g.add(b)}let f=[];for(let b of l){let _=b.filter(S=>!g.has(S));_.length>=2&&f.push({original:b,filtered:_})}if(f.length<2)return[];let y=[];for(let b=0;b<f.length;b++){for(let _=b+1;_<f.length;_++){let S=f[b],x=f[_],L=new Set(S.filtered),w=!1;for(let ce of x.filtered)if(L.has(ce)){w=!0;break}if(!w)continue;let{distance:$,ops:q}=fm(S.filtered,x.filtered),B=Math.max(S.filtered.length,x.filtered.length);if(B===0)continue;let T=1-$/B;if(T<t||$===0)continue;let _e=q.filter(ce=>ce.type==="substitute").map(ce=>({index:ce.indexA,nodeA:S.filtered[ce.indexA],nodeB:x.filtered[ce.indexB]}));if(_e.length===0||q.filter(ce=>ce.type==="match").length<2)continue;let Et=gm(S.original,x.original),bn=hm(S.original,x.original);y.push({chainA:S.original,chainB:x.original,similarity:T,editDistance:$,divergencePoints:_e,commonPrefix:Et,commonSuffix:bn})}if(y.length>s*10)break}y.sort((b,_)=>Math.abs(_.similarity-b.similarity)>.01?_.similarity-b.similarity:b.divergencePoints.length-_.divergencePoints.length);let h=[];for(let b of y)if(h.some(S=>Ho(b.chainA,S.chainA)&&Ho(b.chainB,S.chainB))||h.push(b),h.length>=s)break;return h}function pm(e,n,t){let s=[];for(let o of e.keys()){if(s.length>=500)break;Uo(e,o,[o],new Set([o]),n,t,s,500)}return s}function Uo(e,n,t,s,i,o,a,r){if(a.length>=r)return;if(t.length>=o){t.length>=i&&a.push([...t]);return}let l=e.get(n);if(!l||l.size===0){t.length>=i&&a.push([...t]);return}let c=!1;for(let m of l)if(!s.has(m)&&(s.add(m),t.push(m),Uo(e,m,t,s,i,o,a,r),t.pop(),s.delete(m),c=!0,a.length>=r))return;!c&&t.length>=i&&a.push([...t])}function fm(e,n){let t=e.length,s=n.length,i=Array.from({length:t+1},()=>Array(s+1).fill(0));for(let l=0;l<=t;l++)i[l][0]=l;for(let l=0;l<=s;l++)i[0][l]=l;for(let l=1;l<=t;l++)for(let c=1;c<=s;c++)e[l-1]===n[c-1]?i[l][c]=i[l-1][c-1]:i[l][c]=1+Math.min(i[l-1][c],i[l][c-1],i[l-1][c-1]);let o=[],a=t,r=s;for(;a>0||r>0;)a>0&&r>0&&e[a-1]===n[r-1]?(o.unshift({type:"match",indexA:a-1,indexB:r-1}),a--,r--):a>0&&r>0&&i[a][r]===i[a-1][r-1]+1?(o.unshift({type:"substitute",indexA:a-1,indexB:r-1}),a--,r--):r>0&&i[a][r]===i[a][r-1]+1?(o.unshift({type:"insert",indexA:a,indexB:r-1}),r--):(o.unshift({type:"delete",indexA:a-1,indexB:r}),a--);return{distance:i[t][s],ops:o}}function gm(e,n){let t=[];for(let s=0;s<Math.min(e.length,n.length)&&e[s]===n[s];s++)t.push(e[s]);return t}function hm(e,n){let t=[],s=e.length-1,i=n.length-1;for(;s>=0&&i>=0&&e[s]===n[i];)t.unshift(e[s]),s--,i--;return t}function Ho(e,n){if(e.length>n.length)return!1;let t=n.join("\u2192"),s=e.join("\u2192");return t.includes(s)}function an(e,n={}){let{scope:t,minLoc:s=10,minCallees:i=6,limit:o=20}=n,a=Y(e,t).filter(c=>!e.isIgnored(c.relativePath)).filter(c=>rn(c)>=s&&j(c.symbol)).filter(c=>!(c.relativePath.split("/").pop()??"").includes("types")).filter(c=>U(c.relativePath)!=="test").filter(c=>!G(c.symbol)).filter(c=>!pe(e,c.relativePath,c.startLine)).sort((c,m)=>rn(m)-rn(c)),r=se(e,a),l=[];for(let c of a){let m=r.get(c.symbolId)??[],u=new Set(m.map(h=>h.symbol));if(u.size<i)continue;let d=new Map;for(let h of u)d.set(h,new Set);let g=new Map;for(let h of m)g.has(h.chunkId)||g.set(h.chunkId,new Set),g.get(h.chunkId).add(h.symbol);for(let h of g.values()){let b=[...h];for(let _=0;_<b.length;_++)for(let S=_+1;S<b.length;S++)d.get(b[_]).add(b[S]),d.get(b[S]).add(b[_])}let p=new Set,f=[];for(let h of u){if(p.has(h))continue;let b=new Set,_=[h];for(;_.length>0;){let S=_.pop();if(!p.has(S)){p.add(S),b.add(S);for(let x of d.get(S)??[])p.has(x)||_.push(x)}}f.push(b)}if(f.length<2)continue;let y=f.filter(h=>h.size>=3).map(h=>{let b=new Set;for(let L of f)if(L!==h)for(let w of L)b.add(w);let _=0;for(let L of h)for(let w of d.get(L)??[])b.has(w)&&_++;let S=h.size*b.size,x=S>0?1-_/S:1;return{callees:[...h].map(I),isolation:x}}).filter(h=>h.isolation>.5).sort((h,b)=>b.isolation-h.isolation);y.length>0&&l.push({symbol:c.symbol,shortName:I(c.symbol),relativePath:c.relativePath,startLine:c.startLine,endLine:c.endLine,loc:rn(c),totalCallees:u.size,clusters:y})}return l.sort((c,m)=>m.clusters.length-c.clusters.length||m.loc-c.loc),l.slice(0,o)}function rn(e){return e.endLine-e.startLine+1}function qo(e,n,t={}){let{maxDepth:s=5,scope:i}=t,o=k(e,n);if(!o)return[];let a=[],r=new Set([o.symbolId]),l=new Set,c=[o];for(let m=1;m<=s&&c.length!==0;m++){let u=[];for(let d of c)for(let g of ym(e,d,i)){let p=`${g.file}|${g.shortName}`;if(g.symbolId!==null){if(r.has(g.symbolId))continue;r.add(g.symbolId)}else if(l.has(p))continue;l.add(p),a.push({symbol:g.symbol,shortName:g.shortName,file:g.file,depth:m}),g.symbolId!==null&&g.symbolMatch&&u.push(g.symbolMatch)}c=u}return a.sort((m,u)=>m.depth-u.depth||m.file.localeCompare(u.file)),a}function ym(e,n,t){let s=he(e,n,{limit:500}).filter(m=>!e.isIgnored(m.file)).filter(m=>!t||m.file.includes(t)),i=new Set(s.map(m=>m.file)),o=ye(e).get(n.symbolId)??new Set,a=[];for(let m of o){if(i.has(m)||e.isIgnored(m)||t&&!m.includes(t))continue;let u=A(e,m),d=u.length>0?fe(u,u[0].startLine):null;a.push({symbol:d?.symbol??m,file:m})}let r=[...s,...a],l=[],c=new Set;for(let m of r){let u=Xe(e,m.symbol);if(!u){let g=`${m.file}|${m.symbol}`;if(c.has(g))continue;c.add(g),l.push({symbolId:null,symbol:m.symbol,shortName:I(m.symbol),file:m.file,symbolMatch:null});continue}if(u.symbolId===n.symbolId||e.isIgnored(u.relativePath))continue;let d=`${u.symbolId}|${u.relativePath}`;c.has(d)||(c.add(d),l.push({symbolId:u.symbolId,symbol:u.symbol,shortName:I(u.symbol),file:u.relativePath,symbolMatch:u}))}return l}function zo(e,n){let t=ee(e,n);if(!t)return null;let s=e.get(`SELECT id, relative_path FROM documents
707
+ `)}function Bo(e,n){if(!e)return new Set;let t=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=um(n),o=e.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(a=>a.trim()).filter(a=>a.length>1).filter(a=>!t.has(a)).filter(a=>!s.has(a));return new Set(o)}function um(e){return new Set(e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").split(/[^A-Za-z0-9_]+|_/).map(n=>n.toLowerCase()).filter(n=>n.length>1))}function mm(e){return/^\s*(?:def|fun|fn|function|class|trait|module|object|enum|interface|public|private|protected)\b/.test(e)}function Nt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ho(e,n={}){let{minSimilarity:t=.5,limit:s=20,scope:i,filePattern:o}=n,a=n.minDeps??(o?1:3),r=dm(e,{scope:i,minDeps:a}),l=[];if(o){let c=r.find(m=>m.file.includes(o));if(!c)return[];for(let m of r){if(m.file===c.file)continue;let u=Wo(c,m,t);u&&l.push(u)}}else for(let c=0;c<r.length;c++){for(let m=c+1;m<r.length;m++){let u=Wo(r[c],r[m],t);u&&l.push(u)}if(l.length>s*5)break}return l.sort((c,m)=>m.similarity-c.similarity),l.slice(0,s)}function dm(e,n){let{scope:t,minDeps:s}=n,i=K(e,t),o=pm(i),a=[];for(let[r,l]of i)l.size>=s&&a.push({file:r,deps:new Set([...l].filter(c=>!o.has(c)))});return a}function pm(e){let n=new Set,t=e.size;if(t===0)return n;let s=new Map;for(let i of e.values())for(let o of i)s.set(o,(s.get(o)??0)+1);for(let[i,o]of s)o>=5&&o/t>.3&&n.add(i);return n}function Wo(e,n,t){let s=new Set;for(let r of e.deps)n.deps.has(r)&&s.add(r);if(s.size<3||e.deps.size<4||n.deps.size<4)return null;let i=Po(e.deps,n.deps);if(i<t)return null;let o=[];for(let r of e.deps)n.deps.has(r)||o.push(r);let a=[];for(let r of n.deps)e.deps.has(r)||a.push(r);return{fileA:e.file,fileB:n.file,similarity:i,sharedDeps:[...s],uniqueToA:o,uniqueToB:a}}function Uo(e,n={}){let{minSimilarity:t=.5,limit:s=15,scope:i,minChainLength:o=3,maxChainLength:a=8}=n,r=K(e,i),l=fm(r,o,a);if(l.length===0)return[];let c=new Map,m=new Map;for(let b of l){let _=new Set;for(let S of b)_.has(S)||(c.set(S,(c.get(S)??0)+1),_.add(S));for(let S=Math.max(0,b.length-2);S<b.length;S++)m.set(b[S],(m.get(b[S])??0)+1)}let u=l.length*.9,d=l.length*.8,g=new Set;for(let[b,_]of c)_>u&&g.add(b);for(let[b,_]of m)_>d&&g.add(b);let p=["index.ts","index.js","cli.ts","main.ts","health.ts","health.js"];for(let b of c.keys()){let _=b.split("/").pop()??"";p.includes(_)&&g.add(b)}let f=[];for(let b of l){let _=b.filter(S=>!g.has(S));_.length>=2&&f.push({original:b,filtered:_})}if(f.length<2)return[];let y=[];for(let b=0;b<f.length;b++){for(let _=b+1;_<f.length;_++){let S=f[b],x=f[_],L=new Set(S.filtered),w=!1;for(let ce of x.filtered)if(L.has(ce)){w=!0;break}if(!w)continue;let{distance:$,ops:q}=gm(S.filtered,x.filtered),B=Math.max(S.filtered.length,x.filtered.length);if(B===0)continue;let T=1-$/B;if(T<t||$===0)continue;let _e=q.filter(ce=>ce.type==="substitute").map(ce=>({index:ce.indexA,nodeA:S.filtered[ce.indexA],nodeB:x.filtered[ce.indexB]}));if(_e.length===0||q.filter(ce=>ce.type==="match").length<2)continue;let Et=hm(S.original,x.original),bn=ym(S.original,x.original);y.push({chainA:S.original,chainB:x.original,similarity:T,editDistance:$,divergencePoints:_e,commonPrefix:Et,commonSuffix:bn})}if(y.length>s*10)break}y.sort((b,_)=>Math.abs(_.similarity-b.similarity)>.01?_.similarity-b.similarity:b.divergencePoints.length-_.divergencePoints.length);let h=[];for(let b of y)if(h.some(S=>Jo(b.chainA,S.chainA)&&Jo(b.chainB,S.chainB))||h.push(b),h.length>=s)break;return h}function fm(e,n,t){let s=[];for(let o of e.keys()){if(s.length>=500)break;qo(e,o,[o],new Set([o]),n,t,s,500)}return s}function qo(e,n,t,s,i,o,a,r){if(a.length>=r)return;if(t.length>=o){t.length>=i&&a.push([...t]);return}let l=e.get(n);if(!l||l.size===0){t.length>=i&&a.push([...t]);return}let c=!1;for(let m of l)if(!s.has(m)&&(s.add(m),t.push(m),qo(e,m,t,s,i,o,a,r),t.pop(),s.delete(m),c=!0,a.length>=r))return;!c&&t.length>=i&&a.push([...t])}function gm(e,n){let t=e.length,s=n.length,i=Array.from({length:t+1},()=>Array(s+1).fill(0));for(let l=0;l<=t;l++)i[l][0]=l;for(let l=0;l<=s;l++)i[0][l]=l;for(let l=1;l<=t;l++)for(let c=1;c<=s;c++)e[l-1]===n[c-1]?i[l][c]=i[l-1][c-1]:i[l][c]=1+Math.min(i[l-1][c],i[l][c-1],i[l-1][c-1]);let o=[],a=t,r=s;for(;a>0||r>0;)a>0&&r>0&&e[a-1]===n[r-1]?(o.unshift({type:"match",indexA:a-1,indexB:r-1}),a--,r--):a>0&&r>0&&i[a][r]===i[a-1][r-1]+1?(o.unshift({type:"substitute",indexA:a-1,indexB:r-1}),a--,r--):r>0&&i[a][r]===i[a][r-1]+1?(o.unshift({type:"insert",indexA:a,indexB:r-1}),r--):(o.unshift({type:"delete",indexA:a-1,indexB:r}),a--);return{distance:i[t][s],ops:o}}function hm(e,n){let t=[];for(let s=0;s<Math.min(e.length,n.length)&&e[s]===n[s];s++)t.push(e[s]);return t}function ym(e,n){let t=[],s=e.length-1,i=n.length-1;for(;s>=0&&i>=0&&e[s]===n[i];)t.unshift(e[s]),s--,i--;return t}function Jo(e,n){if(e.length>n.length)return!1;let t=n.join("\u2192"),s=e.join("\u2192");return t.includes(s)}function an(e,n={}){let{scope:t,minLoc:s=10,minCallees:i=6,limit:o=20}=n,a=Y(e,t).filter(c=>!e.isIgnored(c.relativePath)).filter(c=>rn(c)>=s&&j(c.symbol)).filter(c=>!(c.relativePath.split("/").pop()??"").includes("types")).filter(c=>U(c.relativePath)!=="test").filter(c=>!G(c.symbol)).filter(c=>!pe(e,c.relativePath,c.startLine)).sort((c,m)=>rn(m)-rn(c)),r=se(e,a),l=[];for(let c of a){let m=r.get(c.symbolId)??[],u=new Set(m.map(h=>h.symbol));if(u.size<i)continue;let d=new Map;for(let h of u)d.set(h,new Set);let g=new Map;for(let h of m)g.has(h.chunkId)||g.set(h.chunkId,new Set),g.get(h.chunkId).add(h.symbol);for(let h of g.values()){let b=[...h];for(let _=0;_<b.length;_++)for(let S=_+1;S<b.length;S++)d.get(b[_]).add(b[S]),d.get(b[S]).add(b[_])}let p=new Set,f=[];for(let h of u){if(p.has(h))continue;let b=new Set,_=[h];for(;_.length>0;){let S=_.pop();if(!p.has(S)){p.add(S),b.add(S);for(let x of d.get(S)??[])p.has(x)||_.push(x)}}f.push(b)}if(f.length<2)continue;let y=f.filter(h=>h.size>=3).map(h=>{let b=new Set;for(let L of f)if(L!==h)for(let w of L)b.add(w);let _=0;for(let L of h)for(let w of d.get(L)??[])b.has(w)&&_++;let S=h.size*b.size,x=S>0?1-_/S:1;return{callees:[...h].map(I),isolation:x}}).filter(h=>h.isolation>.5).sort((h,b)=>b.isolation-h.isolation);y.length>0&&l.push({symbol:c.symbol,shortName:I(c.symbol),relativePath:c.relativePath,startLine:c.startLine,endLine:c.endLine,loc:rn(c),totalCallees:u.size,clusters:y})}return l.sort((c,m)=>m.clusters.length-c.clusters.length||m.loc-c.loc),l.slice(0,o)}function rn(e){return e.endLine-e.startLine+1}function zo(e,n,t={}){let{maxDepth:s=5,scope:i}=t,o=k(e,n);if(!o)return[];let a=[],r=new Set([o.symbolId]),l=new Set,c=[o];for(let m=1;m<=s&&c.length!==0;m++){let u=[];for(let d of c)for(let g of bm(e,d,i)){let p=`${g.file}|${g.shortName}`;if(g.symbolId!==null){if(r.has(g.symbolId))continue;r.add(g.symbolId)}else if(l.has(p))continue;l.add(p),a.push({symbol:g.symbol,shortName:g.shortName,file:g.file,depth:m}),g.symbolId!==null&&g.symbolMatch&&u.push(g.symbolMatch)}c=u}return a.sort((m,u)=>m.depth-u.depth||m.file.localeCompare(u.file)),a}function bm(e,n,t){let s=he(e,n,{limit:500}).filter(m=>!e.isIgnored(m.file)).filter(m=>!t||m.file.includes(t)),i=new Set(s.map(m=>m.file)),o=ye(e).get(n.symbolId)??new Set,a=[];for(let m of o){if(i.has(m)||e.isIgnored(m)||t&&!m.includes(t))continue;let u=A(e,m),d=u.length>0?fe(u,u[0].startLine):null;a.push({symbol:d?.symbol??m,file:m})}let r=[...s,...a],l=[],c=new Set;for(let m of r){let u=Xe(e,m.symbol);if(!u){let g=`${m.file}|${m.symbol}`;if(c.has(g))continue;c.add(g),l.push({symbolId:null,symbol:m.symbol,shortName:I(m.symbol),file:m.file,symbolMatch:null});continue}if(u.symbolId===n.symbolId||e.isIgnored(u.relativePath))continue;let d=`${u.symbolId}|${u.relativePath}`;c.has(d)||(c.add(d),l.push({symbolId:u.symbolId,symbol:u.symbol,shortName:I(u.symbol),file:u.relativePath,symbolMatch:u}))}return l}function Vo(e,n){let t=ee(e,n);if(!t)return null;let s=e.get(`SELECT id, relative_path FROM documents
708
708
  WHERE relative_path = ?
709
709
  ${e.pathExclusionsFor("documents")}
710
710
  LIMIT 1`,t);if(!s||e.isIgnored(s.relative_path))return null;let i=A(e,s.relative_path).sort((r,l)=>r.startLine-l.startLine||r.endLine-l.endLine),o=[],a=0;for(let r of i){let c=e.get(`SELECT COUNT(DISTINCT c.document_id) AS consumer_count
@@ -712,7 +712,7 @@ ${d}`,c+=1+d.length,m+=ji(d),s+=d.length+1}let u=Kc(l);u&&t.push({...u,start:r,e
712
712
  JOIN chunks c ON m.chunk_id = c.id
713
713
  WHERE m.symbol_id = ?
714
714
  AND m.role != 1
715
- AND c.document_id != ?`,r.symbolId,s.id)?.consumer_count??0,m;c>10?m="high":c>0?m="medium":m="low",a+=c,o.push({symbol:r.symbol,shortName:I(r.symbol),startLine:r.startLine,endLine:r.endLine,externalConsumers:c,riskLevel:m})}return{file:s.relative_path,symbols:o,totalExternalConsumers:a}}import{execFileSync as Yn}from"child_process";function Vo(e,n={}){let{base:t="HEAD"}=n,s;try{s=bm(e.config.projectRoot,t)}catch{return{changedFiles:[],changedSymbols:[],affectedConsumers:[],summary:{totalChangedFiles:0,totalChangedSymbols:0,totalAffectedFiles:0,note:"Unable to compute git diff."}}}if(s.length===0)return{changedFiles:[],changedSymbols:[],affectedConsumers:[],summary:{totalChangedFiles:0,totalChangedSymbols:0,totalAffectedFiles:0,note:"No changed files found."}};let i=[],o=[];for(let u of s){let d=e.get(`SELECT id, relative_path FROM documents
715
+ AND c.document_id != ?`,r.symbolId,s.id)?.consumer_count??0,m;c>10?m="high":c>0?m="medium":m="low",a+=c,o.push({symbol:r.symbol,shortName:I(r.symbol),startLine:r.startLine,endLine:r.endLine,externalConsumers:c,riskLevel:m})}return{file:s.relative_path,symbols:o,totalExternalConsumers:a}}import{execFileSync as Yn}from"child_process";function Go(e,n={}){let{base:t="HEAD"}=n,s;try{s=Sm(e.config.projectRoot,t)}catch{return{changedFiles:[],changedSymbols:[],affectedConsumers:[],summary:{totalChangedFiles:0,totalChangedSymbols:0,totalAffectedFiles:0,note:"Unable to compute git diff."}}}if(s.length===0)return{changedFiles:[],changedSymbols:[],affectedConsumers:[],summary:{totalChangedFiles:0,totalChangedSymbols:0,totalAffectedFiles:0,note:"No changed files found."}};let i=[],o=[];for(let u of s){let d=e.get(`SELECT id, relative_path FROM documents
716
716
  WHERE relative_path LIKE ?
717
717
  LIMIT 1`,`%${u}`);d&&!e.isIgnored(d.relative_path)&&(i.push(d.relative_path),o.push(d.id))}if(o.length===0)return{changedFiles:s,changedSymbols:[],affectedConsumers:[],summary:{totalChangedFiles:s.length,totalChangedSymbols:0,totalAffectedFiles:0,note:"Changed files are not present in the current SCIP index."}};let a=o.map(()=>"?").join(","),r=e.all(`SELECT DISTINCT gs.id AS symbol_id, gs.symbol, d.relative_path
718
718
  FROM mentions m
@@ -733,8 +733,8 @@ ${d}`,c+=1+d.length,m+=ji(d),s+=d.length+1}let u=Kc(l);u&&t.push({...u,start:r,e
733
733
  WHERE m.symbol_id = ?
734
734
  AND m.role != 1
735
735
  AND ref_d.relative_path NOT IN (${i.map(()=>"?").join(",")})
736
- ${e.pathExclusionsFor("ref_d")}`,u.symbol_id,...i);for(let y of f)e.isIgnored(y.relative_path)||(c.has(y.relative_path)||c.set(y.relative_path,new Set),c.get(y.relative_path).add(p))}let m=[...c.entries()].map(([u,d])=>({file:u,consumedSymbols:d.size})).sort((u,d)=>d.consumedSymbols-u.consumedSymbols);return{changedFiles:i,changedSymbols:l,affectedConsumers:m,summary:{totalChangedFiles:i.length,totalChangedSymbols:l.length,totalAffectedFiles:m.length}}}function bm(e,n){let t=Yn("git",["diff","--name-only",n],{encoding:"utf-8",cwd:e,timeout:1e4}),s=Yn("git",["diff","--name-only","--cached",n],{encoding:"utf-8",cwd:e,timeout:1e4}),i=Yn("git",["ls-files","--others","--exclude-standard"],{encoding:"utf-8",cwd:e,timeout:1e4});return[...new Set([t,s,i].flatMap(o=>o.split(`
737
- `)).map(o=>o.trim()).filter(o=>o.length>0))]}import vt from"path";function cn(e,n){let{scope:t}=n??{},s=K(e,t),i=Sm(e,t),o=[];for(let[l,c]of s){if(Ce(l))continue;let m=i.get(l)??new Set;for(let u of c)if(!Ce(u)&&!m.has(u)){if(xm(u)||Im(e,l,u))continue;o.push({file:l,kind:"unused-import",description:`Depends on ${u} but references none of its symbols`,dep:u})}}let a=_m(s);for(let[l,c]of s){if(Ce(l))continue;let m=ln(l);for(let u of c){if(Ce(u))continue;let d=ln(u);if(m===d)continue;a.get(`${m}->${d}`)==="violation"&&o.push({file:l,kind:"layer-violation",description:`Imports from ${d}/ (${u}) \u2014 may cross architectural boundary`,dep:u,detail:`${m}/ should not depend on ${d}/`})}}let r=new Map;for(let l of s.keys()){let c=vt.dirname(l);r.has(c)||r.set(c,[]),r.get(c).push(l)}for(let[l,c]of r){let m=c.filter(d=>!Ce(d));if(m.length<5)continue;let u=new Map;for(let d of m)for(let g of s.get(d)??[])Ce(g)||u.set(g,(u.get(g)??0)+1);for(let d of m)for(let g of s.get(d)??[])Ce(g)||(u.get(g)??0)===1&&vt.dirname(g)!==l&&vt.dirname(g)!==vt.dirname(l)&&o.push({file:d,kind:"pattern-deviation",description:`Only file in ${l}/ that depends on ${g}`,dep:g})}return{results:o,unusedImports:o.filter(l=>l.kind==="unused-import").length,layerViolations:o.filter(l=>l.kind==="layer-violation").length,patternDeviations:o.filter(l=>l.kind==="pattern-deviation").length}}function Sm(e,n){let t=n?`AND d1.relative_path LIKE '%${n}%'`:"",s=e.all(`SELECT DISTINCT d1.relative_path AS from_file, d2.relative_path AS to_file
736
+ ${e.pathExclusionsFor("ref_d")}`,u.symbol_id,...i);for(let y of f)e.isIgnored(y.relative_path)||(c.has(y.relative_path)||c.set(y.relative_path,new Set),c.get(y.relative_path).add(p))}let m=[...c.entries()].map(([u,d])=>({file:u,consumedSymbols:d.size})).sort((u,d)=>d.consumedSymbols-u.consumedSymbols);return{changedFiles:i,changedSymbols:l,affectedConsumers:m,summary:{totalChangedFiles:i.length,totalChangedSymbols:l.length,totalAffectedFiles:m.length}}}function Sm(e,n){let t=Yn("git",["diff","--name-only",n],{encoding:"utf-8",cwd:e,timeout:1e4}),s=Yn("git",["diff","--name-only","--cached",n],{encoding:"utf-8",cwd:e,timeout:1e4}),i=Yn("git",["ls-files","--others","--exclude-standard"],{encoding:"utf-8",cwd:e,timeout:1e4});return[...new Set([t,s,i].flatMap(o=>o.split(`
737
+ `)).map(o=>o.trim()).filter(o=>o.length>0))]}import vt from"path";function cn(e,n){let{scope:t}=n??{},s=K(e,t),i=_m(e,t),o=[];for(let[l,c]of s){if(Ce(l))continue;let m=i.get(l)??new Set;for(let u of c)if(!Ce(u)&&!m.has(u)){if(Im(u)||Nm(e,l,u))continue;o.push({file:l,kind:"unused-import",description:`Depends on ${u} but references none of its symbols`,dep:u})}}let a=xm(s);for(let[l,c]of s){if(Ce(l))continue;let m=ln(l);for(let u of c){if(Ce(u))continue;let d=ln(u);if(m===d)continue;a.get(`${m}->${d}`)==="violation"&&o.push({file:l,kind:"layer-violation",description:`Imports from ${d}/ (${u}) \u2014 may cross architectural boundary`,dep:u,detail:`${m}/ should not depend on ${d}/`})}}let r=new Map;for(let l of s.keys()){let c=vt.dirname(l);r.has(c)||r.set(c,[]),r.get(c).push(l)}for(let[l,c]of r){let m=c.filter(d=>!Ce(d));if(m.length<5)continue;let u=new Map;for(let d of m)for(let g of s.get(d)??[])Ce(g)||u.set(g,(u.get(g)??0)+1);for(let d of m)for(let g of s.get(d)??[])Ce(g)||(u.get(g)??0)===1&&vt.dirname(g)!==l&&vt.dirname(g)!==vt.dirname(l)&&o.push({file:d,kind:"pattern-deviation",description:`Only file in ${l}/ that depends on ${g}`,dep:g})}return{results:o,unusedImports:o.filter(l=>l.kind==="unused-import").length,layerViolations:o.filter(l=>l.kind==="layer-violation").length,patternDeviations:o.filter(l=>l.kind==="pattern-deviation").length}}function _m(e,n){let t=n?`AND d1.relative_path LIKE '%${n}%'`:"",s=e.all(`SELECT DISTINCT d1.relative_path AS from_file, d2.relative_path AS to_file
738
738
  FROM mentions m
739
739
  JOIN chunks c ON m.chunk_id = c.id
740
740
  JOIN documents d1 ON c.document_id = d1.id
@@ -751,24 +751,24 @@ ${d}`,c+=1+d.length,m+=ji(d),s+=d.length+1}let u=Kc(l);u&&t.push({...u,start:r,e
751
751
  AND m.role != 1
752
752
  ${e.pathExclusionsFor("d1","d2")}
753
753
  ${t}`),i=new Map;for(let a of s)e.isIgnored(a.from_file)||e.isIgnored(a.to_file)||(i.has(a.from_file)||i.set(a.from_file,new Set),i.get(a.from_file).add(a.to_file));let o=e.all(`SELECT relative_path FROM documents
754
- WHERE 1 = 1 ${e.pathExclusionsFor("documents")}`);for(let a of o){if(e.isIgnored(a.relative_path)||!P(a.relative_path))continue;let r=xe(e,a.relative_path),l=i.get(a.relative_path);for(let c of r.keys()){let m=St(e,a.relative_path,c);for(let u of m)u.relativePath!==a.relative_path&&(e.isIgnored(u.relativePath)||(l||(l=new Set,i.set(a.relative_path,l)),l.add(u.relativePath)))}if(P(a.relative_path)==="rust"){let c=we(e,a.relative_path);for(let m of c){let u=St(e,a.relative_path,m);for(let d of u)d.relativePath!==a.relative_path&&(e.isIgnored(d.relativePath)||(l||(l=new Set,i.set(a.relative_path,l)),l.add(d.relativePath)))}}}return i}function _m(e){let n=new Map,t=new Set;for(let[i,o]of e){if(Ce(i))continue;let a=ln(i);t.add(a);for(let r of o){if(Ce(r))continue;let l=ln(r);if(a===l)continue;t.add(l);let c=`${a}->${l}`;n.set(c,(n.get(c)??0)+1)}}let s=new Map;for(let[i,o]of n)s.set(i,o<=2?"violation":"ok");return s}function ln(e){let t=e.replace(/\\/g,"/").split("/").filter(Boolean);return t.length<=1?"(root)":t.length>=3&&["src","lib","app","server","client"].includes(t[0])?`${t[0]}/${t[1]}`:t[0]}function xm(e){return e.includes("types")||e.endsWith(".d.ts")}function Im(e,n,t){let s=de(e,n).filter(i=>i.sourcePath===t);return s.length===0?!1:s.every(i=>i.kind==="side-effect"||i.kind==="namespace"&&i.usedMembers.length===0&&!i.used)}function Ce(e){let n=U(e);return!!(n==="entry"||n==="barrel"||n==="test"||n==="worker"||Nm(vt.basename(e)))}function Nm(e){return!!(e==="index.ts"||e==="index.js"||e==="cli.ts"||e==="main.ts"||e==="main.rs"||e.includes("worker.")||e.includes("postinstall.")||e==="health.ts"||e==="health.js")}import{basename as Ct,extname as un}from"path";function mn(e,n){let{scope:t,maxLoc:s=15,limit:i=30}=n??{},o=Rm(K(e,t)),a=vm(e,t,s),r=Em(ye(e,a),ot(e,a)),l=[];for(let c of a){if(pe(e,c.relativePath,c.startLine))continue;let m=Ct(c.relativePath,un(c.relativePath)),u=[...r.get(c.symbolId)??[]].filter(S=>S!==c.relativePath).filter(S=>Ct(S,un(S))!==m).filter(S=>{let x=U(S);return x!=="barrel"&&x!=="entry"&&x!=="test"});if(u.length!==1)continue;let d=u[0],g=e.get(`SELECT c.start_line, c.end_line
754
+ WHERE 1 = 1 ${e.pathExclusionsFor("documents")}`);for(let a of o){if(e.isIgnored(a.relative_path)||!P(a.relative_path))continue;let r=xe(e,a.relative_path),l=i.get(a.relative_path);for(let c of r.keys()){let m=St(e,a.relative_path,c);for(let u of m)u.relativePath!==a.relative_path&&(e.isIgnored(u.relativePath)||(l||(l=new Set,i.set(a.relative_path,l)),l.add(u.relativePath)))}if(P(a.relative_path)==="rust"){let c=we(e,a.relative_path);for(let m of c){let u=St(e,a.relative_path,m);for(let d of u)d.relativePath!==a.relative_path&&(e.isIgnored(d.relativePath)||(l||(l=new Set,i.set(a.relative_path,l)),l.add(d.relativePath)))}}}return i}function xm(e){let n=new Map,t=new Set;for(let[i,o]of e){if(Ce(i))continue;let a=ln(i);t.add(a);for(let r of o){if(Ce(r))continue;let l=ln(r);if(a===l)continue;t.add(l);let c=`${a}->${l}`;n.set(c,(n.get(c)??0)+1)}}let s=new Map;for(let[i,o]of n)s.set(i,o<=2?"violation":"ok");return s}function ln(e){let t=e.replace(/\\/g,"/").split("/").filter(Boolean);return t.length<=1?"(root)":t.length>=3&&["src","lib","app","server","client"].includes(t[0])?`${t[0]}/${t[1]}`:t[0]}function Im(e){return e.includes("types")||e.endsWith(".d.ts")}function Nm(e,n,t){let s=de(e,n).filter(i=>i.sourcePath===t);return s.length===0?!1:s.every(i=>i.kind==="side-effect"||i.kind==="namespace"&&i.usedMembers.length===0&&!i.used)}function Ce(e){let n=U(e);return!!(n==="entry"||n==="barrel"||n==="test"||n==="worker"||vm(vt.basename(e)))}function vm(e){return!!(e==="index.ts"||e==="index.js"||e==="cli.ts"||e==="main.ts"||e==="main.rs"||e.includes("worker.")||e.includes("postinstall.")||e==="health.ts"||e==="health.js")}import{basename as Ct,extname as un}from"path";function mn(e,n){let{scope:t,maxLoc:s=15,limit:i=30}=n??{},o=Lm(K(e,t)),a=Cm(e,t,s),r=Rm(ye(e,a),ot(e,a)),l=[];for(let c of a){if(pe(e,c.relativePath,c.startLine))continue;let m=Ct(c.relativePath,un(c.relativePath)),u=[...r.get(c.symbolId)??[]].filter(S=>S!==c.relativePath).filter(S=>Ct(S,un(S))!==m).filter(S=>{let x=U(S);return x!=="barrel"&&x!=="entry"&&x!=="test"});if(u.length!==1)continue;let d=u[0],g=e.get(`SELECT c.start_line, c.end_line
755
755
  FROM mentions m
756
756
  JOIN chunks c ON m.chunk_id = c.id
757
757
  JOIN documents d ON c.document_id = d.id
758
758
  WHERE m.symbol_id = ? AND m.role != 1 AND d.relative_path = ?
759
- LIMIT 1`,c.symbolId,d);if(!g)continue;let p=A(e,d),f=Cm(e,d,c.symbol,g.start_line,g.end_line),y=fe(p,f);if(y&&G(y.symbol))continue;let h,b=y?.symbol??"",_=y?.isFunctionLike?I(y.symbol):Ct(d);if(y?.isFunctionLike&&y.symbolId!==c.symbolId){let S=[...r.get(y.symbolId)??[]].filter(x=>x!==y.relativePath);h=S.length>0?S.length:Go(o,d)}else h=Go(o,d);h<=3||l.push({symbol:c.symbol,shortName:I(c.symbol),file:c.relativePath,startLine:c.startLine,endLine:c.endLine,loc:Kn(c),singleCaller:b,singleCallerShort:_,callerFanIn:h})}return l.sort((c,m)=>m.callerFanIn-c.callerFanIn||m.loc-c.loc),l.slice(0,i)}function Kn(e){return e.endLine-e.startLine+1}function vm(e,n,t){return Y(e,n).filter(s=>!e.isIgnored(s.relativePath)).filter(s=>j(s.symbol)).filter(s=>!G(s.symbol)).filter(s=>Kn(s)<=t&&Kn(s)>=2)}function Cm(e,n,t,s,i){let o=F(t);if(!o)return s;let a=xe(e,n).get(o);if(!a||a.length===0)return s;for(let r of a)if(r>=s&&r<=i)return r;return s}function Em(...e){let n=new Map;for(let t of e)for(let[s,i]of t){let o=n.get(s);o||(o=new Set,n.set(s,o));for(let a of i)o.add(a)}return n}function Rm(e){let n=new Map;for(let[t,s]of e){n.has(t)||n.set(t,n.get(t)??0);for(let i of s)n.set(i,(n.get(i)??0)+1)}return n}function Go(e,n){let t=e.get(n)??0;if(t>0)return t;let s=Ct(n,un(n)),i=0;for(let[o,a]of e)o!==n&&Ct(o,un(o))===s&&a>i&&(i=a);return i}function Ko(e,n,t,s){let i=P(n);if(!i)return!0;let o=O(e,n);if(!o)return!0;let a=Yo.get(o);return a||(a=Lm(o,i),Yo.set(o,a)),a.get(`${t}:${s}`)??!0}var Yo=new WeakMap;function Lm(e,n){let t=n==="rust"?new Set(["function_item","function_signature_item"]):n==="python"?new Set(["function_definition"]):new Set(["function_declaration","method_definition","arrow_function","function_expression"]),s=new Map,i=o=>{t.has(o.type)&&s.set(`${o.startPosition.row}:${o.endPosition.row}`,wm(o,n));for(let a of o.children)i(a)};return i(e.rootNode),s}function wm(e,n){let t=e.namedChildren.find(u=>u.type==="block"||u.type==="statement_block");if(!t)return!1;let s=t.namedChildren.filter(u=>u.type!=="comment"&&u.type!=="line_comment"&&u.type!=="block_comment");if(s.length!==1)return!1;let i=s[0],o=null;if(i.type==="return_statement"||i.type==="expression_statement"?o=i.namedChild(0)??null:n==="rust"&&(i.type==="call_expression"||i.type==="macro_invocation")&&(o=i),!o)return!1;let a=n==="python"?"call":"call_expression";if(o.type!==a)return!1;let r=o.namedChildren.find(u=>u.type==="arguments"||u.type==="argument_list");if(!r)return!1;let l=r.namedChildren.filter(u=>u.type!=="comment"),c=e.namedChildren.find(u=>u.type==="parameters"||u.type==="formal_parameters");if(!c)return!1;let m=[];for(let u of c.namedChildren)if(u.type==="identifier")m.push(u.text);else{let d=u.namedChildren.find(g=>g.type==="identifier");d&&m.push(d.text)}if(l.length!==m.length)return!1;for(let u=0;u<m.length;u+=1){let d=l[u];if(d.type!=="identifier"||d.text!==m[u])return!1}return!0}function dn(e,n){let{scope:t,maxLoc:s=15,limit:i=30}=n??{},o=Dm(e,t,s),a=se(e,o),r=[];for(let l of o){if(pe(e,l.relativePath,l.startLine))continue;let c=a.get(l.symbolId)??[],m=c.some(g=>j(g.symbol))?c.filter(g=>j(g.symbol)):c,u=new Map;for(let g of m)u.has(g.symbol)||u.set(g.symbol,g);if(u.size!==1||!Ko(e,l.relativePath,l.startLine,l.endLine))continue;let[,d]=[...u.entries()][0];r.push({symbol:l.symbol,shortName:I(l.symbol),file:l.relativePath,startLine:l.startLine,endLine:l.endLine,loc:Qn(l),forwardsTo:d.symbol,forwardsToShort:I(d.symbol),forwardsToFile:d.file})}return r.sort((l,c)=>l.loc-c.loc||l.file.localeCompare(c.file)),r.slice(0,i)}function Dm(e,n,t){return Y(e,n).filter(s=>!e.isIgnored(s.relativePath)).filter(s=>j(s.symbol)).filter(s=>!Ye(s.symbol)).filter(s=>!G(s.symbol)).filter(s=>Qn(s)>=3&&Qn(s)<=t)}function Qn(e){return e.endLine-e.startLine+1}function pn(e,n){let{scope:t,minLoc:s=3,maxLoc:i=80,limit:o=30,includeLowConfidence:a=!1}=n??{},r=km(e,t),l=Y(e,t).filter(f=>f.isTypeLike&&Xn(f)>=s).filter(f=>Xn(f)<=i).filter(f=>!e.isIgnored(f.relativePath)).filter(f=>!Om(f.symbol)).filter(f=>!pe(e,f.relativePath,f.startLine)),c=ye(e,l),m=ot(e,l),u=Jm(c,m),d=new Map;for(let f of l){let y=d.get(f.relativePath);y||(y=new Map,d.set(f.relativePath,y));let h=F(f.symbol);h&&y.set(h,f)}return l.map(f=>{let h=[...u.get(f.symbolId)??new Set].filter(x=>x!==f.relativePath&&!e.isIgnored(x)),{realConsumers:b,barrelConsumers:_}=Pm(e,f.relativePath,f.symbol,h),S=Mm(e,f,u,d);return{definition:f,realConsumers:b,barrelConsumers:_,transitivelyReachable:S}}).filter(f=>!f.transitivelyReachable).filter(f=>f.realConsumers.length<=1).filter(f=>!(f.realConsumers.length===0&&f.barrelConsumers>0)).filter(f=>$m(f.definition,f.realConsumers.length,r)).map(f=>{let y=Bm(e,f.definition.relativePath,f.definition.startLine),h=Qo(f.definition.relativePath)?!0:Wm(e,f.definition),{confidence:b,reason:_}=Hm(f.realConsumers.length,y,h);return{symbol:f.definition.symbol,shortName:I(f.definition.symbol),file:f.definition.relativePath,startLine:f.definition.startLine,endLine:f.definition.endLine,loc:Xn(f.definition),consumers:f.realConsumers.length,barrelConsumers:f.barrelConsumers,kind:y,definerUsesType:h,confidence:b,reason:_}}).filter(f=>a||f.confidence!=="low").sort((f,y)=>{let h={high:0,medium:1,low:2};return h[f.confidence]-h[y.confidence]||y.loc-f.loc||f.file.localeCompare(y.file)||f.startLine-y.startLine}).slice(0,o)}function km(e,n){return new Set(Y(e,n).filter(t=>t.isFunctionLike).map(t=>t.relativePath))}function Om(e){let n=V(e);if("kind"in n)return!1;let t=n.descriptors;if(t.length<2)return!1;let s=t[t.length-1],i=t[t.length-2];return s?.suffix==="type"&&i?.suffix==="type"}function Qo(e){let t=(e.split("/").pop()??"").replace(/\.[^.]+$/,"");return!!(t==="types"||t==="models"||t==="schema"||t==="common"||t==="protocol"||t==="proto"||t==="dto"||t==="mod"||/(^|\/)types(\/|\.)/.test(e)||/(^|\/)models?(\/|\.)/.test(e)||/(^|\/)proto(?:col)?(\/|\.)/.test(e)||/(^|\/)schema(\/|\.)/.test(e))}function $m(e,n,t){return!(Qo(e.relativePath)&&n>0||n===0&&t.has(e.relativePath))}function Pm(e,n,t,s){let i=[],o=0,a=F(t);for(let r of s)jm(e,r,n,a)||Tm(e,r,a)?o++:i.push(r);return{realConsumers:i,barrelConsumers:o}}function Mm(e,n,t,s){let i=ni(e,n.relativePath),o=F(n.symbol);if(!o)return!1;let a=i.get(o);if(!a||a.size===0)return!1;let r=s.get(n.relativePath);if(!r)return!1;for(let l of a){let c=r.get(l);if(!c)continue;let m=t.get(c.symbolId);if(m){for(let u of m)if(u!==n.relativePath&&!e.isIgnored(u))return!0}}return!1}var Fm=W("stale-abs-file-usage");function Tm(e,n,t){if(!t)return!1;let s=P(n);if(!s)return!1;let i=Fm.get(e,n,()=>Am(e,n,s));return i.importedLeaves.has(t)&&!i.usedLeaves.has(t)}function Am(e,n,t){let s=new Set,i=new Set,o=O(e,n);if(!o)return{importedLeaves:s,usedLeaves:i};let a=t==="rust"?new Set(["use_declaration"]):t==="python"?new Set(["import_statement","import_from_statement"]):new Set(["import_statement"]),r=(l,c)=>{let m=c||a.has(l.type);(l.type==="identifier"||l.type==="type_identifier"||l.type==="property_identifier"||l.type==="field_identifier")&&(m?s.add(l.text):i.add(l.text));for(let u of l.children)r(u,m)};return r(o.rootNode,!1),{importedLeaves:s,usedLeaves:i}}function jm(e,n,t,s){if(!s)return!1;let i=M(e,n);if(!i)return!1;let o=Yi(e,n);if(o.length===0)return!1;let a=s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),r=new RegExp(`\\b${a}\\b`),l=i.split(`
760
- `),c=0;for(let m=0;m<l.length;m++){if(!r.test(l[m]??""))continue;if(c++,!o.find(d=>d.startLine<=m&&m<=d.endLine))return!1}return c>0}function Bm(e,n,t){let s=M(e,n);if(!s)return"other";let i=s.split(`
761
- `),o=Math.max(0,t-2),a=Math.min(i.length-1,t+2);for(let r=o;r<=a;r++){let c=(i[r]??"").replace(/^\s*\/\/.*$/g,"");if(/\b(?:export\s+)?(?:abstract\s+)?class\s+\w/.test(c))return"class";if(/\b(?:export\s+)?interface\s+\w/.test(c))return"interface";if(/\b(?:export\s+)?type\s+\w/.test(c))return"type";if(/\b(?:export\s+)?(?:const\s+)?enum\s+\w/.test(c))return"enum"}return"other"}function Wm(e,n){let t=M(e,n.relativePath);if(!t)return!1;let s=F(n.symbol);if(!s)return!1;let i=s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),o=new RegExp(`\\b${i}\\b`),a=t.split(`
762
- `);for(let r=0;r<a.length;r++)if(!(r>=n.startLine&&r<=n.endLine)&&o.test(a[r]??""))return!0;return!1}function Hm(e,n,t){return e===0?{confidence:"high",reason:"unused \u2014 no consumers and defining file has no real usage"}:e===1&&n==="class"?{confidence:"low",reason:"1 consumer + class kind \u2014 likely 1:1 encapsulation, not over-abstraction"}:e===1&&!t?{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 Xn(e){return e.endLine-e.startLine+1}function Jm(...e){let n=new Map;for(let t of e)for(let[s,i]of t){let o=n.get(s);o||(o=new Set,n.set(s,o));for(let a of i)o.add(a)}return n}function fn(e,n){let{scope:t,minLoc:s=10,limit:i=30}=n??{},{definitions:o,callerMap:a,calleeMap:r}=Um(e,t);return o.map(l=>{let c=l.endLine-l.startLine+1,m=a.get(l.symbolId)?.size??0,u=r.get(l.symbolId)??[],d=u.filter(f=>f.file!==l.relativePath),g=new Set(d.map(f=>`${f.symbol}|${f.file}`)).size,p=new Set(u.map(f=>`${f.symbol}|${f.file}`)).size;return{symbol:l.symbol,shortName:I(l.symbol),file:l.relativePath,startLine:l.startLine,endLine:l.endLine,loc:c,fanIn:m,fanOut:g,calleeCount:p,score:Math.round(c/50*(m/5)*Math.max(g/5,1)*100)/100}}).filter(l=>l.loc>=s).sort((l,c)=>c.score-l.score||c.loc-l.loc).slice(0,i)}function Um(e,n){let t=Y(e,n).filter(s=>Ve(s.symbol)&&!e.isIgnored(s.relativePath)).filter(s=>U(s.relativePath)!=="test").filter(s=>!G(s.symbol));return{definitions:t,callerMap:ye(e,t),calleeMap:se(e,t)}}function Xo(e,n={}){let{scope:t}=n,s=Bt(e),i=tn(e,{scope:t,minLoc:3,skipBarrels:!0}),o=sn(e,{scope:t,minLoc:3}),a=nn(e,{scope:t}),r=on(e,{scope:t,minSimilarity:.6,limit:50,minCallees:4}),l=an(e,{scope:t,minLoc:15,minCallees:5,limit:50}),c=mn(e,{scope:t,maxLoc:15,limit:50}),m=dn(e,{scope:t,maxLoc:15,limit:50}),u=pn(e,{scope:t,minLoc:3,limit:50}),d=cn(e,{scope:t}),g=fn(e,{scope:t,minLoc:10,limit:10}),p=i.symbols.filter(R=>!ve(e,R.relativePath)&&!rt(e,R.symbol,R.relativePath)&&R.kind==="dead-code"),f=p.length,y=p.reduce((R,Q)=>R+Q.loc,0),h=o.filter(R=>!ve(e,R.relativePath)&&!rt(e,R.symbol,R.relativePath)).length,b=u.length,_=d.unusedImports+d.layerViolations,S=r.length,x=[];f>0&&x.push({category:"Dead code",description:`${f} symbols with zero references anywhere \u2014 safe to delete`,effort:"low",impact:"high",count:f,locRecoverable:y}),h>0&&x.push({category:"Isolated symbols",description:`${h} symbols completely disconnected from the codebase graph`,effort:"low",impact:"medium",count:h,locRecoverable:o.filter(R=>!ve(e,R.relativePath)&&!rt(e,R.symbol,R.relativePath)).reduce((R,Q)=>R+Q.loc,0)});let L=a.filter(R=>R.kind==="real");if(L.length>0&&x.push({category:"Circular dependencies",description:`${L.length} cycle(s) \u2014 break with dependency inversion or module restructuring`,effort:"medium",impact:"high",count:L.length,locRecoverable:0}),S>0&&x.push({category:"Similar functions",description:`${S} pairs with real logic overlap (beyond shared imports) \u2014 consolidation candidates`,effort:"medium",impact:"medium",count:S,locRecoverable:0}),l.length>0&&x.push({category:"Extraction candidates",description:`${l.length} large functions with isolated callee clusters \u2014 extract method opportunities`,effort:"medium",impact:"medium",count:l.length,locRecoverable:0}),c.length>0&&x.push({category:"Wrapper functions",description:`${c.length} single-consumer symbols that could be inlined`,effort:"low",impact:"low",count:c.length,locRecoverable:c.reduce((R,Q)=>R+Q.loc,0)}),m.length>0&&x.push({category:"Passthrough functions",description:`${m.length} functions that just forward to one callee \u2014 unnecessary indirection`,effort:"low",impact:"low",count:m.length,locRecoverable:m.reduce((R,Q)=>R+Q.loc,0)}),b>0){let R=u.filter(Rt=>Rt.consumers===0).length,Q=b-R,at=[];R>0&&at.push(`${R} unused`),Q>0&&at.push(`${Q} single-consumer (not in types file)`),x.push({category:"Stale abstractions",description:`${at.join(", ")} \u2014 premature abstraction`,effort:"low",impact:"medium",count:b,locRecoverable:u.reduce((Rt,yr)=>Rt+yr.loc,0)})}if(_>0||d.patternDeviations>0){let R=[];d.unusedImports>0&&R.push(`${d.unusedImports} unused imports`),d.layerViolations>0&&R.push(`${d.layerViolations} layer violations`),d.patternDeviations>0&&R.push(`${d.patternDeviations} unique deps`),x.push({category:"Structural drift",description:R.join(", "),effort:d.layerViolations>0?"medium":"low",impact:d.layerViolations>0?"medium":"low",count:_,locRecoverable:0})}let w={high:3,medium:2,low:1},$={low:3,medium:2,high:1};x.sort((R,Q)=>{let at=w[R.impact]*$[R.effort];return w[Q.impact]*$[Q.effort]-at});let q=Math.max(s.documents,1),B=Math.max(s.symbols,1),T=100,_e=f/B;T-=Math.min(20,Math.round(_e*200));let is=h/B;T-=Math.min(10,Math.round(is*200));let Et=a.filter(R=>R.kind==="real").length;T-=Math.min(15,Et*5);let bn=S/B*1e3;T-=Math.min(10,Math.round(bn));let ce=l.length/B*1e3;T-=Math.min(5,Math.round(ce/2)),T-=Math.min(3,c.length),T-=Math.min(3,m.length);let fr=b/Math.max(B*.1,1);T-=Math.min(8,Math.round(fr*10));let gr=_/q;T-=Math.min(5,Math.round(gr*50));let hr=g.filter(R=>R.score>50).length;return T-=Math.min(5,hr*2),T=Math.max(0,Math.min(100,T)),{score:T,overview:{documents:s.documents,symbols:s.symbols,indexSizeBytes:s.indexSizeBytes},findings:{deadSymbols:f,deadLoc:y,isolatedSymbols:h,isolatedLoc:o.filter(R=>!ve(e,R.relativePath)).reduce((R,Q)=>R+Q.loc,0),cycles:Et,similarPairs:S,extractionCandidates:l.length,wrappers:c.length,passthroughs:m.length,staleTypes:b,driftedFiles:_,complexityHotspotCount:g.length},actions:x,topComplexity:g.slice(0,5).map(R=>({symbol:R.shortName,score:R.score}))}}function Zo(e,n,t){let s=k(e,n),i=k(e,t);if(!s||!i)return null;let o=new Set(ne(e,s).map(f=>f.symbol)),a=new Set(ne(e,i).map(f=>f.symbol)),r=[];for(let f of o)a.has(f)&&r.push(f);let l=[];for(let f of o)a.has(f)||l.push(f);let c=[];for(let f of a)o.has(f)||c.push(f);let m=new Set([...o,...a]),u=m.size>0?r.length/m.size:0,d;m.size===0?d="Neither function calls other tracked symbols. There is no callee-pattern evidence for consolidation; inspect the source bodies directly.":r.length===0?d="These functions do not share any callees. They are not a callee-based consolidation candidate.":l.length===0&&c.length===0?d="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.":l.length===0?d="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.":c.length===0?d="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.":l.length<=2&&c.length<=2?d=`Create a shared function with the ${r.length} common callees. Pass the ${l.length+c.length} divergent callees as parameters or strategy callbacks.`:d=`Extract the ${r.length} shared callees into a common helper. Each function calls the helper plus its own unique logic (${l.length} callees in A, ${c.length} in B).`;let g=s.endLine-s.startLine+1,p=i.endLine-i.startLine+1;return{symbolA:{symbol:s.symbol,shortName:I(s.symbol),file:s.relativePath,loc:g},symbolB:{symbol:i.symbol,shortName:I(i.symbol),file:i.relativePath,loc:p},similarity:u,sharedCallees:r.map(I),uniqueToA:l.map(I),uniqueToB:c.map(I),consolidationStrategy:d}}import{readFileSync as er}from"fs";import{join as tr}from"path";function nr(e,n,t={}){let{context:s=0}=t,i=n.match(/^(.+\.\w+):(\d+)-(\d+)$/);if(i)return qm(e,i[1],parseInt(i[2],10),parseInt(i[3],10),s);let o=k(e,n);if(!o)return null;let a=e.get("SELECT language FROM documents WHERE relative_path = ?",o.relativePath),r=tr(e.config.projectRoot,o.relativePath),l;try{l=er(r,"utf-8")}catch{return null}let c=l.split(`
759
+ LIMIT 1`,c.symbolId,d);if(!g)continue;let p=A(e,d),f=Em(e,d,c.symbol,g.start_line,g.end_line),y=fe(p,f);if(y&&G(y.symbol))continue;let h,b=y?.symbol??"",_=y?.isFunctionLike?I(y.symbol):Ct(d);if(y?.isFunctionLike&&y.symbolId!==c.symbolId){let S=[...r.get(y.symbolId)??[]].filter(x=>x!==y.relativePath);h=S.length>0?S.length:Yo(o,d)}else h=Yo(o,d);h<=3||l.push({symbol:c.symbol,shortName:I(c.symbol),file:c.relativePath,startLine:c.startLine,endLine:c.endLine,loc:Kn(c),singleCaller:b,singleCallerShort:_,callerFanIn:h})}return l.sort((c,m)=>m.callerFanIn-c.callerFanIn||m.loc-c.loc),l.slice(0,i)}function Kn(e){return e.endLine-e.startLine+1}function Cm(e,n,t){return Y(e,n).filter(s=>!e.isIgnored(s.relativePath)).filter(s=>j(s.symbol)).filter(s=>!G(s.symbol)).filter(s=>Kn(s)<=t&&Kn(s)>=2)}function Em(e,n,t,s,i){let o=F(t);if(!o)return s;let a=xe(e,n).get(o);if(!a||a.length===0)return s;for(let r of a)if(r>=s&&r<=i)return r;return s}function Rm(...e){let n=new Map;for(let t of e)for(let[s,i]of t){let o=n.get(s);o||(o=new Set,n.set(s,o));for(let a of i)o.add(a)}return n}function Lm(e){let n=new Map;for(let[t,s]of e){n.has(t)||n.set(t,n.get(t)??0);for(let i of s)n.set(i,(n.get(i)??0)+1)}return n}function Yo(e,n){let t=e.get(n)??0;if(t>0)return t;let s=Ct(n,un(n)),i=0;for(let[o,a]of e)o!==n&&Ct(o,un(o))===s&&a>i&&(i=a);return i}function Qo(e,n,t,s){let i=P(n);if(!i)return!0;let o=O(e,n);if(!o)return!0;let a=Ko.get(o);return a||(a=wm(o,i),Ko.set(o,a)),a.get(`${t}:${s}`)??!0}var Ko=new WeakMap;function wm(e,n){let t=n==="rust"?new Set(["function_item","function_signature_item"]):n==="python"?new Set(["function_definition"]):new Set(["function_declaration","method_definition","arrow_function","function_expression"]),s=new Map,i=o=>{t.has(o.type)&&s.set(`${o.startPosition.row}:${o.endPosition.row}`,Dm(o,n));for(let a of o.children)i(a)};return i(e.rootNode),s}function Dm(e,n){let t=e.namedChildren.find(u=>u.type==="block"||u.type==="statement_block");if(!t)return!1;let s=t.namedChildren.filter(u=>u.type!=="comment"&&u.type!=="line_comment"&&u.type!=="block_comment");if(s.length!==1)return!1;let i=s[0],o=null;if(i.type==="return_statement"||i.type==="expression_statement"?o=i.namedChild(0)??null:n==="rust"&&(i.type==="call_expression"||i.type==="macro_invocation")&&(o=i),!o)return!1;let a=n==="python"?"call":"call_expression";if(o.type!==a)return!1;let r=o.namedChildren.find(u=>u.type==="arguments"||u.type==="argument_list");if(!r)return!1;let l=r.namedChildren.filter(u=>u.type!=="comment"),c=e.namedChildren.find(u=>u.type==="parameters"||u.type==="formal_parameters");if(!c)return!1;let m=[];for(let u of c.namedChildren)if(u.type==="identifier")m.push(u.text);else{let d=u.namedChildren.find(g=>g.type==="identifier");d&&m.push(d.text)}if(l.length!==m.length)return!1;for(let u=0;u<m.length;u+=1){let d=l[u];if(d.type!=="identifier"||d.text!==m[u])return!1}return!0}function dn(e,n){let{scope:t,maxLoc:s=15,limit:i=30}=n??{},o=km(e,t,s),a=se(e,o),r=[];for(let l of o){if(pe(e,l.relativePath,l.startLine))continue;let c=a.get(l.symbolId)??[],m=c.some(g=>j(g.symbol))?c.filter(g=>j(g.symbol)):c,u=new Map;for(let g of m)u.has(g.symbol)||u.set(g.symbol,g);if(u.size!==1||!Qo(e,l.relativePath,l.startLine,l.endLine))continue;let[,d]=[...u.entries()][0];r.push({symbol:l.symbol,shortName:I(l.symbol),file:l.relativePath,startLine:l.startLine,endLine:l.endLine,loc:Qn(l),forwardsTo:d.symbol,forwardsToShort:I(d.symbol),forwardsToFile:d.file})}return r.sort((l,c)=>l.loc-c.loc||l.file.localeCompare(c.file)),r.slice(0,i)}function km(e,n,t){return Y(e,n).filter(s=>!e.isIgnored(s.relativePath)).filter(s=>j(s.symbol)).filter(s=>!Ye(s.symbol)).filter(s=>!G(s.symbol)).filter(s=>Qn(s)>=3&&Qn(s)<=t)}function Qn(e){return e.endLine-e.startLine+1}function pn(e,n){let{scope:t,minLoc:s=3,maxLoc:i=80,limit:o=30,includeLowConfidence:a=!1}=n??{},r=Om(e,t),l=Y(e,t).filter(f=>f.isTypeLike&&Xn(f)>=s).filter(f=>Xn(f)<=i).filter(f=>!e.isIgnored(f.relativePath)).filter(f=>!$m(f.symbol)).filter(f=>!pe(e,f.relativePath,f.startLine)),c=ye(e,l),m=ot(e,l),u=Um(c,m),d=new Map;for(let f of l){let y=d.get(f.relativePath);y||(y=new Map,d.set(f.relativePath,y));let h=F(f.symbol);h&&y.set(h,f)}return l.map(f=>{let h=[...u.get(f.symbolId)??new Set].filter(x=>x!==f.relativePath&&!e.isIgnored(x)),{realConsumers:b,barrelConsumers:_}=Mm(e,f.relativePath,f.symbol,h),S=Fm(e,f,u,d);return{definition:f,realConsumers:b,barrelConsumers:_,transitivelyReachable:S}}).filter(f=>!f.transitivelyReachable).filter(f=>f.realConsumers.length<=1).filter(f=>!(f.realConsumers.length===0&&f.barrelConsumers>0)).filter(f=>Pm(f.definition,f.realConsumers.length,r)).map(f=>{let y=Wm(e,f.definition.relativePath,f.definition.startLine),h=Xo(f.definition.relativePath)?!0:Hm(e,f.definition),{confidence:b,reason:_}=Jm(f.realConsumers.length,y,h);return{symbol:f.definition.symbol,shortName:I(f.definition.symbol),file:f.definition.relativePath,startLine:f.definition.startLine,endLine:f.definition.endLine,loc:Xn(f.definition),consumers:f.realConsumers.length,barrelConsumers:f.barrelConsumers,kind:y,definerUsesType:h,confidence:b,reason:_}}).filter(f=>a||f.confidence!=="low").sort((f,y)=>{let h={high:0,medium:1,low:2};return h[f.confidence]-h[y.confidence]||y.loc-f.loc||f.file.localeCompare(y.file)||f.startLine-y.startLine}).slice(0,o)}function Om(e,n){return new Set(Y(e,n).filter(t=>t.isFunctionLike).map(t=>t.relativePath))}function $m(e){let n=V(e);if("kind"in n)return!1;let t=n.descriptors;if(t.length<2)return!1;let s=t[t.length-1],i=t[t.length-2];return s?.suffix==="type"&&i?.suffix==="type"}function Xo(e){let t=(e.split("/").pop()??"").replace(/\.[^.]+$/,"");return!!(t==="types"||t==="models"||t==="schema"||t==="common"||t==="protocol"||t==="proto"||t==="dto"||t==="mod"||/(^|\/)types(\/|\.)/.test(e)||/(^|\/)models?(\/|\.)/.test(e)||/(^|\/)proto(?:col)?(\/|\.)/.test(e)||/(^|\/)schema(\/|\.)/.test(e))}function Pm(e,n,t){return!(Xo(e.relativePath)&&n>0||n===0&&t.has(e.relativePath))}function Mm(e,n,t,s){let i=[],o=0,a=F(t);for(let r of s)Bm(e,r,n,a)||Am(e,r,a)?o++:i.push(r);return{realConsumers:i,barrelConsumers:o}}function Fm(e,n,t,s){let i=si(e,n.relativePath),o=F(n.symbol);if(!o)return!1;let a=i.get(o);if(!a||a.size===0)return!1;let r=s.get(n.relativePath);if(!r)return!1;for(let l of a){let c=r.get(l);if(!c)continue;let m=t.get(c.symbolId);if(m){for(let u of m)if(u!==n.relativePath&&!e.isIgnored(u))return!0}}return!1}var Tm=W("stale-abs-file-usage");function Am(e,n,t){if(!t)return!1;let s=P(n);if(!s)return!1;let i=Tm.get(e,n,()=>jm(e,n,s));return i.importedLeaves.has(t)&&!i.usedLeaves.has(t)}function jm(e,n,t){let s=new Set,i=new Set,o=O(e,n);if(!o)return{importedLeaves:s,usedLeaves:i};let a=t==="rust"?new Set(["use_declaration"]):t==="python"?new Set(["import_statement","import_from_statement"]):new Set(["import_statement"]),r=(l,c)=>{let m=c||a.has(l.type);(l.type==="identifier"||l.type==="type_identifier"||l.type==="property_identifier"||l.type==="field_identifier")&&(m?s.add(l.text):i.add(l.text));for(let u of l.children)r(u,m)};return r(o.rootNode,!1),{importedLeaves:s,usedLeaves:i}}function Bm(e,n,t,s){if(!s)return!1;let i=M(e,n);if(!i)return!1;let o=Ki(e,n);if(o.length===0)return!1;let a=s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),r=new RegExp(`\\b${a}\\b`),l=i.split(`
760
+ `),c=0;for(let m=0;m<l.length;m++){if(!r.test(l[m]??""))continue;if(c++,!o.find(d=>d.startLine<=m&&m<=d.endLine))return!1}return c>0}function Wm(e,n,t){let s=M(e,n);if(!s)return"other";let i=s.split(`
761
+ `),o=Math.max(0,t-2),a=Math.min(i.length-1,t+2);for(let r=o;r<=a;r++){let c=(i[r]??"").replace(/^\s*\/\/.*$/g,"");if(/\b(?:export\s+)?(?:abstract\s+)?class\s+\w/.test(c))return"class";if(/\b(?:export\s+)?interface\s+\w/.test(c))return"interface";if(/\b(?:export\s+)?type\s+\w/.test(c))return"type";if(/\b(?:export\s+)?(?:const\s+)?enum\s+\w/.test(c))return"enum"}return"other"}function Hm(e,n){let t=M(e,n.relativePath);if(!t)return!1;let s=F(n.symbol);if(!s)return!1;let i=s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),o=new RegExp(`\\b${i}\\b`),a=t.split(`
762
+ `);for(let r=0;r<a.length;r++)if(!(r>=n.startLine&&r<=n.endLine)&&o.test(a[r]??""))return!0;return!1}function Jm(e,n,t){return e===0?{confidence:"high",reason:"unused \u2014 no consumers and defining file has no real usage"}:e===1&&n==="class"?{confidence:"low",reason:"1 consumer + class kind \u2014 likely 1:1 encapsulation, not over-abstraction"}:e===1&&!t?{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 Xn(e){return e.endLine-e.startLine+1}function Um(...e){let n=new Map;for(let t of e)for(let[s,i]of t){let o=n.get(s);o||(o=new Set,n.set(s,o));for(let a of i)o.add(a)}return n}function fn(e,n){let{scope:t,minLoc:s=10,limit:i=30}=n??{},{definitions:o,callerMap:a,calleeMap:r}=qm(e,t);return o.map(l=>{let c=l.endLine-l.startLine+1,m=a.get(l.symbolId)?.size??0,u=r.get(l.symbolId)??[],d=u.filter(f=>f.file!==l.relativePath),g=new Set(d.map(f=>`${f.symbol}|${f.file}`)).size,p=new Set(u.map(f=>`${f.symbol}|${f.file}`)).size;return{symbol:l.symbol,shortName:I(l.symbol),file:l.relativePath,startLine:l.startLine,endLine:l.endLine,loc:c,fanIn:m,fanOut:g,calleeCount:p,score:Math.round(c/50*(m/5)*Math.max(g/5,1)*100)/100}}).filter(l=>l.loc>=s).sort((l,c)=>c.score-l.score||c.loc-l.loc).slice(0,i)}function qm(e,n){let t=Y(e,n).filter(s=>Ve(s.symbol)&&!e.isIgnored(s.relativePath)).filter(s=>U(s.relativePath)!=="test").filter(s=>!G(s.symbol));return{definitions:t,callerMap:ye(e,t),calleeMap:se(e,t)}}function Zo(e,n={}){let{scope:t}=n,s=Bt(e),i=tn(e,{scope:t,minLoc:3,skipBarrels:!0}),o=sn(e,{scope:t,minLoc:3}),a=nn(e,{scope:t}),r=on(e,{scope:t,minSimilarity:.6,limit:50,minCallees:4}),l=an(e,{scope:t,minLoc:15,minCallees:5,limit:50}),c=mn(e,{scope:t,maxLoc:15,limit:50}),m=dn(e,{scope:t,maxLoc:15,limit:50}),u=pn(e,{scope:t,minLoc:3,limit:50}),d=cn(e,{scope:t}),g=fn(e,{scope:t,minLoc:10,limit:10}),p=i.symbols.filter(R=>!ve(e,R.relativePath)&&!rt(e,R.symbol,R.relativePath)&&R.kind==="dead-code"),f=p.length,y=p.reduce((R,Q)=>R+Q.loc,0),h=o.filter(R=>!ve(e,R.relativePath)&&!rt(e,R.symbol,R.relativePath)).length,b=u.length,_=d.unusedImports+d.layerViolations,S=r.length,x=[];f>0&&x.push({category:"Dead code",description:`${f} symbols with zero references anywhere \u2014 safe to delete`,effort:"low",impact:"high",count:f,locRecoverable:y}),h>0&&x.push({category:"Isolated symbols",description:`${h} symbols completely disconnected from the codebase graph`,effort:"low",impact:"medium",count:h,locRecoverable:o.filter(R=>!ve(e,R.relativePath)&&!rt(e,R.symbol,R.relativePath)).reduce((R,Q)=>R+Q.loc,0)});let L=a.filter(R=>R.kind==="real");if(L.length>0&&x.push({category:"Circular dependencies",description:`${L.length} cycle(s) \u2014 break with dependency inversion or module restructuring`,effort:"medium",impact:"high",count:L.length,locRecoverable:0}),S>0&&x.push({category:"Similar functions",description:`${S} pairs with real logic overlap (beyond shared imports) \u2014 consolidation candidates`,effort:"medium",impact:"medium",count:S,locRecoverable:0}),l.length>0&&x.push({category:"Extraction candidates",description:`${l.length} large functions with isolated callee clusters \u2014 extract method opportunities`,effort:"medium",impact:"medium",count:l.length,locRecoverable:0}),c.length>0&&x.push({category:"Wrapper functions",description:`${c.length} single-consumer symbols that could be inlined`,effort:"low",impact:"low",count:c.length,locRecoverable:c.reduce((R,Q)=>R+Q.loc,0)}),m.length>0&&x.push({category:"Passthrough functions",description:`${m.length} functions that just forward to one callee \u2014 unnecessary indirection`,effort:"low",impact:"low",count:m.length,locRecoverable:m.reduce((R,Q)=>R+Q.loc,0)}),b>0){let R=u.filter(Rt=>Rt.consumers===0).length,Q=b-R,at=[];R>0&&at.push(`${R} unused`),Q>0&&at.push(`${Q} single-consumer (not in types file)`),x.push({category:"Stale abstractions",description:`${at.join(", ")} \u2014 premature abstraction`,effort:"low",impact:"medium",count:b,locRecoverable:u.reduce((Rt,br)=>Rt+br.loc,0)})}if(_>0||d.patternDeviations>0){let R=[];d.unusedImports>0&&R.push(`${d.unusedImports} unused imports`),d.layerViolations>0&&R.push(`${d.layerViolations} layer violations`),d.patternDeviations>0&&R.push(`${d.patternDeviations} unique deps`),x.push({category:"Structural drift",description:R.join(", "),effort:d.layerViolations>0?"medium":"low",impact:d.layerViolations>0?"medium":"low",count:_,locRecoverable:0})}let w={high:3,medium:2,low:1},$={low:3,medium:2,high:1};x.sort((R,Q)=>{let at=w[R.impact]*$[R.effort];return w[Q.impact]*$[Q.effort]-at});let q=Math.max(s.documents,1),B=Math.max(s.symbols,1),T=100,_e=f/B;T-=Math.min(20,Math.round(_e*200));let is=h/B;T-=Math.min(10,Math.round(is*200));let Et=a.filter(R=>R.kind==="real").length;T-=Math.min(15,Et*5);let bn=S/B*1e3;T-=Math.min(10,Math.round(bn));let ce=l.length/B*1e3;T-=Math.min(5,Math.round(ce/2)),T-=Math.min(3,c.length),T-=Math.min(3,m.length);let gr=b/Math.max(B*.1,1);T-=Math.min(8,Math.round(gr*10));let hr=_/q;T-=Math.min(5,Math.round(hr*50));let yr=g.filter(R=>R.score>50).length;return T-=Math.min(5,yr*2),T=Math.max(0,Math.min(100,T)),{score:T,overview:{documents:s.documents,symbols:s.symbols,indexSizeBytes:s.indexSizeBytes},findings:{deadSymbols:f,deadLoc:y,isolatedSymbols:h,isolatedLoc:o.filter(R=>!ve(e,R.relativePath)).reduce((R,Q)=>R+Q.loc,0),cycles:Et,similarPairs:S,extractionCandidates:l.length,wrappers:c.length,passthroughs:m.length,staleTypes:b,driftedFiles:_,complexityHotspotCount:g.length},actions:x,topComplexity:g.slice(0,5).map(R=>({symbol:R.shortName,score:R.score}))}}function er(e,n,t){let s=k(e,n),i=k(e,t);if(!s||!i)return null;let o=new Set(ne(e,s).map(f=>f.symbol)),a=new Set(ne(e,i).map(f=>f.symbol)),r=[];for(let f of o)a.has(f)&&r.push(f);let l=[];for(let f of o)a.has(f)||l.push(f);let c=[];for(let f of a)o.has(f)||c.push(f);let m=new Set([...o,...a]),u=m.size>0?r.length/m.size:0,d;m.size===0?d="Neither function calls other tracked symbols. There is no callee-pattern evidence for consolidation; inspect the source bodies directly.":r.length===0?d="These functions do not share any callees. They are not a callee-based consolidation candidate.":l.length===0&&c.length===0?d="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.":l.length===0?d="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.":c.length===0?d="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.":l.length<=2&&c.length<=2?d=`Create a shared function with the ${r.length} common callees. Pass the ${l.length+c.length} divergent callees as parameters or strategy callbacks.`:d=`Extract the ${r.length} shared callees into a common helper. Each function calls the helper plus its own unique logic (${l.length} callees in A, ${c.length} in B).`;let g=s.endLine-s.startLine+1,p=i.endLine-i.startLine+1;return{symbolA:{symbol:s.symbol,shortName:I(s.symbol),file:s.relativePath,loc:g},symbolB:{symbol:i.symbol,shortName:I(i.symbol),file:i.relativePath,loc:p},similarity:u,sharedCallees:r.map(I),uniqueToA:l.map(I),uniqueToB:c.map(I),consolidationStrategy:d}}import{readFileSync as tr}from"fs";import{join as nr}from"path";function sr(e,n,t={}){let{context:s=0}=t,i=n.match(/^(.+\.\w+):(\d+)-(\d+)$/);if(i)return zm(e,i[1],parseInt(i[2],10),parseInt(i[3],10),s);let o=k(e,n);if(!o)return null;let a=e.get("SELECT language FROM documents WHERE relative_path = ?",o.relativePath),r=nr(e.config.projectRoot,o.relativePath),l;try{l=tr(r,"utf-8")}catch{return null}let c=l.split(`
763
763
  `),m=Math.max(0,o.startLine-s),u=Math.min(c.length-1,o.endLine+s),d=c.slice(m,u+1).join(`
764
- `);return{symbol:o.symbol,shortName:I(o.symbol),relativePath:o.relativePath,startLine:m,endLine:u,language:a?.language??null,source:d}}function qm(e,n,t,s,i){let o=ee(e,n);if(!o)return null;let a=e.get("SELECT relative_path, language FROM documents WHERE relative_path = ?",o);if(!a)return null;let r=tr(e.config.projectRoot,a.relative_path),l;try{l=er(r,"utf-8")}catch{return null}let c=l.split(`
764
+ `);return{symbol:o.symbol,shortName:I(o.symbol),relativePath:o.relativePath,startLine:m,endLine:u,language:a?.language??null,source:d}}function zm(e,n,t,s,i){let o=ee(e,n);if(!o)return null;let a=e.get("SELECT relative_path, language FROM documents WHERE relative_path = ?",o);if(!a)return null;let r=nr(e.config.projectRoot,a.relative_path),l;try{l=tr(r,"utf-8")}catch{return null}let c=l.split(`
765
765
  `),m=Math.max(0,t-1-i),u=Math.min(c.length-1,s-1+i),d=c.slice(m,u+1).join(`
766
- `);return{symbol:`${a.relative_path}:${t}-${s}`,shortName:`${a.relative_path}:${t}-${s}`,relativePath:a.relative_path,startLine:m,endLine:u,language:a.language,source:d}}import{readFileSync as zm}from"fs";import{join as Vm}from"path";function sr(e,n){let t=k(e,n);if(!t)return null;let i=e.get("SELECT language FROM documents WHERE relative_path = ?",t.relativePath)?.language??"unknown",o=Vm(e.config.projectRoot,t.relativePath),a="";try{a=zm(o,"utf-8").split(`
766
+ `);return{symbol:`${a.relative_path}:${t}-${s}`,shortName:`${a.relative_path}:${t}-${s}`,relativePath:a.relative_path,startLine:m,endLine:u,language:a.language,source:d}}import{readFileSync as Vm}from"fs";import{join as Gm}from"path";function ir(e,n){let t=k(e,n);if(!t)return null;let i=e.get("SELECT language FROM documents WHERE relative_path = ?",t.relativePath)?.language??"unknown",o=Gm(e.config.projectRoot,t.relativePath),a="";try{a=Vm(o,"utf-8").split(`
767
767
  `).slice(t.startLine,t.endLine+1).join(`
768
- `)}catch{}let r=Gm(a,i),l=t.endLine-t.startLine+1,m=se(e,[t],{additive:!0}).get(t.symbolId)??[],u=new Set(m.map(p=>p.symbol)),d=e.get(`SELECT COUNT(DISTINCT c.document_id) AS c
768
+ `)}catch{}let r=Ym(a,i),l=t.endLine-t.startLine+1,m=se(e,[t],{additive:!0}).get(t.symbolId)??[],u=new Set(m.map(p=>p.symbol)),d=e.get(`SELECT COUNT(DISTINCT c.document_id) AS c
769
769
  FROM mentions m
770
770
  JOIN chunks c ON m.chunk_id = c.id
771
- WHERE m.symbol_id = ? AND m.role != 1`,t.symbolId),g=new Set(m.filter(p=>p.file!==t.relativePath).map(p=>p.symbol)).size;return{symbol:t.symbol,shortName:I(t.symbol),relativePath:t.relativePath,startLine:t.startLine,endLine:t.endLine,loc:l,branches:r,cyclomaticEstimate:r+1,calleeCount:u.size,fanIn:d?.c??0,fanOut:g}}function Gm(e,n){let t=Ym(e),s=0,i=[/\bif\b/g,/\belse\s+if\b/g,/\belse\b/g,/\bfor\b/g,/\bwhile\b/g,/\bswitch\b/g,/\bcase\b/g,/\bcatch\b/g,/\?\s*[^?]/g,/&&/g,/\|\|/g];for(let o of i){let a=t.match(o);a&&(s+=a.length)}if(n==="python"){let o=[/\belif\b/g,/\bexcept\b/g,/\bfinally\b/g];for(let a of o){let r=t.match(a);r&&(s+=r.length)}}else if(n==="rust"){let o=[/\bmatch\b/g,/=>/g,/\bloop\b/g];for(let a of o){let r=t.match(a);r&&(s+=r.length)}}else if(n==="ruby"){let o=[/\belsif\b/g,/\bunless\b/g,/\brescue\b/g,/\bwhen\b/g];for(let a of o){let r=t.match(a);r&&(s+=r.length)}}else if(n==="go"){let o=[/\bselect\b/g,/\bdefer\b/g];for(let a of o){let r=t.match(a);r&&(s+=r.length)}}return s}function Ym(e){return e.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/.*/g,"").replace(/#.*/g,"").replace(/"(?:[^"\\]|\\.)*"/g,'""').replace(/'(?:[^'\\]|\\.)*'/g,"''").replace(/`(?:[^`\\]|\\.)*`/g,"``")}function ir(e,n){let t=k(e,n);if(!t)return null;let s=[{file:t.relativePath,line:t.startLine}],i=Pe(e,t),a=(i.length>0?i:$e(e,t)).filter(c=>!e.isIgnored(c.file)).map(c=>({file:c.file,line:c.line,enclosingSymbol:c.enclosingSymbol??"(top-level)",enclosingShort:c.enclosingSymbol?I(c.enclosingSymbol):"(top-level)"})),{producers:r,consumers:l}=Km(e,t,a);return{symbol:t.symbol,shortName:I(t.symbol),relativePath:t.relativePath,definitionSites:s.filter(c=>!e.isIgnored(c.file)),usageSites:a,producers:r.filter(c=>!e.isIgnored(c.file)).map(c=>({symbol:c.symbol,shortName:I(c.symbol),file:c.file})),consumers:l.filter(c=>!e.isIgnored(c.file)).map(c=>({symbol:c.symbol,shortName:c.symbol===c.file?"(top-level)":I(c.symbol),file:c.file}))}}function Km(e,n,t){let s=Zn(ne(e,n,{limit:30}).map(a=>({symbol:a.symbol,file:a.file}))),i=Zn(he(e,n,{limit:30})),o=i.length>0?i:Zn(t.map(a=>({symbol:a.enclosingSymbol==="(top-level)"?a.file:a.enclosingSymbol,file:a.file})));return{producers:s,consumers:o}}function Zn(e){let n=new Set,t=[];for(let s of e){let i=`${s.symbol}|${s.file}`;n.has(i)||(n.add(i),t.push(s))}return t}function or(e,n,t={}){let{direction:s="backward",maxDepth:i=3}=t,o=k(e,n);return o?s==="backward"?Qm(e,o,i):Xm(e,o):null}function Qm(e,n,t){let s=[],i=new Set([n.symbol]),o=[n];for(let a=1;a<=t&&o.length!==0;a++){let r=[];for(let l of o){let c=ne(e,l);for(let m of c){if(i.has(m.symbol))continue;i.add(m.symbol),s.push({symbol:m.symbol,shortName:I(m.symbol),file:m.file,relationship:a===1?"referenced within definition (callee)":`depth ${a} callee`});let u=Xe(e,m.symbol);u&&!e.isIgnored(u.relativePath)&&r.push(u)}}o=r}return{symbol:n.symbol,shortName:I(n.symbol),direction:"backward",connectedSymbols:s}}function Xm(e,n){let t=Pe(e,n),s=t.length>0?t:$e(e,n),i=new Set,o=[];for(let a of s){if(o.length>=30)break;if(e.isIgnored(a.file))continue;let r=a.enclosingSymbol??fe(A(e,a.file),a.line)?.symbol??null;if(!r||r===n.symbol)continue;let l=Xe(e,r);if(l){for(let c of ne(e,l))if(c.symbol!==n.symbol&&c.symbol!==r&&c.file!==a.file&&!e.isIgnored(c.file)&&!i.has(c.symbol)&&(i.add(c.symbol),o.push({symbol:c.symbol,shortName:I(c.symbol),file:c.file,relationship:`used alongside target in ${I(r)}`}),o.length>=30))break}}return o.sort((a,r)=>a.file.localeCompare(r.file)),{symbol:n.symbol,shortName:I(n.symbol),direction:"forward",connectedSymbols:o}}function ar(e,n={}){let{scope:t,limit:s}=n,i=t?`AND barrel_d.relative_path LIKE '%${t}%'`:"",o=e.all(`SELECT DISTINCT
771
+ WHERE m.symbol_id = ? AND m.role != 1`,t.symbolId),g=new Set(m.filter(p=>p.file!==t.relativePath).map(p=>p.symbol)).size;return{symbol:t.symbol,shortName:I(t.symbol),relativePath:t.relativePath,startLine:t.startLine,endLine:t.endLine,loc:l,branches:r,cyclomaticEstimate:r+1,calleeCount:u.size,fanIn:d?.c??0,fanOut:g}}function Ym(e,n){let t=Km(e),s=0,i=[/\bif\b/g,/\belse\s+if\b/g,/\belse\b/g,/\bfor\b/g,/\bwhile\b/g,/\bswitch\b/g,/\bcase\b/g,/\bcatch\b/g,/\?\s*[^?]/g,/&&/g,/\|\|/g];for(let o of i){let a=t.match(o);a&&(s+=a.length)}if(n==="python"){let o=[/\belif\b/g,/\bexcept\b/g,/\bfinally\b/g];for(let a of o){let r=t.match(a);r&&(s+=r.length)}}else if(n==="rust"){let o=[/\bmatch\b/g,/=>/g,/\bloop\b/g];for(let a of o){let r=t.match(a);r&&(s+=r.length)}}else if(n==="ruby"){let o=[/\belsif\b/g,/\bunless\b/g,/\brescue\b/g,/\bwhen\b/g];for(let a of o){let r=t.match(a);r&&(s+=r.length)}}else if(n==="go"){let o=[/\bselect\b/g,/\bdefer\b/g];for(let a of o){let r=t.match(a);r&&(s+=r.length)}}return s}function Km(e){return e.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/.*/g,"").replace(/#.*/g,"").replace(/"(?:[^"\\]|\\.)*"/g,'""').replace(/'(?:[^'\\]|\\.)*'/g,"''").replace(/`(?:[^`\\]|\\.)*`/g,"``")}function or(e,n){let t=k(e,n);if(!t)return null;let s=[{file:t.relativePath,line:t.startLine}],i=Pe(e,t),a=(i.length>0?i:$e(e,t)).filter(c=>!e.isIgnored(c.file)).map(c=>({file:c.file,line:c.line,enclosingSymbol:c.enclosingSymbol??"(top-level)",enclosingShort:c.enclosingSymbol?I(c.enclosingSymbol):"(top-level)"})),{producers:r,consumers:l}=Qm(e,t,a);return{symbol:t.symbol,shortName:I(t.symbol),relativePath:t.relativePath,definitionSites:s.filter(c=>!e.isIgnored(c.file)),usageSites:a,producers:r.filter(c=>!e.isIgnored(c.file)).map(c=>({symbol:c.symbol,shortName:I(c.symbol),file:c.file})),consumers:l.filter(c=>!e.isIgnored(c.file)).map(c=>({symbol:c.symbol,shortName:c.symbol===c.file?"(top-level)":I(c.symbol),file:c.file}))}}function Qm(e,n,t){let s=Zn(ne(e,n,{limit:30}).map(a=>({symbol:a.symbol,file:a.file}))),i=Zn(he(e,n,{limit:30})),o=i.length>0?i:Zn(t.map(a=>({symbol:a.enclosingSymbol==="(top-level)"?a.file:a.enclosingSymbol,file:a.file})));return{producers:s,consumers:o}}function Zn(e){let n=new Set,t=[];for(let s of e){let i=`${s.symbol}|${s.file}`;n.has(i)||(n.add(i),t.push(s))}return t}function rr(e,n,t={}){let{direction:s="backward",maxDepth:i=3}=t,o=k(e,n);return o?s==="backward"?Xm(e,o,i):Zm(e,o):null}function Xm(e,n,t){let s=[],i=new Set([n.symbol]),o=[n];for(let a=1;a<=t&&o.length!==0;a++){let r=[];for(let l of o){let c=ne(e,l);for(let m of c){if(i.has(m.symbol))continue;i.add(m.symbol),s.push({symbol:m.symbol,shortName:I(m.symbol),file:m.file,relationship:a===1?"referenced within definition (callee)":`depth ${a} callee`});let u=Xe(e,m.symbol);u&&!e.isIgnored(u.relativePath)&&r.push(u)}}o=r}return{symbol:n.symbol,shortName:I(n.symbol),direction:"backward",connectedSymbols:s}}function Zm(e,n){let t=Pe(e,n),s=t.length>0?t:$e(e,n),i=new Set,o=[];for(let a of s){if(o.length>=30)break;if(e.isIgnored(a.file))continue;let r=a.enclosingSymbol??fe(A(e,a.file),a.line)?.symbol??null;if(!r||r===n.symbol)continue;let l=Xe(e,r);if(l){for(let c of ne(e,l))if(c.symbol!==n.symbol&&c.symbol!==r&&c.file!==a.file&&!e.isIgnored(c.file)&&!i.has(c.symbol)&&(i.add(c.symbol),o.push({symbol:c.symbol,shortName:I(c.symbol),file:c.file,relationship:`used alongside target in ${I(r)}`}),o.length>=30))break}}return o.sort((a,r)=>a.file.localeCompare(r.file)),{symbol:n.symbol,shortName:I(n.symbol),direction:"forward",connectedSymbols:o}}function lr(e,n={}){let{scope:t,limit:s}=n,i=t?`AND barrel_d.relative_path LIKE '%${t}%'`:"",o=e.all(`SELECT DISTINCT
772
772
  barrel_d.id AS barrel_doc_id,
773
773
  barrel_d.relative_path AS barrel_path,
774
774
  gs.id AS symbol_id,
@@ -827,16 +827,16 @@ ${d}`,c+=1+d.length,m+=ji(d),s+=d.length+1}let u=Kc(l);u&&t.push({...u,start:r,e
827
827
  AND consumer_d.id != ?
828
828
  ${e.pathExclusionsFor("consumer_d")}
829
829
  GROUP BY consumer_d.id
830
- )`,l.barrel_doc_id,l.symbol_id,l.barrel_doc_id,l.original_doc_id),m=c?.barrel_consumers??0,u=c?.direct_consumers??0;m===0&&u===0&&a.push({barrelFile:l.barrel_path,symbol:l.symbol,shortName:I(l.symbol),originalFile:l.original_path,barrelConsumers:m,directConsumers:u})}a.sort((l,c)=>c.directConsumers-l.directConsumers||l.barrelFile.localeCompare(c.barrelFile)||l.shortName.localeCompare(c.shortName));let r=td([...a,...Zm(e,t)]);return r.sort((l,c)=>c.directConsumers-l.directConsumers||l.barrelFile.localeCompare(c.barrelFile)||l.shortName.localeCompare(c.shortName)),s?r.slice(0,s):r}function Zm(e,n){let s=e.all(`SELECT relative_path
830
+ )`,l.barrel_doc_id,l.symbol_id,l.barrel_doc_id,l.original_doc_id),m=c?.barrel_consumers??0,u=c?.direct_consumers??0;m===0&&u===0&&a.push({barrelFile:l.barrel_path,symbol:l.symbol,shortName:I(l.symbol),originalFile:l.original_path,barrelConsumers:m,directConsumers:u})}a.sort((l,c)=>c.directConsumers-l.directConsumers||l.barrelFile.localeCompare(c.barrelFile)||l.shortName.localeCompare(c.shortName));let r=nd([...a,...ed(e,t)]);return r.sort((l,c)=>c.directConsumers-l.directConsumers||l.barrelFile.localeCompare(c.barrelFile)||l.shortName.localeCompare(c.shortName)),s?r.slice(0,s):r}function ed(e,n){let s=e.all(`SELECT relative_path
831
831
  FROM documents
832
832
  WHERE 1 = 1
833
833
  ${n?"AND relative_path LIKE ?":""}
834
834
  ${e.pathExclusionsFor("documents")}
835
- ORDER BY relative_path`,...n?[`%${n}%`]:[]).map(o=>o.relative_path).filter(o=>!e.isIgnored(o)).filter(o=>Jn(e,o).length>0),i=[];for(let o of s){let a=Jn(e,o).filter(l=>l.sourcePath&&!e.isIgnored(l.sourcePath));if(!(a.length===0||rr(e,o,o)>0))for(let l of a){let c=l.sourcePath,m=ed(e,c);m&&i.push({barrelFile:o,symbol:m.symbol,shortName:I(m.symbol),originalFile:c,barrelConsumers:0,directConsumers:rr(e,c,o)})}}return i}function rr(e,n,t){let s=e.all(`SELECT relative_path
835
+ ORDER BY relative_path`,...n?[`%${n}%`]:[]).map(o=>o.relative_path).filter(o=>!e.isIgnored(o)).filter(o=>Jn(e,o).length>0),i=[];for(let o of s){let a=Jn(e,o).filter(l=>l.sourcePath&&!e.isIgnored(l.sourcePath));if(!(a.length===0||ar(e,o,o)>0))for(let l of a){let c=l.sourcePath,m=td(e,c);m&&i.push({barrelFile:o,symbol:m.symbol,shortName:I(m.symbol),originalFile:c,barrelConsumers:0,directConsumers:ar(e,c,o)})}}return i}function ar(e,n,t){let s=e.all(`SELECT relative_path
836
836
  FROM documents
837
837
  WHERE 1 = 1
838
838
  ${e.pathExclusionsFor("documents")}
839
- ORDER BY relative_path`),i=new Set;for(let o of s)if(!(e.isIgnored(o.relative_path)||o.relative_path===t))for(let a of de(e,o.relative_path))a.sourcePath===n&&i.add(o.relative_path);return i.size}function ed(e,n){let t=A(e,n);return t.find(s=>ie(s.symbol)==="method")??t[0]??null}function td(e){let n=new Set,t=[];for(let s of e){let i=`${s.barrelFile}|${s.symbol}|${s.originalFile}`;n.has(i)||(n.add(i),t.push(s))}return t}function lr(e,n={}){let{scope:t,minLoc:s=1,limit:i}=n,o=new Map;for(let r of Z(e,{scope:t})){if(!r.isFunctionLike||e.isIgnored(r.relativePath))continue;let l=r.endLine-r.startLine+1;if(l<s)continue;let c=nd(e,r);if(!c)continue;let m={symbol:r.symbol,shortName:I(r.symbol),file:r.relativePath,startLine:r.startLine,endLine:r.endLine,loc:l},u=o.get(c);u?u.push(m):o.set(c,[m])}let a=[];for(let[r,l]of o)l.length<2||a.push({signature:r,functions:l});return a.sort((r,l)=>{let c=l.functions.length-r.functions.length;if(c!==0)return c;let m=r.functions.reduce((d,g)=>d+g.loc,0);return l.functions.reduce((d,g)=>d+g.loc,0)-m}),i?a.slice(0,i):a}function nd(e,n){let t=sd(n.documentation),s=t?rd(t):null;return s||ad(id(e,n.relativePath,n.startLine,n.endLine,n.leaf),n.leaf)}function sd(e){if(!e||!e.includes("|"))return null;let n=e.slice(e.indexOf("|")+1).replace(/\n/g," ").trim();return n.length>0?n:null}function id(e,n,t,s,i){let o=M(e,n);if(!o)return null;let a=o.split(/\r?\n/),r=ld(a,t,s,i);for(let l of r){let c=Math.min(a.length-1,Math.max(l,l+4)),m="";for(let u=l;u<=c;u+=1){let d=a[u]?.trim();if(d&&(m=m?`${m} ${d}`:d,od(m)))return m}if(m&&m.includes("("))return m}return null}function od(e){let n=e.replace(/\s+/g," ").trim();return!n.includes("(")||cd(n)>0?!1:/[;{]$/.test(n)||/\)\s*(?::\s*[^={]+)?\s*(?:=>|=|throws\b|where\b|$)/i.test(n)||/\)\s*As\s+.+$/i.test(n)}function rd(e){if(!e||!e.trim())return null;let n=e.replace(/^```\w*\s*/,"").replace(/\s*```$/,"").replace(/^\(method\)\s*/,"").replace(/^\(property\)\s*/,"").replace(/^\(function\)\s*/,"").replace(/^\(class\)\s*/,"").replace(/^\(interface\)\s*/,"").replace(/^\(enum\)\s*/,"").replace(/^\(type alias\)\s*/,"").replace(/^\(const\)\s*/,"").replace(/^\(var\)\s*/,"").trim(),t=n.indexOf("(");return t===-1||(n=n.slice(t),n=n.replace(/\s+/g,"").toLowerCase(),n.length<3)?null:n}function ad(e,n){if(!e||!e.trim())return null;let t=e.replace(/\s+/g," ").trim(),s=t.indexOf("(");if(s===-1)return null;let i=t.slice(0,s),a=new RegExp(`\\b${cr(n)}\\b`,"i").exec(i);a&&typeof a.index=="number"&&(i=i.slice(0,a.index)),i=i.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 r=t.slice(s).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(!r.startsWith("("))return null;let l=`${i?`${i} `:""}${r}`.replace(/\s+/g,"").toLowerCase();return l.length>=3?l:null}function ld(e,n,t,s){let i=cr(s),o=new RegExp(`\\b${i}\\b\\s*\\(`,"i"),a=new RegExp(`\\bdef\\s+${i}\\b`,"i"),r=[],l=new Set,c=Math.max(0,Math.min(n,e.length-1)),m=Math.max(c,Math.min(e.length-1,Math.max(t,n+4)));for(let u=c;u<=m;u+=1){let d=e[u]??"";(o.test(d)||a.test(d))&&!l.has(u)&&(l.add(u),r.push(u))}for(let u=0;u<e.length;u+=1){let d=e[u]??"";(o.test(d)||a.test(d))&&!l.has(u)&&(l.add(u),r.push(u))}return r}function cd(e){let n=0;for(let t of e)t==="("&&(n+=1),t===")"&&(n-=1);return n}function cr(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}import{existsSync as es,mkdirSync as ud,symlinkSync as md,readlinkSync as dd,unlinkSync as pd}from"fs";import{join as gn,dirname as ur,resolve as ts}from"path";import{homedir as mr,platform as fd}from"os";import{fileURLToPath as gd}from"url";var hd=fd()==="win32",ns=["concrete-plan","scip-explore","scip-debloat","scip-verify","scip-language-playbook"];function dr(e={}){let n=e.quiet?()=>{}:console.log,t=gd(import.meta.url),s=ts(ur(t),"..","skills"),i=[gn(mr(),".claude","skills"),gn(mr(),".codex","skills")],o={installed:[],skipped:[],alreadyLinked:[]};for(let a of i){let r=ur(a);if(!es(r))continue;ud(a,{recursive:!0});let l=a.includes(".codex")?"Codex":"Claude";for(let c of ns){let m=gn(s,c),u=gn(a,c);if(!es(m)){o.skipped.push(`${l}/${c}`);continue}if(es(u)){try{let d=dd(u);if(ts(d)===ts(m)){o.alreadyLinked.push(`${l}/${c}`),n(` ok: ${c} \u2192 ${l} (already linked)`);continue}}catch{o.skipped.push(`${l}/${c}`),n(` skip: ${c} \u2192 ${l} (exists, not a symlink)`);continue}pd(u)}md(m,u,hd?"junction":"dir"),o.installed.push(`${l}/${c}`),n(` done: ${c} \u2192 ${l}`)}}return o}function Ee(e){return e+1}function be(e,n){return`${Ee(e)}-${Ee(n)}`}function Se(e,n,t){return`${e}:${be(n,t)}`}var N={empty(e){console.log(e)},list(e,n){for(let t of e)console.log(n(t))},groupedByFile(e,n,t=s=>s.relativePath){let s="";for(let i of e){let o=t(i);o!==s&&(s&&console.log(""),console.log(o),s=o),console.log(n(i))}},sectionedReport(e){let n=!0;for(let t of e)if(!(t.skipIfEmpty&&t.rows.length===0)){n||console.log(""),n=!1,t.title!==void 0&&console.log(`\u2550\u2550\u2550 ${t.title} \u2550\u2550\u2550`),t.explanation!==void 0&&console.log(t.explanation);for(let s of t.rows)console.log(s)}},table(e,n,t){console.log(` ${e.join(" ")}`);let s=t??e.map(i=>i.length);console.log(` ${s.map(i=>"\u2500".repeat(i)).join(" ")}`);for(let i of n)console.log(i)}};var _d=yd(import.meta.url),{version:xd}=_d("../package.json");function Me(){return process.env.SCIP_QUERY_PROJECT_ROOT??process.cwd()}function yn(e){let n=Te(e),t=Ae(e,n);return process.env.SCIP_QUERY_INDEX_DB??(hn(t.dbPath)?t.dbPath:bd(e,"index.db"))}function Id(){let e=Me(),n=Te(e),t=Ae(e,n),s=yn(e);hn(s)||(console.error("error: No index.db found. Run: scip-query reindex"),process.exit(1));let i={dbPath:s,indexPath:process.env.SCIP_QUERY_INDEX_SCIP??t.indexPath,projectRoot:e,entryRoots:n.entryRoots},o=Ue(e);return new Lt(i,o)}function E(e){let n=Id();try{e(n)}finally{n.close()}}var C={stats:Bt,files:qs,symbols:di,methods:pi,refs:Qi,trace:Xi,deps:Zi,rdeps:eo,system:to,surface:no,dead:tn,hotspots:lo,imports:uo,importedBy:mo,unusedImports:po,outline:go,members:ho,fanIn:yo,fanOut:bo,topFanIn:So,topFanOut:_o,coupling:xo,topCoupling:Io,cycles:nn,bottlenecks:Co,isolated:sn,byKind:Eo,kindCounts:Ro,deepChains:Do,hierarchy:ko,callGraph:Oo,similar:Mo,similarAll:on,similarFiles:Wo,similarChains:Jo,extractCandidates:an,affected:qo,changeSurface:zo,diffImpact:Vo,drift:cn,wrapperCandidates:mn,passthroughCandidates:dn,staleAbstractions:pn,complexityHotspots:fn,health:Xo,convergence:Zo,code:nr,complexity:sr,dataflow:ir,slice:or,redundantReexports:ar,similarSignatures:lr};v.name("scip-query").description("Language-agnostic code intelligence CLI powered by SCIP indexes").version(xd);v.command("reindex").description("Index the codebase and convert to SQLite").option("-l, --language <lang>","Index only this language (can be repeated)",vd,[]).option("--pnpm-workspaces","Enable pnpm workspace support (TypeScript)").action(async e=>{let n=Me(),t=Te(n),s=Ae(n,t);try{let i=await Hs({projectRoot:n,languages:e.language.length>0?e.language:t.languages,outputScip:s.indexPath,outputDb:s.dbPath,pnpmWorkspaces:e.pnpmWorkspaces||t.indexer?.typescript?.pnpmWorkspaces});console.log(`Indexed ${i.languages.join(", ")} in ${(i.durationMs/1e3).toFixed(1)}s`)}catch(i){console.error(`error: ${i instanceof Error?i.message:i}`),process.exit(1)}});v.command("augment-sources").description("Add source files skipped by upstream SCIP indexers to the SQLite documents table").action(()=>{let e=Me(),n=yn(e);try{let t=Be({projectRoot:e,dbPath:n,onStatus:s=>console.log(s)});console.log(`Scanned ${t.scanned} auxiliary source files; inserted ${t.inserted}.`)}catch(t){console.error(`error: ${t instanceof Error?t.message:t}`),process.exit(1)}});v.command("augment-vue").description("Add compiler-resolved Vue SFC references to the SQLite index using Volar").option("--project <tsconfig>","Vue tsconfig path","frontend/tsconfig.scip.json").action(e=>{let n=Me(),t=yn(n);try{let s=On({projectRoot:n,dbPath:t,tsconfig:e.project,onStatus:i=>console.log(i)});console.log(`Vue files: ${s.vueFiles}; resolved references: ${s.resolvedReferences}; inserted mentions: ${s.insertedMentions}.`)}catch(s){console.error(`error: ${s instanceof Error?s.message:s}`),process.exit(1)}});v.command("stats").description("Show index statistics").action(()=>E(e=>{let n=C.stats(e);console.log(`Documents: ${n.documents}`),console.log(`Symbols: ${n.symbols}`),console.log(`Definitions: ${n.definitions}`),console.log(`References: ${n.references}`),console.log(`Index size: ${ss(n.indexSizeBytes)}`),n.lastBuilt&&console.log(`Last built: ${n.lastBuilt.toISOString().replace("T"," ").slice(0,19)}`)}));v.command("files <pattern>").description("Find files matching a pattern").action(e=>E(n=>{N.list(C.files(n,e),t=>t.relativePath)}));v.command("symbols <file>").description("List symbols defined in a file (with line ranges + signatures)").action(e=>E(n=>{N.list(C.symbols(n,e),t=>{let s=t.signature?` \u2014 ${t.signature}`:"";return` ${be(t.startLine,t.endLine)} ${t.shortName}${s}`})}));v.command("methods <className>").description("List methods of a class (with line ranges)").action(e=>E(n=>{N.list(C.methods(n,e),t=>` ${be(t.startLine,t.endLine)} ${t.name}`)}));v.command("refs <symbol>").description("Find all files referencing a symbol").action(e=>E(n=>{N.groupedByFile(C.refs(n,e),t=>` line ${Ee(t.line)}`)}));v.command("trace <symbol>").description("Trace a symbol: definition + all references").action(e=>E(n=>{let t=C.trace(n,e),s=[];for(let a of t.definitions){let r=a.signature?` \u2014 ${a.signature}`:"";s.push(` ${Se(a.relativePath,a.startLine,a.endLine)}${r}`),a.source&&s.push(a.source.split(`
839
+ ORDER BY relative_path`),i=new Set;for(let o of s)if(!(e.isIgnored(o.relative_path)||o.relative_path===t))for(let a of de(e,o.relative_path))a.sourcePath===n&&i.add(o.relative_path);return i.size}function td(e,n){let t=A(e,n);return t.find(s=>ie(s.symbol)==="method")??t[0]??null}function nd(e){let n=new Set,t=[];for(let s of e){let i=`${s.barrelFile}|${s.symbol}|${s.originalFile}`;n.has(i)||(n.add(i),t.push(s))}return t}function cr(e,n={}){let{scope:t,minLoc:s=1,limit:i}=n,o=new Map;for(let r of Z(e,{scope:t})){if(!r.isFunctionLike||e.isIgnored(r.relativePath))continue;let l=r.endLine-r.startLine+1;if(l<s)continue;let c=sd(e,r);if(!c)continue;let m={symbol:r.symbol,shortName:I(r.symbol),file:r.relativePath,startLine:r.startLine,endLine:r.endLine,loc:l},u=o.get(c);u?u.push(m):o.set(c,[m])}let a=[];for(let[r,l]of o)l.length<2||a.push({signature:r,functions:l});return a.sort((r,l)=>{let c=l.functions.length-r.functions.length;if(c!==0)return c;let m=r.functions.reduce((d,g)=>d+g.loc,0);return l.functions.reduce((d,g)=>d+g.loc,0)-m}),i?a.slice(0,i):a}function sd(e,n){let t=id(n.documentation),s=t?ad(t):null;return s||ld(od(e,n.relativePath,n.startLine,n.endLine,n.leaf),n.leaf)}function id(e){if(!e||!e.includes("|"))return null;let n=e.slice(e.indexOf("|")+1).replace(/\n/g," ").trim();return n.length>0?n:null}function od(e,n,t,s,i){let o=M(e,n);if(!o)return null;let a=o.split(/\r?\n/),r=cd(a,t,s,i);for(let l of r){let c=Math.min(a.length-1,Math.max(l,l+4)),m="";for(let u=l;u<=c;u+=1){let d=a[u]?.trim();if(d&&(m=m?`${m} ${d}`:d,rd(m)))return m}if(m&&m.includes("("))return m}return null}function rd(e){let n=e.replace(/\s+/g," ").trim();return!n.includes("(")||ud(n)>0?!1:/[;{]$/.test(n)||/\)\s*(?::\s*[^={]+)?\s*(?:=>|=|throws\b|where\b|$)/i.test(n)||/\)\s*As\s+.+$/i.test(n)}function ad(e){if(!e||!e.trim())return null;let n=e.replace(/^```\w*\s*/,"").replace(/\s*```$/,"").replace(/^\(method\)\s*/,"").replace(/^\(property\)\s*/,"").replace(/^\(function\)\s*/,"").replace(/^\(class\)\s*/,"").replace(/^\(interface\)\s*/,"").replace(/^\(enum\)\s*/,"").replace(/^\(type alias\)\s*/,"").replace(/^\(const\)\s*/,"").replace(/^\(var\)\s*/,"").trim(),t=n.indexOf("(");return t===-1||(n=n.slice(t),n=n.replace(/\s+/g,"").toLowerCase(),n.length<3)?null:n}function ld(e,n){if(!e||!e.trim())return null;let t=e.replace(/\s+/g," ").trim(),s=t.indexOf("(");if(s===-1)return null;let i=t.slice(0,s),a=new RegExp(`\\b${ur(n)}\\b`,"i").exec(i);a&&typeof a.index=="number"&&(i=i.slice(0,a.index)),i=i.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 r=t.slice(s).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(!r.startsWith("("))return null;let l=`${i?`${i} `:""}${r}`.replace(/\s+/g,"").toLowerCase();return l.length>=3?l:null}function cd(e,n,t,s){let i=ur(s),o=new RegExp(`\\b${i}\\b\\s*\\(`,"i"),a=new RegExp(`\\bdef\\s+${i}\\b`,"i"),r=[],l=new Set,c=Math.max(0,Math.min(n,e.length-1)),m=Math.max(c,Math.min(e.length-1,Math.max(t,n+4)));for(let u=c;u<=m;u+=1){let d=e[u]??"";(o.test(d)||a.test(d))&&!l.has(u)&&(l.add(u),r.push(u))}for(let u=0;u<e.length;u+=1){let d=e[u]??"";(o.test(d)||a.test(d))&&!l.has(u)&&(l.add(u),r.push(u))}return r}function ud(e){let n=0;for(let t of e)t==="("&&(n+=1),t===")"&&(n-=1);return n}function ur(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}import{existsSync as es,mkdirSync as md,symlinkSync as dd,readlinkSync as pd,unlinkSync as fd}from"fs";import{join as gn,dirname as mr,resolve as ts}from"path";import{homedir as dr,platform as gd}from"os";import{fileURLToPath as hd}from"url";var yd=gd()==="win32",ns=["concrete-plan","scip-explore","scip-debloat","scip-verify","scip-language-playbook"];function pr(e={}){let n=e.quiet?()=>{}:console.log,t=hd(import.meta.url),s=ts(mr(t),"..","skills"),i=[gn(dr(),".claude","skills"),gn(dr(),".codex","skills")],o={installed:[],skipped:[],alreadyLinked:[]};for(let a of i){let r=mr(a);if(!es(r))continue;md(a,{recursive:!0});let l=a.includes(".codex")?"Codex":"Claude";for(let c of ns){let m=gn(s,c),u=gn(a,c);if(!es(m)){o.skipped.push(`${l}/${c}`);continue}if(es(u)){try{let d=pd(u);if(ts(d)===ts(m)){o.alreadyLinked.push(`${l}/${c}`),n(` ok: ${c} \u2192 ${l} (already linked)`);continue}}catch{o.skipped.push(`${l}/${c}`),n(` skip: ${c} \u2192 ${l} (exists, not a symlink)`);continue}fd(u)}dd(m,u,yd?"junction":"dir"),o.installed.push(`${l}/${c}`),n(` done: ${c} \u2192 ${l}`)}}return o}function Ee(e){return e+1}function be(e,n){return`${Ee(e)}-${Ee(n)}`}function Se(e,n,t){return`${e}:${be(n,t)}`}var N={empty(e){console.log(e)},list(e,n){for(let t of e)console.log(n(t))},groupedByFile(e,n,t=s=>s.relativePath){let s="";for(let i of e){let o=t(i);o!==s&&(s&&console.log(""),console.log(o),s=o),console.log(n(i))}},sectionedReport(e){let n=!0;for(let t of e)if(!(t.skipIfEmpty&&t.rows.length===0)){n||console.log(""),n=!1,t.title!==void 0&&console.log(`\u2550\u2550\u2550 ${t.title} \u2550\u2550\u2550`),t.explanation!==void 0&&console.log(t.explanation);for(let s of t.rows)console.log(s)}},table(e,n,t){console.log(` ${e.join(" ")}`);let s=t??e.map(i=>i.length);console.log(` ${s.map(i=>"\u2500".repeat(i)).join(" ")}`);for(let i of n)console.log(i)}};var xd=bd(import.meta.url),{version:Id}=xd("../package.json");function Me(){return process.env.SCIP_QUERY_PROJECT_ROOT??process.cwd()}function yn(e){let n=Te(e),t=Ae(e,n);return process.env.SCIP_QUERY_INDEX_DB??(hn(t.dbPath)?t.dbPath:Sd(e,"index.db"))}function Nd(){let e=Me(),n=Te(e),t=Ae(e,n),s=yn(e);hn(s)||(console.error("error: No index.db found. Run: scip-query reindex"),process.exit(1));let i={dbPath:s,indexPath:process.env.SCIP_QUERY_INDEX_SCIP??t.indexPath,projectRoot:e,entryRoots:n.entryRoots},o=Ue(e);return new Lt(i,o)}function E(e){let n=Nd();try{e(n)}finally{n.close()}}var C={stats:Bt,files:qs,symbols:pi,methods:fi,refs:Xi,trace:Zi,deps:eo,rdeps:to,system:no,surface:so,dead:tn,hotspots:co,imports:mo,importedBy:po,unusedImports:fo,outline:ho,members:yo,fanIn:bo,fanOut:So,topFanIn:_o,topFanOut:xo,coupling:Io,topCoupling:No,cycles:nn,bottlenecks:Eo,isolated:sn,byKind:Ro,kindCounts:Lo,deepChains:ko,hierarchy:Oo,callGraph:$o,similar:Fo,similarAll:on,similarFiles:Ho,similarChains:Uo,extractCandidates:an,affected:zo,changeSurface:Vo,diffImpact:Go,drift:cn,wrapperCandidates:mn,passthroughCandidates:dn,staleAbstractions:pn,complexityHotspots:fn,health:Zo,convergence:er,code:sr,complexity:ir,dataflow:or,slice:rr,redundantReexports:lr,similarSignatures:cr};v.name("scip-query").description("Language-agnostic code intelligence CLI powered by SCIP indexes").version(Id);v.command("reindex").description("Index the codebase and convert to SQLite").option("-l, --language <lang>","Index only this language (can be repeated)",Cd,[]).option("--pnpm-workspaces","Enable pnpm workspace support (TypeScript)").action(async e=>{let n=Me(),t=Te(n),s=Ae(n,t);try{let i=await Hs({projectRoot:n,languages:e.language.length>0?e.language:t.languages,outputScip:s.indexPath,outputDb:s.dbPath,pnpmWorkspaces:e.pnpmWorkspaces||t.indexer?.typescript?.pnpmWorkspaces});console.log(`Indexed ${i.languages.join(", ")} in ${(i.durationMs/1e3).toFixed(1)}s`)}catch(i){console.error(`error: ${i instanceof Error?i.message:i}`),process.exit(1)}});v.command("augment-sources").description("Add source files skipped by upstream SCIP indexers to the SQLite documents table").action(()=>{let e=Me(),n=yn(e);try{let t=Be({projectRoot:e,dbPath:n,onStatus:s=>console.log(s)});console.log(`Scanned ${t.scanned} auxiliary source files; inserted ${t.inserted}.`)}catch(t){console.error(`error: ${t instanceof Error?t.message:t}`),process.exit(1)}});v.command("augment-vue").description("Add compiler-resolved Vue SFC references to the SQLite index using Volar").option("--project <tsconfig>","Vue tsconfig path","frontend/tsconfig.scip.json").action(e=>{let n=Me(),t=yn(n);try{let s=On({projectRoot:n,dbPath:t,tsconfig:e.project,onStatus:i=>console.log(i)});console.log(`Vue files: ${s.vueFiles}; resolved references: ${s.resolvedReferences}; inserted mentions: ${s.insertedMentions}.`)}catch(s){console.error(`error: ${s instanceof Error?s.message:s}`),process.exit(1)}});v.command("stats").description("Show index statistics").action(()=>E(e=>{let n=C.stats(e);console.log(`Documents: ${n.documents}`),console.log(`Symbols: ${n.symbols}`),console.log(`Definitions: ${n.definitions}`),console.log(`References: ${n.references}`),console.log(`Index size: ${ss(n.indexSizeBytes)}`),n.lastBuilt&&console.log(`Last built: ${n.lastBuilt.toISOString().replace("T"," ").slice(0,19)}`)}));v.command("files <pattern>").description("Find files matching a pattern").action(e=>E(n=>{N.list(C.files(n,e),t=>t.relativePath)}));v.command("symbols <file>").description("List symbols defined in a file (with line ranges + signatures)").action(e=>E(n=>{N.list(C.symbols(n,e),t=>{let s=t.signature?` \u2014 ${t.signature}`:"";return` ${be(t.startLine,t.endLine)} ${t.shortName}${s}`})}));v.command("methods <className>").description("List methods of a class (with line ranges)").action(e=>E(n=>{N.list(C.methods(n,e),t=>` ${be(t.startLine,t.endLine)} ${t.name}`)}));v.command("refs <symbol>").description("Find all files referencing a symbol").action(e=>E(n=>{N.groupedByFile(C.refs(n,e),t=>` line ${Ee(t.line)}`)}));v.command("trace <symbol>").description("Trace a symbol: definition + all references").action(e=>E(n=>{let t=C.trace(n,e),s=[];for(let a of t.definitions){let r=a.signature?` \u2014 ${a.signature}`:"";s.push(` ${Se(a.relativePath,a.startLine,a.endLine)}${r}`),a.source&&s.push(a.source.split(`
840
840
  `).map((l,c)=>` ${Ee(a.startLine+c)} ${l}`).join(`
841
841
  `))}let i=[],o="";for(let a of t.referencedBy)a.relativePath!==o&&(o&&i.push(""),i.push(` ${a.relativePath}`),o=a.relativePath),i.push(` line ${Ee(a.line)} in ${a.enclosingShort}`);N.sectionedReport([{title:"DEFINITION",rows:s},{title:"REFERENCED BY",rows:i}])}));v.command("deps <file>").description("Files this file depends on (internal)").action(e=>E(n=>{N.list(C.deps(n,e),t=>t.relativePath)}));v.command("rdeps <file>").description("Files that depend on this file/module").action(e=>E(n=>{N.list(C.rdeps(n,e),t=>t.relativePath)}));v.command("system <module>").description("Full module map: files, symbols, deps in/out").action(e=>E(n=>{let t=C.system(n,e);N.sectionedReport([{title:"FILES",rows:t.files},{title:"EXPORTED SYMBOLS",rows:t.symbols.map(s=>` ${be(s.startLine,s.endLine)} ${s.shortName}`)},{title:"DEPENDS ON (internal)",rows:t.dependsOn.map(s=>` ${s}`)},{title:"DEPENDED ON BY",rows:t.dependedOnBy.map(s=>` ${s}`)}])}));v.command("surface <module>").description("What symbols consumers actually use from this module").action(e=>E(n=>{N.list(C.surface(n,e),t=>` ${t.consumer} \u2192 ${t.shortName}`)}));v.command("dead [scope]").description("Find dead code and file-internal symbols (no cross-file consumers)").option("--min-loc <n>","Only show symbols >= N lines",D,1).option("--include-tests","Include test files").option("--skip-barrels","Ignore refs from barrel re-export files").option("--include-members","Include class members").option("--only-dead","Show only [dead code] symbols (skip [file-internal only])").option("--only-internal","Show only [file-internal only] symbols (skip [dead code])").action((e,n)=>E(t=>{let s={scope:e||void 0,minLoc:n.minLoc,includeTests:n.includeTests,skipBarrels:n.skipBarrels,includeMembers:n.includeMembers},i=C.dead(t,s);if(i.symbols.length===0)return N.empty("No dead code found.");let o=i.symbols.filter(d=>d.kind==="dead-code"),a=i.symbols.filter(d=>d.kind!=="dead-code"),r=!n.onlyInternal,l=!n.onlyDead,c=(d,g,p,f)=>{console.log(`\u2550\u2550\u2550 ${g} (${d.length}, ${f} LOC) \u2550\u2550\u2550`),console.log(p),console.log("");let y=new Map;for(let _ of d){let S=y.get(_.relativePath)??[];S.push(_),y.set(_.relativePath,S)}let h=[...y.entries()].map(([_,S])=>({file:_,bucket:S,totalLoc:S.reduce((x,L)=>x+L.loc,0)})).sort((_,S)=>S.totalLoc-_.totalLoc||_.file.localeCompare(S.file)),b=!0;for(let{file:_,bucket:S}of h){b||console.log(""),b=!1,console.log(` ${_}`),S.sort((x,L)=>x.startLine-L.startLine);for(let x of S)console.log(` ${be(x.startLine,x.endLine)} (${x.loc} LOC) ${x.shortName}`)}},m=o.reduce((d,g)=>d+g.loc,0),u=a.reduce((d,g)=>d+g.loc,0);r&&o.length>0&&c(o,"DEAD CODE",` Zero references anywhere \u2014 no cross-file callers AND no same-file uses.
842
842
  Safe to delete.`,m),l&&a.length>0&&(r&&o.length>0&&console.log(""),c(a,"FILE-INTERNAL ONLY",` Used only within the same file (no cross-file callers). Could be a
@@ -899,7 +899,7 @@ ${Math.round(s.similarity*100)}% callee overlap
899
899
  \u2550\u2550\u2550 CONSUMERS (this feeds into) \u2550\u2550\u2550`);for(let s of t.consumers)console.log(` ${s.file} ${s.shortName}`)}}));v.command("slice <symbol>").description("Reference-level program slice: what affects this (backward) or what this affects (forward)").option("--forward","Forward slice (what does this affect). Default is backward.").option("--depth <n>","Max transitive depth for backward slice",D,3).action((e,n)=>E(t=>{let s=n.forward?"forward":"backward",i=C.slice(t,e,{direction:s,maxDepth:n.depth});if(!i)return N.empty("Symbol not found.");if(console.log(`${i.direction} slice of ${i.shortName}
900
900
  `),i.connectedSymbols.length===0){console.log(" No connected symbols found.");return}N.list(i.connectedSymbols,o=>` ${o.file} ${o.shortName}
901
901
  ${o.relationship}`),console.log(`
902
- ${i.connectedSymbols.length} connected symbol(s).`)}));v.command("install-skills").description(`Install skills (${ns.join(", ")}) into Claude Code and Codex`).action(()=>{let e=dr(),n=e.installed.length+e.alreadyLinked.length;console.log(`
902
+ ${i.connectedSymbols.length} connected symbol(s).`)}));v.command("install-skills").description(`Install skills (${ns.join(", ")}) into Claude Code and Codex`).action(()=>{let e=pr(),n=e.installed.length+e.alreadyLinked.length;console.log(`
903
903
  ${e.installed.length} installed, ${e.alreadyLinked.length} already linked, ${e.skipped.length} skipped.`),n>0&&console.log("Skills will be available in your next Claude Code / Codex session.")});v.command("check-deps").description("Check whether scip-query and the detected language indexers are actually runnable").action(()=>{let e=!1;Nn()?console.log("scip CLI: installed"):(vn(),e=!0);let n=Me(),s=Te(n).languages??qe(n);if(s.length===0){console.log(`
904
904
  No supported project languages detected in the current directory.`),process.exitCode=e?1:0;return}console.log(`
905
905
  Detected languages: ${s.join(", ")}`),console.log(`
@@ -909,9 +909,9 @@ ${t.length} redundant re-export(s).`)}));v.command("similar-signatures").descrip
909
909
  Signature: ${s.signature} (${s.functions.length} functions)`,o=s.functions.map(a=>` ${Se(a.file,a.startLine,a.endLine)} ${a.shortName} (${a.loc} LOC)`).join(`
910
910
  `);return`${i}
911
911
  ${o}`}),console.log(`
912
- ${t.length} group(s) found.`)}));v.command("init").description("Create a .scipquery.json config file for this project").action(()=>{let e=Me(),n=qe(e),t=ds(e,n);console.log(`Config written to ${t}`),console.log(`Detected languages: ${n.join(", ")||"(none)"}`)});v.command("watch").description("Watch for file changes and reindex automatically").option("--debounce <ms>","Ms to wait after last change (default: 30000)",parseInt).option("--cooldown <ms>","Min ms between reindexes (default: 60000)",parseInt).action(e=>{let n=Me(),t=Te(n);e.debounce&&((t.watch??={}).debounceMs=e.debounce),e.cooldown&&((t.watch??={}).cooldownMs=e.cooldown);let s=new jt({projectRoot:n,config:t,languages:t.languages,onStatus:i=>{process.stdout.write(`\r\x1B[K${Cd(i)}`)},onReindexComplete:i=>{console.log(`
912
+ ${t.length} group(s) found.`)}));v.command("init").description("Create a .scipquery.json config file for this project").action(()=>{let e=Me(),n=qe(e),t=ds(e,n);console.log(`Config written to ${t}`),console.log(`Detected languages: ${n.join(", ")||"(none)"}`)});v.command("watch").description("Watch for file changes and reindex automatically").option("--debounce <ms>","Ms to wait after last change (default: 30000)",parseInt).option("--cooldown <ms>","Min ms between reindexes (default: 60000)",parseInt).action(e=>{let n=Me(),t=Te(n);e.debounce&&((t.watch??={}).debounceMs=e.debounce),e.cooldown&&((t.watch??={}).cooldownMs=e.cooldown);let s=new jt({projectRoot:n,config:t,languages:t.languages,onStatus:i=>{process.stdout.write(`\r\x1B[K${Ed(i)}`)},onReindexComplete:i=>{console.log(`
913
913
  Reindex complete in ${(i/1e3).toFixed(1)}s`)},onError:i=>{console.error(`
914
914
  Watch error: ${i.message}`)}});console.log(`Watching ${n}`),console.log(`Debounce: ${t.watch?.debounceMs??3e4}ms | Cooldown: ${t.watch?.cooldownMs??6e4}ms`),console.log(`Press Ctrl+C to stop.
915
915
  `),s.start(),process.on("SIGINT",()=>{s.stop(),console.log(`
916
- Stopped.`),process.exit(0)})});v.command("status").description("Show index status for this project").action(()=>{let e=Me(),n=Te(e),t=Ae(e,n),s=yn(e);console.log(`Project: ${e}`),console.log(`DB path: ${s}`),s!==t.dbPath&&console.log(`Config: ${t.dbPath} (fallback to project root index.db)`),console.log(`Exists: ${hn(s)?"yes":"no"}`),hn(s)&&E(i=>{let o=C.stats(i);if(console.log(`Symbols: ${o.symbols}`),console.log(`Files: ${o.documents}`),console.log(`Size: ${ss(o.indexSizeBytes)}`),o.lastBuilt){let a=Math.round((Date.now()-o.lastBuilt.getTime())/1e3);console.log(`Built: ${a}s ago`)}})});Nd()&&v.parse();function Nd(){if(!process.argv[1])return!1;let e=Sd(import.meta.url);try{return pr(e)===pr(process.argv[1])}catch{return e===process.argv[1]}}function vd(e,n){return n.concat([e])}function D(e){return parseInt(e,10)}function ss(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(0)} KB`:e<1024*1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:`${(e/(1024*1024*1024)).toFixed(1)} GB`}function Cd(e){switch(e.state){case"idle":return"Watching (idle)";case"waiting":{let n=Math.round((e.reindexAt-Date.now())/1e3);return`${e.changedFiles} file(s) changed, reindexing in ${n}s...`}case"indexing":return`Reindexing... (${Math.round((Date.now()-e.startedAt)/1e3)}s)`;case"cooldown":return`Cooldown (${Math.round((e.until-Date.now())/1e3)}s)${e.dirty?" \u2014 changes pending":""}`}}export{v as program};
916
+ Stopped.`),process.exit(0)})});v.command("status").description("Show index status for this project").action(()=>{let e=Me(),n=Te(e),t=Ae(e,n),s=yn(e);console.log(`Project: ${e}`),console.log(`DB path: ${s}`),s!==t.dbPath&&console.log(`Config: ${t.dbPath} (fallback to project root index.db)`),console.log(`Exists: ${hn(s)?"yes":"no"}`),hn(s)&&E(i=>{let o=C.stats(i);if(console.log(`Symbols: ${o.symbols}`),console.log(`Files: ${o.documents}`),console.log(`Size: ${ss(o.indexSizeBytes)}`),o.lastBuilt){let a=Math.round((Date.now()-o.lastBuilt.getTime())/1e3);console.log(`Built: ${a}s ago`)}})});vd()&&v.parse();function vd(){if(!process.argv[1])return!1;let e=_d(import.meta.url);try{return fr(e)===fr(process.argv[1])}catch{return e===process.argv[1]}}function Cd(e,n){return n.concat([e])}function D(e){return parseInt(e,10)}function ss(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(0)} KB`:e<1024*1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:`${(e/(1024*1024*1024)).toFixed(1)} GB`}function Ed(e){switch(e.state){case"idle":return"Watching (idle)";case"waiting":{let n=Math.round((e.reindexAt-Date.now())/1e3);return`${e.changedFiles} file(s) changed, reindexing in ${n}s...`}case"indexing":return`Reindexing... (${Math.round((Date.now()-e.startedAt)/1e3)}s)`;case"cooldown":return`Cooldown (${Math.round((e.until-Date.now())/1e3)}s)${e.dirty?" \u2014 changes pending":""}`}}export{v as program};
917
917
  //# sourceMappingURL=cli.js.map